/*! domx - v0.17.2 - 2017-04-06 * http://esha.github.io/domx/ * Copyright (c) 2017 ESHA Research; Licensed , */ !function(a,b,c){"use strict";c={slice:Array.prototype.slice,zero:function(){return 0},isList:function(a){return a&&"object"==typeof a&&"length"in a&&!a.nodeType||a instanceof NodeList||a instanceof HTMLCollection},define:function(a,b,d,e){if("string"==typeof b)for(var f=0,g=a.length;f0){for(var h=f.split(".");h.length>1&&(g=g[f=h.shift()]););void 0===g?(g=b,f=a):f=h[0]}var i=g[f];if(void 0!==i){if("function"==typeof i&&i.apply)return i.apply(g,d);if(!d)return i;g[f]=d[0]}else if(1===b.nodeType){if(!d)return b.getAttribute(a);null===d[0]?b.removeAttribute(a):b.setAttribute(a,d[0])}},fill:function(a,b,c){for(var d=[],e=0,f=a.length;e1||c.isList(a))for(var d=arguments.length>1?arguments:a,e=0,f=d.length;ef.length);g++)f.add(e[g][d===f.length+1?"querySelector":"querySelectorAll"](a));return f},query:function(a){return this.queryAll(a,1)[0]}}),c.define(b.lists,{only:function(a,c){var d=this.toArray();return d=a>=0||a<0?d.slice(a,c||a+1||void 0):d.filter("function"==typeof a?a:1===arguments.length?function(b){return b[b.matches?"matches":"hasOwnProperty"](a)}:function(b){return(b.each?b.each(a):b[a])===c}),new b.List(d)},not:function(a){var b=a instanceof Node?[a]:this.only.apply(this,arguments);return this.only(function(a){return b.indexOf(a)<0})}}),c.estFnArgs=function(a,b,d,e){if(b=c.alias[b]||b,b in a||(e=void 0===d?"boolean"!=typeof b||b:d,d=b,b="parentElement"),"boolean"==typeof d&&(e=d,d=null),d){if("string"==typeof d){var f=d;d=function(a){return a.matches&&a.matches(f)}}}else d=function(){return!0};return[b,d,e||!1]},c.define(b.nodes,"farthest",function(a,b,d){var e=c.estFnArgs(this,a,b,d);return c.farthest(this,e[0],e[1],e[2]&&e[1](this)?this:null)}),c.farthest=function(a,b,d,e){return a&&(a=a[b])?c.farthest(a,b,d,d(a)?a:e):e},c.define(b.nodes,"nearest",function(a,b,d){var e=c.estFnArgs(this,a,b,d);return e[2]&&e[1](this)?this:c.nearest(this,e[0],e[1])}),c.nearest=function(a,b,d){return a&&(a=a[b])?d(a)?a:c.nearest(a,b,d):null},c.define(b.nodes,"closest",function(a){return this.nearest(a?a+"":"*",!0)}),b.add("all",function(a,d,e,f){d===!0&&(e=d,d=void 0),f=f||new b.List;var g=e?this:this[c.alias[a]||a];if(g){var h=d&&d.call(this,g,f);null!==h&&f.add(h||g),!g.all||!g.length&&c.isList(g)||g.all(a,d,!1,f)}return f},[Node]);var d=Element.prototype,e="atchesSelector";c.defprop(d,"matches",d.m||d["webkitM"+e]||d["mozM"+e]||d["msM"+e]);var f=c.insert={create:function(b,c,d){return f.insert(b,a.createElement(c),d)},insert:function(a,b,c){var d=f.find(a,c);return d?a.insertBefore(b,d):a.appendChild(b),b},find:function(a,b){switch(typeof b){case"string":return a[b]||a.only(b);case"number":return a.children[b];case"object":return b;case"function":return b.call(a,a)}}};b.add("insert",function(a,d){if("string"==typeof a)return f.create(this,a,d);if(c.isList(a)){for(var e=new b.List,g=0,h=a.length;g"]).call(a,g,d)||a}return a};var h=g.emmet={"#":function(a){this.each("id",a)},".":function(a){this.each("classList.add",a)},"[":function a(b){b=b.substr(0,b.length-1).match(/(?:[^\s"]+|("[^"]+"))+/g);for(var c=0,d=b.length;c":function(d){var e=this;return d.charAt(0)in h?c.emmet(e,d):this instanceof b.List?this.insert(d):(e=a.createElement(d),this.appendChild(e),e)},"*":function(a,c){for(var d=h.parent(this)||c,e=new b.List(this),f=1;f"].call(h.parent(this),a)},"^":function(a){return h["+"].call(h.parent(this),a)},",":function(a,b){return h[">"].call(b,a)},ends:{"[":"]","{":"}","(":")"},parent:function(a){return a&&(a.parentNode||a.each("parentNode")[0])},split:/(?=\#|\,|\.|\[|\>|\+|\*|\^|\{|\()/g,next:function(a){var b=a.shift(),c=b&&h.ends[b.charAt(0)];if(c){for(;c!==b[b.length-1]||"\\"===b[b.length-2];)b+=a.shift()||c;b=b.replace(new RegExp("\\\\\\"+c,"g"),c)}return b}};c.defprop(a,"html",a.documentElement);var i=c.dot={names:{3:"$text",8:"$comment",7:"$procins"},fns:{},fn:function(a,b){return i.fns[b]||(i.fns[b]=1===a?function(){return this.each("children").only(b).dot()}:function(){return this.each("childNodes").only("nodeType",a)})},init:function(){a.queryAll("[x-dot]").each(function(a){a.dot(!0),j&&!a._observer&&(a._observer=new j(function(a){for(var b=0,c=a.length;b=0&&b(e)}},combine:function(a,b,c){return void 0===a||a===b||c&&null===a?b:Array.isArray(a)?(a.indexOf(b)<0&&a.push(b),a):[a,b]},getNameValue:function(a,b){return V.nameNodes(a,function(a,c){b[a]=V.combine(b[a],c.nameValue)},function(a){V.getNameValue(a,b)},function(a){b[a.name]=a.baseValue}),b},setNameValue:function(a,b){V.nameNodes(a,function(a,c){var d=V.resolve(b,a);void 0!==d&&(c.nameValue=d)},function(a){V.setNameValue(a,b)},function(a){var c=V.resolve(b,a.name);void 0!==c&&(a.baseValue=c)})},booleanAttr:function(a){return{get:function(){return this.hasAttribute(a)},set:function(b){this[b?"setAttribute":"removeAttribute"](a,!0)}}},nameRE:/\$\{([^}]+)\}/,changeEvent:window.CustomEvent?function(a){a.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}:function(a){var b=D.createEvent("CustomEvent");b.initCustomEvent("change",!0),a.dispatchEvent(b)}};_.define([Node],{value:{get:function(){return this.hasAttribute&&this.hasAttribute("value")?this.getAttribute("value"):this.textContent},set:function(a){this.hasAttribute&&this.hasAttribute("value")?this.setAttribute("value",a):this.textContent=a}},baseValue:{get:function(){return V.parse(this.value)},set:function(a){this.value!==(this.value=V.string(a))&&V.changeEvent(this)}},useBaseValue:function(){var a=this.childNodes;return!(!this.noSubNames&&a.length)||!(a.length>1||a[0].name||this.children.length)&&(!a[0].splitOnName||!a[0].splitOnName())},nameParent:{get:function(){for(var a,b=this;a=b.parentNode;){if(V.name(a)||a.hasAttribute&&a.hasAttribute("x-value-parent"))return a;b=a}return b===this?null:b}},nameGroup:{get:function(){var a=this,b=V.name(a);return b?a.parentNode?a.nameParent.queryNameAll(b):new X.List(a):null}},nameValue:{get:function(){var a;return V.name(this)&&this.nameGroup.each(function(b){a=V.combine(a,b.xValue)}),a||this.xValue},set:function(a){if(V.name(this)&&Array.isArray(a)){var b=this.nameGroup;for(_.repeat&&!a.length&&b.length&&!b[0].hasAttribute(_.repeat.id)&&_.repeat.init(b[0],!0),b.each(function(b,c){c=0)for(var l=0;l0&&(a.splitText(c),a.noSubNames=!0,a=a.nextSibling),a.textContent.length>d.length&&a.splitText(d.length),a.name=b[1],a.textContent=""}return a.noSubNames=!0,!!b}},!0),_.define([HTMLInputElement],{checkable:{get:function(){return"radio"===this.type||"checkbox"===this.type}},xValue:{get:function(){return!this.checkable||this.checked?this.baseValue:null},set:function(a){this.nameValue=a}},nameValue:{get:function(){if(this.checkable){var a,b=this.nameGroup||new X.List(this);return b.each(function(b){a=V.combine(a,b.xValue,!0)}),!Array.isArray(a)||"radio"!==this.type&&1!==b.length?a:a[0]}return this.baseValue},set:function(a){var b=this;if(b.checkable&&("on"!==b.value&&""!==b.value||b.hasAttribute("value"))){a=(Array.isArray(a)?a:[a]).map(V.stringifyFor(b));var c=!1;(b.nameGroup||new X.List(b)).each(function(b){var d=b.checked;b.checked=a.indexOf(b.value)>=0,d!==b.checked&&(c=!0)}),c&&V.changeEvent(b)}else b.baseValue=a}}},!0),_.define([HTMLSelectElement],{xValue:{get:function(){if(this.multiple){var a=this.children.only("selected",!0);return a.length?a.each("xValue"):this.children.length>1?[]:null}return V.parse(this.baseValue)},set:function(a){if(this.multiple){a=(Array.isArray(a)?a:[a]).map(V.string);var b=!1;this.children.each(function(c){var d=c.selected;c.selected=a.indexOf(c.value)>=0,c.select!==d&&(b=!0)}),b&&V.changeEvent(this)}else this.baseValue=a}}},!0),_.define([HTMLLIElement],{baseProperty:{get:function(){return this.parentNode instanceof HTMLOListElement?"value":"textContent"}}},!0),_.define([HTMLOptionElement],{baseProperty:{get:function(){return this.hasAttribute("value")?"value":"textContent"}}},!0)}(document),function(a){"use strict";var b=a.x,c=b._,d=c.repeat={id:"x-repeat-id",each:"x-repeat-each",context:"html,[x-repeat-init]",count:0,initAll:function(){a.queryAll(d.context).each(function(b){var c=b.getAttribute("x-repeat-init")||"DOMContentLoaded",e=function(){a.removeEventListener(c,e),b.queryAll("[x-repeat]").not("["+d.id+"]").each(d.init)};"true"!==c&&(b.setAttribute("x-repeat-init","true"),a.addEventListener(c,e))})},init:function(b,e){var f=b.getAttribute("x-repeat"),g=d.count++,h=f&&a.query(f).cloneNode(!0)||b,i=a.createElement("x-repeat");h.setAttribute(d.id,g),i.setAttribute(d.id,g);for(var j=0,k=b.attributes.length;j