/*!
 App Connect
 Version: 2.0.13
 (c) 2024 Wappler.io
 @build 2024-07-15 11:46:43
 */
window.dmx={version:"2.0.13",versions:{},config:{mapping:{form:"form","button, input[type=button], input[type=submit], input[type=reset]":"button","input[type=radio]":"radio","input[type=checkbox]":"checkbox","input[type=file][multiple]":"input-file-multiple","input[type=file]":"input-file",input:"input",textarea:"textarea","select[multiple]":"select-multiple",select:"select",".checkbox-group":"checkbox-group",".radio-group":"radio-group"}},noop:()=>{},isset:e=>void 0!==e,array:e=>null!=e?Array.from(e):[],reIgnoreElement:/^(script|style)$/i,rePrefixed:/^dmx-/i,reExpression:/\{\{(.+?)\}\}/,reExpressionReplace:/\{\{(.+?)\}\}/g,reToggleAttribute:/^(checked|selected|disabled|required|hidden|async|autofocus|autoplay|default|defer|multiple|muted|novalidate|open|readonly|reversed|scoped)$/i,reDashAlpha:/-([a-z])/g,reUppercase:/[A-Z]/g,__components:Object.create(null),__attributes:{before:Object.create(null),mounted:Object.create(null)},__formatters:{boolean:Object.create(null),global:Object.create(null),string:Object.create(null),number:Object.create(null),object:Object.create(null),array:Object.create(null),any:Object.create(null)},__adapters:Object.create(null),__actions:Object.create(null),__startup:new Set},window.Element&&!("closest"in Element.prototype)&&(Element.prototype.closest=function(e){let t,s=(this.document||this.ownerDocument).querySelectorAll(e),n=this;do{for(t=s.length;--t>=0&&s.item(t)!==n;);}while(t<0&&(n=n.parentElement));return n}),window.NodeList&&!("forEach"in NodeList.prototype)&&(NodeList.prototype.forEach=Array.prototype.forEach),"function"!=typeof window.queueMicrotask&&(window.queueMicrotask=function(e){Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e}))))}),window.Node&&!("isConnected"in Node.prototype)&&Object.defineProperty(Node.prototype,"isConnected",{get:function(){return document.contains(this)}}),window.Element&&!("toggleAttribute"in Element.prototype)&&(Element.prototype.toggleAttribute=function(e,t){this.hasAttribute(e)?!0!==t&&this.removeAttribute(e):!1!==t&&this.setAttribute(e,"")}),function(){var e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,s=/\w*$/,n=/^(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array$/,r=function(e,t){return e===t||e!=e&&t!=t},i=function(e,t){for(var s=e.length;s--;)if(r(e[s][0],t))return s;return-1},a=function(e,t){return("string"==(n=typeof(s=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==s:null===s)?e["string"==typeof t?"string":"hash"]:e.map;var s,n},o=function(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var n=e[t];this.set(n[0],n[1])}};o.prototype={clear:function(){this.__data__=Object.create(null),this.size=0},delete:function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},get:function(e){var t=this.__data__[e];return t===HASH_UNDEFINED?void 0:t},has:function(e){return void 0!==this.__data__[e]},set:function(e,t){return this.size+=this.has(e)?0:1,this.__data__[e]=void 0===t?HASH_UNDEFINED:t,this}};var d=function(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var n=e[t];this.set(n[0],n[1])}};d.prototype={clear:function(){this.__data__=[],this.size=0},delete:function(e){var t=this.__data__,s=i(t,e);return!(s<0)&&(s==t.length-1?t.pop():t.splice(s,1),--this.size,!0)},get:function(e){var t=this.__data__,s=i(t,e);return s<0?void 0:t[s][1]},has:function(e){return i(this.__data__,e)>-1},set:function(e,t){var s=this.__data__,n=i(s,e);return n<0?(++this.size,s.push([e,t])):s[n][1]=t,this}};var h=function(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var n=e[t];this.set(n[0],n[1])}};h.prototype={clear:function(){this.size=0,this.__data__={hash:new o,map:new Map,string:new o}},delete:function(e){var t=a(this.__data__,e).delete(e);return this.size-=t?1:0,t},get:function(e){return a(this.__data__,e).get(e)},has:function(e){return a(this.__data__,e).has(e)},set:function(e,t){var s=a(this.__data__,e),n=s.size;return s.set(e,t),this.size+=s.size==n?0:1,this}};var l=function(e){var t=this.__data__=new d(e);this.size=t.size};l.prototype={clear:function(){this.__data__=new d,this.size=0},delete:function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},get:function(e){return this.__data__.get(e)},has:function(e){return this.__data__.has(e)},set:function(e,t){var s=this.__data__;if(s instanceof d){var n=s.__data__;if(n.length<199)return n.push([e,t]),this.size=++s.size,this;s=this.__data__=new h(n)}return s.set(e,t),this.size=s.size,this}};var c=function(t){return e.call(t).slice(8,-1)},u=function(e){return Array.isArray(e)},p=function(e){return null!=e&&"object"==typeof e},m=function(e){var t=new e.constructor(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t},f=function(e){var t=m(e.buffer);return new e.constructor(t,e.byteOffset,e.length)},g=function(e,t){var n,r,i,a,o,d,h=e.constructor;switch(t){case"ArrayBuffer":return m();case"Boolean":case"Date":return new h(+e);case"DataView":return d=m((o=e).buffer),new o.constructor(d,o.byteOffset,o.byteLength);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint8ClampedArray":case"Uint16Array":case"Uint32Array":return f(e);case"Map":case"Set":return new h;case"Number":case"String":return new h(e);case"RegExp":return(a=new(i=e).constructor(i.source,s.exec(i))).lastIndex=i.lastIndex,a;case"ImageData":return r=f((n=e).data),new n.constructor(r,n.width,n.height)}},y=function(e,s,i,a){var o;if(!p(e))return e;var d,h=c(e);o=u(e)?new(d=e).constructor(d.length):"Object"==h?{}:g(e,h);var m=(a=a||new l).get(e);if(m)return m;if(a.set(e,o),"Map"==h)return e.forEach((function(t,s){o.set(s,y(t,s,e,a))})),o;if("Set"==h)return e.forEach((function(t){o.add(y(t,t,e,a))})),o;if(function(e){return p(e)&&n.test(c(e))}(e))return o;var f=u(e)?void 0:Object.keys(Object(e));return function(e,t){for(var s=-1,n=e.length;++s<n&&!1!==t(e[s],s,e););}(f||e,(function(s,n){f&&(s=e[n=s]),function(e,s,n){if("__proto__"!=s){var i=e[s];t.call(e,s)&&r(i,n)&&(void 0!==n||s in e)||(e[s]=n)}}(o,n,y(s,n,e,a))})),o};dmx.clone=y}(),function(){var e=Object.prototype.hasOwnProperty,t=/^(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array$/,s=function(e){return toString.call(e).slice(8,-1)},n=function(e){return"object"==typeof e&&null!==e},r=function(e,t){var s=e.length;if(s!=t.length)return!1;for(var n=-1;++n<s;){var r=e[n],i=t[n];if(r!==i&&!a(r,i))return!1}return!0},i=function(i,o){var d,h=Array.isArray(i),l=Array.isArray(o),c=h?"Array":s(i),u=l?"Array":s(o),p=c==u;return p&&!("Object"==c)?h||n(d=i)&&t.test(s(d))?r(i,o):function(e,t,s){switch(s){case"DataView":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"ArrayBuffer":return!(e.byteLength!=t.byteLength||!a(new Uint8Array(e),new Uint8Array(t)));case"Boolean":case"Date":case"Number":return function(e,t){return e===t||e!=e&&t!=t}(+e,+t);case"RegExp":case"String":return e==String(t);case"Map":case"Set":return e.size==t.size&&r(Array.from(e),Array.from(t))}}(i,o,c):!!p&&function(t,s){var n=Object.keys(t),r=n.length;if(r!=Object.keys(s).length)return!1;for(var i,o=r;o--;)if(i=n[o],!e.call(s,i))return!1;for(var d=!0;++o<r;){var h=t[i=n[o]],l=s[i];if(h!==l&&!a(h,l)){d=!1;break}}if(d){var c=t.constructor,u=s.constructor;c==u||!("constructor"in t)||!("constructor"in s)||"function"==typeof c&&c instanceof c&&"function"==typeof u&&u instanceof u||(d=!1)}return d}(i,o)},a=function(e,t){return e===t||(null==e||null==t||!n(e)&&!n(t)?e!=e&&t!=t:i(e,t))};dmx.equal=a}(),dmx.createClass=(e,t)=>{const s=function(){e.constructor&&e.constructor.apply(this,arguments)};return t&&t.prototype&&(s.prototype=Object.create(t.prototype)),Object.assign(s.prototype,e),s.prototype.constructor=s,s},dmx.ready=e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{e()}),{once:!0}):e()},dmx.Config=e=>{Object.assign(dmx.config,e)},dmx.Component=(e,t)=>{if(t){const s=t.extends?dmx.Component(t.extends):dmx.BaseComponent;"function"!=typeof t.initialData&&(t.initialData=Object.assign({},s.prototype.initialData,t.initialData)),t.attributes=Object.assign({},s.prototype.attributes,t.attributes),t.methods=Object.assign({},s.prototype.methods,t.methods),t.events=Object.assign({},s.prototype.events,t.events),t.hasOwnProperty("constructor")||(t.constructor=function(e,t){s.call(this,e,t)}),t.type=e;const n=dmx.createClass(t,s);n.extends=t.extends,dmx.__components[e]=n}return dmx.__components[e]},dmx.Attribute=(e,t,s)=>{dmx.__attributes[t][e]=s},dmx.Formatter=(e,t,s)=>{dmx.__formatters[e][t]=s},dmx.Formatters=(e,t)=>{for(const s in t)dmx.Formatter(e,s,t[s])},dmx.Adapter=(e,t,s)=>(s&&(dmx.__adapters[e][t]=s),dmx.__adapters[e][t]),dmx.Action=(e,t)=>{dmx.__actions[e]=t},dmx.Actions=e=>{for(const t in e)dmx.Action(t,e[t])},dmx.Startup=e=>{dmx.__startup.add(e)},dmx.debounce=(e,t)=>{let s;return function(){const n=()=>{e.apply(this,arguments)};t?(clearTimeout(s),s=setTimeout(n,t)):(cancelAnimationFrame(s),s=requestAnimationFrame(n))}},dmx.throttle=(e,t)=>{let s,n=!1;return function(){if(s=Array.from(arguments),!n){const r=()=>{n=!1,s&&e.apply(this,s)};e.apply(this,s),s=void 0,n=!0,t?setTimeout(db,t):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(e,t,s,n){let r,i;const a=function(e){if((!n.self||e.target===e.currentTarget)&&(!n.ctrl||e.ctrlKey)&&(!n.alt||e.altKey)&&(!n.shift||e.shiftKey)&&(!n.meta||e.metaKey)&&(!(e.originalEvent||e).nsp||Object.keys(n).includes((e.originalEvent||e).nsp))){if((e.originalEvent||e)instanceof MouseEvent){if(null!=n.button&&e.button!=(parseInt(n.button,10)||0))return;if(n.button0&&0!=e.button)return;if(n.button1&&1!=e.button)return;if(n.button2&&2!=e.button)return;if(n.button3&&3!=e.button)return;if(n.button4&&4!=e.button)return}if((e.originalEvent||e)instanceof KeyboardEvent){var t=[];Object.keys(n).forEach((function(e){var s=parseInt(e,10);s?t.push(s):dmx.keyCodes[e]&&t.push(dmx.keyCodes[e])}));for(var a=0;a<t.length;a++)if(Array.isArray(t[a])){if(!t[a].includes(e.which))return}else if(e.which!==t[a])return}if(n.stop&&e.stopPropagation(),n.prevent&&e.preventDefault(),e.originalEvent&&(e=e.originalEvent),e.$data||(e.$data={}),e instanceof MouseEvent&&(e.$data.altKey=e.altKey,e.$data.ctrlKey=e.ctrlKey,e.$data.metaKey=e.metaKey,e.$data.shiftKey=e.shiftKey,e.$data.pageX=e.pageX,e.$data.pageY=e.pageY,e.$data.x=e.x||e.clientX,e.$data.y=e.y||e.clientY,e.$data.button=e.button),e instanceof WheelEvent&&(e.$data.deltaX=e.deltaX,e.$data.deltaY=e.deltaY,e.$data.deltaZ=e.deltaZ,e.$data.deltaMode=e.deltaMode),window.PointerEvent&&e instanceof PointerEvent&&(e.$data.pointerId=e.pointerId,e.$data.width=e.width,e.$data.height=e.height,e.$data.pressure=e.pressure,e.$data.tangentialPressure=e.tangentialPressure,e.$data.tiltX=e.tiltX,e.$data.tiltY=e.tiltY,e.$data.twist=e.twist,e.$data.pointerType=e.pointerType,e.$data.isPrimary=e.isPrimary),window.TouchEvent&&e instanceof TouchEvent){const t=e=>({identifier:e.identifier,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY});e.$data.altKey=e.altKey,e.$data.ctrlKey=e.ctrlKey,e.$data.metaKey=e.metaKey,e.$data.shiftKey=e.shiftKey,e.$data.touches=Array.from(e.touches).map(t),e.$data.changedTouches=Array.from(e.changedTouches).map(t),e.$data.targetTouches=Array.from(e.targetTouches).map(t),e.$data.rotation=e.rotation,e.$data.scale=e.scale}if(e instanceof KeyboardEvent&&(e.$data.altKey=e.altKey,e.$data.ctrlKey=e.ctrlKey,e.$data.metaKey=e.metaKey,e.$data.shiftKey=e.shiftKey,e.$data.location=e.location,e.$data.repeat=e.repeat,e.$data.code=e.code,e.$data.key=e.key),n.debounce)clearTimeout(r),r=setTimeout((()=>{s.apply(this,arguments)}),parseInt(n.debounce,10)||0);else{if(!n.throttle)return s.apply(this,arguments);i||(i=!0,s.apply(this,arguments),setTimeout((()=>{i=!1}),parseInt(n.throttle,10)||0))}}};return n=n||{},window.Dom7&&1===e.nodeType?(Dom7(e)[n.once?"once":"on"](t.replace(/-/g,"."),a,!!n.capture),()=>Dom7(e).off(t.replace(/-/g,"."),a,!!n.capture)):window.jQuery&&!n.capture?(jQuery(e)[n.once?"one":"on"](t.replace(/-/g,"."),a),()=>jQuery(e).off(t.replace(/-/g,"."),a)):(e.addEventListener(t.replace(/-/g,"."),a,{capture:!!n.capture,once:!!n.once,passive:!!n.passive}),()=>e.removeEventListener(t.replace(/-/g,"."),a,!!n.capture))},dmx.fileUtils={fileReader:(e,t)=>new Promise(((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=()=>n(r.error),r[t](e)})),blobToArrayBuffer:function(e){return dmx.fileUtils.fileReader(e,"readAsArrayBuffer")},blobToBinaryString:function(e){return dmx.fileUtils.fileReader(e,"readAsBinaryString")},blobToDataURL:function(e){return dmx.fileUtils.fileReader(e,"readAsDataURL")},blobToBase64String:function(e){return dmx.fileUtils.fileReader(e,"readAsDataURL").then((e=>e.substring(e.indexOf(",")+1)))},arrayBufferToBlob:function(e,t){return Promise.resolve(new Blob([e],{type:t}))},binaryStringToBlob:function(e,t){const s=Uint8Array.from(e,(e=>e.charCodeAt(0)));return Promise.resolve(new Blob([s],{type:t}))},dataURLToBlob:function(e){const{data:t,type:s}=dmx.fileUtils.parseDataURL(e);return dmx.fileUtils.base64StringToBlob(t,s)},base64StringToBlob:function(e,t){const s=window.atob(e);return dmx.fileUtils.binaryStringToBlob(s,t)},parseDataURL:function(e){const t=e.match(/^data:(.*?)(;base64)?,(.*)$/);return{mediaType:t[1],base64:!!t[2],data:t[3],type:t[1].split(";")[0]}},parseMediaType:function(e){const t=e.match(/^([^/]+)\/([^+;]+)(?:\+([^;]+))?(?:;(.*))?$/);return{type:t[1],subtype:t[2],suffix:t[3],parameters:t[4]?t[4].split(";").reduce(((e,t)=>{const[s,n]=t.split("=");return e[s]=n,e}),{}):{}}}};{const e=function(e){const t=history[e];return function(){const s=t.apply(this,arguments),n=new Event(e.toLowerCase());return n.arguments=arguments,window.dispatchEvent(n),s}};history.pushState=e("pushState"),history.replaceState=e("replaceState")}window.onpopstate=function(e){e.state&&e.state.title&&(document.title=e.state.title)},document.documentElement.style.visibility="hidden",dmx.ready((()=>{Promise.all(dmx.__startup).then((()=>{if(dmx.app)throw Error("App already running!");history.replaceState({title:document.title},"");const e=document.querySelector(':root[dmx-app], [dmx-app], :root[is="dmx-app"], [is="dmx-app"]');if(!e)throw Error("App root not found!");const t=dmx.Component("app");dmx.app=new t(e,dmx.global),document.documentElement.style.visibility=""})).catch((e=>{console.error(e),document.documentElement.style.visibility=""}))})),dmx.extend=function(){var e={},t=!1,s=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],s++);for(var r=function(s){for(var n in s)"__proto__"!=n&&Object.prototype.hasOwnProperty.call(s,n)&&(t&&"[object Object]"===Object.prototype.toString.call(s[n])?e[n]=dmx.extend(!0,e[n],s[n]):null!=s[n]&&(e[n]=s[n]))};s<n;s++){r(arguments[s])}return e},dmx.parseDate=function(e){if("string"==typeof e){var t,s=0,n=[1,4,5,6,7,10,11];if("now"==e.toLowerCase())return new Date;if(t=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(e)){for(var r,i=0;r=n[i];++i)t[r]=+t[r]||0;return t[2]=(+t[2]||1)-1,t[3]=+t[3]||1,void 0===t[8]?new Date(t[1],t[2],t[3],t[4],t[5],t[6],t[7]):("Z"!==t[8]&&void 0!==t[9]&&(s=60*t[10]+t[11],"+"===t[9]&&(s=0-s)),new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5]+s,t[6],t[7])))}if(t=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?$/.exec(e)){var a=new Date;return"Z"===t[5]?(a.setUTCHours(+t[1]||0),a.setUTCMinutes(+t[2]||0),a.setUTCSeconds(+t[3]||0),a.setUTCMilliseconds(+t[4]||0)):(a.setHours(+t[1]||0),a.setMinutes(+t[2]||0),a.setSeconds(+t[3]||0),a.setMilliseconds(+t[4]||0)),a}return new Date(e)}return"number"==typeof e?new Date(1e3*e):new Date("")},dmx.hashCode=function(e){if(null==e)return 0;var t,s=JSON.stringify(e),n=0;for(t=0;t<s.length;t++)n=(n<<5)-n+s.charCodeAt(t),n&=n;return Math.abs(n)},dmx.randomizer=function(e){return e=+e||0,function(){return(e=(9301*e+49297)%233280)/233280}},dmx.repeatItems=function(e){const t=[];if(e)if("object"==typeof e)if(Array.isArray(e))for(let s=0,n=e.length;s<n;s++){const n=dmx.clone(e[s]);t.push(Object.assign({},n,{$key:s,$index:s,$value:n}))}else{let s=0;for(const n in e)if(e.hasOwnProperty(n)){const r=dmx.clone(e[n]);t.push(Object.assign({},r,{$key:n,$index:s,$value:r})),s++}}else if("number"==typeof e)for(let s=0;s<e;s++)t.push({$key:String(s),$index:s,$value:s+1});return t},dmx.escapeRegExp=function(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")},dmx.validate=function(e){return"FORM"==e.tagName&&Array.from(e.elements).forEach((e=>e.dirty=!0)),e.checkValidity()},dmx.validateReset=function(e){},(()=>{const e=[];window.addEventListener("message",(t=>{if(t.source===window&&"dmxNextTick"===t.data&&e.length)for(t.stopPropagation();e.length;){const t=e.shift();t.fn.call(t.context)}}),!0),dmx.nextTick=(t,s)=>{e.push({fn:t,context:s}),window.postMessage("dmxNextTick","*")}})(),dmx.requestUpdate=function(){console.warn("dmx.requestUpdate is deprecated.")},"app:"==document.location.protocol&&dmx.Startup(new Promise((e=>document.addEventListener("deviceready",e)))),(()=>{
/*! (c) Andrea Giammarchi */
const{is:e}=Object;let t;dmx.batch=e=>{const s=t;t=s||[];try{if(e(),!s)for(const{value:e}of t);}finally{t=s}};class s{constructor(e){this._=e}toJSON(){return this.value}toString(){return String(this.value)}valueOf(){return this.value}}let n;dmx.Signal=s;class r extends s{s;constructor(e,t,s,n){super(e),this.f=n,this.$=!0,this.r=new Set,this.s=new p(t,s)}peek(){return this.s.peek()}get value(){if(this.$){const e=n;n=this;try{this.s.value=this._(this.s._)}finally{this.$=!1,n=e}}return this.s.value}}const i={async:!1,equals:!0};let a;dmx.computed=(e,t,s=i)=>new r(e,t,s,!1);const o=[],d=()=>{},h=({s:e})=>{"function"==typeof e._&&(e._=e._())};class l extends r{constructor(e,t,s){super(e,t,s,!0),this.e=o}run(){return this.$=!0,this.value,this}stop(){this._=d;for(const e of this.r)e.c.delete(this);this.r.clear(),this.s.c.clear()}}dmx.FX=l;class c extends l{constructor(e,t,s){super(e,t,s),this.i=0,this.a=!!s.async,this.m=!0,this.e=[]}get value(){this.a?this.async():this.sync()}async(){this.m&&(this.m=!1,queueMicrotask((()=>{this.m=!0,this.sync()})))}sync(){const e=a;(a=this).i=0,h(this),super.value,a=e}stop(){super.stop(),h(this);for(const e of this.e.splice(0))e.stop()}}dmx.Effect=c;dmx.effect=(e,t,s=i)=>{let n;if(a){const{i:r,e:i}=a,o=r===i.length;(o||i[r]._!==e)&&(o||i[r].stop(),i[r]=new c(e,t,s).run()),n=i[r],a.i++}else n=new c(e,t,s).run();return()=>{n.stop()}};const u=()=>!1;class p extends s{constructor(t,{equals:s}){super(t),this.c=new Set,this.s=!0===s?e:s||u}peek(){return this._}get value(){return n&&(this.c.add(n),n.r.add(this)),this._}set value(e){const s=this._;if(!this.s(this._=e,s)&&this.c.size){const e=[],s=[this];for(const t of s)for(const n of t.c)if(!n.$&&n.r.has(t))if(n.r.clear(),n.$=!0,n.f){e.push(n);const t=[n];for(const e of t)for(const s of e.e)s.r.clear(),s.$=!0,t.push(s)}else s.push(n.s);for(const s of e)t?t.push(s):s.value}}}dmx.signal=(e,t=i)=>new p(e,t)})(),dmx.signalProxy=function(e={}){const t=new Map,s=(e,t)=>dmx.equal(e,t);return new Proxy(e,{has:(e,t)=>!0,get(e,n,r){const i=Reflect.get(e,n,r);return"function"==typeof i||"string"!=typeof n||n.startsWith("_")?i:(t.has(n)||t.set(n,dmx.signal(i,{equals:s})),t.get(n).value)},set(e,s,n,r){const i=Reflect.set(e,s,n,r);return i&&t.has(s)&&(t.get(s).value=n),i},deleteProperty(e,s){const n=Reflect.deleteProperty(e,s);return n&&t.has(s)&&(t.get(s).value=void 0),n}})},(()=>{class e{constructor(e={},t=null){"object"!=typeof e&&(e={$value:e}),this.data=dmx.signalProxy(),Object.assign(this.data,e),this.parent=t,this.seed=Math.random()}get(e){return void 0!==this.data[e]?this.data[e]:this.parent?"parent"==e?this.parent.data:this.parent.get(e):void 0}set(e,t){"object"==typeof e?dmx.batch((()=>{for(var t in e)e.hasOwnProperty(t)&&this.set(t,e[t])})):this.data[e]=t}del(e){delete this.data[e]}}dmx.global=new e,dmx.DataScope=function(t,s){return new e(t,s||dmx.global)}})(),function(){var e=function(t){if(!(this instanceof e))return new e(t);if(t instanceof e)return t;if(!t)return this;var s=t.length;if(t.nodeType)this[0]=t,this.length=1;else{if("string"==typeof t)return e(document.querySelectorAll(t));if(s)for(var n=0;n<s;n++)t[n]&&t[n].nodeType&&(this[this.length]=t[n],this.length++)}return this};e.prototype={constructor:e,length:0,addClass:function(e){for(var t=0;t<this.length;t++)this[t].classList.add(e);return this},removeClass:function(e){for(var t=0;t<this.length;t++)this[t].classList.remove(e);return this},toggleClass:function(e){for(var t=0;t<this.length;t++)this[t].classList.toggle(e);return this},hasClass:function(e){return!!this[0]&&this[0].classList.contains(e)},attr:function(e,t){if(1===arguments.length&&"string"==typeof e)return this[0]&&this[0].getAttribute(e);for(var s=0;s<this.length;s++)if(2===arguments.length)this[s].setAttribute(e,t);else for(var n in e)e.hasOwnProperty(n)&&this[s].setAttribute(n,e[n]);return this},removeAttr:function(e){for(var t=0;t<this.length;t++)this[t].removeAttribute(e);return this},prop:function(e,t){if(1===arguments.length&&"string"==typeof e)return this[0]&&this[0][e];for(var s=0;s<this.length;s++)if(2===arguments.length)this[s][e]=t;else for(var n in e)e.hasOwnProperty(n)&&(this[s][n]=e[n]);return this},css:function(e,t){if(1===arguments.length&&"string"==typeof e)return this[0]&&window.getComputedStyle(this[0],null).getPropertyValue(e);for(var s=0;s<this.length;s++)if(2===arguments.length)this[s].style.setProperty(e,t);else for(var n in e)e.hasOwnProperty(n)&&this[s].style.setProperty(n,e[n]);return this},each:function(e,t){if(!e)return this;for(var s=0;s<this.length;s++)if(!1===e.call(t||this[s],s,this[s]))return this;return this},append:function(){for(var t=0;t<arguments.length;t++)for(var s=e(arguments[t]),n=0;n<s.length;n++)this[0].appendChild(s[n]);return this},appendTo:function(t){return e(t).append(this),this},detach:function(){for(var e=0;e<this.length;e++)this[e].parentNode&&this[e].parentNode.removeChild(this[e]);return this},empty:function(){for(var e=0;e<this.length;e++)this[e].innerHTML="";return this}},dmx.dom={get:function(t){return e(document.getElementById(t))},select:function(t){return e(t)},create:function(t){var s=document.createElement(t);return e(s)},contains:function(e){return document.documentElement.contains(e)},walk:function(e,t,s){if(e){if(!1===t.call(s,e))return;if(e.hasChildNodes())for(const n of Array.from(e.childNodes))dmx.dom.walk(n,t,s)}},getAttributes:function(e){var t=[];if(1==e.nodeType)for(var s=0;s<e.attributes.length;s++){var n=e.attributes[s];if(n&&n.specified&&dmx.rePrefixed.test(n.name)){var r=n.name.substr(4),i=null,a={};r.split(".").forEach((function(e,t){if(0===t)r=e;else{var s=e.indexOf(":");s>0?a[e.substr(0,s)]=e.substr(s+1):a[e]=!0}}));var o=r.indexOf(":");o>0&&(i=r.substr(o+1),r=r.substr(0,o)),t.push({name:r,fullName:n.name,value:n.value,argument:i,modifiers:a})}}return t},remove:function(e){Array.isArray(e)?e.forEach((function(e){dmx.dom.remove(e)})):e.remove()},replace:function(e,t){e.parentNode&&e.parentNode.replaceChild(t,e)}}}(),dmx._CACHE=new Map,dmx._OPERATORS=new Map([["{","L_CURLY"],["}","R_CURLY"],["[","L_BRACKET"],["]","R_BRACKET"],["(","L_PAREN"],[")","R_PAREN"],[".","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"]]),dmx._ESCAPE_CHARS=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["'","'"],["`","`"],['"','"']]),dmx._EXPRESSIONS=new Map([["**",(e,t)=>Math.pow(e(),t())],["??",(e,t)=>null==(e=e())?t():e],["in",(e,t)=>e()in t()],["?",(e,t,s)=>e()?t():s()],["+",(e,t)=>(e=e(),t=t(),null==e?t:null==t?e:e+t)],["-",(e,t)=>e()-t()],["*",(e,t)=>e()*t()],["/",(e,t)=>e()/t()],["%",(e,t)=>e()%t()],["===",(e,t)=>e()===t()],["!==",(e,t)=>e()!==t()],["==",(e,t)=>e()==t()],["!=",(e,t)=>e()!=t()],["<",(e,t)=>e()<t()],[">",(e,t)=>e()>t()],["<=",(e,t)=>e()<=t()],[">=",(e,t)=>e()>=t()],["&&",(e,t)=>e()&&t()],["||",(e,t)=>e()||t()],["&",(e,t)=>e()&t()],["|",(e,t)=>e()|t()],["^",(e,t)=>e()^t()],["<<",(e,t)=>e()<<t()],[">>",(e,t)=>e()>>t()],[">>>",(e,t)=>e()>>>t()],["~",e=>~e()],["!",e=>!e()]]),dmx._RESERVED=new Map([["this",e=>()=>e.data],["true",()=>()=>!0],["false",()=>()=>!1],["null",()=>()=>null],["undefined",()=>()=>{}],["_",()=>()=>({__dmxScope__:!0})]]),dmx._SUPPORTED_TYPES=new Map([["Boolean","boolean"],["Null","null"],["Undefined","undefined"],["Number","number"],["BigInt","number"],["Decimal","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"]]),dmx.getType=function(e){return dmx._SUPPORTED_TYPES.get(Object.prototype.toString.call(e).slice(8,-1))},dmx.lexer=function(e){if(dmx._CACHE.has(e))return dmx._CACHE.get(e);let t,s,n,r,i,a,o=[],d=0,h=!0;for(;d<e.length;){if(n=d,r=l(),p(r))s="STRING",t=v(r),h=!1;else if((m(r)||u(".")&&c()&&m(c()))&&h)s="NUMBER",t=x(),h=!1;else if(f(r)&&h)s="IDENT",t=b(),u("(")&&(s="METHOD"),h=!1;else if(u("/")&&h&&("("==t||","==t||"?"==t||":"==t)&&E())s="REGEXP",t=w(),h=!1;else{if(y(r)){d++;continue}if((a=l(3))&&dmx._OPERATORS.has(a))s=dmx._OPERATORS.get(a),t=a,h=!0,d+=3;else if((i=l(2))&&dmx._OPERATORS.has(i))s=dmx._OPERATORS.get(i),t=i,h=!0,d+=2;else{if(!dmx._OPERATORS.has(r))throw new Error(`Unexpected token "${r}" at index ${d} in expression: ${e}`);s=dmx._OPERATORS.get(r),t=r,h=!0,d++}}o.push({name:s,index:n,value:t})}return dmx._CACHE.set(e,o),o;function l(t){return t>1?e.slice(d,d+t):e[d]}function c(t=1){return d+t<e.length&&e[d+t]}function u(e){return e.includes(r)}function p(e){return'"'==e||"'"==e||"`"==e}function m(e){return e>="0"&&e<="9"}function f(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e||"$"===e}function g(e){return f(e)||m(e)}function y(e){return" "==e||"\r"==e||"\t"==e||"\n"==e||"\v"==e||" "==e}function _(e){return"-"==e||"+"==e||m(e)}function v(t){let s=!1,n="";for(d++;d<e.length;){if(r=l(),s){if("u"==r){d++;const t=l(4);if(!t.match(/[\da-f]{4}/i))throw new Error(`Invalid unicode escape [\\u${t}] at index ${d} in expression: ${e}`);n+=String.fromCharCode(parseInt(t,16)),d+=4}else n+=dmx._ESCAPE_CHARS.has(r)?dmx._ESCAPE_CHARS.get(r):r;s=!1}else if("\\"==r)s=!0;else{if(r==t)return d++,"`"==t&&(n="{{"+n+"}}"),n;n+=r}d++}throw new Error(`Unterminated string in expression: ${e}`)}function x(){let t="",s=!1;for(;d<e.length;)if(r=l(),u("_")&&c()&&m(c()))d++;else{if(u(".")&&c()&&m(c())||m(r))t+=r;else{const n=c();if(u("eE")&&_(n))t+="e",s=!0;else{if(!(_(r)&&n&&m(n)&&s)){if(!_(r)||n&&m(n)||!s)break;throw new Error(`Invalid exponent in expression: ${e}`)}t+=r,s=!1}}d++}if("n"==l())return d++,BigInt(t);if("m"==l()){if(d++,window.Decimal)return new Decimal(t);console.warn("Decimal number in expression but library not found")}return+t}function b(){let t="";for(;d<e.length&&(r=l(),g(r));)t+=r,d++;return t}function w(){let t="",s="",n=!1;for(d++;d<e.length;){if(r=l(),n)n=!1;else if("\\"==r)n=!0;else if("/"==r){for(d++;"ign".includes(r=l());)s+=r,d++;return new RegExp(t,s)}t+=r,d++}throw new Error(`Unterminated regexp in expression: ${e}`)}function E(){let e=d,t=!0;try{w()}catch(e){t=!1}return d=e,r="/",t}},dmx.parse=function(e,t=dmx.app){if((e=e.trim()).includes("{{")){if(!e.startsWith("{{")||!e.endsWith("}}")||e.slice(2).includes("{{"))return e.replace(/{{(.+?)}}/g,((e,s)=>{const n=dmx.parse(s,t);return null==n?"":n}));e=e.slice(2,-2)}if(!e)return;let s,n,r;try{s=Array.from(dmx.lexer(e)),r=function(){const e=[];for(;;)if(s.length>0&&!(a("R_PAREN")||a("R_BRACKET")||a("R_CURLY")||a("COMMA")||a("SEMI"))&&e.push(l()),!o("COMMA")&&!o("SEMI"))return(1==e.length?e[0]:t)();function t(){let t;for(let s=0;s<e.length;s++){const n=e[s];n&&(t=n())}return t}}()}catch(t){console.error("Error parsing expression:",e,t)}return r;function i(){if(0===s.length)throw new Error(`Unexpected end of expression: ${e}`);return s[0]}function a(e){if(s.length>0){const t=s[0];if(!e||t.name==e)return t}return!1}function o(e){const t=a(e);return!!t&&(s.shift(),t)}function d(t){if(!o(t))throw new Error(`Expected ${t} at index ${s[0].index} in expression: ${e}`)}function h(e){const s=Array.prototype.slice.call(arguments,1);return()=>dmx._EXPRESSIONS.has(e)?dmx._EXPRESSIONS.get(e).apply(t,s):e}function l(){return function(){const e=function(){let e=c();for(;o("LOGICAL_OR");){e=h("||",e,c())}return e}();if(o("QUESTION")){const t=l();d("COLON");return h("?",e,t,l())}return e}()}function c(){let e=u();for(;o("LOGICAL_AND");){e=h("&&",e,u())}return e}function u(){let e=p();for(;o("BITWISE_OR");){e=h("|",e,p())}return e}function p(){let e=m();for(;o("BITWISE_XOR");){e=h("^",e,m())}return e}function m(){let e=f();for(;o("BITWISE_AND");){e=h("&",e,f())}return e}function f(){let e,t=g();if(e=o("EQUALITY")){const s=f();t=h(e.value,t,s)}return t}function g(){let e,t=y();if(e=o("RELATIONAL")){const s=g();t=h(e.value,t,s)}return t}function y(){let e,t=function(){let e,t=_();for(;e=o("ADDICTIVE");){const s=_();t=h(e.value,t,s)}return t}();if(e=o("BITWISE_SHIFT")){const s=y();t=h(e.value,t,s)}return t}function _(){let e,t=v();for(;e=o("MULTIPLICATIVE");){const s=v();t=h(e.value,t,s)}return t}function v(){let e;return(e=o("ADDICTIVE"))?"+"==e.value?x():h(e.value,(()=>0),x()):(e=o("LOGICAL_NOT"))||(e=o("BITWISE_NOT"))?h(e.value,v()):x()}function x(){let s,r;if(o("L_PAREN"))s=l(),d("R_PAREN");else if(o("L_CURLY")){const e={};if("R_CURLY"!=i().name)do{const t=o().value;d("COLON"),e[t]=l()()}while(o("COMMA"));s=h(e),d("R_CURLY")}else if(o("L_BRACKET")){const e=[];if("R_BRACKET"!=i().name)do{e.push(l()())}while(o("COMMA"));s=h(e),d("R_BRACKET")}else if(o("PERIOD"))s=a()?E(h(t.data)):h(t.data);else{const n=o();if(!1===n)throw new Error(`Unexpected end of expression: ${e}`);s="IDENT"==n.name?dmx._RESERVED.has(n.value)?dmx._RESERVED.get(n.value)(t):()=>t.get(n.value):"METHOD"==n.name?h(dmx.__formatters.global[n.value]||(()=>{console.warn(`Method "${n.value}" not found in expression: ${e}`)})):()=>n.value}for(;r=o("L_PAREN")||o("L_BRACKET")||o("PERIOD");)if("("==r.value)s=b(s,n);else if("["==r.value)n=s,s=w(s);else{if("."!=r.value)throw new Error(`Unexpected token "${r.value}" at index ${r.index} in expression: ${e}`);n=s,s=E(s)}return n=null,s}function b(s,n){const r=[];if("R_PAREN"!=i().name)do{r.push(l())}while(o("COMMA"));return d("R_PAREN"),()=>{let i=[];n&&i.push(n());for(let e of r)i.push(e());try{return(s()||dmx.noop).apply(t,i)}catch(t){return void console.warn(`Error calling method ${s().name} in expression: ${e}`,t)}}}function w(e){const s=l();return d("R_BRACKET"),()=>{const n=e(),r=s();if("object"==typeof n&&null!=n)return n.__dmxScope__?t.get(r):"map"==dmx.getType(n)?n.get(r):n[r]}}function E(s){const n=o();return()=>{const r=s(),i=dmx.getType(r);if("METHOD"==n.name){const t="__"+n.value;return"map"==i&&"function"==typeof r.get(t)?r.get(t).bind(r):"object"==i&&"function"==typeof r[t]?r[t]:dmx.__formatters[i]&&dmx.__formatters[i][n.value]?dmx.__formatters[i][n.value]:dmx.__formatters.any&&dmx.__formatters.any[n.value]?dmx.__formatters.any[n.value]:()=>{null!=r&&console.warn(`Method "${n.value}" not found in expression: ${e}`)}}return r&&r.__dmxScope__?t.get(n.value):"map"==i?r.get(n.value):r&&"object"==typeof r&&n.value in r?r[n.value]:void 0}}},dmx.BaseComponent=dmx.createClass({constructor:function(e,t){this.$node=e,this.parent=t,this.children=[],this.listeners={},this.__disposables=[],this.__childDisposables=[],this.updatedProps=new Map,this.updateRequested=!1,this.isInitialized=!1,this.isDestroyed=!1,this.props=new Proxy({},{set:(e,t,s,n)=>{const r=Reflect.get(e,t,n),i=Reflect.set(e,t,s,n);return i&&this.isInitialized&&(this.attributes[t]&&this.attributes[t].alwaysUpdate||!dmx.equal(r,s))&&this.requestUpdate(t,r),i}}),this.data=dmx.signalProxy(),this.seed=Math.random(),this.name=e.getAttribute("id")||e.getAttribute("name")||this.type&&this.type.toLowerCase().replace(/^dmx-/,"")||"",this.name=this.name.replace(/[^\w]/g,"");try{this.$initialData(),this.$parseAttributes(e),this.init(e),!1!==this.render&&this.render(e),this.$node&&(this.$customAttributes("mounted",this.$node),this.$node.dmxComponent=this,this.$node.dmxRendered=!0),this.isInitialized=!0}catch(e){console.error(e)}},tag:null,initialData:{},attributes:{},methods:{},events:{destroy:Event},render:function(e){this.$node&&this.$parse()},parse:function(e){return dmx.parse(e,this)},find:function(e){if(this.name==e)return this;for(var t=0;t<this.children.length;t++){var s=this.children[t].find(e);if(s)return s}return null},init:dmx.noop,beforeUpdate:dmx.noop,update:dmx.noop,updated:dmx.noop,beforeDestroy:dmx.noop,destroy:dmx.noop,destroyed:dmx.noop,addEventListener:function(e,t){e in this.listeners||(this.listeners[e]=new Set),this.listeners[e].add(t)},removeEventListener:function(e,t){e in this.listeners&&this.listeners[e].delete(t)},dispatchEvent:function(e,t,s,n){if(!this.isDestroyed){if("string"==typeof e)e=new(this.events[e]||CustomEvent)(e,t);if(!(e.type in this.listeners))return!0;e.nsp=n,e.target=this,e.$data=s||{};for(let t of this.listeners[e.type])!1===t.call(this,e)&&e.preventDefault();return!e.defaultPrevented}},$createChild:function(e,t){var s=new(0,dmx.__components[e])(t,this);this.$addChild(s,s.name)},$addChild:function(e,t){this.children.push(e),t&&(this.data[t]&&dmx.debug&&console.warn('Duplicate name "'+t+'" found, component not added to scope.'),this.set(t,e.data))},$removeChild:function(e){this.children.includes(e)&&this.children.splice(this.children.indexOf(e),1),e.name&&this.data[e.name]&&this.del(e.name)},$customAttributes:function(e,t,s){s||(s=dmx.dom.getAttributes(t)),s.forEach((s=>{if(t==this.$node){if("bind"==s.name&&this.attributes[(n=s.argument,n.replace(/-./g,(e=>e[1].toUpperCase())))])return;if("on"==s.name&&this.events[s.argument])return}var n;if(dmx.__attributes[e][s.name]){this.__inChild=t!=this.$node;const n=dmx.__attributes[e][s.name].call(this,t,s);n&&this[this.__inChild?"__childDisposables":"__disposables"].push(n)}})),this.__inChild=null},$parseTextNode(e){if(3===e.nodeType&&dmx.reExpression.test(e.nodeValue)){const t=e.nodeValue.replace(dmx.reExpressionReplace,((e,t)=>`##split##${t}##split##`)).split("##split##"),s=document.createDocumentFragment();t.forEach(((e,t)=>{const n=document.createTextNode(e);s.appendChild(n),t%2&&this.$watch(e,(e=>{n.nodeValue=e}))})),e.parentNode.replaceChild(s,e)}},$parse:function(e){if(e=e||this.$node)return 3===e.nodeType?this.$parseTextNode(e):void(1===e.nodeType&&(dmx.config.mapping&&Object.keys(dmx.config.mapping).forEach((t=>{dmx.array(e.querySelectorAll(t)).forEach((e=>{e.hasAttribute("is")||e.setAttribute("is","dmx-"+dmx.config.mapping[t])}))})),dmx.dom.walk(e,(function(e){if(e!=this.$node){if(1===e.nodeType){var t=e.tagName.toLowerCase(),s=dmx.dom.getAttributes(e);if(e.hasAttribute("is")&&(t=e.getAttribute("is")),dmx.reIgnoreElement.test(t))return!1;if(this.$customAttributes("before",e,s),-1!==s.findIndex((e=>"repeat"===e.name)))return!1;if(dmx.rePrefixed.test(t))return(t=t.replace(/^dmx-/i,""))in dmx.__components?(e.isComponent=!0,e.dmxRendered?window.__WAPPLER__&&e.dmxComponent&&e.dmxComponent.$parse&&(dmx.reIgnoreElement.test(e.tagName)||e.dmxComponent.$parse()):this.$createChild(t,e),!1):void console.warn("Unknown component found! "+t);this.$customAttributes("mounted",e,s)}3===e.nodeType&&this.$parseTextNode(e)}}),this)))},$update:function(e){console.warn("Component.$update is deprecated.")},$parseAttributes:function(e){for(const t in this.attributes){const s=this.attributes[t],n=t.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()));let r=dmx.clone(s.default);if(e.hasAttribute(n)){if(s.type===Boolean)r="false"!==e.getAttribute(n);else{if(r=e.getAttribute(n),s.type===Number&&r&&isFinite(Number(r))&&(r=Number(r)),s.type===Object||s.type===Array)try{r=JSON.parse(r)}catch(e){console.warn("Invalid attribute value, expected a JSON string got "+r)}s.enum&&!s.enum.includes(r)&&(r=dmx.clone(s.default)),s.validate&&!s.validate(r)&&(r=dmx.clone(s.default))}this.props[t]=r}if(e.hasAttribute("dmx-bind:"+n)){const r=e.getAttribute("dmx-bind:"+n);this.$watch(r,(e=>{void 0===e?e=dmx.clone(s.default):s.type===Boolean?e=!!e:(null!=e&&(s.type===Number&&("string"==typeof e?e=e&&isFinite(Number(e))?Number(e):dmx.clone(s.default):"number"==typeof e&&isFinite(Number(e))||(e=dmx.clone(s.default))),s.type===String&&(e=String(e)),s.type===Object&&"object"!=typeof e&&(e=dmx.clone(s.default)),s.type===Array&&(e=Array.from(e))),s.enum&&!s.enum.includes(e)&&(e=dmx.clone(s.default)),s.validate&&!s.validate(e)&&(e=dmx.clone(s.default))),this.props[t]=e}))}else this.props[t]=r}for(const t in this.events)e.hasAttribute("on"+t)&&this.__disposables.push(dmx.eventListener(this,t,Function("event",e.getAttribute("on"+t)),{}));dmx.dom.getAttributes(e).forEach((e=>{"on"==e.name&&this.events[e.argument]&&this.__disposables.push(dmx.eventListener(this,e.argument,(t=>(t.originalEvent&&(t=t.originalEvent),dmx.parse(e.value,dmx.DataScope({$event:t.$data,$originalEvent:t},this)))),e.modifiers))}))},requestUpdate:function(e,t){this.performUpdate&&(this.updatedProps.has(e)||this.updatedProps.set(e,t),this.updateRequested||dmx.nextTick((()=>{this.isDestroyed||(this.updateRequested=!1,this.performUpdate(this.updatedProps),this.updatedProps.clear())})),this.updateRequested=!0)},$initialData:function(){Object.assign(this.data,{$type:this.type},"function"==typeof this.initialData?this.initialData():this.initialData),Object.keys(this.methods).forEach((function(e){var t=this;this.data["__"+e]=function(){return t.methods[e].apply(t,Array.prototype.slice.call(arguments,1))}}),this)},$addBinding:function(e,t){this.$watch(e,t)},$watch:function(e,t){const s=this.__inChild?"__childDisposables":"__disposables";this[s]||(this[s]=[]);let n=!0;this[s].push(dmx.effect((()=>{if(n)t.call(this,this.parse(e)),n=!1;else{const s=this.parse(e);queueMicrotask((()=>t.call(this,s)))}})))},$destroy:function(){this.dispatchEvent("destroy"),this.beforeDestroy(),this.destroy(),this.isDestroyed=!0,this.parent&&this.parent.$removeChild&&this.parent.$removeChild(this),this.$destroyChildren(),this.__disposables.forEach((e=>e())),this.__disposables=[],this.$node&&(this.$node.dmxComponent=null,this.$node=null),this.parent=null,this.data={},this.destroyed()},$destroyChildren:function(){Array.from(this.children).forEach((e=>{e.$destroy()})),this.children=[],this.__childDisposables.forEach((e=>e())),this.__childDisposables=[]},get:function(e,t){return void 0!==this.data[e]?this.data[e]:this.parent&&!0!==t?"parent"==e?this.parent.data:this.parent.get(e):void 0},add:function(e,t){this.data[e]?Array.isArray(this.data[e])?this.data[e].push(t):this.data[e]=[this.data[e],t]:this.set(e,t)},set:function(e,t){"object"==typeof e?dmx.batch((()=>{for(var t in e)e.hasOwnProperty(t)&&this.set(t,e[t])})):this.data[e]=t},del:function(e){delete this.data[e]}}),function(){dmx.pathToRegexp=d,dmx.pathToRegexp.parse=s,dmx.pathToRegexp.compile=function(e,t){return n(s(e,t))},dmx.pathToRegexp.tokensToFunction=n,dmx.pathToRegexp.tokensToRegExp=o;var e="/",t=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function s(s,n){for(var a,o=[],d=0,h=0,l="",c=n&&n.delimiter||e,u=n&&n.whitelist||void 0,p=!1;null!==(a=t.exec(s));){var m=a[0],f=a[1],g=a.index;if(l+=s.slice(h,g),h=g+m.length,f)l+=f[1],p=!0;else{var y="",_=a[2],v=a[3],x=a[4],b=a[5];if(!p&&l.length){var w=l.length-1,E=l[w];(!u||u.indexOf(E)>-1)&&(y=E,l=l.slice(0,w))}l&&(o.push(l),l="",p=!1);var $="+"===b||"*"===b,k="?"===b||"*"===b,A=v||x,C=y||c;o.push({name:_||d++,prefix:y,delimiter:C,optional:k,repeat:$,pattern:A?i(A):"[^"+r(C===c?C:C+c)+"]+?"})}}return(l||h<s.length)&&o.push(l+s.substr(h)),o}function n(e){for(var t=new Array(e.length),s=0;s<e.length;s++)"object"==typeof e[s]&&(t[s]=new RegExp("^(?:"+e[s].pattern+")$"));return function(s,n){for(var r="",i=n&&n.encode||encodeURIComponent,a=0;a<e.length;a++){var o=e[a];if("string"!=typeof o){var d,h=s?s[o.name]:void 0;if(Array.isArray(h)){if(!o.repeat)throw new TypeError('Expected "'+o.name+'" to not repeat, but got array');if(0===h.length){if(o.optional)continue;throw new TypeError('Expected "'+o.name+'" to not be empty')}for(var l=0;l<h.length;l++){if(d=i(h[l],o),!t[a].test(d))throw new TypeError('Expected all "'+o.name+'" to match "'+o.pattern+'"');r+=(0===l?o.prefix:o.delimiter)+d}}else if("string"!=typeof h&&"number"!=typeof h&&"boolean"!=typeof h){if(!o.optional)throw new TypeError('Expected "'+o.name+'" to be '+(o.repeat?"an array":"a string"))}else{if(d=i(String(h),o),!t[a].test(d))throw new TypeError('Expected "'+o.name+'" to match "'+o.pattern+'", but got "'+d+'"');r+=o.prefix+d}}else r+=o}return r}}function r(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function i(e){return e.replace(/([=!:$/()])/g,"\\$1")}function a(e){return e&&e.sensitive?"":"i"}function o(t,s,n){for(var i=(n=n||{}).strict,o=!1!==n.start,d=!1!==n.end,h=n.delimiter||e,l=[].concat(n.endsWith||[]).map(r).concat("$").join("|"),c=o?"^":"",u=0;u<t.length;u++){var p=t[u];if("string"==typeof p)c+=r(p);else{var m=p.repeat?"(?:"+p.pattern+")(?:"+r(p.delimiter)+"(?:"+p.pattern+"))*":p.pattern;s&&s.push(p),p.optional?p.prefix?c+="(?:"+r(p.prefix)+"("+m+"))?":c+="("+m+")?":c+=r(p.prefix)+"("+m+")"}}if(d)i||(c+="(?:"+r(h)+")?"),c+="$"===l?"$":"(?="+l+")";else{var f=t[t.length-1],g="string"==typeof f?f[f.length-1]===h:void 0===f;i||(c+="(?:"+r(h)+"(?="+l+"))?"),g||(c+="(?="+r(h)+"|"+l+")")}return new RegExp(c,a(n))}function d(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var s=e.source.match(/\((?!\?)/g);if(s)for(var n=0;n<s.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,pattern:null});return e}(e,t):Array.isArray(e)?function(e,t,s){for(var n=[],r=0;r<e.length;r++)n.push(d(e[r],t,s).source);return new RegExp("(?:"+n.join("|")+")",a(s))}(e,t,n):function(e,t,n){return o(s(e,n),t,n)}(e,t,n)}}(),window.Hjson||(window.Hjson={},Hjson.parse=function(e){var t,s,n,r={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(e){return"{"===e||"}"===e||"["===e||"]"===e||","===e||":"===e}function a(e){var n,r=0,i=1;for(n=s-1;n>0&&"\n"!==t[n];n--,r++);for(;n>0;n--)"\n"===t[n]&&i++;throw new Error(e+" at line "+i+","+r+" >>>"+t.substr(s-r,20)+" ...")}function o(){return n=t.charAt(s),s++,n}function d(e){return t.charAt(s+e)}function h(e){for(var t="",s=n;o();){if(n===s)return o(),e&&"'"===s&&"'"===n&&0===t.length?(o(),l()):t;if("\\"===n)if(o(),"u"===n){for(var i=0,d=0;d<4;d++){o();var h,c=n.charCodeAt(0);n>="0"&&n<="9"?h=c-48:n>="a"&&n<="f"?h=c-97+10:n>="A"&&n<="F"?h=c-65+10:a("Bad \\u char "+n),i=16*i+h}t+=String.fromCharCode(i)}else{if("string"!=typeof r[n])break;t+=r[n]}else"\n"===n||"\r"===n?a("Bad string containing newline"):t+=n}a("Bad string")}function l(){for(var e="",t=0,s=0;;){var r=d(-s-5);if(!r||"\n"===r)break;s++}function i(){for(var e=s;n&&n<=" "&&"\n"!==n&&e-- >0;)o()}for(;n&&n<=" "&&"\n"!==n;)o();for("\n"===n&&(o(),i());;){if(n){if("'"===n){if(t++,o(),3===t)return"\n"===e.slice(-1)&&(e=e.slice(0,-1)),e;continue}for(;t>0;)e+="'",t--}else a("Bad multiline string");"\n"===n?(e+="\n",o(),i()):("\r"!==n&&(e+=n),o())}}function c(){if('"'===n||"'"===n)return h(!1);for(var e="",t=s,r=-1;;){if(":"===n)return e?r>=0&&r!==e.length&&(s=t+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)"),e;n<=" "?n?r<0&&(r=e.length):a("Found EOF while looking for a key name (check your syntax)"):i(n)?a("Found '"+n+"' where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace)"):e+=n,o()}}function u(){for(;n;){for(;n&&n<=" ";)o();if("#"===n||"/"===n&&"/"===d(0))for(;n&&"\n"!==n;)o();else{if("/"!==n||"*"!==d(0))break;for(o(),o();n&&("*"!==n||"/"!==d(0));)o();n&&(o(),o())}}}function p(e,t){var s,n,r="",i=0,a=!0,o=0;function d(){return n=e.charAt(o),o++,n}for(d(),"-"===n&&(r="-",d());n>="0"&&n<="9";)a&&("0"==n?i++:a=!1),r+=n,d();if(a&&i--,"."===n)for(r+=".";d()&&n>="0"&&n<="9";)r+=n;if("e"===n||"E"===n)for(r+=n,d(),"-"!==n&&"+"!==n||(r+=n,d());n>="0"&&n<="9";)r+=n,d();for(;n&&n<=" ";)d();return t&&(","!==n&&"}"!==n&&"]"!==n&&"#"!==n&&("/"!==n||"/"!==e[o]&&"*"!==e[o])||(n=0)),s=+r,n||i||!isFinite(s)?void 0:s}function m(e){function t(e,s){var n,r,i,a;switch(typeof e){case"string":e.indexOf(s)>=0&&(a=e);break;case"object":if("[object Array]"===Object.prototype.toString.apply(e))for(n=0,i=e.length;n<i;n++)a=t(e[n],s)||a;else for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&(a=t(e[r],s)||a)}return a}function s(s){var n=t(e,s);return n?"found '"+s+"' in a string value, your mistake could be with:\n  > "+n+"\n  (unquoted strings contain everything up to the next line!)":""}return s("}")||s("]")}function f(){var e=[];try{if(o(),u(),"]"===n)return o(),e;for(;n;){if(e.push(y()),u(),","===n&&(o(),u()),"]"===n)return o(),e;u()}a("End of input while parsing an array (missing ']')")}catch(t){throw t.hint=t.hint||m(e),t}}function g(e){var t="",s={};try{if(e||o(),u(),"}"===n&&!e)return o(),s;for(;n;){if(t=c(),u(),":"!==n&&a("Expected ':' instead of '"+n+"'"),o(),s[t]=y(),u(),","===n&&(o(),u()),"}"===n&&!e)return o(),s;u()}if(e)return s;a("End of input while parsing an object (missing '}')")}catch(e){throw e.hint=e.hint||m(s),e}}function y(){switch(u(),n){case"{":return g();case"[":return f();case"'":case'"':return h(!0);default:return function(){var e=n;for(i(n)&&a("Found a punctuator character '"+n+"' when expecting a quoteless string (check your syntax)");;){o();var t="\r"===n||"\n"===n||""===n;if(t||","===n||"}"===n||"]"===n||"#"===n||"/"===n&&("/"===d(0)||"*"===d(0))){var s=e[0];switch(s){case"f":if("false"===e.trim())return!1;break;case"n":if("null"===e.trim())return null;break;case"t":if("true"===e.trim())return!0;break;default:if("-"===s||s>="0"&&s<="9"){var r=p(e);if(void 0!==r)return r}}if(t)return e.trim()}e+=n}}()}}function _(e){return u(),n&&a("Syntax error, found trailing characters"),e}if("string"!=typeof e)throw new Error("source is not a string");return t=e,s=0,n=" ",function(){switch(u(),n){case"{":return _(g());case"[":return _(f());default:return _(y())}}()}),dmx.Flow=dmx.createClass({constructor:function(e){if(!(this instanceof dmx.Flow))return new dmx.Flow(e);window.Promise||console.warn("Promises are not supported, flows can not be used"),this._execStep=this._execStep.bind(this),this.scope=new dmx.DataScope({},e),this.output={}},run:function(e){return this.output={},this._exec(e.exec||e).then((()=>(dmx.debug&&console.debug("finished",this.output),this.output)))},_each:function(e,t){return Promise.resolve(e).then((e=>(e=Array.isArray(e)?e:[e]).reduce(((s,n,r)=>s.then((()=>t(n,r,e.length).then((t=>{t&&(e[r]=t)}))))),Promise.resolve()).then((()=>e))))},_exec:function(e){if(e.steps){var t=this._each(e.steps,this._execStep);return e.catch&&t.catch((t=>this._each(e.catch,self._execStep))),t}return this._each(e,this._execStep)},_execStep:function(e){for(let t in e){if(e.hasOwnProperty(t)&&dmx.__actions[t]){const s=dmx.__actions[t].bind(this),n=e[t],r=t+Date.now();return dmx.debug&&(console.debug("exec action",t,n),console.time(r)),n.disabled?Promise.resolve():Promise.resolve(s(n)).then((e=>{dmx.debug&&(console.debug("finished exec action",t,n),console.timeEnd(r)),n.name&&(dmx.debug&&console.debug("set data",n.name,e),this.scope.set(n.name,e),n.output&&(dmx.debug&&console.debug("set output",n.name,e),this.output[n.name]=e))}))}throw new Error("Action "+t+" was not found.")}},parse:function(e){if(null==e)return e;if("object"==typeof(e=e.valueOf())){var t=e.slice?[]:{};for(var s in e)e.hasOwnProperty(s)&&(t[s]=this.parse(e[s],this.scope));return t}return"string"==typeof e&&-1!=e.indexOf("{{")?dmx.parse(e,this.scope):e}}),dmx.Flow.run=function(e,t){return new dmx.Flow(t).run(e)},dmx.Component("app",{initialData:{query:{}},events:{ready:Event,load:Event},init(){this.dispatchLoad=this.dispatchEvent.bind(this,"load"),this._parseQuery=this._parseQuery.bind(this),window.addEventListener("load",this.dispatchLoad,{once:!0}),window.addEventListener("load",this._parseQuery),window.addEventListener("popstate",this._parseQuery),window.addEventListener("pushstate",this._parseQuery),window.addEventListener("replacestate",this._parseQuery),this._parseQuery(),queueMicrotask((()=>this.dispatchEvent("ready")))},destroy(){window.removeEventListener("load",this.dispatchLoad),window.removeEventListener("load",this._parseQuery),window.removeEventListener("popstate",this._parseQuery),window.removeEventListener("pushstate",this._parseQuery),window.removeEventListener("replacestate",this._parseQuery)},_parseQuery(){let e="";window.location.search?e=window.location.search.slice(1):window.location.hash.indexOf("?")&&(e=window.location.hash.slice(window.location.hash.indexOf("?")+1),e.indexOf("#")>0&&(e=e.slice(0,e.indexOf("#"))));let t=e.split("&").reduce((function(e,t){var s=t.replace(/\+/g," ").split("=");return s[0]&&(e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]||"")),e}),{}),s=document.querySelector('meta[name="ac:base"]'),n=document.querySelector('meta[name="ac:route"]');if(n&&n.content){let e=[],r=n.content;s&&s.content&&(r=s.content.replace(/\/$/,"")+r);let i=dmx.pathToRegexp(r,e,{end:!1}).exec(decodeURI(window.location.pathname));i&&e.forEach((function(e,s){t[e.name]=i[s+1]}))}this.set("query",t)}}),dmx.Component("form",{attributes:{novalidate:{type:Boolean,default:!1}},methods:{submit(e){this._submit(e)},reset(){this._reset()},validate(){this._validate()}},events:{invalid:Event,submit:Event},init(e){this._submitHandler=this._submitHandler.bind(this),this._resetHandler=this._resetHandler.bind(this),e.noValidate=!0,e.addEventListener("submit",this._submitHandler),e.addEventListener("reset",this._resetHandler)},destroy(){this.$node.removeEventListener("submit",this._submitHandler),this.$node.removeEventListener("reset",this._resetHandler)},_submitHandler(e){e.preventDefault(),this._submit()},_resetHandler(e){dmx.validateReset&&dmx.validateReset(this.$node),window.grecaptcha&&this.$node.querySelector(".g-recaptcha")&&grecaptcha.reset()},_submit(e){if(e)return this._formSubmit();this.props.novalidate||this._validate()?this.dispatchEvent("submit",{cancelable:!0})&&this._formSubmit():(this.dispatchEvent("invalid"),this._focusFirstInvalid())},_reset(){this._formReset()},_validate(){return dmx.validate?dmx.validate(this.$node):(Array.from(this.$node.elements).forEach((e=>e.dirty=!0)),this.$node.checkValidity())},_formSubmit(){HTMLFormElement.prototype.submit.call(this.$node)},_formReset(){HTMLFormElement.prototype.reset.call(this.$node)},_focusFirstInvalid(){const e=Array.from(this.$node.elements).find((e=>!e.validity.valid));e&&e.focus()},_parseJsonForm(){const e={};for(const n of this.$node.elements)if(n.name&&!n.disabled){const r=t(n.name.replace(/\[\]$/,""));let i=e;for(const e of r){const t=n.type;"number"==t?n.value&&(i=s(i,e,i[e.key],+n.value)):"radio"==t||"checkbox"==t?n.getAttribute("value")?n.checked&&(i=s(i,e,i[e.key],n.value)):i=s(i,e,i[e.key],n.checked):i=s(i,e,i[e.key],"select-multiple"==t?Array.from(n.selectedOptions).map((e=>e.value)):n.value)}}return e;function t(e){const t=[],s=e,n=/^\[([^\]]*)\]/,r=/^\d+$/;if(!(e=e.replace(/^([^\[]+)/,((e,s)=>(t.push({type:"object",key:s}),"")))))return t[0].last=!0,t;for(;e;){if(!n.test(e))return{type:"object",key:s,last:!0};e=e.replace(n,((e,s)=>(s?r.test(s)?t.push({type:"array",key:+s}):t.push({type:"object",key:s}):t[t.length-1].append=!0,"")))}for(let e=0,s=t.length;e<s;e++){const n=t[e];e+1<s?n.nextType=t[e+1].type:n.last=!0}return t}function s(e,t,n,r){if(t.last){if(void 0===n)e[t.key]=t.append?[r]:r;else if(Array.isArray(n))e[t.key].push(r);else{if("object"==typeof n)return s(n,{type:"object",key:"",last:!0},n[""],r);e[t.key]=[n,r]}return e}if(void 0===n)return e[t.key]="array"==t.nextType?[]:{};if(Array.isArray(n)){if("array"==t.nextType)return n;const s={};for(let e=0,t=n.length;e<t;e++)void 0!==n[e]&&(s[e]=n[e]);return e[t.key]=s}return"object"==typeof n?e[t.key]:e[t.key]={"":n}}}}),dmx.Component("form-element",{initialData:{disabled:!1,focused:!1,invalid:!1,validationMessage:"",value:""},attributes:{value:{type:String,default:"",alwaysUpdate:!0},disabled:{type:Boolean,default:!1}},methods:{setValue(e){this._setValue(e)},focus(){this._focus()},disable(e){this._disable(e)},validate(){this._validate()}},events:{updated:Event,changed:Event},init(e){this._inputHandler=this._inputHandler.bind(this),this._changeHandler=this._changeHandler.bind(this),this._invalidHandler=this._invalidHandler.bind(this),this._resetHandler=this._resetHandler.bind(this),this._focusHandler=this._focusHandler.bind(this),this._blurHandler=this._blurHandler.bind(this),e.value=this.props.value||"",e.defaultValue=e.value,e.addEventListener("input",this._inputHandler),e.addEventListener("change",this._changeHandler),e.addEventListener("invalid",this._invalidHandler),e.addEventListener("focus",this._focusHandler),e.addEventListener("blur",this._blurHandler),e.form&&(this._form=e.form,this._form.addEventListener("reset",this._resetHandler)),this.props.disabled&&this._disable(this.props.disabled),this.set("value",this.props.value),this.$node===document.activeElement&&this.set("focused",!0)},destroy(){this.$node.removeEventListener("input",this._inputHandler),this.$node.removeEventListener("change",this._changeHandler),this.$node.removeEventListener("invalid",this._invalidHandler),this.$node.removeEventListener("focus",this._focusHandler),this.$node.removeEventListener("blur",this._blurHandler),this._form&&(this._form.removeEventListener("reset",this._resetHandler),this._form=null)},performUpdate(e){e.has("value")&&this._setValue(this.props.value,!0),e.has("disabled")&&this._disable(this.props.disabled)},_setValue(e,t){this.$node.value=e||"",t&&(this.$node.defaultValue=e||""),this.set("value",e),dmx.nextTick((()=>this.dispatchEvent("updated")))},_focus(){this.$node.focus()},_disable(e){this.$node.disabled=e,this.set("disabled",this.$node.disabled)},_validate(){dmx.validate(this.$node),this.$node.dirty&&this.set({invalid:!this.$node.validity.valid,validationMessage:this.$node.validationMessage})},_inputHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{this.$node&&this.data.value!==this.$node.value&&(this.set("value",this.$node.value),e&&this.dispatchEvent("changed"),dmx.nextTick((()=>this.dispatchEvent("updated"))))}))},_changeHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{this.$node&&this.data.value!==this.$node.value&&(this.set("value",this.$node.value),e&&this.dispatchEvent("changed"),dmx.nextTick((()=>this.dispatchEvent("updated"))))}))},_invalidHandler(e){this.set({invalid:!this.$node.validity.valid,validationMessage:this.$node.validationMessage})},_resetHandler(e){this.$node&&(this.$node.dirty=!1,this.set({invalid:!1,validationMessage:""}),this._changeHandler())},_focusHandler(e){this.set("focused",!0)},_blurHandler(e){this.set("focused",!1)}}),dmx.Component("textarea",{extends:"form-element",init(e){if(!this.props.value){const e=this.$node.value;this.props.value=e.includes("{{")?this.parse(e):e}dmx.Component("form-element").prototype.init.call(this,e)}}),dmx.Component("input",{extends:"form-element"}),dmx.Component("input-file",{extends:"form-element",attributes:{imageMaxWidth:{type:Number,default:null},imageMaxHeight:{type:Number,default:null},imageType:{type:String,default:null,enum:["png","jpeg","webp"]},imageQuality:{type:Number,default:null}},initialData:{file:null},_imageTypes:{png:"image/png",jpeg:"image/jpeg",webp:"image/webp","image/png":"image/png","image/jpeg":"image/jpeg","image/webp":"image/webp"},_imageExtensions:{"image/png":"png","image/jpeg":"jpg","image/webp":"webp"},_setValue(e){console.warn("Can not set value of a file input!")},_changeHandler(e){dmx.Component("form-element").prototype._changeHandler.call(this,e),this._updateData(),this.$node.files.length&&(this.props.imageMaxWidth||this.props.imageMaxHeight||this.props.imageType)&&this._resizeImage()},_resizeImage(){const e=this.$node.files[0];if(e&&e.type.startsWith("image/")){const t=URL.createObjectURL(e),s=new Image;s.src=t,s.onerror=()=>URL.revokeObjectURL(t),s.onload=()=>{URL.revokeObjectURL(t);const{imageMaxWidth:n,imageMaxHeight:r,imageType:i,imageQuality:a}=this.props;let o=s.width,d=s.height,h=o/d,l=!1;n&&o>n&&(o=n,d=~~(o/h),l=!0),r&&d>r&&(d=r,o=~~(d*h),l=!0);const c=i?this._imageTypes[i]:e.type;if(c!==e.type||l){const t=document.createElement("canvas"),n=t.getContext("2d");t.width=o,t.height=d,n.drawImage(s,0,0,o,d),t.toBlob((t=>{if(null==t)return console.error("Could not resize image!");const s=new DataTransfer,n=e.name.replace(/\.\w+$/,"."+this._imageExtensions[t.type]),r=new File([t],n,{type:t.type});s.items.add(r),this.$node.files=s.files,this._updateData()}),c,a?a/100:void 0)}}}},_updateData(){let e=null;if(this.$node.files.length){const t=this,s=this.$node.files[0];e={date:(s.lastModified?new Date(s.lastModified):s.lastModifiedDate).toISOString(),name:s.name,size:s.size,type:s.type,get dataUrl(){return s._dataUrl||dmx.fileUtils.blobToDataURL(s).then((n=>{s._dataUrl=n,t.set("file",Object.assign({},e,{dataUrl:n}))})).catch((e=>{console.error(e)})),null}}}this.set("file",e)}}),dmx.Component("input-file-multiple",{extends:"form-element",attributes:{imageMaxWidth:{type:Number,default:null},imageMaxHeight:{type:Number,default:null},imageType:{type:String,default:null,enum:["png","jpeg","webp"]},imageQuality:{type:Number,default:null}},initialData:{files:[]},_imageTypes:{png:"image/png",jpeg:"image/jpeg",webp:"image/webp","image/png":"image/png","image/jpeg":"image/jpeg","image/webp":"image/webp"},_imageExtensions:{"image/png":"png","image/jpeg":"jpg","image/webp":"webp"},_setValue(e){console.warn("Can not set value of a file input!")},_changeHandler(e){dmx.Component("form-element").prototype._changeHandler.call(this,e),this._updateData(),this.$node.files.length&&(this.props.imageMaxWidth||this.props.imageMaxHeight||this.props.imageType)&&this._resizeImages()},_resizeImages(){const e=Array.from(this.$node.files);Promise.all(e.map((e=>new Promise((t=>{if(!e.type.startsWith("image/"))return void t(e);const s=URL.createObjectURL(e),n=new Image;n.src=s,n.onerror=()=>URL.revokeObjectURL(s),n.onload=()=>{URL.revokeObjectURL(s);const{imageMaxWidth:r,imageMaxHeight:i,imageType:a,imageQuality:o}=this.props;let d=n.width,h=n.height,l=d/h,c=!1;r&&d>r&&(d=r,h=~~(d/l),c=!0),i&&h>i&&(h=i,d=~~(h*l),c=!0);const u=a?this._imageTypes[a]:e.type;if(u!==e.type||c){const s=document.createElement("canvas"),r=s.getContext("2d");s.width=d,s.height=h,r.drawImage(n,0,0,d,h),s.toBlob((s=>{if(null==s)return console.error("Could not resize image!");const n=e.name.replace(/\.\w+$/,"."+this._imageExtensions[s.type]),r=new File([s],n,{type:s.type});t(r)}),u,o?o/100:void 0)}else t(e)}}))))).then((e=>{const t=new DataTransfer;for(let s of e)t.items.add(s);this.$node.files=t.files,this._updateData()}))},_updateData(){let e=[];if(this.$node.files.length){const t=this;e=Array.from(this.$node.files).map(((s,n)=>({date:(s.lastModified?new Date(s.lastModified):s.lastModifiedDate).toISOString(),name:s.name,size:s.size,type:s.type,get dataUrl(){return s._dataUrl||(loading=!0,dmx.fileUtils.blobToDataURL(s).then((r=>{s._dataUrl=r,e=dmx.clone(e),e[n].dataUrl=r,t.set("files",e)})).catch((e=>{console.error(e)}))),null}})))}this.set("files",e)}}),dmx.Component("button",{extends:"form-element",attributes:{type:{type:String,default:"button",enum:["button","reset","submit"]}},init(e){dmx.Component("form-element").prototype.init.call(this,e),e.type=this.props.type}}),dmx.Component("radio",{extends:"form-element",initialData:{checked:!1},attributes:{checked:{type:Boolean,default:!1,alwaysUpdate:!0}},methods:{select(e){this._select(e)}},events:{checked:Event,unchecked:Event},init(e){dmx.Component("form-element").prototype.init.call(this,e),e.type="radio",e.checked=this.props.checked,e.defaultChecked=this.props.checked,this.props.checked&&this.set("checked",!0)},performUpdate(e){dmx.Component("form-element").prototype.performUpdate.call(this,e),e.has("checked")&&this.$node.checked!=this.props.checked&&(this.$node.defaultChecked=this.props.checked,this.$node.checked=this.props.checked,this.set("checked",this.props.checked),this.$node.dispatchEvent(new Event("radio",{bubbles:!0})),dmx.nextTick((()=>this.dispatchEvent("updated"))))},_select(e){this.$node.checked=!1!==e,this.set("checked",this.$node.checked),dmx.nextTick((()=>this.dispatchEvent("updated")))},_changeHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{if(this.$node&&(this.set("checked",this.$node.checked),this.dispatchEvent("changed"),this.dispatchEvent(this.$node.checked?"checked":"unchecked"),dmx.nextTick((()=>this.dispatchEvent("updated"))),this.$node.checked&&this.$node.form))for(const e of this.$node.form.elements)e!=this.$node&&"radio"==e.type&&e.name==this.$node.name&&e.dispatchEvent(new Event("change",{bubbles:!0}))}))}}),dmx.Component("radio-group",{initialData:{value:null},attributes:{value:{type:String,default:null,alwaysUpdate:!0}},methods:{setValue(e){this._setValue(e)}},events:{updated:Event},init(e){this._changeHandler=this._changeHandler.bind(this),e.addEventListener("change",this._changeHandler),e.addEventListener("radio",this._changeHandler)},render(e){this.$parse(),this._setValue(this.props.value,!0),this._mutationObserver=new MutationObserver((e=>{let t=this.props.value;null==t&&(t=""),t=t.toString();for(let s of e)for(let e of s.addedNodes)e.nodeType===Node.ELEMENT_NODE&&requestAnimationFrame((()=>{"INPUT"===e.tagName&&"radio"===e.type?(e.checked=e.value==t,e.defaultChecked=e.checked):e.querySelectorAll("input[type=radio]").forEach((s=>{s.checked=e.value==t,s.defaultChecked=s.checked})),requestAnimationFrame((()=>{this._updateValue()}))}))})),this._mutationObserver.observe(e,{subtree:!0,childList:!0})},destroy(){this._mutationObserver.disconnect(),this.$node.removeEventListener("change",this._changeHandler),this.$node.removeEventListener("radio",this._changeHandler)},performUpdate(e){e.has("value")&&this._setValue(this.props.value,!0)},_setValue(e,t){null==e&&(e=""),e=e.toString(),this._radios().forEach((s=>{s.checked=s.value==e,t&&(s.defaultChecked=s.checked)})),this._updateValue()},_updateValue(){const e=this._radios().filter((e=>!e.disabled&&e.checked)).map((e=>e.value));dmx.equal(this.data.value,e[0])||(this.set("value",e[0]||null),dmx.nextTick((()=>this.dispatchEvent("updated"))))},_radios(){return Array.from(this.$node.querySelectorAll("input[type=radio]"))},_changeHandler(e){this._updateValue()}}),dmx.Component("checkbox",{extends:"form-element",initialData:{checked:!1},attributes:{checked:{type:Boolean,default:!1,alwaysUpdate:!0}},methods:{select(e){this._select(e)}},events:{checked:Event,unchecked:Event},init(e){dmx.Component("form-element").prototype.init.call(this,e),e.type="checkbox",e.checked=this.props.checked,e.defaultChecked=this.props.checked,this.props.checked&&this.set("checked",!0)},performUpdate(e){dmx.Component("form-element").prototype.performUpdate.call(this,e),e.has("checked")&&this.$node.checked!=this.props.checked&&(this.$node.defaultChecked=this.props.checked,this.$node.checked=this.props.checked,this.set("checked",this.props.checked),this.$node.dispatchEvent(new Event("checkbox",{bubbles:!0})),dmx.nextTick((()=>this.dispatchEvent("updated"))))},_select(e){this.$node.checked=!1!==e,this.set("checked",this.$node.checked),dmx.nextTick((()=>this.dispatchEvent("updated")))},_changeHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{this.$node&&(this.set("checked",this.$node.checked),this.dispatchEvent("changed"),this.dispatchEvent(this.$node.checked?"checked":"unchecked"),dmx.nextTick((()=>this.dispatchEvent("updated"))))}))}}),dmx.Component("checkbox-group",{initialData:{value:[]},attributes:{value:{type:Array,default:[],alwaysUpdate:!0}},methods:{setValue(e){this._setValue(e)}},events:{updated:Event},init(e){this._changeHandler=this._changeHandler.bind(this),e.addEventListener("change",this._changeHandler),e.addEventListener("checkbox",this._changeHandler)},render(e){this.$parse(),this._setValue(this.props.value,!0),this._mutationObserver=new MutationObserver((e=>{let t=this.props.value;null==t&&(t=[]),Array.isArray(t)||(t=[t]),t=t.map((e=>e.toString()));for(let s of e)for(let e of s.addedNodes)e.nodeType===Node.ELEMENT_NODE&&requestAnimationFrame((()=>{"INPUT"===e.tagName&&"checkbox"===e.type?(e.checked=t.includes(e.value),e.defaultChecked=e.checked):e.querySelectorAll("input[type=checkbox]").forEach((e=>{e.checked=t.includes(e.value),e.defaultChecked=e.checked})),requestAnimationFrame((()=>{this._updateValue()}))}))})),this._mutationObserver.observe(e,{subtree:!0,childList:!0})},destroy(){this._mutationObserver.disconnect(),this.$node.removeEventListener("change",this._changeHandler),this.$node.removeEventListener("checkbox",this._changeHandler)},performUpdate(e){e.has("value")&&this._setValue(this.props.value,!0)},_setValue(e,t){null==e&&(e=[]),Array.isArray(e)||(e=[e]),e=e.map((e=>e.toString())),this._checkboxes().forEach((s=>{s.checked=e.includes(s.value),t&&(s.defaultChecked=s.checked)})),this._updateValue()},_updateValue(){const e=this._checkboxes().filter((e=>!e.disabled&&e.checked)).map((e=>e.value));dmx.equal(this.data.value,e)||(this.set("value",e),dmx.nextTick((()=>this.dispatchEvent("updated"))))},_checkboxes(){return Array.from(this.$node.querySelectorAll("input[type=checkbox]"))},_changeHandler(e){this._updateValue()}}),dmx.Component("select",{extends:"form-element",initialData:{selectedIndex:-1,selectedValue:"",selectedText:""},attributes:{options:{type:[Array,Object,Number],default:null},optiontext:{type:String,default:"$value"},optionvalue:{type:String,default:"$value"}},methods:{setSelectedIndex(e){this.$node.selectedIndex=e,this._updateValue()}},init(e){this._options=[],this.props.value||(this.props.value=this.$node.value,this._updateValue()),this._mutationObserver=new MutationObserver((()=>{this._updatingOptions||this._updateValue()})),this._mutationObserver.observe(this.$node,{subtree:!0,childList:!0,attributes:!0}),dmx.Component("form-element").prototype.init.call(this,e)},render(e){this.$parse(),this._renderOptions();let t=this.props.value;null==t&&(t=""),Array.from(this.$node.options).forEach((e=>{e.toggleAttribute("selected",e.value==t),e.selected=e.value==t,e.defaultSelected=e.selected})),this._updateValue()},destroy(){this._mutationObserver.disconnect(),dmx.Component("form-element").prototype.destroy.call(this)},performUpdate(e){dmx.Component("form-element").prototype.performUpdate.call(this,e),(e.has("options")||e.has("optiontext")||e.has("optionvalue"))&&this._renderOptions()},_setValue(e,t){if(null==e&&(e=""),e=e.toString(),t)Array.from(this.$node.options).forEach((t=>{t.toggleAttribute("selected",t.value==e)}));else{const t=Array.from(this.$node.options).findIndex((t=>t.value==e));this.$node.selectedIndex=t}this._updateValue()},_updateValue(){const e=this.$node.selectedIndex,t=this.$node.options[e]||{value:"",text:""};this.set({selectedIndex:e,selectedValue:t.value,selectedText:t.text,value:t.value})},_renderOptions(){this._options.forEach((e=>e.remove())),this._options=[],this.props.options&&(this._updatingOptions=!0,dmx.repeatItems(this.props.options).forEach((e=>{const t=document.createElement("option");t.value=dmx.parse(this.props.optionvalue,dmx.DataScope(e,this)),t.textContent=dmx.parse(this.props.optiontext,dmx.DataScope(e,this)),t.value==this.props.value&&(t.selected=!0),this.$node.append(t),this._options.push(t)})),this._updatingOptions=!1),this._updateValue()},_inputHandler(e){},_changeHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{this.data.selectedIndex!==this.$node.selectedIndex&&(this._updateValue(),this.dispatchEvent("changed"),dmx.nextTick((()=>this.dispatchEvent("updated"))))}))}}),dmx.Component("select-multiple",{extends:"select",initialData:{value:[]},attributes:{value:{type:Array,default:null,alwaysUpdate:!0}},performUpdate(e){dmx.Component("select").prototype.performUpdate.call(this,e),e.has("value")&&this._setValue(this.props.value,!0)},_setValue(e,t){null==e&&(e=""),Array.isArray(e)||(e=[e]),e=e.map((e=>e.toString())),Array.from(this.$node.options).forEach((s=>{const n=e.includes(s.value);t?s.toggleAttribute("selected",n):s.selected=n})),this._updateValue()},_getValue(){return Array.from(this.$node.selectedOptions).map((e=>e.value))},_updateValue(){const e=this._getValue();dmx.batch((()=>{dmx.Component("select").prototype._updateValue.call(this),this.set("value",e)}))},_changeHandler(e){this.$node.dirty&&this._validate(),dmx.nextTick((()=>{this.data.selectedIndex===this.$node.selectedIndex&&dmx.equal(this.data.value,this._getValue())||(this._updateValue(),this.dispatchEvent("changed"),dmx.nextTick((()=>this.dispatchEvent("updated"))))}))}}),dmx.Component("value",{initialData:{value:null},attributes:{value:{default:null}},methods:{setValue(e){this.data.value!==e&&(this.set("value",e),dmx.nextTick((()=>this.dispatchEvent("updated"))))}},events:{updated:Event},render:!1,init(e){this.set("value",this.props.value)},performUpdate(e){e.has("value")&&(this.set("value",this.props.value),dmx.nextTick((()=>this.dispatchEvent("updated"))))}}),dmx.Component("repeat",{initialData:{items:[]},attributes:{repeat:{type:[Array,Object,Number],default:null},key:{type:String,default:""},rerender:{type:Boolean,default:!1}},events:{update:Event,updated:Event},render:!1,init(e){for(this.prevItems=[],this.childKeys=new Map,this.$template=document.createDocumentFragment();this.$node.hasChildNodes();)this.$template.appendChild(this.$node.firstChild);this.props.repeat&&this.performUpdate(new Map([["repeat",void 0]]))},performUpdate(e){if(e.has("key")&&(this._rerender=!0),e.has("repeat")){this.dispatchEvent("update"),(this.props.rerender||this._rerender)&&(this._rerender=!1,this._clear());var t=dmx.Component("repeat-item"),s=dmx.clone(this.props.repeat),n=dmx.repeatItems(s);if(n.length){if(!this.props.rerender&&this.props.key&&n[0].hasOwnProperty(this.props.key)&&this.prevItems.length){var r,i,a=this.props.key,o=this.prevItems,d=this._clone(n),h=0,l=0,c=o.length-1,u=d.length-1;e:for(;;){for(;o[h][a]===d[l][a];)if(this.childKeys.get(d[l][a]).set(d[l]),l++,++h>c||l>u)break e;for(;o[c][a]===d[u][a];)if(this.childKeys.get(d[u][a]).set(d[u]),u--,h>--c||l>u)break e;if(o[c][a]!==d[l][a]){if(o[h][a]!==d[u][a])break;if(i=u+1,this.childKeys.get(d[u][a]).set(d[u]),this._moveChild(d[u][a],d[i]&&d[i][a]),u--,++h>c||l>u)break}else if(this.childKeys.get(d[l][a]).set(d[l]),this._moveChild(d[l][a],o[h][a]),l++,h>--c||l>u)break}if(h>c)for(i=u+1;l<=u;)this._insertChild(d[l++],d[i]&&d[i][a]);else if(l>u)for(;h<=c;)this._removeChild(o[h++][a]);else{var p=c-h+1,m=u-l+1,f=o,g=new Array(m).fill(-1),y=!1,_=0,v=0;if(m<=4||p*m<=16){for(w=h;w<=c;w++)if(v<m)for(r=l;r<=u;r++)if(o[w][a]===d[r][a]){g[r-l]=w,_>r?y=!0:_=r,this.childKeys.get(d[r][a]).set(d[r]),v++,f[w]=null;break}}else{var x={};for(w=l;w<=u;w++)x[d[w][a]]=w;for(w=h;w<=c;w++)v<m&&void 0!==(r=x[o[w][a]])&&(g[r-l]=w,_>r?y=!0:_=r,this.childKeys.get(d[r][a]).set(d[r]),v++,f[w]=null)}if(p===o.length&&0===v)for(this._clear();l<m;)this._insertChild(d[l++],null);else{for(w=p-v;w>0;)null!==f[h]&&(this._removeChild(o[h][a]),w--),h++;if(y){var b=this._lis(g);for(r=b.length-1,w=m-1;w>=0;w--)-1===g[w]?(i=(_=w+l)+1,this._insertChild(d[_],d[i]&&d[i][a])):r<0||w!==b[r]?(i=(_=w+l)+1,this._moveChild(d[_][a],d[i]&&d[i][a])):r--}else if(v!==m)for(w=m-1;w>=0;w--)-1===g[w]&&(i=(_=w+l)+1,this._insertChild(d[_],d[i]&&d[i][a]))}}}else if(this.children.length>n.length&&this.children.splice(n.length).forEach((e=>{e.$destroy()})),this.children.length&&this.children.forEach(((e,t)=>{e.set(n[t])})),n.length>this.children.length){const e=document.createDocumentFragment(),s=new Set;for(var w=this.children.length;w<n.length;w++){var E=new t(this.$template.cloneNode(!0),this,n[w]);E.$nodes.forEach((t=>{e.appendChild(t),s.add(E)})),this.children.push(E)}this.$node.appendChild(e);for(const e of s)e.$nodes.forEach((t=>{e.$parse(t)}))}}else this._clear();if(this.props.key){this.prevItems=this._clone(n);for(let e of this.children)this.childKeys.set(e.data[this.props.key],e)}this.set("items",this.children.map((e=>e.data))),dmx.nextTick((()=>this.dispatchEvent("updated")))}},_lis(e){var t,s,n=e.slice(0),r=[];r.push(0);for(var i=0,a=e.length;i<a;i++)if(-1!==e[i]){var o=r[r.length-1];if(e[o]<e[i])n[i]=o,r.push(i);else{for(t=0,s=r.length-1;t<s;){var d=(t+s)/2|0;e[r[d]]<e[i]?t=d+1:s=d}e[i]<e[r[t]]&&(t>0&&(n[i]=r[t-1]),r[t]=i)}}for(s=r[(t=r.length)-1];t-- >0;)r[t]=s,s=n[s];return r},_clear(){this.prevItems=[],this.childKeys.clear(),this.$node.innerHTML="",this.children.splice(0).forEach((e=>{e.$destroy()}))},_insertChild(e,t){var s=new(dmx.Component("repeat-item"))(this.$template.cloneNode(!0),this,e);s.$nodes.forEach((e=>{t?this.childKeys.has(t)?this.$node.insertBefore(e,this.childKeys.get(t).$nodes[0]):console.warn("(insert) can not insert node before key "+t+"!"):this.$node.appendChild(e),s.$parse(e)})),this.childKeys.set(e[this.props.key],s),this.children.push(s)},_moveChild(e,t){var s=this.childKeys.get(e);s?this.childKeys.has(t)?s.$nodes.forEach((e=>{this.$node.insertBefore(e,this.childKeys.get(t).$nodes[0])})):s.$nodes.forEach((e=>{this.$node.appendChild(e)})):console.warn("(move) child with key "+e+" not found!")},_removeChild(e){var t=this.childKeys.get(e);t?(t.$destroy(),this.children.splice(this.children.indexOf(t),1),this.childKeys.delete(e)):console.warn("(remove) child with key "+e+" not found!")},_clone:e=>dmx.clone(e)}),dmx.Component("repeat-item",{constructor:function(e,t,s,n){this.parent=t,this.children=[],this.listeners={},this.props={},this.__disposables=[],this.__childDisposables=[],this.updatedProps=new Map,this.updateRequested=!1,this.isInitialized=!0,this.isDestroyed=!1,this.data=dmx.signalProxy(s),this.seed=t.seed,this.name=n||"repeatItem",this.$nodes=[];for(var r=0;r<e.childNodes.length;r++)this.$nodes.push(e.childNodes[r])},destroy(){for(const e of this.$nodes)if(this.parent&&this.parent.props&&this.parent.props.key){const t=new Event("remove",{cancelable:!0});e.dispatchEvent(t)&&dmx.dom.remove(e)}else e.remove()}}),dmx.Component("fetch",{initialData:{status:0,data:null,links:{},paging:{},headers:{},state:{executing:!1,uploading:!1,processing:!1,downloading:!1},uploadProgress:{position:0,percent:0,total:0},downloadProgress:{position:0,percent:0,total:0},lastError:{status:0,message:"",response:null}},attributes:{timeout:{type:Number,default:0},method:{type:String,default:"GET"},url:{type:String,default:""},params:{type:Object,default:{}},headers:{type:Object,default:{}},data:{type:Object,default:{}},dataType:{type:String,default:"auto",enum:["auto","json","text"]},noload:{type:Boolean,default:!1},cache:{type:String,default:""},ttl:{type:Number,default:86400},credentials:{type:Boolean,default:!1}},methods:{abort(){this._abort()},load(e,t){const s={};e&&(s.params=e),t&&(s.ttl=0),this._fetch(s)},reset(){this._abort(),this._resetData(!0)}},events:{start:Event,done:Event,error:Event,invalid:Event,unauthorized:Event,forbidden:Event,abort:Event,success:Event,upload:ProgressEvent,download:ProgressEvent},_statusEvents:{200:"success",400:"invalid",401:"unauthorized",403:"forbidden"},render:!1,init(e){this._fetch=dmx.debounce(this._fetch.bind(this)),this._loadHandler=this._loadHandler.bind(this),this._abortHandler=this._abortHandler.bind(this),this._errorHandler=this._errorHandler.bind(this),this._timeoutHandler=this._timeoutHandler.bind(this),this._downloadProgressHandler=this._progressHandler.bind(this,"download"),this._uploadProgressHandler=this._progressHandler.bind(this,"upload"),this._xhr=new XMLHttpRequest,this._xhr.addEventListener("load",this._loadHandler),this._xhr.addEventListener("abort",this._abortHandler),this._xhr.addEventListener("error",this._errorHandler),this._xhr.addEventListener("timeout",this._timeoutHandler),this._xhr.addEventListener("progress",this._downloadProgressHandler),this._xhr.upload.addEventListener("progress",this._uploadProgressHandler),!this.props.noload&&this.props.url&&this._fetch()},destroy(){this._xhr.removeEventListener("load",this._loadHandler),this._xhr.removeEventListener("abort",this._abortHandler),this._xhr.removeEventListener("error",this._errorHandler),this._xhr.removeEventListener("timeout",this._timeoutHandler),this._xhr.removeEventListener("progress",this._downloadProgressHandler),this._xhr.upload.removeEventListener("progress",this._uploadProgressHandler),this._xhr.abort(),this._xhr=null},performUpdate(e){!this.props.noload&&this.props.url&&(e.has("url")||e.has("params"))&&this._fetch()},$parseAttributes(e){dmx.BaseComponent.prototype.$parseAttributes.call(this,e),dmx.dom.getAttributes(e).forEach((({name:e,argument:t,value:s})=>{t&&s&&["param","header"].includes(e)&&this.$watch(s,(s=>{this.props[e+"s"]=Object.assign({},this.props[e+"s"],{[t]:s})})),t&&s&&"data"==e&&this.$watch(s,(e=>{this.props.data=Object.assign({},this.props.data,{[t]:e})}))}))},_abort(){this._xhr&&this._xhr.abort()},_resetData(e){const t={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}};e&&(t.data=null),this.set(t)},_fetch(e){this._abort(),e=dmx.extend(!0,this.props,e||{});let t=Object.keys(e.params).filter((t=>null!=e.params[t])).map((t=>{let s=e.params[t];return"string"==typeof s&&s.startsWith("{{")&&(s=this.parse(s)),encodeURIComponent(t)+"="+encodeURIComponent(s)})).join("&");if(this._resetData(),this.dispatchEvent("start"),this._url=e.url,t&&(this._url+=(this._url.includes("?")?"&":"?")+t),window.WebviewProxy&&(this._url=window.WebviewProxy.convertProxyUrl(this._url)),this.props.cache){const t=this.parse(`${this.props.cache}.data["${this._url}"]`);if(t){if(!(Date.now()-t.created>=1e3*e.ttl))return this.set({headers:t.headers||{},paging:t.paging||{},links:t.links||{},data:t.data}),this.dispatchEvent("success"),void this.dispatchEvent("done");this.parse(`${this.props.cache}.remove("${this._url}")`)}}this.set("state",{executing:!0,uploading:!1,processing:!1,downloading:!1});let s=null,n=this.props.method.toUpperCase();"GET"!==n&&("text"===this.props.dataType?s=this.props.data.toString():"json"===this.props.dataType?s=JSON.stringify(this.props.data):"POST"===n?(s=new FormData,Object.keys(this.props.data).forEach((e=>{let t=this.props.data[e];Array.isArray(t)?(/\[\]$/.text(t)||(e+="[]"),t.forEach((t=>s.append(e,t)))):s.set(e,t)}))):s=this.props.data.toString()),this._xhr.open(n,this._url),this._xhr.timeout=1e3*e.timeout,"json"!==this.props.dataType&&"text"!==this.props.dataType||this._xhr.setRequestHeader("Content-Type","application/"+this.props.dataType);for(const e in this.props.headers)this._xhr.setRequestHeader(e,this.props.headers[e]);if(this._xhr.setRequestHeader("accept","application/json"),this.props.credentials&&(this._xhr.withCredentials=!0),this.serverconnect&&"GET"!==n){const e=document.querySelector('meta[name="csrf-token"]');e&&this._xhr.setRequestHeader("X-CSRF-Token",e.content)}try{this._xhr.send(s)}catch(e){this._done(e)}},_done(e){if(this._resetData(),e)return this.set("lastError",{status:0,message:e.message,response:null}),this.dispatchEvent("error"),void this.dispatchEvent("done");let t=this._xhr.responseText;try{t=JSON.parse(t)}catch(e){if(this._xhr.status<400)return this.set("lastError",{status:0,message:"Response was not valid JSON",response:t}),this.dispatchEvent("error"),void this.dispatchEvent("done")}if(this._parseHeaders(),this._xhr.status<400)return this.set({status:this._xhr.status,data:t}),this.dispatchEvent("success"),this.dispatchEvent("done"),void(this.props.cache&&this.parse(`${this.props.cache}.set("${this._url}", { headers: headers, paging: paging, links: links, data: data, created: ${Date.now()} })`));this.set({status:this._xhr.status,lastError:{status:this._xhr.status,message:this._xhr.statusText,response:t}}),this.dispatchEvent(this._statusEvents[this._xhr.status]||"error"),this.dispatchEvent("done")},_parseHeaders(){try{const e=this._xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",e.reduce(((e,t)=>{const s=t.split(": "),n=s.shift(),r=s.join(": ");return e[n]=r,e}),{}))}catch(e){return void console.warn("Error parsing response headers",e)}this._parseLinkHeaders()},_parseLinkHeaders(){try{const e=Object.keys(this.data.headers).find((e=>"link"===e.toLowerCase()));e&&this.set("links",this.data.headers[e].split(/,\s*</).map((e=>{try{const t=e.match(/<?([^>]*)>(.*)/),s=new URL(t[1]),n=t[2].split(";"),r=s.search.slice(1).split("&").reduce(((e,t)=>{const s=t.split("=");return s[0]&&(e[decodeURIComponent[s[0]]]=decodeURIComponent(s[1]||"")),e}),{});let i=n.slice(1).reduce(((e,t)=>{const s=t.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return s&&(e[s[1]]=s[2]),e}),{});return i=Object.assign({},r,i),i.url=s.toString(),i}catch(e){return console.warn("Error parsing link header part",e),null}}))).filter((e=>e&&e.rel)).reduce(((e,t)=>(t.rel.split(/\s+/).forEach((s=>e[s]=Object.assign(t,{rel:s}))),e)),{})}catch(e){return void console.warn("Error parsing link header",e)}this._parsePaging()},_parsePaging(){try{const e={page:1,pages:1,items:0,has:{first:!1,prev:!1,next:!1,last:!1}},{first:t,prev:s,next:n,last:r}=this.data.links;if(s||n){r&&r.page?e.pages=+r.page:s&&s.page&&(e.pages=+s.page+1);const i=Object.keys(this.data.headers).find((e=>"x-total"===(e=e.toLowerCase())||"x-count"===e||"x-total-count"===e));i&&(e.items=+this.data.headers[i]),s&&s.page?e.page=+s.page+1:n&&n.page&&(e.page=+n.page-1),e.has={first:!!t,prev:!!s,next:!!n,last:!!r}}this.set("paging",e)}catch(e){console.warn("Error parsing paging",e)}},_loadHandler(e){this._done()},_abortHandler(e){this._resetData(),this.dispatchEvent("abort"),this.dispatchEvent("done")},_errorHandler(e){this._done(Error("Failed to execute"))},_timeoutHandler(e){this._done(Error("Execution timeout"))},_progressHandler(e,t){t.loaded=t.loaded||t.position;const s=t.lengthComputable?Math.ceil(100*t.loaded/t.total):0;this.set({state:{executing:!0,uploading:"upload"===e&&s<100,processing:"upload"===e&&100===s,downloading:"download"===e},[e+"Progress"]:{position:t.loaded,total:t.total,percent:s}}),this.dispatchEvent(e,{lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total})}}),dmx.Component("serverconnect",{extends:"fetch",attributes:{sockets:{type:Boolean,default:!1}},init(e){this.serverconnect=!0,this.props.sockets&&dmx.Socket&&(this._refresh=this._refresh.bind(this),this._event=this.props.url.replace(/^(.*?)api\//,""),this._socket=dmx.Socket("/api"),this._socket.on(this._event,this._refresh)),dmx.Component("fetch").prototype.init.call(this,e)},destroy(){this._socket&&this._socket.off(this._event,this._refresh),dmx.Component("fetch").prototype.destroy.call(this)},_fetch(e){this._socket&&this._socket.connected?this._refresh(e&&e.params):dmx.Component("fetch").prototype._fetch.call(this,e)},_refresh(e){e=dmx.extend(!0,{},this.props.params,e||{}),this.dispatchEvent("start"),this.set("state",{executing:!0,uploading:!1,processing:!0,downloading:!1}),this._socket.emit(this._event,e,(e=>{this.set({status:e.status,data:e.data,state:{executing:!1,uploading:!1,processing:!1,downloading:!1}}),this.dispatchEvent(this._statusEvents[e.status]||"error"),this.dispatchEvent("done")}))}}),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:{}},postData:{type:String,default:"form"},credentials:{type:Boolean,default:!1}},methods:{abort(){this._abort()},reset(e){this._reset(),e&&(this._abort(),this._resetData(!0))}},events:{start:Event,done:Event,error:Event,unauthorized:Event,forbidden:Event,abort:Event,success:Event,upload:ProgressEvent,download:ProgressEvent},init(e){dmx.Component("form").prototype.init.call(this,e),this._loadHandler=this._loadHandler.bind(this),this._abortHandler=this._abortHandler.bind(this),this._errorHandler=this._errorHandler.bind(this),this._timeoutHandler=this._timeoutHandler.bind(this),this._downloadProgressHandler=this._progressHandler.bind(this,"download"),this._uploadProgressHandler=this._progressHandler.bind(this,"upload"),this._xhr=new XMLHttpRequest,this._xhr.addEventListener("load",this._loadHandler),this._xhr.addEventListener("abort",this._abortHandler),this._xhr.addEventListener("error",this._errorHandler),this._xhr.addEventListener("timeout",this._timeoutHandler),this._xhr.addEventListener("progress",this._downloadProgressHandler),this._xhr.upload.addEventListener("progress",this._uploadProgressHandler),this._extendNode(e),this.props.autosubmit&&dmx.nextTick((()=>this._submit()))},destroy(){dmx.Component("form").prototype.destroy.call(this),this._xhr.removeEventListener("load",this._loadHandler),this._xhr.removeEventListener("abort",this._abortHandler),this._xhr.removeEventListener("error",this._errorHandler),this._xhr.removeEventListener("timeout",this._timeoutHandler),this._xhr.removeEventListener("progress",this._downloadProgressHandler),this._xhr.upload.removeEventListener("progress",this._uploadProgressHandler),this._xhr=null},$parseAttributes(e){dmx.BaseComponent.prototype.$parseAttributes.call(this,e),dmx.dom.getAttributes(e).forEach((({name:e,argument:t,value:s})=>{t&&s&&["param","header"].includes(e)&&this.$watch(s,(s=>{this.props[e+"s"]=Object.assign({},this.props[e+"s"],{[t]:s})}))}))},_extendNode(e){e.dmxExtraData={},e.dmxExtraElements=[]},_abort(){this._xhr.abort()},_resetData(e){const t={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}};e&&(t.data=null),this.set(t)},_formSubmit(){this._send()},_send(){this._abort();const e=this.$node.method.toUpperCase(),t=this.$node.action;let s=null,n=Object.keys(this.props.params).filter((e=>null!=this.props.params[e])).map((e=>{let t=this.props.params[e];return"string"==typeof t&&t.startsWith("{{")&&(t=this.parse(t)),encodeURIComponent(e)+"="+encodeURIComponent(t)})).join("&");if("GET"===e)n.length&&(n+="&"),n+=Array.from(this.$node.elements).filter((e=>!e.disabled&&("radio"!==e.type&&"checkbox"!==e.type||e.checked))).map((e=>encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))).join("&");else if("json"===this.props.postData)s=this._parseJsonForm(),this.$node.dmxExtraData&&Object.assign(s,this.$node.dmxExtraData),s=JSON.stringify(s);else if(s=new FormData(this.$node),this.$node.dmxExtraData)for(let e in this.$node.dmxExtraData){let t=this.$node.dmxExtraData[e];Array.isArray(t)?(/\[\]$/.test(e)||(e+="[]"),t.forEach((t=>s.append(e,t)))):s.set(e,t)}this._resetData(),this.dispatchEvent("start"),this.set("state",{executing:!0,uploading:!1,processing:!1,downloading:!1});let r=t;n&&(r+=(r.includes("?")?"&":"?")+n),window.WebviewProxy&&(r=window.WebviewProxy.convertProxyUrl(r)),this._xhr.open(e,r),this._xhr.timeout=1e3*this.props.timeout,"json"===this.props.postData&&this._xhr.setRequestHeader("Content-Type","application/json");for(const e in this.props.headers)this._xhr.setRequestHeader(e,this.props.headers[e]);this._xhr.setRequestHeader("accept","application/json"),this.props.credentials&&(this._xhr.withCredentials=!0);const i=document.querySelector('meta[name="csrf-token"]');i&&this._xhr.setRequestHeader("X-CSRF-Token",i.content);try{this._xhr.send(s)}catch(e){this._done(e)}},_done(e){if(this._resetData(),e)return this.set("lastError",{status:0,message:e.message,response:null}),this.dispatchEvent("error"),void this.dispatchEvent("done");let t=this._xhr.responseText;try{t=JSON.parse(t)}catch(e){if(this._xhr.status<400)return this.set("lastError",{status:0,message:"Response was not valid JSON",response:t}),this.dispatchEvent("error"),void this.dispatchEvent("done")}try{const e=this._xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",e.reduce(((e,t)=>{const s=t.split(": "),n=s.shift(),r=s.join(": ");return e[n]=r,e}),{}))}catch(e){console.warn("Error parsing response headers",e)}if(dmx.validateReset&&dmx.validateReset(this.$node),window.grecaptcha&&this.$node.querySelector(".g-recaptcha")&&grecaptcha.reset(),this._xhr.status<400)return this.set({status:this._xhr.status,data:t}),this.dispatchEvent("success"),void this.dispatchEvent("done");if(this.set({status:this._xhr.status,lastError:{status:this._xhr.status,message:this._xhr.statusText,response:t}}),400===this._xhr.status)if(this.dispatchEvent("invalid"),t.form&&dmx.validate.setMessage)for(const e in t.form){const s=this.$node.querySelector(`[name="${e}"]`);if(s){const n=t.form[e];dmx.validate.setMessage(s,n)}}else dmx.debug&&console.warn("400 error, no form errors in response.",t);else 401===this._xhr.status?this.dispatchEvent("unauthorized"):403===this._xhr.status?this.dispatchEvent("forbidden"):this.dispatchEvent("error");this.dispatchEvent("done")},_loadHandler(e){this._done()},_abortHandler(e){this._resetData(),this.dispatchEvent("abort"),this.dispatchEvent("done")},_errorHandler(e){this._done(Error("Failed to execute"))},_timeoutHandler(e){this._done(Error("Execution timeout"))},_progressHandler(e,t){t.loaded=t.loaded||t.position;const s=t.lengthComputable?Math.ceil(100*t.loaded/t.total):0;this.set({state:{executing:!0,uploading:"upload"===e&&s<100,processing:"upload"===e&&100===s,downloading:"download"===e},[e+"Progress"]:{position:t.loaded,total:t.total,percent:s}}),this.dispatchEvent(e,{lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total})}}),dmx.Component("if",{attributes:{condition:{type:Boolean,default:!1}},events:{show:Event,hide:Event},init(e){for(this._shown=!1,this._template=document.createDocumentFragment();e.firstChild;)this._template.appendChild(e.firstChild)},render(e){this.props.condition&&this._show()},performUpdate(e){this.props.condition?this._show():this._hide()},destroy(){this._template=null},_show(){if(this._shown)return;const e=this._template.cloneNode(!0);this.$node.appendChild(e),this.$parse(),this.dispatchEvent("show"),this._shown=!0},_hide(){this._shown&&(this.effects&&(this.effects.forEach((e=>e())),this.effects=null),Array.from(this.$node.childNodes).forEach((e=>{const t=new Event("remove",{cancelable:!0});e.dispatchEvent(t)&&e.remove()})),this.$destroyChildren(),this.dispatchEvent("hide"),this._shown=!1)}}),dmx.Component("datetime",{initialData:{datetime:null},attributes:{interval:{type:String,default:"seconds",enum:["seconds","minutes","hours","days"]},utc:{type:Boolean,default:!1}},init(){this._tick=this._tick.bind(this),this._tick()},destroy(){this._timeout&&clearTimeout(this._timeout),this._animationFrame&&cancelAnimationFrame(this._animationFrame)},_tick(){switch(this.set("datetime",this._datetime()),this.props.interval){case"seconds":return this._timeout=setTimeout(this._tick,1e3);case"minutes":return this._timeout=setTimeout(this._tick,6e4);case"hours":return this._timeout=setTimeout(this._tick,36e5);case"days":return this._timeout=setTimeout(this._tick,864e5);default:return this._animationFrame=requestAnimationFrame(this._tick)}},_datetime(){const e=new Date,t=(e,t)=>("0000"+e).slice(-t),s=this.props.utc,n=s?e.getUTCFullYear():e.getFullYear(),r=(s?e.getUTCMonth():e.getMonth())+1,i=s?e.getUTCDate():e.getDate(),a=s?e.getUTCHours():e.getHours(),o=s?e.getUTCMinutes():e.getMinutes(),d=s?e.getUTCSeconds():e.getSeconds(),h=t(n,4)+"-"+t(r,2)+"-"+t(i,2),l=s?"Z":"";switch(this.props.interval){case"days":return h+"T00:00:00"+l;case"hours":return h+"T"+t(a,2)+":00:00"+l;case"minutes":return h+"T"+t(a,2)+":"+t(o,2)+":00"+l}return h+"T"+t(a,2)+":"+t(o,2)+":"+t(d,2)+l}}),dmx.Component("api-action",{extends:"fetch"}),dmx.Component("api-form",{extends:"serverconnect-form"}),dmx.Component("array",{initialData:{items:[],count:0},attributes:{items:{type:Array,default:[]}},events:{updated:Event},methods:{add(e){this._splice(this._count(),0,e)},addUniq(e){-1==this._indexOf(e)&&this._splice(this._count(),0,e)},insert(e,t){this._splice(e,0,t)},insertBefore(e,t){const s=this._indexOf(e);-1!=s&&this._splice(s,0,t)},insertAfter(e,t){const s=this._indexOf(e);-1!=s&&this._splice(s+1,0,t)},replace(e,t){const s=this._indexOf(e);-1!=s&&this._splice(s,1,t)},replaceAt(e,t){this._splice(e,1,t)},remove(e){const t=this._indexOf(e);-1!=t&&this._splice(t,1)},removeAt(e){this._splice(e,1)},reverse(){this._reverse()},sort(){this._sort()},empty(){this._updateData([])}},render:!1,init(){const e=dmx.array(this.props.items);this.set({items:e,count:e.length})},performUpdate(e){e.has("items")&&this._updateData(dmx.array(this.props.items))},_count(){return this.data.items.length},_indexOf(e){return this.data.items.indexOf(e)},_splice(e,t,s){const n=dmx.clone(this.data.items);void 0!==s?n.splice(e,t,s):n.splice(e,t),this._updateData(n)},_reverse(){const e=dmx.clone(this.data.items);e.reverse(),this._updateData(e)},_sort(){const e=dmx.clone(this.data.items);e.sort(),this._updateData(e)},_updateData(e){dmx.equal(this.data.items,e)||(this.set({items:e,count:e.length}),dmx.nextTick((()=>this.dispatchEvent("updated"))))}}),dmx.Component("group",{}),dmx.Component("flow",{initialData:{data:null,running:!1,lastError:null},attributes:{src:{type:String,default:null},preload:{type:Boolean,default:!1},autorun:{type:Boolean,default:!1},params:{type:Object,default:{}}},methods:{run(e,t){return this._run(e,t)},runSub(e){return this._runSub(e)}},events:{start:Event,done:Event,error:Event},render:!1,init(e){if(this.props.src)(this.props.preload||this.props.autorun)&&this._load(this.props.src,this.props.autorun).catch(console.error);else try{this._flow=this._parse(e.textContent),this.props.autorun&&this._run()}catch(e){console.error(e)}},destroy(){this._destroyed=!0},$parseAttributes(e){dmx.BaseComponent.prototype.$parseAttributes.call(this,e),dmx.dom.getAttributes(e).forEach((({name:e,argument:t,value:s})=>{t&&s&&"param"==e&&this.$watch(s,(e=>{this.props.params=Object.assign({},this.props.params,{[t]:e})}))}))},_load(e,t){return fetch(e).then((e=>{if(!e.ok||e.status>=400)throw Error(`Could not load flow ${this.name}, status ${e.status} ${e.statusText}`);return e.text()})).then((e=>{this._flow=this._parse(e),t&&this._run()}))},_parse:e=>(window.Hjson?Hjson:JSON).parse(e),_runSub(e){if(!this._flow){if(this.props.src)return this._load(this.props.src).then((()=>{this._runFlow(e)}));throw Error("No flow")}return this._runFlow(e)},_run(e,t){return this._flow?this.data.running?void console.info(`Can't run flow ${this.name} when a previous run didn't finish.`):(this.set({running:!0,lastError:null}),this.dispatchEvent("start"),dmx.debug&&(console.debug(`Running flow ${this.name} with params`,e),console.time(`Flow ${this.name}`)),this._runFlow(e).then((e=>(dmx.debug&&(console.debug(`Flow ${this.name} finished`,e),console.timeEnd(`Flow ${this.name}`)),this.set({running:!1,data:e}),this.dispatchEvent("done"),e))).catch((e=>{if(this.set({running:!1,lastError:e&&e.message}),this.dispatchEvent("error"),t)throw e}))):this.props.src?this._load(this.props.src).then((()=>{this._run(e,t)})).catch(console.error):void console.warn(`Flow ${this.name} is missing.`)},_runFlow(e){return dmx.Flow.run(this._flow,dmx.DataScope({$param:Object.assign({},this.props.params,e)},this))}}),dmx.Component("toggle",{initialData:{checked:!1},attributes:{checked:{type:Boolean,default:!1}},methods:{check(){this.props.checked=!0},uncheck(){this.props.checked=!1},toggle(){this.props.checked=!this.data.checked}},events:{updated:Event},render:!1,init(e){this.set("checked",this.props.checked)},performUpdate(e){e.has("checked")&&(this.set("checked",this.props.checked),dmx.nextTick((()=>this.dispatchEvent("updated"))))}}),dmx.Component("form-data",{attributes:{name:{type:String,default:"data"},data:{type:[Array,Object],default:null}},init(e){this._formdataHandler=this._formdataHandler.bind(this),this._form=e.closest("form"),this._form&&this._form.addEventListener("formdata",this._formdataHandler)},destroy(){this._form&&this._form.removeEventListener("formdata",this._formdataHandler)},_formdataHandler(e){const t=e.formData,s=this.props.data;this._appendData(t,s,this.props.name)},_appendData(e,t,s=""){if(Array.isArray(t))t.forEach(((t,n)=>{this._appendData(e,t,`${s}[${n}]`)}));else if("object"==typeof t)for(const n in t)this._appendData(e,t[n],`${s}[${n}]`);else e.append(s,t)}}),dmx.Attribute("bind","mounted",(function(e,t){const s=t.argument,n=dmx.reToggleAttribute.test(s);this.$watch(t.value,(t=>{if(n)e.toggleAttribute(s,!!t);else{if("style"===s&&"object"==typeof t)return Object.assign(e.style,t);if(null==t)return e.removeAttribute(s);e.setAttribute(s,t),"src"===s&&("VIDEO"===e.nodeName||"AUDIO"===e.nodeName?e.load():"SOURCE"===e.nodeName&&e.parentNode&&e.parentNode.load())}}))})),dmx.Attribute("on","mounted",(function(e,t){return e.dmxOn||(e.dmxOn={component:this}),e.dmxOn[t.argument]=!0,dmx.eventListener(e,t.argument,(function(s){s.originalEvent&&(s=s.originalEvent);return dmx.parse(t.value,dmx.DataScope({$event:s.$data,$originalEvent:s},e.dmxOn.component))}),t.modifiers)})),dmx.Attribute("repeat","before",(function(e,t){const s=document.createComment("Repeat Attribute"),n=document.createDocumentFragment(),r=dmx.Component("repeat-item");e.parentNode.replaceChild(s,e),e.removeAttribute(t.fullName),n.append(e);let i=[];this.$watch(t.value,(e=>{const a=dmx.repeatItems(e);if(a.length>1e4&&(console.warn("More than 10000 repeat items, we limit the result!"),a.length=1e4),t.modifiers.fast){if(i.length>a.length&&i.splice(a.length).forEach((e=>e.$destroy())),i.length&&i.forEach(((e,t)=>e.set(a[t]))),a.length>i.length){const e=document.createDocumentFragment(),o=new Set;a.slice(i.length).forEach((t=>{const s=new r(n.cloneNode(!0),this,t);e.appendChild(s.$nodes[0]),o.add(s),i.push(s),this.$addChild(s)})),s.parentNode.insertBefore(e,s);for(const e of o)e.$parse(e.$nodes[0]);t.argument&&this.set(t.argument,a)}}else{const e=document.createDocumentFragment(),o=new Set;i.splice(0).forEach((e=>e.$destroy()));for(const t of a){const s=new r(n.cloneNode(!0),this,t);e.append(s.$nodes[0]),o.add(s),i.push(s),this.$addChild(s)}s.parentNode.insertBefore(e,s);for(const e of o)e.$parse(e.$nodes[0]);t.argument&&this.set(t.argument,a)}}))})),dmx.Attribute("class","mounted",(function(e,t){e.dmxClass||(e.dmxClass={component:this}),this.$watch(t.value,(s=>{e.dmxClass[t.argument]=s,e.classList[s?"add":"remove"](t.argument)}))})),dmx.Attribute("hide","mounted",(function(e,t){e.dmxHide||(e.dmxHide={component:this,initial:{display:e.style.getPropertyValue("display"),priority:e.style.getPropertyPriority("display")},hide:null},this.$watch(t.value,(t=>{e.dmxHide.hide=t;const{initial:s}=e.dmxHide,n=t?"none":s.display,r=t?"important":s.priority;e.style.setProperty("display",n,r)})))})),dmx.Attribute("show","mounted",(function(e,t){e.dmxShow||(e.dmxShow={component:this,initial:{display:e.style.getPropertyValue("display"),priority:e.style.getPropertyPriority("display")},show:null},this.$watch(t.value,(t=>{e.dmxShow.show=t;const{initial:s}=e.dmxShow,n=t?s.display:"none",r=t?s.priority:"important";e.style.setProperty("display",n,r)})))})),dmx.Attribute("html","mounted",(function(e,t){e.dmxHtml||(e.dmxHtml={component:this},this.$watch(t.value,(t=>{e.innerHTML=null!=t?String(t):""})))})),dmx.Attribute("text","mounted",(function(e,t){e.dmxText||(e.dmxText={component:this},this.$watch(t.value,(t=>{e.innerText=null!=t?String(t):""})))})),dmx.Attribute("style","mounted",(function(e,t){e.dmxStyle||(e.dmxStyle={component:this});const s=t.modifiers.important?"important":"";this.$watch(t.value,(n=>{e.dmxStyle[t.argument]=n,null!=n&&e.style.setProperty(t.argument,n,s)}))})),dmx.Formatters("global",{json:function(e){return JSON.stringify(e)},log:function(e){return console.log(e),e},run:function(e,t){var s=dmx.DataScope({$param:t},this);dmx.Flow.run(e,s)}}),dmx.Actions({subflow(e){const t=this.parse(e.flow),s=this.parse(e.param);return this.parse(t+".runSub("+JSON.stringify(s)+")")},comment(e){dmx.debug&&console.debug(e.message)},wait(e){const t=this.parse(e.delay);if("number"!=typeof t)throw new Error("wait: Invalid delay");return new Promise((e=>{setTimeout(e,t)}))},now:e=>(new Date).toISOString(),random(e){let t=this.parse(e.lower),s=this.parse(e.upper),n=!!this.parse(e.floating);"number"==typeof t&&isFinite(t)||(t=0),"number"==typeof s&&isFinite(s)||(s=1);let r=t+Math.random()*(s-t);return n||Math.floor(t)!=t||Math.floor(s)!=s||(r=Math.round(r)),r},confirm(e){const t=this.parse(e.message);if("string"!=typeof t)throw new Error("confirm: Invalid message");const s=confirm(t);if(s){if(e.then)return this._exec(e.then).then((()=>s))}else if(e.else)return this._exec(e.else).then((()=>s));return s},prompt(e){const t=this.parse(e.message);if("string"!=typeof t)throw new Error("prompt: Invalid message");return prompt(t)},alert(e){const t=this.parse(e.message);if("string"!=typeof t)throw new Error("alert: Invalid message");return alert(t)},repeat(e){let t=dmx.clone(this.parse(e.repeat));if(!t)return;if("boolean"==typeof t)t=t?[0]:[];else if("string"==typeof t)t=t.split(/\s*,\s*/);else if("number"==typeof t){for(var s=[],n=0;n<t;n++)s.push(n+1);t=s}if("object"!=typeof t)throw new Error("repeat: data is not repeatable");const r=this.scope,i=this.output;return this._each(t,((t,s)=>(this.scope=new dmx.DataScope(Object.assign({$value:t,$index:s,$name:s,$key:s,$number:s+1,$oddeven:s%2},t),r),this.output={},Array.isArray(e.outputFields)&&t instanceof Object&&e.outputFields.forEach((e=>{this.output[e]=t[e]})),this._exec(e.exec).then((()=>{var e=this.output;return this.scope=r,this.output=i,e})))))},condition(e){const t=!!this.parse(e.if);if(t){if(e.then)return this._exec(e.then).then((()=>t))}else if(e.else)return this._exec(e.else).then((()=>t));return t},conditions(e){if(Array.isArray(e.conditions))for(let t=0;t<e.conditions.length;t++){const s=e.conditions[t];if(this.parse(s.when))return this._exec(s.then)}},select(e){const t=this.parse(e.expression);if(Array.isArray(e.cases))for(let s=0;s<e.cases.length;s++){const n=e.cases[s];if(this.parse(n.value)==t)return this._exec(n.exec)}},group(e){if(e.name){const t=this.output;return this.output={},this._exec(e.exec).then((()=>{var e=this.output;return self.output=t,e}))}return this._exec(e.exec)},while(e){const t=()=>new Promise((s=>{if(!this.parse(e.condition))return s();this._exec(e.exec).then(t).then(s)}));return t()},switch(e){const t=this.parse(e.expression);for(let s=0;s<e.cases.length;s++)if(this.parse(e.cases[s].case)===t)return this._exec(e.cases[s].exec);if(e.default)return this._exec(e.default)},tryCatch(e){return Promise.resolve(this._exec(e.try)).catch((()=>this._exec(e.catch)))},run(e){if(!e.action)throw new Error("run: missing action");return this.parse(e.action)},runJS(e){if(!e.function)throw new Error("runJS: missing function");const t=this.parse(e.function),s=this.parse(e.args);return window[t].apply(null,s)},assign(e){return this.parse(e.value)},setGlobal(e){const t=this.parse(e.key),s=this.parse(e.value);if("string"!=typeof t)throw new Error("setGlobal: key must be a string");return dmx.global.set(t,s),s},setSession(e){const t=this.parse(e.key),s=this.parse(e.value);if("string"!=typeof t)throw new Error("setSession: key must be a string");return sessionStorage.setItem(t,JSON.stringify(s)),s},getSession(e){const t=this.parse(e.key);if("string"!=typeof t)throw new Error("getSession: key must be a string");return JSON.parse(sessionStorage.getItem(t))},removeSession(e){const t=this.parse(e.key);if("string"!=typeof t)throw new Error("removeSession: key must be a string");return sessionStorage.removeItem(t),!0},setStorage(e){const t=this.parse(e.key),s=this.parse(e.value);if("string"!=typeof t)throw new Error("setStorage: key must be a string");return localStorage.setItem(t,JSON.stringify(s)),s},getStorage(e){const t=this.parse(e.key);if("string"!=typeof t)throw new Error("getStorage: key must be a string");const s=localStorage.getItem(t);return null==s?null:JSON.parse(s)},removeStorage(e){const t=this.parse(e.key);if("string"!=typeof t)throw new Error("removeStorage: key must be a string");return localStorage.removeItem(t),!0},fetch(e){let t=this.parse(e.url),s=this.parse(e.method),n=this.parse(e.timeout),r=this.parse(e.dataType),i=this.parse(e.data),a=this.parse(e.params),o=this.parse(e.headers),d=this.parse(e.credentials),h=null;if("string"!=typeof t)throw new Error("fetch: invalid url "+t);if(["GET","POST","PUT","DELETE"].includes(s)||(s="GET"),["auto","json","text"].includes(r)||(r="auto"),"number"!=typeof n&&(n=0),o||(o={}),"object"==typeof a)for(var l in a)a.hasOwnProperty(l)&&null!=a[l]&&(t+=(-1!=t.indexOf("?")?"&":"?")+decodeURIComponent(l)+"="+decodeURIComponent(a[l]));if("GET"!=s)if("text"==r)o["Content-Type"]||(o["Content-Type"]="application/text"),h=i.toString();else if("json"==r)o["Content-Type"]||(o["Content-Type"]="application/json"),h=JSON.stringify(i);else if("POST"==s){if(h=new FormData,"object"==typeof i&&!Array.isArray(i))for(var c in i)if(i.hasOwnProperty(c)){var u=i[c];if(Array.isArray(u))for(var p in/\[\]$/.test(c)||(c+="[]"),u)u.hasOwnProperty(p)&&h.append(c,u[p]);else h.set(c,u)}}else i&&(o["Content-Type"]||(o["Content-Type"]="application/text"),h=i.toString());return new Promise(((e,r)=>{var i=new XMLHttpRequest;for(var a in i.onerror=r,i.onabort=r,i.ontimeout=r,i.onload=function(){var t=i.responseText,s=i.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce((function(e,t){var s=t.split(": "),n=s.shift(),r=s.join(": ");return e[n.toLowerCase()]=r,e}),{});/^application\/json/.test(s["content-type"])&&(t=JSON.parse(t)),e({status:i.status,headers:s,data:t})},i.open(s,t),i.timeout=1e3*n,o)o.hasOwnProperty(a)&&i.setRequestHeader(a,o[a]);d&&(i.withCredentials=!0),i.send(h)}))}}),dmx.__actions.setValue=dmx.__actions.assign,dmx.__actions.api=dmx.__actions.fetch,dmx.__actions["api.send"]=dmx.__actions.fetch,dmx.__actions.serverConnect=dmx.__actions.fetch,dmx.Actions({"collections.addColumns":function(e){var t=this.parse(e.collection),s=e.add,n=!!this.parse(e.overwrite);if(!t.length)return[];for(var r=[],i=0,a=t.length;i<a;i++){var o=dmx.clone(t[i]);for(var d in s)if(s.hasOwnProperty(d)){var h=new dmx.DataScope(o,this.scope);(n||null==o[d])&&(o[d]=dmx.parse(s[d],h))}r.push(o)}return r},"collections.filterColumns":function(e){var t=this.parse(e.collection),s=this.parse(e.columns),n=!!this.parse(e.keep);if(!t.length)return[];for(var r=[],i=0,a=t.length;i<a;i++){var o=t[i],d={};for(var h in o)o.hasOwnProperty(h)&&(s.includes(h)?n&&(d[h]=dmx.clone(o[h])):n||(d[h]=dmx.clone(o[h])));r.push(d)}return r},"collections.renameColumns":function(e){var t=this.parse(e.collection),s=this.parse(e.rename);if(!t.length)return[];for(var n=[],r=0,i=t.length;r<i;r++){var a=t[r],o={};for(var d in a)a.hasOwnProperty(d)&&(o[s[d]||d]=dmx.clone(a[d]));n.push(o)}return n},"collections.fillDown":function(e){var t=this.parse(e.collection),s=this.parse(e.columns);if(!t.length)return[];for(var n=[],r={},i=0,a=s.length;i<a;i++)r[s[i]]=null;for(i=0,a=t.length;i<a;i++){var o=dmx.clone(t[i]);for(var d in r)r.hasOwnProperty(d)&&(null==o[d]?o[d]=r[d]:r[d]=o[d]);n.push(o)}return n},"collections.addRows":function(e){var t=this.parse(e.collection),s=this.parse(e.rows);return dmx.clone(t).concat(dmx.clone(s))},"collections.addRowNumbers":function(e){for(var t=this.parse(e.collection),s=this.parse(e.column),n=this.parse(e.startAt),r=!!this.parse(e.desc),i=[],a=0,o=t.length;a<o;a++){var d=dmx.clone(t[a]);d[s]=r?o+n-a:n+a,i.push(d)}return i},"colections.join":function(e){for(var t=this.parse(e.collection1),s=this.parse(e.collection2),n=this.parse(e.matches),r=!!this.parse(e.matchAll),i=[],a=0,o=t.length;a<o;a++){for(var d=dmx.clone(t[a]),h=0,l=s.length;h<l;h++){var c=s[h],u=!1;for(var p in n)if(n.hasOwnProperty(p))if(d[p]==c[n[p]]){if(u=!0,!r)break}else if(r){u=!1;break}if(u){for(var m in c)c.hasOwnProperty(m)&&(d[m]=dmx.clone(c[m]));break}}i.push(d)}return i},"collections.mormalize":function(e){for(var t=this.parse(e.collection),s=[],n=[],r=0,i=t.length;r<i;r++)for(var a in t[r])t[r].hasOwnProperty(a)&&-1==s.indexOf(a)&&s.push(a);for(r=0,i=t.length;r<i;r++){for(var o={},d=0,h=s.length;d<h;d++){a=s[d];var l=dmx.clone(t[a]);o[a]=null!=l?l:null}n.push(o)}return n}}),dmx.Actions({"console.log":function(e){console.log(this.parse(e.message))},"console.info":function(e){console.info(this.parse(e.message))},"console.warn":function(e){console.warn(this.parse(e.message))},"console.error":function(e){console.error(this.parse(e.message))},"console.count":function(e){console.count(this.parse(e.label))},"console.time":function(e){console.time(this.parse(e.label))},"console.timeEnd":function(e){console.timeEnd(this.parse(e.label))},"console.group":function(e){console.group()},"console.groupEnd":function(e){console.groupEnd()},"console.clear":function(e){console.clear()}});
//# sourceMappingURL=dmxAppConnect.js.map
