@wcstack/state 4.0.0-rc.7 → 4.0.0-rc.9
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 +29 -34
- package/README.md +29 -34
- package/dist/auto.min.js +2 -1
- package/dist/auto.min.js.map +1 -0
- package/dist/index.esm.js +2 -1
- package/dist/index.esm.js.map +1 -0
- package/dist/split/auto.js +2 -1
- package/dist/split/auto.js.map +1 -0
- package/dist/split/chunks/{chunk-V34ZHCK5.js → chunk-4NJBYXIT.js} +2 -1
- package/dist/split/chunks/chunk-4NJBYXIT.js.map +1 -0
- package/dist/split/chunks/{chunk-JMPQHCIT.js → chunk-55J45X6H.js} +2 -1
- package/dist/split/chunks/chunk-55J45X6H.js.map +1 -0
- package/dist/split/chunks/{chunk-LTBR3OV5.js → chunk-7AYOQHZH.js} +2 -1
- package/dist/split/chunks/chunk-7AYOQHZH.js.map +1 -0
- package/dist/split/chunks/chunk-EIMTT5I3.js +2 -0
- package/dist/split/chunks/chunk-EIMTT5I3.js.map +1 -0
- package/dist/split/chunks/chunk-L3PFEJP7.js +2 -0
- package/dist/split/chunks/chunk-L3PFEJP7.js.map +1 -0
- package/dist/split/chunks/{chunk-W5KT4PQ3.js → chunk-M5SODAAE.js} +2 -1
- package/dist/split/chunks/chunk-M5SODAAE.js.map +1 -0
- package/dist/split/chunks/{chunk-SPWZUBQS.js → chunk-NOPTR2L3.js} +2 -1
- package/dist/split/chunks/chunk-NOPTR2L3.js.map +1 -0
- package/dist/split/chunks/chunk-SAUVGHSB.js +2 -0
- package/dist/split/chunks/chunk-SAUVGHSB.js.map +1 -0
- package/dist/split/chunks/{chunk-ARPZVNKL.js → chunk-UD3AYVP2.js} +2 -1
- package/dist/split/chunks/chunk-UD3AYVP2.js.map +1 -0
- package/dist/split/chunks/{chunk-XF6V6DWR.js → chunk-W4KOY6GT.js} +2 -1
- package/dist/split/chunks/chunk-W4KOY6GT.js.map +1 -0
- package/dist/split/chunks/{chunk-2EGTC36Y.js → chunk-ZN52NEIB.js} +2 -1
- package/dist/split/chunks/chunk-ZN52NEIB.js.map +1 -0
- package/dist/split/core.js +2 -1
- package/dist/split/core.js.map +1 -0
- package/dist/split/features/devtools.js +2 -1
- package/dist/split/features/devtools.js.map +1 -0
- package/dist/split/features/diagnostics.js +2 -1
- package/dist/split/features/diagnostics.js.map +1 -0
- package/dist/split/features/formats.js +2 -1
- package/dist/split/features/formats.js.map +1 -0
- package/dist/split/features/list-keys.js +2 -1
- package/dist/split/features/list-keys.js.map +1 -0
- package/dist/split/features/native-commands.js +2 -1
- package/dist/split/features/native-commands.js.map +1 -0
- package/dist/split/features/recursion.js +2 -1
- package/dist/split/features/recursion.js.map +1 -0
- package/dist/split/features/scopes.js +2 -1
- package/dist/split/features/scopes.js.map +1 -0
- package/dist/split/features/ssr.js +2 -1
- package/dist/split/features/ssr.js.map +1 -0
- package/dist/split/features/temporal.js +2 -1
- package/dist/split/features/temporal.js.map +1 -0
- package/package.json +1 -1
- package/dist/split/chunks/chunk-27N3IPIZ.js +0 -1
- package/dist/split/chunks/chunk-7EWPQMA6.js +0 -1
- package/dist/split/chunks/chunk-ALVA5TQM.js +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var e={};function t(e,t){return null==e?t:(...n)=>{e(...n),t(...n)}}function n(e,t,n){return null==t?n:(...r)=>{let l=t(...r);return e(l)?l:n(...r)}}var r=e=>!0===e,l=e=>void 0!==e,i=e=>null!=e,s=new Set;function o(t){let n=t.$features;if(null!=e.Ot&&Array.isArray(n)){let t=n.filter(e=>!s.has(e));if(t.length>0)return e.Ot(t)}}function a(e,t){if(!s.has(e))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${t} needs the add-on @wcstack/state/features/${e}`)}var u=class{constructor(e,t,n){this.c=[],this.getter=null,this.ie=null,this.se=!1,this.B=[],this.Q=[],this.ft=null,this.P=-1,this.z=c,this.Ce=null,this.Ct=null,this.It=null,this._=null,this.pn=!1,this.mn=!1,this._n=!1,this.Z=0,this.pt=new Set,this.t=e,this.d=n,this.s=t;let r=null===n?[null]:n.h.slice(),l="*"===t;l&&r.push(n),this.n=r.length-1,this.q=l?[]:null===n?[t]:[...n.q,t],this.h=r}Wn(e){this.pt.has(e)||(this.pt.add(e),this.B.push(e),e.Q.push(this))}Io(e){this.pt.delete(e);let t=this.B;t.splice(t.indexOf(e),1)}Mo(){this.getter=null,this.ie=null,this.P=-1,this.z=c,this.B.length=0,this.pt.clear(),this.Q.length=0,this.ft=null,this.Ce=null,this.Ct=null,this.It=null,this._=null}ee(e){let t=this;for(;null!==t;){if(t===e)return!0;t=t.d}return!1}},c=Symbol("unset"),f=Symbol("dirty"),h=Symbol("failed"),d=class{constructor(e=null){this.mt=new Map,this.Vn=e}Mt(e){return this.mt.get(e)}get(e){let t=this.mt.get(e);if(void 0!==t)return t;let n=e.lastIndexOf("."),r=n<0?null:this.get(e.slice(0,n));return t=new u(e,e.slice(n+1),r),this.Vn?.(t),this.mt.set(e,t),r&&r.c.push(t),t}all(){return this.mt.values()}jt(e){this.mt.delete(e.t)}},p=new Map;function m(e){let t=p.get(e);if(void 0!==t)return t;let n=!0,r=e.split("."),l=[];for(let e=0;e<r.length;e++){let t=r[e],i=t.charCodeAt(0);e>0&&i>=48&&i<=57?(n=!1,l.push(Number(t)),r[e]="*"):"*"===t&&l.push(-1)}if(!n)return{o:r.join("."),indexes:l};let i={o:e,indexes:null};return p.size>4095&&p.clear(),p.set(e,i),i}var g=class{constructor(e,t,n){this.ht=null,this.$=null,this.ye=null,this._=null,this.c=null,this.y=!0,this.l=e,this.w=t,this.R=n}},y=class{constructor(e,t){this.C=null,this.f=[],this.$=null,this.D=null,this.te=!1,this.Dt=!1,this.yt=!1,this.o=e,this.ae=t,this.n=e.n+1}},b=[];function v(t,n,r){throw new Error(`[@wcstack/state] ${t}${e.Do?.(t,n,r)??""}`)}function $(t,n=[]){return e.Lo?.(t,n)??`#${t}${n.map(e=>` ${"string"==typeof e?JSON.stringify(e):String(e)}`).join("")}`}function w(e,t,n,r){v($(e,t),n,r)}var A=class{constructor(e){this.bt=new Set,this.name=e}get size(){return this.bt.size}subscribe(e){return this.bt.add(e),()=>{this.bt.delete(e)}}unsubscribe(e){return this.bt.delete(e)}emit(...e){let t=[];for(let n of this.bt)try{t.push(n(...e))}catch(e){t.push(void 0),console.error(`[@wcstack/state] ${$(17,[this.name])}`,e)}return t}};function k(e,t,n){if(void 0===e)return[];Array.isArray(e)||w(18,[t]);let r=new Set;for(let l of e)("string"!=typeof l||""===l)&&w(19,[t]),l===n&&w(20,[t,l,n]),r.has(l)&&w(21,[t,l]),r.add(l);return e}var x=Symbol.for("wcstack.transition-runner");function S(e){let t=globalThis[x];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run||"function"!=typeof t.accepts||!t.accepts(e)?null:t}function T(e,t,n){let r=S(e);if(null!==r)return r.run(t,{source:e,types:n});t()}var N="else",j="eventToken",O="command",C="class",M="attr",P="style",E=/^\$[1-9]\d{0,2}$/,W=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function R(e){let t=[],n=[],r="",l=null,i=!1,s=-1,o=-1,a=e=>{let l=function(e,t,n){let r=-1===t?e.length:t,l=-1===n?0:n;return e.slice(r-e.slice(0,r).trimStart().length,l+e.slice(l).trimEnd().length)}(r,s,o);(!e||l||i)&&(t.push(l),n.push(function(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:W.test(e)?Number(e):e)}(l,i))),r="",i=!1,s=-1,o=-1};for(let t=0;t<e.length;t++){let n=e[t];l?n===l?l=null:(-1===s&&(s=r.length),r+=n,o=r.length):'"'===n||"'"===n?(l=n,i=!0):","===n?a():r+=n}return null!==l&&w(107,[l,e]),a(!0),{args:t,literals:n}}var I=e=>e.trim();function D(e,t){let n=[],r=null;for(let l=0;l<e.length;l++){let i=e[l];null!==r?i===r&&(r=null):"'"===i||'"'===i?r=i:i===t&&n.push(l)}return n}var L=(e,t)=>D(e,t)[0]??-1;function q(e,t){let n=[],r=0;for(let l of D(e,t))n.push(e.slice(r,l)),r=l+1;return n.push(e.slice(r)),n}function z(e,t,n){let r=L(e,"|");if(-1===r)return[e.trim(),[]];let l=e.slice(r+1).trim(),i=n.get(l);return void 0===i&&(i=function(e,t,n){let r=n??e.join("|");return e.map(e=>{let n=L(e,"("),l=(e=>D(e,")").pop()??-1)(e);if(-1===l&&(l=e.lastIndexOf(")")),-1!==n&&-1===l&&w(108,[e]),-1!==l&&-1===n&&w(109,[e]),-1!==l&&l<n&&w(110,[e]),-1!==l&&e.slice(l+1).trim().length>0){let t=e.slice(l+1).trim();w(111,[e,t])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&w(112,[r]),i.includes("#")){let[,e]=i.split("#");w("input"===t?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...R(e.substring(n+1,l))}})}(q(l,"|").map(I),t,e),n.set(l,i)),[e.slice(0,r).trim(),i]}var F=new Map;function U(e){w(1101,[e])}function _(e){let[t,n]=z(e,"output",F);t.includes("@")&&w(32,[t]);let r=t,l=r.startsWith("."),i=l?r.slice(1):r;return(i.length>0&&i.split(".").some(e=>0===e.length)||!l&&0===i.length)&&w(119,[e]),function(e){e.includes("**")&&U(e);let t=e.split(".").length;t>512&&w(117,[e,t])}(r),{Qe:r,Ze:n}}var V=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],B=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function H(e){return e.includes("**")&&U(e),e}var K=0;function J(e,t,n){let r=e.get(t);return void 0===r&&e.set(t,r=n()),r}var Y=()=>new Set,G=()=>[];function X(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}function Q(e,t){return e===t||e!=e&&t!=t}function Z(e,t,n){let r=e._?.get(t);void 0!==r&&r.delete(n)&&0===r.size&&e._.delete(t)}function ee(e,t){for(let n=0;n<t.length;n++){if(null==e)return;e=e[t[n]]}return e}function te(e,t){for(;null!==e&&e.l.n>t;)e=e.l.ae;return null!==e&&e.l.n===t?e:null}function ne(e,t,n){let r=te(e,n);return null!==r&&r.l.o===t.h[n]?r:null}var re=class{constructor(e,t){this.Ie=0,this.u=null,this.Me=0,this.wt=new Set,this.et=new Map,this.Kn=Symbol("wcs.block"),this.element=null,this.vt=[],this.je=null,this.Un=[],this.Vt=0,this.Y=null,this.oe=new Map,this.ue=new Map,this.De=[],this.Le=[],this.Be=[],this.St=!1,this.hn=!1,this.Ht=new WeakMap,this.W=0,this.Kt=0,this.gn=!1,this.Ut=!1,this.qt=!1,this.Te=0,this.qn=()=>{this.W=0,this.gn=!1},this.zn=()=>{this.Te--},this.rp=null,this.rr=null,this.Bo=()=>this.zt(),this._o=(e,t)=>e(this.proxy,...t),this.Yn=[],this.tt=[],this.Wo={$untracked:e=>{let t=this.Y;if(null===t)return e();t.be++;try{return e()}finally{t.be--}},$eqIndex:(e,t=1)=>{let n=te(this.u,t);null===n&&w(7,[e]);let r=this.o(e);if(null!==r.getter||r.se)return this.watchIndex(t),n.w===this.read(r,null);let l=this.Y;if(null!==l){let e=l.getter,n=r.Ce??(r.Ce=[]);if(!n.some(n=>n.getter===e&&n.Xn===t)){n.push({getter:e,Xn:t});let l=e.h[t];(l.Ct??(l.Ct=[])).push({source:r,getter:e})}}return n.w===this.v(r,null)},$eq:(e,t)=>this.eq(e,t),$eqPath:(e,t)=>{let n=this.o(t);return this.eq(e,this.v(n,te(this.u,n.n)))},$dependOn:e=>{this.resolve(H(e),this.u),null!==this.Y&&0===this.Y.be&&this.Gn(this.rp,this.rr,this.Y)},$getAll:(e,t)=>this.getAll(e,t),$setAll:(e,t,n,r)=>this.yn(e,t,n,r),$resolve:(...e)=>{let t=H(e[0]),n=e[1]??[],r=this.o(t,!0);this.bn("$resolve",t,r,n,!0);let l=this.Jn(r,n,null);if(e.length<3)return this.read(r,l);this.A(r,l,e[2])},$postUpdate:e=>{this.resolve(H(e),this.u);let t=this.rp,n=this.rr;"*"===t.s&&null!==n&&(n.R=n.l.C[n.w],this.T.Yt(n)),this.wn(t,n),null!==n&&this.Qn(n,t,void 0,n.R,!1),0===t.n&&this.Zn(t,void 0,void 0,!0),this.Xt(t,n,void 0,void 0,!1)}},this.T=t,this.I=new d(e=>{this.tt.push(e),this.nt(e)}),this.eo(e);let n=this,r={getOwnPropertyDescriptor(e,t){let r=Reflect.getOwnPropertyDescriptor(n.target,t);return r&&(r.configurable=!0),r},get(e,t,r){let l=n.target;if("symbol"==typeof t)return Reflect.get(l,t);if(36===t.charCodeAt(0))return n.ot(t);if(t.indexOf(".")<0){let e=n.I.Mt(t);if(void 0===e||null===e.getter){let e=l[t];if("function"==typeof e)return r===n.proxy&&n.V?.(e)||e}if(void 0!==e&&0===e.n)return n.read(e,null)}return n.resolve(t,n.u),n.read(n.rp,n.rr)},set:(e,t,r)=>"symbol"==typeof t?Reflect.set(n.target,t,r):(n.resolve(H(t),n.u),n.A(n.rp,n.rr,r),!0)};for(let e of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])r[e]=(t,...r)=>Reflect[e](n.target,...r);this.proxy=new Proxy({},r)}o(e,t){let n=this.I.get(e);return t||(n.pn=!0),n}to(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n)){if(t.has(e))continue;t.add(e);let r=Object.getOwnPropertyDescriptor(n,e);if(void 0===r.get&&void 0===r.set)continue;let l=this.o(e);l.getter=r.get??null,l.ie=r.set??null,null!==l.getter&&l.n>0&&(l.P=this.Ie++)}for(let e of this.I.all())this.nt(e)}nt(e){e.t.includes("**")&&U(e.t),("__proto__"===e.s||"prototype"===e.s)&&w(120,[e.t]);let t=e.d;e.se=null!==t&&"*"!==e.s&&t.n===e.n&&(null!==t.getter||t.se),null===e.getter&&this.Vo(e)}Vo(e){let t=e.t,n=e.s;if(E.test(n))e.getter=function(){return this[n]};else{let r=t.split("."),l=r.findIndex((e,t)=>t>0&&e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57);if(l<0||r.indexOf("*",l)>=0)return;e.getter=()=>(this.resolve(t,this.u),this.rp!==e?this.read(this.rp,this.rr):this.read(e.d,this.u)?.[n]),e.ie=r=>{if(this.resolve(t,this.u),this.rp!==e)return this.A(this.rp,this.rr,r);let l=this.read(e.d,this.u);null==l&&w(4,[t,l]),l[n]=r}}e._n=!0,e.n>0&&(e.P=this.Ie++)}_e(e,t){let n=null===e?this.oe:e.c??=new Map,r=n.get(t);return void 0===r&&n.set(t,r=new y(t,e)),t.pn=!0,this.X(r),r}no(e){try{this.X(e)}catch(t){this.Gt(t,e.o.t,e.$?.S??null,"for")}}X(t){let n=this.v(t.o,t.ae);if(n===t.C)return;this.oo(t);let r=function(e,t,n){let r=Array.isArray(t)?t:b;if(r===e.C)return null;let l=e.f,i=r.length,s=l.length,o=new Array(i),a=0;for(;a<i&&a<s&&l[a].R===r[a];)o[a]=l[a],a++;let u=s-1,c=i-1;for(;u>=a&&c>=a&&l[u].R===r[c];)o[c]=l[u],u--,c--;if(a>u)for(let t=a;t<=c;t++)o[t]=new g(e,t,r[t]);else if(a>c)for(let e=a;e<=u;e++)n.Lt(l[e]);else{let t=u<c?u:c;for(let e=a;e<=t;e++)l[e].R===r[e]&&(o[e]=l[e]);let i=new Map;for(let e=u;e>=a;e--){let n=l[e];if(e<=t&&o[e]===n)continue;let r=i.get(n.R);void 0===r?i.set(n.R,n):Array.isArray(r)?r.push(n):i.set(n.R,[r,n])}for(let t=a;t<=c;t++){if(void 0!==o[t])continue;let n,l=r[t],s=i.get(l);void 0!==s&&(Array.isArray(s)?(n=s.pop(),0===s.length&&i.delete(l)):(n=s,i.delete(l))),o[t]=n??new g(e,t,l)}for(let e of i.values())if(Array.isArray(e))for(let t of e)n.Lt(t);else n.Lt(e)}for(let e=a;e<i;e++){let t=o[e];t.w!==e&&(t.w=e,n.jo(t))}return e.f=o,e.C=r,l}(t,n,this);if(null===r)return;if(t.C===n){let e=J(this.Ht,n,G);if(e.push(t),e.length>1)for(let t of e)t.yt=!0}e.Jt?.(this,t,r),(null!==t.$||null!==t.D)&&!t.te&&(t.te=!0,this.Le.push(t),this.Ae());let l=t.o.Ct;if(null!==l)for(let{source:e,getter:n}of l){let l=this.v(e,null),i=r[l],s=t.f[l];i!==s&&(void 0!==i&&i.y&&this.vn(n,i),void 0!==s&&this.vn(n,s))}}jo(e){this.T.Ho(this,e)}Lt(e){e.y=!1;let t=e._;if(null!==t){for(let e of t)Z(e.source,e.key,e.sub);e._=null}if(null!==e.c)for(let t of e.c.values()){this.oo(t);for(let e of t.f)this.Lt(e)}}oo(e){let t=this.Ht.get(e.C);void 0!==t&&(t.splice(t.indexOf(e)>>>0,1),e.yt=!1,1===t.length&&(t[0].yt=!1))}resolve(e,t){let n=m(e),r=this.rp=this.o(n.o,!0),l=n.indexes;this.rr=0===r.n?null:null===l?ne(t,r,r.n):this.Jn(r,l,t,e)}Jn(e,t,n,r){let l=null;for(let i,s=1,o=0;s<=e.n;s++){let a=e.h[s],u=this._e(l,a),c=t[o++];if(c<0)c=ne(n,e,s)?.w??-1;else if(r&&u.C===b&&Object(i=this.v(a,l))===i){let t=e.t.split("."),n=a.t.split(".").length;t[n]=r.split(".")[n],e=this.o(t.join("."),!0),s--;continue}if(l=u.f[c]??null,null===l)break}return this.rp=e,l}rt(e,t){return 0===e.n?ee(this.target,e.q):null===t?void 0:ee(t.R,e.q)}read(e,t){let n=this.Y;if(null!==n&&0===n.be&&this.Gn(e,t,n),null!==e.getter)return this.T.Ko(this,e,t);if(e.se){let n=this.read(e.d,t);return n?.[e.s]}return null===e.d&&!(e.s in this.target)&&!this.wt.has(e.s)&&"then"!==e.s&&"toJSON"!==e.s&&w(301,[e.t],e.s,Object.keys(this.target)),this.rt(e,t)}v(e,t){let n=this.Y;if(null===n)return this.read(e,t);n.be++;try{return this.read(e,t)}finally{n.be--}}Gn(e,t,n){let r=n.getter;e.Wn(r),0===r.n?e.Z!==n.de&&(e.Z=n.de,n.Sn.push(e)):e.n>0&&te(t,Math.min(e.n,r.n))!==te(n.r,Math.min(e.n,r.n))&&(r.ft??(r.ft=new Set)).add(e)}Uo(e,t){for(let n=0;n<this.Vt;n++){let r=this.Un[n];r.getter===e&&r.r===t&&w(701,[e.t])}this.Vt>=128&&w(801,[e.t]);let n=this.Vt++;this.Me++;let r=this.Un[n]??={getter:e,r:t,be:0,de:0,Sn:[]};r.getter=e,r.r=t,r.be=0,r.de=++K,r.Sn.length=0;let l=this.Y;this.Y=r;let i=this.u;this.u=t;try{let t=e.getter.call(this.proxy);return 0===e.n&&this.qo(e,r),t}finally{this.Me--,this.Vt--,this.Y=l,this.u=i,r.r=null}}qo(e,t){let n=t.de;for(let e of t.Sn)e.Z=n;e.Q=e.Q.filter(t=>t.Z===n||t.n>0||!t.se&&Array.isArray(null!==t.getter?t.z:this.rt(t,null))||this.io(t,e))}io(e,t){return e.Io(t),this.tt.push(e),!1}zo(){for(let e=this.tt;e.length>0;e=this.tt){this.tt=[];let t=new Set;for(let n of e)if(!(n.pn||n.mn||null===n.d||n.c.length>0||n.B.length>0)&&(null===n.getter||n._n&&n.P<0)&&null===n._){n.mn=!0,this.I.jt(n),t.add(n.d);for(let e of n.Q)this.io(e,n)}for(let e of t)(e.c=e.c.filter(e=>!e.mn)).length||this.tt.push(e)}}watchIndex(e){let t=this.Y;if(null!==t&&0===t.be){let n=t.getter,r=n.h[e];if(r){let e=r.It??(r.It=[]);e.includes(n)||e.push(n)}}}ot(t){let n=t.charCodeAt(1);if(n>=48&&n<=57){let e=2===t.length?n-48:E.test(t)?+t.slice(1):0;return(e<1||e>128)&&w(1001,[t]),this.watchIndex(e),te(this.u,e)?.w}let r=this.Wo[t];if(void 0!==r)return r;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return e.ot?.(this,t)}eq(e,t){this.resolve(e,this.u);let n=this.rp,r=this.rr;if(null!==n.getter||n.se||n.n>0)return Q(this.read(n,r),t);let l=this.Y;return null!==l&&0===l.be&&this.Yo(n,t,l),Q(this.v(n,null),t)}Yo(e,t,n){let r=n.getter,l=n.r,i=null===l?this.Yn:l._??(l._=[]);for(let l=0;l<i.length;l++){let s=i[l];if(s.sub.getter===r&&s.source===e){if(Q(s.key,t))return void(s.de=n.de);s.de!==n.de&&(Z(e,s.key,s.sub),i.splice(l--,1))}}let s={getter:r,r:l};J(e._??=new Map,t,Y).add(s),i.push({source:e,key:t,sub:s,de:n.de})}Zn(e,t,n,r){this.Qt(e,l=>{let i=l._;if(null===i&&null===l.Ce)return;let s=l===e?[]:l.t.slice(e.t.length+1).split("."),o=ee(t,s),a=ee(n,s);if(null!==l.Ce&&this.Xo(l,o,a,r),null!==i)for(let e of r?i.keys():[o,a]){let t=i.get(e);if(void 0!==t)for(let n of t)null===n.r||n.r.y?this.T.we(this,n.getter,n.r):Z(l,e,n)}})}A(t,n,r,l=!1,i=!1){if(this.Me>0&&w(8),i||this.Te>0?this.Ut=!0:this.qt=!0,e.Pe?.(this,t,n,r,i))return;if(null!==t.ie){try{this.kn(t.ie,n,[r])}finally{this.Xt(t,n,void 0,void 0,!1)}return}null!==t.getter&&w(2,[t.t]),t.n>0&&null===n&&w(3,[t.t]);let s=t.se?this.v(t,n):this.rt(t,n);if(l||!this._t||!Object.is(s,r)||Object(r)===r){if("*"===t.s){let e=n;e.l.C[e.w]=r,e.R=r,this.T.Yt(e)}else{let e=1===t.q.length?0===t.n?this.target:n.R:this.v(t.d,n);null==e&&w(4,[t.t,e]),e[t.s]=r}this.En(t,n),null!==n&&this.Qn(n,t,s,r),0===t.n&&this.Zn(t,s,r),this.Xt(t,n,s,r,!0)}}so(e){return(this.Ht.get(e.C)??[]).filter(t=>t.C===e.C&&(null===t.ae||t.ae.y))}Qn(e,t,n,r,l=!0){let i=e.l;if(!i.yt&&null===i.o.getter&&!i.o.B.length)return;let s=e.R,o=t.t.slice(i.o.t.length+2),a=(t,i)=>{if(void 0===i||i===e)return;let s=this.o(`${t.o.t}.*${o}`,!0);""===o&&(i.R=r,this.T.Yt(i)),l?this.En(s,i):this.wn(s,i),this.Xt(s,i,n,r,l)};for(let t of this.so(i))a(t,t.f[e.w]);if(""===o)return;let u=new Set([i.C]),c=e=>Array.isArray(e)&&e.includes(s),h=(e,t)=>{if(!u.has(e)&&u.add(e))for(let t of this.Ht.get(e)??[])for(let e of t.f)e.R===s&&a(t,e);for(let n of t){let t=n.z,r=t===f;r&&(t=this.oe.get(n)?.C),(r||c(t))&&!u.has(n.B)&&u.add(n.B)&&(!r&&t!==e&&this.T.we(this,n,null),h(t,n.B))}},d=e=>{for(let t of e.Q)if(!u.has(t)&&u.add(t))if(null!==t.getter)d(t);else if(!t.se){let e=this.rt(t,null);c(e)&&h(e,t.B)}};null!==i.o.getter?d(i.o):h(i.C,i.o.B)}wn(e,t){this.Go(e,t,e=>{this.X(e);for(let t of e.yt?this.so(e):[e]){let e=this.o(`${t.o.t}.*`);for(let n of t.f)this.kt(e,n),this.wn(e,n)}})}En(e,t){let n=null===t?this.oe:t.c;if(null!==n)for(let t of n.values())t.o.ee(e)&&this.X(t)}Go(e,t,n){let r=null===t?this.oe:t.c;if(null!==r)for(let t of r.values())t.o.ee(e)&&n(t)}Xo(e,t,n,r){for(let{getter:l,Xn:i}of e.Ce)this.lo(l.h[i],e=>{for(let i of r?e.f.keys():[t,n]){let t="number"==typeof i?e.f[i]:void 0;void 0!==t&&this.vn(l,t)}})}vn(e,t){t.l.n===e.n?this.T.we(this,e,t):this.Zt(t,e,t=>this.T.we(this,e,t))}Xt(t,n,r,l,i){e.ve?.(this,t,n,r,l,i),this.We(t,n)}We(e,t){this.T.Jo(this,e,t),this.Ae()}ao(e){let t=this.et.get(e);if(void 0!==t)return t;let n=Symbol(`wcs.on${e}`);this.et.set(e,n);let r=this.root,l=this.Kn;return r.addEventListener(e,t=>{for(let i=t.target;null!==i&&i!==r;i=i.parentNode){let r=i[n];if(void 0!==r&&(r(t),t.cancelBubble))return;let s=i[l];if(void 0!==s&&s.y&&s.Qo(e,t))return}}),n}reset(t){let n=this.target,r=this.wt;for(let e of this.I.all())null===e.d&&null!==e.getter&&r.add(e.s);this.eo(t);for(let e in n)"$"!==e[0]&&r.add(e);for(let e of r)e in t&&r.delete(e);for(let e of this.ue.values())for(let t of e)this.en(t);for(let e of this.oe.values())this.co(e);this.je=null;try{this.zt()}finally{this.$n()}e.element?.(this,"reset")}eo(t){for(let[e,n]of V)void 0!==t[e]&&a(n,e);let n=t.$features;if(void 0!==n){Array.isArray(n)||w(46);for(let e of n)a(e,"$features")}let r=void 0===t.$behavior?{}:t.$behavior;("object"!=typeof r||!r||Array.isArray(r))&&w(44,["state","$behavior"]);for(let e in r)(!B.includes(e)||"boolean"!=typeof r[e])&&w(44,["$behavior",e]);let[l,i,s]=B.map(e=>r[e]??!0);void 0!==this.target&&(l!==this.Bt||i!==this._t||s!==this.Wt)&&w(45);let o=function(e,t){let n={};for(let r of k(e.$commandTokens,"$commandTokens","$command"))n[r]=t?.[r]??new A(r);return Object.freeze(n)}(t,this.commands),u=function(e,t){let n=new Map;for(let t of k(e.$eventTokens,"$eventTokens"))n.set(t,new A(t));let r=e.$on;if(void 0===r)return n;(null===r||"object"!=typeof r)&&w(22);for(let[e,l]of Object.entries(r)){let r=n.get(e);void 0===r&&w(23,[e]),"function"!=typeof l&&w(24,[e]),r.subscribe((...e)=>t(l,e))}return n}(t,this._o);this.Bt=l,this._t=i,this.Wt=s,e.fe?.(this,t),this.target=t,this.Ie=0;for(let e of this.I.all())e.Mo();this.Yn.length=0,this.to(t),this.commands=o,this.ce=u}co(e){this.no(e);let t=this.o(`${e.o.t}.*`);for(let n of e.f)if(n.ht=null,n._=null,this.kt(t,n),null!==n.c)for(let e of n.c.values())this.co(e)}H(e){let t=[];for(let n=e;null!==n;n=n.l.ae)t.unshift(n.w);return t}Zo(e,t,n){let r=this.ce.get(e);void 0===r&&w(1301,[e],e,this.ce.keys()),r.emit(t,...this.H(n))}command(e){let t=this.commands[e];return void 0===t&&w(1302,[e],e,Object.keys(this.commands)),t}er(e,t,n){this.command(e).emit(t,...this.H(n))}tr(e,t,n){let r=e.includes(".")?this.v(this.o(e),null):this.target[e];return"function"!=typeof r&&w(5,[e]),this.kn(r,n,[t,...this.H(n)])}kn(e,t,n){let r=this.u;this.u=t;try{return e.apply(this.proxy,n)}finally{this.u=r}}kt(e,t){if(null!==e.getter){let n=null===t?this.oe:t.c;if(null!==n)for(let t of n.values())!t.Dt&&t.o.ee(e)&&(t.Dt=!0,this.Be.push(t))}if(null===t)return void this.Qt(e,e=>{let t=this.ue.get(e);if(void 0!==t)for(let e of t)this.en(e)});let n=t.ye;if(null!==n)for(let t=0;t<n.length;t++)n[t].o.ee(e)&&this.en(n[t]);let r=t.$;null!==r&&null!==r.pe&&r.uo(this,e);let l=t.l.D;if(null!==l)for(let n of l){let r=n.map.get(t);void 0!==r&&null!==r.pe&&r.uo(this,e)}}xn(e,t,n){this.Qt(e,e=>{let r=e.B;for(let l=0;l<r.length;l++){let i=r[l];if(0===i.n)this.it(i,null,n);else if(null===t||0===e.n||i.h[1]!==e.h[1]||null!==i.ft&&i.ft.has(e))this.tn(i.h[i.n],e=>this.it(i,e,n));else if(i.n<=e.n){let e=te(t,i.n);null!==e&&this.it(i,e,n)}else this.Zt(t,i,e=>this.it(i,e,n))}})}it(t,n,r){r(t,n)&&(e.Se?.(this,t,n),this.kt(t,n),this.xn(t,n,r))}Qt(e,t){t(e);let n=e.c;for(let e=0;e<n.length;e++)this.Qt(n[e],t)}tn(e,t){this.lo(e,e=>{for(let n of e.f)t(n)})}lo(e,t){if(0===e.n){let n=this.oe.get(e);return void(void 0!==n&&t(n))}this.tn(e.h[e.n],n=>{let r=n.c?.get(e);void 0!==r&&t(r)})}Zt(e,t,n){if(e.l.n===t.n)return n(e);let r=e.c?.get(t.h[e.l.n+1]);if(void 0!==r)for(let e of r.f)this.Zt(e,t,n)}nr(e){let t=e.r;null===t?J(this.ue,e.o,Y).add(e):(t.ye??(t.ye=[])).push(e)}Nn(e){let t=e.r;if(null===t)return void this.ue.get(e.o)?.delete(e);let n=t.ye;t.y&&null!==n&&n.splice(n.indexOf(e)>>>0,1)}en(e){e.te||(e.te=!0,this.De.push(e),this.Ae())}Ae(){this.St||(this.St=!0,queueMicrotask(this.Bo))}Rn(){for(let e of this.De)e.te=!1;for(let e of this.Le)e.te=!1;for(let e of this.Be)e.Dt=!1;this.De=[],this.Le=[],this.Be=[],this.T.wt(this)}fo(t,n){let r=[...new Set([...this.De,...this.Le,...this.Be].map(e=>e.o.t))];console.error(`[@wcstack/state] ${$(t)}`,r),e.st?.(this,{type:"state:render-chain-limit",maxDepth:n,paths:r}),this.Rn()}zt(){this.St=!1;let t=this.Kt;this.Kt=0;let n=0;if(!this.Ut||this.qt?this.qn():t>0?n=t:1===(n=++this.W)&&setTimeout(this.qn,0),this.Ut=this.qt=!1,n>100)101===n?this.fo(41,100):this.Rn();else{this.hn=!0;try{for(let e=0;this.De.length>0||this.Le.length>0||this.Be.length>0;e++){if(e>=32){this.gn?this.Rn():this.fo(11,32),this.gn=!0;break}let t=this.Be;if(t.length>0){this.Be=[];for(let e of t)e.Dt=!1,this.no(e)}let r=this.Le,l=this.De;this.Le=[],this.De=[];let i=T("state",()=>{for(let e of r){e.te=!1;for(let t of[e.$,...e.D??[]])if(null!==t&&t.y)try{t.Et()}catch(n){this.Gt(n,e.o.t,t.S,"for")}}for(let e=0;e<l.length;e++){let t=l[e];t.te&&(t.te=!1,(null===t.Tn||t.Tn.y)&&this.Ve(t))}this.hn||(this.He(),this.St&&(this.Kt=n+1))});void 0!==i&&i.then(void 0,e=>console.error(e))}}finally{this.hn=!1}this.Ut=this.qt=!1,this.He(),e.Fe?.(this),this.zo(),t>0&&this.St&&(this.Kt=n+1)}}$t(e,t){this.vt.push([e,t])}Gt(e,t,n,r){this.$t(e,{o:{t},a:n,nn:()=>r})}Ve(e){try{e.apply()}catch(t){return void this.vt.push([t,e])}null!==this.je&&this.po(e.o,e.r)}po(e,t){let n=J(this.je,e.t,G);null!==t&&n.push(this.H(t))}$n(){this.je="function"==typeof this.target.$renderedCallback?new Map:null}He(){let t=this.je;if(null!==t&&t.size>0){this.je=new Map;let e,n=[...t.keys()],r={};for(let[e,n]of t)n.length>0&&(r[e]=n);this.Te++;try{e=this.ke("$renderedCallback",[n,r])}catch(e){console.error(e)}X(e)?e.then(this.zn,e=>{this.zn(),console.error(e)}):this.Te--}if(0===this.vt.length)return;let n=this.vt;this.vt=[];let r=this.target.$errorCallback;for(let[t,l]of n){e.Ke?.(this,t,l);let n=l.o.t,i=l.nn();if("function"==typeof r)try{let e=this.ke("$errorCallback",[t,{path:n,bindingType:i,node:l.a}]);X(e)&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}else console.error(`[@wcstack/state] ${$(12,[i,n])}`,t)}}ke(e,t=[]){let n=this.target[e];return"function"==typeof n?this.kn(n,null,t):void 0}mo(e,t,n){if(0===e.n)return void n(null,[]);let r=[],l=(i,s)=>{let o=e.h[i];this.read(o,s);let a=this._e(s,o),u=t=>{r.push(t.w),i===e.n?n(t,r):l(i+1,t),r.pop()};for(let e of i-1<t.length?[a.f[t[i-1]]]:a.f)void 0!==e&&u(e)};l(1,null)}getAll(e,t){let n=this.o(e,!0);void 0!==t&&this.bn("$getAll",e,n,t,!1);let r=t;if(void 0===r){r=[];let t=this.u;if(null!==t&&n.n>0){for(let e=1;e<=n.n;e++){let l=ne(t,n,e);if(null===l)break;r.push(l.w)}0===r.length&&w(6,[e])}}let l=[];return this.mo(n,r,e=>l.push(this.read(n,e))),l}yn(e,t,n,r){Array.isArray(t)||w(9,[e]),this.Me>0&&w(8);let l=this.o(e,!0);this.bn("$setAll",e,l,t,!1);let i=[];this.mo(l,t,(e,t)=>i.push([e,t.slice()]));let s=!0===r?.spread;s&&(!Array.isArray(n)||n.length!==i.length)&&w(10,[e,i.length]);let o=0;for(let e=0;e<i.length;e++){let[t,r]=i[e],a="function"==typeof n?n(this.v(l,t),...r):s?n[e]:n;void 0!==a&&(this.A(l,t,a),o++)}return o}bn(e,t,n,r,l){let i=r.length;(i>n.n||l&&i<n.n)&&w(l?901:902,[e,t,n.n,i])}},le={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1},ie=()=>le,se=new Map,oe=new Set(["if","elseif","else","for"]),ae=new Set([N,"if","elseif","for","..."]),ue=new Set([C,M,P,O,j,"state"]);function ce(e){let t=function(e){return q(e,";")}(e).map(I).filter(e=>e.length>0).map(e=>{let t=L(e,":");-1===t&&w(101,[e]);let n=e.slice(0,t).trim(),r=e.slice(t+1).trim(),l=n.split("#")[0].split("|")[0].trim();if(ae.has(l)){let t;return l!==n&&w(102,[e,l]),l===N?(r.length>0&&w(103,[e]),t={Qe:"#else",Ze:[]}):"..."===l?(0===r.length&&w(104,[e]),t=_(r),t.Ze.length>0&&w(105,[e])):(t=_(r),"for"===l&&t.Ze.length>0&&w(121,[e])),{Ee:l,$e:[l],on:[],M:[],...t,b:"..."===l?"spread":l}}let i=_(r),s=function(e){let[t,n]=z(e,"input",se),r=t.split("#").map(I);r.length>2&&w(115,[t]);let[l,i]=r,s=l.split(".").map(I);return!(s.length>1&&""===s[0])&&(0===l.length||s.some(e=>0===e.length))&&w(116,[e]),{Ee:l,$e:s,on:i?i.split(",").map(I):[],M:n}}(n),[o]=s.$e;if(""===o&&s.$e.length>1){let e=s.$e.slice(1);return(e.includes("")||ue.has(e[0]))&&w(106,[n]),{...s,Ee:e.join("."),$e:e,...i,b:"prop"}}return{...s,...i,b:"radio"===l||"checkbox"===l?l:o===j||o.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>oe.has(e.b))&&w(201,[e]),t}var fe=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],he=new Map,de=new Map;function pe(e){for(let t of Object.keys(e))he.set(t,{...e[t]});de.clear()}function me(e){return he.has(e)}function ge(e){w(26,[e])}function ye(e){w(27,[e])}function be(e){w(28,[e])}function ve(e){w(29,[e])}function $e(e){return!(!e||isNaN(Number(e)))}function we(e,t){return $e(e)||ye(t),Number(e)}function Ae(e,t,n){return we(e?.[t]??ge(n),n)}function ke(e,t){return void 0!==t&&t.length>0?t[0]:e}var xe=(e,t)=>({factory:n=>{let r=Ae(n,0,e);return n=>("number"!=typeof n&&be(e),t(n,r))},arity:[1,1]}),Se={eq:{factory:(e,t)=>{let n=e?.[0]??ge("eq"),r=ke(n,t);return e=>"number"==typeof e?"string"!=typeof r?e===r:($e(n)||ye("eq"),e===Number(n)):"string"==typeof e?e===n:e===r},arity:[1,1]},ne:{factory:(e,t)=>{let n=e?.[0]??ge("ne"),r=ke(n,t);return e=>"number"==typeof e?"string"!=typeof r?e!==r:($e(n)||ye("ne"),e!==Number(n)):"string"==typeof e?e!==n:e!==r},arity:[1,1]},not:{factory:()=>e=>!e,arity:[0,0]},lt:xe("lt",(e,t)=>e<t),le:xe("le",(e,t)=>e<=t),gt:xe("gt",(e,t)=>e>t),ge:xe("ge",(e,t)=>e>=t),falsy:{factory:()=>e=>!e,arity:[0,0]},truthy:{factory:()=>e=>!!e,arity:[0,0]},boolean:{factory:()=>e=>!!e,arity:[0,0]}},Te=!1;function Ne(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function je(e){return 0===e.length?null:(Te||(Te=!0,pe(Se)),e.map(e=>function(e,t,n){let r=`${e}${function(e,t){return`${JSON.stringify(e)}${JSON.stringify(t)}`}(t,n)}`,l=de.get(r);if(typeof l<"u")return l;let i=he.get(e);void 0===i&&function(e,t){fe.includes(e)&&v(`[wcs/filter-unknown] filter not found: ${e}. "${e}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,e,t),w(501,[e],e,t)}(e,he.keys());let[s,o]=i.arity;t.length<s&&w(601,[e,s,t.length]),t.length>o&&w(602,[e,o,t.length]);let a=i.factory(t,n);return de.set(r,a),a}(e.Hn,e.args,e.literals)))}var Oe=Symbol.for("wcstack.trustedTypes.policy");function Ce(){let e=globalThis[Oe];return null!==e&&"object"==typeof e?e:null}function Me(e){globalThis[Oe]=e}function Pe(e){return"innerHTML"===e||"outerHTML"===e||"srcdoc"===e}function Ee(e){if(globalThis.trustedTypes?.isHTML(e))return e;let t=null==e?"":String(e),n=Ce(),r=n?.createHTML;return"function"==typeof r?r.call(n,t):t}var We=Symbol.for("wcstack.state.view-transition-naming"),Re=new WeakSet;function Ie(){let e=S("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var De=new WeakMap,Le=e=>e.customElementRegistry??customElements;function qe(e,t,n,r,l,i=!1){let s=n.localName;if(!s.includes("-"))return l(null);let o=Le(n);if(!i&&!n.isConnected&&void 0===o.get(s)&&"customElementRegistry"in n)return void queueMicrotask(()=>qe(e,t,n,r,l,!0));let a=()=>{let e=o.get(s);o.upgrade(n),l(e?function(e){if(De.has(e))return De.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Map,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,ho:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.set(e.name,{attribute:"string"==typeof e.attribute?e.attribute:null});for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return De.set(e,n),n}(e):null)};if(!i&&void 0!==o.get(s))return a();null!==r&&!r.y||function(e,t,n){let r=n;null!==t&&(t.xt??=[]).push(()=>{r=null}),e.then(()=>r?.())}(o.whenDefined(s),r,()=>{try{a()}catch(r){Be(e,r,t,n)}e.Ae()})}function ze(t,n,r,l,i=n.o,s,o,a){let u=a.properties.get(l)??null,c=a.inputs.get(l),f=t.Wt;f&&null===u&&void 0===c&&w(38,[l]);let h=n.K;(null===u?"element"===h||"auto"===h:void 0===c&&("state"===h||"auto"===h))&&w(39,[h,l]),"connect"===n.X&&null===u&&w(40,[l]);let d=f&&null!==u&&void 0===c,p=new Je(t,_e,r,l,i,s,o,n.x,void 0);p.M=n.M,p.attribute=c?.attribute??null,nt(t,p,!d),null!==u&&!n.ro&&r.addEventListener(u.event,n=>{let i;null!==u.getter?i=u.getter(n):(i=n.detail,u.ho||e.detail?.(r,l,i)),(!p.An||!Object.is(i,p.value))&&(i=Ne(p.M,i),null===p.x&&(p.value=i),t.A(p.o,p.r,i,u.ho,!0))});let m=h??(d?"element":"state");if("state"===m)d||t.Ve(p);else if("element"===m||"auto"===m){let e=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==t.v(p.o,p.r))return void(d||t.Ve(p));let e=r[l];null===p.x&&(p.value=e),t.A(p.o,p.r,e,!1,!0)};"connect"!==n.X||r.isConnected?e():Promise.resolve().then(e)}return p}function Fe(e,t,n){w(e,[t.localName,n])}var Ue=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),_e=11,Ve=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],Be=(e,t,n,r)=>e.Gt(t,n.o?.t??n.Nt,r,Ve[n.i]),He=Symbol();function Ke(e,t,n){let r=t.K;return null===r||"state"===r||"auto"===r&&void 0!==e.v(t.o,n)?t.U:He}var Je=class{constructor(e,t,n,r,l,i,s,o,a,u=null){this.te=!1,this.M=null,this.attribute=null,this.An=!1,this.engine=e,this.i=t,this.a=n,this.name=r,this.o=l,this.r=i,this.Tn=s,this.x=o,this.value=a,this.W=u}nn(){return Ve[this.i]}apply(){if(null!==this.W)return void this.W.Et();let e=Ne(this.x,this.engine.read(this.o,this.r));if(e===this.value&&9!==this.i&&("object"!=typeof e||null===e||this.i===_e||8===this.i||Pe(this.name)))return;if(this.value===He)return void(this.value=e);let t=this.a;if(this.i!==_e)9===this.i?t.checked=void 0!==e&&this.rn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.rn()):Ge(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.An=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.An=!1}null!==this.attribute&&function(e,t,n){try{if(null==n||!1===n)e.removeAttribute(t);else if(!0===n)e.setAttribute(t,"");else{let r=n;if("object"==typeof n)try{r=JSON.stringify(n)}catch{}e.setAttribute(t,String(r))}}catch{}}(t,this.attribute,e)}}rn(){return Ne(this.M,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.rn()}else if(10===this.i){let r=this.rn(),l=n.v(this.o,this.r),i=Array.isArray(l)?l:[],s=i.includes(r);if(t.checked?s:!s)return;e=s?i.filter(e=>e!==r):[...i,r]}else e=Ne(this.M,t[this.name]),this.value=NaN;n.A(this.o,this.r,e,!1,!0)}},Ye=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Ge(e,t,n,r){switch(e){case 0:return void(t.data=null==r?"":String(r));case 1:return void(Ye(n)?t[n]="innerHTML"===n?Ee(r):null==r?"":String(r):Pe(n)?null==r&&"srcdoc"===n?t.removeAttribute(n):void 0!==r&&(t[n]=Ee(r)):void 0!==r&&(t[n]!==r&&!("value"===n&&t.value===String(r))&&(t[n]=r),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[Xe]=[n,r])));case 8:return void(t.innerHTML=Ee(r));case 2:return null!=r&&"boolean"!=typeof r&&w(401,[n,typeof r]),void t.classList.toggle(n,!0===r);case 3:return void(null==r?t.removeAttribute(n):t.setAttribute(n,String(r)));case 4:return void(n.includes("-")?null==r?t.style.removeProperty(n):t.style.setProperty(n,String(r)):t.style[n]=null==r?"":String(r))}}var Xe=Symbol();function Qe(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[Xe];void 0!==n&&(t[n[0]]=n[1])}var Ze=class{constructor(e,t,n,r){this.y=!0,this.ye=null,this.c=null,this.xt=null,this.Fn=null,this.r=e,this.Ue=t,this.j=n,this.F=r}Qo(e,t){let n=t.target,r=this.F,l=[],i=null;for(let t of r.ce){if(t.name!==e)continue;let s=r.On[t.a],o=ft(null===this.j?this.Ue:this.j[s[0]],s,1);o.contains(n)&&(o!==i&&l.unshift([]),l[0].push(t),i=o)}for(let e of l){for(let n of e)n.Pn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.j?this.Ue:this.j[this.j.length-1]}qe(){let e=this.Fn;return(null===e?null:e.Cn(this.Ue))??this.Ue}insertBefore(e,t){let n=this.s;for(let r=this.qe();;){let l=r.nextSibling;if(e.insertBefore(r,t),r===n)return;r=l}}bo(){null===this.j?this.Ue.remove():ht(this.qe(),this.s)}Ne(e){if(this.y=!1,null!==this.xt)for(let e of this.xt)e();let t=this.ye;if(null!==t)for(let n=0;n<t.length;n++)e.Nn(t[n]);if(null!==this.c)for(let e of this.c)e.Ne()}},et=class extends Ze{constructor(e,t,n,r){super(e,t,n,r),this.wo=0,this.V=null,this.pe=0===r.ze.length?null:new Array(2*r.ze.length)}vo(e,t){let n=this.V??=new Array(this.F.ze.length),r=n[t];if(void 0===r){let l=this.F.ze[t],i=this.pe;r=n[t]=new Je(e,l.i,i[2*t],l.name,l.o,this.r,this,l.x,i[2*t+1])}return r}uo(e,t){let n=this.F.ze;for(let r=0;r<n.length;r++)n[r].o.ee(t)&&e.en(this.vo(e,r))}Ne(e){let t=this.r;t.$===this&&(t.$=null),super.Ne(e)}};function tt(e,t,n,r){let l=te(n,t.n);try{return e._e(l,t)}catch(n){return e.Gt(n,t.t,r,"for"),null===l?e.oe.get(t):l.c.get(t)}}function nt(e,t,n){n&&e.nr(t);let r=t.Tn;null!==r&&(r.ye??=[]).push(t)}var rt=null;function lt(){let e=rt;return rt=null,e}var it=-1;function st(t,n,r,l,i=null){let s,o=n.On,a=n.build,u=n.So,c=null,f=e.Oe?.(n,null===l?i:l.S,null!==l),h=!f&&n.In,d=f?document.createDocumentFragment():(h?n.root:n.sn).cloneNode(!0);if(!f)for(let e=0;e<a.length;e++){let t=a[e];u[t]=ft(d,o[t],h?1:0)}h?s=d:(c=f||[...d.childNodes],s=c[0]);let p,m=null;if(null!==l?(p=m=new et(r,s,c,n),null===l.map?r.$=m:l.map.set(r,m)):p=new Ze(r,s,c,n),it>=0&&function(e,t,n,r){let l=null;if(null===t)l=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===l;e++)1===t[e].nodeType&&(l=t[e]);let i=l?.style;if(null===l||void 0===i||Re.has(l))return;let s=globalThis[We]??={counter:0,assigned:0,warned:!1};s.assigned>=r?s.warned||(s.warned=!0,console.warn(`[@wcstack/state] ${$(25,[r])}`)):(Re.add(l),s.assigned++,i.setProperty("view-transition-name",`wcs-${n}-${++s.counter}`),i.setProperty("view-transition-class",`wcs-${n}`))}(s,c,null!==l?"row":"branch",it),n.ce.length>0){let e=t.Kn;if(null===c)s[e]=p;else for(let t of c)1===t.nodeType&&(t[e]=p)}let g=n.sr,y=t.je,b=n.lr?u.slice(0,o.length):u,v=null===m?null:m.pe;if(null!==v){let e=n.ze;for(let t=0;t<e.length;t++)v[2*t]=b[e[t].a],v[2*t+1]=e[t].U}for(let e=0;e<g.length;e++){let n=g[e],l=b[n.a],i=n.P;if(i>=0&&null!==v){let e=m.V?.[i];if(void 0!==e){e.te=!1,t.Ve(e);continue}try{let e=Ne(n.x,t.read(n.o,r));e!==n.U&&(Ge(n.i,l,n.name,e),v[2*i+1]=e),null!==y&&t.po(n.o,r)}catch(e){t.$t(e,m.vo(t,i))}continue}switch(n.i){case 6:{let e=new ct(t,n.F,tt(t,n.o,r,l),l);(p.c??=[]).push(e),l===s&&(p.Fn=e),e.Et();break}case 7:{let e=at(t,n.G.map(e=>({F:e.F,o:e.o,x:e.x,S:b[e.a]})),r,p);(p.c??=[]).push(e),l===s&&(p.Fn=e);break}default:try{ot(t,n,l,r,p)}catch(e){Be(t,e,n,l)}}}return rt=p,d}function ot(t,n,r,l,i){let s=r;switch(n.i){case 5:return void function(e,t,n,r,l){let i=n.Pn,s=e=>i(e,r);if(n.et){let r=e.ao(n.name),l=t[r];t[r]=void 0===l?s:e=>{l(e),s(e)},n.xe&&t.addEventListener(n.name,e=>e.bubbles||s(e))}else t.addEventListener(n.name,s),n.yo&&null!==l&&(l.xt??=[]).push(()=>t.removeEventListener(n.name,s))}(t,r,n,l,i);case 12:return void qe(t,n,s,i,r=>function(t,n,r,l,i){let s=n.name,o=t.command(n.Nt.slice(9)),a=null===i?e.or?.(r,s):null;a||(null===i&&Fe(1202,r,`command.${s}`),i.commands.has(s)||w(1203,[r.localName,s]));let u=new WeakRef(r),c=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?a?a(t,e):t[s](...e):void 0;c()});null!==l&&(l.xt??=[]).push(c)}(t,n,s,i,r));case 13:return void qe(t,n,s,i,e=>function(e,t,n,r,l){let i=t.name;null===l&&Fe(1202,n,`eventToken.${i}`);let s=l.properties.get(i);void 0===s&&w(1204,[n.localName,i]);let o=t.Nt;n.addEventListener(s.event,n=>{t.Rt&&n.preventDefault(),t.Tt&&n.stopPropagation();try{e.Zo(o,n,r)}catch(e){console.error(e)}})}(t,n,s,l,e))}let o=n.o,a=te(l,o.n);if(14===n.i)return void qe(t,n,s,i,e=>function(e,t,n,r,l,i){null===i&&Fe(1501,n,`"...: ${t.o.t}"`);let s=new Set([...i.properties.keys(),...i.inputs.keys()]);for(let o of s){if(t.go?.includes(o))continue;let s=e.o(`${t.o.t}.${o}`),a=0===s.n?null:r;ze(e,{...t,K:null,X:null},n,o,s,a,l,i)}}(t,n,s,a,i,e));if(n.xe&&1===n.i)return void qe(t,n,s,i,r=>function(t,n,r,l,i,s){if(null!==s)return void ze(t,n,r,n.name,n.o,l,i,s);let o=new Je(t,1,r,n.name,n.o,l,i,n.x,Ke(t,n,l));o.M=n.M,!e.ar?.(o,n.ro)&&(nt(t,o,!0),t.Ve(o))}(t,n,s,a,i,r));let u=new Je(t,n.i,r,n.name,o,a,i,n.x,Ke(t,n,a));u.M=n.M,nt(t,u,!0),t.Ve(u),null!==n.At&&r.addEventListener(n.At,()=>u.ir())}function at(e,t,n,r){let l=new ut(e,t,n),i=null;for(let s of t){if(null===s.o)continue;let t=s.o,o=new Je(e,7,s.S,"if",t,te(n,t.n),r,null,void 0,l);nt(e,o,!0),null===r&&l.ue.push(o),i??=o}return e.Ve(i),l}var ut=class{constructor(e,t,n){this.y=!0,this.O=null,this.w=-1,this.ue=[],this.engine=e,this.G=t,this.r=n}Cn(e){return null!==this.O&&this.G[this.w].S===e?this.O.qe():null}Et(){let e=this.engine,t=-1;for(let n=0;n<this.G.length;n++){let r=this.G[n];if(null===r.o||Ne(r.x,e.read(r.o,te(this.r,r.o.n)))){t=n;break}}if(t!==this.w&&(it=Ie(),null!==this.O&&(this.O.bo(),this.O.Ne(e),this.O=null),this.w=t,t>=0)){let n=this.G[t],r=st(e,n.F,this.r,null,n.S);this.O=lt();let l=n.S.parentNode;l.insertBefore(r,n.S),Qe(l)}}Ne(){this.y=!1;for(let e of this.ue)this.engine.Nn(e);null!==this.O&&this.O.Ne(this.engine)}},ct=class{constructor(e,t,n,r){this.y=!0,this.Re=[],this.engine=e,this.F=t,this.l=n,this.S=r,null===n.$?(n.$=this,this.map=null):((n.D??=[]).push(this),this.map=new Map)}Cn(e){return 0===this.Re.length?null:this.Re[0].qe()}Pt(e){return null===this.map?e.$:this.map.get(e)??null}jt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Ne(this.engine)}Et(){let e=this.engine,t=this.l.f,n=this.Re;it=Ie();let r=t.length,l=n.length,i=this.S,s=i.parentNode;if(0===r){if(l>0){let e=n[0].qe(),t=n[l-1].s,r=[];for(let n=s.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==i&&3!==n.nodeType){r=null;break}r.push(n)}null!==r?s.replaceChildren(...r):ht(e,t);for(let e=0;e<l;e++)this.jt(n[e])}return void(this.Re=[])}let o=new Array(r),a=0;for(;a<r&&a<l&&this.Pt(t[a])===n[a];)o[a]=n[a],a++;let u=l-1,c=r-1;for(;u>=a&&c>=a&&this.Pt(t[c])===n[u];)o[c]=n[u],u--,c--;for(let e=a;e<=u;e++){let t=n[e],r=t.r;r.y&&this.Pt(r)===t?t.wo=e:(t.bo(),this.jt(t))}if(a<=c){let n=c-a+1,u=new Int32Array(n),f=!1;if(l>0)for(let e=0;e<n;e++){let n=this.Pt(t[a+e]);null!==n&&n.y?(u[e]=n.wo,f=!0):u[e]=-1}let h=c+1<r?o[c+1].qe():i;if(f){let r=function(e){let t=e.length,n=new Uint8Array(t),r=new Int32Array(t).fill(-1),l=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let i=0,s=l.length;for(;i<s;){let n=i+s>>1;e[l[n]]<t?i=n+1:s=n}i>0&&(r[n]=l[i-1]),l[i]=n}let i=l.length>0?l[l.length-1]:-1;for(;i>=0;)n[i]=1,i=r[i];return n}(u),l=h;for(let i=n-1;i>=0;i--){let n=t[a+i],u=this.Pt(n);null!==u&&u.y?0===r[i]&&u.insertBefore(s,l):(s.insertBefore(st(e,this.F,n,this),l),u=lt()),o[a+i]=u,l=u.qe()}}else{let n=document.createDocumentFragment();for(let r=a;r<=c;r++)n.appendChild(st(e,this.F,t[r],this)),o[r]=lt();s.insertBefore(n,h)}}this.Re=o,Qe(s)}Ne(){this.y=!1;let e=this.l;if(e.$===this)e.$=null;else if(null!==e.D){let t=e.D.indexOf(this);t>=0&&e.D.splice(t,1),0===e.D.length&&(e.D=null)}for(let e of this.Re)e.Ne(this.engine);this.map?.clear()}};function ft(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let r=t[n];r>0;r--)e=e.nextSibling}return e}function ht(e,t){for(let n,r=e;r!==t;r=n)n=r.nextSibling,r.remove();t.remove()}var dt=()=>le.bindAttributeName;function pt(){return{a:0,i:1,name:"",o:null,x:null,U:c,Pn:null,F:null,G:null,M:null,At:null,xe:!1,K:null,X:null,ro:!1,Rt:!1,Tt:!1,Nt:null,go:null,P:-1,et:!1,yo:!1}}var mt=["state","element","auto","none"],gt=["call","connect"],yt="$command.";function bt(t,n,r){E.test(n)&&(null===r&&w(1401,[n,Number(n.slice(1))]),n=`${r.t}.*.${n}`);let l=t.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&w(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(n,r)),i=null===r?0:r.n+1;l.n>i&&w(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?r:r.h[e];l.h[e]!==t&&w(1403,[l.t,l.h[e].t,t.t])}return e.ko?.(t,l),l}var vt=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),$t=e=>8===e.i||vt(e)||1===e.i&&Ye(e.name);function wt(e){w(202,[e])}function At(e,t,n,r,l){let i=ce(t).map(t=>function(e,t,n,r,l){let i=function(e,t){let n=t.find(e=>e.startsWith("on")),r=null,l=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Wt||w(31);let i=n.slice(0,t).trim(),s=n.slice(t+1).trim(),o="init"===i;!o&&"sync"!==i&&w(33,[i,n]),null!==(o?r:l)&&w(34,[i]),(o?mt:gt).includes(s)||w(35,[i,s]),o?r=s:l=s}return{ro:t.includes("ro"),Rt:t.includes("prevent"),Tt:t.includes("stop"),event:n?n.slice(2):null,K:r,X:l}}(e,t.on),s=r.localName.includes("-"),o=t.$e,a=t.Qe;if("event"===t.b){if(null!==i.K&&"none"!==i.K&&w(36),"eventToken"===o[0])return{...pt(),a:l,i:13,name:o.slice(1).join("."),Nt:a,xe:s,Rt:i.Rt,Tt:i.Tt};let n=a.startsWith(yt)?a.slice(9):null,{Rt:r,Tt:u}=i,c=t.Ee.slice(2),f=t.on.includes("direct"),h=!f&&Ue.has(c);return h&&e.ao(c),{...pt(),a:l,i:5,name:c,et:h,xe:s,yo:f,Pn(t,l){r&&t.preventDefault(),u&&t.stopPropagation();try{if(null!==n)e.er(n,t,l);else{let n=e.tr(a,t,l);X(n)&&n.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.b)return{...pt(),a:l,i:14,o:bt(e,a,n),xe:s};if("command"===o[0]&&o.length>1)return a.startsWith(yt)||w(1201,[t.Ee,a]),{...pt(),a:l,i:12,name:o.slice(1).join("."),Nt:a,xe:s};let u=bt(e,a,n),c={...pt(),a:l,i:1,name:t.Ee,o:u,x:je(t.Ze),M:je(t.M),ro:i.ro,K:i.K,X:i.X};if("radio"===t.b||"checkbox"===t.b)return("element"===i.K||"auto"===i.K)&&w(37,[t.b,i.K]),c.i="radio"===t.b?9:10,i.ro||(c.At=i.event??"input"),c;if(o.length>1){let e=o.slice(1).join("."),t=o[0];if("class"===t||"attr"===t||"style"===t)return c.K=null,c.name=e,"class"===t?(c.i=2,c.U=r.classList.contains(e)):c.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,c}return"html"===t.Ee?(c.i=8,c):(c.name="text"===t.Ee?"textContent":t.Ee,c.xe=s&&!Pe(c.name),!s&&!i.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(r,c.name)&&(c.At=i.event??("select"===r.localName?"change":"input")),c)}(e,t,n,r,l));for(let e=0;e<i.length;e++)14===i[e].i&&(i[e].go=i.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return i}var kt=/\{\{([\s\S]+?)\}\}/g;function xt(e){let t=e.data,n=[],r=0;kt.lastIndex=0;for(let l=kt.exec(t);null!==l;l=kt.exec(t)){let i=kt.lastIndex-l[0].length;i>r&&e.before(t.slice(r,i));let s=e.ownerDocument.createTextNode("");e.before(s),n.push({a:s,cr:l[1].trim()}),r=kt.lastIndex}return 0===n.length||(r<t.length&&e.before(t.slice(r)),e.remove()),n}function St(e,t,n,r){let l=function(e){return{Ee:"textContent",$e:["textContent"],on:[],M:[],..._(e),b:"text"}}(t);return{...pt(),a:r,i:0,o:bt(e,l.Qe,n),x:je(l.Ze),U:""}}function Tt(e){let t=e.getAttribute(dt());if(null===t)return null;let n=ce(t)[0];return void 0===n||"for"!==n.b&&"if"!==n.b&&"elseif"!==n.b&&"else"!==n.b?null:n}var Nt=(e,t)=>0===e?le.commentIfPrefix:null===t.o?le.commentElsePrefix:le.commentElseIfPrefix;function jt(e,t,n){let r=(t,r)=>({el:t,o:"else"===r.b?null:bt(e,r.Qe,n),x:"else"===r.b?null:je(r.Ze)}),l=[r(t,Tt(t))];for(let e=t.nextSibling;null!==e;e=e.nextSibling){if(3===e.nodeType&&""===e.data.trim()||8===e.nodeType)continue;if(1!==e.nodeType||"template"!==e.localName)break;let t=Tt(e);if(null===t||"elseif"!==t.b&&"else"!==t.b||(l.push(r(e,t)),"else"===t.b))break}return l}var Ot=new WeakSet;function Ct(t,n,r,l,i,s,o,a){let u=(n,r)=>{let i=document.createComment(r);return n.replaceWith(i),l&&e.Mn?.(t,i,n),i},c=n=>{for(let f=0;f<n.length;f++){let h=n[f];if(null!==h.parentNode)if(1===h.nodeType){let n=h,a=n.localName;if(l){if("script"===a||"style"===a||Ot.has(n))continue;if(Ot.add(n),a===le.tagNames.state){c([...n.childNodes]);continue}}let f="template"===a?Tt(n):null;if(null!==f){if("for"===f.b){let e=bt(t,f.Qe,r),l=Et(t,n,e,!0);i(u(n,le.commentForPrefix),e,l)}else"if"===f.b?s(jt(t,n,r).map((e,n)=>({F:Et(t,e.el,r,!1),o:e.o,x:e.x,S:u(e.el,Nt(n,e))}))):wt(f.b);continue}let d=n.getAttribute(dt()),p=null===d?null:At(t,d,r,n,0),m="noscript"!==a&&"iframe"!==a&&!p?.some($t)&&!e.Eo?.(n);try{l&&m&&c([...n.childNodes])}finally{null!==p&&o(n,p)}!l&&m&&c([...n.childNodes])}else if(3===h.nodeType&&t.Bt&&h.data.includes("{{")&&!Ot.has(h))for(let{a:e,cr:t}of xt(h))a(e,t);else if(8===h.nodeType){let e=Mt.exec(h.data),t=e&&h.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");h.replaceWith(t),a(t,e[1])}}}};c(n)}var Mt=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Pt=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Et(e,t,n,r){let l=document.importNode(Pt(t),!0),i=[],s=[],o=e=>i.push(e)-1;Ct(e,[...l.childNodes],n,!1,(e,t,n)=>{s.push({...pt(),a:o(e),i:6,o:t,F:n})},e=>{let t=e.map(e=>({a:o(e.S),F:e.F,o:e.o,x:e.x}));s.push({...pt(),a:t[0].a,i:7,G:t})},(e,t)=>{let n=o(e);for(let e of t)vt(e)&&w(203,[e.name]),e.a=n;s.push(...t),e.removeAttribute(dt())},(t,r)=>{s.push(St(e,r,n,o(t)))}),Dt(l,new Set(i),!0);let a=i.map(e=>function(e,t){let n=[];for(let r=t;r!==e;r=r.parentNode){let e=0;for(let t=r.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(l,e)),u=1===l.childNodes.length&&8!==l.firstChild.nodeType,c=s.some(e=>6===e.i||7===e.i),f=[],h=new Set,d=[],p=[],m=r?n.n+1:-1;for(let e of s){if(5===e.i&&e.et&&!e.xe&&!Wt(i[e.a],l)){d.push(e);continue}p.push(e);let t=e.o;if(null!==t&&t.n===m&&t.h[m]===n&&Rt(e)&&(e.P=f.push(e)-1),7===e.i)for(let t of e.G)h.add(t.a);else h.add(e.a)}let g=[...h].sort((e,t)=>e-t);return{sn:l,root:u?l.firstChild:null,On:a,build:g,ce:d,sr:p,In:u,lr:c,So:[],ze:f}}function Wt(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Rt(e){if(null!==e.K)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.xe&&null===e.At;default:return!1}}var It=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Dt(e,t,n){for(let r=e.firstChild;null!==r;){let e=r.nextSibling;3===r.nodeType?n&&!t.has(r)&&""===r.data.trim()&&r.remove():1===r.nodeType&&Dt(r,t,It.has(r.localName)),r=e}}var Lt=new WeakMap;function qt(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Lt.set(t,e),Ft(e,[...n.childNodes]),e.He()}function zt(e,t,n){try{let r="template"===t.localName?Tt(t):null;null!==r&&!n&&w(204,[r.b]),Ft(e,[t])}catch(e){console.error(e)}e.He()}function Ft(t,n){Ct(t,n,null,!0,(e,n,r)=>{new ct(t,r,tt(t,n,null,e),e).Et()},e=>{at(t,e,null,null)},(n,r)=>{e.Mn?.(t,n,r);for(let e of r)ot(t,e,n,null,null)},(n,r)=>{e.Mn?.(t,n,r),ot(t,St(t,r,null,0),n,null,null)})}var Ut=Symbol.for("wcstack.binder"),_t=Symbol.for("wcstack.binder.pending"),Vt=Symbol.for("wcstack.binder.taken");var Bt=new Map;function Ht(e,t){if(1!==e.nodeType||!e.isConnected)return;let n=Lt.get(e.getRootNode());void 0===n||!1===n.element?.isConnected?Bt.set(e,t):zt(n,e,t?.range)}function Kt(){let e=[...Bt];Bt.clear();for(let[t,n]of e)Ht(t,n);!function(){let e=function(){let e=globalThis[Ut];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;let t=function(){let e=globalThis,t=e[_t];return void 0===t&&(t=[],e[_t]=t),t}();if(0===t.length)return;let n=t.splice(0,t.length),r=function(){let e=globalThis,t=e[Vt];return void 0===t&&(t=new WeakSet,e[Vt]=t),t}();for(let t of n)r.add(t),e.bind(t)}()}var Jt=class{constructor(){this.name="dirty",this.Z=(e,t)=>{if(0===e.n){let t=e.z;return t!==c&&t!==f&&(e.z=f,!0)}let n=null===t?null:t.ht;if(null===n)return!1;let r=n[e.P];return r!==c&&r!==f&&(n[e.P]=f,!0)}}Jo(e,t,n){null!==t.getter&&this.Z(t,n),e.kt(t,n),e.xn(t,n,this.Z)}Ho(e,t){let n=t.l.o.It;if(null!==n)for(let r of n)r.n===t.l.n?e.it(r,t,this.Z):e.Zt(t,r,t=>e.it(r,t,this.Z))}we(t,n,r){this.Z(n,r),e.Se?.(t,n,r),t.kt(n,r),t.xn(n,r,this.Z)}Ko(e,t,n){let r=0===t.n;if(!r&&null===n)return;let l=r?null:n.ht??=new Array(e.Ie).fill(c),i=null===l?t.z:l[t.P];if(i!==c&&i!==f&&i!==h&&(null===l||t.P in l))return i;i=h;try{return i=e.Uo(t,null===l?null:n)}finally{null===l?t.z=i:l[t.P]=i}}Yt(e){e.ht=null}wt(e){for(let t of e.I.all())null!==t.getter&&(0===t.n?t.z===f&&(t.z=h):e.tn(t.h[t.n],e=>{let n=e.ht;null!==n&&n[t.P]===f&&(n[t.P]=h)}))}},Yt=0,Gt=new WeakMap;function Xt(e,t=e.getRootNode()){Gt.set(t,[...Gt.get(t)??[],e].filter((e,t,n)=>e.isConnected&&n.lastIndexOf(e)===t))}function Qt(e){let t=Gt.get(e)??[],n=t.filter(t=>t.getRootNode()===e);return Promise.any(n.map(e=>e.initializePromise.then(()=>e.V||e.connectedCallbackPromise))).then(()=>{},r=>n.length?Gt.get(e)!==t?Qt(e):Promise.reject(r.errors[0]):void 0)}var Zt=typeof HTMLElement>"u"?class{}:HTMLElement,en=class extends Zt{constructor(){super(),this.engine=null,this.jn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((e,t)=>{this.an=e,this.$o=t}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(e=>{this.ln=e})}static{this.getBindingsReady=Qt}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.jn){if(null!==this.Ye)return void this.Ye.Xe();Xt(this);let t=this.engine;if(null!==t){let n=t.root;n===this.getRootNode()&&!Lt.has(n)&&Lt.set(n,t),Kt(),e.element?.(t,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&e.element?.(t,"connected")})}return}this.jn=!0;let t=this.getRootNode(),n=e.at?.(this,t);if(n)return this.Ye=n,!n.No&&this.parentNode instanceof ShadowRoot&&Xt(this),void(void 0===n.Ot?this.Ro():n.Ot()).then(e=>(this.loaded=!0,n.start(e,()=>this.To()))).then(()=>{this.ln(),this.an()},e=>this.$t(e,n.No));this.start(t),Xt(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.Dn();let t=this.engine;if(null===t)return;let n=t.root;Lt.get(n)===t&&Lt.delete(n),Xt(this,n),this.xo("$disconnectedCallback",51),e.element?.(t,"disconnected")}setInitialState(e){if(this.Ke&&w(14),this.loaded)this.Ye.reset(e);else if(null===this.engine)if(null!==this.cn){let t=this.cn;this.cn=null,t(e)}else this.U=e;else this.engine.reset(e)}createState(e,t){let n=this.engine;null===n&&w(15),"readonly"===e&&n.Me++;try{t(n.proxy)}finally{"readonly"===e&&n.Me--}}async createStateAsync(e,t){let n=this.engine;null===n&&w(15),await t("writable"===e?n.proxy:new Proxy(n.proxy,{get(e,t,n){let r=Reflect.get(e,t,n);return"$setAll"===t||"$resolve"===t?(...e)=>(e.length>2&&w(8),r(...e)):r},set(){w(8)}}))}async Ro(){await 0;let e=this.getAttribute("state");if(null!==e){let t=t=>[...t.querySelectorAll('script[type="application/json"]')].find(t=>t.id===e),n=t(this.getRootNode())??t(document);return void 0===n?Promise.reject(new Error(`[@wcstack/state] ${$(16,[e])}`)):Promise.resolve(JSON.parse(n.textContent||"{}"))}let t=this.getAttribute("src");if(null!==t)return async function(e){let t=new URL(e,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(t)){let n=await fetch(t);return n.ok||w(13,[e,n.status]),await n.json()}return(await(import(t))).default??{}}(t);let n=this.getAttribute("json");if(null!==n)return Promise.resolve(JSON.parse(n));let r=this.querySelector('script[type="module"]');return null!==r?async function(e){let t=!1,n=e=>{e.effectiveDirective.startsWith("script-src")&&(t=!0)};document.addEventListener("securitypolicyviolation",n);let r="function"==typeof URL.createObjectURL,l=r?URL.createObjectURL(new Blob([e.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${e.text}\n//${++Yt}`);try{return(await(import(l))).default??{}}catch(e){throw await new Promise(e=>setTimeout(e)),new Error(`[@wcstack/state] ${t?$(42):$(43,[e instanceof Error?e.message:String(e)])}`,{cause:e})}finally{document.removeEventListener("securitypolicyviolation",n),r&&URL.revokeObjectURL(l)}}(r):null!==this.U?Promise.resolve(this.U):new Promise(e=>{this.cn=e})}async start(t){try{let n=t.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||n?.hasAttribute("data-wc-definition"))&&a("scopes","<wcs-state>");let r=await this.Ro(),l=o(r);if(l&&await l,this.getRootNode()!==t)return this.U=r,this.jn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&a("ssr","enable-ssr");let i=Lt.get(t)?.element;i?.isConnected&&(i.V||i.Ye)&&w(47);let s=new re(r,new Jt);s.element=this,this.engine=s,e.element?.(s,"mounting"),qt(s,t),Kt(),s.$n(),this.To(),await s.ke("$connectedCallback"),this.isConnected&&e.element?.(s,"connected"),this.an()}catch(e){this.Ke=!this.V,this.$t(e)}}To(){this.V=!0,this.ln()}$t(e,t){this.He(this.V?50:49,e),this.ln(),t?this.an():this.$o(e)}He(e,t){let n=["mount","bind-component","state","src"].flatMap(e=>this.hasAttribute(e)?[e,this.getAttribute(e)]:[]);console.error(`[@wcstack/state] ${$(e,[this.localName,...n])}`,t)}xo(e,t,n){(async()=>this.engine.ke(e))().then(n,e=>this.He(t,e))}},tn=[];function nn(){return(tn=tn.filter(e=>e.deref())).map(e=>e.deref())}function rn(t,n){t&&function(e){let t=le,n=le.tagNames,r=Object.entries(e).filter(([,e])=>void 0!==e),l=Object.entries(e.tagNames??{}).filter(([,e])=>void 0!==e);for(let[e,n]of r){let r=t[e];(!Object.hasOwn(t,e)||null===n||typeof n!=typeof r||Array.isArray(n)!==Array.isArray(r))&&w(44,["bootstrapState",e])}for(let[e,t]of l)(!Object.hasOwn(n,e)||"string"!=typeof t)&&w(44,["bootstrapState",`tagNames.${e}`]);for(let[e,n]of r)"tagNames"!==e&&(t[e]=n);for(let[e,t]of l)n[e]=t}(t),function(t=customElements){(function(){let e=globalThis;void 0===e[Ut]&&(e[Ut]={protocol:"wcs-binder",version:1,bind:Ht})})(),nn().includes(t)||tn.push(new WeakRef(t));let n=le.tagNames.state;void 0===t.get(n)&&t.define(n,class extends en{}),e.Ao?.(t)}(n)}var ln,sn=e=>Qt(e),on=e=>t=>{let n=e(t);return e=>null==e?e:n(e)},an="en";function un(){if(le.locale!==ln){ln=le.locale;try{an=Intl.getCanonicalLocales(ln)[0]}catch{console.warn(`[@wcstack/state] ${$(48,[ln])}`),an="en"}}return an}var{eq:cn,ne:fn,not:hn,lt:dn,le:pn,gt:mn,ge:gn,falsy:yn,truthy:bn,boolean:vn}=Se,$n={toFixed:{factory:e=>{let t=we(e?.[0]??"0","toFixed");return e=>("number"!=typeof e&&be("toFixed"),e.toFixed(t))},arity:[0,1]},locale:{factory:e=>{let t=e?.[0];return e=>("number"!=typeof e&&be("locale"),e.toLocaleString(t??un()))},arity:[0,1]},upper:{factory:on(()=>e=>String(e).toUpperCase()),arity:[0,0]},lower:{factory:on(()=>e=>String(e).toLowerCase()),arity:[0,0]},capitalize:{factory:on(()=>e=>{let t=String(e);return 0===t.length?t:1===t.length?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}),arity:[0,0]},trim:{factory:on(()=>e=>String(e).trim()),arity:[0,0]},slice:{factory:on(e=>{let t=[Ae(e,0,"slice")],n=e?.[1];return typeof n<"u"&&t.push(we(n,"slice")),e=>String(e).slice(...t)}),arity:[1,2]},padStart:{factory:on(e=>{let t=Ae(e,0,"padStart"),n=e?.[1]??"0";return e=>String(e).padStart(t,n)}),arity:[1,2]},padEnd:{factory:on(e=>{let t=Ae(e,0,"padEnd"),n=e?.[1]??" ";return e=>String(e).padEnd(t,n)}),arity:[1,2]},repeat:{factory:on(e=>{let t=Ae(e,0,"repeat");return e=>String(e).repeat(t)}),arity:[1,1]},reverse:{factory:on(()=>e=>String(e).split("").reverse().join("")),arity:[0,0]},truncate:{factory:on(e=>{let t=Ae(e,0,"truncate"),n=e?.[1]??"…";return e=>{let r=String(e);return r.length<=t?r:r.slice(0,t)+n}}),arity:[1,2]},join:{factory:e=>{let t=e?.[0]??", ";return e=>(Array.isArray(e)||w(30,["join"]),e.join(t))},arity:[0,1]},round:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","round"));return e=>("number"!=typeof e&&be("round"),Math.round(e*t)/t)},arity:[0,1]},floor:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","floor"));return e=>("number"!=typeof e&&be("floor"),Math.floor(e*t)/t)},arity:[0,1]},ceil:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","ceil"));return e=>("number"!=typeof e&&be("ceil"),Math.ceil(e*t)/t)},arity:[0,1]},percent:{factory:e=>{let t=we(e?.[0]??"0","percent");return e=>("number"!=typeof e&&be("percent"),`${(100*e).toFixed(t)}%`)},arity:[0,1]},unit:{factory:on(e=>{let t=e?.[0]??ge("unit");return e=>String(e)+t}),arity:[1,1]},date:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("date"),e.toLocaleDateString(t??un()))},arity:[0,1]},time:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("time"),e.toLocaleTimeString(t??un()))},arity:[0,1]},datetime:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("datetime"),e.toLocaleString(t??un()))},arity:[0,1]},ymd:{factory:e=>{let t=e?.[0]??"-";return e=>{e instanceof Date||ve("ymd");let n=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),l=e.getDate().toString().padStart(2,"0");return`${n}${t}${r}${t}${l}`}},arity:[0,1]},hms:{factory:e=>{let t=e?.[0]??":";return e=>{e instanceof Date||ve("hms");let n=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),l=e.getSeconds().toString().padStart(2,"0");return`${n}${t}${r}${t}${l}`}},arity:[0,1]},eq:cn,ne:fn,not:hn,lt:dn,le:pn,gt:mn,ge:gn,add:xe("add",(e,t)=>e+t),sub:xe("sub",(e,t)=>e-t),mul:xe("mul",(e,t)=>e*t),div:xe("div",(e,t)=>e/t),mod:xe("mod",(e,t)=>e%t),abs:{factory:()=>e=>("number"!=typeof e&&be("abs"),Math.abs(e)),arity:[0,0]},clamp:{factory:e=>{let t=Ae(e,0,"clamp"),n=Ae(e,1,"clamp");return e=>("number"!=typeof e&&be("clamp"),Math.min(Math.max(e,t),n))},arity:[2,2]},int:{factory:()=>e=>parseInt(String(e),10),arity:[0,0]},float:{factory:()=>e=>parseFloat(String(e)),arity:[0,0]},falsy:yn,truthy:bn,defaults:{factory:(e,t)=>{let n=ke(e?.[0]??ge("defaults"),t);return e=>e||n},arity:[1,1]},coalesce:{factory:(e,t)=>{let n=ke(e?.[0]??ge("coalesce"),t);return e=>e??n},arity:[1,1]},boolean:vn,number:{factory:()=>e=>Number(e),arity:[0,0]},string:{factory:()=>e=>String(e),arity:[0,0]},nullIfEmpty:{factory:()=>e=>""===e?null:e,arity:[0,0]}},wn=Object.fromEntries(Object.entries($n).filter(([e])=>!(e in Se))),An=!1,kn={name:"formats",install:function(){An||(An=!0,pe($n))}};function xn(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=new Array(t.length+1),l=new Array(t.length+1);for(let e=0;e<=t.length;e++)r[e]=e;for(let n=1;n<=e.length;n++){l[0]=n;for(let i=1;i<=t.length;i++){let s=e[n-1]===t[i-1]?0:1;l[i]=Math.min(r[i]+1,l[i-1]+1,r[i-1]+s)}for(let e=0;e<=t.length;e++)r[e]=l[e]}return r[t.length]}function Sn(e,t){if(0===e.length)return"";let n=e.toLowerCase(),r=null,l=3;for(let e of t){let t=xn(n,e.toLowerCase(),2);t<l&&(r=e,l=t)}return null!==r?` Did you mean "${r}"?`:""}var Tn=" Validate statically: npx @wcstack/lint <file>.",Nn=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],jn=e=>{let t=Nn[e/100|0];return t?`[wcs/${t}] `:""},On=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],Cn=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,Mn="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",Pn={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>"updates did not settle after 32 passes",41:()=>"render chain depth limit exceeded (100 drains that rendering itself started); bindings for this batch were not applied.",12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${Mn}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${Mn}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&On.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${Cn(e,t)} failed to initialize.`,50:(e,...t)=>`${Cn(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${Cn(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": 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.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${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).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,r)=>`${e}("${t}") takes ${n} index(es), got ${r}.`,902:(e,t,n,r)=>`${e}("${t}") takes at most ${n} index(es), got ${r}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).${!e.includes("-")&&t.startsWith("command.")?" A native element's command needs the add-on @wcstack/state/features/native-commands.":""}`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1205:(e,t,n)=>`<${e}> has no command "${t}" (a native <${e}>'s commands: ${n}).`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function En(e,t){let n=Pn[e];return void 0===n?`${jn(e)}#${e} ${t.join(" ")}`:jn(e)+n(...t)}var Wn=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),Rn=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],In={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function Dn(e,t,n){let r=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(In,e)?In[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?Sn(t,n):"");for(let[t,n]of Rn){let l=t.exec(e);null!==l&&(r+=n.replace(/\$(\d)/g,(e,t)=>l[Number(t)]))}let l=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==l&&(r+=` — write "${l[1]}#${l[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?r+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':fe.some(me)||(r+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let i=/\[wcs\/([\w-]+)\]/.exec(e);return null!==i&&Wn.has(i[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(r+=Tn),r}var Ln=new WeakMap,qn=new WeakMap,zn=new WeakSet,Fn=new WeakSet;function Un(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function _n(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function Vn(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let r=e.target,l=t=>null===t?null:function(e,t){let n=t.t.split("."),r=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return r<0||n.indexOf("*",r)>=0||void 0!==Un(e.target,t.t)?.get?t:e.I.Mt(m(t.t).o)}(e,t);for(let t of n){if(null!=l(t)?.getter||null===r||"object"!=typeof r)return null;if("*"===t.s){if(!Array.isArray(r)||0===r.length)return null;r=r[0];continue}if(Array.isArray(r)&&/^\d+$/.test(t.s)){if(Number(t.s)>=r.length)return null;r=r[Number(t.s)];continue}let n=Un(r,t.s);if(void 0===n&&null===t.d&&e.wt.has(t.s))return null;if(void 0===n){let n=_n(r),i=l(t.d);for(let t of e.I.all())t.d===i&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;r=n.value}return null}function Bn(t){zn.has(t)||(zn.add(t),setTimeout(()=>function(t){zn.delete(t);let n=Ln.get(t);if(void 0===n)return;let r=qn.get(t);void 0===r&&qn.set(t,r=new Set);for(let[l,i]of n){if(r.has(l))continue;r.add(l);let n=Vn(t,l);if(null===n)continue;let s=[...t.root?.querySelectorAll(`${le.tagNames.state}[mount]`)??[]].find(e=>!Fn.has(e)&&(l.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==s){r.delete(l),s.initializePromise.then(()=>{Fn.add(s),Bn(t)});continue}let[o,a]=i?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];e.st?.(t,{type:"state:path-unresolved",source:i?"watch":"binding",path:l.t,missingSegment:n.seg});let u=t.I.Mt(m(l.t).o),c="";if(void 0!==u&&u!==l&&null!==u.getter){let e=u.h.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.h[t].t.length+2)}`);c=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${o}] ${a} "${l.t}" does not resolve on the state tree: "${n.seg}" is not declared.${Sn(n.seg,n.names)}${c} Updates to this path will be silently dropped.${Tn}`)}}(t),0))}function Hn(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let r=Ln.get(e);void 0===r&&Ln.set(e,r=new Map),r.has(t)||r.set(t,n),Bn(e)}var Kn=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Jn=!1;function Yn(e,t,n){let r="html"===n.name?"innerHTML":n.name;if(Jn||!(t instanceof TypeError)||!Pe(r)||!("trustedTypes"in globalThis))return;Jn=!0;let l="function"==typeof Ce()?.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 "${r}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${l}\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:n.a,property:r})}var Gn=new WeakMap;function Xn(e,t,n){let r=e[t],l=void 0===n?void 0===r?null:`the event carried no detail (undefined) while element.${t} is ${typeof r}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==r&&"object"==typeof r?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof r}`;if(null===l)return;let i=Gn.get(e);void 0===i&&Gn.set(e,i=new Set),!i.has(t)&&(i.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${l}. 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.`))}var Qn=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],Zn={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},er={name:"diagnostics",install(){e.Do=Dn,e.Lo=En,e.ko=Hn,e.detail=Xn,e.Ke=t(e.Ke,Yn);let r=e.fe;e.fe=(e,t)=>{(function(e){void 0!==e.$scan&&w(1);for(let[t,n]of Qn)void 0!==e[t]&&w(1601,[t,n])})(t),r?.(e,t),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[r,l]=n[0];if(!r.endsWith(".*")||!l.endsWith(".*"))return;let i=r.slice(0,-2),s=l.slice(0,-2),o=`.${l}`,a=`${i}.**`,u=_n(e),c=u.filter(e=>e.startsWith(a)).map(e=>e.slice(a.length)),f=e=>v(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${s}`||e.startsWith(`.${s}.`))&&f(`"${a}${e}" names the recursion structure itself (the "${s}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${Kn(o)})+$`).test(t.slice(0,t.length-e.length))&&f(`"${a}${e}" and "${a}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${l}"). Rename one of them.`);let t=new RegExp(`^${Kn(r)}(?:${Kn(o)})*${Kn(e)}$`);for(let n of u)!n.includes("**")&&t.test(n)&&f(`"${n}" is already defined on the state, so the recursive getter "${a}${e}" cannot expand to it.`)}}(t),function(e){qn.delete(e),Ln.has(e)&&Bn(e)}(e)},e.ot=n(l,e.ot,(e,t)=>Object.hasOwn(Zn,t)?w(1701,[t,Zn[t]]):void 0)}},tr={},nr=/\.\d/,rr=new Set(Object.getOwnPropertyNames(Object.prototype)),lr=0,ir=!1,sr=null,or=()=>{ir=!1,lr++};function ar(){if(null===sr)if("function"==typeof MessageChannel){let e=new MessageChannel;e.port1.onmessage=or,e.port1.unref?.(),sr=()=>e.port2.postMessage(0)}else sr=()=>setTimeout(or,0);return ir||(ir=!0,sr()),lr}function ur(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.pop();if(!n.has(e)){n.add(e);for(let n of e.Q){for(let r of t)if(n.ee(r)&&(n.n===r.n||!(r.n<e.n&&e.h[r.n+1].ee(r))))return!0;null!==n.getter&&r.push(n)}}}return!1}var cr=class{constructor(e,t){this.active=!1,this.Ge=new Map,this.n=0,this.Po=-1,this.Ln=new Set,this.We=null,this.engine=e,this.ct=t}ur(){let e=this.engine;this.Ge.clear();for(let t of this.ct)t.getter=null!==t.p.getter||t.p.se,t.s=new WeakMap,this.prime(t,()=>{0===t.p.n?t.getter&&t.s.set(tr,e.v(t.p,null)):this.Bn(t.p,1,null,n=>{t.getter&&this.prime(t,()=>t.s.set(n,e.v(t.p,n)))})});this.active=!0}prime(t,n){try{n()}catch(n){console.error(`[@wcstack/state] $watch initial evaluation of "${t.t}" threw.`,n),e.st?.(this.engine,{type:"state:watch-error",phase:"prime",path:t.t,error:n})}}Fo(){this.active=!1,this.Ge.clear()}Bn(e,t,n,r){let l=this.engine._e(n,e.h[t]);for(let n of l.f)t===e.n?r(n):this.Bn(e,t+1,n,r)}un(e,t,n,r){let l=this.Ge.get(e);void 0===l&&this.Ge.set(e,l=new Map);let i=l.get(t);void 0===i?l.set(t,[n,this.n,r]):(i[1]<this.n&&(i[1]=this.n),i[2]||=r)}ve(e,t,n,r,l){if(this.active){(this.We??=new Set).add(e);for(let i of this.ct){let s=i.p;s.n!==e.n||!s.ee(e)||this.un(i,t,i.getter?i.s.get(t??tr):s===e&&l&&this.engine._t&&(null===r||"object"!=typeof r&&"function"!=typeof r)?n:void 0,!0)}}}Se(e,t){if(this.active)for(let n of this.ct)(n.getter||=null!==n.p.getter||n.p.se)&&n.p.n===e.n&&n.p.ee(e)&&this.un(n,t,n.s.get(t??tr),!1)}Jt(e,t){if(!this.active)return;let n=null;for(let r of this.ct){let l=r.p;if(!(l.n<e.n||l.h[e.n]!==e.o)){n??=new Set(t);for(let t of e.f)n.has(t)||(l.n===e.n?this.un(r,t,void 0,!0):this.Bn(l,e.n+1,t,e=>this.un(r,e,void 0,!0)))}}}Fe(){let t=this.We;if(this.We=null,!this.active||0===this.Ge.size)return;let n=this.Ge;this.Ge=new Map;let r=this.engine,l=[];for(let i of this.ct){let s=n.get(i);if(void 0===s)continue;let o,a=[...s].filter(([e])=>null===e||e.y);a.length>1&&a.sort((e,t)=>hr(e[0],t[0]));for(let[n,[s,u,c]]of a){let a,f="evaluate",h=r.u;this.n=u+1,r.Te++;try{if(a=r.v(i.p,n),i.getter&&(i.s.set(n??tr,a),Object.is(a,s)&&(nr.test(i.t)||null!==n&&!c&&!(o??=null!==t&&ur(fr(i.p),t)))))continue;if(u>32){l.includes(i.t)||l.push(i.t);continue}r.u=n,e.st?.(r,{type:"state:watch-fired",path:i.t}),f="handler",i.handler.call(r.proxy,a,s,...r.H(n))}catch(t){console.error(`[@wcstack/state] $watch "${i.t}" failed; the other watches still run.`,t),e.st?.(r,{type:"state:watch-error",phase:f,path:i.t,error:t})}finally{r.u=h,this.n=0,r.Te--}}}l.length>0&&this.Oo(l)}Oo(t){let n=ar();n!==this.Po&&(this.Po=n,this.Ln.clear());let r=t.filter(e=>!this.Ln.has(e));if(0!==r.length){for(let e of r)this.Ln.add(e);console.error("[@wcstack/state] $watch handlers / $stream restarts kept writing for 32 batches; the chain is cut (nothing is rolled back)."),e.st?.(this.engine,{type:"state:watch-chain-limit",maxDepth:32,paths:r})}}};function fr(e){for(;null===e.getter&&null!==e.d;)e=e.d;return e}function hr(e,t){let n=[],r=[];for(let t=e;null!==t;t=t.l.ae)n.unshift(t.w);for(let e=t;null!==e;e=e.l.ae)r.unshift(e.w);for(let e=0;e<n.length&&e<r.length;e++)if(n[e]!==r[e])return n[e]-r[e];return n.length-r.length}var dr="$streamStatus",pr="$streamError",mr=new Set(Object.getOwnPropertyNames(Object.prototype)),gr=!1;function yr(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return void 0!==e.get||void 0!==e.set||"function"==typeof e.value}return!1}var br=class{constructor(e,t,n){this.engine=e,this.entries=t,this.L=n}set(e,t,n){gr=!0;try{this.engine.A(this.engine.o(`${e}.${t}`),null,n)}finally{gr=!1}}dr(){for(let e of this.entries)this.start(e,!0)}fr(){for(let e of this.entries)e.ut=!1,e.J?.abort(),e.J=null}pr(){for(let e of this.entries)e.ut=!1,null!==e.J&&(e.J.abort(),e.J=null),this.set(dr,e.name,"idle")}Se(e){let t=this.L.n;for(let n of this.entries)n.g===e&&(n.n=n.ut?Math.max(n.n,t):t,n.ut=!0)}Fe(){let e=this.engine,t=this.L,n=[];for(let r of this.entries){if(!r.ut)continue;let l=r.n;if(r.ut=!1,l>32)n.push(r.name),r.g.z=h;else{t.n=l+1,e.Te++;try{this.start(r,!1)}finally{e.Te--,t.n=0}}}n.length>0&&t.Oo(n)}start(e,t){let n,r=this.engine;if(null!==e.J&&e.J.abort(),e.J=null,null!==e.g){let l=e.g;l.getter=e.args;let i=l.Q.slice();vr(l);try{n=r.read(l,null),function(e,t,n){null!==n&&"function"==typeof n?.then&&v(`$stream "${e}": args must be synchronous (it returned a Promise).`);for(let n of t.Q)n.n>0&&v(`$stream "${e}": args must not read a wildcard path ("${n.t}").`),(n.t===e||n.t===`${dr}.${e}`||n.t===`${pr}.${e}`)&&v(`$stream "${e}": args must not read the stream itself ("${n.t}").`)}(e.name,l,n)}catch(n){vr(l);for(let e of i)e.Wn(l);if(l.z=h,t)throw n;return this.set(pr,e.name,n),void this.set(dr,e.name,"error")}}let l=new AbortController;e.J=l,r.A(r.o(e.name),null,e.U),this.set(pr,e.name,null),this.set(dr,e.name,"active"),this.mr(e,l,n)}async mr(e,t,n){let r=this.engine,l=t.signal,i=()=>!l.aborted&&e.J===t,s=r.o(e.name),o=this.L.n,a=ar(),u=e=>{ar()===a&&(this.L.n=o);try{e()}finally{this.L.n=0}},c=e.U;try{let t=await e.source(n,l);if(!i())return;let o=t=>{c=void 0!==e.Co?e.Co(c,t):t,u(()=>r.A(s,null,c))};if(null!==t&&"function"==typeof t?.getReader){let e=t.getReader();for(l.addEventListener("abort",()=>{e.cancel().catch(()=>{})});;){let t=await e.read();if(!i())return;if(t.done)break;o(t.value)}}else{if(null===t||"function"!=typeof t?.[Symbol.asyncIterator])throw new TypeError(`$stream "${e.name}": source must return an async iterable or a ReadableStream`);{let e=t[Symbol.asyncIterator]();for(l.addEventListener("abort",()=>{e.return?.()});;){let t=await e.next();if(!i())return;if(t.done)break;o(t.value)}}}if(!i())return;e.J=null,u(()=>this.set(dr,e.name,"done"))}catch(n){if(!i())return;e.J=null,t.abort(),u(()=>{this.set(pr,e.name,n),this.set(dr,e.name,"error")})}}};function vr(e){for(let t of e.Q){let n=t.B.indexOf(e);n>=0&&t.B.splice(n,1),t.pt.delete(e)}e.Q.length=0,e.z=c}var $r=new WeakMap;function wr(e){let t=$r.get(e);return t?.target===e.target?t:void 0}function Ar(t,n){let r=new cr(t,function(t,n){if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$watch must be an object mapping paths to handler functions.");let r=[];for(let l of Object.keys(n)){let i=n[l];(""===l||"$"===l[0]||l.includes("@")||rr.has(l))&&v(`$watch path "${l}" is not a path of the state tree.`),"function"!=typeof i&&v(`$watch entry "${l}" must be a function.`);let s=t.o(l);e.ko?.(t,s,!0),r.push({t:l,p:s,handler:i,getter:!1,s:new WeakMap})}return r}(t,n.$watch)),l=new br(t,function(e,t){let n=t.$stream;if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$stream must be an object mapping stream names to definitions.");let r=[],l={},i={};for(let s of Object.keys(n)){let o=n[s];(""===s||"$"===s[0]||/[.*]/.test(s)||mr.has(s))&&v(`$stream entry "${s}" must be a flat property name.`),(null===o||"object"!=typeof o)&&v(`$stream entry "${s}" must be an object.`);let a=o.source,u=o.fold,c=o.args,f=o.initial;"function"!=typeof a&&v(`$stream entry "${s}" needs a source function.`),void 0!==u&&"function"!=typeof u&&v(`$stream entry "${s}": fold must be a function.`),void 0!==u&&!("initial"in o)&&v(`$stream entry "${s}": fold needs an initial value.`),void 0!==c&&"function"!=typeof c&&v(`$stream entry "${s}": args must be a function.`),yr(t,s)&&v(`$stream entry "${s}" collides with a getter, setter or method of the state.`),void 0===t[s]&&(t[s]=f),l[s]="idle",i[s]=null,r.push({name:s,source:a,Co:u,U:f,J:null,ut:!1,n:0,g:void 0===c?null:e.o(`$streamArgs.${s}`),args:void 0===c?null:function(){return c(this)}})}return t[dr]=l,t[pr]=i,r}(t,n),r),i=$r.get(t);void 0!==i&&(i.L.Fo(),i.Ft.fr()),$r.set(t,{L:r,Ft:l,Xe:i?.Xe??!1,target:n})}function kr(e,t){let n=$r.get(e);if(void 0!==n&&"mounting"!==t&&!document.documentElement?.hasAttribute("data-wcs-server")&&("reset"!==t&&(n.Xe="connected"===t),n.target===e.target)){if("disconnected"===t)return n.L.Fo(),void n.Ft.pr();n.Xe&&(n.L.ur(),n.Ft.dr())}}var xr=["$streamStatus","$streamError"],Sr={name:"temporal",install(){e.fe=t(e.fe,Ar),e.element=t(e.element,kr),e.ve=t(e.ve,(e,t,n,r,l,i)=>wr(e)?.L.ve(t,n,r,l,i)),e.Se=t(e.Se,(e,t,n)=>{let r=wr(e);void 0!==r&&(r.L.Se(t,n),r.Ft.Se(t))}),e.Jt=t(e.Jt,(e,t,n)=>wr(e)?.L.Jt(t,n)),e.Fe=t(e.Fe,e=>{let t=wr(e);void 0!==t&&(t.L.Fe(),t.Ft.Fe())}),e.ot=n(l,e.ot,(e,t)=>{let n=t.split(".",1)[0];if(xr.includes(n))return n===t?e.target[t]:e.read(e.o(t),null)}),e.Pe=n(r,e.Pe,(e,t)=>(!gr&&36===t.t.charCodeAt(0)&&xr.includes(t.t.split(".",1)[0])&&v(`"${t.t}" is read-only (the stream runtime owns it).`),!1))}},Tr=new WeakMap,Nr=!1,jr=/^(?!prototype$)[^\d.*$][^.*]*$/;function Or(e,t){let n=t.$listKeys,r=new Map;if(void 0!==n){(null===n||"object"!=typeof n)&&v("$listKeys must be an object mapping list paths to a key field or function.");for(let t of Object.keys(n)){let l=n[t];"string"==typeof l?r.set(e.o(t),e=>e[l]):"function"==typeof l?r.set(e.o(t),l):v(`$listKeys "${t}" must be a field name or a function.`)}}Tr.set(t,r)}function Cr(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Mr(e,t,n){let r=new Map;for(let l of t){Cr(l)||v(`$listKeys "${e}": rows must be plain objects.`);let t=n(l);null==t&&v(`$listKeys "${e}": a row has no key.`),r.has(t)&&v(`$listKeys "${e}": duplicate key ${JSON.stringify(t)}.`),r.set(t,l)}return r}function Pr(e,t,n,r){if(Nr||!Array.isArray(r))return!1;let l=Tr.get(e.target)?.get(t);if(void 0===l)return!1;let i=e.rt(t,n);if(!Array.isArray(i)||i===r)return!1;let s=Mr(t.t,i,l);Mr(t.t,r,l);let o=[],a=[],u=i.length===r.length;for(let e=0;e<r.length;e++){let t=r[e],n=s.get(l(t));o.push(n??t),void 0!==n&&a.push([e,n,t]),o[e]!==i[e]&&(u=!1)}let c=[];for(let[e,t,n]of a){for(let r of Object.keys(n))Object.is(t[r],n[r])||c.push([e,r,n[r]]);for(let r of Object.keys(t))!(r in n)&&null!==t[r]&&c.push([e,r,null])}if(u&&0===c.length)return!0;if(!u){Nr=!0;try{e.A(t,n,o)}finally{Nr=!1}}if(c.length>0){let r=e._e(0===t.n?null:n,t);for(let[n,l,i]of c){if("__proto__"===l)continue;let s=r.f[n],o=jr.test(l)?e.o(`${t.t}.*.${l}`):null;null===o?.getter?e.A(o,s,i):(s.R[l]=i,e.A(e.o(`${t.t}.*`),s,s.R,!0))}}return!0}var Er={name:"list-keys",install(){e.fe=t(e.fe,Or),e.Pe=n(r,e.Pe,Pr)}},Wr=new WeakMap,Rr=new WeakMap,Ir="will not graft: the root state failed to initialize.",Dr=new WeakSet,Lr=new WeakMap,qr=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],zr=["$commandTokens","$eventTokens","$on","$errorCallback"],Fr=e=>`[@wcstack/state] <${le.tagNames.state} mount="${e}">`,Ur=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),_r=e=>e?.element?.isConnected?e:void 0;function Vr(e){let t=Rr.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function Br(e,t){let n=Rr.get(t);if(Rr.delete(t),Array.isArray(n))for(let t of n)Yr(t,e)}function Hr(e){let t=Wr.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function Kr(e,t){console.error(`${Fr(e.t)} ${t}`),Hr(e),e.Je?.(),e.Je=null}function Jr(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function Yr(e,t){if(Dr.has(t))return Kr(e,"will not graft: its component is wired to its host.");let n=e.state,r=t.target,l=e.t.split("."),i=r;for(let e of l)i=i?.[e];if(void 0!==i&&!0!==t.hydrated)return Kr(e,`will not graft: the root state already has "${e.t}".`);let s=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,r){if("symbol"==typeof r)return;if(36!==r.charCodeAt(0))return e.proxy[n(r)];let l=e.proxy[r];return"$eqPath"===r?(e,t)=>l(n(e),n(t)):Ur.has(r)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,r,l)=>"symbol"!=typeof r&&(e.proxy[n(r)]=l,!0)})}(t,e.t);e.chroot=s;let o={},a={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:r,set:l,value:i}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==r||void 0!==l)a[`${e.t}.${n}`]={get:r&&function(){return r.call(s)},set:l&&function(e){l.call(s,e)}};else{if("$"===n[0])continue;if("function"==typeof i){let t=i.bind(s);a[`${e.t}.${n}`]={get:()=>t}}else o[n]=i}}if(void 0===i){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.A(n,null,{})}t.A(t.o(e.t),null,o)}t.to(Object.defineProperties({},a));for(let e in a)t.We(t.o(e),null);e.engine=t;let c=Lr.get(t);void 0===c&&Lr.set(t,c=[]),c.push(e),e.el.isConnected&&Jr(e,"$connectedCallback"),e.Je?.(),e.Je=null}function Gr(e,t){let n=Rr.get(e);if(Array.isArray(n))for(let e of n)Kr(e,Ir);Rr.set(e,t)}var Xr=new WeakMap;function Qr(e,t){let n=e.getAttribute("mount");if(null===n)return null;let r={el:e,root:t,t:n,state:null,engine:null,chroot:null,Je:null},l=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(le.bindAttributeName))l='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=Wr.get(t);void 0===e&&Wr.set(t,e=new Map);let i=e.get(n);if(void 0!==i&&i!==r&&(null===i.engine?i.el.isConnected:_r(i.engine)))l=`will not graft: another volume already holds "${n}".`;else{if(null===i?.engine){let e=Rr.get(t);Array.isArray(e)&&Rr.set(t,e.filter(e=>e!==i)),i.Je?.(),i.Je=null}e.set(n,r)}}else l='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{No:!0,start(e){if(null!==l)return Kr(r,l);if(Wr.get(t).get(n)===r){for(let t of qr)if(void 0!==e[t])return Kr(r,`${t} is not run in a volume — declare it on the root state.`);for(let t of zr)void 0!==e[t]&&console.warn(`${Fr(n)} ${t} is not run in a volume (it belongs to the root).`);return r.state=e,new Promise(e=>{r.Je=e;let n=_r(Lt.get(t)),l=Rr.get(t);void 0!==n?Yr(r,n):Vr(t)?Kr(r,Ir):Rr.set(t,[...Array.isArray(l)?l:[],r])})}},Xe(){null!==r.engine&&Jr(r,"$connectedCallback")},Dn(){null!==r.engine&&Jr(r,"$disconnectedCallback")},reset(){v(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var Zr=new WeakMap,el=new WeakMap;function tl(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||v(`${t} must be an array of state member names.`);let r=new Set;for(let e of n)("string"!=typeof e||""===e)&&v(`${t} entries must be non-empty strings.`),"$"===e[0]&&v(`${t} entry "${e}": internal ($) members are never exposed.`),r.has(e)&&v(`${t} entry "${e}" is duplicated.`),r.add(e);return n}function nl(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let r=document.createDocumentFragment();for(let e of[...t.childNodes])r.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&v("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,r){e.includes("-")||v(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&v(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(r),i=tl(r,"$bindables"),s=tl(r,"$commands");for(let e of i){let t=l.get(e);void 0===t&&v(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&v(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of s){let t=l.get(e);void 0===t&&v(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&v(`$commands entry "${e}" is not a method: list it in $bindables.`)}let o={tag:e,bindables:i},a=new WeakMap,u=new WeakMap,c=r=>{if(a.has(r))return a.get(r);if(r.hasAttribute("data-wc-definition"))return null;let l=r.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let s=l.querySelector(le.tagNames.state);return a.set(r,s),Zr.set(r,o),null===s&&i.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${le.tagNames.state}>: no change events.`),s},f=e=>c(e)?.engine??null,h=e=>Promise.resolve(c(e)?.initializePromise).then(()=>{let t=u.get(e);u.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,r]of t)n.proxy[e]=r});class d extends HTMLElement{static{this.wcBindable=0===i.length&&0===s.length?null:{protocol:"wc-bindable",version:1,properties:i.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:i.map(e=>({name:e})),...0===s.length?{}:{commands:s.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==c(this)&&h(this)}get stateElement(){return c(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(d.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(d.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=u.get(this);void 0===n&&u.set(this,n=[]),n.push([e,t])}}});customElements.define(e,d)}(n.localName,r,l,t)},Xe(){},Dn(){},reset(){v("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var rl=new WeakMap,ll=new WeakSet,il=new WeakMap,sl=new WeakMap,ol="data-wcs-wired",al=new WeakMap,ul=new WeakMap,cl=new WeakMap,fl=0,hl=new Set,dl={},pl=["$watch","$stream","$renderedCallback"],ml=e=>e.split(".",1)[0];function gl(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function yl(e,t){let n=e.a,r=ml(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(ol);else if(!vl(n,r)){let e=n.getAttribute(ol)?.split(" ")??[];e.includes(r)||n.setAttribute(ol,[...e,r].join(" "))}al.get(n)?.me===r&&v(`<${n.localName}>.${r} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=rl.get(n);void 0===l&&rl.set(n,l=[]),l.push(e),t&&ll.add(e);let i=il.get(n);return void 0===i&&il.set(n,i=new Map),i.has(r)||i.set(r,n[r]),sl.get(n)?.(),!1}function bl(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${le.tagNames.state}[bind-component]`)}function vl(e,t){let n=e.getAttribute(le.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function $l(e){let t=e.parentElement;for(;null!==t&&!bl(t);)t=t.parentElement;let n=Lt.get(t??e.getRootNode()),r=n?.element;(r?.isConnected?r.V:null===t)&&(null===t?Ht(e):zt(n,e))}var wl=new Set;function Al(e,t){wl.has(e)||(wl.add(e),console.warn(`[@wcstack/state] ${t}`))}var kl=(e,t)=>t in e.state;function xl(e,t){let n=Sl(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function Sl(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function Tl(e,t,n){if(null!==n.getter)return;let r,l=e.host,i=l.engine,s=ml(n.t),o=l.entries.find(e=>e.E===n.t);if(void 0===o&&null!==n.d)return function(e,t){let n,r=t.d;for(;null!==r&&void 0===(n=e.dt.get(r));)r=r.d;if(null===r||void 0===n)return;let l=e.N,i=e.host.engine,s=i.o(n.p.t+t.t.slice(r.t.length));if(null===s.getter)return;let o=n,a=()=>{let n=Nl(e,o.r);return 0===t.n?n:(i.resolve(gl(s.t,[...i.H(n),...l.H(te(l.u,t.n))]),null),i.rr)};t.getter=()=>{let e=a();return s.n>0&&null===e?void 0:i.v(s,e)},null!==s.ie&&(t.ie=n=>{let r=a();jl(e,o.e,()=>i.A(s,r,n)),e.dn=t}),t.n>0&&(t.P=l.Ie++),e.dt.set(t,{e:o.e,p:s,r:o.r})}(e,n);if(0!==n.n)return;if(void 0!==o){if(o.E!==s?kl(l,s):xl(l,s))return;r=o.he}else{if(null===t||null!==n.d||"$"===s[0]||kl(l,s))return;o=t,r=i.o(`${t.he.t}.${s}`)}let a=o.r,u=o;n.getter=()=>i.v(r,Nl(e,a)),n.ie=t=>{jl(e,u,()=>i.A(r,a,t)),e.dn=n},e.dt.set(n,{e:o,p:r,r:a})}function Nl(e,t){return null!==t&&!t.y&&v(`The host row of <${e.host.el.localName}> was removed.`),t}function jl(e,t,n){let r=hl.has(e.N);hl.add(e.N),e.from=t;try{n()}finally{r||hl.delete(e.N),e.from=null}}var Ol=(e,t)=>t||!hl.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function Cl(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,fl+=t?1:-1;let n=e.host.engine,r=cl.get(n);void 0===r&&cl.set(n,r=new Map);for(let n of e.pe){let e=r.get(n.e.he);void 0===e&&r.set(n.e.he,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.E);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,r=n.engine;e.re=new Map;let l=new Set;for(let i=n.state;null!==i&&i!==Object.prototype;i=Object.getPrototypeOf(i))for(let s of Object.getOwnPropertyNames(i)){if(l.has(s))continue;l.add(s);let o=Object.getOwnPropertyDescriptor(i,s);if(void 0===o.get&&void 0===o.set||"$"===s[0]||s.includes("*"))continue;let a=ml(s);if(s!==a&&!kl(n,a))continue;let u=r.o(`${t.he.t}.${s}`);if(null===u.getter)El(r,u,t.he);else if(!Ml.has(u.getter))continue;e.re.set(u,e.N.o(s))}}(e,l);for(let r of e.re.keys())t&&null===r.getter&&El(n,r,l.he),n.T.we(n,r,l.r);e.re.size>0&&n.Ae(),t&&function(e,t){let n=e.host.engine;for(let[r,l]of e.re){let i=n.v(r.d,t.r);if(null===i||"object"!=typeof i||!(r.s in i))continue;let s=e.host.el.localName;Al(`${s}|${r.t}`,`[wcs/mount-export-shadowed] <${s}>.${e.host.me}.${l.t} is exported at "${r.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var Ml=new WeakSet;function Pl(e,t,n,r){let l=cl.get(e)?.get(t)?.get(n);if(void 0===l)return null;let i=null;for(let e of l)""!==e.e.E||!0!==e.m.re?.has(r)||e.m===i||(null!==i&&v(`[wcs/mount-export-ambiguous] "${r.t}" is exported by two mounted components on the same instance: <${i.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),i=e.m);return i}function El(e,t,n){let r=t.d,l=t.s,i=()=>{let t=e.read(r,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let r=i();if(null!==r)return r[l];let s=Pl(e,n,e.u,t);return null===s?void 0:s.N.read(s.re.get(t),null)},Ml.add(t.getter),t.ie=s=>{let o=null===i()?Pl(e,n,e.u,t):null;if(null===o){let t=e.read(r,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=s))}let a=o.re.get(t);void 0===Sl(o.host.state,a.t)?.set&&v(`Cannot write to "${a.t}" on mounted <${o.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),o.N.A(a,null,s)},t.n>0&&(t.P=e.Ie++)}function Wl(t,n,r,l,i,s){if(null!==n.getter)return t.T.we(t,n,r),void t.Ae();if("*"===n.s){if(null===r)return;if(r.R=r.l.C[r.w],t.T.Yt(r),null!==r.c)for(let e of r.c.values())t.X(e)}else t.En(n,r);e.ve?.(t,n,r,l,i,s),t.We(n,r)}function Rl(e){let t=e.m.N;for(let[n,r]of e.m.dt)r.e===e.e&&(0===n.n?t.T.we(t,n,null):t.tn(n.h[n.n],e=>t.T.we(t,n,e)));t.Ae()}function Il(e,t,n,r,l,i,s){let o=n.t.slice(t.t.length);if(""===o)return Rl(e);let a,u=e.m,c=u.N;if(""===e.e.E){a=o.slice(1);let e=ml(a);if("$"===e[0]||kl(u.host,e)||u.host.entries.some(e=>""!==e.E&&(a===e.E||a.startsWith(`${e.E}.`))))return}else a=e.e.E+o;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(te(r,e).w);c.resolve(gl(a,f),null);let h=c.rp,d=c.rr;h.n>0&&null===d||Wl(c,h,d,l,i,s)}function Dl(e,t,n,r,l,i,s){if(0===fl)return;let o=hl.has(e);hl.add(e);try{let o=ul.get(e);!s&&void 0!==o&&o.fn&&!hl.has(o.host.engine)&&function(e,t,n,r,l,i){let s,o=t;for(;null!==o&&void 0===(s=e.dt.get(o));)o=o.d;if(null===o||void 0===s)return;let a=e.host.engine;if(o===t&&e.dn===t)return void(e.dn=null);if(null!==s.r&&!s.r.y)return;let u=[...a.H(s.r),...e.N.H(n)];a.resolve(gl(s.p.t+t.t.slice(o.t.length),u),null);let c=a.rp,f=a.rr;c.n>0&&null===f||jl(e,s.e,()=>Wl(a,c,f,r,l,i))}(o,t,n,r,l,i),s&&void 0!==o&&o.fn&&null!==o.re&&function(e,t){let n=e.host.entries.find(e=>""===e.E),r=e.host.engine;for(let[l,i]of e.re)i===t&&(r.T.we(r,l,n.r),r.Ae())}(o,t);let a=cl.get(e);if(void 0===a)return;for(let[e,o]of a)if(t.ee(e)){let a=o.get(0===e.n?null:te(n,e.n));if(void 0!==a)for(let o of[...a])Ol(o,s)&&Il(o,e,t,n,r,l,i)}else if(e.ee(t))for(let[e,r]of[...o])if(0===t.n||te(e,t.n)===n)for(let e of[...r])Ol(e,s)&&Rl(e)}finally{o||hl.delete(e)}}async function Ll(t,n,r,l,i){if(l===dl)return;let s=o(l);s&&await s;let a=al.get(n);a.engine&&l.$recursion&&v(`[wcs/mount-dollar-declaration] <${n.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let u=a.O;if(null!==u&&u.el!==t&&u.el.isConnected&&v(`<${n.localName}> already has a connected <${le.tagNames.state} bind-component="${a.me}">.`),null!==u&&Cl(u,!1),null!==u&&function(e,t,n){let r=e.N,l=`[${le.bindAttributeName}]`,i=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),s=new Set,o=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&s.add(e)},a=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)o(n);o(t)};for(let e of r.ue.values())for(let t of e)if(null===t.W)o(t.a);else for(let e of t.W.G)a(t.W,e.S);for(let e of r.oe.values())for(let t of[e.$,...e.D??[]])null!==t&&a(t,t.S);for(let t of e.j)t.parentNode===n&&i(t)&&s.add(t);if(0===s.size)return!1;let u=[...n.childNodes].filter(n=>n!==t&&!s.has(n)&&!e.j.includes(n)&&(i(n)||r.Bt&&n.textContent.includes("{{")));return u.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${u.length} node(s) added beside the content taken over are not bound.`),!0}(u,t,r))return async function(e,t,n,r){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.j=e.j.filter(e=>e.parentNode===n),t.isConnected?await ql(e,r):r()}(u,t,r,i);let c=new re(l,new Jt);c.element=t,t.engine=c,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let r=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof r&&"constructor"!==t&&n.set(r,null)}let r=(t,n,r)=>Reflect.apply(t,e.proxy,r);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:r})),t}}(c,l);let f={el:t,j:[],N:c,host:a,pe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of a.entries)f.pe.push({m:f,e});a.O=f,ul.set(c,f);let h=null===a.engine;h?e.element?.(c,"mounting"):(function(e){let t=e.N,n=e.host,r=n.engine,l=n.el.localName,i=n.entries.find(e=>""===e.E)??null;for(let e of n.entries){if(""===e.E)continue;let t=ml(e.E);kl(n,t)&&(e.E!==t||xl(n,t))&&Al(`${l}.${e.E}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.me}.${e.E}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==i){let e=r.v(i.he,i.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.E===t)&&Al(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${i.he.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let s=pl.filter(e=>void 0!==n.state[e]);s.length>0&&Al(`${l}.${n.me}$`,`[wcs/mount-dollar-declaration] <${l}>: ${s.join(", ")} ${1===s.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let o=t.nt;t.nt=n=>{Tl(e,i,n),o.call(t,n)};let a=[...t.I.all()];for(let t of a)Tl(e,i,t);for(let e of a)o.call(t,e);let u=t.zt;t.zt=()=>{(function(e){for(;void 0!==e;e=ul.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.y))return!1;return!0})(e)&&u.call(t)}}(f),Cl(f,!0),Dr.add(c),Br(c,r));let d=e.hr?.(r);qt(c,r),d?.(),f.j=[...r.childNodes],Kt(),h&&c.$n(),Object.defineProperty(n,a.me,{configurable:!0,enumerable:!0,get:()=>c.proxy});let p=n.$stateReadyCallback;if("function"==typeof p)try{let e=p.call(n,a.me);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}i(),t.isConnected?(await c.ke("$connectedCallback"),h&&t.isConnected&&e.element?.(c,"connected")):Cl(f,!1)}async function ql(t,n){Cl(t,!0);for(let e of t.pe)Rl(e);n?.(),!t.broken&&(await t.N.ke("$connectedCallback"),null===t.host.engine&&t.el.isConnected&&e.element?.(t.N,"connected"))}function zl(t,n){let r=t.getAttribute("bind-component");if(null===r)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=Lt.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){Gr(t,e);for(let e of Xr.get(t)??[])e()}}),null}(t,n);let l=t.parentNode,i=l instanceof ShadowRoot,s=i?l.host:l instanceof Element?l:null,o=()=>{let e=null===s?void 0:al.get(s)?.O;return e?.el===t?e:null},a=e=>{throw i&&Gr(l,t),e},u=!1;return{Ot:()=>(null!==s&&s.localName.includes("-")?async function(e,t,n,r){let l=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&v(`<${le.tagNames.state} bind-component> takes its state from <${l}>.${t}: it cannot also load one (state / src / json / an inline script).`),await Le(n).whenDefined(l);let i=al.get(n);if(void 0!==i)return i.me!==t&&v(`<${l}> already has a <${le.tagNames.state} bind-component="${i.me}">.`),i.state;let s=()=>(rl.get(n)??[]).filter(e=>ml(e.name)===t),o=vl(n,t);if(o&&0===s().length&&$l(n),0===s().length&&(o||((e,t)=>!0===e.getAttribute(ol)?.split(" ").includes(t))(n,t))){let e;await new Promise((r,i)=>{sl.set(n,r),e=function(e,t){Vr(e)&&t();let n=Xr.get(e)??new Set;return Xr.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>i(new Error(`[@wcstack/state] <${l}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}sl.delete(n);let a=s(),u=il.get(n),c=void 0!==u&&u.has(t)?u.get(t):n[t];if((null===c||"object"!=typeof c)&&v(`"bind-component": <${l}>.${t} must be an object (the component's state), got ${null===c?"null":typeof c}.`),0===a.length&&r){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${l}>, or mount it from the host (${le.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),dl}let f=[];for(let e of a){let r=e.name===t?"":e.name.slice(t.length+1);f.some(e=>e.E===r)&&v(`<${l}> maps "${e.name}" twice.`);let i=r.split(".").indexOf("*");if(i>=0){let n=r.split(".").slice(0,i).join(".");v(`<${l}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}f.push({E:r,he:e.o,r:e.r,ro:ll.has(e)}),e.engine.Nn(e),""!==r&&delete n[e.name]}let h=0===a.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(c):c;return al.set(n,i={el:n,me:t,state:h,engine:0===a.length?null:a[0].engine,entries:f,O:null}),h}(t,r,s,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${le.tagNames.state}> to be a direct child of a custom element.`))).catch(a),async start(e,n){await Ll(t,s,i?l:s,e,()=>{u=!0,n()}).catch(e=>{let t=o();return!u&&null!==t&&(t.broken=!0),a(e)})},Xe(){let e=o();null!==e?ql(e).catch(e=>console.error(e)):u?Promise.resolve().then(()=>{if(t.parentNode===l)return Ll(t,s,i?l:s,al.get(s).state,()=>{})}).catch(e=>console.error(e)):sl.has(s)&&$l(s)},Dn(){let t=o();null!==t&&(Cl(t,!1),!t.broken&&(t.N.ke("$disconnectedCallback"),null===t.host.engine&&e.element?.(t.N,"disconnected")))},reset(){v(`re-setting a component's state is not supported: write <${s?.localName}>.${r} instead.`)}}}var Fl={name:"scopes",install(){e.at=n(i,e.at,Qr),e.at=n(i,e.at,nl),e.at=n(i,e.at,zl),e.ar=yl,e.Eo=bl,e.element=t(e.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=Lr.get(e)??[];if("disconnected"===t)for(let e of n)Hr(e);else if("reset"!==t&&_r(Lt.get(e.root))===e){Br(e,e.root);for(let e of n)Wr.get(e.root).has(e.t)||Wr.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();Br(e,n),function(e,t){let n=t.host,r=void 0===n?void 0:Zr.get(n);void 0!==r&&el.set(e,{host:n,def:r})}(e,n)}),e.ve=t(e.ve,(e,t,n,r,l,i)=>{(function(e,t,n,r){let l=el.get(e);if(void 0===l)return;let i=t.t.split(".",1)[0];if(!l.def.bindables.includes(i))return;let s=r&&t.t===i;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${i}-changed`,{detail:s?n:void 0,bubbles:!0}))})(e,t,l,i),Dl(e,t,n,r,l,i,!1)}),e.Se=t(e.Se,(e,t,n)=>Dl(e,t,n,void 0,void 0,!1,!0)),e.Pe=n(r,e.Pe,(e,t,n,r,l)=>(function(e,t){let n=Lr.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&v(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let r,l=ul.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===r;e=e.d)r=l.dt.get(e);if(void 0===r)return!1;let i=r.e;return!((null===i.r||i.r.y)&&!i.ro)&&(!!n||(Nl(l,i.r),void v(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.me}${""===i.E?"":`.${i.E}`}#ro: ${i.he.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let l=e.fe;e.fe=(e,t)=>{let n=Lr.get(e);void 0!==n&&n.length>0&&v(`re-setting a root state with grafted volumes (${n.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=cl.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(e)&&v("re-setting a root state with mounted components is not supported: they read its data."),l?.(e,t)}}},Ul="$recursion",_l=new WeakMap,Vl=new WeakSet,Bl=new WeakSet,Hl=0,Kl=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Jl=e=>`[wcs/recursion-${e}]`;function Yl(e,t){let n=n=>v(`${Jl("declaration-invalid")} ${Ul} ${e} "${String(t)}" ${n}`);("string"!=typeof t||""===t)&&v(`${Jl("declaration-invalid")} ${Ul} ${e} must be a non-empty string.`);let r=t.split(".");(r.length<2||"*"!==r[r.length-1])&&n('must end with ".*" (a list element).');for(let e=0;e<r.length-1;e++){let t=r[e];""===t&&n("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&n('must have exactly one "*", at the end.'),t.includes("#")&&n('must not contain "#".')}return"$"===t[0]&&n('must not start with "$".'),t}var Gl=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function Xl(e,t){let n=`${e.l}.**`,r=t.slice(n.length);return(!t.startsWith(n)||""!==r&&"."!==r[0]||r.includes("**"))&&v(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),r}function Ql(e,t,n){let r=Xl(e,t),l=function(e,t){for(let n=t;null!==n;n=n.l.ae){let t=e.nodeList.exec(n.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r:n}}return null}(e,n);return null===l&&v(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),Gl(e,l.k)+r}function Zl(e,t,n){let r=new Set,l=new Set,i=(e,n,i)=>!(!Array.isArray(e)||0===e.length||(r.has(e)&&v(`${Jl("cycle")} "${n}" is reachable from itself: the data under "${t.l}" must be a tree.`),l.has(e)&&v(`${Jl("shared-list")} "${n}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),i+1>128&&v(`${Jl("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${i+1} (the limit is 128).`),l.add(e),0)),s=(l,o)=>{for(let a of l){n(o,a);let l=e.o(`${Gl(t,o)}.${t.key}`),u=e.read(l,a);i(u,l.t,o+1)&&(r.add(u),s(e._e(a,l).f,o+1),r.delete(u))}},o=e.o(t.l),a=e.read(o,null);i(a,t.l,0)&&(r.add(a),s(e._e(null,o).f,0))}function ei(e,t){let n=function(e){let t=e[Ul],n=[],r=new Set;for(let t=e;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of Object.getOwnPropertyNames(t))!r.has(e)&&e.includes("**")&&n.push([e,Object.getOwnPropertyDescriptor(t,e)]),r.add(e);if(void 0===t)return n.length>0&&U(n[0][0]),null;(null===t||"object"!=typeof t||Array.isArray(t))&&v(`${Jl("declaration-invalid")} ${Ul} must be an object mapping one anchor path to its repeating sub-path.`);let l=Object.entries(t);1!==l.length&&v(`${Jl("declaration-invalid")} ${Ul} must declare exactly one anchor (it declares ${l.length}).`);let i=Yl("anchor",l[0][0]),s=Yl("repeat",l[0][1]),o=i.slice(0,-2),a=s.slice(0,-2),u=`.${s}`,c=new Map,f=[],h=`${o}.**`;for(let[e,t]of n){let n=e.slice(h.length);(!e.startsWith(h)||""!==n&&"."!==n[0]||n.includes("**"))&&v(`[wcs/recursion-anchor] "${e}": a recursive key is "${h}" followed by a path (the anchor is "${i}").`),(""===n||n.split(".").slice(1).some(e=>""===e))&&v(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&v(`${Jl("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),c.set(n,t.get),f.push([new RegExp(`^${Kl(i)}((?:${Kl(u)})*)${Kl(n)}$`),n])}return{l:o,step:u,key:a,families:c,matchers:f,owners:new Map,nodeList:new RegExp(`^${Kl(o)}((?:${Kl(`.*.${a}`)})*)$`)}}(t),r=_l.has(e);null!==n?(r||Hl++,_l.set(e,n),Bl.add(e),Vl.has(e)||function(e){Vl.add(e);let t=e,n=t.nt;t.nt=r=>{let l=_l.get(e);if(r.t.includes("**")){let t=e.I.Mt(r.t)===r;return void(Bl.has(e)||void 0===l&&t?r.getter=()=>U(r.t):t||n.call(e,r))}if(void 0!==l&&null===r.getter)for(let[e,n]of l.matchers)if(e.test(r.t)){r.getter=l.families.get(n),r.n>0&&(r.P=t.Ie++),l.owners.set(r,l.l+".**"+n);break}n.call(e,r)};let r=t.resolve;t.resolve=(t,n)=>{let l=_l.get(e);return r.call(e,void 0!==l&&t.includes("**")?Ql(l,t,n):t,n)};let l=t.getAll;t.getAll=(n,r)=>{let i=_l.get(e);if(void 0===i||!n.includes("**"))return l.call(e,n,r);if(void 0===r)return l.call(e,Ql(i,n,t.u));(!Array.isArray(r)||r.length>0)&&v(`${Jl("getall-form")} $getAll("${n}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let s=Xl(i,n),o=[];return Zl(e,i,(t,n)=>{for(let r of l.call(e,Gl(i,t)+s,e.H(n)))o.push(r)}),o};let i=t.yn;t.yn=(n,r,l,s)=>{let o=_l.get(e);if(void 0===o||!n.includes("**"))return i.call(e,n,r,l,s);Array.isArray(r)||w(9,[n]),r.length>0&&v(`${Jl("setall-form")} $setAll("${n}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof l||!0===s?.spread)&&v(`${Jl("setall-form")} $setAll("${n}", [], value) with "**" takes a plain value (no mapper, no spread).`),t.Me>0&&w(8);let a=Xl(o,n),u=a.replace(/\.\d+(?=\.|$)/g,".*");for(;u.startsWith(o.step);)u=u.slice(o.step.length);let c=o.key.split(".");(""===u||u===`.${o.key}.length`||c.some((e,t)=>u===`.${c.slice(0,t+1).join(".")}`))&&v(`${Jl("structural-write")} "${n}" writes the recursion structure itself (a node, its "${o.key}" list or that list's length, or an object on the way to it).`);for(let e of o.families.keys()){let t=e;for(;t.startsWith(o.step);)t=t.slice(o.step.length);(u===t||u.startsWith(`${t}.`))&&v(`${Jl("readonly")} "${n}" writes into the recursive getter "${o.l}.**${e}".`)}let f=[];Zl(e,o,(e,t)=>f.push([e,t]));let h=0;for(let[t,n]of f)h+=i.call(e,Gl(o,t)+a,e.H(n),l);return h}}(e)):r&&(_l.delete(e),Hl--)}function ti(e,t){if(0===Hl)return!1;let n=_l.get(e);if(void 0===n)return!1;for(let e=t;null!==e;e=e.d){let r=n.owners.get(e);void 0!==r&&v(`${Jl("readonly")} "${t.t}" writes into the recursive getter "${r}".`)}return!1}var ni={name:"recursion",install(){e.fe=t(e.fe,ei),e.element=t(e.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){Bl.delete(e)}(e)}),e.Pe=n(r,e.Pe,ti)}},ri="4.0.0-rc.7",li=e=>e.split(".").slice(0,2).join("."),ii=class extends Zt{static find(e){return e.querySelector?.(le.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return li(this.version)===li(ri)}};function si(e){let t=le.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends ii{})}var oi=()=>le.tagNames.ssr,ai=Symbol.for("wcstack.ssr.snapshotBuilder"),ui=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),ci=e=>document.createComment(e),fi=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,hi=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),di=new WeakMap,pi=new WeakMap,mi=new WeakMap,gi=new WeakSet,yi=new WeakMap;function bi(e,t){let n=[];for(let r=e;null!==r&&(n.push(r),r!==t);r=r.nextSibling);return n}function vi(e,t,...n){for(let n of Array.from(e.attributes))t.setAttribute(n.name,n.value);return(t.content??t).append(...n),t}var $i=e=>null===e.j?e.Ue:e.j[e.j.length-1];function wi(e,t,n){let r=[ci(null===n?"wcs-[":`wcs-[:${n}`)];for(let e of t)null===n&&r.push(ci("wcs-|")),r.push(...bi(e.Ue,$i(e)));r.push(ci("wcs-]")),e.after(...r);for(let e of r)gi.add(e)}function Ai(e){if(e instanceof ct){wi(e.S,e.Re,null);for(let t of e.Re)ki(t);return}let t=e.O;null!==t&&(wi(e.G[e.G.length-1].S,[t],e.w),ki(t))}function ki(e){if(null!==e.c)for(let t of e.c)Ai(t)}var xi=new Set(["script","style","template","textarea","title"]),Si="data-wcs-raw",Ti=e=>xi.has(e.localName)||e.localName===oi();function Ni(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(ci("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(ci("wcs-s")):1===t.nodeType&&!Ti(t)&&Ni(t)}var ji=0;function Oi(e,t){let n=e.getRootNode(),r=[t];for(let e of pi.get(n)??[])e!==t&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let l=new Map;for(let e of r){let t=di.get(e);if(void 0===t)continue;let n=new Map;for(let t of e.oe.values())if(null!==t.$&&n.set(t.$.S,t.$),null!==t.D)for(let e of t.D)n.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.W)for(let t of e.W.G)n.set(t.S,e.W);let r=new Set;for(let[e,i]of t){l.set(e,i);let t=n.get(e);void 0!==t&&!r.has(t)&&e.isConnected&&(r.add(t),Ai(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=mi.get(e);if(void 0!==t){let n=document.createTreeWalker(e,133,{acceptNode:e=>gi.has(e)||1===e.nodeType&&t.has(e)&&Wi(e)?2:1}),r=[];for(let e=n.nextNode();null!==e;e=n.nextNode()){let n=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(Ti(e.parentNode)?yi.has(e):t.has(n)&&hi(n,"wcs-t:"))&&(yi.has(e)||t.get(e)!==e.data):!t.has(e))&&r.push(e)}for(let e of r)e.remove()}let n=Array.from(e.childNodes);Ti(e)&&n.some(e=>yi.has(e))&&e.setAttribute(Si,n.map(e=>yi.has(e)?`{{ ${yi.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}Ni(9===n.nodeType?n.body:n);let i=document.createElement(oi());i.setAttribute("version",ri);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let n of Object.keys(e)){if("$"===n[0])continue;let r=Object.getOwnPropertyDescriptor(e,n);void 0!==r.get||void 0!==r.set||"function"==typeof r.value||(t[n]=r.value)}return t}(t.target)),i.append(s);for(let[e,t]of l){if(!e.isConnected)continue;let n=e.parentNode;for(;null!==n&&"svg"!==n.localName&&"foreignObject"!==n.localName;)n=n.parentElement;let r="svg"===n?.localName,l=`wcs-${r?"s":"t"}${ji++}`;e.replaceWith(ci(`wcs-p:${l}`));let s=document.importNode(Pt(t),!0);for(let e of Array.from(s.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(vi(e,document.createElement("template"),...e.childNodes));if(r){let e=document.createElementNS(n.namespaceURI,"svg");e.append(s),s=e}let o=document.createElement("template");o.id=l,i.append(vi(t,o,s))}e.before(i)}function Ci(e){!function(e){if(null!==e.querySelector(le.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>yi.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${le.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===oi())continue;let e=t.engine;null!=e&&Oi(t,e)}}var Mi=Symbol.for("wcstack.state.ssr.impl"),Pi=new Map,Ei=new WeakMap,Wi=t=>!0===e.Eo?.(t),Ri=e=>1===e.nodeType&&!Ti(e)&&!Wi(e),Ii=e=>e.f.flat().concat(e.q??[]),Di=e=>{for(let t of Ii(e))t.remove()};function Li(e,t,n){let r=/^wcs-\[(?::(\d+))?/.exec(e.data),l=e.previousSibling,i=e.parentNode,s=[],o=e.nextSibling;for(e.remove();null!==o&&!fi(o,"wcs-]");){let e=o.nextSibling;if(fi(o,"wcs-|"))s.push([]),o.remove();else{0===s.length&&s.push([]);let n=s[s.length-1];hi(o,"wcs-[")?e=Li(o,t,n):(n.push(o),Ri(o)&&qi(o,t))}o=e}let a={branch:void 0===r[1]?null:Number(r[1]),f:s,q:o??i.appendChild(ci("wcs-]"))},u=Ii(a);o=a.q.nextSibling;for(let e of u)n?.push(e),t&&Ot.add(e);return t&&null!==l?Pi.set(l,a):Di(a),o}function qi(e,t){for(let n=e.firstChild;null!==n;)hi(n,"wcs-[")?n=Li(n,t):(Ri(n)&&qi(n,t),n=n.nextSibling)}function zi(e,t,n){let r=e=>{for(let l of Array.from(e.childNodes))if(l.parentNode===e)if(8===l.nodeType){let e=l.data;try{if("wcs-s"===e)l.remove();else if("wcs-e"===e)l.replaceWith("");else if(e.startsWith("wcs-t:")){let t=ci(`@@:${decodeURIComponent(e.slice(6))}`),n=l.nextSibling;for(;null!==n&&!fi(n,"wcs-/t");){let e=n.nextSibling;n.remove(),n=e}n?.remove(),l.replaceWith(t)}else if(e.startsWith("wcs-p:")){let n=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==n){let t=l.parentNode,r="s"===e[10]?vi(n,document.createElementNS(t.namespaceURI,"template"),...document.importNode(n.content.firstChild,!0).childNodes):document.importNode(n,!0);r.removeAttribute("id"),t.replaceChild(r,l)}}}catch{}}else 1===l.nodeType&&!Ti(l)&&(Wi(l)?Ei.set(l,{ssr:t,Oe:n}):r(l))};r(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let n=t.previousSibling;null!==n&&(8===n.nodeType||Ki(n)||"template"===n.localName);n=n.previousSibling)e.unshift(n);let n=0,r=0;if(e.forEach((e,t)=>{hi(e,"wcs-[")?r++:fi(e,"wcs-]")&&--r<0&&(r=0,n=t+1)}),0===r)continue;let l=0;for(let r=t.firstChild;null!==r;r=r.nextSibling)if(hi(r,"wcs-["))l++;else if(fi(r,"wcs-]")&&0===l--){t.prepend(...e.slice(n));break}}}(e),qi(e,n)}function Fi(t){let n=Ei.get(t);if(void 0===n||(Ei.delete(t),zi(t,n.ssr,n.Oe),!n.Oe))return null;let r=e.Oe;return e.Oe=Gi,()=>{e.Oe=r,Ui()}}function Ui(){for(let e of Pi.values())Di(e);Pi.clear()}function _i(e){let t=[];for(let n=document.createTreeWalker(e,128);n.nextNode();)t.push(n.currentNode);return t}function Vi(e,t,n,r){let l=null;for(let r of e){let e=r[n];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===l||e.length>l[n].length)&&(l=r)}let i=l?.[r];if(null==i)return null;let s=l[n],o=""===s?t:t.slice(s.length+1);return""===i?o:""===o?i:`${i}.${o}`}function Bi(e,t,n){if(ui()){if(n instanceof Array){for(let e=n.length;e-- >0;)vt(n[e])&&n.splice(e,1);let e=t;if(n.some($t))gi.add(e);else if(e.localName.includes("-")&&!Wi(e)){let t=new Map;for(let n=document.createTreeWalker(e,133);n.nextNode();)t.set(n.currentNode,n.currentNode.data);mi.set(e,t)}return}if("string"==typeof n){if(yi.set(t,n),Ti(t.parentNode))return;let e=ci(`wcs-t:${encodeURIComponent(n)}`),r=ci("wcs-/t");return t.before(e),void t.after(r)}let r=di.get(e);void 0===r&&di.set(e,r=new Map),r.set(t,n);let l=t.getRootNode(),i=pi.get(l);return void 0===i&&pi.set(l,i=new Set),void i.add(e)}if("string"!=typeof n&&Pi.size>0){let e=Pi.get(n);void 0!==e&&(Pi.delete(n),Pi.set(t,e))}}var Hi=e=>null!==e&&8===e.nodeType&&[le.commentIfPrefix,le.commentElseIfPrefix,le.commentElsePrefix].includes(e.data),Ki=e=>3===e.nodeType&&""===e.data.trim(),Ji=e=>(Pi.get(e)?.q??e).nextSibling;function Yi(e,t){if(t.length!==e.sn.childNodes.length)return!1;let n=e.On;for(let r=0;r<n.length;r++){let l=n[r],i=e.sn,s=t[l[0]];for(let e=0;;){if(i=i.childNodes[l[e]],s?.nodeName!==i.nodeName)return!1;if(++e===l.length)break;s=s.firstChild;for(let t=l[e];t>0&&null!==s;t--)s=Ji(s)}e.So[r]=s}return!0}function Gi(e,t,n){if(0===Pi.size)return null;let r=t,l=0;if(!n){let e=le.commentIfPrefix;if(!fi(t,e))for(let n=t.previousSibling;null!==n&&1!==n.nodeType&&(Hi(n)&&l++,!fi(n,e));n=n.previousSibling);for(let n=t.nextSibling;!Pi.has(r)&&null!==n&&!fi(n,e)&&1!==n.nodeType;n=n.nextSibling)Hi(n)&&(r=n)}let i=Pi.get(r);if(void 0===i)return null;if(!n&&i.branch!==l)return Pi.delete(r),Di(i),null;let s=i.f.shift();if(0===i.f.length&&Pi.delete(r),i.q?.replaceWith(...bi(t,r)),i.q=null,void 0===s)return null;let o=[];for(let e=0;e<s.length;e++){let t=Pi.get(s[e]);if(o.push(s[e]),void 0!==t)for(;e<s.length&&s[e]!==t.q;)e++}if(!Yi(e,o)){let n=(e.In?e.root:e.sn).cloneNode(!0);o=e.In?[n]:[...n.childNodes],Yi(e,o),(s[0]??i.f.find(e=>e.length>0)?.[0]??t).before(n);for(let e of s)e.remove()}return o}var Xi={name:"ssr",install(){e.Mn=Bi,e.hr=Fi;let n=e.element;e.element=(t,r)=>{"mounting"===r&&function(t){let n=t.element;if(!n.hasAttribute("enable-ssr")||ui())return;let r=n.previousElementSibling,l=r?.localName===oi(),i=l?r.getAttribute("version"):null,s=null===i||li(i)===li(ri);if(s){let e=t,n=e.ke;e.ke=(e,r)=>"$connectedCallback"===e?void 0:n.call(t,e,r)}if(!l)return;let o=!s&&parseInt(i)<4,a=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==a&&(+a[1]-5||+a[2]-3)>=0;s||console.warn(`[@wcstack/state] <${oi()} version="${i}"> does not match ${ri}: its snapshot is discarded, and the page renders on the client from its own state.${o&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let c=s?r.querySelector('script[type="application/json"]'):null;if(null!==c){let e=JSON.parse(c.textContent||"{}"),n=t.target;for(let t of Object.keys(e)){let r=Object.getOwnPropertyDescriptor(n,t);void 0!==r&&(void 0!==r.get||void 0!==r.set||"function"==typeof r.value)||(n[t]=e[t])}t.hydrated=!0}let f=n.getRootNode();for(let e of Array.from(f.querySelectorAll(`[${Si}]`)))e.textContent=e.getAttribute(Si),e.removeAttribute(Si);let h=9===f.nodeType?f.body:f;o?function(e,t,n){let r=new Map,l=e=>{let t=e.parentElement;for(;null!==t&&!Wi(t);)t=t.parentElement;if(null===t)return null;let n=r.get(t);if(void 0===n){let e=l(t),i=t.querySelector(`:scope > ${le.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,n=[]);for(let r of ce(t.getAttribute(le.bindAttributeName)??"")){let t=r.Qe;r.$e[0]===i&&n.push([e?Vi(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return n},i=(e,t,n)=>{let r=l(e);if(null===r)return t;let i=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===i)return n?t:Vi(r,t,0,1)??t;let s=i[1].replace(/#m\d+\./g,"").slice(0,-1);return r.some(e=>""===e[1]&&(e[0]===s||e[2]===s))?i[2]:Vi(r,i[2],2,1)??i[2]};for(let t of _i(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let r=t.nextSibling;for(;null!==r&&!fi(r,`@@wcs-${e[1]}-end:${e[2]}`);)r=r.nextSibling;if(null!==r){for(;t.nextSibling!==r;)t.nextSibling.remove();r.remove(),t.replaceWith(..."text"===e[1]?[ci(`@@:${i(t,e[2],n)}`)]:[])}}let s=(e,n)=>{for(let r of _i(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(r.data)?.[1],l=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===l)continue;let o=document.importNode(l,!0),a=le.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,l)=>t+i(n??r,l))),s(o.content,n??r);let u=o.content.firstChild;r.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(h,r,u):zi(h,r,s),r.remove(),s&&(e.Oe=Gi,queueMicrotask(()=>{Ui(),e.Oe=null}))}(t),n?.(t,r)},function(){let e=globalThis;e[Mi]={build:Ci,reset(){ji=0}},void 0===e[ai]&&(e[ai]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[Mi].build(t),reset:()=>e[Mi].reset()})}(),e.Ao=t(e.Ao,si);for(let e of nn())si(e)}},Qi="__WCSTACK_DEVTOOLS_HOOK__",Zi=null,es=new Set,ts=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),ns=new WeakMap,rs=0;var ls=new WeakMap;function is(e){if(null===Zi)return;let t=ls.get(e),n=es.has(e)?function(e,t){let n=new Map,r=new Set,l=(r,l,i,s,o,a)=>{if(5===r)return;let u=function(e,t){return 0===e?"textContent":2===e?`class.${t}`:3===e?`attr.${t}`:4===e?`style.${t}`:t}(r,l),c=0===s.n?null:o,f=`${(e=>{let t=ns.get(e);return void 0===t&&ns.set(e,t=++rs),t})(i)}|${u}|${s.t}|${null===c?"":e.H(c).join(",")}`;if(n.has(f))return;let h=t?.get(f);n.set(f,h??{binding:{propName:u,statePathName:s.t,bindingType:a,node:i,replaceNode:i},absoluteAddress:ts(e,s,c)})},i=e=>l(e.i,e.name,e.a,e.o,e.r,e.nn()),s=e=>{if(!r.has(e)){if(r.add(e),null!==e.ye)for(let t of e.ye)i(t);if(e instanceof et&&null!==e.pe){let t=e.F.ze;for(let n=0;n<t.length;n++){let r=e.V?.[n];void 0!==r?i(r):l(t[n].i,t[n].name,e.pe[2*n],t[n].o,e.r,0===t[n].i?"text":"prop")}}if(null!==e.c)for(let t of e.c)o(t)}},o=e=>{if(!r.has(e))if(r.add(e),e instanceof ct){l(-1,"for",e.S,e.l.o,e.l.ae,"for");for(let t of e.Re)s(t)}else null!==e.O&&s(e.O)};for(let t of e.ue.values())for(let e of t)i(e),null!==e.W&&o(e.W);for(let t of e.oe.values())if(null!==t.$&&o(t.$),null!==t.D)for(let e of t.D)o(e);return n}(e,t):new Map;if(void 0!==t)for(let[e,r]of t)n.has(e)||Zi({type:"state:binding-removed",...r});for(let[e,r]of n)(void 0===t||!t.has(e))&&Zi({type:"state:binding-added",...r});ls.set(e,n)}function ss(e){let t=Lt.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function os(e){let t=new Set,n=new Set,r=new Set,l=new Set;for(let i of e.I.all()){for(let e=1;e<=i.n;e++)t.add(i.h[e].t);"*"===i.s&&n.add(i.t),null!==i.getter&&r.add(i.t),null!==i.ie&&l.add(i.t)}let i=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:r,setter:l},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.ce.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==i.$watch&&"object"==typeof i.$watch?new Set(Object.keys(i.$watch)):null,keyedListPaths:null!==i.$listKeys&&"object"==typeof i.$listKeys?new Set(Object.keys(i.$listKeys)):null}}var as=new WeakSet,us=new WeakMap;function cs(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(as.has(t))return;as.add(t);let r=t.emit;t.emit=(...l)=>(null!==Zi&&Zi({type:"state:token-emit",kind:n,tokenName:t.name,args:l,subscriberCount:t.size,stateElement:e.element}),r.apply(t,l))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.ce.values())t(n,"event")}(e),"connected"===t){if(es.has(e))return;es.add(e),Zi?.({type:"state:element-registered",rootNode:e.root,element:e.element}),is(e)}else"disconnected"===t&&(es.delete(e),is(e),Zi?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function fs(e,t,n,r,l,i){if(null===Zi)return;let s=ts(e,t,0===t.n?null:n),o=us.get(e);void 0===o&&us.set(e,o=new Set),o.add(s),i&&Zi({type:"state:write",absoluteAddress:s,value:l,oldValue:r,hasOldValue:!0})}function hs(e){if(null===Zi)return;let t=us.get(e);us.delete(e),void 0!==t&&Zi({type:"state:update-batch",addresses:t}),is(e)}function ds(e,t,n){Zi?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.nn(),error:t})}var ps={"*":["focus","blur","click","scrollIntoView","showPopover","hidePopover","togglePopover"],dialog:["show","showModal","close","requestClose"],form:["requestSubmit","checkValidity","reportValidity"],input:["select","setSelectionRange","showPicker","setCustomValidity","checkValidity","reportValidity"],textarea:["select","setSelectionRange","setCustomValidity","checkValidity","reportValidity"],select:["showPicker","setCustomValidity","checkValidity","reportValidity"],audio:["play","pause","load"],video:["play","pause","load"]};function ms(e,t){let n=e.localName;if(n.includes("-"))return null;let r=(e=>[...ps["*"],...Object.hasOwn(ps,e)?ps[e]:[]])(n);return r.includes(t)||w(1205,[n,t,r.join(", ")],t,r),(e,n)=>e[t](...n[0]instanceof Event?[]:n)}var gs=[kn,er,Sr,Er,Fl,ni,Xi,{name:"devtools",install(){e.element=t(e.element,cs),e.ve=t(e.ve,fs),e.Fe=t(e.Fe,hs),e.Ke=t(e.Ke,ds),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[Qi]??(t[Qi]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let r of t)r.onEvent?.(e.id,n)})};return{version:2,sources:e,register(r){if(!e.has(r.id)){e.set(r.id,r),n(r);for(let e of t)e.onSourceRegistered?.(r)}},unregister(n){let r=e.get(n);if(void 0!==r){r._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(r){t.add(r);for(let t of e.values())n(t),r.onSourceRegistered?.(t);return()=>{if(t.delete(r))for(let t of e.values())n(t)}}}}());2!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:ri,getStateElements:()=>[...es].map(os),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.I.all()){let r=n._,l=n.Ce?.length??0;if((null===r||0===r.size)&&0===l)continue;let i,s=0;if(null!==r)for(let e of r.values())s+=e.size;try{i=0===n.n?e.v(n,null):void 0}catch{i=void 0}t.push({path:n.t,tracked:!1,rows:s,keys:null===r?0:r.size,lists:l,lastValue:i})}return t}(ss(e)),keys(e){let t=ss(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let r;return ss(e).element.createState("readonly",e=>{r=e.$resolve(t,n??[])}),r},write(e,t,n,r){ss(e).element.createState("writable",e=>{e.$resolve(t,r??[],n)})},_setSink(t){let n=null===Zi&&null!==t;Zi=t,null===t&&(ls=new WeakMap),e.st=t&&((e,t)=>Zi?.({...t,stateElement:e.element})),n&&queueMicrotask(()=>{for(let e of es)is(e)})}})}()}},{name:"native-commands",install(){e.or=ms}}];function ys(e){return e}var bs=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],vs={eq:{description:"等しいか比較",hasArgs:!0,resultType:"boolean",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},ne:{description:"異なるか比較",hasArgs:!0,resultType:"boolean",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},not:{description:"真偽性を反転(falsy → true)",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},lt:{description:"より小さいか",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},le:{description:"以下か",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},gt:{description:"より大きいか",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},ge:{description:"以上か",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},add:{description:"加算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},sub:{description:"減算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},mul:{description:"乗算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},div:{description:"除算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},mod:{description:"剰余",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},abs:{description:"絶対値",hasArgs:!1,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:0},clamp:{description:"範囲内に丸める (min,max)",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:2,maxArgs:2,argTypes:["number","number"]},toFixed:{description:"固定小数点表記",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},locale:{description:"ロケール形式で数値フォーマット",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["string"]},upper:{description:"大文字に変換",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},lower:{description:"小文字に変換",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},capitalize:{description:"先頭文字を大文字に",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},trim:{description:"前後の空白を削除",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},slice:{description:"部分文字列 (start[,end])",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","number"]},padStart:{description:"先頭を埋める (length[,char]。char の既定は 0 — JS の既定は空白なので注意)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},padEnd:{description:"末尾を埋める (length[,char]。char の既定は空白 — JS と同じ)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},repeat:{description:"繰り返し (count)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:1,argTypes:["number"]},reverse:{description:"文字順を反転",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},truncate:{description:"切り詰めて省略記号 (length[,suffix]。suffix の既定は … — U+2026 の 1 文字)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},join:{description:"配列を連結 ([separator]。既定はカンマ + 空白)",hasArgs:!0,resultType:"string",acceptTypes:["array"],minArgs:0,maxArgs:1,argTypes:["string"]},int:{description:"整数にパース",hasArgs:!1,resultType:"number",acceptTypes:["string","number"],minArgs:0,maxArgs:0},float:{description:"浮動小数点数にパース",hasArgs:!1,resultType:"number",acceptTypes:["string","number"],minArgs:0,maxArgs:0},round:{description:"四捨五入",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},floor:{description:"切り下げ",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},ceil:{description:"切り上げ",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},percent:{description:"パーセンテージ形式",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},unit:{description:"単位(接尾辞)を付加",hasArgs:!0,resultType:"string",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["string"]},date:{description:"ロケール形式の日付 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},time:{description:"ロケール形式の時刻 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},datetime:{description:"ロケール形式の日時 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},ymd:{description:"YYYY-MM-DD 形式 ([separator]。既定は -)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},hms:{description:"HH:MM:SS 形式 ([separator]。既定は :)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},falsy:{description:"偽値か判定",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},truthy:{description:"真値か判定",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},defaults:{description:"偽値の場合デフォルト値",hasArgs:!0,resultType:"passthrough",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},coalesce:{description:"null / undefined の場合デフォルト値",hasArgs:!0,resultType:"passthrough",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},boolean:{description:"ブール値に変換",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},number:{description:"数値に変換",hasArgs:!1,resultType:"number",acceptTypes:"any",minArgs:0,maxArgs:0},string:{description:"文字列に変換",hasArgs:!1,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:0},nullIfEmpty:{description:"空文字列をnullに変換",hasArgs:!1,resultType:"passthrough",acceptTypes:["string"],minArgs:0,maxArgs:0}},$s=2,ws=Object.freeze({}),As=Object.freeze({}),ks=Object.freeze({}),xs=Object.freeze(["prevent","stop","ro","direct"]),Ss=Object.freeze(["init","sync"]),Ts=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function Ns(){return{version:2,syntax:{bindAttribute:le.bindAttributeName,tagName:le.tagNames.state,pathDelimiter:".",wildcard:"*",delimiters:{binding:";",propValue:":",modifier:"#",filter:"|"},structuralDirectives:Array.from(oe),modifiers:{flags:xs,keyValue:Ss,eventNamePrefix:"on"},indexParam:{prefix:"$",maxDepth:128},bindingTypes:{elseKeyword:N,spread:"...",eventPropertyPrefix:"on",explicitPropertyPrefix:".",propNamespaces:{eventToken:j,command:O,class:C,attr:M,style:P}}},filters:[...Object.keys(Se),...Object.keys(wn)],filterMeta:vs,filterAliases:ws,declarationAliases:As,apiAliases:ks,reservedLifecycle:["$connectedCallback","$disconnectedCallback","$renderedCallback","$errorCallback","$stateReadyCallback"],reservedStateApi:["$bindables","$commands","$commandTokens","$command","$eventTokens","$on","$stream","$watch","$listKeys","$recursion","$streamStatus","$streamError","$behavior","$features"],behaviorOptions:Object.fromEntries(Ts.map(e=>[e,{type:"boolean",default:!0}])),features:[...bs],nativeCommands:Object.fromEntries(Object.entries(ps).map(([e,t])=>[e,[...t]]))}}var js=new Set(["wcstack.types","wcstack.async","wcstack.platformCapabilities","wcstack.application"]),Os=Object.freeze([]);function Cs(e){if(!le.enableContractAnalyzer)return Os;let t=[],n=Zi,r=e=>{t.push(e),n?.(e)},l=e.manifestExtensions;if(null===l||"object"!=typeof l)return t;for(let e of Object.keys(l))js.has(e)||r({type:"contract:unsupported-extension",namespace:e});let i=l["wcstack.types"]?.components;if(null==i)return t;for(let[e,t]of Object.entries(i)){let n=Ms(e);if(r({type:"contract:manifest-read",tag:e,loaded:null!==n}),null===n){r({type:"contract:drift",reason:"component-not-loaded",tag:e});continue}let l=null!==t&&"object"==typeof t?t:{};for(let[t,i]of Object.entries(l.observables??{})){let l=n.ce.get(t);if(void 0===l){r({type:"contract:drift",reason:"missing-member",tag:e,member:t});continue}let s=i?.event;"string"==typeof s&&s!==l&&r({type:"contract:drift",reason:"event-mismatch",tag:e,member:t,sidecarEvent:s,liveEvent:l})}for(let t of Object.keys(l.inputs??{}))n.inputs.has(t)||r({type:"contract:drift",reason:"missing-member",tag:e,member:t});for(let t of Object.keys(l.commands??{}))n.commands.has(t)||r({type:"contract:drift",reason:"missing-member",tag:e,member:t})}return t}function Ms(e){let t=customElements.get(e)?.wcBindable;if(null===t||"object"!=typeof t||"wc-bindable"!==t.protocol)return null;let n=e=>Array.isArray(e)?e:[],r=new Map;for(let e of n(t.properties))"string"==typeof e?.name&&"string"==typeof e.event&&r.set(e.name,e.event);let l=e=>new Set(n(e).map(e=>e?.name).filter(e=>"string"==typeof e));return{ce:r,inputs:l(t.inputs),commands:l(t.commands)}}function Ps(e,t){(function(e){for(let t of e)s.has(t.name)||(s.add(t.name),t.install())})(gs),rn(e,t)}export{ii as Ssr,Oe as TRUSTED_TYPES_POLICY_SLOT,ri as VERSION,$s as WCS_MANIFEST_VERSION,Cs as analyzeContract,Ps as bootstrapState,sn as buildBindings,ws as builtinFilterAliases,vs as builtinFilterMeta,ys as defineState,Qt as getBindingsReady,ie as getConfig,Ce as getTrustedTypesPolicy,Ns as getWcsManifest,Me as setTrustedTypesPolicy};
|
|
1
|
+
var e={};function t(e,t){return null==e?t:(...n)=>{e(...n),t(...n)}}function n(e,t,n){return null==t?n:(...r)=>{let l=t(...r);return e(l)?l:n(...r)}}var r=e=>!0===e,l=e=>void 0!==e,i=e=>null!=e,s=new Set;function o(t){let n=t.$features;if(null!=e.Ot&&Array.isArray(n)){let t=n.filter(e=>!s.has(e));if(t.length>0)return e.Ot(t)}}function a(e,t){if(!s.has(e))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${t} needs the add-on @wcstack/state/features/${e}`)}var u=class{constructor(e,t,n){this.c=[],this.getter=null,this.ie=null,this.se=!1,this.B=[],this.Q=[],this.ft=null,this.P=-1,this.z=c,this.Ce=null,this.Ct=null,this.It=null,this._=null,this.pn=!1,this.mn=!1,this._n=!1,this.Z=0,this.pt=new Set,this.t=e,this.d=n,this.s=t;let r=null===n?[null]:n.h.slice(),l="*"===t;l&&r.push(n),this.n=r.length-1,this.q=l?[]:null===n?[t]:[...n.q,t],this.h=r}Wn(e){this.pt.has(e)||(this.pt.add(e),this.B.push(e),e.Q.push(this))}Io(e){this.pt.delete(e);let t=this.B;t.splice(t.indexOf(e),1)}Mo(){this.getter=null,this.ie=null,this.P=-1,this.z=c,this.B.length=0,this.pt.clear(),this.Q.length=0,this.ft=null,this.Ce=null,this.Ct=null,this.It=null,this._=null}ee(e){let t=this;for(;null!==t;){if(t===e)return!0;t=t.d}return!1}},c=Symbol("unset"),f=Symbol("dirty"),h=Symbol("failed"),d=class{constructor(e=null){this.mt=new Map,this.Vn=e}Mt(e){return this.mt.get(e)}get(e){let t=this.mt.get(e);if(void 0!==t)return t;let n=e.lastIndexOf("."),r=n<0?null:this.get(e.slice(0,n));return t=new u(e,e.slice(n+1),r),this.Vn?.(t),this.mt.set(e,t),r&&r.c.push(t),t}all(){return this.mt.values()}Dt(e){this.mt.delete(e.t)}},p=new Map;function m(e){let t=p.get(e);if(void 0!==t)return t;let n=!0,r=e.split("."),l=[];for(let e=0;e<r.length;e++){let t=r[e],i=t.charCodeAt(0);e>0&&i>=48&&i<=57?(n=!1,l.push(Number(t)),r[e]="*"):"*"===t&&l.push(-1)}if(!n)return{o:r.join("."),indexes:l};let i={o:e,indexes:null};return p.size>4095&&p.clear(),p.set(e,i),i}var g=class{constructor(e,t,n){this.ht=null,this.$=null,this.ye=null,this._=null,this.c=null,this.y=!0,this.l=e,this.w=t,this.R=n}},y=class{constructor(e,t){this.C=null,this.f=[],this.$=null,this.j=null,this.te=!1,this.jt=!1,this.yt=!1,this.o=e,this.ae=t,this.n=e.n+1}},b=[];function v(t,n,r){throw new Error(`[@wcstack/state] ${t}${e.jo?.(t,n,r)??""}`)}function $(t,n=[]){return e.Lo?.(t,n)??`#${t}${n.map(e=>` ${"string"==typeof e?JSON.stringify(e):String(e)}`).join("")}`}function w(e,t,n,r){v($(e,t),n,r)}var A=class{constructor(e){this.bt=new Set,this.name=e}get size(){return this.bt.size}subscribe(e){return this.bt.add(e),()=>{this.bt.delete(e)}}unsubscribe(e){return this.bt.delete(e)}emit(...e){let t=[];for(let n of this.bt)try{t.push(n(...e))}catch(e){t.push(void 0),console.error(`[@wcstack/state] ${$(17,[this.name])}`,e)}return t}};function k(e,t,n){if(void 0===e)return[];Array.isArray(e)||w(18,[t]);let r=new Set;for(let l of e)("string"!=typeof l||""===l)&&w(19,[t]),l===n&&w(20,[t,l,n]),r.has(l)&&w(21,[t,l]),r.add(l);return e}var x=Symbol.for("wcstack.transition-runner");function S(e){let t=globalThis[x];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run||"function"!=typeof t.accepts||!t.accepts(e)?null:t}function T(e,t,n){let r=S(e);if(null!==r)return r.run(t,{source:e,types:n});t()}var N="else",j="eventToken",O="command",C="class",M="attr",P="style",E=/^\$[1-9]\d{0,2}$/,W=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function R(e){let t=[],n=[],r="",l=null,i=!1,s=-1,o=-1,a=e=>{let l=function(e,t,n){let r=-1===t?e.length:t,l=-1===n?0:n;return e.slice(r-e.slice(0,r).trimStart().length,l+e.slice(l).trimEnd().length)}(r,s,o);(!e||l||i)&&(t.push(l),n.push(function(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:W.test(e)?Number(e):e)}(l,i))),r="",i=!1,s=-1,o=-1};for(let t=0;t<e.length;t++){let n=e[t];l?n===l?l=null:(-1===s&&(s=r.length),r+=n,o=r.length):'"'===n||"'"===n?(l=n,i=!0):","===n?a():r+=n}return null!==l&&w(107,[l,e]),a(!0),{args:t,literals:n}}var I=e=>e.trim();function D(e,t){let n=[],r=null;for(let l=0;l<e.length;l++){let i=e[l];null!==r?i===r&&(r=null):"'"===i||'"'===i?r=i:i===t&&n.push(l)}return n}var L=(e,t)=>D(e,t)[0]??-1;function q(e,t){let n=[],r=0;for(let l of D(e,t))n.push(e.slice(r,l)),r=l+1;return n.push(e.slice(r)),n}function z(e,t,n){let r=L(e,"|");if(-1===r)return[e.trim(),[]];let l=e.slice(r+1).trim(),i=n.get(l);return void 0===i&&(i=function(e,t,n){let r=n??e.join("|");return e.map(e=>{let n=L(e,"("),l=(e=>D(e,")").pop()??-1)(e);if(-1===l&&(l=e.lastIndexOf(")")),-1!==n&&-1===l&&w(108,[e]),-1!==l&&-1===n&&w(109,[e]),-1!==l&&l<n&&w(110,[e]),-1!==l&&e.slice(l+1).trim().length>0){let t=e.slice(l+1).trim();w(111,[e,t])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&w(112,[r]),i.includes("#")){let[,e]=i.split("#");w("input"===t?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...R(e.substring(n+1,l))}})}(q(l,"|").map(I),t,e),n.set(l,i)),[e.slice(0,r).trim(),i]}var F=new Map;function U(e){w(1101,[e])}function _(e){let[t,n]=z(e,"output",F);t.includes("@")&&w(32,[t]);let r=t,l=r.startsWith("."),i=l?r.slice(1):r;return(i.length>0&&i.split(".").some(e=>0===e.length)||!l&&0===i.length)&&w(119,[e]),function(e){e.includes("**")&&U(e);let t=e.split(".").length;t>512&&w(117,[e,t])}(r),{Qe:r,Ze:n}}var V=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],B=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function H(e){return e.includes("**")&&U(e),e}var K=0;function J(e,t,n){let r=e.get(t);return void 0===r&&e.set(t,r=n()),r}var Y=()=>new Set,G=()=>[];function X(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}function Q(e,t){return e===t||e!=e&&t!=t}function Z(e,t,n){let r=e._?.get(t);void 0!==r&&r.delete(n)&&0===r.size&&e._.delete(t)}function ee(e,t){for(let n=0;n<t.length;n++){if(null==e)return;e=e[t[n]]}return e}function te(e,t){for(;null!==e&&e.l.n>t;)e=e.l.ae;return null!==e&&e.l.n===t?e:null}function ne(e,t,n){let r=te(e,n);return null!==r&&r.l.o===t.h[n]?r:null}var re=class{constructor(e,t){this.Ie=0,this.u=null,this.Me=0,this.wt=new Set,this.et=new Map,this.Kn=Symbol("wcs.block"),this.element=null,this.vt=[],this.De=null,this.Un=[],this.Vt=0,this.Y=null,this.oe=new Map,this.ue=new Map,this.je=[],this.Le=[],this.Be=[],this.St=!1,this.hn=!1,this.Ht=new WeakMap,this.W=0,this.Kt=0,this.gn=!1,this.Ut=!1,this.qt=!1,this.Te=0,this.qn=()=>{this.W=0,this.gn=!1},this.zn=()=>{this.Te--},this.rp=null,this.rr=null,this.Bo=()=>this.zt(),this._o=(e,t)=>e(this.proxy,...t),this.Yn=[],this.tt=[],this.Wo={$untracked:e=>{let t=this.Y;if(null===t)return e();t.be++;try{return e()}finally{t.be--}},$eqIndex:(e,t=1)=>{let n=te(this.u,t);null===n&&w(7,[e]);let r=this.o(e);if(null!==r.getter||r.se)return this.watchIndex(t),n.w===this.read(r,null);let l=this.Y;if(null!==l){let e=l.getter,n=r.Ce??(r.Ce=[]);if(!n.some(n=>n.getter===e&&n.Xn===t)){n.push({getter:e,Xn:t});let l=e.h[t];(l.Ct??(l.Ct=[])).push({source:r,getter:e})}}return n.w===this.v(r,null)},$eq:(e,t)=>this.eq(e,t),$eqPath:(e,t)=>{let n=this.o(t);return this.eq(e,this.v(n,te(this.u,n.n)))},$dependOn:e=>{this.resolve(H(e),this.u),null!==this.Y&&0===this.Y.be&&this.Gn(this.rp,this.rr,this.Y)},$getAll:(e,t)=>this.getAll(e,t),$setAll:(e,t,n,r)=>this.yn(e,t,n,r),$resolve:(...e)=>{let t=H(e[0]),n=e[1]??[],r=this.o(t,!0);this.bn("$resolve",t,r,n,!0);let l=this.Jn(r,n,null);if(e.length<3)return this.read(r,l);this.A(r,l,e[2])},$postUpdate:e=>{this.resolve(H(e),this.u);let t=this.rp,n=this.rr;"*"===t.s&&null!==n&&(n.R=n.l.C[n.w],this.T.Yt(n)),this.wn(t,n),null!==n&&this.Qn(n,t,void 0,n.R,!1),0===t.n&&this.Zn(t,void 0,void 0,!0),this.Xt(t,n,void 0,void 0,!1)}},this.T=t,this.I=new d(e=>{this.tt.push(e),this.nt(e)}),this.eo(e);let n=this,r={getOwnPropertyDescriptor(e,t){let r=Reflect.getOwnPropertyDescriptor(n.target,t);return r&&(r.configurable=!0),r},get(e,t,r){let l=n.target;if("symbol"==typeof t)return Reflect.get(l,t);if(36===t.charCodeAt(0))return n.ot(t);if(t.indexOf(".")<0){let e=n.I.Mt(t);if(void 0===e||null===e.getter){let e=l[t];if("function"==typeof e)return r===n.proxy&&n.V?.(e)||e}if(void 0!==e&&0===e.n)return n.read(e,null)}return n.resolve(t,n.u),n.read(n.rp,n.rr)},set:(e,t,r)=>"symbol"==typeof t?Reflect.set(n.target,t,r):(n.resolve(H(t),n.u),n.A(n.rp,n.rr,r),!0)};for(let e of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])r[e]=(t,...r)=>Reflect[e](n.target,...r);this.proxy=new Proxy({},r)}o(e,t){let n=this.I.get(e);return t||(n.pn=!0),n}to(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n)){if(t.has(e))continue;t.add(e);let r=Object.getOwnPropertyDescriptor(n,e);if(void 0===r.get&&void 0===r.set)continue;let l=this.o(e);l.getter=r.get??null,l.ie=r.set??null,null!==l.getter&&l.n>0&&(l.P=this.Ie++)}for(let e of this.I.all())this.nt(e)}nt(e){e.t.includes("**")&&U(e.t),("__proto__"===e.s||"prototype"===e.s)&&w(120,[e.t]);let t=e.d;e.se=null!==t&&"*"!==e.s&&t.n===e.n&&(null!==t.getter||t.se),null===e.getter&&this.Vo(e)}Vo(e){let t=e.t,n=e.s;if(E.test(n))e.getter=function(){return this[n]};else{let r=t.split("."),l=r.findIndex((e,t)=>t>0&&e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57);if(l<0||r.indexOf("*",l)>=0)return;e.getter=()=>(this.resolve(t,this.u),this.rp!==e?this.read(this.rp,this.rr):this.read(e.d,this.u)?.[n]),e.ie=r=>{if(this.resolve(t,this.u),this.rp!==e)return this.A(this.rp,this.rr,r);let l=this.read(e.d,this.u);null==l&&w(4,[t,l]),l[n]=r}}e._n=!0,e.n>0&&(e.P=this.Ie++)}_e(e,t){let n=null===e?this.oe:e.c??=new Map,r=n.get(t);return void 0===r&&n.set(t,r=new y(t,e)),t.pn=!0,this.X(r),r}no(e){try{this.X(e)}catch(t){this.Gt(t,e.o.t,e.$?.S??null,"for")}}X(t){let n=this.v(t.o,t.ae);if(n===t.C)return;this.oo(t);let r=function(e,t,n){let r=Array.isArray(t)?t:b;if(r===e.C)return null;let l=e.f,i=r.length,s=l.length,o=new Array(i),a=0;for(;a<i&&a<s&&l[a].R===r[a];)o[a]=l[a],a++;let u=s-1,c=i-1;for(;u>=a&&c>=a&&l[u].R===r[c];)o[c]=l[u],u--,c--;if(a>u)for(let t=a;t<=c;t++)o[t]=new g(e,t,r[t]);else if(a>c)for(let e=a;e<=u;e++)n.Lt(l[e]);else{let t=u<c?u:c;for(let e=a;e<=t;e++)l[e].R===r[e]&&(o[e]=l[e]);let i=new Map;for(let e=u;e>=a;e--){let n=l[e];if(e<=t&&o[e]===n)continue;let r=i.get(n.R);void 0===r?i.set(n.R,n):Array.isArray(r)?r.push(n):i.set(n.R,[r,n])}for(let t=a;t<=c;t++){if(void 0!==o[t])continue;let n,l=r[t],s=i.get(l);void 0!==s&&(Array.isArray(s)?(n=s.pop(),0===s.length&&i.delete(l)):(n=s,i.delete(l))),o[t]=n??new g(e,t,l)}for(let e of i.values())if(Array.isArray(e))for(let t of e)n.Lt(t);else n.Lt(e)}for(let e=a;e<i;e++){let t=o[e];t.w!==e&&(t.w=e,n.Do(t))}return e.f=o,e.C=r,l}(t,n,this);if(null===r)return;if(t.C===n){let e=J(this.Ht,n,G);if(e.push(t),e.length>1)for(let t of e)t.yt=!0}e.Jt?.(this,t,r),(null!==t.$||null!==t.j)&&!t.te&&(t.te=!0,this.Le.push(t),this.Ae());let l=t.o.Ct;if(null!==l)for(let{source:e,getter:n}of l){let l=this.v(e,null),i=r[l],s=t.f[l];i!==s&&(void 0!==i&&i.y&&this.vn(n,i),void 0!==s&&this.vn(n,s))}}Do(e){this.T.Ho(this,e)}Lt(e){e.y=!1;let t=e._;if(null!==t){for(let e of t)Z(e.source,e.key,e.sub);e._=null}if(null!==e.c)for(let t of e.c.values()){this.oo(t);for(let e of t.f)this.Lt(e)}}oo(e){let t=this.Ht.get(e.C);void 0!==t&&(t.splice(t.indexOf(e)>>>0,1),e.yt=!1,1===t.length&&(t[0].yt=!1))}resolve(e,t){let n=m(e),r=this.rp=this.o(n.o,!0),l=n.indexes;this.rr=0===r.n?null:null===l?ne(t,r,r.n):this.Jn(r,l,t,e)}Jn(e,t,n,r){let l=null;for(let i,s=1,o=0;s<=e.n;s++){let a=e.h[s],u=this._e(l,a),c=t[o++];if(c<0)c=ne(n,e,s)?.w??-1;else if(r&&u.C===b&&Object(i=this.v(a,l))===i){let t=e.t.split("."),n=a.t.split(".").length;t[n]=r.split(".")[n],e=this.o(t.join("."),!0),s--;continue}if(l=u.f[c]??null,null===l)break}return this.rp=e,l}rt(e,t){return 0===e.n?ee(this.target,e.q):null===t?void 0:ee(t.R,e.q)}read(e,t){let n=this.Y;if(null!==n&&0===n.be&&this.Gn(e,t,n),null!==e.getter)return this.T.Ko(this,e,t);if(e.se){let n=this.read(e.d,t);return n?.[e.s]}return null===e.d&&!(e.s in this.target)&&!this.wt.has(e.s)&&"then"!==e.s&&"toJSON"!==e.s&&w(301,[e.t],e.s,Object.keys(this.target)),this.rt(e,t)}v(e,t){let n=this.Y;if(null===n)return this.read(e,t);n.be++;try{return this.read(e,t)}finally{n.be--}}Gn(e,t,n){let r=n.getter;e.Wn(r),0===r.n?e.Z!==n.de&&(e.Z=n.de,n.Sn.push(e)):e.n>0&&te(t,Math.min(e.n,r.n))!==te(n.r,Math.min(e.n,r.n))&&(r.ft??(r.ft=new Set)).add(e)}Uo(e,t){for(let n=0;n<this.Vt;n++){let r=this.Un[n];r.getter===e&&r.r===t&&w(701,[e.t])}this.Vt>=128&&w(801,[e.t]);let n=this.Vt++;this.Me++;let r=this.Un[n]??={getter:e,r:t,be:0,de:0,Sn:[]};r.getter=e,r.r=t,r.be=0,r.de=++K,r.Sn.length=0;let l=this.Y;this.Y=r;let i=this.u;this.u=t;try{let t=e.getter.call(this.proxy);return 0===e.n&&this.qo(e,r),t}finally{this.Me--,this.Vt--,this.Y=l,this.u=i,r.r=null}}qo(e,t){let n=t.de;for(let e of t.Sn)e.Z=n;e.Q=e.Q.filter(t=>t.Z===n||t.n>0||!t.se&&Array.isArray(null!==t.getter?t.z:this.rt(t,null))||this.io(t,e))}io(e,t){return e.Io(t),this.tt.push(e),!1}zo(){for(let e=this.tt;e.length>0;e=this.tt){this.tt=[];let t=new Set;for(let n of e)if(!(n.pn||n.mn||null===n.d||n.c.length>0||n.B.length>0)&&(null===n.getter||n._n&&n.P<0)&&null===n._){n.mn=!0,this.I.Dt(n),t.add(n.d);for(let e of n.Q)this.io(e,n)}for(let e of t)(e.c=e.c.filter(e=>!e.mn)).length||this.tt.push(e)}}watchIndex(e){let t=this.Y;if(null!==t&&0===t.be){let n=t.getter,r=n.h[e];if(r){let e=r.It??(r.It=[]);e.includes(n)||e.push(n)}}}ot(t){let n=t.charCodeAt(1);if(n>=48&&n<=57){let e=2===t.length?n-48:E.test(t)?+t.slice(1):0;return(e<1||e>128)&&w(1001,[t]),this.watchIndex(e),te(this.u,e)?.w}let r=this.Wo[t];if(void 0!==r)return r;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return e.ot?.(this,t)}eq(e,t){this.resolve(e,this.u);let n=this.rp,r=this.rr;if(null!==n.getter||n.se||n.n>0)return Q(this.read(n,r),t);let l=this.Y;return null!==l&&0===l.be&&this.Yo(n,t,l),Q(this.v(n,null),t)}Yo(e,t,n){let r=n.getter,l=n.r,i=null===l?this.Yn:l._??(l._=[]);for(let l=0;l<i.length;l++){let s=i[l];if(s.sub.getter===r&&s.source===e){if(Q(s.key,t))return void(s.de=n.de);s.de!==n.de&&(Z(e,s.key,s.sub),i.splice(l--,1))}}let s={getter:r,r:l};J(e._??=new Map,t,Y).add(s),i.push({source:e,key:t,sub:s,de:n.de})}Zn(e,t,n,r){this.Qt(e,l=>{let i=l._;if(null===i&&null===l.Ce)return;let s=l===e?[]:l.t.slice(e.t.length+1).split("."),o=ee(t,s),a=ee(n,s);if(null!==l.Ce&&this.Xo(l,o,a,r),null!==i)for(let e of r?i.keys():[o,a]){let t=i.get(e);if(void 0!==t)for(let n of t)null===n.r||n.r.y?this.T.we(this,n.getter,n.r):Z(l,e,n)}})}A(t,n,r,l=!1,i=!1){if(this.Me>0&&w(8),i||this.Te>0?this.Ut=!0:this.qt=!0,e.Pe?.(this,t,n,r,i))return;if(null!==t.ie){try{this.kn(t.ie,n,[r])}finally{this.Xt(t,n,void 0,void 0,!1)}return}null!==t.getter&&w(2,[t.t]),t.n>0&&null===n&&w(3,[t.t]);let s=t.se?this.v(t,n):this.rt(t,n);if(l||!this._t||!Object.is(s,r)||Object(r)===r){if("*"===t.s){let e=n;e.l.C[e.w]=r,e.R=r,this.T.Yt(e)}else{let e=1===t.q.length?0===t.n?this.target:n.R:this.v(t.d,n);null==e&&w(4,[t.t,e]),e[t.s]=r}this.En(t,n),null!==n&&this.Qn(n,t,s,r),0===t.n&&this.Zn(t,s,r),this.Xt(t,n,s,r,!0)}}so(e){return(this.Ht.get(e.C)??[]).filter(t=>t.C===e.C&&(null===t.ae||t.ae.y))}Qn(e,t,n,r,l=!0){let i=e.l;if(!i.yt&&null===i.o.getter&&!i.o.B.length)return;let s=e.R,o=t.t.slice(i.o.t.length+2),a=(t,i)=>{if(void 0===i||i===e)return;let s=this.o(`${t.o.t}.*${o}`,!0);""===o&&(i.R=r,this.T.Yt(i)),l?this.En(s,i):this.wn(s,i),this.Xt(s,i,n,r,l)};for(let t of this.so(i))a(t,t.f[e.w]);if(""===o)return;let u=new Set([i.C]),c=e=>Array.isArray(e)&&e.includes(s),h=(e,t)=>{if(!u.has(e)&&u.add(e))for(let t of this.Ht.get(e)??[])for(let e of t.f)e.R===s&&a(t,e);for(let n of t){let t=n.z,r=t===f;r&&(t=this.oe.get(n)?.C),(r||c(t))&&!u.has(n.B)&&u.add(n.B)&&(!r&&t!==e&&this.T.we(this,n,null),h(t,n.B))}},d=e=>{for(let t of e.Q)if(!u.has(t)&&u.add(t))if(null!==t.getter)d(t);else if(!t.se){let e=this.rt(t,null);c(e)&&h(e,t.B)}};null!==i.o.getter?d(i.o):h(i.C,i.o.B)}wn(e,t){this.Go(e,t,e=>{this.X(e);for(let t of e.yt?this.so(e):[e]){let e=this.o(`${t.o.t}.*`);for(let n of t.f)this.kt(e,n),this.wn(e,n)}})}En(e,t){let n=null===t?this.oe:t.c;if(null!==n)for(let t of n.values())t.o.ee(e)&&this.X(t)}Go(e,t,n){let r=null===t?this.oe:t.c;if(null!==r)for(let t of r.values())t.o.ee(e)&&n(t)}Xo(e,t,n,r){for(let{getter:l,Xn:i}of e.Ce)this.lo(l.h[i],e=>{for(let i of r?e.f.keys():[t,n]){let t="number"==typeof i?e.f[i]:void 0;void 0!==t&&this.vn(l,t)}})}vn(e,t){t.l.n===e.n?this.T.we(this,e,t):this.Zt(t,e,t=>this.T.we(this,e,t))}Xt(t,n,r,l,i){e.ve?.(this,t,n,r,l,i),this.We(t,n)}We(e,t){this.T.Jo(this,e,t),this.Ae()}ao(e){let t=this.et.get(e);if(void 0!==t)return t;let n=Symbol(`wcs.on${e}`);this.et.set(e,n);let r=this.root,l=this.Kn;return r.addEventListener(e,t=>{for(let i=t.target;null!==i&&i!==r;i=i.parentNode){let r=i[n];if(void 0!==r&&(r(t),t.cancelBubble))return;let s=i[l];if(void 0!==s&&s.y&&s.Qo(e,t))return}}),n}reset(t){let n=this.target,r=this.wt;for(let e of this.I.all())null===e.d&&null!==e.getter&&r.add(e.s);this.eo(t);for(let e in n)"$"!==e[0]&&r.add(e);for(let e of r)e in t&&r.delete(e);for(let e of this.ue.values())for(let t of e)this.en(t);for(let e of this.oe.values())this.co(e);this.De=null;try{this.zt()}finally{this.$n()}e.element?.(this,"reset")}eo(t){for(let[e,n]of V)void 0!==t[e]&&a(n,e);let n=t.$features;if(void 0!==n){Array.isArray(n)||w(46);for(let e of n)a(e,"$features")}let r=void 0===t.$behavior?{}:t.$behavior;("object"!=typeof r||!r||Array.isArray(r))&&w(44,["state","$behavior"]);for(let e in r)(!B.includes(e)||"boolean"!=typeof r[e])&&w(44,["$behavior",e]);let[l,i,s]=B.map(e=>r[e]??!0);void 0!==this.target&&(l!==this.Bt||i!==this._t||s!==this.Wt)&&w(45);let o=function(e,t){let n={};for(let r of k(e.$commandTokens,"$commandTokens","$command"))n[r]=t?.[r]??new A(r);return Object.freeze(n)}(t,this.commands),u=function(e,t){let n=new Map;for(let t of k(e.$eventTokens,"$eventTokens"))n.set(t,new A(t));let r=e.$on;if(void 0===r)return n;(null===r||"object"!=typeof r)&&w(22);for(let[e,l]of Object.entries(r)){let r=n.get(e);void 0===r&&w(23,[e]),"function"!=typeof l&&w(24,[e]),r.subscribe((...e)=>t(l,e))}return n}(t,this._o);this.Bt=l,this._t=i,this.Wt=s,e.fe?.(this,t),this.target=t,this.Ie=0;for(let e of this.I.all())e.Mo();this.Yn.length=0,this.to(t),this.commands=o,this.ce=u}co(e){this.no(e);let t=this.o(`${e.o.t}.*`);for(let n of e.f)if(n.ht=null,n._=null,this.kt(t,n),null!==n.c)for(let e of n.c.values())this.co(e)}H(e){let t=[];for(let n=e;null!==n;n=n.l.ae)t.unshift(n.w);return t}Zo(e,t,n){let r=this.ce.get(e);void 0===r&&w(1301,[e],e,this.ce.keys()),r.emit(t,...this.H(n))}command(e){let t=this.commands[e];return void 0===t&&w(1302,[e],e,Object.keys(this.commands)),t}er(e,t,n){this.command(e).emit(t,...this.H(n))}tr(e,t,n){let r=e.includes(".")?this.v(this.o(e),null):this.target[e];return"function"!=typeof r&&w(5,[e]),this.kn(r,n,[t,...this.H(n)])}kn(e,t,n){let r=this.u;this.u=t;try{return e.apply(this.proxy,n)}finally{this.u=r}}kt(e,t){if(null!==e.getter){let n=null===t?this.oe:t.c;if(null!==n)for(let t of n.values())!t.jt&&t.o.ee(e)&&(t.jt=!0,this.Be.push(t))}if(null===t)return void this.Qt(e,e=>{let t=this.ue.get(e);if(void 0!==t)for(let e of t)this.en(e)});let n=t.ye;if(null!==n)for(let t=0;t<n.length;t++)n[t].o.ee(e)&&this.en(n[t]);let r=t.$;null!==r&&null!==r.pe&&r.uo(this,e);let l=t.l.j;if(null!==l)for(let n of l){let r=n.map.get(t);void 0!==r&&null!==r.pe&&r.uo(this,e)}}xn(e,t,n){this.Qt(e,e=>{let r=e.B;for(let l=0;l<r.length;l++){let i=r[l];if(0===i.n)this.it(i,null,n);else if(null===t||0===e.n||i.h[1]!==e.h[1]||null!==i.ft&&i.ft.has(e))this.tn(i.h[i.n],e=>this.it(i,e,n));else if(i.n<=e.n){let e=te(t,i.n);null!==e&&this.it(i,e,n)}else this.Zt(t,i,e=>this.it(i,e,n))}})}it(t,n,r){r(t,n)&&(e.Se?.(this,t,n),this.kt(t,n),this.xn(t,n,r))}Qt(e,t){t(e);let n=e.c;for(let e=0;e<n.length;e++)this.Qt(n[e],t)}tn(e,t){this.lo(e,e=>{for(let n of e.f)t(n)})}lo(e,t){if(0===e.n){let n=this.oe.get(e);return void(void 0!==n&&t(n))}this.tn(e.h[e.n],n=>{let r=n.c?.get(e);void 0!==r&&t(r)})}Zt(e,t,n){if(e.l.n===t.n)return n(e);let r=e.c?.get(t.h[e.l.n+1]);if(void 0!==r)for(let e of r.f)this.Zt(e,t,n)}nr(e){let t=e.r;null===t?J(this.ue,e.o,Y).add(e):(t.ye??(t.ye=[])).push(e)}Nn(e){let t=e.r;if(null===t)return void this.ue.get(e.o)?.delete(e);let n=t.ye;t.y&&null!==n&&n.splice(n.indexOf(e)>>>0,1)}en(e){e.te||(e.te=!0,this.je.push(e),this.Ae())}Ae(){this.St||(this.St=!0,queueMicrotask(this.Bo))}Rn(){for(let e of this.je)e.te=!1;for(let e of this.Le)e.te=!1;for(let e of this.Be)e.jt=!1;this.je=[],this.Le=[],this.Be=[],this.T.wt(this)}fo(t,n){let r=[...new Set([...this.je,...this.Le,...this.Be].map(e=>e.o.t))];console.error(`[@wcstack/state] ${$(t)}`,r),e.st?.(this,{type:"state:render-chain-limit",maxDepth:n,paths:r}),this.Rn()}zt(){this.St=!1;let t=this.Kt;this.Kt=0;let n=0;if(!this.Ut||this.qt?this.qn():t>0?n=t:1===(n=++this.W)&&setTimeout(this.qn,0),this.Ut=this.qt=!1,n>100)101===n?this.fo(41,100):this.Rn();else{this.hn=!0;try{for(let e=0;this.je.length>0||this.Le.length>0||this.Be.length>0;e++){if(e>=32){this.gn?this.Rn():this.fo(11,32),this.gn=!0;break}let t=this.Be;if(t.length>0){this.Be=[];for(let e of t)e.jt=!1,this.no(e)}let r=this.Le,l=this.je;this.Le=[],this.je=[];let i=T("state",()=>{for(let e of r){e.te=!1;for(let t of[e.$,...e.j??[]])if(null!==t&&t.y)try{t.Et()}catch(n){this.Gt(n,e.o.t,t.S,"for")}}for(let e=0;e<l.length;e++){let t=l[e];t.te&&(t.te=!1,(null===t.Tn||t.Tn.y)&&this.Ve(t))}this.hn||(this.He(),this.St&&(this.Kt=n+1))});void 0!==i&&i.then(void 0,e=>console.error(e))}}finally{this.hn=!1}this.Ut=this.qt=!1,this.He(),e.Fe?.(this),this.zo(),t>0&&this.St&&(this.Kt=n+1)}}$t(e,t){this.vt.push([e,t])}Gt(e,t,n,r){this.$t(e,{o:{t},a:n,nn:()=>r})}Ve(e){try{e.apply()}catch(t){return void this.vt.push([t,e])}null!==this.De&&this.po(e.o,e.r)}po(e,t){let n=J(this.De,e.t,G);null!==t&&n.push(this.H(t))}$n(){this.De="function"==typeof this.target.$renderedCallback?new Map:null}He(){let t=this.De;if(null!==t&&t.size>0){this.De=new Map;let e,n=[...t.keys()],r={};for(let[e,n]of t)n.length>0&&(r[e]=n);this.Te++;try{e=this.ke("$renderedCallback",[n,r])}catch(e){console.error(e)}X(e)?e.then(this.zn,e=>{this.zn(),console.error(e)}):this.Te--}if(0===this.vt.length)return;let n=this.vt;this.vt=[];let r=this.target.$errorCallback;for(let[t,l]of n){e.Ke?.(this,t,l);let n=l.o.t,i=l.nn();if("function"==typeof r)try{let e=this.ke("$errorCallback",[t,{path:n,bindingType:i,node:l.a}]);X(e)&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}else console.error(`[@wcstack/state] ${$(12,[i,n])}`,t)}}ke(e,t=[]){let n=this.target[e];return"function"==typeof n?this.kn(n,null,t):void 0}mo(e,t,n){if(0===e.n)return void n(null,[]);let r=[],l=(i,s)=>{let o=e.h[i];this.read(o,s);let a=this._e(s,o),u=t=>{r.push(t.w),i===e.n?n(t,r):l(i+1,t),r.pop()};for(let e of i-1<t.length?[a.f[t[i-1]]]:a.f)void 0!==e&&u(e)};l(1,null)}getAll(e,t){let n=this.o(e,!0);void 0!==t&&this.bn("$getAll",e,n,t,!1);let r=t;if(void 0===r){r=[];let t=this.u;if(null!==t&&n.n>0){for(let e=1;e<=n.n;e++){let l=ne(t,n,e);if(null===l)break;r.push(l.w)}0===r.length&&w(6,[e])}}let l=[];return this.mo(n,r,e=>l.push(this.read(n,e))),l}yn(e,t,n,r){Array.isArray(t)||w(9,[e]),this.Me>0&&w(8);let l=this.o(e,!0);this.bn("$setAll",e,l,t,!1);let i=[];this.mo(l,t,(e,t)=>i.push([e,t.slice()]));let s=!0===r?.spread;s&&(!Array.isArray(n)||n.length!==i.length)&&w(10,[e,i.length]);let o=0;for(let e=0;e<i.length;e++){let[t,r]=i[e],a="function"==typeof n?n(this.v(l,t),...r):s?n[e]:n;void 0!==a&&(this.A(l,t,a),o++)}return o}bn(e,t,n,r,l){let i=r.length;(i>n.n||l&&i<n.n)&&w(l?901:902,[e,t,n.n,i])}},le={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1},ie=()=>le,se=new Map,oe=new Set(["if","elseif","else","for"]),ae=new Set([N,"if","elseif","for","..."]),ue=new Set([C,M,P,O,j,"state"]);function ce(e){let t=function(e){return q(e,";")}(e).map(I).filter(e=>e.length>0).map(e=>{let t=L(e,":");-1===t&&w(101,[e]);let n=e.slice(0,t).trim(),r=e.slice(t+1).trim(),l=n.split("#")[0].split("|")[0].trim();if(ae.has(l)){let t;return l!==n&&w(102,[e,l]),l===N?(r.length>0&&w(103,[e]),t={Qe:"#else",Ze:[]}):"..."===l?(0===r.length&&w(104,[e]),t=_(r),t.Ze.length>0&&w(105,[e])):(t=_(r),"for"===l&&t.Ze.length>0&&w(121,[e])),{Ee:l,$e:[l],on:[],M:[],...t,b:"..."===l?"spread":l}}let i=_(r),s=function(e){let[t,n]=z(e,"input",se),r=t.split("#").map(I);r.length>2&&w(115,[t]);let[l,i]=r,s=l.split(".").map(I);return!(s.length>1&&""===s[0])&&(0===l.length||s.some(e=>0===e.length))&&w(116,[e]),{Ee:l,$e:s,on:i?i.split(",").map(I):[],M:n}}(n),[o]=s.$e;if(""===o&&s.$e.length>1){let e=s.$e.slice(1);return(e.includes("")||ue.has(e[0]))&&w(106,[n]),{...s,Ee:e.join("."),$e:e,...i,b:"prop"}}return{...s,...i,b:"radio"===l||"checkbox"===l?l:o===j||o.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>oe.has(e.b))&&w(201,[e]),t}var fe=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],he=new Map,de=new Map;function pe(e){for(let t of Object.keys(e))he.set(t,{...e[t]});de.clear()}function me(e){return he.has(e)}function ge(e){w(26,[e])}function ye(e){w(27,[e])}function be(e){w(28,[e])}function ve(e){w(29,[e])}function $e(e){return!(!e||isNaN(Number(e)))}function we(e,t){return $e(e)||ye(t),Number(e)}function Ae(e,t,n){return we(e?.[t]??ge(n),n)}function ke(e,t){return void 0!==t&&t.length>0?t[0]:e}var xe=(e,t)=>({factory:n=>{let r=Ae(n,0,e);return n=>("number"!=typeof n&&be(e),t(n,r))},arity:[1,1]}),Se={eq:{factory:(e,t)=>{let n=e?.[0]??ge("eq"),r=ke(n,t);return e=>"number"==typeof e?"string"!=typeof r?e===r:($e(n)||ye("eq"),e===Number(n)):"string"==typeof e?e===n:e===r},arity:[1,1]},ne:{factory:(e,t)=>{let n=e?.[0]??ge("ne"),r=ke(n,t);return e=>"number"==typeof e?"string"!=typeof r?e!==r:($e(n)||ye("ne"),e!==Number(n)):"string"==typeof e?e!==n:e!==r},arity:[1,1]},not:{factory:()=>e=>!e,arity:[0,0]},lt:xe("lt",(e,t)=>e<t),le:xe("le",(e,t)=>e<=t),gt:xe("gt",(e,t)=>e>t),ge:xe("ge",(e,t)=>e>=t),falsy:{factory:()=>e=>!e,arity:[0,0]},truthy:{factory:()=>e=>!!e,arity:[0,0]},boolean:{factory:()=>e=>!!e,arity:[0,0]}},Te=!1;function Ne(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function je(e){return 0===e.length?null:(Te||(Te=!0,pe(Se)),e.map(e=>function(e,t,n){let r=`${e}${function(e,t){return`${JSON.stringify(e)}${JSON.stringify(t)}`}(t,n)}`,l=de.get(r);if(typeof l<"u")return l;let i=he.get(e);void 0===i&&function(e,t){fe.includes(e)&&v(`[wcs/filter-unknown] filter not found: ${e}. "${e}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,e,t),w(501,[e],e,t)}(e,he.keys());let[s,o]=i.arity;t.length<s&&w(601,[e,s,t.length]),t.length>o&&w(602,[e,o,t.length]);let a=i.factory(t,n);return de.set(r,a),a}(e.Hn,e.args,e.literals)))}var Oe=Symbol.for("wcstack.trustedTypes.policy");function Ce(){let e=globalThis[Oe];return null!==e&&"object"==typeof e?e:null}function Me(e){globalThis[Oe]=e}function Pe(e){return"innerHTML"===e||"outerHTML"===e||"srcdoc"===e}function Ee(e){if(globalThis.trustedTypes?.isHTML(e))return e;let t=null==e?"":String(e),n=Ce(),r=n?.createHTML;return"function"==typeof r?r.call(n,t):t}var We=Symbol.for("wcstack.state.view-transition-naming"),Re=new WeakSet;function Ie(){let e=S("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var De=new WeakMap,Le=e=>e.customElementRegistry??customElements;function qe(e,t,n,r,l,i=!1){let s=n.localName;if(!s.includes("-"))return l(null);let o=Le(n);if(!i&&!n.isConnected&&void 0===o.get(s)&&"customElementRegistry"in n)return void queueMicrotask(()=>qe(e,t,n,r,l,!0));let a=()=>{let e=o.get(s);o.upgrade(n),l(e?function(e){if(De.has(e))return De.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Set,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,ho:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.add(e.name);for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return De.set(e,n),n}(e):null)};if(!i&&void 0!==o.get(s))return a();null!==r&&!r.y||function(e,t,n){let r=n;null!==t&&(t.xt??=[]).push(()=>{r=null}),e.then(()=>r?.())}(o.whenDefined(s),r,()=>{try{a()}catch(r){Be(e,r,t,n)}e.Ae()})}function ze(t,n,r,l,i=n.o,s,o,a){let u=a.properties.get(l)??null,c=a.inputs.has(l),f=t.Wt;f&&null===u&&!c&&w(38,[l]);let h=n.K;(null===u?"element"===h||"auto"===h:!c&&("state"===h||"auto"===h))&&w(39,[h,l]),"connect"===n.X&&null===u&&w(40,[l]);let d=f&&null!==u&&!c,p=new Je(t,_e,r,l,i,s,o,n.x,void 0);p.M=n.M,nt(t,p,!d),null!==u&&!n.ro&&r.addEventListener(u.event,n=>{let i;null!==u.getter?i=u.getter(n):(i=n.detail,u.ho||e.detail?.(r,l,i)),(!p.An||!Object.is(i,p.value))&&(i=Ne(p.M,i),null===p.x&&(p.value=i),t.A(p.o,p.r,i,u.ho,!0))});let m=h??(d?"element":"state");if("state"===m)d||t.Ve(p);else if("element"===m||"auto"===m){let e=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==t.v(p.o,p.r))return void(d||t.Ve(p));let e=r[l];null===p.x&&(p.value=e),t.A(p.o,p.r,e,!1,!0)};"connect"!==n.X||r.isConnected?e():Promise.resolve().then(e)}return p}function Fe(e,t,n){w(e,[t.localName,n])}var Ue=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),_e=11,Ve=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],Be=(e,t,n,r)=>e.Gt(t,n.o?.t??n.Nt,r,Ve[n.i]),He=Symbol();function Ke(e,t,n){let r=t.K;return null===r||"state"===r||"auto"===r&&void 0!==e.v(t.o,n)?t.U:He}var Je=class{constructor(e,t,n,r,l,i,s,o,a,u=null){this.te=!1,this.M=null,this.An=!1,this.engine=e,this.i=t,this.a=n,this.name=r,this.o=l,this.r=i,this.Tn=s,this.x=o,this.value=a,this.W=u}nn(){return Ve[this.i]}apply(){if(null!==this.W)return void this.W.Et();let e=Ne(this.x,this.engine.read(this.o,this.r));if(e===this.value&&9!==this.i&&("object"!=typeof e||null===e||this.i===_e||8===this.i||Pe(this.name)))return;if(this.value===He)return void(this.value=e);let t=this.a;if(this.i!==_e)9===this.i?t.checked=void 0!==e&&this.rn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.rn()):Ge(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.An=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.An=!1}}}rn(){return Ne(this.M,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.rn()}else if(10===this.i){let r=this.rn(),l=n.v(this.o,this.r),i=Array.isArray(l)?l:[],s=i.includes(r);if(t.checked?s:!s)return;e=s?i.filter(e=>e!==r):[...i,r]}else e=Ne(this.M,t[this.name]),this.value=NaN;n.A(this.o,this.r,e,!1,!0)}},Ye=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Ge(e,t,n,r){switch(e){case 0:return void(t.data=null==r?"":String(r));case 1:return void(Ye(n)?t[n]="innerHTML"===n?Ee(r):null==r?"":String(r):Pe(n)?null==r&&"srcdoc"===n?t.removeAttribute(n):void 0!==r&&(t[n]=Ee(r)):void 0!==r&&(t[n]!==r&&!("value"===n&&t.value===String(r))&&(t[n]=r),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[Xe]=[n,r])));case 8:return void(t.innerHTML=Ee(r));case 2:return null!=r&&"boolean"!=typeof r&&w(401,[n,typeof r]),void t.classList.toggle(n,!0===r);case 3:return void(null==r?t.removeAttribute(n):t.setAttribute(n,String(r)));case 4:return void(n.includes("-")?null==r?t.style.removeProperty(n):t.style.setProperty(n,String(r)):t.style[n]=null==r?"":String(r))}}var Xe=Symbol();function Qe(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[Xe];void 0!==n&&(t[n[0]]=n[1])}var Ze=class{constructor(e,t,n,r){this.y=!0,this.ye=null,this.c=null,this.xt=null,this.Fn=null,this.r=e,this.Ue=t,this.D=n,this.F=r}Qo(e,t){let n=t.target,r=this.F,l=[],i=null;for(let t of r.ce){if(t.name!==e)continue;let s=r.On[t.a],o=ft(null===this.D?this.Ue:this.D[s[0]],s,1);o.contains(n)&&(o!==i&&l.unshift([]),l[0].push(t),i=o)}for(let e of l){for(let n of e)n.Pn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.D?this.Ue:this.D[this.D.length-1]}qe(){let e=this.Fn;return(null===e?null:e.Cn(this.Ue))??this.Ue}insertBefore(e,t){let n=this.s;for(let r=this.qe();;){let l=r.nextSibling;if(e.insertBefore(r,t),r===n)return;r=l}}bo(){null===this.D?this.Ue.remove():ht(this.qe(),this.s)}Ne(e){if(this.y=!1,null!==this.xt)for(let e of this.xt)e();let t=this.ye;if(null!==t)for(let n=0;n<t.length;n++)e.Nn(t[n]);if(null!==this.c)for(let e of this.c)e.Ne()}},et=class extends Ze{constructor(e,t,n,r){super(e,t,n,r),this.wo=0,this.V=null,this.pe=0===r.ze.length?null:new Array(2*r.ze.length)}vo(e,t){let n=this.V??=new Array(this.F.ze.length),r=n[t];if(void 0===r){let l=this.F.ze[t],i=this.pe;r=n[t]=new Je(e,l.i,i[2*t],l.name,l.o,this.r,this,l.x,i[2*t+1])}return r}uo(e,t){let n=this.F.ze;for(let r=0;r<n.length;r++)n[r].o.ee(t)&&e.en(this.vo(e,r))}Ne(e){let t=this.r;t.$===this&&(t.$=null),super.Ne(e)}};function tt(e,t,n,r){let l=te(n,t.n);try{return e._e(l,t)}catch(n){return e.Gt(n,t.t,r,"for"),null===l?e.oe.get(t):l.c.get(t)}}function nt(e,t,n){n&&e.nr(t);let r=t.Tn;null!==r&&(r.ye??=[]).push(t)}var rt=null;function lt(){let e=rt;return rt=null,e}var it=-1;function st(t,n,r,l,i=null){let s,o=n.On,a=n.build,u=n.So,c=null,f=e.Oe?.(n,null===l?i:l.S,null!==l),h=!f&&n.In,d=f?document.createDocumentFragment():(h?n.root:n.sn).cloneNode(!0);if(!f)for(let e=0;e<a.length;e++){let t=a[e];u[t]=ft(d,o[t],h?1:0)}h?s=d:(c=f||[...d.childNodes],s=c[0]);let p,m=null;if(null!==l?(p=m=new et(r,s,c,n),null===l.map?r.$=m:l.map.set(r,m)):p=new Ze(r,s,c,n),it>=0&&function(e,t,n,r){let l=null;if(null===t)l=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===l;e++)1===t[e].nodeType&&(l=t[e]);let i=l?.style;if(null===l||void 0===i||Re.has(l))return;let s=globalThis[We]??={counter:0,assigned:0,warned:!1};s.assigned>=r?s.warned||(s.warned=!0,console.warn(`[@wcstack/state] ${$(25,[r])}`)):(Re.add(l),s.assigned++,i.setProperty("view-transition-name",`wcs-${n}-${++s.counter}`),i.setProperty("view-transition-class",`wcs-${n}`))}(s,c,null!==l?"row":"branch",it),n.ce.length>0){let e=t.Kn;if(null===c)s[e]=p;else for(let t of c)1===t.nodeType&&(t[e]=p)}let g=n.sr,y=t.De,b=n.lr?u.slice(0,o.length):u,v=null===m?null:m.pe;if(null!==v){let e=n.ze;for(let t=0;t<e.length;t++)v[2*t]=b[e[t].a],v[2*t+1]=e[t].U}for(let e=0;e<g.length;e++){let n=g[e],l=b[n.a],i=n.P;if(i>=0&&null!==v){let e=m.V?.[i];if(void 0!==e){e.te=!1,t.Ve(e);continue}try{let e=Ne(n.x,t.read(n.o,r));e!==n.U&&(Ge(n.i,l,n.name,e),v[2*i+1]=e),null!==y&&t.po(n.o,r)}catch(e){t.$t(e,m.vo(t,i))}continue}switch(n.i){case 6:{let e=new ct(t,n.F,tt(t,n.o,r,l),l);(p.c??=[]).push(e),l===s&&(p.Fn=e),e.Et();break}case 7:{let e=at(t,n.G.map(e=>({F:e.F,o:e.o,x:e.x,S:b[e.a]})),r,p);(p.c??=[]).push(e),l===s&&(p.Fn=e);break}default:try{ot(t,n,l,r,p)}catch(e){Be(t,e,n,l)}}}return rt=p,d}function ot(t,n,r,l,i){let s=r;switch(n.i){case 5:return void function(e,t,n,r,l){let i=n.Pn,s=e=>i(e,r);if(n.et){let r=e.ao(n.name),l=t[r];t[r]=void 0===l?s:e=>{l(e),s(e)},n.xe&&t.addEventListener(n.name,e=>e.bubbles||s(e))}else t.addEventListener(n.name,s),n.yo&&null!==l&&(l.xt??=[]).push(()=>t.removeEventListener(n.name,s))}(t,r,n,l,i);case 12:return void qe(t,n,s,i,r=>function(t,n,r,l,i){let s=n.name,o=t.command(n.Nt.slice(9)),a=null===i?e.or?.(r,s):null;a||(null===i&&Fe(1202,r,`command.${s}`),i.commands.has(s)||w(1203,[r.localName,s]));let u=new WeakRef(r),c=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?a?a(t,e):t[s](...e):void 0;c()});null!==l&&(l.xt??=[]).push(c)}(t,n,s,i,r));case 13:return void qe(t,n,s,i,e=>function(e,t,n,r,l){let i=t.name;null===l&&Fe(1202,n,`eventToken.${i}`);let s=l.properties.get(i);void 0===s&&w(1204,[n.localName,i]);let o=t.Nt;n.addEventListener(s.event,n=>{t.Rt&&n.preventDefault(),t.Tt&&n.stopPropagation();try{e.Zo(o,n,r)}catch(e){console.error(e)}})}(t,n,s,l,e))}let o=n.o,a=te(l,o.n);if(14===n.i)return void qe(t,n,s,i,e=>function(e,t,n,r,l,i){null===i&&Fe(1501,n,`"...: ${t.o.t}"`);let s=new Set([...i.properties.keys(),...i.inputs]);for(let o of s){if(t.go?.includes(o))continue;let s=e.o(`${t.o.t}.${o}`),a=0===s.n?null:r;ze(e,{...t,K:null,X:null},n,o,s,a,l,i)}}(t,n,s,a,i,e));if(n.xe&&1===n.i)return void qe(t,n,s,i,r=>function(t,n,r,l,i,s){if(null!==s)return void ze(t,n,r,n.name,n.o,l,i,s);let o=new Je(t,1,r,n.name,n.o,l,i,n.x,Ke(t,n,l));o.M=n.M,!e.ar?.(o,n.ro)&&(nt(t,o,!0),t.Ve(o))}(t,n,s,a,i,r));let u=new Je(t,n.i,r,n.name,o,a,i,n.x,Ke(t,n,a));u.M=n.M,nt(t,u,!0),t.Ve(u),null!==n.At&&r.addEventListener(n.At,()=>u.ir())}function at(e,t,n,r){let l=new ut(e,t,n),i=null;for(let s of t){if(null===s.o)continue;let t=s.o,o=new Je(e,7,s.S,"if",t,te(n,t.n),r,null,void 0,l);nt(e,o,!0),null===r&&l.ue.push(o),i??=o}return e.Ve(i),l}var ut=class{constructor(e,t,n){this.y=!0,this.O=null,this.w=-1,this.ue=[],this.engine=e,this.G=t,this.r=n}Cn(e){return null!==this.O&&this.G[this.w].S===e?this.O.qe():null}Et(){let e=this.engine,t=-1;for(let n=0;n<this.G.length;n++){let r=this.G[n];if(null===r.o||Ne(r.x,e.read(r.o,te(this.r,r.o.n)))){t=n;break}}if(t!==this.w&&(it=Ie(),null!==this.O&&(this.O.bo(),this.O.Ne(e),this.O=null),this.w=t,t>=0)){let n=this.G[t],r=st(e,n.F,this.r,null,n.S);this.O=lt();let l=n.S.parentNode;l.insertBefore(r,n.S),Qe(l)}}Ne(){this.y=!1;for(let e of this.ue)this.engine.Nn(e);null!==this.O&&this.O.Ne(this.engine)}},ct=class{constructor(e,t,n,r){this.y=!0,this.Re=[],this.engine=e,this.F=t,this.l=n,this.S=r,null===n.$?(n.$=this,this.map=null):((n.j??=[]).push(this),this.map=new Map)}Cn(e){return 0===this.Re.length?null:this.Re[0].qe()}Pt(e){return null===this.map?e.$:this.map.get(e)??null}Dt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Ne(this.engine)}Et(){let e=this.engine,t=this.l.f,n=this.Re;it=Ie();let r=t.length,l=n.length,i=this.S,s=i.parentNode;if(0===r){if(l>0){let e=n[0].qe(),t=n[l-1].s,r=[];for(let n=s.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==i&&3!==n.nodeType){r=null;break}r.push(n)}null!==r?s.replaceChildren(...r):ht(e,t);for(let e=0;e<l;e++)this.Dt(n[e])}return void(this.Re=[])}let o=new Array(r),a=0;for(;a<r&&a<l&&this.Pt(t[a])===n[a];)o[a]=n[a],a++;let u=l-1,c=r-1;for(;u>=a&&c>=a&&this.Pt(t[c])===n[u];)o[c]=n[u],u--,c--;for(let e=a;e<=u;e++){let t=n[e],r=t.r;r.y&&this.Pt(r)===t?t.wo=e:(t.bo(),this.Dt(t))}if(a<=c){let n=c-a+1,u=new Int32Array(n),f=!1;if(l>0)for(let e=0;e<n;e++){let n=this.Pt(t[a+e]);null!==n&&n.y?(u[e]=n.wo,f=!0):u[e]=-1}let h=c+1<r?o[c+1].qe():i;if(f){let r=function(e){let t=e.length,n=new Uint8Array(t),r=new Int32Array(t).fill(-1),l=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let i=0,s=l.length;for(;i<s;){let n=i+s>>1;e[l[n]]<t?i=n+1:s=n}i>0&&(r[n]=l[i-1]),l[i]=n}let i=l.length>0?l[l.length-1]:-1;for(;i>=0;)n[i]=1,i=r[i];return n}(u),l=h;for(let i=n-1;i>=0;i--){let n=t[a+i],u=this.Pt(n);null!==u&&u.y?0===r[i]&&u.insertBefore(s,l):(s.insertBefore(st(e,this.F,n,this),l),u=lt()),o[a+i]=u,l=u.qe()}}else{let n=document.createDocumentFragment();for(let r=a;r<=c;r++)n.appendChild(st(e,this.F,t[r],this)),o[r]=lt();s.insertBefore(n,h)}}this.Re=o,Qe(s)}Ne(){this.y=!1;let e=this.l;if(e.$===this)e.$=null;else if(null!==e.j){let t=e.j.indexOf(this);t>=0&&e.j.splice(t,1),0===e.j.length&&(e.j=null)}for(let e of this.Re)e.Ne(this.engine);this.map?.clear()}};function ft(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let r=t[n];r>0;r--)e=e.nextSibling}return e}function ht(e,t){for(let n,r=e;r!==t;r=n)n=r.nextSibling,r.remove();t.remove()}var dt=()=>le.bindAttributeName;function pt(){return{a:0,i:1,name:"",o:null,x:null,U:c,Pn:null,F:null,G:null,M:null,At:null,xe:!1,K:null,X:null,ro:!1,Rt:!1,Tt:!1,Nt:null,go:null,P:-1,et:!1,yo:!1}}var mt=["state","element","auto","none"],gt=["call","connect"],yt="$command.";function bt(t,n,r){E.test(n)&&(null===r&&w(1401,[n,Number(n.slice(1))]),n=`${r.t}.*.${n}`);let l=t.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&w(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(n,r)),i=null===r?0:r.n+1;l.n>i&&w(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?r:r.h[e];l.h[e]!==t&&w(1403,[l.t,l.h[e].t,t.t])}return e.ko?.(t,l),l}var vt=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),$t=e=>8===e.i||vt(e)||1===e.i&&Ye(e.name);function wt(e){w(202,[e])}function At(e,t,n,r,l){let i=ce(t).map(t=>function(e,t,n,r,l){let i=function(e,t){let n=t.find(e=>e.startsWith("on")),r=null,l=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Wt||w(31);let i=n.slice(0,t).trim(),s=n.slice(t+1).trim(),o="init"===i;!o&&"sync"!==i&&w(33,[i,n]),null!==(o?r:l)&&w(34,[i]),(o?mt:gt).includes(s)||w(35,[i,s]),o?r=s:l=s}return{ro:t.includes("ro"),Rt:t.includes("prevent"),Tt:t.includes("stop"),event:n?n.slice(2):null,K:r,X:l}}(e,t.on),s=r.localName.includes("-"),o=t.$e,a=t.Qe;if("event"===t.b){if(null!==i.K&&"none"!==i.K&&w(36),"eventToken"===o[0])return{...pt(),a:l,i:13,name:o.slice(1).join("."),Nt:a,xe:s,Rt:i.Rt,Tt:i.Tt};let n=a.startsWith(yt)?a.slice(9):null,{Rt:r,Tt:u}=i,c=t.Ee.slice(2),f=t.on.includes("direct"),h=!f&&Ue.has(c);return h&&e.ao(c),{...pt(),a:l,i:5,name:c,et:h,xe:s,yo:f,Pn(t,l){r&&t.preventDefault(),u&&t.stopPropagation();try{if(null!==n)e.er(n,t,l);else{let n=e.tr(a,t,l);X(n)&&n.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.b)return{...pt(),a:l,i:14,o:bt(e,a,n),xe:s};if("command"===o[0]&&o.length>1)return a.startsWith(yt)||w(1201,[t.Ee,a]),{...pt(),a:l,i:12,name:o.slice(1).join("."),Nt:a,xe:s};let u=bt(e,a,n),c={...pt(),a:l,i:1,name:t.Ee,o:u,x:je(t.Ze),M:je(t.M),ro:i.ro,K:i.K,X:i.X};if("radio"===t.b||"checkbox"===t.b)return("element"===i.K||"auto"===i.K)&&w(37,[t.b,i.K]),c.i="radio"===t.b?9:10,i.ro||(c.At=i.event??"input"),c;if(o.length>1){let e=o.slice(1).join("."),t=o[0];if("class"===t||"attr"===t||"style"===t)return c.K=null,c.name=e,"class"===t?(c.i=2,c.U=r.classList.contains(e)):c.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,c}return"html"===t.Ee?(c.i=8,c):(c.name="text"===t.Ee?"textContent":t.Ee,c.xe=s&&!Pe(c.name),!s&&!i.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(r,c.name)&&(c.At=i.event??("select"===r.localName?"change":"input")),c)}(e,t,n,r,l));for(let e=0;e<i.length;e++)14===i[e].i&&(i[e].go=i.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return i}var kt=/\{\{([\s\S]+?)\}\}/g;function xt(e){let t=e.data,n=[],r=0;kt.lastIndex=0;for(let l=kt.exec(t);null!==l;l=kt.exec(t)){let i=kt.lastIndex-l[0].length;i>r&&e.before(t.slice(r,i));let s=e.ownerDocument.createTextNode("");e.before(s),n.push({a:s,cr:l[1].trim()}),r=kt.lastIndex}return 0===n.length||(r<t.length&&e.before(t.slice(r)),e.remove()),n}function St(e,t,n,r){let l=function(e){return{Ee:"textContent",$e:["textContent"],on:[],M:[],..._(e),b:"text"}}(t);return{...pt(),a:r,i:0,o:bt(e,l.Qe,n),x:je(l.Ze),U:""}}function Tt(e){let t=e.getAttribute(dt());if(null===t)return null;let n=ce(t)[0];return void 0===n||"for"!==n.b&&"if"!==n.b&&"elseif"!==n.b&&"else"!==n.b?null:n}var Nt=(e,t)=>0===e?le.commentIfPrefix:null===t.o?le.commentElsePrefix:le.commentElseIfPrefix;function jt(e,t,n){let r=(t,r)=>({el:t,o:"else"===r.b?null:bt(e,r.Qe,n),x:"else"===r.b?null:je(r.Ze)}),l=[r(t,Tt(t))];for(let e=t.nextSibling;null!==e;e=e.nextSibling){if(3===e.nodeType&&""===e.data.trim()||8===e.nodeType)continue;if(1!==e.nodeType||"template"!==e.localName)break;let t=Tt(e);if(null===t||"elseif"!==t.b&&"else"!==t.b||(l.push(r(e,t)),"else"===t.b))break}return l}var Ot=new WeakSet;function Ct(t,n,r,l,i,s,o,a){let u=(n,r)=>{let i=document.createComment(r);return n.replaceWith(i),l&&e.Mn?.(t,i,n),i},c=n=>{for(let f=0;f<n.length;f++){let h=n[f];if(null!==h.parentNode)if(1===h.nodeType){let n=h,a=n.localName;if(l){if("script"===a||"style"===a||Ot.has(n))continue;if(Ot.add(n),a===le.tagNames.state){c([...n.childNodes]);continue}}let f="template"===a?Tt(n):null;if(null!==f){if("for"===f.b){let e=bt(t,f.Qe,r),l=Et(t,n,e,!0);i(u(n,le.commentForPrefix),e,l)}else"if"===f.b?s(jt(t,n,r).map((e,n)=>({F:Et(t,e.el,r,!1),o:e.o,x:e.x,S:u(e.el,Nt(n,e))}))):wt(f.b);continue}let d=n.getAttribute(dt()),p=null===d?null:At(t,d,r,n,0),m="noscript"!==a&&"iframe"!==a&&!p?.some($t)&&!e.Eo?.(n);try{l&&m&&c([...n.childNodes])}finally{null!==p&&o(n,p)}!l&&m&&c([...n.childNodes])}else if(3===h.nodeType&&t.Bt&&h.data.includes("{{")&&!Ot.has(h))for(let{a:e,cr:t}of xt(h))a(e,t);else if(8===h.nodeType){let e=Mt.exec(h.data),t=e&&h.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");h.replaceWith(t),a(t,e[1])}}}};c(n)}var Mt=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Pt=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Et(e,t,n,r){let l=document.importNode(Pt(t),!0),i=[],s=[],o=e=>i.push(e)-1;Ct(e,[...l.childNodes],n,!1,(e,t,n)=>{s.push({...pt(),a:o(e),i:6,o:t,F:n})},e=>{let t=e.map(e=>({a:o(e.S),F:e.F,o:e.o,x:e.x}));s.push({...pt(),a:t[0].a,i:7,G:t})},(e,t)=>{let n=o(e);for(let e of t)vt(e)&&w(203,[e.name]),e.a=n;s.push(...t),e.removeAttribute(dt())},(t,r)=>{s.push(St(e,r,n,o(t)))}),Dt(l,new Set(i),!0);let a=i.map(e=>function(e,t){let n=[];for(let r=t;r!==e;r=r.parentNode){let e=0;for(let t=r.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(l,e)),u=1===l.childNodes.length&&8!==l.firstChild.nodeType,c=s.some(e=>6===e.i||7===e.i),f=[],h=new Set,d=[],p=[],m=r?n.n+1:-1;for(let e of s){if(5===e.i&&e.et&&!e.xe&&!Wt(i[e.a],l)){d.push(e);continue}p.push(e);let t=e.o;if(null!==t&&t.n===m&&t.h[m]===n&&Rt(e)&&(e.P=f.push(e)-1),7===e.i)for(let t of e.G)h.add(t.a);else h.add(e.a)}let g=[...h].sort((e,t)=>e-t);return{sn:l,root:u?l.firstChild:null,On:a,build:g,ce:d,sr:p,In:u,lr:c,So:[],ze:f}}function Wt(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Rt(e){if(null!==e.K)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.xe&&null===e.At;default:return!1}}var It=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Dt(e,t,n){for(let r=e.firstChild;null!==r;){let e=r.nextSibling;3===r.nodeType?n&&!t.has(r)&&""===r.data.trim()&&r.remove():1===r.nodeType&&Dt(r,t,It.has(r.localName)),r=e}}var Lt=new WeakMap;function qt(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Lt.set(t,e),Ft(e,[...n.childNodes]),e.He()}function zt(e,t,n){try{let r="template"===t.localName?Tt(t):null;null!==r&&!n&&w(204,[r.b]),Ft(e,[t])}catch(e){console.error(e)}e.He()}function Ft(t,n){Ct(t,n,null,!0,(e,n,r)=>{new ct(t,r,tt(t,n,null,e),e).Et()},e=>{at(t,e,null,null)},(n,r)=>{e.Mn?.(t,n,r);for(let e of r)ot(t,e,n,null,null)},(n,r)=>{e.Mn?.(t,n,r),ot(t,St(t,r,null,0),n,null,null)})}var Ut=Symbol.for("wcstack.binder"),_t=Symbol.for("wcstack.binder.pending"),Vt=Symbol.for("wcstack.binder.taken");var Bt=new Map;function Ht(e,t){if(1!==e.nodeType||!e.isConnected)return;let n=Lt.get(e.getRootNode());void 0===n||!1===n.element?.isConnected?Bt.set(e,t):zt(n,e,t?.range)}function Kt(){let e=[...Bt];Bt.clear();for(let[t,n]of e)Ht(t,n);!function(){let e=function(){let e=globalThis[Ut];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;let t=function(){let e=globalThis,t=e[_t];return void 0===t&&(t=[],e[_t]=t),t}();if(0===t.length)return;let n=t.splice(0,t.length),r=function(){let e=globalThis,t=e[Vt];return void 0===t&&(t=new WeakSet,e[Vt]=t),t}();for(let t of n)r.add(t),e.bind(t)}()}var Jt=class{constructor(){this.name="dirty",this.Z=(e,t)=>{if(0===e.n){let t=e.z;return t!==c&&t!==f&&(e.z=f,!0)}let n=null===t?null:t.ht;if(null===n)return!1;let r=n[e.P];return r!==c&&r!==f&&(n[e.P]=f,!0)}}Jo(e,t,n){null!==t.getter&&this.Z(t,n),e.kt(t,n),e.xn(t,n,this.Z)}Ho(e,t){let n=t.l.o.It;if(null!==n)for(let r of n)r.n===t.l.n?e.it(r,t,this.Z):e.Zt(t,r,t=>e.it(r,t,this.Z))}we(t,n,r){this.Z(n,r),e.Se?.(t,n,r),t.kt(n,r),t.xn(n,r,this.Z)}Ko(e,t,n){let r=0===t.n;if(!r&&null===n)return;let l=r?null:n.ht??=new Array(e.Ie).fill(c),i=null===l?t.z:l[t.P];if(i!==c&&i!==f&&i!==h&&(null===l||t.P in l))return i;i=h;try{return i=e.Uo(t,null===l?null:n)}finally{null===l?t.z=i:l[t.P]=i}}Yt(e){e.ht=null}wt(e){for(let t of e.I.all())null!==t.getter&&(0===t.n?t.z===f&&(t.z=h):e.tn(t.h[t.n],e=>{let n=e.ht;null!==n&&n[t.P]===f&&(n[t.P]=h)}))}},Yt=0,Gt=new WeakMap;function Xt(e,t=e.getRootNode()){Gt.set(t,[...Gt.get(t)??[],e].filter((e,t,n)=>e.isConnected&&n.lastIndexOf(e)===t))}function Qt(e){let t=Gt.get(e)??[],n=t.filter(t=>t.getRootNode()===e);return Promise.any(n.map(e=>e.initializePromise.then(()=>e.V||e.connectedCallbackPromise))).then(()=>{},r=>n.length?Gt.get(e)!==t?Qt(e):Promise.reject(r.errors[0]):void 0)}var Zt=typeof HTMLElement>"u"?class{}:HTMLElement,en=class extends Zt{constructor(){super(),this.engine=null,this.Dn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((e,t)=>{this.an=e,this.$o=t}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(e=>{this.ln=e})}static{this.getBindingsReady=Qt}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Dn){if(null!==this.Ye)return void this.Ye.Xe();Xt(this);let t=this.engine;if(null!==t){let n=t.root;n===this.getRootNode()&&!Lt.has(n)&&Lt.set(n,t),Kt(),e.element?.(t,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&e.element?.(t,"connected")})}return}this.Dn=!0;let t=this.getRootNode(),n=e.at?.(this,t);if(n)return this.Ye=n,!n.No&&this.parentNode instanceof ShadowRoot&&Xt(this),void(void 0===n.Ot?this.Ro():n.Ot()).then(e=>(this.loaded=!0,n.start(e,()=>this.To()))).then(()=>{this.ln(),this.an()},e=>this.$t(e,n.No));this.start(t),Xt(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.jn();let t=this.engine;if(null===t)return;let n=t.root;Lt.get(n)===t&&Lt.delete(n),Xt(this,n),this.xo("$disconnectedCallback",51),e.element?.(t,"disconnected")}setInitialState(e){if(this.Ke&&w(14),this.loaded)this.Ye.reset(e);else if(null===this.engine)if(null!==this.cn){let t=this.cn;this.cn=null,t(e)}else this.U=e;else this.engine.reset(e)}createState(e,t){let n=this.engine;null===n&&w(15),"readonly"===e&&n.Me++;try{t(n.proxy)}finally{"readonly"===e&&n.Me--}}async createStateAsync(e,t){let n=this.engine;null===n&&w(15),await t("writable"===e?n.proxy:new Proxy(n.proxy,{get(e,t,n){let r=Reflect.get(e,t,n);return"$setAll"===t||"$resolve"===t?(...e)=>(e.length>2&&w(8),r(...e)):r},set(){w(8)}}))}async Ro(){await 0;let e=this.getAttribute("state");if(null!==e){let t=t=>[...t.querySelectorAll('script[type="application/json"]')].find(t=>t.id===e),n=t(this.getRootNode())??t(document);return void 0===n?Promise.reject(new Error(`[@wcstack/state] ${$(16,[e])}`)):Promise.resolve(JSON.parse(n.textContent||"{}"))}let t=this.getAttribute("src");if(null!==t)return async function(e){let t=new URL(e,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(t)){let n=await fetch(t);return n.ok||w(13,[e,n.status]),await n.json()}return(await(import(t))).default??{}}(t);let n=this.getAttribute("json");if(null!==n)return Promise.resolve(JSON.parse(n));let r=this.querySelector('script[type="module"]');return null!==r?async function(e){let t=!1,n=e=>{e.effectiveDirective.startsWith("script-src")&&(t=!0)};document.addEventListener("securitypolicyviolation",n);let r="function"==typeof URL.createObjectURL,l=r?URL.createObjectURL(new Blob([e.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${e.text}\n//${++Yt}`);try{return(await(import(l))).default??{}}catch(e){throw await new Promise(e=>setTimeout(e)),new Error(`[@wcstack/state] ${t?$(42):$(43,[e instanceof Error?e.message:String(e)])}`,{cause:e})}finally{document.removeEventListener("securitypolicyviolation",n),r&&URL.revokeObjectURL(l)}}(r):null!==this.U?Promise.resolve(this.U):new Promise(e=>{this.cn=e})}async start(t){try{let n=t.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||n?.hasAttribute("data-wc-definition"))&&a("scopes","<wcs-state>");let r=await this.Ro(),l=o(r);if(l&&await l,this.getRootNode()!==t)return this.U=r,this.Dn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&a("ssr","enable-ssr");let i=Lt.get(t)?.element;i?.isConnected&&(i.V||i.Ye)&&w(47);let s=new re(r,new Jt);s.element=this,this.engine=s,e.element?.(s,"mounting"),qt(s,t),Kt(),s.$n(),this.To(),await s.ke("$connectedCallback"),this.isConnected&&e.element?.(s,"connected"),this.an()}catch(e){this.Ke=!this.V,this.$t(e)}}To(){this.V=!0,this.ln()}$t(e,t){this.He(this.V?50:49,e),this.ln(),t?this.an():this.$o(e)}He(e,t){let n=["mount","bind-component","state","src"].flatMap(e=>this.hasAttribute(e)?[e,this.getAttribute(e)]:[]);console.error(`[@wcstack/state] ${$(e,[this.localName,...n])}`,t)}xo(e,t,n){(async()=>this.engine.ke(e))().then(n,e=>this.He(t,e))}},tn=[];function nn(){return(tn=tn.filter(e=>e.deref())).map(e=>e.deref())}function rn(t,n){t&&function(e){let t=le,n=le.tagNames,r=Object.entries(e).filter(([,e])=>void 0!==e),l=Object.entries(e.tagNames??{}).filter(([,e])=>void 0!==e);for(let[e,n]of r){let r=t[e];(!Object.hasOwn(t,e)||null===n||typeof n!=typeof r||Array.isArray(n)!==Array.isArray(r))&&w(44,["bootstrapState",e])}for(let[e,t]of l)(!Object.hasOwn(n,e)||"string"!=typeof t)&&w(44,["bootstrapState",`tagNames.${e}`]);for(let[e,n]of r)"tagNames"!==e&&(t[e]=n);for(let[e,t]of l)n[e]=t}(t),function(t=customElements){(function(){let e=globalThis;void 0===e[Ut]&&(e[Ut]={protocol:"wcs-binder",version:1,bind:Ht})})(),nn().includes(t)||tn.push(new WeakRef(t));let n=le.tagNames.state;void 0===t.get(n)&&t.define(n,class extends en{}),e.Ao?.(t)}(n)}var ln,sn=e=>Qt(e),on=e=>t=>{let n=e(t);return e=>null==e?e:n(e)},an="en";function un(){if(le.locale!==ln){ln=le.locale;try{an=Intl.getCanonicalLocales(ln)[0]}catch{console.warn(`[@wcstack/state] ${$(48,[ln])}`),an="en"}}return an}var{eq:cn,ne:fn,not:hn,lt:dn,le:pn,gt:mn,ge:gn,falsy:yn,truthy:bn,boolean:vn}=Se,$n={toFixed:{factory:e=>{let t=we(e?.[0]??"0","toFixed");return e=>("number"!=typeof e&&be("toFixed"),e.toFixed(t))},arity:[0,1]},locale:{factory:e=>{let t=e?.[0];return e=>("number"!=typeof e&&be("locale"),e.toLocaleString(t??un()))},arity:[0,1]},upper:{factory:on(()=>e=>String(e).toUpperCase()),arity:[0,0]},lower:{factory:on(()=>e=>String(e).toLowerCase()),arity:[0,0]},capitalize:{factory:on(()=>e=>{let t=String(e);return 0===t.length?t:1===t.length?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}),arity:[0,0]},trim:{factory:on(()=>e=>String(e).trim()),arity:[0,0]},slice:{factory:on(e=>{let t=[Ae(e,0,"slice")],n=e?.[1];return typeof n<"u"&&t.push(we(n,"slice")),e=>String(e).slice(...t)}),arity:[1,2]},padStart:{factory:on(e=>{let t=Ae(e,0,"padStart"),n=e?.[1]??"0";return e=>String(e).padStart(t,n)}),arity:[1,2]},padEnd:{factory:on(e=>{let t=Ae(e,0,"padEnd"),n=e?.[1]??" ";return e=>String(e).padEnd(t,n)}),arity:[1,2]},repeat:{factory:on(e=>{let t=Ae(e,0,"repeat");return e=>String(e).repeat(t)}),arity:[1,1]},reverse:{factory:on(()=>e=>String(e).split("").reverse().join("")),arity:[0,0]},truncate:{factory:on(e=>{let t=Ae(e,0,"truncate"),n=e?.[1]??"…";return e=>{let r=String(e);return r.length<=t?r:r.slice(0,t)+n}}),arity:[1,2]},join:{factory:e=>{let t=e?.[0]??", ";return e=>(Array.isArray(e)||w(30,["join"]),e.join(t))},arity:[0,1]},round:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","round"));return e=>("number"!=typeof e&&be("round"),Math.round(e*t)/t)},arity:[0,1]},floor:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","floor"));return e=>("number"!=typeof e&&be("floor"),Math.floor(e*t)/t)},arity:[0,1]},ceil:{factory:e=>{let t=Math.pow(10,we(e?.[0]??"0","ceil"));return e=>("number"!=typeof e&&be("ceil"),Math.ceil(e*t)/t)},arity:[0,1]},percent:{factory:e=>{let t=we(e?.[0]??"0","percent");return e=>("number"!=typeof e&&be("percent"),`${(100*e).toFixed(t)}%`)},arity:[0,1]},unit:{factory:on(e=>{let t=e?.[0]??ge("unit");return e=>String(e)+t}),arity:[1,1]},date:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("date"),e.toLocaleDateString(t??un()))},arity:[0,1]},time:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("time"),e.toLocaleTimeString(t??un()))},arity:[0,1]},datetime:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ve("datetime"),e.toLocaleString(t??un()))},arity:[0,1]},ymd:{factory:e=>{let t=e?.[0]??"-";return e=>{e instanceof Date||ve("ymd");let n=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),l=e.getDate().toString().padStart(2,"0");return`${n}${t}${r}${t}${l}`}},arity:[0,1]},hms:{factory:e=>{let t=e?.[0]??":";return e=>{e instanceof Date||ve("hms");let n=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),l=e.getSeconds().toString().padStart(2,"0");return`${n}${t}${r}${t}${l}`}},arity:[0,1]},eq:cn,ne:fn,not:hn,lt:dn,le:pn,gt:mn,ge:gn,add:xe("add",(e,t)=>e+t),sub:xe("sub",(e,t)=>e-t),mul:xe("mul",(e,t)=>e*t),div:xe("div",(e,t)=>e/t),mod:xe("mod",(e,t)=>e%t),abs:{factory:()=>e=>("number"!=typeof e&&be("abs"),Math.abs(e)),arity:[0,0]},clamp:{factory:e=>{let t=Ae(e,0,"clamp"),n=Ae(e,1,"clamp");return e=>("number"!=typeof e&&be("clamp"),Math.min(Math.max(e,t),n))},arity:[2,2]},int:{factory:()=>e=>parseInt(String(e),10),arity:[0,0]},float:{factory:()=>e=>parseFloat(String(e)),arity:[0,0]},falsy:yn,truthy:bn,defaults:{factory:(e,t)=>{let n=ke(e?.[0]??ge("defaults"),t);return e=>e||n},arity:[1,1]},coalesce:{factory:(e,t)=>{let n=ke(e?.[0]??ge("coalesce"),t);return e=>e??n},arity:[1,1]},boolean:vn,number:{factory:()=>e=>Number(e),arity:[0,0]},string:{factory:()=>e=>String(e),arity:[0,0]},nullIfEmpty:{factory:()=>e=>""===e?null:e,arity:[0,0]}},wn=Object.fromEntries(Object.entries($n).filter(([e])=>!(e in Se))),An=!1,kn={name:"formats",install:function(){An||(An=!0,pe($n))}};function xn(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=new Array(t.length+1),l=new Array(t.length+1);for(let e=0;e<=t.length;e++)r[e]=e;for(let n=1;n<=e.length;n++){l[0]=n;for(let i=1;i<=t.length;i++){let s=e[n-1]===t[i-1]?0:1;l[i]=Math.min(r[i]+1,l[i-1]+1,r[i-1]+s)}for(let e=0;e<=t.length;e++)r[e]=l[e]}return r[t.length]}function Sn(e,t){if(0===e.length)return"";let n=e.toLowerCase(),r=null,l=3;for(let e of t){let t=xn(n,e.toLowerCase(),2);t<l&&(r=e,l=t)}return null!==r?` Did you mean "${r}"?`:""}var Tn=" Validate statically: npx @wcstack/lint <file>.",Nn=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],jn=e=>{let t=Nn[e/100|0];return t?`[wcs/${t}] `:""},On=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],Cn=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,Mn="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",Pn={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>"updates did not settle after 32 passes",41:()=>"render chain depth limit exceeded (100 drains that rendering itself started); bindings for this batch were not applied.",12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${Mn}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${Mn}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&On.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${Cn(e,t)} failed to initialize.`,50:(e,...t)=>`${Cn(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${Cn(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": 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.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${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).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,r)=>`${e}("${t}") takes ${n} index(es), got ${r}.`,902:(e,t,n,r)=>`${e}("${t}") takes at most ${n} index(es), got ${r}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).${!e.includes("-")&&t.startsWith("command.")?" A native element's command needs the add-on @wcstack/state/features/native-commands.":""}`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1205:(e,t,n)=>`<${e}> has no command "${t}" (a native <${e}>'s commands: ${n}).`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function En(e,t){let n=Pn[e];return void 0===n?`${jn(e)}#${e} ${t.join(" ")}`:jn(e)+n(...t)}var Wn=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),Rn=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],In={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function Dn(e,t,n){let r=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(In,e)?In[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?Sn(t,n):"");for(let[t,n]of Rn){let l=t.exec(e);null!==l&&(r+=n.replace(/\$(\d)/g,(e,t)=>l[Number(t)]))}let l=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==l&&(r+=` — write "${l[1]}#${l[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?r+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':fe.some(me)||(r+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let i=/\[wcs\/([\w-]+)\]/.exec(e);return null!==i&&Wn.has(i[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(r+=Tn),r}var Ln=new WeakMap,qn=new WeakMap,zn=new WeakSet,Fn=new WeakSet;function Un(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function _n(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function Vn(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let r=e.target,l=t=>null===t?null:function(e,t){let n=t.t.split("."),r=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return r<0||n.indexOf("*",r)>=0||void 0!==Un(e.target,t.t)?.get?t:e.I.Mt(m(t.t).o)}(e,t);for(let t of n){if(null!=l(t)?.getter||null===r||"object"!=typeof r)return null;if("*"===t.s){if(!Array.isArray(r)||0===r.length)return null;r=r[0];continue}if(Array.isArray(r)&&/^\d+$/.test(t.s)){if(Number(t.s)>=r.length)return null;r=r[Number(t.s)];continue}let n=Un(r,t.s);if(void 0===n&&null===t.d&&e.wt.has(t.s))return null;if(void 0===n){let n=_n(r),i=l(t.d);for(let t of e.I.all())t.d===i&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;r=n.value}return null}function Bn(t){zn.has(t)||(zn.add(t),setTimeout(()=>function(t){zn.delete(t);let n=Ln.get(t);if(void 0===n)return;let r=qn.get(t);void 0===r&&qn.set(t,r=new Set);for(let[l,i]of n){if(r.has(l))continue;r.add(l);let n=Vn(t,l);if(null===n)continue;let s=[...t.root?.querySelectorAll(`${le.tagNames.state}[mount]`)??[]].find(e=>!Fn.has(e)&&(l.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==s){r.delete(l),s.initializePromise.then(()=>{Fn.add(s),Bn(t)});continue}let[o,a]=i?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];e.st?.(t,{type:"state:path-unresolved",source:i?"watch":"binding",path:l.t,missingSegment:n.seg});let u=t.I.Mt(m(l.t).o),c="";if(void 0!==u&&u!==l&&null!==u.getter){let e=u.h.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.h[t].t.length+2)}`);c=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${o}] ${a} "${l.t}" does not resolve on the state tree: "${n.seg}" is not declared.${Sn(n.seg,n.names)}${c} Updates to this path will be silently dropped.${Tn}`)}}(t),0))}function Hn(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let r=Ln.get(e);void 0===r&&Ln.set(e,r=new Map),r.has(t)||r.set(t,n),Bn(e)}var Kn=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Jn=!1;function Yn(e,t,n){let r="html"===n.name?"innerHTML":n.name;if(Jn||!(t instanceof TypeError)||!Pe(r)||!("trustedTypes"in globalThis))return;Jn=!0;let l="function"==typeof Ce()?.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 "${r}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${l}\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:n.a,property:r})}var Gn=new WeakMap;function Xn(e,t,n){let r=e[t],l=void 0===n?void 0===r?null:`the event carried no detail (undefined) while element.${t} is ${typeof r}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==r&&"object"==typeof r?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof r}`;if(null===l)return;let i=Gn.get(e);void 0===i&&Gn.set(e,i=new Set),!i.has(t)&&(i.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${l}. 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.`))}var Qn=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],Zn={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},er={name:"diagnostics",install(){e.jo=Dn,e.Lo=En,e.ko=Hn,e.detail=Xn,e.Ke=t(e.Ke,Yn);let r=e.fe;e.fe=(e,t)=>{(function(e){void 0!==e.$scan&&w(1);for(let[t,n]of Qn)void 0!==e[t]&&w(1601,[t,n])})(t),r?.(e,t),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[r,l]=n[0];if(!r.endsWith(".*")||!l.endsWith(".*"))return;let i=r.slice(0,-2),s=l.slice(0,-2),o=`.${l}`,a=`${i}.**`,u=_n(e),c=u.filter(e=>e.startsWith(a)).map(e=>e.slice(a.length)),f=e=>v(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${s}`||e.startsWith(`.${s}.`))&&f(`"${a}${e}" names the recursion structure itself (the "${s}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${Kn(o)})+$`).test(t.slice(0,t.length-e.length))&&f(`"${a}${e}" and "${a}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${l}"). Rename one of them.`);let t=new RegExp(`^${Kn(r)}(?:${Kn(o)})*${Kn(e)}$`);for(let n of u)!n.includes("**")&&t.test(n)&&f(`"${n}" is already defined on the state, so the recursive getter "${a}${e}" cannot expand to it.`)}}(t),function(e){qn.delete(e),Ln.has(e)&&Bn(e)}(e)},e.ot=n(l,e.ot,(e,t)=>Object.hasOwn(Zn,t)?w(1701,[t,Zn[t]]):void 0)}},tr={},nr=/\.\d/,rr=new Set(Object.getOwnPropertyNames(Object.prototype)),lr=0,ir=!1,sr=null,or=()=>{ir=!1,lr++};function ar(){if(null===sr)if("function"==typeof MessageChannel){let e=new MessageChannel;e.port1.onmessage=or,e.port1.unref?.(),sr=()=>e.port2.postMessage(0)}else sr=()=>setTimeout(or,0);return ir||(ir=!0,sr()),lr}function ur(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.pop();if(!n.has(e)){n.add(e);for(let n of e.Q){for(let r of t)if(n.ee(r)&&(n.n===r.n||!(r.n<e.n&&e.h[r.n+1].ee(r))))return!0;null!==n.getter&&r.push(n)}}}return!1}var cr=class{constructor(e,t){this.active=!1,this.Ge=new Map,this.n=0,this.Po=-1,this.Ln=new Set,this.We=null,this.engine=e,this.ct=t}ur(){let e=this.engine;this.Ge.clear();for(let t of this.ct)t.getter=null!==t.p.getter||t.p.se,t.s=new WeakMap,this.prime(t,()=>{0===t.p.n?t.getter&&t.s.set(tr,e.v(t.p,null)):this.Bn(t.p,1,null,n=>{t.getter&&this.prime(t,()=>t.s.set(n,e.v(t.p,n)))})});this.active=!0}prime(t,n){try{n()}catch(n){console.error(`[@wcstack/state] $watch initial evaluation of "${t.t}" threw.`,n),e.st?.(this.engine,{type:"state:watch-error",phase:"prime",path:t.t,error:n})}}Fo(){this.active=!1,this.Ge.clear()}Bn(e,t,n,r){let l=this.engine._e(n,e.h[t]);for(let n of l.f)t===e.n?r(n):this.Bn(e,t+1,n,r)}un(e,t,n,r){let l=this.Ge.get(e);void 0===l&&this.Ge.set(e,l=new Map);let i=l.get(t);void 0===i?l.set(t,[n,this.n,r]):(i[1]<this.n&&(i[1]=this.n),i[2]||=r)}ve(e,t,n,r,l){if(this.active){(this.We??=new Set).add(e);for(let i of this.ct){let s=i.p;s.n!==e.n||!s.ee(e)||this.un(i,t,i.getter?i.s.get(t??tr):s===e&&l&&this.engine._t&&(null===r||"object"!=typeof r&&"function"!=typeof r)?n:void 0,!0)}}}Se(e,t){if(this.active)for(let n of this.ct)(n.getter||=null!==n.p.getter||n.p.se)&&n.p.n===e.n&&n.p.ee(e)&&this.un(n,t,n.s.get(t??tr),!1)}Jt(e,t){if(!this.active)return;let n=null;for(let r of this.ct){let l=r.p;if(!(l.n<e.n||l.h[e.n]!==e.o)){n??=new Set(t);for(let t of e.f)n.has(t)||(l.n===e.n?this.un(r,t,void 0,!0):this.Bn(l,e.n+1,t,e=>this.un(r,e,void 0,!0)))}}}Fe(){let t=this.We;if(this.We=null,!this.active||0===this.Ge.size)return;let n=this.Ge;this.Ge=new Map;let r=this.engine,l=[];for(let i of this.ct){let s=n.get(i);if(void 0===s)continue;let o,a=[...s].filter(([e])=>null===e||e.y);a.length>1&&a.sort((e,t)=>hr(e[0],t[0]));for(let[n,[s,u,c]]of a){let a,f="evaluate",h=r.u;this.n=u+1,r.Te++;try{if(a=r.v(i.p,n),i.getter&&(i.s.set(n??tr,a),Object.is(a,s)&&(nr.test(i.t)||null!==n&&!c&&!(o??=null!==t&&ur(fr(i.p),t)))))continue;if(u>32){l.includes(i.t)||l.push(i.t);continue}r.u=n,e.st?.(r,{type:"state:watch-fired",path:i.t}),f="handler",i.handler.call(r.proxy,a,s,...r.H(n))}catch(t){console.error(`[@wcstack/state] $watch "${i.t}" failed; the other watches still run.`,t),e.st?.(r,{type:"state:watch-error",phase:f,path:i.t,error:t})}finally{r.u=h,this.n=0,r.Te--}}}l.length>0&&this.Oo(l)}Oo(t){let n=ar();n!==this.Po&&(this.Po=n,this.Ln.clear());let r=t.filter(e=>!this.Ln.has(e));if(0!==r.length){for(let e of r)this.Ln.add(e);console.error("[@wcstack/state] $watch handlers / $stream restarts kept writing for 32 batches; the chain is cut (nothing is rolled back)."),e.st?.(this.engine,{type:"state:watch-chain-limit",maxDepth:32,paths:r})}}};function fr(e){for(;null===e.getter&&null!==e.d;)e=e.d;return e}function hr(e,t){let n=[],r=[];for(let t=e;null!==t;t=t.l.ae)n.unshift(t.w);for(let e=t;null!==e;e=e.l.ae)r.unshift(e.w);for(let e=0;e<n.length&&e<r.length;e++)if(n[e]!==r[e])return n[e]-r[e];return n.length-r.length}var dr="$streamStatus",pr="$streamError",mr=new Set(Object.getOwnPropertyNames(Object.prototype)),gr=!1;function yr(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return void 0!==e.get||void 0!==e.set||"function"==typeof e.value}return!1}var br=class{constructor(e,t,n){this.engine=e,this.entries=t,this.L=n}set(e,t,n){gr=!0;try{this.engine.A(this.engine.o(`${e}.${t}`),null,n)}finally{gr=!1}}dr(){for(let e of this.entries)this.start(e,!0)}fr(){for(let e of this.entries)e.ut=!1,e.J?.abort(),e.J=null}pr(){for(let e of this.entries)e.ut=!1,null!==e.J&&(e.J.abort(),e.J=null),this.set(dr,e.name,"idle")}Se(e){let t=this.L.n;for(let n of this.entries)n.g===e&&(n.n=n.ut?Math.max(n.n,t):t,n.ut=!0)}Fe(){let e=this.engine,t=this.L,n=[];for(let r of this.entries){if(!r.ut)continue;let l=r.n;if(r.ut=!1,l>32)n.push(r.name),r.g.z=h;else{t.n=l+1,e.Te++;try{this.start(r,!1)}finally{e.Te--,t.n=0}}}n.length>0&&t.Oo(n)}start(e,t){let n,r=this.engine;if(null!==e.J&&e.J.abort(),e.J=null,null!==e.g){let l=e.g;l.getter=e.args;let i=l.Q.slice();vr(l);try{n=r.read(l,null),function(e,t,n){null!==n&&"function"==typeof n?.then&&v(`$stream "${e}": args must be synchronous (it returned a Promise).`);for(let n of t.Q)n.n>0&&v(`$stream "${e}": args must not read a wildcard path ("${n.t}").`),(n.t===e||n.t===`${dr}.${e}`||n.t===`${pr}.${e}`)&&v(`$stream "${e}": args must not read the stream itself ("${n.t}").`)}(e.name,l,n)}catch(n){vr(l);for(let e of i)e.Wn(l);if(l.z=h,t)throw n;return this.set(pr,e.name,n),void this.set(dr,e.name,"error")}}let l=new AbortController;e.J=l,r.A(r.o(e.name),null,e.U),this.set(pr,e.name,null),this.set(dr,e.name,"active"),this.mr(e,l,n)}async mr(e,t,n){let r=this.engine,l=t.signal,i=()=>!l.aborted&&e.J===t,s=r.o(e.name),o=this.L.n,a=ar(),u=e=>{ar()===a&&(this.L.n=o);try{e()}finally{this.L.n=0}},c=e.U;try{let t=await e.source(n,l);if(!i())return;let o=t=>{c=void 0!==e.Co?e.Co(c,t):t,u(()=>r.A(s,null,c))};if(null!==t&&"function"==typeof t?.getReader){let e=t.getReader();for(l.addEventListener("abort",()=>{e.cancel().catch(()=>{})});;){let t=await e.read();if(!i())return;if(t.done)break;o(t.value)}}else{if(null===t||"function"!=typeof t?.[Symbol.asyncIterator])throw new TypeError(`$stream "${e.name}": source must return an async iterable or a ReadableStream`);{let e=t[Symbol.asyncIterator]();for(l.addEventListener("abort",()=>{e.return?.()});;){let t=await e.next();if(!i())return;if(t.done)break;o(t.value)}}}if(!i())return;e.J=null,u(()=>this.set(dr,e.name,"done"))}catch(n){if(!i())return;e.J=null,t.abort(),u(()=>{this.set(pr,e.name,n),this.set(dr,e.name,"error")})}}};function vr(e){for(let t of e.Q){let n=t.B.indexOf(e);n>=0&&t.B.splice(n,1),t.pt.delete(e)}e.Q.length=0,e.z=c}var $r=new WeakMap;function wr(e){let t=$r.get(e);return t?.target===e.target?t:void 0}function Ar(t,n){let r=new cr(t,function(t,n){if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$watch must be an object mapping paths to handler functions.");let r=[];for(let l of Object.keys(n)){let i=n[l];(""===l||"$"===l[0]||l.includes("@")||rr.has(l))&&v(`$watch path "${l}" is not a path of the state tree.`),"function"!=typeof i&&v(`$watch entry "${l}" must be a function.`);let s=t.o(l);e.ko?.(t,s,!0),r.push({t:l,p:s,handler:i,getter:!1,s:new WeakMap})}return r}(t,n.$watch)),l=new br(t,function(e,t){let n=t.$stream;if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$stream must be an object mapping stream names to definitions.");let r=[],l={},i={};for(let s of Object.keys(n)){let o=n[s];(""===s||"$"===s[0]||/[.*]/.test(s)||mr.has(s))&&v(`$stream entry "${s}" must be a flat property name.`),(null===o||"object"!=typeof o)&&v(`$stream entry "${s}" must be an object.`);let a=o.source,u=o.fold,c=o.args,f=o.initial;"function"!=typeof a&&v(`$stream entry "${s}" needs a source function.`),void 0!==u&&"function"!=typeof u&&v(`$stream entry "${s}": fold must be a function.`),void 0!==u&&!("initial"in o)&&v(`$stream entry "${s}": fold needs an initial value.`),void 0!==c&&"function"!=typeof c&&v(`$stream entry "${s}": args must be a function.`),yr(t,s)&&v(`$stream entry "${s}" collides with a getter, setter or method of the state.`),void 0===t[s]&&(t[s]=f),l[s]="idle",i[s]=null,r.push({name:s,source:a,Co:u,U:f,J:null,ut:!1,n:0,g:void 0===c?null:e.o(`$streamArgs.${s}`),args:void 0===c?null:function(){return c(this)}})}return t[dr]=l,t[pr]=i,r}(t,n),r),i=$r.get(t);void 0!==i&&(i.L.Fo(),i.Ft.fr()),$r.set(t,{L:r,Ft:l,Xe:i?.Xe??!1,target:n})}function kr(e,t){let n=$r.get(e);if(void 0!==n&&"mounting"!==t&&!document.documentElement?.hasAttribute("data-wcs-server")&&("reset"!==t&&(n.Xe="connected"===t),n.target===e.target)){if("disconnected"===t)return n.L.Fo(),void n.Ft.pr();n.Xe&&(n.L.ur(),n.Ft.dr())}}var xr=["$streamStatus","$streamError"],Sr={name:"temporal",install(){e.fe=t(e.fe,Ar),e.element=t(e.element,kr),e.ve=t(e.ve,(e,t,n,r,l,i)=>wr(e)?.L.ve(t,n,r,l,i)),e.Se=t(e.Se,(e,t,n)=>{let r=wr(e);void 0!==r&&(r.L.Se(t,n),r.Ft.Se(t))}),e.Jt=t(e.Jt,(e,t,n)=>wr(e)?.L.Jt(t,n)),e.Fe=t(e.Fe,e=>{let t=wr(e);void 0!==t&&(t.L.Fe(),t.Ft.Fe())}),e.ot=n(l,e.ot,(e,t)=>{let n=t.split(".",1)[0];if(xr.includes(n))return n===t?e.target[t]:e.read(e.o(t),null)}),e.Pe=n(r,e.Pe,(e,t)=>(!gr&&36===t.t.charCodeAt(0)&&xr.includes(t.t.split(".",1)[0])&&v(`"${t.t}" is read-only (the stream runtime owns it).`),!1))}},Tr=new WeakMap,Nr=!1,jr=/^(?!prototype$)[^\d.*$][^.*]*$/;function Or(e,t){let n=t.$listKeys,r=new Map;if(void 0!==n){(null===n||"object"!=typeof n)&&v("$listKeys must be an object mapping list paths to a key field or function.");for(let t of Object.keys(n)){let l=n[t];"string"==typeof l?r.set(e.o(t),e=>e[l]):"function"==typeof l?r.set(e.o(t),l):v(`$listKeys "${t}" must be a field name or a function.`)}}Tr.set(t,r)}function Cr(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Mr(e,t,n){let r=new Map;for(let l of t){Cr(l)||v(`$listKeys "${e}": rows must be plain objects.`);let t=n(l);null==t&&v(`$listKeys "${e}": a row has no key.`),r.has(t)&&v(`$listKeys "${e}": duplicate key ${JSON.stringify(t)}.`),r.set(t,l)}return r}function Pr(e,t,n,r){if(Nr||!Array.isArray(r))return!1;let l=Tr.get(e.target)?.get(t);if(void 0===l)return!1;let i=e.rt(t,n);if(!Array.isArray(i)||i===r)return!1;let s=Mr(t.t,i,l);Mr(t.t,r,l);let o=[],a=[],u=i.length===r.length;for(let e=0;e<r.length;e++){let t=r[e],n=s.get(l(t));o.push(n??t),void 0!==n&&a.push([e,n,t]),o[e]!==i[e]&&(u=!1)}let c=[];for(let[e,t,n]of a){for(let r of Object.keys(n))Object.is(t[r],n[r])||c.push([e,r,n[r]]);for(let r of Object.keys(t))!(r in n)&&null!==t[r]&&c.push([e,r,null])}if(u&&0===c.length)return!0;if(!u){Nr=!0;try{e.A(t,n,o)}finally{Nr=!1}}if(c.length>0){let r=e._e(0===t.n?null:n,t);for(let[n,l,i]of c){if("__proto__"===l)continue;let s=r.f[n],o=jr.test(l)?e.o(`${t.t}.*.${l}`):null;null===o?.getter?e.A(o,s,i):(s.R[l]=i,e.A(e.o(`${t.t}.*`),s,s.R,!0))}}return!0}var Er={name:"list-keys",install(){e.fe=t(e.fe,Or),e.Pe=n(r,e.Pe,Pr)}},Wr=new WeakMap,Rr=new WeakMap,Ir="will not graft: the root state failed to initialize.",Dr=new WeakSet,Lr=new WeakMap,qr=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],zr=["$commandTokens","$eventTokens","$on","$errorCallback"],Fr=e=>`[@wcstack/state] <${le.tagNames.state} mount="${e}">`,Ur=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),_r=e=>e?.element?.isConnected?e:void 0;function Vr(e){let t=Rr.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function Br(e,t){let n=Rr.get(t);if(Rr.delete(t),Array.isArray(n))for(let t of n)Yr(t,e)}function Hr(e){let t=Wr.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function Kr(e,t){console.error(`${Fr(e.t)} ${t}`),Hr(e),e.Je?.(),e.Je=null}function Jr(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function Yr(e,t){if(Dr.has(t))return Kr(e,"will not graft: its component is wired to its host.");let n=e.state,r=t.target,l=e.t.split("."),i=r;for(let e of l)i=i?.[e];if(void 0!==i&&!0!==t.hydrated)return Kr(e,`will not graft: the root state already has "${e.t}".`);let s=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,r){if("symbol"==typeof r)return;if(36!==r.charCodeAt(0))return e.proxy[n(r)];let l=e.proxy[r];return"$eqPath"===r?(e,t)=>l(n(e),n(t)):Ur.has(r)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,r,l)=>"symbol"!=typeof r&&(e.proxy[n(r)]=l,!0)})}(t,e.t);e.chroot=s;let o={},a={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:r,set:l,value:i}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==r||void 0!==l)a[`${e.t}.${n}`]={get:r&&function(){return r.call(s)},set:l&&function(e){l.call(s,e)}};else{if("$"===n[0])continue;if("function"==typeof i){let t=i.bind(s);a[`${e.t}.${n}`]={get:()=>t}}else o[n]=i}}if(void 0===i){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.A(n,null,{})}t.A(t.o(e.t),null,o)}t.to(Object.defineProperties({},a));for(let e in a)t.We(t.o(e),null);e.engine=t;let c=Lr.get(t);void 0===c&&Lr.set(t,c=[]),c.push(e),e.el.isConnected&&Jr(e,"$connectedCallback"),e.Je?.(),e.Je=null}function Gr(e,t){let n=Rr.get(e);if(Array.isArray(n))for(let e of n)Kr(e,Ir);Rr.set(e,t)}var Xr=new WeakMap;function Qr(e,t){let n=e.getAttribute("mount");if(null===n)return null;let r={el:e,root:t,t:n,state:null,engine:null,chroot:null,Je:null},l=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(le.bindAttributeName))l='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=Wr.get(t);void 0===e&&Wr.set(t,e=new Map);let i=e.get(n);if(void 0!==i&&i!==r&&(null===i.engine?i.el.isConnected:_r(i.engine)))l=`will not graft: another volume already holds "${n}".`;else{if(null===i?.engine){let e=Rr.get(t);Array.isArray(e)&&Rr.set(t,e.filter(e=>e!==i)),i.Je?.(),i.Je=null}e.set(n,r)}}else l='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{No:!0,start(e){if(null!==l)return Kr(r,l);if(Wr.get(t).get(n)===r){for(let t of qr)if(void 0!==e[t])return Kr(r,`${t} is not run in a volume — declare it on the root state.`);for(let t of zr)void 0!==e[t]&&console.warn(`${Fr(n)} ${t} is not run in a volume (it belongs to the root).`);return r.state=e,new Promise(e=>{r.Je=e;let n=_r(Lt.get(t)),l=Rr.get(t);void 0!==n?Yr(r,n):Vr(t)?Kr(r,Ir):Rr.set(t,[...Array.isArray(l)?l:[],r])})}},Xe(){null!==r.engine&&Jr(r,"$connectedCallback")},jn(){null!==r.engine&&Jr(r,"$disconnectedCallback")},reset(){v(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var Zr=new WeakMap,el=new WeakMap;function tl(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||v(`${t} must be an array of state member names.`);let r=new Set;for(let e of n)("string"!=typeof e||""===e)&&v(`${t} entries must be non-empty strings.`),"$"===e[0]&&v(`${t} entry "${e}": internal ($) members are never exposed.`),r.has(e)&&v(`${t} entry "${e}" is duplicated.`),r.add(e);return n}function nl(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let r=document.createDocumentFragment();for(let e of[...t.childNodes])r.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&v("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,r){e.includes("-")||v(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&v(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(r),i=tl(r,"$bindables"),s=tl(r,"$commands");for(let e of i){let t=l.get(e);void 0===t&&v(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&v(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of s){let t=l.get(e);void 0===t&&v(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&v(`$commands entry "${e}" is not a method: list it in $bindables.`)}let o={tag:e,bindables:i},a=new WeakMap,u=new WeakMap,c=r=>{if(a.has(r))return a.get(r);if(r.hasAttribute("data-wc-definition"))return null;let l=r.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let s=l.querySelector(le.tagNames.state);return a.set(r,s),Zr.set(r,o),null===s&&i.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${le.tagNames.state}>: no change events.`),s},f=e=>c(e)?.engine??null,h=e=>Promise.resolve(c(e)?.initializePromise).then(()=>{let t=u.get(e);u.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,r]of t)n.proxy[e]=r});class d extends HTMLElement{static{this.wcBindable=0===i.length&&0===s.length?null:{protocol:"wc-bindable",version:1,properties:i.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:i.map(e=>({name:e})),...0===s.length?{}:{commands:s.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==c(this)&&h(this)}get stateElement(){return c(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(d.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(d.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=u.get(this);void 0===n&&u.set(this,n=[]),n.push([e,t])}}});customElements.define(e,d)}(n.localName,r,l,t)},Xe(){},jn(){},reset(){v("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var rl=new WeakMap,ll=new WeakSet,il=new WeakMap,sl=new WeakMap,ol="data-wcs-wired",al=new WeakMap,ul=new WeakMap,cl=new WeakMap,fl=0,hl=new Set,dl={},pl=["$watch","$stream","$renderedCallback"],ml=e=>e.split(".",1)[0];function gl(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function yl(e,t){let n=e.a,r=ml(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(ol);else if(!vl(n,r)){let e=n.getAttribute(ol)?.split(" ")??[];e.includes(r)||n.setAttribute(ol,[...e,r].join(" "))}al.get(n)?.me===r&&v(`<${n.localName}>.${r} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=rl.get(n);void 0===l&&rl.set(n,l=[]),l.push(e),t&&ll.add(e);let i=il.get(n);return void 0===i&&il.set(n,i=new Map),i.has(r)||i.set(r,n[r]),sl.get(n)?.(),!1}function bl(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${le.tagNames.state}[bind-component]`)}function vl(e,t){let n=e.getAttribute(le.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function $l(e){let t=e.parentElement;for(;null!==t&&!bl(t);)t=t.parentElement;let n=Lt.get(t??e.getRootNode()),r=n?.element;(r?.isConnected?r.V:null===t)&&(null===t?Ht(e):zt(n,e))}var wl=new Set;function Al(e,t){wl.has(e)||(wl.add(e),console.warn(`[@wcstack/state] ${t}`))}var kl=(e,t)=>t in e.state;function xl(e,t){let n=Sl(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function Sl(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function Tl(e,t,n){if(null!==n.getter)return;let r,l=e.host,i=l.engine,s=ml(n.t),o=l.entries.find(e=>e.E===n.t);if(void 0===o&&null!==n.d)return function(e,t){let n,r=t.d;for(;null!==r&&void 0===(n=e.dt.get(r));)r=r.d;if(null===r||void 0===n)return;let l=e.N,i=e.host.engine,s=i.o(n.p.t+t.t.slice(r.t.length));if(null===s.getter)return;let o=n,a=()=>{let n=Nl(e,o.r);return 0===t.n?n:(i.resolve(gl(s.t,[...i.H(n),...l.H(te(l.u,t.n))]),null),i.rr)};t.getter=()=>{let e=a();return s.n>0&&null===e?void 0:i.v(s,e)},null!==s.ie&&(t.ie=n=>{let r=a();jl(e,o.e,()=>i.A(s,r,n)),e.dn=t}),t.n>0&&(t.P=l.Ie++),e.dt.set(t,{e:o.e,p:s,r:o.r})}(e,n);if(0!==n.n)return;if(void 0!==o){if(o.E!==s?kl(l,s):xl(l,s))return;r=o.he}else{if(null===t||null!==n.d||"$"===s[0]||kl(l,s))return;o=t,r=i.o(`${t.he.t}.${s}`)}let a=o.r,u=o;n.getter=()=>i.v(r,Nl(e,a)),n.ie=t=>{jl(e,u,()=>i.A(r,a,t)),e.dn=n},e.dt.set(n,{e:o,p:r,r:a})}function Nl(e,t){return null!==t&&!t.y&&v(`The host row of <${e.host.el.localName}> was removed.`),t}function jl(e,t,n){let r=hl.has(e.N);hl.add(e.N),e.from=t;try{n()}finally{r||hl.delete(e.N),e.from=null}}var Ol=(e,t)=>t||!hl.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function Cl(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,fl+=t?1:-1;let n=e.host.engine,r=cl.get(n);void 0===r&&cl.set(n,r=new Map);for(let n of e.pe){let e=r.get(n.e.he);void 0===e&&r.set(n.e.he,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.E);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,r=n.engine;e.re=new Map;let l=new Set;for(let i=n.state;null!==i&&i!==Object.prototype;i=Object.getPrototypeOf(i))for(let s of Object.getOwnPropertyNames(i)){if(l.has(s))continue;l.add(s);let o=Object.getOwnPropertyDescriptor(i,s);if(void 0===o.get&&void 0===o.set||"$"===s[0]||s.includes("*"))continue;let a=ml(s);if(s!==a&&!kl(n,a))continue;let u=r.o(`${t.he.t}.${s}`);if(null===u.getter)El(r,u,t.he);else if(!Ml.has(u.getter))continue;e.re.set(u,e.N.o(s))}}(e,l);for(let r of e.re.keys())t&&null===r.getter&&El(n,r,l.he),n.T.we(n,r,l.r);e.re.size>0&&n.Ae(),t&&function(e,t){let n=e.host.engine;for(let[r,l]of e.re){let i=n.v(r.d,t.r);if(null===i||"object"!=typeof i||!(r.s in i))continue;let s=e.host.el.localName;Al(`${s}|${r.t}`,`[wcs/mount-export-shadowed] <${s}>.${e.host.me}.${l.t} is exported at "${r.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var Ml=new WeakSet;function Pl(e,t,n,r){let l=cl.get(e)?.get(t)?.get(n);if(void 0===l)return null;let i=null;for(let e of l)""!==e.e.E||!0!==e.m.re?.has(r)||e.m===i||(null!==i&&v(`[wcs/mount-export-ambiguous] "${r.t}" is exported by two mounted components on the same instance: <${i.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),i=e.m);return i}function El(e,t,n){let r=t.d,l=t.s,i=()=>{let t=e.read(r,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let r=i();if(null!==r)return r[l];let s=Pl(e,n,e.u,t);return null===s?void 0:s.N.read(s.re.get(t),null)},Ml.add(t.getter),t.ie=s=>{let o=null===i()?Pl(e,n,e.u,t):null;if(null===o){let t=e.read(r,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=s))}let a=o.re.get(t);void 0===Sl(o.host.state,a.t)?.set&&v(`Cannot write to "${a.t}" on mounted <${o.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),o.N.A(a,null,s)},t.n>0&&(t.P=e.Ie++)}function Wl(t,n,r,l,i,s){if(null!==n.getter)return t.T.we(t,n,r),void t.Ae();if("*"===n.s){if(null===r)return;if(r.R=r.l.C[r.w],t.T.Yt(r),null!==r.c)for(let e of r.c.values())t.X(e)}else t.En(n,r);e.ve?.(t,n,r,l,i,s),t.We(n,r)}function Rl(e){let t=e.m.N;for(let[n,r]of e.m.dt)r.e===e.e&&(0===n.n?t.T.we(t,n,null):t.tn(n.h[n.n],e=>t.T.we(t,n,e)));t.Ae()}function Il(e,t,n,r,l,i,s){let o=n.t.slice(t.t.length);if(""===o)return Rl(e);let a,u=e.m,c=u.N;if(""===e.e.E){a=o.slice(1);let e=ml(a);if("$"===e[0]||kl(u.host,e)||u.host.entries.some(e=>""!==e.E&&(a===e.E||a.startsWith(`${e.E}.`))))return}else a=e.e.E+o;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(te(r,e).w);c.resolve(gl(a,f),null);let h=c.rp,d=c.rr;h.n>0&&null===d||Wl(c,h,d,l,i,s)}function Dl(e,t,n,r,l,i,s){if(0===fl)return;let o=hl.has(e);hl.add(e);try{let o=ul.get(e);!s&&void 0!==o&&o.fn&&!hl.has(o.host.engine)&&function(e,t,n,r,l,i){let s,o=t;for(;null!==o&&void 0===(s=e.dt.get(o));)o=o.d;if(null===o||void 0===s)return;let a=e.host.engine;if(o===t&&e.dn===t)return void(e.dn=null);if(null!==s.r&&!s.r.y)return;let u=[...a.H(s.r),...e.N.H(n)];a.resolve(gl(s.p.t+t.t.slice(o.t.length),u),null);let c=a.rp,f=a.rr;c.n>0&&null===f||jl(e,s.e,()=>Wl(a,c,f,r,l,i))}(o,t,n,r,l,i),s&&void 0!==o&&o.fn&&null!==o.re&&function(e,t){let n=e.host.entries.find(e=>""===e.E),r=e.host.engine;for(let[l,i]of e.re)i===t&&(r.T.we(r,l,n.r),r.Ae())}(o,t);let a=cl.get(e);if(void 0===a)return;for(let[e,o]of a)if(t.ee(e)){let a=o.get(0===e.n?null:te(n,e.n));if(void 0!==a)for(let o of[...a])Ol(o,s)&&Il(o,e,t,n,r,l,i)}else if(e.ee(t))for(let[e,r]of[...o])if(0===t.n||te(e,t.n)===n)for(let e of[...r])Ol(e,s)&&Rl(e)}finally{o||hl.delete(e)}}async function Ll(t,n,r,l,i){if(l===dl)return;let s=o(l);s&&await s;let a=al.get(n);a.engine&&l.$recursion&&v(`[wcs/mount-dollar-declaration] <${n.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let u=a.O;if(null!==u&&u.el!==t&&u.el.isConnected&&v(`<${n.localName}> already has a connected <${le.tagNames.state} bind-component="${a.me}">.`),null!==u&&Cl(u,!1),null!==u&&function(e,t,n){let r=e.N,l=`[${le.bindAttributeName}]`,i=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),s=new Set,o=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&s.add(e)},a=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)o(n);o(t)};for(let e of r.ue.values())for(let t of e)if(null===t.W)o(t.a);else for(let e of t.W.G)a(t.W,e.S);for(let e of r.oe.values())for(let t of[e.$,...e.j??[]])null!==t&&a(t,t.S);for(let t of e.D)t.parentNode===n&&i(t)&&s.add(t);if(0===s.size)return!1;let u=[...n.childNodes].filter(n=>n!==t&&!s.has(n)&&!e.D.includes(n)&&(i(n)||r.Bt&&n.textContent.includes("{{")));return u.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${u.length} node(s) added beside the content taken over are not bound.`),!0}(u,t,r))return async function(e,t,n,r){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.D=e.D.filter(e=>e.parentNode===n),t.isConnected?await ql(e,r):r()}(u,t,r,i);let c=new re(l,new Jt);c.element=t,t.engine=c,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let r=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof r&&"constructor"!==t&&n.set(r,null)}let r=(t,n,r)=>Reflect.apply(t,e.proxy,r);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:r})),t}}(c,l);let f={el:t,D:[],N:c,host:a,pe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of a.entries)f.pe.push({m:f,e});a.O=f,ul.set(c,f);let h=null===a.engine;h?e.element?.(c,"mounting"):(function(e){let t=e.N,n=e.host,r=n.engine,l=n.el.localName,i=n.entries.find(e=>""===e.E)??null;for(let e of n.entries){if(""===e.E)continue;let t=ml(e.E);kl(n,t)&&(e.E!==t||xl(n,t))&&Al(`${l}.${e.E}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.me}.${e.E}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==i){let e=r.v(i.he,i.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.E===t)&&Al(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${i.he.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let s=pl.filter(e=>void 0!==n.state[e]);s.length>0&&Al(`${l}.${n.me}$`,`[wcs/mount-dollar-declaration] <${l}>: ${s.join(", ")} ${1===s.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let o=t.nt;t.nt=n=>{Tl(e,i,n),o.call(t,n)};let a=[...t.I.all()];for(let t of a)Tl(e,i,t);for(let e of a)o.call(t,e);let u=t.zt;t.zt=()=>{(function(e){for(;void 0!==e;e=ul.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.y))return!1;return!0})(e)&&u.call(t)}}(f),Cl(f,!0),Dr.add(c),Br(c,r));let d=e.hr?.(r);qt(c,r),d?.(),f.D=[...r.childNodes],Kt(),h&&c.$n(),Object.defineProperty(n,a.me,{configurable:!0,enumerable:!0,get:()=>c.proxy});let p=n.$stateReadyCallback;if("function"==typeof p)try{let e=p.call(n,a.me);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}i(),t.isConnected?(await c.ke("$connectedCallback"),h&&t.isConnected&&e.element?.(c,"connected")):Cl(f,!1)}async function ql(t,n){Cl(t,!0);for(let e of t.pe)Rl(e);n?.(),!t.broken&&(await t.N.ke("$connectedCallback"),null===t.host.engine&&t.el.isConnected&&e.element?.(t.N,"connected"))}function zl(t,n){let r=t.getAttribute("bind-component");if(null===r)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=Lt.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){Gr(t,e);for(let e of Xr.get(t)??[])e()}}),null}(t,n);let l=t.parentNode,i=l instanceof ShadowRoot,s=i?l.host:l instanceof Element?l:null,o=()=>{let e=null===s?void 0:al.get(s)?.O;return e?.el===t?e:null},a=e=>{throw i&&Gr(l,t),e},u=!1;return{Ot:()=>(null!==s&&s.localName.includes("-")?async function(e,t,n,r){let l=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&v(`<${le.tagNames.state} bind-component> takes its state from <${l}>.${t}: it cannot also load one (state / src / json / an inline script).`),await Le(n).whenDefined(l);let i=al.get(n);if(void 0!==i)return i.me!==t&&v(`<${l}> already has a <${le.tagNames.state} bind-component="${i.me}">.`),i.state;let s=()=>(rl.get(n)??[]).filter(e=>ml(e.name)===t),o=vl(n,t);if(o&&0===s().length&&$l(n),0===s().length&&(o||((e,t)=>!0===e.getAttribute(ol)?.split(" ").includes(t))(n,t))){let e;await new Promise((r,i)=>{sl.set(n,r),e=function(e,t){Vr(e)&&t();let n=Xr.get(e)??new Set;return Xr.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>i(new Error(`[@wcstack/state] <${l}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}sl.delete(n);let a=s(),u=il.get(n),c=void 0!==u&&u.has(t)?u.get(t):n[t];if((null===c||"object"!=typeof c)&&v(`"bind-component": <${l}>.${t} must be an object (the component's state), got ${null===c?"null":typeof c}.`),0===a.length&&r){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${l}>, or mount it from the host (${le.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),dl}let f=[];for(let e of a){let r=e.name===t?"":e.name.slice(t.length+1);f.some(e=>e.E===r)&&v(`<${l}> maps "${e.name}" twice.`);let i=r.split(".").indexOf("*");if(i>=0){let n=r.split(".").slice(0,i).join(".");v(`<${l}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}f.push({E:r,he:e.o,r:e.r,ro:ll.has(e)}),e.engine.Nn(e),""!==r&&delete n[e.name]}let h=0===a.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(c):c;return al.set(n,i={el:n,me:t,state:h,engine:0===a.length?null:a[0].engine,entries:f,O:null}),h}(t,r,s,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${le.tagNames.state}> to be a direct child of a custom element.`))).catch(a),async start(e,n){await Ll(t,s,i?l:s,e,()=>{u=!0,n()}).catch(e=>{let t=o();return!u&&null!==t&&(t.broken=!0),a(e)})},Xe(){let e=o();null!==e?ql(e).catch(e=>console.error(e)):u?Promise.resolve().then(()=>{if(t.parentNode===l)return Ll(t,s,i?l:s,al.get(s).state,()=>{})}).catch(e=>console.error(e)):sl.has(s)&&$l(s)},jn(){let t=o();null!==t&&(Cl(t,!1),!t.broken&&(t.N.ke("$disconnectedCallback"),null===t.host.engine&&e.element?.(t.N,"disconnected")))},reset(){v(`re-setting a component's state is not supported: write <${s?.localName}>.${r} instead.`)}}}var Fl={name:"scopes",install(){e.at=n(i,e.at,Qr),e.at=n(i,e.at,nl),e.at=n(i,e.at,zl),e.ar=yl,e.Eo=bl,e.element=t(e.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=Lr.get(e)??[];if("disconnected"===t)for(let e of n)Hr(e);else if("reset"!==t&&_r(Lt.get(e.root))===e){Br(e,e.root);for(let e of n)Wr.get(e.root).has(e.t)||Wr.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();Br(e,n),function(e,t){let n=t.host,r=void 0===n?void 0:Zr.get(n);void 0!==r&&el.set(e,{host:n,def:r})}(e,n)}),e.ve=t(e.ve,(e,t,n,r,l,i)=>{(function(e,t,n,r){let l=el.get(e);if(void 0===l)return;let i=t.t.split(".",1)[0];if(!l.def.bindables.includes(i))return;let s=r&&t.t===i;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${i}-changed`,{detail:s?n:void 0,bubbles:!0}))})(e,t,l,i),Dl(e,t,n,r,l,i,!1)}),e.Se=t(e.Se,(e,t,n)=>Dl(e,t,n,void 0,void 0,!1,!0)),e.Pe=n(r,e.Pe,(e,t,n,r,l)=>(function(e,t){let n=Lr.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&v(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let r,l=ul.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===r;e=e.d)r=l.dt.get(e);if(void 0===r)return!1;let i=r.e;return!((null===i.r||i.r.y)&&!i.ro)&&(!!n||(Nl(l,i.r),void v(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.me}${""===i.E?"":`.${i.E}`}#ro: ${i.he.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let l=e.fe;e.fe=(e,t)=>{let n=Lr.get(e);void 0!==n&&n.length>0&&v(`re-setting a root state with grafted volumes (${n.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=cl.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(e)&&v("re-setting a root state with mounted components is not supported: they read its data."),l?.(e,t)}}},Ul="$recursion",_l=new WeakMap,Vl=new WeakSet,Bl=new WeakSet,Hl=0,Kl=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Jl=e=>`[wcs/recursion-${e}]`;function Yl(e,t){let n=n=>v(`${Jl("declaration-invalid")} ${Ul} ${e} "${String(t)}" ${n}`);("string"!=typeof t||""===t)&&v(`${Jl("declaration-invalid")} ${Ul} ${e} must be a non-empty string.`);let r=t.split(".");(r.length<2||"*"!==r[r.length-1])&&n('must end with ".*" (a list element).');for(let e=0;e<r.length-1;e++){let t=r[e];""===t&&n("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&n('must have exactly one "*", at the end.'),t.includes("#")&&n('must not contain "#".')}return"$"===t[0]&&n('must not start with "$".'),t}var Gl=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function Xl(e,t){let n=`${e.l}.**`,r=t.slice(n.length);return(!t.startsWith(n)||""!==r&&"."!==r[0]||r.includes("**"))&&v(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),r}function Ql(e,t,n){let r=Xl(e,t),l=function(e,t){for(let n=t;null!==n;n=n.l.ae){let t=e.nodeList.exec(n.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r:n}}return null}(e,n);return null===l&&v(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),Gl(e,l.k)+r}function Zl(e,t,n){let r=new Set,l=new Set,i=(e,n,i)=>!(!Array.isArray(e)||0===e.length||(r.has(e)&&v(`${Jl("cycle")} "${n}" is reachable from itself: the data under "${t.l}" must be a tree.`),l.has(e)&&v(`${Jl("shared-list")} "${n}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),i+1>128&&v(`${Jl("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${i+1} (the limit is 128).`),l.add(e),0)),s=(l,o)=>{for(let a of l){n(o,a);let l=e.o(`${Gl(t,o)}.${t.key}`),u=e.read(l,a);i(u,l.t,o+1)&&(r.add(u),s(e._e(a,l).f,o+1),r.delete(u))}},o=e.o(t.l),a=e.read(o,null);i(a,t.l,0)&&(r.add(a),s(e._e(null,o).f,0))}function ei(e,t){let n=function(e){let t=e[Ul],n=[],r=new Set;for(let t=e;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of Object.getOwnPropertyNames(t))!r.has(e)&&e.includes("**")&&n.push([e,Object.getOwnPropertyDescriptor(t,e)]),r.add(e);if(void 0===t)return n.length>0&&U(n[0][0]),null;(null===t||"object"!=typeof t||Array.isArray(t))&&v(`${Jl("declaration-invalid")} ${Ul} must be an object mapping one anchor path to its repeating sub-path.`);let l=Object.entries(t);1!==l.length&&v(`${Jl("declaration-invalid")} ${Ul} must declare exactly one anchor (it declares ${l.length}).`);let i=Yl("anchor",l[0][0]),s=Yl("repeat",l[0][1]),o=i.slice(0,-2),a=s.slice(0,-2),u=`.${s}`,c=new Map,f=[],h=`${o}.**`;for(let[e,t]of n){let n=e.slice(h.length);(!e.startsWith(h)||""!==n&&"."!==n[0]||n.includes("**"))&&v(`[wcs/recursion-anchor] "${e}": a recursive key is "${h}" followed by a path (the anchor is "${i}").`),(""===n||n.split(".").slice(1).some(e=>""===e))&&v(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&v(`${Jl("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),c.set(n,t.get),f.push([new RegExp(`^${Kl(i)}((?:${Kl(u)})*)${Kl(n)}$`),n])}return{l:o,step:u,key:a,families:c,matchers:f,owners:new Map,nodeList:new RegExp(`^${Kl(o)}((?:${Kl(`.*.${a}`)})*)$`)}}(t),r=_l.has(e);null!==n?(r||Hl++,_l.set(e,n),Bl.add(e),Vl.has(e)||function(e){Vl.add(e);let t=e,n=t.nt;t.nt=r=>{let l=_l.get(e);if(r.t.includes("**")){let t=e.I.Mt(r.t)===r;return void(Bl.has(e)||void 0===l&&t?r.getter=()=>U(r.t):t||n.call(e,r))}if(void 0!==l&&null===r.getter)for(let[e,n]of l.matchers)if(e.test(r.t)){r.getter=l.families.get(n),r.n>0&&(r.P=t.Ie++),l.owners.set(r,l.l+".**"+n);break}n.call(e,r)};let r=t.resolve;t.resolve=(t,n)=>{let l=_l.get(e);return r.call(e,void 0!==l&&t.includes("**")?Ql(l,t,n):t,n)};let l=t.getAll;t.getAll=(n,r)=>{let i=_l.get(e);if(void 0===i||!n.includes("**"))return l.call(e,n,r);if(void 0===r)return l.call(e,Ql(i,n,t.u));(!Array.isArray(r)||r.length>0)&&v(`${Jl("getall-form")} $getAll("${n}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let s=Xl(i,n),o=[];return Zl(e,i,(t,n)=>{for(let r of l.call(e,Gl(i,t)+s,e.H(n)))o.push(r)}),o};let i=t.yn;t.yn=(n,r,l,s)=>{let o=_l.get(e);if(void 0===o||!n.includes("**"))return i.call(e,n,r,l,s);Array.isArray(r)||w(9,[n]),r.length>0&&v(`${Jl("setall-form")} $setAll("${n}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof l||!0===s?.spread)&&v(`${Jl("setall-form")} $setAll("${n}", [], value) with "**" takes a plain value (no mapper, no spread).`),t.Me>0&&w(8);let a=Xl(o,n),u=a.replace(/\.\d+(?=\.|$)/g,".*");for(;u.startsWith(o.step);)u=u.slice(o.step.length);let c=o.key.split(".");(""===u||u===`.${o.key}.length`||c.some((e,t)=>u===`.${c.slice(0,t+1).join(".")}`))&&v(`${Jl("structural-write")} "${n}" writes the recursion structure itself (a node, its "${o.key}" list or that list's length, or an object on the way to it).`);for(let e of o.families.keys()){let t=e;for(;t.startsWith(o.step);)t=t.slice(o.step.length);(u===t||u.startsWith(`${t}.`))&&v(`${Jl("readonly")} "${n}" writes into the recursive getter "${o.l}.**${e}".`)}let f=[];Zl(e,o,(e,t)=>f.push([e,t]));let h=0;for(let[t,n]of f)h+=i.call(e,Gl(o,t)+a,e.H(n),l);return h}}(e)):r&&(_l.delete(e),Hl--)}function ti(e,t){if(0===Hl)return!1;let n=_l.get(e);if(void 0===n)return!1;for(let e=t;null!==e;e=e.d){let r=n.owners.get(e);void 0!==r&&v(`${Jl("readonly")} "${t.t}" writes into the recursive getter "${r}".`)}return!1}var ni={name:"recursion",install(){e.fe=t(e.fe,ei),e.element=t(e.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){Bl.delete(e)}(e)}),e.Pe=n(r,e.Pe,ti)}},ri="4.0.0-rc.9",li=e=>e.split(".").slice(0,2).join("."),ii=class extends Zt{static find(e){return e.querySelector?.(le.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return li(this.version)===li(ri)}};function si(e){let t=le.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends ii{})}var oi=()=>le.tagNames.ssr,ai=Symbol.for("wcstack.ssr.snapshotBuilder"),ui=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),ci=e=>document.createComment(e),fi=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,hi=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),di=new WeakMap,pi=new WeakMap,mi=new WeakMap,gi=new WeakSet,yi=new WeakMap;function bi(e,t){let n=[];for(let r=e;null!==r&&(n.push(r),r!==t);r=r.nextSibling);return n}function vi(e,t,...n){for(let n of Array.from(e.attributes))t.setAttribute(n.name,n.value);return(t.content??t).append(...n),t}var $i=e=>null===e.D?e.Ue:e.D[e.D.length-1];function wi(e,t,n){let r=[ci(null===n?"wcs-[":`wcs-[:${n}`)];for(let e of t)null===n&&r.push(ci("wcs-|")),r.push(...bi(e.Ue,$i(e)));r.push(ci("wcs-]")),e.after(...r);for(let e of r)gi.add(e)}function Ai(e){if(e instanceof ct){wi(e.S,e.Re,null);for(let t of e.Re)ki(t);return}let t=e.O;null!==t&&(wi(e.G[e.G.length-1].S,[t],e.w),ki(t))}function ki(e){if(null!==e.c)for(let t of e.c)Ai(t)}var xi=new Set(["script","style","template","textarea","title"]),Si="data-wcs-raw",Ti=e=>xi.has(e.localName)||e.localName===oi();function Ni(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(ci("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(ci("wcs-s")):1===t.nodeType&&!Ti(t)&&Ni(t)}var ji=0;function Oi(e,t){let n=e.getRootNode(),r=[t];for(let e of pi.get(n)??[])e!==t&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let l=new Map;for(let e of r){let t=di.get(e);if(void 0===t)continue;let n=new Map;for(let t of e.oe.values())if(null!==t.$&&n.set(t.$.S,t.$),null!==t.j)for(let e of t.j)n.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.W)for(let t of e.W.G)n.set(t.S,e.W);let r=new Set;for(let[e,i]of t){l.set(e,i);let t=n.get(e);void 0!==t&&!r.has(t)&&e.isConnected&&(r.add(t),Ai(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=mi.get(e);if(void 0!==t){let n=document.createTreeWalker(e,133,{acceptNode:e=>gi.has(e)||1===e.nodeType&&t.has(e)&&Wi(e)?2:1}),r=[];for(let e=n.nextNode();null!==e;e=n.nextNode()){let n=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(Ti(e.parentNode)?yi.has(e):t.has(n)&&hi(n,"wcs-t:"))&&(yi.has(e)||t.get(e)!==e.data):!t.has(e))&&r.push(e)}for(let e of r)e.remove()}let n=Array.from(e.childNodes);Ti(e)&&n.some(e=>yi.has(e))&&e.setAttribute(Si,n.map(e=>yi.has(e)?`{{ ${yi.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}Ni(9===n.nodeType?n.body:n);let i=document.createElement(oi());i.setAttribute("version",ri);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let n of Object.keys(e)){if("$"===n[0])continue;let r=Object.getOwnPropertyDescriptor(e,n);void 0!==r.get||void 0!==r.set||"function"==typeof r.value||(t[n]=r.value)}return t}(t.target)),i.append(s);for(let[e,t]of l){if(!e.isConnected)continue;let n=e.parentNode;for(;null!==n&&"svg"!==n.localName&&"foreignObject"!==n.localName;)n=n.parentElement;let r="svg"===n?.localName,l=`wcs-${r?"s":"t"}${ji++}`;e.replaceWith(ci(`wcs-p:${l}`));let s=document.importNode(Pt(t),!0);for(let e of Array.from(s.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(vi(e,document.createElement("template"),...e.childNodes));if(r){let e=document.createElementNS(n.namespaceURI,"svg");e.append(s),s=e}let o=document.createElement("template");o.id=l,i.append(vi(t,o,s))}e.before(i)}function Ci(e){!function(e){if(null!==e.querySelector(le.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>yi.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${le.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===oi())continue;let e=t.engine;null!=e&&Oi(t,e)}}var Mi=Symbol.for("wcstack.state.ssr.impl"),Pi=new Map,Ei=new WeakMap,Wi=t=>!0===e.Eo?.(t),Ri=e=>1===e.nodeType&&!Ti(e)&&!Wi(e),Ii=e=>e.f.flat().concat(e.q??[]),Di=e=>{for(let t of Ii(e))t.remove()};function Li(e,t,n){let r=/^wcs-\[(?::(\d+))?/.exec(e.data),l=e.previousSibling,i=e.parentNode,s=[],o=e.nextSibling;for(e.remove();null!==o&&!fi(o,"wcs-]");){let e=o.nextSibling;if(fi(o,"wcs-|"))s.push([]),o.remove();else{0===s.length&&s.push([]);let n=s[s.length-1];hi(o,"wcs-[")?e=Li(o,t,n):(n.push(o),Ri(o)&&qi(o,t))}o=e}let a={branch:void 0===r[1]?null:Number(r[1]),f:s,q:o??i.appendChild(ci("wcs-]"))},u=Ii(a);o=a.q.nextSibling;for(let e of u)n?.push(e),t&&Ot.add(e);return t&&null!==l?Pi.set(l,a):Di(a),o}function qi(e,t){for(let n=e.firstChild;null!==n;)hi(n,"wcs-[")?n=Li(n,t):(Ri(n)&&qi(n,t),n=n.nextSibling)}function zi(e,t,n){let r=e=>{for(let l of Array.from(e.childNodes))if(l.parentNode===e)if(8===l.nodeType){let e=l.data;try{if("wcs-s"===e)l.remove();else if("wcs-e"===e)l.replaceWith("");else if(e.startsWith("wcs-t:")){let t=ci(`@@:${decodeURIComponent(e.slice(6))}`),n=l.nextSibling;for(;null!==n&&!fi(n,"wcs-/t");){let e=n.nextSibling;n.remove(),n=e}n?.remove(),l.replaceWith(t)}else if(e.startsWith("wcs-p:")){let n=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==n){let t=l.parentNode,r="s"===e[10]?vi(n,document.createElementNS(t.namespaceURI,"template"),...document.importNode(n.content.firstChild,!0).childNodes):document.importNode(n,!0);r.removeAttribute("id"),t.replaceChild(r,l)}}}catch{}}else 1===l.nodeType&&!Ti(l)&&(Wi(l)?Ei.set(l,{ssr:t,Oe:n}):r(l))};r(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let n=t.previousSibling;null!==n&&(8===n.nodeType||Ki(n)||"template"===n.localName);n=n.previousSibling)e.unshift(n);let n=0,r=0;if(e.forEach((e,t)=>{hi(e,"wcs-[")?r++:fi(e,"wcs-]")&&--r<0&&(r=0,n=t+1)}),0===r)continue;let l=0;for(let r=t.firstChild;null!==r;r=r.nextSibling)if(hi(r,"wcs-["))l++;else if(fi(r,"wcs-]")&&0===l--){t.prepend(...e.slice(n));break}}}(e),qi(e,n)}function Fi(t){let n=Ei.get(t);if(void 0===n||(Ei.delete(t),zi(t,n.ssr,n.Oe),!n.Oe))return null;let r=e.Oe;return e.Oe=Gi,()=>{e.Oe=r,Ui()}}function Ui(){for(let e of Pi.values())Di(e);Pi.clear()}function _i(e){let t=[];for(let n=document.createTreeWalker(e,128);n.nextNode();)t.push(n.currentNode);return t}function Vi(e,t,n,r){let l=null;for(let r of e){let e=r[n];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===l||e.length>l[n].length)&&(l=r)}let i=l?.[r];if(null==i)return null;let s=l[n],o=""===s?t:t.slice(s.length+1);return""===i?o:""===o?i:`${i}.${o}`}function Bi(e,t,n){if(ui()){if(n instanceof Array){for(let e=n.length;e-- >0;)vt(n[e])&&n.splice(e,1);let e=t;if(n.some($t))gi.add(e);else if(e.localName.includes("-")&&!Wi(e)){let t=new Map;for(let n=document.createTreeWalker(e,133);n.nextNode();)t.set(n.currentNode,n.currentNode.data);mi.set(e,t)}return}if("string"==typeof n){if(yi.set(t,n),Ti(t.parentNode))return;let e=ci(`wcs-t:${encodeURIComponent(n)}`),r=ci("wcs-/t");return t.before(e),void t.after(r)}let r=di.get(e);void 0===r&&di.set(e,r=new Map),r.set(t,n);let l=t.getRootNode(),i=pi.get(l);return void 0===i&&pi.set(l,i=new Set),void i.add(e)}if("string"!=typeof n&&Pi.size>0){let e=Pi.get(n);void 0!==e&&(Pi.delete(n),Pi.set(t,e))}}var Hi=e=>null!==e&&8===e.nodeType&&[le.commentIfPrefix,le.commentElseIfPrefix,le.commentElsePrefix].includes(e.data),Ki=e=>3===e.nodeType&&""===e.data.trim(),Ji=e=>(Pi.get(e)?.q??e).nextSibling;function Yi(e,t){if(t.length!==e.sn.childNodes.length)return!1;let n=e.On;for(let r=0;r<n.length;r++){let l=n[r],i=e.sn,s=t[l[0]];for(let e=0;;){if(i=i.childNodes[l[e]],s?.nodeName!==i.nodeName)return!1;if(++e===l.length)break;s=s.firstChild;for(let t=l[e];t>0&&null!==s;t--)s=Ji(s)}e.So[r]=s}return!0}function Gi(e,t,n){if(0===Pi.size)return null;let r=t,l=0;if(!n){let e=le.commentIfPrefix;if(!fi(t,e))for(let n=t.previousSibling;null!==n&&1!==n.nodeType&&(Hi(n)&&l++,!fi(n,e));n=n.previousSibling);for(let n=t.nextSibling;!Pi.has(r)&&null!==n&&!fi(n,e)&&1!==n.nodeType;n=n.nextSibling)Hi(n)&&(r=n)}let i=Pi.get(r);if(void 0===i)return null;if(!n&&i.branch!==l)return Pi.delete(r),Di(i),null;let s=i.f.shift();if(0===i.f.length&&Pi.delete(r),i.q?.replaceWith(...bi(t,r)),i.q=null,void 0===s)return null;let o=[];for(let e=0;e<s.length;e++){let t=Pi.get(s[e]);if(o.push(s[e]),void 0!==t)for(;e<s.length&&s[e]!==t.q;)e++}if(!Yi(e,o)){let n=(e.In?e.root:e.sn).cloneNode(!0);o=e.In?[n]:[...n.childNodes],Yi(e,o),(s[0]??i.f.find(e=>e.length>0)?.[0]??t).before(n);for(let e of s)e.remove()}return o}var Xi={name:"ssr",install(){e.Mn=Bi,e.hr=Fi;let n=e.element;e.element=(t,r)=>{"mounting"===r&&function(t){let n=t.element;if(!n.hasAttribute("enable-ssr")||ui())return;let r=n.previousElementSibling,l=r?.localName===oi(),i=l?r.getAttribute("version"):null,s=null===i||li(i)===li(ri);if(s){let e=t,n=e.ke;e.ke=(e,r)=>"$connectedCallback"===e?void 0:n.call(t,e,r)}if(!l)return;let o=!s&&parseInt(i)<4,a=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==a&&(+a[1]-5||+a[2]-3)>=0;s||console.warn(`[@wcstack/state] <${oi()} version="${i}"> does not match ${ri}: its snapshot is discarded, and the page renders on the client from its own state.${o&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let c=s?r.querySelector('script[type="application/json"]'):null;if(null!==c){let e=JSON.parse(c.textContent||"{}"),n=t.target;for(let t of Object.keys(e)){let r=Object.getOwnPropertyDescriptor(n,t);void 0!==r&&(void 0!==r.get||void 0!==r.set||"function"==typeof r.value)||(n[t]=e[t])}t.hydrated=!0}let f=n.getRootNode();for(let e of Array.from(f.querySelectorAll(`[${Si}]`)))e.textContent=e.getAttribute(Si),e.removeAttribute(Si);let h=9===f.nodeType?f.body:f;o?function(e,t,n){let r=new Map,l=e=>{let t=e.parentElement;for(;null!==t&&!Wi(t);)t=t.parentElement;if(null===t)return null;let n=r.get(t);if(void 0===n){let e=l(t),i=t.querySelector(`:scope > ${le.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,n=[]);for(let r of ce(t.getAttribute(le.bindAttributeName)??"")){let t=r.Qe;r.$e[0]===i&&n.push([e?Vi(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return n},i=(e,t,n)=>{let r=l(e);if(null===r)return t;let i=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===i)return n?t:Vi(r,t,0,1)??t;let s=i[1].replace(/#m\d+\./g,"").slice(0,-1);return r.some(e=>""===e[1]&&(e[0]===s||e[2]===s))?i[2]:Vi(r,i[2],2,1)??i[2]};for(let t of _i(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let r=t.nextSibling;for(;null!==r&&!fi(r,`@@wcs-${e[1]}-end:${e[2]}`);)r=r.nextSibling;if(null!==r){for(;t.nextSibling!==r;)t.nextSibling.remove();r.remove(),t.replaceWith(..."text"===e[1]?[ci(`@@:${i(t,e[2],n)}`)]:[])}}let s=(e,n)=>{for(let r of _i(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(r.data)?.[1],l=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===l)continue;let o=document.importNode(l,!0),a=le.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,l)=>t+i(n??r,l))),s(o.content,n??r);let u=o.content.firstChild;r.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(h,r,u):zi(h,r,s),r.remove(),s&&(e.Oe=Gi,queueMicrotask(()=>{Ui(),e.Oe=null}))}(t),n?.(t,r)},function(){let e=globalThis;e[Mi]={build:Ci,reset(){ji=0}},void 0===e[ai]&&(e[ai]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[Mi].build(t),reset:()=>e[Mi].reset()})}(),e.Ao=t(e.Ao,si);for(let e of nn())si(e)}},Qi="__WCSTACK_DEVTOOLS_HOOK__",Zi=null,es=new Set,ts=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),ns=new WeakMap,rs=0;var ls=new WeakMap;function is(e){if(null===Zi)return;let t=ls.get(e),n=es.has(e)?function(e,t){let n=new Map,r=new Set,l=(r,l,i,s,o,a)=>{if(5===r)return;let u=function(e,t){return 0===e?"textContent":2===e?`class.${t}`:3===e?`attr.${t}`:4===e?`style.${t}`:t}(r,l),c=0===s.n?null:o,f=`${(e=>{let t=ns.get(e);return void 0===t&&ns.set(e,t=++rs),t})(i)}|${u}|${s.t}|${null===c?"":e.H(c).join(",")}`;if(n.has(f))return;let h=t?.get(f);n.set(f,h??{binding:{propName:u,statePathName:s.t,bindingType:a,node:i,replaceNode:i},absoluteAddress:ts(e,s,c)})},i=e=>l(e.i,e.name,e.a,e.o,e.r,e.nn()),s=e=>{if(!r.has(e)){if(r.add(e),null!==e.ye)for(let t of e.ye)i(t);if(e instanceof et&&null!==e.pe){let t=e.F.ze;for(let n=0;n<t.length;n++){let r=e.V?.[n];void 0!==r?i(r):l(t[n].i,t[n].name,e.pe[2*n],t[n].o,e.r,0===t[n].i?"text":"prop")}}if(null!==e.c)for(let t of e.c)o(t)}},o=e=>{if(!r.has(e))if(r.add(e),e instanceof ct){l(-1,"for",e.S,e.l.o,e.l.ae,"for");for(let t of e.Re)s(t)}else null!==e.O&&s(e.O)};for(let t of e.ue.values())for(let e of t)i(e),null!==e.W&&o(e.W);for(let t of e.oe.values())if(null!==t.$&&o(t.$),null!==t.j)for(let e of t.j)o(e);return n}(e,t):new Map;if(void 0!==t)for(let[e,r]of t)n.has(e)||Zi({type:"state:binding-removed",...r});for(let[e,r]of n)(void 0===t||!t.has(e))&&Zi({type:"state:binding-added",...r});ls.set(e,n)}function ss(e){let t=Lt.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function os(e){let t=new Set,n=new Set,r=new Set,l=new Set;for(let i of e.I.all()){for(let e=1;e<=i.n;e++)t.add(i.h[e].t);"*"===i.s&&n.add(i.t),null!==i.getter&&r.add(i.t),null!==i.ie&&l.add(i.t)}let i=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:r,setter:l},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.ce.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==i.$watch&&"object"==typeof i.$watch?new Set(Object.keys(i.$watch)):null,keyedListPaths:null!==i.$listKeys&&"object"==typeof i.$listKeys?new Set(Object.keys(i.$listKeys)):null}}var as=new WeakSet,us=new WeakMap;function cs(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(as.has(t))return;as.add(t);let r=t.emit;t.emit=(...l)=>(null!==Zi&&Zi({type:"state:token-emit",kind:n,tokenName:t.name,args:l,subscriberCount:t.size,stateElement:e.element}),r.apply(t,l))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.ce.values())t(n,"event")}(e),"connected"===t){if(es.has(e))return;es.add(e),Zi?.({type:"state:element-registered",rootNode:e.root,element:e.element}),is(e)}else"disconnected"===t&&(es.delete(e),is(e),Zi?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function fs(e,t,n,r,l,i){if(null===Zi)return;let s=ts(e,t,0===t.n?null:n),o=us.get(e);void 0===o&&us.set(e,o=new Set),o.add(s),i&&Zi({type:"state:write",absoluteAddress:s,value:l,oldValue:r,hasOldValue:!0})}function hs(e){if(null===Zi)return;let t=us.get(e);us.delete(e),void 0!==t&&Zi({type:"state:update-batch",addresses:t}),is(e)}function ds(e,t,n){Zi?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.nn(),error:t})}var ps={"*":["focus","blur","click","scrollIntoView","showPopover","hidePopover","togglePopover"],dialog:["show","showModal","close","requestClose"],form:["requestSubmit","checkValidity","reportValidity"],input:["select","setSelectionRange","showPicker","setCustomValidity","checkValidity","reportValidity"],textarea:["select","setSelectionRange","setCustomValidity","checkValidity","reportValidity"],select:["showPicker","setCustomValidity","checkValidity","reportValidity"],audio:["play","pause","load"],video:["play","pause","load"]};function ms(e,t){let n=e.localName;if(n.includes("-"))return null;let r=(e=>[...ps["*"],...Object.hasOwn(ps,e)?ps[e]:[]])(n);return r.includes(t)||w(1205,[n,t,r.join(", ")],t,r),(e,n)=>e[t](...n[0]instanceof Event?[]:n)}var gs=[kn,er,Sr,Er,Fl,ni,Xi,{name:"devtools",install(){e.element=t(e.element,cs),e.ve=t(e.ve,fs),e.Fe=t(e.Fe,hs),e.Ke=t(e.Ke,ds),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[Qi]??(t[Qi]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let r of t)r.onEvent?.(e.id,n)})};return{version:2,sources:e,register(r){if(!e.has(r.id)){e.set(r.id,r),n(r);for(let e of t)e.onSourceRegistered?.(r)}},unregister(n){let r=e.get(n);if(void 0!==r){r._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(r){t.add(r);for(let t of e.values())n(t),r.onSourceRegistered?.(t);return()=>{if(t.delete(r))for(let t of e.values())n(t)}}}}());2!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:ri,getStateElements:()=>[...es].map(os),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.I.all()){let r=n._,l=n.Ce?.length??0;if((null===r||0===r.size)&&0===l)continue;let i,s=0;if(null!==r)for(let e of r.values())s+=e.size;try{i=0===n.n?e.v(n,null):void 0}catch{i=void 0}t.push({path:n.t,tracked:!1,rows:s,keys:null===r?0:r.size,lists:l,lastValue:i})}return t}(ss(e)),keys(e){let t=ss(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let r;return ss(e).element.createState("readonly",e=>{r=e.$resolve(t,n??[])}),r},write(e,t,n,r){ss(e).element.createState("writable",e=>{e.$resolve(t,r??[],n)})},_setSink(t){let n=null===Zi&&null!==t;Zi=t,null===t&&(ls=new WeakMap),e.st=t&&((e,t)=>Zi?.({...t,stateElement:e.element})),n&&queueMicrotask(()=>{for(let e of es)is(e)})}})}()}},{name:"native-commands",install(){e.or=ms}}];function ys(e){return e}var bs=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],vs={eq:{description:"等しいか比較",hasArgs:!0,resultType:"boolean",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},ne:{description:"異なるか比較",hasArgs:!0,resultType:"boolean",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},not:{description:"真偽性を反転(falsy → true)",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},lt:{description:"より小さいか",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},le:{description:"以下か",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},gt:{description:"より大きいか",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},ge:{description:"以上か",hasArgs:!0,resultType:"boolean",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["number"]},add:{description:"加算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},sub:{description:"減算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},mul:{description:"乗算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},div:{description:"除算",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},mod:{description:"剰余",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:1,maxArgs:1,argTypes:["number"]},abs:{description:"絶対値",hasArgs:!1,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:0},clamp:{description:"範囲内に丸める (min,max)",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:2,maxArgs:2,argTypes:["number","number"]},toFixed:{description:"固定小数点表記",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},locale:{description:"ロケール形式で数値フォーマット",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["string"]},upper:{description:"大文字に変換",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},lower:{description:"小文字に変換",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},capitalize:{description:"先頭文字を大文字に",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},trim:{description:"前後の空白を削除",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},slice:{description:"部分文字列 (start[,end])",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","number"]},padStart:{description:"先頭を埋める (length[,char]。char の既定は 0 — JS の既定は空白なので注意)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},padEnd:{description:"末尾を埋める (length[,char]。char の既定は空白 — JS と同じ)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},repeat:{description:"繰り返し (count)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:1,argTypes:["number"]},reverse:{description:"文字順を反転",hasArgs:!1,resultType:"string",acceptTypes:["string"],minArgs:0,maxArgs:0},truncate:{description:"切り詰めて省略記号 (length[,suffix]。suffix の既定は … — U+2026 の 1 文字)",hasArgs:!0,resultType:"string",acceptTypes:["string"],minArgs:1,maxArgs:2,argTypes:["number","string"]},join:{description:"配列を連結 ([separator]。既定はカンマ + 空白)",hasArgs:!0,resultType:"string",acceptTypes:["array"],minArgs:0,maxArgs:1,argTypes:["string"]},int:{description:"整数にパース",hasArgs:!1,resultType:"number",acceptTypes:["string","number"],minArgs:0,maxArgs:0},float:{description:"浮動小数点数にパース",hasArgs:!1,resultType:"number",acceptTypes:["string","number"],minArgs:0,maxArgs:0},round:{description:"四捨五入",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},floor:{description:"切り下げ",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},ceil:{description:"切り上げ",hasArgs:!0,resultType:"number",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},percent:{description:"パーセンテージ形式",hasArgs:!0,resultType:"string",acceptTypes:["number"],minArgs:0,maxArgs:1,argTypes:["number"]},unit:{description:"単位(接尾辞)を付加",hasArgs:!0,resultType:"string",acceptTypes:["number","string"],minArgs:1,maxArgs:1,argTypes:["string"]},date:{description:"ロケール形式の日付 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},time:{description:"ロケール形式の時刻 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},datetime:{description:"ロケール形式の日時 ([locale]。既定は config.locale)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},ymd:{description:"YYYY-MM-DD 形式 ([separator]。既定は -)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},hms:{description:"HH:MM:SS 形式 ([separator]。既定は :)",hasArgs:!0,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:1,argTypes:["string"]},falsy:{description:"偽値か判定",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},truthy:{description:"真値か判定",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},defaults:{description:"偽値の場合デフォルト値",hasArgs:!0,resultType:"passthrough",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},coalesce:{description:"null / undefined の場合デフォルト値",hasArgs:!0,resultType:"passthrough",acceptTypes:"any",minArgs:1,maxArgs:1,argTypes:["any"]},boolean:{description:"ブール値に変換",hasArgs:!1,resultType:"boolean",acceptTypes:"any",minArgs:0,maxArgs:0},number:{description:"数値に変換",hasArgs:!1,resultType:"number",acceptTypes:"any",minArgs:0,maxArgs:0},string:{description:"文字列に変換",hasArgs:!1,resultType:"string",acceptTypes:"any",minArgs:0,maxArgs:0},nullIfEmpty:{description:"空文字列をnullに変換",hasArgs:!1,resultType:"passthrough",acceptTypes:["string"],minArgs:0,maxArgs:0}},$s=2,ws=Object.freeze({}),As=Object.freeze({}),ks=Object.freeze({}),xs=Object.freeze(["prevent","stop","ro","direct"]),Ss=Object.freeze(["init","sync"]),Ts=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function Ns(){return{version:2,syntax:{bindAttribute:le.bindAttributeName,tagName:le.tagNames.state,pathDelimiter:".",wildcard:"*",delimiters:{binding:";",propValue:":",modifier:"#",filter:"|"},structuralDirectives:Array.from(oe),modifiers:{flags:xs,keyValue:Ss,eventNamePrefix:"on"},indexParam:{prefix:"$",maxDepth:128},bindingTypes:{elseKeyword:N,spread:"...",eventPropertyPrefix:"on",explicitPropertyPrefix:".",propNamespaces:{eventToken:j,command:O,class:C,attr:M,style:P}}},filters:[...Object.keys(Se),...Object.keys(wn)],filterMeta:vs,filterAliases:ws,declarationAliases:As,apiAliases:ks,reservedLifecycle:["$connectedCallback","$disconnectedCallback","$renderedCallback","$errorCallback","$stateReadyCallback"],reservedStateApi:["$bindables","$commands","$commandTokens","$command","$eventTokens","$on","$stream","$watch","$listKeys","$recursion","$streamStatus","$streamError","$behavior","$features"],behaviorOptions:Object.fromEntries(Ts.map(e=>[e,{type:"boolean",default:!0}])),features:[...bs],nativeCommands:Object.fromEntries(Object.entries(ps).map(([e,t])=>[e,[...t]]))}}var js=new Set(["wcstack.types","wcstack.async","wcstack.platformCapabilities","wcstack.application"]),Os=Object.freeze([]);function Cs(e){if(!le.enableContractAnalyzer)return Os;let t=[],n=Zi,r=e=>{t.push(e),n?.(e)},l=e.manifestExtensions;if(null===l||"object"!=typeof l)return t;for(let e of Object.keys(l))js.has(e)||r({type:"contract:unsupported-extension",namespace:e});let i=l["wcstack.types"]?.components;if(null==i)return t;for(let[e,t]of Object.entries(i)){let n=Ms(e);if(r({type:"contract:manifest-read",tag:e,loaded:null!==n}),null===n){r({type:"contract:drift",reason:"component-not-loaded",tag:e});continue}let l=null!==t&&"object"==typeof t?t:{};for(let[t,i]of Object.entries(l.observables??{})){let l=n.ce.get(t);if(void 0===l){r({type:"contract:drift",reason:"missing-member",tag:e,member:t});continue}let s=i?.event;"string"==typeof s&&s!==l&&r({type:"contract:drift",reason:"event-mismatch",tag:e,member:t,sidecarEvent:s,liveEvent:l})}for(let t of Object.keys(l.inputs??{}))n.inputs.has(t)||r({type:"contract:drift",reason:"missing-member",tag:e,member:t});for(let t of Object.keys(l.commands??{}))n.commands.has(t)||r({type:"contract:drift",reason:"missing-member",tag:e,member:t})}return t}function Ms(e){let t=customElements.get(e)?.wcBindable;if(null===t||"object"!=typeof t||"wc-bindable"!==t.protocol)return null;let n=e=>Array.isArray(e)?e:[],r=new Map;for(let e of n(t.properties))"string"==typeof e?.name&&"string"==typeof e.event&&r.set(e.name,e.event);let l=e=>new Set(n(e).map(e=>e?.name).filter(e=>"string"==typeof e));return{ce:r,inputs:l(t.inputs),commands:l(t.commands)}}function Ps(e,t){(function(e){for(let t of e)s.has(t.name)||(s.add(t.name),t.install())})(gs),rn(e,t)}export{ii as Ssr,Oe as TRUSTED_TYPES_POLICY_SLOT,ri as VERSION,$s as WCS_MANIFEST_VERSION,Cs as analyzeContract,Ps as bootstrapState,sn as buildBindings,ws as builtinFilterAliases,vs as builtinFilterMeta,ys as defineState,Qt as getBindingsReady,ie as getConfig,Ce as getTrustedTypesPolicy,Ns as getWcsManifest,Me as setTrustedTypesPolicy};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|