@cdmx/wappler_ag_grid 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/tests/01-basic-render.html +106 -0
- package/tests/02-themes-locale.html +98 -0
- package/tests/03-editing.html +119 -0
- package/tests/04-selection.html +103 -0
- package/tests/05-action-buttons.html +97 -0
- package/tests/06-export.html +80 -0
- package/tests/07-import.html +80 -0
- package/tests/08-formatting.html +91 -0
- package/tests/09-grouping.html +74 -0
- package/tests/10-state-persistence.html +84 -0
- package/tests/11-layout.html +72 -0
- package/tests/12-methods.html +93 -0
- package/tests/13-flags-styles.html +374 -0
- package/tests/14-compact-view.html +112 -0
- package/tests/README.md +146 -0
- package/tests/data/sample-data.js +52 -0
- package/tests/dmxAppConnect/dmxAppConnect.js +10 -0
- package/tests/dmxAppConnect/dmxAppConnect.js.map +1 -0
- package/tests/index.html +107 -0
- package/tests/lib/common-head.html +30 -0
- package/tests/lib/page-template.js +54 -0
- package/tests/lib/run-collector.js +32 -0
- package/tests/lib/test-helpers.js +145 -0
- package/tests/lib/test-suite.css +178 -0
- package/tests/run-all-puppeteer.cjs +180 -0
- package/tests/run-all.cjs +144 -0
- package/tests/serve.cjs +66 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Shared sample datasets for AG Grid test scenarios.
|
|
2
|
+
// Exposed as global window.SampleData so any test page can pick what it needs.
|
|
3
|
+
|
|
4
|
+
(function () {
|
|
5
|
+
const employees = [
|
|
6
|
+
{ id: 1, first_name: 'Alice', last_name: 'Anderson', email: 'alice@acme.test', department: 'Engineering', salary: 92500, hire_date: '2019-03-12', active: true, rating: 4.6 },
|
|
7
|
+
{ id: 2, first_name: 'Bob', last_name: 'Brown', email: 'bob@acme.test', department: 'Sales', salary: 67000, hire_date: '2020-07-01', active: true, rating: 3.9 },
|
|
8
|
+
{ id: 3, first_name: 'Carol', last_name: 'Carter', email: 'carol@acme.test', department: 'Marketing', salary: 71200, hire_date: '2018-11-23', active: false, rating: 4.1 },
|
|
9
|
+
{ id: 4, first_name: 'David', last_name: 'Davis', email: 'david@acme.test', department: 'Engineering', salary: 110000, hire_date: '2017-05-15', active: true, rating: 4.8 },
|
|
10
|
+
{ id: 5, first_name: 'Eve', last_name: 'Edwards', email: 'eve@acme.test', department: 'HR', salary: 58000, hire_date: '2021-09-03', active: true, rating: 3.5 },
|
|
11
|
+
{ id: 6, first_name: 'Frank', last_name: 'Foster', email: 'frank@acme.test', department: 'Finance', salary: 85000, hire_date: '2016-02-10', active: false, rating: 4.0 },
|
|
12
|
+
{ id: 7, first_name: 'Grace', last_name: 'Garcia', email: 'grace@acme.test', department: 'Engineering', salary: 99800, hire_date: '2022-01-18', active: true, rating: 4.3 },
|
|
13
|
+
{ id: 8, first_name: 'Henry', last_name: 'Hughes', email: 'henry@acme.test', department: 'Sales', salary: 72500, hire_date: '2019-12-05', active: true, rating: 3.7 },
|
|
14
|
+
{ id: 9, first_name: 'Ivy', last_name: 'Ingram', email: 'ivy@acme.test', department: 'Marketing', salary: 64000, hire_date: '2023-04-20', active: true, rating: 4.2 },
|
|
15
|
+
{ id: 10, first_name: 'Jack', last_name: 'Jones', email: 'jack@acme.test', department: 'Finance', salary: 88000, hire_date: '2018-08-30', active: false, rating: 3.8 },
|
|
16
|
+
{ id: 11, first_name: 'Kate', last_name: 'King', email: 'kate@acme.test', department: 'Engineering', salary: 105000, hire_date: '2015-06-22', active: true, rating: 4.9 },
|
|
17
|
+
{ id: 12, first_name: 'Leo', last_name: 'Lewis', email: 'leo@acme.test', department: 'HR', salary: 60500, hire_date: '2020-10-11', active: true, rating: 3.6 },
|
|
18
|
+
{ id: 13, first_name: 'Mia', last_name: 'Mitchell', email: 'mia@acme.test', department: 'Sales', salary: 78000, hire_date: '2019-02-14', active: true, rating: 4.4 },
|
|
19
|
+
{ id: 14, first_name: 'Noah', last_name: 'Nelson', email: 'noah@acme.test', department: 'Marketing', salary: 69500, hire_date: '2021-03-27', active: false, rating: 3.9 },
|
|
20
|
+
{ id: 15, first_name: 'Olivia', last_name: 'Owens', email: 'olivia@acme.test', department: 'Engineering', salary: 95000, hire_date: '2017-11-08', active: true, rating: 4.5 },
|
|
21
|
+
{ id: 16, first_name: 'Peter', last_name: 'Parker', email: 'peter@acme.test', department: 'Finance', salary: 81000, hire_date: '2022-05-19', active: true, rating: 4.0 },
|
|
22
|
+
{ id: 17, first_name: 'Quinn', last_name: 'Quinn', email: 'quinn@acme.test', department: 'HR', salary: 62000, hire_date: '2019-09-16', active: true, rating: 3.7 },
|
|
23
|
+
{ id: 18, first_name: 'Rachel', last_name: 'Reed', email: 'rachel@acme.test', department: 'Sales', salary: 75500, hire_date: '2018-04-25', active: false, rating: 4.1 },
|
|
24
|
+
{ id: 19, first_name: 'Sam', last_name: 'Scott', email: 'sam@acme.test', department: 'Engineering', salary: 102000, hire_date: '2016-12-01', active: true, rating: 4.7 },
|
|
25
|
+
{ id: 20, first_name: 'Tina', last_name: 'Taylor', email: 'tina@acme.test', department: 'Marketing', salary: 70000, hire_date: '2020-06-30', active: true, rating: 4.2 },
|
|
26
|
+
{ id: 21, first_name: 'Uma', last_name: 'Underwood',email: 'uma@acme.test', department: 'Finance', salary: 89500, hire_date: '2017-08-17', active: true, rating: 4.3 },
|
|
27
|
+
{ id: 22, first_name: 'Victor', last_name: 'Vance', email: 'victor@acme.test', department: 'HR', salary: 59500, hire_date: '2023-01-09', active: true, rating: 3.4 },
|
|
28
|
+
{ id: 23, first_name: 'Wendy', last_name: 'Walker', email: 'wendy@acme.test', department: 'Sales', salary: 80000, hire_date: '2019-07-23', active: false, rating: 4.0 },
|
|
29
|
+
{ id: 24, first_name: 'Xavier', last_name: 'Xu', email: 'xavier@acme.test', department: 'Engineering', salary: 98000, hire_date: '2021-11-15', active: true, rating: 4.6 },
|
|
30
|
+
{ id: 25, first_name: 'Yara', last_name: 'Young', email: 'yara@acme.test', department: 'Marketing', salary: 73500, hire_date: '2018-09-04', active: true, rating: 4.1 }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const departments = ['Engineering', 'Sales', 'Marketing', 'HR', 'Finance'];
|
|
34
|
+
|
|
35
|
+
// Orders dataset for grouping/aggregation tests.
|
|
36
|
+
const orders = [
|
|
37
|
+
{ id: 101, customer: 'Acme Corp', region: 'NA', product: 'Widget', qty: 12, unit_price: 25.50, total: 306.00, order_date: '2025-01-12' },
|
|
38
|
+
{ id: 102, customer: 'Globex', region: 'EU', product: 'Gadget', qty: 7, unit_price: 99.99, total: 699.93, order_date: '2025-01-15' },
|
|
39
|
+
{ id: 103, customer: 'Initech', region: 'NA', product: 'Widget', qty: 30, unit_price: 25.50, total: 765.00, order_date: '2025-02-01' },
|
|
40
|
+
{ id: 104, customer: 'Umbrella', region: 'APAC',product: 'Sprocket', qty: 5, unit_price: 49.95, total: 249.75, order_date: '2025-02-08' },
|
|
41
|
+
{ id: 105, customer: 'Stark Ind.', region: 'NA', product: 'Gadget', qty: 20, unit_price: 99.99, total: 1999.80,order_date: '2025-02-14' },
|
|
42
|
+
{ id: 106, customer: 'Wayne Ent.', region: 'NA', product: 'Widget', qty: 50, unit_price: 25.50, total: 1275.00,order_date: '2025-03-03' },
|
|
43
|
+
{ id: 107, customer: 'Globex', region: 'EU', product: 'Sprocket', qty: 14, unit_price: 49.95, total: 699.30, order_date: '2025-03-12' },
|
|
44
|
+
{ id: 108, customer: 'Acme Corp', region: 'NA', product: 'Gadget', qty: 3, unit_price: 99.99, total: 299.97, order_date: '2025-03-20' },
|
|
45
|
+
{ id: 109, customer: 'Initech', region: 'NA', product: 'Sprocket', qty: 22, unit_price: 49.95, total: 1098.90,order_date: '2025-04-01' },
|
|
46
|
+
{ id: 110, customer: 'Umbrella', region: 'APAC',product: 'Widget', qty: 18, unit_price: 25.50, total: 459.00, order_date: '2025-04-09' },
|
|
47
|
+
{ id: 111, customer: 'Stark Ind.', region: 'NA', product: 'Sprocket', qty: 9, unit_price: 49.95, total: 449.55, order_date: '2025-04-22' },
|
|
48
|
+
{ id: 112, customer: 'Wayne Ent.', region: 'NA', product: 'Gadget', qty: 11, unit_price: 99.99, total: 1099.89,order_date: '2025-05-04' }
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
window.SampleData = { employees, orders, departments };
|
|
52
|
+
})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
App Connect
|
|
3
|
+
Version: 2.2.4
|
|
4
|
+
(c) 2026 Wappler.io
|
|
5
|
+
@build 2026-01-19 14:03:35
|
|
6
|
+
*/
|
|
7
|
+
window.dmx={version:"2.2.4",versions:{},config:{throwErrors:!1,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,r=(this.document||this.ownerDocument).querySelectorAll(e),n=this;do{for(t=r.length;--t>=0&&r.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,r=Object.create(null);["[object Float32Array]","[object Float64Array]","[object Int8Array]","[object Int16Array]","[object Int32Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Uint16Array]","[object Uint32Array]","[object BigInt64Array]","[object BigUint64Array]"].forEach(function(e){r[e]=!0});var n=/\w*$/;function s(e){return null!==e&&"object"==typeof e}function i(e){if("function"==typeof e.slice)return e.slice(0);var t=new e.constructor(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}function o(e){var t=i(e.buffer);return new e.constructor(t,e.byteOffset,e.length)}function a(e,t,r){"__proto__"!==t&&(e[t]=r)}function d(l,h){if(!s(l))return l;if(h){var c=h.get(l);if(c)return c}else h=new Map;var u,p,m,f,g,y=e.call(l);return"[object DataView]"===y?new(u=l).constructor(i(u.buffer),u.byteOffset,u.byteLength):"[object ArrayBuffer]"===y?i(l):"[object Date]"===y||"[object Boolean]"===y?new l.constructor(+l):"[object Number]"===y||"[object String]"===y?new l.constructor(l):"[object RegExp]"===y?((m=new(p=l).constructor(p.source,n.exec(p))).lastIndex=p.lastIndex,m):"[object Map]"===y?function(e,t){var r=new Map;return t.set(e,r),e.forEach(function(e,n){r.set(n,d(e,t))}),r}(l,h):"[object Set]"===y?function(e,t){var r=new Set;return t.set(e,r),e.forEach(function(e){r.add(d(e,t))}),r}(l,h):"[object ImageData]"===y?"function"==typeof(g=(f=l).constructor)?new g(o(f.data),f.width,f.height):f:r[y]?o(l):Array.isArray(l)?function(e,t){var r=e.length,n=new Array(r);t.set(e,n);for(var s=0;s<r;s++)n[s]=d(e[s],t);return n}(l,h):function(e){if(!s(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(l)?function(e,r){var n={};r.set(e,n);for(var s=Object.keys(e),i=0;i<s.length;i++){var o=s[i];a(n,o,d(e[o],r))}if(Object.getOwnPropertySymbols)for(var l=Object.getOwnPropertySymbols(e),h=0;h<l.length;h++){var c=l[h];t.call(e,c)&&(n[c]=d(e[c],r))}return n}(l,h):(h.set(l,l),l)}dmx.clone=d}(),function(){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.create(null);function n(e){return null!==e&&"object"==typeof e}function s(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),s=0;s<r.length;s++)if(r[s]!==n[s])return!1;return!0}function i(e,t,n,i){switch(n){case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&s(e.buffer,t.buffer);case"[object ArrayBuffer]":return s(e,t);case"[object Boolean]":case"[object Date]":case"[object Number]":return+e===+t||e!=e&&t!=t;case"[object RegExp]":case"[object String]":return String(e)===String(t);case"[object Map]":return function(e,t,r){if(e.size!==t.size)return!1;for(var n=e.entries(),s=t.entries();;){var i=n.next(),a=s.next();if(i.done&&a.done)return!0;if(i.done!==a.done)return!1;var d=i.value,l=a.value;if(!o(d[0],l[0],r)||!o(d[1],l[1],r))return!1}}(e,t,i);case"[object Set]":return function(e,t,r){if(e.size!==t.size)return!1;for(var n=e.values(),s=t.values();;){var i=n.next(),a=s.next();if(i.done&&a.done)return!0;if(i.done!==a.done)return!1;if(!o(i.value,a.value,r))return!1}}(e,t,i)}return!!r[n]&&function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e,t)}function o(r,s,a){if(r===s)return!0;if(null==r||null==s)return r!=r&&s!=s;if(!n(r)||!n(s))return r!=r&&s!=s;var d=(a=a||new Map).get(r);if(d&&d===s)return!0;a.set(r,s),a.set(s,r);var l=t.call(r);return l===t.call(s)&&("[object Array]"===l?function(e,t,r){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!o(e[n],t[n],r))return!1;return!0}(r,s,a):"[object Object]"===l?function(t,r,n){var s=Object.keys(t),i=Object.keys(r);if(s.length!==i.length)return!1;for(var a=0;a<s.length;a++){var d=s[a];if(!e.call(r,d))return!1}for(var l=0;l<s.length;l++){var h=s[l];if(!o(t[h],r[h],n))return!1}var c=t.constructor,u=r.constructor;return c===u||!("constructor"in t)||!("constructor"in r)||"function"==typeof c&&c instanceof c&&"function"==typeof u&&u instanceof u}(r,s,a):i(r,s,l,a))}["[object Float32Array]","[object Float64Array]","[object Int8Array]","[object Int16Array]","[object Int32Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Uint16Array]","[object Uint32Array]","[object BigInt64Array]","[object BigUint64Array]"].forEach(function(e){r[e]=!0}),dmx.equal=o}(),dmx.createClass=(e,t)=>{const r=function(){e.constructor&&e.constructor.apply(this,arguments)};return t&&t.prototype&&(r.prototype=Object.create(t.prototype)),Object.assign(r.prototype,e),r.prototype.constructor=r,r},dmx.__ready=!1,dmx.ready=e=>{dmx.__ready?e():document.addEventListener("DOMContentLoaded",()=>{dmx.__ready=!0,e()},{once:!0})},dmx.Config=e=>{Object.assign(dmx.config,e)},dmx.Component=(e,t)=>{if(t){const r=t.extends?dmx.Component(t.extends):dmx.BaseComponent;"function"!=typeof t.initialData&&(t.initialData=Object.assign({},r.prototype.initialData,t.initialData)),t.attributes=Object.assign({},r.prototype.attributes,t.attributes),t.methods=Object.assign({},r.prototype.methods,t.methods),t.events=Object.assign({},r.prototype.events,t.events),t.hasOwnProperty("constructor")||(t.constructor=function(e,t){r.call(this,e,t)}),t.type=e;const n=dmx.createClass(t,r);n.extends=t.extends,dmx.__components[e]=n}return dmx.__components[e]},dmx.Attribute=(e,t,r)=>{dmx.__attributes[t]||(dmx.__attributes[t]=Object.create(null)),dmx.__attributes[t][e]=r},dmx.Formatter=(e,t,r)=>{dmx.__formatters[e][t]=r},dmx.Formatters=(e,t)=>{for(const r in t)dmx.Formatter(e,r,t[r])},dmx.Adapter=(e,t,r)=>(dmx.__adapters[e]||(dmx.__adapters[e]=Object.create(null)),r&&(dmx.__adapters[e][t]=r),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)},(()=>{function e(e,t=160){if("string"!=typeof e)return e;const r=e.trim();return r.length>t?r.slice(0,t-3)+"...":r}function t(e){if(!e||!e.ownerDocument)return null;const t=[],r=new Set;let n=1===e.nodeType?e:e.parentElement,s=0;for(;n&&1===n.nodeType&&s<10&&!r.has(n);){r.add(n);let e=n.tagName?n.tagName.toLowerCase():"unknown";if(n.id){e+=`#${n.id}`,t.unshift(e);break}if(n.classList&&n.classList.length){const t=Array.from(n.classList).filter(Boolean).slice(0,2).join(".");t&&(e+=`.${t}`)}const i=n.parentElement;if(i){const t=Array.from(i.children).filter(e=>e.tagName===n.tagName);if(t.length>1){const r=t.indexOf(n);r>=0&&(e+=`:nth-of-type(${r+1})`)}}t.unshift(e),n=i,s++}return 0===t.length?null:(3===e.nodeType&&t.length&&(t[t.length-1]+="::text"),t.join(" > "))}function r(e){if(!e)return null;const t=[];let r=e,n=0;for(;r&&n<10;){const e=r.name||r.type||r.constructor&&r.constructor.name||"component";t.unshift(e),r=r.parent,n++}return t.length?t:null}class n extends Error{constructor(e,t={}){super(e),this.name=t.name||"AppConnectError",this.details=t.details||{},this.originalError=t.originalError||null,this.component=t.component||null,this.context=t.context||null,Error.captureStackTrace&&Error.captureStackTrace(this,t.captureFn||this.constructor)}}class s extends n{constructor(e){super(e.message,{name:"ExpressionError",details:{expression:e.expression,attribute:e.attribute,nodePath:e.nodePath,componentName:e.componentName,componentType:e.componentType,componentPath:e.componentPath,description:e.description},originalError:e.originalError,component:e.component,context:e.context,captureFn:s}),this.expression=e.expression,this.attribute=e.attribute,this.nodePath=e.nodePath,this.componentName=e.componentName,this.componentType=e.componentType,this.componentPath=e.componentPath}}class i extends n{constructor(e){super(e.message,{name:"FormatterError",details:{formatter:e.formatter,value:e.value,hint:e.hint},originalError:e.originalError,context:e.context,captureFn:i}),this.formatter=e.formatter,this.value=e.value,this.hint=e.hint}}function o(e,t={}){const r=Object.assign({},t);return!r.component&&e&&e.$node&&(r.component=e),null==r.expression&&"string"==typeof t.expression&&(r.expression=t.expression),r}function a({formatter:e,message:t,value:r,hint:n,originalError:s,context:a={}}){const d=o(null,a);return new i({message:t,formatter:e,value:r,hint:n,originalError:s,context:d})}dmx.errors={AppConnectError:n,ExpressionError:s,describeNode:t,createExpressionError:function({expression:n,scope:i,context:a={},originalError:d}){const l=o(i,a),h=l.component||null,c=l.node||h&&h.$node||null,u=["Expression error"],p=h&&h.name?h.name:null,m=h&&h.type?h.type:h&&h.constructor&&h.constructor.name||null;p?u.push(`in component "${p}"`):m&&u.push(`in component <${m}>`),l.attribute&&u.push(`for ${l.attribute}`);const f=t(c);f&&u.push(`at ${f}`);const g=d&&d.message?d.message:null,y=g?`${u.join(" ")}: ${g}`:u.join(" ");return new s({message:y,expression:e(n),attribute:l.attribute||null,nodePath:f,componentName:p,componentType:m,componentPath:r(h),description:l.description,originalError:d,component:h,context:l})},handleExpressionError:function(e){if(function(e){const t=e.component;if(t&&(t.lastExpressionError=e,"function"==typeof t._captureExpressionError))try{t._captureExpressionError(e)}catch(e){if(dmx.config&&dmx.config.throwErrors)throw e;console&&console.warn&&console.warn("Error capturing expression error on component",e)}}(e),dmx.config&&dmx.config.throwErrors)throw e;!(dmx&&dmx.config&&!1===dmx.config.logExpressionErrors)&&console&&console.error&&(e.details?console.error(e.message,e.details,e.originalError||e):console.error(e))},FormatterError:i,createFormatterError:a,throwFormatterError:function({formatter:e,message:t,value:r,hint:n,fallback:s,originalError:i,context:o,onFallback:d}){if(!dmx||!dmx.config){if("function"==typeof d)try{d()}catch(e){console&&console.warn&&console.warn("Formatter fallback handler failed",e)}return s}const l=a({formatter:e,message:t,value:r,hint:n,originalError:i,context:o});if(dmx.config&&dmx.config.throwErrors)throw l;if("function"==typeof d)try{d(l)}catch(e){console&&console.warn&&console.warn("Formatter fallback handler failed",e)}return s}}})(),dmx.debounce=(e,t)=>{let r;return function(){const n=()=>{e.apply(this,arguments)};t?(clearTimeout(r),r=setTimeout(n,t)):(cancelAnimationFrame(r),r=requestAnimationFrame(n))}},dmx.throttle=(e,t)=>{let r,n=!1;return function(){if(r=Array.from(arguments),!n){const s=()=>{n=!1,r&&e.apply(this,r)};e.apply(this,r),r=void 0,n=!0,t?setTimeout(s,t):requestAnimationFrame(s)}}},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,r,n){let s,i;const o=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 r=parseInt(e,10);r?t.push(r):dmx.keyCodes[e]&&t.push(dmx.keyCodes[e])});for(var o=0;o<t.length;o++)if(Array.isArray(t[o])){if(!t[o].includes(e.which))return}else if(e.which!==t[o])return}if(n.stop&&e.stopPropagation(),n.prevent&&e.preventDefault(),e.originalEvent&&(e=e.originalEvent),e.$data||(e.$data={}),e.type&&null==e.$data.type&&(e.$data.type=e.type),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),e instanceof CustomEvent&&(e.$data.detail=e.detail),n.debounce)clearTimeout(s),s=setTimeout(()=>{r.apply(this,arguments)},parseInt(n.debounce,10)||0);else{if(!n.throttle)return r.apply(this,arguments);i||(i=!0,r.apply(this,arguments),setTimeout(()=>{i=!1},parseInt(n.throttle,10)||0))}}};n=n||{};const a=new Set;a.add(t),a.add(t.replace(/-/g,".")),a.add(t.replace(/-/g,":"));for(const t of a)window.Dom7&&1===e.nodeType?Dom7(e)[n.once?"once":"on"](t.replace(/-/g,"."),o,!!n.capture):window.jQuery&&!n.capture?jQuery(e)[n.once?"one":"on"](t.replace(/-/g,"."),o):e.addEventListener(t,o,{capture:!!n.capture,once:!!n.once,passive:!!n.passive});return()=>{for(const t of a)window.Dom7&&1===e.nodeType?Dom7(e).off(t,o,!!n.capture):window.jQuery&&!n.capture?jQuery(e).off(t,o):e.removeEventListener(t,o,!!n.capture)}},dmx.fileUtils={fileReader:(e,t)=>new Promise((r,n)=>{const s=new FileReader;s.onload=()=>r(s.result),s.onerror=()=>n(s.error),s[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 r=Uint8Array.from(e,e=>e.charCodeAt(0));return Promise.resolve(new Blob([r],{type:t}))},dataURLToBlob:function(e){const{data:t,type:r}=dmx.fileUtils.parseDataURL(e);return dmx.fileUtils.base64StringToBlob(t,r)},base64StringToBlob:function(e,t){const r=window.atob(e);return dmx.fileUtils.binaryStringToBlob(r,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[r,n]=t.split("=");return e[r]=n,e},{}):{}}}};{const e=function(e){const t=history[e];return function(){const r=t.apply(this,arguments),n=new Event(e.toLowerCase());return n.arguments=arguments,window.dispatchEvent(n),r}};history.pushState=e("pushState"),history.replaceState=e("replaceState")}function cloneRepeatValue(e){if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.slice();const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t?Object.assign({},e):dmx.clone(e)}function buildRepeatItem(e,t,r){const n={};if(e&&"object"==typeof e)if(Array.isArray(e))for(let t=0,r=e.length;t<r;t++)n[t]=e[t];else Object.assign(n,e);return n.$key=t,n.$index=r,n.$value=e,n}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,r=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],r++);for(var s=function(r){for(var n in r)"__proto__"!=n&&Object.prototype.hasOwnProperty.call(r,n)&&(t&&"[object Object]"===Object.prototype.toString.call(r[n])?e[n]=dmx.extend(!0,e[n],r[n]):null!=r[n]&&(e[n]=r[n]))};r<n;r++){s(arguments[r])}return e},dmx.parseDate=function(e){if("string"==typeof e){var t,r=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 s,i=0;s=n[i];++i)t[s]=+t[s]||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]&&(r=60*t[10]+t[11],"+"===t[9]&&(r=0-r)),new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5]+r,t[6],t[7])))}if(t=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?$/.exec(e)){var o=new Date;return"Z"===t[5]?(o.setUTCHours(+t[1]||0),o.setUTCMinutes(+t[2]||0),o.setUTCSeconds(+t[3]||0),o.setUTCMilliseconds(+t[4]||0)):(o.setHours(+t[1]||0),o.setMinutes(+t[2]||0),o.setSeconds(+t[3]||0),o.setMilliseconds(+t[4]||0)),o}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,r=JSON.stringify(e),n=0;for(t=0;t<r.length;t++)n=(n<<5)-n+r.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 r=0,n=e.length;r<n;r++){const n=cloneRepeatValue(e[r]);t.push(buildRepeatItem(n,r,r))}else{let r=0;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=cloneRepeatValue(e[n]);t.push(buildRepeatItem(s,n,r)),r++}}else if("number"==typeof e)for(let r=0;r<e;r++)t.push({$key:String(r),$index:r,$value:r+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||null==t.source)&&"dmxNextTick"===t.data&&e.length)for(t.stopPropagation();e.length;){const t=e.shift();t.fn.call(t.context)}},!0),dmx.nextTick=(t,r)=>{e.push({fn:t,context:r}),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))),(()=>{
|
|
8
|
+
/*! (c) Andrea Giammarchi */
|
|
9
|
+
const{is:e}=Object;let t;dmx.batch=e=>{const r=t;t=r||[];try{if(e(),!r)for(const{value:e}of t);}finally{t=r}};class r{constructor(e){this._=e}toJSON(){return this.value}toString(){return String(this.value)}valueOf(){return this.value}}let n;dmx.Signal=r;class s extends r{s;constructor(e,t,r,n){super(e),this.f=n,this.$=!0,this.r=new Set,this.s=new p(t,r)}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 o;dmx.computed=(e,t,r=i)=>new s(e,t,r,!1);const a=[],d=()=>{},l=({s:e})=>{"function"==typeof e._&&(e._=e._())};class h extends s{constructor(e,t,r){super(e,t,r,!0),this.e=a}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=h;class c extends h{constructor(e,t,r){super(e,t,r),this.i=0,this.a=!!r.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=o;(o=this).i=0,l(this),super.value,o=e}stop(){super.stop(),l(this);for(const e of this.e.splice(0))e.stop()}}dmx.Effect=c;dmx.effect=(e,t,r=i)=>{let n;if(o){const{i:s,e:i}=o,a=s===i.length;(a||i[s]._!==e)&&(a||i[s].stop(),i[s]=new c(e,t,r).run()),n=i[s],o.i++}else n=new c(e,t,r).run();return()=>{n.stop()}};const u=()=>!1;class p extends r{constructor(t,{equals:r}){super(t),this.c=new Set,this.s=!0===r?e:r||u}peek(){return this._}get value(){return n&&(this.c.add(n),n.r.add(this)),this._}set value(e){const r=this._;if(this.s(this._=e,r))return;if(!this.c.size)return;const n=[this],s=[];for(let e=0;e<n.length;e++){const t=n[e];for(const e of t.c)if(!e.$&&e.r.has(t))if(e.r.clear(),e.$=!0,e.f){s.push(e);const t=[e];for(let e=0;e<t.length;e++){const r=t[e];if(r.e.length)for(let e=0;e<r.e.length;e++){const n=r.e[e];n.r.clear(),n.$=!0,t.push(n)}}}else n.push(e.s)}if(s.length)if(t)for(let e=0;e<s.length;e++)t.push(s[e]);else for(let e=0;e<s.length;e++)s[e].value}}dmx.signal=(e,t=i)=>new p(e,t)})(),dmx.signalProxy=function(e={}){const t=new Map,r=(e,t)=>dmx.equal(e,t);return new Proxy(e,{has:(e,t)=>!0,get(e,n,s){const i=Reflect.get(e,n,s);return"function"==typeof i||"string"!=typeof n||n.startsWith("_")?i:(t.has(n)||t.set(n,dmx.signal(i,{equals:r})),t.get(n).value)},set(e,r,n,s){const i=Reflect.set(e,r,n,s);return i&&t.has(r)&&(t.get(r).value=n),i},deleteProperty(e,r){const n=Reflect.deleteProperty(e,r);return n&&t.has(r)&&(t.get(r).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,r){return new e(t,r||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 r=t.length;if(t.nodeType)this[0]=t,this.length=1;else{if("string"==typeof t)return e(document.querySelectorAll(t));if(r)for(var n=0;n<r;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 r=0;r<this.length;r++)if(2===arguments.length)this[r].setAttribute(e,t);else for(var n in e)e.hasOwnProperty(n)&&this[r].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 r=0;r<this.length;r++)if(2===arguments.length)this[r][e]=t;else for(var n in e)e.hasOwnProperty(n)&&(this[r][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 r=0;r<this.length;r++)if(2===arguments.length)this[r].style.setProperty(e,t);else for(var n in e)e.hasOwnProperty(n)&&this[r].style.setProperty(n,e[n]);return this},each:function(e,t){if(!e)return this;for(var r=0;r<this.length;r++)if(!1===e.call(t||this[r],r,this[r]))return this;return this},append:function(){for(var t=0;t<arguments.length;t++)for(var r=e(arguments[t]),n=0;n<r.length;n++)this[0].appendChild(r[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 r=document.createElement(t);return e(r)},contains:function(e){return document.documentElement.contains(e)},walk:function(e,t,r){if(e){if(!1===t.call(r,e))return;if(e.hasChildNodes())for(const n of Array.from(e.childNodes))dmx.dom.walk(n,t,r)}},getAttributes:function(e){var t=[];if(1==e.nodeType)for(var r=0;r<e.attributes.length;r++){var n=e.attributes[r];if(n&&n.specified&&dmx.rePrefixed.test(n.name)){var s=n.name.substr(4),i=null,o={};s.split(".").forEach(function(e,t){if(0===t)s=e;else{var r=e.indexOf(":");r>0?o[e.substr(0,r)]=e.substr(r+1):o[e]=!0}});var a=s.indexOf(":");a>0&&(i=s.substr(a+1),s=s.substr(0,a)),t.push({name:s,fullName:n.name,value:n.value,argument:i,modifiers:o})}}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,r)=>e()?t():r()],["+",(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&&null!=e.$this?e.$this:e.data],["true",()=>()=>!0],["false",()=>()=>!1],["null",()=>()=>null],["undefined",()=>()=>{}],["Infinity",()=>()=>1/0],["_",()=>()=>({__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,r,n,s,i,o,a=[],d=0,l=!0;for(;d<e.length;){if(n=d,s=h(),p(s))r="STRING",t=v(s),l=!1;else if((m(s)||u(".")&&c()&&m(c()))&&l)r="NUMBER",t=_(),l=!1;else if(f(s)&&l)r="IDENT",t=b(),u("(")&&(r="METHOD"),l=!1;else if(u("/")&&l&&("("==t||","==t||"?"==t||":"==t)&&w())r="REGEXP",t=E(),l=!1;else{if(y(s)){d++;continue}if((o=h(3))&&dmx._OPERATORS.has(o))r=dmx._OPERATORS.get(o),t=o,l=!0,d+=3;else if((i=h(2))&&dmx._OPERATORS.has(i))r=dmx._OPERATORS.get(i),t=i,l=!0,d+=2;else{if(!dmx._OPERATORS.has(s))throw new Error(`Unexpected token "${s}" at index ${d} in expression: ${e}`);r=dmx._OPERATORS.get(s),t=s,l=!0,d++}}a.push({name:r,index:n,value:t})}return dmx._CACHE.set(e,a),a;function h(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(s)}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 x(e){return"-"==e||"+"==e||m(e)}function v(t){let r=!1,n="";for(d++;d<e.length;){if(s=h(),r){if("u"==s){d++;const t=h(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(s)?dmx._ESCAPE_CHARS.get(s):s;r=!1}else if("\\"==s)r=!0;else{if(s==t)return d++,"`"==t&&(n="{{"+n+"}}"),n;n+=s}d++}throw new Error(`Unterminated string in expression: ${e}`)}function _(){let t="",r=!1;for(;d<e.length;)if(s=h(),u("_")&&c()&&m(c()))d++;else{if(u(".")&&c()&&m(c())||m(s))t+=s;else{const n=c();if(u("eE")&&x(n))t+="e",r=!0;else{if(!(x(s)&&n&&m(n)&&r)){if(!x(s)||n&&m(n)||!r)break;throw new Error(`Invalid exponent in expression: ${e}`)}t+=s,r=!1}}d++}if("n"==h())return d++,BigInt(t);if("m"==h()){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&&(s=h(),g(s));)t+=s,d++;return t}function E(){let t="",r="",n=!1;for(d++;d<e.length;){if(s=h(),n)n=!1;else if("\\"==s)n=!0;else if("/"==s){for(d++;"ign".includes(s=h());)r+=s,d++;return new RegExp(t,r)}t+=s,d++}throw new Error(`Unterminated regexp in expression: ${e}`)}function w(){let e=d,t=!0;try{E()}catch(e){t=!1}return d=e,s="/",t}},dmx.parse=function(e,t=dmx.app,r){if("string"!=typeof e)return e;e=e.trim();const n=Object.assign({},r||{});if(n.expression=n.expression||e,!n.component&&t&&t.$node&&(n.component=t),e.includes("{{")){if(!e.startsWith("{{")||!e.endsWith("}}")||e.slice(2).includes("{{"))return e.replace(/{{(.+?)}}/g,(e,r)=>{const s=dmx.parse(r,t,n);return null==s?"":s});e=e.slice(2,-2)}if(!e)return;let s,i,o;try{s=Array.from(dmx.lexer(e)),o=function(){const e=[];for(;;)if(s.length>0&&!(d("R_PAREN")||d("R_BRACKET")||d("R_CURLY")||d("COMMA")||d("SEMI"))&&e.push(u()),!l("COMMA")&&!l("SEMI"))return(1===e.length?e[0]:t)();function t(){let t;for(let r=0;r<e.length;r++){const n=e[r];n&&(t=n())}return t}}()}catch(r){if(dmx.errors&&dmx.errors.FormatterError&&r instanceof dmx.errors.FormatterError)throw r;const s=dmx.errors&&dmx.errors.createExpressionError?dmx.errors.createExpressionError({expression:e,scope:t,context:n,originalError:r}):r;if(dmx.errors&&dmx.errors.handleExpressionError&&s instanceof Error&&s!==r)return dmx.errors.handleExpressionError(s);if(dmx.errors&&dmx.errors.handleExpressionError)return dmx.errors.handleExpressionError(dmx.errors.createExpressionError({expression:e,scope:t,context:n,originalError:r}));console.error("Error parsing expression:",e,r)}return o;function a(){if(0===s.length)throw new Error(`Unexpected end of expression: ${e}`);return s[0]}function d(e){if(s.length>0){const t=s[0];if(!e||t.name==e)return t}return!1}function l(e){const t=d(e);return!!t&&(s.shift(),t)}function h(t){if(!l(t))throw new Error(`Expected ${t} at index ${s[0].index} in expression: ${e}`)}function c(e){const r=Array.prototype.slice.call(arguments,1);return()=>dmx._EXPRESSIONS.has(e)?dmx._EXPRESSIONS.get(e).apply(t,r):e}function u(){return function(){const e=function(){let e=p();for(;l("LOGICAL_OR");){e=c("||",e,p())}return e}();if(l("QUESTION")){const t=u();h("COLON");return c("?",e,t,u())}return e}()}function p(){let e=m();for(;l("LOGICAL_AND");){e=c("&&",e,m())}return e}function m(){let e=f();for(;l("BITWISE_OR");){e=c("|",e,f())}return e}function f(){let e=g();for(;l("BITWISE_XOR");){e=c("^",e,g())}return e}function g(){let e=y();for(;l("BITWISE_AND");){e=c("&",e,y())}return e}function y(){let e,t=x();if(e=l("EQUALITY")){const r=y();t=c(e.value,t,r)}return t}function x(){let e,t=v();if(e=l("RELATIONAL")){const r=x();t=c(e.value,t,r)}return t}function v(){let e,t=function(){let e,t=_();for(;e=l("ADDICTIVE");){const r=_();t=c(e.value,t,r)}return t}();if(e=l("BITWISE_SHIFT")){const r=v();t=c(e.value,t,r)}return t}function _(){let e,t=b();for(;e=l("MULTIPLICATIVE");){const r=b();t=c(e.value,t,r)}return t}function b(){let e;return(e=l("ADDICTIVE"))?"+"==e.value?E():c(e.value,()=>0,E()):(e=l("LOGICAL_NOT"))||(e=l("BITWISE_NOT"))?c(e.value,b()):E()}function E(){let r,n;if(l("L_PAREN"))r=u(),h("R_PAREN");else if(l("L_CURLY")){const e={};if("R_CURLY"!=a().name)do{const t=l().value;h("COLON"),e[t]=u()()}while(l("COMMA"));r=c(e),h("R_CURLY")}else if(l("L_BRACKET")){const e=[];if("R_BRACKET"!=a().name)do{e.push(u()())}while(l("COMMA"));r=c(e),h("R_BRACKET")}else if(l("PERIOD"))r=d()?k(c(t.data)):c(t.data);else{const n=l();if(!1===n)throw new Error(`Unexpected end of expression: ${e}`);r="IDENT"==n.name?dmx._RESERVED.has(n.value)?dmx._RESERVED.get(n.value)(t):()=>t.get(n.value):"METHOD"==n.name?c(dmx.__formatters.global[n.value]||(()=>{console.warn(`Method "${n.value}" not found in expression: ${e}`)})):()=>n.value}for(;n=l("L_PAREN")||l("L_BRACKET")||l("PERIOD");)if("("==n.value)r=w(r,i);else if("["==n.value)i=r,r=$(r);else{if("."!=n.value)throw new Error(`Unexpected token "${n.value}" at index ${n.index} in expression: ${e}`);i=r,r=k(r)}return i=null,r}function w(r,n){const s=[];if("R_PAREN"!=a().name)do{s.push(u())}while(l("COMMA"));h("R_PAREN");const i="function"==typeof n,o=s.length,d=o+(i?1:0),c=d>0?new Array(d):null;return()=>{const a=r()||dmx.noop,d=a&&a.name?a.name:"<anonymous>";if(!c)try{return a.call(t)}catch(t){if(dmx&&dmx.config&&dmx.config.throwErrors)throw t;return void(console&&console.warn&&console.warn(`Error calling method ${d} in expression: ${e}`,t))}let l=0;i&&(c[l++]=n());for(let e=0;e<o;e++)c[l++]=s[e]();const h=c.length;c.length=l;try{return a.apply(t,c)}catch(t){if(dmx&&dmx.config&&dmx.config.throwErrors)throw t;return void(console&&console.warn&&console.warn(`Error calling method ${d} in expression: ${e}`,t))}finally{c.length=h}}}function $(e){const r=u();return h("R_BRACKET"),()=>{const n=e(),s=r();if("object"==typeof n&&null!=n)return n.__dmxScope__?t.get(s):"map"==dmx.getType(n)?n.get(s):n[s]}}function k(r){const n=l();return()=>{const s=r(),i=dmx.getType(s);if("METHOD"==n.name){const t="__"+n.value;return"map"==i&&"function"==typeof s.get(t)?s.get(t).bind(s):"object"==i&&"function"==typeof s[t]?s[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!=s&&console.warn(`Method "${n.value}" not found in expression: ${e}`)}}return s&&s.__dmxScope__?t.get(n.value):"map"==i?s.get(n.value):s&&"object"==typeof s&&n.value in s?s[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,r,n)=>{const s=Reflect.get(e,t,n),i=Reflect.set(e,t,r,n);return i&&this.isInitialized&&(this.attributes[t]&&this.attributes[t].alwaysUpdate||!dmx.equal(s,r))&&this.requestUpdate(t,s),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,t){const r=Object.assign({},t||{});return r.component=r.component||this,null==r.expression&&(r.expression=e),dmx.parse(e,this,r)},find:function(e){if(this.name==e)return this;for(var t=0;t<this.children.length;t++){var r=this.children[t].find(e);if(r)return r}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,r,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.$data=r||{};for(let t of this.listeners[e.type])!1===t.call(this,e)&&e.preventDefault();return!e.defaultPrevented}},$createChild:function(e,t){var r=new(0,dmx.__components[e])(t,this);this.$addChild(r,r.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,r){r||(r=dmx.dom.getAttributes(t)),r.forEach(r=>{if(t==this.$node){if("bind"==r.name&&this.attributes[(n=r.argument,n.replace(/-./g,e=>e[1].toUpperCase()))])return;if("on"==r.name&&this.events[r.argument])return}var n;if(dmx.__attributes[e][r.name]){this.__inChild=t!=this.$node;const n=dmx.__attributes[e][r.name].call(this,t,r);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.parentElement||e,r=e.nodeValue.replace(dmx.reExpressionReplace,(e,t)=>`##split##${t}##split##`).split("##split##"),n=document.createDocumentFragment();r.forEach((e,r)=>{const s=document.createTextNode(e);if(n.appendChild(s),r%2){const r=e;this.$watch(r,e=>{s.nodeValue=e},{node:t,type:"text",description:"text content binding"})}}),e.parentNode.replaceChild(n,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(),r=dmx.dom.getAttributes(e);if(e.hasAttribute("is")&&(t=e.getAttribute("is")),dmx.reIgnoreElement.test(t))return!1;if(window.grecaptcha&&e.classList.contains("g-recaptcha")){const t=()=>{e.querySelector('[name="g-recaptcha-response"]')||("function"==typeof grecaptcha.render?grecaptcha.render(e):console&&"function"==typeof console.warn&&console.warn("grecaptcha.render is not available; skipping reCAPTCHA initialization"))};"function"==typeof grecaptcha.ready?grecaptcha.ready(t):t()}if(this.$customAttributes("before",e,r),-1!==r.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,r)}3===e.nodeType&&this.$parseTextNode(e)}},this)))},$update:function(e){console.warn("Component.$update is deprecated.")},$parseAttributes:function(e){const t=e=>e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());if(this.attributes){for(const r in this.attributes){const n=this.attributes[r];if(!n)continue;const s=t(r),i=Object.prototype.hasOwnProperty.call(n,"default");let o=i?dmx.clone(n.default):void 0;if(e.hasAttribute(s)){if(n.type===Boolean)o="false"!==e.getAttribute(s);else{if(o=e.getAttribute(s),n.type===Number&&o&&isFinite(Number(o))&&(o=Number(o)),n.type===Object||n.type===Array)try{o=JSON.parse(o)}catch(e){console.warn("Invalid attribute value, expected a JSON string got "+o)}n.enum&&!n.enum.includes(o)&&(o=i?dmx.clone(n.default):o),n.validate&&!n.validate(o)&&(o=i?dmx.clone(n.default):o)}this.props[r]=o}if(e.hasAttribute("dmx-bind:"+s)){const t=e.getAttribute("dmx-bind:"+s);this.$watch(t,e=>{void 0===e?e=i?dmx.clone(n.default):e:n.type===Boolean?e=!!e:(null!=e&&(n.type===Number&&("string"==typeof e?e=e&&isFinite(Number(e))?Number(e):i?dmx.clone(n.default):e:"number"==typeof e&&isFinite(Number(e))||(e=i?dmx.clone(n.default):e)),n.type===String&&(e=String(e)),n.type===Object&&"object"!=typeof e&&(e=i?dmx.clone(n.default):e),n.type===Array&&(e=Array.from(e))),n.enum&&!n.enum.includes(e)&&(e=i?dmx.clone(n.default):e),n.validate&&!n.validate(e)&&(e=i?dmx.clone(n.default):e)),this.props[r]=e},{node:e,attribute:"dmx-bind:"+s,type:"attribute"})}else(i||void 0!==o)&&(this.props[r]=o)}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(t=>{"on"==t.name&&this.events[t.argument]&&this.__disposables.push(dmx.eventListener(this,t.argument,r=>(r.originalEvent&&(r=r.originalEvent),dmx.parse(t.value,dmx.DataScope({$event:r.$data,$originalEvent:r},this),{component:this,node:e,attribute:t.fullName,type:"event",description:`dmx-on:${t.argument}`})),t.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,r){const n=this.__inChild?"__childDisposables":"__disposables";this[n]||(this[n]=[]);let s=!0;const i=Object.assign({component:this,expression:e},r||{}),o=t=>{try{return this.parse(e,i)}catch(e){const t=dmx.errors&&"object"==typeof dmx.errors,n=t&&dmx.errors.ExpressionError,s=t&&dmx.errors.FormatterError;if(s&&e instanceof s)throw e;if(!(e&&("ExpressionError"===e.name||n&&e instanceof n)))throw e;const i=r&&r.strict,o=!!(dmx&&dmx.config&&dmx.config.throwErrors);if(i||o)throw e;if("function"==typeof this._captureExpressionError)try{this._captureExpressionError(e)}catch(e){console&&console.warn&&console.warn("Failed to capture expression error",e)}return void(!(dmx&&dmx.config&&!1===dmx.config.logExpressionErrors)&&console&&console.error&&(!r||!1!==r.log)&&console.error(e.message||e,e.details||e.originalError||void 0))}};this[n].push(dmx.effect(()=>{if(s)t.call(this,o()),s=!1;else{const e=o();queueMicrotask(()=>{t.call(this,e)})}}))},_captureExpressionError:function(e){this.lastExpressionError=e,this.lastExpressionErrorAt=Date.now()},$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=r,dmx.pathToRegexp.compile=function(e,t){return n(r(e,t))},dmx.pathToRegexp.tokensToFunction=n,dmx.pathToRegexp.tokensToRegExp=a;var e="/",t=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function r(r,n){for(var o,a=[],d=0,l=0,h="",c=n&&n.delimiter||e,u=n&&n.whitelist||void 0,p=!1;null!==(o=t.exec(r));){var m=o[0],f=o[1],g=o.index;if(h+=r.slice(l,g),l=g+m.length,f)h+=f[1],p=!0;else{var y="",x=o[2],v=o[3],_=o[4],b=o[5];if(!p&&h.length){var E=h.length-1,w=h[E];(!u||u.indexOf(w)>-1)&&(y=w,h=h.slice(0,E))}h&&(a.push(h),h="",p=!1);var $="+"===b||"*"===b,k="?"===b||"*"===b,A=v||_,C=y||c;a.push({name:x||d++,prefix:y,delimiter:C,optional:k,repeat:$,pattern:A?i(A):"[^"+s(C===c?C:C+c)+"]+?"})}}return(h||l<r.length)&&a.push(h+r.substr(l)),a}function n(e){for(var t=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(t[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,n){for(var s="",i=n&&n.encode||encodeURIComponent,o=0;o<e.length;o++){var a=e[o];if("string"!=typeof a){var d,l=r?r[a.name]:void 0;if(Array.isArray(l)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but got array');if(0===l.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var h=0;h<l.length;h++){if(d=i(l[h],a),!t[o].test(d))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'"');s+=(0===h?a.prefix:a.delimiter)+d}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){if(!a.optional)throw new TypeError('Expected "'+a.name+'" to be '+(a.repeat?"an array":"a string"))}else{if(d=i(String(l),a),!t[o].test(d))throw new TypeError('Expected "'+a.name+'" to match "'+a.pattern+'", but got "'+d+'"');s+=a.prefix+d}}else s+=a}return s}}function s(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function i(e){return e.replace(/([=!:$/()])/g,"\\$1")}function o(e){return e&&e.sensitive?"":"i"}function a(t,r,n){for(var i=(n=n||{}).strict,a=!1!==n.start,d=!1!==n.end,l=n.delimiter||e,h=[].concat(n.endsWith||[]).map(s).concat("$").join("|"),c=a?"^":"",u=0;u<t.length;u++){var p=t[u];if("string"==typeof p)c+=s(p);else{var m=p.repeat?"(?:"+p.pattern+")(?:"+s(p.delimiter)+"(?:"+p.pattern+"))*":p.pattern;r&&r.push(p),p.optional?p.prefix?c+="(?:"+s(p.prefix)+"("+m+"))?":c+="("+m+")?":c+=s(p.prefix)+"("+m+")"}}if(d)i||(c+="(?:"+s(l)+")?"),c+="$"===h?"$":"(?="+h+")";else{var f=t[t.length-1],g="string"==typeof f?f[f.length-1]===l:void 0===f;i||(c+="(?:"+s(l)+"(?="+h+"))?"),g||(c+="(?="+s(l)+"|"+h+")")}return new RegExp(c,o(n))}function d(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.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,r){for(var n=[],s=0;s<e.length;s++)n.push(d(e[s],t,r).source);return new RegExp("(?:"+n.join("|")+")",o(r))}(e,t,n):function(e,t,n){return a(r(e,n),t,n)}(e,t,n)}}(),window.Hjson||(window.Hjson={},window.Hjson.parse=function(e){var t,r,n,s={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(e){if(!e)return e;for(var t=e.split("\n"),r=null,n=0;n<t.length;n++){var s=t[n];if(s.trim()){var i=s.match(/^[ \t]*/),o=i?i[0].length:0;(null===r||o<r)&&(r=o)}}if(!r)return e;for(var a=0;a<t.length;a++){var d=t[a];if(d.trim()){var l=Math.min(r,d.length);t[a]=d.slice(l)}else t[a]=""}return t.join("\n")}function o(e){return"{"===e||"}"===e||"["===e||"]"===e||","===e||":"===e}function a(e){var n,s=0,i=1;for(n=r-1;n>0&&"\n"!==t[n];n--,s++);for(;n>0;n--)"\n"===t[n]&&i++;throw new Error(e+" at line "+i+","+s+" >>>"+t.substr(r-s,20)+" ...")}function d(){return n=t.charAt(r),r++,n}function l(e){return t.charAt(r+e)}function h(e){for(var n=e||0,s=t.charAt(r+n);s&&s<=" "&&"\n"!==s&&"\r"!==s;)n++,s=t.charAt(r+n);return s}function c(e){for(var t="",r=n;d();){if(n===r)return d(),e&&"'"===r&&"'"===n&&0===t.length?(d(),u()):t;if("\\"===n)if(d(),"u"===n){for(var i=0,o=0;o<4;o++){d();var l,h=n.charCodeAt(0);n>="0"&&n<="9"?l=h-48:n>="a"&&n<="f"?l=h-97+10:n>="A"&&n<="F"?l=h-65+10:a("Bad \\u char "+n),i=16*i+l}t+=String.fromCharCode(i)}else{if("string"!=typeof s[n])break;t+=s[n]}else"\n"===n||"\r"===n?a("Bad string containing newline"):t+=n}a("Bad string")}function u(){for(var e="",t=0,r=0;;){var s=l(-r-5);if(!s||"\n"===s)break;r++}function o(){for(var e=r;n&&n<=" "&&"\n"!==n&&e-- >0;)d()}for(;n&&n<=" "&&"\n"!==n;)d();for("\n"===n&&(d(),o());;){if(n){if("'"===n){if(t++,d(),3===t)return"\n"===(e=i(e)).slice(-1)&&(e=e.slice(0,-1)),e;continue}for(;t>0;)e+="'",t--}else a("Bad multiline string");"\n"===n?(e+="\n",d(),o()):("\r"!==n&&(e+=n),d())}}function p(){if('"'===n||"'"===n)return c(!1);for(var e="",s=r,i=-1;;){if(":"===n)return e?i>=0&&i!==e.length&&(r=s+i,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;if(n<=" ")if(n){i<0&&(i=e.length);for(var l,h=0,u=!1,p=null;l=t.charAt(r+h);){if(l>" "||"\n"===l||"\r"===l){if(null===p&&l>" "&&(p=l),":"===l){u=!0;break}if("\n"===l||"\r"===l||o(l))break}h++}if(!u)a("Expected ':' instead of '"+(p||l||"")+"'")}else a("Found EOF while looking for a key name (check your syntax)");else o(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;d()}}function m(){for(;n;){for(;n&&n<=" ";)d();if("#"===n||"/"===n&&"/"===l(0))for(;n&&"\n"!==n&&"]"!==n&&"}"!==n;)d();else{if("/"!==n||"*"!==l(0))break;for(d(),d();n&&("*"!==n||"/"!==l(0));)d();n&&(d(),d())}}}function f(e,t){var r,n,s="",i=0,o=!0,a=0;function d(){return n=e.charAt(a),a++,n}for(d(),"-"===n&&(s="-",d());n>="0"&&n<="9";)o&&("0"==n?i++:o=!1),s+=n,d();if(o&&i--,"."===n)for(s+=".";d()&&n>="0"&&n<="9";)s+=n;if("e"===n||"E"===n)for(s+=n,d(),"-"!==n&&"+"!==n||(s+=n,d());n>="0"&&n<="9";)s+=n,d();for(;n&&n<=" ";)d();return t&&(","!==n&&"}"!==n&&"]"!==n&&"#"!==n&&("/"!==n||"/"!==e[a]&&"*"!==e[a])||(n=0)),r=+s,n||i||!isFinite(r)?void 0:r}function g(e){function t(e,r){var n,s,i,o;switch(typeof e){case"string":e.indexOf(r)>=0&&(o=e);break;case"object":if("[object Array]"===Object.prototype.toString.apply(e))for(n=0,i=e.length;n<i;n++)o=t(e[n],r)||o;else for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(o=t(e[s],r)||o)}return o}function r(r){var n=t(e,r);return n?"found '"+r+"' in a string value, your mistake could be with:\n > "+n+"\n (unquoted strings contain everything up to the next line!)":""}return r("}")||r("]")}function y(){var e=[];try{if(d(),m(),"]"===n)return d(),e;for(;n;){if(e.push(v()),m(),","===n&&(d(),m()),"]"===n)return d(),e;m()}a("End of input while parsing an array (missing ']')")}catch(t){throw t.hint=t.hint||g(e),t}}function x(e){var t="",r={};try{if(e||d(),m(),"}"===n&&!e)return d(),r;for(;n;){if(t=p(),m(),":"!==n&&a("Expected ':' instead of '"+n+"'"),d(),r[t]=v(),m(),","===n&&(d(),m()),"}"===n&&!e)return d(),r;m()}if(e)return r;a("End of input while parsing an object (missing '}')")}catch(e){throw e.hint=e.hint||g(r),e}}function v(){switch(m(),n){case"{":return x();case"[":return y();case"'":case'"':return c(!0);default:return function(){var e=n;for(o(n)&&a("Found a punctuator character '"+n+"' when expecting a quoteless string (check your syntax)");;){d();var t=n&&n<=" "&&"\n"!==n&&"\r"!==n,r="\r"===n||"\n"===n||""===n,s="/"===n&&("/"===l(0)||"*"===l(0));s&&"/"===l(0)&&e.length&&":"===e.charAt(e.length-1)&&(s=!1);var i=r||","===n||"}"===n||"]"===n||"#"===n||s;if(t){var c=e.trim();if(!c){e=c;continue}var u=h(0);if(!("true"!==c&&"false"!==c&&"null"!==c||u&&","!==u&&"}"!==u&&"]"!==u&&"#"!==u&&"/"!==u&&"\n"!==u&&"\r"!==u))return"true"===c||"false"!==c&&null;var p=c[0];if("-"===p||p>="0"&&p<="9"){var m=f(c,!0);if(void 0!==m)return m;if(!u||","===u||"}"===u||"]"===u||"#"===u||"/"===u||"\n"===u||"\r"===u)return c}e+=n}else{if(i){var g=e.trim(),y=g[0];switch(y){case"f":if("false"===g)return!1;break;case"n":if("null"===g)return null;break;case"t":if("true"===g)return!0;break;default:if("-"===y||y>="0"&&y<="9"){var x=f(g,!0);if(void 0!==x)return x}}return g}e+=n}}}()}}function _(e){return m(),n&&a("Syntax error, found trailing characters"),e}if("string"!=typeof e)throw new Error("source is not a string");return t=e,r=0,n=" ",function(){switch(m(),n){case"{":return _(x());case"[":return _(y());default:return _(v())}}()}),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((r,n,s)=>r.then(()=>t(n,s,e.length).then(t=>{t&&(e[s]=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 r=dmx.__actions[t].bind(this),n=e[t],s=t+Date.now();return dmx.debug&&(console.debug("exec action",t,n),console.time(s)),n.disabled?Promise.resolve():Promise.resolve(r(n)).then(e=>{dmx.debug&&(console.debug("finished exec action",t,n),console.timeEnd(s)),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 r in e)e.hasOwnProperty(r)&&(t[r]=this.parse(e[r]));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 r=t.replace(/\+/g," ").split("=");return r[0]&&(e[decodeURIComponent(r[0])]=decodeURIComponent(r[1]||"")),e},{}),r=document.querySelector('meta[name="ac:base"]'),n=document.querySelector('meta[name="ac:route"]');if(n&&n.content){let e=[],s=n.content;r&&r.content&&(s=r.content.replace(/\/$/,"")+s);let i=dmx.pathToRegexp(s,e,{end:!1}).exec(decodeURI(window.location.pathname));i&&e.forEach(function(e,r){t[e.name]=i[r+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),window.grecaptcha&&this.$node.querySelector('.g-recaptcha[data-size="invisible"]')&&e.querySelectorAll(".g-recaptcha").forEach(e=>{e.setAttribute("data-callback","___cb"+String(this.seed).slice(2))})},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")&&"function"==typeof grecaptcha.reset&&grecaptcha.reset()},_submit(e){if(e)return this._formSubmit();this.props.novalidate||this._validate()?window.grecaptcha&&this.$node.querySelector('.g-recaptcha[data-size="invisible"]')&&"function"==typeof grecaptcha.execute?(window["___cb"+String(this.seed).slice(2)]=()=>{this.dispatchEvent("submit",{cancelable:!0})&&this._formSubmit()},grecaptcha.execute()):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 s=t(n.name.replace(/\[\]$/,""));let i=e;for(const e of s){const t=n.type;"number"==t?n.value&&(i=r(i,e,i[e.key],+n.value)):"radio"==t||"checkbox"==t?n.getAttribute("value")?n.checked&&(i=r(i,e,i[e.key],n.value)):i=r(i,e,i[e.key],n.checked):i=r(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=[],r=e,n=/^\[([^\]]*)\]/,s=/^\d+$/;if(!(e=e.replace(/^([^\[]+)/,(e,r)=>(t.push({type:"object",key:r}),""))))return t[0].last=!0,t;for(;e;){if(!n.test(e))return{type:"object",key:r,last:!0};e=e.replace(n,(e,r)=>(r?s.test(r)?t.push({type:"array",key:+r}):t.push({type:"object",key:r}):t[t.length-1].append=!0,""))}for(let e=0,r=t.length;e<r;e++){const n=t[e];e+1<r?n.nextType=t[e+1].type:n.last=!0}return t}function r(e,t,n,s){if(t.last){if(void 0===n)e[t.key]=t.append?[s]:s;else if(Array.isArray(n))e[t.key].push(s);else{if("object"==typeof n)return r(n,{type:"object",key:"",last:!0},n[""],s);e[t.key]=[n,s]}return e}if(void 0===n)return e[t.key]="array"==t.nextType?[]:{};if(Array.isArray(n)){if("array"==t.nextType)return n;const r={};for(let e=0,t=n.length;e<t;e++)void 0!==n[e]&&(r[e]=n[e]);return e[t.key]=r}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.data.value!==this.$node.value&&(this.set("value",this.$node.value),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(e))},_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),r=new Image;r.src=t,r.onerror=()=>URL.revokeObjectURL(t),r.onload=()=>{URL.revokeObjectURL(t);const{imageMaxWidth:n,imageMaxHeight:s,imageType:i,imageQuality:o}=this.props;let a=r.width,d=r.height,l=a/d,h=!1;n&&a>n&&(a=n,d=~~(a/l),h=!0),s&&d>s&&(d=s,a=~~(d*l),h=!0);const c=i?this._imageTypes[i]:e.type;if(c!==e.type||h){const t=document.createElement("canvas"),n=t.getContext("2d");t.width=a,t.height=d,n.drawImage(r,0,0,a,d),t.toBlob(t=>{if(null==t)return console.error("Could not resize image!");const r=new DataTransfer,n=e.name.replace(/\.\w+$/,"."+this._imageExtensions[t.type]),s=new File([t],n,{type:t.type});r.items.add(s),this.$node.files=r.files,this._updateData()},c,o?o/100:void 0)}}}},_updateData(){let e=null;if(this.$node.files.length){const t=this,r=this.$node.files[0];e={date:(r.lastModified?new Date(r.lastModified):r.lastModifiedDate).toISOString(),name:r.name,size:r.size,type:r.type,get dataUrl(){return r._dataUrl||dmx.fileUtils.blobToDataURL(r).then(n=>{r._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 r=URL.createObjectURL(e),n=new Image;n.src=r,n.onerror=()=>URL.revokeObjectURL(r),n.onload=()=>{URL.revokeObjectURL(r);const{imageMaxWidth:s,imageMaxHeight:i,imageType:o,imageQuality:a}=this.props;let d=n.width,l=n.height,h=d/l,c=!1;s&&d>s&&(d=s,l=~~(d/h),c=!0),i&&l>i&&(l=i,d=~~(l*h),c=!0);const u=o?this._imageTypes[o]:e.type;if(u!==e.type||c){const r=document.createElement("canvas"),s=r.getContext("2d");r.width=d,r.height=l,s.drawImage(n,0,0,d,l),r.toBlob(r=>{if(null==r)return console.error("Could not resize image!");const n=e.name.replace(/\.\w+$/,"."+this._imageExtensions[r.type]),s=new File([r],n,{type:r.type});t(s)},u,a?a/100:void 0)}else t(e)}}))).then(e=>{const t=new DataTransfer;for(let r of e)t.items.add(r);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((r,n)=>({date:(r.lastModified?new Date(r.lastModified):r.lastModifiedDate).toISOString(),name:r.name,size:r.size,type:r.type,get dataUrl(){return r._dataUrl||(loading=!0,dmx.fileUtils.blobToDataURL(r).then(s=>{r._dataUrl=s,e=dmx.clone(e),e[n].dataUrl=s,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,t){this._select(e),t&&dmx.nextTick(()=>{this.dispatchEvent("changed"),this.dispatchEvent(this.$node.checked?"checked":"unchecked")})}},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"))),e.has("value")&&(this.$node.value=this.props.value,this.$node.dispatchEvent(new Event("change",{bubbles:!0})))},_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)){const e=document.querySelectorAll(`input[type=radio][name="${this.$node.name}"]`);for(const t of e)t!=this.$node&&t.form==this.$node.form&&"radio"==t.type&&t.name==this.$node.name&&t.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(),requestAnimationFrame(()=>{this._setValue(this.props.value,!0)}),this._mutationObserver=new MutationObserver(e=>{let t=this.props.value;null==t&&(t=""),t=t.toString();for(let r of e){"attributes"==r.type&&"value"==r.attributeName&&"INPUT"===r.target.tagName&&"radio"===r.target.type&&(r.target.checked=r.target.value==t,r.target.defaultChecked=r.target.checked,r.target.dispatchEvent(new Event("change",{bubbles:!0})),requestAnimationFrame(()=>{this._updateValue()}));for(let e of r.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(r=>{r.checked=e.value==t,r.defaultChecked=r.checked}),requestAnimationFrame(()=>{this._updateValue()})})}}),this._mutationObserver.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["value"]})},destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),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.toString(),this._radios().forEach(r=>{r.checked=r.value==e,t&&(r.defaultChecked=r.checked),r.dispatchEvent(new Event("change",{bubbles:!0}))}),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,t){this._select(e),t&&dmx.nextTick(()=>{this.dispatchEvent("changed"),this.dispatchEvent(this.$node.checked?"checked":"unchecked")})}},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"),"reset"!=e.type&&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 r of e)for(let e of r.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&&(this._mutationObserver.disconnect(),this._mutationObserver=null),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(r=>{r.checked=e.includes(r.value),t&&(r.defaultChecked=r.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(e=>{this._updatingOptions||this._updateValue()}),this._mutationObserver.observe(this.$node,{subtree:!0,childList:!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&&(this._mutationObserver.disconnect(),this._mutationObserver=null),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),t.defaultSelected=t.selected});else{const t=Array.from(this.$node.options).findIndex(t=>t.value==e);this.$node.selectedIndex=t}this._updateValue(),dmx.nextTick(()=>this.dispatchEvent("updated"))},_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),t.defaultSelected=t.selected,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(r=>{const n=e.includes(r.value);t?(r.toggleAttribute("selected",n),r.defaultSelected=r.selected):r.selected=n}),this._updateValue(),dmx.nextTick(()=>this.dispatchEvent("updated"))},_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){return this._updateValue(e)},set(e,t){if(arguments.length>1){if("value"===e)return this._updateValue(t);if(e&&e.startsWith("value.")){const r=e.split(".").slice(1),n=this.data.value,s=dmx.clone(n||{});let i=s;for(let e=0;e<r.length-1;e++){const t=r[e];"object"==typeof i[t]&&null!=i[t]||(i[t]={}),i=i[t]}return i[r[r.length-1]]=t,this._updateValue(s)}return dmx.BaseComponent.prototype.set.call(this,e,t)}return this._updateValue(e)}},events:{updated:Event},render:!1,init(e){this._updateValue(this.props.value)},_updateValue(e){return this.data.value!==e&&(dmx.BaseComponent.prototype.set.call(this,"value",e),dmx.nextTick(()=>this.dispatchEvent("updated"))),this.data.value},performUpdate(e){e.has("value")&&(this._updateValue(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"),r=dmx.clone(this.props.repeat),n=dmx.repeatItems(r);if(n.length)if(!this.props.rerender&&this.props.key&&n[0].hasOwnProperty(this.props.key)&&this.prevItems.length){var s,i,o=this.props.key,a=this.prevItems,d=this._clone(n),l=0,h=0,c=a.length-1,u=d.length-1;e:for(;;){for(;a[l][o]===d[h][o];)if(this.childKeys.get(d[h][o]).set(d[h]),h++,++l>c||h>u)break e;for(;a[c][o]===d[u][o];)if(this.childKeys.get(d[u][o]).set(d[u]),u--,l>--c||h>u)break e;if(a[c][o]!==d[h][o]){if(a[l][o]!==d[u][o])break;if(i=u+1,this.childKeys.get(d[u][o]).set(d[u]),this._moveChild(d[u][o],d[i]&&d[i][o]),u--,++l>c||h>u)break}else if(this.childKeys.get(d[h][o]).set(d[h]),this._moveChild(d[h][o],a[l][o]),h++,l>--c||h>u)break}if(l>c)for(i=u+1;h<=u;)this._insertChild(d[h++],d[i]&&d[i][o]);else if(h>u)for(;l<=c;)this._removeChild(a[l++][o]);else{var p=c-l+1,m=u-h+1,f=a,g=new Array(m).fill(-1),y=!1,x=0,v=0;if(m<=4||p*m<=16){for(E=l;E<=c;E++)if(v<m)for(s=h;s<=u;s++)if(a[E][o]===d[s][o]){g[s-h]=E,x>s?y=!0:x=s,this.childKeys.get(d[s][o]).set(d[s]),v++,f[E]=null;break}}else{var _={};for(E=h;E<=u;E++)_[d[E][o]]=E;for(E=l;E<=c;E++)v<m&&void 0!==(s=_[a[E][o]])&&(g[s-h]=E,x>s?y=!0:x=s,this.childKeys.get(d[s][o]).set(d[s]),v++,f[E]=null)}if(p===a.length&&0===v)for(this._clear();h<m;)this._insertChild(d[h++],null);else{for(E=p-v;E>0;)null!==f[l]&&(this._removeChild(a[l][o]),E--),l++;if(y){var b=this._lis(g);for(s=b.length-1,E=m-1;E>=0;E--)-1===g[E]?(i=(x=E+h)+1,this._insertChild(d[x],d[i]&&d[i][o])):s<0||E!==b[s]?(i=(x=E+h)+1,this._moveChild(d[x][o],d[i]&&d[i][o])):s--}else if(v!==m)for(E=m-1;E>=0;E--)-1===g[E]&&(i=(x=E+h)+1,this._insertChild(d[x],d[i]&&d[i][o]))}}}else{if(this.children.length>n.length){const e=this.children.splice(n.length);for(const t of e)t.$destroy()}if(this.children.length&&dmx.batch(()=>{this.children.forEach((e,t)=>{for(const r in e.data)!n[t][r]&&e.data[r]&&(e.data[r].$type||delete e.data[r]);e.set(n[t])})}),n.length>this.children.length){const e=document.createDocumentFragment(),r=new Set;for(var E=this.children.length;E<n.length;E++){var w=new t(this.$template.cloneNode(!0),this,n[E]);for(const t of w.$nodes)e.appendChild(t);r.add(w),this.children.push(w)}this.$node.appendChild(e);for(const e of r)for(const t of e.$nodes)e.$parse(t)}}else this._clear();if(this.props.key){this.prevItems=[];for(const e of n)this.prevItems.push({[this.props.key]:e[this.props.key]});dmx.batch(()=>{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,r,n=e.slice(0),s=[];s.push(0);for(var i=0,o=e.length;i<o;i++)if(-1!==e[i]){var a=s[s.length-1];if(e[a]<e[i])n[i]=a,s.push(i);else{for(t=0,r=s.length-1;t<r;){var d=(t+r)/2|0;e[s[d]]<e[i]?t=d+1:r=d}e[i]<e[s[t]]&&(t>0&&(n[i]=s[t-1]),s[t]=i)}}for(r=s[(t=s.length)-1];t-- >0;)s[t]=r,r=n[r];return s},_clear(){this.prevItems=[],this.childKeys.clear(),this.$node.innerHTML="";const e=this.children.splice(0);for(const t of e)t.$destroy()},_insertChild(e,t){var r=new(dmx.Component("repeat-item"))(this.$template.cloneNode(!0),this,e);for(const e of r.$nodes)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),r.$parse(e);this.childKeys.set(e[this.props.key],r),this.children.push(r)},_moveChild(e,t){var r=this.childKeys.get(e);if(r)if(this.childKeys.has(t))for(const e of r.$nodes)this.$node.insertBefore(e,this.childKeys.get(t).$nodes[0]);else for(const e of r.$nodes)this.$node.appendChild(e);else 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,r,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(r),this.seed=t.seed,this.name=n||"repeatItem",this.$nodes=[];for(var s=0;s<e.childNodes.length;s++)this.$nodes.push(e.childNodes[s])},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"},prefix:{type:String,default:""},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 r={};e&&(r.params=e),t&&(r.ttl=0),this._fetch(r)},reset(){this._abort(),this._resetData(!0)}},events:{start:Event,done:Event,error:Event,invalid:Event,unauthorized:Event,forbidden:Event,ratelimit:Event,abort:Event,success:Event,upload:ProgressEvent,download:ProgressEvent},_statusEvents:{200:"success",400:"invalid",401:"unauthorized",403:"forbidden",429:"ratelimit"},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&&(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&&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:t,argument:r,value:n})=>{r&&n&&["param","header"].includes(t)&&this.$watch(n,e=>{this.props[t+"s"]=Object.assign({},this.props[t+"s"],{[r]:e})},{node:e,attribute:`dmx-${t}:${r}`,type:"attribute",description:`dmx-fetch ${t} binding`}),r&&n&&"data"==t&&this.$watch(n,e=>{this.props.data=Object.assign({},this.props.data,{[r]:e})},{node:e,attribute:`dmx-data:${r}`,type:"attribute",description:"dmx-fetch data binding"})})},_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 r=e.params[t];return"string"==typeof r&&r.startsWith("{{")&&(r=this.parse(r)),encodeURIComponent(t)+"="+encodeURIComponent(r)}).join("&");if(this._resetData(),this.dispatchEvent("start"),this._url=e.url,e.prefix&&(this._url=e.prefix.replace(/\/$/,"")+"/"+this._url.replace(/^\//,"")),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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrsuccess",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response}}));this.parse(`${this.props.cache}.remove("${this._url}")`)}}this.set("state",{executing:!0,uploading:!1,processing:!1,downloading:!1});let r=null,n=this.props.method.toUpperCase();"GET"!==n&&("text"===this.props.dataType?r=this.props.data.toString():"json"===this.props.dataType?r=JSON.stringify(this.props.data):"POST"===n?(r=new FormData,Object.keys(this.props.data).forEach(e=>{let t=this.props.data[e];Array.isArray(t)?(/\[\]$/.text(t)||(e+="[]"),t.forEach(t=>r.append(e,t))):r.set(e,t)})):r=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(r)}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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrerror",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:e.message}}));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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrerror",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:"Invalid JSON: "+t}}))}if(this._parseHeaders(),this._xhr.status<400)return this.set({status:this._xhr.status,data:t}),this.dispatchEvent("success"),this.dispatchEvent("done"),this.props.cache&&this.parse(`${this.props.cache}.set("${this._url}", { headers: headers, paging: paging, links: links, data: data, created: ${Date.now()} })`),void this.$node.dispatchEvent(new CustomEvent("xhrsuccess",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:t}}));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"),this.$node.dispatchEvent(new CustomEvent("xhr"+(this._statusEvents[this._xhr.status]||"error"),{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:t}}))},_parseHeaders(){try{const e=this._xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",e.reduce((e,t)=>{const r=t.split(": "),n=r.shift(),s=r.join(": ");return e[n]=s,e},{}))}catch(e){return void console.warn("Error parsing response headers",e)}this._parseLinkHeaders()},_parseLinkHeaders(){try{const e=this.data&&this.data.headers?this.data.headers:{},t=Object.keys(e).find(e=>"link"===e.toLowerCase());if(t){const r=e[t];if("string"==typeof r&&r.trim()){let e=!1;const t=r.split(/,\s*</).map(t=>{try{const r=t.match(/<?([^>]*)>(.*)/);if(!r)return e=!0,null;const n=new URL(r[1],window.location&&window.location.href?window.location.href:void 0),s=(r[2]||"").split(";").map(e=>e.trim()).filter(Boolean),i=n.search.slice(1).split("&").filter(Boolean).reduce((e,t)=>{const r=t.split("="),n=decodeURIComponent(r[0]||"");return n?(e[n]=decodeURIComponent(r[1]||""),e):e},{}),o=s.reduce((t,r)=>{const n=r.match(/^(.*)=(.*)$/);if(!n)return e=!0,t;const s=n[1].replace(/^rel$/i,"rel").trim(),i=n[2].replace(/^"|"$/g,"").trim();return t[s]=i,t},{}),a=Object.assign({},i,o);return a.url=n.toString(),a}catch(t){return console.warn("Error parsing link header part",t),e=!0,null}}).filter(e=>e&&e.rel).reduce((e,t)=>(t.rel.split(/\s+/).filter(Boolean).forEach(r=>{e[r]=Object.assign({},t,{rel:r})}),e),{});this.set("links",t),e&&console.warn("Error parsing link header",r)}else this.set("links",{})}else this.set("links",{})}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:r,next:n,last:s}=this.data.links;if(r||n){s&&s.page?e.pages=+s.page:r&&r.page&&(e.pages=+r.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]),r&&r.page?e.page=+r.page+1:n&&n.page&&(e.page=+n.page-1),e.has={first:!!t,prev:!!r,next:!!n,last:!!s}}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"),this.$node.dispatchEvent(new CustomEvent("xhrabort",{bubbles:!0,detail:{source:this.name,status:0,response:null}}))},_errorHandler(e){this._done(Error("Failed to execute"))},_timeoutHandler(e){this._done(Error("Execution timeout"))},_progressHandler(e,t){const r=t.lengthComputable?Math.ceil(100*t.loaded/t.total):0;this.set({state:{executing:!0,uploading:"upload"===e&&r<100,processing:"upload"===e&&100===r,downloading:"download"===e},[e+"Progress"]:{position:t.loaded,total:t.total,percent:r}}),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},prefix:{type:String,default:""}},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,ratelimit: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&&(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&&this._xhr.upload.removeEventListener("progress",this._uploadProgressHandler),this._xhr=null)},$parseAttributes(e){dmx.BaseComponent.prototype.$parseAttributes.call(this,e),dmx.dom.getAttributes(e).forEach(t=>{const{name:r,argument:n,value:s}=t;n&&s&&["param","header"].includes(r)&&this.$watch(s,e=>{this.props[r+"s"]=Object.assign({},this.props[r+"s"],{[n]:e})},{node:e,attribute:t.fullName,type:"attribute",description:`dmx-${r}:${n}`})})},_statusEvents:{200:"success",400:"invalid",401:"unauthorized",403:"forbidden",429:"ratelimit"},_extendNode(e){e.dmxExtraData={},e.dmxExtraElements=[]},_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)},_formSubmit(){this._send()},_send(){this._abort();const e=this.$node.method.toUpperCase();let t=this.$node.action;this.props.prefix&&(t=this.props.prefix.replace(/\/$/,"")+"/"+t.replace(/^\//,""));let r=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)r=this._parseJsonForm(),this.$node.dmxExtraData&&Object.assign(r,this.$node.dmxExtraData),r=JSON.stringify(r);else if(r=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=>r.append(e,t))):r.set(e,t)}this._resetData(),this.dispatchEvent("start"),this.set("state",{executing:!0,uploading:!1,processing:!1,downloading:!1});let s=t;n&&(s+=(s.includes("?")?"&":"?")+n),window.WebviewProxy&&(s=window.WebviewProxy.convertProxyUrl(s)),this._xhr.open(e,s),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(r)}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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrerror",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:e.message}}));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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrerror",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:"Invalid JSON: "+t}}))}try{const e=this._xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);this.set("headers",e.reduce((e,t)=>{const r=t.split(": "),n=r.shift(),s=r.join(": ");return e[n]=s,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"),this.dispatchEvent("done"),void this.$node.dispatchEvent(new CustomEvent("xhrsuccess",{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:t}}));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 r=this.$node.querySelector(`[name="${e}"]`);if(r){const n=t.form[e];dmx.validate.setMessage(r,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"):429===this._xhr.status?this.dispatchEvent("ratelimit"):this.dispatchEvent("error");this.dispatchEvent("done");const r=e?e.message:t;this.$node.dispatchEvent(new CustomEvent("xhr"+(this._statusEvents[this._xhr.status]||"error"),{bubbles:!0,detail:{source:this.name,status:this._xhr.status,response:r}}))},_loadHandler(e){this._done()},_abortHandler(e){this._resetData(),this.dispatchEvent("abort"),this.dispatchEvent("done"),this.$node.dispatchEvent(new CustomEvent("xhrabort",{bubbles:!0,detail:{source:this.name,status:0,response:null}}))},_errorHandler(e){this._done(Error("Failed to execute"))},_timeoutHandler(e){this._done(Error("Execution timeout"))},_progressHandler(e,t){const r=t.lengthComputable?Math.ceil(100*t.loaded/t.total):0;this.set({state:{executing:!0,uploading:"upload"===e&&r<100,processing:"upload"===e&&100===r,downloading:"download"===e},[e+"Progress"]:{position:t.loaded,total:t.total,percent:r}}),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),r=this.props.utc,n=r?e.getUTCFullYear():e.getFullYear(),s=(r?e.getUTCMonth():e.getMonth())+1,i=r?e.getUTCDate():e.getDate(),o=r?e.getUTCHours():e.getHours(),a=r?e.getUTCMinutes():e.getMinutes(),d=r?e.getUTCSeconds():e.getSeconds(),l=t(n,4)+"-"+t(s,2)+"-"+t(i,2),h=r?"Z":"";switch(this.props.interval){case"days":return l+"T00:00:00"+h;case"hours":return l+"T"+t(o,2)+":00:00"+h;case"minutes":return l+"T"+t(o,2)+":"+t(a,2)+":00"+h}return l+"T"+t(o,2)+":"+t(a,2)+":"+t(d,2)+h}}),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 r=this._indexOf(e);-1!=r&&this._splice(r,0,t)},insertAfter(e,t){const r=this._indexOf(e);-1!=r&&this._splice(r+1,0,t)},replace(e,t){const r=this._indexOf(e);-1!=r&&this._splice(r,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)},concat(e){const t=dmx.clone(this.data.items);t.push(...dmx.array(e)),this._updateData(t)},concatUniq(e){const t=dmx.clone(this.data.items),r=dmx.array(e);for(const e of r)-1==t.indexOf(e)&&t.push(e);this._updateData(t)},flatten(e=1){const t=dmx.clone(this.data.items).flat(e);this._updateData(t)},flattenUniq(e=1){const t=dmx.clone(this.data.items).flat(e),r=[];for(const e of t)-1==r.indexOf(e)&&r.push(e);this._updateData(r)},reverse(){this._reverse()},sort(e,t){this._sort(e,t)},randomize(){this._randomize()},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,r){const n=dmx.clone(this.data.items);void 0!==r?n.splice(e,t,r):n.splice(e,t),this._updateData(n)},_reverse(){const e=dmx.clone(this.data.items);e.reverse(),this._updateData(e)},_sort(e,t){const r=dmx.clone(this.data.items),n=null!=e,s="string"==typeof t&&"desc"===t.toLowerCase();if(n){const t=this._createComparator(e,s);r.sort(t)}else r.sort(),s&&r.reverse();this._updateData(r)},_randomize(){const e=dmx.clone(this.data.items);if(e.length<2)return void this._updateData(e);const t=dmx.randomizer(Date.now()+Math.random());for(let r=e.length-1;r>0;r--){const n=Math.floor(t()*(r+1)),s=e[r];e[r]=e[n],e[n]=s}this._updateData(e)},_createComparator(e,t){if("function"==typeof e)return t?(t,r)=>e(r,t):e;const r=this._buildGetter(e);return(e,n)=>{const s=r(e),i=r(n);return this._compareValues(s,i,t)}},_buildGetter(e){if(Array.isArray(e)&&e.length)return t=>this._resolvePath(t,e);if("string"==typeof e&&e.length){const t=e.split(".");return e=>this._resolvePath(e,t)}return e=>e},_resolvePath:(e,t)=>t.reduce((e,t)=>{if(null!=e)return e[t]},e),_compareValues:(e,t,r)=>e===t?0:null==e?r?1:-1:null==t||e>t?r?-1:1:e<t?r?1:-1:0,_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},flow:{type:[Array,Object],default:null},preload:{type:Boolean,default:!1},autorun:{type:Boolean,default:!1},params:{type:Object,default:{}}},methods:{run(e,t){const r=void 0===t||t;return this._run(e,r)},runSub(e){return this._runSub(e)}},events:{start:Event,done:Event,error:Event},render:!1,init(e){if(this.props.flow)this._flow=this.props.flow,this.props.autorun&&this._run();else 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:t,argument:r,value:n})=>{r&&n&&"param"==t&&this.$watch(n,e=>{this.props.params=Object.assign({},this.props.params,{[r]:e})},{node:e,attribute:`dmx-param:${r}`,type:"attribute",description:"dmx-flow param binding"})})},_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=!0){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,r=this.props.data;this._appendData(t,r,this.props.name)},_appendData(e,t,r=""){null!==t&&(Array.isArray(t)?t.forEach((t,n)=>{this._appendData(e,t,`${r}[${n}]`)}):"object"!=typeof t?e.append(r,t):Object.keys(t).forEach(n=>{this._appendData(e,t[n],`${r}[${n}]`)}))}}),dmx.Attribute("bind","mounted",function(e,t){const r=t.argument,n=dmx.reToggleAttribute.test(r);this.$watch(t.value,t=>{if(n)t?e.setAttribute(r,""):e.hasAttribute(r)&&e.removeAttribute(r);else{if("style"===r&&"object"==typeof t)return Object.assign(e.style,t);if(null==t)return e.removeAttribute(r);e.setAttribute(r,t),"src"===r&&("VIDEO"===e.nodeName||"AUDIO"===e.nodeName?e.load():"SOURCE"===e.nodeName&&e.parentNode&&e.parentNode.load())}},{node:e,attribute:t.fullName,type:"attribute",description:`dmx-bind:${r}`})}),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(r){r.originalEvent&&(r=r.originalEvent);const n=dmx.DataScope({$event:r.$data,event:r,$originalEvent:r},e.dmxOn.component);n.$this=this;return dmx.parse(t.value,n,{component:e.dmxOn.component,node:e,attribute:t.fullName,type:"event",description:`dmx-on:${t.argument}`})},t.modifiers)}),dmx.Attribute("repeat","before",function(e,t){const r=document.createComment("start "+t.fullName+"="+t.value),n=document.createComment("end "+t.fullName+"="+t.value),s=document.createDocumentFragment(),i=dmx.Component("repeat-item");e.parentNode.replaceChild(n,e),n.parentNode.insertBefore(r,n),e.removeAttribute(t.fullName),s.append(e);let o=[];this.$watch(t.value,e=>{const r=dmx.repeatItems(e);if(r.length>1e4&&(console.warn("More than 10000 repeat items, we limit the result!"),r.length=1e4),t.modifiers.fast){if(o.length>r.length&&o.splice(r.length).forEach(e=>e.$destroy()),o.length&&o.forEach((e,t)=>e.set(r[t])),r.length>o.length){const e=document.createDocumentFragment(),a=new Set;r.slice(o.length).forEach(t=>{const r=new i(s.cloneNode(!0),this,t);e.appendChild(r.$nodes[0]),a.add(r),o.push(r),this.$addChild(r)}),n.parentNode&&n.parentNode.insertBefore(e,n);for(const e of a)e.$parse(e.$nodes[0]);t.argument&&this.set(t.argument,r)}}else{const e=document.createDocumentFragment(),a=new Set;o.splice(0).forEach(e=>e.$destroy());for(const t of r){const r=new i(s.cloneNode(!0),this,t);e.append(r.$nodes[0]),a.add(r),o.push(r),this.$addChild(r)}n.parentNode&&n.parentNode.insertBefore(e,n);for(const e of a)e.$parse(e.$nodes[0]);t.argument&&this.set(t.argument,r)}},{node:n.parentNode||e.parentNode||e,attribute:t.fullName,type:"attribute",description:"dmx-repeat"})}),dmx.Attribute("class","mounted",function(e,t){e.dmxClass||(e.dmxClass={component:this}),this.$watch(t.value,r=>{e.dmxClass[t.argument]=r,e.classList[r?"add":"remove"](t.argument)},{node:e,attribute:t.fullName,type:"attribute",description:`dmx-class:${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:r}=e.dmxHide,n=t?"none":r.display,s=t?"important":r.priority;e.style.setProperty("display",n,s)},{node:e,attribute:t.fullName,type:"attribute",description:"dmx-hide"}))}),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:r}=e.dmxShow,n=t?r.display:"none",s=t?r.priority:"important";e.style.setProperty("display",n,s)},{node:e,attribute:t.fullName,type:"attribute",description:"dmx-show"}))}),dmx.Attribute("html","mounted",function(e,t){e.dmxHtml||(e.dmxHtml={component:this},this.$watch(t.value,t=>{e.innerHTML=null!=t?String(t):""},{node:e,attribute:t.fullName,type:"attribute",description:"dmx-html"}))}),dmx.Attribute("text","mounted",function(e,t){e.dmxText||(e.dmxText={component:this},this.$watch(t.value,t=>{const r=null!=t?String(t):"";e.textContent=r},{node:e,attribute:t.fullName,type:"attribute",description:"dmx-text"}))}),dmx.Attribute("style","mounted",function(e,t){e.dmxStyle||(e.dmxStyle={component:this});const r=t.modifiers.important?"important":"";this.$watch(t.value,n=>{e.dmxStyle[t.argument]=n,null!=n&&e.style.setProperty(t.argument,n,r)},{node:e,attribute:t.fullName,type:"attribute",description:`dmx-style:${t.argument}`})}),dmx.Formatters("global",{json:function(e){return JSON.stringify(e)},log:function(e){return console.log(e),e},run:function(e,t){var r=dmx.DataScope({$param:t},this);dmx.Flow.run(e,r)}}),dmx.Actions({subflow(e){const t=this.parse(e.flow),r=this.parse(e.param);return this.parse(t+".runSub("+JSON.stringify(r)+")")},comment(e){dmx.debug&&console.debug(e.message)},wait(e){let t=this.parse(e.delay);if("string"==typeof t&&""!==t.trim()){const e=Number(t.trim());t=Number.isFinite(e)?e:t}if("number"!=typeof t||!Number.isFinite(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),r=this.parse(e.upper),n=!!this.parse(e.floating);"number"==typeof t&&isFinite(t)||(t=0),"number"==typeof r&&isFinite(r)||(r=1);let s=t+Math.random()*(r-t);return n||Math.floor(t)!=t||Math.floor(r)!=r||(s=Math.round(s)),s},triggerDownload(e){const t=this.parse(e.url),r=this.parse(e.filename)||"";if("string"!=typeof t)throw new Error("download: Invalid url");const n=document.createElement("a");return n.href=t,n.download=r,document.body.appendChild(n),n.click(),n.remove(),!0},confirm(e){const t=this.parse(e.message);if("string"!=typeof t)throw new Error("confirm: Invalid message");const r=confirm(t);if(r){if(e.then)return this._exec(e.then).then(()=>r)}else if(e.else)return this._exec(e.else).then(()=>r);return r},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 r=[],n=0;n<t;n++)r.push(n+1);t=r}if("object"!=typeof t)throw new Error("repeat: data is not repeatable");const s=this.scope,i=this.output;return this._each(t,(t,r)=>(this.scope=new dmx.DataScope(Object.assign({$value:t,$index:r,$name:r,$key:r,$number:r+1,$oddeven:r%2},t),s),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=s,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 r=e.conditions[t];if(this.parse(r.when))return this._exec(r.then)}},select(e){const t=this.parse(e.expression);if(Array.isArray(e.cases))for(let r=0;r<e.cases.length;r++){const n=e.cases[r];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 this.output=t,e})}return this._exec(e.exec)},while(e){const t=()=>new Promise(r=>{if(!this.parse(e.condition))return r();this._exec(e.exec).then(t).then(r)});return t()},switch(e){const t=this.parse(e.expression);for(let r=0;r<e.cases.length;r++)if(this.parse(e.cases[r].case)===t)return this._exec(e.cases[r].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),r=this.parse(e.args);return window[t].apply(null,r)},assign(e){return this.parse(e.value)},setGlobal(e){const t=this.parse(e.key),r=this.parse(e.value);if("string"!=typeof t)throw new Error("setGlobal: key must be a string");return dmx.global.set(t,r),r},setSession(e){const t=this.parse(e.key),r=this.parse(e.value);if("string"!=typeof t)throw new Error("setSession: key must be a string");return sessionStorage.setItem(t,JSON.stringify(r)),r},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),r=this.parse(e.value);if("string"!=typeof t)throw new Error("setStorage: key must be a string");return localStorage.setItem(t,JSON.stringify(r)),r},getStorage(e){const t=this.parse(e.key);if("string"!=typeof t)throw new Error("getStorage: key must be a string");const r=localStorage.getItem(t);return null==r?null:JSON.parse(r)},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),r=this.parse(e.method),n=this.parse(e.timeout),s=this.parse(e.dataType),i=this.parse(e.data),o=this.parse(e.params),a=this.parse(e.headers),d=this.parse(e.credentials),l=null;if("string"!=typeof t)throw new Error("fetch: invalid url "+t);if(["GET","POST","PUT","DELETE"].includes(r)||(r="GET"),["auto","json","text"].includes(s)||(s="auto"),"number"!=typeof n&&(n=0),a||(a={}),"object"==typeof o)for(var h in o)o.hasOwnProperty(h)&&null!=o[h]&&(t+=(-1!=t.indexOf("?")?"&":"?")+encodeURIComponent(h)+"="+encodeURIComponent(o[h]));if("GET"!=r)if("text"==s)a["Content-Type"]||(a["Content-Type"]="application/text"),l=i.toString();else if("json"==s)a["Content-Type"]||(a["Content-Type"]="application/json"),l=JSON.stringify(i);else if("POST"==r){if(l=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)&&l.append(c,u[p]);else l.set(c,u)}}else i&&(a["Content-Type"]||(a["Content-Type"]="application/text"),l=i.toString());return new Promise((e,s)=>{var i=new XMLHttpRequest;for(var o in i.onerror=s,i.onabort=s,i.ontimeout=s,i.onload=function(){var t=i.responseText,r=i.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce(function(e,t){var r=t.split(": "),n=r.shift(),s=r.join(": ");return e[n.toLowerCase()]=s,e},{});/^application\/json/.test(r["content-type"])&&(t=JSON.parse(t)),e({status:i.status,headers:r,data:t})},i.open(r,t),i.timeout=1e3*n,a)a.hasOwnProperty(o)&&i.setRequestHeader(o,a[o]);d&&(i.withCredentials=!0),i.send(l)})}}),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),r=e.add,n=!!this.parse(e.overwrite);if(!t.length)return[];for(var s=[],i=0,o=t.length;i<o;i++){var a=dmx.clone(t[i]);for(var d in r)if(r.hasOwnProperty(d)){var l=new dmx.DataScope(a,this.scope);(n||null==a[d])&&(a[d]=dmx.parse(r[d],l))}s.push(a)}return s},"collections.filterColumns":function(e){var t=this.parse(e.collection),r=this.parse(e.columns),n=!!this.parse(e.keep);if(!t.length)return[];for(var s=[],i=0,o=t.length;i<o;i++){var a=t[i],d={};for(var l in a)a.hasOwnProperty(l)&&(r.includes(l)?n&&(d[l]=dmx.clone(a[l])):n||(d[l]=dmx.clone(a[l])));s.push(d)}return s},"collections.renameColumns":function(e){var t=this.parse(e.collection),r=this.parse(e.rename);if(!t.length)return[];for(var n=[],s=0,i=t.length;s<i;s++){var o=t[s],a={};for(var d in o)o.hasOwnProperty(d)&&(a[r[d]||d]=dmx.clone(o[d]));n.push(a)}return n},"collections.fillDown":function(e){var t=this.parse(e.collection),r=this.parse(e.columns);if(!t.length)return[];for(var n=[],s={},i=0,o=r.length;i<o;i++)s[r[i]]=null;for(i=0,o=t.length;i<o;i++){var a=dmx.clone(t[i]);for(var d in s)s.hasOwnProperty(d)&&(null==a[d]?a[d]=s[d]:s[d]=a[d]);n.push(a)}return n},"collections.addRows":function(e){var t=this.parse(e.collection),r=this.parse(e.rows);return dmx.clone(t).concat(dmx.clone(r))},"collections.addRowNumbers":function(e){for(var t=this.parse(e.collection),r=this.parse(e.column),n=this.parse(e.startAt),s=!!this.parse(e.desc),i=[],o=0,a=t.length;o<a;o++){var d=dmx.clone(t[o]);d[r]=s?a+n-o:n+o,i.push(d)}return i},"colections.join":function(e){for(var t=this.parse(e.collection1),r=this.parse(e.collection2),n=this.parse(e.matches),s=!!this.parse(e.matchAll),i=[],o=0,a=t.length;o<a;o++){for(var d=dmx.clone(t[o]),l=0,h=r.length;l<h;l++){var c=r[l],u=!1;for(var p in n)if(n.hasOwnProperty(p))if(d[p]==c[n[p]]){if(u=!0,!s)break}else if(s){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),r=[],n=[],s=0,i=t.length;s<i;s++)for(var o in t[s])t[s].hasOwnProperty(o)&&-1==r.indexOf(o)&&r.push(o);for(s=0,i=t.length;s<i;s++){for(var a={},d=0,l=r.length;d<l;d++){o=r[d];var h=t[s].hasOwnProperty(o)?dmx.clone(t[s][o]):null;a[o]=null!=h?h:null}n.push(a)}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()}});
|
|
10
|
+
//# sourceMappingURL=dmxAppConnect.js.map
|