@lucidkiln/core 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-BbikGqIb.js","names":["lookup"],"sources":["../src/errors.ts","../src/names.ts","../src/runtime/escape.ts","../src/runtime/markup.ts","../src/suggest.ts","../src/runtime/scope.ts","../src/runtime/types.ts","../src/runtime/outlets.ts","../src/runtime/ahead.ts","../src/runtime/exposure.ts","../src/runtime/values.ts","../src/runtime/render.ts","../src/runtime/access.ts","../src/builtins/helpers.ts","../src/runtime/operators.ts","../src/builtins/functions.ts","../src/source.ts"],"sourcesContent":["import type { Position, Source, Span } from \"./source.js\";\n\nexport type Diagnostic = {\n\t/** A stable kebab-case code, such as `unknown-filter`. */\n\tcode: string;\n\tmessage: string;\n\tseverity: \"error\" | \"warning\";\n\t/** Resolved template name. */\n\ttemplate: string;\n\tstart: Position;\n\tend: Position;\n};\n\nexport type TemplateLocation = {\n\ttemplate: string;\n\tline: number;\n\tcolumn: number;\n};\n\n/** Creates a diagnostic for a span of a source. */\nexport const createDiagnostic = (\n\tsource: Source,\n\tcode: string,\n\tmessage: string,\n\tspan: Span,\n\tseverity: Diagnostic[\"severity\"] = \"error\",\n): Diagnostic => ({\n\tcode,\n\tmessage,\n\tseverity,\n\ttemplate: source.name,\n\tstart: source.position(span.start),\n\tend: source.position(span.end),\n});\n\nconst describe = (location: TemplateLocation) =>\n\t`in ${location.template} at line ${location.line}, column ${location.column}`;\n\n/**\n * Thrown when a template cannot be parsed or compiled. `diagnostics` lists every problem found.\n */\nexport class KilnSyntaxError extends Error {\n\toverride name = \"KilnSyntaxError\";\n\treadonly diagnostics: Diagnostic[];\n\n\tconstructor(diagnostics: Diagnostic[], source: Source) {\n\t\tconst errors = diagnostics.filter((d) => d.severity === \"error\");\n\t\tconst first = errors[0] ?? diagnostics[0];\n\t\tlet message = \"Template could not be parsed.\";\n\t\tif (first) {\n\t\t\tmessage = `${first.message} ${describe({ template: first.template, line: first.start.line, column: first.start.column })}.`;\n\t\t\tif (first.template === source.name) {\n\t\t\t\tmessage += `\\n\\n${source.frame({ start: first.start.offset, end: first.end.offset })}`;\n\t\t\t}\n\t\t\tif (errors.length > 1) {\n\t\t\t\tmessage += `\\n\\n${errors.length - 1} more ${errors.length === 2 ? \"problem\" : \"problems\"} found.`;\n\t\t\t}\n\t\t}\n\t\tsuper(message);\n\t\tthis.diagnostics = diagnostics;\n\t}\n}\n\n/**\n * Thrown while rendering: type errors, missing variables, limits, missing templates and errors from host functions.\n */\nexport class KilnRenderError extends Error {\n\toverride name = \"KilnRenderError\";\n\treadonly code: string;\n\treadonly template: string;\n\treadonly line: number;\n\treadonly column: number;\n\t/** A few lines of source around the error, with a marker. */\n\treadonly frame: string;\n\t/** Templates from the outermost to the one that failed. */\n\treadonly templateStack: TemplateLocation[];\n\treadonly #detail: string;\n\n\t/**\n\t * `source` is a template name alone when the error has no position, such as a missing top-level template. `line` and `column` are then 0.\n\t */\n\tconstructor(\n\t\tcode: string,\n\t\tdetail: string,\n\t\tsource: Source | string,\n\t\tspan: Span = { start: 0, end: 0 },\n\t\toptions: { hint?: string; cause?: unknown } = {},\n\t) {\n\t\tconst hint = options.hint ? ` ${options.hint}` : \"\";\n\t\tlet location: TemplateLocation;\n\t\tlet frame = \"\";\n\t\tlet message: string;\n\t\tif (typeof source === \"string\") {\n\t\t\tlocation = { template: source, line: 0, column: 0 };\n\t\t\tmessage = `${detail}.${hint}`;\n\t\t} else {\n\t\t\tconst start = source.position(span.start);\n\t\t\tlocation = {\n\t\t\t\ttemplate: source.name,\n\t\t\t\tline: start.line,\n\t\t\t\tcolumn: start.column,\n\t\t\t};\n\t\t\tframe = source.frame(span);\n\t\t\tmessage = `${detail} ${describe(location)}.${hint}\\n\\n${frame}`;\n\t\t}\n\t\tsuper(message, { cause: options.cause });\n\t\tthis.code = code;\n\t\tthis.template = location.template;\n\t\tthis.line = location.line;\n\t\tthis.column = location.column;\n\t\tthis.frame = frame;\n\t\tthis.templateStack = [location];\n\t\tthis.#detail = detail;\n\t}\n\n\t/** The message without its location and code frame. */\n\tget detail(): string {\n\t\treturn this.#detail;\n\t}\n}\n\n/**\n * Raised inside built-ins and runtime helpers that do not know where they were called from.\n *\n * The compiled call site catches it and rethrows a `KilnRenderError` with a location.\n */\nexport class KilnIssue extends Error {\n\tconstructor(\n\t\treadonly code: string,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\n/** Shorthand for throwing a `KilnIssue`. */\nexport const issue = (code: string, message: string): never => {\n\tthrow new KilnIssue(code, message);\n};\n","import { issue } from \"./errors.js\";\n\nexport const TEMPLATE_EXTENSION = \".kiln\";\n\n/**\n * Resolves a template name to a normalised path with an extension.\n *\n * Names starting with `./` or `../` are relative to the directory of `from`. Other names are relative to the loader's root.\n * A name whose last segment already holds a dot, such as `data/config.json`, keeps it and gets no extension.\n */\nexport const resolveTemplateName = (name: string, from?: string): string => {\n\tif (name === \"\")\n\t\treturn issue(\"invalid-template-name\", \"Template name is empty\");\n\tif (name.startsWith(\"/\")) {\n\t\treturn issue(\n\t\t\t\"invalid-template-name\",\n\t\t\t`Template name \"${name}\" must not start with \"/\"`,\n\t\t);\n\t}\n\tif (name.includes(\"\\0\")) {\n\t\treturn issue(\n\t\t\t\"invalid-template-name\",\n\t\t\t`Template name ${JSON.stringify(name)} must not contain a null character`,\n\t\t);\n\t}\n\tif (name.includes(\"\\\\\")) {\n\t\treturn issue(\n\t\t\t\"invalid-template-name\",\n\t\t\t`Template name \"${name}\" must use \"/\" as its separator`,\n\t\t);\n\t}\n\n\tconst relative = name.startsWith(\"./\") || name.startsWith(\"../\");\n\tconst lastSegment = name.slice(name.lastIndexOf(\"/\") + 1);\n\tif (lastSegment === \"\" || lastSegment === \".\" || lastSegment === \"..\") {\n\t\treturn issue(\n\t\t\t\"invalid-template-name\",\n\t\t\t`Template name \"${name}\" names a folder, not a template`,\n\t\t);\n\t}\n\tconst segments: string[] = [];\n\tif (relative && from) {\n\t\tsegments.push(...from.split(\"/\").slice(0, -1));\n\t}\n\n\tfor (const segment of name.split(\"/\")) {\n\t\tif (segment === \"\" || segment === \".\") {\n\t\t\tif (segment === \"\" && !relative) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"invalid-template-name\",\n\t\t\t\t\t`Template name \"${name}\" has an empty path segment`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (segment === \"..\") {\n\t\t\tif (segments.length === 0) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"invalid-template-name\",\n\t\t\t\t\t`Template name \"${name}\" points outside the template root`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tsegments.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tsegments.push(segment);\n\t}\n\n\tconst last = segments[segments.length - 1];\n\tif (last === undefined) {\n\t\treturn issue(\"invalid-template-name\", `Template name \"${name}\" is empty`);\n\t}\n\tif (!last.includes(\".\")) {\n\t\tsegments[segments.length - 1] = `${last}${TEMPLATE_EXTENSION}`;\n\t}\n\treturn segments.join(\"/\");\n};\n","import { issue } from \"../errors.js\";\nimport type { EscapeStrategy } from \"../parser/ast.js\";\n\n/*\n * Escaping can make text up to nine times longer, so a chain of `escape` filters could build strings far longer than\n * any render could print. Every escaper stops once its result passes the limit its caller passes: the `escape` filter\n * passes the render's `maxOutputLength`. Autoescaped output needs no limit here, as `write` checks what it prints.\n */\n\n/** Throws a `KilnIssue`, which the call site locates. */\nconst tooLong = (limit: number): never =>\n\tissue(\n\t\t\"limit-output\",\n\t\t`Escaping made a string longer than the output limit of ${limit}`,\n\t);\n\n/** Global, so a test leaves `lastIndex` just past the first match. */\nconst HTML_CHARACTERS = /[&<>\"']/g;\n\n/**\n * Escapes text for element content and quoted attribute values. Most text has nothing to escape, which one regular\n * expression test finds; the rest is copied a slice at a time, from the first character that needs escaping.\n */\nexport const escapeHtml = (value: string, limit?: number): string => {\n\tHTML_CHARACTERS.lastIndex = 0;\n\tif (!HTML_CHARACTERS.test(value)) return value;\n\tlet result = \"\";\n\tlet last = 0;\n\tfor (let i = HTML_CHARACTERS.lastIndex - 1; i < value.length; i++) {\n\t\tlet replacement: string;\n\t\tswitch (value.charCodeAt(i)) {\n\t\t\tcase 38:\n\t\t\t\treplacement = \"&amp;\";\n\t\t\t\tbreak;\n\t\t\tcase 60:\n\t\t\t\treplacement = \"&lt;\";\n\t\t\t\tbreak;\n\t\t\tcase 62:\n\t\t\t\treplacement = \"&gt;\";\n\t\t\t\tbreak;\n\t\t\tcase 34:\n\t\t\t\treplacement = \"&quot;\";\n\t\t\t\tbreak;\n\t\t\tcase 39:\n\t\t\t\treplacement = \"&#39;\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (last !== i) result += value.slice(last, i);\n\t\tresult += replacement;\n\t\tlast = i + 1;\n\t}\n\t// Each character grows at most six times, so checking once at the end keeps the work bounded.\n\tconst most = limit ?? Infinity;\n\tif (result.length + value.length - last > most) tooLong(most);\n\treturn last < value.length ? result + value.slice(last) : result;\n};\n\nconst isAlphanumeric = (code: number) =>\n\t(code >= 48 && code <= 57) ||\n\t(code >= 65 && code <= 90) ||\n\t(code >= 97 && code <= 122);\n\n/** Escapes everything except letters, digits, `,`, `.`, `-` and `_` as character references, so values are safe even unquoted. */\nconst escapeAttr = (value: string, limit: number): string => {\n\tlet result = \"\";\n\tfor (const char of value) {\n\t\tif (result.length > limit) tooLong(limit);\n\t\tconst code = char.codePointAt(0) as number;\n\t\tif (\n\t\t\tisAlphanumeric(code) ||\n\t\t\tcode === 44 ||\n\t\t\tcode === 46 ||\n\t\t\tcode === 45 ||\n\t\t\tcode === 95\n\t\t) {\n\t\t\tresult += char;\n\t\t} else if (char === \"&\") result += \"&amp;\";\n\t\telse if (char === \"<\") result += \"&lt;\";\n\t\telse if (char === \">\") result += \"&gt;\";\n\t\telse if (char === '\"') result += \"&quot;\";\n\t\telse if (\n\t\t\t(code < 0x20 && code !== 9 && code !== 10 && code !== 13) ||\n\t\t\t(code >= 0x7f && code <= 0x9f) ||\n\t\t\t(code >= 0xd800 && code <= 0xdfff)\n\t\t) {\n\t\t\t// Control characters and lone surrogates are not allowed in HTML.\n\t\t\tresult += \"&#xFFFD;\";\n\t\t} else {\n\t\t\tresult += `&#x${code.toString(16).toUpperCase()};`;\n\t\t}\n\t}\n\treturn result.length > limit ? tooLong(limit) : result;\n};\n\n/** Escapes for a JavaScript string literal, using `\\uXXXX` for everything except letters, digits, `,`, `.` and `_`. */\nconst escapeJs = (value: string, limit: number): string => {\n\tlet result = \"\";\n\tfor (let i = 0; i < value.length; i++) {\n\t\tif (result.length > limit) tooLong(limit);\n\t\tconst code = value.charCodeAt(i);\n\t\tif (isAlphanumeric(code) || code === 44 || code === 46 || code === 95) {\n\t\t\tresult += value[i];\n\t\t} else {\n\t\t\tresult += `\\\\u${code.toString(16).toUpperCase().padStart(4, \"0\")}`;\n\t\t}\n\t}\n\treturn result.length > limit ? tooLong(limit) : result;\n};\n\n/** Escapes for CSS values, using `\\HEX ` for everything except letters and digits. */\nconst escapeCss = (value: string, limit: number): string => {\n\tlet result = \"\";\n\tfor (const char of value) {\n\t\tif (result.length > limit) tooLong(limit);\n\t\tconst code = char.codePointAt(0) as number;\n\t\tresult += isAlphanumeric(code)\n\t\t\t? char\n\t\t\t: `\\\\${code.toString(16).toUpperCase()} `;\n\t}\n\treturn result.length > limit ? tooLong(limit) : result;\n};\n\nconst URL_RESERVED = /[!'()*]/;\n\n/** The last value `escapeUrl` encoded, and the result. Pages often encode one value many times, such as a query. */\nlet lastUrlValue = \"\";\nlet lastUrlEncoded = \"\";\n\n/** Percent-encodes everything outside RFC 3986's unreserved characters. */\nexport const escapeUrl = (value: string, limit = Infinity): string => {\n\tif (value === lastUrlValue) {\n\t\treturn lastUrlEncoded.length > limit ? tooLong(limit) : lastUrlEncoded;\n\t}\n\tlet result: string;\n\ttry {\n\t\tconst encoded = encodeURIComponent(value);\n\t\tresult = URL_RESERVED.test(encoded)\n\t\t\t? encoded.replace(\n\t\t\t\t\t/[!'()*]/g,\n\t\t\t\t\t(char) =>\n\t\t\t\t\t\t`%${(char.charCodeAt(0) as number).toString(16).toUpperCase()}`,\n\t\t\t\t)\n\t\t\t: encoded;\n\t} catch {\n\t\treturn issue(\n\t\t\t\"invalid-argument\",\n\t\t\t\"Cannot URL-encode a string with lone surrogates\",\n\t\t);\n\t}\n\tlastUrlValue = value;\n\tlastUrlEncoded = result;\n\treturn result.length > limit ? tooLong(limit) : result;\n};\n\nconst ESCAPERS: Record<\n\tEscapeStrategy,\n\t(value: string, limit: number) => string\n> = {\n\thtml: escapeHtml,\n\tattr: escapeAttr,\n\tjs: escapeJs,\n\tcss: escapeCss,\n\turl: escapeUrl,\n};\n\n/**\n * Escapes a string with a strategy. Throws a `KilnIssue` with code `limit-output` once the result passes `limit`, which\n * callers that know the render's `maxOutputLength` pass.\n */\nexport const escapeWith = (\n\tvalue: string,\n\tstrategy: EscapeStrategy,\n\tlimit = Infinity,\n): string => ESCAPERS[strategy](value, limit);\n","import type { EscapeStrategy } from \"../parser/ast.js\";\n\n/**\n * A string that is already safe to output with one escaping strategy.\n *\n * Output skips escaping for markup whose strategy matches, and escapes it otherwise.\n */\nexport class Markup {\n\tconstructor(\n\t\treadonly value: string,\n\t\treadonly strategy: EscapeStrategy,\n\t) {}\n\n\ttoString(): string {\n\t\treturn this.value;\n\t}\n}\n\n/**\n * Marks a string as safe to output with one escaping strategy, `\"html\"` by default.\n *\n * Return this from a function or filter that produces trusted HTML, such as rendered rich text.\n */\nexport const safe = (\n\tvalue: string,\n\tstrategy: EscapeStrategy = \"html\",\n): Markup => new Markup(String(value), strategy);\n\n/** Checks whether a value was marked safe with `safe()` or by a template. */\nexport const isSafe = (value: unknown): value is Markup =>\n\tvalue instanceof Markup;\n","/** Edit distance where swapping two neighbouring characters counts as one edit, so \"titel\" is close to \"title\". */\nconst distance = (a: string, b: string): number => {\n\tconst rows = Array.from({ length: a.length + 1 }, (_, i) =>\n\t\tArray.from({ length: b.length + 1 }, (_, j) =>\n\t\t\ti === 0 ? j : j === 0 ? i : 0,\n\t\t),\n\t);\n\tconst at = (i: number, j: number) => rows[i]?.[j] as number;\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tfor (let j = 1; j <= b.length; j++) {\n\t\t\tconst cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\t\t\tlet best = Math.min(\n\t\t\t\tat(i - 1, j) + 1,\n\t\t\t\tat(i, j - 1) + 1,\n\t\t\t\tat(i - 1, j - 1) + cost,\n\t\t\t);\n\t\t\tif (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n\t\t\t\tbest = Math.min(best, at(i - 2, j - 2) + 1);\n\t\t\t}\n\t\t\t(rows[i] as number[])[j] = best;\n\t\t}\n\t}\n\treturn at(a.length, b.length);\n};\n\n/** Returns a `Did you mean \"x\"?` hint for the closest candidate, or undefined if none is close. */\nexport const suggest = (\n\tname: string,\n\tcandidates: Iterable<string>,\n): string | undefined => {\n\tlet best: string | undefined;\n\t// One more than the largest distance allowed, so the first of several equally close candidates wins.\n\tlet bestDistance = Math.max(1, Math.floor(name.length / 3)) + 1;\n\tfor (const candidate of candidates) {\n\t\tif (candidate === name) continue;\n\t\tconst score = distance(name.toLowerCase(), candidate.toLowerCase());\n\t\tif (score < bestDistance) {\n\t\t\tbest = candidate;\n\t\t\tbestDistance = score;\n\t\t}\n\t}\n\treturn best === undefined ? undefined : `Did you mean \"${best}\"?`;\n};\n","/** Key of a scope's parent scope. Templates cannot name symbols. */\nexport const PARENT: unique symbol = Symbol(\"kiln.parent\");\n\n/**\n * Variables visible at one point of a render. A scope holds its own variables as string keys and links to its parent,\n * ending at the globals, whose parent is null. Variables never hold `undefined`, so `lookup` can tell a missing\n * variable from one set to null.\n *\n * Every scope has the same empty prototype, so scopes made the same way share a shape from render to render and\n * V8's property caches stay warm. Chaining scopes with `Object.create(parent)` would give each one a new shape,\n * because every parent would be a new prototype.\n */\nexport type Scope = { [key: string | symbol]: unknown; [PARENT]: Scope | null };\n\nconst SCOPE_PROTOTYPE: object = Object.freeze(Object.create(null));\n\n/** Creates an empty scope inside `parent`. */\nexport const childScope = (parent: Scope | null): Scope => {\n\tconst scope = Object.create(SCOPE_PROTOTYPE) as Scope;\n\tscope[PARENT] = parent;\n\treturn scope;\n};\n\n/** Marks the scope of a cached section that is rendering. See `sectionCopy`. */\nexport const SECTION: unique symbol = Symbol(\"kiln.section\");\n\n/** A scope for a cached section's content, inside `parent`. */\nexport const sectionScope = (parent: Scope): Scope => {\n\tconst scope = childScope(parent);\n\tscope[SECTION] = true;\n\treturn scope;\n};\n\n/**\n * Where `set` writes a variable that `owner` holds: the innermost cached section between `scope` and `owner`, so the\n * section gets its own copy and a saved copy of it leaves the same variables behind as a fresh render. `owner` when\n * there is none.\n */\nexport const sectionCopy = (scope: Scope, owner: Scope): Scope => {\n\tfor (let current = scope; current !== owner;) {\n\t\tif (current[SECTION] === true) return current;\n\t\tconst parent = current[PARENT];\n\t\tif (parent === null) break;\n\t\tcurrent = parent;\n\t}\n\treturn owner;\n};\n\n/** Whether `inner` is `outer` or inside it. */\nexport const isWithin = (inner: Scope, outer: Scope): boolean => {\n\tfor (\n\t\tlet current: Scope | null = inner;\n\t\tcurrent !== null;\n\t\tcurrent = current[PARENT]\n\t) {\n\t\tif (current === outer) return true;\n\t}\n\treturn false;\n};\n\n/** Finds a variable in a scope or its parents. Returns `undefined` when none of them has it. */\nexport const lookup = (scope: Scope, name: string): unknown => {\n\tlet current: Scope | null = scope;\n\tdo {\n\t\tconst value = current[name];\n\t\tif (value !== undefined) return value;\n\t\tcurrent = current[PARENT];\n\t} while (current !== null);\n\treturn undefined;\n};\n\n/** The scope that holds `name`, or null when none does. */\nexport const ownerOf = (scope: Scope, name: string): Scope | null => {\n\tlet current: Scope | null = scope;\n\twhile (current !== null && !Object.hasOwn(current, name)) {\n\t\tcurrent = current[PARENT];\n\t}\n\treturn current;\n};\n\n/** Every variable name a scope can see, for \"did you mean\" hints. */\nexport const variableNames = (scope: Scope): string[] => {\n\tconst names = new Set<string>();\n\tfor (let current: Scope | null = scope; current; current = current[PARENT]) {\n\t\tfor (const name of Object.keys(current)) names.add(name);\n\t}\n\treturn [...names];\n};\n","import type { Effects } from \"../compiler/effects.js\";\nimport type { Diagnostic, KilnSyntaxError } from \"../errors.js\";\nimport type { EscapeStrategy, TemplateNode } from \"../parser/ast.js\";\nimport type { Source, Span } from \"../source.js\";\nimport type { Sequence } from \"./ahead.js\";\nimport type { IslandMode } from \"./islands.js\";\nimport type { Addition, LateAddition, OutletMark } from \"./outlets.js\";\nimport { childScope, isWithin, type Scope, sectionScope } from \"./scope.js\";\nimport type { RenderStream } from \"./stream.js\";\n\n/**\n * The part of `AbortSignal` Kiln reads. A real `AbortSignal` fits. With the listener methods, a render stops as soon as\n * the signal aborts, even while it waits for your code. Without them, it stops at its next step.\n */\nexport type AbortSignalLike = {\n\treadonly aborted: boolean;\n\taddEventListener?(type: \"abort\", listener: () => void): void;\n\tremoveEventListener?(type: \"abort\", listener: () => void): void;\n};\n\nexport type { Scope };\n\n/**\n * An output buffer. Strings are appended to `s`.\n *\n * Every buffer is capped at `maxOutputLength`, including captures such as block `set` and macro bodies, so captured text is only counted against the render's output when it is printed.\n */\nexport type Out = {\n\ts: string;\n\t/** For output that runs ahead of a part that waits, the buffer it ends up in; null otherwise. See `ahead.ts`. */\n\tahead: Ahead | null;\n};\n\n/**\n * The buffers running ahead of the parts writing to `base`, a buffer that runs ahead of nothing, such as the render's\n * output. `size` is their length together, which counts against `maxOutputLength` with the base's own.\n */\nexport type Ahead = { readonly base: Out; size: number };\n\n/** An empty output buffer. Captures start with one too, since what they capture is printed as a value. */\nexport const emptyOut = (): Out => ({ s: \"\", ahead: null });\n\n/** A compiled statement. Returns a promise only when it had to wait for async data. */\nexport type Stmt = (run: Run, scope: Scope, out: Out) => void | Promise<void>;\n\n/** A compiled expression. Returns a promise only when a call returned one. */\nexport type Ev = (run: Run, scope: Scope) => unknown;\n\nexport type Compiled = {\n\tev: Ev;\n\t/** Whether `ev` may return a promise. */\n\tasync: boolean;\n\t/** For arrow functions: whether calling the arrow may return a promise. */\n\tarrowAsync?: boolean;\n\t/** For literals: the value, so callers can use it at compile time. */\n\tconstant?: { value: unknown };\n\t/** For property reads with literal keys, such as `a.b.c`: the parts, so a longer path can extend it. */\n\tpath?: { root: Compiled; steps: PathStep[] };\n\t/** For variables outside `default`, `??` and `is defined`: the name, so outputs can look it up in place. */\n\tvariable?: string;\n\t/** For `test ? yes : no` with literal branches and a test that never waits: the parts, so outputs can emit the branches once. */\n\tchoice?: { test: Ev; yes: unknown; no: unknown };\n};\n\n/** One literal key of a property path. */\nexport type PathStep = {\n\t/** The key, when an own property of a plain object can be read with it directly. Null for blocked names and numbers. */\n\tname: string | null;\n\t/** The full read, for everything else: arrays, maps, class instances, null and missing keys. */\n\tread: (run: Run, target: unknown) => unknown;\n\tspan: Span;\n};\n\nexport type BlockDef = {\n\tbody: Stmt;\n\tstrategy: EscapeStrategy | false;\n\t/**\n\t * The body may set variables, so it renders in a scope of its own, which keeps them in the block. Bodies that\n\t * don't render in the scope around them, which saves making one.\n\t */\n\tsets: boolean;\n};\n\n/** The scope a block's body renders in: its own when it may set variables. */\nexport const blockScope = (def: BlockDef, scope: Scope): Scope =>\n\tdef.sets ? childScope(scope) : scope;\n\n/** A block definition bound to the render of the template that defined it. */\nexport type BlockEntry = { def: BlockDef; run: Run };\n\nexport type CompiledMacro = {\n\tname: string;\n\tparams: { name: string; default: Compiled | null }[];\n\tbody: Stmt;\n\tstrategy: EscapeStrategy | false;\n\ttemplate: CompiledTemplate;\n};\n\nexport type CompiledTemplate = {\n\tname: string;\n\tsource: Source;\n\tast: TemplateNode;\n\tdiagnostics: Diagnostic[];\n\thasErrors: boolean;\n\tsyntaxError: () => KilnSyntaxError;\n\t/** For a child template, runs only its top-level `set`, `props` and similar statements. */\n\tbody: Stmt;\n\t/** The `props` tag, also run on its own when `renderBlock` reaches the top-most template. */\n\tprops: Stmt | null;\n\t/** The `extends` expression, when the template has one. */\n\tparent: Compiled | null;\n\tparentSpan: Span;\n\tblocks: Map<string, BlockDef>;\n\t/** `blocks` as a list, made on first render, since a template's blocks never change once compiled. */\n\tblockList: readonly (readonly [string, BlockDef])[] | undefined;\n\tmacros: Map<string, CompiledMacro>;\n\t/** Resolved names of imported templates, by import slot. */\n\timports: { name: string; span: Span }[];\n\t/** Templates this template's includes, components and layouts name, so each name is resolved once. */\n\tresolved: Map<string, TemplateRef>;\n\t/** For names made of a known prefix and a key, such as `\"sections/\" ~ type`: templates by prefix, then key. */\n\tkeyed: Map<string, Map<string, TemplateRef>> | undefined;\n\t/** Every slot name the template outputs, so `slots` always has a key for each. */\n\tslotNames: string[];\n\t/**\n\t * It extends nothing, defines no blocks and imports nothing, as most partials, so it renders without\n\t * `renderTemplate`.\n\t */\n\tplain: boolean;\n\t/** The top-level statements, which a page's top-level statements may gate while they wait. See `Gate`. */\n\ttop: Sequence | null;\n\t/** For a page, what its top-level statements read and set, or null when its layout must wait for them. */\n\tearly: (() => Effects | null) | null;\n};\n\n/**\n * A template name a template uses, resolved, and the template it found, while the environment's `generation` is the\n * same, so later renders skip loading it.\n */\nexport type TemplateRef = {\n\tresolved: string;\n\ttemplate: CompiledTemplate | null;\n\tgeneration: number;\n};\n\n/** Content a caller passed into a component slot, with the scope it renders in. */\nexport type SlotFill = {\n\tbody: Stmt;\n\trun: Run;\n\tscope: Scope;\n\t/** The body may set variables, so it renders in a scope of its own, as a block's does. See `BlockDef`. */\n\tsets: boolean;\n};\n\n/**\n * The scope a slot's fill renders in, from the slot's render `run`: its own when it may set variables. A fill from\n * outside the cached section rendering it gets a section of its own, so it can't change its caller's variables only\n * when the section isn't saved.\n */\nexport const fillScope = (fill: SlotFill, run: Run): Scope => {\n\tconst section = run.capture?.section;\n\tif (section && !isWithin(fill.scope, section.scope)) {\n\t\treturn sectionScope(fill.scope);\n\t}\n\treturn fill.sets ? childScope(fill.scope) : fill.scope;\n};\n\n/** A built-in callable. Receives the current render first. */\nexport type Builtin = (run: Run, ...args: unknown[]) => unknown;\n\nexport type CallableEntry =\n\t| {\n\t\t\tkind: \"builtin\";\n\t\t\tcall: Builtin;\n\t\t\t/** Parameter names after the filtered or tested value, so named arguments such as `round(precision: 2)` find their place. */\n\t\t\tparams?: readonly string[];\n\t\t\t/** Collects named arguments that match no parameter into a trailing options hash, such as `Intl` options. */\n\t\t\toptions?: boolean;\n\t }\n\t| {\n\t\t\tkind: \"host\";\n\t\t\tname: string;\n\t\t\tcall: (...args: unknown[]) => unknown;\n\t\t\t/** Made with `withRender`, so it receives `RenderInfo` first. */\n\t\t\trender: boolean;\n\t };\n\n/** Checks a value against a host type, such as `Post`. Hosts register these with the `types` option. */\nexport type TypeCheck = (value: unknown) => boolean;\n\n/**\n * Where the `cache` tag saves output, given as the `cache` option. See `memoryCache`. Each method takes one object, so\n * more details can be added without breaking stores.\n */\nexport type KilnCache = {\n\t/** Returns the value saved under `key`, or null when there is none. */\n\tget(entry: {\n\t\tkey: string;\n\t}): string | null | undefined | Promise<string | null | undefined>;\n\t/**\n\t * Saves `value` under `key`. The value is Kiln's own string, holding the HTML and what the section added to outlets,\n\t * to save as it is. `seconds` is the tag's `for` value, or null to let the store decide. `tags` are the section's\n\t * tags from `RenderInfo.tagCache`, sorted, for a store that clears copies by tag.\n\t */\n\tset(entry: {\n\t\tkey: string;\n\t\tvalue: string;\n\t\tseconds: number | null;\n\t\ttags: string[];\n\t}): void | Promise<void>;\n};\n\n/** What the runtime needs from the environment. */\nexport interface EnvironmentCore {\n\treadonly strict: boolean;\n\treadonly debug: boolean;\n\treadonly autoescape: EscapeStrategy | false;\n\treadonly functions: ReadonlyMap<string, CallableEntry>;\n\treadonly filters: ReadonlyMap<string, CallableEntry>;\n\treadonly tests: ReadonlyMap<string, CallableEntry>;\n\treadonly types: ReadonlyMap<string, TypeCheck>;\n\t/** The store for the `cache` tag. Without one, the tag renders its content every time. */\n\treadonly cache: KilnCache | null;\n\t/** App and build identity included in fragment cache keys. */\n\treadonly cacheNamespace: string;\n\t/** Goes up whenever `invalidate` drops templates, so templates found earlier are looked up again. */\n\treadonly generation: number;\n\tload(\n\t\tname: string,\n\t): CompiledTemplate | null | Promise<CompiledTemplate | null>;\n}\n\nexport type RenderInfo<State = unknown> = {\n\tstate: State;\n\tlocale: string;\n\ttimeZone: string;\n\t/** Resolved name of the template making the call. */\n\ttemplate: string;\n\tsignal: AbortSignalLike | undefined;\n\t/**\n\t * Tags the cached section the call runs in, and every cached section around it, so a store can clear its copies\n\t * when that data changes. Does nothing outside a cached section.\n\t */\n\ttagCache(...tags: string[]): void;\n};\n\n/** Counters and settings for one call to `render`. */\nexport class RenderState {\n\tsteps = 0;\n\t/** Parts of the render running ahead of a part that waits, and not joined yet. See `ahead.ts`. */\n\tahead = 0;\n\t/** `add to` tags that ran ahead, which a `flush` must check came after it. See `checkLate`. */\n\tlate: LateAddition[] | null = null;\n\t/** Imports loaded so far this render, by importing template. Made when a template first imports. */\n\timportsCache: Map<CompiledTemplate, CompiledTemplate[]> | null = null;\n\t/** The render's output, where outlets mark their places. Captures such as `set` write elsewhere. */\n\troot: Out | null = null;\n\t/** Outlets reached so far, by name, in the order reached. See `outlets.ts`. */\n\toutlets: Map<string, OutletMark> | null = null;\n\t/** How much of `root` has been taken as final output, and how many outlets' content with it. See `takeOutput`. */\n\ttaken = 0;\n\ttakenOutlets = 0;\n\t/** Sends output while the render waits, for `renderStream`. */\n\tstream: RenderStream | null = null;\n\t/** Every `add to` that ran outside any capture, and the captures started there, in order. See `Capture`. */\n\tadditions: (Addition | Capture)[] | null = null;\n\t/** The first content of each `once` tag that added. */\n\tonce: Map<string, string> | null = null;\n\t/** Whether `island` tags are deferred or streamed, or null to render them in place. */\n\tislands: IslandMode | null = null;\n\t/** The HTML of each streamed island, filling `<kiln-island stream=\"n\">` at index n - 1, for `renderStream` to send. */\n\tstreamed: Promise<string>[] | null = null;\n\t/** Whether the `<kiln-island>` script is in the render's output yet. */\n\tislandScript = false;\n\n\tconstructor(\n\t\treadonly env: EnvironmentCore,\n\t\treadonly globals: Scope,\n\t\treadonly maxSteps: number,\n\t\treadonly maxSize: number,\n\t\treadonly maxDepth: number,\n\t\treadonly locale: string,\n\t\treadonly timeZone: string,\n\t\treadonly userState: unknown,\n\t\treadonly signal: AbortSignalLike | undefined,\n\t) {}\n}\n\n/** A part of a render that others run ahead of, and the part before it, if that one is run ahead of too. */\nexport type Behind = {\n\treadonly part: Promise<void>;\n\treadonly previous: Behind | null;\n};\n\n/**\n * A cached section rendering: its scope, whose content can't change variables outside it, the islands it deferred, and\n * its tags from `RenderInfo.tagCache`.\n */\nexport type Section = {\n\treadonly scope: Scope;\n\treadonly deferred: string[];\n\treadonly tags: Set<string>;\n};\n\n/**\n * A part of a render that keeps the `add to` content it adds in a log of its own: a cached section, or a macro,\n * `block()` or `parent()` call, which can render alongside others while promises are pending. Each capture takes its\n * place in the log around it when it starts, so outlets get content in the template's order however the parts finish,\n * and a cached section saves only its own. A render's `Run` carries the capture it is in.\n */\nexport class Capture {\n\t/** The additions made in it, and the captures started in it, in order. Made when the first is. */\n\tadditions: (Addition | Capture)[] | null = null;\n\n\tconstructor(\n\t\t/** The log of the capture or render it started in. */\n\t\treadonly outer: (Addition | Capture)[],\n\t\t/** The innermost cached section it is in, or null. */\n\t\treadonly section: Section | null,\n\t\t/**\n\t\t * For a capture that runs ahead of parts that wait, or is inside one: the last of those parts, whose promises\n\t\t * settle once every part of the render before it is done. Null otherwise. See `ahead.ts`.\n\t\t */\n\t\treadonly behind: Behind | null,\n\t) {}\n}\n\n/** The log that additions made in `run` go to: its capture's, or the render's. */\nexport const additionLog = (run: Run): (Addition | Capture)[] => {\n\tconst capture = run.capture;\n\treturn capture ? (capture.additions ??= []) : (run.state.additions ??= []);\n};\n\n/** Starts a capture inside `run`'s. With `section`, it is a cached section. */\nexport const startCapture = (run: Run, section?: Section): Capture => {\n\tconst outer = additionLog(run);\n\tconst capture = new Capture(\n\t\touter,\n\t\tsection ?? run.capture?.section ?? null,\n\t\trun.capture?.behind ?? null,\n\t);\n\touter.push(capture);\n\treturn capture;\n};\n\n/**\n * Ends a capture that started inside `run`'s. One that added nothing leaves the log around it when it is last there,\n * as it is unless captures overlap, and a cached section's islands and tags join the section around it.\n */\nexport const endCapture = (run: Run, capture: Capture): void => {\n\tconst outer = capture.outer;\n\tif (capture.additions === null && outer.at(-1) === capture) outer.pop();\n\tconst section = run.capture?.section;\n\tif (section && capture.section && capture.section !== section) {\n\t\tfor (const id of capture.section.deferred) section.deferred.push(id);\n\t\tfor (const tag of capture.section.tags) section.tags.add(tag);\n\t}\n};\n\nconst NO_BLOCKS = new Map<string, BlockEntry[]>();\n/** The imports of a template that imports nothing, shared. */\nexport const NO_IMPORTS: readonly CompiledTemplate[] = [];\n\n/** One template being rendered: the template, its blocks, slots and imports. */\nexport class Run {\n\tblocks: Map<string, BlockEntry[]> = NO_BLOCKS;\n\timports: readonly CompiledTemplate[] = NO_IMPORTS;\n\t#info: RenderInfo | undefined;\n\n\tconstructor(\n\t\treadonly state: RenderState,\n\t\treadonly template: CompiledTemplate,\n\t\treadonly depth: number,\n\t\treadonly slots: Map<string, SlotFill> | null,\n\t\t/** Variable names the caller passed, for `props` checks. */\n\t\treadonly passed: readonly string[] | null,\n\t\t/** The capture it renders in, or null. */\n\t\treadonly capture: Capture | null = null,\n\t\t/** Nesting of the `block()` and `parent()` calls this renders inside, checked against `maxDepth`. */\n\t\treadonly blockDepth = 0,\n\t) {}\n\n\t/**\n\t * This render inside `capture`, for content that renders where a capture other than its own is open, such as a\n\t * block placed in a cached section or a fill in a macro. `blockDepth` is the nesting of `block()` calls where the\n\t * content is placed, since content from elsewhere carries on the chain of calls that placed it.\n\t */\n\twithin(capture: Capture | null, blockDepth = this.blockDepth): Run {\n\t\tif (capture === this.capture && blockDepth === this.blockDepth) return this;\n\t\tconst run = new Run(\n\t\t\tthis.state,\n\t\t\tthis.template,\n\t\t\tthis.depth,\n\t\t\tthis.slots,\n\t\t\tthis.passed,\n\t\t\tcapture,\n\t\t\tblockDepth,\n\t\t);\n\t\trun.blocks = this.blocks;\n\t\trun.imports = this.imports;\n\t\treturn run;\n\t}\n\n\tget info(): RenderInfo {\n\t\tthis.#info ??= {\n\t\t\tstate: this.state.userState,\n\t\t\tlocale: this.state.locale,\n\t\t\ttimeZone: this.state.timeZone,\n\t\t\ttemplate: this.template.name,\n\t\t\tsignal: this.state.signal,\n\t\t\ttagCache: (...tags) => {\n\t\t\t\tconst section = this.capture?.section;\n\t\t\t\tfor (const tag of tags) {\n\t\t\t\t\tif (typeof tag !== \"string\") {\n\t\t\t\t\t\tthrow new TypeError(\"Cache tags must be strings\");\n\t\t\t\t\t}\n\t\t\t\t\tsection?.tags.add(tag);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\treturn this.#info;\n\t}\n}\n","import type { Span } from \"../source.js\";\nimport { fail } from \"./render.js\";\nimport {\n\tadditionLog,\n\tCapture,\n\ttype Out,\n\ttype RenderState,\n\ttype Run,\n} from \"./types.js\";\n\n/*\n * Outlets and `add to`.\n *\n * An outlet marks a place in the render's output, and `add to` records content for an outlet by name. Nothing is\n * written at an outlet until it closes, at `flush` or when the render ends, so content added after the outlet still\n * reaches it.\n *\n * Additions are a log rather than text written into place, so a cached section can save the ones it made and replay\n * them, and so a streamed render can send output as soon as it is final: everything before the first open outlet.\n */\n\n/**\n * Where an outlet stands in the render's output. An outlet reached in output running ahead stands in that buffer until\n * it joins the render's; see `ahead.ts`.\n */\nexport type OutletMark = {\n\tout: Out;\n\toffset: number;\n\t/** The outlet's content once it is closed, or null while content can still be added. */\n\tcontent: string | null;\n};\n\n/** One `add to` that ran. `once` names the tag when it has `once`, or is null. */\nexport type Addition = {\n\treadonly outlet: string;\n\treadonly html: string;\n\treadonly once: string | null;\n};\n\n/** The additions in a log, in order, with each capture's in its place. See `Capture`. */\nexport const additionsIn = (\n\tlog: readonly (Addition | Capture)[],\n\tinto: Addition[] = [],\n): Addition[] => {\n\tfor (const entry of log) {\n\t\tif (entry instanceof Capture) {\n\t\t\tif (entry.additions !== null) additionsIn(entry.additions, into);\n\t\t} else into.push(entry);\n\t}\n\treturn into;\n};\n\n/** An `add to` that ran ahead of a part that waits, kept until a `flush` checks it. See `checkLate`. */\nexport type LateAddition = {\n\treadonly addition: Addition;\n\treadonly run: Run;\n\treadonly span: Span;\n};\n\n/**\n * Records an addition in the log of the capture `run` is in, or the render's. A `once` tag that already added keeps\n * its first content. New content for a closed outlet is an error, since the outlet's part of the page may have been\n * sent.\n *\n * Only parts that run ahead of nothing, or `front` ones whose parts before are all done, note a `once` tag's first\n * content: until then, a part before may still add the same tag. `add to` waits until then for a tag not added yet.\n */\nexport const recordAddition = (\n\trun: Run,\n\tspan: Span,\n\taddition: Addition,\n\tfront = false,\n): void => {\n\tconst state = run.state;\n\tconst ahead = !front && run.capture !== null && run.capture.behind !== null;\n\tif (addition.once !== null) {\n\t\tconst first = state.once?.get(addition.once);\n\t\t// A repeat adds nothing new, so it is fine after the outlet closed.\n\t\tif (first !== undefined) {\n\t\t\tconst repeat =\n\t\t\t\tfirst === addition.html ? addition : { ...addition, html: first };\n\t\t\tadditionLog(run).push(repeat);\n\t\t\treturn;\n\t\t}\n\t}\n\tconst mark = state.outlets?.get(addition.outlet);\n\tif (mark !== undefined && mark.content !== null) {\n\t\tthrow closedError(run, span, addition.outlet);\n\t}\n\tif (ahead) (state.late ??= []).push({ addition, run, span });\n\telse if (addition.once !== null) {\n\t\t(state.once ??= new Map()).set(addition.once, addition.html);\n\t}\n\tadditionLog(run).push(addition);\n};\n\n/**\n * After a `flush` closes outlets, fails for content a part running ahead added to one of them before then. Every part\n * before the flush is done and in the log by now, so content outside the log comes after the flush in the template,\n * where adding to a closed outlet is an error.\n */\nexport const checkLate = (state: RenderState): void => {\n\tconst late = state.late;\n\tif (late === null) return;\n\tconst logged = new Set(additionsIn(state.additions ?? []));\n\tfor (const { addition, run, span } of late) {\n\t\tif (logged.has(addition)) continue;\n\t\tconst mark = state.outlets?.get(addition.outlet);\n\t\tif (mark === undefined || mark.content === null) continue;\n\t\t// A repeat of a `once` tag that added before the flush adds nothing new.\n\t\tif (addition.once !== null && state.once?.has(addition.once)) continue;\n\t\tthrow closedError(run, span, addition.outlet);\n\t}\n\tstate.late = late.filter(({ addition }) => !logged.has(addition));\n};\n\nconst closedError = (run: Run, span: Span, outlet: string) =>\n\tfail(\n\t\trun,\n\t\tspan,\n\t\t\"outlet-closed\",\n\t\t`Outlet \"${outlet}\" was closed by \"flush\", so content can't be added to it any more`,\n\t);\n\n/** Closes every outlet reached so far, fixing its content. */\nexport const closeOutlets = (state: RenderState): void => {\n\tif (state.outlets === null) return;\n\tfor (const [name, mark] of state.outlets) {\n\t\tif (mark.content === null) mark.content = contentFor(state, name);\n\t}\n};\n\n/** An outlet's content: what was added to it, in order, without repeats of `once` tags. */\nconst contentFor = (state: RenderState, name: string): string => {\n\tconst seen = new Set<string>();\n\tlet content = \"\";\n\tfor (const addition of additionsIn(state.additions ?? [])) {\n\t\tif (addition.outlet !== name) continue;\n\t\tif (addition.once !== null) {\n\t\t\tif (seen.has(addition.once)) continue;\n\t\t\tseen.add(addition.once);\n\t\t}\n\t\tcontent += addition.html;\n\t}\n\treturn content;\n};\n\n/** Moves the outlets reached in `from`, output that ran ahead, into `to`, which it joined at `offset`. */\nexport const moveOutlets = (\n\tstate: RenderState,\n\tfrom: Out,\n\tto: Out,\n\toffset: number,\n): void => {\n\tif (state.outlets === null) return;\n\tfor (const mark of state.outlets.values()) {\n\t\tif (mark.out !== from) continue;\n\t\tmark.out = to;\n\t\tmark.offset += offset;\n\t}\n};\n\n/**\n * Takes the part of the render's output that is final and not yet taken: up to the first open outlet, with each\n * closed outlet's content in place. Close the outlets first to take the rest of the output.\n */\nexport const takeOutput = (state: RenderState, output: string): string => {\n\tif (state.outlets === null) {\n\t\tconst text = state.taken === 0 ? output : output.slice(state.taken);\n\t\tstate.taken = output.length;\n\t\treturn text;\n\t}\n\tlet text = \"\";\n\tlet index = 0;\n\t// Outlets are marked in the order they are reached, which is their order in the output. One in output running\n\t// ahead comes after all of the render's output so far.\n\tfor (const mark of state.outlets.values()) {\n\t\tif (index++ < state.takenOutlets) continue;\n\t\tif (mark.out !== state.root) break;\n\t\ttext += output.slice(state.taken, mark.offset);\n\t\tstate.taken = mark.offset;\n\t\tif (mark.content === null) return text;\n\t\ttext += mark.content;\n\t\tstate.takenOutlets++;\n\t}\n\ttext += output.slice(state.taken);\n\tstate.taken = output.length;\n\treturn text;\n};\n","import type { Effects } from \"../compiler/effects.js\";\nimport type { Span } from \"../source.js\";\nimport { moveOutlets } from \"./outlets.js\";\nimport { write } from \"./render.js\";\nimport { ownerOf } from \"./scope.js\";\nimport {\n\tadditionLog,\n\ttype Behind,\n\tCapture,\n\ttype Out,\n\ttype RenderState,\n\ttype Run,\n\ttype Scope,\n\ttype Stmt,\n} from \"./types.js\";\n\n/*\n * Running ahead.\n *\n * When part of a render waits for a promise, the parts after it that don't depend on it start straight away, so their\n * own waits overlap with it. Which parts may is found when compiling; see `compiler/effects.ts`.\n *\n * The part that waits keeps its output buffer. The parts running ahead write to a buffer of their own, and add to\n * outlets in a capture of their own, which takes its place in the outlets' log once the part before it is done. Their\n * output joins the part's once both are done, so the page and every outlet get content in the template's order,\n * however the promises settle.\n *\n * What depends on everything before it in the page waits until all of that is done: an outlet's place, a `flush`,\n * an island and whether it brings the island script. See `atFront`.\n *\n * A page's layout starts while the page's top-level statements wait, and its top-level statements that touch their\n * variables wait for them. See `Gate`.\n */\n\n/** The most parts of one render that run ahead at once. Beyond it, parts wait their turn as they would otherwise. */\nexport const MAX_AHEAD = 64;\n\nconst NOTHING = (): void => {};\n\n/** Whether parts may start early ahead of a part that waits: the render runs fewer parts ahead than it may. */\nexport const mayRunAhead = (state: RenderState): boolean =>\n\tstate.ahead < MAX_AHEAD;\n\n/**\n * Starts `rest` while `pending`, the promise of the part before it, waits, and returns a promise for both. Rejects with\n * the part's error when it fails, or else with the rest's, after both settle, so a failed render has nothing still\n * running. Only call it when `mayRunAhead` allows.\n */\nexport const runAhead = (\n\trun: Run,\n\tout: Out,\n\tpending: Promise<void>,\n\trest: (run: Run, out: Out) => void | Promise<void>,\n\tspan: Span,\n): Promise<void> => {\n\tconst state = run.state;\n\tstate.ahead++;\n\tconst log = additionLog(run);\n\tconst outer = run.capture;\n\tconst capture = new Capture(log, outer?.section ?? null, {\n\t\tpart: pending,\n\t\tprevious: outer?.behind ?? null,\n\t});\n\tconst ahead: Out = { s: \"\", ahead: out.ahead ?? { base: out, size: 0 } };\n\treturn new Promise<void>((resolve, reject) => {\n\t\tlet left = 2;\n\t\tlet failure: { error: unknown } | null = null;\n\t\tconst settle = () => {\n\t\t\tif (--left !== 0) return;\n\t\t\tstate.ahead--;\n\t\t\tif (failure !== null) return reject(failure.error);\n\t\t\ttry {\n\t\t\t\t(ahead.ahead as NonNullable<Out[\"ahead\"]>).size -= ahead.s.length;\n\t\t\t\tconst offset = out.s.length;\n\t\t\t\twrite(run, out, ahead.s, span);\n\t\t\t\tmoveOutlets(state, ahead, out, offset);\n\t\t\t\tresolve();\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t};\n\t\t// The rest's capture goes in the log once the part is done, after everything the part added. Registered before\n\t\t// the rest starts, so it is in place before anything in the rest that waits for the part.\n\t\tpending.then(\n\t\t\t() => {\n\t\t\t\tlog.push(capture);\n\t\t\t\tsettle();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tlog.push(capture);\n\t\t\t\t// The part comes first in the template, so its error wins.\n\t\t\t\tfailure = { error };\n\t\t\t\tsettle();\n\t\t\t},\n\t\t);\n\t\tlet result: void | Promise<void>;\n\t\ttry {\n\t\t\tresult = rest(run.within(capture), ahead);\n\t\t} catch (error) {\n\t\t\tresult = Promise.reject(error);\n\t\t}\n\t\tif (result === undefined) settle();\n\t\telse {\n\t\t\tresult.then(settle, (error: unknown) => {\n\t\t\t\tfailure ??= { error };\n\t\t\t\tsettle();\n\t\t\t});\n\t\t}\n\t});\n};\n\n/**\n * Which later statements of a list may start while each statement waits. For statement `i`, statements `i + 1` to\n * `after[i]` depend on it, directly or through each other, so they run once it is done. Statements `after[i] + 1` to\n * `reach[i]` depend on none of those, so they start at once. When nothing may start early, both are `i`.\n */\nexport type Plan = {\n\treadonly after: readonly number[];\n\treadonly reach: readonly number[];\n};\n\n/**\n * A list of statements, each of which may let others start early while it waits. `plan` gives the plan for a render,\n * with each statement's span, for errors where parts join. It is only worked out the first time a statement waits, so\n * renders that never wait spend no time on it. With `gated`, the plan counts every statement as one that may wait,\n * since any may wait for a `Gate`. `clear` is whether a statement can run in either order with statements that have\n * `effects`.\n */\nexport type Sequence = {\n\treadonly statements: readonly Stmt[];\n\treadonly plan: (\n\t\trun: Run,\n\t\tgated: boolean,\n\t) => Plan & { readonly spans: readonly Span[] };\n\treadonly clear: (run: Run, index: number, effects: Effects) => boolean;\n};\n\n/**\n * A page's top-level statements, still waiting while its layout starts: their promise, and what they read and set. A\n * top-level statement of the layout that touches their variables waits for `part`. `previous` is the gate of the page\n * below, when the page is a layout itself. `done` once `part` fulfils.\n */\nexport type Gate = {\n\treadonly part: Promise<void>;\n\treadonly effects: Effects;\n\treadonly previous: Gate | null;\n\tdone: boolean;\n};\n\n/** A gate for `part`, which marks itself done once `part` fulfils. */\nexport const gateFor = (\n\tpart: Promise<void>,\n\teffects: Effects,\n\tprevious: Gate | null,\n): Gate => {\n\tconst gate: Gate = { part, effects, previous, done: false };\n\tpart.then(() => {\n\t\tgate.done = true;\n\t}, NOTHING);\n\treturn gate;\n};\n\n/** Runs statement `index` of a sequence, once the gates whose statements it touches are done. */\nconst runGated = (\n\tsequence: Sequence,\n\tindex: number,\n\tgate: Gate,\n\trun: Run,\n\tscope: Scope,\n\tout: Out,\n): void | Promise<void> => {\n\tconst statement = sequence.statements[index] as Stmt;\n\tlet waits: Promise<unknown> | null = null;\n\tfor (let at: Gate | null = gate; at !== null; at = at.previous) {\n\t\tif (at.done || sequence.clear(run, index, at.effects)) continue;\n\t\twaits = waits === null ? at.part : Promise.all([waits, at.part]);\n\t}\n\tif (waits === null) return statement(run, scope, out);\n\treturn waits.then(() => statement(run, scope, out));\n};\n\n/**\n * Runs a sequence's statements `index` to `last` in order, waiting only when one returns a promise. While one waits,\n * the statements its plan lets start early run ahead of it, see `runAhead`, while the ones that depend on it run once\n * it is done. The rest run once those are done. With a `gate`, each statement first waits for the gates it touches.\n */\nexport const runSequence = (\n\tsequence: Sequence,\n\tindex: number,\n\tlast: number,\n\trun: Run,\n\tscope: Scope,\n\tout: Out,\n\tgate: Gate | null,\n): void | Promise<void> => {\n\tconst statements = sequence.statements;\n\tfor (let i = index; i <= last; i++) {\n\t\tconst result =\n\t\t\tgate === null\n\t\t\t\t? (statements[i] as Stmt)(run, scope, out)\n\t\t\t\t: runGated(sequence, i, gate, run, scope, out);\n\t\tif (result === undefined) continue;\n\t\tconst plan = sequence.plan(run, gate !== null);\n\t\tconst after = Math.min(plan.after[i] as number, last);\n\t\tconst end = Math.min(plan.reach[i] as number, last);\n\t\tif (end > after && mayRunAhead(run.state)) {\n\t\t\tconst pending =\n\t\t\t\tafter > i\n\t\t\t\t\t? result.then(() =>\n\t\t\t\t\t\t\trunSequence(sequence, i + 1, after, run, scope, out, gate),\n\t\t\t\t\t\t)\n\t\t\t\t\t: result;\n\t\t\tconst joined = runAhead(\n\t\t\t\trun,\n\t\t\t\tout,\n\t\t\t\tpending,\n\t\t\t\t(ahead, aheadOut) =>\n\t\t\t\t\trunSequence(sequence, after + 1, end, ahead, scope, aheadOut, gate),\n\t\t\t\tplan.spans[i] as Span,\n\t\t\t);\n\t\t\treturn end === last\n\t\t\t\t? joined\n\t\t\t\t: joined.then(() =>\n\t\t\t\t\t\trunSequence(sequence, end + 1, last, run, scope, out, gate),\n\t\t\t\t\t);\n\t\t}\n\t\treturn result.then(() =>\n\t\t\trunSequence(sequence, i + 1, last, run, scope, out, gate),\n\t\t);\n\t}\n};\n\n/** Runs one pass of a loop, given its index, in the render and output given. */\nexport type Pass = (run: Run, out: Out, index: number) => void | Promise<void>;\n\n/**\n * Runs passes `from` to `to` of a loop in order, waiting only when one returns a promise. Then the passes after it\n * continue as `passesFrom` runs them. `ahead` is whether the loop's passes may run ahead of each other.\n */\nexport const runPasses = (\n\trun: Run,\n\tout: Out,\n\tfrom: number,\n\tto: number,\n\tpass: Pass,\n\tspan: Span,\n\tahead: boolean,\n): void | Promise<void> => {\n\tfor (let index = from; index < to; index++) {\n\t\tconst result = pass(run, out, index);\n\t\tif (result === undefined) continue;\n\t\treturn index + 1 < to\n\t\t\t? passesFrom(run, out, result, index + 1, to, pass, span, ahead)\n\t\t\t: result;\n\t}\n};\n\n/**\n * Runs passes `from` to `to` of a loop, which come after `pending`, a pass that waits. When `ahead`, they start at\n * once: each pass that waits lets the passes after it start in a buffer and capture of their own, and every buffer\n * joins `out` in order once all the passes are done. Otherwise, or when `mayRunAhead` refuses, they run once the pass\n * is done. Rejects with the first error in the loop's order, once every pass started is done.\n */\nexport const passesFrom = (\n\trun: Run,\n\tout: Out,\n\tpending: Promise<void>,\n\tfrom: number,\n\tto: number,\n\tpass: Pass,\n\tspan: Span,\n\tahead: boolean,\n): Promise<void> => {\n\tconst state = run.state;\n\tif (!ahead || !mayRunAhead(state)) {\n\t\treturn pending.then(() => runPasses(run, out, from, to, pass, span, ahead));\n\t}\n\tconst log = additionLog(run);\n\tconst outer = run.capture;\n\tconst section = outer?.section ?? null;\n\tconst group = out.ahead ?? { base: out, size: 0 };\n\t// Segment k holds the passes after the one waiting at the end of segment k - 1. Segment 0 is `out`.\n\tconst segments: Out[] = [];\n\tconst captures: Capture[] = [];\n\t// The last part waiting at the end of a segment, which every later segment runs ahead of.\n\tlet behind: Behind | null = outer?.behind ?? null;\n\tconst settled: boolean[] = [];\n\tlet linked = 0;\n\tlet left = 0;\n\tlet failure: { error: unknown; at: number } | null = null;\n\tlet resolve = NOTHING;\n\tlet reject: (error: unknown) => void = NOTHING;\n\tconst joined = new Promise<void>((yes, no) => {\n\t\tresolve = yes;\n\t\treject = no;\n\t});\n\tconst fail = (at: number, error: unknown) => {\n\t\tif (failure === null || at < failure.at) failure = { error, at };\n\t};\n\tconst finish = () => {\n\t\tstate.ahead -= segments.length;\n\t\tif (failure !== null) return reject(failure.error);\n\t\ttry {\n\t\t\tfor (const segment of segments) {\n\t\t\t\tgroup.size -= segment.s.length;\n\t\t\t\tconst offset = out.s.length;\n\t\t\t\twrite(run, out, segment.s, span);\n\t\t\t\tmoveOutlets(state, segment, out, offset);\n\t\t\t}\n\t\t\tresolve();\n\t\t} catch (error) {\n\t\t\treject(error);\n\t\t}\n\t};\n\tconst watch = (part: Promise<void>, at: number) => {\n\t\tleft++;\n\t\tbehind = { part, previous: behind };\n\t\tconst done = () => {\n\t\t\tsettled[at] = true;\n\t\t\t// Each segment's capture goes in the log once the part before it is done, after every capture before it.\n\t\t\twhile (linked < captures.length && settled[linked] === true) {\n\t\t\t\tlog.push(captures[linked++] as Capture);\n\t\t\t}\n\t\t\tif (--left === 0) finish();\n\t\t};\n\t\tpart.then(done, (error: unknown) => {\n\t\t\tfail(at, error);\n\t\t\tdone();\n\t\t});\n\t};\n\twatch(pending, 0);\n\tlet index = from;\n\twhile (index < to) {\n\t\tconst at = segments.length + 1;\n\t\tstate.ahead++;\n\t\tconst capture = new Capture(log, section, behind);\n\t\tconst segment: Out = { s: \"\", ahead: group };\n\t\tconst segmentRun = run.within(capture);\n\t\tsegments.push(segment);\n\t\tcaptures.push(capture);\n\t\tlet waiting: void | Promise<void> = undefined;\n\t\ttry {\n\t\t\tfor (; index < to; index++) {\n\t\t\t\twaiting = pass(segmentRun, segment, index);\n\t\t\t\tif (waiting !== undefined) {\n\t\t\t\t\tindex++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(at, error);\n\t\t\tbreak;\n\t\t}\n\t\tif (waiting === undefined) break;\n\t\tif (index < to && state.ahead >= MAX_AHEAD) {\n\t\t\t// No more parts may run ahead, so the rest of the passes run in this segment once its pass is done.\n\t\t\tconst next = index;\n\t\t\twaiting = waiting.then(() =>\n\t\t\t\trunPasses(segmentRun, segment, next, to, pass, span, true),\n\t\t\t);\n\t\t\tindex = to;\n\t\t}\n\t\twatch(waiting, at);\n\t}\n\treturn joined;\n};\n\n/**\n * Whether content placed from elsewhere in `run` may set variables: any version of any block in the render, since\n * blocks place each other through `parent()` and `block()`, or a fill the caller passed. Such content may set any\n * variable that exists, so parts that place it can't start early, nor can parts that read or set anything around it.\n * See `Effects`.\n */\nexport const contentSets = (run: Run): boolean => {\n\tfor (const entries of run.blocks.values()) {\n\t\tfor (const entry of entries) if (entry.def.sets) return true;\n\t}\n\tif (run.slots !== null) {\n\t\tfor (const fill of run.slots.values()) if (fill.sets) return true;\n\t}\n\treturn false;\n};\n\n/**\n * Whether a loop's passes may run ahead of each other: when none of the variables its body sets, `sets`, is in `scope`\n * around the loop, and content from elsewhere the body places, when `elsewhere`, sets none. Then each pass sets its\n * own, in a scope of its own, and no pass depends on another.\n */\nexport const passesAhead = (\n\trun: Run,\n\tscope: Scope,\n\tsets: readonly string[],\n\telsewhere: boolean,\n): boolean => {\n\tif (elsewhere && contentSets(run)) return false;\n\tfor (const name of sets) if (ownerOf(scope, name) !== null) return false;\n\treturn true;\n};\n\n/**\n * Runs `work` once every part of the render before `run`'s is done, for what depends on all of it, such as where an\n * outlet stands. Runs it at once in parts that don't run ahead. When a part before failed, the render fails with its\n * error, so `work` never runs and makes no changes, such as closing outlets or deferring an island.\n */\nexport const atFront = <T>(\n\trun: Run,\n\twork: () => T | Promise<T>,\n): T | Promise<T> => {\n\tlet behind = run.capture?.behind ?? null;\n\tif (behind === null) return work();\n\tconst parts: Promise<void>[] = [];\n\tfor (; behind !== null; behind = behind.previous) parts.push(behind.part);\n\treturn Promise.allSettled(parts).then((results) => {\n\t\tfor (const result of results) {\n\t\t\tif (result.status === \"rejected\") throw result.reason;\n\t\t}\n\t\treturn work();\n\t});\n};\n\n/** Whether `out` is the render's output, or output running ahead that joins it. */\nexport const isRoot = (state: RenderState, out: Out): boolean =>\n\tout === state.root || (out.ahead !== null && out.ahead.base === state.root);\n","/** Names that can never be read, whatever the object. `hashKeys` compares them directly, so change both together. */\nexport const BLOCKED_NAMES = new Set([\"constructor\", \"prototype\", \"__proto__\"]);\n\n/**\n * Lists the members of a class that templates may read or call.\n *\n * ```ts\n * class Post {\n * \tstatic [expose] = [\"title\", \"excerpt\"] as const;\n * }\n * ```\n */\nexport const expose: unique symbol = Symbol.for(\"kiln.expose\");\n\n/**\n * An instance method that answers names not listed in `expose`. Return `undefined` for a missing name.\n *\n * ```ts\n * class Fields {\n * \t[lookup](name: string) { return this.#values.get(name); }\n * }\n * ```\n */\nexport const lookup: unique symbol = Symbol.for(\"kiln.lookup\");\n\ntype Exposable = {\n\t[expose]?: readonly string[];\n};\n\nexport type LookupTarget = {\n\t[lookup]?: (name: string) => unknown;\n};\n\nconst exposedCache = new WeakMap<object, Set<string>>();\n\n/** Collects `expose` lists from an object's class and its parent classes. */\nexport const exposedMembers = (proto: object): Set<string> => {\n\tconst cached = exposedCache.get(proto);\n\tif (cached) return cached;\n\n\tconst members = new Set<string>();\n\tfor (\n\t\tlet current: object | null = proto;\n\t\tcurrent !== null && current !== Object.prototype;\n\t\tcurrent = Object.getPrototypeOf(current)\n\t) {\n\t\tconst owner: unknown = Object.hasOwn(current, \"constructor\")\n\t\t\t? (current as { constructor: unknown }).constructor\n\t\t\t: undefined;\n\t\tif (typeof owner === \"function\" && Object.hasOwn(owner, expose)) {\n\t\t\tconst list = (owner as Exposable)[expose];\n\t\t\tif (Array.isArray(list)) {\n\t\t\t\tfor (const name of list) {\n\t\t\t\t\tif (typeof name === \"string\" && !BLOCKED_NAMES.has(name)) {\n\t\t\t\t\t\tmembers.add(name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\texposedCache.set(proto, members);\n\treturn members;\n};\n","import { issue } from \"../errors.js\";\nimport type { PropType } from \"../parser/ast.js\";\nimport { BLOCKED_NAMES, exposedMembers } from \"./exposure.js\";\nimport { Markup } from \"./markup.js\";\nimport type { TypeCheck } from \"./types.js\";\n\nexport { BLOCKED_NAMES };\n\n/** Returned by guarded lookups for a variable or property that does not exist. Never escapes into template values. */\nexport const MISSING: unique symbol = Symbol(\"kiln.missing\");\n\nexport type Hash = Record<string, unknown>;\n\n/** Checks for an object literal or a null-prototype object, which Kiln treats as a hash. */\nexport const isPlainObject = (value: unknown): value is Hash => {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n};\n\n/** Checks for any value Kiln treats as a hash: a plain object or a `Map`. */\nexport const isHashLike = (\n\tvalue: unknown,\n): value is Hash | Map<unknown, unknown> =>\n\tisPlainObject(value) || value instanceof Map;\n\n/** Own enumerable keys of a plain object, without blocked names. */\nexport const hashKeys = (value: Hash): string[] => {\n\tconst keys = Object.keys(value);\n\tfor (let i = 0; i < keys.length; i++) {\n\t\t// The names in `BLOCKED_NAMES`, compared directly, which is quicker than the set for every key.\n\t\tconst key = keys[i] as string;\n\t\tif (key === \"constructor\" || key === \"prototype\" || key === \"__proto__\") {\n\t\t\treturn keys.filter((item) => !BLOCKED_NAMES.has(item));\n\t\t}\n\t}\n\treturn keys;\n};\n\n/** String keys of a `Map`, without blocked names: the keys templates can read. */\nexport const mapKeys = (map: Map<unknown, unknown>): string[] => {\n\tconst keys: string[] = [];\n\tfor (const key of map.keys()) {\n\t\tif (typeof key === \"string\" && !BLOCKED_NAMES.has(key)) keys.push(key);\n\t}\n\treturn keys;\n};\n\n/** Where a literal options hash keeps the formatters it resolved to, by kind. See `cachedFormatter`. */\nexport const FORMATTERS: unique symbol = Symbol(\"kiln.formatters\");\n\n/** Formatters an options hash last resolved to, with the render settings each was for. */\nexport type FormatterCells = Partial<\n\tRecord<\n\t\t\"number\" | \"date\" | \"plural\",\n\t\t{ locale: string; timeZone: string; formatter: object }\n\t>\n>;\n\n/**\n * A built-in's options hash of literals, such as `formatNumber(style: \"currency\")`'s, frozen, with a hidden place\n * for the formatter it resolves to. Built once per call site, so a filter called in a loop finds its formatter there.\n */\nexport const literalOptions = (\n\toptions: Record<string, unknown>,\n): Readonly<Record<string, unknown>> => {\n\tObject.defineProperty(options, FORMATTERS, { value: {} });\n\treturn Object.freeze(options);\n};\n\n/** Sets an own property without triggering the `__proto__` setter. */\nexport const setOwn = (target: Hash, key: string, value: unknown): void => {\n\tif (key === \"__proto__\") {\n\t\tObject.defineProperty(target, key, {\n\t\t\tvalue,\n\t\t\tenumerable: true,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t} else {\n\t\ttarget[key] = value;\n\t}\n};\n\nconst hasOwnKeys = (value: object): boolean => {\n\tfor (const key in value) {\n\t\tif (Object.hasOwn(value, key)) return true;\n\t}\n\treturn false;\n};\n\n/** Whether a map has an entry loops and filters read, as they skip blocked names. */\nconst hasReadableEntries = (map: Map<unknown, unknown>): boolean => {\n\tfor (const key of map.keys()) {\n\t\tif (typeof key !== \"string\" || !BLOCKED_NAMES.has(key)) return true;\n\t}\n\treturn false;\n};\n\n/** Kiln truthiness: empty arrays, hashes, maps and sets are falsy, and `\"0\"` is truthy. */\nexport const truthy = (value: unknown): boolean => {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn value;\n\t\tcase \"string\":\n\t\t\treturn value !== \"\";\n\t\tcase \"number\":\n\t\t\treturn value !== 0 && !Number.isNaN(value);\n\t\tcase \"undefined\":\n\t\t\treturn false;\n\t\tcase \"object\": {\n\t\t\tif (value === null) return false;\n\t\t\tif (Array.isArray(value)) return value.length > 0;\n\t\t\tif (value instanceof Markup) return value.value !== \"\";\n\t\t\tif (value instanceof Map) return hasReadableEntries(value);\n\t\t\tif (value instanceof Set) return value.size > 0;\n\t\t\tif (isPlainObject(value)) return hasOwnKeys(value);\n\t\t\treturn true;\n\t\t}\n\t\tdefault:\n\t\t\treturn true;\n\t}\n};\n\n/** Kiln emptiness, used by the `empty` test and `default` filter. Unlike falsiness, `0` is not empty. */\nexport const isEmpty = (value: unknown): boolean => {\n\tif (\n\t\tvalue === null ||\n\t\tvalue === undefined ||\n\t\tvalue === false ||\n\t\tvalue === \"\"\n\t) {\n\t\treturn true;\n\t}\n\tif (typeof value !== \"object\") return false;\n\tif (Array.isArray(value)) return value.length === 0;\n\tif (value instanceof Markup) return value.value === \"\";\n\tif (value instanceof Map) return !hasReadableEntries(value);\n\tif (value instanceof Set) return value.size === 0;\n\tif (isPlainObject(value)) return !hasOwnKeys(value);\n\treturn false;\n};\n\n/** A short name for a value's Kiln type, for error messages. */\nexport const typeName = (value: unknown): string => {\n\tif (value === null || value === undefined) return \"null\";\n\tif (Array.isArray(value)) return \"array\";\n\tif (value instanceof Markup) return \"markup\";\n\tif (value instanceof Date) return \"date\";\n\tif (value instanceof Map || isPlainObject(value)) return \"hash\";\n\tif (value instanceof Set) return \"set\";\n\tif (typeof value === \"function\") return \"function\";\n\tif (typeof value === \"object\") {\n\t\tconst name = Object.getPrototypeOf(value)?.constructor?.name;\n\t\treturn typeof name === \"string\" && name !== \"\"\n\t\t\t? `${name} object`\n\t\t\t: \"object\";\n\t}\n\treturn typeof value;\n};\n\n/**\n * Whether a value fits one member of a prop's type. `string` also accepts markup, and `object` any class instance.\n *\n * Only the outer value is checked: a list must be an array and a shape a hash or object, whatever they hold. Host types run their check from `types`.\n */\nexport const matchesType = (\n\tvalue: unknown,\n\ttype: readonly PropType[],\n\ttypes: ReadonlyMap<string, TypeCheck>,\n): boolean => {\n\tconst name = typeName(value);\n\treturn type.some((member) => {\n\t\tif (typeof member === \"string\") {\n\t\t\treturn (\n\t\t\t\tmember === name ||\n\t\t\t\t(member === \"string\" && name === \"markup\") ||\n\t\t\t\t(member === \"object\" && name.endsWith(\"object\"))\n\t\t\t);\n\t\t}\n\t\tif (\"literal\" in member) return unwrap(value) === member.literal;\n\t\tif (\"list\" in member) return name === \"array\";\n\t\tif (\"shape\" in member) return name === \"hash\" || name.endsWith(\"object\");\n\t\treturn types.get(member.named)?.(value) === true;\n\t});\n};\n\n/** Writes a prop's type as it appears in a template, such as `\"primary\" | \"secondary\"`. */\nexport const describeType = (type: readonly PropType[]): string =>\n\ttype.map(describeMember).join(\" | \");\n\nconst describeMember = (member: PropType): string => {\n\tif (typeof member === \"string\") return member;\n\tif (\"literal\" in member) return JSON.stringify(member.literal);\n\tif (\"named\" in member) return member.named;\n\tif (\"list\" in member) {\n\t\tconst inner = describeType(member.list);\n\t\treturn member.list.length > 1 ? `(${inner})[]` : `${inner}[]`;\n\t}\n\tif (member.shape.length === 0) return \"{}\";\n\tconst keys = member.shape.map(\n\t\t(key) => `${key.name}${key.optional ? \"?\" : \"\"}: ${describeType(key.type)}`,\n\t);\n\treturn `{ ${keys.join(\", \")} }`;\n};\n\n/** Describes a value for a type error: literal strings and numbers when the type lists literals, otherwise its type. */\nexport const describeValue = (\n\tvalue: unknown,\n\ttype: readonly PropType[],\n): string => {\n\tconst plain = unwrap(value);\n\tif (\n\t\t(typeof plain === \"string\" || typeof plain === \"number\") &&\n\t\ttype.some((member) => typeof member === \"object\" && \"literal\" in member)\n\t) {\n\t\treturn JSON.stringify(plain);\n\t}\n\treturn aType(value);\n};\n\n/** A value's type with an article, such as \"a hash\" or \"an array\", or \"null\". */\nconst aType = (value: unknown): string => {\n\tconst name = typeName(value);\n\tif (name === \"null\") return \"null\";\n\treturn `${/^[aeiou]/.test(name) ? \"an\" : \"a\"} ${name}`;\n};\n\n/**\n * Names a value in an error message without calling any of its methods, which templates may not call: a string,\n * number or boolean in quotes, or else its type, such as \"a hash\".\n */\nexport const valueLabel = (value: unknown): string => {\n\tconst plain = unwrap(value);\n\treturn typeof plain === \"string\" ||\n\t\ttypeof plain === \"number\" ||\n\t\ttypeof plain === \"boolean\"\n\t\t? `\"${String(plain)}\"`\n\t\t: aType(value);\n};\n\n/**\n * Arrow functions written in templates, each mapped to the version built-ins call. Built-ins that take callbacks accept\n * only these, never functions found in data. A promise from the built-ins' version may resolve to a held value; see\n * `hold`.\n */\nexport const templateFunctions = new WeakMap<\n\tobject,\n\t(...args: unknown[]) => unknown\n>();\n\n/** A class instance prints only when its class exposes `toString`. */\nconst exposesToString = (value: object): boolean => {\n\tif (Array.isArray(value) || isPlainObject(value)) return false;\n\tif (value instanceof Map || value instanceof Set) return false;\n\tconst proto = Object.getPrototypeOf(value) as object | null;\n\treturn proto !== null && exposedMembers(proto).has(\"toString\");\n};\n\n/** Converts a value to a string for output, `~` and interpolation. */\nexport const toStr = (value: unknown): string => {\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\t\treturn value;\n\t\tcase \"number\":\n\t\t\treturn String(value);\n\t\tcase \"boolean\":\n\t\t\treturn value ? \"true\" : \"false\";\n\t\tcase \"undefined\":\n\t\t\treturn \"\";\n\t\tcase \"object\": {\n\t\t\tif (value === null) return \"\";\n\t\t\tif (value instanceof Markup) return value.value;\n\t\t\tif (value instanceof Date) {\n\t\t\t\tif (Number.isNaN(value.getTime())) {\n\t\t\t\t\treturn issue(\"type-error\", \"Cannot print an invalid date\");\n\t\t\t\t}\n\t\t\t\treturn value.toISOString();\n\t\t\t}\n\t\t\tif (exposesToString(value)) {\n\t\t\t\t// Called directly, since `String` would call an unexposed `Symbol.toPrimitive` first.\n\t\t\t\tconst text: unknown = (value as { toString(): unknown }).toString();\n\t\t\t\tif (typeof text === \"string\") return text;\n\t\t\t\treturn issue(\n\t\t\t\t\t\"not-printable\",\n\t\t\t\t\t`\"toString\" of a ${typeName(value)} must return a string, but returned a ${typeName(text)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn issue(\n\t\t\t\t\"not-printable\",\n\t\t\t\t`Cannot print ${typeName(value) === \"array\" ? \"an array\" : `a ${typeName(value)}`}. Use a filter such as \"join\" or \"json\", or a loop`,\n\t\t\t);\n\t\t}\n\t\tdefault:\n\t\t\treturn issue(\"not-printable\", `Cannot print a ${typeName(value)}`);\n\t}\n};\n\n/** Strict equality, except that null equals undefined and markup compares by its text. */\nexport const equals = (left: unknown, right: unknown): boolean => {\n\tif (left === right) return true;\n\tif (left == null || right == null) return left == null && right == null;\n\tif (left instanceof Markup) return equals(left.value, right);\n\tif (right instanceof Markup) return equals(left, right.value);\n\treturn false;\n};\n\n/** Orders two numbers, two strings or two dates. Returns a negative, zero or positive number. */\nexport const compare = (left: unknown, right: unknown): number => {\n\tconst a = left instanceof Markup ? left.value : left;\n\tconst b = right instanceof Markup ? right.value : right;\n\tif (typeof a === \"number\" && typeof b === \"number\") return a - b;\n\tif (typeof a === \"string\" && typeof b === \"string\") {\n\t\treturn a < b ? -1 : a > b ? 1 : 0;\n\t}\n\tif (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();\n\treturn issue(\n\t\t\"type-error\",\n\t\t`Cannot compare ${typeName(a)} with ${typeName(b)}. Both sides must be numbers, strings or dates`,\n\t);\n};\n\n/** Requires a number, for arithmetic. */\nexport const toNumber = (value: unknown, operator: string): number => {\n\tif (typeof value === \"number\") return value;\n\treturn issue(\n\t\t\"type-error\",\n\t\t`\"${operator}\" needs numbers, but got ${typeName(value) === \"array\" ? \"an array\" : `a ${typeName(value)}`}`,\n\t);\n};\n\n/** Converts markup to its string, and leaves other values alone. */\nexport const unwrap = (value: unknown): unknown =>\n\tvalue instanceof Markup ? value.value : value;\n\n/** Requires a string, or markup, which is treated as its text. */\nexport const toStringArgument = (value: unknown, what: string): string => {\n\tif (typeof value === \"string\") return value;\n\tif (value instanceof Markup) return value.value;\n\tif (value === null || value === undefined) return \"\";\n\tif (typeof value === \"number\" || typeof value === \"boolean\") {\n\t\treturn toStr(value);\n\t}\n\treturn issue(\n\t\t\"type-error\",\n\t\t`${what} needs a string, but got a ${typeName(value)}`,\n\t);\n};\n","import {\n\tissue,\n\tKilnIssue,\n\tKilnRenderError,\n\tKilnSyntaxError,\n} from \"../errors.js\";\nimport { resolveTemplateName } from \"../names.js\";\nimport type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport {\n\ttype Gate,\n\tgateFor,\n\tmayRunAhead,\n\trunAhead,\n\trunSequence,\n} from \"./ahead.js\";\nimport { Markup } from \"./markup.js\";\nimport { childScope } from \"./scope.js\";\nimport {\n\ttype BlockDef,\n\ttype BlockEntry,\n\tblockScope,\n\ttype CompiledTemplate,\n\tNO_IMPORTS,\n\ttype Out,\n\ttype RenderState,\n\tRun,\n\ttype Scope,\n\ttype SlotFill,\n\ttype TemplateRef,\n} from \"./types.js\";\nimport {\n\thashKeys,\n\tisPlainObject,\n\tmapKeys,\n\tsetOwn,\n\ttypeName,\n} from \"./values.js\";\n\nexport const isPromise = (value: unknown): value is Promise<unknown> =>\n\tvalue instanceof Promise;\n\n/** A value with a `then` member, carried through a promise by `hold`. */\nclass Held {\n\tconstructor(readonly value: unknown) {}\n}\n\n/**\n * Wraps a value that has a `then` member, so a promise can resolve to it. A promise resolving to such a value would\n * call its `then`, which templates may not call. Whatever waits for the promise takes the value back out with `unhold`.\n *\n * Return a value from a callback that runs after a promise, such as one passed to `then`, through `hold`.\n */\nexport const hold = (value: unknown): unknown =>\n\t((typeof value === \"object\" && value !== null) ||\n\t\ttypeof value === \"function\") &&\n\t\"then\" in value &&\n\t!(value instanceof Promise)\n\t\t? new Held(value)\n\t\t: value;\n\n/**\n * `hold` for a value from your data, which may itself be a promise: a promise in render data is a value like any\n * other, and is never waited for. Return a value from a callback that never waits, after a promise, through it.\n */\nexport const holdData = (value: unknown): unknown =>\n\t((typeof value === \"object\" && value !== null) ||\n\t\ttypeof value === \"function\") &&\n\t\"then\" in value\n\t\t? new Held(value)\n\t\t: value;\n\n/**\n * A value from your data, returned by an expression that may wait. Whatever runs the expression waits for any promise\n * it returns, so a promise in the data comes back inside a promise of its own, which resolves to it held.\n */\nexport const passData = (value: unknown): unknown =>\n\tvalue instanceof Promise ? Promise.resolve(new Held(value)) : value;\n\n/** Takes a value back out of `hold`. Use on every value a promise resolves to. */\nexport const unhold = (value: unknown): unknown =>\n\tvalue instanceof Held ? value.value : value;\n\n/** Calls `next` with the value, after waiting for it only if it is a promise. */\nexport const after = <T, R>(\n\tvalue: T | Promise<T>,\n\tnext: (resolved: T) => R | Promise<R>,\n): R | Promise<R> =>\n\tvalue instanceof Promise\n\t\t? (value.then((resolved) =>\n\t\t\t\thold(next(unhold(resolved) as T)),\n\t\t\t) as Promise<R>)\n\t\t: next(value as T);\n\n/**\n * Waits for every promise in a list. Unlike `Promise.all`, never calls `then` on the other values; see `hold`.\n */\nexport const all = (values: readonly unknown[]): Promise<unknown[]> =>\n\tPromise.all(\n\t\tvalues.map((value) => (value instanceof Promise ? value : hold(value))),\n\t).then((list) => {\n\t\tfor (let i = 0; i < list.length; i++) list[i] = unhold(list[i]);\n\t\treturn list;\n\t});\n\n/** Stops a promise's rejection from being reported as unhandled, when a sibling failed first. */\nexport const silence = (value: unknown): void => {\n\tif (value instanceof Promise) value.catch(() => {});\n};\n\n/** Creates a located render error for the current template. */\nexport const fail = (\n\trun: Run,\n\tspan: Span,\n\tcode: string,\n\tmessage: string,\n\thint?: string,\n): KilnRenderError =>\n\tnew KilnRenderError(code, message, run.template.source, span, { hint });\n\nconst errorMessage = (error: unknown): string =>\n\terror instanceof Error ? error.message : String(error);\n\n/**\n * Turns any error into a located Kiln error. Kiln errors pass through. Errors from host code keep the original as `cause`.\n */\nexport const locate = (\n\trun: Run,\n\tspan: Span,\n\terror: unknown,\n\thost?: string,\n): unknown => {\n\tif (error instanceof KilnRenderError || error instanceof KilnSyntaxError) {\n\t\treturn error;\n\t}\n\tif (error instanceof KilnIssue)\n\t\treturn fail(run, span, error.code, error.message);\n\tif (host !== undefined) {\n\t\treturn new KilnRenderError(\n\t\t\t\"host-error\",\n\t\t\t`${host} threw an error: ${errorMessage(error)}`,\n\t\t\trun.template.source,\n\t\t\tspan,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\treturn fail(run, span, \"invalid-argument\", errorMessage(error));\n};\n\n/** Wraps a value or promise so any error is located at `span`. A promise also tells a streamed render it is waiting. */\nexport const locating = <T>(\n\trun: Run,\n\tspan: Span,\n\tproduce: () => T,\n\thost?: string,\n): T => {\n\ttry {\n\t\tlet value: unknown = produce();\n\t\t// Host code may return a thenable, such as a query builder, or a promise from another realm.\n\t\tif (\n\t\t\thost !== undefined &&\n\t\t\t!(value instanceof Promise) &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\ttypeof (value as { then?: unknown }).then === \"function\"\n\t\t) {\n\t\t\tvalue = Promise.resolve(value);\n\t\t}\n\t\tif (value instanceof Promise) {\n\t\t\trun.state.stream?.wait();\n\t\t\treturn value.catch((error: unknown) => {\n\t\t\t\tthrow locate(run, span, error, host);\n\t\t\t}) as T;\n\t\t}\n\t\treturn value as T;\n\t} catch (error) {\n\t\tthrow locate(run, span, error, host);\n\t}\n};\n\n/** Counts one step against `maxSteps`, and checks the abort signal. */\nexport const step = (run: Run, span: Span): void => {\n\tconst state = run.state;\n\tif (++state.steps > state.maxSteps) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Render stopped after ${state.maxSteps} steps`,\n\t\t);\n\t}\n\tif (state.signal?.aborted) {\n\t\tthrow fail(run, span, \"aborted\", \"Render was aborted\");\n\t}\n};\n\n/**\n * Charges built-in work in proportion to its size, such as items merged or sorted, so one call cannot do unbounded work.\n *\n * Throws a `KilnIssue`, which the call site locates.\n */\nexport const consume = (run: Run, amount: number): void => {\n\tconst state = run.state;\n\tstate.steps += amount;\n\tif (state.steps > state.maxSteps) {\n\t\tissue(\"limit-steps\", `Render stopped after ${state.maxSteps} steps`);\n\t}\n};\n\n/** `consume`, failing at `span`. For work in proportion to a value's size, such as the variables an include passes. */\nexport const consumeAt = (run: Run, span: Span, amount: number): void => {\n\tconst state = run.state;\n\tstate.steps += amount;\n\tif (state.steps > state.maxSteps) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Render stopped after ${state.maxSteps} steps`,\n\t\t);\n\t}\n};\n\n/** Refuses strings longer than `maxOutputLength`, which could never be printed. */\nexport const checkLength = (run: Run, text: string): string => {\n\tif (text.length > run.state.maxSize) {\n\t\tissue(\n\t\t\t\"limit-output\",\n\t\t\t`A string of ${text.length} characters is longer than the output limit of ${run.state.maxSize}`,\n\t\t);\n\t}\n\treturn text;\n};\n\n/**\n * Appends text to an output buffer, enforcing `maxOutputLength`. Output running ahead counts together with the buffer\n * it joins, as it would if it had waited its turn.\n */\nexport const write = (run: Run, out: Out, text: string, span: Span): void => {\n\tout.s += text;\n\tconst state = run.state;\n\tconst ahead = out.ahead;\n\tif (\n\t\tout.s.length > state.maxSize ||\n\t\t(ahead !== null &&\n\t\t\t(ahead.size += text.length) + ahead.base.s.length > state.maxSize)\n\t) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-output\",\n\t\t\t`Render stopped after ${state.maxSize} characters of output`,\n\t\t);\n\t}\n};\n\n/** Records the caller's location on a render error that passes through an include, component or `extends`. */\nexport const markCaller = (run: Run, span: Span, error: unknown): unknown => {\n\tif (error instanceof KilnRenderError) {\n\t\tconst start = run.template.source.position(span.start);\n\t\t(\n\t\t\terror.templateStack as {\n\t\t\t\ttemplate: string;\n\t\t\t\tline: number;\n\t\t\t\tcolumn: number;\n\t\t\t}[]\n\t\t).unshift({\n\t\t\ttemplate: run.template.name,\n\t\t\tline: start.line,\n\t\t\tcolumn: start.column,\n\t\t});\n\t}\n\treturn error;\n};\n\n/** Runs `work`, recording the caller's location on any render error. See `markCaller`. */\nexport const withCaller = <T>(\n\trun: Run,\n\tspan: Span,\n\twork: () => T | Promise<T>,\n): T | Promise<T> => {\n\ttry {\n\t\tconst result = work();\n\t\tif (result instanceof Promise) {\n\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t} catch (error) {\n\t\tthrow markCaller(run, span, error);\n\t}\n};\n\n/**\n * Loads a template by name, relative to the current template. Markup counts as its text. Returns null for a missing\n * template when `ignoreMissing` is set.\n */\nexport const loadTemplate = (\n\trun: Run,\n\tvalue: unknown,\n\tspan: Span,\n\tignoreMissing = false,\n): CompiledTemplate | null | Promise<CompiledTemplate | null> => {\n\tconst name = value instanceof Markup ? value.value : value;\n\tif (typeof name !== \"string\") {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`Template name must be a string, but got a ${typeName(name)}`,\n\t\t);\n\t}\n\tconst names = run.template.resolved;\n\tlet ref = names.get(name);\n\tif (ref === undefined) {\n\t\t// Names may be built from data, so a new one is checked against the output limit before it is resolved.\n\t\tconst resolved = locating(run, span, () =>\n\t\t\tresolveTemplateName(checkLength(run, name), run.template.name),\n\t\t);\n\t\tref = { resolved, template: null, generation: -1 };\n\t\tremember(names, name, ref);\n\t}\n\treturn loadRef(run, ref, span, ignoreMissing);\n};\n\n/** Names may come from data, so the caches of resolved names can't grow without limit. */\nconst remember = (\n\tnames: Map<string, TemplateRef>,\n\tname: string,\n\tref: TemplateRef,\n) => {\n\tif (names.size >= MAX_NAMES) names.clear();\n\tnames.set(name, ref);\n};\n\nconst MAX_NAMES = 1000;\n\n/** The template a reference found, while the environment hasn't dropped templates since, or else loads it again. */\nconst loadRef = (\n\trun: Run,\n\tref: TemplateRef,\n\tspan: Span,\n\tignoreMissing: boolean,\n): CompiledTemplate | null | Promise<CompiledTemplate | null> => {\n\tconst generation = run.state.env.generation;\n\tif (ref.template !== null && ref.generation === generation) {\n\t\treturn ref.template;\n\t}\n\tconst loaded = loadResolved(run, ref.resolved, span, ignoreMissing);\n\tif (loaded !== null && !(loaded instanceof Promise)) {\n\t\tref.template = loaded;\n\t\tref.generation = generation;\n\t}\n\treturn loaded;\n};\n\n/** Loads a template by its resolved name. */\nconst loadResolved = (\n\trun: Run,\n\tresolved: string,\n\tspan: Span,\n\tignoreMissing: boolean,\n): CompiledTemplate | null | Promise<CompiledTemplate | null> => {\n\tlet loaded: ReturnType<RenderState[\"env\"][\"load\"]>;\n\ttry {\n\t\tloaded = run.state.env.load(resolved);\n\t} catch (error) {\n\t\tthrow locate(run, span, error, LOADER);\n\t}\n\tif (loaded instanceof Promise) {\n\t\trun.state.stream?.wait();\n\t\tconst path = resolved;\n\t\treturn loaded.then(\n\t\t\t(template) => checkLoaded(run, span, path, template, ignoreMissing),\n\t\t\t(error: unknown) => {\n\t\t\t\tthrow locate(run, span, error, LOADER);\n\t\t\t},\n\t\t);\n\t}\n\treturn checkLoaded(run, span, resolved, loaded, ignoreMissing);\n};\n\nconst LOADER = \"The template loader\";\n\nconst checkLoaded = (\n\trun: Run,\n\tspan: Span,\n\tresolved: string,\n\ttemplate: CompiledTemplate | null,\n\tignoreMissing: boolean,\n): CompiledTemplate | null => {\n\tif (!template) {\n\t\tif (ignoreMissing) return null;\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-template\",\n\t\t\t`Template \"${resolved}\" was not found`,\n\t\t);\n\t}\n\tif (template.hasErrors) throw template.syntaxError();\n\treturn template;\n};\n\n/**\n * Renders an include or a component into `out`: loads the template, gives it a scope of its own holding `variables`,\n * and renders it. `slots` holds a component's fills. Waits only when loading or rendering returns a promise.\n */\nexport const embed = (\n\trun: Run,\n\tout: Out,\n\tspan: Span,\n\tname: unknown,\n\tvariables: unknown,\n\tslots: Map<string, SlotFill> | null,\n\tignoreMissing: boolean,\n): void | Promise<void> => {\n\tconst loaded = loadTemplate(run, name, span, ignoreMissing);\n\tif (loaded instanceof Promise) {\n\t\treturn loaded.then((template) => {\n\t\t\tif (!template) return;\n\t\t\tconst { scope, passed } = isolatedScope(run, variables, span);\n\t\t\treturn enter(run, out, span, template, scope, passed, slots);\n\t\t});\n\t}\n\tif (!loaded) return;\n\tconst { scope, passed } = isolatedScope(run, variables, span);\n\treturn enter(run, out, span, loaded, scope, passed, slots);\n};\n\n/**\n * `embed` for a scope the caller made, holding the variables named in `passed`. Precompiled templates make it\n * themselves when `with` is a hash of known keys.\n */\nexport const embedScope = (\n\trun: Run,\n\tout: Out,\n\tspan: Span,\n\tname: unknown,\n\tscope: Scope,\n\tpassed: readonly string[],\n\tslots: Map<string, SlotFill> | null,\n\tignoreMissing: boolean,\n): void | Promise<void> => {\n\treturn embedLoaded(\n\t\trun,\n\t\tout,\n\t\tspan,\n\t\tloadTemplate(run, name, span, ignoreMissing),\n\t\tscope,\n\t\tpassed,\n\t\tslots,\n\t);\n};\n\n/**\n * `embedScope` for a name made of a known prefix and a string key, such as `\"sections/\" ~ section.type`. Each key's\n * resolved name is kept on the including template, so the full name isn't built and looked up on every render.\n * `nameSpan` is where the name is joined, for its errors.\n */\nexport const embedKeyed = (\n\trun: Run,\n\tout: Out,\n\tspan: Span,\n\tprefix: string,\n\tkey: string,\n\tnameSpan: Span,\n\tscope: Scope,\n\tpassed: readonly string[],\n\tslots: Map<string, SlotFill> | null,\n\tignoreMissing: boolean,\n): void | Promise<void> => {\n\tconst template = run.template;\n\ttemplate.keyed ??= new Map();\n\tlet names = template.keyed.get(prefix);\n\tif (!names) {\n\t\tnames = new Map();\n\t\ttemplate.keyed.set(prefix, names);\n\t}\n\tlet ref = names.get(key);\n\tif (ref === undefined) {\n\t\tconst name = locating(run, nameSpan, () => checkLength(run, prefix + key));\n\t\tconst resolved = locating(run, span, () =>\n\t\t\tresolveTemplateName(name, template.name),\n\t\t);\n\t\tref = { resolved, template: null, generation: -1 };\n\t\tremember(names, key, ref);\n\t}\n\treturn embedLoaded(\n\t\trun,\n\t\tout,\n\t\tspan,\n\t\tloadRef(run, ref, span, ignoreMissing),\n\t\tscope,\n\t\tpassed,\n\t\tslots,\n\t);\n};\n\nconst embedLoaded = (\n\trun: Run,\n\tout: Out,\n\tspan: Span,\n\tloaded: CompiledTemplate | null | Promise<CompiledTemplate | null>,\n\tscope: Scope,\n\tpassed: readonly string[],\n\tslots: Map<string, SlotFill> | null,\n): void | Promise<void> => {\n\tif (loaded instanceof Promise) {\n\t\treturn loaded.then((template) =>\n\t\t\ttemplate\n\t\t\t\t? enter(run, out, span, template, scope, passed, slots)\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\tif (!loaded) return;\n\tif (loaded.plain) {\n\t\tconst state = run.state;\n\t\tconst depth = run.depth + 1;\n\t\tif (depth > state.maxDepth) {\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"limit-depth\",\n\t\t\t\t`Render stopped after nesting ${state.maxDepth} templates, macros or layouts deep`,\n\t\t\t);\n\t\t}\n\t\tif (slots !== null || loaded.slotNames.length > 0) {\n\t\t\taddSlotFlags(scope, loaded, slots);\n\t\t}\n\t\ttry {\n\t\t\tconst result = loaded.body(\n\t\t\t\tnew Run(\n\t\t\t\t\tstate,\n\t\t\t\t\tloaded,\n\t\t\t\t\tdepth,\n\t\t\t\t\tslots,\n\t\t\t\t\tpassed,\n\t\t\t\t\trun.capture,\n\t\t\t\t\trun.blockDepth,\n\t\t\t\t),\n\t\t\t\tscope,\n\t\t\t\tout,\n\t\t\t);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow markCaller(run, span, error);\n\t\t}\n\t}\n\treturn enter(run, out, span, loaded, scope, passed, slots);\n};\n\nconst enter = (\n\trun: Run,\n\tout: Out,\n\tspan: Span,\n\ttemplate: CompiledTemplate,\n\tscope: Scope,\n\tpassed: readonly string[],\n\tslots: Map<string, SlotFill> | null,\n): void | Promise<void> => {\n\taddSlotFlags(scope, template, slots);\n\ttry {\n\t\tconst result = renderTemplate(\n\t\t\trun.state,\n\t\t\ttemplate,\n\t\t\tscope,\n\t\t\tout,\n\t\t\trun.depth + 1,\n\t\t\tslots,\n\t\t\tpassed,\n\t\t\tnull,\n\t\t\trun,\n\t\t\tspan,\n\t\t);\n\t\tif (result instanceof Promise) {\n\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t} catch (error) {\n\t\tthrow markCaller(run, span, error);\n\t}\n};\n\n/** Loads every template a template imports, once per render. */\nexport const importsFor = (\n\trun: Run,\n\ttemplate: CompiledTemplate,\n): readonly CompiledTemplate[] | Promise<readonly CompiledTemplate[]> => {\n\tif (template.imports.length === 0) return NO_IMPORTS;\n\tconst state = run.state;\n\tconst cached = state.importsCache?.get(template);\n\tif (cached) return cached;\n\n\tconst loaded: (CompiledTemplate | null | Promise<CompiledTemplate | null>)[] =\n\t\t[];\n\ttry {\n\t\tfor (const { name, span } of template.imports) {\n\t\t\tloaded.push(\n\t\t\t\tloadTemplate(\n\t\t\t\t\tnew Run(state, template, run.depth, null, null),\n\t\t\t\t\tname,\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\t// Earlier imports may still be loading. Stop their rejections being reported as unhandled.\n\t\tfor (const value of loaded) silence(value);\n\t\tthrow error;\n\t}\n\tconst finish = (list: (CompiledTemplate | null)[]) => {\n\t\tconst imports = list as CompiledTemplate[];\n\t\tstate.importsCache ??= new Map();\n\t\tstate.importsCache.set(template, imports);\n\t\treturn imports;\n\t};\n\t// oxlint-disable-next-line typescript/await-thenable -- only some are promises, and `Promise.all` passes the rest through\n\tif (loaded.some(isPromise)) return Promise.all(loaded).then(finish);\n\treturn finish(loaded as (CompiledTemplate | null)[]);\n};\n\n/** Creates an isolated scope holding globals plus the given variables. Each variable passed counts as a step. */\nexport const isolatedScope = (\n\trun: Run,\n\tvariables: unknown,\n\tspan: Span,\n): { scope: Scope; passed: string[] } => {\n\tconst scope = childScope(run.state.globals);\n\tconst passed: string[] = [];\n\tif (variables === null || variables === undefined) return { scope, passed };\n\tif (isPlainObject(variables)) {\n\t\tconst keys = hashKeys(variables);\n\t\tconsumeAt(run, span, keys.length);\n\t\tfor (const key of keys) scope[key] = variables[key] ?? null;\n\t\treturn { scope, passed: keys };\n\t}\n\tif (variables instanceof Map) {\n\t\tconsumeAt(run, span, variables.size);\n\t\tfor (const key of mapKeys(variables)) {\n\t\t\tscope[key] = variables.get(key) ?? null;\n\t\t\tpassed.push(key);\n\t\t}\n\t} else {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`\"with\" needs a hash, but got a ${typeName(variables)}`,\n\t\t);\n\t}\n\treturn { scope, passed };\n};\n\n/**\n * Renders a template into `out`, following `extends` and sharing `scope` along the inheritance chain. `inherited` is\n * the block table of the child templates below it, and `caller` the render that asked for it, for depth errors and the\n * capture it renders in: null for the outermost render. `block`, for `renderBlock`, is the block to render once the top-most template is reached,\n * instead of its content. `gate`, for a layout, holds the page's top-level statements while they wait.\n */\nexport const renderTemplate = (\n\tstate: RenderState,\n\ttemplate: CompiledTemplate,\n\tscope: Scope,\n\tout: Out,\n\tdepth: number,\n\tslots: Map<string, SlotFill> | null,\n\tpassed: readonly string[] | null,\n\tinherited: Map<string, BlockEntry[]> | null,\n\tcaller: Run | null,\n\tcallerSpan: Span,\n\tblock?: string,\n\tgate: Gate | null = null,\n): void | Promise<void> => {\n\tif (caller && depth > state.maxDepth) {\n\t\tthrow fail(\n\t\t\tcaller,\n\t\t\tcallerSpan,\n\t\t\t\"limit-depth\",\n\t\t\t`Render stopped after nesting ${state.maxDepth} templates, macros or layouts deep`,\n\t\t);\n\t}\n\n\t// Which layout a template extends is only known now, so the layout's slots join the `slots` hash here.\n\tif (inherited && template.slotNames.length > 0) {\n\t\taddLayoutSlotFlags(scope, template, slots);\n\t}\n\n\tconst run = new Run(\n\t\tstate,\n\t\ttemplate,\n\t\tdepth,\n\t\tslots,\n\t\tpassed,\n\t\tcaller?.capture ?? null,\n\t\tcaller?.blockDepth ?? 0,\n\t);\n\n\t// Every template in an inheritance chain shares one block table, most derived definition first, so `parent()` can find the next one from any level.\n\t// A page that defines no blocks still needs a table of its own, for its layout's blocks.\n\tif (inherited || template.blocks.size > 0 || template.parent !== null) {\n\t\tconst blocks = inherited ?? new Map<string, BlockEntry[]>();\n\t\ttemplate.blockList ??= [...template.blocks];\n\t\tconst defined = template.blockList;\n\t\tfor (let i = 0; i < defined.length; i++) {\n\t\t\tconst [name, def] = defined[i] as readonly [string, BlockDef];\n\t\t\tconst entry = { def, run };\n\t\t\tconst list = blocks.get(name);\n\t\t\tif (list) list.push(entry);\n\t\t\telse blocks.set(name, [entry]);\n\t\t}\n\t\trun.blocks = blocks;\n\t}\n\n\tconst imports = importsFor(run, template);\n\tif (imports instanceof Promise) {\n\t\treturn imports.then((list) =>\n\t\t\trenderBody(run, scope, out, list, block, gate),\n\t\t);\n\t}\n\treturn renderBody(run, scope, out, imports, block, gate);\n};\n\n/**\n * Renders a template's own content once its imports are loaded, then its layout if it extends one. While a page's\n * top-level statements wait, its layout starts, behind a gate for them; see `Gate`.\n */\nconst renderBody = (\n\trun: Run,\n\tscope: Scope,\n\tout: Out,\n\timports: readonly CompiledTemplate[],\n\tblock: string | undefined,\n\tgate: Gate | null,\n): void | Promise<void> => {\n\trun.imports = imports;\n\tconst { template, state } = run;\n\tconst parent = template.parent;\n\tif (!parent && block !== undefined) {\n\t\treturn renderOnlyBlock(run, scope, out, block);\n\t}\n\tconst top = template.top;\n\tconst result =\n\t\tgate === null || top === null\n\t\t\t? template.body(run, scope, out)\n\t\t\t: runSequence(top, 0, top.statements.length - 1, run, scope, out, gate);\n\tif (!parent) return result;\n\n\tconst span = template.parentSpan;\n\tif (\n\t\tresult !== undefined &&\n\t\t!parent.async &&\n\t\tblock === undefined &&\n\t\tmayRunAhead(state)\n\t) {\n\t\tconst effects = template.early?.() ?? null;\n\t\tif (effects !== null) {\n\t\t\tconst next = gateFor(result, effects, gate);\n\t\t\treturn runAhead(\n\t\t\t\trun,\n\t\t\t\tout,\n\t\t\t\tresult,\n\t\t\t\t(ahead, aheadOut) =>\n\t\t\t\t\tafter(loadTemplate(ahead, parent.ev(ahead, scope), span), (layout) =>\n\t\t\t\t\t\twithCaller(ahead, span, () =>\n\t\t\t\t\t\t\trenderTemplate(\n\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\tlayout as CompiledTemplate,\n\t\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\t\taheadOut,\n\t\t\t\t\t\t\t\trun.depth + 1,\n\t\t\t\t\t\t\t\trun.slots,\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\trun.blocks,\n\t\t\t\t\t\t\t\tahead,\n\t\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t}\n\t// Usually nothing waits: the layout is found and rendered without callbacks.\n\tif (result === undefined && !parent.async) {\n\t\tconst loaded = loadTemplate(run, parent.ev(run, scope), span);\n\t\tif (!(loaded instanceof Promise)) {\n\t\t\ttry {\n\t\t\t\tconst layout = renderTemplate(\n\t\t\t\t\tstate,\n\t\t\t\t\tloaded as CompiledTemplate,\n\t\t\t\t\tscope,\n\t\t\t\t\tout,\n\t\t\t\t\trun.depth + 1,\n\t\t\t\t\trun.slots,\n\t\t\t\t\t// Layouts check required props, but not undeclared ones: the context was meant for the page.\n\t\t\t\t\tnull,\n\t\t\t\t\trun.blocks,\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\tblock,\n\t\t\t\t\tgate,\n\t\t\t\t);\n\t\t\t\tif (layout instanceof Promise) {\n\t\t\t\t\treturn layout.catch((error: unknown) => {\n\t\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn layout;\n\t\t\t} catch (error) {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t}\n\t\t}\n\t\treturn loaded.then((layout) =>\n\t\t\twithCaller(run, span, () =>\n\t\t\t\trenderTemplate(\n\t\t\t\t\tstate,\n\t\t\t\t\tlayout as CompiledTemplate,\n\t\t\t\t\tscope,\n\t\t\t\t\tout,\n\t\t\t\t\trun.depth + 1,\n\t\t\t\t\trun.slots,\n\t\t\t\t\tnull,\n\t\t\t\t\trun.blocks,\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\tblock,\n\t\t\t\t\tgate,\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t}\n\treturn after(result, () =>\n\t\tafter(parent.ev(run, scope), (name) =>\n\t\t\tafter(loadTemplate(run, name, span), (parentTemplate) =>\n\t\t\t\twithCaller(run, span, () =>\n\t\t\t\t\trenderTemplate(\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tparentTemplate as CompiledTemplate,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tout,\n\t\t\t\t\t\trun.depth + 1,\n\t\t\t\t\t\trun.slots,\n\t\t\t\t\t\t// Layouts check required props, but not undeclared ones: the context was meant for the page.\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\trun.blocks,\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\tblock,\n\t\t\t\t\t\tgate,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n};\n\n/**\n * Renders one block of the top-most template in a chain, for `renderBlock`. Applies the template's `props`, but runs none of its other content.\n */\nconst renderOnlyBlock = (\n\trun: Run,\n\tscope: Scope,\n\tout: Out,\n\tname: string,\n): void | Promise<void> =>\n\tafter(run.template.props?.(run, scope, out), () => {\n\t\tconst entry = run.blocks.get(name)?.[0];\n\t\tif (!entry) {\n\t\t\tthrow new KilnRenderError(\n\t\t\t\t\"unknown-block\",\n\t\t\t\t`Block \"${name}\" does not exist`,\n\t\t\t\trun.template.name,\n\t\t\t\tundefined,\n\t\t\t\t{ hint: suggest(name, run.blocks.keys()) },\n\t\t\t);\n\t\t}\n\t\treturn entry.def.body(entry.run, blockScope(entry.def, scope), out);\n\t});\n\n/** Gives a component or include scope its `slots` hash, with a key for every slot the template outputs. */\nexport const addSlotFlags = (\n\tscope: Scope,\n\ttemplate: CompiledTemplate,\n\tslots: Map<string, SlotFill> | null,\n): void => {\n\tif (template.slotNames.length === 0 && !slots) return;\n\t// A plain object, which V8 keeps fast; templates only read its own properties.\n\tconst flags: Record<string, boolean> = {};\n\tfor (const name of template.slotNames) setOwn(flags, name, false);\n\tif (slots) for (const name of slots.keys()) setOwn(flags, name, true);\n\tscope.slots = flags;\n};\n\n/** Adds the slots a layout declares to the `slots` hash of the template that extends it. */\nconst addLayoutSlotFlags = (\n\tscope: Scope,\n\ttemplate: CompiledTemplate,\n\tslots: Map<string, SlotFill> | null,\n): void => {\n\tconst current = Object.hasOwn(scope, \"slots\") ? scope.slots : undefined;\n\tconst flags: Record<string, boolean> = {};\n\tif (isPlainObject(current)) {\n\t\tfor (const name of hashKeys(current))\n\t\t\tsetOwn(flags, name, current[name] === true);\n\t}\n\tfor (const name of template.slotNames) {\n\t\tif (!Object.hasOwn(flags, name))\n\t\t\tsetOwn(flags, name, slots?.has(name) ?? false);\n\t}\n\tscope.slots = flags;\n};\n","import {\n\tBLOCKED_NAMES,\n\texposedMembers,\n\ttype LookupTarget,\n\tlookup,\n} from \"./exposure.js\";\nimport { Markup } from \"./markup.js\";\nimport { hashKeys, isPlainObject, mapKeys, MISSING } from \"./values.js\";\n\nconst isClassInstance = (value: object): boolean =>\n\t!Array.isArray(value) &&\n\t!isPlainObject(value) &&\n\t!(value instanceof Map) &&\n\t!(value instanceof Set) &&\n\t!(value instanceof Date) &&\n\t!(value instanceof Markup);\n\nconst arrayIndex = (key: string | number): number => {\n\tif (typeof key === \"number\") return Number.isInteger(key) ? key : -1;\n\treturn /^(0|[1-9]\\d*)$/.test(key) ? Number(key) : -1;\n};\n\n/**\n * Reads a property the way templates may, following the safety model. Returns `MISSING` when the property cannot be read or does not exist.\n */\nexport const getAttr = (target: unknown, key: string | number): unknown => {\n\tif (typeof target !== \"object\" || target === null) return MISSING;\n\n\tif (Array.isArray(target)) {\n\t\tif (key === \"length\") return target.length;\n\t\tconst index = arrayIndex(key);\n\t\treturn index >= 0 && index < target.length ? target[index] : MISSING;\n\t}\n\n\tconst name = typeof key === \"number\" ? String(key) : key;\n\tif (BLOCKED_NAMES.has(name)) return MISSING;\n\n\tconst proto = Object.getPrototypeOf(target);\n\tif (proto === Object.prototype || proto === null) {\n\t\treturn Object.hasOwn(target, name)\n\t\t\t? (target as Record<string, unknown>)[name]\n\t\t\t: MISSING;\n\t}\n\tif (target instanceof Map) {\n\t\treturn target.has(name) ? target.get(name) : MISSING;\n\t}\n\tif (!isClassInstance(target)) return MISSING;\n\n\tif (exposedMembers(proto).has(name)) {\n\t\treturn (target as Record<string, unknown>)[name];\n\t}\n\tconst resolver = (target as LookupTarget)[lookup];\n\tif (typeof resolver === \"function\") {\n\t\tconst value = resolver.call(target, name);\n\t\treturn value === undefined ? MISSING : value;\n\t}\n\treturn MISSING;\n};\n\n/** Returns an exposed method of a class instance, or `undefined` when it is not exposed or not a function. */\nexport const getMethod = (\n\ttarget: unknown,\n\tname: string,\n): ((...args: unknown[]) => unknown) | undefined => {\n\tif (typeof target !== \"object\" || target === null) return undefined;\n\tif (!isClassInstance(target) || BLOCKED_NAMES.has(name)) return undefined;\n\tif (!exposedMembers(Object.getPrototypeOf(target)).has(name))\n\t\treturn undefined;\n\tconst method = (target as Record<string, unknown>)[name];\n\treturn typeof method === \"function\"\n\t\t? (method as (...args: unknown[]) => unknown)\n\t\t: undefined;\n};\n\n/** Names a template could read from a value, for \"did you mean\" hints. */\nexport const readableNames = (target: unknown): string[] => {\n\tif (typeof target !== \"object\" || target === null) return [];\n\tif (isPlainObject(target)) return hashKeys(target);\n\tif (target instanceof Map) return mapKeys(target);\n\tif (isClassInstance(target)) {\n\t\treturn [...exposedMembers(Object.getPrototypeOf(target))];\n\t}\n\treturn [];\n};\n","import { issue } from \"../errors.js\";\nimport type { EscapeStrategy } from \"../parser/ast.js\";\nimport { getAttr, readableNames } from \"../runtime/access.js\";\nimport { escapeWith } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport { checkLength, consume } from \"../runtime/render.js\";\nimport type { Run } from \"../runtime/types.js\";\nimport {\n\tBLOCKED_NAMES,\n\thashKeys,\n\tisPlainObject,\n\tMISSING,\n\ttemplateFunctions,\n\ttoStringArgument,\n\ttypeName,\n} from \"../runtime/values.js\";\n\n/** Iterables from the host are read up to this many items, so an endless generator cannot hang a filter. */\nconst MAX_ITERABLE_ITEMS = 1_000_000;\n\n/** Lists and hashes nested deeper than this are refused by `json`, `dump` and `urlEncode`, so they can't overflow the stack. */\nexport const MAX_DATA_DEPTH = 1000;\n\n/** Refuses data nested deeper than `MAX_DATA_DEPTH`. */\nexport const checkDepth = (depth: number, what: string): void => {\n\tif (depth > MAX_DATA_DEPTH) {\n\t\tissue(\n\t\t\t\"too-deep\",\n\t\t\t`\"${what}\" cannot convert data nested more than ${MAX_DATA_DEPTH} levels deep`,\n\t\t);\n\t}\n};\n\n/**\n * The keys and values of a `Map` that templates can read, as loops see them: every entry except those under a\n * blocked name such as `__proto__`, whatever the type of its key.\n */\nexport const mapContents = (\n\tmap: Map<unknown, unknown>,\n): { keys: unknown[]; values: unknown[] } => {\n\tconst keys: unknown[] = [];\n\tconst values: unknown[] = [];\n\tfor (const [key, item] of map) {\n\t\tif (typeof key === \"string\" && BLOCKED_NAMES.has(key)) continue;\n\t\tkeys.push(key);\n\t\tvalues.push(item);\n\t}\n\treturn { keys, values };\n};\n\n/**\n * Values and keys of anything a filter can treat as a list. Hashes keep their keys.\n *\n * Every item is charged against `maxSteps`: arrays and hashes before they are read, and iterables such as generators\n * as each item is read.\n */\nexport const entriesOf = (\n\trun: Run,\n\tvalue: unknown,\n\twhat: string,\n): { values: unknown[]; keys: unknown[]; isHash: boolean } => {\n\tif (value === null || value === undefined) {\n\t\treturn { values: [], keys: [], isHash: false };\n\t}\n\tif (Array.isArray(value)) {\n\t\tconsume(run, value.length);\n\t\treturn {\n\t\t\tvalues: value,\n\t\t\tkeys: value.map((_, index) => index),\n\t\t\tisHash: false,\n\t\t};\n\t}\n\tif (isPlainObject(value)) {\n\t\tconst keys = hashKeys(value);\n\t\tconsume(run, keys.length);\n\t\treturn { values: keys.map((key) => value[key]), keys, isHash: true };\n\t}\n\tif (value instanceof Map) {\n\t\tconsume(run, value.size);\n\t\treturn { ...mapContents(value), isHash: true };\n\t}\n\tif (\n\t\ttypeof value === \"object\" &&\n\t\t!(value instanceof Markup) &&\n\t\ttypeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] ===\n\t\t\t\"function\"\n\t) {\n\t\tconst values: unknown[] = [];\n\t\tfor (const item of value as Iterable<unknown>) {\n\t\t\tif (values.length === MAX_ITERABLE_ITEMS) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"limit-steps\",\n\t\t\t\t\t`\"${what}\" got an iterable with more than ${MAX_ITERABLE_ITEMS} items`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconsume(run, 1);\n\t\t\tvalues.push(item);\n\t\t}\n\t\treturn { values, keys: values.map((_, index) => index), isHash: false };\n\t}\n\treturn issue(\n\t\t\"type-error\",\n\t\t`\"${what}\" needs an array or hash, but got a ${typeName(value)}`,\n\t);\n};\n\n/** Items of an array, set or other iterable, as an array. Arrays are returned as they are. */\nexport const listOf = (run: Run, value: unknown, what: string): unknown[] => {\n\tif (Array.isArray(value)) return value;\n\treturn entriesOf(run, value, what).values;\n};\n\n/** Requires an integer argument. */\nexport const integerArgument = (value: unknown, what: string): number => {\n\tif (typeof value === \"number\" && Number.isInteger(value)) return value;\n\treturn issue(\n\t\t\"type-error\",\n\t\t`${what} must be an integer, but got ${typeName(value)}`,\n\t);\n};\n\n/** Requires an arrow function written in the template. Functions found in data are refused. */\nexport const functionArgument = (\n\tvalue: unknown,\n\twhat: string,\n): ((...args: unknown[]) => unknown) => {\n\tconst fn =\n\t\ttypeof value === \"function\" ? templateFunctions.get(value) : undefined;\n\tif (fn) return fn;\n\treturn issue(\n\t\t\"type-error\",\n\t\t`\"${what}\" needs an arrow function such as \"item => item.title\", but got a ${typeName(value)}`,\n\t);\n};\n\nconst ISO_DATE =\n\t/^\\d{4}-\\d{2}-\\d{2}(?:[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\n/** Reads `count` digits from `at`, or returns -1 if any is not a digit. */\nconst readDigits = (text: string, at: number, count: number): number => {\n\tlet number = 0;\n\tfor (let i = at; i < at + count; i++) {\n\t\tconst digit = text.charCodeAt(i) - 48;\n\t\tif (digit < 0 || digit > 9) return -1;\n\t\tnumber = number * 10 + digit;\n\t}\n\treturn number;\n};\n\nconst daysInMonth = (year: number, month: number): number =>\n\tmonth === 2\n\t\t? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\t\t\t? 29\n\t\t\t: 28\n\t\t: month === 4 || month === 6 || month === 9 || month === 11\n\t\t\t? 30\n\t\t\t: 31;\n\n/**\n * Reads the two commonest ISO 8601 forms, `2026-10-15` and `2026-10-15T09:30:00.000Z`, as milliseconds since the\n * epoch, without parsing a string as a date. Returns null for anything else, including out of range parts, which\n * `toDate` then reads in full.\n */\nconst quickTime = (text: string): number | null => {\n\tconst length = text.length;\n\tif (length !== 10 && length !== 24) return null;\n\tconst year = readDigits(text, 0, 4);\n\tconst month = readDigits(text, 5, 2);\n\tconst day = readDigits(text, 8, 2);\n\tif (\n\t\tyear < 100 ||\n\t\tmonth < 1 ||\n\t\tmonth > 12 ||\n\t\tday < 1 ||\n\t\tday > daysInMonth(year, month) ||\n\t\ttext[4] !== \"-\" ||\n\t\ttext[7] !== \"-\"\n\t) {\n\t\treturn null;\n\t}\n\tlet time = 0;\n\tif (length === 24) {\n\t\tconst hour = readDigits(text, 11, 2);\n\t\tconst minute = readDigits(text, 14, 2);\n\t\tconst second = readDigits(text, 17, 2);\n\t\tconst millisecond = readDigits(text, 20, 3);\n\t\tif (\n\t\t\ttext[10] !== \"T\" ||\n\t\t\ttext[13] !== \":\" ||\n\t\t\ttext[16] !== \":\" ||\n\t\t\ttext[19] !== \".\" ||\n\t\t\ttext[23] !== \"Z\" ||\n\t\t\thour < 0 ||\n\t\t\thour > 23 ||\n\t\t\tminute < 0 ||\n\t\t\tminute > 59 ||\n\t\t\tsecond < 0 ||\n\t\t\tsecond > 59 ||\n\t\t\tmillisecond < 0\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\ttime = ((hour * 60 + minute) * 60 + second) * 1000 + millisecond;\n\t}\n\treturn Date.UTC(year, month - 1, day) + time;\n};\n\n/** `toDate` as milliseconds since the epoch, which formatters take without making a `Date`. */\nexport const toTime = (value: unknown, what: string): number => {\n\tif (typeof value === \"string\") {\n\t\tconst time = quickTime(value);\n\t\tif (time !== null) return time;\n\t}\n\treturn toDate(value, what).getTime();\n};\n\n/** Converts a date, ISO 8601 string or milliseconds since the epoch into a valid `Date`. */\nexport const toDate = (value: unknown, what: string): Date => {\n\tlet date: Date | undefined;\n\tconst quick = typeof value === \"string\" ? quickTime(value) : null;\n\tif (value instanceof Date) date = value;\n\telse if (typeof value === \"number\") date = new Date(value);\n\telse if (quick !== null) date = new Date(quick);\n\telse if (value instanceof Markup || typeof value === \"string\") {\n\t\tconst text = String(value).trim();\n\t\tif (!ISO_DATE.test(text)) {\n\t\t\treturn issue(\n\t\t\t\t\"invalid-argument\",\n\t\t\t\t`${what} needs an ISO 8601 date such as \"2026-10-15\", but got \"${text}\"`,\n\t\t\t);\n\t\t}\n\t\t// `Date` would roll a day past the end of its month into the next month.\n\t\tconst year = readDigits(text, 0, 4);\n\t\tconst month = readDigits(text, 5, 2);\n\t\tconst day = readDigits(text, 8, 2);\n\t\tif (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)) {\n\t\t\treturn issue(\"invalid-argument\", `${what} got an invalid date \"${text}\"`);\n\t\t}\n\t\t// A date-time without an offset is read as UTC, so output never depends on the server's time zone.\n\t\tconst normalised = text.replace(\" \", \"T\");\n\t\tconst hasZone = /(?:Z|[+-]\\d{2}:?\\d{2})$/.test(normalised);\n\t\tdate = new Date(\n\t\t\tnormalised.length > 10 && !hasZone ? `${normalised}Z` : normalised,\n\t\t);\n\t}\n\tif (!date) {\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t`${what} needs a date, ISO 8601 string or milliseconds, but got a ${typeName(value)}`,\n\t\t);\n\t}\n\tif (Number.isNaN(date.getTime())) {\n\t\treturn issue(\"invalid-argument\", `${what} got an invalid date`);\n\t}\n\treturn date;\n};\n\n/** Reads one property of an item for `column` and `sort`, or null when missing. */\nexport const readProperty = (item: unknown, name: string | number): unknown => {\n\tconst value = getAttr(item, name);\n\treturn value === MISSING || value === undefined || typeof value === \"function\"\n\t\t? null\n\t\t: value;\n};\n\n/** How `toPlainData` charges for and limits its work. */\nexport type PlainDataOptions = {\n\t/** The filter or function converting, for error messages. */\n\twhat: string;\n\t/** Called with the number of items in each list or hash before they are copied. */\n\tcharge?: (count: number) => void;\n\t/** Refuses data whose JSON would be longer than this many characters. */\n\tmaxLength?: number;\n\t/** The spaces each level of the JSON is indented by, which `maxLength` counts. */\n\tindent?: number;\n};\n\n/**\n * Converts a value into plain JSON data, following the safety model: hashes by own keys, class instances by exposed\n * members only, and sets, generators and other iterables as lists.\n *\n * `onCycle` decides what a repeated object becomes. While it converts, it counts the shortest JSON the data could\n * make, and stops at `maxLength`, so a value that shares one long string in many places can't make a huge string.\n */\nexport const toPlainData = (\n\tvalue: unknown,\n\tonCycle: () => unknown,\n\t{\n\t\twhat,\n\t\tcharge = () => {},\n\t\tmaxLength = Infinity,\n\t\tindent = 0,\n\t}: PlainDataOptions,\n): unknown => {\n\tconst seen = new Set<object>();\n\tlet size = 0;\n\tconst grow = (amount: number) => {\n\t\tsize += amount;\n\t\tif (size > maxLength) {\n\t\t\tissue(\n\t\t\t\t\"limit-output\",\n\t\t\t\t`\"${what}\" would build a string longer than the output limit of ${maxLength}`,\n\t\t\t);\n\t\t}\n\t};\n\tconst convertItems = (items: Iterable<unknown>, depth: number): unknown[] => {\n\t\tconst result: unknown[] = [];\n\t\tfor (const item of items) {\n\t\t\tgrow(indent === 0 ? 1 : 2 + depth * indent);\n\t\t\tresult.push(convert(item, depth) ?? null);\n\t\t}\n\t\treturn result;\n\t};\n\tconst convert = (value: unknown, depth: number): unknown => {\n\t\tif (value === null || value === undefined) {\n\t\t\tgrow(4);\n\t\t\treturn null;\n\t\t}\n\t\tswitch (typeof value) {\n\t\t\tcase \"string\":\n\t\t\t\tgrow(value.length + 2);\n\t\t\t\treturn value;\n\t\t\tcase \"boolean\":\n\t\t\t\tgrow(value ? 4 : 5);\n\t\t\t\treturn value;\n\t\t\tcase \"number\":\n\t\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\t\tgrow(4);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tgrow(String(value).length);\n\t\t\t\treturn value;\n\t\t\tcase \"bigint\": {\n\t\t\t\tconst text = value.toString();\n\t\t\t\tgrow(text.length + 2);\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tcase \"function\":\n\t\t\tcase \"symbol\":\n\t\t\t\treturn undefined;\n\t\t}\n\t\tif (value instanceof Markup) return convert(value.value, depth);\n\t\tif (value instanceof Date) {\n\t\t\treturn convert(\n\t\t\t\tNumber.isNaN(value.getTime()) ? null : value.toISOString(),\n\t\t\t\tdepth,\n\t\t\t);\n\t\t}\n\t\tconst object = value as object;\n\t\tif (seen.has(object)) return onCycle();\n\t\tcheckDepth(depth + 1, what);\n\t\tseen.add(object);\n\t\tgrow(2);\n\t\ttry {\n\t\t\tif (Array.isArray(object)) {\n\t\t\t\tcharge(object.length);\n\t\t\t\treturn convertItems(object, depth + 1);\n\t\t\t}\n\t\t\tif (object instanceof Set) {\n\t\t\t\tcharge(object.size);\n\t\t\t\treturn convertItems(object, depth + 1);\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!isPlainObject(object) &&\n\t\t\t\t!(object instanceof Map) &&\n\t\t\t\ttypeof (object as { [Symbol.iterator]?: unknown })[Symbol.iterator] ===\n\t\t\t\t\t\"function\"\n\t\t\t) {\n\t\t\t\tconst items: unknown[] = [];\n\t\t\t\tfor (const item of object as Iterable<unknown>) {\n\t\t\t\t\tif (items.length === MAX_ITERABLE_ITEMS) {\n\t\t\t\t\t\treturn issue(\n\t\t\t\t\t\t\t\"limit-steps\",\n\t\t\t\t\t\t\t`\"${what}\" got an iterable with more than ${MAX_ITERABLE_ITEMS} items`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcharge(1);\n\t\t\t\t\titems.push(item);\n\t\t\t\t}\n\t\t\t\treturn convertItems(items, depth + 1);\n\t\t\t}\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tconst { keys, values } =\n\t\t\t\tobject instanceof Map\n\t\t\t\t\t? mapContents(object)\n\t\t\t\t\t: { keys: readableNames(object), values: null };\n\t\t\tcharge(keys.length);\n\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\tconst name = String(keys[i]);\n\t\t\t\tconst item = convert(\n\t\t\t\t\tvalues ? values[i] : getAttr(object, name),\n\t\t\t\t\tdepth + 1,\n\t\t\t\t);\n\t\t\t\tif (item !== undefined && item !== MISSING) {\n\t\t\t\t\tgrow(name.length + (indent === 0 ? 4 : 6 + (depth + 1) * indent));\n\t\t\t\t\tObject.defineProperty(result, name, {\n\t\t\t\t\t\tvalue: item,\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\twritable: true,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tseen.delete(object);\n\t\t}\n\t};\n\treturn convert(value, 0);\n};\n\nconst isAsciiLetter = (code: number): boolean =>\n\t(code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n\nconst isSpace = (char: string | undefined): boolean =>\n\tchar === \" \" ||\n\tchar === \"\\t\" ||\n\tchar === \"\\n\" ||\n\tchar === \"\\r\" ||\n\tchar === \"\\f\";\n\n/**\n * Finds the `>` that ends a tag, or -1 when the tag never ends. A quote starts a value only straight after `=`, as in\n * HTML, and only when the same quote appears again later, so an unclosed quote can't hide the rest of the text.\n */\nconst tagEnd = (\n\thtml: string,\n\tfrom: number,\n\tlastDouble: number,\n\tlastSingle: number,\n): number => {\n\tlet quote = \"\";\n\tlet afterEquals = false;\n\tfor (let i = from; i < html.length; i++) {\n\t\tconst char = html[i];\n\t\tif (quote) {\n\t\t\tif (char === quote) quote = \"\";\n\t\t} else if (char === \">\") return i;\n\t\telse if (char === \"=\") afterEquals = true;\n\t\telse if (\n\t\t\tafterEquals &&\n\t\t\t((char === '\"' && i < lastDouble) || (char === \"'\" && i < lastSingle))\n\t\t) {\n\t\t\tquote = char;\n\t\t\tafterEquals = false;\n\t\t} else if (!isSpace(char)) afterEquals = false;\n\t}\n\treturn -1;\n};\n\n/**\n * Splits HTML into tags and comments, given to `onTag`, and the text between them, given to `onText`, in one linear\n * pass. A `<` that doesn't start a tag that closes is text.\n */\nexport const scanHtml = (\n\thtml: string,\n\tonText: (text: string) => void,\n\tonTag: (tag: string) => void,\n): void => {\n\tconst lastDouble = html.lastIndexOf('\"');\n\tconst lastSingle = html.lastIndexOf(\"'\");\n\tlet index = 0;\n\tlet textStart = 0;\n\tlet commentsCanClose = true;\n\tlet tagsCanClose = true;\n\tconst tag = (open: number, end: number) => {\n\t\tif (textStart < open) onText(html.slice(textStart, open));\n\t\tonTag(html.slice(open, end));\n\t\tindex = textStart = end;\n\t};\n\tfor (;;) {\n\t\tconst open = html.indexOf(\"<\", index);\n\t\tif (open === -1) break;\n\t\tif (commentsCanClose && html.startsWith(\"<!--\", open)) {\n\t\t\t// `<!-->` and `<!--->` are empty comments.\n\t\t\tconst close = html.startsWith(\"<!-->\", open)\n\t\t\t\t? open + 2\n\t\t\t\t: html.startsWith(\"<!--->\", open)\n\t\t\t\t\t? open + 3\n\t\t\t\t\t: html.indexOf(\"-->\", open + 4);\n\t\t\tif (close !== -1) {\n\t\t\t\ttag(open, close + 3);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// No later comment can close either.\n\t\t\tcommentsCanClose = false;\n\t\t}\n\t\tlet nameStart = open + 1;\n\t\tconst marker = html[nameStart];\n\t\tif (marker === \"!\" || marker === \"?\" || marker === \"/\") nameStart++;\n\t\tif (tagsCanClose && isAsciiLetter(html.charCodeAt(nameStart))) {\n\t\t\tconst close = tagEnd(html, nameStart, lastDouble, lastSingle);\n\t\t\tif (close !== -1) {\n\t\t\t\ttag(open, close + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttagsCanClose = false;\n\t\t}\n\t\tindex = open + 1;\n\t}\n\tif (textStart < html.length) onText(html.slice(textStart));\n};\n\n/** A piece of markup that string filters keep as it is: a tag, a comment, or an entity they don't decode. */\nexport class Kept {\n\tconstructor(readonly html: string) {}\n}\n\n/** Markup's text, decoded, between the pieces string filters keep. Plain text is one string. */\nexport type Pieces = (string | Kept)[];\n\n/** Strategies whose markup is HTML, with tags and entities. The others only use escape sequences. */\nexport const isHtmlStrategy = (strategy: EscapeStrategy): boolean =>\n\tstrategy === \"html\" || strategy === \"attr\";\n\nconst ENTITY =\n\t/&(?:#(\\d{1,7})|#[xX]([\\da-fA-F]{1,6})|([a-zA-Z][\\da-zA-Z]{0,31}));/g;\n\n/** The named entities the escapers write. Other names, such as `&nbsp;`, are kept as they are. */\nconst NAMED_ENTITIES: Record<string, string> = {\n\tamp: \"&\",\n\tlt: \"<\",\n\tgt: \">\",\n\tquot: '\"',\n\tapos: \"'\",\n};\n\nconst pushText = (pieces: Pieces, text: string) => {\n\tif (text === \"\") return;\n\tconst last = pieces.length - 1;\n\tif (typeof pieces[last] === \"string\") pieces[last] += text;\n\telse pieces.push(text);\n};\n\n/** Decodes entities in HTML text into `pieces`, keeping entities it doesn't know. */\nconst decodeEntities = (text: string, pieces: Pieces) => {\n\tlet last = 0;\n\tfor (const match of text.matchAll(ENTITY)) {\n\t\tconst [entity, decimal, hex, name] = match;\n\t\tconst code =\n\t\t\tdecimal !== undefined\n\t\t\t\t? Number(decimal)\n\t\t\t\t: hex !== undefined\n\t\t\t\t\t? Number.parseInt(hex, 16)\n\t\t\t\t\t: -1;\n\t\tconst char =\n\t\t\tname !== undefined\n\t\t\t\t? NAMED_ENTITIES[name]\n\t\t\t\t: code > 0 && code <= 0x10ffff && (code < 0xd800 || code > 0xdfff)\n\t\t\t\t\t? String.fromCodePoint(code)\n\t\t\t\t\t: undefined;\n\t\tpushText(pieces, text.slice(last, match.index));\n\t\tif (char === undefined) pieces.push(new Kept(entity));\n\t\telse pushText(pieces, char);\n\t\tlast = match.index + entity.length;\n\t}\n\tpushText(pieces, text.slice(last));\n};\n\nconst JS_ESCAPES: Record<string, string> = {\n\tn: \"\\n\",\n\tr: \"\\r\",\n\tt: \"\\t\",\n\tb: \"\\b\",\n\tf: \"\\f\",\n\tv: \"\\v\",\n\t\"0\": \"\\0\",\n};\n\n/** Decodes the escape sequences of JavaScript, CSS or URL markup into its text. */\nconst decodeSequences = (text: string, strategy: EscapeStrategy): string => {\n\tswitch (strategy) {\n\t\tcase \"js\":\n\t\t\treturn text.replace(\n\t\t\t\t/\\\\(?:u([\\da-fA-F]{4})|x([\\da-fA-F]{2})|(.))/gs,\n\t\t\t\t(_match, unit?: string, byte?: string, char?: string) =>\n\t\t\t\t\tunit !== undefined || byte !== undefined\n\t\t\t\t\t\t? String.fromCharCode(Number.parseInt(unit ?? byte ?? \"\", 16))\n\t\t\t\t\t\t: (JS_ESCAPES[char ?? \"\"] ?? char ?? \"\"),\n\t\t\t);\n\t\tcase \"css\":\n\t\t\treturn text.replace(\n\t\t\t\t/\\\\(?:([\\da-fA-F]{1,6}) ?|(.))/gs,\n\t\t\t\t(_match, hex?: string, char?: string) => {\n\t\t\t\t\tconst code = hex === undefined ? -1 : Number.parseInt(hex, 16);\n\t\t\t\t\treturn hex === undefined\n\t\t\t\t\t\t? (char ?? \"\")\n\t\t\t\t\t\t: code > 0 && code <= 0x10ffff\n\t\t\t\t\t\t\t? String.fromCodePoint(code)\n\t\t\t\t\t\t\t: \"�\";\n\t\t\t\t},\n\t\t\t);\n\t\tdefault:\n\t\t\treturn text.replace(/(?:%[\\da-fA-F]{2})+/g, (run) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn decodeURIComponent(run);\n\t\t\t\t} catch {\n\t\t\t\t\treturn run;\n\t\t\t\t}\n\t\t\t});\n\t}\n};\n\n/**\n * Splits markup into its decoded text and the pieces string filters keep as they are. HTML markup keeps its tags,\n * comments and the entities the escapers don't write. Other markup is all text.\n */\nexport const toPieces = (markup: Markup): Pieces => {\n\tif (!isHtmlStrategy(markup.strategy)) {\n\t\treturn [decodeSequences(markup.value, markup.strategy)];\n\t}\n\tconst pieces: Pieces = [];\n\tscanHtml(\n\t\tmarkup.value,\n\t\t(text) => decodeEntities(text, pieces),\n\t\t(tag) => pieces.push(new Kept(tag)),\n\t);\n\treturn pieces;\n};\n\n/** Joins pieces back into markup, escaping the text with the markup's strategy. */\nexport const fromPieces = (\n\trun: Run,\n\tpieces: Pieces,\n\tstrategy: EscapeStrategy,\n): Markup => {\n\tlet html = \"\";\n\tfor (const piece of pieces) {\n\t\thtml = checkLength(\n\t\t\trun,\n\t\t\thtml +\n\t\t\t\t(typeof piece === \"string\" ? escapeWith(piece, strategy) : piece.html),\n\t\t);\n\t}\n\treturn new Markup(html, strategy);\n};\n\n/**\n * A text argument a string filter inserts into markup, such as `replace`'s replacement: markup of the same strategy\n * is kept as it is, and anything else is text, escaped when the pieces are joined.\n */\nexport const insertedPiece = (\n\tvalue: unknown,\n\tstrategy: EscapeStrategy,\n\twhat: string,\n): string | Kept =>\n\tvalue instanceof Markup && value.strategy === strategy\n\t\t? new Kept(value.value)\n\t\t: value instanceof Markup\n\t\t\t? markupText(value)\n\t\t\t: toStringArgument(value, what);\n\n/** Markup's decoded text, with the pieces string filters keep left as they are. */\nexport const markupText = (markup: Markup): string =>\n\ttoPieces(markup)\n\t\t.map((piece) => (typeof piece === \"string\" ? piece : piece.html))\n\t\t.join(\"\");\n","import { issue } from \"../errors.js\";\nimport {\n\tBLOCKED_NAMES,\n\tcompare,\n\tequals,\n\tisPlainObject,\n\ttoNumber,\n\ttoStr,\n\ttypeName,\n\tunwrap,\n} from \"./values.js\";\n\n/** Builds the inclusive array of numbers for `a..b` and `range()`, refusing arrays longer than `limit`. */\nexport const buildRange = (\n\tstart: unknown,\n\tend: unknown,\n\tstepValue: unknown,\n\tlimit: number,\n): number[] => {\n\tconst from = toNumber(start, \"range\");\n\tconst to = toNumber(end, \"range\");\n\tconst step =\n\t\tstepValue === undefined || stepValue === null\n\t\t\t? to < from\n\t\t\t\t? -1\n\t\t\t\t: 1\n\t\t\t: toNumber(stepValue, \"range\");\n\tif (step === 0 || !Number.isFinite(step)) {\n\t\treturn issue(\"invalid-argument\", \"Range step must be a non-zero number\");\n\t}\n\tif (!Number.isFinite(from) || !Number.isFinite(to)) {\n\t\treturn issue(\"invalid-argument\", \"Range ends must be finite numbers\");\n\t}\n\tconst steps = (to - from) / step;\n\tif (steps < 0) return [];\n\tconst exact =\n\t\tNumber.isInteger(from) && Number.isInteger(to) && Number.isInteger(step);\n\t// A little slack for fractions, so a step such as 0.1 still reaches the end despite rounding.\n\tconst length =\n\t\tMath.floor(exact ? steps : steps + Math.max(1, steps) * 1e-12) + 1;\n\tif (length > limit) {\n\t\treturn issue(\n\t\t\t\"limit-steps\",\n\t\t\t`Range of ${length} items is larger than the step limit`,\n\t\t);\n\t}\n\t// oxlint-disable-next-line unicorn/no-new-array -- preallocates a known length on the hot path\n\tconst result = new Array<number>(length);\n\tif (exact) {\n\t\tfor (let i = 0; i < length; i++) result[i] = from + i * step;\n\t} else {\n\t\t// Rounded to 15 significant digits, so 3 steps of 0.1 are 0.3, not 0.30000000000000004.\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tresult[i] = Number((from + i * step).toPrecision(15));\n\t\t}\n\t}\n\treturn result;\n};\n\n/** `a..b`: both ends must be integers. */\nexport const rangeOperator = (\n\tleft: unknown,\n\tright: unknown,\n\tlimit: number,\n): number[] => {\n\tif (!Number.isInteger(left) || !Number.isInteger(right)) {\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t`\"..\" needs integers, but got ${typeName(left)} and ${typeName(right)}`,\n\t\t);\n\t}\n\treturn buildRange(left, right, undefined, limit);\n};\n\n/**\n * `a in b`. `charge` is called with the number of items before an array or set is searched, so templates can't\n * search large lists over and over for free.\n */\nexport const contains = (\n\tneedle: unknown,\n\thaystack: unknown,\n\tcharge: (count: number) => void = () => {},\n): boolean => {\n\tconst target = unwrap(haystack);\n\tif (Array.isArray(target)) {\n\t\tcharge(target.length);\n\t\treturn target.some((item) => equals(item, needle));\n\t}\n\tif (target instanceof Set) {\n\t\tif (target.has(needle)) return true;\n\t\tcharge(target.size);\n\t\tfor (const item of target) if (equals(item, needle)) return true;\n\t\treturn false;\n\t}\n\tif (typeof target === \"string\") {\n\t\treturn target.includes(stringOperand(needle, \"in\"));\n\t}\n\tif (isPlainObject(target)) {\n\t\tconst key = unwrap(needle);\n\t\tif (typeof key !== \"string\" && typeof key !== \"number\") return false;\n\t\tconst name = String(key);\n\t\treturn !BLOCKED_NAMES.has(name) && Object.hasOwn(target, name);\n\t}\n\tif (target instanceof Map) {\n\t\tconst key = unwrap(needle);\n\t\treturn (\n\t\t\t!(typeof key === \"string\" && BLOCKED_NAMES.has(key)) && target.has(key)\n\t\t);\n\t}\n\treturn issue(\n\t\t\"type-error\",\n\t\t`\"in\" needs an array, set, string or hash on its right, but got a ${typeName(target)}`,\n\t);\n};\n\nconst stringOperand = (value: unknown, operator: string): string => {\n\tconst unwrapped = unwrap(value);\n\tif (typeof unwrapped === \"string\") return unwrapped;\n\treturn issue(\n\t\t\"type-error\",\n\t\t`\"${operator}\" needs strings, but got a ${typeName(unwrapped)}`,\n\t);\n};\n\n/** Applies a binary operator that has no short-circuit behaviour. */\nexport const binaryOperation = (\n\toperator: string,\n\tleft: unknown,\n\tright: unknown,\n): unknown => {\n\tswitch (operator) {\n\t\tcase \"==\":\n\t\t\treturn equals(left, right);\n\t\tcase \"!=\":\n\t\t\treturn !equals(left, right);\n\t\tcase \"<\":\n\t\t\treturn compare(left, right) < 0;\n\t\tcase \">\":\n\t\t\treturn compare(left, right) > 0;\n\t\tcase \"<=\":\n\t\t\treturn compare(left, right) <= 0;\n\t\tcase \">=\":\n\t\t\treturn compare(left, right) >= 0;\n\t\tcase \"in\":\n\t\t\treturn contains(left, right);\n\t\tcase \"not in\":\n\t\t\treturn !contains(left, right);\n\t\tcase \"starts with\":\n\t\t\treturn stringOperand(left, operator).startsWith(\n\t\t\t\tstringOperand(right, operator),\n\t\t\t);\n\t\tcase \"ends with\":\n\t\t\treturn stringOperand(left, operator).endsWith(\n\t\t\t\tstringOperand(right, operator),\n\t\t\t);\n\t\tcase \"~\":\n\t\t\treturn toStr(left) + toStr(right);\n\t\tcase \"+\":\n\t\t\treturn toNumber(left, operator) + toNumber(right, operator);\n\t\tcase \"-\":\n\t\t\treturn toNumber(left, operator) - toNumber(right, operator);\n\t\tcase \"*\":\n\t\t\treturn toNumber(left, operator) * toNumber(right, operator);\n\t\tcase \"/\":\n\t\t\treturn toNumber(left, operator) / toNumber(right, operator);\n\t\tcase \"//\":\n\t\t\treturn Math.floor(toNumber(left, operator) / toNumber(right, operator));\n\t\tcase \"%\":\n\t\t\treturn toNumber(left, operator) % toNumber(right, operator);\n\t\tcase \"**\":\n\t\t\treturn toNumber(left, operator) ** toNumber(right, operator);\n\t\tdefault:\n\t\t\treturn issue(\"invalid-operator\", `Unknown operator \"${operator}\"`);\n\t}\n};\n\n/** Fast paths for the most common operators, so the hot loop avoids the switch. */\nexport const operatorFunction = (\n\toperator: string,\n): ((left: unknown, right: unknown) => unknown) => {\n\tswitch (operator) {\n\t\tcase \"==\":\n\t\t\treturn equals;\n\t\tcase \"!=\":\n\t\t\treturn (left, right) => !equals(left, right);\n\t\tcase \"~\":\n\t\t\treturn (left, right) =>\n\t\t\t\t(typeof left === \"string\" ? left : toStr(left)) +\n\t\t\t\t(typeof right === \"string\" ? right : toStr(right));\n\t\tcase \"+\":\n\t\t\treturn (left, right) =>\n\t\t\t\ttypeof left === \"number\" && typeof right === \"number\"\n\t\t\t\t\t? left + right\n\t\t\t\t\t: toNumber(left, \"+\") + toNumber(right, \"+\");\n\t\tdefault:\n\t\t\treturn (left, right) => binaryOperation(operator, left, right);\n\t}\n};\n","import { issue } from \"../errors.js\";\nimport { escapeHtml } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport { buildRange } from \"../runtime/operators.js\";\nimport { checkLength, consume } from \"../runtime/render.js\";\nimport type { CallableEntry, Run } from \"../runtime/types.js\";\nimport {\n\tcompare,\n\tisEmpty,\n\tisHashLike,\n\tisPlainObject,\n\ttoStr,\n\ttypeName,\n\tunwrap,\n} from \"../runtime/values.js\";\nimport {\n\tentriesOf,\n\tintegerArgument,\n\tlistOf,\n\tmapContents,\n\ttoDate,\n\ttoPlainData,\n} from \"./helpers.js\";\n\ntype BuiltinEntry = Extract<CallableEntry, { kind: \"builtin\" }>;\n\nconst define = (\n\tcall: BuiltinEntry[\"call\"],\n\tparams: readonly string[] = [],\n): BuiltinEntry => ({ kind: \"builtin\", call, params });\n\n/** Attribute names HTML allows: no spaces, quotes, `>`, `/`, `=` or control characters. */\nconst ATTRIBUTE_NAME = /^[^\\s\"'>/=\\p{Cc}]+$/u;\n\n/** `max` and `min`, of their arguments or of the items of one list or the values of one hash. Charges for the items compared. */\nconst extremes = (\n\trun: Run,\n\tvalues: unknown[],\n\twhat: string,\n\tpick: (order: number) => boolean,\n): unknown => {\n\tconst [only] = values;\n\tconst items =\n\t\tvalues.length === 1 &&\n\t\t(Array.isArray(only) || only instanceof Set || isHashLike(only))\n\t\t\t? entriesOf(run, only, what).values\n\t\t\t: values;\n\tif (items === values) consume(run, items.length);\n\tif (items.length === 0) return null;\n\tlet best = items[0];\n\tfor (let i = 1; i < items.length; i++) {\n\t\tconst item = items[i];\n\t\tif (pick(compare(item, best))) best = item;\n\t}\n\treturn best ?? null;\n};\n\n/**\n * Turns one `attrs` value into its attribute text, or null to leave the attribute out. Lists are charged per item,\n * and refused before they are joined if the text would pass `maxOutputLength`.\n */\nconst attributeValue = (run: Run, value: unknown): string | null => {\n\tif (value === null || value === undefined || value === false) return null;\n\tif (Array.isArray(value)) {\n\t\tconsume(run, value.length);\n\t\tconst parts = value\n\t\t\t.filter(\n\t\t\t\t(item) =>\n\t\t\t\t\titem !== null && item !== undefined && item !== false && item !== \"\",\n\t\t\t)\n\t\t\t.map((item) => attributeText(item));\n\t\tif (parts.length === 0) return null;\n\t\tlet length = parts.length - 1;\n\t\tfor (const part of parts) length += part.length;\n\t\tif (length > run.state.maxSize) {\n\t\t\treturn issue(\n\t\t\t\t\"limit-output\",\n\t\t\t\t`\"attrs\" would build a string longer than the output limit of ${run.state.maxSize}`,\n\t\t\t);\n\t\t}\n\t\treturn parts.join(\" \");\n\t}\n\treturn attributeText(value);\n};\n\n/** HTML markup is kept, except for `\"`, which would end the quoted attribute. */\nconst attributeText = (value: unknown): string =>\n\tvalue instanceof Markup && value.strategy === \"html\"\n\t\t? value.value.replaceAll('\"', \"&quot;\")\n\t\t: escapeHtml(toStr(value));\n\nexport const builtinFunctions: Record<string, BuiltinEntry> = {\n\trange: define(\n\t\t(run, start, end, step) => {\n\t\t\tconst items = buildRange(start, end, step, run.state.maxSteps);\n\t\t\tconsume(run, items.length);\n\t\t\treturn items;\n\t\t},\n\t\t[\"start\", \"end\", \"step\"],\n\t),\n\tmax: define((run, ...values) =>\n\t\textremes(run, values, \"max\", (order) => order > 0),\n\t),\n\tmin: define((run, ...values) =>\n\t\textremes(run, values, \"min\", (order) => order < 0),\n\t),\n\tcycle: define(\n\t\t(run, values, position) => {\n\t\t\tconst items = listOf(run, values, \"cycle\");\n\t\t\tif (items.length === 0) return null;\n\t\t\tconst index = integerArgument(position, '\"cycle\" position');\n\t\t\treturn items[((index % items.length) + items.length) % items.length];\n\t\t},\n\t\t[\"values\", \"position\"],\n\t),\n\tdate: define(\n\t\t(_run, ...args) => {\n\t\t\t// Only a missing argument means now. A null date stays null, so a missing field never prints as today.\n\t\t\tif (args.length === 0) return new Date();\n\t\t\tconst value = args[0];\n\t\t\treturn value === null || value === undefined\n\t\t\t\t? null\n\t\t\t\t: toDate(value, '\"date\"');\n\t\t},\n\t\t[\"value\"],\n\t),\n\tattrs: define(\n\t\t(run, attributes) => {\n\t\t\tconst target = unwrap(attributes);\n\t\t\tif (target === null || target === undefined)\n\t\t\t\treturn new Markup(\"\", \"html\");\n\t\t\tif (!isPlainObject(target) && !(target instanceof Map)) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"type-error\",\n\t\t\t\t\t`\"attrs\" needs a hash, but got a ${typeName(target)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { values, keys } = entriesOf(run, target, \"attrs\");\n\t\t\tlet html = \"\";\n\t\t\tkeys.forEach((key, index) => {\n\t\t\t\tconst name = String(key);\n\t\t\t\tif (!ATTRIBUTE_NAME.test(name)) {\n\t\t\t\t\tissue(\"invalid-argument\", `\"${name}\" is not a valid attribute name`);\n\t\t\t\t}\n\t\t\t\tconst value = values[index];\n\t\t\t\tif (value === true) {\n\t\t\t\t\thtml += ` ${name}`;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst text = attributeValue(run, value);\n\t\t\t\tif (text === null) return;\n\t\t\t\tif (html.length + name.length + text.length + 4 > run.state.maxSize) {\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"limit-output\",\n\t\t\t\t\t\t`\"attrs\" would build a string longer than the output limit of ${run.state.maxSize}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\thtml += ` ${name}=\"${text}\"`;\n\t\t\t});\n\t\t\treturn new Markup(html, \"html\");\n\t\t},\n\t\t[\"attributes\"],\n\t),\n\tdump: define((run, ...values) => {\n\t\tif (!run.state.env.debug) return new Markup(\"\", \"html\");\n\t\tconst data = values.map((value) =>\n\t\t\ttoPlainData(value, () => \"[Circular]\", {\n\t\t\t\twhat: \"dump\",\n\t\t\t\tcharge: (count) => consume(run, count),\n\t\t\t\tmaxLength: run.state.maxSize,\n\t\t\t\tindent: 2,\n\t\t\t}),\n\t\t);\n\t\tconst text = checkLength(\n\t\t\trun,\n\t\t\tJSON.stringify(data.length === 1 ? data[0] : data, null, 2) ?? \"null\",\n\t\t);\n\t\treturn new Markup(\n\t\t\tcheckLength(run, `<pre class=\"kiln-dump\">${escapeHtml(text)}</pre>`),\n\t\t\t\"html\",\n\t\t);\n\t}),\n};\n\nexport const builtinTests: Record<string, BuiltinEntry> = {\n\tnull: define((_run, value) => value === null || value === undefined),\n\t// A `Map` is empty when a loop would see no entries in it.\n\tempty: define((_run, value) =>\n\t\tvalue instanceof Map\n\t\t\t? mapContents(value).keys.length === 0\n\t\t\t: isEmpty(value),\n\t),\n\teven: define(\n\t\t(_run, value) =>\n\t\t\ttypeof value === \"number\" && Number.isInteger(value) && value % 2 === 0,\n\t),\n\todd: define(\n\t\t(_run, value) =>\n\t\t\ttypeof value === \"number\" &&\n\t\t\tNumber.isInteger(value) &&\n\t\t\tMath.abs(value % 2) === 1,\n\t),\n\titerable: define((_run, value) => {\n\t\tif (value === null || value === undefined || typeof value !== \"object\")\n\t\t\treturn false;\n\t\tif (value instanceof Markup) return false;\n\t\treturn (\n\t\t\tArray.isArray(value) ||\n\t\t\tisPlainObject(value) ||\n\t\t\ttypeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] ===\n\t\t\t\t\"function\"\n\t\t);\n\t}),\n\t\"divisible by\": define(\n\t\t(_run, value, divisor) => {\n\t\t\tif (typeof value !== \"number\" || typeof divisor !== \"number\") {\n\t\t\t\treturn issue(\"type-error\", '\"divisible by\" needs numbers');\n\t\t\t}\n\t\t\tif (divisor === 0)\n\t\t\t\treturn issue(\n\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t'\"divisible by\" cannot divide by zero',\n\t\t\t\t);\n\t\t\treturn value % divisor === 0;\n\t\t},\n\t\t[\"divisor\"],\n\t),\n};\n","import { contentStart } from \"./lexer/lexer.js\";\n\n/** A range of a template's source, as zero-based offsets. `end` is exclusive. */\nexport type Span = { start: number; end: number };\n\nexport type Position = {\n\t/** Zero-based offset into the source. */\n\toffset: number;\n\t/** One-based. */\n\tline: number;\n\t/** One-based, counted in UTF-16 code units. */\n\tcolumn: number;\n};\n\n/**\n * A template's text and resolved name.\n *\n * The line index is built on first use, because only errors and tooling need lines and columns. A byte order mark at the\n * start is not counted in columns or shown in frames, as editors hide it, but offsets still count it.\n */\nexport class Source {\n\t#lineStarts: number[] | undefined;\n\n\tconstructor(\n\t\treadonly name: string,\n\t\treadonly text: string,\n\t) {}\n\n\t/** Converts an offset into a line and column. */\n\tposition(offset: number): Position {\n\t\tconst starts = this.#getLineStarts();\n\t\tlet low = 0;\n\t\tlet high = starts.length - 1;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high + 1) >> 1;\n\t\t\tif ((starts[middle] ?? 0) <= offset) low = middle;\n\t\t\telse high = middle - 1;\n\t\t}\n\t\tconst bom = low === 0 && offset > 0 ? contentStart(this.text) : 0;\n\t\treturn {\n\t\t\toffset,\n\t\t\tline: low + 1,\n\t\t\tcolumn: offset - (starts[low] ?? 0) - bom + 1,\n\t\t};\n\t}\n\n\t/**\n\t * Renders a few lines around a span, with a marker under it.\n\t *\n\t * ```text\n\t * 3 | {% block content %}\n\t * > 4 | <h1>{{ titel }}</h1>\n\t * | ^^^^^\n\t * ```\n\t */\n\tframe(span: Span, context = 1): string {\n\t\tconst starts = this.#getLineStarts();\n\t\tconst start = this.position(span.start);\n\t\tconst firstLine = Math.max(1, start.line - context);\n\t\tconst lastLine = Math.min(starts.length, start.line + context);\n\t\tconst gutter = String(lastLine).length;\n\t\tconst lines: string[] = [];\n\n\t\tfor (let line = firstLine; line <= lastLine; line++) {\n\t\t\tconst text = this.#lineText(line);\n\t\t\tconst number = String(line).padStart(gutter);\n\t\t\tconst marker = line === start.line ? \">\" : \" \";\n\t\t\tlines.push(`${marker} ${number} | ${text}`);\n\n\t\t\tif (line === start.line) {\n\t\t\t\tconst lineEnd = this.#lineStart(line) + text.length;\n\t\t\t\tconst width = Math.max(1, Math.min(span.end, lineEnd) - span.start);\n\t\t\t\t// Keep tabs so the marker lines up with tab-indented source.\n\t\t\t\tconst indent = text.slice(0, start.column - 1).replace(/[^\\t]/g, \" \");\n\t\t\t\tlines.push(` ${\" \".repeat(gutter)} | ${indent}${\"^\".repeat(width)}`);\n\t\t\t}\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\t#lineText(line: number): string {\n\t\tconst starts = this.#getLineStarts();\n\t\tconst next = starts[line];\n\t\tconst end = next === undefined ? this.text.length : next - 1;\n\t\treturn this.text.slice(this.#lineStart(line), end).replace(/\\r$/, \"\");\n\t}\n\n\t/** Where a one-based line's text starts, after any byte order mark on the first line. */\n\t#lineStart(line: number): number {\n\t\tconst start = this.#getLineStarts()[line - 1] ?? 0;\n\t\treturn line === 1 ? start + contentStart(this.text) : start;\n\t}\n\n\t#getLineStarts(): number[] {\n\t\tif (this.#lineStarts) return this.#lineStarts;\n\t\tconst starts = [0];\n\t\tconst text = this.text;\n\t\tfor (let i = 0; i < text.length; i++) {\n\t\t\tif (text.charCodeAt(i) === 10) starts.push(i + 1);\n\t\t}\n\t\tthis.#lineStarts = starts;\n\t\treturn starts;\n\t}\n}\n"],"mappings":";;;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ACnB,OAAO;CACR;AACD"}
package/dist/syntax.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as HashEntry, c as PropType, d as Statement, f as TemplateNode, g as Span, i as Expression, l as ShapeKey, n as BinaryOperator, o as Param, s as PropParam, t as Argument, u as Spread } from "./ast-1akLiy-A.js";
1
+ import { a as HashEntry, c as PropType, d as Statement, f as TemplateNode, g as Span, i as Expression, l as ShapeKey, n as BinaryOperator, o as Param, s as PropParam, t as Argument, u as Spread } from "./ast-DDhHuwaY.js";
2
2
  //#region src/lexer/lexer.d.ts
