@wcstack/state 3.2.0 → 3.4.0
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.ja.md +140 -83
- package/README.md +141 -84
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +74 -8
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.d.ts +28 -5
- package/dist/manifest.esm.js +253 -246
- package/dist/parser.d.ts +16 -2
- package/dist/parser.esm.js +223 -50
- package/dist/split/chunks/binder.js +1 -1
- package/dist/split/chunks/binder.js.map +1 -1
- package/dist/split/chunks/checkDependency.js +1 -1
- package/dist/split/chunks/checkDependency.js.map +1 -1
- package/dist/split/chunks/declarationAliases.js +1 -1
- package/dist/split/chunks/declarationAliases.js.map +1 -1
- package/dist/split/chunks/declarationHooks.js +2 -0
- package/dist/split/chunks/declarationHooks.js.map +1 -0
- package/dist/split/chunks/diagnosticsHooks.js.map +1 -1
- package/dist/split/chunks/featureBridge.js +2 -0
- package/dist/split/chunks/featureBridge.js.map +1 -0
- package/dist/split/chunks/filterRegistry.js +1 -1
- package/dist/split/chunks/filterRegistry.js.map +1 -1
- package/dist/split/chunks/getAllPropertyDescriptors.js +1 -1
- package/dist/split/chunks/getAllPropertyDescriptors.js.map +1 -1
- package/dist/split/chunks/lifecycleHooks.js +1 -1
- package/dist/split/chunks/pathDiagnostics.js +1 -1
- package/dist/split/chunks/pathDiagnostics.js.map +1 -1
- package/dist/split/chunks/registerComponents.js +1 -1
- package/dist/split/chunks/registerComponents.js.map +1 -1
- package/dist/split/chunks/setAll.js +1 -1
- package/dist/split/chunks/setAll.js.map +1 -1
- package/dist/split/chunks/version.js +1 -1
- package/dist/split/core.d.ts +64 -2
- package/dist/split/core.js +1 -1
- package/dist/split/core.js.map +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/devtools.js.map +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/recursion.js.map +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/scopes.js.map +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/ssr.js.map +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/split/features/temporal.js.map +1 -1
- package/dist/wcs-manifest.json +36 -21
- package/package.json +1 -1
- package/dist/split/chunks/mount.js +0 -2
- package/dist/split/chunks/mount.js.map +0 -1
- package/dist/split/chunks/watchRuntime.js +0 -2
- package/dist/split/chunks/watchRuntime.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,r as t,i as n}from"./filterRegistry.js";import{O as o,P as s,D as i,Q as r,g as a,T as l,U as d,X as c,Y as u,Z as f,_ as p,$ as h,a0 as g,a1 as m,a2 as b,p as w,W as y,j as v,a3 as N,a4 as x,w as S,a5 as I,a6 as A,a7 as T,I as $,F as k,V as P}from"./pathDiagnostics.js";import{r as M,L as E,d as C}from"./errorGuidance.js";const _=Symbol.for("wcstack.binder");const R=Symbol.for("wcstack.binder.pending"),O=Symbol.for("wcstack.binder.taken");function B(){const e=function(){const e=globalThis[_];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;const t=function(){const e=globalThis;let t=e[R];return void 0===t&&(t=[],e[R]=t),t}();if(0===t.length)return;const n=t.splice(0,t.length),o=function(){const e=globalThis;let t=e[O];return void 0===t&&(t=new WeakSet,e[O]=t),t}();for(const t of n)o.add(t),e.bind(t)}const L=/\{\{\s*(.+?)\s*\}\}/g,W=new Set(["SCRIPT","STYLE"]);function D(t){if(!e.enableMustache)return;!function(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(;t.nextNode();)n.push(t.currentNode);for(const e of n)e.parentElement&&W.has(e.parentElement.tagName)||F(e)}(t);const n=Array.from(t.querySelectorAll("template"));for(const e of n)if(e.namespaceURI===o){const t=document.createElement("template"),n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){const o=n[e];t.content.appendChild(o)}for(const n of e.attributes)t.setAttribute(n.name,n.value);e.replaceWith(t),D(t.content)}else D(e.content)}function F(e){const t=e.data;if(L.lastIndex=0,!L.test(t))return;L.lastIndex=0;const n=document.createDocumentFragment();let o,s=0;for(;null!==(o=L.exec(t));){o.index>s&&n.appendChild(document.createTextNode(t.slice(s,o.index)));const e=o[1];n.appendChild(document.createComment(`@@: ${e}`)),s=o.index+o[0].length}s<t.length&&n.appendChild(document.createTextNode(t.slice(s))),e.parentNode.replaceChild(n,e)}const j=new Set(["if","elseif","else","for"]);function q(e,t,n){const o=-1===t?e.length:t;let s=0;for(;s<o&&/\s/.test(e[s]);)s++;const i=-1===n?0:n;let r=e.length;for(;r>i&&/\s/.test(e[r-1]);)r--;return e.slice(s,r)}const z=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function V(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:z.test(e)?Number(e):e)}function H(e){const t=[],n=[];let o="",s=null,i=!1,r=-1,a=-1;const l=()=>{const e=q(o,r,a);t.push(e),n.push(V(e,i)),o="",i=!1,r=-1,a=-1};for(let t=0;t<e.length;t++){const n=e[t];s?n===s?s=null:(-1===r&&(r=o.length),o+=n,a=o.length):'"'===n||"'"===n?(s=n,i=!0):","===n?l():o+=n}null!==s&&M(`[wcs/binding-syntax] unterminated ${s} quote in the filter arguments "(${e})". Close the quote.${E}`);const d=q(o,r,a);return(d||i)&&(t.push(d),n.push(V(d,i))),{args:t,literals:n}}function U(e,t){return e.map(t=>{const n=t.indexOf("("),o=t.lastIndexOf(")");-1!==n&&-1===o&&M(`Invalid filter format: missing closing parenthesis in "${t}"`),-1!==o&&-1===n&&M(`Invalid filter format: missing opening parenthesis in "${t}"`);const s=(-1===n?t:t.substring(0,n)).trim();if(0===s.length&&M(`[wcs/binding-syntax] an empty filter in "${e.join("|")}" — remove the extra "|" or name the filter.${E}`),-1===n)return{filterName:s,args:[],literals:[]};return{filterName:s,...H(t.substring(n+1,o))}})}const G=e=>e.trim(),K=e=>"'"===e||'"'===e;function X(e,t){let n=null;for(let o=0;o<e.length;o++){const s=e[o];if(null!==n)s===n&&(n=null);else if(K(s))n=s;else if(s===t)return o}return-1}function Q(e,t){const n=[];let o=null,s=0;for(let i=0;i<e.length;i++){const r=e[i];null!==o?r===o&&(o=null):K(r)?o=r:r===t&&(n.push(e.slice(s,i)),s=i+1)}return n.push(e.slice(s)),n}const J=new Map;function Y(e){const t=X(e,r);let n="",o=[],a="",l=[];-1!==t?(n=e.slice(0,t).trim(),a=e.slice(t+1).trim(),J.has(a)?l=J.get(a):(o=Q(a,r).map(G),l=U(o),J.set(a,l))):n=e.trim();const d=n.split(s).map(G);d.length>2&&M(`[wcs/binding-syntax] "${n}": a binding takes one modifier list after a single "${s}" — write "${d[0]}${s}${d.slice(1).join(",")}".${E}`);const[c,u]=d,f=c.split(i).map(G);return{propName:c,propSegments:f,propModifiers:u?u.split(",").map(G):[],inFilters:l}}const Z=new Map;function ee(e){const t=X(e,r);let n="",o=[],s="",i=[];-1!==t?(n=e.slice(0,t).trim(),s=e.slice(t+1).trim(),Z.has(s)?i=Z.get(s):(o=Q(s,r).map(G),i=U(o),Z.set(s,i))):n=e.trim(),-1!==n.indexOf("@")&&M(`"${n}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`);return{statePathName:n,statePathInfo:a(n),outFilters:i}}const te=new Set([d,"if","elseif","for",c]),ne=new Set([p,h,g,m,u]);function oe(e){const[...t]=function(e){return Q(e,b)}(e).map(G).filter(e=>e.length>0),n=t.map(e=>{const t=e.indexOf(l);-1===t&&M(`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`);const n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),p=n.split(s)[0].split(r)[0].trim();if(p!==n&&te.has(p)&&M(`[wcs/binding-syntax] "${e}": "${p}" takes no modifiers or filters on its left side — write "${p}:".${E}`),n===d){o.length>0&&M(`[wcs/binding-syntax] "${e}": "else" takes no value — write "else:".${E}`);const t=a("#else");return{propName:d,propSegments:[d],propModifiers:[],statePathName:"#else",statePathInfo:t,inFilters:[],outFilters:[],bindingType:"else"}}if(n===c){const t=ee(o);return t.outFilters.length>0&&M(`Invalid spread binding "${e}": filters are not allowed on spread targets.`),0===t.statePathName.length&&M(`Invalid spread binding "${e}": spread target path is required.`),{propName:c,propSegments:[c],propModifiers:[],inFilters:[],...t,bindingType:"spread"}}if("if"===n||"elseif"===n||"for"===n){return{propName:n,propSegments:[n],propModifiers:[],inFilters:[],...ee(o),bindingType:n}}if("radio"===p||"checkbox"===p){const e=ee(o);return{...Y(n),...e,bindingType:p}}{const e=ee(o),t=Y(n);if(""===t.propSegments[0]&&t.propSegments.length>1){const o=t.propSegments.slice(1);return(o.includes("")||ne.has(o[0]))&&M(`[wcs/binding-syntax] "${n}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (${[...ne].join(", ")}).${E}`),{...t,propName:o.join(i),propSegments:o,...e,bindingType:"prop"}}return t.propSegments[0]===u||t.propSegments[0].startsWith(f)?{...t,...e,bindingType:"event"}:{...t,...e,bindingType:"prop"}}});if(n.length>1){n.some(e=>j.has(e.bindingType))&&M(`[wcs/template-syntax] Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding. Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).${E}`)}return n}const se=new WeakMap,ie=new Set([e.commentTextPrefix,e.commentForPrefix,e.commentIfPrefix,e.commentElseIfPrefix,e.commentElsePrefix]),re=new RegExp("^\\s*@@\\s*(.*?)\\s*:\\s*(.+?)\\s*$");function ae(t){const n=se.get(t);if("string"==typeof n)return n;if(t.nodeType!==Node.COMMENT_NODE)return null;const o=t.data.trim(),s=re.exec(o);if(null===s)return null;const i=s[1]||e.commentTextPrefix;return ie.has(i)?(se.set(t,s[2]),s[2]):null}function le(e){return{propName:"textContent",propSegments:["textContent"],propModifiers:[],inFilters:[],...ee(e),bindingType:"text"}}const de=new WeakMap,ce=new WeakSet;let ue=0;async function fe(e){const t=function(e){let t,n=de.get(e)||null;if(null!==n)return n;const o=new Promise(e=>{t=e});return n={id:++ue,promise:o,resolve:t},de.set(e,n),ce.has(e)&&n.resolve(),n}(e);await t.promise}function pe(e){const t=de.get(e);void 0===t?ce.add(e):t.resolve()}const he=new WeakMap;function ge(e){const t=he.get(e);if(void 0!==t)return t;let n=null;try{if(e.nodeType!==Node.ELEMENT_NODE)return n;const t=e,o=t.tagName.toLowerCase();if(o.includes("-"))return n=o;if(t.hasAttribute("is")){const e=t.getAttribute("is");if(e.includes("-"))return n=e}return n}finally{he.set(e,n)}}function me(e){if("object"!=typeof e||null===e)return null;const t=e;return"function"!=typeof t.get||"function"!=typeof t.whenDefined?null:t}function be(e=null){if(null!=e){const{customElementRegistry:t,customElements:n}=e;if(null===t)return null;if(void 0!==t)return me(t);if(void 0!==n)return me(n)}return me(globalThis.customElements)}function we(e,t){e.upgrade?.(t)}function ye(e){try{if(null===e||"object"!=typeof e&&"function"!=typeof e)return null;const t=e,n=t.addEventListener,o=t.removeEventListener,s=t.constructor?.wcBindable;if("function"!=typeof n||"function"!=typeof o)return null;if("wc-bindable"!==s?.protocol)return null;if(!Number.isInteger(s.version)||s.version<1)return null;const i=Se(s.properties,ve);if(null===i)return null;const r=void 0===s.inputs?new Map:Se(s.inputs,Ne);if(null===r)return null;const a=void 0===s.commands?new Map:Se(s.commands,xe);return null===a?null:{target:e,liveDeclaration:s,knownProperties:i,declaredInputs:r,declaredCommands:a}}catch{return null}}function ve(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&("string"==typeof t.event&&0!==t.event.length&&(void 0===t.getter||"function"==typeof t.getter))}function Ne(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&(void 0===t.attribute||"string"==typeof t.attribute)}function xe(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&(void 0===t.async||"boolean"==typeof t.async)}function Se(e,t){if(!Array.isArray(e))return null;const n=new Map;for(const o of e){if(!t(o)||n.has(o.name))return null;n.set(o.name,o)}return n}function Ie(e,t){const n="."===t?`.${e}`:`${t}.${e}`;return{propName:e,propSegments:[e],propModifiers:[],statePathName:n,statePathInfo:a(n),inFilters:[],outFilters:[],bindingType:"prop"}}function Ae(e){switch(e.bindingType){case"prop":case"event":case"radio":case"checkbox":return`${e.bindingType}::${e.propName}`;default:return null}}function Te(t,n,o={}){const s=o.allowDeferred??!0;if(!n.some(e=>"spread"===e.bindingType))return n;const i=[],r=new WeakSet;for(const e of n){if("spread"!==e.bindingType){i.push(e);continue}t.nodeType!==Node.ELEMENT_NODE&&M("Spread binding requires an element node.");const n=t,o=ge(n);null===o&&M(`Spread binding "${e.statePathName}" requires a custom element with wcBindable, but <${n.tagName.toLowerCase()}> is not a custom element.`);const a=be(n);null===a&&M(`CustomElementRegistry is unavailable for <${o}>.`);if(void 0===a.get(o)){s||M(`Spread binding "${e.statePathName}" requires <${o}> to be registered. Define the custom element before initializing this binding.`),i.push(e);continue}we(a,n);const l=ye(n);null===l&&M(`Spread binding "${e.statePathName}" requires <${o}> to expose a valid wcBindable declaration.`);const d=e.statePathName,c=new Set;for(const e of l.knownProperties.keys()){if(c.has(e))continue;c.add(e);const t=Ie(e,d);r.add(t),i.push(t)}for(const e of l.declaredInputs.keys()){if(c.has(e))continue;c.add(e);const t=Ie(e,d);r.add(t),i.push(t)}}const a=new Map;for(let e=0;e<i.length;e++){const t=Ae(i[e]);null!==t&&a.set(t,e)}const l=[];for(let n=0;n<i.length;n++){const o=Ae(i[n]);if(null!==o){if(a.get(o)===n)l.push(i[n]);else if(e.debug&&r.has(i[n])){const e=i[a.get(o)],s=t.nodeType===Node.ELEMENT_NODE?`<${t.tagName.toLowerCase()}>`:"node";console.debug(`[@wcstack/state] spread: prop "${i[n].propName}" of ${s} overridden by explicit binding (statePath: "${e.statePathName}").`)}}else l.push(i[n])}return l}function $e(e,t){let n=e;for(let e=0;e<t.length;e++){let o=t[e];for(n=n.firstChild;null!==n&&o>0;)n=n.nextSibling,o--;if(null===n)break}return n}function ke(e,n){if(0===e.length)return e;const o=[];for(let s=0;s<e.length;s++){const i=e[s];o.push({filterName:i.filterName,args:i.args,filterFn:t(i.filterName,i.args,n,i.literals??i.args)})}return o}const Pe=new WeakMap;function Me(e){return Pe.get(e)||null}function Ee(t){if(!t.hasAttribute("bind-component"))return!1;const n=t.parentNode;return n instanceof Element&&n.hasAttribute(e.bindAttributeName)}function Ce(t){const n=[],o=t.querySelectorAll(`${e.tagNames.state}[bind-component]`);for(const e of o){if(!Ee(e))continue;const o=e.parentNode;o!==t&&n.push(o)}return n}function _e(e,t){for(let n=0;n<t.length;n++){const o=t[n];if(o!==e&&o.contains(e))return!0}return!1}function Re(t){const n=[],o=Ce(t),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,{acceptNode(t){if(t.nodeType===Node.ELEMENT_NODE){return t.hasAttribute(e.bindAttributeName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}return null!==ae(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();){const e=s.currentNode;o.length>0&&_e(e,o)||n.push(e)}return n}const Oe=new WeakSet;function Be(e,t,n,o){const s=Te(e,t,{allowDeferred:n.allowDeferred});if(s.some(e=>"spread"===e.bindingType)){const n=e.nodeType===Node.ELEMENT_NODE?ge(e):null;return null===n&&M("Spread binding deferred but element is not a custom element."),{bindings:[],deferred:{node:e,tagName:n,parseResults:t,transform:o}}}Oe.add(e);const i=function(e,t){const n=[];for(const o of t){const t=ke(o.inFilters,"input"),s=ke(o.outFilters,"output");if("text"!==o.bindingType)n.push({...o,inFilters:t,outFilters:s,node:e,replaceNode:e});else{const i=e.nodeType===Node.TEXT_NODE?e:document.createTextNode("");n.push({...o,inFilters:t,outFilters:s,node:e,replaceNode:i})}}return n}(e,function(e,t){return void 0===t?e:e.map(e=>null!=e.uuid?e:t(e))}(s,o));return function(e,t){Pe.set(e,t)}(e,i),pe(e),{bindings:i,deferred:null}}function Le(e,t){const n=Re(e),o=[],s=[];for(const e of n){if(Oe.has(e))continue;const n=Be(e,ua(e),{allowDeferred:!0},t);null===n.deferred?o.push(...n.bindings):s.push(n.deferred)}return[n,o,s]}function We(e){Oe.add(e)}function De(e){const{node:t,parseResults:n,transform:o}=e;!function(e){Oe.delete(e)}(t);return Be(t,n,{allowDeferred:!1},o).bindings}const Fe=new WeakMap;let je=null;function qe(e){je=e}function ze(e){let t=e;for(;t;){const e=Fe.get(t);if(e)return e;let n=t.parentNode;null===n&&null!==je&&t instanceof ShadowRoot&&(n=je(t)),t=n}return null}function Ve(e,t){null!==t?Fe.set(e,t):Fe.delete(e)}const He=new WeakMap;function Ue(e){return He.get(e)??[]}function Ge(e,t){He.set(e,t)}function Ke(e){return He.has(e)}const Xe=new WeakMap;let Qe=null,Je=0;function Ye(e){return Xe.get(e)??[]}function Ze(e,t){null===Qe?Xe.set(e,t):Qe.set(e,t)}function et(){Je++,null===Qe&&(Qe=new Map)}function tt(){if(0!==Je&&(Je--,!(Je>0||null===Qe))){for(const[e,t]of Qe)Xe.set(e,t);Qe=null}}function nt(e){return(Qe?.has(e)??!1)||Xe.has(e)}const ot=Symbol("$$setLoopContext"),st=Symbol("$$getByAddress"),it=Symbol("$$hasByAddress"),rt=Symbol("$$setByAddress"),at=Symbol("$$connectedCallback"),lt=Symbol("$$disconnectedCallback"),dt=Symbol("$$updatedCallback"),ct=Symbol("$$errorCallback"),ut=new WeakMap,ft=new WeakMap;class pt{absolutePathInfo;listIndex;constructor(e,t){this.absolutePathInfo=e,this.listIndex=t}}function ht(e,t){if(null===t){let t=ft.get(e);return void 0!==t||(t=new pt(e,null),ft.set(e,t)),t}{let n=ut.get(t);void 0===n&&(n=new WeakMap,ut.set(t,n));let o=n.get(e);return void 0!==o||(o=new pt(e,t),n.set(e,o)),o}}const gt=new WeakMap;function mt(e,t){let n=gt.get(e);void 0===n&&(n=new Map,gt.set(e,n));let o=n.get(t);return void 0===o&&(o=Object.freeze(new bt(e,t)),n.set(t,o)),o}class bt{pathInfo;stateElement;constructor(e,t){this.pathInfo=t,this.stateElement=e}}function wt(e,t){return ht(mt(e,t.pathInfo),t.listIndex)}function yt(e,t,n){return ht(mt(e,t),n)}const vt=new WeakMap;function Nt(e,t){null===t?vt.delete(e):vt.set(e,t)}function xt(e){return vt.get(e)||null}const St=new Map;function It(e,t){let n,o;if(0===e.wildcardCount||0===t.wildcardCount)return 0;if(1===e.wildcardCount&&t.wildcardCount>0&&t.wildcardPathSet.has(e.path))return 1;e.id<t.id?(n=e,o=t):(n=t,o=e);const s=`${n.path}\t${o.path}`;let i=St.get(s);if(void 0!==i)return i;return i=n.wildcardPathSet.intersection(o.wildcardPathSet).size,St.set(s,i),i}function At(e,t,n){return t<0||t>=n?null:e.at(t-n)}function Tt(e,t){const n=e.indexes??[];return n.length===t?n:n.slice(n.length-t)}const $t=new WeakMap;function kt(e){const t=ze(e.node);if(null===t)return null;let n=$t.get(t);if(void 0===n)n=new WeakMap,$t.set(t,n);else{const t=n.get(e);if(void 0!==t)return t}let o=null;try{const n=It(t.pathInfo,e.statePathInfo);return n>0&&(o=At(t.listIndex,n-1,t.pathInfo.wildcardCount)),o}finally{n.set(e,o)}}const Pt=new WeakMap;function Mt(e,t){if(null!=t)return t;let n=e.replaceNode.getRootNode();if(!1===e.replaceNode.isConnected){const t=xt(n);null===t?M(`Cannot get absolute state address for disconnected binding: ${e.bindingType} ${e.statePathName} on ${e.node.nodeName}`):n=t}return n}function Et(e,t){let n=null;if(n=Pt.get(e)||null,null!==n)return n;const o=Mt(e,t),s=kt(e),i=Zr(o);return null===i&&M("No state tree found on this root for binding."),n=yt(i,e.statePathInfo,s),Pt.set(e,n),n}function Ct(e){Pt.delete(e)}const _t=new WeakMap;function Rt(e,t){const n=_t.get(e);void 0===n?_t.set(e,t):n instanceof Set?n.add(t):n!==t&&_t.set(e,new Set([n,t])),null!==w&&w({type:"state:binding-added",absoluteAddress:e,binding:t})}function Ot(e,t){const n=_t.get(e);void 0!==n&&(n instanceof Set?n.delete(t):n===t&&_t.delete(e),null!==w&&w({type:"state:binding-removed",absoluteAddress:e,binding:t}))}const Bt=new WeakMap;function Lt(e){const t=_t.get(e);return void 0!==t?t:null!==e.listIndex?Bt.get(e.absolutePathInfo)?.get(e.listIndex):void 0}const Wt=new WeakMap,Dt=new WeakMap;class Ft{pathInfo;listIndex;_parentAddress;constructor(e,t){this.pathInfo=e,this.listIndex=t}get parentAddress(){if(void 0!==this._parentAddress)return this._parentAddress;const e=this.pathInfo.parentPathInfo;if(null===e)return null;let t=null;return t=this.pathInfo.segments[this.pathInfo.segments.length-1]===y?this.listIndex?.parentListIndex??null:this.listIndex,this._parentAddress=jt(e,t)}}function jt(e,t){if(null===t){let t=Dt.get(e);return void 0!==t||(t=new Ft(e,null),Dt.set(e,t)),t}{let n=Wt.get(t);void 0===n&&(n=new WeakMap,Wt.set(t,n));let o=n.get(e);return void 0!==o||(o=new Ft(e,t),n.set(e,o)),o}}const qt=new WeakMap;function zt(e){let t=null;if(t=qt.get(e)||null,null!==t)return t;if(e.statePathInfo.wildcardCount>0){const n=kt(e);null===n&&M(`Cannot resolve state address for binding with wildcard statePathName "${e.statePathName}" because list index is null.`),t=jt(e.statePathInfo,n)}else t=jt(e.statePathInfo,null);return qt.set(e,t),t}function Vt(e){qt.delete(e)}function Ht(){const e=new Map,t=new Map;return{add(n,o){let s=e.get(n);return void 0===s&&(s=new WeakSet,e.set(n,s)),!s.has(o)&&(s.add(o),t.set(n,(t.get(n)??0)+1),!0)},remove(n,o){const s=e.get(n);if(void 0===s||!s.has(o))return!1;s.delete(o);const i=(t.get(n)??1)-1;return i<=0?(e.delete(n),t.delete(n),!0):(t.set(n,i),!1)},has:(t,n)=>e.get(t)?.has(n)??!1,countOf:e=>t.get(e)??0,get keyCount(){return t.size},clear(){e.clear(),t.clear()}}}const Ut=new Map,Gt=Ht();function Kt(e,t){const n=e.inFilters.map(e=>e.filterName+"("+e.args.join(",")+")").join("|");return`${e.statePathName}::${t}::${n}`}function Xt(e){let t="input";for(const n of e.propModifiers)n.startsWith(f)&&(t=n.slice(f.length));return t}function Qt(e){if("checkbox"===e.bindingType&&-1===e.propModifiers.indexOf(v)){const o=Xt(e),s=Kt(e,o);let i=Ut.get(s);return void 0===i&&(t=e.statePathName,n=e.inFilters,i=e=>{const o=e.target;if(null===o)return void console.warn("[@wcstack/state] event.target is null.");if("checkbox"!==o.type)return void console.warn("[@wcstack/state] event.target is not a checkbox input element.");const s=o.checked;let i=o.value;for(const e of n)i=e.filterFn(i);const r=Zr(o.getRootNode());null===r&&M("No state tree found on this root for two-way binding.");const a=ze(o);r.createState("writable",e=>{e[ot](a,()=>{let n=e[t];if(Array.isArray(n))if(s)-1===n.indexOf(i)&&(e[t]=n.concat(i));else{const o=n.indexOf(i);-1!==o&&(e[t]=n.toSpliced(o,1))}else e[t]=s?[i]:[]})})},Ut.set(s,i)),e.node.addEventListener(o,i),Gt.add(s,e),!0}var t,n;return!1}function Jt(e){return("object"==typeof e||"function"==typeof e)&&null!==e&&"function"==typeof e.then}function Yt(e,t){const n=Array.isArray(e)?e:[e];for(const e of n)Jt(e)&&Promise.resolve(e).catch(e=>{console.error(`[wcstack/state] ${t} rejected.`,e)})}class Zt{_name;_subscribers=new Set;constructor(e){this._name=e}get name(){return this._name}get size(){return this._subscribers.size}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}unsubscribe(e){return this._subscribers.delete(e)}emit(...e){const t=[];for(const n of this._subscribers)t.push(n(...e));return t}}class en extends Zt{_stateElement;constructor(e,t){super(e),this._stateElement=t}emit(...e){return null!==w&&w({type:"state:token-emit",kind:"event",tokenName:this.name,args:e,subscriberCount:this.size,stateElement:this._stateElement}),super.emit(...e)}}const tn=new WeakMap;function nn(e,t){let n=tn.get(e);void 0===n&&(n=new Map,tn.set(e,n));let o=n.get(t);return void 0===o&&(o=new en(t,e),n.set(t,o)),o}function on(e){tn.delete(e)}const sn=new WeakMap;function rn(e){if(e.propSegments[0]!==u)return!1;const t=e.node,n=ge(t),o=be(t);if(null!==n&&void 0===o?.get(n))return null===o&&M(`CustomElementRegistry is unavailable for <${n}>.`),!0;if(sn.has(e))return!0;const s=e.propSegments[1];"string"==typeof s&&0!==s.length||M('eventToken binding requires a property name (e.g., "eventToken.error").');const i=function(e){return null===ge(e)?null:ye(e)}(t);null===i&&M(`eventToken binding requires a wc-bindable custom element. <${t.tagName.toLowerCase()}> is not wc-bindable.`);const r=i.knownProperties.get(s);void 0===r&&M(`Property "${s}" is not declared in wcBindable.properties of <${t.tagName.toLowerCase()}>.${C(s,i.knownProperties.keys())}`);const a=r.event,l=e.statePathName,d=e.propModifiers,c=e=>{d.includes(N)&&e.preventDefault(),d.includes(x)&&e.stopPropagation();const n=Zr(t.getRootNode());null===n&&M("No state tree found on this root for eventToken handler."),n.eventTokenNames.has(l)||M(`[wcs/token-undeclared] eventToken "${l}" is not declared in $eventTokens.${C(l,n.eventTokenNames)}${E}`);const o=ze(t);n.createStateAsync("writable",async t=>{Yt(t[ot](o,()=>{const s=null!==o?Tt(o.listIndex,o.pathInfo.wildcardCount):[];return nn(n,l).emit(t,e,...s)}),`$on."${l}"`)})};return t.addEventListener(a,c),sn.set(e,{eventName:a,handler:c}),!0}class an extends Zt{_stateElement;constructor(e,t){super(e),this._stateElement=t}emit(...e){return null!==w&&w({type:"state:token-emit",kind:"command",tokenName:this.name,args:e,subscriberCount:this.size,stateElement:this._stateElement}),super.emit(...e)}}function ln(e){return e instanceof an}const dn=new Map,cn=Ht();function un(e){const t=e.propModifiers.filter(e=>e===N||e===x).sort().join(",");return`${e.statePathName}::${t}`}const fn=(e,t,n)=>o=>{t.includes(N)&&o.preventDefault(),t.includes(x)&&o.stopPropagation();const s=o.target,i=s.getRootNode(),r=Zr(i);null===r&&M("No state tree found on this root for event handler.");const a=ze(s),l=e.startsWith(S+".");r.createStateAsync("writable",async t=>{Yt(t[ot](a,()=>{let d=null!==a?a.pathInfo.wildcardCount:0;if(null!==a){const e=r.addressHooks;if(e){const t=e.handlerScope;for(let e=0;e<t.length;e++)d=t[e](r,s,i,a,d)}}const c=null!==a?Tt(a.listIndex,d):[];if(l){const s=t[st](jt(n,null));return ln(s)||M(`Event binding "${e}" did not resolve to a CommandToken. Declare the name in $commandTokens and reference it as $command.<name>.`),s.emit(o,...c)}const u=t[e];return"function"!=typeof u&&M(`Handler "${e}" is not a function on the state tree.`),Reflect.apply(u,t,[o,...c])}),`"${e}"`)})};function pn(e){if(!e.propName.startsWith(f))return!1;const t=un(e);let n=dn.get(t);void 0===n&&(n=fn(e.statePathName,e.propModifiers,e.statePathInfo),dn.set(t,n));const o=e.propName.slice(2);return e.node.addEventListener(o,n),cn.add(t,e),!0}function hn(e){if(!e.propName.startsWith(f))return!1;const t=un(e),n=dn.get(t);if(void 0===n)return!1;const o=e.propName.slice(2);return e.node.removeEventListener(o,n),0!==cn.countOf(t)&&(cn.remove(t,e)&&dn.delete(t),!0)}const gn=new Map,mn=Ht();function bn(e,t){const n=e.inFilters.map(e=>e.filterName+"("+e.args.join(",")+")").join("|");return`${e.statePathName}::${t}::${n}`}function wn(e){let t="input";for(const n of e.propModifiers)n.startsWith(f)&&(t=n.slice(f.length));return t}function yn(e){if("radio"===e.bindingType&&-1===e.propModifiers.indexOf(v)){const o=wn(e),s=bn(e,o);let i=gn.get(s);return void 0===i&&(t=e.statePathName,n=e.inFilters,i=e=>{const o=e.target;if(null===o)return void console.warn("[@wcstack/state] event.target is null.");if("radio"!==o.type)return void console.warn("[@wcstack/state] event.target is not a radio input element.");if(!1===o.checked)return;let s=o.value;for(const e of n)s=e.filterFn(s);const i=Zr(o.getRootNode());null===i&&M("No state tree found on this root for two-way binding.");const r=ze(o);i.createState("writable",e=>{e[ot](r,()=>{e[t]=s})})},gn.set(s,i)),e.node.addEventListener(o,i),mn.add(s,e),!0}var t,n;return!1}const vn=new Set(["radio","checkbox"]),Nn=new Set(["value","valueAsNumber","valueAsDate"]);function xn(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return!1;const n=e,o=n.tagName.toLowerCase();if("input"===o){const e=(n.getAttribute("type")||"text").toLowerCase();if("button"===e)return!1;if(vn.has(e)&&"checked"===t)return!0;if(Nn.has(t))return!0}if("select"===o&&"value"===t)return!0;if("textarea"===o&&"value"===t)return!0;const s=ge(n);if(null!==s){const e=be(n)?.get(s);void 0===e&&M(`Custom element <${s}> is not defined. Cannot determine if property "${t}" is suitable for two-way binding.`);const o=ye(n);if(o?.knownProperties.has(t))return!0}return!1}let Sn=1,In=1,An=1;const Tn=new WeakMap;function $n(e,t,n){let o=Tn.get(e);void 0===o&&(o=new Map,Tn.set(e,o));const s=function(e,t){return`${t}::${e}`}(t,n);let i=o.get(s);return void 0===i&&(i=Sn++,o.set(s,i)),i}function kn(e,t){return"to-element"===t?2*e:2*e+1}const Pn=new Set;function Mn(e){return{transactionId:In++,originBindingId:e,visitedEdges:Pn,hop:0}}function En(e,t){const n=new Set(e.visitedEdges);return n.add(t),{transactionId:e.transactionId,originBindingId:e.originBindingId,visitedEdges:n,hop:e.hop+1}}let Cn=null;function _n(){return Cn}function Rn(e,t){const n=Cn;Cn=e;try{return t()}finally{Cn=n}}const On=[];let Bn=!1;function Ln(){return!!Bn&&(Bn=!1,!0)}const Wn=new Map,Dn=Ht(),Fn=new WeakMap,jn=e=>e.detail,qn=new WeakMap;function zn(e,t,n,o){const s=e.inFilters.map(e=>e.filterName+"("+e.args.join(",")+")").join("|");return`${e.propName}::${e.statePathName}::${t}::${s}::${n?"g":"n"}::${o?"o":"s"}`}function Vn(e){let t="select"===e.node.tagName.toLowerCase()?"change":"input";const n=ge(e.node);if(null!==n){const o=be(e.node)?.get(n);void 0===o&&M(`Custom element <${n}> is not defined. Cannot determine event name for two-way binding.`);const s=ye(e.node)?.knownProperties.get(e.propName);s&&(t=s.event)}for(const n of e.propModifiers)n.startsWith(f)&&(t=n.slice(f.length));return t}function Hn(e){if(null!==ge(e.node)){const t=ye(e.node)?.knownProperties.get(e.propName);if(t)return t.getter??jn}return null}function Un(e){if(null===ge(e.node))return!1;const t=ye(e.node)?.knownProperties.get(e.propName);return"event"===t?.semantics}const Gn=(t,n,o,s,i)=>r=>{const a=r.target;if(null===a)return void console.warn("[@wcstack/state] event.target is null.");let l;if(null!==s)l=s(r),s!==jn||i||function(e,t,n){const o=e[t];let s=null;if(void 0===n?void 0!==o&&(s=`the event carried no detail (undefined) while element.${t} is ${typeof o}`):null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==o&&"object"==typeof o||(s=`the event's detail is an object with a "${t}" key while element.${t} is ${typeof o}`),null===s)return;let i=qn.get(e);void 0===i&&(i=new Set,qn.set(e,i)),i.has(t)||(i.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.tagName.toLowerCase()}> "${t}": ${s}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}(a,t,l);else{if(!(t in a))return void console.warn(`[@wcstack/state] Property "${t}" does not exist on target element.`);l=a[t]}let d=l;for(const e of o)d=e.filterFn(d);const c=Fn.get(a)?.get(t);if(void 0!==c)for(const e of c)e(d);let u=null;if(e.enablePropagationContext){const o=$n(a,t,n),s=function(e,t){for(let n=On.length-1;n>=0;n--){const o=On[n];if(o.node===e&&o.receipt.member===t)return o.receipt}return null}(a,t);if(null!==s&&Object.is(s.writtenValue,l))return e.debug&&console.debug("[@wcstack/state] propagation: write confirmation suppressed echo.",{node:a,propName:t,statePathName:n,transactionId:s.transactionId,coveredBySameValueGuard:e.sameValueGuard&&(null===d||"object"!=typeof d)}),void(null!==w&&w({type:"propagation:suppressed",reason:"confirmation",transactionId:s.transactionId,edgeId:kn(o,"to-state"),node:a,member:t}));const i=kn(o,"to-state"),r=_n();if(null!==r&&r.visitedEdges.has(i))return void(null!==w&&w({type:"propagation:suppressed",reason:"visited-edge",transactionId:r.transactionId,edgeId:i,node:a,member:t}));u=En(r??Mn(o),i)}const f=Zr(a.getRootNode());null===f&&M("No state tree found on this root for two-way binding.");const p=ze(a),h=()=>{i&&(Bn=!0);try{f.createState("writable",e=>{e[ot](p,()=>{e[n]=d})})}finally{i&&(Bn=!1)}};null!==u?Rn(u,h):h()};const Kn=new WeakSet;function Xn(e){Kn.add(e)}function Qn(e){return!!Kn.has(e)&&(Kn.delete(e),!0)}const Jn=new WeakMap;function Yn(e,t){const n=Jn.get(e);return!(void 0===n||n<t)&&(n===t?Jn.delete(e):Jn.set(e,n-t),!0)}const Zn=new WeakSet;function eo(e){Zn.add(e)}function to(e){return!!Zn.has(e)&&(Zn.delete(e),!0)}let no=0;function oo(){no--}function so(){return no>0}class io{registry;entries=new Map;constructor(e){this.registry=e}wait(e,t,n=()=>{}){const o=e.toLowerCase();let s=this.entries.get(o);void 0===s&&(s={waiters:new Set},this.entries.set(o,s),this.registry.whenDefined(o).then(()=>this.settle(o,null),e=>this.settle(o,e)));const i={active:!0,resolve:t,reject:n};return s.waiters.add(i),()=>{i.active&&(i.active=!1,s?.waiters.delete(i))}}pendingCount(e){return this.entries.get(e.toLowerCase())?.waiters.size??0}settle(e,t){const n=this.entries.get(e);if(void 0===n)return;this.entries.delete(e);const o=Array.from(n.waiters);n.waiters.clear();for(const e of o)e.active&&(e.active=!1,null===t?e.resolve():e.reject(t))}}const ro=new WeakMap;function ao(e){let t=ro.get(e);return void 0===t&&(t=new io(e),ro.set(e,t)),t}function lo(e,t){let n=null;for(const o of e.propModifiers){const e=o.indexOf("=");if(e<0)continue;const s=o.slice(0,e).trim(),i=o.slice(e+1).trim();s!==I&&s!==A&&M(`Unknown binding modifier "${s}" in "${o}".`),s===t&&(null!==n&&M(`Binding modifier "${t}" may only be specified once.`),n=i)}return n}function co(e){return e.propModifiers.some(e=>e.includes("="))}const uo=Object.freeze({authority:"state",syncOn:"call",observable:!1,outputOnly:!1}),fo=Object.freeze({authority:"none",syncOn:"call",observable:!1,outputOnly:!1});function po(e,t){return"state"===e&&"call"===t?uo:{authority:e,syncOn:t,observable:!1,outputOnly:!1}}function ho(t){if(!e.enableDirectionalInitialSync)return co(t)&&M("init=/sync= modifiers require enableDirectionalInitialSync."),uo;const n=null===(o=lo(t,I))?null:"state"===o||"element"===o||"auto"===o||"none"===o?o:M(`Invalid init modifier value "${o}".`);var o;const s=function(e){return null===e||"call"===e?"call":"connect"===e?"connect":M(`Invalid sync modifier value "${e}".`)}(lo(t,A));if("event"===t.bindingType)return null!==n&&"none"!==n&&M("Event bindings only allow init=none."),"call"===s?fo:{authority:"none",syncOn:s,observable:!1,outputOnly:!1};if(t.propSegments[0]===m)return po("state",s);if("prop"!==t.bindingType)return null!==n&&"state"!==n&&"none"!==n&&M(`Binding type "${t.bindingType}" does not support init=${n}.`),po(n??"state",s);const i=ye(t.node);if(null===i)return po(n??"state",s);const r=i.knownProperties.has(t.propName),a=i.declaredInputs.has(t.propName);r||a||M(`Property "${t.propName}" is not declared by wcBindable.`);const l=n??(r&&!a?"element":"state");return(r&&a?new Set(["state","element","auto","none"]):r?new Set(["element","none"]):new Set(["state","none"])).has(l)||M(`init=${l} is incompatible with wcBindable member "${t.propName}".`),"connect"!==s||r||M(`sync=connect requires observable property "${t.propName}".`),{authority:l,syncOn:s,observable:r,outputOnly:r&&!a}}function go(e,t){return"auto"!==t?t:function(e){const t=Zr(e.replaceNode.getRootNode());null===t&&M("No state tree found on this root for binding.");const n=zt(e);let o=!1;return t.createState("readonly",e=>{o=e[it](n)}),o}(e)?"state":"element"}let mo=0,bo=0;const wo=["active","disposed","failed"],yo=new WeakMap,vo=new WeakMap,No=new WeakMap,xo=new WeakMap,So=new WeakMap;function Io(e,t){const n=So.get(e);void 0!==n?n!==t&&(n instanceof Set?n.add(t):So.set(e,new Set([n,t]))):So.set(e,t)}function Ao(e){return So.has(e)}function To(e,t){const n=So.get(e);if(void 0!==n)if(n instanceof Set)for(const e of Array.from(n))t(e);else t(n)}function $o(e,t){if(t(e),null!==e.firstChild)for(const n of Array.from(e.childNodes))$o(n,t)}function ko(e){if("object"!=typeof e||null===e)return!1;const t=e;return 9===t.nodeType||11===t.nodeType&&"host"in t}class Po{root;observer;constructor(e){this.root=e;const t=globalThis.MutationObserver;this.observer="function"==typeof t?new t(e=>this.handleMutations(e)):null,this.observer?.observe(e,{childList:!0,subtree:!0})}handleMutations(e){const t=[],n=[];for(let o=0;o<e.length;o++){const s=e[o],i=s.removedNodes;if(0===i.length||!Yn(s.target,i.length))for(let e=0;e<i.length;e++)t.push(i[e]);const r=s.addedNodes;for(let e=0;e<r.length;e++)n.push(r[e])}const o=[];for(const e of t)Qn(e)||$o(e,e=>{To(e,t=>{this.root.contains(e)||t.handleRemovedNode(e)})});for(const e of n)to(e)&&!so()||$o(e,e=>{To(e,t=>{this.root.contains(e)&&t.handleAddedNode(e,o)})});o.length>0&&Lr(o)}}const Mo=new WeakMap;function Eo(e){let t=Mo.get(e);return void 0===t&&(t=new Po(e),Mo.set(e,t)),t}function Co(e){const t=e.inFilters.map(e=>`${e.filterName}(${e.args.join(",")})`).join("|"),n=e.outFilters.map(e=>`${e.filterName}(${e.args.join(",")})`).join("|");return[e.bindingType,e.propName,e.propModifiers.join(","),e.statePathName,t,n,e.uuid??""].join("\0")}function _o(e,t,n){const o=Zr(Mt(e,n));null===o&&M("No state tree found on this root for binding.");const s=mt(o,e.statePathInfo);return function(e,t,n){let o=Bt.get(e);void 0===o&&(o=new WeakMap,Bt.set(e,o));const s=o.get(t);void 0===s?o.set(t,n):s instanceof Set?s.add(n):s!==n&&o.set(t,new Set([s,n])),null!==w&&w({type:"state:binding-added",absoluteAddress:ht(e,t),binding:n})}(s,t,e),s}function Ro(e,t){const n=Et(e,t);return Rt(n,e),n}function Oo(e,t,n,o){null!==t?Ot(t,e):function(e,t,n){const o=Bt.get(e);if(void 0===o)return;const s=o.get(t);void 0!==s&&(s instanceof Set?s.delete(n):s===n&&o.delete(t),null!==w&&w({type:"state:binding-removed",absoluteAddress:ht(e,t),binding:n}))}(n,o,e),Vt(e),Ct(e)}function Bo(e,t){null===e.teardowns&&(e.teardowns=new Set),e.teardowns.add(t)}class Lo{records=new Set;rowPlan=null;rows=new Set;knownBindingsByNode=new WeakMap;optionsByBinding=new WeakMap;deferredByNode=new WeakMap;deferred=new Set;constructor(e=null){null!==e&&this.observe(e)}initialize(e,t={},n){const o=t.registerAddress??!0,s={registerAddress:o,registerPathInfo:t.registerPathInfo??o,applyOnReconnect:t.applyOnReconnect??!0},i=[];for(const t of e){const e=this.remember(t,s),o=this.rowOf(e),r=null===o?-1:o.bindings.indexOf(e);if(null!==o&&0===o.phases[r]){const t=o;this.observe(e.replaceNode),s.registerAddress&&null===t.addresses[r]&&null===t.patternPathInfos[r]&&(t.registered=!0,this.registerRowSlot(t,r));continue}const a=vo.get(e);void 0===a||"disposed"===a.phase||"failed"===a.phase?(this.start(e,s,n),i.push(e)):(this.observe(a.anchor),s.registerAddress&&null===a.address&&null===a.patternListIndex&&(a.options.registerAddress=!0,this.registerAddress(a)),"active"===a.phase&&this.settleInitialRecord(a),this.settleConnectedSnapshot(a))}return i.filter(e=>this.shouldApplyState(e))}activate(e,t){if(ko(t)&&Eo(t),null===this.rowPlan)for(const n of e){const e=vo.get(n);if(void 0!==e&&e.session===this&&"disposed"!==e.phase&&"failed"!==e.phase){null===e.address&&null===e.patternListIndex&&(e.options.registerAddress=!0,this.registerAddress(e,t)),"active"===e.phase&&this.settleInitialRecord(e),this.settleConnectedSnapshot(e);continue}const o=this.optionsByBinding.get(n);void 0!==o?(o.registerAddress=!0,this.start(n,o,t)):this.initialize([n],{registerAddress:!0,registerPathInfo:!1,applyOnReconnect:!1})}else this.activatePlanRows(this.rowPlan,e,t)}shouldApplyState(t){if(!e.enableDirectionalInitialSync)return co(t)&&ho(t),!0;const n=this.rowOf(t);if(null!==n){const e=n.bindings.indexOf(t);if(e>=0){if(!n.registered)return!0;if(2===n.phases[e])return!1;const t=n.plan.slots[e];return 1&n.flags[e]?"state"===t.authority||!t.policy.outputOnly:(n.flags[e]|=1,"state"===t.authority)}}const o=vo.get(t);return void 0===o||o.session!==this||(!o.options.registerAddress||"waiting-definition"===o.phase||"failed"!==o.phase&&("active"===o.phase&&this.settleInitialRecord(o),o.initialApplyDone?"state"===o.resolvedAuthority||!o.outputOnlyMember&&!o.observationPending:(o.initialApplyDone=!0,"state"===o.resolvedAuthority)))}getRecord(e){const t=this.rowOf(e),n=null===t?-1:t.bindings.indexOf(e);if(null!==t&&n>=0)return{id:64*t.id+n,info:e,generation:t.generation,phase:wo[t.phases[n]],teardowns:null};const o=vo.get(e);return o?.session===this?o:null}addTeardown(e,t){const n=vo.get(e);return!(void 0===n||!this.isAlive(n,n.generation))&&(Bo(n,t),!0)}deferUntilDefined(e,t,n,o=()=>{}){const s=be(e);null===s&&M(`CustomElementRegistry is unavailable for <${t}>.`),this.observe(e),Io(e,this);const i={node:e,active:!0,cancel:null};let r=this.deferredByNode.get(e);void 0===r&&(r=new Set,this.deferredByNode.set(e,r)),r.add(i),this.deferred.add(i);const a=()=>!!i.active&&(i.active=!1,r?.delete(i),this.deferred.delete(i),!0);return i.cancel=ao(s).wait(t,()=>{if(a())try{we(s,e),n()}catch(e){o(e)}},e=>{a()&&o(e)}),()=>{a()&&i.cancel?.()}}disposeBinding(e){const t=this.rowOf(e);if(null!==t){const n=t.bindings.indexOf(e);if(n>=0)return void this.disposeRowSlot(t,n)}const n=vo.get(e);void 0!==n&&n.session===this&&this.disposeRecord(n)}get isRowSession(){return null!==this.rowPlan}get currentRowPlan(){return this.rowPlan}disposeBindings(e){for(let t=0;t<e.length;t++)this.disposeBinding(e[t]);if(!(this.rows.size>0))for(const e of Array.from(this.deferred))e.active=!1,e.cancel?.(),this.deferred.delete(e),this.deferredByNode.get(e.node)?.delete(e)}destroyRow(e){const t=e.length>0?this.rowOf(e[0]):null;null!==t?(this.destroyRowRecord(t),this.rows.delete(t)):this.destroyRecords()}destroyRowRecord(e){for(let t=0;t<e.bindings.length;t++){const n=e.addresses[t];null!==n&&(Ot(n,e.bindings[t]),e.addresses[t]=null),e.phases[t]=1}}dispose(){for(const e of Array.from(this.rows))for(let t=0;t<e.bindings.length;t++)this.disposeRowSlot(e,t);for(const e of Array.from(this.records))this.disposeRecord(e);for(const e of Array.from(this.deferred))e.active=!1,e.cancel?.(),this.deferred.delete(e),this.deferredByNode.get(e.node)?.delete(e)}canWholesaleDestroy(){if(this.deferred.size>0)return!1;if(0===this.records.size)return!0;for(const e of this.records)if(e.pendingDefinitions>0||e.observationPending)return!1;return!0}destroyRecords(){for(const e of this.rows)this.destroyRowRecord(e);this.rows.clear();for(const e of this.records)null!==e.address&&(Ot(e.address,e.info),e.address=null),e.phase="disposed",e.teardowns=null;this.records.clear()}forEachActiveBindingNode(e){for(const t of this.rows)for(let n=0;n<t.bindings.length;n++)0===t.phases[n]&&e(t.bindings[n].node);for(const t of this.records)"active"===t.phase&&e(t.info.node)}rebindAddresses(){const e=[];for(const t of this.rows)for(let n=0;n<t.bindings.length;n++){if(0!==t.phases[n])continue;if(null===t.addresses[n]&&null===t.patternPathInfos[n])continue;const o=t.bindings[n];this.unregisterRowSlot(t,n),this.registerRowSlot(t,n),this.shouldApplyState(o)&&e.push(o)}for(const t of this.records){if("active"!==t.phase)continue;const n=t.info;if(null===t.address&&null===t.patternListIndex)continue;const o="for"===n.bindingType?Et(n):null;if(Oo(n,t.address,t.patternPathInfo,t.patternListIndex),t.address=null,t.patternPathInfo=null,t.patternListIndex=null,this.registerAddress(t),null!==o){const e=Et(n);e!==o&&Ke(o)&&Ge(e,Ue(o)),e!==o&&nt(o)&&Ze(e,Ye(o))}this.shouldApplyState(n)&&e.push(n)}return e}observe(e){const t=function(e){const t=e.getRootNode();return ko(t)?t:null}(e);null!==t&&Eo(t)}handleMutations(e,t,n){for(const n of t)$o(n,t=>{e.contains(t)||this.handleRemovedNode(t)});const o=[];for(const t of n)$o(t,t=>{e.contains(t)&&this.handleAddedNode(t,o)});o.length>0&&Lr(o)}handleRemovedNode(e){const t=this.knownBindingsByNode.get(e);if(void 0!==t)if(t instanceof Map)for(const e of t.values())this.disposeBinding(e);else this.disposeBinding(t);const n=this.deferredByNode.get(e);if(void 0!==n)for(const e of Array.from(n))e.active=!1,e.cancel?.(),n.delete(e),this.deferred.delete(e)}handleAddedNode(e,t){const n=this.knownBindingsByNode.get(e);if(void 0===n)return;const o=n instanceof Map?n.values():[n];for(const e of o){const n=vo.get(e);if("active"===n?.phase){this.settleConnectedSnapshot(n);continue}if("disposed"!==n?.phase)continue;const o=this.optionsByBinding.get(e);if(void 0!==o)try{this.start(e,o),o.applyOnReconnect&&this.shouldApplyState(e)&&t.push(e)}catch{}}}knownMapFor(e){const t=this.knownBindingsByNode.get(e);if(t instanceof Map)return t;const n=new Map;if(void 0!==t){let e=xo.get(t);void 0===e&&(e=Co(t),xo.set(t,e)),n.set(e,t)}return this.knownBindingsByNode.set(e,n),n}remember(e,t){const n=e.replaceNode;Io(n,this);const o=this.knownMapFor(n);let s=xo.get(e);void 0===s&&(s=Co(e),xo.set(e,s));const i=o.get(s);if(void 0!==i){const e=this.optionsByBinding.get(i);return void 0!==e&&(e.registerAddress||=t.registerAddress,e.registerPathInfo||=t.registerPathInfo,e.applyOnReconnect||=t.applyOnReconnect),i}return o.set(s,e),this.optionsByBinding.set(e,{...t}),e}initializeRow(e,t){this.rowPlan=e;const n=e.slots,o=t.length,s={id:++mo,session:this,generation:++bo,plan:e,bindings:t,registered:!1,phases:new Array(o).fill(0),flags:new Array(o).fill(0),addresses:new Array(o).fill(null),patternPathInfos:new Array(o).fill(null),patternListIndexes:new Array(o).fill(null)};this.rows.add(s);for(let e=0;e<o;e++){const o=t[e],i=o.replaceNode;if(Io(i,this),this.addKnownRowBinding(i,o,e),yo.set(o,s),n[e].isEvent){try{pn(o)}catch(t){throw s.phases[e]=2,t}s.flags[e]|=2}}}activatePlanRows(e,t,n){const o=t.length>0?this.rowOf(t[0]):null;if(null===o||o.bindings!==t){for(const e of t)this.initialize([e],{registerAddress:!0,registerPathInfo:!1,applyOnReconnect:!1});return}o.registered=!0;const s=e.slots;let i=!1;for(let e=0;e<t.length;e++)if(0===o.phases[e])null===o.addresses[e]&&null===o.patternPathInfos[e]&&this.registerRowSlot(o,e,n);else{if(i||(o.generation=++bo,i=!0,this.rows.add(o)),o.phases[e]=0,o.flags[e]=0,s[e].isEvent){try{pn(t[e])}catch(t){throw o.phases[e]=2,this.runRowSlotTeardowns(o,e),t}o.flags[e]|=2}this.registerRowSlot(o,e,n)}}rowOf(e){const t=yo.get(e);return void 0!==t&&t.session===this?t:null}registerRowSlot(e,t,n){if(null!==e.addresses[t]||null!==e.patternPathInfos[t])return;const o=e.bindings[t],s=kt(o);null!==s?(e.patternPathInfos[t]=_o(o,s,n),e.patternListIndexes[t]=s):e.addresses[t]=Ro(o,n)}unregisterRowSlot(e,t){const n=e.addresses[t],o=e.patternPathInfos[t];null===n&&null===o||(Oo(e.bindings[t],n,o,e.patternListIndexes[t]),e.addresses[t]=null,e.patternPathInfos[t]=null,e.patternListIndexes[t]=null)}disposeRowSlot(e,t){if(1!==e.phases[t]){e.phases[t]=1,this.runRowSlotTeardowns(e,t);for(let t=0;t<e.phases.length;t++)if(0===e.phases[t])return;this.rows.delete(e)}}runRowSlotTeardowns(e,t){try{this.unregisterRowSlot(e,t)}catch{}if(2&e.flags[t]){e.flags[t]&=-3;try{hn(e.bindings[t])}catch{}}}addKnownRowBinding(e,t,n){const o=this.knownBindingsByNode.get(e);if(void 0===o)return void this.knownBindingsByNode.set(e,t);if(o instanceof Map)return void o.set("@plan:"+n,t);const s=new Map;s.set("@plan:first",o),s.set("@plan:"+n,t),this.knownBindingsByNode.set(e,s)}start(e,t,n){!function(e){const t=e.node,n=e.replaceNode;t!==n&&null!==t.parentNode&&t.parentNode.replaceChild(n,t)}(e);const o=this.optionsByBinding.get(e)??{...t},s={id:++mo,info:e,generation:++bo,phase:"discovered",teardowns:null,session:this,anchor:e.replaceNode,options:o,address:null,patternPathInfo:null,patternListIndex:null,pendingDefinitions:0,initialPolicy:null,resolvedAuthority:null,initialSettled:!1,initialApplyDone:!1,outputOnlyMember:!1,observationPending:!1,eventSequence:0,hasProducerValue:!1,producerValue:void 0,eventAttached:!1,twowayAttached:!1};vo.set(e,s),this.records.add(s),void 0===n&&this.observe(s.anchor);try{s.phase="attaching",this.attachListeners(s),s.options.registerAddress&&this.registerAddress(s,n),0===s.pendingDefinitions&&(s.phase="active")}catch(e){throw s.phase="failed",this.runTeardowns(s),this.records.delete(s),e}}attachListeners(t){const n=t.info;pn(n)?t.eventAttached=!0:n.propSegments[0]!==u?(yn(n)&&Bo(t,()=>function(e){if("radio"===e.bindingType&&-1===e.propModifiers.indexOf(v)){const t=wn(e),n=bn(e,t),o=gn.get(n);return void 0!==o&&(e.node.removeEventListener(t,o),0!==mn.countOf(n)&&(mn.remove(n,e)&&gn.delete(n),!0))}return!1}(n)),Qt(n)&&Bo(t,()=>function(e){if("checkbox"===e.bindingType&&-1===e.propModifiers.indexOf(v)){const t=Xt(e),n=Kt(e,t),o=Ut.get(n);return void 0!==o&&(e.node.removeEventListener(t,o),0!==Gt.countOf(n)&&(Gt.remove(n,e)&&Ut.delete(n),!0))}return!1}(n)),this.attachAfterDefinition(t,()=>{if(e.enableDirectionalInitialSync&&xn(n.node,n.propName)&&-1===n.propModifiers.indexOf(v)){const e=function(e,t,n){let o=Fn.get(e);void 0===o&&(o=new Map,Fn.set(e,o));let s=o.get(t);return void 0===s&&(s=new Set,o.set(t,s)),s.add(n),()=>{s?.delete(n),0===s?.size&&o?.delete(t),0===o?.size&&Fn.delete(e)}}(n.node,n.propName,e=>{this.isAlive(t,t.generation)&&(t.eventSequence+=1,t.hasProducerValue=!0,t.producerValue=e)});Bo(t,e)}!function(e){const t=ge(e.node);if(null!==t){const n=be(e.node),o=n?.get(t);if(void 0===o)return void(null===n&&M(`CustomElementRegistry is unavailable for <${t}>.`))}if(xn(e.node,e.propName)&&-1===e.propModifiers.indexOf(v)){const t=Vn(e),n=Hn(e),o=Un(e),s=zn(e,t,null!==n,o);let i=Wn.get(s);void 0===i&&(i=Gn(e.propName,e.statePathName,e.inFilters,n,o),Wn.set(s,i)),e.node.addEventListener(t,i),Dn.add(s,e)}}(n),t.twowayAttached=!0})):this.attachAfterDefinition(t,()=>{rn(n)&&Bo(t,()=>function(e){if(e.propSegments[0]!==u)return!1;const t=sn.get(e);return void 0!==t&&(e.node.removeEventListener(t.eventName,t.handler),sn.delete(e),!0)}(n))})}attachAfterDefinition(e,t){const n=ge(e.info.node);if(null===n)return void t();const o=be(e.info.node);if(null===o&&M(`CustomElementRegistry is unavailable for <${n}>.`),void 0!==o.get(n))return void t();e.phase="waiting-definition",e.pendingDefinitions+=1;const s=e.generation,i=ao(o).wait(n,()=>{if(this.isAlive(e,s))try{we(o,e.info.node),t(),e.pendingDefinitions-=1,0===e.pendingDefinitions&&(e.phase="active",this.settleInitialRecord(e))}catch{e.phase="failed",this.runTeardowns(e),this.records.delete(e)}},()=>{this.isAlive(e,s)&&(e.phase="failed",this.runTeardowns(e),this.records.delete(e))});Bo(e,i)}settleInitialRecord(t){if(e.enableDirectionalInitialSync&&!t.initialSettled&&t.options.registerAddress){t.phase="synchronizing";try{const e=ho(t.info),n=go(t.info,e.authority);if(t.initialPolicy=e,t.resolvedAuthority=n,t.initialSettled=!0,t.outputOnlyMember=e.outputOnly,t.phase="active",!e.observable)return;if("connect"===e.syncOn&&t.info.node instanceof HTMLElement&&!t.info.node.isConnected)return t.observationPending=!0,void no++;this.readProducerSnapshot(t,"call"===e.syncOn)}catch(e){throw t.phase="failed",this.runTeardowns(t),this.records.delete(t),e}}}readProducerSnapshot(e,t){if(!this.isAlive(e,e.generation))return;const n=e.info.node,o=e.info.propName;if(!(o in n))return;const s=e.eventSequence,i=n[o];e.observationPending&&(e.observationPending=!1,oo()),t&&e.eventSequence!==s||(e.hasProducerValue=!0,e.producerValue=i,"element"===e.resolvedAuthority&&function(e,t){let n=t;for(const t of e.inFilters)n=t.filterFn(n);const o=Zr(e.node.getRootNode());null===o&&M("No state tree found on this root for initial binding sync.");const s=ze(e.node);o.createState("writable",t=>{t[ot](s,()=>{t[e.statePathName]=n})})}(e.info,i))}settleConnectedSnapshot(t){if(e.enableDirectionalInitialSync&&t.observationPending&&t.info.node instanceof HTMLElement&&t.info.node.isConnected)try{this.readProducerSnapshot(t,!1)}catch{t.phase="failed",this.runTeardowns(t),this.records.delete(t)}}registerAddress(e,t){if(null!==e.address||null!==e.patternListIndex)return;const n=e.info,o=kt(n);if(null!==o?(e.patternPathInfo=_o(n,o,t),e.patternListIndex=o):e.address=Ro(n,t),!e.options.registerPathInfo)return;const s=Zr(n.replaceNode.getRootNode());null===s&&M("No state tree found on this root for binding."),"event"!==n.bindingType&&s.setPathInfo(n.statePathName,n.bindingType)}isAlive(e,t){return e.generation===t&&vo.get(e.info)===e&&"disposed"!==e.phase&&"failed"!==e.phase}disposeRecord(e){"disposed"!==e.phase&&(e.phase="disposed",this.runTeardowns(e),this.records.delete(e))}runTeardowns(e){e.observationPending&&(e.observationPending=!1,oo());const t=e.info;if(null!==e.address||null!==e.patternListIndex)try{Oo(t,e.address,e.patternPathInfo,e.patternListIndex),e.address=null,e.patternPathInfo=null,e.patternListIndex=null}catch{}if(e.twowayAttached){e.twowayAttached=!1;try{!function(e){const t=ge(e.node);if(null!==t){const n=be(e.node),o=n?.get(t);if(void 0===o)return}if(xn(e.node,e.propName)&&-1===e.propModifiers.indexOf(v)){const t=Vn(e),n=zn(e,t,null!==Hn(e),Un(e)),o=Wn.get(n);if(void 0===o)return;e.node.removeEventListener(t,o),Dn.remove(n,e)&&Wn.delete(n)}}(t)}catch{}}if(null!==e.teardowns){const t=Array.from(e.teardowns).reverse();e.teardowns=null;for(const e of t)try{e()}catch{}}if(e.eventAttached){e.eventAttached=!1;try{hn(t)}catch{}}}}function Wo(e){let t=No.get(e);return void 0===t&&(t=new Lo(e),No.set(e,t)),t}function Do(e){return vo.get(e)?.session??yo.get(e)?.session??null}let Fo=null;function jo(e){Fo=e}function qo(e,t){let n=e;for(const e of t)n=e.filterFn(n);return n}const zo=Object.freeze([]);const Vo=new WeakMap;const Ho=new WeakMap;function Uo(e){return Ho.get(e)??[]}function Go(e,t){Ho.set(e,t)}const Ko=new WeakMap;function Xo(e){return Ko.get(e)??[]}function Qo(e,t){Ko.set(e,t)}Set.prototype.difference||(Set.prototype.difference=function(e){const t=new Set(this);for(const n of e)t.delete(n);return t}),Set.prototype.intersection||(Set.prototype.intersection=function(e){const t=new Set;for(const n of e)this.has(n)&&t.add(n);return t});let Jo=0;function Yo(){return`u${(Jo++).toString(36)}`}let Zo=0,es=0;const ts=Symbol("wcs.listIndex.noValue");class ns{uuid=Yo();parentListIndex;position;length;_index;_version;_indexes;_listIndexes;_chainGeneration;_homeParentListIndex;_value;constructor(e,t,n){this.parentListIndex=e,this.position=e?e.position+1:0,this.length=this.position+1,this._homeParentListIndex=n,this._value=ts,this._index=t,this._version=Zo,this._chainGeneration=es}get index(){return this._index}set index(e){this._index=e,this._version=++Zo,this.indexes[this.position]=e}get version(){return this._version}get homeParentListIndex(){return this._homeParentListIndex}get value(){return this._value}set value(e){this._value=e}get dirty(){return null!==this.parentListIndex&&(this.parentListIndex.dirty||this.parentListIndex.version>this._version)}get indexes(){return null===this.parentListIndex?void 0===this._indexes&&(this._indexes=[this._index]):(void 0===this._indexes||this.dirty)&&(this._indexes=[...this.parentListIndex.indexes,this._index],this._version=Zo),this._indexes}get listIndexes(){return null===this.parentListIndex?void 0===this._listIndexes&&(this._listIndexes=[new WeakRef(this)]):void 0!==this._listIndexes&&this._chainGeneration===es||(this._listIndexes=[...this.parentListIndex.listIndexes,new WeakRef(this)],this._chainGeneration=es),this._listIndexes}get varName(){return`$${this.position+1}`}reparent(e){this.parentListIndex=e,this._indexes=void 0,this._listIndexes=void 0,this._version=++Zo,es++}at(e){return e>=0?this.listIndexes[e]?.deref()||null:this.listIndexes[this.listIndexes.length+e]?.deref()||null}}function os(e,t,n=e){return new ns(e,t,n)}function ss(e,t){e.reparent(t)}function is(e){return e.homeParentListIndex}function rs(e,t){e.value=t}function as(e,t){const n=e.value;return n!==ts&&n===t.value}const ls=new WeakMap,ds=new WeakSet;function cs(e){return ds.has(e)}function us(e,t){const n=is(e),o=e.parentListIndex;return null===n||n===o||ds.has(n)?function(e,t,n){return null!==e&&null!==n&&n!==t&&!!ds.has(e)&&!ds.has(n)&&n.position===e.position&&as(n,e)}(n,o,t)||function(e,t){return e!==t&&null!==e&&null!==t&&e.position===t.position&&ds.has(e)&&!ds.has(t)}(o,t)?t:null:n}function fs(e){const t=ls.get(e);return void 0===t?null:t}function ps(e,t){const n=ls.get(e);if(void 0===n)return null;const o=n[0];if(void 0!==o){const e=us(o,t);if(null!==e)for(const t of n)ss(t,e)}return n}function hs(e,t){null!==t?ls.set(e,t):ls.delete(e)}const gs=new WeakMap;function ms(e){return gs.get(e)??null}function bs(e,t){null===t?gs.delete(e):gs.set(e,t)}function ws(e){const t=gs.get(e);t&&(t.dirty=!0)}const ys=Symbol.for("wcstack.transition-runner");function vs(e){const t=globalThis[ys];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run?null:"function"==typeof t.accepts&&t.accepts(e)?t:null}function Ns(e,t,n){const o=vs(e);if(null!==o)return o.run(t,{source:e,types:n});t()}const xs=[],Ss=[];function Is(e){Ss.includes(e)||Ss.push(e)}function As(e,t=0){const n=xs.findIndex(e=>e.priority>t),o={listener:e,priority:t};-1===n?xs.push(o):xs.splice(n,0,o)}function Ts(e){const t=xs.findIndex(t=>t.listener===e);-1!==t&&xs.splice(t,1)}function $s(e){queueMicrotask(()=>{throw e})}class ks{_queueUpdateRecords=[];_queueRenderOnlyAddresses=[];constructor(){}enqueueAbsoluteAddress(e,t=null){for(let t=0;t<Ss.length;t++)Ss[t](e);const n=this._isQueueEmpty();this._queueUpdateRecords.push({absoluteAddress:e,context:t}),n&&this._scheduleDrain()}enqueueRenderOnlyAddress(e){const t=this._isQueueEmpty();this._queueRenderOnlyAddresses.push(e),t&&this._scheduleDrain()}_isQueueEmpty(){return 0===this._queueUpdateRecords.length&&0===this._queueRenderOnlyAddresses.length}_scheduleDrain(){et(),queueMicrotask(()=>{const e=this._queueUpdateRecords,t=this._queueRenderOnlyAddresses;this._queueUpdateRecords=[],this._queueRenderOnlyAddresses=[],this._applyChange(e,t)})}hasQueuedPath(e,t){return this._queueUpdateRecords.some(n=>n.absoluteAddress.absolutePathInfo.stateElement===e&&n.absoluteAddress.absolutePathInfo.pathInfo.path===t)}testApplyChange(e,t){this._applyChange(e.map((e,n)=>({absoluteAddress:e,context:t?.[n]??null})))}_applyChange(e,t=[]){const o=new Map,s=new Set;for(let t=0;t<e.length;t++){const n=e[t],i=o.get(n.absoluteAddress);null!==w&&null!=i&&null!==n.context&&i.transactionId!==n.context.transactionId&&w({type:"propagation:coalesced",absoluteAddress:n.absoluteAddress,droppedTransactionId:i.transactionId,winnerTransactionId:n.context.transactionId}),o.set(n.absoluteAddress,n.context),s.add(n.absoluteAddress)}for(let e=0;e<t.length;e++){const n=t[e];o.has(n)||o.set(n,null)}const i=[],r=new Map;o.forEach((e,t)=>{if(null!==e&&e.hop>=T)return console.error("[@wcstack/state] propagation hop limit exceeded; update record quarantined.",{path:t.absolutePathInfo.pathInfo.path,transactionId:e.transactionId,hop:e.hop,maxHops:T}),void(null!==w&&w({type:"propagation:hop-limit",absoluteAddress:t,transactionId:e.transactionId,hop:e.hop}));const n=Lt(t);if(void 0!==n)if(n instanceof Set)for(const t of n)!1!==t.replaceNode.isConnected&&(i.push(t),null!==e&&r.set(t,e));else!1!==n.replaceNode.isConnected&&(i.push(n),null!==e&&r.set(n,e))});try{const e=()=>{r.size>0?Lr(i,r):Lr(i)};if(n()||0===i.length)e();else{const t=Ns("state",e);void 0!==t&&t.catch($s)}}finally{tt(),function(e){for(const t of xs.slice())t.listener(e)}(s)}}}const Ps=new ks;function Ms(){return Ps}const Es=new WeakMap,Cs=new WeakMap,_s=new WeakMap,Rs=new WeakMap;let Os=!1;const Bs=new WeakMap,Ls=new WeakMap,Ws=new WeakMap,Ds=[];function Fs(e,t){const n=js(e);if(n.recorded.has(t))return;n.recorded.add(t);const o=a(t).cumulativePaths;if(o.length<2)return;let s=Ws.get(e);void 0===s&&Ws.set(e,s=new Map);for(let e=0;e<o.length-1;e++){let n=s.get(o[e]);void 0===n&&s.set(o[e],n=new Set),n.add(t)}}function js(e){let t=Es.get(e);return void 0===t&&Es.set(e,t={byPath:new Map,lastValue:new Map,recorded:new Set,tracked:new Set}),t}function qs(e,t,n){let o=e.get(t);void 0===o&&e.set(t,o=new Set),o.add(n)}function zs(e,t,n){const o=e.get(t);o.delete(n),0===o.size&&e.delete(t)}function Vs(e,t,n,o){const s=function(e,t){let n=e.byPath.get(t);return void 0===n&&e.byPath.set(t,n=new Map),n}(e,t);let i=Cs.get(o);if(void 0===i&&Cs.set(o,i=new Map),i.has(t)){const e=i.get(t);return Object.is(e,n)||(zs(s,e,o),i.set(t,n),qs(s,n,o)),!1}return i.set(t,n),qs(s,n,o),!0}function Hs(e,t,n){const o=e.get(t);void 0===o?e.set(t,[n]):o.push(n)}function Us(e,t,n,o,s,i){e.lastValue.set(t,n),s&&(null!==o.listIndex&&Hs(_s,o.listIndex,i),null!==i.levelListIndex&&Hs(Rs,i.levelListIndex,i))}function Gs(e,t,n,o,s){Os=!0;const i=js(e);Fs(e,t);Us(i,t,s,o,Vs(i,t,n,o),{stateElement:e,path:t,absAddress:o,levelListIndex:null})}function Ks(e,t,n,o,s){Os=!0;const i=js(e);Fs(e,t);Us(i,t,s,o,Vs(i,t,n.index,o),{stateElement:e,path:t,absAddress:o,levelListIndex:n})}function Xs(e,t){js(e).tracked.add(t)}function Qs(e){const t=Es.get(e);return void 0===t?null:{byPath:t.byPath,lastValue:t.lastValue,tracked:t.tracked,watchers:Bs.get(e)}}function Js(e,t){return!0===Es.get(e)?.byPath.has(t)||!0===Bs.get(e)?.has(t)}function Ys(e,t,n,o,s){Os=!0,js(e).lastValue.set(t,s),Fs(e,t);let i=Bs.get(e);void 0===i&&Bs.set(e,i=new Map);let r=i.get(t);void 0===r&&i.set(t,r=new Set);let a,l=Ls.get(o);void 0===l?Ls.set(o,l=[]):a=l.find(n=>n.stateElement===e&&n.path===t),void 0===a&&(a={stateElement:e,path:t,indexes:o,getters:new Set},l.push(a),r.add(a)),a.getters.add(n)}function Zs(e,t,n){if("number"!=typeof t)return;const o=e.indexes[t];if(void 0!==o)for(const t of e.getters)n.push(wt(e.stateElement,jt(t,o)))}function ei(e,t){if(void 0!==e)for(const n of e)t.push(n)}function ti(e,t,n,o,s){const i=Es.get(e),r=i?.byPath.get(t),a=Bs.get(e)?.get(t);if(void 0===i||void 0===r&&void 0===a)return Ds;const l=i.lastValue.has(t),d=i.lastValue.get(t);i.lastValue.set(t,s);const c=[],u=!n||!Object.is(o,s),f=l&&(!n||!Object.is(d,o))&&!Object.is(d,s);if(void 0!==r&&(n&&ei(r.get(o),c),f&&ei(r.get(d),c),u&&ei(r.get(s),c)),void 0!==a)for(const e of a)n&&Zs(e,o,c),f&&Zs(e,d,c),u&&Zs(e,s,c);return c}function ni(e,t){return!0===Ws.get(e)?.has(t)}function oi(e,t){let n=e;for(const e of t){if("object"!=typeof n||null===n)return;n=n[e]}return n}function si(e,t,n,o){const s=a(t).segments.length,i=[];for(const r of Ws.get(e).get(t)){const t=a(r).segments.slice(s);if(t.includes(y))ii(e,r,i);else for(const s of ti(e,r,!0,oi(n,t),oi(o,t)))i.push(s)}return i}function ii(e,t,n){const o=Es.get(e).byPath.get(t);if(void 0!==o)for(const e of o.values())ei(e,n);const s=Bs.get(e)?.get(t);if(void 0!==s)for(const e of s)for(let t=0;t<e.indexes.length;t++)Zs(e,t,n)}function ri(e){const t=Rs.get(e.levelListIndex),n=t.indexOf(e);t.splice(n,1)}function ai(e){if(!Os)return;const t=_s.get(e);if(void 0!==t){_s.delete(e);for(const e of t){const{stateElement:t,path:n,absAddress:o}=e,s=Cs.get(o),i=s.get(n);s.delete(n),zs(Es.get(t).byPath.get(n),i,o),null!==e.levelListIndex&&ri(e)}}}function li(e,t,n){if(!Os)return;const o=Rs.get(e);if(void 0!==o)for(const{stateElement:e,path:s,absAddress:i}of o){const o=Es.get(e),r=o.byPath.get(s);zs(r,t,i),qs(r,n,i),Cs.get(i).set(s,n);const a=o.lastValue.get(s);(Object.is(a,t)||Object.is(a,n))&&(ws(i),Ms().enqueueAbsoluteAddress(i,null))}}const di=new WeakMap,ci=Object.freeze([]),ui=new Set;function fi(e,t,n){const o=function(e,t,n){const o=Array.isArray(t)&&t.length>0?t:ci,s=Array.isArray(n)&&n.length>0?n:ci,i=function(e,t){const n=Array.isArray(e)&&e.length>0?e:ci,o=Array.isArray(t)&&t.length>0?t:ci;let s=di.get(n);return s&&s.get(o)||null}(o,s);if(i)return i;const r=ps(o,e)||[],a=r.length>0?is(r[0]):e;let l;try{if(0===s.length)return l={oldIndexes:r,newIndexes:[],changeIndexSet:ui,deleteIndexSet:new Set(r),addIndexSet:ui};let t=ps(s,e);if(0===o.length){if(null===t){t=[];for(let n=0;n<s.length;n++){const o=os(e,n,a);t.push(o)}}return l={oldIndexes:r,newIndexes:t,changeIndexSet:ui,deleteIndexSet:ui,addIndexSet:new Set(t)}}if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(o,s))return l={oldIndexes:r,newIndexes:r,changeIndexSet:ui,deleteIndexSet:ui,addIndexSet:ui};if(null!==t)return function(e,t){const n=new Set(t),o=new Set(e),s=new Set,i=n.difference(o),r=o.difference(n),a=new Map;for(let t=0;t<e.length;t++)a.set(e[t],t);for(let e=0;e<t.length;e++){const n=t[e];i.has(n)||a.get(n)!==e&&s.add(n)}return{oldIndexes:e,newIndexes:t,changeIndexSet:s,deleteIndexSet:r,addIndexSet:i}}(r,t);t=[];const n=new Map;for(let e=0;e<o.length;e++){const t=o[e];let s=n.get(t);s||(s=[],n.set(t,s)),s.push(e)}const i=new Set,d=new Set;for(let o=0;o<s.length;o++){const l=s[o],c=n.get(l),u=c&&c.length>0?c.shift():void 0;if(void 0===u){const n=os(e,o,a);t.push(n),d.add(n)}else{const e=r[u];u!==o&&i.add(e),t.push(e)}}return l={oldIndexes:r,newIndexes:t,changeIndexSet:i,deleteIndexSet:new Set(r).difference(new Set(t)),addIndexSet:d}}finally{void 0!==l&&(!function(e,t,n){let o=di.get(e);o||(o=new WeakMap,di.set(e,o)),o.set(t,n)}(o,s,l),hs(s,l.newIndexes))}}(e,t,n);!function(e,t){for(let n=0;n<e.length;n++){if(e[n].index!==n){const t=e[n].index;e[n].index=n,li(e[n],t,n)}rs(e[n],t[n])}}(o.newIndexes,Array.isArray(n)&&n.length>0?n:ci),function(e){for(const t of e)ds.add(t)}(o.deleteIndexSet);for(const e of o.deleteIndexSet)ai(e);return function(e){for(const t of e)ds.delete(t)}(o.newIndexes),function(e,t){if(!Os||e===t)return;const n=Ls.get(e);if(void 0===n)return;Ls.delete(e);const o=Ls.get(t);Ls.set(t,void 0===o?n:o.concat(n));for(const o of n){o.indexes=t;const n=js(o.stateElement).lastValue.get(o.path);if("number"!=typeof n)continue;const s=e[n],i=t[n];if(s!==i)for(const e of[s,i])if(void 0!==e&&!cs(e))for(const t of o.getters){const n=wt(o.stateElement,jt(t,e));ws(n),Ms().enqueueAbsoluteAddress(n,null)}}}(o.oldIndexes,o.newIndexes),o}function pi(e){if(0===e.changeIndexSet.size||e.addIndexSet.size===e.newIndexes.length)return null;const t=new Map;for(let n=0;n<e.oldIndexes.length;n++)t.set(e.oldIndexes[n],n);const n=[],o=[];let s=-1,i=!0;for(const r of e.newIndexes){if(e.addIndexSet.has(r))continue;const a=t.get(r);if(void 0===a)return null;a<s&&(i=!1),s=a,n.push(r),o.push(a)}if(i)return null;const r=function(e){const t=e.length,n=[],o=new Array(t).fill(-1);for(let s=0;s<t;s++){const t=e[s];let i=0,r=n.length;for(;i<r;){const o=i+r>>1;e[n[o]]<t?i=o+1:r=o}i>0&&(o[s]=n[i-1]),n[i]=s}const s=[];let i=n.length>0?n[n.length-1]:-1;for(;i>=0;)s.push(i),i=o[i];return s.reverse(),s}(o),a=new Set;for(const e of r)a.add(n[e]);return a}const hi=new WeakSet;function gi(e){hi.add(e)}const mi=new WeakMap;function bi(e){return mi.get(e)??null}function wi(e,t){mi.set(e,t)}const yi=new WeakMap;function vi(e){return yi.get(e)??[]}function Ni(e,t){yi.set(e,t)}function xi(e,t){const n=vi(e);for(const e of n)Ve(e,t)}const Si=new WeakMap;const Ii=new WeakMap;function Ai(e,t){for(let n=0;n<e.length;n++)if(t.has(e[n]))return!0;return!1}function Ti(e,t,n,o,s){const i=function(e,t,n){let o=Ii.get(e);void 0===o&&Ii.set(e,o=new Map);const s=o.get(n);if(void 0!==s)return s;const i=n+".",r=t.map((t,o)=>{const s=e.slots[o];if(s.isEvent||s.isIndexBinding)return null;const r=t.statePathInfo.path;if(!r.startsWith(i))return null;const a=r.slice(i.length).split("."),l=[];let d=n;for(const e of a){if("*"===e)return null;d+="."+e,l.push(d)}return{tail:a,prefixes:l}});return o.set(n,r),r}(e,t,o.pathInfo.path),r=s.stateElement.getterPaths;let a,l=!1;for(let e=0;e<t.length;e++){const d=t[e];if(!n.shouldApplyState(d))continue;const c=i[e];if(null===c||Ai(c.prefixes,r)){Or(d,s);continue}if(s.appliedBindingSet.has(d))continue;s.appliedBindingSet.add(d),l||(a=s.state[st](o),l=!0);const u=c.tail;let f=a;for(let e=0;e<u.length;e++){if(null==f){f=void 0;break}f=f[u[e]]}Rr(d,s,f)}}function $i(e,t,n){xi(e,t);const o=Uo(e),s=bi(e);if(null!==s&&(s.activate(o,n.rootNode),null!==t&&!1===n.stateElement.hasUpdatedCallback&&!0!==n.stateElement.hasRecursion)){const i=function(e){return Si.get(e)??null}(e);if(null!==i)return void Ti(i,o,s,t,n)}for(const e of o){if(null===s){Rt(Et(e),e)}(null===s||s.shouldApplyState(e))&&Or(e,n)}}function ki(e){if(!e.mounted)return;const t=Uo(e),n=bi(e);for(let e=0;e<t.length;e++){const o=t[e];if(null!==n)n.disposeBinding(o);else{Ot(Et(o),o)}}!function(e){const t=vi(e);for(let e=0;e<t.length;e++)Ve(t[e],null)}(e)}function Pi(){return Object.freeze(new Set)}const Mi=new WeakMap,Ei=Pi();function Ci(e,t){const n=Mi.get(e);n?n.add(t):Mi.set(e,new Set([t]))}function _i(e){const t=Mi.get(e);return void 0!==t?t:Ei}function Ri(e,t){const n=Mi.get(e);n&&(n.delete(t),0===n.size&&Mi.delete(e))}function Oi(e,n){if(0===e.length)return e;const o=[];for(let s=0;s<e.length;s++){const i=e[s];o.push({filterName:i.filterName,args:i.args,filterFn:t(i.filterName,i.args,n,i.literals??i.args)})}return o}function Bi(e){return{...e,inFilters:Oi(e.inFilters,"input"),outFilters:Oi(e.outFilters,"output")}}const Li=new Set(["if","elseif","else","for"]);class Wi{_content;_childNodeArray=[];_firstNode=null;_lastNode=null;_mounted=!1;_ranged=!1;constructor(e,t=!1){this._content=e,this._ranged=t;const n=[];for(let t=e.firstChild;null!==t;t=t.nextSibling)n.push(t);this._childNodeArray=n,this._firstNode=this._childNodeArray.length>0?this._childNodeArray[0]:null,this._lastNode=this._childNodeArray.length>0?this._childNodeArray[this._childNodeArray.length-1]:null}get firstNode(){return this._firstNode}get lastNode(){return this._lastNode}get mounted(){return this._mounted}appendTo(e){const t=this._childNodeArray;for(let n=0;n<t.length;n++){const o=t[n];eo(o),e.appendChild(o)}this._mounted=!0}_movableNodes(){if(!this._ranged||!this._mounted)return this._childNodeArray;const e=this._firstNode,t=this._lastNode;if(null===e||null===t||null===e.parentNode)return this._childNodeArray;const n=[];for(let o=e;null!==o;o=o.nextSibling)if(n.push(o),o===t)return n;return this._childNodeArray}mountAfter(e){const t=e.parentNode;if(t){let n=e;for(const e of this._movableNodes()){if(n.nextSibling!==e){eo(e);const o=t;e.parentNode===t&&"function"==typeof o.moveBefore?o.moveBefore(e,n.nextSibling):t.insertBefore(e,n.nextSibling)}n=e}}this._mounted=!0}tryDestroy(){const e=bi(this);if(null===e||!e.canWholesaleDestroy())return!1;e.destroyRow(Uo(this));const t=this._childNodeArray;for(let e=0;e<t.length;e++){const n=t[e];null!==n.parentNode&&(Xn(n),n.parentNode.removeChild(n))}const n=Uo(this);for(let e=0;e<n.length;e++){const t=n[e];Li.has(t.bindingType)&&_i(t.node).forEach(e=>{e.tryDestroy()||e.unmount()})}return this._mounted=!1,!0}unmountInPlace(){{const e=bi(this);null!==e&&(e.isRowSession?e.disposeBindings(Uo(this)):e.dispose())}this._teardownBindings()}_teardownBindings(){const e=Uo(this);for(let t=0;t<e.length;t++){const n=e[t];Li.has(n.bindingType)&&_i(n.node).forEach(e=>{e.unmount()}),Vt(n),Ct(n)}}unmount(){{const e=bi(this);null!==e&&(e.isRowSession?e.disposeBindings(Uo(this)):e.dispose())}for(const e of this._childNodeArray)null!==e.parentNode&&(Xn(e),e.parentNode.removeChild(e));const e=Uo(this);for(let t=0;t<e.length;t++){const n=e[t];Li.has(n.bindingType)&&_i(n.node).forEach(e=>{e.unmount()}),Vt(n),Ct(n)}this._mounted=!1}}function Di(t){let n=t.topLevelStructural;return void 0===n&&(n=t.topLevelStructural=function(t){const n=new RegExp(`^@@(?:${e.commentForPrefix}|${e.commentIfPrefix}|${e.commentElseIfPrefix}|${e.commentElsePrefix}):`);for(let e=t.firstChild;null!==e;e=e.nextSibling)if(e.nodeType===Node.COMMENT_NODE&&n.test(e.data))return!0;return!1}(t.fragment)),n}function Fi(e){const t=document.createDocumentFragment(),n=new Wi(t);return n._childNodeArray=e,n._firstNode=e.length>0?e[0]:null,n._lastNode=e.length>0?e[e.length-1]:null,n._mounted=!0,n}function ji(e,t,n){const o=document.importNode(t.fragment,!0),s=t.nodeInfos,i=new Array(s.length);for(let e=0;e<s.length;e++){const t=$e(o,s[e].nodePath);null===t&&M(`Node not found by path [${s[e].nodePath.join(", ")}] in fragment.`),We(t),pe(t),i[e]=t}const r=n.slots,a=new Array(r.length),l=[];for(let e=0;e<r.length;e++){const t=r[e],n=i[t.nodeIndex],o={...t.template,node:n,replaceNode:n};a[e]=o,t.isIndexBinding&&l.push(o)}const d=function(e,t,n){let o=Dr.get(n);void 0!==o&&o.currentRowPlan===e||(o=new Lo,Dr.set(n,o));return o.initializeRow(e,t),o}(n,a,e.node),c=new Wi(o);return wi(c,d),Go(c,a),function(e,t){Si.set(e,t)}(c,n),Qo(c,l),Ni(c,i),Ci(e.node,c),c}function qi(t){void 0!==t.uuid&&null!==t.uuid||M("BindingInfo.uuid is null.");const o=da(t.uuid);o||M(`Fragment with UUID "${t.uuid}" not found.`);const s=!n()&&Di(o);let i=o.rowPlan;if((void 0===i||null!==i&&i.directional!==e.enableDirectionalInitialSync)&&(i=o.rowPlan=function(t){const n=e.enableDirectionalInitialSync,o=[],s=t.nodeInfos;for(let e=0;e<s.length;e++){const n=s[e],i=$e(t.fragment,n.nodePath);if(null===i)return null;for(const t of n.parseBindTextResults){const n=t.bindingType;if("text"!==n&&"prop"!==n&&"event"!==n)return null;const s=t.propSegments[0];if(s===m||s===u)return null;if("text"===n){if(i.nodeType!==Node.TEXT_NODE)return null}else if(null!==ge(i))return null;if("prop"===n&&xn(i,t.propName))return null;const r=Bi(t);let a;try{a=ho({...r,node:i,replaceNode:i})}catch{return null}if(a.observable||"auto"===a.authority)return null;o.push({nodeIndex:e,template:r,isEvent:"event"===n,isIndexBinding:t.statePathName in $,policy:a,authority:a.authority})}}return{directional:n,slots:o}}(o)),null!==i)return ji(t,o,i);const r=document.importNode(o.fragment,!0),a=function(e,t){const[n,o]=function(e,t){const n=[],o=[];for(const s of t){const t=$e(e,s.nodePath);if(null===t&&M(`Node not found by path [${s.nodePath.join(", ")}] in fragment.`),Oe.has(t))continue;const i=Be(t,s.parseBindTextResults,{allowDeferred:!1});o.push(...i.bindings),n.push(t)}return[n,o]}(e,t),s=new Lo,i=s.initialize(o,{registerAddress:!1,applyOnReconnect:!1},null);return{nodes:n,bindingInfos:i,bindingSession:s}}(r,o.nodeInfos);s&&function(e,t){e.appendChild(document.createComment(`wcs-row-end:${t}`))}(r,t.uuid);const l=new Wi(r,s);wi(l,a.bindingSession),Go(l,a.bindingInfos);const d=[];for(const e of a.bindingInfos)e.statePathName in $&&d.push(e);return Qo(l,d),Ni(l,a.nodes),Ci(t.node,l),l}const zi=new WeakSet,Vi=Symbol.for("wcstack.state.view-transition-naming");function Hi(){const e=vs("state");return null===e||"auto"!==e.naming?null:{limit:e.namingLimit}}function Ui(e,t,n){const o=function(e){const t=e.firstNode;if(null===t)return null;const n=e.lastNode;for(let e=t;null!==e;e=e.nextSibling){if(e.nodeType===Node.ELEMENT_NODE)return e;if(e===n)break}return null}(e);if(null===o||zi.has(o))return;const s=o.style;if(void 0===s)return;const i=function(){const e=globalThis;return e[Vi]??={counter:0,assigned:0,warned:!1}}();i.assigned>=n.limit?i.warned||(i.warned=!0,console.warn(`[@wcstack/state] auto view-transition-name limit (${n.limit}) reached; further elements are left unnamed. Raise naming-limit on <wcs-view-transition>, or switch to naming="manual" and name only what should morph.`)):(zi.add(o),i.assigned+=1,i.counter+=1,s.setProperty("view-transition-name",`wcs-${t}-${i.counter}`),s.setProperty("view-transition-class",`wcs-${t}`))}const Gi=new WeakMap,Ki=new WeakMap,Xi=new WeakMap,Qi=new WeakMap;function Ji(e,t,n){!function(e,t,n){let o=Ki.get(e);if(void 0===o){if(null===n)return;o=new WeakMap,Ki.set(e,o)}null===n?o.delete(t):o.set(t,n)}(e,t,n)}function Yi(e,t){Gi.set(e,t)}function Zi(e){return e.nodeType===Node.ELEMENT_NODE||(e.nodeType===Node.TEXT_NODE?""!==(e.textContent?.trim()??""):e.nodeType===Node.COMMENT_NODE&&e.data.startsWith("@@wcs-"))}function er(e,t){if(null===t)return!1;if(e.nextSibling===t)return!0;const n=e.compareDocumentPosition(t);return 0!==(n&Node.DOCUMENT_POSITION_FOLLOWING)&&0===(n&Node.DOCUMENT_POSITION_DISCONNECTED)}function tr(e,t,n){if(o=t,!hi.has(o))return null;var o;let s=null;for(let t=0;t<n.newIndexes.length;t++){const o=n.newIndexes[t],i=n.oldIndexes[t],r=n.addIndexSet.has(o)&&n.deleteIndexSet.has(i)?e.get(i):void 0;void 0!==r&&(s??={byAddedIndex:new Map,reused:new Set},s.byAddedIndex.set(o,r),s.reused.add(r))}return s}const nr=new Set(["if","elseif","else","for"]);function or(e,t){for(const n of Uo(e))if(t.appliedBindingSet.delete(n),nr.has(n.bindingType))for(const e of _i(n.node))or(e,t)}function sr(e){for(const t of Uo(e)){if(!nr.has(t.bindingType))continue;const e="for"===t.bindingType;for(const n of _i(t.node))sr(n),e&&n.mounted&&(ki(n),n.unmount(),Ri(t.node,n))}}function ir(e){return`${e.bindingType} ${e.statePathName} ${e.outFilters.map(e=>e.filterName).join("|")} ${e.node.isConnected?"(connected)":"(disconnected)"}`}function rr(t,o,s){const i=Boolean(s);let r;const a=_i(t.node);r=0===a.size?qi(t):a.values().next().value;const l=n(),d=t.uuid??"",c=t.bindingType;if(i||(e.debug&&console.log(`unmount if content : ${ir(t)}`),ki(r),r.unmount()),i){if(e.debug&&console.log(`mount if content : ${ir(t)}`),l){const e=document.createComment(`@@wcs-${c}-start:${d}:${t.statePathName}`);t.node.parentNode.insertBefore(e,t.node.nextSibling),r.mountAfter(e);const n=document.createComment(`@@wcs-${c}-end:${d}:${t.statePathName}`),o=r.lastNode??e;o.parentNode.insertBefore(n,o.nextSibling)}else r.mountAfter(t.node);$i(r,ze(t.node),o);const n=Hi();null!==n&&Ui(r,"branch",n)}}const ar=new WeakMap;function lr(e){return ar.get(e)??[]}function dr(){return Array.from(cr)}const cr=new Set;function ur(){cr.clear()}const fr=Symbol.for("wcstack.trustedTypes.policy");function pr(){const e=globalThis[fr];return null===e||"object"!=typeof e?null:e}function hr(e){globalThis[fr]=e}let gr;let mr=!1;function br(e,t){if(mr)return;if(!function(){if(void 0!==gr)return gr;if(!("trustedTypes"in globalThis))return gr=!1,gr;try{document.createElement("div").innerHTML="<i></i>",gr=!1}catch{gr=!0}return gr}())return;mr=!0;const n="function"==typeof pr()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${t}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${n}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:e,property:t})}const wr={value(e,t){"TEXTAREA"===e.tagName?e.textContent=String(t??""):e.setAttribute("value",String(t??""))},checked(e,t){t?e.setAttribute("checked",""):e.removeAttribute("checked")},selected(e,t){t?e.setAttribute("selected",""):e.removeAttribute("selected")},disabled(e,t){t?e.setAttribute("disabled",""):e.removeAttribute("disabled")},selectedIndex(e,t){const n=e.querySelectorAll("option"),o=Number(t);for(let e=0;e<n.length;e++)e===o?n[e].setAttribute("selected",""):n[e].removeAttribute("selected")}},yr=new Set(["textContent","innerText","innerHTML"]);function vr(t,o,s){if(void 0===s&&1===t.propSegments.length&&yr.has(t.propSegments[0])&&(s=""),void 0===s)return void(e.debug&&console.debug("Skipped property write: state value is undefined.",{element:t.node,propSegments:t.propSegments,statePathName:t.statePathName}));const i=t.node,r=t.propSegments;if(1===r.length){const d=r[0],c=i[d];if(c!==s){null!==Fo&&null!==c&&"object"==typeof c&&null!==s&&"object"==typeof s&&null!==ge(i)&&Fo.rememberOverwrittenObject(i,d,c);const n="innerHTML"===(l=d)||"outerHTML"===l||"srcdoc"===l,r=()=>{let t=!1;try{i[d]=n?function(e){if("string"!=typeof e)return e;const t=pr(),n=t?.createHTML;return"function"!=typeof n?e:n.call(t,e)}(s):s,t=!0}catch(t){n&&br(i,d),e.debug&&console.warn(`Failed to set property '${d}' on element.`,{element:i,newValue:s,error:t})}if(t){const t=function(e,t){const n=ge(e);if(null===n)return null;const o=be(e)?.get(n);if(void 0===o)return null;const s=ye(e)?.declaredInputs.get(t);return"string"==typeof s?.attribute&&s.attribute.length>0?s.attribute:null}(i,d);if(null!==t)try{!function(e,t,n){if(null==n)return void e.removeAttribute(t);let o;if("object"==typeof n)try{o=JSON.stringify(n)}catch{o=String(n)}else o=String(n);e.setAttribute(t,o)}(i,t,s)}catch(n){e.debug&&console.warn(`Failed to mirror attribute '${t}' on element.`,{element:i,newValue:s,error:n})}}};if(e.enablePropagationContext&&xn(i,d)){const e=$n(i,d,t.statePathName),n=kn(e,"to-element"),a=o?.propagationContextByBinding?.get(t)??_n()??Mn(e);if(a.visitedEdges.has(n))null!==w&&w({type:"propagation:suppressed",reason:"visited-edge",transactionId:a.transactionId,edgeId:n,node:i,member:d});else{const t=En(a,n);Rn(t,()=>function(e,t,n,o,s,i){const r={bindingId:o,bindingGeneration:0,member:t,transactionId:s,synchronousScopeId:An++,writtenValue:n};On.push({receipt:r,node:e});try{return i()}finally{On.pop()}}(i,d,s,e,t.transactionId,r))}}else r()}if(n()){const e=wr[d];e?e(i,s):(!function(e,t,n){let o=ar.get(e);o||(o=[],ar.set(e,o));const s=o.find(e=>e.propName===t);s?s.value=n:o.push({propName:t,value:n})}(i,d,s),a=i,cr.add(a))}return}var a,l;const d=r[0];let c=i[d];for(let e=1;e<r.length-1;e++){const t=r[e];if(null==c)return;c=c[t]}const u=r[r.length-1],f=c[u];if(f!==s){if(Object.isFrozen(c))return void(e.debug&&console.warn("Attempting to set property on frozen object.",{element:i,propSegments:r,oldValue:f,newValue:s}));null!==Fo&&2===r.length&&"object"==typeof c&&null!==c&&null!==ge(i)&&(u in c?Fo.rememberOverwrittenValue(i,d,u,c[u]):Fo.recordInjectedKey(i,d,u));try{c[u]=s}catch(t){e.debug&&console.warn("Failed to set property on sub-object.",{element:i,propSegments:r,oldValue:f,newValue:s,error:t})}}}const Nr=new WeakSet;function xr(e,t,n){}function Sr(e,t){const n=zt(t);if(n.pathInfo.path in $){const e=ze(t.node);return null===e&&M(`ListIndex not found for binding: ${t.statePathName}`),function(e,t){null===e.listIndex&&M("ListIndex not found for loopContext:");const n=$[t];void 0===n&&M(`Invalid index name: ${t}`);const o=At(e.listIndex,n,e.pathInfo.wildcardCount);return null===o&&M(k(`"${t}"`,n+1,e.pathInfo.wildcardCount)),o.index}(e,n.pathInfo.path)}return e[st](n)}const Ir=new WeakSet;function Ar(e,t){console.error(`[@wcstack/state] deferred apply failed for <${e}>.`,t)}const Tr=Object.freeze({[p]:function(e,t,n){const o=e.node,s=e.propSegments[1];"boolean"!=typeof n&&M("Invalid value for class application: expected boolean, got "+typeof n),o.classList.toggle(s,n)},[h]:function(e,t,n){const o=e.node,s=e.propSegments[1];null!=n?o.getAttribute(s)!==n&&o.setAttribute(s,n):o.hasAttribute(s)&&o.removeAttribute(s)},[g]:function(e,t,n){const o=e.propSegments[1],s=e.node.style;null==n&&(n=""),s[o]!==n&&(s[o]=n)},[m]:function(e,t,n){ln(n)||M("command binding requires a CommandToken value (use $command.<tokenName> with a name declared in $commandTokens).");const o=n,s=Vo.get(e);if(s&&s.token===o)return;const i=e.node,r=e.propSegments[1];"string"==typeof r&&0!==r.length||M('command binding requires a method name (e.g., "command.fetch").');const a=function(e){const t=ge(e);if(null===t)return null;const n=be(e)?.get(t);return void 0===n&&M(`Custom element <${t}> is not defined for command binding.`),ye(e)}(i);null===a&&M(`command binding requires a wc-bindable custom element. <${i.tagName.toLowerCase()}> is not wc-bindable.`),a.declaredCommands.has(r)||M(`Command "${r}" is not declared in wcBindable.commands of <${i.tagName.toLowerCase()}>.${C(r,a.declaredCommands.keys())}`),s&&(s.unsubscribe(),Vo.delete(e));const l=new WeakRef(i);let d=null;d=o.subscribe((...t)=>{const n=l.deref();if(!n||!n.isConnected)return d?.(),void Vo.delete(e);const o=n[r];return"function"!=typeof o&&M(`Method "${r}" is not a function on <${n.tagName.toLowerCase()}>.`),Reflect.apply(o,n,t)}),Vo.set(e,{token:o,unsubscribe:d,elementRef:l})}}),$r={text:function(e,t,o){const s=null==o?"":String(o);if(e.replaceNode.nodeValue!==s&&(e.replaceNode.nodeValue=s),n()&&!Nr.has(e.replaceNode)){Nr.add(e.replaceNode);const t=e.replaceNode.parentNode;if(t){const n=e.statePathName,o=document.createComment(`@@wcs-text-start:${n}`),s=document.createComment(`@@wcs-text-end:${n}`);t.insertBefore(o,e.replaceNode),t.insertBefore(s,e.replaceNode.nextSibling)}}},for:function(e,t,o){const s=e.statePathInfo,i=kt(e),r=Et(e),l=Ue(r),d=l.length>0&&!Ki.has(e.node)?[]:l,c=fi(i,d,o);t.newListValueByAbsAddress.set(r,Array.isArray(o)?o:[]);let u=Ki.get(e.node);const f=void 0!==u?tr(u,d,c):null,p=Array.isArray(d)&&d.length===c.deleteIndexSet.size&&c.deleteIndexSet.size>0;if(p&&null===f&&null!==e.node.parentNode){let t=Qi.get(e.node);if(void 0===t){const n=Gi.get(e.node)||e.node;t=function(e,t){let n=e.previousSibling,o=t.nextSibling,s=!0;for(;null!==n;){if(Zi(n)){s=!1;break}n=n.previousSibling}for(;null!==o;){if(Zi(o)){s=!1;break}o=o.nextSibling}return s}(e.node,n),Qi.set(e.node,t)}if(t){const t=e.node.parentNode;!function(e,t){Jn.set(e,(Jn.get(e)??0)+t)}(t,t.childNodes.length),t.textContent="",t.appendChild(e.node)}}let h=p?1e3-function(e){return Xi.get(e.node)||[]}(e).length:Number.POSITIVE_INFINITY;if(void 0!==u){const t=u;c.deleteIndexSet.forEach(n=>{const o=t.get(n);void 0!==o&&(null!==f&&f.reused.has(o)?(ki(o),sr(o),o.unmountInPlace()):h<=0&&o.tryDestroy()?Ri(e.node,o):(ki(o),o.unmount(),function(e,t){let n=Xi.get(e.node);void 0===n&&(n=[],Xi.set(e.node,n)),n.length<1e3?n.push(t):Ri(e.node,t)}(e,o),h-=1),p||t.delete(n))}),p&&(Ki.delete(e.node),u=void 0)}let g=e.node;const m=a(s.path+"."+y),b=t.stateElement.loopContextStack,w=pi(c);let v=null;c.newIndexes.length==c.addIndexSet.size&&c.newIndexes.length>0&&g.isConnected&&null===f&&(v=document.createDocumentFragment(),Nt(v,t.rootNode));const N=n(),x=Hi(),S=e.uuid??"",I=Xi.get(e.node);for(const n of c.newIndexes){let o;if(c.addIndexSet.has(n)){const i=jt(m,n);if(b.createLoopContext(i,i=>{if(o=f?.byAddedIndex.get(n)??(void 0!==I?I.pop():void 0),void 0===o?o=qi(e):or(o,t),null!==v)N&&v.appendChild(document.createComment(`@@wcs-for-start:${S}:${s.path}:${n.index}`)),o.appendTo(v),N&&v.appendChild(document.createComment(`@@wcs-for-end:${S}:${s.path}:${n.index}`));else{if(g.nextSibling!==o.firstNode){if(N){const e=document.createComment(`@@wcs-for-start:${S}:${s.path}:${n.index}`);g.parentNode.insertBefore(e,g.nextSibling),g=e}o.mountAfter(g)}if(N){const e=document.createComment(`@@wcs-for-end:${S}:${s.path}:${n.index}`),t=o.lastNode??g;t.parentNode.insertBefore(e,t.nextSibling)}}$i(o,i,t),null!==x&&Ui(o,"row",x)}),void 0===o&&M(`Content not found for ListIndex: ${n.index} at path "${s.path}"`),null!==f&&f.reused.has(o)){const e=t.stateElement.addressHooks;if(e){const n=e.rowReused;for(let e=0;e<n.length;e++)n[e](t.stateElement,o)}}}else{if(o=void 0!==u?u.get(n)??null:null,c.changeIndexSet.has(n)){const e=Xo(o);for(const n of e)Or(n,t)}null===o&&M(`Content not found for ListIndex: ${n.index} at path "${s.path}"`);const e=!o.mounted;if(null!==w&&w.has(n)&&er(g,o.firstNode)||g.nextSibling===o.firstNode||o.mountAfter(g),e){const e=o,s=jt(m,n);b.createLoopContext(s,n=>{$i(e,n,t)})}}g=o.lastNode||g,void 0===u&&(u=new WeakMap,Ki.set(e.node,u)),u.set(n,o)}Gi.set(e.node,g),null!==v&&(e.node.parentNode.insertBefore(v,e.node.nextSibling),Nt(v,null))},if:rr,else:rr,elseif:rr,radio:function(e,t,n){const o=e.node,s=qo(o.value,e.inFilters);o.checked=n===s},checkbox:function(e,t,n){const o=e.node,s=qo(o.value,e.inFilters),i=Array.isArray(n)?n:zo;o.checked=i.includes(s)}},kr=new WeakMap,Pr=new WeakMap,Mr=new WeakMap;function Er(){}function Cr(e){const t=Fo;if(null!==t){const n=e.replaceNode,o=e.propSegments[0];if(t.isComplete(n,o))return xr;if(t.isDeclared(n,o))return Er}return vr}function _r(e,t){Rr(e,t,Sr(t.state,e))}function Rr(e,t,n){const o=qo(n,e.outFilters);if(!0===Pr.get(e))return void t.deferredSelectBindings.push({binding:e,value:o,stateElement:t.stateElement});let s=kr.get(e);if(void 0===s){if(kr.has(e))return s=Cr(e),s===xr&&kr.set(e,s),void s(e,t,o);if(s=$r[e.bindingType],void 0===s){const t=e.propSegments[0];if(s=Tr[t],kr.set(e,s),void 0===s){ge(e.replaceNode)?(s=Cr(e),s===xr&&kr.set(e,s)):(s=vr,kr.set(e,s))}}if(s===vr){if("SELECT"===e.node.tagName){const n=e.propSegments[0];if("value"===n||"selectedIndex"===n)return t.deferredSelectBindings.push({binding:e,value:o,stateElement:t.stateElement}),void Pr.set(e,!0)}}s(e,t,o)}else s(e,t,o)}function Or(e,t){if(t.appliedBindingSet.has(e))return;if(t.appliedBindingSet.add(e),!1!==t.stateElement.hasUpdatedCallback){const n=Et(e);if(t.updatedAbsAddressSetByStateElement.has(t.stateElement)){t.updatedAbsAddressSetByStateElement.get(t.stateElement).add(n)}else t.updatedAbsAddressSetByStateElement.set(t.stateElement,new Set([n]))}const n=Do(e);if(null!==n&&!n.shouldApplyState(e))return;if("event"===e.bindingType)return;if(!0!==Mr.get(e)){const t=ge(e.replaceNode);if(t&&void 0===be(e.replaceNode)?.get(t))return void function(e,t){if(Ir.has(e))return;Ir.add(e);const n=()=>{Ir.delete(e);const t=Do(e);(null===t||t.shouldApplyState(e))&&Lr([e])},o=n=>{Ir.delete(e),Ar(t,n)},s=Do(e);if(null!==s){const i=s.deferUntilDefined(e.replaceNode,t,n,o);return void(s.addTeardown(e,()=>{Ir.delete(e),i()})||(Ir.delete(e),i()))}const i=be(e.replaceNode);if(null===i)return Ir.delete(e),void Ar(t,new Error("CustomElementRegistry is unavailable."));ao(i).wait(t,()=>{e.replaceNode.isConnected?n():Ir.delete(e)},o)}(e,t);Mr.set(e,!0)}if(!0===t.sameRootVerified)return void _r(e,t);let o=e.replaceNode.getRootNode();if(o instanceof DocumentFragment&&!(o instanceof ShadowRoot)&&(o=xt(o),null===o&&M("Root node for fragment not found for binding.")),o!==t.rootNode){const n=Zr(o);null===n&&M("No state tree found on this root for binding."),n.createState("readonly",s=>{const i={rootNode:o,stateElement:n,state:s,appliedBindingSet:t.appliedBindingSet,newListValueByAbsAddress:t.newListValueByAbsAddress,updatedAbsAddressSetByStateElement:t.updatedAbsAddressSetByStateElement,deferredSelectBindings:t.deferredSelectBindings};_r(e,i)})}else _r(e,t)}function Br(e,t,n,o){if(null!==n&&!0===n.hasErrorCallback){const s={path:e.statePathName,bindingType:e.bindingType,node:e.node},i=o.get(n);void 0===i?o.set(n,[{error:t,info:s}]):i.push({error:t,info:s})}else console.error(`[@wcstack/state] binding "${e.bindingType}: ${e.statePathName}" failed to apply; the rest of this batch continues.`,{node:e.node,error:t});null!==w&&w({type:"state:binding-apply-error",path:e.statePathName,bindingType:e.bindingType,error:t})}function Lr(t,n,o){let s=0;const i=new Set,r=new Map,a=new Map,l=[],d=new Map;for(;s<t.length;){let o=t[s];if(!1===o.replaceNode.isConnected){e.debug&&console.log(`applyChangeFromBindings: skip disconnected binding: ${o.bindingType} ${o.statePathName} on ${o.node.nodeName}`,o),s++;continue}let c=o.replaceNode.getRootNode();c instanceof DocumentFragment&&!(c instanceof ShadowRoot)&&(c=xt(c),null===c&&M("Root node for fragment not found for binding."));const u=Zr(c);null===u&&M("No state tree found on this root for binding."),u.createState("readonly",e=>{const f={rootNode:c,stateElement:u,state:e,appliedBindingSet:i,newListValueByAbsAddress:r,updatedAbsAddressSetByStateElement:a,deferredSelectBindings:l,sameRootVerified:!0,propagationContextByBinding:n};for(;;){try{Or(o,f)}catch(e){Br(o,e,u,d)}s++;const e=t[s];if(!e)break;if(e.replaceNode.getRootNode()!==f.rootNode)break;o=e}})}for(const{binding:e,value:t,stateElement:o}of l)try{vr(e,{propagationContextByBinding:n},t)}catch(t){Br(e,t,o??null,d)}for(const[e,t]of r.entries())Ge(e,t),Ze(e,t);if(!1!==o?.updatedCallback)for(const[e,t]of a.entries())e.createState("writable",e=>{e[dt](Array.from(t))});for(const[e,t]of d.entries())e.createState("writable",e=>{for(const{error:n,info:o}of t)try{e[ct](n,o)}catch(e){console.error(`[@wcstack/state] $errorCallback threw while handling the failure of binding "${o.bindingType}: ${o.path}".`,{error:e,original:n,node:o.node})}})}function Wr(e,t,n){const[o,s,i]=Le(e,n),r=Wo(e);for(const e of o)Ve(e,t);Lr(r.initialize(s)),function(e,t,n){for(const o of e)n.deferUntilDefined(o.node,o.tagName,()=>{const e=De(o);0!==e.length&&(Ve(o.node,t),Lr(n.initialize(e)))},e=>{console.error(`[@wcstack/state] deferred spread failed for <${o.tagName}>.`,e)})}(i,t,r)}const Dr=new WeakMap;async function Fr(t){const n=t.querySelectorAll(e.tagNames.state),o=[],s=be(t);null===s&&M(`CustomElementRegistry is unavailable for <${e.tagNames.state}>.`),await s.whenDefined(e.tagNames.state);for(const e of n){if(Ee(e))continue;const t=e;o.push(t.initializePromise)}await Promise.all(o)}async function jr(t){if(t===document)await Fr(document),D(document),$a(document,document),Wr(document.body,null);else{const n=t;n.host.hasAttribute(e.bindAttributeName)&&await fe(n.host),await Fr(n),D(n),$a(n,n),Wr(n,null)}}const qr={watch:"temporal",scan:"temporal",stream:"temporal",scopes:"scopes",dcc:"scopes",bindComponent:"scopes",recursion:"recursion",ssr:"ssr",devtools:"devtools"};function zr(e,t){return`[wcs/feature-not-installed] ${t} needs the "${e}" feature: install it with installFeatures([...]) from "@wcstack/state/features/${qr[e]??e}" before the state is defined.`}let Vr=null;function Hr(e){Vr=e}function Ur(e){return null===Vr&&M(zr("ssr",e)),Vr}const Gr=new WeakMap,Kr=new WeakMap,Xr=new Set,Qr=[];function Jr(e){Qr.includes(e)||Qr.push(e)}function Yr(){return Xr}function Zr(e){return Gr.get(e)??null}function ea(e){return Kr.get(e)??Promise.resolve()}function ta(e,t){const n=Promise.reject(t);n.catch(()=>{}),Kr.set(e,n)}const na=new WeakSet;function oa(e,t){const n=Gr.get(e);if(void 0!==n){if(n===t)return;M("A state tree is already registered on this root.")}Gr.set(e,t)}function sa(e,t){Kr.set(e,t),t.then(()=>ia(e),()=>{})}function ia(e){na.add(e)}function ra(t,o){const s=Gr.get(t);if(null===o){if(void 0===s)return;Gr.delete(t),Xr.delete(s),null!==w&&w({type:"state:element-unregistered",rootNode:t,element:s}),e.debug&&console.debug("State element unregistered")}else{if(s===o)return;if(void 0===s){const e=!n()&&o.hasAttribute?.("enable-ssr");if("HTMLDocument"===t.constructor.name||"Document"===t.constructor.name){const n=new Promise((n,o)=>{queueMicrotask(async()=>{try{if(e){await Ur('the "enable-ssr" attribute').hydrate(t)||await jr(t)}else await jr(t);ia(t),_a(),n()}catch(e){o(e)}})});Kr.set(t,n)}else if("ShadowRoot"===t.constructor.name){const e=new Promise((e,n)=>{queueMicrotask(async()=>{try{await jr(t),ia(t),_a(),e()}catch(e){n(e)}})});Kr.set(t,e)}}void 0!==s&&M('A state tree is already registered on this root — one <wcs-state> per root in v2. This second element stays unregistered: it keeps the state it loaded and its declarations stay live, but nothing binds to it and disconnecting it runs no cleanup — remove it. Mount additional states onto the tree instead: <wcs-state mount="...">.'),Gr.set(t,o),Xr.add(o);for(let e=0;e<Qr.length;e++)Qr[e](t,o);null!==w&&w({type:"state:element-registered",rootNode:t,element:o}),e.debug&&console.debug("State element registered",o)}}const aa=new Map;function la(e,t,n){if(null===n)aa.delete(e);else{aa.set(e,n);const o=Zr(t);null===o&&M("No state tree found on this root for fragment info.");const s=n.parseBindTextResult;o.setPathInfo(s.statePathName,s.bindingType);for(const e of n.nodeInfos)for(const t of e.parseBindTextResults)o.setPathInfo(t.statePathName,t.bindingType)}}function da(e){return aa.get(e)||null}function ca(){return Array.from(aa.keys())}function ua(t){if(t.nodeType===Node.ELEMENT_NODE){const n=t,o=oe(n.getAttribute(e.bindAttributeName)||"");return n.localName===e.tagNames.state&&n.hasAttribute("mount")?o.filter(e=>e.propSegments[0]!==P):o}if(t.nodeType===Node.COMMENT_NODE){const e=ae(t);null===e&&M("Comment node binding text not found.");const n=da(e);let o=n?.parseBindTextResult??null,s=null;return null===o?(o=le(e),s=null):s=e,[{...o,uuid:s}]}return[]}let fa;function pa(){return fa??={filterName:"not",args:[]}}const ha=/^(\s*@@\s*(?:.*?)\s*:\s*)(.+?)(\s*)$/;function ga(e,t){const n=t+i+y,o=e.indexOf("|");let s,r;if(-1!==o?(s=e.slice(0,o).trim(),r=e.slice(o)):(s=e.trim(),r=""),"."===s)s=n;else{if(!s.startsWith("."))return e;s=n+i+s.slice(1)}return r.length>0?s+r:s}function ma(e,t){const n=ha.exec(e);if(null===n)return e;const o=n[1],s=n[2],i=n[3];return o+ga(s,t)+i}function ba(e,t){const n=e.split(";");let o=!1;const s=n.map(e=>{const n=e.trim();if(0===n.length)return e;const s=n.indexOf(":");if(-1===s)return e;const i=n.slice(0,s).trim(),r=n.slice(s+1).trim(),a=ga(r,t);return a!==r?(o=!0,`${i}: ${a}`):e});return o?s.join(";"):e}function wa(e,t){return ba(e,t)}function ya(t,n){const o=e.bindAttributeName,s=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_ELEMENT);for(;s.nextNode();){const e=s.currentNode;if(e.nodeType===Node.COMMENT_NODE){const t=e;t.data=ma(t.data,n);continue}const t=e;if(t instanceof HTMLTemplateElement)continue;const i=t.getAttribute(o);if(null!==i){const e=ba(i,n);e!==i&&t.setAttribute(o,e)}}}function va(e){let t=e;const n=[];for(;null!==t.parentNode;){const e=Array.from(t.parentNode.childNodes).indexOf(t);n.unshift(e),t=t.parentNode}return n}function Na(e){const t=[],n=Re(e);for(const e of n){const n=ua(e);let o=e;if(e.nodeType===Node.COMMENT_NODE&&1===n.length&&"text"===n[0].bindingType&&null!==e.parentNode){const t=document.createTextNode("");e.parentNode.replaceChild(t,e),o=t}t.push({nodePath:va(o),parseBindTextResults:n})}return t}function xa(e){const t=Array.from(e.childNodes);for(const n of t)if(n.nodeType===Node.TEXT_NODE){""===(n.textContent||"").trim()&&e.removeChild(n)}}const Sa=new Map([["for",e.commentForPrefix],["if",e.commentIfPrefix],["elseif",e.commentElseIfPrefix],["else",e.commentElsePrefix]]),Ia=pa();function Aa(e,t){const n=t.outFilters;return{...t,outFilters:[...n,Ia],bindingType:e}}function Ta(e,t,n,o,s,i=!0){xa(t),"string"==typeof o&&ya(t,o),$a(e,t,o,s);const r={fragment:t,parseBindTextResult:void 0!==s&&i?s(n,o):n,nodeInfos:Na(t)};return void 0!==s&&function(e,t,n){for(const o of e)for(let e=0;e<o.parseBindTextResults.length;e++){const s=o.parseBindTextResults[e];null==s.uuid&&(o.parseBindTextResults[e]=t(s,n))}}(r.nodeInfos,s,o),r}function $a(t,n,o,s){const i=e.commentElsePrefix,r=Ce(n),a=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode(t){const n=t;if(r.length>0&&-1!==r.indexOf(n))return NodeFilter.FILTER_REJECT;if("template"===n.tagName.toLowerCase()){if((n.getAttribute(e.bindAttributeName)||"").length>0)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let l=null;const d=[],c=[];for(;a.nextNode();){const e=a.currentNode;c.push(e)}for(const n of c){let r=n.getAttribute(e.bindAttributeName)||"";"string"==typeof o&&(r=wa(r,o));let a=oe(r)[0];const c=Sa.get(a.bindingType);if(void 0===c)continue;const u=a.bindingType,f=n.content,p=Yo();let h=null;const g="for"===u?a.statePathName:o;if("else"===u){null===l&&M("'else' binding found without preceding 'if' or 'elseif' binding."),a=Aa("else",l.parseBindTextResult),h=Ta(t,f,a,g,s,!1),la(p,t,h);const e=d.at(-1),o=document.createComment(`@@${c}:${p}`);void 0!==e?(n.remove(),e.fragment.appendChild(o),e.nodeInfos.push({nodePath:va(o),parseBindTextResults:ua(o)})):n.replaceWith(o)}else if("elseif"===u){null===l&&M("'elseif' binding found without preceding 'if' or 'elseif' binding."),h=Ta(t,f,a,g,s),la(p,t,h);const e=document.createComment(`@@${c}:${p}`),o=Yo(),r={fragment:document.createDocumentFragment(),parseBindTextResult:Aa("else",l.parseBindTextResult),nodeInfos:[]};r.fragment.appendChild(e),r.nodeInfos.push({nodePath:va(e),parseBindTextResults:ua(e)}),la(o,t,r);const u=d.at(-1);d.push(r);const m=document.createComment(`@@${i}:${o}`);void 0!==u?(n.remove(),u.fragment.appendChild(m),u.nodeInfos.push({nodePath:va(m),parseBindTextResults:ua(m)})):n.replaceWith(m)}else{h=Ta(t,f,a,g,s),la(p,t,h);const e=document.createComment(`@@${c}:${p}`);n.replaceWith(e)}"if"===u?(d.length=0,l=h):"elseif"===u?l=h:"else"===u&&(l=null,d.length=0)}}const ka=()=>`[${e.bindAttributeName}]`;function Pa(t){if(Ao(t))return!0;if(!Ma(t))return!1;if(t.hasAttribute(e.bindAttributeName))return!1;const n=t.querySelector(ka());return null!==n&&Ao(n)}function Ma(e){return 1===e.nodeType}function Ea(t){if(Pa(t))return;D(t),$a(t.getRootNode(),t);const n=t.hasAttribute(e.bindAttributeName),o=t.parentNode,s=null!==o&&(1===o.nodeType||9===o.nodeType||11===o.nodeType);Wr(n&&s?o:t,null)}const Ca=[];function _a(){const e=Ca.splice(0,Ca.length);for(const t of e)Ea(t);B()}const Ra={protocol:"wcs-binder",version:1,bind:function(e){var t;Ma(e)&&!Pa(e)&&(t=e.getRootNode(),na.has(t)?Ea(e):Ca.push(e))}};function Oa(){const e=globalThis;void 0===e[_]&&(e[_]=Ra)}export{Na as $,jo as A,ge as B,fe as C,oe as D,Jr as E,cs as F,st as G,fs as H,At as I,as as J,yt as K,Ze as L,fi as M,Ye as N,bs as O,ca as P,da as Q,dr as R,lr as S,fr as T,ur as U,Fr as V,Le as W,Et as X,Ge as Y,xa as Z,ya as _,pr as a,la as a0,Fi as a1,wi as a2,Go as a3,Ni as a4,Qo as a5,os as a6,Ji as a7,Yi as a8,Ci as a9,an as aA,ms as aB,ps as aC,It as aD,Ln as aE,Js as aF,ni as aG,_n as aH,ti as aI,si as aJ,Mn as aK,Ue as aL,gi as aM,Te as aN,le as aO,Qs as aP,Yr as aQ,Ts as aR,qe as aS,xi as aa,hs as ab,Lo as ac,pa as ad,Hr as ae,ws as af,Xs as ag,Ys as ah,Ks as ai,Gs as aj,ct as ak,dt as al,lt as am,at as an,rt as ao,it as ap,Ns as aq,$s as ar,tt as as,Lt as at,et as au,on as av,Ur as aw,ra as ax,ta as ay,zr as az,jr as b,Ms as c,nn as d,Is as e,As as f,ea as g,be as h,ze as i,ot as j,jt as k,wt as l,Wo as m,Ve as n,Lr as o,oa as p,sa as q,Oa as r,hr as s,D as t,we as u,$a as v,Wr as w,Tt as x,Zr as y,Me as z};
|
|
1
|
+
import{c as e,r as t,f as n,i as o,a as s}from"./filterRegistry.js";import{P as i,Q as r,T as a,D as l,g as d,U as c,X as u,Y as f,Z as p,_ as h,$ as g,a0 as m,a1 as b,a2 as w,V as y,a3 as v,d as N,W as x,n as I,a4 as S,a5 as k,w as A,a6 as $,a7 as T,a8 as M,a9 as P,I as E,G as C}from"./pathDiagnostics.js";import{r as _,L as W,d as R}from"./errorGuidance.js";const L=Symbol.for("wcstack.binder");const O=Symbol.for("wcstack.binder.pending"),B=Symbol.for("wcstack.binder.taken");function D(){const e=function(){const e=globalThis[L];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;const t=function(){const e=globalThis;let t=e[O];return void 0===t&&(t=[],e[O]=t),t}();if(0===t.length)return;const n=t.splice(0,t.length),o=function(){const e=globalThis;let t=e[B];return void 0===t&&(t=new WeakSet,e[B]=t),t}();for(const t of n)o.add(t),e.bind(t)}const F=/\{\{\s*(.+?)\s*\}\}/g,j=new Set(["SCRIPT","STYLE"]);function z(t){if(!e.enableMustache)return;!function(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(;t.nextNode();)n.push(t.currentNode);for(const e of n)e.parentElement&&j.has(e.parentElement.tagName)||q(e)}(t);const n=Array.from(t.querySelectorAll("template"));for(const e of n)if(e.namespaceURI===i){const t=document.createElement("template"),n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){const o=n[e];t.content.appendChild(o)}for(const n of e.attributes)t.setAttribute(n.name,n.value);e.replaceWith(t),z(t.content)}else z(e.content)}function q(e){const t=e.data;if(F.lastIndex=0,!F.test(t))return;F.lastIndex=0;const n=document.createDocumentFragment();let o,s=0;for(;null!==(o=F.exec(t));){o.index>s&&n.appendChild(document.createTextNode(t.slice(s,o.index)));const e=o[1];n.appendChild(document.createComment(`@@: ${e}`)),s=o.index+o[0].length}s<t.length&&n.appendChild(document.createTextNode(t.slice(s))),e.parentNode.replaceChild(n,e)}const V=new Set(["if","elseif","else","for"]);function H(e,t,n){const o=-1===t?e.length:t;let s=0;for(;s<o&&/\s/.test(e[s]);)s++;const i=-1===n?0:n;let r=e.length;for(;r>i&&/\s/.test(e[r-1]);)r--;return e.slice(s,r)}const U=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function G(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:U.test(e)?Number(e):e)}function X(e){const t=[],n=[];let o="",s=null,i=!1,r=-1,a=-1;const l=()=>{const e=H(o,r,a);t.push(e),n.push(G(e,i)),o="",i=!1,r=-1,a=-1};for(let t=0;t<e.length;t++){const n=e[t];s?n===s?s=null:(-1===r&&(r=o.length),o+=n,a=o.length):'"'===n||"'"===n?(s=n,i=!0):","===n?l():o+=n}null!==s&&_(`[wcs/binding-syntax] unterminated ${s} quote in the filter arguments "(${e})". Close the quote.${W}`);const d=H(o,r,a);return(d||i)&&(t.push(d),n.push(G(d,i))),{args:t,literals:n}}const K=e=>e.trim(),Q=e=>"'"===e||'"'===e;function Y(e,t){let n=null;for(let o=0;o<e.length;o++){const s=e[o];if(null!==n)s===n&&(n=null);else if(Q(s))n=s;else if(s===t)return o}return-1}function J(e,t){const n=[];let o=null,s=0;for(let i=0;i<e.length;i++){const r=e[i];null!==o?r===o&&(o=null):Q(r)?o=r:r===t&&(n.push(e.slice(s,i)),s=i+1)}return n.push(e.slice(s)),n}function Z(e,t,n){const o=n??e.join("|");return e.map(e=>{const n=Y(e,"(");let s=function(e,t){let n=null,o=-1;for(let s=0;s<e.length;s++){const i=e[s];null!==n?i===n&&(n=null):Q(i)?n=i:i===t&&(o=s)}return o}(e,")");if(-1===s&&(s=e.lastIndexOf(")")),-1!==n&&-1===s&&_(`[wcs/binding-syntax] Invalid filter format: missing closing parenthesis in "${e}".${W}`),-1!==s&&-1===n&&_(`[wcs/binding-syntax] Invalid filter format: missing opening parenthesis in "${e}".${W}`),-1!==s&&s<n&&_(`[wcs/binding-syntax] Invalid filter format: ")" comes before "(" in "${e}".${W}`),-1!==s&&e.slice(s+1).trim().length>0){const t=e.slice(s+1).trim();_(`[wcs/binding-syntax] "${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,s+1)}|${t}").${W}`)}const i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&_(`[wcs/binding-syntax] an empty filter in "${o}" — remove the extra "|" or name the filter.${W}`),i.includes(r)){const[e,n]=i.split(r);_("input"===t?`[wcs/binding-syntax] "${i}" is not a filter name: a modifier list "${r}${n}" comes before the input filters, not inside one — write "<property>${r}${n}|${e}".${W}`:`[wcs/binding-syntax] "${i}" is not a filter name: "${r}" cannot appear in one. Modifiers belong on the left side of the binding, before the ":" — write "${e}" here.${W}`)}if(-1===n)return{filterName:i,args:[],literals:[]};return{filterName:i,...X(e.substring(n+1,s))}})}const ee=new Map;function te(e){const t=Y(e,a);let n="",o=[],s="",i=[];-1!==t?(n=e.slice(0,t).trim(),s=e.slice(t+1).trim(),ee.has(s)?i=ee.get(s):(o=J(s,a).map(K),i=Z(o,"input",e),ee.set(s,i))):n=e.trim();const d=n.split(r).map(K);d.length>2&&_(`[wcs/binding-syntax] "${n}": a binding takes one modifier list after a single "${r}" — write "${d[0]}${r}${d.slice(1).join(",")}".${W}`);const[c,u]=d,f=c.split(l).map(K);f.length>1&&""===f[0]||0!==c.length&&!f.some(e=>0===e.length)||_(`[wcs/binding-syntax] "${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).${W}`);return{propName:c,propSegments:f,propModifiers:u?u.split(",").map(K):[],inFilters:i}}const ne=new Map;function oe(e){const t=Y(e,a);let n="",o=[],s="",i=[];-1!==t?(n=e.slice(0,t).trim(),s=e.slice(t+1).trim(),ne.has(s)?i=ne.get(s):(o=J(s,a).map(K),i=Z(o,"output",e),ne.set(s,i))):n=e.trim(),-1!==n.indexOf("@")&&_(`"${n}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`);const r=n,c=r.startsWith(l),u=c?r.slice(l.length):r;(u.length>0&&u.split(l).some(e=>0===e.length)||!c&&0===u.length)&&_(`[wcs/binding-syntax] "${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).${W}`);return{statePathName:r,statePathInfo:d(r),outFilters:i}}const se=new Set([c,"if","elseif","for",u]),ie=new Set([g,m,b,w,f,y]);function re(e){const[...t]=function(e){return J(e,v)}(e).map(K).filter(e=>e.length>0),n=t.map(e=>{const t=Y(e,h);-1===t&&_(`[wcs/binding-syntax] Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.${W}`);const n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),s=n.split(r)[0].split(a)[0].trim();if(s!==n&&se.has(s)&&_(`[wcs/binding-syntax] "${e}": "${s}" takes no modifiers or filters on its left side — write "${s}:".${W}`),n===c){o.length>0&&_(`[wcs/binding-syntax] "${e}": "else" takes no value — write "else:".${W}`);const t=d("#else");return{propName:c,propSegments:[c],propModifiers:[],statePathName:"#else",statePathInfo:t,inFilters:[],outFilters:[],bindingType:"else"}}if(n===u){0===o.length&&_(`[wcs/binding-syntax] Invalid spread binding "${e}": spread target path is required.${W}`);const t=oe(o);return t.outFilters.length>0&&_(`[wcs/binding-syntax] Invalid spread binding "${e}": filters are not allowed on spread targets.${W}`),{propName:u,propSegments:[u],propModifiers:[],inFilters:[],...t,bindingType:"spread"}}if("if"===n||"elseif"===n||"for"===n){return{propName:n,propSegments:[n],propModifiers:[],inFilters:[],...oe(o),bindingType:n}}if("radio"===s||"checkbox"===s){const e=oe(o);return{...te(n),...e,bindingType:s}}{const e=oe(o),t=te(n);if(""===t.propSegments[0]&&t.propSegments.length>1){const o=t.propSegments.slice(1);return(o.includes("")||ie.has(o[0]))&&_(`[wcs/binding-syntax] "${n}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (${[...ie].join(", ")}).${W}`),{...t,propName:o.join(l),propSegments:o,...e,bindingType:"prop"}}return t.propSegments[0]===f||t.propSegments[0].startsWith(p)?{...t,...e,bindingType:"event"}:{...t,...e,bindingType:"prop"}}});if(n.length>1){n.some(e=>V.has(e.bindingType))&&_(`[wcs/template-syntax] Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding. Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).${W}`)}return n}const ae=new WeakMap,le=new Set([e.commentTextPrefix,e.commentForPrefix,e.commentIfPrefix,e.commentElseIfPrefix,e.commentElsePrefix]),de=new RegExp("^\\s*@@\\s*(.*?)\\s*:\\s*(.+?)\\s*$");function ce(t){const n=ae.get(t);if("string"==typeof n)return n;if(t.nodeType!==Node.COMMENT_NODE)return null;const o=t.data.trim(),s=de.exec(o);if(null===s)return null;const i=s[1]||e.commentTextPrefix;return le.has(i)?(ae.set(t,s[2]),s[2]):null}function ue(e){return{propName:"textContent",propSegments:["textContent"],propModifiers:[],inFilters:[],...oe(e),bindingType:"text"}}const fe=new WeakMap,pe=new WeakSet;let he=0;async function ge(e){const t=function(e){let t,n=fe.get(e)||null;if(null!==n)return n;const o=new Promise(e=>{t=e});return n={id:++he,promise:o,resolve:t},fe.set(e,n),pe.has(e)&&n.resolve(),n}(e);await t.promise}function me(e){const t=fe.get(e);void 0===t?pe.add(e):t.resolve()}const be=new WeakMap;function we(e){const t=be.get(e);if(void 0!==t)return t;let n=null;try{if(e.nodeType!==Node.ELEMENT_NODE)return n;const t=e,o=t.tagName.toLowerCase();if(o.includes("-"))return n=o;if(t.hasAttribute("is")){const e=t.getAttribute("is");if(e.includes("-"))return n=e}return n}finally{be.set(e,n)}}function ye(e){if("object"!=typeof e||null===e)return null;const t=e;return"function"!=typeof t.get||"function"!=typeof t.whenDefined?null:t}function ve(e=null){if(null!=e){const{customElementRegistry:t,customElements:n}=e;if(null===t)return null;if(void 0!==t)return ye(t);if(void 0!==n)return ye(n)}return ye(globalThis.customElements)}function Ne(e,t){e.upgrade?.(t)}function xe(e){try{if(null===e||"object"!=typeof e&&"function"!=typeof e)return null;const t=e,n=t.addEventListener,o=t.removeEventListener,s=t.constructor?.wcBindable;if("function"!=typeof n||"function"!=typeof o)return null;if("wc-bindable"!==s?.protocol)return null;if(!Number.isInteger(s.version)||s.version<1)return null;const i=Ae(s.properties,Ie);if(null===i)return null;const r=void 0===s.inputs?new Map:Ae(s.inputs,Se);if(null===r)return null;const a=void 0===s.commands?new Map:Ae(s.commands,ke);return null===a?null:{target:e,liveDeclaration:s,knownProperties:i,declaredInputs:r,declaredCommands:a}}catch{return null}}function Ie(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&("string"==typeof t.event&&0!==t.event.length&&(void 0===t.getter||"function"==typeof t.getter))}function Se(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&(void 0===t.attribute||"string"==typeof t.attribute)}function ke(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.name&&0!==t.name.length&&(void 0===t.async||"boolean"==typeof t.async)}function Ae(e,t){if(!Array.isArray(e))return null;const n=new Map;for(const o of e){if(!t(o)||n.has(o.name))return null;n.set(o.name,o)}return n}function $e(e,t){const n="."===t?`.${e}`:`${t}.${e}`;return{propName:e,propSegments:[e],propModifiers:[],statePathName:n,statePathInfo:d(n),inFilters:[],outFilters:[],bindingType:"prop"}}function Te(e){switch(e.bindingType){case"prop":case"event":case"radio":case"checkbox":return`${e.bindingType}::${e.propName}`;default:return null}}function Me(t,n,o={}){const s=o.allowDeferred??!0;if(!n.some(e=>"spread"===e.bindingType))return n;const i=[],r=new WeakSet;for(const e of n){if("spread"!==e.bindingType){i.push(e);continue}t.nodeType!==Node.ELEMENT_NODE&&_("Spread binding requires an element node.");const n=t,o=we(n);null===o&&_(`Spread binding "${e.statePathName}" requires a custom element with wcBindable, but <${n.tagName.toLowerCase()}> is not a custom element.`);const a=ve(n);null===a&&_(`CustomElementRegistry is unavailable for <${o}>.`);if(void 0===a.get(o)){s||_(`Spread binding "${e.statePathName}" requires <${o}> to be registered. Define the custom element before initializing this binding.`),i.push(e);continue}Ne(a,n);const l=xe(n);null===l&&_(`Spread binding "${e.statePathName}" requires <${o}> to expose a valid wcBindable declaration.`);const d=e.statePathName,c=new Set;for(const e of l.knownProperties.keys()){if(c.has(e))continue;c.add(e);const t=$e(e,d);r.add(t),i.push(t)}for(const e of l.declaredInputs.keys()){if(c.has(e))continue;c.add(e);const t=$e(e,d);r.add(t),i.push(t)}}const a=new Map;for(let e=0;e<i.length;e++){const t=Te(i[e]);null!==t&&a.set(t,e)}const l=[];for(let n=0;n<i.length;n++){const o=Te(i[n]);if(null!==o){if(a.get(o)===n)l.push(i[n]);else if(e.debug&&r.has(i[n])){const e=i[a.get(o)],s=t.nodeType===Node.ELEMENT_NODE?`<${t.tagName.toLowerCase()}>`:"node";console.debug(`[@wcstack/state] spread: prop "${i[n].propName}" of ${s} overridden by explicit binding (statePath: "${e.statePathName}").`)}}else l.push(i[n])}return l}function Pe(e,t){let n=e;for(let e=0;e<t.length;e++){let o=t[e];for(n=n.firstChild;null!==n&&o>0;)n=n.nextSibling,o--;if(null===n)break}return n}function Ee(e,n){if(0===e.length)return e;const o=[];for(let s=0;s<e.length;s++){const i=e[s],r=i.literals??i.args;o.push({filterName:i.filterName,args:i.args,literals:r,filterFn:t(i.filterName,i.args,n,r)})}return o}function Ce(e){return{...e,inFilters:Ee(e.inFilters,"input"),outFilters:Ee(e.outFilters,"output")}}const _e=new WeakMap;function We(e){return _e.get(e)||null}function Re(t){if(!t.hasAttribute("bind-component"))return!1;const n=t.parentNode;return n instanceof Element&&n.hasAttribute(e.bindAttributeName)}function Le(t){const n=[],o=t.querySelectorAll(`${e.tagNames.state}[bind-component]`);for(const e of o){if(!Re(e))continue;const o=e.parentNode;o!==t&&n.push(o)}return n}function Oe(e,t){for(let n=0;n<t.length;n++){const o=t[n];if(o!==e&&o.contains(e))return!0}return!1}function Be(t){const n=[],o=Le(t),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,{acceptNode(t){if(t.nodeType===Node.ELEMENT_NODE){return t.hasAttribute(e.bindAttributeName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}return null!==ce(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();){const e=s.currentNode;o.length>0&&Oe(e,o)||n.push(e)}return n}const De=new WeakSet;function Fe(e,t,n,o){const s=Me(e,t,{allowDeferred:n.allowDeferred});if(s.some(e=>"spread"===e.bindingType)){const n=e.nodeType===Node.ELEMENT_NODE?we(e):null;return null===n&&_("Spread binding deferred but element is not a custom element."),{bindings:[],deferred:{node:e,tagName:n,parseResults:t,transform:o}}}De.add(e);const i=function(e,t){const n=[];for(const o of t){const t=Ee(o.inFilters,"input"),s=Ee(o.outFilters,"output");if("text"!==o.bindingType)n.push({...o,inFilters:t,outFilters:s,node:e,replaceNode:e});else{const i=e.nodeType===Node.TEXT_NODE?e:document.createTextNode("");n.push({...o,inFilters:t,outFilters:s,node:e,replaceNode:i})}}return n}(e,function(e,t){return void 0===t?e:e.map(e=>null!=e.uuid?e:t(e))}(s,o));return function(e,t){_e.set(e,t)}(e,i),me(e),{bindings:i,deferred:null}}function je(e,t){return ze(Be(e),t)}function ze(e,t){const n=[],o=[];for(const s of e){if(De.has(s))continue;const e=Fe(s,Ol(s),{allowDeferred:!0},t);null===e.deferred?n.push(...e.bindings):o.push(e.deferred)}return[e,n,o]}function qe(e){De.add(e)}function Ve(e){const{node:t,parseResults:n,transform:o}=e;!function(e){De.delete(e)}(t);return Fe(t,n,{allowDeferred:!1},o).bindings}const He=new WeakMap;let Ue=null;function Ge(e){Ue=e}function Xe(e){let t=e;for(;t;){const e=He.get(t);if(e)return e;let n=t.parentNode;null===n&&null!==Ue&&t instanceof ShadowRoot&&(n=Ue(t)),t=n}return null}function Ke(e,t){null!==t?He.set(e,t):He.delete(e)}let Qe=0;function Ye(){return`u${(Qe++).toString(36)}`}let Je=0,Ze=0;const et=Symbol("wcs.listIndex.noValue");class tt{uuid=Ye();parentListIndex;position;length;_index;_version;_indexes;_listIndexes;_chainGeneration;_homeParentListIndex;_value;cacheStamp=0;ref;constructor(e,t,n){this.parentListIndex=e,this.position=e?e.position+1:0,this.length=this.position+1,this._homeParentListIndex=n,this._value=et,this._index=t,this._version=Je,this._chainGeneration=Ze}get index(){return this._index}set index(e){this._index=e,this._version=++Je,this.indexes[this.position]=e}get version(){return this._version}get homeParentListIndex(){return this._homeParentListIndex}set homeParentListIndex(e){this._homeParentListIndex=e}get value(){return this._value}set value(e){this._value=e}get dirty(){return null!==this.parentListIndex&&(this.parentListIndex.dirty||this.parentListIndex.version>this._version)}get indexes(){return null===this.parentListIndex?void 0===this._indexes&&(this._indexes=[this._index]):(void 0===this._indexes||this.dirty)&&(this._indexes=[...this.parentListIndex.indexes,this._index],this._version=Je),this._indexes}get listIndexes(){return null===this.parentListIndex?void 0===this._listIndexes&&(this._listIndexes=[new WeakRef(this)]):void 0!==this._listIndexes&&this._chainGeneration===Ze||(this._listIndexes=[...this.parentListIndex.listIndexes,new WeakRef(this)],this._chainGeneration=Ze),this._listIndexes}get varName(){return`$${this.position+1}`}reparent(e){this.parentListIndex=e,this._indexes=void 0,this._listIndexes=void 0,this._version=++Je,Ze++}at(e){return e>=0?this.listIndexes[e]?.deref()||null:this.listIndexes[this.listIndexes.length+e]?.deref()||null}}function nt(e,t,n=e){return new tt(e,t,n)}function ot(e,t){e.reparent(t)}function st(e){return e.homeParentListIndex}function it(e,t){e.homeParentListIndex=t}function rt(e){return e?.cacheStamp}function at(e,t){const n=e,o=n.value,s=o!==et&&!Object.is(o,t);return o!==t&&(lt.get(o)?.delete(n.ref),function(e,t){if("object"!=typeof e||null===e||null===t.parentListIndex)return;let n=lt.get(e);void 0===n?(n=new Set,lt.set(e,n)):n.size>=(dt.get(n)??8)&&(ct(n,t,!0),dt.set(n,2*n.size+8));n.add(t.ref??=new WeakRef(t))}(t,n)),n.value=t,s}const lt=new WeakMap,dt=new WeakMap;function ct(e,t,n=!1){const o=[];return e?.forEach(s=>{const i=s.deref();void 0===i||n&&ft(i)?e.delete(s):i!==t&&o.push(i)}),o}const ut=new WeakSet;function ft(e){for(let t=e;null!==t;t=t.parentListIndex)if(ut.has(t))return!0;return!1}function pt(e){return e.value}function ht(e,t){const n=e.value;return n!==et&&n===t.value}let gt=0;const mt=new WeakSet;function bt(e){mt.add(e)}function wt(e){return mt.has(e)}const yt=new WeakMap;function vt(e){return ut.has(e)}const Nt=new WeakMap;function xt(e,t,n,o){if(!yt.has(e))return!1;let s=!1;for(const t in n)s||=t!==o&&n[t]===e;if(!s){let n=Nt.get(t);void 0===n&&(n=new WeakSet,Nt.set(t,n)),n.add(e)}const i=yt.get(e),r=St.get(e);if(i[0]?.parentListIndex===t&&(!s||r?.[0]!==t||r[1]!==gt))for(const n of _t.get(e)??[])if(n!==t&&n.position===t.position&&Ct(e,n)&&Object(pt(n))[o]===e){i.forEach(e=>ot(e,n)),It.set(e,[t,gt]);break}return s}const It=new WeakMap,St=new WeakMap;function kt(e,t){Nt.get(t)?.delete(e);const n=yt.get(e);if(void 0!==n){St.set(e,[t,gt]);const o=It.get(e);o?.[0]===t&&o[1]===gt&&n.forEach(e=>ot(e,t))}}function At(e,t){return!0===Nt.get(t)?.has(e)}function $t(e,t){return At(e,t)||ft(t)}const Tt=new WeakMap;function Mt(e){Tt.set(e,gt)}function Pt(e){Tt.delete(e)}function Et(e,t,n){const o=Object(pt(t)),s=pt(n);for(const t in s)if(s[t]===e&&o[t]!==e)return!1;return!0}function Ct(e,t){return!$t(e,t)&&Tt.get(t)!==gt}const _t=new WeakMap,Wt=new WeakMap;const Rt=new WeakSet;function Lt(e,t){const n=(o=e,ct(lt.get(o.value),o));var o;if(0===n.length)return n;const s=new Set(yt.get(t()));return n.filter(t=>t.position===e.position&&!s.has(t)&&!ft(t))}function Ot(e,t,n){const o=st(t),s=t.parentListIndex;return null!==o&&o!==s&&!$t(e,o)&&Et(e,o,s)?o:function(e,t,n,o){return null!==t&&null!==o&&o!==n&&!!ut.has(t)&&!(!Ct(e,o)||o.position!==t.position)&&!At(e,t)&&ht(o,t)}(e,o,s,n)||function(e,t,n){return t!==n&&null!==t&&null!==n&&t.position===n.position&&$t(e,t)&&Ct(e,n)}(e,s,n)?n:null}function Bt(e){const t=yt.get(e);return void 0===t?null:t}function Dt(e,t){const n=yt.get(e);if(void 0===n)return null;const o=n[0];if(void 0!==o&&!wt(e)){const s=null!==t&&o.parentListIndex!==t&&Tt.get(t)!==gt,i=Ot(e,o,t);if(null!==i&&Rt.has(e)){Rt.delete(e);const t=[...e];bt(t),yt.set(t,n),Gt(e,t);const o=n.map((t,n)=>{const o=nt(i,n);return at(o,e[n]),o});return yt.set(e,o),o}if(null!==i)for(const e of n)ot(e,i);else if(s){!function(e,t){let n=_t.get(e);void 0===n?(n=new Set,_t.set(e,n)):n.size>=(Wt.get(e)??8)&&(n.forEach(t=>{$t(e,t)&&n.delete(t)}),Wt.set(e,2*n.size+8));for(const e of t)n.add(e)}(e,[o.parentListIndex,t]);const s=o.parentListIndex;if(null!==s&&s.position===t.position&&!Et(e,s,t)&&Et(e,t,s))for(const e of n)ot(e,t)}}return n}const Ft=new WeakSet;function jt(e){return Ft.has(e)}function zt(e){Ft.delete(e)}function qt(e,t,n=!1){null!==t?(n?Ft.add(t):zt(t),yt.set(e,t)):yt.delete(e)}const Vt=new WeakMap;function Ht(e){let t=Vt.get(e);return void 0===t&&(t={value:e},Vt.set(e,t)),t}function Ut(e){return Vt.has(e)}function Gt(e,t){const n=Vt.get(e);void 0!==n&&(n.value=t,Vt.delete(e))}const Xt=new WeakMap,Kt=new WeakMap,Qt=new Set,Yt=new WeakMap,Jt=new WeakMap;function Zt(e){const t=e.absolutePathInfo.stateElement;let n=Kt.get(t);return void 0===n&&(n=new WeakMap,Kt.set(t,n)),n}function en(e){return Xt.get(e)??[]}function tn(e,t){const n=Xt.get(e);Xt.set(e,t),Jt.delete(e);const o=Zt(e);n!==t&&void 0!==n&&o.get(n).delete(e);const s=o.get(t);void 0===s?o.set(t,new Set([e])):s.has(e)||(s.size>=(Yt.get(s)??8)&&(s.forEach(e=>{nn(e.listIndex)&&s.delete(e)}),Yt.set(s,Math.max(8,2*s.size))),s.add(e))}function nn(e){for(let t=e;null!==t;t=t.parentListIndex)if(vt(t))return!0;return!1}function on(e,t){const n=Zt(e).get(t);return void 0===n?Qt:(n.forEach(e=>{nn(e.listIndex)&&n.delete(e)}),n)}function sn(e,t){return!Jt.has(e)&&(Jt.set(e,t),!0)}function rn(e){return Xt.has(e)}const an=new WeakMap;let ln=null,dn=0;function cn(e){return an.get(e)??[]}function un(e,t){null===ln?an.set(e,t):ln.set(e,t)}function fn(){dn++,null===ln&&(ln=new Map)}function pn(){if(0!==dn&&(dn--,!(dn>0||null===ln))){for(const[e,t]of ln)an.set(e,t);ln=null}}function hn(e){return(ln?.has(e)??!1)||an.has(e)}const gn=Symbol("$$setLoopContext"),mn=Symbol("$$getByAddress"),bn=Symbol("$$hasByAddress"),wn=Symbol("$$connectedCallback"),yn=Symbol("$$disconnectedCallback"),vn=Symbol("$$updatedCallback"),Nn=Symbol("$$errorCallback"),xn=new WeakMap,In=new WeakMap;class Sn{absolutePathInfo;listIndex;constructor(e,t){this.absolutePathInfo=e,this.listIndex=t}}function kn(e,t){if(null===t){let t=In.get(e);return void 0!==t||(t=new Sn(e,null),In.set(e,t)),t}{let n=xn.get(t);void 0===n&&(n=new WeakMap,xn.set(t,n));let o=n.get(e);return void 0!==o||(o=new Sn(e,t),n.set(e,o)),o}}const An=new WeakMap;function $n(e,t){let n=An.get(e);void 0===n&&(n=new Map,An.set(e,n));let o=n.get(t);return void 0===o&&(o=Object.freeze(new Tn(e,t)),n.set(t,o)),o}class Tn{pathInfo;stateElement;constructor(e,t){this.pathInfo=t,this.stateElement=e}}function Mn(e,t){return kn($n(e,t.pathInfo),t.listIndex)}function Pn(e,t,n){return kn($n(e,t),n)}const En=new WeakMap;function Cn(e,t){null===t?En.delete(e):En.set(e,t)}function _n(e){return En.get(e)||null}const Wn=new Map;function Rn(e,t){let n,o;if(0===e.wildcardCount||0===t.wildcardCount)return 0;if(1===e.wildcardCount&&t.wildcardCount>0&&t.wildcardPathSet.has(e.path))return 1;e.id<t.id?(n=e,o=t):(n=t,o=e);const s=`${n.path}\t${o.path}`;let i=Wn.get(s);if(void 0!==i)return i;return i=n.wildcardPathSet.intersection(o.wildcardPathSet).size,Wn.set(s,i),i}function Ln(e,t,n){return t<0||t>=n?null:e.at(t-n)}function On(e,t){const n=e.indexes??[];return n.length===t?n:n.slice(n.length-t)}const Bn=new WeakMap;function Dn(e){const t=Xe(e.node);if(null===t)return null;let n=Bn.get(t);if(void 0===n)n=new WeakMap,Bn.set(t,n);else{const t=n.get(e);if(void 0!==t)return t}let o=null;try{const n=Rn(t.pathInfo,e.statePathInfo);return n>0&&(o=Ln(t.listIndex,n-1,t.pathInfo.wildcardCount)),o}finally{n.set(e,o)}}const Fn=new WeakMap;function jn(e,t){if(null!=t)return t;let n=e.replaceNode.getRootNode();if(!1===e.replaceNode.isConnected){const t=_n(n);null===t?_(`Cannot get absolute state address for disconnected binding: ${e.bindingType} ${e.statePathName} on ${e.node.nodeName}`):n=t}return n}function zn(e,t){let n=null;if(n=Fn.get(e)||null,null!==n)return n;const o=jn(e,t),s=Dn(e),i=kl(o);return null===i&&_("No state tree found on this root for binding."),n=Pn(i,e.statePathInfo,s),Fn.set(e,n),n}function qn(e){Fn.delete(e)}const Vn=new WeakMap;function Hn(e,t){const n=Vn.get(e);void 0===n?Vn.set(e,t):n instanceof Set?n.add(t):n!==t&&Vn.set(e,new Set([n,t])),null!==N&&N({type:"state:binding-added",absoluteAddress:e,binding:t})}function Un(e,t){const n=Vn.get(e);void 0!==n&&(n instanceof Set?n.delete(t):n===t&&Vn.delete(e),null!==N&&N({type:"state:binding-removed",absoluteAddress:e,binding:t}))}const Gn=new WeakMap;function Xn(e){const t=Vn.get(e);return void 0!==t?t:null!==e.listIndex?Gn.get(e.absolutePathInfo)?.get(e.listIndex):void 0}const Kn=new WeakMap,Qn=new WeakMap;class Yn{pathInfo;listIndex;_parentAddress;_rowAddress;constructor(e,t){this.pathInfo=e,this.listIndex=t,this._rowAddress=null!==t&&e.lastSegment===x}get parentAddress(){const e=this._parentAddress;if(void 0!==e&&(!this._rowAddress||e.listIndex===this.listIndex.parentListIndex))return e;const t=this.pathInfo.parentPathInfo;if(null===t)return null;let n=null;n=this.pathInfo.segments[this.pathInfo.segments.length-1]===x?this.listIndex?.parentListIndex??null:this.listIndex;const o=Zn(t,n);return void 0!==e&&!Jn(o,this.listIndex)&&Jn(e,this.listIndex)?e:this._parentAddress=o}}function Jn(e,t){const n=e.pathInfo;let o=pt(e.listIndex);for(const e of n.segments.slice(n.wildcardPositions[n.wildcardCount-1]+1))o=Object(o)[e];return Bt(o)?.[t.index]===t}function Zn(e,t){if(null===t){let t=Qn.get(e);return void 0!==t||(t=new Yn(e,null),Qn.set(e,t)),t}{let n=Kn.get(t);void 0===n&&(n=new WeakMap,Kn.set(t,n));let o=n.get(e);return void 0!==o||(o=new Yn(e,t),n.set(e,o)),o}}const eo=new WeakMap;function to(e){let t=null;if(t=eo.get(e)||null,null!==t)return t;if(e.statePathInfo.wildcardCount>0){const n=Dn(e);null===n&&_(`Cannot resolve state address for binding with wildcard statePathName "${e.statePathName}" because list index is null.`),t=Zn(e.statePathInfo,n)}else t=Zn(e.statePathInfo,null);return eo.set(e,t),t}function no(e){eo.delete(e)}function oo(){const e=new Map,t=new Map;return{add(n,o){let s=e.get(n);return void 0===s&&(s=new WeakSet,e.set(n,s)),!s.has(o)&&(s.add(o),t.set(n,(t.get(n)??0)+1),!0)},remove(n,o){const s=e.get(n);if(void 0===s||!s.has(o))return!1;s.delete(o);const i=(t.get(n)??1)-1;return i<=0?(e.delete(n),t.delete(n),!0):(t.set(n,i),!1)},has:(t,n)=>e.get(t)?.has(n)??!1,countOf:e=>t.get(e)??0,get keyCount(){return t.size},clear(){e.clear(),t.clear()}}}const so=new Map,io=oo();function ro(e,t){const o=n(e.inFilters);return`${e.statePathName}::${t}::${o}`}function ao(e){let t="input";for(const n of e.propModifiers)n.startsWith(p)&&(t=n.slice(p.length));return t}function lo(e){if("checkbox"===e.bindingType&&-1===e.propModifiers.indexOf(I)){const o=ao(e),s=ro(e,o);let i=so.get(s);return void 0===i&&(t=e.statePathName,n=e.inFilters,i=e=>{const o=e.target;if(null===o)return void console.warn("[@wcstack/state] event.target is null.");if("checkbox"!==o.type)return void console.warn("[@wcstack/state] event.target is not a checkbox input element.");const s=o.checked;let i=o.value;for(const e of n)i=e.filterFn(i);const r=kl(o.getRootNode());null===r&&_("No state tree found on this root for two-way binding.");const a=Xe(o);r.createState("writable",e=>{e[gn](a,()=>{let n=e[t];if(Array.isArray(n))if(s)-1===n.indexOf(i)&&(e[t]=n.concat(i));else{const o=n.indexOf(i);-1!==o&&(e[t]=n.toSpliced(o,1))}else e[t]=s?[i]:[]})})},so.set(s,i)),e.node.addEventListener(o,i),io.add(s,e),!0}var t,n;return!1}function co(e){return("object"==typeof e||"function"==typeof e)&&null!==e&&"function"==typeof e.then}function uo(e,t){console.error(`[wcstack/state] ${t} rejected.`,e)}function fo(e,t){const n=Array.isArray(e)?e:[e];for(const e of n)co(e)&&Promise.resolve(e).catch(e=>uo(e,t))}class po{_name;_subscribers=new Set;constructor(e){this._name=e}get name(){return this._name}get size(){return this._subscribers.size}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}unsubscribe(e){return this._subscribers.delete(e)}emit(...e){const t=[];for(const n of this._subscribers)try{t.push(n(...e))}catch(e){t.push(void 0),console.error(`[wcstack/state] a subscriber of token "${this.name}" threw; the remaining subscribers still received it.`,e)}return t}}class ho extends po{_stateElement;constructor(e,t){super(e),this._stateElement=t}emit(...e){return null!==N&&N({type:"state:token-emit",kind:"event",tokenName:this.name,args:e,subscriberCount:this.size,stateElement:this._stateElement}),super.emit(...e)}}const go=new WeakMap;function mo(e,t){let n=go.get(e);void 0===n&&(n=new Map,go.set(e,n));let o=n.get(t);return void 0===o&&(o=new ho(t,e),n.set(t,o)),o}function bo(e){go.delete(e)}const wo=new WeakMap;function yo(e){if(e.propSegments[0]!==f)return!1;const t=e.node,n=we(t),o=ve(t);if(null!==n&&void 0===o?.get(n))return null===o&&_(`CustomElementRegistry is unavailable for <${n}>.`),!0;if(wo.has(e))return!0;const s=e.propSegments[1];"string"==typeof s&&0!==s.length||_('eventToken binding requires a property name (e.g., "eventToken.error").');const i=function(e){return null===we(e)?null:xe(e)}(t);null===i&&_(`eventToken binding requires a wc-bindable custom element. <${t.tagName.toLowerCase()}> is not wc-bindable.`);const r=i.knownProperties.get(s);void 0===r&&_(`Property "${s}" is not declared in wcBindable.properties of <${t.tagName.toLowerCase()}>.${R(s,i.knownProperties.keys())}`);const a=r.event,l=e.statePathName,d=e.propModifiers,c=e=>{d.includes(S)&&e.preventDefault(),d.includes(k)&&e.stopPropagation();const n=kl(t.getRootNode());null===n&&_("No state tree found on this root for eventToken handler."),n.eventTokenNames.has(l)||_(`[wcs/token-undeclared] eventToken "${l}" is not declared in $eventTokens.${R(l,n.eventTokenNames)}${W}`);const o=Xe(t);n.createStateAsync("writable",async t=>{fo(t[gn](o,()=>{const s=null!==o?On(o.listIndex,o.pathInfo.wildcardCount):[];return mo(n,l).emit(t,e,...s)}),`$on."${l}"`)})};return t.addEventListener(a,c),wo.set(e,{eventName:a,handler:c}),!0}class vo extends po{_stateElement;constructor(e,t){super(e),this._stateElement=t}emit(...e){return null!==N&&N({type:"state:token-emit",kind:"command",tokenName:this.name,args:e,subscriberCount:this.size,stateElement:this._stateElement}),super.emit(...e)}}function No(e){return e instanceof vo}const xo=new Map,Io=oo();function So(e){const t=e.propModifiers.filter(e=>e===S||e===k).sort().join(",");return`${e.statePathName}::${t}`}const ko=(e,t,n)=>o=>{t.includes(S)&&o.preventDefault(),t.includes(k)&&o.stopPropagation();const s=o.target,i=s.getRootNode(),r=kl(i);null===r&&_("No state tree found on this root for event handler.");const a=Xe(s),l=e.startsWith(A+".");r.createStateAsync("writable",async t=>{fo(t[gn](a,()=>{let d=null!==a?a.pathInfo.wildcardCount:0;if(null!==a){const e=r.addressHooks;if(e){const t=e.handlerScope;for(let e=0;e<t.length;e++)d=t[e](r,s,i,a,d)}}const c=null!==a?On(a.listIndex,d):[];if(l){const s=t[mn](Zn(n,null));return No(s)||_(`Event binding "${e}" did not resolve to a CommandToken. Declare the name in $commandTokens and reference it as $command.<name>.`),s.emit(o,...c)}const u=t[e];return"function"!=typeof u&&_(`Handler "${e}" is not a function on the state tree.`),Reflect.apply(u,t,[o,...c])}),`"${e}"`)}).catch(t=>uo(t,`"${e}"`))};function Ao(e){return"event"===e.bindingType&&e.propName.startsWith(p)}function $o(e){if(!Ao(e))return!1;const t=So(e);let n=xo.get(t);void 0===n&&(n=ko(e.statePathName,e.propModifiers,e.statePathInfo),xo.set(t,n));const o=e.propName.slice(2);return e.node.addEventListener(o,n),Io.add(t,e),!0}function To(e){if(!Ao(e))return!1;const t=So(e),n=xo.get(t);if(void 0===n)return!1;const o=e.propName.slice(2);return e.node.removeEventListener(o,n),0!==Io.countOf(t)&&(Io.remove(t,e)&&xo.delete(t),!0)}const Mo=new Map,Po=oo();function Eo(e,t){const o=n(e.inFilters);return`${e.statePathName}::${t}::${o}`}function Co(e){let t="input";for(const n of e.propModifiers)n.startsWith(p)&&(t=n.slice(p.length));return t}function _o(e){if("radio"===e.bindingType&&-1===e.propModifiers.indexOf(I)){const o=Co(e),s=Eo(e,o);let i=Mo.get(s);return void 0===i&&(t=e.statePathName,n=e.inFilters,i=e=>{const o=e.target;if(null===o)return void console.warn("[@wcstack/state] event.target is null.");if("radio"!==o.type)return void console.warn("[@wcstack/state] event.target is not a radio input element.");if(!1===o.checked)return;let s=o.value;for(const e of n)s=e.filterFn(s);const i=kl(o.getRootNode());null===i&&_("No state tree found on this root for two-way binding.");const r=Xe(o);i.createState("writable",e=>{e[gn](r,()=>{e[t]=s})})},Mo.set(s,i)),e.node.addEventListener(o,i),Po.add(s,e),!0}var t,n;return!1}const Wo=new Set(["radio","checkbox"]),Ro=new Set(["value","valueAsNumber","valueAsDate"]);function Lo(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return!1;const n=e,o=n.tagName.toLowerCase();if("input"===o){const e=(n.getAttribute("type")||"text").toLowerCase();if("button"===e)return!1;if(Wo.has(e)&&"checked"===t)return!0;if(Ro.has(t))return!0}if("select"===o&&"value"===t)return!0;if("textarea"===o&&"value"===t)return!0;const s=we(n);if(null!==s){const e=ve(n)?.get(s);void 0===e&&_(`Custom element <${s}> is not defined. Cannot determine if property "${t}" is suitable for two-way binding.`);const o=xe(n);if(o?.knownProperties.has(t))return!0}return!1}let Oo=1,Bo=1,Do=1;const Fo=new WeakMap;function jo(e,t,n){let o=Fo.get(e);void 0===o&&(o=new Map,Fo.set(e,o));const s=function(e,t){return`${t}::${e}`}(t,n);let i=o.get(s);return void 0===i&&(i=Oo++,o.set(s,i)),i}function zo(e,t){return"to-element"===t?2*e:2*e+1}const qo=new Set;function Vo(e){return{transactionId:Bo++,originBindingId:e,visitedEdges:qo,hop:0}}function Ho(e,t){const n=new Set(e.visitedEdges);return n.add(t),{transactionId:e.transactionId,originBindingId:e.originBindingId,visitedEdges:n,hop:e.hop+1}}let Uo=null;function Go(){return Uo}function Xo(e,t){const n=Uo;Uo=e;try{return t()}finally{Uo=n}}const Ko=[];let Qo=0;function Yo(e,t,n,o,s=!1){Qo=s?2:1;try{e.createState("writable",e=>{e[gn](t,()=>{e[n]=o})})}finally{Qo=0}}function Jo(){const e=Qo;return Qo=0,e}const Zo=new Map,es=oo(),ts=new WeakMap,ns=e=>e.detail,os=new WeakMap;const ss=new WeakMap;let is=0;const rs=new WeakMap;function as(e,t,o,s){const i=n(e.inFilters);return`${e.propName}::${e.statePathName}::${t}::${i}::${function(e){if(null===e)return"n";let t=ss.get(e);return void 0===t&&ss.set(e,t=++is),`g${t}`}(o)}::${s?"o":"s"}`}const ls=(t,n,o,s,i)=>r=>{const a=r.target;if(null===a)return void console.warn("[@wcstack/state] event.target is null.");let l;if(null!==s)l=s(r),s!==ns||i||function(e,t,n){const o=e[t];let s=null;if(void 0===n?void 0!==o&&(s=`the event carried no detail (undefined) while element.${t} is ${typeof o}`):null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==o&&"object"==typeof o||(s=`the event's detail is an object with a "${t}" key while element.${t} is ${typeof o}`),null===s)return;let i=os.get(e);void 0===i&&(i=new Set,os.set(e,i)),i.has(t)||(i.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.tagName.toLowerCase()}> "${t}": ${s}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}(a,t,l);else{if(!(t in a))return void console.warn(`[@wcstack/state] Property "${t}" does not exist on target element.`);l=a[t]}let d=l;for(const e of o)d=e.filterFn(d);const c=ts.get(a)?.get(t);if(void 0!==c)for(const e of c)e(d);let u=null;if(e.enablePropagationContext){const o=jo(a,t,n),s=function(e,t){for(let n=Ko.length-1;n>=0;n--){const o=Ko[n];if(o.node===e&&o.receipt.member===t)return o.receipt}return null}(a,t);if(null!==s&&Object.is(s.writtenValue,l))return e.debug&&console.debug("[@wcstack/state] propagation: write confirmation suppressed echo.",{node:a,propName:t,statePathName:n,transactionId:s.transactionId,coveredBySameValueGuard:e.sameValueGuard&&(null===d||"object"!=typeof d)}),void(null!==N&&N({type:"propagation:suppressed",reason:"confirmation",transactionId:s.transactionId,edgeId:zo(o,"to-state"),node:a,member:t}));const i=zo(o,"to-state"),r=Go();if(null!==r&&r.visitedEdges.has(i))return void(null!==N&&N({type:"propagation:suppressed",reason:"visited-edge",transactionId:r.transactionId,edgeId:i,node:a,member:t}));u=Ho(r??Vo(o),i)}const f=kl(a.getRootNode());null===f&&_("No state tree found on this root for two-way binding.");const p=Xe(a),h=()=>Yo(f,p,n,d,i);null!==u?Xo(u,h):h()};function ds(e){const t=we(e.node);if(null!==t){const n=ve(e.node),o=n?.get(t);if(void 0===o)return void(null===n&&_(`CustomElementRegistry is unavailable for <${t}>.`))}if(Lo(e.node,e.propName)&&-1===e.propModifiers.indexOf(I)){const t=function(e){let t="select"===e.node.tagName.toLowerCase()?"change":"input";const n=we(e.node);if(null!==n){const o=ve(e.node)?.get(n);void 0===o&&_(`Custom element <${n}> is not defined. Cannot determine event name for two-way binding.`);const s=xe(e.node)?.knownProperties.get(e.propName);s&&(t=s.event)}for(const n of e.propModifiers)n.startsWith(p)&&(t=n.slice(p.length));return t}(e),n=function(e){if(null!==we(e.node)){const t=xe(e.node)?.knownProperties.get(e.propName);if(t)return t.getter??ns}return null}(e),o=function(e){if(null===we(e.node))return!1;const t=xe(e.node)?.knownProperties.get(e.propName);return"event"===t?.semantics}(e),s=as(e,t,n,o);rs.set(e,{key:s,eventName:t});let i=Zo.get(s);void 0===i&&(i=ls(e.propName,e.statePathName,e.inFilters,n,o),Zo.set(s,i)),e.node.addEventListener(t,i),es.add(s,e)}}const cs=new WeakSet;function us(e){cs.add(e)}function fs(e){return!!cs.has(e)&&(cs.delete(e),!0)}const ps=new WeakMap;function hs(e,t){const n=ps.get(e);return!(void 0===n||n<t)&&(n===t?ps.delete(e):ps.set(e,n-t),!0)}const gs=new WeakSet;function ms(e){gs.add(e)}function bs(e){return!!gs.has(e)&&(gs.delete(e),!0)}let ws=0;function ys(){ws--}function vs(){return ws>0}class Ns{registry;entries=new Map;constructor(e){this.registry=e}wait(e,t,n=()=>{}){const o=e.toLowerCase();let s=this.entries.get(o);void 0===s&&(s={waiters:new Set},this.entries.set(o,s),this.registry.whenDefined(o).then(()=>this.settle(o,null),e=>this.settle(o,e)));const i={active:!0,resolve:t,reject:n};return s.waiters.add(i),()=>{i.active&&(i.active=!1,s?.waiters.delete(i))}}pendingCount(e){return this.entries.get(e.toLowerCase())?.waiters.size??0}settle(e,t){const n=this.entries.get(e);if(void 0===n)return;this.entries.delete(e);const o=Array.from(n.waiters);n.waiters.clear();for(const e of o)e.active&&(e.active=!1,null===t?e.resolve():e.reject(t))}}const xs=new WeakMap;function Is(e){let t=xs.get(e);return void 0===t&&(t=new Ns(e),xs.set(e,t)),t}const Ss=new Set([g,m,b,w]);function ks(e,t){let n=null;for(const o of e.propModifiers){const e=o.indexOf("=");if(e<0)continue;const s=o.slice(0,e).trim(),i=o.slice(e+1).trim();s!==$&&s!==T&&_(`Unknown binding modifier "${s}" in "${o}".`),s===t&&(null!==n&&_(`Binding modifier "${t}" may only be specified once.`),n=i)}return n}function As(e){return e.propModifiers.some(e=>e.includes("="))}const $s=Object.freeze({authority:"state",syncOn:"call",observable:!1,outputOnly:!1}),Ts=Object.freeze({authority:"none",syncOn:"call",observable:!1,outputOnly:!1});function Ms(e,t){return"state"===e&&"call"===t?$s:{authority:e,syncOn:t,observable:!1,outputOnly:!1}}function Ps(t){if(!e.enableDirectionalInitialSync)return As(t)&&_("init=/sync= modifiers require enableDirectionalInitialSync."),$s;const n=null===(o=ks(t,$))?null:"state"===o||"element"===o||"auto"===o||"none"===o?o:_(`Invalid init modifier value "${o}".`);var o;const s=function(e){return null===e||"call"===e?"call":"connect"===e?"connect":_(`Invalid sync modifier value "${e}".`)}(ks(t,T));if("event"===t.bindingType)return null!==n&&"none"!==n&&_("Event bindings only allow init=none."),"call"===s?Ts:{authority:"none",syncOn:s,observable:!1,outputOnly:!1};if(Ss.has(t.propSegments[0]))return Ms("state",s);if("prop"!==t.bindingType)return null!==n&&"state"!==n&&"none"!==n&&_(`Binding type "${t.bindingType}" does not support init=${n}.`),Ms(n??"state",s);const i=xe(t.node);if(null===i)return Ms(n??"state",s);const r=i.knownProperties.has(t.propName),a=i.declaredInputs.has(t.propName);r||a||_(`Property "${t.propName}" is not declared by wcBindable.`);const l=n??(r&&!a?"element":"state");return(r&&a?new Set(["state","element","auto","none"]):r?new Set(["element","none"]):new Set(["state","none"])).has(l)||_(`init=${l} is incompatible with wcBindable member "${t.propName}".`),"connect"!==s||r||_(`sync=connect requires observable property "${t.propName}".`),{authority:l,syncOn:s,observable:r,outputOnly:r&&!a}}function Es(e){let t=e.getRootNode();return t instanceof DocumentFragment&&!(t instanceof ShadowRoot)&&(t=_n(t)),null===t?null:kl(t)}function Cs(e,t){return"auto"!==t?t:function(e){const t=Es(e.replaceNode);null===t&&_("No state tree found on this root for binding.");const n=to(e);let o=!1;return t.createState("readonly",e=>{o=e[bn](n)}),o}(e)?"state":"element"}let _s=0,Ws=null,Rs=0;const Ls=["active","disposed","failed"],Os=new WeakMap,Bs=new WeakMap,Ds=new WeakMap,Fs=new WeakMap,js=new WeakMap,zs=new WeakMap;function qs(e,t){const n=zs.get(e);void 0!==n?n!==t&&(n instanceof Set?n.add(t):zs.set(e,new Set([n,t]))):zs.set(e,t)}function Vs(e){return zs.has(e)}function Hs(e,t){const n=zs.get(e);if(void 0!==n)if(n instanceof Set)for(const e of Array.from(n))t(e);else t(n)}function Us(e,t){if(t(e),null!==e.firstChild)for(const n of Array.from(e.childNodes))Us(n,t)}function Gs(e){if("object"!=typeof e||null===e)return!1;const t=e;return 9===t.nodeType||11===t.nodeType&&"host"in t}class Xs{root;observer;constructor(e){this.root=e;const t=globalThis.MutationObserver;this.observer="function"==typeof t?new t(e=>this.handleMutations(e)):null,this.observer?.observe(e,{childList:!0,subtree:!0})}handleMutations(e){const t=[],n=[];for(let o=0;o<e.length;o++){const s=e[o],i=s.removedNodes;if(0===i.length||!hs(s.target,i.length))for(let e=0;e<i.length;e++)t.push(i[e]);const r=s.addedNodes;for(let e=0;e<r.length;e++)n.push(r[e])}const o=[];for(const e of t)fs(e)||Us(e,e=>{Hs(e,t=>{this.root.contains(e)||t.handleRemovedNode(e)})});for(const e of n)bs(e)&&!vs()||Us(e,e=>{Hs(e,t=>{this.root.contains(e)&&t.handleAddedNode(e,o)})});o.length>0&&ll(o)}}const Ks=new WeakMap;function Qs(e){let t=Ks.get(e);return void 0===t&&(t=new Xs(e),Ks.set(e,t)),t}function Ys(e){const t=n(e.inFilters),o=n(e.outFilters);return[e.bindingType,e.propName,e.propModifiers.join(","),e.statePathName,t,o,e.uuid??""].join("\0")}function Js(e,t,n){const o=kl(jn(e,n));null===o&&_("No state tree found on this root for binding.");const s=$n(o,e.statePathInfo);return function(e,t,n){let o=Gn.get(e);void 0===o&&(o=new WeakMap,Gn.set(e,o));const s=o.get(t);void 0===s?o.set(t,n):s instanceof Set?s.add(n):s!==n&&o.set(t,new Set([s,n])),null!==N&&N({type:"state:binding-added",absoluteAddress:kn(e,t),binding:n})}(s,t,e),s}function Zs(e,t){const n=zn(e,t);return Hn(n,e),n}function ei(e,t,n,o){null!==t?Un(t,e):function(e,t,n){const o=Gn.get(e);if(void 0===o)return;const s=o.get(t);void 0!==s&&(s instanceof Set?s.delete(n):s===n&&o.delete(t),null!==N&&N({type:"state:binding-removed",absoluteAddress:kn(e,t),binding:n}))}(n,o,e),no(e),qn(e)}function ti(e,t){null===e.teardowns&&(e.teardowns=new Set),e.teardowns.add(t)}class ni{records=new Set;rowPlan=null;rows=new Set;knownBindingsByNode=new WeakMap;optionsByBinding=new WeakMap;deferredByNode=new WeakMap;deferred=new Set;disposedAt=0;constructor(e=null){null!==e&&this.observe(e)}initialize(e,t={},n){const o=t.registerAddress??!0,s={registerAddress:o,registerPathInfo:t.registerPathInfo??o,applyOnReconnect:t.applyOnReconnect??!0},i=[];for(const t of e){const e=this.remember(t,s),o=this.rowOf(e),r=null===o?-1:o.bindings.indexOf(e);if(null!==o&&0===o.phases[r]){const t=o;this.observe(e.replaceNode),s.registerAddress&&null===t.addresses[r]&&null===t.patternPathInfos[r]&&(t.registered=!0,this.registerRowSlot(t,r));continue}const a=Ds.get(e);void 0===a||"disposed"===a.phase||"failed"===a.phase?(this.start(e,s,n),i.push(e)):(this.observe(a.anchor),s.registerAddress&&null===a.address&&null===a.patternListIndex&&(a.options.registerAddress=!0,this.registerAddress(a)),"active"===a.phase&&this.settleInitialRecord(a),this.settleConnectedSnapshot(a))}return i.filter(e=>this.shouldApplyState(e))}activate(e,t){if(Gs(t)&&Qs(t),null===this.rowPlan)for(const n of e){const e=Ds.get(n);if(void 0!==e&&e.session===this&&"disposed"!==e.phase&&"failed"!==e.phase){null===e.address&&null===e.patternListIndex&&(e.options.registerAddress=!0,this.registerAddress(e,t)),"active"===e.phase&&this.settleInitialRecord(e),this.settleConnectedSnapshot(e);continue}const o=this.optionsByBinding.get(n);void 0!==o?(o.registerAddress=!0,this.start(n,o,t)):this.initialize([n],{registerAddress:!0,registerPathInfo:!1,applyOnReconnect:!1})}else this.activatePlanRows(this.rowPlan,e,t)}shouldApplyState(t){if(!e.enableDirectionalInitialSync)return As(t)&&Ps(t),!0;const n=this.rowOf(t);if(null!==n){const e=n.bindings.indexOf(t);if(e>=0){if(!n.registered)return!0;if(2===n.phases[e])return!1;const t=n.plan.slots[e];return 1&n.flags[e]?"state"===t.authority||!t.policy.outputOnly:(n.flags[e]|=1,"state"===t.authority)}}const o=Ds.get(t);return void 0===o||o.session!==this||(!o.options.registerAddress||"waiting-definition"===o.phase||"failed"!==o.phase&&("active"===o.phase&&this.settleInitialRecord(o),o.initialApplyDone?"state"===o.resolvedAuthority||!o.outputOnlyMember&&!o.observationPending:(o.initialApplyDone=!0,"state"===o.resolvedAuthority)))}getRecord(e){const t=this.rowOf(e),n=null===t?-1:t.bindings.indexOf(e);if(null!==t&&n>=0){let o=Bs.get(t);void 0===o&&Bs.set(t,o=[]);return{id:o[n]??(o[n]=++_s),info:e,generation:t.generation,phase:Ls[t.phases[n]],teardowns:null}}const o=Ds.get(e);return o?.session===this?o:null}addTeardown(e,t){const n=Ds.get(e);return!(void 0===n||!this.isAlive(n,n.generation))&&(ti(n,t),!0)}deferUntilDefined(e,t,n,o=()=>{}){const s=this.deferredByNode.get(e)??new Set,i=()=>s.delete(a)&&this.deferred.delete(a),r=()=>{const s=ve(e);null===s&&_(`CustomElementRegistry is unavailable for <${t}>.`),a.cancel=Is(s).wait(t,()=>{if(i())try{Ne(s,e),n()}catch(e){o(e)}},e=>{i()&&o(e)})},a={node:e,born:++Rs,cancel:null,arm:()=>{if(null===a.cancel&&this.deferred.has(a))try{r()}catch(e){i(),o(e)}}},l=e.getRootNode();if(null!==Ws||11===l.nodeType&&!Gs(l)){if(null===Ws){const e=Ws=[];queueMicrotask(()=>{Ws=null;for(let t=0;t<e.length;t++)e[t].arm()})}Ws.push(a)}else r();return Gs(l)&&Qs(l),qs(e,this),this.deferredByNode.set(e,s.add(a)),this.deferred.add(a),()=>{i(),a.cancel?.()}}disposeBinding(e){const t=this.rowOf(e);if(null!==t){const n=t.bindings.indexOf(e);if(n>=0)return void this.disposeRowSlot(t,n)}const n=Ds.get(e);void 0!==n&&n.session===this&&this.disposeRecord(n)}get isRowSession(){return null!==this.rowPlan}get currentRowPlan(){return this.rowPlan}disposeBindings(e){for(let t=0;t<e.length;t++)this.disposeBinding(e[t]);if(!(this.rows.size>0))for(const e of Array.from(this.deferred))e.cancel?.(),this.deferred.delete(e),this.deferredByNode.get(e.node)?.delete(e)}destroyRow(e){const t=e.length>0?this.rowOf(e[0]):null;null!==t?(this.destroyRowRecord(t),this.rows.delete(t)):this.destroyRecords()}destroyRowRecord(e){for(let t=0;t<e.bindings.length;t++){const n=e.addresses[t];null!==n&&(Un(n,e.bindings[t]),e.addresses[t]=null),e.phases[t]=1}}dispose(){this.disposedAt=Rs;for(const e of Array.from(this.rows))for(let t=0;t<e.bindings.length;t++)this.disposeRowSlot(e,t);for(const e of Array.from(this.records))this.disposeRecord(e);for(const e of Array.from(this.deferred))e.cancel?.(),this.deferred.delete(e),this.deferredByNode.get(e.node)?.delete(e)}canWholesaleDestroy(){if(this.deferred.size>0)return!1;if(0===this.records.size)return!0;for(const e of this.records)if(e.pendingDefinitions>0||e.observationPending)return!1;return!0}destroyRecords(){this.disposedAt=Rs;for(const e of this.rows)this.destroyRowRecord(e);this.rows.clear();for(const e of this.records)null!==e.address&&(Un(e.address,e.info),e.address=null),e.phase="disposed",e.teardowns=null;this.records.clear()}forEachActiveBindingNode(e){for(const t of this.rows)for(let n=0;n<t.bindings.length;n++)0===t.phases[n]&&e(t.bindings[n].node);for(const t of this.records)"active"===t.phase&&e(t.info.node)}rebindAddresses(){const e=[];for(const t of this.rows)for(let n=0;n<t.bindings.length;n++){if(0!==t.phases[n])continue;if(null===t.addresses[n]&&null===t.patternPathInfos[n])continue;const o=t.bindings[n];this.unregisterRowSlot(t,n),this.registerRowSlot(t,n),this.shouldApplyState(o)&&e.push(o)}for(const t of this.records){if("active"!==t.phase)continue;const n=t.info;if(null===t.address&&null===t.patternListIndex)continue;const o="for"===n.bindingType?zn(n):null;if(ei(n,t.address,t.patternPathInfo,t.patternListIndex),t.address=null,t.patternPathInfo=null,t.patternListIndex=null,this.registerAddress(t),null!==o){const e=zn(n);e!==o&&rn(o)&&tn(e,en(o)),e!==o&&hn(o)&&un(e,cn(o))}this.shouldApplyState(n)&&e.push(n)}return e}observe(e){const t=function(e){const t=e.getRootNode();return Gs(t)?t:null}(e);null!==t&&Qs(t)}handleMutations(e,t,n){for(const n of t)Us(n,t=>{e.contains(t)||this.handleRemovedNode(t)});const o=[];for(const t of n)Us(t,t=>{e.contains(t)&&this.handleAddedNode(t,o)});o.length>0&&ll(o)}handleRemovedNode(e){const t=this.knownBindingsByNode.get(e);if(void 0!==t)if(t instanceof Map)for(const e of t.values())this.disposeBinding(e);else this.disposeBinding(t);this.deferredByNode.get(e)?.forEach(e=>{e.cancel?.(),e.cancel=null,this.deferred.delete(e)})}handleAddedNode(e,t){this.deferredByNode.get(e)?.forEach(e=>{e.born<=this.disposedAt||(this.deferred.add(e),e.arm())});const n=this.knownBindingsByNode.get(e);if(void 0===n)return;const o=n instanceof Map?n.values():[n];for(const e of o){const n=Ds.get(e);if("active"===n?.phase){this.settleConnectedSnapshot(n);continue}if("disposed"!==n?.phase)continue;const o=this.optionsByBinding.get(e);if(void 0!==o)try{this.start(e,o),(o.applyOnReconnect||n.pendingDefinitions>0&&n.generation>this.disposedAt)&&this.shouldApplyState(e)&&t.push(e)}catch{}}}knownMapFor(e){const t=this.knownBindingsByNode.get(e);if(t instanceof Map)return t;const n=new Map;if(void 0!==t){let e=js.get(t);void 0===e&&(e=Ys(t),js.set(t,e)),n.set(e,t)}return this.knownBindingsByNode.set(e,n),n}remember(e,t){const n=e.replaceNode;qs(n,this);const o=this.knownMapFor(n);let s=js.get(e);void 0===s&&(s=Ys(e),js.set(e,s));const i=o.get(s);if(void 0!==i){const e=this.optionsByBinding.get(i);return void 0!==e&&(e.registerAddress||=t.registerAddress,e.registerPathInfo||=t.registerPathInfo,e.applyOnReconnect||=t.applyOnReconnect),i}return o.set(s,e),this.optionsByBinding.set(e,{...t}),e}initializeRow(e,t){this.rowPlan=e;const n=e.slots,o=t.length,s={id:++_s,session:this,generation:++Rs,plan:e,bindings:t,registered:!1,phases:new Array(o).fill(0),flags:new Array(o).fill(0),addresses:new Array(o).fill(null),patternPathInfos:new Array(o).fill(null),patternListIndexes:new Array(o).fill(null)};this.rows.add(s);for(let e=0;e<o;e++){const o=t[e],i=o.replaceNode;if(qs(i,this),this.addKnownRowBinding(i,o,e),Os.set(o,s),n[e].isEvent){let t=!1;try{t=$o(o)}catch(t){throw s.phases[e]=2,t}t&&(s.flags[e]|=2)}}}activatePlanRows(e,t,n){const o=t.length>0?this.rowOf(t[0]):null;if(null===o||o.bindings!==t){for(const e of t)this.initialize([e],{registerAddress:!0,registerPathInfo:!1,applyOnReconnect:!1});return}o.registered=!0;const s=e.slots;let i=!1;for(let e=0;e<t.length;e++)if(0===o.phases[e])null===o.addresses[e]&&null===o.patternPathInfos[e]&&this.registerRowSlot(o,e,n);else{if(i||(o.generation=++Rs,i=!0,this.rows.add(o)),o.phases[e]=0,o.flags[e]=0,s[e].isEvent){let n=!1;try{n=$o(t[e])}catch(t){throw o.phases[e]=2,this.runRowSlotTeardowns(o,e),t}n&&(o.flags[e]|=2)}this.registerRowSlot(o,e,n)}}rowOf(e){const t=Os.get(e);return void 0!==t&&t.session===this?t:null}registerRowSlot(e,t,n){if(null!==e.addresses[t]||null!==e.patternPathInfos[t])return;const o=e.bindings[t],s=Dn(o);null!==s?(e.patternPathInfos[t]=Js(o,s,n),e.patternListIndexes[t]=s):e.addresses[t]=Zs(o,n)}unregisterRowSlot(e,t){const n=e.addresses[t],o=e.patternPathInfos[t];null===n&&null===o||(ei(e.bindings[t],n,o,e.patternListIndexes[t]),e.addresses[t]=null,e.patternPathInfos[t]=null,e.patternListIndexes[t]=null)}disposeRowSlot(e,t){if(1!==e.phases[t]){e.phases[t]=1,this.runRowSlotTeardowns(e,t);for(let t=0;t<e.phases.length;t++)if(0===e.phases[t])return;this.rows.delete(e)}}runRowSlotTeardowns(e,t){try{this.unregisterRowSlot(e,t)}catch{}if(2&e.flags[t]){e.flags[t]&=-3;try{To(e.bindings[t])}catch{}}}addKnownRowBinding(e,t,n){const o=this.knownBindingsByNode.get(e);if(void 0===o)return void this.knownBindingsByNode.set(e,t);if(o instanceof Map)return void o.set("@plan:"+n,t);const s=new Map;s.set("@plan:first",o),s.set("@plan:"+n,t),this.knownBindingsByNode.set(e,s)}start(e,t,n){!function(e){const t=e.node,n=e.replaceNode;t!==n&&null!==t.parentNode&&t.parentNode.replaceChild(n,t)}(e);const o=this.optionsByBinding.get(e)??{...t},s={id:++_s,info:e,generation:++Rs,phase:"discovered",teardowns:null,session:this,anchor:e.replaceNode,options:o,address:null,patternPathInfo:null,patternListIndex:null,pendingDefinitions:0,initialPolicy:null,resolvedAuthority:null,initialSettled:!1,initialApplyDone:!1,outputOnlyMember:!1,observationPending:!1,eventSequence:0,hasProducerValue:!1,producerValue:void 0,eventAttached:!1,twowayAttached:!1};Ds.set(e,s),this.records.add(s),void 0===n&&this.observe(s.anchor);try{s.phase="attaching",this.attachListeners(s),s.options.registerAddress&&this.registerAddress(s,n),0===s.pendingDefinitions&&(s.phase="active")}catch(e){throw s.phase="failed",this.runTeardowns(s),this.records.delete(s),e}}attachListeners(t){const n=t.info;$o(n)?t.eventAttached=!0:n.propSegments[0]!==f?(_o(n)&&ti(t,()=>function(e){if("radio"===e.bindingType&&-1===e.propModifiers.indexOf(I)){const t=Co(e),n=Eo(e,t),o=Mo.get(n);return void 0!==o&&(e.node.removeEventListener(t,o),0!==Po.countOf(n)&&(Po.remove(n,e)&&Mo.delete(n),!0))}return!1}(n)),lo(n)&&ti(t,()=>function(e){if("checkbox"===e.bindingType&&-1===e.propModifiers.indexOf(I)){const t=ao(e),n=ro(e,t),o=so.get(n);return void 0!==o&&(e.node.removeEventListener(t,o),0!==io.countOf(n)&&(io.remove(n,e)&&so.delete(n),!0))}return!1}(n)),this.attachAfterDefinition(t,()=>{if(e.enableDirectionalInitialSync&&Lo(n.node,n.propName)&&-1===n.propModifiers.indexOf(I)){const e=function(e,t,n){let o=ts.get(e);void 0===o&&(o=new Map,ts.set(e,o));let s=o.get(t);return void 0===s&&(s=new Set,o.set(t,s)),s.add(n),()=>{s?.delete(n),0===s?.size&&o?.delete(t),0===o?.size&&ts.delete(e)}}(n.node,n.propName,e=>{this.isAlive(t,t.generation)&&(t.eventSequence+=1,t.hasProducerValue=!0,t.producerValue=e)});ti(t,e)}ds(n),t.twowayAttached=!0})):this.attachAfterDefinition(t,()=>{yo(n)&&ti(t,()=>function(e){if(e.propSegments[0]!==f)return!1;const t=wo.get(e);return void 0!==t&&(e.node.removeEventListener(t.eventName,t.handler),wo.delete(e),!0)}(n))})}attachAfterDefinition(e,t){const n=we(e.info.node);if(null===n)return void t();const o=ve(e.info.node);if(null===o&&_(`CustomElementRegistry is unavailable for <${n}>.`),void 0!==o.get(n))return void t();e.phase="waiting-definition",e.pendingDefinitions+=1;const s=e.generation;ti(e,this.deferUntilDefined(e.info.node,n,()=>{this.isAlive(e,s)&&(t(),e.pendingDefinitions-=1,0===e.pendingDefinitions&&(e.phase="active",this.settleInitialRecord(e)))},()=>{this.isAlive(e,s)&&(e.phase="failed",this.runTeardowns(e),this.records.delete(e))}))}settleInitialRecord(t){if(e.enableDirectionalInitialSync&&!t.initialSettled&&t.options.registerAddress){t.phase="synchronizing";try{const e=Ps(t.info),n=Cs(t.info,e.authority);if(t.initialPolicy=e,t.resolvedAuthority=n,t.initialSettled=!0,t.outputOnlyMember=e.outputOnly,t.phase="active",!e.observable)return;if("connect"===e.syncOn&&t.info.node instanceof HTMLElement&&!t.info.node.isConnected)return t.observationPending=!0,void ws++;this.readProducerSnapshot(t,"call"===e.syncOn)}catch(e){throw t.phase="failed",this.runTeardowns(t),this.records.delete(t),e}}}readProducerSnapshot(e,t){if(!this.isAlive(e,e.generation))return;const n=e.info.node,o=e.info.propName;if(!(o in n))return;const s=e.eventSequence,i=n[o];e.observationPending&&(e.observationPending=!1,ys()),t&&e.eventSequence!==s||(e.hasProducerValue=!0,e.producerValue=i,"element"===e.resolvedAuthority&&function(e,t){let n=t;for(const t of e.inFilters)n=t.filterFn(n);const o=Es(e.node);null===o&&_("No state tree found on this root for initial binding sync."),Yo(o,Xe(e.node),e.statePathName,n)}(e.info,i))}settleConnectedSnapshot(t){if(e.enableDirectionalInitialSync&&t.observationPending&&t.info.node instanceof HTMLElement&&t.info.node.isConnected)try{this.readProducerSnapshot(t,!1)}catch{t.phase="failed",this.runTeardowns(t),this.records.delete(t)}}registerAddress(e,t){if(null!==e.address||null!==e.patternListIndex)return;const n=e.info,o=Dn(n);if(null!==o?(e.patternPathInfo=Js(n,o,t),e.patternListIndex=o):e.address=Zs(n,t),!e.options.registerPathInfo)return;const s=kl(n.replaceNode.getRootNode());null===s&&_("No state tree found on this root for binding."),"event"!==n.bindingType&&s.setPathInfo(n.statePathName,n.bindingType)}isAlive(e,t){return e.generation===t&&Ds.get(e.info)===e&&"disposed"!==e.phase&&"failed"!==e.phase}disposeRecord(e){"disposed"!==e.phase&&(e.phase="disposed",this.runTeardowns(e),this.records.delete(e))}runTeardowns(e){e.observationPending&&(e.observationPending=!1,ys());const t=e.info;if(null!==e.address||null!==e.patternListIndex)try{ei(t,e.address,e.patternPathInfo,e.patternListIndex),e.address=null,e.patternPathInfo=null,e.patternListIndex=null}catch{}if(e.twowayAttached){e.twowayAttached=!1;try{!function(e){const t=rs.get(e);if(void 0===t)return;rs.delete(e);const n=Zo.get(t.key);void 0!==n&&(e.node.removeEventListener(t.eventName,n),es.remove(t.key,e)&&Zo.delete(t.key))}(t)}catch{}}if(null!==e.teardowns){const t=Array.from(e.teardowns).reverse();e.teardowns=null;for(const e of t)try{e()}catch{}}if(e.eventAttached){e.eventAttached=!1;try{To(t)}catch{}}}}function oi(e){let t=Fs.get(e);return void 0===t&&(t=new ni(e),Fs.set(e,t)),t}function si(e){return Ds.get(e)?.session??Os.get(e)?.session??null}let ii=null;function ri(e){ii=e}function ai(e,t){let n=e;for(const e of t)n=e.filterFn(n);return n}const li=Object.freeze([]);const di=new WeakMap;const ci=new WeakMap;function ui(e){return ci.get(e)??[]}function fi(e,t){ci.set(e,t)}const pi=new WeakMap;function hi(e){return pi.get(e)??[]}function gi(e,t){pi.set(e,t)}function mi(e,t){const n=hi(e);for(const e of n)Ke(e,t)}const bi=new WeakMap;function wi(e){return bi.get(e)??[]}function yi(e,t){bi.set(e,t)}Set.prototype.difference||(Set.prototype.difference=function(e){const t=new Set(this);for(const n of e)t.delete(n);return t}),Set.prototype.intersection||(Set.prototype.intersection=function(e){const t=new Set;for(const n of e)this.has(n)&&t.add(n);return t});const vi=new WeakMap,Ni=new WeakSet;function xi(e){return vi.get(e)??null}function Ii(e,t){if(null===t)vi.delete(e);else{vi.set(e,t);const{stateElement:n,pathInfo:o}=e.absolutePathInfo;if(o.wildcardCount>0){for(let e=o.parentPathInfo;null!==e&&e.wildcardCount===o.wildcardCount&&!Ni.has(e);e=e.parentPathInfo)Ni.add(e);n.setPathInfo(o.lastWildcardPath,"prop","internal")}}}function Si(e){const t=vi.get(e);t&&(t.dirty=!0),null!==e.listIndex&&Ni.has(e.absolutePathInfo.pathInfo)&&e.listIndex.cacheStamp++}const ki=Symbol.for("wcstack.transition-runner");function Ai(e){const t=globalThis[ki];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run?null:"function"==typeof t.accepts&&t.accepts(e)?t:null}function $i(e,t,n){const o=Ai(e);if(null!==o)return o.run(t,{source:e,types:n});t()}const Ti=[],Mi=[];let Pi=-1,Ei=0,Ci=!1;function _i(e){Mi.includes(e)||Mi.push(e)}function Wi(e,t=0){const n=Ti.findIndex(e=>e.priority>t),o={listener:e,priority:t};-1===n?Ti.push(o):Ti.splice(n,0,o)}function Ri(e){const t=Ti.findIndex(t=>t.listener===e);-1!==t&&Ti.splice(t,1)}function Li(e){queueMicrotask(()=>{throw e})}class Oi{_queueUpdateRecords=[];_queueRenderOnlyAddresses=[];constructor(){}enqueueAbsoluteAddress(e,t=null){for(let t=0;t<Mi.length;t++)Mi[t](e);Pi>Ei&&(Ei=Pi),Pi<0&&(Ci=!0);const n=this._isQueueEmpty();this._queueUpdateRecords.push({absoluteAddress:e,context:t}),n&&this._scheduleDrain()}enqueueRenderOnlyAddress(e){const t=this._isQueueEmpty();this._queueRenderOnlyAddresses.push(e),t&&this._scheduleDrain()}_isQueueEmpty(){return 0===this._queueUpdateRecords.length&&0===this._queueRenderOnlyAddresses.length}_scheduleDrain(){fn(),queueMicrotask(()=>{const e=this._queueUpdateRecords,t=this._queueRenderOnlyAddresses;this._queueUpdateRecords=[],this._queueRenderOnlyAddresses=[],gt++,this._applyChange(e,t)})}hasQueuedPath(e,t){return this._queueUpdateRecords.some(n=>n.absoluteAddress.absolutePathInfo.stateElement===e&&n.absoluteAddress.absolutePathInfo.pathInfo.path===t)}testApplyChange(e,t){this._applyChange(e.map((e,n)=>({absoluteAddress:e,context:t?.[n]??null})))}_applyChange(e,t=[]){let n=Ci?0:Ei;Ei=0,Ci=!1;const s=new Map,i=new Set;for(let t=0;t<e.length;t++){const n=e[t],o=s.get(n.absoluteAddress);null!==N&&null!=o&&null!==n.context&&o.transactionId!==n.context.transactionId&&N({type:"propagation:coalesced",absoluteAddress:n.absoluteAddress,droppedTransactionId:o.transactionId,winnerTransactionId:n.context.transactionId}),s.set(n.absoluteAddress,n.context),i.add(n.absoluteAddress)}for(let e=0;e<t.length;e++){const n=t[e];s.has(n)||s.set(n,null)}const r=[],a=new Map;s.forEach((e,t)=>{if(null!==e&&e.hop>=M)return console.error("[@wcstack/state] propagation hop limit exceeded; update record quarantined.",{path:t.absolutePathInfo.pathInfo.path,transactionId:e.transactionId,hop:e.hop,maxHops:M}),void(null!==N&&N({type:"propagation:hop-limit",absoluteAddress:t,transactionId:e.transactionId,hop:e.hop}));const n=Xn(t);if(void 0!==n)if(n instanceof Set)for(const t of n)!1!==t.replaceNode.isConnected&&(r.push(t),null!==e&&a.set(t,e));else!1!==n.replaceNode.isConnected&&(r.push(n),null!==e&&a.set(n,e))});try{const e=()=>{Pi=n+1;try{a.size>0?ll(r,a):ll(r)}finally{Pi=-1}};if(n>P&&r.length>0){if(n++===P+1){const e=[...new Set(Array.from(i,e=>e.absolutePathInfo.pathInfo.path))];console.error("[@wcstack/state] render chain depth limit exceeded; bindings for this batch were not applied.",{maxDepth:P,paths:e}),null!==N&&N({type:"state:render-chain-limit",maxDepth:P,paths:e})}}else if(o()||0===r.length)e();else{const t=$i("state",e);void 0!==t&&t.catch(Li)}}finally{pn(),Pi=n,function(e){for(const t of Ti.slice())t.listener(e)}(i),Pi=-1}}}const Bi=new Oi;function Di(){return Bi}const Fi=new WeakMap,ji=new WeakMap,zi=new WeakMap,qi=new WeakMap;let Vi=!1;const Hi=new WeakMap;function Ui(e){const t=e.absolutePathInfo.stateElement;let n=Hi.get(t);void 0===n&&Hi.set(t,n=new Set),n.add(e)}function Gi(e){const t=Hi.get(e);return void 0===t?null:(Hi.delete(e),t)}const Xi=new WeakMap,Ki=new WeakMap,Qi=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,Zi=[];function er(e,t){const n=tr(e);if(n.recorded.has(t))return;n.recorded.add(t);const o=d(t).cumulativePaths;if(o.length<2)return;let s=Ji.get(e);void 0===s&&Ji.set(e,s=new Map);for(let e=0;e<o.length-1;e++){let n=s.get(o[e]);void 0===n&&s.set(o[e],n=new Set),n.add(t)}}function tr(e){let t=Fi.get(e);return void 0===t&&Fi.set(e,t={byPath:new Map,lastValue:new Map,recorded:new Set,tracked:new Set}),t}function nr(e,t,n){let o=e.get(t);void 0===o&&e.set(t,o=new Set),o.add(n)}function or(e,t,n){const o=e.get(t);o.delete(n),0===o.size&&e.delete(t)}function sr(e,t,n,o){const s=function(e,t){let n=e.byPath.get(t);return void 0===n&&e.byPath.set(t,n=new Map),n}(e,t);let i=ji.get(o);if(void 0===i&&ji.set(o,i=new Map),i.has(t)){const e=i.get(t);return Object.is(e,n)||(or(s,e,o),i.set(t,n),nr(s,n,o)),!1}return i.set(t,n),nr(s,n,o),!0}function ir(e,t,n){const o=e.get(t);return void 0===o?(e.set(t,[n]),!0):(o.push(n),!1)}function rr(e,t,n,o,s,i){e.lastValue.set(t,n),s&&(null!==o.listIndex&&ir(zi,o.listIndex,i)&&function(e){for(let t=e.parentListIndex;null!==t;t=t.parentListIndex){let n=Qi.get(t);void 0===n&&Qi.set(t,n=new Set),n.add(e)}}(o.listIndex),null!==i.levelListIndex&&ir(qi,i.levelListIndex,i))}function ar(e,t,n,o,s){Vi=!0;const i=tr(e);er(e,t);rr(i,t,s,o,sr(i,t,n,o),{stateElement:e,path:t,absAddress:o,levelListIndex:null})}function lr(e,t,n,o,s){Vi=!0;const i=tr(e);er(e,t);rr(i,t,s,o,sr(i,t,n.index,o),{stateElement:e,path:t,absAddress:o,levelListIndex:n})}function dr(e,t){tr(e).tracked.add(t)}function cr(e){const t=Fi.get(e);return void 0===t?null:{byPath:t.byPath,lastValue:t.lastValue,tracked:t.tracked,watchers:Xi.get(e)}}function ur(e,t){return!0===Fi.get(e)?.byPath.has(t)||!0===Xi.get(e)?.has(t)}function fr(e,t,n,o,s){Vi=!0,tr(e).lastValue.set(t,s),er(e,t);let i=Xi.get(e);void 0===i&&Xi.set(e,i=new Map);let r=i.get(t);void 0===r&&i.set(t,r=new Set);let a,l=Ki.get(o);if(void 0===l?(Ki.set(o,l=[]),zt(o)):a=l.find(n=>n.stateElement===e&&n.path===t),void 0===a){a={stateElement:e,path:t,indexes:o,getters:new Set},l.push(a),r.add(a);const n=o[0]?.parentListIndex??null;if(null!==n){let e=Yi.get(n);void 0===e&&Yi.set(n,e=new Set),e.add(a)}}a.getters.add(n)}function pr(e,t,n){if("number"!=typeof t)return;const o=e.indexes[t];if(void 0!==o)for(const t of e.getters)n.push(Mn(e.stateElement,Zn(t,o)))}function hr(e,t){if(!Vi||e===t)return;const n=Ki.get(e);if(void 0===n)return;Ki.delete(e);const o=Ki.get(t);Ki.set(t,void 0===o?n:o.concat(n)),zt(t);for(const o of n){o.indexes=t;const n=tr(o.stateElement).lastValue.get(o.path);if("number"!=typeof n)continue;const s=e[n],i=t[n];if(s!==i)for(const e of[s,i])if(void 0!==e&&!vt(e))for(const t of o.getters){const n=Mn(o.stateElement,Zn(t,e));Si(n),Di().enqueueAbsoluteAddress(n,null),Ui(n)}}}function gr(e,t){if(void 0!==e)for(const n of e)t.push(n)}function mr(e,t,n,o,s){const i=Fi.get(e),r=i?.byPath.get(t),a=Xi.get(e)?.get(t);if(void 0===i||void 0===r&&void 0===a)return Zi;const l=i.lastValue.has(t),d=i.lastValue.get(t);i.lastValue.set(t,s);const c=[],u=!n||!Object.is(o,s),f=l&&(!n||!Object.is(d,o))&&!Object.is(d,s);if(void 0!==r&&(n&&gr(r.get(o),c),f&&gr(r.get(d),c),u&&gr(r.get(s),c)),void 0!==a)for(const e of a)n&&pr(e,o,c),f&&pr(e,d,c),u&&pr(e,s,c);return c}function br(e,t){return!0===Ji.get(e)?.has(t)}function wr(e,t){let n=e;for(const e of t){if("object"!=typeof n||null===n)return;n=n[e]}return n}function yr(e,t,n,o,s=!0){const i=d(t).segments.length,r=[];for(const a of Ji.get(e).get(t)){const t=d(a).segments.slice(i);if(t.includes(x)){vr(e,a,r);continue}const l=s?wr(n,t):void 0;for(const n of mr(e,a,s,l,wr(o,t)))r.push(n)}return r}function vr(e,t,n){const o=Fi.get(e).byPath.get(t);if(void 0!==o)for(const e of o.values())gr(e,n);const s=Xi.get(e)?.get(t);if(void 0!==s)for(const e of s)for(let t=0;t<e.indexes.length;t++)pr(e,t,n)}function Nr(e){const t=qi.get(e.levelListIndex),n=t.indexOf(e);t.splice(n,1)}function xr(e){const t=zi.get(e);if(void 0!==t){zi.delete(e),function(e){for(let t=e.parentListIndex;null!==t;t=t.parentListIndex){const n=Qi.get(t);void 0!==n&&(n.delete(e),0===n.size&&Qi.delete(t))}}(e);for(const e of t){const{stateElement:t,path:n,absAddress:o}=e,s=ji.get(o),i=s.get(n);s.delete(n),or(Fi.get(t).byPath.get(n),i,o),null!==e.levelListIndex&&Nr(e)}}}function Ir(e){const t=Yi.get(e);if(void 0!==t){Yi.delete(e);for(const e of t){const t=Xi.get(e.stateElement),n=t.get(e.path);n.delete(e),0===n.size&&t.delete(e.path);const o=Ki.get(e.indexes);o.splice(o.indexOf(e),1),0===o.length&&Ki.delete(e.indexes)}}}function Sr(e){if(!Vi)return;xr(e),Ir(e);const t=Qi.get(e);if(void 0!==t){Qi.delete(e);for(const e of t)xr(e),Ir(e),Qi.delete(e)}}function kr(e,t,n){if(!Vi)return;const o=qi.get(e);if(void 0!==o)for(const{stateElement:e,path:s,absAddress:i}of o){const o=Fi.get(e),r=o.byPath.get(s);or(r,t,i),nr(r,n,i),ji.get(i).set(s,n);const a=o.lastValue.get(s);(Object.is(a,t)||Object.is(a,n))&&(Si(i),Di().enqueueAbsoluteAddress(i,null),Ui(i))}}const Ar=new WeakMap,$r=Object.freeze([]),Tr=new Set,Mr=new WeakMap,Pr=new WeakMap;function Er(e,t){Pr.set(e,new WeakRef(Object(t)))}function Cr(e){return Pr.get(e)?.deref()}function _r(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Wr(e){!function(e){for(const t of e)ut.add(t)}(e);for(const t of e)Sr(t)}function Rr(e,t,n){const o=function(e,t,n){const o=Array.isArray(t)&&t.length>0?t:$r,s=Array.isArray(n)&&n.length>0?n:$r,i=function(e,t){const n=Array.isArray(e)&&e.length>0?e:$r,o=Array.isArray(t)&&t.length>0?t:$r;let s=Ar.get(n);return s&&s.get(o)||null}(o,s);if(i&&i.newIndexes===Dt(s,e))return i;const r=Dt(o,e)||[];let a;try{if(0===s.length)return a={oldIndexes:r,newIndexes:[],changeIndexSet:Tr,deleteIndexSet:new Set(r),addIndexSet:Tr};let t=Dt(s,e);if(null===t&&null!==e&&function(e,t){const n=_t.get(e);for(const o of n??[])if($t(e,o))n.delete(o);else if(o!==t)return!0;return!1}(o,e)&&Er(s,o),0===o.length||null===t&&Cr(s)===o){if(null===t){t=[];for(let n=0;n<s.length;n++){const o=nt(e,n);t.push(o)}}return a={oldIndexes:r,newIndexes:t,changeIndexSet:Tr,deleteIndexSet:new Set(r),addIndexSet:new Set(t)}}if(_r(o,s)&&(t??r)===r)return o!==s&&Lr(o,r,e),a={oldIndexes:r,newIndexes:r,changeIndexSet:Tr,deleteIndexSet:Tr,addIndexSet:Tr};if(null!==t)return Or(r,t);t=[];const n=new Map;for(let e=0;e<o.length;e++){const t=o[e];let s=n.get(t);s||(s=[],n.set(t,s)),s.push(e)}const i=new Set,l=new Set;let d=!1;for(let o=0;o<s.length;o++){const a=s[o],c=n.get(a),u=c&&c.length>0?c.shift():void 0;if(void 0===u){const n=nt(e,o);t.push(n),l.add(n)}else{const e=r[u];d=!0,u!==o&&i.add(e),t.push(e)}}d&&Lr(o,t,e);return a={oldIndexes:r,newIndexes:t,changeIndexSet:i,deleteIndexSet:new Set(r).difference(new Set(t)),addIndexSet:l}}finally{void 0!==a&&(!function(e,t,n){let o=Ar.get(e);o||(o=new WeakMap,Ar.set(e,o)),o.set(t,n)}(o,s,a),zt(r),qt(s,a.newIndexes))}}(e,t,n);return function(e,t){const n=e.newIndexes;let o;for(let e=0;e<n.length;e++){if(n[e].index!==e){const t=n[e].index;n[e].index=e,kr(n[e],t,e)}at(n[e],t[e])&&(o??=[]).push(n[e])}const s=Mr.get(t);s?.[0]===gt&&(o=o?s[1].concat(o):s[1]),o&&Mr.set(t,[gt,o]),e.valueChangeIndexes=o}(o,Array.isArray(n)&&n.length>0?n:$r),function(e){for(const t of e)ut.delete(t)}(o.newIndexes),Cr(n)!==t&&(Wr(o.deleteIndexSet),hr(o.oldIndexes,o.newIndexes)),o}function Lr(e,t,n){var o;if(o=e,Rt.add(o),null!==n)for(const e of t)it(e,n)}function Or(e,t){const n=new Set(t),o=new Set(e),s=new Set,i=n.difference(o),r=o.difference(n),a=new Map;for(let t=0;t<e.length;t++)a.set(e[t],t);for(let e=0;e<t.length;e++){const n=t[e];i.has(n)||a.get(n)!==e&&s.add(n)}return{oldIndexes:e,newIndexes:t,changeIndexSet:s,deleteIndexSet:r,addIndexSet:i}}function Br(e){if(0===e.changeIndexSet.size||e.addIndexSet.size===e.newIndexes.length)return null;const t=new Map;for(let n=0;n<e.oldIndexes.length;n++)t.set(e.oldIndexes[n],n);const n=[],o=[];let s=-1,i=!0;for(const r of e.newIndexes){if(e.addIndexSet.has(r))continue;const a=t.get(r);if(void 0===a)return null;a<s&&(i=!1),s=a,n.push(r),o.push(a)}if(i)return null;const r=function(e){const t=e.length,n=[],o=new Array(t).fill(-1);for(let s=0;s<t;s++){const t=e[s];let i=0,r=n.length;for(;i<r;){const o=i+r>>1;e[n[o]]<t?i=o+1:r=o}i>0&&(o[s]=n[i-1]),n[i]=s}const s=[];let i=n.length>0?n[n.length-1]:-1;for(;i>=0;)s.push(i),i=o[i];return s.reverse(),s}(o),a=new Set;for(const e of r)a.add(n[e]);return a}const Dr=new WeakMap;function Fr(e){return Dr.get(e)??null}function jr(e,t){Dr.set(e,t)}const zr=new WeakMap;const qr=new WeakMap;function Vr(e,t){for(let n=0;n<e.length;n++)if(t.has(e[n]))return!0;return!1}function Hr(e,t,n,o,s){const i=function(e,t,n){let o=qr.get(e);void 0===o&&qr.set(e,o=new Map);const s=o.get(n);if(void 0!==s)return s;const i=n+".",r=t.map((t,o)=>{const s=e.slots[o];if(s.isEvent||s.isIndexBinding)return null;const r=t.statePathInfo.path;if(!r.startsWith(i))return null;const a=r.slice(i.length).split("."),l=[];let d=n;for(const e of a){if("*"===e)return null;d+="."+e,l.push(d)}return{tail:a,prefixes:l}});return o.set(n,r),r}(e,t,o.pathInfo.path),r=s.stateElement.getterPaths,a=0!==(s.stateElement.addressHooks?.readMissing.length??0);let l,d=!1;for(let e=0;e<t.length;e++){const c=t[e];if(!n.shouldApplyState(c))continue;const u=i[e];if(null===u||Vr(u.prefixes,r)){rl(c,s);continue}if(s.appliedBindingSet.has(c))continue;d||(l=s.state[mn](o),d=!0);const f=u.tail;let p=l,h=!1;for(let e=0;e<f.length;e++){if(null==p){p=void 0;break}if(a&&!(f[e]in Object(p))){h=!0;break}p=p[f[e]]}h?rl(c,s):(s.appliedBindingSet.add(c),il(c,s,p))}}function Ur(e,t,n){mi(e,t);const o=ui(e),s=Fr(e);if(null!==s&&(s.activate(o,n.rootNode),null!==t&&!1===n.stateElement.hasUpdatedCallback&&!0!==n.stateElement.hasRecursion)){const i=function(e){return zr.get(e)??null}(e);if(null!==i)return void Hr(i,o,s,t,n)}for(const e of o){if(null===s){Hn(zn(e),e)}(null===s||s.shouldApplyState(e))&&rl(e,n)}e.spreads&&dl(e.spreads,t,s,o,wi(e))}function Gr(e){if(!e.mounted)return;const t=ui(e),n=Fr(e);for(let e=0;e<t.length;e++){const o=t[e];if(null!==n)n.disposeBinding(o);else{Un(zn(o),o)}}!function(e){const t=hi(e);for(let e=0;e<t.length;e++)Ke(t[e],null)}(e)}function Xr(){return Object.freeze(new Set)}const Kr=new WeakMap,Qr=Xr();function Yr(e,t){const n=Kr.get(e);n?n.add(t):Kr.set(e,new Set([t]))}function Jr(e){const t=Kr.get(e);return void 0!==t?t:Qr}function Zr(e,t){const n=Kr.get(e);n&&(n.delete(t),0===n.size&&Kr.delete(e))}const ea=new Set(["if","elseif","else","for"]);class ta{_content;_childNodeArray=[];_firstNode=null;_lastNode=null;_mounted=!1;_ranged=!1;constructor(e,t=!1){this._content=e,this._ranged=t;const n=[];for(let t=e.firstChild;null!==t;t=t.nextSibling)n.push(t);this._childNodeArray=n,this._firstNode=this._childNodeArray.length>0?this._childNodeArray[0]:null,this._lastNode=this._childNodeArray.length>0?this._childNodeArray[this._childNodeArray.length-1]:null}get firstNode(){return this._firstNode}get lastNode(){return this._lastNode}get mounted(){return this._mounted}appendTo(e){const t=this._childNodeArray;for(let n=0;n<t.length;n++){const o=t[n];ms(o),e.appendChild(o)}this._mounted=!0}_movableNodes(){if(!this._ranged||!this._mounted)return this._childNodeArray;const e=this._firstNode,t=this._lastNode;if(null===e||null===t||null===e.parentNode)return this._childNodeArray;const n=[];for(let o=e;null!==o;o=o.nextSibling)if(n.push(o),o===t)return n;return this._childNodeArray}mountAfter(e){const t=e.parentNode;if(t){let n=e;for(const e of this._movableNodes()){if(n.nextSibling!==e){ms(e);const o=t;e.parentNode===t&&"function"==typeof o.moveBefore?o.moveBefore(e,n.nextSibling):t.insertBefore(e,n.nextSibling)}n=e}}this._mounted=!0}tryDestroy(){const e=Fr(this);if(null===e||!e.canWholesaleDestroy())return!1;e.destroyRow(ui(this));const t=this._childNodeArray;for(let e=0;e<t.length;e++){const n=t[e];null!==n.parentNode&&(us(n),n.parentNode.removeChild(n))}const n=ui(this);for(let e=0;e<n.length;e++){const t=n[e];ea.has(t.bindingType)&&Jr(t.node).forEach(e=>{e.tryDestroy()||e.unmount()})}return this._mounted=!1,!0}unmountInPlace(){{const e=Fr(this);null!==e&&(e.isRowSession?e.disposeBindings(ui(this)):e.dispose())}this._teardownBindings()}_teardownBindings(){const e=ui(this);for(let t=0;t<e.length;t++){const n=e[t];ea.has(n.bindingType)&&Jr(n.node).forEach(e=>{e.unmount()}),no(n),qn(n)}}unmount(){{const e=Fr(this);null!==e&&(e.isRowSession?e.disposeBindings(ui(this)):e.dispose())}for(const e of this._childNodeArray)null!==e.parentNode&&(us(e),e.parentNode.removeChild(e));const e=ui(this);for(let t=0;t<e.length;t++){const n=e[t];ea.has(n.bindingType)&&Jr(n.node).forEach(e=>{e.unmount()}),no(n),qn(n)}this._mounted=!1}}function na(t){let n=t.topLevelStructural;return void 0===n&&(n=t.topLevelStructural=function(t){const n=new RegExp(`^@@(?:${e.commentForPrefix}|${e.commentIfPrefix}|${e.commentElseIfPrefix}|${e.commentElsePrefix}):`);for(let e=t.firstChild;null!==e;e=e.nextSibling)if(e.nodeType===Node.COMMENT_NODE&&n.test(e.data))return!0;return!1}(t.fragment)),n}function oa(e){return 1<<Math.min(e,31)}const sa=-1;function ia(e){let t=e.indexBits;if(void 0===t){t=0;for(const n of e.nodeInfos)for(const e of n.parseBindTextResults)e.statePathName in E&&(t|=oa(E[e.statePathName])),"string"==typeof e.uuid&&(t|=ia(Rl(e.uuid)));e.indexBits=t}return t}function ra(e){return ia(Rl(e.uuid))}function aa(e,t){return e.statePathName in E||ea.has(e.bindingType)&&0!==(ra(e)&t)}function la(e,t){const n=document.createDocumentFragment(),o=new ta(n,t);return o._childNodeArray=e,o._firstNode=e.length>0?e[0]:null,o._lastNode=e.length>0?e[e.length-1]:null,o._mounted=!0,o}function da(e,t,n){const o=document.importNode(t.fragment,!0),s=t.nodeInfos,i=new Array(s.length);for(let e=0;e<s.length;e++){const t=Pe(o,s[e].nodePath);null===t&&_(`Node not found by path [${s[e].nodePath.join(", ")}] in fragment.`),qe(t),me(t),i[e]=t}const r=n.slots,a=new Array(r.length),l=[];for(let e=0;e<r.length;e++){const t=r[e],n=i[t.nodeIndex],o={...t.template,node:n,replaceNode:n};a[e]=o,t.isIndexBinding&&l.push(o)}const d=function(e,t,n){let o=ul.get(n);void 0!==o&&o.currentRowPlan===e||(o=new ni,ul.set(n,o));return o.initializeRow(e,t),o}(n,a,e.node),c=new ta(o);return jr(c,d),fi(c,a),function(e,t){zr.set(e,t)}(c,n),yi(c,l),gi(c,i),Yr(e.node,c),c}function ca(t){void 0!==t.uuid&&null!==t.uuid||_("BindingInfo.uuid is null.");const n=Rl(t.uuid);n||_(`Fragment with UUID "${t.uuid}" not found.`);const s=!o()&&na(n);let i=n.rowPlan;if((void 0===i||null!==i&&i.directional!==e.enableDirectionalInitialSync)&&(i=n.rowPlan=function(t){const n=e.enableDirectionalInitialSync,o=[],s=t.nodeInfos;for(let e=0;e<s.length;e++){const n=s[e],i=Pe(t.fragment,n.nodePath);if(null===i)return null;for(const t of n.parseBindTextResults){const n=t.bindingType;if("text"!==n&&"prop"!==n&&"event"!==n)return null;const s=t.propSegments[0];if(s===w||s===f)return null;if("text"===n){if(i.nodeType!==Node.TEXT_NODE)return null}else if(null!==we(i))return null;if("prop"===n&&Lo(i,t.propName))return null;const r=Ce(t);let a;try{a=Ps({...r,node:i,replaceNode:i})}catch{return null}if(a.observable||"auto"===a.authority)return null;o.push({nodeIndex:e,template:r,isEvent:"event"===n,isIndexBinding:t.statePathName in E,policy:a,authority:a.authority})}}return 0===o.length?null:{directional:n,slots:o}}(n)),null!==i)return da(t,n,i);const r=document.importNode(n.fragment,!0),a=function(e,t){const[n,o,s]=function(e,t){const n=[],o=[],s=[];for(const i of t){const t=Pe(e,i.nodePath);if(null===t&&_(`Node not found by path [${i.nodePath.join(", ")}] in fragment.`),De.has(t))continue;const r=Fe(t,i.parseBindTextResults,{allowDeferred:!0});null!==r.deferred&&(s.push(r.deferred),De.add(t)),o.push(...r.bindings),n.push(t)}return[n,o,s]}(e,t),i=new ni,r=i.initialize(o,{registerAddress:!1,applyOnReconnect:!1},null);return{nodes:n,bindingInfos:r,bindingSession:i,spreads:s}}(r,n.nodeInfos);s&&function(e,t){e.appendChild(document.createComment(`wcs-row-end:${t}`))}(r,t.uuid);const l=new ta(r,s);a.spreads.length>0&&(l.spreads=a.spreads),jr(l,a.bindingSession),fi(l,a.bindingInfos);const d="for"===t.bindingType?(c=t.statePathInfo.wildcardCount+1,2**Math.min(c,32)-1):-1;var c;const u=[];for(const e of a.bindingInfos)aa(e,d)&&u.push(e);return yi(l,u),gi(l,a.nodes),Yr(t.node,l),l}const ua=new WeakSet,fa=Symbol.for("wcstack.state.view-transition-naming");function pa(){const e=Ai("state");return null===e||"auto"!==e.naming?null:{limit:e.namingLimit}}function ha(e,t,n){const o=function(e){const t=e.firstNode;if(null===t)return null;const n=e.lastNode;for(let e=t;null!==e;e=e.nextSibling){if(e.nodeType===Node.ELEMENT_NODE)return e;if(e===n)break}return null}(e);if(null===o||ua.has(o))return;const s=o.style;if(void 0===s)return;const i=function(){const e=globalThis;return e[fa]??={counter:0,assigned:0,warned:!1}}();i.assigned>=n.limit?i.warned||(i.warned=!0,console.warn(`[@wcstack/state] auto view-transition-name limit (${n.limit}) reached; further elements are left unnamed. Raise naming-limit on <wcs-view-transition>, or switch to naming="manual" and name only what should morph.`)):(ua.add(o),i.assigned+=1,i.counter+=1,s.setProperty("view-transition-name",`wcs-${t}-${i.counter}`),s.setProperty("view-transition-class",`wcs-${t}`))}const ga=new WeakMap,ma=new WeakMap,ba=new WeakMap,wa=new WeakMap,ya=new WeakMap,va=new WeakMap;function Na(e,t,n,o){let s=va.get(e);void 0===s&&(s=[document.createComment(""),document.createComment("")],va.set(e,s));const[i,r]=s;i.data=`@@wcs-for-start:${o}`,r.data=`@@wcs-for-end:${o}`,e.mounted||(i.remove(),r.remove());const a=null===n?null:n.nextSibling;if(null===i.parentNode)t.insertBefore(i,a),t.insertBefore(r,a),e.mountAfter(i);else if(a!==i){let e=i;for(;e!==r;){const n=e.nextSibling;t.insertBefore(e,a),e=n}t.insertBefore(r,a)}return r}function xa(e,t,n){!function(e,t,n){let o=ma.get(e);if(void 0===o){if(null===n)return;o=new WeakMap,ma.set(e,o)}null===n?o.delete(t):o.set(t,n)}(e,t,n)}function Ia(e,t){ga.set(e,t)}function Sa(e,t){ya.set(e,Ht(t))}function ka(e){return e.nodeType===Node.ELEMENT_NODE||(e.nodeType===Node.TEXT_NODE?""!==(e.textContent?.trim()??""):e.nodeType===Node.COMMENT_NODE&&e.data.startsWith("@@wcs-"))}function Aa(e,t){if(null===t)return!1;if(e.nextSibling===t)return!0;const n=e.compareDocumentPosition(t);return 0!==(n&Node.DOCUMENT_POSITION_FOLLOWING)&&0===(n&Node.DOCUMENT_POSITION_DISCONNECTED)}const $a=new Set(["if","elseif","else","for"]);function Ta(e,t){for(const n of ui(e))if(t.appliedBindingSet.delete(n),$a.has(n.bindingType))for(const e of Jr(n.node))Ta(e,t)}function Ma(e,t,n){for(const o of wi(e))if($a.has(o.bindingType)){if(o.statePathName in E&&rl(o,t),0!==(ra(o)&n))for(const e of Jr(o.node))e.mounted&&Ma(e,t,n)}else rl(o,t)}function Pa(e){for(const t of ui(e)){if(!$a.has(t.bindingType))continue;const e="for"===t.bindingType;for(const n of Jr(t.node))Pa(n),e&&n.mounted&&(Gr(n),n.unmount(),Zr(t.node,n),ya.delete(t.node),ma.delete(t.node))}}function Ea(e){return`${e.bindingType} ${e.statePathName} ${e.outFilters.map(e=>e.filterName).join("|")} ${e.node.isConnected?"(connected)":"(disconnected)"}`}function Ca(t,n,i){const r=Boolean(i);let a;const l=Jr(t.node);a=0===l.size?ca(t):l.values().next().value;const d=o(),c=t.uuid??"",u=t.bindingType;if(r||(e.debug&&console.log(`unmount if content : ${Ea(t)}`),d&&a.mounted&&(s.seen=!0),Gr(a),a.unmount()),r){e.debug&&console.log(`mount if content : ${Ea(t)}`);const o=Xe(t.node);if(mi(a,o),d){if(!a.mounted){const e=document.createComment(`@@wcs-${u}-start:${c}:${t.statePathName}`);t.node.parentNode.insertBefore(e,t.node.nextSibling),a.mountAfter(e);const n=document.createComment(`@@wcs-${u}-end:${c}:${t.statePathName}`),o=a.lastNode??e;o.parentNode.insertBefore(n,o.nextSibling)}}else a.mountAfter(t.node);Ur(a,o,n);const s=pa();null!==s&&ha(a,"branch",s)}}const _a=new WeakMap;function Wa(e){return _a.get(e)??[]}function Ra(){return Array.from(La)}const La=new Set;function Oa(){La.clear()}const Ba=Symbol.for("wcstack.trustedTypes.policy");function Da(){const e=globalThis[Ba];return null===e||"object"!=typeof e?null:e}function Fa(e){globalThis[Ba]=e}let ja;let za=!1;function qa(e,t){if(za)return;if(!function(){if(void 0!==ja)return ja;if(!("trustedTypes"in globalThis))return ja=!1,ja;try{document.createElement("div").innerHTML="<i></i>",ja=!1}catch{ja=!0}return ja}())return;za=!0;const n="function"==typeof Da()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${t}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${n}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:e,property:t})}const Va={value(e,t){"TEXTAREA"===e.tagName?e.textContent=String(t??""):e.setAttribute("value",String(t??""))},checked(e,t){t?e.setAttribute("checked",""):e.removeAttribute("checked")},selected(e,t){t?e.setAttribute("selected",""):e.removeAttribute("selected")},disabled(e,t){t?e.setAttribute("disabled",""):e.removeAttribute("disabled")},selectedIndex(e,t){const n=e.querySelectorAll("option"),o=Number(t);for(let e=0;e<n.length;e++)e===o?n[e].setAttribute("selected",""):n[e].removeAttribute("selected")}};function Ha(t,n,s){if(1===t.propSegments.length){const e=t.propSegments[0];"textContent"===e||"innerText"===e?s=null==s?"":String(s):void 0===s&&"innerHTML"===e&&(s="")}if(void 0===s)return void(e.debug&&console.debug("Skipped property write: state value is undefined.",{element:t.node,propSegments:t.propSegments,statePathName:t.statePathName}));const i=t.node,r=t.propSegments;if(1===r.length){const d=r[0],c=i[d];if(c!==s){null!==ii&&null!==c&&"object"==typeof c&&null!==s&&"object"==typeof s&&null!==we(i)&&ii.rememberOverwrittenObject(i,d,c);const o="innerHTML"===(l=d)||"outerHTML"===l||"srcdoc"===l,r=()=>{let t=!1;try{i[d]=o?function(e){if("string"!=typeof e)return e;const t=Da(),n=t?.createHTML;return"function"!=typeof n?e:n.call(t,e)}(s):s,t=!0}catch(t){o&&qa(i,d),e.debug&&console.warn(`Failed to set property '${d}' on element.`,{element:i,newValue:s,error:t})}if(t){const t=function(e,t){const n=we(e);if(null===n)return null;const o=ve(e)?.get(n);if(void 0===o)return null;const s=xe(e)?.declaredInputs.get(t);return"string"==typeof s?.attribute&&s.attribute.length>0?s.attribute:null}(i,d);if(null!==t)try{!function(e,t,n){if(null==n)return void e.removeAttribute(t);let o;if("object"==typeof n)try{o=JSON.stringify(n)}catch{o=String(n)}else o=String(n);e.setAttribute(t,o)}(i,t,s)}catch(n){e.debug&&console.warn(`Failed to mirror attribute '${t}' on element.`,{element:i,newValue:s,error:n})}}};if(e.enablePropagationContext&&Lo(i,d)){const e=jo(i,d,t.statePathName),o=zo(e,"to-element"),a=n?.propagationContextByBinding?.get(t)??Go()??Vo(e);if(a.visitedEdges.has(o))null!==N&&N({type:"propagation:suppressed",reason:"visited-edge",transactionId:a.transactionId,edgeId:o,node:i,member:d});else{const t=Ho(a,o);Xo(t,()=>function(e,t,n,o,s,i){const r={bindingId:o,bindingGeneration:0,member:t,transactionId:s,synchronousScopeId:Do++,writtenValue:n};Ko.push({receipt:r,node:e});try{return i()}finally{Ko.pop()}}(i,d,s,e,t.transactionId,r))}}else r()}if(o()){const e=Va[d];e?e(i,s):(!function(e,t,n){let o=_a.get(e);o||(o=[],_a.set(e,o));const s=o.find(e=>e.propName===t);s?s.value=n:o.push({propName:t,value:n})}(i,d,s),a=i,La.add(a))}return}var a,l;const d=r[0];let c=i[d];for(let e=1;e<r.length-1;e++){const t=r[e];if(null==c)return;c=c[t]}const u=r[r.length-1],f=c[u];if(f!==s){if(Object.isFrozen(c))return void(e.debug&&console.warn("Attempting to set property on frozen object.",{element:i,propSegments:r,oldValue:f,newValue:s}));null!==ii&&2===r.length&&"object"==typeof c&&null!==c&&null!==we(i)&&(u in c?ii.rememberOverwrittenValue(i,d,u,c[u]):ii.recordInjectedKey(i,d,u));try{c[u]=s}catch(t){e.debug&&console.warn("Failed to set property on sub-object.",{element:i,propSegments:r,oldValue:f,newValue:s,error:t})}}}const Ua=new WeakSet;function Ga(e,t,n){}function Xa(e,t){const n=to(t);if(n.pathInfo.path in E){const e=Xe(t.node);return null===e&&_(`ListIndex not found for binding: ${t.statePathName}`),function(e,t){null===e.listIndex&&_("ListIndex not found for loopContext:");const n=E[t];void 0===n&&_(`Invalid index name: ${t}`);const o=Ln(e.listIndex,n,e.pathInfo.wildcardCount);return null===o&&_(C(`"${t}"`,n+1,e.pathInfo.wildcardCount)),o.index}(e,n.pathInfo.path)}return e[mn](n)}const Ka=new WeakSet;function Qa(e,t){console.error(`[@wcstack/state] deferred apply failed for <${e}>.`,t)}const Ya=Object.freeze({[g]:function(e,t,n){const o=e.node,s=e.propSegments[1];null!=n?("boolean"!=typeof n&&_(`Invalid value for class application: expected boolean, got ${typeof n}. Write "|truthy" if you mean to coerce.`),o.classList.toggle(s,n)):o.classList.toggle(s,!1)},[m]:function(e,t,n){const o=e.node,s=e.propSegments[1];if(null==n)return void(o.hasAttribute(s)&&o.removeAttribute(s));const i=String(n);o.getAttribute(s)!==i&&o.setAttribute(s,i)},[b]:function(e,t,n){const o=e.propSegments[1],s=e.node.style;null==n&&(n=""),s[o]!==n&&(s[o]=n)},[w]:function(e,t,n){No(n)||_("command binding requires a CommandToken value (use $command.<tokenName> with a name declared in $commandTokens).");const o=n,s=di.get(e);if(s&&s.token===o)return;const i=e.node,r=e.propSegments[1];"string"==typeof r&&0!==r.length||_('command binding requires a method name (e.g., "command.fetch").');const a=function(e){const t=we(e);if(null===t)return null;const n=ve(e)?.get(t);return void 0===n&&_(`Custom element <${t}> is not defined for command binding.`),xe(e)}(i);null===a&&_(`command binding requires a wc-bindable custom element. <${i.tagName.toLowerCase()}> is not wc-bindable.`),a.declaredCommands.has(r)||_(`Command "${r}" is not declared in wcBindable.commands of <${i.tagName.toLowerCase()}>.${R(r,a.declaredCommands.keys())}`),s&&(s.unsubscribe(),di.delete(e));const l=new WeakRef(i);let d=null;d=o.subscribe((...t)=>{const n=l.deref();if(!n||!n.isConnected)return d?.(),void di.delete(e);const o=n[r];return"function"!=typeof o&&_(`Method "${r}" is not a function on <${n.tagName.toLowerCase()}>.`),Reflect.apply(o,n,t)}),di.set(e,{token:o,unsubscribe:d,elementRef:l})}}),Ja={text:function(e,t,n){const s=null==n?"":String(n);if(e.replaceNode.nodeValue!==s&&(e.replaceNode.nodeValue=s),o()&&!Ua.has(e.replaceNode)){Ua.add(e.replaceNode);const t=e.replaceNode.parentNode;if(t){const n=e.statePathName,o=document.createComment(`@@wcs-text-start:${n}`),s=document.createComment(`@@wcs-text-end:${n}`);t.insertBefore(o,e.replaceNode),t.insertBefore(s,e.replaceNode.nextSibling)}}},for:function(e,t,n){const i=e.statePathInfo,r=Dn(e),a=zn(e),l=en(a),c=ya.get(e.node);let u,f;const p=void 0!==c&&function(e,t){const n=Jt.get(e);return void 0!==n&&(n===t||Bt(t)===Bt(n))}(a,n),h=p||void 0===c||c.value===l?null:Rr(r,l,n);p?(u=c.value,f=Or(Bt(u),Bt(n))):null!==h&&h.newIndexes.every(e=>e.parentListIndex===r||vt(e.parentListIndex)||!At(n,e.parentListIndex))?(u=c.value,f=Or(Bt(u)??[],h.newIndexes)):(u=l.length>0&&!ma.has(e.node)?[]:l,f=Rr(r,u,n));const g=Array.isArray(n)?n:[];t.newListValueByAbsAddress.set(a,g),ya.set(e.node,Ht(g));let m=ma.get(e.node);const b=void 0!==m?function(e,t,n){if(!wt(t))return null;let o=null;for(let t=0;t<n.newIndexes.length;t++){const s=n.newIndexes[t],i=n.oldIndexes[t],r=n.addIndexSet.has(s)&&n.deleteIndexSet.has(i)?e.get(i):void 0;void 0!==r&&(o??={byAddedIndex:new Map,reused:new Set},o.byAddedIndex.set(s,r),o.reused.add(r))}return o}(m,u,f):null,w=Array.isArray(u)&&u.length===f.deleteIndexSet.size&&f.deleteIndexSet.size>0;if(w&&null===b&&null!==e.node.parentNode){let t=wa.get(e.node);if(void 0===t){const n=ga.get(e.node)||e.node;t=function(e,t){let n=e.previousSibling,o=t.nextSibling,s=!0;for(;null!==n;){if(ka(n)){s=!1;break}n=n.previousSibling}for(;null!==o;){if(ka(o)){s=!1;break}o=o.nextSibling}return s}(e.node,n.parentNode===e.node.parentNode?n:e.node),wa.set(e.node,t)}if(t){const t=e.node.parentNode;!function(e,t){ps.set(e,(ps.get(e)??0)+t)}(t,t.childNodes.length),t.textContent="",t.appendChild(e.node)}}let y=w?1e3-function(e){return ba.get(e.node)||[]}(e).length:Number.POSITIVE_INFINITY;const v=o();if(void 0!==m){const t=m;f.deleteIndexSet.forEach(n=>{const o=t.get(n);void 0!==o&&(v&&(va.get(o)?.forEach(e=>e.remove()),s.seen=!0),null!==b&&b.reused.has(o)?(Gr(o),Pa(o),o.unmountInPlace()):y<=0&&o.tryDestroy()?Zr(e.node,o):(Gr(o),o.unmount(),function(e,t){let n=ba.get(e.node);void 0===n&&(n=[],ba.set(e.node,n)),n.length<1e3?n.push(t):Zr(e.node,t)}(e,o),y-=1),w||t.delete(n))}),w&&(ma.delete(e.node),m=void 0)}let N=e.node;const I=d(i.path+"."+x),S=t.stateElement.loopContextStack,k=Br(f);let A=null;f.newIndexes.length==f.addIndexSet.size&&f.newIndexes.length>0&&N.isConnected&&null===b&&(A=document.createDocumentFragment(),Cn(A,t.rootNode));const $=v?`${e.uuid}:${i.path}:`:"",T=pa(),M=ba.get(e.node);for(const n of f.newIndexes){let o;if(f.addIndexSet.has(n)){const s=Zn(I,n);if(S.createLoopContext(s,s=>{o=b?.byAddedIndex.get(n)??(void 0!==M?M.pop():void 0),void 0===o?o=ca(e):(Ta(o,t),mi(o,s)),v?N=null!==A?Na(o,A,null,$+n.index):Na(o,N.parentNode,N,$+n.index):null!==A?o.appendTo(A):N.nextSibling!==o.firstNode&&o.mountAfter(N),Ur(o,s,t),null!==T&&ha(o,"row",T)}),void 0===o&&_(`Content not found for ListIndex: ${n.index} at path "${i.path}"`),null!==b&&b.reused.has(o)){const e=t.stateElement.addressHooks;if(e){const n=e.rowReused;for(let e=0;e<n.length;e++)n[e](t.stateElement,o)}}}else{o=void 0!==m?m.get(n)??null:null,f.changeIndexSet.has(n)&&Ma(o,t,oa(i.wildcardCount)),null===o&&_(`Content not found for ListIndex: ${n.index} at path "${i.path}"`);const e=!o.mounted;if(v?N=Na(o,N.parentNode,N,$+n.index):null!==k&&k.has(n)&&Aa(N,o.firstNode)||N.nextSibling===o.firstNode||o.mountAfter(N),e){const e=o,s=Zn(I,n);S.createLoopContext(s,n=>{Ur(e,n,t)})}}v||(N=o.lastNode||N),void 0===m&&(m=new WeakMap,ma.set(e.node,m)),m.set(n,o)}ga.set(e.node,N),null!==A&&(e.node.parentNode.insertBefore(A,e.node.nextSibling),Cn(A,null))},if:Ca,else:Ca,elseif:Ca,radio:function(e,t,n){const o=e.node,s=ai(o.value,e.inFilters);o.checked=n===s},checkbox:function(e,t,n){const o=e.node,s=ai(o.value,e.inFilters),i=Array.isArray(n)?n:li;o.checked=i.includes(s)}},Za=new WeakMap,el=new WeakMap,tl=new WeakMap;function nl(){}function ol(e){const t=ii;if(null!==t){const n=e.replaceNode,o=e.propSegments[0];if(t.isComplete(n,o))return Ga;if(t.isDeclared(n,o))return nl}return Ha}function sl(e,t){il(e,t,Xa(t.state,e))}function il(e,t,n){const o=ai(n,e.outFilters);if(!0===el.get(e))return void t.deferredSelectBindings.push({binding:e,value:o,stateElement:t.stateElement});let s=Za.get(e);if(void 0===s){if(Za.has(e))return s=ol(e),s===Ga&&Za.set(e,s),void s(e,t,o);if(s=Ja[e.bindingType],void 0===s){const t=e.propSegments[0];if(s=Ya[t],Za.set(e,s),void 0===s){we(e.replaceNode)?(s=ol(e),s===Ga&&Za.set(e,s)):(s=Ha,Za.set(e,s))}}if(s===Ha){if("SELECT"===e.node.tagName){const n=e.propSegments[0];if("value"===n||"selectedIndex"===n)return t.deferredSelectBindings.push({binding:e,value:o,stateElement:t.stateElement}),void el.set(e,!0)}}s(e,t,o)}else s(e,t,o)}function rl(e,t){if(t.appliedBindingSet.has(e))return;if(t.appliedBindingSet.add(e),!1!==t.stateElement.hasUpdatedCallback){const n=zn(e);if(t.updatedAbsAddressSetByStateElement.has(t.stateElement)){t.updatedAbsAddressSetByStateElement.get(t.stateElement).add(n)}else t.updatedAbsAddressSetByStateElement.set(t.stateElement,new Set([n]))}const n=si(e);if(null!==n&&!n.shouldApplyState(e))return;if("event"===e.bindingType)return;if(!0!==tl.get(e)){const t=we(e.replaceNode);if(t&&(void 0===ve(e.replaceNode)?.get(t)||function(e){return"waiting-definition"===Ds.get(e)?.phase}(e)))return void function(e,t){if(Ka.has(e))return;Ka.add(e);const n=()=>{Ka.delete(e);const t=si(e);(null===t||t.shouldApplyState(e))&&ll([e])},o=n=>{Ka.delete(e),Qa(t,n)},s=si(e);if(null!==s){const i=s.deferUntilDefined(e.replaceNode,t,n,o);return void(s.addTeardown(e,()=>{Ka.delete(e),i()})||(Ka.delete(e),i()))}const i=ve(e.replaceNode);if(null===i)return Ka.delete(e),void Qa(t,new Error("CustomElementRegistry is unavailable."));Is(i).wait(t,()=>{e.replaceNode.isConnected?n():Ka.delete(e)},o)}(e,t);tl.set(e,!0)}if(!0===t.sameRootVerified)return void sl(e,t);let o=e.replaceNode.getRootNode();if(o instanceof DocumentFragment&&!(o instanceof ShadowRoot)&&(o=_n(o),null===o&&_("Root node for fragment not found for binding.")),o!==t.rootNode){const n=kl(o);null===n&&_("No state tree found on this root for binding."),n.createState("readonly",s=>{const i={rootNode:o,stateElement:n,state:s,appliedBindingSet:t.appliedBindingSet,newListValueByAbsAddress:t.newListValueByAbsAddress,updatedAbsAddressSetByStateElement:t.updatedAbsAddressSetByStateElement,deferredSelectBindings:t.deferredSelectBindings};sl(e,i)})}else sl(e,t)}function al(e,t,n,o){if(null!==n&&!0===n.hasErrorCallback){const s={path:e.statePathName,bindingType:e.bindingType,node:e.node},i=o.get(n);void 0===i?o.set(n,[{error:t,info:s}]):i.push({error:t,info:s})}else console.error(`[@wcstack/state] binding "${e.bindingType}: ${e.statePathName}" failed to apply; the rest of this batch continues.`,{node:e.node,error:t});null!==N&&N({type:"state:binding-apply-error",path:e.statePathName,bindingType:e.bindingType,error:t})}function ll(t,n,o){let s=0;const i=new Set,r=new Map,a=new Map,l=[],d=new Map;for(;s<t.length;){let o=t[s];if(!1===o.replaceNode.isConnected){e.debug&&console.log(`applyChangeFromBindings: skip disconnected binding: ${o.bindingType} ${o.statePathName} on ${o.node.nodeName}`,o),s++;continue}let c=o.replaceNode.getRootNode();c instanceof DocumentFragment&&!(c instanceof ShadowRoot)&&(c=_n(c),null===c&&_("Root node for fragment not found for binding."));const u=kl(c);null===u&&_("No state tree found on this root for binding."),u.createState("readonly",e=>{const f={rootNode:c,stateElement:u,state:e,appliedBindingSet:i,newListValueByAbsAddress:r,updatedAbsAddressSetByStateElement:a,deferredSelectBindings:l,sameRootVerified:!0,propagationContextByBinding:n};for(;;){try{rl(o,f)}catch(e){al(o,e,u,d)}s++;const e=t[s];if(!e)break;if(e.replaceNode.getRootNode()!==f.rootNode)break;o=e}})}for(const{binding:e,value:t,stateElement:o}of l)try{Ha(e,{propagationContextByBinding:n},t)}catch(t){al(e,t,o??null,d)}for(const[e,t]of r.entries())tn(e,t),un(e,t);if(!1!==o?.updatedCallback)for(const[e,t]of a.entries())e.createState("writable",e=>{e[vn](Array.from(t))});for(const[e,t]of d.entries())e.createState("writable",e=>{for(const{error:n,info:o}of t)try{e[Nn](n,o)}catch(e){console.error(`[@wcstack/state] $errorCallback threw while handling the failure of binding "${o.bindingType}: ${o.path}".`,{error:e,original:n,node:o.node})}})}function dl(e,t,n,o,s){for(const i of e)i.cancel?.(),i.cancel=n.deferUntilDefined(i.node,i.tagName,()=>{const r=Ve(i);if(o&&(e.splice(e.indexOf(i),1),o.push(...r),s.push(...r.filter(e=>e.statePathName in E))),0===r.length)return;Ke(i.node,t);ll(n.initialize(r,o&&{registerPathInfo:!1,applyOnReconnect:!1}))},e=>{console.error(`[@wcstack/state] deferred spread failed for <${i.tagName}>.`,e)})}function cl(e,t,n){const[o,s,i]=je(e,n),r=oi(e);for(const e of o)Ke(e,t);ll(r.initialize(s)),dl(i,t,r)}const ul=new WeakMap;async function fl(t){const n=t.querySelectorAll(e.tagNames.state),o=[],s=ve(t);null===s&&_(`CustomElementRegistry is unavailable for <${e.tagNames.state}>.`),await s.whenDefined(e.tagNames.state);for(const e of n){if(Re(e))continue;const t=e;o.push(t.initializePromise)}await Promise.all(o)}async function pl(t){if(t===document)await fl(document),z(document),td(document,document),cl(document.body,null);else{const n=t;n.host.hasAttribute(e.bindAttributeName)&&await ge(n.host),await fl(n),z(n),td(n,n),cl(n,null)}}const hl={watch:"temporal",scan:"temporal",streams:"temporal",scopes:"scopes",dcc:"scopes",recursion:"recursion",ssr:"ssr",devtools:"devtools"};function gl(e,t){return`[wcs/feature-not-installed] ${t} needs the "${e}" feature: install it with installFeatures([...]) from "@wcstack/state/features/${hl[e]??e}" before the state is defined.`}let ml=null;function bl(e){ml=e}function wl(e){return null===ml&&_(gl("ssr",e)),ml}const yl=new WeakMap,vl=new WeakMap,Nl=new Set,xl=[];function Il(e){xl.includes(e)||xl.push(e)}function Sl(){return Nl}function kl(e){return yl.get(e)??null}function Al(e){return vl.get(e)??Promise.resolve()}function $l(e,t){const n=Promise.reject(t);n.catch(()=>{}),vl.set(e,n)}const Tl=new WeakSet;function Ml(e,t){const n=yl.get(e);if(void 0!==n){if(n===t)return;_("A state tree is already registered on this root.")}yl.set(e,t)}function Pl(e,t){vl.set(e,t),t.then(()=>El(e),()=>{})}function El(e){Tl.add(e)}function Cl(t,n){const s=yl.get(t);if(null===n){if(void 0===s)return;yl.delete(t),Nl.delete(s),null!==N&&N({type:"state:element-unregistered",rootNode:t,element:s}),e.debug&&console.debug("State element unregistered")}else{if(s===n)return;if(void 0===s){const e=!o()&&n.hasAttribute?.("enable-ssr");if("HTMLDocument"===t.constructor.name||"Document"===t.constructor.name){const n=new Promise((n,o)=>{queueMicrotask(async()=>{try{if(e){await wl('the "enable-ssr" attribute').hydrate(t)||await pl(t)}else await pl(t);El(t),ad(),n()}catch(e){o(e)}})});vl.set(t,n)}else if("ShadowRoot"===t.constructor.name){const e=new Promise((e,n)=>{queueMicrotask(async()=>{try{await pl(t),El(t),ad(),e()}catch(e){n(e)}})});vl.set(t,e)}}void 0!==s&&_('A state tree is already registered on this root — one <wcs-state> per root in v2. This second element stays unregistered: it keeps the state it loaded and its declarations stay live, but nothing binds to it and disconnecting it runs no cleanup — remove it. Mount additional states onto the tree instead: <wcs-state mount="...">.'),yl.set(t,n),Nl.add(n);for(let e=0;e<xl.length;e++)xl[e](t,n);null!==N&&N({type:"state:element-registered",rootNode:t,element:n}),e.debug&&console.debug("State element registered",n)}}const _l=new Map;function Wl(e,t,n){if(null===n)_l.delete(e);else{_l.set(e,n);const o=kl(t);null===o&&_("No state tree found on this root for fragment info.");const s=n.parseBindTextResult;o.setPathInfo(s.statePathName,s.bindingType);for(const e of n.nodeInfos)for(const t of e.parseBindTextResults)o.setPathInfo(t.statePathName,t.bindingType)}}function Rl(e){return _l.get(e)||null}function Ll(){_l.clear()}function Ol(t){if(t.nodeType===Node.ELEMENT_NODE){const n=t,o=re(n.getAttribute(e.bindAttributeName)||"");if(n.localName===e.tagNames.state){if(n.hasAttribute("mount"))return o.filter(e=>e.propSegments[0]!==y);const t=o.find(e=>e.propSegments[0]===y);if(void 0!==t){const n=`on a volume element — a <${e.tagNames.state}> with a "mount" attribute`;_(1===t.propSegments.length?`[wcs/mount-path-invalid] "${t.propName}" is the reserved namespace for volume injection, so it cannot be bound as an element property. Write one key at a time ("${y}.<key>: <path>") ${n}.`:`[wcs/mount-path-invalid] "${t.propName}: ${t.statePathName}" is a volume injection declaration, and it can only be written ${n}. Add mount="<path>", or bind an element property instead.`)}}return o}if(t.nodeType===Node.COMMENT_NODE){const e=ce(t);null===e&&_("Comment node binding text not found.");const n=Rl(e);let o=n?.parseBindTextResult??null,s=null;return null===o?(o=ue(e),s=null):s=e,[{...o,uuid:s}]}return[]}let Bl;function Dl(){return Bl??={filterName:"not",args:[]}}const Fl=/^(\s*@@\s*(?:.*?)\s*:\s*)(.+?)(\s*)$/;function jl(e,t){const n=t+l+x,o=Y(e,"|");let s,i;if(-1!==o?(s=e.slice(0,o).trim(),i=e.slice(o)):(s=e.trim(),i=""),"."===s)s=n;else{if(!s.startsWith("."))return e;s=n+l+s.slice(1)}return i.length>0?s+i:s}function zl(e,t){const n=Fl.exec(e);if(null===n)return e;const o=n[1],s=n[2],i=n[3];return o+jl(s,t)+i}function ql(e,t){const n=J(e,";");let o=!1;const s=n.map(e=>{const n=e.trim();if(0===n.length)return e;const s=Y(n,":");if(-1===s)return e;const i=n.slice(0,s).trim(),r=n.slice(s+1).trim(),a=jl(r,t);return a!==r?(o=!0,`${i}: ${a}`):e});return o?s.join(";"):e}function Vl(e,t){return ql(e,t)}function Hl(t,n){const o=e.bindAttributeName,s=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_ELEMENT);for(;s.nextNode();){const e=s.currentNode;if(e.nodeType===Node.COMMENT_NODE){const t=e;t.data=zl(t.data,n);continue}const t=e;if(t instanceof HTMLTemplateElement)continue;const i=t.getAttribute(o);if(null!==i){const e=ql(i,n);e!==i&&t.setAttribute(o,e)}}}function Ul(e){let t=e;const n=[];for(;null!==t.parentNode;){const e=Array.from(t.parentNode.childNodes).indexOf(t);n.unshift(e),t=t.parentNode}return n}const Gl=new WeakMap;function Xl(e){return Gl.get(e)??null}function Kl(e){const t=[],n=Be(e);for(const e of n){const n=Ol(e);let o=e;if(e.nodeType===Node.COMMENT_NODE&&1===n.length&&"text"===n[0].bindingType&&null!==e.parentNode){const t=document.createTextNode("");Gl.set(t,e.data),e.parentNode.replaceChild(t,e),o=t}t.push({nodePath:Ul(o),parseBindTextResults:n})}return t}function Ql(e){const t=Array.from(e.childNodes);for(const n of t)if(n.nodeType===Node.TEXT_NODE){""===(n.textContent||"").trim()&&e.removeChild(n)}}const Yl=new Map([["for",e.commentForPrefix],["if",e.commentIfPrefix],["elseif",e.commentElseIfPrefix],["else",e.commentElsePrefix]]),Jl=Dl();function Zl(e,t){const n=t.outFilters;return{...t,outFilters:[...n,Jl],bindingType:e}}function ed(e,t,n,o,s,i=!0){Ql(t),"string"==typeof o&&Hl(t,o),td(e,t,o,s);const r={fragment:t,parseBindTextResult:void 0!==s&&i?s(n,o):n,nodeInfos:Kl(t)};return void 0!==s&&function(e,t,n){for(const o of e)for(let e=0;e<o.parseBindTextResults.length;e++){const s=o.parseBindTextResults[e];null==s.uuid&&(o.parseBindTextResults[e]=t(s,n))}}(r.nodeInfos,s,o),r}function td(t,n,o,s){const i=e.commentElsePrefix,r=Le(n),a=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode(t){const n=t;if(r.length>0&&-1!==r.indexOf(n))return NodeFilter.FILTER_REJECT;if("template"===n.tagName.toLowerCase()){if((n.getAttribute(e.bindAttributeName)||"").length>0)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let l=null;const d=[],c=[];for(;a.nextNode();){const e=a.currentNode;c.push(e)}for(const n of c){let r=n.getAttribute(e.bindAttributeName)||"";"string"==typeof o&&(r=Vl(r,o));let a=re(r)[0];const c=Yl.get(a.bindingType);if(void 0===c)continue;const u=a.bindingType,f=n.content,p=Ye();let h=null;const g="for"===u?a.statePathName:o;if("else"===u){null===l&&_("'else' binding found without preceding 'if' or 'elseif' binding."),a=Zl("else",l.parseBindTextResult),h=ed(t,f,a,g,s,!1),Wl(p,t,h);const e=d.at(-1),o=document.createComment(`@@${c}:${p}`);void 0!==e?(n.remove(),e.fragment.appendChild(o),e.nodeInfos.push({nodePath:Ul(o),parseBindTextResults:Ol(o)})):n.replaceWith(o)}else if("elseif"===u){null===l&&_("'elseif' binding found without preceding 'if' or 'elseif' binding."),h=ed(t,f,a,g,s),Wl(p,t,h);const e=document.createComment(`@@${c}:${p}`),o=Ye(),r={fragment:document.createDocumentFragment(),parseBindTextResult:Zl("else",l.parseBindTextResult),nodeInfos:[]};r.fragment.appendChild(e),r.nodeInfos.push({nodePath:Ul(e),parseBindTextResults:Ol(e)}),Wl(o,t,r);const u=d.at(-1);d.push(r);const m=document.createComment(`@@${i}:${o}`);void 0!==u?(n.remove(),u.fragment.appendChild(m),u.nodeInfos.push({nodePath:Ul(m),parseBindTextResults:Ol(m)})):n.replaceWith(m)}else{h=ed(t,f,a,g,s),Wl(p,t,h);const e=document.createComment(`@@${c}:${p}`);n.replaceWith(e)}"if"===u?(d.length=0,l=h):"elseif"===u?l=h:"else"===u&&(l=null,d.length=0)}}const nd=()=>`[${e.bindAttributeName}]`;function od(t){if(Vs(t))return!0;if(!sd(t))return!1;if(t.hasAttribute(e.bindAttributeName))return!1;const n=t.querySelector(nd());return null!==n&&Vs(n)}function sd(e){return 1===e.nodeType}function id(t){if(od(t))return;z(t),td(t.getRootNode(),t);const n=t.hasAttribute(e.bindAttributeName),o=t.parentNode,s=null!==o&&(1===o.nodeType||9===o.nodeType||11===o.nodeType);cl(n&&s?o:t,null)}const rd=[];function ad(){const e=rd.splice(0,rd.length);for(const t of e)id(t);D()}const ld={protocol:"wcs-binder",version:1,bind:function(e){var t;sd(e)&&!od(e)&&(t=e.getRootNode(),Tl.has(t)?id(e):rd.push(e))}};function dd(){const e=globalThis;void 0===e[L]&&(e[L]=ld)}export{ai as $,Ml as A,Pl as B,z as C,td as D,cl as E,kl as F,We as G,ri as H,we as I,ge as J,re as K,Il as L,un as M,Rr as N,cn as O,Ra as P,Wa as Q,Oa as R,Rl as S,Ba as T,Xl as U,Pe as V,Ll as W,fl as X,je as Y,dl as Z,zn as _,Da as a,br as a$,qt as a0,tn as a1,Sa as a2,ii as a3,Le as a4,Dl as a5,Ql as a6,Hl as a7,Kl as a8,Wl as a9,vn as aA,yn as aB,wn as aC,bn as aD,$i as aE,Li as aF,pn as aG,Xn as aH,fn as aI,bo as aJ,wl as aK,Cl as aL,$l as aM,gl as aN,vo as aO,xi as aP,rt as aQ,Ii as aR,Er as aS,Dt as aT,zt as aU,Gi as aV,_r as aW,Rn as aX,xt as aY,kt as aZ,ur as a_,la as aa,jr as ab,fi as ac,gi as ad,aa as ae,sa as af,yi as ag,nt as ah,xa as ai,Ia as aj,Yr as ak,mi as al,Re as am,Be as an,ce as ao,ze as ap,ni as aq,Ee as ar,qe as as,bl as at,Si as au,dr as av,fr as aw,lr as ax,ar as ay,Nn as az,pl as b,mr as b0,yr as b1,st as b2,Ut as b3,Gt as b4,jt as b5,hr as b6,Wr as b7,Go as b8,Vo as b9,Lt as ba,on as bb,at as bc,gt as bd,Mt as be,Pt as bf,Jo as bg,bt as bh,en as bi,sn as bj,Me as bk,ue as bl,cr as bm,Sl as bn,Ri as bo,Di as c,mo as d,_i as e,Wi as f,Al as g,mn as h,vt as i,Zn as j,Bt as k,Mn as l,Ln as m,ht as n,On as o,Pn as p,ve as q,dd as r,Fa as s,Ge as t,Ne as u,Xe as v,gn as w,ll as x,oi as y,Ke as z};
|
|
2
2
|
//# sourceMappingURL=binder.js.map
|