element"),X=1);const r=`wrapper-${s}`;t.innerHTML=`
${t.innerHTML}
`,console.warn(`The template "${s}" contains ${e.length} child elements that have been wrapped in a div element with attribute "${r}".`)}else if(0===e.length)throw new Error(`The template "${s}" needs to have at least one child element`);r[s]=t,t.remove()}G(t,"x-fill:not([name])",(t=>{if(t.querySelector("x-fill:not([name])"))throw`Don't fill unnamed x-fills with unnamed x-fill elements!!!\n${t.outerHTML}`;const r=`t${e()}`;t.setAttribute("name",r);const n=document.createElement("template");n.setAttribute("name",r),n.innerHTML=t.innerHTML,t.innerHTML="",t.appendChild(n)})),G(t,"x-if,x-else-if,x-else",(e=>{const t=e.children[0];t&&"TEMPLATE"===t.tagName||(e.innerHTML=`
${e.innerHTML}`)})),G(t,"template",(e=>{const t=Y(e);Object.keys(t).forEach((e=>{if(r[e])throw new Error(`Template "${e}" already exists`)})),r={...r,...t}})),Array.from(t.content.children).forEach((e=>K(e)));for(let[e,r]of Object.entries(n))G(t,`[code-id="${e}"]`,(e=>{e.removeAttribute("code-id"),e.innerHTML=r}));return r},Z=e=>d(e)?e():e,Q={prop(...e){let[t,r]=e;if(1===e.length)return this[t];r=Z(r),t=u(t),this.set(t,r)},attr(...e){let[t,r]=e;if(1===e.length)return this.ele.getAttribute(t);r=Z(r),null===r?this.ele.removeAttribute(t):this.ele.setAttribute(t,r)},class(...e){let[t,r]=e;if(1===e.length)return this.ele.classList.contains(t);r=Z(r),r?this.ele.classList.add(t):this.ele.classList.remove(t)}};Q.prop.always=!0,Q.attr.always=!0,Q.class.always=!0,Q.prop.revoke=({target:e,args:t,$ele:r,data:n})=>{const s=t[0];e.set(s,null)};const ee={sync(e,t,r){if(!r)throw"Sync is only allowed within the renderer";[e,t]=r.beforeArgs;const{data:n}=r;if(n.get(t)instanceof Object){const e=`Object values cannot be synchronized using the sync function : ${t}`;throw console.log(e,n),new Error(e)}this[e]=n.get(t);const s=this.watch((r=>{if(r.hasModified(e))try{const r=this.get(e);n.set(t,r)}catch(e){}})),i=n.watch((r=>{if(r.hasModified(t))try{const r=n.get(t);this.set(e,r)}catch(e){}}));return()=>{this.unwatch(s),n.unwatch(i)}}};ee.sync.revoke=e=>{e.result()};const te={on(e,t,r){let n;if(r){const s=r.beforeArgs[1];/[^\d\w_\$\.]/.test(s)||(t=r.data.get(s).bind(r.data)),n=()=>this.ele.removeEventListener(e,t)}return this.ele.addEventListener(e,t),n||this},one(e,t,r){const n=r=>{this.off(e,n),t(r)};return this.on(e,n,r),this},off(e,t){return this.ele.removeEventListener(e,t),this},emit(e,t){const r={...t};let n,s;return r.hasOwnProperty("data")&&(n=r.data,delete r.data),e instanceof Event?s=e:e&&(s=new Event(e,{bubbles:!0,...r})),n&&(s.data=n),this.ele.dispatchEvent(s),this}};te.on.revoke=e=>{e.result()};const re=(e,t,r,...n)=>{const{children:s}=e;t<0&&(t+=e.children.length),void 0===r&&(r=e.children.length-t);const i=[];for(let e=t,n=t+r;e
e&&e.remove())),n.length){const r=document.createDocumentFragment();n.forEach((e=>r.append(Pe(e).ele)));const i=s[t];i?e.insertBefore(r,i):e.appendChild(r)}return i},ne=["push","pop","shift","unshift","splice","reverse","sort","fill","copyWithin"],se={push(...e){const{ele:t}=this;return re(t,t.children.length,0,...e),k({type:"array",currentTarget:this,target:this,args:e,name:"push"}),t.children.length},pop(...e){const{ele:t}=this,r=re(t,t.children.length-1,1,...e);return k({type:"array",currentTarget:this,target:this,args:e,name:"pop"}),Re(r[0])},shift(...e){const{ele:t}=this,r=re(t,0,1,...e);return k({type:"array",currentTarget:this,target:this,args:e,name:"shift"}),Re(r[0])},unshift(...e){const{ele:t}=this;return re(t,0,0,...e),k({type:"array",currentTarget:this,target:this,args:e,name:"unshift"}),t.children.length},splice(...e){const t=re(this.ele,...e);return k({type:"array",currentTarget:this,target:this,args:e,name:"splice"}),t.map(Re)},reverse(...e){const t=Array.from(this.ele.childNodes);ie.reverse.call(t,...e);const r=document.createDocumentFragment();return t.forEach((e=>{e.__internal=1,r.append(e)})),this.ele.append(r),t.forEach((e=>{delete e.__internal})),k({type:"array",currentTarget:this,target:this,args:e,name:"reverse"}),this},sort(...e){const t=Array.from(this.ele.children).map(Re);ie.sort.call(t,...e);const r=document.createDocumentFragment();return t.forEach((e=>{e.ele.__internal=1,r.append(e.ele)})),this.ele.append(r),t.forEach((e=>{delete e.ele.__internal})),k({type:"array",currentTarget:this,target:this,args:e,name:"sort"}),this}},ie=Array.prototype;Object.keys(Object.getOwnPropertyDescriptors(ie)).forEach((e=>{if("constructor"===e||"length"===e||ne.includes(e))return;const t=ie[e];d(t)&&(se[e]=function(...e){return t.apply(Array.from(this.ele.children).map(Re),e)})}));class ae{}for(let[e,t]of Object.entries(se))Object.defineProperty(ae.prototype,e,{value:t});const oe=e=>new H(e);Object.assign(oe,{is:C});const{defineProperty:le,assign:ce}=Object,he=(e,t)=>{const{ele:r}=t;e.forEach((e=>{if(e in r){let n=!1;le(t,e,{enumerable:!0,get:()=>{let t=r[e];return n&&(/\D/.test(t)?n=!1:t=Number(t)),t},set:t=>{n="number"==typeof t,r[e]=t}})}}))},de=new Set(["input","textarea","select","option","button","label","fieldset","legend","form"]),ue=(e,t={})=>{const{name:r,type:n}=t,{ele:s}=e;let i=s[r];e.on(n,(()=>{k({type:"set",target:e,currentTarget:e,name:r,value:s[r],oldValue:i}),i=s[r]}))},fe=e=>{switch(e.attr("type")){case"file":he(["multiple","files"],e),ue(e,{name:"files",type:"change"});break;case"checkbox":he(["checked","multiple","value"],e),ue(e,{name:"checked",type:"change"});break;case"radio":he(["checked","value"],e),ue(e,{name:"checked",type:"change"});break;default:he(["placeholder","value"],e),ue(e,{name:"value",type:"input"})}},pe=(e,t)=>{const r={};return e.all(t).forEach((e=>{const{name:t,tag:n,ele:s}=e;if("input"===n)switch(e.type){case"checkbox":t in r||(r[t]=[]),s.checked&&r[t].push(s.value);break;case"radio":s.checked&&(r[t]=s.value);break;case"file":r[t]=s.files;break;default:r[t]=s.value}else if("textarea"===n)r[t]=s.value;else if("select"===n){const e=g(s,"option:checked");if(s.multiple)r[t]=e.map((e=>e.value||e.textContent));else{const[n]=e;r[t]=n.value||n.textContent}}else r[t]=e.value})),r};var me={formData(e,t={wait:200}){const r=oe({});ce(r,pe(this,e||"input,select,textarea"));const n=this.watchTick((t=>{const n=pe(this,e||"input,select,textarea");!function(e,t){for(let r of Object.keys(e))t.hasOwnProperty(r)||delete e[r];for(let[r,n]of Object.entries(t))e[r]=n}(r,n)}),t.wait),s=r.watchTick((t=>{!function(e,t,r){const n=e.all(t);Object.keys(r).forEach((e=>{const t=n.filter((t=>t.attr("name")===e));if(0===t.length)return;const s=r[e],i=t[0],a=i.attr("type");if(1===t.length){let e=!0;if("input"!==i.tag||"radio"!==a&&"checkbox"!==a||(e=!1),e)return void(i.value!==s&&(i.value=s))}t.forEach((e=>{switch(e.attr("type")){case"radio":e.value===s?e.checked=!0:e.checked=!1;break;case"checkbox":e.checked=s.includes(e.value)}}))}))}(this,e||"input,select,textarea",r)})),i=this,a=r.revoke;return r.extend({revoke(){i.unwatch(n),r.unwatch(s),a.call(this)}}),r}};const ge={set:(e,t,r,n)=>(e._ele.style[t]=r,Reflect.set(e,t,r,n),!0),get(e,t,r){if("length"===t)return 0;const{style:n}=e._ele;return Array.from(n).includes(t)?n[t]:getComputedStyle(e._ele)[t]}};class _e{constructor(e){const t={};Object.defineProperty(t,"_ele",{enumerable:!1,get:()=>e.ele});const{style:r}=e.ele;return Array.from(r).forEach((e=>{t[e]=r[e]})),e._css=new Proxy(t,ge)}}var ye={get css(){return new _e(this)},set css(e){if("string"==r(e))return void(this.ele.style=e);let{style:t}=this,n=Object.keys(e);Array.from(t).forEach((e=>{n.includes(e)||(t[e]="")})),Object.assign(t,e)}};const we={},be=({defaults:e,ele:t,template:r,temps:n})=>{let s;try{const i={...Ee(e.data),...e.attrs};s=Re(t),e.proto&&s.extend(e.proto,{enumerable:!1});for(let[e,t]of Object.entries(i))s.hasOwnProperty(e)||(s[e]=t);if(e.temp){const e=t.attachShadow({mode:"open"});e.innerHTML=r.innerHTML,z({target:e,data:s,temps:n})}e.ready&&e.ready.call(s)}catch(e){const r=new Error(`Render element error: ${t.tagName} \n ${e.stack}`);throw r.error=e,r}if(e.watch){const t=Object.entries(e.watch);s.watchTick((e=>{for(let[r,n]of t)e.hasModified(r)&&n.call(s,s[r],{watchers:e})}));for(let[e,r]of t)r.call(s,s[e],{})}},ve=(e={})=>{const t={tag:"",temp:"",data:{},proto:{},...e};let r,n,s;try{if(function(e){if("-"===e.charAt(0)||"-"===e.charAt(e.length-1))throw new Error(`The string "${e}" cannot start or end with "-"`);for(let t=0;t{let t;return t=e instanceof Array?[...e]:Object.keys(e),t},o=we[s]=class extends HTMLElement{constructor(...e){super(...e);const s=Re(this);if(t.created&&t.created.call(s),t.attrs){const e=a(t.attrs);s.watchTick((t=>{e.forEach((e=>{if(t.hasModified(e)){const t=s[e],r=f(e);null==t?this.removeAttribute(r):this.setAttribute(r,t)}}))}))}be({defaults:t,ele:this,template:r,temps:n})}connectedCallback(){ke(this)||t.attached&&t.attached.call(Re(this))}disconnectedCallback(){ke(this)||t.detached&&t.detached.call(Re(this))}attributeChangedCallback(e,t,r){const n=Re(this);/[^\d.]/.test(r)||"number"!=typeof n[e]||(r=Number(r)),n[u(e)]=r}static get observedAttributes(){return a(t.attrs||{}).map((e=>f(e)))}};if("loading"!==document.readyState)customElements.define(t.tag,o);else{const e="readystatechange";let r;document.addEventListener(e,r=()=>{customElements.define(t.tag,o),document.removeEventListener(e,r)})}};function ke(e){let t=e;for(;t;){if(t.__internal)return!0;if(t=t.parentNode||t.host,!t||t.tagName&&"BODY"===t.tagName)break}return!1}function Ee(e){if(e instanceof Set||e instanceof Map)throw"The data of the registered component should contain only regular data types such as String, Number, Object and Array. for other data types, please set them after ready.";if(e instanceof Function)throw"Please write the function in the 'proto' property object.";if("object"!=typeof e||null===e)return e;const t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Ee(e[r]));return t}class xe extends Comment{constructor(e){const t="Fake Node"+(e?": "+e:"");super(` ${t} --end `),this._mark=e,this._inited=!1;const r=new Comment(` ${t} --start `);r.__fake_end=this,Object.defineProperty(this,"_start",{value:r})}init(){this._inited||(this.parentNode.insertBefore(this._start,this),this._inited=!0)}querySelector(e){return this.__searchEl(e,"find")}querySelectorAll(e){return this.__searchEl(e)}__searchEl(e,t="filter"){const r=this.parentNode;if(!r)return[];const n=this.children;return Array.from(r.querySelectorAll(e))[t]((e=>{let t=e;for(;;){if(n.includes(t))return!0;if(t=t.parentNode,!t)break}}))}insertBefore(e,t){const{parentNode:r}=this;Array.from(r.children).includes(t)?r.insertBefore(e,t):r.insertBefore(e,this)}appendChild(e){this.parentNode.insertBefore(e,this)}get children(){const e=[];let t=this;for(;;){if(t=t.previousSibling,!t)throw"This is an unclosed FakeNode";if(t instanceof HTMLElement)e.unshift(t);else if(t===this._start)break}return e}get childNodes(){const e=[];let t=this;for(;;){if(t=t.previousSibling,!t)throw"This is an unclosed FakeNode";if(t===this._start)break;e.unshift(t)}return e}set innerHTML(e){this.childNodes.forEach((e=>{e.remove()}));const t=document.createElement("template");t.innerHTML=e,Array.from(t.content.childNodes).forEach((e=>{this.appendChild(e)}))}get innerHTML(){const{children:e}=this;let t="";return e.forEach((e=>{t+=e.outerHTML+"\n"})),t}get nextElementSibling(){let e=this.nextSibling;return e?e.__fake_end?e.__fake_end:(!e||e instanceof Element||(e=e.nextElementSibling),e):null}get previousElementSibling(){const{_start:e}=this;let t=e.previousSibling;return t?t instanceof xe?t:e.previousElementSibling:null}}const $e=e=>{if(e.parentNode){const t=e.parentNode;Array.from(e.content.children).forEach((r=>{t.insertBefore(r,e)})),e.remove()}};if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))B.beforeRender=({target:e})=>{let t=[];for(;t=Array.from(e.querySelectorAll('template[is="replace-temp"]')),t.length;)t.forEach((e=>{$e(e)}))};else{class e extends HTMLTemplateElement{constructor(){super(),this.init()}init(){$e(this)}connectedCallback(){this.init()}}customElements.define("replace-temp",e,{extends:"template"})}const Te={data:{value:null,__rendered:!1},watch:{value(){this._bindend&&this.refreshValue()}},proto:{refreshValue(){clearTimeout(this._timer),this._timer=setTimeout((()=>{const e=[this,...this._others];let t=!1;e.forEach((e=>{t?e._clearContent():e.value||"x-else"===e.tag?(t=!0,e._renderContent()):e._clearContent()})),Re(this._fake.parentNode).refresh()}),0)},_renderContent(){if(this.__rendered)return;this.__rendered=!0;const e=Ae(this._fake);if(!e)return;const{target:t,data:r,temps:n}=e;c(r)||(this._fake.innerHTML=this.__originHTML,z({target:t,data:r,temps:n}))},_clearContent(){this.__rendered=!1,He(this._fake),this._fake.innerHTML=""},init(){if(this._bindend)return;this._bindend=!0;const e=this._fake=new xe(this.tag);if(this.before(e),e.init(),this.remove(),"x-if"===this.tag){const t=this._others=[];let r=e;for(;r=r.nextElementSibling,r;)switch(r.tagName){case"X-ELSE":{const e=Re(r);return e.init?e.init():e._if_ready=1,void t.push(e)}case"X-ELSE-IF":{const e=Re(r);e._xif=this,t.push(e);break}}}}},created(){this.__originHTML=this.$("template[condition]").html,this.html=""},ready(){this.ele._bindingRendered?this.init():this.one("binding-rendered",(()=>this.init()))}};ve({tag:"x-if",...Te}),ve({tag:"x-else-if",...Te,watch:{value(){this._bindend&&this._xif&&this._xif.refreshValue()}}}),ve({tag:"x-else",...Te,watch:{},ready(){this._if_ready&&this.init()}});const Ae=e=>{for(;e&&!e.__render_data;)e=e.parentNode;return e?{target:e,data:e.__render_data,temps:e.__render_temps}:null};ve({tag:"x-fill",data:{value:null},watch:{value(){this.refreshValue()}},proto:{refreshValue(){const e=this.value;if(!this._bindend)return;const t=this._fake.children;if(!e)return t.forEach((e=>He(e))),void(this._fake.innerHTML="");if(!(e instanceof Array))return console.warn(`The value of x-fill component must be of type Array, and the type of the current value is ${getType(e)}`),void(t&&t.forEach((e=>{He(e),e.remove()})));const r=Ae(this._fake);if(!r)return;const n=t.map((e=>e._data_xid||e)),{data:s,temps:i}=r,a=i[this._name],o=e.length;let l;for(let r=0;r-1){if(c===r){l=t[r];continue}const e=t[c];Re(e).__item.$index=r,e.__internal=1,0===r?this._fake.insertBefore(e,t[0]):this._fake.insertBefore(e,l.nextElementSibling),l=e,delete e.__internal;continue}const h=Oe(o,i,a,s.$host||s,r);l?this._fake.insertBefore(h.ele,l.nextSibling):t.length?this._fake.insertBefore(h.ele,t[0]):this._fake.appendChild(h.ele),l=h.ele}const c=this._fake.children;o{e.remove(),He(e)})),Re(this._fake.parentNode).refresh()},init(){if(this._bindend)return;this._bindend=!0;const e=this._fake=new xe("x-fill");this.before(e),e.init(),this.remove(),this.refreshValue()}},ready(){this._name=this.attr("name"),this.ele._bindingRendered?this.init():this.one("binding-rendered",(()=>this.init()))}});const Oe=(e,t,r,n,s)=>{const i=Pe(r.innerHTML),a=new H({$data:e,$ele:i,$host:n,$index:s});z({target:i.ele,data:a,temps:t,$host:n,isRenderSelf:!0});const o=i.ele.__revokes,l=()=>{m(o,l),a.revoke()};return o.push(l),i.__item=a,i.ele._data_xid=e.xid||e,i},{defineProperties:Se}=Object,Le=({_this:e,ele:t,proxySelf:r})=>{const n={owner:{get(){const{parentNode:r}=t,{_owner:n}=e,s=r?[Re(r),...n]:[...n];return new Set(s)}},ele:{get:()=>t}},s=t.tagName&&t.tagName.toLowerCase();s&&(n.tag={enumerable:!0,value:s}),Se(e,n),(e=>{const{tag:t}=e;if(de.has(t))switch(he(["type","name","disabled"],e),t){case"input":fe(e);break;case"textarea":he(["value"],e),ue(e,{name:"value",type:"input"});break;case"option":he(["selected","value"],e);break;case"select":{const{ele:t}=e;e.watch((()=>{t.value=e.value})),e.on("change",(()=>{e.value=t.value}))}}})(r)};class je extends ae{constructor({ele:e}){super();const t=P.call(this,{},q);return Le({_this:this,ele:e,proxySelf:t}),e.__xhear__=t,t}get length(){return this.ele&&this.ele.children.length}$(e){let{ele:t}=this;t instanceof HTMLTemplateElement&&(t=t.content);const r=t.querySelector(e);return r?Re(r):null}all(e){return g(this.ele,e).map(Re)}extend(e,t){return l(this,e,t)}get text(){return this.ele.textContent}set text(e){this.ele.textContent=e}get html(){return this.ele.innerHTML}set html(e){this.ele.innerHTML=e}get classList(){return this.ele.classList}get data(){return this.ele.dataset}get shadow(){return Re(this.ele.shadowRoot)}get root(){const e=this.ele.getRootNode();return e?Re(e):null}get host(){let e=this.ele.getRootNode(),{host:t}=e;return t instanceof Node?Re(t):null}get parent(){let{parentNode:e}=this.ele;return e&&e!==document?Re(e):null}get parents(){const e=[];let t=this;for(;t.parent;)t=t.parent,e.push(t);return e}get next(){const e=this.ele.nextElementSibling;return e?Re(e):null}after(e){const{next:t}=this;t?t.before(e):this.parent.push(e)}get nexts(){const{parent:e}=this,t=this.index;return e.filter(((e,r)=>r>t))}get prev(){const e=this.ele.previousElementSibling;return e?Re(e):null}before(e){const t=Pe(e);this.parent.ele.insertBefore(t.ele,this.ele)}get prevs(){const{parent:e}=this,t=this.index;return e.filter(((e,r)=>re!==this))}get index(){let{parentNode:e}=this.ele;return e?Array.prototype.indexOf.call(e.children,this.ele):null}get style(){return this.ele.style}get width(){return parseInt(getComputedStyle(this.ele).width)||0}get height(){return parseInt(getComputedStyle(this.ele).height)||0}get clientWidth(){return this.ele.clientWidth}get clientHeight(){return this.ele.clientHeight}get offsetWidth(){return this.ele.offsetWidth}get offsetHeight(){return this.ele.offsetHeight}get outerWidth(){let e=getComputedStyle(this.ele);return this.ele.offsetWidth+parseInt(e["margin-left"])+parseInt(e["margin-right"])}get outerHeight(){let e=getComputedStyle(this.ele);return this.ele.offsetHeight+parseInt(e["margin-top"])+parseInt(e["margin-bottom"])}is(e){return p(this.ele,e)}remove(){const{parent:e}=this;e.splice(e.indexOf(this),1)}clone(e=!0){return Re(this.ele.cloneNode(e))}wrap(e){const t=Pe(e),{ele:r}=this;if(!r.parentNode)throw"The target has a sibling element, so you can't use unwrap";return r.parentNode.insertBefore(t.ele,r),r.__internal=1,t.ele.appendChild(r),delete r.__internal,this}unwrap(){const{ele:e}=this,t=e.parentNode;if(t.children.length>1)throw"The element itself must have a parent";return e.__internal=1,t.parentNode.insertBefore(e,t),t.remove(),delete e.__internal,this}}const Me=H.prototype,Ne=je.prototype;Ne.extend({get:Me.get,set:Me.set,toJSON:Me.toJSON,toString:Me.toString,...E,...te,...Q,...ee,...me},{enumerable:!1}),Ne.extend(ye);const Re=e=>e?e.__xhear__?e.__xhear__:new je({ele:e}):null,Ce=document.createElement("template"),Pe=(e,t)=>{if(e instanceof je)return e;if(e instanceof Node||e===window)return Re(e);switch(r(e)){case"object":return(e=>{const t={...e};if(!e.tag)return null;const r=document.createElement(e.tag);delete t.tag;const n=Re(r);return Object.assign(n,t),n})(e);case"string":return(e=>{Ce.innerHTML=e;const t=Ce.content.children[0]||Ce.content.childNodes[0];return Ce.innerHTML="",Re(t)})(e)}},He=e=>{e.__revokes&&Array.from(e.__revokes).forEach((e=>e&&e())),e.childNodes&&Array.from(e.childNodes).forEach((e=>{He(e)}));const t=e?.shadowRoot?.__revokes;t&&[...t].forEach((e=>e()))};function Ue(e){if("string"===r(e)&&!/<.+>/.test(e)){const t=document.querySelector(e);return Re(t)}return Pe(e)}function De(e,t,r,n){let s=e.host.root.$(`[inject-host="${t}"]`);if(s)return s.ele.__items.add(n),void(n.__host_link=s);s=r(),s.attr("inject-host",t),s.ele.__items=new Set([n]),n.__host_link=s;const{root:i}=e.host;i.ele===document?document.head.appendChild(s.ele):i.root.push(s)}function Ie(e){if(e.__inited&&e.__host_link){const t=e.__host_link.ele.__items;t.delete(e),t.size||e.__host_link.remove(),delete e.__inited}}Object.defineProperties(Ue,{extensions:{value:{}}}),Object.assign(Ue,{stanz:oe,render:z,convert:Y,register:ve,fn:je.prototype,all:e=>g(document,e).map(Re)}),Ue.register({tag:"inject-host",temp:"",data:{},proto:{init(){this.ele.isConnected&&this.forEach((e=>this._init(e)))},_init(e){if(!e.ele.__inited)switch(e.tag){case"link":this._initLink(e);break;case"style":this._initStyle(e);break;case"x-if":case"x-else-if":case"x-else":case"x-fill":break;default:console.log("This element will be invalidated within the inject-host",e)}},_initLink(e){const t=e.attr("href"),r=e.attr("rel");if("stylesheet"!==r&&"host"!==r)throw'The "rel" attribute of the "link" tag within "inject-host" can only use "stylesheet" as its value.';let{ele:n}=e;"host"!==r&&(e.attr("rel","host"),e.attr("href",t)),n.__inited=!0,n._revoke=()=>{Ie(n),n._revoke=null},De(this,t,(()=>{const t=e.clone();return t.attr("rel","stylesheet"),t}),n)},async _initStyle(e){const t=new Comment(e.html);t.__inited=!0,t._revoke=()=>{Ie(e.ele),delete t.__inited,delete e.ele.__inited,t._revoke=null,e.ele._revoke=null},e.html="",e.push(t),e.ele.__inited=!0,e.ele._revoke=t._revoke;De(this,function(e){let t=0,r=e.length;for(let n=0;n>>19,t=7*t-3*t}return t.toString(36)+"--"+r}(t.data),(()=>Ue(``)),e.ele)}},attached(){(this._obs=new MutationObserver((e=>{for(let t of e)if("attributes"===t.type){if("x-bind-data"===t.attributeName)continue;const{target:e}=t;e.__inited&&(e._revoke(),this._init(Re(e)))}else"childList"===t.type&&(t.removedNodes.forEach((e=>{e.__inited&&e._revoke()})),t.addedNodes.forEach((e=>{if(!e.__inited){if(e instanceof Text&&"STYLE"===e.parentElement.tagName&&this.init(e.parentNode),e.__inited)return;if(e instanceof Text||e instanceof Comment)return;this._init(Re(e))}})))}))).observe(this.ele,{attributes:!0,childList:!0,subtree:!0}),this.init()},detached(){this.forEach((e=>Ie(e.ele))),this._obs.disconnect()}});class Fe{constructor(){this._middlewares=new Map}use(e){const t=Math.random().toString(32).slice(2);return this._middlewares.set(t,e),t}unuse(e){return this._middlewares.delete(e)}async run(e){let t=-1;const r=Array.from(this._middlewares.values()),n=async()=>{t++,t{(qe[e]||(qe[e]=new Fe)).use(t)},We=(e,t)=>{e instanceof Function&&(t=e,e=["js","mjs"]),e instanceof Array?e.forEach((e=>{Be(e,t)})):Be(e,t)};We(["mjs","js"],(async(e,t)=>{if(!e.result){const{url:t,params:r}=e,n=new URL(t),s=/^blob:/.test(t)||/^data:/.test(t);try{s||r.includes("-direct")?e.result=await import(t):e.result=await import(`${n.origin}${n.pathname}`)}catch(r){const n=Ve(`Failed to load module ${e.realUrl||t}`,r);throw s&&console.log("Failed to load module:",e),n}}await t()})),We(["txt","html","htm"],(async(e,t)=>{if(!e.result){const{url:t}=e;let r;try{r=await fetch(t)}catch(e){throw Ve(`Load ${t} failed`,e)}if(!/^2.{2}$/.test(r.status))throw new Error(`Load ${t} failed: status code ${r.status}`);e.result=await r.text()}await t()})),We("json",(async(e,t)=>{if(!e.result){const{url:t}=e;e.result=await fetch(t).then((e=>e.json()))}await t()})),We("wasm",(async(e,t)=>{if(!e.result){const{url:t}=e,r=await fetch(t).then((e=>e.arrayBuffer())),n=await WebAssembly.compile(r),s=new WebAssembly.Instance(n);e.result=s.exports}await t()})),We("css",(async(e,t)=>{if(!e.result){const{url:t,element:r}=e;if(r){const e=document.createElement("link");e.rel="stylesheet",e.href=t;const n=r.getRootNode();let s;n===document?n.head.append(e):n.appendChild(e),r.addEventListener("disconnected",s=t=>{e.remove(),r.removeEventListener("disconnected",s)})}else e.result=await fetch(t).then((e=>e.text()))}await t()}));const Ve=(e,t)=>{const r=new Error(`${e} \n ${t.toString()}`);return r.error=t,r},Je=Symbol("loaded"),ze=async(e,t)=>{const r=new URL(e),{pathname:n}=r;let s,i=null;t.params&&t.params.forEach((e=>{/^\..+/.test(e)?s=e.replace(/^\.(.+)/,"$1"):/^\-\-real/.test(e)&&(i=e.replace(/^\-\-real\:/,""))})),s||(s=n.slice(2+(n.lastIndexOf(".")-1>>>0)));const a={url:e,result:null,realUrl:i,...t},o=qe[s];if(o?await o.run(a):a.result=fetch(e),t&&t.element){const{element:e}=t;e[Je]=!0;const r=new Event("load");e.dispatchEvent(r)}return t.params&&t.params.includes("-ctx")?a:a.result};function Ke(e){return(e=>(e||(e={url:document.location.href}),t=>{let r="";const[n,...s]=t.split(" ");if(e.resolve)r=e.resolve(n);else{const t=new URL(e.url);r=new URL(n,t).href}return ze(r,{params:s})}))(e)}Object.assign(Ke,{use:We});class Ge extends HTMLElement{constructor(...e){super(...e),this[Je]=!1,Object.defineProperties(this,{loaded:{get:()=>this[Je]}}),this._init()}_init(){if(this.__initSrc||this.attributes.hasOwnProperty("pause"))return;let e=this.getAttribute("src");if(!e)return;this.__initSrc=e,e=new URL(e,location.href).href,Object.defineProperties(this,{src:{configurable:!0,value:e}});const[t,...r]=e.split(" ");ze(t,{element:this,params:r})}connectedCallback(){const e=new CustomEvent("connected");e.root=this._root=this.getRootNode(),this.dispatchEvent(e)}disconnectedCallback(){const e=new CustomEvent("disconnected");e.root=this._root,delete this._root,this.dispatchEvent(e)}attributeChangedCallback(e,t,r){"src"===e?r&&null===t?this._init():this.__initSrc&&t&&r!==this.__initSrc&&(console.warn(`${this.tagName.toLowerCase()} change src is invalid, only the first change will be loaded`),this.setAttribute("src",this.__initSrc)):"pause"===e&&null===r&&this._init()}static get observedAttributes(){return["src","pause"]}}class Xe extends Ge{constructor(...e){super(...e)}}const Ye=()=>{customElements.define("load-module",Ge),customElements.define("l-m",Xe),window.removeEventListener("load",Ye)};function Ze(e,t){const[r,...n]=e.split(" "),s=t?new URL(t,location.href):location.href;if(r.startsWith("http://")||r.startsWith("https://"))return r;const i=new URL(r,s);return n.length?`${i.href} ${n.join(" ")}`:i.href}function Qe(e,t){g(e,"[href],[src]").forEach((e=>{["href","src"].forEach((r=>{const n=e.getAttribute(r);/^#/.test(n)||n&&!/^(https?:)?\/\/\S+/.test(n)&&e.setAttribute(r,Ze(n,t))}))}))}function et(e,t){const r=document.createElement("template");return r.innerHTML=e,Qe(r.content,t),g(r.content,"style").forEach((e=>{const r=e.innerHTML;e.innerHTML=r.replace(/url\((.+)\)/g,((e,r)=>`url(${Ze(r,t)})`))})),r.innerHTML}"complete"===document.readyState?Ye():window.addEventListener("load",Ye),window.lm=Ke;const tt=Symbol("loadError"),rt=async e=>{const t=lm({url:e}),r=[];let n,s,i,a=e;for(;;){try{let e=a;const[r]=a.split(" "),s=new URL(r);/\/$/.test(s.pathname)&&(e+=" .html"),n=await t(e)}catch(e){let t;t=s?new Error(`${s} request to parent page(${a}) fails; \n ${e.stack}`):new Error(`Request for ${a} page failed; \n ${e.stack}`),t.error=e,i=t,console.error(i)}if(i){r.unshift({src:e,ISERROR:tt,error:i});break}if(r.unshift({src:a,defaults:n}),!n.parent)break;s=a,a=new URL(n.parent,a).href}return r},nt=(e,t)=>{const r=document.createElement("div");r.innerHTML=``;const n=$(r.children[0]);return n._pause_init=1,o((()=>{n._renderDefault(t),delete n._pause_init})),n},st=B.render;B.render=e=>{st&&st(e);const{step:t,name:r,target:n}=e,{link:s}=Ue.extensions;if("init"===t)n.host&&s&&Ue(n).all("a").forEach((e=>s(e)));else if("attr"===r&&"refresh"===t&&""===n.attr("olink")){const e=n.parents.pop()||n;if(e.__fixLinkTimer)return;e.__fixLinkTimer=o((()=>{const{host:t}=n;t&&"o-page"===t.tag&&Qe(e.ele,t.src),s&&Ue(e).all("a").forEach((e=>s(e))),delete e.__fixLinkTimer}))}};const it=e=>{const t=Ue(e);t.on("click",(e=>{if(e.__processed)return;const r=Ue(e.target);let n=[r,...r.parents].find((e=>"a"===e.tag));if(n&&(n=n.ele),n&&n.attributes.hasOwnProperty("olink"))if(t.app){if(e.metaKey||e.shiftKey)return;if(e.defaultPrevented)return;e.preventDefault();let r=!1;if(e.preventDefault=()=>{r=!0},e.__processed=!0,"A"===n.tagName){const e=n.getAttribute("origin-href");setTimeout((()=>{const s=e||n.href;s&&!r&&t.app.goto(s)}))}}else console.warn("olink is only allowed within o-apps")}))},at=async(e,t,r=!0)=>{const n=new File([e],"genfile",{type:"js"===t?"text/javascript":"application/json"});if(!r)return URL.createObjectURL(n);return await new Promise((e=>{const t=new FileReader;t.onload=t=>{e(t.target.result)},t.readAsDataURL(n)}))},ot=new Map;async function lt(e,t,r=!0){let n=ot.get(t);if(n)return n;let s=!0;$.hasOwnProperty("debugMode")&&(s=$.debugMode);const i=$("");i.html=e;const a=i.$("title"),o=i.$(`template[${r?"page":"component"}]`),l=o.$("script");l&&l.remove();let c="";!!o.html.replace(/\<\!\-\-[\s\S]*?\-\-\>/g,"").trim()&&(c=o.html.replace(/\s+$/,"").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"));const h=`\n export const type = ${r?"$.PAGE":"$.COMP"};\n export const PATH = '${t}';\n ${r&&a?`export const title = '${a.text}';`:""}\n export const temp = \`${c}\`;`;let d="";l&&(l.html.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"").replace(/(import [\s\S]+?from .+);?/g,(e=>e.replace(/([\s\S]+?from )([\s\S]+);?/,((t,r,n)=>{if((!/`/.test(n)||/\$\{.*\}/.test(n))&&!/['"]/.test(n))throw new Error(`Unable to parse addresses of strings with variables: ${e}`)})))),d=l.html.replace(/([\s\S]+?from )['"](.+?)['"]/g,((e,r,n)=>`${r}"${Ze(n,t)}";`)));const u=`${h};\n${d}`;let f="";s&&(f=`//# sourceMappingURL=${await(async(e,t,r)=>{const n=t.split("\n");let s="";for(let e=0;e<=r;e++)s+=";";const i=n.findIndex((e=>"
+
diff --git a/ofa.js/pages/syntax/text.html b/ofa.js/pages/syntax/text.html
new file mode 100644
index 0000000..42f742b
--- /dev/null
+++ b/ofa.js/pages/syntax/text.html
@@ -0,0 +1,22 @@
+
+
+ Rendered Text: {{txt}}
+
+
diff --git a/ofa.js/router.4.3.20.min.js b/ofa.js/router.4.3.20.min.js
new file mode 100644
index 0000000..87732f8
--- /dev/null
+++ b/ofa.js/router.4.3.20.min.js
@@ -0,0 +1,3 @@
+//! ofa.js - v4.3.20 https://github.com/kirakiray/ofa.js (c) 2018-2023 YAO
+!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";new Set;const t=`f-${Math.random().toString(32).slice(2)}`;$.register({tag:"o-router",temp:"",attrs:{fixBody:null},watch:{fixBody(e){if(null!==e){const e=document.createElement("style");e.setAttribute(t,""),e.innerHTML="html,body{margin:0;padding:0;width:100%;height:100%;}",document.head.append(e)}else{const e=document.head.querySelector(t);e&&e.remove()}}},attached(){const t=this.$("o-app");!history.state&&window.location.hash&&(t.$("o-page")?.remove(),t.goto(location.hash.replace("#",""))),this._popstateFunc=function({app:t,getStateUrl:e,fixStateUrl:o}){let r,n,s,i,a;return history.state&&history.state.routerMode&&(t.routers=history.state.routers),t.on("router-change",(o=>{let a="pushState";const{name:c,delta:h,src:l}=o.data||{};switch(c){case"replace":a="replaceState";case"goto":const{routers:o}=t,{pathname:c,search:u}=new URL(l,location.href);if(n)return void(n=null);const d=e?e(c,u,a):`#${c}${u}`;i&&(a="replaceState",i=null),history[a]({routerMode:1,routers:o.map((t=>({src:t.src})))},"",d);break;case"back":if(s)return void(s=null);r=1,history.go(-h)}})),window.addEventListener("popstate",a=e=>{const{state:a}=e;if(r)return void(r=null);if(!a){if(o){const e=o();if(e)return i=1,void t.goto(e);if(!1===e)return}return s=1,void t.back(t.routers.length-1)}if(!a.routerMode||a.ignore)return;const{routers:c}=a,{routers:h}=t;if(c.lengthh.length){const e=c.slice(),o=e.pop();if(e.length>h.length){const o=e.slice(t._history.length);t._history.push(...o)}n=1,t.goto(o.src)}else JSON.stringify(c)!==JSON.stringify(h)&&console.error("o-router error occurred")}),a}({app:t,fixStateUrl(){const t=new URL(location.href);if(t.hash)return t.hash.replace("#","")}})},detached(){this._popstateFunc&&window.removeEventListener("popstate",this._popstateFunc)}}),$.extensions.link=t=>{if(""===t.attr("olink")){const e=t.attr("href");let o;try{o=new URL(e)}catch(t){return}if(!/^#\//.test(o.hash)){t.attr("origin-href",e);const o=new URL(e);t.attr("href",`${location.origin}${location.pathname}#${o.pathname}`)}}}}));
+//# sourceMappingURL=router.min.js.map