3
3
  type LexProblem = {
4
4
  code: string;
package/dist/syntax.js CHANGED
@@ -1 +1 @@
1
- export { t as parse } from "./parser-BU5dThuk.js";
1
+ export { t as parse } from "./parser-isboTef0.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucidkiln/core",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A fast, safe, async-aware template language for building websites. Runs on Node and Cloudflare Workers.",
5
5
  "homepage": "https://kilnlang.com",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"ast-1akLiy-A.d.ts","names":[],"sources":["../src/source.ts","../src/parser/ast.ts"],"mappings":";;KAGY;EAAS;EAAe;;KAExB;;EAEX;;EAEA;;EAEA;;;;;;;;cASY;;WAIF;WACA;EAFV,YACU,cACA;;EAIV,SAAS,iBAAiB;;;;;;;;;;EA0B1B,MAAM,MAAM,MAAM;;;;KCrDP;KAEA;KAyBA;EAAW;EAAgB,OAAO;EAAY,MAAM;;KAEpD;EACP;EAAoB,OAAO;EAAY,MAAM;;EAC7C;EAAe;EAAc,OAAO;EAAY,MAAM;IACxD;KAES;EACP;EAAkB,KAAK;EAAY,OAAO;EAAY,MAAM;IAC9D;KAES;EAET;EACA;EACA,MAAM;;EAEJ;EAAc;EAAc,MAAM;;;;EAElC;EAAuB,OAAO;EAAc,MAAM;;EAClD;EAAe,WAAW,aAAa;EAAW,MAAM;;EAC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F;EACD;EAAc;EAAc,MAAM;EAAa,MAAM;IAAS;;;;;;;EAOjE;EACA,UAAU;EACV,MAAM;EACN,MAAM;EACN;IAAY;IAAuB;;EACnC,MAAM;IACF;EAEJ;EACA;EACA,QAAQ;EACR,MAAM;EACN,MAAM;;EAEJ;EAAgB;EAAkB;EAAe,MAAM;;EAEzD;EACA;EACA;IAAS;IAAc;IAAe,MAAM;;EAC5C,MAAM;;EAEJ;EAAc,OAAO;EAAY,MAAM;EAAa,MAAM;;;;EAEzD;EAAgB;EAAc,MAAM;IAAS;;;EAE9C;EAAe,MAAM;;;;EAGvB;EACA;EACA;EACA,MAAM;EACN,MAAM;;;;EAIN;EACA,KAAK;EACL,SAAS;EACT,MAAM;EACN,MAAM;;EAEJ;EAAe,SAAS;EAAc,MAAM;EAAa,MAAM;;EAEjE;EACA,UAAU;EACV,MAAM;EACN,MAAM;;KAGG;EAAiB;EAAkB,MAAM;EAAa,MAAM;;;cAoB3D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment-DkfrPazl.d.ts","names":[],"sources":["../src/errors.ts","../src/runtime/islands.ts","../src/runtime/types.ts","../src/analyzer.ts","../src/compiler/precompiled.ts","../src/html/options.ts","../src/environment.ts"],"mappings":";;KAEY;;EAEX;EACA;EACA;;EAEA;EACA,OAAO;EACP,KAAK;;KAGM;EACX;EACA;EACA;;;;;cAyBY,wBAAwB;EAC3B;WACA,aAAa;EAEtB,YAAY,aAAa,cAAc,QAAQ;;;;;cAqBnC,wBAAwB;;EAC3B;WACA;WACA;WACA;WACA;;WAEA;;WAEA,eAAe;;;;EAMxB,YACC,cACA,gBACA,QAAQ,iBACR,OAAM,MACN;IAAW;IAAe;;;MA8BvB;;;;;KCnFO,+CAKT;GACG,cAAc;;;KAGR;EACX;EACA,OAAO,eAAe;;;KAIX,iBAAiB,eAAe;;KAGhC;WACF;;WAEA;;WAEA;;WAEA,UAAU;;;;;;;;;;;cAYP,iBAAY,KAAA;EAIxB;EACA;MACG;;KAQQ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