/*! App Connect Version: 1.14.12 (c) 2023 Wappler.io @build 2023-03-14 12:22:18 */ window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(t){var e,n=(this.document||this.ownerDocument).querySelectorAll(t),i=this;do{for(e=n.length;--e>=0&&n.item(e)!==i;);}while(e<0&&(i=i.parentElement));return i}),window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),function(){window.dmx=window.dmx||{};var t=Object.prototype.toString,e=Object.prototype.hasOwnProperty,n=/\w*$/,i=/^(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array$/,r=function(t,e){return t===e||t!=t&&e!=e},s=function(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return-1},a=function(t,e){return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?t["string"==typeof e?"string":"hash"]:t.map},o=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1},set:function(t,e){var n=this.__data__,i=s(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}};var u=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e{t.state&&t.state.title&&(document.title=t.state.title),dmx.requestUpdate()}),0)},window.onhashchange=function(){dmx.requestUpdate()};var n=dmx.Component("app");dmx.app=new n(t,dmx.global),dmx.app.$update(),e&&e()}else e&&e()},document.documentElement.style.visibility="hidden",document.addEventListener("DOMContentLoaded",(()=>{Promise.all(dmx.__startup).then((()=>{var t=document.querySelector(':root[dmx-app], [dmx-app], :root[is="dmx-app"], [is="dmx-app"]');dmx.appConnect(t,(function(){document.documentElement.style.visibility="",t&&t.removeAttribute("dmx-app")}))}))})),dmx.useHistory=window.history&&window.history.pushState,dmx.extend=function(){var t={},e=!1,n=0,i=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],n++);for(var r=function(n){for(var i in n)"__proto__"!=i&&Object.prototype.hasOwnProperty.call(n,i)&&(e&&"[object Object]"===Object.prototype.toString.call(n[i])?t[i]=dmx.extend(!0,t[i],n[i]):null!=n[i]&&(t[i]=n[i]))};nt.dirty=!0)),t.checkValidity()},dmx.validateReset=function(t){},(()=>{const t=[];window.addEventListener("message",(e=>{if(e.source===window&&"dmxNextTick"===e.data&&t.length){const e=t.shift();e.fn.call(e.context)}})),dmx.nextTick=(e,n)=>{t.push({fn:e,context:n}),window.postMessage("dmxNextTick","*")}})(),dmx.requestUpdate=function(){var t=!1,e=new Set;return function(n){e.add(n||"*"),t||(t=!0,dmx.nextTick((function(){if(t=!1,dmx.app){var n=new Set(e);e.clear(),dmx.app.$update(n)}})))}}(),dmx.debounce=function(t,e){let n;return function(){const i=()=>{t.apply(this,arguments)};e?(clearTimeout(n),n=setTimeout(i,e)):(cancelAnimationFrame(n),n=requestAnimationFrame(i))}},dmx.throttle=function(t,e){let n,i=!1;return function(){if(n=Array.from(arguments),!i){const r=()=>{i=!1,n&&t.apply(this,n)};t.apply(this,n),n=void 0,i=!0,e?setTimeout(r,e):requestAnimationFrame(r)}}},dmx.keyCodes={bs:8,tab:9,enter:13,esc:27,space:32,left:37,up:38,right:39,down:40,delete:46,backspace:8,pause:19,capslock:20,escape:27,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,numlock:144,scrolllock:145,semicolon:186,equal:187,comma:188,minus:189,period:190,slash:191,backquote:192,bracketleft:219,backslash:220,bracketright:221,quote:222,numpad0:96,numpad1:97,numpad2:98,numpad3:99,numpad4:100,numpad5:101,numpad6:102,numpad7:103,numpad8:104,numpad9:105,numpadmultiply:106,numpadadd:107,numpadsubstract:109,numpaddivide:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,keya:[65,97],keyb:[66,98],keyc:[67,99],keyd:[68,100],keye:[69,101],keyf:[70,102],keyg:[71,103],keyh:[72,104],keyi:[73,105],keyj:[74,106],keyk:[75,107],keyl:[76,108],keym:[77,109],keyn:[78,110],keyo:[79,111],keyp:[80,112],keyq:[81,113],keyr:[82,114],keys:[83,115],keyt:[84,116],keyu:[85,117],keyv:[86,118],keyw:[87,119],keyx:[88,120],keyy:[89,121],keyz:[90,122]},dmx.eventListener=function(t,e,n,i){let r,s;const a=function(t){if((!i.self||t.target===t.currentTarget)&&(!i.ctrl||t.ctrlKey)&&(!i.alt||t.altKey)&&(!i.shift||t.shiftKey)&&(!i.meta||t.metaKey)&&(!(t.originalEvent||t).nsp||Object.keys(i).includes((t.originalEvent||t).nsp))){if((t.originalEvent||t)instanceof MouseEvent){if(null!=i.button&&t.button!=(parseInt(i.button,10)||0))return;if(i.button0&&0!=t.button)return;if(i.button1&&1!=t.button)return;if(i.button2&&2!=t.button)return;if(i.button3&&3!=t.button)return;if(i.button4&&4!=t.button)return}if((t.originalEvent||t)instanceof KeyboardEvent){var e=[];Object.keys(i).forEach((function(t){var n=parseInt(t,10);n?e.push(n):dmx.keyCodes[t]&&e.push(dmx.keyCodes[t])}));for(var a=0;a({identifier:t.identifier,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY});t.$data.altKey=t.altKey,t.$data.ctrlKey=t.ctrlKey,t.$data.metaKey=t.metaKey,t.$data.shiftKey=t.shiftKey,t.$data.touches=Array.from(t.touches).map(e),t.$data.changedTouches=Array.from(t.changedTouches).map(e),t.$data.targetTouches=Array.from(t.targetTouches).map(e),t.$data.rotation=t.rotation,t.$data.scale=t.scale}if(t instanceof KeyboardEvent&&(t.$data.altKey=t.altKey,t.$data.ctrlKey=t.ctrlKey,t.$data.metaKey=t.metaKey,t.$data.shiftKey=t.shiftKey,t.$data.location=t.location,t.$data.repeat=t.repeat,t.$data.code=t.code,t.$data.key=t.key),i.debounce)clearTimeout(r),r=setTimeout((()=>{n.apply(this,arguments)}),parseInt(i.debounce,10)||0);else{if(!i.throttle)return n.apply(this,arguments);s||(s=!0,n.apply(this,arguments),setTimeout((()=>{s=!1}),parseInt(i.throttle,10)||0))}}};i=i||{},window.Dom7&&1===t.nodeType?Dom7(t)[i.once?"once":"on"](e.replace(/-/g,"."),a,!!i.capture):window.jQuery&&!i.capture?jQuery(t)[i.once?"one":"on"](e.replace(/-/g,"."),a):t.addEventListener(e.replace(/-/g,"."),a,{capture:!!i.capture,once:!!i.once,passive:!!i.passive})},dmx.createClass=function(t,e){var n=function(){t.constructor&&t.constructor.apply(this,arguments)};return e&&e.prototype&&(n.prototype=Object.create(e.prototype)),Object.assign(n.prototype,t),n.prototype.constructor=n,n},dmx.Config=function(t){Object.assign(dmx.config,t)},dmx.Component=function(t,e){if(e){var n=dmx.Component(e.extends)||dmx.BaseComponent;e.initialData=Object.assign({},n.prototype.initialData,e.initialData),e.attributes=Object.assign({},n.prototype.attributes,e.attributes),e.methods=Object.assign({},n.prototype.methods,e.methods),e.events=Object.assign({},n.prototype.events,e.events),e.hasOwnProperty("constructor")||(e.constructor=function(t,e){n.call(this,t,e)}),e.type=t;var i=dmx.createClass(e,n);i.extends=e.extends,dmx.__components[t]=i}return dmx.__components[t]},dmx.Attribute=function(t,e,n){dmx.__attributes[e]||(dmx.__attributes[e]={}),dmx.__attributes[e][t]=n},dmx.Formatters=function(t,e){for(var n in dmx.__formatters[t]||(dmx.__formatters[t]={}),e)e.hasOwnProperty(n)&&(dmx.__formatters[t][n]=e[n])},dmx.Formatter=function(t,e,n){dmx.__formatters[t]||(dmx.__formatters[t]={}),dmx.__formatters[t][e]=n},dmx.Adapter=function(t,e,n){return dmx.__adapters[t]||(dmx.__adapters[t]={}),n&&(dmx.__adapters[t][e]=n),dmx.__adapters[t][e]},dmx.Actions=function(t){for(var e in t)t.hasOwnProperty(e)&&(dmx.__actions[e]=t[e])},dmx.Action=function(t,e){dmx.__actions[t]=e},dmx.Startup=function(t){dmx.__startup.add(t)},"app:"==document.location.protocol&&dmx.Startup(new Promise((t=>document.addEventListener("deviceready",t)))),function(){var t=function(e){if(!(this instanceof t))return new t(e);if(e instanceof t)return e;if(!e)return this;var n=e.length;if(e.nodeType)this[0]=e,this.length=1;else{if("string"==typeof e)return t(document.querySelectorAll(e));if(n)for(var i=0;i0?a[t.substr(0,n)]=t.substr(n+1):a[t]=!0}}));var o=r.indexOf(":");o>0&&(s=r.substr(o+1),r=r.substr(0,o)),e.push({name:r,fullName:i.name,value:i.value,argument:s,modifiers:a})}}return e},remove:function(t){Array.isArray(t)?t.forEach((function(t){dmx.dom.remove(t)})):t.remove()},replace:function(t,e){t.parentNode&&t.parentNode.replaceChild(e,t)}}}(),function(){var t={},e={Boolean:"boolean",Null:"null",Undefinec:"undefined",Number:"number",BigInt:"number",String:"string",Date:"date",RegExp:"regexp",Blob:"blob",File:"file",FileList:"filelist",ArrayBuffer:"arraybuffer",ImageBitmap:"imagebitmap",ImageData:"imagedata",Array:"array",Object:"object",Map:"map",Set:"set",DataView:"array",Int8Array:"array",Uint8Array:"array",Uint8ClampedArray:"array",Int16Array:"array",Uint16Array:"array",Int32Array:"array",Uint32Array:"array",Float32Array:"array",Float64Array:"array",BigInt64Array:"array",BigUint64Array:"array"},n={"{":"L_CURLY","}":"R_CURLY","(":"L_PAREN",")":"R_PAREN","[":"L_BRACKET","]":"R_BRACKET",".":"PERIOD",",":"COMMA",";":"SEMI",":":"COLON","?":"QUESTION","+":"ADDICTIVE","-":"ADDICTIVE","*":"MULTIPLICATIVE","/":"MULTIPLICATIVE","%":"MULTIPLICATIVE","===":"EQUALITY","!==":"EQUALITY","==":"EQUALITY","!=":"EQUALITY","<":"RELATIONAL",">":"RELATIONAL","<=":"RELATIONAL",">=":"RELATIONAL",in:"RELATIONAL","&&":"LOGICAL_AND","||":"LOGICAL_OR","!":"LOGICAL_NOT","&":"BITWISE_AND","|":"BITWISE_OR","^":"BITWISE_XOR","~":"BITWISE_NOT","<<":"BITWISE_SHIFT",">>":"BITWISE_SHIFT",">>>":"BITWISE_SHIFT"},i={n:"\n",f:"\f",r:"\r",t:"\t",v:"\v","'":"'",'"':'"',"`":"`"},r={"**":function(t,e){return Math.pow(t(),e())},"??":function(t,e){return null==(t=t())?e():t},in:function(t,e){return t()in e()},"?":function(t,e,n){return t()?e():n()},"+":function(t,e){return t=t(),e=e(),null==t?e:null==e?t:t+e},"-":function(t,e){return t()-e()},"*":function(t,e){return t()*e()},"/":function(t,e){return t()/e()},"%":function(t,e){return t()%e()},"===":function(t,e){return t()===e()},"!==":function(t,e){return t()!==e()},"==":function(t,e){return t()==e()},"!=":function(t,e){return t()!=e()},"<":function(t,e){return t()":function(t,e){return t()>e()},"<=":function(t,e){return t()<=e()},">=":function(t,e){return t()>=e()},"&&":function(t,e){return t()&&e()},"||":function(t,e){return t()||e()},"&":function(t,e){return t()&e()},"|":function(t,e){return t()|e()},"^":function(t,e){return t()^e()},"<<":function(t,e){return t()<>":function(t,e){return t()>>e()},">>>":function(t,e){return t()>>>e()},"~":function(t){return~t()},"!":function(t){return!t()}},s={this:function(t){return function(){return t.data}},undefined:function(){return function(){}},null:function(){return function(){return null}},true:function(){return function(){return!0}},false:function(){return function(){return!1}},_:function(){return function(){return{__dmxScope__:!0}}}},a=function(){return 0};dmx.getType=function(t){return e[Object.prototype.toString.call(t).slice(8,-1)]},dmx.getIdents=function(t){if("string"!=typeof t)return[];let e=[];if(t.includes("{{")){let n;for(;null!=(n=dmx.reExpressionReplace.exec(t));)e=e.concat(dmx.lexer(n[1]))}else e=dmx.lexer(t);return e.reduce(((t,e)=>("IDENT"==e.name?t.push(e.value):"STRING"==e.name&&e.value.startsWith("{{")&&(t=t.concat(dmx.getIdents(e.value))),t)),[])},dmx.lexer=function(e){if(t[e])return t[e];for(var r,s,a,o,d,u,c=[],h=0,l=!0;h1?e.substr(h,t):e[h]}function f(t){return h+(t=t||1)="0"&&t<="9"}function y(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||"_"==t||"$"==t}function g(t){return y(t)||x(t)}function b(t){return" "==t||"\r"==t||"\t"==t||"\n"==t||"\v"==t||" "==t}function E(t){return"-"==t||"+"==t||x(t)}function w(t){var n="",r=!1;for(h++;h0&&!(u("R_PAREN")||u("R_BRACKET")||u("R_CURLY")||u("COMMA")||u("SEMI"))&&t.push(p()),!c("COMMA")&&!c("SEMI"))return(1==t.length?t[0]:e)();function e(){for(var e,n=0;n0){var e=o[0];if(!t||e.name==t)return e}return!1}function c(t){var e=u(t);return!!e&&(o.shift(),e)}function h(e){if(!c(e))throw Error("Unexpected token, expecting ["+e+"] in expression ["+t+"]")}function l(t){var n=Array.prototype.slice.call(arguments,1);return function(){return r.hasOwnProperty(t)?r[t].apply(e,n):t}}function p(){return f()}function f(){var e,n=function(){var t,e=m();for(;;){if(!(t=c("LOGICAL_OR")))return e;e=l(t.value,e,m())}}();if(c("QUESTION")){if(e=f(),c("COLON"))return l("?",n,e,f());throw Error('Expecting a ":" in expression ['+t+"]")}return n}function m(){var t,e=function(){var t,e=v();(t=c("BITWISE_OR"))&&(e=l(t.value,e,v()));return e}();return(t=c("LOGICAL_AND"))&&(e=l(t.value,e,m())),e}function v(){var t,e=x();return(t=c("BITWISE_XOR"))&&(e=l(t.value,e,x())),e}function x(){var t,e=y();return(t=c("BITWISE_AND"))&&(e=l(t.value,e,x())),e}function y(){var t,e=g();return(t=c("EQUALITY"))&&(e=l(t.value,e,y())),e}function g(){var t,e=function(){var t,e=b();for(;t=c("BITWISE_SHIFT");)e=l(t.value,e,b());return e}();return(t=c("RELATIONAL"))&&(e=l(t.value,e,g())),e}function b(){for(var t,e=E();t=c("ADDICTIVE");)e=l(t.value,e,E());return e}function E(){for(var t,e=w();t=c("MULTIPLICATIVE");)e=l(t.value,e,w());return e}function w(){var t;return(t=c("ADDICTIVE"))?"+"==t.value?_():l(t.value,a,w()):(t=c("LOGICAL_NOT"))?l(t.value,w()):_()}function _(){var n,r;if(c("L_PAREN"))n=p(),h("R_PAREN");else if(c("L_CURLY")){var a={};if("R_CURLY"!=d().name)do{var o=c().value;h("COLON"),a[o]=p()()}while(c("COMMA"));n=l(a),h("R_CURLY")}else if(c("L_BRACKET")){var f=[];if("R_BRACKET"!=d().name)do{f.push(p()())}while(c("COMMA"));n=l(f),h("R_BRACKET")}else if(c("PERIOD"))n=u()?A(l(e.data)):l(e.data);else{var m=c();if(!1===m)throw Error("Not a primary expression ["+t+"]");n="IDENT"==m.name?s.hasOwnProperty(m.value)?s[m.value](e):function(){return e.get(m.value)}:"METHOD"==m.name?l(dmx.__formatters.global[m.value]||function(){window.warn&&console.warn("Formatter "+m.value+" in expression ["+t+"] doesn't exist")}):function(){return m.value}}for(;r=c("L_PAREN")||c("L_BRACKET")||c("PERIOD");)if("("==r.value)n=$(n,i);else if("["==r.value)i=n,n=k(n);else{if("."!=r.value)throw Error("Parse Error in expression ["+t+"]");i=n,n=A(n)}return i=null,n}function $(t,n){var i=[];if("R_PAREN"!=d().name)do{i.push(p())}while(c("COMMA"));return h("R_PAREN"),function(){var r=[];n&&r.push(n());for(var s=0;s-1&&r){var s=new r(n,e.parent);e.parent.children.splice(i,1,s),s.name&&e.parent.add(s.name,s.data)}}dmx.requestUpdate()}},__remove:function(t){var e=this.__find(t);if(e){e.$destroy();var n=e.parent.children.indexOf(this);n>-1&&e.parent.children.splice(n,1),dmx.requestUpdate()}},beforeMount:dmx.noop,mounted:dmx.noop,beforeUpdate:dmx.noop,update:dmx.noop,updated:dmx.noop,beforeDestroy:dmx.noop,destroyed:dmx.noop,addEventListener:function(t,e){t in this.listeners||(this.listeners[t]=new Set),this.listeners[t].add(e)},removeEventListener:function(t,e){t in this.listeners&&this.listeners[t].delete(e)},dispatchEvent:function(t,e,n,i){if("string"==typeof t)try{var r=this.events[t];t=new r(t,e)}catch(n){var s=t;if((t=document.createEvent("CustomEvent")).initEvent(s,e&&e.bubbles,e&&e.cancelable),!(t instanceof Event))return console.warn("Unknown event "+t,this.events),!1;var a=t.preventDefault;t.preventDefault=function(){a.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}return t}}if(!(t.type in this.listeners))return!0;t.nsp=i,t.target=this,t.$data=n||{};for(let e of this.listeners[t.type])!1===e.call(this,t)&&t.preventDefault();return!t.defaultPrevented},$addChild:function(t,e){var n=new(0,dmx.__components[t])(e,this);this.children.push(n),n.name&&(this.data[n.name]&&dmx.debug&&console.warn('Duplicate name "'+n.name+'" found, component not added to scope.'),this.set(n.name,n.data))},$customAttributes:function(t,e){dmx.dom.getAttributes(e).forEach((function(n){dmx.__attributes[t][n.name]&&(e.removeAttribute(n.fullName),dmx.__attributes[t][n.name].call(this,e,n))}),this)},$parse:function(t){if(t=t||this.$node)if(3!==t.nodeType)1===t.nodeType&&(dmx.config.mapping&&Object.keys(dmx.config.mapping).forEach((function(e){dmx.array(t.querySelectorAll(e)).forEach((function(t){t.hasAttribute("is")||t.setAttribute("is","dmx-"+dmx.config.mapping[e])}))})),dmx.dom.walk(t,(function(t){if(t!=this.$node){if(1===t.nodeType){var e=t.tagName.toLowerCase(),n=dmx.dom.getAttributes(t);if(t.hasAttribute("is")&&(e=t.getAttribute("is")),dmx.reIgnoreElement.test(e))return!1;if(this.$customAttributes("before",t),-1!==n.findIndex((function(t){return"repeat"===t.name})))return!1;if(dmx.rePrefixed.test(e))return(e=e.replace(/^dmx-/i,""))in dmx.__components?(t.isComponent=!0,t.dmxRendered?window.__WAPPLER__&&t.dmxComponent&&t.dmxComponent.$parse&&(dmx.reIgnoreElement.test(t.tagName)||t.dmxComponent.$parse()):this.$addChild(e,t),!1):void console.warn("Unknown component found! "+e);this.$customAttributes("mounted",t)}if(3===t.nodeType&&dmx.reExpression.test(t.nodeValue)){var i=t.nodeValue;"{{"==i.substr(0,2)&&"}}"==i.substr(-2)&&-1==i.indexOf("{{",2)&&(i=i.substring(2,i.length-2)),this.$addBinding(i,(function(e,n){t.nodeValue=e}))}}}),this));else if(dmx.reExpression.test(t.nodeValue)){var e=t.nodeValue;"{{"==e.substr(0,2)&&"}}"==e.substr(-2)&&-1==e.indexOf("{{",2)&&(e=e.substring(2,e.length-2)),this.$addBinding(e,(function(e,n){t.nodeValue=e}))}},$update:function(t){try{if(!1!==this.beforeUpdate(t)){const e=dmx.clone(this.props),n=(this.$updateBindings(this.bindings,t),this.$updatePropBindings(t));try{this.update(e,n)}catch(t){console.error(t)}this.children.forEach((function(e){e.$update(t)})),this.updated()}}catch(t){console.error(t)}},$canSkip:function(t,e){if(e&&!e.has("*")){for(const n of t.idents)if(e.has(n))return!1;return!0}return!1},$updateBindings:function(t,e){let n=!1;for(const i in t)if(t.hasOwnProperty(i)){const r=t[i];if(this.$canSkip(r,e))continue;const s=dmx.parse(i,this);if(!dmx.equal(s,r.value)){for(const t of r.callbacks)t.call(this,s,r.value);n=!0,r.value=dmx.clone(s)}}return n},$updatePropBindings:function(t){const e=new Set;for(const n in this.propBindings)if(this.propBindings.hasOwnProperty(n)){const i=this.propBindings[n];if(this.$canSkip(i,t))continue;const r=dmx.parse(i.expression,this);dmx.equal(r,i.value)||(i.callback.call(this,r),i.value=dmx.clone(r),e.add(n))}return e},$parseAttributes:function(t){var e=this;this.attributes&&(Object.keys(this.attributes).forEach((function(n){var i=e.attributes[n],r=i.default;if(t.hasAttribute(n)&&(i.type==Boolean?r=!0:(r=t.getAttribute(n),i.type==Number&&r&&!isNaN(Number(r))&&(r=Number(r)),i.type==String&&(r=String(r)),i.validate&&!i.validate(r)&&(r=i.default)),t.removeAttribute(n)),t.hasAttribute("dmx-bind:"+n)){const e=t.getAttribute("dmx-bind:"+n),i=this.$propBinding(n).bind(this);this.propBindings[n]={expression:e,callback:i,idents:dmx.getIdents(e),value:null},t.removeAttribute("dmx-bind:"+n)}e.props[n]=dmx.clone(r)}),this),this.$updatePropBindings()),this.events&&Object.keys(this.events).forEach((function(n){t.hasAttribute("on"+n)&&(dmx.eventListener(e,n,Function("event",t.getAttribute("on"+n)),{}),t.removeAttribute("on"+n))})),dmx.dom.getAttributes(t).forEach((function(n){"on"==n.name&&this.events[n.argument]&&(dmx.eventListener(e,n.argument,(function(t){return t.originalEvent&&(t=t.originalEvent),dmx.parse(n.value,dmx.DataScope({$event:t.$data,$originalEvent:t},e))}),n.modifiers),t.removeAttribute(n.fullName))}),this)},$propBinding:function(t){var e=this.attributes[t],n=this;return function(i){void 0===i&&(i=e.default),e.type==Boolean&&(i=!!i),null!=i&&(e.type==Number&&(i=""===i||isNaN(Number(i))?e.default:Number(i)),e.type==String&&(i=String(i))),e.validate&&!e.validate(i)&&(i=e.default),n.props[t]=dmx.clone(i)}},$initialData:function(){Object.assign(this.data,{$type:this.type},"function"==typeof this.initialData?this.initialData():this.initialData),Object.keys(this.methods).forEach((function(t){var e=this;this.data["__"+t]=function(){return e.methods[t].apply(e,Array.prototype.slice.call(arguments,1))}}),this)},$mount:function(t){this.$placeholder&&this.$node&&dmx.dom.replace(this.$placeholder,this.$node)},$addBinding:function(t,e){this.bindings[t]=this.bindings[t]||{expression:t,value:dmx.parse(t,this),callbacks:[],idents:dmx.getIdents(t)},this.bindings[t].callbacks.push(e),e.call(this,this.bindings[t].value)},$destroy:function(){this.dispatchEvent("destroy"),this.beforeDestroy(),this.$destroyChildren(),this.parent&&this.parent.del(this.name),this.$node&&dmx.dom.remove(this.$node),this.destroyed()},$destroyChildren:function(){this.children.forEach((function(t){t.$destroy()})),this.children=[]},updateRelated:function(){if(this.parent){let t=this.parent;for(;t;)!t.data||"repeat"!=t.data.$type&&"form-repeat"!=t.data.$type||dmx.requestUpdate(t.name),t=t.parent}},get:function(t,e){return this.data.hasOwnProperty(t)?this.data[t]:this.parent&&!0!==e?"parent"==t?this.parent.data:this.parent.get(t):null},add:function(t,e){this.data[t]?Array.isArray(this.data[t])?this.data[t].push(e):this.data[t]=[this.data[t],e]:this.set(t,e),dmx.requestUpdate(t),dmx.requestUpdate(this.name),this.updateRelated()},set:function(t,e){if("object"!=typeof t)dmx.equal(this.data[t],e)||(this.data[t]=e,dmx.requestUpdate(t),dmx.requestUpdate(this.name),this.updateRelated());else for(var n in t)t.hasOwnProperty(n)&&this.set(n,t[n])},del:function(t){delete this.data[t],dmx.requestUpdate(t),dmx.requestUpdate(this.name),this.updateRelated()}}),function(){dmx.pathToRegexp=o,dmx.pathToRegexp.parse=e,dmx.pathToRegexp.compile=function(t,i){return n(e(t,i))},dmx.pathToRegexp.tokensToFunction=n,dmx.pathToRegexp.tokensToRegExp=a;var t=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function e(e,n){for(var s,a=[],o=0,d=0,u="",c=n&&n.delimiter||"/",h=n&&n.whitelist||void 0,l=!1;null!==(s=t.exec(e));){var p=s[0],f=s[1],m=s.index;if(u+=e.slice(d,m),d=m+p.length,f)u+=f[1],l=!0;else{var v="",x=s[2],y=s[3],g=s[4],b=s[5];if(!l&&u.length){var E=u.length-1,w=u[E];(!h||h.indexOf(w)>-1)&&(v=w,u=u.slice(0,E))}u&&(a.push(u),u="",l=!1);var _="+"===b||"*"===b,$="?"===b||"*"===b,k=y||g,A=v||c;a.push({name:x||o++,prefix:v,delimiter:A,optional:$,repeat:_,pattern:k?r(k):"[^"+i(A===c?A:A+c)+"]+?"})}}return(u||d0&&"\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++)yi?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();u0;)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*]*)>(.*)/),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