Bundled output for commit 0b83c29ab6 [skip ci]

This commit is contained in:
Gandalf-the-Bot 2018-03-06 15:59:33 +00:00
parent 0b83c29ab6
commit 550ad86ec5
3 changed files with 72 additions and 50 deletions

View file

@ -18,7 +18,7 @@ mithril.js [![NPM Version](https://img.shields.io/npm/v/mithril.svg)](https://ww
## What is Mithril?
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.68 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.74 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍.

View file

@ -174,6 +174,20 @@ PromisePolyfill.prototype.then = function(onFulfilled, onRejection) {
PromisePolyfill.prototype.catch = function(onRejection) {
return this.then(null, onRejection)
}
PromisePolyfill.prototype.finally = function(callback) {
return this.then(
function(value) {
return PromisePolyfill.resolve(callback()).then(function() {
return value
})
},
function(reason) {
return PromisePolyfill.resolve(callback()).then(function() {
return PromisePolyfill.reject(reason);
})
}
)
}
PromisePolyfill.resolve = function(value) {
if (value instanceof PromisePolyfill) return value
return new PromisePolyfill(function(resolve) {resolve(value)})
@ -208,10 +222,18 @@ PromisePolyfill.race = function(list) {
})
}
if (typeof window !== "undefined") {
if (typeof window.Promise === "undefined") window.Promise = PromisePolyfill
if (typeof window.Promise === "undefined") {
window.Promise = PromisePolyfill
} else if (!window.Promise.prototype.finally) {
window.Promise.prototype.finally = PromisePolyfill.prototype.finally
}
var PromisePolyfill = window.Promise
} else if (typeof global !== "undefined") {
if (typeof global.Promise === "undefined") global.Promise = PromisePolyfill
if (typeof global.Promise === "undefined") {
global.Promise = PromisePolyfill
} else if (!global.Promise.prototype.finally) {
global.Promise.prototype.finally = PromisePolyfill.prototype.finally
}
var PromisePolyfill = global.Promise
} else {
}

94
mithril.min.js vendored
View file

@ -1,47 +1,47 @@
(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})();
(function(){function x(b,c,e,h,p,l){return{tag:b,key:c,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 c in b)if(G.call(b,c))return!1;return!0}function w(b){var c=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],
t=h[2];""===q&&""!==t?p=t:"#"===q?k.id=t:"."===q?l.push(t):"["===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==c)c={};else if("object"!==typeof c||null!=c.tag||Array.isArray(c))c={},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,A;l=c.className||c["class"];if(!R(h.attrs)&&!R(c)){k={};for(var a in c)G.call(c,a)&&(k[a]=c[a]);c=k}for(a in h.attrs)G.call(h.attrs,a)&&(c[a]=h.attrs[a]);void 0!==l&&(void 0!==c["class"]&&(c["class"]=void 0,c.className=l),null!=h.attrs.className&&(c.className=h.attrs.className+" "+l));for(a in c)if(G.call(c,a)&&"key"!==a){p=!0;break}Array.isArray(e)&&1===e.length&&null!=e[0]&&"#"===e[0].tag?A=e[0].children:m=e;return x(h.tag,c.key,p?c:void 0,m,A)}return x(b,c.key,c,e)}function X(b){var c=
0,e=null,h="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var p=Date.now()-c;null===e&&(e=h(function(){e=null;b();c=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 c=0;c<b.length;c++)b[c]=x.normalize(b[c]);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,c){return x("[",b.key,b,x.normalizeChildren(c),void 0,void 0)};var r=function(b){function c(b,a){return function M(c){var z;try{if(!a||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(z=c.then))m(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",c);for(var e=0;e<b.length;e++)b[e](c);p.length=0;l.length=0;t.state=a;t.retry=
function(){M(c)}});else{if(c===h)throw new TypeError("Promise can't be resolved w/ itself");e(z.bind(c))}}catch(Y){q(Y)}}}function e(b){function a(a){return function(b){0<c++||a(b)}}var c=0,t=a(q);try{b(a(k),t)}catch(M){t(M)}}if(!(this instanceof r))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=c(p,!0),q=c(l,!1),t=h._instance={resolvers:p,rejectors:l},m="function"===typeof setImmediate?setImmediate:
setTimeout;e(b)};r.prototype.then=function(b,c){function e(b,c,e,k){c.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 r(function(b,c){p=b;l=c});e(b,h.resolvers,p,!0);e(c,h.rejectors,l,!1);return k};r.prototype["catch"]=function(b){return this.then(null,b)};r.prototype["finally"]=function(b){return this.then(function(c){return r.resolve(b()).then(function(){return c})},function(c){return r.resolve(b()).then(function(){return r.reject(c)})})};
r.resolve=function(b){return b instanceof r?b:new r(function(c){c(b)})};r.reject=function(b){return new r(function(c,e){e(b)})};r.all=function(b){return new r(function(c,e){var h=b.length,p=0,l=[];if(0===b.length)c([]);else for(var k=0;k<b.length;k++)(function(k){function t(b){p++;l[k]=b;p===h&&c(l)}null==b[k]||"object"!==typeof b[k]&&"function"!==typeof b[k]||"function"!==typeof b[k].then?t(b[k]):b[k].then(t,e)})(k)})};r.race=function(b){return new r(function(c,e){for(var h=0;h<b.length;h++)b[h].then(c,
e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=r:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=r.prototype["finally"]),r=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=r:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=r.prototype["finally"]),r=global.Promise);var E=function(b){function c(b,h){if(Array.isArray(h))for(var k=0;k<h.length;k++)c(b+"["+k+"]",h[k]);
else if("[object Object]"===Object.prototype.toString.call(h))for(k in h)c(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)c(h,b[h]);return e.join("&")},Z=/^file:\/\//i,P=function(b,c){function e(){function a(){0===--b&&"function"===typeof A&&A()}var b=0;return function J(c){var e=c.then;c.then=function(){b++;var t=e.apply(c,arguments);t.then(a,function(c){a();
if(0===b)throw c;});return J(t)};return c}}function h(a,b){if("string"===typeof a){var c=a;a=b||{};null==a.url&&(a.url=c)}return a}function p(a,b){if(null==b)return a;for(var c=a.match(/:[^\/]+/gi)||[],e=0;e<c.length;e++){var t=c[e].slice(1);null!=b[t]&&(a=a.replace(c[e],b[t]))}return a}function l(a,b){var c=E(b);if(""!==c){var e=0>a.indexOf("?")?"?":"&";a+=e+c}return a}function k(a){try{return""!==a?JSON.parse(a):null}catch(B){throw Error(a);}}function q(a){return a.responseText}function t(a,b){if("function"===
typeof a)if(Array.isArray(b))for(var c=0;c<b.length;c++)b[c]=new a(b[c]);else return new a(b);return b}var m=0,A;return{request:function(a,m){var z=e();a=h(a,m);var B=new c(function(c,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,z=!1,B=m.abort;m.abort=function(){z=!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 A in a.headers)({}).hasOwnProperty.call(a.headers,A)&&m.setRequestHeader(A,a.headers[A]);"function"===typeof a.config&&(m=a.config(m,a)||m);m.onreadystatechange=function(){if(!z&&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))c(t(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:z(B)},jsonp:function(a,k){var z=e();a=h(a,k);var q=new c(function(c,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);c(t(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:z(q)},setCompletionCallback:function(a){A=a}}}(window,r),V=function(b){function c(g,d){if(g.state!==d)throw Error("`vnode.state` must not be modified");}function e(g){var d=g.state;try{return this.apply(d,arguments)}finally{c(g,d)}}function h(g,d,f,a,b,c,e){for(;f<a;f++){var h=d[f];
null!=h&&p(g,h,b,e,c)}}function p(g,d,f,b,c){var e=d.tag;if("string"===typeof e)switch(d.state={},null!=d.attrs&&L(d.attrs,d,f),e){case "#":return d.dom=C.createTextNode(d.children),a(g,d.dom,c),d.dom;case "<":return l(g,d,b,c);case "[":var t=C.createDocumentFragment();null!=d.children&&(e=d.children,h(t,e,0,e.length,f,null,b));d.dom=t.firstChild;d.domSize=t.childNodes.length;a(g,t,c);return t;default:var n=d.tag,m=(e=d.attrs)&&e.is;n=(b=d.attrs&&d.attrs.xmlns||G[d.tag]||b)?m?C.createElementNS(b,
n,{is:m}):C.createElementNS(b,n):m?C.createElement(n,{is:m}):C.createElement(n);d.dom=n;if(null!=e)for(t in m=b,e)K(d,t,null,e[t],m);a(g,n,c);null!=d.attrs&&null!=d.attrs.contenteditable?B(d):(null!=d.text&&(""!==d.text?n.textContent=d.text:d.children=[x("#",void 0,void 0,d.text,void 0,void 0)]),null!=d.children&&(g=d.children,h(n,g,0,g.length,f,null,b),g=d.attrs,"select"===d.tag&&null!=g&&("value"in g&&K(d,"value",null,g.value,void 0),"selectedIndex"in g&&K(d,"selectedIndex",null,g.selectedIndex,
void 0))));return n}else return k(d,f),null!=d.instance?(f=p(g,d.instance,f,b,c),d.dom=d.instance.dom,d.domSize=null!=d.dom?d.instance.domSize:0,a(g,f,c),d=f):(d.domSize=0,d=I),d}function l(g,d,f,b){var c=d.children.match(/^\s*?<(\w+)/im)||[];c=C.createElement(H[c[1]]||"div");"http://www.w3.org/2000/svg"===f?(c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+d.children+"</svg>",c=c.firstChild):c.innerHTML=d.children;d.dom=c.firstChild;d.domSize=c.childNodes.length;for(d=C.createDocumentFragment();f=
c.firstChild;)d.appendChild(f);a(g,d,b);return d}function k(g,d){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,d);L(g.state,g,d);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,d,f,b,c,e,k){if(!(d===f&&!b||null==d&&null==f))if(null==d)h(g,f,0,f.length,c,e,k);else if(null==f)z(d,0,d.length,f,b);else{for(var n=0,l=Math.min(d.length,f.length),q=d.length,B=!1,D=!1;n<l;n++)if(null!=d[n]&&null!=f[n]){null==d[n].key&&null==f[n].key&&(D=!0);break}if(D&&q===f.length)for(n=0;n<q;n++)d[n]===f[n]&&!b||null==d[n]&&null==f[n]||(null==d[n]?p(g,f[n],c,k,A(d,n+1,q,e)):null==f[n]?z(d,n,n+1,f,b):t(g,d[n],f[n],c,A(d,n+1,q,e),b,k));else{a:{if(null!=d.pool&&
Math.abs(d.pool.length-f.length)<=Math.abs(d.length-f.length)&&(n=f[0]&&f[0].children&&f[0].children.length||0,Math.abs((d.pool[0]&&d.pool[0].children&&d.pool[0].children.length||0)-n)<=Math.abs((d[0]&&d[0].children&&d[0].children.length||0)-n))){n=!0;break a}n=!1}n&&(B=!0,d=d.concat(d.pool));var r=n=0;l=d.length-1;for(var F=f.length-1,x,v,y,u;l>=r&&F>=n;)if(v=d[r],y=f[n],u=B&&r>=q,v===y&&!u&&!b||null==v&&null==y)r++,n++;else if(null==v)(D||null==y.key)&&p(g,f[n],c,k,A(d,++n,q,e)),r++;else if(null==
y){if(D||null==v.key)z(d,n,n+1,f,b),r++;n++}else if(v.key===y.key)r++,n++,t(g,v,y,c,A(d,r,q,e),u||b,k),u&&v.tag===y.tag&&a(g,m(y),e);else if(v=d[l],u=B&&l>=q,v!==y||u||b)if(null==v)l--;else if(null==y)n++;else if(v.key===y.key)t(g,v,y,c,A(d,l+1,q,e),u||b,k),(u&&v.tag===y.tag||n<F)&&a(g,m(y),A(d,r,q,e)),l--,n++;else break;else l--,n++;for(;l>=r&&F>=n;){v=d[l];y=f[F];u=B&&l>=q;if(v!==y||u||b)if(null==v)l--;else{if(null!=y)if(v.key===y.key)t(g,v,y,c,A(d,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=d;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=d[D],u=B&&D>=q,t(g,v,y,c,A(d,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,c,k,e))}F--}else l--,F--;if(F<n)break}h(g,f,n,F+1,c,e,k);z(d,r,Math.min(l+1,q),f,b);if(B)for(g=Math.max(r,q);l>=g;l--)d[l].skip?d[l].skip=!1:J(d[l],f)}}}function t(g,d,f,b,a,c,h){var n=d.tag;if(n===f.tag){f.state=d.state;f.events=d.events;var z;if(z=
!c){var A,D;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(A=e.call(f.attrs.onbeforeupdate,f,d));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&(D=e.call(f.state.onbeforeupdate,f,d));void 0===A&&void 0===D||A||D?z=!1:(f.dom=d.dom,f.domSize=d.domSize,f.instance=d.instance,z=!0)}if(!z)if("string"===typeof n)switch(null!=f.attrs&&(c?(f.state={},L(f.attrs,f,b)):N(f.attrs,f,b)),n){case "#":d.children.toString()!==f.children.toString()&&(d.dom.nodeValue=f.children);f.dom=
d.dom;break;case "<":d.children!==f.children?(m(d),l(g,f,h,a)):(f.dom=d.dom,f.domSize=d.domSize);break;case "[":q(g,d.children,f.children,c,b,a,h);d=0;b=f.children;f.dom=null;if(null!=b){for(c=0;c<b.length;c++){var u=b[c];null!=u&&null!=u.dom&&(null==f.dom&&(f.dom=u.dom),d+=u.domSize||1)}1!==d&&(f.domSize=d)}break;default:g=f.dom=d.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));a=d.attrs;n=f.attrs;z=h;
if(null!=n)for(u in n)K(f,u,a&&a[u],n[u],z);if(null!=a)for(u in a)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!=d.text&&null!=f.text&&""!==f.text?d.text.toString()!==f.text.toString()&&(d.dom.firstChild.nodeValue=f.text):(null!=d.text&&(d.children=[x("#",void 0,void 0,d.text,void 0,d.dom.firstChild)]),null!=f.text&&(f.children=[x("#",void 0,void 0,f.text,void 0,
void 0)]),q(g,d.children,f.children,c,b,null,h))}else{if(c)k(f,b);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,b);N(f.state,f,b)}null!=f.instance?(null==d.instance?p(g,f.instance,b,h,a):t(g,d.instance,f.instance,b,a,c,h),f.dom=f.instance.dom,f.domSize=f.instance.domSize):null!=d.instance?(r(d.instance,null,c),f.dom=void 0,f.domSize=0):(f.dom=d.dom,f.domSize=d.domSize)}}else r(d,
null,c),p(g,f,b,h,a)}function m(g){var d=g.domSize;if(null!=d||null==g.dom){var b=C.createDocumentFragment();if(0<d){for(g=g.dom;--d;)b.appendChild(g.nextSibling);b.insertBefore(g,b.firstChild)}return b}return g.dom}function A(g,d,b,a){for(;d<b;d++)if(null!=g[d]&&null!=g[d].dom)return g[d].dom;return a}function a(g,d,b){b?g.insertBefore(d,b):g.appendChild(d)}function B(g){var d=g.children;if(null!=d&&1===d.length&&"<"===d[0].tag)d=d[0].children,g.dom.innerHTML!==d&&(g.dom.innerHTML=d);else if(null!=
g.text||null!=d&&0!==d.length)throw Error("Child node of a contenteditable must be trusted");}function z(g,d,b,a,c){for(;d<b;d++){var f=g[d];null!=f&&(f.skip?f.skip=!1:r(f,a,c))}}function r(g,d,b){function a(){if(++h===f&&(b||(c(g,t),w(g)),g.dom)){var a=g.domSize||1;if(1<a)for(var e=g.dom;--a;){var n=e.nextSibling,k=n.parentNode;null!=k&&k.removeChild(n)}a=g.dom;e=a.parentNode;null!=e&&e.removeChild(a);J(g,d)}}var f=1,h=0;if(!b){var t=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(a,a))}"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(a,a)))}a()}function J(b,d){var a;if(a=null!=d&&null==b.domSize)a=b.attrs,a=!(null!=a&&(a.oncreate||a.onupdate||a.onbeforeremove||a.onremove));a&&"string"===typeof b.tag&&(d.pool?d.pool.push(b):d.pool=[b])}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 d=0;d<a.length;d++){var b=a[d];null!=b&&w(b)}}function K(a,d,b,c,e){if("key"!==d&&"is"!==d&&!T(d)){if("o"===d[0]&&"n"===d[1])return U(a,d,c);if("undefined"===typeof c&&"value"===d&&b!==c)a.dom.value="";else if((b!==c||"value"===d||"checked"===d||"selectedIndex"===d||"selected"===d&&a.dom===C.activeElement||
"option"===a.tag&&a.dom.parentNode===C.activeElement||"object"===typeof c)&&void 0!==c){var f=a.dom;if("xlink:"===d.slice(0,6))f.setAttributeNS("http://www.w3.org/1999/xlink",d,c);else if("style"===d)if(a=b,null!=a&&null!=c&&"object"===typeof a&&"object"===typeof c&&c!==a){for(var g in c)c[g]!==a[g]&&(f.style[g]=c[g]);for(g in a)g in c||(f.style[g]="")}else if(a===c&&(f.style.cssText="",a=null),null==c)f.style.cssText="";else if("string"===typeof c)f.style.cssText=c;else for(g in"string"===typeof a&&
(f.style.cssText=""),c)f.style[g]=c[g];else if(d in f&&"href"!==d&&"list"!==d&&"form"!==d&&"width"!==d&&"height"!==d&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===d){g=""+c;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===g&&a.dom===C.activeElement)return;if("select"===a.tag)if(null===c){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"===d?f.setAttribute(d,c):f[d]=c}else"boolean"===typeof c?c?f.setAttribute(d,""):f.removeAttribute(d):f.setAttribute("className"===d?"class":d,c)}}}function T(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function O(){}function U(a,d,b){null!=a.events?a.events[d]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[d]&&a.dom.removeEventListener(d.slice(2),a.events,!1),a.events[d]=void 0):(null==a.events[d]&&
a.dom.addEventListener(d.slice(2),a.events,!1),a.events[d]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new O,a.dom.addEventListener(d.slice(2),a.events,!1),a.events[d]=b)}function L(a,d,b){"function"===typeof a.oninit&&e.call(a.oninit,d);"function"===typeof a.oncreate&&b.push(e.bind(a.oncreate,d))}function N(a,d,b){"function"===typeof a.onupdate&&b.push(e.bind(a.onupdate,d))}var C=b.document,I=C.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},
E,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 d=this["on"+a.type];"function"===typeof d?d.call(a.target,a):"function"===typeof d.handleEvent&&d.handleEvent(a);"function"===typeof E&&E.call(a.target,a)};return{render:function(a,d){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],c=C.activeElement,
e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(d)||(d=[d]);q(a,a.vnodes,x.normalizeChildren(d),!1,b,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=d;null!=c&&C.activeElement!==c&&c.focus();for(c=0;c<b.length;c++)b[c]()},setEventCallback:function(a){return E=a}}},H=function(b,c){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=(c||X)(h);q.sync=h;return{subscribe:function(b,c){e(b);l.push(b,c)},unsubscribe:e,redraw:q,render:p.render}}(window);P.setCompletionCallback(H.redraw);w.mount=function(b){return function(c,e){if(null===e)b.render(c,[]),b.unsubscribe(c);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(c,x(e))};
b.subscribe(c,h);h()}}}(H);var aa=r,Q=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var c={},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=c;-1<l.indexOf("[")&&k.pop();for(var t=0;t<k.length;t++){l=k[t];var m=k[t+1];m=""==m||!isNaN(parseInt(m,10));var r=t===k.length-1;""===l&&(l=k.slice(0,t).join(),null==e[l]&&(e[l]=0),
l=e[l]++);null==q[l]&&(q[l]=r?p:m?[]:{});q=q[l]}}return c},ba=function(b){function c(c){var e=b.location[c].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===c&&"/"!==e[0]&&(e="/"+e);return e}function e(b){return function(){null==k&&(k=l(function(){k=null;b()}))}}function h(b,c,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)c[l]=a[l]}if(-1<h)for(l in c=Q(b.slice(h+1)),c)e[l]=c[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 c("hash").slice(q.prefix.length);case "?":return c("search").slice(q.prefix.length)+c("hash");default:return c("pathname").slice(q.prefix.length)+c("search")+c("hash")}},setPath:function(c,e,k){var a={},l={};c=h(c,a,l);if(null!=e){for(var m in e)a[m]=e[m];c=c.replace(/:([^\/]+)/g,function(b,c){delete a[c];return e[c]})}(m=
E(a))&&(c+="?"+m);(l=E(l))&&(c+="#"+l);p?(l=k?k.state:null,m=k?k.title:null,b.onpopstate(),k&&k.replace?b.history.replaceState(l,m,q.prefix+c):b.history.pushState(l,m,q.prefix+c)):b.location.href=q.prefix+c},defineRoutes:function(c,k,l){function a(){var a=q.getPath(),e={},m=h(a,e,e),p=b.history.state;if(null!=p)for(var t in p)e[t]=p[t];for(var r in c)if(p=new RegExp("^"+r.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(m)){m.replace(p,function(){for(var b=r.match(/:[^\/]+/g)||
[],h=[].slice.call(arguments,1,-2),l=0;l<b.length;l++)e[b[l].replace(/:|\./g,"")]=decodeURIComponent(h[l]);k(c[r],e,a,r)});return}l(a,e)}p?b.onpopstate=e(a):"#"===q.prefix.charAt(0)&&(b.onhashchange=a);a()}};return q};w.route=function(b,c){var e=ba(b),h=function(a){return a},p,l,k,q,t,m=function(a,b,m){function r(){null!=p&&c.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 z=function(){r();z=c.redraw};c.subscribe(a,r);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,c){var e=t=function(a,m){e===t&&(l=null==m||"function"!==typeof m.view&&"function"!==typeof m?"div":m,k=b,q=c,t=null,p=(a.render||h).bind(a),z())};a.view||"function"===typeof a?e({},a):a.onmatch?aa.resolve(a.onmatch(b,c)).then(function(b){e(a,b)},w):e(a,"div")},w)};m.set=function(a,b,c){null!=t&&(c=c||{},c.replace=!0);t=null;e.setPath(a,b,c)};m.get=function(){return q};
m.prefix=function(a){e.prefix=a};var r=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?r.bind(r,a):r({},a)};m.param=function(a){return"undefined"!==typeof k&&"undefined"!==typeof a?k[a]:k};return m}(window,H);w.withAttr=function(b,c,e){return function(h){c.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=E;w.version="1.1.3";w.vnode=x;w.PromisePolyfill=r;"undefined"!==typeof module?module.exports=w:window.m=w})();