#1342 update m.route.link target if href changes

This commit is contained in:
Leo Horie 2016-10-04 12:19:55 -04:00
parent 0e918f14c2
commit 40251c6c16
7 changed files with 153 additions and 44 deletions

84
mithril.min.js vendored
View file

@ -1,42 +1,42 @@
new function(){function u(b,e,l,g,k,h){return{tag:b,key:e,attrs:l,children:g,text:k,dom:h,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function w(b){if(null==b||"string"!==typeof b&&null==b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b&&void 0===G[b]){for(var e,l,g=[],k={};e=P.exec(b);){var h=e[1],q=e[2];""===h&&""!==q?l=q:"#"===h?k.id=q:"."===h?g.push(q):"["===e[3][0]&&((h=e[6])&&(h=h.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),
k[e[4]]=h||!0)}0<g.length&&(k.className=g.join(" "));G[b]=function(b,f){var e=!1,h,g,q=b.className||b["class"],x;for(x in k)b[x]=k[x];void 0!==q&&(void 0!==b["class"]&&(b["class"]=void 0,b.className=q),void 0!==k.className&&(b.className=k.className+" "+q));for(x in b)if("key"!==x){e=!0;break}f instanceof Array&&1==f.length&&null!=f[0]&&"#"===f[0].tag?g=f[0].children:h=f;return u(l||"div",b.key,e?b:void 0,h,g,void 0)}}var t;null!=arguments[1]&&("object"!==typeof arguments[1]||void 0!==arguments[1].tag||
arguments[1]instanceof Array)?g=1:(t=arguments[1],g=2);if(arguments.length===g+1)e=arguments[g]instanceof Array?arguments[g]:[arguments[g]];else for(e=[];g<arguments.length;g++)e.push(arguments[g]);return"string"===typeof b?G[b](t||{},u.normalizeChildren(e)):u(b,t&&t.key,t||{},u.normalizeChildren(e),void 0,void 0)}u.normalize=function(b){return b instanceof Array?u("[",void 0,void 0,u.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?u("#",void 0,void 0,b,void 0,void 0):b};u.normalizeChildren=
function(b){for(var e=0;e<b.length;e++)b[e]=u.normalize(b[e]);return b};var P=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,G={};w.trust=function(b){return u("<",void 0,void 0,b,void 0,void 0)};w.fragment=function(b,e){return u("[",b.key,b,u.normalizeChildren(e),void 0,void 0)};var N=function(b){function e(){function a(){0<arguments.length&&arguments[0]!==D&&g(a,arguments[0],void 0);return a._state.value}l(a);0<arguments.length&&arguments[0]!==D&&g(a,arguments[0],
void 0);return a}function l(a){a.constructor=e;a._state={id:Q++,value:void 0,error:void 0,state:0,derive:void 0,recover:void 0,deps:{},parents:[],errorStream:void 0,endStream:void 0};a.map=u;a.ap=w;a.of=e;a.valueOf=n;a.toJSON=H;a.toString=n;a.run=p;a["catch"]=A;Object.defineProperties(a,{error:{get:function(){if(!a._state.errorStream){var c=function(){0<arguments.length&&arguments[0]!==D&&g(a,void 0,arguments[0]);return a._state.error};l(c);x(c,[a],L,L);a._state.errorStream=c}return a._state.errorStream}},
end:{get:function(){if(!a._state.endStream){var c=e();c.map(function(d){!0===d&&(z(a),z(c));return d});a._state.endStream=c}return a._state.endStream}}})}function g(a,c,d){k(a,c,d);for(var f in a._state.deps)q(a._state.deps[f],!1);a._state.changed=!1;for(var b in a._state.deps)a._state.deps[b]._state.changed=!1}function k(a,c,d){d=r(c,d);if(void 0!==d&&"function"===typeof a._state.recover){if(!t(a,h,!0))return}else h(a,c,d);a._state.changed=!0;2!==a._state.state&&(a._state.state=1)}function h(a,c,
d){a._state.value=c;a._state.error=d}function q(d,f){var b=d._state.parents;0<b.length&&b.filter(c).length===b.length&&(f||0<b.filter(a).length)&&(b=b.filter(M),0<b.length?k(d,void 0,b[0]._state.error):t(d,k,!1))}function t(a,c,d){try{var b=d?a._state.recover():a._state.derive();if(b===D)return!1;c(a,b,void 0)}catch(e){c(a,void 0,null!=e.__error?e.__error:e),null==e.__error&&f(a,e)}return!0}function r(a,c){null!=a&&a.constructor===e&&(c=void 0!==a._state.error?a._state.error:r(a._state.value,a._state.error));
return c}function f(a,c){0===Object.keys(a._state.deps).length&&setTimeout(function(){0===Object.keys(a._state.deps).length&&b(c)},0)}function p(a){var c=e(),d=this;return x(c,[d],function(){return B(c,a(d()))},void 0)}function A(a){var c=e(),d=this;return x(c,[d],function(){return d._state.value},function(){return B(c,a(d._state.error))})}function m(c,d){if(d.length>d.filter(E).length)throw Error("Ensure that each item passed to m.prop.combine/m.prop.merge is a stream");return x(e(),d,function(){var b=
d.filter(M);if(0<b.length)throw{__error:b[0]._state.error};return c.apply(this,d.concat([d.filter(a)]))},void 0)}function B(a,c){if(null!=c&&c.constructor===e){var d=c,b=function(){k(a,d._state.value,d._state.error);for(var c in a._state.deps)q(a._state.deps[c],!1)};d.map(b)["catch"](function(a){b();throw{__error:a};});if(0===d._state.state)return D;if(d._state.error)throw{__error:d._state.error};c=d._state.value}return c}function x(a,c,b,f){var e=a._state;e.derive=b;e.recover=f;e.parents=c.filter(d);
C(a,e.parents);q(a,!0);return a}function C(a,c){for(var d=0;d<c.length;d++)c[d]._state.deps[a._state.id]=a,C(a,c[d]._state.parents)}function z(a){for(var c=0;c<a._state.parents.length;c++)delete a._state.parents[c]._state.deps[a._state.id];for(var d in a._state.deps){var c=a._state.deps[d],b=c._state.parents.indexOf(a);-1<b&&c._state.parents.splice(b,1)}a._state.state=2;a._state.deps={}}function u(a){return m(function(c){return a(c())},[this])}function w(a){return m(function(a,c){return a()(c())},
[this,a])}function n(){return this._state.value}function H(){return null!=this._state.value&&"function"===typeof this._state.value.toJSON?this._state.value.toJSON():this._state.value}function E(a){return a._state}function c(a){return 1===a._state.state}function a(a){return a._state.changed}function d(a){return 2!==a._state.state}function M(a){return a._state.error}var Q=0,L=function(){},D={};e.merge=function(a){return m(function(){return a.map(function(a){return a()})},a)};e.combine=m;e.reject=function(a){var c=
e();c.error(a);return c};e.HALT=D;return e}(console.log.bind(console)),F=function(b){function e(b,h){if(h instanceof Array)for(var g=0;g<h.length;g++)e(b+"["+g+"]",h[g]);else if("[object Object]"===Object.prototype.toString.call(h))for(g in h)e(b+"["+g+"]",h[g]);else l.push(encodeURIComponent(b)+(null!=h&&""!==h?"="+encodeURIComponent(h):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var l=[],g;for(g in b)e(g,b[g]);return l.join("&")},I=function(b,e){function l(b,e){if(null==
e)return b;for(var g=b.match(/:[^\/]+/gi)||[],h=0;h<g.length;h++){var k=g[h].slice(1);null!=e[k]&&(b=b.replace(g[h],e[k]),delete e[k])}return b}function g(b,e){var g=F(e);if(""!==g){var h=0>b.indexOf("?")?"?":"&";b+=h+g}return b}function k(b){try{return""!==b?JSON.parse(b):null}catch(e){throw Error(b);}}function h(b){return b.responseText}function q(b,e){if("function"===typeof b)if(e instanceof Array)for(var g=0;g<e.length;g++)e[g]=new b(e[g]);else return new b(e);return e}var t=0,r;return{request:function(f){var p=
e();void 0!==f.initialValue&&p(f.initialValue);var A="boolean"===typeof f.useBody?f.useBody:"GET"!==f.method&&"TRACE"!==f.method;"function"!==typeof f.serialize&&(f.serialize="undefined"!==typeof FormData&&f.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof f.deserialize&&(f.deserialize=k);"function"!==typeof f.extract&&(f.extract=h);f.url=l(f.url,f.data);A?f.data=f.serialize(f.data):f.url=g(f.url,f.data);var m=new b.XMLHttpRequest;m.open(f.method,f.url,"boolean"===
typeof f.async?f.async:!0,"string"===typeof f.user?f.user:void 0,"string"===typeof f.password?f.password:void 0);f.serialize===JSON.stringify&&A&&m.setRequestHeader("Content-Type","application/json; charset=utf-8");f.deserialize===k&&m.setRequestHeader("Accept","application/json, text/*");"function"===typeof f.config&&(m=f.config(m,f)||m);m.onreadystatechange=function(){if(4===m.readyState){try{var b=f.extract!==h?f.extract(m,f):f.deserialize(f.extract(m,f));if(200<=m.status&&300>m.status||304===
m.status)p(q(f.type,b));else{var e=Error(m.responseText),g;for(g in b)e[g]=b[g];p.error(e)}}catch(k){p.error(k)}"function"===typeof r&&r()}};A?m.send(f.data):m.send();return p},jsonp:function(f){var h=e();void 0!==f.initialValue&&h(f.initialValue);var k=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+t++,m=b.document.createElement("script");b[k]=function(e){m.parentNode.removeChild(m);h(q(f.type,e));"function"===typeof r&&r();delete b[k]};m.onerror=function(){m.parentNode.removeChild(m);
h.error(Error("JSONP request failed"));"function"===typeof r&&r();delete b[k]};null==f.data&&(f.data={});f.url=l(f.url,f.data);f.data[f.callbackKey||"callback"]=k;m.src=g(f.url,f.data);b.document.documentElement.appendChild(m);return h},setCompletionCallback:function(b){r=b}}}(window,N),J=function(){var b=[];return{subscribe:b.push.bind(b),unsubscribe:function(e){e=b.indexOf(e);-1<e&&b.splice(e,1)},publish:function(){for(var e=0;e<b.length;e++)b[e].apply(this,arguments)}}}();I.setCompletionCallback(J.publish);
var O=function(b){function e(c,a,d,b,e,f,g){for(;d<b;d++){var h=a[d];null!=h&&r(c,l(h,e,g),f)}}function l(c,a,d){var b=c.tag;null!=c.attrs&&z(c.attrs,c,a);if("string"===typeof b)switch(b){case "#":return c.dom=n.createTextNode(c.children);case "<":return g(c);case "[":var f=n.createDocumentFragment();null!=c.children&&(b=c.children,e(f,b,0,b.length,a,null,d));c.dom=f.firstChild;c.domSize=f.childNodes.length;return f;default:var h=c.tag;switch(c.tag){case "svg":d="http://www.w3.org/2000/svg";break;
case "math":d="http://www.w3.org/1998/Math/MathML"}var k=(b=c.attrs)&&b.is,h=d?k?n.createElementNS(d,h,{is:k}):n.createElementNS(d,h):k?n.createElement(h,{is:k}):n.createElement(h);c.dom=h;if(null!=b)for(f in k=d,b)B(c,f,null,b[f],k);null!=c.text&&(""!==c.text?h.textContent=c.text:c.children=[u("#",void 0,void 0,c.text,void 0,void 0)]);null!=c.children&&(f=c.children,e(h,f,0,f.length,a,null,d),a=c.attrs,"select"===c.tag&&null!=a&&("value"in a&&B(c,"value",null,a.value,void 0),"selectedIndex"in a&&
B(c,"selectedIndex",null,a.selectedIndex,void 0)));return h}else{c.state||(c.state={});R(c.state,c.tag);z(c.tag,c,a);c.instance=u.normalize(c.tag.view.call(c.state,c));if(null!=c.instance){if(c.instance===c)throw Error("A view cannot return the vnode it received as arguments");a=l(c.instance,a,d);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;c=a}else c.domSize=0,c=H;return c}}function g(c){var a={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",a=n.createElement(a);a.innerHTML=c.children;c.dom=a.firstChild;c.domSize=a.childNodes.length;c=n.createDocumentFragment();for(var d;d=a.firstChild;)c.appendChild(d);return c}function k(c,a,d,b,g,k){if(a!==d&&(null!=a||null!=d))if(null==a)e(c,d,0,d.length,b,g,void 0);else if(null==d)f(c,a,0,a.length,d);else{var p;a:{if(null!=a.pool&&Math.abs(a.pool.length-d.length)<=Math.abs(a.length-d.length)&&(p=d[0]&&d[0].children&&
d[0].children.length||0,Math.abs((a.pool[0]&&a.pool[0].children&&a.pool[0].children.length||0)-p)<=Math.abs((a[0]&&a[0].children&&a[0].children.length||0)-p))){p=!0;break a}p=!1}p&&(a=a.concat(a.pool));if(a.length===d.length&&null!=d[0]&&null==d[0].key)for(var v=0;v<a.length;v++)a[v]===d[v]||null==a[v]&&null==d[v]||(null==a[v]?r(c,l(d[v],b,k),t(a,v+1,g)):null==d[v]?f(c,a,v,v+1,d):h(c,a[v],d[v],b,t(a,v+1,g),p,k),p&&a[v].tag===d[v].tag&&r(c,q(a[v]),t(a,v+1,g)));else{for(var m=v=0,x=a.length-1,A=d.length-
1,B;x>=v&&A>=m;){var y=a[v],n=d[m];if(y===n)v++,m++;else if(null!=y&&null!=n&&y.key===n.key)v++,m++,h(c,y,n,b,t(a,v,g),p,k),p&&y.tag===n.tag&&r(c,q(y),g);else if(y=a[x],y===n)x--,m++;else if(null!=y&&null!=n&&y.key===n.key)h(c,y,n,b,t(a,x+1,g),p,k),m<A&&r(c,q(y),t(a,v,g)),x--,m++;else break}for(;x>=v&&A>=m;){y=a[x];n=d[A];if(y===n)x--;else if(null!=y&&null!=n&&y.key===n.key)h(c,y,n,b,t(a,x+1,g),p,k),p&&y.tag===n.tag&&r(c,q(y),g),null!=y.dom&&(g=y.dom),x--;else{if(!B){B=a;var y=x,u={},w;for(w=0;w<
y;w++){var C=B[w];null!=C&&(C=C.key,null!=C&&(u[C]=w))}B=u}null!=n&&(y=B[n.key],null!=y?(u=a[y],h(c,u,n,b,t(a,x+1,g),p,k),r(c,q(u),g),a[y].skip=!0,null!=u.dom&&(g=u.dom)):(n=l(n,b,void 0),r(c,n,g),g=n))}A--;if(A<m)break}e(c,d,m,A+1,b,g,k);f(c,a,v,x+1,d)}}}function h(c,a,d,b,e,f,p){var m=a.tag;if(m===d.tag){d.state=a.state;d.events=a.events;var n;var t;null!=d.attrs&&"function"===typeof d.attrs.onbeforeupdate&&(n=d.attrs.onbeforeupdate.call(d.state,d,a));"string"!==typeof d.tag&&"function"===typeof d.tag.onbeforeupdate&&
(t=d.tag.onbeforeupdate.call(d.state,d,a));void 0===n&&void 0===t||n||t?n=!1:(d.dom=a.dom,d.domSize=a.domSize,d.instance=a.instance,n=!0);if(!n)if(null!=d.attrs&&w(d.attrs,d,b,f),"string"===typeof m)switch(m){case "#":a.children.toString()!==d.children.toString()&&(a.dom.nodeValue=d.children);d.dom=a.dom;break;case "<":a.children!==d.children?(q(a),r(c,g(d),e)):(d.dom=a.dom,d.domSize=a.domSize);break;case "[":k(c,a.children,d.children,b,e,p);a=0;b=d.children;d.dom=null;if(null!=b){for(var z=0;z<b.length;z++)c=
b[z],null!=c&&null!=c.dom&&(null==d.dom&&(d.dom=c.dom),a+=c.domSize||1);1!==a&&(d.domSize=a)}break;default:c=p;e=d.dom=a.dom;switch(d.tag){case "svg":c="http://www.w3.org/2000/svg";break;case "math":c="http://www.w3.org/1998/Math/MathML"}"textarea"===d.tag&&(null==d.attrs&&(d.attrs={}),null!=d.text&&(d.attrs.value=d.text));f=a.attrs;p=d.attrs;m=c;if(null!=p)for(z in p)B(d,z,f&&f[z],p[z],m);if(null!=f)for(z in f)null!=p&&z in p||("className"===z&&(z="class"),"o"!==z[0]||"n"!==z[1]||x(z)?"key"!==z&&
d.dom.removeAttribute(z):C(d,z,void 0));null!=a.text&&null!=d.text&&""!==d.text?a.text.toString()!==d.text.toString()&&(a.dom.firstChild.nodeValue=d.text):(null!=a.text&&(a.children=[u("#",void 0,void 0,a.text,void 0,a.dom.firstChild)]),null!=d.text&&(d.children=[u("#",void 0,void 0,d.text,void 0,void 0)]),k(e,a.children,d.children,b,null,c))}else d.instance=u.normalize(d.tag.view.call(d.state,d)),w(d.tag,d,b,f),null!=d.instance?(null==a.instance?r(c,l(d.instance,b,p),e):h(c,a.instance,d.instance,
b,e,f,p),d.dom=d.instance.dom,d.domSize=d.instance.domSize):null!=a.instance?(A(c,a.instance,null),d.dom=void 0,d.domSize=0):(d.dom=a.dom,d.domSize=a.domSize)}else A(c,a,null),r(c,l(d,b,void 0),e)}function q(c){var a=c.domSize;if(null!=a||null==c.dom){var d=n.createDocumentFragment();if(0<a){for(c=c.dom;--a;)d.appendChild(c.nextSibling);d.insertBefore(c,d.firstChild)}return d}return c.dom}function t(c,a,d){for(;a<c.length;a++)if(null!=c[a]&&null!=c[a].dom)return c[a].dom;return d}function r(c,a,d){d&&
d.parentNode?c.insertBefore(a,d):c.appendChild(a)}function f(c,a,d,b,e){for(;d<b;d++){var f=a[d];null!=f&&(f.skip?f.skip=!1:A(c,f,e))}}function p(c){var a=!1;return function(){a||(a=!0,c())}}function A(c,a,d){function b(){if(++f===e&&(m(a),a.dom)){var g=a.domSize||1;if(1<g)for(var h=a.dom;--g;)c.removeChild(h.nextSibling);null!=a.dom.parentNode&&c.removeChild(a.dom);if(g=null!=d&&null==a.domSize)g=a.attrs,g=!(null!=g&&(g.oncreate||g.onupdate||g.onbeforeremove||g.onremove));g&&"string"===typeof a.tag&&
(d.pool?d.pool.push(a):d.pool=[a])}}var e=1,f=0;a.attrs&&a.attrs.onbeforeremove&&(e++,a.attrs.onbeforeremove.call(a.state,a,p(b)));"string"!==typeof a.tag&&a.tag.onbeforeremove&&(e++,a.tag.onbeforeremove.call(a.state,a,p(b)));b()}function m(c){c.attrs&&c.attrs.onremove&&c.attrs.onremove.call(c.state,c);"string"!==typeof c.tag&&c.tag.onremove&&c.tag.onremove.call(c.state,c);if(null!=c.instance)m(c.instance);else if(c=c.children,c instanceof Array)for(var a=0;a<c.length;a++){var d=c[a];null!=d&&m(d)}}
function B(c,a,d,b,e){var f=c.dom;if("key"!==a&&(d!==b||"value"===a||"checked"===a||"selectedIndex"===a||"selected"===a&&c.dom===n.activeElement||"object"===typeof b)&&"undefined"!==typeof b&&!x(a)){var g=a.indexOf(":");if(-1<g&&"xlink"===a.substr(0,g))f.setAttributeNS("http://www.w3.org/1999/xlink",a.slice(g+1),b);else if("o"===a[0]&&"n"===a[1]&&"function"===typeof b)C(c,a,b);else if("style"===a)if(c=d,c===b&&(f.style.cssText="",c=null),null==b)f.style.cssText="";else if("string"===typeof b)f.style.cssText=
b;else{"string"===typeof c&&(f.style.cssText="");for(var h in b)f.style[h]=b[h];if(null!=c&&"string"!==typeof c)for(h in c)h in b||(f.style[h]="")}else if(a in f&&"href"!==a&&"list"!==a&&"form"!==a&&"width"!==a&&"height"!==a&&void 0===e){if("input"!==c.tag||"value"!==a||c.dom.value!==b||c.dom!==n.activeElement)f[a]=b}else"boolean"===typeof b?b?f.setAttribute(a,""):f.removeAttribute(a):f.setAttribute("className"===a?"class":a,b)}}function x(c){return"oninit"===c||"oncreate"===c||"onupdate"===c||"onremove"===
c||"onbeforeremove"===c||"onbeforeupdate"===c}function C(c,a,b){var e=c.dom,f=function(a){var c=b.call(e,a);"function"===typeof E&&E.call(e,a);return c};if(a in e)e[a]=f;else{var g=a.slice(2);void 0===c.events&&(c.events={});null!=c.events[a]&&e.removeEventListener(g,c.events[a],!1);"function"===typeof b&&(c.events[a]=f,e.addEventListener(g,c.events[a],!1))}}function z(c,a,b){"function"===typeof c.oninit&&c.oninit.call(a.state,a);"function"===typeof c.oncreate&&b.push(c.oncreate.bind(a.state,a))}
function w(c,a,b,e){e?z(c,a,b):"function"===typeof c.onupdate&&b.push(c.onupdate.bind(a.state,a))}function R(c,a){Object.keys(a).forEach(function(b){c[b]=a[b]})}var n=b.document,H=n.createDocumentFragment(),E;return{render:function(c,a){if(!c)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],e=n.activeElement;null==c.vnodes&&(c.textContent="");a instanceof Array||(a=[a]);k(c,c.vnodes,u.normalizeChildren(a),b,null,void 0);c.vnodes=a;for(var f=
0;f<b.length;f++)b[f]();n.activeElement!==e&&e.focus()},setEventCallback:function(c){return E=c}}}(window),S=function(b){var e=0,l=null,g="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(k){var h=Date.now();!0===k||0===e||16<=h-e?(e=h,b()):null===l&&(l=g(function(){l=null;b();e=Date.now()},16-(h-e)))}},T=function(b,e,l,g){g=S(g);null!=e&&e.setEventCallback(function(b){!1!==b.redraw&&l.publish()});null!=l&&(b.redraw&&l.unsubscribe(b.redraw),l.subscribe(g));
return b.redraw=g};w.mount=function(b,e){return function(l,g){null===g?(b.render(l,[]),e.unsubscribe(l.redraw),delete l.redraw):T(l,b,e,function(){b.render(l,u(g,void 0,void 0,void 0,void 0,void 0))})()}}(O,J);var K=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var e={},l={},g=0;g<b.length;g++){var k=b[g].split("="),h=decodeURIComponent(k[0]),k=2===k.length?decodeURIComponent(k[1]):"",q=Number(k);""!==k&&!isNaN(q)||"NaN"===k?k=q:"true"===k?k=!0:"false"===
k?k=!1:"/"!==k.charAt(0)&&(q=new Date(k),isNaN(q.getTime())||(k=q));var q=h.split(/\]\[?|\[/),t=e;-1<h.indexOf("[")&&q.pop();for(var r=0;r<q.length;r++){var h=q[r],f=q[r+1],f=""==f||!isNaN(parseInt(f,10)),p=r===q.length-1;""===h&&(h=q.slice(0,r).join(),null==l[h]&&(l[h]=0),h=l[h]++);null==t[h]&&(t[h]=p?k:f?[]:{});t=t[h]}}return e},U=function(b){function e(e){var f=b.location[e].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===e&&"/"!==f[0]&&(f="/"+f);return f}function l(b){return function(){null==
f&&(f=t(function(){f=null;b()}))}}function g(b,e,f){var g=b.indexOf("?"),h=b.indexOf("#"),k=-1<g?g:-1<h?h:b.length;if(-1<g){var g=K(b.slice(g+1,-1<h?h:b.length)),l;for(l in g)e[l]=g[l]}if(-1<h)for(l in e=K(b.slice(h+1)),e)f[l]=e[l];return b.slice(0,k)}function k(){switch(r.charAt(0)){case "#":return e("hash").slice(r.length);case "?":return e("search").slice(r.length)+e("hash");default:return e("pathname").slice(r.length)+e("search")+e("hash")}}function h(e,f,h){var k={},l={};e=g(e,k,l);if(null!=
f){for(var t in f)k[t]=f[t];e=e.replace(/:([^\/]+)/g,function(b,e){delete k[e];return f[e]})}(t=F(k))&&(e+="?"+t);(l=F(l))&&(e+="#"+l);q?(h&&h.replace?b.history.replaceState(null,null,r+e):b.history.pushState(null,null,r+e),b.onpopstate()):b.location.href=r+e}var q="function"===typeof b.history.pushState,t="function"===typeof setImmediate?setImmediate:setTimeout,r="#!",f;return{setPrefix:function(b){r=b},getPath:k,setPath:h,defineRoutes:function(e,f,h){function t(){var b=k(),l={},r=g(b,l,l),q;for(q in e){var u=
new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(u.test(r)){r.replace(u,function(){for(var g=q.match(/:[^\/]+/g)||[],h=[].slice.call(arguments,1,-2),k=0;k<g.length;k++)l[g[k].replace(/:|\./g,"")]=decodeURIComponent(h[k]);f(e[q],l,b,q)});return}}h(b,l)}q?b.onpopstate=l(t):"#"===r.charAt(0)&&(b.onhashchange=t);t();return t},link:function(b){b.dom.setAttribute("href",r+b.attrs.href);b.dom.onclick=function(e){e.preventDefault();e.redraw=!1;h(b.attrs.href,void 0,
void 0)}}}};w.route=function(b,e){function l(b){return b}var g=U(b),k,h,q,t,r,f={view:function(){return q(u(h,null,t,void 0,void 0,void 0))}},p=function(b,m,p){h="div";q=l;t=null;e(b,f);g.defineRoutes(p,function(e,f,g){var m="function"!==typeof e.view,p=l,n=k=function(l){n===k&&(k=null,h=null!=l?l:m?"div":e,q=p,t=f,r=g,b.redraw(!0))},u=function(){n()};m&&("function"===typeof e.render&&(p=e.render.bind(e)),"function"===typeof e.onmatch&&(u=e.onmatch));u.call(e,n,f,g)},function(){g.setPath(m,null,{replace:!0})})};
p.link=g.link;p.prefix=g.setPrefix;p.set=g.setPath;p.get=function(){return r};return p}(window,w.mount);w.withAttr=function(b,e,l){return function(g){return e.call(l||this,b in g.currentTarget?g.currentTarget[b]:g.currentTarget.getAttribute(b))}};w.prop=N;w.render=O.render;w.redraw=J.publish;w.request=I.request;w.jsonp=I.jsonp;w.parseQueryString=K;w.buildQueryString=F;w.version="1.0.0";"undefined"!==typeof module?module.exports=w:window.m=w};
new function(){function u(b,e,m,g,k,h){return{tag:b,key:e,attrs:m,children:g,text:k,dom:h,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function v(b){if(null==b||"string"!==typeof b&&null==b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b&&void 0===F[b]){for(var e,m,g=[],k={};e=O.exec(b);){var h=e[1],q=e[2];""===h&&""!==q?m=q:"#"===h?k.id=q:"."===h?g.push(q):"["===e[3][0]&&((h=e[6])&&(h=h.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),
k[e[4]]=h||!0)}0<g.length&&(k.className=g.join(" "));F[b]=function(b,f){var e=!1,h,g,q=b.className||b["class"],w;for(w in k)b[w]=k[w];void 0!==q&&(void 0!==b["class"]&&(b["class"]=void 0,b.className=q),void 0!==k.className&&(b.className=k.className+" "+q));for(w in b)if("key"!==w){e=!0;break}f instanceof Array&&1==f.length&&null!=f[0]&&"#"===f[0].tag?g=f[0].children:h=f;return u(m||"div",b.key,e?b:void 0,h,g,void 0)}}var t;null!=arguments[1]&&("object"!==typeof arguments[1]||void 0!==arguments[1].tag||
arguments[1]instanceof Array)?g=1:(t=arguments[1],g=2);if(arguments.length===g+1)e=arguments[g]instanceof Array?arguments[g]:[arguments[g]];else for(e=[];g<arguments.length;g++)e.push(arguments[g]);return"string"===typeof b?F[b](t||{},u.normalizeChildren(e)):u(b,t&&t.key,t||{},u.normalizeChildren(e),void 0,void 0)}u.normalize=function(b){return b instanceof Array?u("[",void 0,void 0,u.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?u("#",void 0,void 0,b,void 0,void 0):b};u.normalizeChildren=
function(b){for(var e=0;e<b.length;e++)b[e]=u.normalize(b[e]);return b};var O=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,F={};v.trust=function(b){return u("<",void 0,void 0,b,void 0,void 0)};v.fragment=function(b,e){return u("[",b.key,b,u.normalizeChildren(e),void 0,void 0)};var M=function(b){function e(){function a(){0<arguments.length&&arguments[0]!==z&&g(a,arguments[0],void 0);return a._state.value}m(a);0<arguments.length&&arguments[0]!==z&&g(a,arguments[0],
void 0);return a}function m(a){a.constructor=e;a._state={id:P++,value:void 0,error:void 0,state:0,derive:void 0,recover:void 0,deps:{},parents:[],errorStream:void 0,endStream:void 0};a.map=u;a.ap=v;a.of=e;a.valueOf=p;a.toJSON=G;a.toString=p;a.run=l;a["catch"]=A;Object.defineProperties(a,{error:{get:function(){if(!a._state.errorStream){var c=function(){0<arguments.length&&arguments[0]!==z&&g(a,void 0,arguments[0]);return a._state.error};m(c);w(c,[a],K,K);a._state.errorStream=c}return a._state.errorStream}},
end:{get:function(){if(!a._state.endStream){var c=e();c.map(function(d){!0===d&&(y(a),y(c));return d});a._state.endStream=c}return a._state.endStream}}})}function g(a,c,d){k(a,c,d);for(var f in a._state.deps)q(a._state.deps[f],!1);a._state.changed=!1;for(var b in a._state.deps)a._state.deps[b]._state.changed=!1}function k(a,c,d){d=r(c,d);if(void 0!==d&&"function"===typeof a._state.recover){if(!t(a,h,!0))return}else h(a,c,d);a._state.changed=!0;2!==a._state.state&&(a._state.state=1)}function h(a,c,
d){a._state.value=c;a._state.error=d}function q(d,f){var b=d._state.parents;0<b.length&&b.filter(c).length===b.length&&(f||0<b.filter(a).length)&&(b=b.filter(L),0<b.length?k(d,void 0,b[0]._state.error):t(d,k,!1))}function t(a,c,d){try{var b=d?a._state.recover():a._state.derive();if(b===z)return!1;c(a,b,void 0)}catch(e){c(a,void 0,null!=e.__error?e.__error:e),null==e.__error&&f(a,e)}return!0}function r(a,c){null!=a&&a.constructor===e&&(c=void 0!==a._state.error?a._state.error:r(a._state.value,a._state.error));
return c}function f(a,c){0===Object.keys(a._state.deps).length&&setTimeout(function(){0===Object.keys(a._state.deps).length&&b(c)},0)}function l(a){var c=e(),d=this;return w(c,[d],function(){return B(c,a(d()))},void 0)}function A(a){var c=e(),d=this;return w(c,[d],function(){return d._state.value},function(){return B(c,a(d._state.error))})}function n(c,d){if(d.length>d.filter(D).length)throw Error("Ensure that each item passed to m.prop.combine/m.prop.merge is a stream");return w(e(),d,function(){var b=
d.filter(L);if(0<b.length)throw{__error:b[0]._state.error};return c.apply(this,d.concat([d.filter(a)]))},void 0)}function B(a,c){if(null!=c&&c.constructor===e){var d=c,b=function(){k(a,d._state.value,d._state.error);for(var c in a._state.deps)q(a._state.deps[c],!1)};d.map(b)["catch"](function(a){b();throw{__error:a};});if(0===d._state.state)return z;if(d._state.error)throw{__error:d._state.error};c=d._state.value}return c}function w(a,c,b,f){var e=a._state;e.derive=b;e.recover=f;e.parents=c.filter(d);
C(a,e.parents);q(a,!0);return a}function C(a,c){for(var d=0;d<c.length;d++)c[d]._state.deps[a._state.id]=a,C(a,c[d]._state.parents)}function y(a){for(var c=0;c<a._state.parents.length;c++)delete a._state.parents[c]._state.deps[a._state.id];for(var d in a._state.deps){var c=a._state.deps[d],b=c._state.parents.indexOf(a);-1<b&&c._state.parents.splice(b,1)}a._state.state=2;a._state.deps={}}function u(a){return n(function(c){return a(c())},[this])}function v(a){return n(function(a,c){return a()(c())},
[this,a])}function p(){return this._state.value}function G(){return null!=this._state.value&&"function"===typeof this._state.value.toJSON?this._state.value.toJSON():this._state.value}function D(a){return a._state}function c(a){return 1===a._state.state}function a(a){return a._state.changed}function d(a){return 2!==a._state.state}function L(a){return a._state.error}var P=0,K=function(){},z={};e.merge=function(a){return n(function(){return a.map(function(a){return a()})},a)};e.combine=n;e.reject=function(a){var c=
e();c.error(a);return c};e.HALT=z;return e}(console.log.bind(console)),E=function(b){function e(b,h){if(h instanceof Array)for(var g=0;g<h.length;g++)e(b+"["+g+"]",h[g]);else if("[object Object]"===Object.prototype.toString.call(h))for(g in h)e(b+"["+g+"]",h[g]);else m.push(encodeURIComponent(b)+(null!=h&&""!==h?"="+encodeURIComponent(h):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var m=[],g;for(g in b)e(g,b[g]);return m.join("&")},H=function(b,e){function m(b,e){if(null==
e)return b;for(var g=b.match(/:[^\/]+/gi)||[],h=0;h<g.length;h++){var k=g[h].slice(1);null!=e[k]&&(b=b.replace(g[h],e[k]),delete e[k])}return b}function g(b,e){var g=E(e);if(""!==g){var h=0>b.indexOf("?")?"?":"&";b+=h+g}return b}function k(b){try{return""!==b?JSON.parse(b):null}catch(e){throw Error(b);}}function h(b){return b.responseText}function q(b,e){if("function"===typeof b)if(e instanceof Array)for(var g=0;g<e.length;g++)e[g]=new b(e[g]);else return new b(e);return e}var t=0,r;return{request:function(f){var l=
e();void 0!==f.initialValue&&l(f.initialValue);var A="boolean"===typeof f.useBody?f.useBody:"GET"!==f.method&&"TRACE"!==f.method;"function"!==typeof f.serialize&&(f.serialize="undefined"!==typeof FormData&&f.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof f.deserialize&&(f.deserialize=k);"function"!==typeof f.extract&&(f.extract=h);f.url=m(f.url,f.data);A?f.data=f.serialize(f.data):f.url=g(f.url,f.data);var n=new b.XMLHttpRequest;n.open(f.method,f.url,"boolean"===
typeof f.async?f.async:!0,"string"===typeof f.user?f.user:void 0,"string"===typeof f.password?f.password:void 0);f.serialize===JSON.stringify&&A&&n.setRequestHeader("Content-Type","application/json; charset=utf-8");f.deserialize===k&&n.setRequestHeader("Accept","application/json, text/*");"function"===typeof f.config&&(n=f.config(n,f)||n);n.onreadystatechange=function(){if(4===n.readyState){try{var b=f.extract!==h?f.extract(n,f):f.deserialize(f.extract(n,f));if(200<=n.status&&300>n.status||304===
n.status)l(q(f.type,b));else{var e=Error(n.responseText),g;for(g in b)e[g]=b[g];l.error(e)}}catch(k){l.error(k)}"function"===typeof r&&r()}};A?n.send(f.data):n.send();return l},jsonp:function(f){var h=e();void 0!==f.initialValue&&h(f.initialValue);var k=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+t++,n=b.document.createElement("script");b[k]=function(e){n.parentNode.removeChild(n);h(q(f.type,e));"function"===typeof r&&r();delete b[k]};n.onerror=function(){n.parentNode.removeChild(n);
h.error(Error("JSONP request failed"));"function"===typeof r&&r();delete b[k]};null==f.data&&(f.data={});f.url=m(f.url,f.data);f.data[f.callbackKey||"callback"]=k;n.src=g(f.url,f.data);b.document.documentElement.appendChild(n);return h},setCompletionCallback:function(b){r=b}}}(window,M),I=function(){var b=[];return{subscribe:b.push.bind(b),unsubscribe:function(e){e=b.indexOf(e);-1<e&&b.splice(e,1)},publish:function(){for(var e=0;e<b.length;e++)b[e].apply(this,arguments)}}}();H.setCompletionCallback(I.publish);
var N=function(b){function e(c,a,d,b,e,f,g){for(;d<b;d++){var h=a[d];null!=h&&r(c,m(h,e,g),f)}}function m(c,a,d){var b=c.tag;null!=c.attrs&&y(c.attrs,c,a);if("string"===typeof b)switch(b){case "#":return c.dom=p.createTextNode(c.children);case "<":return g(c);case "[":var f=p.createDocumentFragment();null!=c.children&&(b=c.children,e(f,b,0,b.length,a,null,d));c.dom=f.firstChild;c.domSize=f.childNodes.length;return f;default:var h=c.tag;switch(c.tag){case "svg":d="http://www.w3.org/2000/svg";break;
case "math":d="http://www.w3.org/1998/Math/MathML"}var k=(b=c.attrs)&&b.is,h=d?k?p.createElementNS(d,h,{is:k}):p.createElementNS(d,h):k?p.createElement(h,{is:k}):p.createElement(h);c.dom=h;if(null!=b)for(f in k=d,b)B(c,f,null,b[f],k);null!=c.text&&(""!==c.text?h.textContent=c.text:c.children=[u("#",void 0,void 0,c.text,void 0,void 0)]);null!=c.children&&(f=c.children,e(h,f,0,f.length,a,null,d),a=c.attrs,"select"===c.tag&&null!=a&&("value"in a&&B(c,"value",null,a.value,void 0),"selectedIndex"in a&&
B(c,"selectedIndex",null,a.selectedIndex,void 0)));return h}else{c.state||(c.state={});Q(c.state,c.tag);y(c.tag,c,a);c.instance=u.normalize(c.tag.view.call(c.state,c));if(null!=c.instance){if(c.instance===c)throw Error("A view cannot return the vnode it received as arguments");a=m(c.instance,a,d);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;c=a}else c.domSize=0,c=G;return c}}function g(c){var a={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",a=p.createElement(a);a.innerHTML=c.children;c.dom=a.firstChild;c.domSize=a.childNodes.length;c=p.createDocumentFragment();for(var d;d=a.firstChild;)c.appendChild(d);return c}function k(c,a,d,b,g,k){if(a!==d&&(null!=a||null!=d))if(null==a)e(c,d,0,d.length,b,g,void 0);else if(null==d)f(c,a,0,a.length,d);else{var z;a:{if(null!=a.pool&&Math.abs(a.pool.length-d.length)<=Math.abs(a.length-d.length)&&(z=d[0]&&d[0].children&&
d[0].children.length||0,Math.abs((a.pool[0]&&a.pool[0].children&&a.pool[0].children.length||0)-z)<=Math.abs((a[0]&&a[0].children&&a[0].children.length||0)-z))){z=!0;break a}z=!1}z&&(a=a.concat(a.pool));if(a.length===d.length&&null!=d[0]&&null==d[0].key)for(var l=0;l<a.length;l++)a[l]===d[l]||null==a[l]&&null==d[l]||(null==a[l]?r(c,m(d[l],b,k),t(a,l+1,g)):null==d[l]?f(c,a,l,l+1,d):h(c,a[l],d[l],b,t(a,l+1,g),z,k),z&&a[l].tag===d[l].tag&&r(c,q(a[l]),t(a,l+1,g)));else{for(var n=l=0,w=a.length-1,A=d.length-
1,B;w>=l&&A>=n;){var x=a[l],p=d[n];if(x===p)l++,n++;else if(null!=x&&null!=p&&x.key===p.key)l++,n++,h(c,x,p,b,t(a,l,g),z,k),z&&x.tag===p.tag&&r(c,q(x),g);else if(x=a[w],x===p)w--,n++;else if(null!=x&&null!=p&&x.key===p.key)h(c,x,p,b,t(a,w+1,g),z,k),n<A&&r(c,q(x),t(a,l,g)),w--,n++;else break}for(;w>=l&&A>=n;){x=a[w];p=d[A];if(x===p)w--;else if(null!=x&&null!=p&&x.key===p.key)h(c,x,p,b,t(a,w+1,g),z,k),z&&x.tag===p.tag&&r(c,q(x),g),null!=x.dom&&(g=x.dom),w--;else{if(!B){B=a;var x=w,u={},v;for(v=0;v<
x;v++){var C=B[v];null!=C&&(C=C.key,null!=C&&(u[C]=v))}B=u}null!=p&&(x=B[p.key],null!=x?(u=a[x],h(c,u,p,b,t(a,w+1,g),z,k),r(c,q(u),g),a[x].skip=!0,null!=u.dom&&(g=u.dom)):(p=m(p,b,void 0),r(c,p,g),g=p))}A--;if(A<n)break}e(c,d,n,A+1,b,g,k);f(c,a,l,w+1,d)}}}function h(c,a,d,b,e,f,l){var n=a.tag;if(n===d.tag){d.state=a.state;d.events=a.events;var p;var t;null!=d.attrs&&"function"===typeof d.attrs.onbeforeupdate&&(p=d.attrs.onbeforeupdate.call(d.state,d,a));"string"!==typeof d.tag&&"function"===typeof d.tag.onbeforeupdate&&
(t=d.tag.onbeforeupdate.call(d.state,d,a));void 0===p&&void 0===t||p||t?p=!1:(d.dom=a.dom,d.domSize=a.domSize,d.instance=a.instance,p=!0);if(!p)if(null!=d.attrs&&v(d.attrs,d,b,f),"string"===typeof n)switch(n){case "#":a.children.toString()!==d.children.toString()&&(a.dom.nodeValue=d.children);d.dom=a.dom;break;case "<":a.children!==d.children?(q(a),r(c,g(d),e)):(d.dom=a.dom,d.domSize=a.domSize);break;case "[":k(c,a.children,d.children,b,e,l);a=0;b=d.children;d.dom=null;if(null!=b){for(var y=0;y<b.length;y++)c=
b[y],null!=c&&null!=c.dom&&(null==d.dom&&(d.dom=c.dom),a+=c.domSize||1);1!==a&&(d.domSize=a)}break;default:c=l;e=d.dom=a.dom;switch(d.tag){case "svg":c="http://www.w3.org/2000/svg";break;case "math":c="http://www.w3.org/1998/Math/MathML"}"textarea"===d.tag&&(null==d.attrs&&(d.attrs={}),null!=d.text&&(d.attrs.value=d.text));f=a.attrs;l=d.attrs;n=c;if(null!=l)for(y in l)B(d,y,f&&f[y],l[y],n);if(null!=f)for(y in f)null!=l&&y in l||("className"===y&&(y="class"),"o"!==y[0]||"n"!==y[1]||w(y)?"key"!==y&&
d.dom.removeAttribute(y):C(d,y,void 0));null!=a.text&&null!=d.text&&""!==d.text?a.text.toString()!==d.text.toString()&&(a.dom.firstChild.nodeValue=d.text):(null!=a.text&&(a.children=[u("#",void 0,void 0,a.text,void 0,a.dom.firstChild)]),null!=d.text&&(d.children=[u("#",void 0,void 0,d.text,void 0,void 0)]),k(e,a.children,d.children,b,null,c))}else d.instance=u.normalize(d.tag.view.call(d.state,d)),v(d.tag,d,b,f),null!=d.instance?(null==a.instance?r(c,m(d.instance,b,l),e):h(c,a.instance,d.instance,
b,e,f,l),d.dom=d.instance.dom,d.domSize=d.instance.domSize):null!=a.instance?(A(c,a.instance,null),d.dom=void 0,d.domSize=0):(d.dom=a.dom,d.domSize=a.domSize)}else A(c,a,null),r(c,m(d,b,void 0),e)}function q(c){var a=c.domSize;if(null!=a||null==c.dom){var d=p.createDocumentFragment();if(0<a){for(c=c.dom;--a;)d.appendChild(c.nextSibling);d.insertBefore(c,d.firstChild)}return d}return c.dom}function t(c,a,d){for(;a<c.length;a++)if(null!=c[a]&&null!=c[a].dom)return c[a].dom;return d}function r(c,a,d){d&&
d.parentNode?c.insertBefore(a,d):c.appendChild(a)}function f(c,a,d,b,e){for(;d<b;d++){var f=a[d];null!=f&&(f.skip?f.skip=!1:A(c,f,e))}}function l(c){var a=!1;return function(){a||(a=!0,c())}}function A(c,a,d){function b(){if(++f===e&&(n(a),a.dom)){var g=a.domSize||1;if(1<g)for(var l=a.dom;--g;)c.removeChild(l.nextSibling);null!=a.dom.parentNode&&c.removeChild(a.dom);if(g=null!=d&&null==a.domSize)g=a.attrs,g=!(null!=g&&(g.oncreate||g.onupdate||g.onbeforeremove||g.onremove));g&&"string"===typeof a.tag&&
(d.pool?d.pool.push(a):d.pool=[a])}}var e=1,f=0;a.attrs&&a.attrs.onbeforeremove&&(e++,a.attrs.onbeforeremove.call(a.state,a,l(b)));"string"!==typeof a.tag&&a.tag.onbeforeremove&&(e++,a.tag.onbeforeremove.call(a.state,a,l(b)));b()}function n(c){c.attrs&&c.attrs.onremove&&c.attrs.onremove.call(c.state,c);"string"!==typeof c.tag&&c.tag.onremove&&c.tag.onremove.call(c.state,c);if(null!=c.instance)n(c.instance);else if(c=c.children,c instanceof Array)for(var a=0;a<c.length;a++){var d=c[a];null!=d&&n(d)}}
function B(c,a,d,b,e){var f=c.dom;if("key"!==a&&(d!==b||"value"===a||"checked"===a||"selectedIndex"===a||"selected"===a&&c.dom===p.activeElement||"object"===typeof b)&&"undefined"!==typeof b&&!w(a)){var g=a.indexOf(":");if(-1<g&&"xlink"===a.substr(0,g))f.setAttributeNS("http://www.w3.org/1999/xlink",a.slice(g+1),b);else if("o"===a[0]&&"n"===a[1]&&"function"===typeof b)C(c,a,b);else if("style"===a)if(c=d,c===b&&(f.style.cssText="",c=null),null==b)f.style.cssText="";else if("string"===typeof b)f.style.cssText=
b;else{"string"===typeof c&&(f.style.cssText="");for(var l in b)f.style[l]=b[l];if(null!=c&&"string"!==typeof c)for(l in c)l in b||(f.style[l]="")}else if(a in f&&"href"!==a&&"list"!==a&&"form"!==a&&"width"!==a&&"height"!==a&&void 0===e){if("input"!==c.tag||"value"!==a||c.dom.value!==b||c.dom!==p.activeElement)f[a]=b}else"boolean"===typeof b?b?f.setAttribute(a,""):f.removeAttribute(a):f.setAttribute("className"===a?"class":a,b)}}function w(c){return"oninit"===c||"oncreate"===c||"onupdate"===c||"onremove"===
c||"onbeforeremove"===c||"onbeforeupdate"===c}function C(c,a,b){var e=c.dom,f=function(a){console.log(111,c);var f=b.call(e,a,c);"function"===typeof D&&D.call(e,a,c);return f};if(a in e)e[a]=f;else{var g=a.slice(2);void 0===c.events&&(c.events={});null!=c.events[a]&&e.removeEventListener(g,c.events[a],!1);"function"===typeof b&&(c.events[a]=f,e.addEventListener(g,c.events[a],!1))}}function y(c,a,b){"function"===typeof c.oninit&&c.oninit.call(a.state,a);"function"===typeof c.oncreate&&b.push(c.oncreate.bind(a.state,
a))}function v(c,a,b,e){e?y(c,a,b):"function"===typeof c.onupdate&&b.push(c.onupdate.bind(a.state,a))}function Q(c,a){Object.keys(a).forEach(function(b){c[b]=a[b]})}var p=b.document,G=p.createDocumentFragment(),D;return{render:function(c,a){if(!c)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],e=p.activeElement;null==c.vnodes&&(c.textContent="");a instanceof Array||(a=[a]);k(c,c.vnodes,u.normalizeChildren(a),b,null,void 0);c.vnodes=a;for(var f=
0;f<b.length;f++)b[f]();p.activeElement!==e&&e.focus()},setEventCallback:function(c){return D=c}}}(window),R=function(b){var e=0,m=null,g="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(k){var h=Date.now();!0===k||0===e||16<=h-e?(e=h,b()):null===m&&(m=g(function(){m=null;b();e=Date.now()},16-(h-e)))}},S=function(b,e,m,g){g=R(g);null!=e&&e.setEventCallback(function(b){!1!==b.redraw&&m.publish()});null!=m&&(b.redraw&&m.unsubscribe(b.redraw),m.subscribe(g));
return b.redraw=g};v.mount=function(b,e){return function(m,g){null===g?(b.render(m,[]),e.unsubscribe(m.redraw),delete m.redraw):S(m,b,e,function(){b.render(m,u(g,void 0,void 0,void 0,void 0,void 0))})()}}(N,I);var J=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var e={},m={},g=0;g<b.length;g++){var k=b[g].split("="),h=decodeURIComponent(k[0]),k=2===k.length?decodeURIComponent(k[1]):"",q=Number(k);""!==k&&!isNaN(q)||"NaN"===k?k=q:"true"===k?k=!0:"false"===
k?k=!1:"/"!==k.charAt(0)&&(q=new Date(k),isNaN(q.getTime())||(k=q));var q=h.split(/\]\[?|\[/),t=e;-1<h.indexOf("[")&&q.pop();for(var r=0;r<q.length;r++){var h=q[r],f=q[r+1],f=""==f||!isNaN(parseInt(f,10)),l=r===q.length-1;""===h&&(h=q.slice(0,r).join(),null==m[h]&&(m[h]=0),h=m[h]++);null==t[h]&&(t[h]=l?k:f?[]:{});t=t[h]}}return e},T=function(b){function e(e){var f=b.location[e].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===e&&"/"!==f[0]&&(f="/"+f);return f}function m(b){return function(){null==
f&&(f=t(function(){f=null;b()}))}}function g(b,e,f){var g=b.indexOf("?"),h=b.indexOf("#"),k=-1<g?g:-1<h?h:b.length;if(-1<g){var g=J(b.slice(g+1,-1<h?h:b.length)),m;for(m in g)e[m]=g[m]}if(-1<h)for(m in e=J(b.slice(h+1)),e)f[m]=e[m];return b.slice(0,k)}function k(){switch(r.charAt(0)){case "#":return e("hash").slice(r.length);case "?":return e("search").slice(r.length)+e("hash");default:return e("pathname").slice(r.length)+e("search")+e("hash")}}function h(e,f,h){var k={},m={};e=g(e,k,m);if(null!=
f){for(var t in f)k[t]=f[t];e=e.replace(/:([^\/]+)/g,function(b,e){delete k[e];return f[e]})}(t=E(k))&&(e+="?"+t);(m=E(m))&&(e+="#"+m);q?(h&&h.replace?b.history.replaceState(null,null,r+e):b.history.pushState(null,null,r+e),b.onpopstate()):b.location.href=r+e}var q="function"===typeof b.history.pushState,t="function"===typeof setImmediate?setImmediate:setTimeout,r="#!",f;return{setPrefix:function(b){r=b},getPath:k,setPath:h,defineRoutes:function(e,f,h){function t(){var b=k(),m={},r=g(b,m,m),q;for(q in e){var u=
new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(u.test(r)){r.replace(u,function(){for(var g=q.match(/:[^\/]+/g)||[],h=[].slice.call(arguments,1,-2),k=0;k<g.length;k++)m[g[k].replace(/:|\./g,"")]=decodeURIComponent(h[k]);f(e[q],m,b,q)});return}}h(b,m)}q?b.onpopstate=m(t):"#"===r.charAt(0)&&(b.onhashchange=t);t();return t},link:function(b){b.dom.setAttribute("href",r+b.attrs.href);b.dom.onclick=function(b,e){b.preventDefault();b.redraw=!1;console.log(e);
h(e.attrs.href,void 0,void 0)}}}};v.route=function(b,e){function m(b){return b}var g=T(b),k,h,q,t,r,f={view:function(){return q(u(h,null,t,void 0,void 0,void 0))}},l=function(b,l,u){h="div";q=m;t=null;e(b,f);g.defineRoutes(u,function(e,f,g){var l="function"!==typeof e.view,n=m,p=k=function(m){p===k&&(k=null,h=null!=m?m:l?"div":e,q=n,t=f,r=g,b.redraw(!0))},u=function(){p()};l&&("function"===typeof e.render&&(n=e.render.bind(e)),"function"===typeof e.onmatch&&(u=e.onmatch));u.call(e,p,f,g)},function(){g.setPath(l,
null,{replace:!0})})};l.link=g.link;l.prefix=g.setPrefix;l.set=g.setPath;l.get=function(){return r};return l}(window,v.mount);v.withAttr=function(b,e,m){return function(g){return e.call(m||this,b in g.currentTarget?g.currentTarget[b]:g.currentTarget.getAttribute(b))}};v.prop=M;v.render=N.render;v.redraw=I.publish;v.request=H.request;v.jsonp=H.jsonp;v.parseQueryString=J;v.buildQueryString=E;v.version="1.0.0";"undefined"!==typeof module?module.exports=v:window.m=v};