@shortfuse/materialdesignweb 0.11.1 → 0.11.2

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/README.md CHANGED
@@ -72,7 +72,7 @@ Notes:
72
72
 
73
73
  ## Documentation
74
74
 
75
- Material Design Web (MDW) is components-first. If you just want to build UI, start with the component docs and use HTML only — no JavaScript required.
75
+ Material Design Web (MDW) is components-first. If you just want to build a UI, start with the component docs and use HTML only — no custom JavaScript required.
76
76
 
77
77
  ### 1) Use the components
78
78
  - [Getting started](docs/components/getting-started.md)
@@ -1344,6 +1344,9 @@ export default class Composition {
1344
1344
 
1345
1345
  // @ts-ignore DocumentFragment in documents can be replaced (bad typings)
1346
1346
  instanceAnchorElement.replaceWith(anchorNode);
1347
+ // Store parent props that nested composition needs
1348
+ const parentProps = newComposition.props.filter((p) => p !== valueName && p !== iterableName);
1349
+
1347
1350
  adapter = new CompositionAdapter({
1348
1351
  anchorNode,
1349
1352
  composition: newComposition,
@@ -1353,6 +1356,7 @@ export default class Composition {
1353
1356
  store: state.options.store,
1354
1357
  injections: this.injections,
1355
1358
  },
1359
+ parentProps,
1356
1360
  });
1357
1361
 
1358
1362
  state.adapters[this.adapterIndex] = adapter;
@@ -1375,11 +1379,12 @@ export default class Composition {
1375
1379
  const changeList = iterableDeepProp
1376
1380
  ? deepPropFromObject(iterableDeepProp, changes)
1377
1381
  : changes[iterableName];
1382
+ const needTargetAll = newComposition.props
1383
+ .some((prop) => prop !== valueName && prop !== iterableName && prop in changes);
1378
1384
 
1379
- if (changeList === undefined) return;
1385
+ if (changeList === undefined && !needTargetAll) return;
1380
1386
 
1381
1387
  const innerChanges = { ...changes };
1382
- const needTargetAll = newComposition.props.some((prop) => prop !== iterableName && prop in changes);
1383
1388
 
1384
1389
  adapter.startBatch();
1385
1390
  let isArray;
@@ -1398,7 +1403,7 @@ export default class Composition {
1398
1403
  currentInjections[valueName] = resource;
1399
1404
  currentInjections.index = index;
1400
1405
  adapter.renderOptions.injections = currentInjections;
1401
- adapter.renderData(index, innerChanges, data, resource, change);
1406
+ adapter.renderData(index, innerChanges, source, resource, change);
1402
1407
  }
1403
1408
  } else {
1404
1409
  if (!changeList) {
@@ -1423,7 +1428,7 @@ export default class Composition {
1423
1428
  currentInjections[valueName] = resource;
1424
1429
  currentInjections.index = index;
1425
1430
  adapter.renderOptions.injections = currentInjections;
1426
- adapter.renderData(index, innerChanges, data, resource, change);
1431
+ adapter.renderData(index, innerChanges, source, resource, change);
1427
1432
  // adapter.renderIndex(index, innerChanges, data, resource);
1428
1433
  }
1429
1434
  }
@@ -12,11 +12,12 @@ import { createEmptyComment } from './optimizations.js';
12
12
 
13
13
  /**
14
14
  * @template T
15
- * @typedef {Object} DomAdapterCreateOptions
15
+ * @typedef {Object} CompositionAdapterCreateOptions
16
16
  * @prop {Comment} anchorNode
17
17
  * @prop {(...args:any[]) => HTMLElement} [create]
18
18
  * @prop {Composition<T>} composition
19
19
  * @prop {RenderOptions<T>} renderOptions
20
+ * @prop {string[]} [parentProps]
20
21
  */
21
22
 
22
23
  /**
@@ -71,7 +72,7 @@ const moveBeforeNode = hasMoveBefore
71
72
 
72
73
  /** @template T */
73
74
  export default class CompositionAdapter {
74
- /** @param {DomAdapterCreateOptions<T>} options */
75
+ /** @param {CompositionAdapterCreateOptions<T>} options */
75
76
  constructor(options) {
76
77
  this.anchorNode = options.anchorNode;
77
78
 
@@ -106,6 +107,8 @@ export default class CompositionAdapter {
106
107
  this.batchStartIndex = null;
107
108
  /** @type {number|null} */
108
109
  this.batchEndIndex = null;
110
+
111
+ this.parentProps = options.parentProps || [];
109
112
  }
110
113
 
111
114
  /**
@@ -286,7 +289,17 @@ export default class CompositionAdapter {
286
289
  }
287
290
  }
288
291
 
289
- const render = this.render(changes, data);
292
+ const initialChanges = { ...changes };
293
+
294
+ if (this.parentProps.length) {
295
+ for (const prop of this.parentProps) {
296
+ if (prop in data) {
297
+ initialChanges[prop] = data[prop];
298
+ }
299
+ }
300
+ }
301
+
302
+ const render = this.render(initialChanges, data);
290
303
  const element = /** @type {Element} */ (render.target);
291
304
 
292
305
  this.metadata[newIndex] = {
@@ -1,2 +1,2 @@
1
- var Le,Ue;function pe(){return(Le??=new Text).cloneNode()}function F(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,t;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(t=i==null?void 0:i.querySelector)==null?void 0:t.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function me(i,e,t){let n=Ve(i);e?e.before(i):t.append(i),qe(n)}var $e=typeof Element.prototype.moveBefore=="function",J=$e?(i,e,t)=>{t.moveBefore(i,e)}:me,U=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null}render(e,t){return this.composition.render(e,t,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var t;if(!this.queuedElements.length)return;(((t=this.metadata[this.batchStartIndex-1])==null?void 0:t.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}moveToEndByIndex(e){let[t]=this.metadata.splice(e,1),{domNode:n,key:s}=t;this.keys.splice(e,1);let r=n.parentNode;r&&me(n,null,r),this.metadataCache?this.metadataCache.set(s,t):this.metadataCache=new Map([[s,t]])}renderData(e,t,n,s,r,o){if(e<this.metadata.length){let c=this.metadata[e],u=c.key,p=u===s,x=r!==s;if(p){x?c.render(t,n):o||c.render(t,n);return}let y=this.metadataCache??=new Map,C=!1;this.needsArrayKeyFastPath&&(C=!this.keys.includes(s),this.needsArrayFastPath=!1);let h=C?-1:this.keys.indexOf(s,e+1);if(h===-1){if(y.has(s)){let d=y.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),J(d.domNode,c.domNode,c.domNode.parentNode),d.render(t,n),y.delete(s);return}y.set(u,c)}else{if(e-h===-1){this.moveToEndByIndex(e);return}let d=this.metadata[h];this.metadata[e]=d,this.metadata[h]=c;let{domNode:f}=c,m=f.parentNode,g=d.domNode.nextSibling;J(d.domNode,f,m),g&&J(f,g,m),o||d.render(t,n),this.keys[e]=s,this.keys[h]=u;return}}let a=this.render(t,n),l=a.target;this.metadata[e]={render:a,element:l,key:s,domNode:l},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(l)}removeEntries(e=0){let{length:t}=this.metadata;for(let n=t-1;n>=e;n--){let s=this.metadata[n];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||t.hidden)return!1;let{comment:s,element:r}=t;return s||(s=F(),t.comment=s),r.replaceWith(s),t.domNode=s,t.hidden=!0,!0}show(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||!t.hidden)return!1;let{comment:s,element:r}=t;return s.replaceWith(r),t.domNode=r,t.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let t=new CSSStyleSheet;return t.replaceSync(i),e&&ee.set(i,t),t}var te=new Map,ye;function He(i,e=!0){let t;return e&&te.has(i)?t=te.get(i):(ye??=document.implementation.createHTMLDocument(),t=ye.createElement("style"),t.textContent=i,e&&te.set(i,t)),t.cloneNode(!0)}var K;function be(i,e=!0){if(K==null)try{let t=G(i,e);return K=!0,t}catch{K=!1}return K?G(i,e):He(i,e)}function*ge(i,e=!0){for(let t of i)t instanceof HTMLStyleElement?yield G(t.textContent,e):t.ownerNode?yield G([...t.cssRules].map(n=>n.cssText).join(""),e):yield t}var ne=new WeakMap;function*Ce(i,e=!0){for(let t of i)if(t instanceof HTMLStyleElement)yield t;else if(t.ownerNode instanceof HTMLStyleElement)yield t.ownerNode.cloneNode(!0);else if(e&&ne.has(t))yield ne.get(t).cloneNode(!0);else{let n=document.createElement("style");n.textContent=[...t.cssRules].map(s=>s.cssText).join(""),e&&ne.set(t,n),yield n.cloneNode(!0)}}function xe(i,...e){return be(typeof i=="string"?i:String.raw({raw:i},...e))}function ke(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var Q;function R(i){if(Q??=new Map,Q.has(i))return Q.get(i);let e=i.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return Q.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Se,ut=Number.parseFloat((Se=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Se[1]),Pe,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((Pe=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:Pe[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[t,n]of Object.entries(e))n==null?t in i&&delete i[t]:i[t]=Ee(i[t],n);return i}function Ne(i,e){if(i===e)return i;let t=e!=null&&typeof e=="object"&&!Array.isArray(e),n=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!t||!n)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function Ie(i,e,t="reference"){switch(t){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function ve(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return e;let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=ve(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return structuredClone(e);let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}return e.length!==i.length&&(t.length=e.length),t}let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Ae(i,e,t="reference"){switch(t){case"clone":return _e(i,e);case"object":return se(i,e);default:return ve(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[t,n]of Object.entries(e))if(n==null){if(t in i)return!0}else if(ie(i[t],n))return!0;return!1}function Ge(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,t="reference"){switch(t){case"clone":case"object":return Ge(i,e);default:return ie(i,e)}}function Oe(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,t,n){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;if(n?t.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,t,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;n?t.add(a):e.add(a)}return o}})}var z=new WeakMap,oe=new WeakMap;function Qe(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let t=new Set;e={subscribe(n){t.add(n)},unsubscribe(n){t.delete(n)},emit(n){for(let s of t)s(n)}},oe.set(i,e)}return e}function X(i,e){let t={},n=t;for(let s=0;s<i.length-1;s++)n[i[s]]={},n=n[i[s]];return n[i.at(-1)]=e,t}function je(i,e,t,n,s){if(i==null||typeof i!="object")return i;let r=Qe(i);s||(s=r);let o=z.get(i);if(o||(o=new Map,z.set(i,o)),o.has(n))return o.get(n);let a=new Proxy(i,{get(l,c){if(typeof c=="symbol")return l[c];let u=l[c];return je(u,e,t.concat(c),n,s)},set(l,c,u){if(l[c]=u,typeof c!="symbol"){let p=X(t.concat(c),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=X([c],u);r.emit(x)}}return!0},deleteProperty(l,c){if(typeof c!="symbol"){let u=X(t.concat(c),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=X([c],null);r.emit(p)}}return Reflect.deleteProperty(l,c)}});return z.set(a,o),r&&oe.set(a,r),o.set(n,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let t=new Set,n=new Set,s=e.map(l=>{let c=new Set,u=new Set,p=re(l,c,u);return{poked:c,pokedDeep:u,proxy:p}}),r=re(this??{},t,n),o=i.apply(r,s.map(l=>l.proxy)),a=i.name?!0:!t.size;return{props:{this:[...t],args:s.map(l=>[...l.poked])},deepPropStrings:{this:[...n],args:s.map(l=>[...l.pokedDeep])},deepProps:{this:[...n].map(l=>l.split(".")),args:s.map(l=>[...l.pokedDeep].map(c=>c.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,t){let n=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:l,enumerable:c,reflect:u,attr:p,nullable:x,parser:y,nullParser:C,get:h,is:d,diff:f,props:m}=n;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let g=ae(h.bind(t),t,()=>r);r??=g.defaultValue,m=new Set([...g.props.this,...g.props.args[0]])}if(!l)if(r==null)l="string";else{let g=typeof r;l=g==="number"?Number.isInteger(r)?"integer":"float":g}return c??=i[0]!=="_",x??=l==="boolean"?!1:a==null,x||(a??=Oe(l),r??=a),u??=c?l!=="object":p?"write":!1,p??=u?R(i):null,y??=Xe(l),C||(x?C=ze:C=a===null?()=>Oe(l):()=>a),d??=l==="object"||l==="proxy"?(g,N)=>!Me(g,N):l==="array"?()=>!1:Object.is,f===void 0&&(f=l==="object"?(g,N)=>Ae(g,N):null),{...n,type:l,is:d,diff:f,attr:p,reflect:u,readonly:o,enumerable:c,value:r,parser:y,nullParser:C,key:i,props:m,watchers:s}}function V(i,e,t){var r,o;i.get;let n=t==null?i.nullParser.call(this,t):i.parser.call(this,t),s=n;if(e==null){if(n==null)return!1}else if(n!=null){if(i.diff){if(s=i.diff.call(this,e,n),s==null)return!1}else if(i.is.call(this,e,n))return!1}return i.values?i.values.set(this,n):i.values=new WeakMap([[this,n]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,n,s),(o=i.changedCallback)==null||o.call(this,e,n,s),!0}function ce(i,e,t){let n=Ye(e,t,i);function s(h){if(n.type!=="proxy"||h==null||typeof h!="object")return h;let d=z.get(h);if(d&&d.has(this))return d.get(this);let f=this;return je(h,g=>{var S,O,j;let N=((S=n.values)==null?void 0:S.get(f))??h;(O=n.propChangedCallback)==null||O.call(f,n.key,N,N,g),(j=n.changedCallback)==null||j.call(f,N,N,g)},[],f,null)}function r(){var h;return(h=n.values)!=null&&h.has(this)?n.values.get(this):n.value}function o(){var d;if((d=n.values)!=null&&d.has(this))return n.values.get(this);let h=s.call(this,n.value);return h!==n.value&&(n.values?n.values.set(this,h):n.values=new WeakMap([[this,h]])),h}function a(h){var f;if(i===this&&((f=this==null?void 0:this.constructor)==null?void 0:f.prototype)===this)return;let d=this[e];V.call(this,n,d,h)}function l(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let d=this[e],f=s.call(this,h);V.call(this,n,d,f)}function c(){var f,m;let h=(f=n.computedValues)==null?void 0:f.get(this),d=this[e];(m=n.needsSelfInvalidation)==null||m.delete(this),V.call(this,n,h,d)}if(n.props)for(let h of n.props)n.watchers.push([h,c]);function u(){let h=n.get.call(this,this,r.bind(this));return(n.computedValues??=new WeakMap).set(this,h),h}function p(){let h=n.get.call(this,this,o.bind(this)),d=s.call(this,h);return(n.computedValues??=new WeakMap).set(this,d),d}function x(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let d=this[e];n.set.call(this,h,a.bind(this));let f=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),V.call(this,n,d,f))}function y(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let d=this[e];n.set.call(this,h,l.bind(this));let f=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),V.call(this,n,d,f))}let C={enumerable:n.enumerable,configurable:!0,get:n.get?n.type==="proxy"?p:u:n.type==="proxy"?o:r,set:n.set?n.type==="proxy"?y:x:n.type==="proxy"?l:a};return Object.defineProperty(i,e,C),n}var Te=new Set;function q(i="mdw_",e=4){let t;for(;Te.has(t=Math.random().toString(36).slice(2,e+2)););return Te.add(t),`${i}${t}`}var le,Fe,Re;function B(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Fe??=le.createDocumentFragment(),Fe.cloneNode())}var Y=new Map;function ue(i){let e=`#${q()}`;return Y.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let t,n=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=q();return t??=new Map,t.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...n);if(t){let o=B(s);for(let[a,l]of t)o.getElementById(a).replaceWith(l);return o}let r;return he.has(s)?r=he.get(s):(r=B(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:t,attrName:n}=this,s=i[t];switch(e){case void 0:case null:case!1:return s.removeAttribute(n),!1;case!0:return s.setAttribute(n,""),"";default:return s.setAttribute(n,e),e}}function Je({nodeStates:i,comments:e,nodes:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(n!=null&&n!==!1)){if(a)return;let p=e[s];p||(p=F(),e[s]=p),t[r].replaceWith(p),i[r]|=1;return}let c=t[r],u=o&2;if(n instanceof Node)n.nodeType===11||c!==n&&(c.replaceWith(n),t[r]=n),i[r]|=2;else if(typeof n!="object")if(u){let p=new Text(n);c.replaceWith(p),t[r]=p,i[r]&=-3}else c.data=n;a&&(e[s].replaceWith(c),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=n!=null&&n!==!1;if(a===!o)return;let l=e[r],c=t[s];c||(c=F(),t[s]=c),a?(c.replaceWith(l),i[r]&=-2):(l.replaceWith(c),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:t}){let{commentIndex:n,nodeIndex:s}=this,r=F();i[n]=r,e[s]|=1,t[s].replaceWith(r)}function fe(i,...e){let[{caches:t,searchStates:n}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,l=t[s],c=n[r];if(c&1)return{value:l,dirty:(c&2)===2};n[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&l!==void 0)return n[r]&=-3,{value:l,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||l===u)return{value:u,dirty:!1}}return t[s]=u,n[r]|=2,{value:u,dirty:!0}}function Be({options:{context:i,store:e,injections:t}},n,s){return this.expression.call(i,e??s,t)}function nt(i,e){return e[this.prop]}function st(i,e,t){let n=e;for(let s of this.deepProp){if(n==null)return n;if(!(s in n))return;n=n[s]}return n}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function $(i,e){if(!e)return;let t=e,n;for(n of i)if(typeof t=="object"){if(t===null)return null;if(!(n in t))return;t=t[n]}else return t[n];return t}function ot(i,e){let t=e;for(let n of i.split("."))if(!n||(t=t[n],t==null))return null;return t===e?null:t}var We=new Map,W=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=B(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[n,s]of We)if(n.length===e.length&&e.every((r,o)=>r===n[o]))return s;let t=new i(...e);return We.set(e,t),t}append(...e){for(let t of e)typeof t=="string"?this.append(B(t.trim())):t instanceof i?this.append(...t):t instanceof DocumentFragment?this.template.append(t):(t instanceof CSSStyleSheet||t instanceof HTMLStyleElement)&&this.styles.push(t);return this}addCompositionEventListener(e){let t=e.tag??"",n=this.events??=new Map;return n.has(t)?n.get(t).push(e):n.set(t,[e]),this}#s(e,t,n){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=$(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),t.addEventListener(r.type,n?o.bind(n):o,r)}}render(e,t,n={}){this.interpolated||this.interpolate({defaults:t??e,...n});let s=this.cloneable.cloneNode(!0),r=n.shadowRoot,o=r??n.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:n},{nodes:l,refs:c,searchStates:u,caches:p}=a;for(let{tag:y,textNodes:C}of this.nodesToBind){let h;if(y===""){if(!C.length)continue;c.push(null),l.push(null),h=s.firstChild}else{let f=s.getElementById(y);if(c.push(f),l.push(f),this.#s(y,f,n.context),!C.length)continue;h=f.firstChild}let d=0;for(let f of C){for(;f!==d;)h=h.nextSibling,d++;l.push(h)}}this.#s("",n.context),this.#s(i.shadowRootTag,n.context.shadowRoot,n.context);for(let y of this.postInitActions)y.invocation(a);let x=(y,C)=>{var d;if(!y)return;let h=!1;for(let f of this.props){if(!((d=this.actionsByPropsUsed)!=null&&d.has(f))||!(f in y))continue;let m=this.actionsByPropsUsed.get(f);for(let g of m){h=!0;let{dirty:N,value:S}=fe(g.search,a,y,C);N&&g.invocation(a,S,y,C)}}h&&u.fill(0)};return r?(n.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):n.context??=o,e!==this.interpolateOptions.defaults&&x(e,t),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(y,C,h)=>{var g,N;if(!((g=this.actionsByPropsUsed)!=null&&g.has(y)))return;let d=!1;if((N=this.searchByQuery)!=null&&N.has(y)){d=!0;let S=this.searchByQuery.get(y);if(p[S.cacheIndex]===C)return;p[S.cacheIndex]=C,u[S.searchIndex]=3}let f,m=this.actionsByPropsUsed.get(y);for(let S of m)if(S.search.query===y)S.invocation(a,C);else{f??={[y]:C},h??=f,d=!0;let O=fe(S.search,a,f,h);O.dirty&&S.invocation(a,O.value,f,h)}d&&u.fill(0)},x.state=a,x}#n(e,t,n,s){var O,j;let{nodeValue:r,nodeName:o,nodeType:a}=e,l,c;if(a===Node.ATTRIBUTE_NODE?l=e:c=e,s==null){if(!r)return;let P=r.trim();if(!P)return;if(l||(t==null?void 0:t.tagName)==="STYLE"){if(P[0]!=="{")return;let{length:w}=P;if(P[w-1]!=="}")return;s=P.slice(1,-1)}else{let w=P.split(it);if(w.length<3)return;if(w.length===3&&!w[0]&&!w[2])s=w[1];else{for(let[b,M]of w.entries())if(b%2){let I=pe();c.before(I),this.#n(I,t,n,M)}else M&&c.before(M);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let y,C;if(c){t!==c.parentElement&&(t=c.parentElement),C=0;let P=c;for(;P=P.previousSibling;)C++}else if(t!==l.ownerElement&&(t=l.ownerElement),o.startsWith("on")){let P=o.indexOf("-");if(P===-1)return;y=P===2}if(y){t.removeAttribute(o);let P=this.#t(t),w=o.slice(3),[,b,M]=w.match(/^([*1~]+)?(.*)$/),I,_,k=[];if(s.startsWith("#"))I=Y.get(s).fn;else{let T=s.split(".");T.length===1?(_=s,k=[]):(_=T[0],k=T)}this.addCompositionEventListener({tag:P,type:M,handleEvent:I,prop:_,deepProp:k,once:b==null?void 0:b.includes("1"),passive:b==null?void 0:b.includes("~"),capture:b==null?void 0:b.includes("*")});return}let h;if((O=this.searchByQuery)!=null&&O.has(u))h=this.searchByQuery.get(u);else{let P=s,w=P!==u,b;if(w&&((j=this.searchByQuery)!=null&&j.has(P)))b=this.searchByQuery.get(P);else{let M,I,_,k,T,D,A,E;if(s.startsWith("#")){if(E=Y.get(s),!E)return;M=E.fn,A=Be,E.props?(I=E.props,_=E.deepProps,k=E.defaultValue??null):k=E.fn}else k=null,n!=null&&n.defaults&&(k=$(s.split("."),n.defaults)??null),k==null&&(n!=null&&n.injections)&&(k=ot(s,n.injections));if(!I)if(typeof k=="function"){let v=ae.call(this,k,n==null?void 0:n.defaults,n==null?void 0:n.injections),L=new Set([...v.props.this,...v.props.args[0],...v.props.args[1]]),H=new Set([...v.deepPropStrings.this,...v.deepPropStrings.args[0]]);M=k,k=v.defaultValue,I=[...L],_=[...H].map(De=>De.split(".")),A=Be}else{let v=s.split(".");v.length===1?(T=s,I=[T],A=nt):(I=[v[0]],D=v,_=[v],A=st)}E&&(E.defaultValue=k,E.props=I,E.deepProps=_),b={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:P,defaultValue:k,subSearch:null,prop:T,propsUsed:I,deepProp:D,deepPropsUsed:_,invocation:A,expression:M},this.addSearch(b)}w?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:b,negate:p,doubleNegate:x,prop:b.prop,deepProp:b.deepProp,propsUsed:b.propsUsed,deepPropsUsed:b.deepPropsUsed,defaultValue:x?!!b.defaultValue:p?!b.defaultValue:b.defaultValue,invocation(M){return this.doubleNegate?!!M:this.negate?!M:M}},this.addSearch(h)):h=b}let d,f=null,m=h.defaultValue;c?f=C:o==="mdw-if"?(d=this.#t(t),t.removeAttribute(o),m=m!=null&&m!==!1):(f=o,o==="id"||m==null||m===!1?t.removeAttribute(o):t.setAttribute(o,m===!0?"":m)),d??=this.#t(t);let g=this._interpolationState.nodeEntry;(!g||g.tag!==d)&&(g={tag:d,textNodes:[]},this._interpolationState.nodeEntry=g,this.nodesToBind.push(g),this._interpolationState.nodeIndex++);let N;if(c)switch(g.textNodes.push(C),this._interpolationState.nodeIndex++,N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":c.data=m;break;case"number":c.data=`${m}`;break;default:c.data="";break}else f?N={nodeIndex:this._interpolationState.nodeIndex,attrName:f,defaultValue:m,invocation:Ze,search:h}:(N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...N,invocation:tt}));this.addAction(N),(this.tagsWithBindings??=new Set).add(d)}#t(e){if(!e)return"";let t=e.id;return t?this.allIds.includes(t)||this.allIds.push(t):(t=q(),(this.temporaryIds??=new Set).add(t),this.allIds.push(t),e.id=t),t}#e(e,t){let n=e.getAttribute("mdw-for"),s=n==null?void 0:n.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,l]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let c=e.ownerDocument.createElement("template");e.replaceWith(c);let u=this.#t(c),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let y={...t.injections,[a]:null,index:null},C=l.split("."),h=C.length>1?C:null,d=h?C[0]:l,f=[d],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:f,deepPropsUsed:h?[h]:[[d]],defaultValue:{},invocation:null},g={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:y,invocation(S,O,j,P){let w=S.adapters[this.adapterIndex];if(!w){let A=S.nodes[this.nodeIndex],E=F();if(S.comments[this.commentIndex])throw new Error("Comment already exists at index");S.comments[this.commentIndex]=E,A.replaceWith(E),w=new U({anchorNode:E,composition:x,renderOptions:{target:null,context:S.options.context,store:S.options.store,injections:this.injections}}),S.adapters[this.adapterIndex]=w}let b=S.options.injections??this.injections,M=P??S.options.store,I=h?$(h,M):M[d];if(I===void 0&&h&&b&&(I=$(h,b)),!I||I.length===0){w.removeEntries();return}let _=h?$(h,j):j[d];if(_===void 0)return;let k={...j},T=x.props.some(A=>A!==d&&A in j);w.startBatch();let D;if(!T&&!(D=Array.isArray(_))){let A=D?_.entries():Object.entries(_);for(let[E,v]of A){if(E==="length"||v===null)continue;let L=+E,H=I[L];k[a]=v,b[a]=H,b.index=L,w.renderOptions.injections=b,w.renderData(L,k,P,H,v)}}else{_||delete k[a];for(let[A,E]of I.entries()){let v;if(_){if(!T&&!(A in _)||(v=_[A],v===null))continue;k[a]=v}b[a]=E,b.index=A,w.renderOptions.injections=b,w.renderData(A,k,P,E,v)}}w.stopBatch(),w.removeEntries(I.length)}};return x.interpolate({defaults:t.defaults,injections:y}),f.push(...x.props),this.addSearch(m),this.addAction(g),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let n=document.createTreeWalker(this.cloneable,5),s=n.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=n.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=n.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=n.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let l of[...o.attributes].reverse())l.nodeName!=="id"&&this.#n(l,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=n.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=n.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...ge(this.styles)]:(this.stylesFragment=B(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let t=this.actionsByPropsUsed??=new Map;for(let n of e.search.propsUsed)t.has(n)?t.get(n).push(e):t.set(n,[e]);return e}};function Tt(i,e){return(t,n,s)=>{n==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,n)}}var Z=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new W}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,t){if(!this.hasOwnProperty(e)){this[e]=[...this[e],t];return}this[e].push(t)}static _removeCallback(e,t){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(n=>n!==t)}static _removeFromCallbackMap(e,t,n){if(!e.has(t))return;if(!n){e.delete(t);return}let s=e.get(t).filter(r=>r!==n);s.length===0?e.delete(t):e.set(t,s)}static append(...e){return this._onComposeCallbacks.push(({composition:t})=>{t.append(...e)}),this._addCallback("_onComposeCallbacks",(t=>{let{composition:n}=t;n.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;typeof e=="string"||Array.isArray(e)?s.append(xe(e,...t)):s.append(e,...t)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;s.append(de(e,...t))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,t){return this.set(e,{...t,writable:!1})}static set(e,t){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([n,s])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,value:s,writable:!0,...t}])),...Object.getOwnPropertySymbols(e).map(n=>[n,{enumerable:!1,configurable:!0,value:e[n],writable:!0,...t}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._attributeChangedCallbacks}static prop(e,t){let n=ce(this.prototype,e,t),{changedCallback:s,attr:r,reflect:o,watchers:a}=n;return s&&a.push([e,s]),n.changedCallback=function(c,u,p){this.#l.call(this,e,c,u,p)},this.propList.set(e,n),r&&(o===!0||o==="read")&&(n.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,n),this.onPropChanged(a),this}static setPrototype(e,t){return this.prop(e,t),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([t,n])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,...typeof n=="function"?{get:n}:n}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:t,attr:n,reflect:s}=this.propList.get(e);if(t.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of t){let l=r.indexOf(a);l!==-1&&r.splice(l,1)}}n&&(s===!0||s==="read")&&this.attrList.delete(n),this.propList.delete(e)}return this}static observe(e){for(let[t,n]of Object.entries(e??{})){let s=typeof n=="function"?{reflect:!1,get:n}:n;this.prop(t,s)}return this}static defineStatic(e){for(let[t,n]of Object.entries(e??{}))ce(this,t,{reflect:!1,...typeof n=="function"?{get:n}:typeof n=="string"?{type:n}:n});return this}static events(e,t){return this.on({composed({composition:n}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),l,c=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(l=r,c=[]):(l=u[0],c=u)}n.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:l,deepProp:c}:r,...t})}}}),this}static childEvents(e,t){for(let[n,s]of Object.entries(e))this.events(s,{tag:R(n),...t});return this}static rootEvents(e,t){return this.events(e,{tag:W.shadowRootTag,...t})}static on(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static offAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static onPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}static onAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let t of this.static._onConstructedCallbacks)t.call(this,this.callbackArguments)}propChangedCallback(e,t,n,s=n){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,t,n,s,this)}attributeChangedCallback(e,t,n){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,t,n,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,t,n);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===n))return;let l=this[o.key],c=n===null?o.nullParser(n):o.type==="boolean"?!0:o.parser(n);c!==l&&(a?(a.stringValue=n,a.parsedValue=c):this.attributeCache.set(e,{stringValue:n,parsedValue:c}),this[o.key]=c)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,t,n,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let l,c=!1,{attributeCache:u}=this;if(u.has(a)?(l=u.get(a),c=l.parsedValue!==n):(l={},u.set(a,l),c=!0),c){let p=ke(n);l.parsedValue=n,l.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,t,n,s)}get static(){return this.constructor}patch(e){this.#r=!0,Ie(this,e,"object");for(let[t,n,s]of this.#i)t in e||this.render.byProp(t,n,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,t)=>{let n=this.composition,s;if(!n.interpolated){if(this.#t.has(t)&&(s=this.#t.get(t).deref(),s))return s;let a=R(t);return s=n.template.getElementById(a),s?(this.#t.set(t,new WeakRef(s)),s):null}if(this.#n.has(t)&&(s=this.#n.get(t).deref(),s))return s;let r=R(t),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(t,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};Z.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,Z as default};
1
+ var Le,Ue;function pe(){return(Le??=new Text).cloneNode()}function R(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,n;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(n=i==null?void 0:i.querySelector)==null?void 0:n.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function me(i,e,n){let t=Ve(i);e?e.before(i):n.append(i),qe(t)}var $e=typeof Element.prototype.moveBefore=="function",J=$e?(i,e,n)=>{n.moveBefore(i,e)}:me,U=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null,this.parentProps=e.parentProps||[]}render(e,n){return this.composition.render(e,n,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var n;if(!this.queuedElements.length)return;(((n=this.metadata[this.batchStartIndex-1])==null?void 0:n.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}moveToEndByIndex(e){let[n]=this.metadata.splice(e,1),{domNode:t,key:s}=n;this.keys.splice(e,1);let r=t.parentNode;r&&me(t,null,r),this.metadataCache?this.metadataCache.set(s,n):this.metadataCache=new Map([[s,n]])}renderData(e,n,t,s,r,o){if(e<this.metadata.length){let u=this.metadata[e],p=u.key,x=p===s,C=r!==s;if(x){C?u.render(n,t):o||u.render(n,t);return}let b=this.metadataCache??=new Map,h=!1;this.needsArrayKeyFastPath&&(h=!this.keys.includes(s),this.needsArrayFastPath=!1);let f=h?-1:this.keys.indexOf(s,e+1);if(f===-1){if(b.has(s)){let d=b.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),J(d.domNode,u.domNode,u.domNode.parentNode),d.render(n,t),b.delete(s);return}b.set(p,u)}else{if(e-f===-1){this.moveToEndByIndex(e);return}let d=this.metadata[f];this.metadata[e]=d,this.metadata[f]=u;let{domNode:m}=u,g=m.parentNode,S=d.domNode.nextSibling;J(d.domNode,m,g),S&&J(m,S,g),o||d.render(n,t),this.keys[e]=s,this.keys[f]=p;return}}let a={...n};if(this.parentProps.length)for(let u of this.parentProps)u in t&&(a[u]=t[u]);let c=this.render(a,t),l=c.target;this.metadata[e]={render:c,element:l,key:s,domNode:l},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(l)}removeEntries(e=0){let{length:n}=this.metadata;for(let t=n-1;t>=e;t--){let s=this.metadata[t];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,n,t){if(!n&&(e==null&&(e=this.keys.indexOf(t)),n=this.metadata[e],!n)||n.hidden)return!1;let{comment:s,element:r}=n;return s||(s=R(),n.comment=s),r.replaceWith(s),n.domNode=s,n.hidden=!0,!0}show(e,n,t){if(!n&&(e==null&&(e=this.keys.indexOf(t)),n=this.metadata[e],!n)||!n.hidden)return!1;let{comment:s,element:r}=n;return s.replaceWith(r),n.domNode=r,n.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let n=new CSSStyleSheet;return n.replaceSync(i),e&&ee.set(i,n),n}var te=new Map,ye;function He(i,e=!0){let n;return e&&te.has(i)?n=te.get(i):(ye??=document.implementation.createHTMLDocument(),n=ye.createElement("style"),n.textContent=i,e&&te.set(i,n)),n.cloneNode(!0)}var K;function be(i,e=!0){if(K==null)try{let n=G(i,e);return K=!0,n}catch{K=!1}return K?G(i,e):He(i,e)}function*ge(i,e=!0){for(let n of i)n instanceof HTMLStyleElement?yield G(n.textContent,e):n.ownerNode?yield G([...n.cssRules].map(t=>t.cssText).join(""),e):yield n}var ne=new WeakMap;function*Ce(i,e=!0){for(let n of i)if(n instanceof HTMLStyleElement)yield n;else if(n.ownerNode instanceof HTMLStyleElement)yield n.ownerNode.cloneNode(!0);else if(e&&ne.has(n))yield ne.get(n).cloneNode(!0);else{let t=document.createElement("style");t.textContent=[...n.cssRules].map(s=>s.cssText).join(""),e&&ne.set(n,t),yield t.cloneNode(!0)}}function xe(i,...e){return be(typeof i=="string"?i:String.raw({raw:i},...e))}function ke(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var Q;function B(i){if(Q??=new Map,Q.has(i))return Q.get(i);let e=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return Q.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Se,ut=Number.parseFloat((Se=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Se[1]),Pe,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((Pe=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:Pe[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[n,t]of Object.entries(e))t==null?n in i&&delete i[n]:i[n]=Ee(i[n],t);return i}function Ne(i,e){if(i===e)return i;let n=e!=null&&typeof e=="object"&&!Array.isArray(e),t=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!n||!t)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function Ie(i,e,n="reference"){switch(n){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function ve(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e))return e;let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=ve(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e))return structuredClone(e);let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){n[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(n[s]=o)}return e.length!==i.length&&(n.length=e.length),n}let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function Ae(i,e,n="reference"){switch(n){case"clone":return _e(i,e);case"object":return se(i,e);default:return ve(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[n,t]of Object.entries(e))if(t==null){if(n in i)return!0}else if(ie(i[n],t))return!0;return!1}function Ge(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,n="reference"){switch(n){case"clone":case"object":return Ge(i,e);default:return ie(i,e)}}function Oe(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,n,t){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=t?`${t}.${r}`:r;if(t?n.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,n,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=t?`${t}.${r}`:r;t?n.add(a):e.add(a)}return o}})}var z=new WeakMap,oe=new WeakMap;function Qe(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let n=new Set;e={subscribe(t){n.add(t)},unsubscribe(t){n.delete(t)},emit(t){for(let s of n)s(t)}},oe.set(i,e)}return e}function X(i,e){let n={},t=n;for(let s=0;s<i.length-1;s++)t[i[s]]={},t=t[i[s]];return t[i.at(-1)]=e,n}function je(i,e,n,t,s){if(i==null||typeof i!="object")return i;let r=Qe(i);s||(s=r);let o=z.get(i);if(o||(o=new Map,z.set(i,o)),o.has(t))return o.get(t);let a=new Proxy(i,{get(c,l){if(typeof l=="symbol")return c[l];let u=c[l];return je(u,e,n.concat(l),t,s)},set(c,l,u){if(c[l]=u,typeof l!="symbol"){let p=X(n.concat(l),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=X([l],u);r.emit(x)}}return!0},deleteProperty(c,l){if(typeof l!="symbol"){let u=X(n.concat(l),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=X([l],null);r.emit(p)}}return Reflect.deleteProperty(c,l)}});return z.set(a,o),r&&oe.set(a,r),o.set(t,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let n=new Set,t=new Set,s=e.map(c=>{let l=new Set,u=new Set,p=re(c,l,u);return{poked:l,pokedDeep:u,proxy:p}}),r=re(this??{},n,t),o=i.apply(r,s.map(c=>c.proxy)),a=i.name?!0:!n.size;return{props:{this:[...n],args:s.map(c=>[...c.poked])},deepPropStrings:{this:[...t],args:s.map(c=>[...c.pokedDeep])},deepProps:{this:[...t].map(c=>c.split(".")),args:s.map(c=>[...c.pokedDeep].map(l=>l.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,n){let t=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:c,enumerable:l,reflect:u,attr:p,nullable:x,parser:C,nullParser:b,get:h,is:f,diff:d,props:m}=t;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let g=ae(h.bind(n),n,()=>r);r??=g.defaultValue,m=new Set([...g.props.this,...g.props.args[0]])}if(!c)if(r==null)c="string";else{let g=typeof r;c=g==="number"?Number.isInteger(r)?"integer":"float":g}return l??=i[0]!=="_",x??=c==="boolean"?!1:a==null,x||(a??=Oe(c),r??=a),u??=l?c!=="object":p?"write":!1,p??=u?B(i):null,C??=Xe(c),b||(x?b=ze:b=a===null?()=>Oe(c):()=>a),f??=c==="object"||c==="proxy"?(g,S)=>!Me(g,S):c==="array"?()=>!1:Object.is,d===void 0&&(d=c==="object"?(g,S)=>Ae(g,S):null),{...t,type:c,is:f,diff:d,attr:p,reflect:u,readonly:o,enumerable:l,value:r,parser:C,nullParser:b,key:i,props:m,watchers:s}}function V(i,e,n){var r,o;i.get;let t=n==null?i.nullParser.call(this,n):i.parser.call(this,n),s=t;if(e==null){if(t==null)return!1}else if(t!=null){if(i.diff){if(s=i.diff.call(this,e,t),s==null)return!1}else if(i.is.call(this,e,t))return!1}return i.values?i.values.set(this,t):i.values=new WeakMap([[this,t]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,t,s),(o=i.changedCallback)==null||o.call(this,e,t,s),!0}function ce(i,e,n){let t=Ye(e,n,i);function s(h){if(t.type!=="proxy"||h==null||typeof h!="object")return h;let f=z.get(h);if(f&&f.has(this))return f.get(this);let d=this;return je(h,g=>{var P,j,T;let S=((P=t.values)==null?void 0:P.get(d))??h;(j=t.propChangedCallback)==null||j.call(d,t.key,S,S,g),(T=t.changedCallback)==null||T.call(d,S,S,g)},[],d,null)}function r(){var h;return(h=t.values)!=null&&h.has(this)?t.values.get(this):t.value}function o(){var f;if((f=t.values)!=null&&f.has(this))return t.values.get(this);let h=s.call(this,t.value);return h!==t.value&&(t.values?t.values.set(this,h):t.values=new WeakMap([[this,h]])),h}function a(h){var d;if(i===this&&((d=this==null?void 0:this.constructor)==null?void 0:d.prototype)===this)return;let f=this[e];V.call(this,t,f,h)}function c(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let f=this[e],d=s.call(this,h);V.call(this,t,f,d)}function l(){var d,m;let h=(d=t.computedValues)==null?void 0:d.get(this),f=this[e];(m=t.needsSelfInvalidation)==null||m.delete(this),V.call(this,t,h,f)}if(t.props)for(let h of t.props)t.watchers.push([h,l]);function u(){let h=t.get.call(this,this,r.bind(this));return(t.computedValues??=new WeakMap).set(this,h),h}function p(){let h=t.get.call(this,this,o.bind(this)),f=s.call(this,h);return(t.computedValues??=new WeakMap).set(this,f),f}function x(h){t.needsSelfInvalidation?t.needsSelfInvalidation.add(this):t.needsSelfInvalidation=new WeakSet([this]);let f=this[e];t.set.call(this,h,a.bind(this));let d=this[e];t.needsSelfInvalidation.has(this)&&(t.needsSelfInvalidation.delete(this),V.call(this,t,f,d))}function C(h){t.needsSelfInvalidation?t.needsSelfInvalidation.add(this):t.needsSelfInvalidation=new WeakSet([this]);let f=this[e];t.set.call(this,h,c.bind(this));let d=this[e];t.needsSelfInvalidation.has(this)&&(t.needsSelfInvalidation.delete(this),V.call(this,t,f,d))}let b={enumerable:t.enumerable,configurable:!0,get:t.get?t.type==="proxy"?p:u:t.type==="proxy"?o:r,set:t.set?t.type==="proxy"?C:x:t.type==="proxy"?c:a};return Object.defineProperty(i,e,b),t}var Te=new Set;function q(i="mdw_",e=4){let n;for(;Te.has(n=Math.random().toString(36).slice(2,e+2)););return Te.add(n),`${i}${n}`}var le,Fe,Re;function W(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Fe??=le.createDocumentFragment(),Fe.cloneNode())}var Y=new Map;function ue(i){let e=`#${q()}`;return Y.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let n,t=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=q();return n??=new Map,n.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...t);if(n){let o=W(s);for(let[a,c]of n)o.getElementById(a).replaceWith(c);return o}let r;return he.has(s)?r=he.get(s):(r=W(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:n,attrName:t}=this,s=i[n];switch(e){case void 0:case null:case!1:return s.removeAttribute(t),!1;case!0:return s.setAttribute(t,""),"";default:return s.setAttribute(t,e),e}}function Je({nodeStates:i,comments:e,nodes:n},t){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(t!=null&&t!==!1)){if(a)return;let p=e[s];p||(p=R(),e[s]=p),n[r].replaceWith(p),i[r]|=1;return}let l=n[r],u=o&2;if(t instanceof Node)t.nodeType===11||l!==t&&(l.replaceWith(t),n[r]=t),i[r]|=2;else if(typeof t!="object")if(u){let p=new Text(t);l.replaceWith(p),n[r]=p,i[r]&=-3}else l.data=t;a&&(e[s].replaceWith(l),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:n},t){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=t!=null&&t!==!1;if(a===!o)return;let c=e[r],l=n[s];l||(l=R(),n[s]=l),a?(l.replaceWith(c),i[r]&=-2):(c.replaceWith(l),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:n}){let{commentIndex:t,nodeIndex:s}=this,r=R();i[t]=r,e[s]|=1,n[s].replaceWith(r)}function fe(i,...e){let[{caches:n,searchStates:t}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,c=n[s],l=t[r];if(l&1)return{value:c,dirty:(l&2)===2};t[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&c!==void 0)return t[r]&=-3,{value:c,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||c===u)return{value:u,dirty:!1}}return n[s]=u,t[r]|=2,{value:u,dirty:!0}}function Be({options:{context:i,store:e,injections:n}},t,s){return this.expression.call(i,e??s,n)}function nt(i,e){return e[this.prop]}function st(i,e,n){let t=e;for(let s of this.deepProp){if(t==null)return t;if(!(s in t))return;t=t[s]}return t}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function $(i,e){if(!e)return;let n=e,t;for(t of i)if(typeof n=="object"){if(n===null)return null;if(!(t in n))return;n=n[t]}else return n[t];return n}function ot(i,e){let n=e;for(let t of i.split("."))if(!t||(n=n[t],n==null))return null;return n===e?null:n}var We=new Map,D=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=W(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[t,s]of We)if(t.length===e.length&&e.every((r,o)=>r===t[o]))return s;let n=new i(...e);return We.set(e,n),n}append(...e){for(let n of e)typeof n=="string"?this.append(W(n.trim())):n instanceof i?this.append(...n):n instanceof DocumentFragment?this.template.append(n):(n instanceof CSSStyleSheet||n instanceof HTMLStyleElement)&&this.styles.push(n);return this}addCompositionEventListener(e){let n=e.tag??"",t=this.events??=new Map;return t.has(n)?t.get(n).push(e):t.set(n,[e]),this}#s(e,n,t){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=$(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),n.addEventListener(r.type,t?o.bind(t):o,r)}}render(e,n,t={}){this.interpolated||this.interpolate({defaults:n??e,...t});let s=this.cloneable.cloneNode(!0),r=t.shadowRoot,o=r??t.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:t},{nodes:c,refs:l,searchStates:u,caches:p}=a;for(let{tag:C,textNodes:b}of this.nodesToBind){let h;if(C===""){if(!b.length)continue;l.push(null),c.push(null),h=s.firstChild}else{let d=s.getElementById(C);if(l.push(d),c.push(d),this.#s(C,d,t.context),!b.length)continue;h=d.firstChild}let f=0;for(let d of b){for(;d!==f;)h=h.nextSibling,f++;c.push(h)}}this.#s("",t.context),this.#s(i.shadowRootTag,t.context.shadowRoot,t.context);for(let C of this.postInitActions)C.invocation(a);let x=(C,b)=>{var f;if(!C)return;let h=!1;for(let d of this.props){if(!((f=this.actionsByPropsUsed)!=null&&f.has(d))||!(d in C))continue;let m=this.actionsByPropsUsed.get(d);for(let g of m){h=!0;let{dirty:S,value:P}=fe(g.search,a,C,b);S&&g.invocation(a,P,C,b)}}h&&u.fill(0)};return r?(t.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):t.context??=o,e!==this.interpolateOptions.defaults&&x(e,n),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(C,b,h)=>{var g,S;if(!((g=this.actionsByPropsUsed)!=null&&g.has(C)))return;let f=!1;if((S=this.searchByQuery)!=null&&S.has(C)){f=!0;let P=this.searchByQuery.get(C);if(p[P.cacheIndex]===b)return;p[P.cacheIndex]=b,u[P.searchIndex]=3}let d,m=this.actionsByPropsUsed.get(C);for(let P of m)if(P.search.query===C)P.invocation(a,b);else{d??={[C]:b},h??=d,f=!0;let j=fe(P.search,a,d,h);j.dirty&&P.invocation(a,j.value,d,h)}f&&u.fill(0)},x.state=a,x}#n(e,n,t,s){var j,T;let{nodeValue:r,nodeName:o,nodeType:a}=e,c,l;if(a===Node.ATTRIBUTE_NODE?c=e:l=e,s==null){if(!r)return;let N=r.trim();if(!N)return;if(c||(n==null?void 0:n.tagName)==="STYLE"){if(N[0]!=="{")return;let{length:w}=N;if(N[w-1]!=="}")return;s=N.slice(1,-1)}else{let w=N.split(it);if(w.length<3)return;if(w.length===3&&!w[0]&&!w[2])s=w[1];else{for(let[y,_]of w.entries())if(y%2){let I=pe();l.before(I),this.#n(I,n,t,_)}else _&&l.before(_);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let C,b;if(l){n!==l.parentElement&&(n=l.parentElement),b=0;let N=l;for(;N=N.previousSibling;)b++}else if(n!==c.ownerElement&&(n=c.ownerElement),o.startsWith("on")){let N=o.indexOf("-");if(N===-1)return;C=N===2}if(C){n.removeAttribute(o);let N=this.#t(n),w=o.slice(3),[,y,_]=w.match(/^([*1~]+)?(.*)$/),I,A,v=[];if(s.startsWith("#"))I=Y.get(s).fn;else{let O=s.split(".");O.length===1?(A=s,v=[]):(A=O[0],v=O)}this.addCompositionEventListener({tag:N,type:_,handleEvent:I,prop:A,deepProp:v,once:y==null?void 0:y.includes("1"),passive:y==null?void 0:y.includes("~"),capture:y==null?void 0:y.includes("*")});return}let h;if((j=this.searchByQuery)!=null&&j.has(u))h=this.searchByQuery.get(u);else{let N=s,w=N!==u,y;if(w&&((T=this.searchByQuery)!=null&&T.has(N)))y=this.searchByQuery.get(N);else{let _,I,A,v,O,L,M,k;if(s.startsWith("#")){if(k=Y.get(s),!k)return;_=k.fn,M=Be,k.props?(I=k.props,A=k.deepProps,v=k.defaultValue??null):v=k.fn}else v=null,t!=null&&t.defaults&&(v=$(s.split("."),t.defaults)??null),v==null&&(t!=null&&t.injections)&&(v=ot(s,t.injections));if(!I)if(typeof v=="function"){let E=ae.call(this,v,t==null?void 0:t.defaults,t==null?void 0:t.injections),F=new Set([...E.props.this,...E.props.args[0],...E.props.args[1]]),H=new Set([...E.deepPropStrings.this,...E.deepPropStrings.args[0]]);_=v,v=E.defaultValue,I=[...F],A=[...H].map(De=>De.split(".")),M=Be}else{let E=s.split(".");E.length===1?(O=s,I=[O],M=nt):(I=[E[0]],L=E,A=[E],M=st)}k&&(k.defaultValue=v,k.props=I,k.deepProps=A),y={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:N,defaultValue:v,subSearch:null,prop:O,propsUsed:I,deepProp:L,deepPropsUsed:A,invocation:M,expression:_},this.addSearch(y)}w?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:y,negate:p,doubleNegate:x,prop:y.prop,deepProp:y.deepProp,propsUsed:y.propsUsed,deepPropsUsed:y.deepPropsUsed,defaultValue:x?!!y.defaultValue:p?!y.defaultValue:y.defaultValue,invocation(_){return this.doubleNegate?!!_:this.negate?!_:_}},this.addSearch(h)):h=y}let f,d=null,m=h.defaultValue;l?d=b:o==="mdw-if"?(f=this.#t(n),n.removeAttribute(o),m=m!=null&&m!==!1):(d=o,o==="id"||m==null||m===!1?n.removeAttribute(o):n.setAttribute(o,m===!0?"":m)),f??=this.#t(n);let g=this._interpolationState.nodeEntry;(!g||g.tag!==f)&&(g={tag:f,textNodes:[]},this._interpolationState.nodeEntry=g,this.nodesToBind.push(g),this._interpolationState.nodeIndex++);let S;if(l)switch(g.textNodes.push(b),this._interpolationState.nodeIndex++,S={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":l.data=m;break;case"number":l.data=`${m}`;break;default:l.data="";break}else d?S={nodeIndex:this._interpolationState.nodeIndex,attrName:d,defaultValue:m,invocation:Ze,search:h}:(S={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...S,invocation:tt}));this.addAction(S),(this.tagsWithBindings??=new Set).add(f)}#t(e){if(!e)return"";let n=e.id;return n?this.allIds.includes(n)||this.allIds.push(n):(n=q(),(this.temporaryIds??=new Set).add(n),this.allIds.push(n),e.id=n),n}#e(e,n){let t=e.getAttribute("mdw-for"),s=t==null?void 0:t.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,c]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let l=e.ownerDocument.createElement("template");e.replaceWith(l);let u=this.#t(l),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let C={...n.injections,[a]:null,index:null},b=c.split("."),h=b.length>1?b:null,f=h?b[0]:c,d=[f],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:d,deepPropsUsed:h?[h]:[[f]],defaultValue:{},invocation:null},g={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:C,invocation(P,j,T,N){let w=P.adapters[this.adapterIndex];if(!w){let M=P.nodes[this.nodeIndex],k=R();if(P.comments[this.commentIndex])throw new Error("Comment already exists at index");P.comments[this.commentIndex]=k,M.replaceWith(k);let E=x.props.filter(F=>F!==a&&F!==f);w=new U({anchorNode:k,composition:x,renderOptions:{target:null,context:P.options.context,store:P.options.store,injections:this.injections},parentProps:E}),P.adapters[this.adapterIndex]=w}let y=P.options.injections??this.injections,_=N??P.options.store,I=h?$(h,_):_[f];if(I===void 0&&h&&y&&(I=$(h,y)),!I||I.length===0){w.removeEntries();return}let A=h?$(h,T):T[f],v=x.props.some(M=>M!==a&&M!==f&&M in T);if(A===void 0&&!v)return;let O={...T};w.startBatch();let L;if(!v&&!(L=Array.isArray(A))){let M=L?A.entries():Object.entries(A);for(let[k,E]of M){if(k==="length"||E===null)continue;let F=+k,H=I[F];O[a]=E,y[a]=H,y.index=F,w.renderOptions.injections=y,w.renderData(F,O,_,H,E)}}else{A||delete O[a];for(let[M,k]of I.entries()){let E;if(A){if(!v&&!(M in A)||(E=A[M],E===null))continue;O[a]=E}y[a]=k,y.index=M,w.renderOptions.injections=y,w.renderData(M,O,_,k,E)}}w.stopBatch(),w.removeEntries(I.length)}};return x.interpolate({defaults:n.defaults,injections:C}),d.push(...x.props),this.addSearch(m),this.addAction(g),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let t=document.createTreeWalker(this.cloneable,5),s=t.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=t.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=t.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=t.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let c of[...o.attributes].reverse())c.nodeName!=="id"&&this.#n(c,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=t.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=t.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...ge(this.styles)]:(this.stylesFragment=W(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let n=this.actionsByPropsUsed??=new Map;for(let t of e.search.propsUsed)n.has(t)?n.get(t).push(e):n.set(t,[e]);return e}};function Tt(i,e){return(n,t,s)=>{t==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,t)}}var Z=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new D}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,n){if(!this.hasOwnProperty(e)){this[e]=[...this[e],n];return}this[e].push(n)}static _removeCallback(e,n){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(t=>t!==n)}static _removeFromCallbackMap(e,n,t){if(!e.has(n))return;if(!t){e.delete(n);return}let s=e.get(n).filter(r=>r!==t);s.length===0?e.delete(n):e.set(n,s)}static append(...e){return this._onComposeCallbacks.push(({composition:n})=>{n.append(...e)}),this._addCallback("_onComposeCallbacks",(n=>{let{composition:t}=n;t.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...n){return this._addCallback("_onComposeCallbacks",(t=>{let{composition:s}=t;typeof e=="string"||Array.isArray(e)?s.append(xe(e,...n)):s.append(e,...n)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...n){return this._addCallback("_onComposeCallbacks",(t=>{let{composition:s}=t;s.append(de(e,...n))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,n){return this.set(e,{...n,writable:!1})}static set(e,n){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([t,s])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,value:s,writable:!0,...n}])),...Object.getOwnPropertySymbols(e).map(t=>[t,{enumerable:!1,configurable:!0,value:e[t],writable:!0,...n}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,n])=>[e,n.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,n])=>[e,n.slice()]))),this._attributeChangedCallbacks}static prop(e,n){let t=ce(this.prototype,e,n),{changedCallback:s,attr:r,reflect:o,watchers:a}=t;return s&&a.push([e,s]),t.changedCallback=function(l,u,p){this.#l.call(this,e,l,u,p)},this.propList.set(e,t),r&&(o===!0||o==="read")&&(t.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,t),this.onPropChanged(a),this}static setPrototype(e,n){return this.prop(e,n),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([n,t])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,...typeof t=="function"?{get:t}:t}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:n,attr:t,reflect:s}=this.propList.get(e);if(n.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of n){let c=r.indexOf(a);c!==-1&&r.splice(c,1)}}t&&(s===!0||s==="read")&&this.attrList.delete(t),this.propList.delete(e)}return this}static observe(e){for(let[n,t]of Object.entries(e??{})){let s=typeof t=="function"?{reflect:!1,get:t}:t;this.prop(n,s)}return this}static defineStatic(e){for(let[n,t]of Object.entries(e??{}))ce(this,n,{reflect:!1,...typeof t=="function"?{get:t}:typeof t=="string"?{type:t}:t});return this}static events(e,n){return this.on({composed({composition:t}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),c,l=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(c=r,l=[]):(c=u[0],l=u)}t.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:c,deepProp:l}:r,...n})}}}),this}static childEvents(e,n){for(let[t,s]of Object.entries(e))this.events(s,{tag:B(t),...n});return this}static rootEvents(e,n){return this.events(e,{tag:D.shadowRootTag,...n})}static on(e,n){let t=typeof e=="string"?{[e]:n}:e;for(let[s,r]of Object.entries(t)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,n){let t=typeof e=="string"?{[e]:n}:e;for(let[s,r]of Object.entries(t)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:t}=this;for(let[s,r]of n)this._removeFromCallbackMap(t,s,r);return this}static offAttributeChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:t}=this;for(let[s,r]of n)this._removeFromCallbackMap(t,s,r);return this}static onPropChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:t}=this;for(let[s,r]of n)t.has(s)?t.get(s).push(r):t.set(s,[r]);return this}static onAttributeChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:t}=this;for(let[s,r]of n)t.has(s)?t.get(s).push(r):t.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let n of this.static._onConstructedCallbacks)n.call(this,this.callbackArguments)}propChangedCallback(e,n,t,s=t){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,n,t,s,this)}attributeChangedCallback(e,n,t){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,n,t,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,n,t);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===t))return;let c=this[o.key],l=t===null?o.nullParser(t):o.type==="boolean"?!0:o.parser(t);l!==c&&(a?(a.stringValue=t,a.parsedValue=l):this.attributeCache.set(e,{stringValue:t,parsedValue:l}),this[o.key]=l)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,n,t,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let c,l=!1,{attributeCache:u}=this;if(u.has(a)?(c=u.get(a),l=c.parsedValue!==t):(c={},u.set(a,c),l=!0),l){let p=ke(t);c.parsedValue=t,c.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,n,t,s)}get static(){return this.constructor}patch(e){this.#r=!0,Ie(this,e,"object");for(let[n,t,s]of this.#i)n in e||this.render.byProp(n,t,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,n)=>{let t=this.composition,s;if(!t.interpolated){if(this.#t.has(n)&&(s=this.#t.get(n).deref(),s))return s;let a=B(n);return s=t.template.getElementById(a),s?(this.#t.set(n,new WeakRef(s)),s):null}if(this.#n.has(n)&&(s=this.#n.get(n).deref(),s))return s;let r=B(n),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(n,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};Z.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,Z as default};
2
2
  //# sourceMappingURL=CustomElement.min.js.map