-
Notifications
You must be signed in to change notification settings - Fork 11
/
mag-latest.min.js
7 lines (7 loc) · 25 KB
/
mag-latest.min.js
1
2
3
4
5
6
7
/*
Mag.JS v0.29.8
http://github.com/magnumjs/mag.js
(c) Michael Glazer
License: MIT
*/
(function(b,f){'use strict';function h(S,T){if(y[S]&&!T)return y[S];var U=mag.doc.getElementById(S);return U&&(y[S]=U),y[S]}var j='KEY',l=0,n=['#'+j,'.'+j,j],o=function(S,T){var U;for(var V in n){var W=n[V].replace(j,T);if(U=S.querySelector(W),U)break}return U},q=function(S){var T=mag.utils.items.getItemVal(S),U=mag.getNode(T);return U},r=function(S){if('string'==typeof S){var T=q(~mag.mod.runningViewInstance||mag.utils.runningEventInstance),U=o(T||mag.doc,S);if(U)return U}return S},t=function(S,T,U){var Z,V=[],W=S.cloneNode(1),Y=[],$=[],_=function(aa){var ba=S;aa=aa||{};var ca;aa.key&&(ca=aa.key+'-'+_.id);var da=aa.key?aa.key+'-'+_.id:_.id;if($[da]||($[da]='object'==typeof U?mag.utils.copy(U):U),'object'==typeof aa&&(aa=mag.utils.extend($[da],aa)),ca&&!V[ca]?ba=V[ca]=W.cloneNode(1):ca&&V[ca]&&(ba=V[ca]),Z&&Z==ba[u].scid)throw Error('MagJS Error - recursive call:'+Z);ba[u]=ba[u]||{},mag._cprops[da]&&'object'==typeof aa&&(aa.children=mag._cprops[da]),_.props=aa,_.key=ca;var ea;if(Y[da]!=mag.utils.toJson(aa))try{ea=T(aa),Z=ba[u].scid=da,Y[da]=mag.utils.toJson(aa);var fa=mag.fill.id;fa&&fa[u]&&fa[u].scid&&(ba[u].pscid=fa[u].scid),mag.fill.setId(ba),mag.fill.run(ba,ea)}finally{mag.fill.setId(fa),Z=0}return ba};return _.id=++l,_.element=W,_};b.mag=function(S,T,U){if(S=r(S),T=r(T),U=U||{},mag.utils.isHTMLEle(T)&&mag.utils.isHTMLEle(S))T[u]||mag.fill.run(T,S);else{if('function'==typeof T&&mag.utils.isHTMLEle(S)){try{t(S.cloneNode(1),T,U)()}catch(V){}return t(S,T,U)}return K(-1,h(mag._isNode(S)),T,U)}};var u='__magnum__';mag.MAGNUM=u,mag.rafBounceIds=[],mag._cprops=[],mag.doc=f;var w={values:[],attributes:[],elementMatcher:[]},y=[],l=0;mag._isNode=function(S){return mag.utils.isHTMLEle(S)&&(!S.id&&(S.id=++l),y[S.id]=S,S=S.id),S};var z=function(S,T){var U,V=T?S+'-'+T:S;return U=mag.utils.items.isItem(V)?mag.utils.items.getItem(V):mag.utils.getItemInstanceId(V),U};mag.module=function(S,T,U){U=U||{},S=mag._isNode(S);var V=z(S,U.key),W=A(U,V,T,S);return W?K(V,W,T,mag.utils.copy(U)):void 0};var A=function(S,T,U,V){S.retain||mag.mod.clear(T);var W=h(V);if(mag.mod.submodule(V,T,U,S),L(T,V),!Q(T,W))return mag.redraw(W,T,1).then(function(){R(T,W)}),W},B=function(S,T){return 0>T||T!=mag.utils.items.getItem(S)?S==mag.mod.getId(T):!0},C=[];mag.begin=function(S){'undefined'==typeof C[S]?C[S]=1:C[S]++},mag.end=function(S){if(1<C[S])C[S]--;else{C[S]=0;var T=mag.utils.items.getItemVal(S);mag.redraw(h(T),S)}},mag.redraw=function(S,T,U){if(!C[T]){if(!S||'undefined'==typeof T)throw Error('Mag.JS - Id or node invalid: '+mag.utils.items.getItemVal(T));if(!B(S.id,T))return{then:V=>V()};if(U&&mag.fill.configs.splice(0,mag.fill.configs.length),U&&mag.mod.clear(T),mag.mod.runningViewInstance==T)throw Error('Mag.JS - recursive call:'+T);return mag.utils.scheduleFlush(T,M(S,T,U))}},mag.hookin=function(S,T,U){w[S].push({context:{},handler:U,key:T})},mag.hook=function(S,T,U){for(var V=0,W=w[S].length;V<W;V++)mag.utils.callHook(w,T,S,V,U)};var D={},E=[],F=[],G=function(S,T,U){var V=mag.getNode(mag.mod.getId(S)),W=function(){mag.utils.callLCEvent('onunload',mag.mod.getState(S),V,S)||(mag.clear(S),P(S,V),T[S]&&(T[S].length=0),U&&(mag.fill.removeNode(V),mag.mod.remove(S)))};mag.mod.getState(S).onbeforeunload?mag.utils.callLCEvent('onbeforeunload',mag.mod.getState(S),V,S,0,function(){W()}):W()},H=function(S,T){F[S]=F[S]||[];var U=F[S].push(T);return mag.utils.onLCEvent('didupdate',S,function(V,W){var X=mag.utils.toJson([W,V]);for(var Y of F[S])Y(V,W,h(mag.mod.getId(S)),JSON.parse(E[S]||'[]'));E[S]=X}),function(){return F[S].splice(U-1,1)}},I=[],J=function(S,T,U,V,W){var X=mag.utils.items.getItem(T);T=mag._isNode(S);var Y=mag.utils.toJson(mag.mod.getProps(X));(R(X,S),!(mag.mod.exists(X)&&mag.utils.callLCEvent('willgetprops',mag.mod.getState(X),S,X,0,U)))&&(mag.mod.submodule(S.id,X,V,U),Y!=mag.utils.toJson(mag.mod.getProps(X))&&(W=1),L(X,S.id),Q(X,S)||mag.redraw(S,X,W).then(function(){R(X,S)}))},K=function(S,T,U,V){I[S]=I[S]||[];var W=function(X,Y,Z,$,_){'object'==typeof _&&($=mag.utils.merge(mag.utils.copy($),_),_=0),0>X&&!_&&(_=1);var aa=Y.id+($.key?'.'+$.key+'.':'')+(_||'');!D[aa]||$.key||~W._id||(aa+=++l);var ba=D[aa]=D[aa]||Y.cloneNode(1);if(ba.id=aa,mag.utils.items.isItem(aa))return J(ba,aa,$,Z),ba;var ca=mag.utils.getItemInstanceId(ba.id);return 0>X?X=W._id=ca:I[X].push({instanceId:ca,subscribe:H.bind({},ca)}),J(ba,aa,$,Z),ba}.bind({},S,T,U,V);return W._id=S,W.clones=function(){return I[W._id]},W.destroy=function(X){G(W._id,W.clones,X)},W.getId=function(){return W._id},W.rafBounce=function(X){return X?mag.rafBounceIds[W._id]=1:!1===X&&(mag.rafBounceIds[W._id]=0),!!mag.rafBounceIds[W._id]},W.draw=function(X){return mag.redraw(T,W._id,X)},W.getState=function(){return mag.mod.getState(W._id)},W.getProps=function(){return mag.mod.getProps(W._id)},W.subscribe=function(X){return H(W._id,X)},W},L=function(S,T){var U=function(V,W){h(W)?mag.redraw(h(W),V):mag.utils.items.isItem(W)&&mag.clear(V)}.bind({},S,T);mag.mod.setFrameId(S,U)};mag.clear=function(S){mag.utils.items.removeItem(S),mag.mod.clear(S),mag.fill.clearCache(mag.mod.getId(S))};var M=function(S,T,U){return function(V,W,X){if(h(V.id,1),B(V.id,W)&&V){var Y=mag.mod.getState(W);if(!mag.utils.callLCEvent('isupdate',Y,V,W)){if(mag.mod.iscached(W)&&!X)return 0;if(!mag.utils.callLCEvent('willupdate',Y,V,W)){mag.mod.callView(V,W);var Z=mag.fill.id;mag.fill.setId(V.id),mag.fill.run(V,Y),mag.fill.setId(Z),N(V.id,mag.fill.configs),mag.utils.callLCEvent('didupdate',Y,V,W),X||mag.mod.iscached(W)}}}}.bind({},S,T,U)},N=function(S,T){for(var U in T)U.startsWith('id("'+S+'")/')&&T[U]()},O=function(S){var U=[];for(var V in mag.fill.cached)-1<V.indexOf('id("'+S+'")/')&&-1<V.indexOf('-config')&&mag.fill.cached[V].configContext&&U.push({path:V.split('-config')[0],controller:mag.fill.cached[V].configContext,handler:mag.fill.cached[V].configContext.onunload});return U},P=function(S,T){for(var W,U=O(T.id,S),V=0,X=U;W=X&&X[V];V++)W.controller.onunload&&(W.handler.call(W.controller,T,W.path),W.controller.onunload=0)},Q=function(S,T){return mag.utils.callLCEvent('willload',mag.mod.getState(S),T,S,1)},R=function(S,T){var U=mag.utils.items.getItemVal(S);if(h(U)&&mag.mod.exists(S))return mag.utils.callLCEvent('didload',mag.mod.getState(S),T,S,1)};mag._find=function(S,T){var U=mag.fill.id;mag.fill.setId(S);var V=mag.fill.find(S,T);return mag.fill.setId(U),V},mag.getNode=h})(window||global||this,document),function(b){'use strict';function f(u,w){var y=u.name;if('undefined'==typeof u.object[u.name]&&'_'!=y[0]){var z=b._find(w,y),A='$'===y[0],B=[];return z.length?(z.forEach(function(G){var H;if(!(G&&G.type&&!~['submit','button'].indexOf(G.type)))'undefined'==typeof u.oldValue&&'undefined'==typeof u.object[u.name]&&G&&!~['submit','button'].indexOf(G.type)&&1==G.childNodes.length&&G.childNodes[0].textContent.trim()&&(H={_text:G.childNodes[0].textContent.trim()});else if(G.value&&0<G.value.length)if('checkbox'!=G.type&&'radio'!=G.type){var K=G.multiple&&Array.prototype.map.call(G.selectedOptions,L=>L.value);H={_value:K||G.value}}else if(G.checked&&(H={},H._checked=!0),!A){var I=w.querySelectorAll('[name='+G.name+']');if(I.length)for(var J of I)J.checked&&(H?H._value=J.value:H={_value:J.value})}else H?H._value=G.value:H={_value:G.value};H?B.push(H):G&&!G.hasChildNodes()&&B.push(j)}),0===B.length?void 0:A?B:B[0]&&'undefined'!=typeof B[0]._value?B[0]._value:B[0]&&B[0]._text?B[0]._text:B[0]):j}if('_'==y[0]){var C=y.substr(1);if(w.length){var B=[];for(var D in w){var E=w[D],F=E[C];'undefined'==typeof F&&(F=E.getAttribute(C)),B.push(F)}return B}var F=w[C];return'undefined'==typeof F&&(F=w.getAttribute(C)),F}}function g(u,w){return new u(b.proxy({},t.bind({},'state',w)))}var h=[],j=b.MAGNUM,n={runningViewInstance:-1,innerMods:[],cache:[]};n.getState=function(u){return h[u][1]},n.setState=function(u,w){h[u][1]=w},n.getView=function(u){return h[u][0]},n.getProps=function(u){return h[u]&&h[u][2]},n.setProps=function(u,w){return h[u][2]=w},n.remove=function(u){h[u]&&(h[u]=0)},n.getId=function(u){return h[u]&&h[u][3]},n.exists=function(u){return'object'==typeof h[u]},n.setFrameId=function(u,w){h[u][4]=w},n.getFrameId=function(u){return h[u][4]},n.getMod=function(u){return h[u][5]};var o=(u,w)=>{for(var y in w=w||u,u){var z=u[y];'function'!=typeof z||~['controller','view'].indexOf(y)||(u[y]=z.bind(w))}return u};n.submodule=function(u,w,y,z){if(h[w])return z.key&&z.key==n.getProps(w).key?n.setProps(w,b.utils.copy(b.utils.merge(n.getProps(w),z))):n.setProps(w,z),h[w];y=b.utils.copy(y),o(y,y),h[w]=[0,0,0,0,0,0],n.setProps(w,z);var B=function(D,E,F){y.element=F,y.state=E,y.props=n.getProps(D),y.view&&y.view.call(y,E,y.props,F)}.bind({},w),C={controller:function(D){return y.props=n.getProps(w),y.state=D,y.element=b.getNode(u),(y.controller||function(){}).call(D,y.props)||D},view:B};return h[w][0]=C.view,h[w][3]=u,h[w][1]=g(C.controller,w,u),h[w][5]=y,h[w]};var q=[],r=function(u,w){var y=u,z=w.split('/');for(var A of z)if(A){var B=b._find(y,A);B.length&&(y=B)}return y},t=function(u,w,y){if('get'==y.type&&'props'!=u&&!~b.fill.ignorekeys.indexOf(y.name.toString())&&'undefined'==typeof y.oldValue){var z=b.getNode(n.getId(w));if(y.path&&'/'==y.path[0])var A=r(z,y.path);A&&'$'!=y.path.split('/').pop()[0]&&(A=A[0]);var B=f(y,A?A:z);if(null!==B&&'object'==typeof B&&y.object&&b.utils.merge(B,y.object[y.name]),B)return n.cached[w]=0,B}else'set'==y.type&&'props'!=u&&y.object[y.name]&&y.object[y.name].draw&&'function'==typeof y.object[y.name].draw&&(n.innerMods[n.getId(w)]=[y.name,y.object[y.name]]);var C=n.getFrameId(w);'function'==typeof C&&'set'==y.type&&(cancelAnimationFrame(q[w]),q[w]=requestAnimationFrame(C))};n.iscached=function(u){var w=b.utils.toJson([n.getProps(u),n.getState(u)]);return u in n.cache&&n.cache[u]==w||void(n.cache[u]=w)},n.clear=function(u){~u&&n.cache[u]&&n.cache.splice(u,1)},n.cached=[],n.callView=function(u,w){n.runningViewInstance=w,n.cached[w]||(b.props.attachToArgs(w,n.getState(w),u),n.cached[w]=1);try{n.exists(w)&&n.getView(w)(n.getState(w),u)}finally{n.runningViewInstance=-1}},b.mod=n}(mag),function(b){'use strict';function g(y,z,A,B){var C=[];for(var D in y){var E=y[D];j(E)&&(C.push(E),h(E,z,A,B))}return!!C.length&&(1==C.length?C[0]:C)}function h(y,z,A,B){if(y[q]=y[q]||{},!y[q].eventOnFocus){var C=function(D,E,F){var H=~['radio','checkbox'].indexOf(y.type);if(this[q].dirty||(this[q].dirty=1),y.selectedOptions)var I=Array.prototype.map.call(y.selectedOptions,J=>J.value);H?'_checked'in E||o in E?E._checked=this.checked:this.checked&&(E[F]=this.value):void 0===E[o]?void 0!==E._text&&(E._text=I||this.value):E[o]=I||this.value,b.redraw(D,b.utils.items.getItem(D.id))}.bind(y,B,z,A);y.addEventListener('click',C),y.addEventListener('input',C),y.addEventListener('change',C),y.addEventListener('focus',C),y[q].eventOnFocus=1}}function j(y){return y&&~['INPUT','SELECT','TEXTAREA'].indexOf(y.tagName)}function l(y){for(var z in y)if(j(y[z]))return y[z];return!1}var n={},o='_value',q=b.MAGNUM,r=function(y,z){for(var A=1;A<y.length;A++){var B=y[A],C=y[A+1],D=b._find(Array.isArray(z)?z[0]:z,B);if(C&&!isNaN(+C))z=D[C];else if(D&&D.length&&C&&A+2<y.length)z=b._find(D[0],C);else if(D&&D.length&&(z=D,A+2==y.length))break}return Array.isArray(z)?z[0]:z},t=function(y,z,A,B){var D,C=A.toString().split('.');if(3<=C.length)B=r(C,B),D=b._find(B,z);else{var E=parseInt(C.pop()),F=isNaN(E)?0:E;D=b._find(B[F]?B[F]:B,z)}return g(D,y,z,B)},u=function(y,z,A,B){var C=A[z];~[o,'_checked','_text'].indexOf(z)&&'string'==typeof y&&(z=y.split('.').pop());var D=b._find(B,z),E=l(D);if('function'!=typeof C&&E){var F=t.bind({},A,z,y,B);F(),Object.defineProperty(A,z,{configurable:!0,get:function(){var G=F();return G&&'undefined'!==G.value&&G[q]&&G[q].dirty&&G.value!==C?(C=G.value,b.redraw(B,y,1),G.value):C},set:function(G){var H=F();H&&'undefined'!==H.value&&H.value!==G&&G!==C&&(H.value=G,C=G)}})}},w=function(y,z,A){for(var B in z)if(z.hasOwnProperty(B)){var C=z[B];B==o||'object'!=typeof C||b.utils.isHTMLEle(C)?u.bind({},y,B,z,A)():(b.utils.isObject(C)&&b.utils.isEmpty(C)&&(C[o]=''),w(y+'.'+B,C,A))}};n.attachToArgs=w,b.props=n}(mag),function(b){'use strict';function f(u,w){return!b.rafRate||u-w<b.rafRate}function g(u,w,y){var z;o=0;do{var A=l.shift();A&&A(),z=performance.now()}while(l.length&&f(z,w));l.length?h.scheduleFlush(y).then(u):u()}var h={};h.copy=u=>Object.assign({},u),h.merge=function(){return Object.assign.apply({},arguments)},h.extend=function(u,w,y){for(var z in w)if(w[z]===void 0)delete w[z];else if(y&&h.isObject(w[z]))return h.extend(u[z],w[z]);return h.merge(u,w)},h.isObject=u=>'Object]'==Object.prototype.toString.call(u).substr(-7);var j=(u,w)=>'function'==typeof w?''+w:w;h.toJson=u=>JSON.stringify(u,j),h.isEmpty=u=>{for(var w in u)if(u.hasOwnProperty(w))return 0;return 1},h.isHTMLEle=u=>u&&1===u.nodeType,h.callHook=function(u,w,y,z,A,B){u[y][z].key==w&&(B={v:A.value,k:A.key},A.change=!1,u[y][z].handler.call(u[y][z].context,A),{v:A.value,k:A.key}!==B&&(A.change=!0))};var o,l=[],n=[],q=[];h.scheduleFlush=function(u,w){return new Promise(function(y){b.rafBounce||b.rafBounceIds[u]&&w?(n[u]&&(q[u](),cancelAnimationFrame(n[u])),q[u]=y,n[u]=requestAnimationFrame(()=>{n[u]=0,w(),y()})):(w&&l.push(w),!o&&(o=requestAnimationFrame(z=>g(y,z,u))))})};var r=[];h.onLCEvent=function(u,w,y){var z=u+'-'+w;r[z]=r[z]||[];var A=r[z].push(y);return function(){return r[z].splice(A-1,1)}},h.callLCEvent=function(u,w,y,z,A,B){var C;h.runningEventInstance=z;var D=b.mod.getProps(z),E=b.mod.getMod(z),F=E&&E[u]||w&&w[u];F&&!F.called&&(C=F.call(E,y,D,z,B),A&&(F.called=1));var G=u+'-'+z;if(r[G])for(var H of r[G])H(w,D);return(h.runningEventInstance=-1,!1===C)||void 0};var t={i:[],isItem:u=>~t.i.indexOf(u),setItem:u=>t.i[t.i.length]=u,getItem:u=>t.i.indexOf(u),getItemVal:u=>t.i[u],removeItem:u=>t.i.splice(t.i.indexOf(u),1)};h.items=t,h.getItemInstanceIdAll=()=>t.i,h.getItemInstanceId=u=>{return t.isItem(u)?t.getItem(u):(t.setItem(u),t.getItem(u))},b.utils=h}(mag),function(b,f,g){'use strict';function h(ia){return Array.isArray(ia)}function j(ia,ja){return ia[Z]=ia[Z]||{},(!ia[Z].uid||ja)&&(ia[Z].uid=++ea),ia[Z].uid}function l(ia,ja){var ka=j(ia);return ba[ka]&&!ja?ba[ka]:ba[ka]=u(ia)}function n(ia){for(var ja=1;ia=ia.previousElementSibling;)++ja;return ja}function o(ia,ja){var ka=j(ia);return ca[X.id]=ca[X.id]||[],ca[X.id][ka]&&ca[X.id][ka]==ja?1:void(ca[X.id][ka]=ja)}function q(ia){return ia.id&&b.utils.items.isItem(ia.id)?ia:ia.parentNode?q(ia.parentNode):void 0}function r(ia,ja){if(ia[Z]&&ia[Z].scid&&!ia[Z].pscid)ja=ia;else if(ja)return ja;return ia.parentNode?r(ia.parentNode,ja):void 0}function t(ia){var ja='',ka=q(ia),la=n(ia);return ka&&(ja+='id("'+(ka.id||ka.tagName)+'")'),ja+='/'+ia.tagName+'['+la+']',ja}function u(ia){if(ia.id&&X.id===ia.id||X.id===ia)return'id("'+(ia.id||ia.tagName)+'")';if(ia===b.doc.body)return ia.tagName;var ka=0;if(ia.parentNode)for(var oa,la=ia.parentNode.childNodes,ma=0,na=la.length;ma<na;ma++){if(oa=la[ma],oa===ia)return u(ia.parentNode)+(ia.tagName?'/'+ia.tagName+'['+(ka+1)+']':'');1===oa.nodeType&&oa.tagName===ia.tagName&&ka++}}function w(ia){var ja=u(ia);ia&&Y[ja+'-config']&&Y[ja+'-config'].configContext&&typeof Y[ja+'-config'].configContext.onunload==='function'&&(Y[ja+'-config'].configContext.onunload(Y[ja+'-config'].configContext,ia,ja),delete Y[ja+'-config'],delete X.configs[ja]),E(ia),ia.parentNode&&ia.parentNode.removeChild(ia)}function y(ia){var ja=ia&&parseInt(ia.split('[').pop().slice(0,-1));return ja?parseInt(ja)-1:0}function z(ia){var ja=[];return ia.replace(/\[(.+?)\]/g,function(ka,la){ja.push(la)}),ja}function A(ia){return ia&&~ia.indexOf('id(')&&ia.split('id("')[1].split('")')[0]}function B(ia,ja,ka){var la=j(ia);if(ba[la])return ba[la];if(fa[la])return fa[la];var ma=+ka==+ka?ja+ka:ja,na='object'==typeof X.id?X.id.tagName:X.id,oa='string'==typeof ka?ka.split(')')[1]+'/':'/',pa='id("'+na+'")'+oa+ia.tagName+'['+ma+']';return fa[la]=ia[Z].xpath=pa}function C(ia){if(ia&&ia[Z]&&ia[Z].isItem)return ia;return ia.parentNode?C(ia.parentNode):void 0}function D(ia,ja){if(!o(ia,ja.outerHTML)&&(!ja.id&&!ia.childNodes[0]||ja.id&&!b.doc.getElementById(ja.id)||ia.firstChild&&!ia.firstChild.isEqualNode(ja))){var ka=b.utils.items.getItem(ja.id);if(~ka&&ia.hasChildNodes()){var la=b.utils.items.getItem(X.id),ma=ia.cloneNode(1);ma[Z]={childof:la},b.mod.getProps(ka).children=ma,b.redraw(ja,ka)}else ja[Z]&&ja[Z].scid&&(ma=ia.cloneNode(1),ma[Z]={childof:ja[Z].scid},b._cprops[ja[Z].scid]=ma);for(;ia.lastChild;)w(ia.lastChild);if(ja[Z]&&ja[Z].childof!==g){ia.innerHTML=ja.innerHTML;var na=ja[Z].childof;b._cprops[na]||(F(ia,na),b.utils.onLCEvent('willupdate',na,()=>{F(ia,na)}))}else ia.appendChild(ja)}}function E(ia){var ja=b.utils.items.getItem(ia.id);if(ia.children)for(var ka=0;ka<ia.children.length;ka++)E(ia.children[ka]);~ja&&(b.utils.callLCEvent('onunload',b.mod.getState(ja),ia,ja),b.mod.clear(ja),b.mod.remove(ja),b.fill.clearCache(b.mod.getId(ja)))}function F(ia,ja){var ka=X.id;X.setId(b.mod.getId(ja)),X.run(ia,b.mod.getState(ja)),X.setId(ka)}function G(ia,ja){var ka;for(var la in ja){var ma=ja[la];ma===g?ma='':null===ma&&-1===['onunload'].indexOf(la)?(ia[Z].detached=ia[Z].detached||[],ia[Z].detached[la]=1,K(ia,la)):ia[Z].detached&&ia[Z].detached[la]&&(J(ia,la,ma.nodeType),ia[Z].detached[la]=0),'_'===la[0]&&'_'!==la[1]&&(ka=ka||{},ka[la.substr(1)]=ma)}return ka}function H(ia,ja,ka){var la;for(var ma in ja){var na=ja[ma];if(!~X.ignorekeys.indexOf(ma)&&'_'!==ma[0]){la=T(ia,ma);var oa={key:ma,value:na,node:ia};b.hook('values','*',oa),oa.change&&(na=oa.value),X.run(la,na,ka+'/'+ma)}}}function I(ia,ja,ka,la){var ma,qa=y(ka);return ja&&b.utils.isHTMLEle(ja)?void D(ia,ja):'function'==typeof ja?ga(ja,ia,qa,ka):'object'==typeof ja?void(b.mod.innerMods[X.id]&&ja[b.mod.innerMods[X.id][0]]&&!ja[b.mod.innerMods[X.id][0]].draw&&b.mod.innerMods[X.id][1].destroy(),ma=G(ia,ja),ma&&P(ia,ma,ka,la),H(ia,ja,ka)):I(ia,{_text:ja},ka)}function J(ia,ja,ka){var la=T(ia,ja);la.forEach(function(ma){var na=j(ma);if(na in ha){if(!ka)for(var oa in ha[na])ma.appendChild(ha[na][oa]);delete ha[na]}})}function K(ia,ja){var ka=0,la=1,ma=function(pa){if(++ka==la)for(;pa.lastChild;)w(pa.lastChild)},na=function(pa,qa){var ra;pa.id&&b.utils.items.isItem(pa.id)&&(ra=b.utils.items.getItem(pa.id)),ra&&b.mod.getState(ra).onbeforeunload?(la++,b.utils.callLCEvent('onbeforeunload',b.mod.getState(ra),pa,ra,0,function(){ra&&b.utils.callLCEvent('onunload',b.mod.getState(ra),pa,ra),qa()})):(ra&&b.utils.callLCEvent('onunload',b.mod.getState(ra),pa,ra,1),qa())},oa=T(ia,ja);oa.forEach(function(pa){var qa=j(pa);pa.children.length&&(ha[qa]=L(pa.children));for(var sa in ha[qa]){var ta=ha[qa][sa];na(ta,function(){ma(pa)})}ma(pa)})}function L(ia){var ja;if(null==ia.length&&(ia=[ia]),!h(ia)){ja=[];for(var ka=0;ka<ia.length;ka+=1)ia[ka]&&ja.push(ia[ka]);ia=ja}return ia}function M(ia,ja){var ka=function(la,ma,na){var oa=t(ma),pa=A(oa);pa||(pa=r(ma));var qa=X.id;X.setId(pa);var ra=C(ma),sa=ra&&u(ra),ta=y(sa),oa=oa,ua=y(oa),va={path:sa,node:ra,data:((ra||{})[Z]||[]).dataPass,index:ta};X.setId(qa);var wa=b.doc.getElementById(pa),xa=b.utils.items.getItem(pa),ya=la.call(~xa?b.mod.getMod(xa):wa,na,ua,ma,va);if(pa&&wa){var za=function(){b.redraw(wa,xa,1)};ya&&ya.then?ya.then(function(Aa){return za(),Aa}):za()}return ya}.bind({},ja,ia);return ka}function N(ia,ja){function ka(la){var ma=ia[Z].eventHandlers[ja];for(var na in ma){var oa=ma[na],pa=M(ia,oa),qa=pa(la);!1===qa&&la.preventDefault()}}ia.removeEventListener(ja,ka),ia.addEventListener(ja,ka)}function O(ia,ja,ka,la){var ma=ja.substr(2).toLowerCase(),na=('string'==typeof la?la.split('/')[0]:'')+'-'+ka[Z].uid,oa=ka[Z].events=ka[Z].events||[],pa=ka[Z].eventHandlers=ka[Z].eventHandlers||[];pa[ma]=pa[ma]||[],pa[ma][na]=ia,oa[ma]||(oa[ma]=1,N(ka,ma))}function P(ia,ja,ka,la){var ma=y(ka);for(var na in Y[j(ia)]=Y[j(ia)]||[],ja)if('text'!==na&&'html'!==na)if(0==na.indexOf('on'))O(ja[na],na,ia,la);else{if('config'==na){var ka=l(ia),ma=y(ka),oa=!0;Y[ka+'-config']?oa=!1:Y[ka+'-config']={};var pa=Y[ka+'-config'].configContext=Y[ka+'-config'].configContext||{},qa=function(ua,va){return function(){return ua.apply(ua,va)}};f[ka]=qa(ja[na],[ia,oa,pa,ma]);continue}var ra={key:na,value:ja[na],node:ia};if(b.hook('attributes',na,ra),ra.change&&(na=ra.key,ja[na]=ra.value),Y[j(ia)]&&Y[j(ia)][na]==ja[na])continue;null===ja[na]?ia.removeAttribute(na):'value'==na&&ia.multiple&&ia.selectedOptions&&Array.isArray(ja[na])?(ia.value=ja[na],ja[na].forEach(function(ua){Array.from(ia.options).find(va=>va.value==ua).selected=!0})):na in ia?'style'==na?ia[na].cssText=ja[na]:ia[na]=ja[na]:ia.setAttribute(na,ja[na]+''),Y[j(ia)][na]=ja[na]}Q(ia,ja.text),S(ia,ja.html)}function Q(ia,ja){if(ia&&null!=ja&&!o(ia,ja)){var ka=ja+'';if('INPUT'!==ia.nodeName)'SELECT'!==ia.nodeName&&(ia.firstChild?ia.firstChild.textContent=ka:ia.appendChild(ia.ownerDocument.createTextNode(ka)));else if(!~['radio','checkbox'].indexOf(ia.type))ka!=ia.value&&(ia.value=ka);else if(ia.name){var la=b.getNode(X.id).querySelectorAll('[name='+ia.name+']');if(1<la.length)for(var ma of la)if(ma.value==ka){ma.checked=!0;break}}'SELECT'===ia.nodeName&&ka&&(ia.value=ka)}}function R(ia,ja,ka){!ja||ia.childNodes[ka]&&ia.childNodes[ka].isEqualNode(ja)||(ia.childNodes[ka]?ia.replaceChild(ja,ia.childNodes[ka]):ia.appendChild(ja))}function S(ia,ja){if(Array.isArray(ja)){for(var ka in ja)R(ia,ja[ka],ka);return}return b.utils.isHTMLEle(ja)?void R(ia,ja,0):void(!ia||null==ja||o(ia,ja)||(ia.innerHTML=ja))}function T(ia,ja,ka){var la=V(ia),ma=[],na=ja,oa='$'===ja[0];'$'===na[0]&&(na=na.substr(1));for(var pa=0;pa<la.length;pa+=1)W(la[pa],na)&&ma.push(la[pa]);if(!ma.length||oa)for(var pa=0;pa<la.length&&(ma=ma.concat(T(la[pa],ja,!0)),!ma.length||oa);pa++);if(!ka&&!ma.length){var qa={key:ja,value:ma,node:ia};b.hook('elementMatcher',ja,qa),qa.change&&(ma=qa.value)}return ma}function U(ia){return X.id&&(b.utils.isHTMLEle(X.id)&&ia[Z]&&ia[Z].scid||ia.id&&ia.id!=X.id&&b.utils.items.isItem(ia.id))?0:1}function V(ia){var ja=[];if(ia){var ka=ia.childNodes;if(ka)for(var la=0;la<ka.length;la+=1)1===ka[la].nodeType&&U(ka[la])&&ja.push(ka[la])}return ja}function W(ia,ja){var ka=' '+ia.className+' ';return ia.id===ja||~ka.indexOf(' '+ja+' ')||ia.name===ja||ia.nodeName.toLowerCase()===ja.toLowerCase()||ia.getAttribute('data-bind')===ja}var X={cached:[],ignorekeys:['toString','draw','then','hasOwnProperty','willgetprops','onbeforeunload','Symbol(Symbol.toStringTag)','nodeType','toJSON','onunload','willupdate','didupdate','didload','willload','isupdate']},Y=X.cached,Z=b.MAGNUM,_='undefined',aa='_key',ba=[],ca=[],da={},ea=0;X.run=function(ia,ja,ka){var la,ma;if(ia){null==ja&&(ja={_text:''});var na=L(ia);if(ma=h(ja),ma){if(da[ka]&&0===na.length&&(da[ka].parent.insertAdjacentHTML('beforeend',da[ka].node),na=L(da[ka].parent.children)),!na.length)return;var oa=na[0].parentNode;da[ka]||(da[ka]={node:na[0].cloneNode(1).outerHTML,parent:oa});for(var pa=b.doc.createDocumentFragment(),qa=0;na.length<ja.length;)da[ka]?(oa.insertAdjacentHTML('beforeend',da[ka].node),la=oa.lastChild):la=na[0].cloneNode(1),B(la,++qa,ka),na.push(la),pa.appendChild(la);oa.appendChild(pa);var ra=ja.map(function(wa){return wa&&wa[aa]});if((na.length==ja.length||-1!==ra.indexOf(g))&&(ja=ja.map(function(wa,xa){if('object'==typeof wa){if(na[xa][Z]=na[xa][Z]||{},na[xa][Z].__key&&typeof wa[aa]==_)return wa[aa]=na[xa][Z].__key,wa;typeof wa[aa]==_&&(wa[aa]=Z+xa),na[xa][Z].__key=wa[aa]}return wa})),na.length>ja.length)if(0===ja.length||'object'!=typeof ja[0])for(;na.length>ja.length;)la=na.pop(),oa=la.parentNode,oa&&w(la);else{var sa=[],ta=ja.map(function(wa){return wa[aa]});na=na.filter(function(wa){var ya;return(typeof wa[Z]==_?ya=1:(!~ta.indexOf(wa[Z].__key)||~sa.indexOf(wa[Z].__key))&&(sa.push(wa[Z].__key),ya=1),ya)?(w(wa),!1):(sa.push(wa[Z].__key),!0)})}}for(var ua=0;ua<na.length;ua++)if(ma)na[ua]&&X.run(na[ua],ja[ua],ua);else{var va=B(na[ua],ua+1,ka);ja&&'object'==typeof ja&&ja.hasOwnProperty(aa)&&!b.utils.isHTMLEle(ja)&&(na[ua][Z].isItem=!0,na[ua][Z].dataPass=ja),I(na[ua],ja,va,ka)}}};var fa=[],ga=function(ia,ja,ka,la){la=l(ja),ka=z(la);var ma=ia(ka.join('.'),la);return ma&&b.utils.isHTMLEle(ma)?void(D(ja,ma),ja[Z]=ja[Z]||{},ja[Z].isItem=!0,ja[Z].dataPass={index:ka},ia.draw&&ia.draw()):I(ja,ma,la)},ha=[];X.removeNode=w,X.configs=f,X.find=T,X.setId=ia=>{X.id=ia},X.clearCache=ia=>{ca[ia]&&delete ca[ia]},b.fill=X}(mag,[]),function(b){function g(j,l,n,o){function q(t){return r.has(t)}var r=new WeakSet;return new Proxy(j,{get:function(t,u,w){var y=t[u];if('symbol'==typeof u)return y;if('object'!=typeof y||'symbol'==typeof y||null===y||'function'==typeof y||Array.isArray(y)||!b.utils.isObject(y)||y.then||y.draw)u in t||~b.fill.ignorekeys.indexOf(u.toString())||n||'_'==u[0]||(y=b.proxy({},l,n,o+h+u));else if(!q(y))return r.add(y),b.proxy(y,l,n,o+h+u);var z=l({type:'get',object:t,name:u,path:o,oldValue:Reflect.get(t,u,w)});return'undefined'!=typeof z&&(y=z==b.MAGNUM?void 0:z),y},deleteProperty:function(t,u){return l({type:'delete',name:u,object:t,oldValue:Reflect.get(t,u)}),Reflect.deleteProperty(t,u)},set:function(t,u,w,y){var z=Reflect.get(t,u,y);return z===w&&'length'!==u||(l({type:'set',name:u,object:t,oldValue:z}),Reflect.set(t,u,w,y))}})}var h='/';b.proxy=function(j,l,n,o){for(var q in j){var r=typeof j[q];Array.isArray(j[q])&&101>j[q].length?j[q]=g(j[q],l):'object'==r&&null!==j[q]&&'symbol'!=typeof q&&'symbol'!=r&&'function'!=r&&b.utils.isObject(j[q])&&(j[q]=b.proxy(j[q],l,n,o+h+q))}return g(j,l,n,o||h)}}(mag,window||global||this);