@yagejs-addons/dialogue 0.1.0 → 0.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.
- package/dist/DialogueController-BMeNLi0v.d.cts +1204 -0
- package/dist/DialogueController-Cs5IUc-u.d.ts +1204 -0
- package/dist/chunk-7QVYU63E.js +7 -0
- package/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/chunk-CU47RPEB.js +410 -0
- package/dist/chunk-CU47RPEB.js.map +1 -0
- package/dist/chunk-GJQKZCOL.js +983 -0
- package/dist/chunk-GJQKZCOL.js.map +1 -0
- package/dist/index.cjs +3441 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +591 -0
- package/dist/index.d.ts +591 -0
- package/dist/index.js +2048 -0
- package/dist/index.js.map +1 -0
- package/dist/presenters.cjs +3149 -0
- package/dist/presenters.cjs.map +1 -0
- package/dist/presenters.d.cts +1817 -0
- package/dist/presenters.d.ts +1817 -0
- package/dist/presenters.js +2920 -0
- package/dist/presenters.js.map +1 -0
- package/dist/types-DSbBSlh7.d.cts +375 -0
- package/dist/types-DSbBSlh7.d.ts +375 -0
- package/dist/yaml.cjs +726 -0
- package/dist/yaml.cjs.map +1 -0
- package/dist/yaml.d.cts +23 -0
- package/dist/yaml.d.ts +23 -0
- package/dist/yaml.js +37 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/vars.ts","../src/core/expr.ts","../src/core/i18n.ts","../src/core/validate.ts","../src/core/expr-parse.ts","../src/core/formats/canonical.ts"],"sourcesContent":["/**\n * {@link VariableStorage} implementations — the read/write bridge between a\n * conversation and game state. One **opaque** name namespace; scoping is\n * the host's policy. Three building blocks:\n *\n * • {@link MemoryVariableStorage} — the zero-config default. A plain Map; holds\n * dialogue-locals and seeded defaults, persists across plays.\n * • {@link cells} — first-class **two-way binding**: `{ gold: { get, set } }`\n * drives a value the *script* owns the arithmetic of (a read-only getter\n * throws on `set`). A bare `() => value` is the read-only shorthand.\n * • {@link compose} — layer several storages into one (reads/writes route to\n * the first that `has` the name; a brand-new name lands in the last —\n * so put a writable store last to catch seeds + locals).\n *\n * The interface lives in `types.ts`; this file is the concrete kit. Seed-if-\n * absent + persistence are policy of the *caller* (`session.play`), not the\n * storage — these just hold values.\n */\n\nimport type { VariableStorage, VarMap, VarValue } from \"./types.js\";\n\n/** Materialize a storage's enumerable variables into a plain map — backs\n * `{token}` interpolation params and `handle.getVars()`. */\nexport function materialize(storage: VariableStorage): VarMap {\n const out: VarMap = {};\n for (const [name, value] of storage.entries()) out[name] = value;\n return out;\n}\n\n/** The zero-config default storage: a Map-backed, fully-enumerable store. */\nexport class MemoryVariableStorage implements VariableStorage {\n private readonly map = new Map<string, VarValue>();\n\n constructor(initial?: Readonly<VarMap>) {\n if (initial) for (const [name, value] of Object.entries(initial)) this.map.set(name, value);\n }\n\n get(name: string): VarValue | undefined {\n return this.map.get(name);\n }\n set(name: string, value: VarValue): void {\n this.map.set(name, value);\n }\n has(name: string): boolean {\n return this.map.has(name);\n }\n entries(): Iterable<readonly [string, VarValue]> {\n return this.map.entries();\n }\n /** Drop everything — host-controlled reset (variables persist across plays by default). */\n clear(): void {\n this.map.clear();\n }\n}\n\n/** A two-way (or read-only) binding for one game-owned value. A bare function is\n * the read-only shorthand for `{ get }`. */\nexport type Cell =\n | { get(): VarValue; set?(value: VarValue): void }\n | (() => VarValue);\n\n/**\n * A {@link VariableStorage} over named accessors into game state. `has` is true\n * for exactly the declared names; `get` invokes the getter live; `set` writes\n * through the setter, or throws if the cell is read-only (a getter with no\n * setter). This is the seam for a value whose arithmetic the *script* owns\n * (`set gold = gold - 50`).\n */\nexport function cells(defs: Readonly<Record<string, Cell>>): VariableStorage {\n // Own-property checks only (like i18n's `interpolate`): a bare `name in defs`\n // walks the prototype chain, so `has(\"toString\")` / `has(\"constructor\")` would\n // report true and read an inherited Object.prototype member as a cell.\n const read = (name: string): VarValue => {\n const cell = defs[name]!;\n return typeof cell === \"function\" ? cell() : cell.get();\n };\n return {\n get(name) {\n return Object.hasOwn(defs, name) ? read(name) : undefined;\n },\n set(name, value) {\n if (!Object.hasOwn(defs, name)) {\n throw new Error(`dialogue: cells() has no accessor for \"${name}\"`);\n }\n const cell = defs[name]!;\n if (typeof cell === \"function\" || cell.set === undefined) {\n throw new Error(\n `dialogue: \"${name}\" is read-only (a cells getter without a setter)`,\n );\n }\n cell.set(value);\n },\n has(name) {\n return Object.hasOwn(defs, name);\n },\n *entries() {\n for (const name of Object.keys(defs)) yield [name, read(name)] as const;\n },\n };\n}\n\n/**\n * Layer storages into one. `get`/`has` consult them in order (first that `has`\n * the name wins); `set` writes through the first that `has` it, else the **last**\n * storage — so a brand-new name (a dialogue-local or a seeded default) lands in\n * whatever writable store you put last. Typical: `compose(cells(...game), new\n * MemoryVariableStorage())`.\n */\nexport function compose(...storages: readonly VariableStorage[]): VariableStorage {\n if (storages.length === 0) {\n throw new Error(\"dialogue: compose() needs at least one storage\");\n }\n const last = storages[storages.length - 1]!;\n return {\n get(name) {\n for (const s of storages) if (s.has(name)) return s.get(name);\n return undefined;\n },\n set(name, value) {\n for (const s of storages) {\n if (s.has(name)) {\n s.set(name, value);\n return;\n }\n }\n last.set(name, value);\n },\n has(name) {\n return storages.some((s) => s.has(name));\n },\n *entries() {\n const seen = new Set<string>();\n for (const s of storages) {\n for (const [name, value] of s.entries()) {\n if (!seen.has(name)) {\n seen.add(name);\n yield [name, value] as const;\n }\n }\n }\n },\n };\n}\n","/**\n * Expression evaluator. `Condition`s and `set` values are expression\n * *trees* — `literal | varRef | call | unary | binary | group` — evaluated\n * against an {@link EvalScope} (variable reads + installed functions). The\n * operator set mirrors Yarn Spinner so a future Yarn parser maps onto this IR\n * 1:1; the atomic `{ var, op, value }` comparison evaluates as the degenerate\n * one-level tree (lowered into a `binary` node in {@link evalCondition}).\n */\n\nimport { materialize } from \"./vars.js\";\nimport type {\n Condition,\n DialogueFunction,\n Expr,\n VariableStorage,\n VarMap,\n VarValue,\n} from \"./types.js\";\n\n/** What an expression evaluates against: per-name reads + function calls, plus\n * a materialized snapshot for the `(vars) => boolean` predicate escape hatch. */\nexport interface EvalScope {\n /** Read a variable (absent → `null`). */\n get(name: string): VarValue;\n /** Invoke an installed function with already-evaluated args. */\n call(fn: string, args: readonly VarValue[]): VarValue;\n /** Materialize the readable variables (for a predicate condition). */\n vars(): VarMap;\n}\n\n/** Build an {@link EvalScope} over a storage + the installed functions. */\nexport function createScope(\n storage: VariableStorage,\n functions: Readonly<Record<string, DialogueFunction>>,\n): EvalScope {\n return {\n get: (name) => storage.get(name) ?? null,\n call: (fn, args) => {\n const f = functions[fn];\n // play-time validation guarantees a function exists; guard anyway so a\n // hand-built runner fails loudly instead of throwing an opaque TypeError.\n if (!f) throw new Error(`dialogue: no function \"${fn}\" is installed`);\n return f(...args);\n },\n vars: () => materialize(storage),\n };\n}\n\n/** A condition (or none) holds against `scope`: an absent condition always holds;\n * otherwise it's evaluated via {@link evalCondition}. The one no-condition gate\n * shared by the runner and the session's preview walk. */\nexport function holds(condition: Condition | undefined, scope: EvalScope): boolean {\n return condition === undefined ? true : evalCondition(condition, scope);\n}\n\n/** A condition holds when its value is truthy. */\nexport function evalCondition(condition: Condition, scope: EvalScope): boolean {\n if (typeof condition === \"function\") return condition(scope.vars());\n if (typeof condition === \"string\") return truthy(scope.get(condition));\n if (isExpr(condition)) return truthy(evaluate(condition, scope));\n // Atomic { var, op, value } — the degenerate one-level tree. `truthy`/`falsy`\n // are presence checks; every other op lowers into a `binary` node so the\n // comparison runs through the single operator implementation (applyBinary).\n const { var: name, op, value } = condition;\n if (op === \"truthy\") return truthy(scope.get(name));\n if (op === \"falsy\") return !truthy(scope.get(name));\n return truthy(\n evaluate(\n {\n kind: \"binary\",\n op,\n left: { kind: \"varRef\", name },\n right: { kind: \"literal\", value: value as VarValue },\n },\n scope,\n ),\n );\n}\n\n/** Evaluate an expression tree to a single value. */\nexport function evaluate(expr: Expr, scope: EvalScope): VarValue {\n switch (expr.kind) {\n case \"literal\":\n return expr.value;\n case \"varRef\":\n return scope.get(expr.name);\n case \"group\":\n return evaluate(expr.expr, scope);\n case \"call\":\n return scope.call(\n expr.fn,\n (expr.args ?? []).map((a) => evaluate(a, scope)),\n );\n case \"unary\":\n return applyUnary(expr.op, evaluate(expr.operand, scope));\n case \"binary\": {\n // Short-circuit `and`/`or` (Yarn-faithful) via JS &&/|| so a guarded right\n // operand isn't evaluated when the left already decides — e.g.\n // `has_item(\"key\") and count(\"key\") > 0` won't call `count` (which may\n // throw) when the item is absent. `xor` and the rest need both operands.\n const { op } = expr;\n if (op === \"and\" || op === \"&&\") {\n return truthy(evaluate(expr.left, scope)) && truthy(evaluate(expr.right, scope));\n }\n if (op === \"or\" || op === \"||\") {\n return truthy(evaluate(expr.left, scope)) || truthy(evaluate(expr.right, scope));\n }\n return applyBinary(op, evaluate(expr.left, scope), evaluate(expr.right, scope));\n }\n }\n}\n\n/** True for an {@link Expr} node (discriminated by `kind`), so `Condition` can\n * tell a tree apart from the atomic `{ var, op, value }` shape. */\nexport function isExpr(value: unknown): value is Expr {\n return typeof value === \"object\" && value !== null && \"kind\" in value;\n}\n\n/** JS truthiness: `null` / `false` / `0` / `\"\"` are false. */\nexport function truthy(value: VarValue): boolean {\n return Boolean(value);\n}\n\nfunction applyUnary(op: \"not\" | \"!\" | \"-\", v: VarValue): VarValue {\n switch (op) {\n case \"not\":\n case \"!\":\n return !truthy(v);\n case \"-\":\n return -num(v);\n }\n}\n\nfunction applyBinary(op: string, l: VarValue, r: VarValue): VarValue {\n switch (op) {\n case \"==\":\n case \"eq\":\n case \"is\":\n return l === r;\n case \"!=\":\n case \"neq\":\n return l !== r;\n case \">\":\n case \"gt\":\n return num(l) > num(r);\n case \"<\":\n case \"lt\":\n return num(l) < num(r);\n case \">=\":\n case \"gte\":\n return num(l) >= num(r);\n case \"<=\":\n case \"lte\":\n return num(l) <= num(r);\n // `and`/`or` (and `&&`/`||`) are short-circuited in evaluate() and never\n // reach here; `xor` needs both operands, so it stays.\n case \"xor\":\n case \"^\":\n return truthy(l) !== truthy(r);\n case \"+\":\n // String concat when either side is a string; numeric otherwise.\n return typeof l === \"string\" || typeof r === \"string\"\n ? `${str(l)}${str(r)}`\n : num(l) + num(r);\n case \"-\":\n return num(l) - num(r);\n case \"*\":\n return num(l) * num(r);\n case \"/\":\n return num(l) / num(r);\n case \"%\":\n return num(l) % num(r);\n default:\n throw new Error(`dialogue: unknown binary operator \"${op}\"`);\n }\n}\n\nfunction num(v: unknown): number {\n return typeof v === \"number\" ? v : Number(v);\n}\n\nfunction str(v: VarValue): string {\n return v === null ? \"\" : String(v);\n}\n","/**\n * i18n seam. The runtime never reaches for a translation library directly —\n * it asks an {@link I18nAdapter}. Ship the identity adapter (literal text +\n * `{param}` interpolation) by default; wrap i18next / FormatJS / your own\n * string table in a ~10-line adapter to localise without touching the engine.\n */\n\nexport interface I18nAdapter {\n /** Current locale tag, e.g. \"en\", \"fr-CA\". Informational. */\n readonly locale: string;\n /**\n * Resolve a string. `key` is the translation key when the script provides\n * one; `fallback` is the authored literal text. `params` feed interpolation.\n * Implementations should return localised markup-bearing text.\n */\n t(key: string | undefined, fallback: string, params?: Readonly<Record<string, unknown>>): string;\n}\n\n/**\n * No-op adapter: returns the authored literal, interpolating `{name}` tokens\n * from `params`. This is what runs until a real i18n backend is plugged in.\n */\nexport class IdentityI18n implements I18nAdapter {\n constructor(readonly locale: string = \"en\") {}\n\n t(_key: string | undefined, fallback: string, params?: Readonly<Record<string, unknown>>): string {\n return params ? interpolate(fallback, params) : fallback;\n }\n}\n\n/** Matches an interpolation token `{name}` (word chars only). */\nconst TOKEN = /\\{(\\w+)\\}/g;\n\n/** Replace `{token}` with `params.token`; leaves unknown tokens untouched.\n * Own-property check only — `{constructor}`/`{toString}` must not stringify\n * inherited Object.prototype members. */\nexport function interpolate(text: string, params: Readonly<Record<string, unknown>>): string {\n return text.replace(TOKEN, (whole, name: string) =>\n Object.hasOwn(params, name) ? String(params[name]) : whole,\n );\n}\n\n/** Distinct `{token}` names in `text` — used by load-time validation to check\n * every interpolation target resolves to a declared var/external. */\nexport function tokensIn(text: string): string[] {\n const names = new Set<string>();\n for (const m of text.matchAll(TOKEN)) names.add(m[1]!);\n return [...names];\n}\n","/**\n * Two-stage validation for the storage model.\n *\n * • **Load-time** ({@link analyzeScript}, environment-free): walk the script\n * once, collecting the names it **reads** (conditions, `{token}`s, `set`\n * values), the names it **writes** (`set` targets), the **functions** it\n * calls, and the **command types** it fires. Type-check what's statically\n * knowable — an atomic numeric comparison against a declared non-number, a\n * literal `set` value whose type conflicts with the target's declared\n * default. Undeclared *references* are NOT rejected here: the installed\n * storage / functions may provide them, which is only known at play-time.\n * • **Play-time** ({@link validatePlay}): given the installed storage,\n * functions, and commands, throw on a *significant* mismatch — a read name\n * nothing provides, a called function with no implementation, a `set` target\n * that's a function (read-only), a command type with no handler/fallback, a\n * declared default whose type conflicts with the value the storage already\n * holds.\n *\n * Both throw hard — a dangling reference or an environment that can't satisfy the\n * script is a programming error, not a recoverable runtime condition.\n */\n\nimport { isExpr } from \"./expr.js\";\nimport { tokensIn } from \"./i18n.js\";\nimport type {\n BinaryOp,\n ChoiceStep,\n Command,\n CommandStep,\n Condition,\n DialogueFunction,\n DialogueScript,\n Expr,\n SayStep,\n VariableStorage,\n VarValue,\n} from \"./types.js\";\n\n/** A script reference is broken (load-time). */\nexport class DialogueScriptError extends Error {}\n/** The installed storage/functions/commands don't satisfy the script (play-time). */\nexport class DialoguePlayError extends Error {}\n\n/** Inferred type of a declared default; `\"null\"` (a `null` default) is untyped —\n * type checks are skipped for it. */\ntype ValueType = \"string\" | \"number\" | \"boolean\" | \"null\";\n\nconst NUMERIC_OPS: ReadonlySet<string> = new Set([\">\", \">=\", \"<\", \"<=\"]);\n/** Binary ops (symbol + word forms) whose operands must be numbers. `+` is\n * handled separately — it also accepts strings (concatenation). */\nconst NUMERIC_EXPR_OPS: ReadonlySet<string> = new Set([\n \">\", \"<\", \">=\", \"<=\", \"gt\", \"lt\", \"gte\", \"lte\", \"-\", \"*\", \"/\", \"%\",\n]);\n/** Built-in command types the runner handles — exempt from the \"must have a\n * handler\" check. Only `set` (runner-owned flow op); every other command type,\n * including a face change, needs a handler. (A mid-line face change is the\n * `[expression=…/]` reveal marker, not a command.) */\nconst BUILTIN_COMMANDS: ReadonlySet<string> = new Set([\"set\"]);\n\n/** What a binary operator requires of a literal operand, for the load-time type\n * walk. `null` = no constraint (equality / logical ops accept any type). */\nfunction operandRequirement(op: BinaryOp): \"number\" | \"numberOrString\" | null {\n if (op === \"+\") return \"numberOrString\"; // string concat OR numeric add\n return NUMERIC_EXPR_OPS.has(op) ? \"number\" : null;\n}\n\nexport interface ScriptAnalysis {\n /** Declared default types, keyed by name (drives seed-if-absent + typing). */\n readonly declaredTypes: ReadonlyMap<string, ValueType>;\n /** Names the script reads (conditions, tokens, `set` values, call args). */\n readonly readVars: ReadonlySet<string>;\n /** Names the script writes via `set` (need not be pre-provided — locals). */\n readonly setTargets: ReadonlySet<string>;\n /** Functions the script calls (`{ kind: \"call\" }`). */\n readonly calledFunctions: ReadonlySet<string>;\n /** Non-built-in command `type`s the script fires (for handler coverage). */\n readonly commandTypes: ReadonlySet<string>;\n}\n\nconst analysisCache = new WeakMap<DialogueScript, ScriptAnalysis>();\n\n/** Walk + type-check a script once (memoized on the frozen script object). */\nexport function analyzeScript(script: DialogueScript): ScriptAnalysis {\n const cached = analysisCache.get(script);\n if (cached) return cached;\n const analysis = computeAnalysis(script);\n analysisCache.set(script, analysis);\n return analysis;\n}\n\nfunction computeAnalysis(script: DialogueScript): ScriptAnalysis {\n const declaredTypes = new Map<string, ValueType>();\n for (const [name, value] of Object.entries(script.declare ?? {})) {\n declaredTypes.set(name, valueType(value));\n }\n\n const readVars = new Set<string>();\n const setTargets = new Set<string>();\n const calledFunctions = new Set<string>();\n const commandTypes = new Set<string>();\n\n // `where` is threaded so a wrong-type operand reports the same context the\n // atomic `{ var, op, value }` check uses.\n const collectExpr = (expr: Expr, where: string): void => {\n switch (expr.kind) {\n case \"literal\":\n return;\n case \"varRef\":\n readVars.add(expr.name);\n return;\n case \"call\":\n calledFunctions.add(expr.fn);\n for (const arg of expr.args ?? []) collectExpr(arg, where);\n return;\n case \"group\":\n collectExpr(expr.expr, where);\n return;\n case \"unary\":\n collectExpr(expr.operand, where);\n return;\n case \"binary\":\n collectExpr(expr.left, where);\n collectExpr(expr.right, where);\n checkBinaryOperands(expr, where);\n return;\n }\n };\n\n // Minimal parity with the atomic `{ var, op, value }` check, but on the tree:\n // a numeric/arithmetic operator with a literal operand of the wrong type, or\n // against a declared non-number var, is a script bug. Nothing deeper — no\n // single-type inference; the parser stays purely syntactic.\n const checkBinaryOperands = (\n expr: Extract<Expr, { kind: \"binary\" }>,\n where: string,\n ): void => {\n const req = operandRequirement(expr.op);\n if (!req) return;\n const expected = req === \"numberOrString\" ? \"a number or string\" : \"a number\";\n for (const operand of [expr.left, expr.right]) {\n if (operand.kind === \"literal\") {\n const t = valueType(operand.value);\n if (t === \"number\" || (req === \"numberOrString\" && t === \"string\")) continue;\n throw new DialogueScriptError(\n `${where}: operator \"${expr.op}\" expects ${expected}, got ${t}`,\n );\n }\n if (operand.kind === \"varRef\" && req === \"number\") {\n const t = declaredTypes.get(operand.name);\n if (t !== undefined && t !== \"number\" && t !== \"null\") {\n throw new DialogueScriptError(\n `${where}: operator \"${expr.op}\" needs a number; \"${operand.name}\" is ${t}`,\n );\n }\n }\n }\n };\n\n const checkTokens = (text: string | undefined): void => {\n if (!text) return;\n for (const token of tokensIn(text)) readVars.add(token);\n };\n\n const checkCondition = (condition: Condition | undefined, where: string): void => {\n if (condition === undefined || typeof condition === \"function\") return;\n if (typeof condition === \"string\") {\n readVars.add(condition);\n return;\n }\n if (isExpr(condition)) {\n collectExpr(condition, where);\n return;\n }\n // Atomic { var, op, value } — collect the operand and type-check numeric ops.\n readVars.add(condition.var);\n if (NUMERIC_OPS.has(condition.op)) {\n const t = declaredTypes.get(condition.var);\n if (t !== undefined && t !== \"number\" && t !== \"null\") {\n throw new DialogueScriptError(\n `${where}: operator \"${condition.op}\" needs a number; \"${condition.var}\" is ${t}`,\n );\n }\n if (typeof condition.value !== \"number\") {\n throw new DialogueScriptError(\n `${where}: operator \"${condition.op}\" compares against a number, ` +\n `got ${typeof condition.value}`,\n );\n }\n }\n };\n\n // A literal `set` value must match its target's declared default type (e.g.\n // `set gold = \"lots\"` against a numeric `gold`). `null` clears; an undeclared\n // target is a local with no type to clash against.\n const checkSetLiteralType = (target: string, value: unknown, where: string): void => {\n const declared = declaredTypes.get(target);\n if (\n declared !== undefined &&\n declared !== \"null\" &&\n value !== null &&\n typeof value !== declared\n ) {\n throw new DialogueScriptError(\n `${where}: set \"${target}\" expects ${declared}, got ${typeof value}`,\n );\n }\n };\n\n const checkCommands = (commands: readonly Command[] | undefined, where: string): void => {\n for (const cmd of commands ?? []) {\n if (cmd.type === \"set\") {\n const target = cmd[\"var\"];\n if (typeof target !== \"string\") {\n throw new DialogueScriptError(`${where}: set command has no string \"var\"`);\n }\n setTargets.add(target);\n const value = cmd[\"value\"];\n // A `set` with no `value` is malformed — it would write `undefined`,\n // poisoning the name (`has` true, `get` undefined) and defeating\n // seed-if-absent on the next play. Die here. (`value: null` is allowed —\n // an intentional clear.)\n if (value === undefined) {\n throw new DialogueScriptError(`${where}: set \"${target}\" has no value`);\n }\n if (isExpr(value)) {\n collectExpr(value, where);\n // A bare literal RHS (incl. a quoted-string literal from the pre-walk,\n // e.g. `set gold = \"'lots'\"`) is type-checked against the target like a\n // raw literal would be.\n if (value.kind === \"literal\") checkSetLiteralType(target, value.value, where);\n } else {\n // Raw literal value (number/boolean/null — strings were pre-walked to\n // an Expr): type-check against the target's declared default.\n checkSetLiteralType(target, value, where);\n }\n continue;\n }\n if (!BUILTIN_COMMANDS.has(cmd.type)) commandTypes.add(cmd.type);\n }\n };\n\n for (const speaker of Object.values(script.speakers ?? {})) {\n checkTokens(speaker.name);\n }\n\n for (const node of Object.values(script.nodes)) {\n const where = `node \"${node.id}\"`;\n for (const step of node.steps) {\n switch (step.kind) {\n case \"say\": {\n const s = step as SayStep;\n checkTokens(s.text);\n checkCommands(s.commands, `${where} say`);\n break;\n }\n case \"choice\": {\n const c = step as ChoiceStep;\n checkTokens(c.text);\n for (const opt of c.options) {\n checkTokens(opt.text);\n checkTokens(opt.disabledReason);\n checkCondition(opt.condition, `${where} choice option \"${opt.text}\"`);\n checkCommands(opt.commands, `${where} choice option \"${opt.text}\"`);\n }\n break;\n }\n case \"command\": {\n const cs = step as CommandStep;\n checkCommands(cs.commands, `${where} command`);\n checkCondition(cs.condition, `${where} command`);\n break;\n }\n default:\n break; // goto / end carry no references\n }\n }\n }\n\n return { declaredTypes, readVars, setTargets, calledFunctions, commandTypes };\n}\n\n/** The environment a `play()` installs, as far as validation cares. */\nexport interface PlayEnv {\n readonly storage: VariableStorage;\n readonly functions: Readonly<Record<string, DialogueFunction>>;\n readonly commands: Readonly<Record<string, unknown>>;\n readonly fallbackCommand: unknown;\n}\n\n/**\n * Play-time: the installed environment must satisfy the analyzed script. Runs\n * **before** seed-if-absent, so the declared-default/storage conflict check sees\n * the host-provided value (not the seed we're about to write).\n */\nexport function validatePlay(analysis: ScriptAnalysis, env: PlayEnv): void {\n // 1. A declared default must not conflict with a value the storage already\n // holds (the game-linked value wins, but a type clash is a script bug).\n for (const [name, type] of analysis.declaredTypes) {\n if (type === \"null\" || !env.storage.has(name)) continue;\n const current = env.storage.get(name);\n if (current !== undefined && current !== null && typeof current !== type) {\n throw new DialoguePlayError(\n `declared default for \"${name}\" is ${type} but storage already holds ${typeof current}`,\n );\n }\n }\n\n // 2. Every name the script reads must be provided — declared (it'll be seeded),\n // already in storage, OR written by a `set` somewhere in the script (a local\n // the script manages itself). The walk is flow-insensitive, so it can't (and\n // needn't) reason about read-before-write order: a read of an as-yet-\n // unset local is a script logic bug, not a missing binding — at runtime it\n // reads null. A typo (a name that is read but never declared/stored/written)\n // still dies here.\n for (const name of analysis.readVars) {\n if (\n !analysis.declaredTypes.has(name) &&\n !env.storage.has(name) &&\n !analysis.setTargets.has(name)\n ) {\n throw new DialoguePlayError(\n `script reads \"${name}\" but nothing provides it ` +\n `(no declared default, no storage value, no \\`set\\`; for an argument read use a function call)`,\n );\n }\n }\n\n // 3. Every function the script calls must be installed.\n for (const fn of analysis.calledFunctions) {\n if (!Object.hasOwn(env.functions, fn)) {\n throw new DialoguePlayError(\n `script calls function \"${fn}\" but no such function is installed`,\n );\n }\n }\n\n // 4. A `set` target must not be a function name (functions are read-only).\n for (const target of analysis.setTargets) {\n if (Object.hasOwn(env.functions, target)) {\n throw new DialoguePlayError(\n `set target \"${target}\" is a function (read-only); functions cannot be assigned`,\n );\n }\n }\n\n // 5. Every non-built-in command type must resolve to a handler or the fallback.\n if (env.fallbackCommand === undefined) {\n const unhandled = [...analysis.commandTypes].filter((t) => !Object.hasOwn(env.commands, t));\n if (unhandled.length > 0) {\n throw new DialoguePlayError(\n `no handler for command type(s): ${unhandled.join(\", \")} ` +\n `(add to commands, or set fallbackCommand)`,\n );\n }\n }\n}\n\nfunction valueType(value: VarValue): ValueType {\n if (value === null) return \"null\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"number\") return \"number\";\n return \"boolean\";\n}\n","/**\n * String → expression front-end. `parseExpr(\"str >= 8 and has_item('key')\")`\n * produces the same {@link Expr} tree a hand-authored JSON condition / `set`\n * value would — `literal | varRef | call | unary | binary | group`, no new node\n * kinds — so the evaluator (`expr.ts`) and the load-time walk (`validate.ts`)\n * are reused unchanged. This is purely a parser: it does no type-checking and\n * no name resolution (that stays in `validate.ts`), which keeps it reusable 1:1\n * for a future Yarn front-end.\n *\n * The operator set mirrors Yarn Spinner. v1 wires what the authoring examples\n * exercise: `or`/`||`, `and`/`&&`, `not`/`!`, the comparisons (`== != > < >= <=`\n * plus the word forms `eq neq gt lt gte lte is`), unary `-`, binary `+ -`, calls\n * `f(a, b)`, and parentheses. `xor`/`^` and `* / %` are reserved but not yet\n * wired (the IR + evaluator already accept them, so adding them later is purely\n * additive). Word-form operators normalise to their symbol equivalents in the IR\n * (`and` → `&&`, `eq` → `==`, `gt` → `>`, …), so `a and b` and `a && b` parse to\n * the identical tree.\n *\n * An identifier is `[A-Za-z_$]` followed by `[A-Za-z0-9_.$]` repeats — `.` and\n * `$` are included (so `$gold` and `quest.stage` each read as ONE name,\n * Yarn-forward) but `-` is excluded, so `hp-1` is `hp` minus `1` and an item id\n * like `'rusty-key'` must live in a quoted string literal.\n */\n\nimport { DialogueScriptError } from \"./validate.js\";\nimport type { BinaryOp, Expr, VarValue } from \"./types.js\";\n\n/**\n * A string expression failed to parse. Carries the 1-based source position.\n * Extends {@link DialogueScriptError} so the loaders' contract holds: a malformed\n * string condition / `set` value surfaced by `loadScript` / `loadYaml` is caught\n * by a single `catch (e instanceof DialogueScriptError)`, while `instanceof\n * DialogueExprError` (and `line` / `col`) still distinguish a parse error.\n */\nexport class DialogueExprError extends DialogueScriptError {\n readonly line: number;\n readonly col: number;\n constructor(message: string, line: number, col: number) {\n super(`${message} (at ${line}:${col})`);\n this.name = \"DialogueExprError\";\n this.line = line;\n this.col = col;\n }\n}\n\n/**\n * Parse a string into an {@link Expr} tree. Throws {@link DialogueExprError}\n * (with line/col) on an empty/blank source, a leftover trailing token, or a\n * dangling operator.\n */\nexport function parseExpr(src: string): Expr {\n const tokens = tokenize(src);\n return new Parser(tokens).parse();\n}\n\n// ── Tokenizer ───────────────────────────────────────────────────────────────\n\ntype TokenKind =\n // literals + names\n | \"number\"\n | \"string\"\n | \"ident\"\n | \"true\"\n | \"false\"\n | \"null\"\n // operators (canonical symbol forms; word forms map onto these)\n | \"&&\"\n | \"||\"\n | \"!\"\n | \"==\"\n | \"!=\"\n | \">\"\n | \"<\"\n | \">=\"\n | \"<=\"\n | \"+\"\n | \"-\"\n // reserved but unwired in v1 (kept out of the parser → using it errors)\n | \"xor\"\n // punctuation\n | \"(\"\n | \")\"\n | \",\"\n | \"eof\";\n\ninterface Token {\n readonly kind: TokenKind;\n /** Set for `number` (numeric value), `string`/`ident` (text). */\n readonly value?: VarValue;\n readonly line: number;\n readonly col: number;\n}\n\n/** Word-form keywords → the token kind they lex to. A variable literally named\n * one of these can't be referenced *bare in a string* — use the `{ var, op,\n * value }` form, `defineScript`, or rename. */\nconst KEYWORDS: Readonly<Record<string, TokenKind>> = {\n and: \"&&\",\n or: \"||\",\n not: \"!\",\n xor: \"xor\",\n is: \"==\",\n eq: \"==\",\n neq: \"!=\",\n gt: \">\",\n lt: \"<\",\n gte: \">=\",\n lte: \"<=\",\n true: \"true\",\n false: \"false\",\n null: \"null\",\n};\n\nconst isDigit = (c: string): boolean => c >= \"0\" && c <= \"9\";\nconst isIdentStart = (c: string): boolean =>\n (c >= \"A\" && c <= \"Z\") || (c >= \"a\" && c <= \"z\") || c === \"_\" || c === \"$\";\nconst isIdentPart = (c: string): boolean =>\n isIdentStart(c) || isDigit(c) || c === \".\";\n\nfunction tokenize(src: string): Token[] {\n const tokens: Token[] = [];\n let i = 0;\n let line = 1;\n let col = 1;\n\n const advance = (n = 1): void => {\n for (let k = 0; k < n; k++) {\n if (src[i] === \"\\n\") {\n line++;\n col = 1;\n } else {\n col++;\n }\n i++;\n }\n };\n\n while (i < src.length) {\n const c = src[i]!;\n\n // Whitespace (including newlines, for multi-line YAML block scalars).\n if (c === \" \" || c === \"\\t\" || c === \"\\n\" || c === \"\\r\") {\n advance();\n continue;\n }\n\n const startLine = line;\n const startCol = col;\n\n // Number: digits with an optional fractional part. A leading `-` is unary\n // minus, not part of the literal.\n if (isDigit(c)) {\n let text = \"\";\n while (i < src.length && isDigit(src[i]!)) {\n text += src[i];\n advance();\n }\n if (src[i] === \".\" && isDigit(src[i + 1] ?? \"\")) {\n text += \".\";\n advance();\n while (i < src.length && isDigit(src[i]!)) {\n text += src[i];\n advance();\n }\n }\n tokens.push({ kind: \"number\", value: Number(text), line: startLine, col: startCol });\n continue;\n }\n\n // String: single- or double-quoted, with `\\` escapes.\n if (c === \"'\" || c === '\"') {\n const quote = c;\n advance(); // opening quote\n let text = \"\";\n while (i < src.length && src[i] !== quote) {\n if (src[i] === \"\\\\\") {\n advance();\n if (i >= src.length) break;\n text += unescape(src[i]!);\n } else {\n text += src[i];\n }\n advance();\n }\n if (src[i] !== quote) {\n throw new DialogueExprError(\"unterminated string literal\", startLine, startCol);\n }\n advance(); // closing quote\n tokens.push({ kind: \"string\", value: text, line: startLine, col: startCol });\n continue;\n }\n\n // Identifier / keyword.\n if (isIdentStart(c)) {\n let text = \"\";\n while (i < src.length && isIdentPart(src[i]!)) {\n text += src[i];\n advance();\n }\n const keyword = KEYWORDS[text];\n if (keyword === undefined) {\n tokens.push({ kind: \"ident\", value: text, line: startLine, col: startCol });\n } else if (keyword === \"true\" || keyword === \"false\" || keyword === \"null\") {\n // Literal keywords carry a value; the operator keywords are bare.\n const value: VarValue = keyword === \"true\" ? true : keyword === \"false\" ? false : null;\n tokens.push({ kind: keyword, value, line: startLine, col: startCol });\n } else {\n tokens.push({ kind: keyword, line: startLine, col: startCol });\n }\n continue;\n }\n\n // Two-char operators.\n const two = src.slice(i, i + 2);\n if (two === \"&&\" || two === \"||\" || two === \"==\" || two === \"!=\" || two === \">=\" || two === \"<=\") {\n tokens.push({ kind: two, line: startLine, col: startCol });\n advance(2);\n continue;\n }\n\n // One-char operators / punctuation.\n if (c === \">\" || c === \"<\" || c === \"!\" || c === \"+\" || c === \"-\" || c === \"(\" || c === \")\" || c === \",\") {\n tokens.push({ kind: c, line: startLine, col: startCol });\n advance();\n continue;\n }\n\n throw new DialogueExprError(`unexpected character \"${c}\"`, startLine, startCol);\n }\n\n tokens.push({ kind: \"eof\", line, col });\n return tokens;\n}\n\nfunction unescape(c: string): string {\n switch (c) {\n case \"n\":\n return \"\\n\";\n case \"t\":\n return \"\\t\";\n case \"r\":\n return \"\\r\";\n default:\n return c; // \\\\ \\' \\\" and any other escaped char → the char itself\n }\n}\n\n// ── Parser (precedence climbing) ─────────────────────────────────────────────\n\n/** Left binding power per infix operator. Higher binds tighter. */\nconst INFIX_BP: Partial<Record<TokenKind, number>> = {\n \"||\": 1,\n \"&&\": 2,\n \"==\": 3,\n \"!=\": 3,\n \">\": 3,\n \"<\": 3,\n \">=\": 3,\n \"<=\": 3,\n \"+\": 4,\n \"-\": 4,\n};\n\nclass Parser {\n private pos = 0;\n constructor(private readonly tokens: Token[]) {}\n\n parse(): Expr {\n const expr = this.parseBinary(0);\n const t = this.peek();\n if (t.kind !== \"eof\") {\n throw new DialogueExprError(`unexpected trailing token \"${describe(t)}\"`, t.line, t.col);\n }\n return expr;\n }\n\n private parseBinary(minBp: number): Expr {\n let left = this.parseUnary();\n for (;;) {\n const t = this.peek();\n const bp = INFIX_BP[t.kind];\n if (bp === undefined || bp < minBp) break;\n this.next();\n const right = this.parseBinary(bp + 1); // left-associative\n // The INFIX_BP guard above admits only symbol kinds that are valid BinaryOps.\n left = { kind: \"binary\", op: t.kind as BinaryOp, left, right };\n }\n return left;\n }\n\n private parseUnary(): Expr {\n const t = this.peek();\n if (t.kind === \"!\" || t.kind === \"-\") {\n this.next();\n const operand = this.parseUnary();\n return { kind: \"unary\", op: t.kind === \"!\" ? \"!\" : \"-\", operand };\n }\n return this.parsePrimary();\n }\n\n private parsePrimary(): Expr {\n const t = this.peek();\n switch (t.kind) {\n case \"number\":\n case \"string\":\n this.next();\n return { kind: \"literal\", value: t.value as VarValue };\n case \"true\":\n case \"false\":\n case \"null\":\n this.next();\n return { kind: \"literal\", value: t.value as VarValue };\n case \"ident\": {\n this.next();\n const name = t.value as string;\n if (this.peek().kind === \"(\") {\n this.next(); // consume \"(\"\n const args = this.parseArgs();\n return { kind: \"call\", fn: name, args };\n }\n return { kind: \"varRef\", name };\n }\n case \"(\": {\n this.next();\n const inner = this.parseBinary(0);\n this.expect(\")\");\n return { kind: \"group\", expr: inner };\n }\n default:\n throw new DialogueExprError(`unexpected ${describe(t)}`, t.line, t.col);\n }\n }\n\n /** Parse a comma-separated argument list; the opening `(` is already consumed. */\n private parseArgs(): Expr[] {\n const args: Expr[] = [];\n if (this.peek().kind === \")\") {\n this.next();\n return args;\n }\n for (;;) {\n args.push(this.parseBinary(0));\n const t = this.peek();\n if (t.kind === \",\") {\n this.next();\n continue;\n }\n if (t.kind === \")\") {\n this.next();\n return args;\n }\n throw new DialogueExprError(`expected \",\" or \")\" in argument list, got ${describe(t)}`, t.line, t.col);\n }\n }\n\n private expect(kind: TokenKind): void {\n const t = this.peek();\n if (t.kind !== kind) {\n throw new DialogueExprError(`expected \"${kind}\", got ${describe(t)}`, t.line, t.col);\n }\n this.next();\n }\n\n private peek(): Token {\n return this.tokens[this.pos]!;\n }\n\n private next(): Token {\n return this.tokens[this.pos++]!;\n }\n}\n\n/** A human-readable token label for error messages. */\nfunction describe(t: Token): string {\n if (t.kind === \"eof\") return \"end of input\";\n if (t.kind === \"ident\") return `\"${String(t.value)}\"`;\n if (t.kind === \"string\") return `string \"${String(t.value)}\"`;\n if (t.kind === \"number\") return `number ${String(t.value)}`;\n return `\"${t.kind}\"`;\n}\n","/**\n * Canonical loader: validates + normalises a hand-authored / JSON\n * {@link DialogueScript} into a frozen, structurally-checked script the runner\n * can trust. Other \"common formats\" (a Yarn/ink-style screenplay parser) are\n * additional modules in this folder that emit the same canonical shape — the\n * runner only ever sees the canonical model.\n */\n\nimport { analyzeScript, DialogueScriptError } from \"../validate.js\";\nimport { parseExpr } from \"../expr-parse.js\";\nimport type {\n ChoiceOption,\n ChoiceStep,\n Command,\n CommandStep,\n Condition,\n DialogueScript,\n DialogueNode,\n Expr,\n NodeId,\n SayStep,\n Step,\n} from \"../types.js\";\n\nexport { DialogueScriptError };\n\nexport function loadScript(raw: DialogueScript): DialogueScript {\n if (!raw || typeof raw !== \"object\") {\n throw new DialogueScriptError(\"script must be an object\");\n }\n if (!raw.id) throw new DialogueScriptError(\"script.id is required\");\n if (!raw.nodes || typeof raw.nodes !== \"object\") {\n throw new DialogueScriptError(`script \"${raw.id}\" has no nodes`);\n }\n\n const nodeIds = Object.keys(raw.nodes);\n if (nodeIds.length === 0) {\n throw new DialogueScriptError(`script \"${raw.id}\" has no nodes`);\n }\n const start = raw.start ?? nodeIds[0]!;\n if (!raw.nodes[start]) {\n throw new DialogueScriptError(`start node \"${start}\" not found in \"${raw.id}\"`);\n }\n\n // Speakers are resolved by record KEY at runtime but presenters look actors\n // up by `SpeakerDef.id` — a mismatch silently splits nameplate vs actor\n // anchoring, so the two must agree (same rule as node key ↔ node.id).\n for (const [key, speaker] of Object.entries(raw.speakers ?? {})) {\n if (speaker.id !== key) {\n throw new DialogueScriptError(\n `speaker key \"${key}\" != speaker.id \"${speaker.id}\"`,\n );\n }\n }\n\n // Each node's id must match its key; every jump target must resolve.\n for (const [id, node] of Object.entries(raw.nodes)) {\n validateNode(raw, id, node);\n }\n\n // One pre-walk resolving every string condition and string `set` value to an\n // expression tree, so the frozen IR carries only `Expr`s and the runtime never\n // re-parses. A bare name (`\"gate\"`) becomes a `varRef` (a truthy read of that\n // variable); operator strings (`\"hp > 0 and not rude\"`) parse to comparison /\n // logical trees. Runs on every loader (JSON included). A malformed string\n // throws `DialogueExprError` with its position.\n const resolved = resolveExpressions(raw);\n\n const script = Object.freeze({ ...resolved, start });\n // Binding-free load-time walk: condition vars, set targets, and {token}s must\n // resolve to declared vars/externals; type-incompatible ops error. Memoized on\n // the frozen script, so the session's play-time re-check is free.\n analyzeScript(script);\n return script;\n}\n\nfunction validateNode(script: DialogueScript, id: string, node: DialogueNode): void {\n if (node.id !== id) {\n throw new DialogueScriptError(`node key \"${id}\" != node.id \"${node.id}\"`);\n }\n if (!Array.isArray(node.steps) || node.steps.length === 0) {\n throw new DialogueScriptError(`node \"${id}\" has no steps`);\n }\n for (const step of node.steps) validateStep(script, id, step);\n}\n\nfunction validateStep(script: DialogueScript, nodeId: string, step: Step): void {\n const targetExists = (t: string | undefined): void => {\n if (t !== undefined && !script.nodes[t]) {\n throw new DialogueScriptError(\n `node \"${nodeId}\": jump target \"${t}\" does not exist`,\n );\n }\n };\n // Node typos throw, so speaker typos must too — an unknown speaker would\n // otherwise silently render as a narrator line (and never find its actor).\n const speakerExists = (s: string | undefined): void => {\n if (s !== undefined && !script.speakers?.[s]) {\n throw new DialogueScriptError(\n `node \"${nodeId}\": speaker \"${s}\" is not in script.speakers`,\n );\n }\n };\n switch (step.kind) {\n case \"say\":\n if (typeof step.text !== \"string\") {\n throw new DialogueScriptError(`node \"${nodeId}\": say.text must be a string`);\n }\n speakerExists(step.speaker);\n break;\n case \"choice\":\n if (!Array.isArray(step.options) || step.options.length === 0) {\n throw new DialogueScriptError(`node \"${nodeId}\": choice has no options`);\n }\n speakerExists(step.speaker);\n for (const opt of step.options) targetExists(opt.target);\n break;\n case \"command\":\n targetExists(step.target);\n break;\n case \"goto\":\n // GotoStep types `target` as required, but hand-authored JSON can omit it\n // — and an undefined target silently ends the conversation at jump time.\n if (step.target === undefined) {\n throw new DialogueScriptError(`node \"${nodeId}\": goto has no target`);\n }\n targetExists(step.target);\n break;\n case \"end\":\n break;\n default:\n throw new DialogueScriptError(\n `node \"${nodeId}\": unknown step kind \"${(step as { kind: string }).kind}\"`,\n );\n }\n}\n\n// ── String → Expr pre-walk (unify) ──────────────────────────────────────────\n// Each rewrite helper returns a *new* value only when a string was parsed, else\n// `undefined` (so the caller keeps the original reference and skips cloning the\n// branch). String conditions/`set`-values are the only nodes rewritten; atomic\n// `{ var, op, value }`, predicate functions, and already-built `Expr`s pass\n// through untouched.\n\nfunction resolveExpressions(script: DialogueScript): DialogueScript {\n let nodesChanged = false;\n const nodes: Record<NodeId, DialogueNode> = {};\n for (const [id, node] of Object.entries(script.nodes)) {\n let stepsChanged = false;\n const steps = node.steps.map((step) => {\n const next = resolveStep(step);\n if (next !== step) stepsChanged = true;\n return next;\n });\n if (stepsChanged) {\n nodes[id] = { ...node, steps };\n nodesChanged = true;\n } else {\n nodes[id] = node;\n }\n }\n return nodesChanged ? { ...script, nodes } : script;\n}\n\nfunction resolveStep(step: Step): Step {\n switch (step.kind) {\n case \"say\":\n return resolveSay(step);\n case \"choice\":\n return resolveChoice(step);\n case \"command\":\n return resolveCommandStep(step);\n case \"goto\":\n case \"end\":\n return step;\n }\n}\n\nfunction resolveSay(step: SayStep): SayStep {\n const commands = rewriteCommands(step.commands);\n return commands ? { ...step, commands } : step;\n}\n\nfunction resolveCommandStep(step: CommandStep): CommandStep {\n const condition = rewriteCondition(step.condition);\n const commands = rewriteCommands(step.commands);\n if (!condition && !commands) return step;\n return {\n ...step,\n ...(condition ? { condition } : {}),\n ...(commands ? { commands } : {}),\n };\n}\n\nfunction resolveChoice(step: ChoiceStep): ChoiceStep {\n let changed = false;\n const options = step.options.map((opt) => {\n const next = rewriteOption(opt);\n if (next) {\n changed = true;\n return next;\n }\n return opt;\n });\n return changed ? { ...step, options } : step;\n}\n\nfunction rewriteOption(opt: ChoiceOption): ChoiceOption | undefined {\n const condition = rewriteCondition(opt.condition);\n const commands = rewriteCommands(opt.commands);\n if (!condition && !commands) return undefined;\n return {\n ...opt,\n ...(condition ? { condition } : {}),\n ...(commands ? { commands } : {}),\n };\n}\n\n/** A string condition → its `Expr` tree; anything else → `undefined` (no rewrite). */\nfunction rewriteCondition(condition: Condition | undefined): Expr | undefined {\n return typeof condition === \"string\" ? parseExpr(condition) : undefined;\n}\n\n/** Rewrite each `set` command whose value is a string into its `Expr` tree.\n * Returns a new array only when at least one command changed. */\nfunction rewriteCommands(\n commands: readonly Command[] | undefined,\n): readonly Command[] | undefined {\n if (!commands) return undefined;\n let changed = false;\n const out = commands.map((cmd) => {\n if (cmd.type === \"set\" && typeof cmd.value === \"string\") {\n changed = true;\n return { ...cmd, value: parseExpr(cmd.value) };\n }\n return cmd;\n });\n return changed ? out : undefined;\n}\n"],"mappings":";;;;;AAuBO,SAAS,YAAY,SAAkC;AAC5D,QAAM,MAAc,CAAC;AACrB,aAAW,CAAC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