New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

absurd

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absurd - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

lib/api/define.js

26

client-side/build/absurd.js

@@ -1,2 +0,2 @@

/* version: 0.2.4 */
/* version: 0.2.5 */
var Absurd = (function(w) {

@@ -729,3 +729,2 @@ var lib = {

allRules = API.getRules(stylesheet);
// console.log(selector, props);
if(typeof allRules[selector] == 'object') {

@@ -819,2 +818,9 @@ var current = allRules[selector];

}
lib.api.define = function(api) {
return function(prop, value) {
if(!api.getStorage().__defined) api.getStorage().__defined = {};
api.getStorage().__defined[prop] = value;
return api;
}
}
lib.api.hook = function(api) {

@@ -1209,2 +1215,17 @@ return function(method, callback) {

var replaceDefined = function(css, options) {
if(options && options.api && options.api.getStorage().__defined) {
var storage = options.api.getStorage().__defined;
for(var prop in storage) {
var re = new RegExp('<%( )?' + prop + '( )?%>', 'g');
if(typeof storage[prop] != 'function') {
css = css.replace(re, storage[prop]);
} else {
css = css.replace(re, storage[prop]());
}
}
}
return css;
}
lib.processors.css.CSS = function() {

@@ -1223,2 +1244,3 @@ var processor = function(rules, callback, options) {

}
css = replaceDefined(css, options);
// Minification

@@ -1225,0 +1247,0 @@ if(options.minify) {

2

client-side/build/absurd.min.js

@@ -1,1 +0,1 @@

var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},b=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},d=function(a,b){var c;try{c=(b||document).querySelectorAll(a)}catch(d){c=document.querySelectorAll(a)}return c},e=function(a){var b=document.createElement("div");return b.innerHTML=a,b.childNodes[0]},f=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},g=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},h=function(b){return b.indexOf("css/CSS.js")>0?a.processors.css.CSS:b.indexOf("html/HTML.js")>0?a.processors.html.HTML:b.indexOf("component/Component.js")>0?a.processors.component.Component:"js-beautify"==b?{html:function(a){return a}}:"./helpers/PropAnalyzer"==b?a.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==b?a.helpers.TransformUppercase:"./helpers/TemplateEngine"==b?a.processors.html.helpers.TemplateEngine:"../helpers/Extend"==b?a.helpers.Extend:"../helpers/Clone"==b?a.helpers.Clone:function(){}},i="",j=function(a){var b=[];return{listeners:b,on:function(a,c,d){return b[a]||(b[a]=[]),b[a].push({callback:c,scope:d}),this},off:function(a,c){return b[a]?(c||(b[a]=[]),this):this},dispatch:function(c,d,e){if(!d||"object"!=typeof d||d instanceof Array||(d.target=this),b[c])for(var f=0;f<b[c].length;f++){var g=b[c][f].callback;g.apply(e||b[c][f].scope||{},[d])}return this[c]&&"function"==typeof this[c]&&this[c](d),a&&a.dispatch(c,d),this}}},k=function(c,h){var i=!1,j=!1,k=!1,l=a.helpers.Extend,m={},n=!1,o={funcs:{},index:0},p={events:{}},q=function(a){this.css?h.flush().add(this.css).compile(function(b,e){if(i)i.raw!==e&&(i.raw=e,i.element.innerHTML=e);else{var f=document.createElement("style");f.setAttribute("id",c+"-css"),f.setAttribute("type","text/css"),f.innerHTML=e,(d("head")||d("body"))[0].appendChild(f),i={raw:e,element:f}}a()}):a()},r=function(a){if(this.html)if("string"==typeof this.html){if(k===!1){var b=d(this.html);b.length>0&&(k=b[0]),j={"":k.outerHTML.replace(/&lt;/g,"<").replace(/&gt;/g,">")}}a()}else"object"==typeof this.html?(j=l({},this.html),k===!1?h.flush().morph("html").add(j).compile(function(b,c){k=e(c),a(!0)},this):a()):a();else a()},s=function(a,b){j&&b!==!0?h.flush().morph("html").add(j).compile(function(b,c){!function d(a,b){if(g(a),g(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,e,f=a.attributes,h=b.attributes,i={},j=0;j<f.length,c=f[j];j++){for(var k=0;k<h.length,e=h[k];k++)c.name===e.name&&(a.setAttribute(c.name,e.value),i[c.name]=!0);i[c.name]||a.removeAttribute(c.name)}for(var j=0;j<h.length,e=h[j];j++)i[e.name]||a.setAttribute(e.name,e.value)}var l=[];if(a.childNodes.length>=b.childNodes.length)for(var j=0;j<a.childNodes.length;j++)b.childNodes[j]||b.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);else for(var j=0;j<b.childNodes.length;j++)a.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);for(var j=0;j<l.length;j++)d(l[j][0],l[j][1])}}(k,e(c)),a()},this):a()},t=function(a){if(k){var b=[];if(k.hasAttribute("data-absurd-async"))b.push(k);else for(var c=k.querySelectorAll?k.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var f=this;!function g(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(e(a),c):c.parentNode.replaceChild(a,c),g()};"function"==typeof f[o.funcs[d].name]?f[o.funcs[d].name].apply(f,[h].concat(o.funcs[d].args)):"function"==typeof o.funcs[d].func&&o.funcs[d].func.apply(f,[h].concat(o.funcs[d].args))}}()}}else a()},u=function(a){!n&&k&&this.get("parent")&&(n=!0,this.get("parent").appendChild(k)),a()},v=function(a){if(k){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");c=c.split(":"),c.length>=2&&(!p.events[c[0]]||p.events[c[0]].indexOf(a)<0)&&(p.events[c[0]]||(p.events[c[0]]=[]),p.events[c[0]].push(a),f(a,c[0],function(a){"function"==typeof b[c[1]]&&b[c[1]](a)}))};k.hasAttribute("data-absurd-event")&&c(k);for(var d=k.querySelectorAll?k.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}a()},w={name:c,populate:function(a){return b([q,r,s,u,v,t,function(){o={funcs:{},index:0};var b={css:i,html:{element:k}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this},el:function(){return k},set:function(a,b){return m[a]=b,this},get:function(a){return m[a]},wire:function(a){h.components.events.on(a,this[a]||function(){},this)},async:function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+o.index++;return o.funcs[c]={args:a,name:b},'<span data-absurd-async="'+c+'"></span>'},child:function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+o.index++;return o.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<span data-absurd-async="'+d+'"></span>'}};return w},l=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}},m=function(b){var c=a.helpers.Extend,d={},e={},f=[];return d.events=c({},j()),d.register=function(a,g){return e[a]=function(){var e=c({},j(d.events),k(a,b),g);return b.di.resolveObject(e),f.push(e),"function"==typeof e.constructor&&e.constructor.apply(e,Array.prototype.slice.call(arguments,0)),e}},d.get=function(a){if(e[a])return e[a];throw new Error("There is no component with name '"+a+"'.")},d.remove=function(a){return e[a]?(delete e[a],!0):!1},d.list=function(){var a=[];for(var b in e)a.push(b);return a},d.flush=function(){return e={},f=[],d},d.broadcast=function(a,b){for(var c=0;c<f.length,instance=f[c];c++)"function"==typeof instance[a]&&instance[a](b);return d},d},n=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){return f={},g=[],i={},e.defaultProcessor=a.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=m(e),e.component=l(e),e.di=a.DI(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.plugins)e.plugin(k,a.plugins[k]());return"function"==typeof b&&b(e),e}};a.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=[],e=this,f=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var g=0;g<b.length;g++)"undefined"!=typeof this.dependencies[b[g]]&&(f=!0);return f?function(){for(var f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];d.push(e.dependencies[h]&&""!=h?e.dependencies[h]:f.shift())}return a.apply(c,d)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},a.api.add=function(a){var b=(h("../helpers/Extend"),h("../helpers/Clone"),[]),c=function(b,c,e,f,g){var h=a.getPlugins()[c];if("undefined"!=typeof h){var i=h(a,e);return i&&d(b,i,f,g),!0}return!1},d=function(a,e,f,g){if(f=f||"mainstream",/, ?/g.test(a))for(var h=a.replace(/, /g,",").split(","),i=0;i<h.length,p=h[i];i++)d(p,e,f,g);else if("undefined"==typeof e.length||"object"!=typeof e){if(!c(null,a,e,f,g)){var j={},k=a,l={},m={};for(var n in e){var o=typeof e[n];"object"!==o&&"function"!==o?c(a,n,e[n],f,g)===!1&&(k="undefined"!=typeof g?g+" "+a:a,j[n]=e[n]):"object"===o?l[n]=e[n]:"function"===o&&(m[n]=e[n])}b.push({selector:k,props:j,stylesheet:f});for(var n in l)":"===n.charAt(0)?d(a+n,l[n],f,g):/&/g.test(n)?d(n.replace(/&/g,a),l[n],f,g):0===n.indexOf("@media")||0===n.indexOf("@supports")?d(a,l[n],n,g):0===a.indexOf("@media")||0===n.indexOf("@supports")?d(n,l[n],a,g):c(a,n,l[n],f,g)===!1&&d(n,l[n],f,(g?g+" ":"")+a);for(var n in m){var q={};q[n]=m[n](),d(a,q,f,g)}}}else for(var i=0;i<e.length,n=e[i];i++)d(a,n,f,g)},e=function(c,e){b=[],a.numOfAddedRules+=1;for(var f in c)d(f,c[f],e||"mainstream");for(var g=0;g<b.length;g++){var e=b[g].stylesheet,f=b[g].selector,h=b[g].props,i=a.getRules(e);if("object"==typeof i[f]){var j=i[f];for(var k in h)"object"!=typeof h[k]&&(j[k]=h[k])}else i[f]=h}return a};return e};var q=h("../helpers/Extend");a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=q(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{t.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var r=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};a.api.darken=function(){return function(a,b){return r(a,-(b/100))}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var r=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};a.api.lighten=function(){return function(a,b){return r(a,b/100)}};var s={html:function(a){a.defaultProcessor=h(i+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=h(i+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};a.api.morph=function(a){return function(b){return s[b]&&(a.flush(),s[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var t=h("fs");h("path")}a.api.rawImport=function(a){var b=function(b){var c=t.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.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},a.helpers.Clone=function L(a){function b(a,b,c){var d,e,f={};for(d in b)e=b[d],d in a&&(a[d]===e||d in f&&f[d]===e)||(a[d]=c?c(e):e);return a}if(!a||"object"!=typeof a||"[object Function]"===Object.prototype.toString.call(a))return a;if(a.nodeType&&"cloneNode"in a)return a.cloneNode(!0);if(a instanceof Date)return new Date(a.getTime());if(a instanceof RegExp)return new RegExp(a);var c,d,e;if(a instanceof Array)for(c=[],d=0,e=a.length;e>d;++d)d in a&&c.push(L(a[d]));else c=a.constructor?new a.constructor:{};return b(c,a,L)},a.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},a.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<arguments.length;c++)b=a(b,arguments[c]);return b},a.helpers.RequireUncached=function(a){return delete h.cache[h.resolve(a)],h(a)},a.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 u=function(a,b,d){var e="",f="",g=[],j=d.api;cssPreprocessor=h(i+"/../css/CSS.js")(),htmlPreprocessor=h(i+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<g.length,l=g[b];b++)"function"==typeof l&&(l=l()),j.add(l.css?l.css:{});cssPreprocessor(j.getRules(),function(b,c){e+=c,a(b)},d)},m=function(b){var c=0,e=null,g=function(){if(c>a.length-1)return b(e),void 0;var h=a[c];"function"==typeof h&&(h=h()),j.morph("html").add(h.html?h.html:{}),htmlPreprocessor(j.getRules(),function(a,b){f+=b,c+=1,e=a,g()},d)};g()},n=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),g.push(c),n(c);else"function"==typeof a[b]&&(a[b]=a[b]()),g.push(a[b]),n(a[b]);else"object"==typeof a[b]&&n(a[b])},o=0;o<a.length,c=a[o];o++)"function"==typeof c&&(c=c()),g.push(c),n(c);j.flush(),k(function(a){j.morph("html"),m(function(c){b(a||c?{error:{css:a,html:c}}:null,e,f)})})};a.processors.component.Component=function(){var a=function(a,b,c){u(a.mainstream,b,c)};return a.type="component",a};var w="\n",x={combineSelectors:!0,minify:!1,keepCamelCase:!1},y=h("../../helpers/TransformUppercase"),z=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+w;else{var e=d+" {"+w;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=b&&b.keepCamelCase===!0?" "+f+": "+g+";"+w:" "+y(f)+": "+g+";"+w}e+="}"+w,c+=e}return c},A=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},B=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")};a.processors.css.CSS=function(){var a=function(a,b,c){c=c||x;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?A(f):f,d+="mainstream"===e?z(f,c):e+" {"+w+z(f,c)+"}"+w}return c.minify?(d=B(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},a.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+'";'))}},a.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)}}},a.processors.css.plugins.keyframes=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b)if("undefined"!=typeof b.frames){var d="@keyframes "+b.name+" {\n";d+=c({mainstream:b.frames}),d+="}",a.raw(d+"\n"+d.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var d="@keyframes "+b.name+" {\n",e={},f=0;rule=b.keyframes[f];f++)if("keyframe"===rule.type)for(var g=e[rule.values]={},j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value);d+=c({mainstream:e}),d+="}",a.raw(d+"\n"+d.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@media "+b.media+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}},a.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+'";'))}},a.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)}}},a.processors.css.plugins.supports=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@supports "+b.supports+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}};var C=null,w="\n",x={},D=h("js-beautify").html,E=h("../../helpers/TransformUppercase"),F={},G=function(a){var b="";for(var c in C)if(c==a)for(var d=C[c].length,e=0;d>e;e++)b+=I("",C[c][e]);return b},H=function(a,b){return b&&b.keepCamelCase===!0?a:E(a,b)},I=function(a,b){var c="",d="",e="",f=h("./helpers/PropAnalyzer")(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return J(a,d,b);var g=function(a){""!=e&&(e+=w),e+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)d+="function"==typeof j[k]?" "+H(k,F)+'="'+j[k]()+'"':" "+H(k,F)+'="'+j[k]+'"';break;case"_":g(j);break;case"_tpl":if("string"==typeof j)g(G(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=G(tpl),m<j.length-1&&(l+=w);g(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=I("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);g(l);break;default:switch(typeof j){case"string":g(I(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=I("","function"==typeof v?v():v),m<j.length-1&&(l+=w);g(I(i,l))}else g(I(i,j));break;case"function":g(I(i,j()))}}}return c+=""!=a?J(a,d,e):e},J=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+H(a,F)+b+">"+w+c+w+"</"+H(a,F)+">":"<"+H(a,F)+b+"/>")},K=function(a){return a=h("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),F),F.minify?a:D(a,{indent_size:F.indentSize||4})};return a.processors.html.HTML=function(){var a=function(a,b,c){C=a,b=b||function(){},c=F=c||x;var d=K(G("mainstream"));return b(null,d),d};return a.type="html",a},a.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<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},a.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(if|for|else|switch|case|break|{|}|;))(.*)?/g,f="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(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},n()}(window);
var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},b=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},d=function(a,b){var c;try{c=(b||document).querySelectorAll(a)}catch(d){c=document.querySelectorAll(a)}return c},e=function(a){var b=document.createElement("div");return b.innerHTML=a,b.childNodes[0]},f=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},g=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},h=function(b){return b.indexOf("css/CSS.js")>0?a.processors.css.CSS:b.indexOf("html/HTML.js")>0?a.processors.html.HTML:b.indexOf("component/Component.js")>0?a.processors.component.Component:"js-beautify"==b?{html:function(a){return a}}:"./helpers/PropAnalyzer"==b?a.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==b?a.helpers.TransformUppercase:"./helpers/TemplateEngine"==b?a.processors.html.helpers.TemplateEngine:"../helpers/Extend"==b?a.helpers.Extend:"../helpers/Clone"==b?a.helpers.Clone:function(){}},i="",j=function(a){var b=[];return{listeners:b,on:function(a,c,d){return b[a]||(b[a]=[]),b[a].push({callback:c,scope:d}),this},off:function(a,c){return b[a]?(c||(b[a]=[]),this):this},dispatch:function(c,d,e){if(!d||"object"!=typeof d||d instanceof Array||(d.target=this),b[c])for(var f=0;f<b[c].length;f++){var g=b[c][f].callback;g.apply(e||b[c][f].scope||{},[d])}return this[c]&&"function"==typeof this[c]&&this[c](d),a&&a.dispatch(c,d),this}}},k=function(c,h){var i=!1,j=!1,k=!1,l=a.helpers.Extend,m={},n=!1,o={funcs:{},index:0},p={events:{}},q=function(a){this.css?h.flush().add(this.css).compile(function(b,e){if(i)i.raw!==e&&(i.raw=e,i.element.innerHTML=e);else{var f=document.createElement("style");f.setAttribute("id",c+"-css"),f.setAttribute("type","text/css"),f.innerHTML=e,(d("head")||d("body"))[0].appendChild(f),i={raw:e,element:f}}a()}):a()},r=function(a){if(this.html)if("string"==typeof this.html){if(k===!1){var b=d(this.html);b.length>0&&(k=b[0]),j={"":k.outerHTML.replace(/&lt;/g,"<").replace(/&gt;/g,">")}}a()}else"object"==typeof this.html?(j=l({},this.html),k===!1?h.flush().morph("html").add(j).compile(function(b,c){k=e(c),a(!0)},this):a()):a();else a()},s=function(a,b){j&&b!==!0?h.flush().morph("html").add(j).compile(function(b,c){!function d(a,b){if(g(a),g(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,e,f=a.attributes,h=b.attributes,i={},j=0;j<f.length,c=f[j];j++){for(var k=0;k<h.length,e=h[k];k++)c.name===e.name&&(a.setAttribute(c.name,e.value),i[c.name]=!0);i[c.name]||a.removeAttribute(c.name)}for(var j=0;j<h.length,e=h[j];j++)i[e.name]||a.setAttribute(e.name,e.value)}var l=[];if(a.childNodes.length>=b.childNodes.length)for(var j=0;j<a.childNodes.length;j++)b.childNodes[j]||b.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);else for(var j=0;j<b.childNodes.length;j++)a.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);for(var j=0;j<l.length;j++)d(l[j][0],l[j][1])}}(k,e(c)),a()},this):a()},t=function(a){if(k){var b=[];if(k.hasAttribute("data-absurd-async"))b.push(k);else for(var c=k.querySelectorAll?k.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var f=this;!function g(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(e(a),c):c.parentNode.replaceChild(a,c),g()};"function"==typeof f[o.funcs[d].name]?f[o.funcs[d].name].apply(f,[h].concat(o.funcs[d].args)):"function"==typeof o.funcs[d].func&&o.funcs[d].func.apply(f,[h].concat(o.funcs[d].args))}}()}}else a()},u=function(a){!n&&k&&this.get("parent")&&(n=!0,this.get("parent").appendChild(k)),a()},v=function(a){if(k){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");c=c.split(":"),c.length>=2&&(!p.events[c[0]]||p.events[c[0]].indexOf(a)<0)&&(p.events[c[0]]||(p.events[c[0]]=[]),p.events[c[0]].push(a),f(a,c[0],function(a){"function"==typeof b[c[1]]&&b[c[1]](a)}))};k.hasAttribute("data-absurd-event")&&c(k);for(var d=k.querySelectorAll?k.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}a()},w={name:c,populate:function(a){return b([q,r,s,u,v,t,function(){o={funcs:{},index:0};var b={css:i,html:{element:k}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this},el:function(){return k},set:function(a,b){return m[a]=b,this},get:function(a){return m[a]},wire:function(a){h.components.events.on(a,this[a]||function(){},this)},async:function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+o.index++;return o.funcs[c]={args:a,name:b},'<span data-absurd-async="'+c+'"></span>'},child:function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+o.index++;return o.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<span data-absurd-async="'+d+'"></span>'}};return w},l=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}},m=function(b){var c=a.helpers.Extend,d={},e={},f=[];return d.events=c({},j()),d.register=function(a,g){return e[a]=function(){var e=c({},j(d.events),k(a,b),g);return b.di.resolveObject(e),f.push(e),"function"==typeof e.constructor&&e.constructor.apply(e,Array.prototype.slice.call(arguments,0)),e}},d.get=function(a){if(e[a])return e[a];throw new Error("There is no component with name '"+a+"'.")},d.remove=function(a){return e[a]?(delete e[a],!0):!1},d.list=function(){var a=[];for(var b in e)a.push(b);return a},d.flush=function(){return e={},f=[],d},d.broadcast=function(a,b){for(var c=0;c<f.length,instance=f[c];c++)"function"==typeof instance[a]&&instance[a](b);return d},d},n=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){return f={},g=[],i={},e.defaultProcessor=a.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=m(e),e.component=l(e),e.di=a.DI(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.plugins)e.plugin(k,a.plugins[k]());return"function"==typeof b&&b(e),e}};a.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=[],e=this,f=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var g=0;g<b.length;g++)"undefined"!=typeof this.dependencies[b[g]]&&(f=!0);return f?function(){for(var f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];d.push(e.dependencies[h]&&""!=h?e.dependencies[h]:f.shift())}return a.apply(c,d)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},a.api.add=function(a){var b=(h("../helpers/Extend"),h("../helpers/Clone"),[]),c=function(b,c,e,f,g){var h=a.getPlugins()[c];if("undefined"!=typeof h){var i=h(a,e);return i&&d(b,i,f,g),!0}return!1},d=function(a,e,f,g){if(f=f||"mainstream",/, ?/g.test(a))for(var h=a.replace(/, /g,",").split(","),i=0;i<h.length,p=h[i];i++)d(p,e,f,g);else if("undefined"==typeof e.length||"object"!=typeof e){if(!c(null,a,e,f,g)){var j={},k=a,l={},m={};for(var n in e){var o=typeof e[n];"object"!==o&&"function"!==o?c(a,n,e[n],f,g)===!1&&(k="undefined"!=typeof g?g+" "+a:a,j[n]=e[n]):"object"===o?l[n]=e[n]:"function"===o&&(m[n]=e[n])}b.push({selector:k,props:j,stylesheet:f});for(var n in l)":"===n.charAt(0)?d(a+n,l[n],f,g):/&/g.test(n)?d(n.replace(/&/g,a),l[n],f,g):0===n.indexOf("@media")||0===n.indexOf("@supports")?d(a,l[n],n,g):0===a.indexOf("@media")||0===n.indexOf("@supports")?d(n,l[n],a,g):c(a,n,l[n],f,g)===!1&&d(n,l[n],f,(g?g+" ":"")+a);for(var n in m){var q={};q[n]=m[n](),d(a,q,f,g)}}}else for(var i=0;i<e.length,n=e[i];i++)d(a,n,f,g)},e=function(c,e){b=[],a.numOfAddedRules+=1;for(var f in c)d(f,c[f],e||"mainstream");for(var g=0;g<b.length;g++){var e=b[g].stylesheet,f=b[g].selector,h=b[g].props,i=a.getRules(e);if("object"==typeof i[f]){var j=i[f];for(var k in h)"object"!=typeof h[k]&&(j[k]=h[k])}else i[f]=h}return a};return e};var q=h("../helpers/Extend");a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=q(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{t.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var r=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};a.api.darken=function(){return function(a,b){return r(a,-(b/100))}},a.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var r=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};a.api.lighten=function(){return function(a,b){return r(a,b/100)}};var s={html:function(a){a.defaultProcessor=h(i+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=h(i+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};a.api.morph=function(a){return function(b){return s[b]&&(a.flush(),s[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var t=h("fs");h("path")}a.api.rawImport=function(a){var b=function(b){var c=t.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.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},a.helpers.Clone=function M(a){function b(a,b,c){var d,e,f={};for(d in b)e=b[d],d in a&&(a[d]===e||d in f&&f[d]===e)||(a[d]=c?c(e):e);return a}if(!a||"object"!=typeof a||"[object Function]"===Object.prototype.toString.call(a))return a;if(a.nodeType&&"cloneNode"in a)return a.cloneNode(!0);if(a instanceof Date)return new Date(a.getTime());if(a instanceof RegExp)return new RegExp(a);var c,d,e;if(a instanceof Array)for(c=[],d=0,e=a.length;e>d;++d)d in a&&c.push(M(a[d]));else c=a.constructor?new a.constructor:{};return b(c,a,M)},a.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},a.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<arguments.length;c++)b=a(b,arguments[c]);return b},a.helpers.RequireUncached=function(a){return delete h.cache[h.resolve(a)],h(a)},a.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 u=function(a,b,d){var e="",f="",g=[],j=d.api;cssPreprocessor=h(i+"/../css/CSS.js")(),htmlPreprocessor=h(i+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<g.length,l=g[b];b++)"function"==typeof l&&(l=l()),j.add(l.css?l.css:{});cssPreprocessor(j.getRules(),function(b,c){e+=c,a(b)},d)},m=function(b){var c=0,e=null,g=function(){if(c>a.length-1)return b(e),void 0;var h=a[c];"function"==typeof h&&(h=h()),j.morph("html").add(h.html?h.html:{}),htmlPreprocessor(j.getRules(),function(a,b){f+=b,c+=1,e=a,g()},d)};g()},n=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),g.push(c),n(c);else"function"==typeof a[b]&&(a[b]=a[b]()),g.push(a[b]),n(a[b]);else"object"==typeof a[b]&&n(a[b])},o=0;o<a.length,c=a[o];o++)"function"==typeof c&&(c=c()),g.push(c),n(c);j.flush(),k(function(a){j.morph("html"),m(function(c){b(a||c?{error:{css:a,html:c}}:null,e,f)})})};a.processors.component.Component=function(){var a=function(a,b,c){u(a.mainstream,b,c)};return a.type="component",a};var w="\n",x={combineSelectors:!0,minify:!1,keepCamelCase:!1},y=h("../../helpers/TransformUppercase"),z=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+w;else{var e=d+" {"+w;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=b&&b.keepCamelCase===!0?" "+f+": "+g+";"+w:" "+y(f)+": "+g+";"+w}e+="}"+w,c+=e}return c},A=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},B=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")},C=function(a,b){if(b&&b.api&&b.api.getStorage().__defined){var c=b.api.getStorage().__defined;for(var d in c){var e=new RegExp("<%( )?"+d+"( )?%>","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};a.processors.css.CSS=function(){var a=function(a,b,c){c=c||x;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?A(f):f,d+="mainstream"===e?z(f,c):e+" {"+w+z(f,c)+"}"+w}return d=C(d,c),c.minify?(d=B(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},a.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+'";'))}},a.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)}}},a.processors.css.plugins.keyframes=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b)if("undefined"!=typeof b.frames){var d="@keyframes "+b.name+" {\n";d+=c({mainstream:b.frames}),d+="}",a.raw(d+"\n"+d.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var d="@keyframes "+b.name+" {\n",e={},f=0;rule=b.keyframes[f];f++)if("keyframe"===rule.type)for(var g=e[rule.values]={},j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value);d+=c({mainstream:e}),d+="}",a.raw(d+"\n"+d.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@media "+b.media+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}},a.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+'";'))}},a.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)}}},a.processors.css.plugins.supports=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@supports "+b.supports+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}};var D=null,w="\n",x={},E=h("js-beautify").html,F=h("../../helpers/TransformUppercase"),G={},H=function(a){var b="";for(var c in D)if(c==a)for(var d=D[c].length,e=0;d>e;e++)b+=J("",D[c][e]);return b},I=function(a,b){return b&&b.keepCamelCase===!0?a:F(a,b)},J=function(a,b){var c="",d="",e="",f=h("./helpers/PropAnalyzer")(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return K(a,d,b);var g=function(a){""!=e&&(e+=w),e+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)d+="function"==typeof j[k]?" "+I(k,G)+'="'+j[k]()+'"':" "+I(k,G)+'="'+j[k]+'"';break;case"_":g(j);break;case"_tpl":if("string"==typeof j)g(H(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=H(tpl),m<j.length-1&&(l+=w);g(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=J("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);g(l);break;default:switch(typeof j){case"string":g(J(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=J("","function"==typeof v?v():v),m<j.length-1&&(l+=w);g(J(i,l))}else g(J(i,j));break;case"function":g(J(i,j()))}}}return c+=""!=a?K(a,d,e):e},K=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+I(a,G)+b+">"+w+c+w+"</"+I(a,G)+">":"<"+I(a,G)+b+"/>")},L=function(a){return a=h("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),G),G.minify?a:E(a,{indent_size:G.indentSize||4})};return a.processors.html.HTML=function(){var a=function(a,b,c){D=a,b=b||function(){},c=G=c||x;var d=L(H("mainstream"));return b(null,d),d};return a.type="html",a},a.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<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},a.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(if|for|else|switch|case|break|{|}|;))(.*)?/g,f="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(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},n()}(window);

@@ -97,2 +97,35 @@ describe("Adding raw data", function() {

});
describe(".define function", function() {
var api = require('../../index.js')();
it("should use define to register a variable", function(done) {
api.flush().define("brand-color", "#BADA55");
api.add({
body: {
color: '<% brand-color %>',
borderTop: '1px <%brand-color%> dotted'
}
}).compile(function(err, css) {
expect(css).toBe('body{color: #BADA55;border-top: 1px #BADA55 dotted;}');
done();
}, { minify: true });
});
it("should use define to register a function", function(done) {
api.flush().define("brand-color", function() {
return '#BADA55';
});
api.add({
body: {
color: '<% brand-color %>',
borderTop: '1px <% brand-color %> dotted'
}
}).compile(function(err, css) {
expect(css).toBe('body{color: #BADA55;border-top: 1px #BADA55 dotted;}');
done();
}, { minify: true });
});
});
describe("Hooks", function() {

@@ -99,0 +132,0 @@

@@ -162,3 +162,2 @@ lib.DI = function(api) {

allRules = API.getRules(stylesheet);
// console.log(selector, props);
if(typeof allRules[selector] == 'object') {

@@ -252,2 +251,9 @@ var current = allRules[selector];

}
lib.api.define = function(api) {
return function(prop, value) {
if(!api.getStorage().__defined) api.getStorage().__defined = {};
api.getStorage().__defined[prop] = value;
return api;
}
}
lib.api.hook = function(api) {

@@ -642,2 +648,17 @@ return function(method, callback) {

var replaceDefined = function(css, options) {
if(options && options.api && options.api.getStorage().__defined) {
var storage = options.api.getStorage().__defined;
for(var prop in storage) {
var re = new RegExp('<%( )?' + prop + '( )?%>', 'g');
if(typeof storage[prop] != 'function') {
css = css.replace(re, storage[prop]);
} else {
css = css.replace(re, storage[prop]());
}
}
}
return css;
}
lib.processors.css.CSS = function() {

@@ -656,2 +677,3 @@ var processor = function(rules, callback, options) {

}
css = replaceDefined(css, options);
// Minification

@@ -658,0 +680,0 @@ if(options.minify) {

@@ -15,3 +15,4 @@ var path = require("path");

'!lib/api/handlecssimport.js',
'!lib/api/import.js'
'!lib/api/import.js',
'!lib/processors/css/organic/**/*.*'
],

@@ -46,5 +47,7 @@ dest: 'client-side/tmp/absurd.js',

'!tests/common/adding-raw-external-data.spec.js',
'!tests/common/define.external.css.spec.js',
'!tests/metamorphosis/html/morph.html.import.spec.js',
'!tests/metamorphosis/html/morph.html.indentation.spec.js',
'!tests/bugs/css.import.multiple.classes.spec.js',
'!tests/organic/*.js',
],

@@ -51,0 +54,0 @@ dest: 'client-side/tests/tests.from.node.js',

@@ -35,3 +35,3 @@ var fs = require('fs');

registerAPIMethods();
return api;
return _api;
}

@@ -128,3 +128,6 @@

var file = plugins[i];
_api.plugin(file.replace(".js", ""), require(__dirname + "/processors/css/plugins/" + file)());
var stat = fs.statSync(__dirname + "/processors/css/plugins/" + file);
if(stat.isFile()) {
_api.plugin(file.replace(".js", ""), require(__dirname + "/processors/css/plugins/" + file)());
}
}

@@ -134,4 +137,9 @@ }

var registerOrganic = function() {
require(__dirname + "/processors/css/organic").init(_api);
}
registerAPIMethods();
registerPlugins();
registerOrganic();

@@ -138,0 +146,0 @@ return _api;

@@ -110,3 +110,2 @@ module.exports = function(API) {

allRules = API.getRules(stylesheet);
// console.log(selector, props);
if(typeof allRules[selector] == 'object') {

@@ -113,0 +112,0 @@ var current = allRules[selector];

@@ -75,2 +75,17 @@ var newline = '\n',

var replaceDefined = function(css, options) {
if(options && options.api && options.api.getStorage().__defined) {
var storage = options.api.getStorage().__defined;
for(var prop in storage) {
var re = new RegExp('<%( )?' + prop + '( )?%>', 'g');
if(typeof storage[prop] != 'function') {
css = css.replace(re, storage[prop]);
} else {
css = css.replace(re, storage[prop]());
}
}
}
return css;
}
module.exports = function() {

@@ -89,2 +104,3 @@ var processor = function(rules, callback, options) {

}
css = replaceDefined(css, options);
// Minification

@@ -91,0 +107,0 @@ if(options.minify) {

{
"name": "absurd",
"version": "0.2.4",
"version": "0.2.5",
"homepage": "http://krasimir.github.io/absurd",

@@ -5,0 +5,0 @@ "description": "CSS/HTML preprocessor. Check out krasimirtsonev.com/blog/article/AbsurdJS-fundamentals",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc