magix
Version:
view manager framewrok
1 lines • 18.8 kB
JavaScript
/*!3.8.14 MIT kooboy_li@163.com*/KISSY.add("magix",(e,t,r,n)=>{let i=e.all,o=e.isObject,l=e.isArray,a=0,f="",s=[],h=window,d=void 0,$=document,u=$.documentElement.getAttribute,c=(e,t)=>u.call(e,t),p=i($),m=h.setTimeout;function g(){}let b,v=JSON.stringify,w="\x1e",y="prototype",x="params",k=/[#?].*$/,V=/([^=&?\/#]+)=?([^&#?]*)/g,I=/(?!^)=|&/,T=e=>(e||"mx_")+a++,S=T(),C={rootId:T(),defaultView:S,error(e){throw e}},j=e=>"object"==typeof e?e:$.getElementById(e),q=e=>!e||"object"!=typeof e,A=(e,t,r,n)=>{let i,o,l,a=0;for(l in e)i=e[l],o=t[l],q(i)&&o===i||L(n,l)||(r[l]=1,a=1),t[l]=i;return a},U=(e,t,r)=>{if(e=j(e),t=j(t),e&&t&&!(r=e==t))try{r=16==(16&t.compareDocumentPosition(e))}catch(e){}return r},{assign:E,keys:N,hasOwnProperty:O}=Object,H=i("head"),M=(e,t)=>{t&&!M[e]&&(M[e]=1,H.append(`<style>${t}`))},P=e=>c(e,"id")||(e.$a=1,e.id=T()),_=(e,t,r,n,i)=>{for(i of(t=t||s,l(e)||(e=[e]),l(t)||(t=[t]),e))try{n=i&&i.apply(r,t)}catch(e){C.error(e)}return n},L=(e,t)=>e&&O.call(e,t),R=(e,t)=>{let r,n;if(q(t))(r=t+f)[0]==w&&L(e,r)&&(t=e[r]);else for(r in t)n=t[r],n=R(e,n),t[r]=n;return t},Z=(e,t)=>t.f-e.f||t.t-e.t;function B(e,t,r,n){(n=this).c=[],n.b=t||5,n.x=n.b+(e||20),n.r=r}E(B[y],{get(e){let t=this.c[w+e];return t&&(t.f++,t.t=a++,t=t.v),t},each(e,t,r,n,i){for(i of(r=this).c)e(i.v,t,r)},set(e,t){let r=this,n=r.c,i=w+e,o=n[i],l=r.b;if(!o){if(n.length>=r.x)for(n.sort(Z);l--;)(o=n.pop()).f>0&&r.del(o.o);o={o:e},n.push(o),n[i]=o}o.v=t,o.f=1,o.t=a++},del(e){e=w+e;let t=this.c,r=t[e],n=this.r;r&&(r.f=-1,r.v=f,delete t[e],n&&_(n,r.o))},has(e){return L(this.c,w+e)}});let D=(t,r)=>{e.use(t&&t+f,(e,...t)=>{r&&r.apply(e,t)})},z=e.extend,F=r.test;function J(e,t){t=this,e.eventTarget=t.e,_(t.f,e,t.v)}let K=(e,r,n,i,o)=>{o?t[`${i?"un":f}delegate`](e,r,n,o):t[i?"detach":"on"](e,r,n,o)},Q=e=>e;let X,Y=new B,G=0,W=(e,t,r)=>{try{r=decodeURIComponent(r)}catch(e){}X[t]=r},ee=e=>{let t,r=Y.get(e);return r||(X={},t=e.replace(k,f),e==t&&I.test(t)&&(t=f),e.replace(t,f).replace(V,W),Y.set(e,r={a:t,b:X})),{path:r.a,params:{...r.b}}},te=(e,t,r)=>{let n,i,o,l=[];for(i in t)n=t[i]+f,(!r||n||L(r,i))&&(n=encodeURIComponent(n),l.push(o=i+"="+n));return o&&(e+=(e&&(~e.indexOf("?")?"&":"?"))+l.join("&")),e},re=(e,t)=>{let r,n={};if(e)for(r of e)n[t&&r?r[t]:r]=t?r:1+(0|n[r]);return n},ne=new B,ie=(e,t,r)=>(ne.has(e)?r=ne.get(e):(r=_(Function(`return ${e}`)),e.indexOf(w)>-1?R(t,r):ne.set(e,r)),r),oe={config:(e,t)=>(t=C,e&&(t=o(e)?E(t,e):t[e]),t),boot(e){E(C,e),D(C.ini,t=>{E(C,t,e),D(C.exts,()=>{Ee.on("changed",Pe),ue.on("changed",Pe),G=1,je()})})},toMap:re,toTry:_,toUrl:te,parseUrl:ee,mix:E,has:L,keys:N,inside:U,node:j,applyStyle:M,guid:T,use:D,Cache:B,nodeId:P,guard:Q},le={fire(e,t,r,n){let i,o,l,a,s=this,h=s[w+e];if(t||(t={}),t.type=e,h)for(o=(i=h.length)-1;i--;)(a=h[l=n?i:o-i]).f?(a.x=1,_(a.f,t,s),a.x=f):a.x||(h.splice(l,1),o--);return(h=s[`on${e}`])&&_(h,t,s),r&&s.off(e),s},on(e,t){let r=w+e;return(this[r]||(this[r]=[])).push({f:t}),this},off(e,t){let r,n=w+e,i=this,o=i[n];if(t){if(o)for(r of o)if(r.f==t){r.f=f;break}}else delete i[n],delete i[`on${e}`];return i}};oe.Event=le;let ae={},fe={},se={},he=0,de=e=>{e=(e+f).split(",");for(let t of e)L(fe,t)?fe[t]++:fe[t]=1;return e},$e=e=>{let t,r;for(t of e)L(fe,t)&&((r=--fe[t])||(delete fe[t],delete ae[t]))};let ue={get(e){let t=e?ae[e]:ae;return t},set(e,t){return he=A(e,ae,se,t)||he,this},digest(e,t){if(e&&ue.set(e,t),he){0,he=0;let e=E({},se);se={},this.fire("changed",{keys:e})}},diff:()=>se,clean:e=>({ctor(){e=de(e),this.on("destroy",()=>$e(e))}}),...le};oe.State=ue;let ce,pe=new B,me=new B,ge=h.location,be=0,ve={query:{},params:{},href:f},we=/(?:^.*\/\/[^\/]+|#.*$)/gi,ye=/^[^#]*#?!?/;function xe(e,t){return this[x][e]||t!==d&&t||f}let ke,Ve,Ie,Te,Se,Ce=(e,t)=>{e="#!"+e,t?ge.replace(e):ge.hash=e},je=()=>{let e,t,r=Ae().srcHash;K(h,"hashchange",(n,i,o)=>{t||(i=Ae(),(e=i.srcHash)!=r&&(o=(()=>{n.p=1,r=e,t=f,Ce(e),Ue()}),n={reject(){n.p=1,t=f,Ce(r)},resolve:o,prevent(){t=1}},Ee.fire("change",n),t||n.p||o()))}),K(h,"beforeunload",(e,t,r)=>{if(e=e||h.event,t={},Ee.fire("pageunload",t),r=t.msg)return e&&(e.returnValue=r),r}),Ue()},qe=$.title,Ae=e=>{e=e||ge.href;let t,r,n,i,l,a=pe.get(e);return a||(t=e.replace(we,f),r=e.replace(ye,f),a={get:xe,href:e,srcQuery:t,srcHash:r,query:n=ee(t),hash:i=ee(r),params:l={...n[x],...i[x]}},G&&(((e,t)=>{if(ke||(ke=C.routes||{},Ve=C.unmatchView,Ie=C.defaultView,Te=C.defaultPath||"/",Se=C.rewrite),!e.view){let r=e.hash.path||Te;Se&&(r=Se(r,e[x],ke)),t=ke[r]||Ve||Ie,e.path=r,e.view=t,o(t)&&E(e,t)}})(a),pe.set(e,a))),a},Ue=()=>{let e=Ae(),t=((e,t)=>{let r=e.href,n=t.href,i=r+w+n,o=me.get(i);if(!o){let n,l;o={params:l={},force:!r};let a,f=e[x],s=t[x],h=N(f).concat(N(s)),d=e=>{let t=f[e],r=s[e];t!=r&&(l[e]={from:t,to:r},n=1)};for(a of h)d(a);f=e,s=t,l=o,d("path"),d("view"),me.set(i,o={a:n,b:o})}return o})(ve,ve=e);return!be&&t.a&&((ce=t.b).path&&($.title=e.title||qe),Ee.fire("changed",ce)),be=0,ce},Ee={parse:Ae,diff:Ue,to(e,t,r,n){!t&&o(e)&&(t=e,e=f);let i=ee(e),l=i[x],a=i.path,s=ve.path,h=ve[x],d=ve.query[x];if(E(l,t),a)for(s in d)L(l,s)||(l[s]=f);else h&&(a=s,l={...h,...l});((e,t,r,n,i,o)=>{(e=te(e,t,o))!=r.srcHash&&(be=i,Ce(e,n))})(a,l,ve,r,n,d)},...le};oe.Router=Ee;let Ne,Oe,He=0,Me=(e,t,r,n,i,o,l)=>{e&&e.$a!=He&&(r=e.$v)&&r.$a>1&&((t?((e,t,r)=>{let n,i=e.$os;if(i)for(n of i)if(r=L(t,n))break;return r})(r,t):Lt(r))&&(l=r.$b()),l&&l.then||(l=Le),l.then(()=>{for(o of e.children())Me(_e[o],t)}))},Pe=(e,t,r)=>{t=De(),(r=e.view)?t.mountView(r.to):(He=a++,Me(t,e.keys))},_e={},Le={then:e=>e()},Re=e=>{if(!e.$b&&!e.$d&&e.$cc==e.$rc){e.$cr||(e.$cr=1,e.$ca=0,e.fire("created"));let{id:t,pId:r}=e,n=_e[r];n&&!L(n.$e,t)&&(n.$e[t]=1,n.$rc++,Re(n))}},Ze=(e,t)=>{if(!e.$ca&&e.$cr){e.$cr=0,e.$ca=1,e.fire("alter",t);let{id:r,pId:n}=e,i=_e[n];i&&L(i.$e,r)&&(i.$rc--,delete i.$e[r],Ze(i,t))}},Be=(e,t,r,n)=>(n=(n=(n=_e[e])&&n.$v)?n.$d.$a:{},t.indexOf(w)>0&&R(n,r),n),De=e=>(Ne||(b=$.body,e=C.rootId,j(e)||(b.id=e),Ne=new Ke(e)),Ne),ze=(e,t)=>{L(_e,e)||(_e[e]=t,Ke.fire("add",{vframe:t}),(e=j(e))&&(e.vframe=t))},Fe=(e,t,r)=>{for(t=e.$f;t.length;)(r=t.shift()).r||e.invoke(r.n,r.a),delete t[r.k]},Je=[];function Ke(e,t,r){(r=this).id=e,r.$c={},r.$cc=0,r.$rc=0,r.$g=r.$g||1,r.$e={},r.$f=[],r.pId=t,ze(e,r)}E(Ke,{all:()=>_e,get:e=>_e[e]},le),E(Ke[y],le,{mountView(e,t){let r,n,i,o,l,a=this,s=a.id,h=j(s),d=a.pId;!a.$h&&h&&(a.$h=1,a.$i=h.innerHTML),a.unmountView(),a.$b=0,r=ee(e||f),i=r.path,h&&i&&(a.path=e,o=r[x],Be(d,e,o),a.$j=r.path,E(o,t),n=a.$g,D(i,e=>{if(n==a.$g){if(!e)return C.error(Error(`id:${s} cannot load:${i}`));l=_t(e),i=new e(s,a,o,h,l),a.$v=i,a.$a=He,Ot(i),_(i.init,[o,{node:h,deep:!i.tmpl}],i),i.$b(),i.tmpl||(a.$h=0,i.$e||i.endUpdate())}}))},unmountView(){let e,t,r=this,{$v:n,id:o}=r;r.$f=[],n&&(Oe||(t=1,Oe={id:o}),r.$b=1,r.unmountZone(0,1),Ze(r,Oe),r.$v=0,n.$a>0&&(n.$a=0,delete We[o],delete et[o],n.fire("destroy",0,1,1),Ut(n,1),Ot(n,1),n.owner=0),n.$a--,(e=j(o))&&r.$h&&i(e).html(r.$i),t&&(Oe=0)),r.$g++},mountVframe(e,t,r){let n,i=this,o=i.id,l=i.$c;return Ze(i,{id:e}),(n=_e[e])||(L(l,e)||(i.$n=0,i.$cc++),l[e]=e,(n=Je.pop())?Ke.call(n,e,o):n=new Ke(e,o)),n.mountView(t,r),n},mountZone(e,t){let r,n,o=this,l=[];e=e||o.id;let a=i(`#${e} [mx-view]`);for(r of(o.$d=1,a))r.$b||(n=P(r),r.$b=1,l.push([n,c(r,"mx-view")]));for([n,r]of l)o.mountVframe(n,r);o.$d=0,t||Re(o)},unmountVframe(e,t){let r;if(e=e?this.$c[e]:this.id,r=_e[e]){let{$cr:n,pId:i}=r;r.unmountView(),((e,t,r)=>{(r=_e[e])&&(delete _e[e],Ke.fire("remove",{vframe:r,fcc:t}),(e=j(e))&&(e.$b=0,e.vframe=0,e.$a=0))})(e,n),r.id=r.pId=r.$c=r.$e=0,r.$h=0,r.off("alter"),r.off("created"),Je.push(r),(r=_e[i])&&L(r.$c,e)&&(delete r.$c[e],r.$n=0,r.$cc--,t||Re(r))}},unmountZone(e,t){let r,n=this;for(r in n.$c)(!e||r!=e&&U(r,e))&&n.unmountVframe(r,1);t||Re(n)},parent(e,t){for(t=this,e=e>>>0||1;t&&e--;)t=_e[t.pId];return t},children(e){return(e=this).$n||(e.$n=N(e.$c))},invoke(e,t){let r,n,i,o,l,a=this.$f;return(n=this.$v)&&n.$e?r=(i=n[e])&&_(i,t,n):((o=a[l=w+e])&&(o.r=t===o.a),o={n:e,a:t,k:l},a.push(o),a[l]=o),r}}),oe.Vframe=Ke,n[y].invokeView=function(e,t){let r,n,i=[];for(r of this)n=r.vframe,i.push(n&&n.invoke(e,t));return i};let Qe=new B(30,10),Xe=/(?:([\w\-]+)\x1e)?([^(]+)\(([\s\S]*)?\)/,Ye={},Ge={},We={},et={},tt=0,rt=(e,t)=>{let r,n,i,o,l,a,f=[],h=e,d=c(e,`mx-${t}`),$=[],u="#",p=0;if(d&&((l=Qe.get(d))||(l={v:(l=d.match(Xe)||s)[1],n:l[2],i:l[3]},Qe.set(d,l)),l={...l,r:d}),l&&!l.v||Ge[t]){if((i=et[n=h.$d])&&1==i[h.$e]&&(a=1,u=n),!a){for($.push(h);h!=b&&(h=h.parentNode);){if(_e[n=h.id]||(i=et[n=h.$d])&&1==i[h.$e]){u=n;break}$.push(h)}for(d of $)(n=et[u])||(n=et[u]={}),n[i=d.$e||(d.$e=++tt)]=1,d.$d=u}h=e.id,_e[h]&&(p=u=h);do{if((r=_e[u])&&(a=r.$v)){if(o=(i=a.$so)[t])for(h=o.length;h--;)i={r:n=o[h],v:u,n:n},n?!p&&F(e,n)&&f.push(i):p&&f.unshift(i);if(a.tmpl&&!p){l&&!l.v&&(l.v=u);break}p=0}}while(r&&(u=r.pId))}return l&&f.push(l),f},nt=e=>{let t,r,n,i,o,l,a,f,{target:s,type:h}=e,d=[];for(;s!=b;){if((t=rt(s,h)).length){d=[];for(let{v:r,r:d,n:$,i:u}of t){if(a!=r){if(a&&e.isPropagationStopped())break;a=r}(i=(n=_e[r])&&n.$v)?(l=i[o=$+w+h])&&(e.eventTarget=s,f=u?ie(u,i.$d.$a):{},e[x]=f,_(l,e,i)):e.stopPropagation()}}if((r=We[l=s.$d])&&(r=r[s.$e])&&r[h]||e.isPropagationStopped()){d.length&&d.push(l);break}a=s.id,_e[a]&&d.push(a),d.push(s),s=s.parentNode||b}if(l=d.length)for(r="#";l--;)(i=d[l]).nodeType?((t=We[r])||(t=We[r]={}),(f=t[a=i.$e||(i.$e=++tt)])||(f=t[a]={}),f[h]=1):r=i},it=(e,t,r)=>{let n=0|Ye[e],i=r?-1:1;n&&r!==n||K(b,e,nt,r),Ye[e]=n+i,t&&(Ge[e]=(0|Ge[e])+i)},ot="http://www.w3.org/2000/svg",lt="http://www.w3.org/1998/Math/MathML",at={option:[1,"<select multiple>"],thead:[1,"<table>"],col:[2,"<table><colgroup>"],tr:[2,"<table><tbody>"],td:[3,"<table><tbody><tr>"],area:[1,"<map>"],param:[1,"<object>"],g:[1,`<svg xmlns="${ot}">`],m:[1,`<math xmlns="${lt}">`],_:[0,""]},ft=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i;at.optgroup=at.option,at.tbody=at.tfoot=at.colgroup=at.caption=at.thead,at.th=at.td;let st=$.implementation.createHTMLDocument(f),ht=st.createElement("base");ht.href=$.location.href,st.head.appendChild(ht);let dt=(e,t)=>{if(1==t.nodeType){let r=P(t);e.unmountZone(r,1),e.$c[r]&&e.unmountVframe(r,1)}},$t={INPUT:["value","checked"],TEXTAREA:["value"],OPTION:["selected"]},ut=(e,t)=>(1==e.nodeType&&(e.$f?t=e.$g:((t=e.$a?f:c(e,"id"))||(t=c(e,"mxs")),t||(t=c(e,"mx-view"))&&(t=ee(t).path),e.$f=1,e.$g=t)),t),ct=(e,t,r,n,i)=>{let o,l,a,f,s,h=e.lastChild,d=t.firstChild,$=0,u={},c={};for(;h;)$++,(a=ut(h))&&(a=u[a]||(u[a]=[])).push(h),h=h.previousSibling;for(;d;)(a=ut(d))&&(c[a]=(c[a]||0)+1),d=d.nextSibling;for(d=t.firstChild,h=e.firstChild;d;)if($--,o=d,d=d.nextSibling,(f=u[a=ut(o)])&&(f=f.pop())){for(;f!=h;)s=h.nextSibling,e.appendChild(h),h=s;h=f.nextSibling,c[a]&&c[a]--,pt(f,o,e,r,n,i)}else h?(a=ut(l=h))&&u[a]&&c[a]?($++,r.c=1,r.n.push([8,e,o,l])):(h=h.nextSibling,pt(l,o,e,r,n,i)):(r.c=1,r.n.push([1,e,o]));for(l=e.lastChild;$-- >0;)dt(n,l),r.n.push([2,e,l]),l=l.previousSibling,r.c=1},pt=(e,t,r,n,i,o)=>{if(((e,t)=>{let r,n=e.nodeName,i=$t[n],o=0;if(i)for(r of i)e[r]!=t[r]&&(o=1,e[r]=t[r]);return o})(e,t)||1==e.nodeType&&e.hasAttribute("mxv")||!e.isEqualNode||!e.isEqualNode(t))if(e.nodeName===t.nodeName)if(1===e.nodeType){let r=c(t,"mxs");if(r&&r==c(e,"mxs"))return;let l,a,s,h,d,$,u,p=c(t,"mx-view"),m=t.innerHTML,g=c(t,"mxa"),b=!g||g!=c(e,"mxa"),v=_e[c(e,"id")],w=p&&ee(p);if(p&&v&&(!c(t,"id")||c(t,"id")==c(e,"id"))&&v.$j==w.path&&(h=v.$v)){if($=m!=v.$i,u=p!=v.path,s=c(e,"mxv"),!$&&!u&&s)for(s of d=s.split(","))if("#"==s||L(o,s)){u=1;break}(u||$)&&((s=h.$e&&h.$f)?(d=w[x],Be(v.pId,p,d),v.$i=m,v.path=p,w={node:t,deep:!h.tmpl,attr:b,inner:$,query:u,keys:o},_(s,[d,w],h)&&n.v.push(h),l=w.deep):(a=1,l=1))}else l=1,a=v;a&&(n.c=1,v.unmountVframe(0,1)),b&&((e,t,r,n)=>{let i,o,l,a;delete e.$f;let s=e.attributes,h=t.attributes;for(o=s.length;o--;)i=s[o].name,t.hasAttribute(i)||("id"==i?n||r.d.push([e,f]):(r.c=1,e.removeAttribute(i)));for(o=h.length;o--;)l=(i=h[o]).name,a=i.value,c(e,l)!=a&&("id"==l?r.d.push([e,a]):(r.c=1,e.setAttribute(l,a)))})(e,t,n,v&&p),l&&ct(e,t,n,i,o)}else e.nodeValue!==t.nodeValue&&(n.c=1,e.nodeValue=t.nodeValue);else dt(i,e),n.c=1,n.n.push([4,r,t,e])},mt={"&":"amp","<":"lt",">":"gt",'"':"#34","'":"#39","`":"#96"},gt=/[&<>"'\`]/g,bt=e=>""+(null==e?"":e),vt=e=>`&${mt[e]};`,wt=e=>bt(e).replace(gt,vt),yt=(e,t,r,n)=>{for(n=e[w];--n;)if(e[r=w+n]===t)return r;return e[r=w+e[w]++]=t,r},xt={"!":"%21","'":"%27","(":"%28",")":"%29","*":"%2A"},kt=e=>xt[e],Vt=/[!')(*]/g,It=e=>encodeURIComponent(bt(e)).replace(Vt,kt),Tt=/[\\'"]/g,St=e=>bt(e).replace(Tt,"\\$&"),Ct=(e,t)=>{let r,n,i=e.$k,o=e.$c,l=e.$b,a=_e[l],f=a&&a.$v,s={d:[],v:[],n:[]},h=j(l),d=e.$d,$=e.$a,u=r=>{t.i<t.length?Ct(e,t):(s=t.slice(),t.i=t.length=0,r&&f.fire("domready"),_(s))};if(t.i=t.length,e.$c=0,e.$k={},o&&f&&h&&f.$a>0&&(r=f.tmpl)&&f.$d==e){for(n of(f.fire("dompatch"),delete We[l],delete et[l],n=((e,t)=>{let r,n=st.createElement("div"),i=t.namespaceURI;r=i==ot?"g":i==lt?"m":(ft.exec(e)||[0,""])[1];let o=at[r]||at._;n.innerHTML=o[1]+e;let l=o[0];for(;l--;)n=n.lastChild;return n})(r(d,l,$,wt,bt,It,yt,St),h),ct(h,n,s,a,i),s.d))n[0].id=n[1];for(n of s.n)1==n[0]?n[1].appendChild(n[2]):2==n[0]?n[1].removeChild(n[2]):4==n[0]?n[1].replaceChild(n[2],n[3]):n[1].insertBefore(n[2],n[3]);for(n of(a.$d=r=s.c||!f.$e,s.v))n.$b();r&&f.endUpdate(l),s.c&&p.fire("htmlchanged",{vId:l}),u(1)}else u()};function jt(e){let t=this;t.$b=e,t.$c=1,t.$d={vId:e},t.$a={[w]:1},t.$e=[],t.$k={}}E(jt[y],{get(e,t){return t=this.$d,e&&(t=t[e]),t},set(e,t){let r=this;return r.$c=A(e,r.$d,r.$k,t)||r.$c,r},digest(e,t,r){let n=this.set(e,t),i=n.$e;r&&i.push(r),i.i||Ct(n,i)},snapshot(){return this.$f=v(this.$d),this},altered(){let e=this;if(e.$f)return e.$f!=v(e.$d)},translate(e){return R(this.$d,e)},parse(e){return ie(e,this.$a)}});let qt=/^(\$?)([^<]*)<([^>]+)>(?:&(.+))?$/,At=(e,t,r)=>(e.a?r=e:((r=function(e){_(r.a,e,this)}).a=[e],r.b=1),r.a=r.a.concat(t.a||t),r),Ut=(e,t)=>{let r,n,i=e.$r;for(r in i)n=i[r],(t||n.x)&&Et(i,r,1)},Et=(e,t,r,n)=>{let i,o,l=e[t];return l&&l!=n&&((i=(o=l.e).destroy)&&r&&_(i,s,o),delete e[t]),o},Nt=(e,t,r,n,i)=>{n=e[t],e[t]=e[r]=function(...e){if((i=this).$a>0)return i.$a++,i.fire("rendercall"),Ut(i),_(n,e,i)}},Ot=(e,t)=>{let r,{$eo:n,$so:i,$el:o,id:l}=e;for(r in n)it(r,i[r],t);for(r of o)K(r.e,r.n,J,t,{i:l,v:e,f:r.f,m:r.m,e:r.e})},Ht={win:h,doc:$},Mt=(e,t,r)=>{let n,i,o,l,a={};for(i of e)for(n in i)o=i[n],l=a[n],"ctor"!=n?(qt.test(n)&&(l?o=At(l,o):o.b=1),a[n]=o):r.push(o);for(n in a)L(t,n)||(t[n]=a[n])};function Pt(...e){let t=this._||(this._=[]);return Mt(e,this[y],t),this}let _t=e=>{if(!e[w]){e[w]=[];let t,r,n,i,o,l,a,f,s,h,d,$=e[y],u={},c=[],p={};for(a in(r=$.mixins)&&Mt(r,$,e[w]),$)if(t=$[a],r=a.match(qt)){if([,l,n,i,d]=r,h={},d)for(f of d=d.split(","))h[f]=!0;for(f of i=i.split(",")){if(o=Ht[n],s=1,l){if(o){c.push({f:t,e:o,n:f,m:h});continue}s=2,(o=p[f])||(o=p[f]=[]),o[n]||(o[n]=1,o.push(n))}u[f]=u[f]|s,(o=$[f=n+w+f])?o.b&&(t.b?$[f]=At(t,o):L($,a)&&($[f]=t)):$[f]=t}}Nt($,"render","$b"),$.$eo=u,$.$el=c,$.$so=p,$.$f=$.assign}return e[w]},Lt=e=>{let t,r,n,i=e.$l;if(i.f&&(i.p&&(t=ce.path),!t&&i.k))for(r of(n=ce[x],i.k))if(t=L(n,r))break;return t};function Rt(e,t,r,n,i){(i=this).owner=t,i.id=e,i.$l={k:[]},i.$r={},i.$a=1,i.updater=i.$d=new jt(i.id),(e=Rt._)&&_(e,[r,{node:n,deep:!i.tmpl}],i)}E(Rt,{merge:Pt,extend:function e(t,r){let n=this,i=(t=t||{}).ctor,o=[];function l(e,t,r,i,a,f,s,h,d){n.call(s=this,e,t,r,i,a),f=l._,h=[r,{node:i,deep:!s.tmpl}],f&&_(f,h,s),(d=o.concat(a)).length&&_(d,h,s)}return i&&o.push(i),l.merge=Pt,l.extend=e,z(l,n,t,r)}}),E(Rt[y],le,{init:g,beginUpdate(e,t){(t=this).$a>0&&t.$e&&t.owner.unmountZone(e,1)},endUpdate(e,t,r,n,i){(r=this).$a>0&&(e=e||r.id,t?i=t:(i=r.$e,r.$e=1),(n=r.owner).mountZone(e,t),i||m(r.wrapAsync(Fe),0,n))},wrapAsync(e,t){let r=this,n=r.$a;return(...i)=>{if(n>0&&n==r.$a)return e.apply(t||r,i)}},observeLocation(e,t){let r;(r=this.$l).f=1,o(e)&&(t=e.path,e=e[x]),r.p=t,e&&(r.k=(e+f).split(","))},observeState(e){this.$os=(e+f).split(",")},capture(e,t,r,n){return n=this.$r,t?(Et(n,e,1,t),n[e]={e:t,x:r}):t=(n=n[e])&&n.e,t},release(e,t){return Et(this.$r,e,t)},leaveTip(e,t){let r=this,n=i=>{let o="a",l="b";"change"!=i.type&&(o="b",l="a"),n[o]?(i.prevent(),i.reject()):t()&&(i.prevent(),n[l]=1,r.leaveConfirm(()=>{n[l]=0,i.resolve()},()=>{n[l]=0,i.reject()},e))},i=r=>{t()&&(r.msg=e)};Ee.on("change",n),Ee.on("pageunload",i),r.on("unload",n),r.on("destroy",()=>{Ee.off("change",n),Ee.off("pageunload",i)})},render:g}),oe.View=Rt;let Zt=e.type,Bt=e.now;function Dt(){this.id=T("b"),this.$={}}E(Dt[y],{get(e,t){let r,n=this.$;if(e){let t,r=l(e)?e.slice():(e+f).split(".");for(;(t=r.shift())&&n;)n=n[t];t&&(n=d)}return t!==d&&(r=Zt(t))!=Zt(n)&&(n=t),n},set(e,t){o(e)||(e={[e]:t}),E(this.$,e)}});function zt(e,t,r){(r=this[e])&&(delete this[e],_(r,t,r.e))}let Ft=(e,t,r,n,i,o)=>{let l=[],a=null,f=0;return function(s,h){f++;let d,$,u=this,c=u.$b,p=c.k;if(l[s+1]=u,h?(a=h,d=1):o.has(p)||(p&&o.set(p,u),c.t=Bt(),($=c.a)&&_($,u,u),($=c.x)&&t.clear($),d=1),!r.$d){let t=f==n;t&&(r.$e=0,2==i&&(l[0]=a,_(e,l,r))),1==i&&_(e,[h||null,u,t,s],r)}d&&t.fire("end",{bag:u,error:h})}},Jt=(e,t,r,n,i)=>{if(e.$d)return e;if(e.$e)return e.enqueue(Jt.bind(e,e,t,r,n,i));e.$e=1,l(t)||(t=[t]);let o=e.constructor,a=0,f=o.$f,s=Ft(r,o,e,t.length,n,o.$c);for(let e of t)if(e){let t,r=o.get(e,i),n=r.e,l=n.$b.k,h=s.bind(n,a++);l&&f[l]?f[l].push(h):r.u?(l&&((t=[h]).e=n,f[l]=t,h=zt.bind(f,l)),o.$s(n,h)):h()}return e};function Kt(){let e=this;e.id=T("s"),e.$g=[]}E(Kt[y],{all(e,t){return Jt(this,e,t,2)},save(e,t){return Jt(this,e,t,2,1)},one(e,t){return Jt(this,e,t,1)},enqueue(e){let t=this;return t.$d||(t.$g.push(e),t.dequeue(t.$h)),t},dequeue(...e){let t,r=this;r.$e||r.$d||(r.$e=1,m(()=>{r.$e=0,r.$d||(t=r.$g.shift())&&_(t,r.$h=e)},0))},destroy(e){(e=this).$d=1,e.$g=0}});let Qt=(e,t)=>[v(t),v(e)].join(w),Xt=(e,t,r,n)=>{(n=e&&e.$b)&&t[n.n]&&r.del(n.k)},Yt={add(e){let t,r=this.$b;for(t of(l(e)||(e=[e]),e))if(t){let{name:e,cache:n}=t;t.cache=0|n,r[e]=t}},create(e){let t=this.meta(e),r=0|e.cache||t.cache,n=new Dt;n.set(t),n.$b={n:t.name,a:t.after,x:t.cleans,k:r&&Qt(t,e)},o(e)&&n.set(e);let i=t.before;return i&&_(i,n,n),this.fire("begin",{bag:n}),n},meta(e){return this.$b[e.name||e]||e},get(e,t){let r,n,i=this;return t||(r=i.cached(e)),r||(r=i.create(e),n=1),{e:r,u:n}},clear(e){this.$c.each(Xt,re((e+f).split(",")))},cached(e){let t,r,n=this,i=n.$c,o=n.meta(e),l=0|e.cache||o.cache;if(l&&(r=Qt(o,e)),r){let e=n.$f[r];e?t=e.e:(t=i.get(r))&&Bt()-t.$b.t>l&&(i.del(r),t=0)}return t},...le};return Kt.extend=((e,t,r)=>{function n(){Kt.call(this)}return n.$s=e,n.$c=new B(t,r),n.$f={},n.$b={},z(n,Kt,null,Yt)}),oe.Service=Kt,E(g[y],le),g.extend=function e(t,r){let n=this,i=t&&t.ctor;function o(...e){n.apply(this,e),i&&i.apply(this,e)}return o.extend=e,z(o,n,t,r)},oe.Base=g,e.add(S,()=>Rt.extend()),oe},{requires:["event","dom","node"]});