text: /*!
  * ofa v3.0.0
  * https://github.com/kirakiray/ofa.js
  * 
  * (c) 2018-2021 YAO
  * Released under the MIT License.
  */(e=>{"use strict";const t=()=>Math.random().toString(32).substr(2);var r=Object.prototype.toString,s=e=>r.call(e).toLowerCase().replace(/(\[object )|(])/g,"");const a=e=>s(e).search("function")>-1;var n=e=>!Object.keys(e).length;const i=Object.defineProperties,o=Object.getOwnPropertyDescriptor,l=e=>e instanceof x,c=null!==document.currentScript.getAttribute("debug"),h=(()=>{if(c){let e=new Map;return(r,s)=>{s||(s=t());let a=e.get(s);clearTimeout(a),e.set(s,setTimeout(()=>{r(),e.delete(s)}))}}let e=new Map,r=e=>Promise.resolve().then(()=>e());"object"==typeof process&&process.nextTick&&(r=process.nextTick);let s=!1;return(a,n)=>{n||(n=t()),e.set(n,{key:n,fun:a}),s||(s=!0,r(()=>{e.size&&e.forEach(({key:t,fun:r})=>{try{r()}catch(e){console.error(e)}e.delete(t)}),e.clear(),s=!1}))}})(),d=(e,t)=>{let r,s=[];const a=n=>{s.push(Object.assign({},n)),t?(clearTimeout(r),r=setTimeout(()=>{e(s),s.length=0},t)):h(()=>{e(s),s.length=0},a)};return a},p=(e,t,r={})=>{Object.keys(t).forEach(s=>{let{get:a,set:n,value:i}=o(t,s);i?e.hasOwnProperty(s)?e[s]=i:Object.defineProperty(e,s,{...r,value:i}):Object.defineProperty(e,s,{...r,get:a,set:n})})},u=(Date.now(),Symbol("self")),m=Symbol("proxy"),f=Symbol("watchs"),g=Symbol("can_update"),y=new Set(["root","sub","revoke"]),b=(e,t,r,s)=>{if(r&&r.includes(e[m]))return;let a;a=t.path=r?[e[m],...r]:[e[m]],e[f].forEach(e=>e(t)),s||e._unupdate||e.owner&&e.owner.forEach(e=>b(e,t,a.slice()))};class x{constructor(e,r){let s;e.get?(s=new Proxy(this,{get:e.get,ownKeys:e.ownKeys,getOwnPropertyDescriptor:e.getOwnPropertyDescriptor,set:w.set}),delete e.get,delete e.ownKeys,delete e.getOwnPropertyDescriptor):s=new Proxy(this,w);let a=r;i(this,{[u]:{value:this},[m]:{value:s},xid:{value:"x_"+t()},_xtatus:{get:()=>a,set(e){if(!y.has(e))throw{target:s,desc:`xtatus not allowed to be set ${e}`};const t=this.owner.size;if("revoke"===e&&t)throw{target:s,desc:"the owner is not empty"};if("revoke"===a&&"revoke"!==e)t||v(this);else if("sub"===a&&"root"===e)throw{target:s,desc:"cannot modify sub to root"};a=e}},owner:{configurable:!0,writable:!0,value:new Set},length:{configurable:!0,writable:!0,value:0},[f]:{value:new Map},[g]:{writable:!0,value:0}});let n=-1;return Object.keys(e).forEach(t=>{let r=o(e,t),{value:a,get:l,set:c}=r;"get"!==t&&(/\D/.test(t)||(t=parseInt(t))>n&&(n=t),l||c?i(this,{[t]:r}):s[t]=a)}),n>-1&&(this.length=n+1),this[g]=1,s}watch(e){const r="e_"+t();return this[f].set(r,e),r}unwatch(e){return this[f].delete(e)}setData(e,t){let r,a=s(t);"array"!=a&&"object"!=a||(t=E(t,"sub")).owner.add(this);const n=Object.getOwnPropertyDescriptor(this,e),i=this[m];try{r=i[e]}catch(e){}if(r===t)return!0;let o;return n&&n.set?(n.set.call(i,t),o=!0):o=Reflect.set(this,e,t),this[g]&&b(this,{xid:this.xid,name:"setData",args:[e,t]}),_(r,this),o}update(e={}){b(this,Object.assign({},e,{xid:this.xid,isCustom:!0}))}delete(e){if(/^_/.test(e)||"symbol"==typeof e)return Reflect.deleteProperty(this,e);if(!e)return!1;const t=this[u];let r=t[e];_(r,t);let s=Reflect.deleteProperty(t,e);return b(this,{xid:this.xid,name:"delete",args:[e]}),s}}const w={set(e,t,r,s){if("symbol"==typeof t)return Reflect.set(e,t,r,s);if(/^_/.test(t))return e.hasOwnProperty(t)?Reflect.set(e,t,r,s):i(e,{[t]:{writable:!0,configurable:!0,value:r}}),!0;try{return e.setData(t,r)}catch(e){throw{desc:`failed to set ${t}`,key:t,value:r,target:s}}},deleteProperty:function(e,t){return e.delete(t)}},_=(e,t)=>{if(!l(e))return;const{owner:r}=e;r.delete(t),r.size||(e._xtatus="revoke",Object.values(e).forEach(t=>{_(t,e[u])}))},v=e=>{"revoke"===e._xtatus&&Object.values(e).forEach(t=>{l(t)&&(v(t),t.owner.add(e),t._xtatus="sub")})},E=(e,t="root")=>l(e)?(e._xtatus=t,e):new x(e,t);p(x.prototype,{seek(e){let t=[];if(!a(e)){let t=new Function(`with(this){return ${e}}`);e=(e=>{try{return t.call(e,e)}catch(e){}})}return e.call(this,this)&&t.push(this),Object.values(this).forEach(r=>{l(r)&&t.push(...r.seek(e))}),t},watchTick(e,t){return this.watch(d(e,t))},watchUntil(e){let t=a(e);if(!t&&/[^=><]=[^=]/.test(e))throw"cannot use single =";return new Promise(r=>{let s,a=t?e.bind(this):new Function(`\n        try{with(this){\n            return ${e}\n        }}catch(e){}`).bind(this);const n=this.watchTick(s=(()=>{let e=a();e&&(this.unwatch(n),r(e))}));s()})},watchKey(e,t){t&&Object.keys(e).forEach(t=>e[t].call(this,this[t]));let r={};return Object.keys(e).forEach(e=>{r[e]=this[e]}),this.watch(d(t=>{Object.keys(e).forEach(s=>{let a=this[s],n=r[s];if(n!==a)e[s].call(this,a,{old:n});else if(l(a)){t.some(e=>{return e.path[1]==a})&&e[s].call(this,a,{old:n})}r[s]=a})}))},toJSON(){let e={},t=!0,r=0;Object.keys(this).forEach(s=>{let a=this[s];/\D/.test(s)?t=!1:(s=parseInt(s))>r&&(r=s),l(a)&&(a=a.toJSON()),e[s]=a}),t&&(e.length=r+1,e=Array.from(e));const s=this.xid;return i(e,{xid:{get:()=>s}}),e},toString(){return JSON.stringify(this.toJSON())}}),["concat","every","filter","find","findIndex","forEach","map","slice","some","indexOf","lastIndexOf","includes","join"].forEach(e=>{let t=Array.prototype[e];t&&i(x.prototype,{[e]:{value:t}})});const k=Array.prototype.splice;p(x.prototype,{splice(e,t,...r){let a=this[u];r=r.map(e=>{let t=s(e);return"array"!=t&&"object"!=t||(e=E(e,"sub")).owner.add(a),e});let n="number"==s(t)?t:this.length-e,i=k.call(a,e,n,...r);return i.forEach(e=>_(e,a)),b(this,{xid:this.xid,name:"splice",args:[e,t,...r]}),i},unshift(...e){return this.splice(0,0,...e),this.length},push(...e){return this.splice(this.length,0,...e),this.length},shift(){return this.splice(0,1)[0]},pop(){return this.splice(this.length-1,1)[0]}}),["sort","reverse"].forEach(e=>{const t=Array.prototype[e];t&&i(x.prototype,{[e]:{value(...r){let s=t.apply(this[u],r);return b(this,{xid:this.xid,name:e}),s}}})});const O=e=>e?e.__xEle__?e.__xEle__:e.__xEle__=new H(e):null,A=document.createElement("template"),j=(e,t)=>!!e.tagName&&(e===t||e!==document&&(A.innerHTML=`<${e.tagName.toLowerCase()} ${Array.from(e.attributes).map(e=>e.name+'="'+e.value+'"').join(" ")} />`,!!A.content.querySelector(t))),S=e=>{const t=document.createElement("div");return t.innerHTML=e,Array.from(t.children).map(function(e){return t.removeChild(e),e})},L=e=>{if(!e.tag)throw console.error("this data need tag =>",e),"";let t=document.createElement(e.tag);e.class&&t.setAttribute("class",e.class),e.slot&&t.setAttribute("slot",e.slot);const r=O(t);r[M].forEach(t=>{e[t]&&(r[t]=e[t])});let s=0;for(;s in e;){let r=L(e[s]);t.appendChild(r),s++}return t},$=e=>(/\-/.test(e)&&(e=e.replace(/\-[\D]/g,e=>e.substr(1).toUpperCase())),e),T=e=>(/[A-Z]/.test(e)&&(e=e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())),e),C={get:(e,t,r)=>"string"!=typeof t||/\D/.test(t)?Reflect.get(e,t,r):O(e.ele.children[t]),ownKeys(e){let t=Reflect.ownKeys(e),r=e.ele.children.length;for(let e=0;e<r;e++)t.push(String(e));return t},getOwnPropertyDescriptor:(e,t)=>"string"!=typeof t||/\D/.test(t)?Reflect.getOwnPropertyDescriptor(e,t):{enumerable:!0,configurable:!0}},P=Symbol("events"),D=x.prototype.setData,N=["text","html","show","style"],M=Symbol("cansetkeys");class H extends x{constructor(e){super(Object.assign({},C));const t=this[u];t.tag=e.tagName?e.tagName.toLowerCase():"",i(t,{owner:{get(){let t=e.parentNode;return t?[O(t)]:[]}}}),i(t,{ele:{get:()=>e},[P]:{writable:!0,value:""}}),delete t.length,"input"!=t.tag&&"textarea"!=t.tag&&"select"!=t.tag||R(t)}setData(e,t){if(!this[M]||this[M].has(e))return D.call(this,e,t)}get root(){return O(this.ele.getRootNode())}get host(){let e=this.ele.getRootNode(),{host:t}=e;return t?O(t):null}get shadow(){return O(this.ele.shadowRoot)}get parent(){let{parentNode:e}=this.ele;return e&&e!==document?O(e):null}get index(){let{parentNode:e}=this.ele;return e?Array.prototype.indexOf.call(e.children,this.ele):null}get length(){return this.ele.children.length}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 class(){return this.ele.classList}get data(){return this.ele.dataset}get css(){return getComputedStyle(this.ele)}get style(){return this.ele.style}set style(e){if("string"==s(e))return void(this.ele.style=e);let{style:t}=this,r=Array.from(t),a=Object.keys(e);r.forEach(e=>{a.includes(e)||(t[e]="")}),Object.assign(t,e)}get show(){return"none"!==this.ele.style.display}set show(e){this.ele.style.display=e?"":"none"}get position(){return{top:this.ele.offsetTop,left:this.ele.offsetLeft}}get offset(){let e={top:0,left:0},t=this.ele;for(;t&&t!==document;)e.top+=t.offsetTop,e.left+=t.offsetLeft,t=t.offsetParent;return e}get width(){return parseInt(getComputedStyle(this.ele).width)}get height(){return parseInt(getComputedStyle(this.ele).height)}get innerWidth(){return this.ele.clientWidth}get innerHeight(){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"])}get next(){const e=this.ele.nextElementSibling;return e?O(e):null}get prev(){const e=this.ele.previousElementSibling;return e?O(e):null}$(e){const t=this.ele.querySelector(e);return t?O(t):null}all(e){return Array.from(this.ele.querySelectorAll(e)).map(e=>O(e))}is(e){return j(this.ele,e)}attr(...e){let[t,r]=e,{ele:s}=this;if(1==e.length)return t instanceof Object&&Object.keys(t).forEach(e=>{s.setAttribute(e,t[e])}),s.getAttribute(t);null===r?s.removeAttribute(t):s.setAttribute(t,r)}siblings(e){let t=Array.from(this.parent.ele.children),r=t.indexOf(this.ele);return t.splice(r,1),e&&(t=t.filter(t=>{if(j(t,e))return!0})),t.map(e=>O(e))}parents(e,t){let r=[],a=this.parent;if(e){if("string"==s(e))for(;a&&a;)j(a.ele,e)&&r.push(a),a=a.parent}else for(;a;)r.push(a),a=a.parent;if(t)if(t instanceof H){let e=[];r.some(r=>{if(r===t)return!0;e.push(r)}),r=e}else if("string"==s(t)){let e=[];r.some(r=>{if(r.is(t))return!0;e.push(r)}),r=e}return r}clone(){let e=O(this.ele.cloneNode(!0));return Object.keys(this).forEach(t=>{"tag"!==t&&(e[t]=this[t])}),e}remove(){const{parent:e}=this;e.splice(e.indexOf(this),1)}extend(e){const t=Object.getOwnPropertyDescriptors(e);Object.entries(t).forEach(([e,t])=>{t.set&&this[M].add(e)}),p(this,e,{configurable:!0})}initSizeObs(e=300){if(this._initedSizeObs)return void console.warn({target:this.ele,desc:"initRect is runned"});this._initedSizeObs=1;const t=()=>{clearTimeout(void 0),setTimeout(()=>{b(this,{xid:this.xid,name:"sizeUpdate"},void 0,!1)},e)};if(t(),window.ResizeObserver){const e=new ResizeObserver(e=>{t()});return e.observe(this.ele),()=>{e.disconnect()}}{let e;return window.addEventListener("resize",e=(e=>{t()})),()=>{window.removeEventListener("resize",e)}}}}i(H.prototype,{[M]:{value:new Set(N)}});const R=e=>{let t=e.attr("type")||"text";const{ele:r}=e;let s={type:{enumerable:!0,get:()=>t},name:{enumerable:!0,get:()=>r.name},value:{enumerable:!0,get:()=>r.hasOwnProperty("__value")?r.__value:r.value,set(t){r.value=r.__value=t,b(e,{xid:e.xid,name:"setData",args:["value",t]})}},disabled:{enumerable:!0,get:()=>r.disabled,set(e){r.disabled=e}},msg:{writable:!0,value:null},[M]:{value:new Set(["value","disabled","msg",...N])}};switch(t){case"radio":case"checkbox":Object.assign(s,{checked:{enumerable:!0,get:()=>r.checked,set(e){r.checked=e}},name:{enumerable:!0,get:()=>r.name}}),delete s.msg,e.on("change",t=>{b(e,{xid:e.xid,name:"setData",args:["checked",r.checked]})}),s[M].value.add("checked");break;case"file":Object.assign(s,{accept:{enumerable:!0,get:()=>r.accept}});break;case"text":default:e.on("input",t=>{delete r.__value,b(e,{xid:e.xid,name:"setData",args:["value",r.value]})})}i(e,s)};const I=(e,t)=>{const r={};return e.forEach(e=>{const{name:s,type:a,value:n}=e;switch(a){case"radio":e.checked&&(r[s]=n);break;case"checkbox":let i=r[s]||(r[s]=t[s])||(r[s]=[]);e.checked?i.includes(e.value)||i.push(n):i.includes(e.value)&&i.splice(i.indexOf(e.value),1);break;case"text":default:r[s]=n}}),r},q=e=>{e.forEach(e=>{const t=new CustomEvent("verify",{bubbles:!1});t.msg="",t.formData=this,t.$target=e,e.trigger(t);const{msg:r}=t,a=s(r);"string"==a?e.msg=r||null:"error"==a?"error"===s(e.msg)&&e.msg.message===r.message||(e.msg=r):console.warn({target:e,msg:r,desc:"msg can only be Error or String"})})};p(H.prototype,{form(e){const t={selector:"input,textarea,select",delay:100};return"string"===s(e)?t.selector=e:Object.assign(t,e),new class extends x{constructor(e,{selector:t,delay:r,_target:s}){super(e,"root"),this._selector=t,this._target=s,this._delay=r;let a,n,i=0,o=()=>{const e=this.formEles,t=I(e,this),r=Object.keys(t);Object.keys(this).filter(e=>!r.includes(e)).forEach(e=>{delete this[e]}),Object.assign(this,t),a=this.toJSON(),i&&q(e)};this._wid=s.watch(()=>{clearTimeout(n),n=setTimeout(()=>{o()},this._delay)}),o(),i=1,this.watchTick(e=>{let t=this.toJSON();Object.entries(t).forEach(([e,t])=>{let r=a[e];(t!==r||"object"==typeof t&&"object"==typeof r&&JSON.stringify(t)!==JSON.stringify(r))&&this.getTarget(e).forEach(e=>{switch(e.type){case"checkbox":t.includes(e.value)?e.checked=!0:e.checked=!1;break;case"radio":e.value==t?e.checked=!0:e.checked=!1;break;case"text":default:e.value=t}})}),a=t})}get formEles(){return this._target.all(this._selector)}getTarget(e){return this.formEles.filter(t=>t.name===e)}}({},{selector:t.selector,delay:t.delay,_target:this})}}),["concat","every","filter","find","findIndex","forEach","map","slice","some","indexOf","lastIndexOf","includes","join"].forEach(e=>{const t=Array.prototype[e];t&&Object.defineProperty(H.prototype,e,{value(...e){return t.apply(Array.from(this.ele.children).map(O),e)}})}),p(H.prototype,{splice(e,t,...r){const{ele:a}=this,n=Array.from(a.children),i=[];let o=e,l="number"==s(t)?t:this.length-e,c=n[o];for(;c&&l>0;)i.push(c),a.removeChild(c),l--,c=n[++o];if(r.length){let t=document.createDocumentFragment();r.forEach(e=>{if(e instanceof Element)return void t.appendChild(e);if(e instanceof H)return void t.appendChild(e.ele);let r=s(e);"string"==r?S(e).forEach(e=>{t.appendChild(e)}):"object"==r&&t.appendChild(L(e))}),e>=this.length?a.appendChild(t):a.insertBefore(t,a.children[e])}return b(this,{xid:this.xid,name:"splice",args:[e,t,...r]}),i},sort(e){const t=this.ele,r=Array.from(t.children).map(O).sort(e);return J(t,r),b(this,{xid:this.xid,name:"sort"}),this},reverse(){const e=this.ele,t=Array.from(e.children).reverse();return J(e,t),b(this,{xid:this.xid,name:"reverse"}),this}});const J=(e,t)=>{const{children:r}=e;t.forEach((t,s)=>{let a=t.ele||t;const n=r[s];n?a!==n&&e.insertBefore(a,n):e.appendChild(a)})},z=e=>e[P]?e[P]:e[P]=new Map,F=e.MouseEvent||Event,U=e.TouchEvent||Event,K=new Map([["click",F],["mousedown",F],["mouseup",F],["mousemove",F],["mouseenter",F],["mouseleave",F],["touchstart",U],["touchend",U],["touchmove",U]]),W=(e,t,r,s=!0)=>{let a=K.get(t)||CustomEvent;const n=t instanceof Event?t:new a(t,{bubbles:s,cancelable:!0});return n.data=r,e.ele.dispatchEvent(n)};p(H.prototype,{on(e,r,s){if(a(r))s=r,r=void 0;else{const e=s,{ele:t}=this;s=(s=>{let a;s.path?a=s.path:(a=O(s.target).parents(null,t).map(e=>e.ele)).unshift(s.target),a.some(a=>{if(a==t)return!0;O(a).is(r)&&(s.selector=a,e(s),delete s.selector)})})}this.ele.addEventListener(e,s);const n="e_"+t();return z(this).set(n,{name:e,selector:r,callback:s}),n},off(e){let t=z(this).get(e);return!!t&&(this.ele.removeEventListener(t.name,t.callback),this[P].delete(e),!0)},one(e,t,r){let s,a;return"string"==typeof t?(a=r,r=(e=>{a(e),this.off(s)})):(a=t,t=(e=>{a(e),this.off(s)})),s=this.on(e,t,r)},trigger(e,t){return W(this,e,t)},triggerHandler(e,t){return W(this,e,t,!1)}}),["click","focus","blur"].forEach(e=>{p(H.prototype,{[e](t){if(!a(t))return this.trigger(e,t);this.on(e,t)}})});const B={},Z={},V=async({xele:e,defs:t,temps:r,_this:s})=>{if(Object.assign(e,t.data,t.attrs),t.created&&t.created.call(e),t.temp){const a=s.attachShadow({mode:"open"});a.innerHTML=t.temp,fe({host:e,xdata:e,content:a,temps:r}),e.shadow&&e.shadow.watchTick(t=>{t.some(e=>e.path.length>1)&&b(e,{xid:e.xid,name:"forceUpdate"})},10);let n=a.querySelectorAll("link");n.length&&await Promise.all(Array.from(n).map(t=>new Promise((r,s)=>{if(t.sheet)r();else{let a,n;t.addEventListener("load",a=(e=>{t.removeEventListener("load",a),t.removeEventListener("error",n),r()})),t.addEventListener("error",n=(r=>{t.removeEventListener("load",a),t.removeEventListener("error",n),s({desc:"link load error",ele:t,target:e.ele})}))}})))}if(t.ready&&t.ready.call(e),!n(t.attrs)){const{ele:r}=e;Object.keys(t.attrs).forEach(t=>{r.hasAttribute(t)&&(e[t]=r.getAttribute(t))}),e.watchTick(r=>{s.__set_attr=1,Object.keys(t.attrs).forEach(t=>{let r=e[t];null===r||void 0===r?s.removeAttribute(T(t)):s.setAttribute(T(t),e[t])}),delete s.__set_attr})}let a=t.watch;n(a)||e.watchKey(a,!0)},G=Symbol("runned_revoke"),Q=e=>{const t={tag:"",temp:"",attrs:{},data:{},watch:{},proto:{}};let r;if(Object.assign(t,e),t.temp){const e=Y(t.temp,t.tag);t.temp=e.html,r=e.temps}let s=$(e.tag);const a=class extends H{constructor(e){super(e),e.isCustom=!0}forceUpdate(){b(this,{xid:this.xid,name:"forceUpdate"})}revoke(){this[G]||(this[G]=1,Object.values(this).forEach(e=>{e instanceof H||!l(e)||_(e,this[u])}),pe(this.shadow.ele))}};p(a.prototype,t.proto);const n=X(t);i(a.prototype,{[M]:{writable:!0,value:new Set([...N,...n])}});customElements.define(t.tag,class extends HTMLElement{constructor(...e){super(...e);let s=this.__xEle__;s&&console.warn({target:s,desc:"please re-instantiate the object"}),this.__xEle__=new a(this);const n=O(this);V({xele:n,defs:t,temps:r,_this:this}).then(e=>{this.__x_connected?this.setAttribute("x-render",1):this.x_render=1})}connectedCallback(){this.x_render&&this.setAttribute("x-render",this.x_render),this.__x_connected=!0,t.attached&&!this.__x_runned_connected&&h(()=>{this.__x_connected&&!this.__x_runned_connected&&(this.__x_runned_connected=!0,t.attached.call(O(this)))})}disconnectedCallback(){this.__x_connected=!1,t.detached&&!this.__x_runnded_disconnected&&h(()=>{this.__x_connected||this.__x_runnded_disconnected||(this.__x_runnded_disconnected=!0,t.detached.call(O(this)))})}attributeChangedCallback(e,t,r){this.__set_attr||(O(this)[$(e)]=r)}static get observedAttributes(){return Object.keys(t.attrs).map(e=>T(e))}}),Z[s]?(Z[s](a),delete Z[s]):B[s]=Promise.resolve(a)},X=e=>{const{attrs:t,data:r,watch:s,proto:a}=e,n=[...Object.keys(t),...Object.keys(r),...Object.keys(s)],i=Object.getOwnPropertyDescriptors(a);return Object.keys(i).forEach(e=>{let{set:t}=i[e];t&&n.push(e)}),n},Y=(e,t)=>{var r=(e=e.replace(/<!--.+?-->/g,"")).match(/{{.+?}}/g);r&&r.forEach(t=>{var r=/{{(.+?)}}/.exec(t);r&&(e=e.replace(t,`<x-span prop="${encodeURI(r[1])}"></x-span>`))});const s=document.createElement("template");s.innerHTML=e;let a=[],n=[];Array.from(s.content.querySelectorAll("*")).forEach(e=>{const t={},r=[];Array.from(e.attributes).forEach(s=>{let i,o,{name:l,value:c}=s,h=/^temp:(.+)/.exec(l);if(h){let[,t]=h,r=document.createElement("template");return r.setAttribute("name",t),e.removeAttribute(l),r.innerHTML=e.outerHTML,a.push(r),n.push(e),!0}if(/^#/.test(l))i="cmd",o=l.replace(/^#/,"");else if(/^@/.test(l))i="on",o=l.replace(/^@/,"");else if(l.includes(":")){let t=l.split(":");if(2!=t.length)throw{desc:"template binding mark error",target:e,expr:l};i=t[0],o=t[1],""===i&&(i="prop")}if(i){let e=t[i]||(t[i]={});"on"==i?e[o]={name:c}:o&&(e[o]=c),r.push(l)}}),r.length&&(Object.keys(t).forEach(r=>{let s=t[r];"cmd"==r?Object.keys(s).forEach(t=>{e.setAttribute(`x-cmd-${t}`,s[t])}):e.setAttribute(`x-${r}`,JSON.stringify(s))}),r.forEach(t=>e.removeAttribute(t)))}),a.length&&(a.forEach(e=>{s.content.appendChild(e)}),n.forEach(e=>{s.content.removeChild(e)})),Array.from(s.content.querySelectorAll("template")).forEach(e=>{e.innerHTML=Y(e.innerHTML).html}),ee(s);let i=new Map;if(Array.from(s.content.querySelectorAll("template[name]")).forEach(e=>{i.set(e.getAttribute("name"),{ele:e,code:e.content.children[0].outerHTML}),e.parentNode.removeChild(e)}),i.size)for(let[e,r]of i.entries()){const{children:s}=r.ele.content;if(1!==s.length)throw{name:e,html:r.code,tag:t,desc:"register error, only one element must exist in the template"};if(s[0].getAttribute("x-cmd-if"))throw{name:e,html:r.code,tag:t,desc:"register error, cannot use if on template first element"}}return{temps:i,html:s.innerHTML}},ee=e=>{e.content.querySelectorAll("[x-cmd-if],[x-cmd-else-if],[x-cmd-else],[x-cmd-await],[x-cmd-then],[x-cmd-catch]").forEach(e=>{if("template"==e.tagName.toLowerCase())return;let t=document.createElement("template");["x-cmd-if","x-cmd-else-if","x-cmd-else","x-cmd-await","x-cmd-then","x-cmd-catch"].forEach(r=>{let s=e.getAttribute(r);null!==s&&(t.setAttribute(r,s),e.removeAttribute(r))}),e.parentNode.insertBefore(t,e),t.content.appendChild(e)}),Array.from(e.content.querySelectorAll("template")).forEach(ee)},te=(e,t)=>{let r=Array.from(e.querySelectorAll(t));return e instanceof Element&&j(e,t)&&r.push(e),r},re=e=>{let t=new Comment("x-marker"),r=e.parentNode;return r.insertBefore(t,e),r.removeChild(e),{marker:t,parent:r}},se=e=>new Function("...$args",`\nconst [$e,$target] = $args;\n\ntry{\n    with(this){\n        ${e};\n    }\n}catch(e){\n    throw {\n        message:e.message || "run error",\n        expr:\`${e.replace(/`/g,"\\`")}\`,\n        target:this,\n        error:e\n    };\n}`),ae=(e,t,r)=>{e.removeAttribute(t);let s=e.__renderData;s||(s=e.__renderData={},e.setAttribute("x-rendered","")),s[t]=r},ne=(e,t,r)=>{let s=e.watchTick(t);r.push({eid:s,target:e})},ie=(e,t)=>{let r;return r=he.test(e)?se("return "+e).bind(t):()=>t[e]},oe=({xdata:e,host:t,expr:r,watchFun:s})=>{const a=[];return e instanceof H?ne(e,s,a):r.includes("$host")?(r.includes("$index")&&ne(e,s,a),ne(t,s,a)):r.includes("$index")||r.includes("$item")?(ne(e,s,a),l(e.$data)&&ne(e.$data,s,a)):r.includes("$data")&&l(e.$data)&&ne(e.$data,s,a),a},le=({xdata:e,host:t,expr:r,callback:s,isArray:a})=>{let n,i,o,c=ie(r,e);const h=e=>{const t=c();if(l(t))if(a){let r=t.map(e=>e&&e.xid?e.xid:e).join(",");i!==r&&(s({val:t,modifys:e}),i=r)}else{let r=t.toJSON();n===t&&r===o||(s({val:t,modifys:e}),o=r)}else n!==t&&(s({val:t,modifys:e}),o=null);n=t};return h(),oe({xdata:e,host:t,expr:r,watchFun:h})},ce=(e,t)=>{(e.__bindings||(e.__bindings=[])).push(...t)},he=/[\(\)\;\.\=\>\<\|\!\?\+\-\*\/]/,de=(e,t)=>{Array.from(e.childNodes).forEach(e=>{t(e),e instanceof Element&&de(e,t)})},pe=e=>{de(e,e=>{e.isCustom&&O(e).revoke(),e.__bindings&&e.__bindings.forEach(e=>{let{target:t,eid:r}=e;t.unwatch(r)})})},ue=({temp:e,temps:t,marker:r,parent:s,host:a,xdata:n})=>{let i=S(e.innerHTML);return i.forEach(e=>{s.insertBefore(e,r),fe({host:a,xdata:n,content:e,temps:t})}),i},me=e=>{e.forEach(e=>{pe(e),e.parentNode.removeChild(e)})},fe=({host:e,xdata:t,content:r,temps:s})=>{te(r,"[x-on]").forEach(e=>{let r=JSON.parse(e.getAttribute("x-on")),s=[];const n=O(e);Object.keys(r).forEach(e=>{let i,{name:o}=r[e];if(he.test(o)){const r=se(o);i=n.on(e,e=>{r.call(t,e,n)})}else i=n.on(e,e=>{const r=t[o];r?a(r)?r.call(t,e):console.error({target:t,name:o,value:r,desc:"bind value is not function"}):console.error({target:t,name:o,desc:"no binding function"})});s.push(i)}),ae(e,"x-on",r)}),te(r,"[x-attr]").forEach(r=>{const s=JSON.parse(r.getAttribute("x-attr"));ae(r,"x-attr",s),Object.keys(s).forEach(a=>{const n=le({xdata:t,host:e,expr:s[a],callback:({val:e})=>{null===e||void 0===e?r.removeAttribute(a):r.setAttribute(a,e)}});ce(r,n)})}),te(r,"[x-class]").forEach(r=>{const s=JSON.parse(r.getAttribute("x-class"));ae(r,"x-class",s),Object.keys(s).forEach(a=>{const n=le({xdata:t,host:e,expr:s[a],callback:({val:e})=>{e?r.classList.add(a):r.classList.remove(a)}});ce(r,n)})}),te(r,"[x-prop]").forEach(r=>{const s=JSON.parse(r.getAttribute("x-prop")),a=O(r);ae(r,"x-prop",s),Object.keys(s).forEach(n=>{const i=le({xdata:t,host:e,expr:s[n],callback:({val:e})=>{a[n]=e}});ce(r,i)})}),te(r,"[x-sync]").forEach(r=>{const s=JSON.parse(r.getAttribute("x-sync")),a=O(r);Object.keys(s).forEach(n=>{let i=s[n];if(he.test(i))throw{desc:"sync only accepts attribute names"};const o=le({xdata:t,host:e,expr:i,callback:({val:e})=>{a[n]=e}}),l=le({xdata:a,host:e,expr:n,callback:({val:e})=>{t[i]=e}});ce(r,[...o,...l])})}),te(r,"x-span").forEach(r=>{let s=decodeURI(r.getAttribute("prop")),{marker:a,parent:n}=re(r);const i=document.createTextNode("");n.replaceChild(i,a);const o=le({xdata:t,host:e,expr:s,callback:({val:e})=>{i.textContent=e}});ce(i,o)}),te(r,"[x-cmd-if]").forEach(r=>{const a=[r];let{nextElementSibling:n}=r;for(;n&&(n.hasAttribute("x-cmd-else-if")||n.hasAttribute("x-cmd-else"));)n.parentNode.removeChild(n),a.push(n),n=r.nextElementSibling;let i="";const o=a.map((e,r)=>{let s;const a=e.getAttribute("x-cmd-else-if")||e.getAttribute("x-cmd-if");return a&&(s=ie(a,t),i+=`${0==r?"if":"else-if"}(${a})...`),{callback:s,tempEle:e}});let{marker:l,parent:c}=re(r),h=null,d=-1;const p=r=>{let a,n,i=-1;o.some((e,t)=>{if(e.callback){if(n=!!e.callback())return a=e.tempEle,i=t,!0}else a=e.tempEle,i=t}),d!==i&&(h&&(pe(h),h.parentNode.removeChild(h),h=null),a&&(h=S(a.content.children[0].outerHTML)[0],c.insertBefore(h,l),fe({host:e,xdata:t,content:h,temps:s}))),d=i};p(),ce(l,oe({xdata:t,host:e,expr:i,watchFun:p}))}),te(r,"[x-cmd-await]").forEach(r=>{let a,n,i=r,{nextElementSibling:o}=r;for(;o&&(o.hasAttribute("x-cmd-then")||o.hasAttribute("x-cmd-catch"));)o.hasAttribute("x-cmd-then")?a=o:o.hasAttribute("x-cmd-catch")&&(n=o),o.parentNode.removeChild(o),o=r.nextElementSibling;let l,c,{marker:h,parent:d}=re(r),p=r.getAttribute("x-cmd-await");const u=le({xdata:t,host:e,expr:p,callback:({val:r})=>{c&&(me(c),c=null),c=ue({temp:i,temps:s,marker:h,parent:d,host:e,xdata:t}),l=r,r.then(t=>{l===r&&(me(c),c=null,a&&(c=ue({temp:a,temps:s,marker:h,parent:d,host:e,xdata:{[a.getAttribute("x-cmd-then")]:t}})))}).catch(t=>{l===r&&(me(c),c=null,n&&(c=ue({temp:n,temps:s,marker:h,parent:d,host:e,xdata:{[n.getAttribute("x-cmd-catch")]:t}})))})}});ce(h,u)}),te(r,"[x-fill]").forEach(r=>{const a=JSON.parse(r.getAttribute("x-fill"));let n=r.getAttribute("x-item");n&&(n=JSON.parse(n));const i=r;O(i)._unupdate=1;let o,[l,c]=Object.entries(a)[0];ae(r,"x-fill",a),ae(r,"x-item",n);const h=le({xdata:t,host:e,expr:c,isArray:1,callback:r=>{const a=r.val;let c=s.get(l);if(!c)throw{target:e.ele,desc:"this template was not found",name:l};if(o){const r=Array.from(i.children),o=r.map(e=>e.__fill_item.$data),l=Symbol("holder"),h=[];a.forEach((a,i)=>{let d=o.indexOf(a);if(-1===d){let r=ye({host:e,data:a,index:i,tempData:c,temps:s});n&&ge(r,n,t,e),h.push(r.ele)}else{let e=r[d];e.__fill_item.$index=i,h.push(e),o[d]=l}});const d=[];o.forEach((e,t)=>{if(e!==l){let e=r[t];d.push(e),i.removeChild(e)}}),d.forEach(e=>pe(e)),J(i,h)}else a.forEach((r,a)=>{const o=ye({host:e,data:r,index:a,tempData:c,temps:s});n&&ge(o,n,t,e),i.appendChild(o.ele)}),o=a.xid}});ce(r,h)})},ge=(e,t,r,s)=>{let a=e.$item;Object.keys(t).forEach(n=>{let i=t[n];const o=$(n);let l=le({xdata:r,host:s,expr:i,callback:({val:e})=>{a[o]=e}});ce(e.ele,l)})},ye=({host:e,data:t,index:r,tempData:s,temps:a})=>{const n=O(S(s.code)[0]),o=E({get $host(){return e},$index:r,get $data(){return t},get $item(){return o}});return i(n,{$item:{get:()=>o},$data:{get:()=>t}}),n.ele.__fill_item=o,fe({host:e,xdata:o,content:n.ele,temps:a}),n};function be(e){if(e instanceof Element)return O(e);const t=s(e);let r;return"string"==t?r=/\<.+\>/.test(e)?S(e)[0]:document.querySelector(e):"object"==t?r=L(e):(e===document||e instanceof DocumentFragment)&&(r=e),r?O(r):null}Object.assign(be,{all:e=>Array.from(document.querySelectorAll(e)).map(e=>O(e)),register:Q,xdata:e=>E(e),nextTick:h,fn:H.prototype,tag:e=>{if(e=$(e),B[e])return B[e];let t=new Promise(t=>{Z[e]=t});return B[e]=t,t}}),(e=>{const t=()=>Math.random().toString(32).substr(2);var r=Object.prototype.toString;const s=e=>(e=>r.call(e).toLowerCase().replace(/(\[object )|(])/g,""))(e).search("function")>-1;const{defineProperties:a}=Object,n=(()=>{const e=e=>Promise.resolve().then(()=>e());return"object"==typeof process&&process.nextTick&&(e=process.nextTick),e})(),i=new Map,o=(t,r)=>{i.set(t,r),a(e,{[t]:{value:e=>{let s=document.currentScript.src,a=u(s);a||(a=new m(s),p(s,a)),a.status=1,a.ptype=t,r({respone:e,record:a,relativeLoad(...e){let t=new E(...e);return t.__relative__=s,t}})}}})};o("define",async({respone:e,record:t,relativeLoad:r})=>{let a;if(s(e)){const s={};let n=await e({load:r,FILE:t.src,exports:s});void 0!==n||(e=>!(0 in Object.keys(e)))(s)||(n=s),a=(e=>n)}else a=(t=>e);t.done(a)}),o("task",async({respone:e,record:t,relativeLoad:r})=>{if(!s(e))throw"task must be a function";t.done(async s=>await e({data:s.data,load:r,FILE:t.src}))});const l=new Map,c=(e,t)=>{l.set(e,r=>{const s=u(r);return s.type=e,t({src:r,record:s})})};c("js",({src:e,record:t})=>new Promise((r,s)=>{let a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=e,t.sourceElement=a,a.addEventListener("load",async()=>{t.loadedTime=Date.now(),0==t.status&&(t.ptype="script",t.done(e=>{})),r()}),a.addEventListener("error",e=>{s({desc:"load script error",event:e})}),document.head.appendChild(a)})),c("mjs",async({src:e,record:t})=>{let r=await import(e);t.done(()=>r)}),c("wasm",async({src:e,record:t})=>{let r=await fetch(e).then(e=>e.arrayBuffer()),s=await WebAssembly.compile(r);const a=new WebAssembly.Instance(s);t.done(()=>a.exports)}),c("json",async({src:e,record:t})=>{let r=await fetch(e);r=await r.json(),t.done(()=>r)}),c("css",async({src:e,record:t})=>{let r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=e,t.sourceElement=r;let s=!1;t.done(async e=>{if(e.params.includes("-unpull"))return r;s||(document.head.appendChild(r),s=!0),r.sheet||await new Promise(e=>{r.addEventListener("load",t=>{e()})})})}),["html"].forEach(e=>{c(e,async({src:e,record:t})=>{let r=await fetch(e).then(e=>e.text());t.done(()=>r)})});const h=async({src:e,record:t})=>{let r=await fetch(e);if(!r.ok)throw{desc:"fetch "+r.statusText,response:r};t.done(()=>r)},d=new Map,p=(e,t)=>{let r=new URL(e);d.set(r.origin+r.pathname,t)},u=e=>{let t=new URL(e);return d.get(t.origin+t.pathname)};class m{constructor(e){this.src=e,this.status=0,this.bid="b_"+t(),this.data=new Promise((e,t)=>{this.__resolve=e,this.__reject=t}),this.startTime=Date.now()}done(e){this.status=2,this.__resolve(e),delete this.__resolve,delete this.__reject,this.doneTime=Date.now()}fail(e){this.status=-1,this.__reject(data),delete this.__resolve,delete this.__reject,this.doneTime=Date.now()}}const f={};const g=new Map;class y{constructor(e,t){let[r,...s]=e.split(" ");this.url=r,this.params=s,this.bag=t}get src(){let{url:e}=this;if(/^@.+/.test(e))for(let[t,r]of g)if(t.test(e)){e=e.replace(t,r);break}if(this.params.includes("-p")){e+=`/${e.replace(/.+\/(.+)/,"$1")}.js`}return new URL(e,this.relative).href}get ftype(){let e=new URL(this.src).pathname.replace(/.+\.(.+)/,"$1");return this.params.some(t=>{if(/^:(.+)/.test(t))return e=t.replace(/^:(.+)/,"$1"),!0}),e}get data(){return this.bag[_]}get relative(){return this.bag.__relative__||location.href}}function b(e){e.args.forEach(t=>e.result.push(void 0));let t=0,r=!1,{result:s}=e;const a=e[v];e.args.forEach((n,i)=>{let o=new y(n,e),c=n=>{s[i]=n,t++,a&&a({index:i,pkg:o,data:n}),1===e.args.length?e[x](n):t!==e.args.length||r||e[x](s),c=null};o.params.includes("-link")?c(o.src):o.params.includes("-pkg")?c(o):async function(e){let t=u(e.src);if(t){if(-1==t.status)throw{expr:e.url,src:t.src};const r=await t.data;return await r(e)}t=new m(e.src),p(e.src,t);let r=l.get(e.ftype);try{r?await r(t.src):(f[e.ftype]||(console.warn({desc:"did not find this loader",type:e.ftype}),f[e.ftype]=1),await h({src:t.src,record:t}))}catch(e){t.fail(e)}const s=await t.data;return await s(e)}(o).then(c).catch(t=>{r=!0,t&&console.error({expr:n,src:o.src,...t}),s[i]=t,e[w]({expr:n,src:o.src,error:t}),c=null})})}const x=Symbol("resolve"),w=Symbol("reject"),_=Symbol("postData"),v=Symbol("pendFunc");class E extends Promise{constructor(...e){if(s(e[0]))return super(...e),this;let r,i;super((e,t)=>{r=e,i=t}),this.id="d_"+t(),a(this,{[x]:{value:r},[w]:{value:i},args:{value:e},result:{value:[]},__relative__:{writable:!0,value:""}}),n(()=>b(this))}pend(e){if(this[v])throw{desc:"pend has been used",target:this};return a(this,{[v]:{value:e}}),this}post(e){if(this[_])throw{desc:"post has been used",target:this};return a(this,{[_]:{value:e}}),this}}const k=e.load=((...e)=>new E(...e));a(e,{drill:{value:{load:k,config:e=>{let{paths:t}=e;t&&Object.keys(t).forEach(e=>{let r=t[e];if(!/^@.+\/$/.test(e))throw{desc:"incorrect definition of paths",key:e};if(!/.+\/$/.test(e))throw{desc:"incorrect definition of paths",key:e,path:r};g.set(new RegExp("^"+e),r)})},async has(e){let t=await k(`${e} -link`);return!!u(t)},async remove(e){let t=await k(`${e} -link`),r=u(t).sourceElement;r&&r.parentNode.removeChild(r),d.delete(t)},ext(e){e({bag:d,addLoader:c,addProcess:o})},bag:d,version:"4.0.0",v:4e6}}})})("undefined"!=typeof globalThis?globalThis:window),drill.ext(({addProcess:e})=>{e("Component",async({respone:e,record:t,relativeLoad:r})=>{let s=e;a(e)&&(s=await e({load:r,FILE:t.src}));const n=await xe(t,r,s);Q(n),t.done(async e=>{})})});const xe=async(e,t,r)=>{const s={temp:"",data:{},attrs:{},proto:{},watch:{}};Object.assign(s,r);let a=new URL(e.src).pathname.replace(/.*\/(.+)/,"$1").replace(/\.js$/,"");if(s.tag||(s.tag=a),""===s.temp){let e=await t(`./${a}.html`);s.temp=await we(e,t)}return s},we=async(e,t)=>{let r=document.createElement("template");r.innerHTML=e;let s=r.content.querySelectorAll("[href]"),a=r.content.querySelectorAll("[src]"),n=r.content.querySelectorAll('[style*="url("]');const i=[];s&&Array.from(s).forEach(e=>{i.push((async()=>{let r=await t(`${e.getAttribute("href")} -link`);e.setAttribute("href",r)})())}),a&&Array.from(a).forEach(e=>{i.push((async()=>{let r=await t(`${e.getAttribute("src")} -link`);e.setAttribute("src",r)})())}),n&&Array.from(n).forEach(e=>{i.push((async()=>{e.setAttribute("style",await _e(e.getAttribute("style"),t))})())});let o=r.content.querySelectorAll("style");return o&&Array.from(o).forEach(e=>{i.push((async()=>{e.innerHTML=await _e(e.innerHTML,t)})())}),await Promise.all(i),r.innerHTML},_e=async(e,t)=>{let r=e.match(/url\(.+?\)/g);return r&&await Promise.all(r.map(async r=>{let s=r.replace(/url\((.+?)\)/,"$1"),a=await t(`${s} -link`);e=e.replace(r,`url(${a})`)})),e};drill.ext(({addProcess:e})=>{e("Page",async({respone:e,record:t,relativeLoad:r})=>{let s=e;a(e)&&(s=await e({load:r,FILE:t.src}));const n=await xe(t,r,s);let i=Y(n.temp);n.temp=i.html;const o=X(n);t.done(async e=>({defaults:n,cansetKeys:o,temps:i.temps}))})});const ve=Symbol("page_status"),Ee=e=>{if(e.parent.is("o-app"))return e;for(;e.host;)if((e=e.host).is("o-page")&&e.parent.is("o-app"))return e};Q({tag:"o-page",attrs:{src:null,[ve]:"empty"},proto:{get status(){return this[ve]},get app(){let e=Ee(this);if(e)return e.parent;throw{desc:"cannot find the app",target:this}},get query(){const e=new URLSearchParams(this.src.replace(/.+(\?.+)/,"$1"));let t={};for(const[r,s]of e.entries())t[r]=s;return t},navigateTo(e){let t=Ee(this);const{router:r}=this.app;let s=r.findIndex(e=>e._page==t);r.splice(s+1,r.length,e)},replaceTo(e){let t=Ee(this);const{router:r}=this.app;let s=r.findIndex(e=>e._page==t);r.splice(s,r.length,e)},back(){this.app.back()}},watch:{async src(t){if(!t)return;if("empty"!==this[ve])throw{desc:"src can only be set once",target:this};let r;this[ve]="loading",this._waiting&&await this._waiting;try{let s=await load(t);this._realsrc=await load(t+" -link");const a=new Set([...Array.from(this[M]),...s.cansetKeys]);a.delete("src"),this[M]=a,r=s.defaults,p(this,r.proto),V({xele:this,defs:Object.assign({},r,{attrs:{}}),temps:s.temps,_this:this.ele}).then(e=>{this.ele.x_render=2,this.attr("x-render",2)})}catch(t){return void(e.ofa&&(this.html=je.onState.loadError(t),this[ve]="error"))}this[ve]="loaded",b(this,{xid:this.xid,name:"setData",args:["status",this[ve]]}),r.attached&&this.__attached_pms.then(()=>r.attached.call(this)),r.detached&&this.__detached_pms.then(()=>r.detached.call(this))}},created(){this.__attached_pms=new Promise(e=>this.__attached_resolve=e),this.__detached_pms=new Promise(e=>this.__detached_resolve=e)},attached(){this.__attached_resolve()},detached(){this.__detached_resolve()}});Symbol("router_page");const ke=[];Q({tag:"o-app",temp:'<style>:host{display:block}::slotted(o-page){position:absolute;left:0;top:0;width:100%;height:100%}::slotted(o-page[page-area]){transition:all ease-in-out .25s;z-index:2}::slotted(o-page[page-area=back]){transform:translate(-30%,0);opacity:0;z-index:1}::slotted(o-page[page-area=next]){transform:translate(30%,0);opacity:0;z-index:1}.container{display:flex;flex-direction:column;width:100%;height:100%}.main{position:relative;flex:1}.article{position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden}</style><style id="initStyle">::slotted(o-page[page-area]){transition:none}</style><div class="container"><div><slot name="header"></slot></div><div class="main"><div class="article" part="body"><slot></slot></div></div></div>',attrs:{home:"",src:""},data:{router:[],rect:{width:"",height:""},visibility:document.hidden?"hide":"show"},watch:{async src(e){if(!e||this._loaded_src)return;this._loaded_src=1;let t=await load(e);t.data&&Object.assign(this,t.data),t.proto&&this.extend(t.proto),t.ready&&t.ready.call(this),this.home&&!this.router.length&&this.router.push({path:this.home})},home(e){this.src||!e||this.router.length||this.router.push({path:e})},router(t){if(!t.length)return;let r=this._backup_router;r||(r=this._backup_router=[]);const s=r.filter(e=>!t.includes(e)),a=[];let n=t.length-1;const i=t.map((s,i)=>{if("string"==typeof s&&(s=E({path:s})).owner.add(t[u]),!s._page){let t,r=s._page=be({tag:"o-page",src:s.path});e.ofa&&je.onState.loading&&r.push(je.onState.loading({src:s.path})),r._waiting=new Promise(e=>t=e),r.__waiter_resolve=t}if(s.state&&void 0===s._page.state){let e=s.state;p(s._page,{get state(){return e}})}return r.includes(s)||a.push(s),i<n?s._page.attr("page-area","back"):i==n&&(null===s._page.attr("page-area")?(s._page.attr("page-area","next"),setTimeout(()=>{"next"===s._page.attr("page-area")&&s._page.attr("page-area","")},10)):s._page.attr("page-area","")),i+2>n&&s._page.__waiter_resolve&&(s._page.__waiter_resolve(),delete s._page.__waiter_resolve),s});a.forEach(e=>{this.push(e._page)}),s.forEach(e=>{if(e._page.attr("page-area","next"),parseFloat(e._page.css.transitionDuration)>0){let t=setTimeout(()=>e._page.remove(),500);e._page.one("transitionend",()=>{e._page.remove(),clearTimeout(t)})}else e._page.remove()}),t[u].splice(0,1e3,...i),this._backup_router=t.slice(),t.slice(-1)[0]._page.trigger("activepage")}},proto:{get currentPage(){return this.router.slice(-1)[0]._page},back(){const e=new Event("back",{cancelable:!0});this.triggerHandler(e),e.returnValue&&this.router.length>1&&this.router.splice(-1,1)},get globalData(){return Oe},postback(e){let t;if(top!==window)t=top;else{if(!opener)return console.warn("can't use postback"),!1;t=opener}return t.postMessage({type:"web-app-postback-data",data:e},"*"),!0}},ready(){window.addEventListener("visibilitychange",e=>{this.visibility=document.hidden?"hide":"show"}),setTimeout(()=>{this.shadow.$("#initStyle").remove()},150)},attached(){ke.push(this)},detached(){let e=ke.indexOf(this);e>-1&&ke.splice(e,1)}});const Oe={message:null};if(opener&&!opener.closed){if("complete"==document.readyState)opener.postMessage({type:"web-app-postback-data",command:"complete"},"*");else{let t=()=>{opener.postMessage({type:"web-app-postback-data",command:"complete"},"*"),e.removeEventListener("load",t),t=null};e.addEventListener("load",t)}e.addEventListener("beforeunload",e=>{opener.postMessage({type:"web-app-postback-data",command:"close"},"*")})}(opener||top!==window)&&e.addEventListener("message",e=>{let{data:t}=e;if(!t||!t.type)return;const{type:r}=t;if(t=t.data,"web-app-post-init-data"==r)Oe.initial=t;else{if("web-app-post-data"!==r)return;Oe.message=t,ke.forEach(e=>e.triggerHandler("message",t))}ke.forEach(e=>b(e,{xid:e.xid,name:"message"}))});let Ae=e.ofa;const je={v:3e6,version:"3.0.0",get config(){return drill.config},onState:{loading:e=>'<div style="display:flex;justify-content:center;align-items:center;width:100%;height:100%;font-size:14px;color:#aaa;">Loading</div>',loadError:e=>`<div style="text-align:center;"><h2>load Error</h2><div style="color:#aaa;">error expr:${e.expr} <br>error src:${e.src}</div></div>`},get apps(){return ke.slice()}};i(e,{ofa:{set(e){e(je)},get:()=>je}}),Ae&&Ae(je),drill.config({paths:{"@lib/":"https://cdn.jsdelivr.net/gh/kirakiray/ofa.js/lib/"}}),e.$=be})(window);