/* Mithril v0.1.20 http://github.com/lhorie/mithril.js (c) Leo Horie License: MIT */ Mithril=m=new function a(b,c){function d(){for(var a,b=arguments,d=(!(b[1]===c||"[object Object]"!=A.call(b[1])||"tag"in b[1]||"subtree"in b[1])),e=d?b[1]:{},f=("class"in e?"class":"className"),g={tag:"div",attrs:{}},h=[];a=B.exec(b[0]);)if(""==a[1])g.tag=a[2];else if("#"==a[1])g.attrs.id=a[2];else if("."==a[1])h.push(a[2]);else if("["==a[3][0]){var i=C.exec(a[3]);g.attrs[i[1]]=i[3]||(i[2]?"":!0)}h.length>0&&(g.attrs[f]=h.join(" ")),g.children=d?b[2]:b[1];for(var j in e)g.attrs[j]=j==f?(g.attrs[j]||"")+" "+e[j]:e[j];return g}function e(a,d,h,k,l,m,n,o,p,q,r){if((l===c||null===l)&&(l=""),"retain"===l.subtree)return m;var s=A.call(m),t=A.call(l);if(m===c||null===m||s!=t){if(null!==m&&m!==c)if(h&&h.nodes){var u=o-k,v=u+("[object Array]"==t?l:m.nodes).length;g(h.nodes.slice(u,v),h.slice(u,v))}else m.nodes&&g(m.nodes,m);m=new l.constructor,m.nodes=[]}if("[object Array]"==t){l=j(l);for(var w=[],x=m.length===l.length,y=0,z=1,B=2,C=3,D={},E=[],F=!1,G=0;G-1?new l.constructor(l):l,m.nodes=w):m.valueOf()!==l.valueOf()||n===!0?(w=m.nodes,p&&p===b.document.activeElement||(l.$trusted?(g(w,m),w=i(a,o,l)):"textarea"===d?a.value=l:p?p.innerHTML=l:((1==w[0].nodeType||w.length>1)&&(g(m.nodes,m),w=[b.document.createTextNode(l)]),a.insertBefore(w[0],a.childNodes[o]||null),w[0].nodeValue=l)),m=new l.constructor(l),m.nodes=w):m.nodes.intact=!0}return m}function f(a,d,e,f,g){for(var h in e){var i=e[h],j=f[h];if(!(h in f)||j!==i||a===b.document.activeElement){if(f[h]=i,"config"===h)continue;if("function"==typeof i&&0==h.indexOf("on"))a[h]=k(i,a);else if("style"===h&&"object"==typeof i){for(var l in i)(j===c||j[l]!==i[l])&&(a.style[l]=i[l]);for(var l in j)l in i||(a.style[l]="")}else g!==c?"href"===h?a.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===h?a.setAttribute("class",i):a.setAttribute(h,i):"value"===h&&"input"===d?a.value!==i&&(a.value=i):h in a&&"list"!=h&&"style"!=h?a[h]=i:a.setAttribute(h,i)}}return f}function g(a,b){for(var c=a.length-1;c>-1;c--)a[c]&&a[c].parentNode&&(a[c].parentNode.removeChild(a[c]),b=[].concat(b),b[c]&&h(b[c]));0!=a.length&&(a.length=0)}function h(a){if(a.configContext&&"function"==typeof a.configContext.onunload&&a.configContext.onunload(),a.children)if("[object Array]"==A.call(a.children))for(var b=0;bb?E.push(a)-1:b}function m(){for(var a=d.redraw.strategy(),b=0;b=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize==JSON.stringify&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof a.config){var e=a.config(d,a);e!==c&&(d=e)}return d.send("GET"==a.method?"":a.data),d}function x(a,b,c){return b&&Object.keys(b).length>0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+r(b):a.data=c(b)),a}function y(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;dc&&(c=G.length);var e=!1;if(I[c]&&"function"==typeof I[c].onunload){var f={preventDefault:function(){e=!0}};I[c].onunload(f)}e||(d.redraw.strategy("all"),d.startComputation(),G[c]=a,H[c]=b,I[c]=new b.controller,d.endComputation())},d.redraw=function(){var a=b.cancelAnimationFrame||b.clearTimeout,c=b.requestAnimationFrame||b.setTimeout;J?(a(J),J=c(m,0)):(m(),J=c(function(){J=null},0))},d.redraw.strategy=d.prop();var L=0;d.startComputation=function(){L++},d.endComputation=function(){L=Math.max(L-1,0),0==L&&d.redraw()},d.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var M,N={pathname:"",hash:"#",search:"?"},O=function(){},P={};d.route=function(){if(0===arguments.length)return M;if(3===arguments.length&&"string"==typeof arguments[1]){var a=arguments[0],c=arguments[1],e=arguments[2];O=function(b){var f=M=n(b);o(a,e,f)||d.route(c,!0)};var f="hash"==d.route.mode?"onhashchange":"onpopstate";b[f]=function(){M!=n(b.location[d.route.mode])&&O(b.location[d.route.mode])},K=q,b[f]()}else if(arguments[0].addEventListener){var g=arguments[0],h=arguments[1];g.href.indexOf(N[d.route.mode])<0&&(g.href=b.location.pathname+N[d.route.mode]+g.pathname),h||(g.removeEventListener("click",p),g.addEventListener("click",p))}else if("string"==typeof arguments[0]){M=arguments[0];var i="object"==typeof arguments[1]?r(arguments[1]):null;i&&(M+=(-1===M.indexOf("?")?"?":"&")+i);var j=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(K=function(){b.history[j?"replaceState":"pushState"](null,b.document.title,N[d.route.mode]+M),q()},O(N[d.route.mode]+M)):b.location[d.route.mode]=M}},d.route.param=function(a){return P[a]},d.route.mode="search";var Q={};return d.deferred=function(){var a=[],b=[],e=Q,f=Q,g=d.prop(),h={resolve:function(c){e===Q&&g(e=c);for(var d=0;d0)for(var h=0;h