@torpor/view 0.4.14 → 0.4.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"compile.mjs","names":["#mapped","#text","i","#space","start","fragments: Fragment[]","spans: SourceSpan[]","offsets: number[]","lengths: number[]","props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets: number[];\n\t\t\tlengths: number[];\n\t\t}[]","runs: string[]","bindingRuns: string[]","forVarNames: string[]","maybeAppend","buildElementAttributes","props: { name: string; value: string; span: SourceSpan }[]","runs: string[]","offsets: number[]","lengths: number[]","importsMap: Record<string, string>","importsMap","status: BuildStatus","selectors: string[]","props: { name: string; value: string }[]","voidTags: string[]","voidTags","attributes: string[]","importsMap: Record<string, string>","status: BuildServerStatus","map: SourceMapping[]","space: TextNode","attributes: Attribute[]","value: string | undefined","spans: SourceSpan[]","text: TextNode","voidTags","ifGroup: ControlNode","forGroup: ControlNode","awaitGroup: ControlNode","replaceGroup: ControlNode","htmlGroup: ControlNode","text: TextNode","hash","styleStatus: ParseStatus","block: StyleBlock","selectors: string[]","status: ParseStatus","current: TemplateComponent","start","props: string[]","contexts: string[]"],"sources":["../src/compile/utils/endOfTemplateString.ts","../src/compile/utils/Builder.ts","../src/compile/build/client/addMappedText.ts","../src/compile/build/client/addPopDevBoundary.ts","../src/compile/build/client/addPushDevBoundary.ts","../src/compile/types/comments.ts","../src/compile/utils/isReactive.ts","../src/compile/utils/trimQuotes.ts","../src/compile/build/client/buildFragmentText.ts","../src/compile/utils/isSpecialNode.ts","../src/compile/build/utils/nextVarName.ts","../src/compile/build/client/addMappedTextWithOffsets.ts","../src/compile/build/client/buildAddFragment.ts","../src/compile/parse/utils/isSpaceChar.ts","../src/compile/parse/utils/isSpace.ts","../src/compile/utils/isControlNode.ts","../src/compile/utils/isElementNode.ts","../src/compile/utils/isTextNode.ts","../src/compile/build/client/buildFragment.ts","../src/compile/build/client/replaceForVarNames.ts","../src/compile/build/client/buildRun.ts","../src/compile/utils/endOfString.ts","../src/compile/build/client/getAttributeOffsets.ts","../src/compile/build/client/buildComponentNode.ts","../src/compile/utils/trimMatched.ts","../src/compile/build/client/buildAwaitNode.ts","../src/compile/build/client/buildForNode.ts","../src/compile/build/client/buildHtmlNode.ts","../src/compile/build/client/buildIfNode.ts","../src/compile/build/client/buildReplaceNode.ts","../src/compile/build/client/buildScriptNode.ts","../src/compile/build/client/buildSwitchNode.ts","../src/compile/build/client/buildControlNode.ts","../src/compile/utils/trimEnd.ts","../src/compile/build/client/buildMount.ts","../src/compile/build/client/stashRun.ts","../src/compile/build/client/stashRunWithOffsets.ts","../src/compile/build/client/buildElementNode.ts","../src/compile/build/client/buildRootNode.ts","../src/compile/build/client/buildSlotNode.ts","../src/compile/build/client/buildSpecialNode.ts","../src/compile/build/client/buildTextNode.ts","../src/compile/build/client/buildNode.ts","../src/compile/build/client/buildCode.ts","../src/compile/build/client/buildStyles.ts","../src/compile/build/server/buildServerComponentNode.ts","../src/compile/build/server/buildServerAwaitNode.ts","../src/compile/build/server/buildServerForNode.ts","../src/compile/build/server/buildServerHtmlNode.ts","../src/compile/build/server/buildServerIfNode.ts","../src/compile/build/server/buildServerReplaceNode.ts","../src/compile/build/server/buildServerScriptNode.ts","../src/compile/build/server/buildServerSwitchNode.ts","../src/compile/build/server/buildServerControlNode.ts","../src/compile/utils/voidTags.ts","../src/compile/build/server/buildServerElementNode.ts","../src/compile/build/server/buildServerRootNode.ts","../src/compile/build/server/buildServerSlotNode.ts","../src/compile/build/server/buildServerSpecialNode.ts","../src/compile/build/server/buildServerTextNode.ts","../src/compile/build/server/buildServerNode.ts","../src/compile/build/server/buildServerCode.ts","../src/compile/build.ts","../src/compile/buildType.ts","../src/compile/utils/isSpaceNode.ts","../src/compile/parse/utils/accept.ts","../src/compile/parse/parseInlineScript.ts","../src/compile/utils/trimStart.ts","../src/compile/parse/utils/consumeSpace.ts","../src/compile/parse/addSpaceElement.ts","../src/compile/utils/isFullyReactive.ts","../src/compile/parse/utils/isAlphaNumericChar.ts","../src/compile/parse/utils/consumeAlphaNumeric.ts","../src/compile/parse/utils/consumeUntil.ts","../src/compile/parse/parseTag.ts","../src/compile/parse/parseText.ts","../src/compile/parse/slottifyChildNodes.ts","../src/compile/parse/utils/addError.ts","../src/compile/parse/parseElement.ts","../src/compile/parse/parseControl.ts","../src/compile/parse/parseMarkup.ts","../src/compile/utils/hash.ts","../src/compile/parse/utils/expect.ts","../src/compile/parse/parseStyles.ts","../src/compile/utils/isComponentNode.ts","../src/compile/utils/isParentNode.ts","../src/compile/parse/scopeStyles.ts","../src/compile/parse/parseCode.ts","../src/compile/parse.ts"],"sourcesContent":["export default function endOfTemplateString(content: string, start: number): number {\n\t// TODO: Recursively skip strings and comments inside the interpolated JS\n\tlet level = 0;\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === \"`\" && content[j - 1] !== \"\\\\\" && level === 0) {\n\t\t\treturn j;\n\t\t} else if (content[j] === \"{\" && (level > 0 || content[j - 1] === \"$\")) {\n\t\t\tlevel += 1;\n\t\t} else if (content[j] === \"}\" && level > 0) {\n\t\t\tlevel -= 1;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import endOfTemplateString from \"./endOfTemplateString\";\n\nexport default class Builder {\n\t#text = \"\";\n\t#space = 0;\n\t#mapped = false;\n\n\tlineMap: number[] = [];\n\n\tconstructor(mapped?: boolean) {\n\t\tthis.#mapped = mapped === true;\n\t}\n\n\tprepend(text: string): void {\n\t\t// TODO: adjust line map\n\t\tthis.#text = text + \"\\n\" + this.#text;\n\t}\n\n\tappend(text: string): void {\n\t\tif (this.#mapped) {\n\t\t\tthis.lineMap.push(this.#text.length);\n\t\t\tfor (let i = 0; i < text.length; i++) {\n\t\t\t\tif (text[i] === \"\\n\") {\n\t\t\t\t\tthis.lineMap.push(this.#text.length + i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#text += \"\\n\" + text;\n\t\t\treturn;\n\t\t}\n\n\t\tconst start = this.#text.length;\n\n\t\ttext = text.trim();\n\t\tlet i = 0;\n\t\t//let newline = !!text.length && !text.endsWith(\"\\n\");\n\n\t\twhile (i < text.length) {\n\t\t\t// Skip spaces\n\t\t\twhile (text[i] === \" \" || text[i] === \"\\t\") {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (text[i] === \";\") {\n\t\t\t\t// HACK: we just set ; to ignore the line\n\t\t\t\ti++;\n\t\t\t} else if (text[i] === \"\\n\") {\n\t\t\t\tthis.lineMap.push(start + i);\n\t\t\t\tthis.#text += \"\\n\";\n\t\t\t} else {\n\t\t\t\t// Maybe outdent\n\t\t\t\tif (text[i] === \"}\" || text[i] === \")\" || text[i] === \"]\") {\n\t\t\t\t\tthis.#space -= 1;\n\t\t\t\t}\n\n\t\t\t\t// Add indentation\n\t\t\t\tthis.#text += \"\\t\".repeat(Math.max(0, this.#space));\n\t\t\t\t// Add from text until the next newline or the end of text\n\t\t\t\tconst start = i;\n\t\t\t\twhile (i < text.length && text[i] !== \"\\n\") {\n\t\t\t\t\t// Just add backticked text as-is\n\t\t\t\t\tif (text[i] === \"`\") {\n\t\t\t\t\t\ti = endOfTemplateString(text, i);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tconst line = text.substring(start, i + 1);\n\n\t\t\t\tif (line.startsWith(\"*\")) {\n\t\t\t\t\t// JSDoc\n\t\t\t\t\tthis.#text += \" \";\n\t\t\t\t}\n\t\t\t\tthis.#text += line;\n\n\t\t\t\t// Maybe indent\n\t\t\t\tif (text[i - 1] === \"{\" || text[i - 1] === \"(\" || text[i - 1] === \"[\") {\n\t\t\t\t\tthis.#space += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\tif (!this.#text.endsWith(\"\\n\\n\")) {\n\t\t\tthis.#text += \"\\n\";\n\t\t}\n\t}\n\n\ttoString(): string {\n\t\treturn this.#text;\n\t}\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedText(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet start = b.toString().length + preText.length;\n\t\tb.append(preText + text + postText);\n\t\tlet end = start + text.length;\n\t\tstatus.map.push({\n\t\t\tscript: text,\n\t\t\tsource: span,\n\t\t\tcompiled: { start, end },\n\t\t});\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPopDevBoundary(status: BuildStatus, b: Builder): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_pop_dev_bound\");\n\t\tb.append(\"\");\n\t\tb.append(`t_pop_dev_bound();`);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPushDevBoundary(\n\ttype: \"component\" | \"region\" | \"run\" | \"watch\" | \"control\" | \"branch\",\n\tname: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_push_dev_bound\");\n\n\t\t// Ensure the name is wrapped with quotes, and internal quotes are escaped\n\t\tconst nameHasQuotes =\n\t\t\t(name.startsWith(\"'\") && name.endsWith(\"'\")) ||\n\t\t\t(name.startsWith('\"') && name.endsWith('\"')) ||\n\t\t\t(name.startsWith(\"`\") && name.endsWith(\"`\"));\n\t\tif (nameHasQuotes) {\n\t\t\tconst quote = name[0];\n\t\t\tname = quote + name.substring(1, name.length - 1).replaceAll(quote, \"\\\\\" + quote) + quote;\n\t\t} else {\n\t\t\tname = `\"${name.replaceAll('\"', '\\\\\"')}\"`;\n\t\t}\n\n\t\tb.append(`t_push_dev_bound(\"${type}\", ${name});`);\n\t\tb.append(\"\");\n\t}\n}\n","const ANCHOR_COMMENT = \"<!>\";\nconst HYDRATION_START_COMMENT = \"<![>\";\nconst HYDRATION_END_COMMENT = \"<!]>\";\nconst HYDRATION_BREAK_COMMENT = \"<!^>\";\n\nexport { ANCHOR_COMMENT, HYDRATION_START_COMMENT, HYDRATION_END_COMMENT, HYDRATION_BREAK_COMMENT };\n","/**\n * Checks whether the supplied string is fully or partially reactive (i.e. contains braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully or partially reactive\n */\nexport default function isReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.includes(\"{\") && text.includes(\"}\");\n}\n","/**\n * Trims matching quotes from the start and end of the supplied text\n *\n * @param text The text to trim\n *\n * @returns The text without the quotes at the start or the end\n */\nexport default function trimQuotes(text: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (\n\t\t(text[start] === \"'\" && text[end - 1] === \"'\") ||\n\t\t(text[start] === '\"' && text[end - 1] === '\"') ||\n\t\t(text[start] === \"`\" && text[end - 1] === \"`\")\n\t) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import { ANCHOR_COMMENT } from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isReactive from \"../../utils/isReactive\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Builds the HTML template text for all of the fragments in a component\n */\nexport default function buildFragmentText(\n\tnode: RootNode | ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tconst fragments: Fragment[] = [];\n\tbuildNodeFragmentText(node, status, fragments);\n\n\tif (fragments.length) {\n\t\tb.append(`const t_fragments: DocumentFragment[] = [];`);\n\t}\n}\n\nfunction buildNodeFragmentText(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment?: Fragment,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootFragmentText(node as RootNode, status, fragments);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlFragmentText(node as ControlNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\t// NOTE: We don't support nested SVG for now\n\t\t\tlet ns = (node as ElementNode).tagName === \"svg\";\n\t\t\tif (ns) status.ns = true;\n\t\t\tbuildElementFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tif (ns) status.ns = false;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tconst content = (node as TextNode).content;\n\t\t\tif (currentFragment) {\n\t\t\t\tcurrentFragment.text += isReactive(content) ? \"#\" : content;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildRootFragmentText(node: RootNode, status: BuildStatus, fragments: Fragment[]) {\n\tnode.fragment = {\n\t\tnumber: fragments.length,\n\t\ttext: \"\",\n\t\tns: status.ns,\n\t\teffects: [],\n\t\tevents: [],\n\t\tanimations: [],\n\t};\n\tfragments.push(node.fragment);\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t}\n}\n\nfunction buildControlFragmentText(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\t// Add a placeholder if it's a branching control node\n\t\t\t//if (!node.singleRooted) {\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\t//}\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// Add a new fragment if it's a control branch and it has children\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildComponentFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tcurrentFragment.text += ANCHOR_COMMENT;\n\n\t// Add fragments for slots if there are children\n\tif (node.children.length) {\n\t\tnode.fragment = {\n\t\t\tnumber: fragments.length,\n\t\t\ttext: \"\",\n\t\t\tns: status.ns,\n\t\t\teffects: [],\n\t\t\tevents: [],\n\t\t\tanimations: [],\n\t\t};\n\t\tfragments.push(node.fragment);\n\t\tfor (let child of node.children) {\n\t\t\t// TODO: Make sure it's not a fill node\n\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t}\n\t}\n}\n\nfunction buildElementFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tlet needsClass = node.scopeStyles;\n\tcurrentFragment.text += `<${node.tagName}`;\n\tlet attributesText = node.attributes\n\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t.map((a) => {\n\t\t\tif (a.value && a.reactive) {\n\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t// up, especially in the case of data attributes. Otherwise don't set it\n\t\t\t\tif (a.name.startsWith(\"data-\")) {\n\t\t\t\t\treturn `${a.name}=\"\"`;\n\t\t\t\t}\n\t\t\t} else if (a.name === \"class\" && node.scopeStyles) {\n\t\t\t\tneedsClass = false;\n\t\t\t\tlet value = a.value\n\t\t\t\t\t? `\"${trimQuotes(a.value)} torp-${status.styleHash}\"`\n\t\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\t\treturn `${a.name}=${value}`;\n\t\t\t} else {\n\t\t\t\treturn `${a.name}${a.value != null ? `=${a.value}` : \"\"}`;\n\t\t\t}\n\t\t})\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\tif (attributesText) {\n\t\tcurrentFragment.text += \" \" + attributesText;\n\t}\n\tif (needsClass) {\n\t\tcurrentFragment.text += ` class=\"torp-${status.styleHash}\"`;\n\t}\n\tcurrentFragment.text += \">\";\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t}\n\tcurrentFragment.text += `</${node.tagName}>`;\n}\n\nfunction buildSpecialFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\t// Add an anchor for the slot\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// Add a new fragment for filled slot content\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\t// HACK: Just treat it as a component node as that does what we need for now\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isSpecialNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"special\";\n}\n","import type BuildStatus from \"../client/BuildStatus\";\nimport type BuildServerStatus from \"../server/BuildServerStatus\";\n\n/**\n * Makes a supplied variable name (hopefully!) unique by prepending `t_` and\n * appending a sequence number\n *\n * @param name The variable name\n * @param status The build status\n *\n * @returns A unique variable name\n */\nexport default function nextVarName(name: string, status: BuildStatus | BuildServerStatus): string {\n\tif (!status.varNames[name]) {\n\t\tstatus.varNames[name] = 1;\n\t}\n\tlet varName = `t_${name}_${status.varNames[name]}`;\n\tstatus.varNames[name] += 1;\n\treturn varName;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedTextWithOffsets(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet mappedStart = b.toString().length + preText.length;\n\t\tlet functionBody = preText + text + postText;\n\t\tb.append(functionBody);\n\t\tfor (let i = 0; i < spans.length; i++) {\n\t\t\tlet start = mappedStart + offsets[i];\n\t\t\tlet end = start + lengths[i];\n\t\t\tstatus.map.push({\n\t\t\t\tscript: functionBody,\n\t\t\t\tsource: spans[i],\n\t\t\t\tcompiled: { start, end },\n\t\t\t});\n\t\t}\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\n\nexport default function buildAddFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tstatus.imports.add(\"t_add_fragment\");\n\t\tif (fragment.effects.length > 0) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tif (status.options.mapped === true) {\n\t\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.functionBody,\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.spans,\n\t\t\t\t\t\teffect.offsets,\n\t\t\t\t\t\teffect.lengths,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tb,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tb.append(fragment.effects.map((e) => e.functionBody).join(\"\\n\"));\n\t\t\t}\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setAttributes\"` : \"\"});`);\n\t\t}\n\t\tlet params = [fragmentName, parentName, anchorName];\n\t\tif (fragment.endVarName) {\n\t\t\tparams.push(fragment.endVarName);\n\t\t}\n\t\tb.append(`t_add_fragment(${params.join(\", \")});`);\n\t\t// TODO: Don't need to do this if the last thing we hydrated was the end node\n\t\tif (fragment.endVarName) {\n\t\t\tstatus.imports.add(\"t_next\");\n\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied character is a space\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is a space\n */\nexport default function isSpaceChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn code === 32 || (code >= 9 && code <= 13);\n}\n","import isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Checks whether the supplied string contains only space characters\n *\n * @param text The string to check\n *\n * @returns True if the supplied string contains only space characters\n */\nexport default function isSpace(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (!isSpaceChar(text, i)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isControlNode(node: TemplateNode): node is ControlNode {\n\treturn node.type === \"control\";\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isElementNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\n\nexport default function isTextNode(node: TemplateNode): node is TextNode {\n\treturn node.type === \"text\";\n}\n","import isSpace from \"../../parse/utils/isSpace\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isElementNode from \"../../utils/isElementNode\";\nimport isReactive from \"../../utils/isReactive\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport isTextNode from \"../../utils/isTextNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildNode from \"./buildNode\";\n\ninterface VariablePath {\n\tparent: VariablePath | null;\n\ttype: string;\n\tchildren: VariablePath[];\n}\n\n/**\n * Builds the variables and code in a fragment\n */\nexport default function buildFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (status.options.useCreateElement === true) {\n\t\t\t// Declarations, then createXxx calls\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tfragmentPath.children.length = 0;\n\t\t\tvarPaths.clear();\n\t\t\tstatus.imports.add(\"t_frg\");\n\t\t\tb.append(`const ${fragmentName} = t_frg([`);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tb.append(`]);`);\n\t\t} else {\n\t\t\t// Text, then declarations\n\t\t\tstatus.imports.add(\"t_fragment\");\n\t\t\tconst fragmentText = fragment.text.replaceAll(\"`\", \"\\\\`\").replaceAll(/\\s+/g, \" \");\n\t\t\tb.append(\n\t\t\t\t`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t);\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tmaybeAddRootNodeDeclaration(node, fragment, fragmentName, status, b, varPaths);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction maybeAddRootNodeDeclaration(\n\tnode: RootNode | ControlNode | ElementNode,\n\tfragment: Fragment,\n\tfragmentName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n) {\n\tif (!node.children.length) return;\n\n\t// We need to store the root node of the fragment for subsequent updates of the fragment\n\t// But not if the node would be declared anyway\n\tlet firstNode = node.children[0];\n\tlet firstNodeIsLastNode = node.children.length === 1;\n\tif (\n\t\t(isControlNode(firstNode) && firstNode.operation.endsWith(\" group\")) ||\n\t\t(isElementNode(firstNode) &&\n\t\t\telementNodeNeedsDeclaration(firstNode, true, firstNodeIsLastNode)) ||\n\t\t(isTextNode(firstNode) && textNodeNeedsDeclaration(firstNode, true, firstNodeIsLastNode))\n\t) {\n\t\t// It's going to be declared later on\n\t} else {\n\t\tstatus.imports.add(\"t_root\");\n\t\tconst rootName = `t_root_${fragment.number}`;\n\t\tconst params = [fragmentName];\n\t\tif (firstNode.type === \"text\") {\n\t\t\tparams.push(\"true\");\n\t\t}\n\t\tconst rootPath = `t_root(${params.join(\", \")})`;\n\t\tb.append(`const ${rootName} = ${rootPath};`);\n\t\t// HACK: pretend we don't have the text param, so that subsequent t_root\n\t\t// uses will be shortened, even if we don't know they are text nodes\n\t\tvarPaths.set(`t_root(${fragmentName})`, rootName);\n\n\t\tprintDebug(rootName, status, b);\n\t}\n}\n\nfunction declareFragmentVars(\n\tfragment: Fragment,\n\tnode: TemplateNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tdeclareRootFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as RootNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tdeclareControlFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ControlNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tdeclareTextFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as TextNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tdeclareSpecialFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction declareRootFragmentVars(\n\tfragment: Fragment,\n\tnode: RootNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n}\n\nfunction declareControlFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\tconst operation = node.operation.substring(1).replace(\" group\", \"\");\n\t\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\toperation,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction declareComponentFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tdeclareParentAndAnchorFragmentVars(\n\t\tfragment,\n\t\tnode,\n\t\tpath,\n\t\tstatus,\n\t\tb,\n\t\tparentName,\n\t\tanchorName,\n\t\tvarPaths,\n\t\t\"comp\",\n\t\tdeclare,\n\t);\n}\n\nfunction elementTypeName(node: ElementNode) {\n\t// TODO: Etc\n\tswitch (node.tagName.toLowerCase()) {\n\t\tcase \"div\":\n\t\tcase \"span\":\n\t\tcase \"input\":\n\t\tcase \"select\":\n\t\tcase \"option\":\n\t\tcase \"button\":\n\t\tcase \"form\":\n\t\t\treturn `HTML${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t\tcase \"a\":\n\t\t\treturn \"HTMLAnchorElement\";\n\t\tcase \"img\":\n\t\t\treturn \"HTMLImageElement\";\n\t\tcase \"textarea\":\n\t\t\treturn \"HTMLTextAreaElement\";\n\t}\n\treturn \"HTMLElement\";\n}\n\nfunction declareElementFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"element\" : node.tagName;\n\n\tlet elementPath = { parent: path, type: tagName, children: [] };\n\tpath.children.push(elementPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = elementNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(tagName, status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, elementPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tif (node.tagName === \"@element\") {\n\t\t\t\t\tb.append(`let ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If there is an immediate child of this element that has this element as its parent,\n\t// we need to assign the element to the parent var\n\t// @ts-ignore\n\tlet childParentName = node.children.find((c) => !!c.parentName)?.parentName;\n\n\tif (!declare) {\n\t\tlet attributes = node.attributes\n\t\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t\t.map((a) => {\n\t\t\t\tif (a.value && a.reactive) {\n\t\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t\t// up, especially in the case of data attributes\n\t\t\t\t\treturn `\"${a.name}\": \"#\"`;\n\t\t\t\t} else if (a.value) {\n\t\t\t\t\treturn `\"${a.name}\": \"${trimQuotes(a.value) || a.name}\"`;\n\t\t\t\t} else {\n\t\t\t\t\treturn `\"${a.name}\": true\"`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.join(\", \");\n\n\t\tstatus.imports.add(\"t_elm\");\n\t\tif (declareVariable) {\n\t\t\tb.append(\n\t\t\t\t`(${childParentName ? `${childParentName} = ` : \"\"}${node.varName} = t_elm(\"${node.tagName}\", {${attributes}}, [`,\n\t\t\t);\n\t\t} else if (childParentName) {\n\t\t\tb.append(`(${childParentName} = t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t} else {\n\t\t\tb.append(`t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t}\n\t}\n\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\telementPath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tif (!declare) {\n\t\tif (declareVariable || childParentName) {\n\t\t\tb.append(\"])),\");\n\t\t} else {\n\t\t\tb.append(\"]),\");\n\t\t}\n\t}\n}\n\nfunction elementNodeNeedsDeclaration(node: ElementNode, topLevel: boolean, lastChild: boolean) {\n\tconst hasReactiveAttribute = node.attributes.some((a) => a.value && a.reactive);\n\tconst isDynamicElement =\n\t\tnode.tagName === \"@element\" && node.attributes.find((a) => a.name === \"self\");\n\treturn hasReactiveAttribute || isDynamicElement || (topLevel && lastChild);\n}\n\nfunction declareTextFragmentVars(\n\tfragment: Fragment,\n\tnode: TextNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\t// HACK: Text nodes get merged together\n\t// Is this because of control nodes like @key and @const??\n\t// TODO: We should do this when building for the server too\n\tconst lastType = path.children[path.children.length - 1]?.type;\n\tif (lastType === \"text\" || lastType === \"space\") {\n\t\treturn;\n\t}\n\n\tlet textPath = { parent: path, type: isSpace(node.content) ? \"space\" : \"text\", children: [] };\n\tpath.children.push(textPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = textNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(\"text\", status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, textPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tb.append(`const ${node.varName} = ${varPath};`);\n\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_txt\");\n\t\tif (declareVariable) {\n\t\t\tb.append(`(${node.varName} = t_txt(\" \")),`);\n\t\t} else {\n\t\t\tb.append(`t_txt(\"${node.content}\"),`);\n\t\t}\n\t}\n}\n\nfunction textNodeNeedsDeclaration(node: TextNode, topLevel: boolean, lastChild: boolean) {\n\treturn isReactive(node.content) || (topLevel && lastChild);\n}\n\nfunction declareSpecialFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tif (node.tagName === \"slot\") {\n\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\tfragment,\n\t\t\tnode,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\t\"slot\",\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tswitch (node.tagName) {\n\t\tcase \"slot\":\n\t\tcase \"fill\": {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\t// Don't build the fill node twice\n\t\t\t\tif (node.tagName === \"slot\" && isSpecialNode(child) && child.tagName === \"fill\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n\nfunction declareParentAndAnchorFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode | ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tname: string,\n\tdeclare: boolean,\n) {\n\tconst topLevel = !path.parent;\n\n\t// Declare the parent\n\tif (topLevel) {\n\t\t// If this is a top-level element, then the parent is the fragment\n\t\tnode.parentName = `t_fragment_${fragment.number}`;\n\t} else {\n\t\tconst parentPath = path;\n\t\tconst oldChildren = parentPath.children;\n\t\tparentPath.children = [];\n\t\tconst parentVarPath = getFragmentVarPath(fragment, status, \"?\", parentPath, varPaths);\n\t\tparentPath.children = oldChildren;\n\t\t// TODO: Should do this thing for the last child as well\n\t\tif (varPaths.has(parentVarPath)) {\n\t\t\tnode.parentName = varPaths.get(parentVarPath);\n\t\t} else {\n\t\t\tif (declare) {\n\t\t\t\tnode.parentName = nextVarName(`${name}_parent`, status);\n\t\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\t\tb.append(`let ${node.parentName} as HTMLElement;`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.parentName} = ${parentVarPath} as HTMLElement;`);\n\n\t\t\t\t\tprintDebug(node.parentName, status, b);\n\t\t\t\t}\n\t\t\t\tvarPaths.set(parentVarPath, node.parentName);\n\t\t\t} else {\n\t\t\t\t// HACK: For the createElement option, this gets done in the parent\n\t\t\t}\n\t\t}\n\t}\n\n\t// Declare the anchor\n\tif (declare) {\n\t\tconst anchorPath = { parent: path, type: \"#\", children: [] };\n\t\tpath.children.push(anchorPath);\n\n\t\tnode.varName = nextVarName(`${name}_anchor`, status);\n\t\tconst anchorVarPath = getFragmentVarPath(fragment, status, node.varName, anchorPath, varPaths);\n\t\tif (status.options.useCreateElement === true) {\n\t\t\tb.append(`let ${node.varName};`);\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_anchor\");\n\t\t\tb.append(`let ${node.varName} = t_anchor(${anchorVarPath}) as HTMLElement;`);\n\n\t\t\tprintDebug(node.varName, status, b);\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_cmt\");\n\t\tb.append(`(${node.varName} = t_cmt()),`);\n\t}\n\n\t// Build nodes with anchors immediately, while we have their anchor node,\n\t// rather than at the end of the fragment\n\tbuildNode(node, status, b, parentName, anchorName);\n\tnode.handled = true;\n}\n\nfunction getFragmentVarPath(\n\tfragment: Fragment,\n\tstatus: BuildStatus,\n\tname: string,\n\tpath: VariablePath,\n\tvarPaths: Map<string, string>,\n): string {\n\tlet node = path;\n\twhile (node.parent) {\n\t\tnode = node.parent;\n\t}\n\tlet varName = `t_fragment_${fragment.number}`;\n\tlet varPath = getFragmentVarPathPart(node, varName, status, true);\n\n\t// Check for parts of the path that have already been run to shorten our\n\t// traversal\n\tfor (let [existingPath, existingName] of varPaths) {\n\t\tif (varPath.includes(existingPath)) {\n\t\t\tvarPath = varPath.replace(existingPath, existingName);\n\t\t}\n\t}\n\n\t// HACK: allow passing in \"?\" to not add the parentVarPath to the existing\n\t// paths\n\tif (name !== \"?\") {\n\t\t// Add the path, so that we can shorten subsequent paths e.g.\n\t\t// const div = t_next(t_child(root));\n\t\t// const p = t_next(t_next(t_next(t_child(root))))\n\t\t// => const p = t_next(t_next(div))\n\t\tvarPaths.set(varPath, name);\n\t\t// Add the name, so that we are always using the last declared name\n\t\tvarPaths.set(name, name);\n\t}\n\n\t// Shorten `t_next(t_next(x))` to `t_skip(x, 2)`\n\twhile (varPath.includes(\"t_next(t_next(\")) {\n\t\tstatus.imports.add(\"t_skip\");\n\t\tconst match = varPath.match(/(t_next\\(){2,}/)![0];\n\t\tconst count = match.length / \"t_next(\".length;\n\t\tconst pos = varPath.indexOf(\"t_next(t_next(\");\n\t\tconst head = varPath.substring(0, pos);\n\t\tlet level = 0;\n\t\tlet end = 0;\n\t\tfor (let i = pos + match.length; i < varPath.length; i++) {\n\t\t\tif (varPath[i] === \"(\") {\n\t\t\t\tlevel++;\n\t\t\t} else if (varPath[i] === \")\") {\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tend = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tlevel--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst tail = varPath.substring(end + count);\n\t\tconst param = varPath.substring(pos + match.length, end);\n\t\tvarPath = `${head}t_skip(${param}, ${count})${tail}`;\n\t}\n\n\t// Set t_next_text back to t_next\n\tvarPath = varPath.replaceAll(\"t_next_text\", \"t_next\");\n\n\treturn varPath;\n}\n\nfunction getFragmentVarPathPart(\n\tpath: VariablePath,\n\tvarPath: string,\n\tstatus: BuildStatus,\n\troot = false,\n): string {\n\tif (root) {\n\t\tstatus.imports.add(\"t_root\");\n\t\tvarPath = `t_root(${varPath})`;\n\t} else {\n\t\tstatus.imports.add(\"t_child\");\n\t\tvarPath = `t_child(${varPath})`;\n\t}\n\tfor (let [i, child] of path.children.entries()) {\n\t\tif (i > 0) {\n\t\t\tif (child.type === \"text\" || child.type === \"space\") {\n\t\t\t\t// HACK: Using t_next_text just stops t_next(node, true) from\n\t\t\t\t// being converted into t_skip\n\t\t\t\tvarPath = `t_next_text(${varPath}, true)`;\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tvarPath = `t_next(${varPath})`;\n\t\t\t}\n\t\t}\n\n\t\tif (i === path.children.length - 1 && child.children.length) {\n\t\t\tvarPath = getFragmentVarPathPart(child, varPath, status);\n\t\t}\n\t}\n\treturn varPath;\n}\n\nconst debug = false;\nfunction printDebug(varName: string, status: BuildStatus, b: Builder) {\n\tif (debug) {\n\t\tstatus.imports.add(\"t_print\");\n\t\tb.append(`console.log(\"${varName}:\", t_print(${varName}));`);\n\t}\n}\n\n/*\nfunction printPath(path: VariablePath) {\n\tlet parent = path;\n\twhile (parent.parent) {\n\t\tparent = parent.parent;\n\t}\n\tprintPathPart(parent);\n}\n\nfunction printPathPart(path: VariablePath, indent = 0) {\n\tconsole.log(`${\" \".repeat(indent * 2)}${path.type}`);\n\tfor (let child of path.children) {\n\t\tprintPathPart(child, indent + 1);\n\t}\n}\n*/\n","import type BuildStatus from \"./BuildStatus\";\n\n/**\n * Variables used within a for loop need to be retrieved from the loop data.\n */\nexport default function replaceForVarNames(value: string, status: BuildStatus): string {\n\t// HACK: If a value from a for loop is used in the function body,\n\t// get it from the loop data to trigger an update when it is changed\n\tfor (let varName of status.forVarNames) {\n\t\tvalue = value.replaceAll(\n\t\t\tnew RegExp(`(^|\\\\s|\\\\(|\\\\[|\\\\{|!)${varName[0]}($|\\\\s|\\\\.|,|\\\\(|\\\\)|\\\\[|\\\\]|\\\\}|;)`, \"g\"),\n\t\t\t`$1${varName[1]}$2`,\n\t\t);\n\t}\n\treturn value;\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildRun(\n\tfunctionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\taddPushDevBoundary(\"run\", functionName, status, b);\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(functionBody);\n\tb.append(`}${status.options.dev === true ? `, \"${functionName}\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n}\n","export default function endOfString(char: string, content: string, start: number): number {\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === char && content[j - 1] !== \"\\\\\") {\n\t\t\treturn j;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport trimQuotes from \"../../utils/trimQuotes\";\n\nexport default function getAttributeOffsets(\n\tvalue: string,\n\tspan: SourceSpan,\n): {\n\tnewValue: string;\n\tspans: SourceSpan[];\n\toffsets: number[];\n\tlengths: number[];\n} {\n\t// Build offsets for interpolated values e.g. attribute=\"value {x}\n\t// and {y}\" should have offsets for where the x and y are\n\t// interpolated into the output\n\tvalue = trimQuotes(value);\n\tlet spans: SourceSpan[] = [];\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\n\tlet textContent = \"\";\n\tlet reactiveStart = 0;\n\tlet level = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst char = value[i];\n\t\tconst nextChar = value[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\t//maxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\t//reactiveCount += 1;\n\t\t\t\ttextContent += \"${\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.push({ start: span.start + i + 2, end: -1 });\n\t\t\t\toffsets.push(reactiveStart + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.at(-1)!.end = span.start + i + 2;\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \"}\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = value.indexOf(\"\\n\", i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = value.indexOf(\"*/\", i) + 1;\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, value, i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(value, i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += value[i];\n\t}\n\tvalue = `\\`${textContent}\\``;\n\n\treturn {\n\t\tnewValue: value,\n\t\tspans,\n\t\toffsets,\n\t\tlengths,\n\t};\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\troot = false,\n): void {\n\tb.append(\"\");\n\tb.append(\"/* @component */\");\n\n\t// TODO: map params to props\n\n\t// Props\n\tconst componentHasProps = node.attributes.length || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// NOTE: The $props object is wrapped in a proxy so that components can\n\t\t// be updated if they refer to a $props.property in e.g. an element's\n\t\t// attribute\n\t\t// TODO: default props etc\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets: number[];\n\t\t\tlengths: number[];\n\t\t}[] = [];\n\t\tlet runs: string[] = [];\n\t\tlet bindingRuns: string[] = [];\n\n\t\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\t\tif (name === \"self\" && node.tagName === \"@component\") {\n\t\t\t\t// Ignore this special attribute\n\t\t\t} else if (value != null && fullyReactive) {\n\t\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\t\t// It's a bound property\n\t\t\t\t\t// Add two $runs -- one to update the props, and one to update the value\n\t\t\t\t\t// The component author will need to make sure $props.x is updated\n\t\t\t\t\t// TODO: Maybe allow adding a Bindable<T> type to the $props interface??\n\t\t\t\t\t// e.g. Component($props: { text: Bindable<string> })\n\t\t\t\t\tname = name.substring(1);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \"\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t\tbindingRuns.push(`${value} = ${propsName}[\"${name}\"];`);\n\t\t\t\t} else if (name === \"class\") {\n\t\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\t\tconst params = [value];\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tvalue = params.join(\", \");\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"t_class(\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \")\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_class(${value});`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"t_style(\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \")\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_style(${value});`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \"\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null && reactive) {\n\t\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\t\tvalue = newValue;\n\t\t\t\tif (name === \"class\") {\n\t\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\t\tconst params = [value];\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tvalue = params.join(\", \");\n\t\t\t\t\tprops.push({ name, preText: \"t_class(\", value, postText: \")\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_class(${value});`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\t\tprops.push({ name, preText: \"t_style(\", value, postText: \")\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_style(${value});`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({ name, preText: \"\", value, postText: \"\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null) {\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tpreText: \"\",\n\t\t\t\t\tvalue,\n\t\t\t\t\tpostText: \"\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t\toffsets: [],\n\t\t\t\t\tlengths: [],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tpreText: \"\",\n\t\t\t\t\tvalue: \"true\",\n\t\t\t\t\tpostText: \"\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t\toffsets: [],\n\t\t\t\t\tlengths: [],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\tif (p.spans.length === 1) {\n\t\t\t\taddMappedText(`${p.name}: ` + p.preText, value, p.postText + \",\", p.spans[0], status, b);\n\t\t\t} else {\n\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t`${p.name}: ` + p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans,\n\t\t\t\t\tp.offsets,\n\t\t\t\t\tp.lengths,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t\tif (bindingRuns.length) {\n\t\t\tbuildRun(\"setBindings\", replaceForVarNames(bindingRuns.join(\"\\n\"), status), status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t$run(() => ${propsName}[name] = $props[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, SlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && slot.tagName === \"fill\") {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t\"$sparent: ParentNode\",\n\t\t\t\t\t\"$sanchor: Node | null\",\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$sprops: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"// @ts-ignore\\n$sprops?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\n\t\t\t\tbuildFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tstatus.fragmentStack.push({\n\t\t\t\t\tfragment: slot.fragment,\n\t\t\t\t\tpath: \"\",\n\t\t\t\t});\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildNode(child, status, b, \"$sparent\", \"$sanchor\");\n\t\t\t\t}\n\t\t\t\tstatus.fragmentStack.pop();\n\n\t\t\t\tbuildAddFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render the component\n\tconst compParentName = node.parentName;\n\tconst compAnchorName = node.varName;\n\tlet renderParams = `${compParentName}, ${compAnchorName}, ${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// TODO: Map the params properly, either by checking for things ourselves,\n\t// or better checking for $props being undefined in components\n\t//addMappedText(\"\", componentName, `(${renderParams});`, node.span, status, b);\n\taddMappedText(\"\", `${componentName}(${renderParams})`, \";\", node.span, status, b);\n\n\tb.append(\"\");\n}\n","/**\n * Trims chars from the start and end of the supplied text when both the start and end match\n *\n * @param text The text to trim\n *\n * @returns The text without the chars at the start or the end\n */\nexport default function trimMatched(text: string, startChar: string, endChar: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (text[start] === startChar && text[end - 1] === endChar) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildAwaitNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"await_region\", status);\n\tconst indexName = nextVarName(\"await_index\", status);\n\tconst tokenName = nextVarName(\"await_token\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Make sure all branches exist\n\tlet awaitBranch = branches.find((n) => n.operation === \"@await\")!;\n\tif (!awaitBranch) {\n\t\t// TODO: Error handling\n\t}\n\tlet thenBranch = branches.find((n) => n.operation === \"@then\");\n\tif (!thenBranch) {\n\t\tthenBranch = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@then\",\n\t\t\tstatement: \"then\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t}\n\tlet catchBranch = branches.find((n) => n.operation === \"@catch\");\n\tif (!catchBranch) {\n\t\tcatchBranch = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@catch\",\n\t\t\tstatement: \"catch\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t}\n\n\tconst awaiterName = trimMatched(awaitBranch.statement.substring(\"await\".length).trim(), \"(\", \")\");\n\tconst thenVar = trimMatched(thenBranch.statement.substring(\"then\".length).trim(), \"(\", \")\");\n\tconst catchVar = trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\");\n\n\t// Use an incrementing token to make sure only the last request gets handled\n\t// TODO: This might have unforeseen consequences\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @await */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"await\"` : \"\"});\n\t\tlet ${tokenName} = 0;\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (t_before) => {`);\n\n\tlet index = 0;\n\n\t// Build the waiting branch before anything happens\n\tbuildAwaitBranch(awaitBranch, status, b, parentName, regionName, indexName, index++);\n\n\tb.append(`\n\t\t${tokenName}++;\n\t\t((t_token) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tawaitBranch.span.start += \"await\".length + 2;\n\taddMappedText(\"\", replaceForVarNames(awaiterName, status), \"\", awaitBranch.span, status, b);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tthenBranch.span.start -= 1;\n\taddMappedText(\n\t\t\".then((\",\n\t\treplaceForVarNames(thenVar, status),\n\t\t\") => {\",\n\t\tthenBranch.span,\n\t\tstatus,\n\t\tb,\n\t);\n\n\tb.append(`if (t_token === ${tokenName}) {`);\n\tbuildAwaitBranch(thenBranch, status, b, parentName, regionName, indexName, index++);\n\tb.append(`}\n\t\t})`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tcatchBranch.span.start -= 1;\n\taddMappedText(\n\t\t\".catch((\",\n\t\treplaceForVarNames(catchVar, status),\n\t\t\") => {\",\n\t\tcatchBranch.span,\n\t\tstatus,\n\t\tb,\n\t);\n\n\tb.append(`if (t_token === ${tokenName}) {`);\n\tbuildAwaitBranch(catchBranch, status, b, parentName, regionName, indexName, index++);\n\tb.append(`}\n\t\t\t\t});\n\t\t\t})(${tokenName});\n\t\t}${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildAwaitBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\t// NOTE: for await branches, we need to push the control region again,\n\t\t// because it will have been popped by the time the `then` or `catch`\n\t\t// branches are hit\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"await_branch\"` : \"\"});\n\t\t\tconst t_old_control_region = t_push_region(${regionName});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment!,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t\tb.append(\"t_pop_region(t_old_control_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nconst forLoopRegex = /for\\s*\\((.+?);.*?;.*?\\)/;\nconst forLoopVarsRegex = /(?:let\\s+|var\\s+){0,1}([^\\s,;+=]+)(?:\\s*=\\s*[^,;]+){0,1}/g;\nconst forOfRegex = /for\\s*\\(\\s*(?:let\\s*|var\\s*){0,1}(.+?)\\s+(?:of|in).*?\\)/;\n\nexport default function buildForNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst parentName = node.parentName!;\n\tconst anchorName = node.varName ?? \"null\";\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\t// HACK: Need to wrangle the declaration(s) out of the for loop and put them in data\n\t// TODO: Handle destructuring, quotes, comments etc\n\tconst forVarNames: string[] = [];\n\tconst forLoopMatch = node.statement.match(forLoopRegex);\n\tif (forLoopMatch) {\n\t\tconst forVarMatches = forLoopMatch[1].matchAll(forLoopVarsRegex);\n\t\tfor (let match of forVarMatches) {\n\t\t\tforVarNames.push(match[1]);\n\t\t}\n\t} else {\n\t\tconst forOfMatch = node.statement.match(forOfRegex);\n\t\tif (forOfMatch) {\n\t\t\tconst match = forOfMatch[1];\n\t\t\tif (\n\t\t\t\t(match.startsWith(\"{\") && match.endsWith(\"}\")) ||\n\t\t\t\t(match.startsWith(\"[\") && match.endsWith(\"]\"))\n\t\t\t) {\n\t\t\t\tforVarNames.push(\n\t\t\t\t\t...trimMatched(trimMatched(match, \"{\", \"}\"), \"[\", \"]\")\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map((m) => m.trim()),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tforVarNames.push(match);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst regionName = nextVarName(\"for_region\", status);\n\tconst listItemsName = nextVarName(\"new_items\", status);\n\tconst previousItemName = nextVarName(\"previous_item\", status);\n\tconst nextItemName = nextVarName(\"next_item\", status);\n\tconst newItemName = nextVarName(\"new_item\", status);\n\tconst itemName = nextVarName(\"item\", status);\n\tconst beforeName = nextVarName(\"before\", status);\n\n\t// Get the key node if it's been set\n\tlet keyStatement = \"\";\n\tconst key = node.children.find(\n\t\t(n) => n.type === \"control\" && (n as ControlNode).operation === \"@key\",\n\t) as ControlNode;\n\tif (key !== undefined) {\n\t\tlet matches = key.statement.match(/^(\\s*@*key\\s*=\\s*)(.+?)\\s*;*\\s*$/);\n\t\tif (matches) {\n\t\t\tkey.span.start += matches[1].length;\n\t\t\tkeyStatement = matches[2];\n\t\t}\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_list\");\n\tstatus.imports.add(\"t_list_item\");\n\tstatus.imports.add(\"ListItem\");\n\n\tb.append(\"\");\n\tb.append(\"/* @for */\");\n\taddPushDevBoundary(\"control\", `@${node.statement}`, status, b);\n\tb.append(`\n\t\tlet ${regionName} = t_region(${status.options.dev === true ? `\"for\"` : \"\"});\n\t\tt_run_list(\n\t\t${regionName},\n\t\t${parentName},\n\t\t${anchorName},\n\t\t${status.options.dev === true ? \"function createNewItems() {\" : \"() => {\"}\n\t\t\tlet ${listItemsName}: ListItem[] = [];\n\t\t\tlet ${previousItemName} = ${regionName};\n\t\t\tlet ${nextItemName} = ${regionName}.nextRegion;`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`let ${newItemName} = t_list_item(`);\n\t// TODO: Should map these\n\tb.append(`{ ${forVarNames.join(\", \")} },`);\n\tif (key !== undefined) {\n\t\taddMappedText(\"\", `${keyStatement || \"undefined\"}`, \",\", key.span, status, b);\n\t}\n\tif (status.options.dev === true) {\n\t\tb.append(`\"for item\"`);\n\t}\n\tb.append(\");\");\n\tb.append(`\n\t\t\t${newItemName}.previousRegion = ${previousItemName};\n\t\t\t${previousItemName}.nextRegion = ${newItemName};\n\t\t\t${previousItemName} = ${newItemName};\n\t\t\t${listItemsName}.push(${newItemName});\n\t\t}\n\t\t${regionName}.nextRegion = ${nextItemName};\n\t\treturn ${listItemsName};\n\t},\n\t${status.options.dev === true ? `function createListItem(${itemName}, ${beforeName}) {` : `(${itemName}, ${beforeName}) => {`}`);\n\n\tlet oldForVarNames = status.forVarNames;\n\tstatus.forVarNames = [\n\t\t...status.forVarNames,\n\t\t...forVarNames.map((v) => [v, `${itemName}.data.${v}`]),\n\t];\n\tbuildForItem(node, status, b, parentName, beforeName, itemName);\n\tstatus.forVarNames = oldForVarNames;\n\n\tb.append(`},\n\t${status.options.dev === true ? \"function updateListItem(t_old_item, t_new_item) {\" : \"(t_old_item, t_new_item) => {\"}`);\n\tfor (let varName of forVarNames) {\n\t\tb.append(`t_old_item.data.${varName} = t_new_item.data.${varName};`);\n\t}\n\tb.append(`}\n\t\t);`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildForItem(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tbeforeName: string,\n\titemName: string,\n) {\n\tconst oldRegionName = nextVarName(\"old_region\", status);\n\n\tstatus.imports.add(\"t_push_region\");\n\tb.append(`let ${oldRegionName} = t_push_region(${itemName});`);\n\n\tbuildFragment(node, status, b, parentName, beforeName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment!,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tif (isControlNode(child) && child.operation === \"@key\") {\n\t\t\tcontinue;\n\t\t}\n\t\tbuildNode(child, status, b, parentName, beforeName);\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, beforeName);\n\n\t// If we wanted to return the fragment instead:\n\t//b.append(`t_item.startNode = t_fragment_1.firstChild;`);\n\t//b.append(`t_item.endNode = t_fragment_1.lastChild;`);\n\t//for (let ev of node.fragment!.events) {\n\t// b.append(`${ev.varName}.addEventListener(\"${ev.eventName}\", ${ev.handler});`);\n\t//}\n\n\tstatus.imports.add(\"t_pop_region\");\n\tb.append(`t_pop_region(${oldRegionName});`);\n\n\t// If we wanted to return the fragment instead:\n\t//b.append(`return t_fragment_${node.fragment!.number};`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildHtmlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst htmlAnchorName = node.varName!;\n\tconst htmlParentName = node.parentName || htmlAnchorName + \".parentNode\";\n\tconst htmlRegionName = nextVarName(\"html_region\", status);\n\n\t// HACK: I'm not actually sure we need this here (or in @replace, where I copied it from)\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @html */\n\tconst ${htmlRegionName} = t_region(${status.options.dev === true ? `\"html\"` : \"\"});\n\tt_run_control(${htmlRegionName}, ${htmlAnchorName}, (t_before) => {`);\n\n\tbuildHtmlBranch(node, status, b, htmlParentName, htmlRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"html\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildHtmlBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"html_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tconst templateName = nextVarName(\"template\", status);\n\tconst fragmentName = `t_fragment_${node.fragment!.number}`;\n\tb.append(`let ${templateName} = document.createElement(\"template\");`);\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tnode.span.start += \"html(\".length;\n\tnode.span.end -= 2;\n\taddMappedText(\n\t\t\"\",\n\t\t`${templateName}.innerHTML = ${replaceForVarNames(node.statement, status)};`,\n\t\t\"\",\n\t\tnode.span,\n\t\tstatus,\n\t\tb,\n\t);\n\tb.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: Are there too many branches for ifs etc?\n\nexport default function buildIfNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"if_region\", status);\n\tconst indexName = nextVarName(\"if_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add an else branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@else\") === -1) {\n\t\tconst elseBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@else\",\n\t\t\tstatement: \"else\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(elseBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @if */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"if\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildIfBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\n\tb.append(`}${status.options.dev === true ? `, \"runIf\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildIfBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"if_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildReplaceNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst replaceAnchorName = node.varName!;\n\tconst replaceParentName = node.parentName || replaceAnchorName + \".parentNode\";\n\tconst replaceRegionName = nextVarName(\"replace_region\", status);\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @replace */\n\tconst ${replaceRegionName} = t_region(${status.options.dev === true ? `\"replace\"` : \"\"});\n\tt_run_control(${replaceRegionName}, ${replaceAnchorName}, (t_before) => {`);\n\n\tbuildReplaceBranch(node, status, b, replaceParentName, replaceRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"replace\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildReplaceBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"replace_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\n\nexport default function buildScriptNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tb.append(`/* ${node.operation} */`);\n\taddMappedText(\"\", `${maybeAppend(node.statement, \";\")}`, \"\", node.span, status, b);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSwitchNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"switch_region\", status);\n\tconst indexName = nextVarName(\"switch_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add a default branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@default\") === -1) {\n\t\tconst defaultBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@default\",\n\t\t\tstatement: \"default\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(defaultBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @switch */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"switch\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildSwitchBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\tb.append(`\n\t\t}\n\t}${status.options.dev === true ? `, \"runSwitch\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildSwitchBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"switch_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`\n\t\t\t${indexName} = ${index};\n\t\t\tbreak;\n\t\t}`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAwaitNode from \"./buildAwaitNode\";\nimport buildForNode from \"./buildForNode\";\nimport buildHtmlNode from \"./buildHtmlNode\";\nimport buildIfNode from \"./buildIfNode\";\nimport buildReplaceNode from \"./buildReplaceNode\";\nimport buildScriptNode from \"./buildScriptNode\";\nimport buildSwitchNode from \"./buildSwitchNode\";\n\nexport default function buildControlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@then\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildHtmlNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\":\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tb.append(\"\");\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tb.append(\"\");\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","/**\n * Trims a char from the end of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the end of the text\n *\n * @returns The text without the char on the end\n */\nexport default function trimEnd(text: string, char: string): string {\n\tlet end = text.length;\n\twhile (text[end - 1] === char) {\n\t\tend -= 1;\n\t}\n\treturn text.substring(0, end);\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildMount(\n\t// TODO: like in buildRun\n\t_functionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\tstatus.imports.add(\"$mount\");\n\t// Ignore errors if the user hasn't returned a cleanup function\n\tb.append(\"// @ts-ignore\\n$mount(() => {\");\n\tb.append(functionBody);\n\tb.append(\"});\");\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRun(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n): void {\n\tvalue = replaceForVarNames(value, status);\n\tlet functionBody = functionStart + value + functionEnd;\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: [span],\n\t\toffsets: [functionStart.length],\n\t\tlengths: [value.length],\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRunWithOffsets(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n): void {\n\tlet functionBody = functionStart + value + functionEnd;\n\n\tfor (let i = 0; i < offsets.length; i++) {\n\t\toffsets[i] += functionStart.length;\n\t\tconst oldLength = functionBody.length;\n\t\tfunctionBody =\n\t\t\tfunctionBody.substring(0, offsets[i]) +\n\t\t\treplaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) +\n\t\t\tfunctionBody.substring(offsets[i] + lengths[i]);\n\t\tconst changedLength = functionBody.length - oldLength;\n\t\tlengths[i] += changedLength;\n\t\tfor (let j = i + 1; j < offsets.length; j++) {\n\t\t\toffsets[j] += changedLength;\n\t\t}\n\t}\n\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: spans,\n\t\toffsets,\n\t\tlengths,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimEnd from \"../../utils/trimEnd\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildMount from \"./buildMount\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\nimport stashRun from \"./stashRun\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildElementNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n): void {\n\tif (status.inHead) {\n\t\tif (node.tagName === \"title\") {\n\t\t\tbuildTitleNode(node, status, b);\n\t\t} else {\n\t\t\tbuildHeadNode(node, status, b);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst svgElement = node.tagName === \"svg\";\n\tconst oldns = status.ns;\n\tif (svgElement) {\n\t\tstatus.ns = true;\n\t}\n\n\tconst varName = node.varName;\n\tif (varName) {\n\t\tif (node.tagName === \"@element\") {\n\t\t\tbuildDynamicElementNode(node, status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\t//status.imports.add(\"t_apply_props\");\n\t\t\t//// TODO: I think we know what the props are at this stage, so we could be more direct?\n\t\t\t//b.append(\"\");\n\t\t\t//b.append(\n\t\t\t//\t`t_apply_props(${varName}, $props, [${status.props.map((p) => `'${p}'`).join(\", \")}]);`,\n\t\t\t//);\n\t\t}\n\n\t\tbuildElementAttributes(node, varName, status, b);\n\t}\n\n\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\tstatus.preserveWhitespace = node.tagName === \"code\" || node.tagName === \"pre\";\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"null\");\n\t}\n\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\n\tif (svgElement) {\n\t\tstatus.ns = oldns;\n\t}\n}\n\nfunction buildDynamicElementNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\tstatus.imports.add(\"$run\");\n\t\tstatus.imports.add(\"t_dynamic\");\n\t\tlet selfValue = selfAttribute.value;\n\n\t\tb.append(\"$run(() => {\");\n\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\n\t\tlet parentName = node.varName;\n\n\t\tbuildFragment(node, status, b, parentName!, \"null\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName!, \"null\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName!, \"null\");\n\n\t\tb.append(`}${status.options.dev === true ? `, \"setDynamic\"` : \"\"});`);\n\t}\n}\n\nfunction buildTitleNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet content = (node.children[0] as TextNode).content || \"\";\n\n\t// Replace all spaces with a single space, both to save space and to remove\n\t// newlines from generated JS strings\n\tcontent = content.replace(/\\s+/g, \" \");\n\n\t// TODO: Should be fancier about this in parse -- e.g. ignore braces in\n\t// quotes, unclosed, etc\n\tlet reactiveStarted = false;\n\tlet reactiveCount = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tif (content[i] === \"{\") {\n\t\t\treactiveStarted = true;\n\t\t} else if (content[i] === \"}\") {\n\t\t\tif (reactiveStarted) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\treactiveStarted = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (reactiveCount) {\n\t\tstatus.imports.add(\"t_fmt\");\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\tcontent = `t_fmt(${content.substring(1, content.length - 1)})`;\n\t\t} else {\n\t\t\tcontent = `\\`${content.replaceAll(\"{\", \"${t_fmt(\").replaceAll(\"}\", \")}\")}\\``;\n\t\t}\n\t} else {\n\t\tcontent = `\"${content}\"`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_old_title = document.title;\n\t\t\tdocument.title = ${content};\n\t\t\treturn () => document.title = t_old_title;\n\t\t}${status.options.dev === true ? `, \"runTitle\"` : \"\"});`);\n}\n\nfunction buildHeadNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tstatus.imports.add(\"$run\");\n\t// TODO: dedupe e.g. <meta name=\"x\"> or on special key\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_head_el = document.createElement(\"${node.tagName}\");\n\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(t_head_el);`);\n\tfor (let { name, value, span } of node.attributes) {\n\t\tif (value != null) {\n\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\tvalue = replaceForVarNames(value, status);\n\t\t\taddMappedText(`t_attribute(t_head_el, \"${name}\", `, value, \");\", span, status, b);\n\t\t}\n\t}\n\tb.append(`}${status.options.dev === true ? `, \"runHead\"` : \"\"});`);\n}\n\nfunction buildElementAttributes(\n\tnode: ElementNode,\n\tvarName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) throw new Error(\"No fragment on stack\");\n\n\t// TODO: Add an error if any reactive attributes are used non-reactively\n\n\t// Do &ref first, just in case any other attributes depend on it being set\n\t// e.g. if you have a `style` attribute that depends on the element's size\n\tconst refAttribute = node.attributes.find((a) => a.name === \"&ref\");\n\tif (refAttribute) {\n\t\tlet { value, fullyReactive } = refAttribute;\n\t\tif (value != null && fullyReactive) {\n\t\t\t// Bind the DOM element to a user-defined variable\n\t\t\tb.append(`${value} = ${varName};`);\n\t\t}\n\t}\n\n\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// Ignore this one, it should have been done already, above\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&group\") {\n\t\t\t\tbuildBindGroupAttribute(node, varName, value, status, b);\n\t\t\t} else if (name === \"&value\" || name === \"&checked\") {\n\t\t\t\tbuildBindAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"onmount\") {\n\t\t\t\t// The onmount event is faked by us by creating a $mount. This\n\t\t\t\t// also means that you can have unmount functionality by\n\t\t\t\t// returning a cleanup function\n\t\t\t\tbuildMount(\"elMount\", `return (${trimEnd(value.trim(), \";\")})(${varName});`, status, b);\n\t\t\t} else if (name.startsWith(\"on\")) {\n\t\t\t\tbuildEventAttribute(varName, name, value, span, status, b);\n\t\t\t} else if (name.startsWith(\"transition\")) {\n\t\t\t\tbuildTransitionAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRun(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspan,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRun(fragment, `${varName}.setAttribute(\"style\", t_style(`, value, \"));\", span, status);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\tvalue = newValue;\n\t\t\tif (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${varName}.setAttribute(\"style\", t_style(`,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\"));\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction buildBindGroupAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Only tested this with radio buttons\n\tlet eventName = \"change\";\n\tlet inputValue = node.attributes.find((a) => a.name === \"value\")?.value;\n\tlet set = `${value} == ${inputValue}`;\n\tlet propName = \"checked\";\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => {\n\t\t\tif (e.target.${propName}) ${value} = ${inputValue};\n\t\t});`);\n}\n\nfunction buildBindAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Need to check the element to find out what type of event to add\n\tlet eventName = \"input\";\n\tlet defaultValue = '\"\"';\n\tlet inputValue = \"e.target.value\";\n\tif (node.tagName === \"input\") {\n\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\tcase \"number\": {\n\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\tinputValue = \"Number(e.target.value)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\tinputValue = \"e.target.checked\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"radio\": {\n\t\t\t\t\teventName = \"change\";\n\t\t\t\t\tinputValue = \"e.target.value\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (node.tagName === \"select\") {\n\t\teventName = \"change\";\n\t}\n\tlet set = `${value} || ${defaultValue}`;\n\tconst propName = name.substring(1);\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => ${value} = ${inputValue});`);\n}\n\nfunction buildEventAttribute(\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Add an event listener, after the fragment has been added\n\tconst eventName = name.substring(2);\n\tstatus.imports.add(\"t_event\");\n\taddMappedText(`t_event(${varName}, \"${eventName}\", `, value, `);`, span, status, b);\n}\n\nfunction buildTransitionAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\tstatus.imports.add(\"t_animate\");\n\n\t// Add an in and out transition, after the fragment has been added\n\t// TODO: Separate these -- you should be able to have multiple,\n\t// unrelated entry and exit transitions?\n\tlet entryVarName = nextVarName(\"trans_in\", status);\n\tlet exitVarName = nextVarName(\"trans_out\", status);\n\n\tif (name === \"transition\") {\n\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\tb.append(`const ${exitVarName} = ${entryVarName};`);\n\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t} else if (name === \"transition-in\") {\n\t\tlet outAttribute = node.attributes.find((a) => a.name === \"transition-out\");\n\t\tif (outAttribute && outAttribute.value && outAttribute.fullyReactive) {\n\t\t\tlet outValue = outAttribute.value;\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`const ${exitVarName} = (${outValue})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t\t} else {\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName});`);\n\t\t}\n\t} else if (name === \"transition-out\") {\n\t\tlet inAttribute = node.attributes.find((a) => a.name === \"transition-in\");\n\t\tif (inAttribute) {\n\t\t\t// This has already been handled with transition-in, above\n\t\t\treturn;\n\t\t} else {\n\t\t\tb.append(`const ${exitVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, null, ${entryVarName});`);\n\t\t}\n\t} else {\n\t\t// TODO: Add an error\n\t}\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildRootNode(\n\tnode: RootNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tbuildFragment(node, status, b, parentName, anchorName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"0:ch/\",\n\t});\n\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, anchorName, true);\n\t}\n\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, anchorName);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSlotNode(node: ElementNode, status: BuildStatus, b: Builder): void {\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"sprops\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: { name: string; value: string; span: SourceSpan }[] = [];\n\t\tlet runs: string[] = [];\n\n\t\tfor (let { name, value, reactive, span } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tprops.push({ name, value, span });\n\t\t\t\tif (reactive) {\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\", span });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\taddMappedText(`${p.name}: `, value, \",\", p.span, status, b);\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t}\n\n\tconst slotParentName = node.parentName!;\n\tconst slotAnchorName = node.varName!;\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tlet params = [slotParentName, slotAnchorName, slotHasProps ? propsName : \"undefined\", \"$context\"];\n\tb.append(`$slots[\"${slotName}\"](${params.join(\", \")})`);\n\n\t// TODO: Maybe not if there's only a single space node?\n\tconst fill = node.children.find((c) => isSpecialNode(c) && c.tagName === \"fill\");\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tbuildFragment(fill, status, b, slotParentName, slotAnchorName);\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: fill.fragment,\n\t\t\tpath: \"0:ch/\",\n\t\t});\n\t\tfor (let child of fill.children) {\n\t\t\tbuildNode(child, status, b, slotParentName, slotAnchorName);\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(fill, status, b, slotParentName, slotAnchorName);\n\t}\n\n\tb.append(`}`);\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildSlotNode from \"./buildSlotNode\";\n\nexport default function buildSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementNode(node, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentNode(node, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport type BuildStatus from \"./BuildStatus\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildTextNode(node: TextNode, status: BuildStatus): void {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) return; // probably in @head...\n\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Should we be parsing out the spans here? Like we do with\n\t// attributes? And should we merge this with the attributes logic?\n\tlet textContent = \"\";\n\tlet reactiveCount = 0;\n\tlet reactiveStart = 0;\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\tlet level = 0;\n\tlet maxLevel = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tconst nextChar = content[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tmaxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\ttextContent += \"${t_fmt(\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\toffsets.push(reactiveStart);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"\\n\", i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"*/\", i) + 1;\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, content, i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(content, i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += content[i];\n\t}\n\n\t// Only need to build if there is any reactive content, otherwise the plain\n\t// text content will be output in fragment text\n\tif (maxLevel) {\n\t\tlet offsetChange = 0;\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\ttextContent = textContent.substring(2, textContent.length - 1);\n\t\t\toffsetChange = -2;\n\t\t} else {\n\t\t\ttextContent = `\\`${textContent}\\``;\n\t\t\toffsetChange = 1;\n\t\t}\n\n\t\tstatus.imports.add(\"t_fmt\");\n\t\toffsets.map((_, i) => (offsets[i] += offsetChange));\n\n\t\tstashRunWithOffsets(\n\t\t\tfragment,\n\t\t\t`${node.varName}.textContent = `,\n\t\t\ttextContent,\n\t\t\t\";\",\n\t\t\tnode.spans,\n\t\t\toffsets,\n\t\t\tlengths,\n\t\t\tstatus,\n\t\t);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildControlNode from \"./buildControlNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildRootNode from \"./buildRootNode\";\nimport buildSpecialNode from \"./buildSpecialNode\";\nimport buildTextNode from \"./buildTextNode\";\n\nexport default function buildNode(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\troot = false,\n): void {\n\t// Nodes with anchors will have been handled when their containing fragment\n\t// was built so we want to skip them here\n\tif (node.handled) {\n\t\tnode.handled = false;\n\t\treturn;\n\t}\n\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootNode(node as RootNode, status, b, parentName, anchorName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentNode(node as ElementNode, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildElementNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type TemplateComponent from \"../../../types/TemplateComponent\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport type SourceMapping from \"../../types/SourceMapping\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildFragmentText from \"./buildFragmentText\";\nimport buildNode from \"./buildNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$mount: 'import { $mount } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_region: 'import { t_region } from \"${folder}\";',\n\tt_push_region: 'import { t_push_region } from \"${folder}\";',\n\tt_pop_region: 'import { t_pop_region } from \"${folder}\";',\n\tt_run_control: 'import { t_run_control } from \"${folder}\";',\n\tt_run_branch: 'import { t_run_branch } from \"${folder}\";',\n\tt_list_item: 'import { t_list_item } from \"${folder}\";',\n\tt_run_list: 'import { t_run_list } from \"${folder}\";',\n\tt_add_fragment: 'import { t_add_fragment } from \"${folder}\";',\n\tt_apply_props: 'import { t_apply_props } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tt_attribute: 'import { t_attribute } from \"${folder}\";',\n\tt_dynamic: 'import { t_dynamic } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_fragment: 'import { t_fragment } from \"${folder}\";',\n\tt_event: 'import { t_event } from \"${folder}\";',\n\tt_animate: 'import { t_animate } from \"${folder}\";',\n\tt_root: 'import { t_root } from \"${folder}\";',\n\tt_anchor: 'import { t_anchor } from \"${folder}\";',\n\tt_child: 'import { t_child } from \"${folder}\";',\n\tt_next: 'import { t_next } from \"${folder}\";',\n\tt_skip: 'import { t_skip } from \"${folder}\";',\n\tt_frg: 'import { t_frg } from \"${folder}\";',\n\tt_elm: 'import { t_elm } from \"${folder}\";',\n\tt_txt: 'import { t_txt } from \"${folder}\";',\n\tt_cmt: 'import { t_cmt } from \"${folder}\";',\n\tt_print: 'import { t_print } from \"${folder}\";',\n\tListItem: 'import { type ListItem } from \"${folder}\";',\n\tSlotRender: 'import { type SlotRender } from \"${folder}\";',\n\t// HACK: this one's a bit different\n\tdevContext: 'import { devContext } from \"${folder}/dev\";',\n\tt_push_dev_bound: 'import { t_push_dev_bound } from \"${folder}/dev\";',\n\tt_pop_dev_bound: 'import { t_pop_dev_bound } from \"${folder}/dev\";',\n};\n\nexport default function buildCode(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\toptions?: BuildOptions,\n): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"SlotRender\");\n\n\t// Build the component\n\tbuildTemplate(template, map, imports, b, options);\n\n\tlet startSize = b.toString().length;\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tb.prepend(\"\");\n\t\tfor (let imp of Array.from(imports).sort().reverse()) {\n\t\t\tlet importStatement = importsMap[imp] ?? imp;\n\t\t\tlet folder = options?.renderFolder ?? \"@torpor/view\";\n\t\t\timportStatement = importStatement.replace(\"${folder}\", folder);\n\t\t\tb.prepend(importStatement);\n\t\t}\n\t}\n\n\tif (options?.mapped) {\n\t\tlet endSize = b.toString().length;\n\t\tlet diff = endSize - startSize + 1;\n\t\tfor (let m of map) {\n\t\t\tm.compiled.start += diff;\n\t\t\tm.compiled.end += diff;\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildTemplate(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(script)) imports.add(\"$watch\");\n\tif (/\\$cache\\b/.test(script)) imports.add(\"$cache\");\n\tif (/\\$run\\b/.test(script)) imports.add(\"$run\");\n\tif (/\\$mount\\b/.test(script)) imports.add(\"$mount\");\n\tif (/\\$unwrap\\b/.test(script)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(script)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(script)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\tlet status: BuildStatus = makeStatus(imports, map, current, options);\n\tlet first = true;\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// Reset the status for each new function body\n\t\t\tif (!first) {\n\t\t\t\tstatus = makeStatus(imports, map, current, options);\n\t\t\t}\n\t\t\tfirst = false;\n\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tb.append(`\n\t\t\t\t\t${current.markup ? \"$parent\" : \"_$parent\"}: ParentNode,\n\t\t\t\t\t${current.markup ? \"$anchor\" : \"_$anchor\"}: Node | null,`);\n\t\t\tif (current.params !== undefined) {\n\t\t\t\taddMappedText(\"\", current.params, \",\", chunk.span, status, b);\n\t\t\t} else {\n\t\t\t\tb.append(\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"// @ts-ignore\\n$props?: Record<PropertyKey, any>\"},`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t\t\t${current.contextProps?.length ? \"$context\" : \"// @ts-ignore\\n$context\"}?: Record<PropertyKey, any>,\n\t\t\t\t\t${current.slotProps?.length ? \"$slots\" : \"// @ts-ignore\\n$slots\"}?: Record<string, SlotRender>`);\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): void {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Add the component to devContext for display in DevTools\n\t\t\taddPushDevBoundary(\"component\", current.name || \"Anon Component\", status, b);\n\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\t\t\t\tbuildFragmentText(current.markup, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.markup, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Add the head tags\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\t\t\t\tstatus.inHead = true;\n\t\t\t\tbuildNode(current.head, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tstatus.inHead = false;\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t// No styles in the client\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\taddPopDevBoundary(status, b);\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\taddMappedText(\"\", chunk.script, \"\", chunk.span, status, b);\n\t\t}\n\t}\n}\n\nfunction makeStatus(\n\timports: Set<string>,\n\tmap: SourceMapping[],\n\tcurrent?: TemplateComponent,\n\toptions?: BuildOptions,\n): BuildStatus {\n\treturn {\n\t\timports,\n\t\tprops: current?.props ?? [],\n\t\tcontextProps: current?.contextProps ?? [],\n\t\tslotProps: current?.slotProps ?? [],\n\t\tstyleHash: current?.style?.hash ?? \"\",\n\t\tmap,\n\t\tvarNames: {},\n\t\tfragmentStack: [],\n\t\tforVarNames: [],\n\t\tns: false,\n\t\tpreserveWhitespace: false,\n\t\tinHead: false,\n\t\toptions: options ?? {},\n\t};\n}\n","import type Attribute from \"../../types/styles/Attribute\";\nimport type Style from \"../../types/styles/Style\";\nimport type StyleBlock from \"../../types/styles/StyleBlock\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildStyles(style: Style, styleHash: string): string {\n\tconst b = new Builder();\n\n\tfor (let block of style.blocks) {\n\t\tbuildStyleBlock(block, b, styleHash);\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildStyleBlock(block: StyleBlock, b: Builder, styleHash: string) {\n\t// TODO: This should probably be done while parsing\n\t// And handle attribute selectors\n\tif (block.selector.startsWith(\"@\")) {\n\t\t// Just output media queries and properties as-is\n\t\tb.append(`${block.selector} {`);\n\t} else {\n\t\tblock.selector = block.selector.replaceAll(/\\s+/g, \" \");\n\t\tlet selectors: string[] = [];\n\t\tlet global = false;\n\t\tlet start = 0;\n\t\tfor (let i = 0; i <= block.selector.length; i++) {\n\t\t\tif (block.selector.substring(i).startsWith(\":global(\")) {\n\t\t\t\ti += \":global\".length;\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = true;\n\t\t\t} else if (global && block.selector[i] === \")\") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = false;\n\t\t\t} else if (\"*,>+~\".includes(block.selector[i])) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tselectors.push(block.selector[i]);\n\t\t\t\tstart = i + 1;\n\t\t\t} else if (i === block.selector.length) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t} else if (block.selector[i] === \" \") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t}\n\t\t}\n\t\tb.append(`${selectors.join(\" \").replaceAll(\" ,\", \",\")} {`);\n\t}\n\tfor (let attribute of block.attributes) {\n\t\tbuildStyleAttribute(attribute, b);\n\t}\n\tfor (let child of block.children) {\n\t\tbuildStyleBlock(child, b, styleHash);\n\t}\n\tb.append(`}`);\n}\n\nfunction addSelector(\n\tselectors: string[],\n\tselector: string,\n\tstyleHash: string,\n\tstart: number,\n\tend: number,\n\tglobal: boolean,\n) {\n\tif (end > start) {\n\t\tlet s = selector.substring(start, end);\n\t\tif (!global) {\n\t\t\tlet pre = s;\n\t\t\tlet post = \"\";\n\t\t\t// We might need to handle e.g. `:hover` or `::before`\n\t\t\tlet colonPosition = s.indexOf(\":\");\n\t\t\tif (colonPosition !== -1) {\n\t\t\t\tpre = s.substring(0, colonPosition);\n\t\t\t\tpost = s.substring(colonPosition);\n\t\t\t}\n\t\t\ts = `${pre}.torp-${styleHash}${post}`;\n\t\t}\n\t\tselectors.push(s);\n\t}\n}\n\nfunction buildStyleAttribute(attribute: Attribute, b: Builder) {\n\tb.append(`${attribute.name}: ${attribute.value};`);\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Props\n\tconst componentHasProps = node.attributes.length; // || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// TODO: defaults etc props\n\n\t\t// Gather props, and set them all at once\n\t\tlet props: { name: string; value: string }[] = [];\n\n\t\tfor (let { name, value } of node.attributes) {\n\t\t\t// No binding on the server\n\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\tname = name.substring(1);\n\t\t\t}\n\n\t\t\tif (name === \"class\" && value != null) {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\tprops.push({ name, value: `t_class(${params.join(\", \")})` });\n\t\t\t} else if (name === \"style\" && value != null) {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tprops.push({ name, value: `t_style(${value})` });\n\t\t\t} else if (value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\" });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props that we gathered\n\t\tb.append(`const ${propsName} = {`);\n\t\tfor (let p of props) {\n\t\t\tb.append(`${p.name}: ${p.value},`);\n\t\t}\n\t\tb.append(\"};\");\n\n\t\t// NOTE: Not sure if this is needed\n\t\t/*\n\t\tif (root) {\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t${propsName}[name] = $props[name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t\t*/\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, ServerSlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && slot.tagName === \"fill\") {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$sprops: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"// @ts-ignore\\n$sprops?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\t\t\t\tb.append(`let t_body = \"\";`);\n\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t\t}\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"return t_body;\");\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// Render the component\n\tlet renderParams = `${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\tconst componentResult = nextVarName(\"comp\", status);\n\tb.append(`const ${componentResult} = ${componentName}(${renderParams});`);\n\tb.append(`t_body += ${componentResult}.body;`);\n\tb.append(`t_head += ${componentResult}.head;`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerAwaitNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the await statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch) && branch.operation === \"@await\") {\n\t\t\tbuildServerAwaitBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerAwaitBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerForNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the for statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerForBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerForBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerHtmlNode(node: ControlNode, status: BuildServerStatus): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\t// Build the html statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tstatus.output += `\\${${branch.statement}}`;\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerIfNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the if statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerIfBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerIfBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerReplaceNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the replace statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerReplaceBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerReplaceBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement};`);\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildServerScriptNode(node: ControlNode, b: Builder): void {\n\tb.append(`${maybeAppend(node.statement, \";\")}`);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerSwitchNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the switch statement\n\tb.append(`${node.statement} {`);\n\tfor (let branch of node.children.filter((c) => isControlNode(c))) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerSwitchBranch(branch, status, b);\n\t\t}\n\t}\n\tb.append(\"}\");\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerSwitchBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"break;\");\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerAwaitNode from \"./buildServerAwaitNode\";\nimport buildServerForNode from \"./buildServerForNode\";\nimport buildServerHtmlNode from \"./buildServerHtmlNode\";\nimport buildServerIfNode from \"./buildServerIfNode\";\nimport buildServerReplaceNode from \"./buildServerReplaceNode\";\nimport buildServerScriptNode from \"./buildServerScriptNode\";\nimport buildServerSwitchNode from \"./buildServerSwitchNode\";\n\nexport default function buildServerControlNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildServerIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildServerSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildServerForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildServerAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@then\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildServerReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildServerHtmlNode(node, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\": {\n\t\t\tif (status.output) {\n\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\tstatus.output = \"\";\n\t\t\t}\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tif (status.output) {\n\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\tstatus.output = \"\";\n\t\t\t}\n\t\t\t//b.append(\"/* eslint-disable */\");\n\t\t\tb.append(\"\");\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tb.append(\"\");\n\t\t\t//b.append(\"/* eslint-enable */\");\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\t// These can't be used on the server\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","// From https://developer.mozilla.org/en-US/docs/Glossary/Void_element\nconst voidTags: string[] = [\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n];\nexport default voidTags;\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerElementNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tlet attributes = buildElementAttributes(node, status);\n\tif (attributes.length) {\n\t\tattributes = \" \" + attributes;\n\t}\n\n\tlet tagName = node.tagName;\n\tif (tagName === \"@element\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute) {\n\t\t\ttagName = `$\\{${selfAttribute.value}}`;\n\t\t}\n\t}\n\n\t// NOTE: Only void tags can be self-closed in HTML, although we allow it in\n\t// templates and auto-expand it here\n\tstatus.output += `<${tagName}${attributes}>`;\n\tif (!voidTags.includes(tagName)) {\n\t\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\t\tstatus.preserveWhitespace = [\"pre\", \"code\"].includes(tagName);\n\t\tfor (let child of node.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\t\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\t\tstatus.output += `</${tagName}>`;\n\t}\n}\n\nfunction buildElementAttributes(node: ElementNode, status: BuildServerStatus) {\n\tlet needsClass = node.scopeStyles;\n\tlet attributes: string[] = [];\n\tfor (let { name, value, reactive, fullyReactive } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// No elements on the server\n\t\t} else if (name.startsWith(\"on\") || name.startsWith(\":on\")) {\n\t\t\t// No events on the server\n\t\t} else if (name.startsWith(\"transition\") && value) {\n\t\t\t// TODO: No animation on the server, but we do need to set the\n\t\t\t// attributes from the first keyframe\n\t\t\t// HACK: use a regex instead maybe?\n\t\t\t//value = value.split(\",\")[0].trim();\n\t\t\t//if (value.startsWith(\"[\")) {\n\t\t\t//\tvalue = value.substring(1);\n\t\t\t//} else {\n\t\t\t//\tvalue = value + \"[0]\";\n\t\t\t//}\n\t\t\t//attributes.push(\n\t\t\t//\t`style=\"\\${Object.entries(${value}).map(([k, v]) => \\`$\\{k}: $\\{v}\\`).join(\"; \")}\"`,\n\t\t\t//);\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&value\" || name === \"&checked\" || name === \"&group\") {\n\t\t\t\tlet defaultValue = \"\";\n\t\t\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\t\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\t\t\tcase \"number\": {\n\t\t\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultValue) {\n\t\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\t\tvalue = `t_attr(${value})`;\n\t\t\t\t\tdefaultValue = '\"\"';\n\t\t\t\t}\n\t\t\t\tlet valueOrDefault = `${value} || ${defaultValue}`;\n\t\t\t\tconst propName = name.substring(1);\n\t\t\t\tattributes.push(`${propName}=\"\\${${valueOrDefault}}\"`);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tlet params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\tneedsClass = false;\n\t\t\t\t}\n\t\t\t\tattributes.push(`class=\"\\${t_class(${params.join(\", \")})}\"`);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tattributes.push(`style=\"\\${t_style(${value})}\"`);\n\t\t\t} else {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// e.g. `... ${className ? `class=\"${className}\"` : ''} ...`\n\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\tattributes.push(`\\${${value} ? \\`${name}=\"\\${t_attr(${value})}\"\\` : ''}`);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\t// TODO: Match braces, don't replace braces inside code\n\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\tattributes.push(\n\t\t\t\t`${name}=\"${trimQuotes(value).replaceAll(\"{\", \"${t_attr(\").replaceAll(\"}\", \")}\")}\"`,\n\t\t\t);\n\t\t} else if (name === \"class\" && node.scopeStyles) {\n\t\t\tvalue = value\n\t\t\t\t? `\"${trimQuotes(value)} torp-${status.styleHash}\"`\n\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t\tneedsClass = false;\n\t\t} else if (value != null) {\n\t\t\t// Just set the attribute\n\t\t\t// TODO: Probably check if it's a boolean attribute e.g. disabled\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t} else {\n\t\t\tattributes.push(`${name}`);\n\t\t}\n\t}\n\tif (needsClass) {\n\t\tattributes.push(`class=\"torp-${status.styleHash}\"`);\n\t}\n\treturn attributes.join(\" \");\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerRootNode(\n\tnode: RootNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerSlotNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"sprops\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tb.append(`const ${propsName}: any = {};`);\n\t\tfor (let { name, value } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t} else {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = true;`);\n\t\t\t}\n\t\t}\n\t}\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tb.append(`t_body += $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`);\n\t////const slotResult = nextVarName(\"comp\", status);\n\t////b.append(\n\t////\t`const ${slotResult} = $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`,\n\t////);\n\t////b.append(`t_body += ${slotResult}.body;`);\n\t////b.append(`t_head += ${slotResult}.head;`);\n\n\t// TODO: Not if there's only a single space node -- maybe check in parse\n\tconst fill = node.children.find((c) => isSpecialNode(c) && c.tagName === \"fill\");\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tfor (let child of fill.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\n\t\tif (status.output) {\n\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\tstatus.output = \"\";\n\t\t}\n\t}\n\n\tb.append(`}`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerSlotNode from \"./buildServerSlotNode\";\n\nexport default function buildServerSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildServerSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildServerElementNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildServerComponentNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerTextNode(node: TextNode, status: BuildServerStatus): void {\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Move all of this logic into parse, for text nodes and attribute values\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tconst nextChar = content[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tif (level === 1) {\n\t\t\t\tstatus.imports.add(\"t_fmt\");\n\t\t\t\tstatus.output += \"${t_fmt(\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tstatus.output += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\tstatus.output += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"\\n\", i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"*/\", i) + 1;\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, content, i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(content, i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tstatus.output += char;\n\t}\n}\n\n// Escape HTML in comments and strings on the server, so that we don't output unintended tags etc\n// This doesn't need to be done on the client, where we will be setting textContent\nfunction escapeHtml(text: string) {\n\treturn text.replaceAll(\"&\", \"&amp;\").replaceAll(\"<\", \"&lt;\").replaceAll(\">\", \"&gt;\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerControlNode from \"./buildServerControlNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerRootNode from \"./buildServerRootNode\";\nimport buildServerSpecialNode from \"./buildServerSpecialNode\";\nimport buildServerTextNode from \"./buildServerTextNode\";\n\nexport default function buildServerNode(\n\tnode: TemplateNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildServerRootNode(node as RootNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildServerControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildServerComponentNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildServerElementNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildServerTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildServerSpecialNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport Builder from \"../../utils/Builder\";\nimport buildStyles from \"../client/buildStyles\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$mount: 'import { $mount } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_attr: 'import { t_attr } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tServerSlotRender: 'import { type ServerSlotRender } from \"${folder}\";',\n};\n\nexport default function buildServerCode(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"ServerSlotRender\");\n\n\t// Build the component and any child components\n\tbuildServerTemplate(template, imports, b, options);\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tb.prepend(\"\");\n\t\tfor (let imp of Array.from(imports).sort().reverse()) {\n\t\t\timp = importsMap[imp] || imp;\n\t\t\tb.prepend(imp.replace(\"${folder}\", options?.renderFolder || \"@torpor/view/ssr\"));\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildServerTemplate(\n\ttemplate: Template,\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(script)) imports.add(\"$watch\");\n\tif (/\\$cache\\b/.test(script)) imports.add(\"$cache\");\n\tif (/\\$run\\b/.test(script)) imports.add(\"$run\");\n\tif (/\\$mount\\b/.test(script)) imports.add(\"$mount\");\n\tif (/\\$unwrap\\b/.test(script)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(script)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(script)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tlet params = [\n\t\t\t\tcurrent.params ??\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"// @ts-ignore\\n$props?: Record<PropertyKey, any>\"}`,\n\t\t\t\t`${current.contextProps?.length ? \"$context\" : \"// @ts-ignore\\n$context\"}?: Record<PropertyKey, any>`,\n\t\t\t\t`${current.slotProps?.length ? \"$slots\" : \"// @ts-ignore\\n$slots\"}?: Record<string, ServerSlotRender>`,\n\t\t\t];\n\t\t\tb.append(params.join(\",\\n\"));\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): { body: string, head: string } {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\n\t\t\t// Declare t_head and t_body\n\t\t\tb.append(`let t_body = \"\";`);\n\t\t\tb.append(`let t_head = \"\";`);\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.markup) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\tbuildServerNode(current.markup, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\t\t\t// TODO: need to add e.g. a title to the head, but remove when changing page\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.style) {\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Style */\");\n\n\t\t\t\t// Replace multiple spaces with a single space\n\t\t\t\tconst styles = buildStyles(current.style, current.style.hash)\n\t\t\t\t\t.replaceAll('\"', '\\\\\"')\n\t\t\t\t\t.replaceAll(/\\s+/g, \" \");\n\t\t\t\tb.append(`t_head += \"<style id='${current.style.hash}'>${styles}</style>\";\\n`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\tb.append(`return { body: t_body, head: t_head };`);\n\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\tb.append(chunk.script);\n\t\t}\n\t}\n}\n","import type Template from \"../types/Template\";\nimport buildCode from \"./build/client/buildCode\";\nimport buildStyles from \"./build/client/buildStyles\";\nimport buildServerCode from \"./build/server/buildServerCode\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport type BuildResult from \"./types/BuildResult\";\nimport type SourceMapping from \"./types/SourceMapping\";\n\n/**\n * Builds a component template into code and styles for rendering\n *\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The component's code and styles\n */\nexport default function build(template: Template, options?: BuildOptions): BuildResult {\n\tlet map: SourceMapping[] = [];\n\tlet code = options?.server\n\t\t? buildServerCode(template, options)\n\t\t: buildCode(template, map, options);\n\tlet styles = template.components\n\t\t.map((c) =>\n\t\t\tc.style ? { style: buildStyles(c.style, c.style.hash), hash: c.style.hash } : undefined,\n\t\t)\n\t\t.filter((c) => c !== undefined);\n\treturn {\n\t\tcode,\n\t\tstyles,\n\t\tmap,\n\t};\n}\n","import type Template from \"../types/Template\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport Builder from \"./utils/Builder\";\n\n/**\n * Builds a component template into a d.ts file\n *\n * @param name The name of the component\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The d.ts file content\n */\nexport default function buildType(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder();\n\n\tb.append(`import { type SlotRender } from \"${options?.renderFolder || \"@torpor/view\"}\";`);\n\n\tfor (let component of template.components) {\n\t\tif (component.exported) {\n\t\t\tb.append(\"\");\n\t\t\tif (component.propsType) {\n\t\t\t\tb.append(component.propsType);\n\t\t\t\tb.append(\"\");\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t${component.documentation ?? \"\"}\n\t\t\t${component.default ? \"declare\" : \"export declare\"} function ${component.name}(\n\t\t\t\t$parent: ParentNode,\n\t\t\t\t$anchor: Node | null,\n\t\t\t\t${component.params || \"$props?: Record<PropertyKey, any>\"},\n\t\t\t\t$context?: Record<PropertyKey, any>,\n\t\t\t\t$slots?: Record<string, SlotRender>,\n\t\t\t): void;\n\t\t`);\n\t\t\tif (component.default) {\n\t\t\t\tb.append(`export default ${component.name};`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"./isTextNode\";\n\nexport default function isSpaceNode(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && isSpace(node.content);\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function accept(value: string, status: ParseStatus, advance = true): boolean {\n\tconst check = status.source.substring(status.i, status.i + value.length);\n\tif (check == value) {\n\t\tstatus.i += advance ? value.length : 0;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\n\nexport default function parseInlineScript(status: ParseStatus): string {\n\tconst start = status.i;\n\tlet braceCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tif (accept(\"{\", status)) {\n\t\t\tbraceCount += 1;\n\t\t} else if (accept(\"}\", status)) {\n\t\t\tif (braceCount > 0) {\n\t\t\t\tbraceCount -= 1;\n\t\t\t} else {\n\t\t\t\treturn status.source.substring(start, status.i - 1);\n\t\t\t}\n\t\t} else if (accept(\"//\", status)) {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"/*\", status)) {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept('\"', status) || accept(\"'\", status)) {\n\t\t\t// Skip string contents\n\t\t\tconst char = status.source[status.i - 1];\n\t\t\tstatus.i = endOfString(char, status.source, status.i - 1) + 1;\n\t\t} else if (accept(\"`\", status)) {\n\t\t\t// Skip template string contents\n\t\t\tstatus.i = endOfTemplateString(status.source, status.i - 1) + 1;\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n","/**\n * Trims a char from the start of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the start of the text\n *\n * @returns The text without the char on the start\n */\nexport default function trimStart(text: string, char: string): string {\n\tlet start = 0;\n\twhile (text[start] === char) {\n\t\tstart += 1;\n\t}\n\treturn text.substring(start);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Consumes space characters and advances the current parse position to before\n * the next non-space character\n *\n * @param status The parse status\n *\n * @returns The string of space characters from the current parse position to\n * the next non-space character\n */\nexport default function consumeSpace(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isSpaceChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function addSpaceElement(\n\tparent: ElementNode | ControlNode,\n\tstatus: ParseStatus,\n): void {\n\tconst content = consumeSpace(status);\n\tif (content) {\n\t\tconst previousNode = parent.children[parent.children.length - 1];\n\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\tpreviousNode.content += content;\n\t\t} else {\n\t\t\tconst space: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tparent.children.push(space);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied string is fully reactive (i.e. starts and ends with braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully reactive\n */\nexport default function isFullyReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.trim().startsWith(\"{\") && text.trim().endsWith(\"}\");\n}\n","/**\n * Checks whether the supplied character is a alpha-numeric\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is alpha-numeric\n */\nexport default function isAlphaNumericChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn (\n\t\t// 0-9\n\t\t(code > 47 && code < 58) ||\n\t\t// A-Z\n\t\t(code > 64 && code < 91) ||\n\t\t// a-z\n\t\t(code > 96 && code < 123)\n\t);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isAlphaNumericChar from \"./isAlphaNumericChar\";\n\n/**\n * Consumes alpha-numeric characters and advances the current parse position to\n * before the next non-alpha character\n *\n * @param status The parse status\n *\n * @returns The string of alpha-numeric characters from the current parse position\n * to the next non-alpha character\n */\nexport default function consumeAlphaNumeric(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isAlphaNumericChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Consumes characters until one of the characters in the supplied string is\n * found. The parse position will be advanced to before the found character\n *\n * @param chars The characters to match\n * @param status The parse status\n *\n * @returns The string of characters from the current parse position to the\n * found character\n */\nexport default function consumeUntil(chars: string, status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (chars.includes(status.source[status.i])) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type Attribute from \"../types/nodes/Attribute\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isFullyReactive from \"../utils/isFullyReactive\";\nimport isReactive from \"../utils/isReactive\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\n\nexport default function parseTag(status: ParseStatus): ElementNode {\n\taccept(\"<\", status);\n\n\tlet closeTag = accept(\"/\", status);\n\n\tconsumeSpace(status);\n\n\tlet tagStart = status.i + 1;\n\tlet snailed = accept(\"@\", status);\n\tlet tagName = consumeAlphaNumeric(status);\n\tlet tagEnd = status.i;\n\n\tif (snailed) {\n\t\ttagName = \"@\" + tagName;\n\t}\n\tif (closeTag) {\n\t\ttagName = \"/\" + tagName;\n\t}\n\n\tconsumeSpace(status);\n\n\tlet attributes = parseTagAttributes(status);\n\n\tlet selfClosed = false;\n\tif (accept(\"/>\", status)) {\n\t\tselfClosed = true;\n\t\t// Actually, it is kind of convenient to self-close things, and more consistent with\n\t\t// component tags...\n\t\t//if (!voidTags.includes(tagName)) {\n\t\t//\taddError(status, `Self-closed non-void element: ${tagName}`, start);\n\t\t//}\n\t} else {\n\t\taccept(\">\", status);\n\t}\n\n\tif (closeTag) {\n\t\tselfClosed = true;\n\t}\n\n\tlet special = [\"slot\", \"fill\", \"@component\", \"@element\"].includes(tagName);\n\n\treturn {\n\t\ttype: special ? \"special\" : \"element\",\n\t\ttagName,\n\t\tselfClosed: selfClosed || undefined,\n\t\tclosed: selfClosed || undefined,\n\t\tattributes,\n\t\tchildren: [],\n\t\tspan: { start: tagStart, end: tagEnd },\n\t} satisfies ElementNode;\n}\n\nfunction parseTagAttributes(status: ParseStatus): Attribute[] {\n\tlet attributes: Attribute[] = [];\n\twhile (status.i < status.source.length) {\n\t\tconsumeSpace(status);\n\t\tif (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"/>\", status, false) || accept(\">\", status, false)) {\n\t\t\t// That's the end of the attributes\n\t\t\tbreak;\n\t\t} else if (\n\t\t\taccept(\"<\", status, false) ||\n\t\t\taccept(\"@\", status, false) ||\n\t\t\taccept(\"}\", status, false)\n\t\t) {\n\t\t\t// It's an unclosed tag -- just bail out here\n\t\t\tbreak;\n\t\t} else {\n\t\t\tconst attribute = parseAttribute(status);\n\t\t\tattributes.push(attribute);\n\t\t}\n\t}\n\treturn attributes;\n}\n\nfunction parseAttribute(status: ParseStatus): Attribute {\n\tlet valueStart = status.i;\n\tlet valueEnd = status.i;\n\tlet name = consumeUntil(\"= \\t\\r\\n/>\", status);\n\tlet value: string | undefined = undefined;\n\tlet reactive = false;\n\tlet fullyReactive = false;\n\tconsumeSpace(status);\n\tif (accept(\"=\", status)) {\n\t\tconsumeSpace(status);\n\t\tvalueStart = status.i;\n\t\tvalue = parseAttributeValue(status);\n\t\tvalueEnd = status.i;\n\t\treactive = isReactive(value);\n\t\tfullyReactive = isFullyReactive(value);\n\t\tif (fullyReactive) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t\tvalueStart++;\n\t\t\tvalueEnd--;\n\t\t}\n\t} else if (name.startsWith(\"{\") && name.endsWith(\"}\")) {\n\t\t// It's a shortcut attribute. It could be e.g. {width} or it could be\n\t\t// {$state.width}, but in either case we set the value of the width\n\t\t// property\n\t\tvalue = name.substring(1, name.length - 1);\n\t\tvalueStart++;\n\t\tvalueEnd = valueStart + name.length;\n\t\tname = value.split(\".\").at(-1)!;\n\t\t// Handle definite assignment assertions e.g. {$state.width!}\n\t\tif (name.endsWith(\"!\")) {\n\t\t\tname = name.substring(0, name.length - 1);\n\t\t}\n\t\treactive = fullyReactive = true;\n\t}\n\treturn {\n\t\tname,\n\t\tvalue,\n\t\treactive,\n\t\tfullyReactive,\n\t\tspan: { start: valueStart, end: valueEnd },\n\t};\n}\n\nfunction parseAttributeValue(status: ParseStatus): string {\n\tif (accept('\"', status)) {\n\t\tconst value = consumeUntil('\"', status);\n\t\taccept('\"', status);\n\t\treturn `\"${value}\"`;\n\t} else if (accept(\"'\", status)) {\n\t\tconst value = consumeUntil(\"'\", status);\n\t\taccept(\"'\", status);\n\t\treturn `'${value}'`;\n\t} else if (accept(\"{\", status)) {\n\t\tconst value = parseInlineScript(status);\n\t\treturn `{${value}}`;\n\t} else {\n\t\tlet value = consumeUntil(\" \\t\\r\\n>\", status);\n\t\t// Check whether we've landed at /> and if so, rewind\n\t\tif (status.source.substring(status.i - 1, status.i + 1) === \"/>\") {\n\t\t\tvalue = value.substring(0, value.length - 1);\n\t\t\tstatus.i -= 1;\n\t\t}\n\t\treturn value;\n\t}\n}\n","import type SourceSpan from \"../types/SourceSpan\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseText(status: ParseStatus, element: ElementNode): void {\n\t// Add a range for each reactive part of the text so that we can map them\n\t// back when building\n\tlet spans: SourceSpan[] = [];\n\n\t// Text ends at the next element, or at the next control statement, or at\n\t// the end of the render\n\t// But only if the control statement is after a newline, so we don't mess\n\t// with emails etc. This may need more finessing\n\tconst start = status.i;\n\tlet end = -1;\n\tfor (let j = status.i; j < status.source.length; j++) {\n\t\tif (status.source[j] === \"}\") {\n\t\t\t// That's the rendering done\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"{\") {\n\t\t\t// Skip reactive content\n\t\t\tconst reactiveStart = j + 1;\n\t\t\tlet level = 0;\n\t\t\tfor (let k = j; k < status.source.length; k++) {\n\t\t\t\tconst char = status.source[k];\n\t\t\t\tconst nextChar = status.source[k + 1];\n\t\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t\t// Skip one-line comments\n\t\t\t\t\tk = status.source.indexOf(\"\\n\", k);\n\t\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t\t// Skip block comments\n\t\t\t\t\tk = status.source.indexOf(\"*/\", k) + 1;\n\t\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t\t// Skip string contents\n\t\t\t\t\tk = endOfString(char, status.source, k);\n\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t// Skip template string contents\n\t\t\t\t\tk = endOfTemplateString(status.source, k);\n\t\t\t\t} else if (char === \"{\") {\n\t\t\t\t\tlevel += 1;\n\t\t\t\t} else if (char === \"}\") {\n\t\t\t\t\tlevel -= 1;\n\t\t\t\t\tif (level === 0) {\n\t\t\t\t\t\tj = k;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the source range\n\t\t\tspans.push({ start: reactiveStart, end: j });\n\t\t} else if (status.source[j] === \"<\") {\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"@\") {\n\t\t\t// Backtrack\n\t\t\tfor (let k = j - 1; k > status.i; k--) {\n\t\t\t\tif (status.source[k] === \"\\n\") {\n\t\t\t\t\tend = j;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (!isSpaceChar(status.source, k)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (end !== -1) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (end !== -1) {\n\t\tconst content = status.source.substring(start, end).trimEnd();\n\t\tconst spaceContent = status.source.substring(start + content.length, end);\n\t\tif (content || spaceContent) {\n\t\t\tconst previousNode = element.children[element.children.length - 1];\n\t\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\t\tpreviousNode.content += content + spaceContent;\n\t\t\t\tpreviousNode.spans.push(...spans);\n\t\t\t\t//previousNode.range.endIndex += content.length + spaceContent.length;\n\t\t\t\t// TODO: end char etc\n\t\t\t} else {\n\t\t\t\tconst text: TextNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\tcontent: content + spaceContent,\n\t\t\t\t\tspans,\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t}\n\t\t}\n\t\tstatus.i = end;\n\t} else {\n\t\tstatus.i += 1;\n\t}\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\n\n/**\n * Moves any child nodes that aren't already in a <fill> node into a default\n * <fill> node\n */\nexport default function slottifyChildNodes(node: ElementNode): void {\n\tconst nonFillNodes = node.children.filter((c) => !isFillNode(c));\n\t// TODO: Not if it's only spaces??\n\tif (nonFillNodes.length) {\n\t\tlet defaultFillNode = node.children.find(\n\t\t\t(n) => isFillNode(n) && !n.attributes.find((a) => a.name === \"name\"),\n\t\t) as ElementNode | undefined;\n\t\tif (!defaultFillNode) {\n\t\t\tdefaultFillNode = {\n\t\t\t\ttype: \"special\",\n\t\t\t\ttagName: \"fill\",\n\t\t\t\tattributes: [],\n\t\t\t\tchildren: nonFillNodes,\n\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t};\n\t\t\tnode.children.unshift(defaultFillNode);\n\t\t}\n\t}\n\tnode.children = node.children.filter((c) => isFillNode(c));\n}\n\nfunction isFillNode(n: TemplateNode): n is ElementNode {\n\treturn isSpecialNode(n) && n.tagName === \"fill\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Adds an error to the parse status\n *\n * @param status The parse status\n * @param message The error message to add\n * @param start (Optional) The start position of the error (defaults to the\n * current parse position)\n */\nexport default function addError(\n\tstatus: ParseStatus,\n\tmessage: string,\n\tstart: number = status.i,\n\tend: number = status.i,\n): void {\n\tlet startLine = 0;\n\tlet lastLineStart = 0;\n\tlet i = 0;\n\tfor (; i < start; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tstartLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet startChar = start - lastLineStart;\n\tlet endLine = startLine;\n\tfor (; i < end; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tendLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet endChar = end - lastLineStart;\n\tstatus.errors.push({\n\t\tmessage,\n\t\tstartIndex: start,\n\t\tstartLine,\n\t\tstartChar,\n\t\tendIndex: end,\n\t\tendLine,\n\t\tendChar,\n\t});\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport voidTags from \"../utils/voidTags\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseControl from \"./parseControl\";\nimport parseTag from \"./parseTag\";\nimport parseText from \"./parseText\";\nimport slottifyChildNodes from \"./slottifyChildNodes\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseElement(status: ParseStatus): ElementNode {\n\tconst current = status.components.at(-1);\n\tif (!current) throw new Error(\"No component in stack\");\n\n\tconst start = status.i;\n\n\tconst element = parseTag(status);\n\n\tif (element.tagName.startsWith(\"/\")) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${element.tagName.substring(1)}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length,\n\t\t);\n\t\treturn element;\n\t}\n\n\tif (voidTags.includes(element.tagName)) {\n\t\tcheckVoidElement(status, element);\n\t}\n\n\tif (!element.selfClosed && !voidTags.includes(element.tagName)) {\n\t\tstatus.stack.push(element);\n\n\t\t// Get the children\n\t\twhile (status.i < status.source.length) {\n\t\t\taddSpaceElement(element, status);\n\t\t\tif (accept(\"}\", status, false)) {\n\t\t\t\t// That's the rendering done\n\t\t\t\tbreak;\n\t\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t\t// It's a comment, swallow it\n\t\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\t} else if (accept(\"@//\", status)) {\n\t\t\t\t// Swallow one-line comments\n\t\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t\t// Swallow block comments\n\t\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\t} else if (accept(\"</\", status, false)) {\n\t\t\t\t// It's a close tag, so we're done here\n\t\t\t\tif (checkCloseTag(status, element)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t\t// It's a child element\n\t\t\t\tconst child = parseElement(status);\n\t\t\t\telement.children.push(child);\n\t\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t\t// It's a control statement\n\t\t\t\tparseControl(status, element);\n\t\t\t} else {\n\t\t\t\t// It's text content\n\t\t\t\tparseText(status, element);\n\t\t\t}\n\t\t}\n\n\t\tstatus.stack.pop();\n\t}\n\n\t// If this is a component element, add a default <fill> node\n\t// HACK: For now, we just treat all tags starting with a capital as components\n\tif (/[A-Z]/.test(element.tagName[0])) {\n\t\telement.type = \"component\";\n\t\tslottifyChildNodes(element);\n\t}\n\n\tif (isSpecialNode(element)) {\n\t\tif (element.tagName === \"slot\") {\n\t\t\t// If this is a <slot> element, add a <fill> node for its fallback\n\t\t\t// content. Anchors will be created for <slot> nodes and fragments will\n\t\t\t// be created for the <fill> content\n\t\t\tslottifyChildNodes(element);\n\n\t\t\t// Add it to the component's slots collection\n\t\t\tcurrent.slotProps ??= [];\n\t\t\tcurrent.slotProps.push(element.attributes.find((a) => a.name === \"name\")?.name ?? \"default\");\n\t\t} else if (element.tagName === \"fill\") {\n\t\t\tconst fillSource = status.source.substring(start, status.i);\n\t\t\telement.hasSlotProps = /\\$sprops\\b/.test(fillSource);\n\t\t} else if (element.tagName === \"@component\") {\n\t\t\tconst selfAttribute = element.attributes.find((a) => a.name === \"self\");\n\t\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\t\telement.type = \"component\";\n\t\t\t\tslottifyChildNodes(element);\n\n\t\t\t\tconst selfValue = selfAttribute.value;\n\t\t\t\tconst replace: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [element],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\t\t\t\tconst replaceGroup: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace group\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [replace],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\n\t\t\t\treturn replaceGroup as any;\n\t\t\t} else {\n\t\t\t\taddError(\n\t\t\t\t\tstatus,\n\t\t\t\t\t\"@component element must have a self attribute\",\n\t\t\t\t\tstart,\n\t\t\t\t\tstart + element.tagName.length + 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!element.closed && !voidTags.includes(element.tagName)) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unclosed non-void element: ${element.tagName}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn element;\n}\n\nfunction checkVoidElement(status: ParseStatus, element: ElementNode) {\n\tlet i = status.i;\n\n\tconsumeSpace(status);\n\tif (accept(\"</\", status)) {\n\t\tconsumeSpace(status);\n\t\tif (accept(element.tagName, status)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Closed void element: ${element.tagName}`,\n\t\t\t\ti,\n\t\t\t\ti + element.tagName.length + 1,\n\t\t\t);\n\t\t\tconsumeSpace(status);\n\t\t\taccept(\">\", status);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tstatus.i = i;\n}\n\nfunction checkCloseTag(status: ParseStatus, element: ElementNode) {\n\tconst start = status.i;\n\n\taccept(\"</\", status);\n\tconsumeSpace(status);\n\tlet snailed = accept(\"@\", status);\n\tlet closingTagName = consumeAlphaNumeric(status);\n\tif (snailed) {\n\t\tclosingTagName = \"@\" + closingTagName;\n\t}\n\tconsumeSpace(status);\n\taccept(\">\", status);\n\n\tlet found = false;\n\tfor (let i = status.stack.length - 1; i >= 0; i--) {\n\t\tif (closingTagName === status.stack[i].tagName) {\n\t\t\tstatus.stack[i].closed = true;\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${closingTagName} (expected ${element.tagName})`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn found;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type OperationType from \"../types/nodes/OperationType\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isControlNode from \"../utils/isControlNode\";\nimport trimMatched from \"../utils/trimMatched\";\nimport trimStart from \"../utils/trimStart\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseElement from \"./parseElement\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nconst controlOperations = [\n\t\"@if\",\n\t\"@else\",\n\t\"@for\",\n\t\"@key\",\n\t\"@switch\",\n\t\"@case\",\n\t\"@default\",\n\t\"@await\",\n\t\"@then\",\n\t\"@catch\",\n\t\"@replace\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nconst standaloneOperations = [\n\t\"@key\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nexport default function parseControl(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n): void {\n\tconst node = parseControlOpen(status);\n\tif (!node) {\n\t\treturn;\n\t}\n\n\t// Some operations don't have children\n\tif (standaloneOperations.includes(node.operation)) {\n\t\twrangleControlNode(node, parentNode);\n\t\treturn;\n\t}\n\n\t// Get the children\n\twhile (status.i < status.source.length) {\n\t\taddSpaceElement(node, status);\n\t\tif (accept(\"}\", status)) {\n\t\t\t// It's the end of the control block, so we're done here\n\t\t\tbreak;\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// It's a child element\n\t\t\tconst child = parseElement(status);\n\t\t\tnode.children.push(child);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// It's a nested control\n\t\t\tparseControl(status, node);\n\t\t} else if (accept(\"case\", status, false) || accept(\"key\", status, false)) {\n\t\t\t// `case` and `key` can be bare in a control block\n\t\t\tparseControl(status, node);\n\t\t} else {\n\t\t\t// Can't have text content in control blocks\n\t\t\tconst char = status.source[status.i];\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Unexpected token in control block: ${char}`,\n\t\t\t\tstatus.i,\n\t\t\t\t// TODO: Should probably go until a boundary\n\t\t\t\tstatus.i + 1,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twrangleControlNode(node, parentNode);\n\n\tparseControlBranches(status, parentNode);\n}\n\nfunction parseControlOpen(status: ParseStatus): ControlNode | null {\n\tconst start = status.i;\n\tlet statementStart = start;\n\n\tlet operation = \"\";\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (\n\t\t\t(isSpaceChar(status.source, status.i) && operation !== \"@async\") ||\n\t\t\t(accept(\":\", status) && operation === \"default\") ||\n\t\t\t(accept(\".\", status) && operation === \"@console\") ||\n\t\t\t(accept(\"(\", status, false) && operation === \"@html\")\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\toperation += char;\n\t}\n\n\t// Some operations (else etc) don't start with an @\n\tif (!operation.startsWith(\"@\")) {\n\t\toperation = \"@\" + operation;\n\t} else {\n\t\tstatementStart++;\n\t}\n\n\tlet statement = \"\";\n\tif (controlOperations.includes(operation)) {\n\t\tstatement = parseControlStatement(start, operation, status);\n\n\t\t// Special processing for functions -- read until the closing brace\n\t\tif (operation === \"@function\" || operation === \"@async function\") {\n\t\t\tstatement += ` {${parseInlineScript(status)}}`;\n\t\t\taccept(\"}\", status);\n\t\t}\n\n\t\t// Special processing for replace and html\n\t\tif (operation === \"@replace\" || operation === \"@html\") {\n\t\t\tstatement = trimMatched(statement.substring(statement.indexOf(\"(\")).trim(), \"(\", \")\");\n\t\t}\n\t} else {\n\t\t// TODO: Should probably advance until a closing brace or a newline\n\t\taddError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"control\",\n\t\toperation: operation as OperationType,\n\t\tstatement,\n\t\tchildren: [],\n\t\tspan: { start: statementStart, end: status.i },\n\t};\n}\n\nfunction parseControlStatement(start: number, operation: string, status: ParseStatus) {\n\tlet parenCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tif (accept(\"(\", status)) {\n\t\t\tparenCount += 1;\n\t\t} else if (accept(\")\", status)) {\n\t\t\tparenCount -= 1;\n\t\t} else if (\n\t\t\taccept(\"{\", status) ||\n\t\t\t(accept(\"\\n\", status) && standaloneOperations.includes(operation))\n\t\t) {\n\t\t\tif (parenCount === 0) {\n\t\t\t\treturn trimStart(status.source.substring(start, status.i - 1).trim(), \"@\");\n\t\t\t}\n\t\t} else if (accept(\"//\", status)) {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"/*\", status)) {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept('\"', status) || accept(\"'\", status)) {\n\t\t\t// Skip string contents\n\t\t\tlet char = status.source[status.i - 1];\n\t\t\tstatus.i = endOfString(char, status.source, status.i - 1) + 1;\n\t\t} else if (accept(\"`\", status)) {\n\t\t\t// Skip template string contents\n\t\t\tstatus.i = endOfTemplateString(status.source, status.i - 1) + 1;\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n\n/**\n * Groups the control node into the correct parent e.g. if/else into an if group\n * @param node The control node\n * @param parentNode The parent node\n */\nfunction wrangleControlNode(node: ControlNode, parentNode: RootNode | ElementNode | ControlNode) {\n\t// Group\n\t// * if/else into an if group\n\t// * for into a for group\n\t// * switch into a switch group (cases will have the correct parent)\n\t// * await/then/catch into an await group\n\t// * replace into a replace group\n\t// * html into a html group\n\tif (node.operation === \"@if\") {\n\t\tconst ifGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@if group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(ifGroup);\n\t} else if (node.operation === \"@else\") {\n\t\tif (/^else\\s+if/.test(node.statement)) {\n\t\t\tnode.operation = \"@else if\";\n\t\t}\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@if group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@for\") {\n\t\tconst forGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@for group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(forGroup);\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@switch\") {\n\t\tnode.operation = \"@switch group\";\n\t\tparentNode.children.push(node);\n\t} else if (node.operation === \"@await\") {\n\t\tconst awaitGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@await group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(awaitGroup);\n\t} else if (node.operation === \"@then\" || node.operation === \"@catch\") {\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@await group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (node.operation === \"@replace\") {\n\t\tconst replaceGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@replace group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(replaceGroup);\n\t} else if (node.operation === \"@html\") {\n\t\tconst htmlGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@html group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(htmlGroup);\n\t} else {\n\t\tparentNode.children.push(node);\n\t}\n}\n\n/**\n * Parses control branches that don't start with an @ symbol e.g. else or case\n * @param status The parse status\n * @param parentNode The parent node\n */\nfunction parseControlBranches(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n) {\n\t// Look ahead and see if we have another control statement\n\t// NOTE: We could be more strict here (e.g. we could check that an else is\n\t// after an if), but for now we are just leaving it to the JS parser\n\tlet gotAnotherBranch = true;\n\twhile (gotAnotherBranch) {\n\t\tlet start = status.i;\n\t\tstatus.i += 1;\n\t\tconsumeSpace(status);\n\t\tif (\n\t\t\taccept(\"else\", status, false) ||\n\t\t\taccept(\"case\", status, false) ||\n\t\t\taccept(\"default\", status, false) ||\n\t\t\taccept(\"then\", status, false) ||\n\t\t\taccept(\"catch\", status, false)\n\t\t) {\n\t\t\tparseControl(status, parentNode);\n\t\t} else {\n\t\t\tgotAnotherBranch = false;\n\t\t\tstatus.i = start;\n\t\t}\n\t}\n}\n","import type TextNode from \"../types/nodes/TextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseControl from \"./parseControl\";\nimport parseElement from \"./parseElement\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseMarkup(status: ParseStatus, source: string): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\twhile (status.i < source.length) {\n\t\tif (accept(\"}\", status, false)) {\n\t\t\t// That's the rendering done\n\t\t\treturn;\n\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t// It's a comment, swallow it\n\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (isSpaceChar(status.source, status.i)) {\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\t//const start = status.i;\n\t\t\tconst space = consumeSpace(status);\n\t\t\tconst text: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent: space,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tcurrent.markup.children.push(text);\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// Parse the element\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\tconst element = parseElement(status);\n\t\t\tcurrent.markup.children.push(element);\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// Parse the control\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\tparseControl(status, current.markup);\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n}\n","// Adapted from https://github.com/sveltejs/svelte\n\nconst returnRegex = /\\r/g;\n\nexport default function hash(input: string): string {\n\tinput = input.replace(returnRegex, \"\");\n\tlet hash = 5381;\n\tlet i = input.length;\n\twhile (i--) {\n\t\thash = ((hash << 5) - hash) ^ input.charCodeAt(i);\n\t}\n\treturn (hash >>> 0).toString(36);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport addError from \"./addError\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string and if not, adds an error to the parse status\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function expect(value: string, status: ParseStatus, advance = true): boolean {\n\tif (status.i < status.source.length) {\n\t\tif (status.source.substring(status.i, status.i + value.length) == value) {\n\t\t\tstatus.i += advance ? value.length : 0;\n\t\t\treturn true;\n\t\t} else {\n\t\t\taddError(status, `Expected ${value}`);\n\t\t}\n\t} else {\n\t\taddError(status, \"Expected token\");\n\t}\n\treturn false;\n}\n","import type Attribute from \"../types/styles/Attribute\";\nimport type StyleBlock from \"../types/styles/StyleBlock\";\nimport hash from \"../utils/hash\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\nimport expect from \"./utils/expect\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseStyles(source: string, status: ParseStatus): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tcurrent.style = {\n\t\tglobal: false,\n\t\tblocks: [],\n\t\thash: hash(source),\n\t};\n\n\tconst styleStatus: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\twhile (styleStatus.i < styleStatus.source.length) {\n\t\tif (isSpaceChar(styleStatus.source, styleStatus.i)) {\n\t\t\tconsumeSpace(styleStatus);\n\t\t} else {\n\t\t\tconst block = parseStyleBlock(styleStatus);\n\t\t\tif (block) {\n\t\t\t\tcurrent.style.blocks.push(block);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.errors = status.errors.concat(styleStatus.errors);\n}\n\nfunction parseStyleBlock(status: ParseStatus): StyleBlock | undefined {\n\tconst selector = consumeUntil(\"{\", status).trim();\n\tif (expect(\"{\", status)) {\n\t\tconst block: StyleBlock = {\n\t\t\tselector,\n\t\t\tattributes: [],\n\t\t\tchildren: [],\n\t\t};\n\t\tconsumeSpace(status);\n\t\twhile (status.source[status.i] !== \"}\") {\n\t\t\t// HACK: Is it an attribute or a child block?\n\t\t\tlet nextColon = status.source.indexOf(\":\", status.i);\n\t\t\tif (nextColon === -1) nextColon = status.source.length;\n\t\t\tlet nextOpenBrace = status.source.indexOf(\"{\", status.i);\n\t\t\tif (nextOpenBrace === -1) nextOpenBrace = status.source.length;\n\t\t\tif (nextColon < nextOpenBrace) {\n\t\t\t\tconst attribute = parseStyleAttribute(status);\n\t\t\t\tblock.attributes.push(attribute);\n\t\t\t} else if (nextOpenBrace < nextColon) {\n\t\t\t\tconst child = parseStyleBlock(status);\n\t\t\t\tif (child) {\n\t\t\t\t\tblock.children.push(child);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn block;\n\t\t\t}\n\t\t\tconsumeSpace(status);\n\t\t}\n\t\taccept(\"}\", status);\n\n\t\treturn block;\n\t}\n}\n\nfunction parseStyleAttribute(status: ParseStatus): Attribute {\n\tconst name = consumeUntil(\":\", status).trim();\n\taccept(\":\", status);\n\tconst value = consumeUntil(\";\", status).trim();\n\taccept(\";\", status);\n\treturn {\n\t\tname,\n\t\tvalue,\n\t};\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isComponentNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"component\";\n}\n","import type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isParentNode(node: TemplateNode): node is ParentNode {\n\treturn \"children\" in node;\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type StyleBlock from \"../types/styles/StyleBlock\";\nimport isComponentNode from \"../utils/isComponentNode\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isParentNode from \"../utils/isParentNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\n\nexport default function scopeStyles(status: ParseStatus): void {\n\tlet selectors: string[] = [];\n\tfor (let component of status.components) {\n\t\tif (component.style && component.markup) {\n\t\t\tfor (let block of component.style.blocks) {\n\t\t\t\tcollectStyleSelectors(block, selectors);\n\t\t\t}\n\t\t\tscopeStylesOnNode(component.markup, selectors);\n\t\t}\n\t}\n}\n\nfunction scopeStylesOnNode(node: TemplateNode, selectors: string[]) {\n\tif (isElementNode(node) || isComponentNode(node)) {\n\t\tnode.scopeStyles =\n\t\t\tselectors.includes(node.tagName) ||\n\t\t\tnode.attributes.find((a) => {\n\t\t\t\tif (a.name === \"class\" && a.reactive) {\n\t\t\t\t\t// Any reactivity in a class attribute makes it scoped,\n\t\t\t\t\t// because we can't tell what's going on in there\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (a.name === \"id\" && a.value) {\n\t\t\t\t\tif (selectors.includes(`#${trimQuotes(a.value)}`)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t} else if (a.name === \"class\" && a.value) {\n\t\t\t\t\tfor (let classname of trimQuotes(a.value).split(/\\s+/)) {\n\t\t\t\t\t\tif (selectors.includes(`.${classname}`)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) !== undefined;\n\t}\n\n\tif (isParentNode(node)) {\n\t\tfor (let child of node.children) {\n\t\t\tscopeStylesOnNode(child, selectors);\n\t\t}\n\t}\n}\n\nfunction collectStyleSelectors(block: StyleBlock, selectors: string[]) {\n\t// HACK: We should be collecting the actual selectors and then checking\n\t// attributes, parents, children, siblings etc\n\tfor (let s of block.selector.split(/[\\s*,>+~]/)) {\n\t\tselectors.push(s);\n\t}\n}\n","import type TemplateComponent from \"../../types/TemplateComponent\";\nimport type ParseResult from \"../types/ParseResult\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport parseMarkup from \"./parseMarkup\";\nimport parseStyleElement from \"./parseStyles\";\nimport scopeStyles from \"./scopeStyles\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseCode(source: string): ParseResult {\n\tconst status: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\tfor (status.i; status.i < source.length; status.i++) {\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (status.source[status.i] === \"{\") {\n\t\t\tstatus.level += 1;\n\t\t} else if (status.source[status.i] === \"}\") {\n\t\t\tstatus.level -= 1;\n\t\t\tif (status.level === 0) {\n\t\t\t\tparseComponentEnd(status);\n\t\t\t}\n\t\t} else if (accept(\"function\", status)) {\n\t\t\t// If the function name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"const\", status)) {\n\t\t\t// If it's a function and its name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tconst start = status.i;\n\t\t\t\t\tconsumeAlphaNumeric(status);\n\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\tif (accept(\"=\", status)) {\n\t\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\t\tif (accept(\"(\", status, false)) {\n\t\t\t\t\t\t\tstatus.i = start;\n\t\t\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"export\", status)) {\n\t\t\t// If it's an anonymous default export function, parse it as a component\n\t\t\tconst start = status.i;\n\t\t\tif (\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"default\", status) &&\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"(\", status, false)\n\t\t\t) {\n\t\t\t\tparseComponentStart(status);\n\t\t\t} else {\n\t\t\t\tstatus.i = start;\n\t\t\t}\n\t\t} else if (accept(\"@render\", status, false)) {\n\t\t\tparseComponentRender(status);\n\t\t} else if (accept(\"@head\", status, false)) {\n\t\t\tparseComponentHead(status);\n\t\t} else if (accept(\"@style\", status, false)) {\n\t\t\tparseComponentStyle(status);\n\t\t}\n\t}\n\tstatus.script.push({\n\t\tscript: source.substring(status.marker, source.length),\n\t\tspan: { start: status.marker, end: source.length },\n\t});\n\n\tscopeStyles(status);\n\n\tconst ok = !status.errors.length;\n\tif (!ok) {\n\t\tstatus.errors = status.errors.sort((a, b) => a.startIndex - b.startIndex);\n\t}\n\n\treturn {\n\t\tok,\n\t\terrors: status.errors,\n\t\ttemplate: ok\n\t\t\t? {\n\t\t\t\t\timports: status.imports,\n\t\t\t\t\tscript: status.script,\n\t\t\t\t\tcomponents: status.components,\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n}\n\nfunction parseComponentStart(status: ParseStatus) {\n\tlet source = status.source.substring(status.marker, status.i);\n\tlet exported = /export\\s+(default\\s+)*(function\\s+|const\\s+)*$/.test(source);\n\tlet def = /export\\s+default\\s+(function\\s+|const\\s+)*$/.test(source);\n\tlet isConst = /const\\s+$/.test(source);\n\tlet isAnon = /export default\\s+$/.test(source);\n\n\tlet componentStart = status.i;\n\tlet name = consumeAlphaNumeric(status);\n\n\tconst current: TemplateComponent = {\n\t\tstart: componentStart,\n\t\tname,\n\t\texported,\n\t\tdefault: def,\n\t};\n\tstatus.components.push(current);\n\n\t// Look for /** ... */ documentation comments\n\tlet presource = source.substring(0, status.i).trimEnd();\n\tlet lastNewline = presource.lastIndexOf(\"\\n\");\n\tif (lastNewline !== -1) {\n\t\tpresource = presource.substring(0, lastNewline).trimEnd();\n\t\tif (presource.endsWith(\"*/\")) {\n\t\t\tfor (let i = presource.length; i >= 0; i--) {\n\t\t\t\tif (presource.substring(i, i + 3) === \"/**\") {\n\t\t\t\t\tcurrent.documentation = presource.substring(i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlet start = -1;\n\tlet end = -1;\n\tlet level = 0;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (char === \"(\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t}\n\t\t} else if (char === \")\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, start),\n\t\tspan: { start: status.marker, end: start },\n\t});\n\tstatus.script.push({ script: \"/* @params */\", span: { start, end } });\n\n\tcurrent.params = status.source.substring(start, end);\n\tif (current.params.trim().length === 0) {\n\t\tcurrent.params = undefined;\n\t}\n\n\t// Look for a params type or interface\n\t// Might need to get fancier with this\n\tconst paramsMatch = current.params?.match(/\\$props:\\s*([$A-Za-z0-9]+)/);\n\tif (paramsMatch) {\n\t\tlet propsTypeName = paramsMatch[1];\n\t\tlet propsTypeStart = status.source.search(new RegExp(`interface\\\\s+${propsTypeName}`));\n\t\tif (propsTypeStart === -1) {\n\t\t\tpropsTypeStart = status.source.search(new RegExp(`type\\\\s+${propsTypeName}`));\n\t\t}\n\t\tif (propsTypeStart !== -1) {\n\t\t\tlet bracesStart = status.source.indexOf(\"{\", propsTypeStart);\n\t\t\tif (bracesStart !== -1) {\n\t\t\t\tconst status2: ParseStatus = {\n\t\t\t\t\tsource: status.source,\n\t\t\t\t\ti: bracesStart + 1,\n\t\t\t\t\tmarker: 0,\n\t\t\t\t\tlevel: 0,\n\t\t\t\t\timports: [],\n\t\t\t\t\tscript: [],\n\t\t\t\t\tcomponents: [],\n\t\t\t\t\tstack: [],\n\t\t\t\t\terrors: [],\n\t\t\t\t};\n\t\t\t\tconst propsType = parseInlineScript(status2);\n\t\t\t\tif (propsType) {\n\t\t\t\t\tcurrent.propsType = `${status.source.substring(propsTypeStart, bracesStart)}{${propsType}}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.marker = end;\n\tstatus.i = status.marker;\n\n\taccept(\")\", status);\n\tconsumeSpace(status);\n\n\tif (isConst || isAnon) {\n\t\taccept(\"=>\", status);\n\t\tconsumeSpace(status);\n\t}\n\n\taccept(\"{\", status);\n\tstatus.level += 1;\n\n\t// Sneak in a function type\n\tconst postFunctionChunk = {\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t};\n\tif (/\\)\\s+\\{/.test(postFunctionChunk.script)) {\n\t\tpostFunctionChunk.script = \") /* @return_type */ {\";\n\t}\n\tstatus.script.push(postFunctionChunk);\n\n\tstatus.script.push({\n\t\tscript: \"/* @start */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tstatus.marker = status.i;\n\tconst space = consumeSpace(status);\n\tstatus.script.push({\n\t\tscript: space,\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.marker = status.i;\n\tstatus.i -= 1;\n}\n\nfunction parseComponentRender(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.markup) {\n\t\taddError(status, `Multiple @render sections`, status.i, status.i + \"@render\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @render */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@render\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentHead(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.head) {\n\t\taddError(status, `Multiple @head sections`, status.i, status.i + \"@head\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @head */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// HACK: add a new component, and move its markup into the current\n\t// component's head section after\n\tstatus.components.push({\n\t\tstart: status.i,\n\t});\n\n\taccept(\"@head\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\t// Swap render and markup\n\tconst head = status.components.pop();\n\tcurrent.head = head?.markup;\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentStyle(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.style) {\n\t\taddError(status, `Multiple @style sections`, status.i, status.i + \"@style\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @style */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tlet start = -1;\n\tlet end = status.source.length;\n\tlet level = 0;\n\t// HACK: strip the comments out of styles only\n\tlet styleSource = \"\";\n\tfor (; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tconst nextChar = status.source[status.i + 1];\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t// Skip string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfString(char, status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"`\") {\n\t\t\t// Skip interpolated string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfTemplateString(status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else {\n\t\t\tif (start !== -1) {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.i = start;\n\tparseStyleElement(styleSource.trim(), status);\n\n\tstatus.i = end + 2;\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentEnd(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.script.push({\n\t\tscript: \"/* @end */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// Get all usages of $props.name and $props[\"name\"]\n\t// Get all usages of $context.name and $context[\"name\"]\n\tconst componentSource = status.source.substring(current.start || 0, status.i);\n\tcurrent.props = getPropsUsage(componentSource);\n\tcurrent.contextProps = getContextUsage(componentSource);\n\n\t// If the top-level element is <html> and there is whitespace after it,\n\t// delete the whitespace, as that's what browsers seem to do. It may be\n\t// better instead to create whitespace if we don't find it when hydrating...\n\tif (\n\t\tcurrent.markup &&\n\t\tisElementNode(current.markup.children[0]) &&\n\t\tcurrent.markup.children[0].tagName === \"html\" &&\n\t\tisSpaceNode(current.markup.children[0].children[0])\n\t) {\n\t\tcurrent.markup.children.splice(1, 1);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction getPropsUsage(source: string): string[] | undefined {\n\tconst propsMatches = source.matchAll(/\\$props\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst props: string[] = [];\n\tfor (let match of propsMatches) {\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!props.includes(name)) {\n\t\t\tprops.push(name);\n\t\t}\n\t}\n\treturn props.length ? props : undefined;\n}\n\nfunction getContextUsage(source: string): string[] | undefined {\n\tconst contextsMatches = source.matchAll(/\\$context\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst contexts: string[] = [];\n\tfor (let match of contextsMatches) {\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!contexts.includes(name)) {\n\t\t\tcontexts.push(name);\n\t\t}\n\t}\n\treturn contexts.length ? contexts : undefined;\n}\n\nfunction consumeScriptComments(status: ParseStatus): boolean {\n\tconst char = status.source[status.i];\n\tconst nextChar = status.source[status.i + 1];\n\tif (char === \"/\" && nextChar === \"/\") {\n\t\t// Skip one-line comments\n\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\treturn true;\n\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t// Skip block comments\n\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\treturn true;\n\t} else if (char === '\"' || char === \"'\") {\n\t\t// Skip string contents\n\t\tstatus.i = endOfString(char, status.source, status.i);\n\t\treturn true;\n\t} else if (char === \"`\") {\n\t\t// Skip interpolated string contents\n\t\tstatus.i = endOfTemplateString(status.source, status.i);\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import parseCode from \"./parse/parseCode\";\nimport type ParseResult from \"./types/ParseResult\";\n\n/**\n * Parses source code into a component template\n *\n * @param source The source code\n *\n * @returns A result indicating whether parsing was ok, and if so, containing\n * the component template's parts such as script, markup and styles\n */\nexport default function parse(source: string): ParseResult {\n\treturn parseCode(source);\n}\n"],"mappings":";AAAA,SAAwB,oBAAoB,SAAiB,OAAuB;CAEnF,IAAI,QAAQ;AACZ,MAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,QAAQ,QAAQ,IAC3C,KAAI,QAAQ,OAAO,OAAO,QAAQ,IAAI,OAAO,QAAQ,UAAU,EAC9D,QAAO;UACG,QAAQ,OAAO,QAAQ,QAAQ,KAAK,QAAQ,IAAI,OAAO,KACjE,UAAS;UACC,QAAQ,OAAO,OAAO,QAAQ,EACxC,UAAS;AAGX,QAAO,QAAQ;;;;;ACVhB,IAAqB,UAArB,MAA6B;CAC5B,QAA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AED,KAAK;AACJ,8BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,QACA;AACD;EAED,KAAK;AACJ,2BACC,UACA,MACA,MACA,QACA,GACA,UACA,WACA,QACA;AACD;EAED,KAAK;AACJ,8BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,QACA;AACD;EAED,QAEC,OAAM,IAAI,MAAM,sBAAsB,KAAK,OAAO;;;AAKrD,SAAS,wBACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,MAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,SAAS,CAC7C,qBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,QACA;;AAIH,SAAS,2BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,SAAQ,KAAK,WAAb;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;AAEJ,sCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UATiB,KAAK,UAAU,UAAU,EAAE,CAAC,QAAQ,UAAU,GAAG,EAWlE,QACA;AACD;EAED;AACC,QAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,SAAS,CAC7C,qBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,QACA;AAEF;;;AAKH,SAAS,6BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,oCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,QACA,QACA;;AAGF,SAAS,gBAAgB,MAAmB;AAE3C,SAAQ,KAAK,QAAQ,aAAa,EAAlC;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO,OAAO,KAAK,QAAQ,UAAU,GAAG,EAAE,CAAC,aAAa,GAAG,KA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js","names":["#mapped","#text","i","#space","start","fragments: Fragment[]","spans: SourceSpan[]","offsets: number[]","lengths: number[]","props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets: number[];\n\t\t\tlengths: number[];\n\t\t}[]","runs: string[]","bindingRuns: string[]","forVarNames: string[]","maybeAppend","buildElementAttributes","props: { name: string; value: string; span: SourceSpan }[]","runs: string[]","offsets: number[]","lengths: number[]","importsMap: Record<string, string>","importsMap","status: BuildStatus","selectors: string[]","props: { name: string; value: string }[]","voidTags: string[]","voidTags","attributes: string[]","importsMap: Record<string, string>","status: BuildServerStatus","map: SourceMapping[]","space: TextNode","attributes: Attribute[]","value: string | undefined","spans: SourceSpan[]","text: TextNode","voidTags","ifGroup: ControlNode","forGroup: ControlNode","awaitGroup: ControlNode","replaceGroup: ControlNode","htmlGroup: ControlNode","text: TextNode","hash","styleStatus: ParseStatus","block: StyleBlock","selectors: string[]","status: ParseStatus","current: TemplateComponent","start","props: string[]","contexts: string[]"],"sources":["../src/compile/utils/endOfTemplateString.ts","../src/compile/utils/Builder.ts","../src/compile/build/client/addMappedText.ts","../src/compile/build/client/addPopDevBoundary.ts","../src/compile/build/client/addPushDevBoundary.ts","../src/compile/types/comments.ts","../src/compile/utils/isReactive.ts","../src/compile/utils/trimQuotes.ts","../src/compile/build/client/buildFragmentText.ts","../src/compile/utils/isSpecialNode.ts","../src/compile/build/utils/nextVarName.ts","../src/compile/build/client/addMappedTextWithOffsets.ts","../src/compile/build/client/buildAddFragment.ts","../src/compile/parse/utils/isSpaceChar.ts","../src/compile/parse/utils/isSpace.ts","../src/compile/utils/isControlNode.ts","../src/compile/utils/isElementNode.ts","../src/compile/utils/isTextNode.ts","../src/compile/build/client/buildFragment.ts","../src/compile/build/client/replaceForVarNames.ts","../src/compile/build/client/buildRun.ts","../src/compile/utils/endOfString.ts","../src/compile/build/client/getAttributeOffsets.ts","../src/compile/build/client/buildComponentNode.ts","../src/compile/utils/trimMatched.ts","../src/compile/build/client/buildAwaitNode.ts","../src/compile/build/client/buildForNode.ts","../src/compile/build/client/buildHtmlNode.ts","../src/compile/build/client/buildIfNode.ts","../src/compile/build/client/buildReplaceNode.ts","../src/compile/build/client/buildScriptNode.ts","../src/compile/build/client/buildSwitchNode.ts","../src/compile/build/client/buildControlNode.ts","../src/compile/utils/trimEnd.ts","../src/compile/build/client/buildMount.ts","../src/compile/build/client/stashRun.ts","../src/compile/build/client/stashRunWithOffsets.ts","../src/compile/build/client/buildElementNode.ts","../src/compile/build/client/buildRootNode.ts","../src/compile/build/client/buildSlotNode.ts","../src/compile/build/client/buildSpecialNode.ts","../src/compile/build/client/buildTextNode.ts","../src/compile/build/client/buildNode.ts","../src/compile/build/client/buildCode.ts","../src/compile/build/client/buildStyles.ts","../src/compile/build/server/buildServerComponentNode.ts","../src/compile/build/server/buildServerAwaitNode.ts","../src/compile/build/server/buildServerForNode.ts","../src/compile/build/server/buildServerHtmlNode.ts","../src/compile/build/server/buildServerIfNode.ts","../src/compile/build/server/buildServerReplaceNode.ts","../src/compile/build/server/buildServerScriptNode.ts","../src/compile/build/server/buildServerSwitchNode.ts","../src/compile/build/server/buildServerControlNode.ts","../src/compile/utils/voidTags.ts","../src/compile/build/server/buildServerElementNode.ts","../src/compile/build/server/buildServerRootNode.ts","../src/compile/build/server/buildServerSlotNode.ts","../src/compile/build/server/buildServerSpecialNode.ts","../src/compile/build/server/buildServerTextNode.ts","../src/compile/build/server/buildServerNode.ts","../src/compile/build/server/buildServerCode.ts","../src/compile/build.ts","../src/compile/buildType.ts","../src/compile/utils/isSpaceNode.ts","../src/compile/parse/utils/accept.ts","../src/compile/parse/parseInlineScript.ts","../src/compile/utils/trimStart.ts","../src/compile/parse/utils/consumeSpace.ts","../src/compile/parse/addSpaceElement.ts","../src/compile/utils/isFullyReactive.ts","../src/compile/parse/utils/isAlphaNumericChar.ts","../src/compile/parse/utils/consumeAlphaNumeric.ts","../src/compile/parse/utils/consumeUntil.ts","../src/compile/parse/parseTag.ts","../src/compile/parse/parseText.ts","../src/compile/parse/slottifyChildNodes.ts","../src/compile/parse/utils/addError.ts","../src/compile/parse/parseElement.ts","../src/compile/parse/parseControl.ts","../src/compile/parse/parseMarkup.ts","../src/compile/utils/hash.ts","../src/compile/parse/utils/expect.ts","../src/compile/parse/parseStyles.ts","../src/compile/utils/isComponentNode.ts","../src/compile/utils/isParentNode.ts","../src/compile/parse/scopeStyles.ts","../src/compile/parse/parseCode.ts","../src/compile/parse.ts"],"sourcesContent":["export default function endOfTemplateString(content: string, start: number): number {\n\t// TODO: Recursively skip strings and comments inside the interpolated JS\n\tlet level = 0;\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === \"`\" && content[j - 1] !== \"\\\\\" && level === 0) {\n\t\t\treturn j;\n\t\t} else if (content[j] === \"{\" && (level > 0 || content[j - 1] === \"$\")) {\n\t\t\tlevel += 1;\n\t\t} else if (content[j] === \"}\" && level > 0) {\n\t\t\tlevel -= 1;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import endOfTemplateString from \"./endOfTemplateString\";\n\nexport default class Builder {\n\t#text = \"\";\n\t#space = 0;\n\t#mapped = false;\n\n\tlineMap: number[] = [];\n\n\tconstructor(mapped?: boolean) {\n\t\tthis.#mapped = mapped === true;\n\t}\n\n\tprepend(text: string): void {\n\t\t// TODO: adjust line map\n\t\tthis.#text = text + \"\\n\" + this.#text;\n\t}\n\n\tappend(text: string): void {\n\t\tif (this.#mapped) {\n\t\t\tthis.lineMap.push(this.#text.length);\n\t\t\tfor (let i = 0; i < text.length; i++) {\n\t\t\t\tif (text[i] === \"\\n\") {\n\t\t\t\t\tthis.lineMap.push(this.#text.length + i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#text += \"\\n\" + text;\n\t\t\treturn;\n\t\t}\n\n\t\tconst start = this.#text.length;\n\n\t\ttext = text.trim();\n\t\tlet i = 0;\n\t\t//let newline = !!text.length && !text.endsWith(\"\\n\");\n\n\t\twhile (i < text.length) {\n\t\t\t// Skip spaces\n\t\t\twhile (text[i] === \" \" || text[i] === \"\\t\") {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (text[i] === \";\") {\n\t\t\t\t// HACK: we just set ; to ignore the line\n\t\t\t\ti++;\n\t\t\t} else if (text[i] === \"\\n\") {\n\t\t\t\tthis.lineMap.push(start + i);\n\t\t\t\tthis.#text += \"\\n\";\n\t\t\t} else {\n\t\t\t\t// Maybe outdent\n\t\t\t\tif (text[i] === \"}\" || text[i] === \")\" || text[i] === \"]\") {\n\t\t\t\t\tthis.#space -= 1;\n\t\t\t\t}\n\n\t\t\t\t// Add indentation\n\t\t\t\tthis.#text += \"\\t\".repeat(Math.max(0, this.#space));\n\t\t\t\t// Add from text until the next newline or the end of text\n\t\t\t\tconst start = i;\n\t\t\t\twhile (i < text.length && text[i] !== \"\\n\") {\n\t\t\t\t\t// Just add backticked text as-is\n\t\t\t\t\tif (text[i] === \"`\") {\n\t\t\t\t\t\ti = endOfTemplateString(text, i);\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tconst line = text.substring(start, i + 1);\n\n\t\t\t\tif (line.startsWith(\"*\")) {\n\t\t\t\t\t// JSDoc\n\t\t\t\t\tthis.#text += \" \";\n\t\t\t\t}\n\t\t\t\tthis.#text += line;\n\n\t\t\t\t// Maybe indent\n\t\t\t\tif (text[i - 1] === \"{\" || text[i - 1] === \"(\" || text[i - 1] === \"[\") {\n\t\t\t\t\tthis.#space += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\tif (!this.#text.endsWith(\"\\n\\n\")) {\n\t\t\tthis.#text += \"\\n\";\n\t\t}\n\t}\n\n\ttoString(): string {\n\t\treturn this.#text;\n\t}\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedText(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet start = b.toString().length + preText.length;\n\t\tb.append(preText + text + postText);\n\t\tlet end = start + text.length;\n\t\tstatus.map.push({\n\t\t\tscript: text,\n\t\t\tsource: span,\n\t\t\tcompiled: { start, end },\n\t\t});\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPopDevBoundary(status: BuildStatus, b: Builder): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_pop_dev_bound\");\n\t\tb.append(\"\");\n\t\tb.append(`t_pop_dev_bound();`);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPushDevBoundary(\n\ttype: \"component\" | \"region\" | \"run\" | \"watch\" | \"control\" | \"branch\",\n\tname: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_push_dev_bound\");\n\n\t\t// Ensure the name is wrapped with quotes, and internal quotes are escaped\n\t\tconst nameHasQuotes =\n\t\t\t(name.startsWith(\"'\") && name.endsWith(\"'\")) ||\n\t\t\t(name.startsWith('\"') && name.endsWith('\"')) ||\n\t\t\t(name.startsWith(\"`\") && name.endsWith(\"`\"));\n\t\tif (nameHasQuotes) {\n\t\t\tconst quote = name[0];\n\t\t\tname = quote + name.substring(1, name.length - 1).replaceAll(quote, \"\\\\\" + quote) + quote;\n\t\t} else {\n\t\t\tname = `\"${name.replaceAll('\"', '\\\\\"')}\"`;\n\t\t}\n\n\t\tb.append(`t_push_dev_bound(\"${type}\", ${name});`);\n\t\tb.append(\"\");\n\t}\n}\n","const ANCHOR_COMMENT = \"<!>\";\nconst HYDRATION_START_COMMENT = \"<![>\";\nconst HYDRATION_END_COMMENT = \"<!]>\";\nconst HYDRATION_BREAK_COMMENT = \"<!^>\";\n\nexport { ANCHOR_COMMENT, HYDRATION_START_COMMENT, HYDRATION_END_COMMENT, HYDRATION_BREAK_COMMENT };\n","/**\n * Checks whether the supplied string is fully or partially reactive (i.e. contains braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully or partially reactive\n */\nexport default function isReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.includes(\"{\") && text.includes(\"}\");\n}\n","/**\n * Trims matching quotes from the start and end of the supplied text\n *\n * @param text The text to trim\n *\n * @returns The text without the quotes at the start or the end\n */\nexport default function trimQuotes(text: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (\n\t\t(text[start] === \"'\" && text[end - 1] === \"'\") ||\n\t\t(text[start] === '\"' && text[end - 1] === '\"') ||\n\t\t(text[start] === \"`\" && text[end - 1] === \"`\")\n\t) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import { ANCHOR_COMMENT } from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isReactive from \"../../utils/isReactive\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Builds the HTML template text for all of the fragments in a component\n */\nexport default function buildFragmentText(\n\tnode: RootNode | ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tconst fragments: Fragment[] = [];\n\tbuildNodeFragmentText(node, status, fragments);\n\n\tif (fragments.length) {\n\t\tb.append(`const t_fragments: DocumentFragment[] = [];`);\n\t}\n}\n\nfunction buildNodeFragmentText(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment?: Fragment,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootFragmentText(node as RootNode, status, fragments);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlFragmentText(node as ControlNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\t// NOTE: We don't support nested SVG for now\n\t\t\tlet ns = (node as ElementNode).tagName === \"svg\";\n\t\t\tif (ns) status.ns = true;\n\t\t\tbuildElementFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tif (ns) status.ns = false;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tconst content = (node as TextNode).content;\n\t\t\tif (currentFragment) {\n\t\t\t\tcurrentFragment.text += isReactive(content) ? \"#\" : content;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildRootFragmentText(node: RootNode, status: BuildStatus, fragments: Fragment[]) {\n\tnode.fragment = {\n\t\tnumber: fragments.length,\n\t\ttext: \"\",\n\t\tns: status.ns,\n\t\teffects: [],\n\t\tevents: [],\n\t\tanimations: [],\n\t};\n\tfragments.push(node.fragment);\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t}\n}\n\nfunction buildControlFragmentText(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\t// Add a placeholder if it's a branching control node\n\t\t\t//if (!node.singleRooted) {\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\t//}\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// Add a new fragment if it's a control branch and it has children\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildComponentFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tcurrentFragment.text += ANCHOR_COMMENT;\n\n\t// Add fragments for slots if there are children\n\tif (node.children.length) {\n\t\tnode.fragment = {\n\t\t\tnumber: fragments.length,\n\t\t\ttext: \"\",\n\t\t\tns: status.ns,\n\t\t\teffects: [],\n\t\t\tevents: [],\n\t\t\tanimations: [],\n\t\t};\n\t\tfragments.push(node.fragment);\n\t\tfor (let child of node.children) {\n\t\t\t// TODO: Make sure it's not a fill node\n\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t}\n\t}\n}\n\nfunction buildElementFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tlet needsClass = node.scopeStyles;\n\tcurrentFragment.text += `<${node.tagName}`;\n\tlet attributesText = node.attributes\n\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t.map((a) => {\n\t\t\tif (a.value && a.reactive) {\n\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t// up, especially in the case of data attributes. Otherwise don't set it\n\t\t\t\tif (a.name.startsWith(\"data-\")) {\n\t\t\t\t\treturn `${a.name}=\"\"`;\n\t\t\t\t}\n\t\t\t} else if (a.name === \"class\" && node.scopeStyles) {\n\t\t\t\tneedsClass = false;\n\t\t\t\tlet value = a.value\n\t\t\t\t\t? `\"${trimQuotes(a.value)} torp-${status.styleHash}\"`\n\t\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\t\treturn `${a.name}=${value}`;\n\t\t\t} else {\n\t\t\t\treturn `${a.name}${a.value != null ? `=${a.value}` : \"\"}`;\n\t\t\t}\n\t\t})\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\tif (attributesText) {\n\t\tcurrentFragment.text += \" \" + attributesText;\n\t}\n\tif (needsClass) {\n\t\tcurrentFragment.text += ` class=\"torp-${status.styleHash}\"`;\n\t}\n\tcurrentFragment.text += \">\";\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t}\n\tcurrentFragment.text += `</${node.tagName}>`;\n}\n\nfunction buildSpecialFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\t// Add an anchor for the slot\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// Add a new fragment for filled slot content\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\t// HACK: Just treat it as a component node as that does what we need for now\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isSpecialNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"special\";\n}\n","import type BuildStatus from \"../client/BuildStatus\";\nimport type BuildServerStatus from \"../server/BuildServerStatus\";\n\n/**\n * Makes a supplied variable name (hopefully!) unique by prepending `t_` and\n * appending a sequence number\n *\n * @param name The variable name\n * @param status The build status\n *\n * @returns A unique variable name\n */\nexport default function nextVarName(name: string, status: BuildStatus | BuildServerStatus): string {\n\tif (!status.varNames[name]) {\n\t\tstatus.varNames[name] = 1;\n\t}\n\tlet varName = `t_${name}_${status.varNames[name]}`;\n\tstatus.varNames[name] += 1;\n\treturn varName;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedTextWithOffsets(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet mappedStart = b.toString().length + preText.length;\n\t\tlet functionBody = preText + text + postText;\n\t\tb.append(functionBody);\n\t\tfor (let i = 0; i < spans.length; i++) {\n\t\t\tlet start = mappedStart + offsets[i];\n\t\t\tlet end = start + lengths[i];\n\t\t\tstatus.map.push({\n\t\t\t\tscript: functionBody,\n\t\t\t\tsource: spans[i],\n\t\t\t\tcompiled: { start, end },\n\t\t\t});\n\t\t}\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\n\nexport default function buildAddFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tstatus.imports.add(\"t_add_fragment\");\n\t\tif (fragment.effects.length > 0) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tif (status.options.mapped === true) {\n\t\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.functionBody,\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.spans,\n\t\t\t\t\t\teffect.offsets,\n\t\t\t\t\t\teffect.lengths,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tb,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tb.append(fragment.effects.map((e) => e.functionBody).join(\"\\n\"));\n\t\t\t}\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setAttributes\"` : \"\"});`);\n\t\t}\n\t\tlet params = [fragmentName, parentName, anchorName];\n\t\tif (fragment.endVarName) {\n\t\t\tparams.push(fragment.endVarName);\n\t\t}\n\t\tb.append(`t_add_fragment(${params.join(\", \")});`);\n\t\t// TODO: Don't need to do this if the last thing we hydrated was the end node\n\t\tif (fragment.endVarName) {\n\t\t\tstatus.imports.add(\"t_next\");\n\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied character is a space\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is a space\n */\nexport default function isSpaceChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn code === 32 || (code >= 9 && code <= 13);\n}\n","import isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Checks whether the supplied string contains only space characters\n *\n * @param text The string to check\n *\n * @returns True if the supplied string contains only space characters\n */\nexport default function isSpace(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (!isSpaceChar(text, i)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isControlNode(node: TemplateNode): node is ControlNode {\n\treturn node.type === \"control\";\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isElementNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\n\nexport default function isTextNode(node: TemplateNode): node is TextNode {\n\treturn node.type === \"text\";\n}\n","import isSpace from \"../../parse/utils/isSpace\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isElementNode from \"../../utils/isElementNode\";\nimport isReactive from \"../../utils/isReactive\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport isTextNode from \"../../utils/isTextNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildNode from \"./buildNode\";\n\ninterface VariablePath {\n\tparent: VariablePath | null;\n\ttype: string;\n\tchildren: VariablePath[];\n}\n\n/**\n * Builds the variables and code in a fragment\n */\nexport default function buildFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (status.options.useCreateElement === true) {\n\t\t\t// Declarations, then createXxx calls\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tfragmentPath.children.length = 0;\n\t\t\tvarPaths.clear();\n\t\t\tstatus.imports.add(\"t_frg\");\n\t\t\tb.append(`const ${fragmentName} = t_frg([`);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tb.append(`]);`);\n\t\t} else {\n\t\t\t// Text, then declarations\n\t\t\tstatus.imports.add(\"t_fragment\");\n\t\t\tconst fragmentText = fragment.text.replaceAll(\"`\", \"\\\\`\").replaceAll(/\\s+/g, \" \");\n\t\t\tb.append(\n\t\t\t\t`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t);\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tmaybeAddRootNodeDeclaration(node, fragment, fragmentName, status, b, varPaths);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction maybeAddRootNodeDeclaration(\n\tnode: RootNode | ControlNode | ElementNode,\n\tfragment: Fragment,\n\tfragmentName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n) {\n\tif (!node.children.length) return;\n\n\t// We need to store the root node of the fragment for subsequent updates of the fragment\n\t// But not if the node would be declared anyway\n\tlet firstNode = node.children[0];\n\tlet firstNodeIsLastNode = node.children.length === 1;\n\tif (\n\t\t(isControlNode(firstNode) && firstNode.operation.endsWith(\" group\")) ||\n\t\t(isElementNode(firstNode) &&\n\t\t\telementNodeNeedsDeclaration(firstNode, true, firstNodeIsLastNode)) ||\n\t\t(isTextNode(firstNode) && textNodeNeedsDeclaration(firstNode, true, firstNodeIsLastNode))\n\t) {\n\t\t// It's going to be declared later on\n\t} else {\n\t\tstatus.imports.add(\"t_root\");\n\t\tconst rootName = `t_root_${fragment.number}`;\n\t\tconst params = [fragmentName];\n\t\tif (firstNode.type === \"text\") {\n\t\t\tparams.push(\"true\");\n\t\t}\n\t\tconst rootPath = `t_root(${params.join(\", \")})`;\n\t\tb.append(`const ${rootName} = ${rootPath};`);\n\t\t// HACK: pretend we don't have the text param, so that subsequent t_root\n\t\t// uses will be shortened, even if we don't know they are text nodes\n\t\tvarPaths.set(`t_root(${fragmentName})`, rootName);\n\n\t\tprintDebug(rootName, status, b);\n\t}\n}\n\nfunction declareFragmentVars(\n\tfragment: Fragment,\n\tnode: TemplateNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tdeclareRootFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as RootNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tdeclareControlFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ControlNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tdeclareTextFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as TextNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tdeclareSpecialFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction declareRootFragmentVars(\n\tfragment: Fragment,\n\tnode: RootNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n}\n\nfunction declareControlFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\tconst operation = node.operation.substring(1).replace(\" group\", \"\");\n\t\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\toperation,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction declareComponentFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tdeclareParentAndAnchorFragmentVars(\n\t\tfragment,\n\t\tnode,\n\t\tpath,\n\t\tstatus,\n\t\tb,\n\t\tparentName,\n\t\tanchorName,\n\t\tvarPaths,\n\t\t\"comp\",\n\t\tdeclare,\n\t);\n}\n\nfunction elementTypeName(node: ElementNode) {\n\t// TODO: Etc\n\tswitch (node.tagName.toLowerCase()) {\n\t\tcase \"div\":\n\t\tcase \"span\":\n\t\tcase \"input\":\n\t\tcase \"select\":\n\t\tcase \"option\":\n\t\tcase \"button\":\n\t\tcase \"form\":\n\t\t\treturn `HTML${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t\tcase \"a\":\n\t\t\treturn \"HTMLAnchorElement\";\n\t\tcase \"img\":\n\t\t\treturn \"HTMLImageElement\";\n\t\tcase \"textarea\":\n\t\t\treturn \"HTMLTextAreaElement\";\n\t}\n\treturn \"HTMLElement\";\n}\n\nfunction declareElementFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"element\" : node.tagName;\n\n\tlet elementPath = { parent: path, type: tagName, children: [] };\n\tpath.children.push(elementPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = elementNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(tagName, status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, elementPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tif (node.tagName === \"@element\") {\n\t\t\t\t\tb.append(`let ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If there is an immediate child of this element that has this element as its parent,\n\t// we need to assign the element to the parent var\n\t// @ts-ignore\n\tlet childParentName = node.children.find((c) => !!c.parentName)?.parentName;\n\n\tif (!declare) {\n\t\tlet attributes = node.attributes\n\t\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t\t.map((a) => {\n\t\t\t\tif (a.value && a.reactive) {\n\t\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t\t// up, especially in the case of data attributes\n\t\t\t\t\treturn `\"${a.name}\": \"#\"`;\n\t\t\t\t} else if (a.value) {\n\t\t\t\t\treturn `\"${a.name}\": \"${trimQuotes(a.value) || a.name}\"`;\n\t\t\t\t} else {\n\t\t\t\t\treturn `\"${a.name}\": true\"`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.join(\", \");\n\n\t\tstatus.imports.add(\"t_elm\");\n\t\tif (declareVariable) {\n\t\t\tb.append(\n\t\t\t\t`(${childParentName ? `${childParentName} = ` : \"\"}${node.varName} = t_elm(\"${node.tagName}\", {${attributes}}, [`,\n\t\t\t);\n\t\t} else if (childParentName) {\n\t\t\tb.append(`(${childParentName} = t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t} else {\n\t\t\tb.append(`t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t}\n\t}\n\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\telementPath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tif (!declare) {\n\t\tif (declareVariable || childParentName) {\n\t\t\tb.append(\"])),\");\n\t\t} else {\n\t\t\tb.append(\"]),\");\n\t\t}\n\t}\n}\n\nfunction elementNodeNeedsDeclaration(node: ElementNode, topLevel: boolean, lastChild: boolean) {\n\tconst hasReactiveAttribute = node.attributes.some((a) => a.value && a.reactive);\n\tconst isDynamicElement =\n\t\tnode.tagName === \"@element\" && node.attributes.find((a) => a.name === \"self\");\n\treturn hasReactiveAttribute || isDynamicElement || (topLevel && lastChild);\n}\n\nfunction declareTextFragmentVars(\n\tfragment: Fragment,\n\tnode: TextNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\t// HACK: Text nodes get merged together\n\t// Is this because of control nodes like @key and @const??\n\t// TODO: We should do this when building for the server too\n\tconst lastType = path.children[path.children.length - 1]?.type;\n\tif (lastType === \"text\" || lastType === \"space\") {\n\t\treturn;\n\t}\n\n\tlet textPath = { parent: path, type: isSpace(node.content) ? \"space\" : \"text\", children: [] };\n\tpath.children.push(textPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = textNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(\"text\", status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, textPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tb.append(`const ${node.varName} = ${varPath};`);\n\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_txt\");\n\t\tif (declareVariable) {\n\t\t\tb.append(`(${node.varName} = t_txt(\" \")),`);\n\t\t} else {\n\t\t\tb.append(`t_txt(\"${node.content}\"),`);\n\t\t}\n\t}\n}\n\nfunction textNodeNeedsDeclaration(node: TextNode, topLevel: boolean, lastChild: boolean) {\n\treturn isReactive(node.content) || (topLevel && lastChild);\n}\n\nfunction declareSpecialFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tif (node.tagName === \"slot\") {\n\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\tfragment,\n\t\t\tnode,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\t\"slot\",\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tswitch (node.tagName) {\n\t\tcase \"slot\":\n\t\tcase \"fill\": {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\t// Don't build the fill node twice\n\t\t\t\tif (node.tagName === \"slot\" && isSpecialNode(child) && child.tagName === \"fill\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n\nfunction declareParentAndAnchorFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode | ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tname: string,\n\tdeclare: boolean,\n) {\n\tconst topLevel = !path.parent;\n\n\t// Declare the parent\n\tif (topLevel) {\n\t\t// If this is a top-level element, then the parent is the fragment\n\t\tnode.parentName = `t_fragment_${fragment.number}`;\n\t} else {\n\t\tconst parentPath = path;\n\t\tconst oldChildren = parentPath.children;\n\t\tparentPath.children = [];\n\t\tconst parentVarPath = getFragmentVarPath(fragment, status, \"?\", parentPath, varPaths);\n\t\tparentPath.children = oldChildren;\n\t\t// TODO: Should do this thing for the last child as well\n\t\tif (varPaths.has(parentVarPath)) {\n\t\t\tnode.parentName = varPaths.get(parentVarPath);\n\t\t} else {\n\t\t\tif (declare) {\n\t\t\t\tnode.parentName = nextVarName(`${name}_parent`, status);\n\t\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\t\tb.append(`let ${node.parentName} as HTMLElement;`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.parentName} = ${parentVarPath} as HTMLElement;`);\n\n\t\t\t\t\tprintDebug(node.parentName, status, b);\n\t\t\t\t}\n\t\t\t\tvarPaths.set(parentVarPath, node.parentName);\n\t\t\t} else {\n\t\t\t\t// HACK: For the createElement option, this gets done in the parent\n\t\t\t}\n\t\t}\n\t}\n\n\t// Declare the anchor\n\tif (declare) {\n\t\tconst anchorPath = { parent: path, type: \"#\", children: [] };\n\t\tpath.children.push(anchorPath);\n\n\t\tnode.varName = nextVarName(`${name}_anchor`, status);\n\t\tconst anchorVarPath = getFragmentVarPath(fragment, status, node.varName, anchorPath, varPaths);\n\t\tif (status.options.useCreateElement === true) {\n\t\t\tb.append(`let ${node.varName};`);\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_anchor\");\n\t\t\tb.append(`let ${node.varName} = t_anchor(${anchorVarPath}) as HTMLElement;`);\n\n\t\t\tprintDebug(node.varName, status, b);\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_cmt\");\n\t\tb.append(`(${node.varName} = t_cmt()),`);\n\t}\n\n\t// Build nodes with anchors immediately, while we have their anchor node,\n\t// rather than at the end of the fragment\n\tbuildNode(node, status, b, parentName, anchorName);\n\tnode.handled = true;\n}\n\nfunction getFragmentVarPath(\n\tfragment: Fragment,\n\tstatus: BuildStatus,\n\tname: string,\n\tpath: VariablePath,\n\tvarPaths: Map<string, string>,\n): string {\n\tlet node = path;\n\twhile (node.parent) {\n\t\tnode = node.parent;\n\t}\n\tlet varName = `t_fragment_${fragment.number}`;\n\tlet varPath = getFragmentVarPathPart(node, varName, status, true);\n\n\t// Check for parts of the path that have already been run to shorten our\n\t// traversal\n\tfor (let [existingPath, existingName] of varPaths) {\n\t\tif (varPath.includes(existingPath)) {\n\t\t\tvarPath = varPath.replace(existingPath, existingName);\n\t\t}\n\t}\n\n\t// HACK: allow passing in \"?\" to not add the parentVarPath to the existing\n\t// paths\n\tif (name !== \"?\") {\n\t\t// Add the path, so that we can shorten subsequent paths e.g.\n\t\t// const div = t_next(t_child(root));\n\t\t// const p = t_next(t_next(t_next(t_child(root))))\n\t\t// => const p = t_next(t_next(div))\n\t\tvarPaths.set(varPath, name);\n\t\t// Add the name, so that we are always using the last declared name\n\t\tvarPaths.set(name, name);\n\t}\n\n\t// Shorten `t_next(t_next(x))` to `t_skip(x, 2)`\n\twhile (varPath.includes(\"t_next(t_next(\")) {\n\t\tstatus.imports.add(\"t_skip\");\n\t\tconst match = varPath.match(/(t_next\\(){2,}/)![0];\n\t\tconst count = match.length / \"t_next(\".length;\n\t\tconst pos = varPath.indexOf(\"t_next(t_next(\");\n\t\tconst head = varPath.substring(0, pos);\n\t\tlet level = 0;\n\t\tlet end = 0;\n\t\tfor (let i = pos + match.length; i < varPath.length; i++) {\n\t\t\tif (varPath[i] === \"(\") {\n\t\t\t\tlevel++;\n\t\t\t} else if (varPath[i] === \")\") {\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tend = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tlevel--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst tail = varPath.substring(end + count);\n\t\tconst param = varPath.substring(pos + match.length, end);\n\t\tvarPath = `${head}t_skip(${param}, ${count})${tail}`;\n\t}\n\n\t// Set t_next_text back to t_next\n\tvarPath = varPath.replaceAll(\"t_next_text\", \"t_next\");\n\n\treturn varPath;\n}\n\nfunction getFragmentVarPathPart(\n\tpath: VariablePath,\n\tvarPath: string,\n\tstatus: BuildStatus,\n\troot = false,\n): string {\n\tif (root) {\n\t\tstatus.imports.add(\"t_root\");\n\t\tvarPath = `t_root(${varPath})`;\n\t} else {\n\t\tstatus.imports.add(\"t_child\");\n\t\tvarPath = `t_child(${varPath})`;\n\t}\n\tfor (let [i, child] of path.children.entries()) {\n\t\tif (i > 0) {\n\t\t\tif (child.type === \"text\" || child.type === \"space\") {\n\t\t\t\t// HACK: Using t_next_text just stops t_next(node, true) from\n\t\t\t\t// being converted into t_skip\n\t\t\t\tvarPath = `t_next_text(${varPath}, true)`;\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tvarPath = `t_next(${varPath})`;\n\t\t\t}\n\t\t}\n\n\t\tif (i === path.children.length - 1 && child.children.length) {\n\t\t\tvarPath = getFragmentVarPathPart(child, varPath, status);\n\t\t}\n\t}\n\treturn varPath;\n}\n\nconst debug = false;\nfunction printDebug(varName: string, status: BuildStatus, b: Builder) {\n\tif (debug) {\n\t\tstatus.imports.add(\"t_print\");\n\t\tb.append(`console.log(\"${varName}:\", t_print(${varName}));`);\n\t}\n}\n\n/*\nfunction printPath(path: VariablePath) {\n\tlet parent = path;\n\twhile (parent.parent) {\n\t\tparent = parent.parent;\n\t}\n\tprintPathPart(parent);\n}\n\nfunction printPathPart(path: VariablePath, indent = 0) {\n\tconsole.log(`${\" \".repeat(indent * 2)}${path.type}`);\n\tfor (let child of path.children) {\n\t\tprintPathPart(child, indent + 1);\n\t}\n}\n*/\n","import type BuildStatus from \"./BuildStatus\";\n\n/**\n * Variables used within a for loop need to be retrieved from the loop data.\n */\nexport default function replaceForVarNames(value: string, status: BuildStatus): string {\n\t// HACK: If a value from a for loop is used in the function body,\n\t// get it from the loop data to trigger an update when it is changed\n\tfor (let varName of status.forVarNames) {\n\t\tvalue = value.replaceAll(\n\t\t\tnew RegExp(`(^|\\\\s|\\\\(|\\\\[|\\\\{|!)${varName[0]}($|\\\\s|\\\\.|,|\\\\(|\\\\)|\\\\[|\\\\]|\\\\}|;)`, \"g\"),\n\t\t\t`$1${varName[1]}$2`,\n\t\t);\n\t}\n\treturn value;\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildRun(\n\tfunctionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\taddPushDevBoundary(\"run\", functionName, status, b);\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(functionBody);\n\tb.append(`}${status.options.dev === true ? `, \"${functionName}\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n}\n","export default function endOfString(char: string, content: string, start: number): number {\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === char && content[j - 1] !== \"\\\\\") {\n\t\t\treturn j;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport trimQuotes from \"../../utils/trimQuotes\";\n\nexport default function getAttributeOffsets(\n\tvalue: string,\n\tspan: SourceSpan,\n): {\n\tnewValue: string;\n\tspans: SourceSpan[];\n\toffsets: number[];\n\tlengths: number[];\n} {\n\t// Build offsets for interpolated values e.g. attribute=\"value {x}\n\t// and {y}\" should have offsets for where the x and y are\n\t// interpolated into the output\n\tvalue = trimQuotes(value);\n\tlet spans: SourceSpan[] = [];\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\n\tlet textContent = \"\";\n\tlet reactiveStart = 0;\n\tlet level = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst char = value[i];\n\t\tconst nextChar = value[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\t//maxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\t//reactiveCount += 1;\n\t\t\t\ttextContent += \"${\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.push({ start: span.start + i + 2, end: -1 });\n\t\t\t\toffsets.push(reactiveStart + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.at(-1)!.end = span.start + i + 2;\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \"}\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = value.indexOf(\"\\n\", i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = value.indexOf(\"*/\", i) + 1;\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, value, i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(value, i);\n\t\t\t\ttextContent += value.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += value[i];\n\t}\n\tvalue = `\\`${textContent}\\``;\n\n\treturn {\n\t\tnewValue: value,\n\t\tspans,\n\t\toffsets,\n\t\tlengths,\n\t};\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\troot = false,\n): void {\n\tb.append(\"\");\n\tb.append(\"/* @component */\");\n\n\t// TODO: map params to props\n\n\t// Props\n\tconst componentHasProps = node.attributes.length || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// NOTE: The $props object is wrapped in a proxy so that components can\n\t\t// be updated if they refer to a $props.property in e.g. an element's\n\t\t// attribute\n\t\t// TODO: default props etc\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets: number[];\n\t\t\tlengths: number[];\n\t\t}[] = [];\n\t\tlet runs: string[] = [];\n\t\tlet bindingRuns: string[] = [];\n\n\t\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\t\tif (name === \"self\" && node.tagName === \"@component\") {\n\t\t\t\t// Ignore this special attribute\n\t\t\t} else if (value != null && fullyReactive) {\n\t\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\t\t// It's a bound property\n\t\t\t\t\t// Add two $runs -- one to update the props, and one to update the value\n\t\t\t\t\t// The component author will need to make sure $props.x is updated\n\t\t\t\t\t// TODO: Maybe allow adding a Bindable<T> type to the $props interface??\n\t\t\t\t\t// e.g. Component($props: { text: Bindable<string> })\n\t\t\t\t\tname = name.substring(1);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \"\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t\tbindingRuns.push(`${value} = ${propsName}[\"${name}\"];`);\n\t\t\t\t} else if (name === \"class\") {\n\t\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\t\tconst params = [value];\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tvalue = params.join(\", \");\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"t_class(\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \")\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_class(${value});`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"t_style(\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \")\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_style(${value});`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tpreText: \"\",\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpostText: \"\",\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t\toffsets: [],\n\t\t\t\t\t\tlengths: [],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null && reactive) {\n\t\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\t\tvalue = newValue;\n\t\t\t\tif (name === \"class\") {\n\t\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\t\tconst params = [value];\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tvalue = params.join(\", \");\n\t\t\t\t\tprops.push({ name, preText: \"t_class(\", value, postText: \")\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_class(${value});`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\t\tprops.push({ name, preText: \"t_style(\", value, postText: \")\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = t_style(${value});`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({ name, preText: \"\", value, postText: \"\", spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null) {\n\t\t\t\tif (name === \"class\" && node.scopeStyles) {\n\t\t\t\t\tvalue = `\"${trimQuotes(value)} torp-${status.styleHash}\"`;\n\t\t\t\t}\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tpreText: \"\",\n\t\t\t\t\tvalue,\n\t\t\t\t\tpostText: \"\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t\toffsets: [],\n\t\t\t\t\tlengths: [],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tpreText: \"\",\n\t\t\t\t\tvalue: \"true\",\n\t\t\t\t\tpostText: \"\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t\toffsets: [],\n\t\t\t\t\tlengths: [],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\tif (p.spans.length === 1) {\n\t\t\t\taddMappedText(`${p.name}: ` + p.preText, value, p.postText + \",\", p.spans[0], status, b);\n\t\t\t} else {\n\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t`${p.name}: ` + p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans,\n\t\t\t\t\tp.offsets,\n\t\t\t\t\tp.lengths,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t\tif (bindingRuns.length) {\n\t\t\tbuildRun(\"setBindings\", replaceForVarNames(bindingRuns.join(\"\\n\"), status), status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t$run(() => ${propsName}[name] = $props[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, SlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && slot.tagName === \"fill\") {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t\"$sparent: ParentNode\",\n\t\t\t\t\t\"$sanchor: Node | null\",\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$sprops: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"// @ts-ignore\\n$sprops?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\n\t\t\t\tbuildFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tstatus.fragmentStack.push({\n\t\t\t\t\tfragment: slot.fragment,\n\t\t\t\t\tpath: \"\",\n\t\t\t\t});\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildNode(child, status, b, \"$sparent\", \"$sanchor\");\n\t\t\t\t}\n\t\t\t\tstatus.fragmentStack.pop();\n\n\t\t\t\tbuildAddFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render the component\n\tconst compParentName = node.parentName;\n\tconst compAnchorName = node.varName;\n\tlet renderParams = `${compParentName}, ${compAnchorName}, ${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// TODO: Map the params properly, either by checking for things ourselves,\n\t// or better checking for $props being undefined in components\n\t//addMappedText(\"\", componentName, `(${renderParams});`, node.span, status, b);\n\taddMappedText(\"\", `${componentName}(${renderParams})`, \";\", node.span, status, b);\n\n\tb.append(\"\");\n}\n","/**\n * Trims chars from the start and end of the supplied text when both the start and end match\n *\n * @param text The text to trim\n *\n * @returns The text without the chars at the start or the end\n */\nexport default function trimMatched(text: string, startChar: string, endChar: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (text[start] === startChar && text[end - 1] === endChar) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildAwaitNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"await_region\", status);\n\tconst indexName = nextVarName(\"await_index\", status);\n\tconst tokenName = nextVarName(\"await_token\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Make sure all branches exist\n\tlet awaitBranch = branches.find((n) => n.operation === \"@await\")!;\n\tif (!awaitBranch) {\n\t\t// TODO: Error handling\n\t}\n\tlet thenBranch = branches.find((n) => n.operation === \"@then\");\n\tif (!thenBranch) {\n\t\tthenBranch = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@then\",\n\t\t\tstatement: \"then\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t}\n\tlet catchBranch = branches.find((n) => n.operation === \"@catch\");\n\tif (!catchBranch) {\n\t\tcatchBranch = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@catch\",\n\t\t\tstatement: \"catch\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t}\n\n\tconst awaiterName = trimMatched(awaitBranch.statement.substring(\"await\".length).trim(), \"(\", \")\");\n\tconst thenVar = trimMatched(thenBranch.statement.substring(\"then\".length).trim(), \"(\", \")\");\n\tconst catchVar = trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\");\n\n\t// Use an incrementing token to make sure only the last request gets handled\n\t// TODO: This might have unforeseen consequences\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @await */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"await\"` : \"\"});\n\t\tlet ${tokenName} = 0;\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (t_before) => {`);\n\n\tlet index = 0;\n\n\t// Build the waiting branch before anything happens\n\tbuildAwaitBranch(awaitBranch, status, b, parentName, regionName, indexName, index++);\n\n\tb.append(`\n\t\t${tokenName}++;\n\t\t((t_token) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tawaitBranch.span.start += \"await\".length + 2;\n\taddMappedText(\"\", replaceForVarNames(awaiterName, status), \"\", awaitBranch.span, status, b);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tthenBranch.span.start -= 1;\n\taddMappedText(\n\t\t\".then((\",\n\t\treplaceForVarNames(thenVar, status),\n\t\t\") => {\",\n\t\tthenBranch.span,\n\t\tstatus,\n\t\tb,\n\t);\n\n\tb.append(`if (t_token === ${tokenName}) {`);\n\tbuildAwaitBranch(thenBranch, status, b, parentName, regionName, indexName, index++);\n\tb.append(`}\n\t\t})`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tcatchBranch.span.start -= 1;\n\taddMappedText(\n\t\t\".catch((\",\n\t\treplaceForVarNames(catchVar, status),\n\t\t\") => {\",\n\t\tcatchBranch.span,\n\t\tstatus,\n\t\tb,\n\t);\n\n\tb.append(`if (t_token === ${tokenName}) {`);\n\tbuildAwaitBranch(catchBranch, status, b, parentName, regionName, indexName, index++);\n\tb.append(`}\n\t\t\t\t});\n\t\t\t})(${tokenName});\n\t\t}${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildAwaitBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\t// NOTE: for await branches, we need to push the control region again,\n\t\t// because it will have been popped by the time the `then` or `catch`\n\t\t// branches are hit\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"await_branch\"` : \"\"});\n\t\t\tconst t_old_control_region = t_push_region(${regionName});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment!,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t\tb.append(\"t_pop_region(t_old_control_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nconst forLoopRegex = /for\\s*\\((.+?);.*?;.*?\\)/;\nconst forLoopVarsRegex = /(?:let\\s+|var\\s+){0,1}([^\\s,;+=]+)(?:\\s*=\\s*[^,;]+){0,1}/g;\nconst forOfRegex = /for\\s*\\(\\s*(?:let\\s*|var\\s*){0,1}(.+?)\\s+(?:of|in).*?\\)/;\n\nexport default function buildForNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst parentName = node.parentName!;\n\tconst anchorName = node.varName ?? \"null\";\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\t// HACK: Need to wrangle the declaration(s) out of the for loop and put them in data\n\t// TODO: Handle destructuring, quotes, comments etc\n\tconst forVarNames: string[] = [];\n\tconst forLoopMatch = node.statement.match(forLoopRegex);\n\tif (forLoopMatch) {\n\t\tconst forVarMatches = forLoopMatch[1].matchAll(forLoopVarsRegex);\n\t\tfor (let match of forVarMatches) {\n\t\t\tforVarNames.push(match[1]);\n\t\t}\n\t} else {\n\t\tconst forOfMatch = node.statement.match(forOfRegex);\n\t\tif (forOfMatch) {\n\t\t\tconst match = forOfMatch[1];\n\t\t\tif (\n\t\t\t\t(match.startsWith(\"{\") && match.endsWith(\"}\")) ||\n\t\t\t\t(match.startsWith(\"[\") && match.endsWith(\"]\"))\n\t\t\t) {\n\t\t\t\tforVarNames.push(\n\t\t\t\t\t...trimMatched(trimMatched(match, \"{\", \"}\"), \"[\", \"]\")\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map((m) => m.trim()),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tforVarNames.push(match);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst regionName = nextVarName(\"for_region\", status);\n\tconst listItemsName = nextVarName(\"new_items\", status);\n\tconst previousItemName = nextVarName(\"previous_item\", status);\n\tconst nextItemName = nextVarName(\"next_item\", status);\n\tconst newItemName = nextVarName(\"new_item\", status);\n\tconst itemName = nextVarName(\"item\", status);\n\tconst beforeName = nextVarName(\"before\", status);\n\n\t// Get the key node if it's been set\n\tlet keyStatement = \"\";\n\tconst key = node.children.find(\n\t\t(n) => n.type === \"control\" && (n as ControlNode).operation === \"@key\",\n\t) as ControlNode;\n\tif (key !== undefined) {\n\t\tlet matches = key.statement.match(/^(\\s*@*key\\s*=\\s*)(.+?)\\s*;*\\s*$/);\n\t\tif (matches) {\n\t\t\tkey.span.start += matches[1].length;\n\t\t\tkeyStatement = matches[2];\n\t\t}\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_list\");\n\tstatus.imports.add(\"t_list_item\");\n\tstatus.imports.add(\"ListItem\");\n\n\tb.append(\"\");\n\tb.append(\"/* @for */\");\n\taddPushDevBoundary(\"control\", `@${node.statement}`, status, b);\n\tb.append(`\n\t\tlet ${regionName} = t_region(${status.options.dev === true ? `\"for\"` : \"\"});\n\t\tt_run_list(\n\t\t${regionName},\n\t\t${parentName},\n\t\t${anchorName},\n\t\t${status.options.dev === true ? \"function createNewItems() {\" : \"() => {\"}\n\t\t\tlet ${listItemsName}: ListItem[] = [];\n\t\t\tlet ${previousItemName} = ${regionName};\n\t\t\tlet ${nextItemName} = ${regionName}.nextRegion;`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`let ${newItemName} = t_list_item(`);\n\t// TODO: Should map these\n\tb.append(`{ ${forVarNames.join(\", \")} },`);\n\tif (key !== undefined) {\n\t\taddMappedText(\"\", `${keyStatement || \"undefined\"}`, \",\", key.span, status, b);\n\t}\n\tif (status.options.dev === true) {\n\t\tb.append(`\"for item\"`);\n\t}\n\tb.append(\");\");\n\tb.append(`\n\t\t\t${newItemName}.previousRegion = ${previousItemName};\n\t\t\t${previousItemName}.nextRegion = ${newItemName};\n\t\t\t${previousItemName} = ${newItemName};\n\t\t\t${listItemsName}.push(${newItemName});\n\t\t}\n\t\t${regionName}.nextRegion = ${nextItemName};\n\t\treturn ${listItemsName};\n\t},\n\t${status.options.dev === true ? `function createListItem(${itemName}, ${beforeName}) {` : `(${itemName}, ${beforeName}) => {`}`);\n\n\tlet oldForVarNames = status.forVarNames;\n\tstatus.forVarNames = [\n\t\t...status.forVarNames,\n\t\t...forVarNames.map((v) => [v, `${itemName}.data.${v}`]),\n\t];\n\tbuildForItem(node, status, b, parentName, beforeName, itemName);\n\tstatus.forVarNames = oldForVarNames;\n\n\tb.append(`},\n\t${status.options.dev === true ? \"function updateListItem(t_old_item, t_new_item) {\" : \"(t_old_item, t_new_item) => {\"}`);\n\tfor (let varName of forVarNames) {\n\t\tb.append(`t_old_item.data.${varName} = t_new_item.data.${varName};`);\n\t}\n\tb.append(`}\n\t\t);`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildForItem(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tbeforeName: string,\n\titemName: string,\n) {\n\tconst oldRegionName = nextVarName(\"old_region\", status);\n\n\tstatus.imports.add(\"t_push_region\");\n\tb.append(`let ${oldRegionName} = t_push_region(${itemName});`);\n\n\tbuildFragment(node, status, b, parentName, beforeName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment!,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tif (isControlNode(child) && child.operation === \"@key\") {\n\t\t\tcontinue;\n\t\t}\n\t\tbuildNode(child, status, b, parentName, beforeName);\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, beforeName);\n\n\t// If we wanted to return the fragment instead:\n\t//b.append(`t_item.startNode = t_fragment_1.firstChild;`);\n\t//b.append(`t_item.endNode = t_fragment_1.lastChild;`);\n\t//for (let ev of node.fragment!.events) {\n\t// b.append(`${ev.varName}.addEventListener(\"${ev.eventName}\", ${ev.handler});`);\n\t//}\n\n\tstatus.imports.add(\"t_pop_region\");\n\tb.append(`t_pop_region(${oldRegionName});`);\n\n\t// If we wanted to return the fragment instead:\n\t//b.append(`return t_fragment_${node.fragment!.number};`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildHtmlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst htmlAnchorName = node.varName!;\n\tconst htmlParentName = node.parentName || htmlAnchorName + \".parentNode\";\n\tconst htmlRegionName = nextVarName(\"html_region\", status);\n\n\t// HACK: I'm not actually sure we need this here (or in @replace, where I copied it from)\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @html */\n\tconst ${htmlRegionName} = t_region(${status.options.dev === true ? `\"html\"` : \"\"});\n\tt_run_control(${htmlRegionName}, ${htmlAnchorName}, (t_before) => {`);\n\n\tbuildHtmlBranch(node, status, b, htmlParentName, htmlRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"html\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildHtmlBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"html_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tconst templateName = nextVarName(\"template\", status);\n\tconst fragmentName = `t_fragment_${node.fragment!.number}`;\n\tb.append(`let ${templateName} = document.createElement(\"template\");`);\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tnode.span.start += \"html(\".length;\n\tnode.span.end -= 2;\n\taddMappedText(\n\t\t\"\",\n\t\t`${templateName}.innerHTML = ${replaceForVarNames(node.statement, status)};`,\n\t\t\"\",\n\t\tnode.span,\n\t\tstatus,\n\t\tb,\n\t);\n\tb.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: Are there too many branches for ifs etc?\n\nexport default function buildIfNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"if_region\", status);\n\tconst indexName = nextVarName(\"if_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add an else branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@else\") === -1) {\n\t\tconst elseBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@else\",\n\t\t\tstatement: \"else\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(elseBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @if */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"if\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildIfBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\n\tb.append(`}${status.options.dev === true ? `, \"runIf\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildIfBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"if_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildReplaceNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst replaceAnchorName = node.varName!;\n\tconst replaceParentName = node.parentName || replaceAnchorName + \".parentNode\";\n\tconst replaceRegionName = nextVarName(\"replace_region\", status);\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @replace */\n\tconst ${replaceRegionName} = t_region(${status.options.dev === true ? `\"replace\"` : \"\"});\n\tt_run_control(${replaceRegionName}, ${replaceAnchorName}, (t_before) => {`);\n\n\tbuildReplaceBranch(node, status, b, replaceParentName, replaceRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"replace\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildReplaceBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"replace_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\n\nexport default function buildScriptNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tb.append(`/* ${node.operation} */`);\n\taddMappedText(\"\", `${maybeAppend(node.statement, \";\")}`, \"\", node.span, status, b);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSwitchNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"switch_region\", status);\n\tconst indexName = nextVarName(\"switch_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add a default branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@default\") === -1) {\n\t\tconst defaultBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@default\",\n\t\t\tstatement: \"default\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(defaultBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @switch */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"switch\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildSwitchBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\tb.append(`\n\t\t}\n\t}${status.options.dev === true ? `, \"runSwitch\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildSwitchBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"switch_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`\n\t\t\t${indexName} = ${index};\n\t\t\tbreak;\n\t\t}`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAwaitNode from \"./buildAwaitNode\";\nimport buildForNode from \"./buildForNode\";\nimport buildHtmlNode from \"./buildHtmlNode\";\nimport buildIfNode from \"./buildIfNode\";\nimport buildReplaceNode from \"./buildReplaceNode\";\nimport buildScriptNode from \"./buildScriptNode\";\nimport buildSwitchNode from \"./buildSwitchNode\";\n\nexport default function buildControlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@then\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildHtmlNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\":\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tb.append(\"\");\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tb.append(\"\");\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","/**\n * Trims a char from the end of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the end of the text\n *\n * @returns The text without the char on the end\n */\nexport default function trimEnd(text: string, char: string): string {\n\tlet end = text.length;\n\twhile (text[end - 1] === char) {\n\t\tend -= 1;\n\t}\n\treturn text.substring(0, end);\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildMount(\n\t// TODO: like in buildRun\n\t_functionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\tstatus.imports.add(\"$mount\");\n\t// Ignore errors if the user hasn't returned a cleanup function\n\tb.append(\"// @ts-ignore\\n$mount(() => {\");\n\tb.append(functionBody);\n\tb.append(\"});\");\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRun(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n): void {\n\tvalue = replaceForVarNames(value, status);\n\tlet functionBody = functionStart + value + functionEnd;\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: [span],\n\t\toffsets: [functionStart.length],\n\t\tlengths: [value.length],\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRunWithOffsets(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n): void {\n\tlet functionBody = functionStart + value + functionEnd;\n\n\tfor (let i = 0; i < offsets.length; i++) {\n\t\toffsets[i] += functionStart.length;\n\t\tconst oldLength = functionBody.length;\n\t\tfunctionBody =\n\t\t\tfunctionBody.substring(0, offsets[i]) +\n\t\t\treplaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) +\n\t\t\tfunctionBody.substring(offsets[i] + lengths[i]);\n\t\tconst changedLength = functionBody.length - oldLength;\n\t\tlengths[i] += changedLength;\n\t\tfor (let j = i + 1; j < offsets.length; j++) {\n\t\t\toffsets[j] += changedLength;\n\t\t}\n\t}\n\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: spans,\n\t\toffsets,\n\t\tlengths,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimEnd from \"../../utils/trimEnd\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildMount from \"./buildMount\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\nimport stashRun from \"./stashRun\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildElementNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n): void {\n\tif (status.inHead) {\n\t\tif (node.tagName === \"title\") {\n\t\t\tbuildTitleNode(node, status, b);\n\t\t} else {\n\t\t\tbuildHeadNode(node, status, b);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst svgElement = node.tagName === \"svg\";\n\tconst oldns = status.ns;\n\tif (svgElement) {\n\t\tstatus.ns = true;\n\t}\n\n\tconst varName = node.varName;\n\tif (varName) {\n\t\tif (node.tagName === \"@element\") {\n\t\t\tbuildDynamicElementNode(node, status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\t//status.imports.add(\"t_apply_props\");\n\t\t\t//// TODO: I think we know what the props are at this stage, so we could be more direct?\n\t\t\t//b.append(\"\");\n\t\t\t//b.append(\n\t\t\t//\t`t_apply_props(${varName}, $props, [${status.props.map((p) => `'${p}'`).join(\", \")}]);`,\n\t\t\t//);\n\t\t}\n\n\t\tbuildElementAttributes(node, varName, status, b);\n\t}\n\n\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\tstatus.preserveWhitespace = node.tagName === \"code\" || node.tagName === \"pre\";\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"null\");\n\t}\n\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\n\tif (svgElement) {\n\t\tstatus.ns = oldns;\n\t}\n}\n\nfunction buildDynamicElementNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\tstatus.imports.add(\"$run\");\n\t\tstatus.imports.add(\"t_dynamic\");\n\t\tlet selfValue = selfAttribute.value;\n\n\t\tb.append(\"$run(() => {\");\n\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\n\t\tlet parentName = node.varName;\n\n\t\tbuildFragment(node, status, b, parentName!, \"null\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName!, \"null\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName!, \"null\");\n\n\t\tb.append(`}${status.options.dev === true ? `, \"setDynamic\"` : \"\"});`);\n\t}\n}\n\nfunction buildTitleNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet content = (node.children[0] as TextNode).content || \"\";\n\n\t// Replace all spaces with a single space, both to save space and to remove\n\t// newlines from generated JS strings\n\tcontent = content.replace(/\\s+/g, \" \");\n\n\t// TODO: Should be fancier about this in parse -- e.g. ignore braces in\n\t// quotes, unclosed, etc\n\tlet reactiveStarted = false;\n\tlet reactiveCount = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tif (content[i] === \"{\") {\n\t\t\treactiveStarted = true;\n\t\t} else if (content[i] === \"}\") {\n\t\t\tif (reactiveStarted) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\treactiveStarted = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (reactiveCount) {\n\t\tstatus.imports.add(\"t_fmt\");\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\tcontent = `t_fmt(${content.substring(1, content.length - 1)})`;\n\t\t} else {\n\t\t\tcontent = `\\`${content.replaceAll(\"{\", \"${t_fmt(\").replaceAll(\"}\", \")}\")}\\``;\n\t\t}\n\t} else {\n\t\tcontent = `\"${content}\"`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_old_title = document.title;\n\t\t\tdocument.title = ${content};\n\t\t\treturn () => document.title = t_old_title;\n\t\t}${status.options.dev === true ? `, \"runTitle\"` : \"\"});`);\n}\n\nfunction buildHeadNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tstatus.imports.add(\"$run\");\n\t// TODO: dedupe e.g. <meta name=\"x\"> or on special key\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_head_el = document.createElement(\"${node.tagName}\");\n\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(t_head_el);`);\n\tfor (let { name, value, span } of node.attributes) {\n\t\tif (value != null) {\n\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\tvalue = replaceForVarNames(value, status);\n\t\t\taddMappedText(`t_attribute(t_head_el, \"${name}\", `, value, \");\", span, status, b);\n\t\t}\n\t}\n\tb.append(`}${status.options.dev === true ? `, \"runHead\"` : \"\"});`);\n}\n\nfunction buildElementAttributes(\n\tnode: ElementNode,\n\tvarName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) throw new Error(\"No fragment on stack\");\n\n\t// TODO: Add an error if any reactive attributes are used non-reactively\n\n\t// Do &ref first, just in case any other attributes depend on it being set\n\t// e.g. if you have a `style` attribute that depends on the element's size\n\tconst refAttribute = node.attributes.find((a) => a.name === \"&ref\");\n\tif (refAttribute) {\n\t\tlet { value, fullyReactive } = refAttribute;\n\t\tif (value != null && fullyReactive) {\n\t\t\t// Bind the DOM element to a user-defined variable\n\t\t\tb.append(`${value} = ${varName};`);\n\t\t}\n\t}\n\n\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// Ignore this one, it should have been done already, above\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&group\") {\n\t\t\t\tbuildBindGroupAttribute(node, varName, value, status, b);\n\t\t\t} else if (name === \"&value\" || name === \"&checked\") {\n\t\t\t\tbuildBindAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"onmount\") {\n\t\t\t\t// The onmount event is faked by us by creating a $mount. This\n\t\t\t\t// also means that you can have unmount functionality by\n\t\t\t\t// returning a cleanup function\n\t\t\t\tbuildMount(\"elMount\", `return (${trimEnd(value.trim(), \";\")})(${varName});`, status, b);\n\t\t\t} else if (name.startsWith(\"on\")) {\n\t\t\t\tbuildEventAttribute(varName, name, value, span, status, b);\n\t\t\t} else if (name.startsWith(\"transition\")) {\n\t\t\t\tbuildTransitionAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRun(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspan,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRun(fragment, `${varName}.setAttribute(\"style\", t_style(`, value, \"));\", span, status);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\tvalue = newValue;\n\t\t\tif (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${varName}.setAttribute(\"style\", t_style(`,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\"));\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction buildBindGroupAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Only tested this with radio buttons\n\tlet eventName = \"change\";\n\tlet inputValue = node.attributes.find((a) => a.name === \"value\")?.value;\n\tlet set = `${value} == ${inputValue}`;\n\tlet propName = \"checked\";\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => {\n\t\t\tif (e.target.${propName}) ${value} = ${inputValue};\n\t\t});`);\n}\n\nfunction buildBindAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Need to check the element to find out what type of event to add\n\tlet eventName = \"input\";\n\tlet defaultValue = '\"\"';\n\tlet inputValue = \"e.target.value\";\n\tif (node.tagName === \"input\") {\n\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\tcase \"number\": {\n\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\tinputValue = \"Number(e.target.value)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\tinputValue = \"e.target.checked\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"radio\": {\n\t\t\t\t\teventName = \"change\";\n\t\t\t\t\tinputValue = \"e.target.value\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (node.tagName === \"select\") {\n\t\teventName = \"change\";\n\t}\n\tlet set = `${value} || ${defaultValue}`;\n\tconst propName = name.substring(1);\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => ${value} = ${inputValue});`);\n}\n\nfunction buildEventAttribute(\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Add an event listener, after the fragment has been added\n\tconst eventName = name.substring(2);\n\tstatus.imports.add(\"t_event\");\n\taddMappedText(`t_event(${varName}, \"${eventName}\", `, value, `);`, span, status, b);\n}\n\nfunction buildTransitionAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\tstatus.imports.add(\"t_animate\");\n\n\t// Add an in and out transition, after the fragment has been added\n\t// TODO: Separate these -- you should be able to have multiple,\n\t// unrelated entry and exit transitions?\n\tlet entryVarName = nextVarName(\"trans_in\", status);\n\tlet exitVarName = nextVarName(\"trans_out\", status);\n\n\tif (name === \"transition\") {\n\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\tb.append(`const ${exitVarName} = ${entryVarName};`);\n\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t} else if (name === \"transition-in\") {\n\t\tlet outAttribute = node.attributes.find((a) => a.name === \"transition-out\");\n\t\tif (outAttribute && outAttribute.value && outAttribute.fullyReactive) {\n\t\t\tlet outValue = outAttribute.value;\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`const ${exitVarName} = (${outValue})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t\t} else {\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName});`);\n\t\t}\n\t} else if (name === \"transition-out\") {\n\t\tlet inAttribute = node.attributes.find((a) => a.name === \"transition-in\");\n\t\tif (inAttribute) {\n\t\t\t// This has already been handled with transition-in, above\n\t\t\treturn;\n\t\t} else {\n\t\t\tb.append(`const ${exitVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, null, ${entryVarName});`);\n\t\t}\n\t} else {\n\t\t// TODO: Add an error\n\t}\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildRootNode(\n\tnode: RootNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tbuildFragment(node, status, b, parentName, anchorName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"0:ch/\",\n\t});\n\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, anchorName, true);\n\t}\n\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, anchorName);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSlotNode(node: ElementNode, status: BuildStatus, b: Builder): void {\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"sprops\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: { name: string; value: string; span: SourceSpan }[] = [];\n\t\tlet runs: string[] = [];\n\n\t\tfor (let { name, value, reactive, span } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tprops.push({ name, value, span });\n\t\t\t\tif (reactive) {\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\", span });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\taddMappedText(`${p.name}: `, value, \",\", p.span, status, b);\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t}\n\n\tconst slotParentName = node.parentName!;\n\tconst slotAnchorName = node.varName!;\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tlet params = [slotParentName, slotAnchorName, slotHasProps ? propsName : \"undefined\", \"$context\"];\n\tb.append(`$slots[\"${slotName}\"](${params.join(\", \")})`);\n\n\t// TODO: Maybe not if there's only a single space node?\n\tconst fill = node.children.find((c) => isSpecialNode(c) && c.tagName === \"fill\");\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tbuildFragment(fill, status, b, slotParentName, slotAnchorName);\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: fill.fragment,\n\t\t\tpath: \"0:ch/\",\n\t\t});\n\t\tfor (let child of fill.children) {\n\t\t\tbuildNode(child, status, b, slotParentName, slotAnchorName);\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(fill, status, b, slotParentName, slotAnchorName);\n\t}\n\n\tb.append(`}`);\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildSlotNode from \"./buildSlotNode\";\n\nexport default function buildSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementNode(node, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentNode(node, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport type BuildStatus from \"./BuildStatus\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildTextNode(node: TextNode, status: BuildStatus): void {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) return; // probably in @head...\n\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Should we be parsing out the spans here? Like we do with\n\t// attributes? And should we merge this with the attributes logic?\n\tlet textContent = \"\";\n\tlet reactiveCount = 0;\n\tlet reactiveStart = 0;\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\tlet level = 0;\n\tlet maxLevel = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tconst nextChar = content[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tmaxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\ttextContent += \"${t_fmt(\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\toffsets.push(reactiveStart);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"\\n\", i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"*/\", i) + 1;\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, content, i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(content, i);\n\t\t\t\ttextContent += content.substring(start, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += content[i];\n\t}\n\n\t// Only need to build if there is any reactive content, otherwise the plain\n\t// text content will be output in fragment text\n\tif (maxLevel) {\n\t\tlet offsetChange = 0;\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\ttextContent = textContent.substring(2, textContent.length - 1);\n\t\t\toffsetChange = -2;\n\t\t} else {\n\t\t\ttextContent = `\\`${textContent}\\``;\n\t\t\toffsetChange = 1;\n\t\t}\n\n\t\tstatus.imports.add(\"t_fmt\");\n\t\toffsets.map((_, i) => (offsets[i] += offsetChange));\n\n\t\tstashRunWithOffsets(\n\t\t\tfragment,\n\t\t\t`${node.varName}.textContent = `,\n\t\t\ttextContent,\n\t\t\t\";\",\n\t\t\tnode.spans,\n\t\t\toffsets,\n\t\t\tlengths,\n\t\t\tstatus,\n\t\t);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildControlNode from \"./buildControlNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildRootNode from \"./buildRootNode\";\nimport buildSpecialNode from \"./buildSpecialNode\";\nimport buildTextNode from \"./buildTextNode\";\n\nexport default function buildNode(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\troot = false,\n): void {\n\t// Nodes with anchors will have been handled when their containing fragment\n\t// was built so we want to skip them here\n\tif (node.handled) {\n\t\tnode.handled = false;\n\t\treturn;\n\t}\n\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootNode(node as RootNode, status, b, parentName, anchorName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentNode(node as ElementNode, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildElementNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type TemplateComponent from \"../../../types/TemplateComponent\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport type SourceMapping from \"../../types/SourceMapping\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildFragmentText from \"./buildFragmentText\";\nimport buildNode from \"./buildNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$mount: 'import { $mount } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_region: 'import { t_region } from \"${folder}\";',\n\tt_push_region: 'import { t_push_region } from \"${folder}\";',\n\tt_pop_region: 'import { t_pop_region } from \"${folder}\";',\n\tt_run_control: 'import { t_run_control } from \"${folder}\";',\n\tt_run_branch: 'import { t_run_branch } from \"${folder}\";',\n\tt_list_item: 'import { t_list_item } from \"${folder}\";',\n\tt_run_list: 'import { t_run_list } from \"${folder}\";',\n\tt_add_fragment: 'import { t_add_fragment } from \"${folder}\";',\n\tt_apply_props: 'import { t_apply_props } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tt_attribute: 'import { t_attribute } from \"${folder}\";',\n\tt_dynamic: 'import { t_dynamic } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_fragment: 'import { t_fragment } from \"${folder}\";',\n\tt_event: 'import { t_event } from \"${folder}\";',\n\tt_animate: 'import { t_animate } from \"${folder}\";',\n\tt_root: 'import { t_root } from \"${folder}\";',\n\tt_anchor: 'import { t_anchor } from \"${folder}\";',\n\tt_child: 'import { t_child } from \"${folder}\";',\n\tt_next: 'import { t_next } from \"${folder}\";',\n\tt_skip: 'import { t_skip } from \"${folder}\";',\n\tt_frg: 'import { t_frg } from \"${folder}\";',\n\tt_elm: 'import { t_elm } from \"${folder}\";',\n\tt_txt: 'import { t_txt } from \"${folder}\";',\n\tt_cmt: 'import { t_cmt } from \"${folder}\";',\n\tt_print: 'import { t_print } from \"${folder}\";',\n\tListItem: 'import { type ListItem } from \"${folder}\";',\n\tSlotRender: 'import { type SlotRender } from \"${folder}\";',\n\t// HACK: this one's a bit different\n\tdevContext: 'import { devContext } from \"${folder}/dev\";',\n\tt_push_dev_bound: 'import { t_push_dev_bound } from \"${folder}/dev\";',\n\tt_pop_dev_bound: 'import { t_pop_dev_bound } from \"${folder}/dev\";',\n};\n\nexport default function buildCode(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\toptions?: BuildOptions,\n): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"SlotRender\");\n\n\t// Build the component\n\tbuildTemplate(template, map, imports, b, options);\n\n\tlet startSize = b.toString().length;\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tb.prepend(\"\");\n\t\tfor (let imp of Array.from(imports).sort().reverse()) {\n\t\t\tlet importStatement = importsMap[imp] ?? imp;\n\t\t\tlet folder = options?.renderFolder ?? \"@torpor/view\";\n\t\t\timportStatement = importStatement.replace(\"${folder}\", folder);\n\t\t\tb.prepend(importStatement);\n\t\t}\n\t}\n\n\tif (options?.mapped) {\n\t\tlet endSize = b.toString().length;\n\t\tlet diff = endSize - startSize + 1;\n\t\tfor (let m of map) {\n\t\t\tm.compiled.start += diff;\n\t\t\tm.compiled.end += diff;\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildTemplate(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(script)) imports.add(\"$watch\");\n\tif (/\\$cache\\b/.test(script)) imports.add(\"$cache\");\n\tif (/\\$run\\b/.test(script)) imports.add(\"$run\");\n\tif (/\\$mount\\b/.test(script)) imports.add(\"$mount\");\n\tif (/\\$unwrap\\b/.test(script)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(script)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(script)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\tlet status: BuildStatus = makeStatus(imports, map, current, options);\n\tlet first = true;\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// Reset the status for each new function body\n\t\t\tif (!first) {\n\t\t\t\tstatus = makeStatus(imports, map, current, options);\n\t\t\t}\n\t\t\tfirst = false;\n\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tb.append(`\n\t\t\t\t\t${current.markup ? \"$parent\" : \"_$parent\"}: ParentNode,\n\t\t\t\t\t${current.markup ? \"$anchor\" : \"_$anchor\"}: Node | null,`);\n\t\t\tif (current.params !== undefined) {\n\t\t\t\taddMappedText(\"\", current.params, \",\", chunk.span, status, b);\n\t\t\t} else {\n\t\t\t\tb.append(\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"// @ts-ignore\\n$props?: Record<PropertyKey, any>\"},`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t\t\t${current.contextProps?.length ? \"$context\" : \"// @ts-ignore\\n$context\"}?: Record<PropertyKey, any>,\n\t\t\t\t\t${current.slotProps?.length ? \"$slots\" : \"// @ts-ignore\\n$slots\"}?: Record<string, SlotRender>`);\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): void {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Add the component to devContext for display in DevTools\n\t\t\taddPushDevBoundary(\"component\", current.name || \"Anon Component\", status, b);\n\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\t\t\t\tbuildFragmentText(current.markup, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.markup, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Add the head tags\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\t\t\t\tstatus.inHead = true;\n\t\t\t\tbuildNode(current.head, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tstatus.inHead = false;\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t// No styles in the client\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\taddPopDevBoundary(status, b);\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\taddMappedText(\"\", chunk.script, \"\", chunk.span, status, b);\n\t\t}\n\t}\n}\n\nfunction makeStatus(\n\timports: Set<string>,\n\tmap: SourceMapping[],\n\tcurrent?: TemplateComponent,\n\toptions?: BuildOptions,\n): BuildStatus {\n\treturn {\n\t\timports,\n\t\tprops: current?.props ?? [],\n\t\tcontextProps: current?.contextProps ?? [],\n\t\tslotProps: current?.slotProps ?? [],\n\t\tstyleHash: current?.style?.hash ?? \"\",\n\t\tmap,\n\t\tvarNames: {},\n\t\tfragmentStack: [],\n\t\tforVarNames: [],\n\t\tns: false,\n\t\tpreserveWhitespace: false,\n\t\tinHead: false,\n\t\toptions: options ?? {},\n\t};\n}\n","import type Attribute from \"../../types/styles/Attribute\";\nimport type Style from \"../../types/styles/Style\";\nimport type StyleBlock from \"../../types/styles/StyleBlock\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildStyles(style: Style, styleHash: string): string {\n\tconst b = new Builder();\n\n\tfor (let block of style.blocks) {\n\t\tbuildStyleBlock(block, b, styleHash);\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildStyleBlock(block: StyleBlock, b: Builder, styleHash: string) {\n\t// TODO: This should probably be done while parsing\n\t// And handle attribute selectors\n\tif (block.selector.startsWith(\"@\")) {\n\t\t// Just output media queries and properties as-is\n\t\tb.append(`${block.selector} {`);\n\t} else {\n\t\tblock.selector = block.selector.replaceAll(/\\s+/g, \" \");\n\t\tlet selectors: string[] = [];\n\t\tlet global = false;\n\t\tlet start = 0;\n\t\tfor (let i = 0; i <= block.selector.length; i++) {\n\t\t\tif (block.selector.substring(i).startsWith(\":global(\")) {\n\t\t\t\ti += \":global\".length;\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = true;\n\t\t\t} else if (global && block.selector[i] === \")\") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = false;\n\t\t\t} else if (\"*,>+~\".includes(block.selector[i])) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tselectors.push(block.selector[i]);\n\t\t\t\tstart = i + 1;\n\t\t\t} else if (i === block.selector.length) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t} else if (block.selector[i] === \" \") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t}\n\t\t}\n\t\tb.append(`${selectors.join(\" \").replaceAll(\" ,\", \",\")} {`);\n\t}\n\tfor (let attribute of block.attributes) {\n\t\tbuildStyleAttribute(attribute, b);\n\t}\n\tfor (let child of block.children) {\n\t\tbuildStyleBlock(child, b, styleHash);\n\t}\n\tb.append(`}`);\n}\n\nfunction addSelector(\n\tselectors: string[],\n\tselector: string,\n\tstyleHash: string,\n\tstart: number,\n\tend: number,\n\tglobal: boolean,\n) {\n\tif (end > start) {\n\t\tlet s = selector.substring(start, end);\n\t\tif (!global) {\n\t\t\tlet pre = s;\n\t\t\tlet post = \"\";\n\t\t\t// We might need to handle e.g. `:hover` or `::before`\n\t\t\tlet colonPosition = s.indexOf(\":\");\n\t\t\tif (colonPosition !== -1) {\n\t\t\t\tpre = s.substring(0, colonPosition);\n\t\t\t\tpost = s.substring(colonPosition);\n\t\t\t}\n\t\t\ts = `${pre}.torp-${styleHash}${post}`;\n\t\t}\n\t\tselectors.push(s);\n\t}\n}\n\nfunction buildStyleAttribute(attribute: Attribute, b: Builder) {\n\tb.append(`${attribute.name}: ${attribute.value};`);\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Props\n\tconst componentHasProps = node.attributes.length; // || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// TODO: defaults etc props\n\n\t\t// Gather props, and set them all at once\n\t\tlet props: { name: string; value: string }[] = [];\n\n\t\tfor (let { name, value } of node.attributes) {\n\t\t\t// No binding on the server\n\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\tname = name.substring(1);\n\t\t\t}\n\n\t\t\tif (name === \"class\" && value != null) {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\tprops.push({ name, value: `t_class(${params.join(\", \")})` });\n\t\t\t} else if (name === \"style\" && value != null) {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tprops.push({ name, value: `t_style(${value})` });\n\t\t\t} else if (value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\" });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props that we gathered\n\t\tb.append(`const ${propsName} = {`);\n\t\tfor (let p of props) {\n\t\t\tb.append(`${p.name}: ${p.value},`);\n\t\t}\n\t\tb.append(\"};\");\n\n\t\t// NOTE: Not sure if this is needed\n\t\t/*\n\t\tif (root) {\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t${propsName}[name] = $props[name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t\t*/\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, ServerSlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && slot.tagName === \"fill\") {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$sprops: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"// @ts-ignore\\n$sprops?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\t\t\t\tb.append(`let t_body = \"\";`);\n\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t\t}\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"return t_body;\");\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// Render the component\n\tlet renderParams = `${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\tconst componentResult = nextVarName(\"comp\", status);\n\tb.append(`const ${componentResult} = ${componentName}(${renderParams});`);\n\tb.append(`t_body += ${componentResult}.body;`);\n\tb.append(`t_head += ${componentResult}.head;`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerAwaitNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the await statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch) && branch.operation === \"@await\") {\n\t\t\tbuildServerAwaitBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerAwaitBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerForNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the for statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerForBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerForBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerHtmlNode(node: ControlNode, status: BuildServerStatus): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\t// Build the html statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tstatus.output += `\\${${branch.statement}}`;\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerIfNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the if statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerIfBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerIfBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerReplaceNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the replace statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerReplaceBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerReplaceBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement};`);\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildServerScriptNode(node: ControlNode, b: Builder): void {\n\tb.append(`${maybeAppend(node.statement, \";\")}`);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerSwitchNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// Build the switch statement\n\tb.append(`${node.statement} {`);\n\tfor (let branch of node.children.filter((c) => isControlNode(c))) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerSwitchBranch(branch, status, b);\n\t\t}\n\t}\n\tb.append(\"}\");\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerSwitchBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\tb.append(\"break;\");\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerAwaitNode from \"./buildServerAwaitNode\";\nimport buildServerForNode from \"./buildServerForNode\";\nimport buildServerHtmlNode from \"./buildServerHtmlNode\";\nimport buildServerIfNode from \"./buildServerIfNode\";\nimport buildServerReplaceNode from \"./buildServerReplaceNode\";\nimport buildServerScriptNode from \"./buildServerScriptNode\";\nimport buildServerSwitchNode from \"./buildServerSwitchNode\";\n\nexport default function buildServerControlNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildServerIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildServerSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildServerForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildServerAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@then\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildServerReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildServerHtmlNode(node, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\": {\n\t\t\tif (status.output) {\n\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\tstatus.output = \"\";\n\t\t\t}\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tif (status.output) {\n\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\tstatus.output = \"\";\n\t\t\t}\n\t\t\t//b.append(\"/* eslint-disable */\");\n\t\t\tb.append(\"\");\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tb.append(\"\");\n\t\t\t//b.append(\"/* eslint-enable */\");\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\t// These can't be used on the server\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","// From https://developer.mozilla.org/en-US/docs/Glossary/Void_element\nconst voidTags: string[] = [\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n];\nexport default voidTags;\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerElementNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tlet attributes = buildElementAttributes(node, status);\n\tif (attributes.length) {\n\t\tattributes = \" \" + attributes;\n\t}\n\n\tlet tagName = node.tagName;\n\tif (tagName === \"@element\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute) {\n\t\t\ttagName = `$\\{${selfAttribute.value}}`;\n\t\t}\n\t}\n\n\t// NOTE: Only void tags can be self-closed in HTML, although we allow it in\n\t// templates and auto-expand it here\n\tstatus.output += `<${tagName}${attributes}>`;\n\tif (!voidTags.includes(tagName)) {\n\t\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\t\tstatus.preserveWhitespace = [\"pre\", \"code\"].includes(tagName);\n\t\tfor (let child of node.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\t\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\t\tstatus.output += `</${tagName}>`;\n\t}\n}\n\nfunction buildElementAttributes(node: ElementNode, status: BuildServerStatus) {\n\tlet needsClass = node.scopeStyles;\n\tlet attributes: string[] = [];\n\tfor (let { name, value, reactive, fullyReactive } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// No elements on the server\n\t\t} else if (name.startsWith(\"on\") || name.startsWith(\":on\")) {\n\t\t\t// No events on the server\n\t\t} else if (name.startsWith(\"transition\") && value) {\n\t\t\t// TODO: No animation on the server, but we do need to set the\n\t\t\t// attributes from the first keyframe\n\t\t\t// HACK: use a regex instead maybe?\n\t\t\t//value = value.split(\",\")[0].trim();\n\t\t\t//if (value.startsWith(\"[\")) {\n\t\t\t//\tvalue = value.substring(1);\n\t\t\t//} else {\n\t\t\t//\tvalue = value + \"[0]\";\n\t\t\t//}\n\t\t\t//attributes.push(\n\t\t\t//\t`style=\"\\${Object.entries(${value}).map(([k, v]) => \\`$\\{k}: $\\{v}\\`).join(\"; \")}\"`,\n\t\t\t//);\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&value\" || name === \"&checked\" || name === \"&group\") {\n\t\t\t\tlet defaultValue = \"\";\n\t\t\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\t\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\t\t\tcase \"number\": {\n\t\t\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultValue) {\n\t\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\t\tvalue = `t_attr(${value})`;\n\t\t\t\t\tdefaultValue = '\"\"';\n\t\t\t\t}\n\t\t\t\tlet valueOrDefault = `${value} || ${defaultValue}`;\n\t\t\t\tconst propName = name.substring(1);\n\t\t\t\tattributes.push(`${propName}=\"\\${${valueOrDefault}}\"`);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tlet params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\tneedsClass = false;\n\t\t\t\t}\n\t\t\t\tattributes.push(`class=\"\\${t_class(${params.join(\", \")})}\"`);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tattributes.push(`style=\"\\${t_style(${value})}\"`);\n\t\t\t} else {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// e.g. `... ${className ? `class=\"${className}\"` : ''} ...`\n\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\tattributes.push(`\\${${value} ? \\`${name}=\"\\${t_attr(${value})}\"\\` : ''}`);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\t// TODO: Match braces, don't replace braces inside code\n\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\tattributes.push(\n\t\t\t\t`${name}=\"${trimQuotes(value).replaceAll(\"{\", \"${t_attr(\").replaceAll(\"}\", \")}\")}\"`,\n\t\t\t);\n\t\t} else if (name === \"class\" && node.scopeStyles) {\n\t\t\tvalue = value\n\t\t\t\t? `\"${trimQuotes(value)} torp-${status.styleHash}\"`\n\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t\tneedsClass = false;\n\t\t} else if (value != null) {\n\t\t\t// Just set the attribute\n\t\t\t// TODO: Probably check if it's a boolean attribute e.g. disabled\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t} else {\n\t\t\tattributes.push(`${name}`);\n\t\t}\n\t}\n\tif (needsClass) {\n\t\tattributes.push(`class=\"torp-${status.styleHash}\"`);\n\t}\n\treturn attributes.join(\" \");\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerRootNode(\n\tnode: RootNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerSlotNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tif (status.output) {\n\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"sprops\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tb.append(`const ${propsName}: any = {};`);\n\t\tfor (let { name, value } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t} else {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = true;`);\n\t\t\t}\n\t\t}\n\t}\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tb.append(`t_body += $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`);\n\t////const slotResult = nextVarName(\"comp\", status);\n\t////b.append(\n\t////\t`const ${slotResult} = $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`,\n\t////);\n\t////b.append(`t_body += ${slotResult}.body;`);\n\t////b.append(`t_head += ${slotResult}.head;`);\n\n\t// TODO: Not if there's only a single space node -- maybe check in parse\n\tconst fill = node.children.find((c) => isSpecialNode(c) && c.tagName === \"fill\");\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tfor (let child of fill.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\n\t\tif (status.output) {\n\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\tstatus.output = \"\";\n\t\t}\n\t}\n\n\tb.append(`}`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerSlotNode from \"./buildServerSlotNode\";\n\nexport default function buildServerSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildServerSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildServerElementNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildServerComponentNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport endOfString from \"../../utils/endOfString\";\nimport endOfTemplateString from \"../../utils/endOfTemplateString\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerTextNode(node: TextNode, status: BuildServerStatus): void {\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Move all of this logic into parse, for text nodes and attribute values\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tconst nextChar = content[i + 1];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tif (level === 1) {\n\t\t\t\tstatus.imports.add(\"t_fmt\");\n\t\t\t\tstatus.output += \"${t_fmt(\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tstatus.output += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\tstatus.output += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t// Skip one-line comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"\\n\", i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t// Skip block comments\n\t\t\t\tlet start = i;\n\t\t\t\ti = content.indexOf(\"*/\", i) + 1;\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t// Skip string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfString(char, content, i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t} else if (char === \"`\") {\n\t\t\t\t// Skip interpolated string contents\n\t\t\t\tlet start = i;\n\t\t\t\ti = endOfTemplateString(content, i);\n\t\t\t\tstatus.output += escapeHtml(content.substring(start, i + 1));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tstatus.output += char;\n\t}\n}\n\n// Escape HTML in comments and strings on the server, so that we don't output unintended tags etc\n// This doesn't need to be done on the client, where we will be setting textContent\nfunction escapeHtml(text: string) {\n\treturn text.replaceAll(\"&\", \"&amp;\").replaceAll(\"<\", \"&lt;\").replaceAll(\">\", \"&gt;\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerControlNode from \"./buildServerControlNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerRootNode from \"./buildServerRootNode\";\nimport buildServerSpecialNode from \"./buildServerSpecialNode\";\nimport buildServerTextNode from \"./buildServerTextNode\";\n\nexport default function buildServerNode(\n\tnode: TemplateNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildServerRootNode(node as RootNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildServerControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildServerComponentNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildServerElementNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildServerTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildServerSpecialNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport Builder from \"../../utils/Builder\";\nimport buildStyles from \"../client/buildStyles\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$mount: 'import { $mount } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_attr: 'import { t_attr } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tServerSlotRender: 'import { type ServerSlotRender } from \"${folder}\";',\n};\n\nexport default function buildServerCode(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"ServerSlotRender\");\n\n\t// Build the component and any child components\n\tbuildServerTemplate(template, imports, b, options);\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tb.prepend(\"\");\n\t\tfor (let imp of Array.from(imports).sort().reverse()) {\n\t\t\timp = importsMap[imp] || imp;\n\t\t\tb.prepend(imp.replace(\"${folder}\", options?.renderFolder || \"@torpor/view/ssr\"));\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildServerTemplate(\n\ttemplate: Template,\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(script)) imports.add(\"$watch\");\n\tif (/\\$cache\\b/.test(script)) imports.add(\"$cache\");\n\tif (/\\$run\\b/.test(script)) imports.add(\"$run\");\n\tif (/\\$mount\\b/.test(script)) imports.add(\"$mount\");\n\tif (/\\$unwrap\\b/.test(script)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(script)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(script)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tlet params = [\n\t\t\t\tcurrent.params ??\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"// @ts-ignore\\n$props?: Record<PropertyKey, any>\"}`,\n\t\t\t\t`${current.contextProps?.length ? \"$context\" : \"// @ts-ignore\\n$context\"}?: Record<PropertyKey, any>`,\n\t\t\t\t`${current.slotProps?.length ? \"$slots\" : \"// @ts-ignore\\n$slots\"}?: Record<string, ServerSlotRender>`,\n\t\t\t];\n\t\t\tb.append(params.join(\",\\n\"));\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): { body: string, head: string } {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\n\t\t\t// Declare t_head and t_body\n\t\t\tb.append(`let t_body = \"\";`);\n\t\t\tb.append(`let t_head = \"\";`);\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.markup) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\tbuildServerNode(current.markup, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\t\t\t// TODO: need to add e.g. a title to the head, but remove when changing page\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.style) {\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Style */\");\n\n\t\t\t\t// Replace multiple spaces with a single space\n\t\t\t\tconst styles = buildStyles(current.style, current.style.hash)\n\t\t\t\t\t.replaceAll('\"', '\\\\\"')\n\t\t\t\t\t.replaceAll(/\\s+/g, \" \");\n\t\t\t\tb.append(`t_head += \"<style id='${current.style.hash}'>${styles}</style>\";\\n`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\tb.append(`return { body: t_body, head: t_head };`);\n\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\tb.append(chunk.script);\n\t\t}\n\t}\n}\n","import type Template from \"../types/Template\";\nimport buildCode from \"./build/client/buildCode\";\nimport buildStyles from \"./build/client/buildStyles\";\nimport buildServerCode from \"./build/server/buildServerCode\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport type BuildResult from \"./types/BuildResult\";\nimport type SourceMapping from \"./types/SourceMapping\";\n\n/**\n * Builds a component template into code and styles for rendering\n *\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The component's code and styles\n */\nexport default function build(template: Template, options?: BuildOptions): BuildResult {\n\tlet map: SourceMapping[] = [];\n\tlet code = options?.server\n\t\t? buildServerCode(template, options)\n\t\t: buildCode(template, map, options);\n\tlet styles = template.components\n\t\t.map((c) =>\n\t\t\tc.style ? { style: buildStyles(c.style, c.style.hash), hash: c.style.hash } : undefined,\n\t\t)\n\t\t.filter((c) => c !== undefined);\n\treturn {\n\t\tcode,\n\t\tstyles,\n\t\tmap,\n\t};\n}\n","import type Template from \"../types/Template\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport Builder from \"./utils/Builder\";\n\n/**\n * Builds a component template into a d.ts file\n *\n * @param name The name of the component\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The d.ts file content\n */\nexport default function buildType(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder();\n\n\tb.append(`import { type SlotRender } from \"${options?.renderFolder || \"@torpor/view\"}\";`);\n\n\tfor (let component of template.components) {\n\t\tif (component.exported) {\n\t\t\tb.append(\"\");\n\t\t\tif (component.propsType) {\n\t\t\t\tb.append(component.propsType);\n\t\t\t\tb.append(\"\");\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t${component.documentation ?? \"\"}\n\t\t\t${component.default ? \"declare\" : \"export declare\"} function ${component.name}(\n\t\t\t\t$parent: ParentNode,\n\t\t\t\t$anchor: Node | null,\n\t\t\t\t${component.params || \"$props?: Record<PropertyKey, any>\"},\n\t\t\t\t$context?: Record<PropertyKey, any>,\n\t\t\t\t$slots?: Record<string, SlotRender>,\n\t\t\t): void;\n\t\t`);\n\t\t\tif (component.default) {\n\t\t\t\tb.append(`export default ${component.name};`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"./isTextNode\";\n\nexport default function isSpaceNode(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && isSpace(node.content);\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function accept(value: string, status: ParseStatus, advance = true): boolean {\n\tconst check = status.source.substring(status.i, status.i + value.length);\n\tif (check == value) {\n\t\tstatus.i += advance ? value.length : 0;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\n\nexport default function parseInlineScript(status: ParseStatus): string {\n\tconst start = status.i;\n\tlet braceCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tif (accept(\"{\", status)) {\n\t\t\tbraceCount += 1;\n\t\t} else if (accept(\"}\", status)) {\n\t\t\tif (braceCount > 0) {\n\t\t\t\tbraceCount -= 1;\n\t\t\t} else {\n\t\t\t\treturn status.source.substring(start, status.i - 1);\n\t\t\t}\n\t\t} else if (accept(\"//\", status)) {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"/*\", status)) {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept('\"', status) || accept(\"'\", status)) {\n\t\t\t// Skip string contents\n\t\t\tconst char = status.source[status.i - 1];\n\t\t\tstatus.i = endOfString(char, status.source, status.i - 1) + 1;\n\t\t} else if (accept(\"`\", status)) {\n\t\t\t// Skip template string contents\n\t\t\tstatus.i = endOfTemplateString(status.source, status.i - 1) + 1;\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n","/**\n * Trims a char from the start of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the start of the text\n *\n * @returns The text without the char on the start\n */\nexport default function trimStart(text: string, char: string): string {\n\tlet start = 0;\n\twhile (text[start] === char) {\n\t\tstart += 1;\n\t}\n\treturn text.substring(start);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Consumes space characters and advances the current parse position to before\n * the next non-space character\n *\n * @param status The parse status\n *\n * @returns The string of space characters from the current parse position to\n * the next non-space character\n */\nexport default function consumeSpace(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isSpaceChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function addSpaceElement(\n\tparent: ElementNode | ControlNode,\n\tstatus: ParseStatus,\n): void {\n\tconst content = consumeSpace(status);\n\tif (content) {\n\t\tconst previousNode = parent.children[parent.children.length - 1];\n\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\tpreviousNode.content += content;\n\t\t} else {\n\t\t\tconst space: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tparent.children.push(space);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied string is fully reactive (i.e. starts and ends with braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully reactive\n */\nexport default function isFullyReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.trim().startsWith(\"{\") && text.trim().endsWith(\"}\");\n}\n","/**\n * Checks whether the supplied character is a alpha-numeric\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is alpha-numeric\n */\nexport default function isAlphaNumericChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn (\n\t\t// 0-9\n\t\t(code > 47 && code < 58) ||\n\t\t// A-Z\n\t\t(code > 64 && code < 91) ||\n\t\t// a-z\n\t\t(code > 96 && code < 123)\n\t);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isAlphaNumericChar from \"./isAlphaNumericChar\";\n\n/**\n * Consumes alpha-numeric characters and advances the current parse position to\n * before the next non-alpha character\n *\n * @param status The parse status\n *\n * @returns The string of alpha-numeric characters from the current parse position\n * to the next non-alpha character\n */\nexport default function consumeAlphaNumeric(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isAlphaNumericChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Consumes characters until one of the characters in the supplied string is\n * found. The parse position will be advanced to before the found character\n *\n * @param chars The characters to match\n * @param status The parse status\n *\n * @returns The string of characters from the current parse position to the\n * found character\n */\nexport default function consumeUntil(chars: string, status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (chars.includes(status.source[status.i])) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type Attribute from \"../types/nodes/Attribute\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isFullyReactive from \"../utils/isFullyReactive\";\nimport isReactive from \"../utils/isReactive\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\n\nexport default function parseTag(status: ParseStatus): ElementNode {\n\taccept(\"<\", status);\n\n\tlet closeTag = accept(\"/\", status);\n\n\tconsumeSpace(status);\n\n\tlet tagStart = status.i + 1;\n\tlet snailed = accept(\"@\", status);\n\tlet tagName = consumeAlphaNumeric(status);\n\tlet tagEnd = status.i;\n\n\tif (snailed) {\n\t\ttagName = \"@\" + tagName;\n\t}\n\tif (closeTag) {\n\t\ttagName = \"/\" + tagName;\n\t}\n\n\tconsumeSpace(status);\n\n\tlet attributes = parseTagAttributes(status);\n\n\tlet selfClosed = false;\n\tif (accept(\"/>\", status)) {\n\t\tselfClosed = true;\n\t\t// Actually, it is kind of convenient to self-close things, and more consistent with\n\t\t// component tags...\n\t\t//if (!voidTags.includes(tagName)) {\n\t\t//\taddError(status, `Self-closed non-void element: ${tagName}`, start);\n\t\t//}\n\t} else {\n\t\taccept(\">\", status);\n\t}\n\n\tif (closeTag) {\n\t\tselfClosed = true;\n\t}\n\n\tlet special = [\"slot\", \"fill\", \"@component\", \"@element\"].includes(tagName);\n\n\treturn {\n\t\ttype: special ? \"special\" : \"element\",\n\t\ttagName,\n\t\tselfClosed: selfClosed || undefined,\n\t\tclosed: selfClosed || undefined,\n\t\tattributes,\n\t\tchildren: [],\n\t\tspan: { start: tagStart, end: tagEnd },\n\t} satisfies ElementNode;\n}\n\nfunction parseTagAttributes(status: ParseStatus): Attribute[] {\n\tlet attributes: Attribute[] = [];\n\twhile (status.i < status.source.length) {\n\t\tconsumeSpace(status);\n\t\tif (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"/>\", status, false) || accept(\">\", status, false)) {\n\t\t\t// That's the end of the attributes\n\t\t\tbreak;\n\t\t} else if (\n\t\t\taccept(\"<\", status, false) ||\n\t\t\taccept(\"@\", status, false) ||\n\t\t\taccept(\"}\", status, false)\n\t\t) {\n\t\t\t// It's an unclosed tag -- just bail out here\n\t\t\tbreak;\n\t\t} else {\n\t\t\tconst attribute = parseAttribute(status);\n\t\t\tattributes.push(attribute);\n\t\t}\n\t}\n\treturn attributes;\n}\n\nfunction parseAttribute(status: ParseStatus): Attribute {\n\tlet valueStart = status.i;\n\tlet valueEnd = status.i;\n\tlet name = consumeUntil(\"= \\t\\r\\n/>\", status);\n\tlet value: string | undefined = undefined;\n\tlet reactive = false;\n\tlet fullyReactive = false;\n\tconsumeSpace(status);\n\tif (accept(\"=\", status)) {\n\t\tconsumeSpace(status);\n\t\tvalueStart = status.i;\n\t\tvalue = parseAttributeValue(status);\n\t\tvalueEnd = status.i;\n\t\treactive = isReactive(value);\n\t\tfullyReactive = isFullyReactive(value);\n\t\tif (fullyReactive) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t\tvalueStart++;\n\t\t\tvalueEnd--;\n\t\t}\n\t} else if (name.startsWith(\"{\") && name.endsWith(\"}\")) {\n\t\t// It's a shortcut attribute. It could be e.g. {width} or it could be\n\t\t// {$state.width}, but in either case we set the value of the width\n\t\t// property\n\t\tvalue = name.substring(1, name.length - 1);\n\t\tvalueStart++;\n\t\tvalueEnd = valueStart + name.length;\n\t\tname = value.split(\".\").at(-1)!;\n\t\t// Handle definite assignment assertions e.g. {$state.width!}\n\t\tif (name.endsWith(\"!\")) {\n\t\t\tname = name.substring(0, name.length - 1);\n\t\t}\n\t\treactive = fullyReactive = true;\n\t}\n\treturn {\n\t\tname,\n\t\tvalue,\n\t\treactive,\n\t\tfullyReactive,\n\t\tspan: { start: valueStart, end: valueEnd },\n\t};\n}\n\nfunction parseAttributeValue(status: ParseStatus): string {\n\tif (accept('\"', status)) {\n\t\tconst value = consumeUntil('\"', status);\n\t\taccept('\"', status);\n\t\treturn `\"${value}\"`;\n\t} else if (accept(\"'\", status)) {\n\t\tconst value = consumeUntil(\"'\", status);\n\t\taccept(\"'\", status);\n\t\treturn `'${value}'`;\n\t} else if (accept(\"{\", status)) {\n\t\tconst value = parseInlineScript(status);\n\t\treturn `{${value}}`;\n\t} else {\n\t\tlet value = consumeUntil(\" \\t\\r\\n>\", status);\n\t\t// Check whether we've landed at /> and if so, rewind\n\t\tif (status.source.substring(status.i - 1, status.i + 1) === \"/>\") {\n\t\t\tvalue = value.substring(0, value.length - 1);\n\t\t\tstatus.i -= 1;\n\t\t}\n\t\treturn value;\n\t}\n}\n","import type SourceSpan from \"../types/SourceSpan\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseText(status: ParseStatus, element: ElementNode): void {\n\t// Add a range for each reactive part of the text so that we can map them\n\t// back when building\n\tlet spans: SourceSpan[] = [];\n\n\t// Text ends at the next element, or at the next control statement, or at\n\t// the end of the render\n\t// But only if the control statement is after a newline, so we don't mess\n\t// with emails etc. This may need more finessing\n\tconst start = status.i;\n\tlet end = -1;\n\tfor (let j = status.i; j < status.source.length; j++) {\n\t\tif (status.source[j] === \"}\") {\n\t\t\t// That's the rendering done\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"{\") {\n\t\t\t// Skip reactive content\n\t\t\tconst reactiveStart = j + 1;\n\t\t\tlet level = 0;\n\t\t\tfor (let k = j; k < status.source.length; k++) {\n\t\t\t\tconst char = status.source[k];\n\t\t\t\tconst nextChar = status.source[k + 1];\n\t\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\t\t// Skip one-line comments\n\t\t\t\t\tk = status.source.indexOf(\"\\n\", k);\n\t\t\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t\t\t// Skip block comments\n\t\t\t\t\tk = status.source.indexOf(\"*/\", k) + 1;\n\t\t\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t\t\t// Skip string contents\n\t\t\t\t\tk = endOfString(char, status.source, k);\n\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t// Skip template string contents\n\t\t\t\t\tk = endOfTemplateString(status.source, k);\n\t\t\t\t} else if (char === \"{\") {\n\t\t\t\t\tlevel += 1;\n\t\t\t\t} else if (char === \"}\") {\n\t\t\t\t\tlevel -= 1;\n\t\t\t\t\tif (level === 0) {\n\t\t\t\t\t\tj = k;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the source range\n\t\t\tspans.push({ start: reactiveStart, end: j });\n\t\t} else if (status.source[j] === \"<\") {\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"@\") {\n\t\t\t// Backtrack\n\t\t\tfor (let k = j - 1; k > status.i; k--) {\n\t\t\t\tif (status.source[k] === \"\\n\") {\n\t\t\t\t\tend = j;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (!isSpaceChar(status.source, k)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (end !== -1) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (end !== -1) {\n\t\tconst content = status.source.substring(start, end).trimEnd();\n\t\tconst spaceContent = status.source.substring(start + content.length, end);\n\t\tif (content || spaceContent) {\n\t\t\tconst previousNode = element.children[element.children.length - 1];\n\t\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\t\tpreviousNode.content += content + spaceContent;\n\t\t\t\tpreviousNode.spans.push(...spans);\n\t\t\t\t//previousNode.range.endIndex += content.length + spaceContent.length;\n\t\t\t\t// TODO: end char etc\n\t\t\t} else {\n\t\t\t\tconst text: TextNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\tcontent: content + spaceContent,\n\t\t\t\t\tspans,\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t}\n\t\t}\n\t\tstatus.i = end;\n\t} else {\n\t\tstatus.i += 1;\n\t}\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\n\n/**\n * Moves any child nodes that aren't already in a <fill> node into a default\n * <fill> node\n */\nexport default function slottifyChildNodes(node: ElementNode): void {\n\tconst nonFillNodes = node.children.filter((c) => !isFillNode(c));\n\t// TODO: Not if it's only spaces??\n\tif (nonFillNodes.length) {\n\t\tlet defaultFillNode = node.children.find(\n\t\t\t(n) => isFillNode(n) && !n.attributes.find((a) => a.name === \"name\"),\n\t\t) as ElementNode | undefined;\n\t\tif (!defaultFillNode) {\n\t\t\tdefaultFillNode = {\n\t\t\t\ttype: \"special\",\n\t\t\t\ttagName: \"fill\",\n\t\t\t\tattributes: [],\n\t\t\t\tchildren: nonFillNodes,\n\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t};\n\t\t\tnode.children.unshift(defaultFillNode);\n\t\t}\n\t}\n\tnode.children = node.children.filter((c) => isFillNode(c));\n}\n\nfunction isFillNode(n: TemplateNode): n is ElementNode {\n\treturn isSpecialNode(n) && n.tagName === \"fill\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Adds an error to the parse status\n *\n * @param status The parse status\n * @param message The error message to add\n * @param start (Optional) The start position of the error (defaults to the\n * current parse position)\n */\nexport default function addError(\n\tstatus: ParseStatus,\n\tmessage: string,\n\tstart: number = status.i,\n\tend: number = status.i,\n): void {\n\tlet startLine = 0;\n\tlet lastLineStart = 0;\n\tlet i = 0;\n\tfor (; i < start; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tstartLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet startChar = start - lastLineStart;\n\tlet endLine = startLine;\n\tfor (; i < end; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tendLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet endChar = end - lastLineStart;\n\tstatus.errors.push({\n\t\tmessage,\n\t\tstartIndex: start,\n\t\tstartLine,\n\t\tstartChar,\n\t\tendIndex: end,\n\t\tendLine,\n\t\tendChar,\n\t});\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport voidTags from \"../utils/voidTags\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseControl from \"./parseControl\";\nimport parseTag from \"./parseTag\";\nimport parseText from \"./parseText\";\nimport slottifyChildNodes from \"./slottifyChildNodes\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseElement(status: ParseStatus): ElementNode {\n\tconst current = status.components.at(-1);\n\tif (!current) throw new Error(\"No component in stack\");\n\n\tconst start = status.i;\n\n\tconst element = parseTag(status);\n\n\tif (element.tagName.startsWith(\"/\")) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${element.tagName.substring(1)}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length,\n\t\t);\n\t\treturn element;\n\t}\n\n\tif (voidTags.includes(element.tagName)) {\n\t\tcheckVoidElement(status, element);\n\t}\n\n\tif (!element.selfClosed && !voidTags.includes(element.tagName)) {\n\t\tstatus.stack.push(element);\n\n\t\t// Get the children\n\t\twhile (status.i < status.source.length) {\n\t\t\taddSpaceElement(element, status);\n\t\t\tif (accept(\"}\", status, false)) {\n\t\t\t\t// That's the rendering done\n\t\t\t\tbreak;\n\t\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t\t// It's a comment, swallow it\n\t\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\t} else if (accept(\"@//\", status)) {\n\t\t\t\t// Swallow one-line comments\n\t\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t\t// Swallow block comments\n\t\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\t} else if (accept(\"</\", status, false)) {\n\t\t\t\t// It's a close tag, so we're done here\n\t\t\t\tif (checkCloseTag(status, element)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t\t// It's a child element\n\t\t\t\tconst child = parseElement(status);\n\t\t\t\telement.children.push(child);\n\t\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t\t// It's a control statement\n\t\t\t\tparseControl(status, element);\n\t\t\t} else {\n\t\t\t\t// It's text content\n\t\t\t\tparseText(status, element);\n\t\t\t}\n\t\t}\n\n\t\tstatus.stack.pop();\n\t}\n\n\t// If this is a component element, add a default <fill> node\n\t// HACK: For now, we just treat all tags starting with a capital as components\n\tif (/[A-Z]/.test(element.tagName[0])) {\n\t\telement.type = \"component\";\n\t\tslottifyChildNodes(element);\n\t}\n\n\tif (isSpecialNode(element)) {\n\t\tif (element.tagName === \"slot\") {\n\t\t\t// If this is a <slot> element, add a <fill> node for its fallback\n\t\t\t// content. Anchors will be created for <slot> nodes and fragments will\n\t\t\t// be created for the <fill> content\n\t\t\tslottifyChildNodes(element);\n\n\t\t\t// Add it to the component's slots collection\n\t\t\tcurrent.slotProps ??= [];\n\t\t\tcurrent.slotProps.push(element.attributes.find((a) => a.name === \"name\")?.name ?? \"default\");\n\t\t} else if (element.tagName === \"fill\") {\n\t\t\tconst fillSource = status.source.substring(start, status.i);\n\t\t\telement.hasSlotProps = /\\$sprops\\b/.test(fillSource);\n\t\t} else if (element.tagName === \"@component\") {\n\t\t\tconst selfAttribute = element.attributes.find((a) => a.name === \"self\");\n\t\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\t\telement.type = \"component\";\n\t\t\t\tslottifyChildNodes(element);\n\n\t\t\t\tconst selfValue = selfAttribute.value;\n\t\t\t\tconst replace: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [element],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\t\t\t\tconst replaceGroup: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace group\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [replace],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\n\t\t\t\treturn replaceGroup as any;\n\t\t\t} else {\n\t\t\t\taddError(\n\t\t\t\t\tstatus,\n\t\t\t\t\t\"@component element must have a self attribute\",\n\t\t\t\t\tstart,\n\t\t\t\t\tstart + element.tagName.length + 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!element.closed && !voidTags.includes(element.tagName)) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unclosed non-void element: ${element.tagName}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn element;\n}\n\nfunction checkVoidElement(status: ParseStatus, element: ElementNode) {\n\tlet i = status.i;\n\n\tconsumeSpace(status);\n\tif (accept(\"</\", status)) {\n\t\tconsumeSpace(status);\n\t\tif (accept(element.tagName, status)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Closed void element: ${element.tagName}`,\n\t\t\t\ti,\n\t\t\t\ti + element.tagName.length + 1,\n\t\t\t);\n\t\t\tconsumeSpace(status);\n\t\t\taccept(\">\", status);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tstatus.i = i;\n}\n\nfunction checkCloseTag(status: ParseStatus, element: ElementNode) {\n\tconst start = status.i;\n\n\taccept(\"</\", status);\n\tconsumeSpace(status);\n\tlet snailed = accept(\"@\", status);\n\tlet closingTagName = consumeAlphaNumeric(status);\n\tif (snailed) {\n\t\tclosingTagName = \"@\" + closingTagName;\n\t}\n\tconsumeSpace(status);\n\taccept(\">\", status);\n\n\tlet found = false;\n\tfor (let i = status.stack.length - 1; i >= 0; i--) {\n\t\tif (closingTagName === status.stack[i].tagName) {\n\t\t\tstatus.stack[i].closed = true;\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${closingTagName} (expected ${element.tagName})`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn found;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type OperationType from \"../types/nodes/OperationType\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isControlNode from \"../utils/isControlNode\";\nimport trimMatched from \"../utils/trimMatched\";\nimport trimStart from \"../utils/trimStart\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseElement from \"./parseElement\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nconst controlOperations = [\n\t\"@if\",\n\t\"@else\",\n\t\"@for\",\n\t\"@key\",\n\t\"@switch\",\n\t\"@case\",\n\t\"@default\",\n\t\"@await\",\n\t\"@then\",\n\t\"@catch\",\n\t\"@replace\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nconst standaloneOperations = [\n\t\"@key\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nexport default function parseControl(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n): void {\n\tconst node = parseControlOpen(status);\n\tif (!node) {\n\t\treturn;\n\t}\n\n\t// Some operations don't have children\n\tif (standaloneOperations.includes(node.operation)) {\n\t\twrangleControlNode(node, parentNode);\n\t\treturn;\n\t}\n\n\t// Get the children\n\twhile (status.i < status.source.length) {\n\t\taddSpaceElement(node, status);\n\t\tif (accept(\"}\", status)) {\n\t\t\t// It's the end of the control block, so we're done here\n\t\t\tbreak;\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// It's a child element\n\t\t\tconst child = parseElement(status);\n\t\t\tnode.children.push(child);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// It's a nested control\n\t\t\tparseControl(status, node);\n\t\t} else if (accept(\"case\", status, false) || accept(\"key\", status, false)) {\n\t\t\t// `case` and `key` can be bare in a control block\n\t\t\tparseControl(status, node);\n\t\t} else {\n\t\t\t// Can't have text content in control blocks\n\t\t\tconst char = status.source[status.i];\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Unexpected token in control block: ${char}`,\n\t\t\t\tstatus.i,\n\t\t\t\t// TODO: Should probably go until a boundary\n\t\t\t\tstatus.i + 1,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twrangleControlNode(node, parentNode);\n\n\tparseControlBranches(status, parentNode);\n}\n\nfunction parseControlOpen(status: ParseStatus): ControlNode | null {\n\tconst start = status.i;\n\tlet statementStart = start;\n\n\tlet operation = \"\";\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (\n\t\t\t(isSpaceChar(status.source, status.i) && operation !== \"@async\") ||\n\t\t\t(accept(\":\", status) && operation === \"default\") ||\n\t\t\t(accept(\".\", status) && operation === \"@console\") ||\n\t\t\t(accept(\"(\", status, false) && operation === \"@html\")\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\toperation += char;\n\t}\n\n\t// Some operations (else etc) don't start with an @\n\tif (!operation.startsWith(\"@\")) {\n\t\toperation = \"@\" + operation;\n\t} else {\n\t\tstatementStart++;\n\t}\n\n\tlet statement = \"\";\n\tif (controlOperations.includes(operation)) {\n\t\tstatement = parseControlStatement(start, operation, status);\n\n\t\t// Special processing for functions -- read until the closing brace\n\t\tif (operation === \"@function\" || operation === \"@async function\") {\n\t\t\tstatement += ` {${parseInlineScript(status)}}`;\n\t\t\taccept(\"}\", status);\n\t\t}\n\n\t\t// Special processing for replace and html\n\t\tif (operation === \"@replace\" || operation === \"@html\") {\n\t\t\tstatement = trimMatched(statement.substring(statement.indexOf(\"(\")).trim(), \"(\", \")\");\n\t\t}\n\t} else {\n\t\t// TODO: Should probably advance until a closing brace or a newline\n\t\taddError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"control\",\n\t\toperation: operation as OperationType,\n\t\tstatement,\n\t\tchildren: [],\n\t\tspan: { start: statementStart, end: status.i },\n\t};\n}\n\nfunction parseControlStatement(start: number, operation: string, status: ParseStatus) {\n\tlet parenCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tif (accept(\"(\", status)) {\n\t\t\tparenCount += 1;\n\t\t} else if (accept(\")\", status)) {\n\t\t\tparenCount -= 1;\n\t\t} else if (\n\t\t\taccept(\"{\", status) ||\n\t\t\t(accept(\"\\n\", status) && standaloneOperations.includes(operation))\n\t\t) {\n\t\t\tif (parenCount === 0) {\n\t\t\t\treturn trimStart(status.source.substring(start, status.i - 1).trim(), \"@\");\n\t\t\t}\n\t\t} else if (accept(\"//\", status)) {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"/*\", status)) {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept('\"', status) || accept(\"'\", status)) {\n\t\t\t// Skip string contents\n\t\t\tlet char = status.source[status.i - 1];\n\t\t\tstatus.i = endOfString(char, status.source, status.i - 1) + 1;\n\t\t} else if (accept(\"`\", status)) {\n\t\t\t// Skip template string contents\n\t\t\tstatus.i = endOfTemplateString(status.source, status.i - 1) + 1;\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n\n/**\n * Groups the control node into the correct parent e.g. if/else into an if group\n * @param node The control node\n * @param parentNode The parent node\n */\nfunction wrangleControlNode(node: ControlNode, parentNode: RootNode | ElementNode | ControlNode) {\n\t// Group\n\t// * if/else into an if group\n\t// * for into a for group\n\t// * switch into a switch group (cases will have the correct parent)\n\t// * await/then/catch into an await group\n\t// * replace into a replace group\n\t// * html into a html group\n\tif (node.operation === \"@if\") {\n\t\tconst ifGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@if group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(ifGroup);\n\t} else if (node.operation === \"@else\") {\n\t\tif (/^else\\s+if/.test(node.statement)) {\n\t\t\tnode.operation = \"@else if\";\n\t\t}\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@if group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@for\") {\n\t\tconst forGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@for group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(forGroup);\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@switch\") {\n\t\tnode.operation = \"@switch group\";\n\t\tparentNode.children.push(node);\n\t} else if (node.operation === \"@await\") {\n\t\tconst awaitGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@await group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(awaitGroup);\n\t} else if (node.operation === \"@then\" || node.operation === \"@catch\") {\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@await group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (node.operation === \"@replace\") {\n\t\tconst replaceGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@replace group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(replaceGroup);\n\t} else if (node.operation === \"@html\") {\n\t\tconst htmlGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@html group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(htmlGroup);\n\t} else {\n\t\tparentNode.children.push(node);\n\t}\n}\n\n/**\n * Parses control branches that don't start with an @ symbol e.g. else or case\n * @param status The parse status\n * @param parentNode The parent node\n */\nfunction parseControlBranches(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n) {\n\t// Look ahead and see if we have another control statement\n\t// NOTE: We could be more strict here (e.g. we could check that an else is\n\t// after an if), but for now we are just leaving it to the JS parser\n\tlet gotAnotherBranch = true;\n\twhile (gotAnotherBranch) {\n\t\tlet start = status.i;\n\t\tstatus.i += 1;\n\t\tconsumeSpace(status);\n\t\tif (\n\t\t\taccept(\"else\", status, false) ||\n\t\t\taccept(\"case\", status, false) ||\n\t\t\taccept(\"default\", status, false) ||\n\t\t\taccept(\"then\", status, false) ||\n\t\t\taccept(\"catch\", status, false)\n\t\t) {\n\t\t\tparseControl(status, parentNode);\n\t\t} else {\n\t\t\tgotAnotherBranch = false;\n\t\t\tstatus.i = start;\n\t\t}\n\t}\n}\n","import type TextNode from \"../types/nodes/TextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseControl from \"./parseControl\";\nimport parseElement from \"./parseElement\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseMarkup(status: ParseStatus, source: string): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\twhile (status.i < source.length) {\n\t\tif (accept(\"}\", status, false)) {\n\t\t\t// That's the rendering done\n\t\t\treturn;\n\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t// It's a comment, swallow it\n\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (isSpaceChar(status.source, status.i)) {\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\t//const start = status.i;\n\t\t\tconst space = consumeSpace(status);\n\t\t\tconst text: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent: space,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tcurrent.markup.children.push(text);\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// Parse the element\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\tconst element = parseElement(status);\n\t\t\tcurrent.markup.children.push(element);\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// Parse the control\n\t\t\tcurrent.markup ??= { type: \"root\", children: [] };\n\t\t\tparseControl(status, current.markup);\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n}\n","// Adapted from https://github.com/sveltejs/svelte\n\nconst returnRegex = /\\r/g;\n\nexport default function hash(input: string): string {\n\tinput = input.replace(returnRegex, \"\");\n\tlet hash = 5381;\n\tlet i = input.length;\n\twhile (i--) {\n\t\thash = ((hash << 5) - hash) ^ input.charCodeAt(i);\n\t}\n\treturn (hash >>> 0).toString(36);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport addError from \"./addError\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string and if not, adds an error to the parse status\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function expect(value: string, status: ParseStatus, advance = true): boolean {\n\tif (status.i < status.source.length) {\n\t\tif (status.source.substring(status.i, status.i + value.length) == value) {\n\t\t\tstatus.i += advance ? value.length : 0;\n\t\t\treturn true;\n\t\t} else {\n\t\t\taddError(status, `Expected ${value}`);\n\t\t}\n\t} else {\n\t\taddError(status, \"Expected token\");\n\t}\n\treturn false;\n}\n","import type Attribute from \"../types/styles/Attribute\";\nimport type StyleBlock from \"../types/styles/StyleBlock\";\nimport hash from \"../utils/hash\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\nimport expect from \"./utils/expect\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseStyles(source: string, status: ParseStatus): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tcurrent.style = {\n\t\tglobal: false,\n\t\tblocks: [],\n\t\thash: hash(source),\n\t};\n\n\tconst styleStatus: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\twhile (styleStatus.i < styleStatus.source.length) {\n\t\tif (isSpaceChar(styleStatus.source, styleStatus.i)) {\n\t\t\tconsumeSpace(styleStatus);\n\t\t} else {\n\t\t\tconst block = parseStyleBlock(styleStatus);\n\t\t\tif (block) {\n\t\t\t\tcurrent.style.blocks.push(block);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.errors = status.errors.concat(styleStatus.errors);\n}\n\nfunction parseStyleBlock(status: ParseStatus): StyleBlock | undefined {\n\tconst selector = consumeUntil(\"{\", status).trim();\n\tif (expect(\"{\", status)) {\n\t\tconst block: StyleBlock = {\n\t\t\tselector,\n\t\t\tattributes: [],\n\t\t\tchildren: [],\n\t\t};\n\t\tconsumeSpace(status);\n\t\twhile (status.source[status.i] !== \"}\") {\n\t\t\t// HACK: Is it an attribute or a child block?\n\t\t\tlet nextColon = status.source.indexOf(\":\", status.i);\n\t\t\tif (nextColon === -1) nextColon = status.source.length;\n\t\t\tlet nextOpenBrace = status.source.indexOf(\"{\", status.i);\n\t\t\tif (nextOpenBrace === -1) nextOpenBrace = status.source.length;\n\t\t\tif (nextColon < nextOpenBrace) {\n\t\t\t\tconst attribute = parseStyleAttribute(status);\n\t\t\t\tblock.attributes.push(attribute);\n\t\t\t} else if (nextOpenBrace < nextColon) {\n\t\t\t\tconst child = parseStyleBlock(status);\n\t\t\t\tif (child) {\n\t\t\t\t\tblock.children.push(child);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn block;\n\t\t\t}\n\t\t\tconsumeSpace(status);\n\t\t}\n\t\taccept(\"}\", status);\n\n\t\treturn block;\n\t}\n}\n\nfunction parseStyleAttribute(status: ParseStatus): Attribute {\n\tconst name = consumeUntil(\":\", status).trim();\n\taccept(\":\", status);\n\tconst value = consumeUntil(\";\", status).trim();\n\taccept(\";\", status);\n\treturn {\n\t\tname,\n\t\tvalue,\n\t};\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isComponentNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"component\";\n}\n","import type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isParentNode(node: TemplateNode): node is ParentNode {\n\treturn \"children\" in node;\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type StyleBlock from \"../types/styles/StyleBlock\";\nimport isComponentNode from \"../utils/isComponentNode\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isParentNode from \"../utils/isParentNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\n\nexport default function scopeStyles(status: ParseStatus): void {\n\tlet selectors: string[] = [];\n\tfor (let component of status.components) {\n\t\tif (component.style && component.markup) {\n\t\t\tfor (let block of component.style.blocks) {\n\t\t\t\tcollectStyleSelectors(block, selectors);\n\t\t\t}\n\t\t\tscopeStylesOnNode(component.markup, selectors);\n\t\t}\n\t}\n}\n\nfunction scopeStylesOnNode(node: TemplateNode, selectors: string[]) {\n\tif (isElementNode(node) || isComponentNode(node)) {\n\t\tnode.scopeStyles =\n\t\t\tselectors.includes(node.tagName) ||\n\t\t\tnode.attributes.find((a) => {\n\t\t\t\tif (a.name === \"class\" && a.reactive) {\n\t\t\t\t\t// Any reactivity in a class attribute makes it scoped,\n\t\t\t\t\t// because we can't tell what's going on in there\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (a.name === \"id\" && a.value) {\n\t\t\t\t\tif (selectors.includes(`#${trimQuotes(a.value)}`)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t} else if (a.name === \"class\" && a.value) {\n\t\t\t\t\tfor (let classname of trimQuotes(a.value).split(/\\s+/)) {\n\t\t\t\t\t\tif (selectors.includes(`.${classname}`)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) !== undefined;\n\t}\n\n\tif (isParentNode(node)) {\n\t\tfor (let child of node.children) {\n\t\t\tscopeStylesOnNode(child, selectors);\n\t\t}\n\t}\n}\n\nfunction collectStyleSelectors(block: StyleBlock, selectors: string[]) {\n\t// HACK: We should be collecting the actual selectors and then checking\n\t// attributes, parents, children, siblings etc\n\tfor (let s of block.selector.split(/[\\s*,>+~]/)) {\n\t\tselectors.push(s);\n\t}\n}\n","import type TemplateComponent from \"../../types/TemplateComponent\";\nimport type ParseResult from \"../types/ParseResult\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport parseMarkup from \"./parseMarkup\";\nimport parseStyleElement from \"./parseStyles\";\nimport scopeStyles from \"./scopeStyles\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseCode(source: string): ParseResult {\n\tconst status: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\tfor (status.i; status.i < source.length; status.i++) {\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (status.source[status.i] === \"{\") {\n\t\t\tstatus.level += 1;\n\t\t} else if (status.source[status.i] === \"}\") {\n\t\t\tstatus.level -= 1;\n\t\t\tif (status.level === 0) {\n\t\t\t\tparseComponentEnd(status);\n\t\t\t}\n\t\t} else if (accept(\"function\", status)) {\n\t\t\t// If the function name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"const\", status)) {\n\t\t\t// If it's a function and its name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tconst start = status.i;\n\t\t\t\t\tconsumeAlphaNumeric(status);\n\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\tif (accept(\"=\", status)) {\n\t\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\t\tif (accept(\"(\", status, false)) {\n\t\t\t\t\t\t\tstatus.i = start;\n\t\t\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"export\", status)) {\n\t\t\t// If it's an anonymous default export function, parse it as a component\n\t\t\tconst start = status.i;\n\t\t\tif (\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"default\", status) &&\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"(\", status, false)\n\t\t\t) {\n\t\t\t\tparseComponentStart(status);\n\t\t\t} else {\n\t\t\t\tstatus.i = start;\n\t\t\t}\n\t\t} else if (accept(\"@render\", status, false)) {\n\t\t\tparseComponentRender(status);\n\t\t} else if (accept(\"@head\", status, false)) {\n\t\t\tparseComponentHead(status);\n\t\t} else if (accept(\"@style\", status, false)) {\n\t\t\tparseComponentStyle(status);\n\t\t}\n\t}\n\tstatus.script.push({\n\t\tscript: source.substring(status.marker, source.length),\n\t\tspan: { start: status.marker, end: source.length },\n\t});\n\n\tscopeStyles(status);\n\n\tconst ok = !status.errors.length;\n\tif (!ok) {\n\t\tstatus.errors = status.errors.sort((a, b) => a.startIndex - b.startIndex);\n\t}\n\n\treturn {\n\t\tok,\n\t\terrors: status.errors,\n\t\ttemplate: ok\n\t\t\t? {\n\t\t\t\t\timports: status.imports,\n\t\t\t\t\tscript: status.script,\n\t\t\t\t\tcomponents: status.components,\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n}\n\nfunction parseComponentStart(status: ParseStatus) {\n\tlet source = status.source.substring(status.marker, status.i);\n\tlet exported = /export\\s+(default\\s+)*(function\\s+|const\\s+)*$/.test(source);\n\tlet def = /export\\s+default\\s+(function\\s+|const\\s+)*$/.test(source);\n\tlet isConst = /const\\s+$/.test(source);\n\tlet isAnon = /export default\\s+$/.test(source);\n\n\tlet componentStart = status.i;\n\tlet name = consumeAlphaNumeric(status);\n\n\tconst current: TemplateComponent = {\n\t\tstart: componentStart,\n\t\tname,\n\t\texported,\n\t\tdefault: def,\n\t};\n\tstatus.components.push(current);\n\n\t// Look for /** ... */ documentation comments\n\tlet presource = source.substring(0, status.i).trimEnd();\n\tlet lastNewline = presource.lastIndexOf(\"\\n\");\n\tif (lastNewline !== -1) {\n\t\tpresource = presource.substring(0, lastNewline).trimEnd();\n\t\tif (presource.endsWith(\"*/\")) {\n\t\t\tfor (let i = presource.length; i >= 0; i--) {\n\t\t\t\tif (presource.substring(i, i + 3) === \"/**\") {\n\t\t\t\t\tcurrent.documentation = presource.substring(i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlet start = -1;\n\tlet end = -1;\n\tlet level = 0;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (char === \"(\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t}\n\t\t} else if (char === \")\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, start),\n\t\tspan: { start: status.marker, end: start },\n\t});\n\tstatus.script.push({ script: \"/* @params */\", span: { start, end } });\n\n\tcurrent.params = status.source.substring(start, end);\n\tif (current.params.trim().length === 0) {\n\t\tcurrent.params = undefined;\n\t}\n\n\t// Look for a params type or interface\n\t// Might need to get fancier with this\n\tconst paramsMatch = current.params?.match(/\\$props:\\s*([$A-Za-z0-9]+)/);\n\tif (paramsMatch) {\n\t\tlet propsTypeName = paramsMatch[1];\n\t\tlet propsTypeStart = status.source.search(new RegExp(`interface\\\\s+${propsTypeName}`));\n\t\tif (propsTypeStart === -1) {\n\t\t\tpropsTypeStart = status.source.search(new RegExp(`type\\\\s+${propsTypeName}`));\n\t\t}\n\t\tif (propsTypeStart !== -1) {\n\t\t\tlet bracesStart = status.source.indexOf(\"{\", propsTypeStart);\n\t\t\tif (bracesStart !== -1) {\n\t\t\t\tconst status2: ParseStatus = {\n\t\t\t\t\tsource: status.source,\n\t\t\t\t\ti: bracesStart + 1,\n\t\t\t\t\tmarker: 0,\n\t\t\t\t\tlevel: 0,\n\t\t\t\t\timports: [],\n\t\t\t\t\tscript: [],\n\t\t\t\t\tcomponents: [],\n\t\t\t\t\tstack: [],\n\t\t\t\t\terrors: [],\n\t\t\t\t};\n\t\t\t\tconst propsType = parseInlineScript(status2);\n\t\t\t\tif (propsType) {\n\t\t\t\t\tcurrent.propsType = `${status.source.substring(propsTypeStart, bracesStart)}{${propsType}}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.marker = end;\n\tstatus.i = status.marker;\n\n\taccept(\")\", status);\n\tconsumeSpace(status);\n\n\tif (isConst || isAnon) {\n\t\taccept(\"=>\", status);\n\t\tconsumeSpace(status);\n\t}\n\n\taccept(\"{\", status);\n\tstatus.level += 1;\n\n\t// Sneak in a function type\n\tconst postFunctionChunk = {\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t};\n\tif (/\\)\\s+\\{/.test(postFunctionChunk.script)) {\n\t\tpostFunctionChunk.script = \") /* @return_type */ {\";\n\t}\n\tstatus.script.push(postFunctionChunk);\n\n\tstatus.script.push({\n\t\tscript: \"/* @start */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tstatus.marker = status.i;\n\tconst space = consumeSpace(status);\n\tstatus.script.push({\n\t\tscript: space,\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.marker = status.i;\n\tstatus.i -= 1;\n}\n\nfunction parseComponentRender(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.markup) {\n\t\taddError(status, `Multiple @render sections`, status.i, status.i + \"@render\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @render */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@render\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentHead(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.head) {\n\t\taddError(status, `Multiple @head sections`, status.i, status.i + \"@head\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @head */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// HACK: add a new component, and move its markup into the current\n\t// component's head section after\n\tstatus.components.push({\n\t\tstart: status.i,\n\t});\n\n\taccept(\"@head\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\t// Swap render and markup\n\tconst head = status.components.pop();\n\tcurrent.head = head?.markup;\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentStyle(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.style) {\n\t\taddError(status, `Multiple @style sections`, status.i, status.i + \"@style\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @style */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tlet start = -1;\n\tlet end = status.source.length;\n\tlet level = 0;\n\t// HACK: strip the comments out of styles only\n\tlet styleSource = \"\";\n\tfor (; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tconst nextChar = status.source[status.i + 1];\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t// Skip one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t// Skip block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t// Skip string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfString(char, status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"`\") {\n\t\t\t// Skip interpolated string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfTemplateString(status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else {\n\t\t\tif (start !== -1) {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.i = start;\n\tparseStyleElement(styleSource.trim(), status);\n\n\tstatus.i = end + 2;\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentEnd(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.script.push({\n\t\tscript: \"/* @end */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// Get all usages of $props.name and $props[\"name\"]\n\t// Get all usages of $context.name and $context[\"name\"]\n\tconst componentSource = status.source.substring(current.start || 0, status.i);\n\tcurrent.props = getPropsUsage(componentSource);\n\tcurrent.contextProps = getContextUsage(componentSource);\n\n\t// If the top-level element is <html> and there is whitespace after it,\n\t// delete the whitespace, as that's what browsers seem to do. It may be\n\t// better instead to create whitespace if we don't find it when hydrating...\n\tif (\n\t\tcurrent.markup &&\n\t\tisElementNode(current.markup.children[0]) &&\n\t\tcurrent.markup.children[0].tagName === \"html\" &&\n\t\tisSpaceNode(current.markup.children[0].children[0])\n\t) {\n\t\tcurrent.markup.children.splice(1, 1);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction getPropsUsage(source: string): string[] | undefined {\n\tconst propsMatches = source.matchAll(/\\$props\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst props: string[] = [];\n\tfor (let match of propsMatches) {\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!props.includes(name)) {\n\t\t\tprops.push(name);\n\t\t}\n\t}\n\treturn props.length ? props : undefined;\n}\n\nfunction getContextUsage(source: string): string[] | undefined {\n\tconst contextsMatches = source.matchAll(/\\$context\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst contexts: string[] = [];\n\tfor (let match of contextsMatches) {\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!contexts.includes(name)) {\n\t\t\tcontexts.push(name);\n\t\t}\n\t}\n\treturn contexts.length ? contexts : undefined;\n}\n\nfunction consumeScriptComments(status: ParseStatus): boolean {\n\tconst char = status.source[status.i];\n\tconst nextChar = status.source[status.i + 1];\n\tif (char === \"/\" && nextChar === \"/\") {\n\t\t// Skip one-line comments\n\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\treturn true;\n\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t// Skip block comments\n\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\treturn true;\n\t} else if (char === '\"' || char === \"'\") {\n\t\t// Skip string contents\n\t\tstatus.i = endOfString(char, status.source, status.i);\n\t\treturn true;\n\t} else if (char === \"`\") {\n\t\t// Skip interpolated string contents\n\t\tstatus.i = endOfTemplateString(status.source, status.i);\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import parseCode from \"./parse/parseCode\";\nimport type ParseResult from \"./types/ParseResult\";\n\n/**\n * Parses source code into a component template\n *\n * @param source The source code\n *\n * @returns A result indicating whether parsing was ok, and if so, containing\n * the component template's parts such as script, markup and styles\n */\nexport default function parse(source: string): ParseResult {\n\treturn parseCode(source);\n}\n"],"mappings":";AAAA,SAAwB,oBAAoB,SAAiB,OAAuB;CAEnF,IAAI,QAAQ;AACZ,MAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,QAAQ,QAAQ,IAC3C,KAAI,QAAQ,OAAO,OAAO,QAAQ,IAAI,OAAO,QAAQ,UAAU,EAC9D,QAAO;UACG,QAAQ,OAAO,QAAQ,QAAQ,KAAK,QAAQ,IAAI,OAAO,KACjE,UAAS;UACC,QAAQ,OAAO,OAAO,QAAQ,EACxC,UAAS;AAGX,QAAO,QAAQ;;;;;ACVhB,IAAqB,UAArB,MAA6B;CAC5B,QAAQ;CACR,SAAS;CACT,UAAU;CAEV,UAAoB,E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,GACA,YACA,YACA,UACA,WACA,QACA;AACD;EAED,KAAK;AACJ,2BACC,UACA,MACA,MACA,QACA,GACA,UACA,WACA,QACA;AACD;EAED,KAAK;AACJ,8BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,QACA;AACD;EAED,QAEC,OAAM,IAAI,MAAM,sBAAsB,KAAK,OAAO;;;AAKrD,SAAS,wBACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,MAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,SAAS,CAC7C,qBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,QACA;;AAIH,SAAS,2BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,SAAQ,KAAK,WAAb;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;AAEJ,sCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UATiB,KAAK,UAAU,UAAU,EAAE,CAAC,QAAQ,UAAU,GAAG,EAWlE,QACA;AACD;EAED;AACC,QAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,SAAS,CAC7C,qBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,QACA;AAEF;;;AAKH,SAAS,6BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;AACD,oCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,QACA,QACA;;AAGF,SAAS,gBAAgB,MAAmB;AAE3C,SAAQ,KAAK,QAAQ,aAAa,EAAlC;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO,OAAO,KAAK,QAAQ,UAAU,GAAG,EAAE,CAAC,aAAa,GAAG,KAAK,QAAQ,UAAU,EAAE,CAAC;EACtF,KAAK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