=0?c.splice(d,1):c.push(a),b.className=c.join(" ")}return this},u=function(a,b,c){return b instanceof Array&&(c=b,b=this),b||(b=this),function(){a.apply(b,(c||[]).concat(Array.prototype.slice.call(arguments,0)))}},w=function(a,b,c,e){var f=d.helpers.Extend({__name:a},e),o=d.helpers.Extend,p=[];f.listeners=p,f.on=function(a,b,c){return p[a]||(p[a]=[]),p[a].push({callback:b,scope:c}),this},f.off=function(a,b){return p[a]?(b||(p[a]=[]),this):this},f.dispatch=function(a,b,d){if(!b||"object"!=typeof b||b instanceof Array||(b.target=this),p[a])for(var e=0;e=b.childNodes.length)for(var i=0;i")})}d()}else"object"==typeof this.html?(x=o({},this.html),d()):a();else a();return this},f.applyHTML=function(a,b){return this.html=a,b||this.populate(),this};var y=!1;f.__append=function(a){return!y&&this.el&&this.get("parent")&&(y=!0,this.get("parent").appendChild(this.el)),a(),this};var z={events:{}};f.__handleEvents=function(a){if(this.el){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event"),d=function(c){if(c=c.split(":"),c.length>=2){var d=c[0],e=c[1];c.splice(0,2);var f=c;(!z.events[d]||z.events[d].indexOf(a)<0)&&(z.events[d]||(z.events[d]=[]),z.events[d].push(a),i(a,d,function(a){if("function"==typeof b[e]){var c=b[e];c.apply(b,[a].concat(f))}}))}};c=c.split(/, ?/g);for(var e=0;e'},f.child=function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+A.index++;return A.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},''},f.wire=function(a){return b.components.events.on(a,this[a]||function(){},this),this};var B=!1;return f.populate=function(a){return B?void 0:(B=!0,g([f.__handleCSS,f.__handleHTML,f.__append,f.__handleEvents,f.__handleAsyncFunctions,function(){B=!1,A={funcs:{},index:0};var b={css:w,html:{element:this.el}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this)},f.str2DOMElement=h,f.addEventListener=i,f.queue=g,f.qs=l,f.qsa=m,f.getStyle=n,f.addClass=q,f.removeClass=r,f.replaceClass=s,f.bind=u,f.toggleClass=t,f.compileHTML=function(a,c,d){b.flush().morph("html").add(a).compile(c,d)},f.compileCSS=function(a,c,d){b.flush().add(a).compile(c,d)},f.delay=function(a,b,c){var d=this;setTimeout(function(){b.apply(d,c)},a)},f},x=function(a){a.di.register("is",{appended:function(a){return"undefined"==typeof a&&(a=this.host.html),l(a)?!0:!1},hidden:function(a){return a=a||this.host.el,null===a.offsetParent}}),a.di.register("router",{routes:[],mode:null,root:"/",getFragment:function(){var a="";if("history"===this.mode){if(!location)return"";a=this.clearSlashes(decodeURI(location.pathname+location.search)),a=a.replace(/\?(.*)$/,""),a="/"!=this.root?a.replace(this.root,""):a}else{if(!window)return"";var b=window.location.href.match(/#(.*)$/);a=b?b[1]:""}return this.clearSlashes(a)},clearSlashes:function(a){return a.toString().replace(/\/$/,"").replace(/^\//,"")},add:function(a,b){return"function"==typeof a&&(b=a,a=""),this.routes.push({re:a,handler:b}),this},remove:function(a){for(var b,c=0;c0){for(var g=0;decl=a.declarations[g];g++)"declaration"===decl.type&&(f[decl.property]=decl.value);if(a.selectors&&a.selectors.length>0)for(var g=0;selector=a.selectors[g];g++)d[selector]=b({},f);e.add(d,c)}return e},e.addHook=function(a,b){j[a]||(j[a]=[]);for(var d=!1,e=0;c=j[a][e];e++)c===b&&(d=!0);d===!1?j[a].push(b):null},e.callHooks=function(a,b){if(j[a])for(var d=0;c=j[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=function(a){var b=d.helpers.Extend,c=d.helpers.Clone,e={},f=[],g=b({},w()),h={};return function(a){window&&(window.addEventListener?window.addEventListener("load",a):window.attachEvent&&window.attachEvent("onload",a))}(function(){h.broadcast("ready")}),h={numOfComponents:0,events:g,register:function(d,h){return this.numOfComponents+=1,e[d]=function(){var e=b({},w(d,a,g,c(h)));return a.di.resolveObject(e),f.push(e),"function"==typeof e.constructor&&e.constructor.apply(e,Array.prototype.slice.call(arguments,0)),e}},get:function(a){if(e[a])return e[a];throw new Error("There is no component with name '"+a+"'.")},remove:function(a){return e[a]?(delete e[a],!0):!1},list:function(){var a=[];for(var b in e)a.push(b);return a},flush:function(){return e={},f=[],this},broadcast:function(a,b){for(var c=0;c=0?h(p.replace(/&/g,a),n[q],e,i):h(p,n[q],e,"undefined"!=typeof i?i+" "+a:a);else h(q.replace(/&/g,a),n[q],e,i);else 0===q.indexOf("@media")||0===q.indexOf("@supports")?h(a,n[q],q,i):0===a.indexOf("@media")||0===q.indexOf("@supports")?h(q,n[q],a,i):0===a.indexOf("^")?h(a.substr(1,a.length-1)+("undefined"!=typeof i?" "+i:"")+" "+q,n[q],e):g(a,q,n[q],e,i)===!1&&h(q,n[q],e,(i?i+" ":"")+a);for(var q in o){var s={};s[q]=o[q](),h(a,s,e,i)}}else for(var k=0;k=0?"~~"+a.numOfAddedRules+"~~":"",p=n[i+k]||{};for(var q in m){var r=m[q];q=i+q,"object"!=typeof r&&(p[q]="css"==j?"+"===r.toString().charAt(0)?p&&p[q]?p[q]+", "+r.substr(1,r.length-1):r.substr(1,r.length-1):">"===r.toString().charAt(0)?p&&p[q]?p[q]+" "+r.substr(1,r.length-1):r.substr(1,r.length-1):r:r)}n[i+k]=p}return a}catch(s){throw new Error("Error adding: "+JSON.stringify({rules:c,error:s.toString()}))}};return i};var z=e("../helpers/Extend");d.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;ed;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};d.api.darken=function(){return function(a,b){return A(a,-(b/100))}},d.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},d.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}},d.api.importCSS=function(a){var b=e("../helpers/CSSParse");return function(c){try{var d=b(c);a.handlecss(d,"")}catch(e){console.log("Error in the CSS: '"+c+"'",e,e.stack)}return a}};var A=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};d.api.lighten=function(){return function(a,b){return A(a,b/100)}};var B={html:function(a){a.defaultProcessor=e(f+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=e(f+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;de;e++)d=c[e],b(d);return a}},d.api.register=function(a){return function(b,c){return a[b]=c,a}},d.api.storage=function(a){var b=a.getStorage(),c=function(d,e){if("undefined"!=typeof e)b[d]=e;else{if("object"!=typeof d){if(b[d])return b[d];throw new Error("There is no data in the storage associated with '"+d+"'")}for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&c(f,d[f])}return a};return c};var D=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;d.helpers.CSSParse=function(a,c){function d(a){var b=a.match(/\n/g);b&&(F+=b.length);var c=a.lastIndexOf("\n");G=~c?a.length-c:G+a.length}function e(){var a={line:F,column:G};return c.position?function(b){return b.position=new f(a),n(),b}:g}function f(a){this.start=a,this.end={line:F,column:G},this.source=c.source}function g(a){return n(),a}function h(b){var d=new Error(b+" near line "+F+":"+G);throw d.filename=c.source,d.line=F,d.column=G,d.source=a,d}function i(){return{type:"stylesheet",stylesheet:{rules:l()}}}function j(){return m(/^{\s*/)}function k(){return m(/^}/)}function l(){var b,c=[];for(n(),o(c);a.length&&"}"!=a.charAt(0)&&(b=C()||E());)c.push(b),o(c);return c}function m(b){var c=b.exec(a);if(c){var e=c[0];return d(e),a=a.slice(e.length),c}}function n(){m(/^\s*/)}function o(a){var b;for(a=a||[];b=p();)a.push(b);return a}function p(){var b=e();if("/"==a.charAt(0)&&"*"==a.charAt(1)){for(var c=2;""!=a.charAt(c)&&("*"!=a.charAt(c)||"/"!=a.charAt(c+1));)++c;if(c+=2,""===a.charAt(c-1))return h("End of comment missing");var f=a.slice(2,c-2);return G+=2,d(f),a=a.slice(c),G+=2,b({type:"comment",comment:f})}}function q(){var a=m(/^([^{]+)/);if(a)return b(a[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").split(/\s*,\s*/)}function r(){var a=e(),c=m(/^(\*?[-#\/\*\w]+(\[[0-9a-z_-]+\])?)\s*/);if(c){if(c=b(c[0]),!m(/^:\s*/))return h("property missing ':'");var d=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);if(!d)return h("property missing value");var f=a({type:"declaration",property:c.replace(D,""),value:b(d[0]).replace(D,"")});return m(/^[;\s]*/),f}}function s(){var a=[];if(!j())return h("missing '{'");o(a);for(var b;b=r();)a.push(b),o(a);return k()?a:h("missing '}'")}function t(){for(var a,b=[],c=e();a=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)b.push(a[1]),m(/^,\s*/);return b.length?c({type:"keyframe",values:b,declarations:s()}):void 0}function u(){var a=e(),b=m(/^@([-\w]+)?keyframes */);if(b){var c=b[1],b=m(/^([-\w]+)\s*/);if(!b)return h("@keyframes missing name");var d=b[1];if(!j())return h("@keyframes missing '{'");for(var f,g=o();f=t();)g.push(f),g=g.concat(o());return k()?a({type:"keyframes",name:d,vendor:c,keyframes:g}):h("@keyframes missing '}'")}}function v(){var a=e(),c=m(/^@supports *([^{]+)/);if(c){var d=b(c[1]);if(!j())return h("@supports missing '{'");var f=o().concat(l());return k()?a({type:"supports",supports:d,rules:f}):h("@supports missing '}'")}}function w(){var a=e(),b=m(/^@host */);if(b){if(!j())return h("@host missing '{'");var c=o().concat(l());return k()?a({type:"host",rules:c}):h("@host missing '}'")}}function x(){var a=e(),c=m(/^@media *([^{]+)/);if(c){var d=b(c[1]);if(!j())return h("@media missing '{'");var f=o().concat(l());return k()?a({type:"media",media:d,rules:f}):h("@media missing '}'")}}function y(){var a=e(),b=m(/^@page */);if(b){var c=q()||[];if(!j())return h("@page missing '{'");for(var d,f=o();d=r();)f.push(d),f=f.concat(o());return k()?a({type:"page",selectors:c,declarations:f}):h("@page missing '}'")}}function z(){var a=e(),c=m(/^@([-\w]+)?document *([^{]+)/);if(c){var d=b(c[1]),f=b(c[2]);if(!j())return h("@document missing '{'");var g=o().concat(l());return k()?a({type:"document",document:f,vendor:d,rules:g}):h("@document missing '}'")}}function A(){var a=e(),b=m(/^@font-face */);if(b){if(!j())return h("@font-face missing '{'");for(var c,d=o();c=r();)d.push(c),d=d.concat(o());return k()?a({type:"font-face",declarations:d}):h("@font-face missing '}'")}}function B(a){var b=new RegExp("^@"+a+" *([^;\\n]+);");return function(){var c=e(),d=m(b);if(d){var f={type:a};return f[a]=d[1].trim(),c(f)}}}function C(){return"@"==a[0]?u()||x()||v()||H()||I()||J()||z()||y()||w()||A():void 0}function E(){var a=e(),b=q();return b?(o(),a({type:"rule",selectors:b,declarations:s()})):h("selector missing")}c=c||{},c.position=c.position===!1?!1:!0;var F=1,G=1;f.prototype.content=a;var H=B("import"),I=B("charset"),J=B("namespace");return i()},d.helpers.Clone=function X(a){if(!a)return a;var b,c=[Number,String,Boolean];if(c.forEach(function(c){a instanceof c&&(b=c(a))}),"undefined"==typeof b)if("[object Array]"===Object.prototype.toString.call(a))b=[],a.forEach(function(a,c){b[c]=X(a)});else if("object"==typeof a)if(a.nodeType&&"function"==typeof a.cloneNode)var b=a.cloneNode(!0);else if(a.prototype)b=a;else if(a instanceof Date)b=new Date(a);else{b={};for(var d in a)b[d]=X(a[d])}else b=a;return b},d.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},d.helpers.Extend=function(){for(var a=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},b=arguments[0],c=1;c=0)&&(b["-webkit-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("m")>=0)&&(b["-moz-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("s")>=0)&&(b["-ms-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("o")>=0)&&(b["-o-"+d.prop]=e))},nonPrefixProp:function(a){var b=E(a);return b.prefix!==!1&&(b.prefix=""==b.prefix?"-":"-"+b.prefix+"-"),b}},d.helpers.RequireUncached=function(a){return delete e.cache[e.resolve(a)],e(a)},d.helpers.TransformUppercase=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};var F=function(a,b,d){var g="",h="",i=[],j=d.api;cssPreprocessor=e(f+"/../css/CSS.js")(),htmlPreprocessor=e(f+"/../html/HTML.js")();for(var k=function(a){for(var b=0;ba.length-1)return void b(e);var g=a[c];"function"==typeof g&&(g=g()),j.morph("html").add(g.html?g.html:{}),htmlPreprocessor(j.getRules(),function(a,b){h+=b,c+=1,e=a,f()},d)};f()},m=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d=0){b[c]={};for(var e in d){b[c][e]={};for(var f in d[e])b[c][e][f]=d[e][f]}}}return b},L=function(a,b){var c=[],d={},b=[].concat(b||[]);b.splice(0,0,""),b=b.join("|");for(var e in a){var f=a[e];for(var g in f)c.push({selector:e,prop:g,value:f[g],combine:b.indexOf("|"+g)<0})}for(var h=0;h","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};d.processors.css.CSS=function(){var a=function(a,b,c){if(c=c||H,c.api&&c.api.jsonify){var d=K(a,c);return b(null,d),d}var e="";for(var f in a){var g=a[f];g=c.combineSelectors?L(g,c.preventCombining):g,e+="mainstream"===f?J(g,c):f+" {"+G+J(g,c,[" "," "])+"}"+G}return e=N(e,c),c.minify?(e=M(e),b&&b(null,e)):b&&b(null,e),e};return a.type="css",a},d.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},d.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},d.processors.css.plugins.keyframes=function(){return function(a,b){e(f+"/../CSS.js")(),e(f+"/../../../helpers/Prefixes");if("object"==typeof b){var c;if("undefined"!=typeof b.frames)c=b.frames;else if("undefined"!=typeof b.keyframes){c={};for(var d=0;rule=b.keyframes[d];d++)if("keyframe"===rule.type)for(var g=c[rule.values]={},h=0;declaration=rule.declarations[h];h++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}if(a.jsonify){var i={};i.keyframes={name:b.name,frames:c},a.add(i)}else{var j=e(f+"/../../../../")();j.add(c).compile(function(c,d){var e="@keyframes "+b.name+" {\n";e+=d,e+="}",e=e+"\n"+e.replace("@keyframes","@-webkit-keyframes"),a.raw(e)},{combineSelectors:!1})}}}},d.processors.css.plugins.media=function(){return function(a,b){var c=e(f+"/../CSS.js")();if("object"==typeof b){for(var d="@media "+b.media+" {\n",g={},h={},i=0;rule=b.rules[i];i++){var j=g[rule.selectors.toString()]={},k=h[rule.selectors.toString()]={};if("rule"===rule.type)for(var l=0;declaration=rule.declarations[l];l++)"declaration"===declaration.type&&(j[declaration.property]=declaration.value,k[declaration.property]=declaration.value)}d+=c({mainstream:g}),d+="}",a.jsonify?a.add(h,"@media "+b.media):a.raw(d)}}},d.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},d.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},d.processors.css.plugins.supports=function(){return function(a,b){var c=e(f+"/../CSS.js")();if("object"==typeof b){for(var d="@supports "+b.supports+" {\n",g={},h=0;rule=b.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}d+=c({mainstream:g}),d+="}",a.raw(d)}}};var O=null,G="\n",H={},P=e("js-beautify").html,Q=e("../../helpers/TransformUppercase"),R={},S=function(a){var b="";for(var c in O)if(c==a)for(var d=O[c].length,e=0;d>e;e++)b+=U("",O[c][e]);return b},T=function(a,b){return b&&b.keepCamelCase===!0?a:Q(a,b)},U=function(a,b){var c="",d="",f="",g=e("./helpers/PropAnalyzer")(a);if(a=g.tag,""!=g.attrs&&(d+=" "+g.attrs),"string"==typeof b)return V(a,d,b);var h=function(a){""!=f&&(f+=G),f+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)d+="function"==typeof j[k]?" "+T(k,R)+'="'+j[k]()+'"':" "+T(k,R)+'="'+j[k]+'"';break;case"_":h(j);break;case"_tpl":if("string"==typeof j)h(S(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=S(tpl),m0){for(var l="",m=0;v=j[m];m++)l+=U("","function"==typeof v?v():v),m"+G+c+G+""+T(a,R)+">":"<"+T(a,R)+b+"/>")},W=function(a){return a=e("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),R),R.minify?a:P(a,{indent_size:R.indentSize||4})};return d.processors.html.HTML=function(){var a=function(a,b,c){O=a,b=b||function(){},c=R=c||H;var d=W(S("mainstream"));return b(null,d),d};return a.type="html",a},d.processors.html.helpers.PropAnalyzer=function(a){var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1;if(/(#|\.|\[|\])/gi.test(a)===!1)return{tag:a,attrs:""};for(var k=0;k/g,e=/(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,f="with(obj) { var r=[];\n",g=0,h=function(a,b){return f+=b?a.match(e)?a+"\n":"r.push("+a+");\n":""!=a?'r.push("'+a.replace(/"/g,'\\"')+'");\n':"",h};match=d.exec(a);)h(a.slice(g,match.index))(match[1],!0),g=match.index+match[0].length;h(a.substr(g,a.length-g)),f=(f+'return r.join(""); }').replace(/[\r\t\n]/g,"");try{c=new Function("obj",f).apply(b,[b])}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},y()}(window);