@wcstack/state 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.ja.md +17 -8
  2. package/README.md +17 -7
  3. package/dist/auto.min.js +1 -1
  4. package/dist/auto.min.js.map +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/split/auto.js +1 -1
  8. package/dist/split/chunks/chunk-467LYA2V.js +2 -0
  9. package/dist/split/chunks/chunk-467LYA2V.js.map +1 -0
  10. package/dist/split/chunks/{chunk-6I7GGFNJ.js → chunk-CBMAVRYG.js} +2 -2
  11. package/dist/split/chunks/chunk-DUUQZITD.js +2 -0
  12. package/dist/split/chunks/{chunk-M67C46SN.js.map → chunk-DUUQZITD.js.map} +1 -1
  13. package/dist/split/chunks/{chunk-2RBI6DVS.js → chunk-FBBHQU7S.js} +2 -2
  14. package/dist/split/chunks/chunk-GBBBRPZR.js +2 -0
  15. package/dist/split/chunks/{chunk-DOWWBZVS.js.map → chunk-GBBBRPZR.js.map} +1 -1
  16. package/dist/split/chunks/chunk-JWRQLKOQ.js +2 -0
  17. package/dist/split/chunks/chunk-NITPUCPA.js +2 -0
  18. package/dist/split/chunks/{chunk-CIBJLAA3.js → chunk-T3FN37DU.js} +2 -2
  19. package/dist/split/chunks/{chunk-BGUJ3HF6.js → chunk-TNYNJXEC.js} +2 -2
  20. package/dist/split/chunks/chunk-TNYNJXEC.js.map +1 -0
  21. package/dist/split/chunks/{chunk-BKLFDVOP.js → chunk-ULMHOGJ2.js} +2 -2
  22. package/dist/split/chunks/chunk-ZJYPRSTO.js +2 -0
  23. package/dist/split/core.js +1 -1
  24. package/dist/split/features/devtools.js +1 -1
  25. package/dist/split/features/diagnostics.js +1 -1
  26. package/dist/split/features/diagnostics.js.map +1 -1
  27. package/dist/split/features/formats.js +1 -1
  28. package/dist/split/features/list-keys.js +1 -1
  29. package/dist/split/features/native-commands.js +1 -1
  30. package/dist/split/features/recursion.js +1 -1
  31. package/dist/split/features/scopes.js +1 -1
  32. package/dist/split/features/scopes.js.map +1 -1
  33. package/dist/split/features/ssr.js +1 -1
  34. package/dist/split/features/ssr.js.map +1 -1
  35. package/dist/split/features/temporal.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/split/chunks/chunk-5Q4M6A3C.js +0 -2
  38. package/dist/split/chunks/chunk-BGUJ3HF6.js.map +0 -1
  39. package/dist/split/chunks/chunk-DOWWBZVS.js +0 -2
  40. package/dist/split/chunks/chunk-F3DVWVH3.js +0 -2
  41. package/dist/split/chunks/chunk-M67C46SN.js +0 -2
  42. package/dist/split/chunks/chunk-NMOSSDKJ.js +0 -2
  43. package/dist/split/chunks/chunk-NMOSSDKJ.js.map +0 -1
  44. package/dist/split/chunks/chunk-UBGJGMSG.js +0 -2
  45. /package/dist/split/chunks/{chunk-6I7GGFNJ.js.map → chunk-CBMAVRYG.js.map} +0 -0
  46. /package/dist/split/chunks/{chunk-2RBI6DVS.js.map → chunk-FBBHQU7S.js.map} +0 -0
  47. /package/dist/split/chunks/{chunk-UBGJGMSG.js.map → chunk-JWRQLKOQ.js.map} +0 -0
  48. /package/dist/split/chunks/{chunk-5Q4M6A3C.js.map → chunk-NITPUCPA.js.map} +0 -0
  49. /package/dist/split/chunks/{chunk-CIBJLAA3.js.map → chunk-T3FN37DU.js.map} +0 -0
  50. /package/dist/split/chunks/{chunk-BKLFDVOP.js.map → chunk-ULMHOGJ2.js.map} +0 -0
  51. /package/dist/split/chunks/{chunk-F3DVWVH3.js.map → chunk-ZJYPRSTO.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ var t=class{constructor(t,l,e){this.u=[],this.getter=null,this.se=null,this.ae=!1,this.B=[],this.Q=[],this.mt=null,this.F=-1,this.Y=s,this.je=null,this.Dt=null,this.jt=null,this._=null,this.pn=!1,this.mn=!1,this.hn=!1,this.Z=0,this.ht=new Set,this.t=t,this.c=e,this.s=l;let h=null===e?[null]:e.h.slice(),i="*"===l;i&&h.push(e),this.n=h.length-1,this.z=i?[]:null===e?[l]:[...e.z,l],this.h=h}_n(t){this.ht.has(t)||(this.ht.add(t),this.B.push(t),t.Q.push(this))}Do(t){this.ht.delete(t);let s=this.B;s.splice(s.indexOf(t),1)}jo(){this.getter=null,this.se=null,this.F=-1,this.Y=s,this.B.length=0,this.ht.clear(),this.Q.length=0,this.mt=null,this.je=null,this.Dt=null,this.jt=null,this._=null}ee(t){let s=this;for(;null!==s;){if(s===t)return!0;s=s.c}return!1}},s=Symbol("unset"),l=Symbol("dirty"),e=Symbol("failed"),h=class{constructor(t=null){this.yt=new Map,this.Vn=t}wt(t){return this.yt.get(t)}get(s){let l=this.yt.get(s);if(void 0!==l)return l;let e=s.lastIndexOf("."),h=e<0?null:this.get(s.slice(0,e));return l=new t(s,s.slice(e+1),h),this.Vn?.(l),this.yt.set(s,l),h&&h.u.push(l),l}all(){return this.yt.values()}Lt(t){this.yt.delete(t.t)}},i=new Map;function n(t){let s=i.get(t);if(void 0!==s)return s;let l=!0,e=t.split("."),h=[];for(let t=0;t<e.length;t++){let s=e[t],i=s.charCodeAt(0);t>0&&i>=48&&i<=57?(l=!1,h.push(Number(s)),e[t]="*"):"*"===s&&h.push(-1)}if(!l)return{o:e.join("."),indexes:h};let n={o:t,indexes:null};return i.size>4095&&i.clear(),i.set(t,n),n}export{s as a,l as b,e as c,h as d,n as e};
2
+ //# sourceMappingURL=chunk-NITPUCPA.js.map
@@ -1,2 +1,2 @@
1
- import{b as t}from"./chunk-UBGJGMSG.js";import{j as e}from"./chunk-BGUJ3HF6.js";var a={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};function r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["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","currency"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
2
- //# sourceMappingURL=chunk-CIBJLAA3.js.map
1
+ import{b as t}from"./chunk-JWRQLKOQ.js";import{j as e}from"./chunk-TNYNJXEC.js";var a={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};function r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["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","currency"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
2
+ //# sourceMappingURL=chunk-T3FN37DU.js.map
@@ -1,2 +1,2 @@
1
- var t={};function a(t,a){return null==t?a:(...e)=>{t(...e),a(...e)}}function e(t,a,e){return null==a?e:(...n)=>{let r=a(...n);return t(r)?r:e(...n)}}var n=t=>!0===t,r=t=>void 0!==t,s=t=>null!=t,l=new Set;function o(t){for(let a of t)l.has(a.name)||(l.add(a.name),a.install())}function u(a){let e=a.$features;if(null!=t.bt&&Array.isArray(e)){let a=e.filter(t=>!l.has(t));if(a.length>0)return t.bt(a)}}function f(t,a){if(!l.has(t))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${a} needs the add-on @wcstack/state/features/${t}`)}function i(a,e,n){throw new Error(`[@wcstack/state] ${a}${t.Lo?.(a,e,n)??""}`)}export{t as a,a as b,e as c,n as d,r as e,s as f,o as g,u as h,f as i,i as j};
2
- //# sourceMappingURL=chunk-BGUJ3HF6.js.map
1
+ var t={};function a(t,a){return null==t?a:(...e)=>{t(...e),a(...e)}}function e(t,a,e){return null==a?e:(...n)=>{let r=a(...n);return t(r)?r:e(...n)}}var n=t=>!0===t,r=t=>void 0!==t,s=t=>null!=t,l=new Set;function o(t){for(let a of t)l.has(a.name)||(l.add(a.name),a.install())}function u(a){let e=a.$features;if(null!=t.kt&&Array.isArray(e)){let a=e.filter(t=>!l.has(t));if(a.length>0)return t.kt(a)}}function f(t,a){if(!l.has(t))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${a} needs the add-on @wcstack/state/features/${t}`)}function i(a,e,n){throw new Error(`[@wcstack/state] ${a}${t.Bo?.(a,e,n)??""}`)}export{t as a,a as b,e as c,n as d,r as e,s as f,o as g,u as h,f as i,i as j};
2
+ //# sourceMappingURL=chunk-TNYNJXEC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hooks","chain","prev","fn","a","first","answered","r","handled","known","taken","installed","Set","installFeatures","features","f","has","name","add","install","loadFeatures","state","names","$features","load","Array","isArray","missing","filter","n","length","requireFeature","feature","what","Error","raiseError","message","subject","candidates","explain","i","d","s","u","g","c","m","w","v"],"sources":["../../../src/hooks.ts","../../../src/parser/raiseError.ts"],"sourcesContent":["/**\n * The places the core calls into add-ons (docs/state-engine-rewrite/addons-plan.ja.md §1.2).\n *\n * Add-ons ship as separate entries of the same build as the core (`features/*`): they reach\n * the core's internals directly, and the core only calls out through these slots. A slot is\n * empty until an installed feature fills it (the object starts with none: a list of null slots\n * would be the core's bytes), so a page without the feature pays one `?.` check. A feature\n * restoring a slot may set it to null.\n * Slots are added with the first feature that needs them; several features share one through\n * chain / first. The slots `element` and `detail` keep their names (a DevTools-facing field and a DOM\n * name share them); the others are shortened by the build. An empty slot is read through\n * Object.prototype: a page that polluted it (a value under `element`, say) breaks the core loudly\n * there, as it does wherever the core reads a plain object's keys (`$behavior`); not defended.\n */\nimport type { Engine } from \"./engine\";\nimport type { Pattern } from \"./pattern\";\nimport type { StateList, StateRow } from \"./list\";\nimport type { Binding, RowPlan, Spec } from \"./dom/view\";\n\nexport interface Hooks {\n /** Diagnostics: extra text for an error message (did-you-mean, lint pointer, how to fix). */\n explain?: ((message: string, subject?: string, candidates?: Iterable<string>) => string) | null;\n /** Diagnostics: the full sentence of a numbered core message (`src/messages.ts`). */\n render?: ((id: number, args: readonly unknown[]) => string) | null;\n /**\n * A write before it is applied (`element`: an element wrote it back, not code); true = the\n * add-on handled it ($listKeys, a read-only mount dropping an element's write).\n */\n beforeWrite?: ((engine: Engine, p: Pattern, row: StateRow | null, value: unknown, element: boolean) => boolean) | null;\n /** A write landed: `direct` for a data write (then `old` is the value before, `value` the new one). */\n /** `element`: an element wrote it (a binding's write-back or its initial value), not code. */\n written?: ((engine: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean, element?: boolean) => void) | null;\n /** A change reached a getter occurrence whose cached value was current (it may now differ). */\n getterReached?: ((engine: Engine, g: Pattern, row: StateRow | null) => void) | null;\n /** A list was reconciled with a new value; `old` are its rows before. */\n listSynced?: ((engine: Engine, list: StateList, old: StateRow[]) => void) | null;\n /** A drain ended (after its report and `$renderedCallback`). */\n drained?: ((engine: Engine) => void) | null;\n /** A state object was received (construction, or a re-set before it replaces the old one). */\n declare?: ((engine: Engine, target: Record<string, any>) => void) | null;\n /**\n * A root engine's lifecycle: \"mounting\" (created, its page not bound yet), \"back\" (its `<wcs-state>`\n * connected again, before `$connectedCallback` runs again: it holds its root again, unless another\n * one bound it meanwhile), \"connected\" (after `$connectedCallback`, and on reconnect), \"disconnected\",\n * \"reset\" (after a re-set).\n */\n element?: ((engine: Engine, phase: \"mounting\" | \"back\" | \"connected\" | \"disconnected\" | \"reset\") => void) | null;\n /**\n * A `<wcs-state>` an add-on takes over instead of it becoming a root (a volume, a DCC\n * definition): asked when it connects; the core then only loads its state.\n */\n claim?: ((el: HTMLElement, root: Node) => Claimed | null) | null;\n /** A `$` name the core does not know. */\n dollar?: ((engine: Engine, key: string) => unknown) | null;\n /** A binding failed to apply (reported after the drain, before `$errorCallback` / the console). */\n failed?: ((engine: Engine, error: unknown, binding: Binding) => void) | null;\n /**\n * A plain property binding on a custom element, made and not yet registered or applied (a\n * component mount's wiring, `state.x: path`); true = an add-on took it over.\n */\n hostBinding?: ((binding: Binding, ro: boolean) => boolean) | null;\n /** An element whose content an add-on binds (a Light DOM component): the walker leaves it. */\n componentScope?: ((el: Element) => boolean) | null;\n /**\n * The page walker replaced a structural template with its anchor (`source` is the template),\n * bound a mustache text node (`source` is its expression), or is about to bind an element\n * (`source` is its specs, which the hook may take some out of): SSR records the first two, and\n * on the server leaves `outerHTML:` to the client.\n */\n ssrMark?: ((engine: Engine, node: Node, source: Element | string | Spec[]) => void) | null;\n /**\n * A block is about to be cloned from `plan` for the view anchored at `anchor`: an add-on may\n * hand over existing nodes instead (SSR hydration) — the block's top-level nodes, already where\n * the block renders (the view inserts nothing), with the plan's nodes in them in `plan.scratch`.\n */\n adopt?: ((plan: RowPlan, anchor: Node, isFor: boolean) => ChildNode[] | null) | null;\n /**\n * A Light DOM component's engine is about to bind `root` (its host): SSR hands over the server's\n * nodes there too; the function returned is called when the walk is done.\n */\n adoptScope?: ((root: Node, engine: Engine) => (() => void) | null) | null;\n /** A path a binding (or, with `watch`, a `$watch` key) names: diagnostics checks it exists. */\n declared?: ((engine: Engine, p: Pattern, watch?: boolean) => void) | null;\n /** `<wcs-state>` was defined in `registry`: an add-on defines its own tags there (`<wcs-ssr>`). */\n tags?: ((registry: CustomElementRegistry) => void) | null;\n /** A wc-bindable property's event read with the default getter (`e.detail`): diagnostics checks its shape. */\n detail?: ((el: Element, name: string, detail: unknown) => void) | null;\n /** The handler `path` of a delegated `on<type>:` threw (reported already): diagnostics says when `currentTarget` is why. */\n handlerThrew?: ((engine: Engine, path: string, type: string) => void) | null;\n /**\n * `command.<method>:` on an element with no wc-bindable declaration: how a native element's\n * method is called (native-commands), or null for a custom element. The add-on throws for a\n * method a native element may not be commanded to run.\n */\n nativeCommand?: ((el: Element, method: string) => NativeCall | null) | null;\n /** The split auto entry: loads and installs add-ons of its build by name (a state's `$features`). */\n load?: ((names: string[]) => Promise<void>) | null;\n /**\n * An event an add-on (or the core) reports for the DevTools protocol (a `$watch` handler fired or\n * threw, a `$watch` chain or an update loop cut, a path that does not resolve): `event` is the\n * protocol's payload, its keys quoted (`{ \"type\": \"state:watch-fired\", \"path\": … }`). Called as\n * `hooks.noticed?.(engine, {…})`, the payload is built only while the slot is filled.\n */\n noticed?: ((engine: Engine, event: Record<string, unknown>) => void) | null;\n}\n\n/** Calls a native element's command method with what the token was emitted with. */\nexport type NativeCall = (target: Element, args: unknown[]) => unknown;\n\n/** What an add-on does with a `<wcs-state>` it claimed. */\nexport interface Claimed {\n /** Where the state comes from, when not from the element's own sources. */\n load?(): Promise<Record<string, any>>;\n /**\n * The loaded state; `connectedCallbackPromise` resolves when this is done, and `built` is called\n * once its bindings are built (before `$connectedCallback`: getBindingsReady resolves then, as for a\n * root). When it (or the load) throws, the core reports the failure and rejects the promise with\n * it — a DCC definition, a component mount: 3.x's README promises it for their configuration\n * errors, and 4.0 also rejects where 3.x did not (a component whose root failed: 3.x left it\n * unsettled; a second mount in one scope: 3.x resolved it) — or resolves it, for a lenient claim.\n */\n start(state: Record<string, any>, built: () => void): Promise<void> | void;\n /** A failure resolves `connectedCallbackPromise` instead (a volume settles without grafting, as 3.x). */\n lenient?: boolean;\n connected(): void;\n disconnected(): void;\n /** `setInitialState` after the start. */\n reset(state: Record<string, any>): void;\n}\n\nexport const hooks: Hooks = {};\n\ntype HookFn = (...args: any[]) => any;\n\n/*\n * A feature fills a slot by assigning it (`hooks.written = chain(hooks.written, fn)`), never by\n * its name as a string: the slot names are shortened by the build (mangle.mjs) like any internal\n * property.\n */\n\n/** A slot several features share: `fn` runs after whatever is there. */\nexport function chain<F extends HookFn>(prev: F | null | undefined, fn: F): F {\n return prev == null ? fn : ((...a: unknown[]) => { prev(...a); fn(...a); }) as F;\n}\n\n/** A slot whose first answer wins (`answered` tells one): `fn` is asked when what is there does not answer. */\nexport function first<F extends HookFn>(answered: (r: unknown) => boolean, prev: F | null | undefined, fn: F): F {\n return prev == null ? fn : ((...a: unknown[]) => { const r = prev(...a); return answered(r) ? r : fn(...a); }) as F;\n}\n\n/** `beforeWrite`: the first feature that handles the write. */\nexport const handled = (r: unknown): boolean => r === true;\n/** `dollar`: the first feature that knows the `$` name (a value, possibly null or false). */\nexport const known = (r: unknown): boolean => r !== undefined;\n/** `claim`: the first feature that takes the `<wcs-state>`. */\nexport const taken = (r: unknown): boolean => r != null;\n\n/** An add-on entry: `installFeatures([temporal, diagnostics])` before the state is defined. */\nexport interface Feature {\n readonly name: string;\n install(): void;\n}\n\nconst installed = new Set<string>();\n\nexport function installFeatures(features: readonly Feature[]): void {\n for (const f of features) {\n if (installed.has(f.name)) continue;\n installed.add(f.name);\n f.install();\n }\n}\n\n/**\n * A state's `$features` before its engine is made: the missing add-ons, loaded where an entry can\n * load them (`hooks.load`); undefined when there is nothing to wait for. The engine then checks\n * every name (a bundle or the full build only checks).\n */\nexport function loadFeatures(state: Record<string, any>): Promise<void> | undefined {\n const names = state.$features;\n if (hooks.load != null && Array.isArray(names)) {\n const missing = names.filter((n) => !installed.has(n));\n if (missing.length > 0) return hooks.load(missing);\n }\n}\n\n/** The barrier: a declaration that needs a feature the page did not install. */\nexport function requireFeature(feature: string, what: string): void {\n if (!installed.has(feature)) {\n throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${what} needs the add-on @wcstack/state/features/${feature}`);\n }\n}\n","import { hooks } from \"../hooks\";\n\n/**\n * Throws `[@wcstack/state] <message>`. The core's messages state the fact (a number and values); the\n * diagnostics add-on, when installed, appends the guidance (the nearest of `candidates` to\n * `subject`, how to fix it, the lint pointer).\n */\nexport function raiseError(message: string, subject?: string, candidates?: Iterable<string>): never {\n throw new Error(`[@wcstack/state] ${message}${hooks.explain?.(message, subject, candidates) ?? \"\"}`);\n}\n"],"mappings":"AAkIO,IAAMA,EAAe,CAAC,EAWtB,SAASC,EAAwBC,EAA4BC,GAClE,OAAe,MAARD,EAAeC,MAAUC,KAAmBF,KAAQE,GAAID,KAAMC,EAAI,CAC3E,CAGO,SAASC,EAAwBC,EAAmCJ,EAA4BC,GACrG,OAAe,MAARD,EAAeC,MAAUC,KAAmB,IAAMG,EAAIL,KAAQE,GAAI,OAAOE,EAASC,GAAKA,EAAIJ,KAAMC,EAAI,CAC9G,CAGO,IAAMI,EAAWD,IAA8B,IAANA,EAEnCE,EAASF,QAA8B,IAANA,EAEjCG,EAASH,GAA6B,MAALA,EAQxCI,EAAY,IAAIC,IAEf,SAASC,EAAgBC,GAC9B,QAAWC,KAAKD,EACVH,EAAUK,IAAID,EAAEE,QACpBN,EAAUO,IAAIH,EAAEE,MAChBF,EAAEI,UAEN,CAOO,SAASC,EAAaC,GAC3B,IAAMC,EAAQD,EAAME,UACpB,GAAkB,MAAdvB,EAAMwB,IAAgBC,MAAMC,QAAQJ,GAAQ,CAC9C,IAAMK,EAAUL,EAAMM,OAAQC,IAAOlB,EAAUK,IAAIa,IACnD,GAAIF,EAAQG,OAAS,EAAG,OAAO9B,EAAMwB,GAAKG,EAC5C,CACF,CAGO,SAASI,EAAeC,EAAiBC,GAC9C,IAAKtB,EAAUK,IAAIgB,GACjB,MAAM,IAAIE,MAAM,gDAAgDD,8CAAiDD,IAErH,CCxLO,SAASG,EAAWC,EAAiBC,EAAkBC,GAC5D,MAAM,IAAIJ,MAAM,oBAAoBE,IAAUpC,EAAMuC,KAAUH,EAASC,EAASC,IAAe,KACjG,QAAAE,OAAApC,OAAAqC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{b as t,c as e,d as s}from"./chunk-DOWWBZVS.js";import{n as i,o as n}from"./chunk-NMOSSDKJ.js";import{f as o}from"./chunk-F3DVWVH3.js";import{a,b as r}from"./chunk-CIBJLAA3.js";import{a as l,b as c}from"./chunk-UBGJGMSG.js";import{a as h,h as u,i as d}from"./chunk-BGUJ3HF6.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function b(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?b(t):Promise.reject(i.errors[0]):void 0)}var g=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends g{constructor(){super(),this.engine=null,this.jn=!1,this.ze=!1,this.U=null,this.Xe=null,this.loaded=!1,this.un=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.cn=t,this.Eo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.an=t})}static{this.getBindingsReady=b}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.jn){if(null!==this.Xe)return void this.Xe.Ge();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.No("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.jn=!0;let e=this.getRootNode(),s=h.ct?.(this,e);if(s)return this.Xe=s,!s.xo&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.bt?this.Ro():s.bt()).then(t=>(this.loaded=!0,s.start(t,()=>this.Po()))).then(()=>{this.an(),this.cn()},t=>this.xt(t,s.xo));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Xe)return void this.Xe.Ln();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.No("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.ze&&c(14),this.loaded)this.Xe.reset(t);else if(null===this.engine)if(null!==this.un){let e=this.un;this.un=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.Be++;try{e(s.proxy)}finally{"readonly"===t&&s.Be--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(globalThis[Symbol.for("wcstack.ssr.resolveModule")]?.(e)??e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.un=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.jn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Xe)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.En(),this.Po(),await f.Se("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.cn()}catch(t){this.ze=!this.V,this.xt(t)}}Po(){this.V=!0,this.an()}xt(t,e){this.qe(this.V?50:49,t),this.an(),e?this.cn():this.Eo(t)}qe(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}No(t,e,s){(async()=>this.engine.Se(t))().then(s,t=>this.qe(e,t))}},y=[];function v(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function k(t,s){t&&r(t),function(t=customElements){e(),v().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.To?.(t)}(s)}var R=t=>b(t);export{b as a,g as b,v as c,k as d,R as e};
2
- //# sourceMappingURL=chunk-BKLFDVOP.js.map
1
+ import{b as t,c as e,d as s}from"./chunk-GBBBRPZR.js";import{p as i,q as n}from"./chunk-467LYA2V.js";import{f as o}from"./chunk-ZJYPRSTO.js";import{a,b as r}from"./chunk-T3FN37DU.js";import{a as l,b as c}from"./chunk-JWRQLKOQ.js";import{a as h,h as u,i as d}from"./chunk-TNYNJXEC.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function b(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?b(t):Promise.reject(i.errors[0]):void 0)}var g=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends g{constructor(){super(),this.engine=null,this.Ln=!1,this.Ye=!1,this.U=null,this.Ge=null,this.loaded=!1,this.un=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.cn=t,this.No=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.an=t})}static{this.getBindingsReady=b}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Ln){if(null!==this.Ge)return void this.Ge.Je();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Ln=!0;let e=this.getRootNode(),s=h.ut?.(this,e);if(s)return this.Ge=s,!s.Po&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.kt?this.Ro():s.kt()).then(t=>(this.loaded=!0,s.start(t,()=>this.To()))).then(()=>{this.an(),this.cn()},t=>this.Pt(t,s.Po));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Ge)return void this.Ge.Bn();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ye&&c(14),this.loaded)this.Ge.reset(t);else if(null===this.engine)if(null!==this.un){let e=this.un;this.un=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.Be++;try{e(s.proxy)}finally{"readonly"===t&&s.Be--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(globalThis[Symbol.for("wcstack.ssr.resolveModule")]?.(e)??e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.un=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Ln=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ge)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.Nn(),this.To(),await f.$e("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.cn()}catch(t){this.Ye=!this.V,this.Pt(t)}}To(){this.V=!0,this.an()}Pt(t,e){this.ze(this.V?50:49,t),this.an(),e?this.cn():this.No(t)}ze(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}xo(t,e,s){(async()=>this.engine.$e(t))().then(s,t=>this.ze(e,t))}},y=[];function k(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function v(t,s){t&&r(t),function(t=customElements){e(),k().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.Ao?.(t)}(s)}var R=t=>b(t);export{b as a,g as b,k as c,v as d,R as e};
2
+ //# sourceMappingURL=chunk-ULMHOGJ2.js.map
@@ -0,0 +1,2 @@
1
+ import{b as t,d as e,e as i}from"./chunk-NITPUCPA.js";import{h as l,m as s}from"./chunk-CBMAVRYG.js";import{a as n,b as r}from"./chunk-JWRQLKOQ.js";import{a as h,i as o}from"./chunk-TNYNJXEC.js";var u=Symbol.for("wcstack.trustedTypes.policy");function f(){let t=globalThis[u];return null!==t&&"object"==typeof t?t:null}function a(t){globalThis[u]=t}function c(t){return"innerHTML"===t||"outerHTML"===t||"srcdoc"===t}function d(t){if(globalThis.trustedTypes?.isHTML(t))return t;let e=null==t?"":String(t),i=f(),l=i?.createHTML;return"function"==typeof l?l.call(i,e):e}var p=class{constructor(t,e,i){this.bt=null,this.N=null,this.we=null,this._=null,this.u=null,this.w=!0,this.l=t,this.y=e,this.E=i}},g=class{constructor(t,e){this.R=null,this.f=[],this.N=null,this.M=null,this.te=!1,this.Bt=!1,this.vt=!1,this.o=t,this.ce=e,this.n=t.n+1}},y=[],v=class{constructor(t){this.St=new Set,this.name=t}get size(){return this.St.size}subscribe(t){return this.St.add(t),()=>{this.St.delete(t)}}unsubscribe(t){return this.St.delete(t)}emit(...t){let e=[];for(let i of this.St)try{e.push(i(...t))}catch(t){e.push(void 0),console.error(`[@wcstack/state] ${n(17,[this.name])}`,t)}return e}};function b(t,e,i){if(void 0===t)return[];Array.isArray(t)||r(18,[e]);let l=new Set;for(let s of t)("string"!=typeof s||""===s)&&r(19,[e]),s===i&&r(20,[e,s,i]),l.has(s)&&r(21,[e,s]),l.add(s);return t}var m=Symbol.for("wcstack.transition-runner");function w(t){let e=globalThis[m];return null==e||"wcs-transition-runner"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.run||"function"!=typeof e.accepts||!e.accepts(t)?null:e}function $(t,e,i){let l=w(t);if(null!==l)return l.run(e,{source:t,types:i});e()}var k=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],A=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function M(t){return t.includes("**")&&s(t),t}var O=0,T=32,j=100;function S(t,e,i){let l=t.get(e);return void 0===l&&t.set(e,l=i()),l}var _=()=>new Set,E=()=>[],R=new WeakMap;function H(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function x(t,e){return t===e||t!=t&&e!=e}function z(t,e,i){let l=t._?.get(e);void 0!==l&&l.delete(i)&&0===l.size&&t._.delete(e)}function X(t,e){for(let i=0;i<e.length;i++){if(null==t)return;t=t[e[i]]}return t}function B(t,e){for(;null!==t&&t.l.n>e;)t=t.l.ce;return null!==t&&t.l.n===e?t:null}function q(t,e,i){let l=B(t,i);return null!==l&&l.l.o===e.h[i]?l:null}var N=class{constructor(t,i){this.Le=0,this.d=null,this.Be=0,this.tt=new Set,this.nt=new Map,this.Kn=Symbol("wcs.block"),this.element=null,this.$t=[],this.Me=null,this.Un=[],this.Ht=0,this.X=null,this.oe=new Map,this.ue=new Map,this.We=[],this._e=[],this.Ve=[],this.Et=!1,this.gn=!1,this.Kt=new WeakMap,this.D=0,this.Ut=0,this.yn=!1,this.qt=!1,this.zt=!1,this.Ce=0,this.qn=()=>{this.D=0,this.yn=!1},this.zn=()=>{this.Ce--},this.rp=null,this.rr=null,this.Wo=()=>this.Yt(),this._o=(t,e)=>t(this.proxy,...e),this.Yn=[],this.He=[],this.Xn={$untracked:t=>{let e=this.X;if(null===e)return t();e.be++;try{return t()}finally{e.be--}},$eqIndex:(t,e=1)=>{let i=B(this.d,e);null===i&&r(7,[t]);let l=this.o(t);if(null!==l.getter||l.ae)return this.watchIndex(e),i.y===this.read(l,null);let s=this.X;if(null!==s){let t=s.getter,i=l.je??(l.je=[]);if(!i.some(i=>i.getter===t&&i.Gn===e)){i.push({getter:t,Gn:e});let s=t.h[e];(s.Dt??(s.Dt=[])).push({source:l,getter:t})}}return i.y===this.v(l,null)},$eq:(t,e)=>this.eq(t,e),$eqPath:(t,e)=>{let i=this.o(e);return this.eq(t,this.v(i,B(this.d,i.n)))},$dependOn:t=>{this.resolve(M(t),this.d),null!==this.X&&0===this.X.be&&this.Jn(this.rp,this.rr,this.X)},$getAll:(t,e)=>this.getAll(t,e),$setAll:(t,e,i,l)=>this.wn(t,e,i,l),$resolve:(...t)=>{let e=M(t[0]),i=t[1]??[],l=this.o(e,!0);this.bn("$resolve",e,l,i,!0);let s=this.Qn(l,i,null);if(t.length<3)return this.read(l,s);this.A(l,s,t[2])},$postUpdate:t=>{this.resolve(M(t),this.d);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.E=i.l.R[i.y],R.delete(i.l.R),this.T.Xt(i)),this.vn(e,i),null!==i&&this.Zn(i,e,void 0,i.E,!1),0===e.n&&this.eo(e,void 0,void 0,!0),this.Gt(e,i,void 0,void 0,!1)}},this.T=i,this.O=new e(t=>{this.He.push(t),this.ot(t)}),this.to(t);let l=this,s={getOwnPropertyDescriptor(t,e){let i=Reflect.getOwnPropertyDescriptor(l.target,e);return i&&(i.configurable=!0),i},get(t,e,i){let s=l.target;if("symbol"==typeof e)return Reflect.get(s,e);if(36===e.charCodeAt(0))return l.rt(e);if(e.indexOf(".")<0){let t=l.O.wt(e);if(void 0===t||null===t.getter){let t=s[e];if("function"==typeof t)return i===l.proxy&&l.V?.(t)||t}if(void 0!==t&&0===t.n)return l.read(t,null)}return l.resolve(e,l.d),l.read(l.rp,l.rr)},set:(t,e,i)=>"symbol"==typeof e?Reflect.set(l.target,e,i):(l.resolve(M(e),l.d),l.A(l.rp,l.rr,i),!0)};for(let t of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])s[t]=(e,...i)=>Reflect[t](l.target,...i);this.proxy=new Proxy({},s)}o(t,e){let i=this.O.get(t);return e||(i.pn=!0),i}no(t){let e=new Set;for(let i=t;null!==i&&i!==Object.prototype;i=Object.getPrototypeOf(i))for(let t of Object.getOwnPropertyNames(i)){if(e.has(t))continue;e.add(t);let l=Object.getOwnPropertyDescriptor(i,t);if(void 0===l.get&&void 0===l.set)continue;let s=this.o(t);s.getter=l.get??null,s.se=l.set??null,null!==s.getter&&s.n>0&&(s.F=this.Le++)}for(let t of this.O.all())this.ot(t)}ot(t){t.t.includes("**")&&s(t.t),("__proto__"===t.s||"prototype"===t.s)&&r(120,[t.t]);let e=t.c;t.ae=null!==e&&"*"!==t.s&&e.n===t.n&&(null!==e.getter||e.ae),null===t.getter&&this.Vo(t)}Vo(t){let e=t.t,i=t.s;if(l.test(i))t.getter=function(){return this[i]};else{let l=e.split("."),s=l.findIndex((t,e)=>e>0&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57);if(s<0||l.indexOf("*",s)>=0)return;t.getter=()=>(this.resolve(e,this.d),this.rp!==t?this.read(this.rp,this.rr):this.read(t.c,this.d)?.[i]),t.se=l=>{if(this.resolve(e,this.d),this.rp!==t)return this.A(this.rp,this.rr,l);let s=this.read(t.c,this.d);null==s&&r(4,[e,s]),s[i]=l}}t.hn=!0,t.n>0&&(t.F=this.Le++)}Ke(t,e){let i=null===t?this.oe:t.u??=new Map,l=i.get(e);return void 0===l&&i.set(e,l=new g(e,t)),e.pn=!0,this.G(l),l}oo(t){try{this.G(t)}catch(e){this.Jt(e,t.o.t,t.N?.S??null,"for")}}G(t){let e=this.v(t.o,t.ce);if(e===t.R)return;this.io(t);let i=function(t,e,i){let l=Array.isArray(e)?e:y;if(l===t.R)return null;let s=t.f,n=l.length,r=s.length,h=new Array(n),o=0;for(;o<n&&o<r&&s[o].E===l[o];)h[o]=s[o],o++;let u=r-1,f=n-1;for(;u>=o&&f>=o&&s[u].E===l[f];)h[f]=s[u],u--,f--;if(o>u)for(let e=o;e<=f;e++)h[e]=new p(t,e,l[e]);else if(o>f)for(let t=o;t<=u;t++)i.Mt(s[t]);else{let e=u<f?u:f;for(let t=o;t<=e;t++)s[t].E===l[t]&&(h[t]=s[t]);let n=new Map;for(let t=u;t>=o;t--){let i=s[t];if(t<=e&&h[t]===i)continue;let l=n.get(i.E);void 0===l?n.set(i.E,i):Array.isArray(l)?l.push(i):n.set(i.E,[l,i])}for(let e=o;e<=f;e++){if(void 0!==h[e])continue;let i,s=l[e],r=n.get(s);void 0!==r&&(Array.isArray(r)?(i=r.pop(),0===r.length&&n.delete(s)):(i=r,n.delete(s))),h[e]=i??new p(t,e,s)}for(let t of n.values())if(Array.isArray(t))for(let e of t)i.Mt(e);else i.Mt(t)}for(let t=o;t<n;t++){let e=h[t];e.y!==t&&(e.y=t,i.Lo(e))}return t.f=h,t.R=l,s}(t,e,this);if(null===i)return;if(t.R===e){let i=S(this.Kt,e,E);if(i.push(t),i.length>1)for(let t of i)t.vt=!0}h.Qt?.(this,t,i),(null!==t.N||null!==t.M)&&!t.te&&(t.te=!0,this._e.push(t),this.ve());let l=t.o.Dt;if(null!==l)for(let{source:e,getter:s}of l){let l=this.v(e,null),n=i[l],r=t.f[l];n!==r&&(void 0!==n&&n.w&&this.kn(s,n),void 0!==r&&this.kn(s,r))}}Lo(t){this.T.Ho(this,t)}Mt(t){t.w=!1;let e=t._;if(null!==e){for(let t of e)z(t.source,t.key,t.sub);t._=null}if(null!==t.u)for(let e of t.u.values()){this.io(e);for(let t of e.f)this.Mt(t)}}io(t){let e=this.Kt.get(t.R);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.vt=!1,1===e.length&&(e[0].vt=!1))}resolve(t,e){let l=i(t),s=this.rp=this.o(l.o,!0),n=l.indexes;this.rr=0===s.n?null:null===n?q(e,s,s.n):this.Qn(s,n,e,t)}Qn(t,e,i,l){let s=null;for(let n,r=1,h=0;r<=t.n;r++){let o=t.h[r],u=this.Ke(s,o),f=e[h++];if(f<0)f=q(i,t,r)?.y??-1;else if(l&&u.R===y&&Object(n=this.v(o,s))===n){let e=t.t.split("."),i=o.t.split(".").length;e[i]=l.split(".")[i],t=this.o(e.join("."),!0),r--;continue}if(s=u.f[f]??null,null===s)break}return this.rp=t,s}it(t,e){return 0===t.n?X(this.target,t.z):null===e?void 0:X(e.E,t.z)}read(t,e){let i=this.X;if(null!==i&&0===i.be&&this.Jn(t,e,i),null!==t.getter)return this.T.Ko(this,t,e);if(t.ae){let i=this.read(t.c,e);return i?.[t.s]}return null===t.c&&!(t.s in this.target)&&!this.tt.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&r(301,[t.t],t.s,Object.keys(this.target)),this.it(t,e)}v(t,e){let i=this.X;if(null===i)return this.read(t,e);i.be++;try{return this.read(t,e)}finally{i.be--}}Jn(t,e,i){let l=i.getter;t._n(l),0===l.n?t.Z!==i.de&&(t.Z=i.de,i.Sn.push(t)):t.n>0&&B(e,Math.min(t.n,l.n))!==B(i.r,Math.min(t.n,l.n))&&(l.mt??(l.mt=new Set)).add(t)}Uo(t,e){for(let i=0;i<this.Ht;i++){let l=this.Un[i];l.getter===t&&l.r===e&&r(701,[t.t])}this.Ht>=128&&r(801,[t.t]);let i=this.Ht++;this.Be++;let l=this.Un[i]??={getter:t,r:e,be:0,de:0,Sn:[]};l.getter=t,l.r=e,l.be=0,l.de=++O,l.Sn.length=0;let s=this.X;this.X=l;let n=this.d;this.d=e;try{let e=t.getter.call(this.proxy);return 0===t.n&&this.qo(t,l),e}finally{this.Be--,this.Ht--,this.X=s,this.d=n,l.r=null}}qo(t,e){let i=e.de;for(let t of e.Sn)t.Z=i;t.Q=t.Q.filter(e=>e.Z===i||e.n>0||!e.ae&&Array.isArray(null!==e.getter?e.Y:this.it(e,null))||this.so(e,t))}so(t,e){return t.Do(e),this.He.push(t),!1}zo(){for(let t=this.He;t.length>0;t=this.He){this.He=[];let e=new Set;for(let i of t)if(!(i.pn||i.mn||null===i.c||i.u.length>0||i.B.length>0)&&(null===i.getter||i.hn&&i.F<0)&&null===i._){i.mn=!0,this.O.Lt(i),e.add(i.c);for(let t of i.Q)this.so(t,i)}for(let t of e)(t.u=t.u.filter(t=>!t.mn)).length||this.He.push(t)}}watchIndex(t){let e=this.X;if(null!==e&&0===e.be){let i=e.getter,l=i.h[t];if(l){let t=l.jt??(l.jt=[]);t.includes(i)||t.push(i)}}}rt(t){let e=t.charCodeAt(1);if(e>=48&&e<=57){let i=2===t.length?e-48:l.test(t)?+t.slice(1):0;return(i<1||i>128)&&r(1001,[t]),this.watchIndex(i),B(this.d,i)?.y}let i=this.Xn[t];if(void 0!==i)return i;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return h.rt?.(this,t)}eq(t,e){this.resolve(t,this.d);let i=this.rp,l=this.rr;if(null!==i.getter||i.ae||i.n>0)return x(this.read(i,l),e);let s=this.X;return null!==s&&0===s.be&&this.Yo(i,e,s),x(this.v(i,null),e)}Yo(t,e,i){let l=i.getter,s=i.r,n=null===s?this.Yn:s._??(s._=[]);for(let s=0;s<n.length;s++){let r=n[s];if(r.sub.getter===l&&r.source===t){if(x(r.key,e))return void(r.de=i.de);r.de!==i.de&&(z(t,r.key,r.sub),n.splice(s--,1))}}let r={getter:l,r:s};S(t._??=new Map,e,_).add(r),n.push({source:t,key:e,sub:r,de:i.de})}eo(t,e,i,l){this.Zt(t,s=>{let n=s._;if(null===n&&null===s.je)return;let r=s===t?[]:s.t.slice(t.t.length+1).split("."),h=X(e,r),o=X(i,r);if(null!==s.je&&this.Xo(s,h,o,l),null!==n)for(let t of l?n.keys():[h,o]){let e=n.get(t);if(void 0!==e)for(let i of e)null===i.r||i.r.w?this.T.ke(this,i.getter,i.r):z(s,t,i)}})}A(t,e,i,l=!1,s=!1){if(this.Be>0&&r(8),s||this.Ce>0?this.qt=!0:this.zt=!0,h.Ie?.(this,t,e,i,s))return;if(null!==t.se){try{this.$n(t.se,e,[i])}finally{this.Gt(t,e,void 0,void 0,!1,s)}return}null!==t.getter&&r(2,[t.t]),t.n>0&&null===e&&r(3,[t.t]);let n=t.ae?this.v(t,e):this.it(t,e);if(l||!this._t||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.R[t.y]=i,R.delete(t.l.R),t.E=i,this.T.Xt(t)}else{let l=1===t.z.length?0===t.n?this.target:e.E:this.v(t.c,e);null==l&&r(4,[t.t,l]),l[t.s]=i}this.En(t,e),null!==e&&this.Zn(e,t,n,i),0===t.n&&this.eo(t,n,i),this.Gt(t,e,n,i,!0,s)}}lo(t){return(this.Kt.get(t.R)??[]).filter(e=>e.R===t.R&&(null===e.ce||e.ce.w))}Zn(e,i,l,s,n=!0){let r=e.l,h=i.t.slice(r.o.t.length+2),o=""!==h&&function(t){let e=R.get(t);if(void 0===e){let i=new Set;R.set(t,e=t.some(t=>Object(t)===t&&(i.has(t)||!i.add(t))))}return e}(r.R);if(!o&&!r.vt&&null===r.o.getter&&!r.o.B.length)return;let u=e.E,f=(t,i)=>{if(void 0===i||i===e)return;let r=this.o(`${t.o.t}.*${h}`,!0);""===h&&(i.E=s,this.T.Xt(i)),n?this.En(r,i):this.vn(r,i),this.Gt(r,i,l,s,n)};for(let t of this.lo(r))if(f(t,t.f[e.y]),o)for(let i of t.f)i.E===u&&i.y!==e.y&&f(t,i);if(""===h)return;let a=new Set([r.R]),c=t=>Array.isArray(t)&&t.includes(u),d=(e,i)=>{if(!a.has(e)&&a.add(e))for(let t of this.Kt.get(e)??[])for(let e of t.f)e.E===u&&f(t,e);for(let l of i){let i=l.Y,s=i===t;s&&(i=this.oe.get(l)?.R),(s||c(i))&&!a.has(l.B)&&a.add(l.B)&&(!s&&i!==e&&this.T.ke(this,l,null),d(i,l.B))}},p=t=>{for(let e of t.Q)if(!a.has(e)&&a.add(e))if(null!==e.getter)p(e);else if(!e.ae){let t=this.it(e,null);c(t)&&d(t,e.B)}};null!==r.o.getter?p(r.o):d(r.R,r.o.B)}vn(t,e){this.Go(t,e,t=>{this.G(t);for(let e of t.vt?this.lo(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.f)this.Nt(t,i),this.vn(t,i)}})}En(t,e){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())e.o.ee(t)&&this.G(e)}Go(t,e,i){let l=null===e?this.oe:e.u;if(null!==l)for(let e of l.values())e.o.ee(t)&&i(e)}Xo(t,e,i,l){for(let{getter:s,Gn:n}of t.je)this.ao(s.h[n],t=>{for(let n of l?t.f.keys():[e,i]){let e="number"==typeof n?t.f[n]:void 0;void 0!==e&&this.kn(s,e)}})}kn(t,e){e.l.n===t.n?this.T.ke(this,t,e):this.en(e,t,e=>this.T.ke(this,t,e))}Gt(t,e,i,l,s,n){h.re?.(this,t,e,i,l,s,n),this.Ue(t,e)}Ue(t,e){this.T.Jo(this,t,e),this.ve()}co(t){let e=this.nt.get(t);if(void 0!==e)return e;let i=Symbol(`wcs.on${t}`);this.nt.set(t,i);let l=this.root,s=this.Kn;return l.addEventListener(t,e=>{for(let n=e.target;null!==n&&n!==l;n=n.parentNode){let l=n[i];if(void 0!==l&&(l(e),e.cancelBubble))return;let r=n[s];if(void 0!==r&&r.w&&r.Qo(t,e))return}}),i}reset(t){let e=this.target,i=this.tt;for(let t of this.O.all())null===t.c&&null!==t.getter&&i.add(t.s);this.to(t);for(let t in e)"$"!==t[0]&&i.add(t);for(let e of i)e in t&&i.delete(e);for(let t of this.ue.values())for(let e of t)this.tn(e);for(let t of this.oe.values())this.uo(t);this.Me=null;try{this.Yt()}finally{this.Nn()}h.element?.(this,"reset")}to(t){for(let[e,i]of k)void 0!==t[e]&&o(i,e);let e=t.$features;if(void 0!==e){Array.isArray(e)||r(46);for(let t of e)o(t,"$features")}let i=void 0===t.$behavior?{}:t.$behavior;("object"!=typeof i||!i||Array.isArray(i))&&r(44,["state","$behavior"]);for(let t in i)(!A.includes(t)||"boolean"!=typeof i[t])&&r(44,["$behavior",t]);let[l,s,n]=A.map(t=>i[t]??!0);void 0!==this.target&&(l!==this.Wt||s!==this._t||n!==this.Vt)&&r(45);let u=function(t,e){let i={};for(let l of b(t.$commandTokens,"$commandTokens","$command"))i[l]=e?.[l]??new v(l);return Object.freeze(i)}(t,this.commands),f=function(t,e){let i=new Map;for(let e of b(t.$eventTokens,"$eventTokens"))i.set(e,new v(e));let l=t.$on;if(void 0===l)return i;(null===l||"object"!=typeof l)&&r(22);for(let[t,s]of Object.entries(l)){let l=i.get(t);void 0===l&&r(23,[t]),"function"!=typeof s&&r(24,[t]),l.subscribe((...t)=>e(s,t))}return i}(t,this._o);this.Wt=l,this._t=s,this.Vt=n,h.fe?.(this,t),this.target=t,this.Le=0;for(let t of this.O.all())t.jo();this.Yn.length=0,this.no(t),this.commands=u,this.Oe=f}uo(t){this.oo(t);let e=this.o(`${t.o.t}.*`);for(let i of t.f)if(i.bt=null,i._=null,this.Nt(e,i),null!==i.u)for(let t of i.u.values())this.uo(t)}H(t){let e=[];for(let i=t;null!==i;i=i.l.ce)e.unshift(i.y);return e}Zo(t,e,i){let l=this.Oe.get(t);void 0===l&&r(1301,[t],t,this.Oe.keys()),l.emit(e,...this.H(i))}command(t){let e=this.commands[t];return void 0===e&&r(1302,[t],t,Object.keys(this.commands)),e}er(t,e,i){this.command(t).emit(e,...this.H(i))}tr(t,e,i){let l=t.includes(".")?this.v(this.o(t),null):this.target[t];return"function"!=typeof l&&r(5,[t]),this.$n(l,i,[e,...this.H(i)])}$n(t,e,i){let l=this.d;this.d=e;try{return t.apply(this.proxy,i)}finally{this.d=l}}Nt(t,e){if(null!==t.getter){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())!e.Bt&&e.o.ee(t)&&(e.Bt=!0,this.Ve.push(e))}if(null===e)return void this.Zt(t,t=>{let e=this.ue.get(t);if(void 0!==e)for(let t of e)this.tn(t)});let i=e.we;if(null!==i)for(let e=0;e<i.length;e++)i[e].o.ee(t)&&this.tn(i[e]);let l=e.N;null!==l&&null!==l.pe&&l.fo(this,t);let s=e.l.M;if(null!==s)for(let i of s){let l=i.map.get(e);void 0!==l&&null!==l.pe&&l.fo(this,t)}}xn(t,e,i){this.Zt(t,t=>{let l=t.B;for(let s=0;s<l.length;s++){let n=l[s];if(0===n.n)this.st(n,null,i);else if(null===e||0===t.n||n.h[1]!==t.h[1]||null!==n.mt&&n.mt.has(t))this.nn(n.h[n.n],t=>this.st(n,t,i));else if(n.n<=t.n){let t=B(e,n.n);null!==t&&this.st(n,t,i)}else this.en(e,n,t=>this.st(n,t,i))}})}st(t,e,i){i(t,e)&&(h.Se?.(this,t,e),this.Nt(t,e),this.xn(t,e,i))}Zt(t,e){e(t);let i=t.u;for(let t=0;t<i.length;t++)this.Zt(i[t],e)}nn(t,e){this.ao(t,t=>{for(let i of t.f)e(i)})}ao(t,e){if(0===t.n){let i=this.oe.get(t);return void(void 0!==i&&e(i))}this.nn(t.h[t.n],i=>{let l=i.u?.get(t);void 0!==l&&e(l)})}en(t,e,i){if(t.l.n===e.n)return i(t);let l=t.u?.get(e.h[t.l.n+1]);if(void 0!==l)for(let t of l.f)this.en(t,e,i)}nr(t){let e=t.r;null===e?S(this.ue,t.o,_).add(t):(e.we??(e.we=[])).push(t)}Pn(t){let e=t.r;if(null===e)return void this.ue.get(t.o)?.delete(t);let i=e.we;e.w&&null!==i&&i.splice(i.indexOf(t)>>>0,1)}tn(t){t.te||(t.te=!0,this.We.push(t),this.ve())}ve(){this.Et||(this.Et=!0,queueMicrotask(this.Wo))}Rn(){for(let t of this.We)t.te=!1;for(let t of this._e)t.te=!1;for(let t of this.Ve)t.Bt=!1;this.We=[],this._e=[],this.Ve=[],this.T.tt(this)}po(t,e){let i=[...new Set([...this.We,...this._e,...this.Ve].map(t=>t.o.t))];console.error(`[@wcstack/state] ${n(t)}`,i),h.at?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.Rn()}Yt(){this.Et=!1;let t=this.Ut;this.Ut=0;let e=0;if(!this.qt||this.zt?this.qn():t>0?e=t:1===(e=++this.D)&&setTimeout(this.qn,0),this.qt=this.zt=!1,e>100)101===e?this.po(41,100):this.Rn();else{this.gn=!0;try{for(let t=0;this.We.length>0||this._e.length>0||this.Ve.length>0;t++){if(t>=32){this.yn?this.Rn():this.po(11,32),this.yn=!0;break}let i=this.Ve;if(i.length>0){this.Ve=[];for(let t of i)t.Bt=!1,this.oo(t)}let l=this._e,s=this.We;this._e=[],this.We=[];let n=()=>{for(let t of l){t.te=!1;for(let e of[t.N,...t.M??[]])if(null!==e&&e.w)try{e.xt()}catch(i){this.Jt(i,t.o.t,e.S,"for")}}for(let t=0;t<2;t++)for(let e=0;e<s.length;e++){let i=s[e];!i.te||null===i.D==(0===t)||(i.te=!1,(null===i.Tn||i.Tn.w)&&this.qe(i))}this.gn||(this.ze(),this.Et&&(this.Ut=e+1))},r=l.length>0||s.some(t=>null!==t.D)?$("state",n):n();void 0!==r&&r.then(void 0,t=>console.error(t))}}finally{this.gn=!1}this.qt=this.zt=!1,this.ze(),h.me?.(this),this.zo(),t>0&&this.Et&&(this.Ut=e+1)}}Pt(t,e){this.$t.push([t,e])}Jt(t,e,i,l){this.Pt(t,{o:{t:e},a:i,on:()=>l})}qe(t){try{t.apply()}catch(e){return void this.$t.push([e,t])}null!==this.Me&&this.mo(t.o,t.r)}mo(t,e){let i=S(this.Me,t.t,E);null!==e&&i.push(this.H(e))}Nn(){this.Me="function"==typeof this.target.$renderedCallback?new Map:null}ze(){let t=this.Me;if(null!==t&&t.size>0){this.Me=new Map;let e,i=[...t.keys()],l={};for(let[e,i]of t)i.length>0&&(l[e]=i);this.Ce++;try{e=this.$e("$renderedCallback",[i,l])}catch(t){console.error(t)}H(e)?e.then(this.zn,t=>{this.zn(),console.error(t)}):this.Ce--}if(0===this.$t.length)return;let e=this.$t;this.$t=[];let i=this.target.$errorCallback;for(let[t,l]of e){h.Ye?.(this,t,l);let e=l.o.t,s=l.on();if("function"==typeof i)try{let i=this.$e("$errorCallback",[t,{path:e,bindingType:s,node:l.a}]);H(i)&&i.then(void 0,t=>console.error(t))}catch(t){console.error(t)}else console.error(`[@wcstack/state] ${n(12,l.name?[s,e,l.name,l.i]:[s,e])}`,t,l.a)}}$e(t,e=[]){let i=this.target[t];return"function"==typeof i?this.$n(i,null,e):void 0}ho(t,e,i){if(0===t.n)return void i(null,[]);let l=[],s=(n,r)=>{let h=t.h[n];this.read(h,r);let o=this.Ke(r,h),u=e=>{l.push(e.y),n===t.n?i(e,l):s(n+1,e),l.pop()};for(let t of n-1<e.length?[o.f[e[n-1]]]:o.f)void 0!==t&&u(t)};s(1,null)}getAll(t,e){let i=this.o(t,!0);void 0!==e&&this.bn("$getAll",t,i,e,!1);let l=e;if(void 0===l){l=[];let e=this.d;if(null!==e&&i.n>0){for(let t=1;t<=i.n;t++){let s=q(e,i,t);if(null===s)break;l.push(s.y)}0===l.length&&r(6,[t])}}let s=[];return this.ho(i,l,t=>s.push(this.read(i,t))),s}wn(t,e,i,l){Array.isArray(e)||r(9,[t]),this.Be>0&&r(8);let s=this.o(t,!0);this.bn("$setAll",t,s,e,!1);let n=[];this.ho(s,e,(t,e)=>n.push([t,e.slice()]));let h=!0===l?.spread;h&&(!Array.isArray(i)||i.length!==n.length)&&r(10,[t,n.length]);let o=0;for(let t=0;t<n.length;t++){let[e,l]=n[t],r="function"==typeof i?i(this.v(s,e),...l):h?i[t]:i;void 0!==r&&(this.A(s,e,r),o++)}return o}bn(t,e,i,l,s){let n=l.length;(n>i.n||s&&n<i.n)&&r(s?901:902,[t,e,i.n,n])}};export{w as a,T as b,j as c,H as d,B as e,N as f,u as g,f as h,a as i,c as j,d as k};
2
+ //# sourceMappingURL=chunk-ZJYPRSTO.js.map
@@ -1,2 +1,2 @@
1
- import{a as s}from"./chunks/chunk-M67C46SN.js";import{a as n,d as t,e as u}from"./chunks/chunk-BKLFDVOP.js";import"./chunks/chunk-DOWWBZVS.js";import"./chunks/chunk-NMOSSDKJ.js";import"./chunks/chunk-2RBI6DVS.js";import{g as a,h as c,i as h}from"./chunks/chunk-F3DVWVH3.js";import{c as i}from"./chunks/chunk-CIBJLAA3.js";import"./chunks/chunk-5Q4M6A3C.js";import"./chunks/chunk-6I7GGFNJ.js";import"./chunks/chunk-UBGJGMSG.js";import{g as o}from"./chunks/chunk-BGUJ3HF6.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
1
+ import{a as s}from"./chunks/chunk-DUUQZITD.js";import{a as n,d as t,e as u}from"./chunks/chunk-ULMHOGJ2.js";import"./chunks/chunk-GBBBRPZR.js";import"./chunks/chunk-467LYA2V.js";import"./chunks/chunk-FBBHQU7S.js";import{g as a,h as c,i as h}from"./chunks/chunk-ZJYPRSTO.js";import{c as i}from"./chunks/chunk-T3FN37DU.js";import"./chunks/chunk-NITPUCPA.js";import"./chunks/chunk-CBMAVRYG.js";import"./chunks/chunk-JWRQLKOQ.js";import{g as o}from"./chunks/chunk-TNYNJXEC.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- import{a as e}from"../chunks/chunk-M67C46SN.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,n as i}from"../chunks/chunk-NMOSSDKJ.js";import"../chunks/chunk-2RBI6DVS.js";import"../chunks/chunk-F3DVWVH3.js";import"../chunks/chunk-CIBJLAA3.js";import"../chunks/chunk-5Q4M6A3C.js";import"../chunks/chunk-6I7GGFNJ.js";import"../chunks/chunk-UBGJGMSG.js";import{a as u,b as d}from"../chunks/chunk-BGUJ3HF6.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.on()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.he)for(let t of e.he)c(t);if(e instanceof r&&null!==e.fe){let n=e.O.Ye;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.fe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.c)for(let t of e.c)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ae,"for");for(let t of e.Pe)m(t)}else null!==e.C&&m(e.C)};for(let t of e.ce.values())for(let e of t)c(e),null!==e.D&&v(e.D);for(let t of e.oe.values())if(null!==t.N&&v(t.N),null!==t.B)for(let e of t.B)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.I.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.ie&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Ae.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Ae.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function $(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function M(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function N(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.on(),error:t})}var O={name:"devtools",install(){u.element=d(u.element,j),u.ve=d(u.ve,$),u.Ce=d(u.Ce,M),u.ze=d(u.ze,N),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))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:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.I.all()){let l=n._,o=n.je?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(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 l;return w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.st=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},C=O;export{C as default,O as devtools};
1
+ import{a as e}from"../chunks/chunk-DUUQZITD.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,p as i}from"../chunks/chunk-467LYA2V.js";import"../chunks/chunk-FBBHQU7S.js";import"../chunks/chunk-ZJYPRSTO.js";import"../chunks/chunk-T3FN37DU.js";import"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import"../chunks/chunk-JWRQLKOQ.js";import{a as u,b as d}from"../chunks/chunk-TNYNJXEC.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.on()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.we)for(let t of e.we)c(t);if(e instanceof r&&null!==e.pe){let n=e.C.Xe;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.pe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.u)for(let t of e.u)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ce,"for");for(let t of e.Ae)m(t)}else null!==e.I&&m(e.I)};for(let t of e.ue.values())for(let e of t)c(e),null!==e.D&&v(e.D);for(let t of e.oe.values())if(null!==t.N&&v(t.N),null!==t.M)for(let e of t.M)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.O.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.se&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Oe.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Oe.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function O(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function $(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function N(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.on(),error:t})}var M={name:"devtools",install(){u.element=d(u.element,j),u.re=d(u.re,O),u.me=d(u.me,$),u.Ye=d(u.Ye,N),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))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:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.O.all()){let l=n._,o=n.je?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(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 l;return w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.at=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},T=M;export{T as default,M as devtools};
2
2
  //# sourceMappingURL=devtools.js.map
