forked from MithrilJS/mithril.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mithril.min.js
43 lines (43 loc) · 21.2 KB
/
mithril.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
new function(){function x(b,d,l,e,g,k){return{tag:b,key:d,attrs:l,children:e,text:g,dom:k,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function B(b){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&&void 0===I[b]){for(var d,l,e=[],g={};d=O.exec(b);){var k=d[1],h=d[2];""===k&&""!==h?l=h:"#"===k?g.id=h:"."===k?e.push(h):"["===d[3][0]&&((k=d[6])&&(k=k.replace(/\\(["'])/g,
"$1").replace(/\\\\/g,"\\")),"class"===d[4]?e.push(k):g[d[4]]=k||!0)}0<e.length&&(g.className=e.join(" "));I[b]=function(b,d){var e=!1,a,k,n=b.className||b["class"],y;for(y in g)b[y]=g[y];void 0!==n&&(void 0!==b["class"]&&(b["class"]=void 0,b.className=n),void 0!==g.className&&(b.className=g.className+" "+n));for(y in b)if("key"!==y){e=!0;break}Array.isArray(d)&&1==d.length&&null!=d[0]&&"#"===d[0].tag?k=d[0].children:a=d;return x(l||"div",b.key,e?b:void 0,a,k,void 0)}}var r;null==arguments[1]||"object"===
typeof arguments[1]&&void 0===arguments[1].tag&&!Array.isArray(arguments[1])?(r=arguments[1],e=2):e=1;if(arguments.length===e+1)d=Array.isArray(arguments[e])?arguments[e]:[arguments[e]];else for(d=[];e<arguments.length;e++)d.push(arguments[e]);return"string"===typeof b?I[b](r||{},x.normalizeChildren(d)):x(b,r&&r.key,r||{},x.normalizeChildren(d),void 0,void 0)}function P(b){var d=0,l=null,e="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var g=Date.now();
0===d||16<=g-d?(d=g,b()):null===l&&(l=e(function(){l=null;b();d=Date.now()},16-(g-d)))}}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 O=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,I={};B.trust=function(b){null==b&&(b="");return x("<",
void 0,void 0,b,void 0,void 0)};B.fragment=function(b,d){return x("[",b.key,b,x.normalizeChildren(d),void 0,void 0)};var A=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);g.length=0;k.length=0;n.state=a;n.retry=function(){t(d)}});else{if(d===e)throw new TypeError("Promise can't be resolved w/ itself");
l(h.bind(d))}}catch(Q){r(Q)}}}function l(b){function a(a){return function(b){0<d++||a(b)}}var d=0,e=a(r);try{b(a(h),e)}catch(y){e(y)}}if(!(this instanceof A))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var e=this,g=[],k=[],h=d(g,!0),r=d(k,!1),n=e._instance={resolvers:g,rejectors:k},m="function"===typeof setImmediate?setImmediate:setTimeout;l(b)};A.prototype.then=function(b,d){function l(b,d,l,h){d.push(function(a){if("function"!==
typeof b)l(a);else try{g(b(a))}catch(w){k&&k(w)}});"function"===typeof e.retry&&h===e.state&&e.retry()}var e=this._instance,g,k,h=new A(function(b,d){g=b;k=d});l(b,e.resolvers,g,!0);l(d,e.rejectors,k,!1);return h};A.prototype["catch"]=function(b){return this.then(null,b)};A.resolve=function(b){return b instanceof A?b:new A(function(d){d(b)})};A.reject=function(b){return new A(function(d,l){l(b)})};A.all=function(b){return new A(function(d,l){var e=b.length,g=0,k=[];if(0===b.length)d([]);else for(var h=
0;h<b.length;h++)(function(h){function n(b){g++;k[h]=b;g===e&&d(k)}null==b[h]||"object"!==typeof b[h]&&"function"!==typeof b[h]||"function"!==typeof b[h].then?n(b[h]):b[h].then(n,l)})(h)})};A.race=function(b){return new A(function(d,l){for(var e=0;e<b.length;e++)b[e].then(d,l)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=A),A=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=A),A=global.Promise);var F=function(b){function d(b,
e){if(Array.isArray(e))for(var g=0;g<e.length;g++)d(b+"["+g+"]",e[g]);else if("[object Object]"===Object.prototype.toString.call(e))for(g in e)d(b+"["+g+"]",e[g]);else l.push(encodeURIComponent(b)+(null!=e&&""!==e?"="+encodeURIComponent(e):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var l=[],e;for(e in b)d(e,b[e]);return l.join("&")},R=/^file:\/\//i,L=function(b,d){function l(){function a(){0===--b&&"function"===typeof v&&v()}var b=0;return function y(d){var e=d.then;d.then=
function(){b++;var g=e.apply(d,arguments);g.then(a,function(d){a();if(0===b)throw d;});return y(g)};return d}}function e(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function g(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var g=d[e].slice(1);null!=b[g]&&(a=a.replace(d[e],b[g]))}return a}function k(a,b){var d=F(b);if(""!==d){var e=0>a.indexOf("?")?"?":"&";a+=e+d}return a}function h(a){try{return""!==a?JSON.parse(a):null}catch(w){throw Error(a);
}}function r(a){return a.responseText}function n(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,v;return{request:function(a,m){var v=l();a=e(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(f){return f}:JSON.stringify);"function"!==typeof a.deserialize&&(a.deserialize=h);"function"!==typeof a.extract&&(a.extract=r);a.url=g(a.url,a.data);l?a.data=a.serialize(a.data):a.url=k(a.url,a.data);var m=new b.XMLHttpRequest,v=!1,y=m.abort;m.abort=function(){v=!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&&m.setRequestHeader("Content-Type",
"application/json; charset=utf-8");a.deserialize===h&&m.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(m.withCredentials=a.withCredentials);for(var w in a.headers)({}).hasOwnProperty.call(a.headers,w)&&m.setRequestHeader(w,a.headers[w]);"function"===typeof a.config&&(m=a.config(m,a)||m);m.onreadystatechange=function(){if(!v&&4===m.readyState)try{var f=a.extract!==r?a.extract(m,a):a.deserialize(a.extract(m,a));if(200<=m.status&&300>m.status||304===m.status||R.test(a.url))d(n(a.type,
f));else{var c=Error(m.responseText),q;for(q in f)c[q]=f[q];e(c)}}catch(p){e(p)}};l&&null!=a.data?m.send(a.data):m.send()});return!0===a.background?y:v(y)},jsonp:function(a,h){var v=l();a=e(a,h);var r=new d(function(d,e){var l=a.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,h=b.document.createElement("script");b[l]=function(e){h.parentNode.removeChild(h);d(n(a.type,e));delete b[l]};h.onerror=function(){h.parentNode.removeChild(h);e(Error("JSONP request failed"));delete b[l]};null==
a.data&&(a.data={});a.url=g(a.url,a.data);a.data[a.callbackKey||"callback"]=l;h.src=k(a.url,a.data);b.document.documentElement.appendChild(h)});return!0===a.background?r:v(r)},setCompletionCallback:function(b){v=b}}}(window,A),N=function(b){function d(f,c,q,b,a,d,e){for(;q<b;q++){var p=c[q];null!=p&&l(f,p,a,e,d)}}function l(f,c,q,b,a){var p=c.tag;if("string"===typeof p)switch(null!=c.attrs&&B(c.attrs,c,q),p){case "#":return c.dom=C.createTextNode(c.children),m(f,c.dom,a),c.dom;case "<":return e(f,
c,a);case "[":var h=C.createDocumentFragment();null!=c.children&&(p=c.children,d(h,p,0,p.length,q,null,b));c.dom=h.firstChild;c.domSize=h.childNodes.length;m(f,h,a);return h;default:var n=c.tag;switch(c.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}var k=(p=c.attrs)&&p.is,n=b?k?C.createElementNS(b,n,{is:k}):C.createElementNS(b,n):k?C.createElement(n,{is:k}):C.createElement(n);c.dom=n;if(null!=p)for(h in k=b,p)y(c,h,null,p[h],k);m(f,n,a);null!=
c.attrs&&null!=c.attrs.contenteditable?v(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&&(f=c.children,d(n,f,0,f.length,q,null,b),f=c.attrs,"select"===c.tag&&null!=f&&("value"in f&&y(c,"value",null,f.value,void 0),"selectedIndex"in f&&y(c,"selectedIndex",null,f.selectedIndex,void 0))));return n}else{g(c,q);if(null!=c.instance){if(c.instance===c)throw Error("A view cannot return the vnode it received as arguments");q=l(f,
c.instance,q,b,a);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;m(f,q,a);c=q}else c.domSize=0,c=K;return c}}function e(f,c,b){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=C.createElement(q);q.innerHTML=c.children;c.dom=q.firstChild;c.domSize=q.childNodes.length;c=C.createDocumentFragment();for(var a;a=q.firstChild;)c.appendChild(a);m(f,c,b);return c}
function g(f,c){var b;if("function"===typeof f.tag){f.state=null;b=f.tag;if(null!=b.$$reentrantLock$$)return K;b.$$reentrantLock$$=!0;f.state=null!=f.tag.prototype&&"function"===typeof f.tag.prototype.view?new f.tag(f):f.tag(f)}else{f.state=Object.create(f.tag);b=f.state.view;if(null!=b.$$reentrantLock$$)return K;b.$$reentrantLock$$=!0}null!=f.attrs&&B(f.attrs,f,c);B(f.state,f,c);f.instance=x.normalize(f.state.view(f));b.$$reentrantLock$$=null}function k(f,c,b,e,g,k,v){if(c!==b&&(null!=c||null!=b))if(null==
c)d(f,b,0,b.length,g,k,void 0);else if(null==b)a(c,0,c.length,b);else{if(c.length===b.length){for(var q=!1,p=0;p<b.length;p++)if(null!=b[p]&&null!=c[p]){q=null==b[p].key&&null==c[p].key;break}if(q){for(p=0;p<c.length;p++)c[p]!==b[p]&&(null==c[p]&&null!=b[p]?l(f,b[p],g,v,n(c,p+1,k)):null==b[p]?a(c,p,p+1,b):h(f,c[p],b[p],g,n(c,p+1,k),e,v));return}}if(!e)a:{if(null!=c.pool&&Math.abs(c.pool.length-b.length)<=Math.abs(c.length-b.length)&&(e=b[0]&&b[0].children&&b[0].children.length||0,Math.abs((c.pool[0]&&
c.pool[0].children&&c.pool[0].children.length||0)-e)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-e))){e=!0;break a}e=!1}if(e){var D=c.pool;c=c.concat(c.pool)}for(var p=q=0,w=c.length-1,y=b.length-1,G;w>=q&&y>=p;){var z=c[q],t=b[p];if(z!==t||e)if(null==z)q++;else if(null==t)p++;else if(z.key===t.key){var u=null!=D&&q>=c.length-D.length||null==D&&e;q++;p++;h(f,z,t,g,n(c,q,k),u,v);e&&z.tag===t.tag&&m(f,r(z),k)}else if(z=c[w],z!==t||e)if(null==z)w--;else if(null==t)p++;else if(z.key===t.key)u=
null!=D&&w>=c.length-D.length||null==D&&e,h(f,z,t,g,n(c,w+1,k),u,v),(e||p<y)&&m(f,r(z),n(c,q,k)),w--,p++;else break;else w--,p++;else q++,p++}for(;w>=q&&y>=p;){z=c[w];t=b[y];if(z!==t||e)if(null==z)w--;else{if(null!=t)if(z.key===t.key)u=null!=D&&w>=c.length-D.length||null==D&&e,h(f,z,t,g,n(c,w+1,k),u,v),e&&z.tag===t.tag&&m(f,r(z),k),null!=z.dom&&(k=z.dom),w--;else{if(!G){G=c;var z=w,u={},x;for(x=0;x<z;x++){var E=G[x];null!=E&&(E=E.key,null!=E&&(u[E]=x))}G=u}null!=t&&(z=G[t.key],null!=z?(u=c[z],h(f,
u,t,g,n(c,w+1,k),e,v),m(f,r(u),k),c[z].skip=!0,null!=u.dom&&(k=u.dom)):k=l(f,t,g,void 0,k))}y--}else w--,y--;if(y<p)break}d(f,b,p,y+1,g,k,v);a(c,q,w+1,b)}}function h(b,c,a,d,n,m,t){var f=c.tag;if(f===a.tag){a.state=c.state;a.events=c.events;var p;if(p=!m){var q,D;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&&(q=a.attrs.onbeforeupdate.call(a.state,a,c));"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeupdate&&(D=a.state.onbeforeupdate(a,c));void 0===q&&void 0===D||q||D?p=!1:
(a.dom=c.dom,a.domSize=c.domSize,a.instance=c.instance,p=!0)}if(!p)if("string"===typeof f)switch(null!=a.attrs&&(m?B(a.attrs,a,d):J(a.attrs,a,d)),f){case "#":c.children.toString()!==a.children.toString()&&(c.dom.nodeValue=a.children);a.dom=c.dom;break;case "<":c.children!==a.children?(r(c),e(b,a,n)):(a.dom=c.dom,a.domSize=c.domSize);break;case "[":k(b,c.children,a.children,m,d,n,t);c=0;d=a.children;a.dom=null;if(null!=d){for(m=0;m<d.length;m++){var u=d[m];null!=u&&null!=u.dom&&(null==a.dom&&(a.dom=
u.dom),c+=u.domSize||1)}1!==c&&(a.domSize=c)}break;default:b=t;n=a.dom=c.dom;switch(a.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));t=c.attrs;f=a.attrs;p=b;if(null!=f)for(u in f)y(a,u,t&&t[u],f[u],p);if(null!=t)for(u in t)null!=f&&u in f||("className"===u&&(u="class"),"o"!==u[0]||"n"!==u[1]||E(u)?"key"!==u&&a.dom.removeAttribute(u):A(a,u,void 0));
null!=a.attrs&&null!=a.attrs.contenteditable?v(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=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=a.text&&(a.children=[x("#",void 0,void 0,a.text,void 0,void 0)]),k(n,c.children,a.children,m,d,null,b))}else m?g(a,d):(a.instance=x.normalize(a.state.view(a)),null!=a.attrs&&J(a.attrs,a,d),J(a.state,a,d)),null!=a.instance?(null==c.instance?l(b,a.instance,
d,t,n):h(b,c.instance,a.instance,d,n,m,t),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=c.instance?(w(c.instance,null),a.dom=void 0,a.domSize=0):(a.dom=c.dom,a.domSize=c.domSize)}else w(c,null),l(b,a,d,t,n)}function r(a){var c=a.domSize;if(null!=c||null==a.dom){var b=C.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function n(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 v(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 f=a[c];null!=f&&(f.skip?f.skip=!1:w(f,d))}}function w(a,b){function c(){if(++d===f&&(t(a),a.dom)){var c=a.domSize||1;if(1<c)for(var e=a.dom;--c;){var p=e.nextSibling,
g=p.parentNode;null!=g&&g.removeChild(p)}c=a.dom;e=c.parentNode;null!=e&&e.removeChild(c);if(c=null!=b&&null==a.domSize)c=a.attrs,c=!(null!=c&&(c.oncreate||c.onupdate||c.onbeforeremove||c.onremove));c&&"string"===typeof a.tag&&(b.pool?b.pool.push(a):b.pool=[a])}}var f=1,d=0;if(a.attrs&&a.attrs.onbeforeremove){var e=a.attrs.onbeforeremove.call(a.state,a);null!=e&&"function"===typeof e.then&&(f++,e.then(c,c))}"string"!==typeof a.tag&&a.state.onbeforeremove&&(e=a.state.onbeforeremove(a),null!=e&&"function"===
typeof e.then&&(f++,e.then(c,c)));c()}function t(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag&&a.state.onremove)a.state.onremove(a);if(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 y(a,c,b,d,e){var f=a.dom;if("key"!==c&&"is"!==c&&(b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===C.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&
!E(c)){var g=c.indexOf(":");if(-1<g&&"xlink"===c.substr(0,g))f.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(g+1),d);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof d)A(a,c,d);else if("style"===c)if(a=b,a===d&&(f.style.cssText="",a=null),null==d)f.style.cssText="";else if("string"===typeof d)f.style.cssText=d;else{"string"===typeof a&&(f.style.cssText="");for(var n in d)f.style[n]=d[n];if(null!=a&&"string"!==typeof a)for(n in a)n in d||(f.style[n]="")}else c in f&&"href"!==c&&"list"!==
c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===C.activeElement||"select"===a.tag&&"value"===c&&a.dom.value==d&&a.dom===C.activeElement||"option"===a.tag&&"value"===c&&a.dom.value==d||("input"===a.tag&&"type"===c?f.setAttribute(c,d):f[c]=d):"boolean"===typeof d?d?f.setAttribute(c,""):f.removeAttribute(c):f.setAttribute("className"===c?"class":c,d)}}function E(a){return"oninit"===a||"oncreate"===a||"onupdate"===
a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function A(a,c,b){var d=a.dom,e="function"!==typeof F?b:function(a){var c=b.call(d,a);F.call(d,a);return c};if(c in d)d[c]="function"===typeof b?e:null;else{var f=c.slice(2);void 0===a.events&&(a.events={});a.events[c]!==e&&(null!=a.events[c]&&d.removeEventListener(f,a.events[c],!1),"function"===typeof b&&(a.events[c]=e,d.addEventListener(f,a.events[c],!1)))}}function B(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 J(a,b,d){"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,b))}var C=b.document,K=C.createDocumentFragment(),F;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=C.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);k(a,a.vnodes,x.normalizeChildren(b),!1,c,null,void 0);a.vnodes=b;for(var e=0;e<c.length;e++)c[e]();
C.activeElement!==d&&d.focus()},setEventCallback:function(a){return F=a}}},H=function(b){function d(b){b=e.indexOf(b);-1<b&&e.splice(b,2)}function l(){for(var b=1;b<e.length;b+=2)e[b]()}b=N(b);b.setEventCallback(function(b){!1!==b.redraw&&l()});var e=[];return{subscribe:function(b,k){d(b);e.push(b,P(k))},unsubscribe:d,redraw:l,render:b.render}}(window);L.setCompletionCallback(H.redraw);B.mount=function(b){return function(d,l){if(null===l)b.render(d,[]),b.unsubscribe(d);else{if(null==l.view&&"function"!==
typeof l)throw Error("m.mount(element, component) expects a component, not a vnode");b.subscribe(d,function(){b.render(d,x(l))});b.redraw()}}}(H);var S=A,M=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},l={},e=0;e<b.length;e++){var g=b[e].split("="),k=decodeURIComponent(g[0]),g=2===g.length?decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var h=k.split(/\]\[?|\[/),r=d;-1<k.indexOf("[")&&h.pop();for(var n=0;n<h.length;n++){var k=
h[n],m=h[n+1],m=""==m||!isNaN(parseInt(m,10)),v=n===h.length-1;""===k&&(k=h.slice(0,n).join(),null==l[k]&&(l[k]=0),k=l[k]++);null==r[k]&&(r[k]=v?g:m?[]:{});r=r[k]}}return d},T=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 l(b){return function(){null==h&&(h=k(function(){h=null;b()}))}}function e(b,d,e){var a=b.indexOf("?"),g=b.indexOf("#"),k=-1<a?a:-1<g?g:b.length;if(-1<a){var a=M(b.slice(a+
1,-1<g?g:b.length)),h;for(h in a)d[h]=a[h]}if(-1<g)for(h in d=M(b.slice(g+1)),d)e[h]=d[h];return b.slice(0,k)}var g="function"===typeof b.history.pushState,k="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,h,k){var a={},l={};
d=e(d,a,l);if(null!=h){for(var m in h)a[m]=h[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return h[d]})}(m=F(a))&&(d+="?"+m);(l=F(l))&&(d+="#"+l);g?(l=k?k.state:null,m=k?k.title:null,b.onpopstate(),k&&k.replace?b.history.replaceState(l,m,r.prefix+d):b.history.pushState(l,m,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,k,h){function a(){var a=r.getPath(),g={},l=e(a,g,g),m=b.history.state;if(null!=m)for(var n in m)g[n]=m[n];for(var v in d)if(m=new RegExp("^"+v.replace(/:[^\/]+?\.{3}/g,
"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),m.test(l)){l.replace(m,function(){for(var b=v.match(/:[^\/]+/g)||[],e=[].slice.call(arguments,1,-2),h=0;h<b.length;h++)g[b[h].replace(/:|\./g,"")]=decodeURIComponent(e[h]);k(d[v],g,a,v)});return}h(a,g)}g?b.onpopstate=l(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};B.route=function(b,d){var l=T(b),e=function(b){return b},g,k,h,r,n,m=function(b,a,m){if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");
var v=function(){null!=g&&d.render(b,g(x(k,h.key,h)))},w=function(b){if(b!==a)l.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};l.defineRoutes(m,function(a,b,d){var l=n=function(a,m){l===n&&(k=null==m||"function"!==typeof m.view&&"function"!==typeof m?"div":m,h=b,r=d,n=null,g=(a.render||e).bind(a),v())};a.view||"function"===typeof a?l({},a):a.onmatch?S.resolve(a.onmatch(b,d)).then(function(b){l(a,b)},w):l(a,"div")},w);d.subscribe(b,v)};m.set=function(b,a,d){null!=
n&&(d={replace:!0});n=null;l.setPath(b,a,d)};m.get=function(){return r};m.prefix=function(b){l.prefix=b};m.link=function(b){b.dom.setAttribute("href",l.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(l.prefix)&&(a=a.slice(l.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);B.withAttr=function(b,
d,l){return function(e){d.call(l||this,b in e.currentTarget?e.currentTarget[b]:e.currentTarget.getAttribute(b))}};var U=N(window);B.render=U.render;B.redraw=H.redraw;B.request=L.request;B.jsonp=L.jsonp;B.parseQueryString=M;B.buildQueryString=F;B.version="1.0.1";B.vnode=x;"undefined"!==typeof module?module.exports=B:window.m=B};