mail/public/js/lib/mithril.min.js
2020-04-23 07:56:39 +02:00

44 lines
22 KiB
JavaScript

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