@@ -1,2 +1,2 @@
1
- import{b as e,c as t,h as n,j as a}from"../chunks/chunk-F3DVWVH3.js";import{a as i,d as s,f as r}from"../chunks/chunk-CIBJLAA3.js";import{e as o}from"../chunks/chunk-5Q4M6A3C.js";import"../chunks/chunk-6I7GGFNJ.js";import{b as l}from"../chunks/chunk-UBGJGMSG.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-BGUJ3HF6.js";function $(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function p(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=$(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","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"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=e=>null==e?String(e):e instanceof Date?"a Date":Array.isArray(e)?"an array":"string"==typeof e?`a string (${JSON.stringify(e.length>32?e.slice(0,32)+"…":e)})`:"object"==typeof e?"an object":`a ${typeof e} (${String(e)})`,v=["","","class.","attr.","style."],k=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,x="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",j={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 ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t,n,a)=>`binding "${n?(v[a]??"")+n: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 ${x}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${x}`,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,t)=>`filter ${e} requires a number value, not ${y(t)}${"string"==typeof t?` — put |number before |${e}, or convert it where it is read`:""}`,29:(e,t)=>`filter ${e} requires a date value (a Date), not ${y(t)}${"string"==typeof t||"number"==typeof t?" — make the Date where it is read: a getter returning new Date(…)":""}`,52:(e,t)=>`filter ${e} takes a style of full, long, medium or short, not "${t}"`,53:e=>`filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${e}"`,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&&b.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)=>`${k(e,t)} failed to initialize.`,50:(e,...t)=>`${k(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${k(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>").`,122:(e,t)=>"class"===t?`"${e}": "class:" needs a class name — "class.NAME:" toggles one class (a bare "class:" would set an element property named "class", which does nothing). To set the whole class attribute, bind "className:".`:`"${e}": "attr:" needs an attribute name — "attr.NAME:" sets one attribute (a bare "attr:" would set an element property named "attr", which does nothing).`,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,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,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 T(e,t){let n=j[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var S=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),I=[[/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.']],O={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function A(e,t,n){let a=(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(O,e)?O[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?p(t,n):"");for(let[t,n]of I){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' 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 o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&S.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var M=new WeakMap,P=new WeakMap,W=new WeakSet,D=new WeakSet;function q(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 B(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let a=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==q(e.target,t.t)?.get?t:e.I.jt(o(t.t).o)}(e,t);return n.some(e=>null!=a(e)?.getter)?null:C(e,n,0,e.target,a)}function C(e,t,n,a,i){for(;n<t.length;n++){let s=t[n];if(null===a||"object"!=typeof a)return null;if("*"===s.s){if(!Array.isArray(a)||0===a.length)return null;let s=null;for(let r of a){let a=C(e,t,n+1,r,i);if(null===a)return null;if(null===s)s=a;else if(a.seg===s.seg)for(let e of a.names)s.names.includes(e)||s.names.push(e)}return s}if(Array.isArray(a)&&/^\d+$/.test(s.s)){if(Number(s.s)>=a.length)return null;a=a[Number(s.s)];continue}let r=q(a,s.s);if(void 0===r&&null===s.d&&e.kt.has(s.s))return null;if(void 0===r){let t=N(a),n=i(s.d);for(let a of e.I.all())a.d===n&&null!==a.getter&&t.push(a.s);return{seg:s.s,names:t}}if(void 0!==r.get||void 0!==r.set)return null;a=r.value}return null}function L(e){W.has(e)||(W.add(e),setTimeout(()=>function(e){W.delete(e);let t=M.get(e);if(void 0===t)return;let n=P.get(e);void 0===n&&P.set(e,n=new Set);for(let[a,s]of t){if(n.has(a))continue;n.add(a);let t=B(e,a);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!D.has(e)&&(a.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(a),r.initializePromise.then(()=>{D.add(r),L(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.st?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:a.t,missingSegment:t.seg});let u=e.I.jt(o(a.t).o),f="";if(void 0!==u&&u!==a&&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)}`);f=` 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/${l}] ${c} "${a.t}" does not resolve on the state tree: "${t.seg}" is not declared.${p(t.seg,t.names)}${f} Updates to this path will be silently dropped.${m}`)}}(e),0))}function z(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let a=M.get(e);void 0===a&&M.set(e,a=new Map),a.has(t)||a.set(t,n),L(e)}var E=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=!1;function U(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(H||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;H=!0;let r="function"==typeof n()?.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 "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\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:i.a,property:s})}var G=new WeakMap;function F(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)return;let s=G.get(e);void 0===s&&G.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. 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 J=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],R={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},_={name:"diagnostics",install(){d.Lo=A,d.Bo=T,d.So=z,d.detail=F,d.ze=c(d.ze,U);let e=d.de;d.de=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of J)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),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[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=N(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${E(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${E(a)}(?:${E(o)})*${E(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}}(n),function(e){P.delete(e),M.has(e)&&L(e)}(t)},d.ot=u(f,d.ot,(e,t)=>Object.hasOwn(R,t)?l(1701,[t,R[t]]):void 0)}},V=_;export{V as default,_ as diagnostics};
1
+ import{b as e,c as t,h as n,j as a}from"../chunks/chunk-ZJYPRSTO.js";import{a as i,d as s,f as r}from"../chunks/chunk-T3FN37DU.js";import{e as o}from"../chunks/chunk-NITPUCPA.js";import"../chunks/chunk-CBMAVRYG.js";import{b as l}from"../chunks/chunk-JWRQLKOQ.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-TNYNJXEC.js";function p(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function $(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=p(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","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"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=e=>null==e?String(e):e instanceof Date?"a Date":Array.isArray(e)?"an array":"string"==typeof e?`a string (${JSON.stringify(e.length>32?e.slice(0,32)+"…":e)})`:"object"==typeof e?"an object":`a ${typeof e} (${String(e)})`,v=["","","class.","attr.","style."],k=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,x="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",T={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 ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t,n,a)=>`binding "${n?(v[a]??"")+n: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 ${x}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${x}`,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,t)=>`filter ${e} requires a number value, not ${y(t)}${"string"==typeof t?` — put |number before |${e}, or convert it where it is read`:""}`,29:(e,t)=>`filter ${e} requires a date value (a Date), not ${y(t)}${"string"==typeof t||"number"==typeof t?" — make the Date where it is read: a getter returning new Date(…)":""}`,52:(e,t)=>`filter ${e} takes a style of full, long, medium or short, not "${t}"`,53:e=>`filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${e}"`,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&&b.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)=>`${k(e,t)} failed to initialize.`,50:(e,...t)=>`${k(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${k(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>").`,122:(e,t)=>"class"===t?`"${e}": "class:" needs a class name — "class.NAME:" toggles one class (a bare "class:" would set an element property named "class", which does nothing). To set the whole class attribute, bind "className:".`:`"${e}": "attr:" needs an attribute name — "attr.NAME:" sets one attribute (a bare "attr:" would set an element property named "attr", which does nothing).`,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,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,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 j(e,t){let n=T[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var O=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),S=[[/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.']],M={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function A(e,t,n){let a=(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(M,e)?M[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?$(t,n):"");for(let[t,n]of S){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' 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 o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&O.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var P=new WeakMap,W=new WeakMap,I=new WeakSet,D=new WeakSet;function N(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 q(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 C(e,t){let n=[];for(let e=t;null!==e;e=e.c)n.unshift(e);let a=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==N(e.target,t.t)?.get?t:e.O.wt(o(t.t).o)}(e,t);return n.some(e=>null!=a(e)?.getter)?null:U(e,n,0,e.target,a)}function U(e,t,n,a,i){for(;n<t.length;n++){let s=t[n];if(null===a||"object"!=typeof a)return null;if("*"===s.s){if(!Array.isArray(a)||0===a.length)return null;let s=null;for(let r of a){let a=U(e,t,n+1,r,i);if(null===a)return null;if(null===s)s=a;else if(a.seg===s.seg)for(let e of a.names)s.names.includes(e)||s.names.push(e)}return s}if(Array.isArray(a)&&/^\d+$/.test(s.s)){if(Number(s.s)>=a.length)return null;a=a[Number(s.s)];continue}let r=N(a,s.s);if(void 0===r&&null===s.c&&e.tt.has(s.s))return null;if(void 0===r){let r=q(a),o=i(s.c);for(let t of e.O.all())t.c===o&&null!==t.getter&&r.push(t.s);return{seg:s.s,names:r,r:t.slice(0,n).some(e=>"*"===e.s)}}if(void 0!==r.get||void 0!==r.set)return null;a=r.value}return null}function B(e){I.has(e)||(I.add(e),setTimeout(()=>function(e){I.delete(e);let t=P.get(e);if(void 0===t)return;let n=W.get(e);void 0===n&&W.set(e,n=new Set);let a=new Map(t),s=new Map;for(let i of e.O.all()){let e=null===i.c||n.has(i)||t.has(i)?void 0:i.B.find(e=>!e.hn);void 0!==e&&(s.set(i,e),a.set(i,3))}for(let[t,r]of a){if(n.has(t))continue;n.add(t);let a=C(e,t);if(null===a)continue;let l=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!D.has(e)&&(t.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==l){n.delete(t),l.initializePromise.then(()=>{D.add(l),B(e)});continue}let c=e.O.wt(o(t.t).o),u="";if(void 0!==c&&c!==t&&null!==c.getter){let e=c.h.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(c.h[t].t.length+2)}`);u=` The getter "${c.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}let f=$(a.seg,a.names);if((a.r||3===r)&&""===f&&""===u)continue;let[h,p,g]=1===r?["watch-path-missing","$watch path","watch"]:2===r?["post-update-path-missing","$postUpdate path","postUpdate"]:3===r?["read-path-missing","Path","getter"]:["binding-path-missing","Bound path","binding"];d.at?.(e,{type:"state:path-unresolved",source:g,path:t.t,missingSegment:a.seg}),console.warn(`[@wcstack/state] [wcs/${h}] ${p} "${t.t}"${3===r?` read by the getter "${s.get(t).t}"`:""} does not resolve on the state tree: "${a.seg}" is not declared.${f}${u} ${2===r?"The call updates nothing.":3===r?"The getter reads undefined.":"Updates to this path will be silently dropped."}${m}`)}}(e),0))}function L(e,t,n=!1){E(e,t,n?1:0)}function E(e,t,n){if("$"===t.t[0]||t.t.includes("#")||0===n&&null===t.c)return;let a=P.get(e);void 0===a&&P.set(e,a=new Map),a.has(t)||a.set(t,n),B(e)}var z=new WeakSet,H=!1,R=new WeakMap;function Y(e,t){let n=R.get(e),a=t.s;if(null!==t.c||H||void 0===n||n.has(a)||"$"===a[0]||e.tt.has(a))return;let s=$(a,[...n]);n.add(a),""!==s&&![...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].some(e=>`${e.getAttribute("mount")}.`.startsWith(`${a}.`))&&console.warn(`[@wcstack/state] [wcs/write-path-missing] "${a}" is not declared: writing it creates a new key.${s}${m}`)}var J=new WeakSet;function _(e){if(J.has(e))return;J.add(e);let t=e.emit,n=!1;e.emit=(...a)=>(0===e.size&&!n&&(n=!0,console.warn(`[@wcstack/state] [wcs/command-token-unbound] "$command.${e.name}" was emitted with no subscriber and is lost: its element is not defined or rendered yet (emit from $renderedCallback), or no command. binding takes it.${m}`)),t.apply(e,a))}var F=new WeakMap;function V(e,t,n){let a=e.target;for(let e of t.split("."))a=null==a?void 0:N(a,e)?.value;if("function"!=typeof a||!String(a).includes("currentTarget"))return;let i=F.get(e);void 0===i&&F.set(e,i=new Set),!i.has(t)&&(i.add(t),console.warn(`[@wcstack/state] [wcs/delegated-current-target] "${t}" reads event.currentTarget, the root for a delegated on${n}:. Write on${n}#direct:, or use event.target.closest(…).${m}`))}function G(e){P.has(e)&&e.He.length>0&&B(e)}var Q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=!1;function K(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(X||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;X=!0;let r="function"==typeof n()?.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 "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\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:i.a,property:s})}var Z=new WeakMap;function ee(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)return;let s=Z.get(e);void 0===s&&Z.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. 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 te=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],ne={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},ae={name:"diagnostics",install(){d.Bo=A,d.Mo=j,d.$o=L,d.detail=ee,d.Ye=c(d.Ye,K);let e=d.fe;d.fe=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of te)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),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[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=q(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${Q(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${Q(a)}(?:${Q(o)})*${Q(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}}(n),function(e){W.delete(e),P.has(e)&&B(e)}(t),function(e){if(z.has(e))return;z.add(e);let t=e.Xn,n=t.$postUpdate;t.$postUpdate=t=>{H=!0;try{n(t)}finally{H=!1}let a=e.O.wt(o(t).o);void 0!==a&&E(e,a,2)}}(t),function(e){if(void 0!==Object.getOwnPropertyDescriptor(e,"commands")?.set)return;let t=e.commands;Object.defineProperty(e,"commands",{configurable:!0,get:()=>t,set:e=>{t=e;for(let t of Object.values(e))_(t)}})}(t),R.set(t,new Set(q(n)))},d.handlerThrew=V,d.re=c(d.re,Y),d.me=c(d.me,G),d.rt=u(f,d.rt,(e,t)=>Object.hasOwn(ne,t)?l(1701,[t,ne[t]]):void 0)}},ie=ae;export{ie as default,ae as diagnostics};
2
2
  //# sourceMappingURL=diagnostics.js.map