Bundled output for commit 457dd92d46 [skip ci]

This commit is contained in:
Gandalf-the-Bot 2017-08-16 07:14:17 +00:00
parent 457dd92d46
commit 96aa185302
3 changed files with 57 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.25 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.29 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

@ -905,6 +905,18 @@ var coreRenderer = function($window) {
}
//style
function updateStyle(element, old, style) {
if (old != null && style != null && typeof old === "object" && typeof style === "object" && style !== old) {
// Both old & new are (different) objects.
// Update style properties that have changed
for (var key2 in style) {
if (style[key2] !== old[key2]) element.style[key2] = style[key2]
}
// Remove style properties that no longer exist
for (var key2 in old) {
if (!(key2 in style)) element.style[key2] = ""
}
return
}
if (old === style) element.style.cssText = "", old = null
if (style == null) element.style.cssText = ""
else if (typeof style === "string") element.style.cssText = style
@ -913,11 +925,6 @@ var coreRenderer = function($window) {
for (var key2 in style) {
element.style[key2] = style[key2]
}
if (old != null && typeof old !== "string") {
for (var key2 in old) {
if (!(key2 in style)) element.style[key2] = ""
}
}
}
}
//event

88
mithril.min.js vendored
View file

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