@mark1russell7/vex 0.4.0 → 0.5.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/build/index.d.ts +34 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +291 -92
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/deps.ts +11 -12
- package/src/errors.ts +16 -2
- package/src/evaluate.ts +42 -7
- package/src/ir.ts +68 -42
- package/src/json.ts +11 -4
- package/src/sheet.ts +126 -33
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["spaces","keyMove","indexMove","offsetMove","otherMove","originMove","parentMove","cellRef"],"sources":["../src/result.ts","../src/errors.ts","../src/ir.ts","../src/space.ts","../src/domain.ts","../src/list.ts","../src/evaluate.ts","../src/deps.ts","../src/json.ts","../src/traversal.ts","../src/sheet.ts","../src/builder.ts"],"sourcesContent":["import type { Optional as FamilyOptional } from \"@mark1russell7/optional\";\nimport type { VexError } from \"./errors.ts\";\n\n/**\n * A value that is there, or not there. This is the public result of a Vex program. It is the Optional of the\n * family (`@mark1russell7/optional`), so render and Vex give and take the same values. The import is a type import\n * only: the build copies the type into the declarations, so the package has no runtime dependency.\n */\nexport type Optional<T> = FamilyOptional<T>;\n\n/** A value, or the error that tells why there is no value. The interpreter uses this type. */\nexport type Result<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly error: VexError };\n\nconst NONE: Optional<never> = Object.freeze({ tag: \"none\" });\n\n/** This function makes an `Optional` that holds `value`. */\nexport const some = <T>(value: T): Optional<T> => ({ tag: \"some\", value });\n\n/** This function gives the shared empty `Optional`. */\nexport const none = <T = never>(): Optional<T> => NONE;\n\n/** This function makes a successful `Result`. */\nexport const ok = <T>(value: T): Result<T> => ({ ok: true, value });\n\n/** This function makes a failed `Result`. */\nexport const fail = <T = never>(error: VexError): Result<T> => ({ ok: false, error });\n\n/** This function tells if an `Optional` holds a value. */\nexport const isSome = <T>(o: Optional<T>): o is { readonly tag: \"some\"; readonly value: T } => o.tag === \"some\";\n\n/** This function tells if an `Optional` is empty. */\nexport const isNone = <T>(o: Optional<T>): o is { readonly tag: \"none\" } => o.tag === \"none\";\n\n/** This function changes a `Result` into an `Optional`. The error is lost. */\nexport const toOptional = <T>(r: Result<T>): Optional<T> => (r.ok ? some(r.value) : none());\n\n/** This function gives the value of an `Optional`, or `fallback` if it is empty. */\nexport const getOr = <T, U>(o: Optional<T>, fallback: U): T | U => (o.tag === \"some\" ? o.value : fallback);\n\n/** This function applies `f` to the value of a `Result`. An error stays the same. */\nexport const mapResult = <T, U>(r: Result<T>, f: (value: T) => U): Result<U> => (r.ok ? ok(f(r.value)) : r);\n\n/** This function applies `f` to the value of a `Result`, and `f` gives a `Result`. An error stays the same. */\nexport const chainResult = <T, U>(r: Result<T>, f: (value: T) => Result<U>): Result<U> => (r.ok ? f(r.value) : r);\n","/**\n * The error codes of Vex. The names come from the spreadsheet error values, because a Vex program is a\n * spreadsheet formula over records.\n */\nexport type ErrorCode = \"#REF!\" | \"#N/A\" | \"#VALUE!\" | \"#NAME?\" | \"#NUM!\" | \"#CALC!\" | \"#ARGS\" | \"#CYCLE!\";\n\n/** The cause of an error, in more detail than the code. */\nexport type ErrorKind =\n | \"unknown-key\"\n | \"not-a-pair\"\n | \"out-of-bounds\"\n | \"no-offset\"\n | \"no-grid\"\n | \"no-tree\"\n | \"missing-field\"\n | \"empty\"\n | \"not-instance\"\n | \"kind-mismatch\"\n | \"unknown-op\"\n | \"unbound\"\n | \"not-finite\"\n | \"invalid-value\"\n | \"threw\"\n | \"undefined-result\"\n | \"args\"\n | \"cycle\"\n | \"bad-expression\";\n\nconst CODE_OF: Readonly<Record<ErrorKind, ErrorCode>> = {\n \"unknown-key\": \"#REF!\",\n \"not-a-pair\": \"#REF!\",\n \"out-of-bounds\": \"#REF!\",\n \"no-offset\": \"#REF!\",\n \"no-grid\": \"#REF!\",\n \"no-tree\": \"#REF!\",\n \"missing-field\": \"#N/A\",\n empty: \"#N/A\",\n \"not-instance\": \"#VALUE!\",\n \"kind-mismatch\": \"#VALUE!\",\n \"bad-expression\": \"#VALUE!\",\n \"unknown-op\": \"#NAME?\",\n unbound: \"#NAME?\",\n \"not-finite\": \"#NUM!\",\n \"invalid-value\": \"#NUM!\",\n threw: \"#CALC!\",\n \"undefined-result\": \"#CALC!\",\n args: \"#ARGS\",\n cycle: \"#CYCLE!\",\n};\n\n/** A Vex error. It is a value: a program can catch it with `ifError`. */\nexport interface VexError {\n /** The spreadsheet-style code, for example `#REF!`. */\n readonly code: ErrorCode;\n /** The cause in more detail. */\n readonly kind: ErrorKind;\n /** A sentence that tells what went wrong. */\n readonly message: string;\n /** The position of the failed node in the expression tree. The root is `[]`. */\n readonly path: readonly number[];\n /** The key where the evaluation started. */\n readonly origin?: string;\n /** The key where relative references read when the error occurred. */\n readonly focus?: string;\n /** The op name, for errors of an op. */\n readonly op?: string;\n /** The errors of the arguments, for the code `#ARGS`. */\n readonly causes?: readonly VexError[];\n /** The value that an op threw, for the kind `threw`. */\n readonly thrown?: unknown;\n}\n\n/** The details that a caller can give to `vexError`. */\nexport interface ErrorDetails {\n readonly path?: readonly number[];\n readonly origin?: string;\n readonly focus?: string;\n readonly op?: string;\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function gives the code of an error kind. */\nexport const codeOf = (kind: ErrorKind): ErrorCode => CODE_OF[kind];\n\n/** This function makes a `VexError`. */\nexport function vexError(kind: ErrorKind, message: string, details: ErrorDetails = {}): VexError {\n return {\n code: CODE_OF[kind],\n kind,\n message,\n path: details.path ?? [],\n ...(details.origin === undefined ? {} : { origin: details.origin }),\n ...(details.focus === undefined ? {} : { focus: details.focus }),\n ...(details.op === undefined ? {} : { op: details.op }),\n ...(details.causes === undefined ? {} : { causes: details.causes }),\n ...(details.thrown === undefined ? {} : { thrown: details.thrown }),\n };\n}\n\n/** This function gives a short text for an error, for example `#REF! unknown-key: there is no key \"Z\"`. */\nexport const formatError = (e: VexError): string => `${e.code} ${e.kind}: ${e.message}`;\n","/**\n * The expression IR of Vex. It is plain JSON data. Its first three kinds (`lit`, `ref`, `app`) have the same\n * shape as the expressions of `render`.\n */\n\n/** One move of an address. The moves of an address apply in order, from the focus of the evaluation. */\nexport type Move =\n | { readonly t: \"key\"; readonly key: string }\n | { readonly t: \"index\"; readonly i: number }\n | { readonly t: \"other\" }\n | { readonly t: \"offset\"; readonly d: readonly number[] }\n | { readonly t: \"origin\" }\n | { readonly t: \"parent\" };\n\n/** An address: a list of moves. The empty list is the focus. */\nexport type Addr = readonly Move[];\n\n/** An axis: the relation between a position and the targets that a body reads. */\nexport type Axis =\n | { readonly t: \"all\" }\n | { readonly t: \"others\" }\n | { readonly t: \"other\" }\n | { readonly t: \"neighbors\"; readonly n: 4 | 8 }\n | { readonly t: \"children\" }\n | { readonly t: \"ancestors\" }\n | { readonly t: \"descendants\" }\n | { readonly t: \"siblings\" }\n | { readonly t: \"where\"; readonly axis: Axis; readonly test: Expr };\n\n/** A Vex expression. */\nexport type Expr =\n | { readonly tag: \"lit\"; readonly value: unknown }\n | { readonly tag: \"ref\"; readonly path: readonly string[]; readonly at?: Addr }\n | { readonly tag: \"app\"; readonly op: string; readonly args: readonly Expr[] }\n | { readonly tag: \"let\"; readonly bind: Readonly<Record<string, Expr>>; readonly body: Expr }\n | { readonly tag: \"var\"; readonly name: string }\n | { readonly tag: \"rec\"; readonly fields: Readonly<Record<string, Expr>> }\n | { readonly tag: \"each\"; readonly axis: Axis; readonly body: Expr; readonly at?: Addr }\n | { readonly tag: \"ext\"; readonly kind: string; readonly data: unknown };\n\n/** The tag of an expression kind. */\nexport type ExprTag = Expr[\"tag\"];\n\n/** An expression of one kind. */\nexport type ExprOf<T extends ExprTag> = Extract<Expr, { readonly tag: T }>;\n\n// ---------------------------------------------------------------- constructors\n\n/** This function makes a literal. */\nexport const lit = (value: unknown): ExprOf<\"lit\"> => ({ tag: \"lit\", value });\n\n/** This function splits a dotted path, for example `\"pos.x\"`, into its segments. */\nexport const toPath = (path: string | readonly string[]): readonly string[] =>\n typeof path === \"string\" ? path.split(\".\").filter((s) => s.length > 0) : path;\n\n/** This function makes a reference to a field path. With `at`, the reference reads at that address. */\nexport function ref(path: string | readonly string[], at?: Addr): ExprOf<\"ref\"> {\n const segments = toPath(path);\n return at === undefined || at.length === 0 ? { tag: \"ref\", path: segments } : { tag: \"ref\", path: segments, at };\n}\n\n/** This function makes the application of an op to arguments. For a method op, the first argument is the receiver. */\nexport const app = (op: string, ...args: readonly Expr[]): ExprOf<\"app\"> => ({ tag: \"app\", op, args });\n\n/** This function binds names to expressions for the body. */\nexport const let_ = (bind: Readonly<Record<string, Expr>>, body: Expr): ExprOf<\"let\"> => ({ tag: \"let\", bind, body });\n\n/** This function makes a reference to a bound name. */\nexport const v = (name: string): ExprOf<\"var\"> => ({ tag: \"var\", name });\n\n/** This function makes a record from field expressions. */\nexport const rec = (fields: Readonly<Record<string, Expr>>): ExprOf<\"rec\"> => ({ tag: \"rec\", fields });\n\n/**\n * This function evaluates `body` once for each target of `axis`. The result is a list. With `at`, the axis finds its\n * targets from the key of that address, not from the focus.\n */\nexport function each(axis: Axis, body: Expr, at?: Addr): ExprOf<\"each\"> {\n return at === undefined || at.length === 0 ? { tag: \"each\", axis, body } : { tag: \"each\", axis, body, at };\n}\n\n/** This function makes an expression of an extension kind. */\nexport const ext = (kind: string, data: unknown): ExprOf<\"ext\"> => ({ tag: \"ext\", kind, data });\n\n// ---------------------------------------------------------------- moves and axes\n\n/** The move to an absolute key. */\nexport const key = (k: string): Move => ({ t: \"key\", key: k });\n/** The move to a position in the key order. */\nexport const index = (i: number): Move => ({ t: \"index\", i });\n/** The move to the other key of a space with two keys. */\nexport const other: Move = Object.freeze({ t: \"other\" });\n/** The relative move in an array (one number) or a grid (two numbers). */\nexport const offset = (...d: readonly number[]): Move => ({ t: \"offset\", d });\n/** The move back to the origin of the evaluation. */\nexport const origin: Move = Object.freeze({ t: \"origin\" });\n/** The move to the parent of the focus in a tree space. */\nexport const parent: Move = Object.freeze({ t: \"parent\" });\n\n/** The axes. */\nexport const axes = {\n /** Each key of the space. */\n all: Object.freeze({ t: \"all\" }) as Axis,\n /** Each key except the focus. */\n others: Object.freeze({ t: \"others\" }) as Axis,\n /** The other key of a pair. */\n other: Object.freeze({ t: \"other\" }) as Axis,\n /** The neighbors of the focus in a grid. */\n neighbors: (n: 4 | 8 = 8): Axis => ({ t: \"neighbors\", n }),\n /** The children of the focus in a tree, in key order. */\n children: Object.freeze({ t: \"children\" }) as Axis,\n /** The ancestors of the focus in a tree: the parent first, the root last. */\n ancestors: Object.freeze({ t: \"ancestors\" }) as Axis,\n /** The descendants of the focus in a tree, depth first, each parent before its children. */\n descendants: Object.freeze({ t: \"descendants\" }) as Axis,\n /** The other children of the parent of the focus. For a root, the other roots. */\n siblings: Object.freeze({ t: \"siblings\" }) as Axis,\n /** The targets of `axis` where `test` gives `true`. */\n where: (axis: Axis, test: Expr): Axis => ({ t: \"where\", axis, test }),\n} as const;\n\n// ---------------------------------------------------------------- validation\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\nconst isStringArray = (u: unknown): u is readonly string[] => Array.isArray(u) && u.every((s) => typeof s === \"string\");\n\n/** This function tells if a value is a valid move. */\nexport function isMove(u: unknown): u is Move {\n if (!isObject(u)) return false;\n switch (u[\"t\"]) {\n case \"key\":\n return typeof u[\"key\"] === \"string\";\n case \"index\":\n return Number.isInteger(u[\"i\"]);\n case \"offset\":\n return Array.isArray(u[\"d\"]) && u[\"d\"].every((n) => Number.isInteger(n));\n case \"other\":\n case \"origin\":\n case \"parent\":\n return true;\n default:\n return false;\n }\n}\n\n/** This function tells if a value is a valid axis. */\nexport function isAxis(u: unknown): u is Axis {\n if (!isObject(u)) return false;\n switch (u[\"t\"]) {\n case \"all\":\n case \"others\":\n case \"other\":\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n return true;\n case \"neighbors\":\n return u[\"n\"] === 4 || u[\"n\"] === 8;\n case \"where\":\n return isAxis(u[\"axis\"]) && isExpr(u[\"test\"]);\n default:\n return false;\n }\n}\n\nconst isExprRecord = (u: unknown): u is Readonly<Record<string, Expr>> =>\n isObject(u) && !Array.isArray(u) && Object.values(u).every((e) => isExpr(e));\n\n/** This function tells if a value is a valid expression. It checks the whole tree. */\nexport function isExpr(u: unknown): u is Expr {\n if (!isObject(u)) return false;\n switch (u[\"tag\"]) {\n case \"lit\":\n return \"value\" in u;\n case \"ref\":\n return isStringArray(u[\"path\"]) && (u[\"at\"] === undefined || (Array.isArray(u[\"at\"]) && u[\"at\"].every(isMove)));\n case \"app\":\n return typeof u[\"op\"] === \"string\" && Array.isArray(u[\"args\"]) && u[\"args\"].every((a) => isExpr(a));\n case \"let\":\n return isExprRecord(u[\"bind\"]) && isExpr(u[\"body\"]);\n case \"var\":\n return typeof u[\"name\"] === \"string\";\n case \"rec\":\n return isExprRecord(u[\"fields\"]);\n case \"each\":\n return isAxis(u[\"axis\"]) && isExpr(u[\"body\"]) && (u[\"at\"] === undefined || (Array.isArray(u[\"at\"]) && u[\"at\"].every(isMove)));\n case \"ext\":\n return typeof u[\"kind\"] === \"string\" && \"data\" in u;\n default:\n return false;\n }\n}\n\n/** This function gives the child expressions of an expression, in the order of their child index. */\nexport function children(e: Expr): readonly Expr[] {\n switch (e.tag) {\n case \"app\":\n return e.args;\n case \"let\":\n return [...Object.values(e.bind), e.body];\n case \"rec\":\n return Object.values(e.fields);\n case \"each\":\n return [e.body, ...whereTests(e.axis)];\n case \"lit\":\n case \"ref\":\n case \"var\":\n case \"ext\":\n return [];\n }\n}\n\nfunction whereTests(a: Axis): readonly Expr[] {\n return a.t === \"where\" ? [...whereTests(a.axis), a.test] : [];\n}\n","import { vexError } from \"./errors.ts\";\nimport type { Addr, Axis, Move } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** The kind of a space. The kind sets which moves and axes are valid. */\nexport type SpaceKind = \"record\" | \"array\" | \"grid\" | \"tree\";\n\n/**\n * A space: an immutable collection of records with keys. A Vex program evaluates at one key of a space.\n * Nothing changes a space after it is made.\n */\nexport interface Space<K extends string = string, O = unknown> {\n readonly kind: SpaceKind;\n /** The keys, in their order. */\n readonly keys: readonly K[];\n /** This function tells if the space has the key `k`. */\n has(k: string): k is K;\n /** This function gives the record at the key `k`, or `undefined`. */\n get(k: string): O | undefined;\n /** The position of each key, for array and grid spaces. An array key has one number, a grid key has two. */\n coords(k: string): readonly number[] | undefined;\n /** The key at a position, or `undefined`. */\n keyAt(coords: readonly number[]): K | undefined;\n /** The parent of the key `k` in a tree space, or `undefined` for a root. Other spaces do not have it. */\n parentOf?(k: string): K | undefined;\n /** The children of the key `k` in a tree space, in key order. Other spaces do not have it. */\n childrenOf?(k: string): readonly K[];\n}\n\n/** The key type of a grid space. */\nexport type GridKey = `${number},${number}`;\n\n/** The key type of an array space. */\nexport type ArrayKey = `${number}`;\n\nclass RecordSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"record\";\n readonly keys: readonly K[];\n readonly #records: ReadonlyMap<string, O>;\n\n constructor(records: Readonly<Record<K, O>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#records = new Map(entries);\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n}\n\nclass ArraySpace<O> implements Space<ArrayKey, O> {\n readonly kind: SpaceKind = \"array\";\n readonly keys: readonly ArrayKey[];\n readonly #items: ReadonlyMap<string, O>;\n\n constructor(items: readonly O[]) {\n const entries = items.map((item, i): [ArrayKey, O] => [`${i}`, item]);\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#items = new Map(entries);\n }\n\n has(k: string): k is ArrayKey {\n return this.#items.has(k);\n }\n get(k: string): O | undefined {\n return this.#items.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.has(k) ? [Number(k)] : undefined;\n }\n keyAt(coords: readonly number[]): ArrayKey | undefined {\n const k = String(coords[0]);\n return coords.length === 1 && this.has(k) ? k : undefined;\n }\n}\n\nclass GridSpace<O> implements Space<GridKey, O> {\n readonly kind: SpaceKind = \"grid\";\n readonly keys: readonly GridKey[];\n readonly #cells: ReadonlyMap<string, O>;\n readonly #coords: ReadonlyMap<string, readonly number[]>;\n\n constructor(rows: readonly (readonly O[])[]) {\n const entries = rows.flatMap((row, i) => row.map((cell, j): [GridKey, O, readonly number[]] => [`${i},${j}`, cell, Object.freeze([i, j])]));\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#cells = new Map(entries.map(([k, cell]) => [k, cell]));\n this.#coords = new Map(entries.map(([k, , c]) => [k, c]));\n }\n\n has(k: string): k is GridKey {\n return this.#cells.has(k);\n }\n get(k: string): O | undefined {\n return this.#cells.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.#coords.get(k);\n }\n keyAt(coords: readonly number[]): GridKey | undefined {\n // Each key has two coordinates, so a list with more or fewer coordinates gives no key.\n const k = coords.join(\",\");\n return this.has(k) ? k : undefined;\n }\n}\n\nclass TreeSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"tree\";\n readonly keys: readonly K[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #parents: ReadonlyMap<string, K>;\n readonly #children: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, parents: Readonly<Partial<Record<K, K | null>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#records = new Map(entries);\n const parentOf = new Map<string, K>();\n for (const [k, p] of Object.entries(parents) as [K, K | null | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the tree has no key \"${k}\", but the parents name it`);\n if (p === null || p === undefined) continue;\n if (!this.#records.has(p)) throw new TypeError(`the parent \"${p}\" of \"${k}\" is not a key of the tree`);\n parentOf.set(k, p);\n }\n // A parent chain that comes back to a key of the same walk is a cycle, not a tree. Each key is in one walk\n // only: a walk stops at a key that an earlier walk proved to reach a root. Thus the check is linear.\n const reachesRoot = new Set<string>();\n for (const k of this.keys) {\n const walk = new Set<string>();\n for (let p: string | undefined = k; p !== undefined && !reachesRoot.has(p); p = parentOf.get(p)) {\n if (walk.has(p)) throw new TypeError(`the parents of \"${k}\" make a cycle, so the space is not a tree`);\n walk.add(p);\n }\n for (const w of walk) reachesRoot.add(w);\n }\n this.#parents = parentOf;\n const children = new Map<string, K[]>(this.keys.map((k) => [k, []]));\n for (const k of this.keys) {\n const p = parentOf.get(k);\n // Each parent is a key, so its list exists, and the test of p only skips the roots.\n // Stryker disable next-line ConditionalExpression,OptionalChaining: a root has no list to push to\n if (p !== undefined) children.get(p)?.push(k);\n }\n this.#children = new Map([...children].map(([k, c]) => [k, Object.freeze(c)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n parentOf(k: string): K | undefined {\n return this.#parents.get(k);\n }\n childrenOf(k: string): readonly K[] {\n return this.#children.get(k) ?? [];\n }\n}\n\n/** The constructors of spaces. */\nexport const space = {\n /** This function makes a space from the entries of an object. The keys are the property names. */\n record<const R extends Readonly<Record<string, unknown>>>(records: R): Space<keyof R & string, R[keyof R]> {\n return new RecordSpace<keyof R & string, R[keyof R]>(records);\n },\n /** This function makes a space from an array. The keys are `\"0\"`, `\"1\"` and so on. */\n array<O>(items: readonly O[]): Space<ArrayKey, O> {\n return new ArraySpace(items);\n },\n /** This function makes a space from rows of cells. The key of a cell is `\"row,column\"`. */\n grid<O>(rows: readonly (readonly O[])[]): Space<GridKey, O> {\n return new GridSpace(rows);\n },\n /**\n * This function makes a tree space: the records by key, and the parent of each key. A key without a parent, or\n * with the parent `null`, is a root. A parent that is not a key, or a cycle of parents, throws a `TypeError`.\n */\n tree<const R extends Readonly<Record<string, unknown>>>(records: R, parents: Readonly<Partial<Record<keyof R & string, (keyof R & string) | null>>>): Space<keyof R & string, R[keyof R]> {\n return new TreeSpace<keyof R & string, R[keyof R]>(records, parents);\n },\n} as const;\n\n/** The position of an evaluation: the key where it started, and the key where relative references read. */\nexport interface Position {\n readonly origin: string;\n readonly focus: string;\n}\n\n/** This function applies one move to the focus. It gives the new focus, or a `#REF!` error. */\nexport function applyMove(s: Space, at: Position, m: Move): Result<string> {\n const refError = (kind: \"unknown-key\" | \"not-a-pair\" | \"out-of-bounds\" | \"no-offset\" | \"no-tree\", message: string): Result<string> =>\n fail(vexError(kind, message, { origin: at.origin, focus: at.focus }));\n switch (m.t) {\n case \"key\":\n return s.has(m.key) ? ok(m.key) : refError(\"unknown-key\", `the space has no key \"${m.key}\"`);\n case \"index\": {\n const k = s.keys[m.i];\n return k !== undefined ? ok(k) : refError(\"out-of-bounds\", `the space has no key at index ${m.i}`);\n }\n case \"other\": {\n if (s.keys.length !== 2) return refError(\"not-a-pair\", `\"other\" needs a space with 2 keys, but this space has ${s.keys.length}`);\n const [a, b] = s.keys;\n // A pair has two keys, so `a` and `b` are defined.\n /* v8 ignore next -- @preserve */\n return ok(at.focus === a ? (b ?? at.focus) : (a ?? at.focus));\n }\n case \"offset\": {\n // In a tree space, an offset with one number moves among the siblings in key order. The roots are siblings.\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf !== undefined && childrenOf !== undefined && m.d.length === 1) {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n const i = group.indexOf(at.focus);\n const k = i < 0 ? undefined : group[i + (m.d[0] ?? 0)];\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside its siblings`) : ok(k);\n }\n const c = s.coords(at.focus);\n if (c === undefined || c.length !== m.d.length) {\n return refError(\"no-offset\", `an offset of length ${m.d.length} is not valid in a ${s.kind} space`);\n }\n // The lengths are equal, so each index of `c` is also an index of `m.d`.\n /* v8 ignore next -- @preserve */\n const target = c.map((x, i) => x + (m.d[i] ?? 0));\n const k = s.keyAt(target);\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside the space`) : ok(k);\n }\n case \"origin\":\n return ok(at.origin);\n case \"parent\": {\n if (s.parentOf === undefined) return refError(\"no-tree\", `\"parent\" needs a tree space, but this space is a ${s.kind}`);\n const p = s.parentOf(at.focus);\n return p === undefined ? refError(\"out-of-bounds\", `the key \"${at.focus}\" is a root, so it has no parent`) : ok(p);\n }\n }\n}\n\n/** This function applies the moves of an address in order. It gives the key where the address points. */\nexport function resolveAddr(s: Space, at: Position, addr: Addr | undefined): Result<string> {\n let focus = at.focus;\n for (const m of addr ?? []) {\n const r = applyMove(s, { origin: at.origin, focus }, m);\n if (!r.ok) return r;\n focus = r.value;\n }\n return ok(focus);\n}\n\nconst NEIGHBORS_4: readonly (readonly [number, number])[] = [[-1, 0], [0, -1], [0, 1], [1, 0]];\nconst NEIGHBORS_8: readonly (readonly [number, number])[] = [\n [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1],\n];\n\n/** The axes of a tree space. */\ntype TreeAxis = \"children\" | \"ancestors\" | \"descendants\" | \"siblings\";\n\nfunction treeTargets(s: Space, at: Position, t: TreeAxis): Result<readonly string[]> {\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf === undefined || childrenOf === undefined) {\n return fail(vexError(\"no-tree\", `\"${t}\" needs a tree space, but this space is a ${s.kind}`, at));\n }\n switch (t) {\n case \"children\":\n return ok(childrenOf(at.focus));\n case \"ancestors\": {\n const out: string[] = [];\n for (let p = parentOf(at.focus); p !== undefined; p = parentOf(p)) out.push(p);\n return ok(out);\n }\n case \"descendants\": {\n // A depth-first walk with a stack, so a deep tree does not need a deep call stack.\n const out: string[] = [];\n const stack = childrenOf(at.focus).toReversed();\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n stack.push(...childrenOf(k).toReversed());\n }\n return ok(out);\n }\n case \"siblings\": {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n return ok(group.filter((k) => k !== at.focus));\n }\n }\n}\n\n/**\n * This function gives the targets of a base axis at a focus. It does not handle `where`, because the\n * interpreter must evaluate the test.\n */\nexport function axisTargets(s: Space, at: Position, a: Exclude<Axis, { readonly t: \"where\" }>): Result<readonly string[]> {\n switch (a.t) {\n case \"all\":\n return ok(s.keys);\n case \"others\":\n return ok(s.keys.filter((k) => k !== at.focus));\n case \"other\": {\n const r = applyMove(s, at, { t: \"other\" });\n return r.ok ? ok([r.value]) : r;\n }\n case \"neighbors\": {\n if (s.kind !== \"grid\") return fail(vexError(\"no-grid\", `\"neighbors\" needs a grid space, but this space is a ${s.kind}`, at));\n const deltas = a.n === 4 ? NEIGHBORS_4 : NEIGHBORS_8;\n return ok(\n deltas.flatMap((d) => {\n const r = applyMove(s, at, { t: \"offset\", d });\n return r.ok ? [r.value] : [];\n }),\n );\n }\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n return treeTargets(s, at, a.t);\n }\n}\n","/**\n * Domains. A domain tells which values belong to it and which ops it has. The domain object owns this data.\n * Vex does not write to the prototypes of domain classes, and an import has no side effects.\n */\n\n/** An algebraic law that an op claims. `@mark1russell7/vex-testkit` checks each claim with property tests. */\nexport type Law = \"commutative\" | \"associative\" | \"idempotent\";\n\n/** The kind of a parameter. The interpreter checks the arguments of an op that declares its parameters. */\nexport type ParamKind = \"domain\" | \"number\" | \"boolean\" | \"string\" | \"any\";\n\n/** The description of one op of a domain. */\nexport interface OpSpec<D = never> {\n /**\n * The implementation, for an op that is not a method of the value (static-land style). The first argument\n * is the receiver. Without `fn`, the interpreter calls the method of the receiver with the same name.\n */\n readonly fn?: (self: D, ...args: never[]) => unknown;\n /** The laws that the op claims. */\n readonly laws?: readonly Law[];\n /** The identity element of the op, for reductions over an empty list. */\n readonly identity?: () => D;\n /** Scalar lifting: `true` lifts each number argument with `fromScalar`. An array sets it for each argument. */\n readonly liftScalar?: boolean | readonly boolean[];\n /** The kinds of the parameters after the receiver. When set, the interpreter checks the arguments. */\n readonly params?: readonly ParamKind[];\n}\n\n/** The type of an op that lifts number arguments. Use it to type the ops of a domain under `isolatedDeclarations`. */\nexport type LiftedOp<D> = OpSpec<D> & { readonly liftScalar: true };\n\n/** The type of an op with an implementation function `F`. */\nexport type FnOp<D, F extends (self: D, ...args: never[]) => unknown> = OpSpec<D> & { readonly fn: F };\n\n/**\n * The type of an op table: each name in `Names` is an op, and each name in `Lifted` lifts number arguments.\n * Use it to type the ops of a domain under `isolatedDeclarations`.\n */\nexport type OpTable<D, Names extends string, Lifted extends string = never> = {\n readonly [N in Names]: N extends Lifted ? LiftedOp<D> : OpSpec<D>;\n};\n\n/** The description of a domain, as a caller gives it to `defineDomain`. */\nexport interface DomainSpec<Name extends string, D, Ops extends Readonly<Record<string, OpSpec<D>>>> {\n /** The name of the domain. */\n readonly name: Name;\n /** The runtime test for the values of the domain. It must not give false positives. */\n readonly is: (u: unknown) => u is D;\n /** The ops of the domain, with their metadata. */\n readonly ops: Ops;\n /** With `\"all\"`, each method of a value is an op, also without an entry in `ops`. The default is `\"declared\"`. */\n readonly methods?: \"declared\" | \"all\";\n /** The scalar lift: it makes a domain value from a number. */\n readonly fromScalar?: (n: number) => D;\n /** A check of the values that ops give. A value that fails the check gives the error `#NUM!`. */\n readonly valid?: (d: D) => boolean;\n /** A short text for a value, for traces and the site. */\n readonly show?: (d: D) => string;\n /** The JSON form of a value, for literals in serialized programs. */\n readonly encode?: (d: D) => unknown;\n /** The value of a JSON form that `encode` made. */\n readonly decode?: (json: unknown) => D;\n}\n\n/** A domain. Make one with `defineDomain`. */\nexport interface Domain<Name extends string = string, D = unknown, Ops extends Readonly<Record<string, OpSpec<D>>> = Readonly<Record<string, OpSpec<D>>>>\n extends DomainSpec<Name, D, Ops> {\n readonly kind: \"vex.domain\";\n}\n\n/** A domain with any value type. The interpreter uses this type. */\n// oxlint-disable-next-line typescript/no-explicit-any -- a list of domains with different value types needs `any`: `fn` is contravariant in the value type.\nexport type AnyDomain = Domain<string, any, Readonly<Record<string, OpSpec<any>>>>;\n\n/** This function makes a domain. The result is frozen. */\nexport function defineDomain<const Name extends string, D, const Ops extends Readonly<Record<string, OpSpec<D>>>>(\n spec: DomainSpec<Name, D, Ops>,\n): Domain<Name, D, Ops> {\n return Object.freeze({ ...spec, kind: \"vex.domain\" as const });\n}\n\nconst FORBIDDEN = new Set([\"constructor\", \"__proto__\", \"prototype\", \"__defineGetter__\", \"__defineSetter__\", \"__lookupGetter__\", \"__lookupSetter__\"]);\n\n/** This function tells if a name can be an op name. */\nexport const isOpName = (name: string): boolean => name.length > 0 && !FORBIDDEN.has(name);\n\n/**\n * This function finds a method on a value: an own function property, or a function on the prototype chain.\n * It stops at `Object.prototype` and `Function.prototype`, so inherited members (for example `toString`) are not ops.\n */\nexport function findMethod(self: unknown, name: string): ((...args: unknown[]) => unknown) | undefined {\n if (!isOpName(name)) return undefined;\n // A primitive has no own methods. The loop below stops at null, so null needs no test here.\n if (typeof self !== \"object\" && typeof self !== \"function\") return undefined;\n let o: object | null = self;\n while (o !== null && o !== Object.prototype && o !== Function.prototype) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) {\n return typeof d.value === \"function\" ? (d.value as (...args: unknown[]) => unknown) : undefined;\n }\n o = Object.getPrototypeOf(o) as object | null;\n }\n return undefined;\n}\n\n/** An op that the interpreter found for a receiver. */\nexport interface ResolvedOp {\n readonly domain: AnyDomain;\n readonly spec: OpSpec<unknown>;\n readonly call: (args: readonly unknown[]) => unknown;\n}\n\nconst EMPTY_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** This function finds the op `name` for `self` in one domain. It gives `undefined` if the domain does not have it. */\nexport function resolveOp(domain: AnyDomain, self: unknown, name: string): ResolvedOp | undefined {\n if (!isOpName(name)) return undefined;\n const declared = Object.hasOwn(domain.ops, name) ? (domain.ops[name] as OpSpec<unknown>) : undefined;\n if (declared?.fn !== undefined) {\n const fn = declared.fn as (self: unknown, ...args: unknown[]) => unknown;\n return { domain, spec: declared, call: (args) => fn(self, ...args) };\n }\n if (declared === undefined && domain.methods !== \"all\") return undefined;\n const method = findMethod(self, name);\n if (method === undefined) return undefined;\n return { domain, spec: declared ?? EMPTY_SPEC, call: (args) => method.apply(self, [...args]) };\n}\n\n/** This function gives the domain of a value: the first domain whose `is` accepts it. */\nexport function domainOf(domains: readonly AnyDomain[], value: unknown): AnyDomain | undefined {\n return domains.find((d) => d.is(value));\n}\n\n/** This function tells if the `liftScalar` setting lifts the argument at `index`. */\nexport const liftsAt = (lift: OpSpec<unknown>[\"liftScalar\"], index: number): boolean =>\n lift === true || (Array.isArray(lift) && lift[index] === true);\n","import type { Result } from \"./result.ts\";\n\n/** One item of a list: the key of the target and the result of the body there. */\nexport interface ListItem<T = unknown> {\n readonly key: string;\n readonly result: Result<T>;\n}\n\n/** The value of an `each` expression: one item for each target of the axis. */\nexport interface VexList<T = unknown> {\n readonly kind: \"vex.list\";\n readonly items: readonly ListItem<T>[];\n}\n\n/** This function makes a list. */\nexport const vexList = <T>(items: readonly ListItem<T>[]): VexList<T> => Object.freeze({ kind: \"vex.list\", items: Object.freeze([...items]) });\n\n/** This function tells if a value is a Vex list. */\nexport const isVexList = (u: unknown): u is VexList =>\n (u as { kind?: unknown } | null | undefined)?.kind === \"vex.list\" && Array.isArray((u as { items?: unknown }).items);\n\n/** The name of a core list op. */\nexport type ListOp = \"count\" | \"sum\" | \"min\" | \"max\" | \"mean\" | \"any\" | \"all\" | \"none\" | \"values\" | \"keys\" | \"reduce\" | \"first\" | \"errors\";\n\n/** The names of the core list ops. They apply when the first argument is a list. */\nexport const LIST_OPS: ReadonlySet<string> = new Set<ListOp>([\"count\", \"sum\", \"min\", \"max\", \"mean\", \"any\", \"all\", \"none\", \"values\", \"keys\", \"reduce\", \"first\", \"errors\"]);\n\n/** This function tells if a name is the name of a core list op. */\nexport const isListOp = (op: string): op is ListOp => LIST_OPS.has(op);\n\n/** The options of a list op. */\nexport interface ListOptions {\n /** With `true`, any error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n","import { liftsAt, resolveOp, type AnyDomain, type ParamKind, type ResolvedOp } from \"./domain.ts\";\nimport { formatError, vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { children, type Axis, type Expr, type ExprOf, type Move } from \"./ir.ts\";\nimport { isListOp, isVexList, vexList, type ListItem, type ListOp, type ListOptions, type VexList } from \"./list.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { axisTargets, resolveAddr, type Position, type Space } from \"./space.ts\";\nimport type { Read, Trace, TraceEvent, TraceSink } from \"./trace.ts\";\n\n/** A free function op. The interpreter gives it the values of all arguments. */\nexport type FreeFn = (...args: readonly unknown[]) => unknown;\n\n/** The context of an extension handler. */\nexport interface ExtContext {\n readonly space: Space;\n readonly position: Position;\n readonly path: readonly number[];\n}\n\n/** The handler of an extension expression kind. */\nexport type ExtHandler = (data: unknown, ctx: ExtContext) => Result<unknown>;\n\n/** The options of an evaluation. */\nexport interface EvalOptions {\n /** The space that the program reads. */\n readonly space: Space;\n /** The key where the evaluation starts. Relative references read here. */\n readonly origin: string;\n /** The domains. The interpreter finds the op of a value in the first domain that accepts the value. */\n readonly domains?: readonly AnyDomain[];\n /** Free function ops, for ops that are not domain ops. */\n readonly fns?: Readonly<Record<string, FreeFn>>;\n /** The handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n /** Variables that the program can read with `v(name)`. */\n readonly vars?: Readonly<Record<string, unknown>>;\n /** A receiver of trace events. */\n readonly trace?: TraceSink;\n}\n\ntype Env = ReadonlyMap<string, Result<unknown>>;\n\ninterface Frame {\n readonly pos: Position;\n readonly env: Env;\n}\n\n/** The name of a special form. */\nexport type SpecialForm = \"if\" | \"and\" | \"or\" | \"ifError\";\n\n/** The names of the special forms. Their arguments are not evaluated before the call. */\nexport const SPECIAL_FORMS: ReadonlySet<string> = new Set<SpecialForm>([\"if\", \"and\", \"or\", \"ifError\"]);\n\nconst isSpecialForm = (op: string): op is SpecialForm => SPECIAL_FORMS.has(op);\n\n/** The options that a compiled program keeps: the domains, the free functions and the extension handlers. */\nexport type CompileOptions = Pick<EvalOptions, \"domains\" | \"fns\" | \"extensions\">;\n\n/** The options of one run of a compiled program. */\nexport type RunOptions = Pick<EvalOptions, \"space\" | \"origin\" | \"vars\" | \"trace\">;\n\n/**\n * A compiled program: the expression as a tree of functions. A program evaluates many times at different origins,\n * and over different spaces, without a new walk of the expression.\n */\nexport interface Program {\n /** The expression of the program. */\n readonly expr: Expr;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: RunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, with a trace of each node. */\n explain(opts: Omit<RunOptions, \"trace\">): Trace;\n}\n\n/**\n * This function compiles an expression. The result gives the same results and the same traces as `evaluate`,\n * because `evaluate` uses it too.\n */\nexport function compile(expr: Expr, opts: CompileOptions = {}): Program {\n const root = new Compiler(opts).node(expr, []);\n const run = (r: RunOptions): Result<unknown> => {\n const { space, origin } = r;\n if (!space.has(origin)) return fail(vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin }));\n const env = new Map<string, Result<unknown>>(Object.entries(r.vars ?? {}).map(([k, val]) => [k, ok(val)]));\n try {\n return root({ pos: { origin, focus: origin }, env }, { space, trace: r.trace });\n } catch (thrown) {\n // A defect in an extension handler or in a test of the interpreter itself. Totality still holds.\n return fail(vexError(\"threw\", \"the evaluation threw an exception\", { origin, focus: origin, thrown }));\n }\n };\n return {\n expr,\n run,\n explain: (r) => {\n const sink: TraceSink = { events: [] };\n const result = run({ ...r, trace: sink });\n return { events: sink.events, result };\n },\n };\n}\n\n// The cache of compiled programs: one entry for each expression object, for the last options.\nconst CACHE = new WeakMap<Expr, { readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly program: Program }>();\n\nfunction compiled(expr: Expr, opts: CompileOptions): Program {\n const hit = CACHE.get(expr);\n // Without the cache, each evaluation compiles again: the result is the same, so a mutant that removes a hit is\n // equivalent. A false hit changes results, and the tests find it.\n // Stryker disable next-line ConditionalExpression: a missed hit only compiles again\n if (hit !== undefined && hit.domains === opts.domains && hit.fns === opts.fns && hit.extensions === opts.extensions) return hit.program;\n const program = compile(expr, opts);\n CACHE.set(expr, { domains: opts.domains, fns: opts.fns, extensions: opts.extensions, program });\n return program;\n}\n\n/** This function evaluates an expression at the origin of a space. It does not throw. */\nexport function evaluate(expr: Expr, opts: EvalOptions): Result<unknown> {\n return compiled(expr, opts).run(opts);\n}\n\n/** This function evaluates an expression and records a trace of each node. */\nexport function explain(expr: Expr, opts: Omit<EvalOptions, \"trace\">): Trace {\n return compiled(expr, opts).explain(opts);\n}\n\n/** The state of one run that the nodes read: the space and the trace sink. */\ninterface Ctx {\n readonly space: Space;\n readonly trace: TraceSink | undefined;\n}\n\n/** A compiled node: it evaluates in a frame of a run. */\ntype Node = (f: Frame, c: Ctx) => Result<unknown>;\n\n/** The static facts of a node for its trace events. */\ninterface Info {\n readonly path: readonly number[];\n readonly tag: Expr[\"tag\"];\n readonly label: string;\n}\n\nclass Compiler {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, FreeFn>> | undefined;\n readonly #extensions: Readonly<Record<string, ExtHandler>> | undefined;\n\n constructor(opts: CompileOptions) {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#extensions = opts.extensions;\n }\n\n #err(kind: ErrorKind, message: string, f: Frame, path: readonly number[], extra: { op?: string; causes?: readonly VexError[]; thrown?: unknown } = {}): Result<never> {\n return fail(vexError(kind, message, { path, origin: f.pos.origin, focus: f.pos.focus, ...extra }));\n }\n\n #emit(c: Ctx, info: Info, f: Frame, result: Result<unknown>, reads?: readonly Read[]): Result<unknown> {\n if (c.trace !== undefined) {\n const event: TraceEvent = {\n path: info.path,\n tag: info.tag,\n label: info.label,\n origin: f.pos.origin,\n focus: f.pos.focus,\n ...(reads === undefined ? {} : { reads }),\n result,\n };\n c.trace.events.push(event);\n }\n return result;\n }\n\n /** This method compiles the expression `e` at the position `path` of the tree. */\n node(e: Expr, path: readonly number[]): Node {\n const info: Info = { path, tag: e.tag, label: labelOf(e) };\n switch (e.tag) {\n case \"lit\": {\n const r = ok(e.value);\n return (f, c) => this.#emit(c, info, f, r);\n }\n case \"ref\":\n return this.#ref(e, info);\n case \"var\": {\n const name = e.name;\n return (f, c) => this.#emit(c, info, f, f.env.get(name) ?? this.#err(\"unbound\", `the name \"${name}\" has no binding`, f, path));\n }\n case \"let\": {\n const binds = Object.entries(e.bind).map(([name, be], i): readonly [string, Node] => [name, this.node(be, [...path, i])]);\n const body = this.node(e.body, [...path, binds.length]);\n return (f, c) => {\n const env = new Map(f.env);\n for (const [name, n] of binds) env.set(name, n(f, c));\n return this.#emit(c, info, f, body({ pos: f.pos, env }, c));\n };\n }\n case \"rec\": {\n const names = Object.keys(e.fields);\n const fields = this.#nodes(Object.values(e.fields), path);\n return (f, c) => {\n const values = this.#all(fields, f, c, path, \"fields\");\n if (!values.ok) return this.#emit(c, info, f, values);\n const out: Record<string, unknown> = {};\n names.forEach((n, i) => {\n out[n] = values.value[i];\n });\n return this.#emit(c, info, f, ok(Object.freeze(out)));\n };\n }\n case \"app\":\n return isSpecialForm(e.op) ? this.#special(e.op, this.#nodes(e.args, path), info) : this.#app(e.op, this.#nodes(e.args, path), info);\n case \"each\":\n return this.#each(e, info);\n case \"ext\": {\n const extensions = this.#extensions ?? {};\n const handler = Object.hasOwn(extensions, e.kind) ? extensions[e.kind] : undefined;\n const { kind, data } = e;\n if (handler === undefined) return (f, c) => this.#emit(c, info, f, this.#err(\"unknown-op\", `no handler for the extension kind \"${kind}\"`, f, path));\n return (f, c) =>\n this.#emit(c, info, f, this.#locate(this.#guard(() => handler(data, { space: c.space, position: f.pos, path }), f, path, kind), f, path));\n }\n }\n }\n\n #nodes(es: readonly Expr[], path: readonly number[]): readonly Node[] {\n return es.map((x, i) => this.node(x, [...path, i]));\n }\n\n /** This method gives an error of a handler the path, the origin and the focus of its node, if it has no origin. */\n #locate(r: Result<unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n if (r.ok || r.error.origin !== undefined) return r;\n return fail({ ...r.error, path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n #guard(run: () => Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n try {\n return run();\n } catch (thrown) {\n return this.#err(\"threw\", `\"${op}\" threw an exception`, f, path, { op, thrown });\n }\n }\n\n #ref(e: ExprOf<\"ref\">, info: Info): Node {\n const { path } = info;\n const segs = e.path;\n const at = e.at ?? [];\n const label = segs.join(\".\");\n const steps = segs.map((seg, i) => ({ seg, where: segs.slice(0, i + 1).join(\".\"), valid: isFieldName(seg) }));\n return (f, c) => {\n let key = f.pos.focus;\n // The empty address resolves to the focus, so this fast path changes no result.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = resolveAddr(c.space, f.pos, at);\n if (!where.ok) return this.#emit(c, info, f, fail({ ...where.error, path }));\n key = where.value;\n }\n const failed = (r: Result<unknown>): Result<unknown> => this.#emit(c, info, f, r, [{ key, path: segs, ok: false }]);\n const missing = (where: string): Result<unknown> => failed(this.#err(\"missing-field\", `the record at \"${key}\" has no value at \"${where}\"`, f, path));\n let value: unknown = c.space.get(key);\n if (value === undefined || value === null) return missing(label === \"\" ? \"(record)\" : label);\n for (const { seg, where, valid } of steps) {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || !valid) return missing(where);\n try {\n value = Reflect.get(value, seg);\n } catch (thrown) {\n return failed(this.#err(\"threw\", `reading \"${where}\" at \"${key}\" threw an exception`, f, path, { thrown }));\n }\n if (value === undefined || value === null) return missing(where);\n }\n return this.#emit(c, info, f, ok(value), [{ key, path: segs, ok: true }]);\n };\n }\n\n /** This method evaluates nodes applicatively. One failure stays as it is. Two or more give `#ARGS`. */\n #all(nodes: readonly Node[], f: Frame, c: Ctx, path: readonly number[], what: string): Result<readonly unknown[]> {\n const values: unknown[] = [];\n let first: VexError | undefined;\n let errors: VexError[] | undefined;\n for (const n of nodes) {\n const r = n(f, c);\n if (r.ok) values.push(r.value);\n else if (first === undefined) first = r.error;\n else (errors ??= [first]).push(r.error);\n }\n if (first === undefined) return ok(values);\n return errors === undefined ? fail(first) : this.#err(\"args\", `${errors.length} ${what} failed`, f, path, { causes: errors });\n }\n\n #each(e: ExprOf<\"each\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const targets = this.#targets(e.axis, path, { next: 1 });\n const body = this.node(e.body, [...path, 0]);\n return (f, c) => {\n // An axis with an address finds its targets from the key of the address. The origin does not change.\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = resolveAddr(c.space, f.pos, at);\n if (!where.ok) return this.#emit(c, info, f, fail({ ...where.error, path }));\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n const ts = targets(from, c);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n const items: ListItem[] = ts.value.map(({ key, test }) => {\n if (test !== undefined && !test.ok) return { key, result: test };\n return { key, result: body({ pos: { origin: f.pos.origin, focus: key }, env: f.env }, c) };\n });\n return this.#emit(c, info, f, ok(vexList(items)));\n };\n }\n\n /** This method compiles the targets of an axis. For `where`, a failed test keeps the target with its error. */\n #targets(a: Axis, path: readonly number[], counter: { next: number }): (f: Frame, c: Ctx) => Result<readonly { readonly key: string; readonly test?: Result<unknown> }[]> {\n if (a.t !== \"where\") {\n return (f, c) => {\n const keys = axisTargets(c.space, f.pos, a);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : fail({ ...keys.error, path });\n };\n }\n const inner = this.#targets(a.axis, path, counter);\n const testPath = [...path, counter.next++];\n const test = this.node(a.test, testPath);\n return (f, c) => {\n const ts = inner(f, c);\n if (!ts.ok) return ts;\n const out: { key: string; test?: Result<unknown> }[] = [];\n for (const t of ts.value) {\n if (t.test !== undefined && !t.test.ok) {\n out.push(t);\n continue;\n }\n const at: Frame = { pos: { origin: f.pos.origin, focus: t.key }, env: f.env };\n const r = test(at, c);\n if (!r.ok) out.push({ key: t.key, test: r });\n else if (r.value === true) out.push({ key: t.key });\n else if (r.value !== false) {\n out.push({ key: t.key, test: this.#err(\"kind-mismatch\", `the test of \"where\" gave a ${typeof r.value}, not a boolean`, at, testPath) });\n }\n }\n return ok(out);\n };\n }\n\n #app(op: string, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n return (f, c) => {\n const all = this.#all(args, f, c, path, \"arguments\");\n if (!all.ok) return this.#emit(c, info, f, all);\n const values = all.value;\n const self = values[0];\n if (listOp !== undefined && isVexList(self)) return this.#emit(c, info, f, this.#listOp(listOp, self, values.slice(1), f, path));\n let accepted: AnyDomain | undefined;\n // Without arguments, the receiver is undefined, and no domain of a test accepts it.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: the loop finds no domain for undefined\n if (values.length > 0) {\n for (const d of this.#domains) {\n if (!safeIs(d, self)) continue;\n accepted ??= d;\n const resolved = resolveOp(d, self, op);\n if (resolved !== undefined) return this.#emit(c, info, f, this.#call(resolved, op, values.slice(1), f, path));\n }\n }\n if (fn !== undefined) return this.#emit(c, info, f, this.#checkResult(this.#invoke(() => fn(...values), op, f, path), f, path, op));\n if (accepted !== undefined) return this.#emit(c, info, f, this.#err(\"unknown-op\", `the domain \"${accepted.name}\" has no op \"${op}\"`, f, path, { op }));\n if (values.length === 0) return this.#emit(c, info, f, this.#err(\"unknown-op\", `there is no function \"${op}\"`, f, path, { op }));\n return this.#emit(c, info, f, this.#err(\"not-instance\", `no domain accepts the receiver of \"${op}\" (${describeType(self)})`, f, path, { op }));\n };\n }\n\n #special(op: SpecialForm, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const arg = (i: number, f: Frame, c: Ctx): Result<unknown> => {\n const n = args[i];\n return n === undefined ? this.#err(\"bad-expression\", `\"${op}\" needs argument ${i + 1}`, f, path, { op }) : n(f, c);\n };\n const bool = (i: number, f: Frame, c: Ctx): Result<boolean> => {\n const r = arg(i, f, c);\n if (!r.ok) return r;\n return typeof r.value === \"boolean\" ? ok(r.value) : this.#err(\"kind-mismatch\", `argument ${i + 1} of \"${op}\" is a ${describeType(r.value)}, not a boolean`, f, path, { op });\n };\n switch (op) {\n case \"if\":\n return (f, c) => {\n const cond = bool(0, f, c);\n return this.#emit(c, info, f, cond.ok ? arg(cond.value ? 1 : 2, f, c) : cond);\n };\n case \"and\":\n case \"or\": {\n const stop = op === \"or\";\n return (f, c) => {\n if (args.length === 0) return this.#emit(c, info, f, this.#err(\"bad-expression\", `\"${op}\" needs at least 1 argument`, f, path, { op }));\n for (let i = 0; i < args.length; i++) {\n const b = bool(i, f, c);\n if (!b.ok) return this.#emit(c, info, f, b);\n if (b.value === stop) return this.#emit(c, info, f, ok(b.value));\n }\n return this.#emit(c, info, f, ok(!stop));\n };\n }\n case \"ifError\":\n return (f, c) => {\n const first = arg(0, f, c);\n return this.#emit(c, info, f, first.ok ? first : arg(1, f, c));\n };\n }\n }\n\n #call(op: ResolvedOp, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const { domain, spec } = op;\n const lift = spec.liftScalar;\n const from = domain.fromScalar;\n let callArgs: readonly unknown[] = rest;\n if (lift && from !== undefined) {\n const lifted = this.#invoke(() => rest.map((a, i): unknown => (typeof a === \"number\" && liftsAt(lift, i) ? from(a) : a)), `${domain.name}.fromScalar`, f, path);\n if (!lifted.ok) return lifted;\n callArgs = lifted.value as readonly unknown[];\n }\n if (spec.params !== undefined) {\n for (let i = 0; i < callArgs.length; i++) {\n const kind = spec.params[i] ?? \"any\";\n if (!matchesKind(kind, callArgs[i], domain)) {\n const k: ErrorKind = kind === \"domain\" ? \"not-instance\" : \"kind-mismatch\";\n return this.#err(k, `argument ${i + 1} of \"${name}\" is a ${describeType(callArgs[i])}, not a ${kind === \"domain\" ? domain.name : kind}`, f, path, { op: name });\n }\n }\n }\n return this.#checkResult(this.#invoke(() => op.call(callArgs), name, f, path), f, path, name);\n }\n\n #invoke(run: () => unknown, op: string, f: Frame, path: readonly number[]): Result<unknown> {\n try {\n return ok(run());\n } catch (thrown) {\n return this.#err(\"threw\", `\"${op}\" threw an exception`, f, path, { op, thrown });\n }\n }\n\n /** This method checks the value that an op gave: no `undefined`, finite numbers, and valid domain values. */\n #checkResult(r: Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n if (!r.ok) return r;\n const value = r.value;\n const extra = { op };\n if (value === undefined || value === null) return this.#err(\"undefined-result\", `\"${op}\" gave no value`, f, path, extra);\n if (typeof value === \"number\" && !Number.isFinite(value)) return this.#err(\"not-finite\", `\"${op}\" gave ${value}`, f, path, extra);\n const d = this.#domains.find((dom) => safeIs(dom, value));\n if (d?.valid !== undefined) {\n let valid: boolean;\n try {\n valid = d.valid(value);\n } catch (thrown) {\n return this.#err(\"threw\", `the \"valid\" check of \"${d.name}\" threw an exception`, f, path, { ...extra, thrown });\n }\n if (!valid) return this.#err(\"invalid-value\", `\"${op}\" gave a value that is not a valid ${d.name}`, f, path, extra);\n }\n return r;\n }\n\n #listOp(op: ListOp, list: VexList, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const optsArg = op === \"reduce\" ? rest[1] : rest[0];\n const strict = (optsArg as ListOptions | null | undefined)?.strict === true;\n const firstError = list.items.find((it) => !it.result.ok)?.result;\n if (strict && firstError !== undefined && !firstError.ok) return fail(firstError.error);\n const okValues = list.items.flatMap((it) => (it.result.ok ? [it.result.value] : []));\n const numbers = (): Result<readonly number[]> => {\n const bad = okValues.find((x) => typeof x !== \"number\");\n return bad === undefined ? ok(okValues as readonly number[]) : this.#err(\"kind-mismatch\", `\"${op}\" needs numbers, but an item is a ${describeType(bad)}`, f, path, { op });\n };\n const booleans = (): Result<readonly boolean[]> => {\n const bad = okValues.find((x) => typeof x !== \"boolean\");\n return bad === undefined ? ok(okValues as readonly boolean[]) : this.#err(\"kind-mismatch\", `\"${op}\" needs booleans, but an item is a ${describeType(bad)}`, f, path, { op });\n };\n const empty = (): Result<never> => this.#err(\"empty\", `\"${op}\" has no values to work with`, f, path, { op });\n switch (op) {\n case \"count\":\n return ok(okValues.length);\n case \"values\":\n return ok(Object.freeze([...okValues]));\n case \"keys\":\n return ok(Object.freeze(list.items.filter((it) => it.result.ok).map((it) => it.key)));\n case \"errors\":\n return ok(Object.freeze(list.items.flatMap((it) => (it.result.ok ? [] : [it.result.error]))));\n case \"first\":\n return okValues.length > 0 ? ok(okValues[0]) : empty();\n case \"sum\": {\n const n = numbers();\n return n.ok ? this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0)), f, path, op) : n;\n }\n case \"mean\": {\n const n = numbers();\n if (!n.ok) return n;\n return n.value.length === 0 ? empty() : this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0) / n.value.length), f, path, op);\n }\n case \"min\":\n case \"max\": {\n const n = numbers();\n if (!n.ok) return n;\n if (n.value.length === 0) return empty();\n return ok(n.value.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x))));\n }\n case \"any\":\n case \"all\":\n case \"none\": {\n const b = booleans();\n if (!b.ok) return b;\n if (op === \"any\") return ok(b.value.some((x) => x));\n if (op === \"all\") return ok(b.value.every((x) => x));\n return ok(!b.value.some((x) => x));\n }\n case \"reduce\":\n return this.#reduce(rest[0], okValues, f, path, optsArg);\n }\n }\n\n /**\n * This method folds the values with a domain op, from the left. An empty list gives the identity of the op, if one\n * domain has an identity for the op (LIST.EMPTY). The option `domain` names that domain when more domains have one.\n */\n #reduce(opName: unknown, values: readonly unknown[], f: Frame, path: readonly number[], opts: unknown): Result<unknown> {\n if (typeof opName !== \"string\") return this.#err(\"kind-mismatch\", `\"reduce\" needs an op name, but got a ${describeType(opName)}`, f, path, { op: \"reduce\" });\n if (values.length === 0) {\n const named = (opts as { domain?: unknown } | null | undefined)?.domain;\n const candidates = this.#domains.filter((d) => Object.hasOwn(d.ops, opName) && (d.ops[opName] as { identity?: () => unknown }).identity !== undefined && (named === undefined || d.name === named));\n if (named !== undefined && !this.#domains.some((d) => d.name === named)) {\n return this.#err(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named)}, but the program has no such domain`, f, path, { op: opName });\n }\n const [only, second] = candidates;\n if (only === undefined) return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values and the op has no identity`, f, path, { op: opName });\n if (second !== undefined) {\n const names = candidates.map((d) => d.name).join(\", \");\n return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values, and more domains have an identity for it (${names}). Name one with { domain }`, f, path, { op: opName });\n }\n return this.#invoke((only.ops[opName] as { identity: () => unknown }).identity, opName, f, path);\n }\n let acc: unknown = values[0];\n for (let i = 1; i < values.length; i++) {\n const d = this.#domains.find((dom) => safeIs(dom, acc) && resolveOp(dom, acc, opName) !== undefined);\n const op = d === undefined ? undefined : resolveOp(d, acc, opName);\n if (op === undefined) return this.#err(\"unknown-op\", `no domain gives \"${opName}\" for a ${describeType(acc)}`, f, path, { op: opName });\n const r = this.#call(op, opName, [values[i]], f, path);\n if (!r.ok) return r;\n acc = r.value;\n }\n return ok(acc);\n }\n}\n\nconst FORBIDDEN_FIELDS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\nconst isFieldName = (seg: string): boolean => seg.length > 0 && !FORBIDDEN_FIELDS.has(seg);\n\n/** This function runs the `is` test of a domain. A test that throws counts as `false`. */\n// Stryker disable BlockStatement: an empty catch gives undefined, which also counts as false\nfunction safeIs(d: AnyDomain, value: unknown): boolean {\n try {\n return d.is(value);\n } catch {\n return false;\n }\n}\n// Stryker restore BlockStatement\n\n\nfunction matchesKind(kind: ParamKind, value: unknown, domain: AnyDomain): boolean {\n switch (kind) {\n case \"domain\":\n return safeIs(domain, value);\n case \"number\":\n return typeof value === \"number\";\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"string\":\n return typeof value === \"string\";\n case \"any\":\n return true;\n }\n}\n\n/** This function gives a short name for the type of a value, for error messages. */\nexport function describeType(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n if (typeof u === \"object\") {\n const name = (Object.getPrototypeOf(u) as { constructor?: { name?: unknown } } | null)?.constructor?.name;\n return typeof name === \"string\" && name !== \"Object\" ? name : \"object\";\n }\n return typeof u;\n}\n\n/** This function gives the label of a node, for traces. */\nexport function labelOf(e: Expr): string {\n switch (e.tag) {\n case \"lit\":\n return previewValue(e.value);\n case \"ref\":\n return e.path.length === 0 ? \"(record)\" : e.path.join(\".\");\n case \"app\":\n return e.op;\n case \"let\":\n return `let ${Object.keys(e.bind).join(\", \")}`;\n case \"var\":\n return e.name;\n case \"rec\":\n return `{ ${Object.keys(e.fields).join(\", \")} }`;\n case \"each\":\n return e.at === undefined ? `each ${e.axis.t}` : `each ${e.axis.t} from ${e.at.map(moveText).join(\".\")}`;\n case \"ext\":\n return e.kind;\n }\n}\n\n/** This function gives a short text for a move, for the label of an axis with an address. */\nfunction moveText(m: Move): string {\n switch (m.t) {\n case \"key\":\n return `key(${m.key})`;\n case \"index\":\n return `index(${m.i})`;\n case \"offset\":\n return `offset(${m.d.join(\", \")})`;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return m.t;\n }\n}\n\n/** This function gives a short text for a value. */\nexport function previewValue(u: unknown): string {\n // JSON has no NaN and no Infinity, so a number gets its own text. JSON gives the text of the other primitives.\n if (typeof u === \"number\") return String(u);\n if (isVexList(u)) return `list(${u.items.length})`;\n try {\n const json = JSON.stringify(u);\n // A function, a symbol and undefined have no JSON form.\n // Stryker disable next-line ConditionalExpression: without the test, undefined.length throws, and the catch gives the same text\n if (json !== undefined) return json.length > 60 ? `${json.slice(0, 57)}...` : json;\n } catch {\n // A value with cycles has no JSON form.\n }\n return describeType(u);\n}\n\n// The reads of a reference show the key and the path, for example \"read B.position\" or \"no value at A.mass\".\nconst formatRead = (r: Read): string => `${r.ok ? \"read\" : \"no value at\"} ${r.key}.${r.path.length === 0 ? \"(record)\" : r.path.join(\".\")}`;\n\n/**\n * This function gives a text form of a trace. Each event has one line, in finish order. The indent of a line\n * shows the depth of the node. A domain with `show` gives the text of its values. The golden tests compare this text.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain shows no value\nexport function formatTrace(trace: Trace, domains: readonly AnyDomain[] = []): string {\n const show = (u: unknown): string => {\n if (isVexList(u)) return `[${u.items.map((it) => `${it.key}: ${result(it.result)}`).join(\", \")}]`;\n const d = domains.find((dom) => dom.show !== undefined && safeIs(dom, u));\n try {\n // Stryker disable next-line ConditionalExpression,OptionalChaining: without a domain, d.show throws, and the catch gives the same text\n if (d?.show !== undefined) return d.show(u);\n } catch {\n // A show function that throws gives the default text.\n }\n return previewValue(u);\n };\n const result = (r: Result<unknown>): string => (r.ok ? show(r.value) : formatError(r.error));\n const line = (e: TraceEvent): string => {\n const reads = e.reads === undefined ? \"\" : ` [${e.reads.map(formatRead).join(\", \")}]`;\n return `${\" \".repeat(e.path.length)}${e.label} @${e.focus}${reads} = ${result(e.result)}`;\n };\n const lines = trace.events.map(line);\n return [...lines, `result = ${result(trace.result)}`, \"\"].join(\"\\n\");\n}\n\n/** This function gives the number of nodes of an expression. */\nexport const sizeOf = (e: Expr): number => 1 + children(e).reduce((s, c) => s + sizeOf(c), 0);\n","import { children, type Addr, type Axis, type Expr } from \"./ir.ts\";\n\n/** One static read of a program: a field path at an address, inside zero or more axes. */\nexport interface Dependency {\n /** The address of the read. The empty address is the focus. */\n readonly at: Addr;\n /** The field path of the read. */\n readonly path: readonly string[];\n /** The axes around the read, from the outside to the inside. Inside an axis, the focus is the target. */\n readonly axes: readonly Axis[\"t\"][];\n /** The address of each axis in `axes`, in the same order. The empty address is the focus. */\n readonly axisAt: readonly Addr[];\n}\n\n/**\n * This function gives the static reads of an expression. A host can use them to recompute a program only\n * when a field that it reads changes.\n */\nexport function deps(e: Expr): readonly Dependency[] {\n const out: Dependency[] = [];\n const walk = (x: Expr, axes: readonly Axis[\"t\"][], axisAt: readonly Addr[]): void => {\n if (x.tag === \"ref\") {\n out.push({ at: x.at ?? [], path: x.path, axes, axisAt });\n return;\n }\n if (x.tag === \"each\") {\n const inner = [...axes, x.axis.t];\n const innerAt = [...axisAt, x.at ?? []];\n children(x).forEach((c) => walk(c, inner, innerAt));\n return;\n }\n children(x).forEach((c) => walk(c, axes, axisAt));\n };\n walk(e, [], []);\n return out;\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { vexError } from \"./errors.ts\";\nimport { isExpr, type Expr } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/**\n * The JSON form of the values in a literal. JSON data stays as it is, with three exceptions. Each exception is a record\n * with the key `$vex`:\n *\n * - `{ \"$vex\": \"domain\", \"domain\": name, \"value\": v }`: a value of a domain, with the `encode` of the domain.\n * - `{ \"$vex\": \"number\", \"value\": \"-0\" }`: a number that JSON has no text for: `-0`, `NaN`, `Infinity` or `-Infinity`.\n * - `{ \"$vex\": \"escape\", \"value\": record }`: a record of the data that has the key `$vex` itself (IR.JSON.ESCAPE).\n *\n * A record with the key `$vex` and another form stays data, so a file from an older version reads as before.\n *\n * The functions walk the tree of the expression, so only the value of a literal gets this form. A field of a literal\n * that looks like an expression stays data. The data of an extension is plain JSON, as before.\n */\ntype Encoded =\n | { readonly $vex: \"domain\"; readonly domain: string; readonly value: unknown }\n | { readonly $vex: \"number\"; readonly value: \"-0\" | \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { readonly $vex: \"escape\"; readonly value: Readonly<Record<string, unknown>> };\n\nconst isRecord = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null && !Array.isArray(u);\n\nconst isPlainRecord = (u: unknown): u is Readonly<Record<string, unknown>> => {\n if (!isRecord(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto === Object.prototype || proto === null;\n};\n\n/** This function gives the JSON form of a value, or the reason why the value has no JSON form. */\nfunction encodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (u === null || typeof u === \"string\" || typeof u === \"boolean\") return ok(u);\n if (typeof u === \"number\") {\n if (Object.is(u, -0)) return ok({ $vex: \"number\", value: \"-0\" } satisfies Encoded);\n // Stryker disable next-line EqualityOperator: here u is an infinity, so u > 0 and u >= 0 are the same test\n return Number.isFinite(u) ? ok(u) : ok({ $vex: \"number\", value: Number.isNaN(u) ? \"NaN\" : u > 0 ? \"Infinity\" : \"-Infinity\" } satisfies Encoded);\n }\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (isPlainRecord(u)) {\n const out: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(u)) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out[k] = r.value;\n }\n return ok(Object.hasOwn(u, \"$vex\") ? ({ $vex: \"escape\", value: out } satisfies Encoded) : out);\n }\n // A plain array or record stays data. Another object is a value of a domain, or it has no JSON form.\n const d = domains.find((dom) => dom.encode !== undefined && dom.is(u));\n if (d?.encode !== undefined) return ok({ $vex: \"domain\", domain: d.name, value: d.encode(u) } satisfies Encoded);\n return fail(vexError(\"bad-expression\", \"a literal value is not JSON data and no domain encodes it\"));\n}\n\nconst NUMBERS: Readonly<Record<string, number>> = { \"-0\": -0, NaN: Number.NaN, Infinity: Number.POSITIVE_INFINITY, \"-Infinity\": Number.NEGATIVE_INFINITY };\n\n/** This function reads a value from its JSON form. */\nfunction decodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (!isRecord(u)) return ok(u);\n const fields = (record: Readonly<Record<string, unknown>>): Result<unknown> => {\n const out: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(record)) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out[k] = r.value;\n }\n return ok(out);\n };\n // A record without the key $vex matches none of the forms below, so it stays data too.\n const kind = u[\"$vex\"];\n if (kind === \"escape\" && isRecord(u[\"value\"])) return fields(u[\"value\"]);\n if (kind === \"number\" && typeof u[\"value\"] === \"string\" && Object.hasOwn(NUMBERS, u[\"value\"])) return ok(NUMBERS[u[\"value\"]]);\n if (kind === \"domain\" && typeof u[\"domain\"] === \"string\") {\n const name = u[\"domain\"];\n const d = domains.find((dom) => dom.name === name);\n if (d?.decode === undefined) return fail(vexError(\"bad-expression\", `no domain \"${name}\" decodes a literal`));\n return ok(d.decode(u[\"value\"]));\n }\n // A form that this version does not know stays data, so a file from an older version reads as before.\n return fields(u);\n}\n\n/** This function applies `f` to each literal value of a JSON tree of an expression. */\nfunction mapValues(u: unknown, f: (value: unknown) => Result<unknown>): Result<unknown> {\n if (!isRecord(u)) return ok(u);\n const out: Record<string, unknown> = { ...u };\n const child = (key: string): Result<unknown> | undefined => {\n const r = mapValues(u[key], f);\n if (r.ok) out[key] = r.value;\n return r.ok ? undefined : r;\n };\n const each = (key: string): Result<unknown> | undefined => {\n const list = u[key];\n if (Array.isArray(list)) {\n const items: unknown[] = [];\n for (const x of list) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n items.push(r.value);\n }\n out[key] = items;\n } else if (isRecord(list)) {\n const rec: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(list)) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n rec[k] = r.value;\n }\n out[key] = rec;\n }\n return undefined;\n };\n const axis = (a: unknown): Result<unknown> => {\n if (!isRecord(a) || a[\"t\"] !== \"where\") return ok(a);\n const inner = axis(a[\"axis\"]);\n if (!inner.ok) return inner;\n const test = mapValues(a[\"test\"], f);\n return test.ok ? ok({ ...a, axis: inner.value, test: test.value }) : test;\n };\n switch (u[\"tag\"]) {\n case \"lit\": {\n if (!Object.hasOwn(u, \"value\")) return ok(out);\n const r = f(u[\"value\"]);\n if (!r.ok) return r;\n out[\"value\"] = r.value;\n return ok(out);\n }\n case \"app\":\n return each(\"args\") ?? ok(out);\n case \"let\":\n return each(\"bind\") ?? child(\"body\") ?? ok(out);\n case \"rec\":\n return each(\"fields\") ?? ok(out);\n case \"each\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return child(\"body\") ?? ok(out);\n }\n default:\n return ok(out);\n }\n}\n\n/**\n * This function gives the JSON text of an expression. A literal value that is a domain value needs a domain with\n * `encode`. A literal value that is not JSON data and has no such domain gives the error `#VALUE!`.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function serialize(e: Expr, domains: readonly AnyDomain[] = []): Result<string> {\n try {\n // A getter of a literal value can throw, so the encoding is inside the try too.\n const tree = mapValues(e, (v) => encodeValue(v, domains));\n return tree.ok ? ok(JSON.stringify(tree.value)) : fail(tree.error);\n } catch (thrown) {\n return fail(vexError(\"threw\", \"the expression has no JSON form\", { thrown }));\n }\n}\n\n/** This function reads an expression from JSON text. It checks the whole tree. */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function parse(text: string, domains: readonly AnyDomain[] = []): Result<Expr> {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (thrown) {\n return fail(vexError(\"bad-expression\", \"the text is not JSON\", { thrown }));\n }\n const tree = mapValues(raw, (v) => decodeValue(v, domains));\n if (!tree.ok) return fail(tree.error);\n return isExpr(tree.value) ? ok(tree.value) : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { evaluate, type FreeFn } from \"./evaluate.ts\";\nimport { app, lit, v } from \"./ir.ts\";\nimport { vexList, type ListItem } from \"./list.ts\";\nimport { fail, none, ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport { space as spaces, type Space } from \"./space.ts\";\n\n/** A monoid: an associative `concat` with an identity element `empty`. */\nexport interface Monoid<M> {\n readonly empty: M;\n readonly concat: (a: M, b: M) => M;\n}\n\n/** Standard monoids. */\nexport const monoids: {\n readonly sum: Monoid<number>;\n readonly product: Monoid<number>;\n readonly all: Monoid<boolean>;\n readonly any: Monoid<boolean>;\n} = {\n sum: { empty: 0, concat: (a, b) => a + b },\n product: { empty: 1, concat: (a, b) => a * b },\n all: { empty: true, concat: (a, b) => a && b },\n any: { empty: false, concat: (a, b) => a || b },\n};\n\n/** One item of a traversal: the start key and the result there. */\nexport interface TraversalItem<K extends string, T> {\n readonly key: K;\n readonly result: Result<T>;\n}\n\n/**\n * A traversal: the results of one program at each start key. The reductions skip error items by default.\n * After `strict()`, an error item makes the reduction that error.\n */\nexport interface Traversal<K extends string, T> {\n readonly items: readonly TraversalItem<K, T>[];\n /** This method gives a traversal whose reductions fail on the first error item. */\n strict(): Traversal<K, T>;\n /** This method gives the result at one key. */\n get(k: K): Optional<T>;\n /** The values of the items without errors. */\n values(): readonly T[];\n /** The keys of the items without errors. */\n keys(): readonly K[];\n /** The errors of the items with errors. */\n errors(): readonly VexError[];\n count(): Optional<number>;\n sum(this: Traversal<K, number>): Optional<number>;\n mean(this: Traversal<K, number>): Optional<number>;\n min(this: Traversal<K, number>): Optional<number>;\n max(this: Traversal<K, number>): Optional<number>;\n any(this: Traversal<K, boolean>): Optional<boolean>;\n all(this: Traversal<K, boolean>): Optional<boolean>;\n none(this: Traversal<K, boolean>): Optional<boolean>;\n /** This method folds the values with a domain op, from the left. */\n reduce(op: string): Optional<T>;\n /** This method gives the result of a reduction, with its error. */\n reduceResult(op: \"count\" | \"sum\" | \"mean\" | \"min\" | \"max\" | \"any\" | \"all\" | \"none\" | \"reduce\", reduceOp?: string): Result<unknown>;\n /** This method maps each value with `f`. If `f` throws, the item has the error `#CALC!`. */\n map<U>(f: (value: T, key: K) => U): Traversal<K, U>;\n /** This method folds the values with a monoid. */\n fold<M>(monoid: Monoid<M>, f: (value: T) => M): M;\n}\n\ninterface TraversalEnv {\n readonly domains: readonly AnyDomain[];\n readonly options?: { readonly fns?: Readonly<Record<string, FreeFn>> };\n}\n\nconst EMPTY_SPACE: Space = spaces.record({ $: {} });\n\nconst opt = <U>(r: Result<unknown>): Optional<U> => toOptional(r as Result<U>);\n\n/** This function makes a traversal from items. */\nexport function traversal<K extends string, T>(items: readonly TraversalItem<K, T>[], env: TraversalEnv, isStrict = false): Traversal<K, T> {\n const reduce = (op: string, reduceOp?: string): Result<unknown> => {\n const list = vexList(items as readonly ListItem[]);\n const args = [v(\"$list\"), ...(reduceOp === undefined ? [] : [lit(reduceOp)]), ...(isStrict ? [lit({ strict: true })] : [])];\n return evaluate(app(op, ...args), {\n space: EMPTY_SPACE,\n origin: \"$\",\n domains: env.domains,\n vars: { $list: list },\n });\n };\n const t: Traversal<K, T> = {\n items,\n strict: () => traversal(items, env, true),\n get: (k) => {\n const item = items.find((it) => it.key === k);\n return item === undefined ? none() : toOptional(item.result);\n },\n values: () => items.flatMap((it) => (it.result.ok ? [it.result.value] : [])),\n keys: () => items.flatMap((it) => (it.result.ok ? [it.key] : [])),\n errors: () => items.flatMap((it) => (it.result.ok ? [] : [it.result.error])),\n count: () => opt(reduce(\"count\")),\n sum: () => opt(reduce(\"sum\")),\n mean: () => opt(reduce(\"mean\")),\n min: () => opt(reduce(\"min\")),\n max: () => opt(reduce(\"max\")),\n any: () => opt(reduce(\"any\")),\n all: () => opt(reduce(\"all\")),\n none: () => opt(reduce(\"none\")),\n reduce: (op) => opt(reduce(\"reduce\", op)),\n reduceResult: (op, reduceOp) => reduce(op, reduceOp),\n map: <U>(f: (value: T, key: K) => U): Traversal<K, U> =>\n traversal(\n items.map((it): TraversalItem<K, U> => {\n if (!it.result.ok) return { key: it.key, result: it.result };\n try {\n return { key: it.key, result: ok(f(it.result.value, it.key)) };\n } catch (thrown) {\n return { key: it.key, result: fail(vexError(\"threw\", \"the map function threw an exception\", { thrown, focus: it.key })) };\n }\n }),\n env,\n isStrict,\n ),\n fold: <M>(monoid: Monoid<M>, f: (value: T) => M): M => t.values().reduce((acc, x) => monoid.concat(acc, f(x)), monoid.empty),\n };\n return t;\n}\n","/**\n * Sheets: named columns of formulas over a space. A formula can read a column at an address, like a cell\n * reference of a spreadsheet. A cell is one column at one key. A run evaluates each cell once, and each cell on a\n * cycle of reads gives `#CYCLE!`.\n *\n * A cell reference is the extension node `ext(\"vex.cell\", { column, at })`. Thus the IR has no new kind, and the\n * JSON form, `deps` and the traces work without a change.\n */\nimport { vexError } from \"./errors.ts\";\nimport { evaluate, explain, type EvalOptions, type ExtHandler } from \"./evaluate.ts\";\nimport { ext, isMove, type Addr, type Expr } from \"./ir.ts\";\nimport { fail, type Result } from \"./result.ts\";\nimport { resolveAddr } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\n\n/** The extension kind of a cell reference. */\nexport const CELL_KIND = \"vex.cell\";\n\n/** The data of a cell reference: the column, and the address from the focus. */\nexport interface CellRef {\n readonly column: string;\n readonly at: Addr;\n}\n\n/** This function makes a cell reference: the column `column` at the address `at` from the focus. */\nexport const cell = (column: string, at: Addr = []): Expr => ext(CELL_KIND, { column, at } satisfies CellRef);\n\nconst isCellRef = (u: unknown): u is CellRef =>\n typeof u === \"object\" &&\n u !== null &&\n typeof (u as { column?: unknown }).column === \"string\" &&\n Array.isArray((u as { at?: unknown }).at) &&\n (u as { at: readonly unknown[] }).at.every(isMove);\n\n/** The options of a sheet run: the evaluation options without the origin and the trace. */\nexport type SheetOptions = Omit<EvalOptions, \"origin\" | \"trace\">;\n\nconst cycleError = (column: string, key: string): Result<never> =>\n fail(vexError(\"cycle\", `the cell \"${column}\" at \"${key}\" is on a cycle of cell references`, { origin: key, focus: key }));\n\n/**\n * One run of a sheet. It keeps the result of each cell that it evaluated. The space does not change, so a cell has\n * one result in a run.\n *\n * The run is a depth-first search with the algorithm of Tarjan for strongly connected components. A cell finishes\n * when its component finishes. Each cell of a component with two or more cells, or with a reference to itself,\n * gives `#CYCLE!`. A read of a cell that is not finished gives `#CYCLE!` too. Thus the order of the evaluations\n * does not change a result, also when `ifError` catches the error of a cycle.\n */\n/** The state of one cell in the search. */\ninterface Visit {\n readonly id: string;\n readonly column: string;\n readonly key: string;\n readonly index: number;\n low: number;\n reread: boolean;\n result: Result<unknown>;\n}\n\nexport class SheetRun {\n readonly #columns: ReadonlyMap<string, Expr>;\n readonly #opts: SheetOptions;\n readonly #done = new Map<string, Result<unknown>>();\n // For each column, the number of keys at the start of the key order that a warm-up evaluated.\n readonly #warmed = new Map<string, number>();\n // The position of each key in the key order, made at the first warm-up.\n #index: ReadonlyMap<string, number> | undefined;\n // The cells on the stack of the search: started, but their component is not finished.\n readonly #visits = new Map<string, Visit>();\n // Stryker disable next-line ArrayDeclaration: the search never reads below the root of a component\n readonly #stack: Visit[] = [];\n // The cell whose formula is in evaluation. At the top level, it is a placeholder that is not a cell.\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n #top: Visit = { id: \"\", column: \"\", key: \"\", index: -1, low: -1, reread: false, result: cycleError(\"\", \"\") };\n #next = 0;\n\n constructor(columns: ReadonlyMap<string, Expr>, opts: SheetOptions) {\n this.#columns = columns;\n this.#opts = { ...opts, extensions: { ...opts.extensions, [CELL_KIND]: this.#handler } };\n }\n\n readonly #handler: ExtHandler = (data, ctx) => {\n if (!isCellRef(data)) return fail(vexError(\"bad-expression\", \"a cell reference needs a column name and an address\", { path: ctx.path }));\n const where = resolveAddr(ctx.space, ctx.position, data.at);\n if (!where.ok) return fail({ ...where.error, path: ctx.path });\n return this.cell(data.column, where.value);\n };\n\n /**\n * This method gives the result of one cell: the column `column` at the key `key`. A read from a host first evaluates\n * the column at the keys before `key`, in key order. Thus a recurrence over the keys reads finished cells, and a\n * first read at the last key does not go deep into the call stack.\n */\n cell(column: string, key: string): Result<unknown> {\n // The placeholder at the top has the index -1. A read inside a formula has a cell at the top, so it does not warm.\n if (this.#top.index < 0) this.#warmTo(column, key);\n return this.#cell(column, key);\n }\n\n /** This method evaluates the column `column` at each key before `key` that it did not evaluate before, in key order. */\n #warmTo(column: string, key: string): void {\n if (!this.#columns.has(column)) return;\n const keys = this.#opts.space.keys;\n this.#index ??= new Map(keys.map((k, i) => [k, i]));\n const end = this.#index.get(key) ?? 0;\n const start = this.#warmed.get(column) ?? 0;\n for (let i = start; i < end; i++) this.#cell(column, keys[i] ?? key);\n if (end > start) this.#warmed.set(column, end);\n }\n\n /** This method evaluates one cell, without the warm-up of `cell`. */\n #cell(column: string, key: string): Result<unknown> {\n const id = `${column}\\u0000${key}`;\n const done = this.#done.get(id);\n if (done !== undefined) return done;\n const caller = this.#top;\n const seen = this.#visits.get(id);\n if (seen !== undefined) {\n // A read of a cell that is not finished: the caller and this cell are on one cycle. The cell is on the\n // stack of the search, so it is in the component of the caller. Thus a component with one cell is cyclic\n // only if that cell reads itself.\n caller.low = Math.min(caller.low, seen.index);\n seen.reread = true;\n return cycleError(column, key);\n }\n const program = this.#columns.get(column);\n if (program === undefined) return fail(vexError(\"unbound\", `the sheet has no column \"${column}\"`, { origin: key, focus: key }));\n\n const n = this.#next++;\n const visit: Visit = { id, column, key, index: n, low: n, reread: false, result: cycleError(column, key) };\n this.#visits.set(id, visit);\n this.#stack.push(visit);\n this.#top = visit;\n visit.result = evaluate(program, { ...this.#opts, origin: key });\n this.#top = caller;\n\n if (visit.low === visit.index) this.#finish(visit);\n else caller.low = Math.min(caller.low, visit.low);\n return this.#done.get(id) ?? cycleError(column, key);\n }\n\n /** This method takes the component of `root` from the stack, and sets the final result of each of its cells. */\n #finish(root: Visit): void {\n const members = this.#stack.splice(this.#stack.indexOf(root));\n // A component of two or more cells reads its root again, so root.reread alone decides. The length test is a guard.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: members.length > 1 implies root.reread\n const cyclic = members.length > 1 || root.reread;\n for (const m of members) {\n // Stryker disable next-line CallExpression: a finished cell is in #done, and cell() reads #done first\n this.#visits.delete(m.id);\n this.#done.set(m.id, cyclic ? cycleError(m.column, m.key) : m.result);\n }\n }\n\n /** This method evaluates one cell with a trace of the nodes of its column. The result is the result of the cell. */\n explain(column: string, key: string): Trace {\n const result = this.cell(column, key);\n const program = this.#columns.get(column);\n if (program === undefined) return { events: [], result };\n return { events: explain(program, { ...this.#opts, origin: key }).events, result };\n }\n\n /**\n * This method evaluates the column `column` at each key before `key`, in key order. A recurrence over the keys,\n * for example a running total, then reads finished cells and does not go deep into the call stack.\n */\n warm(column: string, key: string): void {\n this.#warmTo(column, key);\n }\n}\n","/**\n * The typed builder. Method calls make an expression of the IR. The builder has no other job: it does not\n * evaluate anything until a caller asks for a value.\n */\nimport type { AnyDomain, Domain, OpSpec } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { evaluate, explain, type EvalOptions, type ExtHandler, type FreeFn } from \"./evaluate.ts\";\nimport { app, each, ext, index as indexMove, key as keyMove, let_, lit, offset as offsetMove, other as otherMove, origin as originMove, parent as parentMove, rec, ref, toPath, v, type Addr, type Axis, type Expr, type Move } from \"./ir.ts\";\nimport { cell as cellRef, SheetRun } from \"./sheet.ts\";\nimport { toOptional, type Optional, type Result } from \"./result.ts\";\nimport type { Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\nimport type { VexList } from \"./list.ts\";\nimport { traversal, type Traversal } from \"./traversal.ts\";\n\n// ---------------------------------------------------------------- argument tokens\n\ndeclare const ARG_TYPE: unique symbol;\ndeclare const CHAIN_VALUE: unique symbol;\n\n/** An argument token: an expression with the static type `T` of its value. */\nexport interface Arg<T> {\n readonly kind: \"vex.arg\";\n readonly expr: Expr;\n /** This phantom member carries the type. It is not present at run time. */\n readonly [ARG_TYPE]?: T;\n}\n\nconst argToken = <T>(expr: Expr): Arg<T> => ({ kind: \"vex.arg\", expr });\n\n\n// ---------------------------------------------------------------- type helpers\n\n/** The keys of any member of a union of record types. */\ntype AllKeys<O> = O extends unknown ? keyof O : never;\n\n/** The type of field `P` in the members of `O` that have it. */\ntype FieldType<O, P extends PropertyKey> = O extends unknown ? (P extends keyof O ? O[P] : never) : never;\n\n/**\n * The merged view of a union of record types: each field of any member, with the union of its types. A record\n * without the field gives `#N/A` at run time.\n */\nexport type Merge<O> = { readonly [P in AllKeys<O>]: FieldType<O, P> };\n\n/** The keys of `O` whose values have the type `T`. */\nexport type KeysOfType<O, T> = { [P in keyof O]-?: [NonNullable<O[P]>] extends [never] ? never : NonNullable<O[P]> extends T ? P : never }[keyof O] & string;\n\n/** The method names of `D`. */\nexport type MethodKeys<D> = { [P in keyof D]-?: D[P] extends (...args: never[]) => unknown ? P : never }[keyof D] & string;\n\n/** The value type of a domain. */\nexport type DomainValue<Dm> = Dm extends Domain<string, infer D, infer _Ops> ? D : never;\n\ntype OpsOf<Dm> = Dm extends Domain<string, unknown, infer Ops> ? Ops : Dm extends { readonly ops: infer Ops } ? Ops : never;\n\n/** The op names that a chain over a value of domain `Dm` can use. */\nexport type OpNames<Dm> =\n | (keyof OpsOf<Dm> & string)\n | (Dm extends { readonly methods: \"all\" } ? MethodKeys<DomainValue<Dm>> : never);\n\ntype FnOf<Dm, M extends string> = M extends keyof OpsOf<Dm>\n ? OpsOf<Dm>[M] extends { readonly fn: (self: never, ...args: infer P) => infer R }\n ? (...args: P) => R\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never;\n\n/** The parameters of op `M` after the receiver. */\nexport type OpParams<Dm, M extends string> = FnOf<Dm, M> extends (...args: infer P) => unknown ? P : never;\n\n/** The value type that op `M` gives. */\nexport type OpReturn<Dm, M extends string> = FnOf<Dm, M> extends (...args: never[]) => infer R ? R : never;\n\ntype Lifts<Dm, M extends string> = M extends keyof OpsOf<Dm> ? (OpsOf<Dm>[M] extends { readonly liftScalar: true } ? true : false) : false;\n\n/** The first domain of `Dms` whose values include `T`, or `never`. */\nexport type DomainFor<Dms extends readonly AnyDomain[], T> = Dms extends readonly [infer H, ...infer R extends readonly AnyDomain[]]\n ? [T] extends [never]\n ? never\n : [T] extends [DomainValue<H>]\n ? H\n : DomainFor<R, T>\n : never;\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;\ntype LastOf<U> = UnionToIntersection<U extends unknown ? () => U : never> extends () => infer R ? R : never;\n\n/** `true` if `other()` is permitted for the key type: a pair of keys, or keys that the compiler does not know. */\nexport type AllowsOther<K extends string> = string extends K\n ? true\n : `${number}` extends K\n ? true\n : [Exclude<K, LastOf<K>>] extends [never]\n ? false\n : [Exclude<Exclude<K, LastOf<K>>, LastOf<Exclude<K, LastOf<K>>>>] extends [never]\n ? true\n : false;\n\n/**\n * The inputs for an argument with the parameter type `P`. The input can be a literal of type `P`, but not a bare\n * string. It can be a field of the record with type `P`, an argument token, or a chain that gives `P`. If the op\n * lifts scalars, it can also be a number.\n */\nexport type ArgInput<P, Ctx extends ChainContext, Lift extends boolean> =\n | (P extends string ? never : P)\n | KeysOfType<Ctx[\"record\"], P>\n | Arg<P>\n | ChainOf<Ctx, P>\n | (Lift extends true ? ([P] extends [DomainValue<DomainFor<Ctx[\"domains\"], P>>] ? LiftedNumber<Ctx> : never) : never);\n\n/**\n * A number argument for a domain parameter of an op with `liftScalar` (TYPE.LIFT): a number, a field with numbers, an\n * argument or a chain. The interpreter lifts each of them with `fromScalar` (CALL.LIFT).\n */\ntype LiftedNumber<Ctx extends ChainContext> = number | KeysOfType<Ctx[\"record\"], number> | Arg<number> | ChainOf<Ctx, number>;\n\ntype MapArgs<P extends readonly unknown[], Ctx extends ChainContext, Lift extends boolean> = { [I in keyof P]: ArgInput<P[I], Ctx, Lift> };\n\n/** A table of free functions. The first parameter of a function gets the current value of the chain. */\nexport type FnTable = Readonly<Record<string, (...args: never[]) => unknown>>;\n\n/** The free functions of a builder without `withOptions`: none, so `call` accepts no name. */\n// oxlint-disable-next-line typescript/no-generated-empty-object-type -- an empty table is the intent.\nexport type NoFns = Record<never, never>;\n\n/** The static context of a chain: its domains, its key type, its record type and its free functions. */\nexport interface ChainContext {\n readonly domains: readonly AnyDomain[];\n readonly keys: string;\n readonly record: unknown;\n readonly fns?: FnTable;\n}\n\ntype FnsOf<Ctx extends ChainContext> = NonNullable<Ctx[\"fns\"]>;\ntype FnParams<F> = F extends (...args: infer P) => unknown ? P : never;\ntype FirstParam<P> = P extends readonly [infer A, ...unknown[]] ? A : unknown;\ntype RestParams<P> = P extends readonly [unknown, ...infer R] ? R : [];\n\n/** The names of the free functions whose first parameter accepts a value of type `T`. */\nexport type CallableFns<Ctx extends ChainContext, T> = {\n [K in keyof FnsOf<Ctx>]: [T] extends [FirstParam<FnParams<FnsOf<Ctx>[K]>>] ? K : never;\n}[keyof FnsOf<Ctx>] &\n string;\n\n/** The inputs for the parameters of the free function `N` after its first parameter. */\nexport type CallArgs<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = MapArgs<RestParams<FnParams<FnsOf<Ctx>[N]>>, Ctx, false>;\n\n/** The return type of the free function `N`. */\nexport type CallReturn<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = FnsOf<Ctx>[N] extends (...args: never[]) => infer R ? R : unknown;\n\n/** The ops section `._` of a chain whose value has domain `Dm`. */\nexport type OpsProxy<Ctx extends ChainContext, Dm> = {\n readonly [M in OpNames<Dm>]: (...args: MapArgs<OpParams<Dm, M>, Ctx, Lifts<Dm, M>>) => ChainOf<Ctx, OpReturn<Dm, M>>;\n};\n\n// ---------------------------------------------------------------- chain types\n\n/** The members of every chain. */\nexport interface ChainBase<Ctx extends ChainContext, T> {\n readonly kind: \"vex.chain\";\n /** This phantom member carries the value type. It is not present at run time. */\n readonly [CHAIN_VALUE]?: T;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /** This method evaluates the chain at a key. An error gives `none`. */\n at(k: Ctx[\"keys\"]): Optional<T>;\n /** This method is the same as `at`. The v0.9 spec calls it `value`. */\n value(k: Ctx[\"keys\"]): Optional<T>;\n /** This method evaluates the chain at a key, and gives the error if there is one. */\n result(k: Ctx[\"keys\"]): Result<T>;\n /** This method evaluates the chain at a key, with a trace of each node. */\n explain(k: Ctx[\"keys\"]): Trace;\n /** This method evaluates the chain at each key of the space (the start axis). */\n all(): Traversal<Ctx[\"keys\"], T>;\n /** This method gives a chain whose value is a field of the record at the current address. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** Navigation: later field references read at the key `k`. */\n to(k: Ctx[\"keys\"]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the key with this position in the key order. */\n index(i: number): ChainOf<Ctx, T>;\n /** Navigation: later field references read at a relative position in an array or a grid. */\n offset(...d: readonly number[]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the origin again. */\n origin(): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the parent of the focus, in a tree space. A root gives `#REF!`. */\n parent(): ChainOf<Ctx, T>;\n /** This method uses `fallback` when the chain gives an error. */\n ifError<U>(fallback: ArgInput<U, Ctx, false> | T): ChainOf<Ctx, T | U>;\n /**\n * This method gives `then` when the boolean value is true, and `otherwise` when it is false (the form `if`). Only\n * the selected branch evaluates.\n */\n if<U, V>(this: ChainBase<Ctx, boolean>, then: ArgInput<U, Ctx, false>, otherwise: ArgInput<V, Ctx, false>): ChainOf<Ctx, U | V>;\n /**\n * This method applies the free function `name` of `withOptions`. The function gets the current value as its first\n * argument, then `args`. The types accept only the functions whose first parameter accepts the current value.\n */\n call<N extends CallableFns<Ctx, T>>(name: N, ...args: CallArgs<Ctx, N>): ChainOf<Ctx, CallReturn<Ctx, N>>;\n /** This method evaluates each branch with the current value, and gives a record of the results. */\n fork<const B extends Readonly<Record<string, (c: ChainOf<Ctx, T>) => ChainBase<Ctx, unknown>>>>(branches: B): ChainOf<Ctx, { readonly [N in keyof B]: ValueOf<ReturnType<B[N]>> }>;\n /** This method binds names for the body. The body gets a variable token for each name. */\n with<const B extends Readonly<Record<string, unknown>>, U>(\n binds: B,\n body: (c: ChainOf<Ctx, T>, vars: { readonly [N in keyof B]: Arg<ArgValue<Ctx, B[N]>> }) => ChainBase<Ctx, U>,\n ): ChainOf<Ctx, U>;\n /** The others axis: the body evaluates at each key except the focus. Its start value is the current value. */\n others<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The neighbors axis of a grid. */\n neighbors<U>(n: 4 | 8, body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The all axis inside the expression: the body evaluates at each key, with the current value as start value. */\n each<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The children axis of a tree space: the body evaluates at each child of the focus. */\n children<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The ancestors axis of a tree space: the parent first, the root last. */\n ancestors<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The descendants axis of a tree space: depth first, each parent before its children. */\n descendants<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The siblings axis of a tree space: the other children of the parent, or the other roots for a root. */\n siblings<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n}\n\n/** The options of an axis. */\nexport interface AxisOpts<Ctx extends ChainContext, T> {\n /** A test at each target. The body evaluates only at the targets where the test gives `true`. */\n readonly where?: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, boolean>;\n}\n\n/** The members of a chain whose value has a domain. */\nexport interface DomainMembers<Ctx extends ChainContext, Dm> {\n /** The ops of the domain of the current value. */\n readonly _: OpsProxy<Ctx, Dm>;\n}\n\n/** The members of a chain over a space whose keys permit `other()`. */\nexport interface OtherMembers<Ctx extends ChainContext, T> {\n /** Navigation: later field references read at the other key of the pair. */\n other(): ChainOf<Ctx, T>;\n}\n\n/** A chain with the current value type `T`. */\nexport type ChainOf<Ctx extends ChainContext, T> = ChainBase<Ctx, T> &\n ([DomainFor<Ctx[\"domains\"], T>] extends [never] ? unknown : DomainMembers<Ctx, DomainFor<Ctx[\"domains\"], T>>) &\n (AllowsOther<Ctx[\"keys\"]> extends true ? OtherMembers<Ctx, T> : unknown);\n\n/** The value type of a chain. */\nexport type ValueOf<C> = C extends { readonly [CHAIN_VALUE]?: infer T } ? T : never;\n\n/** The value type of an argument input. */\nexport type ArgValue<Ctx extends ChainContext, A> = A extends Arg<infer T>\n ? T\n : A extends { readonly kind: \"vex.chain\" }\n ? ValueOf<A>\n : A extends keyof Ctx[\"record\"] & string\n ? NonNullable<Ctx[\"record\"][A]>\n : A;\n\n/** A chain whose value is a list: the result of an axis. */\nexport interface ListChain<Ctx extends ChainContext, U> {\n readonly kind: \"vex.list-chain\";\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n count(opts?: ListOpts): ChainOf<Ctx, number>;\n sum(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n mean(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n min(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n max(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n any(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n all(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n none(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n values(opts?: ListOpts): ChainOf<Ctx, readonly U[]>;\n /** The keys of the items with a value, in the order of the axis. */\n keys(opts?: ListOpts): ChainOf<Ctx, readonly Ctx[\"keys\"][]>;\n /** The error of each item that failed, in the order of the axis. */\n errors(): ChainOf<Ctx, readonly VexError[]>;\n first(opts?: ListOpts): ChainOf<Ctx, U>;\n reduce(op: OpNames<DomainFor<Ctx[\"domains\"], U>>, opts?: ReduceOpts<Ctx>): ChainOf<Ctx, U>;\n /** The list at the origin `k`: one item for each target of the axis, with its key and its result. */\n result(k: Ctx[\"keys\"]): Result<VexList<U>>;\n /** The list at the origin `k`, as an `Optional`. */\n at(k: Ctx[\"keys\"]): Optional<VexList<U>>;\n /** The trace of the evaluation of the list at the origin `k`. */\n explain(k: Ctx[\"keys\"]): Trace;\n}\n\n/** The options of a list reduction. */\nexport interface ListOpts {\n /** With `true`, an error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n\n/** The options of `reduce`. `domain` names the domain whose identity an empty list gives (LIST.EMPTY). */\nexport interface ReduceOpts<Ctx extends ChainContext> extends ListOpts {\n readonly domain?: Ctx[\"domains\"][number][\"name\"];\n}\n\n/** The root of the builder for one space. */\nexport interface Root<Ctx extends ChainContext> {\n /** This method starts a chain with a field of the record at the focus. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** This method starts a chain with a value. A string is a field reference, as in an argument. */\n start<const T>(value: T): ChainOf<Ctx, ArgValue<Ctx, T>>;\n /** This method makes an absolute reference: the field of the record at key `k`. */\n of<P extends keyof Ctx[\"record\"] & string>(k: Ctx[\"keys\"], field: P): Arg<NonNullable<Ctx[\"record\"][P]>>;\n /** This method makes a reference to a dotted path at the focus, with the type that the caller gives. */\n field<T>(path: string): Arg<T>;\n /** This method makes a literal argument. Use it for a string or an array: a bare string is a field reference. */\n lit<const T>(value: T): Arg<T>;\n /** This method makes an absolute reference to a dotted path at key `k`, with the type that the caller gives. */\n ofPath<T>(k: Ctx[\"keys\"], path: string): Arg<T>;\n /** This method makes a record argument from field arguments. */\n rec<const F extends Readonly<Record<string, unknown>>>(fields: F): Arg<{ readonly [N in keyof F]: ArgValue<Ctx, F[N]> }>;\n /**\n * This method makes an extension argument: the node `ext(kind, data)`. The handler of `kind` in the options of\n * `withOptions` gives its value. The caller gives the type `T` of that value.\n */\n ext<T>(kind: string, data?: unknown): Arg<T>;\n /** This method starts a sheet over the space: named columns of formulas. Refer to `Sheet`. */\n sheet(): Sheet<Ctx, object>;\n /** The space of the root. */\n readonly space: Space<Ctx[\"keys\"], Ctx[\"record\"]>;\n}\n\n/** The root of a column formula: the root of the builder, and references to the cells of the sheet. */\nexport interface SheetRoot<Ctx extends ChainContext, Cols> extends Root<Ctx> {\n /**\n * This method makes a cell reference: the column `column` at the key `at`, or at the address `at` from the focus.\n * Without `at`, it reads at the focus. The type is the type of a column before this one.\n */\n cell<N extends keyof Cols & string>(column: N, at?: Ctx[\"keys\"] | Addr): Arg<Cols[N]>;\n /** This method makes a cell reference to any column, also this column or a later one. The caller gives the type. */\n cell<T>(column: string, at?: Ctx[\"keys\"] | Addr): Arg<T>;\n}\n\n/** One row of a sheet: the key and the result of each column. */\nexport interface SheetRow<K extends string, Cols> {\n readonly key: K;\n readonly cells: { readonly [N in keyof Cols]: Result<Cols[N]> };\n}\n\n/**\n * A sheet: named columns of formulas over a space, like the computed columns of a spreadsheet. A formula reads the\n * other columns with `cell`. Each evaluation evaluates a cell once, and each cell on a cycle of references gives\n * `#CYCLE!`. A sheet is immutable: `column` gives a new sheet.\n */\nexport interface Sheet<Ctx extends ChainContext, Cols, Decl = object> {\n /**\n * This method gives a new sheet with one more column. The formula gets a root with `cell`. If `declare` gave the\n * column a type, the formula must give a value of that type.\n */\n column<const N extends string, C extends ChainBase<Ctx, DeclaredType<Decl, N>>>(\n name: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => C,\n ): Sheet<Ctx, Cols & { readonly [P in N]: ValueOf<C> }, Decl>;\n /**\n * This method gives the types of columns before their formulas. A formula can then read a declared column with\n * `cell` and its type: the column itself (a recurrence) or a later column. It has no effect at run time.\n */\n declare<D extends Readonly<Record<string, unknown>>>(): Sheet<Ctx, Cols, Decl & D>;\n /** The program of each column. */\n readonly columns: Readonly<Record<string, Expr>>;\n /** This method evaluates one cell, and gives the error if there is one. */\n result<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Result<Cols[N]>;\n /** This method evaluates one cell. An error gives `none`. */\n at<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Optional<Cols[N]>;\n /** This method evaluates one cell, with a trace of the nodes of its column. */\n explain(k: Ctx[\"keys\"], column: keyof Cols & string): Trace;\n /** This method evaluates each cell, in key order, with one result for each cell. */\n table(): readonly SheetRow<Ctx[\"keys\"], Cols>[];\n}\n\n/** The declared type of the column `N`, or `unknown` for a column without a declaration. */\nexport type DeclaredType<Decl, N extends string> = N extends keyof Decl ? Decl[N] : unknown;\n\n/** The options of the builder. */\nexport interface VexOptions<F extends FnTable = FnTable> {\n /** Free function ops. A chain applies them with `call`. */\n readonly fns?: F;\n /** Handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** The entry point for a list of domains. */\nexport interface VexEntry<Dms extends readonly AnyDomain[], F extends FnTable = NoFns> {\n /** This method gives the root of the builder for a space. */\n over<K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }>;\n /** The domains. */\n readonly domains: Dms;\n}\n\n// ---------------------------------------------------------------- run time\n\n/** The options as the interpreter takes them: free functions get untyped arguments at run time. */\ninterface RuntimeOptions {\n readonly fns?: Readonly<Record<string, FreeFn>>;\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** This function gives the run-time form of the options. A typed free function gets the values that the types promise. */\nconst runtimeOptions = (options: VexOptions): RuntimeOptions => ({\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns as Readonly<Record<string, FreeFn>> }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n});\n\ninterface Env {\n readonly space: Space;\n readonly domains: readonly AnyDomain[];\n readonly options: RuntimeOptions;\n}\n\ninterface State {\n readonly env: Env;\n /** The current value. */\n readonly expr: Expr;\n /** The address where later field references read. */\n readonly addr: readonly Move[];\n /** The depth of nested axis and binding bodies, for unique variable names. */\n readonly depth: number;\n}\n\nconst kindOf = (u: unknown): unknown => (u as { kind?: unknown } | null | undefined)?.kind;\nconst isArg = (u: unknown): u is Arg<unknown> => kindOf(u) === \"vex.arg\";\nconst isChainLike = (u: unknown): u is { readonly program: Expr } => kindOf(u) === \"vex.chain\" || kindOf(u) === \"vex.list-chain\";\n\n/** This function turns a builder argument into an expression. A bare string is a field reference at `addr`. */\nfunction toExpr(a: unknown, addr: readonly Move[]): Expr {\n if (typeof a === \"string\") return ref(toPath(a), addr);\n if (isArg(a)) return a.expr;\n if (isChainLike(a)) return a.program;\n return lit(a);\n}\n\nconst PROXY_RESERVED = new Set([\"then\", \"catch\", \"finally\", \"toJSON\", \"valueOf\", \"toString\", \"constructor\", \"inspect\", \"asymmetricMatch\", \"$$typeof\", \"nodeType\"]);\n\nclass ChainImpl {\n readonly kind = \"vex.chain\" as const;\n readonly #s: State;\n\n constructor(s: State) {\n this.#s = s;\n }\n\n get program(): Expr {\n return this.#s.expr;\n }\n\n get _(): Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>> {\n const s = this.#s;\n return new Proxy(Object.create(null) as Record<string, never>, {\n get: (_t, prop): unknown => {\n if (typeof prop !== \"string\" || PROXY_RESERVED.has(prop)) return undefined;\n return (...args: readonly unknown[]): ChainImpl => new ChainImpl({ ...s, expr: app(prop, s.expr, ...args.map((a) => toExpr(a, s.addr))) });\n },\n });\n }\n\n #opts(k: string): EvalOptions {\n return evalOptions(this.#s, k);\n }\n\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, this.#opts(k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n value(k: string): Optional<unknown> {\n return this.at(k);\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, this.#opts(k));\n }\n all(): Traversal<string, unknown> {\n const { env } = this.#s;\n const items = env.space.keys.map((k) => ({ key: k, result: this.result(k) }));\n return traversal(items, env);\n }\n\n from(field: string): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: ref(toPath(field), this.#s.addr) });\n }\n\n #move(m: Move): ChainImpl {\n return new ChainImpl({ ...this.#s, addr: [...this.#s.addr, m] });\n }\n to(k: string): ChainImpl {\n return this.#move(keyMove(k));\n }\n index(i: number): ChainImpl {\n return this.#move(indexMove(i));\n }\n offset(...d: readonly number[]): ChainImpl {\n return this.#move(offsetMove(...d));\n }\n other(): ChainImpl {\n return this.#move(otherMove);\n }\n origin(): ChainImpl {\n return this.#move(originMove);\n }\n parent(): ChainImpl {\n return this.#move(parentMove);\n }\n\n call(name: string, ...args: readonly unknown[]): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(name, this.#s.expr, ...args.map((a) => toExpr(a, this.#s.addr))) });\n }\n if(then: unknown, otherwise: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"if\", this.#s.expr, toExpr(then, this.#s.addr), toExpr(otherwise, this.#s.addr)) });\n }\n ifError(fallback: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"ifError\", this.#s.expr, toExpr(fallback, this.#s.addr)) });\n }\n\n /** This method binds the current value to a fresh name, and gives a chain that starts from that name. */\n #bound(): { readonly name: string; readonly start: ChainImpl } {\n const name = `$${this.#s.depth}`;\n return { name, start: new ChainImpl({ ...this.#s, expr: v(name), depth: this.#s.depth + 1 }) };\n }\n\n fork(branches: Readonly<Record<string, (c: ChainImpl) => { readonly program: Expr }>>): ChainImpl {\n const { name, start } = this.#bound();\n const fields: Record<string, Expr> = {};\n for (const [n, f] of Object.entries(branches)) fields[n] = f(start).program;\n return new ChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, rec(fields)) });\n }\n\n with(binds: Readonly<Record<string, unknown>>, body: (c: ChainImpl, vars: Readonly<Record<string, Arg<unknown>>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const bindExprs: Record<string, Expr> = {};\n const vars: Record<string, Arg<unknown>> = {};\n for (const [n, a] of Object.entries(binds)) {\n const unique = `${n}$${depth}`;\n bindExprs[unique] = toExpr(a, this.#s.addr);\n vars[n] = argToken(v(unique));\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), vars);\n return new ChainImpl({ ...this.#s, expr: let_(bindExprs, inner.program) });\n }\n\n #axis(a: Axis, body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n const { name, start } = this.#bound();\n // Inside the axis, the focus is the target, so the address of the body starts empty.\n const inTarget = new ChainImpl({ ...start.#s, addr: [] });\n const inner = body(inTarget);\n const axis: Axis = opts?.where === undefined ? a : { t: \"where\", axis: a, test: opts.where(inTarget).program };\n // The moves before the axis are its address: parent().children(f) gives f at each child of the parent.\n return new ListChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, each(axis, inner.program, this.#s.addr)) });\n }\n others(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"others\" }, body, opts);\n }\n neighbors(n: 4 | 8, body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"neighbors\", n }, body, opts);\n }\n each(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"all\" }, body, opts);\n }\n children(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"children\" }, body, opts);\n }\n ancestors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"ancestors\" }, body, opts);\n }\n descendants(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"descendants\" }, body, opts);\n }\n siblings(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"siblings\" }, body, opts);\n }\n}\n\n/** This function gives the options of an evaluation of a chain or a list chain at the origin `k`. */\nfunction evalOptions(s: State, k: string): EvalOptions {\n const { env } = s;\n return {\n space: env.space,\n origin: k,\n domains: env.domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.fns === undefined ? {} : { fns: env.options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.extensions === undefined ? {} : { extensions: env.options.extensions }),\n };\n}\n\nclass ListChainImpl {\n readonly kind = \"vex.list-chain\" as const;\n readonly #s: State;\n constructor(s: State) {\n this.#s = s;\n }\n get program(): Expr {\n return this.#s.expr;\n }\n #op(op: string, extra: readonly Expr[], opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n const options = { ...(opts?.strict === true ? { strict: true } : {}), ...(opts?.domain === undefined ? {} : { domain: opts.domain }) };\n const args = Object.keys(options).length > 0 ? [...extra, lit(options)] : extra;\n return new ChainImpl({ ...this.#s, expr: app(op, this.#s.expr, ...args) });\n }\n count(opts?: ListOpts): ChainImpl {\n return this.#op(\"count\", [], opts);\n }\n sum(opts?: ListOpts): ChainImpl {\n return this.#op(\"sum\", [], opts);\n }\n mean(opts?: ListOpts): ChainImpl {\n return this.#op(\"mean\", [], opts);\n }\n min(opts?: ListOpts): ChainImpl {\n return this.#op(\"min\", [], opts);\n }\n max(opts?: ListOpts): ChainImpl {\n return this.#op(\"max\", [], opts);\n }\n any(opts?: ListOpts): ChainImpl {\n return this.#op(\"any\", [], opts);\n }\n all(opts?: ListOpts): ChainImpl {\n return this.#op(\"all\", [], opts);\n }\n none(opts?: ListOpts): ChainImpl {\n return this.#op(\"none\", [], opts);\n }\n values(opts?: ListOpts): ChainImpl {\n return this.#op(\"values\", [], opts);\n }\n keys(opts?: ListOpts): ChainImpl {\n return this.#op(\"keys\", [], opts);\n }\n errors(): ChainImpl {\n return this.#op(\"errors\", []);\n }\n first(opts?: ListOpts): ChainImpl {\n return this.#op(\"first\", [], opts);\n }\n reduce(op: string, opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n return this.#op(\"reduce\", [lit(op)], opts);\n }\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, evalOptions(this.#s, k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, evalOptions(this.#s, k));\n }\n}\n\nclass RootImpl {\n readonly #env: Env;\n constructor(env: Env) {\n this.#env = env;\n }\n get space(): Space {\n return this.#env.space;\n }\n #chain(expr: Expr): ChainImpl {\n return new ChainImpl({ env: this.#env, expr, addr: [], depth: 0 });\n }\n from(field: string): ChainImpl {\n return this.#chain(ref(toPath(field)));\n }\n start(value: unknown): ChainImpl {\n return this.#chain(toExpr(value, []));\n }\n of(k: string, field: string): Arg<unknown> {\n return argToken(ref(toPath(field), [keyMove(k)]));\n }\n field(path: string): Arg<unknown> {\n return argToken(ref(toPath(path)));\n }\n lit(value: unknown): Arg<unknown> {\n return argToken(lit(value));\n }\n ofPath(k: string, path: string): Arg<unknown> {\n return argToken(ref(toPath(path), [keyMove(k)]));\n }\n ext(kind: string, data: unknown = null): Arg<unknown> {\n return argToken(ext(kind, data));\n }\n sheet(): SheetImpl {\n return new SheetImpl(this.#env, new Map());\n }\n rec(fields: Readonly<Record<string, unknown>>): Arg<unknown> {\n const out: Record<string, Expr> = {};\n for (const [n, a] of Object.entries(fields)) out[n] = toExpr(a, []);\n return argToken(rec(out));\n }\n}\n\nclass SheetRootImpl extends RootImpl {\n cell(column: string, at?: string | Addr): Arg<unknown> {\n return argToken(cellRef(column, typeof at === \"string\" ? [keyMove(at)] : at));\n }\n}\n\nclass SheetImpl {\n readonly #env: Env;\n readonly #columns: ReadonlyMap<string, Expr>;\n constructor(env: Env, columns: ReadonlyMap<string, Expr>) {\n this.#env = env;\n this.#columns = columns;\n }\n get columns(): Readonly<Record<string, Expr>> {\n return Object.freeze(Object.fromEntries(this.#columns));\n }\n declare(): SheetImpl {\n return this;\n }\n column(name: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n return new SheetImpl(this.#env, new Map([...this.#columns, [name, program]]));\n }\n #run(): SheetRun {\n const { space: s, domains, options } = this.#env;\n return new SheetRun(this.#columns, {\n space: s,\n domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n });\n }\n result(k: string, column: string): Result<unknown> {\n const run = this.#run();\n run.warm(column, k);\n return run.cell(column, k);\n }\n at(k: string, column: string): Optional<unknown> {\n return toOptional(this.result(k, column));\n }\n explain(k: string, column: string): Trace {\n const run = this.#run();\n run.warm(column, k);\n return run.explain(column, k);\n }\n table(): readonly SheetRow<string, Record<string, unknown>>[] {\n const run = this.#run();\n const names = [...this.#columns.keys()];\n return this.#env.space.keys.map((key) => ({ key, cells: Object.fromEntries(names.map((c) => [c, run.cell(c, key)])) }));\n }\n}\n\n/**\n * This function gives the entry point of the builder for a list of domains. The interpreter finds the op of a\n * value in the first domain that accepts the value.\n */\nexport function vex<const Dms extends readonly AnyDomain[]>(\n ...domains: Dms\n): VexEntry<Dms> & { withOptions<const F extends FnTable = NoFns>(options: VexOptions<F>): VexEntry<Dms, F> } {\n const make = <F extends FnTable>(options: VexOptions<F>): VexEntry<Dms, F> => ({\n domains,\n over: <K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }> =>\n new RootImpl({ space: s, domains, options: runtimeOptions(options) }) as unknown as Root<{\n readonly domains: Dms;\n readonly keys: K;\n readonly record: Merge<O>;\n readonly fns: F;\n }>,\n });\n return { ...make<NoFns>({}), withOptions: make };\n}\n\n/** The type of a domain value, from the domain object. */\nexport type ValueOfDomain<Dm> = DomainValue<Dm>;\n\n/** An op specification type, for domain authors. */\nexport type { OpSpec };\n"],"mappings":";AAaA,MAAM,OAAwB,OAAO,OAAO,EAAE,KAAK,OAAO,CAAC;;AAG3D,MAAa,QAAW,WAA2B;CAAE,KAAK;CAAQ;AAAM;;AAGxE,MAAa,aAAqC;;AAGlD,MAAa,MAAS,WAAyB;CAAE,IAAI;CAAM;AAAM;;AAGjE,MAAa,QAAmB,WAAgC;CAAE,IAAI;CAAO;AAAM;;AAGnF,MAAa,UAAa,MAAqE,EAAE,QAAQ;;AAGzG,MAAa,UAAa,M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AAmC;EAC/C,OAAO,WAAW,KAAK,OAAO,GAAG,MAAM,CAAC;CAC1C;CACA,QAAQ,GAAW,QAAuB;EACxC,MAAM,MAAM,KAAK,KAAK;EACtB,IAAI,KAAK,QAAQ,CAAC;EAClB,OAAO,IAAI,QAAQ,QAAQ,CAAC;CAC9B;CACA,QAA8D;EAC5D,MAAM,MAAM,KAAK,KAAK;EACtB,MAAM,QAAQ,CAAC,GAAG,KAAK,SAAS,KAAK,CAAC;EACtC,OAAO,KAAK,KAAK,MAAM,KAAK,KAAK,SAAS;GAAE;GAAK,OAAO,OAAO,YAAY,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;EAAE,EAAE;CACxH;AACF;;;;;AAMA,SAAgB,IACd,GAAG,SACyG;CAC5G,MAAM,QAA2B,aAA8C;EAC7E;EACA,OAA4B,MAC1B,IAAI,SAAS;GAAE,OAAO;GAAG;GAAS,SAAS,eAAe,OAAO;EAAE,CAAC;CAMxE;CACA,OAAO;EAAE,GAAG,KAAY,CAAC,CAAC;EAAG,aAAa;CAAK;AACjD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["spaces","keyMove","indexMove","offsetMove","otherMove","originMove","parentMove","cellRef"],"sources":["../src/result.ts","../src/errors.ts","../src/ir.ts","../src/space.ts","../src/domain.ts","../src/list.ts","../src/evaluate.ts","../src/deps.ts","../src/json.ts","../src/traversal.ts","../src/sheet.ts","../src/builder.ts"],"sourcesContent":["import type { Optional as FamilyOptional } from \"@mark1russell7/optional\";\nimport type { VexError } from \"./errors.ts\";\n\n/**\n * A value that is there, or not there. This is the public result of a Vex program. It is the Optional of the\n * family (`@mark1russell7/optional`), so render and Vex give and take the same values. The import is a type import\n * only: the build copies the type into the declarations, so the package has no runtime dependency.\n */\nexport type Optional<T> = FamilyOptional<T>;\n\n/** A value, or the error that tells why there is no value. The interpreter uses this type. */\nexport type Result<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly error: VexError };\n\nconst NONE: Optional<never> = Object.freeze({ tag: \"none\" });\n\n/** This function makes an `Optional` that holds `value`. */\nexport const some = <T>(value: T): Optional<T> => ({ tag: \"some\", value });\n\n/** This function gives the shared empty `Optional`. */\nexport const none = <T = never>(): Optional<T> => NONE;\n\n/** This function makes a successful `Result`. */\nexport const ok = <T>(value: T): Result<T> => ({ ok: true, value });\n\n/** This function makes a failed `Result`. */\nexport const fail = <T = never>(error: VexError): Result<T> => ({ ok: false, error });\n\n/** This function tells if an `Optional` holds a value. */\nexport const isSome = <T>(o: Optional<T>): o is { readonly tag: \"some\"; readonly value: T } => o.tag === \"some\";\n\n/** This function tells if an `Optional` is empty. */\nexport const isNone = <T>(o: Optional<T>): o is { readonly tag: \"none\" } => o.tag === \"none\";\n\n/** This function changes a `Result` into an `Optional`. The error is lost. */\nexport const toOptional = <T>(r: Result<T>): Optional<T> => (r.ok ? some(r.value) : none());\n\n/** This function gives the value of an `Optional`, or `fallback` if it is empty. */\nexport const getOr = <T, U>(o: Optional<T>, fallback: U): T | U => (o.tag === \"some\" ? o.value : fallback);\n\n/** This function applies `f` to the value of a `Result`. An error stays the same. */\nexport const mapResult = <T, U>(r: Result<T>, f: (value: T) => U): Result<U> => (r.ok ? ok(f(r.value)) : r);\n\n/** This function applies `f` to the value of a `Result`, and `f` gives a `Result`. An error stays the same. */\nexport const chainResult = <T, U>(r: Result<T>, f: (value: T) => Result<U>): Result<U> => (r.ok ? f(r.value) : r);\n","/**\n * The error codes of Vex. The names come from the spreadsheet error values, because a Vex program is a\n * spreadsheet formula over records.\n */\nexport type ErrorCode = \"#REF!\" | \"#N/A\" | \"#VALUE!\" | \"#NAME?\" | \"#NUM!\" | \"#CALC!\" | \"#ARGS\" | \"#CYCLE!\" | \"#DEPTH!\";\n\n/** The cause of an error, in more detail than the code. */\nexport type ErrorKind =\n | \"unknown-key\"\n | \"not-a-pair\"\n | \"out-of-bounds\"\n | \"no-offset\"\n | \"no-grid\"\n | \"no-tree\"\n | \"missing-field\"\n | \"empty\"\n | \"not-instance\"\n | \"kind-mismatch\"\n | \"unknown-op\"\n | \"unbound\"\n | \"not-finite\"\n | \"invalid-value\"\n | \"threw\"\n | \"undefined-result\"\n | \"args\"\n | \"cycle\"\n | \"depth\"\n | \"bad-expression\";\n\nconst CODE_OF: Readonly<Record<ErrorKind, ErrorCode>> = {\n \"unknown-key\": \"#REF!\",\n \"not-a-pair\": \"#REF!\",\n \"out-of-bounds\": \"#REF!\",\n \"no-offset\": \"#REF!\",\n \"no-grid\": \"#REF!\",\n \"no-tree\": \"#REF!\",\n \"missing-field\": \"#N/A\",\n empty: \"#N/A\",\n \"not-instance\": \"#VALUE!\",\n \"kind-mismatch\": \"#VALUE!\",\n \"bad-expression\": \"#VALUE!\",\n \"unknown-op\": \"#NAME?\",\n unbound: \"#NAME?\",\n \"not-finite\": \"#NUM!\",\n \"invalid-value\": \"#NUM!\",\n threw: \"#CALC!\",\n \"undefined-result\": \"#CALC!\",\n args: \"#ARGS\",\n cycle: \"#CYCLE!\",\n depth: \"#DEPTH!\",\n};\n\n/**\n * This function tells if an exception is the report of the engine that the call stack is full. V8 and JavaScriptCore\n * throw a `RangeError`. SpiderMonkey throws an `InternalError` (\"too much recursion\").\n */\nexport function isStackOverflow(thrown: unknown): boolean {\n if (!(thrown instanceof Error)) return false;\n return (thrown instanceof RangeError && /call stack/i.test(thrown.message)) || (thrown.name === \"InternalError\" && /recursion/i.test(thrown.message));\n}\n\n/** This function tells if an error is `#DEPTH!`. `ifError` and the reductions that skip errors do not hide it (EVAL.DEPTH). */\nexport const isDepthError = (e: VexError): boolean => e.kind === \"depth\";\n\n/** A Vex error. It is a value: a program can catch it with `ifError`, except `#DEPTH!`. */\nexport interface VexError {\n /** The spreadsheet-style code, for example `#REF!`. */\n readonly code: ErrorCode;\n /** The cause in more detail. */\n readonly kind: ErrorKind;\n /** A sentence that tells what went wrong. */\n readonly message: string;\n /** The position of the failed node in the expression tree. The root is `[]`. */\n readonly path: readonly number[];\n /** The key where the evaluation started. */\n readonly origin?: string;\n /** The key where relative references read when the error occurred. */\n readonly focus?: string;\n /** The op name, for errors of an op. */\n readonly op?: string;\n /** The errors of the arguments, for the code `#ARGS`. */\n readonly causes?: readonly VexError[];\n /** The value that an op threw, for the kind `threw`. */\n readonly thrown?: unknown;\n}\n\n/** The details that a caller can give to `vexError`. */\nexport interface ErrorDetails {\n readonly path?: readonly number[];\n readonly origin?: string;\n readonly focus?: string;\n readonly op?: string;\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function gives the code of an error kind. */\nexport const codeOf = (kind: ErrorKind): ErrorCode => CODE_OF[kind];\n\n/** This function makes a `VexError`. */\nexport function vexError(kind: ErrorKind, message: string, details: ErrorDetails = {}): VexError {\n return {\n code: CODE_OF[kind],\n kind,\n message,\n path: details.path ?? [],\n ...(details.origin === undefined ? {} : { origin: details.origin }),\n ...(details.focus === undefined ? {} : { focus: details.focus }),\n ...(details.op === undefined ? {} : { op: details.op }),\n ...(details.causes === undefined ? {} : { causes: details.causes }),\n ...(details.thrown === undefined ? {} : { thrown: details.thrown }),\n };\n}\n\n/** This function gives a short text for an error, for example `#REF! unknown-key: there is no key \"Z\"`. */\nexport const formatError = (e: VexError): string => `${e.code} ${e.kind}: ${e.message}`;\n","/**\n * The expression IR of Vex. It is plain JSON data. Its first three kinds (`lit`, `ref`, `app`) have the same\n * shape as the expressions of `render`.\n */\n\n/** One move of an address. The moves of an address apply in order, from the focus of the evaluation. */\nexport type Move =\n | { readonly t: \"key\"; readonly key: string }\n | { readonly t: \"index\"; readonly i: number }\n | { readonly t: \"other\" }\n | { readonly t: \"offset\"; readonly d: readonly number[] }\n | { readonly t: \"origin\" }\n | { readonly t: \"parent\" };\n\n/** An address: a list of moves. The empty list is the focus. */\nexport type Addr = readonly Move[];\n\n/** An axis: the relation between a position and the targets that a body reads. */\nexport type Axis =\n | { readonly t: \"all\" }\n | { readonly t: \"others\" }\n | { readonly t: \"other\" }\n | { readonly t: \"neighbors\"; readonly n: 4 | 8 }\n | { readonly t: \"children\" }\n | { readonly t: \"ancestors\" }\n | { readonly t: \"descendants\" }\n | { readonly t: \"siblings\" }\n | { readonly t: \"where\"; readonly axis: Axis; readonly test: Expr };\n\n/** A Vex expression. */\nexport type Expr =\n | { readonly tag: \"lit\"; readonly value: unknown }\n | { readonly tag: \"ref\"; readonly path: readonly string[]; readonly at?: Addr }\n | { readonly tag: \"app\"; readonly op: string; readonly args: readonly Expr[] }\n | { readonly tag: \"let\"; readonly bind: Readonly<Record<string, Expr>>; readonly body: Expr }\n | { readonly tag: \"var\"; readonly name: string }\n | { readonly tag: \"rec\"; readonly fields: Readonly<Record<string, Expr>> }\n | { readonly tag: \"each\"; readonly axis: Axis; readonly body: Expr; readonly at?: Addr }\n | { readonly tag: \"ext\"; readonly kind: string; readonly data: unknown };\n\n/** The tag of an expression kind. */\nexport type ExprTag = Expr[\"tag\"];\n\n/** An expression of one kind. */\nexport type ExprOf<T extends ExprTag> = Extract<Expr, { readonly tag: T }>;\n\n// ---------------------------------------------------------------- constructors\n\n/** This function makes a literal. */\nexport const lit = (value: unknown): ExprOf<\"lit\"> => ({ tag: \"lit\", value });\n\n/** This function splits a dotted path, for example `\"pos.x\"`, into its segments. */\nexport const toPath = (path: string | readonly string[]): readonly string[] =>\n typeof path === \"string\" ? path.split(\".\").filter((s) => s.length > 0) : path;\n\n/** This function makes a reference to a field path. With `at`, the reference reads at that address. */\nexport function ref(path: string | readonly string[], at?: Addr): ExprOf<\"ref\"> {\n const segments = toPath(path);\n return at === undefined || at.length === 0 ? { tag: \"ref\", path: segments } : { tag: \"ref\", path: segments, at };\n}\n\n/** This function makes the application of an op to arguments. For a method op, the first argument is the receiver. */\nexport const app = (op: string, ...args: readonly Expr[]): ExprOf<\"app\"> => ({ tag: \"app\", op, args });\n\n/** This function binds names to expressions for the body. */\nexport const let_ = (bind: Readonly<Record<string, Expr>>, body: Expr): ExprOf<\"let\"> => ({ tag: \"let\", bind, body });\n\n/** This function makes a reference to a bound name. */\nexport const v = (name: string): ExprOf<\"var\"> => ({ tag: \"var\", name });\n\n/** This function makes a record from field expressions. */\nexport const rec = (fields: Readonly<Record<string, Expr>>): ExprOf<\"rec\"> => ({ tag: \"rec\", fields });\n\n/**\n * This function evaluates `body` once for each target of `axis`. The result is a list. With `at`, the axis finds its\n * targets from the key of that address, not from the focus.\n */\nexport function each(axis: Axis, body: Expr, at?: Addr): ExprOf<\"each\"> {\n return at === undefined || at.length === 0 ? { tag: \"each\", axis, body } : { tag: \"each\", axis, body, at };\n}\n\n/** This function makes an expression of an extension kind. */\nexport const ext = (kind: string, data: unknown): ExprOf<\"ext\"> => ({ tag: \"ext\", kind, data });\n\n// ---------------------------------------------------------------- moves and axes\n\n/** The move to an absolute key. */\nexport const key = (k: string): Move => ({ t: \"key\", key: k });\n/** The move to a position in the key order. */\nexport const index = (i: number): Move => ({ t: \"index\", i });\n/** The move to the other key of a space with two keys. */\nexport const other: Move = Object.freeze({ t: \"other\" });\n/** The relative move in an array (one number) or a grid (two numbers). */\nexport const offset = (...d: readonly number[]): Move => ({ t: \"offset\", d });\n/** The move back to the origin of the evaluation. */\nexport const origin: Move = Object.freeze({ t: \"origin\" });\n/** The move to the parent of the focus in a tree space. */\nexport const parent: Move = Object.freeze({ t: \"parent\" });\n\n/** The axes. */\nexport const axes = {\n /** Each key of the space. */\n all: Object.freeze({ t: \"all\" }) as Axis,\n /** Each key except the focus. */\n others: Object.freeze({ t: \"others\" }) as Axis,\n /** The other key of a pair. */\n other: Object.freeze({ t: \"other\" }) as Axis,\n /** The neighbors of the focus in a grid. */\n neighbors: (n: 4 | 8 = 8): Axis => ({ t: \"neighbors\", n }),\n /** The children of the focus in a tree, in key order. */\n children: Object.freeze({ t: \"children\" }) as Axis,\n /** The ancestors of the focus in a tree: the parent first, the root last. */\n ancestors: Object.freeze({ t: \"ancestors\" }) as Axis,\n /** The descendants of the focus in a tree, depth first, each parent before its children. */\n descendants: Object.freeze({ t: \"descendants\" }) as Axis,\n /** The other children of the parent of the focus. For a root, the other roots. */\n siblings: Object.freeze({ t: \"siblings\" }) as Axis,\n /** The targets of `axis` where `test` gives `true`. */\n where: (axis: Axis, test: Expr): Axis => ({ t: \"where\", axis, test }),\n} as const;\n\n// ---------------------------------------------------------------- validation\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\nconst isStringArray = (u: unknown): u is readonly string[] => Array.isArray(u) && u.every((s) => typeof s === \"string\");\n\n/** This function tells if a value is a valid move. */\nexport function isMove(u: unknown): u is Move {\n if (!isObject(u)) return false;\n switch (u[\"t\"]) {\n case \"key\":\n return typeof u[\"key\"] === \"string\";\n case \"index\":\n return Number.isInteger(u[\"i\"]);\n case \"offset\":\n return Array.isArray(u[\"d\"]) && u[\"d\"].every((n) => Number.isInteger(n));\n case \"other\":\n case \"origin\":\n case \"parent\":\n return true;\n default:\n return false;\n }\n}\n\n/** This function tells if a value is a valid axis. It checks the tests of `where` too. */\nexport function isAxis(u: unknown): u is Axis {\n return validTree([{ axis: true, u }]);\n}\n\n/** This function tells if a value is a valid expression. It checks the whole tree. */\nexport function isExpr(u: unknown): u is Expr {\n return validTree([{ axis: false, u }]);\n}\n\nconst isAddr = (u: unknown): boolean => u === undefined || (Array.isArray(u) && u.every(isMove));\n\n/**\n * This function checks a tree of expressions and axes. It uses a stack, not recursion, so the input can be deep. For\n * example, a deep JSON file from a stranger does not need a deep call stack (EVAL.NESTING).\n */\nfunction validTree(todo: { readonly axis: boolean; readonly u: unknown }[]): boolean {\n const push = (axis: boolean, values: readonly unknown[]): void => {\n for (const u of values) todo.push({ axis, u });\n };\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const { u } = item;\n if (!isObject(u)) return false;\n if (item.axis) {\n const t = u[\"t\"];\n if (t === \"neighbors\") {\n if (u[\"n\"] !== 4 && u[\"n\"] !== 8) return false;\n } else if (t === \"where\") {\n push(true, [u[\"axis\"]]);\n push(false, [u[\"test\"]]);\n } else if (![\"all\", \"others\", \"other\", \"children\", \"ancestors\", \"descendants\", \"siblings\"].includes(t as string)) {\n return false;\n }\n continue;\n }\n switch (u[\"tag\"]) {\n case \"lit\":\n if (!(\"value\" in u)) return false;\n break;\n case \"ref\":\n if (!isStringArray(u[\"path\"]) || !isAddr(u[\"at\"])) return false;\n break;\n case \"app\":\n if (typeof u[\"op\"] !== \"string\" || !Array.isArray(u[\"args\"])) return false;\n push(false, u[\"args\"]);\n break;\n case \"let\":\n if (!isObject(u[\"bind\"]) || Array.isArray(u[\"bind\"])) return false;\n push(false, [...Object.values(u[\"bind\"]), u[\"body\"]]);\n break;\n case \"var\":\n if (typeof u[\"name\"] !== \"string\") return false;\n break;\n case \"rec\":\n if (!isObject(u[\"fields\"]) || Array.isArray(u[\"fields\"])) return false;\n push(false, Object.values(u[\"fields\"]));\n break;\n case \"each\":\n if (!isAddr(u[\"at\"])) return false;\n push(true, [u[\"axis\"]]);\n push(false, [u[\"body\"]]);\n break;\n case \"ext\":\n if (typeof u[\"kind\"] !== \"string\" || !(\"data\" in u)) return false;\n break;\n default:\n return false;\n }\n }\n return true;\n}\n\n/** This function gives the child expressions of an expression, in the order of their child index. */\nexport function children(e: Expr): readonly Expr[] {\n switch (e.tag) {\n case \"app\":\n return e.args;\n case \"let\":\n return [...Object.values(e.bind), e.body];\n case \"rec\":\n return Object.values(e.fields);\n case \"each\":\n return [e.body, ...whereTests(e.axis)];\n case \"lit\":\n case \"ref\":\n case \"var\":\n case \"ext\":\n return [];\n }\n}\n\n/** This function gives the tests of the `where` axes of an axis, from the inside out. It uses a loop, not recursion. */\nfunction whereTests(a: Axis): readonly Expr[] {\n const out: Expr[] = [];\n for (let x: Axis = a; x.t === \"where\"; x = x.axis) out.unshift(x.test);\n return out;\n}\n","import { vexError } from \"./errors.ts\";\nimport type { Addr, Axis, Move } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** The kind of a space. The kind sets which moves and axes are valid. */\nexport type SpaceKind = \"record\" | \"array\" | \"grid\" | \"tree\";\n\n/**\n * A space: an immutable collection of records with keys. A Vex program evaluates at one key of a space.\n * Nothing changes a space after it is made.\n */\nexport interface Space<K extends string = string, O = unknown> {\n readonly kind: SpaceKind;\n /** The keys, in their order. */\n readonly keys: readonly K[];\n /** This function tells if the space has the key `k`. */\n has(k: string): k is K;\n /** This function gives the record at the key `k`, or `undefined`. */\n get(k: string): O | undefined;\n /** The position of each key, for array and grid spaces. An array key has one number, a grid key has two. */\n coords(k: string): readonly number[] | undefined;\n /** The key at a position, or `undefined`. */\n keyAt(coords: readonly number[]): K | undefined;\n /** The parent of the key `k` in a tree space, or `undefined` for a root. Other spaces do not have it. */\n parentOf?(k: string): K | undefined;\n /** The children of the key `k` in a tree space, in key order. Other spaces do not have it. */\n childrenOf?(k: string): readonly K[];\n}\n\n/** The key type of a grid space. */\nexport type GridKey = `${number},${number}`;\n\n/** The key type of an array space. */\nexport type ArrayKey = `${number}`;\n\nclass RecordSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"record\";\n readonly keys: readonly K[];\n readonly #records: ReadonlyMap<string, O>;\n\n constructor(records: Readonly<Record<K, O>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#records = new Map(entries);\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n}\n\nclass ArraySpace<O> implements Space<ArrayKey, O> {\n readonly kind: SpaceKind = \"array\";\n readonly keys: readonly ArrayKey[];\n readonly #items: ReadonlyMap<string, O>;\n\n constructor(items: readonly O[]) {\n const entries = items.map((item, i): [ArrayKey, O] => [`${i}`, item]);\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#items = new Map(entries);\n }\n\n has(k: string): k is ArrayKey {\n return this.#items.has(k);\n }\n get(k: string): O | undefined {\n return this.#items.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.has(k) ? [Number(k)] : undefined;\n }\n keyAt(coords: readonly number[]): ArrayKey | undefined {\n const k = String(coords[0]);\n return coords.length === 1 && this.has(k) ? k : undefined;\n }\n}\n\nclass GridSpace<O> implements Space<GridKey, O> {\n readonly kind: SpaceKind = \"grid\";\n readonly keys: readonly GridKey[];\n readonly #cells: ReadonlyMap<string, O>;\n readonly #coords: ReadonlyMap<string, readonly number[]>;\n\n constructor(rows: readonly (readonly O[])[]) {\n const entries = rows.flatMap((row, i) => row.map((cell, j): [GridKey, O, readonly number[]] => [`${i},${j}`, cell, Object.freeze([i, j])]));\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#cells = new Map(entries.map(([k, cell]) => [k, cell]));\n this.#coords = new Map(entries.map(([k, , c]) => [k, c]));\n }\n\n has(k: string): k is GridKey {\n return this.#cells.has(k);\n }\n get(k: string): O | undefined {\n return this.#cells.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.#coords.get(k);\n }\n keyAt(coords: readonly number[]): GridKey | undefined {\n // Each key has two coordinates, so a list with more or fewer coordinates gives no key.\n const k = coords.join(\",\");\n return this.has(k) ? k : undefined;\n }\n}\n\nclass TreeSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"tree\";\n readonly keys: readonly K[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #parents: ReadonlyMap<string, K>;\n readonly #children: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, parents: Readonly<Partial<Record<K, K | null>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.#records = new Map(entries);\n const parentOf = new Map<string, K>();\n for (const [k, p] of Object.entries(parents) as [K, K | null | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the tree has no key \"${k}\", but the parents name it`);\n if (p === null || p === undefined) continue;\n if (!this.#records.has(p)) throw new TypeError(`the parent \"${p}\" of \"${k}\" is not a key of the tree`);\n parentOf.set(k, p);\n }\n // A parent chain that comes back to a key of the same walk is a cycle, not a tree. Each key is in one walk\n // only: a walk stops at a key that an earlier walk proved to reach a root. Thus the check is linear.\n const reachesRoot = new Set<string>();\n for (const k of this.keys) {\n const walk = new Set<string>();\n for (let p: string | undefined = k; p !== undefined && !reachesRoot.has(p); p = parentOf.get(p)) {\n if (walk.has(p)) throw new TypeError(`the parents of \"${k}\" make a cycle, so the space is not a tree`);\n walk.add(p);\n }\n for (const w of walk) reachesRoot.add(w);\n }\n this.#parents = parentOf;\n const children = new Map<string, K[]>(this.keys.map((k) => [k, []]));\n for (const k of this.keys) {\n const p = parentOf.get(k);\n // Each parent is a key, so its list exists, and the test of p only skips the roots.\n // Stryker disable next-line ConditionalExpression,OptionalChaining: a root has no list to push to\n if (p !== undefined) children.get(p)?.push(k);\n }\n this.#children = new Map([...children].map(([k, c]) => [k, Object.freeze(c)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n parentOf(k: string): K | undefined {\n return this.#parents.get(k);\n }\n childrenOf(k: string): readonly K[] {\n return this.#children.get(k) ?? [];\n }\n}\n\n/** The constructors of spaces. */\nexport const space = {\n /** This function makes a space from the entries of an object. The keys are the property names. */\n record<const R extends Readonly<Record<string, unknown>>>(records: R): Space<keyof R & string, R[keyof R]> {\n return new RecordSpace<keyof R & string, R[keyof R]>(records);\n },\n /** This function makes a space from an array. The keys are `\"0\"`, `\"1\"` and so on. */\n array<O>(items: readonly O[]): Space<ArrayKey, O> {\n return new ArraySpace(items);\n },\n /** This function makes a space from rows of cells. The key of a cell is `\"row,column\"`. */\n grid<O>(rows: readonly (readonly O[])[]): Space<GridKey, O> {\n return new GridSpace(rows);\n },\n /**\n * This function makes a tree space: the records by key, and the parent of each key. A key without a parent, or\n * with the parent `null`, is a root. A parent that is not a key, or a cycle of parents, throws a `TypeError`.\n */\n tree<const R extends Readonly<Record<string, unknown>>>(records: R, parents: Readonly<Partial<Record<keyof R & string, (keyof R & string) | null>>>): Space<keyof R & string, R[keyof R]> {\n return new TreeSpace<keyof R & string, R[keyof R]>(records, parents);\n },\n} as const;\n\n/** The position of an evaluation: the key where it started, and the key where relative references read. */\nexport interface Position {\n readonly origin: string;\n readonly focus: string;\n}\n\n/** This function applies one move to the focus. It gives the new focus, or a `#REF!` error. */\nexport function applyMove(s: Space, at: Position, m: Move): Result<string> {\n const refError = (kind: \"unknown-key\" | \"not-a-pair\" | \"out-of-bounds\" | \"no-offset\" | \"no-tree\", message: string): Result<string> =>\n fail(vexError(kind, message, { origin: at.origin, focus: at.focus }));\n switch (m.t) {\n case \"key\":\n return s.has(m.key) ? ok(m.key) : refError(\"unknown-key\", `the space has no key \"${m.key}\"`);\n case \"index\": {\n const k = s.keys[m.i];\n return k !== undefined ? ok(k) : refError(\"out-of-bounds\", `the space has no key at index ${m.i}`);\n }\n case \"other\": {\n if (s.keys.length !== 2) return refError(\"not-a-pair\", `\"other\" needs a space with 2 keys, but this space has ${s.keys.length}`);\n const [a, b] = s.keys;\n // A pair has two keys, so `a` and `b` are defined.\n /* v8 ignore next -- @preserve */\n return ok(at.focus === a ? (b ?? at.focus) : (a ?? at.focus));\n }\n case \"offset\": {\n // In a tree space, an offset with one number moves among the siblings in key order. The roots are siblings.\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf !== undefined && childrenOf !== undefined && m.d.length === 1) {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n const i = group.indexOf(at.focus);\n const k = i < 0 ? undefined : group[i + (m.d[0] ?? 0)];\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside its siblings`) : ok(k);\n }\n const c = s.coords(at.focus);\n if (c === undefined || c.length !== m.d.length) {\n return refError(\"no-offset\", `an offset of length ${m.d.length} is not valid in a ${s.kind} space`);\n }\n // The lengths are equal, so each index of `c` is also an index of `m.d`.\n /* v8 ignore next -- @preserve */\n const target = c.map((x, i) => x + (m.d[i] ?? 0));\n const k = s.keyAt(target);\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside the space`) : ok(k);\n }\n case \"origin\":\n return ok(at.origin);\n case \"parent\": {\n if (s.parentOf === undefined) return refError(\"no-tree\", `\"parent\" needs a tree space, but this space is a ${s.kind}`);\n const p = s.parentOf(at.focus);\n return p === undefined ? refError(\"out-of-bounds\", `the key \"${at.focus}\" is a root, so it has no parent`) : ok(p);\n }\n }\n}\n\n/** This function applies the moves of an address in order. It gives the key where the address points. */\nexport function resolveAddr(s: Space, at: Position, addr: Addr | undefined): Result<string> {\n let focus = at.focus;\n for (const m of addr ?? []) {\n const r = applyMove(s, { origin: at.origin, focus }, m);\n if (!r.ok) return r;\n focus = r.value;\n }\n return ok(focus);\n}\n\nconst NEIGHBORS_4: readonly (readonly [number, number])[] = [[-1, 0], [0, -1], [0, 1], [1, 0]];\nconst NEIGHBORS_8: readonly (readonly [number, number])[] = [\n [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1],\n];\n\n/** The axes of a tree space. */\ntype TreeAxis = \"children\" | \"ancestors\" | \"descendants\" | \"siblings\";\n\nfunction treeTargets(s: Space, at: Position, t: TreeAxis): Result<readonly string[]> {\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf === undefined || childrenOf === undefined) {\n return fail(vexError(\"no-tree\", `\"${t}\" needs a tree space, but this space is a ${s.kind}`, at));\n }\n switch (t) {\n case \"children\":\n return ok(childrenOf(at.focus));\n case \"ancestors\": {\n const out: string[] = [];\n for (let p = parentOf(at.focus); p !== undefined; p = parentOf(p)) out.push(p);\n return ok(out);\n }\n case \"descendants\": {\n // A depth-first walk with a stack, so a deep tree does not need a deep call stack.\n const out: string[] = [];\n const stack = childrenOf(at.focus).toReversed();\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n stack.push(...childrenOf(k).toReversed());\n }\n return ok(out);\n }\n case \"siblings\": {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n return ok(group.filter((k) => k !== at.focus));\n }\n }\n}\n\n/**\n * This function gives the targets of a base axis at a focus. It does not handle `where`, because the\n * interpreter must evaluate the test.\n */\nexport function axisTargets(s: Space, at: Position, a: Exclude<Axis, { readonly t: \"where\" }>): Result<readonly string[]> {\n switch (a.t) {\n case \"all\":\n return ok(s.keys);\n case \"others\":\n return ok(s.keys.filter((k) => k !== at.focus));\n case \"other\": {\n const r = applyMove(s, at, { t: \"other\" });\n return r.ok ? ok([r.value]) : r;\n }\n case \"neighbors\": {\n if (s.kind !== \"grid\") return fail(vexError(\"no-grid\", `\"neighbors\" needs a grid space, but this space is a ${s.kind}`, at));\n const deltas = a.n === 4 ? NEIGHBORS_4 : NEIGHBORS_8;\n return ok(\n deltas.flatMap((d) => {\n const r = applyMove(s, at, { t: \"offset\", d });\n return r.ok ? [r.value] : [];\n }),\n );\n }\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n return treeTargets(s, at, a.t);\n }\n}\n","/**\n * Domains. A domain tells which values belong to it and which ops it has. The domain object owns this data.\n * Vex does not write to the prototypes of domain classes, and an import has no side effects.\n */\n\n/** An algebraic law that an op claims. `@mark1russell7/vex-testkit` checks each claim with property tests. */\nexport type Law = \"commutative\" | \"associative\" | \"idempotent\";\n\n/** The kind of a parameter. The interpreter checks the arguments of an op that declares its parameters. */\nexport type ParamKind = \"domain\" | \"number\" | \"boolean\" | \"string\" | \"any\";\n\n/** The description of one op of a domain. */\nexport interface OpSpec<D = never> {\n /**\n * The implementation, for an op that is not a method of the value (static-land style). The first argument\n * is the receiver. Without `fn`, the interpreter calls the method of the receiver with the same name.\n */\n readonly fn?: (self: D, ...args: never[]) => unknown;\n /** The laws that the op claims. */\n readonly laws?: readonly Law[];\n /** The identity element of the op, for reductions over an empty list. */\n readonly identity?: () => D;\n /** Scalar lifting: `true` lifts each number argument with `fromScalar`. An array sets it for each argument. */\n readonly liftScalar?: boolean | readonly boolean[];\n /** The kinds of the parameters after the receiver. When set, the interpreter checks the arguments. */\n readonly params?: readonly ParamKind[];\n}\n\n/** The type of an op that lifts number arguments. Use it to type the ops of a domain under `isolatedDeclarations`. */\nexport type LiftedOp<D> = OpSpec<D> & { readonly liftScalar: true };\n\n/** The type of an op with an implementation function `F`. */\nexport type FnOp<D, F extends (self: D, ...args: never[]) => unknown> = OpSpec<D> & { readonly fn: F };\n\n/**\n * The type of an op table: each name in `Names` is an op, and each name in `Lifted` lifts number arguments.\n * Use it to type the ops of a domain under `isolatedDeclarations`.\n */\nexport type OpTable<D, Names extends string, Lifted extends string = never> = {\n readonly [N in Names]: N extends Lifted ? LiftedOp<D> : OpSpec<D>;\n};\n\n/** The description of a domain, as a caller gives it to `defineDomain`. */\nexport interface DomainSpec<Name extends string, D, Ops extends Readonly<Record<string, OpSpec<D>>>> {\n /** The name of the domain. */\n readonly name: Name;\n /** The runtime test for the values of the domain. It must not give false positives. */\n readonly is: (u: unknown) => u is D;\n /** The ops of the domain, with their metadata. */\n readonly ops: Ops;\n /** With `\"all\"`, each method of a value is an op, also without an entry in `ops`. The default is `\"declared\"`. */\n readonly methods?: \"declared\" | \"all\";\n /** The scalar lift: it makes a domain value from a number. */\n readonly fromScalar?: (n: number) => D;\n /** A check of the values that ops give. A value that fails the check gives the error `#NUM!`. */\n readonly valid?: (d: D) => boolean;\n /** A short text for a value, for traces and the site. */\n readonly show?: (d: D) => string;\n /** The JSON form of a value, for literals in serialized programs. */\n readonly encode?: (d: D) => unknown;\n /** The value of a JSON form that `encode` made. */\n readonly decode?: (json: unknown) => D;\n}\n\n/** A domain. Make one with `defineDomain`. */\nexport interface Domain<Name extends string = string, D = unknown, Ops extends Readonly<Record<string, OpSpec<D>>> = Readonly<Record<string, OpSpec<D>>>>\n extends DomainSpec<Name, D, Ops> {\n readonly kind: \"vex.domain\";\n}\n\n/** A domain with any value type. The interpreter uses this type. */\n// oxlint-disable-next-line typescript/no-explicit-any -- a list of domains with different value types needs `any`: `fn` is contravariant in the value type.\nexport type AnyDomain = Domain<string, any, Readonly<Record<string, OpSpec<any>>>>;\n\n/** This function makes a domain. The result is frozen. */\nexport function defineDomain<const Name extends string, D, const Ops extends Readonly<Record<string, OpSpec<D>>>>(\n spec: DomainSpec<Name, D, Ops>,\n): Domain<Name, D, Ops> {\n return Object.freeze({ ...spec, kind: \"vex.domain\" as const });\n}\n\nconst FORBIDDEN = new Set([\"constructor\", \"__proto__\", \"prototype\", \"__defineGetter__\", \"__defineSetter__\", \"__lookupGetter__\", \"__lookupSetter__\"]);\n\n/** This function tells if a name can be an op name. */\nexport const isOpName = (name: string): boolean => name.length > 0 && !FORBIDDEN.has(name);\n\n/**\n * This function finds a method on a value: an own function property, or a function on the prototype chain.\n * It stops at `Object.prototype` and `Function.prototype`, so inherited members (for example `toString`) are not ops.\n */\nexport function findMethod(self: unknown, name: string): ((...args: unknown[]) => unknown) | undefined {\n if (!isOpName(name)) return undefined;\n // A primitive has no own methods. The loop below stops at null, so null needs no test here.\n if (typeof self !== \"object\" && typeof self !== \"function\") return undefined;\n let o: object | null = self;\n while (o !== null && o !== Object.prototype && o !== Function.prototype) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) {\n return typeof d.value === \"function\" ? (d.value as (...args: unknown[]) => unknown) : undefined;\n }\n o = Object.getPrototypeOf(o) as object | null;\n }\n return undefined;\n}\n\n/** An op that the interpreter found for a receiver. */\nexport interface ResolvedOp {\n readonly domain: AnyDomain;\n readonly spec: OpSpec<unknown>;\n readonly call: (args: readonly unknown[]) => unknown;\n}\n\nconst EMPTY_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** This function finds the op `name` for `self` in one domain. It gives `undefined` if the domain does not have it. */\nexport function resolveOp(domain: AnyDomain, self: unknown, name: string): ResolvedOp | undefined {\n if (!isOpName(name)) return undefined;\n const declared = Object.hasOwn(domain.ops, name) ? (domain.ops[name] as OpSpec<unknown>) : undefined;\n if (declared?.fn !== undefined) {\n const fn = declared.fn as (self: unknown, ...args: unknown[]) => unknown;\n return { domain, spec: declared, call: (args) => fn(self, ...args) };\n }\n if (declared === undefined && domain.methods !== \"all\") return undefined;\n const method = findMethod(self, name);\n if (method === undefined) return undefined;\n return { domain, spec: declared ?? EMPTY_SPEC, call: (args) => method.apply(self, [...args]) };\n}\n\n/** This function gives the domain of a value: the first domain whose `is` accepts it. */\nexport function domainOf(domains: readonly AnyDomain[], value: unknown): AnyDomain | undefined {\n return domains.find((d) => d.is(value));\n}\n\n/** This function tells if the `liftScalar` setting lifts the argument at `index`. */\nexport const liftsAt = (lift: OpSpec<unknown>[\"liftScalar\"], index: number): boolean =>\n lift === true || (Array.isArray(lift) && lift[index] === true);\n","import type { Result } from \"./result.ts\";\n\n/** One item of a list: the key of the target and the result of the body there. */\nexport interface ListItem<T = unknown> {\n readonly key: string;\n readonly result: Result<T>;\n}\n\n/** The value of an `each` expression: one item for each target of the axis. */\nexport interface VexList<T = unknown> {\n readonly kind: \"vex.list\";\n readonly items: readonly ListItem<T>[];\n}\n\n/** This function makes a list. */\nexport const vexList = <T>(items: readonly ListItem<T>[]): VexList<T> => Object.freeze({ kind: \"vex.list\", items: Object.freeze([...items]) });\n\n/** This function tells if a value is a Vex list. */\nexport const isVexList = (u: unknown): u is VexList =>\n (u as { kind?: unknown } | null | undefined)?.kind === \"vex.list\" && Array.isArray((u as { items?: unknown }).items);\n\n/** The name of a core list op. */\nexport type ListOp = \"count\" | \"sum\" | \"min\" | \"max\" | \"mean\" | \"any\" | \"all\" | \"none\" | \"values\" | \"keys\" | \"reduce\" | \"first\" | \"errors\";\n\n/** The names of the core list ops. They apply when the first argument is a list. */\nexport const LIST_OPS: ReadonlySet<string> = new Set<ListOp>([\"count\", \"sum\", \"min\", \"max\", \"mean\", \"any\", \"all\", \"none\", \"values\", \"keys\", \"reduce\", \"first\", \"errors\"]);\n\n/** This function tells if a name is the name of a core list op. */\nexport const isListOp = (op: string): op is ListOp => LIST_OPS.has(op);\n\n/** The options of a list op. */\nexport interface ListOptions {\n /** With `true`, any error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n","import { liftsAt, resolveOp, type AnyDomain, type ParamKind, type ResolvedOp } from \"./domain.ts\";\nimport { formatError, isDepthError, isStackOverflow, vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { children, type Axis, type Expr, type ExprOf, type Move } from \"./ir.ts\";\nimport { isListOp, isVexList, vexList, type ListItem, type ListOp, type ListOptions, type VexList } from \"./list.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { axisTargets, resolveAddr, type Position, type Space } from \"./space.ts\";\nimport type { Read, Trace, TraceEvent, TraceSink } from \"./trace.ts\";\n\n/** A free function op. The interpreter gives it the values of all arguments. */\nexport type FreeFn = (...args: readonly unknown[]) => unknown;\n\n/** The context of an extension handler. */\nexport interface ExtContext {\n readonly space: Space;\n readonly position: Position;\n readonly path: readonly number[];\n}\n\n/** The handler of an extension expression kind. */\nexport type ExtHandler = (data: unknown, ctx: ExtContext) => Result<unknown>;\n\n/** The options of an evaluation. */\nexport interface EvalOptions {\n /** The space that the program reads. */\n readonly space: Space;\n /** The key where the evaluation starts. Relative references read here. */\n readonly origin: string;\n /** The domains. The interpreter finds the op of a value in the first domain that accepts the value. */\n readonly domains?: readonly AnyDomain[];\n /** Free function ops, for ops that are not domain ops. */\n readonly fns?: Readonly<Record<string, FreeFn>>;\n /** The handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n /** Variables that the program can read with `v(name)`. */\n readonly vars?: Readonly<Record<string, unknown>>;\n /** A receiver of trace events. */\n readonly trace?: TraceSink;\n}\n\ntype Env = ReadonlyMap<string, Result<unknown>>;\n\ninterface Frame {\n readonly pos: Position;\n readonly env: Env;\n}\n\n/** The name of a special form. */\nexport type SpecialForm = \"if\" | \"and\" | \"or\" | \"ifError\";\n\n/** The names of the special forms. Their arguments are not evaluated before the call. */\nexport const SPECIAL_FORMS: ReadonlySet<string> = new Set<SpecialForm>([\"if\", \"and\", \"or\", \"ifError\"]);\n\nconst isSpecialForm = (op: string): op is SpecialForm => SPECIAL_FORMS.has(op);\n\n/** The options that a compiled program keeps: the domains, the free functions and the extension handlers. */\nexport type CompileOptions = Pick<EvalOptions, \"domains\" | \"fns\" | \"extensions\">;\n\n/** The options of one run of a compiled program. */\nexport type RunOptions = Pick<EvalOptions, \"space\" | \"origin\" | \"vars\" | \"trace\">;\n\n/**\n * A compiled program: the expression as a tree of functions. A program evaluates many times at different origins,\n * and over different spaces, without a new walk of the expression.\n */\nexport interface Program {\n /** The expression of the program. */\n readonly expr: Expr;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: RunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, with a trace of each node. */\n explain(opts: Omit<RunOptions, \"trace\">): Trace;\n}\n\n/**\n * This function compiles an expression. The result gives the same results and the same traces as `evaluate`,\n * because `evaluate` uses it too.\n */\n/** The deepest nesting of an expression that `compile` accepts (EVAL.NESTING). */\nexport const MAX_NESTING = 500;\n\nconst DEPTH_MESSAGE = \"the evaluation is too deep for the call stack of the engine\";\n\n/** This function gives the number of nodes on the longest path from the root of `e`. It uses a stack, not recursion. */\nexport function nestingOf(e: Expr): number {\n let deepest = 0;\n const todo: [Expr, number][] = [[e, 1]];\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const [x, d] = item;\n if (d > deepest) deepest = d;\n for (const child of children(x)) todo.push([child, d + 1]);\n }\n return deepest;\n}\n\nexport function compile(expr: Expr, opts: CompileOptions = {}): Program {\n // EVAL.NESTING: a program nested too deep gives an error before the compiler walks it with recursion.\n const nesting = nestingOf(expr);\n const root: Node =\n nesting > MAX_NESTING\n ? (f) => fail(vexError(\"bad-expression\", `the expression is nested ${nesting} levels deep, and the limit is ${MAX_NESTING}`, { path: [], origin: f.pos.origin, focus: f.pos.focus }))\n : new Compiler(opts).node(expr, []);\n const run = (r: RunOptions): Result<unknown> => {\n const { space, origin } = r;\n if (!space.has(origin)) return fail(vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin }));\n const env = new Map<string, Result<unknown>>(Object.entries(r.vars ?? {}).map(([k, val]) => [k, ok(val)]));\n try {\n return root({ pos: { origin, focus: origin }, env }, { space, trace: r.trace });\n } catch (thrown) {\n // A defect in an extension handler or in a test of the interpreter itself. Totality still holds.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", DEPTH_MESSAGE, { origin, focus: origin, thrown }));\n return fail(vexError(\"threw\", \"the evaluation threw an exception\", { origin, focus: origin, thrown }));\n }\n };\n return {\n expr,\n run,\n explain: (r) => {\n const sink: TraceSink = { events: [] };\n const result = run({ ...r, trace: sink });\n return { events: sink.events, result };\n },\n };\n}\n\n// The cache of compiled programs: one entry for each expression object, for the last options.\nconst CACHE = new WeakMap<Expr, { readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly program: Program }>();\n\nfunction compiled(expr: Expr, opts: CompileOptions): Program {\n const hit = CACHE.get(expr);\n // Without the cache, each evaluation compiles again: the result is the same, so a mutant that removes a hit is\n // equivalent. A false hit changes results, and the tests find it.\n // Stryker disable next-line ConditionalExpression: a missed hit only compiles again\n if (hit !== undefined && hit.domains === opts.domains && hit.fns === opts.fns && hit.extensions === opts.extensions) return hit.program;\n const program = compile(expr, opts);\n CACHE.set(expr, { domains: opts.domains, fns: opts.fns, extensions: opts.extensions, program });\n return program;\n}\n\n/** This function evaluates an expression at the origin of a space. It does not throw. */\nexport function evaluate(expr: Expr, opts: EvalOptions): Result<unknown> {\n return compiled(expr, opts).run(opts);\n}\n\n/** This function evaluates an expression and records a trace of each node. */\nexport function explain(expr: Expr, opts: Omit<EvalOptions, \"trace\">): Trace {\n return compiled(expr, opts).explain(opts);\n}\n\n/** The state of one run that the nodes read: the space and the trace sink. */\ninterface Ctx {\n readonly space: Space;\n readonly trace: TraceSink | undefined;\n}\n\n/** A compiled node: it evaluates in a frame of a run. */\ntype Node = (f: Frame, c: Ctx) => Result<unknown>;\n\n/** The static facts of a node for its trace events. */\ninterface Info {\n readonly path: readonly number[];\n readonly tag: Expr[\"tag\"];\n readonly label: string;\n}\n\nclass Compiler {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, FreeFn>> | undefined;\n readonly #extensions: Readonly<Record<string, ExtHandler>> | undefined;\n\n constructor(opts: CompileOptions) {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#extensions = opts.extensions;\n }\n\n #err(kind: ErrorKind, message: string, f: Frame, path: readonly number[], extra: { op?: string; causes?: readonly VexError[]; thrown?: unknown } = {}): Result<never> {\n return fail(vexError(kind, message, { path, origin: f.pos.origin, focus: f.pos.focus, ...extra }));\n }\n\n #emit(c: Ctx, info: Info, f: Frame, result: Result<unknown>, reads?: readonly Read[]): Result<unknown> {\n if (c.trace !== undefined) {\n const event: TraceEvent = {\n path: info.path,\n tag: info.tag,\n label: info.label,\n origin: f.pos.origin,\n focus: f.pos.focus,\n ...(reads === undefined ? {} : { reads }),\n result,\n };\n c.trace.events.push(event);\n }\n return result;\n }\n\n /** This method compiles the expression `e` at the position `path` of the tree. */\n node(e: Expr, path: readonly number[]): Node {\n const info: Info = { path, tag: e.tag, label: labelOf(e) };\n switch (e.tag) {\n case \"lit\": {\n const r = ok(e.value);\n return (f, c) => this.#emit(c, info, f, r);\n }\n case \"ref\":\n return this.#ref(e, info);\n case \"var\": {\n const name = e.name;\n return (f, c) => this.#emit(c, info, f, f.env.get(name) ?? this.#err(\"unbound\", `the name \"${name}\" has no binding`, f, path));\n }\n case \"let\": {\n const binds = Object.entries(e.bind).map(([name, be], i): readonly [string, Node] => [name, this.node(be, [...path, i])]);\n const body = this.node(e.body, [...path, binds.length]);\n return (f, c) => {\n const env = new Map(f.env);\n for (const [name, n] of binds) env.set(name, n(f, c));\n return this.#emit(c, info, f, body({ pos: f.pos, env }, c));\n };\n }\n case \"rec\": {\n const names = Object.keys(e.fields);\n const fields = this.#nodes(Object.values(e.fields), path);\n return (f, c) => {\n const values = this.#all(fields, f, c, path, \"fields\");\n if (!values.ok) return this.#emit(c, info, f, values);\n const out: Record<string, unknown> = {};\n names.forEach((n, i) => {\n out[n] = values.value[i];\n });\n return this.#emit(c, info, f, ok(Object.freeze(out)));\n };\n }\n case \"app\":\n return isSpecialForm(e.op) ? this.#special(e.op, this.#nodes(e.args, path), info) : this.#app(e.op, this.#nodes(e.args, path), info);\n case \"each\":\n return this.#each(e, info);\n case \"ext\": {\n const extensions = this.#extensions ?? {};\n const handler = Object.hasOwn(extensions, e.kind) ? extensions[e.kind] : undefined;\n const { kind, data } = e;\n if (handler === undefined) return (f, c) => this.#emit(c, info, f, this.#err(\"unknown-op\", `no handler for the extension kind \"${kind}\"`, f, path));\n return (f, c) =>\n this.#emit(c, info, f, this.#locate(this.#guard(() => handler(data, { space: c.space, position: f.pos, path }), f, path, kind), f, path));\n }\n }\n }\n\n #nodes(es: readonly Expr[], path: readonly number[]): readonly Node[] {\n return es.map((x, i) => this.node(x, [...path, i]));\n }\n\n /** This method gives an error of a handler the path, the origin and the focus of its node, if it has no origin. */\n #locate(r: Result<unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n if (r.ok || r.error.origin !== undefined) return r;\n return fail({ ...r.error, path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n #guard(run: () => Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n try {\n return run();\n } catch (thrown) {\n return this.#threw(thrown, `\"${op}\" threw an exception`, f, path, { op });\n }\n }\n\n /** This method gives the error of an exception: `#DEPTH!` for a full call stack, and `#CALC!` for each other exception. */\n #threw(thrown: unknown, message: string, f: Frame, path: readonly number[], extra: Partial<VexError> = {}): Result<never> {\n return isStackOverflow(thrown) ? this.#err(\"depth\", DEPTH_MESSAGE, f, path, { ...extra, thrown }) : this.#err(\"threw\", message, f, path, { ...extra, thrown });\n }\n\n #ref(e: ExprOf<\"ref\">, info: Info): Node {\n const { path } = info;\n const segs = e.path;\n const at = e.at ?? [];\n const label = segs.join(\".\");\n const steps = segs.map((seg, i) => ({ seg, where: segs.slice(0, i + 1).join(\".\"), valid: isFieldName(seg) }));\n return (f, c) => {\n let key = f.pos.focus;\n // The empty address resolves to the focus, so this fast path changes no result.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = resolveAddr(c.space, f.pos, at);\n if (!where.ok) return this.#emit(c, info, f, fail({ ...where.error, path }));\n key = where.value;\n }\n const failed = (r: Result<unknown>): Result<unknown> => this.#emit(c, info, f, r, [{ key, path: segs, ok: false }]);\n const missing = (where: string): Result<unknown> => failed(this.#err(\"missing-field\", `the record at \"${key}\" has no value at \"${where}\"`, f, path));\n let value: unknown = c.space.get(key);\n if (value === undefined || value === null) return missing(label === \"\" ? \"(record)\" : label);\n for (const { seg, where, valid } of steps) {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || !valid) return missing(where);\n try {\n value = Reflect.get(value, seg);\n } catch (thrown) {\n return failed(this.#threw(thrown, `reading \"${where}\" at \"${key}\" threw an exception`, f, path));\n }\n if (value === undefined || value === null) return missing(where);\n }\n return this.#emit(c, info, f, ok(value), [{ key, path: segs, ok: true }]);\n };\n }\n\n /** This method evaluates nodes applicatively. One failure stays as it is. Two or more give `#ARGS`. */\n #all(nodes: readonly Node[], f: Frame, c: Ctx, path: readonly number[], what: string): Result<readonly unknown[]> {\n const values: unknown[] = [];\n let first: VexError | undefined;\n let errors: VexError[] | undefined;\n for (const n of nodes) {\n const r = n(f, c);\n if (r.ok) values.push(r.value);\n else if (first === undefined) first = r.error;\n else (errors ??= [first]).push(r.error);\n }\n if (first === undefined) return ok(values);\n // A #DEPTH! argument is the result, so #ARGS does not wrap it, and ifError cannot hide it.\n const depth = [first, ...(errors ?? [])].find(isDepthError);\n if (depth !== undefined) return fail(depth);\n return errors === undefined ? fail(first) : this.#err(\"args\", `${errors.length} ${what} failed`, f, path, { causes: errors });\n }\n\n #each(e: ExprOf<\"each\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const targets = this.#targets(e.axis, path, { next: 1 });\n const body = this.node(e.body, [...path, 0]);\n return (f, c) => {\n // An axis with an address finds its targets from the key of the address. The origin does not change.\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = resolveAddr(c.space, f.pos, at);\n if (!where.ok) return this.#emit(c, info, f, fail({ ...where.error, path }));\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n const ts = targets(from, c);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n const items: ListItem[] = ts.value.map(({ key, test }) => {\n if (test !== undefined && !test.ok) return { key, result: test };\n return { key, result: body({ pos: { origin: f.pos.origin, focus: key }, env: f.env }, c) };\n });\n return this.#emit(c, info, f, ok(vexList(items)));\n };\n }\n\n /** This method compiles the targets of an axis. For `where`, a failed test keeps the target with its error. */\n #targets(a: Axis, path: readonly number[], counter: { next: number }): (f: Frame, c: Ctx) => Result<readonly { readonly key: string; readonly test?: Result<unknown> }[]> {\n if (a.t !== \"where\") {\n return (f, c) => {\n const keys = axisTargets(c.space, f.pos, a);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : fail({ ...keys.error, path });\n };\n }\n const inner = this.#targets(a.axis, path, counter);\n const testPath = [...path, counter.next++];\n const test = this.node(a.test, testPath);\n return (f, c) => {\n const ts = inner(f, c);\n if (!ts.ok) return ts;\n const out: { key: string; test?: Result<unknown> }[] = [];\n for (const t of ts.value) {\n if (t.test !== undefined && !t.test.ok) {\n out.push(t);\n continue;\n }\n const at: Frame = { pos: { origin: f.pos.origin, focus: t.key }, env: f.env };\n const r = test(at, c);\n if (!r.ok) out.push({ key: t.key, test: r });\n else if (r.value === true) out.push({ key: t.key });\n else if (r.value !== false) {\n out.push({ key: t.key, test: this.#err(\"kind-mismatch\", `the test of \"where\" gave a ${typeof r.value}, not a boolean`, at, testPath) });\n }\n }\n return ok(out);\n };\n }\n\n #app(op: string, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n return (f, c) => {\n const all = this.#all(args, f, c, path, \"arguments\");\n if (!all.ok) return this.#emit(c, info, f, all);\n const values = all.value;\n const self = values[0];\n if (listOp !== undefined && isVexList(self)) return this.#emit(c, info, f, this.#listOp(listOp, self, values.slice(1), f, path));\n let accepted: AnyDomain | undefined;\n // Without arguments, the receiver is undefined, and no domain of a test accepts it.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: the loop finds no domain for undefined\n if (values.length > 0) {\n for (const d of this.#domains) {\n if (!safeIs(d, self)) continue;\n accepted ??= d;\n const resolved = resolveOp(d, self, op);\n if (resolved !== undefined) return this.#emit(c, info, f, this.#call(resolved, op, values.slice(1), f, path));\n }\n }\n if (fn !== undefined) return this.#emit(c, info, f, this.#checkResult(this.#invoke(() => fn(...values), op, f, path), f, path, op));\n if (accepted !== undefined) return this.#emit(c, info, f, this.#err(\"unknown-op\", `the domain \"${accepted.name}\" has no op \"${op}\"`, f, path, { op }));\n if (values.length === 0) return this.#emit(c, info, f, this.#err(\"unknown-op\", `there is no function \"${op}\"`, f, path, { op }));\n return this.#emit(c, info, f, this.#err(\"not-instance\", `no domain accepts the receiver of \"${op}\" (${describeType(self)})`, f, path, { op }));\n };\n }\n\n #special(op: SpecialForm, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const arg = (i: number, f: Frame, c: Ctx): Result<unknown> => {\n const n = args[i];\n return n === undefined ? this.#err(\"bad-expression\", `\"${op}\" needs argument ${i + 1}`, f, path, { op }) : n(f, c);\n };\n const bool = (i: number, f: Frame, c: Ctx): Result<boolean> => {\n const r = arg(i, f, c);\n if (!r.ok) return r;\n return typeof r.value === \"boolean\" ? ok(r.value) : this.#err(\"kind-mismatch\", `argument ${i + 1} of \"${op}\" is a ${describeType(r.value)}, not a boolean`, f, path, { op });\n };\n switch (op) {\n case \"if\":\n return (f, c) => {\n const cond = bool(0, f, c);\n return this.#emit(c, info, f, cond.ok ? arg(cond.value ? 1 : 2, f, c) : cond);\n };\n case \"and\":\n case \"or\": {\n const stop = op === \"or\";\n return (f, c) => {\n if (args.length === 0) return this.#emit(c, info, f, this.#err(\"bad-expression\", `\"${op}\" needs at least 1 argument`, f, path, { op }));\n for (let i = 0; i < args.length; i++) {\n const b = bool(i, f, c);\n if (!b.ok) return this.#emit(c, info, f, b);\n if (b.value === stop) return this.#emit(c, info, f, ok(b.value));\n }\n return this.#emit(c, info, f, ok(!stop));\n };\n }\n case \"ifError\":\n return (f, c) => {\n const first = arg(0, f, c);\n // EVAL.DEPTH: ifError does not hide #DEPTH!, because the engine, not the data, failed.\n return this.#emit(c, info, f, first.ok || isDepthError(first.error) ? first : arg(1, f, c));\n };\n }\n }\n\n #call(op: ResolvedOp, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const { domain, spec } = op;\n const lift = spec.liftScalar;\n const from = domain.fromScalar;\n let callArgs: readonly unknown[] = rest;\n if (lift && from !== undefined) {\n const lifted = this.#invoke(() => rest.map((a, i): unknown => (typeof a === \"number\" && liftsAt(lift, i) ? from(a) : a)), `${domain.name}.fromScalar`, f, path);\n if (!lifted.ok) return lifted;\n callArgs = lifted.value as readonly unknown[];\n }\n if (spec.params !== undefined) {\n for (let i = 0; i < callArgs.length; i++) {\n const kind = spec.params[i] ?? \"any\";\n if (!matchesKind(kind, callArgs[i], domain)) {\n const k: ErrorKind = kind === \"domain\" ? \"not-instance\" : \"kind-mismatch\";\n return this.#err(k, `argument ${i + 1} of \"${name}\" is a ${describeType(callArgs[i])}, not a ${kind === \"domain\" ? domain.name : kind}`, f, path, { op: name });\n }\n }\n }\n return this.#checkResult(this.#invoke(() => op.call(callArgs), name, f, path), f, path, name);\n }\n\n #invoke(run: () => unknown, op: string, f: Frame, path: readonly number[]): Result<unknown> {\n try {\n return ok(run());\n } catch (thrown) {\n return this.#threw(thrown, `\"${op}\" threw an exception`, f, path, { op });\n }\n }\n\n /** This method checks the value that an op gave: no `undefined`, finite numbers, and valid domain values. */\n #checkResult(r: Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n if (!r.ok) return r;\n const value = r.value;\n const extra = { op };\n if (value === undefined || value === null) return this.#err(\"undefined-result\", `\"${op}\" gave no value`, f, path, extra);\n if (typeof value === \"number\" && !Number.isFinite(value)) return this.#err(\"not-finite\", `\"${op}\" gave ${value}`, f, path, extra);\n const d = this.#domains.find((dom) => safeIs(dom, value));\n if (d?.valid !== undefined) {\n let valid: boolean;\n try {\n valid = d.valid(value);\n } catch (thrown) {\n return this.#threw(thrown, `the \"valid\" check of \"${d.name}\" threw an exception`, f, path, extra);\n }\n if (!valid) return this.#err(\"invalid-value\", `\"${op}\" gave a value that is not a valid ${d.name}`, f, path, extra);\n }\n return r;\n }\n\n #listOp(op: ListOp, list: VexList, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const optsArg = op === \"reduce\" ? rest[1] : rest[0];\n // A reduction that skips error items does not skip #DEPTH! (EVAL.DEPTH).\n const depth = list.items.find((it) => !it.result.ok && isDepthError(it.result.error))?.result;\n if (depth !== undefined && !depth.ok) return fail(depth.error);\n const strict = (optsArg as ListOptions | null | undefined)?.strict === true;\n const firstError = list.items.find((it) => !it.result.ok)?.result;\n if (strict && firstError !== undefined && !firstError.ok) return fail(firstError.error);\n const okValues = list.items.flatMap((it) => (it.result.ok ? [it.result.value] : []));\n const numbers = (): Result<readonly number[]> => {\n const bad = okValues.find((x) => typeof x !== \"number\");\n return bad === undefined ? ok(okValues as readonly number[]) : this.#err(\"kind-mismatch\", `\"${op}\" needs numbers, but an item is a ${describeType(bad)}`, f, path, { op });\n };\n const booleans = (): Result<readonly boolean[]> => {\n const bad = okValues.find((x) => typeof x !== \"boolean\");\n return bad === undefined ? ok(okValues as readonly boolean[]) : this.#err(\"kind-mismatch\", `\"${op}\" needs booleans, but an item is a ${describeType(bad)}`, f, path, { op });\n };\n const empty = (): Result<never> => this.#err(\"empty\", `\"${op}\" has no values to work with`, f, path, { op });\n switch (op) {\n case \"count\":\n return ok(okValues.length);\n case \"values\":\n return ok(Object.freeze([...okValues]));\n case \"keys\":\n return ok(Object.freeze(list.items.filter((it) => it.result.ok).map((it) => it.key)));\n case \"errors\":\n return ok(Object.freeze(list.items.flatMap((it) => (it.result.ok ? [] : [it.result.error]))));\n case \"first\":\n return okValues.length > 0 ? ok(okValues[0]) : empty();\n case \"sum\": {\n const n = numbers();\n return n.ok ? this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0)), f, path, op) : n;\n }\n case \"mean\": {\n const n = numbers();\n if (!n.ok) return n;\n return n.value.length === 0 ? empty() : this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0) / n.value.length), f, path, op);\n }\n case \"min\":\n case \"max\": {\n const n = numbers();\n if (!n.ok) return n;\n if (n.value.length === 0) return empty();\n return ok(n.value.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x))));\n }\n case \"any\":\n case \"all\":\n case \"none\": {\n const b = booleans();\n if (!b.ok) return b;\n if (op === \"any\") return ok(b.value.some((x) => x));\n if (op === \"all\") return ok(b.value.every((x) => x));\n return ok(!b.value.some((x) => x));\n }\n case \"reduce\":\n return this.#reduce(rest[0], okValues, f, path, optsArg);\n }\n }\n\n /**\n * This method folds the values with a domain op, from the left. An empty list gives the identity of the op, if one\n * domain has an identity for the op (LIST.EMPTY). The option `domain` names that domain when more domains have one.\n */\n #reduce(opName: unknown, values: readonly unknown[], f: Frame, path: readonly number[], opts: unknown): Result<unknown> {\n if (typeof opName !== \"string\") return this.#err(\"kind-mismatch\", `\"reduce\" needs an op name, but got a ${describeType(opName)}`, f, path, { op: \"reduce\" });\n if (values.length === 0) {\n const named = (opts as { domain?: unknown } | null | undefined)?.domain;\n const candidates = this.#domains.filter((d) => Object.hasOwn(d.ops, opName) && (d.ops[opName] as { identity?: () => unknown }).identity !== undefined && (named === undefined || d.name === named));\n if (named !== undefined && !this.#domains.some((d) => d.name === named)) {\n return this.#err(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named)}, but the program has no such domain`, f, path, { op: opName });\n }\n const [only, second] = candidates;\n if (only === undefined) return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values and the op has no identity`, f, path, { op: opName });\n if (second !== undefined) {\n const names = candidates.map((d) => d.name).join(\", \");\n return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values, and more domains have an identity for it (${names}). Name one with { domain }`, f, path, { op: opName });\n }\n return this.#invoke((only.ops[opName] as { identity: () => unknown }).identity, opName, f, path);\n }\n let acc: unknown = values[0];\n for (let i = 1; i < values.length; i++) {\n const d = this.#domains.find((dom) => safeIs(dom, acc) && resolveOp(dom, acc, opName) !== undefined);\n const op = d === undefined ? undefined : resolveOp(d, acc, opName);\n if (op === undefined) return this.#err(\"unknown-op\", `no domain gives \"${opName}\" for a ${describeType(acc)}`, f, path, { op: opName });\n const r = this.#call(op, opName, [values[i]], f, path);\n if (!r.ok) return r;\n acc = r.value;\n }\n return ok(acc);\n }\n}\n\nconst FORBIDDEN_FIELDS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\nconst isFieldName = (seg: string): boolean => seg.length > 0 && !FORBIDDEN_FIELDS.has(seg);\n\n/** This function runs the `is` test of a domain. A test that throws counts as `false`. */\n// Stryker disable BlockStatement: an empty catch gives undefined, which also counts as false\nfunction safeIs(d: AnyDomain, value: unknown): boolean {\n try {\n return d.is(value);\n } catch {\n return false;\n }\n}\n// Stryker restore BlockStatement\n\n\nfunction matchesKind(kind: ParamKind, value: unknown, domain: AnyDomain): boolean {\n switch (kind) {\n case \"domain\":\n return safeIs(domain, value);\n case \"number\":\n return typeof value === \"number\";\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"string\":\n return typeof value === \"string\";\n case \"any\":\n return true;\n }\n}\n\n/** This function gives a short name for the type of a value, for error messages. */\nexport function describeType(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n if (typeof u === \"object\") {\n const name = (Object.getPrototypeOf(u) as { constructor?: { name?: unknown } } | null)?.constructor?.name;\n return typeof name === \"string\" && name !== \"Object\" ? name : \"object\";\n }\n return typeof u;\n}\n\n/** This function gives the label of a node, for traces. */\nexport function labelOf(e: Expr): string {\n switch (e.tag) {\n case \"lit\":\n return previewValue(e.value);\n case \"ref\":\n return e.path.length === 0 ? \"(record)\" : e.path.join(\".\");\n case \"app\":\n return e.op;\n case \"let\":\n return `let ${Object.keys(e.bind).join(\", \")}`;\n case \"var\":\n return e.name;\n case \"rec\":\n return `{ ${Object.keys(e.fields).join(\", \")} }`;\n case \"each\":\n return e.at === undefined ? `each ${e.axis.t}` : `each ${e.axis.t} from ${e.at.map(moveText).join(\".\")}`;\n case \"ext\":\n return e.kind;\n }\n}\n\n/** This function gives a short text for a move, for the label of an axis with an address. */\nfunction moveText(m: Move): string {\n switch (m.t) {\n case \"key\":\n return `key(${m.key})`;\n case \"index\":\n return `index(${m.i})`;\n case \"offset\":\n return `offset(${m.d.join(\", \")})`;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return m.t;\n }\n}\n\n/** This function gives a short text for a value. */\nexport function previewValue(u: unknown): string {\n // JSON has no NaN and no Infinity, so a number gets its own text. JSON gives the text of the other primitives.\n if (typeof u === \"number\") return String(u);\n if (isVexList(u)) return `list(${u.items.length})`;\n try {\n const json = JSON.stringify(u);\n // A function, a symbol and undefined have no JSON form.\n // Stryker disable next-line ConditionalExpression: without the test, undefined.length throws, and the catch gives the same text\n if (json !== undefined) return json.length > 60 ? `${json.slice(0, 57)}...` : json;\n } catch {\n // A value with cycles has no JSON form.\n }\n return describeType(u);\n}\n\n// The reads of a reference show the key and the path, for example \"read B.position\" or \"no value at A.mass\".\nconst formatRead = (r: Read): string => `${r.ok ? \"read\" : \"no value at\"} ${r.key}.${r.path.length === 0 ? \"(record)\" : r.path.join(\".\")}`;\n\n/**\n * This function gives a text form of a trace. Each event has one line, in finish order. The indent of a line\n * shows the depth of the node. A domain with `show` gives the text of its values. The golden tests compare this text.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain shows no value\nexport function formatTrace(trace: Trace, domains: readonly AnyDomain[] = []): string {\n const show = (u: unknown): string => {\n if (isVexList(u)) return `[${u.items.map((it) => `${it.key}: ${result(it.result)}`).join(\", \")}]`;\n const d = domains.find((dom) => dom.show !== undefined && safeIs(dom, u));\n try {\n // Stryker disable next-line ConditionalExpression,OptionalChaining: without a domain, d.show throws, and the catch gives the same text\n if (d?.show !== undefined) return d.show(u);\n } catch {\n // A show function that throws gives the default text.\n }\n return previewValue(u);\n };\n const result = (r: Result<unknown>): string => (r.ok ? show(r.value) : formatError(r.error));\n const line = (e: TraceEvent): string => {\n const reads = e.reads === undefined ? \"\" : ` [${e.reads.map(formatRead).join(\", \")}]`;\n return `${\" \".repeat(e.path.length)}${e.label} @${e.focus}${reads} = ${result(e.result)}`;\n };\n const lines = trace.events.map(line);\n return [...lines, `result = ${result(trace.result)}`, \"\"].join(\"\\n\");\n}\n\n/** This function gives the number of nodes of an expression. */\nexport const sizeOf = (e: Expr): number => 1 + children(e).reduce((s, c) => s + sizeOf(c), 0);\n","import { children, type Addr, type Axis, type Expr } from \"./ir.ts\";\n\n/** One static read of a program: a field path at an address, inside zero or more axes. */\nexport interface Dependency {\n /** The address of the read. The empty address is the focus. */\n readonly at: Addr;\n /** The field path of the read. */\n readonly path: readonly string[];\n /** The axes around the read, from the outside to the inside. Inside an axis, the focus is the target. */\n readonly axes: readonly Axis[\"t\"][];\n /** The address of each axis in `axes`, in the same order. The empty address is the focus. */\n readonly axisAt: readonly Addr[];\n}\n\n/**\n * This function gives the static reads of an expression. A host can use them to recompute a program only\n * when a field that it reads changes.\n */\nexport function deps(e: Expr): readonly Dependency[] {\n const out: Dependency[] = [];\n // A stack, not recursion, so a deep expression needs no deep call stack. The children go on the stack in reverse\n // order, so the reads come out in the order of a depth-first walk.\n const todo: { readonly x: Expr; readonly axes: readonly Axis[\"t\"][]; readonly axisAt: readonly Addr[] }[] = [{ x: e, axes: [], axisAt: [] }];\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const { x } = item;\n if (x.tag === \"ref\") {\n out.push({ at: x.at ?? [], path: x.path, axes: item.axes, axisAt: item.axisAt });\n continue;\n }\n const axes = x.tag === \"each\" ? [...item.axes, x.axis.t] : item.axes;\n const axisAt = x.tag === \"each\" ? [...item.axisAt, x.at ?? []] : item.axisAt;\n for (const child of children(x).toReversed()) todo.push({ x: child, axes, axisAt });\n }\n return out;\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { isStackOverflow, vexError } from \"./errors.ts\";\nimport { isExpr, type Expr } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/**\n * The JSON form of the values in a literal. JSON data stays as it is, with three exceptions. Each exception is a record\n * with the key `$vex`:\n *\n * - `{ \"$vex\": \"domain\", \"domain\": name, \"value\": v }`: a value of a domain, with the `encode` of the domain.\n * - `{ \"$vex\": \"number\", \"value\": \"-0\" }`: a number that JSON has no text for: `-0`, `NaN`, `Infinity` or `-Infinity`.\n * - `{ \"$vex\": \"escape\", \"value\": record }`: a record of the data that has the key `$vex` itself (IR.JSON.ESCAPE).\n *\n * A record with the key `$vex` and another form stays data, so a file from an older version reads as before.\n *\n * The functions walk the tree of the expression, so only the value of a literal gets this form. A field of a literal\n * that looks like an expression stays data. The data of an extension is plain JSON, as before.\n */\ntype Encoded =\n | { readonly $vex: \"domain\"; readonly domain: string; readonly value: unknown }\n | { readonly $vex: \"number\"; readonly value: \"-0\" | \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { readonly $vex: \"escape\"; readonly value: Readonly<Record<string, unknown>> };\n\nconst isRecord = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null && !Array.isArray(u);\n\nconst isPlainRecord = (u: unknown): u is Readonly<Record<string, unknown>> => {\n if (!isRecord(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto === Object.prototype || proto === null;\n};\n\n/** This function gives the JSON form of a value, or the reason why the value has no JSON form. */\nfunction encodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (u === null || typeof u === \"string\" || typeof u === \"boolean\") return ok(u);\n if (typeof u === \"number\") {\n if (Object.is(u, -0)) return ok({ $vex: \"number\", value: \"-0\" } satisfies Encoded);\n // Stryker disable next-line EqualityOperator: here u is an infinity, so u > 0 and u >= 0 are the same test\n return Number.isFinite(u) ? ok(u) : ok({ $vex: \"number\", value: Number.isNaN(u) ? \"NaN\" : u > 0 ? \"Infinity\" : \"-Infinity\" } satisfies Encoded);\n }\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (isPlainRecord(u)) {\n const out: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(u)) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out[k] = r.value;\n }\n return ok(Object.hasOwn(u, \"$vex\") ? ({ $vex: \"escape\", value: out } satisfies Encoded) : out);\n }\n // A plain array or record stays data. Another object is a value of a domain, or it has no JSON form.\n const d = domains.find((dom) => dom.encode !== undefined && dom.is(u));\n if (d?.encode !== undefined) return ok({ $vex: \"domain\", domain: d.name, value: d.encode(u) } satisfies Encoded);\n return fail(vexError(\"bad-expression\", \"a literal value is not JSON data and no domain encodes it\"));\n}\n\nconst NUMBERS: Readonly<Record<string, number>> = { \"-0\": -0, NaN: Number.NaN, Infinity: Number.POSITIVE_INFINITY, \"-Infinity\": Number.NEGATIVE_INFINITY };\n\n/** This function reads a value from its JSON form. */\nfunction decodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (!isRecord(u)) return ok(u);\n const fields = (record: Readonly<Record<string, unknown>>): Result<unknown> => {\n const out: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(record)) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out[k] = r.value;\n }\n return ok(out);\n };\n // A record without the key $vex matches none of the forms below, so it stays data too.\n const kind = u[\"$vex\"];\n if (kind === \"escape\" && isRecord(u[\"value\"])) return fields(u[\"value\"]);\n if (kind === \"number\" && typeof u[\"value\"] === \"string\" && Object.hasOwn(NUMBERS, u[\"value\"])) return ok(NUMBERS[u[\"value\"]]);\n if (kind === \"domain\" && typeof u[\"domain\"] === \"string\") {\n const name = u[\"domain\"];\n const d = domains.find((dom) => dom.name === name);\n if (d?.decode === undefined) return fail(vexError(\"bad-expression\", `no domain \"${name}\" decodes a literal`));\n return ok(d.decode(u[\"value\"]));\n }\n // A form that this version does not know stays data, so a file from an older version reads as before.\n return fields(u);\n}\n\n/** This function applies `f` to each literal value of a JSON tree of an expression. */\nfunction mapValues(u: unknown, f: (value: unknown) => Result<unknown>): Result<unknown> {\n if (!isRecord(u)) return ok(u);\n const out: Record<string, unknown> = { ...u };\n const child = (key: string): Result<unknown> | undefined => {\n const r = mapValues(u[key], f);\n if (r.ok) out[key] = r.value;\n return r.ok ? undefined : r;\n };\n const each = (key: string): Result<unknown> | undefined => {\n const list = u[key];\n if (Array.isArray(list)) {\n const items: unknown[] = [];\n for (const x of list) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n items.push(r.value);\n }\n out[key] = items;\n } else if (isRecord(list)) {\n const rec: Record<string, unknown> = {};\n for (const [k, x] of Object.entries(list)) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n rec[k] = r.value;\n }\n out[key] = rec;\n }\n return undefined;\n };\n const axis = (a: unknown): Result<unknown> => {\n if (!isRecord(a) || a[\"t\"] !== \"where\") return ok(a);\n const inner = axis(a[\"axis\"]);\n if (!inner.ok) return inner;\n const test = mapValues(a[\"test\"], f);\n return test.ok ? ok({ ...a, axis: inner.value, test: test.value }) : test;\n };\n switch (u[\"tag\"]) {\n case \"lit\": {\n if (!Object.hasOwn(u, \"value\")) return ok(out);\n const r = f(u[\"value\"]);\n if (!r.ok) return r;\n out[\"value\"] = r.value;\n return ok(out);\n }\n case \"app\":\n return each(\"args\") ?? ok(out);\n case \"let\":\n return each(\"bind\") ?? child(\"body\") ?? ok(out);\n case \"rec\":\n return each(\"fields\") ?? ok(out);\n case \"each\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return child(\"body\") ?? ok(out);\n }\n default:\n return ok(out);\n }\n}\n\n/**\n * This function gives the JSON text of an expression. A literal value that is a domain value needs a domain with\n * `encode`. A literal value that is not JSON data and has no such domain gives the error `#VALUE!`.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function serialize(e: Expr, domains: readonly AnyDomain[] = []): Result<string> {\n try {\n // A getter of a literal value can throw, so the encoding is inside the try too.\n const tree = mapValues(e, (v) => encodeValue(v, domains));\n return tree.ok ? ok(JSON.stringify(tree.value)) : fail(tree.error);\n } catch (thrown) {\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the expression is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"the expression has no JSON form\", { thrown }));\n }\n}\n\n/** This function reads an expression from JSON text. It checks the whole tree. */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function parse(text: string, domains: readonly AnyDomain[] = []): Result<Expr> {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (thrown) {\n return fail(vexError(\"bad-expression\", \"the text is not JSON\", { thrown }));\n }\n try {\n const tree = mapValues(raw, (v) => decodeValue(v, domains));\n if (!tree.ok) return fail(tree.error);\n return isExpr(tree.value) ? ok(tree.value) : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n } catch (thrown) {\n // A JSON text nested deeper than the call stack, or a decoder of a domain that throws.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the JSON is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"a decoder of a domain threw an exception\", { thrown }));\n }\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { evaluate, type FreeFn } from \"./evaluate.ts\";\nimport { app, lit, v } from \"./ir.ts\";\nimport { vexList, type ListItem } from \"./list.ts\";\nimport { fail, none, ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport { space as spaces, type Space } from \"./space.ts\";\n\n/** A monoid: an associative `concat` with an identity element `empty`. */\nexport interface Monoid<M> {\n readonly empty: M;\n readonly concat: (a: M, b: M) => M;\n}\n\n/** Standard monoids. */\nexport const monoids: {\n readonly sum: Monoid<number>;\n readonly product: Monoid<number>;\n readonly all: Monoid<boolean>;\n readonly any: Monoid<boolean>;\n} = {\n sum: { empty: 0, concat: (a, b) => a + b },\n product: { empty: 1, concat: (a, b) => a * b },\n all: { empty: true, concat: (a, b) => a && b },\n any: { empty: false, concat: (a, b) => a || b },\n};\n\n/** One item of a traversal: the start key and the result there. */\nexport interface TraversalItem<K extends string, T> {\n readonly key: K;\n readonly result: Result<T>;\n}\n\n/**\n * A traversal: the results of one program at each start key. The reductions skip error items by default.\n * After `strict()`, an error item makes the reduction that error.\n */\nexport interface Traversal<K extends string, T> {\n readonly items: readonly TraversalItem<K, T>[];\n /** This method gives a traversal whose reductions fail on the first error item. */\n strict(): Traversal<K, T>;\n /** This method gives the result at one key. */\n get(k: K): Optional<T>;\n /** The values of the items without errors. */\n values(): readonly T[];\n /** The keys of the items without errors. */\n keys(): readonly K[];\n /** The errors of the items with errors. */\n errors(): readonly VexError[];\n count(): Optional<number>;\n sum(this: Traversal<K, number>): Optional<number>;\n mean(this: Traversal<K, number>): Optional<number>;\n min(this: Traversal<K, number>): Optional<number>;\n max(this: Traversal<K, number>): Optional<number>;\n any(this: Traversal<K, boolean>): Optional<boolean>;\n all(this: Traversal<K, boolean>): Optional<boolean>;\n none(this: Traversal<K, boolean>): Optional<boolean>;\n /** This method folds the values with a domain op, from the left. */\n reduce(op: string): Optional<T>;\n /** This method gives the result of a reduction, with its error. */\n reduceResult(op: \"count\" | \"sum\" | \"mean\" | \"min\" | \"max\" | \"any\" | \"all\" | \"none\" | \"reduce\", reduceOp?: string): Result<unknown>;\n /** This method maps each value with `f`. If `f` throws, the item has the error `#CALC!`. */\n map<U>(f: (value: T, key: K) => U): Traversal<K, U>;\n /** This method folds the values with a monoid. */\n fold<M>(monoid: Monoid<M>, f: (value: T) => M): M;\n}\n\ninterface TraversalEnv {\n readonly domains: readonly AnyDomain[];\n readonly options?: { readonly fns?: Readonly<Record<string, FreeFn>> };\n}\n\nconst EMPTY_SPACE: Space = spaces.record({ $: {} });\n\nconst opt = <U>(r: Result<unknown>): Optional<U> => toOptional(r as Result<U>);\n\n/** This function makes a traversal from items. */\nexport function traversal<K extends string, T>(items: readonly TraversalItem<K, T>[], env: TraversalEnv, isStrict = false): Traversal<K, T> {\n const reduce = (op: string, reduceOp?: string): Result<unknown> => {\n const list = vexList(items as readonly ListItem[]);\n const args = [v(\"$list\"), ...(reduceOp === undefined ? [] : [lit(reduceOp)]), ...(isStrict ? [lit({ strict: true })] : [])];\n return evaluate(app(op, ...args), {\n space: EMPTY_SPACE,\n origin: \"$\",\n domains: env.domains,\n vars: { $list: list },\n });\n };\n const t: Traversal<K, T> = {\n items,\n strict: () => traversal(items, env, true),\n get: (k) => {\n const item = items.find((it) => it.key === k);\n return item === undefined ? none() : toOptional(item.result);\n },\n values: () => items.flatMap((it) => (it.result.ok ? [it.result.value] : [])),\n keys: () => items.flatMap((it) => (it.result.ok ? [it.key] : [])),\n errors: () => items.flatMap((it) => (it.result.ok ? [] : [it.result.error])),\n count: () => opt(reduce(\"count\")),\n sum: () => opt(reduce(\"sum\")),\n mean: () => opt(reduce(\"mean\")),\n min: () => opt(reduce(\"min\")),\n max: () => opt(reduce(\"max\")),\n any: () => opt(reduce(\"any\")),\n all: () => opt(reduce(\"all\")),\n none: () => opt(reduce(\"none\")),\n reduce: (op) => opt(reduce(\"reduce\", op)),\n reduceResult: (op, reduceOp) => reduce(op, reduceOp),\n map: <U>(f: (value: T, key: K) => U): Traversal<K, U> =>\n traversal(\n items.map((it): TraversalItem<K, U> => {\n if (!it.result.ok) return { key: it.key, result: it.result };\n try {\n return { key: it.key, result: ok(f(it.result.value, it.key)) };\n } catch (thrown) {\n return { key: it.key, result: fail(vexError(\"threw\", \"the map function threw an exception\", { thrown, focus: it.key })) };\n }\n }),\n env,\n isStrict,\n ),\n fold: <M>(monoid: Monoid<M>, f: (value: T) => M): M => t.values().reduce((acc, x) => monoid.concat(acc, f(x)), monoid.empty),\n };\n return t;\n}\n","/**\n * Sheets: named columns of formulas over a space. A formula can read a column at an address, like a cell\n * reference of a spreadsheet. A cell is one column at one key. A run evaluates each cell once, and each cell on a\n * cycle of reads gives `#CYCLE!`.\n *\n * A cell reference is the extension node `ext(\"vex.cell\", { column, at })`. Thus the IR has no new kind, and the\n * JSON form, `deps` and the traces work without a change.\n */\nimport { vexError } from \"./errors.ts\";\nimport { evaluate, explain, nestingOf, type EvalOptions, type ExtHandler } from \"./evaluate.ts\";\nimport { ext, isMove, type Addr, type Expr } from \"./ir.ts\";\nimport { fail, type Result } from \"./result.ts\";\nimport { resolveAddr } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\n\n/** The extension kind of a cell reference. */\nexport const CELL_KIND = \"vex.cell\";\n\n/** The data of a cell reference: the column, and the address from the focus. */\nexport interface CellRef {\n readonly column: string;\n readonly at: Addr;\n}\n\n/** This function makes a cell reference: the column `column` at the address `at` from the focus. */\nexport const cell = (column: string, at: Addr = []): Expr => ext(CELL_KIND, { column, at } satisfies CellRef);\n\nconst isCellRef = (u: unknown): u is CellRef =>\n typeof u === \"object\" &&\n u !== null &&\n typeof (u as { column?: unknown }).column === \"string\" &&\n Array.isArray((u as { at?: unknown }).at) &&\n (u as { at: readonly unknown[] }).at.every(isMove);\n\n/** The options of a sheet run: the evaluation options without the origin and the trace. */\nexport type SheetOptions = Omit<EvalOptions, \"origin\" | \"trace\">;\n\nconst cycleError = (column: string, key: string): Result<never> =>\n fail(vexError(\"cycle\", `the cell \"${column}\" at \"${key}\" is on a cycle of cell references`, { origin: key, focus: key }));\n\n/** The id of a cell. */\nconst idOf = (column: string, key: string): string => `${column}\\u0000${key}`;\n\n/** The state of one cell in the search. */\ninterface Visit {\n readonly id: string;\n readonly column: string;\n readonly key: string;\n readonly index: number;\n low: number;\n reread: boolean;\n result: Result<unknown>;\n /** True when the last evaluation paused, because a cell that it reads is not finished. */\n paused: boolean;\n /** The cell that the evaluation waits for: a cell that the run started, or a cell that paused too. */\n need: Visit | undefined;\n}\n\n/**\n * The budget of the stack for the recursion of a run, in estimated frames. Each engine has more stack than this, so\n * the recursion of a run cannot fill the stack (SHEET.DEEP).\n */\nconst STACK_BUDGET = 3000;\n\n/**\n * One run of a sheet. It keeps the result of each cell that it evaluated. The space does not change, so a cell has\n * one result in a run.\n *\n * The run is a depth-first search with the algorithm of Tarjan for strongly connected components. A cell finishes\n * when its component finishes. Each cell of a component with two or more cells, or with a reference to itself,\n * gives `#CYCLE!`. A read of a cell that is not finished gives `#CYCLE!` too. Thus the order of the evaluations\n * does not change a result, also when `ifError` catches the error of a cycle.\n *\n * The search does not depend on the call stack of the engine (SHEET.DEEP). A read of a cell evaluates that cell\n * with recursion while the stack of the run stays in a budget. When a read is over the budget, the run starts the\n * cell, and the cell that reads it pauses. A paused evaluation reads no other cell and changes no state of the\n * search. The run then evaluates the started cell from its own list, and it evaluates the paused cell again after\n * that cell. A formula is pure (EVAL.PURE), so the second evaluation gives the result of one evaluation.\n */\nexport class SheetRun {\n readonly #columns: ReadonlyMap<string, Expr>;\n readonly #opts: SheetOptions;\n readonly #done = new Map<string, Result<unknown>>();\n // For each column, the number of keys at the start of the key order that a warm-up evaluated.\n readonly #warmed = new Map<string, number>();\n // The position of each key in the key order, made at the first warm-up.\n #index: ReadonlyMap<string, number> | undefined;\n // The cells on the stack of the search: started, but their component is not finished.\n readonly #visits = new Map<string, Visit>();\n // Stryker disable next-line ArrayDeclaration: the search never reads below the root of a component\n readonly #stack: Visit[] = [];\n // The cell whose formula is in evaluation. At the top level, it is a placeholder that is not a cell.\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n #top: Visit = { id: \"\", column: \"\", key: \"\", index: -1, low: -1, reread: false, result: cycleError(\"\", \"\"), paused: false, need: undefined };\n #next = 0;\n // The estimated frames of the stack that the evaluations in progress use, and the cost of a cell of each column.\n #used = 0;\n readonly #cost = new Map<string, number>();\n readonly #budget: number;\n\n /** `budget` is the budget of the stack in estimated frames. A test can make it small, so the run pauses often. */\n constructor(columns: ReadonlyMap<string, Expr>, opts: SheetOptions, budget: number = STACK_BUDGET) {\n this.#columns = columns;\n this.#budget = budget;\n this.#opts = { ...opts, extensions: { ...opts.extensions, [CELL_KIND]: this.#handler } };\n }\n\n readonly #handler: ExtHandler = (data, ctx) => {\n if (!isCellRef(data)) return fail(vexError(\"bad-expression\", \"a cell reference needs a column name and an address\", { path: ctx.path }));\n const where = resolveAddr(ctx.space, ctx.position, data.at);\n if (!where.ok) return fail({ ...where.error, path: ctx.path });\n return this.#read(data.column, where.value);\n };\n\n /**\n * This method gives the result of one cell: the column `column` at the key `key`. A read from a host first evaluates\n * the column at the keys before `key`, in key order. Thus a recurrence over the keys reads finished cells.\n */\n cell(column: string, key: string): Result<unknown> {\n // The placeholder at the top has the index -1. A read inside a formula has a cell at the top, so it does not warm.\n if (this.#top.index >= 0) return this.#read(column, key);\n this.#warmTo(column, key);\n return this.#drive(column, key);\n }\n\n /** This method evaluates the column `column` at each key before `key` that it did not evaluate before, in key order. */\n #warmTo(column: string, key: string): void {\n if (!this.#columns.has(column)) return;\n const keys = this.#opts.space.keys;\n this.#index ??= new Map(keys.map((k, i) => [k, i]));\n const end = this.#index.get(key) ?? 0;\n const start = this.#warmed.get(column) ?? 0;\n for (let i = start; i < end; i++) this.#drive(column, keys[i] ?? key);\n if (end > start) this.#warmed.set(column, end);\n }\n\n /** This method gives the estimated frames of the stack that one evaluation of a cell of `column` uses. */\n #costOf(column: string, program: Expr): number {\n let cost = this.#cost.get(column);\n if (cost === undefined) {\n cost = 3 * nestingOf(program) + 16;\n this.#cost.set(column, cost);\n }\n return cost;\n }\n\n /** This method puts a new cell on the stack of the search. */\n #start(column: string, key: string): Visit {\n const n = this.#next++;\n const visit: Visit = { id: idOf(column, key), column, key, index: n, low: n, reread: false, result: cycleError(column, key), paused: false, need: undefined };\n this.#visits.set(visit.id, visit);\n this.#stack.push(visit);\n return visit;\n }\n\n /** This method evaluates the formula of a cell once. When the evaluation pauses, the result of the cell does not change. */\n #evaluate(visit: Visit, program: Expr): void {\n const caller = this.#top;\n const cost = this.#costOf(visit.column, program);\n visit.paused = false;\n visit.need = undefined;\n this.#top = visit;\n this.#used += cost;\n const result = evaluate(program, { ...this.#opts, origin: visit.key });\n this.#used -= cost;\n this.#top = caller;\n if (!visit.paused) visit.result = result;\n }\n\n /** This method ends a cell whose evaluation did not pause: it finishes its component, or it gives its low to the caller. */\n #end(visit: Visit, caller: Visit | undefined): void {\n if (visit.low === visit.index) this.#finish(visit);\n else if (caller !== undefined) caller.low = Math.min(caller.low, visit.low);\n }\n\n /** This method reads a cell from the formula of the cell at the top. */\n #read(column: string, key: string): Result<unknown> {\n const id = idOf(column, key);\n const done = this.#done.get(id);\n if (done !== undefined) return done;\n const caller = this.#top;\n // A paused evaluation reads no other cell, so it does not follow a path that its final evaluation does not follow.\n if (caller.paused) return cycleError(column, key);\n const seen = this.#visits.get(id);\n if (seen !== undefined) {\n // A read of a cell that is not finished: the caller and this cell are on one cycle. The cell is on the\n // stack of the search, so it is in the component of the caller. Thus a component with one cell is cyclic\n // only if that cell reads itself.\n caller.low = Math.min(caller.low, seen.index);\n seen.reread = true;\n return cycleError(column, key);\n }\n const program = this.#columns.get(column);\n if (program === undefined) return fail(vexError(\"unbound\", `the sheet has no column \"${column}\"`, { origin: key, focus: key }));\n const visit = this.#start(column, key);\n if (this.#used + this.#costOf(column, program) > this.#budget) {\n // Over the budget: the caller pauses, and the run evaluates the new cell from its own list.\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#evaluate(visit, program);\n if (visit.paused) {\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#end(visit, caller);\n return this.#done.get(id) ?? cycleError(column, key);\n }\n\n /** This method evaluates a cell from the top level. The cells that pause go on a list, not on the call stack. */\n #drive(column: string, key: string): Result<unknown> {\n const id = idOf(column, key);\n const done = this.#done.get(id);\n if (done !== undefined) return done;\n if (!this.#columns.has(column)) return fail(vexError(\"unbound\", `the sheet has no column \"${column}\"`, { origin: key, focus: key }));\n const work: Visit[] = [this.#start(column, key)];\n for (let visit = work.at(-1); visit !== undefined; visit = work.at(-1)) {\n const program = this.#columns.get(visit.column);\n /* v8 ignore next -- @preserve: a visit exists only for a column with a program */\n if (program === undefined) break;\n this.#evaluate(visit, program);\n if (visit.paused) {\n // The cells that the evaluation waits for go on the list, the last one on the top.\n for (let need = visit.need; need !== undefined; need = need.need) work.push(need);\n continue;\n }\n work.pop();\n this.#end(visit, work.at(-1));\n }\n return this.#done.get(id) ?? cycleError(column, key);\n }\n\n /** This method takes the component of `root` from the stack, and sets the final result of each of its cells. */\n #finish(root: Visit): void {\n // The root is near the top of the stack, so the search starts at the top: a deep chain needs no long scan.\n const members = this.#stack.splice(this.#stack.lastIndexOf(root));\n // A component of two or more cells reads its root again, so root.reread alone decides. The length test is a guard.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: members.length > 1 implies root.reread\n const cyclic = members.length > 1 || root.reread;\n for (const m of members) {\n // Stryker disable next-line CallExpression: a finished cell is in #done, and cell() reads #done first\n this.#visits.delete(m.id);\n this.#done.set(m.id, cyclic ? cycleError(m.column, m.key) : m.result);\n }\n }\n\n /** This method evaluates one cell with a trace of the nodes of its column. The result is the result of the cell. */\n explain(column: string, key: string): Trace {\n const result = this.cell(column, key);\n const program = this.#columns.get(column);\n if (program === undefined) return { events: [], result };\n return { events: explain(program, { ...this.#opts, origin: key }).events, result };\n }\n\n /**\n * This method evaluates the column `column` at each key before `key`, in key order. A recurrence over the keys,\n * for example a running total, then reads finished cells.\n */\n warm(column: string, key: string): void {\n this.#warmTo(column, key);\n }\n}\n","/**\n * The typed builder. Method calls make an expression of the IR. The builder has no other job: it does not\n * evaluate anything until a caller asks for a value.\n */\nimport type { AnyDomain, Domain, OpSpec } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { evaluate, explain, type EvalOptions, type ExtHandler, type FreeFn } from \"./evaluate.ts\";\nimport { app, each, ext, index as indexMove, key as keyMove, let_, lit, offset as offsetMove, other as otherMove, origin as originMove, parent as parentMove, rec, ref, toPath, v, type Addr, type Axis, type Expr, type Move } from \"./ir.ts\";\nimport { cell as cellRef, SheetRun } from \"./sheet.ts\";\nimport { toOptional, type Optional, type Result } from \"./result.ts\";\nimport type { Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\nimport type { VexList } from \"./list.ts\";\nimport { traversal, type Traversal } from \"./traversal.ts\";\n\n// ---------------------------------------------------------------- argument tokens\n\ndeclare const ARG_TYPE: unique symbol;\ndeclare const CHAIN_VALUE: unique symbol;\n\n/** An argument token: an expression with the static type `T` of its value. */\nexport interface Arg<T> {\n readonly kind: \"vex.arg\";\n readonly expr: Expr;\n /** This phantom member carries the type. It is not present at run time. */\n readonly [ARG_TYPE]?: T;\n}\n\nconst argToken = <T>(expr: Expr): Arg<T> => ({ kind: \"vex.arg\", expr });\n\n\n// ---------------------------------------------------------------- type helpers\n\n/** The keys of any member of a union of record types. */\ntype AllKeys<O> = O extends unknown ? keyof O : never;\n\n/** The type of field `P` in the members of `O` that have it. */\ntype FieldType<O, P extends PropertyKey> = O extends unknown ? (P extends keyof O ? O[P] : never) : never;\n\n/**\n * The merged view of a union of record types: each field of any member, with the union of its types. A record\n * without the field gives `#N/A` at run time.\n */\nexport type Merge<O> = { readonly [P in AllKeys<O>]: FieldType<O, P> };\n\n/** The keys of `O` whose values have the type `T`. */\nexport type KeysOfType<O, T> = { [P in keyof O]-?: [NonNullable<O[P]>] extends [never] ? never : NonNullable<O[P]> extends T ? P : never }[keyof O] & string;\n\n/** The method names of `D`. */\nexport type MethodKeys<D> = { [P in keyof D]-?: D[P] extends (...args: never[]) => unknown ? P : never }[keyof D] & string;\n\n/** The value type of a domain. */\nexport type DomainValue<Dm> = Dm extends Domain<string, infer D, infer _Ops> ? D : never;\n\ntype OpsOf<Dm> = Dm extends Domain<string, unknown, infer Ops> ? Ops : Dm extends { readonly ops: infer Ops } ? Ops : never;\n\n/** The op names that a chain over a value of domain `Dm` can use. */\nexport type OpNames<Dm> =\n | (keyof OpsOf<Dm> & string)\n | (Dm extends { readonly methods: \"all\" } ? MethodKeys<DomainValue<Dm>> : never);\n\ntype FnOf<Dm, M extends string> = M extends keyof OpsOf<Dm>\n ? OpsOf<Dm>[M] extends { readonly fn: (self: never, ...args: infer P) => infer R }\n ? (...args: P) => R\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never;\n\n/** The parameters of op `M` after the receiver. */\nexport type OpParams<Dm, M extends string> = FnOf<Dm, M> extends (...args: infer P) => unknown ? P : never;\n\n/** The value type that op `M` gives. */\nexport type OpReturn<Dm, M extends string> = FnOf<Dm, M> extends (...args: never[]) => infer R ? R : never;\n\ntype Lifts<Dm, M extends string> = M extends keyof OpsOf<Dm> ? (OpsOf<Dm>[M] extends { readonly liftScalar: true } ? true : false) : false;\n\n/** The first domain of `Dms` whose values include `T`, or `never`. */\nexport type DomainFor<Dms extends readonly AnyDomain[], T> = Dms extends readonly [infer H, ...infer R extends readonly AnyDomain[]]\n ? [T] extends [never]\n ? never\n : [T] extends [DomainValue<H>]\n ? H\n : DomainFor<R, T>\n : never;\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;\ntype LastOf<U> = UnionToIntersection<U extends unknown ? () => U : never> extends () => infer R ? R : never;\n\n/** `true` if `other()` is permitted for the key type: a pair of keys, or keys that the compiler does not know. */\nexport type AllowsOther<K extends string> = string extends K\n ? true\n : `${number}` extends K\n ? true\n : [Exclude<K, LastOf<K>>] extends [never]\n ? false\n : [Exclude<Exclude<K, LastOf<K>>, LastOf<Exclude<K, LastOf<K>>>>] extends [never]\n ? true\n : false;\n\n/**\n * The inputs for an argument with the parameter type `P`. The input can be a literal of type `P`, but not a bare\n * string. It can be a field of the record with type `P`, an argument token, or a chain that gives `P`. If the op\n * lifts scalars, it can also be a number.\n */\nexport type ArgInput<P, Ctx extends ChainContext, Lift extends boolean> =\n | (P extends string ? never : P)\n | KeysOfType<Ctx[\"record\"], P>\n | Arg<P>\n | ChainOf<Ctx, P>\n | (Lift extends true ? ([P] extends [DomainValue<DomainFor<Ctx[\"domains\"], P>>] ? LiftedNumber<Ctx> : never) : never);\n\n/**\n * A number argument for a domain parameter of an op with `liftScalar` (TYPE.LIFT): a number, a field with numbers, an\n * argument or a chain. The interpreter lifts each of them with `fromScalar` (CALL.LIFT).\n */\ntype LiftedNumber<Ctx extends ChainContext> = number | KeysOfType<Ctx[\"record\"], number> | Arg<number> | ChainOf<Ctx, number>;\n\ntype MapArgs<P extends readonly unknown[], Ctx extends ChainContext, Lift extends boolean> = { [I in keyof P]: ArgInput<P[I], Ctx, Lift> };\n\n/** A table of free functions. The first parameter of a function gets the current value of the chain. */\nexport type FnTable = Readonly<Record<string, (...args: never[]) => unknown>>;\n\n/** The free functions of a builder without `withOptions`: none, so `call` accepts no name. */\n// oxlint-disable-next-line typescript/no-generated-empty-object-type -- an empty table is the intent.\nexport type NoFns = Record<never, never>;\n\n/** The static context of a chain: its domains, its key type, its record type and its free functions. */\nexport interface ChainContext {\n readonly domains: readonly AnyDomain[];\n readonly keys: string;\n readonly record: unknown;\n readonly fns?: FnTable;\n}\n\ntype FnsOf<Ctx extends ChainContext> = NonNullable<Ctx[\"fns\"]>;\ntype FnParams<F> = F extends (...args: infer P) => unknown ? P : never;\ntype FirstParam<P> = P extends readonly [infer A, ...unknown[]] ? A : unknown;\ntype RestParams<P> = P extends readonly [unknown, ...infer R] ? R : [];\n\n/** The names of the free functions whose first parameter accepts a value of type `T`. */\nexport type CallableFns<Ctx extends ChainContext, T> = {\n [K in keyof FnsOf<Ctx>]: [T] extends [FirstParam<FnParams<FnsOf<Ctx>[K]>>] ? K : never;\n}[keyof FnsOf<Ctx>] &\n string;\n\n/** The inputs for the parameters of the free function `N` after its first parameter. */\nexport type CallArgs<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = MapArgs<RestParams<FnParams<FnsOf<Ctx>[N]>>, Ctx, false>;\n\n/** The return type of the free function `N`. */\nexport type CallReturn<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = FnsOf<Ctx>[N] extends (...args: never[]) => infer R ? R : unknown;\n\n/** The ops section `._` of a chain whose value has domain `Dm`. */\nexport type OpsProxy<Ctx extends ChainContext, Dm> = {\n readonly [M in OpNames<Dm>]: (...args: MapArgs<OpParams<Dm, M>, Ctx, Lifts<Dm, M>>) => ChainOf<Ctx, OpReturn<Dm, M>>;\n};\n\n// ---------------------------------------------------------------- chain types\n\n/** The members of every chain. */\nexport interface ChainBase<Ctx extends ChainContext, T> {\n readonly kind: \"vex.chain\";\n /** This phantom member carries the value type. It is not present at run time. */\n readonly [CHAIN_VALUE]?: T;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /** This method evaluates the chain at a key. An error gives `none`. */\n at(k: Ctx[\"keys\"]): Optional<T>;\n /** This method is the same as `at`. The v0.9 spec calls it `value`. */\n value(k: Ctx[\"keys\"]): Optional<T>;\n /** This method evaluates the chain at a key, and gives the error if there is one. */\n result(k: Ctx[\"keys\"]): Result<T>;\n /** This method evaluates the chain at a key, with a trace of each node. */\n explain(k: Ctx[\"keys\"]): Trace;\n /** This method evaluates the chain at each key of the space (the start axis). */\n all(): Traversal<Ctx[\"keys\"], T>;\n /** This method gives a chain whose value is a field of the record at the current address. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** Navigation: later field references read at the key `k`. */\n to(k: Ctx[\"keys\"]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the key with this position in the key order. */\n index(i: number): ChainOf<Ctx, T>;\n /** Navigation: later field references read at a relative position in an array or a grid. */\n offset(...d: readonly number[]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the origin again. */\n origin(): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the parent of the focus, in a tree space. A root gives `#REF!`. */\n parent(): ChainOf<Ctx, T>;\n /** This method uses `fallback` when the chain gives an error. */\n ifError<U>(fallback: ArgInput<U, Ctx, false> | T): ChainOf<Ctx, T | U>;\n /**\n * This method gives `then` when the boolean value is true, and `otherwise` when it is false (the form `if`). Only\n * the selected branch evaluates.\n */\n if<U, V>(this: ChainBase<Ctx, boolean>, then: ArgInput<U, Ctx, false>, otherwise: ArgInput<V, Ctx, false>): ChainOf<Ctx, U | V>;\n /**\n * This method applies the free function `name` of `withOptions`. The function gets the current value as its first\n * argument, then `args`. The types accept only the functions whose first parameter accepts the current value.\n */\n call<N extends CallableFns<Ctx, T>>(name: N, ...args: CallArgs<Ctx, N>): ChainOf<Ctx, CallReturn<Ctx, N>>;\n /** This method evaluates each branch with the current value, and gives a record of the results. */\n fork<const B extends Readonly<Record<string, (c: ChainOf<Ctx, T>) => ChainBase<Ctx, unknown>>>>(branches: B): ChainOf<Ctx, { readonly [N in keyof B]: ValueOf<ReturnType<B[N]>> }>;\n /** This method binds names for the body. The body gets a variable token for each name. */\n with<const B extends Readonly<Record<string, unknown>>, U>(\n binds: B,\n body: (c: ChainOf<Ctx, T>, vars: { readonly [N in keyof B]: Arg<ArgValue<Ctx, B[N]>> }) => ChainBase<Ctx, U>,\n ): ChainOf<Ctx, U>;\n /** The others axis: the body evaluates at each key except the focus. Its start value is the current value. */\n others<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The neighbors axis of a grid. */\n neighbors<U>(n: 4 | 8, body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The all axis inside the expression: the body evaluates at each key, with the current value as start value. */\n each<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The children axis of a tree space: the body evaluates at each child of the focus. */\n children<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The ancestors axis of a tree space: the parent first, the root last. */\n ancestors<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The descendants axis of a tree space: depth first, each parent before its children. */\n descendants<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The siblings axis of a tree space: the other children of the parent, or the other roots for a root. */\n siblings<U>(body: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n}\n\n/** The options of an axis. */\nexport interface AxisOpts<Ctx extends ChainContext, T> {\n /** A test at each target. The body evaluates only at the targets where the test gives `true`. */\n readonly where?: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, boolean>;\n}\n\n/** The members of a chain whose value has a domain. */\nexport interface DomainMembers<Ctx extends ChainContext, Dm> {\n /** The ops of the domain of the current value. */\n readonly _: OpsProxy<Ctx, Dm>;\n}\n\n/** The members of a chain over a space whose keys permit `other()`. */\nexport interface OtherMembers<Ctx extends ChainContext, T> {\n /** Navigation: later field references read at the other key of the pair. */\n other(): ChainOf<Ctx, T>;\n}\n\n/** A chain with the current value type `T`. */\nexport type ChainOf<Ctx extends ChainContext, T> = ChainBase<Ctx, T> &\n ([DomainFor<Ctx[\"domains\"], T>] extends [never] ? unknown : DomainMembers<Ctx, DomainFor<Ctx[\"domains\"], T>>) &\n (AllowsOther<Ctx[\"keys\"]> extends true ? OtherMembers<Ctx, T> : unknown);\n\n/** The value type of a chain. */\nexport type ValueOf<C> = C extends { readonly [CHAIN_VALUE]?: infer T } ? T : never;\n\n/** The value type of an argument input. */\nexport type ArgValue<Ctx extends ChainContext, A> = A extends Arg<infer T>\n ? T\n : A extends { readonly kind: \"vex.chain\" }\n ? ValueOf<A>\n : A extends keyof Ctx[\"record\"] & string\n ? NonNullable<Ctx[\"record\"][A]>\n : A;\n\n/** A chain whose value is a list: the result of an axis. */\nexport interface ListChain<Ctx extends ChainContext, U> {\n readonly kind: \"vex.list-chain\";\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n count(opts?: ListOpts): ChainOf<Ctx, number>;\n sum(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n mean(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n min(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n max(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n any(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n all(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n none(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n values(opts?: ListOpts): ChainOf<Ctx, readonly U[]>;\n /** The keys of the items with a value, in the order of the axis. */\n keys(opts?: ListOpts): ChainOf<Ctx, readonly Ctx[\"keys\"][]>;\n /** The error of each item that failed, in the order of the axis. */\n errors(): ChainOf<Ctx, readonly VexError[]>;\n first(opts?: ListOpts): ChainOf<Ctx, U>;\n reduce(op: OpNames<DomainFor<Ctx[\"domains\"], U>>, opts?: ReduceOpts<Ctx>): ChainOf<Ctx, U>;\n /** The list at the origin `k`: one item for each target of the axis, with its key and its result. */\n result(k: Ctx[\"keys\"]): Result<VexList<U>>;\n /** The list at the origin `k`, as an `Optional`. */\n at(k: Ctx[\"keys\"]): Optional<VexList<U>>;\n /** The trace of the evaluation of the list at the origin `k`. */\n explain(k: Ctx[\"keys\"]): Trace;\n}\n\n/** The options of a list reduction. */\nexport interface ListOpts {\n /** With `true`, an error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n\n/** The options of `reduce`. `domain` names the domain whose identity an empty list gives (LIST.EMPTY). */\nexport interface ReduceOpts<Ctx extends ChainContext> extends ListOpts {\n readonly domain?: Ctx[\"domains\"][number][\"name\"];\n}\n\n/** The root of the builder for one space. */\nexport interface Root<Ctx extends ChainContext> {\n /** This method starts a chain with a field of the record at the focus. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** This method starts a chain with a value. A string is a field reference, as in an argument. */\n start<const T>(value: T): ChainOf<Ctx, ArgValue<Ctx, T>>;\n /** This method makes an absolute reference: the field of the record at key `k`. */\n of<P extends keyof Ctx[\"record\"] & string>(k: Ctx[\"keys\"], field: P): Arg<NonNullable<Ctx[\"record\"][P]>>;\n /** This method makes a reference to a dotted path at the focus, with the type that the caller gives. */\n field<T>(path: string): Arg<T>;\n /** This method makes a literal argument. Use it for a string or an array: a bare string is a field reference. */\n lit<const T>(value: T): Arg<T>;\n /** This method makes an absolute reference to a dotted path at key `k`, with the type that the caller gives. */\n ofPath<T>(k: Ctx[\"keys\"], path: string): Arg<T>;\n /** This method makes a record argument from field arguments. */\n rec<const F extends Readonly<Record<string, unknown>>>(fields: F): Arg<{ readonly [N in keyof F]: ArgValue<Ctx, F[N]> }>;\n /**\n * This method makes an extension argument: the node `ext(kind, data)`. The handler of `kind` in the options of\n * `withOptions` gives its value. The caller gives the type `T` of that value.\n */\n ext<T>(kind: string, data?: unknown): Arg<T>;\n /** This method starts a sheet over the space: named columns of formulas. Refer to `Sheet`. */\n sheet(): Sheet<Ctx, object>;\n /** The space of the root. */\n readonly space: Space<Ctx[\"keys\"], Ctx[\"record\"]>;\n}\n\n/** The root of a column formula: the root of the builder, and references to the cells of the sheet. */\nexport interface SheetRoot<Ctx extends ChainContext, Cols> extends Root<Ctx> {\n /**\n * This method makes a cell reference: the column `column` at the key `at`, or at the address `at` from the focus.\n * Without `at`, it reads at the focus. The type is the type of a column before this one.\n */\n cell<N extends keyof Cols & string>(column: N, at?: Ctx[\"keys\"] | Addr): Arg<Cols[N]>;\n /** This method makes a cell reference to any column, also this column or a later one. The caller gives the type. */\n cell<T>(column: string, at?: Ctx[\"keys\"] | Addr): Arg<T>;\n}\n\n/** One row of a sheet: the key and the result of each column. */\nexport interface SheetRow<K extends string, Cols> {\n readonly key: K;\n readonly cells: { readonly [N in keyof Cols]: Result<Cols[N]> };\n}\n\n/**\n * A sheet: named columns of formulas over a space, like the computed columns of a spreadsheet. A formula reads the\n * other columns with `cell`. Each evaluation evaluates a cell once, and each cell on a cycle of references gives\n * `#CYCLE!`. A sheet is immutable: `column` gives a new sheet.\n */\nexport interface Sheet<Ctx extends ChainContext, Cols, Decl = object> {\n /**\n * This method gives a new sheet with one more column. The formula gets a root with `cell`. If `declare` gave the\n * column a type, the formula must give a value of that type.\n */\n column<const N extends string, C extends ChainBase<Ctx, DeclaredType<Decl, N>>>(\n name: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => C,\n ): Sheet<Ctx, Cols & { readonly [P in N]: ValueOf<C> }, Decl>;\n /**\n * This method gives the types of columns before their formulas. A formula can then read a declared column with\n * `cell` and its type: the column itself (a recurrence) or a later column. It has no effect at run time.\n */\n declare<D extends Readonly<Record<string, unknown>>>(): Sheet<Ctx, Cols, Decl & D>;\n /** The program of each column. */\n readonly columns: Readonly<Record<string, Expr>>;\n /** This method evaluates one cell, and gives the error if there is one. */\n result<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Result<Cols[N]>;\n /** This method evaluates one cell. An error gives `none`. */\n at<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Optional<Cols[N]>;\n /** This method evaluates one cell, with a trace of the nodes of its column. */\n explain(k: Ctx[\"keys\"], column: keyof Cols & string): Trace;\n /** This method evaluates each cell, in key order, with one result for each cell. */\n table(): readonly SheetRow<Ctx[\"keys\"], Cols>[];\n}\n\n/** The declared type of the column `N`, or `unknown` for a column without a declaration. */\nexport type DeclaredType<Decl, N extends string> = N extends keyof Decl ? Decl[N] : unknown;\n\n/** The options of the builder. */\nexport interface VexOptions<F extends FnTable = FnTable> {\n /** Free function ops. A chain applies them with `call`. */\n readonly fns?: F;\n /** Handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** The entry point for a list of domains. */\nexport interface VexEntry<Dms extends readonly AnyDomain[], F extends FnTable = NoFns> {\n /** This method gives the root of the builder for a space. */\n over<K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }>;\n /** The domains. */\n readonly domains: Dms;\n}\n\n// ---------------------------------------------------------------- run time\n\n/** The options as the interpreter takes them: free functions get untyped arguments at run time. */\ninterface RuntimeOptions {\n readonly fns?: Readonly<Record<string, FreeFn>>;\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** This function gives the run-time form of the options. A typed free function gets the values that the types promise. */\nconst runtimeOptions = (options: VexOptions): RuntimeOptions => ({\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns as Readonly<Record<string, FreeFn>> }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n});\n\ninterface Env {\n readonly space: Space;\n readonly domains: readonly AnyDomain[];\n readonly options: RuntimeOptions;\n}\n\ninterface State {\n readonly env: Env;\n /** The current value. */\n readonly expr: Expr;\n /** The address where later field references read. */\n readonly addr: readonly Move[];\n /** The depth of nested axis and binding bodies, for unique variable names. */\n readonly depth: number;\n}\n\nconst kindOf = (u: unknown): unknown => (u as { kind?: unknown } | null | undefined)?.kind;\nconst isArg = (u: unknown): u is Arg<unknown> => kindOf(u) === \"vex.arg\";\nconst isChainLike = (u: unknown): u is { readonly program: Expr } => kindOf(u) === \"vex.chain\" || kindOf(u) === \"vex.list-chain\";\n\n/** This function turns a builder argument into an expression. A bare string is a field reference at `addr`. */\nfunction toExpr(a: unknown, addr: readonly Move[]): Expr {\n if (typeof a === \"string\") return ref(toPath(a), addr);\n if (isArg(a)) return a.expr;\n if (isChainLike(a)) return a.program;\n return lit(a);\n}\n\nconst PROXY_RESERVED = new Set([\"then\", \"catch\", \"finally\", \"toJSON\", \"valueOf\", \"toString\", \"constructor\", \"inspect\", \"asymmetricMatch\", \"$$typeof\", \"nodeType\"]);\n\nclass ChainImpl {\n readonly kind = \"vex.chain\" as const;\n readonly #s: State;\n\n constructor(s: State) {\n this.#s = s;\n }\n\n get program(): Expr {\n return this.#s.expr;\n }\n\n get _(): Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>> {\n const s = this.#s;\n return new Proxy(Object.create(null) as Record<string, never>, {\n get: (_t, prop): unknown => {\n if (typeof prop !== \"string\" || PROXY_RESERVED.has(prop)) return undefined;\n return (...args: readonly unknown[]): ChainImpl => new ChainImpl({ ...s, expr: app(prop, s.expr, ...args.map((a) => toExpr(a, s.addr))) });\n },\n });\n }\n\n #opts(k: string): EvalOptions {\n return evalOptions(this.#s, k);\n }\n\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, this.#opts(k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n value(k: string): Optional<unknown> {\n return this.at(k);\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, this.#opts(k));\n }\n all(): Traversal<string, unknown> {\n const { env } = this.#s;\n const items = env.space.keys.map((k) => ({ key: k, result: this.result(k) }));\n return traversal(items, env);\n }\n\n from(field: string): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: ref(toPath(field), this.#s.addr) });\n }\n\n #move(m: Move): ChainImpl {\n return new ChainImpl({ ...this.#s, addr: [...this.#s.addr, m] });\n }\n to(k: string): ChainImpl {\n return this.#move(keyMove(k));\n }\n index(i: number): ChainImpl {\n return this.#move(indexMove(i));\n }\n offset(...d: readonly number[]): ChainImpl {\n return this.#move(offsetMove(...d));\n }\n other(): ChainImpl {\n return this.#move(otherMove);\n }\n origin(): ChainImpl {\n return this.#move(originMove);\n }\n parent(): ChainImpl {\n return this.#move(parentMove);\n }\n\n call(name: string, ...args: readonly unknown[]): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(name, this.#s.expr, ...args.map((a) => toExpr(a, this.#s.addr))) });\n }\n if(then: unknown, otherwise: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"if\", this.#s.expr, toExpr(then, this.#s.addr), toExpr(otherwise, this.#s.addr)) });\n }\n ifError(fallback: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"ifError\", this.#s.expr, toExpr(fallback, this.#s.addr)) });\n }\n\n /** This method binds the current value to a fresh name, and gives a chain that starts from that name. */\n #bound(): { readonly name: string; readonly start: ChainImpl } {\n const name = `$${this.#s.depth}`;\n return { name, start: new ChainImpl({ ...this.#s, expr: v(name), depth: this.#s.depth + 1 }) };\n }\n\n fork(branches: Readonly<Record<string, (c: ChainImpl) => { readonly program: Expr }>>): ChainImpl {\n const { name, start } = this.#bound();\n const fields: Record<string, Expr> = {};\n for (const [n, f] of Object.entries(branches)) fields[n] = f(start).program;\n return new ChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, rec(fields)) });\n }\n\n with(binds: Readonly<Record<string, unknown>>, body: (c: ChainImpl, vars: Readonly<Record<string, Arg<unknown>>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const bindExprs: Record<string, Expr> = {};\n const vars: Record<string, Arg<unknown>> = {};\n for (const [n, a] of Object.entries(binds)) {\n const unique = `${n}$${depth}`;\n bindExprs[unique] = toExpr(a, this.#s.addr);\n vars[n] = argToken(v(unique));\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), vars);\n return new ChainImpl({ ...this.#s, expr: let_(bindExprs, inner.program) });\n }\n\n #axis(a: Axis, body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n const { name, start } = this.#bound();\n // Inside the axis, the focus is the target, so the address of the body starts empty.\n const inTarget = new ChainImpl({ ...start.#s, addr: [] });\n const inner = body(inTarget);\n const axis: Axis = opts?.where === undefined ? a : { t: \"where\", axis: a, test: opts.where(inTarget).program };\n // The moves before the axis are its address: parent().children(f) gives f at each child of the parent.\n return new ListChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, each(axis, inner.program, this.#s.addr)) });\n }\n others(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"others\" }, body, opts);\n }\n neighbors(n: 4 | 8, body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"neighbors\", n }, body, opts);\n }\n each(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"all\" }, body, opts);\n }\n children(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"children\" }, body, opts);\n }\n ancestors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"ancestors\" }, body, opts);\n }\n descendants(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"descendants\" }, body, opts);\n }\n siblings(body: (c: ChainImpl) => { readonly program: Expr }, opts?: { readonly where?: (c: ChainImpl) => { readonly program: Expr } }): ListChainImpl {\n return this.#axis({ t: \"siblings\" }, body, opts);\n }\n}\n\n/** This function gives the options of an evaluation of a chain or a list chain at the origin `k`. */\nfunction evalOptions(s: State, k: string): EvalOptions {\n const { env } = s;\n return {\n space: env.space,\n origin: k,\n domains: env.domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.fns === undefined ? {} : { fns: env.options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.extensions === undefined ? {} : { extensions: env.options.extensions }),\n };\n}\n\nclass ListChainImpl {\n readonly kind = \"vex.list-chain\" as const;\n readonly #s: State;\n constructor(s: State) {\n this.#s = s;\n }\n get program(): Expr {\n return this.#s.expr;\n }\n #op(op: string, extra: readonly Expr[], opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n const options = { ...(opts?.strict === true ? { strict: true } : {}), ...(opts?.domain === undefined ? {} : { domain: opts.domain }) };\n const args = Object.keys(options).length > 0 ? [...extra, lit(options)] : extra;\n return new ChainImpl({ ...this.#s, expr: app(op, this.#s.expr, ...args) });\n }\n count(opts?: ListOpts): ChainImpl {\n return this.#op(\"count\", [], opts);\n }\n sum(opts?: ListOpts): ChainImpl {\n return this.#op(\"sum\", [], opts);\n }\n mean(opts?: ListOpts): ChainImpl {\n return this.#op(\"mean\", [], opts);\n }\n min(opts?: ListOpts): ChainImpl {\n return this.#op(\"min\", [], opts);\n }\n max(opts?: ListOpts): ChainImpl {\n return this.#op(\"max\", [], opts);\n }\n any(opts?: ListOpts): ChainImpl {\n return this.#op(\"any\", [], opts);\n }\n all(opts?: ListOpts): ChainImpl {\n return this.#op(\"all\", [], opts);\n }\n none(opts?: ListOpts): ChainImpl {\n return this.#op(\"none\", [], opts);\n }\n values(opts?: ListOpts): ChainImpl {\n return this.#op(\"values\", [], opts);\n }\n keys(opts?: ListOpts): ChainImpl {\n return this.#op(\"keys\", [], opts);\n }\n errors(): ChainImpl {\n return this.#op(\"errors\", []);\n }\n first(opts?: ListOpts): ChainImpl {\n return this.#op(\"first\", [], opts);\n }\n reduce(op: string, opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n return this.#op(\"reduce\", [lit(op)], opts);\n }\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, evalOptions(this.#s, k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, evalOptions(this.#s, k));\n }\n}\n\nclass RootImpl {\n readonly #env: Env;\n constructor(env: Env) {\n this.#env = env;\n }\n get space(): Space {\n return this.#env.space;\n }\n #chain(expr: Expr): ChainImpl {\n return new ChainImpl({ env: this.#env, expr, addr: [], depth: 0 });\n }\n from(field: string): ChainImpl {\n return this.#chain(ref(toPath(field)));\n }\n start(value: unknown): ChainImpl {\n return this.#chain(toExpr(value, []));\n }\n of(k: string, field: string): Arg<unknown> {\n return argToken(ref(toPath(field), [keyMove(k)]));\n }\n field(path: string): Arg<unknown> {\n return argToken(ref(toPath(path)));\n }\n lit(value: unknown): Arg<unknown> {\n return argToken(lit(value));\n }\n ofPath(k: string, path: string): Arg<unknown> {\n return argToken(ref(toPath(path), [keyMove(k)]));\n }\n ext(kind: string, data: unknown = null): Arg<unknown> {\n return argToken(ext(kind, data));\n }\n sheet(): SheetImpl {\n return new SheetImpl(this.#env, new Map());\n }\n rec(fields: Readonly<Record<string, unknown>>): Arg<unknown> {\n const out: Record<string, Expr> = {};\n for (const [n, a] of Object.entries(fields)) out[n] = toExpr(a, []);\n return argToken(rec(out));\n }\n}\n\nclass SheetRootImpl extends RootImpl {\n cell(column: string, at?: string | Addr): Arg<unknown> {\n return argToken(cellRef(column, typeof at === \"string\" ? [keyMove(at)] : at));\n }\n}\n\nclass SheetImpl {\n readonly #env: Env;\n readonly #columns: ReadonlyMap<string, Expr>;\n constructor(env: Env, columns: ReadonlyMap<string, Expr>) {\n this.#env = env;\n this.#columns = columns;\n }\n get columns(): Readonly<Record<string, Expr>> {\n return Object.freeze(Object.fromEntries(this.#columns));\n }\n declare(): SheetImpl {\n return this;\n }\n column(name: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n return new SheetImpl(this.#env, new Map([...this.#columns, [name, program]]));\n }\n #run(): SheetRun {\n const { space: s, domains, options } = this.#env;\n return new SheetRun(this.#columns, {\n space: s,\n domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n });\n }\n result(k: string, column: string): Result<unknown> {\n const run = this.#run();\n run.warm(column, k);\n return run.cell(column, k);\n }\n at(k: string, column: string): Optional<unknown> {\n return toOptional(this.result(k, column));\n }\n explain(k: string, column: string): Trace {\n const run = this.#run();\n run.warm(column, k);\n return run.explain(column, k);\n }\n table(): readonly SheetRow<string, Record<string, unknown>>[] {\n const run = this.#run();\n const names = [...this.#columns.keys()];\n return this.#env.space.keys.map((key) => ({ key, cells: Object.fromEntries(names.map((c) => [c, run.cell(c, key)])) }));\n }\n}\n\n/**\n * This function gives the entry point of the builder for a list of domains. The interpreter finds the op of a\n * value in the first domain that accepts the value.\n */\nexport function vex<const Dms extends readonly AnyDomain[]>(\n ...domains: Dms\n): VexEntry<Dms> & { withOptions<const F extends FnTable = NoFns>(options: VexOptions<F>): VexEntry<Dms, F> } {\n const make = <F extends FnTable>(options: VexOptions<F>): VexEntry<Dms, F> => ({\n domains,\n over: <K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }> =>\n new RootImpl({ space: s, domains, options: runtimeOptions(options) }) as unknown as Root<{\n readonly domains: Dms;\n readonly keys: K;\n readonly record: Merge<O>;\n readonly fns: F;\n }>,\n });\n return { ...make<NoFns>({}), withOptions: make };\n}\n\n/** The type of a domain value, from the domain object. */\nexport type ValueOfDomain<Dm> = DomainValue<Dm>;\n\n/** An op specification type, for domain authors. */\nexport type { OpSpec };\n"],"mappings":";AAaA,MAAM,OAAwB,OAAO,OAAO,EAAE,KAAK,OAAO,CAAC;;AAG3D,MAAa,QAAW,WAA2B;CAAE,KAAK;CAAQ;AAAM;;AAGxE,MAAa,aAAqC;;AAGlD,MAAa,MAAS,WAAyB;CAAE,IAAI;CAAM;AAAM;;AAGjE,MAAa,QAAmB,WAAgC;CAAE,IAAI;CAAO;AAAM;;AAGnF,MAAa,UAAa,MAAqE,EAAE,QAAQ;;AAGzG,MAAa,UAAa,MAAkD,EAAE,QAAQ;;AAGtF,MAAa,cAAiB,MAA+B,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,KAAK;;AAGzF,MAAa,SAAe,GAAgB,aAAwB,EAAE,QAAQ,SAAS,EAAE,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