@wcstack/state 4.1.1 → 4.2.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 (53) hide show
  1. package/README.ja.md +20 -17
  2. package/README.md +20 -17
  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/manifest.esm.js +73 -34
  8. package/dist/parser.esm.js +10 -4
  9. package/dist/split/auto.js +1 -1
  10. package/dist/split/chunks/chunk-2RBI6DVS.js +2 -0
  11. package/dist/split/chunks/chunk-2RBI6DVS.js.map +1 -0
  12. package/dist/split/chunks/{chunk-V3HFN3MW.js → chunk-3Q7LGONS.js} +2 -2
  13. package/dist/split/chunks/{chunk-V3HFN3MW.js.map → chunk-3Q7LGONS.js.map} +1 -1
  14. package/dist/split/chunks/{chunk-UFIDBJBP.js → chunk-4ECL4ITF.js} +2 -2
  15. package/dist/split/chunks/{chunk-7ZU3CLEG.js → chunk-BGUJ3HF6.js} +2 -2
  16. package/dist/split/chunks/{chunk-4HLDITUB.js → chunk-BI4645UG.js} +2 -2
  17. package/dist/split/chunks/chunk-BI4645UG.js.map +1 -0
  18. package/dist/split/chunks/{chunk-JAEYZSVS.js → chunk-BYQBV3ZC.js} +2 -2
  19. package/dist/split/chunks/{chunk-R5OJ52SF.js → chunk-CIBJLAA3.js} +2 -2
  20. package/dist/split/chunks/{chunk-R5OJ52SF.js.map → chunk-CIBJLAA3.js.map} +1 -1
  21. package/dist/split/chunks/chunk-JK3B3LLB.js +2 -0
  22. package/dist/split/chunks/chunk-OKBVNGFK.js +2 -0
  23. package/dist/split/chunks/{chunk-JZW5KGXQ.js.map → chunk-OKBVNGFK.js.map} +1 -1
  24. package/dist/split/chunks/{chunk-GGSHXG7N.js → chunk-UBGJGMSG.js} +2 -2
  25. package/dist/split/chunks/chunk-UBGJGMSG.js.map +1 -0
  26. package/dist/split/chunks/{chunk-7QVEF5E3.js → chunk-UPSLR4FS.js} +2 -2
  27. package/dist/split/core.js +1 -1
  28. package/dist/split/features/devtools.js +1 -1
  29. package/dist/split/features/diagnostics.js +1 -1
  30. package/dist/split/features/diagnostics.js.map +1 -1
  31. package/dist/split/features/formats.d.ts +1 -1
  32. package/dist/split/features/formats.js +1 -1
  33. package/dist/split/features/formats.js.map +1 -1
  34. package/dist/split/features/list-keys.js +1 -1
  35. package/dist/split/features/native-commands.js +1 -1
  36. package/dist/split/features/recursion.js +1 -1
  37. package/dist/split/features/scopes.js +1 -1
  38. package/dist/split/features/ssr.js +1 -1
  39. package/dist/split/features/temporal.js +1 -1
  40. package/dist/split/features/temporal.js.map +1 -1
  41. package/dist/wcs-manifest.json +25 -7
  42. package/package.json +1 -1
  43. package/dist/split/chunks/chunk-4HLDITUB.js.map +0 -1
  44. package/dist/split/chunks/chunk-BWGPKDHS.js +0 -2
  45. package/dist/split/chunks/chunk-BWGPKDHS.js.map +0 -1
  46. package/dist/split/chunks/chunk-GGSHXG7N.js.map +0 -1
  47. package/dist/split/chunks/chunk-JZW5KGXQ.js +0 -2
  48. package/dist/split/chunks/chunk-XEGL4FW5.js +0 -2
  49. /package/dist/split/chunks/{chunk-UFIDBJBP.js.map → chunk-4ECL4ITF.js.map} +0 -0
  50. /package/dist/split/chunks/{chunk-7ZU3CLEG.js.map → chunk-BGUJ3HF6.js.map} +0 -0
  51. /package/dist/split/chunks/{chunk-JAEYZSVS.js.map → chunk-BYQBV3ZC.js.map} +0 -0
  52. /package/dist/split/chunks/{chunk-XEGL4FW5.js.map → chunk-JK3B3LLB.js.map} +0 -0
  53. /package/dist/split/chunks/{chunk-7QVEF5E3.js.map → chunk-UPSLR4FS.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["config","bindAttributeName","commentForPrefix","commentIfPrefix","commentElseIfPrefix","commentElsePrefix","tagNames","state","ssr","locale","document","documentElement","lang","enableContractAnalyzer","setConfig","partial","options","tags","given","Object","entries","filter","value","givenTags","tag","key","current","hasOwn","Array","isArray","raise","name","getConfig","FORMATS_FILTER_NAMES","definitions","Map","resolvedByKey","registerFilters","map","keys","set","clear","hasFilter","has","resolveFilter","literals","args","JSON","stringify","filterArgsKey","resolved","get","definition","known","includes","raiseError","unknownFilter","min","max","arity","length","filterFn","factory","c","x","b","y","A","O","h"],"sources":["../../../src/config.ts","../../../src/filters/registry.ts"],"sourcesContent":["import { raise, M } from \"./messages\";\n\n/**\n * Page-wide configuration (`bootstrapState(config)`): how this page spells wcstack markup (the tag\n * names, the binding attribute, the anchor comments — fixed before the first definition, the same\n * on the server) and the locale default. How a state tree behaves is its own `$behavior` (engine.ts).\n */\nexport interface Config {\n bindAttributeName: string;\n /** The text of a `for` template's anchor comment. */\n commentForPrefix: string;\n /** The texts of an `if` / `elseif` / `else` chain's anchor comments. */\n commentIfPrefix: string;\n commentElseIfPrefix: string;\n commentElsePrefix: string;\n tagNames: { state: string; ssr: string };\n locale: string;\n /** Opt-in `analyzeContract()` (dev time); off, it returns at once. */\n enableContractAnalyzer: boolean;\n}\n\nexport const config: Config = {\n bindAttributeName: \"data-wcs\",\n commentForPrefix: \"wcs-for\",\n commentIfPrefix: \"wcs-if\",\n commentElseIfPrefix: \"wcs-elseif\",\n commentElsePrefix: \"wcs-else\",\n tagNames: { state: \"wcs-state\", ssr: \"wcs-ssr\" },\n locale: typeof document !== \"undefined\" ? document.documentElement?.lang || \"en\" : \"en\",\n enableContractAnalyzer: false,\n};\n\nexport type PartialConfig = Partial<Omit<Config, \"tagNames\">> & { tagNames?: Partial<Config[\"tagNames\"]> };\n\n/**\n * Applies the options given; an undefined value is left out. An option `bootstrapState` does not\n * have (a key 4.0 moved to the state's `$behavior` or removed included), a value of another type\n * than its default (null, or an array for an object, included) or a tag name it does not define\n * throws, and then nothing is applied — the same rule as every package's bootstrap.\n */\nexport function setConfig(partial: PartialConfig): void {\n const options = config as unknown as Record<string, unknown>;\n const tags = config.tagNames as Record<string, string>;\n const given = Object.entries(partial).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partial.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n raise(M.OptionInvalid, [\"bootstrapState\", key]);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") raise(M.OptionInvalid, [\"bootstrapState\", `tagNames.${name}`]);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n}\n\n/** The current configuration (read-only view). */\nexport const getConfig = (): Readonly<Config> => config;\n","/**\n * filters/registry.ts — the filter registry, ported from `@wcstack/state` (`core/filterRegistry.ts`).\n *\n * The grammar (`path|filter(args)`) only produces names and arguments; the functions are looked up\n * here when the bindings are planned. The core set (`./core`) and the formats add-on (`./formats`)\n * each put their filters in with an install call; this module knows neither implementation, so a\n * page that skips the add-on does not carry its code.\n *\n * Differences from the source, all decided:\n * - one registry, not an input / output pair (the source registered the same table in both);\n * - no aliases (`inc dec fix uc lc cap pad rep rev null` are not carried over);\n * - every registered filter has arity bounds (the source allowed them to be absent);\n * - the core set is registered like any other (the source hard-wired `not` into the registry).\n */\nimport { raiseError } from \"../parser/raiseError\";\nimport { raise, M } from \"../messages\";\n\nexport type FilterFn = (value: unknown) => unknown;\n\n/**\n * Builds the function for one use of a filter. `options` are the argument texts (unquoted),\n * `literals` their typed values (requirement B9 — only filters that compare or return an argument\n * read them).\n */\nexport type FilterFactory = (options: string[], literals: readonly unknown[]) => FilterFn;\n\n/** A filter as an install call hands it to the registry: the factory and its [min, max] argument count (B3). */\nexport interface FilterDefinition {\n factory: FilterFactory;\n arity: readonly [number, number];\n}\n\n/**\n * The formats add-on's filters (37: up to 4.0.0-rc.3 the 23 display ones, then the core's\n * arithmetic, conversion and missing-value 14). Only the names live here (not the code), so that a\n * page without the add-on can still say where one of them comes from instead of calling it a typo.\n * A test keeps this list equal to the add-on's table.\n */\nexport const FORMATS_FILTER_NAMES: readonly string[] = [\n \"toFixed\", \"locale\",\n \"upper\", \"lower\", \"capitalize\", \"trim\", \"slice\", \"padStart\", \"padEnd\", \"repeat\", \"reverse\", \"truncate\", \"join\",\n \"round\", \"floor\", \"ceil\", \"percent\", \"unit\",\n \"date\", \"time\", \"datetime\", \"ymd\", \"hms\",\n \"add\", \"sub\", \"mul\", \"div\", \"mod\", \"abs\", \"clamp\", \"int\", \"float\", \"defaults\", \"coalesce\", \"number\", \"string\", \"nullIfEmpty\",\n];\n\n/**\n * A `Map`, not a plain object: bracket access on an object lets the `Object.prototype` members\n * through as filters (`|toString` / `|constructor` / `|valueOf`), which then fail with a\n * meaningless TypeError instead of `[wcs/filter-unknown]`.\n */\nconst definitions = new Map<string, FilterDefinition>();\n\n/** Name + arguments → the function already built for them (each is built once). */\nconst resolvedByKey = new Map<string, FilterFn>();\n\n/**\n * The key of one argument list: **both the raw texts and the typed values** (B3 / B9).\n * - Raw texts alone would make `defaults(0)` and `defaults('0')` the same `[\"0\"]`, sharing one\n * function between two filters of different types.\n * - Typed values alone would fold `1` / `1.0` / `01` / `+1` into the same number, although the\n * factories that read the raw text (`truncate` / `unit` / `join` / `ymd` / `padStart` …) answer\n * them differently.\n * - A structural key, never `args.join(\",\")`: `['a,b']` and `['a', 'b']` are different arguments.\n */\nexport function filterArgsKey(args: readonly string[], literals: readonly unknown[]): string {\n return `${JSON.stringify(args)}${JSON.stringify(literals)}`;\n}\n\n/** Called by the install functions. Idempotent — a name registered again replaces the previous one. */\nexport function registerFilters(map: Record<string, FilterDefinition>): void {\n for (const name of Object.keys(map)) {\n // a copy: the registry keeps what was registered\n definitions.set(name, { ...map[name] });\n }\n // A new registration can change the answers already built (a page installs once; tests and\n // tooling swap registrations)\n resolvedByKey.clear();\n}\n\nexport function hasFilter(name: string): boolean {\n return definitions.has(name);\n}\n\n/** The registered names, which the did-you-mean suggestion reads. */\nexport function knownFilterNames(): string[] {\n return [...definitions.keys()];\n}\n\n/** Drops the functions already built (tooling that clears its parser caches). */\nexport function clearFilterResolutionCache(): void {\n resolvedByKey.clear();\n}\n\n/**\n * `[wcs/filter-unknown]`. A formatting filter on a page without the formats add-on is not a typo:\n * that barrier is kept as full text, since it is met on pages without add-ons (the diagnostics\n * add-on adds the nearest name to either).\n */\nfunction unknownFilter(name: string, known: Iterable<string>): never {\n if (FORMATS_FILTER_NAMES.includes(name)) {\n raiseError(`[wcs/filter-unknown] filter not found: ${name}. \"${name}\" is in the formats add-on — install it with installFeatures([formats]) from \"@wcstack/state/features/formats\".`, name, known);\n }\n raise(M.FilterUnknown, [name], name, known);\n}\n\n/**\n * The function for one use of a filter (binding planning). An unknown name or a wrong argument count\n * fails here, by name — the parser never rejects a filter.\n */\nexport function resolveFilter(name: string, options: string[], literals: readonly unknown[]): FilterFn {\n const key = `${name}${filterArgsKey(options, literals)}`;\n const resolved = resolvedByKey.get(key);\n if (typeof resolved !== \"undefined\") {\n return resolved;\n }\n const definition = definitions.get(name);\n if (definition === undefined) {\n unknownFilter(name, definitions.keys());\n }\n // Same vocabulary as lint's wcs/filter-arity\n const [min, max] = definition.arity;\n if (options.length < min) raise(M.FilterTooFewArgs, [name, min, options.length]);\n if (options.length > max) raise(M.FilterTooManyArgs, [name, max, options.length]);\n const filterFn = definition.factory(options, literals);\n resolvedByKey.set(key, filterFn);\n return filterFn;\n}\n"],"mappings":"gFAqBO,IAAMA,EAAiB,CAC5BC,kBAAmB,WACnBC,iBAAkB,UAClBC,gBAAiB,SACjBC,oBAAqB,aACrBC,kBAAmB,WACnBC,SAAU,CAAEC,MAAO,YAAaC,IAAK,WACrCC,cAAeC,SAAa,KAAcA,SAASC,iBAAiBC,MAAQ,KAC5EC,wBAAwB,GAWnB,SAASC,EAAUC,GACxB,IAAMC,EAAUhB,EACViB,EAAOjB,EAAOM,SACdY,EAAQC,OAAOC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,CAAcjC,EAAS6B,KACvCK,EAAWd,EAAce,IAAI1B,GACnC,UAAWyB,EAAa,IACtB,OAAOA,EAET,IAAME,EAAalB,EAAYiB,IAAIpB,QAChB,IAAfqB,GAlBN,SAAuBrB,EAAcsB,GAC/BpB,EAAqBqB,SAASvB,IAChCwB,EAAW,0CAA0CxB,OAAUA,mHAAuHA,EAAMsB,GAE9LvB,MAAuB,CAACC,GAAOA,EAAMsB,EACvC,CAcIG,CAAczB,EAAMG,EAAYK,QAGlC,IAAOkB,EAAKC,GAAON,EAAWO,MAC1B3C,EAAQ4C,OAASH,GAAK3B,MAA0B,CAACC,EAAM0B,EAAKzC,EAAQ4C,SACpE5C,EAAQ4C,OAASF,GAAK5B,MAA2B,CAACC,EAAM2B,EAAK1C,EAAQ4C,SACzE,IAAMC,EAAWT,EAAWU,QAAQ9C,EAAS6B,GAC7C,OAAAT,EAAcI,IAAIf,EAAKoC,GAChBA,CACT,QAAAE,EAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
1
+ {"version":3,"names":["config","bindAttributeName","commentForPrefix","commentIfPrefix","commentElseIfPrefix","commentElsePrefix","tagNames","state","ssr","locale","document","documentElement","lang","enableContractAnalyzer","setConfig","partial","options","tags","given","Object","entries","filter","value","givenTags","tag","key","current","hasOwn","Array","isArray","raise","name","getConfig","FORMATS_FILTER_NAMES","definitions","Map","resolvedByKey","registerFilters","map","keys","set","clear","hasFilter","has","resolveFilter","literals","args","JSON","stringify","filterArgsKey","resolved","get","definition","known","includes","raiseError","unknownFilter","min","max","arity","length","filterFn","factory","c","x","b","y","A","O","h"],"sources":["../../../src/config.ts","../../../src/filters/registry.ts"],"sourcesContent":["import { raise, M } from \"./messages\";\n\n/**\n * Page-wide configuration (`bootstrapState(config)`): how this page spells wcstack markup (the tag\n * names, the binding attribute, the anchor comments — fixed before the first definition, the same\n * on the server) and the locale default. How a state tree behaves is its own `$behavior` (engine.ts).\n */\nexport interface Config {\n bindAttributeName: string;\n /** The text of a `for` template's anchor comment. */\n commentForPrefix: string;\n /** The texts of an `if` / `elseif` / `else` chain's anchor comments. */\n commentIfPrefix: string;\n commentElseIfPrefix: string;\n commentElsePrefix: string;\n tagNames: { state: string; ssr: string };\n locale: string;\n /** Opt-in `analyzeContract()` (dev time); off, it returns at once. */\n enableContractAnalyzer: boolean;\n}\n\nexport const config: Config = {\n bindAttributeName: \"data-wcs\",\n commentForPrefix: \"wcs-for\",\n commentIfPrefix: \"wcs-if\",\n commentElseIfPrefix: \"wcs-elseif\",\n commentElsePrefix: \"wcs-else\",\n tagNames: { state: \"wcs-state\", ssr: \"wcs-ssr\" },\n locale: typeof document !== \"undefined\" ? document.documentElement?.lang || \"en\" : \"en\",\n enableContractAnalyzer: false,\n};\n\nexport type PartialConfig = Partial<Omit<Config, \"tagNames\">> & { tagNames?: Partial<Config[\"tagNames\"]> };\n\n/**\n * Applies the options given; an undefined value is left out. An option `bootstrapState` does not\n * have (a key 4.0 moved to the state's `$behavior` or removed included), a value of another type\n * than its default (null, or an array for an object, included) or a tag name it does not define\n * throws, and then nothing is applied — the same rule as every package's bootstrap.\n */\nexport function setConfig(partial: PartialConfig): void {\n const options = config as unknown as Record<string, unknown>;\n const tags = config.tagNames as Record<string, string>;\n const given = Object.entries(partial).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partial.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n raise(M.OptionInvalid, [\"bootstrapState\", key]);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") raise(M.OptionInvalid, [\"bootstrapState\", `tagNames.${name}`]);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n}\n\n/** The current configuration (read-only view). */\nexport const getConfig = (): Readonly<Config> => config;\n","/**\n * filters/registry.ts — the filter registry, ported from `@wcstack/state` (`core/filterRegistry.ts`).\n *\n * The grammar (`path|filter(args)`) only produces names and arguments; the functions are looked up\n * here when the bindings are planned. The core set (`./core`) and the formats add-on (`./formats`)\n * each put their filters in with an install call; this module knows neither implementation, so a\n * page that skips the add-on does not carry its code.\n *\n * Differences from the source, all decided:\n * - one registry, not an input / output pair (the source registered the same table in both);\n * - no aliases (`inc dec fix uc lc cap pad rep rev null` are not carried over);\n * - every registered filter has arity bounds (the source allowed them to be absent);\n * - the core set is registered like any other (the source hard-wired `not` into the registry).\n */\nimport { raiseError } from \"../parser/raiseError\";\nimport { raise, M } from \"../messages\";\n\nexport type FilterFn = (value: unknown) => unknown;\n\n/**\n * Builds the function for one use of a filter. `options` are the argument texts (unquoted),\n * `literals` their typed values (requirement B9 — only filters that compare or return an argument\n * read them).\n */\nexport type FilterFactory = (options: string[], literals: readonly unknown[]) => FilterFn;\n\n/** A filter as an install call hands it to the registry: the factory and its [min, max] argument count (B3). */\nexport interface FilterDefinition {\n factory: FilterFactory;\n arity: readonly [number, number];\n}\n\n/**\n * The formats add-on's filters (37: up to 4.0.0-rc.3 the 23 display ones, then the core's\n * arithmetic, conversion and missing-value 14). Only the names live here (not the code), so that a\n * page without the add-on can still say where one of them comes from instead of calling it a typo.\n * A test keeps this list equal to the add-on's table.\n */\nexport const FORMATS_FILTER_NAMES: readonly string[] = [\n \"toFixed\", \"locale\",\n \"upper\", \"lower\", \"capitalize\", \"trim\", \"slice\", \"padStart\", \"padEnd\", \"repeat\", \"reverse\", \"truncate\", \"join\",\n \"round\", \"floor\", \"ceil\", \"percent\", \"unit\",\n \"date\", \"time\", \"datetime\", \"ymd\", \"hms\",\n \"add\", \"sub\", \"mul\", \"div\", \"mod\", \"abs\", \"clamp\", \"int\", \"float\", \"defaults\", \"coalesce\", \"number\", \"string\", \"nullIfEmpty\",\n \"currency\",\n];\n\n/**\n * A `Map`, not a plain object: bracket access on an object lets the `Object.prototype` members\n * through as filters (`|toString` / `|constructor` / `|valueOf`), which then fail with a\n * meaningless TypeError instead of `[wcs/filter-unknown]`.\n */\nconst definitions = new Map<string, FilterDefinition>();\n\n/** Name + arguments → the function already built for them (each is built once). */\nconst resolvedByKey = new Map<string, FilterFn>();\n\n/**\n * The key of one argument list: **both the raw texts and the typed values** (B3 / B9).\n * - Raw texts alone would make `defaults(0)` and `defaults('0')` the same `[\"0\"]`, sharing one\n * function between two filters of different types.\n * - Typed values alone would fold `1` / `1.0` / `01` / `+1` into the same number, although the\n * factories that read the raw text (`truncate` / `unit` / `join` / `ymd` / `padStart` …) answer\n * them differently.\n * - A structural key, never `args.join(\",\")`: `['a,b']` and `['a', 'b']` are different arguments.\n */\nexport function filterArgsKey(args: readonly string[], literals: readonly unknown[]): string {\n return `${JSON.stringify(args)}${JSON.stringify(literals)}`;\n}\n\n/** Called by the install functions. Idempotent — a name registered again replaces the previous one. */\nexport function registerFilters(map: Record<string, FilterDefinition>): void {\n for (const name of Object.keys(map)) {\n // a copy: the registry keeps what was registered\n definitions.set(name, { ...map[name] });\n }\n // A new registration can change the answers already built (a page installs once; tests and\n // tooling swap registrations)\n resolvedByKey.clear();\n}\n\nexport function hasFilter(name: string): boolean {\n return definitions.has(name);\n}\n\n/** The registered names, which the did-you-mean suggestion reads. */\nexport function knownFilterNames(): string[] {\n return [...definitions.keys()];\n}\n\n/** Drops the functions already built (tooling that clears its parser caches). */\nexport function clearFilterResolutionCache(): void {\n resolvedByKey.clear();\n}\n\n/**\n * `[wcs/filter-unknown]`. A formatting filter on a page without the formats add-on is not a typo:\n * that barrier is kept as full text, since it is met on pages without add-ons (the diagnostics\n * add-on adds the nearest name to either).\n */\nfunction unknownFilter(name: string, known: Iterable<string>): never {\n if (FORMATS_FILTER_NAMES.includes(name)) {\n raiseError(`[wcs/filter-unknown] filter not found: ${name}. \"${name}\" is in the formats add-on — install it with installFeatures([formats]) from \"@wcstack/state/features/formats\".`, name, known);\n }\n raise(M.FilterUnknown, [name], name, known);\n}\n\n/**\n * The function for one use of a filter (binding planning). An unknown name or a wrong argument count\n * fails here, by name — the parser never rejects a filter.\n */\nexport function resolveFilter(name: string, options: string[], literals: readonly unknown[]): FilterFn {\n const key = `${name}${filterArgsKey(options, literals)}`;\n const resolved = resolvedByKey.get(key);\n if (typeof resolved !== \"undefined\") {\n return resolved;\n }\n const definition = definitions.get(name);\n if (definition === undefined) {\n unknownFilter(name, definitions.keys());\n }\n // Same vocabulary as lint's wcs/filter-arity\n const [min, max] = definition.arity;\n if (options.length < min) raise(M.FilterTooFewArgs, [name, min, options.length]);\n if (options.length > max) raise(M.FilterTooManyArgs, [name, max, options.length]);\n const filterFn = definition.factory(options, literals);\n resolvedByKey.set(key, filterFn);\n return filterFn;\n}\n"],"mappings":"gFAqBO,IAAMA,EAAiB,CAC5BC,kBAAmB,WACnBC,iBAAkB,UAClBC,gBAAiB,SACjBC,oBAAqB,aACrBC,kBAAmB,WACnBC,SAAU,CAAEC,MAAO,YAAaC,IAAK,WACrCC,cAAeC,SAAa,KAAcA,SAASC,iBAAiBC,MAAQ,KAC5EC,wBAAwB,GAWnB,SAASC,EAAUC,GACxB,IAAMC,EAAUhB,EACViB,EAAOjB,EAAOM,SACdY,EAAQC,OAAOC,QAAQL,GAASM,OAAO,EAAE,CAAEC,UAAqB,IAAVA,GACtDC,EAAYJ,OAAOC,QAAQL,EAAQT,UAAY,CAAC,GAAGe,OAAO,EAAE,CAAEG,UAAiB,IAARA,GAC7E,QAAYC,EAAKH,KAAUJ,EAAO,CAChC,IAAMQ,EAAUV,EAAQS,KACnBN,OAAOQ,OAAOX,EAASS,IAAkB,OAAVH,UAAyBA,UAAiBI,GAAWE,MAAMC,QAAQP,KAAWM,MAAMC,QAAQH,KAC9HI,KAAuB,CAAC,iBAAkBL,GAE9C,CACA,QAAYM,EAAMP,KAAQD,IACnBJ,OAAOQ,OAAOV,EAAMc,IAAwB,iBAARP,IAAkBM,KAAuB,CAAC,i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AASF,GAAK5B,MAA2B,CAACC,EAAM2B,EAAK1C,EAAQ4C,SACzE,IAAMC,EAAWT,EAAWU,QAAQ9C,EAAS6B,GAC7C,OAAAT,EAAcI,IAAIf,EAAKoC,GAChBA,CACT,QAAAE,EAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ var t=class{constructor(t,l,i){this.c=[],this.getter=null,this.ie=null,this.se=!1,this.W=[],this.Q=[],this.pt=null,this.A=-1,this.z=s,this.De=null,this.It=null,this.Dt=null,this._=null,this.pn=!1,this.mn=!1,this.Wn=!1,this.Z=0,this.mt=new Set,this.t=t,this.d=i,this.s=l;let e=null===i?[null]:i.h.slice(),h="*"===l;h&&e.push(i),this.n=e.length-1,this.q=h?[]:null===i?[l]:[...i.q,l],this.h=e}_n(t){this.mt.has(t)||(this.mt.add(t),this.W.push(t),t.Q.push(this))}Io(t){this.mt.delete(t);let s=this.W;s.splice(s.indexOf(t),1)}Do(){this.getter=null,this.ie=null,this.A=-1,this.z=s,this.W.length=0,this.mt.clear(),this.Q.length=0,this.pt=null,this.De=null,this.It=null,this.Dt=null,this._=null}ee(t){let s=this;for(;null!==s;){if(s===t)return!0;s=s.d}return!1}},s=Symbol("unset"),l=Symbol("dirty"),i=Symbol("failed"),e=class{constructor(t=null){this.ht=new Map,this.Vn=t}jt(t){return this.ht.get(t)}get(s){let l=this.ht.get(s);if(void 0!==l)return l;let i=s.lastIndexOf("."),e=i<0?null:this.get(s.slice(0,i));return l=new t(s,s.slice(i+1),e),this.Vn?.(l),this.ht.set(s,l),e&&e.c.push(l),l}all(){return this.ht.values()}Lt(t){this.ht.delete(t.t)}},h=new Map;function n(t){let s=h.get(t);if(void 0!==s)return s;let l=!0,i=t.split("."),e=[];for(let t=0;t<i.length;t++){let s=i[t],h=s.charCodeAt(0);t>0&&h>=48&&h<=57?(l=!1,e.push(Number(s)),i[t]="*"):"*"===s&&e.push(-1)}if(!l)return{o:i.join("."),indexes:e};let n={o:t,indexes:null};return h.size>4095&&h.clear(),h.set(t,n),n}export{s as a,l as b,i as c,e as d,n as e};
2
+ //# sourceMappingURL=chunk-JK3B3LLB.js.map
@@ -0,0 +1,2 @@
1
+ var a="4.2.0";export{a};
2
+ //# sourceMappingURL=chunk-OKBVNGFK.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["VERSION","r"],"sources":["../../../package.json","../../../src/version.ts"],"sourcesContent":["{\n \"name\": \"@wcstack/state\",\n \"version\": \"4.1.1\",\n \"description\": \"Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.\",\n \"type\": \"module\",\n \"main\": \"./dist/index.esm.js\",\n \"module\": \"./dist/index.esm.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.esm.js\"\n },\n \"./auto\": \"./dist/auto.min.js\",\n \"./core\": {\n \"types\": \"./dist/split/core.d.ts\",\n \"import\": \"./dist/split/core.js\"\n },\n \"./features/*\": {\n \"types\": \"./dist/split/features/*.d.ts\",\n \"import\": \"./dist/split/features/*.js\"\n },\n \"./define\": {\n \"types\": \"./dist/define.d.ts\",\n \"import\": \"./dist/define.js\"\n },\n \"./manifest\": {\n \"types\": \"./dist/manifest.d.ts\",\n \"import\": \"./dist/manifest.esm.js\"\n },\n \"./parser\": {\n \"types\": \"./dist/parser.d.ts\",\n \"import\": \"./dist/parser.esm.js\"\n },\n \"./wcs-manifest.json\": \"./dist/wcs-manifest.json\"\n },\n \"files\": [\n \"dist\",\n \"!dist/core.min.js\"\n ],\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist', { recursive: true, force: true })\\\"\",\n \"build\": \"node build.mjs\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"lint\": \"eslint src\",\n \"typecheck\": \"tsc --noEmit\",\n \"golden\": \"node scripts/golden.mjs\",\n \"version:patch\": \"npm version patch\",\n \"version:minor\": \"npm version minor\",\n \"version:major\": \"npm version major\",\n \"prepublishOnly\": \"npm run build && npm run test:coverage\"\n },\n \"keywords\": [\n \"web-components\",\n \"state-management\",\n \"reactive\",\n \"data-binding\",\n \"proxy\",\n \"custom-elements\",\n \"shadow-dom\",\n \"buildless\",\n \"zero-dependencies\",\n \"declarative\"\n ],\n \"author\": \"mogera551\",\n \"homepage\": \"https://wcstack.github.io\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/wcstack/wcstack.git\",\n \"directory\": \"packages/state\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/wcstack/wcstack/issues\"\n },\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.5\",\n \"@vitest/coverage-v8\": \"^4.1.11\",\n \"esbuild\": \"0.27.2\",\n \"eslint\": \"^9.39.5\",\n \"globals\": \"^16.5.0\",\n \"happy-dom\": \"^20.0.11\",\n \"rollup\": \"^4.63.5\",\n \"rollup-plugin-dts\": \"^6.5.1\",\n \"terser\": \"^5.51.2\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.70.1\",\n \"vitest\": \"^4.0.15\"\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\n\n/** The package version: stamped into `<wcs-ssr>`, compared on hydration (major.minor), shown by DevTools. */\nexport const VERSION: string = pkg.version;\n"],"mappings":"AAAA,ICGaA,EDDA,eCCsBC","ignoreList":[]}
1
+ {"version":3,"names":["VERSION","r"],"sources":["../../../package.json","../../../src/version.ts"],"sourcesContent":["{\n \"name\": \"@wcstack/state\",\n \"version\": \"4.2.0\",\n \"description\": \"Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.\",\n \"type\": \"module\",\n \"main\": \"./dist/index.esm.js\",\n \"module\": \"./dist/index.esm.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.esm.js\"\n },\n \"./auto\": \"./dist/auto.min.js\",\n \"./core\": {\n \"types\": \"./dist/split/core.d.ts\",\n \"import\": \"./dist/split/core.js\"\n },\n \"./features/*\": {\n \"types\": \"./dist/split/features/*.d.ts\",\n \"import\": \"./dist/split/features/*.js\"\n },\n \"./define\": {\n \"types\": \"./dist/define.d.ts\",\n \"import\": \"./dist/define.js\"\n },\n \"./manifest\": {\n \"types\": \"./dist/manifest.d.ts\",\n \"import\": \"./dist/manifest.esm.js\"\n },\n \"./parser\": {\n \"types\": \"./dist/parser.d.ts\",\n \"import\": \"./dist/parser.esm.js\"\n },\n \"./wcs-manifest.json\": \"./dist/wcs-manifest.json\"\n },\n \"files\": [\n \"dist\",\n \"!dist/core.min.js\"\n ],\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist', { recursive: true, force: true })\\\"\",\n \"build\": \"node build.mjs\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"lint\": \"eslint src\",\n \"typecheck\": \"tsc --noEmit\",\n \"golden\": \"node scripts/golden.mjs\",\n \"version:patch\": \"npm version patch\",\n \"version:minor\": \"npm version minor\",\n \"version:major\": \"npm version major\",\n \"prepublishOnly\": \"npm run build && npm run test:coverage\"\n },\n \"keywords\": [\n \"web-components\",\n \"state-management\",\n \"reactive\",\n \"data-binding\",\n \"proxy\",\n \"custom-elements\",\n \"shadow-dom\",\n \"buildless\",\n \"zero-dependencies\",\n \"declarative\"\n ],\n \"author\": \"mogera551\",\n \"homepage\": \"https://wcstack.github.io\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/wcstack/wcstack.git\",\n \"directory\": \"packages/state\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/wcstack/wcstack/issues\"\n },\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.5\",\n \"@vitest/coverage-v8\": \"^4.1.11\",\n \"esbuild\": \"0.27.2\",\n \"eslint\": \"^9.39.5\",\n \"globals\": \"^16.5.0\",\n \"happy-dom\": \"^20.0.11\",\n \"rollup\": \"^4.63.5\",\n \"rollup-plugin-dts\": \"^6.5.1\",\n \"terser\": \"^5.51.2\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.70.1\",\n \"vitest\": \"^4.0.15\"\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\n\n/** The package version: stamped into `<wcs-ssr>`, compared on hydration (major.minor), shown by DevTools. */\nexport const VERSION: string = pkg.version;\n"],"mappings":"AAAA,ICGaA,EDDA,eCCsBC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{a as n,j as t}from"./chunk-7ZU3CLEG.js";function i(t,i=[]){return n.Bo?.(t,i)??`#${t}${i.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function o(n,o,r,s){t(i(n,o),r,s)}export{i as a,o as b};
2
- //# sourceMappingURL=chunk-GGSHXG7N.js.map
1
+ import{a as n,j as t}from"./chunk-BGUJ3HF6.js";function i(t,i=[]){return n.Bo?.(t,i)??`#${t}${i.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function o(n,o,r,s){t(i(n,o),r,s)}export{i as a,o as b};
2
+ //# sourceMappingURL=chunk-UBGJGMSG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["text","id","args","hooks","render","map","a","JSON","stringify","String","join","raise","subject","candidates","raiseError","s"],"sources":["../../../src/messages.ts"],"sourcesContent":["/**\n * The core's messages, by number. The prose lives in the diagnostics add-on\n * (`src/diagnostics/messages.ts`); without it a message reads `[@wcstack/state] #108 \"a|b(\"` —\n * the message number and the values it would have shown. With it (the full `auto` bundle installs\n * it) the message is the code shared with lint and the VS Code extension and the full sentence\n * (`[wcs/binding-syntax] Invalid filter format: …`), followed by the guidance.\n *\n * The hundreds of a number name its code (the diagnostics add-on's `CODES`, in the core up to\n * 4.0.0-rc.3): 1xx binding-syntax, 2xx template-syntax, …; 1–99 carry no code. Numbers are only\n * ever added, so a number read on a page keeps its meaning across versions. `M` is a const enum:\n * the build inlines the numbers.\n *\n * Kept as full text in the core, not numbered: the barriers a page without add-ons meets on\n * purpose (`[wcs/feature-not-installed]`, a formatting filter without the formats add-on).\n */\nimport { hooks } from \"./hooks\";\nimport { raiseError } from \"./parser/raiseError\";\n\nexport const enum M {\n // no code\n ScanRemoved = 1,\n GetterWithoutSetter = 2,\n NoRow = 3,\n ParentNotObject = 4,\n NotAMethod = 5,\n GetAllNoCommonLevel = 6,\n EqIndexNoRow = 7,\n Readonly = 8,\n SetAllNeedsIndexes = 9,\n SetAllSpreadLength = 10,\n DrainNotSettled = 11,\n BindingFailed = 12,\n LoadFailed = 13,\n ElementFailed = 14,\n NotInitialized = 15,\n NoScript = 16,\n TokenSubscriberThrew = 17,\n TokenListNotArray = 18,\n TokenEntryEmpty = 19,\n TokenEntryReserved = 20,\n TokenEntryDuplicated = 21,\n OnNotObject = 22,\n OnEntryUndeclared = 23,\n OnEntryNotFunction = 24,\n NamingLimit = 25,\n FilterOptionsRequired = 26,\n FilterOptionNotNumber = 27,\n FilterValueNotNumber = 28,\n FilterValueNotDate = 29,\n FilterValueNotArray = 30,\n DirectionalSyncDisabled = 31,\n SelectorRemoved = 32,\n ModifierUnknown = 33,\n ModifierTwice = 34,\n ModifierValue = 35,\n EventInitNone = 36,\n InitUnsupported = 37,\n MemberUndeclared = 38,\n InitIncompatible = 39,\n SyncConnectNeedsOutput = 40,\n RenderChain = 41,\n InlineBlocked = 42,\n InlineFailed = 43,\n OptionInvalid = 44,\n BehaviorChanged = 45,\n FeaturesNotArray = 46,\n SecondRoot = 47,\n LocaleInvalid = 48,\n InitFailed = 49,\n ConnectedFailed = 50,\n DisconnectedFailed = 51,\n FilterStyleInvalid = 52,\n FilterCurrencyInvalid = 53,\n // [wcs/binding-syntax]\n BindTextNoColon = 101,\n StructuralTakesNoModifiers = 102,\n ElseTakesNoValue = 103,\n SpreadNoPath = 104,\n SpreadNoFilters = 105,\n LeadingDotNamespace = 106,\n UnterminatedQuote = 107,\n FilterUnclosed = 108,\n FilterUnopened = 109,\n FilterParenOrder = 110,\n FilterTrailing = 111,\n FilterEmpty = 112,\n FilterNameHasModifiersInput = 113,\n FilterNameHasModifiersOutput = 114,\n OneModifierList = 115,\n NoPropertyName = 116,\n TooManySegments = 117,\n EmptySegment = 119,\n UnsafeSegment = 120,\n ForNoFilters = 121,\n NamespaceNeedsName = 122,\n // [wcs/template-syntax]\n StructuralNotSingle = 201,\n ElseWithoutIf = 202,\n OuterInTemplate = 203,\n TemplateHandedOver = 204,\n // [wcs/binding-path-missing]\n PathMissing = 301,\n // [wcs/binding-type-expectation]\n ClassNeedsBoolean = 401,\n // [wcs/filter-unknown]\n FilterUnknown = 501,\n // [wcs/filter-arity]\n FilterTooFewArgs = 601,\n FilterTooManyArgs = 602,\n // [wcs/getter-cycle]\n GetterCycle = 701,\n // [wcs/getter-depth-exceeded]\n GetterDepth = 801,\n // [wcs/index-arity]\n IndexArityExact = 901,\n IndexArityAtMost = 902,\n // [wcs/index-param-range]\n IndexParamRange = 1001,\n // [wcs/recursion-unsupported]\n RecursionUnsupported = 1101,\n // [wcs/token-misconfigured]\n CommandRightSide = 1201,\n NoBindable = 1202,\n NoCommand = 1203,\n NoProperty = 1204,\n NativeNoCommand = 1205,\n // [wcs/token-undeclared]\n EventTokenUndeclared = 1301,\n CommandTokenUndeclared = 1302,\n // [wcs/wildcard-rank]\n WildcardNoLoop = 1401,\n WildcardRelative = 1402,\n WildcardOtherList = 1403,\n // [wcs/spread-no-bindable]\n SpreadNoBindable = 1501,\n // [wcs/declaration-alias]\n DeclarationRemoved = 1601,\n // [wcs/name-alias]\n ApiRemoved = 1701,\n}\n\n/** A message without the `[@wcstack/state]` prefix: the code and the full sentence with diagnostics, else the number and the values. */\nexport function text(id: M, args: readonly unknown[] = []): string {\n return hooks.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === \"string\" ? JSON.stringify(a) : String(a)}`).join(\"\")}`;\n}\n\n/** Throws message `id` (`subject` / `candidates` feed the diagnostics add-on's did-you-mean). */\nexport function raise(id: M, args?: readonly unknown[], subject?: string, candidates?: Iterable<string>): never {\n raiseError(text(id, args), subject, candidates);\n}\n"],"mappings":"+CA8IO,SAASA,EAAKC,EAAOC,EAA2B,IACrD,OAAOC,EAAMC,KAASH,EAAIC,IAAS,IAAID,IAAKC,EAAKG,IAAKC,GAAM,IAAiB,iBAANA,EAAiBC,KAAKC,UAAUF,GAAKG,OAAOH,MAAMI,KAAK,KAChI,CAGO,SAASC,EAAMV,EAAOC,EAA2BU,EAAkBC,GACxEC,EAAWd,EAAKC,EAAIC,GAAOU,EAASC,EACtC,QAAAP,OAAAS","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{b as t}from"./chunk-GGSHXG7N.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Ze:s,et:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
2
- //# sourceMappingURL=chunk-7QVEF5E3.js.map
1
+ import{b as t}from"./chunk-UBGJGMSG.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Ze:s,et:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
2
+ //# sourceMappingURL=chunk-UPSLR4FS.js.map
@@ -1,2 +1,2 @@
1
- import{a as s}from"./chunks/chunk-JZW5KGXQ.js";import{a as n,d as t,e as u}from"./chunks/chunk-V3HFN3MW.js";import"./chunks/chunk-JAEYZSVS.js";import"./chunks/chunk-UFIDBJBP.js";import"./chunks/chunk-BWGPKDHS.js";import{g as a,h as c,i as h}from"./chunks/chunk-4HLDITUB.js";import{c as i}from"./chunks/chunk-R5OJ52SF.js";import"./chunks/chunk-XEGL4FW5.js";import"./chunks/chunk-7QVEF5E3.js";import"./chunks/chunk-GGSHXG7N.js";import{g as o}from"./chunks/chunk-7ZU3CLEG.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-OKBVNGFK.js";import{a as n,d as t,e as u}from"./chunks/chunk-3Q7LGONS.js";import"./chunks/chunk-BYQBV3ZC.js";import"./chunks/chunk-4ECL4ITF.js";import"./chunks/chunk-2RBI6DVS.js";import{g as a,h as c,i as h}from"./chunks/chunk-BI4645UG.js";import{c as i}from"./chunks/chunk-CIBJLAA3.js";import"./chunks/chunk-JK3B3LLB.js";import"./chunks/chunk-UPSLR4FS.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};
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- import{a as e}from"../chunks/chunk-JZW5KGXQ.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-UFIDBJBP.js";import"../chunks/chunk-BWGPKDHS.js";import"../chunks/chunk-4HLDITUB.js";import"../chunks/chunk-R5OJ52SF.js";import"../chunks/chunk-XEGL4FW5.js";import"../chunks/chunk-7QVEF5E3.js";import"../chunks/chunk-GGSHXG7N.js";import{a as u,b as d}from"../chunks/chunk-7ZU3CLEG.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.F.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.Re)m(t)}else null!==e.O&&m(e.O)};for(let t of e.ce.values())for(let e of t)c(e),null!==e.j&&v(e.j);for(let t of e.oe.values())if(null!==t.E&&v(t.E),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.Pe.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.Pe.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 O(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 E(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.ve=d(u.ve,$),u.Fe=d(u.Fe,O),u.Ue=d(u.Ue,E),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.Ie?.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)})}})}()}},_=M;export{_ as default,M as devtools};
1
+ import{a as e}from"../chunks/chunk-OKBVNGFK.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-4ECL4ITF.js";import"../chunks/chunk-2RBI6DVS.js";import"../chunks/chunk-BI4645UG.js";import"../chunks/chunk-CIBJLAA3.js";import"../chunks/chunk-JK3B3LLB.js";import"../chunks/chunk-UPSLR4FS.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.F.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.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.Re)m(t)}else null!==e.O&&m(e.O)};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.E&&v(t.E),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.Te.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.Te.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 O(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 M(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.on(),error:t})}var E={name:"devtools",install(){u.element=d(u.element,j),u.ve=d(u.ve,$),u.Oe=d(u.Oe,O),u.qe=d(u.qe,M),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.De?.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)})}})}()}},_=E;export{_ as default,E 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-4HLDITUB.js";import{a as i,d as s,f as r}from"../chunks/chunk-R5OJ52SF.js";import{e as o}from"../chunks/chunk-XEGL4FW5.js";import"../chunks/chunk-7QVEF5E3.js";import{b as l}from"../chunks/chunk-GGSHXG7N.js";import{a as d,b as c,c as u,e as h,j as f}from"../chunks/chunk-7ZU3CLEG.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,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,v="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",k={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)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${v}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${v}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&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)=>`${y(e,t)} failed to initialize.`,50:(e,...t)=>`${y(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${y(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 x(e,t){let n=k[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var j=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),T=[[/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 S(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 T){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&&j.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var I=new WeakMap,M=new WeakMap,A=new WeakSet,W=new WeakSet;function P(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 L(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let a=e.target,i=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!==P(e.target,t.t)?.get?t:e.I.Dt(o(t.t).o)}(e,t);if(n.some(e=>null!=i(e)?.getter))return null;for(let t of n){if(null===a||"object"!=typeof a)return null;if("*"===t.s){if(!Array.isArray(a)||0===a.length)return null;a=a[0];continue}if(Array.isArray(a)&&/^\d+$/.test(t.s)){if(Number(t.s)>=a.length)return null;a=a[Number(t.s)];continue}let n=P(a,t.s);if(void 0===n&&null===t.d&&e.vt.has(t.s))return null;if(void 0===n){let n=q(a),s=i(t.d);for(let t of e.I.all())t.d===s&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;a=n.value}return null}function D(e){A.has(e)||(A.add(e),setTimeout(()=>function(e){A.delete(e);let t=I.get(e);if(void 0===t)return;let n=M.get(e);void 0===n&&M.set(e,n=new Set);for(let[a,s]of t){if(n.has(a))continue;n.add(a);let t=L(e,a);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!W.has(e)&&(a.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(a),r.initializePromise.then(()=>{W.add(r),D(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.at?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:a.t,missingSegment:t.seg});let u=e.I.Dt(o(a.t).o),h="";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)}`);h=` 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)}${h} Updates to this path will be silently dropped.${m}`)}}(e),0))}function E(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let a=I.get(e);void 0===a&&I.set(e,a=new Map),a.has(t)||a.set(t,n),D(e)}var N=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C=!1;function B(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(C||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;C=!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 H=new WeakMap;function U(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=H.get(e);void 0===s&&H.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 z=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],F={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},G={name:"diagnostics",install(){d.Lo=S,d.Bo=x,d.So=E,d.detail=U,d.Ue=c(d.Ue,B);let e=d.de;d.de=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of z)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=>f(`[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(`^(?:${N(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(`^${N(a)}(?:${N(o)})*${N(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){M.delete(e),I.has(e)&&D(e)}(t)},d.rt=u(h,d.rt,(e,t)=>Object.hasOwn(F,t)?l(1701,[t,F[t]]):void 0)}},R=G;export{R as default,G as diagnostics};
1
+ import{b as e,c as t,h as n,j as a}from"../chunks/chunk-BI4645UG.js";import{a as i,d as s,f as r}from"../chunks/chunk-CIBJLAA3.js";import{e as o}from"../chunks/chunk-JK3B3LLB.js";import"../chunks/chunk-UPSLR4FS.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 S(e,t){let n=j[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var T=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&&T.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,q=new WeakSet,W=new WeakSet;function B(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 D(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 L(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let a=e.target,i=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!==B(e.target,t.t)?.get?t:e.I.jt(o(t.t).o)}(e,t);if(n.some(e=>null!=i(e)?.getter))return null;for(let t of n){if(null===a||"object"!=typeof a)return null;if("*"===t.s){if(!Array.isArray(a)||0===a.length)return null;a=a[0];continue}if(Array.isArray(a)&&/^\d+$/.test(t.s)){if(Number(t.s)>=a.length)return null;a=a[Number(t.s)];continue}let n=B(a,t.s);if(void 0===n&&null===t.d&&e.kt.has(t.s))return null;if(void 0===n){let n=D(a),s=i(t.d);for(let t of e.I.all())t.d===s&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;a=n.value}return null}function N(e){q.has(e)||(q.add(e),setTimeout(()=>function(e){q.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=L(e,a);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!W.has(e)&&(a.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(a),r.initializePromise.then(()=>{W.add(r),N(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.at?.(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 C(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),N(e)}var U=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=!1;function z(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(E||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;E=!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 H=new WeakMap;function G(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=H.get(e);void 0===s&&H.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"},F={name:"diagnostics",install(){d.Lo=A,d.Bo=S,d.So=C,d.detail=G,d.qe=c(d.qe,z);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=D(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(`^(?:${U(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(`^${U(a)}(?:${U(o)})*${U(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)&&N(e)}(t)},d.rt=u(f,d.rt,(e,t)=>Object.hasOwn(R,t)?l(1701,[t,R[t]]):void 0)}},_=F;export{_ as default,F as diagnostics};
2
2
  //# sourceMappingURL=diagnostics.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["editDistance","a","b","max","Math","abs","length","prev","Array","curr","j","i","cost","min","didYouMean","input","candidates","folded","toLowerCase","best","bestDistance","candidate","distance","LINT_HINT","CODES","codeOf","id","c","MOVED","element","tag","at","map","join","CSP_GUIDE","SENTENCES","p","parent","name","n","MAX_DRAIN_PASSES","MAX_RENDER_CHAIN","type","src","status","detail","key","reserved","limit","fn","modifier","value","init","where","includes","l","t","keyword","prop","quote","args","f","trailing","slice","lastIndexOf","source","mods","ns","given","api","depth","what","startsWith","method","allowed","over","loop","old","render","sentence","LINT_CODES","Set","GUIDES","RENAMED_FILTERS","inc","dec","fix","uc","lc","cap","rep","rev","pad","null","explain","message","subject","out","to","Object","hasOwn","removedFilter","re","text","m","exec","replace","_","Number","split","FORMATS_FILTER_NAMES","some","hasFilter","code","has","test","named","WeakMap","checked","due","WeakSet","settled","findDescriptor","o","x","prototype","getPrototypeOf","d","getOwnPropertyDescriptor","keysOf","k","getOwnPropertyNames","add","missing","engine","chain","q","unshift","v","target","segs","path","findIndex","s","indexOf","get","patterns","peek","parsePath","pattern","wildcardForm","getter","last","isArray","dropped","names","g","all","push","seg","set","schedule","setTimeout","delete","done","watch","root","querySelectorAll","config","tagNames","state","find","e","getAttribute","initializePromise","then","hooks","noticed","missingSegment","w","rowGetter","loops","lists","console","warn","check","declared","Map","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","said","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","keys","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","dollar","first","known","diagnostics_default"],"sources":["../../../src/diagnostics/guidance.ts","../../../src/diagnostics/messages.ts","../../../src/diagnostics/explain.ts","../../../src/features/diagnostics.ts"],"sourcesContent":["/**\n * diagnostics/guidance.ts — self-fix guidance for error messages, ported verbatim from\n * `@wcstack/state` (`errorGuidance.ts`). Only the diagnostics add-on uses it: the core's\n * messages state the fact, and the add-on appends this.\n *\n * The did-you-mean criteria (edit distance 2, ties go to the first candidate, case folded) are the\n * same as lint's suggestion, so the console, lint and the IDE never propose different names.\n */\n\n/** Insert / delete / substitute edit distance. Returns max + 1 early when the lengths differ by more than max. */\nfunction editDistance(a: string, b: string, max: number): number {\n if (Math.abs(a.length - b.length) > max) {\n return max + 1;\n }\n const prev: number[] = new Array(b.length + 1);\n const curr: number[] = new Array(b.length + 1);\n for (let j = 0; j <= b.length; j++) {\n prev[j] = j;\n }\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);\n }\n for (let j = 0; j <= b.length; j++) {\n prev[j] = curr[j];\n }\n }\n return prev[b.length];\n}\n\n/**\n * The nearest candidate within edit distance 2 as ` Did you mean \"<best>\"?`, or `\"\"` when there is\n * none. An empty input (a trailing `a|` pipe) gets no suggestion.\n */\nexport function didYouMean(input: string, candidates: Iterable<string>): string {\n if (input.length === 0) {\n return \"\";\n }\n const folded = input.toLowerCase();\n let best: string | null = null;\n let bestDistance = 3;\n for (const candidate of candidates) {\n const distance = editDistance(folded, candidate.toLowerCase(), 2);\n if (distance < bestDistance) {\n best = candidate;\n bestDistance = distance;\n }\n }\n return best !== null ? ` Did you mean \"${best}\"?` : \"\";\n}\n\n/**\n * The pointer to lint. Attach it **only where lint actually detects the case** — a hint that sends\n * the author to a lint run that comes back clean costs the loop its credibility.\n */\nexport const LINT_HINT = \" Validate statically: npx @wcstack/lint <file>.\";\n","/**\n * The sentences of the core's numbered messages (src/messages.ts), in the diagnostics add-on:\n * the core carries the number and the values, this renders what the core used to say. Each\n * sentence follows its `[wcs/<code>] ` (`codeOf`: the code the hundreds of the number name).\n * `Record<M, …>` makes a number without a sentence a type error.\n */\nimport { M } from \"../messages\";\nimport { MAX_DRAIN_PASSES, MAX_INDEX_PARAM, MAX_RENDER_CHAIN } from \"../engine\";\nimport { MAX_PATH_SEGMENTS, MODIFIER_SEPARATOR, RECURSION_WILDCARD } from \"../parser/define\";\n\ntype Sentence = (...a: any[]) => string;\n\n/**\n * The code of each hundred of message numbers (\"\" = none): the code lint and the VS Code extension\n * report for the same case. The core carried this up to 4.0.0-rc.3; without this add-on a message\n * now reads as its number and values alone.\n */\nexport const CODES = [\n \"\", \"binding-syntax\", \"template-syntax\", \"binding-path-missing\", \"binding-type-expectation\",\n \"filter-unknown\", \"filter-arity\", \"getter-cycle\", \"getter-depth-exceeded\", \"index-arity\",\n \"index-param-range\", \"recursion-unsupported\", \"token-misconfigured\", \"token-undeclared\",\n \"wildcard-rank\", \"spread-no-bindable\", \"declaration-alias\", \"name-alias\",\n];\n\n/** `[wcs/<code>] ` for a message number, or \"\" when it has none. */\nexport const codeOf = (id: M): string => {\n const c = CODES[(id / 100) | 0];\n return c ? `[wcs/${c}] ` : \"\";\n};\n\n/** The options 4.0 moved from `bootstrapState` to the state's `$behavior`. */\nconst MOVED = [\"enableMustache\", \"sameValueGuard\", \"enableDirectionalInitialSync\"];\n\n/** `<tag a=\"v\" …>` from the tag and its attributes' names and values. */\nconst element = (tag: string, at: string[]): string => `<${tag}${at.map((a, i) => (i % 2 ? `=\"${a}\"` : ` ${a}`)).join(\"\")}>`;\n\nconst CSP_GUIDE = \"https://github.com/wcstack/wcstack/blob/main/docs/csp.md\";\n\nexport const SENTENCES: Record<M, Sentence> = {\n [M.ScanRemoved]: () => \"$scan was removed (use $watch or $on)\",\n [M.GetterWithoutSetter]: (p) => `\"${p}\" is a getter without a setter`,\n [M.NoRow]: (p) => `no row for \"${p}\"`,\n [M.ParentNotObject]: (p, parent) => `cannot write \"${p}\": its parent is ${parent}`,\n [M.NotAMethod]: (name) => `\"${name}\" is not a method`,\n [M.GetAllNoCommonLevel]: (p) => `$getAll(\"${p}\"): no loop level in common with the context`,\n [M.EqIndexNoRow]: (p) => `$eqIndex(\"${p}\") needs a list row scope.`,\n [M.Readonly]: () => \"This state is readonly.\",\n [M.SetAllNeedsIndexes]: (p) => `$setAll(\"${p}\") needs indexes ([] for every match)`,\n [M.SetAllSpreadLength]: (p, n) => `$setAll(\"${p}\", …, { spread: true }) needs an array of ${n} values`,\n [M.DrainNotSettled]: () => `updates did not settle after ${MAX_DRAIN_PASSES} passes`,\n [M.RenderChain]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,\n [M.BindingFailed]: (type, p) => `binding \"${type}: ${p}\" failed to apply.`,\n [M.LoadFailed]: (src, status) => `failed to load \"${src}\": ${status}`,\n [M.ElementFailed]: () => \"this <wcs-state> failed to initialize; create a new one\",\n [M.NotInitialized]: () => \"state is not initialized\",\n [M.NoScript]: (id) => `no <script> with id \"${id}\"`,\n [M.InlineBlocked]: () => `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 ${CSP_GUIDE}`,\n [M.InlineFailed]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,\n [M.TokenSubscriberThrew]: (name) => `a subscriber of token \"${name}\" threw.`,\n [M.TokenListNotArray]: (key) => `${key} must be an array of strings.`,\n [M.TokenEntryEmpty]: (key) => `${key} entries must be non-empty strings.`,\n [M.TokenEntryReserved]: (key, name, reserved) => `${key} entry \"${name}\" conflicts with the reserved namespace name \"${reserved}\".`,\n [M.TokenEntryDuplicated]: (key, name) => `${key} entry \"${name}\" is duplicated.`,\n [M.OnNotObject]: () => \"$on must be an object of handlers.\",\n [M.OnEntryUndeclared]: (name) => `$on entry \"${name}\" is not declared in $eventTokens.`,\n [M.OnEntryNotFunction]: (name) => `$on entry \"${name}\" must be a function.`,\n [M.NamingLimit]: (limit) => `view-transition naming-limit (${limit}) reached.`,\n [M.FilterOptionsRequired]: (fn) => `filter ${fn} requires at least one option`,\n [M.FilterOptionNotNumber]: (fn) => `filter ${fn} requires a number as option`,\n [M.FilterValueNotNumber]: (fn) => `filter ${fn} requires a number value`,\n [M.FilterValueNotDate]: (fn) => `filter ${fn} requires a date value`,\n [M.FilterValueNotArray]: (fn) => `filter ${fn} requires an array value`,\n [M.DirectionalSyncDisabled]: () => \"init=/sync= modifiers require enableDirectionalInitialSync.\",\n [M.ModifierUnknown]: (key, modifier) => `Unknown binding modifier \"${key}\" in \"${modifier}\".`,\n [M.ModifierTwice]: (key) => `Binding modifier \"${key}\" may only be specified once.`,\n [M.ModifierValue]: (key, value) => `Invalid ${key} modifier value \"${value}\".`,\n [M.EventInitNone]: () => \"Event bindings only allow init=none.\",\n [M.InitUnsupported]: (type, init) => `Binding type \"${type}\" does not support init=${init}.`,\n [M.MemberUndeclared]: (name) => `Property \"${name}\" is not declared by wcBindable.`,\n [M.InitIncompatible]: (init, name) => `init=${init} is incompatible with wcBindable member \"${name}\".`,\n [M.SyncConnectNeedsOutput]: (name) => `sync=connect requires observable property \"${name}\".`,\n [M.OptionInvalid]: (where, key) => `${where}: \"${key}\" is not one of its options, or not of the option's type.${where === \"bootstrapState\" && MOVED.includes(key) ? \" 4.0 moved it to the state's $behavior.\" : \"\"}`,\n [M.BehaviorChanged]: () => \"a re-set state may not change $behavior: create the element again.\",\n [M.SecondRoot]: () => \"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).\",\n [M.LocaleInvalid]: (l) => `the locale \"${l}\" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use \"en\".`,\n [M.FeaturesNotArray]: () => '$features must be an array of add-on names ([\"temporal\", \"formats\"]).',\n [M.InitFailed]: (tag, ...at) => `${element(tag, at)} failed to initialize.`,\n [M.ConnectedFailed]: (tag, ...at) => `${element(tag, at)} $connectedCallback failed.`,\n [M.DisconnectedFailed]: (tag, ...at) => `${element(tag, at)} $disconnectedCallback failed.`,\n\n [M.BindTextNoColon]: (t) => `Invalid bindText: \"${t}\". Missing ':' separator between propPart and statePart.`,\n [M.StructuralTakesNoModifiers]: (t, keyword) => `\"${t}\": \"${keyword}\" takes no modifiers or filters on its left side — write \"${keyword}:\".`,\n [M.ElseTakesNoValue]: (t) => `\"${t}\": \"else\" takes no value — write \"else:\".`,\n [M.SpreadNoPath]: (t) => `Invalid spread binding \"${t}\": spread target path is required.`,\n [M.SpreadNoFilters]: (t) => `Invalid spread binding \"${t}\": filters are not allowed on spread targets.`,\n [M.LeadingDotNamespace]: (prop) => `\"${prop}\": a leading \".\" binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,\n [M.UnterminatedQuote]: (quote, args) => `unterminated ${quote} quote in the filter arguments \"(${args})\". Close the quote.`,\n [M.FilterUnclosed]: (f) => `Invalid filter format: missing closing parenthesis in \"${f}\".`,\n [M.FilterUnopened]: (f) => `Invalid filter format: missing opening parenthesis in \"${f}\".`,\n [M.FilterParenOrder]: (f) => `Invalid filter format: \")\" comes before \"(\" in \"${f}\".`,\n [M.FilterTrailing]: (f, trailing) => `\"${f}\": unexpected \"${trailing}\" after the filter's closing \")\" — separate filters with \"|\" (write \"${f.slice(0, f.lastIndexOf(\")\") + 1)}|${trailing}\").`,\n [M.FilterEmpty]: (source) => `an empty filter in \"${source}\" — remove the extra \"|\" or name the filter.`,\n [M.FilterNameHasModifiersInput]: (name, mods) => `\"${name}\" is not a filter name: a modifier list \"${MODIFIER_SEPARATOR}${mods}\" comes before the input filters, not inside one`,\n [M.FilterNameHasModifiersOutput]: (name) => `\"${name}\" is not a filter name: \"${MODIFIER_SEPARATOR}\" cannot appear in one.`,\n [M.OneModifierList]: (prop) => `\"${prop}\": a binding takes one modifier list after a single \"#\"`,\n [M.NoPropertyName]: (prop) => `\"${prop}\": the left side of a binding must name a property — write \"<property>: <path>\" (modifiers and input filters come after the name).`,\n [M.TooManySegments]: (p, n) => `\"${p}\" has ${n} path segments — the limit is ${MAX_PATH_SEGMENTS}.`,\n [M.SelectorRemoved]: (t) => `\"${t}\": 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.`,\n [M.UnsafeSegment]: (p) => `\"${p}\": a state path cannot go through \"__proto__\" or \"prototype\" (it would reach every object's prototype).`,\n [M.ForNoFilters]: (t) => `\"${t}\": \"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>\").`,\n [M.NamespaceNeedsName]: (t, ns) => ns === \"class\"\n ? `\"${t}\": \"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:\".`\n : `\"${t}\": \"attr:\" needs an attribute name — \"attr.NAME:\" sets one attribute (a bare \"attr:\" would set an element property named \"attr\", which does nothing).`,\n [M.EmptySegment]: (t) => `\"${t}\": 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).`,\n\n [M.StructuralNotSingle]: (t) => `Invalid bindText: \"${t}\". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,\n [M.ElseWithoutIf]: (type) => `\"${type}:\" must follow an \"if:\" template`,\n [M.TemplateHandedOver]: (type) => `a \"${type}:\" 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.`,\n [M.OuterInTemplate]: (name) => `\"${name}:\" 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.`,\n\n [M.PathMissing]: (p) => `Path \"${p}\" does not exist on the state tree.`,\n\n [M.ClassNeedsBoolean]: (name, type) => `class.${name} needs a boolean, got ${type}.`,\n\n [M.FilterUnknown]: (name) => `filter not found: ${name}.`,\n\n [M.FilterTooFewArgs]: (name, min, given) => `filter \"${name}\" requires at least ${min} argument(s) (${given} given).`,\n [M.FilterTooManyArgs]: (name, max, given) => `filter \"${name}\" accepts at most ${max} argument(s) (${given} given).`,\n\n [M.GetterCycle]: (p) => `\"${p}\" depends on itself`,\n\n [M.GetterDepth]: (p) => `\"${p}\"`,\n\n [M.IndexArityExact]: (api, p, depth, n) => `${api}(\"${p}\") takes ${depth} index(es), got ${n}.`,\n [M.IndexArityAtMost]: (api, p, depth, n) => `${api}(\"${p}\") takes at most ${depth} index(es), got ${n}.`,\n\n [M.IndexParamRange]: (key) => `\"${key}\": list index parameters run from $1 to $${MAX_INDEX_PARAM}.`,\n\n [M.RecursionUnsupported]: (p) => `\"${p}\" uses \"${RECURSION_WILDCARD}\", which is not accepted here.`,\n\n [M.CommandRightSide]: (prop, p) => `\"${prop}: ${p}\": the right-hand side must be $command.<name>`,\n // a native element's command (no hyphen: never a custom element) is the native-commands add-on's\n [M.NoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${\n !tag.includes(\"-\") && what.startsWith(\"command.\") ? \" A native element's command needs the add-on @wcstack/state/features/native-commands.\" : \"\"}`,\n [M.NoCommand]: (tag, method) => `<${tag}> declares no command \"${method}\".`,\n [M.NoProperty]: (tag, prop) => `<${tag}> declares no property \"${prop}\".`,\n [M.NativeNoCommand]: (tag, method, allowed) => `<${tag}> has no command \"${method}\" (a native <${tag}>'s commands: ${allowed}).`,\n\n [M.EventTokenUndeclared]: (name) => `eventToken \"${name}\" is not declared in $eventTokens.`,\n [M.CommandTokenUndeclared]: (name) => `\"$command.${name}\" is not declared in $commandTokens.`,\n\n [M.WildcardNoLoop]: (p, depth, n = 0) => `\"${p}\" needs ${depth} enclosing loop level(s); the scope provides ${n}.`,\n [M.WildcardRelative]: (p) => `\"${p}\" is relative: it needs an enclosing \"for\" template`,\n [M.WildcardOtherList]: (p, over, loop) => `\"${p}\" ranges over the rows of \"${over}\", but the enclosing \"for\" template at that level renders \"${loop}\".`,\n\n [M.SpreadNoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,\n\n [M.DeclarationRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n\n [M.ApiRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n};\n","/**\n * The diagnostics add-on's sentences and guidance: a numbered core message rendered as its\n * sentence (src/diagnostics/messages.ts), then how to fix it, the nearest name and the lint\n * pointer. The add-on installs these; so does `@wcstack/state/parser`, a bundle of its own.\n */\nimport { didYouMean, LINT_HINT } from \"./guidance\";\nimport { FORMATS_FILTER_NAMES, hasFilter } from \"../filters/registry\";\nimport type { M } from \"../messages\";\nimport { codeOf, SENTENCES } from \"./messages\";\n\n/** A numbered core message as its sentence (the number and the values if it is not known here). */\nexport function render(id: number, args: readonly unknown[]): string {\n const sentence = SENTENCES[id as M];\n return sentence === undefined ? `${codeOf(id)}#${id} ${args.join(\" \")}` : codeOf(id) + sentence(...args);\n}\n\n/** Codes lint detects statically: only these point the author to a lint run. */\nconst LINT_CODES = new Set([\n \"binding-syntax\", \"template-syntax\", \"filter-unknown\", \"filter-arity\", \"index-arity\",\n \"wildcard-rank\", \"token-undeclared\", \"binding-path-missing\", \"index-param-range\",\n]);\n\n/** How to fix it, by what the message says. */\nconst GUIDES: [RegExp, string][] = [\n [/no loop level in common with the context/, \"; pass indexes ([] for all).\"],\n [/\"([^\"#]+)#([^\"]*)\" is not a filter name: a modifier list .* comes before the input filters/, ' — write \"<property>#$2|$1\".'],\n [/\\[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.\"],\n [/must be single binding/, ' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs=\"for: items\">).'],\n [/\\[wcs\\/wildcard-rank\\] .* needs \\d+ enclosing/, ' Wrap it in that many \"for\" templates, or use $resolve(path, indexes) to name the row explicitly.'],\n [/\\[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).'],\n [/\\[wcs\\/binding-type-expectation\\] class\\.([^ ]+)/, ' Write \"class.$1: path|truthy\" to toggle on truthiness.'],\n [/path segments — the limit/, \" Every prefix of a path is interned, so the cost grows with the square of the depth.\"],\n [/\\[wcs\\/index-arity\\] \\$resolve/, \" $resolve takes one index per \\\"*\\\"; $getAll / $setAll take at most that many (fewer expands the rest).\"],\n [/\"([^\"#]+)#[^\"]*\" is not a filter name: \"#\" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the \":\" — write \"$1\" here.'],\n];\n\n/**\n * The filter names 3.2 renamed, which 3.x kept as aliases and 4.0 removed (3.x's `filterAliases`;\n * lint has the same table). Their message names the replacement, not the nearest name: for these\n * that is an unrelated filter (`dec` → `eq`, `fix` → `div`), and following it changes the meaning.\n */\nexport const RENAMED_FILTERS: Readonly<Record<string, string>> = {\n inc: \"add\", dec: \"sub\", fix: \"toFixed\", uc: \"upper\", lc: \"lower\", cap: \"capitalize\", rep: \"repeat\", rev: \"reverse\", pad: \"padStart\", null: \"nullIfEmpty\",\n};\n\n/** How to write a filter 4.0 removed, or null. */\nfunction removedFilter(name: string): string | null {\n // 4.0 folded substr(start, length) into slice(start, end): the second argument changes meaning\n if (name === \"substr\") return ' \"substr\" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';\n const to = Object.hasOwn(RENAMED_FILTERS, name) ? RENAMED_FILTERS[name] : null;\n return to === null ? null : ` \"${name}\" was renamed \"${to}\" in 3.2 and removed in 4.0 — write \"${to}\".`;\n}\n\nexport function explain(message: string, subject?: string, candidates?: Iterable<string>): string {\n const removed = subject !== undefined && message.includes(\"[wcs/filter-unknown]\") ? removedFilter(subject) : null;\n let out = removed ?? (subject !== undefined && candidates !== undefined ? didYouMean(subject, candidates) : \"\");\n for (const [re, text] of GUIDES) {\n const m = re.exec(message);\n if (m !== null) out += text.replace(/\\$(\\d)/g, (_, i: string) => m[Number(i)]);\n }\n // \"value#ro#wo\": one modifier list — the fix joins them\n const mods = /\"([^\"#]+)#([^\"]+)\": a binding takes one modifier list/.exec(message);\n if (mods !== null) out += ` — write \"${mods[1]}#${mods[2].split(\"#\").join(\",\")}\".`;\n // a formatting filter on a page without the formats add-on (the core names installFeatures), or a\n // typo on a page with no formatting filters at all: the formats add-on may be what is missing\n if (message.includes(\"[wcs/filter-unknown]\")) {\n if (message.includes(\"formats add-on\")) out += ` On a split auto page: features=\"formats\" on the root, or \"$features\": [\"formats\"].`;\n else if (!FORMATS_FILTER_NAMES.some(hasFilter)) {\n out += ` 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\").`;\n }\n }\n const code = /\\[wcs\\/([\\w-]+)\\]/.exec(message);\n // (not something lint reports: the path-length limit is a runtime cost, a template handed over at\n // the top of inserted content (#204) is the page's order of loading, not its markup, and lint's\n // manifest knows the formatting filters — one missing because the formats add-on is not installed\n // is the page's. A row of another list (#1403) and an `outerHTML:` in a template (#203) lint does\n // report, as of its 4.0 parser)\n if (code !== null && LINT_CODES.has(code[1]) && !/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(message)) out += LINT_HINT;\n return out;\n}\n","/**\n * The diagnostics add-on (@wcstack/state/features/diagnostics): the sentences and the self-fix\n * guidance of error messages. The core states the message number and the values\n * (`#901 \"$resolve\" \"m.*.*\" 2 1`); with this installed, the message is the code shared with lint\n * and the sentence (`[wcs/index-arity] $resolve(\"m.*.*\") takes 2 index(es), got 1.`), followed by the\n * nearest name (did-you-mean, the same rule as lint), how to fix it, and a pointer to lint where\n * lint really detects the case. The full `auto` bundle installs it.\n */\nimport { chain, first, hooks, known, type Feature } from \"../hooks\";\nimport type { Engine } from \"../engine\";\nimport { parsePath, type Pattern } from \"../pattern\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { config } from \"../config\";\nimport type { WcsState } from \"../element\";\nimport type { Binding } from \"../dom/view\";\nimport { getTrustedTypesPolicy, isHtmlSink } from \"../trustedTypes\";\nimport { didYouMean, LINT_HINT } from \"../diagnostics/guidance\";\nimport { explain, render } from \"../diagnostics/explain\";\nimport { raise, M } from \"../messages\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** Paths bindings and `$watch` keys named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, boolean>>();\nconst checked = new WeakMap<Engine, Set<Pattern>>();\nconst due = new WeakSet<Engine>();\n/** Volumes (`<wcs-state mount>`) whose loading settled: the paths under them are checked from then on. */\nconst settled = new WeakSet<Element>();\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction keysOf(o: object): string[] {\n const out = new Set<string>();\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n for (const k of Object.getOwnPropertyNames(x)) if (k[0] !== \"$\" && k !== \"constructor\") out.add(k);\n }\n return [...out];\n}\n\n/**\n * The pattern a path with an explicit index reads through: an index with no `*` after it\n * (`items.0.x`) has an accessor of its own (Engine.markupAccessor), so whether it reads a getter\n * is the question of the pattern it names (`items.*.x`). A `*` after the index (`groups.0.items.*.x`,\n * a row of `for: groups.0.items`) reads its row's own item: the pattern itself. So does a path the\n * author declared a getter under (`get \"groups.0.items\"()`): that getter is what it reads (#388).\n */\nfunction wildcardForm(engine: Engine, q: Pattern): Pattern | undefined {\n const segs = q.path.split(\".\");\n // (a leading numeric segment is a root key, not an index: parsePath)\n const i = segs.findIndex((s, j) => j > 0 && /^\\d/.test(s));\n return i < 0 || segs.indexOf(\"*\", i) >= 0 || findDescriptor(engine.target, q.path)?.get !== undefined\n ? q : engine.patterns.peek(parsePath(q.path).pattern);\n}\n\n/**\n * The segment of `p` that certainly does not exist, with the names that do at its level; null\n * when the path exists or it cannot be told without evaluating a getter (a getter on the way, a\n * null or primitive on the way, a list with no row to look into).\n */\nfunction missing(engine: Engine, p: Pattern): { seg: string; names: string[] } | null {\n const chain: Pattern[] = [];\n for (let q: Pattern | null = p; q !== null; q = q.parent) chain.unshift(q);\n let v: any = engine.target;\n const named = (q: Pattern | null): Pattern | null | undefined => (q === null ? null : wildcardForm(engine, q));\n // a getter anywhere on the path answers it — also one declared deeper than a segment the data\n // lacks (\\`get \"box.label\"()\\` with no \\`box\\` key: it renders and updates — docs/seam-apps.md)\n if (chain.some((q) => named(q)?.getter != null)) return null;\n for (const q of chain) {\n if (v === null || typeof v !== \"object\") return null;\n if (q.last === \"*\") {\n if (!Array.isArray(v) || v.length === 0) return null;\n v = v[0];\n continue;\n }\n if (Array.isArray(v) && /^\\d+$/.test(q.last)) {\n // an explicit index: only a row that is there can be looked into\n if (Number(q.last) >= v.length) return null;\n v = v[Number(q.last)];\n continue;\n }\n const d = findDescriptor(v, q.last);\n // a top-level key a re-set dropped is declared: it reads undefined, and a write fills it\n if (d === undefined && q.parent === null && engine.dropped.has(q.last)) return null;\n if (d === undefined) {\n const names = keysOf(v);\n // getters declared one level under the same parent (`items.*.subtotal`)\n const parent = named(q.parent);\n for (const g of engine.patterns.all()) if (g.parent === parent && g.getter !== null) names.push(g.last);\n return { seg: q.last, names };\n }\n if (d.get !== undefined || d.set !== undefined) return null;\n v = d.value;\n }\n return null;\n}\n\nfunction check(engine: Engine): void {\n due.delete(engine);\n const map = named.get(engine);\n if (map === undefined) return;\n let done = checked.get(engine);\n if (done === undefined) checked.set(engine, (done = new Set()));\n for (const [p, watch] of map) {\n if (done.has(p)) continue;\n done.add(p);\n const m = missing(engine, p);\n if (m === null) continue;\n // under the mount path of a volume on the page still loading: checked again once it settles (3.x D22)\n const v = [...((engine.root as ParentNode | null)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .find((e) => !settled.has(e) && (p.path + \".\").startsWith(e.getAttribute(\"mount\") + \".\"));\n if (v !== undefined) {\n done.delete(p);\n void (v as WcsState).initializePromise.then(() => {\n settled.add(v);\n schedule(engine);\n });\n continue;\n }\n const [code, subject] = watch ? [\"watch-path-missing\", \"$watch path\"] : [\"binding-path-missing\", \"Bound path\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": watch ? \"watch\" : \"binding\", \"path\": p.path, \"missingSegment\": m.seg });\n // a row of `for: groups.0.items` with a row getter declared on `groups.*.items.*` (#388)\n const w = engine.patterns.peek(parsePath(p.path).pattern);\n let rowGetter = \"\";\n if (w !== undefined && w !== p && w.getter !== null) {\n const loops = w.lists.slice(1).map((l, k) => `for: ${k === 0 ? l!.path : l!.path.slice(w.lists[k]!.path.length + 2)}`);\n rowGetter = ` The getter \"${w.path}\" is declared for the rows of ${loops.join(\" → \")}; a list named by an index has rows of its own.`;\n }\n console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\" does not resolve on the state tree: \"${m.seg}\" is not declared.${didYouMean(m.seg, m.names)}${rowGetter} Updates to this path will be silently dropped.${LINT_HINT}`);\n }\n}\n\nfunction schedule(engine: Engine): void {\n if (due.has(engine)) return;\n due.add(engine);\n setTimeout(() => check(engine), 0);\n}\n\n/** The `declared` hook: a path a binding or a `$watch` key names. */\nfunction declared(engine: Engine, p: Pattern, watch = false): void {\n // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (!watch && p.parent === null)) return;\n let map = named.get(engine);\n if (map === undefined) named.set(engine, (map = new Map()));\n if (!map.has(p)) map.set(p, watch);\n schedule(engine);\n}\n\n/** A re-set: every path is checked again against the new state. */\nfunction recheck(engine: Engine): void {\n checked.delete(engine);\n if (named.has(engine)) schedule(engine);\n}\n\n// ---------------------------------------------------------------- recursion's static checks\n\n/**\n * `$recursion` families that can never work (approved simplification: these checks moved out of\n * the core): a suffix naming the recursion structure itself, two families one of which is the\n * other a few repeats deeper, and a concrete key that one of the families expands to.\n */\nfunction checkRecursion(target: Record<string, any>): void {\n const decl = target.$recursion;\n if (decl === null || typeof decl !== \"object\") return;\n const entries = Object.entries(decl);\n if (entries.length !== 1 || typeof entries[0][1] !== \"string\") return;\n const [anchor, repeat] = entries[0] as [string, string];\n if (!anchor.endsWith(\".*\") || !repeat.endsWith(\".*\")) return;\n const list = anchor.slice(0, -2);\n const key = repeat.slice(0, -2);\n const step = `.${repeat}`;\n const head = `${list}.**`;\n const keys = keysOf(target);\n const families = keys.filter((k) => k.startsWith(head)).map((k) => k.slice(head.length));\n const bad = (why: string): never => raiseError(`[wcs/recursion-declaration-invalid] ${why}`);\n for (const s of families) {\n if (s === `.${key}` || s.startsWith(`.${key}.`)) {\n bad(`\"${head}${s}\" names the recursion structure itself (the \"${key}\" lists): recursive getters compute values over the nodes.`);\n }\n for (const t of families) {\n if (t.length > s.length && t.endsWith(s) && new RegExp(`^(?:${esc(step)})+$`).test(t.slice(0, t.length - s.length))) {\n bad(`\"${head}${s}\" and \"${head}${t}\" expand to the same concrete path at different depths (they differ by whole repetitions of \"${repeat}\"). Rename one of them.`);\n }\n }\n const re = new RegExp(`^${esc(anchor)}(?:${esc(step)})*${esc(s)}$`);\n for (const k of keys) {\n if (!k.includes(\"**\") && re.test(k)) bad(`\"${k}\" is already defined on the state, so the recursive getter \"${head}${s}\" cannot expand to it.`);\n }\n }\n}\n\nconst esc = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nlet trustedTypesReported = false;\n\n/**\n * An HTML sink write Trusted Types blocked: the browser's message names no fix, so say once\n * per page what to install (the same report as @wcstack/state 3.3).\n */\nfunction failed(_engine: Engine, error: unknown, binding: Binding): void {\n const prop = binding.name === \"html\" ? \"innerHTML\" : binding.name;\n if (trustedTypesReported || !(error instanceof TypeError) || !isHtmlSink(prop) || !(\"trustedTypes\" in globalThis)) return;\n trustedTypesReported = true;\n const cause = typeof getTrustedTypesPolicy()?.createHTML === \"function\"\n ? \"The injected policy's createHTML() did not return a TrustedHTML.\"\n : \"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.\";\n console.error(\n `[@wcstack/state] Writing to \"${prop}\" was blocked by Trusted Types (require-trusted-types-for 'script'). ${cause}\\n`\n + `Install a sanitizing policy before the first binding is applied:\\n`\n + ` globalThis[Symbol.for(\"wcstack.trustedTypes.policy\")] =\\n`\n + ` trustedTypes.createPolicy(\"my-app\", { createHTML: (s) => DOMPurify.sanitize(s) });\\n`\n + `Or bind the value as text instead of HTML. See docs/csp.md section 7.`,\n { element: binding.node, property: prop },\n );\n}\n\n// ---------------------------------------------------------------- the default getter\n\nconst warnedDetail = new WeakMap<Element, Set<string>>();\n\n/**\n * A wc-bindable property's event read with the default getter (`e.detail`): warns once per\n * element and property about the two shapes that cannot be what the element meant (README\n * \"What the element writes back\", as @wcstack/state 3.3). The write is applied as it is.\n * (a) no detail while the element's property has a value — a plain Event, or a forgotten detail;\n * (b) a detail object with a `<name>` key while the property is not an object — a wrapper.\n */\nfunction detail(el: Element, name: string, v: unknown): void {\n const prop = (el as any)[name];\n const reason = v === undefined\n ? prop === undefined ? null : `the event carried no detail (undefined) while element.${name} is ${typeof prop}`\n : v !== null && typeof v === \"object\" && Object.prototype.hasOwnProperty.call(v, name) && (prop === null || typeof prop !== \"object\")\n ? `the event's detail is an object with a \"${name}\" key while element.${name} is ${typeof prop}`\n : null;\n if (reason === null) return;\n let said = warnedDetail.get(el);\n if (said === undefined) warnedDetail.set(el, (said = new Set()));\n if (said.has(name)) return;\n said.add(name);\n console.warn(\n `[@wcstack/state] [wcs/default-getter-mismatch] <${el.localName}> \"${name}\": ${reason}. `\n + \"With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare \"\n + `getter (e.g. (e) => e.detail.${name}, or (e) => e.target.${name}) on that wcBindable property.`,\n );\n}\n\n// ---------------------------------------------------------------- 3.x names 4.0 removed\n\n/**\n * Declarations 3.2 renamed, whose old names 4.0 removed: a declaration under one would do nothing.\n * (The core detected these and the two APIs below up to 4.0.0-rc.3; without this add-on they are\n * ignored like any other unknown `$` key.)\n */\nconst REMOVED_DECLARATIONS: [string, string][] = [[\"$streams\", \"$stream\"], [\"$updatedCallback\", \"$renderedCallback\"]];\n/** APIs 3.2 renamed, whose old names 4.0 removed: reading one fails with the name to write. */\nconst REMOVED_APIS: Readonly<Record<string, string>> = { \"$trackDependency\": \"$dependOn\", \"$untrackDependency\": \"$untracked\" };\n\n/** A state that declares a 3.x name 4.0 removed (`$scan` has no successor: $watch or $on). */\nfunction removedDeclarations(target: Record<string, any>): void {\n if (target.$scan !== undefined) raise(M.ScanRemoved);\n for (const [old, name] of REMOVED_DECLARATIONS) if (target[old] !== undefined) raise(M.DeclarationRemoved, [old, name]);\n}\n\nexport const diagnostics: Feature = {\n name: \"diagnostics\",\n install(): void {\n hooks.explain = explain;\n hooks.render = render;\n hooks.declared = declared;\n hooks.detail = detail;\n hooks.failed = chain(hooks.failed, failed);\n // the removed names first, before what is installed (the core checked them before it took the\n // state in): a refused state never reaches the other add-ons' runtimes\n const prev = hooks.declare;\n hooks.declare = (engine, target) => {\n removedDeclarations(target);\n prev?.(engine, target);\n checkRecursion(target);\n recheck(engine);\n };\n hooks.dollar = first(known, hooks.dollar, (_engine, key) => (Object.hasOwn(REMOVED_APIS, key) ? raise(M.ApiRemoved, [key, REMOVED_APIS[key]]) : undefined));\n },\n};\nexport default diagnostics;\n"],"mappings":"mVAUA,SAASA,EAAaC,EAAWC,EAAWC,GAC1C,GAAIC,KAAKC,IAAIJ,EAAEK,OAASJ,EAAEI,QAAUH,EAClC,OAAOA,EAAM,EAEf,IAAMI,EAAiB,IAAIC,MAAMN,EAAEI,OAAS,GACtCG,EAAiB,IAAID,MAAMN,EAAEI,OAAS,GAC5C,QAASI,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKA,EAEZ,QAASC,EAAI,EAAGA,GAAKV,EAAEK,OAAQK,IAAK,CAClCF,EAAK,GAAKE,EACV,QAASD,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAAK,CAClC,IAAME,EAAOX,EAAEU,EAAI,KAAOT,EAAEQ,EAAI,GAAK,EAAI,EACzCD,EAAKC,GAAKN,KAAKS,IAAIN,EAAKG,GAAK,EAAGD,EAAKC,EAAI,GAAK,EAAGH,EAAKG,EAAI,GAAKE,EACjE,CACA,QAASF,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKD,EAAKC,EAEnB,CACA,OAAOH,EAAKL,EAAEI,OAChB,CAMO,SAASQ,EAAWC,EAAeC,GACxC,GAAqB,IAAjBD,EAAMT,OACR,MAAO,GAET,IAAMW,EAASF,EAAMG,cACjBC,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,EAAK7N,SAC1EiO,EAAOC,GAAuBC,EAAW,uCAAuCD,KACtF,QAAWzF,KAAKsF,EAAU,EACpBtF,IAAM,IAAIjG,KAASiG,EAAEvE,WAAW,IAAI1B,QACtCyL,EAAI,IAAIJ,IAAOpF,iDAAiDjG,+DAElE,QAAWU,KAAK6K,EACV7K,EAAElD,OAASyI,EAAEzI,QAAUkD,EAAEwK,SAASjF,IAAM,IAAI2F,OAAO,OAAO9C,EAAIsC,SAAY/G,KAAK3D,EAAEO,MAAM,EAAGP,EAAElD,OAASyI,EAAEzI,UACzGiO,EAAI,IAAIJ,IAAOpF,WAAWoF,IAAO3K,iGAAiGuK,4BAGtI,IAAMzH,EAAK,IAAIoI,OAAO,IAAI9C,EAAIkC,QAAalC,EAAIsC,OAAUtC,EAAI7C,OAC7D,QAAWb,KAAKkG,GACTlG,EAAE5E,SAAS,OAASgD,EAAGa,KAAKe,IAAIqG,EAAI,IAAIrG,gEAAgEiG,IAAOpF,0BAExH,CACF,CAwFM4F,CAAehG,GAhIrB,SAAiBL,GACfhB,EAAQ6C,OAAO7B,GACXlB,EAAMF,IAAIoB,IAAS2B,EAAS3B,EAClC,CA8HMsG,CAAQtG,IAEV0C,EAAM6D,GAASC,EAAMC,EAAO/D,EAAM6D,GAAQ,CAAC9C,EAASjJ,IAASqD,OAAOC,OAAO8G,EAAcpK,GAAO2K,OAAoB,CAAC3K,EAAKoK,EAAapK,UAAS,EAClJ,GAEKkM,EAAQ3B","ignoreList":[]}
1
+ {"version":3,"names":["editDistance","a","b","max","Math","abs","length","prev","Array","curr","j","i","cost","min","didYouMean","input","candidates","folded","toLowerCase","best","bestDistance","candidate","distance","LINT_HINT","CODES","codeOf","id","c","MOVED","was","v","String","Date","isArray","JSON","stringify","slice","NAMESPACES","element","tag","at","map","join","CSP_GUIDE","SENTENCES","p","parent","name","n","MAX_DRAIN_PASSES","MAX_RENDER_CHAIN","type","kind","src","status","detail","key","reserved","limit","fn","modifier","value","init","where","includes","l","t","keyword","prop","quote","args","f","trailing","lastIndexOf","source","mods","ns","given","api","depth","what","startsWith","method","allowed","over","loop","old","render","sentence","LINT_CODES","Set","GUIDES","RENAMED_FILTERS","inc","dec","fix","uc","lc","cap","rep","rev","pad","null","explain","message","subject","out","to","Object","hasOwn","removedFilter","re","text","m","exec","replace","_","Number","split","FORMATS_FILTER_NAMES","some","hasFilter","code","has","test","named","WeakMap","checked","due","WeakSet","settled","findDescriptor","o","x","prototype","getPrototypeOf","d","getOwnPropertyDescriptor","keysOf","k","getOwnPropertyNames","add","missing","engine","chain","q","unshift","target","segs","path","findIndex","s","indexOf","get","patterns","peek","parsePath","pattern","wildcardForm","getter","last","dropped","names","g","all","push","seg","set","schedule","setTimeout","delete","done","watch","root","querySelectorAll","config","tagNames","state","find","e","getAttribute","initializePromise","then","hooks","noticed","missingSegment","w","rowGetter","loops","lists","console","warn","check","declared","Map","esc","trustedTypesReported","failed","_engine","error","binding","TypeError","isHtmlSink","globalThis","cause","getTrustedTypesPolicy","createHTML","node","property","warnedDetail","el","reason","hasOwnProperty","call","said","localName","REMOVED_DECLARATIONS","REMOVED_APIS","$trackDependency","$untrackDependency","diagnostics","install","declare","$scan","raise","removedDeclarations","decl","$recursion","entries","anchor","repeat","endsWith","list","step","head","keys","families","filter","bad","why","raiseError","RegExp","checkRecursion","recheck","dollar","first","known","diagnostics_default"],"sources":["../../../src/diagnostics/guidance.ts","../../../src/diagnostics/messages.ts","../../../src/diagnostics/explain.ts","../../../src/features/diagnostics.ts"],"sourcesContent":["/**\n * diagnostics/guidance.ts — self-fix guidance for error messages, ported verbatim from\n * `@wcstack/state` (`errorGuidance.ts`). Only the diagnostics add-on uses it: the core's\n * messages state the fact, and the add-on appends this.\n *\n * The did-you-mean criteria (edit distance 2, ties go to the first candidate, case folded) are the\n * same as lint's suggestion, so the console, lint and the IDE never propose different names.\n */\n\n/** Insert / delete / substitute edit distance. Returns max + 1 early when the lengths differ by more than max. */\nfunction editDistance(a: string, b: string, max: number): number {\n if (Math.abs(a.length - b.length) > max) {\n return max + 1;\n }\n const prev: number[] = new Array(b.length + 1);\n const curr: number[] = new Array(b.length + 1);\n for (let j = 0; j <= b.length; j++) {\n prev[j] = j;\n }\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);\n }\n for (let j = 0; j <= b.length; j++) {\n prev[j] = curr[j];\n }\n }\n return prev[b.length];\n}\n\n/**\n * The nearest candidate within edit distance 2 as ` Did you mean \"<best>\"?`, or `\"\"` when there is\n * none. An empty input (a trailing `a|` pipe) gets no suggestion.\n */\nexport function didYouMean(input: string, candidates: Iterable<string>): string {\n if (input.length === 0) {\n return \"\";\n }\n const folded = input.toLowerCase();\n let best: string | null = null;\n let bestDistance = 3;\n for (const candidate of candidates) {\n const distance = editDistance(folded, candidate.toLowerCase(), 2);\n if (distance < bestDistance) {\n best = candidate;\n bestDistance = distance;\n }\n }\n return best !== null ? ` Did you mean \"${best}\"?` : \"\";\n}\n\n/**\n * The pointer to lint. Attach it **only where lint actually detects the case** — a hint that sends\n * the author to a lint run that comes back clean costs the loop its credibility.\n */\nexport const LINT_HINT = \" Validate statically: npx @wcstack/lint <file>.\";\n","/**\n * The sentences of the core's numbered messages (src/messages.ts), in the diagnostics add-on:\n * the core carries the number and the values, this renders what the core used to say. Each\n * sentence follows its `[wcs/<code>] ` (`codeOf`: the code the hundreds of the number name).\n * `Record<M, …>` makes a number without a sentence a type error.\n */\nimport { M } from \"../messages\";\nimport { MAX_DRAIN_PASSES, MAX_INDEX_PARAM, MAX_RENDER_CHAIN } from \"../engine\";\nimport { MAX_PATH_SEGMENTS, MODIFIER_SEPARATOR, RECURSION_WILDCARD } from \"../parser/define\";\n\ntype Sentence = (...a: any[]) => string;\n\n/**\n * The code of each hundred of message numbers (\"\" = none): the code lint and the VS Code extension\n * report for the same case. The core carried this up to 4.0.0-rc.3; without this add-on a message\n * now reads as its number and values alone.\n */\nexport const CODES = [\n \"\", \"binding-syntax\", \"template-syntax\", \"binding-path-missing\", \"binding-type-expectation\",\n \"filter-unknown\", \"filter-arity\", \"getter-cycle\", \"getter-depth-exceeded\", \"index-arity\",\n \"index-param-range\", \"recursion-unsupported\", \"token-misconfigured\", \"token-undeclared\",\n \"wildcard-rank\", \"spread-no-bindable\", \"declaration-alias\", \"name-alias\",\n];\n\n/** `[wcs/<code>] ` for a message number, or \"\" when it has none. */\nexport const codeOf = (id: M): string => {\n const c = CODES[(id / 100) | 0];\n return c ? `[wcs/${c}] ` : \"\";\n};\n\n/** The options 4.0 moved from `bootstrapState` to the state's `$behavior`. */\nconst MOVED = [\"enableMustache\", \"sameValueGuard\", \"enableDirectionalInitialSync\"];\n\n/** `<tag a=\"v\" …>` from the tag and its attributes' names and values. */\n/** What a value given to a filter was (`a string (\"2026-10-13T…\")`), for the type messages. */\nconst was = (v: unknown): string =>\n v == null ? String(v)\n : v instanceof Date ? \"a Date\"\n : Array.isArray(v) ? \"an array\"\n : typeof v === \"string\" ? `a string (${JSON.stringify(v.length > 32 ? v.slice(0, 32) + \"…\" : v)})`\n : typeof v === \"object\" ? \"an object\" : `a ${typeof v} (${String(v)})`;\n/** The namespace a binding of kind 2–4 (dom/view.ts: K_CLASS, K_ATTR, K_STYLE) names its member under. */\nconst NAMESPACES = [\"\", \"\", \"class.\", \"attr.\", \"style.\"];\n\nconst element = (tag: string, at: string[]): string => `<${tag}${at.map((a, i) => (i % 2 ? `=\"${a}\"` : ` ${a}`)).join(\"\")}>`;\n\nconst CSP_GUIDE = \"https://github.com/wcstack/wcstack/blob/main/docs/csp.md\";\n\nexport const SENTENCES: Record<M, Sentence> = {\n [M.ScanRemoved]: () => \"$scan was removed (use $watch or $on)\",\n [M.GetterWithoutSetter]: (p) => `\"${p}\" is a getter without a setter`,\n [M.NoRow]: (p) => `no row for \"${p}\"`,\n [M.ParentNotObject]: (p, parent) => `cannot write \"${p}\": its parent is ${parent}`,\n [M.NotAMethod]: (name) => `\"${name}\" is not a method`,\n [M.GetAllNoCommonLevel]: (p) => `$getAll(\"${p}\"): no loop level in common with the context`,\n [M.EqIndexNoRow]: (p) => `$eqIndex(\"${p}\") needs a list row scope.`,\n [M.Readonly]: () => \"This state is readonly.\",\n [M.SetAllNeedsIndexes]: (p) => `$setAll(\"${p}\") needs indexes ([] for every match)`,\n [M.SetAllSpreadLength]: (p, n) => `$setAll(\"${p}\", …, { spread: true }) needs an array of ${n} values`,\n [M.DrainNotSettled]: () => `updates did not settle after ${MAX_DRAIN_PASSES} passes`,\n [M.RenderChain]: () => `render chain depth limit exceeded (${MAX_RENDER_CHAIN} drains that rendering itself started); bindings for this batch were not applied.`,\n // (named as written — `textContent: iso`, `class.active: x` — when the binding has a member; else its type)\n [M.BindingFailed]: (type, p, name, kind) => `binding \"${name ? (NAMESPACES[kind] ?? \"\") + name : type}: ${p}\" failed to apply.`,\n [M.LoadFailed]: (src, status) => `failed to load \"${src}\": ${status}`,\n [M.ElementFailed]: () => \"this <wcs-state> failed to initialize; create a new one\",\n [M.NotInitialized]: () => \"state is not initialized\",\n [M.NoScript]: (id) => `no <script> with id \"${id}\"`,\n [M.InlineBlocked]: () => `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 ${CSP_GUIDE}`,\n [M.InlineFailed]: (detail) => `Failed to evaluate the inline <script> of <wcs-state>: ${detail}. If this page sets a Content-Security-Policy, see ${CSP_GUIDE}`,\n [M.TokenSubscriberThrew]: (name) => `a subscriber of token \"${name}\" threw.`,\n [M.TokenListNotArray]: (key) => `${key} must be an array of strings.`,\n [M.TokenEntryEmpty]: (key) => `${key} entries must be non-empty strings.`,\n [M.TokenEntryReserved]: (key, name, reserved) => `${key} entry \"${name}\" conflicts with the reserved namespace name \"${reserved}\".`,\n [M.TokenEntryDuplicated]: (key, name) => `${key} entry \"${name}\" is duplicated.`,\n [M.OnNotObject]: () => \"$on must be an object of handlers.\",\n [M.OnEntryUndeclared]: (name) => `$on entry \"${name}\" is not declared in $eventTokens.`,\n [M.OnEntryNotFunction]: (name) => `$on entry \"${name}\" must be a function.`,\n [M.NamingLimit]: (limit) => `view-transition naming-limit (${limit}) reached.`,\n [M.FilterOptionsRequired]: (fn) => `filter ${fn} requires at least one option`,\n [M.FilterOptionNotNumber]: (fn) => `filter ${fn} requires a number as option`,\n [M.FilterValueNotNumber]: (fn, v) => `filter ${fn} requires a number value, not ${was(v)}${typeof v === \"string\" ? ` — put |number before |${fn}, or convert it where it is read` : \"\"}`,\n [M.FilterValueNotDate]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === \"string\" || typeof v === \"number\" ? \" — make the Date where it is read: a getter returning new Date(…)\" : \"\"}`,\n [M.FilterStyleInvalid]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not \"${v}\"`,\n [M.FilterCurrencyInvalid]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not \"${v}\"`,\n [M.FilterValueNotArray]: (fn) => `filter ${fn} requires an array value`,\n [M.DirectionalSyncDisabled]: () => \"init=/sync= modifiers require enableDirectionalInitialSync.\",\n [M.ModifierUnknown]: (key, modifier) => `Unknown binding modifier \"${key}\" in \"${modifier}\".`,\n [M.ModifierTwice]: (key) => `Binding modifier \"${key}\" may only be specified once.`,\n [M.ModifierValue]: (key, value) => `Invalid ${key} modifier value \"${value}\".`,\n [M.EventInitNone]: () => \"Event bindings only allow init=none.\",\n [M.InitUnsupported]: (type, init) => `Binding type \"${type}\" does not support init=${init}.`,\n [M.MemberUndeclared]: (name) => `Property \"${name}\" is not declared by wcBindable.`,\n [M.InitIncompatible]: (init, name) => `init=${init} is incompatible with wcBindable member \"${name}\".`,\n [M.SyncConnectNeedsOutput]: (name) => `sync=connect requires observable property \"${name}\".`,\n [M.OptionInvalid]: (where, key) => `${where}: \"${key}\" is not one of its options, or not of the option's type.${where === \"bootstrapState\" && MOVED.includes(key) ? \" 4.0 moved it to the state's $behavior.\" : \"\"}`,\n [M.BehaviorChanged]: () => \"a re-set state may not change $behavior: create the element again.\",\n [M.SecondRoot]: () => \"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).\",\n [M.LocaleInvalid]: (l) => `the locale \"${l}\" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use \"en\".`,\n [M.FeaturesNotArray]: () => '$features must be an array of add-on names ([\"temporal\", \"formats\"]).',\n [M.InitFailed]: (tag, ...at) => `${element(tag, at)} failed to initialize.`,\n [M.ConnectedFailed]: (tag, ...at) => `${element(tag, at)} $connectedCallback failed.`,\n [M.DisconnectedFailed]: (tag, ...at) => `${element(tag, at)} $disconnectedCallback failed.`,\n\n [M.BindTextNoColon]: (t) => `Invalid bindText: \"${t}\". Missing ':' separator between propPart and statePart.`,\n [M.StructuralTakesNoModifiers]: (t, keyword) => `\"${t}\": \"${keyword}\" takes no modifiers or filters on its left side — write \"${keyword}:\".`,\n [M.ElseTakesNoValue]: (t) => `\"${t}\": \"else\" takes no value — write \"else:\".`,\n [M.SpreadNoPath]: (t) => `Invalid spread binding \"${t}\": spread target path is required.`,\n [M.SpreadNoFilters]: (t) => `Invalid spread binding \"${t}\": filters are not allowed on spread targets.`,\n [M.LeadingDotNamespace]: (prop) => `\"${prop}\": a leading \".\" binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,\n [M.UnterminatedQuote]: (quote, args) => `unterminated ${quote} quote in the filter arguments \"(${args})\". Close the quote.`,\n [M.FilterUnclosed]: (f) => `Invalid filter format: missing closing parenthesis in \"${f}\".`,\n [M.FilterUnopened]: (f) => `Invalid filter format: missing opening parenthesis in \"${f}\".`,\n [M.FilterParenOrder]: (f) => `Invalid filter format: \")\" comes before \"(\" in \"${f}\".`,\n [M.FilterTrailing]: (f, trailing) => `\"${f}\": unexpected \"${trailing}\" after the filter's closing \")\" — separate filters with \"|\" (write \"${f.slice(0, f.lastIndexOf(\")\") + 1)}|${trailing}\").`,\n [M.FilterEmpty]: (source) => `an empty filter in \"${source}\" — remove the extra \"|\" or name the filter.`,\n [M.FilterNameHasModifiersInput]: (name, mods) => `\"${name}\" is not a filter name: a modifier list \"${MODIFIER_SEPARATOR}${mods}\" comes before the input filters, not inside one`,\n [M.FilterNameHasModifiersOutput]: (name) => `\"${name}\" is not a filter name: \"${MODIFIER_SEPARATOR}\" cannot appear in one.`,\n [M.OneModifierList]: (prop) => `\"${prop}\": a binding takes one modifier list after a single \"#\"`,\n [M.NoPropertyName]: (prop) => `\"${prop}\": the left side of a binding must name a property — write \"<property>: <path>\" (modifiers and input filters come after the name).`,\n [M.TooManySegments]: (p, n) => `\"${p}\" has ${n} path segments — the limit is ${MAX_PATH_SEGMENTS}.`,\n [M.SelectorRemoved]: (t) => `\"${t}\": 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.`,\n [M.UnsafeSegment]: (p) => `\"${p}\": a state path cannot go through \"__proto__\" or \"prototype\" (it would reach every object's prototype).`,\n [M.ForNoFilters]: (t) => `\"${t}\": \"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>\").`,\n [M.NamespaceNeedsName]: (t, ns) => ns === \"class\"\n ? `\"${t}\": \"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:\".`\n : `\"${t}\": \"attr:\" needs an attribute name — \"attr.NAME:\" sets one attribute (a bare \"attr:\" would set an element property named \"attr\", which does nothing).`,\n [M.EmptySegment]: (t) => `\"${t}\": 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).`,\n\n [M.StructuralNotSingle]: (t) => `Invalid bindText: \"${t}\". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,\n [M.ElseWithoutIf]: (type) => `\"${type}:\" must follow an \"if:\" template`,\n [M.TemplateHandedOver]: (type) => `a \"${type}:\" 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.`,\n [M.OuterInTemplate]: (name) => `\"${name}:\" 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.`,\n\n [M.PathMissing]: (p) => `Path \"${p}\" does not exist on the state tree.`,\n\n [M.ClassNeedsBoolean]: (name, type) => `class.${name} needs a boolean, got ${type}.`,\n\n [M.FilterUnknown]: (name) => `filter not found: ${name}.`,\n\n [M.FilterTooFewArgs]: (name, min, given) => `filter \"${name}\" requires at least ${min} argument(s) (${given} given).`,\n [M.FilterTooManyArgs]: (name, max, given) => `filter \"${name}\" accepts at most ${max} argument(s) (${given} given).`,\n\n [M.GetterCycle]: (p) => `\"${p}\" depends on itself`,\n\n [M.GetterDepth]: (p) => `\"${p}\"`,\n\n [M.IndexArityExact]: (api, p, depth, n) => `${api}(\"${p}\") takes ${depth} index(es), got ${n}.`,\n [M.IndexArityAtMost]: (api, p, depth, n) => `${api}(\"${p}\") takes at most ${depth} index(es), got ${n}.`,\n\n [M.IndexParamRange]: (key) => `\"${key}\": list index parameters run from $1 to $${MAX_INDEX_PARAM}.`,\n\n [M.RecursionUnsupported]: (p) => `\"${p}\" uses \"${RECURSION_WILDCARD}\", which is not accepted here.`,\n\n [M.CommandRightSide]: (prop, p) => `\"${prop}: ${p}\": the right-hand side must be $command.<name>`,\n // a native element's command (no hyphen: never a custom element) is the native-commands add-on's\n [M.NoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${\n !tag.includes(\"-\") && what.startsWith(\"command.\") ? \" A native element's command needs the add-on @wcstack/state/features/native-commands.\" : \"\"}`,\n [M.NoCommand]: (tag, method) => `<${tag}> declares no command \"${method}\".`,\n [M.NoProperty]: (tag, prop) => `<${tag}> declares no property \"${prop}\".`,\n [M.NativeNoCommand]: (tag, method, allowed) => `<${tag}> has no command \"${method}\" (a native <${tag}>'s commands: ${allowed}).`,\n\n [M.EventTokenUndeclared]: (name) => `eventToken \"${name}\" is not declared in $eventTokens.`,\n [M.CommandTokenUndeclared]: (name) => `\"$command.${name}\" is not declared in $commandTokens.`,\n\n [M.WildcardNoLoop]: (p, depth, n = 0) => `\"${p}\" needs ${depth} enclosing loop level(s); the scope provides ${n}.`,\n [M.WildcardRelative]: (p) => `\"${p}\" is relative: it needs an enclosing \"for\" template`,\n [M.WildcardOtherList]: (p, over, loop) => `\"${p}\" ranges over the rows of \"${over}\", but the enclosing \"for\" template at that level renders \"${loop}\".`,\n\n [M.SpreadNoBindable]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,\n\n [M.DeclarationRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n\n [M.ApiRemoved]: (old, name) => `${old} was removed: write ${name}.`,\n};\n","/**\n * The diagnostics add-on's sentences and guidance: a numbered core message rendered as its\n * sentence (src/diagnostics/messages.ts), then how to fix it, the nearest name and the lint\n * pointer. The add-on installs these; so does `@wcstack/state/parser`, a bundle of its own.\n */\nimport { didYouMean, LINT_HINT } from \"./guidance\";\nimport { FORMATS_FILTER_NAMES, hasFilter } from \"../filters/registry\";\nimport type { M } from \"../messages\";\nimport { codeOf, SENTENCES } from \"./messages\";\n\n/** A numbered core message as its sentence (the number and the values if it is not known here). */\nexport function render(id: number, args: readonly unknown[]): string {\n const sentence = SENTENCES[id as M];\n return sentence === undefined ? `${codeOf(id)}#${id} ${args.join(\" \")}` : codeOf(id) + sentence(...args);\n}\n\n/** Codes lint detects statically: only these point the author to a lint run. */\nconst LINT_CODES = new Set([\n \"binding-syntax\", \"template-syntax\", \"filter-unknown\", \"filter-arity\", \"index-arity\",\n \"wildcard-rank\", \"token-undeclared\", \"binding-path-missing\", \"index-param-range\",\n]);\n\n/** How to fix it, by what the message says. */\nconst GUIDES: [RegExp, string][] = [\n [/no loop level in common with the context/, \"; pass indexes ([] for all).\"],\n [/\"([^\"#]+)#([^\"]*)\" is not a filter name: a modifier list .* comes before the input filters/, ' — write \"<property>#$2|$1\".'],\n [/\\[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.\"],\n [/must be single binding/, ' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs=\"for: items\">).'],\n [/\\[wcs\\/wildcard-rank\\] .* needs \\d+ enclosing/, ' Wrap it in that many \"for\" templates, or use $resolve(path, indexes) to name the row explicitly.'],\n [/\\[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).'],\n [/\\[wcs\\/binding-type-expectation\\] class\\.([^ ]+)/, ' Write \"class.$1: path|truthy\" to toggle on truthiness.'],\n [/path segments — the limit/, \" Every prefix of a path is interned, so the cost grows with the square of the depth.\"],\n [/\\[wcs\\/index-arity\\] \\$resolve/, \" $resolve takes one index per \\\"*\\\"; $getAll / $setAll take at most that many (fewer expands the rest).\"],\n [/\"([^\"#]+)#[^\"]*\" is not a filter name: \"#\" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the \":\" — write \"$1\" here.'],\n];\n\n/**\n * The filter names 3.2 renamed, which 3.x kept as aliases and 4.0 removed (3.x's `filterAliases`;\n * lint has the same table). Their message names the replacement, not the nearest name: for these\n * that is an unrelated filter (`dec` → `eq`, `fix` → `div`), and following it changes the meaning.\n */\nexport const RENAMED_FILTERS: Readonly<Record<string, string>> = {\n inc: \"add\", dec: \"sub\", fix: \"toFixed\", uc: \"upper\", lc: \"lower\", cap: \"capitalize\", rep: \"repeat\", rev: \"reverse\", pad: \"padStart\", null: \"nullIfEmpty\",\n};\n\n/** How to write a filter 4.0 removed, or null. */\nfunction removedFilter(name: string): string | null {\n // 4.0 folded substr(start, length) into slice(start, end): the second argument changes meaning\n if (name === \"substr\") return ' \"substr\" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';\n const to = Object.hasOwn(RENAMED_FILTERS, name) ? RENAMED_FILTERS[name] : null;\n return to === null ? null : ` \"${name}\" was renamed \"${to}\" in 3.2 and removed in 4.0 — write \"${to}\".`;\n}\n\nexport function explain(message: string, subject?: string, candidates?: Iterable<string>): string {\n const removed = subject !== undefined && message.includes(\"[wcs/filter-unknown]\") ? removedFilter(subject) : null;\n let out = removed ?? (subject !== undefined && candidates !== undefined ? didYouMean(subject, candidates) : \"\");\n for (const [re, text] of GUIDES) {\n const m = re.exec(message);\n if (m !== null) out += text.replace(/\\$(\\d)/g, (_, i: string) => m[Number(i)]);\n }\n // \"value#ro#wo\": one modifier list — the fix joins them\n const mods = /\"([^\"#]+)#([^\"]+)\": a binding takes one modifier list/.exec(message);\n if (mods !== null) out += ` — write \"${mods[1]}#${mods[2].split(\"#\").join(\",\")}\".`;\n // a formatting filter on a page without the formats add-on (the core names installFeatures), or a\n // typo on a page with no formatting filters at all: the formats add-on may be what is missing\n if (message.includes(\"[wcs/filter-unknown]\")) {\n if (message.includes(\"formats add-on\")) out += ` On a split auto page: features=\"formats\" on the root, or \"$features\": [\"formats\"].`;\n else if (!FORMATS_FILTER_NAMES.some(hasFilter)) {\n out += ` 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\").`;\n }\n }\n const code = /\\[wcs\\/([\\w-]+)\\]/.exec(message);\n // (not something lint reports: the path-length limit is a runtime cost, a template handed over at\n // the top of inserted content (#204) is the page's order of loading, not its markup, and lint's\n // manifest knows the formatting filters — one missing because the formats add-on is not installed\n // is the page's. A row of another list (#1403) and an `outerHTML:` in a template (#203) lint does\n // report, as of its 4.0 parser)\n if (code !== null && LINT_CODES.has(code[1]) && !/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(message)) out += LINT_HINT;\n return out;\n}\n","/**\n * The diagnostics add-on (@wcstack/state/features/diagnostics): the sentences and the self-fix\n * guidance of error messages. The core states the message number and the values\n * (`#901 \"$resolve\" \"m.*.*\" 2 1`); with this installed, the message is the code shared with lint\n * and the sentence (`[wcs/index-arity] $resolve(\"m.*.*\") takes 2 index(es), got 1.`), followed by the\n * nearest name (did-you-mean, the same rule as lint), how to fix it, and a pointer to lint where\n * lint really detects the case. The full `auto` bundle installs it.\n */\nimport { chain, first, hooks, known, type Feature } from \"../hooks\";\nimport type { Engine } from \"../engine\";\nimport { parsePath, type Pattern } from \"../pattern\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { config } from \"../config\";\nimport type { WcsState } from \"../element\";\nimport type { Binding } from \"../dom/view\";\nimport { getTrustedTypesPolicy, isHtmlSink } from \"../trustedTypes\";\nimport { didYouMean, LINT_HINT } from \"../diagnostics/guidance\";\nimport { explain, render } from \"../diagnostics/explain\";\nimport { raise, M } from \"../messages\";\n\n// ---------------------------------------------------------------- paths that do not resolve\n\n/** Paths bindings and `$watch` keys named, by engine: checked one macrotask later (and after a re-set). */\nconst named = new WeakMap<Engine, Map<Pattern, boolean>>();\nconst checked = new WeakMap<Engine, Set<Pattern>>();\nconst due = new WeakSet<Engine>();\n/** Volumes (`<wcs-state mount>`) whose loading settled: the paths under them are checked from then on. */\nconst settled = new WeakSet<Element>();\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction keysOf(o: object): string[] {\n const out = new Set<string>();\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n for (const k of Object.getOwnPropertyNames(x)) if (k[0] !== \"$\" && k !== \"constructor\") out.add(k);\n }\n return [...out];\n}\n\n/**\n * The pattern a path with an explicit index reads through: an index with no `*` after it\n * (`items.0.x`) has an accessor of its own (Engine.markupAccessor), so whether it reads a getter\n * is the question of the pattern it names (`items.*.x`). A `*` after the index (`groups.0.items.*.x`,\n * a row of `for: groups.0.items`) reads its row's own item: the pattern itself. So does a path the\n * author declared a getter under (`get \"groups.0.items\"()`): that getter is what it reads (#388).\n */\nfunction wildcardForm(engine: Engine, q: Pattern): Pattern | undefined {\n const segs = q.path.split(\".\");\n // (a leading numeric segment is a root key, not an index: parsePath)\n const i = segs.findIndex((s, j) => j > 0 && /^\\d/.test(s));\n return i < 0 || segs.indexOf(\"*\", i) >= 0 || findDescriptor(engine.target, q.path)?.get !== undefined\n ? q : engine.patterns.peek(parsePath(q.path).pattern);\n}\n\n/**\n * The segment of `p` that certainly does not exist, with the names that do at its level; null\n * when the path exists or it cannot be told without evaluating a getter (a getter on the way, a\n * null or primitive on the way, a list with no row to look into).\n */\nfunction missing(engine: Engine, p: Pattern): { seg: string; names: string[] } | null {\n const chain: Pattern[] = [];\n for (let q: Pattern | null = p; q !== null; q = q.parent) chain.unshift(q);\n let v: any = engine.target;\n const named = (q: Pattern | null): Pattern | null | undefined => (q === null ? null : wildcardForm(engine, q));\n // a getter anywhere on the path answers it — also one declared deeper than a segment the data\n // lacks (\\`get \"box.label\"()\\` with no \\`box\\` key: it renders and updates — docs/seam-apps.md)\n if (chain.some((q) => named(q)?.getter != null)) return null;\n for (const q of chain) {\n if (v === null || typeof v !== \"object\") return null;\n if (q.last === \"*\") {\n if (!Array.isArray(v) || v.length === 0) return null;\n v = v[0];\n continue;\n }\n if (Array.isArray(v) && /^\\d+$/.test(q.last)) {\n // an explicit index: only a row that is there can be looked into\n if (Number(q.last) >= v.length) return null;\n v = v[Number(q.last)];\n continue;\n }\n const d = findDescriptor(v, q.last);\n // a top-level key a re-set dropped is declared: it reads undefined, and a write fills it\n if (d === undefined && q.parent === null && engine.dropped.has(q.last)) return null;\n if (d === undefined) {\n const names = keysOf(v);\n // getters declared one level under the same parent (`items.*.subtotal`)\n const parent = named(q.parent);\n for (const g of engine.patterns.all()) if (g.parent === parent && g.getter !== null) names.push(g.last);\n return { seg: q.last, names };\n }\n if (d.get !== undefined || d.set !== undefined) return null;\n v = d.value;\n }\n return null;\n}\n\nfunction check(engine: Engine): void {\n due.delete(engine);\n const map = named.get(engine);\n if (map === undefined) return;\n let done = checked.get(engine);\n if (done === undefined) checked.set(engine, (done = new Set()));\n for (const [p, watch] of map) {\n if (done.has(p)) continue;\n done.add(p);\n const m = missing(engine, p);\n if (m === null) continue;\n // under the mount path of a volume on the page still loading: checked again once it settles (3.x D22)\n const v = [...((engine.root as ParentNode | null)?.querySelectorAll(`${config.tagNames.state}[mount]`) ?? [])]\n .find((e) => !settled.has(e) && (p.path + \".\").startsWith(e.getAttribute(\"mount\") + \".\"));\n if (v !== undefined) {\n done.delete(p);\n void (v as WcsState).initializePromise.then(() => {\n settled.add(v);\n schedule(engine);\n });\n continue;\n }\n const [code, subject] = watch ? [\"watch-path-missing\", \"$watch path\"] : [\"binding-path-missing\", \"Bound path\"];\n hooks.noticed?.(engine, { \"type\": \"state:path-unresolved\", \"source\": watch ? \"watch\" : \"binding\", \"path\": p.path, \"missingSegment\": m.seg });\n // a row of `for: groups.0.items` with a row getter declared on `groups.*.items.*` (#388)\n const w = engine.patterns.peek(parsePath(p.path).pattern);\n let rowGetter = \"\";\n if (w !== undefined && w !== p && w.getter !== null) {\n const loops = w.lists.slice(1).map((l, k) => `for: ${k === 0 ? l!.path : l!.path.slice(w.lists[k]!.path.length + 2)}`);\n rowGetter = ` The getter \"${w.path}\" is declared for the rows of ${loops.join(\" → \")}; a list named by an index has rows of its own.`;\n }\n console.warn(`[@wcstack/state] [wcs/${code}] ${subject} \"${p.path}\" does not resolve on the state tree: \"${m.seg}\" is not declared.${didYouMean(m.seg, m.names)}${rowGetter} Updates to this path will be silently dropped.${LINT_HINT}`);\n }\n}\n\nfunction schedule(engine: Engine): void {\n if (due.has(engine)) return;\n due.add(engine);\n setTimeout(() => check(engine), 0);\n}\n\n/** The `declared` hook: a path a binding or a `$watch` key names. */\nfunction declared(engine: Engine, p: Pattern, watch = false): void {\n // a missing top-level key already fails the binding's read (the core's error)\n if (p.path[0] === \"$\" || p.path.includes(\"#\") || (!watch && p.parent === null)) return;\n let map = named.get(engine);\n if (map === undefined) named.set(engine, (map = new Map()));\n if (!map.has(p)) map.set(p, watch);\n schedule(engine);\n}\n\n/** A re-set: every path is checked again against the new state. */\nfunction recheck(engine: Engine): void {\n checked.delete(engine);\n if (named.has(engine)) schedule(engine);\n}\n\n// ---------------------------------------------------------------- recursion's static checks\n\n/**\n * `$recursion` families that can never work (approved simplification: these checks moved out of\n * the core): a suffix naming the recursion structure itself, two families one of which is the\n * other a few repeats deeper, and a concrete key that one of the families expands to.\n */\nfunction checkRecursion(target: Record<string, any>): void {\n const decl = target.$recursion;\n if (decl === null || typeof decl !== \"object\") return;\n const entries = Object.entries(decl);\n if (entries.length !== 1 || typeof entries[0][1] !== \"string\") return;\n const [anchor, repeat] = entries[0] as [string, string];\n if (!anchor.endsWith(\".*\") || !repeat.endsWith(\".*\")) return;\n const list = anchor.slice(0, -2);\n const key = repeat.slice(0, -2);\n const step = `.${repeat}`;\n const head = `${list}.**`;\n const keys = keysOf(target);\n const families = keys.filter((k) => k.startsWith(head)).map((k) => k.slice(head.length));\n const bad = (why: string): never => raiseError(`[wcs/recursion-declaration-invalid] ${why}`);\n for (const s of families) {\n if (s === `.${key}` || s.startsWith(`.${key}.`)) {\n bad(`\"${head}${s}\" names the recursion structure itself (the \"${key}\" lists): recursive getters compute values over the nodes.`);\n }\n for (const t of families) {\n if (t.length > s.length && t.endsWith(s) && new RegExp(`^(?:${esc(step)})+$`).test(t.slice(0, t.length - s.length))) {\n bad(`\"${head}${s}\" and \"${head}${t}\" expand to the same concrete path at different depths (they differ by whole repetitions of \"${repeat}\"). Rename one of them.`);\n }\n }\n const re = new RegExp(`^${esc(anchor)}(?:${esc(step)})*${esc(s)}$`);\n for (const k of keys) {\n if (!k.includes(\"**\") && re.test(k)) bad(`\"${k}\" is already defined on the state, so the recursive getter \"${head}${s}\" cannot expand to it.`);\n }\n }\n}\n\nconst esc = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nlet trustedTypesReported = false;\n\n/**\n * An HTML sink write Trusted Types blocked: the browser's message names no fix, so say once\n * per page what to install (the same report as @wcstack/state 3.3).\n */\nfunction failed(_engine: Engine, error: unknown, binding: Binding): void {\n const prop = binding.name === \"html\" ? \"innerHTML\" : binding.name;\n if (trustedTypesReported || !(error instanceof TypeError) || !isHtmlSink(prop) || !(\"trustedTypes\" in globalThis)) return;\n trustedTypesReported = true;\n const cause = typeof getTrustedTypesPolicy()?.createHTML === \"function\"\n ? \"The injected policy's createHTML() did not return a TrustedHTML.\"\n : \"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.\";\n console.error(\n `[@wcstack/state] Writing to \"${prop}\" was blocked by Trusted Types (require-trusted-types-for 'script'). ${cause}\\n`\n + `Install a sanitizing policy before the first binding is applied:\\n`\n + ` globalThis[Symbol.for(\"wcstack.trustedTypes.policy\")] =\\n`\n + ` trustedTypes.createPolicy(\"my-app\", { createHTML: (s) => DOMPurify.sanitize(s) });\\n`\n + `Or bind the value as text instead of HTML. See docs/csp.md section 7.`,\n { element: binding.node, property: prop },\n );\n}\n\n// ---------------------------------------------------------------- the default getter\n\nconst warnedDetail = new WeakMap<Element, Set<string>>();\n\n/**\n * A wc-bindable property's event read with the default getter (`e.detail`): warns once per\n * element and property about the two shapes that cannot be what the element meant (README\n * \"What the element writes back\", as @wcstack/state 3.3). The write is applied as it is.\n * (a) no detail while the element's property has a value — a plain Event, or a forgotten detail;\n * (b) a detail object with a `<name>` key while the property is not an object — a wrapper.\n */\nfunction detail(el: Element, name: string, v: unknown): void {\n const prop = (el as any)[name];\n const reason = v === undefined\n ? prop === undefined ? null : `the event carried no detail (undefined) while element.${name} is ${typeof prop}`\n : v !== null && typeof v === \"object\" && Object.prototype.hasOwnProperty.call(v, name) && (prop === null || typeof prop !== \"object\")\n ? `the event's detail is an object with a \"${name}\" key while element.${name} is ${typeof prop}`\n : null;\n if (reason === null) return;\n let said = warnedDetail.get(el);\n if (said === undefined) warnedDetail.set(el, (said = new Set()));\n if (said.has(name)) return;\n said.add(name);\n console.warn(\n `[@wcstack/state] [wcs/default-getter-mismatch] <${el.localName}> \"${name}\": ${reason}. `\n + \"With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare \"\n + `getter (e.g. (e) => e.detail.${name}, or (e) => e.target.${name}) on that wcBindable property.`,\n );\n}\n\n// ---------------------------------------------------------------- 3.x names 4.0 removed\n\n/**\n * Declarations 3.2 renamed, whose old names 4.0 removed: a declaration under one would do nothing.\n * (The core detected these and the two APIs below up to 4.0.0-rc.3; without this add-on they are\n * ignored like any other unknown `$` key.)\n */\nconst REMOVED_DECLARATIONS: [string, string][] = [[\"$streams\", \"$stream\"], [\"$updatedCallback\", \"$renderedCallback\"]];\n/** APIs 3.2 renamed, whose old names 4.0 removed: reading one fails with the name to write. */\nconst REMOVED_APIS: Readonly<Record<string, string>> = { \"$trackDependency\": \"$dependOn\", \"$untrackDependency\": \"$untracked\" };\n\n/** A state that declares a 3.x name 4.0 removed (`$scan` has no successor: $watch or $on). */\nfunction removedDeclarations(target: Record<string, any>): void {\n if (target.$scan !== undefined) raise(M.ScanRemoved);\n for (const [old, name] of REMOVED_DECLARATIONS) if (target[old] !== undefined) raise(M.DeclarationRemoved, [old, name]);\n}\n\nexport const diagnostics: Feature = {\n name: \"diagnostics\",\n install(): void {\n hooks.explain = explain;\n hooks.render = render;\n hooks.declared = declared;\n hooks.detail = detail;\n hooks.failed = chain(hooks.failed, failed);\n // the removed names first, before what is installed (the core checked them before it took the\n // state in): a refused state never reaches the other add-ons' runtimes\n const prev = hooks.declare;\n hooks.declare = (engine, target) => {\n removedDeclarations(target);\n prev?.(engine, target);\n checkRecursion(target);\n recheck(engine);\n };\n hooks.dollar = first(known, hooks.dollar, (_engine, key) => (Object.hasOwn(REMOVED_APIS, key) ? raise(M.ApiRemoved, [key, REMOVED_APIS[key]]) : undefined));\n },\n};\nexport default diagnostics;\n"],"mappings":"mVAUA,SAASA,EAAaC,EAAWC,EAAWC,GAC1C,GAAIC,KAAKC,IAAIJ,EAAEK,OAASJ,EAAEI,QAAUH,EAClC,OAAOA,EAAM,EAEf,IAAMI,EAAiB,IAAIC,MAAMN,EAAEI,OAAS,GACtCG,EAAiB,IAAID,MAAMN,EAAEI,OAAS,GAC5C,QAASI,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKA,EAEZ,QAASC,EAAI,EAAGA,GAAKV,EAAEK,OAAQK,IAAK,CAClCF,EAAK,GAAKE,EACV,QAASD,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAAK,CAClC,IAAME,EAAOX,EAAEU,EAAI,KAAOT,EAAEQ,EAAI,GAAK,EAAI,EACzCD,EAAKC,GAAKN,KAAKS,IAAIN,EAAKG,GAAK,EAAGD,EAAKC,EAAI,GAAK,EAAGH,EAAKG,EAAI,GAAKE,EACjE,CACA,QAASF,EAAI,EAAGA,GAAKR,EAAEI,OAAQI,IAC7BH,EAAKG,GAAKD,EAAKC,EAEnB,CACA,OAAOH,EAAKL,EAAEI,OAChB,CAMO,SAASQ,EAAWC,EAAeC,GACxC,GAAqB,IAAjBD,EAAMT,OACR,MAAO,GAET,IAAMW,EAASF,EAAMG,cACjBC,EAAsB,KACtBC,EAAe,EACnB,QAAWC,KAAaL,EAAY,CAClC,IAAMM,EAAWtB,EAAaiB,EAAQI,EAAUH,cAAe,GAC3DI,EAAWF,IACbD,EAAOE,EACPD,EAAeE,EAEnB,CACA,OAAgB,OAATH,EAAgB,kBAAkBA,MAAW,EACtD,CAMO,IAAMI,EAAY,kDCxCZC,EAAQ,CACnB,GAAI,iBAAkB,kBAAmB,uBAAwB,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