47 lines
No EOL
23 KiB
JavaScript
47 lines
No EOL
23 KiB
JavaScript
(function(){function x(b,d,e,h,p,l){return{tag:b,key:d,attrs:e,children:h,text:p,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0,skip:!1}}function R(b){for(var d in b)if(G.call(b,d))return!1;return!0}function w(b){var d=arguments[1],e=2;if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b){var h;if(!(h=S[b])){var p="div";for(var l=[],k={};h=W.exec(b);){var q=h[1],
|
|
r=h[2];""===q&&""!==r?p=r:"#"===q?k.id=r:"."===q?l.push(r):"["===h[3][0]&&((q=h[6])&&(q=q.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===h[4]?l.push(q):k[h[4]]=""===q?q:q||!0)}0<l.length&&(k.className=l.join(" "));h=S[b]={tag:p,attrs:k}}}if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length===e+1)p=arguments[e],Array.isArray(p)||(p=[p]);else for(p=[];e<arguments.length;)p.push(arguments[e++]);e=x.normalizeChildren(p);if("string"===typeof b){p=
|
|
!1;var m,z;l=d.className||d["class"];if(!R(h.attrs)&&!R(d)){k={};for(var a in d)G.call(d,a)&&(k[a]=d[a]);d=k}for(a in h.attrs)G.call(h.attrs,a)&&(d[a]=h.attrs[a]);void 0!==l&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=l),null!=h.attrs.className&&(d.className=h.attrs.className+" "+l));for(a in d)if(G.call(d,a)&&"key"!==a){p=!0;break}Array.isArray(e)&&1===e.length&&null!=e[0]&&"#"===e[0].tag?z=e[0].children:m=e;return x(h.tag,d.key,p?d:void 0,m,z)}return x(b,d.key,d,e)}function X(b){var d=
|
|
0,e=null,h="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var p=Date.now()-d;null===e&&(e=h(function(){e=null;b();d=Date.now()},16-p))}}x.normalize=function(b){return Array.isArray(b)?x("[",void 0,void 0,x.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?x("#",void 0,void 0,!1===b?"":b,void 0,void 0):b};x.normalizeChildren=function(b){for(var d=0;d<b.length;d++)b[d]=x.normalize(b[d]);return b};var W=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,
|
|
S={},G={}.hasOwnProperty;w.trust=function(b){null==b&&(b="");return x("<",void 0,void 0,b,void 0,void 0)};w.fragment=function(b,d){return x("[",b.key,b,x.normalizeChildren(d),void 0,void 0)};var t=function(b){function d(b,a){return function M(d){var A;try{if(!a||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(A=d.then))m(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",d);for(var e=0;e<b.length;e++)b[e](d);p.length=0;l.length=0;r.state=a;r.retry=
|
|
function(){M(d)}});else{if(d===h)throw new TypeError("Promise can't be resolved w/ itself");e(A.bind(d))}}catch(Y){q(Y)}}}function e(b){function a(a){return function(b){0<d++||a(b)}}var d=0,r=a(q);try{b(a(k),r)}catch(M){r(M)}}if(!(this instanceof t))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var h=this,p=[],l=[],k=d(p,!0),q=d(l,!1),r=h._instance={resolvers:p,rejectors:l},m="function"===typeof setImmediate?setImmediate:
|
|
setTimeout;e(b)};t.prototype.then=function(b,d){function e(b,d,e,k){d.push(function(a){if("function"!==typeof b)e(a);else try{p(b(a))}catch(B){l&&l(B)}});"function"===typeof h.retry&&k===h.state&&h.retry()}var h=this._instance,p,l,k=new t(function(b,d){p=b;l=d});e(b,h.resolvers,p,!0);e(d,h.rejectors,l,!1);return k};t.prototype["catch"]=function(b){return this.then(null,b)};t.resolve=function(b){return b instanceof t?b:new t(function(d){d(b)})};t.reject=function(b){return new t(function(d,e){e(b)})};
|
|
t.all=function(b){return new t(function(d,e){var h=b.length,p=0,l=[];if(0===b.length)d([]);else for(var k=0;k<b.length;k++)(function(k){function r(b){p++;l[k]=b;p===h&&d(l)}null==b[k]||"object"!==typeof b[k]&&"function"!==typeof b[k]||"function"!==typeof b[k].then?r(b[k]):b[k].then(r,e)})(k)})};t.race=function(b){return new t(function(d,e){for(var h=0;h<b.length;h++)b[h].then(d,e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=t),t=window.Promise):"undefined"!==
|
|
typeof global&&("undefined"===typeof global.Promise&&(global.Promise=t),t=global.Promise);var F=function(b){function d(b,h){if(Array.isArray(h))for(var k=0;k<h.length;k++)d(b+"["+k+"]",h[k]);else if("[object Object]"===Object.prototype.toString.call(h))for(k in h)d(b+"["+k+"]",h[k]);else e.push(encodeURIComponent(b)+(null!=h&&""!==h?"="+encodeURIComponent(h):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var e=[],h;for(h in b)d(h,b[h]);return e.join("&")},Z=/^file:\/\//i,P=
|
|
function(b,d){function e(){function a(){0===--b&&"function"===typeof z&&z()}var b=0;return function J(d){var e=d.then;d.then=function(){b++;var r=e.apply(d,arguments);r.then(a,function(d){a();if(0===b)throw d;});return J(r)};return d}}function h(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function p(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var r=d[e].slice(1);null!=b[r]&&(a=a.replace(d[e],b[r]))}return a}function l(a,b){var d=
|
|
F(b);if(""!==d){var e=0>a.indexOf("?")?"?":"&";a+=e+d}return a}function k(a){try{return""!==a?JSON.parse(a):null}catch(B){throw Error(a);}}function q(a){return a.responseText}function r(a,b){if("function"===typeof a)if(Array.isArray(b))for(var d=0;d<b.length;d++)b[d]=new a(b[d]);else return new a(b);return b}var m=0,z;return{request:function(a,m){var A=e();a=h(a,m);var B=new d(function(d,e){null==a.method&&(a.method="GET");a.method=a.method.toUpperCase();var h="GET"===a.method||"TRACE"===a.method?
|
|
!1:"boolean"===typeof a.useBody?a.useBody:!0;"function"!==typeof a.serialize&&(a.serialize="undefined"!==typeof FormData&&a.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==typeof a.deserialize&&(a.deserialize=k);"function"!==typeof a.extract&&(a.extract=q);a.url=p(a.url,a.data);h?a.data=a.serialize(a.data):a.url=l(a.url,a.data);var m=new b.XMLHttpRequest,A=!1,B=m.abort;m.abort=function(){A=!0;B.call(m)};m.open(a.method,a.url,"boolean"===typeof a.async?a.async:!0,"string"===
|
|
typeof a.user?a.user:void 0,"string"===typeof a.password?a.password:void 0);a.serialize!==JSON.stringify||!h||a.headers&&a.headers.hasOwnProperty("Content-Type")||m.setRequestHeader("Content-Type","application/json; charset=utf-8");a.deserialize!==k||a.headers&&a.headers.hasOwnProperty("Accept")||m.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(m.withCredentials=a.withCredentials);a.timeout&&(m.timeout=a.timeout);for(var z in a.headers)({}).hasOwnProperty.call(a.headers,
|
|
z)&&m.setRequestHeader(z,a.headers[z]);"function"===typeof a.config&&(m=a.config(m,a)||m);m.onreadystatechange=function(){if(!A&&4===m.readyState)try{var b=a.extract!==q?a.extract(m,a):a.deserialize(a.extract(m,a));if(a.extract!==q||200<=m.status&&300>m.status||304===m.status||Z.test(a.url))d(r(a.type,b));else{var h=Error(m.responseText);h.code=m.status;h.response=b;e(h)}}catch(I){e(I)}};h&&null!=a.data?m.send(a.data):m.send()});return!0===a.background?B:A(B)},jsonp:function(a,k){var A=e();a=h(a,
|
|
k);var q=new d(function(d,e){var h=a.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,k=b.document.createElement("script");b[h]=function(e){k.parentNode.removeChild(k);d(r(a.type,e));delete b[h]};k.onerror=function(){k.parentNode.removeChild(k);e(Error("JSONP request failed"));delete b[h]};null==a.data&&(a.data={});a.url=p(a.url,a.data);a.data[a.callbackKey||"callback"]=h;k.src=l(a.url,a.data);b.document.documentElement.appendChild(k)});return!0===a.background?q:A(q)},setCompletionCallback:function(a){z=
|
|
a}}}(window,t),V=function(b){function d(g,c){if(g.state!==c)throw Error("`vnode.state` must not be modified");}function e(g){var c=g.state;try{return this.apply(c,arguments)}finally{d(g,c)}}function h(g,c,f,a,b,d,e){for(;f<a;f++){var h=c[f];null!=h&&p(g,h,b,e,d)}}function p(g,c,f,b,d){var e=c.tag;if("string"===typeof e)switch(c.state={},null!=c.attrs&&L(c.attrs,c,f),e){case "#":return c.dom=C.createTextNode(c.children),a(g,c.dom,d),c.dom;case "<":return l(g,c,b,d);case "[":var r=C.createDocumentFragment();
|
|
null!=c.children&&(e=c.children,h(r,e,0,e.length,f,null,b));c.dom=r.firstChild;c.domSize=r.childNodes.length;a(g,r,d);return r;default:var n=c.tag,m=(e=c.attrs)&&e.is;n=(b=c.attrs&&c.attrs.xmlns||G[c.tag]||b)?m?C.createElementNS(b,n,{is:m}):C.createElementNS(b,n):m?C.createElement(n,{is:m}):C.createElement(n);c.dom=n;if(null!=e)for(r in m=b,e)K(c,r,null,e[r],m);a(g,n,d);null!=c.attrs&&null!=c.attrs.contenteditable?B(c):(null!=c.text&&(""!==c.text?n.textContent=c.text:c.children=[x("#",void 0,void 0,
|
|
c.text,void 0,void 0)]),null!=c.children&&(g=c.children,h(n,g,0,g.length,f,null,b),g=c.attrs,"select"===c.tag&&null!=g&&("value"in g&&K(c,"value",null,g.value,void 0),"selectedIndex"in g&&K(c,"selectedIndex",null,g.selectedIndex,void 0))));return n}else return k(c,f),null!=c.instance?(f=p(g,c.instance,f,b,d),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0,a(g,f,d),c=f):(c.domSize=0,c=I),c}function l(g,c,f,b){var d=c.children.match(/^\s*?<(\w+)/im)||[];d=C.createElement(H[d[1]]||"div");
|
|
"http://www.w3.org/2000/svg"===f?(d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+c.children+"</svg>",d=d.firstChild):d.innerHTML=c.children;c.dom=d.firstChild;c.domSize=d.childNodes.length;for(c=C.createDocumentFragment();f=d.firstChild;)c.appendChild(f);a(g,c,b);return c}function k(g,c){if("function"===typeof g.tag.view){g.state=Object.create(g.tag);var f=g.state.view;if(null!=f.$$reentrantLock$$)return I;f.$$reentrantLock$$=!0}else{g.state=void 0;f=g.tag;if(null!=f.$$reentrantLock$$)return I;
|
|
f.$$reentrantLock$$=!0;g.state=null!=g.tag.prototype&&"function"===typeof g.tag.prototype.view?new g.tag(g):g.tag(g)}null!=g.attrs&&L(g.attrs,g,c);L(g.state,g,c);g.instance=x.normalize(e.call(g.state.view,g));if(g.instance===g)throw Error("A view cannot return the vnode it received as argument");f.$$reentrantLock$$=null}function q(g,c,f,b,d,e,k){if(!(c===f&&!b||null==c&&null==f))if(null==c)h(g,f,0,f.length,d,e,k);else if(null==f)A(c,0,c.length,f,b);else{for(var n=0,l=Math.min(c.length,f.length),q=
|
|
c.length,B=!1,D=!1;n<l;n++)if(null!=c[n]&&null!=f[n]){null==c[n].key&&null==f[n].key&&(D=!0);break}if(D&&q===f.length)for(n=0;n<q;n++)c[n]===f[n]&&!b||null==c[n]&&null==f[n]||(null==c[n]?p(g,f[n],d,k,z(c,n+1,q,e)):null==f[n]?A(c,n,n+1,f,b):r(g,c[n],f[n],d,z(c,n+1,q,e),b,k));else{a:{if(null!=c.pool&&Math.abs(c.pool.length-f.length)<=Math.abs(c.length-f.length)&&(n=f[0]&&f[0].children&&f[0].children.length||0,Math.abs((c.pool[0]&&c.pool[0].children&&c.pool[0].children.length||0)-n)<=Math.abs((c[0]&&
|
|
c[0].children&&c[0].children.length||0)-n))){n=!0;break a}n=!1}n&&(B=!0,c=c.concat(c.pool));var E=n=0;l=c.length-1;for(var t=f.length-1,x,v,y,u;l>=E&&t>=n;)if(v=c[E],y=f[n],u=B&&E>=q,v===y&&!u&&!b||null==v&&null==y)E++,n++;else if(null==v)(D||null==y.key)&&p(g,f[n],d,k,z(c,++n,q,e)),E++;else if(null==y){if(D||null==v.key)A(c,n,n+1,f,b),E++;n++}else if(v.key===y.key)E++,n++,r(g,v,y,d,z(c,E,q,e),u||b,k),u&&v.tag===y.tag&&a(g,m(y),e);else if(v=c[l],u=B&&l>=q,v!==y||u||b)if(null==v)l--;else if(null==
|
|
y)n++;else if(v.key===y.key)r(g,v,y,d,z(c,l+1,q,e),u||b,k),(u&&v.tag===y.tag||n<t)&&a(g,m(y),z(c,E,q,e)),l--,n++;else break;else l--,n++;for(;l>=E&&t>=n;){v=c[l];y=f[t];u=B&&l>=q;if(v!==y||u||b)if(null==v)l--;else{if(null!=y)if(v.key===y.key)r(g,v,y,d,z(c,l+1,q,e),u||b,k),u&&v.tag===y.tag&&a(g,m(y),e),null!=v.dom&&(e=v.dom),l--;else{if(!x){x=c;D=l;v={};for(u=0;u<D;u++){var w=x[u];null!=w&&(w=w.key,null!=w&&(v[w]=u))}x=v}null!=y&&(D=x[y.key],null!=D?(v=c[D],u=B&&D>=q,r(g,v,y,d,z(c,l+1,q,e),u||b,k),
|
|
a(g,m(y),e),v.skip=!0,null!=v.dom&&(e=v.dom)):e=p(g,y,d,k,e))}t--}else l--,t--;if(t<n)break}h(g,f,n,t+1,d,e,k);A(c,E,Math.min(l+1,q),f,b);if(B)for(g=Math.max(E,q);l>=g;l--)c[l].skip?c[l].skip=!1:J(c[l],f)}}}function r(g,c,f,a,b,d,h){var n=c.tag;if(n===f.tag){f.state=c.state;f.events=c.events;var A;if(A=!d){var z,D;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(z=e.call(f.attrs.onbeforeupdate,f,c));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&(D=e.call(f.state.onbeforeupdate,
|
|
f,c));void 0===z&&void 0===D||z||D?A=!1:(f.dom=c.dom,f.domSize=c.domSize,f.instance=c.instance,A=!0)}if(!A)if("string"===typeof n)switch(null!=f.attrs&&(d?(f.state={},L(f.attrs,f,a)):N(f.attrs,f,a)),n){case "#":c.children.toString()!==f.children.toString()&&(c.dom.nodeValue=f.children);f.dom=c.dom;break;case "<":c.children!==f.children?(m(c),l(g,f,h,b)):(f.dom=c.dom,f.domSize=c.domSize);break;case "[":q(g,c.children,f.children,d,a,b,h);c=0;a=f.children;f.dom=null;if(null!=a){for(d=0;d<a.length;d++){var u=
|
|
a[d];null!=u&&null!=u.dom&&(null==f.dom&&(f.dom=u.dom),c+=u.domSize||1)}1!==c&&(f.domSize=c)}break;default:g=f.dom=c.dom;h=f.attrs&&f.attrs.xmlns||G[f.tag]||h;"textarea"===f.tag&&(null==f.attrs&&(f.attrs={}),null!=f.text&&(f.attrs.value=f.text,f.text=void 0));b=c.attrs;n=f.attrs;A=h;if(null!=n)for(u in n)K(f,u,b&&b[u],n[u],A);if(null!=b)for(u in b)null!=n&&u in n||("className"===u&&(u="class"),"o"!==u[0]||"n"!==u[1]||T(u)?"key"!==u&&f.dom.removeAttribute(u):U(f,u,void 0));null!=f.attrs&&null!=f.attrs.contenteditable?
|
|
B(f):null!=c.text&&null!=f.text&&""!==f.text?c.text.toString()!==f.text.toString()&&(c.dom.firstChild.nodeValue=f.text):(null!=c.text&&(c.children=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=f.text&&(f.children=[x("#",void 0,void 0,f.text,void 0,void 0)]),q(g,c.children,f.children,d,a,null,h))}else{if(d)k(f,a);else{f.instance=x.normalize(e.call(f.state.view,f));if(f.instance===f)throw Error("A view cannot return the vnode it received as argument");null!=f.attrs&&N(f.attrs,f,a);N(f.state,
|
|
f,a)}null!=f.instance?(null==c.instance?p(g,f.instance,a,h,b):r(g,c.instance,f.instance,a,b,d,h),f.dom=f.instance.dom,f.domSize=f.instance.domSize):null!=c.instance?(t(c.instance,null,d),f.dom=void 0,f.domSize=0):(f.dom=c.dom,f.domSize=c.domSize)}}else t(c,null,d),p(g,f,a,h,b)}function m(g){var c=g.domSize;if(null!=c||null==g.dom){var a=C.createDocumentFragment();if(0<c){for(g=g.dom;--c;)a.appendChild(g.nextSibling);a.insertBefore(g,a.firstChild)}return a}return g.dom}function z(g,c,a,b){for(;c<a;c++)if(null!=
|
|
g[c]&&null!=g[c].dom)return g[c].dom;return b}function a(g,c,a){a?g.insertBefore(c,a):g.appendChild(c)}function B(g){var c=g.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,g.dom.innerHTML!==c&&(g.dom.innerHTML=c);else if(null!=g.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function A(g,c,a,b,d){for(;c<a;c++){var f=g[c];null!=f&&(f.skip?f.skip=!1:t(f,b,d))}}function t(g,c,a){function b(){if(++h===f&&(a||(d(g,r),w(g)),g.dom)){var b=g.domSize||
|
|
1;if(1<b)for(var e=g.dom;--b;){var n=e.nextSibling,k=n.parentNode;null!=k&&k.removeChild(n)}b=g.dom;e=b.parentNode;null!=e&&e.removeChild(b);J(g,c)}}var f=1,h=0;if(!a){var r=g.state;if(g.attrs&&"function"===typeof g.attrs.onbeforeremove){var k=e.call(g.attrs.onbeforeremove,g);null!=k&&"function"===typeof k.then&&(f++,k.then(b,b))}"string"!==typeof g.tag&&"function"===typeof g.state.onbeforeremove&&(k=e.call(g.state.onbeforeremove,g),null!=k&&"function"===typeof k.then&&(f++,k.then(b,b)))}b()}function J(a,
|
|
c){var b;if(b=null!=c&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}function w(a){a.attrs&&"function"===typeof a.attrs.onremove&&e.call(a.attrs.onremove,a);if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&w(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&w(b)}}function K(a,c,b,
|
|
d,e){if("key"!==c&&"is"!==c&&!T(c)){if("o"===c[0]&&"n"===c[1])return U(a,c,d);if("undefined"===typeof d&&"value"===c&&b!==d)a.dom.value="";else if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===C.activeElement||"option"===a.tag&&a.dom.parentNode===C.activeElement||"object"===typeof d)&&void 0!==d){var f=a.dom;if("xlink:"===c.slice(0,6))f.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&"object"===
|
|
typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(f.style[g]=d[g]);for(g in a)g in d||(f.style[g]="")}else if(a===d&&(f.style.cssText="",a=null),null==d)f.style.cssText="";else if("string"===typeof d)f.style.cssText=d;else for(g in"string"===typeof a&&(f.style.cssText=""),d)f.style[g]=d[g];else if(c in f&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===g&&a.dom===
|
|
C.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===C.activeElement)return}else if(null!==b&&a.dom.value===g&&a.dom===C.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===g)return}"input"===a.tag&&"type"===c?f.setAttribute(c,d):f[c]=d}else"boolean"===typeof d?d?f.setAttribute(c,""):f.removeAttribute(c):f.setAttribute("className"===c?"class":c,d)}}}function T(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===
|
|
a||"onbeforeupdate"===a}function O(){}function U(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new O,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function L(a,c,b){"function"===typeof a.oninit&&e.call(a.oninit,
|
|
c);"function"===typeof a.oncreate&&b.push(e.bind(a.oncreate,c))}function N(a,c,b){"function"===typeof a.onupdate&&b.push(e.bind(a.onupdate,c))}var C=b.document,I=C.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},F,H={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};O.prototype=Object.create(null);O.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?
|
|
c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof F&&F.call(a.target,a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=C.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);q(a,a.vnodes,x.normalizeChildren(c),!1,b,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=c;null!=d&&C.activeElement!==d&&d.focus();for(d=0;d<
|
|
b.length;d++)b[d]()},setEventCallback:function(a){return F=a}}},H=function(b,d){function e(b){b=l.indexOf(b);-1<b&&l.splice(b,2)}function h(){if(k)throw Error("Nested m.redraw.sync() call");k=!0;for(var b=1;b<l.length;b+=2)try{l[b]()}catch(m){"undefined"!==typeof console&&console.error(m)}k=!1}var p=V(b);p.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:q()});var l=[],k=!1,q=(d||X)(h);q.sync=h;return{subscribe:function(b,d){e(b);l.push(b,d)},unsubscribe:e,redraw:q,render:p.render}}(window);
|
|
P.setCompletionCallback(H.redraw);w.mount=function(b){return function(d,e){if(null===e)b.render(d,[]),b.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var h=function(){b.render(d,x(e))};b.subscribe(d,h);h()}}}(H);var aa=t,Q=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},e={},h=0;h<b.length;h++){var p=b[h].split("="),l=decodeURIComponent(p[0]);p=2===p.length?
|
|
decodeURIComponent(p[1]):"";"true"===p?p=!0:"false"===p&&(p=!1);var k=l.split(/\]\[?|\[/),q=d;-1<l.indexOf("[")&&k.pop();for(var r=0;r<k.length;r++){l=k[r];var m=k[r+1];m=""==m||!isNaN(parseInt(m,10));var z=r===k.length-1;""===l&&(l=k.slice(0,r).join(),null==e[l]&&(e[l]=0),l=e[l]++);null==q[l]&&(q[l]=z?p:m?[]:{});q=q[l]}}return d},ba=function(b){function d(d){var e=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(b){return function(){null==
|
|
k&&(k=l(function(){k=null;b()}))}}function h(b,d,e){var a=b.indexOf("?"),h=b.indexOf("#"),k=-1<a?a:-1<h?h:b.length;if(-1<a){a=Q(b.slice(a+1,-1<h?h:b.length));for(var l in a)d[l]=a[l]}if(-1<h)for(l in d=Q(b.slice(h+1)),d)e[l]=d[l];return b.slice(0,k)}var p="function"===typeof b.history.pushState,l="function"===typeof setImmediate?setImmediate:setTimeout,k,q={prefix:"#!",getPath:function(){switch(q.prefix.charAt(0)){case "#":return d("hash").slice(q.prefix.length);case "?":return d("search").slice(q.prefix.length)+
|
|
d("hash");default:return d("pathname").slice(q.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,k){var a={},l={};d=h(d,a,l);if(null!=e){for(var m in e)a[m]=e[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return e[d]})}(m=F(a))&&(d+="?"+m);(l=F(l))&&(d+="#"+l);p?(l=k?k.state:null,m=k?k.title:null,b.onpopstate(),k&&k.replace?b.history.replaceState(l,m,q.prefix+d):b.history.pushState(l,m,q.prefix+d)):b.location.href=q.prefix+d},defineRoutes:function(d,k,l){function a(){var a=q.getPath(),
|
|
e={},m=h(a,e,e),p=b.history.state;if(null!=p)for(var r in p)e[r]=p[r];for(var t in d)if(p=new RegExp("^"+t.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(m)){m.replace(p,function(){for(var b=t.match(/:[^\/]+/g)||[],h=[].slice.call(arguments,1,-2),l=0;l<b.length;l++)e[b[l].replace(/:|\./g,"")]=decodeURIComponent(h[l]);k(d[t],e,a,t)});return}l(a,e)}p?b.onpopstate=e(a):"#"===q.prefix.charAt(0)&&(b.onhashchange=a);a()}};return q};w.route=function(b,d){var e=ba(b),h=function(a){return a},
|
|
p,l,k,q,r,m=function(a,b,m){function t(){null!=p&&d.render(a,p(x(l,k.key,k)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var A=function(){t();A=d.redraw};d.subscribe(a,t);var w=function(a){if(a!==b)e.setPath(b,null,{replace:!0});else throw Error("Could not resolve default route "+b);};e.defineRoutes(m,function(a,b,d){var e=r=function(a,m){e===r&&(l=null==m||"function"!==typeof m.view&&"function"!==typeof m?"div":m,k=b,q=d,r=null,p=(a.render||h).bind(a),
|
|
A())};a.view||"function"===typeof a?e({},a):a.onmatch?aa.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},w):e(a,"div")},w)};m.set=function(a,b,d){null!=r&&(d=d||{},d.replace=!0);r=null;e.setPath(a,b,d)};m.get=function(){return q};m.prefix=function(a){e.prefix=a};var t=function(a,b){b.dom.setAttribute("href",e.prefix+b.attrs.href);b.dom.onclick=function(b){b.ctrlKey||b.metaKey||b.shiftKey||2===b.which||(b.preventDefault(),b.redraw=!1,b=this.getAttribute("href"),0===b.indexOf(e.prefix)&&(b=b.slice(e.prefix.length)),
|
|
m.set(b,void 0,a))}};m.link=function(a){return null==a.tag?t.bind(t,a):t({},a)};m.param=function(a){return"undefined"!==typeof k&&"undefined"!==typeof a?k[a]:k};return m}(window,H);w.withAttr=function(b,d,e){return function(h){d.call(e||this,b in h.currentTarget?h.currentTarget[b]:h.currentTarget.getAttribute(b))}};var ca=V(window);w.render=ca.render;w.redraw=H.redraw;w.request=P.request;w.jsonp=P.jsonp;w.parseQueryString=Q;w.buildQueryString=F;w.version="1.1.3";w.vnode=x;w.PromisePolyfill=t;"undefined"!==
|
|
typeof module?module.exports=w:window.m=w})(); |