0&&"\n"!==e[i];i--,r++);for(;i>0;i--)"\n"===e[i]&&s++;throw new Error(t+" at line "+s+","+r+" >>>"+e.substr(n-r,20)+" ...")}function o(){return i=e.charAt(n),n++,i}function d(t){return e.charAt(n+t)}function u(t){for(var e="",n=i;o();){if(i===n)return o(),t&&"'"===n&&"'"===i&&0===e.length?(o(),c()):e;if("\\"===i)if(o(),"u"===i){for(var s=0,d=0;d<4;d++){o();var u,h=i.charCodeAt(0);i>="0"&&i<="9"?u=h-48:i>="a"&&i<="f"?u=h-97+10:i>="A"&&i<="F"?u=h-65+10:a("Bad \\u char "+i),s=16*s+u}e+=String.fromCharCode(s)}else{if("string"!=typeof r[i])break;e+=r[i]}else"\n"===i||"\r"===i?a("Bad string containing newline"):e+=i}a("Bad string")}function c(){for(var t="",e=0,n=0;;){var r=d(-n-5);if(!r||"\n"===r)break;n++}function s(){for(var t=n;i&&i<=" "&&"\n"!==i&&t-- >0;)o()}for(;i&&i<=" "&&"\n"!==i;)o();for("\n"===i&&(o(),s());;){if(i){if("'"===i){if(e++,o(),3===e)return"\n"===t.slice(-1)&&(t=t.slice(0,-1)),t;continue}for(;e>0;)t+="'",e--}else a("Bad multiline string");"\n"===i?(t+="\n",o(),s()):("\r"!==i&&(t+=i),o())}}function h(){if('"'===i||"'"===i)return u(!1);for(var t="",e=n,r=-1;;){if(":"===i)return t?r>=0&&r!==t.length&&(n=e+r,a("Found whitespace in your key name (use quotes to include)")):a("Found ':' but no key name (for an empty key name use quotes)"),t;i<=" "?i?r<0&&(r=t.length):a("Found EOF while looking for a key name (check your syntax)"):s(i)?a("Found '"+i+"' where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace)"):t+=i,o()}}function l(){for(;i;){for(;i&&i<=" ";)o();if("#"===i||"/"===i&&"/"===d(0))for(;i&&"\n"!==i;)o();else{if("/"!==i||"*"!==d(0))break;for(o(),o();i&&("*"!==i||"/"!==d(0));)o();i&&(o(),o())}}}function p(t,e){var n,i,r="",s=0,a=!0,o=0;function d(){return i=t.charAt(o),o++,i}for(d(),"-"===i&&(r="-",d());i>="0"&&i<="9";)a&&("0"==i?s++:a=!1),r+=i,d();if(a&&s--,"."===i)for(r+=".";d()&&i>="0"&&i<="9";)r+=i;if("e"===i||"E"===i)for(r+=i,d(),"-"!==i&&"+"!==i||(r+=i,d());i>="0"&&i<="9";)r+=i,d();for(;i&&i<=" ";)d();return e&&(","!==i&&"}"!==i&&"]"!==i&&"#"!==i&&("/"!==i||"/"!==t[o]&&"*"!==t[o])||(i=0)),n=+r,i||s||!isFinite(n)?void 0:n}function f(t){function e(t,n){var i,r,s,a;switch(typeof t){case"string":t.indexOf(n)>=0&&(a=t);break;case"object":if("[object Array]"===Object.prototype.toString.apply(t))for(i=0,s=t.length;i "+i+"\n (unquoted strings contain everything up to the next line!)":""}return n("}")||n("]")}function m(){var t=[];try{if(o(),l(),"]"===i)return o(),t;for(;i;){if(t.push(x()),l(),","===i&&(o(),l()),"]"===i)return o(),t;l()}a("End of input while parsing an array (missing ']')")}catch(e){throw e.hint=e.hint||f(t),e}}function v(t){var e="",n={};try{if(t||o(),l(),"}"===i&&!t)return o(),n;for(;i;){if(e=h(),l(),":"!==i&&a("Expected ':' instead of '"+i+"'"),o(),n[e]=x(),l(),","===i&&(o(),l()),"}"===i&&!t)return o(),n;l()}if(t)return n;a("End of input while parsing an object (missing '}')")}catch(t){throw t.hint=t.hint||f(n),t}}function x(){switch(l(),i){case"{":return v();case"[":return m();case"'":case'"':return u(!0);default:return function(){var t=i;for(s(i)&&a("Found a punctuator character '"+i+"' when expecting a quoteless string (check your syntax)");;){o();var e="\r"===i||"\n"===i||""===i;if(e||","===i||"}"===i||"]"===i||"#"===i||"/"===i&&("/"===d(0)||"*"===d(0))){var n=t[0];switch(n){case"f":if("false"===t.trim())return!1;break;case"n":if("null"===t.trim())return null;break;case"t":if("true"===t.trim())return!0;break;default:if("-"===n||n>="0"&&n<="9"){var r=p(t);if(void 0!==r)return r}}if(e)return t.trim()}t+=i}}()}}function y(t){return l(),i&&a("Syntax error, found trailing characters"),t}if("string"!=typeof t)throw new Error("source is not a string");return e=t,n=0,i=" ",function(){switch(l(),i){case"{":return y(v());case"[":return y(m());default:return y(x())}}()}),dmx.Flow=dmx.createClass({constructor:function(t){if(!(this instanceof dmx.Flow))return new dmx.Flow(t);window.Promise||console.warn("Promises are not supported, flows can not be used"),this._execStep=this._execStep.bind(this),this.scope=new dmx.DataScope({},t),this.output={}},run:function(t){var e=this;return this.output={},this._exec(t.exec||t).then((function(){return dmx.debug&&console.debug("finished",e.output),e.output}))},_each:function(t,e){return Promise.resolve(t).then((function(t){return(t=Array.isArray(t)?t:[t]).reduce((function(n,i,r){return n.then((function(){return e(i,r,t.length).then((function(e){e&&(t[r]=e)}))}))}),Promise.resolve()).then((function(){return t}))}))},_exec:function(t){var e=this;if(t.steps){var n=this._each(t.steps,this._execStep);return t.catch&&n.catch((function(n){return e._each(t.catch,e._execStep)})),n}return this._each(t,this._execStep)},_execStep:function(t){var e=this;for(var n in dmx.debug&&console.debug("exec step",t),t){if(t.hasOwnProperty(n)&&dmx.__actions[n]){var i=dmx.__actions[n].bind(this),r=t[n];return dmx.debug&&console.debug("exec action",n,r),r.disabled?Promise.resolve():Promise.resolve(i(r)).then((function(t){r.name&&(dmx.debug&&console.debug("set data",r.name,t),e.scope.set(r.name,t),r.output&&(dmx.debug&&console.debug("set output",r.name,t),e.output[r.name]=t))}))}throw new Error("Action "+n+" was not found.")}},parse:function(t){if(null==t)return t;if("object"==typeof(t=t.valueOf())){var e=t.slice?[]:{};for(var n in t)t.hasOwnProperty(n)&&(e[n]=this.parse(t[n],this.scope));return e}return"string"==typeof t&&-1!=t.indexOf("{{")?dmx.parse(t,this.scope):t}}),dmx.Flow.run=function(t,e){return new dmx.Flow(e).run(t)},dmx.Component("app",{constructor:function(t,e){this.onload=this.onload.bind(this),dmx.BaseComponent.call(this,t,e)},initialData:{query:{}},attributes:{},methods:{},events:{ready:Event,load:Event},render:function(t){this.parseQuery(),this.$parse(),window.removeEventListener("load",this.onload),window.addEventListener("load",this.onload),dmx.nextTick((function(){this.dispatchEvent("ready")}),this)},update:function(){this.parseQuery()},onload:function(){this.dispatchEvent("load")},parseQuery:function(){var t="";window.location.search?t=window.location.search.substr(1):window.location.hash.indexOf("?")&&(t=window.location.hash.substr(window.location.hash.indexOf("?")+1)).indexOf("#")>0&&(t=t.substr(0,t.indexOf("#")));var e=t.split("&").reduce((function(t,e){var n=e.replace(/\+/g," ").split("=");return n[0]&&(t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]||"")),t}),{}),n=document.querySelector('meta[name="ac:base"]'),i=document.querySelector('meta[name="ac:route"]');if(i&&i.content){var r=[],s=i.content;n&&n.content&&(s=n.content.replace(/\/$/,"")+s);var a=dmx.pathToRegexp(s,r,{end:!1}).exec(decodeURI(window.location.pathname));a&&r.forEach((function(t,n){e[t.name]=a[n+1]}))}this.set("query",e)}}),dmx.Component("form",{tag:"form",attributes:{novalidate:{type:Boolean,default:!1}},methods:{submit:function(t){t?this._submit():this.submit()},reset:function(){this.reset()},validate:function(){this.validate()}},events:{invalid:Event,submit:Event},render:function(t){dmx.BaseComponent.prototype.render.call(this,t),this.$node.noValidate=!0,this.$node.addEventListener("submit",this.onsubmit.bind(this)),this.$node.addEventListener("reset",this.onreset.bind(this))},submit:function(t){if(this.props.novalidate||this.validate())this.dispatchEvent("submit",{cancelable:!0})&&this._submit();else{dmx.requestUpdate(),this.dispatchEvent("invalid");var e=dmx.array(this.$node.elements).find((function(t){if(!t.validity.valid)return!0}));e&&e.focus()}},_submit:function(){HTMLFormElement.prototype.submit.call(this.$node)},reset:function(){HTMLFormElement.prototype.reset.call(this.$node)},validate:function(){return dmx.validate(this.$node)},onsubmit:function(t){t.preventDefault(),this.submit()},onreset:function(t){dmx.validateReset(this.$node),window.grecaptcha&&this.$node.querySelector(".g-recaptcha")&&grecaptcha.reset(),dmx.requestUpdate()}}),dmx.Component("form-element",{constructor:function(t,e){this.updateData=dmx.debounce(this.updateData.bind(this)),dmx.BaseComponent.call(this,t,e)},initialData:{value:"",disabled:!1,validationMessage:"",invalid:!1,focused:!1},attributes:{value:{type:String,default:""},disabled:{type:Boolean,default:!1}},methods:{setValue:function(t){this.setValue(t)},focus:function(){this.focus()},disable:function(t){this.disable(t)},validate:function(){this.validate()}},events:{updated:Event,changed:Event},render:function(t){dmx.BaseComponent.prototype.render.call(this,t),this.$node.value=this.props.value||"",this.$node.disabled=this.props.disabled,this.$node.defaultValue=this.props.value||"",this.$node.addEventListener("input",this.updateData.bind(this)),this.$node.addEventListener("change",this.updateData.bind(this)),this.$node.addEventListener("invalid",this.updateData.bind(this)),this.$node.addEventListener("focus",this.updateData.bind(this)),this.$node.addEventListener("blur",this.updateData.bind(this)),this.updateData()},update:function(t,e){e.has("value")&&(this.$node.defaultValue=this.props.value||"",this.setValue(this.props.value)),t.disabled!=this.props.disabled&&(this.$node.disabled=this.props.disabled),this.updateData()},updateData:function(t){t&&this.$node.dirty&&dmx.validate(this.$node),this.$node.value!==this.data.value&&dmx.nextTick((function(){this.dispatchEvent("updated"),t&&this.dispatchEvent("changed")}),this),this.set("value",this.$node.value),this.set("disabled",this.$node.disabled),this.set("focused",this.$node===document.activeElement),this.$node.dirty&&(this.set("invalid",!this.$node.validity.valid),this.set("validationMessage",this.$node.validationMessage))},setValue:function(t){this.$node.value=t||"",this.updateData()},focus:function(){this.$node.focus()},disable:function(t){this.$node.disabled=!0===t,this.updateData()},validate:function(){dmx.validate(this.$node),this.updateData()}}),dmx.Component("textarea",{extends:"form-element",tag:"textarea",render:function(t){if(!this.props.value){var e=this.$node.value;-1!==e.indexOf("{{")?this.props.value=dmx.parse(e,this):this.props.value=e}dmx.Component("form-element").prototype.render.call(this,t)}}),dmx.Component("input",{extends:"form-element",tag:"input"}),dmx.Component("input-file",{extends:"input",initialData:{file:null},render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.$node.addEventListener("change",this.onchange.bind(this)),this.$node.form&&this.$node.form.addEventListener("reset",this.onchange.bind(this))},onchange:function(){var t=null;if(this.$node.files.length){var e=this.$node.files[0];t={date:(e.lastModified?new Date(e.lastModified):e.lastModifiedDate).toISOString(),name:e.name,size:e.size,type:e.type,dataUrl:null},-1===e.type.indexOf("image/")||e.reader||(e.reader=new FileReader,e.reader.onload=function(e){t.dataUrl=e.target.result,dmx.requestUpdate()},e.reader.readAsDataURL(e))}this.set("file",t)},setValue:function(){console.warn("Can not set value of a file input!")}}),dmx.Component("input-file-multiple",{extends:"input",initialData:{files:[]},render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.$node.addEventListener("change",this.onchange.bind(this)),this.$node.form&&this.$node.form.addEventListener("reset",this.onchange.bind(this))},onchange:function(){var t=Array.prototype.slice.call(this.$node.files).map((function(t){var e={date:(t.lastModified?new Date(t.lastModified):t.lastModifiedDate).toISOString(),name:t.name,size:t.size,type:t.type,dataUrl:null};return-1===t.type.indexOf("image/")||t.reader||(t.reader=new FileReader,t.reader.onload=function(t){e.dataUrl=t.target.result,dmx.requestUpdate()},t.reader.readAsDataURL(t)),e}));this.set("files",t)},setValue:function(){console.warn("Can not set value of a file input!")}}),dmx.Component("input-number",{extends:"input",render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.set("value",+this.props.value)},updateData:function(t){t&&this.$node.dirty&&dmx.validate(this.$node),this.$node.value!==this.data.value&&dmx.nextTick((function(){this.dispatchEvent("updated"),t&&this.dispatchEvent("changed")}),this),this.set("value",this.$node.value?+this.$node.value:null),this.set("disabled",this.$node.disabled),this.$node.dirty&&(this.set("invalid",!this.$node.validity.valid),this.set("validationMessage",this.$node.validationMessage))}}),dmx.Component("button",{extends:"form-element",tag:"button",attributes:{type:{type:String,default:"button",validate:function(t){return/^(button|submit|reset)$/i.test(t)}}},render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.$node.type=this.props.type}}),dmx.Component("radio",{extends:"form-element",initialData:{checked:!1},tag:"input",attributes:{checked:{type:Boolean,default:!1}},methods:{select:function(t){this.select(t)}},render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.$node.addEventListener("click",this.updateData.bind(this)),this.$node.type="radio",this.$node.checked=this.props.checked,this.$node.defaultChecked=this.props.checked,this.set("checked",this.props.checked)},update:function(t,e){dmx.Component("form-element").prototype.update.call(this,t,e),t.checked!==this.props.checked&&(this.$node.checked=this.props.checked,this.$node.defaultChecked=this.props.checked),this.updateData()},updateData:function(t){dmx.Component("form-element").prototype.updateData.call(this,t),this.data.checked!=this.$node.checked&&dmx.nextTick((function(){this.dispatchEvent("updated"),t&&this.dispatchEvent("changed")}),this),this.set("checked",this.$node.checked)},select:function(t){this.$node.checked=!1!==t}}),dmx.Component("radio-group",{initialData:{value:""},tag:"div",attributes:{value:{type:String,default:""}},methods:{setValue:function(t){this.setValue(t)}},events:{updated:Event},render:function(t){dmx.BaseComponent.prototype.render.call(this,t),this.setValue(this.props.value)},update:function(t){dmx.BaseComponent.prototype.update.call(this,t),t.value!=this.props.value&&(this.updateValue=!0,dmx.nextTick((function(){this.dispatchEvent("updated")}),this))},updated:function(){this.updateValue&&(this.updateValue=!1,this.setValue(this.props.value,!0));var t=Array.prototype.slice.call(this.$node.querySelectorAll("input[type=radio]")).filter((function(t){return!t.disabled&&t.checked})).map((function(t){return t.value}));dmx.equal(this.data.value,t[0])||(this.set("value",t[0]),dmx.nextTick((function(){this.dispatchEvent("updated")}),this))},setValue:function(t,e){Array.prototype.slice.call(this.$node.querySelectorAll("input[type=radio]")).forEach((function(n){n.checked=n.value==t,e&&(n.defaultChecked=n.checked)})),this.updated()}}),dmx.Component("checkbox",{extends:"form-element",initialData:{checked:!1},tag:"input",attributes:{checked:{type:Boolean,default:!1}},methods:{select:function(t){this.select(t)}},events:{checked:Event,unchecked:Event},render:function(t){dmx.Component("form-element").prototype.render.call(this,t),this.$node.addEventListener("click",this.updateData.bind(this)),this.$node.type="checkbox",this.$node.checked=this.props.checked,this.$node.defaultChecked=this.props.checked,this.set("checked",this.props.checked)},update:function(t,e){dmx.Component("form-element").prototype.update.call(this,t,e),t.checked!==this.props.checked&&(this.$node.checked=this.props.checked,this.$node.defaultChecked=this.props.checked),this.updateData()},updateData:function(t){dmx.Component("form-element").prototype.updateData.call(this,t),this.data.checked!=this.$node.checked&&dmx.nextTick((function(){this.dispatchEvent("updated"),t&&(this.dispatchEvent("changed"),this.dispatchEvent(this.$node.checked?"checked":"unchecked"))}),this),this.set("checked",this.$node.checked)},select:function(t){this.$node.checked=!1!==t}}),dmx.Component("checkbox-group",{initialData:{value:[]},tag:"div",attributes:{value:{type:Array,default:[]}},methods:{setValue:function(t){this.setValue(t)}},events:{updated:Event},render:function(t){dmx.BaseComponent.prototype.render.call(this,t),this.setValue(this.props.value)},update:function(t,e){dmx.BaseComponent.prototype.update.call(this,t,e),e.has("value")&&(this.updateValue=!0)},updated:function(){this.updateValue&&(this.updateValue=!1,this.setValue(this.props.value));var t=Array.prototype.slice.call(this.$node.querySelectorAll("input[type=checkbox]")).filter((function(t){return!t.disabled&&t.checked})).map((function(t){return t.value}));dmx.equal(this.data.value,t)||(this.set("value",t),dmx.nextTick((function(){this.dispatchEvent("updated")}),this))},setValue:function(t,e){Array.isArray(t)||(t=[t]),Array.prototype.slice.call(this.$node.querySelectorAll("input[type=checkbox]")).forEach((function(n){n.checked=t.indexOf(n.value)>-1,e&&(n.defaultChecked=n.checked)})),this.updated()}}),dmx.Component("select",{extends:"form-element",initialData:{selectedIndex:-1,selectedValue:"",selectedText:""},tag:"select",attributes:{options:{type:Array,default:[]},optionText:{type:String,default:"$value"},optionValue:{type:String,default:"$value"}},methods:{setSelectedIndex:function(t){this.$node.selectedIndex=t,this.updateData()}},render:function(t){this.options=[],this.props.value?this.updateValue=!0:this.props.value=this.$node.value,dmx.BaseComponent.prototype.render.call(this,t),this.$node.disabled=this.props.disabled,this.$node.addEventListener("change",this.updateData.bind(this)),this.$node.addEventListener("invalid",this.updateData.bind(this)),this.$node.addEventListener("focus",this.updateData.bind(this)),this.$node.addEventListener("blur",this.updateData.bind(this)),this.renderOptions(),this.updateData()},update:function(t,e){e.has("options")&&(this.renderOptions(),this.updateValue=!0),e.has("value")&&(this.updateValue=!0),t.disabled!=this.props.disabled&&(this.$node.disabled=this.props.disabled),this.updateData()},updated:function(){this.updateValue&&(this.updateValue=!1,this.setValue(this.props.value,!0),this.updateData())},updateData:function(t){dmx.Component("form-element").prototype.updateData.call(this,t);var e=this.$node.selectedIndex;this.set("selectedIndex",e),this.set("selectedValue",this.$node.options[e]&&this.$node.options[e].value||""),this.set("selectedText",this.$node.options[e]&&this.$node.options[e].text||"")},setValue:function(t,e){dmx.array(this.$node.options).forEach((function(n){n.selected=n.value==t,e&&(n.defaultSelected=n.selected)}))},renderOptions:function(){this.options.splice(0).forEach((function(t){dmx.dom.remove(t)})),dmx.repeatItems(this.props.options).forEach((function(t){"object"!=typeof t&&(t={$value:t});var e=document.createElement("option");e.value=dmx.parse(this.props.optionValue,dmx.DataScope(t,this)),e.innerText=dmx.parse(this.props.optionText,dmx.DataScope(t,this)),this.options.push(this.$node.appendChild(e))}),this)}}),dmx.Component("select-multiple",{extends:"select",initialData:{value:[]},attributes:{value:{type:Array,default:null}},methods:{setSelectedIndex:function(t){this.$node.selectedIndex=t,this.updateData()}},update:function(t,e){e.has("options")&&(this.renderOptions(),this.updateValue=!0),e.has("value")&&(this.updateValue=!0),t.disabled!=this.props.disabled&&(this.$node.disabled=this.props.disabled),this.updateData()},updateData:function(t){var e=Array.prototype.slice.call(this.$node.options).filter((function(t){return t.selected})).map((function(t){return t.value}));dmx.equal(this.data.value,e)||dmx.nextTick((function(){this.dispatchEvent("updated"),t&&this.dispatchEvent("changed")}),this),this.set("value",e),this.set("disabled",this.$node.disabled),this.set("invalid",!this.$node.validity.valid),this.set("focused",this.$node===document.activeElement),this.set("validationMessage",this.$node.validationMessage);var n=this.$node.selectedIndex;this.set("selectedIndex",n),this.set("selectedValue",this.$node.options[n]&&this.$node.options[n].value||""),this.set("selectedText",this.$node.options[n]&&this.$node.options[n].text||"")},setValue:function(t,e){Array.isArray(t)||(t=[t]),t=t.map((function(t){return t.toString()})),dmx.array(this.$node.options).forEach((function(n){n.selected=t.indexOf(n.value)>-1,e&&(n.defaultSelected=n.selected)}))}}),dmx.Component("value",{initialData:{value:null},attributes:{value:{default:null}},methods:{setValue:function(t){this.data.value!==t&&(this.set("value",t),dmx.nextTick((function(){this.dispatchEvent("updated")}),this))}},events:{updated:Event},render:function(){this.set("value",this.props.value)},update:function(t,e){e.has("value")&&(this.set("value",this.props.value),dmx.nextTick((function(){this.dispatchEvent("updated")}),this))}}),dmx.Component("repeat",{initialData:{items:[]},attributes:{repeat:{type:[Array,Object,Number],default:[]},key:{type:String,default:""},rerender:{type:Boolean,default:!1}},events:{update:Event,updated:Event},render:function(t){for(this.prevItems=[],this.childKeys={},this.$template=document.createDocumentFragment();this.$node.hasChildNodes();)this.$template.appendChild(this.$node.firstChild);this.update({repeat:[]},new Set(["repeat"]))},update:function(t,e){e.has("repeat")&&(e.has("key")&&(this._rerender=!0),this._willUpdate||(this._willUpdate=!0,dmx.nextTick(this._update,this)))},_update:function(){this._willUpdate=!1,this.dispatchEvent("update"),(this.props.rerender||this._rerender)&&(this._rerender=!1,this._clear());var t=dmx.Component("repeat-item"),e=this.props.repeat,n=dmx.repeatItems(e);if(n.length){if(!this.props.rerender&&this.props.key&&n[0].hasOwnProperty(this.props.key)&&this.prevItems.length){var i,r,s=this.props.key,a=this.prevItems,o=this._clone(n),d=0,u=0,c=a.length-1,h=o.length-1;t:for(;;){for(;a[d][s]===o[u][s];)if(this.childKeys[o[u][s]].set(o[u]),u++,++d>c||u>h)break t;for(;a[c][s]===o[h][s];)if(this.childKeys[o[h][s]].set(o[h]),h--,d>--c||u>h)break t;if(a[c][s]!==o[u][s]){if(a[d][s]!==o[h][s])break;if(r=h+1,this.childKeys[o[h][s]].set(o[h]),this._moveChild(o[h][s],o[r]&&o[r][s]),h--,++d>c||u>h)break}else if(this.childKeys[o[u][s]].set(o[u]),this._moveChild(o[u][s],a[d][s]),u++,d>--c||u>h)break}if(d>c)for(r=h+1;u<=h;)this._insertChild(o[u++],o[r]&&o[r][s]);else if(u>h)for(;d<=c;)this._removeChild(a[d++][s]);else{var l=c-d+1,p=h-u+1,f=a,m=new Array(p).fill(-1),v=!1,x=0,y=0;if(p<=4||l*p<=16){for(w=d;w<=c;w++)if(yi?v=!0:x=i,this.childKeys[o[i][s]].set(o[i]),y++,f[w]=null;break}}else{var g={};for(w=u;w<=h;w++)g[o[w][s]]=w;for(w=d;w<=c;w++)y
i?v=!0:x=i,this.childKeys[o[i][s]].set(o[i]),y++,f[w]=null)}if(l===a.length&&0===y)for(this._clear();u
0;)null!==f[d]&&(this._removeChild(a[d][s]),w--),d++;if(v){var b=this._lis(m);for(i=b.length-1,w=p-1;w>=0;w--)-1===m[w]?(r=(x=w+u)+1,this._insertChild(o[x],o[r]&&o[r][s])):i<0||w!==b[i]?(r=(x=w+u)+1,this._moveChild(o[x][s],o[r]&&o[r][s])):i--}else if(y!==p)for(w=p-1;w>=0;w--)-1===m[w]&&(r=(x=w+u)+1,this._insertChild(o[x],o[r]&&o[r][s]))}}}else if(this.children.length>n.length&&this.children.splice(n.length).forEach((function(t){t.$destroy()})),this.children.length&&this.children.forEach((function(t,e){t.set(n[e])})),n.length>this.children.length){for(var E=document.createDocumentFragment(),w=this.children.length;wt.data))),dmx.nextTick((()=>this.dispatchEvent("updated")))},_lis:function(t){var e,n,i=t.slice(0),r=[];r.push(0);for(var s=0,a=t.length;s0&&(i[s]=r[e-1]),r[e]=s)}}for(n=r[(e=r.length)-1];e-- >0;)r[e]=n,n=i[n];return r},_clear:function(){this.prevItems=[],this.childKeys={},this.children.splice(0).forEach((function(t){t.$destroy()})),this.$node.innerHTML=""},_insertChild:function(t,e){var n=new(dmx.Component("repeat-item"))(this.$template.cloneNode(!0),this,t);n.$nodes.forEach((function(t){e?this.childKeys[e]?this.$node.insertBefore(t,this.childKeys[e].$nodes[0]):console.warn("(insert) can not insert node before key "+e+"!"):this.$node.appendChild(t),n.$parse(t)}),this),this.childKeys[t[this.props.key]]=n,this.children.push(n)},_moveChild:function(t,e){var n=this.childKeys[t];n?this.childKeys[e]?n.$nodes.forEach((function(t){this.$node.insertBefore(t,this.childKeys[e].$nodes[0])}),this):n.$nodes.forEach((function(t){this.$node.appendChild(t)}),this):console.warn("(move) child with key "+t+" not found!")},_removeChild:function(t){var e=this.childKeys[t];e?(e.$destroy(),this.children.splice(this.children.indexOf(e),1),delete this.childKeys[t]):console.warn("(remove) child with key "+t+" not found!")},_clone:function(t){return dmx.clone(t)}}),dmx.Component("repeat-item",{constructor:function(t,e,n,i){this.parent=e,this.bindings={},this.propBindings={},this.children=[],this.listeners=[],this.props={},this.data=dmx.clone(n||{}),this.seed=e.seed,this.name=i||"repeat",this.$nodes=[];for(var r=0;rthis.fetch())))},abort:function(){this.xhr&&this.xhr.abort()},fetch:function(t){this.xhr.abort(),t=dmx.extend(!0,this.props,t||{}),this._reset(),this.dispatchEvent("start");var e=(t.url.indexOf("?")>-1?"&":"?")+Object.keys(t.params).filter((function(e){return null!=t.params[e]}),this).map((function(e){var n=t.params[e];return"string"==typeof n&&n.startsWith("{{")&&(n=dmx.parse(n,this)),encodeURIComponent(e)+"="+encodeURIComponent(n)}),this).join("&");if(this._url=t.url+e,window.WebviewProxy&&(this._url=window.WebviewProxy.convertProxyUrl(this._url)),this.props.cache){var n=dmx.parse(this.props.cache+'.data["'+this._url+'"]',this);if(n){if(!(Date.now()-n.created>=1e3*t.ttl))return this.set("headers",n.headers||{}),this.set("paging",n.paging||{}),this.set("links",n.links||{}),this.set("data",n.data),this.dispatchEvent("success"),void this.dispatchEvent("done");dmx.parse(this.props.cache+'.remove("'+this._url+'")',this)}}this.set("state",{executing:!0,uploading:!1,processing:!1,downloading:!1});var i=null;"GET"!=this.props.method.toUpperCase()&&("text"==this.props["data-type"]?(t.headers["Content-Type"]||(t.headers["Content-Type"]="application/text"),i=this.props.data.toString()):"json"==this.props["data-type"]?(t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),i=JSON.stringify(this.props.data)):"POST"==this.props.method.toUpperCase()?(i=new FormData,Object.keys(this.props.data).forEach((function(t){var e=this.props.data[t];Array.isArray(e)?(/\[\]$/.test(t)||(t+="[]"),e.forEach((function(e){i.append(t,e)}),this)):i.set(t,e)}),this)):(t.headers["Content-Type"]||(t.headers["Content-Type"]="application/text"),i=this.props.data.toString())),this.xhr.open(this.props.method.toUpperCase(),this._url),this.xhr.timeout=1e3*t.timeout,Object.keys(t.headers).forEach((function(e){this.xhr.setRequestHeader(e,t.headers[e])}),this),this.xhr.setRequestHeader("accept","application/json"),this.props.credentials&&(this.xhr.withCredentials=!0);try{this.xhr.send(i)}catch(t){this._done(t)}},_reset:function(){this.set({status:0,links:{},headers:{},state:{executing:!1,uploading:!1,processing:!1,downloading:!1},uploadProgress:{position:0,total:0,percent:0},downloadProgress:{position:0,total:0,percent:0},lastError:{status:0,message:"",response:null}})},_done:function(t){if(this._reset(),t)this.set("lastError",{status:0,message:t.message,response:null}),this.dispatchEvent("error");else{var e=this.xhr.responseText;try{e=JSON.parse(e)}catch(t){if(this.xhr.status<400)return this.set("lastError",{status:0,message:"Response was not valid JSON",response:e}),void this.dispatchEvent("error")}try{var n=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",n.reduce((function(t,e){var n=e.split(": "),i=n.shift(),r=n.join(": ");return t[i]=r,t}),{}))}catch(t){console.warn("Error parsing response headers",t)}try{var i=Object.keys(this.data.headers).find((function(t){return"link"==t.toLowerCase()}));i&&this.set("links",this.data.headers[i].split(/,\s*).map((function(t){try{var e=t.match(/([^>]*)>(.*)/),n=e[1],i=e[2].split(";"),r=n.substr(n.indexOf("?")+1);r.indexOf("#")>0&&(r=r.substr(0,r.indexOf("#")));var s=r.split("&").reduce((function(t,e){var n=e.split("=");return n[0]&&(t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]||"")),t}),{});i.shift();var a=i.reduce((function(t,e){var n=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return n&&(t[n[1]]=n[2]),t}),{});return(a=Object.assign({},s,a)).url=n,a}catch(t){return console.warn("Error parsing link header part",t),null}})).filter((function(t){return t&&t.rel})).reduce((function(t,e){return e.rel.split(/\s+/).forEach((function(n){t[n]=Object.assign(e,{rel:n})})),t}),{}))}catch(t){console.warn("Error parsing link header",t)}try{var r={page:1,pages:1,items:0,has:{first:!1,prev:!1,next:!1,last:!1}};if(this.data.links.prev||this.data.links.next){this.data.links.last&&this.data.links.last.page?r.pages=+this.data.links.last.page:this.data.links.prev&&this.data.prev.page&&(r.pages=+this.data.links.prev.page+1);var s=Object.keys(this.data.headers).find((function(t){return"x-total"==(t=t.toLowerCase())||"x-count"==t||"x-total-count"==t}));s&&(r.items=+this.data.headers[s]),this.data.links.prev&&this.data.links.prev.page?r.page=+this.data.links.prev.page+1:this.data.links.next&&this.data.links.next.page&&(r.page=+this.data.links.next.page-1),r.has={first:!!this.data.links.first,prev:!!this.data.links.prev,next:!!this.data.links.next,last:!!this.data.links.last}}this.set("paging",r)}catch(t){console.warn("Error parsing paging",t)}this.set("status",this.xhr.status),this.xhr.status<400?(this.set("data",e),this.dispatchEvent("success"),this.props.cache&&dmx.parse(this.props.cache+'.set("'+this._url+'", { headers: headers, paging: paging, links: links, data: data, created: '+Date.now()+" })",this)):(this.set("lastError",{status:this.xhr.status,message:this.xhr.statusText,response:e}),400==this.xhr.status?this.dispatchEvent("invalid"):401==this.xhr.status?this.dispatchEvent("unauthorized"):403==this.xhr.status?this.dispatchEvent("forbidden"):this.dispatchEvent("error"))}this.dispatchEvent("done")},onload:function(t){this._done()},onabort:function(t){this._reset(),this.dispatchEvent("abort"),this.dispatchEvent("done")},onerror:function(t){this._done({message:"Failed to execute"})},ontimeout:function(t){this._done({message:"Execution timeout"})},onprogress:function(t){return function(e){e.loaded=e.loaded||e.position;var n=e.lengthComputable?Math.ceil(e.loaded/e.total*100):0;this.set("state",{executing:!0,uploading:"upload"==t&&n<100,processing:"upload"==t&&100==n,downloading:"download"==t}),this.set(t+"Progress",{position:e.loaded,total:e.total,percent:n}),this.dispatchEvent(t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})}}}),dmx.Component("serverconnect",{extends:"fetch",attributes:{sockets:{type:Boolean,default:!1}},render:function(t){this.props.sockets?(this.eventName=this.props.url.replace(/^(.*?)api\//,""),this.socket=dmx.Socket("/api"),this.socket.on(this.eventName,this.refresh.bind(this)),this.update({})):dmx.Component("fetch").prototype.render.call(this,t)},fetch:function(t){this.props.sockets?this.refresh(t&&t.params):dmx.Component("fetch").prototype.fetch.call(this,t)},refresh:function(t){t=dmx.extend(!0,{},this.props.params,t||{}),this.dispatchEvent("start"),this.set("state",{executing:!0,uploading:!1,processing:!0,downloading:!1}),this.socket.emit(this.eventName,t,function(t){this.set("status",t.status),this.set("data",t.data),this.set("state",{executing:!1,uploading:!1,processing:!1,downloading:!1}),t.status<400?this.dispatchEvent("success"):400==t.status?this.dispatchEvent("invalid"):401==t.status?this.dispatchEvent("unauthorized"):403==t.status?this.dispatchEvent("forbidden"):this.dispatchEvent("error"),this.dispatchEvent("done")}.bind(this))}}),dmx.Component("serverconnect-form",{extends:"form",initialData:{status:0,data:null,headers:{},state:{executing:!1,uploading:!1,processing:!1,downloading:!1},uploadProgress:{position:0,total:0,percent:0},downloadProgress:{position:0,total:0,percent:0},lastError:{status:0,message:"",response:null}},attributes:{timeout:{type:Number,default:0},autosubmit:{type:Boolean,default:!1},params:{type:Object,default:{}},headers:{type:Object,default:{}},"post-data":{type:String,default:"form"},credentials:{type:Boolean,default:!1}},methods:{abort:function(){this.abort()},reset:function(t){this.reset(),t&&(this.abort(),this._reset(),this.set("data",null))}},events:{start:Event,done:Event,error:Event,unauthorized:Event,forbidden:Event,abort:Event,success:Event,upload:ProgressEvent,download:ProgressEvent},$parseAttributes:function(t){dmx.BaseComponent.prototype.$parseAttributes.call(this,t),dmx.dom.getAttributes(t).forEach((function(t){"param"==t.name&&t.argument&&this.$addBinding(t.value,(function(e){this.props.params[t.argument]=e})),"header"==t.name&&t.argument&&this.$addBinding(t.value,(function(e){this.props.headers[t.argument]=e}))}),this)},render:function(t){this.xhr=new XMLHttpRequest,this.xhr.addEventListener("load",this.onload.bind(this)),this.xhr.addEventListener("abort",this.onabort.bind(this)),this.xhr.addEventListener("error",this.onerror.bind(this)),this.xhr.addEventListener("timeout",this.ontimeout.bind(this)),this.xhr.addEventListener("progress",this.onprogress("download").bind(this)),this.xhr.upload&&this.xhr.upload.addEventListener("progress",this.onprogress("upload").bind(this));var e=t.checkValidity;t.dmxExtraData={},t.dmxExtraElements=[],t.checkValidity=function(){for(var n=0;n-1?"&":"?")+r),window.WebviewProxy&&(s=window.WebviewProxy.convertProxyUrl(s)),this.xhr.open(e,s),this.xhr.timeout=1e3*this.props.timeout,Object.keys(this.props.headers).forEach((function(t){this.xhr.setRequestHeader(t,this.props.headers[t])}),this),this.xhr.setRequestHeader("accept","application/json"),this.props.credentials&&(this.xhr.withCredentials=!0);try{this.xhr.send(i)}catch(t){this._done(t)}},_reset:function(){this.set({status:0,headers:{},state:{executing:!1,uploading:!1,processing:!1,downloading:!1},uploadProgress:{position:0,total:0,percent:0},downloadProgress:{position:0,total:0,percent:0},lastError:{status:0,message:"",response:null}})},_done:function(t){if(this._reset(),t)this.set("lastError",{status:0,message:t.message,response:null}),this.dispatchEvent("error");else{var e=this.xhr.responseText;try{e=JSON.parse(e)}catch(t){if(this.xhr.status<400)return this.set("lastError",{status:0,message:"Response was not valid JSON",response:e}),void this.dispatchEvent("error")}try{var n=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",n.reduce((function(t,e){var n=e.split(": "),i=n.shift(),r=n.join(": ");return t[i]=r,t}),{}))}catch(t){console.warn("Error parsing response headers",t)}if(this.set("status",this.xhr.status),dmx.validateReset&&dmx.validateReset(this.$node),window.grecaptcha&&this.$node.querySelector(".g-recaptcha")&&grecaptcha.reset(),this.xhr.status<400)this.set("data",e),this.dispatchEvent("success");else if(this.set("lastError",{status:this.xhr.status,message:this.xhr.statusText,response:e}),400==this.xhr.status)if(this.dispatchEvent("invalid"),e.form){for(var i in e.form)if(e.form.hasOwnProperty(i)){var r=this.$node.querySelector('[name="'+i+'"]');r&&(r.setCustomValidity(e.form[i]),dmx.requestUpdate(),dmx.bootstrap5forms?dmx.validate.setBootstrap5Message(r,e.form[i]):dmx.bootstrap4forms?dmx.validate.setBootstrap4Message(r,e.form[i]):dmx.bootstrap3forms?dmx.validate.setBootstrapMessage(r,e.form[i]):dmx.validate.setErrorMessage(r,e.form[i]))}}else console.warn("400 error, no form errors in response.",e);else 401==this.xhr.status?this.dispatchEvent("unauthorized"):403==this.xhr.status?this.dispatchEvent("forbidden"):this.dispatchEvent("error")}this.dispatchEvent("done")},onload:function(t){this._done()},onabort:function(t){this._reset(),this.dispatchEvent("abort"),this.dispatchEvent("done")},onerror:function(t){this._done({message:"Failed to execute"})},ontimeout:function(t){this._done({message:"Execution timeout"})},onprogress:function(t){return function(e){e.loaded=e.loaded||e.position;var n=e.lengthComputable?Math.ceil(e.loaded/e.total*100):0;this.set("state",{executing:!0,uploading:"upload"==t&&n<100,processing:"upload"==t&&100==n,downloading:"download"==t}),this.set(t+"Progress",{position:e.loaded,total:e.total,percent:n}),this.dispatchEvent(t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})}},_parseJsonForm:function(t){const e={};for(const r of t.elements)if(r.name&&!r.disabled){const t=n(r.name.replace(/\[\]$/,""));let s=e;for(const e of t){const t=r.type;"number"==t?r.value&&(s=i(s,e,s[e.key],+r.value)):"radio"==t||"checkbox"==t?r.getAttribute("value")?r.checked&&(s=i(s,e,s[e.key],r.value)):s=i(s,e,s[e.key],r.checked):s=i(s,e,s[e.key],"select-multiple"==t?Array.from(r.selectedOptions).map((t=>t.value)):r.value)}}return e;function n(t){const e=[],n=t,i=/^\[([^\]]*)\]/,r=/^\d+$/;if(!(t=t.replace(/^([^\[]+)/,((t,n)=>(e.push({type:"object",key:n}),"")))))return e[0].last=!0,e;for(;t;){if(!i.test(t))return{type:"object",key:n,last:!0};t=t.replace(i,((t,n)=>(n?r.test(n)?e.push({type:"array",key:+n}):e.push({type:"object",key:n}):e[e.length-1].append=!0,"")))}for(let t=0,n=e.length;td.length&&i.splice(d.length).forEach((function(t){n.children.splice(n.children.indexOf(t),1),t.$destroy()})),i.length&&i.forEach((function(t,e){t.set(d[e])})),d.length>i.length){for(u=document.createDocumentFragment(),c=i.length;c
+
+
\ No newline at end of file
diff --git a/views/layouts/main.ejs b/views/layouts/main.ejs
new file mode 100644
index 0000000..cbd4236
--- /dev/null
+++ b/views/layouts/main.ejs
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+Untitled Document
+
+
+
+
+
+
+
+
+
+ <%- await include(content, locals); %>
+
+
+
+