aktion-runtime 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +206 -125
  2. package/dist/aktion.iife.js +106 -460
  3. package/dist/aktion.iife.js.map +1 -1
  4. package/dist/aktion.js +13612 -12644
  5. package/dist/aktion.js.map +1 -1
  6. package/dist/aktion.umd.cjs +106 -460
  7. package/dist/aktion.umd.cjs.map +1 -1
  8. package/dist/devtools.js +1367 -0
  9. package/dist/devtools.js.map +1 -0
  10. package/dist/{node/index-8OvnOYPI.js → language.js} +14789 -12298
  11. package/dist/language.js.map +1 -0
  12. package/dist/plugin.cjs +2660 -0
  13. package/dist/plugin.cjs.map +1 -0
  14. package/dist/plugin.js +2660 -0
  15. package/dist/plugin.js.map +1 -0
  16. package/dist/system_prompt.txt +200 -451
  17. package/dist/system_prompt_chat.txt +35 -85
  18. package/dist/testing.js +30190 -0
  19. package/dist/testing.js.map +1 -0
  20. package/dist/types/aktion-modules.d.ts +6 -10
  21. package/dist/types/compiler/index.d.ts +9 -11
  22. package/dist/types/compiler/linker.d.ts +11 -11
  23. package/dist/types/compiler/project.d.ts +45 -0
  24. package/dist/types/compiler/runtime.d.ts +22 -26
  25. package/dist/types/devtools/hook.d.ts +88 -0
  26. package/dist/types/devtools/index.d.ts +35 -0
  27. package/dist/types/devtools/panel.d.ts +109 -0
  28. package/dist/types/devtools/protocol.d.ts +130 -0
  29. package/dist/types/devtools/styles.d.ts +7 -0
  30. package/dist/types/element.d.ts +56 -25
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/language/builtins.d.ts +52 -0
  33. package/dist/types/language/index.d.ts +5 -2
  34. package/dist/types/language-api.d.ts +12 -8
  35. package/dist/types/library/components/helpers.d.ts +0 -5
  36. package/dist/types/library/components/wrappers.d.ts +1 -0
  37. package/dist/types/parser/types.d.ts +8 -9
  38. package/dist/types/plugin/index.d.ts +13 -6
  39. package/dist/types/renderer/renderer.d.ts +28 -0
  40. package/dist/types/runtime/builtins.d.ts +5 -11
  41. package/dist/types/runtime/effects.d.ts +16 -18
  42. package/dist/types/runtime/evaluator.d.ts +46 -5
  43. package/dist/types/runtime/http.d.ts +41 -1
  44. package/dist/types/runtime/index.d.ts +2 -1
  45. package/dist/types/runtime/router.d.ts +28 -2
  46. package/dist/types/runtime/toast.d.ts +45 -0
  47. package/dist/types/runtime/util.d.ts +11 -1
  48. package/dist/types/testing/index.d.ts +201 -0
  49. package/dist/types/theme/index.d.ts +3 -3
  50. package/dist/types/theme/styles.d.ts +1 -1
  51. package/dist/types/tooling/formatter.d.ts +7 -1
  52. package/dist/types/tooling/index.d.ts +6 -3
  53. package/dist/types/tooling/language-service.d.ts +10 -5
  54. package/dist/types/tooling/navigation.d.ts +91 -0
  55. package/dist/types/tooling/semantic-tokens.d.ts +24 -0
  56. package/dist/types/tooling/signature-help.d.ts +21 -0
  57. package/package.json +21 -19
  58. package/dist/node/compile-BUw0GAvN.cjs +0 -491
  59. package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
  60. package/dist/node/compile-DxttTzo8.js +0 -492
  61. package/dist/node/compile-DxttTzo8.js.map +0 -1
  62. package/dist/node/compiler.cjs +0 -11
  63. package/dist/node/compiler.cjs.map +0 -1
  64. package/dist/node/compiler.js +0 -11
  65. package/dist/node/compiler.js.map +0 -1
  66. package/dist/node/index-8OvnOYPI.js.map +0 -1
  67. package/dist/node/index-DBgA3bHQ.cjs +0 -14069
  68. package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
  69. package/dist/node/language.cjs +0 -1244
  70. package/dist/node/language.cjs.map +0 -1
  71. package/dist/node/language.js +0 -1244
  72. package/dist/node/language.js.map +0 -1
  73. package/dist/node/vite.cjs +0 -65
  74. package/dist/node/vite.cjs.map +0 -1
  75. package/dist/node/vite.js +0 -65
  76. package/dist/node/vite.js.map +0 -1
  77. package/dist/types/compiler/compile.d.ts +0 -54
  78. package/dist/types/compiler/emit.d.ts +0 -15
  79. package/dist/types/compiler/sourcemap.d.ts +0 -40
  80. package/dist/types/library/components/theme.d.ts +0 -2
  81. package/dist/types/plugin/vite.d.ts +0 -21
  82. package/dist/types/tooling/codemod.d.ts +0 -36
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-8OvnOYPI.js","sources":["../../src/library/types.ts","../../src/icons/index.ts","../../src/library/utils.ts","../../src/library/components/layout.ts","../../src/library/components/content.ts","../../src/library/components/_internal.ts","../../src/library/components/forms-shared.ts","../../src/library/components/wrappers.ts","../../src/library/components/forms.ts","../../src/library/components/patterns.ts","../../src/library/components/data.ts","../../src/library/components/charts.ts","../../src/library/components/chat.ts","../../src/library/components/feedback.ts","../../src/library/components/navigation.ts","../../src/library/components/menu.ts","../../src/library/components/advanced-data.ts","../../src/library/components/media.ts","../../src/library/components/editors.ts","../../src/library/components/advanced-charts.ts","../../src/library/components/advanced-forms.ts","../../src/library/components/advanced-patterns.ts","../../src/library/components/theme.ts","../../src/library/components/router.ts","../../src/library/components/new-components.ts","../../src/library/components/helpers.ts","../../src/library/components/escape-hatch.ts","../../src/library/registry.ts","../../src/parser/lexer.ts","../../src/parser/parser.ts","../../src/library/validate.ts","../../src/library/index.ts"],"sourcesContent":["/**\n * Component library schema types.\n *\n * Components are described by:\n * - `name`: identifier used in Aktion (e.g. `Stack`, `Button`).\n * - `props`: ordered prop list. Order defines positional argument mapping.\n * - `description`: shown in the generated system prompt.\n * - `render`: produces a DOM node from resolved prop values.\n */\n\nimport type { ComponentNode } from \"../runtime/evaluator.js\";\nimport type { Router } from \"../runtime/router.js\";\n\nexport type PrimitiveType =\n | \"string\"\n | \"number\"\n | \"boolean\"\n | \"any\"\n | \"callable\"\n | \"Node\"\n | \"Node[]\";\n\nexport interface PropSpec {\n name: string;\n type: PrimitiveType | string; // accept named types like \"Series[]\"\n optional?: boolean;\n /**\n * Aktion 0.5 §19.1 — at most one prop per spec may be marked\n * positional. Authors may pass exactly one positional argument at the\n * call site; it lands in this prop's slot regardless of its position in\n * the `props` array. Every other prop must be provided as a named\n * argument (`prop: value`). Specs without any `positional: true` flag\n * reject every positional argument at evaluation time.\n */\n positional?: boolean;\n /**\n * Marker only — recorded so the schema-driven prompt generator can render\n * required props without an `?` suffix. Not enforced by the runtime.\n */\n required?: boolean;\n description?: string;\n /** Accepted enum values, formatted as a comma-separated list in the prompt. */\n enum?: readonly string[];\n /**\n * Optional alternative names that route to this prop when used as a\n * `name: value` named argument at the call site. Lets the same prop be\n * called by its canonical name *and* a synonym so authors writing\n * `Badge(\"Live\", tone: \"success\")` and `Badge(\"Live\", variant: \"success\")`\n * both land in the same slot. Aliases never change the runtime prop name\n * — renderers continue to read `props[spec.name]`.\n */\n aliases?: readonly string[];\n}\n\nexport interface ComponentSpec {\n name: string;\n description: string;\n props: readonly PropSpec[];\n render: ComponentRenderFn;\n}\n\n/**\n * Aktion 0.5 §19.1 — locate the canonical positional prop\n * for a spec. A spec opts in by marking exactly one prop with\n * `positional: true`. Specs that omit the marker fall back to \"first prop\n * is positional\", which is the convention every legacy library component\n * was authored with.\n *\n * `findPositionalIndex` is consumed by the evaluator (to route the single\n * positional argument to the right slot regardless of where in `props`\n * the positional prop lives — e.g. `Portal(target?, children)` keeps\n * `children` as the positional but it lives at index 1).\n *\n * `findPositionalProp` returns the resolved prop or `undefined` for void\n * components (zero props).\n */\nexport function findPositionalIndex(spec: ComponentSpec): number {\n const explicit = spec.props.findIndex((p) => p.positional === true);\n if (explicit >= 0) return explicit;\n return spec.props.length > 0 ? 0 : -1;\n}\n\nexport function findPositionalProp(spec: ComponentSpec): PropSpec | undefined {\n const idx = findPositionalIndex(spec);\n return idx >= 0 ? spec.props[idx] : undefined;\n}\n\n/**\n * Asserts that every spec in the library declares at most one positional\n * prop. Surfaces inconsistencies as a `SyntaxError` at module load so the\n * library never ships a contradictory spec.\n */\nexport function assertOnePositionalMax(specs: ReadonlyArray<ComponentSpec>): void {\n for (const spec of specs) {\n const positional = spec.props.filter((p) => p.positional === true);\n if (positional.length > 1) {\n const names = positional.map((p) => p.name).join(\", \");\n throw new SyntaxError(\n `Component \"${spec.name}\" declares ${positional.length} positional ` +\n `props (${names}). Aktion 0.5 §19.1 allows at most one.`,\n );\n }\n }\n}\n\n/**\n * Stable, component-local state slot. Returned by\n * `RenderHelpers.useInstanceState`. Keep the reference for the lifetime of\n * a single render — the renderer wires it to a long-lived storage cell so\n * subsequent renders read the value the previous click handler wrote.\n */\nexport interface InstanceStateSlot<T> {\n get(): T;\n set(value: T): void;\n}\n\nexport interface RenderHelpers {\n /** Render a child node tree (a ComponentNode or array of nodes). */\n renderNode: (node: unknown) => Node;\n /**\n * Invoke a user-supplied callable (e.g. a lambda passed as an `onClick`\n * prop, or a bare `action` declaration reference). Safe to call with\n * `undefined` / `null` — silently no-ops. Returned values are ignored.\n *\n * This is the single dispatch path for user-authored event handlers in\n * Aktion 0.5. The legacy `Action([@Set, @Run, ...])` payload\n * is no longer accepted.\n */\n invoke: (callable: unknown, ...args: unknown[]) => void;\n /** Set a state value. Used by library primitives for their own internal state writes. */\n setState: (name: string, value: unknown) => void;\n /** Reset state values back to their initial declared value. */\n resetState: (...names: string[]) => void;\n /** Dispatch an `assistant-message` CustomEvent on the host element. */\n sendToAssistant: (message: string) => void;\n /** Open a URL (sanitised against `javascript:` payloads). */\n openUrl: (url: string) => void;\n /** Bind a `$variable` to an HTML form element. */\n bindState: (\n element: HTMLElement,\n name: string,\n options?: { event?: string; getValue?: (el: HTMLElement) => unknown },\n ) => void;\n /**\n * Persist component-local state across re-renders. The slot is keyed by\n * the component's position in the tree (its source location plus its\n * path through sibling iterations), so independent instances never share\n * a value. Used by stateful primitives like `Tabs` so user-driven UI\n * state (active tab, expanded row, …) survives a re-render triggered by\n * unrelated state changes.\n */\n useInstanceState: <T>(key: string, initialValue: T) => InstanceStateSlot<T>;\n /**\n * Register a cleanup callback tied to this component instance. The renderer\n * invokes the callback once the instance disappears from the tree (e.g. a\n * Toast finishes auto-dismissing or the parent re-renders without it).\n * Use for `setTimeout` / `setInterval` handles and external resources so we\n * never accumulate work for components the user can no longer see.\n *\n * Calling this multiple times during a single render replaces any previous\n * disposer for the same `key` (cancelling the prior cleanup runs immediately\n * via that callback's caller). If `key` is omitted, each call registers an\n * independent disposer.\n */\n registerDisposer: (cleanup: () => void, key?: string) => void;\n /**\n * Hash-based router instance, always provided. Components such as `NavLink`\n * call `router.navigate(path)` directly to change the active route.\n */\n router: Router;\n}\n\nexport type ComponentRenderFn = (\n node: ComponentNode,\n props: Record<string, unknown>,\n helpers: RenderHelpers,\n) => Node;\n\nexport interface ComponentGroup {\n name: string;\n components: readonly string[];\n notes?: readonly string[];\n}\n\nexport interface ComponentLibrary {\n root: string;\n components: ReadonlyArray<ComponentSpec>;\n componentGroups?: ReadonlyArray<ComponentGroup>;\n}\n\n/** Resolve positional args from Aktion into named props. */\nexport function mapPositionalArgs(\n spec: ComponentSpec,\n args: ReadonlyArray<unknown>,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n spec.props.forEach((prop, index) => {\n if (index < args.length) out[prop.name] = args[index];\n });\n return out;\n}\n","/**\n * Font Awesome integration for `<aktion-app>`.\n *\n * Icons across the library are referenced by Font Awesome name (without the\n * `fa-` prefix). The optional `variant:` prefix (`solid:`, `regular:`,\n * `brands:`) picks the FA style — when omitted, it defaults to `solid`.\n *\n * The custom element auto-loads the CDN stylesheet on connect (once per\n * page and once per shadow root) so host apps do not have to add anything\n * to make icons render.\n */\n\nexport const FONT_AWESOME_CDN_URL =\n \"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css\";\n\nexport const FONT_AWESOME_VERSION = \"6.7.2\";\n\nconst LINK_MARKER_ATTR = \"data-rui-font-awesome\";\n\nconst SUPPORTED_VARIANTS = new Set([\"solid\", \"regular\", \"brands\"]);\n\nconst DEFAULT_VARIANT = \"solid\";\n\n/**\n * Inject the Font Awesome stylesheet into `document.head` (once per page)\n * and into the given shadow root (once per instance) so icon classes\n * resolve both outside and inside the custom element.\n *\n * Safe to call from every `connectedCallback`.\n */\nexport function ensureFontAwesomeLoaded(shadow: ShadowRoot): void {\n if (typeof document !== \"undefined\") {\n injectLink(document.head, document);\n }\n injectLink(shadow, shadow.ownerDocument ?? document);\n}\n\nfunction injectLink(root: ParentNode, doc: Document): void {\n // happy-dom logs disallowed external stylesheet loads to stderr before\n // throwing, so a plain try/catch isn't enough to keep the test output\n // clean. Detect the test environment and skip — there is no browser to\n // render icons into anyway.\n if (isHappyDomEnvironment()) return;\n\n const existing = root.querySelector(\n `link[${LINK_MARKER_ATTR}=\"${FONT_AWESOME_VERSION}\"]`,\n );\n if (existing) return;\n const link = doc.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = FONT_AWESOME_CDN_URL;\n link.setAttribute(LINK_MARKER_ATTR, FONT_AWESOME_VERSION);\n try {\n root.appendChild(link);\n } catch {\n // Defensive: some DOM implementations may still throw when appending an\n // external stylesheet. Production browsers never throw here.\n }\n}\n\nfunction isHappyDomEnvironment(): boolean {\n const g = globalThis as { happyDOM?: unknown };\n return typeof g.happyDOM !== \"undefined\";\n}\n\n/**\n * Resolve a Aktion icon string into Font Awesome class tokens.\n *\n * - `\"house\"` → `[\"fa-solid\", \"fa-house\"]`\n * - `\"regular:star\"` → `[\"fa-regular\", \"fa-star\"]`\n * - `\"brands:github\"` → `[\"fa-brands\", \"fa-github\"]`\n *\n * Invisible Unicode glyph modifiers (variation selectors U+FE0E/U+FE0F and\n * the zero-width joiner U+200D) are stripped before validation — they often\n * sneak in when an LLM copies an FA name out of a doc that previously used\n * an emoji glyph, and would otherwise break ASCII-only validation.\n *\n * Returns an empty array for blank input or names that contain non-ASCII\n * characters (legacy emoji input — the caller renders those inline as text).\n */\nexport function resolveIconClasses(value: unknown): string[] {\n if (typeof value !== \"string\") return [];\n const sanitized = stripInvisibleModifiers(value).trim();\n if (!sanitized) return [];\n if (!isAsciiIconName(sanitized)) return [];\n\n const [variant, name] = splitVariant(sanitized);\n if (!name) return [];\n return [`fa-${variant}`, `fa-${name}`];\n}\n\nconst INVISIBLE_MODIFIER_RE = /[\\uFE0E\\uFE0F\\u200D\\u200C\\uFEFF]/g;\n\nfunction stripInvisibleModifiers(input: string): string {\n return input.replace(INVISIBLE_MODIFIER_RE, \"\");\n}\n\n/**\n * True when the value should be treated as a Font Awesome name (vs legacy\n * emoji text that the renderer should print inline).\n */\nexport function isIconName(value: unknown): value is string {\n return resolveIconClasses(value).length > 0;\n}\n\nfunction splitVariant(input: string): [string, string] {\n const idx = input.indexOf(\":\");\n if (idx === -1) return [DEFAULT_VARIANT, input];\n const variant = input.slice(0, idx).trim().toLowerCase();\n const name = input.slice(idx + 1).trim();\n if (!SUPPORTED_VARIANTS.has(variant)) return [DEFAULT_VARIANT, name || input];\n return [variant, name];\n}\n\nfunction isAsciiIconName(value: string): boolean {\n // FA names are kebab-case ASCII (letters, digits, dashes). Allow the\n // optional `variant:` prefix. Anything else (emoji, accented text)\n // falls back to inline text rendering.\n return /^[a-zA-Z0-9:_-]+$/.test(value);\n}\n\nexport const ICON_SIZES = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type IconSize = (typeof ICON_SIZES)[number];\n\nexport function isIconSize(value: unknown): value is IconSize {\n return typeof value === \"string\" && (ICON_SIZES as readonly string[]).includes(value);\n}\n","/**\n * DOM helpers shared by built-in components.\n */\n\nimport { resolveIconClasses, type IconSize } from \"../icons/index.js\";\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs?: Record<string, string | number | boolean | null | undefined>,\n children?: ReadonlyArray<Node | string | null | undefined>,\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n if (value === null || value === undefined || value === false) continue;\n if (key === \"class\") node.setAttribute(\"class\", String(value));\n else if (key === \"html\") node.innerHTML = String(value);\n else if (value === true) node.setAttribute(key, \"\");\n else node.setAttribute(key, String(value));\n }\n }\n if (children) {\n for (const child of children) {\n if (child === null || child === undefined) continue;\n node.append(typeof child === \"string\" ? document.createTextNode(child) : child);\n }\n }\n return node;\n}\n\nexport function text(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n return String(value);\n}\n\nexport function classNames(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport function asArray<T>(value: unknown): T[] {\n if (Array.isArray(value)) return value as T[];\n if (value === null || value === undefined) return [];\n return [value as T];\n}\n\nexport function asString(value: unknown, fallback = \"\"): string {\n if (value === null || value === undefined) return fallback;\n if (typeof value === \"string\") return value;\n return String(value);\n}\n\nexport function asBoolean(value: unknown, fallback = false): boolean {\n if (typeof value === \"boolean\") return value;\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n if (value === null || value === undefined) return fallback;\n return Boolean(value);\n}\n\nexport function asNumber(value: unknown, fallback = 0): number {\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const n = Number(value);\n if (!Number.isNaN(n)) return n;\n }\n return fallback;\n}\n\n/**\n * Breakpoint keys honoured by responsive prop maps (Grid columns, Stack\n * direction, etc.). Ordered from narrow → wide so CSS only needs to chain\n * one `min-width` per breakpoint and naturally cascades.\n */\nexport const RESPONSIVE_BREAKPOINTS = [\"base\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type Breakpoint = typeof RESPONSIVE_BREAKPOINTS[number];\n\n/**\n * Normalise a prop value that may be a single value or a responsive map\n * like `{sm: 1, md: 2, lg: 4}`. Returns either:\n * - `{kind: \"single\", value}` — caller should use the value directly\n * - `{kind: \"responsive\", values}` — caller should emit CSS variables /\n * data attributes for each breakpoint\n *\n * A bare key without a breakpoint prefix (e.g. `{value: 2}`) collapses to\n * a single-value result. Unknown breakpoint keys are ignored so typos\n * don't crash the page.\n */\nexport type ResponsiveProp<T> =\n | { kind: \"single\"; value: T | null }\n | { kind: \"responsive\"; values: Partial<Record<Breakpoint, T>> };\n\nexport function readResponsiveProp<T>(value: unknown): ResponsiveProp<T> {\n if (value == null || typeof value !== \"object\" || Array.isArray(value)) {\n return { kind: \"single\", value: (value ?? null) as T | null };\n }\n const entries = Object.entries(value as Record<string, unknown>);\n const values: Partial<Record<Breakpoint, T>> = {};\n let matched = false;\n for (const [key, raw] of entries) {\n if ((RESPONSIVE_BREAKPOINTS as readonly string[]).includes(key)) {\n values[key as Breakpoint] = raw as T;\n matched = true;\n }\n }\n if (!matched) {\n // Caller passed a non-responsive object — treat as a single value\n // (probably a component-config object the caller passes through).\n return { kind: \"single\", value: value as T };\n }\n return { kind: \"responsive\", values };\n}\n\n/**\n * Strip characters that would let an LLM-supplied string break out of a\n * `url(\"...\")` literal embedded in an inline `style` attribute. We keep the\n * common allowed URL characters and drop anything that could close the\n * literal, terminate the declaration, or introduce another rule. Returns an\n * empty string for non-string / blank input so callers can render a tasteful\n * fallback rather than a malformed `url(\"\")`.\n */\nconst CSS_URL_FORBIDDEN = /[\"'\\\\\\n\\r<>;{}]/g;\nexport function sanitiseCssUrl(raw: string): string {\n if (!raw) return \"\";\n return raw.replace(CSS_URL_FORBIDDEN, \"\").trim();\n}\n\n/**\n * Validate a CSS length / dimension value (`280px`, `40vh`, `clamp(...)`,\n * `calc(...)`) so an LLM-supplied string cannot inject extra declarations\n * through an inline `style` attribute. We accept a small alphabet that covers\n * every standard CSS length token; anything outside that — or values that\n * are unreasonably long — falls back to `fallback`.\n */\nconst CSS_LENGTH_ALLOWED = /^[a-zA-Z0-9.%+\\-*/\\s(),]+$/;\nexport function sanitiseCssLength(raw: unknown, fallback: string): string {\n const trimmed = (asString(raw) ?? \"\").trim();\n if (!trimmed) return fallback;\n if (trimmed.length > 64) return fallback;\n if (!CSS_LENGTH_ALLOWED.test(trimmed)) return fallback;\n return trimmed;\n}\n\n/**\n * Validate an LLM-supplied CSS colour value before it lands on an inline\n * `color: …` declaration. Accepts the full standard colour vocabulary —\n * hex (`#00ff00`), named colours (`tomato`), functional notations\n * (`rgb(...)`, `hsl(...)`, `color-mix(...)`), and `var(--token)` — while\n * rejecting anything that could break out of the single declaration:\n * `;`/`{`/`}` (declaration separators), quotes/backslash/angle-brackets,\n * and the `url()` / `expression()` / `javascript:` / `@import` attack\n * vectors. Returns an empty string for blank or rejected input so callers\n * can drop the style entirely.\n */\nconst CSS_COLOR_ALLOWED = /^[a-zA-Z0-9#%.,()\\s+\\-]+$/;\nexport function sanitiseCssColor(raw: unknown): string {\n const trimmed = asString(raw).trim();\n if (!trimmed) return \"\";\n if (trimmed.length > 64) return \"\";\n if (!CSS_COLOR_ALLOWED.test(trimmed)) return \"\";\n if (/\\burl\\s*\\(|\\bexpression\\s*\\(|javascript\\s*:|@import\\b/i.test(trimmed)) return \"\";\n return trimmed;\n}\n\n/**\n * URL schemes that are allowed in anchor `href` and `window.open` targets.\n * Anything outside this allow-list (notably `javascript:`, `vbscript:`,\n * `data:` text payloads, `file:`) is rewritten to a safe placeholder so a\n * hostile LLM/tool response cannot smuggle script execution into a click.\n */\nconst SAFE_HREF_SCHEMES = new Set([\"http\", \"https\", \"mailto\", \"tel\"]);\n\n/**\n * Sanitise an LLM-supplied `href` value before it lands on an anchor.\n *\n * - Fragments (`#anchor`), root-relative paths (`/about`), and pure query\n * strings (`?q=foo`) are kept verbatim.\n * - Absolute URLs with an allow-listed scheme (`http`, `https`, `mailto`,\n * `tel`) are kept verbatim.\n * - Anything else — `javascript:`, `vbscript:`, `data:text/html`,\n * `file:`, protocol-relative `//host/path`, control characters — collapses\n * to `fallback` (default `\"#\"`) so the click never navigates anywhere\n * dangerous.\n *\n * This is the single chokepoint every component should call before assigning\n * `href`. The Markdown renderer has its own (stricter, HTML-escaping)\n * sibling, but the validation rules match so behaviour stays consistent.\n */\nexport function sanitiseHref(raw: unknown, fallback = \"#\"): string {\n const value = asString(raw).trim();\n if (!value) return fallback;\n // Strip control characters (including TAB / LF / CR) before scheme\n // detection — `java\\tscript:` is a well-known browser-tolerated bypass.\n // eslint-disable-next-line no-control-regex\n const cleaned = value.replace(/[\\u0000-\\u001F\\u007F]/g, \"\");\n if (!cleaned) return fallback;\n // Protocol-relative URLs (`//host/path`) inherit the page scheme and can\n // navigate to a hostile origin, so they are treated as unsafe.\n if (cleaned.startsWith(\"//\")) return fallback;\n // Same-origin shapes — fragments, root-relative, query-only — are safe.\n if (\n cleaned.startsWith(\"#\") ||\n cleaned.startsWith(\"/\") ||\n cleaned.startsWith(\"?\") ||\n cleaned.startsWith(\".\")\n ) {\n return cleaned;\n }\n const schemeMatch = /^([a-zA-Z][a-zA-Z0-9+.\\-]*):/.exec(cleaned);\n if (!schemeMatch) {\n // No scheme = a relative path like `about.html` or `page#foo`.\n return cleaned;\n }\n const scheme = schemeMatch[1]!.toLowerCase();\n if (!SAFE_HREF_SCHEMES.has(scheme)) return fallback;\n return cleaned;\n}\n\n/**\n * URL schemes that are safe to render inside an `<img src>`. Browsers do not\n * execute JavaScript from `img.src`, but a hostile `data:text/html` (in\n * theory ignored by image decoders), `javascript:`, or `vbscript:` is still\n * worth rejecting to keep the surface predictable for downstream consumers\n * that may copy `src` into other attribute slots.\n */\nconst SAFE_IMAGE_SCHEMES = new Set([\"http\", \"https\", \"data\", \"blob\"]);\n\n/**\n * Sanitise an LLM-supplied image `src` before it lands on an `<img>`.\n *\n * Relative paths and same-origin shapes are kept as-is. Absolute URLs with\n * an allow-listed scheme (`http`, `https`, `data`, `blob`) are kept. Anything\n * else (`javascript:`, `vbscript:`, `file:`, …) returns the empty string so\n * callers can render their own placeholder.\n */\nexport function sanitiseImageSrc(raw: unknown): string {\n const value = asString(raw).trim();\n if (!value) return \"\";\n // eslint-disable-next-line no-control-regex\n const cleaned = value.replace(/[\\u0000-\\u001F\\u007F]/g, \"\");\n if (!cleaned) return \"\";\n // Protocol-relative is fine for images (browsers resolve to current scheme)\n // but we still bail because it leaks the host scheme into a foreign origin.\n if (cleaned.startsWith(\"//\")) return \"\";\n if (\n cleaned.startsWith(\"/\") ||\n cleaned.startsWith(\".\") ||\n cleaned.startsWith(\"?\") ||\n cleaned.startsWith(\"#\")\n ) {\n return cleaned;\n }\n const schemeMatch = /^([a-zA-Z][a-zA-Z0-9+.\\-]*):/.exec(cleaned);\n if (!schemeMatch) return cleaned;\n const scheme = schemeMatch[1]!.toLowerCase();\n if (!SAFE_IMAGE_SCHEMES.has(scheme)) return \"\";\n // For `data:` URLs, only allow `image/*` payloads — `data:text/html` would\n // render markup if a host accidentally copies the src into another sink.\n if (scheme === \"data\" && !/^data:image\\//i.test(cleaned)) return \"\";\n return cleaned;\n}\n\n/** `true` when a value is a renderable component node produced by the runtime. */\nexport function isComponentNode(value: unknown): boolean {\n if (value === null || typeof value !== \"object\") return false;\n const kind = (value as { __kind?: string }).__kind;\n return kind === \"Component\" || kind === \"UserComponent\";\n}\n\n/** Subset of `RenderHelpers` the table cell builder needs. */\nexport interface CellRenderHelpers {\n renderNode: (node: unknown) => Node;\n invoke: (callable: unknown, ...args: unknown[]) => void;\n}\n\n/** A column's cell-rendering configuration, shared by Table and DataGrid. */\nexport interface TableCellCol {\n /** Cell value formatting hint (`text|number|currency|date`). */\n format?: string;\n /**\n * Optional `(value, rowIndex) => Component | string | (Component|string)[]`\n * mapper. Lets a column render arbitrary components — action buttons,\n * badges, avatars, links — instead of plain text. When omitted, a cell\n * value that is itself a component node still renders directly.\n */\n render?: unknown;\n /**\n * Optional `(value, rowIndex) => void` fired when the cell is clicked or\n * activated via keyboard. Clicks originating on an interactive child\n * (a rendered Button / link / input) are ignored so nested actions keep\n * their own handlers.\n */\n onClick?: unknown;\n}\n\n/**\n * Populate a `<td>` for one Table / DataGrid cell. Content resolution order:\n *\n * 1. `col.render(value, rowIndex)` — when provided, its result (a\n * component, string, or array of either) is rendered. This is the\n * idiomatic way to put buttons / badges / links in a column.\n * 2. a component-node `value` — rendered directly (so authors can also\n * pass a pre-built array of component cells as the column `values`).\n * 3. otherwise the value is formatted as text via `formatValue`.\n *\n * When `col.onClick` is a callable the whole cell becomes an accessible\n * button (pointer + Enter/Space), firing `onClick(value, rowIndex)`.\n */\nexport function fillTableCell(\n td: HTMLElement,\n col: TableCellCol,\n value: unknown,\n rowIndex: number,\n helpers: CellRenderHelpers,\n formatValue: (value: unknown, format: string) => string,\n): void {\n const format = col.format ?? \"text\";\n\n let content: unknown = value;\n if (typeof col.render === \"function\") {\n try {\n content = (col.render as (...a: unknown[]) => unknown)(value, rowIndex);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"[aktion] Col render() threw\", err);\n content = null;\n }\n }\n\n const appendOne = (item: unknown): void => {\n if (isComponentNode(item)) {\n td.append(helpers.renderNode(item));\n } else if (item !== null && item !== undefined) {\n td.append(document.createTextNode(formatValue(item, format)));\n }\n };\n if (Array.isArray(content)) {\n for (const item of content) appendOne(item);\n } else {\n appendOne(content);\n }\n\n if (typeof col.onClick === \"function\") {\n td.setAttribute(\"data-clickable\", \"true\");\n td.setAttribute(\"role\", \"button\");\n td.tabIndex = 0;\n const guardedFire = (event: Event): boolean => {\n const target = event.target as Element | null;\n // Let interactive children (rendered buttons / links / inputs) handle\n // their own clicks without also firing the cell handler.\n if (target?.closest(\"input,button,a,label,select,textarea\")) return false;\n // Stop the event bubbling to an enclosing clickable row (DataGrid's\n // `onRowClick`) so a cell action doesn't double-fire.\n event.stopPropagation();\n helpers.invoke(col.onClick, value, rowIndex);\n return true;\n };\n td.onclick = (event) => { guardedFire(event); };\n td.onkeydown = (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n if (guardedFire(event)) event.preventDefault();\n };\n }\n}\n\n/**\n * Render an icon-typed prop into an `<i class=\"rui-icon fa-...\">` element.\n *\n * Falls back to a `<span>` containing the raw string when the value is not\n * a Font Awesome name (legacy emoji input). Returns `null` when the value\n * is empty / nullish so callers can short-circuit.\n */\nexport function renderIcon(\n value: unknown,\n options: { className?: string; size?: IconSize | string; color?: string } = {},\n): HTMLElement | null {\n const text = asString(value);\n if (!text) return null;\n const color = options.color ? sanitiseCssColor(options.color) : \"\";\n const style = color ? `color:${color};` : null;\n const classes = resolveIconClasses(text);\n const wrapperClass = [\"rui-icon\", options.className].filter(Boolean).join(\" \");\n if (classes.length === 0) {\n return el(\"span\", {\n class: wrapperClass,\n \"data-icon-size\": options.size ?? null,\n style,\n }, [text]);\n }\n return el(\"i\", {\n class: `${wrapperClass} ${classes.join(\" \")}`,\n \"data-icon-size\": options.size ?? null,\n style,\n \"aria-hidden\": \"true\",\n });\n}\n","/**\n * Layout components: Stack, StackItem, Grid, GridItem, Box, Card, CardHeader,\n * CardFooter, Tabs, TabItem, Accordion, AccordionItem,\n * Modal, AspectRatio, ScrollArea.\n */\n\nimport type { ComponentSpec, RenderHelpers } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon, sanitiseCssLength,\n readResponsiveProp, RESPONSIVE_BREAKPOINTS, type Breakpoint, type ResponsiveProp,\n} from \"../utils.js\";\n\nconst GRID_COLUMNS = 12;\n\nconst FLEX_ALIGN: Record<string, string> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n stretch: \"stretch\",\n};\n\nconst FLEX_JUSTIFY: Record<string, string> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n between: \"space-between\",\n around: \"space-around\",\n evenly: \"space-evenly\",\n};\n\nfunction mapFlexAlign(token: string): string {\n return FLEX_ALIGN[token] ?? \"stretch\";\n}\n\nfunction mapFlexJustify(token: string): string {\n return FLEX_JUSTIFY[token] ?? \"flex-start\";\n}\n\nfunction applyDirectionWithReverse(value: string, reverse: boolean): string {\n if (!reverse) return value;\n if (value === \"row\") return \"row-reverse\";\n if (value === \"column\") return \"column-reverse\";\n if (value.endsWith(\"-reverse\")) return value;\n return `${value}-reverse`;\n}\n\nfunction emitResponsiveSpacingVars(\n styleParts: string[],\n prop: Extract<ResponsiveProp<string>, { kind: \"responsive\" }>,\n cssPrefix: string,\n): void {\n for (const bp of RESPONSIVE_BREAKPOINTS) {\n const v = prop.values[bp];\n if (v) styleParts.push(`${cssPrefix}-${bp}:var(--rui-spacing-${v}, ${v})`);\n }\n}\n\nfunction emitResponsiveFlexVars(\n styleParts: string[],\n prop: Extract<ResponsiveProp<string>, { kind: \"responsive\" }>,\n cssPrefix: string,\n mapper: (token: string) => string,\n): void {\n for (const bp of RESPONSIVE_BREAKPOINTS) {\n const v = prop.values[bp];\n if (v) styleParts.push(`${cssPrefix}-${bp}:${mapper(String(v))}`);\n }\n}\n\nfunction applyResponsiveEnumProp(\n value: unknown,\n styleParts: string[],\n attrs: Record<string, string | null>,\n options: {\n attrName: string;\n responsiveFlag: string;\n cssVarPrefix: string;\n defaultToken: string;\n mapper: (token: string) => string;\n },\n): void {\n const parsed = readResponsiveProp<string>(value);\n if (parsed.kind === \"single\") {\n const token = parsed.value ? String(parsed.value) : options.defaultToken;\n attrs[options.attrName] = token;\n return;\n }\n attrs[options.attrName] = \"responsive\";\n attrs[options.responsiveFlag] = \"true\";\n emitResponsiveFlexVars(styleParts, parsed, options.cssVarPrefix, options.mapper);\n}\n\nfunction isComponentNamed(value: unknown, name: string): boolean {\n return Boolean(\n value\n && typeof value === \"object\"\n && (value as { __kind?: string }).__kind === \"Component\"\n && (value as { name?: string }).name === name,\n );\n}\n\nfunction stackBaseDirection(props: Record<string, unknown>): string {\n const direction = readResponsiveProp<string>(props.direction);\n if (direction.kind === \"single\") {\n return direction.value ? String(direction.value) : \"column\";\n }\n return direction.values.base ? String(direction.values.base) : \"column\";\n}\n\nexport const StackItem: ComponentSpec = {\n name: \"StackItem\",\n description:\n \"Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one \" +\n \"child so it can `grow` to fill leftover space, `shrink`, set a `basis`, \" +\n \"override `alignSelf`, or change visual `order` — the building block for \" +\n \"asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), \" +\n \"saveButton])` (input expands, button hugs).\",\n props: [\n { name: \"child\", type: \"Node\", description: \"Child node to wrap\" },\n { name: \"grow\", type: \"number\", optional: true, description: \"flex-grow (0 or 1 typical)\" },\n { name: \"shrink\", type: \"number\", optional: true, description: \"flex-shrink (0 or 1 typical)\" },\n { name: \"basis\", type: \"string\", optional: true, description: \"flex-basis (`auto`, `0`, or CSS length)\" },\n { name: \"alignSelf\", type: \"string\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Per-item cross-axis alignment\" },\n { name: \"order\", type: \"number\", optional: true, description: \"Visual order override\" },\n { name: \"minWidth\", type: \"string\", optional: true, description: \"CSS min-width\" },\n { name: \"maxWidth\", type: \"string\", optional: true, description: \"CSS max-width\" },\n ],\n render: (_node, props, helpers) => {\n const attrs: Record<string, string | null> = { class: \"rui-stack-item\" };\n const styleParts: string[] = [];\n if (props.grow !== undefined && props.grow !== null) {\n attrs[\"data-grow\"] = String(asNumber(props.grow, 0));\n }\n if (props.shrink !== undefined && props.shrink !== null) {\n attrs[\"data-shrink\"] = String(asNumber(props.shrink, 1));\n }\n const basis = asString(props.basis);\n if (basis === \"auto\" || basis === \"0\") {\n attrs[\"data-basis\"] = basis;\n } else if (basis) {\n styleParts.push(`flex-basis:${sanitiseCssLength(basis, basis)}`);\n }\n const alignSelf = asString(props.alignSelf);\n if (alignSelf) attrs[\"data-align-self\"] = alignSelf;\n if (props.order !== undefined && props.order !== null) {\n const order = asNumber(props.order, 0);\n attrs[\"data-order\"] = String(order);\n styleParts.push(`order:${order}`);\n }\n const minWidth = asString(props.minWidth);\n if (minWidth) styleParts.push(`min-width:${sanitiseCssLength(minWidth, minWidth)}`);\n const maxWidth = asString(props.maxWidth);\n if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);\n if (styleParts.length > 0) attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n root.append(helpers.renderNode(props.child));\n return root;\n },\n};\n\n/**\n * Shared flex engine behind `Stack`, `Row`, and `Column`. All three render\n * the same `.rui-stack` DOM so they share one stylesheet; they differ only\n * in their *defaults* (direction, cross-axis alignment, whether children\n * grow to fill the main axis). `directionValue` may be a single token or a\n * responsive map (`Stack` passes the author's `direction` prop; `Row` /\n * `Column` pass a fixed `\"row\"` / `\"column\"`). `uniform` is the resolved\n * \"children share the main axis equally\" flag.\n */\nfunction renderFlexContainer(\n directionValue: unknown,\n uniform: boolean,\n alignDefault: string,\n props: Record<string, unknown>,\n helpers: RenderHelpers,\n): HTMLElement {\n const direction = readResponsiveProp<string>(directionValue);\n const gap = readResponsiveProp<string>(props.gap);\n const padding = readResponsiveProp<string>(props.padding);\n const reverse = asBoolean(props.reverse);\n const attrs: Record<string, string | null> = {\n class: \"rui-stack\",\n \"data-wrap\": asBoolean(props.wrap) ? \"true\" : null,\n \"data-reverse\": reverse ? \"true\" : null,\n \"data-uniform\": uniform ? \"true\" : \"false\",\n \"data-inline\": asBoolean(props.inline) ? \"true\" : null,\n };\n const styleParts: string[] = [];\n if (direction.kind === \"single\") {\n const dir = direction.value ? String(direction.value) : \"column\";\n attrs[\"data-direction\"] = applyDirectionWithReverse(dir, reverse);\n } else {\n attrs[\"data-direction\"] = \"responsive\";\n attrs[\"data-responsive-dir\"] = \"true\";\n for (const bp of RESPONSIVE_BREAKPOINTS) {\n const v = direction.values[bp];\n if (v) styleParts.push(`--rui-stack-dir-${bp}:${applyDirectionWithReverse(String(v), reverse)}`);\n }\n }\n if (gap.kind === \"single\") {\n attrs[\"data-gap\"] = gap.value ? String(gap.value) : \"m\";\n } else {\n attrs[\"data-gap\"] = \"responsive\";\n attrs[\"data-responsive-gap\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, gap, \"--rui-stack-gap\");\n }\n applyResponsiveEnumProp(props.align, styleParts, attrs, {\n attrName: \"data-align\",\n responsiveFlag: \"data-responsive-align\",\n cssVarPrefix: \"--rui-stack-align\",\n defaultToken: alignDefault,\n mapper: mapFlexAlign,\n });\n applyResponsiveEnumProp(props.justify, styleParts, attrs, {\n attrName: \"data-justify\",\n responsiveFlag: \"data-responsive-justify\",\n cssVarPrefix: \"--rui-stack-justify\",\n defaultToken: \"start\",\n mapper: mapFlexJustify,\n });\n const alignContent = asString(props.alignContent);\n if (alignContent) attrs[\"data-align-content\"] = alignContent;\n if (padding.kind === \"single\") {\n const pad = padding.value ? String(padding.value) : null;\n if (pad) attrs[\"data-padding\"] = pad;\n } else {\n attrs[\"data-padding\"] = \"responsive\";\n attrs[\"data-responsive-padding\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, padding, \"--rui-stack-padding\");\n }\n if (styleParts.length > 0) attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n for (const child of asArray(props.children)) {\n root.append(helpers.renderNode(child));\n }\n return root;\n}\n\n/** Shared prop docs for the flex family (Stack/Row/Column). */\nconst FLEX_GAP_PROP = { name: \"gap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Spacing between children. May be a responsive map.\" } as const;\nconst FLEX_JUSTIFY_PROP = { name: \"justify\", type: \"string | object\", optional: true, enum: [\"start\", \"center\", \"end\", \"between\", \"around\", \"evenly\"], description: \"Main-axis distribution. May be a responsive map.\" } as const;\nconst FLEX_WRAP_PROP = { name: \"wrap\", type: \"boolean\", optional: true, description: \"Wrap children onto multiple lines when they overflow\" } as const;\nconst FLEX_REVERSE_PROP = { name: \"reverse\", type: \"boolean\", optional: true, description: \"Reverse the visual order of children\" } as const;\nconst FLEX_PADDING_PROP = { name: \"padding\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Inner padding token. May be a responsive map.\" } as const;\nconst FLEX_INLINE_PROP = { name: \"inline\", type: \"boolean\", optional: true, description: \"Use inline-flex (shrink-to-fit) instead of a full-width block\" } as const;\nconst FLEX_ALIGN_CONTENT_PROP = { name: \"alignContent\", type: \"string\", optional: true, enum: [\"start\", \"center\", \"end\", \"between\", \"around\", \"stretch\"], description: \"Alignment of wrapped lines (only when `wrap` is on)\" } as const;\n\nexport const Row: ComponentSpec = {\n name: \"Row\",\n description:\n \"Lay children out horizontally (left → right) with even spacing. The \" +\n \"developer-friendly default: children keep their natural width and are \" +\n \"vertically centered. Set `grow=true` to make children share the row \" +\n \"equally (for equal-width columns prefer `Grid(columns: N)`); drop a \" +\n \"`Spacer()` between children to push them apart; wrap a child in \" +\n \"`StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for \" +\n \"chips/tags that should flow onto multiple lines.\",\n props: [\n { name: \"children\", type: \"Node[]\", description: \"Children laid out left → right\" },\n { name: \"gap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Horizontal spacing between children (default `m`). May be a responsive map.\" },\n { name: \"align\", type: \"string | object\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Vertical alignment of children (default `center`). May be a responsive map.\" },\n { ...FLEX_JUSTIFY_PROP },\n { name: \"grow\", type: \"boolean\", optional: true, description: \"Children share the row width equally (replaces the old `uniform`)\" },\n { ...FLEX_WRAP_PROP },\n { ...FLEX_REVERSE_PROP },\n { ...FLEX_PADDING_PROP },\n { ...FLEX_INLINE_PROP },\n { ...FLEX_ALIGN_CONTENT_PROP },\n ],\n render: (_node, props, helpers) =>\n renderFlexContainer(\"row\", asBoolean(props.grow), \"center\", props, helpers),\n};\n\nexport const Column: ComponentSpec = {\n name: \"Column\",\n description:\n \"Lay children out vertically (top → bottom) with even spacing — the \" +\n \"most common page/section layout. Children stretch to the full width by \" +\n \"default; set `align` to `start`/`center`/`end` to change that. This is \" +\n \"the recommended root container for a page or a card body.\",\n props: [\n { name: \"children\", type: \"Node[]\", description: \"Children laid out top → bottom\" },\n { name: \"gap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Vertical spacing between children (default `m`). May be a responsive map.\" },\n { name: \"align\", type: \"string | object\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Horizontal alignment of children (default `stretch`). May be a responsive map.\" },\n { ...FLEX_JUSTIFY_PROP },\n { ...FLEX_WRAP_PROP },\n { ...FLEX_REVERSE_PROP },\n { ...FLEX_PADDING_PROP },\n { ...FLEX_INLINE_PROP },\n ],\n render: (_node, props, helpers) =>\n renderFlexContainer(\"column\", false, \"stretch\", props, helpers),\n};\n\nexport const Stack: ComponentSpec = {\n name: \"Stack\",\n description:\n \"Low-level flex container with a configurable, optionally responsive \" +\n \"`direction`. Reach for `Row` or `Column` first — they are clearer for \" +\n \"fixed-direction layouts. Use `Stack` when the direction itself must \" +\n \"change across breakpoints, e.g. `direction: {base: \\\"column\\\", md: \" +\n \"\\\"row\\\"}` for a sidebar that stacks on mobile. `gap`, `align`, \" +\n \"`justify`, and `padding` also accept responsive maps. NOTE: a `row` \" +\n \"Stack grows its children equally by default (`uniform=true`); set \" +\n \"`uniform=false` for natural widths (this is `Row`'s default).\",\n props: [\n { name: \"children\", type: \"Node[]\", description: \"Child components to stack\" },\n { name: \"direction\", type: \"string | object\", optional: true, enum: [\"column\", \"row\"], description: \"Layout direction (default column). May be a responsive map like `{base: \\\"column\\\", md: \\\"row\\\"}`.\" },\n { ...FLEX_GAP_PROP },\n { name: \"align\", type: \"string | object\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Cross-axis alignment (default stretch). May be a responsive map.\" },\n { ...FLEX_JUSTIFY_PROP },\n { ...FLEX_ALIGN_CONTENT_PROP },\n { ...FLEX_WRAP_PROP },\n { ...FLEX_REVERSE_PROP },\n { name: \"uniform\", type: \"boolean\", optional: true, description: \"Row children share space equally (default true for row stacks; use `Row` for natural widths)\" },\n { ...FLEX_INLINE_PROP },\n { ...FLEX_PADDING_PROP },\n ],\n render: (_node, props, helpers) => {\n const baseDir = stackBaseDirection(props);\n const uniformDefault = baseDir === \"row\";\n const uniform = props.uniform === undefined\n ? uniformDefault\n : asBoolean(props.uniform, uniformDefault);\n return renderFlexContainer(props.direction, uniform, \"stretch\", props, helpers);\n },\n};\n\nexport const Center: ComponentSpec = {\n name: \"Center\",\n description:\n \"Centers its children on both axes — the easy way to drop a spinner, an \" +\n \"empty state, a hero call-to-action, or a modal body into the middle of \" +\n \"a region. Give it `minHeight` (e.g. `\\\"60vh\\\"`) to center vertically \" +\n \"inside a tall area, or `axis` to center on only one axis. Multiple \" +\n \"children stack in a column and are centered as a group.\",\n props: [\n { name: \"children\", type: \"Node[]\", description: \"Content to center\" },\n { name: \"axis\", type: \"string\", optional: true, enum: [\"both\", \"horizontal\", \"vertical\"], description: \"Which axis to center on (default both)\" },\n { name: \"minHeight\", type: \"string\", optional: true, description: \"CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)\" },\n { name: \"gap\", type: \"string\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Spacing between stacked children (default `m`)\" },\n { name: \"padding\", type: \"string\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Inner padding token\" },\n { name: \"inline\", type: \"boolean\", optional: true, description: \"Shrink to fit content instead of filling the available width\" },\n ],\n render: (_node, props, helpers) => {\n const attrs: Record<string, string | null> = {\n class: \"rui-center\",\n \"data-axis\": asString(props.axis, \"both\"),\n \"data-gap\": asString(props.gap, \"m\"),\n \"data-inline\": asBoolean(props.inline) ? \"true\" : null,\n };\n const padding = asString(props.padding);\n if (padding) attrs[\"data-padding\"] = padding;\n const styleParts: string[] = [];\n const minHeight = asString(props.minHeight);\n if (minHeight) styleParts.push(`min-height:${sanitiseCssLength(minHeight, minHeight)}`);\n if (styleParts.length > 0) attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const Card: ComponentSpec = {\n name: \"Card\",\n description: \"Vertical card container.\",\n props: [\n { name: \"children\", type: \"Node[]\", description: \"Card contents\" },\n { name: \"variant\", type: \"string\", optional: true, enum: [\"default\", \"outlined\", \"elevated\"] },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-card\",\n \"data-variant\": asString(props.variant, \"default\"),\n });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const CardHeader: ComponentSpec = {\n name: \"CardHeader\",\n description: \"Card header with title and optional subtitle.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"subtitle\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const root = el(\"header\", { class: \"rui-card-header\" });\n root.append(el(\"h3\", { class: \"rui-card-title\" }, [asString(props.title)]));\n const subtitle = asString(props.subtitle);\n if (subtitle) root.append(el(\"p\", { class: \"rui-card-subtitle\" }, [subtitle]));\n return root;\n },\n};\n\nexport const CardFooter: ComponentSpec = {\n name: \"CardFooter\",\n description: \"Card footer for actions.\",\n props: [{ name: \"children\", type: \"Node[]\" }],\n render: (_node, props, helpers) => {\n const root = el(\"footer\", { class: \"rui-card-footer\" });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const Separator: ComponentSpec = {\n name: \"Separator\",\n description:\n \"Visual divider between content sections. Supports horizontal or \" +\n \"vertical orientation, and an optional center `label` (lifted from \" +\n \"the legacy `Divider`). Use `decorative=false` to expose the \" +\n \"separator to assistive tech.\",\n props: [\n { name: \"orientation\", type: \"string\", optional: true, enum: [\"horizontal\", \"vertical\"] },\n { name: \"label\", type: \"string\", optional: true, description: \"Optional label rendered in the middle (horizontal only)\" },\n { name: \"decorative\", type: \"boolean\", optional: true, description: \"Hides the separator from assistive tech when true (default)\" },\n ],\n render: (_node, props) => {\n const orientation = asString(props.orientation, \"horizontal\");\n const decorative = asBoolean(props.decorative, true);\n const label = asString(props.label);\n if (label && orientation === \"horizontal\") {\n return el(\"div\", {\n class: \"rui-separator rui-separator-with-label\",\n \"data-orientation\": orientation,\n role: decorative ? \"presentation\" : \"separator\",\n \"aria-orientation\": decorative ? null : orientation,\n }, [\n el(\"span\", { class: \"rui-separator-line\" }),\n el(\"span\", { class: \"rui-separator-label\" }, [label]),\n el(\"span\", { class: \"rui-separator-line\" }),\n ]);\n }\n return el(\"div\", {\n class: \"rui-separator\",\n \"data-orientation\": orientation,\n role: decorative ? \"presentation\" : \"separator\",\n \"aria-orientation\": decorative ? null : orientation,\n });\n },\n};\n\nconst renderStepLi = (title: string, details: string, active = false): HTMLElement => {\n const root = el(\"li\", {\n class: \"rui-steps-item\",\n \"data-active\": active ? \"true\" : \"false\",\n });\n root.append(el(\"div\", { class: \"rui-steps-title\" }, [title]));\n if (details) root.append(el(\"div\", { class: \"rui-steps-details\" }, [details]));\n return root;\n};\n\nexport const Steps: ComponentSpec = {\n name: \"Steps\",\n description:\n \"Numbered step-by-step guide. Pass items as `{title, details?, active?}` \" +\n \"objects. Use `active` to mark the current step in a multi-step flow.\",\n props: [\n { name: \"items\", type: \"object[]\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"ol\", { class: \"rui-steps\" });\n for (const item of asArray<unknown>(props.items)) {\n if (item && typeof item === \"object\" && (item as { __kind?: string }).__kind === \"Component\") {\n root.append(helpers.renderNode(item));\n continue;\n }\n if (item && typeof item === \"object\") {\n const data = item as { title?: unknown; details?: unknown; active?: unknown };\n root.append(renderStepLi(\n asString(data.title),\n asString(data.details),\n asBoolean(data.active),\n ));\n continue;\n }\n // Plain string falls back to a title-only step.\n root.append(renderStepLi(asString(item), \"\"));\n }\n return root;\n },\n};\n\nexport const TabItem: ComponentSpec = {\n name: \"TabItem\",\n description:\n \"Single tab definition (used inside Tabs). Add `badge` for a count \" +\n \"chip in the tab trigger, and `icon` for a leading Font Awesome icon.\",\n props: [\n { name: \"value\", type: \"string\", description: \"Stable identifier for the tab\" },\n { name: \"label\", type: \"string\", description: \"Display label\" },\n { name: \"children\", type: \"Node[]\", description: \"Tab content\" },\n { name: \"badge\", type: \"string\", optional: true, description: \"Trailing chip rendered in the tab trigger (count / status)\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name shown before the label\" },\n ],\n render: (_node, props, helpers) => {\n const wrapper = el(\"div\", {\n class: \"rui-tab-content\",\n role: \"tabpanel\",\n \"data-value\": asString(props.value),\n \"data-active\": \"false\",\n });\n for (const child of asArray(props.children)) wrapper.append(helpers.renderNode(child));\n return wrapper;\n },\n};\n\nexport const Tabs: ComponentSpec = {\n name: \"Tabs\",\n description:\n \"Tabbed container. Children must be TabItem components. Supports \" +\n \"`orientation=\\\"vertical\\\"` for sidebar-style tabs and built-in \" +\n \"keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to \" +\n \"react when the user switches tabs (called with the new tab's value).\",\n props: [\n { name: \"items\", type: \"TabItem[]\", description: \"Tab definitions\" },\n { name: \"defaultValue\", type: \"string\", optional: true, description: \"Initially active tab value\" },\n { name: \"orientation\", type: \"string\", optional: true, enum: [\"horizontal\", \"vertical\"], description: \"Layout direction (default `horizontal`)\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-activated tab value when the user switches tabs\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const orientation = asString(props.orientation, \"horizontal\");\n const root = el(\"div\", { class: \"rui-tabs\", \"data-orientation\": orientation });\n const tablist = el(\"div\", {\n class: \"rui-tab-list\",\n role: \"tablist\",\n \"aria-orientation\": orientation,\n });\n const panels = el(\"div\", { class: \"rui-tab-panels\" });\n\n // Compute the falsy-default tab value (LLM-supplied `defaultValue` or\n // the first item) so we can seed the persistent active slot when the\n // user has never interacted with this Tabs instance.\n let fallbackValue = asString(props.defaultValue);\n if (!fallbackValue && items.length > 0) {\n const first = items[0] as { args?: unknown[] } | undefined;\n fallbackValue = asString(first?.args?.[0], \"tab-0\");\n }\n\n // Persist the active tab across re-renders. Without this slot the active\n // pane would jump back to `defaultValue` every time an unrelated state\n // change re-renders the tree (e.g. typing into an Input one panel over).\n const activeSlot = helpers.useInstanceState<string>(\"activeTab\", fallbackValue);\n\n // If `defaultValue` was changed by the LLM since last render, honour the\n // new prop. This lets host code drive the active tab via state without\n // breaking the persistence behaviour for user-initiated clicks.\n if (asString(props.defaultValue) && asString(props.defaultValue) !== fallbackValue) {\n activeSlot.set(asString(props.defaultValue));\n }\n\n // Make sure the persisted value still refers to a tab that exists —\n // the LLM may have removed the previously-active tab mid-stream.\n const validValues = new Set(\n items.map((item, idx) => asString((item as { args?: unknown[] }).args?.[0], `tab-${idx}`)),\n );\n if (!validValues.has(activeSlot.get())) {\n activeSlot.set(fallbackValue);\n }\n\n // setActive walks the LIVE DOM (via the clicked button's ancestor chain)\n // instead of the local `tablist` / `panels` closure variables. With the\n // morph reconciler in place, an unrelated re-render may produce a fresh\n // Tabs subtree whose onclick handlers get copied onto the previously\n // mounted nodes — the closures' local refs point at the discarded fresh\n // subtree, but `event.currentTarget` is always the in-DOM button.\n const setActive = (next: string, originBtn: Element): void => {\n const previous = activeSlot.get();\n activeSlot.set(next);\n const liveRoot = originBtn.closest(\".rui-tabs\");\n if (liveRoot) {\n liveRoot.querySelectorAll<HTMLButtonElement>(\".rui-tab-trigger\").forEach((b) => {\n const isActive = b.getAttribute(\"data-value\") === next;\n b.setAttribute(\"aria-selected\", isActive ? \"true\" : \"false\");\n b.tabIndex = isActive ? 0 : -1;\n });\n liveRoot.querySelectorAll<HTMLElement>(\".rui-tab-content\").forEach((p) => {\n p.setAttribute(\"data-active\", p.getAttribute(\"data-value\") === next ? \"true\" : \"false\");\n });\n }\n if (previous !== next) helpers.invoke(props.onChange, next);\n };\n\n items.forEach((item, idx) => {\n const tabNode = item as { name?: string; args?: unknown[] };\n const value = asString(tabNode.args?.[0], `tab-${idx}`);\n const label = asString(tabNode.args?.[1], `Tab ${idx + 1}`);\n const badge = asString(tabNode.args?.[3]);\n const icon = asString(tabNode.args?.[4]);\n const isActive = value === activeSlot.get();\n const button = el(\n \"button\",\n {\n class: \"rui-tab-trigger\",\n role: \"tab\",\n type: \"button\",\n \"data-value\": value,\n \"aria-selected\": isActive ? \"true\" : \"false\",\n tabindex: isActive ? \"0\" : \"-1\",\n },\n );\n // We use the icon helper without falling back to inline emoji so that\n // an unset icon prop renders the trigger as label-only.\n const iconNode = icon ? renderIconForTab(icon) : null;\n if (iconNode) button.append(iconNode);\n button.append(el(\"span\", { class: \"rui-tab-trigger-label\" }, [label]));\n if (badge) button.append(el(\"span\", { class: \"rui-tab-trigger-badge\" }, [badge]));\n button.onclick = (event) => {\n const origin = (event.currentTarget ?? event.target) as Element;\n setActive(value, origin);\n };\n // Keyboard navigation between tabs (ArrowLeft/Right/Up/Down/Home/End)\n // resolves the next focusable trigger from the live DOM so it survives\n // morph reconciliation.\n button.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n const horizontal = orientation !== \"vertical\";\n const isNext = horizontal ? e.key === \"ArrowRight\" : e.key === \"ArrowDown\";\n const isPrev = horizontal ? e.key === \"ArrowLeft\" : e.key === \"ArrowUp\";\n if (!isNext && !isPrev && e.key !== \"Home\" && e.key !== \"End\") return;\n e.preventDefault();\n const origin = (e.currentTarget ?? e.target) as Element;\n const liveList = origin.closest(\".rui-tab-list\");\n if (!liveList) return;\n const triggers = Array.from(liveList.querySelectorAll<HTMLButtonElement>(\".rui-tab-trigger\"));\n if (triggers.length === 0) return;\n const currentIdx = triggers.indexOf(origin as HTMLButtonElement);\n let nextIdx = currentIdx;\n if (e.key === \"Home\") nextIdx = 0;\n else if (e.key === \"End\") nextIdx = triggers.length - 1;\n else if (isNext) nextIdx = (currentIdx + 1) % triggers.length;\n else if (isPrev) nextIdx = (currentIdx - 1 + triggers.length) % triggers.length;\n const target = triggers[nextIdx];\n if (!target) return;\n target.focus();\n const nextValue = target.getAttribute(\"data-value\") ?? \"\";\n if (nextValue) setActive(nextValue, target);\n };\n tablist.append(button);\n\n const panel = helpers.renderNode(item) as HTMLElement;\n panel.setAttribute(\"data-value\", value);\n panel.setAttribute(\"data-active\", isActive ? \"true\" : \"false\");\n panels.append(panel);\n });\n\n root.append(tablist, panels);\n return root;\n },\n};\n\nfunction renderIconForTab(iconName: string): HTMLElement | null {\n // Tab triggers use the standard rui-icon helper class so consumers can\n // override icon spacing via theme tokens without touching the trigger.\n return renderIcon(iconName, { className: \"rui-tab-trigger-icon\" });\n}\n\nexport const AccordionItem: ComponentSpec = {\n name: \"AccordionItem\",\n description: \"Single accordion section.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"children\", type: \"Node[]\" },\n { name: \"open\", type: \"boolean\", optional: true },\n { name: \"showArrow\", type: \"boolean\", optional: true, description: \"Show a chevron icon on the right (default false). Inherits from parent Accordion when unset.\" },\n ],\n render: (_node, props, helpers) => {\n const explicit = props.showArrow !== undefined && props.showArrow !== null;\n const details = el(\"details\", {\n class: \"rui-accordion-item\",\n \"data-show-arrow\": explicit ? (asBoolean(props.showArrow) ? \"true\" : \"false\") : null,\n });\n if (asBoolean(props.open)) details.setAttribute(\"open\", \"\");\n const summary = el(\"summary\", { class: \"rui-accordion-trigger\" });\n summary.append(el(\"span\", { class: \"rui-accordion-title\" }, [asString(props.title)]));\n summary.append(el(\"span\", { class: \"rui-accordion-chevron\", \"aria-hidden\": \"true\" }));\n details.append(summary);\n const body = el(\"div\", { class: \"rui-accordion-body\" });\n for (const child of asArray(props.children)) body.append(helpers.renderNode(child));\n details.append(body);\n return details;\n },\n};\n\nexport const Accordion: ComponentSpec = {\n name: \"Accordion\",\n description:\n \"Accordion container. Children must be AccordionItem components. \" +\n \"Set `showArrow: true` to add a chevron indicator to every item; \" +\n \"individual `AccordionItem`s can override via their own `showArrow` prop.\",\n props: [\n { name: \"items\", type: \"AccordionItem[]\" },\n { name: \"showArrow\", type: \"boolean\", optional: true, description: \"Show chevron icon on every item (default false).\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-accordion\",\n \"data-show-arrow\": asBoolean(props.showArrow) ? \"true\" : \"false\",\n });\n for (const child of asArray(props.items)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nconst clampGridColumns = (n: number): number => Math.max(1, Math.min(GRID_COLUMNS, Math.round(n)));\n\n/** Resolve a grid span from a number or fraction string (e.g. `\"1/3\"` → 4 on a 12-col grid). */\nexport function resolveSpan(span: unknown): number {\n if (span == null || span === \"\") return 12;\n const raw = String(span).trim();\n if (raw.includes(\"/\")) {\n const [numPart, denPart] = raw.split(\"/\");\n const num = Number(numPart);\n const den = Number(denPart);\n if (Number.isFinite(num) && Number.isFinite(den) && den > 0) {\n return clampGridColumns(Math.round((GRID_COLUMNS * num) / den));\n }\n }\n if (raw === \"auto\" || raw === \"fit\" || raw === \"auto-fit\" || raw === \"full\" || raw === \"100%\") return 12;\n return clampGridColumns(asNumber(span, 12));\n}\n\nfunction gridMinChildWidth(props: Record<string, unknown>): string {\n const width = asString(props.minChildWidth) || asString(props.minItemWidth);\n return sanitiseCssLength(width || \"220px\", \"220px\");\n}\n\nexport const GridItem: ComponentSpec = {\n name: \"GridItem\",\n description:\n \"Wraps a child in a 12-column grid cell with `span`, `offset`, and \" +\n \"responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode \" +\n \"when any child is a `GridItem`. Fraction spans like `\\\"1/3\\\"` resolve \" +\n \"against the 12-column track.\",\n props: [\n { name: \"child\", type: \"Node\", description: \"Child node to place in the grid\" },\n { name: \"span\", type: \"number | string\", optional: true, description: \"Columns to span (1–12) or fraction like \\\"1/2\\\", \\\"1/3\\\"\" },\n { name: \"offset\", type: \"number\", optional: true, description: \"Empty columns before this item (0–11)\" },\n { name: \"spanAt\", type: \"object\", optional: true, description: \"Responsive span map `{sm: 12, md: 6, lg: 4}`\" },\n ],\n render: (_node, props, helpers) => {\n const baseSpan = resolveSpan(props.span ?? 12);\n const spanAt = readResponsiveProp<number | string>(props.spanAt);\n const offset = props.offset === undefined || props.offset === null\n ? 0\n : Math.max(0, Math.min(GRID_COLUMNS - 1, Math.round(asNumber(props.offset, 0))));\n const attrs: Record<string, string | null> = {\n class: \"rui-grid-item\",\n \"data-span\": String(baseSpan),\n };\n const styleParts: string[] = [`--rui-grid-item-span:${baseSpan}`];\n if (offset > 0) {\n attrs[\"data-offset\"] = String(offset);\n styleParts.push(`--rui-grid-item-offset:${offset}`);\n }\n if (spanAt.kind === \"responsive\") {\n attrs[\"data-responsive-span\"] = \"true\";\n for (const bp of RESPONSIVE_BREAKPOINTS) {\n const v = spanAt.values[bp];\n if (v !== undefined) {\n const resolved = resolveSpan(v);\n styleParts.push(`--rui-grid-item-span-${bp}:${resolved}`);\n }\n }\n } else if (spanAt.kind === \"single\" && spanAt.value != null) {\n const resolved = resolveSpan(spanAt.value);\n styleParts.push(`--rui-grid-item-span:${resolved}`);\n attrs[\"data-span\"] = String(resolved);\n }\n attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n root.append(helpers.renderNode(props.child));\n return root;\n },\n};\n\nexport const Box: ComponentSpec = {\n name: \"Box\",\n description:\n \"Spacing and surface wrapper for padding, margin, borders, semantic \" +\n \"backgrounds, and max-width constraints. Use when a `Card` is too heavy \" +\n \"but the content needs a subtle surface or inset.\",\n props: [\n { name: \"children\", type: \"Node[]\" },\n { name: \"padding\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Inner padding. May be a responsive map.\" },\n { name: \"margin\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Outer margin. May be a responsive map.\" },\n { name: \"border\", type: \"string\", optional: true, enum: [\"none\", \"subtle\", \"default\"], description: \"Border preset (default none)\" },\n { name: \"background\", type: \"string\", optional: true, enum: [\"none\", \"surface\", \"muted\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"], description: \"Semantic background token\" },\n { name: \"maxWidth\", type: \"string\", optional: true, description: \"CSS max-width\" },\n ],\n render: (_node, props, helpers) => {\n const padding = readResponsiveProp<string>(props.padding);\n const margin = readResponsiveProp<string>(props.margin);\n const attrs: Record<string, string | null> = {\n class: \"rui-box\",\n \"data-border\": asString(props.border, \"none\"),\n \"data-background\": asString(props.background, \"none\"),\n };\n const styleParts: string[] = [];\n const maxWidth = asString(props.maxWidth);\n if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);\n if (padding.kind === \"single\") {\n const pad = padding.value ? String(padding.value) : null;\n if (pad) attrs[\"data-padding\"] = pad;\n } else {\n attrs[\"data-padding\"] = \"responsive\";\n attrs[\"data-responsive-padding\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, padding, \"--rui-box-padding\");\n }\n if (margin.kind === \"single\") {\n const mar = margin.value ? String(margin.value) : null;\n if (mar) attrs[\"data-margin\"] = mar;\n } else {\n attrs[\"data-margin\"] = \"responsive\";\n attrs[\"data-responsive-margin\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, margin, \"--rui-box-margin\");\n }\n if (styleParts.length > 0) attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const Grid: ComponentSpec = {\n name: \"Grid\",\n description:\n \"Two-dimensional grid with three modes:\\n\" +\n \" 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as \" +\n \"fit, each at least `minChildWidth` wide (default 220px) — perfect for \" +\n \"card/KPI grids that should reflow on their own.\\n\" +\n \" 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\\n\" +\n \" 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid \" +\n \"where each `GridItem` sets its own `span` (a number 1–12 or a fraction \" +\n \"like `\\\"1/3\\\"`) for dashboards and asymmetric layouts.\\n\" +\n \"`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.\",\n props: [\n { name: \"children\", type: \"Node[]\" },\n { name: \"columns\", type: \"number | object\", optional: true, description: \"Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`.\" },\n { name: \"gap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Gap on both axes (default `m`). May be a responsive map.\" },\n { name: \"rowGap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Row gap override. May be a responsive map.\" },\n { name: \"columnGap\", type: \"string | object\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Column gap override. May be a responsive map.\" },\n { name: \"minChildWidth\", type: \"string\", optional: true, aliases: [\"minItemWidth\"], description: \"Minimum column width for AUTO-FIT mode, e.g. `\\\"240px\\\"` (default 220px). Also caps the floor in FIXED mode.\" },\n { name: \"alignItems\", type: \"string\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Vertical alignment of items within their cells\" },\n { name: \"justifyItems\", type: \"string\", optional: true, enum: [\"start\", \"center\", \"end\", \"stretch\"], description: \"Horizontal alignment of items within their cells\" },\n { name: \"dense\", type: \"boolean\", optional: true, description: \"Dense auto-flow packing — let later items backfill earlier gaps\" },\n ],\n render: (_node, props, helpers) => {\n const children = asArray(props.children);\n const hasGridItems = children.some((child) => isComponentNamed(child, \"GridItem\"));\n const columns = readResponsiveProp<number | string>(props.columns);\n const gap = readResponsiveProp<string>(props.gap);\n const rowGap = readResponsiveProp<string>(props.rowGap);\n const columnGap = readResponsiveProp<string>(props.columnGap);\n const attrs: Record<string, string | null> = {\n class: \"rui-grid\",\n };\n const styleParts: string[] = [];\n // Twelve-column mode is enabled when (a) the author explicitly asks\n // for 12 columns or (b) GridItem children are present AND no explicit\n // non-12 column count was supplied. When the author writes\n // `Grid([...], 3)` they expect a 3-column grid regardless of whether\n // the children are GridItem wrappers; forcing 12-column mode squashes\n // each `GridItem` (default span=1) to 1/12 of the row.\n let twelveColMode = false;\n let explicitNonTwelve = false;\n\n if (columns.kind === \"single\") {\n const requested = columns.value === null ? 0 : asNumber(columns.value, 0);\n const cols = requested > 0 ? clampGridColumns(requested) : 0;\n if (cols === GRID_COLUMNS) {\n twelveColMode = true;\n } else if (cols > 0) {\n explicitNonTwelve = true;\n }\n if (cols > 0) {\n attrs[\"data-columns\"] = String(cols);\n const minChild = asString(props.minChildWidth) || asString(props.minItemWidth);\n if (minChild) {\n attrs[\"data-min-child-width\"] = \"true\";\n styleParts.push(`--rui-grid-min-child:${sanitiseCssLength(minChild, \"220px\")}`);\n }\n } else {\n styleParts.push(`--rui-grid-min-item:${gridMinChildWidth(props)}`);\n }\n } else {\n attrs[\"data-responsive-cols\"] = \"true\";\n for (const bp of RESPONSIVE_BREAKPOINTS) {\n const v = columns.values[bp as Breakpoint];\n if (v === undefined) continue;\n const cols = clampGridColumns(asNumber(v, 0));\n if (cols === GRID_COLUMNS) {\n twelveColMode = true;\n } else if (cols > 0) {\n explicitNonTwelve = true;\n }\n styleParts.push(`--rui-grid-cols-${bp}:${cols}`);\n }\n }\n\n if (hasGridItems && !explicitNonTwelve) twelveColMode = true;\n if (twelveColMode) attrs[\"data-grid-mode\"] = \"12\";\n\n if (gap.kind === \"single\") {\n attrs[\"data-gap\"] = gap.value ? String(gap.value) : \"m\";\n } else {\n attrs[\"data-gap\"] = \"responsive\";\n attrs[\"data-responsive-gap\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, gap, \"--rui-grid-gap\");\n }\n\n if (rowGap.kind === \"single\" && rowGap.value) {\n attrs[\"data-row-gap\"] = String(rowGap.value);\n } else if (rowGap.kind === \"responsive\") {\n attrs[\"data-row-gap\"] = \"responsive\";\n attrs[\"data-responsive-row-gap\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, rowGap, \"--rui-grid-row-gap\");\n }\n\n if (columnGap.kind === \"single\" && columnGap.value) {\n attrs[\"data-column-gap\"] = String(columnGap.value);\n } else if (columnGap.kind === \"responsive\") {\n attrs[\"data-column-gap\"] = \"responsive\";\n attrs[\"data-responsive-column-gap\"] = \"true\";\n emitResponsiveSpacingVars(styleParts, columnGap, \"--rui-grid-column-gap\");\n }\n\n const alignItems = asString(props.alignItems);\n if (alignItems) attrs[\"data-align-items\"] = alignItems;\n const justifyItems = asString(props.justifyItems);\n if (justifyItems) attrs[\"data-justify-items\"] = justifyItems;\n if (asBoolean(props.dense)) attrs[\"data-dense\"] = \"true\";\n\n if (styleParts.length > 0) attrs.style = styleParts.join(\";\");\n const root = el(\"div\", attrs);\n for (const child of children) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const AspectRatio: ComponentSpec = {\n name: \"AspectRatio\",\n description:\n \"Container that constrains its child to a fixed aspect ratio (e.g. 16:9 \" +\n \"for video embeds, 1:1 for thumbnails). The child fills the box.\",\n props: [\n { name: \"ratio\", type: \"string\", description: \"`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`\" },\n { name: \"children\", type: \"Node[]\" },\n ],\n render: (_node, props, helpers) => {\n const ratio = parseRatio(asString(props.ratio, \"16:9\"));\n const root = el(\"div\", {\n class: \"rui-aspect-ratio\",\n style: `aspect-ratio:${ratio};`,\n });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nfunction parseRatio(input: string): string {\n if (input.includes(\":\")) {\n const [w, h] = input.split(\":\");\n const num = Number(w);\n const den = Number(h);\n if (Number.isFinite(num) && Number.isFinite(den) && den !== 0) return `${num} / ${den}`;\n }\n const n = Number(input);\n return Number.isFinite(n) && n > 0 ? `${n} / 1` : \"16 / 9\";\n}\n\nexport const ScrollArea: ComponentSpec = {\n name: \"ScrollArea\",\n description:\n \"Bounded scroll container. Use to clip long lists / logs / chat panels \" +\n \"to a fixed max height with a clean scrollbar.\",\n props: [\n { name: \"children\", type: \"Node[]\" },\n { name: \"maxHeight\", type: \"string\", optional: true, aliases: [\"height\"], description: \"CSS height (default 320px)\" },\n { name: \"direction\", type: \"string\", optional: true, enum: [\"vertical\", \"horizontal\", \"both\"] },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-scroll-area\",\n \"data-direction\": asString(props.direction, \"vertical\"),\n style: `max-height:${sanitiseCssLength(props.maxHeight, \"320px\")};`,\n });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nconst MODAL_SIZES = [\"sm\", \"md\", \"lg\", \"xl\", \"full\"] as const;\n\nexport const Modal: ComponentSpec = {\n name: \"Modal\",\n description:\n \"Dialog overlay shown when `open` is true. Pass a `$variable` as \" +\n \"`open` to control it. The header always renders a × close button \" +\n \"(disable via `closable: false`); the optional `footer` slot is the \" +\n \"canonical place for action buttons. `closeOnBackdrop=true` opts in \" +\n \"to backdrop-click dismissal. `onClose` fires every time the modal \" +\n \"closes (× button, backdrop, programmatic state write).\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"open\", type: \"boolean\", description: \"Open/closed state — usually a $variable\" },\n { name: \"children\", type: \"Node[]\" },\n { name: \"size\", type: \"string\", optional: true, enum: MODAL_SIZES, description: \"Width preset (default `md`)\" },\n { name: \"footer\", type: \"Node[]\", optional: true, description: \"Footer slot — typically a row of action Buttons\" },\n { name: \"closable\", type: \"boolean\", optional: true, description: \"Render the header × button (default true)\" },\n { name: \"closeOnBackdrop\", type: \"boolean\", optional: true, description: \"Close when the overlay is clicked (default false)\" },\n { name: \"onClose\", type: \"callable\", optional: true, aliases: [\"onclose\"], description: \"Callable invoked when the modal is closed (× button or backdrop)\" },\n ],\n render: (node, props, helpers) => {\n const size = asString(props.size, \"md\");\n const closable = props.closable === undefined ? true : asBoolean(props.closable);\n const overlay = el(\"div\", {\n class: \"rui-modal-overlay\",\n \"data-open\": asBoolean(props.open) ? \"true\" : \"false\",\n });\n const dialog = el(\"div\", {\n class: \"rui-modal\",\n role: \"dialog\",\n \"aria-modal\": \"true\",\n \"data-size\": size,\n });\n const header = el(\"header\", { class: \"rui-modal-header\" });\n header.append(el(\"h3\", { class: \"rui-modal-title\" }, [asString(props.title)]));\n const stateName = node.argMeta?.[1]?.stateRef;\n const closeModal = () => {\n if (stateName) helpers.setState(stateName, false);\n helpers.invoke(props.onClose);\n };\n if (closable) {\n const closeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-modal-close\",\n \"aria-label\": \"Close dialog\",\n }, [\"×\"]);\n closeBtn.onclick = (event) => {\n event.stopPropagation();\n closeModal();\n };\n header.append(closeBtn);\n }\n dialog.append(header);\n const body = el(\"div\", { class: \"rui-modal-body\" });\n for (const child of asArray(props.children)) body.append(helpers.renderNode(child));\n dialog.append(body);\n const footer = asArray<unknown>(props.footer);\n if (footer.length > 0) {\n const footRow = el(\"footer\", { class: \"rui-modal-footer\" });\n for (const item of footer) footRow.append(helpers.renderNode(item));\n dialog.append(footRow);\n }\n overlay.append(dialog);\n if (asBoolean(props.closeOnBackdrop)) {\n overlay.onclick = (event) => {\n if (event.target === overlay) closeModal();\n };\n }\n return overlay;\n },\n};\n","/**\n * Content components: Text, Image, Link, Badge, BadgeList, Callout,\n * CodeBlock, Skeleton, Markdown, Icon, Quote, Container, Spacer, Spinner.\n *\n * `TextContent` is exported as a deprecated alias for `Text` so existing\n * Aktion programs keep rendering — prefer `Text` in new code.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n sanitiseCssLength, sanitiseImageSrc,\n} from \"../utils.js\";\nimport { ICON_SIZES } from \"../../icons/index.js\";\n\nconst ICON_VARIANTS = [\"solid\", \"regular\", \"brands\"] as const;\n\nconst SIZE_ENUM = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nconst TONE_ENUM = [\"default\", \"neutral\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] as const;\n\n/**\n * Normalise a legacy size token to the shared `xs|sm|md|lg|xl` vocabulary.\n * Keeps the catalogue self-consistent (suggestion 4.2) while letting old\n * prompts that emit `\"small\"` / `\"normal\"` / `\"large\"` still render.\n */\nexport function normaliseSize(value: unknown, fallback: string = \"md\"): string {\n const v = asString(value).trim().toLowerCase();\n if (!v) return fallback;\n if (v === \"small\") return \"sm\";\n if (v === \"normal\") return \"md\";\n if (v === \"large\") return \"lg\";\n if ((SIZE_ENUM as readonly string[]).includes(v)) return v;\n return fallback;\n}\n\nexport const Icon: ComponentSpec = {\n name: \"Icon\",\n description:\n \"Single Font Awesome icon. `name` is the FA name without the `fa-` \" +\n \"prefix (e.g. `\\\"house\\\"`, `\\\"chart-line\\\"`). Use `variant` for non-solid \" +\n \"styles (`regular`/`brands`) or prefix the name (`\\\"regular:star\\\"`). \" +\n \"`color` accepts any CSS colour (`\\\"#00ff00\\\"`, `\\\"tomato\\\"`, \" +\n \"`\\\"var(--rui-color-primary)\\\"`).\",\n props: [\n { name: \"name\", type: \"string\", description: \"FA name without the fa- prefix\" },\n { name: \"variant\", type: \"string\", optional: true, enum: ICON_VARIANTS },\n { name: \"size\", type: \"string\", optional: true, enum: ICON_SIZES },\n { name: \"color\", type: \"string\", optional: true, description: \"CSS colour applied to the glyph (hex, named, rgb()/hsl(), or var(--token))\" },\n ],\n render: (_node, props) => {\n const name = asString(props.name);\n const variant = asString(props.variant, \"\");\n const size = asString(props.size, \"md\");\n const color = asString(props.color, \"\");\n const composed = variant ? `${variant}:${name}` : name;\n const node = renderIcon(composed, { size, color });\n if (node) return node;\n return el(\"span\", { class: \"rui-icon\", \"data-icon-size\": size }, [name]);\n },\n};\n\n\nconst TEXT_VARIANTS = [\n \"small\",\n \"small-heavy\",\n \"body\",\n \"body-heavy\",\n \"large\",\n \"large-heavy\",\n \"heading\",\n \"title\",\n] as const;\n\n/**\n * Sanitise an inline CSS declaration string before it lands on a DOM\n * element's `style` attribute. The `<span>` style attribute can't host\n * `<style>` injection, but we still strip the legacy attack vectors\n * (IE-only `expression()`, `javascript:` URLs, `behavior:`, `@import`)\n * and any angle brackets defensively. Returns an empty string when the\n * input is rejected so callers can drop the attribute entirely.\n */\nfunction sanitiseInlineStyle(input: unknown): string {\n const raw = asString(input).trim();\n if (!raw) return \"\";\n if (/[<>]/.test(raw)) return \"\";\n if (/\\bexpression\\s*\\(|\\bjavascript\\s*:|\\bbehavior\\s*:|@import\\b/i.test(raw)) {\n return \"\";\n }\n return raw;\n}\n\nconst TEXT_PROPS = [\n { name: \"value\", type: \"string\" },\n { name: \"variant\", type: \"string\", optional: true, enum: TEXT_VARIANTS },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"default\", \"muted\", \"primary\", \"success\", \"warning\", \"danger\"], description: \"Visual accent\" },\n {\n name: \"style\",\n type: \"string\",\n optional: true,\n description: \"Inline CSS declarations applied to the rendered element (e.g. \\\"font-size: 16px; font-weight: bold; color: #000;\\\").\",\n },\n] as const;\n\nconst renderText: ComponentSpec[\"render\"] = (_node, props) => {\n const variant = asString(props.variant, \"body\");\n const tone = asString(props.tone, \"default\");\n const style = sanitiseInlineStyle(props.style);\n return el(\"span\", {\n class: \"rui-text\",\n \"data-variant\": variant,\n \"data-color\": tone,\n style: style || null,\n }, [asString(props.value)]);\n};\n\nexport const Text: ComponentSpec = {\n name: \"Text\",\n description:\n \"Renders plain text with a typographic variant. Optional `style` prop \" +\n \"accepts a CSS declaration string (e.g. \\\"font-size: 16px; color: #000;\\\") \" +\n \"applied directly to the rendered element.\",\n props: TEXT_PROPS,\n render: renderText,\n};\n\n/**\n * Deprecated alias for `Text`. Kept registered so existing Aktion\n * programs that still emit `TextContent(...)` keep rendering. New code\n * should use `Text(...)`.\n */\nexport const TextContent: ComponentSpec = {\n name: \"TextContent\",\n description: \"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.\",\n props: TEXT_PROPS,\n render: renderText,\n};\n\nconst IMAGE_FIT = [\"cover\", \"contain\", \"fill\", \"none\", \"scale-down\"] as const;\n\nexport const Image: ComponentSpec = {\n name: \"Image\",\n description:\n \"Inline image. `ratio` constrains the box to a fixed aspect ratio (e.g. \" +\n \"`16:9`, `1:1`) so callers do not need an outer `AspectRatio`. `fit` \" +\n \"controls how the image fills that box. When `src` is missing or \" +\n \"unsafe the component renders a placeholder (or `fallback` text/icon).\",\n props: [\n { name: \"src\", type: \"string\" },\n { name: \"alt\", type: \"string\", optional: true },\n { name: \"caption\", type: \"string\", optional: true },\n { name: \"ratio\", type: \"string\", optional: true, description: \"Aspect ratio shorthand (e.g. `16:9`, `1:1`, `4:3`)\" },\n { name: \"fit\", type: \"string\", optional: true, enum: IMAGE_FIT, description: \"object-fit value (default `cover`)\" },\n { name: \"fallback\", type: \"string\", optional: true, description: \"Text label or Font Awesome icon shown when src is missing/unsafe\" },\n ],\n render: (_node, props) => {\n const wrapper = el(\"figure\", {\n class: \"rui-image\",\n \"data-fit\": asString(props.fit, \"cover\"),\n style: props.ratio ? `aspect-ratio:${parseImageRatio(asString(props.ratio))};` : null,\n });\n const safeSrc = sanitiseImageSrc(props.src);\n if (safeSrc) {\n wrapper.append(el(\"img\", {\n src: safeSrc,\n alt: asString(props.alt),\n loading: \"lazy\",\n }));\n } else {\n // Rendering a broken/hostile src is worse than rendering nothing —\n // keep the layout slot but skip the network request.\n const placeholder = el(\"div\", {\n class: \"rui-image-placeholder\",\n role: \"presentation\",\n \"aria-hidden\": \"true\",\n });\n const fallback = asString(props.fallback);\n if (fallback) {\n const iconNode = renderIcon(fallback, { className: \"rui-image-fallback-icon\" });\n if (iconNode) placeholder.append(iconNode);\n else placeholder.append(el(\"span\", { class: \"rui-image-fallback-text\" }, [fallback]));\n }\n wrapper.append(placeholder);\n }\n const cap = asString(props.caption);\n if (cap) wrapper.append(el(\"figcaption\", { class: \"rui-image-caption\" }, [cap]));\n return wrapper;\n },\n};\n\nfunction parseImageRatio(input: string): string {\n if (!input) return \"auto\";\n if (input.includes(\":\")) {\n const [w, h] = input.split(\":\");\n const num = Number(w);\n const den = Number(h);\n if (Number.isFinite(num) && Number.isFinite(den) && den > 0) return `${num} / ${den}`;\n }\n const n = Number(input);\n return Number.isFinite(n) && n > 0 ? `${n} / 1` : \"auto\";\n}\n\nconst BADGE_VARIANTS = [\"neutral\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] as const;\n\nexport const Badge: ComponentSpec = {\n name: \"Badge\",\n description:\n \"Small pill-style tag for status, counts, categories. Accepts an \" +\n \"optional leading `icon` and a `size`.\",\n props: [\n { name: \"label\", type: \"string\", positional: true },\n { name: \"tone\", type: \"string\", optional: true, enum: BADGE_VARIANTS, aliases: [\"variant\"], description: \"Visual tone\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name (e.g. \\\"star\\\")\" },\n { name: \"size\", type: \"string\", optional: true, enum: SIZE_ENUM },\n ],\n render: (_node, props) => {\n const variant = asString(props.tone, \"neutral\");\n const size = normaliseSize(props.size, \"md\");\n const root = el(\"span\", {\n class: \"rui-badge\",\n \"data-variant\": variant,\n \"data-size\": size,\n });\n const iconNode = renderIcon(props.icon, { className: \"rui-badge-icon\" });\n if (iconNode) root.append(iconNode);\n const label = asString(props.label);\n if (label) root.append(el(\"span\", { class: \"rui-badge-label\" }, [label]));\n return root;\n },\n};\n\n/**\n * `BadgeList` renders an array of string labels as a row of Badge pills.\n * Replaces the legacy `TagBlock` component.\n */\nexport const BadgeList: ComponentSpec = {\n name: \"BadgeList\",\n description: \"Cluster of Badge pills rendered from an array of strings.\",\n props: [\n { name: \"labels\", type: \"string[]\", positional: true, description: \"Array of badge labels\" },\n { name: \"tone\", type: \"string\", optional: true, enum: BADGE_VARIANTS, aliases: [\"variant\"] },\n { name: \"size\", type: \"string\", optional: true, enum: SIZE_ENUM },\n ],\n render: (_node, props) => {\n const variant = asString(props.tone, \"neutral\");\n const size = normaliseSize(props.size, \"md\");\n const root = el(\"div\", { class: \"rui-badge-list\" });\n for (const raw of asArray(props.labels)) {\n const label = asString(raw);\n if (!label) continue;\n const pill = el(\"span\", {\n class: \"rui-badge\",\n \"data-variant\": variant,\n \"data-size\": size,\n });\n pill.append(el(\"span\", { class: \"rui-badge-label\" }, [label]));\n root.append(pill);\n }\n return root;\n },\n};\n\nconst CALLOUT_VARIANTS = [\"neutral\", \"info\", \"success\", \"warning\", \"danger\", \"error\"] as const;\n\nexport const Callout: ComponentSpec = {\n name: \"Callout\",\n description:\n \"Highlighted callout banner with variant, title, description, and \" +\n \"leading icon. Pass `compact: true` for a one-line inline-note rendering.\",\n props: [\n { name: \"tone\", type: \"string\", optional: true, enum: CALLOUT_VARIANTS, aliases: [\"variant\"] },\n { name: \"title\", type: \"string\", positional: true, required: true },\n { name: \"description\", type: \"string\", optional: true, aliases: [\"text\"], description: \"Body text\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name\" },\n { name: \"compact\", type: \"boolean\", optional: true, description: \"Render with the dense, one-line note shape.\" },\n ],\n render: (_node, props) => {\n const variant = asString(props.tone, \"info\");\n const compact = asBoolean(props.compact);\n const root = el(\"div\", {\n class: \"rui-callout\",\n \"data-variant\": variant,\n \"data-compact\": compact ? \"true\" : \"false\",\n });\n const iconName = asString(props.icon) || defaultCalloutIcon(variant);\n const iconNode = renderIcon(iconName, { className: \"rui-callout-icon\" });\n if (iconNode) root.append(iconNode);\n const body = el(\"div\", { class: \"rui-callout-body\" });\n body.append(el(\"div\", { class: \"rui-callout-title\" }, [asString(props.title)]));\n const desc = asString(props.description);\n if (desc) body.append(el(\"div\", { class: \"rui-callout-description\" }, [desc]));\n root.append(body);\n return root;\n },\n};\n\nexport const CodeBlock: ComponentSpec = {\n name: \"CodeBlock\",\n description:\n \"Read-only code block with a language label and a copy-to-clipboard \" +\n \"button. Pass `showLineNumbers=true` to render a gutter; `highlightLines` \" +\n \"accepts a string like `\\\"3-5,8\\\"` to emphasise specific lines.\",\n props: [\n { name: \"language\", type: \"string\", optional: true, description: \"Display label (e.g. ts, bash)\" },\n { name: \"codeString\", type: \"string\", positional: true, required: true, aliases: [\"code\"], description: \"Raw source text\" },\n { name: \"showLineNumbers\", type: \"boolean\", optional: true, description: \"Render a left-side line-number gutter\" },\n { name: \"highlightLines\", type: \"string\", optional: true, aliases: [\"highlight\"], description: \"Highlight ranges, e.g. \\\"3-5,8\\\"\" },\n { name: \"copy\", type: \"boolean\", optional: true, description: \"Show the copy-to-clipboard button (default true)\" },\n ],\n render: (_node, props) => {\n const language = asString(props.language);\n const code = asString(props.codeString);\n const showLineNumbers = asBoolean(props.showLineNumbers);\n const highlights = parseLineRanges(asString(props.highlightLines));\n const showCopy = props.copy === undefined ? true : asBoolean(props.copy);\n const root = el(\"div\", { class: \"rui-code-block\" });\n\n if (language || showCopy) {\n const head = el(\"div\", { class: \"rui-code-block-head\" });\n if (language) head.append(el(\"span\", { class: \"rui-code-block-language\" }, [language]));\n if (showCopy) {\n const copyBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-code-block-copy\",\n \"aria-label\": \"Copy code\",\n title: \"Copy\",\n });\n const copyIcon = renderIcon(\"copy\", { className: \"rui-code-block-copy-icon\" });\n if (copyIcon) copyBtn.append(copyIcon);\n copyBtn.append(el(\"span\", { class: \"rui-code-block-copy-label\" }, [\"Copy\"]));\n copyBtn.onclick = (event) => {\n const origin = (event.currentTarget ?? event.target) as HTMLButtonElement;\n // Resolve the live code from the on-page DOM so this still works\n // after the morph reconciler keeps the previous element.\n const live = origin.closest(\".rui-code-block\")?.querySelector(\"code\");\n const text = live?.textContent ?? code;\n const nav = (typeof navigator !== \"undefined\") ? navigator as Navigator & { clipboard?: { writeText?: (t: string) => Promise<void> } } : null;\n const clipboard = nav?.clipboard;\n if (clipboard?.writeText) {\n clipboard.writeText(text).catch(() => { /* user denied / non-secure */ });\n }\n const label = origin.querySelector(\".rui-code-block-copy-label\");\n if (label) {\n const original = label.textContent ?? \"Copy\";\n label.textContent = \"Copied\";\n setTimeout(() => { label.textContent = original; }, 1500);\n }\n };\n head.append(copyBtn);\n }\n root.append(head);\n }\n\n const pre = el(\"pre\", { class: \"rui-code-block-pre\", \"data-line-numbers\": showLineNumbers ? \"true\" : \"false\" });\n if (showLineNumbers || highlights.size > 0) {\n const lines = code.split(/\\r?\\n/);\n const codeEl = el(\"code\", {});\n lines.forEach((lineText, idx) => {\n const lineNumber = idx + 1;\n const line = el(\"span\", {\n class: \"rui-code-block-line\",\n \"data-line\": String(lineNumber),\n \"data-highlight\": highlights.has(lineNumber) ? \"true\" : null,\n });\n if (showLineNumbers) {\n line.append(el(\"span\", { class: \"rui-code-block-gutter\" }, [String(lineNumber)]));\n }\n line.append(el(\"span\", { class: \"rui-code-block-code\" }, [lineText]));\n codeEl.append(line);\n });\n pre.append(codeEl);\n } else {\n pre.append(el(\"code\", {}, [code]));\n }\n root.append(pre);\n return root;\n },\n};\n\nfunction parseLineRanges(input: string): Set<number> {\n const out = new Set<number>();\n if (!input) return out;\n for (const segment of input.split(\",\")) {\n const trimmed = segment.trim();\n if (!trimmed) continue;\n if (trimmed.includes(\"-\")) {\n const parts = trimmed.split(\"-\").map((s) => Number(s.trim()));\n const a = parts[0] ?? NaN;\n const b = parts[1] ?? NaN;\n if (Number.isFinite(a) && Number.isFinite(b) && a <= b) {\n for (let i = a; i <= b; i += 1) out.add(i);\n }\n } else {\n const n = Number(trimmed);\n if (Number.isFinite(n)) out.add(n);\n }\n }\n return out;\n}\n\nfunction defaultCalloutIcon(variant: string): string {\n switch (variant) {\n case \"success\": return \"circle-check\";\n case \"warning\": return \"triangle-exclamation\";\n case \"danger\":\n case \"error\": return \"circle-xmark\";\n case \"info\": return \"circle-info\";\n default: return \"circle-info\";\n }\n}\n\nconst SKELETON_VARIANTS = [\"paragraph\", \"card\", \"table-row\", \"avatar\", \"image\"] as const;\nconst SKELETON_SHAPES = [\"rect\", \"circle\"] as const;\n\nexport const Skeleton: ComponentSpec = {\n name: \"Skeleton\",\n description:\n \"Loading placeholder. Pass a `variant` for common shapes — `paragraph` \" +\n \"(default), `card`, `table-row`, `avatar`, `image` — or use `shape` / \" +\n \"`width` / `height` to build a custom one. All variants use a shimmer \" +\n \"animation that respects `prefers-reduced-motion`.\",\n props: [\n { name: \"variant\", type: \"string\", optional: true, enum: SKELETON_VARIANTS },\n { name: \"lines\", type: \"number\", optional: true, aliases: [\"count\"], description: \"Lines for the `paragraph` variant (default 3)\" },\n { name: \"height\", type: \"number | string\", optional: true, description: \"Line height in px (paragraph) or CSS height for custom shape\" },\n { name: \"shape\", type: \"string\", optional: true, enum: SKELETON_SHAPES, description: \"Force a primitive shape (rect/circle)\" },\n { name: \"width\", type: \"string\", optional: true, description: \"CSS width for shape-only skeletons\" },\n ],\n render: (_node, props) => {\n const variant = asString(props.variant);\n const shape = asString(props.shape);\n if (shape) return renderShapeSkeleton(shape, props);\n if (variant && variant !== \"paragraph\") return renderVariantSkeleton(variant, props);\n\n const rawLines = Number(props.lines);\n const lines = Math.max(1, Math.min(50, Number.isFinite(rawLines) ? Math.floor(rawLines) : 3));\n const rawHeight = Number(props.height);\n const lineHeight = Number.isFinite(rawHeight) && rawHeight > 0 ? Math.min(200, Math.floor(rawHeight)) : 12;\n const root = el(\"div\", { class: \"rui-skeleton\", \"data-variant\": \"paragraph\" });\n for (let i = 0; i < lines; i += 1) {\n root.append(el(\"div\", { class: \"rui-skeleton-line\", style: `height:${lineHeight}px` }));\n }\n return root;\n },\n};\n\nfunction renderShapeSkeleton(shape: string, props: Record<string, unknown>): HTMLElement {\n const width = sanitiseCssLength(asString(props.width), \"100%\");\n const heightInput = asString(props.height);\n const height = heightInput\n ? sanitiseCssLength(heightInput, \"16px\")\n : (shape === \"circle\" ? width : \"16px\");\n return el(\"div\", {\n class: \"rui-skeleton\",\n \"data-variant\": \"shape\",\n \"data-shape\": shape === \"circle\" ? \"circle\" : \"rect\",\n style: `width:${width};height:${height};`,\n });\n}\n\nfunction renderVariantSkeleton(variant: string, props: Record<string, unknown>): HTMLElement {\n const root = el(\"div\", { class: \"rui-skeleton\", \"data-variant\": variant });\n switch (variant) {\n case \"avatar\": {\n const size = sanitiseCssLength(asString(props.width), \"40px\");\n root.append(el(\"div\", {\n class: \"rui-skeleton-shape\",\n \"data-shape\": \"circle\",\n style: `width:${size};height:${size};`,\n }));\n return root;\n }\n case \"image\": {\n const width = sanitiseCssLength(asString(props.width), \"100%\");\n const height = sanitiseCssLength(asString(props.height), \"160px\");\n root.append(el(\"div\", {\n class: \"rui-skeleton-shape\",\n \"data-shape\": \"rect\",\n style: `width:${width};height:${height};`,\n }));\n return root;\n }\n case \"card\": {\n root.append(el(\"div\", { class: \"rui-skeleton-shape\", \"data-shape\": \"rect\", style: \"width:100%;height:120px;\" }));\n root.append(el(\"div\", { class: \"rui-skeleton-line\", style: \"height:14px;width:70%;\" }));\n root.append(el(\"div\", { class: \"rui-skeleton-line\", style: \"height:12px;width:90%;\" }));\n root.append(el(\"div\", { class: \"rui-skeleton-line\", style: \"height:12px;width:60%;\" }));\n return root;\n }\n case \"table-row\": {\n const cells = Math.max(1, Math.min(8, Math.floor(Number(props.lines ?? 4))));\n const row = el(\"div\", { class: \"rui-skeleton-row\" });\n for (let i = 0; i < cells; i += 1) {\n row.append(el(\"div\", { class: \"rui-skeleton-line\", style: \"height:12px;flex:1;\" }));\n }\n root.append(row);\n return root;\n }\n default:\n return root;\n }\n}\n\nexport const Markdown: ComponentSpec = {\n name: \"Markdown\",\n description:\n \"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, \" +\n \"headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and \" +\n \"numbered (`1.`) lists, fenced code blocks (```), images \" +\n \"(`![alt](src)`), inline links, and auto-linked bare URLs. Multi-line \" +\n \"paragraphs collapse into `<p>` blocks.\",\n props: [{ name: \"content\", type: \"string\" }],\n render: (_node, props) => {\n const value = asString(props.content);\n const html = renderMarkdown(value);\n return el(\"div\", { class: \"rui-markdown\", html });\n },\n};\n\nexport const Container: ComponentSpec = {\n name: \"Container\",\n description:\n \"Centered, max-width content wrapper. Use when a page is wider than \" +\n \"comfortable reading width — landing pages, marketing sections, long \" +\n \"documents. Picks a sensible default max-width per size; pass \" +\n \"`maxWidth` to override with any CSS value.\",\n props: [\n { name: \"children\", type: \"Node[]\" },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\", \"xl\", \"full\"], description: \"sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)\" },\n { name: \"maxWidth\", type: \"string\", optional: true, description: \"Custom CSS max-width (overrides `size`)\" },\n { name: \"padding\", type: \"string\", optional: true, enum: [\"none\", \"s\", \"m\", \"l\"], description: \"Horizontal padding (default m)\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-container\",\n \"data-size\": asString(props.size, \"lg\"),\n \"data-padding\": asString(props.padding, \"m\"),\n style: props.maxWidth ? `max-width:${sanitiseCssLength(props.maxWidth, \"auto\")};` : null,\n });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const Spacer: ComponentSpec = {\n name: \"Spacer\",\n description:\n \"Explicit space element for fine layout control. By default acts as a \" +\n \"flex spacer that pushes following content to the far edge (use \" +\n \"inside `Stack(direction=\\\"row\\\")`). Pass `size` to render a fixed \" +\n \"vertical/horizontal gap instead.\",\n props: [\n { name: \"size\", type: \"string\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"], description: \"Fixed gap; omit to flex-grow\" },\n { name: \"flex\", type: \"boolean\", optional: true, description: \"Flex-grow even when size is set (default true when size omitted)\" },\n ],\n render: (_node, props) => {\n const size = asString(props.size);\n const flex = props.flex === undefined ? !size : asBoolean(props.flex);\n return el(\"span\", {\n class: \"rui-spacer\",\n \"data-size\": size || null,\n \"data-flex\": flex ? \"true\" : \"false\",\n \"aria-hidden\": \"true\",\n });\n },\n};\n\nexport const Spinner: ComponentSpec = {\n name: \"Spinner\",\n description:\n \"Indeterminate inline loader. Use for tiny loading states inside \" +\n \"buttons, toolbars, table cells, or chat bubbles where `Skeleton` \" +\n \"and `Progress(indeterminate=true)` are too heavy. Pass `label` to \" +\n \"render an inline caption beside the spinner (also announced via \" +\n \"`aria-label`).\",\n props: [\n { name: \"size\", type: \"string\", optional: true, enum: SIZE_ENUM, description: \"Default `md`\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Caption rendered beside the spinner (also announced)\" },\n { name: \"tone\", type: \"string\", optional: true, enum: TONE_ENUM, description: \"Visual accent (default `primary`)\" },\n ],\n render: (_node, props) => {\n const size = normaliseSize(props.size, \"md\");\n const tone = asString(props.tone, \"primary\");\n const label = asString(props.label);\n const root = el(\"span\", {\n class: \"rui-spinner\",\n \"data-size\": size,\n \"data-tone\": tone,\n role: \"status\",\n \"aria-live\": \"polite\",\n \"aria-label\": label || \"Loading\",\n });\n root.append(el(\"span\", { class: \"rui-spinner-ring\", \"aria-hidden\": \"true\" }));\n if (label) root.append(el(\"span\", { class: \"rui-spinner-label\" }, [label]));\n return root;\n },\n};\n\nexport const Quote: ComponentSpec = {\n name: \"Quote\",\n description:\n \"Inline pull-quote with optional citation. Lighter than `Testimonial` \" +\n \"— use inside articles, blog posts, marketing sections, or anywhere \" +\n \"you need to highlight a sentence without the full quote/author/role \" +\n \"+ rating shape.\",\n props: [\n { name: \"text\", type: \"string\" },\n { name: \"cite\", type: \"string\", optional: true, aliases: [\"attribution\", \"author\"], description: \"Attribution text shown below the quote\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"default\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n ],\n render: (_node, props) => {\n const root = el(\"figure\", {\n class: \"rui-quote\",\n \"data-tone\": asString(props.tone, \"default\"),\n });\n root.append(el(\"blockquote\", { class: \"rui-quote-text\" }, [asString(props.text)]));\n const cite = asString(props.cite);\n if (cite) root.append(el(\"figcaption\", { class: \"rui-quote-cite\" }, [cite]));\n return root;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * Markdown renderer\n *\n * Hand-rolled because we ship inside a Shadow DOM with no peer deps. The\n * parser handles:\n *\n * - Headings (#, ##, ###)\n * - Blockquotes (>)\n * - Fenced code blocks (```lang)\n * - Bullet lists (`-` / `*`) and numbered lists (`1.`)\n * - Inline **bold**, *italic*, `code`\n * - Links `[label](href)` (sanitised) and images `![alt](src)` (sanitised)\n * - Auto-linked bare HTTP/HTTPS URLs\n *\n * All HTML output is escape-encoded so an LLM cannot smuggle raw markup\n * past the parser.\n * ------------------------------------------------------------------------ */\nfunction renderMarkdown(value: string): string {\n const escape = (s: string) =>\n s.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n const lines = value.split(/\\r?\\n/);\n const out: string[] = [];\n\n // List / quote state so we can close them on a context change.\n let listMode: \"ul\" | \"ol\" | null = null;\n let inQuote = false;\n let inCode = false;\n let codeLang = \"\";\n let codeBuf: string[] = [];\n\n const closeList = () => {\n if (listMode) {\n out.push(listMode === \"ul\" ? \"</ul>\" : \"</ol>\");\n listMode = null;\n }\n };\n const closeQuote = () => {\n if (inQuote) { out.push(\"</blockquote>\"); inQuote = false; }\n };\n const flushCode = () => {\n const lang = codeLang ? ` data-language=\"${escape(codeLang)}\"` : \"\";\n out.push(`<pre class=\"rui-markdown-code\"${lang}><code>${escape(codeBuf.join(\"\\n\"))}</code></pre>`);\n codeBuf = [];\n codeLang = \"\";\n inCode = false;\n };\n\n for (const rawLine of lines) {\n // Fenced code blocks must be detected before any inline transform so\n // their content is preserved verbatim (no `**bold**` interpretation).\n const fenceMatch = /^```\\s*(.*)$/.exec(rawLine.trim());\n if (inCode) {\n if (fenceMatch) {\n flushCode();\n continue;\n }\n codeBuf.push(rawLine);\n continue;\n }\n if (fenceMatch) {\n closeList(); closeQuote();\n inCode = true;\n codeLang = fenceMatch[1] ?? \"\";\n continue;\n }\n\n const heading = /^\\s*(#{1,3})\\s+(.+)$/.exec(rawLine);\n if (heading) {\n closeList(); closeQuote();\n const level = heading[1]!.length;\n out.push(`<h${level} class=\"rui-markdown-h${level}\">${inline(escape(heading[2]!))}</h${level}>`);\n continue;\n }\n\n const quoteMatch = /^\\s*>\\s?(.*)$/.exec(rawLine);\n if (quoteMatch) {\n closeList();\n if (!inQuote) { out.push(\"<blockquote class=\\\"rui-markdown-quote\\\">\"); inQuote = true; }\n out.push(`<p>${inline(escape(quoteMatch[1] ?? \"\"))}</p>`);\n continue;\n } else if (inQuote && rawLine.trim() !== \"\") {\n // Non-empty non-quote line ends a quote block.\n closeQuote();\n }\n\n const ulMatch = /^\\s*[-*]\\s+(.*)$/.exec(rawLine);\n if (ulMatch) {\n closeQuote();\n if (listMode !== \"ul\") { closeList(); out.push(\"<ul>\"); listMode = \"ul\"; }\n out.push(`<li>${inline(escape(ulMatch[1] ?? \"\"))}</li>`);\n continue;\n }\n\n const olMatch = /^\\s*\\d+\\.\\s+(.*)$/.exec(rawLine);\n if (olMatch) {\n closeQuote();\n if (listMode !== \"ol\") { closeList(); out.push(\"<ol>\"); listMode = \"ol\"; }\n out.push(`<li>${inline(escape(olMatch[1] ?? \"\"))}</li>`);\n continue;\n }\n\n if (rawLine.trim() === \"\") {\n closeList(); closeQuote();\n continue;\n }\n\n closeList(); closeQuote();\n out.push(`<p>${inline(escape(rawLine))}</p>`);\n }\n\n if (inCode) flushCode();\n closeList();\n closeQuote();\n return out.join(\"\");\n\n function inline(s: string): string {\n let result = s\n // Images first so the ![alt](src) regex does not match inside link labels.\n .replace(/!\\[([^\\]]*)\\]\\(([^)]+)\\)/g, (_match, alt: string, rawSrc: string) => {\n const src = sanitiseImageSrc(rawSrc);\n if (!src) return `<span class=\"rui-markdown-image-fallback\">${alt}</span>`;\n return `<img class=\"rui-markdown-image\" src=\"${escapeAttr(src)}\" alt=\"${alt}\" loading=\"lazy\">`;\n })\n // Inline code — careful not to match across line boundaries.\n .replace(/`([^`]+)`/g, \"<code>$1</code>\")\n .replace(/\\*\\*([^*]+)\\*\\*/g, \"<strong>$1</strong>\")\n .replace(/\\*([^*]+)\\*/g, \"<em>$1</em>\")\n .replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, (_match, label: string, rawHref: string) => {\n const href = sanitizeMarkdownHref(rawHref);\n return `<a class=\"rui-link\" href=\"${href}\" target=\"_blank\" rel=\"noopener noreferrer\">${label}</a>`;\n });\n // Auto-link bare http(s) URLs. We only match URLs that are not already\n // wrapped in an anchor or attribute — heuristic check via a negative\n // lookbehind on `\"` (attribute) or `>` (already inside a tag).\n result = result.replace(\n /(?<![=\"'>])\\bhttps?:\\/\\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\\-]+/g,\n (url) => {\n const safe = sanitizeMarkdownHref(url);\n return `<a class=\"rui-link\" href=\"${safe}\" target=\"_blank\" rel=\"noopener noreferrer\">${url}</a>`;\n },\n );\n return result;\n }\n}\n\n/**\n * Block dangerous URL schemes (`javascript:`, `data:`, `vbscript:`, …) and\n * protocol-relative URLs (`//evil.com/...`) so a tool response embedded\n * inside a Markdown link cannot smuggle script execution or cross-origin\n * navigation into the page. Allow http/https/mailto/tel absolute URLs plus\n * same-origin fragments and root-relative paths.\n */\nfunction sanitizeMarkdownHref(raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) return \"#\";\n // Protocol-relative URLs (`//host/path`) inherit the page's scheme and\n // therefore can navigate to a hostile host. Treat them as unsafe.\n if (trimmed.startsWith(\"//\")) return \"#\";\n // Same-origin fragments / root-relative paths / query-only links are safe.\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"/\") || trimmed.startsWith(\"?\")) {\n return escapeAttr(trimmed);\n }\n const schemeMatch = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(trimmed);\n if (!schemeMatch) return escapeAttr(trimmed);\n const scheme = schemeMatch[1]!.toLowerCase();\n const allowed = new Set([\"http\", \"https\", \"mailto\", \"tel\"]);\n if (!allowed.has(scheme)) return \"#\";\n return escapeAttr(trimmed);\n}\n\nfunction escapeAttr(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n// `asNumber` is re-exported here so consumers that wanted it for the old\n// helper shape keep working without changing imports (kept for clarity).\nexport { asNumber };\n","/**\n * Internal DOM helpers shared by primitives (`feedback.ts`) and pattern\n * composites (`patterns.ts`). Not exported from the package barrel — these\n * are implementation details that keep avatar/initials rendering consistent\n * across every component that needs them.\n */\n\nimport { el, sanitiseImageSrc } from \"../utils.js\";\n\nexport type AvatarSize = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/** Render an `<rui-avatar>` matching the canonical Avatar primitive. */\nexport function renderAvatar(src: string, name: string, size: AvatarSize): HTMLElement {\n const root = el(\"span\", { class: \"rui-avatar\", \"data-size\": size, role: \"img\" });\n // Defensive sanitisation — even though browsers do not execute JS from\n // `img.src`, an unsafe scheme should never land on a network-fetched\n // attribute (some hosts copy the value into other sinks).\n const safeSrc = sanitiseImageSrc(src);\n if (safeSrc) {\n const img = el(\"img\", { src: safeSrc, alt: name, loading: \"lazy\" });\n // Resolve the live image from the event so this handler still works\n // after the morph reconciler copies it onto a kept DOM node.\n // (`onerror`'s first argument is typed `Event | string` because the\n // window-level handler also fires from script errors — but for an\n // `<img>` it's always an Event.)\n img.onerror = (event) => {\n const ev = event as Event;\n const live = (ev.currentTarget ?? ev.target) as Element;\n live.replaceWith(el(\"span\", { class: \"rui-avatar-fallback\" }, [initialsFor(name)]));\n };\n root.append(img);\n } else {\n root.append(el(\"span\", { class: \"rui-avatar-fallback\" }, [initialsFor(name)]));\n }\n return root;\n}\n\n/** Two-letter initials, falling back to `?` for empty input. */\nexport function initialsFor(name: string): string {\n const trimmed = name.trim();\n if (!trimmed) return \"?\";\n const parts = trimmed.split(/\\s+/).slice(0, 2);\n return parts.map((p) => p.charAt(0).toUpperCase()).join(\"\") || trimmed.charAt(0).toUpperCase();\n}\n\n/**\n * Shared outside-click + Escape dismissal for popovers, dropdowns, comboboxes.\n *\n * Previous implementations leaked listeners in three subtle ways:\n *\n * 1. Re-opening the floater (trigger clicked while still open) installed a\n * second listener pair without removing the first.\n * 2. Closing via any code path *other than* an outside-click / Escape (e.g.\n * clicking the trigger again, selecting an item, programmatic close)\n * left the listeners attached, holding references to detached DOM.\n * 3. The host node being removed from the DOM (LLM produced a new response,\n * route changed, parent re-rendered) silently kept the listeners on the\n * shadow root forever.\n *\n * This helper installs listeners exactly once per open, exposes a single\n * `dispose()` so every close path can clean up, and observes the host so we\n * auto-dispose when the floater is unmounted.\n *\n * `key` lets the caller dedupe re-opens — if the same `key` is passed while\n * a previous registration is still live, we dispose it before installing\n * the new one.\n */\nexport interface DismissHandle {\n dispose: () => void;\n}\n\ninterface DismissOptions {\n liveRoot: HTMLElement;\n onDismiss: () => void;\n /** Stable per-instance identifier, used to deduplicate re-opens. */\n key?: string;\n}\n\nconst DISMISS_REGISTRY: WeakMap<HTMLElement, DismissHandle> = new WeakMap();\n\nexport function installDismissListeners(opts: DismissOptions): DismissHandle {\n const { liveRoot, onDismiss } = opts;\n const existing = DISMISS_REGISTRY.get(liveRoot);\n if (existing) existing.dispose();\n\n const host = liveRoot.getRootNode() as Document | ShadowRoot;\n let disposed = false;\n\n const onOutside = (event: Event): void => {\n const target = event.target as Element | null;\n if (target && liveRoot.contains(target)) return;\n handle.dispose();\n onDismiss();\n };\n const onKey = (event: Event): void => {\n if ((event as KeyboardEvent).key !== \"Escape\") return;\n handle.dispose();\n onDismiss();\n };\n\n // Auto-dispose when the floater is removed from the DOM so we never keep\n // listeners alive against a detached subtree.\n const ownerDoc = liveRoot.ownerDocument;\n let observer: MutationObserver | null = null;\n if (ownerDoc && typeof MutationObserver !== \"undefined\") {\n observer = new MutationObserver(() => {\n if (!liveRoot.isConnected) handle.dispose();\n });\n const observeRoot = liveRoot.getRootNode();\n if (observeRoot instanceof Element || observeRoot instanceof Document || observeRoot instanceof ShadowRoot) {\n observer.observe(observeRoot, { childList: true, subtree: true });\n }\n }\n\n const handle: DismissHandle = {\n dispose: () => {\n if (disposed) return;\n disposed = true;\n host.removeEventListener(\"click\", onOutside, true);\n host.removeEventListener(\"keydown\", onKey, true);\n observer?.disconnect();\n DISMISS_REGISTRY.delete(liveRoot);\n },\n };\n\n // Defer attachment so the same click that opened the floater does not\n // immediately trip the close handler.\n setTimeout(() => {\n if (disposed) return;\n host.addEventListener(\"click\", onOutside, true);\n host.addEventListener(\"keydown\", onKey, true);\n }, 0);\n\n DISMISS_REGISTRY.set(liveRoot, handle);\n return handle;\n}\n\n/** Trigger an immediate dispose for a live root if one is registered. */\nexport function disposeDismissListeners(liveRoot: HTMLElement | null | undefined): void {\n if (!liveRoot) return;\n const existing = DISMISS_REGISTRY.get(liveRoot);\n if (existing) existing.dispose();\n}\n\n/**\n * Map a free-text label to a sensible Font Awesome icon. Used by\n * \"self-decorating\" defaults — e.g. StatCard auto-pick from label,\n * EmptyState auto-pick from title, Banner auto-pick from tone.\n *\n * Returns `null` when no rule matches so callers can fall back to whatever\n * default they prefer.\n */\nconst ICON_KEYWORD_RULES: Array<{ match: RegExp; icon: string }> = [\n { match: /\\b(revenue|sales|sale|income|payment|charges?|invoices?|billing)\\b/i, icon: \"sack-dollar\" },\n { match: /\\b(profit|earnings?|margin|roi)\\b/i, icon: \"chart-line\" },\n { match: /\\b(customers?|clients?|users?|members?|people|accounts?)\\b/i, icon: \"users\" },\n { match: /\\b(visitors?|sessions?|traffic|page-?views?|impressions?)\\b/i, icon: \"chart-line\" },\n { match: /\\b(orders?|carts?|purchases?|transactions?)\\b/i, icon: \"cart-shopping\" },\n { match: /\\b(products?|inventory|sku|stock|items?)\\b/i, icon: \"box\" },\n { match: /\\b(subscriptions?|plans?|tiers?|pricing)\\b/i, icon: \"credit-card\" },\n { match: /\\b(emails?|messages?|inbox|threads?|mail)\\b/i, icon: \"envelope\" },\n { match: /\\b(notifications?|alerts?|reminders?)\\b/i, icon: \"bell\" },\n { match: /\\b(growth|trend|increase|up)\\b/i, icon: \"arrow-trend-up\" },\n { match: /\\b(decline|drop|down|decrease|loss)\\b/i, icon: \"arrow-trend-down\" },\n { match: /\\b(reports?|analytics|insights?|dashboards?|metrics?|stats?|kpis?)\\b/i, icon: \"chart-pie\" },\n { match: /\\b(charts?|graphs?)\\b/i, icon: \"chart-column\" },\n { match: /\\b(tasks?|todos?|backlog|kanban|sprint)\\b/i, icon: \"list-check\" },\n { match: /\\b(projects?|workspaces?)\\b/i, icon: \"folder-open\" },\n { match: /\\b(files?|folders?|documents?|docs?|attachments?)\\b/i, icon: \"folder-open\" },\n { match: /\\b(images?|photos?|gallery|albums?)\\b/i, icon: \"image\" },\n { match: /\\b(videos?|clips?|recordings?)\\b/i, icon: \"video\" },\n { match: /\\b(audio|music|podcasts?|sounds?)\\b/i, icon: \"music\" },\n { match: /\\b(calendars?|schedule|events?|meetings?|appointments?)\\b/i, icon: \"calendar-days\" },\n { match: /\\b(comments?|replies|feedback|reviews?|ratings?)\\b/i, icon: \"comments\" },\n { match: /\\b(settings?|preferences?|config|configuration|options?)\\b/i, icon: \"gear\" },\n { match: /\\b(security|privacy|password|locks?|secure)\\b/i, icon: \"shield-halved\" },\n { match: /\\b(api|integrations?|webhooks?|connections?)\\b/i, icon: \"plug\" },\n { match: /\\b(database|storage|backups?|servers?)\\b/i, icon: \"database\" },\n { match: /\\b(speed|performance|latency|response\\s?time)\\b/i, icon: \"gauge-high\" },\n { match: /\\b(uptime|availability|status|health)\\b/i, icon: \"heart-pulse\" },\n { match: /\\b(errors?|bugs?|failures?|exceptions?|incidents?)\\b/i, icon: \"circle-exclamation\" },\n { match: /\\b(success|complete|done|approved)\\b/i, icon: \"circle-check\" },\n { match: /\\b(warnings?|caution)\\b/i, icon: \"triangle-exclamation\" },\n { match: /\\b(search|results?|queries)\\b/i, icon: \"magnifying-glass\" },\n { match: /\\b(downloads?|exports?)\\b/i, icon: \"download\" },\n { match: /\\b(uploads?|imports?)\\b/i, icon: \"upload\" },\n { match: /\\b(time|hours?|duration|elapsed)\\b/i, icon: \"clock\" },\n { match: /\\b(locations?|maps?|addresses?|countries?|regions?)\\b/i, icon: \"location-dot\" },\n { match: /\\b(stars?|favourites?|favorites?|highlights?)\\b/i, icon: \"star\" },\n { match: /\\b(trophy|awards?|achievements?|badges?|gold)\\b/i, icon: \"trophy\" },\n { match: /\\b(targets?|goals?|objectives?|quotas?)\\b/i, icon: \"bullseye\" },\n { match: /\\b(teams?|departments?|orgs?|organisations?|organizations?)\\b/i, icon: \"people-group\" },\n { match: /\\b(tickets?|issues?|bugs?|requests?)\\b/i, icon: \"ticket\" },\n { match: /\\b(deploys?|builds?|releases?|versions?)\\b/i, icon: \"rocket\" },\n];\n\nexport function pickIconForLabel(label: string | null | undefined): string | null {\n if (!label) return null;\n for (const rule of ICON_KEYWORD_RULES) {\n if (rule.match.test(label)) return rule.icon;\n }\n return null;\n}\n\n/**\n * Map a tone keyword (`primary`, `success`, `warning`, …) to a sensible\n * default icon, used by Banner / Callout when the LLM omits `icon`.\n */\nconst TONE_ICONS: Record<string, string> = {\n default: \"circle-info\",\n info: \"circle-info\",\n primary: \"bolt\",\n success: \"circle-check\",\n warning: \"triangle-exclamation\",\n danger: \"circle-exclamation\",\n error: \"circle-exclamation\",\n neutral: \"circle-info\",\n};\n\nexport function pickIconForTone(tone: string | null | undefined): string | null {\n if (!tone) return null;\n return TONE_ICONS[tone.toLowerCase()] ?? null;\n}\n\n/**\n * Build a deterministic DiceBear avatar URL for a person name.\n *\n * Used as the fallback when the LLM passes a name but omits `src`.\n * `style` defaults to `initials` which is bulletproof (no network face-art),\n * but callers can pass `shapes`, `avataaars`, etc. for fancier looks.\n */\nexport function dicebearUrlFor(name: string, style: string = \"shapes\"): string {\n const seed = name.trim() || \"anon\";\n const safeStyle = /^[a-z0-9-]+$/i.test(style) ? style : \"shapes\";\n return `https://api.dicebear.com/9.x/${safeStyle}/svg?seed=${encodeURIComponent(seed)}`;\n}\n","/**\n * Shared form helpers used by forms.ts and new-components.ts.\n */\n\nimport { asArray, asString } from \"../utils.js\";\n\nexport function extractComboboxItems(raw: unknown): Array<{ value: string; label: string }> {\n const items = asArray<unknown>(raw);\n return items\n .map((entry) => {\n if (entry && typeof entry === \"object\") {\n const node = entry as { __kind?: string; args?: unknown[]; value?: unknown; label?: unknown };\n if (node.__kind === \"Component\" && Array.isArray(node.args)) {\n const value = asString(node.args[0]);\n return { value, label: asString(node.args[1], value) };\n }\n if (node.value !== undefined || node.label !== undefined) {\n const value = asString(node.value);\n return { value, label: asString(node.label, value) };\n }\n }\n const value = asString(entry);\n return { value, label: value };\n })\n .filter((item) => item.value !== \"\" || item.label !== \"\");\n}\n","/**\n * Behavioural & styling wrappers.\n *\n * These components wrap an arbitrary child component to attach behaviour\n * (click, mouse, keyboard, focus, intersection) or styling (raw CSS class\n * / inline style) without forcing every primitive to grow another prop.\n *\n * Design notes:\n *\n * - Event wrappers (`OnClick`, `OnMouse`, `OnKeyboard`, `OnFocus`) render\n * the child wrapped in a `<span class=\"rui-wrapper\" style=\"display: contents\">`.\n * `display: contents` makes the wrapper transparent in the layout tree\n * so the child renders exactly as if there were no wrapper, while\n * events still bubble up to the wrapper element where listeners live.\n *\n * - `Css` is different — class / style cannot be inherited via\n * `display: contents`. It therefore renders the child first and then\n * merges the supplied `class` / `style` onto the rendered HTMLElement.\n * When the child is a non-element node (text, document fragment) it\n * falls back to a real wrapper `<span>` so the styling has somewhere\n * to attach.\n *\n * - `OnIntersect` is implemented with a `IntersectionObserver` registered\n * for the wrapper, and disposed via `helpers.registerDisposer` when the\n * component leaves the tree. The wrapper uses normal `inline-block`\n * (rather than `display: contents`) because a transparent wrapper is\n * skipped by the intersection observer.\n *\n * Every wrapper accepts the child as the canonical positional argument\n * named `child` (with `children` as an alias) so authors can write either\n * `OnClick(Card(\"Hi\"), { onClick: fn })` or\n * `OnClick({ child: Card(...), onClick: fn })`.\n */\n\nimport type { ComponentSpec, RenderHelpers } from \"../types.js\";\nimport { el, asBoolean, asNumber, asString, sanitiseHref } from \"../utils.js\";\n\n/**\n * Render a child value into a single DOM node. Arrays of children produce\n * a wrapping span (since we can only return one Node). Strings render as\n * text nodes. Nullish values render as an empty text node so the\n * wrapper still has a stable child to attach to.\n */\nfunction renderChildAsNode(helpers: RenderHelpers, child: unknown): Node {\n if (child == null) return document.createTextNode(\"\");\n if (Array.isArray(child)) {\n const wrap = el(\"span\", { class: \"rui-wrapper-fragment\" });\n for (const c of child) {\n if (c == null) continue;\n wrap.append(typeof c === \"string\" ? document.createTextNode(c) : helpers.renderNode(c));\n }\n return wrap;\n }\n if (typeof child === \"string\") return document.createTextNode(child);\n return helpers.renderNode(child);\n}\n\n/**\n * Build a transparent wrapper `<span>` (display: contents) around a\n * rendered child node. The wrapper is the listener anchor — events fire\n * from the child but bubble to the wrapper where the wrapper's listener\n * runs. This keeps the visual tree identical to \"no wrapper\" while still\n * giving us a stable element to attach handlers to.\n */\nfunction transparentWrapper(className: string, extraAttrs?: Record<string, string | null>): HTMLElement {\n return el(\"span\", {\n class: `rui-wrapper ${className}`,\n style: \"display: contents;\",\n ...(extraAttrs ?? {}),\n });\n}\n\n/**\n * Strip characters that could break out of a `style=\"...\"` attribute or\n * smuggle a `javascript:` URL into an inline declaration. Mirrors the\n * filter used by `Text` and `HTMLTag`. Returns the empty string when the\n * value is rejected so callers can drop the attribute.\n */\nfunction sanitiseInlineStyle(input: unknown): string {\n const raw = asString(input).trim();\n if (!raw) return \"\";\n if (/[<>]/.test(raw)) return \"\";\n if (/\\bexpression\\s*\\(|\\bjavascript\\s*:|\\bbehavior\\s*:|@import\\b/i.test(raw)) return \"\";\n return raw;\n}\n\n/**\n * Accept a class string (\"rounded shadow\") or an array ([\"rounded\", \"shadow\"])\n * and return the safe set of class tokens. Anything that does not match a\n * conservative CSS-identifier shape is dropped so authors cannot smuggle\n * attribute-breaking characters into the rendered class list.\n */\nconst CLASS_TOKEN_RE = /^[A-Za-z_][A-Za-z0-9_\\-:/]*$/;\n\nfunction sanitiseClassList(input: unknown): string[] {\n const tokens = Array.isArray(input)\n ? input.map((value) => asString(value))\n : asString(input).split(/\\s+/);\n return tokens\n .map((token) => token.trim())\n .filter((token) => token.length > 0 && token.length <= 64 && CLASS_TOKEN_RE.test(token));\n}\n\n/* ------------------------------------------------------------------------ *\n * OnClick — single click / tap wrapper.\n *\n * Browsers fire a synthetic `click` event for taps on touch devices, so\n * registering a single `click` listener covers both interaction models.\n * We attach to the wrapper element (transparent via `display: contents`)\n * and stop event propagation at the wrapper so OnClick wrappers can be\n * safely nested without one outer wrapper swallowing inner clicks.\n * ------------------------------------------------------------------------ */\nexport const OnClick: ComponentSpec = {\n name: \"OnClick\",\n description:\n \"Make any component clickable. Wraps the child in a transparent \" +\n \"span and dispatches `onClick(event)` when the user clicks or taps \" +\n \"anywhere inside it. Use to attach click behaviour to components \" +\n \"that do not expose an `action` / `onClick` prop (cards, list rows, \" +\n \"media tiles, custom layouts).\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"], description: \"Component (or array of components) to wrap\" },\n { name: \"onClick\", type: \"callable\", required: true, aliases: [\"action\", \"onclick\"], description: \"Callable invoked on click / tap. Receives the native MouseEvent.\" },\n { name: \"disabled\", type: \"boolean\", optional: true, description: \"Skip firing the handler while truthy\" },\n { name: \"stopPropagation\", type: \"boolean\", optional: true, description: \"Call event.stopPropagation() after invoking the handler (default false)\" },\n ],\n render: (_node, props, helpers) => {\n const wrapper = transparentWrapper(\"rui-on-click\", { role: \"button\", tabindex: \"0\" });\n wrapper.append(renderChildAsNode(helpers, props.child));\n const disabled = asBoolean(props.disabled);\n const stopProp = asBoolean(props.stopPropagation);\n const handle = (event: Event) => {\n if (disabled) return;\n if (stopProp) event.stopPropagation();\n helpers.invoke(props.onClick, event);\n };\n wrapper.addEventListener(\"click\", handle);\n // Keyboard accessibility: Enter / Space activate the wrapper too.\n wrapper.addEventListener(\"keydown\", (event) => {\n const e = event as KeyboardEvent;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handle(e);\n }\n });\n return wrapper;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * OnMouse — every mouse / pointer event in one wrapper.\n *\n * Each event prop is optional. We only attach listeners for props the\n * caller actually supplied so unused events do not pay any cost — no\n * extra event handlers, no extra capture-phase listeners.\n *\n * Aliases (`hover` → `mouseover`) match the names common in CSS / web\n * docs so the LLM can pick whichever name they remember.\n * ------------------------------------------------------------------------ */\n\n/**\n * Mapping from the prop name authors use → the native DOM event name\n * the listener should subscribe to. Ordered so the table stays readable.\n */\nconst MOUSE_EVENT_MAP: ReadonlyArray<{ prop: string; event: string }> = [\n { prop: \"enter\", event: \"mouseenter\" },\n { prop: \"leave\", event: \"mouseleave\" },\n { prop: \"hover\", event: \"mouseover\" },\n { prop: \"move\", event: \"mousemove\" },\n { prop: \"down\", event: \"mousedown\" },\n { prop: \"up\", event: \"mouseup\" },\n { prop: \"click\", event: \"click\" },\n { prop: \"doubleClick\", event: \"dblclick\" },\n { prop: \"contextMenu\", event: \"contextmenu\" },\n { prop: \"scroll\", event: \"scroll\" },\n { prop: \"wheel\", event: \"wheel\" },\n { prop: \"drag\", event: \"drag\" },\n { prop: \"drop\", event: \"drop\" },\n { prop: \"dragStart\", event: \"dragstart\" },\n { prop: \"dragEnd\", event: \"dragend\" },\n { prop: \"dragEnter\", event: \"dragenter\" },\n { prop: \"dragLeave\", event: \"dragleave\" },\n { prop: \"dragOver\", event: \"dragover\" },\n];\n\nexport const OnMouse: ComponentSpec = {\n name: \"OnMouse\",\n description:\n \"Attach any combination of mouse / pointer / drag listeners to a \" +\n \"component. Pass only the props you need — unused events install no \" +\n \"listener so the wrapper is essentially free. Each handler receives \" +\n \"the native MouseEvent / DragEvent / WheelEvent. Use for hover \" +\n \"tracking, custom drag-and-drop, context menus, scroll-aware UIs.\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"], description: \"Component to wrap\" },\n { name: \"enter\", type: \"callable\", optional: true, description: \"Fired when the pointer enters the element (mouseenter)\" },\n { name: \"leave\", type: \"callable\", optional: true, description: \"Fired when the pointer leaves the element (mouseleave)\" },\n { name: \"hover\", type: \"callable\", optional: true, description: \"Fired on every mouseover inside the element\" },\n { name: \"move\", type: \"callable\", optional: true, description: \"Fired on every mousemove inside the element\" },\n { name: \"down\", type: \"callable\", optional: true, description: \"Fired on mousedown\" },\n { name: \"up\", type: \"callable\", optional: true, description: \"Fired on mouseup\" },\n { name: \"click\", type: \"callable\", optional: true, description: \"Fired on click / tap\" },\n { name: \"doubleClick\", type: \"callable\", optional: true, description: \"Fired on double-click\" },\n { name: \"contextMenu\", type: \"callable\", optional: true, description: \"Fired on right-click (contextmenu)\" },\n { name: \"scroll\", type: \"callable\", optional: true, description: \"Fired when an inner element scrolls\" },\n { name: \"wheel\", type: \"callable\", optional: true, description: \"Fired on mouse-wheel / trackpad scroll\" },\n { name: \"drag\", type: \"callable\", optional: true, description: \"Fired while the element is being dragged\" },\n { name: \"drop\", type: \"callable\", optional: true, description: \"Fired when something is dropped onto the element\" },\n { name: \"dragStart\", type: \"callable\", optional: true, description: \"Fired when a drag begins\" },\n { name: \"dragEnd\", type: \"callable\", optional: true, description: \"Fired when a drag ends\" },\n { name: \"dragEnter\", type: \"callable\", optional: true, description: \"Fired when a drag enters the element\" },\n { name: \"dragLeave\", type: \"callable\", optional: true, description: \"Fired when a drag leaves the element\" },\n { name: \"dragOver\", type: \"callable\", optional: true, description: \"Fired while something is dragged over the element. Call `event.preventDefault()` to make the element a valid drop target.\" },\n { name: \"draggable\", type: \"boolean\", optional: true, description: \"Make the wrapper itself draggable (sets `draggable=\\\"true\\\"`)\" },\n { name: \"passiveScroll\", type: \"boolean\", optional: true, description: \"Register scroll/wheel listeners as passive (default true for better scroll performance)\" },\n ],\n render: (_node, props, helpers) => {\n const wrapper = transparentWrapper(\"rui-on-mouse\");\n if (asBoolean(props.draggable)) wrapper.setAttribute(\"draggable\", \"true\");\n wrapper.append(renderChildAsNode(helpers, props.child));\n const passive = props.passiveScroll === undefined ? true : asBoolean(props.passiveScroll);\n for (const { prop, event } of MOUSE_EVENT_MAP) {\n const handler = (props as Record<string, unknown>)[prop];\n if (handler == null) continue;\n const isScrollEvent = event === \"scroll\" || event === \"wheel\";\n const options: AddEventListenerOptions = isScrollEvent ? { passive } : {};\n wrapper.addEventListener(event, (ev) => {\n helpers.invoke(handler, ev);\n }, options);\n }\n return wrapper;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * OnKeyboard — keyboard event wrapper.\n *\n * The wrapper gets `tabindex=\"0\"` so it can receive keyboard focus by\n * default; pass `focusable=false` to opt out (useful when the child is\n * already focusable like an input).\n * ------------------------------------------------------------------------ */\nconst KEYBOARD_EVENT_MAP: ReadonlyArray<{ prop: string; event: string }> = [\n { prop: \"onKeyDown\", event: \"keydown\" },\n { prop: \"onKeyUp\", event: \"keyup\" },\n { prop: \"onKeyPress\", event: \"keypress\" },\n];\n\nexport const OnKeyboard: ComponentSpec = {\n name: \"OnKeyboard\",\n description:\n \"Attach keyboard listeners to a component. Pass any combination of \" +\n \"`onKeyDown`, `onKeyUp`, and `onKeyPress`; each handler receives the \" +\n \"native KeyboardEvent. Use for keyboard shortcuts, navigation, and \" +\n \"custom focusable widgets. The wrapper is focusable by default \" +\n \"(tabindex=\\\"0\\\") so it can be reached via Tab; pass `focusable=false` \" +\n \"to disable when the child is already focusable.\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"] },\n { name: \"onKeyDown\", type: \"callable\", optional: true, aliases: [\"onkeydown\"], description: \"Fired on keydown\" },\n { name: \"onKeyUp\", type: \"callable\", optional: true, aliases: [\"onkeyup\"], description: \"Fired on keyup\" },\n { name: \"onKeyPress\", type: \"callable\", optional: true, aliases: [\"onkeypress\"], description: \"Fired on keypress\" },\n { name: \"focusable\", type: \"boolean\", optional: true, description: \"Make the wrapper focusable via Tab (default true)\" },\n ],\n render: (_node, props, helpers) => {\n const focusable = props.focusable === undefined ? true : asBoolean(props.focusable);\n const wrapper = transparentWrapper(\"rui-on-keyboard\", focusable ? { tabindex: \"0\" } : {});\n wrapper.append(renderChildAsNode(helpers, props.child));\n for (const { prop, event } of KEYBOARD_EVENT_MAP) {\n const handler = (props as Record<string, unknown>)[prop];\n if (handler == null) continue;\n wrapper.addEventListener(event, (ev) => {\n helpers.invoke(handler, ev);\n });\n }\n return wrapper;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * OnFocus — focus / blur wrapper.\n * ------------------------------------------------------------------------ */\nexport const OnFocus: ComponentSpec = {\n name: \"OnFocus\",\n description:\n \"Attach focus / blur listeners to a component. Use to track input \" +\n \"focus rings, custom focus indicators, or autosave-on-blur flows. \" +\n \"Listens on the capture phase so blur from descendants is observed.\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"] },\n { name: \"onFocus\", type: \"callable\", optional: true, aliases: [\"onfocus\"], description: \"Fired when focus enters the element or any descendant\" },\n { name: \"onBlur\", type: \"callable\", optional: true, aliases: [\"onblur\"], description: \"Fired when focus leaves the element and all descendants\" },\n ],\n render: (_node, props, helpers) => {\n const wrapper = transparentWrapper(\"rui-on-focus\");\n wrapper.append(renderChildAsNode(helpers, props.child));\n // focusin / focusout bubble (unlike focus / blur), so a single wrapper\n // listener observes focus changes anywhere in the subtree.\n if (props.onFocus != null) {\n wrapper.addEventListener(\"focusin\", (ev) => helpers.invoke(props.onFocus, ev));\n }\n if (props.onBlur != null) {\n wrapper.addEventListener(\"focusout\", (ev) => helpers.invoke(props.onBlur, ev));\n }\n return wrapper;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * OnIntersect — IntersectionObserver wrapper.\n *\n * The wrapper element is the observed target. `onEnter` fires once when\n * the element starts intersecting the viewport (or the supplied root);\n * `onLeave` fires when it stops. `onChange` fires for every state\n * transition with `{visible: boolean, ratio: number}`. Use for lazy-load,\n * infinite-scroll sentinels, impression tracking, and reveal animations.\n *\n * The observer is registered against the wrapper element itself. We use\n * a real `inline-block` wrapper (NOT `display: contents`) because the\n * IntersectionObserver skips boxless wrappers.\n * ------------------------------------------------------------------------ */\nexport const OnIntersect: ComponentSpec = {\n name: \"OnIntersect\",\n description:\n \"Observe whether a component is visible in the viewport (or a scroll \" +\n \"container) using IntersectionObserver. Fires `onEnter` the first \" +\n \"time the wrapped element becomes visible, `onLeave` when it leaves, \" +\n \"and `onChange({visible, ratio})` for every transition. Use for \" +\n \"lazy-load sentinels, infinite-scroll triggers, impression analytics, \" +\n \"and reveal-on-scroll animations.\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"] },\n { name: \"onEnter\", type: \"callable\", optional: true, description: \"Fired when the element enters the viewport\" },\n { name: \"onLeave\", type: \"callable\", optional: true, description: \"Fired when the element leaves the viewport\" },\n { name: \"onChange\", type: \"callable\", optional: true, description: \"Fired with `{visible, ratio}` on every transition\" },\n { name: \"threshold\", type: \"number\", optional: true, description: \"Visible-ratio threshold 0–1 (default 0.05)\" },\n { name: \"rootMargin\", type: \"string\", optional: true, description: \"CSS-length root margin (e.g. \\\"0px 0px -64px 0px\\\")\" },\n { name: \"once\", type: \"boolean\", optional: true, description: \"Disconnect after the first entry (default false)\" },\n ],\n render: (_node, props, helpers) => {\n const wrapper = el(\"span\", {\n class: \"rui-wrapper rui-on-intersect\",\n style: \"display: inline-block;\",\n });\n wrapper.append(renderChildAsNode(helpers, props.child));\n // IntersectionObserver only exists in browser environments; bail\n // gracefully in SSR / test environments.\n const ObserverCtor: typeof IntersectionObserver | undefined =\n typeof IntersectionObserver !== \"undefined\" ? IntersectionObserver : undefined;\n if (!ObserverCtor) return wrapper;\n const threshold = Math.max(0, Math.min(1, asNumber(props.threshold, 0.05)));\n const rootMargin = asString(props.rootMargin);\n const once = asBoolean(props.once);\n let lastVisible: boolean | null = null;\n const observer = new ObserverCtor((entries) => {\n for (const entry of entries) {\n const visible = entry.isIntersecting;\n if (visible !== lastVisible) {\n if (visible && props.onEnter != null) helpers.invoke(props.onEnter, entry);\n if (!visible && lastVisible === true && props.onLeave != null) {\n helpers.invoke(props.onLeave, entry);\n }\n lastVisible = visible;\n }\n if (props.onChange != null) {\n helpers.invoke(props.onChange, { visible, ratio: entry.intersectionRatio });\n }\n if (once && visible) {\n observer.disconnect();\n return;\n }\n }\n }, {\n threshold,\n ...(rootMargin ? { rootMargin } : {}),\n });\n observer.observe(wrapper);\n helpers.registerDisposer(() => observer.disconnect());\n return wrapper;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * Link — anchor that wraps either a label string or any component.\n *\n * Aktion 0.5 supports two link shapes via the same `Link` call:\n *\n * Link(\"Docs\", \"/docs\") // legacy: label + href\n * Link(\"Docs\", { to: \"/docs\" }) // new: router-aware\n * Link(IconButton(\"home\"), { to: \"/\" }) // new: wrap a component\n * Link(Card(\"Read more\"), { href: \"https://x.com\", external: true })\n *\n * If `to` is provided, the click navigates via the runtime router. If\n * only `href` is provided, the anchor behaves like a plain `<a href>`.\n * If both are given, `to` wins. External links open in a new tab with\n * `noopener noreferrer`.\n * ------------------------------------------------------------------------ */\n\n/**\n * Render the positional argument — accepts either a string label (rendered\n * as the anchor's text) or any component / array of components (rendered\n * as children of the anchor). Identical semantics to `renderChildAsNode`\n * but returns an array so callers can `anchor.append(...nodes)`.\n */\nfunction renderLinkChildren(helpers: RenderHelpers, child: unknown): Node[] {\n if (child == null) return [];\n if (typeof child === \"string\") return [document.createTextNode(child)];\n if (Array.isArray(child)) {\n return child\n .filter((c) => c != null)\n .map((c) => (typeof c === \"string\" ? document.createTextNode(c) : helpers.renderNode(c)));\n }\n return [helpers.renderNode(child)];\n}\n\nexport const Link: ComponentSpec = {\n name: \"Link\",\n description:\n \"Anchor link. Accepts either a plain string label or a wrapped \" +\n \"component as its positional child. Pass `to` for client-side \" +\n \"router navigation (no page reload) or `href` for a regular \" +\n \"anchor. `external: true` opens the link in a new tab with \" +\n \"`rel=\\\"noopener noreferrer\\\"`. Use to make any component clickable \" +\n \"as a link — cards, icons, badges, list rows.\",\n props: [\n { name: \"label\", type: \"string | Node\", positional: true, required: true, aliases: [\"child\", \"children\"], description: \"Visible text OR a wrapped component\" },\n { name: \"to\", type: \"string\", optional: true, description: \"Router path (preferred). Navigates via the runtime router on click.\" },\n { name: \"href\", type: \"string\", optional: true, description: \"Standard anchor href. Used when `to` is omitted.\" },\n { name: \"external\", type: \"boolean\", optional: true, description: \"Open in a new tab (`target=\\\"_blank\\\"`, `rel=\\\"noopener noreferrer\\\"`)\" },\n { name: \"variant\", type: \"string\", optional: true, enum: [\"default\", \"subtle\"] },\n ],\n render: (_node, props, helpers) => {\n const to = asString(props.to);\n const external = asBoolean(props.external);\n // `to` wins over `href`. Both are sanitised against `javascript:` URLs.\n const target = to || asString(props.href);\n const safeHref = to\n ? (target.startsWith(\"/\") || target.startsWith(\"#\") ? target : sanitiseHref(target, \"#\"))\n : sanitiseHref(props.href, \"#\");\n const variant = asString(props.variant, \"default\");\n const anchor = el(\"a\", {\n class: \"rui-link\",\n \"data-variant\": variant,\n href: safeHref,\n target: external ? \"_blank\" : null,\n rel: external ? \"noopener noreferrer\" : null,\n });\n for (const node of renderLinkChildren(helpers, props.label)) anchor.append(node);\n // Wire router navigation for `to` only — `href` keeps native behaviour\n // (full reload, mailto:, tel:, external URL).\n if (to && !external) {\n anchor.addEventListener(\"click\", (event) => {\n if (event.defaultPrevented) return;\n if (event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n helpers.router.navigate(to);\n });\n }\n return anchor;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * Css — class / style wrapper.\n *\n * Merges the supplied `class` tokens and `style` declarations onto the\n * rendered child element. This is the \"escape hatch for layout / styling\"\n * — prefer the dedicated component props (Box padding, Stack gap, etc.)\n * whenever they cover the case.\n *\n * Unlike the event wrappers, Css MUST forward styling onto the child:\n * `display: contents` does not transmit class / style to children, so\n * wrapping in a transparent span would render the styling invisible.\n * When the child is a plain text node (or fragment) we still wrap it in\n * a `<span>` so there is a single anchor to attach the styling to.\n * ------------------------------------------------------------------------ */\nexport const Css: ComponentSpec = {\n name: \"Css\",\n description:\n \"Apply raw CSS class names and / or an inline style string to a \" +\n \"wrapped component. The styling is merged onto the rendered child's \" +\n \"DOM element — no extra wrapper element is added unless the child \" +\n \"is plain text (in which case the styling lands on a wrapping span). \" +\n \"Reach for `Css` only when the component's own props cannot express \" +\n \"the styling (use `Box`/`Stack`/`Grid` props for layout, `Theme` for \" +\n \"tokens, `Styles` + selector classes for sweeping changes).\",\n props: [\n { name: \"child\", type: \"Node\", positional: true, required: true, aliases: [\"children\"] },\n { name: \"style\", type: \"string\", optional: true, description: \"Inline CSS declarations (e.g. \\\"padding: 16px; background: #eef;\\\")\" },\n { name: \"class\", type: \"string | string[]\", optional: true, aliases: [\"className\", \"classes\"], description: \"Class name (space-separated string or array). Tokens must match `[A-Za-z_][A-Za-z0-9_-:/]*`.\" },\n ],\n render: (_node, props, helpers) => {\n const rendered = renderChildAsNode(helpers, props.child);\n // If the rendered child is not an element (e.g. a text node), wrap it\n // in a span so the class / style attribute has somewhere to live.\n const target: HTMLElement = rendered instanceof HTMLElement\n ? rendered\n : (() => {\n const span = el(\"span\", { class: \"rui-css\" });\n span.append(rendered);\n return span;\n })();\n const safeClasses = sanitiseClassList(props.class);\n for (const token of safeClasses) target.classList.add(token);\n const safeStyle = sanitiseInlineStyle(props.style);\n if (safeStyle) {\n const existing = target.getAttribute(\"style\");\n target.setAttribute(\"style\", existing ? `${existing};${safeStyle}` : safeStyle);\n }\n return target;\n },\n};\n\n/* ------------------------------------------------------------------------ *\n * Shared helpers re-exported for sibling input components.\n *\n * Inputs (Input, Checkbox, Switch, etc.) accept an `onChange(value)` prop\n * that fires with the freshly-read value. We expose a tiny helper so the\n * dozen input renderers can hook into the same event in one line:\n *\n * attachOnChange(input, props.onChange, helpers, {\n * event: \"change\",\n * getValue: (el) => (el as HTMLInputElement).value,\n * });\n *\n * The helper uses `addEventListener` so it composes cleanly with the\n * property-based `oninput` / `onchange` set by `bindState` — both run\n * on the same DOM event.\n * ------------------------------------------------------------------------ */\nexport function attachOnChange(\n element: HTMLElement,\n callback: unknown,\n helpers: RenderHelpers,\n options: { event?: string; getValue: (el: HTMLElement) => unknown },\n): void {\n if (callback === null || callback === undefined) return;\n const eventName = options.event ?? \"change\";\n element.addEventListener(eventName, () => {\n helpers.invoke(callback, options.getValue(element));\n });\n}\n","/**\n * Form components: Form, FormControl, Input, TextArea, Select, SelectItem,\n * Checkbox, CheckBoxGroup, CheckBoxItem, Radio, Button, Buttons, SearchBar,\n * Slider, NumberInput, DatePicker, FileUpload, Combobox.\n */\n\nimport type { ComponentSpec, RenderHelpers } from \"../types.js\";\nimport type { ComponentNode } from \"../../runtime/evaluator.js\";\nimport { el, asArray, asString, asBoolean, asNumber, renderIcon } from \"../utils.js\";\nimport { installDismissListeners, disposeDismissListeners } from \"./_internal.js\";\nimport { extractComboboxItems } from \"./forms-shared.js\";\nimport { attachOnChange } from \"./wrappers.js\";\n\nconst BUTTON_VARIANTS = [\"primary\", \"secondary\", \"ghost\", \"danger\"] as const;\nconst BUTTON_SIZES = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"small\", \"normal\", \"large\"] as const;\nconst INPUT_TYPES = [\"text\", \"email\", \"password\", \"number\", \"tel\", \"url\", \"date\"] as const;\n\n/**\n * Normalise size tokens to the shared `sm|md|lg` vocabulary. The legacy\n * `small|normal|large` triple is preserved (suggestion 4.2) so prompts\n * that mix the old and new names produce consistent visual output.\n */\nfunction normaliseButtonSize(value: unknown): string {\n const v = asString(value).trim().toLowerCase();\n if (v === \"xs\" || v === \"extra-small\") return \"xs\";\n if (v === \"small\" || v === \"sm\") return \"sm\";\n if (v === \"large\" || v === \"lg\") return \"lg\";\n if (v === \"xl\" || v === \"extra-large\") return \"xl\";\n if (v === \"normal\" || v === \"md\" || v === \"\") return \"md\";\n if (v === \"xs\" || v === \"sm\" || v === \"md\" || v === \"lg\" || v === \"xl\") return v;\n return \"md\";\n}\n\nexport const Button: ComponentSpec = {\n name: \"Button\",\n description:\n \"Clickable button. `onClick` (a callable) runs when the user \" +\n \"presses the button. The legacy `action` prop is an alias and is \" +\n \"still accepted.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Callable invoked when the button is clicked\" },\n { name: \"variant\", type: \"string\", optional: true, aliases: [\"tone\"], enum: BUTTON_VARIANTS },\n { name: \"type\", type: \"string\", optional: true, enum: [\"button\", \"submit\"], description: \"HTML button type\" },\n { name: \"size\", type: \"string\", optional: true, enum: BUTTON_SIZES, description: \"Canonical `xs|sm|md|lg|xl` (legacy `small|normal|large` still accepted)\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name\" },\n { name: \"iconPosition\", type: \"string\", optional: true, enum: [\"leading\", \"trailing\"], description: \"Icon placement (default leading)\" },\n { name: \"iconOnly\", type: \"boolean\", optional: true, description: \"Hide the label visually (keeps aria-label)\" },\n { name: \"loading\", type: \"boolean\", optional: true, description: \"Show spinner and disable interaction\" },\n { name: \"fullWidth\", type: \"boolean\", optional: true },\n { name: \"disabled\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const loading = asBoolean(props.loading);\n const iconOnly = asBoolean(props.iconOnly);\n const iconPosition = asString(props.iconPosition, \"leading\");\n const labelText = asString(props.label);\n const button = el(\"button\", {\n class: \"rui-button\",\n type: asString(props.type, \"button\"),\n \"data-variant\": asString(props.variant, \"primary\"),\n \"data-size\": normaliseButtonSize(props.size),\n \"data-icon-position\": iconPosition,\n \"data-icon-only\": iconOnly ? \"true\" : null,\n \"data-full-width\": asBoolean(props.fullWidth) ? \"true\" : null,\n \"data-loading\": loading ? \"true\" : null,\n \"aria-label\": iconOnly ? labelText : null,\n disabled: asBoolean(props.disabled) || loading ? \"\" : null,\n });\n const labelSpan = el(\"span\", { class: \"rui-button-label\" }, [labelText]);\n const iconNode = renderIcon(props.icon, { className: \"rui-button-icon\" });\n const spinNode = loading ? renderIcon(\"spinner\", { className: \"rui-button-spinner\" }) : null;\n const adornment = spinNode ?? iconNode;\n if (iconOnly) {\n if (adornment) button.append(adornment);\n } else if (iconPosition === \"trailing\") {\n button.append(labelSpan);\n if (adornment) button.append(adornment);\n } else {\n if (adornment) button.append(adornment);\n button.append(labelSpan);\n }\n button.onclick = () => {\n if (loading) return;\n helpers.invoke(props.onClick);\n };\n return button;\n },\n};\n\nexport const Buttons: ComponentSpec = {\n name: \"Buttons\",\n description: \"Group of buttons laid out horizontally or vertically.\",\n props: [\n { name: \"items\", type: \"Button[]\" },\n { name: \"direction\", type: \"string\", optional: true, enum: [\"row\", \"column\"] },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-buttons\",\n \"data-direction\": asString(props.direction, \"row\"),\n });\n for (const child of asArray(props.items)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const Input: ComponentSpec = {\n name: \"Input\",\n description: \"Text input field. Pass a $variable as `value` for two-way binding. `onChange(value)` fires on every keystroke with the current string.\",\n props: [\n { name: \"id\", type: \"string\", description: \"Input identifier\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"type\", type: \"string\", optional: true, enum: INPUT_TYPES },\n { name: \"validations\", type: \"any\", optional: true, description: \"Array or object of validation hints\" },\n { name: \"value\", type: \"any\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current value on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const input = el(\"input\", {\n class: \"rui-input\",\n id: asString(props.id),\n name: asString(props.id),\n type: asString(props.type, \"text\"),\n placeholder: asString(props.placeholder),\n value: asString(props.value),\n }) as HTMLInputElement;\n bindToStateAtArg(input, node, 4, helpers);\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n applyValidations(input, props.validations);\n return input;\n },\n};\n\nexport const TextArea: ComponentSpec = {\n name: \"TextArea\",\n description: \"Multi-line text input. `onChange(value)` fires on every keystroke with the current text.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"rows\", type: \"number\", optional: true },\n { name: \"value\", type: \"any\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current value on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const textarea = el(\"textarea\", {\n class: \"rui-textarea\",\n id: asString(props.id),\n name: asString(props.id),\n placeholder: asString(props.placeholder),\n rows: String(Number(props.rows ?? 4) || 4),\n }) as HTMLTextAreaElement;\n textarea.value = asString(props.value);\n bindToStateAtArg(textarea, node, 3, helpers);\n attachOnChange(textarea, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLTextAreaElement).value,\n });\n return textarea;\n },\n};\n\nexport const SelectItem: ComponentSpec = {\n name: \"SelectItem\",\n description: \"Single option for a Select component.\",\n props: [\n { name: \"value\", type: \"string\" },\n { name: \"label\", type: \"string\" },\n ],\n render: (_node, props) => {\n return el(\"option\", { value: asString(props.value) }, [asString(props.label)]);\n },\n};\n\nexport const Select: ComponentSpec = {\n name: \"Select\",\n description:\n \"Dropdown select. Pass a `$variable` as `value` for two-way binding. \" +\n \"Set `searchable: true` for a combobox-style filter UI on long option \" +\n \"lists. `onChange(value)` fires with the newly-selected value.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"items\", type: \"SelectItem[]\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"value\", type: \"any\", optional: true },\n { name: \"searchable\", type: \"boolean\", optional: true, description: \"Render as a filterable combobox\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-selected value\" },\n ],\n render: (node, props, helpers) => {\n if (asBoolean(props.searchable)) {\n return renderSearchableSelect(node, props, helpers);\n }\n const select = el(\"select\", {\n class: \"rui-select\",\n id: asString(props.id),\n name: asString(props.id),\n }) as HTMLSelectElement;\n const placeholder = asString(props.placeholder);\n if (placeholder) {\n select.append(el(\"option\", { value: \"\", disabled: \"\", selected: \"\" }, [placeholder]));\n }\n for (const item of asArray(props.items)) {\n select.append(helpers.renderNode(item));\n }\n select.value = asString(props.value);\n bindToStateAtArg(select, node, 4, helpers);\n attachOnChange(select, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLSelectElement).value,\n });\n return select;\n },\n};\n\nexport const Checkbox: ComponentSpec = {\n name: \"Checkbox\",\n description: \"Boolean checkbox. `onChange(checked)` fires with the new boolean state.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"label\", type: \"string\" },\n { name: \"value\", type: \"boolean\", optional: true, aliases: [\"checked\"] },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new boolean value\" },\n ],\n render: (node, props, helpers) => {\n const wrapper = el(\"label\", { class: \"rui-checkbox\" });\n const isChecked = asBoolean(props.value);\n const input = el(\"input\", {\n type: \"checkbox\",\n id: asString(props.id),\n name: asString(props.id),\n checked: isChecked ? \"\" : null,\n }) as HTMLInputElement;\n input.checked = isChecked;\n bindToStateAtArg(input, node, 2, helpers);\n attachOnChange(input, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).checked,\n });\n wrapper.append(input, el(\"span\", { class: \"rui-checkbox-label\" }, [asString(props.label)]));\n return wrapper;\n },\n};\n\nexport const CheckBoxItem: ComponentSpec = {\n name: \"CheckBoxItem\",\n description: \"Single option inside a CheckBoxGroup.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"name\", type: \"string\", description: \"Key inside the group's value object\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"defaultChecked\", type: \"boolean\", optional: true, aliases: [\"checked\"] },\n ],\n render: (_node, props) => {\n const itemName = asString(props.name);\n const label = asString(props.label);\n const description = asString(props.description);\n const isChecked = asBoolean(props.defaultChecked);\n const wrapper = el(\"label\", {\n class: \"rui-checkbox-item\",\n \"data-name\": itemName,\n });\n const input = el(\"input\", {\n type: \"checkbox\",\n name: itemName,\n checked: isChecked ? \"\" : null,\n }) as HTMLInputElement;\n input.checked = isChecked;\n const text = el(\"div\", { class: \"rui-checkbox-item-text\" });\n text.append(el(\"div\", { class: \"rui-checkbox-item-label\" }, [label]));\n if (description) text.append(el(\"div\", { class: \"rui-checkbox-item-description\" }, [description]));\n wrapper.append(input, text);\n return wrapper;\n },\n};\n\nexport const CheckBoxGroup: ComponentSpec = {\n name: \"CheckBoxGroup\",\n description: \"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding. `onChange(value)` fires with the full updated object.\",\n props: [\n { name: \"name\", type: \"string\", description: \"Group identifier\" },\n { name: \"items\", type: \"CheckBoxItem[]\" },\n { name: \"value\", type: \"any\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the updated `{name: checked}` object when any item toggles\" },\n ],\n render: (node, props, helpers) => {\n const groupName = asString(props.name);\n const root = el(\"div\", { class: \"rui-checkbox-group\", role: \"group\", \"data-name\": groupName });\n const items = asArray<{ args?: unknown[] }>(props.items);\n const valueObject = (props.value && typeof props.value === \"object\")\n ? (props.value as Record<string, unknown>)\n : {};\n const inputs: HTMLInputElement[] = [];\n\n items.forEach((item, idx) => {\n const label = asString(item.args?.[0]);\n const itemName = asString(item.args?.[1], `${groupName}-${idx}`);\n const description = asString(item.args?.[2]);\n const defaultChecked = asBoolean(item.args?.[3]);\n const id = `${groupName}-${itemName}`;\n const wrapper = el(\"label\", { class: \"rui-checkbox-item\", for: id });\n const isChecked = itemName in valueObject\n ? Boolean(valueObject[itemName])\n : defaultChecked;\n const input = el(\"input\", {\n type: \"checkbox\",\n id,\n name: itemName,\n checked: isChecked ? \"\" : null,\n }) as HTMLInputElement;\n inputs.push(input);\n const text = el(\"div\", { class: \"rui-checkbox-item-text\" });\n text.append(el(\"div\", { class: \"rui-checkbox-item-label\" }, [label]));\n if (description) text.append(el(\"div\", { class: \"rui-checkbox-item-description\" }, [description]));\n wrapper.append(input, text);\n root.append(wrapper);\n });\n\n const stateName = node.argMeta?.[2]?.stateRef;\n // Snapshot the live `{name: checked}` object from the rendered DOM. The\n // CheckBoxGroup re-derives the object on every event so morphing and\n // user-supplied `onChange` handlers stay in sync.\n const readGroupValue = (rootEl: HTMLElement): Record<string, boolean> => {\n const out: Record<string, boolean> = {};\n rootEl\n .querySelectorAll<HTMLInputElement>('input[type=\"checkbox\"]')\n .forEach((input) => {\n out[input.name] = input.checked;\n });\n return out;\n };\n if (stateName) {\n helpers.bindState(root, stateName, {\n event: \"change\",\n // Read from the *live* DOM rooted at the event target, never from\n // the closure's `inputs` array. After a morph re-render those\n // captured input elements are detached and report stale `checked`.\n getValue: readGroupValue,\n });\n }\n attachOnChange(root, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => readGroupValue(n as HTMLElement),\n });\n\n return root;\n },\n};\n\nexport const Radio: ComponentSpec = {\n name: \"Radio\",\n description: \"Radio button group. `onChange(value)` fires with the newly-selected option value.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"items\", type: \"SelectItem[]\" },\n { name: \"value\", type: \"any\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-selected radio value\" },\n ],\n render: (node, props, helpers) => {\n const groupName = asString(props.id);\n const root = el(\"div\", { class: \"rui-radio-group\", role: \"radiogroup\" });\n for (const item of asArray<{ args?: unknown[] }>(props.items)) {\n const value = asString(item.args?.[0]);\n const label = asString(item.args?.[1], value);\n const id = `${groupName}-${value}`;\n const itemRoot = el(\"label\", { class: \"rui-radio\", for: id });\n const isChecked = asString(props.value) === value;\n const input = el(\"input\", {\n type: \"radio\",\n id,\n name: groupName,\n value,\n checked: isChecked ? \"\" : null,\n }) as HTMLInputElement;\n input.checked = isChecked;\n bindToStateAtArg(input, node, 2, helpers);\n attachOnChange(input, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n itemRoot.append(input, el(\"span\", { class: \"rui-radio-label\" }, [label]));\n root.append(itemRoot);\n }\n return root;\n },\n};\n\nexport const FormControl: ComponentSpec = {\n name: \"FormControl\",\n description: \"Labeled wrapper around a single form field.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"field\", type: \"Node\", aliases: [\"control\"] },\n { name: \"hint\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-form-control\" });\n root.append(el(\"label\", { class: \"rui-form-label\" }, [asString(props.label)]));\n const fieldEl = helpers.renderNode(props.field);\n root.append(fieldEl);\n const hint = asString(props.hint);\n if (hint) root.append(el(\"p\", { class: \"rui-form-hint\" }, [hint]));\n return root;\n },\n};\n\nexport const SearchBar: ComponentSpec = {\n name: \"SearchBar\",\n description:\n \"Pre-styled search input with a leading magnifying-glass icon, optional \" +\n \"trailing submit button, and optional keyboard-shortcut hint. Pass a \" +\n \"`$variable` as `value` for two-way binding. Use anywhere a user \" +\n \"needs to filter content — toolbars, command bars, lists, headers.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"shortcut\", type: \"string\", optional: true, description: \"Keyboard hint chip on the right (e.g. \\\"/\\\")\" },\n { name: \"onSubmit\", type: \"callable\", optional: true, aliases: [\"action\", \"onClick\"], description: \"Optional submit callable; clicking the trailing button or pressing Enter invokes it\" },\n { name: \"submitLabel\", type: \"string\", optional: true, description: \"Label for the trailing submit button (default \\\"Search\\\"). Omitted when no action is provided.\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current query on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const root = el(\"form\", { class: \"rui-search-bar\", role: \"search\" });\n root.onsubmit = (event) => {\n event.preventDefault();\n helpers.invoke(props.onSubmit);\n };\n const iconWrap = renderIcon(\"magnifying-glass\", { className: \"rui-search-bar-icon\" })\n ?? el(\"span\", { class: \"rui-search-bar-icon\", \"aria-hidden\": \"true\" });\n root.append(iconWrap);\n const input = el(\"input\", {\n class: \"rui-search-bar-input\",\n id: asString(props.id),\n name: asString(props.id),\n type: \"search\",\n placeholder: asString(props.placeholder, \"Search…\"),\n value: asString(props.value),\n autocomplete: \"off\",\n }) as HTMLInputElement;\n bindToStateAtArg(input, node, 2, helpers);\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n root.append(input);\n const shortcut = asString(props.shortcut);\n if (shortcut) root.append(el(\"span\", { class: \"rui-search-bar-shortcut\" }, [shortcut]));\n if (props.onSubmit != null) {\n const btn = el(\"button\", {\n type: \"submit\",\n class: \"rui-search-bar-submit\",\n }, [asString(props.submitLabel, \"Search\")]);\n root.append(btn);\n }\n return root;\n },\n};\n\nexport const Form: ComponentSpec = {\n name: \"Form\",\n description:\n \"Form container. Children FormControls render in order; buttons \" +\n \"render at the bottom. Provide `onSubmit` to handle form submission \" +\n \"(invoked when the user presses Enter on a focused input or clicks a \" +\n \"`type=\\\"submit\\\"` Button inside the form).\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"buttons\", type: \"Buttons | Button\" },\n { name: \"fields\", type: \"FormControl[]\" },\n { name: \"onSubmit\", type: \"callable\", optional: true, aliases: [\"onsubmit\"], description: \"Called when the form is submitted (Enter key or submit button)\" },\n ],\n render: (_node, props, helpers) => {\n const form = el(\"form\", { class: \"rui-form\", id: asString(props.id) });\n form.onsubmit = (event) => {\n event.preventDefault();\n helpers.invoke(props.onSubmit);\n };\n for (const field of asArray(props.fields)) form.append(helpers.renderNode(field));\n if (props.buttons) {\n const actions = el(\"div\", { class: \"rui-form-actions\" });\n actions.append(helpers.renderNode(props.buttons));\n form.append(actions);\n }\n return form;\n },\n};\n\nexport const Slider: ComponentSpec = {\n name: \"Slider\",\n description:\n \"Range slider for selecting a single numeric value between `min` and \" +\n \"`max`. Pass a `$variable` as `value` for two-way binding. Useful for \" +\n \"filters, settings (volume, brightness), and parameter tuning.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"min\", type: \"number\", optional: true, description: \"Default 0\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Default 100\" },\n { name: \"step\", type: \"number\", optional: true, description: \"Default 1\" },\n { name: \"value\", type: \"number\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"showValue\", type: \"boolean\", optional: true, description: \"Render the current numeric value beside the slider\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new number as the user drags\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const min = asNumber(props.min, 0);\n const max = asNumber(props.max, 100);\n const step = asNumber(props.step, 1);\n const value = asNumber(props.value, min);\n const root = el(\"div\", { class: \"rui-slider\", \"data-disabled\": asBoolean(props.disabled) ? \"true\" : \"false\" });\n const label = asString(props.label);\n const showValue = asBoolean(props.showValue);\n if (label || showValue) {\n const head = el(\"div\", { class: \"rui-slider-head\" });\n if (label) head.append(el(\"label\", { class: \"rui-slider-label\", for: id }, [label]));\n if (showValue) head.append(el(\"span\", { class: \"rui-slider-value\" }, [String(value)]));\n root.append(head);\n }\n const input = el(\"input\", {\n type: \"range\",\n class: \"rui-slider-input\",\n id,\n name: id,\n min: String(min),\n max: String(max),\n step: String(step),\n value: String(value),\n disabled: asBoolean(props.disabled) ? \"\" : null,\n }) as HTMLInputElement;\n // Update the inline value pill while dragging so the user gets feedback\n // before the state binding propagates back through a render tick.\n // NOTE: the morph copies `oninput` onto the *live* input, so we must\n // resolve sibling nodes from the event target — capturing `root` /\n // `input` here would point at the freshly-rendered (detached) tree.\n input.oninput = (event: Event) => {\n const target = event.currentTarget as HTMLInputElement | null;\n if (!target) return;\n const sliderRoot = target.closest(\".rui-slider\");\n const valueEl = sliderRoot?.querySelector(\".rui-slider-value\");\n if (valueEl) valueEl.textContent = target.value;\n };\n const stateName = node.argMeta?.[4]?.stateRef;\n if (stateName) {\n helpers.bindState(input, stateName, {\n event: \"input\",\n getValue: (n) => Number((n as HTMLInputElement).value),\n });\n }\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => Number((n as HTMLInputElement).value),\n });\n root.append(input);\n return root;\n },\n};\n\nexport const NumberInput: ComponentSpec = {\n name: \"NumberInput\",\n description:\n \"Numeric input with paired increment/decrement buttons. Use for \" +\n \"quantity steppers, integer settings, and any field where a `<input \" +\n \"type=\\\"number\\\">` plus +/- controls is friendlier than the native \" +\n \"spinner. Pass a `$variable` as `value` for two-way binding.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"number\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"min\", type: \"number\", optional: true },\n { name: \"max\", type: \"number\", optional: true },\n { name: \"step\", type: \"number\", optional: true, description: \"Default 1\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new number (or null when blank)\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const step = asNumber(props.step, 1);\n const hasMin = props.min !== undefined && props.min !== null;\n const hasMax = props.max !== undefined && props.max !== null;\n const min = hasMin ? asNumber(props.min, 0) : Number.NEGATIVE_INFINITY;\n const max = hasMax ? asNumber(props.max, 0) : Number.POSITIVE_INFINITY;\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", { class: \"rui-number-input\", \"data-disabled\": disabled ? \"true\" : \"false\" });\n const decBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-number-input-button\",\n \"data-direction\": \"down\",\n \"aria-label\": \"Decrement\",\n disabled: disabled ? \"\" : null,\n }, [\"−\"]);\n const input = el(\"input\", {\n type: \"number\",\n class: \"rui-number-input-field\",\n id,\n name: id,\n value: asString(props.value),\n placeholder: asString(props.placeholder),\n min: hasMin ? String(min) : null,\n max: hasMax ? String(max) : null,\n step: String(step),\n disabled: disabled ? \"\" : null,\n }) as HTMLInputElement;\n const incBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-number-input-button\",\n \"data-direction\": \"up\",\n \"aria-label\": \"Increment\",\n disabled: disabled ? \"\" : null,\n }, [\"+\"]);\n const stateName = node.argMeta?.[1]?.stateRef;\n const readNumberValue = (n: HTMLElement): number | null => {\n const raw = (n as HTMLInputElement).value;\n if (raw === \"\") return null;\n const num = Number(raw);\n return Number.isFinite(num) ? num : null;\n };\n if (stateName) {\n helpers.bindState(input, stateName, { event: \"input\", getValue: readNumberValue });\n }\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: readNumberValue,\n });\n const adjust = (origin: Element, delta: number): void => {\n // Resolve the *live* input via the DOM. The `input` captured by this\n // closure points at the freshly-rendered node, which is detached\n // once the morph reconciler reuses the previous one.\n const liveRoot = origin.closest(\".rui-number-input\");\n const live = liveRoot?.querySelector<HTMLInputElement>(\".rui-number-input-field\");\n if (!live) return;\n const current = Number(live.value);\n const base = Number.isFinite(current) ? current : 0;\n const next = clampNumber(base + delta, min, max);\n live.value = String(next);\n live.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n decBtn.onclick = (event) => adjust((event.currentTarget ?? event.target) as Element, -step);\n incBtn.onclick = (event) => adjust((event.currentTarget ?? event.target) as Element, step);\n root.append(decBtn, input, incBtn);\n return root;\n },\n};\n\nexport const DatePicker: ComponentSpec = {\n name: \"DatePicker\",\n description:\n \"Date picker that wraps the native `<input type=\\\"date\\\">` with \" +\n \"consistent styling. Pass a `$variable` as `value` for two-way binding. \" +\n \"Use `min`/`max` to bound the selectable range.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"ISO date (YYYY-MM-DD); typically $variable\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"min\", type: \"string\", optional: true, description: \"Earliest ISO date\" },\n { name: \"max\", type: \"string\", optional: true, description: \"Latest ISO date\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new ISO date string when the picker changes\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const root = el(\"div\", { class: \"rui-date-picker\" });\n const label = asString(props.label);\n if (label) root.append(el(\"label\", { class: \"rui-date-picker-label\", for: id }, [label]));\n const input = el(\"input\", {\n type: \"date\",\n class: \"rui-date-picker-input\",\n id,\n name: id,\n value: asString(props.value),\n min: asString(props.min) || null,\n max: asString(props.max) || null,\n placeholder: asString(props.placeholder),\n disabled: asBoolean(props.disabled) ? \"\" : null,\n }) as HTMLInputElement;\n bindToStateAtArg(input, node, 1, helpers);\n attachOnChange(input, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n root.append(input);\n return root;\n },\n};\n\nexport const FileUpload: ComponentSpec = {\n name: \"FileUpload\",\n description:\n \"Styled file picker. Renders a click/drop area with a leading icon, \" +\n \"label, and helper text. Files cannot round-trip through `$variables` \" +\n \"(they are not serialisable), so pass a callable as `action` to handle \" +\n \"the picked files via `ctx.query(\\\"#id\\\").files`.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Primary label (default \\\"Choose a file\\\")\" },\n { name: \"hint\", type: \"string\", optional: true, description: \"Secondary helper text\" },\n { name: \"accept\", type: \"string\", optional: true, description: \"Comma-separated MIME types or extensions\" },\n { name: \"multiple\", type: \"boolean\", optional: true },\n { name: \"onSelect\", type: \"callable\", optional: true, aliases: [\"action\", \"onChange\"], description: \"Callable fired with the FileList when files are picked\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon (default \\\"cloud-arrow-up\\\")\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const id = asString(props.id);\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", {\n class: \"rui-file-upload\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n const dropZone = el(\"label\", {\n class: \"rui-file-upload-dropzone\",\n for: id,\n });\n const iconNode = renderIcon(asString(props.icon, \"cloud-arrow-up\"), { className: \"rui-file-upload-icon\" });\n if (iconNode) dropZone.append(iconNode);\n const text = el(\"div\", { class: \"rui-file-upload-text\" });\n text.append(el(\"div\", { class: \"rui-file-upload-label\" }, [asString(props.label, \"Choose a file\")]));\n const hint = asString(props.hint);\n if (hint) text.append(el(\"div\", { class: \"rui-file-upload-hint\" }, [hint]));\n dropZone.append(text);\n const input = el(\"input\", {\n type: \"file\",\n id,\n name: id,\n class: \"rui-file-upload-input\",\n accept: asString(props.accept) || null,\n multiple: asBoolean(props.multiple) ? \"\" : null,\n disabled: disabled ? \"\" : null,\n });\n dropZone.append(input);\n root.append(dropZone);\n\n const isImageFile = (file: File, accept: string): boolean =>\n accept.includes(\"image\") ||\n file.type.startsWith(\"image/\") ||\n /\\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(file.name);\n\n input.onchange = (event) => {\n const fileInput = event.currentTarget as HTMLInputElement;\n // Pass the FileList as the first argument so handlers can read it\n // directly: `(files) => uploadAll(files)`. Older handlers that\n // ignore arguments keep working unchanged.\n helpers.invoke(props.onSelect, fileInput.files);\n const uploadRoot = fileInput.closest(\".rui-file-upload\") as HTMLElement | null;\n if (!uploadRoot) return;\n const files = fileInput.files;\n const existing = uploadRoot.querySelector(\".rui-file-upload-preview\");\n if (existing) existing.remove();\n if (!files || files.length === 0) return;\n const accept = asString(props.accept);\n const preview = el(\"div\", { class: \"rui-file-upload-preview\" });\n Array.from(files).forEach((file) => {\n const row = el(\"div\", { class: \"rui-file-upload-preview-item\" });\n if (isImageFile(file, accept)) {\n const objectUrl = URL.createObjectURL(file);\n const img = el(\"img\", {\n src: objectUrl,\n alt: file.name,\n class: \"rui-file-upload-thumbnail\",\n }) as HTMLImageElement;\n // Revoke the object URL when the image has rendered so memory is\n // released. Browsers keep the bitmap cached after decode so the\n // src can be safely revoked once `load` fires.\n img.onload = () => URL.revokeObjectURL(objectUrl);\n row.append(img);\n }\n row.append(el(\"span\", { class: \"rui-file-upload-filename\" }, [file.name]));\n preview.append(row);\n });\n uploadRoot.append(preview);\n };\n return root;\n },\n};\n\nexport const Combobox: ComponentSpec = {\n name: \"Combobox\",\n description:\n \"Searchable single-select dropdown — type to filter, click an option \" +\n \"to choose. Use instead of `Select` when the list is long enough that \" +\n \"scanning is faster than scrolling (countries, currencies, repos, \" +\n \"users). Pass a `$variable` as `value` for two-way binding; the \" +\n \"selected option's `value` is written to state on pick.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"items\", type: \"SelectItem[]\", description: \"Options; SelectItem(value, label) or {value, label}\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound selected value (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"emptyLabel\", type: \"string\", optional: true, description: \"Text shown when no items match the filter (default \\\"No matches\\\")\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Initial open state — use to demo or pre-open the dropdown\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-selected value\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const items = extractComboboxItems(props.items);\n const currentValue = asString(props.value);\n const currentLabel = items.find((item) => item.value === currentValue)?.label ?? currentValue;\n const placeholder = asString(props.placeholder, \"Select…\");\n const emptyLabel = asString(props.emptyLabel, \"No matches\");\n const disabled = asBoolean(props.disabled);\n const initialOpen = asBoolean(props.open);\n const openSlot = helpers.useInstanceState<boolean>(\"open\", initialOpen);\n const filterSlot = helpers.useInstanceState<string>(\"filter\", \"\");\n const isOpen = openSlot.get();\n\n const root = el(\"div\", {\n class: \"rui-combobox\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n const triggerBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-combobox-trigger\",\n id,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen ? \"true\" : \"false\",\n disabled: disabled ? \"\" : null,\n });\n triggerBtn.append(el(\"span\", {\n class: \"rui-combobox-value\",\n \"data-placeholder\": currentLabel ? \"false\" : \"true\",\n }, [currentLabel || placeholder]));\n const chevron = renderIcon(\"chevron-down\", { className: \"rui-combobox-chevron\" });\n if (chevron) triggerBtn.append(chevron);\n root.append(triggerBtn);\n\n const panel = el(\"div\", { class: \"rui-combobox-panel\", role: \"listbox\" });\n const filterInput = el(\"input\", {\n type: \"text\",\n class: \"rui-combobox-filter\",\n placeholder: \"Filter…\",\n autocomplete: \"off\",\n value: filterSlot.get(),\n }) as HTMLInputElement;\n panel.append(filterInput);\n const list = el(\"div\", { class: \"rui-combobox-list\" });\n panel.append(list);\n\n // Re-paint the option list into the supplied container. When the\n // user types into the filter input on a re-rendered combobox the\n // closure-captured `list` reference points at the (detached)\n // freshly-rendered DOM; the live target is the only thing that\n // actually shows in the page, so we accept it as an argument and let\n // each call site resolve it from the live tree.\n const renderList = (target: HTMLElement, filter: string): void => {\n target.replaceChildren();\n const lower = filter.trim().toLowerCase();\n const matches = lower === \"\"\n ? items\n : items.filter((item) =>\n item.label.toLowerCase().includes(lower) ||\n item.value.toLowerCase().includes(lower),\n );\n if (matches.length === 0) {\n target.append(el(\"div\", { class: \"rui-combobox-empty\" }, [emptyLabel]));\n return;\n }\n for (const item of matches) {\n const option = el(\"button\", {\n type: \"button\",\n class: \"rui-combobox-option\",\n role: \"option\",\n \"data-value\": item.value,\n \"aria-selected\": item.value === currentValue ? \"true\" : \"false\",\n }, [item.label]);\n option.onclick = (event) => {\n event.stopPropagation();\n selectComboboxValue(event.currentTarget as Element, item.value);\n };\n target.append(option);\n }\n };\n\n // Apply a value as the bound state, then close the combobox UI. Also\n // disposes any pending dismissal listeners so we don't accumulate them\n // after a successful pick (the previous implementation only cleaned\n // them up on outside-click / Escape).\n const selectComboboxValue = (origin: Element, value: string): void => {\n const stateName = node.argMeta?.[2]?.stateRef;\n if (stateName) {\n helpers.setState(stateName, value);\n }\n helpers.invoke(props.onChange, value);\n openSlot.set(false);\n filterSlot.set(\"\");\n const live = origin.closest(\".rui-combobox\") as HTMLElement | null;\n live?.setAttribute(\"data-open\", \"false\");\n live?.querySelector(\".rui-combobox-trigger\")\n ?.setAttribute(\"aria-expanded\", \"false\");\n disposeDismissListeners(live);\n };\n\n renderList(list, filterSlot.get());\n\n filterInput.oninput = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n filterSlot.set(target.value);\n const liveList = target.closest(\".rui-combobox-panel\")\n ?.querySelector(\".rui-combobox-list\") as HTMLElement | null;\n if (liveList) renderList(liveList, target.value);\n };\n\n // Enter on the filter selects the first visible option, matching the\n // type-ahead behaviour that users expect from native comboboxes. We\n // resolve the option from the live DOM so the handler survives morph.\n filterInput.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n if (e.key !== \"Enter\") return;\n e.preventDefault();\n const target = e.currentTarget as HTMLInputElement;\n const live = target.closest(\".rui-combobox\");\n const firstOption = live?.querySelector<HTMLElement>(\n \".rui-combobox-option[data-value]\",\n );\n const value = firstOption?.getAttribute(\"data-value\");\n if (value !== null && value !== undefined && firstOption) {\n selectComboboxValue(firstOption, value);\n }\n };\n\n triggerBtn.onclick = (event) => {\n if (disabled) return;\n event.stopPropagation();\n const next = !openSlot.get();\n openSlot.set(next);\n const live = (event.currentTarget as Element).closest(\".rui-combobox\") as HTMLElement | null;\n live?.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n live?.querySelector(\".rui-combobox-trigger\")\n ?.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n if (!live) return;\n if (!next) {\n // Close path: release any listeners that an earlier open() installed.\n disposeDismissListeners(live);\n return;\n }\n // Focus the filter so users can type immediately. Defer one tick so\n // the element is in the DOM after attribute updates settle.\n setTimeout(() => filterInput.focus(), 0);\n installDismissListeners({\n liveRoot: live,\n onDismiss: () => {\n openSlot.set(false);\n filterSlot.set(\"\");\n live.setAttribute(\"data-open\", \"false\");\n live.querySelector(\".rui-combobox-trigger\")\n ?.setAttribute(\"aria-expanded\", \"false\");\n },\n });\n };\n root.append(panel);\n return root;\n },\n};\n\nexport const MultiSelect: ComponentSpec = {\n name: \"MultiSelect\",\n description:\n \"Multi-option searchable dropdown. Type to filter, click an option to \" +\n \"add/remove it from the bound array. Renders the selected options as \" +\n \"removable chips inside the trigger. Pass a `$variable` (array of \" +\n \"values) as `value` for two-way binding.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"items\", type: \"SelectItem[]\", description: \"Options; SelectItem(value, label) or {value, label}\" },\n { name: \"value\", type: \"any[]\", optional: true, description: \"Bound array of selected values (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"emptyLabel\", type: \"string\", optional: true, description: \"Text shown when no items match the filter\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Maximum number of selections\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Initial open state — use to demo or pre-open the dropdown\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the updated array of selected values\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const items = extractComboboxItems(props.items);\n const placeholder = asString(props.placeholder, \"Select…\");\n const emptyLabel = asString(props.emptyLabel, \"No matches\");\n const disabled = asBoolean(props.disabled);\n const max = Math.max(0, Math.floor(Number(props.max ?? 0)));\n const selected = Array.isArray(props.value)\n ? (props.value as unknown[]).map((v) => asString(v)).filter(Boolean)\n : [];\n const selectedSet = new Set(selected);\n const stateName = node.argMeta?.[2]?.stateRef;\n\n const initialOpen = asBoolean(props.open);\n const openSlot = helpers.useInstanceState<boolean>(\"open\", initialOpen);\n const filterSlot = helpers.useInstanceState<string>(\"filter\", \"\");\n const isOpen = openSlot.get();\n\n const root = el(\"div\", {\n class: \"rui-multiselect\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n\n const triggerBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-multiselect-trigger\",\n id,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen ? \"true\" : \"false\",\n disabled: disabled ? \"\" : null,\n });\n const chipRow = el(\"span\", { class: \"rui-multiselect-chips\" });\n const writeSelection = (next: string[]): void => {\n if (stateName) helpers.setState(stateName, next);\n helpers.invoke(props.onChange, next);\n };\n if (selected.length === 0) {\n chipRow.append(el(\"span\", { class: \"rui-multiselect-placeholder\" }, [placeholder]));\n } else {\n for (const value of selected) {\n const label = items.find((item) => item.value === value)?.label ?? value;\n const chip = el(\"span\", { class: \"rui-multiselect-chip\", \"data-value\": value });\n chip.append(el(\"span\", { class: \"rui-multiselect-chip-label\" }, [label]));\n const removeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-multiselect-chip-remove\",\n \"aria-label\": `Remove ${label}`,\n }, [\"×\"]);\n removeBtn.onclick = (event) => {\n event.stopPropagation();\n const next = selected.filter((v) => v !== value);\n writeSelection(next);\n };\n chip.append(removeBtn);\n chipRow.append(chip);\n }\n }\n triggerBtn.append(chipRow);\n const chevron = renderIcon(\"chevron-down\", { className: \"rui-multiselect-chevron\" });\n if (chevron) triggerBtn.append(chevron);\n root.append(triggerBtn);\n\n const panel = el(\"div\", { class: \"rui-multiselect-panel\", role: \"listbox\", \"aria-multiselectable\": \"true\" });\n const filterInput = el(\"input\", {\n type: \"text\",\n class: \"rui-multiselect-filter\",\n placeholder: \"Filter…\",\n autocomplete: \"off\",\n value: filterSlot.get(),\n }) as HTMLInputElement;\n panel.append(filterInput);\n const list = el(\"div\", { class: \"rui-multiselect-list\" });\n panel.append(list);\n\n // Paint into the *given* container so the input handler can pass the\n // live list element it found from `event.currentTarget` (the\n // closure-captured `list` is detached after morph keeps the previous\n // multiselect DOM).\n const renderList = (target: HTMLElement, filter: string): void => {\n target.replaceChildren();\n const lower = filter.trim().toLowerCase();\n const matches = lower === \"\"\n ? items\n : items.filter((item) =>\n item.label.toLowerCase().includes(lower) ||\n item.value.toLowerCase().includes(lower),\n );\n if (matches.length === 0) {\n target.append(el(\"div\", { class: \"rui-multiselect-empty\" }, [emptyLabel]));\n return;\n }\n for (const item of matches) {\n const isSelected = selectedSet.has(item.value);\n const atCap = !isSelected && max > 0 && selected.length >= max;\n const option = el(\"button\", {\n type: \"button\",\n class: \"rui-multiselect-option\",\n role: \"option\",\n \"data-value\": item.value,\n \"data-selected\": isSelected ? \"true\" : \"false\",\n \"aria-selected\": isSelected ? \"true\" : \"false\",\n disabled: atCap ? \"\" : null,\n });\n const checkbox = el(\"span\", { class: \"rui-multiselect-option-check\" });\n const checkIcon = renderIcon(isSelected ? \"check\" : \"\", { className: \"rui-multiselect-option-check-icon\" });\n if (checkIcon) checkbox.append(checkIcon);\n option.append(checkbox);\n option.append(el(\"span\", { class: \"rui-multiselect-option-label\" }, [item.label]));\n option.onclick = (event) => {\n event.stopPropagation();\n if (atCap) return;\n const next = isSelected\n ? selected.filter((v) => v !== item.value)\n : [...selected, item.value];\n writeSelection(next);\n };\n target.append(option);\n }\n };\n\n renderList(list, filterSlot.get());\n\n filterInput.oninput = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n filterSlot.set(target.value);\n const liveList = target.closest(\".rui-multiselect-panel\")\n ?.querySelector(\".rui-multiselect-list\") as HTMLElement | null;\n if (liveList) renderList(liveList, target.value);\n };\n\n triggerBtn.onclick = (event) => {\n if (disabled) return;\n event.stopPropagation();\n const next = !openSlot.get();\n openSlot.set(next);\n const live = (event.currentTarget as Element).closest(\".rui-multiselect\") as HTMLElement | null;\n live?.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n live?.querySelector(\".rui-multiselect-trigger\")\n ?.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n if (!live) return;\n if (!next) { disposeDismissListeners(live); return; }\n setTimeout(() => filterInput.focus(), 0);\n installDismissListeners({\n liveRoot: live,\n onDismiss: () => {\n openSlot.set(false);\n filterSlot.set(\"\");\n live.setAttribute(\"data-open\", \"false\");\n live.querySelector(\".rui-multiselect-trigger\")\n ?.setAttribute(\"aria-expanded\", \"false\");\n },\n });\n };\n\n root.append(panel);\n return root;\n },\n};\n\nexport const DateRangePicker: ComponentSpec = {\n name: \"DateRangePicker\",\n description:\n \"Paired date inputs with a single label, sharing the same min/max \" +\n \"range. Pass `$variable` references for both `from` and `to` to \" +\n \"two-way-bind a date range (ISO `YYYY-MM-DD` strings).\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"from\", type: \"string\", optional: true, description: \"ISO date start; typically $variable\" },\n { name: \"to\", type: \"string\", optional: true, description: \"ISO date end; typically $variable\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"min\", type: \"string\", optional: true, description: \"Earliest selectable ISO date\" },\n { name: \"max\", type: \"string\", optional: true, description: \"Latest selectable ISO date\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with `{from, to}` whenever either endpoint changes\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const fromId = `${id}-from`;\n const toId = `${id}-to`;\n const min = asString(props.min);\n const max = asString(props.max);\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", { class: \"rui-date-range-picker\", \"data-disabled\": disabled ? \"true\" : \"false\" });\n const label = asString(props.label);\n if (label) root.append(el(\"label\", { class: \"rui-date-range-picker-label\", for: fromId }, [label]));\n const row = el(\"div\", { class: \"rui-date-range-picker-row\" });\n const fromInput = el(\"input\", {\n type: \"date\",\n class: \"rui-date-range-picker-input\",\n id: fromId,\n name: fromId,\n value: asString(props.from),\n min: min || null,\n max: max || null,\n disabled: disabled ? \"\" : null,\n \"data-role\": \"from\",\n });\n row.append(fromInput);\n row.append(el(\"span\", { class: \"rui-date-range-picker-separator\", \"aria-hidden\": \"true\" }, [\"–\"]));\n const toInput = el(\"input\", {\n type: \"date\",\n class: \"rui-date-range-picker-input\",\n id: toId,\n name: toId,\n value: asString(props.to),\n min: min || null,\n max: max || null,\n disabled: disabled ? \"\" : null,\n \"data-role\": \"to\",\n });\n row.append(toInput);\n root.append(row);\n const fromState = node.argMeta?.[1]?.stateRef;\n const toState = node.argMeta?.[2]?.stateRef;\n if (fromState) helpers.bindState(fromInput, fromState);\n if (toState) helpers.bindState(toInput, toState);\n if (props.onChange != null) {\n const readRange = (target: HTMLInputElement) => {\n const wrapper = target.closest(\".rui-date-range-picker\");\n const from = wrapper?.querySelector<HTMLInputElement>(\".rui-date-range-picker-input[data-role=\\\"from\\\"]\")?.value ?? \"\";\n const to = wrapper?.querySelector<HTMLInputElement>(\".rui-date-range-picker-input[data-role=\\\"to\\\"]\")?.value ?? \"\";\n return { from, to };\n };\n fromInput.addEventListener(\"change\", (e) => helpers.invoke(props.onChange, readRange(e.currentTarget as HTMLInputElement)));\n toInput.addEventListener(\"change\", (e) => helpers.invoke(props.onChange, readRange(e.currentTarget as HTMLInputElement)));\n }\n return root;\n },\n};\n\nfunction clampNumber(value: number, min: number, max: number): number {\n if (Number.isNaN(value)) return min === Number.NEGATIVE_INFINITY ? 0 : min;\n return Math.min(Math.max(value, min), max);\n}\n\n/** Searchable `Select` delegates to the Combobox renderer (value binds at arg index 4). */\nfunction renderSearchableSelect(\n node: ComponentNode,\n props: Record<string, unknown>,\n helpers: RenderHelpers,\n): Node {\n const meta = node.argMeta ? [...node.argMeta] : [];\n while (meta.length < 5) meta.push({});\n if (meta[4]?.stateRef) meta[2] = meta[4];\n const root = Combobox.render(\n { ...node, argMeta: meta } as ComponentNode,\n {\n id: props.id,\n items: props.items,\n value: props.value,\n placeholder: props.placeholder,\n emptyLabel: \"No matches\",\n disabled: false,\n },\n helpers,\n ) as HTMLElement;\n root.classList.add(\"rui-select-searchable\");\n return root;\n}\n\nfunction bindToStateAtArg(\n element: HTMLElement,\n node: { argMeta?: { stateRef?: string }[] },\n argIndex: number,\n helpers: {\n bindState: (\n el: HTMLElement,\n name: string,\n opts?: { event?: string; getValue?: (el: HTMLElement) => unknown },\n ) => void;\n },\n): void {\n const stateName = node.argMeta?.[argIndex]?.stateRef;\n if (!stateName) return;\n if (element instanceof HTMLInputElement && element.type === \"checkbox\") {\n helpers.bindState(element, stateName, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).checked,\n });\n return;\n }\n helpers.bindState(element, stateName);\n}\n\nfunction applyValidations(input: HTMLInputElement, validations: unknown): void {\n if (!validations) return;\n const list = Array.isArray(validations)\n ? validations.map((v) => String(v))\n : typeof validations === \"object\"\n ? Object.entries(validations as Record<string, unknown>).map(([k, v]) => (v ? `${k}:${v}` : k))\n : [];\n for (const v of list) {\n if (v === \"required\") input.required = true;\n else if (v.startsWith(\"minLength:\")) input.minLength = Number(v.slice(\"minLength:\".length)) || 0;\n else if (v.startsWith(\"maxLength:\")) input.maxLength = Number(v.slice(\"maxLength:\".length)) || 0;\n else if (v === \"email\") input.type = \"email\";\n }\n}\n","/**\n * Rich, opinionated layout patterns the LLM can reach for in a single line.\n *\n * Each component packs an entire UI idiom (hero, page header, empty state,\n * timeline, kanban board, …) into a small, predictable signature. The goal is\n * to let the LLM emit beautiful, dense UI without composing dozens of nested\n * primitives — the components below handle the visual hierarchy internally.\n *\n * Everything here is presentational: state binding is delegated to the\n * primitives the patterns embed (Button, Card, etc.), so the patterns stay\n * stateless and composable.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n sanitiseCssLength, sanitiseCssUrl, sanitiseImageSrc,\n} from \"../utils.js\";\nimport { renderAvatar, pickIconForLabel, pickIconForTone } from \"./_internal.js\";\nimport { SearchBar } from \"./forms.js\";\nimport { Grid } from \"./layout.js\";\n\nconst SURFACE_TONES = [\"default\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] as const;\n\nconst renderActionsRow = (\n raw: unknown,\n helpers: { renderNode: (n: unknown) => Node },\n): HTMLElement | null => {\n const items = asArray<unknown>(raw);\n if (items.length === 0) return null;\n const row = el(\"div\", { class: \"rui-pattern-actions\" });\n for (const item of items) row.append(helpers.renderNode(item));\n return row;\n};\n\n/**\n * Pick a short eyebrow tag for a Hero based on intent keywords in its title\n * or subtitle. Returns the empty string when no rule matches so the caller\n * can decide whether to render the band at all.\n */\nconst HERO_EYEBROW_RULES: Array<{ match: RegExp; label: string }> = [\n { match: /\\bbeta\\b/i, label: \"Beta\" },\n { match: /\\b(early\\s?access|preview)\\b/i, label: \"Preview\" },\n { match: /\\b(introduc(?:ing|e)|launch(?:ed|ing)?|announcing)\\b/i, label: \"Introducing\" },\n { match: /\\b(welcome\\b|get(?:ting)?\\s?started)/i, label: \"Welcome\" },\n { match: /\\b(new\\b|whats\\s?new|now\\b)/i, label: \"What's new\" },\n { match: /\\bfree\\b/i, label: \"Free trial\" },\n { match: /\\bupgrade\\b/i, label: \"Upgrade\" },\n { match: /\\b(sale|discount|deal)\\b/i, label: \"Limited time\" },\n];\n\nfunction deriveHeroEyebrow(title: string, subtitle: string): string {\n const haystack = `${title} ${subtitle}`.trim();\n if (!haystack) return \"\";\n for (const rule of HERO_EYEBROW_RULES) {\n if (rule.match.test(haystack)) return rule.label;\n }\n return \"\";\n}\n\nexport const Hero: ComponentSpec = {\n name: \"Hero\",\n description:\n \"Eye-catching landing/marketing header with eyebrow tag, title, subtitle, \" +\n \"optional bullet highlights, and primary/secondary CTA buttons. Use \" +\n \"`layout=\\\"cover\\\"` with `imageSrc` for an image-backed hero band \" +\n \"(pass `height` and optional `caption`). Default layout shows an \" +\n \"optional side illustration.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"subtitle\", type: \"string\", optional: true },\n { name: \"primary\", type: \"Button\", optional: true, description: \"Primary CTA — pass a Button(...)\" },\n { name: \"secondary\", type: \"Button\", optional: true, description: \"Secondary CTA — pass a Button(...)\" },\n { name: \"eyebrow\", type: \"string\", optional: true, description: \"Short uppercase tag above the title\" },\n { name: \"highlights\", type: \"string[]\", optional: true, description: \"Bullet items rendered as tag pills\" },\n { name: \"imageSrc\", type: \"string\", optional: true, description: \"Illustration or cover background when layout=cover\" },\n { name: \"caption\", type: \"string\", optional: true, description: \"Small caption above CTAs (cover layout)\" },\n { name: \"height\", type: \"string\", optional: true, description: \"Min-height for cover layout (default 280px)\" },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"CTA row (cover layout; alternative to primary/secondary)\" },\n { name: \"layout\", type: \"string\", optional: true, enum: [\"default\", \"cover\"], description: \"default = text-first; cover = image-backed band\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES, description: \"Accent tone\" },\n ],\n render: (_node, props, helpers) => {\n const layout = asString(props.layout, \"default\");\n const heroTitle = asString(props.title);\n const heroSubtitle = asString(props.subtitle);\n const explicitEyebrow = asString(props.eyebrow);\n const eyebrow = explicitEyebrow || deriveHeroEyebrow(heroTitle, heroSubtitle);\n const tone = asString(props.tone, \"primary\");\n\n if (layout === \"cover\") {\n const safeImageSrc = sanitiseCssUrl(asString(props.imageSrc));\n const safeHeight = sanitiseCssLength(asString(props.height), \"280px\");\n const root = el(\"section\", {\n class: \"rui-cover\",\n \"data-tone\": tone,\n style: `background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url(\"${safeImageSrc}\");min-height:${safeHeight};`,\n });\n const body = el(\"div\", { class: \"rui-cover-body\" });\n if (eyebrow) body.append(el(\"span\", { class: \"rui-cover-eyebrow\" }, [eyebrow]));\n body.append(el(\"h1\", { class: \"rui-cover-title\" }, [heroTitle]));\n if (heroSubtitle) body.append(el(\"p\", { class: \"rui-cover-subtitle\" }, [heroSubtitle]));\n const caption = asString(props.caption);\n if (caption) body.append(el(\"p\", { class: \"rui-cover-caption\" }, [caption]));\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-cover-actions\");\n body.append(actions);\n } else {\n const ctaItems = [props.primary, props.secondary].filter(Boolean);\n if (ctaItems.length > 0) {\n const ctas = el(\"div\", { class: \"rui-cover-actions rui-pattern-actions\" });\n for (const cta of ctaItems) ctas.append(helpers.renderNode(cta));\n body.append(ctas);\n }\n }\n root.append(body);\n return root;\n }\n\n const heroImageSrc = sanitiseImageSrc(props.imageSrc);\n const root = el(\"section\", {\n class: \"rui-hero\",\n \"data-tone\": tone,\n \"data-has-image\": heroImageSrc ? \"true\" : \"false\",\n });\n const body = el(\"div\", { class: \"rui-hero-body\" });\n if (eyebrow) body.append(el(\"span\", { class: \"rui-hero-eyebrow\" }, [eyebrow]));\n body.append(el(\"h1\", { class: \"rui-hero-title\" }, [heroTitle]));\n if (heroSubtitle) body.append(el(\"p\", { class: \"rui-hero-subtitle\" }, [heroSubtitle]));\n const highlights = asArray<unknown>(props.highlights);\n if (highlights.length > 0) {\n const tags = el(\"div\", { class: \"rui-hero-highlights\" });\n for (const h of highlights) {\n const label = asString(h);\n if (label) tags.append(el(\"span\", { class: \"rui-hero-highlight\" }, [label]));\n }\n body.append(tags);\n }\n const ctaItems = [props.primary, props.secondary].filter(Boolean);\n if (ctaItems.length > 0) {\n const ctas = el(\"div\", { class: \"rui-hero-ctas\" });\n for (const cta of ctaItems) ctas.append(helpers.renderNode(cta));\n body.append(ctas);\n }\n root.append(body);\n if (heroImageSrc) {\n const media = el(\"div\", { class: \"rui-hero-media\" });\n media.append(el(\"img\", { src: heroImageSrc, alt: \"\", loading: \"lazy\" }));\n root.append(media);\n }\n return root;\n },\n};\n\nexport const PageHeader: ComponentSpec = {\n name: \"PageHeader\",\n description:\n \"Page-level header with breadcrumbs, title, subtitle, status tag, and a \" +\n \"right-aligned actions row. The canonical first child for any dashboard, \" +\n \"settings, or detail page — replaces ad-hoc Stack+Header+Buttons stitching. \" +\n \"If `breadcrumbs` is omitted the component auto-derives `[\\\"Home\\\", title]` \" +\n \"so the page never lacks a trail. Pass `breadcrumbs=false` to opt out.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"subtitle\", type: \"string\", optional: true },\n { name: \"breadcrumbs\", type: \"string[] | Breadcrumb | false\", optional: true, description: \"Array of strings, a Breadcrumb(...) node, or `false` to suppress the auto-derived trail\" },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Buttons / NavLinks shown on the right\" },\n { name: \"status\", type: \"Badge\", optional: true, aliases: [\"badge\"], description: \"Optional Badge(...) rendered next to the title\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"header\", { class: \"rui-page-header\" });\n\n const title = asString(props.title);\n // Default: auto-derive [\"Home\", title] when caller omits breadcrumbs.\n // Pass `breadcrumbs=false` to suppress (handy for sign-in screens).\n let crumbs: unknown = props.breadcrumbs;\n if (crumbs === undefined || crumbs === null) {\n if (title) crumbs = [\"Home\", title];\n } else if (crumbs === false || crumbs === \"false\") {\n crumbs = null;\n }\n\n if (crumbs) {\n const crumbWrap = el(\"div\", { class: \"rui-page-header-breadcrumbs\" });\n if (Array.isArray(crumbs)) {\n crumbs.forEach((c, i) => {\n if (i > 0) crumbWrap.append(el(\"span\", { class: \"rui-page-header-crumb-sep\" }, [\"/\"]));\n crumbWrap.append(el(\"span\", { class: \"rui-page-header-crumb\" }, [asString(c)]));\n });\n } else {\n crumbWrap.append(helpers.renderNode(crumbs));\n }\n root.append(crumbWrap);\n }\n\n const titleRow = el(\"div\", { class: \"rui-page-header-title-row\" });\n const titleBlock = el(\"div\", { class: \"rui-page-header-title-block\" });\n const titleLine = el(\"div\", { class: \"rui-page-header-title-line\" });\n titleLine.append(el(\"h1\", { class: \"rui-page-header-title\" }, [title]));\n if (props.status) titleLine.append(helpers.renderNode(props.status));\n titleBlock.append(titleLine);\n\n const subtitle = asString(props.subtitle);\n if (subtitle) titleBlock.append(el(\"p\", { class: \"rui-page-header-subtitle\" }, [subtitle]));\n titleRow.append(titleBlock);\n\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-page-header-actions\");\n titleRow.append(actions);\n }\n\n root.append(titleRow);\n return root;\n },\n};\n\nexport const EmptyState: ComponentSpec = {\n name: \"EmptyState\",\n description:\n \"Zero-state placeholder for empty lists, searches, dashboards. Renders \" +\n \"a centered icon (or illustration), title, description, and either a \" +\n \"single `action` Button or an `actions` row (primary + secondary). \" +\n \"Always preferable to an empty Card with raw text.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name (defaults to \\\"inbox\\\")\" },\n { name: \"illustration\", type: \"string\", optional: true, description: \"Image URL — takes precedence over `icon` when provided\" },\n { name: \"action\", type: \"Button\", optional: true, description: \"Single CTA (legacy slot)\" },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Row of CTA Buttons / Links — preferred over `action` for primary + secondary affordances\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-empty-state\" });\n const illustration = sanitiseImageSrc(props.illustration);\n if (illustration) {\n root.append(el(\"img\", {\n class: \"rui-empty-state-illustration\",\n src: illustration,\n alt: \"\",\n loading: \"lazy\",\n }));\n } else {\n const title = asString(props.title);\n const description = asString(props.description);\n const iconName =\n asString(props.icon) ||\n pickIconForLabel(`${title} ${description}`) ||\n \"inbox\";\n const iconNode = renderIcon(iconName, { className: \"rui-empty-state-icon\" });\n if (iconNode) root.append(iconNode);\n }\n root.append(el(\"h3\", { class: \"rui-empty-state-title\" }, [asString(props.title)]));\n const desc = asString(props.description);\n if (desc) root.append(el(\"p\", { class: \"rui-empty-state-description\" }, [desc]));\n const actions = asArray<unknown>(props.actions);\n if (actions.length > 0) {\n const row = el(\"div\", { class: \"rui-empty-state-actions\" });\n for (const item of actions) row.append(helpers.renderNode(item));\n root.append(row);\n } else if (props.action) {\n const wrap = el(\"div\", { class: \"rui-empty-state-action\" });\n wrap.append(helpers.renderNode(props.action));\n root.append(wrap);\n }\n return root;\n },\n};\n\nexport const TimelineItem: ComponentSpec = {\n name: \"TimelineItem\",\n description: \"Single event on a Timeline.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"time\", type: \"string\", optional: true, description: \"Display label (ISO, relative, etc.)\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name rendered inside the marker\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n ],\n render: (_node, props) => {\n const li = el(\"li\", {\n class: \"rui-timeline-item\",\n \"data-tone\": asString(props.tone, \"default\"),\n });\n const marker = el(\"span\", { class: \"rui-timeline-marker\" });\n const iconNode = renderIcon(props.icon);\n if (iconNode) marker.append(iconNode);\n li.append(marker);\n\n const body = el(\"div\", { class: \"rui-timeline-body\" });\n const head = el(\"div\", { class: \"rui-timeline-head\" });\n head.append(el(\"span\", { class: \"rui-timeline-title\" }, [asString(props.title)]));\n const time = asString(props.time);\n if (time) head.append(el(\"span\", { class: \"rui-timeline-time\" }, [time]));\n body.append(head);\n\n const desc = asString(props.description);\n if (desc) body.append(el(\"div\", { class: \"rui-timeline-description\" }, [desc]));\n\n li.append(body);\n return li;\n },\n};\n\nexport const Timeline: ComponentSpec = {\n name: \"Timeline\",\n description:\n \"Vertical event timeline. Children must be TimelineItem entries. Ideal \" +\n \"for activity feeds, changelogs, and process flows.\",\n props: [{ name: \"items\", type: \"TimelineItem[]\" }],\n render: (_node, props, helpers) => {\n const root = el(\"ol\", { class: \"rui-timeline\" });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const FeatureItem: ComponentSpec = {\n name: \"FeatureItem\",\n description: \"Single tile on a FeatureGrid.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name shown in a colored disc\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n ],\n render: (_node, props) => {\n const root = el(\"div\", {\n class: \"rui-feature-item\",\n \"data-tone\": asString(props.tone, \"primary\"),\n });\n const iconName = asString(props.icon, \"sparkles\");\n const iconNode = renderIcon(iconName, { className: \"rui-feature-icon\" });\n if (iconNode) root.append(iconNode);\n root.append(el(\"h3\", { class: \"rui-feature-title\" }, [asString(props.title)]));\n const desc = asString(props.description);\n if (desc) root.append(el(\"p\", { class: \"rui-feature-description\" }, [desc]));\n return root;\n },\n};\n\nexport const FeatureGrid: ComponentSpec = {\n name: \"FeatureGrid\",\n description:\n \"Responsive grid of FeatureItem tiles (typically 2–3 columns). Use to \" +\n \"highlight product capabilities or page categories.\",\n props: [\n { name: \"items\", type: \"FeatureItem[]\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"Preferred column count (default auto)\" },\n ],\n render: (_node, props, helpers) => {\n const columns = Math.max(1, Math.min(4, Number(props.columns ?? \"auto\")));\n const root = el(\"div\", {\n class: \"rui-feature-grid\",\n \"data-columns\": columns > 0 ? String(columns) : null,\n });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const Testimonial: ComponentSpec = {\n name: \"Testimonial\",\n description: \"Quote card with author, role, and optional avatar.\",\n props: [\n { name: \"quote\", type: \"string\" },\n { name: \"author\", type: \"string\", aliases: [\"name\"] },\n { name: \"role\", type: \"string\", optional: true },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"] },\n { name: \"rating\", type: \"number\", optional: true, description: \"0–5 stars\" },\n ],\n render: (_node, props) => {\n const root = el(\"figure\", { class: \"rui-testimonial\" });\n const rating = Math.max(0, Math.min(5, Math.round(Number(props.rating ?? 0))));\n if (rating > 0) {\n const stars = el(\"div\", { class: \"rui-testimonial-rating\" });\n for (let i = 0; i < 5; i += 1) {\n const filled = i < rating;\n const icon = renderIcon(filled ? \"star\" : \"regular:star\", { className: \"rui-testimonial-rating-star\" });\n if (icon) stars.append(icon);\n }\n root.append(stars);\n }\n root.append(el(\"blockquote\", { class: \"rui-testimonial-quote\" }, [\n asString(props.quote),\n ]));\n const footer = el(\"figcaption\", { class: \"rui-testimonial-author\" });\n const avatarSrc = sanitiseImageSrc(props.avatarSrc);\n if (avatarSrc) {\n footer.append(el(\"img\", { class: \"rui-testimonial-avatar\", src: avatarSrc, alt: \"\" }));\n }\n const meta = el(\"div\", { class: \"rui-testimonial-meta\" });\n meta.append(el(\"div\", { class: \"rui-testimonial-name\" }, [asString(props.author)]));\n const role = asString(props.role);\n if (role) meta.append(el(\"div\", { class: \"rui-testimonial-role\" }, [role]));\n footer.append(meta);\n root.append(footer);\n return root;\n },\n};\n\nexport const ProfileCard: ComponentSpec = {\n name: \"ProfileCard\",\n description:\n \"Compact profile/user card with avatar, name, role, optional bio, social \" +\n \"tags, and a row of action buttons. Use for team rosters, contributor \" +\n \"lists, and contact panels.\",\n props: [\n { name: \"name\", type: \"string\" },\n { name: \"role\", type: \"string\", optional: true },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"], description: \"Avatar image src; falls back to initials\" },\n { name: \"bio\", type: \"string\", optional: true },\n { name: \"tags\", type: \"string[]\", optional: true },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Buttons to render at the bottom\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-profile-card\" });\n const header = el(\"div\", { class: \"rui-profile-card-header\" });\n header.append(renderAvatar(asString(props.avatarSrc), asString(props.name), \"lg\"));\n const meta = el(\"div\", { class: \"rui-profile-card-meta\" });\n meta.append(el(\"h3\", { class: \"rui-profile-card-name\" }, [asString(props.name)]));\n const role = asString(props.role);\n if (role) meta.append(el(\"p\", { class: \"rui-profile-card-role\" }, [role]));\n header.append(meta);\n root.append(header);\n\n const bio = asString(props.bio);\n if (bio) root.append(el(\"p\", { class: \"rui-profile-card-bio\" }, [bio]));\n\n const tags = asArray<unknown>(props.tags);\n if (tags.length > 0) {\n const tagRow = el(\"div\", { class: \"rui-profile-card-tags\" });\n for (const t of tags) {\n const label = asString(t);\n if (label) tagRow.append(el(\"span\", { class: \"rui-tag\", \"data-size\": \"sm\" }, [\n el(\"span\", { class: \"rui-tag-label\" }, [label]),\n ]));\n }\n root.append(tagRow);\n }\n\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-profile-card-actions\");\n root.append(actions);\n }\n return root;\n },\n};\n\nexport const Comment: ComponentSpec = {\n name: \"Comment\",\n description:\n \"Single comment / message bubble. Renders avatar, author, timestamp, \" +\n \"body, and an optional row of toolbar buttons (reply, like, …).\",\n props: [\n { name: \"author\", type: \"string\" },\n { name: \"body\", type: \"string\", aliases: [\"text\", \"message\"] },\n { name: \"time\", type: \"string\", optional: true, description: \"Relative or absolute timestamp\" },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"] },\n { name: \"actions\", type: \"Node[]\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"article\", { class: \"rui-comment\" });\n root.append(renderAvatar(asString(props.avatarSrc), asString(props.author), \"md\"));\n const body = el(\"div\", { class: \"rui-comment-body\" });\n const head = el(\"header\", { class: \"rui-comment-header\" });\n head.append(el(\"span\", { class: \"rui-comment-author\" }, [asString(props.author)]));\n const time = asString(props.time);\n if (time) head.append(el(\"span\", { class: \"rui-comment-time\" }, [time]));\n body.append(head);\n body.append(el(\"div\", { class: \"rui-comment-content\" }, [asString(props.body)]));\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-comment-actions\");\n body.append(actions);\n }\n root.append(body);\n return root;\n },\n};\n\nexport const Banner: ComponentSpec = {\n name: \"Banner\",\n description:\n \"Full-width announcement banner. Use at the top of a page for promos, \" +\n \"release notes, or downtime notices. For inline notices prefer Callout \" +\n \"or Alert.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"message\", type: \"string\", optional: true, aliases: [\"description\"] },\n { name: \"action\", type: \"Button\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n ],\n render: (_node, props, helpers) => {\n const tone = asString(props.tone, \"primary\");\n const root = el(\"aside\", {\n class: \"rui-banner\",\n \"data-tone\": tone,\n });\n const iconName = asString(props.icon) || pickIconForTone(tone) || \"\";\n const iconNode = renderIcon(iconName, { className: \"rui-banner-icon\" });\n if (iconNode) root.append(iconNode);\n const body = el(\"div\", { class: \"rui-banner-body\" });\n body.append(el(\"strong\", { class: \"rui-banner-title\" }, [asString(props.title)]));\n const msg = asString(props.message);\n if (msg) body.append(el(\"span\", { class: \"rui-banner-message\" }, [msg]));\n root.append(body);\n if (props.action) {\n const wrap = el(\"div\", { class: \"rui-banner-action\" });\n wrap.append(helpers.renderNode(props.action));\n root.append(wrap);\n }\n return root;\n },\n};\n\nexport const KanbanCard: ComponentSpec = {\n name: \"KanbanCard\",\n description: \"Single card on a Kanban board.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"tags\", type: \"string[]\", optional: true },\n { name: \"assignee\", type: \"string\", optional: true, description: \"Name shown next to avatar initials\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name shown beside the title\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Optional callable fired when the card is clicked\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", {\n class: \"rui-kanban-card\",\n \"data-tone\": asString(props.tone, \"default\"),\n });\n if (typeof props.onClick === \"function\") {\n root.setAttribute(\"role\", \"button\");\n root.setAttribute(\"tabindex\", \"0\");\n root.onclick = () => helpers.invoke(props.onClick);\n root.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n helpers.invoke(props.onClick);\n }\n };\n }\n const titleEl = el(\"div\", { class: \"rui-kanban-card-title\" });\n const iconNode = renderIcon(props.icon, { className: \"rui-kanban-card-icon\" });\n if (iconNode) titleEl.append(iconNode);\n titleEl.append(document.createTextNode(asString(props.title)));\n root.append(titleEl);\n const desc = asString(props.description);\n if (desc) root.append(el(\"p\", { class: \"rui-kanban-card-description\" }, [desc]));\n\n const tags = asArray<unknown>(props.tags);\n if (tags.length > 0) {\n const tagRow = el(\"div\", { class: \"rui-kanban-card-tags\" });\n for (const t of tags) {\n const label = asString(t);\n if (label) tagRow.append(el(\"span\", { class: \"rui-tag\", \"data-size\": \"sm\" }, [\n el(\"span\", { class: \"rui-tag-label\" }, [label]),\n ]));\n }\n root.append(tagRow);\n }\n\n const assignee = asString(props.assignee);\n if (assignee) {\n const footer = el(\"footer\", { class: \"rui-kanban-card-footer\" });\n footer.append(renderAvatar(\"\", assignee, \"sm\"));\n footer.append(el(\"span\", { class: \"rui-kanban-card-assignee\" }, [assignee]));\n root.append(footer);\n }\n return root;\n },\n};\n\nexport const KanbanColumn: ComponentSpec = {\n name: \"KanbanColumn\",\n description: \"Single column inside a KanbanBoard. Children must be KanbanCard entries.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"items\", type: \"KanbanCard[]\", aliases: [\"cards\"] },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES, description: \"Header accent tone\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const root = el(\"section\", {\n class: \"rui-kanban-column\",\n \"data-tone\": asString(props.tone, \"default\"),\n });\n const header = el(\"header\", { class: \"rui-kanban-column-header\" });\n header.append(el(\"span\", { class: \"rui-kanban-column-title\" }, [asString(props.title)]));\n header.append(el(\"span\", { class: \"rui-kanban-column-count\" }, [String(items.length)]));\n root.append(header);\n const body = el(\"div\", { class: \"rui-kanban-column-body\" });\n for (const item of items) body.append(helpers.renderNode(item));\n if (items.length === 0) {\n body.append(el(\"div\", { class: \"rui-kanban-column-empty\" }, [\"No items\"]));\n }\n root.append(body);\n return root;\n },\n};\n\nexport const KanbanBoard: ComponentSpec = {\n name: \"KanbanBoard\",\n description:\n \"Horizontal Kanban board. Children must be KanbanColumn entries. The \" +\n \"board scrolls horizontally on narrow viewports so columns stay readable.\",\n props: [{ name: \"columns\", type: \"KanbanColumn[]\" }],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-kanban-board\" });\n for (const column of asArray(props.columns)) root.append(helpers.renderNode(column));\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Rich application-shell patterns\n *\n * These composites encode the most common SaaS-style page shells in a\n * single line, so the LLM can reach for them instead of stitching nested\n * Stacks/Cards by hand. They were added specifically to bridge the gap\n * between hand-rolled component demos and polished, real-world UIs.\n * ----------------------------------------------------------------------- */\n\nexport const SectionHeader: ComponentSpec = {\n name: \"SectionHeader\",\n description:\n \"Compact section header for the top of a Card or panel. Renders a small \" +\n \"eyebrow, a title, an optional subtitle, an optional status Tag/Badge, \" +\n \"and a right-aligned actions row. Use this inside a Card to introduce \" +\n \"a section instead of a bare `CardHeader`.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"subtitle\", type: \"string\", optional: true, aliases: [\"description\"] },\n { name: \"eyebrow\", type: \"string\", optional: true, description: \"Short uppercase label above the title\" },\n { name: \"status\", type: \"Badge | Tag\", optional: true, aliases: [\"badge\"] },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Buttons / Links shown on the right\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"header\", { class: \"rui-section-header\" });\n const left = el(\"div\", { class: \"rui-section-header-left\" });\n const eyebrow = asString(props.eyebrow);\n if (eyebrow) left.append(el(\"span\", { class: \"rui-section-header-eyebrow\" }, [eyebrow]));\n const titleLine = el(\"div\", { class: \"rui-section-header-title-line\" });\n titleLine.append(el(\"h3\", { class: \"rui-section-header-title\" }, [asString(props.title)]));\n if (props.status) titleLine.append(helpers.renderNode(props.status));\n left.append(titleLine);\n const subtitle = asString(props.subtitle);\n if (subtitle) left.append(el(\"p\", { class: \"rui-section-header-subtitle\" }, [subtitle]));\n root.append(left);\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-section-header-actions\");\n root.append(actions);\n }\n return root;\n },\n};\n\nexport const Toolbar: ComponentSpec = {\n name: \"Toolbar\",\n description:\n \"Horizontal toolbar for filters, search, view modes, and primary \" +\n \"actions. Left/center/right slots wrap onto separate rows on narrow \" +\n \"viewports so the bar never overflows. Pass `searchable: true` to \" +\n \"auto-mount a SearchBar in the left slot (bind `searchValue` to a \" +\n \"`$variable`). Use ABOVE a Table, List, Grid, or Kanban view — never \" +\n \"replace `PageHeader` with it.\",\n props: [\n { name: \"left\", type: \"Node[]\", optional: true, description: \"Filters / search inputs / chips\" },\n { name: \"right\", type: \"Node[]\", optional: true, description: \"Primary action buttons\" },\n { name: \"center\", type: \"Node[]\", optional: true, description: \"Centered controls (e.g. SegmentedControl, search bar)\" },\n { name: \"searchable\", type: \"boolean\", optional: true, description: \"Auto-mount a SearchBar at the start of the left slot\" },\n { name: \"searchPlaceholder\", type: \"string\", optional: true, description: \"Placeholder for the auto-mounted SearchBar\" },\n { name: \"searchValue\", type: \"string\", optional: true, description: \"$variable bound to the auto-mounted SearchBar\" },\n ],\n render: (_node, props, helpers) => {\n const center = asArray<unknown>(props.center);\n const root = el(\"div\", {\n class: \"rui-toolbar\",\n \"data-has-center\": center.length > 0 ? \"true\" : \"false\",\n });\n const left = el(\"div\", { class: \"rui-toolbar-side rui-toolbar-left\" });\n if (asBoolean(props.searchable)) {\n left.append(SearchBar.render(\n { __kind: \"Component\", name: \"SearchBar\", args: [], argMeta: [] },\n {\n id: \"toolbar-search\",\n placeholder: asString(props.searchPlaceholder, \"Search…\"),\n value: props.searchValue,\n },\n helpers,\n ));\n }\n for (const child of asArray(props.left)) left.append(helpers.renderNode(child));\n root.append(left);\n if (center.length > 0) {\n const centerWrap = el(\"div\", { class: \"rui-toolbar-side rui-toolbar-center\" });\n for (const child of center) centerWrap.append(helpers.renderNode(child));\n root.append(centerWrap);\n }\n const right = el(\"div\", { class: \"rui-toolbar-side rui-toolbar-right\" });\n for (const child of asArray(props.right)) right.append(helpers.renderNode(child));\n root.append(right);\n return root;\n },\n};\n\nexport const SidebarItem: ComponentSpec = {\n name: \"SidebarItem\",\n description:\n \"Single navigation item inside a Sidebar. Pass `active=true` to mark \" +\n \"as the current page, a `to` path to navigate via the runtime router \" +\n \"on click, an `onClick` callable for arbitrary click handling, or an \" +\n \"optional `badge` (string/number) for a trailing chip. `to` and \" +\n \"`onClick` can coexist — `onClick` is invoked AFTER the router \" +\n \"navigates so authors can do extra work (analytics, side-effects).\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name rendered before the label\" },\n { name: \"active\", type: \"boolean\", optional: true, description: \"Mark this item as the current page. When `to` is provided and `active` is omitted, the item auto-detects the active state from the current router path.\" },\n { name: \"badge\", type: \"string\", optional: true, description: \"Trailing chip (count or status)\" },\n { name: \"to\", type: \"string\", optional: true, description: \"Router path to navigate to on click (e.g. \\\"/\\\", \\\"/orders\\\"). Uses the runtime router — no full page reload.\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Callable invoked on click. Runs in addition to `to`-based navigation.\" },\n ],\n render: (_node, props, helpers) => {\n const to = asString(props.to);\n const explicitActive = props.active !== undefined && props.active !== null;\n const currentPath = to ? helpers.router.getPath() : \"\";\n // When the caller supplies `to` without an explicit `active`, derive\n // the active state from the current router path so a single declaration\n // (`SidebarItem(\"Home\", { to: \"/\", icon: \"house\" })`) renders the\n // active highlight without extra wiring.\n const autoActive = (() => {\n if (!to) return false;\n if (to === \"/\") return currentPath === \"/\";\n if (currentPath === to) return true;\n return currentPath.startsWith(to + \"/\");\n })();\n const isActive = explicitActive ? asBoolean(props.active) : autoActive;\n const root = el(\"button\", {\n type: \"button\",\n class: \"rui-sidebar-item\",\n \"data-active\": isActive ? \"true\" : \"false\",\n \"data-to\": to || null,\n });\n const iconNode = renderIcon(props.icon, { className: \"rui-sidebar-item-icon\" });\n if (iconNode) root.append(iconNode);\n root.append(el(\"span\", { class: \"rui-sidebar-item-label\" }, [asString(props.label)]));\n const badge = asString(props.badge);\n if (badge) root.append(el(\"span\", { class: \"rui-sidebar-item-badge\" }, [badge]));\n if (to || props.onClick != null) {\n root.onclick = (event) => {\n if (to) {\n // Honour modifier keys (Cmd/Ctrl + click etc.) the way an anchor\n // would — but the trigger is a <button>, so we have no native\n // fallback. Just navigate via the runtime router.\n const e = event as MouseEvent;\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n helpers.router.navigate(to);\n }\n if (props.onClick != null) helpers.invoke(props.onClick);\n };\n }\n return root;\n },\n};\n\nexport const SidebarSection: ComponentSpec = {\n name: \"SidebarSection\",\n description:\n \"Grouping inside a Sidebar — small uppercase label followed by \" +\n \"SidebarItem entries. Use this to chunk a long sidebar into sections.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"items\", type: \"SidebarItem[]\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-sidebar-section\" });\n const label = asString(props.label);\n if (label) root.append(el(\"div\", { class: \"rui-sidebar-section-label\" }, [label]));\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const Sidebar: ComponentSpec = {\n name: \"Sidebar\",\n description:\n \"Vertical app navigation panel. Supports a brand header, navigation \" +\n \"items (`SidebarItem` or `SidebarSection`), an optional footer, and a \" +\n \"`collapsed` mode that hides labels to leave just an icon rail. Use \" +\n \"inside `AppShell` for SaaS-style left navigation.\",\n props: [\n { name: \"items\", type: \"(SidebarItem | SidebarSection)[]\" },\n { name: \"brand\", type: \"string\", optional: true, description: \"Product name / workspace label at the top\" },\n { name: \"tagline\", type: \"string\", optional: true },\n { name: \"footer\", type: \"Node[]\", optional: true, description: \"Footer block (Avatar + name, upgrade CTA, …)\" },\n { name: \"collapsed\", type: \"boolean\", optional: true, description: \"Render as an icon-only rail (hides labels/badges)\" },\n ],\n render: (_node, props, helpers) => {\n const collapsed = asBoolean(props.collapsed);\n const root = el(\"aside\", { class: \"rui-sidebar\" });\n if (collapsed) root.dataset.collapsed = \"true\";\n const brand = asString(props.brand);\n const tagline = asString(props.tagline);\n if (brand || tagline) {\n const header = el(\"div\", { class: \"rui-sidebar-header\" });\n if (brand) header.append(el(\"div\", { class: \"rui-sidebar-brand\" }, [brand]));\n if (tagline) header.append(el(\"div\", { class: \"rui-sidebar-tagline\" }, [tagline]));\n root.append(header);\n }\n const body = el(\"nav\", { class: \"rui-sidebar-body\" });\n for (const item of asArray(props.items)) body.append(helpers.renderNode(item));\n root.append(body);\n const footerItems = asArray<unknown>(props.footer);\n if (footerItems.length > 0) {\n const footer = el(\"div\", { class: \"rui-sidebar-footer\" });\n for (const item of footerItems) footer.append(helpers.renderNode(item));\n root.append(footer);\n }\n return root;\n },\n};\n\nexport const AppShell: ComponentSpec = {\n name: \"AppShell\",\n description:\n \"Canonical SaaS application shell: optional top bar, fixed left \" +\n \"Sidebar, and scrollable main content. Reach for this whenever a \" +\n \"response represents a full product surface (dashboard with nav, \" +\n \"settings + sections, admin panels). Pass `collapsible=true` to render \" +\n \"a hamburger that turns the sidebar into a slide-over drawer on narrow \" +\n \"viewports.\",\n props: [\n { name: \"sidebar\", type: \"Sidebar\", description: \"Pass a Sidebar(...) node\" },\n { name: \"content\", type: \"Node[]\", description: \"Main content (typically starts with a PageHeader)\" },\n { name: \"topbar\", type: \"Node[]\", optional: true, description: \"Optional thin top bar above the content\" },\n { name: \"collapsible\", type: \"boolean\", optional: true, description: \"Show a hamburger that toggles the sidebar drawer on mobile\" },\n { name: \"sidebarOpen\", type: \"boolean\", optional: true, description: \"$variable controlling whether the mobile drawer is open\" },\n ],\n render: (_node, props, helpers) => {\n const collapsible = asBoolean(props.collapsible);\n const sidebarOpen = asBoolean(props.sidebarOpen);\n const root = el(\"div\", { class: \"rui-app-shell\" });\n if (collapsible) root.dataset.collapsible = \"true\";\n if (sidebarOpen) root.dataset.sidebarOpen = \"true\";\n const sidebarHost = el(\"div\", { class: \"rui-app-shell-sidebar\" });\n sidebarHost.append(helpers.renderNode(props.sidebar));\n root.append(sidebarHost);\n if (collapsible) {\n const scrim = el(\"div\", { class: \"rui-app-shell-scrim\", \"aria-hidden\": \"true\" });\n scrim.addEventListener(\"click\", () => {\n delete root.dataset.sidebarOpen;\n });\n root.append(scrim);\n }\n const main = el(\"div\", { class: \"rui-app-shell-main\" });\n const topbar = asArray<unknown>(props.topbar);\n if (topbar.length > 0 || collapsible) {\n const bar = el(\"div\", { class: \"rui-app-shell-topbar\" });\n if (collapsible) {\n const toggle = el(\"button\", {\n class: \"rui-app-shell-toggle\",\n type: \"button\",\n \"aria-label\": \"Toggle navigation\",\n });\n toggle.append(renderIcon(\"bars\", { size: \"md\" }) ?? document.createTextNode(\"≡\"));\n toggle.addEventListener(\"click\", () => {\n if (root.dataset.sidebarOpen) delete root.dataset.sidebarOpen;\n else root.dataset.sidebarOpen = \"true\";\n });\n bar.append(toggle);\n }\n for (const item of topbar) bar.append(helpers.renderNode(item));\n main.append(bar);\n }\n const content = el(\"div\", { class: \"rui-app-shell-content\" });\n for (const child of asArray(props.content)) content.append(helpers.renderNode(child));\n main.append(content);\n root.append(main);\n return root;\n },\n};\n\nexport const SplitView: ComponentSpec = {\n name: \"SplitView\",\n description:\n \"Two-pane master/detail layout — a narrow primary pane on the left, \" +\n \"wider detail pane on the right. Collapses to a single column on \" +\n \"narrow viewports. Use for inboxes, file browsers, contact lists.\",\n props: [\n { name: \"primary\", type: \"Node[]\", description: \"Master pane content (list, filters)\" },\n { name: \"detail\", type: \"Node[]\", aliases: [\"secondary\"], description: \"Detail pane content (selected item, empty state)\" },\n { name: \"primaryWidth\", type: \"string\", optional: true, aliases: [\"splitAt\"], description: \"CSS width for the primary pane (default 320px)\" },\n ],\n render: (_node, props, helpers) => {\n const width = sanitiseCssLength(asString(props.primaryWidth), \"320px\");\n const root = el(\"div\", { class: \"rui-split-view\", style: `--rui-split-primary:${width}` });\n const primary = el(\"div\", { class: \"rui-split-view-primary\" });\n for (const child of asArray(props.primary)) primary.append(helpers.renderNode(child));\n const detail = el(\"div\", { class: \"rui-split-view-detail\" });\n for (const child of asArray(props.detail)) detail.append(helpers.renderNode(child));\n root.append(primary, detail);\n return root;\n },\n};\n\nexport const DescriptionItem: ComponentSpec = {\n name: \"DescriptionItem\",\n description:\n \"Single row inside a DescriptionList. Renders a small uppercase \" +\n \"label on the left and a value (string or arbitrary Node) on the right.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"value\", type: \"Node | string\" },\n { name: \"icon\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-description-item\" });\n const labelWrap = el(\"dt\", { class: \"rui-description-label\" });\n const iconNode = renderIcon(props.icon, { className: \"rui-description-icon\" });\n if (iconNode) labelWrap.append(iconNode);\n labelWrap.append(document.createTextNode(asString(props.label)));\n const value = el(\"dd\", { class: \"rui-description-value\" });\n if (props.value && typeof props.value === \"object\" && (props.value as { __kind?: string }).__kind === \"Component\") {\n value.append(helpers.renderNode(props.value));\n } else {\n value.append(document.createTextNode(asString(props.value)));\n }\n root.append(labelWrap, value);\n return root;\n },\n};\n\nexport const DescriptionList: ComponentSpec = {\n name: \"DescriptionList\",\n description:\n \"Compact key/value summary for detail pages — replaces a row of \" +\n \"`Text`s with a properly aligned `<dl>`. Children must be \" +\n \"DescriptionItem entries. Two columns by default on wide viewports.\",\n props: [\n { name: \"items\", type: \"DescriptionItem[]\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"1 or 2 (default 2)\" },\n ],\n render: (_node, props, helpers) => {\n const columns = Math.max(1, Math.min(2, Math.floor(Number(props.columns ?? 2))));\n const root = el(\"dl\", {\n class: \"rui-description-list\",\n \"data-columns\": String(columns),\n });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const StatusDot: ComponentSpec = {\n name: \"StatusDot\",\n description:\n \"Inline status pip + label. Use for compact health/state indicators \" +\n \"in toolbars, sidebars, lists, and table cells.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"default\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n { name: \"pulse\", type: \"boolean\", optional: true, description: \"Animate the dot for 'live' state\" },\n ],\n render: (_node, props) => {\n const root = el(\"span\", {\n class: \"rui-status-dot\",\n \"data-tone\": asString(props.tone, \"success\"),\n \"data-pulse\": asBoolean(props.pulse) ? \"true\" : \"false\",\n });\n root.append(el(\"span\", { class: \"rui-status-dot-marker\" }));\n root.append(el(\"span\", { class: \"rui-status-dot-label\" }, [asString(props.label)]));\n return root;\n },\n};\n\nexport const PricingCard: ComponentSpec = {\n name: \"PricingCard\",\n description:\n \"Single pricing tier card with plan name, price, billing period, \" +\n \"description, bullet features, and a CTA button. Mark one tier as \" +\n \"`featured=true` to highlight it (raises the card, adds a ribbon).\",\n props: [\n { name: \"plan\", type: \"string\", description: \"Tier name (e.g. 'Pro')\" },\n { name: \"price\", type: \"string\", description: \"Display price (e.g. '$29')\" },\n { name: \"period\", type: \"string\", optional: true, description: \"Billing period (e.g. '/mo')\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"features\", type: \"string[]\", optional: true, description: \"Bullet list of included features\" },\n { name: \"action\", type: \"Button\", optional: true, aliases: [\"cta\"], description: \"Primary CTA — pass a Button(...)\" },\n { name: \"badge\", type: \"string\", optional: true, description: \"Eyebrow / badge above the plan name\" },\n { name: \"featured\", type: \"boolean\", optional: true, aliases: [\"highlighted\"] },\n ],\n render: (_node, props, helpers) => {\n const featured = asBoolean(props.featured);\n const root = el(\"article\", {\n class: \"rui-pricing-card\",\n \"data-featured\": featured ? \"true\" : \"false\",\n });\n const badge = asString(props.badge);\n if (badge) root.append(el(\"div\", { class: \"rui-pricing-card-badge\" }, [badge]));\n root.append(el(\"h3\", { class: \"rui-pricing-card-plan\" }, [asString(props.plan)]));\n const description = asString(props.description);\n if (description) root.append(el(\"p\", { class: \"rui-pricing-card-description\" }, [description]));\n const priceRow = el(\"div\", { class: \"rui-pricing-card-price-row\" });\n priceRow.append(el(\"span\", { class: \"rui-pricing-card-price\" }, [asString(props.price)]));\n const period = asString(props.period);\n if (period) priceRow.append(el(\"span\", { class: \"rui-pricing-card-period\" }, [period]));\n root.append(priceRow);\n const features = asArray<unknown>(props.features);\n if (features.length > 0) {\n const list = el(\"ul\", { class: \"rui-pricing-card-features\" });\n for (const f of features) {\n const label = asString(f);\n if (!label) continue;\n const check = renderIcon(\"circle-check\", { className: \"rui-pricing-card-check\" })\n ?? el(\"span\", { class: \"rui-pricing-card-check\" });\n list.append(el(\"li\", { class: \"rui-pricing-card-feature\" }, [\n check,\n document.createTextNode(label),\n ]));\n }\n root.append(list);\n }\n if (props.action) {\n const wrap = el(\"div\", { class: \"rui-pricing-card-action\" });\n wrap.append(helpers.renderNode(props.action));\n root.append(wrap);\n }\n return root;\n },\n};\n\nexport const PricingTable: ComponentSpec = {\n name: \"PricingTable\",\n description:\n \"Responsive grid of PricingCard tiers. Items size uniformly across a \" +\n \"row and wrap onto multiple rows on narrow viewports. Use as the \" +\n \"centerpiece of any pricing or upgrade page.\",\n props: [\n { name: \"tiers\", type: \"PricingCard[]\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"Preferred column count (default auto)\" },\n ],\n render: (_node, props, helpers) => {\n const columns = Math.max(1, Math.min(4, Math.floor(Number(props.columns ?? \"auto\"))));\n const root = el(\"div\", {\n class: \"rui-pricing-table\",\n \"data-columns\": columns > 0 ? String(columns) : null,\n });\n for (const tier of asArray(props.tiers)) root.append(helpers.renderNode(tier));\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Richer composition primitives\n *\n * These small, named patterns close the remaining gap between hand-rolled\n * `Stack(Card([...]))` blocks and the polished, dense layouts that LLMs\n * produce with shadcn/ui or Tailwind. Each component covers a recurring\n * UI motif (cover hero, media card, compact stat strip, icon tile, person\n * chip, inline notification) so the LLM can reach for a single line.\n * ----------------------------------------------------------------------- */\n\nexport const MediaCard: ComponentSpec = {\n name: \"MediaCard\",\n description:\n \"Card with a media (image) header followed by title, body, optional \" +\n \"tags, footer meta, and an actions row. Use for article previews, \" +\n \"product cards, project highlights, gallery items — anywhere a Card \" +\n \"needs a leading image. Orient with `orientation=\\\"horizontal\\\"` for \" +\n \"side-by-side media + content on wide viewports.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"imageSrc\", type: \"string\", optional: true, aliases: [\"src\", \"image\"], description: \"Image URL (omit to render a neutral placeholder)\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"tags\", type: \"string[]\", optional: true, description: \"Tag pill labels\" },\n { name: \"meta\", type: \"string\", optional: true, description: \"Footer meta line (author · date · category)\" },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Buttons / Links rendered at the bottom\" },\n { name: \"badge\", type: \"string | Badge\", optional: true, description: \"Eyebrow string or Badge node shown over the image\" },\n { name: \"orientation\", type: \"string\", optional: true, enum: [\"vertical\", \"horizontal\"] },\n { name: \"ratio\", type: \"string\", optional: true, description: \"Media aspect ratio (default 16:9 vertical, 4:3 horizontal)\" },\n ],\n render: (_node, props, helpers) => {\n const orientation = asString(props.orientation, \"vertical\");\n const root = el(\"article\", {\n class: \"rui-media-card\",\n \"data-orientation\": orientation,\n });\n const ratio = parseMediaRatio(asString(props.ratio, orientation === \"horizontal\" ? \"4:3\" : \"16:9\"));\n const media = el(\"div\", {\n class: \"rui-media-card-media\",\n style: `aspect-ratio:${ratio};`,\n });\n const imageSrc = sanitiseImageSrc(props.imageSrc);\n if (imageSrc) {\n media.append(el(\"img\", { src: imageSrc, alt: asString(props.title), loading: \"lazy\" }));\n } else {\n media.classList.add(\"rui-media-card-media-empty\");\n const placeholder = renderIcon(\"image\", { className: \"rui-media-card-placeholder\" })\n ?? el(\"span\", { class: \"rui-media-card-placeholder\" });\n media.append(placeholder);\n }\n if (props.badge) {\n const badgeWrap = el(\"span\", { class: \"rui-media-card-badge\" });\n if (typeof props.badge === \"string\") {\n badgeWrap.append(document.createTextNode(asString(props.badge)));\n } else {\n badgeWrap.append(helpers.renderNode(props.badge));\n }\n media.append(badgeWrap);\n }\n root.append(media);\n\n const body = el(\"div\", { class: \"rui-media-card-body\" });\n body.append(el(\"h3\", { class: \"rui-media-card-title\" }, [asString(props.title)]));\n const description = asString(props.description);\n if (description) body.append(el(\"p\", { class: \"rui-media-card-description\" }, [description]));\n const tags = asArray<unknown>(props.tags);\n if (tags.length > 0) {\n const row = el(\"div\", { class: \"rui-media-card-tags\" });\n for (const t of tags) {\n const label = asString(t);\n if (label) row.append(el(\"span\", { class: \"rui-tag\", \"data-size\": \"sm\" }, [\n el(\"span\", { class: \"rui-tag-label\" }, [label]),\n ]));\n }\n body.append(row);\n }\n const meta = asString(props.meta);\n if (meta) body.append(el(\"p\", { class: \"rui-media-card-meta\" }, [meta]));\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-media-card-actions\");\n body.append(actions);\n }\n root.append(body);\n return root;\n },\n};\n\nfunction parseMediaRatio(input: string): string {\n if (input.includes(\":\")) {\n const [w, h] = input.split(\":\");\n const num = Number(w);\n const den = Number(h);\n if (Number.isFinite(num) && Number.isFinite(den) && den > 0) return `${num} / ${den}`;\n }\n const n = Number(input);\n return Number.isFinite(n) && n > 0 ? `${n} / 1` : \"16 / 9\";\n}\n\n/**\n * Render a tiny inline sparkline as an SVG. Shared by `Stats`, `StatCard`,\n * and the standalone `Sparkline` component so the visual language stays\n * consistent across surfaces. `tone` maps to a CSS variable so themes can\n * override the stroke colour.\n */\nexport function renderInlineSparkline(values: number[], tone = \"primary\"): SVGSVGElement {\n const width = 80;\n const height = 24;\n const svgNS = \"http://www.w3.org/2000/svg\";\n const svg = document.createElementNS(svgNS, \"svg\");\n svg.setAttribute(\"class\", \"rui-sparkline\");\n svg.setAttribute(\"data-tone\", tone);\n svg.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n svg.setAttribute(\"width\", String(width));\n svg.setAttribute(\"height\", String(height));\n svg.setAttribute(\"aria-hidden\", \"true\");\n if (values.length < 2) return svg;\n const min = Math.min(...values);\n const max = Math.max(...values);\n const range = max - min || 1;\n const step = width / (values.length - 1);\n const points = values.map((value, i) => {\n const x = i * step;\n // Bias by 2px padding top/bottom so the stroke is fully visible.\n const y = 2 + ((max - value) / range) * (height - 4);\n return [x, y] as const;\n });\n const linePath = points.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x.toFixed(1)},${y.toFixed(1)}`).join(\" \");\n const areaPath = `${linePath} L${width},${height} L0,${height} Z`;\n const area = document.createElementNS(svgNS, \"path\");\n area.setAttribute(\"d\", areaPath);\n area.setAttribute(\"class\", \"rui-sparkline-area\");\n svg.appendChild(area);\n const line = document.createElementNS(svgNS, \"path\");\n line.setAttribute(\"d\", linePath);\n line.setAttribute(\"class\", \"rui-sparkline-line\");\n line.setAttribute(\"fill\", \"none\");\n svg.appendChild(line);\n return svg;\n}\n\nexport const Stats: ComponentSpec = {\n name: \"Stats\",\n description:\n \"KPI strip or grid. Pass `items` as `{label, value, hint?, tone?, spark?}` \" +\n \"objects for strip layout, or as `StatCard(...)` nodes when `layout=\\\"grid\\\"`.\",\n props: [\n { name: \"items\", type: \"object[] | StatCard[]\", description: \"Stat objects or StatCard nodes when layout=grid\" },\n { name: \"layout\", type: \"string\", optional: true, enum: [\"strip\", \"grid\"], description: \"strip = horizontal row; grid = responsive Grid\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"Preferred column count for grid layout (1–6)\" },\n { name: \"align\", type: \"string\", optional: true, enum: [\"start\", \"center\", \"end\"], description: \"Strip alignment (layout=strip only)\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const hasComponentItems = items.some(\n (item) => item && typeof item === \"object\" && (item as { __kind?: string }).__kind === \"Component\",\n );\n const layout = asString(\n props.layout,\n hasComponentItems ? \"grid\" : \"strip\",\n );\n if (layout === \"grid\") {\n const columns = props.columns ? Math.max(1, Math.min(6, Math.floor(asNumber(props.columns)))) : 0;\n const gridNode = Grid.render(\n { __kind: \"Component\", name: \"Grid\", args: [], argMeta: [] },\n {\n children: items,\n columns: columns > 0 ? columns : \"auto\",\n gap: \"m\",\n },\n helpers,\n ) as HTMLElement;\n gridNode.classList.add(\"rui-metric-grid\");\n return gridNode;\n }\n const align = asString(props.align, \"start\");\n const root = el(\"div\", { class: \"rui-stats\", \"data-align\": align });\n for (const raw of items) {\n const item = (raw ?? {}) as {\n label?: unknown; value?: unknown; hint?: unknown; tone?: unknown; spark?: unknown;\n };\n const tone = asString(item.tone, \"default\");\n const block = el(\"div\", { class: \"rui-stats-item\", \"data-tone\": tone });\n block.append(el(\"div\", { class: \"rui-stats-label\" }, [asString(item.label)]));\n const valueRow = el(\"div\", { class: \"rui-stats-value-row\" });\n valueRow.append(el(\"div\", { class: \"rui-stats-value\" }, [asString(item.value)]));\n const sparkValues = asArray<unknown>(item.spark).map((v) => Number(v)).filter((n) => Number.isFinite(n));\n if (sparkValues.length > 1) {\n valueRow.append(renderInlineSparkline(sparkValues, tone));\n }\n block.append(valueRow);\n const hint = asString(item.hint);\n if (hint) block.append(el(\"div\", { class: \"rui-stats-hint\" }, [hint]));\n root.append(block);\n }\n return root;\n },\n};\n\nexport const Tile: ComponentSpec = {\n name: \"Tile\",\n description:\n \"Compact icon + label + optional value tile. Smaller and denser than \" +\n \"`StatCard`, ideal for menu grids, quick-action panels, category \" +\n \"directories, and category filters. Pair with `Grid` for uniform rows.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name shown in a colored disc\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Secondary value rendered next to/under the label\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"] },\n ],\n render: (_node, props, helpers) => {\n const isClickable = typeof props.onClick === \"function\";\n const tag = isClickable ? \"button\" : \"div\";\n const root = el(tag as \"div\", {\n type: isClickable ? \"button\" : null,\n class: \"rui-tile\",\n \"data-tone\": asString(props.tone, \"default\"),\n });\n const iconNode = renderIcon(props.icon, { className: \"rui-tile-icon\" });\n if (iconNode) root.append(iconNode);\n const body = el(\"div\", { class: \"rui-tile-body\" });\n body.append(el(\"div\", { class: \"rui-tile-label\" }, [asString(props.label)]));\n const value = asString(props.value);\n if (value) body.append(el(\"div\", { class: \"rui-tile-value\" }, [value]));\n const description = asString(props.description);\n if (description) body.append(el(\"div\", { class: \"rui-tile-description\" }, [description]));\n root.append(body);\n if (isClickable) {\n root.onclick = () => helpers.invoke(props.onClick);\n }\n return root;\n },\n};\n\nexport const Notification: ComponentSpec = {\n name: \"Notification\",\n description:\n \"Inline notification card with title, message, time, optional avatar, \" +\n \"and dismiss/action buttons. Use inside notification panels, inboxes, \" +\n \"or activity drawers — for top-of-page announcements prefer `Banner`.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"message\", type: \"string\", optional: true, aliases: [\"description\"] },\n { name: \"time\", type: \"string\", optional: true, description: \"Relative or absolute timestamp\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name shown in a colored disc\" },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"], description: \"Avatar URL (alternative to `icon`)\" },\n { name: \"tone\", type: \"string\", optional: true, enum: SURFACE_TONES },\n { name: \"unread\", type: \"boolean\", optional: true, description: \"Highlights the card with an accent\" },\n { name: \"actions\", type: \"Node[]\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const isUnread = asBoolean(props.unread);\n const root = el(\"article\", {\n class: \"rui-notification\",\n \"data-tone\": asString(props.tone, \"default\"),\n \"data-unread\": isUnread ? \"true\" : \"false\",\n });\n const avatarSrc = asString(props.avatarSrc);\n const visual = el(\"div\", { class: \"rui-notification-visual\" });\n if (avatarSrc) {\n visual.append(renderAvatar(avatarSrc, asString(props.title), \"md\"));\n } else {\n const iconNode = renderIcon(asString(props.icon, \"bell\"), { className: \"rui-notification-icon\" });\n if (iconNode) visual.append(iconNode);\n }\n root.append(visual);\n const body = el(\"div\", { class: \"rui-notification-body\" });\n const head = el(\"header\", { class: \"rui-notification-head\" });\n const titleWrap = el(\"span\", { class: \"rui-notification-title-wrap\" });\n if (isUnread) {\n titleWrap.append(el(\"span\", { class: \"rui-notification-unread-dot\", \"aria-label\": \"Unread\" }));\n }\n titleWrap.append(el(\"span\", { class: \"rui-notification-title\" }, [asString(props.title)]));\n head.append(titleWrap);\n const time = asString(props.time);\n if (time) head.append(el(\"span\", { class: \"rui-notification-time\" }, [time]));\n body.append(head);\n const message = asString(props.message);\n if (message) body.append(el(\"p\", { class: \"rui-notification-message\" }, [message]));\n const actions = renderActionsRow(props.actions, helpers);\n if (actions) {\n actions.classList.add(\"rui-notification-actions\");\n body.append(actions);\n }\n root.append(body);\n return root;\n },\n};\n\nexport const PersonChip: ComponentSpec = {\n name: \"PersonChip\",\n description:\n \"Inline avatar + name + optional role/meta pill. Use anywhere a \" +\n \"person needs to be referenced compactly: table cells, list rows, \" +\n \"comments, kanban cards, sidebar footers. Pair multiple chips with \" +\n \"`Stack(direction=\\\"row\\\", wrap=true)` for assignee lists.\",\n props: [\n { name: \"name\", type: \"string\" },\n { name: \"role\", type: \"string\", optional: true, description: \"Sub-line below the name (role, email, handle, …)\" },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"] },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\"] },\n { name: \"status\", type: \"string\", optional: true, enum: [\"online\", \"offline\", \"busy\", \"away\"] },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"] },\n ],\n render: (_node, props, helpers) => {\n const isClickable = typeof props.onClick === \"function\";\n const tag = isClickable ? \"button\" : \"div\";\n const size = asString(props.size, \"md\");\n const avatarSize = size === \"lg\" ? \"lg\" : size === \"sm\" ? \"sm\" : \"md\";\n const root = el(tag as \"div\", {\n type: isClickable ? \"button\" : null,\n class: \"rui-person-chip\",\n \"data-size\": size,\n });\n const avatarWrap = el(\"span\", { class: \"rui-person-chip-avatar\" });\n avatarWrap.append(renderAvatar(asString(props.avatarSrc), asString(props.name), avatarSize));\n const status = asString(props.status);\n if (status) avatarWrap.append(el(\"span\", { class: \"rui-person-chip-status\", \"data-status\": status }));\n root.append(avatarWrap);\n const meta = el(\"div\", { class: \"rui-person-chip-meta\" });\n meta.append(el(\"span\", { class: \"rui-person-chip-name\" }, [asString(props.name)]));\n const role = asString(props.role);\n if (role) meta.append(el(\"span\", { class: \"rui-person-chip-role\" }, [role]));\n root.append(meta);\n if (isClickable) {\n root.onclick = () => helpers.invoke(props.onClick);\n }\n return root;\n },\n};\n\n","/**\n * Data components: Table, Col, List, ListItem, StatCard, Tree, TreeNode,\n * Sparkline.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asBoolean, asNumber, renderIcon, fillTableCell } from \"../utils.js\";\nimport { renderInlineSparkline } from \"./patterns.js\";\nimport { pickIconForLabel } from \"./_internal.js\";\n\nconst COL_ALIGN = [\"left\", \"center\", \"right\"] as const;\n\nexport const Col: ComponentSpec = {\n name: \"Col\",\n description:\n \"Single column inside a Table or DataGrid. Use `align` for per-column \" +\n \"text alignment, `format` for cell rendering \" +\n \"(`text|number|currency|date`). `values` may be plain values OR an \" +\n \"array of component nodes — e.g. `Col(\\\"Status\\\", rows.map(r => \" +\n \"Badge(r.status)))` or `Col(\\\"Actions\\\", rows.map(r => Button(\\\"Edit\\\")))` \" +\n \"— each component renders directly in its cell. Pass \" +\n \"`render: (value, index) => …` for the same effect when you prefer to \" +\n \"keep `values` as the raw row data (return a component, string, or \" +\n \"array). Pass `onClick: (value, index) => …` to make the whole cell \" +\n \"clickable (pointer + keyboard). `sortable` and `filterable` only take \" +\n \"effect inside `DataGrid` (Table ignores them).\",\n props: [\n { name: \"header\", type: \"string\" },\n { name: \"values\", type: \"any[]\", description: \"Column values. Plain values are formatted as text; component nodes (e.g. `rows.map(r => Badge(r.status))`) render directly. You can also pass the full row array and map each cell with `render`.\" },\n { name: \"format\", type: \"string\", optional: true, enum: [\"text\", \"number\", \"currency\", \"date\"] },\n { name: \"align\", type: \"string\", optional: true, enum: COL_ALIGN, description: \"Per-column horizontal alignment\" },\n { name: \"sortable\", type: \"boolean\", optional: true, description: \"DataGrid: enable click-to-sort on this column\" },\n { name: \"filterable\", type: \"boolean\", optional: true, description: \"DataGrid: enable a per-column filter chip\" },\n { name: \"render\", type: \"callable\", optional: true, aliases: [\"cell\"], description: \"`(value, index) => Component | string | array` — map each cell to arbitrary content (buttons, badges, links).\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"onclick\", \"cellClick\"], description: \"`(value, index) => void` — fired when a cell in this column is clicked or activated via keyboard.\" },\n ],\n // Cols are read positionally inside Table.render — this render is a fallback.\n render: (_node, props) => {\n const wrapper = el(\"div\", { class: \"rui-col\" });\n wrapper.append(el(\"strong\", {}, [asString(props.header)]));\n return wrapper;\n },\n};\n\nconst TABLE_DENSITY = [\"comfortable\", \"compact\"] as const;\n\nexport const Table: ComponentSpec = {\n name: \"Table\",\n description:\n \"Tabular data view. Children must be Col components. `density=\\\"compact\\\"` \" +\n \"tightens row padding for dense data, `striped=true` zebra-stripes the \" +\n \"rows, and `sticky=true` pins the header row when the table scrolls. \" +\n \"The empty-state row uses `emptyLabel` when set.\",\n props: [\n { name: \"columns\", type: \"Col[]\" },\n { name: \"caption\", type: \"string\", optional: true, aliases: [\"title\"] },\n { name: \"density\", type: \"string\", optional: true, enum: TABLE_DENSITY, description: \"Row padding (default `comfortable`)\" },\n { name: \"striped\", type: \"boolean\", optional: true, description: \"Zebra-stripe alternating rows\" },\n { name: \"sticky\", type: \"boolean\", optional: true, description: \"Pin the header row when the table scrolls\" },\n { name: \"emptyLabel\", type: \"string\", optional: true, description: \"Text shown when the table has no rows (default `No data`)\" },\n ],\n render: (_node, props, helpers) => {\n const cols = asArray<{ args?: unknown[] }>(props.columns);\n const density = asString(props.density, \"comfortable\");\n const striped = asBoolean(props.striped);\n const sticky = asBoolean(props.sticky);\n const wrapper = el(\"div\", {\n class: \"rui-table-wrapper\",\n \"data-density\": density,\n \"data-striped\": striped ? \"true\" : \"false\",\n \"data-sticky\": sticky ? \"true\" : \"false\",\n });\n const table = el(\"table\", { class: \"rui-table\" });\n\n const caption = asString(props.caption);\n if (caption) table.append(el(\"caption\", { class: \"rui-table-caption\" }, [caption]));\n\n const aligns = cols.map((col) => {\n const align = asString(col.args?.[3], \"\");\n return (COL_ALIGN as readonly string[]).includes(align) ? align : \"\";\n });\n\n const thead = el(\"thead\");\n const headRow = el(\"tr\");\n for (let c = 0; c < cols.length; c += 1) {\n const col = cols[c]!;\n const th = el(\"th\", {\n \"data-align\": aligns[c] || null,\n }, [asString(col.args?.[0])]);\n headRow.append(th);\n }\n thead.append(headRow);\n table.append(thead);\n\n const tbody = el(\"tbody\");\n const columnValues = cols.map((col) => asArray(col.args?.[1]));\n const formats = cols.map((col) => asString(col.args?.[2], \"text\"));\n const renders = cols.map((col) => col.args?.[6]);\n const clicks = cols.map((col) => col.args?.[7]);\n const rowCount = Math.max(0, ...columnValues.map((c) => c.length));\n\n for (let r = 0; r < rowCount; r += 1) {\n const tr = el(\"tr\");\n columnValues.forEach((values, c) => {\n const format = formats[c] ?? \"text\";\n const align = aligns[c];\n const td = el(\"td\", { \"data-format\": format, \"data-align\": align || null });\n fillTableCell(\n td,\n { format, render: renders[c], onClick: clicks[c] },\n values[r],\n r,\n helpers,\n formatCell,\n );\n tr.append(td);\n });\n tbody.append(tr);\n }\n\n if (rowCount === 0) {\n const emptyRow = el(\"tr\");\n const emptyLabel = asString(props.emptyLabel, \"No data\");\n emptyRow.append(el(\"td\", {\n colspan: String(cols.length || 1),\n class: \"rui-table-empty\",\n }, [emptyLabel]));\n tbody.append(emptyRow);\n }\n\n table.append(tbody);\n wrapper.append(table);\n return wrapper;\n },\n};\n\nexport const ListItem: ComponentSpec = {\n name: \"ListItem\",\n description: \"Single list item with optional title and description.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"description\", type: \"string\", optional: true, aliases: [\"meta\"] },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name\" },\n ],\n render: (_node, props) => {\n const li = el(\"li\", { class: \"rui-list-item\" });\n const iconNode = renderIcon(props.icon, { className: \"rui-list-icon\" });\n if (iconNode) li.append(iconNode);\n const text = el(\"div\", { class: \"rui-list-text\" });\n text.append(el(\"div\", { class: \"rui-list-title\" }, [asString(props.title)]));\n const desc = asString(props.description);\n if (desc) text.append(el(\"div\", { class: \"rui-list-description\" }, [desc]));\n li.append(text);\n return li;\n },\n};\n\nexport const List: ComponentSpec = {\n name: \"List\",\n description: \"Vertical list of ListItems.\",\n props: [\n { name: \"items\", type: \"ListItem[]\" },\n { name: \"ordered\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const tag = asBoolean(props.ordered) ? \"ol\" : \"ul\";\n const root = el(tag as \"ul\", { class: \"rui-list\" });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const StatCard: ComponentSpec = {\n name: \"StatCard\",\n description:\n \"Single KPI card with label, value, optional delta, optional icon, \" +\n \"and optional inline sparkline (`spark=[…numbers]`). Use inside \" +\n \"`Stats` for a uniform KPI strip.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"value\", type: \"string\" },\n { name: \"trend\", type: \"string\", optional: true, enum: [\"up\", \"down\", \"flat\"] },\n { name: \"delta\", type: \"string\", optional: true, description: \"Change vs previous period\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name shown in a chip beside the label\" },\n { name: \"spark\", type: \"number[]\", optional: true, description: \"Optional inline sparkline values\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"default\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n ],\n render: (_node, props) => {\n const tone = asString(props.tone, \"default\");\n const root = el(\"div\", { class: \"rui-stat-card\", \"data-tone\": tone });\n const labelRow = el(\"div\", { class: \"rui-stat-label-row\" });\n const label = asString(props.label);\n const iconName = asString(props.icon) || pickIconForLabel(label) || \"\";\n const iconNode = renderIcon(iconName, { className: \"rui-stat-icon\" });\n if (iconNode) labelRow.append(iconNode);\n labelRow.append(el(\"div\", { class: \"rui-stat-label\" }, [label]));\n root.append(labelRow);\n root.append(el(\"div\", { class: \"rui-stat-value\" }, [asString(props.value)]));\n const delta = asString(props.delta);\n const trend = asString(props.trend);\n if (delta || trend) {\n root.append(el(\"div\", { class: \"rui-stat-trend\", \"data-trend\": trend || \"flat\" }, [delta || trendArrow(trend)]));\n }\n const spark = asArray<unknown>(props.spark).map((v) => asNumber(v));\n if (spark.length > 1) {\n const sparkWrap = el(\"div\", { class: \"rui-stat-spark\" });\n sparkWrap.append(renderInlineSparkline(spark, tone === \"default\" ? \"primary\" : tone));\n root.append(sparkWrap);\n }\n return root;\n },\n};\n\nexport const Sparkline: ComponentSpec = {\n name: \"Sparkline\",\n description:\n \"Tiny inline trend chart for KPIs, table cells, and dashboards. \" +\n \"Renders an SVG line with a soft fill — use anywhere you would \" +\n \"otherwise reach for `LineChart` but a single value series should \" +\n \"stay inline with surrounding text.\",\n props: [\n { name: \"values\", type: \"number[]\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n ],\n render: (_node, props) => {\n const tone = asString(props.tone, \"primary\");\n const values = asArray<unknown>(props.values).map((v) => asNumber(v));\n const wrap = el(\"span\", { class: \"rui-sparkline-wrap\" });\n wrap.append(renderInlineSparkline(values, tone));\n return wrap;\n },\n};\n\nexport const TreeNode: ComponentSpec = {\n name: \"TreeNode\",\n description:\n \"Single node in a Tree view. When `children` is provided the node \" +\n \"renders as an expandable branch with a chevron; otherwise it renders \" +\n \"as a leaf. `onClick` fires on click. Use `active=true` to highlight \" +\n \"the current selection.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"children\", type: \"TreeNode[]\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon shown before the label\" },\n { name: \"expanded\", type: \"boolean\", optional: true, description: \"Whether the branch is open by default\" },\n { name: \"active\", type: \"boolean\", optional: true, aliases: [\"selected\"], description: \"Highlights the row as the current selection\" },\n { name: \"badge\", type: \"string\", optional: true, description: \"Trailing chip (count or status)\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Callable fired when the row is clicked\" },\n ],\n render: (_node, props, helpers) => {\n const children = asArray<unknown>(props.children);\n const hasChildren = children.length > 0;\n const expanded = asBoolean(props.expanded);\n const active = asBoolean(props.active);\n const isClickable = typeof props.onClick === \"function\";\n\n const row = el(isClickable ? \"button\" : \"div\" as \"div\", {\n type: isClickable ? \"button\" : null,\n class: \"rui-tree-node-row\",\n role: \"treeitem\",\n \"data-active\": active ? \"true\" : \"false\",\n \"aria-expanded\": hasChildren ? (expanded ? \"true\" : \"false\") : null,\n });\n\n if (hasChildren) {\n const chevron = renderIcon(\"chevron-right\", { className: \"rui-tree-node-chevron\" });\n if (chevron) row.append(chevron);\n } else {\n row.append(el(\"span\", { class: \"rui-tree-node-chevron-spacer\", \"aria-hidden\": \"true\" }));\n }\n const iconNode = renderIcon(props.icon, { className: \"rui-tree-node-icon\" });\n if (iconNode) row.append(iconNode);\n row.append(el(\"span\", { class: \"rui-tree-node-label\" }, [asString(props.label)]));\n const badge = asString(props.badge);\n if (badge) row.append(el(\"span\", { class: \"rui-tree-node-badge\" }, [badge]));\n\n if (isClickable) {\n row.onclick = () => helpers.invoke(props.onClick);\n }\n\n if (!hasChildren) return row;\n\n // Branch: render as a <details> so expand/collapse is browser-native\n // (no extra state slot needed) and survives morph reconciliation.\n const details = el(\"details\", { class: \"rui-tree-node\" }) as HTMLDetailsElement;\n if (expanded) details.setAttribute(\"open\", \"\");\n const summary = el(\"summary\", { class: \"rui-tree-node-summary\" });\n summary.append(row);\n // When the row is clickable, swallow the summary's default toggle so a\n // click on the label runs the action without expanding/collapsing. The\n // chevron still toggles because we wire it explicitly below.\n if (isClickable) {\n summary.onclick = (event) => {\n const target = event.target as Element | null;\n if (target?.closest(\".rui-tree-node-chevron\")) return;\n event.preventDefault();\n };\n }\n details.append(summary);\n\n const childList = el(\"div\", { class: \"rui-tree-node-children\", role: \"group\" });\n for (const child of children) childList.append(helpers.renderNode(child));\n details.append(childList);\n return details;\n },\n};\n\nexport const Tree: ComponentSpec = {\n name: \"Tree\",\n description:\n \"Hierarchical tree view. Children must be TreeNode entries. Use for \" +\n \"file browsers, nested navigation, category pickers, and any \" +\n \"parent/child structure with arbitrary depth.\",\n props: [{ name: \"items\", type: \"TreeNode[]\" }],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-tree\", role: \"tree\" });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nfunction trendArrow(trend: string): string {\n if (trend === \"up\") return \"▲\";\n if (trend === \"down\") return \"▼\";\n return \"—\";\n}\n\nfunction formatCell(value: unknown, format: string): string {\n if (value === null || value === undefined) return \"\";\n switch (format) {\n case \"number\":\n return typeof value === \"number\" ? value.toLocaleString() : asString(value);\n case \"currency\":\n return typeof value === \"number\"\n ? value.toLocaleString(undefined, { style: \"currency\", currency: \"USD\" })\n : asString(value);\n case \"date\":\n try {\n const d = new Date(asString(value));\n return Number.isNaN(d.getTime()) ? asString(value) : d.toLocaleDateString();\n } catch { return asString(value); }\n default:\n return asString(value);\n }\n}\n","/**\n * Chart components: Series (data definition), BarChart, LineChart, PieChart.\n *\n * The charts are rendered as inline SVG so they work inside the shadow root\n * without any external dependency.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asNumber, asBoolean } from \"../utils.js\";\n\nconst PALETTE: readonly string[] = [\n \"var(--rui-chart-1, #6366f1)\",\n \"var(--rui-chart-2, #10b981)\",\n \"var(--rui-chart-3, #f59e0b)\",\n \"var(--rui-chart-4, #ef4444)\",\n \"var(--rui-chart-5, #06b6d4)\",\n \"var(--rui-chart-6, #8b5cf6)\",\n];\n\nconst colorAt = (index: number): string => PALETTE[index % PALETTE.length] ?? PALETTE[0]!;\n\nexport const Series: ComponentSpec = {\n name: \"Series\",\n description: \"Named data series for charts. Used inside BarChart, LineChart, PieChart.\",\n props: [\n { name: \"name\", type: \"string\" },\n { name: \"values\", type: \"number[]\" },\n ],\n render: (_node, props) => {\n return el(\"span\", { class: \"rui-series\", \"data-name\": asString(props.name) });\n },\n};\n\ninterface SeriesData {\n name: string;\n values: number[];\n}\n\nconst readSeries = (raw: unknown[]): SeriesData[] => {\n return raw.map((s, i) => {\n const node = s as { args?: unknown[] };\n const name = asString(node.args?.[0], `Series ${i + 1}`);\n const values = asArray<unknown>(node.args?.[1]).map((v) => asNumber(v));\n return { name, values };\n });\n};\n\nexport const BarChart: ComponentSpec = {\n name: \"BarChart\",\n description: \"Vertical bar chart. `labels` define the x-axis, `series` define grouped bars.\",\n props: [\n { name: \"labels\", type: \"string[]\" },\n { name: \"series\", type: \"Series[]\" },\n { name: \"title\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const labels = asArray<unknown>(props.labels).map((l) => asString(l));\n const series = readSeries(asArray<unknown>(props.series));\n const root = el(\"div\", { class: \"rui-chart rui-bar-chart\" });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n\n const max = Math.max(1, ...series.flatMap((s) => s.values));\n const width = 640;\n const height = 240;\n const labelPlan = planLabels(labels, width - 40 - 12);\n const padding = { left: 40, right: 12, top: 12, bottom: labelPlan.bottomPadding };\n const innerWidth = width - padding.left - padding.right;\n const innerHeight = height - padding.top - padding.bottom;\n const svg = createSvg(width, height);\n\n drawAxes(svg, padding, innerWidth, innerHeight, max);\n\n const groupCount = labels.length;\n const groupWidth = innerWidth / Math.max(groupCount, 1);\n const seriesCount = series.length;\n const barWidth = (groupWidth * 0.7) / Math.max(seriesCount, 1);\n\n series.forEach((s, sIdx) => {\n s.values.forEach((value, gIdx) => {\n const barHeight = (value / max) * innerHeight;\n const x = padding.left + gIdx * groupWidth + groupWidth * 0.15 + sIdx * barWidth;\n const y = padding.top + innerHeight - barHeight;\n const rect = svgEl(\"rect\", {\n x: String(x),\n y: String(y),\n width: String(Math.max(barWidth - 2, 1)),\n height: String(barHeight),\n fill: colorAt(sIdx),\n rx: \"2\",\n });\n rect.append(svgEl(\"title\", {}, [`${s.name}: ${value}`]));\n svg.append(rect);\n });\n });\n\n drawXAxisLabels(svg, labels, padding, innerWidth, innerHeight, labelPlan, (i) => padding.left + (i + 0.5) * groupWidth);\n\n root.append(svg);\n if (series.length > 0) root.append(legend(series));\n return root;\n },\n};\n\nexport const LineChart: ComponentSpec = {\n name: \"LineChart\",\n description:\n \"Line chart. `labels` define the x-axis, each Series is a line. As a \" +\n \"shortcut you can pass `data=[{x: \\\"Jan\\\", revenue: 12, signups: 4}, …]` \" +\n \"and the labels + series will be derived automatically (one line per \" +\n \"non-`x` key). Use `data` when the dataset is already row-shaped; use \" +\n \"`series` when you have explicit Series objects.\",\n props: [\n { name: \"labels\", type: \"string[]\", optional: true },\n { name: \"series\", type: \"Series[]\", optional: true },\n { name: \"data\", type: \"{x: string, [key: string]: number}[]\", optional: true, description: \"Row-shaped data — labels and series are auto-derived\" },\n { name: \"title\", type: \"string\", optional: true },\n { name: \"filled\", type: \"boolean\", optional: true, description: \"Fill the area beneath each line (area-chart style)\" },\n { name: \"stacked\", type: \"boolean\", optional: true, description: \"Stack series when filled=true\" },\n ],\n render: (_node, props) => {\n let labels = asArray<unknown>(props.labels).map((l) => asString(l));\n let series = readSeries(asArray<unknown>(props.series));\n // Row-shaped shorthand: pull labels from `x` and one Series per other key.\n const rows = asArray<unknown>(props.data);\n if (rows.length > 0 && (labels.length === 0 || series.length === 0)) {\n const derivedLabels: string[] = [];\n const seriesByKey = new Map<string, number[]>();\n for (const raw of rows) {\n const row = raw as Record<string, unknown> | null;\n if (!row || typeof row !== \"object\") continue;\n derivedLabels.push(asString(row.x ?? row.label ?? \"\"));\n for (const [k, v] of Object.entries(row)) {\n if (k === \"x\" || k === \"label\") continue;\n const num = asNumber(v);\n if (Number.isNaN(num)) continue;\n if (!seriesByKey.has(k)) seriesByKey.set(k, []);\n seriesByKey.get(k)!.push(num);\n }\n }\n if (labels.length === 0) labels = derivedLabels;\n if (series.length === 0) {\n series = [...seriesByKey.entries()].map(([name, values]) => ({ name, values }));\n }\n }\n const filled = props.filled === true;\n const stacked = props.stacked === true;\n const pointCount = Math.max(labels.length, ...series.map((s) => s.values.length), 1);\n const stackedValues: number[][] = series.map(() => Array(pointCount).fill(0));\n if (filled && stacked) {\n for (let i = 0; i < pointCount; i += 1) {\n let acc = 0;\n series.forEach((s, sIdx) => {\n acc += s.values[i] ?? 0;\n stackedValues[sIdx]![i] = acc;\n });\n }\n }\n const root = el(\"div\", {\n class: \"rui-chart rui-line-chart\",\n \"data-filled\": filled ? \"true\" : \"false\",\n });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n\n const all = filled && stacked\n ? stackedValues.flat()\n : series.flatMap((s) => s.values);\n const max = Math.max(1, ...all);\n const min = filled && stacked ? 0 : Math.min(0, ...all);\n const width = 640;\n const height = 240;\n const labelPlan = planLabels(labels, width - 40 - 12);\n const padding = { left: 40, right: 12, top: 12, bottom: labelPlan.bottomPadding };\n const innerWidth = width - padding.left - padding.right;\n const innerHeight = height - padding.top - padding.bottom;\n const svg = createSvg(width, height);\n\n drawAxes(svg, padding, innerWidth, innerHeight, max, min);\n\n const denominator = Math.max(labels.length - 1, 1);\n const stepX = innerWidth / denominator;\n const xForPoint = (i: number): number =>\n padding.left + i * (innerWidth / Math.max(pointCount - 1, 1));\n\n series.forEach((s, sIdx) => {\n const values = filled && stacked ? stackedValues[sIdx]! : s.values;\n const baseline = filled && stacked && sIdx > 0 ? stackedValues[sIdx - 1]! : null;\n const points = values.map((value, i) => {\n const x = xForPoint(i);\n const y = padding.top + innerHeight - ((value - min) / (max - min || 1)) * innerHeight;\n return [x, y] as const;\n });\n if (filled && points.length > 0) {\n let areaPath = points.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x.toFixed(1)},${y.toFixed(1)}`).join(\" \");\n if (baseline) {\n const baselinePoints = baseline.map((value, i) => {\n const x = xForPoint(i);\n const y = padding.top + innerHeight - ((value - min) / (max - min || 1)) * innerHeight;\n return [x, y] as const;\n });\n areaPath += \" \" + baselinePoints.slice().reverse().map(([x, y]) => `L${x.toFixed(1)},${y.toFixed(1)}`).join(\" \") + \" Z\";\n } else {\n const first = points[0]!;\n const last = points[points.length - 1]!;\n areaPath += ` L${last[0].toFixed(1)},${(padding.top + innerHeight).toFixed(1)} L${first[0].toFixed(1)},${(padding.top + innerHeight).toFixed(1)} Z`;\n }\n svg.append(svgEl(\"path\", {\n d: areaPath,\n fill: colorAt(sIdx),\n \"fill-opacity\": \"0.2\",\n stroke: \"none\",\n }));\n }\n const d = points.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x.toFixed(1)},${y.toFixed(1)}`).join(\" \");\n svg.append(svgEl(\"path\", {\n d,\n fill: \"none\",\n stroke: colorAt(sIdx),\n \"stroke-width\": \"2\",\n \"stroke-linejoin\": \"round\",\n \"stroke-linecap\": \"round\",\n }));\n // Hide individual data points when the line is dense — they create\n // visual noise without helping readability.\n if (s.values.length <= 30) {\n points.forEach(([x, y]) => {\n svg.append(svgEl(\"circle\", {\n cx: String(x),\n cy: String(y),\n r: \"3\",\n fill: colorAt(sIdx),\n }));\n });\n }\n });\n\n drawXAxisLabels(svg, labels, padding, innerWidth, innerHeight, labelPlan, (i) => padding.left + i * stepX);\n\n root.append(svg);\n if (series.length > 0) root.append(legend(series));\n return root;\n },\n};\n\nexport const PieChart: ComponentSpec = {\n name: \"PieChart\",\n description:\n \"Pie / Donut chart. Each segment maps to a label/value pair. Numeric \" +\n \"labels are rendered on every segment by default — set \" +\n \"`showValues: false` to hide them, or `valueFormat: \\\"percent\\\"` \" +\n \"to show the share instead of the raw value.\",\n props: [\n { name: \"labels\", type: \"string[]\" },\n { name: \"values\", type: \"number[]\" },\n { name: \"title\", type: \"string\", optional: true },\n { name: \"showValues\", type: \"boolean\", optional: true, description: \"Render numeric labels on each slice (default true)\" },\n { name: \"valueFormat\", type: \"string\", optional: true, enum: [\"value\", \"percent\", \"both\"], description: \"How to format the on-segment label (default \\\"value\\\")\" },\n ],\n render: (_node, props) => {\n const labels = asArray<unknown>(props.labels).map((l) => asString(l));\n const values = asArray<unknown>(props.values).map((v) => asNumber(v));\n const showValues = props.showValues == null ? true : asBoolean(props.showValues);\n const fmtToken = asString(props.valueFormat, \"value\").toLowerCase();\n const valueFormat: \"value\" | \"percent\" | \"both\" =\n fmtToken === \"percent\" ? \"percent\" : fmtToken === \"both\" ? \"both\" : \"value\";\n const root = el(\"div\", { class: \"rui-chart rui-pie-chart\" });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n\n const total = values.reduce((acc, v) => acc + (v > 0 ? v : 0), 0) || 1;\n const svg = createSvg(240, 240);\n const cx = 120, cy = 120, r = 90;\n // Minimum slice (in fraction of total) for which we still render an\n // inline label. Tiny slivers would overlap and clutter the chart, so\n // we drop them and rely on the legend / hover title instead.\n const MIN_LABEL_FRACTION = 0.05;\n let angle = -Math.PI / 2;\n\n values.forEach((value, i) => {\n const safeValue = value > 0 ? value : 0;\n const fraction = safeValue / total;\n const slice = fraction * Math.PI * 2;\n const next = angle + slice;\n const large = slice > Math.PI ? 1 : 0;\n const x1 = cx + r * Math.cos(angle);\n const y1 = cy + r * Math.sin(angle);\n const x2 = cx + r * Math.cos(next);\n const y2 = cy + r * Math.sin(next);\n const path = `M${cx},${cy} L${x1},${y1} A${r},${r} 0 ${large} 1 ${x2},${y2} Z`;\n const segment = svgEl(\"path\", {\n d: path,\n fill: colorAt(i),\n stroke: \"var(--rui-color-bg, #fff)\",\n \"stroke-width\": \"2\",\n });\n segment.append(svgEl(\"title\", {}, [\n `${labels[i] ?? \"\"}: ${value} (${(fraction * 100).toFixed(1)}%)`,\n ]));\n svg.append(segment);\n\n if (showValues && safeValue > 0 && fraction >= MIN_LABEL_FRACTION) {\n const mid = angle + slice / 2;\n // Pull the label inward (~62% of the radius) so it sits visually\n // centered inside the slice rather than near the rim.\n const labelR = r * 0.62;\n const lx = cx + labelR * Math.cos(mid);\n const ly = cy + labelR * Math.sin(mid);\n const display = formatSliceLabel(value, fraction, valueFormat);\n // Soft shadow text first (paint-order: stroke fill keeps the\n // outline behind the glyph) so labels stay legible on any color.\n const labelText = svgEl(\"text\", {\n x: String(lx),\n y: String(ly),\n class: \"rui-pie-chart-value\",\n \"text-anchor\": \"middle\",\n \"dominant-baseline\": \"central\",\n \"paint-order\": \"stroke\",\n stroke: \"rgba(15, 23, 42, 0.55)\",\n \"stroke-width\": \"3\",\n \"stroke-linejoin\": \"round\",\n fill: \"#fff\",\n }, [display]);\n svg.append(labelText);\n }\n angle = next;\n });\n\n root.append(svg);\n root.append(legend(labels.map((name, i) => ({ name, values: [values[i] ?? 0] }))));\n return root;\n },\n};\n\nfunction formatSliceLabel(\n value: number,\n fraction: number,\n format: \"value\" | \"percent\" | \"both\",\n): string {\n const pct = `${Math.round(fraction * 100)}%`;\n const num = formatNumeric(value);\n if (format === \"percent\") return pct;\n if (format === \"both\") return `${num} (${pct})`;\n return num;\n}\n\nfunction formatNumeric(value: number): string {\n if (!Number.isFinite(value)) return String(value);\n const abs = Math.abs(value);\n if (abs >= 1_000_000) return `${(value / 1_000_000).toFixed(1).replace(/\\.0$/, \"\")}M`;\n if (abs >= 1_000) return `${(value / 1_000).toFixed(1).replace(/\\.0$/, \"\")}k`;\n if (Number.isInteger(value)) return String(value);\n return value.toFixed(1);\n}\n\ninterface LabelPlan {\n /** Render every Nth label (1 = all of them). */\n step: number;\n /** Rotate labels -45° when horizontal space per label is too tight. */\n rotated: boolean;\n /** Truncate each label to this many characters; full label stays in <title>. */\n maxChars: number;\n /** Reserved height under the chart so rotated labels are not clipped. */\n bottomPadding: number;\n}\n\n// Pixel budget assumptions for label sizing. These are deliberately conservative\n// — the chart is rendered as SVG so we cannot measure text without a layout\n// pass, but treating each character as ~7px wide tracks reality for the\n// chart label font (~11px sans-serif) closely enough for layout decisions.\nconst APPROX_CHAR_PX = 7;\n// Below this per-label slot, even rotated labels are too tight; we thin them\n// by showing every Nth label and keep the rest discoverable via hover titles.\nconst MIN_ROTATED_SLOT_PX = 12;\n\nfunction planLabels(labels: ReadonlyArray<string>, innerWidth: number): LabelPlan {\n if (labels.length === 0) {\n return { step: 1, rotated: false, maxChars: 32, bottomPadding: 32 };\n }\n const slot = innerWidth / Math.max(labels.length, 1);\n const longest = labels.reduce((max, l) => Math.max(max, l.length), 0);\n // Horizontal fit: enough room to print without rotating.\n if (longest * APPROX_CHAR_PX + 4 <= slot) {\n return { step: 1, rotated: false, maxChars: longest, bottomPadding: 32 };\n }\n // Otherwise rotate. If still too tight after rotating, drop every Nth label.\n const step = slot < MIN_ROTATED_SLOT_PX ? Math.max(1, Math.ceil(MIN_ROTATED_SLOT_PX / slot)) : 1;\n // Cap label characters by the bottom padding we are willing to spend. The\n // 50px budget renders ~14 chars after the 45° rotation flattens to ~70%.\n const maxChars = Math.min(longest, 14);\n return { step, rotated: true, maxChars, bottomPadding: 60 };\n}\n\nfunction truncateLabel(label: string, maxChars: number): string {\n if (label.length <= maxChars) return label;\n return label.slice(0, Math.max(maxChars - 1, 1)) + \"…\";\n}\n\nfunction drawXAxisLabels(\n svg: SVGSVGElement,\n labels: ReadonlyArray<string>,\n padding: { left: number; right: number; top: number; bottom: number },\n _innerWidth: number,\n innerHeight: number,\n plan: LabelPlan,\n xFor: (index: number) => number,\n): void {\n const baseY = padding.top + innerHeight + (plan.rotated ? 14 : 18);\n labels.forEach((label, i) => {\n if (i % plan.step !== 0) return;\n const x = xFor(i);\n const display = truncateLabel(label, plan.maxChars);\n const attrs: Record<string, string> = {\n x: String(x),\n y: String(baseY),\n class: \"rui-chart-label\",\n \"text-anchor\": plan.rotated ? \"end\" : \"middle\",\n };\n if (plan.rotated) {\n attrs.transform = `rotate(-45, ${x}, ${baseY})`;\n }\n const text = svgEl(\"text\", attrs, [display]);\n if (display !== label) {\n // Preserve the full label as a hover tooltip when we had to truncate.\n text.append(svgEl(\"title\", {}, [label]));\n }\n svg.append(text);\n });\n}\n\nfunction createSvg(width: number, height: number): SVGSVGElement {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n svg.setAttribute(\"class\", \"rui-chart-svg\");\n svg.setAttribute(\"role\", \"img\");\n return svg;\n}\n\nfunction svgEl(\n tag: string,\n attrs: Record<string, string>,\n children?: ReadonlyArray<Node | string>,\n): SVGElement {\n const node = document.createElementNS(\"http://www.w3.org/2000/svg\", tag);\n for (const [key, value] of Object.entries(attrs)) node.setAttribute(key, value);\n if (children) {\n for (const child of children) {\n node.append(typeof child === \"string\" ? document.createTextNode(child) : child);\n }\n }\n return node;\n}\n\nfunction drawAxes(\n svg: SVGSVGElement,\n padding: { left: number; right: number; top: number; bottom: number },\n innerWidth: number,\n innerHeight: number,\n max: number,\n min = 0,\n): void {\n const ticks = 4;\n for (let i = 0; i <= ticks; i += 1) {\n const ratio = i / ticks;\n const y = padding.top + innerHeight - ratio * innerHeight;\n svg.append(svgEl(\"line\", {\n x1: String(padding.left),\n x2: String(padding.left + innerWidth),\n y1: String(y),\n y2: String(y),\n stroke: \"var(--rui-color-border-subtle, rgba(0,0,0,0.08))\",\n }));\n svg.append(svgEl(\"text\", {\n x: String(padding.left - 6),\n y: String(y + 3),\n \"text-anchor\": \"end\",\n class: \"rui-chart-tick\",\n }, [String(Math.round((min + (max - min) * ratio) * 10) / 10)]));\n }\n}\n\nfunction legend(series: SeriesData[]): HTMLElement {\n const root = el(\"div\", { class: \"rui-chart-legend\" });\n series.forEach((s, i) => {\n const item = el(\"span\", { class: \"rui-chart-legend-item\" });\n item.append(el(\"span\", { class: \"rui-chart-legend-swatch\", style: `background:${colorAt(i)}` }));\n item.append(el(\"span\", {}, [s.name]));\n root.append(item);\n });\n return root;\n}\n","/**\n * Chat-friendly composite components: SectionBlock, ListBlock, FollowUpBlock.\n * These wrap content with the right typography for assistant responses.\n */\n\nimport type { ComponentSpec, RenderHelpers } from \"../types.js\";\nimport { el, asArray, asBoolean, asString } from \"../utils.js\";\n\nexport const SectionBlock: ComponentSpec = {\n name: \"SectionBlock\",\n description: \"Titled chat block with a description and child content.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"children\", type: \"Node[]\" },\n { name: \"description\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"section\", { class: \"rui-section-block\" });\n root.append(el(\"h3\", { class: \"rui-section-block-title\" }, [asString(props.title)]));\n const desc = asString(props.description);\n if (desc) root.append(el(\"p\", { class: \"rui-section-block-description\" }, [desc]));\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const ListBlock: ComponentSpec = {\n name: \"ListBlock\",\n description: \"Chat-styled list with bullets, useful for steps or summaries.\",\n props: [\n { name: \"items\", type: \"string[]\" },\n { name: \"ordered\", type: \"boolean\", optional: true },\n ],\n render: (_node, props) => {\n const tag = asBoolean(props.ordered) ? \"ol\" : \"ul\";\n const root = el(tag as \"ul\", { class: \"rui-list-block\" });\n for (const item of asArray(props.items)) {\n root.append(el(\"li\", {}, [asString(item)]));\n }\n return root;\n },\n};\n\nexport const FollowUpBlock: ComponentSpec = {\n name: \"FollowUpBlock\",\n description: \"Suggested follow-up prompts shown as buttons. Each item dispatches its label as an assistant message (equivalent to `emit \\\"assistant-message\\\" { message }`).\",\n props: [\n { name: \"items\", type: \"FollowUpItem[]\", description: \"Array of FollowUpItem(label, message?), {label, message} objects, or plain strings\" },\n { name: \"title\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-follow-up\" });\n const title = asString(props.title, \"You can also ask\");\n if (title) root.append(el(\"div\", { class: \"rui-follow-up-title\" }, [title]));\n const list = el(\"div\", { class: \"rui-follow-up-list\" });\n for (const item of asArray<unknown>(props.items)) {\n list.append(buildFollowUpButton(item, helpers));\n }\n root.append(list);\n return root;\n },\n};\n\nconst buildFollowUpButton = (\n item: unknown,\n helpers: Pick<RenderHelpers, \"sendToAssistant\">,\n): HTMLButtonElement => {\n const { label, message } = extractFollowUp(item);\n const button = el(\"button\", { class: \"rui-follow-up-button\", type: \"button\" }, [label]);\n button.onclick = () => {\n helpers.sendToAssistant(message);\n };\n return button;\n};\n\nconst extractFollowUp = (item: unknown): { label: string; message: string } => {\n if (typeof item === \"string\") return { label: item, message: item };\n if (item && typeof item === \"object\") {\n const node = item as { __kind?: string; args?: unknown[]; label?: unknown; message?: unknown };\n if (node.__kind === \"Component\" && Array.isArray(node.args)) {\n const label = asString(node.args[0]);\n const message = asString(node.args[1], label);\n return { label, message };\n }\n const label = asString(node.label);\n const message = asString(node.message, label);\n return { label, message };\n }\n const fallback = asString(item);\n return { label: fallback, message: fallback };\n};\n\nexport const FollowUpItem: ComponentSpec = {\n name: \"FollowUpItem\",\n description: \"Single follow-up item.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"message\", type: \"string\", optional: true, description: \"Defaults to label\" },\n ],\n render: (_node, props, helpers) => {\n const label = asString(props.label);\n const message = asString(props.message, label);\n const button = el(\"button\", { class: \"rui-follow-up-button\", type: \"button\" }, [label]);\n button.onclick = () => {\n helpers.sendToAssistant(message);\n };\n return button;\n },\n};\n\nexport const ActionLink: ComponentSpec = {\n name: \"ActionLink\",\n description: \"Inline link that runs an action when clicked instead of navigating.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"onClick\", type: \"callable\", aliases: [\"action\", \"onclick\"] },\n ],\n render: (_node, props, helpers) => {\n const link = el(\"a\", { class: \"rui-action-link\", href: \"#\", role: \"button\" }, [asString(props.label)]);\n link.onclick = (event) => {\n event.preventDefault();\n helpers.invoke(props.onClick);\n };\n return link;\n },\n};\n","/**\n * Feedback primitives modeled after shadcn/ui:\n * Avatar, AvatarGroup, Progress, Switch, Toggle, ToggleGroup, Tooltip,\n * HoverCard, Popover, Toast, Toasts, Kbd.\n *\n * These cover the most common \"small bits of UI\" that the LLM otherwise has\n * to fake with Text + emoji combinations. Every component is purely\n * declarative — state binding is done at the prop level so a `$variable`\n * passed to `Switch` two-way-binds the same way it does for `Checkbox`.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n sanitiseCssLength, sanitiseImageSrc,\n} from \"../utils.js\";\nimport { initialsFor, installDismissListeners, disposeDismissListeners, dicebearUrlFor } from \"./_internal.js\";\nimport { resolveIconClasses } from \"../../icons/index.js\";\n\nconst AVATAR_SIZES = [\"sm\", \"md\", \"lg\", \"xl\"] as const;\n\nconst AVATAR_FALLBACKS = [\"initials\", \"dicebear\"] as const;\n\nexport const Avatar: ComponentSpec = {\n name: \"Avatar\",\n description:\n \"User avatar. Shows the image at `src`. When `src` is missing, falls back \" +\n \"to a deterministic DiceBear illustration seeded by `name` (pass \" +\n \"`fallback=\\\"initials\\\"` to render two-letter initials instead). If the \" +\n \"image errors at runtime the avatar gracefully degrades to initials.\",\n props: [\n { name: \"name\", type: \"string\", description: \"Used for alt text + initials fallback\" },\n { name: \"src\", type: \"string\", optional: true, description: \"Image URL\" },\n { name: \"size\", type: \"string\", optional: true, enum: AVATAR_SIZES },\n { name: \"status\", type: \"string\", optional: true, enum: [\"online\", \"offline\", \"busy\", \"away\"] },\n {\n name: \"fallback\",\n type: \"string\",\n optional: true,\n enum: AVATAR_FALLBACKS,\n description: \"How to render when `src` is missing (default: dicebear illustration; pass `initials` for the two-letter pill)\",\n },\n ],\n render: (_node, props) => {\n const size = asString(props.size, \"md\");\n const root = el(\"span\", {\n class: \"rui-avatar\",\n \"data-size\": size,\n role: \"img\",\n });\n const name = asString(props.name);\n const fallback = asString(props.fallback, \"dicebear\") as (typeof AVATAR_FALLBACKS)[number];\n const explicitSrc = sanitiseImageSrc(props.src);\n const generated = !explicitSrc && fallback === \"dicebear\" && name\n ? sanitiseImageSrc(dicebearUrlFor(name))\n : \"\";\n const src = explicitSrc || generated;\n if (src) {\n const img = el(\"img\", { src, alt: name, loading: \"lazy\" });\n img.onerror = (event) => {\n const ev = event as Event;\n const live = (ev.currentTarget ?? ev.target) as Element;\n live.replaceWith(el(\"span\", { class: \"rui-avatar-fallback\" }, [initialsFor(name)]));\n };\n root.append(img);\n } else {\n root.append(el(\"span\", { class: \"rui-avatar-fallback\" }, [initialsFor(name)]));\n }\n const status = asString(props.status);\n if (status) root.append(el(\"span\", { class: \"rui-avatar-status\", \"data-status\": status }));\n return root;\n },\n};\n\nexport const AvatarGroup: ComponentSpec = {\n name: \"AvatarGroup\",\n description:\n \"Stack of overlapping avatars with a `+N` chip when the list overflows. \" +\n \"Pass either Avatar(...) nodes or plain {name, src} objects.\",\n props: [\n { name: \"items\", type: \"Avatar[]\", description: \"Avatar(...) nodes or {name, src} objects\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Maximum avatars to show (default 4)\" },\n { name: \"size\", type: \"string\", optional: true, enum: AVATAR_SIZES },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const max = Math.max(1, Math.floor(Number(props.max ?? 4)));\n const size = asString(props.size, \"md\");\n const visible = items.slice(0, max);\n const overflow = items.length - visible.length;\n const root = el(\"div\", { class: \"rui-avatar-group\", \"data-size\": size });\n for (const item of visible) {\n if (item && typeof item === \"object\" && (item as { __kind?: string }).__kind === \"Component\") {\n root.append(helpers.renderNode(item));\n continue;\n }\n const data = item as { name?: unknown; src?: unknown } | string | null;\n const name = typeof data === \"string\" ? data : asString((data ?? {}).name);\n const src = typeof data === \"string\" ? \"\" : asString((data ?? {}).src);\n root.append(Avatar.render(\n { __kind: \"Component\", name: \"Avatar\", args: [], argMeta: [] },\n { name, src, size },\n helpers,\n ));\n }\n if (overflow > 0) {\n root.append(el(\"span\", {\n class: \"rui-avatar rui-avatar-overflow\",\n \"data-size\": size,\n }, [el(\"span\", { class: \"rui-avatar-fallback\" }, [`+${overflow}`])]));\n }\n return root;\n },\n};\n\nexport const Progress: ComponentSpec = {\n name: \"Progress\",\n description:\n \"Linear progress bar. `value` is clamped between 0 and `max` (default \" +\n \"100). `indeterminate=true` renders a looping animation when the total \" +\n \"is unknown. Provide `segments` to render a segmented progress strip \" +\n \"(steps in an onboarding flow), or `buffered` for a secondary \" +\n \"buffer indicator (downloads, video buffering).\",\n props: [\n { name: \"value\", type: \"number\", optional: true, description: \"Current progress; ignored when indeterminate\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Upper bound (default 100)\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Shown above the bar\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n { name: \"indeterminate\", type: \"boolean\", optional: true },\n { name: \"showValue\", type: \"boolean\", optional: true, description: \"Show the numeric value on the right\" },\n { name: \"segments\", type: \"number\", optional: true, description: \"Render N equal segments (filled by current step)\" },\n { name: \"buffered\", type: \"number\", optional: true, description: \"Secondary value (0..max) drawn behind the bar\" },\n ],\n render: (_node, props) => {\n const max = Math.max(1, asNumber(props.max, 100));\n const indeterminate = asBoolean(props.indeterminate);\n const value = Math.max(0, Math.min(max, asNumber(props.value, 0)));\n const percent = Math.round((value / max) * 100);\n const segments = Math.max(0, Math.floor(asNumber(props.segments, 0)));\n const buffered = props.buffered != null ? Math.max(0, Math.min(max, asNumber(props.buffered, 0))) : null;\n const root = el(\"div\", { class: \"rui-progress\", \"data-tone\": asString(props.tone, \"primary\") });\n const label = asString(props.label);\n const showValue = asBoolean(props.showValue);\n if (label || showValue) {\n const head = el(\"div\", { class: \"rui-progress-head\" });\n head.append(el(\"span\", { class: \"rui-progress-label\" }, [label]));\n if (showValue && !indeterminate) {\n const display = segments > 0\n ? `${Math.min(segments, Math.round((value / max) * segments))} / ${segments}`\n : `${percent}%`;\n head.append(el(\"span\", { class: \"rui-progress-value\" }, [display]));\n }\n root.append(head);\n }\n\n if (segments > 0 && !indeterminate) {\n const trackRoot = el(\"div\", {\n class: \"rui-progress-segments\",\n role: \"progressbar\",\n \"aria-valuemin\": \"0\",\n \"aria-valuemax\": String(segments),\n \"aria-valuenow\": String(Math.min(segments, Math.round((value / max) * segments))),\n });\n const filled = Math.min(segments, Math.round((value / max) * segments));\n for (let i = 0; i < segments; i += 1) {\n trackRoot.append(el(\"span\", {\n class: \"rui-progress-segment\",\n \"data-filled\": i < filled ? \"true\" : \"false\",\n }));\n }\n root.append(trackRoot);\n return root;\n }\n\n const track = el(\"div\", {\n class: \"rui-progress-track\",\n role: \"progressbar\",\n \"aria-valuemin\": \"0\",\n \"aria-valuemax\": String(max),\n \"aria-valuenow\": indeterminate ? null : String(value),\n \"data-indeterminate\": indeterminate ? \"true\" : \"false\",\n });\n if (buffered !== null) {\n const bufferedPercent = Math.round((buffered / max) * 100);\n track.append(el(\"div\", {\n class: \"rui-progress-buffer\",\n style: `width:${bufferedPercent}%`,\n \"aria-hidden\": \"true\",\n }));\n }\n track.append(el(\"div\", {\n class: \"rui-progress-bar\",\n style: indeterminate ? \"\" : `width:${percent}%`,\n }));\n root.append(track);\n return root;\n },\n};\n\nexport const Switch: ComponentSpec = {\n name: \"Switch\",\n description:\n \"Compact on/off toggle. Pass a `$variable` as `value` for two-way binding \" +\n \"— prefer Switch over Checkbox when the control represents a setting. \" +\n \"`onChange(checked)` fires with the new boolean.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"value\", type: \"boolean\", optional: true, aliases: [\"checked\"], description: \"Bound value (typically $variable)\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new boolean value\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const root = el(\"label\", {\n class: \"rui-switch\",\n for: id,\n \"data-disabled\": asBoolean(props.disabled) ? \"true\" : \"false\",\n });\n const isChecked = asBoolean(props.value);\n const input = el(\"input\", {\n type: \"checkbox\",\n id,\n name: id,\n class: \"rui-switch-input\",\n role: \"switch\",\n checked: isChecked ? \"\" : null,\n disabled: asBoolean(props.disabled) ? \"\" : null,\n }) as HTMLInputElement;\n input.checked = isChecked;\n const track = el(\"span\", { class: \"rui-switch-track\" }, [\n el(\"span\", { class: \"rui-switch-thumb\" }),\n ]);\n const stateName = node.argMeta?.[2]?.stateRef;\n if (stateName) {\n helpers.bindState(input, stateName, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).checked,\n });\n }\n if (props.onChange != null) {\n input.addEventListener(\"change\", (e) => {\n helpers.invoke(props.onChange, (e.currentTarget as HTMLInputElement).checked);\n });\n }\n const label = asString(props.label);\n const description = asString(props.description);\n root.append(input, track);\n if (label || description) {\n const meta = el(\"span\", { class: \"rui-switch-meta\" });\n if (label) meta.append(el(\"span\", { class: \"rui-switch-label\" }, [label]));\n if (description) meta.append(el(\"span\", { class: \"rui-switch-description\" }, [description]));\n root.append(meta);\n }\n return root;\n },\n};\n\nexport const ToggleGroup: ComponentSpec = {\n name: \"ToggleGroup\",\n description:\n \"Group of mutually-exclusive Toggle-style buttons (single-select). Items \" +\n \"are `[value, label]` arrays, `{value, label, icon?}` objects, or plain \" +\n \"strings (used for both value and label). Pass a `$variable` as `value` \" +\n \"for two-way binding. `onChange(value)` fires with the newly-selected value.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"items\", type: \"any[]\" },\n { name: \"value\", type: \"any\", optional: true },\n { name: \"variant\", type: \"string\", optional: true, enum: [\"default\", \"outline\"] },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\"] },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-selected value\" },\n ],\n render: (node, props, helpers) => {\n const current = asString(props.value);\n const variant = asString(props.variant, \"outline\");\n const size = asString(props.size, \"md\");\n const root = el(\"div\", {\n class: \"rui-toggle-group\",\n role: \"radiogroup\",\n \"data-variant\": variant,\n \"data-size\": size,\n });\n const stateName = node.argMeta?.[2]?.stateRef;\n for (const raw of asArray<unknown>(props.items)) {\n const { value, label, icon } = extractToggleItem(raw);\n const isOn = value === current;\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-toggle\",\n role: \"radio\",\n \"aria-checked\": isOn ? \"true\" : \"false\",\n \"data-variant\": variant,\n \"data-size\": size,\n \"data-state\": isOn ? \"on\" : \"off\",\n \"data-value\": value,\n });\n const itemIconNode = renderIcon(icon, { className: \"rui-toggle-icon\" });\n if (itemIconNode) btn.append(itemIconNode);\n btn.append(el(\"span\", { class: \"rui-toggle-label\" }, [label]));\n btn.onclick = () => {\n if (stateName) helpers.setState(stateName, value);\n helpers.invoke(props.onChange, value);\n };\n root.append(btn);\n }\n return root;\n },\n};\n\nfunction extractToggleItem(raw: unknown): { value: string; label: string; icon: string } {\n if (typeof raw === \"string\") return { value: raw, label: raw, icon: \"\" };\n if (Array.isArray(raw)) {\n return {\n value: asString(raw[0]),\n label: asString(raw[1], asString(raw[0])),\n icon: asString(raw[2]),\n };\n }\n if (raw && typeof raw === \"object\") {\n const r = raw as { value?: unknown; label?: unknown; icon?: unknown };\n const value = asString(r.value);\n return { value, label: asString(r.label, value), icon: asString(r.icon) };\n }\n return { value: \"\", label: \"\", icon: \"\" };\n}\n\nexport const Tooltip: ComponentSpec = {\n name: \"Tooltip\",\n description:\n \"Wraps a trigger node and shows `label` text when the user hovers or \" +\n \"focuses it. Pure CSS — no JS needed. The tooltip hides on \" +\n \"click/touch (so it does not stay stuck on touch devices) and \" +\n \"supports `top|bottom|left|right` placement. Use for short hints \" +\n \"(≤6 words); reach for HoverCard when you need rich content.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"trigger\", type: \"Node\", aliases: [\"children\"] },\n { name: \"side\", type: \"string\", optional: true, enum: [\"top\", \"bottom\", \"left\", \"right\"], aliases: [\"placement\"] },\n ],\n render: (_node, props, helpers) => {\n const side = asString(props.side, \"top\");\n const root = el(\"span\", {\n class: \"rui-tooltip\",\n \"data-side\": side,\n tabindex: \"0\",\n });\n root.append(el(\"span\", { class: \"rui-tooltip-trigger\" }, [\n helpers.renderNode(props.trigger),\n ]));\n const content = el(\"span\", { class: \"rui-tooltip-content\", role: \"tooltip\" }, [\n asString(props.label),\n ]);\n content.append(el(\"span\", { class: \"rui-tooltip-arrow\", \"aria-hidden\": \"true\" }));\n root.append(content);\n // Native :focus-within would leave the tooltip visible after a click\n // (because the trigger keeps focus). We blur the wrapper on\n // mousedown so the next render hides the tooltip immediately.\n root.addEventListener(\"mousedown\", () => {\n requestAnimationFrame(() => {\n if (document.activeElement === root || root.contains(document.activeElement)) {\n (document.activeElement as HTMLElement | null)?.blur?.();\n }\n });\n });\n return root;\n },\n};\n\nexport const HoverCard: ComponentSpec = {\n name: \"HoverCard\",\n description:\n \"Wraps a trigger node and reveals a card with rich content on hover/focus. \" +\n \"Use for previewing a referenced item (profile, link target, definition).\",\n props: [\n { name: \"trigger\", type: \"Node\" },\n { name: \"content\", type: \"Node[]\", aliases: [\"children\"] },\n { name: \"side\", type: \"string\", optional: true, enum: [\"top\", \"bottom\", \"left\", \"right\"], aliases: [\"placement\"] },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Force the card open (otherwise reveal on hover/focus)\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"span\", {\n class: \"rui-hover-card\",\n \"data-side\": asString(props.side, \"bottom\"),\n \"data-open\": asBoolean(props.open) ? \"true\" : null,\n tabindex: \"0\",\n });\n root.append(el(\"span\", { class: \"rui-hover-card-trigger\" }, [\n helpers.renderNode(props.trigger),\n ]));\n const card = el(\"span\", { class: \"rui-hover-card-content\", role: \"dialog\" });\n for (const child of asArray(props.content)) card.append(helpers.renderNode(child));\n root.append(card);\n return root;\n },\n};\n\nconst RATING_ICONS: Record<string, { full: string; half: string; empty: string }> = {\n star: { full: \"star\", half: \"star-half-stroke\", empty: \"regular:star\" },\n heart: { full: \"heart\", half: \"heart\", empty: \"regular:heart\" },\n thumb: { full: \"thumbs-up\", half: \"thumbs-up\", empty: \"regular:thumbs-up\" },\n fire: { full: \"fire\", half: \"fire\", empty: \"regular:fire\" },\n bolt: { full: \"bolt\", half: \"bolt\", empty: \"regular:bolt\" },\n};\n\nexport const Rating: ComponentSpec = {\n name: \"Rating\",\n description:\n \"Compact 0–5 star rating with optional numeric badge and review \" +\n \"count. Use in product cards, testimonials, reviews, and KPI rows. \" +\n \"Pass `interactive=true` and a `$variable` as `value` to let users \" +\n \"rate something; with `halfStep=true` clicking the left half of a \" +\n \"star sets a fractional value. `icon` swaps the glyph family — \" +\n \"`star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom \" +\n \"Font Awesome name.\",\n props: [\n { name: \"value\", type: \"number\", description: \"0–max; can be a $variable when interactive\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Maximum number of stars (default 5)\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Inline text shown after the stars (e.g. \\\"4.2 of 5\\\")\" },\n { name: \"count\", type: \"number\", optional: true, description: \"Review/voter count rendered in parentheses\" },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\"] },\n { name: \"interactive\", type: \"boolean\", optional: true, description: \"Allow clicking a star to set the value\" },\n { name: \"readonly\", type: \"boolean\", optional: true, description: \"Force read-only (overrides `interactive`)\" },\n { name: \"halfStep\", type: \"boolean\", optional: true, description: \"Allow half-star resolution when interactive\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Icon family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any FA name\" },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new rating when the user clicks a star (interactive mode)\" },\n ],\n render: (node, props, helpers) => {\n const max = Math.max(1, Math.floor(asNumber(props.max, 5)));\n const raw = Math.max(0, Math.min(max, asNumber(props.value, 0)));\n const size = asString(props.size, \"md\");\n const interactive = asBoolean(props.interactive) && !asBoolean(props.readonly);\n const halfStep = asBoolean(props.halfStep);\n const stateName = node.argMeta?.[0]?.stateRef;\n const iconChoice = resolveRatingIcons(asString(props.icon));\n const root = el(\"div\", {\n class: \"rui-rating\",\n \"data-size\": size,\n \"data-interactive\": interactive && stateName ? \"true\" : \"false\",\n \"data-half-step\": interactive && stateName && halfStep ? \"true\" : \"false\",\n role: \"img\",\n \"aria-label\": `${raw} of ${max}`,\n });\n const stars = el(\"span\", { class: \"rui-rating-stars\" });\n for (let i = 1; i <= max; i += 1) {\n const fill = Math.max(0, Math.min(1, raw - (i - 1)));\n const iconName =\n fill >= 1 ? iconChoice.full : fill > 0 ? iconChoice.half : iconChoice.empty;\n const iconClasses = resolveIconClasses(iconName).join(\" \");\n const star = el(interactive && stateName ? \"button\" : \"span\", {\n class: `rui-rating-star ${iconClasses}`.trim(),\n type: interactive && stateName ? \"button\" : null,\n \"data-fill\": fill >= 1 ? \"full\" : fill > 0 ? \"half\" : \"empty\",\n \"aria-label\": interactive && stateName ? `Rate ${i}` : null,\n \"aria-hidden\": interactive && stateName ? null : \"true\",\n });\n if (interactive && stateName) {\n const fullValue = i;\n const halfValue = i - 0.5;\n (star as HTMLButtonElement).onclick = (event) => {\n let next: number = fullValue;\n if (halfStep) {\n // Determine which half of the star was clicked. Resolve from\n // the live element via the event so the handler still works\n // after the morph reconciler keeps the previous DOM.\n const evt = event as MouseEvent;\n const target = (evt.currentTarget ?? evt.target) as HTMLElement;\n const rect = target.getBoundingClientRect();\n if (rect.width > 0 && evt.clientX - rect.left < rect.width / 2) {\n next = halfValue;\n }\n }\n helpers.setState(stateName, next);\n helpers.invoke(props.onChange, next);\n };\n }\n stars.append(star);\n }\n root.append(stars);\n const label = asString(props.label);\n if (label) root.append(el(\"span\", { class: \"rui-rating-label\" }, [label]));\n const count = props.count != null ? asNumber(props.count, 0) : null;\n if (count !== null && count > 0) {\n root.append(el(\"span\", { class: \"rui-rating-count\" }, [`(${count.toLocaleString()})`]));\n }\n return root;\n },\n};\n\nfunction resolveRatingIcons(icon: string): { full: string; half: string; empty: string } {\n const key = icon.trim().toLowerCase();\n if (!key) return RATING_ICONS.star!;\n if (RATING_ICONS[key]) return RATING_ICONS[key]!;\n // Custom icon name (e.g. \"circle\") — fill/half/empty reuse the same glyph\n // and rely on the data-fill attribute for visual differentiation in CSS.\n return { full: key, half: key, empty: `regular:${key}` };\n}\n\nexport const ProgressRing: ComponentSpec = {\n name: \"ProgressRing\",\n description:\n \"Circular progress indicator. Use for KPIs, quotas, completion rings, \" +\n \"and any metric better shown as a circle than a bar. Renders the \" +\n \"value (or a custom label) inside the ring.\",\n props: [\n { name: \"value\", type: \"number\", optional: true, description: \"Current value (ignored when indeterminate)\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Upper bound (default 100)\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Text shown inside the ring (default \\\"{percent}%\\\")\" },\n { name: \"caption\", type: \"string\", optional: true, aliases: [\"description\"], description: \"Small caption rendered under the ring\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\"] },\n { name: \"indeterminate\", type: \"boolean\", optional: true },\n ],\n render: (_node, props) => {\n const max = Math.max(1, asNumber(props.max, 100));\n const indeterminate = asBoolean(props.indeterminate);\n const value = Math.max(0, Math.min(max, asNumber(props.value, 0)));\n const percent = Math.round((value / max) * 100);\n const size = asString(props.size, \"md\");\n const px = size === \"lg\" ? 120 : size === \"sm\" ? 72 : 96;\n const stroke = size === \"lg\" ? 10 : size === \"sm\" ? 6 : 8;\n const r = (px - stroke) / 2;\n const circumference = 2 * Math.PI * r;\n const offset = indeterminate ? circumference * 0.65 : circumference * (1 - percent / 100);\n const root = el(\"div\", {\n class: \"rui-progress-ring\",\n \"data-tone\": asString(props.tone, \"primary\"),\n \"data-size\": size,\n \"data-indeterminate\": indeterminate ? \"true\" : \"false\",\n });\n const wrap = el(\"div\", { class: \"rui-progress-ring-wrap\" });\n const svgNS = \"http://www.w3.org/2000/svg\";\n const svg = document.createElementNS(svgNS, \"svg\");\n svg.setAttribute(\"width\", String(px));\n svg.setAttribute(\"height\", String(px));\n svg.setAttribute(\"viewBox\", `0 0 ${px} ${px}`);\n svg.setAttribute(\"class\", \"rui-progress-ring-svg\");\n const track = document.createElementNS(svgNS, \"circle\");\n track.setAttribute(\"class\", \"rui-progress-ring-track\");\n track.setAttribute(\"cx\", String(px / 2));\n track.setAttribute(\"cy\", String(px / 2));\n track.setAttribute(\"r\", String(r));\n track.setAttribute(\"stroke-width\", String(stroke));\n track.setAttribute(\"fill\", \"none\");\n svg.appendChild(track);\n const bar = document.createElementNS(svgNS, \"circle\");\n bar.setAttribute(\"class\", \"rui-progress-ring-bar\");\n bar.setAttribute(\"cx\", String(px / 2));\n bar.setAttribute(\"cy\", String(px / 2));\n bar.setAttribute(\"r\", String(r));\n bar.setAttribute(\"stroke-width\", String(stroke));\n bar.setAttribute(\"fill\", \"none\");\n bar.setAttribute(\"stroke-linecap\", \"round\");\n bar.setAttribute(\"stroke-dasharray\", String(circumference));\n bar.setAttribute(\"stroke-dashoffset\", String(offset));\n svg.appendChild(bar);\n wrap.append(svg);\n const rawLabel = asString(props.label, indeterminate ? \"…\" : `${percent}%`);\n const center = el(\"span\", { class: \"rui-progress-ring-value\" });\n // Allow the inner label to be a Font Awesome icon name (e.g. \"circle-check\")\n // for completion-style rings, while still accepting plain text labels.\n const labelIcon = renderIcon(rawLabel, { className: \"rui-progress-ring-icon\" });\n if (labelIcon && resolveIconClasses(rawLabel).length > 0) {\n center.append(labelIcon);\n } else {\n center.append(document.createTextNode(rawLabel));\n }\n wrap.append(center);\n root.append(wrap);\n const caption = asString(props.caption);\n if (caption) root.append(el(\"span\", { class: \"rui-progress-ring-caption\" }, [caption]));\n return root;\n },\n};\n\nexport const ChatBubble: ComponentSpec = {\n name: \"ChatBubble\",\n description:\n \"Single chat-style message bubble with author, time, and body. Use \" +\n \"for conversation threads, agent transcripts, support chats, and any \" +\n \"message-style UI. Set `from=\\\"me\\\"` (or any non-empty author) for \" +\n \"the active speaker — the bubble aligns to the right with a primary \" +\n \"tint. `from=\\\"agent\\\"` (default) renders as the canonical incoming \" +\n \"bubble on the left.\",\n props: [\n { name: \"author\", type: \"string\" },\n { name: \"body\", type: \"string\", aliases: [\"text\", \"message\"] },\n { name: \"time\", type: \"string\", optional: true },\n { name: \"avatarSrc\", type: \"string\", optional: true, aliases: [\"src\"] },\n { name: \"from\", type: \"string\", optional: true, enum: [\"agent\", \"me\", \"system\"], aliases: [\"role\"], description: \"Lane (default agent)\" },\n { name: \"status\", type: \"string\", optional: true, enum: [\"sending\", \"sent\", \"delivered\", \"read\", \"error\"] },\n ],\n render: (_node, props) => {\n const from = asString(props.from, \"agent\");\n const root = el(\"div\", {\n class: \"rui-chat-bubble\",\n \"data-from\": from,\n });\n if (from !== \"me\") {\n root.append(renderAvatarFallback(asString(props.avatarSrc), asString(props.author)));\n }\n const bubble = el(\"div\", { class: \"rui-chat-bubble-bubble\" });\n const head = el(\"header\", { class: \"rui-chat-bubble-head\" });\n head.append(el(\"span\", { class: \"rui-chat-bubble-author\" }, [asString(props.author)]));\n const time = asString(props.time);\n if (time) head.append(el(\"span\", { class: \"rui-chat-bubble-time\" }, [time]));\n bubble.append(head);\n bubble.append(el(\"p\", { class: \"rui-chat-bubble-body\" }, [asString(props.body)]));\n const status = asString(props.status);\n if (status) bubble.append(el(\"span\", { class: \"rui-chat-bubble-status\", \"data-status\": status }, [status]));\n root.append(bubble);\n if (from === \"me\") {\n root.append(renderAvatarFallback(asString(props.avatarSrc), asString(props.author)));\n }\n return root;\n },\n};\n\nfunction renderAvatarFallback(src: string, name: string): HTMLElement {\n const wrap = el(\"span\", { class: \"rui-chat-bubble-avatar\" });\n const safeSrc = sanitiseImageSrc(src);\n if (safeSrc) {\n wrap.append(el(\"img\", { src: safeSrc, alt: name, loading: \"lazy\" }));\n } else {\n wrap.append(el(\"span\", { class: \"rui-chat-bubble-fallback\" }, [initialsFor(name)]));\n }\n return wrap;\n}\n\nexport const Kbd: ComponentSpec = {\n name: \"Kbd\",\n description:\n \"Renders a keyboard shortcut chip (e.g. `Cmd+K`). Pass a single label, or \" +\n \"multiple labels as an array to render a `key + key + …` combo.\",\n props: [\n { name: \"keys\", type: \"string | string[]\" },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\"] },\n ],\n render: (_node, props) => {\n const size = asString(props.size, \"md\");\n const root = el(\"span\", { class: \"rui-kbd-group\", \"data-size\": size });\n const keys = Array.isArray(props.keys) ? props.keys : [props.keys];\n keys.forEach((key, i) => {\n const label = asString(key);\n if (!label) return;\n if (i > 0) root.append(el(\"span\", { class: \"rui-kbd-sep\" }, [\"+\"]));\n root.append(el(\"kbd\", { class: \"rui-kbd\" }, [label]));\n });\n return root;\n },\n};\n\nconst POPOVER_SIDES = [\"bottom\", \"top\", \"left\", \"right\"] as const;\nconst POPOVER_ALIGNS = [\"start\", \"center\", \"end\"] as const;\n\nexport const Popover: ComponentSpec = {\n name: \"Popover\",\n description:\n \"Click-triggered popup with arbitrary rich content. Use when \" +\n \"HoverCard's hover trigger is too eager and Modal/Sheet is too heavy — \" +\n \"perfect for filter panels, color pickers, share menus, and small \" +\n \"settings flyouts. The trigger stays visible while the popover is \" +\n \"open — clicking it again, clicking outside, pressing Escape, or \" +\n \"clicking the built-in × button all close it.\",\n props: [\n { name: \"trigger\", type: \"Node\", description: \"Clickable trigger element (Button, Avatar, IconButton, …). The trigger remains visible while the popover is open.\" },\n { name: \"content\", type: \"Node[]\", aliases: [\"children\"], description: \"Body rendered inside the popover\" },\n { name: \"title\", type: \"string\", optional: true, description: \"Optional bold heading rendered above the content\" },\n { name: \"side\", type: \"string\", optional: true, enum: POPOVER_SIDES, aliases: [\"placement\"], description: \"Where the popover opens relative to the trigger (default \\\"bottom\\\")\" },\n { name: \"align\", type: \"string\", optional: true, enum: POPOVER_ALIGNS, description: \"Alignment along the trigger edge (default \\\"start\\\")\" },\n { name: \"width\", type: \"string\", optional: true, description: \"CSS width for the popover panel (default \\\"280px\\\")\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Initial open state — use to demo or pre-open the popover\" },\n ],\n render: (_node, props, helpers) => {\n const initialOpen = asBoolean(props.open);\n const openSlot = helpers.useInstanceState<boolean>(\"open\", initialOpen);\n const isOpen = openSlot.get();\n const width = sanitiseCssLength(props.width, \"\");\n const root = el(\"div\", {\n class: \"rui-popover\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n \"data-side\": asString(props.side, \"bottom\"),\n \"data-align\": asString(props.align, \"start\"),\n });\n\n // Render the user's trigger directly and wrap it in a span so we can\n // attach the toggle handler without nesting <button> inside <button>\n // (which is invalid HTML and silently swallows clicks in some browsers).\n const triggerWrap = el(\"span\", {\n class: \"rui-popover-trigger\",\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": isOpen ? \"true\" : \"false\",\n });\n triggerWrap.append(helpers.renderNode(props.trigger));\n root.append(triggerWrap);\n\n const body = el(\"div\", {\n class: \"rui-popover-content\",\n role: \"dialog\",\n style: width ? `width: ${width};` : null,\n });\n // Always render a header so the close (×) button has a stable slot,\n // whether or not the user provided a title.\n const header = el(\"div\", { class: \"rui-popover-header\" });\n const titleText = asString(props.title);\n header.append(\n titleText\n ? el(\"div\", { class: \"rui-popover-title\" }, [titleText])\n : el(\"span\", { class: \"rui-popover-title-spacer\" }),\n );\n const closeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-popover-close\",\n \"aria-label\": \"Close popover\",\n }, [\"×\"]);\n closeBtn.onclick = (event) => {\n event.stopPropagation();\n setPopoverOpen(closeBtn, false, openSlot);\n };\n header.append(closeBtn);\n body.append(header);\n for (const child of asArray(props.content)) {\n body.append(helpers.renderNode(child));\n }\n root.append(body);\n\n // Property-based handlers so the morph reconciler can copy the latest\n // closure (with up-to-date `openSlot`) onto kept DOM. `addEventListener`\n // would leak a fresh listener onto every detached re-render snapshot.\n triggerWrap.onclick = (event) => {\n event.stopPropagation();\n const origin = (event.currentTarget ?? event.target) as Element;\n const next = !openSlot.get();\n const liveRoot = setPopoverOpen(origin, next, openSlot);\n if (next && liveRoot) installPopoverDismiss(liveRoot, openSlot);\n };\n triggerWrap.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n const origin = (e.currentTarget ?? e.target) as Element;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const next = !openSlot.get();\n const liveRoot = setPopoverOpen(origin, next, openSlot);\n if (next && liveRoot) installPopoverDismiss(liveRoot, openSlot);\n } else if (e.key === \"Escape\" && openSlot.get()) {\n e.preventDefault();\n setPopoverOpen(origin, false, openSlot);\n }\n };\n\n return root;\n },\n};\n\n/**\n * Toggle a Popover's open state and reflect it in the live DOM so the\n * change feels instant. Returns the live root so callers can install the\n * outside-click / Escape dismiss handlers on `open`.\n */\nconst setPopoverOpen = (\n origin: Element,\n next: boolean,\n openSlot: { set: (value: boolean) => void },\n): HTMLElement | null => {\n openSlot.set(next);\n const liveRoot = origin.closest(\".rui-popover\") as HTMLElement | null;\n if (!liveRoot) return null;\n liveRoot.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n const trigger = liveRoot.querySelector(\".rui-popover-trigger\");\n trigger?.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n trigger?.setAttribute(\"data-state\", next ? \"open\" : \"closed\");\n if (!next) disposeDismissListeners(liveRoot);\n return liveRoot;\n};\n\nconst installPopoverDismiss = (\n liveRoot: HTMLElement,\n openSlot: { set: (value: boolean) => void },\n): void => {\n installDismissListeners({\n liveRoot,\n onDismiss: () => {\n openSlot.set(false);\n liveRoot.setAttribute(\"data-open\", \"false\");\n const trigger = liveRoot.querySelector(\".rui-popover-trigger\");\n trigger?.setAttribute(\"aria-expanded\", \"false\");\n trigger?.setAttribute(\"data-state\", \"closed\");\n },\n });\n};\n\nconst TOAST_TONES = [\"default\", \"primary\", \"success\", \"warning\", \"danger\", \"info\"] as const;\n\nconst TOASTS_POSITIONS = [\n \"top-right\", \"top-left\", \"top-center\",\n \"bottom-right\", \"bottom-left\", \"bottom-center\",\n] as const;\n\nexport const Toast: ComponentSpec = {\n name: \"Toast\",\n description:\n \"Single transient notification card. Always shows a close (×) button \" +\n \"that removes the toast from the DOM (and fires `onClose` if set). \" +\n \"Pass `duration` (ms) to auto-dismiss, or `position` for a standalone \" +\n \"one-off toast (the renderer will pin it to the viewport corner so \" +\n \"you do not have to wrap a single notification in `Stack(...)`). \" +\n \"Use `Toasts` for grouped stacks; prefer `Banner` for top-of-page \" +\n \"announcements and `Notification` for permanent inbox entries.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"message\", type: \"string\", optional: true, aliases: [\"description\"] },\n { name: \"tone\", type: \"string\", optional: true, enum: TOAST_TONES, description: \"Visual accent (default \\\"default\\\")\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name (default picked from tone)\" },\n { name: \"duration\", type: \"number\", optional: true, description: \"Auto-dismiss after N milliseconds (e.g. 4000). Omit to keep the toast until the user closes it.\" },\n { name: \"action\", type: \"Button\", optional: true, description: \"Optional inline `Button` action shown above the message\" },\n { name: \"onClose\", type: \"callable\", optional: true, description: \"Callable invoked when the toast is dismissed (× button, auto-dismiss, or programmatic)\" },\n { name: \"position\", type: \"string\", optional: true, enum: TOASTS_POSITIONS, description: \"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`\" },\n ],\n render: (_node, props, helpers) => {\n const tone = asString(props.tone, \"default\");\n const position = asString(props.position);\n const root = el(\"div\", {\n class: position ? \"rui-toast rui-toast-standalone\" : \"rui-toast\",\n role: \"status\",\n \"aria-live\": tone === \"danger\" ? \"assertive\" : \"polite\",\n \"data-tone\": tone,\n \"data-position\": position || null,\n });\n const iconName = asString(props.icon) || defaultToastIcon(tone);\n const iconNode = renderIcon(iconName, { className: \"rui-toast-icon\" });\n if (iconNode) root.append(iconNode);\n const body = el(\"div\", { class: \"rui-toast-body\" });\n body.append(el(\"div\", { class: \"rui-toast-title\" }, [asString(props.title)]));\n const message = asString(props.message);\n if (message) body.append(el(\"div\", { class: \"rui-toast-message\" }, [message]));\n if (props.action) {\n const actionWrap = el(\"div\", { class: \"rui-toast-action\" });\n actionWrap.append(helpers.renderNode(props.action));\n body.append(actionWrap);\n }\n root.append(body);\n\n // Track dismiss locally so re-renders don't restart the timer or undo\n // the manual close. `useInstanceState` keeps the slot keyed by the\n // toast's path in the tree.\n const dismissedSlot = helpers.useInstanceState<boolean>(\"dismissed\", false);\n const timerSlot = helpers.useInstanceState<ReturnType<typeof setTimeout> | null>(\"timer\", null);\n\n // Resolves whichever .rui-toast element is currently in the DOM,\n // preferring the live one over the closure-captured (potentially\n // detached) root.\n const liveToast = (origin?: Element): HTMLElement | null => {\n if (origin) {\n const live = origin.closest(\".rui-toast\") as HTMLElement | null;\n if (live) return live;\n }\n return root.isConnected ? root : null;\n };\n\n const cancelTimer = (): void => {\n const handle = timerSlot.get();\n if (handle !== null) {\n clearTimeout(handle);\n timerSlot.set(null);\n }\n };\n\n const removalTimerSlot = helpers.useInstanceState<ReturnType<typeof setTimeout> | null>(\"removal-timer\", null);\n\n const dismiss = (origin?: Element): void => {\n if (dismissedSlot.get()) return;\n dismissedSlot.set(true);\n // Clear the pending auto-dismiss timer so it doesn't fire `onClose`\n // a second time after the user has already closed the toast.\n cancelTimer();\n const target = liveToast(origin);\n if (!target) return;\n target.classList.add(\"is-dismissed\");\n // Allow the CSS exit animation to complete before unmounting.\n const handle = setTimeout(() => {\n removalTimerSlot.set(null);\n target.remove();\n }, 180);\n removalTimerSlot.set(handle);\n helpers.registerDisposer(() => {\n const h = removalTimerSlot.get();\n if (h !== null) {\n clearTimeout(h);\n removalTimerSlot.set(null);\n }\n }, \"exit-animation-timer\");\n helpers.invoke(props.onClose);\n };\n\n const closeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-toast-close\",\n \"aria-label\": \"Dismiss notification\",\n }, [\"×\"]);\n closeBtn.onclick = (event) => {\n event.stopPropagation();\n dismiss((event.currentTarget ?? event.target) as Element);\n };\n root.append(closeBtn);\n\n const duration = asNumber(props.duration, 0);\n if (duration > 0 && timerSlot.get() === null && !dismissedSlot.get()) {\n const handle = setTimeout(() => {\n timerSlot.set(null);\n // Only auto-dismiss if the element is still in the document and\n // hasn't been manually closed.\n if (!dismissedSlot.get() && root.isConnected) dismiss();\n }, duration);\n timerSlot.set(handle);\n // If the toast is unmounted before the timer fires (parent re-rendered\n // without it, page navigated, host cleared), cancel the timer instead\n // of letting it fire a stale `onClose` action.\n helpers.registerDisposer(() => {\n const h = timerSlot.get();\n if (h !== null) {\n clearTimeout(h);\n timerSlot.set(null);\n }\n }, \"auto-dismiss-timer\");\n }\n\n if (dismissedSlot.get()) {\n // The toast was already dismissed in a previous render cycle —\n // return an empty placeholder so the reconciler doesn't resurrect it.\n const placeholder = el(\"div\", { class: \"rui-toast-placeholder\", hidden: \"\" });\n return placeholder;\n }\n return root;\n },\n};\n\nfunction defaultToastIcon(tone: string): string {\n switch (tone) {\n case \"success\": return \"circle-check\";\n case \"warning\": return \"triangle-exclamation\";\n case \"danger\": return \"circle-xmark\";\n case \"primary\": return \"bell\";\n case \"info\": return \"circle-info\";\n default: return \"circle-info\";\n }\n}\n\n","/**\n * Navigation primitives modeled after shadcn/ui:\n * Breadcrumb, BreadcrumbItem, Pagination, Navbar, NavbarItem.\n *\n * These are intentionally light — they wrap the existing Link/NavLink\n * components when an `href`/`to` is provided so routing stays consistent\n * with the rest of the library.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon, sanitiseHref,\n} from \"../utils.js\";\n\nexport const BreadcrumbItem: ComponentSpec = {\n name: \"BreadcrumbItem\",\n description:\n \"Single item inside a Breadcrumb trail. Provide `href` for a link, omit \" +\n \"it for the current/leaf page (rendered with emphasis).\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"href\", type: \"string\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Optional Font Awesome icon name\" },\n ],\n render: (_node, props) => {\n const root = el(\"li\", { class: \"rui-breadcrumb-item\" });\n const label = asString(props.label);\n // Sanitise the href so a hostile `javascript:` URL coming from an LLM\n // cannot fire on click. Empty input keeps the legacy \"current page\"\n // rendering path so leaf crumbs still render as plain text.\n const rawHref = asString(props.href);\n const safeHref = rawHref ? sanitiseHref(rawHref) : \"\";\n const inner: Array<Node | string | null> = [];\n const iconNode = renderIcon(props.icon, { className: \"rui-breadcrumb-icon\" });\n if (iconNode) inner.push(iconNode);\n inner.push(el(\"span\", { class: \"rui-breadcrumb-label\" }, [label]));\n if (safeHref) {\n root.append(el(\"a\", { class: \"rui-breadcrumb-link\", href: safeHref }, inner));\n } else {\n root.setAttribute(\"aria-current\", \"page\");\n const span = el(\"span\", { class: \"rui-breadcrumb-current\" });\n for (const node of inner) if (node) span.append(typeof node === \"string\" ? document.createTextNode(node) : node);\n root.append(span);\n }\n return root;\n },\n};\n\nexport const Breadcrumb: ComponentSpec = {\n name: \"Breadcrumb\",\n description:\n \"Trail of links showing the user's location. Children may be \" +\n \"BreadcrumbItem(label, href?) nodes OR plain strings (the last string is \" +\n \"treated as the current page).\",\n props: [\n { name: \"items\", type: \"BreadcrumbItem[] | string[]\" },\n { name: \"separator\", type: \"string\", optional: true, description: \"Default `/`\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const separator = asString(props.separator, \"/\");\n const root = el(\"nav\", { class: \"rui-breadcrumb\", \"aria-label\": \"Breadcrumb\" });\n const list = el(\"ol\", { class: \"rui-breadcrumb-list\" });\n items.forEach((item, i) => {\n if (i > 0) {\n list.append(el(\"li\", { class: \"rui-breadcrumb-separator\", \"aria-hidden\": \"true\" }, [separator]));\n }\n if (item && typeof item === \"object\" && (item as { __kind?: string }).__kind === \"Component\") {\n list.append(helpers.renderNode(item));\n return;\n }\n const label = asString(item);\n const isLast = i === items.length - 1;\n list.append(BreadcrumbItem.render(\n { __kind: \"Component\", name: \"BreadcrumbItem\", args: [], argMeta: [] },\n { label, href: isLast ? \"\" : \"#\" },\n helpers,\n ));\n });\n root.append(list);\n return root;\n },\n};\n\nconst PER_PAGE_OPTIONS = [10, 20, 50, 100] as const;\n\nexport const Pagination: ComponentSpec = {\n name: \"Pagination\",\n description:\n \"Page navigator with Prev/Next, page numbers, and ellipses. Pass a \" +\n \"`$variable` as `page` for two-way binding — clicking a page button \" +\n \"sets that state to the new (1-indexed) value. Add `total` to render \" +\n \"a \\\"Showing N–M of T\\\" summary, pass `$variable` as `perPage` to \" +\n \"expose a per-page selector, or set `compact: true` to drop the \" +\n \"page-number row for tight toolbars.\",\n props: [\n { name: \"page\", type: \"number\", description: \"Current page (1-indexed); typically a $variable\" },\n { name: \"totalPages\", type: \"number\", aliases: [\"pages\"] },\n { name: \"siblings\", type: \"number\", optional: true, description: \"Number of page links shown around the current page (default 1)\" },\n { name: \"total\", type: \"number\", optional: true, description: \"Total record count — enables the \\\"Showing N–M of T\\\" summary\" },\n { name: \"perPage\", type: \"number\", optional: true, description: \"Bind a `$variable` to expose a per-page selector\" },\n { name: \"perPageOptions\", type: \"number[]\", optional: true, description: \"Override the per-page choices (default 10/20/50/100)\" },\n { name: \"compact\", type: \"boolean\", optional: true, description: \"Hide page numbers — keep Prev / Next only\" },\n ],\n render: (node, props, helpers) => {\n const total = Math.max(1, Math.floor(asNumber(props.totalPages, 1)));\n const current = Math.max(1, Math.min(total, Math.floor(asNumber(props.page, 1))));\n const siblings = Math.max(0, Math.floor(asNumber(props.siblings, 1)));\n const compact = asBoolean(props.compact);\n const stateName = node.argMeta?.[0]?.stateRef;\n\n const root = el(\"nav\", { class: \"rui-pagination\", \"aria-label\": \"Pagination\", \"data-compact\": compact ? \"true\" : \"false\" });\n\n const setPage = (next: number) => {\n if (!stateName) return;\n const clamped = Math.max(1, Math.min(total, next));\n if (clamped === current) return;\n helpers.setState(stateName, clamped);\n };\n\n // Optional record-count summary (\"Showing 21–30 of 123\").\n const totalRecords = props.total != null ? Math.max(0, Math.floor(asNumber(props.total, 0))) : null;\n const perPageValue = props.perPage != null ? Math.max(1, Math.floor(asNumber(props.perPage, 0))) : null;\n if (totalRecords !== null && perPageValue && perPageValue > 0) {\n const start = totalRecords === 0 ? 0 : (current - 1) * perPageValue + 1;\n const end = Math.min(totalRecords, current * perPageValue);\n root.append(el(\"span\", { class: \"rui-pagination-summary\" }, [\n totalRecords === 0\n ? \"No results\"\n : `Showing ${start.toLocaleString()}–${end.toLocaleString()} of ${totalRecords.toLocaleString()}`,\n ]));\n } else if (totalRecords !== null) {\n root.append(el(\"span\", { class: \"rui-pagination-summary\" }, [\n `${totalRecords.toLocaleString()} result${totalRecords === 1 ? \"\" : \"s\"}`,\n ]));\n }\n\n const buttonsWrap = el(\"div\", { class: \"rui-pagination-buttons\" });\n\n const button = (label: string, target: number, opts: { active?: boolean; disabled?: boolean; ellipsis?: boolean; ariaLabel?: string } = {}) => {\n if (opts.ellipsis) {\n return el(\"span\", { class: \"rui-pagination-ellipsis\", \"aria-hidden\": \"true\" }, [label]);\n }\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-pagination-button\",\n \"data-active\": opts.active ? \"true\" : \"false\",\n \"aria-current\": opts.active ? \"page\" : null,\n \"aria-label\": opts.ariaLabel ?? null,\n disabled: opts.disabled ? \"\" : null,\n }, [label]);\n if (!opts.disabled && !opts.active) {\n btn.onclick = () => setPage(target);\n }\n return btn;\n };\n\n buttonsWrap.append(button(\"‹\", current - 1, { disabled: current <= 1, ariaLabel: \"Previous page\" }));\n\n if (!compact) {\n const pageNumbers = computePageNumbers(current, total, siblings);\n for (const entry of pageNumbers) {\n if (entry === \"…\") {\n buttonsWrap.append(button(\"…\", 0, { ellipsis: true }));\n } else {\n buttonsWrap.append(button(String(entry), entry, { active: entry === current }));\n }\n }\n } else {\n // Compact variant still shows the current page label so callers\n // know where they are when the numbered row is hidden.\n buttonsWrap.append(el(\"span\", { class: \"rui-pagination-current\" }, [`${current} / ${total}`]));\n }\n\n buttonsWrap.append(button(\"›\", current + 1, { disabled: current >= total, ariaLabel: \"Next page\" }));\n root.append(buttonsWrap);\n\n // Per-page selector — only renders when `perPage` is a $variable so the\n // bound state can absorb the change. Falls back to a passive label when\n // perPage is a plain number.\n const perPageState = node.argMeta?.[4]?.stateRef;\n if (perPageValue && (perPageState || asArray(props.perPageOptions).length > 0)) {\n const options = asArray<unknown>(props.perPageOptions).length > 0\n ? asArray<unknown>(props.perPageOptions).map((v) => Math.max(1, Math.floor(Number(v) || 0))).filter((n) => n > 0)\n : Array.from(PER_PAGE_OPTIONS);\n const perPageWrap = el(\"label\", { class: \"rui-pagination-per-page\" }, [\n document.createTextNode(\"Show \"),\n ]);\n const select = el(\"select\", { class: \"rui-pagination-per-page-select\" }) as HTMLSelectElement;\n for (const opt of options) {\n const optEl = el(\"option\", {\n value: String(opt),\n selected: opt === perPageValue ? \"\" : null,\n }, [String(opt)]);\n select.append(optEl);\n }\n if (perPageState) {\n helpers.bindState(select, perPageState, {\n event: \"change\",\n getValue: (n) => Number((n as HTMLSelectElement).value),\n });\n }\n perPageWrap.append(select);\n perPageWrap.append(document.createTextNode(\" per page\"));\n root.append(perPageWrap);\n }\n\n return root;\n },\n};\n\nfunction computePageNumbers(current: number, total: number, siblings: number): Array<number | \"…\"> {\n const pages: Array<number | \"…\"> = [];\n const range = (from: number, to: number) => {\n for (let i = from; i <= to; i += 1) pages.push(i);\n };\n const totalNumbers = siblings * 2 + 5; // first, last, current, 2 ellipses, siblings on both sides\n if (total <= totalNumbers) {\n range(1, total);\n return pages;\n }\n const leftSibling = Math.max(2, current - siblings);\n const rightSibling = Math.min(total - 1, current + siblings);\n pages.push(1);\n if (leftSibling > 2) pages.push(\"…\");\n range(leftSibling, rightSibling);\n if (rightSibling < total - 1) pages.push(\"…\");\n pages.push(total);\n return pages;\n}\n\nexport const NavbarItem: ComponentSpec = {\n name: \"NavbarItem\",\n description:\n \"Single link inside a Navbar's main item slot. Renders as an inline \" +\n \"anchor / button — pass `to` for a router-aware link, `href` for an \" +\n \"external link, or `onClick` for a click handler. `active=true` \" +\n \"highlights the current page.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"to\", type: \"string\", optional: true, description: \"Internal route (consumes the built-in router)\" },\n { name: \"href\", type: \"string\", optional: true, description: \"External href; opens in a new tab when set with `external=true`\" },\n { name: \"icon\", type: \"string\", optional: true },\n { name: \"active\", type: \"boolean\", optional: true },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Callable fired on click (alternative to `to`/`href`)\" },\n { name: \"external\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const label = asString(props.label);\n const icon = props.icon;\n const active = asBoolean(props.active);\n const to = asString(props.to);\n // Sanitise the external href so a hostile `javascript:` cannot fire on\n // click. The internal `to` value is always rendered through the hash\n // router (`#/...`) which is inherently safe.\n const safeHref = sanitiseHref(props.href, \"\");\n const external = asBoolean(props.external);\n const tagName: \"a\" | \"button\" = (to || safeHref) ? \"a\" : \"button\";\n const root = el(tagName, {\n class: \"rui-navbar-item\",\n type: tagName === \"button\" ? \"button\" : null,\n href: safeHref || (to ? `#${to.startsWith(\"/\") ? to : `/${to}`}` : null),\n target: external && safeHref ? \"_blank\" : null,\n rel: external && safeHref ? \"noopener noreferrer\" : null,\n \"data-active\": active ? \"true\" : \"false\",\n });\n const iconNode = renderIcon(icon, { className: \"rui-navbar-item-icon\" });\n if (iconNode) root.append(iconNode);\n root.append(el(\"span\", { class: \"rui-navbar-item-label\" }, [label]));\n if (to && !safeHref) {\n root.onclick = (event) => {\n if (event.defaultPrevented) return;\n const evt = event as MouseEvent;\n if (evt.button !== 0 || evt.metaKey || evt.ctrlKey || evt.shiftKey || evt.altKey) return;\n event.preventDefault();\n helpers.router.navigate(to);\n };\n } else if (typeof props.onClick === \"function\") {\n root.onclick = (event) => {\n event.preventDefault();\n helpers.invoke(props.onClick);\n };\n }\n return root;\n },\n};\n\nexport const Navbar: ComponentSpec = {\n name: \"Navbar\",\n description:\n \"Top navigation bar with a brand on the left, primary nav items in \" +\n \"the middle, and a right-aligned actions slot (user avatar, \" +\n \"DropdownMenu, CTA buttons, …). Use `sticky=true` to pin it to the \" +\n \"top of the page. The canonical companion of `Sidebar` for product \" +\n \"surfaces; prefer Navbar for marketing/docs pages without a sidebar.\",\n props: [\n { name: \"brand\", type: \"string | Node\", optional: true, description: \"Workspace/product name (string) or a node (e.g. logo Image)\" },\n { name: \"items\", type: \"NavbarItem[]\", optional: true, description: \"Center navigation items\" },\n { name: \"actions\", type: \"Node[]\", optional: true, description: \"Right-side controls (Buttons, Avatar, DropdownMenu, …)\" },\n { name: \"sticky\", type: \"boolean\", optional: true, description: \"Pin the bar to the top of the viewport\" },\n { name: \"variant\", type: \"string\", optional: true, enum: [\"default\", \"transparent\"], description: \"Visual variant\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"nav\", {\n class: \"rui-navbar\",\n \"data-sticky\": asBoolean(props.sticky) ? \"true\" : \"false\",\n \"data-variant\": asString(props.variant, \"default\"),\n \"aria-label\": \"Primary\",\n });\n const brand = props.brand;\n if (brand !== undefined && brand !== null && brand !== \"\") {\n const brandWrap = el(\"div\", { class: \"rui-navbar-brand\" });\n if (typeof brand === \"string\") {\n brandWrap.append(document.createTextNode(brand));\n } else {\n brandWrap.append(helpers.renderNode(brand));\n }\n root.append(brandWrap);\n }\n const items = asArray<unknown>(props.items);\n if (items.length > 0) {\n const list = el(\"div\", { class: \"rui-navbar-items\" });\n for (const item of items) list.append(helpers.renderNode(item));\n root.append(list);\n }\n const actions = asArray<unknown>(props.actions);\n if (actions.length > 0) {\n const right = el(\"div\", { class: \"rui-navbar-actions\" });\n for (const item of actions) right.append(helpers.renderNode(item));\n root.append(right);\n }\n return root;\n },\n};\n","/**\n * Dropdown menu primitives modeled after shadcn/ui.\n *\n * DropdownMenu(trigger, items, side?, align?, label?)\n * MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)\n * MenuSeparator()\n * MenuLabel(label)\n *\n * `DropdownMenu` keeps its open/closed state persistent across re-renders via\n * `helpers.useInstanceState`, so unrelated state changes (typing into an\n * input, ticking a checkbox, …) do not collapse the menu mid-interaction.\n * Clicking the trigger toggles it; clicking a `MenuItem` runs its action and\n * closes; clicking anywhere outside the menu also closes (handled by an\n * outside-click listener attached lazily to the host shadow root on open).\n *\n * The trigger is rendered inside a `<span>` wrapper (not a nested `<button>`)\n * so that user-provided triggers like `Button(\"Open\")` or `Avatar(...)`\n * remain valid HTML and receive clicks reliably.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asBoolean, renderIcon } from \"../utils.js\";\nimport { installDismissListeners, disposeDismissListeners } from \"./_internal.js\";\n\nconst MENU_SIDES = [\"bottom\", \"top\", \"left\", \"right\"] as const;\nconst MENU_ALIGNS = [\"start\", \"center\", \"end\"] as const;\nconst MENU_VARIANTS = [\"default\", \"danger\"] as const;\n\n/**\n * Walk up the live DOM and toggle the dropdown's open state, keeping the\n * persisted instance-state slot in sync. Modifies the DOM directly so the\n * interaction feels instant without waiting for a render tick.\n */\nconst setDropdownOpen = (\n origin: Element,\n next: boolean,\n openSlot: { set: (value: boolean) => void },\n): HTMLElement | null => {\n openSlot.set(next);\n const liveRoot = origin.closest(\".rui-dropdown-menu\") as HTMLElement | null;\n if (!liveRoot) return null;\n liveRoot.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n const trigger = liveRoot.querySelector(\".rui-dropdown-menu-trigger\");\n trigger?.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n // Any path that closes the menu also releases the dismissal listeners so\n // we don't accumulate stale listener pairs on the host shadow root.\n if (!next) disposeDismissListeners(liveRoot);\n return liveRoot;\n};\n\nconst installOutsideClickClose = (\n liveRoot: HTMLElement,\n openSlot: { set: (value: boolean) => void },\n): void => {\n installDismissListeners({\n liveRoot,\n onDismiss: () => {\n openSlot.set(false);\n liveRoot.setAttribute(\"data-open\", \"false\");\n liveRoot.querySelector(\".rui-dropdown-menu-trigger\")\n ?.setAttribute(\"aria-expanded\", \"false\");\n },\n });\n};\n\ninterface MenuItemNode {\n __kind?: string;\n name?: string;\n args?: unknown[];\n argMeta?: unknown[];\n}\n\nconst isMenuChild = (item: unknown, name: string): item is MenuItemNode => {\n if (!item || typeof item !== \"object\") return false;\n const node = item as MenuItemNode;\n return node.__kind === \"Component\" && node.name === name;\n};\n\nexport const DropdownMenu: ComponentSpec = {\n name: \"DropdownMenu\",\n description:\n \"Click-triggered dropdown menu. Click the trigger to toggle, click a \" +\n \"MenuItem to run its action and close, click outside or press Escape \" +\n \"to close without acting. Children must be MenuItem, MenuSeparator, \" +\n \"or MenuLabel entries.\",\n props: [\n { name: \"trigger\", type: \"Node\", description: \"Clickable trigger element (typically a Button or Avatar)\" },\n { name: \"items\", type: \"(MenuItem | MenuSeparator | MenuLabel)[]\" },\n { name: \"side\", type: \"string\", optional: true, enum: MENU_SIDES, description: \"Where the menu opens relative to the trigger (default \\\"bottom\\\")\" },\n { name: \"align\", type: \"string\", optional: true, enum: MENU_ALIGNS, description: \"How the menu aligns along the trigger edge (default \\\"start\\\")\" },\n { name: \"label\", type: \"string\", optional: true, description: \"Optional ARIA label for the menu\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Initial open state — use to demo or pre-open the menu\" },\n ],\n render: (_node, props, helpers) => {\n const initialOpen = asBoolean(props.open);\n const openSlot = helpers.useInstanceState<boolean>(\"open\", initialOpen);\n const isOpen = openSlot.get();\n\n const root = el(\"div\", {\n class: \"rui-dropdown-menu\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n \"data-side\": asString(props.side, \"bottom\"),\n \"data-align\": asString(props.align, \"start\"),\n });\n\n // Render the user's trigger directly (Button, Avatar, IconButton, …)\n // and wrap it in a span so we don't nest <button> inside <button>\n // (which is invalid HTML and silently swallows clicks in some browsers).\n const triggerWrap = el(\"span\", {\n class: \"rui-dropdown-menu-trigger\",\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": isOpen ? \"true\" : \"false\",\n tabindex: \"0\",\n });\n triggerWrap.append(helpers.renderNode(props.trigger));\n // Property-based handlers so the morph reconciler can copy the latest\n // closure (with up-to-date `openSlot`) onto kept DOM. `addEventListener`\n // would leak fresh listeners onto every detached re-render snapshot.\n triggerWrap.onclick = (event) => {\n event.stopPropagation();\n const origin = (event.currentTarget ?? event.target) as Element;\n const next = !openSlot.get();\n const liveRoot = setDropdownOpen(origin, next, openSlot);\n if (next && liveRoot) installOutsideClickClose(liveRoot, openSlot);\n };\n triggerWrap.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n const origin = (e.currentTarget ?? e.target) as Element;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const next = !openSlot.get();\n const liveRoot = setDropdownOpen(origin, next, openSlot);\n if (next && liveRoot) installOutsideClickClose(liveRoot, openSlot);\n return;\n }\n if (e.key === \"Escape\" && openSlot.get()) {\n e.preventDefault();\n setDropdownOpen(origin, false, openSlot);\n }\n };\n root.append(triggerWrap);\n\n const content = el(\"div\", {\n class: \"rui-dropdown-menu-content\",\n role: \"menu\",\n \"aria-label\": asString(props.label) || null,\n });\n\n for (const raw of asArray<unknown>(props.items)) {\n if (isMenuChild(raw, \"MenuItem\")) {\n const args = raw.args ?? [];\n const label = asString(args[0]);\n const action = args[1];\n const icon = args[2];\n const shortcut = asString(args[3]);\n const variant = asString(args[4], \"default\");\n const disabled = asBoolean(args[5]);\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-menu-item\",\n role: \"menuitem\",\n \"data-variant\": variant,\n disabled: disabled ? \"\" : null,\n });\n const iconNode = renderIcon(icon, { className: \"rui-menu-item-icon\" });\n if (iconNode) btn.append(iconNode);\n btn.append(el(\"span\", { class: \"rui-menu-item-label\" }, [label]));\n if (shortcut) btn.append(el(\"span\", { class: \"rui-menu-item-shortcut\" }, [shortcut]));\n if (!disabled) {\n btn.onclick = (event) => {\n const origin = (event.currentTarget ?? event.target) as Element;\n setDropdownOpen(origin, false, openSlot);\n helpers.invoke(action);\n };\n }\n content.append(btn);\n continue;\n }\n if (isMenuChild(raw, \"MenuSeparator\")) {\n content.append(el(\"div\", { class: \"rui-menu-separator\", role: \"separator\" }));\n continue;\n }\n if (isMenuChild(raw, \"MenuLabel\")) {\n const label = asString((raw.args ?? [])[0]);\n content.append(el(\"div\", { class: \"rui-menu-label\" }, [label]));\n continue;\n }\n // Fallback: render arbitrary child nodes (Link, Switch, …) so the LLM\n // can nest controls inside a menu when it needs to.\n content.append(helpers.renderNode(raw));\n }\n root.append(content);\n return root;\n },\n};\n\nexport const MenuItem: ComponentSpec = {\n name: \"MenuItem\",\n description:\n \"Single item inside a DropdownMenu. Renders a button-style row with an \" +\n \"optional leading icon and trailing keyboard-shortcut hint. `onClick` \" +\n \"(legacy: `action`) runs when clicked; the menu closes automatically \" +\n \"afterwards.\",\n props: [\n { name: \"label\", type: \"string\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"], description: \"Callable to execute on click\" },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon name shown before the label\" },\n { name: \"shortcut\", type: \"string\", optional: true, description: \"Trailing keyboard-shortcut hint (e.g. \\\"⌘ K\\\")\" },\n { name: \"variant\", type: \"string\", optional: true, enum: MENU_VARIANTS, description: \"Use \\\"danger\\\" for destructive actions\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n ],\n // Standalone render (when used outside a DropdownMenu): an inert button so\n // the structure still appears, but without the parent's open/close wiring.\n render: (_node, props, helpers) => {\n const disabled = asBoolean(props.disabled);\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-menu-item\",\n role: \"menuitem\",\n \"data-variant\": asString(props.variant, \"default\"),\n disabled: disabled ? \"\" : null,\n });\n const iconNode = renderIcon(props.icon, { className: \"rui-menu-item-icon\" });\n if (iconNode) btn.append(iconNode);\n btn.append(el(\"span\", { class: \"rui-menu-item-label\" }, [asString(props.label)]));\n const shortcut = asString(props.shortcut);\n if (shortcut) btn.append(el(\"span\", { class: \"rui-menu-item-shortcut\" }, [shortcut]));\n if (!disabled) {\n btn.onclick = () => {\n helpers.invoke(props.onClick);\n };\n }\n return btn;\n },\n};\n\nexport const MenuSeparator: ComponentSpec = {\n name: \"MenuSeparator\",\n description: \"Thin horizontal rule used inside a DropdownMenu to group items.\",\n props: [],\n render: () => el(\"div\", { class: \"rui-menu-separator\", role: \"separator\" }),\n};\n\nexport const MenuLabel: ComponentSpec = {\n name: \"MenuLabel\",\n description:\n \"Small uppercase section header inside a DropdownMenu. Use to group \" +\n \"related MenuItems (e.g. \\\"Account\\\", \\\"Workspace\\\", \\\"Danger zone\\\").\",\n props: [{ name: \"label\", type: \"string\" }],\n render: (_node, props) =>\n el(\"div\", { class: \"rui-menu-label\" }, [asString(props.label)]),\n};\n","/**\n * Advanced data components:\n *\n * - DataGrid — Table with built-in sort, filter, row selection, pagination.\n * - CalendarView — Month/week calendar grid distinct from DatePicker.\n * - ActivityLog — Timeline-like specialised feeds.\n * - ComparisonTable — Generic feature/spec comparison table.\n * - InfiniteList — Scroll-to-load list container.\n *\n * These are presentational + lightly stateful (using `useInstanceState` for\n * local UI state). State that should round-trip through the host is bound\n * via `$variables` exactly like every other component in the library.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asBoolean, asNumber, renderIcon, fillTableCell } from \"../utils.js\";\n\nconst COL_ALIGN = [\"left\", \"center\", \"right\"] as const;\n\ninterface ColDef {\n header: string;\n values: unknown[];\n format: string;\n align: string;\n sortable: boolean;\n filterable: boolean;\n /** `(value, index) => Component|string|array` per-cell renderer. */\n render: unknown;\n /** `(value, index) => void` per-cell click handler. */\n onClick: unknown;\n key: string;\n}\n\nfunction readDataGridCols(raw: unknown): ColDef[] {\n return asArray<{ args?: unknown[] }>(raw).map((node, idx) => {\n const args = node.args ?? [];\n const header = asString(args[0]);\n return {\n header,\n values: asArray<unknown>(args[1]),\n format: asString(args[2], \"text\"),\n align: (COL_ALIGN as readonly string[]).includes(asString(args[3])) ? asString(args[3]) : \"\",\n sortable: asBoolean(args[4]),\n filterable: asBoolean(args[5]),\n render: args[6],\n onClick: args[7],\n key: header || `col-${idx}`,\n };\n });\n}\n\nfunction compareCells(a: unknown, b: unknown, format: string): number {\n if (a === null || a === undefined) return b === null || b === undefined ? 0 : 1;\n if (b === null || b === undefined) return -1;\n if (format === \"number\" || format === \"currency\") {\n return asNumber(a, 0) - asNumber(b, 0);\n }\n if (format === \"date\") {\n const ta = new Date(asString(a)).getTime();\n const tb = new Date(asString(b)).getTime();\n if (Number.isFinite(ta) && Number.isFinite(tb)) return ta - tb;\n }\n return asString(a).localeCompare(asString(b));\n}\n\nfunction formatCellValue(value: unknown, format: string): string {\n if (value === null || value === undefined) return \"\";\n switch (format) {\n case \"number\":\n return typeof value === \"number\" ? value.toLocaleString() : asString(value);\n case \"currency\":\n return typeof value === \"number\"\n ? value.toLocaleString(undefined, { style: \"currency\", currency: \"USD\" })\n : asString(value);\n case \"date\":\n try {\n const d = new Date(asString(value));\n return Number.isNaN(d.getTime()) ? asString(value) : d.toLocaleDateString();\n } catch { return asString(value); }\n default:\n return asString(value);\n }\n}\n\nexport const DataGrid: ComponentSpec = {\n name: \"DataGrid\",\n description:\n \"Advanced data table with sortable headers, per-column filter chips, \" +\n \"row selection (checkboxes), sticky header / first column, optional \" +\n \"pagination, an optional bulk-action toolbar slot, and click-to-act \" +\n \"rows. Columns are Col(header, values, format?, align?, sortable?, \" +\n \"filterable?) entries. Bind `$sort` (`{key, direction}` object), \" +\n \"`$selectedIds` (string[]), and `$page` (number) for full reactivity. \" +\n \"Use INSTEAD of `Table` when you need any of those interactions.\",\n props: [\n { name: \"columns\", type: \"Col[]\", description: \"Columns; pass sortable=true / filterable=true on each Col.\" },\n { name: \"rowIds\", type: \"any[]\", optional: true, description: \"Stable id per row (used by `selectedIds`); defaults to row index.\" },\n { name: \"caption\", type: \"string\", optional: true },\n { name: \"sort\", type: \"object\", optional: true, description: \"`{key, direction}` — pass a $variable for two-way binding\" },\n { name: \"selectedIds\", type: \"any[]\", optional: true, description: \"Array of selected row ids — bind a $variable\" },\n { name: \"selectable\", type: \"boolean\", optional: true, description: \"Render leading selection checkboxes\" },\n { name: \"page\", type: \"number\", optional: true, description: \"1-indexed current page — bind a $variable\" },\n { name: \"perPage\", type: \"number\", optional: true, description: \"Page size (default 20)\" },\n { name: \"emptyLabel\", type: \"string\", optional: true, description: \"Text shown when no rows match (default `No results`)\" },\n { name: \"onRowClick\", type: \"callable\", optional: true, aliases: [\"rowAction\"], description: \"Callable fired when a row is clicked. Receives the row index.\" },\n { name: \"toolbar\", type: \"Node[]\", optional: true, description: \"Bulk-action toolbar shown above the table when any rows are selected\" },\n { name: \"density\", type: \"string\", optional: true, enum: [\"comfortable\", \"compact\"] },\n { name: \"striped\", type: \"boolean\", optional: true },\n { name: \"stickyHeader\", type: \"boolean\", optional: true, description: \"Pin the header row (default true)\" },\n { name: \"stickyFirstColumn\", type: \"boolean\", optional: true, description: \"Pin the first column horizontally\" },\n ],\n render: (node, props, helpers) => {\n const cols = readDataGridCols(props.columns);\n const rowCount = Math.max(0, ...cols.map((c) => c.values.length));\n const rowIds = asArray<unknown>(props.rowIds);\n const idFor = (rowIdx: number): string => asString(rowIds[rowIdx] ?? rowIdx);\n const sortState = (props.sort && typeof props.sort === \"object\")\n ? (props.sort as { key?: unknown; direction?: unknown })\n : null;\n const sortKey = asString(sortState?.key);\n const sortDir = asString(sortState?.direction, \"asc\") === \"desc\" ? \"desc\" : \"asc\";\n const selectedIds = asArray<unknown>(props.selectedIds).map((v) => asString(v));\n const selectedSet = new Set(selectedIds);\n const selectable = asBoolean(props.selectable) || node.argMeta?.[4]?.stateRef !== undefined;\n const stickyHeader = props.stickyHeader === undefined ? true : asBoolean(props.stickyHeader);\n const stickyFirst = asBoolean(props.stickyFirstColumn);\n const density = asString(props.density, \"comfortable\");\n const striped = asBoolean(props.striped);\n\n // Filter chip state (per-column) — stored locally because filtering\n // happens client-side and we don't want each chip to allocate its own\n // $variable.\n const filterSlot = helpers.useInstanceState<Record<string, string>>(\"filters\", {});\n const filters = filterSlot.get();\n\n // Compute a row-index ordering after applying filters + sort.\n const indices: number[] = [];\n for (let r = 0; r < rowCount; r += 1) {\n let keep = true;\n for (const c of cols) {\n if (!c.filterable) continue;\n const term = (filters[c.key] ?? \"\").trim().toLowerCase();\n if (!term) continue;\n const cell = c.values[r];\n if (!formatCellValue(cell, c.format).toLowerCase().includes(term)) {\n keep = false;\n break;\n }\n }\n if (keep) indices.push(r);\n }\n if (sortKey) {\n const sortCol = cols.find((c) => c.key === sortKey);\n if (sortCol && sortCol.sortable) {\n indices.sort((a, b) => {\n const cmp = compareCells(sortCol.values[a], sortCol.values[b], sortCol.format);\n return sortDir === \"desc\" ? -cmp : cmp;\n });\n }\n }\n\n const totalAfterFilter = indices.length;\n const perPage = Math.max(1, Math.floor(asNumber(props.perPage, 20)));\n const totalPages = Math.max(1, Math.ceil(totalAfterFilter / perPage));\n const rawPage = Math.max(1, Math.floor(asNumber(props.page, 1)));\n const page = Math.min(rawPage, totalPages);\n const visible = indices.slice((page - 1) * perPage, page * perPage);\n\n const wrapper = el(\"div\", {\n class: \"rui-data-grid\",\n \"data-density\": density,\n \"data-striped\": striped ? \"true\" : \"false\",\n \"data-sticky-header\": stickyHeader ? \"true\" : \"false\",\n \"data-sticky-first\": stickyFirst ? \"true\" : \"false\",\n });\n\n const sortStateName = node.argMeta?.[3]?.stateRef;\n const selectedStateName = node.argMeta?.[4]?.stateRef;\n const pageStateName = node.argMeta?.[6]?.stateRef;\n\n // Bulk-edit toolbar (shows when at least one row is selected).\n const toolbarChildren = asArray<unknown>(props.toolbar);\n if (selectedIds.length > 0 && toolbarChildren.length > 0) {\n const bar = el(\"div\", { class: \"rui-data-grid-bulk\" });\n bar.append(el(\"span\", { class: \"rui-data-grid-bulk-count\" }, [\n `${selectedIds.length} selected`,\n ]));\n const tools = el(\"div\", { class: \"rui-data-grid-bulk-tools\" });\n for (const child of toolbarChildren) tools.append(helpers.renderNode(child));\n bar.append(tools);\n wrapper.append(bar);\n }\n\n const tableWrap = el(\"div\", { class: \"rui-data-grid-scroll\" });\n const table = el(\"table\", { class: \"rui-data-grid-table\" });\n const caption = asString(props.caption);\n if (caption) table.append(el(\"caption\", { class: \"rui-data-grid-caption\" }, [caption]));\n\n const thead = el(\"thead\");\n const headRow = el(\"tr\");\n if (selectable) {\n const th = el(\"th\", { class: \"rui-data-grid-cell-select\", scope: \"col\" });\n const allSelected = visible.length > 0 && visible.every((r) => selectedSet.has(idFor(r)));\n const cb = el(\"input\", {\n type: \"checkbox\",\n class: \"rui-data-grid-checkbox\",\n \"aria-label\": \"Select all rows on this page\",\n checked: allSelected ? \"\" : null,\n }) as HTMLInputElement;\n if (selectedStateName) {\n cb.onclick = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n const next = new Set(selectedIds);\n for (const r of visible) {\n const id = idFor(r);\n if (target.checked) next.add(id); else next.delete(id);\n }\n helpers.setState(selectedStateName, Array.from(next));\n };\n }\n th.append(cb);\n headRow.append(th);\n }\n cols.forEach((col, c) => {\n const th = el(\"th\", {\n scope: \"col\",\n \"data-align\": col.align || null,\n \"data-sortable\": col.sortable ? \"true\" : null,\n \"data-active\": col.sortable && col.key === sortKey ? \"true\" : null,\n \"data-first\": c === 0 ? \"true\" : null,\n });\n if (col.sortable && sortStateName) {\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-data-grid-sort\",\n });\n btn.append(el(\"span\", {}, [col.header]));\n const dirIcon = col.key === sortKey\n ? (sortDir === \"asc\" ? \"arrow-up-short-wide\" : \"arrow-down-wide-short\")\n : \"sort\";\n const dirNode = renderIcon(dirIcon, { className: \"rui-data-grid-sort-icon\" });\n if (dirNode) btn.append(dirNode);\n btn.onclick = () => {\n const nextDir = col.key === sortKey && sortDir === \"asc\" ? \"desc\" : \"asc\";\n helpers.setState(sortStateName, { key: col.key, direction: nextDir });\n };\n th.append(btn);\n } else {\n th.append(document.createTextNode(col.header));\n }\n headRow.append(th);\n });\n thead.append(headRow);\n\n // Filter row (only if any column is filterable)\n if (cols.some((c) => c.filterable)) {\n const filterRow = el(\"tr\", { class: \"rui-data-grid-filter-row\" });\n if (selectable) filterRow.append(el(\"td\", { class: \"rui-data-grid-cell-select\" }));\n cols.forEach((col) => {\n const td = el(\"td\");\n if (col.filterable) {\n const input = el(\"input\", {\n type: \"search\",\n class: \"rui-data-grid-filter\",\n placeholder: `Filter ${col.header}`,\n value: filters[col.key] ?? \"\",\n }) as HTMLInputElement;\n input.oninput = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n const next = { ...filterSlot.get(), [col.key]: target.value };\n filterSlot.set(next);\n // Resolve the *live* tbody from the input target — the\n // closure-captured `wrapper`/`tbody` references are detached\n // once morph keeps the previously mounted grid in place.\n const liveTbody = target.closest(\"table\")?.querySelector(\"tbody\") as HTMLElement | null;\n requestRebody(liveTbody);\n };\n td.append(input);\n }\n filterRow.append(td);\n });\n thead.append(filterRow);\n }\n table.append(thead);\n\n const tbody = el(\"tbody\");\n table.append(tbody);\n\n const renderBody = (rows: number[]): void => {\n tbody.replaceChildren();\n if (rows.length === 0) {\n const emptyRow = el(\"tr\");\n const span = (selectable ? 1 : 0) + Math.max(cols.length, 1);\n emptyRow.append(el(\"td\", {\n colspan: String(span),\n class: \"rui-data-grid-empty\",\n }, [asString(props.emptyLabel, \"No results\")]));\n tbody.append(emptyRow);\n return;\n }\n for (const r of rows) {\n const id = idFor(r);\n const isSelected = selectedSet.has(id);\n const tr = el(\"tr\", {\n \"data-selected\": isSelected ? \"true\" : null,\n });\n if (selectable) {\n const cellTd = el(\"td\", { class: \"rui-data-grid-cell-select\" });\n const cb = el(\"input\", {\n type: \"checkbox\",\n class: \"rui-data-grid-checkbox\",\n \"aria-label\": \"Select row\",\n checked: isSelected ? \"\" : null,\n }) as HTMLInputElement;\n if (selectedStateName) {\n cb.onclick = (event) => {\n event.stopPropagation();\n const target = event.currentTarget as HTMLInputElement;\n const next = new Set(selectedIds);\n if (target.checked) next.add(id); else next.delete(id);\n helpers.setState(selectedStateName, Array.from(next));\n };\n }\n cellTd.append(cb);\n tr.append(cellTd);\n }\n cols.forEach((col, c) => {\n const td = el(\"td\", {\n \"data-format\": col.format,\n \"data-align\": col.align || null,\n \"data-first\": c === 0 ? \"true\" : null,\n });\n fillTableCell(td, col, col.values[r], r, helpers, formatCellValue);\n tr.append(td);\n });\n if (typeof props.onRowClick === \"function\") {\n tr.setAttribute(\"data-clickable\", \"true\");\n tr.onclick = (event) => {\n const target = event.target as Element | null;\n if (target?.closest(\"input,button,a,label,select,textarea\")) return;\n helpers.invoke(props.onRowClick, r);\n };\n }\n tbody.append(tr);\n }\n };\n\n const requestRebody = (liveOverride?: HTMLElement | null): void => {\n const liveTbody = liveOverride ?? tbody;\n const localFilters = filterSlot.get();\n const filtered: number[] = [];\n for (let r = 0; r < rowCount; r += 1) {\n let keep = true;\n for (const c of cols) {\n if (!c.filterable) continue;\n const term = (localFilters[c.key] ?? \"\").trim().toLowerCase();\n if (!term) continue;\n const cell = c.values[r];\n if (!formatCellValue(cell, c.format).toLowerCase().includes(term)) {\n keep = false; break;\n }\n }\n if (keep) filtered.push(r);\n }\n if (sortKey) {\n const sortCol = cols.find((c) => c.key === sortKey);\n if (sortCol && sortCol.sortable) {\n filtered.sort((a, b) => {\n const cmp = compareCells(sortCol.values[a], sortCol.values[b], sortCol.format);\n return sortDir === \"desc\" ? -cmp : cmp;\n });\n }\n }\n const pageRows = filtered.slice((page - 1) * perPage, page * perPage);\n // Re-render against the (possibly live) tbody so user input keeps focus.\n const swap = (target: HTMLElement) => {\n target.replaceChildren();\n for (const row of pageRows) {\n // Lightweight re-render — same logic as the initial render path.\n const id = idFor(row);\n const isSelected = selectedSet.has(id);\n const tr = el(\"tr\", { \"data-selected\": isSelected ? \"true\" : null });\n if (selectable) {\n const cellTd = el(\"td\", { class: \"rui-data-grid-cell-select\" });\n const cb = el(\"input\", {\n type: \"checkbox\",\n class: \"rui-data-grid-checkbox\",\n checked: isSelected ? \"\" : null,\n }) as HTMLInputElement;\n cellTd.append(cb);\n tr.append(cellTd);\n }\n cols.forEach((col, c) => {\n const td = el(\"td\", {\n \"data-format\": col.format,\n \"data-align\": col.align || null,\n \"data-first\": c === 0 ? \"true\" : null,\n });\n fillTableCell(td, col, col.values[row], row, helpers, formatCellValue);\n tr.append(td);\n });\n target.append(tr);\n }\n if (pageRows.length === 0) {\n const emptyRow = el(\"tr\");\n const span = (selectable ? 1 : 0) + Math.max(cols.length, 1);\n emptyRow.append(el(\"td\", {\n colspan: String(span),\n class: \"rui-data-grid-empty\",\n }, [asString(props.emptyLabel, \"No results\")]));\n target.append(emptyRow);\n }\n };\n swap(liveTbody as HTMLElement);\n };\n\n renderBody(visible);\n\n tableWrap.append(table);\n wrapper.append(tableWrap);\n\n // Footer pagination summary\n if (totalAfterFilter > perPage) {\n const footer = el(\"div\", { class: \"rui-data-grid-footer\" });\n const startIdx = totalAfterFilter === 0 ? 0 : (page - 1) * perPage + 1;\n const endIdx = Math.min(totalAfterFilter, page * perPage);\n footer.append(el(\"span\", { class: \"rui-data-grid-footer-summary\" }, [\n totalAfterFilter === 0 ? \"No results\" : `Showing ${startIdx}–${endIdx} of ${totalAfterFilter}`,\n ]));\n const buttons = el(\"div\", { class: \"rui-data-grid-footer-buttons\" });\n const prev = el(\"button\", {\n type: \"button\",\n class: \"rui-data-grid-page-button\",\n disabled: page <= 1 ? \"\" : null,\n }, [\"‹ Prev\"]);\n const next = el(\"button\", {\n type: \"button\",\n class: \"rui-data-grid-page-button\",\n disabled: page >= totalPages ? \"\" : null,\n }, [\"Next ›\"]);\n if (pageStateName) {\n prev.onclick = () => {\n if (page <= 1) return;\n helpers.setState(pageStateName, page - 1);\n };\n next.onclick = () => {\n if (page >= totalPages) return;\n helpers.setState(pageStateName, page + 1);\n };\n }\n buttons.append(prev);\n buttons.append(el(\"span\", { class: \"rui-data-grid-page-current\" }, [`${page} / ${totalPages}`]));\n buttons.append(next);\n footer.append(buttons);\n wrapper.append(footer);\n }\n return wrapper;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * CalendarView — month/week calendar grid\n * ----------------------------------------------------------------------- */\n\ninterface CalendarEvent {\n date: string;\n title: string;\n tone?: string;\n time?: string;\n}\n\nfunction readCalendarEvents(raw: unknown): CalendarEvent[] {\n const out: CalendarEvent[] = [];\n for (const entry of asArray<unknown>(raw)) {\n if (!entry || typeof entry !== \"object\") continue;\n const e = entry as { date?: unknown; title?: unknown; tone?: unknown; time?: unknown };\n const date = asString(e.date);\n if (!date) continue;\n out.push({\n date,\n title: asString(e.title),\n tone: asString(e.tone, \"primary\"),\n time: asString(e.time),\n });\n }\n return out;\n}\n\nfunction startOfWeek(date: Date, weekStartsOn: number): Date {\n const out = new Date(date.getFullYear(), date.getMonth(), date.getDate());\n const day = out.getDay();\n const diff = (day - weekStartsOn + 7) % 7;\n out.setDate(out.getDate() - diff);\n return out;\n}\n\nfunction formatIsoDate(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nexport const CalendarView: ComponentSpec = {\n name: \"CalendarView\",\n description:\n \"Full-month or week calendar grid for scheduling apps — distinct from \" +\n \"the form-input `DatePicker`. Pass events as an array of \" +\n \"`{date: 'YYYY-MM-DD', title, tone?, time?}` objects. Bind `value` \" +\n \"to a `$variable` for the selected date (ISO string). Use \" +\n \"`view=\\\"week\\\"` for a single-week strip. `firstDay=1` (Monday) \" +\n \"matches most business apps.\",\n props: [\n { name: \"value\", type: \"string\", optional: true, description: \"Selected ISO date (YYYY-MM-DD); bind a $variable\" },\n { name: \"month\", type: \"string\", optional: true, description: \"Reference month — ISO date or YYYY-MM (defaults to today)\" },\n { name: \"events\", type: \"object[]\", optional: true, description: \"Array of {date, title, tone?, time?} objects\" },\n { name: \"view\", type: \"string\", optional: true, enum: [\"month\", \"week\"] },\n { name: \"firstDay\", type: \"number\", optional: true, description: \"0=Sunday, 1=Monday (default 1)\" },\n { name: \"onSelect\", type: \"callable\", optional: true, description: \"Callable fired when a day is clicked; receives the ISO date string\" },\n ],\n render: (node, props, helpers) => {\n const view = asString(props.view, \"month\");\n const events = readCalendarEvents(props.events);\n const valueRaw = asString(props.value);\n const monthRaw = asString(props.month, valueRaw);\n const today = new Date();\n let refDate = new Date(NaN);\n if (monthRaw) {\n const m = /^(\\d{4})-(\\d{2})(?:-(\\d{2}))?$/.exec(monthRaw);\n if (m) {\n refDate = new Date(Number(m[1]), Number(m[2]) - 1, m[3] ? Number(m[3]) : 1);\n } else {\n const d = new Date(monthRaw);\n if (!Number.isNaN(d.getTime())) refDate = d;\n }\n }\n if (Number.isNaN(refDate.getTime())) refDate = today;\n const weekStartsOn = ((asNumber(props.firstDay, 1) % 7) + 7) % 7;\n const valueIso = valueRaw && /^\\d{4}-\\d{2}-\\d{2}$/.test(valueRaw) ? valueRaw : \"\";\n const eventsByDate = new Map<string, CalendarEvent[]>();\n for (const evt of events) {\n const key = evt.date.slice(0, 10);\n const list = eventsByDate.get(key) ?? [];\n list.push(evt);\n eventsByDate.set(key, list);\n }\n const onSelectState = node.argMeta?.[0]?.stateRef;\n const root = el(\"div\", { class: \"rui-calendar\", \"data-view\": view });\n const header = el(\"div\", { class: \"rui-calendar-header\" });\n const monthLabel = refDate.toLocaleDateString(undefined, { month: \"long\", year: \"numeric\" });\n header.append(el(\"div\", { class: \"rui-calendar-title\" }, [monthLabel]));\n root.append(header);\n\n const weekRow = el(\"div\", { class: \"rui-calendar-weekrow\" });\n const dayLabels = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n for (let i = 0; i < 7; i += 1) {\n const label = dayLabels[(weekStartsOn + i) % 7] ?? \"\";\n weekRow.append(el(\"div\", { class: \"rui-calendar-weekday\" }, [label]));\n }\n root.append(weekRow);\n\n const cells: { date: Date; inMonth: boolean }[] = [];\n if (view === \"week\") {\n const anchor = valueIso ? new Date(valueIso) : refDate;\n const start = startOfWeek(anchor, weekStartsOn);\n for (let i = 0; i < 7; i += 1) {\n const d = new Date(start);\n d.setDate(start.getDate() + i);\n cells.push({ date: d, inMonth: d.getMonth() === refDate.getMonth() });\n }\n } else {\n const firstOfMonth = new Date(refDate.getFullYear(), refDate.getMonth(), 1);\n const lastOfMonth = new Date(refDate.getFullYear(), refDate.getMonth() + 1, 0);\n const gridStart = startOfWeek(firstOfMonth, weekStartsOn);\n const totalDays = Math.ceil((lastOfMonth.getDate() + ((firstOfMonth.getDay() - weekStartsOn + 7) % 7)) / 7) * 7;\n for (let i = 0; i < totalDays; i += 1) {\n const d = new Date(gridStart);\n d.setDate(gridStart.getDate() + i);\n cells.push({ date: d, inMonth: d.getMonth() === refDate.getMonth() });\n }\n }\n\n const grid = el(\"div\", { class: \"rui-calendar-grid\", \"data-view\": view });\n const todayIso = formatIsoDate(today);\n for (const cell of cells) {\n const iso = formatIsoDate(cell.date);\n const isToday = iso === todayIso;\n const isSelected = iso === valueIso;\n const cellEvents = eventsByDate.get(iso) ?? [];\n const dayBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-calendar-day\",\n \"data-in-month\": cell.inMonth ? \"true\" : \"false\",\n \"data-today\": isToday ? \"true\" : \"false\",\n \"data-selected\": isSelected ? \"true\" : \"false\",\n \"aria-label\": cell.date.toDateString(),\n });\n dayBtn.append(el(\"span\", { class: \"rui-calendar-daynumber\" }, [String(cell.date.getDate())]));\n if (cellEvents.length > 0) {\n const evts = el(\"div\", { class: \"rui-calendar-day-events\" });\n const visibleEvents = cellEvents.slice(0, 3);\n for (const evt of visibleEvents) {\n const chip = el(\"span\", {\n class: \"rui-calendar-event\",\n \"data-tone\": evt.tone ?? \"primary\",\n title: evt.time ? `${evt.time} — ${evt.title}` : evt.title,\n }, [evt.title]);\n evts.append(chip);\n }\n if (cellEvents.length > 3) {\n evts.append(el(\"span\", { class: \"rui-calendar-event-more\" }, [\n `+${cellEvents.length - 3} more`,\n ]));\n }\n dayBtn.append(evts);\n }\n dayBtn.onclick = () => {\n if (onSelectState) helpers.setState(onSelectState, iso);\n helpers.invoke(props.onSelect, iso);\n };\n grid.append(dayBtn);\n }\n root.append(grid);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * ActivityLog — activity / audit feeds\n * ----------------------------------------------------------------------- */\n\ninterface FeedEntry {\n title: string;\n description: string;\n actor: string;\n avatarSrc: string;\n time: string;\n icon: string;\n tone: string;\n meta: string;\n}\n\nfunction readFeedEntries(raw: unknown): FeedEntry[] {\n const out: FeedEntry[] = [];\n for (const entry of asArray<unknown>(raw)) {\n if (!entry || typeof entry !== \"object\") continue;\n const e = entry as Record<string, unknown>;\n out.push({\n title: asString(e.title),\n description: asString(e.description),\n actor: asString(e.actor),\n avatarSrc: asString(e.avatarSrc),\n time: asString(e.time),\n icon: asString(e.icon),\n tone: asString(e.tone, \"default\"),\n meta: asString(e.meta),\n });\n }\n return out;\n}\n\nfunction renderFeed(klass: string, items: FeedEntry[], variant: string): HTMLElement {\n const root = el(\"ol\", { class: klass, \"data-variant\": variant });\n for (const entry of items) {\n const li = el(\"li\", { class: `${klass}-item`, \"data-tone\": entry.tone });\n const marker = el(\"span\", { class: `${klass}-marker` });\n const iconNode = renderIcon(entry.icon, { className: `${klass}-icon` });\n if (iconNode) marker.append(iconNode);\n li.append(marker);\n const body = el(\"div\", { class: `${klass}-body` });\n const head = el(\"div\", { class: `${klass}-head` });\n if (entry.actor) head.append(el(\"span\", { class: `${klass}-actor` }, [entry.actor]));\n head.append(el(\"span\", { class: `${klass}-title` }, [entry.title]));\n if (entry.time) head.append(el(\"span\", { class: `${klass}-time` }, [entry.time]));\n body.append(head);\n if (entry.description) {\n body.append(el(\"p\", { class: `${klass}-description` }, [entry.description]));\n }\n if (entry.meta) {\n body.append(el(\"span\", { class: `${klass}-meta` }, [entry.meta]));\n }\n li.append(body);\n root.append(li);\n }\n return root;\n}\n\nexport const ActivityLog: ComponentSpec = {\n name: \"ActivityLog\",\n description:\n \"Purpose-built feed of user/system activity. Each entry has `actor`, \" +\n \"`title`, `description?`, `time?`, `icon?`, `tone?`, and optional `meta` \" +\n \"(IP, browser, request id). Use `variant=\\\"audit\\\"` for monospace \" +\n \"security/admin trails. Pass items as `{actor, title, description, time, \" +\n \"icon, tone, avatarSrc, meta}` objects.\",\n props: [\n { name: \"items\", type: \"object[]\" },\n { name: \"variant\", type: \"string\", optional: true, enum: [\"default\", \"audit\"], description: \"audit = monospace voice with meta column\" },\n ],\n render: (_node, props) => {\n const variant = asString(props.variant, \"default\");\n const klass = variant === \"audit\" ? \"rui-audit-trail\" : \"rui-activity-log\";\n return renderFeed(klass, readFeedEntries(props.items), variant);\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * ComparisonTable — generic counterpart of PricingTable\n * ----------------------------------------------------------------------- */\n\nexport const ComparisonTable: ComponentSpec = {\n name: \"ComparisonTable\",\n description:\n \"Feature/spec comparison table — generic counterpart of `PricingTable`. \" +\n \"Pass `columns` (e.g. plan/product names) and `rows` of \" +\n \"`{label, values}` where `values` aligns 1-to-1 with `columns`. \" +\n \"Each value can be a boolean (✓/—), a string, or a node.\",\n props: [\n { name: \"columns\", type: \"string[]\", description: \"Column headers\" },\n { name: \"rows\", type: \"object[]\", description: \"Array of {label, values, hint?, group?} entries\" },\n { name: \"highlightColumn\", type: \"number\", optional: true, description: \"0-indexed column to visually emphasise\" },\n ],\n render: (_node, props, helpers) => {\n const columns = asArray<unknown>(props.columns).map((c) => asString(c));\n const rows = asArray<unknown>(props.rows).map((entry) => {\n const r = (entry ?? {}) as { label?: unknown; values?: unknown; hint?: unknown; group?: unknown };\n return {\n label: asString(r.label),\n values: asArray<unknown>(r.values),\n hint: asString(r.hint),\n group: asString(r.group),\n };\n });\n const highlightIdx = Math.floor(asNumber(props.highlightColumn, -1));\n const root = el(\"div\", { class: \"rui-comparison-table\" });\n const table = el(\"table\");\n const thead = el(\"thead\");\n const headRow = el(\"tr\");\n headRow.append(el(\"th\", { scope: \"col\", class: \"rui-comparison-table-feature\" }, [\"Feature\"]));\n columns.forEach((col, c) => {\n headRow.append(el(\"th\", {\n scope: \"col\",\n \"data-highlight\": c === highlightIdx ? \"true\" : null,\n }, [col]));\n });\n thead.append(headRow);\n table.append(thead);\n\n const tbody = el(\"tbody\");\n let currentGroup = \"\";\n for (const row of rows) {\n if (row.group && row.group !== currentGroup) {\n currentGroup = row.group;\n const groupRow = el(\"tr\", { class: \"rui-comparison-table-group\" });\n groupRow.append(el(\"td\", { colspan: String(columns.length + 1) }, [row.group]));\n tbody.append(groupRow);\n }\n const tr = el(\"tr\");\n const labelCell = el(\"td\", { class: \"rui-comparison-table-feature\" });\n labelCell.append(el(\"div\", { class: \"rui-comparison-table-feature-label\" }, [row.label]));\n if (row.hint) labelCell.append(el(\"div\", { class: \"rui-comparison-table-feature-hint\" }, [row.hint]));\n tr.append(labelCell);\n for (let c = 0; c < columns.length; c += 1) {\n const value = row.values[c];\n const td = el(\"td\", { \"data-highlight\": c === highlightIdx ? \"true\" : null });\n if (value === true) {\n const icon = renderIcon(\"circle-check\", { className: \"rui-comparison-yes\" });\n if (icon) td.append(icon);\n else td.textContent = \"✓\";\n } else if (value === false || value === null || value === undefined) {\n td.append(el(\"span\", { class: \"rui-comparison-no\" }, [\"—\"]));\n } else if (value && typeof value === \"object\" && (value as { __kind?: string }).__kind === \"Component\") {\n td.append(helpers.renderNode(value));\n } else {\n td.textContent = asString(value);\n }\n tr.append(td);\n }\n tbody.append(tr);\n }\n table.append(tbody);\n root.append(table);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * InfiniteList — scroll-to-load list\n * ----------------------------------------------------------------------- */\n\nexport const InfiniteList: ComponentSpec = {\n name: \"InfiniteList\",\n description:\n \"Vertical list that fires `onLoadMore` when the user scrolls near the \" +\n \"bottom. Pass already-rendered child nodes as `items`; wire `onLoadMore` \" +\n \"to an `action` that awaits a `$mutation` or `$query` (e.g. \" +\n \"`await loadMore.invoke()`) and appends to the bound state. Use \" +\n \"`loading=true` to show the spinner row, `hasMore=false` to suppress further loads.\",\n props: [\n { name: \"items\", type: \"Node[]\", description: \"Already-rendered child nodes\" },\n { name: \"onLoadMore\", type: \"callable\", optional: true, description: \"Callable fired when the sentinel scrolls into view\" },\n { name: \"loading\", type: \"boolean\", optional: true },\n { name: \"hasMore\", type: \"boolean\", optional: true, description: \"Default true — set false to hide the sentinel\" },\n { name: \"loaderLabel\", type: \"string\", optional: true, description: \"Label rendered while loading (default `Loading…`)\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-infinite-list\" });\n const list = el(\"div\", { class: \"rui-infinite-list-body\" });\n for (const child of asArray(props.items)) list.append(helpers.renderNode(child));\n root.append(list);\n const hasMore = props.hasMore === undefined ? true : asBoolean(props.hasMore);\n const loading = asBoolean(props.loading);\n if (hasMore) {\n const sentinel = el(\"div\", { class: \"rui-infinite-list-sentinel\" });\n if (loading) {\n const spin = renderIcon(\"spinner\", { className: \"rui-infinite-list-spin\" });\n if (spin) sentinel.append(spin);\n sentinel.append(el(\"span\", {}, [asString(props.loaderLabel, \"Loading…\")]));\n } else if (typeof props.onLoadMore === \"function\") {\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-infinite-list-load-more\",\n }, [\"Load more\"]);\n btn.onclick = () => helpers.invoke(props.onLoadMore);\n sentinel.append(btn);\n }\n root.append(sentinel);\n // Lightweight IntersectionObserver fallback — fires the load callback\n // when the sentinel enters the viewport. Cleaned up automatically\n // when the list is unmounted.\n if (!loading && typeof props.onLoadMore === \"function\" && typeof IntersectionObserver !== \"undefined\") {\n const callback = props.onLoadMore;\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n helpers.invoke(callback);\n break;\n }\n }\n });\n observer.observe(sentinel);\n helpers.registerDisposer(() => observer.disconnect(), \"infinite-observer\");\n }\n }\n return root;\n },\n};\n","/**\n * Media components:\n *\n * - VideoPlayer / AudioPlayer — Native media wrappers with consistent styling.\n * - Carousel — Horizontal scrolling slider with prev/next + dot navigation.\n * - Gallery — Responsive image grid with optional click-to-open Lightbox.\n * - Lightbox — Full-viewport image viewer (controlled via $variable).\n * - Map — Static map (OpenStreetMap tiles) given lat/lng coordinates.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n sanitiseCssLength, sanitiseImageSrc,\n} from \"../utils.js\";\n\nconst SAFE_MEDIA_SCHEMES = /^(https?:|blob:|data:(audio|video)\\/)/i;\n\nfunction sanitiseMediaSrc(raw: unknown): string {\n const value = asString(raw).trim();\n if (!value) return \"\";\n if (value.startsWith(\"/\") || value.startsWith(\".\")) return value;\n if (value.startsWith(\"//\")) return \"\";\n return SAFE_MEDIA_SCHEMES.test(value) ? value : \"\";\n}\n\nexport const VideoPlayer: ComponentSpec = {\n name: \"VideoPlayer\",\n description:\n \"Themed native `<video>` wrapper. Pass a `src` URL (or `sources` array \" +\n \"for multi-codec fallback) and optional `poster`. Standard controls \" +\n \"are visible by default; pass `autoplay`, `loop`, `muted`, or \" +\n \"`controls=false` to override. Use for product demos, tutorials, \" +\n \"and any inline video.\",\n props: [\n { name: \"src\", type: \"string\", optional: true, description: \"Video URL (mp4 / webm / etc.)\" },\n { name: \"sources\", type: \"object[]\", optional: true, description: \"Array of {src, type} entries for multi-codec fallback\" },\n { name: \"poster\", type: \"string\", optional: true, description: \"Thumbnail image URL shown before playback\" },\n { name: \"caption\", type: \"string\", optional: true },\n { name: \"controls\", type: \"boolean\", optional: true, description: \"Show native controls (default true)\" },\n { name: \"autoplay\", type: \"boolean\", optional: true },\n { name: \"loop\", type: \"boolean\", optional: true },\n { name: \"muted\", type: \"boolean\", optional: true },\n { name: \"ratio\", type: \"string\", optional: true, description: \"Aspect ratio (default 16:9)\" },\n ],\n render: (_node, props) => {\n const root = el(\"figure\", { class: \"rui-video-player\" });\n const ratio = parseRatio(asString(props.ratio, \"16:9\"));\n const playerWrap = el(\"div\", {\n class: \"rui-video-player-frame\",\n style: `aspect-ratio:${ratio};`,\n });\n const showControls = props.controls === undefined ? true : asBoolean(props.controls);\n const video = el(\"video\", {\n class: \"rui-video-player-video\",\n controls: showControls ? \"\" : null,\n autoplay: asBoolean(props.autoplay) ? \"\" : null,\n loop: asBoolean(props.loop) ? \"\" : null,\n muted: asBoolean(props.muted) ? \"\" : null,\n poster: sanitiseImageSrc(props.poster) || null,\n playsinline: \"\",\n preload: \"metadata\",\n });\n const sources = asArray<unknown>(props.sources);\n if (sources.length > 0) {\n for (const raw of sources) {\n if (!raw || typeof raw !== \"object\") continue;\n const s = raw as { src?: unknown; type?: unknown };\n const safeSrc = sanitiseMediaSrc(s.src);\n if (!safeSrc) continue;\n video.append(el(\"source\", { src: safeSrc, type: asString(s.type) || null }));\n }\n } else {\n const safeSrc = sanitiseMediaSrc(props.src);\n if (safeSrc) video.setAttribute(\"src\", safeSrc);\n }\n playerWrap.append(video);\n root.append(playerWrap);\n const caption = asString(props.caption);\n if (caption) root.append(el(\"figcaption\", { class: \"rui-video-player-caption\" }, [caption]));\n return root;\n },\n};\n\nexport const AudioPlayer: ComponentSpec = {\n name: \"AudioPlayer\",\n description:\n \"Themed native `<audio>` wrapper with a title, optional artist, and \" +\n \"standard transport controls. Pass `src` (or `sources`) plus a \" +\n \"`title` so the bar still looks like a player when the controls bar \" +\n \"is hidden. Use for podcasts, voice notes, and demo audio.\",\n props: [\n { name: \"src\", type: \"string\", optional: true, description: \"Audio URL (mp3 / ogg / wav / etc.)\" },\n { name: \"sources\", type: \"object[]\", optional: true, description: \"Array of {src, type} entries for multi-codec fallback\" },\n { name: \"title\", type: \"string\", optional: true },\n { name: \"artist\", type: \"string\", optional: true },\n { name: \"controls\", type: \"boolean\", optional: true, description: \"Show native controls (default true)\" },\n { name: \"autoplay\", type: \"boolean\", optional: true },\n { name: \"loop\", type: \"boolean\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Leading icon (default `music`)\" },\n ],\n render: (_node, props) => {\n const root = el(\"div\", { class: \"rui-audio-player\" });\n const meta = el(\"div\", { class: \"rui-audio-player-meta\" });\n const iconNode = renderIcon(asString(props.icon, \"music\"), { className: \"rui-audio-player-icon\" });\n if (iconNode) meta.append(iconNode);\n const text = el(\"div\", { class: \"rui-audio-player-text\" });\n const title = asString(props.title);\n if (title) text.append(el(\"div\", { class: \"rui-audio-player-title\" }, [title]));\n const artist = asString(props.artist);\n if (artist) text.append(el(\"div\", { class: \"rui-audio-player-artist\" }, [artist]));\n meta.append(text);\n root.append(meta);\n const showControls = props.controls === undefined ? true : asBoolean(props.controls);\n const audio = el(\"audio\", {\n class: \"rui-audio-player-audio\",\n controls: showControls ? \"\" : null,\n autoplay: asBoolean(props.autoplay) ? \"\" : null,\n loop: asBoolean(props.loop) ? \"\" : null,\n preload: \"metadata\",\n });\n const sources = asArray<unknown>(props.sources);\n if (sources.length > 0) {\n for (const raw of sources) {\n if (!raw || typeof raw !== \"object\") continue;\n const s = raw as { src?: unknown; type?: unknown };\n const safeSrc = sanitiseMediaSrc(s.src);\n if (!safeSrc) continue;\n audio.append(el(\"source\", { src: safeSrc, type: asString(s.type) || null }));\n }\n } else {\n const safeSrc = sanitiseMediaSrc(props.src);\n if (safeSrc) audio.setAttribute(\"src\", safeSrc);\n }\n root.append(audio);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Carousel — horizontal slider with prev/next + dot navigation\n * ----------------------------------------------------------------------- */\n\ninterface SlideHelpers {\n renderNode: (node: unknown) => Node;\n}\n\nfunction renderCarouselSlide(item: unknown, helpers: SlideHelpers): Node | null {\n if (item === null || item === undefined) return null;\n if (typeof item === \"object\" && (item as { __kind?: string }).__kind === \"Component\") {\n return helpers.renderNode(item);\n }\n if (typeof item === \"string\") {\n const safeSrc = sanitiseImageSrc(item);\n if (!safeSrc) return null;\n return el(\"img\", { src: safeSrc, alt: \"\", loading: \"lazy\", class: \"rui-carousel-image\" });\n }\n if (typeof item === \"object\") {\n const obj = item as { src?: unknown; alt?: unknown; caption?: unknown; title?: unknown };\n const safeSrc = sanitiseImageSrc(obj.src);\n if (safeSrc) {\n const wrap = el(\"figure\", { class: \"rui-carousel-figure\" });\n wrap.append(el(\"img\", {\n src: safeSrc,\n alt: asString(obj.alt ?? obj.caption ?? obj.title),\n loading: \"lazy\",\n class: \"rui-carousel-image\",\n }));\n const captionText = asString(obj.caption ?? obj.title);\n if (captionText) {\n wrap.append(el(\"figcaption\", { class: \"rui-carousel-caption\" }, [captionText]));\n }\n return wrap;\n }\n }\n return helpers.renderNode(item);\n}\n\nexport const Carousel: ComponentSpec = {\n name: \"Carousel\",\n description:\n \"Horizontal slider with prev/next buttons and dot navigation. Each \" +\n \"child slide takes full width. Slides may be Component nodes \" +\n \"(Image, Card, MediaCard, …), URL strings, or plain \" +\n \"`{src, alt, caption?}` image objects — bare image objects are \" +\n \"auto-wrapped into a captioned figure. Use for image galleries, \" +\n \"onboarding carousels, hero banners, and product image strips. The \" +\n \"active slide is preserved across re-renders via instance state.\",\n props: [\n { name: \"items\", type: \"Node[]\", description: \"Slide nodes, image URLs, or {src, alt, caption?} objects\" },\n { name: \"activeIndex\", type: \"number\", optional: true, description: \"0-indexed initial slide (default 0)\" },\n { name: \"ratio\", type: \"string\", optional: true, description: \"Aspect ratio of the frame (default `16:9`)\" },\n { name: \"showDots\", type: \"boolean\", optional: true, description: \"Show indicator dots (default true)\" },\n { name: \"showArrows\", type: \"boolean\", optional: true, description: \"Show prev/next arrows (default true)\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const count = items.length;\n const defaultIdx = Math.max(0, Math.min(Math.max(count - 1, 0), Math.floor(asNumber(props.activeIndex, 0))));\n const slot = helpers.useInstanceState<number>(\"active\", defaultIdx);\n let active = slot.get();\n if (active >= count) { active = 0; slot.set(active); }\n const showDots = props.showDots === undefined ? true : asBoolean(props.showDots);\n const showArrows = props.showArrows === undefined ? true : asBoolean(props.showArrows);\n const ratio = parseRatio(asString(props.ratio, \"16:9\"));\n const root = el(\"div\", { class: \"rui-carousel\" });\n const frame = el(\"div\", {\n class: \"rui-carousel-frame\",\n style: `aspect-ratio:${ratio};`,\n });\n const track = el(\"div\", {\n class: \"rui-carousel-track\",\n style: `transform:translateX(${active * -100}%);`,\n });\n items.forEach((item) => {\n const slide = el(\"div\", { class: \"rui-carousel-slide\" });\n const rendered = renderCarouselSlide(item, helpers);\n if (rendered) slide.append(rendered);\n track.append(slide);\n });\n frame.append(track);\n\n const move = (origin: Element, next: number): void => {\n const clamped = ((next % count) + count) % count;\n slot.set(clamped);\n const liveRoot = origin.closest(\".rui-carousel\");\n const liveTrack = liveRoot?.querySelector(\".rui-carousel-track\") as HTMLElement | null;\n if (liveTrack) liveTrack.style.transform = `translateX(${clamped * -100}%)`;\n liveRoot?.querySelectorAll<HTMLElement>(\".rui-carousel-dot\").forEach((dot, i) => {\n dot.setAttribute(\"data-active\", i === clamped ? \"true\" : \"false\");\n });\n };\n\n if (showArrows && count > 1) {\n const prev = el(\"button\", {\n type: \"button\",\n class: \"rui-carousel-arrow\",\n \"data-direction\": \"prev\",\n \"aria-label\": \"Previous slide\",\n });\n const prevIcon = renderIcon(\"chevron-left\");\n if (prevIcon) prev.append(prevIcon);\n const next = el(\"button\", {\n type: \"button\",\n class: \"rui-carousel-arrow\",\n \"data-direction\": \"next\",\n \"aria-label\": \"Next slide\",\n });\n const nextIcon = renderIcon(\"chevron-right\");\n if (nextIcon) next.append(nextIcon);\n prev.onclick = (event) => move(event.currentTarget as Element, slot.get() - 1);\n next.onclick = (event) => move(event.currentTarget as Element, slot.get() + 1);\n frame.append(prev, next);\n }\n root.append(frame);\n\n if (showDots && count > 1) {\n const dots = el(\"div\", { class: \"rui-carousel-dots\" });\n items.forEach((_item, i) => {\n const dot = el(\"button\", {\n type: \"button\",\n class: \"rui-carousel-dot\",\n \"data-active\": i === active ? \"true\" : \"false\",\n \"aria-label\": `Go to slide ${i + 1}`,\n });\n dot.onclick = (event) => move(event.currentTarget as Element, i);\n dots.append(dot);\n });\n root.append(dots);\n }\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Gallery + Lightbox\n * ----------------------------------------------------------------------- */\n\nexport const Gallery: ComponentSpec = {\n name: \"Gallery\",\n description:\n \"Responsive image grid. Pass items as plain URL strings, \" +\n \"`{src, alt, caption?}` objects, or `Image(...)` nodes. When \" +\n \"`onSelect` is provided each tile becomes a button; bind it through \" +\n \"an Action that opens a `Lightbox`.\",\n props: [\n { name: \"items\", type: \"any[]\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"Preferred column count (default auto)\" },\n { name: \"ratio\", type: \"string\", optional: true, description: \"Per-tile aspect ratio (default `1:1`)\" },\n { name: \"onSelect\", type: \"callable\", optional: true, description: \"Callable fired when a tile is clicked\" },\n ],\n render: (_node, props, helpers) => {\n const items = asArray<unknown>(props.items);\n const columns = Math.max(1, Math.min(6, Number(props.columns ?? \"auto\")));\n const ratio = parseRatio(asString(props.ratio, \"1:1\"));\n const root = el(\"div\", {\n class: \"rui-gallery\",\n \"data-columns\": columns > 0 ? String(columns) : null,\n });\n items.forEach((raw, i) => {\n const { src, alt, caption } = extractGalleryItem(raw);\n const safeSrc = sanitiseImageSrc(src);\n const clickable = typeof props.onSelect === \"function\";\n const tile = el(clickable ? \"button\" : \"figure\" as \"figure\", {\n type: clickable ? \"button\" : null,\n class: \"rui-gallery-tile\",\n style: `aspect-ratio:${ratio};`,\n \"data-index\": String(i),\n });\n if (safeSrc) {\n tile.append(el(\"img\", { src: safeSrc, alt, loading: \"lazy\" }));\n } else {\n const placeholder = renderIcon(\"image\", { className: \"rui-gallery-placeholder\" });\n if (placeholder) tile.append(placeholder);\n }\n if (caption) {\n tile.append(el(\"span\", { class: \"rui-gallery-caption\" }, [caption]));\n }\n if (clickable) {\n tile.onclick = () => helpers.invoke(props.onSelect, i, raw);\n }\n root.append(tile);\n });\n return root;\n },\n};\n\nfunction extractGalleryItem(raw: unknown): { src: string; alt: string; caption: string } {\n if (typeof raw === \"string\") return { src: raw, alt: \"\", caption: \"\" };\n if (raw && typeof raw === \"object\") {\n const r = raw as Record<string, unknown>;\n if ((r as { __kind?: string }).__kind === \"Component\" && Array.isArray(r.args)) {\n return {\n src: asString(r.args[0]),\n alt: asString(r.args[1]),\n caption: asString(r.args[2]),\n };\n }\n return {\n src: asString(r.src),\n alt: asString(r.alt),\n caption: asString(r.caption),\n };\n }\n return { src: \"\", alt: \"\", caption: \"\" };\n}\n\nexport const Lightbox: ComponentSpec = {\n name: \"Lightbox\",\n description:\n \"Image overlay. When you bind a `$variable` to `open` you control it \" +\n \"explicitly; without one, Lightbox renders a clickable thumbnail of \" +\n \"the current image that opens the overlay on click (and uses internal \" +\n \"state for next/prev). Pass `items` (string URLs or \" +\n \"`{src, alt, caption?}` objects). Clicking the backdrop or × closes; \" +\n \"arrows step through the array.\",\n props: [\n { name: \"items\", type: \"any[]\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Open/closed; bind a $variable to control externally\" },\n { name: \"index\", type: \"number\", optional: true, description: \"0-indexed current image; typically a $variable\" },\n ],\n render: (node, props, helpers) => {\n const items = asArray<unknown>(props.items)\n .map((raw) => extractGalleryItem(raw))\n .filter((entry) => sanitiseImageSrc(entry.src) !== \"\");\n const total = items.length;\n const indexStateName = node.argMeta?.[2]?.stateRef;\n const openStateName = node.argMeta?.[1]?.stateRef;\n // Self-managed open/index when no $variable is bound — clicking the\n // thumbnail toggles the overlay, prev/next step through `items`.\n const internalOpen = helpers.useInstanceState<boolean>(\"open\", false);\n const internalIndex = helpers.useInstanceState<number>(\"index\", 0);\n const isOpen = openStateName\n ? asBoolean(props.open)\n : internalOpen.get();\n const rawIndex = indexStateName\n ? Math.floor(asNumber(props.index, 0))\n : internalIndex.get();\n const idx = total === 0 ? 0 : ((rawIndex % total) + total) % total;\n\n const setOpen = (next: boolean): void => {\n if (openStateName) helpers.setState(openStateName, next);\n else internalOpen.set(next);\n };\n const setIndex = (next: number): void => {\n if (indexStateName) helpers.setState(indexStateName, next);\n else internalIndex.set(next);\n };\n const close = () => setOpen(false);\n const move = (delta: number) => {\n if (total === 0) return;\n setIndex(((idx + delta) % total + total) % total);\n };\n\n const root = el(\"div\", { class: \"rui-lightbox-root\" });\n // Render a clickable thumbnail when the lightbox is self-managed and\n // no externally bound `open` state is in play. Authors who explicitly\n // bind `open: $var` keep the legacy headless behaviour.\n if (!openStateName && total > 0) {\n const current = items[idx];\n const thumb = el(\"button\", {\n type: \"button\",\n class: \"rui-lightbox-thumb\",\n \"aria-label\": current?.alt || \"Open image\",\n });\n if (current) {\n const safeThumb = sanitiseImageSrc(current.src);\n if (safeThumb) thumb.append(el(\"img\", { src: safeThumb, alt: current.alt, loading: \"lazy\" }));\n }\n thumb.onclick = (event) => {\n event.stopPropagation();\n setOpen(true);\n };\n root.append(thumb);\n }\n\n const overlay = el(\"div\", {\n class: \"rui-lightbox-overlay\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n });\n root.append(overlay);\n if (!isOpen || total === 0) return root;\n const current = items[idx];\n if (!current) return root;\n const safeSrc = sanitiseImageSrc(current.src);\n overlay.onclick = (event) => {\n if (event.target === overlay) close();\n };\n const dialog = el(\"div\", { class: \"rui-lightbox\", role: \"dialog\", \"aria-modal\": \"true\" });\n const closeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-lightbox-close\",\n \"aria-label\": \"Close lightbox\",\n }, [\"×\"]);\n closeBtn.onclick = close;\n dialog.append(closeBtn);\n if (total > 1) {\n const prev = el(\"button\", {\n type: \"button\",\n class: \"rui-lightbox-arrow\",\n \"data-direction\": \"prev\",\n \"aria-label\": \"Previous image\",\n });\n const prevIcon = renderIcon(\"chevron-left\");\n if (prevIcon) prev.append(prevIcon);\n prev.onclick = () => move(-1);\n const next = el(\"button\", {\n type: \"button\",\n class: \"rui-lightbox-arrow\",\n \"data-direction\": \"next\",\n \"aria-label\": \"Next image\",\n });\n const nextIcon = renderIcon(\"chevron-right\");\n if (nextIcon) next.append(nextIcon);\n next.onclick = () => move(1);\n dialog.append(prev, next);\n }\n const imageWrap = el(\"div\", { class: \"rui-lightbox-image-wrap\" });\n if (safeSrc) {\n imageWrap.append(el(\"img\", { src: safeSrc, alt: current.alt }));\n }\n dialog.append(imageWrap);\n if (current.caption) {\n dialog.append(el(\"div\", { class: \"rui-lightbox-caption\" }, [current.caption]));\n }\n if (total > 1) {\n dialog.append(el(\"div\", { class: \"rui-lightbox-counter\" }, [`${idx + 1} / ${total}`]));\n }\n overlay.append(dialog);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Map — static OpenStreetMap embed\n * ----------------------------------------------------------------------- */\n\nfunction parseLatLng(raw: unknown): { lat: number; lng: number } | null {\n if (!raw) return null;\n if (typeof raw === \"object\" && !Array.isArray(raw)) {\n const r = raw as { lat?: unknown; lng?: unknown; latitude?: unknown; longitude?: unknown };\n const lat = asNumber(r.lat ?? r.latitude, NaN);\n const lng = asNumber(r.lng ?? r.longitude, NaN);\n if (Number.isFinite(lat) && Number.isFinite(lng)) return { lat, lng };\n }\n if (Array.isArray(raw) && raw.length >= 2) {\n const lat = asNumber(raw[0], NaN);\n const lng = asNumber(raw[1], NaN);\n if (Number.isFinite(lat) && Number.isFinite(lng)) return { lat, lng };\n }\n if (typeof raw === \"string\") {\n const parts = raw.split(\",\").map((s) => Number(s.trim()));\n if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {\n return { lat: parts[0]!, lng: parts[1]! };\n }\n }\n return null;\n}\n\nexport const Map: ComponentSpec = {\n name: \"Map\",\n description:\n \"Static map view centered on a lat/lng coordinate. Renders an \" +\n \"OpenStreetMap embed inside an `<iframe>` (no external JS, no API \" +\n \"key). Pass `lat` and `lng` as bare numbers; `zoom` controls the \" +\n \"level (1–18, default 13). Optional `markers` array adds map pins \" +\n \"(rendered as a labelled list alongside the map). Use for store \" +\n \"locators, address cards, itinerary previews.\",\n props: [\n { name: \"lat\", type: \"number\", description: \"Latitude of the map center\" },\n { name: \"lng\", type: \"number\", description: \"Longitude of the map center\" },\n { name: \"zoom\", type: \"number\", optional: true, description: \"1–18 (default 13)\" },\n { name: \"markers\", type: \"object[]\", optional: true, description: \"Array of {lat, lng, label?} markers (informational; rendered alongside the map)\" },\n { name: \"height\", type: \"string\", optional: true, description: \"CSS height (default 320px)\" },\n { name: \"caption\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const root = el(\"figure\", { class: \"rui-map\" });\n const height = sanitiseCssLength(props.height, \"320px\");\n const frameWrap = el(\"div\", { class: \"rui-map-frame\", style: `height:${height};` });\n const lat = asNumber(props.lat, NaN);\n const lng = asNumber(props.lng, NaN);\n const center = Number.isFinite(lat) && Number.isFinite(lng) ? { lat, lng } : null;\n if (!center) {\n frameWrap.append(el(\"div\", { class: \"rui-map-empty\" }, [\n \"Pass lat & lng (numbers) to render the map.\",\n ]));\n root.append(frameWrap);\n const caption = asString(props.caption);\n if (caption) root.append(el(\"figcaption\", { class: \"rui-map-caption\" }, [caption]));\n return root;\n }\n const zoom = Math.max(1, Math.min(18, Math.floor(asNumber(props.zoom, 13))));\n // Approximate bounding box from a span that scales with zoom — small\n // enough that the requested center stays prominent in the embed.\n const span = 1 / Math.pow(2, zoom - 8);\n const bbox = [\n center.lng - span,\n center.lat - span / 2,\n center.lng + span,\n center.lat + span / 2,\n ].join(\",\");\n const url = `https://www.openstreetmap.org/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${center.lat},${center.lng}`;\n const iframe = el(\"iframe\", {\n class: \"rui-map-iframe\",\n src: url,\n loading: \"lazy\",\n title: \"Map view\",\n referrerpolicy: \"no-referrer\",\n });\n frameWrap.append(iframe);\n root.append(frameWrap);\n const markers = asArray<unknown>(props.markers)\n .map((raw) => {\n const pin = parseLatLng(raw);\n const label = raw && typeof raw === \"object\" ? asString((raw as { label?: unknown }).label) : \"\";\n return pin ? { ...pin, label } : null;\n })\n .filter((p): p is { lat: number; lng: number; label: string } => p !== null);\n if (markers.length > 0) {\n const list = el(\"ul\", { class: \"rui-map-markers\" });\n for (const m of markers) {\n const li = el(\"li\", { class: \"rui-map-marker\" });\n const pinIcon = renderIcon(\"location-dot\", { className: \"rui-map-marker-icon\" });\n if (pinIcon) li.append(pinIcon);\n li.append(el(\"span\", { class: \"rui-map-marker-label\" }, [\n m.label || `${m.lat.toFixed(4)}, ${m.lng.toFixed(4)}`,\n ]));\n list.append(li);\n }\n root.append(list);\n }\n const caption = asString(props.caption);\n if (caption) root.append(el(\"figcaption\", { class: \"rui-map-caption\" }, [caption]));\n return root;\n },\n};\n\nfunction parseRatio(input: string): string {\n if (input.includes(\":\")) {\n const [w, h] = input.split(\":\");\n const num = Number(w);\n const den = Number(h);\n if (Number.isFinite(num) && Number.isFinite(den) && den > 0) return `${num} / ${den}`;\n }\n const n = Number(input);\n return Number.isFinite(n) && n > 0 ? `${n} / 1` : \"16 / 9\";\n}\n","/**\n * Editor components:\n *\n * - RichTextEditor — `contenteditable`-based WYSIWYG editor for CMS / email.\n * - CodeEditor — Lightweight, dependency-free code editor (textarea + gutter).\n * - ContextMenu — Right-click menu attachable to any wrapped node.\n * - ColorPicker — Hex / RGB form control with preset swatches.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asBoolean, asNumber, renderIcon } from \"../utils.js\";\nimport { attachOnChange } from \"./wrappers.js\";\n\n/* ----------------------------------------------------------------------- *\n * RichTextEditor\n * ----------------------------------------------------------------------- */\n\ninterface RteCommand {\n command: string;\n icon: string;\n label: string;\n block?: string;\n}\n\nconst DEFAULT_RTE_TOOLS: RteCommand[] = [\n { command: \"bold\", icon: \"bold\", label: \"Bold\" },\n { command: \"italic\", icon: \"italic\", label: \"Italic\" },\n { command: \"underline\", icon: \"underline\", label: \"Underline\" },\n { command: \"strikeThrough\", icon: \"strikethrough\", label: \"Strikethrough\" },\n { command: \"formatBlock\", icon: \"heading\", label: \"Heading\", block: \"h2\" },\n { command: \"formatBlock\", icon: \"quote-left\", label: \"Quote\", block: \"blockquote\" },\n { command: \"insertUnorderedList\", icon: \"list-ul\", label: \"Bullet list\" },\n { command: \"insertOrderedList\", icon: \"list-ol\", label: \"Numbered list\" },\n { command: \"createLink\", icon: \"link\", label: \"Link\" },\n];\n\nexport const RichTextEditor: ComponentSpec = {\n name: \"RichTextEditor\",\n description:\n \"Rich-text WYSIWYG editor for CMS, email, and comment surfaces. \" +\n \"Renders a small toolbar (bold / italic / underline / strikethrough / \" +\n \"headings / lists / quote / link) above a `contenteditable` region. \" +\n \"Pass `$variable` as `value` for two-way binding — the HTML body is \" +\n \"written back to state on every edit. Provide `placeholder` for the \" +\n \"empty-state prompt.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound HTML body (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true, description: \"Empty-state prompt\" },\n { name: \"minHeight\", type: \"string\", optional: true, description: \"CSS min-height for the editor area (default 160px)\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current HTML on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const placeholder = asString(props.placeholder, \"Start writing…\");\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", {\n class: \"rui-rich-text\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n const toolbar = el(\"div\", { class: \"rui-rich-text-toolbar\", role: \"toolbar\" });\n for (const tool of DEFAULT_RTE_TOOLS) {\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-rich-text-tool\",\n \"data-command\": tool.command,\n \"data-block\": tool.block ?? null,\n \"aria-label\": tool.label,\n title: tool.label,\n disabled: disabled ? \"\" : null,\n });\n const iconNode = renderIcon(tool.icon);\n if (iconNode) btn.append(iconNode);\n btn.onmousedown = (event) => event.preventDefault();\n btn.onclick = (event) => {\n const live = (event.currentTarget as Element).closest(\".rui-rich-text\");\n const editor = live?.querySelector<HTMLElement>(\".rui-rich-text-content\");\n if (!editor) return;\n editor.focus();\n try {\n if (tool.command === \"createLink\") {\n const url = window.prompt(\"URL\");\n if (url) document.execCommand(\"createLink\", false, url);\n } else if (tool.command === \"formatBlock\" && tool.block) {\n document.execCommand(\"formatBlock\", false, tool.block);\n } else {\n document.execCommand(tool.command, false);\n }\n } catch {\n // execCommand can throw in some sandboxed contexts; swallow.\n }\n // Dispatch an input event so the state binding picks up the change.\n editor.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n toolbar.append(btn);\n }\n root.append(toolbar);\n\n const initial = asString(props.value) || \"\";\n const isEmpty = (html: string): boolean => {\n const text = html.replace(/<br\\s*\\/?>(?=\\s*$)/gi, \"\").replace(/<[^>]+>/g, \"\").replace(/&nbsp;/g, \" \").trim();\n return text.length === 0;\n };\n const editor = el(\"div\", {\n class: \"rui-rich-text-content\",\n id,\n contenteditable: disabled ? \"false\" : \"true\",\n role: \"textbox\",\n \"aria-multiline\": \"true\",\n \"aria-placeholder\": placeholder,\n \"data-placeholder\": placeholder,\n \"data-empty\": isEmpty(initial) ? \"true\" : \"false\",\n style: `min-height:${asString(props.minHeight, \"160px\")};`,\n html: initial,\n });\n const refreshEmpty = (target: HTMLElement): void => {\n target.setAttribute(\"data-empty\", isEmpty(target.innerHTML) ? \"true\" : \"false\");\n };\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName && !disabled) {\n helpers.bindState(editor, stateName, {\n event: \"input\",\n // Sync the placeholder state on every keystroke, alongside the\n // state write — keeps both behaviours in the single property-based\n // `oninput` slot so the morph reconciler transfers them as a unit.\n getValue: (n) => {\n const target = n as HTMLElement;\n refreshEmpty(target);\n return target.innerHTML;\n },\n });\n } else {\n editor.oninput = (event) => {\n const target = (event.currentTarget ?? event.target) as HTMLElement;\n refreshEmpty(target);\n };\n }\n editor.onblur = (event) => {\n const target = (event.currentTarget ?? event.target) as HTMLElement;\n refreshEmpty(target);\n };\n attachOnChange(editor, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLElement).innerHTML,\n });\n root.append(editor);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * CodeEditor — lightweight textarea-based editor with gutter\n * ----------------------------------------------------------------------- */\n\nconst CODE_LANGUAGES = [\"text\", \"javascript\", \"typescript\", \"json\", \"html\", \"css\", \"bash\", \"python\", \"sql\", \"markdown\"] as const;\n\nexport const CodeEditor: ComponentSpec = {\n name: \"CodeEditor\",\n description:\n \"Lightweight, dependency-free code editor. Pairs a styled textarea \" +\n \"with a synchronised line-number gutter — no syntax highlighting, but \" +\n \"the editor stays a single rendered node so it works inside Shadow \" +\n \"DOM. Use for dev tooling, snippet editing, prompt playgrounds. Pass \" +\n \"a `$variable` as `value` for two-way binding. For read-only \" +\n \"rendering with highlights prefer `CodeBlock`.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound source text (typically $variable)\" },\n { name: \"language\", type: \"string\", optional: true, enum: CODE_LANGUAGES, description: \"Language label shown on the header (default `text`)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"minHeight\", type: \"string\", optional: true, description: \"CSS min-height for the editor area (default 200px)\" },\n { name: \"tabSize\", type: \"number\", optional: true, description: \"Spaces per Tab (default 2)\" },\n { name: \"showGutter\", type: \"boolean\", optional: true, description: \"Show line-number gutter (default true)\" },\n { name: \"readonly\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current source on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const value = asString(props.value);\n const language = asString(props.language, \"text\");\n const showGutter = props.showGutter === undefined ? true : asBoolean(props.showGutter);\n const tabSize = Math.max(1, Math.min(8, Math.floor(asNumber(props.tabSize, 2))));\n const readonly = asBoolean(props.readonly);\n const minHeight = asString(props.minHeight, \"200px\");\n const root = el(\"div\", {\n class: \"rui-code-editor\",\n \"data-language\": language,\n \"data-gutter\": showGutter ? \"true\" : \"false\",\n });\n const head = el(\"div\", { class: \"rui-code-editor-head\" });\n head.append(el(\"span\", { class: \"rui-code-editor-language\" }, [language]));\n root.append(head);\n const body = el(\"div\", {\n class: \"rui-code-editor-body\",\n style: `min-height:${minHeight};`,\n });\n const gutter = el(\"div\", { class: \"rui-code-editor-gutter\", \"aria-hidden\": \"true\" });\n const renderGutter = (text: string) => {\n gutter.replaceChildren();\n const lines = text.split(/\\r?\\n/);\n const total = Math.max(1, lines.length);\n for (let i = 1; i <= total; i += 1) {\n gutter.append(el(\"span\", { class: \"rui-code-editor-line\" }, [String(i)]));\n }\n };\n if (showGutter) {\n renderGutter(value);\n body.append(gutter);\n }\n const textarea = el(\"textarea\", {\n class: \"rui-code-editor-textarea\",\n id,\n name: id,\n spellcheck: \"false\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n placeholder: asString(props.placeholder),\n readonly: readonly ? \"\" : null,\n style: `tab-size:${tabSize};-moz-tab-size:${tabSize};`,\n }) as HTMLTextAreaElement;\n textarea.value = value;\n textarea.oninput = (event) => {\n const target = event.currentTarget as HTMLTextAreaElement;\n if (!showGutter) return;\n const liveRoot = target.closest(\".rui-code-editor\");\n const liveGutter = liveRoot?.querySelector<HTMLElement>(\".rui-code-editor-gutter\");\n if (!liveGutter) return;\n liveGutter.replaceChildren();\n const lines = target.value.split(/\\r?\\n/);\n const total = Math.max(1, lines.length);\n for (let i = 1; i <= total; i += 1) {\n liveGutter.append(el(\"span\", { class: \"rui-code-editor-line\" }, [String(i)]));\n }\n };\n // Honour Tab as indentation rather than focus-change.\n textarea.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n if (e.key !== \"Tab\") return;\n e.preventDefault();\n const target = e.currentTarget as HTMLTextAreaElement;\n const start = target.selectionStart;\n const end = target.selectionEnd;\n const indent = \" \".repeat(tabSize);\n target.value = target.value.slice(0, start) + indent + target.value.slice(end);\n target.selectionStart = target.selectionEnd = start + indent.length;\n target.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName && !readonly) {\n helpers.bindState(textarea, stateName, {\n event: \"input\",\n getValue: (n) => (n as HTMLTextAreaElement).value,\n });\n }\n if (!readonly) {\n attachOnChange(textarea, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLTextAreaElement).value,\n });\n }\n body.append(textarea);\n root.append(body);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * ContextMenu — right-click menu attachable to a child node\n * ----------------------------------------------------------------------- */\n\ninterface ContextMenuItem {\n label: string;\n action: unknown;\n icon: string;\n shortcut: string;\n variant: string;\n disabled: boolean;\n separator: boolean;\n}\n\nfunction extractContextItem(raw: unknown): ContextMenuItem | null {\n if (!raw) return null;\n if (typeof raw === \"object\") {\n const node = raw as { __kind?: string; name?: string; args?: unknown[] };\n if (node.__kind === \"Component\" && node.name === \"MenuItem\" && Array.isArray(node.args)) {\n const args = node.args;\n return {\n label: asString(args[0]),\n action: args[1],\n icon: asString(args[2]),\n shortcut: asString(args[3]),\n variant: asString(args[4], \"default\"),\n disabled: asBoolean(args[5]),\n separator: false,\n };\n }\n if (node.__kind === \"Component\" && node.name === \"MenuSeparator\") {\n return { label: \"\", action: null, icon: \"\", shortcut: \"\", variant: \"default\", disabled: false, separator: true };\n }\n const r = raw as Record<string, unknown>;\n if (r.separator) {\n return { label: \"\", action: null, icon: \"\", shortcut: \"\", variant: \"default\", disabled: false, separator: true };\n }\n return {\n label: asString(r.label),\n action: r.action,\n icon: asString(r.icon),\n shortcut: asString(r.shortcut),\n variant: asString(r.variant, \"default\"),\n disabled: asBoolean(r.disabled),\n separator: false,\n };\n }\n return null;\n}\n\nexport const ContextMenu: ComponentSpec = {\n name: \"ContextMenu\",\n description:\n \"Right-click (or long-press) menu that attaches to a child node. \" +\n \"Wraps `target` and shows the menu at the pointer when the user \" +\n \"right-clicks anywhere inside it. Items are `MenuItem(...)` nodes, \" +\n \"`MenuSeparator()` entries, or `{label, action, icon?, shortcut?, \" +\n \"variant?, disabled?, separator?}` objects. Use on table rows, tree \" +\n \"nodes, kanban cards, file browser entries.\",\n props: [\n { name: \"target\", type: \"Node\", description: \"Child node the menu is bound to\" },\n { name: \"items\", type: \"any[]\", description: \"MenuItem nodes or {label, action} objects\" },\n { name: \"label\", type: \"string\", optional: true, description: \"ARIA label for the menu\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"div\", { class: \"rui-context-menu\" });\n const wrap = el(\"div\", { class: \"rui-context-menu-target\" });\n wrap.append(helpers.renderNode(props.target));\n root.append(wrap);\n const menu = el(\"div\", {\n class: \"rui-context-menu-pop\",\n role: \"menu\",\n \"aria-label\": asString(props.label) || null,\n \"data-open\": \"false\",\n });\n const items = asArray<unknown>(props.items)\n .map(extractContextItem)\n .filter((i): i is ContextMenuItem => i !== null);\n for (const item of items) {\n if (item.separator) {\n menu.append(el(\"div\", { class: \"rui-menu-separator\", role: \"separator\" }));\n continue;\n }\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-menu-item\",\n role: \"menuitem\",\n \"data-variant\": item.variant,\n disabled: item.disabled ? \"\" : null,\n });\n const iconNode = renderIcon(item.icon, { className: \"rui-menu-item-icon\" });\n if (iconNode) btn.append(iconNode);\n btn.append(el(\"span\", { class: \"rui-menu-item-label\" }, [item.label]));\n if (item.shortcut) btn.append(el(\"span\", { class: \"rui-menu-item-shortcut\" }, [item.shortcut]));\n if (!item.disabled) {\n btn.onclick = () => {\n helpers.invoke(item.action);\n menu.setAttribute(\"data-open\", \"false\");\n };\n }\n menu.append(btn);\n }\n root.append(menu);\n\n const closeAll = () => menu.setAttribute(\"data-open\", \"false\");\n const open = (clientX: number, clientY: number) => {\n const liveRoot = wrap.isConnected ? wrap.closest(\".rui-context-menu\") as HTMLElement | null : null;\n const liveMenu = liveRoot?.querySelector<HTMLElement>(\".rui-context-menu-pop\") ?? menu;\n const rect = liveRoot?.getBoundingClientRect();\n const x = rect ? clientX - rect.left : clientX;\n const y = rect ? clientY - rect.top : clientY;\n liveMenu.style.left = `${x}px`;\n liveMenu.style.top = `${y}px`;\n liveMenu.setAttribute(\"data-open\", \"true\");\n const dismiss = (event: Event) => {\n if (event.target && liveMenu.contains(event.target as Node)) return;\n liveMenu.setAttribute(\"data-open\", \"false\");\n document.removeEventListener(\"click\", dismiss, true);\n document.removeEventListener(\"contextmenu\", dismiss, true);\n };\n setTimeout(() => {\n document.addEventListener(\"click\", dismiss, true);\n document.addEventListener(\"contextmenu\", dismiss, true);\n }, 0);\n };\n\n wrap.oncontextmenu = (event) => {\n event.preventDefault();\n open(event.clientX, event.clientY);\n };\n wrap.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n if (e.key === \"ContextMenu\" || (e.shiftKey && e.key === \"F10\")) {\n e.preventDefault();\n const target = e.currentTarget as HTMLElement;\n const rect = target.getBoundingClientRect();\n open(rect.left, rect.top + rect.height);\n }\n if (e.key === \"Escape\") closeAll();\n };\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * ColorPicker\n * ----------------------------------------------------------------------- */\n\nconst DEFAULT_SWATCHES = [\n \"#0f172a\", \"#334155\", \"#64748b\", \"#94a3b8\",\n \"#ef4444\", \"#f59e0b\", \"#facc15\", \"#10b981\",\n \"#06b6d4\", \"#3b82f6\", \"#6366f1\", \"#8b5cf6\",\n];\n\nfunction normaliseHex(value: string): string {\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n let hex = trimmed.startsWith(\"#\") ? trimmed.slice(1) : trimmed;\n if (hex.length === 3) hex = hex.split(\"\").map((c) => c + c).join(\"\");\n if (!/^[0-9a-fA-F]{6,8}$/.test(hex)) return \"\";\n return `#${hex.toLowerCase().slice(0, 6)}`;\n}\n\nexport const ColorPicker: ComponentSpec = {\n name: \"ColorPicker\",\n description:\n \"Hex / RGB color form control with preset swatches. Pairs a native \" +\n \"`<input type=\\\"color\\\">` chip with a hex text input and a row of \" +\n \"preset swatches. Pass a `$variable` as `value` (hex string, e.g. \" +\n \"`\\\"#6366f1\\\"`) for two-way binding. Use for theme builders, label \" +\n \"color pickers, and any \\\"pick a color\\\" surface.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound hex value (typically $variable)\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"swatches\", type: \"string[]\", optional: true, description: \"Preset hex colors (default to a 12-color palette)\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the newly-selected hex string\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const value = normaliseHex(asString(props.value)) || asString(props.value, \"#000000\");\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", { class: \"rui-color-picker\", \"data-disabled\": disabled ? \"true\" : \"false\" });\n const label = asString(props.label);\n if (label) root.append(el(\"label\", { class: \"rui-color-picker-label\", for: id }, [label]));\n const row = el(\"div\", { class: \"rui-color-picker-row\" });\n const colorInput = el(\"input\", {\n type: \"color\",\n class: \"rui-color-picker-color\",\n id,\n name: id,\n value: normaliseHex(value) || \"#000000\",\n disabled: disabled ? \"\" : null,\n }) as HTMLInputElement;\n const textInput = el(\"input\", {\n type: \"text\",\n class: \"rui-color-picker-hex\",\n value,\n placeholder: \"#000000\",\n disabled: disabled ? \"\" : null,\n autocomplete: \"off\",\n }) as HTMLInputElement;\n const swatchRow = el(\"div\", { class: \"rui-color-picker-swatches\" });\n const swatches = asArray<unknown>(props.swatches).map((c) => asString(c)).filter(Boolean);\n const palette = swatches.length > 0 ? swatches : DEFAULT_SWATCHES;\n for (const swatch of palette) {\n const safeHex = normaliseHex(swatch) || swatch;\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-color-picker-swatch\",\n style: `background:${safeHex}`,\n \"aria-label\": safeHex,\n title: safeHex,\n \"data-active\": safeHex.toLowerCase() === value.toLowerCase() ? \"true\" : \"false\",\n });\n btn.onclick = () => {\n colorInput.value = normaliseHex(safeHex) || colorInput.value;\n textInput.value = safeHex;\n colorInput.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n swatchRow.append(btn);\n }\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName && !disabled) {\n helpers.bindState(colorInput, stateName, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n // Keep the hex text input in sync with the color picker.\n colorInput.addEventListener(\"input\", () => {\n textInput.value = colorInput.value;\n });\n textInput.oninput = () => {\n const next = normaliseHex(textInput.value);\n if (!next) return;\n colorInput.value = next;\n colorInput.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n }\n if (!disabled) {\n attachOnChange(colorInput, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n }\n row.append(colorInput, textInput);\n root.append(row, swatchRow);\n return root;\n },\n};\n","/**\n * Advanced chart components built on the same SVG primitives as `charts.ts`:\n *\n * - Gauge — half-doughnut indicator for KPIs and thresholds.\n * - Heatmap — color-intensity grid (calendar / matrix style).\n * - RadarChart — multi-axis polygon for skills, comparisons, scorecards.\n * - ScatterChart — XY scatter for correlations and distributions.\n * - Histogram — frequency distribution from raw numbers.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asNumber } from \"../utils.js\";\n\nconst PALETTE: readonly string[] = [\n \"var(--rui-chart-1, #6366f1)\",\n \"var(--rui-chart-2, #10b981)\",\n \"var(--rui-chart-3, #f59e0b)\",\n \"var(--rui-chart-4, #ef4444)\",\n \"var(--rui-chart-5, #06b6d4)\",\n \"var(--rui-chart-6, #8b5cf6)\",\n];\n\nconst colorAt = (index: number): string => PALETTE[index % PALETTE.length] ?? PALETTE[0]!;\n\ninterface SeriesData {\n name: string;\n values: number[];\n}\n\nfunction readSeries(raw: unknown[]): SeriesData[] {\n return raw.map((s, i) => {\n const node = s as { args?: unknown[] };\n const name = asString(node.args?.[0], `Series ${i + 1}`);\n const values = asArray<unknown>(node.args?.[1]).map((v) => asNumber(v));\n return { name, values };\n });\n}\n\nfunction createSvg(width: number, height: number): SVGSVGElement {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n svg.setAttribute(\"class\", \"rui-chart-svg\");\n svg.setAttribute(\"role\", \"img\");\n return svg;\n}\n\nfunction svgEl(\n tag: string,\n attrs: Record<string, string>,\n children?: ReadonlyArray<Node | string>,\n): SVGElement {\n const node = document.createElementNS(\"http://www.w3.org/2000/svg\", tag);\n for (const [key, value] of Object.entries(attrs)) node.setAttribute(key, value);\n if (children) {\n for (const child of children) {\n node.append(typeof child === \"string\" ? document.createTextNode(child) : child);\n }\n }\n return node;\n}\n\nfunction legend(series: SeriesData[]): HTMLElement {\n const root = el(\"div\", { class: \"rui-chart-legend\" });\n series.forEach((s, i) => {\n const item = el(\"span\", { class: \"rui-chart-legend-item\" });\n item.append(el(\"span\", { class: \"rui-chart-legend-swatch\", style: `background:${colorAt(i)}` }));\n item.append(el(\"span\", {}, [s.name]));\n root.append(item);\n });\n return root;\n}\n\n/* ----------------------------------------------------------------------- *\n * Gauge\n * ----------------------------------------------------------------------- */\n\nexport const Gauge: ComponentSpec = {\n name: \"Gauge\",\n description:\n \"Half-doughnut gauge indicator for a single value between `min` and \" +\n \"`max`. The inner value is auto-formatted from the value (override \" +\n \"via `label`). Pass `caption`, `tone`, and `size` for visual \" +\n \"treatment. Use for KPI thresholds (uptime %, score, capacity, NPS, \" +\n \"page-speed).\",\n props: [\n { name: \"value\", type: \"number\" },\n { name: \"min\", type: \"number\", optional: true, description: \"Lower bound (default 0)\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Upper bound (default 100)\" },\n { name: \"caption\", type: \"string\", optional: true, description: \"Small caption below the gauge\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n { name: \"size\", type: \"string\", optional: true, enum: [\"sm\", \"md\", \"lg\"] },\n { name: \"label\", type: \"string\", optional: true, description: \"Inner label override (defaults to auto-formatted value)\" },\n ],\n render: (_node, props) => {\n const min = asNumber(props.min, 0);\n const max = Math.max(min + 1, asNumber(props.max, 100));\n const value = Math.max(min, Math.min(max, asNumber(props.value, min)));\n const pct = (value - min) / (max - min);\n const tone = asString(props.tone, \"primary\");\n const size = asString(props.size, \"md\");\n const px = size === \"lg\" ? 220 : size === \"sm\" ? 140 : 180;\n const half = px / 2;\n const stroke = size === \"lg\" ? 18 : size === \"sm\" ? 10 : 14;\n const r = half - stroke;\n const root = el(\"div\", {\n class: \"rui-gauge\",\n \"data-tone\": tone,\n \"data-size\": size,\n });\n const svg = createSvg(px, half + stroke + 4);\n const cx = half;\n const cy = half;\n const startX = cx - r;\n const startY = cy;\n const endX = cx + r;\n const endY = cy;\n svg.append(svgEl(\"path\", {\n d: `M${startX},${startY} A${r},${r} 0 0 1 ${endX},${endY}`,\n fill: \"none\",\n stroke: \"var(--rui-color-border, #e2e8f0)\",\n \"stroke-width\": String(stroke),\n \"stroke-linecap\": \"round\",\n }));\n if (pct > 0) {\n const angle = Math.PI * pct;\n const x = cx - r * Math.cos(angle);\n const y = cy - r * Math.sin(angle);\n // The gauge is only the upper half of a circle, so the foreground\n // arc never exceeds 180°. `large-arc-flag` is therefore always 0 —\n // setting it to 1 makes the SVG renderer take the long way round\n // and draw the missing portion instead of the filled portion.\n svg.append(svgEl(\"path\", {\n d: `M${startX},${startY} A${r},${r} 0 0 1 ${x.toFixed(2)},${y.toFixed(2)}`,\n fill: \"none\",\n stroke: `var(--rui-color-${tone}, ${colorAt(0)})`,\n \"stroke-width\": String(stroke),\n \"stroke-linecap\": \"round\",\n class: \"rui-gauge-arc\",\n }));\n }\n root.append(svg);\n const autoLabel = formatGaugeValue(value, min, max);\n const label = asString(props.label) || autoLabel;\n root.append(el(\"div\", { class: \"rui-gauge-value\" }, [label]));\n const caption = asString(props.caption);\n if (caption) root.append(el(\"div\", { class: \"rui-gauge-caption\" }, [caption]));\n return root;\n },\n};\n\nfunction formatGaugeValue(value: number, min: number, max: number): string {\n const isPercentLike = min === 0 && max === 100;\n if (isPercentLike) {\n return value % 1 === 0 ? `${value}%` : `${value.toFixed(1)}%`;\n }\n if (Math.abs(value) >= 1000) return Math.round(value).toLocaleString();\n if (value % 1 === 0) return String(value);\n return value.toFixed(value < 10 ? 2 : 1);\n}\n\n/* ----------------------------------------------------------------------- *\n * Heatmap\n * ----------------------------------------------------------------------- */\n\nexport const Heatmap: ComponentSpec = {\n name: \"Heatmap\",\n description:\n \"Color-intensity matrix grid (calendar-style or correlation-style). \" +\n \"Pass `xLabels`, `yLabels`, and a `values` array of arrays (rows × \" +\n \"columns). Each cell's color intensity scales with the value relative \" +\n \"to the global max. Use for activity heatmaps, schedule density, \" +\n \"correlation matrices.\",\n props: [\n { name: \"xLabels\", type: \"string[]\" },\n { name: \"yLabels\", type: \"string[]\" },\n { name: \"values\", type: \"number[][]\", description: \"Matrix indexed by row (y), then column (x)\" },\n { name: \"title\", type: \"string\", optional: true },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"primary\", \"success\", \"warning\", \"danger\", \"info\"] },\n ],\n render: (_node, props) => {\n const xLabels = asArray<unknown>(props.xLabels).map((l) => asString(l));\n const yLabels = asArray<unknown>(props.yLabels).map((l) => asString(l));\n const valueRows: number[][] = asArray<unknown>(props.values).map((row) =>\n asArray<unknown>(row).map((v) => asNumber(v, 0)));\n const tone = asString(props.tone, \"primary\");\n const max = Math.max(1, ...valueRows.flat());\n const root = el(\"div\", { class: \"rui-heatmap\", \"data-tone\": tone });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n const tableWrap = el(\"div\", { class: \"rui-heatmap-table\" });\n const headerRow = el(\"div\", { class: \"rui-heatmap-row rui-heatmap-row-header\" });\n headerRow.append(el(\"div\", { class: \"rui-heatmap-cell rui-heatmap-corner\" }));\n for (const x of xLabels) {\n headerRow.append(el(\"div\", { class: \"rui-heatmap-cell rui-heatmap-xlabel\" }, [x]));\n }\n tableWrap.append(headerRow);\n valueRows.forEach((row, rIdx) => {\n const rowEl = el(\"div\", { class: \"rui-heatmap-row\" });\n rowEl.append(el(\"div\", { class: \"rui-heatmap-cell rui-heatmap-ylabel\" }, [yLabels[rIdx] ?? String(rIdx + 1)]));\n row.forEach((value, cIdx) => {\n const intensity = max > 0 ? value / max : 0;\n const cell = el(\"div\", {\n class: \"rui-heatmap-cell rui-heatmap-value\",\n style: `background:color-mix(in srgb, var(--rui-color-${tone}, ${colorAt(0)}) ${Math.round(intensity * 90 + 5)}%, transparent);`,\n title: `${xLabels[cIdx] ?? cIdx + 1} · ${yLabels[rIdx] ?? rIdx + 1}: ${value}`,\n });\n cell.append(el(\"span\", {}, [String(value)]));\n rowEl.append(cell);\n });\n tableWrap.append(rowEl);\n });\n root.append(tableWrap);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * RadarChart\n * ----------------------------------------------------------------------- */\n\nexport const RadarChart: ComponentSpec = {\n name: \"RadarChart\",\n description:\n \"Polygon chart with one axis per category. Use for skill maps, \" +\n \"scorecards, capability comparisons, and any multi-dimensional \" +\n \"snapshot. Each Series renders as a filled polygon — overlapping is \" +\n \"expected for comparisons.\",\n props: [\n { name: \"axes\", type: \"string[]\", description: \"Category labels — one per radial axis\" },\n { name: \"series\", type: \"Series[]\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Outer ring value (default = max across series)\" },\n { name: \"title\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const axes = asArray<unknown>(props.axes).map((a) => asString(a));\n const series = readSeries(asArray<unknown>(props.series));\n const n = Math.max(axes.length, 3);\n const root = el(\"div\", { class: \"rui-chart rui-radar-chart\" });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n const max = Math.max(1, asNumber(props.max, series.flatMap((s) => s.values).reduce((m, v) => Math.max(m, v), 1)));\n const size = 280;\n const cx = size / 2;\n const cy = size / 2;\n const r = size / 2 - 24;\n const svg = createSvg(size, size);\n const rings = 4;\n for (let i = 1; i <= rings; i += 1) {\n const radius = (r / rings) * i;\n const points: string[] = [];\n for (let j = 0; j < n; j += 1) {\n const angle = (Math.PI * 2 * j) / n - Math.PI / 2;\n points.push(`${(cx + radius * Math.cos(angle)).toFixed(1)},${(cy + radius * Math.sin(angle)).toFixed(1)}`);\n }\n svg.append(svgEl(\"polygon\", {\n points: points.join(\" \"),\n fill: \"none\",\n stroke: \"var(--rui-color-border-subtle, rgba(0,0,0,0.08))\",\n \"stroke-width\": \"1\",\n }));\n }\n for (let j = 0; j < n; j += 1) {\n const angle = (Math.PI * 2 * j) / n - Math.PI / 2;\n const x = cx + r * Math.cos(angle);\n const y = cy + r * Math.sin(angle);\n svg.append(svgEl(\"line\", {\n x1: String(cx),\n y1: String(cy),\n x2: x.toFixed(1),\n y2: y.toFixed(1),\n stroke: \"var(--rui-color-border-subtle, rgba(0,0,0,0.08))\",\n \"stroke-width\": \"1\",\n }));\n const labelX = cx + (r + 16) * Math.cos(angle);\n const labelY = cy + (r + 16) * Math.sin(angle);\n svg.append(svgEl(\"text\", {\n x: labelX.toFixed(1),\n y: labelY.toFixed(1),\n \"text-anchor\": \"middle\",\n \"dominant-baseline\": \"middle\",\n class: \"rui-chart-label\",\n \"font-size\": \"13\",\n \"font-weight\": \"500\",\n }, [axes[j] ?? \"\"]));\n }\n series.forEach((s, sIdx) => {\n const points: string[] = [];\n for (let j = 0; j < n; j += 1) {\n const value = s.values[j] ?? 0;\n const ratio = Math.max(0, Math.min(1, value / max));\n const angle = (Math.PI * 2 * j) / n - Math.PI / 2;\n const x = cx + r * ratio * Math.cos(angle);\n const y = cy + r * ratio * Math.sin(angle);\n points.push(`${x.toFixed(1)},${y.toFixed(1)}`);\n }\n svg.append(svgEl(\"polygon\", {\n points: points.join(\" \"),\n fill: colorAt(sIdx),\n \"fill-opacity\": \"0.2\",\n stroke: colorAt(sIdx),\n \"stroke-width\": \"2\",\n \"stroke-linejoin\": \"round\",\n }));\n });\n root.append(svg);\n if (series.length > 0) root.append(legend(series));\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * ScatterChart\n * ----------------------------------------------------------------------- */\n\ninterface ScatterPoint {\n x: number;\n y: number;\n label: string;\n}\n\nfunction readScatterSeries(raw: unknown[]): { name: string; points: ScatterPoint[] }[] {\n return raw.map((entry, i) => {\n const node = entry as { args?: unknown[] };\n const name = asString(node.args?.[0], `Series ${i + 1}`);\n const points = asArray<unknown>(node.args?.[1]).map((p) => {\n if (Array.isArray(p)) {\n return { x: asNumber(p[0], 0), y: asNumber(p[1], 0), label: asString(p[2]) };\n }\n if (p && typeof p === \"object\") {\n const r = p as Record<string, unknown>;\n return { x: asNumber(r.x, 0), y: asNumber(r.y, 0), label: asString(r.label) };\n }\n return { x: 0, y: 0, label: \"\" };\n });\n return { name, points };\n });\n}\n\nexport const ScatterChart: ComponentSpec = {\n name: \"ScatterChart\",\n description:\n \"XY scatter plot — one dot per data point, optionally grouped by \" +\n \"series. Pass each `Series(name, points)` with points as \" +\n \"`{x, y, label?}` objects or `[x, y, label?]` tuples. Use for \" +\n \"correlations, distributions, and \\\"price vs. rating\\\" style charts.\",\n props: [\n { name: \"series\", type: \"Series[]\" },\n { name: \"xLabel\", type: \"string\", optional: true },\n { name: \"yLabel\", type: \"string\", optional: true },\n { name: \"title\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const series = readScatterSeries(asArray<unknown>(props.series));\n const root = el(\"div\", { class: \"rui-chart rui-scatter-chart\" });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n const width = 640;\n const height = 280;\n const padding = { left: 50, right: 16, top: 16, bottom: 40 };\n const innerWidth = width - padding.left - padding.right;\n const innerHeight = height - padding.top - padding.bottom;\n const points = series.flatMap((s) => s.points);\n if (points.length === 0) {\n root.append(el(\"div\", { class: \"rui-chart-empty\" }, [\"No points\"]));\n return root;\n }\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n const minX = Math.min(...xs), maxX = Math.max(...xs);\n const minY = Math.min(...ys), maxY = Math.max(...ys);\n const xRange = maxX - minX || 1;\n const yRange = maxY - minY || 1;\n const svg = createSvg(width, height);\n drawHorizontalGrid(svg, padding, innerWidth, innerHeight, maxY, minY);\n // x-axis\n svg.append(svgEl(\"line\", {\n x1: String(padding.left),\n y1: String(padding.top + innerHeight),\n x2: String(padding.left + innerWidth),\n y2: String(padding.top + innerHeight),\n stroke: \"var(--rui-color-border, #e2e8f0)\",\n }));\n series.forEach((s, sIdx) => {\n s.points.forEach((pt) => {\n const cx = padding.left + ((pt.x - minX) / xRange) * innerWidth;\n const cy = padding.top + innerHeight - ((pt.y - minY) / yRange) * innerHeight;\n const circle = svgEl(\"circle\", {\n cx: cx.toFixed(1),\n cy: cy.toFixed(1),\n r: \"7\",\n fill: colorAt(sIdx),\n \"fill-opacity\": \"0.8\",\n stroke: \"#fff\",\n \"stroke-width\": \"1.5\",\n });\n circle.append(svgEl(\"title\", {}, [pt.label || `${pt.x}, ${pt.y}`]));\n svg.append(circle);\n });\n });\n if (asString(props.xLabel)) {\n svg.append(svgEl(\"text\", {\n x: String(padding.left + innerWidth / 2),\n y: String(height - 6),\n \"text-anchor\": \"middle\",\n class: \"rui-chart-label\",\n \"font-size\": \"14\",\n \"font-weight\": \"500\",\n }, [asString(props.xLabel)]));\n }\n if (asString(props.yLabel)) {\n const labelX = 14;\n const labelY = padding.top + innerHeight / 2;\n svg.append(svgEl(\"text\", {\n x: String(labelX),\n y: String(labelY),\n \"text-anchor\": \"middle\",\n transform: `rotate(-90, ${labelX}, ${labelY})`,\n class: \"rui-chart-label\",\n \"font-size\": \"14\",\n \"font-weight\": \"500\",\n }, [asString(props.yLabel)]));\n }\n root.append(svg);\n const seriesData: SeriesData[] = series.map((s) => ({ name: s.name, values: s.points.map((p) => p.y) }));\n if (seriesData.length > 0) root.append(legend(seriesData));\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Histogram\n * ----------------------------------------------------------------------- */\n\nexport const Histogram: ComponentSpec = {\n name: \"Histogram\",\n description:\n \"Frequency distribution from raw numeric values. Pass `values` \" +\n \"directly (the component bins them automatically) or pre-computed \" +\n \"`bins` of `{label, count}` objects. Use for response-time histograms, \" +\n \"score distributions, age buckets.\",\n props: [\n { name: \"values\", type: \"number[]\", optional: true, description: \"Raw observations (binned automatically)\" },\n { name: \"bins\", type: \"object[]\", optional: true, description: \"Pre-computed {label, count} entries (overrides `values`)\" },\n { name: \"binCount\", type: \"number\", optional: true, description: \"Number of bins when computing from `values` (default 10)\" },\n { name: \"title\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n let bins: { label: string; count: number }[] = [];\n if (Array.isArray(props.bins) && (props.bins as unknown[]).length > 0) {\n bins = (props.bins as unknown[]).map((entry) => {\n const r = (entry ?? {}) as { label?: unknown; count?: unknown };\n return { label: asString(r.label), count: asNumber(r.count, 0) };\n });\n } else {\n const values = asArray<unknown>(props.values).map((v) => asNumber(v, NaN)).filter((n) => Number.isFinite(n));\n if (values.length > 0) {\n const binCount = Math.max(2, Math.min(50, Math.floor(asNumber(props.binCount, 10))));\n const min = Math.min(...values);\n const max = Math.max(...values);\n const span = max - min || 1;\n const step = span / binCount;\n const counts = new Array(binCount).fill(0);\n for (const v of values) {\n let idx = Math.floor((v - min) / step);\n if (idx >= binCount) idx = binCount - 1;\n if (idx < 0) idx = 0;\n counts[idx] += 1;\n }\n bins = counts.map((count, i) => {\n const a = min + i * step;\n const b = a + step;\n return { label: `${formatBinLabel(a)}–${formatBinLabel(b)}`, count };\n });\n }\n }\n const root = el(\"div\", { class: \"rui-chart rui-histogram\" });\n if (asString(props.title)) root.append(el(\"div\", { class: \"rui-chart-title\" }, [asString(props.title)]));\n if (bins.length === 0) {\n root.append(el(\"div\", { class: \"rui-chart-empty\" }, [\"No data\"]));\n return root;\n }\n const width = 640;\n const height = 240;\n const padding = { left: 40, right: 12, top: 16, bottom: 50 };\n const innerWidth = width - padding.left - padding.right;\n const innerHeight = height - padding.top - padding.bottom;\n const max = Math.max(1, ...bins.map((b) => b.count));\n const slot = innerWidth / bins.length;\n const svg = createSvg(width, height);\n drawHorizontalGrid(svg, padding, innerWidth, innerHeight, max);\n bins.forEach((bin, i) => {\n const x = padding.left + i * slot + slot * 0.1;\n const barWidth = slot * 0.8;\n const barHeight = (bin.count / max) * innerHeight;\n const y = padding.top + innerHeight - barHeight;\n const rect = svgEl(\"rect\", {\n x: x.toFixed(1),\n y: y.toFixed(1),\n width: barWidth.toFixed(1),\n height: barHeight.toFixed(1),\n fill: colorAt(0),\n rx: \"2\",\n });\n rect.append(svgEl(\"title\", {}, [`${bin.label}: ${bin.count}`]));\n svg.append(rect);\n svg.append(svgEl(\"text\", {\n x: (x + barWidth / 2).toFixed(1),\n y: String(padding.top + innerHeight + 22),\n \"text-anchor\": \"middle\",\n class: \"rui-chart-label\",\n \"font-size\": \"12\",\n }, [bin.label]));\n });\n root.append(svg);\n return root;\n },\n};\n\nfunction formatBinLabel(value: number): string {\n if (!Number.isFinite(value)) return \"?\";\n if (Math.abs(value) >= 1000) return Math.round(value).toLocaleString();\n if (Math.abs(value) >= 10) return value.toFixed(0);\n return value.toFixed(1);\n}\n\n/* ----------------------------------------------------------------------- *\n * Shared chart helpers\n * ----------------------------------------------------------------------- */\n\nfunction drawHorizontalGrid(\n svg: SVGSVGElement,\n padding: { left: number; right: number; top: number; bottom: number },\n innerWidth: number,\n innerHeight: number,\n max: number,\n min = 0,\n): void {\n const ticks = 4;\n for (let i = 0; i <= ticks; i += 1) {\n const ratio = i / ticks;\n const y = padding.top + innerHeight - ratio * innerHeight;\n svg.append(svgEl(\"line\", {\n x1: String(padding.left),\n x2: String(padding.left + innerWidth),\n y1: String(y),\n y2: String(y),\n stroke: \"var(--rui-color-border-subtle, rgba(0,0,0,0.08))\",\n }));\n svg.append(svgEl(\"text\", {\n x: String(padding.left - 8),\n y: String(y + 5),\n \"text-anchor\": \"end\",\n class: \"rui-chart-tick\",\n \"font-size\": \"14\",\n }, [String(Math.round((min + (max - min) * ratio) * 10) / 10)]));\n }\n}\n","/**\n * Advanced form components:\n *\n * - PinInput / OtpInput — Per-digit code entry for 2FA, SMS verification.\n * - PasswordInput — Text input with visibility toggle and strength meter.\n * - TagInput — Comma/Enter-separated chip input bound to a `$variable` array.\n * - MentionInput — TextArea-like input that suggests @-mentions from a list.\n * - TimePicker — `<input type=\"time\">` wrapper.\n * - DateTimePicker — `<input type=\"datetime-local\">` wrapper.\n * - MaskedInput — Text input with a simple mask (e.g. `(999) 999-9999`).\n * - FormSection / FieldSet — Semantic grouping for form fields.\n * - ValidationSummary — Aggregate errors list for the top of a form.\n * - MultiStepForm — Steps + content + prev/next composite.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { el, asArray, asString, asBoolean, asNumber, renderIcon } from \"../utils.js\";\nimport { attachOnChange } from \"./wrappers.js\";\n\nconst PIN_TYPES = [\"numeric\", \"alphanumeric\"] as const;\n\n/* ----------------------------------------------------------------------- *\n * PinInput / OtpInput\n * ----------------------------------------------------------------------- */\n\nfunction renderPin(\n id: string,\n length: number,\n type: string,\n value: string,\n disabled: boolean,\n mask: boolean,\n onChange?: (next: string) => void,\n): HTMLElement {\n const root = el(\"div\", {\n class: \"rui-pin-input\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n const inputs: HTMLInputElement[] = [];\n for (let i = 0; i < length; i += 1) {\n const input = el(\"input\", {\n class: \"rui-pin-input-slot\",\n id: i === 0 ? id : null,\n maxlength: \"1\",\n autocomplete: \"one-time-code\",\n inputmode: type === \"numeric\" ? \"numeric\" : \"text\",\n type: mask ? \"password\" : \"text\",\n \"aria-label\": `Digit ${i + 1}`,\n value: value.charAt(i) || \"\",\n disabled: disabled ? \"\" : null,\n }) as HTMLInputElement;\n inputs.push(input);\n root.append(input);\n }\n const getLiveSlots = (origin: Element): HTMLInputElement[] => {\n const pinRoot = origin.closest(\".rui-pin-input\");\n if (!pinRoot) return inputs;\n return Array.from(pinRoot.querySelectorAll<HTMLInputElement>(\".rui-pin-input-slot\"));\n };\n const collectLive = (origin: Element): string => {\n return getLiveSlots(origin).map((i) => i.value).join(\"\").slice(0, length);\n };\n inputs.forEach((input, idx) => {\n input.oninput = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n const liveSlots = getLiveSlots(target);\n let v = target.value;\n if (type === \"numeric\") v = v.replace(/\\D/g, \"\");\n else v = v.replace(/[^A-Za-z0-9]/g, \"\");\n if (v.length > 1) {\n const chars = v.split(\"\");\n chars.slice(0, length - idx).forEach((c, k) => {\n const next = liveSlots[idx + k];\n if (next) next.value = c;\n });\n const lastFilled = Math.min(idx + chars.length, length - 1);\n liveSlots[lastFilled]?.focus();\n } else {\n target.value = v;\n if (v && idx < length - 1) liveSlots[idx + 1]?.focus();\n }\n onChange?.(collectLive(target));\n };\n input.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n const target = e.currentTarget as HTMLInputElement;\n const liveSlots = getLiveSlots(target);\n if (e.key === \"Backspace\" && !target.value && idx > 0) {\n e.preventDefault();\n liveSlots[idx - 1]?.focus();\n const prev = liveSlots[idx - 1];\n if (prev) prev.value = \"\";\n onChange?.(collectLive(target));\n } else if (e.key === \"ArrowLeft\" && idx > 0) {\n e.preventDefault();\n liveSlots[idx - 1]?.focus();\n } else if (e.key === \"ArrowRight\" && idx < length - 1) {\n e.preventDefault();\n liveSlots[idx + 1]?.focus();\n }\n };\n });\n return root;\n}\n\nexport const PinInput: ComponentSpec = {\n name: \"PinInput\",\n description:\n \"Per-digit PIN entry. Auto-advances focus as the user types and \" +\n \"supports paste. Pass a `$variable` as `value` for two-way binding \" +\n \"(the bound value is the joined string). Use `type=\\\"numeric\\\"` for \" +\n \"PINs / 2FA codes, `\\\"alphanumeric\\\"` for invite codes.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"length\", type: \"number\", optional: true, description: \"Number of slots (default 4)\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"type\", type: \"string\", optional: true, enum: PIN_TYPES },\n { name: \"mask\", type: \"boolean\", optional: true, description: \"Render slots as `<input type=password>`\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current joined string on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const length = Math.max(1, Math.min(12, Math.floor(asNumber(props.length, 4))));\n const type = asString(props.type, \"numeric\");\n const value = asString(props.value);\n const disabled = asBoolean(props.disabled);\n const mask = asBoolean(props.mask);\n const stateName = node.argMeta?.[2]?.stateRef;\n return renderPin(id, length, type, value, disabled, mask, (next) => {\n if (stateName) helpers.setState(stateName, next);\n helpers.invoke(props.onChange, next);\n });\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * PasswordInput\n * ----------------------------------------------------------------------- */\n\nfunction passwordStrength(value: string): { score: number; label: string } {\n if (!value) return { score: 0, label: \"\" };\n let score = 0;\n if (value.length >= 8) score += 1;\n if (value.length >= 12) score += 1;\n if (/[A-Z]/.test(value) && /[a-z]/.test(value)) score += 1;\n if (/[0-9]/.test(value)) score += 1;\n if (/[^A-Za-z0-9]/.test(value)) score += 1;\n score = Math.min(4, score);\n const labels = [\"Too short\", \"Weak\", \"Fair\", \"Good\", \"Strong\"];\n return { score, label: labels[score] ?? \"\" };\n}\n\nexport const PasswordInput: ComponentSpec = {\n name: \"PasswordInput\",\n description:\n \"Password input with a show/hide toggle and an optional strength \" +\n \"meter. Pass a `$variable` as `value` for two-way binding. Set \" +\n \"`strengthMeter=true` to render a 4-step indicator and label.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"label\", type: \"string\", optional: true, description: \"Inline label above the field\" },\n { name: \"strengthMeter\", type: \"boolean\", optional: true, aliases: [\"showStrength\"] },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current value on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const visibleSlot = helpers.useInstanceState<boolean>(\"visible\", false);\n const visible = visibleSlot.get();\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", { class: \"rui-password-input\", \"data-disabled\": disabled ? \"true\" : \"false\" });\n const labelText = asString(props.label);\n if (labelText) {\n root.append(el(\"label\", { class: \"rui-password-input-label\", for: id }, [labelText]));\n }\n const row = el(\"div\", { class: \"rui-password-input-row\" });\n const input = el(\"input\", {\n type: visible ? \"text\" : \"password\",\n class: \"rui-password-input-field\",\n id,\n name: id,\n autocomplete: \"current-password\",\n placeholder: asString(props.placeholder),\n value: asString(props.value),\n disabled: disabled ? \"\" : null,\n }) as HTMLInputElement;\n const toggleBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-password-input-toggle\",\n \"aria-label\": visible ? \"Hide password\" : \"Show password\",\n });\n const toggleIcon = renderIcon(visible ? \"eye-slash\" : \"eye\");\n if (toggleIcon) toggleBtn.append(toggleIcon);\n toggleBtn.onclick = (event) => {\n event.preventDefault();\n const next = !visibleSlot.get();\n visibleSlot.set(next);\n const target = event.currentTarget as Element;\n const live = target.closest(\".rui-password-input\");\n const liveInput = live?.querySelector<HTMLInputElement>(\".rui-password-input-field\");\n if (liveInput) liveInput.type = next ? \"text\" : \"password\";\n };\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName) {\n helpers.bindState(input, stateName, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n }\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n row.append(input);\n row.append(toggleBtn);\n root.append(row);\n if (asBoolean(props.strengthMeter)) {\n const strength = passwordStrength(asString(props.value));\n const meter = el(\"div\", { class: \"rui-password-input-strength\", \"data-score\": String(strength.score) });\n for (let i = 0; i < 4; i += 1) {\n meter.append(el(\"span\", {\n class: \"rui-password-input-strength-bar\",\n \"data-filled\": i < strength.score ? \"true\" : \"false\",\n }));\n }\n const labelRow = el(\"div\", { class: \"rui-password-input-strength-row\" });\n labelRow.append(meter);\n if (strength.label) labelRow.append(el(\"span\", { class: \"rui-password-input-strength-label\" }, [strength.label]));\n root.append(labelRow);\n }\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * TagInput\n * ----------------------------------------------------------------------- */\n\nexport const TagInput: ComponentSpec = {\n name: \"TagInput\",\n description:\n \"Tag/chip input — type a value, press Enter (or comma) to commit, \" +\n \"click × on a chip to remove. Pass a `$variable` (array of strings) \" +\n \"as `value` for two-way binding. Use for keywords, recipients, \" +\n \"labels, skills, allowlists.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string[]\", optional: true, description: \"Bound array of tag values\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"label\", type: \"string\", optional: true, description: \"Inline label above the field\" },\n { name: \"max\", type: \"number\", optional: true, description: \"Maximum number of tags\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the updated array of tags whenever one is added or removed\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const tags = asArray<unknown>(props.value).map((v) => asString(v)).filter(Boolean);\n const max = Math.max(0, Math.floor(asNumber(props.max, 0)));\n const disabled = asBoolean(props.disabled);\n const stateName = node.argMeta?.[1]?.stateRef;\n const setTags = (next: string[]) => {\n if (stateName) helpers.setState(stateName, next);\n helpers.invoke(props.onChange, next);\n };\n const labelText = asString(props.label);\n const root = el(\"div\", {\n class: \"rui-tag-input\",\n \"data-disabled\": disabled ? \"true\" : \"false\",\n });\n for (const tag of tags) {\n const chip = el(\"span\", { class: \"rui-tag-input-chip\" });\n chip.append(el(\"span\", {}, [tag]));\n const remove = el(\"button\", {\n type: \"button\",\n class: \"rui-tag-input-remove\",\n \"aria-label\": `Remove ${tag}`,\n }, [\"×\"]);\n remove.onclick = () => setTags(tags.filter((t) => t !== tag));\n chip.append(remove);\n root.append(chip);\n }\n const input = el(\"input\", {\n type: \"text\",\n class: \"rui-tag-input-field\",\n id,\n name: id,\n placeholder: asString(props.placeholder, tags.length === 0 ? \"Add tags…\" : \"\"),\n disabled: disabled ? \"\" : null,\n autocomplete: \"off\",\n }) as HTMLInputElement;\n input.onkeydown = (event) => {\n const e = event as KeyboardEvent;\n // Read the value from the *live* input — morph keeps the previously\n // mounted DOM node, so the closure-captured `input` reference points\n // at the freshly rendered (detached) field and its `.value` is empty.\n const liveInput = e.currentTarget as HTMLInputElement;\n if (e.key === \"Enter\" || e.key === \",\") {\n e.preventDefault();\n const value = liveInput.value.trim();\n if (!value) return;\n if (max > 0 && tags.length >= max) return;\n if (tags.includes(value)) {\n liveInput.value = \"\";\n return;\n }\n setTags([...tags, value]);\n liveInput.value = \"\";\n } else if (e.key === \"Backspace\" && liveInput.value === \"\" && tags.length > 0) {\n e.preventDefault();\n setTags(tags.slice(0, -1));\n }\n };\n root.append(input);\n if (labelText) {\n const wrapper = el(\"div\", { class: \"rui-tag-input-wrapper\" });\n wrapper.append(el(\"label\", { class: \"rui-tag-input-label\", for: id }, [labelText]));\n wrapper.append(root);\n return wrapper;\n }\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * MentionInput\n * ----------------------------------------------------------------------- */\n\ninterface MentionItem {\n value: string;\n label: string;\n}\n\nfunction readMentionItems(raw: unknown): MentionItem[] {\n return asArray<unknown>(raw).map((entry) => {\n if (typeof entry === \"string\") return { value: entry, label: entry };\n if (entry && typeof entry === \"object\") {\n const r = entry as Record<string, unknown>;\n // Accept `{name}`, `{label}`, `{value}`, or `{id}` plus a `handle`\n // for tagging (e.g. `@ada` vs full name \"Ada Lovelace\").\n const display = asString(r.label ?? r.name ?? r.value ?? r.id);\n const handle = asString(r.handle ?? r.value ?? r.id ?? r.name ?? r.label);\n return { value: handle, label: display };\n }\n return { value: \"\", label: \"\" };\n }).filter((i) => i.value || i.label);\n}\n\nexport const MentionInput: ComponentSpec = {\n name: \"MentionInput\",\n description:\n \"Multi-line input with inline @-mention suggestions. Typing `@` \" +\n \"opens a popover listing the provided `people` (filtered by what \" +\n \"follows). Selecting an option inserts `@label` into the text. Pass \" +\n \"a `$variable` as `value` for two-way binding. Use for comments, \" +\n \"task notes, chat composers.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"people\", type: \"any[]\", description: \"Available mentions: strings or {value, label} objects\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound text (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"rows\", type: \"number\", optional: true, description: \"TextArea rows (default 3)\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the current text on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const people = readMentionItems(props.people);\n const disabled = asBoolean(props.disabled);\n const root = el(\"div\", { class: \"rui-mention-input\", \"data-disabled\": disabled ? \"true\" : \"false\" });\n const textarea = el(\"textarea\", {\n class: \"rui-mention-input-field\",\n id,\n name: id,\n rows: String(Math.max(2, Math.floor(asNumber(props.rows, 3)))),\n placeholder: asString(props.placeholder, \"Type @ to mention someone\"),\n disabled: disabled ? \"\" : null,\n }) as HTMLTextAreaElement;\n textarea.value = asString(props.value);\n const suggestions = el(\"div\", { class: \"rui-mention-input-suggestions\", \"data-open\": \"false\" });\n\n // Per-instance UI state survives re-renders triggered by two-way\n // binding. The fresh render must reproduce the open state on the\n // freshly-built suggestions panel so morph doesn't reset the live\n // panel back to \"closed\" when it copies attributes/children over.\n const activeSlot = helpers.useInstanceState<number>(\"activeIndex\", 0);\n const matchesSlot = helpers.useInstanceState<MentionItem[]>(\"matches\", []);\n const querySlot = helpers.useInstanceState<string | null>(\"query\", null);\n\n const liveSuggestionsFor = (origin: Element): HTMLElement | null => {\n const root = origin.closest(\".rui-mention-input\");\n return root?.querySelector<HTMLElement>(\".rui-mention-input-suggestions\") ?? null;\n };\n\n const liveTextareaFor = (origin: Element): HTMLTextAreaElement | null => {\n const root = origin.closest(\".rui-mention-input\");\n return root?.querySelector<HTMLTextAreaElement>(\".rui-mention-input-field\") ?? null;\n };\n\n const insertMention = (liveTextarea: HTMLTextAreaElement, item: MentionItem) => {\n const text = liveTextarea.value;\n const caret = liveTextarea.selectionStart ?? text.length;\n const before = text.slice(0, caret);\n const triggerIdx = before.lastIndexOf(\"@\");\n if (triggerIdx === -1) return;\n const after = text.slice(caret);\n const insert = `@${item.value} `;\n const next = before.slice(0, triggerIdx) + insert + after;\n liveTextarea.value = next;\n const cursor = triggerIdx + insert.length;\n liveTextarea.selectionStart = liveTextarea.selectionEnd = cursor;\n liveTextarea.dispatchEvent(new Event(\"input\", { bubbles: true }));\n liveTextarea.focus();\n };\n\n const paintSuggestions = (panel: HTMLElement, query: string | null) => {\n panel.replaceChildren();\n if (query === null) {\n panel.setAttribute(\"data-open\", \"false\");\n matchesSlot.set([]);\n return;\n }\n const q = query.toLowerCase();\n const filtered = people.filter((p) =>\n p.label.toLowerCase().includes(q) || p.value.toLowerCase().includes(q),\n );\n const slice = filtered.slice(0, 6);\n matchesSlot.set(slice);\n if (slice.length === 0) {\n panel.setAttribute(\"data-open\", \"false\");\n return;\n }\n const nextActive = Math.min(activeSlot.get(), slice.length - 1);\n activeSlot.set(nextActive);\n panel.setAttribute(\"data-open\", \"true\");\n slice.forEach((item, idx) => {\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-mention-input-option\",\n \"data-value\": item.value,\n \"data-active\": idx === nextActive ? \"true\" : \"false\",\n });\n btn.append(el(\"span\", { class: \"rui-mention-input-option-label\" }, [item.label]));\n if (item.value && item.value !== item.label) {\n btn.append(el(\"span\", { class: \"rui-mention-input-option-handle\" }, [`@${item.value}`]));\n }\n btn.onmousedown = (event) => event.preventDefault();\n btn.onclick = (event) => {\n const origin = event.currentTarget as Element;\n const ta = liveTextareaFor(origin);\n const live = liveSuggestionsFor(origin);\n if (ta) insertMention(ta, item);\n querySlot.set(null);\n if (live) paintSuggestions(live, null);\n };\n panel.append(btn);\n });\n };\n\n const updateFromCaret = (liveTextarea: HTMLTextAreaElement) => {\n const live = liveSuggestionsFor(liveTextarea);\n if (!live) return;\n const caret = liveTextarea.selectionStart ?? liveTextarea.value.length;\n const before = liveTextarea.value.slice(0, caret);\n const match = /@([\\w-]*)$/.exec(before);\n const nextQuery = match ? match[1] ?? \"\" : null;\n querySlot.set(nextQuery);\n paintSuggestions(live, nextQuery);\n };\n\n const stateName = node.argMeta?.[2]?.stateRef;\n if (stateName) {\n // bindState overwrites `oninput`, so we piggyback the suggestion\n // update onto `getValue` (called by the renderer's listener with\n // the live currentTarget).\n helpers.bindState(textarea, stateName, {\n event: \"input\",\n getValue: (n) => {\n const ta = n as HTMLTextAreaElement;\n updateFromCaret(ta);\n return ta.value;\n },\n });\n } else {\n textarea.oninput = (event) => {\n updateFromCaret(event.currentTarget as HTMLTextAreaElement);\n };\n }\n attachOnChange(textarea, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLTextAreaElement).value,\n });\n textarea.onkeydown = (event) => {\n const ta = event.currentTarget as HTMLTextAreaElement;\n const live = liveSuggestionsFor(ta);\n if (!live || live.getAttribute(\"data-open\") !== \"true\") return;\n const matches = matchesSlot.get();\n if (matches.length === 0) return;\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n const next = (activeSlot.get() + 1) % matches.length;\n activeSlot.set(next);\n const items = live.querySelectorAll<HTMLElement>(\".rui-mention-input-option\");\n items.forEach((b, i) => b.setAttribute(\"data-active\", i === next ? \"true\" : \"false\"));\n } else if (event.key === \"ArrowUp\") {\n event.preventDefault();\n const next = (activeSlot.get() - 1 + matches.length) % matches.length;\n activeSlot.set(next);\n const items = live.querySelectorAll<HTMLElement>(\".rui-mention-input-option\");\n items.forEach((b, i) => b.setAttribute(\"data-active\", i === next ? \"true\" : \"false\"));\n } else if (event.key === \"Enter\" || event.key === \"Tab\") {\n event.preventDefault();\n const chosen = matches[activeSlot.get()];\n if (chosen) {\n insertMention(ta, chosen);\n querySlot.set(null);\n paintSuggestions(live, null);\n }\n } else if (event.key === \"Escape\") {\n querySlot.set(null);\n paintSuggestions(live, null);\n }\n };\n textarea.onblur = (event) => {\n const ta = event.currentTarget as HTMLTextAreaElement;\n setTimeout(() => {\n const live = liveSuggestionsFor(ta);\n querySlot.set(null);\n if (live) paintSuggestions(live, null);\n }, 120);\n };\n root.append(textarea);\n root.append(suggestions);\n // Reproduce the persisted open/query state on this freshly-built\n // panel so morph keeps the live popover open across re-renders.\n paintSuggestions(suggestions, querySlot.get());\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * TimePicker / DateTimePicker / MaskedInput\n * ----------------------------------------------------------------------- */\n\nexport const TimePicker: ComponentSpec = {\n name: \"TimePicker\",\n description:\n \"Time-of-day picker that wraps `<input type=\\\"time\\\">`. Pass a \" +\n \"`$variable` as `value` for two-way binding (HH:MM 24-hour). Set \" +\n \"`step` to constrain to specific increments (e.g. 900 for 15-minute \" +\n \"buckets).\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"HH:MM value; typically $variable\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"min\", type: \"string\", optional: true },\n { name: \"max\", type: \"string\", optional: true },\n { name: \"step\", type: \"number\", optional: true, description: \"Seconds between selectable times\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new HH:MM string when the user picks a time\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const root = el(\"div\", { class: \"rui-time-picker\" });\n const label = asString(props.label);\n if (label) root.append(el(\"label\", { class: \"rui-time-picker-label\", for: id }, [label]));\n const input = el(\"input\", {\n type: \"time\",\n class: \"rui-time-picker-input\",\n id,\n name: id,\n value: asString(props.value),\n min: asString(props.min) || null,\n max: asString(props.max) || null,\n step: props.step != null ? String(asNumber(props.step, 60)) : null,\n disabled: asBoolean(props.disabled) ? \"\" : null,\n }) as HTMLInputElement;\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName) helpers.bindState(input, stateName);\n attachOnChange(input, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n root.append(input);\n return root;\n },\n};\n\nexport const DateTimePicker: ComponentSpec = {\n name: \"DateTimePicker\",\n description:\n \"Combined date + time picker — wraps `<input \" +\n \"type=\\\"datetime-local\\\">`. Pass a `$variable` as `value` for two-way \" +\n \"binding (ISO `YYYY-MM-DDTHH:MM`).\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"value\", type: \"string\", optional: true, description: \"ISO date-time value; typically $variable\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"min\", type: \"string\", optional: true },\n { name: \"max\", type: \"string\", optional: true },\n { name: \"step\", type: \"number\", optional: true, description: \"Seconds between selectable times\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the new ISO `YYYY-MM-DDTHH:MM` string\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const root = el(\"div\", { class: \"rui-datetime-picker\" });\n const label = asString(props.label);\n if (label) root.append(el(\"label\", { class: \"rui-datetime-picker-label\", for: id }, [label]));\n const input = el(\"input\", {\n type: \"datetime-local\",\n class: \"rui-datetime-picker-input\",\n id,\n name: id,\n value: asString(props.value),\n min: asString(props.min) || null,\n max: asString(props.max) || null,\n step: props.step != null ? String(asNumber(props.step, 60)) : null,\n disabled: asBoolean(props.disabled) ? \"\" : null,\n }) as HTMLInputElement;\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName) helpers.bindState(input, stateName);\n attachOnChange(input, props.onChange, helpers, {\n event: \"change\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n root.append(input);\n return root;\n },\n};\n\n/**\n * Mask tokens:\n * - `9` matches a single digit\n * - `A` matches a single alpha character\n * - `*` matches any single character\n * - Any other character is a fixed delimiter inserted automatically\n *\n * Behavior: the raw value is stripped of all non-token-matching characters\n * for each placeholder; fixed delimiters are inserted between tokens as the\n * user types. This produces the expected progressive formatting (e.g. typing\n * `4155550114` into a `(999) 999-9999` mask becomes `(415) 555-0114`).\n */\nfunction applyMask(value: string, mask: string): string {\n if (!mask) return value;\n let out = \"\";\n let i = 0;\n const v = String(value ?? \"\");\n for (const ch of mask) {\n if (i >= v.length) break;\n if (ch === \"9\") {\n while (i < v.length && !/\\d/.test(v[i] ?? \"\")) i += 1;\n if (i >= v.length) break;\n out += v[i];\n i += 1;\n } else if (ch === \"A\") {\n while (i < v.length && !/[a-zA-Z]/.test(v[i] ?? \"\")) i += 1;\n if (i >= v.length) break;\n out += v[i];\n i += 1;\n } else if (ch === \"*\") {\n out += v[i];\n i += 1;\n } else {\n out += ch;\n if (v[i] === ch) i += 1;\n }\n }\n return out;\n}\n\nexport const MaskedInput: ComponentSpec = {\n name: \"MaskedInput\",\n description:\n \"Text input with an inline mask — `9` matches a digit, `A` matches a \" +\n \"letter, `*` matches any character, every other character is a \" +\n \"fixed delimiter. Useful for phone numbers, postal codes, credit \" +\n \"cards. Pass `mask` (e.g. `\\\"(999) 999-9999\\\"`) and a `$variable` \" +\n \"as `value`.\",\n props: [\n { name: \"id\", type: \"string\" },\n { name: \"mask\", type: \"string\", description: \"Mask pattern\" },\n { name: \"value\", type: \"string\", optional: true, description: \"Bound value (typically $variable)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"label\", type: \"string\", optional: true, description: \"Inline label above the field\" },\n { name: \"disabled\", type: \"boolean\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, aliases: [\"onchange\"], description: \"Called with the masked value on every keystroke\" },\n ],\n render: (node, props, helpers) => {\n const id = asString(props.id);\n const mask = asString(props.mask);\n const disabled = asBoolean(props.disabled);\n const initial = applyMask(asString(props.value), mask);\n const labelText = asString(props.label);\n const input = el(\"input\", {\n type: \"text\",\n class: \"rui-masked-input\",\n id,\n name: id,\n value: initial,\n placeholder: asString(props.placeholder, mask),\n disabled: disabled ? \"\" : null,\n autocomplete: \"off\",\n }) as HTMLInputElement;\n input.value = initial;\n const stateName = node.argMeta?.[2]?.stateRef;\n // Apply the mask in place and keep the caret near the user's edit\n // position. We use a property-based `oninput` so the morph reconciler\n // can transfer it to a kept DOM node across re-renders.\n const formatInPlace = (target: HTMLInputElement) => {\n const before = target.value;\n const masked = applyMask(before, mask);\n if (masked === before) return masked;\n const caret = target.selectionStart ?? masked.length;\n target.value = masked;\n const newPos = Math.min(masked.length, caret);\n try { target.setSelectionRange(newPos, newPos); } catch { /* ignore */ }\n return masked;\n };\n if (stateName) {\n // bindState overwrites `oninput`, so we mask inside `getValue`\n // (which the renderer's listener calls every time the input fires).\n helpers.bindState(input, stateName, {\n event: \"input\",\n getValue: (n) => formatInPlace(n as HTMLInputElement),\n });\n } else {\n input.oninput = (event) => {\n formatInPlace((event.currentTarget ?? event.target) as HTMLInputElement);\n };\n }\n attachOnChange(input, props.onChange, helpers, {\n event: \"input\",\n getValue: (n) => (n as HTMLInputElement).value,\n });\n if (labelText) {\n const wrapper = el(\"div\", { class: \"rui-masked-input-wrapper\" });\n wrapper.append(el(\"label\", { class: \"rui-masked-input-label\", for: id }, [labelText]));\n wrapper.append(input);\n return wrapper;\n }\n return input;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * FormSection / FieldSet / ValidationSummary\n * ----------------------------------------------------------------------- */\n\nexport const FormSection: ComponentSpec = {\n name: \"FormSection\",\n description:\n \"Semantic grouping for related form fields — renders a small heading \" +\n \"(`label`), optional helper paragraph, and stacks the children with \" +\n \"consistent spacing. Use INSTEAD of wrapping fields in `Card` + \" +\n \"`SectionHeader` by hand. Pair with `FieldSet` when the group is a \" +\n \"true `<fieldset>` (radio sets, checkbox groups).\",\n props: [\n { name: \"label\", type: \"string\", aliases: [\"title\"] },\n { name: \"children\", type: \"Node[]\", aliases: [\"fields\"] },\n { name: \"helper\", type: \"string\", optional: true, aliases: [\"description\"], description: \"Description rendered below the label\" },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"section\", { class: \"rui-form-section\" });\n const header = el(\"header\", { class: \"rui-form-section-header\" });\n header.append(el(\"h3\", { class: \"rui-form-section-label\" }, [asString(props.label)]));\n const helper = asString(props.helper);\n if (helper) header.append(el(\"p\", { class: \"rui-form-section-helper\" }, [helper]));\n root.append(header);\n const body = el(\"div\", { class: \"rui-form-section-body\" });\n for (const child of asArray(props.children)) body.append(helpers.renderNode(child));\n root.append(body);\n return root;\n },\n};\n\nexport const FieldSet: ComponentSpec = {\n name: \"FieldSet\",\n description:\n \"Native `<fieldset>`/`<legend>` wrapper for accessible grouping of \" +\n \"related controls. Use when assistive tech should announce the \" +\n \"wrapper (radio sets, checkbox groups). For purely visual grouping \" +\n \"prefer `FormSection`.\",\n props: [\n { name: \"legend\", type: \"string\", aliases: [\"title\", \"label\"] },\n { name: \"children\", type: \"Node[]\", aliases: [\"fields\"] },\n { name: \"helper\", type: \"string\", optional: true, aliases: [\"hint\", \"description\"] },\n { name: \"disabled\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"fieldset\", {\n class: \"rui-fieldset\",\n disabled: asBoolean(props.disabled) ? \"\" : null,\n });\n root.append(el(\"legend\", { class: \"rui-fieldset-legend\" }, [asString(props.legend)]));\n const helper = asString(props.helper);\n if (helper) root.append(el(\"p\", { class: \"rui-fieldset-helper\" }, [helper]));\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const ValidationSummary: ComponentSpec = {\n name: \"ValidationSummary\",\n description:\n \"Aggregate error list rendered at the top of a form. Pass `errors` \" +\n \"as `{label?, message, field?}` objects or plain strings. Pair with \" +\n \"individual field hints via `FormControl(hint=...)`.\",\n props: [\n { name: \"errors\", type: \"any[]\" },\n { name: \"title\", type: \"string\", optional: true, description: \"Heading (default \\\"Please fix the following:\\\")\" },\n { name: \"tone\", type: \"string\", optional: true, enum: [\"danger\", \"warning\"] },\n ],\n render: (_node, props) => {\n const errors = asArray<unknown>(props.errors)\n .map((entry) => {\n if (!entry) return null;\n if (typeof entry === \"string\") return { label: \"\", message: entry, field: \"\" };\n if (typeof entry === \"object\") {\n const r = entry as Record<string, unknown>;\n return {\n label: asString(r.label),\n message: asString(r.message ?? r.error),\n field: asString(r.field),\n };\n }\n return null;\n })\n .filter((e): e is { label: string; message: string; field: string } => e !== null && e.message !== \"\");\n if (errors.length === 0) {\n return el(\"div\", { class: \"rui-validation-summary\", \"data-empty\": \"true\", hidden: \"\" });\n }\n const tone = asString(props.tone, \"danger\");\n const root = el(\"aside\", {\n class: \"rui-validation-summary\",\n \"data-tone\": tone,\n role: \"alert\",\n });\n const titleNode = el(\"div\", { class: \"rui-validation-summary-title\" });\n const iconNode = renderIcon(tone === \"warning\" ? \"triangle-exclamation\" : \"circle-xmark\", { className: \"rui-validation-summary-icon\" });\n if (iconNode) titleNode.append(iconNode);\n titleNode.append(document.createTextNode(asString(props.title, \"Please fix the following:\")));\n root.append(titleNode);\n const list = el(\"ul\", { class: \"rui-validation-summary-list\" });\n for (const err of errors) {\n const li = el(\"li\", { class: \"rui-validation-summary-item\" });\n if (err.label) li.append(el(\"strong\", {}, [`${err.label}: `]));\n li.append(document.createTextNode(err.message));\n list.append(li);\n }\n root.append(list);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * MultiStepForm\n * ----------------------------------------------------------------------- */\n\ninterface MultiStepFormStep {\n title: string;\n details: string;\n content: unknown;\n}\n\nfunction readSteps(raw: unknown): MultiStepFormStep[] {\n return asArray<unknown>(raw).map((entry) => {\n if (!entry || typeof entry !== \"object\") {\n return { title: asString(entry), details: \"\", content: null };\n }\n const r = entry as Record<string, unknown>;\n return {\n title: asString(r.title),\n details: asString(r.details),\n content: r.content ?? null,\n };\n });\n}\n\nexport const MultiStepForm: ComponentSpec = {\n name: \"MultiStepForm\",\n description:\n \"Multi-step / wizard form composite. Renders a `Steps` indicator, \" +\n \"the active step's `content`, and Prev/Next buttons that drive a \" +\n \"`$variable` for the current 0-indexed step. Use INSTEAD of \" +\n \"hand-rolling `Steps` + content + manual prev/next wiring. The \" +\n \"submit button is rendered on the final step (override via \" +\n \"`submitLabel`). Step indicator direction defaults to `column` \" +\n \"(stacked next to the content); set `stepsLayout: \\\"row\\\"` for a \" +\n \"classic horizontal stepper.\",\n props: [\n { name: \"steps\", type: \"object[]\", description: \"Array of {title, details?, content} step objects\" },\n { name: \"current\", type: \"number\", description: \"0-indexed active step — bind a $variable\" },\n { name: \"onSubmit\", type: \"callable\", optional: true, description: \"Callable fired when the user clicks Submit on the final step\" },\n { name: \"prevLabel\", type: \"string\", optional: true, description: \"Default \\\"Back\\\"\" },\n { name: \"nextLabel\", type: \"string\", optional: true, description: \"Default \\\"Continue\\\"\" },\n { name: \"submitLabel\", type: \"string\", optional: true, description: \"Default \\\"Submit\\\" (final step)\" },\n { name: \"stepsLayout\", type: \"string\", optional: true, enum: [\"column\", \"row\"], aliases: [\"layout\", \"stepsDirection\"], description: \"Direction of the steps indicator (default \\\"column\\\")\" },\n ],\n render: (node, props, helpers) => {\n const steps = readSteps(props.steps);\n const total = steps.length;\n const current = Math.max(0, Math.min(total - 1, Math.floor(asNumber(props.current, 0))));\n const stateName = node.argMeta?.[1]?.stateRef;\n const layoutToken = asString(props.stepsLayout, \"column\").toLowerCase();\n const layout = layoutToken === \"row\" || layoutToken === \"horizontal\" ? \"row\" : \"column\";\n const root = el(\"div\", {\n class: \"rui-multi-step-form\",\n \"data-layout\": layout,\n });\n const stepsEl = el(\"ol\", {\n class: \"rui-steps rui-multi-step-form-steps\",\n \"data-layout\": layout,\n });\n steps.forEach((step, idx) => {\n const li = el(\"li\", {\n class: \"rui-steps-item\",\n \"data-active\": idx === current ? \"true\" : \"false\",\n \"data-complete\": idx < current ? \"true\" : \"false\",\n });\n li.append(el(\"div\", { class: \"rui-steps-title\" }, [step.title || `Step ${idx + 1}`]));\n if (step.details) li.append(el(\"div\", { class: \"rui-steps-details\" }, [step.details]));\n stepsEl.append(li);\n });\n root.append(stepsEl);\n const body = el(\"div\", { class: \"rui-multi-step-form-body\" });\n const active = steps[current];\n if (active && active.content) {\n body.append(helpers.renderNode(active.content));\n }\n root.append(body);\n const footer = el(\"div\", { class: \"rui-multi-step-form-footer\" });\n const prevBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-button\",\n \"data-variant\": \"ghost\",\n disabled: current <= 0 ? \"\" : null,\n }, [asString(props.prevLabel, \"Back\")]);\n if (stateName && current > 0) {\n prevBtn.onclick = () => helpers.setState(stateName, current - 1);\n }\n const isFinal = current >= total - 1;\n const nextLabel = isFinal ? asString(props.submitLabel, \"Submit\") : asString(props.nextLabel, \"Continue\");\n const nextBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-button\",\n \"data-variant\": \"primary\",\n }, [nextLabel]);\n nextBtn.onclick = () => {\n if (isFinal) {\n helpers.invoke(props.onSubmit);\n } else if (stateName) {\n helpers.setState(stateName, current + 1);\n }\n };\n footer.append(prevBtn);\n footer.append(el(\"span\", { class: \"rui-multi-step-form-progress\" }, [`${current + 1} / ${total}`]));\n footer.append(nextBtn);\n root.append(footer);\n return root;\n },\n};\n","/**\n * Advanced pattern composites that round out the catalogue:\n *\n * - InboxPanel — Grouped notification card list (read / unread).\n * - OnboardingChecklist — Step-by-step product checklist.\n * - LoadingState / ErrorState / SuccessState — Full-card status panels.\n * - Tour / Spotlight — Light-weight product-tour primitives.\n * - Sticky / Affix — Pin a child to the top while scrolling.\n * - ResizablePanels — Two-pane drag-to-resize split.\n * - MasonryGrid — Pinterest-style column grid.\n * - TopBar — Convenience composite.\n * - Drawer — Side-panel overlay (detail views, filters, previews).\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n sanitiseCssLength,\n} from \"../utils.js\";\nimport { Notification } from \"./patterns.js\";\n\n/* ----------------------------------------------------------------------- *\n * InboxPanel\n * ----------------------------------------------------------------------- */\n\ninterface InboxEntry {\n title: string;\n message: string;\n time: string;\n icon: string;\n tone: string;\n unread: boolean;\n avatarSrc: string;\n onClick: unknown;\n}\n\nfunction readInboxEntries(raw: unknown): InboxEntry[] {\n return asArray<unknown>(raw)\n .map((entry) => {\n if (!entry || typeof entry !== \"object\") return null;\n const r = entry as Record<string, unknown>;\n return {\n title: asString(r.title),\n message: asString(r.message),\n time: asString(r.time),\n icon: asString(r.icon),\n tone: asString(r.tone, \"default\"),\n unread: asBoolean(r.unread),\n avatarSrc: asString(r.avatarSrc),\n onClick: r.onClick ?? r.action,\n };\n })\n .filter((e): e is InboxEntry => e !== null);\n}\n\nexport const InboxPanel: ComponentSpec = {\n name: \"InboxPanel\",\n description:\n \"Grouped notification list — entries are grouped into Unread/Earlier \" +\n \"sections, with a count chip on each group header. Pass `items` as \" +\n \"`{title, message, time, icon?, tone?, unread?, avatarSrc?, onClick?}` \" +\n \"objects (`action` is also accepted as an alias). Pair with a `SectionHeader` for the panel title (the \" +\n \"component does not render its own title to avoid duplication). Use \" +\n \"for top-bar notification trays, activity drawers, and alert center \" +\n \"pages.\",\n props: [\n { name: \"items\", type: \"object[]\" },\n { name: \"emptyLabel\", type: \"string\", optional: true, description: \"Text shown when there are no notifications\" },\n { name: \"onMarkAllRead\", type: \"callable\", optional: true, description: \"Callable fired by the \\\"Mark all as read\\\" button\" },\n ],\n render: (_node, props, helpers) => {\n const entries = readInboxEntries(props.items);\n const unread = entries.filter((e) => e.unread);\n const read = entries.filter((e) => !e.unread);\n const root = el(\"div\", { class: \"rui-inbox-panel\" });\n if (typeof props.onMarkAllRead === \"function\" && unread.length > 0) {\n const toolbar = el(\"div\", { class: \"rui-inbox-panel-toolbar\" });\n const btn = el(\"button\", { type: \"button\", class: \"rui-inbox-panel-mark-all\" }, [\"Mark all as read\"]);\n btn.onclick = () => helpers.invoke(props.onMarkAllRead);\n toolbar.append(btn);\n root.append(toolbar);\n }\n if (entries.length === 0) {\n root.append(el(\"div\", { class: \"rui-inbox-panel-empty\" }, [asString(props.emptyLabel, \"You're all caught up.\")]));\n return root;\n }\n const renderGroup = (label: string, items: InboxEntry[]) => {\n if (items.length === 0) return;\n const group = el(\"section\", { class: \"rui-inbox-panel-group\" });\n const groupHead = el(\"header\", { class: \"rui-inbox-panel-group-head\" });\n groupHead.append(el(\"span\", { class: \"rui-inbox-panel-group-label\" }, [label]));\n groupHead.append(el(\"span\", { class: \"rui-inbox-panel-group-count\" }, [String(items.length)]));\n group.append(groupHead);\n for (const entry of items) {\n const card = Notification.render(\n { __kind: \"Component\", name: \"Notification\", args: [], argMeta: [] },\n {\n title: entry.title,\n message: entry.message,\n time: entry.time,\n icon: entry.icon,\n tone: entry.tone,\n avatarSrc: entry.avatarSrc,\n unread: entry.unread,\n },\n helpers,\n ) as HTMLElement;\n if (typeof entry.onClick === \"function\") {\n card.setAttribute(\"data-clickable\", \"true\");\n card.onclick = () => helpers.invoke(entry.onClick);\n }\n group.append(card);\n }\n root.append(group);\n };\n renderGroup(`Unread (${unread.length})`, unread);\n renderGroup(\"Earlier\", read);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * OnboardingChecklist\n * ----------------------------------------------------------------------- */\n\ninterface ChecklistItem {\n title: string;\n description: string;\n done: boolean;\n onClick: unknown;\n cta: string;\n}\n\nfunction readChecklistItems(raw: unknown): ChecklistItem[] {\n return asArray<unknown>(raw)\n .map((entry) => {\n if (!entry || typeof entry !== \"object\") return null;\n const r = entry as Record<string, unknown>;\n return {\n title: asString(r.title),\n description: asString(r.description),\n done: asBoolean(r.done),\n onClick: r.onClick ?? r.action,\n cta: asString(r.cta, \"Start\"),\n };\n })\n .filter((c): c is ChecklistItem => c !== null);\n}\n\nexport const OnboardingChecklist: ComponentSpec = {\n name: \"OnboardingChecklist\",\n description:\n \"Step-by-step product checklist with completion progress at the top. \" +\n \"Pass `items` as `{title, description?, done?, onClick?, cta?}` \" +\n \"objects (`action` is also accepted as an alias). The progress percentage is computed automatically from \" +\n \"`done`. Use on first-run dashboards, empty workspaces, and \" +\n \"\\\"complete your profile\\\" surfaces.\",\n props: [\n { name: \"items\", type: \"object[]\" },\n { name: \"title\", type: \"string\", optional: true, description: \"Heading (default \\\"Getting started\\\")\" },\n { name: \"subtitle\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const items = readChecklistItems(props.items);\n const completed = items.filter((i) => i.done).length;\n const total = Math.max(1, items.length);\n const pct = Math.round((completed / total) * 100);\n const root = el(\"div\", { class: \"rui-onboarding-checklist\" });\n const head = el(\"header\", { class: \"rui-onboarding-checklist-header\" });\n head.append(el(\"h3\", { class: \"rui-onboarding-checklist-title\" }, [\n asString(props.title, \"Getting started\"),\n ]));\n const subtitle = asString(props.subtitle);\n if (subtitle) head.append(el(\"p\", { class: \"rui-onboarding-checklist-subtitle\" }, [subtitle]));\n head.append(el(\"div\", { class: \"rui-onboarding-checklist-progress\" }, [\n el(\"div\", { class: \"rui-onboarding-checklist-bar\" }, [\n el(\"div\", {\n class: \"rui-onboarding-checklist-fill\",\n style: `width:${pct}%`,\n }),\n ]),\n el(\"span\", { class: \"rui-onboarding-checklist-meta\" }, [`${completed}/${items.length} complete`]),\n ]));\n root.append(head);\n const list = el(\"ol\", { class: \"rui-onboarding-checklist-list\" });\n for (const item of items) {\n const li = el(\"li\", {\n class: \"rui-onboarding-checklist-item\",\n \"data-done\": item.done ? \"true\" : \"false\",\n });\n const marker = el(\"span\", { class: \"rui-onboarding-checklist-marker\" });\n const iconNode = renderIcon(item.done ? \"circle-check\" : \"circle\", { className: \"rui-onboarding-checklist-marker-icon\" });\n if (iconNode) marker.append(iconNode);\n li.append(marker);\n const body = el(\"div\", { class: \"rui-onboarding-checklist-body\" });\n body.append(el(\"div\", { class: \"rui-onboarding-checklist-item-title\" }, [item.title]));\n if (item.description) body.append(el(\"p\", { class: \"rui-onboarding-checklist-item-description\" }, [item.description]));\n li.append(body);\n if (!item.done && typeof item.onClick === \"function\") {\n const btn = el(\"button\", {\n type: \"button\",\n class: \"rui-button\",\n \"data-variant\": \"secondary\",\n \"data-size\": \"sm\",\n }, [item.cta]);\n btn.onclick = () => helpers.invoke(item.onClick);\n li.append(btn);\n }\n list.append(li);\n }\n root.append(list);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * LoadingState / ErrorState / SuccessState\n * ----------------------------------------------------------------------- */\n\nfunction renderStateCard(opts: {\n klass: string;\n iconName: string;\n iconClass: string;\n title: string;\n description: string;\n actions: unknown;\n helpers: { renderNode: (n: unknown) => Node };\n}): HTMLElement {\n const root = el(\"div\", { class: `rui-${opts.klass}` });\n if (opts.iconName) {\n const icon = renderIcon(opts.iconName, { className: opts.iconClass });\n if (icon) root.append(icon);\n }\n if (opts.title) root.append(el(\"h3\", { class: `rui-${opts.klass}-title` }, [opts.title]));\n if (opts.description) root.append(el(\"p\", { class: `rui-${opts.klass}-description` }, [opts.description]));\n const items = asArray<unknown>(opts.actions);\n if (items.length > 0) {\n const row = el(\"div\", { class: `rui-${opts.klass}-actions` });\n for (const item of items) row.append(opts.helpers.renderNode(item));\n root.append(row);\n }\n return root;\n}\n\nexport const LoadingState: ComponentSpec = {\n name: \"LoadingState\",\n description:\n \"Full-card loading state — large spinner + title + description. Use \" +\n \"while a query is in flight or while a long-running tool runs. For \" +\n \"tiny inline loaders prefer `Spinner`; for skeleton placeholders \" +\n \"prefer `Skeleton`.\",\n props: [\n { name: \"title\", type: \"string\", optional: true, description: \"Default \\\"Loading…\\\"\" },\n { name: \"description\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const root = el(\"div\", { class: \"rui-loading-state\" });\n const spinner = el(\"span\", { class: \"rui-spinner\", \"data-size\": \"lg\", \"data-tone\": \"primary\" });\n spinner.append(el(\"span\", { class: \"rui-spinner-ring\", \"aria-hidden\": \"true\" }));\n root.append(spinner);\n root.append(el(\"h3\", { class: \"rui-loading-state-title\" }, [asString(props.title, \"Loading…\")]));\n const description = asString(props.description);\n if (description) root.append(el(\"p\", { class: \"rui-loading-state-description\" }, [description]));\n return root;\n },\n};\n\nexport const ErrorState: ComponentSpec = {\n name: \"ErrorState\",\n description:\n \"Full-card error placeholder. Pairs a danger icon with title, \" +\n \"description, and a row of recovery actions (Retry / Contact \" +\n \"support / Go home). Pass `actions` as Button(...) entries.\",\n props: [\n { name: \"title\", type: \"string\", optional: true, description: \"Default \\\"Something went wrong\\\"\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"actions\", type: \"Node[]\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Font Awesome icon (default `circle-exclamation`)\" },\n ],\n render: (_node, props, helpers) => renderStateCard({\n klass: \"error-state\",\n iconName: asString(props.icon, \"circle-exclamation\"),\n iconClass: \"rui-error-state-icon\",\n title: asString(props.title, \"Something went wrong\"),\n description: asString(props.description),\n actions: props.actions,\n helpers,\n }),\n};\n\nexport const SuccessState: ComponentSpec = {\n name: \"SuccessState\",\n description:\n \"Full-card success placeholder. Use for confirmation screens \" +\n \"(\\\"Order placed\\\", \\\"Payment succeeded\\\", \\\"Account verified\\\") at \" +\n \"the end of a flow. Pass `actions` for follow-up CTAs.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"actions\", type: \"Node[]\", optional: true },\n { name: \"icon\", type: \"string\", optional: true, description: \"Default `circle-check`\" },\n ],\n render: (_node, props, helpers) => renderStateCard({\n klass: \"success-state\",\n iconName: asString(props.icon, \"circle-check\"),\n iconClass: \"rui-success-state-icon\",\n title: asString(props.title),\n description: asString(props.description),\n actions: props.actions,\n helpers,\n }),\n};\n\n/* ----------------------------------------------------------------------- *\n * Tour / Spotlight\n * ----------------------------------------------------------------------- */\n\ninterface TourStep {\n title: string;\n description: string;\n target: string;\n}\n\nexport const Tour: ComponentSpec = {\n name: \"Tour\",\n description:\n \"Product-tour controller — renders the current step's title, \" +\n \"description, and a Prev/Next/Skip row. Bind `current` to a \" +\n \"`$variable` (0-indexed). Pass `steps` as `{title, description, \" +\n \"target?}` objects; the optional `target` is a CSS selector that \" +\n \"renders alongside the step for designers to reference.\",\n props: [\n { name: \"steps\", type: \"object[]\" },\n { name: \"current\", type: \"number\", description: \"0-indexed active step — bind a $variable\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Whether the tour is visible\" },\n { name: \"onComplete\", type: \"callable\", optional: true },\n ],\n render: (node, props, helpers) => {\n const steps: TourStep[] = asArray<unknown>(props.steps).map((entry) => {\n if (!entry || typeof entry !== \"object\") return { title: asString(entry), description: \"\", target: \"\" };\n const r = entry as Record<string, unknown>;\n return { title: asString(r.title), description: asString(r.description), target: asString(r.target) };\n });\n const isOpen = props.open === undefined ? true : asBoolean(props.open);\n const total = steps.length;\n const current = Math.max(0, Math.min(total - 1, Math.floor(asNumber(props.current, 0))));\n const stateName = node.argMeta?.[1]?.stateRef;\n const overlay = el(\"div\", { class: \"rui-tour\", \"data-open\": isOpen ? \"true\" : \"false\" });\n if (!isOpen || total === 0) return overlay;\n const step = steps[current];\n if (!step) return overlay;\n const card = el(\"div\", { class: \"rui-tour-card\", role: \"dialog\", \"aria-modal\": \"false\" });\n card.append(el(\"div\", { class: \"rui-tour-step\" }, [`Step ${current + 1} of ${total}`]));\n card.append(el(\"h3\", { class: \"rui-tour-title\" }, [step.title]));\n if (step.description) card.append(el(\"p\", { class: \"rui-tour-description\" }, [step.description]));\n if (step.target) card.append(el(\"div\", { class: \"rui-tour-target\" }, [`Target: ${step.target}`]));\n const footer = el(\"div\", { class: \"rui-tour-footer\" });\n const skip = el(\"button\", { type: \"button\", class: \"rui-button\", \"data-variant\": \"ghost\" }, [\"Skip\"]);\n skip.onclick = () => helpers.invoke(props.onComplete);\n const prev = el(\"button\", {\n type: \"button\",\n class: \"rui-button\",\n \"data-variant\": \"secondary\",\n disabled: current <= 0 ? \"\" : null,\n }, [\"Back\"]);\n if (stateName && current > 0) {\n prev.onclick = () => helpers.setState(stateName, current - 1);\n }\n const isLast = current >= total - 1;\n const next = el(\"button\", { type: \"button\", class: \"rui-button\", \"data-variant\": \"primary\" }, [isLast ? \"Finish\" : \"Next\"]);\n next.onclick = () => {\n if (isLast) {\n helpers.invoke(props.onComplete);\n } else if (stateName) {\n helpers.setState(stateName, current + 1);\n }\n };\n footer.append(skip, prev, next);\n card.append(footer);\n overlay.append(card);\n return overlay;\n },\n};\n\nexport const Spotlight: ComponentSpec = {\n name: \"Spotlight\",\n description:\n \"Single-step product highlight — a dimmed full-page overlay with a \" +\n \"ring around the focused area and a small explainer card. Use for \" +\n \"one-off feature reveals (\\\"Try the new commands menu\\\"). Bind \" +\n \"`open` to a `$variable` to dismiss.\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Whether the spotlight is visible — typically a $variable (default true)\" },\n { name: \"description\", type: \"string\", optional: true },\n { name: \"actions\", type: \"Node[]\", optional: true, aliases: [\"action\"] },\n ],\n render: (node, props, helpers) => {\n const isOpen = props.open === undefined ? true : asBoolean(props.open);\n const overlay = el(\"div\", { class: \"rui-spotlight\", \"data-open\": isOpen ? \"true\" : \"false\" });\n if (!isOpen) return overlay;\n const card = el(\"div\", { class: \"rui-spotlight-card\" });\n card.append(el(\"h3\", { class: \"rui-spotlight-title\" }, [asString(props.title)]));\n const description = asString(props.description);\n if (description) card.append(el(\"p\", { class: \"rui-spotlight-description\" }, [description]));\n const actions = asArray<unknown>(props.actions);\n if (actions.length > 0) {\n const row = el(\"div\", { class: \"rui-spotlight-actions\" });\n for (const item of actions) row.append(helpers.renderNode(item));\n card.append(row);\n }\n const stateName = node.argMeta?.[1]?.stateRef;\n if (stateName) {\n overlay.onclick = (event) => {\n if (event.target !== overlay) return;\n helpers.setState(stateName, false);\n };\n }\n overlay.append(card);\n return overlay;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Sticky / ResizablePanels / MasonryGrid / Drawer / TopBar\n * ----------------------------------------------------------------------- */\n\nexport const Sticky: ComponentSpec = {\n name: \"Sticky\",\n description:\n \"Wraps content in a `position: sticky` container so it pins to the \" +\n \"top (or bottom) of the nearest scrollable ancestor. Use for \" +\n \"toolbar action rows above tables, in-page navs, status banners.\",\n props: [\n { name: \"children\", type: \"Node[]\" },\n { name: \"side\", type: \"string\", optional: true, enum: [\"top\", \"bottom\"] },\n { name: \"offset\", type: \"string\", optional: true, description: \"CSS offset (default 0)\" },\n { name: \"zIndex\", type: \"number\", optional: true, description: \"Z-index (default 10)\" },\n ],\n render: (_node, props, helpers) => {\n const side = asString(props.side, \"top\");\n const offset = sanitiseCssLength(props.offset, \"0\");\n const z = Math.max(0, Math.floor(asNumber(props.zIndex, 10)));\n const styles = `position:sticky;${side}:${offset};z-index:${z};`;\n const root = el(\"div\", { class: \"rui-sticky\", style: styles });\n for (const child of asArray(props.children)) root.append(helpers.renderNode(child));\n return root;\n },\n};\n\nexport const ResizablePanels: ComponentSpec = {\n name: \"ResizablePanels\",\n description:\n \"Two-pane horizontal split with a draggable divider. The user can \" +\n \"drag the divider to resize the primary pane; defaults respect the \" +\n \"starting width. Use for code editors, file browsers, master/detail \" +\n \"layouts that need user-controllable proportions.\",\n props: [\n { name: \"primary\", type: \"Node[]\" },\n { name: \"secondary\", type: \"Node[]\" },\n { name: \"initialPrimaryWidth\", type: \"string\", optional: true, description: \"CSS width for the primary pane (default 40%)\" },\n { name: \"minPrimaryWidth\", type: \"string\", optional: true, description: \"Min width (default 240px)\" },\n ],\n render: (_node, props, helpers) => {\n const initial = sanitiseCssLength(props.initialPrimaryWidth, \"40%\");\n const minWidth = sanitiseCssLength(props.minPrimaryWidth, \"240px\");\n const root = el(\"div\", {\n class: \"rui-resizable-panels\",\n style: `--rui-resizable-primary:${initial};--rui-resizable-min:${minWidth};`,\n });\n const primary = el(\"div\", { class: \"rui-resizable-panel rui-resizable-panel-primary\" });\n for (const child of asArray(props.primary)) primary.append(helpers.renderNode(child));\n const divider = el(\"div\", {\n class: \"rui-resizable-divider\",\n role: \"separator\",\n \"aria-orientation\": \"vertical\",\n tabindex: \"0\",\n });\n const secondary = el(\"div\", { class: \"rui-resizable-panel rui-resizable-panel-secondary\" });\n for (const child of asArray(props.secondary)) secondary.append(helpers.renderNode(child));\n root.append(primary, divider, secondary);\n\n divider.onpointerdown = (event) => {\n const e = event as PointerEvent;\n const target = e.currentTarget as HTMLElement;\n target.setPointerCapture(e.pointerId);\n const live = target.closest(\".rui-resizable-panels\") as HTMLElement | null;\n if (!live) return;\n const rect = live.getBoundingClientRect();\n const onMove = (moveEvent: PointerEvent) => {\n const ratio = ((moveEvent.clientX - rect.left) / rect.width) * 100;\n const clamped = Math.max(15, Math.min(85, ratio));\n live.style.setProperty(\"--rui-resizable-primary\", `${clamped}%`);\n };\n const onUp = (upEvent: PointerEvent) => {\n target.releasePointerCapture(upEvent.pointerId);\n target.removeEventListener(\"pointermove\", onMove);\n target.removeEventListener(\"pointerup\", onUp);\n };\n target.addEventListener(\"pointermove\", onMove);\n target.addEventListener(\"pointerup\", onUp);\n };\n\n return root;\n },\n};\n\nexport const MasonryGrid: ComponentSpec = {\n name: \"MasonryGrid\",\n description:\n \"Pinterest-style column grid. Children flow into columns that reflow \" +\n \"on viewport changes. Use for galleries, social-style feeds, and \" +\n \"mixed-height card walls. Prefer `Grid` when children should share \" +\n \"the same height per row.\",\n props: [\n { name: \"items\", type: \"Node[]\" },\n { name: \"columns\", type: \"number\", optional: true, description: \"Preferred column count (default 3)\" },\n { name: \"gap\", type: \"string\", optional: true, enum: [\"xs\", \"s\", \"m\", \"l\", \"xl\"] },\n ],\n render: (_node, props, helpers) => {\n const columns = Math.max(1, Math.min(6, Math.floor(asNumber(props.columns, 3))));\n const gap = asString(props.gap, \"m\");\n const root = el(\"div\", {\n class: \"rui-masonry-grid\",\n \"data-columns\": String(columns),\n \"data-gap\": gap,\n });\n for (const item of asArray(props.items)) root.append(helpers.renderNode(item));\n return root;\n },\n};\n\nexport const Drawer: ComponentSpec = {\n name: \"Drawer\",\n description:\n \"Side drawer overlay shown when `open` is true. Pass a `$variable` as \" +\n \"`open` to control it. Choose `side` for slide direction (default right). \" +\n \"`onClose` fires whenever the drawer is dismissed (× button or \" +\n \"backdrop click).\",\n props: [\n { name: \"title\", type: \"string\" },\n { name: \"open\", type: \"boolean\", description: \"Open/closed state — usually a $variable\" },\n { name: \"children\", type: \"Node[]\" },\n { name: \"side\", type: \"string\", optional: true, enum: [\"right\", \"left\", \"top\", \"bottom\"] },\n { name: \"footer\", type: \"Node[]\", optional: true, description: \"Optional footer actions row\" },\n { name: \"onClose\", type: \"callable\", optional: true, aliases: [\"onclose\"], description: \"Callable invoked when the drawer is dismissed\" },\n ],\n render: (node, props, helpers) => {\n const isOpen = asBoolean(props.open);\n const side = asString(props.side, \"right\");\n const overlay = el(\"div\", {\n class: \"rui-sheet-overlay\",\n \"data-open\": isOpen ? \"true\" : \"false\",\n \"data-side\": side,\n });\n const panel = el(\"aside\", {\n class: \"rui-sheet\",\n role: \"dialog\",\n \"aria-modal\": \"true\",\n \"data-side\": side,\n });\n const header = el(\"header\", { class: \"rui-sheet-header\" });\n header.append(el(\"h3\", { class: \"rui-sheet-title\" }, [asString(props.title)]));\n const closeBtn = el(\"button\", {\n type: \"button\",\n class: \"rui-sheet-close\",\n \"aria-label\": \"Close\",\n }, [\"×\"]);\n const stateName = node.argMeta?.[1]?.stateRef;\n const closeDrawer = () => {\n if (stateName) helpers.setState(stateName, false);\n helpers.invoke(props.onClose);\n };\n closeBtn.onclick = closeDrawer;\n overlay.onclick = (event) => {\n if (event.target === overlay) closeDrawer();\n };\n header.append(closeBtn);\n panel.append(header);\n const body = el(\"div\", { class: \"rui-sheet-body\" });\n for (const child of asArray(props.children)) body.append(helpers.renderNode(child));\n panel.append(body);\n const footer = asArray<unknown>(props.footer);\n if (footer.length > 0) {\n const footerRow = el(\"footer\", { class: \"rui-sheet-footer\" });\n for (const child of footer) footerRow.append(helpers.renderNode(child));\n panel.append(footerRow);\n }\n overlay.append(panel);\n return overlay;\n },\n};\n\nexport const TopBar: ComponentSpec = {\n name: \"TopBar\",\n description:\n \"Compact header strip that pairs a title (or breadcrumb) with \" +\n \"search and action slots. Use INSTEAD of hand-rolling a \" +\n \"`Stack(direction=\\\"row\\\")` above a page. For full SaaS shells use \" +\n \"`Navbar` (links) or `AppShell` (sidebar + topbar + content).\",\n props: [\n { name: \"title\", type: \"string\", optional: true },\n { name: \"subtitle\", type: \"string\", optional: true },\n { name: \"left\", type: \"Node[]\", optional: true, aliases: [\"badges\"], description: \"Leading slot (breadcrumbs, brand, status, badges)\" },\n { name: \"center\", type: \"Node[]\", optional: true, aliases: [\"search\"], description: \"Centered slot (search bar, segmented control)\" },\n { name: \"right\", type: \"Node[]\", optional: true, aliases: [\"actions\"], description: \"Trailing slot (actions, avatar)\" },\n { name: \"sticky\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const root = el(\"header\", {\n class: \"rui-topbar\",\n \"data-sticky\": asBoolean(props.sticky) ? \"true\" : \"false\",\n });\n const left = el(\"div\", { class: \"rui-topbar-side rui-topbar-left\" });\n const title = asString(props.title);\n if (title) {\n const titleBlock = el(\"div\", { class: \"rui-topbar-title-block\" });\n titleBlock.append(el(\"h2\", { class: \"rui-topbar-title\" }, [title]));\n const subtitle = asString(props.subtitle);\n if (subtitle) titleBlock.append(el(\"p\", { class: \"rui-topbar-subtitle\" }, [subtitle]));\n left.append(titleBlock);\n }\n for (const child of asArray(props.left)) left.append(helpers.renderNode(child));\n root.append(left);\n const center = asArray<unknown>(props.center);\n if (center.length > 0) {\n const centerWrap = el(\"div\", { class: \"rui-topbar-side rui-topbar-center\" });\n for (const child of center) centerWrap.append(helpers.renderNode(child));\n root.append(centerWrap);\n }\n const right = el(\"div\", { class: \"rui-topbar-side rui-topbar-right\" });\n for (const child of asArray(props.right)) right.append(helpers.renderNode(child));\n root.append(right);\n return root;\n },\n};\n\n","/**\n * In-script theming component.\n *\n * `Theme({...})` is a meta-construct: the evaluator intercepts the call and\n * emits a `ThemeNode` instead of a regular `ComponentNode`. The element picks\n * the value up between render cycles and applies the tokens as CSS custom\n * properties on the host. This file exists so the prompt generator,\n * playground autocomplete, and the language server all know the signature.\n *\n * Authors write:\n *\n * theme = Theme({\n * colorPrimary: \"#0969da\",\n * fontFamily: \"'Inter', system-ui, sans-serif\",\n * radiusButton: \"6px\",\n * })\n * root = Stack([...])\n */\n\nimport type { ComponentSpec } from \"../types.js\";\n\nexport const Theme: ComponentSpec = {\n name: \"Theme\",\n description:\n \"Apply a partial theme on top of the base theme. Pass an object of token → value pairs (colors, fonts, radii, spacing, button styling). Assigning the result to a top-level binding (conventionally `theme`) lets the runtime detect it and write the tokens to the host as CSS custom properties — the rest of the rendered UI picks them up instantly.\",\n props: [\n {\n name: \"tokens\",\n type: \"any\",\n description:\n \"Object literal of theme tokens. Keys must match `ThemeTokens` (e.g. colorPrimary, colorBg, fontFamily, fontFamilyHeading, fontSizeBase, radiusMd, radiusButton, borderWidth, shadowMd, buttonFontWeight, …). Unknown keys are ignored.\",\n },\n ],\n // Theme(...) never produces UI — the evaluator captures it and short-\n // circuits before reaching this render fn. The no-op renderer is here so\n // the spec satisfies `ComponentSpec` for prompt / catalog generation.\n render: () => document.createDocumentFragment(),\n};\n","/**\n * Routing-related library components.\n *\n * In Aktion 0.5 routing is expressed with the\n * `Router({...})` call (see `src/runtime/router.ts` and the\n * `evaluateRouterCall` intercept in `runtime/evaluator.ts`). The legacy\n * `Routes(...)` outlet and `Route(...)` row components, and the\n * `$router = router { … }` block syntax, were removed in the 0.5\n * cleanup pass. The only routing-related component that still ships is\n * `NavLink`, which navigates via `helpers.router.navigate(to)`.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport { asBoolean, asString, el, renderIcon } from \"../utils.js\";\n\nexport const NavLink: ComponentSpec = {\n name: \"NavLink\",\n description:\n \"Anchor that navigates to a route on click and stays in sync with the URL hash. \" +\n \"Reflects `data-active=\\\"true\\\"` when the current path matches `to` (set `exact=true` \" +\n \"to require exact equality instead of prefix matching).\",\n props: [\n { name: \"label\", type: \"string\", description: \"Visible link text.\" },\n { name: \"to\", type: \"string\", description: \"Target route path, e.g. \\\"/about\\\".\" },\n {\n name: \"variant\",\n type: \"string\",\n optional: true,\n enum: [\"default\", \"primary\", \"ghost\", \"pill\"],\n description: \"Visual variant.\",\n },\n {\n name: \"exact\",\n type: \"boolean\",\n optional: true,\n description: \"Match the current path exactly (default: prefix match).\",\n },\n {\n name: \"icon\",\n type: \"string\",\n optional: true,\n description: \"Optional Font Awesome icon name shown before the label.\",\n },\n ],\n render: (_node, props, helpers) => {\n const label = asString(props.label, \"\");\n const to = asString(props.to, \"/\");\n const variant = asString(props.variant, \"default\");\n const exact = asBoolean(props.exact, false);\n const router = helpers.router;\n const currentPath = router.getPath();\n\n const isActive = (() => {\n if (!currentPath) return false;\n if (exact) return currentPath === to;\n if (to === \"/\") return currentPath === \"/\";\n if (currentPath === to) return true;\n return currentPath.startsWith(to + \"/\");\n })();\n\n const anchor = el(\"a\", {\n class: \"rui-nav-link\",\n \"data-variant\": variant,\n \"data-active\": isActive ? \"true\" : \"false\",\n href: \"#\" + (to.startsWith(\"/\") ? to : \"/\" + to),\n });\n\n const iconNode = renderIcon(props.icon, { className: \"rui-nav-link-icon\" });\n if (iconNode) anchor.append(iconNode);\n anchor.append(el(\"span\", { class: \"rui-nav-link-label\" }, [label]));\n\n anchor.onclick = (event) => {\n if (event.defaultPrevented) return;\n if (event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n router.navigate(to);\n };\n\n return anchor;\n },\n};\n","/**\n * Tier 1–3 components: IconButton, CommandPalette, FilterChips, FieldRepeater,\n * VirtualList, QueryBuilder, DiffViewer, JsonTree, Gantt, Truncate, InlineEdit,\n * NotificationBell.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, asBoolean, asNumber, renderIcon,\n} from \"../utils.js\";\nimport { installDismissListeners, disposeDismissListeners } from \"./_internal.js\";\n\nconst BUTTON_VARIANTS = [\"primary\", \"secondary\", \"ghost\", \"danger\"] as const;\nconst BUTTON_SIZES = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"small\", \"normal\", \"large\"] as const;\n\nfunction normaliseButtonSize(value: unknown): string {\n const v = asString(value).trim().toLowerCase();\n if (v === \"xs\" || v === \"extra-small\") return \"xs\";\n if (v === \"small\" || v === \"sm\") return \"sm\";\n if (v === \"large\" || v === \"lg\") return \"lg\";\n if (v === \"xl\" || v === \"extra-large\") return \"xl\";\n if (v === \"normal\" || v === \"md\" || v === \"\") return \"md\";\n if (v === \"xs\" || v === \"sm\" || v === \"md\" || v === \"lg\" || v === \"xl\") return v;\n return \"md\";\n}\n\nfunction readChipList(raw: unknown): Array<{ label: string; value: string }> {\n return asArray<unknown>(raw).map((entry) => {\n if (entry && typeof entry === \"object\") {\n const obj = entry as { label?: unknown; value?: unknown };\n const value = asString(obj.value ?? obj.label);\n return { value, label: asString(obj.label, value) };\n }\n const value = asString(entry);\n return { value, label: value };\n }).filter((c) => c.label !== \"\");\n}\n\nfunction readPlainObjects(raw: unknown): Record<string, unknown>[] {\n return asArray<unknown>(raw).filter(\n (e): e is Record<string, unknown> => !!e && typeof e === \"object\" && !Array.isArray(e),\n ) as Record<string, unknown>[];\n}\n\ntype CommandItem = { label: string; value: string; group?: string; shortcut?: string; action?: unknown };\n\nfunction readCommandItems(raw: unknown): CommandItem[] {\n return asArray<unknown>(raw).map((entry) => {\n if (entry && typeof entry === \"object\") {\n const obj = entry as CommandItem;\n const value = asString(obj.value ?? obj.label);\n return {\n value,\n label: asString(obj.label, value),\n group: asString(obj.group) || undefined,\n shortcut: asString(obj.shortcut) || undefined,\n action: obj.action,\n };\n }\n const value = asString(entry);\n return { value, label: value };\n }).filter((i) => i.label !== \"\");\n}\n\nfunction readFields(raw: unknown): Array<{ name: string; label: string; type?: string }> {\n return asArray<unknown>(raw).map((entry) => {\n if (entry && typeof entry === \"object\") {\n const obj = entry as { name?: unknown; label?: unknown; type?: unknown };\n const name = asString(obj.name ?? obj.label);\n return { name, label: asString(obj.label, name), type: asString(obj.type, \"text\") || \"text\" };\n }\n const name = asString(entry);\n return { name, label: name, type: \"text\" };\n }).filter((f) => f.name !== \"\");\n}\n\nfunction readGanttTasks(raw: unknown): Array<{\n id: string; label: string; start: string; end: string; progress?: number;\n}> {\n return readPlainObjects(raw).map((t, i) => ({\n id: asString(t.id, `task-${i}`),\n label: asString(t.label ?? t.name, `Task ${i + 1}`),\n start: asString(t.start),\n end: asString(t.end),\n progress: t.progress != null ? asNumber(t.progress, 0) : undefined,\n }));\n}\n\nfunction parseIsoDate(value: string): number {\n const t = Date.parse(value);\n return Number.isNaN(t) ? Date.now() : t;\n}\n\nfunction diffLines(left: string, right: string): Array<{ type: \"same\" | \"add\" | \"remove\"; text: string }> {\n const a = left.split(\"\\n\");\n const b = right.split(\"\\n\");\n const max = Math.max(a.length, b.length);\n const out: Array<{ type: \"same\" | \"add\" | \"remove\"; text: string }> = [];\n for (let i = 0; i < max; i++) {\n const la = a[i];\n const lb = b[i];\n if (la === lb) {\n if (la !== undefined) out.push({ type: \"same\", text: la });\n } else {\n if (la !== undefined) out.push({ type: \"remove\", text: la });\n if (lb !== undefined) out.push({ type: \"add\", text: lb });\n }\n }\n return out;\n}\n\nfunction jsonPreview(value: unknown): string {\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n\nfunction appendJsonChildren(\n container: HTMLElement,\n entries: ReadonlyArray<readonly [string, unknown]>,\n expanded: boolean,\n depth: number,\n): void {\n for (const [key, val] of entries) {\n const row = el(\"div\", { class: \"rui-json-tree-row\" });\n row.append(el(\"span\", { class: \"rui-json-tree-key\" }, [`${key}: `]));\n if (val !== null && typeof val === \"object\") {\n row.append(buildJsonTree(val, expanded, depth + 1));\n } else {\n row.append(el(\"span\", { class: \"rui-json-tree-leaf\" }, [jsonPreview(val)]));\n }\n container.append(row);\n }\n}\n\nfunction buildJsonTree(data: unknown, expanded: boolean, depth = 0): HTMLElement {\n const root = el(\"div\", { class: \"rui-json-tree-node\", \"data-depth\": String(depth) });\n if (data === null || typeof data !== \"object\") {\n root.append(el(\"span\", { class: \"rui-json-tree-leaf\" }, [jsonPreview(data)]));\n return root;\n }\n const isArray = Array.isArray(data);\n const entries = isArray\n ? (data as unknown[]).map((v, i) => [String(i), v] as const)\n : (Object.entries(data as Record<string, unknown>) as ReadonlyArray<readonly [string, unknown]>);\n const open = expanded || depth < 1;\n const toggle = el(\"button\", {\n type: \"button\",\n class: \"rui-json-tree-toggle\",\n \"aria-expanded\": open ? \"true\" : \"false\",\n }, [open ? \"▼\" : \"▶\", isArray ? ` Array(${entries.length})` : ` Object`]);\n const children = el(\"div\", { class: \"rui-json-tree-children\", \"data-open\": open ? \"true\" : \"false\" });\n if (open) appendJsonChildren(children, entries, expanded, depth);\n toggle.onclick = (event) => {\n // Walk to the live siblings — morph copies this handler onto the kept\n // toggle but the closure's `toggle`/`children` are detached.\n const liveToggle = event.currentTarget as HTMLElement;\n const liveChildren = liveToggle.nextElementSibling as HTMLElement | null;\n if (!liveChildren) return;\n const next = liveChildren.getAttribute(\"data-open\") !== \"true\";\n liveChildren.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n liveToggle.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n if (liveToggle.firstChild) liveToggle.firstChild.textContent = next ? \"▼\" : \"▶\";\n if (next && liveChildren.childElementCount === 0) {\n appendJsonChildren(liveChildren, entries, expanded, depth);\n } else if (!next) {\n // Collapse: drop the rendered rows so re-opening rebuilds them\n // against the latest data (and keeps the DOM small for big trees).\n liveChildren.replaceChildren();\n }\n };\n root.append(toggle, children);\n return root;\n}\n\n/* ----------------------------------------------------------------------- *\n * Tier 1\n * ----------------------------------------------------------------------- */\n\nexport const IconButton: ComponentSpec = {\n name: \"IconButton\",\n description:\n \"Icon-only button with an accessible label. Use for toolbars, table row actions, and compact controls.\",\n props: [\n { name: \"icon\", type: \"string\", description: \"Font Awesome icon name\" },\n { name: \"label\", type: \"string\", description: \"Accessible label (visually hidden)\" },\n { name: \"onClick\", type: \"callable\", optional: true, aliases: [\"action\", \"onclick\"] },\n { name: \"variant\", type: \"string\", optional: true, aliases: [\"tone\"], enum: BUTTON_VARIANTS },\n { name: \"size\", type: \"string\", optional: true, enum: BUTTON_SIZES },\n { name: \"disabled\", type: \"boolean\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const btn = el(\"button\", {\n class: \"rui-icon-button\",\n type: \"button\",\n \"data-variant\": asString(props.variant, \"ghost\"),\n \"data-size\": normaliseButtonSize(props.size),\n \"aria-label\": asString(props.label),\n title: asString(props.label),\n disabled: asBoolean(props.disabled) ? \"\" : null,\n });\n const iconNode = renderIcon(props.icon, { className: \"rui-icon-button-icon\" });\n if (iconNode) btn.append(iconNode);\n btn.onclick = () => helpers.invoke(props.onClick);\n return btn;\n },\n};\n\nexport const CommandPalette: ComponentSpec = {\n name: \"CommandPalette\",\n description:\n \"Cmd-K style searchable command list. Pass `items` as `{label, value, group?, shortcut?, action?}` objects.\",\n props: [\n { name: \"items\", type: \"any[]\" },\n { name: \"open\", type: \"boolean\", optional: true, description: \"Whether the palette is visible (default true)\" },\n { name: \"placeholder\", type: \"string\", optional: true },\n { name: \"shortcut\", type: \"string\", optional: true, description: \"Hint label, e.g. Cmd+K\" },\n ],\n render: (_node, props, helpers) => {\n const items = readCommandItems(props.items);\n // The palette is \"controlled\" whenever the script supplies an `open`\n // prop (so `open: $atom` updates the visibility on every change), and\n // \"uncontrolled\" otherwise (the internal slot tracks open/closed for\n // demo programs). When controlled, dismiss handlers still write to\n // the slot so the next host re-render keeps the visual state in sync\n // if the script also clears the bound atom.\n const propProvided = props.open !== undefined;\n const propOpen = propProvided ? asBoolean(props.open) : true;\n const openSlot = helpers.useInstanceState<boolean>(\"open\", propOpen);\n // Sync the slot to the latest prop value on every render so internal\n // dismiss handlers operate against the current \"open\" state.\n if (propProvided && openSlot.get() !== propOpen) openSlot.set(propOpen);\n const filterSlot = helpers.useInstanceState<string>(\"filter\", \"\");\n const isOpen = propProvided ? propOpen : openSlot.get();\n\n const host = el(\"div\", { class: \"rui-command-palette\", \"data-open\": isOpen ? \"true\" : \"false\" });\n if (!isOpen) return host;\n\n const backdrop = el(\"div\", { class: \"rui-command-palette-backdrop\" });\n const shell = el(\"div\", { class: \"rui-command-palette-panel\", role: \"dialog\", \"aria-modal\": \"true\" });\n const header = el(\"div\", { class: \"rui-command-palette-header\" });\n const search = el(\"input\", {\n type: \"text\",\n class: \"rui-command-palette-input\",\n placeholder: asString(props.placeholder, \"Search commands…\"),\n value: filterSlot.get(),\n autocomplete: \"off\",\n }) as HTMLInputElement;\n header.append(search);\n const shortcut = asString(props.shortcut);\n if (shortcut) header.append(el(\"span\", { class: \"rui-command-palette-shortcut\" }, [shortcut]));\n shell.append(header);\n\n const list = el(\"div\", { class: \"rui-command-palette-list\", role: \"listbox\" });\n const paintList = (target: HTMLElement, filter: string): void => {\n target.replaceChildren();\n const lower = filter.trim().toLowerCase();\n const matches = lower === \"\"\n ? items\n : items.filter((i) =>\n i.label.toLowerCase().includes(lower) ||\n i.value.toLowerCase().includes(lower) ||\n (i.group ?? \"\").toLowerCase().includes(lower),\n );\n let lastGroup = \"\";\n for (const item of matches.slice(0, 50)) {\n if (item.group && item.group !== lastGroup) {\n lastGroup = item.group;\n target.append(el(\"div\", { class: \"rui-command-palette-group\" }, [lastGroup]));\n }\n const row = el(\"button\", {\n type: \"button\",\n class: \"rui-command-palette-item\",\n role: \"option\",\n \"data-value\": item.value,\n }, [item.label]);\n if (item.shortcut) row.append(el(\"span\", { class: \"rui-command-palette-item-kbd\" }, [item.shortcut]));\n row.onclick = (event) => {\n event.stopPropagation();\n helpers.invoke(item.action);\n openSlot.set(false);\n filterSlot.set(\"\");\n const liveHost = (event.currentTarget as Element).closest(\".rui-command-palette\") as HTMLElement | null;\n const liveShell = liveHost?.querySelector(\".rui-command-palette-panel\") as HTMLElement | null;\n liveHost?.setAttribute(\"data-open\", \"false\");\n disposeDismissListeners(liveShell ?? null);\n };\n target.append(row);\n }\n if (matches.length === 0) {\n target.append(el(\"div\", { class: \"rui-command-palette-empty\" }, [\"No commands found\"]));\n }\n };\n paintList(list, filterSlot.get());\n shell.append(list);\n\n backdrop.onclick = (event) => {\n const liveHost = (event.currentTarget as Element).closest(\".rui-command-palette\") as HTMLElement | null;\n const liveShell = liveHost?.querySelector(\".rui-command-palette-panel\") as HTMLElement | null;\n openSlot.set(false);\n liveHost?.setAttribute(\"data-open\", \"false\");\n disposeDismissListeners(liveShell ?? null);\n };\n host.append(backdrop, shell);\n\n search.oninput = (event) => {\n const target = event.currentTarget as HTMLInputElement;\n const liveList = target.closest(\".rui-command-palette-panel\")\n ?.querySelector(\".rui-command-palette-list\") as HTMLElement | null;\n filterSlot.set(target.value);\n if (liveList) paintList(liveList, target.value);\n };\n search.onkeydown = (event) => {\n if ((event as KeyboardEvent).key === \"Escape\") {\n const liveHost = (event.currentTarget as Element).closest(\".rui-command-palette\") as HTMLElement | null;\n const liveShell = liveHost?.querySelector(\".rui-command-palette-panel\") as HTMLElement | null;\n openSlot.set(false);\n liveHost?.setAttribute(\"data-open\", \"false\");\n disposeDismissListeners(liveShell ?? null);\n }\n };\n setTimeout(() => search.focus(), 0);\n installDismissListeners({\n liveRoot: shell,\n key: \"command-palette\",\n onDismiss: () => {\n openSlot.set(false);\n host.setAttribute(\"data-open\", \"false\");\n },\n });\n return host;\n },\n};\n\nexport const FilterChips: ComponentSpec = {\n name: \"FilterChips\",\n description: \"Removable filter chips with an optional clear-all control.\",\n props: [\n { name: \"chips\", type: \"any[]\", description: \"Array of strings or {label, value} objects\" },\n { name: \"onRemove\", type: \"callable\", optional: true, description: \"Receives the removed chip value as an argument\" },\n { name: \"onClear\", type: \"callable\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const chips = readChipList(props.chips);\n const root = el(\"div\", { class: \"rui-filter-chips\" });\n const row = el(\"div\", { class: \"rui-filter-chips-row\" });\n for (const chip of chips) {\n const pill = el(\"span\", { class: \"rui-filter-chip\", \"data-value\": chip.value });\n pill.append(el(\"span\", { class: \"rui-filter-chip-label\" }, [chip.label]));\n const remove = el(\"button\", {\n type: \"button\",\n class: \"rui-filter-chip-remove\",\n \"aria-label\": `Remove ${chip.label}`,\n });\n const xIcon = renderIcon(\"xmark\", { className: \"rui-filter-chip-remove-icon\" });\n if (xIcon) remove.append(xIcon);\n remove.onclick = () => helpers.invoke(props.onRemove, chip.value);\n pill.append(remove);\n row.append(pill);\n }\n root.append(row);\n if (chips.length > 0 && typeof props.onClear === \"function\") {\n const clear = el(\"button\", { type: \"button\", class: \"rui-filter-chips-clear\" }, [\"Clear all\"]);\n clear.onclick = () => helpers.invoke(props.onClear);\n root.append(clear);\n }\n return root;\n },\n};\n\nexport const FieldRepeater: ComponentSpec = {\n name: \"FieldRepeater\",\n description:\n \"Dynamic list of field groups. Pass `items` as row objects and `fields` as `{name, label, type?}` definitions.\",\n props: [\n { name: \"items\", type: \"any[]\" },\n { name: \"fields\", type: \"any[]\" },\n { name: \"onAdd\", type: \"callable\", optional: true },\n { name: \"onRemove\", type: \"callable\", optional: true, description: \"Receives the removed row's 0-indexed position\" },\n { name: \"addLabel\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const rows = readPlainObjects(props.items);\n const fields = readFields(props.fields);\n const root = el(\"div\", { class: \"rui-field-repeater\" });\n rows.forEach((row, index) => {\n const card = el(\"div\", { class: \"rui-field-repeater-row\", \"data-index\": String(index) });\n const grid = el(\"div\", { class: \"rui-field-repeater-grid\" });\n for (const field of fields) {\n const wrap = el(\"label\", { class: \"rui-field-repeater-field\" });\n wrap.append(el(\"span\", { class: \"rui-field-repeater-label\" }, [field.label]));\n const input = el(\"input\", {\n class: \"rui-input\",\n type: field.type === \"number\" ? \"number\" : \"text\",\n name: `${field.name}-${index}`,\n value: asString(row[field.name]),\n readonly: \"\",\n });\n wrap.append(input);\n grid.append(wrap);\n }\n card.append(grid);\n if (typeof props.onRemove === \"function\") {\n const remove = el(\"button\", {\n type: \"button\",\n class: \"rui-field-repeater-remove\",\n \"aria-label\": \"Remove row\",\n }, [\"Remove\"]);\n remove.onclick = () => helpers.invoke(props.onRemove, index);\n card.append(remove);\n }\n root.append(card);\n });\n if (typeof props.onAdd === \"function\") {\n const add = el(\"button\", {\n type: \"button\",\n class: \"rui-field-repeater-add rui-button\",\n \"data-variant\": \"secondary\",\n }, [asString(props.addLabel, \"Add row\")]);\n add.onclick = () => helpers.invoke(props.onAdd);\n root.append(add);\n }\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Tier 2\n * ----------------------------------------------------------------------- */\n\nexport const VirtualList: ComponentSpec = {\n name: \"VirtualList\",\n description:\n \"Windowed vertical list for large datasets. Pass pre-rendered nodes as `items` \" +\n \"or plain row objects plus a `renderItem` component node per row.\",\n props: [\n { name: \"items\", type: \"any[]\" },\n { name: \"itemHeight\", type: \"number\", optional: true, description: \"Fixed row height in px (default 40)\" },\n { name: \"renderItem\", type: \"Node\", optional: true, description: \"Template node rendered per data row\" },\n ],\n render: (_node, props, helpers) => {\n const itemHeight = Math.max(24, asNumber(props.itemHeight, 40));\n const rawItems = asArray<unknown>(props.items);\n const viewport = el(\"div\", { class: \"rui-virtual-list\" });\n const scrollEl = el(\"div\", { class: \"rui-virtual-list-scroller\" });\n const spacer = el(\"div\", { class: \"rui-virtual-list-spacer\" });\n const windowEl = el(\"div\", { class: \"rui-virtual-list-window\" });\n\n const total = rawItems.length;\n spacer.style.height = `${total * itemHeight}px`;\n spacer.style.position = \"relative\";\n windowEl.style.position = \"absolute\";\n windowEl.style.top = \"0\";\n windowEl.style.left = \"0\";\n windowEl.style.right = \"0\";\n scrollEl.style.maxHeight = `${Math.min(Math.max(total, 1), 12) * itemHeight}px`;\n scrollEl.style.overflow = \"auto\";\n\n const renderSlice = (startIndex: number): void => {\n windowEl.replaceChildren();\n const viewHeight = scrollEl.clientHeight || itemHeight * 12;\n const visible = Math.ceil(viewHeight / itemHeight) + 2;\n const start = Math.max(0, startIndex);\n const end = Math.min(total, start + visible);\n windowEl.style.transform = `translateY(${start * itemHeight}px)`;\n for (let i = start; i < end; i++) {\n const entry = rawItems[i];\n if (props.renderItem) {\n windowEl.append(helpers.renderNode(entry ?? props.renderItem));\n } else if (entry && typeof entry === \"object\" && (entry as { __kind?: string }).__kind) {\n windowEl.append(helpers.renderNode(entry));\n } else {\n const row = el(\"div\", { class: \"rui-virtual-list-item\", style: `height:${itemHeight}px` });\n row.append(el(\"span\", {}, [asString(entry)]));\n windowEl.append(row);\n }\n }\n };\n\n scrollEl.onscroll = () => {\n const start = Math.floor(scrollEl.scrollTop / itemHeight);\n renderSlice(start);\n };\n renderSlice(0);\n scrollEl.append(spacer, windowEl);\n viewport.append(scrollEl);\n return viewport;\n },\n};\n\nexport const QueryBuilder: ComponentSpec = {\n name: \"QueryBuilder\",\n description:\n \"Visual filter builder. Pass `fields` as `{name, label, type?}` and bind `value` to a rule array.\",\n props: [\n { name: \"fields\", type: \"any[]\" },\n { name: \"value\", type: \"any[]\", optional: true },\n { name: \"onChange\", type: \"callable\", optional: true, description: \"Receives the next rule array\" },\n ],\n render: (node, props, helpers) => {\n const fields = readFields(props.fields);\n const rules = readPlainObjects(props.value);\n const stateRef = node.argMeta?.[1]?.stateRef;\n const root = el(\"div\", { class: \"rui-query-builder\" });\n\n const paint = (current: Record<string, unknown>[]): void => {\n root.replaceChildren();\n current.forEach((rule, index) => {\n const row = el(\"div\", { class: \"rui-query-builder-row\", \"data-index\": String(index) });\n const fieldSelect = el(\"select\", { class: \"rui-select rui-query-builder-field\" });\n for (const f of fields) {\n fieldSelect.append(el(\"option\", { value: f.name }, [f.label]));\n }\n fieldSelect.value = asString(rule.field ?? fields[0]?.name);\n const opSelect = el(\"select\", { class: \"rui-select rui-query-builder-op\" }, []);\n for (const op of [\"equals\", \"contains\", \"gt\", \"lt\"]) {\n opSelect.append(el(\"option\", { value: op }, [op]));\n }\n opSelect.value = asString(rule.op, \"equals\");\n const valueInput = el(\"input\", {\n class: \"rui-input rui-query-builder-value\",\n value: asString(rule.value),\n });\n row.append(fieldSelect, opSelect, valueInput);\n const remove = el(\"button\", { type: \"button\", class: \"rui-query-builder-remove\" }, [\"×\"]);\n remove.onclick = () => {\n const next = current.filter((_, i) => i !== index);\n if (stateRef) helpers.setState(stateRef, next);\n else helpers.invoke(props.onChange, next);\n paint(next);\n };\n row.append(remove);\n root.append(row);\n });\n const add = el(\"button\", { type: \"button\", class: \"rui-query-builder-add\" }, [\"Add rule\"]);\n add.onclick = () => {\n const next = [...current, { field: fields[0]?.name ?? \"\", op: \"equals\", value: \"\" }];\n if (stateRef) helpers.setState(stateRef, next);\n else helpers.invoke(props.onChange, next);\n paint(next);\n };\n root.append(add);\n };\n\n paint(rules.length > 0 ? rules : [{ field: fields[0]?.name ?? \"\", op: \"equals\", value: \"\" }]);\n return root;\n },\n};\n\nexport const DiffViewer: ComponentSpec = {\n name: \"DiffViewer\",\n description: \"Side-by-side or unified diff of two text blobs.\",\n props: [\n { name: \"left\", type: \"string\" },\n { name: \"right\", type: \"string\" },\n { name: \"mode\", type: \"string\", optional: true, enum: [\"split\", \"unified\"], description: \"Default split\" },\n ],\n render: (_node, props) => {\n const left = asString(props.left);\n const right = asString(props.right);\n const mode = asString(props.mode, \"split\");\n const root = el(\"div\", { class: \"rui-diff-viewer\", \"data-mode\": mode });\n\n if (mode === \"unified\") {\n const body = el(\"pre\", { class: \"rui-diff-viewer-unified\" });\n for (const line of diffLines(left, right)) {\n body.append(el(\"div\", { class: `rui-diff-line rui-diff-line-${line.type}` }, [\n (line.type === \"add\" ? \"+ \" : line.type === \"remove\" ? \"- \" : \" \") + line.text,\n ]));\n }\n root.append(body);\n return root;\n }\n\n const panes = el(\"div\", { class: \"rui-diff-viewer-panes\" });\n const leftPane = el(\"pre\", { class: \"rui-diff-viewer-pane rui-diff-viewer-left\" }, [left]);\n const rightPane = el(\"pre\", { class: \"rui-diff-viewer-pane rui-diff-viewer-right\" }, [right]);\n panes.append(leftPane, rightPane);\n root.append(panes);\n return root;\n },\n};\n\nexport const JsonTree: ComponentSpec = {\n name: \"JsonTree\",\n description: \"Expandable JSON tree viewer for objects and arrays.\",\n props: [\n { name: \"data\", type: \"any\" },\n { name: \"expanded\", type: \"boolean\", optional: true, description: \"Expand all nodes (default: first level only)\" },\n ],\n render: (_node, props) => {\n const root = el(\"div\", { class: \"rui-json-tree\" });\n root.append(buildJsonTree(props.data, asBoolean(props.expanded)));\n return root;\n },\n};\n\nexport const Gantt: ComponentSpec = {\n name: \"Gantt\",\n description:\n \"Simple Gantt chart. Pass `tasks` as `{id, label, start, end, progress?}` ISO date strings.\",\n props: [\n { name: \"tasks\", type: \"any[]\" },\n { name: \"startDate\", type: \"string\", optional: true },\n { name: \"endDate\", type: \"string\", optional: true },\n ],\n render: (_node, props) => {\n const tasks = readGanttTasks(props.tasks);\n const starts = tasks.map((t) => parseIsoDate(t.start));\n const ends = tasks.map((t) => parseIsoDate(t.end));\n const rangeStart = props.startDate\n ? parseIsoDate(asString(props.startDate))\n : (starts.length ? Math.min(...starts) : Date.now());\n const rangeEnd = props.endDate\n ? parseIsoDate(asString(props.endDate))\n : (ends.length ? Math.max(...ends) : rangeStart + 86_400_000);\n const span = Math.max(rangeEnd - rangeStart, 1);\n\n const root = el(\"div\", { class: \"rui-gantt\" });\n const track = el(\"div\", { class: \"rui-gantt-track\" });\n for (const task of tasks) {\n const row = el(\"div\", { class: \"rui-gantt-row\" });\n row.append(el(\"div\", { class: \"rui-gantt-label\" }, [task.label]));\n const barWrap = el(\"div\", { class: \"rui-gantt-bars\" });\n const startPct = ((parseIsoDate(task.start) - rangeStart) / span) * 100;\n const widthPct = Math.max(\n ((parseIsoDate(task.end) - parseIsoDate(task.start)) / span) * 100,\n 2,\n );\n const bar = el(\"div\", {\n class: \"rui-gantt-bar\",\n style: `left:${startPct}%;width:${widthPct}%`,\n title: `${task.start} → ${task.end}`,\n });\n if (task.progress != null) {\n bar.append(el(\"div\", {\n class: \"rui-gantt-bar-progress\",\n style: `width:${Math.min(100, Math.max(0, task.progress))}%`,\n }));\n }\n barWrap.append(bar);\n row.append(barWrap);\n track.append(row);\n }\n root.append(track);\n return root;\n },\n};\n\n/* ----------------------------------------------------------------------- *\n * Tier 3\n * ----------------------------------------------------------------------- */\n\nexport const Truncate: ComponentSpec = {\n name: \"Truncate\",\n description: \"Clamp long text with an expand control.\",\n props: [\n { name: \"text\", type: \"string\" },\n { name: \"maxLines\", type: \"number\", optional: true, description: \"Lines before clamping (default 3)\" },\n { name: \"expandLabel\", type: \"string\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const maxLines = Math.max(1, Math.floor(asNumber(props.maxLines, 3)));\n const expandedSlot = helpers.useInstanceState<boolean>(\"expanded\", false);\n const clampStyle = `display:-webkit-box;-webkit-line-clamp:${maxLines};-webkit-box-orient:vertical;overflow:hidden`;\n const root = el(\"div\", { class: \"rui-truncate\", \"data-expanded\": expandedSlot.get() ? \"true\" : \"false\" });\n const body = el(\"p\", {\n class: \"rui-truncate-text\",\n style: expandedSlot.get() ? \"\" : clampStyle,\n }, [asString(props.text)]);\n const toggle = el(\"button\", {\n type: \"button\",\n class: \"rui-truncate-toggle\",\n }, [expandedSlot.get() ? \"Show less\" : asString(props.expandLabel, \"Show more\")]);\n toggle.onclick = (event) => {\n // Walk to the live `.rui-truncate` root and find the live <p>; the\n // closure-captured nodes are detached once morph reuses the kept DOM.\n const liveToggle = event.currentTarget as HTMLElement;\n const liveRoot = liveToggle.closest(\".rui-truncate\") as HTMLElement | null;\n const liveBody = liveRoot?.querySelector(\".rui-truncate-text\") as HTMLElement | null;\n if (!liveRoot || !liveBody) return;\n const next = !expandedSlot.get();\n expandedSlot.set(next);\n liveBody.style.cssText = next ? \"\" : clampStyle;\n liveToggle.textContent = next ? \"Show less\" : asString(props.expandLabel, \"Show more\");\n liveRoot.setAttribute(\"data-expanded\", next ? \"true\" : \"false\");\n };\n root.append(body, toggle);\n return root;\n },\n};\n\nexport const InlineEdit: ComponentSpec = {\n name: \"InlineEdit\",\n description: \"Click-to-edit inline field with save on Enter or blur.\",\n props: [\n { name: \"value\", type: \"string\" },\n { name: \"label\", type: \"string\", optional: true },\n { name: \"onSave\", type: \"callable\", optional: true, description: \"Receives the committed draft string\" },\n ],\n render: (node, props, helpers) => {\n const editingSlot = helpers.useInstanceState<boolean>(\"editing\", false);\n const draftSlot = helpers.useInstanceState<string>(\"draft\", asString(props.value));\n const stateRef = node.argMeta?.[0]?.stateRef;\n const root = el(\"div\", { class: \"rui-inline-edit\", \"data-editing\": editingSlot.get() ? \"true\" : \"false\" });\n const label = asString(props.label);\n if (label) root.append(el(\"span\", { class: \"rui-inline-edit-label\" }, [label]));\n\n const display = el(\"button\", {\n type: \"button\",\n class: \"rui-inline-edit-display\",\n }, [asString(props.value)]);\n const input = el(\"input\", {\n class: \"rui-inline-edit-input rui-input\",\n value: draftSlot.get(),\n }) as HTMLInputElement;\n\n const resolveLive = (origin: Element): {\n root: HTMLElement; input: HTMLInputElement;\n } | null => {\n const liveRoot = origin.closest(\".rui-inline-edit\") as HTMLElement | null;\n const liveInput = liveRoot?.querySelector(\".rui-inline-edit-input\") as HTMLInputElement | null;\n if (!liveRoot || !liveInput) return null;\n return { root: liveRoot, input: liveInput };\n };\n\n const commit = (origin: Element): void => {\n const live = resolveLive(origin);\n editingSlot.set(false);\n live?.root.setAttribute(\"data-editing\", \"false\");\n const draft = draftSlot.get();\n if (stateRef) helpers.setState(stateRef, draft);\n helpers.invoke(props.onSave, draft);\n };\n\n display.onclick = (event) => {\n const live = resolveLive(event.currentTarget as Element);\n draftSlot.set(asString(props.value));\n editingSlot.set(true);\n if (live) {\n live.root.setAttribute(\"data-editing\", \"true\");\n live.input.value = draftSlot.get();\n setTimeout(() => live.input.focus(), 0);\n }\n };\n input.oninput = (event) => draftSlot.set((event.currentTarget as HTMLInputElement).value);\n input.onkeydown = (event) => {\n const kev = event as KeyboardEvent;\n if (kev.key === \"Enter\") commit(event.currentTarget as Element);\n if (kev.key === \"Escape\") {\n const live = resolveLive(event.currentTarget as Element);\n editingSlot.set(false);\n live?.root.setAttribute(\"data-editing\", \"false\");\n }\n };\n input.onblur = (event) => commit(event.currentTarget as Element);\n\n root.append(display, input);\n return root;\n },\n};\n\nexport const NotificationBell: ComponentSpec = {\n name: \"NotificationBell\",\n description: \"Bell icon with unread count badge and dropdown notification list.\",\n props: [\n { name: \"count\", type: \"number\", optional: true },\n { name: \"items\", type: \"any[]\", optional: true, description: \"{title, message?, time?} objects\" },\n { name: \"onOpen\", type: \"callable\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const count = Math.max(0, Math.floor(asNumber(props.count, 0)));\n const items = readPlainObjects(props.items);\n const openSlot = helpers.useInstanceState<boolean>(\"open\", false);\n const isOpen = openSlot.get();\n\n const root = el(\"div\", { class: \"rui-notification-bell\", \"data-open\": isOpen ? \"true\" : \"false\" });\n const trigger = el(\"button\", {\n type: \"button\",\n class: \"rui-notification-bell-trigger\",\n \"aria-expanded\": isOpen ? \"true\" : \"false\",\n \"aria-haspopup\": \"true\",\n });\n const bell = renderIcon(\"bell\", { className: \"rui-notification-bell-icon\" });\n if (bell) trigger.append(bell);\n if (count > 0) {\n trigger.append(el(\"span\", { class: \"rui-notification-bell-badge\" }, [\n count > 99 ? \"99+\" : String(count),\n ]));\n }\n root.append(trigger);\n\n const panel = el(\"div\", { class: \"rui-notification-bell-panel\", role: \"menu\" });\n if (items.length === 0) {\n panel.append(el(\"div\", { class: \"rui-notification-bell-empty\" }, [\"No notifications\"]));\n } else {\n for (const item of items) {\n const row = el(\"div\", { class: \"rui-notification-bell-item\" });\n row.append(el(\"div\", { class: \"rui-notification-bell-item-title\" }, [asString(item.title)]));\n const msg = asString(item.message);\n if (msg) row.append(el(\"div\", { class: \"rui-notification-bell-item-message\" }, [msg]));\n const time = asString(item.time);\n if (time) row.append(el(\"div\", { class: \"rui-notification-bell-item-time\" }, [time]));\n panel.append(row);\n }\n }\n root.append(panel);\n\n trigger.onclick = (event) => {\n event.stopPropagation();\n // Resolve the *live* DOM nodes from the event target so this\n // handler keeps working after the morph reconciler copies it onto\n // the kept DOM (the closure-captured `root`/`trigger` reference\n // the freshly-built fragment, which is detached after morph).\n const liveTrigger = event.currentTarget as HTMLElement;\n const liveRoot = liveTrigger.closest(\".rui-notification-bell\") as HTMLElement | null;\n if (!liveRoot) return;\n const next = !openSlot.get();\n openSlot.set(next);\n liveRoot.setAttribute(\"data-open\", next ? \"true\" : \"false\");\n liveTrigger.setAttribute(\"aria-expanded\", next ? \"true\" : \"false\");\n if (next) {\n helpers.invoke(props.onOpen);\n installDismissListeners({\n liveRoot,\n key: \"notification-bell\",\n onDismiss: () => {\n openSlot.set(false);\n liveRoot.setAttribute(\"data-open\", \"false\");\n liveTrigger.setAttribute(\"aria-expanded\", \"false\");\n },\n });\n } else {\n disposeDismissListeners(liveRoot);\n }\n };\n return root;\n },\n};\n","/**\n * Aktion 0.5 standard helper components.\n *\n * These are the \"frameworky\" features that ship as library components\n * rather than language constructs (per spec §24). Keeping them as\n * components keeps the language core small and the runtime tractable.\n *\n * - `Async(resource, loading:, error:, empty:, data:)` — branches on an\n * `$http({...})` resource state.\n * - `ErrorBoundary(fallback:, onError:, children)` — subtree error catcher.\n * - `Portal(target?, children)` — escape-hatch render to another DOM node.\n * - `Redirect(path)` — navigate then unmount. Recognised by the router.\n * - `Lazy(loader, fallback?)` — defer the children until `loader` resolves.\n * - `Show(when, fallback?, children)` — sugar over `if`.\n */\n\nimport type { ComponentSpec, RenderHelpers } from \"../types.js\";\nimport { el, asArray, asString } from \"../utils.js\";\n\nconst renderChild = (helpers: RenderHelpers, value: unknown): Node => {\n if (value == null) return document.createDocumentFragment();\n return helpers.renderNode(value);\n};\n\nconst isResourceShape = (\n value: unknown,\n): value is { state?: string; data?: unknown; error?: unknown; loading?: boolean } => {\n return Boolean(value && typeof value === \"object\");\n};\n\n/**\n * `Async(resource, loading:, error:, empty:, data:)` — render the\n * appropriate branch based on the resource's `state`. The resource is\n * expected to expose at least `{ state, data, error, loading }`.\n */\nexport const Async: ComponentSpec = {\n name: \"Async\",\n description:\n \"Render `loading`, `error`, `empty`, or `data` slot based on an `$http({...})` resource's state.\",\n props: [\n { name: \"resource\", type: \"any\", positional: true, required: true },\n { name: \"loading\", type: \"Node\", optional: true },\n { name: \"error\", type: \"Node\", optional: true },\n { name: \"empty\", type: \"Node\", optional: true },\n { name: \"data\", type: \"Node\", optional: true },\n ],\n render: (_node, props, helpers) => {\n const resource = props.resource;\n const slots = {\n loading: props.loading,\n error: props.error,\n empty: props.empty,\n data: props.data,\n };\n if (!isResourceShape(resource)) {\n return renderChild(helpers, slots.empty ?? slots.data ?? null);\n }\n const state = (resource as { state?: string }).state;\n if (state === \"loading\" || (resource as { loading?: boolean }).loading) {\n return renderChild(helpers, slots.loading ?? null);\n }\n if (state === \"error\" || (resource as { error?: unknown }).error) {\n return renderChild(helpers, slots.error ?? null);\n }\n const data = (resource as { data?: unknown }).data;\n if (data === undefined || data === null || (Array.isArray(data) && data.length === 0)) {\n return renderChild(helpers, slots.empty ?? slots.data ?? null);\n }\n return renderChild(helpers, slots.data ?? null);\n },\n};\n\n/**\n * `Show(when, fallback?, children)` — sugar over `if`. Renders `children`\n * when `when` is truthy; falls back to `fallback` (or nothing) otherwise.\n */\nexport const Show: ComponentSpec = {\n name: \"Show\",\n description: \"Conditional renderer. Sugar over `if expr { children } else { fallback }`.\",\n props: [\n { name: \"when\", type: \"any\", positional: true, required: true },\n { name: \"fallback\", type: \"Node\", optional: true },\n { name: \"children\", type: \"Node[]\", optional: true },\n ],\n render: (_node, props, helpers) => {\n if (props.when) {\n return renderChild(helpers, props.children ?? null);\n }\n return renderChild(helpers, props.fallback ?? null);\n },\n};\n\n/**\n * `Portal(target?, children)` — render `children` outside the normal\n * subtree. `target` accepts a CSS selector; falls back to `document.body`.\n */\nexport const Portal: ComponentSpec = {\n name: \"Portal\",\n description: \"Render children outside the parent subtree (e.g. into document.body).\",\n props: [\n { name: \"target\", type: \"string\", optional: true },\n { name: \"children\", type: \"Node[]\", positional: true },\n ],\n render: (_node, props, helpers) => {\n const target = asString(props.target);\n let mount: Element | null = null;\n if (target) {\n try {\n mount = document.querySelector(target);\n } catch {\n mount = null;\n }\n }\n if (!mount) mount = document.body;\n const container = el(\"div\", { class: \"rui-portal\" });\n for (const child of asArray(props.children)) {\n container.append(helpers.renderNode(child));\n }\n if (mount) {\n mount.append(container);\n // Schedule removal on next render — the renderer owns the lifecycle.\n helpers.registerDisposer(() => {\n if (container.parentNode) container.parentNode.removeChild(container);\n });\n }\n // Render an empty placeholder in the original position so morph\n // diffing keeps a stable node identity.\n return el(\"span\", { class: \"rui-portal-anchor\", \"data-portal\": target ?? \"body\" });\n },\n};\n\n/**\n * `Redirect(path)` — Issued by a route guard component. The runtime\n * recognises the rendered output and redirects the router immediately.\n */\nexport const Redirect: ComponentSpec = {\n name: \"Redirect\",\n description: \"Navigate to `path` and unmount the rest of the subtree.\",\n props: [\n { name: \"path\", type: \"string\", positional: true, required: true },\n ],\n render: (_node, props, helpers) => {\n const path = asString(props.path);\n if (path) {\n try {\n helpers.router.navigate(path);\n } catch {\n // Router may be unavailable (SSR); fall through to no-op.\n }\n }\n return el(\"span\", { class: \"rui-redirect\", \"data-path\": path, hidden: \"true\" });\n },\n};\n\n/**\n * `Lazy(loader, fallback?)` — Defer the children until the `loader`\n * promise resolves. The `loader` can be either a function returning a\n * promise or a promise directly.\n */\nexport const Lazy: ComponentSpec = {\n name: \"Lazy\",\n description: \"Defer rendering `children` until `loader` resolves.\",\n props: [\n { name: \"loader\", type: \"any\", positional: true, required: true },\n { name: \"fallback\", type: \"Node\", optional: true },\n { name: \"children\", type: \"Node[]\", optional: true },\n ],\n render: (_node, props, helpers) => {\n // Best-effort static rendering: invoke the loader if it's a function;\n // if it returns a promise, render the fallback. The full streaming\n // resolution belongs to the runtime — see status file §24.\n const loader = props.loader;\n if (typeof loader === \"function\") {\n try {\n const result = (loader as () => unknown)();\n if (result && typeof (result as { then?: unknown }).then === \"function\") {\n return renderChild(helpers, props.fallback ?? null);\n }\n return renderChild(helpers, result ?? props.children ?? null);\n } catch {\n return renderChild(helpers, props.fallback ?? null);\n }\n }\n return renderChild(helpers, props.children ?? null);\n },\n};\n\n/**\n * `ErrorBoundary(fallback?, onError?, children)` — catches rendering\n * errors raised by descendants and renders the fallback instead.\n */\nexport const ErrorBoundary: ComponentSpec = {\n name: \"ErrorBoundary\",\n description: \"Render a fallback subtree when rendering children throws.\",\n props: [\n { name: \"fallback\", type: \"Node\", optional: true },\n { name: \"onError\", type: \"callable\", optional: true },\n { name: \"children\", type: \"Node[]\", positional: true },\n ],\n render: (_node, props, helpers) => {\n const wrapper = el(\"div\", { class: \"rui-error-boundary\" });\n try {\n for (const child of asArray(props.children)) {\n wrapper.append(helpers.renderNode(child));\n }\n return wrapper;\n } catch (err) {\n try { helpers.invoke(props.onError, err); } catch { /* swallow */ }\n const fallback = renderChild(helpers, props.fallback ?? null);\n const errorWrapper = el(\"div\", { class: \"rui-error-boundary rui-error-boundary--fallback\" });\n errorWrapper.append(fallback);\n // Surface the error message in a hidden attribute for diagnostics.\n errorWrapper.setAttribute(\"data-error\", err instanceof Error ? err.message : String(err));\n return errorWrapper;\n }\n },\n};\n\n","/**\n * Escape-hatch components — `HTMLTag` renders an arbitrary allow-listed HTML\n * tag (with attributes and children), and `Styles` renders a scoped\n * `<style>` block. Both exist for the rare case where the standard\n * component catalogue cannot express what the author needs (custom layout,\n * embedded SVG, third-party widget container, etc.).\n *\n * Both components run aggressive sanitisation so an LLM-supplied tag name,\n * attribute, or stylesheet cannot smuggle script execution into the page.\n */\n\nimport type { ComponentSpec } from \"../types.js\";\nimport {\n el, asArray, asString, sanitiseHref, sanitiseImageSrc,\n} from \"../utils.js\";\n\n/**\n * Tags `HTMLTag` will render. Anything outside this set falls back to a\n * `<div>` so a hostile / typo'd LLM response never lands a `<script>` or\n * top-level document tag in the DOM. The list is intentionally broad —\n * structural, text, table, media, and form primitives — so authors can\n * compose almost anything HTML supports without raw `innerHTML` access.\n *\n * SVG / MathML are intentionally excluded: their namespaces require a\n * different `createElement` path. Authors who need vector graphics\n * should reach for `Image` / `Icon` instead.\n */\nconst ALLOWED_TAGS = new Set<string>([\n \"div\", \"span\", \"p\", \"section\", \"article\", \"header\", \"footer\", \"main\",\n \"nav\", \"aside\", \"figure\", \"figcaption\", \"details\", \"summary\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\",\n \"ul\", \"ol\", \"li\", \"dl\", \"dt\", \"dd\",\n \"table\", \"thead\", \"tbody\", \"tfoot\", \"tr\", \"td\", \"th\", \"caption\",\n \"colgroup\", \"col\",\n \"a\", \"img\", \"picture\", \"source\", \"video\", \"audio\", \"track\",\n \"small\", \"strong\", \"em\", \"b\", \"i\", \"u\", \"s\", \"mark\", \"code\", \"pre\",\n \"kbd\", \"samp\", \"var\", \"sub\", \"sup\", \"abbr\", \"cite\", \"blockquote\", \"q\",\n \"time\", \"address\", \"ins\", \"del\", \"ruby\", \"rt\", \"rp\", \"bdi\", \"bdo\",\n \"br\", \"hr\", \"wbr\", \"hgroup\",\n \"label\", \"fieldset\", \"legend\", \"progress\", \"meter\", \"output\",\n]);\n\n/**\n * Attribute name matcher. Accepts standard HTML attributes plus\n * `data-*` / `aria-*`. Forbids `on*` event handlers and any name that\n * contains characters which could break out of the attribute boundary.\n */\nconst ATTR_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_:-]*$/;\n\n/**\n * Attribute names that may carry URL-shaped values. We funnel them through\n * `sanitiseHref` / `sanitiseImageSrc` so a `javascript:` payload from an\n * LLM response can never land on a clickable / loadable surface.\n */\nconst URL_ATTRS_HREF = new Set([\"href\", \"ping\", \"action\", \"formaction\"]);\nconst URL_ATTRS_SRC = new Set([\"src\", \"poster\"]);\n\n/**\n * Inline `style` attribute sanitiser. Mirrors the rules used by `Text`'s\n * `style` prop — block angle brackets, `expression()`, `javascript:`,\n * `behavior:`, and `@import`. Returns the empty string when the value is\n * rejected so the caller can drop the attribute entirely.\n */\nfunction sanitiseInlineStyleAttr(value: unknown): string {\n const raw = asString(value).trim();\n if (!raw) return \"\";\n if (/[<>]/.test(raw)) return \"\";\n if (/\\bexpression\\s*\\(|\\bjavascript\\s*:|\\bbehavior\\s*:|@import\\b/i.test(raw)) return \"\";\n return raw;\n}\n\n/**\n * Coerce a tag name into a safe lower-case token. Falls back to `div` for\n * anything outside the allow-list so the rendered DOM is always\n * predictable.\n */\nfunction resolveTagName(input: unknown): string {\n const name = asString(input).trim().toLowerCase();\n if (!name) return \"div\";\n if (!ALLOWED_TAGS.has(name)) return \"div\";\n return name;\n}\n\n/**\n * Build the attribute object the DOM should receive. We keep the shape\n * small (string values only) so the existing `el(tag, attrs, children)`\n * helper can apply them via `setAttribute` — bypassing innerHTML and the\n * \"boolean attribute\" coercion path that would otherwise let a `false`\n * value slip onto the DOM as the literal string `\"false\"`.\n */\nfunction buildAttrs(input: unknown): Record<string, string> {\n if (!input || typeof input !== \"object\" || Array.isArray(input)) return {};\n const out: Record<string, string> = {};\n for (const [rawKey, rawValue] of Object.entries(input as Record<string, unknown>)) {\n const key = rawKey.trim();\n if (!key) continue;\n if (!ATTR_NAME_RE.test(key)) continue;\n const lower = key.toLowerCase();\n if (lower.startsWith(\"on\")) continue;\n if (rawValue === null || rawValue === undefined || rawValue === false) continue;\n\n if (lower === \"style\") {\n const style = sanitiseInlineStyleAttr(rawValue);\n if (style) out.style = style;\n continue;\n }\n if (URL_ATTRS_HREF.has(lower)) {\n const safe = sanitiseHref(rawValue, \"\");\n if (safe) out[key] = safe;\n continue;\n }\n if (URL_ATTRS_SRC.has(lower)) {\n const safe = sanitiseImageSrc(rawValue);\n if (safe) out[key] = safe;\n continue;\n }\n out[key] = rawValue === true ? \"\" : asString(rawValue);\n }\n return out;\n}\n\nexport const HTMLTag: ComponentSpec = {\n name: \"HTMLTag\",\n description:\n \"Escape-hatch primitive that renders an allow-listed HTML tag with \" +\n \"the given attributes and children. Use ONLY when the standard \" +\n \"component catalogue cannot express the markup (custom semantic \" +\n \"elements, inline SVG, third-party widget mounts). Tag names outside \" +\n \"the allow-list collapse to `div`. Attribute names matching `on*` \" +\n \"(event handlers) are dropped, `href`/`src` are sanitised, and \" +\n \"`style` is filtered for `expression()` / `javascript:` / `@import`. \" +\n \"Pass children as an array of components — strings render as text \" +\n \"nodes.\",\n props: [\n { name: \"tag\", type: \"string\", positional: true, required: true, description: \"HTML tag name (e.g. \\\"div\\\", \\\"section\\\", \\\"svg\\\"). Falls back to `div` when outside the allow-list.\" },\n { name: \"attributes\", type: \"object\", optional: true, aliases: [\"attrs\", \"props\"], description: \"Plain object of attribute name → value pairs (e.g. `{ class: \\\"hero\\\", \\\"data-id\\\": 1 }`). `on*` handlers are dropped.\" },\n { name: \"children\", type: \"Node[]\", optional: true, description: \"Child components or text nodes to render inside the tag.\" },\n ],\n render: (_node, props, helpers) => {\n const tag = resolveTagName(props.tag);\n const attrs = buildAttrs(props.attributes);\n const root = el(tag as keyof HTMLElementTagNameMap, attrs);\n for (const child of asArray<unknown>(props.children)) {\n if (child === null || child === undefined) continue;\n if (typeof child === \"string\") {\n root.append(document.createTextNode(child));\n continue;\n }\n if (typeof child === \"number\" || typeof child === \"boolean\") {\n root.append(document.createTextNode(String(child)));\n continue;\n }\n root.append(helpers.renderNode(child));\n }\n return root;\n },\n};\n\n/**\n * Strip CSS payloads that would break out of a `<style>` element or\n * execute script in legacy browsers. We do not parse the stylesheet —\n * that would balloon the runtime — so the rules below are a defensive\n * subset:\n *\n * - Reject anything containing `</style` so a malicious payload cannot\n * close the tag and inject HTML/JS afterwards.\n * - Reject `expression(`, `javascript:`, `behavior:`, `@import`, and\n * `<script` so common XSS shapes never reach the DOM.\n * - Drop the value when it exceeds a generous safety cap so a runaway\n * paste cannot block the render thread.\n */\nconst STYLES_BLOCK_RE = /<\\/style|<script|expression\\s*\\(|javascript\\s*:|behavior\\s*:|@import\\b/i;\nconst STYLES_MAX_LENGTH = 64 * 1024;\n\nfunction sanitiseStyleSheet(input: unknown): string {\n const raw = asString(input);\n if (!raw) return \"\";\n if (raw.length > STYLES_MAX_LENGTH) return \"\";\n if (STYLES_BLOCK_RE.test(raw)) return \"\";\n return raw;\n}\n\nexport const Styles: ComponentSpec = {\n name: \"Styles\",\n description:\n \"Escape-hatch primitive that injects a `<style>` block containing the \" +\n \"given CSS rules. Use ONLY when a layout cannot be expressed via \" +\n \"component props or the `$theme(...)` token map. The CSS is rendered \" +\n \"verbatim into the document so authors can target their own \" +\n \"`HTMLTag` markup or scope rules to a wrapper class. Payloads \" +\n \"containing `</style>`, `<script>`, `expression(`, `javascript:`, \" +\n \"`behavior:`, or `@import` are dropped for safety.\",\n props: [\n { name: \"css\", type: \"string\", positional: true, required: true, aliases: [\"content\", \"rules\"], description: \"Raw CSS text (e.g. `\\\".hero { color: red; }\\\"`).\" },\n ],\n render: (_node, props) => {\n const css = sanitiseStyleSheet(props.css);\n const node = document.createElement(\"style\");\n node.setAttribute(\"class\", \"rui-styles\");\n if (css) node.textContent = css;\n return node;\n },\n};\n","import type { ComponentLibrary, ComponentSpec } from \"./types.js\";\n\n/**\n * Cache of Map<name, spec> indexes keyed by the `components` array reference.\n * Lets `findComponent` run in O(1) while still treating libraries as\n * immutable arrays — when the library is replaced (e.g. after\n * `registerComponents`), the new array gets its own index automatically.\n */\nconst indexCache = new WeakMap<ReadonlyArray<ComponentSpec>, Map<string, ComponentSpec>>();\n\nfunction getIndex(library: ComponentLibrary): Map<string, ComponentSpec> {\n let index = indexCache.get(library.components);\n if (!index) {\n index = new Map();\n for (const spec of library.components) {\n if (spec?.name) index.set(spec.name, spec);\n }\n indexCache.set(library.components, index);\n }\n return index;\n}\n\n/**\n * Combines two libraries by name. Components from `extra` win on collision.\n * Useful when a consumer registers their own components alongside the\n * built-ins via `<aktion-app>.registerComponents([...])`.\n */\nexport function mergeLibraries(\n base: ComponentLibrary,\n extra: { components: ReadonlyArray<ComponentSpec>; root?: string },\n): ComponentLibrary {\n const map = new Map<string, ComponentSpec>();\n for (const c of base.components) map.set(c.name, c);\n for (const c of extra.components) map.set(c.name, c);\n return {\n root: extra.root ?? base.root,\n components: [...map.values()],\n componentGroups: base.componentGroups,\n };\n}\n\n/**\n * Resolve a component spec by name. O(1) thanks to the lazily-built index\n * cached against the library's `components` array.\n */\nexport function findComponent(library: ComponentLibrary, name: string): ComponentSpec | undefined {\n return getIndex(library).get(name);\n}\n","/**\n * Tokenizer for Aktion.\n *\n * The surface syntax is a strict subset of JavaScript. We tokenize into a\n * flat stream of tokens including NEWLINE markers so that the parser can\n * recover at line boundaries.\n */\n\nexport type TokenType =\n | \"Identifier\"\n | \"Keyword\"\n | \"StateIdentifier\"\n | \"Number\"\n | \"String\"\n /**\n * Backtick-quoted template literal — carries alternating raw chunks and\n * embedded expression source strings via `parts`.\n */\n | \"TemplateString\"\n | \"Boolean\"\n | \"Null\"\n | \"Punctuation\"\n | \"Operator\"\n | \"Newline\"\n | \"Semicolon\"\n | \"EOF\";\n\n/**\n * Keywords reserved by Aktion. The lexer recognises them so the parser can\n * dispatch on `Keyword` tokens directly.\n */\nexport const KEYWORDS_AKTION = new Set([\n \"function\",\n // Module syntax for multi-file `.aktion` programs (resolved at build time by\n // the compiler/linker; a no-op for the streaming runtime). `from`/`as` are\n // NOT keywords — they stay usable as ordinary identifiers and are matched\n // contextually by the import parser.\n \"import\",\n \"export\",\n // NOTE: `$effect` (the side-effect builtin) is `$`-prefixed, so it lexes as\n // a StateIdentifier and is recognised in the parser — it is NOT a keyword.\n \"if\",\n \"else\",\n \"switch\",\n \"case\",\n \"break\",\n \"continue\",\n \"for\",\n \"while\",\n \"do\",\n \"of\",\n \"in\",\n \"let\",\n \"var\",\n \"const\",\n \"await\",\n \"async\",\n \"return\",\n \"default\",\n \"try\",\n \"catch\",\n \"finally\",\n \"throw\",\n \"new\",\n \"typeof\",\n \"instanceof\",\n \"delete\",\n \"void\",\n]);\n\nexport type TemplatePart =\n | { kind: \"str\"; text: string }\n | { kind: \"expr\"; source: string; line: number; column: number };\n\nexport interface Token {\n type: TokenType;\n value: string;\n line: number;\n column: number;\n /** Set on `TemplateString` tokens to carry the alternating parts. */\n parts?: TemplatePart[];\n}\n\nconst SINGLE_CHAR_PUNCT = new Set([\"(\", \")\", \"[\", \"]\", \"{\", \"}\", \",\", \":\", \"?\", \".\"]);\nconst KEYWORDS: Record<string, TokenType> = {\n true: \"Boolean\",\n false: \"Boolean\",\n null: \"Null\",\n};\n\nexport function tokenize(source: string): Token[] {\n const tokens: Token[] = [];\n let i = 0;\n let line = 1;\n let column = 1;\n\n const peek = (offset = 0) => source[i + offset];\n const push = (type: TokenType, value: string, startLine: number, startCol: number) => {\n tokens.push({ type, value, line: startLine, column: startCol });\n };\n const advance = () => {\n const ch = source[i];\n i += 1;\n if (ch === \"\\n\") {\n line += 1;\n column = 1;\n } else {\n column += 1;\n }\n return ch;\n };\n\n while (i < source.length) {\n const ch = peek();\n\n if (ch === undefined) break;\n\n // Newline.\n if (ch === \"\\n\") {\n const startLine = line;\n const startCol = column;\n advance();\n push(\"Newline\", \"\\n\", startLine, startCol);\n continue;\n }\n\n // Whitespace (excluding newline).\n if (ch === \" \" || ch === \"\\t\" || ch === \"\\r\") {\n advance();\n continue;\n }\n\n // Line comments: //...\n if (ch === \"/\" && peek(1) === \"/\") {\n while (i < source.length && peek() !== \"\\n\") advance();\n continue;\n }\n\n // Block comments: /* ... */\n if (ch === \"/\" && peek(1) === \"*\") {\n advance();\n advance();\n while (i < source.length && !(peek() === \"*\" && peek(1) === \"/\")) {\n advance();\n }\n if (i < source.length) {\n advance();\n advance();\n }\n continue;\n }\n\n // Semicolons — treated as statement terminators (like newlines).\n if (ch === \";\") {\n const startLine = line;\n const startCol = column;\n advance();\n push(\"Semicolon\", \";\", startLine, startCol);\n continue;\n }\n\n // String literal:\n // - \"...\" / '...' — single-line strings with escape support\n // - `...` — multi-line template literals with `${expr}` interpolation\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n const startLine = line;\n const startCol = column;\n advance();\n let value = \"\";\n while (i < source.length && peek() !== quote) {\n if (peek() === \"\\\\\" && peek(1) !== undefined) {\n advance();\n const escaped = advance();\n switch (escaped) {\n case \"n\": value += \"\\n\"; break;\n case \"t\": value += \"\\t\"; break;\n case \"r\": value += \"\\r\"; break;\n case \"\\\\\": value += \"\\\\\"; break;\n case '\"': value += '\"'; break;\n case \"'\": value += \"'\"; break;\n case \"`\": value += \"`\"; break;\n default: value += escaped ?? \"\";\n }\n continue;\n }\n if (peek() === \"\\n\") {\n break;\n }\n value += advance();\n }\n if (peek() === quote) advance();\n push(\"String\", value, startLine, startCol);\n continue;\n }\n if (ch === \"`\") {\n const startLine = line;\n const startCol = column;\n advance();\n const parts: TemplatePart[] = [];\n let chunk = \"\";\n let sawExpr = false;\n while (i < source.length && peek() !== \"`\") {\n if (peek() === \"\\\\\" && peek(1) !== undefined) {\n advance();\n const escaped = advance();\n switch (escaped) {\n case \"n\": chunk += \"\\n\"; break;\n case \"t\": chunk += \"\\t\"; break;\n case \"r\": chunk += \"\\r\"; break;\n case \"\\\\\": chunk += \"\\\\\"; break;\n case '\"': chunk += '\"'; break;\n case \"'\": chunk += \"'\"; break;\n case \"`\": chunk += \"`\"; break;\n case \"$\": chunk += \"$\"; break;\n default: chunk += escaped ?? \"\";\n }\n continue;\n }\n if (peek() === \"$\" && peek(1) === \"{\") {\n parts.push({ kind: \"str\", text: chunk });\n chunk = \"\";\n const exprLine = line;\n const exprCol = column;\n advance();\n advance();\n let depth = 1;\n let source2 = \"\";\n while (i < source.length && depth > 0) {\n const next = peek();\n if (next === undefined) break;\n if (next === \"`\") {\n source2 += advance();\n while (i < source.length && peek() !== \"`\") {\n if (peek() === \"\\\\\" && peek(1) !== undefined) {\n source2 += advance();\n source2 += advance();\n continue;\n }\n source2 += advance();\n }\n if (peek() === \"`\") source2 += advance();\n continue;\n }\n if (next === '\"' || next === \"'\") {\n const q = next;\n source2 += advance();\n while (i < source.length && peek() !== q) {\n if (peek() === \"\\\\\" && peek(1) !== undefined) {\n source2 += advance();\n source2 += advance();\n continue;\n }\n if (peek() === \"\\n\") break;\n source2 += advance();\n }\n if (peek() === q) source2 += advance();\n continue;\n }\n if (next === \"{\") {\n depth += 1;\n source2 += advance();\n continue;\n }\n if (next === \"}\") {\n depth -= 1;\n if (depth === 0) {\n advance();\n break;\n }\n source2 += advance();\n continue;\n }\n source2 += advance();\n }\n parts.push({ kind: \"expr\", source: source2, line: exprLine, column: exprCol });\n sawExpr = true;\n continue;\n }\n chunk += advance();\n }\n if (peek() === \"`\") advance();\n parts.push({ kind: \"str\", text: chunk });\n if (!sawExpr) {\n push(\"String\", chunk, startLine, startCol);\n continue;\n }\n tokens.push({\n type: \"TemplateString\",\n value: \"\",\n line: startLine,\n column: startCol,\n parts,\n });\n continue;\n }\n\n // Number literal.\n const lastToken = tokens[tokens.length - 1];\n const allowSignedNumber =\n !lastToken ||\n lastToken.type === \"Newline\" ||\n lastToken.type === \"Semicolon\" ||\n lastToken.type === \"Operator\" ||\n (lastToken.type === \"Punctuation\" &&\n (lastToken.value === \"(\" || lastToken.value === \"[\" ||\n lastToken.value === \",\" || lastToken.value === \":\" ||\n lastToken.value === \"?\" || lastToken.value === \"{\"));\n if (isDigit(ch) || (ch === \"-\" && isDigit(peek(1) ?? \"\") && allowSignedNumber)) {\n const startLine = line;\n const startCol = column;\n let raw = \"\";\n if (ch === \"-\") raw += advance();\n let sawDot = false;\n while (i < source.length) {\n const next = peek() ?? \"\";\n if (isDigit(next)) {\n raw += advance();\n continue;\n }\n if (next === \".\" && !sawDot && isDigit(peek(1) ?? \"\")) {\n sawDot = true;\n raw += advance();\n continue;\n }\n break;\n }\n push(\"Number\", raw, startLine, startCol);\n continue;\n }\n\n // Legacy `@name(...)` builtin sigil — removed. Surface a clear\n // error so authors get a single squiggle pointing at the migration\n // site rather than a cascade of confused parse errors.\n if (ch === \"@\") {\n const err = new Error(\n 'Legacy `@name(...)` builtins are removed. Use `$util.<name>(...)` ' +\n 'or the equivalent native JavaScript instead (e.g. `arr.length` for `$util.count(arr)`).',\n ) as Error & { line?: number; column?: number };\n err.line = line;\n err.column = column;\n throw err;\n }\n\n // State identifier: $name. Reactive atoms are declared with `$name = value`\n // and referenced as `$name`.\n if (ch === \"$\") {\n const startLine = line;\n const startCol = column;\n advance();\n if (peek() === \"$\") {\n const err = new Error(\n 'Legacy \"$$x\" persistent reference is removed. ' +\n 'Reactive state is declared with \"$x = value\" and referenced as \"$x\".',\n ) as Error & { line?: number; column?: number };\n err.line = startLine;\n err.column = startCol;\n throw err;\n }\n let name = \"\";\n while (i < source.length && isIdentifierChar(peek() ?? \"\")) {\n name += advance();\n }\n push(\"StateIdentifier\", name, startLine, startCol);\n continue;\n }\n\n // Identifier or keyword.\n if (isIdentifierStart(ch)) {\n const startLine = line;\n const startCol = column;\n let name = \"\";\n while (i < source.length && isIdentifierChar(peek() ?? \"\")) {\n name += advance();\n }\n\n const keyword = KEYWORDS[name];\n if (keyword === \"Boolean\") {\n push(\"Boolean\", name, startLine, startCol);\n } else if (keyword === \"Null\") {\n push(\"Null\", name, startLine, startCol);\n } else if (KEYWORDS_AKTION.has(name)) {\n push(\"Keyword\", name, startLine, startCol);\n } else {\n push(\"Identifier\", name, startLine, startCol);\n }\n continue;\n }\n\n // Spread operator `...` (must come before single-dot punctuation).\n if (ch === \".\" && peek(1) === \".\" && peek(2) === \".\") {\n const startLine = line;\n const startCol = column;\n advance();\n advance();\n advance();\n push(\"Operator\", \"...\", startLine, startCol);\n continue;\n }\n\n // Multi-character operators. Order matters — longer matches must\n // be attempted before shorter ones (`===` before `==`, `**=` before\n // `**`, `&&=` before `&&`, `>>>=` before `>>>` before `>>`).\n const two = ch + (peek(1) ?? \"\");\n const three = two + (peek(2) ?? \"\");\n const four = three + (peek(3) ?? \"\");\n // Unsigned right-shift assignment — the only 4-char operator in JS.\n if (four === \">>>=\") {\n const startLine = line;\n const startCol = column;\n advance(); advance(); advance(); advance();\n push(\"Operator\", four, startLine, startCol);\n continue;\n }\n if (three === \"===\" || three === \"!==\" || three === \"**=\" ||\n three === \"??=\" || three === \"&&=\" || three === \"||=\" ||\n three === \">>>\" || three === \">>=\" || three === \"<<=\") {\n const startLine = line;\n const startCol = column;\n advance(); advance(); advance();\n push(\"Operator\", three, startLine, startCol);\n continue;\n }\n if (\n two === \"==\" || two === \"!=\" || two === \">=\" || two === \"<=\" ||\n two === \"&&\" || two === \"||\" || two === \"??\" || two === \"?.\" ||\n two === \"->\" || two === \"=>\" || two === \"**\" || two === \"%=\" ||\n two === \"+=\" || two === \"-=\" || two === \"*=\" || two === \"/=\" ||\n two === \"++\" || two === \"--\" ||\n two === \"<<\" || two === \">>\" ||\n two === \"&=\" || two === \"|=\" || two === \"^=\"\n ) {\n const startLine = line;\n const startCol = column;\n advance();\n advance();\n push(\"Operator\", two, startLine, startCol);\n continue;\n }\n\n // Single-char operators (arithmetic, comparison, bitwise).\n if (\"+-*/%!=<>&|^~\".includes(ch)) {\n const startLine = line;\n const startCol = column;\n advance();\n push(\"Operator\", ch, startLine, startCol);\n continue;\n }\n\n // Punctuation.\n if (SINGLE_CHAR_PUNCT.has(ch)) {\n const startLine = line;\n const startCol = column;\n advance();\n push(\"Punctuation\", ch, startLine, startCol);\n continue;\n }\n\n // Unknown char: skip with no token (parser surfaces errors per line).\n advance();\n }\n\n tokens.push({ type: \"EOF\", value: \"\", line, column });\n return tokens;\n}\n\nfunction isDigit(ch: string): boolean {\n return ch >= \"0\" && ch <= \"9\";\n}\n\nfunction isIdentifierStart(ch: string): boolean {\n return (ch >= \"a\" && ch <= \"z\") || (ch >= \"A\" && ch <= \"Z\") || ch === \"_\";\n}\n\nfunction isIdentifierChar(ch: string): boolean {\n return isIdentifierStart(ch) || isDigit(ch);\n}\n","/**\n * Parser for Aktion (strict JavaScript subset).\n *\n * The grammar mirrors the JS spec:\n *\n * program := (statement (NEWLINE | \";\"))*\n * statement := functionDecl | varDecl | ifStmt | forStmt | whileStmt\n * | switchStmt | tryStmt | breakStmt | continueStmt\n * | returnStmt | throwStmt | assignment | expressionStmt\n * expression := assignmentExpr (logical, comparison, arithmetic, …)\n * primary := literal | identifier | array | object | lambda\n * | grouped | new | unary\n *\n * `if` / `for` / `switch` / `while` / `try` are **statements only** —\n * they do not produce a value. To collect iterable bodies into an array\n * use `arr.map(x => …)` (every Aktion program is valid JavaScript).\n */\n\nimport { tokenize, type Token } from \"./lexer.js\";\nimport type {\n Program,\n Statement,\n AssignmentStatement,\n ExpressionStatement,\n Expression,\n ParseError,\n ObjectProperty,\n BlockExpr,\n DeclParam,\n EffectRateLimit,\n EffectTrigger,\n SwitchCase,\n DestructuringPattern,\n LambdaParam,\n ImportSpecifier,\n} from \"./types.js\";\n\nexport function parse(source: string): Program {\n const tokens = tokenize(source);\n const ctx = new ParserContext(tokens);\n const statements: Statement[] = [];\n const errors: ParseError[] = [];\n\n while (!ctx.isEnd()) {\n if (ctx.match(\"Newline\") || ctx.match(\"Semicolon\")) continue;\n\n try {\n const stmt = parseStatement(ctx, true);\n if (stmt) statements.push(stmt);\n } catch (err) {\n const error = err as ParseError;\n errors.push(error);\n ctx.recoverToNextLine();\n }\n }\n\n return { statements, errors };\n}\n\n/**\n * Top-level statement dispatcher. Mirrors the JS statement grammar —\n * keyword-led statements (`function`, `if`, `for`, `while`, `switch`,\n * `try`, `throw`, `break`, `continue`, `return`, `await`, `let` /\n * `const` / `var`) take precedence; otherwise we try an assignment\n * (`name = expr` / `$name = expr`) and fall through to a bare\n * expression statement.\n */\nfunction parseStatement(ctx: ParserContext, _topLevel: boolean): Statement | null {\n const head = ctx.peek();\n // `$effect(() => { … }, [deps])` — the side-effect builtin. Its name is\n // `$`-prefixed (lexes as a StateIdentifier), but it is parsed specially so\n // the dependency array keeps its trigger semantics (`$state` refs by name,\n // `\"mount\"`, `\"every(N)\"`, …) rather than being read as a plain array.\n if (head.type === \"StateIdentifier\" && head.value === \"effect\" &&\n ctx.peek(1).type === \"Punctuation\" && ctx.peek(1).value === \"(\") {\n return parseEffectStatement(ctx);\n }\n if (head.type === \"Keyword\") {\n switch (head.value) {\n case \"function\": return parseFunctionDecl(ctx);\n case \"import\": return parseImportStatement(ctx);\n case \"export\": return parseExportStatement(ctx);\n case \"await\": return parseAwait(ctx);\n case \"async\": {\n // `async function name(...) { ... }` — the runtime is already\n // async-aware (the action / effect runners `await` every\n // expression that returns a thenable), so `async` is accepted\n // as a no-op modifier in front of a function declaration.\n if (ctx.peek(1).type === \"Keyword\" && ctx.peek(1).value === \"function\") {\n ctx.consume();\n return parseFunctionDecl(ctx);\n }\n break;\n }\n case \"return\": return parseReturn(ctx);\n case \"let\":\n case \"const\":\n case \"var\": return parseVarDecl(ctx);\n case \"if\": return parseIfStatement(ctx);\n case \"switch\": return parseSwitchStatement(ctx);\n case \"for\": return parseForStatement(ctx);\n case \"while\": return parseWhileStatement(ctx);\n case \"do\": return parseDoWhileStatement(ctx);\n case \"break\": return parseBreakStatement(ctx);\n case \"continue\": return parseContinueStatement(ctx);\n case \"throw\": return parseThrowStatement(ctx);\n case \"try\": return parseTryStatement(ctx);\n }\n }\n const saved = ctx.snapshot();\n if (couldStartAssignment(ctx)) {\n try {\n return parseAssignment(ctx);\n } catch (err) {\n if (err && typeof err === \"object\" && (err as { __definitive?: boolean }).__definitive) {\n throw err;\n }\n ctx.restore(saved);\n }\n }\n return parseExpressionStatement(ctx);\n}\n\nfunction couldStartAssignment(ctx: ParserContext): boolean {\n const head = ctx.peek();\n if (head.type !== \"Identifier\" && head.type !== \"StateIdentifier\") {\n return false;\n }\n const next = ctx.peek(1);\n return next.type === \"Operator\" && next.value === \"=\";\n}\n\nfunction parseExpressionStatement(ctx: ParserContext): Statement {\n const start = ctx.peek();\n let expression = parseExpression(ctx);\n const next = ctx.peek();\n if (next.type === \"Operator\" && isAssignmentOperator(next.value)) {\n if (isAssignableTarget(expression)) {\n ctx.consume();\n const value = parseExpression(ctx);\n expression = {\n kind: \"BuiltinCall\",\n name: \"__rui_assign__\",\n arguments: [\n expression,\n value,\n { kind: \"Literal\", value: next.value },\n ],\n loc: { line: next.line, column: next.column },\n };\n }\n } else if (next.type === \"Operator\" && (next.value === \"++\" || next.value === \"--\")) {\n if (isAssignableTarget(expression)) {\n ctx.consume();\n expression = {\n kind: \"BuiltinCall\",\n name: \"__rui_postfix__\",\n arguments: [expression, { kind: \"Literal\", value: next.value }],\n loc: { line: next.line, column: next.column },\n };\n }\n }\n skipTerminator(ctx);\n return {\n kind: \"ExpressionStatement\",\n expression,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction isAssignmentOperator(value: string): boolean {\n return value === \"=\" || value === \"+=\" || value === \"-=\" || value === \"*=\"\n || value === \"/=\" || value === \"%=\" || value === \"**=\"\n || value === \"??=\" || value === \"&&=\" || value === \"||=\"\n || value === \"&=\" || value === \"|=\" || value === \"^=\"\n || value === \"<<=\" || value === \">>=\" || value === \">>>=\";\n}\n\nfunction isAssignableTarget(expr: Expression): boolean {\n if (expr.kind === \"Member\") return true;\n if (expr.kind === \"StateRef\") return true;\n if (expr.kind === \"Identifier\") return true;\n return false;\n}\n\n/**\n * Parse `function name(params) { body }`.\n *\n * Name-case selects the default classification — a PascalCase name\n * declares a component, a lowercase-first name declares an action. The\n * runtime registers every component as an action too (so it works in\n * event-handler position), and every action remains usable as a value-\n * returning helper. The \"component must `return`\" requirement has been\n * dropped: a component with no `return` simply renders nothing.\n */\nfunction parseFunctionDecl(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"function\");\n // A `$`-prefixed name (`function $useCounter() { ... }`) declares a HOOK.\n // The lexer emits the name as a `StateIdentifier` (value without the `$`).\n // Hooks compose per-instance state — their body runs inline in the calling\n // component's hook scope (React's custom-hook model).\n const isHook = ctx.peek().type === \"StateIdentifier\";\n const nameTok = isHook ? ctx.consume() : ctx.expect(\"Identifier\");\n const params = parseFunctionParams(ctx);\n const body = parseBlock(ctx);\n skipTerminator(ctx);\n\n if (isHook) {\n return {\n kind: \"HookDeclaration\",\n name: nameTok.value,\n params,\n body,\n loc: { line: start.line, column: start.column },\n };\n }\n\n const isPascalCase =\n nameTok.value.length > 0 && nameTok.value[0]! >= \"A\" && nameTok.value[0]! <= \"Z\";\n\n if (isPascalCase) {\n return {\n kind: \"ComponentDeclaration\",\n name: nameTok.value,\n params,\n slots: [],\n body,\n loc: { line: start.line, column: start.column },\n };\n }\n\n return {\n kind: \"ActionDeclaration\",\n name: nameTok.value,\n params,\n optimistic: false,\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseFunctionParams(ctx: ParserContext): DeclParam[] {\n ctx.expect(\"Punctuation\", \"(\");\n const params: DeclParam[] = [];\n skipWhitespace(ctx);\n if (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \")\")) {\n while (true) {\n skipWhitespace(ctx);\n let isRest = false;\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"...\") {\n ctx.consume();\n isRest = true;\n }\n const tok = ctx.peek();\n // Destructuring pattern parameter: `function Foo({ name }, [a, b]) { … }`.\n if (!isRest && tok.type === \"Punctuation\" && (tok.value === \"{\" || tok.value === \"[\")) {\n const pattern = parseDestructuringPattern(ctx);\n let defaultValue: Expression | undefined;\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n defaultValue = parseExpression(ctx);\n }\n const param: DeclParam = { name: \"\", pattern };\n if (defaultValue) param.defaultValue = defaultValue;\n params.push(param);\n } else if (tok.type === \"Identifier\" || tok.type === \"Keyword\") {\n const nameTok = ctx.consume();\n let defaultValue: Expression | undefined;\n if (!isRest && ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n defaultValue = parseExpression(ctx);\n }\n const param: DeclParam = { name: nameTok.value };\n if (defaultValue) param.defaultValue = defaultValue;\n if (isRest) (param as DeclParam & { rest?: boolean }).rest = true;\n params.push(param);\n } else {\n throw {\n message: `Expected parameter name, got ${tok.type} \"${tok.value}\"`,\n line: tok.line,\n column: tok.column,\n } satisfies ParseError;\n }\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n if (isRest) {\n throw {\n message: \"Rest parameter `...name` must be the final parameter.\",\n line: ctx.peek().line,\n column: ctx.peek().column,\n } satisfies ParseError;\n }\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \")\") break;\n continue;\n }\n break;\n }\n }\n ctx.expect(\"Punctuation\", \")\");\n return params;\n}\n\n/**\n * Parse `effect(() => { body }, [deps])` at the statement level.\n * Produces an EffectDeclaration AST node.\n */\nfunction parseEffectStatement(ctx: ParserContext): Statement {\n const start = ctx.consume(); // consume the `$effect` StateIdentifier\n ctx.expect(\"Punctuation\", \"(\");\n skipWhitespace(ctx);\n\n const callbackExpr = parseExpression(ctx);\n let body: BlockExpr;\n if (callbackExpr.kind === \"Lambda\") {\n body = callbackExpr.body.kind === \"Block\"\n ? callbackExpr.body\n : { kind: \"Block\", body: [{ kind: \"ExpressionStatement\", expression: callbackExpr.body }] };\n } else {\n body = { kind: \"Block\", body: [] };\n }\n\n const triggers: EffectTrigger[] = [];\n let rateLimit: EffectRateLimit | undefined;\n\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"[\") {\n ctx.consume();\n skipWhitespace(ctx);\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"]\")) {\n parseEffectDep(ctx, triggers, (rl) => { rateLimit = rl; });\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n }\n }\n ctx.expect(\"Punctuation\", \"]\");\n } else {\n parseExpression(ctx);\n }\n }\n\n skipWhitespace(ctx);\n ctx.expect(\"Punctuation\", \")\");\n skipTerminator(ctx);\n\n const decl: Statement = {\n kind: \"EffectDeclaration\",\n name: `__effect_L${start.line}_C${start.column}`,\n triggers,\n body,\n loc: { line: start.line, column: start.column },\n };\n if (rateLimit) (decl as { rateLimit?: EffectRateLimit }).rateLimit = rateLimit;\n return decl;\n}\n\n/**\n * Parse a single dependency entry inside `effect(() => {}, [...])`.\n * Accepts: $state refs, \"mount\", \"unmount\", \"every(N)\", \"debounce(N)\", \"throttle(N)\".\n */\nfunction parseEffectDep(\n ctx: ParserContext,\n triggers: EffectTrigger[],\n setRateLimit: (rl: EffectRateLimit) => void,\n): void {\n const head = ctx.peek();\n\n if (head.type === \"StateIdentifier\") {\n ctx.consume();\n // Consume a dotted property path so an effect can depend on a precise\n // sub-path: `effect(() => …, [$user.name])` → trigger \"user.name\", which\n // fires only when `user.name` (or the whole `user`) changes. Bracket /\n // computed access stops the path (the trigger coarsens to what precedes\n // it), keeping the dependency sound.\n let name = head.value;\n while (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \".\") {\n const prop = ctx.peek(1);\n if (prop.type !== \"Identifier\" && prop.type !== \"Keyword\") break;\n ctx.consume(); // \".\"\n ctx.consume(); // property\n name += \".\" + prop.value;\n }\n triggers.push({ kind: \"state\", name });\n return;\n }\n\n if (head.type === \"String\") {\n ctx.consume();\n const val = head.value;\n if (val === \"mount\" || val === \"unmount\") {\n triggers.push({ kind: \"lifecycle\", name: val });\n return;\n }\n const everyMatch = val.match(/^every\\((\\d+)\\)$/);\n if (everyMatch) {\n triggers.push({ kind: \"every\", intervalMs: Number(everyMatch[1]) });\n return;\n }\n const debounceMatch = val.match(/^debounce\\((\\d+)\\)$/);\n if (debounceMatch) {\n setRateLimit({ kind: \"debounce\", ms: Number(debounceMatch[1]) });\n return;\n }\n const throttleMatch = val.match(/^throttle\\((\\d+)\\)$/);\n if (throttleMatch) {\n setRateLimit({ kind: \"throttle\", ms: Number(throttleMatch[1]) });\n return;\n }\n throw {\n message: `Unknown effect dependency string \"${val}\". Expected \"mount\", \"unmount\", \"every(N)\", \"debounce(N)\", or \"throttle(N)\".`,\n line: head.line,\n column: head.column,\n } satisfies ParseError;\n }\n\n throw {\n message:\n `Unexpected ${head.type} \"${head.value}\" inside effect dependency array. ` +\n `Expected $state or a string token (\"mount\", \"unmount\", \"every(N)\", etc.).`,\n line: head.line,\n column: head.column,\n } satisfies ParseError;\n}\n\n/** Parse `let/const/var identifier = expression`. */\nfunction parseVarDecl(ctx: ParserContext): Statement {\n const start = ctx.consume(); // let/const/var\n const head = ctx.peek();\n\n // Destructuring forms: `let [a, b, ...rest] = arr` and\n // `let {a, b: alias, c = 1, ...rest} = obj`. Both expand into a single\n // `DestructureStatement` so the evaluator can fan out the bindings\n // when the right-hand side is evaluated once.\n if (head.type === \"Punctuation\" && (head.value === \"[\" || head.value === \"{\")) {\n return parseDestructureDecl(ctx, start);\n }\n\n let identifier = \"\";\n let isState = false;\n if (head.type === \"StateIdentifier\") {\n identifier = ctx.consume().value;\n isState = true;\n } else if (head.type === \"Identifier\") {\n identifier = ctx.consume().value;\n } else {\n throw {\n message: `Expected identifier after \"${start.value}\", got ${head.type} \"${head.value}\"`,\n line: head.line,\n column: head.column,\n } satisfies ParseError;\n }\n ctx.expect(\"Operator\", \"=\");\n const expression = parseExpression(ctx);\n skipTerminator(ctx);\n return {\n kind: \"Assignment\",\n identifier,\n isState,\n expression,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * Parse a destructuring declaration: `let [a, b, ...rest] = arr` or\n * `let {x, y: alias, z = 0, ...rest} = obj`. Nested patterns are\n * intentionally not supported — destructure in two steps for those.\n */\nfunction parseDestructureDecl(ctx: ParserContext, start: Token): Statement {\n const pattern = parseDestructuringPattern(ctx);\n ctx.expect(\"Operator\", \"=\");\n const expression = parseExpression(ctx);\n skipTerminator(ctx);\n return {\n kind: \"DestructureStatement\",\n patternKind: pattern.kind,\n bindings: pattern.bindings,\n expression,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * Parse a destructuring pattern (`[a, b, ...rest]` or\n * `{x, y: alias, z = 0, ...rest}`) WITHOUT the trailing `=` / value, so\n * the same code drives `let`-declarations and function / lambda\n * parameters. Nested patterns are intentionally flat — destructure in\n * two steps for deeper shapes.\n */\nfunction parseDestructuringPattern(ctx: ParserContext): DestructuringPattern {\n const head = ctx.consume(); // `[` or `{`\n const patternKind: \"array\" | \"object\" = head.value === \"[\" ? \"array\" : \"object\";\n const bindings: import(\"./types.js\").DestructuringBinding[] = [];\n\n if (patternKind === \"array\") {\n skipWhitespace(ctx);\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"]\")) {\n // `[,, x]` — array holes skip a position. Parsed as an empty\n // binding name so the evaluator advances the index without\n // creating a variable.\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n bindings.push({ name: \"\" });\n ctx.consume();\n skipWhitespace(ctx);\n continue;\n }\n let isRest = false;\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"...\") {\n ctx.consume();\n isRest = true;\n }\n const nameTok = ctx.expect(\"Identifier\");\n let defaultValue: Expression | undefined;\n if (!isRest && ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n defaultValue = parseExpression(ctx);\n }\n const binding: import(\"./types.js\").DestructuringBinding = { name: nameTok.value };\n if (isRest) binding.rest = true;\n if (defaultValue) binding.defaultValue = defaultValue;\n bindings.push(binding);\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n continue;\n }\n break;\n }\n ctx.expect(\"Punctuation\", \"]\");\n } else {\n skipWhitespace(ctx);\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")) {\n let isRest = false;\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"...\") {\n ctx.consume();\n isRest = true;\n }\n const keyTok = ctx.expect(\"Identifier\");\n let alias = keyTok.value;\n let sourceKey: string | undefined;\n // `{a: b}` — rename: source key `a`, local binding `b`.\n if (!isRest && ctx.peek().type === \"Punctuation\" && ctx.peek().value === \":\") {\n ctx.consume();\n const aliasTok = ctx.expect(\"Identifier\");\n sourceKey = keyTok.value;\n alias = aliasTok.value;\n }\n let defaultValue: Expression | undefined;\n if (!isRest && ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n defaultValue = parseExpression(ctx);\n }\n const binding: import(\"./types.js\").DestructuringBinding = { name: alias };\n if (sourceKey) binding.sourceKey = sourceKey;\n if (isRest) binding.rest = true;\n if (defaultValue) binding.defaultValue = defaultValue;\n bindings.push(binding);\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n continue;\n }\n break;\n }\n ctx.expect(\"Punctuation\", \"}\");\n }\n\n return { kind: patternKind, bindings };\n}\n\nfunction parseBlock(ctx: ParserContext): BlockExpr {\n const start = ctx.expect(\"Punctuation\", \"{\");\n const body: Statement[] = [];\n skipWhitespace(ctx);\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")) {\n const stmt = parseStatement(ctx, false);\n if (stmt) body.push(stmt);\n skipWhitespace(ctx);\n }\n ctx.expect(\"Punctuation\", \"}\");\n return {\n kind: \"Block\",\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * Parse the body of an `if` / `else` / `for` / `while` clause. Accepts\n * either a brace-delimited block (`{ … }`) or a single statement\n * (`if (cond) return`, `while (i--) i += 1`, etc.) and always returns\n * a `BlockExpr` so downstream evaluation is uniform.\n */\nfunction parseBlockOrSingleStatement(ctx: ParserContext): BlockExpr {\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"{\") {\n return parseBlock(ctx);\n }\n const head = ctx.peek();\n const stmt = parseStatement(ctx, false);\n return {\n kind: \"Block\",\n body: stmt ? [stmt] : [],\n loc: { line: head.line, column: head.column },\n };\n}\n\nfunction parseAwait(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"await\");\n const argument = parseExpression(ctx);\n skipTerminator(ctx);\n return {\n kind: \"Await\",\n argument,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseReturn(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"return\");\n let argument: Expression | undefined;\n const next = ctx.peek();\n if (\n next.type !== \"Newline\" && next.type !== \"Semicolon\" &&\n !(next.type === \"Punctuation\" && next.value === \"}\")\n ) {\n argument = parseExpression(ctx);\n }\n skipTerminator(ctx);\n return {\n kind: \"Return\",\n argument,\n loc: { line: start.line, column: start.column },\n };\n}\n\nclass ParserContext {\n private index = 0;\n constructor(private readonly tokens: Token[]) {}\n\n isEnd(): boolean {\n return this.peek().type === \"EOF\";\n }\n\n peek(offset = 0): Token {\n return this.tokens[this.index + offset] ?? { type: \"EOF\", value: \"\", line: 0, column: 0 };\n }\n\n consume(): Token {\n const tok = this.tokens[this.index] ?? { type: \"EOF\", value: \"\", line: 0, column: 0 };\n this.index += 1;\n return tok;\n }\n\n match(type: Token[\"type\"], value?: string): boolean {\n const tok = this.peek();\n if (tok.type !== type) return false;\n if (value !== undefined && tok.value !== value) return false;\n this.consume();\n return true;\n }\n\n expect(type: Token[\"type\"], value?: string): Token {\n const tok = this.peek();\n if (tok.type !== type || (value !== undefined && tok.value !== value)) {\n throw {\n message: `Expected ${type}${value !== undefined ? ` \"${value}\"` : \"\"} but got ${tok.type} \"${tok.value}\"`,\n line: tok.line,\n column: tok.column,\n } satisfies ParseError;\n }\n return this.consume();\n }\n\n recoverToNextLine(): void {\n while (!this.isEnd() && this.peek().type !== \"Newline\" && this.peek().type !== \"Semicolon\") this.consume();\n if (this.peek().type === \"Newline\" || this.peek().type === \"Semicolon\") this.consume();\n }\n\n snapshot(): number {\n return this.index;\n }\n\n restore(index: number): void {\n this.index = index;\n }\n}\n\nfunction parseAssignment(ctx: ParserContext): Statement | null {\n const head = ctx.peek();\n let identifier = \"\";\n let isState = false;\n if (head.type === \"Identifier\") {\n identifier = ctx.consume().value;\n } else if (head.type === \"StateIdentifier\") {\n identifier = ctx.consume().value;\n isState = true;\n } else {\n throw {\n message: `Expected identifier at start of statement, got ${head.type} \"${head.value}\"`,\n line: head.line,\n column: head.column,\n } satisfies ParseError;\n }\n\n const eq = ctx.expect(\"Operator\", \"=\");\n const expression = parseExpression(ctx);\n skipTerminator(ctx);\n\n return {\n kind: \"Assignment\",\n identifier,\n isState,\n expression,\n loc: { line: eq.line, column: eq.column },\n };\n}\n\n/**\n * `import { A, B as C, $shared } from \"./other.aktion\"` — named imports only.\n * `from`/`as` are contextual identifiers (not keywords). A `$state` import must\n * keep its `$` across `as`. Build-time only; the runtime ignores `Import`.\n */\nfunction parseImportStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"import\");\n ctx.expect(\"Punctuation\", \"{\");\n const specifiers: ImportSpecifier[] = [];\n while (!ctx.isEnd() && !(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")) {\n const importedTok = ctx.peek();\n let imported: string;\n let isState = false;\n if (importedTok.type === \"StateIdentifier\") {\n imported = ctx.consume().value;\n isState = true;\n } else if (importedTok.type === \"Identifier\") {\n imported = ctx.consume().value;\n } else {\n throw {\n message: `Expected an import name, got ${importedTok.type} \"${importedTok.value}\"`,\n line: importedTok.line,\n column: importedTok.column,\n } satisfies ParseError;\n }\n\n let local = imported;\n // Optional `as alias` — `as` is a contextual identifier here.\n if (ctx.peek().type === \"Identifier\" && ctx.peek().value === \"as\") {\n ctx.consume();\n const aliasTok = ctx.peek();\n let aliasIsState = false;\n if (aliasTok.type === \"StateIdentifier\") {\n local = ctx.consume().value;\n aliasIsState = true;\n } else if (aliasTok.type === \"Identifier\") {\n local = ctx.consume().value;\n } else {\n throw {\n message: `Expected an alias after \\`as\\`, got ${aliasTok.type} \"${aliasTok.value}\"`,\n line: aliasTok.line,\n column: aliasTok.column,\n } satisfies ParseError;\n }\n if (aliasIsState !== isState) {\n throw {\n message:\n \"A `$state` import must keep its `$` across `as` (e.g. `{ $x as $y }`); \" +\n \"a non-state import must not gain one.\",\n line: aliasTok.line,\n column: aliasTok.column,\n } satisfies ParseError;\n }\n }\n\n specifiers.push(isState ? { imported, local, isState: true } : { imported, local });\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n continue;\n }\n break;\n }\n ctx.expect(\"Punctuation\", \"}\");\n\n const fromTok = ctx.peek();\n if (!(fromTok.type === \"Identifier\" && fromTok.value === \"from\")) {\n throw {\n message: `Expected \\`from\\` after import specifiers, got ${fromTok.type} \"${fromTok.value}\"`,\n line: fromTok.line,\n column: fromTok.column,\n } satisfies ParseError;\n }\n ctx.consume();\n const sourceTok = ctx.expect(\"String\");\n skipTerminator(ctx);\n\n return {\n kind: \"Import\",\n specifiers,\n source: sourceTok.value,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * `export <declaration | assignment>` — marks the following top-level binding\n * importable from another module. `export { … }` lists / re-exports and\n * `export <destructure>` are intentionally not supported yet (clear errors).\n */\nfunction parseExportStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"export\");\n const next = ctx.peek();\n\n if (next.type === \"Punctuation\" && next.value === \"{\") {\n throw {\n message:\n \"`export { … }` lists are not supported yet — use inline `export <declaration>` \" +\n \"(e.g. `export function Foo() {…}`, `export $count = 0`).\",\n line: next.line,\n column: next.column,\n } satisfies ParseError;\n }\n\n let stmt: Statement | null;\n if (next.type === \"Keyword\" && next.value === \"function\") {\n stmt = parseFunctionDecl(ctx);\n } else if (\n next.type === \"Keyword\" && next.value === \"async\" &&\n ctx.peek(1).type === \"Keyword\" && ctx.peek(1).value === \"function\"\n ) {\n ctx.consume(); // async — accepted as a no-op modifier, mirroring parseStatement\n stmt = parseFunctionDecl(ctx);\n } else if (next.type === \"Keyword\" && (next.value === \"let\" || next.value === \"const\" || next.value === \"var\")) {\n stmt = parseVarDecl(ctx);\n if (stmt && stmt.kind === \"DestructureStatement\") {\n throw {\n message: \"`export` of a destructuring declaration is not supported — export named bindings individually.\",\n line: next.line,\n column: next.column,\n } satisfies ParseError;\n }\n } else if (couldStartAssignment(ctx)) {\n stmt = parseAssignment(ctx);\n } else {\n throw {\n message:\n \"`export` must be followed by a declaration or assignment \" +\n \"(`export function …`, `export let x = …`, `export $state = …`).\",\n line: next.line,\n column: next.column,\n } satisfies ParseError;\n }\n\n if (\n stmt &&\n (stmt.kind === \"Assignment\" ||\n stmt.kind === \"ComponentDeclaration\" ||\n stmt.kind === \"ActionDeclaration\" ||\n stmt.kind === \"HookDeclaration\")\n ) {\n stmt.exported = true;\n return stmt;\n }\n throw {\n message: \"`export` must be followed by a declaration or assignment.\",\n line: start.line,\n column: start.column,\n } satisfies ParseError;\n}\n\n/** `let foo = expr` ALSO accepts compound assignment operators? No — JS only\n * allows `=` after `let/const/var`, so we stick with `=`. (Compound forms\n * apply only to existing bindings.) */\n\nfunction parseExpression(ctx: ParserContext): Expression {\n return parseTernary(ctx);\n}\n\n/**\n * Peek through leading `Newline` tokens without consuming them and return\n * the first significant token. JavaScript treats a line break as a\n * continuation when the next token can only extend the current expression\n * (`.`, `?.`, `?`, `&&`, `||`, `+`, `-`, …). Operator parsers use this to\n * decide whether to swallow the newlines and keep building the expression.\n */\nfunction peekNonNewline(ctx: ParserContext): { token: Token; skipped: number } {\n let i = 0;\n while (true) {\n const t = ctx.peek(i);\n if (t.type === \"Newline\") { i += 1; continue; }\n return { token: t, skipped: i };\n }\n}\n\n/**\n * If the next non-newline token satisfies `predicate`, drop the\n * intervening newlines (committing the continuation) and return true.\n * Otherwise the cursor is left untouched.\n */\nfunction consumeNewlinesIfNext(\n ctx: ParserContext,\n predicate: (t: Token) => boolean,\n): boolean {\n const { token, skipped } = peekNonNewline(ctx);\n if (!predicate(token)) return false;\n for (let i = 0; i < skipped; i += 1) ctx.consume();\n return true;\n}\n\nfunction parseTernary(ctx: ParserContext): Expression {\n const test = parseLogicalOr(ctx);\n if (consumeNewlinesIfNext(ctx, (t) => t.type === \"Punctuation\" && t.value === \"?\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const consequent = parseExpression(ctx);\n skipWhitespace(ctx);\n ctx.expect(\"Punctuation\", \":\");\n skipWhitespace(ctx);\n const alternate = parseExpression(ctx);\n return { kind: \"Ternary\", test, consequent, alternate };\n }\n return test;\n}\n\nfunction parseLogicalOr(ctx: ParserContext): Expression {\n let left = parseLogicalAnd(ctx);\n while (\n consumeNewlinesIfNext(\n ctx,\n (t) => t.type === \"Operator\" && (t.value === \"||\" || t.value === \"??\"),\n )\n ) {\n const op = ctx.consume().value as \"||\" | \"??\";\n skipWhitespace(ctx);\n const right = parseLogicalAnd(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n }\n return left;\n}\n\nfunction parseLogicalAnd(ctx: ParserContext): Expression {\n let left = parseBitwiseOr(ctx);\n while (consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && t.value === \"&&\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const right = parseBitwiseOr(ctx);\n left = { kind: \"Binary\", operator: \"&&\", left, right };\n }\n return left;\n}\n\n/** Bitwise OR (`|`) — lower precedence than `^`, higher than `&&`. */\nfunction parseBitwiseOr(ctx: ParserContext): Expression {\n let left = parseBitwiseXor(ctx);\n while (consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && t.value === \"|\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const right = parseBitwiseXor(ctx);\n left = { kind: \"Binary\", operator: \"|\", left, right };\n }\n return left;\n}\n\n/** Bitwise XOR (`^`). */\nfunction parseBitwiseXor(ctx: ParserContext): Expression {\n let left = parseBitwiseAnd(ctx);\n while (consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && t.value === \"^\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const right = parseBitwiseAnd(ctx);\n left = { kind: \"Binary\", operator: \"^\", left, right };\n }\n return left;\n}\n\n/** Bitwise AND (`&`). */\nfunction parseBitwiseAnd(ctx: ParserContext): Expression {\n let left = parseEquality(ctx);\n while (consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && t.value === \"&\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const right = parseEquality(ctx);\n left = { kind: \"Binary\", operator: \"&\", left, right };\n }\n return left;\n}\n\nfunction parseEquality(ctx: ParserContext): Expression {\n let left = parseComparison(ctx);\n while (\n consumeNewlinesIfNext(\n ctx,\n (t) =>\n t.type === \"Operator\" &&\n (t.value === \"==\" || t.value === \"!=\" || t.value === \"===\" || t.value === \"!==\"),\n )\n ) {\n const op = ctx.consume().value as \"==\" | \"!=\" | \"===\" | \"!==\";\n skipWhitespace(ctx);\n const right = parseComparison(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n }\n return left;\n}\n\nfunction parseComparison(ctx: ParserContext): Expression {\n let left = parseShift(ctx);\n while (true) {\n if (\n consumeNewlinesIfNext(\n ctx,\n (t) => t.type === \"Operator\" && (t.value === \">\" || t.value === \"<\" || t.value === \">=\" || t.value === \"<=\"),\n )\n ) {\n const op = ctx.consume().value as \">\" | \"<\" | \">=\" | \"<=\";\n skipWhitespace(ctx);\n const right = parseShift(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n continue;\n }\n if (consumeNewlinesIfNext(ctx, (t) => t.type === \"Keyword\" && (t.value === \"instanceof\" || t.value === \"in\"))) {\n const op = ctx.consume().value as \"instanceof\" | \"in\";\n skipWhitespace(ctx);\n const right = parseShift(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n continue;\n }\n break;\n }\n return left;\n}\n\n/** Bitwise shift operators (`<<`, `>>`, `>>>`) — between relational and additive. */\nfunction parseShift(ctx: ParserContext): Expression {\n let left = parseAdditive(ctx);\n while (\n consumeNewlinesIfNext(\n ctx,\n (t) => t.type === \"Operator\" && (t.value === \"<<\" || t.value === \">>\" || t.value === \">>>\"),\n )\n ) {\n const op = ctx.consume().value as \"<<\" | \">>\" | \">>>\";\n skipWhitespace(ctx);\n const right = parseAdditive(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n }\n return left;\n}\n\nfunction parseAdditive(ctx: ParserContext): Expression {\n let left = parseMultiplicative(ctx);\n while (\n consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && (t.value === \"+\" || t.value === \"-\"))\n ) {\n const op = ctx.consume().value as \"+\" | \"-\";\n skipWhitespace(ctx);\n const right = parseMultiplicative(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n }\n return left;\n}\n\nfunction parseMultiplicative(ctx: ParserContext): Expression {\n let left = parseExponent(ctx);\n while (\n consumeNewlinesIfNext(\n ctx,\n (t) => t.type === \"Operator\" && (t.value === \"*\" || t.value === \"/\" || t.value === \"%\"),\n )\n ) {\n const op = ctx.consume().value as \"*\" | \"/\" | \"%\";\n skipWhitespace(ctx);\n const right = parseExponent(ctx);\n left = { kind: \"Binary\", operator: op, left, right };\n }\n return left;\n}\n\n/** Right-associative exponentiation — `2 ** 3 ** 2` parses as `2 ** (3 ** 2)`. */\nfunction parseExponent(ctx: ParserContext): Expression {\n const left = parseUnary(ctx);\n if (consumeNewlinesIfNext(ctx, (t) => t.type === \"Operator\" && t.value === \"**\")) {\n ctx.consume();\n skipWhitespace(ctx);\n const right = parseExponent(ctx);\n return { kind: \"Binary\", operator: \"**\", left, right };\n }\n return left;\n}\n\nfunction parseUnary(ctx: ParserContext): Expression {\n const tok = ctx.peek();\n if (tok.type === \"Operator\" && (tok.value === \"!\" || tok.value === \"-\" || tok.value === \"+\" || tok.value === \"~\")) {\n ctx.consume();\n const argument = parseUnary(ctx);\n return { kind: \"Unary\", operator: tok.value as \"!\" | \"-\" | \"+\" | \"~\", argument };\n }\n // `await expr` as an expression — `let user = await fetch(...)`. The\n // expression itself is a pass-through; the surrounding action / effect\n // runner unwraps any thenable returned by the assignment expression,\n // so this keyword works inside action / effect bodies the way JS\n // authors expect. In purely synchronous contexts it short-circuits to\n // the raw value (mirroring how `await` on a non-thenable is a no-op).\n if (tok.type === \"Keyword\" && tok.value === \"await\") {\n ctx.consume();\n const argument = parseUnary(ctx);\n return {\n kind: \"BuiltinCall\",\n name: \"__rui_await__\",\n arguments: [argument],\n loc: { line: tok.line, column: tok.column },\n };\n }\n // Prefix increment / decrement: `++x` and `--x`. Reuses the runtime's\n // synthetic assignment helper with an explicit \"prefix\" flag so the\n // value of `++x` is the NEW value (whereas `x++` keeps JS's postfix\n // semantics of returning the OLD value).\n if (tok.type === \"Operator\" && (tok.value === \"++\" || tok.value === \"--\")) {\n ctx.consume();\n const argument = parseUnary(ctx);\n return {\n kind: \"BuiltinCall\",\n name: \"__rui_prefix__\",\n arguments: [\n argument,\n { kind: \"Literal\", value: tok.value },\n ],\n loc: { line: tok.line, column: tok.column },\n };\n }\n // `typeof expr`, `void expr`, `delete expr` — prefix keyword operators.\n if (tok.type === \"Keyword\" && (tok.value === \"typeof\" || tok.value === \"void\" || tok.value === \"delete\")) {\n ctx.consume();\n const argument = parseUnary(ctx);\n return {\n kind: \"Unary\",\n operator: tok.value as \"typeof\" | \"void\" | \"delete\",\n argument,\n };\n }\n // `new Constructor(args)` — produces a New AST node so the evaluator\n // can `Reflect.construct(...)` against host globals (Date, Map, …). JS\n // binds the constructor's own argument list tighter than any trailing\n // `.member` / call, so `new Date(0).getTime()` is `(new Date(0)).getTime()`.\n // We parse the callee as a member-only chain (no call), consume one\n // optional argument list, then resume the postfix loop on the result.\n if (tok.type === \"Keyword\" && tok.value === \"new\") {\n ctx.consume();\n let callee = parsePrimary(ctx);\n let args: Expression[] = [];\n // `parsePrimary` parses `Foo(...)` as a `Call` (consuming its args) —\n // those ARE the constructor's arguments. Lift them onto the New node\n // and normalise the callee back to an identifier.\n if (callee.kind === \"Call\") {\n args = callee.arguments;\n callee = { kind: \"Identifier\", name: callee.callee, loc: callee.loc };\n } else {\n // `new ns.Thing(...)` / `new Foo` — extend with member-only access\n // (no calls), then take one optional constructor argument list.\n while (true) {\n const t = ctx.peek();\n if (t.type === \"Punctuation\" && t.value === \".\") {\n ctx.consume();\n const propTok = ctx.consume();\n if (propTok.type !== \"Identifier\" && propTok.type !== \"Keyword\") {\n throw {\n message: `Expected Identifier but got ${propTok.type} \"${propTok.value}\"`,\n line: propTok.line,\n column: propTok.column,\n } satisfies ParseError;\n }\n callee = { kind: \"Member\", object: callee, property: propTok.value };\n continue;\n }\n if (t.type === \"Punctuation\" && t.value === \"[\") {\n ctx.consume();\n const computed = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \"]\");\n callee = { kind: \"Member\", object: callee, computed };\n continue;\n }\n break;\n }\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"(\") {\n ctx.consume();\n args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n }\n }\n const newNode: Expression = {\n kind: \"New\",\n callee,\n arguments: args,\n loc: { line: tok.line, column: tok.column },\n };\n // Resume the postfix loop so `new Date(0).getTime()` chains the\n // trailing member / call onto the constructed value.\n return parsePostfixFrom(ctx, newNode);\n }\n return parsePostfixWithIncDec(ctx);\n}\n\n/**\n * Wrap `parsePostfix` with trailing `++` / `--` so postfix increment /\n * decrement can appear anywhere a normal expression can — `let x = i++`,\n * `total + i--`, etc. JS's postfix returns the OLD value (handled by\n * the runtime's `__rui_postfix__` helper).\n */\nfunction parsePostfixWithIncDec(ctx: ParserContext): Expression {\n const expr = parsePostfix(ctx);\n const tok = ctx.peek();\n if (tok.type === \"Operator\" && (tok.value === \"++\" || tok.value === \"--\")) {\n ctx.consume();\n return {\n kind: \"BuiltinCall\",\n name: \"__rui_postfix__\",\n arguments: [\n expr,\n { kind: \"Literal\", value: tok.value },\n ],\n loc: { line: tok.line, column: tok.column },\n };\n }\n return expr;\n}\n\nfunction parsePostfix(ctx: ParserContext): Expression {\n return parsePostfixFrom(ctx, parsePrimary(ctx));\n}\n\n/**\n * Run the member / call / index postfix loop starting from an already-\n * parsed base expression. Lets `new Date(0).getTime()` continue chaining\n * onto the `New` node (JS binds `new X(args)` tighter than the trailing\n * `.member` / call).\n */\nfunction parsePostfixFrom(ctx: ParserContext, base: Expression): Expression {\n let expr = base;\n while (true) {\n // Member / optional-member access may continue on the next line:\n // fetch(url)\n // .then(…)\n // ?.catch(…)\n // We only commit the line break when the next significant token is\n // a continuation. `[ ... ]` and `( ... )` postfixes are not skipped\n // across newlines — that direction is a well-known ASI footgun and\n // very rare in practice.\n consumeNewlinesIfNext(\n ctx,\n (t) => (t.type === \"Punctuation\" && t.value === \".\") ||\n (t.type === \"Operator\" && t.value === \"?.\"),\n );\n const tok = ctx.peek();\n if (tok.type === \"Punctuation\" && tok.value === \".\") {\n ctx.consume();\n const propTok = ctx.consume();\n if (propTok.type !== \"Identifier\" && propTok.type !== \"Keyword\") {\n throw {\n message: `Expected Identifier but got ${propTok.type} \"${propTok.value}\"`,\n line: propTok.line,\n column: propTok.column,\n } satisfies ParseError;\n }\n const after = ctx.peek();\n if (after.type === \"Punctuation\" && after.value === \"(\") {\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n expr = {\n kind: \"MethodCall\",\n object: expr,\n method: propTok.value,\n arguments: args,\n loc: { line: propTok.line, column: propTok.column },\n };\n continue;\n }\n expr = { kind: \"Member\", object: expr, property: propTok.value };\n continue;\n }\n if (tok.type === \"Operator\" && tok.value === \"?.\") {\n ctx.consume();\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"[\") {\n ctx.consume();\n const computed = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \"]\");\n expr = { kind: \"Member\", object: expr, computed, optional: true };\n } else if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"(\") {\n // `expr?.()` — optional call on an arbitrary expression.\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n expr = {\n kind: \"Invoke\",\n callee: expr,\n arguments: args,\n optional: true,\n loc: { line: tok.line, column: tok.column },\n };\n } else {\n const propTok = ctx.consume();\n if (propTok.type !== \"Identifier\" && propTok.type !== \"Keyword\") {\n throw {\n message: `Expected Identifier but got ${propTok.type} \"${propTok.value}\"`,\n line: propTok.line,\n column: propTok.column,\n } satisfies ParseError;\n }\n const after = ctx.peek();\n if (after.type === \"Punctuation\" && after.value === \"(\") {\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n expr = {\n kind: \"MethodCall\",\n object: expr,\n method: propTok.value,\n arguments: args,\n optional: true,\n loc: { line: propTok.line, column: propTok.column },\n };\n continue;\n }\n expr = { kind: \"Member\", object: expr, property: propTok.value, optional: true };\n }\n continue;\n }\n if (tok.type === \"Punctuation\" && tok.value === \"[\") {\n ctx.consume();\n const computed = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \"]\");\n expr = { kind: \"Member\", object: expr, computed };\n continue;\n }\n // Call postfix on an arbitrary expression — `(fn)(args)`, IIFE\n // `(() => …)()`, `arr[i](args)`, etc. Bare identifier callees stay\n // as `Call` nodes (handled in `parsePrimary`) so component / action\n // / library lookups still resolve by name.\n if (tok.type === \"Punctuation\" && tok.value === \"(\") {\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n expr = {\n kind: \"Invoke\",\n callee: expr,\n arguments: args,\n loc: { line: tok.line, column: tok.column },\n };\n continue;\n }\n break;\n }\n return expr;\n}\n\nfunction parsePrimary(ctx: ParserContext): Expression {\n const tok = ctx.peek();\n\n // `if` / `for` / `switch` / `while` / `try` are STATEMENTS in JS —\n // they do not produce a value. Reject any attempt to use them in\n // expression position (e.g. `name = for (…) { … }`) with a clear\n // migration hint instead of silently parsing the legacy form.\n if (\n tok.type === \"Keyword\" &&\n (tok.value === \"if\" || tok.value === \"for\" || tok.value === \"switch\" ||\n tok.value === \"while\" || tok.value === \"try\")\n ) {\n const hint = tok.value === \"if\"\n ? \"Use the ternary operator (`cond ? a : b`) when you need a value.\"\n : tok.value === \"for\"\n ? \"Use `arr.map(x => …)` (or `.filter`, `.reduce`, …) to collect bodies into an array.\"\n : tok.value === \"switch\"\n ? \"Use chained ternaries, an object lookup, or wrap the switch inside a `function`.\"\n : `Use the ${tok.value} statement inside a function / effect body.`;\n const err: ParseError & { __definitive?: boolean } = {\n message:\n `\\`${tok.value}\\` is a statement, not an expression. ${hint}`,\n line: tok.line,\n column: tok.column,\n };\n err.__definitive = true;\n throw err;\n }\n\n if (tok.type === \"Keyword\") {\n // Anonymous function expression: `function (params) { body }` or\n // `function name(params) { body }`. JS allows these as values\n // (e.g. `arr.map(function (e) { return Button(e) })`) so we parse\n // them into a `Lambda` node sharing the same params/body shape as\n // an arrow function — `name`, if present, is currently discarded\n // (function expressions are rarely referenced by their own name in\n // this subset).\n if (tok.value === \"function\") {\n const lookahead = ctx.peek(1);\n const lookahead2 = ctx.peek(2);\n const looksLikeFunctionExpr =\n (lookahead.type === \"Punctuation\" && lookahead.value === \"(\") ||\n (lookahead.type === \"Identifier\" && lookahead2.type === \"Punctuation\" && lookahead2.value === \"(\");\n if (looksLikeFunctionExpr) {\n const start = tok;\n ctx.consume(); // function\n if (ctx.peek().type === \"Identifier\") ctx.consume(); // optional name\n const params = parseFunctionParams(ctx);\n const body = parseBlock(ctx);\n return {\n kind: \"Lambda\",\n params,\n body: body as never,\n loc: { line: start.line, column: start.column },\n };\n }\n }\n // Keywords that are also valid identifier names in expressions.\n if (\n tok.value === \"function\" ||\n tok.value === \"let\" || tok.value === \"const\" || tok.value === \"var\" ||\n tok.value === \"of\" || tok.value === \"in\" || tok.value === \"case\" ||\n tok.value === \"break\" || tok.value === \"continue\" || tok.value === \"default\"\n ) {\n ctx.consume();\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"(\") {\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n return {\n kind: \"Call\",\n callee: tok.value,\n arguments: args,\n loc: { line: tok.line, column: tok.column },\n };\n }\n return { kind: \"Identifier\", name: tok.value, loc: { line: tok.line, column: tok.column } };\n }\n }\n\n if (tok.type === \"Number\") {\n ctx.consume();\n return { kind: \"Literal\", value: Number(tok.value) };\n }\n if (tok.type === \"String\") {\n ctx.consume();\n return { kind: \"Literal\", value: tok.value };\n }\n if (tok.type === \"TemplateString\") {\n ctx.consume();\n const parts = tok.parts ?? [];\n const quasis: string[] = [];\n const expressions: Expression[] = [];\n let pendingChunk = \"\";\n let hasPendingChunk = false;\n const flushChunk = (): void => {\n quasis.push(pendingChunk);\n pendingChunk = \"\";\n hasPendingChunk = false;\n };\n for (const part of parts) {\n if (part.kind === \"str\") {\n pendingChunk += part.text;\n hasPendingChunk = true;\n continue;\n }\n if (!hasPendingChunk) {\n quasis.push(\"\");\n } else {\n flushChunk();\n }\n const sub = parse(`__rui_tmpl__ = ${part.source}`);\n const firstStmt = sub.statements[0];\n if (firstStmt && firstStmt.kind === \"Assignment\") {\n expressions.push(firstStmt.expression);\n } else {\n expressions.push({ kind: \"Literal\", value: \"\" });\n }\n }\n if (hasPendingChunk || quasis.length === 0) {\n quasis.push(pendingChunk);\n }\n while (quasis.length <= expressions.length) quasis.push(\"\");\n return {\n kind: \"Template\",\n quasis,\n expressions,\n loc: { line: tok.line, column: tok.column },\n };\n }\n if (tok.type === \"Boolean\") {\n ctx.consume();\n return { kind: \"Literal\", value: tok.value === \"true\" };\n }\n if (tok.type === \"Null\") {\n ctx.consume();\n return { kind: \"Literal\", value: null };\n }\n if (tok.type === \"StateIdentifier\") {\n // `$effect(...)` in expression position — produce an EffectDeclaration so\n // its dependency array keeps trigger semantics (rare; effects are usually\n // statements). Other `$name(...)` calls stay StateRef Invokes.\n if (tok.value === \"effect\" && ctx.peek(1).type === \"Punctuation\" && ctx.peek(1).value === \"(\") {\n ctx.consume();\n return parseEffectCallAsExpr(ctx, tok);\n }\n ctx.consume();\n return { kind: \"StateRef\", name: tok.value };\n }\n if (tok.type === \"Identifier\") {\n ctx.consume();\n // Unparenthesised single-param arrow: `x => expr` or `x => { … }`.\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"=>\") {\n ctx.consume();\n const body = parseLambdaBody(ctx);\n return {\n kind: \"Lambda\",\n params: [{ name: tok.value }],\n body: body as never,\n loc: { line: tok.line, column: tok.column },\n };\n }\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"(\") {\n ctx.consume();\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n return {\n kind: \"Call\",\n callee: tok.value,\n arguments: args,\n loc: { line: tok.line, column: tok.column },\n };\n }\n return {\n kind: \"Identifier\",\n name: tok.value,\n loc: { line: tok.line, column: tok.column },\n };\n }\n if (tok.type === \"Punctuation\" && tok.value === \"[\") {\n ctx.consume();\n const elements = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \"]\");\n return { kind: \"Array\", elements };\n }\n if (tok.type === \"Punctuation\" && tok.value === \"{\") {\n ctx.consume();\n const properties = parseObjectProps(ctx);\n ctx.expect(\"Punctuation\", \"}\");\n return { kind: \"Object\", properties };\n }\n if (tok.type === \"Punctuation\" && tok.value === \"(\") {\n const saved = ctx.snapshot();\n const lambda = tryParseLambdaFromParenList(ctx);\n if (lambda) return lambda;\n ctx.restore(saved);\n ctx.consume();\n const expr = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n return expr;\n }\n\n throw {\n message: `Unexpected token ${tok.type} \"${tok.value}\"`,\n line: tok.line,\n column: tok.column,\n } satisfies ParseError;\n}\n\n/**\n * Parse `effect(...)` in expression position — should not normally reach\n * here since the statement dispatcher handles `effect` at the top level.\n * Falls back to a regular Call node for the evaluator to handle.\n */\nfunction parseEffectCallAsExpr(ctx: ParserContext, nameTok: Token): Expression {\n ctx.consume(); // (\n const args = parseCallArgs(ctx);\n ctx.expect(\"Punctuation\", \")\");\n return {\n kind: \"Call\",\n callee: nameTok.value,\n arguments: args,\n loc: { line: nameTok.line, column: nameTok.column },\n };\n}\n\nfunction parseCallArgs(ctx: ParserContext): Expression[] {\n const args: Expression[] = [];\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && (ctx.peek().value === \")\" || ctx.peek().value === \"]\")) {\n return args;\n }\n args.push(parseArgItem(ctx));\n skipWhitespace(ctx);\n while (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && (ctx.peek().value === \")\" || ctx.peek().value === \"]\")) {\n break;\n }\n args.push(parseArgItem(ctx));\n skipWhitespace(ctx);\n }\n skipWhitespace(ctx);\n return args;\n}\n\nfunction parseArgItem(ctx: ParserContext): Expression {\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"...\") {\n const tok = ctx.consume();\n const argument = parseExpression(ctx);\n return { kind: \"Spread\", argument, loc: { line: tok.line, column: tok.column } };\n }\n return parseExpression(ctx);\n}\n\n/**\n * Parse `if (condition) { … } else if (…) { … } else { … }` as a\n * STATEMENT. The condition MUST be wrapped in parentheses (JS syntax).\n * `if` does not produce a value — use the ternary operator\n * (`cond ? a : b`) when you need a value.\n */\nfunction parseIfStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"if\");\n ctx.expect(\"Punctuation\", \"(\");\n const test = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n // Either a block `{ … }` or a single statement — `if (!$email) return`.\n const consequent = parseBlockOrSingleStatement(ctx);\n let alternate: Statement | BlockExpr | undefined;\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"else\") {\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"if\") {\n alternate = parseIfStatement(ctx);\n } else {\n alternate = parseBlockOrSingleStatement(ctx);\n }\n }\n skipTerminator(ctx);\n return {\n kind: \"IfStatement\",\n test,\n consequent,\n alternate: alternate as never,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * Parse `switch (value) { case X: …; break; default: … }` as a\n * STATEMENT. `switch` does not produce a value — use chained ternaries\n * or an object lookup when you need one.\n */\nfunction parseSwitchStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"switch\");\n ctx.expect(\"Punctuation\", \"(\");\n const discriminant = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n ctx.expect(\"Punctuation\", \"{\");\n const cases: SwitchCase[] = [];\n skipWhitespace(ctx);\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")) {\n let test: Expression | null = null;\n if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"case\") {\n ctx.consume();\n test = parseExpression(ctx);\n } else if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"default\") {\n ctx.consume();\n test = null;\n } else {\n throw {\n message: `Expected \"case\" or \"default\" in switch body, got ${ctx.peek().type} \"${ctx.peek().value}\"`,\n line: ctx.peek().line,\n column: ctx.peek().column,\n } satisfies ParseError;\n }\n ctx.expect(\"Punctuation\", \":\");\n skipWhitespace(ctx);\n const body: Statement[] = [];\n while (\n !ctx.isEnd() &&\n !(ctx.peek().type === \"Keyword\" && (ctx.peek().value === \"case\" || ctx.peek().value === \"default\")) &&\n !(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")\n ) {\n const stmt = parseStatement(ctx, false);\n if (stmt) body.push(stmt);\n skipWhitespace(ctx);\n }\n cases.push({ test, body });\n skipWhitespace(ctx);\n }\n ctx.expect(\"Punctuation\", \"}\");\n skipTerminator(ctx);\n return {\n kind: \"SwitchStatement\",\n discriminant,\n cases,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/**\n * Parse `for` STATEMENT. Two shapes are recognised — `for (let x of arr) { … }`\n * (iteration; supports array / object destructuring) and the classic\n * `for (init; cond; update) { … }`. Neither shape produces a value.\n * To collect the bodies into an array use `arr.map(x => …)`.\n */\nfunction parseForStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"for\");\n ctx.expect(\"Punctuation\", \"(\");\n skipWhitespace(ctx);\n\n // Decide between for-of, for-in, and classic-for. We peek ahead: a `;`\n // before the matching `)` means classic; an `of`/`in` keyword\n // determines for-of vs. for-in.\n const headSnapshot = ctx.snapshot();\n let kind: \"for-of\" | \"for-in\" | \"classic\" = \"for-of\";\n {\n let depth = 1;\n let i = 0;\n while (true) {\n const tok = ctx.peek(i);\n if (tok.type === \"EOF\") break;\n if (tok.type === \"Punctuation\" && tok.value === \"(\") depth += 1;\n else if (tok.type === \"Punctuation\" && tok.value === \")\") {\n depth -= 1;\n if (depth === 0) break;\n } else if (depth === 1 && tok.type === \"Semicolon\") {\n kind = \"classic\";\n break;\n } else if (depth === 1 && tok.type === \"Keyword\" && tok.value === \"of\") {\n kind = \"for-of\";\n break;\n } else if (depth === 1 && tok.type === \"Keyword\" && tok.value === \"in\") {\n kind = \"for-in\";\n break;\n }\n i += 1;\n }\n }\n ctx.restore(headSnapshot);\n\n if (kind === \"classic\") return parseForClassic(ctx, start);\n\n // for-of / for-in: optional let/const/var, then binding,\n // then `of` / `in`, then iterable.\n if (\n ctx.peek().type === \"Keyword\" &&\n (ctx.peek().value === \"let\" || ctx.peek().value === \"const\" || ctx.peek().value === \"var\")\n ) {\n ctx.consume();\n }\n skipWhitespace(ctx);\n\n let item: string;\n let index: string | undefined;\n let destructure: string[] | undefined;\n\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"[\") {\n ctx.consume();\n item = ctx.expect(\"Identifier\").value;\n ctx.expect(\"Punctuation\", \",\");\n index = ctx.expect(\"Identifier\").value;\n ctx.expect(\"Punctuation\", \"]\");\n } else if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"{\") {\n ctx.consume();\n const fields: string[] = [];\n while (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\")) {\n fields.push(ctx.expect(\"Identifier\").value);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") ctx.consume();\n }\n ctx.expect(\"Punctuation\", \"}\");\n item = \"__row\";\n destructure = fields;\n } else {\n item = ctx.expect(\"Identifier\").value;\n }\n\n if (kind === \"for-in\") {\n ctx.expect(\"Keyword\", \"in\");\n } else {\n ctx.expect(\"Keyword\", \"of\");\n }\n const iterable = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n const body = parseBlockOrSingleStatement(ctx);\n skipTerminator(ctx);\n if (kind === \"for-in\") {\n return {\n kind: \"ForInStatement\",\n item,\n iterable,\n body,\n loc: { line: start.line, column: start.column },\n };\n }\n return {\n kind: \"ForOfStatement\",\n item,\n index,\n destructure,\n iterable,\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseForClassic(ctx: ParserContext, start: Token): Statement {\n // init — may be a `let/const/var` decl, an expression, or empty.\n let init: AssignmentStatement | ExpressionStatement | undefined;\n if (!(ctx.peek().type === \"Semicolon\")) {\n if (\n ctx.peek().type === \"Keyword\" &&\n (ctx.peek().value === \"let\" || ctx.peek().value === \"const\" || ctx.peek().value === \"var\")\n ) {\n // `parseVarDecl` itself consumes the trailing `;` / newline, so we\n // do not need to expect another semicolon afterwards.\n const decl = parseVarDecl(ctx);\n if (decl.kind === \"Assignment\") init = decl;\n skipWhitespace(ctx);\n } else {\n const exprStart = ctx.peek();\n const expression = parseExpression(ctx);\n init = {\n kind: \"ExpressionStatement\",\n expression,\n loc: { line: exprStart.line, column: exprStart.column },\n };\n ctx.expect(\"Semicolon\");\n skipWhitespace(ctx);\n }\n } else {\n ctx.expect(\"Semicolon\");\n skipWhitespace(ctx);\n }\n\n let test: Expression | undefined;\n if (!(ctx.peek().type === \"Semicolon\")) {\n test = parseExpression(ctx);\n }\n ctx.expect(\"Semicolon\");\n skipWhitespace(ctx);\n\n let update: Expression | undefined;\n if (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \")\")) {\n update = parseAssignmentLikeExpression(ctx);\n }\n ctx.expect(\"Punctuation\", \")\");\n const body = parseBlockOrSingleStatement(ctx);\n skipTerminator(ctx);\n return {\n kind: \"ForClassicStatement\",\n init,\n test,\n update,\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/** Parse `while (cond) { body }`. */\nfunction parseWhileStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"while\");\n ctx.expect(\"Punctuation\", \"(\");\n const test = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n const body = parseBlockOrSingleStatement(ctx);\n skipTerminator(ctx);\n return {\n kind: \"WhileStatement\",\n test,\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseDoWhileStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"do\");\n const body = parseBlockOrSingleStatement(ctx);\n skipWhitespace(ctx);\n ctx.expect(\"Keyword\", \"while\");\n ctx.expect(\"Punctuation\", \"(\");\n const test = parseExpression(ctx);\n ctx.expect(\"Punctuation\", \")\");\n skipTerminator(ctx);\n return {\n kind: \"DoWhileStatement\",\n test,\n body,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseBreakStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"break\");\n skipTerminator(ctx);\n return { kind: \"BreakStatement\", loc: { line: start.line, column: start.column } };\n}\n\nfunction parseContinueStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"continue\");\n skipTerminator(ctx);\n return { kind: \"ContinueStatement\", loc: { line: start.line, column: start.column } };\n}\n\nfunction parseThrowStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"throw\");\n const argument = parseExpression(ctx);\n skipTerminator(ctx);\n return {\n kind: \"ThrowStatement\",\n argument,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction parseTryStatement(ctx: ParserContext): Statement {\n const start = ctx.expect(\"Keyword\", \"try\");\n const block = parseBlock(ctx);\n let catchParam: string | undefined;\n let catchBlock: BlockExpr | undefined;\n let finallyBlock: BlockExpr | undefined;\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"catch\") {\n ctx.consume();\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"(\") {\n ctx.consume();\n if (ctx.peek().type === \"Identifier\") {\n catchParam = ctx.consume().value;\n }\n ctx.expect(\"Punctuation\", \")\");\n }\n catchBlock = parseBlock(ctx);\n skipWhitespace(ctx);\n }\n if (ctx.peek().type === \"Keyword\" && ctx.peek().value === \"finally\") {\n ctx.consume();\n finallyBlock = parseBlock(ctx);\n }\n skipTerminator(ctx);\n return {\n kind: \"TryStatement\",\n block,\n catchParam,\n catchBlock,\n finallyBlock,\n loc: { line: start.line, column: start.column },\n };\n}\n\nfunction tryParseLambdaFromParenList(ctx: ParserContext): Expression | null {\n const start = ctx.peek();\n if (start.type !== \"Punctuation\" || start.value !== \"(\") return null;\n ctx.consume();\n const params: LambdaParam[] = [];\n skipWhitespace(ctx);\n if (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \")\")) {\n while (true) {\n skipWhitespace(ctx);\n // Rest parameter: `(...args) => …`. Must be the final parameter\n // — `parseFunctionParams` enforces the same rule.\n let isRest = false;\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"...\") {\n ctx.consume();\n isRest = true;\n }\n const tok = ctx.peek();\n // Destructuring pattern param: `({ a, b }) => …` / `([a, b]) => …`.\n if (!isRest && tok.type === \"Punctuation\" && (tok.value === \"{\" || tok.value === \"[\")) {\n let pattern: DestructuringPattern;\n try {\n pattern = parseDestructuringPattern(ctx);\n } catch {\n return null;\n }\n const param: LambdaParam = { name: \"\", pattern };\n if (ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n try {\n param.defaultValue = parseExpression(ctx);\n } catch {\n return null;\n }\n }\n params.push(param);\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n continue;\n }\n break;\n }\n if (tok.type !== \"Identifier\") return null;\n ctx.consume();\n const param: LambdaParam = { name: tok.value };\n if (isRest) param.rest = true;\n // Default values use `=` in JS arrow functions.\n if (!isRest && ctx.peek().type === \"Operator\" && ctx.peek().value === \"=\") {\n ctx.consume();\n try {\n param.defaultValue = parseExpression(ctx);\n } catch {\n return null;\n }\n }\n params.push(param);\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n if (isRest) return null;\n ctx.consume();\n continue;\n }\n break;\n }\n }\n skipWhitespace(ctx);\n if (!(ctx.peek().type === \"Punctuation\" && ctx.peek().value === \")\")) {\n return null;\n }\n ctx.consume();\n if (!(ctx.peek().type === \"Operator\" && ctx.peek().value === \"=>\")) {\n return null;\n }\n ctx.consume();\n const body = parseLambdaBody(ctx);\n return {\n kind: \"Lambda\",\n params,\n body: body as never,\n loc: { line: start.line, column: start.column },\n };\n}\n\n/** Parse the body of an arrow function — either `{ stmts }` or a bare\n * expression. In JavaScript the body may legally appear on the line\n * after `=>` (`x =>\\n expr`), so we tolerate intervening newlines. */\nfunction parseLambdaBody(ctx: ParserContext): Expression {\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"{\") {\n return parseBlock(ctx);\n }\n return parseAssignmentLikeExpression(ctx);\n}\n\nfunction parseAssignmentLikeExpression(ctx: ParserContext): Expression {\n const expression = parseExpression(ctx);\n const next = ctx.peek();\n if (next.type === \"Operator\") {\n if (isAssignmentOperator(next.value)) {\n ctx.consume();\n const value = parseExpression(ctx);\n return {\n kind: \"BuiltinCall\",\n name: \"__rui_assign__\",\n arguments: [\n expression,\n value,\n { kind: \"Literal\", value: next.value },\n ],\n loc: { line: next.line, column: next.column },\n };\n }\n if (next.value === \"++\" || next.value === \"--\") {\n ctx.consume();\n return {\n kind: \"BuiltinCall\",\n name: \"__rui_postfix__\",\n arguments: [\n expression,\n { kind: \"Literal\", value: next.value },\n ],\n loc: { line: next.line, column: next.column },\n };\n }\n }\n return expression;\n}\n\nfunction parseObjectProps(ctx: ParserContext): ObjectProperty[] {\n const props: ObjectProperty[] = [];\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\") return props;\n\n while (true) {\n skipWhitespace(ctx);\n const keyTok = ctx.peek();\n if (keyTok.type === \"Operator\" && keyTok.value === \"...\") {\n ctx.consume();\n const value = parseExpression(ctx);\n props.push({ key: \"\", value, spread: true });\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\") break;\n continue;\n }\n break;\n }\n let key: string;\n let computedKey: Expression | undefined;\n if (keyTok.type === \"Punctuation\" && keyTok.value === \"[\") {\n ctx.consume();\n skipWhitespace(ctx);\n computedKey = parseExpression(ctx);\n skipWhitespace(ctx);\n ctx.expect(\"Punctuation\", \"]\");\n key = \"\";\n } else if (keyTok.type === \"Number\") {\n key = ctx.consume().value;\n } else if (keyTok.type === \"Identifier\" || keyTok.type === \"String\" || keyTok.type === \"Keyword\") {\n key = ctx.consume().value;\n } else {\n throw {\n message: `Expected object key, got ${keyTok.type} \"${keyTok.value}\"`,\n line: keyTok.line,\n column: keyTok.column,\n } satisfies ParseError;\n }\n const after = ctx.peek();\n let value: Expression;\n if (\n !computedKey &&\n keyTok.type === \"Identifier\" &&\n after.type === \"Punctuation\" &&\n (after.value === \",\" || after.value === \"}\")\n ) {\n value = { kind: \"Identifier\", name: key, loc: { line: keyTok.line, column: keyTok.column } };\n } else {\n ctx.expect(\"Punctuation\", \":\");\n value = parseExpression(ctx);\n }\n const prop: ObjectProperty = { key, value };\n if (computedKey) prop.computedKey = computedKey;\n props.push(prop);\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \",\") {\n ctx.consume();\n skipWhitespace(ctx);\n if (ctx.peek().type === \"Punctuation\" && ctx.peek().value === \"}\") break;\n continue;\n }\n break;\n }\n skipWhitespace(ctx);\n return props;\n}\n\n/** Skip newlines and semicolons. */\nfunction skipWhitespace(ctx: ParserContext): void {\n while (ctx.match(\"Newline\") || ctx.match(\"Semicolon\")) {/* skip */}\n}\n\n/** Skip an optional statement terminator (newline, semicolon, or nothing before `}`/EOF). */\nfunction skipTerminator(ctx: ParserContext): void {\n if (!ctx.isEnd()) {\n ctx.match(\"Newline\") || ctx.match(\"Semicolon\");\n }\n}\n","/**\n * Schema-as-truth validation (§15).\n *\n * Walks a parsed `Program` and reports **fatal** diagnostics for:\n *\n * - Closed-token enum mismatches (`Button(\"Save\", { tone: \"magic\" })` →\n * \"magic\" is not in the `tone` enum).\n * - Unknown props (`Stack([...], { gap: \"md\", junk: 1 })` → no such prop).\n *\n * In Aktion 0.5 these are surfaced through `program.errors` and block\n * rendering — see `validateProgram(source, library)` for the combined\n * entry point the element calls. The goal is to give authors (and LLMs)\n * a clear signal that they are reaching outside the documented surface.\n */\n\nimport type {\n Expression,\n ParseError,\n Program,\n Statement,\n} from \"../parser/types.js\";\nimport { parse } from \"../parser/index.js\";\nimport type { ComponentLibrary } from \"./types.js\";\nimport { findPositionalProp } from \"./types.js\";\nimport { findComponent } from \"./registry.js\";\n\n/**\n * Combined entry point for hosts: parse the source and merge any\n * schema-level violations into `program.errors`. The element calls\n * this so the on-screen error banner surfaces *every* Aktion 0.5\n * violation, not just the syntactic ones. Returning the\n * parsed program lets the caller render the committed prefix when\n * the input still parses cleanly.\n */\nexport function validateProgram(\n source: string,\n library: ComponentLibrary,\n): Program {\n const program = parse(source);\n const schemaErrors = validateProgramSchema(program, library);\n if (schemaErrors.length > 0) {\n program.errors = [...program.errors, ...schemaErrors];\n }\n return program;\n}\n\n/**\n * Schema-as-truth validation (§15).\n *\n * Walks a parsed `Program` and returns every Aktion 0.5\n * schema violation as a `ParseError`. In 0.5 these are **fatal** — the\n * host should merge them into `program.errors` (see\n * `validateProgram(source, library)` for the combined entry point) and\n * surface the error banner instead of rendering. There are no longer\n * any \"advisory warnings\" — every legacy v1 surface either:\n *\n * - produces a parser-level migration error at parse time, or\n * - produces a schema-validator error here when library knowledge is\n * required (multi-positional calls, unknown props, enum mismatches,\n * legacy Theme tokens, …).\n */\nexport function validateProgramSchema(\n program: Program,\n library: ComponentLibrary,\n): ParseError[] {\n const errors: ParseError[] = [];\n for (const stmt of program.statements) {\n walkStatement(stmt, library, errors);\n }\n return errors;\n}\n\nfunction walkStatement(\n stmt: Statement,\n library: ComponentLibrary,\n out: ParseError[],\n): void {\n switch (stmt.kind) {\n case \"Assignment\":\n walkExpression(stmt.expression, library, out);\n return;\n case \"ExpressionStatement\":\n walkExpression(stmt.expression, library, out);\n return;\n case \"ComponentDeclaration\":\n case \"ActionDeclaration\":\n case \"EffectDeclaration\":\n case \"HookDeclaration\":\n for (const inner of stmt.body.body) walkStatement(inner, library, out);\n return;\n case \"Return\":\n if (stmt.argument) walkExpression(stmt.argument, library, out);\n return;\n case \"Await\":\n walkExpression(stmt.argument, library, out);\n return;\n case \"IfStatement\":\n walkExpression(stmt.test, library, out);\n for (const inner of stmt.consequent.body) walkStatement(inner, library, out);\n if (stmt.alternate) {\n if (stmt.alternate.kind === \"IfStatement\") {\n walkStatement(stmt.alternate, library, out);\n } else {\n for (const inner of stmt.alternate.body) walkStatement(inner, library, out);\n }\n }\n return;\n case \"SwitchStatement\":\n walkExpression(stmt.discriminant, library, out);\n for (const c of stmt.cases) {\n if (c.test) walkExpression(c.test, library, out);\n for (const inner of c.body) walkStatement(inner, library, out);\n }\n return;\n case \"ForOfStatement\":\n walkExpression(stmt.iterable, library, out);\n for (const inner of stmt.body.body) walkStatement(inner, library, out);\n return;\n case \"ForClassicStatement\":\n if (stmt.init) walkStatement(stmt.init, library, out);\n if (stmt.test) walkExpression(stmt.test, library, out);\n if (stmt.update) walkExpression(stmt.update, library, out);\n for (const inner of stmt.body.body) walkStatement(inner, library, out);\n return;\n case \"WhileStatement\":\n case \"DoWhileStatement\":\n walkExpression(stmt.test, library, out);\n for (const inner of stmt.body.body) walkStatement(inner, library, out);\n return;\n case \"ForInStatement\":\n walkExpression(stmt.iterable, library, out);\n for (const inner of stmt.body.body) walkStatement(inner, library, out);\n return;\n case \"DestructureStatement\":\n walkExpression(stmt.expression, library, out);\n for (const binding of stmt.bindings) {\n if (binding.defaultValue) walkExpression(binding.defaultValue, library, out);\n }\n return;\n case \"TryStatement\":\n for (const inner of stmt.block.body) walkStatement(inner, library, out);\n if (stmt.catchBlock) for (const inner of stmt.catchBlock.body) walkStatement(inner, library, out);\n if (stmt.finallyBlock) for (const inner of stmt.finallyBlock.body) walkStatement(inner, library, out);\n return;\n case \"ThrowStatement\":\n walkExpression(stmt.argument, library, out);\n return;\n default:\n return;\n }\n}\n\nfunction walkExpression(\n expr: Expression,\n library: ComponentLibrary,\n out: ParseError[],\n): void {\n if (!expr) return;\n switch (expr.kind) {\n case \"Call\": {\n validateCall(expr, library, out);\n for (const arg of expr.arguments) walkExpression(arg, library, out);\n return;\n }\n case \"MethodCall\": {\n // Method calls on namespace globals (`storage.set`, `console.log`,\n // resource bag callables like `$res.refetch()`) are validated at\n // runtime — the schema validator just walks the children.\n walkExpression(expr.object, library, out);\n for (const arg of expr.arguments) walkExpression(arg, library, out);\n return;\n }\n case \"BuiltinCall\": {\n // Synthetic `__rui_*` nodes only — user-facing `Util.name(...)` syntax\n // was removed. Just walk arguments.\n for (const arg of expr.arguments) walkExpression(arg, library, out);\n return;\n }\n case \"Array\":\n for (const e of expr.elements) walkExpression(e, library, out);\n return;\n case \"Object\":\n for (const prop of expr.properties) walkExpression(prop.value, library, out);\n return;\n case \"Template\":\n for (const e of expr.expressions) walkExpression(e, library, out);\n return;\n case \"Binary\":\n walkExpression(expr.left, library, out);\n walkExpression(expr.right, library, out);\n return;\n case \"Unary\":\n walkExpression(expr.argument, library, out);\n return;\n case \"Ternary\":\n walkExpression(expr.test, library, out);\n walkExpression(expr.consequent, library, out);\n walkExpression(expr.alternate, library, out);\n return;\n case \"Member\":\n walkExpression(expr.object, library, out);\n if (expr.computed) walkExpression(expr.computed, library, out);\n return;\n case \"Spread\":\n walkExpression(expr.argument, library, out);\n return;\n case \"Invoke\":\n // `$theme({...})` is an Invoke on a StateRef — validate its token shape\n // here (the `expr.callee === \"Theme\"` Call path no longer fires).\n if (expr.callee.kind === \"StateRef\" && expr.callee.name === \"theme\") {\n validateThemeCall(expr, out);\n }\n walkExpression(expr.callee, library, out);\n for (const arg of expr.arguments) walkExpression(arg, library, out);\n return;\n case \"New\":\n walkExpression(expr.callee, library, out);\n for (const arg of expr.arguments) walkExpression(arg, library, out);\n return;\n case \"Lambda\":\n if (expr.body.kind === \"Block\") {\n for (const inner of expr.body.body) walkStatement(inner, library, out);\n } else {\n walkExpression(expr.body, library, out);\n }\n return;\n case \"Block\":\n for (const inner of expr.body) walkStatement(inner, library, out);\n return;\n default:\n return;\n }\n}\n\n/**\n * Appendix-A legacy call sites. Each entry is a v1 form that the 0.5\n * surface explicitly removed (see `language-update-final.md`,\n * Appendix A). The parser accepts the *syntax* (a call expression is\n * syntactically fine), so without an explicit guard here the runtime\n * would silently render `null` and the author would have no signal\n * that the code is rejected. The error message points at the canonical\n * 0.5 replacement.\n */\nconst LEGACY_V1_CALLS: Record<string, string> = {\n Script:\n `Script(\"id\", body, deps?) is not supported. Use \\`$effect(() => { … }, [deps])\\` (see §9 — effect declarations).`,\n Action:\n `Action([@Set, @Run, …]) payloads are removed in 0.5. Use \\`function name() { … }\\` declarations and reference them by name (e.g. \\`Button(\"Save\", { action: save })\\`) — see §10.`,\n Routes:\n `Routes(items, default?) is removed in 0.5. Use \\`pages = $router({ \"/\": Home(), default: NotFound() })\\` (see §12 — outlet-first router).`,\n Route:\n `Route(path, content) is only valid inside a v1 \\`Routes(...)\\` outlet, which has been removed. Use \\`\"/path\": content\\` arms inside a \\`$router({ … })\\` call (see §12).`,\n Query:\n `Query(\"name\", args, placeholder, refreshSec?) is removed in 0.5. Declare a top-level \\`query <Name>(args) { url, method, … }\\` block and bind it with \\`$query foo = <Name>(args)\\` (see §11.2).`,\n Mutation:\n `Mutation(\"name\", args) is removed in 0.5. Declare a top-level \\`mutation <Name>(args) { url, method, body, … }\\` block and bind it with \\`$mutation save = <Name>\\` (see §11.3).`,\n NavLinkRoute:\n `NavLinkRoute is removed in 0.5. Use \\`NavLink(label, { to: \"/path\" })\\` (see §12 — Outlet-first router).`,\n useInstanceState:\n `useInstanceState(...) is removed in 0.5. Declare per-instance state inside the component body with \\`$state name = init\\` — identity is content-addressed (§13).`,\n};\n\nfunction validateCall(\n expr: Extract<Expression, { kind: \"Call\" }>,\n library: ComponentLibrary,\n out: ParseError[],\n): void {\n const legacy = LEGACY_V1_CALLS[expr.callee];\n if (legacy) {\n out.push({\n message: `${expr.callee}(...) — ${legacy}`,\n line: expr.loc?.line ?? 0,\n column: expr.loc?.column ?? 0,\n });\n return;\n }\n if (expr.callee === \"Theme\") {\n validateThemeCall(expr, out);\n return;\n }\n const spec = findComponent(library, expr.callee);\n if (!spec) return; // User-declared or unknown — skip silently.\n const propNames = new Set<string>();\n for (const p of spec.props) {\n propNames.add(p.name);\n if (p.aliases) {\n for (const alias of p.aliases) propNames.add(alias);\n }\n }\n // Allow `key:` everywhere (content-addressed identity, §13).\n propNames.add(\"key\");\n\n // Detect the named-props ObjectExpr (JS-style props: `Button(\"Save\", { variant: \"primary\" })`).\n // We accept the *last* ObjectExpr in the argument list so leading\n // props (`Grid({ cols: 12 }, [children])`) and trailing props\n // (`Button(\"Hi\", { onClick })`) both validate consistently.\n const args = expr.arguments;\n let trailingObjIdx = -1;\n for (let i = args.length - 1; i >= 0; i -= 1) {\n if (args[i]!.kind === \"Object\") {\n trailingObjIdx = i;\n break;\n }\n }\n const trailingObj =\n trailingObjIdx >= 0\n ? (args[trailingObjIdx] as Extract<Expression, { kind: \"Object\" }>)\n : null;\n\n const positionalArgs: Expression[] = [];\n for (let i = 0; i < args.length; i++) {\n if (i === trailingObjIdx) continue;\n positionalArgs.push(args[i]!);\n }\n if (positionalArgs.length > 1) {\n const positionalProp = findPositionalProp(spec);\n const positionalName = positionalProp?.name ?? \"(none)\";\n const namedNames = collectNamedPropNames(args, trailingObj);\n const extras = spec.props\n .filter((p) => p.name !== positionalName && !namedNames.has(p.name))\n .slice(0, positionalArgs.length - 1)\n .map((p) => p.name);\n const hints = extras.length > 0\n ? extras.map((n) => `${n}: …`).join(\", \")\n : \"use a trailing { prop: value } object\";\n out.push({\n message:\n `${expr.callee}(...) — Aktion 0.5 §19.1 allows at most ` +\n `one positional argument (the \"${positionalName}\" prop). The extra ` +\n `${positionalArgs.length - 1} positional argument(s) must be passed ` +\n `inside a trailing object: ${hints}. Multi-positional calls are removed.`,\n line: expr.loc?.line ?? 0,\n column: expr.loc?.column ?? 0,\n });\n }\n\n // Collect named entries from trailing Object properties.\n const namedEntries: Array<{ name: string; value: Expression; loc?: { line: number; column: number } }> = [];\n if (trailingObj) {\n for (const prop of trailingObj.properties) {\n if (prop.spread) continue;\n namedEntries.push({\n name: prop.key,\n value: prop.value,\n loc: prop.value.loc ?? trailingObj.loc,\n });\n }\n }\n\n for (const entry of namedEntries) {\n if (!propNames.has(entry.name)) {\n out.push({\n message: `Unknown prop \"${entry.name}\" on <${expr.callee}>. Known props: ${spec.props.map((p) => p.name).join(\", \")}.`,\n line: entry.loc?.line ?? expr.loc?.line ?? 0,\n column: entry.loc?.column ?? expr.loc?.column ?? 0,\n });\n continue;\n }\n const prop = spec.props.find(\n (p) => p.name === entry.name || (p.aliases?.includes(entry.name) ?? false),\n );\n if (prop?.enum && entry.value.kind === \"Literal\" && typeof entry.value.value === \"string\") {\n const value = entry.value.value;\n if (!prop.enum.includes(value)) {\n out.push({\n message: `<${expr.callee}> ${entry.name}=\"${value}\" — must be one of ${prop.enum.map((v) => `\"${v}\"`).join(\", \")}.`,\n line: entry.loc?.line ?? expr.loc?.line ?? 0,\n column: entry.loc?.column ?? expr.loc?.column ?? 0,\n });\n }\n }\n }\n}\n\nfunction collectNamedPropNames(\n _args: ReadonlyArray<Expression>,\n trailingObj: Extract<Expression, { kind: \"Object\" }> | null,\n): Set<string> {\n const names = new Set<string>();\n if (trailingObj) {\n for (const prop of trailingObj.properties) {\n if (!prop.spread) names.add(prop.key);\n }\n }\n return names;\n}\n\n/**\n * Theme token validation (§16).\n *\n * SUIS/2 only accepts the structured form:\n *\n * $theme({ name?, direction?, colors: {...}, radius: {...},\n * font: {...}, motion: {...}, elevation: {...} })\n *\n * Any other top-level key is either a legacy flat-shape token\n * (`colorPrimary`, `radiusMd`) or a free-form CSS variable\n * (`--color-x`). Both forms surface as advisory warnings so the runtime\n * can keep streaming partial themes without crashing.\n */\nconst STRUCTURED_THEME_GROUPS = new Set([\"colors\", \"radius\", \"font\", \"motion\", \"elevation\"]);\nconst THEME_METADATA_KEYS = new Set([\"name\", \"direction\"]);\n\nfunction validateThemeCall(\n expr: { arguments: ReadonlyArray<Expression>; loc?: { line: number; column: number } },\n out: ParseError[],\n): void {\n const arg = expr.arguments[0];\n if (!arg || arg.kind !== \"Object\") return;\n for (const prop of arg.properties) {\n if (prop.spread) continue;\n if (STRUCTURED_THEME_GROUPS.has(prop.key)) continue;\n if (THEME_METADATA_KEYS.has(prop.key)) continue;\n const suggestion = suggestStructuredKey(prop.key);\n const message = prop.key.startsWith(\"--\")\n ? `$theme({\"${prop.key}\": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`\n : `$theme({${prop.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${suggestion}.`;\n out.push({\n message,\n line: expr.loc?.line ?? 0,\n column: expr.loc?.column ?? 0,\n });\n }\n}\n\nfunction suggestStructuredKey(flatKey: string): string {\n // `colorPrimary` -> `colors: { primary: ... }`\n // `radiusMd` -> `radius: { md: ... }`\n // `fontHeading` -> `font: { heading: ... }`\n // `motionSlow` -> `motion: { slow: ... }`\n // `elevation2` -> `elevation: { 2: ... }`\n const groups: Array<{ prefix: string; group: string }> = [\n { prefix: \"color\", group: \"colors\" },\n { prefix: \"radius\", group: \"radius\" },\n { prefix: \"font\", group: \"font\" },\n { prefix: \"motion\", group: \"motion\" },\n { prefix: \"elevation\", group: \"elevation\" },\n ];\n for (const { prefix, group } of groups) {\n if (flatKey === prefix) continue;\n if (flatKey.startsWith(prefix) && flatKey.length > prefix.length) {\n const tail = flatKey.slice(prefix.length);\n const inner = tail.charAt(0).toLowerCase() + tail.slice(1);\n return `$theme({ ${group}: { ${inner}: ... } })`;\n }\n }\n return `$theme({ colors: {...}, radius: {...}, font: {...}, motion: {...}, elevation: {...} })`;\n}\n","/**\n * Built-in component library for `<aktion-app>`.\n *\n * Exports a single `defaultLibrary` that ships with the package. Consumers can\n * extend it via `<aktion-app>.registerComponents([...])`.\n */\n\nimport { assertOnePositionalMax } from \"./types.js\";\nimport type { ComponentLibrary, ComponentSpec, ComponentGroup } from \"./types.js\";\nimport {\n Stack, StackItem, Row, Column, Center, Grid, GridItem, Box, Card, CardHeader, CardFooter, Separator,\n Tabs, TabItem, Accordion, AccordionItem, Modal, Steps,\n AspectRatio, ScrollArea,\n} from \"./components/layout.js\";\nimport {\n Text, TextContent, Image, Badge, BadgeList,\n Callout, CodeBlock, Skeleton, Markdown,\n Container, Spacer, Quote, Icon, Spinner,\n} from \"./components/content.js\";\nimport {\n Form, FormControl, Input, TextArea, Select, SelectItem, Checkbox,\n CheckBoxGroup, CheckBoxItem, Radio, Button, Buttons, SearchBar,\n Slider, NumberInput, DatePicker, FileUpload, Combobox,\n MultiSelect, DateRangePicker,\n} from \"./components/forms.js\";\nimport {\n Table, Col, List, ListItem, StatCard, Tree, TreeNode, Sparkline,\n} from \"./components/data.js\";\nimport { BarChart, LineChart, PieChart, Series } from \"./components/charts.js\";\nimport {\n SectionBlock, ListBlock, FollowUpBlock, FollowUpItem, ActionLink,\n} from \"./components/chat.js\";\nimport {\n Avatar, AvatarGroup, Progress, Switch, ToggleGroup,\n Tooltip, HoverCard, Popover, Toast, Kbd, Rating, ProgressRing, ChatBubble,\n} from \"./components/feedback.js\";\nimport {\n Breadcrumb, BreadcrumbItem, Pagination, Navbar, NavbarItem,\n} from \"./components/navigation.js\";\nimport {\n DropdownMenu, MenuItem, MenuSeparator, MenuLabel,\n} from \"./components/menu.js\";\nimport {\n Hero, PageHeader, EmptyState,\n Timeline, TimelineItem, FeatureGrid, FeatureItem,\n Testimonial, ProfileCard, Comment, Banner,\n KanbanBoard, KanbanColumn, KanbanCard,\n SectionHeader, Toolbar, Sidebar, SidebarSection, SidebarItem,\n AppShell, SplitView, DescriptionList, DescriptionItem,\n StatusDot, PricingTable, PricingCard,\n MediaCard, Stats, Tile, Notification, PersonChip,\n} from \"./components/patterns.js\";\nimport {\n DataGrid, CalendarView, ActivityLog, ComparisonTable, InfiniteList,\n} from \"./components/advanced-data.js\";\nimport {\n VideoPlayer, AudioPlayer, Carousel, Gallery, Lightbox, Map,\n} from \"./components/media.js\";\nimport {\n RichTextEditor, CodeEditor, ContextMenu, ColorPicker,\n} from \"./components/editors.js\";\nimport {\n Gauge, Heatmap, RadarChart, ScatterChart, Histogram,\n} from \"./components/advanced-charts.js\";\nimport {\n PinInput, PasswordInput, TagInput, MentionInput,\n TimePicker, DateTimePicker, MaskedInput,\n FormSection, FieldSet, ValidationSummary, MultiStepForm,\n} from \"./components/advanced-forms.js\";\nimport {\n InboxPanel, OnboardingChecklist, LoadingState, ErrorState, SuccessState,\n Tour, Spotlight, Sticky, ResizablePanels, MasonryGrid, Drawer, TopBar,\n} from \"./components/advanced-patterns.js\";\nimport { Theme } from \"./components/theme.js\";\nimport { NavLink } from \"./components/router.js\";\nimport {\n IconButton, CommandPalette, FilterChips, FieldRepeater,\n VirtualList, QueryBuilder, DiffViewer, JsonTree, Gantt,\n Truncate, InlineEdit, NotificationBell,\n} from \"./components/new-components.js\";\nimport {\n Async, Show, Portal, Redirect, Lazy, ErrorBoundary,\n} from \"./components/helpers.js\";\nimport { HTMLTag, Styles } from \"./components/escape-hatch.js\";\nimport {\n OnClick, OnMouse, OnKeyboard, OnFocus, OnIntersect, Css, Link,\n} from \"./components/wrappers.js\";\n\nexport * from \"./types.js\";\nexport * from \"./registry.js\";\nexport { validateProgramSchema, validateProgram } from \"./validate.js\";\n\nconst components: ComponentSpec[] = [\n Row, Column, Center, Stack, StackItem, Grid, GridItem, Box, Card, CardHeader, CardFooter, Separator,\n Tabs, TabItem, Accordion, AccordionItem, Modal, Steps,\n AspectRatio, ScrollArea, Container, Spacer,\n Text, TextContent, Image, Link, Badge, BadgeList,\n Callout, CodeBlock, Skeleton, Markdown, Quote, Icon, Spinner,\n Form, FormControl, Input, TextArea, Select, SelectItem, Checkbox,\n CheckBoxGroup, CheckBoxItem, Radio, Button, Buttons, SearchBar,\n Slider, NumberInput, DatePicker, FileUpload, Combobox,\n MultiSelect, DateRangePicker,\n Table, Col, List, ListItem, StatCard, Sparkline, Tree, TreeNode,\n BarChart, LineChart, PieChart, Series,\n SectionBlock, ListBlock, FollowUpBlock, FollowUpItem, ActionLink, ChatBubble,\n Avatar, AvatarGroup, Progress, ProgressRing, Switch, ToggleGroup,\n Tooltip, HoverCard, Popover, Toast, Kbd, Rating,\n Breadcrumb, BreadcrumbItem, Pagination, Navbar, NavbarItem,\n DropdownMenu, MenuItem, MenuSeparator, MenuLabel,\n Hero, PageHeader, Stats, Tile, EmptyState,\n Timeline, TimelineItem, FeatureGrid, FeatureItem,\n Testimonial, ProfileCard, PersonChip, Comment, Banner, Notification,\n MediaCard, KanbanBoard, KanbanColumn, KanbanCard,\n SectionHeader, Toolbar, Sidebar, SidebarSection, SidebarItem,\n AppShell, SplitView, DescriptionList, DescriptionItem,\n StatusDot, PricingTable, PricingCard,\n // Advanced data\n DataGrid, CalendarView, ActivityLog, ComparisonTable, InfiniteList,\n // Media\n VideoPlayer, AudioPlayer, Carousel, Gallery, Lightbox, Map,\n // Editors\n RichTextEditor, CodeEditor, ContextMenu, ColorPicker,\n // More charts\n Gauge, Heatmap, RadarChart, ScatterChart, Histogram,\n // Advanced forms\n PinInput, PasswordInput, TagInput, MentionInput,\n TimePicker, DateTimePicker, MaskedInput,\n FormSection, FieldSet, ValidationSummary, MultiStepForm,\n // Advanced patterns + state cards\n InboxPanel, OnboardingChecklist, LoadingState, ErrorState, SuccessState,\n Tour, Spotlight, Sticky, ResizablePanels, MasonryGrid, Drawer, TopBar,\n Theme,\n NavLink,\n IconButton, CommandPalette, FilterChips, FieldRepeater,\n VirtualList, QueryBuilder, DiffViewer, JsonTree, Gantt,\n Truncate, InlineEdit, NotificationBell,\n // Aktion 0.5 standard helpers\n Async, Show, Portal, Redirect, Lazy, ErrorBoundary,\n // Behavioural & styling wrappers\n OnClick, OnMouse, OnKeyboard, OnFocus, OnIntersect, Css, Link,\n // Escape hatches for raw HTML / CSS — last-resort primitives\n HTMLTag, Styles,\n];\n\nconst componentGroups: ComponentGroup[] = [\n {\n name: \"Layout\",\n components: [\n \"Column\", \"Row\", \"Center\", \"Stack\", \"StackItem\", \"Grid\", \"GridItem\",\n \"Box\", \"Container\", \"Spacer\",\n \"Card\", \"CardHeader\", \"CardFooter\", \"Separator\", \"Tabs\", \"TabItem\",\n \"Accordion\", \"AccordionItem\", \"Modal\", \"Drawer\", \"Steps\",\n \"AspectRatio\", \"ScrollArea\", \"Sticky\", \"ResizablePanels\", \"MasonryGrid\",\n ],\n notes: [\n \"- THREE primitives cover almost everything: `Column` (stack top→bottom), `Row` (left→right), and `Grid` (equal columns / card walls). Reach for these first.\",\n \"- `root` is normally a `Column([...])` (or `Container([...])` for a centered page). A `Column` is the page body; put each major chunk in a `Card(...)`.\",\n \"- `Row([...])` keeps children at their natural width and vertically centered — ideal for toolbars, button rows, label+value pairs, nav bars. Use `justify` to distribute (`between`, `center`, `end`) and `gap` for spacing.\",\n \"- `Grid([...], { columns: N })` = N equal columns. Omit `columns` for auto-fit (wraps as many ≥`minChildWidth` columns as fit — best for KPI/card grids). Prefer `Grid` over a wrapping `Row` whenever cells should share a width.\",\n \"- For a 12-column dashboard / sidebar layout use `GridItem` spans: `Grid([GridItem(side, { span: \\\"1/4\\\" }), GridItem(main, { span: \\\"3/4\\\" })])`. Fractions `\\\"1/2\\\"`…`\\\"1/12\\\"` (or numbers 1–12) resolve on a 12-track grid; any `GridItem` child turns the grid on automatically.\",\n \"- `Center([...], { minHeight })` centers content on both axes — spinners, empty states, hero CTAs, modal bodies. Add `minHeight: \\\"60vh\\\"` to center vertically in a region.\",\n \"- `Stack` is the responsive escape hatch: use it ONLY when the direction itself must change across breakpoints, e.g. `Stack([...], { direction: {base: \\\"column\\\", md: \\\"row\\\"} })`.\",\n \"- Make one child in a `Row` expand with `StackItem(child, { grow: 1 })` (e.g. a search input beside a fixed button), or push items apart with a bare `Spacer()` between them.\",\n \"- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.\",\n \"- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.\",\n \"- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered \\\"OR\\\"-style divider.\",\n \"- `gap`/`padding` spacing tokens are `xs|s|m|l|xl`; `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.\",\n \"- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls.\",\n ],\n },\n {\n name: \"Content\",\n components: [\n \"Text\", \"Image\", \"Badge\", \"BadgeList\",\n \"Callout\", \"Quote\", \"CodeBlock\", \"Skeleton\", \"Spinner\",\n \"Markdown\", \"Kbd\", \"Icon\",\n ],\n notes: [\n \"- Prefer `Markdown(...)` for rich paragraph text with inline formatting — the parser supports headings, blockquotes, fenced code, numbered/bullet lists, links, images, and bare-URL auto-linking.\",\n \"- Use `Callout(variant, title, description, icon?, compact?)` for highlighted notices; pass `compact: true` for a one-line inline note.\",\n \"- Use `Quote(text, cite?)` for inline pull-quotes inside articles and marketing sections (use `Testimonial` when you also have author/role/rating).\",\n \"- Use `CodeBlock(language, codeString, showLineNumbers?, highlightLines?)` for read-only code snippets. The header always renders a copy-to-clipboard button.\",\n \"- Use `Badge(label, variant?, icon?, size?)` for a single pill and `BadgeList([\\\"a\\\",\\\"b\\\",\\\"c\\\"], variant?, size?)` to render an array of strings as Badge pills.\",\n \"- Use `Skeleton(variant?, lines?, height?, shape?, width?)` for loading placeholders; `variant` accepts `paragraph` (default), `card`, `table-row`, `avatar`, `image`.\",\n \"- Use `Spinner(size?, label?, tone?)` for tiny inline loading indicators inside buttons, toolbars, or table cells.\",\n \"- Use `Image(src, alt?, caption?, ratio?, fit?, fallback?)` — `ratio` (e.g. `\\\"16:9\\\"`) makes the image self-constrain so you do not need an outer `AspectRatio`.\",\n \"- Use `Kbd([\\\"Cmd\\\", \\\"K\\\"])` when referring to keyboard shortcuts.\",\n \"- Use `Icon(name, variant?, size?)` to render a standalone Font Awesome icon (`name` is the FA name without the `fa-` prefix, e.g. `\\\"house\\\"`, `\\\"chart-line\\\"`, `\\\"regular:star\\\"`, `\\\"brands:github\\\"`).\",\n \"- For page-level titles reach for `PageHeader(...)` (top of dashboards/detail pages) or `SectionHeader(...)` (inside a Card). For tiny inline titles use `Text(value, variant=\\\"large-heavy\\\")`.\",\n ],\n },\n {\n name: \"Forms\",\n components: [\n \"Form\", \"FormControl\", \"FormSection\", \"FieldSet\", \"ValidationSummary\",\n \"Input\", \"TextArea\", \"PasswordInput\", \"MaskedInput\", \"MentionInput\", \"TagInput\",\n \"Select\", \"SelectItem\", \"Combobox\", \"MultiSelect\",\n \"Checkbox\", \"CheckBoxGroup\", \"CheckBoxItem\", \"Radio\", \"Switch\",\n \"ToggleGroup\", \"Button\", \"Buttons\", \"SearchBar\",\n \"Slider\", \"NumberInput\", \"ColorPicker\",\n \"DatePicker\", \"DateRangePicker\", \"TimePicker\", \"DateTimePicker\",\n \"FileUpload\", \"PinInput\",\n \"MultiStepForm\",\n ],\n notes: [\n \"- Each FormControl should be a separate reference for progressive streaming.\",\n \"- Pass a `$variable` as the last argument to `Input`, `Select`, `Checkbox`, `Switch`, `MultiSelect`, or `CheckBoxGroup` for two-way binding.\",\n \"- Prefer `Switch` over `Checkbox` for settings; use `ToggleGroup` for view-mode pickers and mutually-exclusive filters.\",\n \"- Reach for `SearchBar(id, placeholder?, value?, shortcut?)` instead of a raw `Input` whenever the field's purpose is to filter content. It ships with the magnifier icon and keyboard hint baked in.\",\n \"- `Slider(id, min?, max?, step?, value?, label?, showValue?)` is the canonical control for numeric ranges (volume, brightness, filters); pass a `$variable` as `value` for two-way binding.\",\n \"- `NumberInput(id, value?, min?, max?, step?, placeholder?)` is friendlier than `Input(type=\\\"number\\\")` for quantity steppers and integer settings — it ships with +/- buttons that respect `min`/`max`.\",\n \"- `DatePicker(id, value?, label?, min?, max?, placeholder?)` wraps the native date picker; pass `value` as a `$variable` for two-way binding (ISO `YYYY-MM-DD`).\",\n \"- `DateRangePicker(id, from?, to?, label?, min?, max?)` is the paired-date variant — bind both `from` and `to` to `$variable`s for a single shared range.\",\n \"- `Combobox(id, items, value?, placeholder?, emptyLabel?)` is the searchable single-select alternative to `Select` — type to filter long option lists (countries, currencies, users).\",\n \"- `MultiSelect(id, items, value?, placeholder?, emptyLabel?, max?)` is the multi-select equivalent — bind a `$variable` array as `value` for two-way binding, the trigger renders the picks as removable chips.\",\n \"- `FileUpload(id, { label?, hint?, accept?, multiple?, action? })` is the styled file picker; the picked files cannot pass through a `$variable`, so wire the `action` prop to a `function` declaration.\",\n \"- A submit button should call an `action` that awaits the relevant `$mutation` resource, optionally refetches a `$query`, and resets the form `$variable`s (e.g. `$title = \\\"\\\"`).\",\n \"- Button `size` accepts both `sm|md|lg` (canonical) and the legacy `small|normal|large`. Pass `icon` for an inline leading icon.\",\n \"- `FormSection(label, children, helper?)` is the canonical wrapper for related fields. Reach for it INSTEAD of nesting fields in Card + SectionHeader by hand.\",\n \"- `FieldSet(legend, children, helper?)` is the accessible `<fieldset>` for radio/checkbox groups; prefer `FormSection` for purely visual grouping.\",\n \"- `ValidationSummary(errors, title?)` renders an aggregate error panel at the top of the form. Pass `errors` as `{label, message}` objects.\",\n \"- `PasswordInput(id, value?, placeholder?, strengthMeter?)` adds a show/hide toggle and an optional 4-step strength meter — prefer over `Input(type=\\\"password\\\")` for sign-up flows.\",\n \"- `PinInput(id, length?, value?, type?)` renders per-digit code entry for 2FA / SMS verification (use `length=6` for OTP codes).\",\n \"- `TagInput(id, value?, placeholder?)` lets the user add comma- or Enter-separated chips bound to a `$variable` array.\",\n \"- `MentionInput(id, people, value?)` is a textarea with inline @-mention suggestions — use for comments, task notes, chat composers.\",\n \"- `MaskedInput(id, mask, value?)` formats input against a mask string (`9` digit, `A` letter, `*` any). Use for phone numbers, postal codes.\",\n \"- `TimePicker(id, value?)` and `DateTimePicker(id, value?)` wrap the corresponding native inputs with consistent styling.\",\n \"- `ColorPicker(id, value?, label?, swatches?)` pairs a color chip with a hex input and preset swatches — bind a $variable holding a hex string.\",\n \"- `MultiStepForm(steps, current, onSubmit?)` replaces ad-hoc `Steps` + content + manual prev/next wiring. Each step is `{title, details?, content}`.\",\n ],\n },\n {\n name: \"Data\",\n components: [\"Table\", \"Col\", \"DataGrid\", \"List\", \"ListItem\", \"StatCard\", \"Stats\", \"Sparkline\", \"Tile\", \"Progress\", \"ProgressRing\", \"Pagination\", \"Tree\", \"TreeNode\", \"CalendarView\", \"ComparisonTable\", \"InfiniteList\"],\n notes: [\n \"- Build columns using array pluck: `Col(\\\"Title\\\", data.rows.title, format?, align?)`.\",\n \"- For per-row controls inside a Col, use `for (let row of data.rows) { ... }` and reference `row.field` inline.\",\n \"- `Table(cols, caption?, density?, striped?, sticky?, emptyLabel?)` — pass `density=\\\"compact\\\"` for dense data, `sticky=true` to pin the header in a scrolling parent, and `emptyLabel` for the zero-state cell.\",\n \"- `DataGrid(cols, rowIds?, caption?, sort, selectedIds, selectable?, page, perPage?, …)` is the advanced Table — adds sortable headers (`sortable=true` on Col), per-column filter chips (`filterable=true`), checkbox row selection bound to `$selectedIds`, sticky header / first column, pagination, and an optional bulk-action toolbar. Reach for this whenever a user needs to sort, filter, or page through a list.\",\n \"- `CalendarView(value?, month?, events?, view?, firstDay?, onSelect?)` renders a full-month (or week) calendar grid for scheduling apps — distinct from the `DatePicker` input. Bind `value` to a `$variable` for the selected ISO date.\",\n \"- `ComparisonTable(columns, rows, highlightColumn?)` is the generic counterpart of `PricingTable` — pass rows of `{label, values, hint?, group?}`. Use for feature comparisons, spec sheets, plan grids.\",\n \"- `InfiniteList(items, onLoadMore?, loading?, hasMore?)` is a scroll-to-load list; the action fires when the sentinel scrolls into view.\",\n \"- Use `Progress(value, max?, label?, tone?, indeterminate?, segments?, buffered?)` for linear bars — `segments` renders an N-step strip (onboarding flows), `buffered` adds a secondary buffer indicator.\",\n \"- `ProgressRing(value, max?, label?, tone?, size?)` is the circular variant for quotas/completion.\",\n \"- `Stats([{label, value, hint?, tone?, spark?}, …], layout?)` — `layout=\\\"strip\\\"` (default) for inline KPIs; `layout=\\\"grid\\\"` for a responsive StatCard grid. Pass `spark` for an inline trend line.\",\n \"- `StatCard(label, value, trend?, delta?, icon?, spark?, tone?)` gains an optional inline `Sparkline` via the `spark` prop. Use `Sparkline(values, tone?)` standalone for tiny trend chips in table cells.\",\n \"- `Tile(label, icon?, value?, description?, tone?, action?)` is the dense icon tile for quick-action menus and category grids; pair with `Grid` for uniform rows.\",\n \"- `Tree([TreeNode(label, children?, icon?, expanded?, active?, badge?, action?)])` renders a hierarchical tree (file browsers, nested navigation, category pickers); use `expanded=true` to open a branch by default.\",\n \"- `Pagination(page, totalPages, siblings?, total?, perPage?, perPageOptions?, compact?)` — bind `page` (and optionally `perPage`) to a `$variable`; pass `total` to render the \\\"Showing N–M of T\\\" summary. Reuse the same variable when slicing data with `arr.filter(...)` / `for`.\",\n ],\n },\n {\n name: \"Charts\",\n components: [\n \"BarChart\", \"LineChart\", \"PieChart\", \"RadarChart\",\n \"ScatterChart\", \"Histogram\", \"Heatmap\", \"Gauge\", \"Series\",\n ],\n notes: [\n \"- Use `LineChart` for trends (pass `filled=true` for area-style charts), `BarChart` for comparisons, `PieChart` for proportions, `RadarChart` for multi-axis scorecards.\",\n \"- `Heatmap(xLabels, yLabels, values)` renders a color-intensity matrix — perfect for calendar heatmaps, correlation grids, schedule density.\",\n \"- `ScatterChart(series, xLabel?, yLabel?)` plots XY points; pass each Series as `Series(name, points)` where points are `{x, y, label?}`.\",\n \"- `Histogram(values, binCount?)` bins raw numbers; pass pre-computed `bins=[{label, count}]` instead when you control the bucketing.\",\n \"- `Gauge(value, min?, max?, label?, tone?, size?)` is the half-doughnut KPI indicator for thresholds (uptime %, score, NPS).\",\n \"- Pass series via `Series(\\\"Name\\\", [...numbers])`.\",\n ],\n },\n {\n name: \"Feedback & Media\",\n components: [\n \"Avatar\", \"AvatarGroup\", \"PersonChip\", \"Tooltip\", \"HoverCard\", \"Popover\",\n \"Rating\", \"Toast\",\n \"VideoPlayer\", \"AudioPlayer\", \"Carousel\", \"Gallery\", \"Lightbox\", \"Map\",\n ],\n notes: [\n \"- `Avatar(name, src?, size?, status?)` falls back to initials when the image is missing.\",\n \"- Use `AvatarGroup` to render contributor strips with a `+N` overflow chip.\",\n \"- `PersonChip(name, role?, avatarSrc?, size?, status?, action?)` is the inline avatar + name + role pill — use everywhere a person is referenced (table cells, list rows, sidebar footers, kanban cards) instead of a raw `Avatar` next to `Text`.\",\n \"- Wrap any node in `Tooltip(label, trigger)` for inline hints.\",\n \"- Use `HoverCard(trigger, content)` when the popover needs rich content (profile preview, link target) and the trigger should open on hover.\",\n \"- `Popover(trigger, content, title?, side?, align?, width?)` is the click-triggered counterpart of `HoverCard` — use for filter panels, color pickers, share menus, and small settings flyouts. Always renders an × close button in the header; clicking the trigger again, clicking outside, or pressing Escape also closes it.\",\n \"- `Rating(value, max?, label?, count?, size?, interactive?, halfStep?, icon?)` renders stars for product reviews, testimonials, and ranked lists. Pass a `$variable` as `value` with `interactive=true` to let users rate; add `halfStep=true` so clicking the left half of a star sets a half-value. Set `icon=\\\"heart\\\"|\\\"thumb\\\"|\\\"fire\\\"|\\\"bolt\\\"` (or any FA name) to swap glyphs.\",\n \"- `Toast(title, message?, tone?, icon?, duration?, action?, onClose?, position?)` pins a transient notice; pass `duration` (ms) for auto-dismiss. Drive lists from an `action` body: `$toasts = [...$toasts, item]` to append and `$toasts = $toasts.filter((t) => t.id !== id)` to dismiss. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.\",\n \"- `NotificationBell(count?, items?, onOpen?)` — compact inbox trigger; `CommandPalette` for Cmd-K action search.\",\n ],\n },\n {\n name: \"Navigation\",\n components: [\"Breadcrumb\", \"BreadcrumbItem\", \"Navbar\", \"NavbarItem\", \"DropdownMenu\", \"MenuItem\", \"MenuSeparator\", \"MenuLabel\"],\n notes: [\n \"- Use `Breadcrumb([\\\"Workspace\\\", \\\"Reports\\\", \\\"Q3\\\"])` at the top of every detail page so users see the path.\",\n \"- For per-item links, pass `BreadcrumbItem(label, href)` nodes instead of strings.\",\n \"- `Navbar(brand?, items?, actions?, sticky?, variant?)` + `NavbarItem(label, to?, href?, icon?, active?, action?, external?)` produces a top navigation bar with brand on the left, links in the middle, and actions on the right — the canonical companion of `Sidebar` for marketing pages, docs, or any product surface without left-side nav.\",\n \"- `DropdownMenu(trigger, items, side?, align?, label?)` is the click-triggered dropdown menu — use it for user-profile menus, row \\\"…\\\" action menus, and any compact list of actions hanging off a single trigger. Children must be `MenuItem`, `MenuSeparator`, or `MenuLabel` entries.\",\n \"- `MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)` renders a single row inside a `DropdownMenu`; use `variant=\\\"danger\\\"` for destructive actions and `MenuSeparator()`/`MenuLabel(label)` to group related items.\",\n ],\n },\n {\n name: \"Chat\",\n components: [\"SectionBlock\", \"ListBlock\", \"FollowUpBlock\", \"FollowUpItem\", \"ActionLink\", \"ChatBubble\"],\n notes: [\n \"- End most responses with a `FollowUpBlock` of 2–4 short prompts to keep the conversation moving.\",\n \"- `ChatBubble(author, body, time?, avatarSrc?, from?)` renders a single message bubble; use `from=\\\"me\\\"` for the active speaker and `from=\\\"agent\\\"` for the assistant. Compose transcripts as `Stack([ChatBubble(...), ChatBubble(...), …])` inside a `Card`.\",\n ],\n },\n {\n name: \"Patterns\",\n components: [\n \"Hero\", \"PageHeader\", \"EmptyState\",\n \"Timeline\", \"TimelineItem\", \"ActivityLog\",\n \"FeatureGrid\", \"FeatureItem\",\n \"Testimonial\", \"ProfileCard\", \"Comment\", \"Banner\", \"Notification\",\n \"InboxPanel\", \"OnboardingChecklist\",\n \"MediaCard\", \"TopBar\",\n \"KanbanBoard\", \"KanbanColumn\", \"KanbanCard\",\n \"SectionHeader\", \"Toolbar\", \"DescriptionList\", \"DescriptionItem\",\n \"StatusDot\", \"PricingTable\", \"PricingCard\",\n \"LoadingState\", \"ErrorState\", \"SuccessState\",\n \"Tour\", \"Spotlight\",\n ],\n notes: [\n \"- Patterns are **opinionated composites** that pack an entire UI idiom into one component. Reach for them BEFORE composing equivalent layouts by hand with Card+Stack — the result will look more polished and require fewer tokens.\",\n \"- `Hero(title, subtitle, primary, secondary, eyebrow?, highlights?, tone?)` — landing-style text-first header. Use `layout=\\\"cover\\\"` with `imageSrc`, `height`, and optional `caption` for image-backed hero bands.\",\n \"- `PageHeader(title, subtitle?, breadcrumbs?, actions?, status?)` — the canonical first child for any dashboard or detail page. If you omit `breadcrumbs`, the component auto-derives `[\\\"Home\\\", title]`.\",\n \"- `TopBar(title?, search?, actions?, sticky?)` — compact top strip for a content surface (panels, dialogs, embedded views). Use `AppShell` when you need a full sidebar; use `TopBar` for narrower headers above scrolling content.\",\n \"- `SectionHeader(title, subtitle?, eyebrow?, status?, actions?)` — sub-header inside a Card or panel. Use instead of bare `CardHeader` when the section also needs eyebrow / actions / status.\",\n \"- `Stats(items, layout?)` — KPI strip (`layout=\\\"strip\\\"`, default) or responsive grid (`layout=\\\"grid\\\"` with StatCard children). Prefer over hand-rolled StatCard rows.\",\n \"- `Toolbar(left?, right?, center?, searchable?, searchPlaceholder?, searchValue?)` — filter/search/actions row above a list, table, or board. Pass `searchable: true` to auto-mount a `SearchBar` (use `searchValue` to bind it to a `$variable`).\",\n \"- `EmptyState(title, description?, icon?, illustration?, actions?, action?)` — render this when a list is empty rather than an empty Card. The icon is auto-picked from the title keywords if you omit it (inbox/messages → `inbox`, charts/analytics → `chart-pie`, files/folders → `folder-open`, etc.).\",\n \"- `Timeline([TimelineItem(...)])` — vertical event feed (audit log, changelog, activity).\",\n \"- `ActivityLog(entries, variant?)` — purpose-built feed of user actions. Pass `entries` of `{actor, title, description?, time?, icon?, tone?, meta?}`; use `variant=\\\"audit\\\"` for security/admin trails with monospace meta.\",\n \"- `FeatureGrid([FeatureItem(...)])` — feature highlights with iconography.\",\n \"- `MediaCard(title, imageSrc?, description?, tags?, meta?, actions?, badge?, orientation?, ratio?)` — image + content card. Use for article previews, product cards, project highlights. Pair with `Grid` for uniform card rows.\",\n \"- `KanbanBoard([KanbanColumn(\\\"To do\\\", [KanbanCard(...), ...])])` — task boards.\",\n \"- `DescriptionList([DescriptionItem(\\\"Status\\\", Badge(...)), …])` — detail-page key/value summary. Always preferable to a Stack of Text rows on profile, billing, or metadata panels.\",\n \"- `StatusDot(label, tone?, pulse?)` — inline status pip. Use in toolbars, list rows, table cells, sidebars.\",\n \"- `Notification(title, message?, time?, icon?, avatarSrc?, tone?, unread?, actions?)` — inline notification card for notification panels / inboxes (prefer `Banner` for top-of-page announcements).\",\n \"- `InboxPanel(items, title?, onMarkAllRead?)` — `Notification` cards grouped into Unread / Earlier sections, with a shared mark-all-read action.\",\n \"- `OnboardingChecklist(items, title?, description?)` — checklist of `{title, description?, done?, action?}` items with progress. Use for product onboarding, setup wizards, getting-started panels.\",\n \"- `PricingTable([PricingCard(plan, price, period?, description?, features?, action?, badge?, featured?)])` — full pricing page block.\",\n \"- `LoadingState(title?, description?, tone?, action?)`, `ErrorState(title, description?, action?, secondaryAction?, retryLabel?)`, `SuccessState(title, description?, action?, secondaryAction?)` — full-card empty-state alternatives for asynchronous content states.\",\n \"- `Tour(steps, current, onFinish?)` and `Spotlight(title?, description?, action?)` are the product-tour primitives. `Spotlight` is a single highlighted call-out; `Tour` walks the user through multiple `{title, description, image?}` steps with Prev/Next/Skip controls and a progress dots indicator.\",\n ],\n },\n {\n name: \"Editors & overlays\",\n components: [\"RichTextEditor\", \"CodeEditor\", \"ContextMenu\"],\n notes: [\n \"- `RichTextEditor(id, value?, placeholder?, minHeight?)` is the contenteditable WYSIWYG editor — toolbar ships with bold/italic/underline/strike/heading/lists/link. Bind `value` to a `$variable` holding HTML.\",\n \"- `CodeEditor(id, value?, language?, placeholder?, minHeight?)` is a lightweight `<textarea>` with a synced line-number gutter and tab indentation. Use for snippet editors, prompt sandboxes, settings JSON.\",\n \"- `ContextMenu(target, items)` attaches a right-click menu to any node. `items` are `MenuItem` or `{label, action?, icon?, shortcut?, variant?, disabled?}` objects; pass a `MenuSeparator()` to split groups.\",\n ],\n },\n {\n name: \"App shell\",\n components: [\n \"AppShell\", \"Sidebar\", \"SidebarSection\", \"SidebarItem\", \"SplitView\",\n ],\n notes: [\n \"- App shell components produce a **full SaaS-style layout in a single statement**. Use them whenever the response represents a complete product surface (dashboards with nav, settings sections, admin consoles, inboxes).\",\n \"- `AppShell(sidebar, content, topbar?, collapsible?, sidebarOpen?)` — fixed-left navigation + scrollable main area. Pass `collapsible=true` to enable a hamburger that turns the sidebar into a slide-over drawer on mobile; bind `sidebarOpen` to a `$variable` if you want to drive that drawer programmatically.\",\n \"- `Sidebar(items, brand?, tagline?, footer?, collapsed?)` + `SidebarItem(label, icon?, active?, badge?, action?)` + `SidebarSection(label, items)` — group nav links into sections, mark the current page with `active=true`, attach badges for counts. Pass `collapsed=true` (or bind to a `$variable`) to collapse it to an icon rail.\",\n \"- `SplitView(primary, detail, primaryWidth?)` — master/detail layout (inboxes, file browsers, contact lists). Both panes are scrollable.\",\n ],\n },\n {\n name: \"Theming\",\n components: [\"Theme\"],\n notes: [\n \"- `$theme({...})` applies a partial token override **on top of** the base theme set by the host (attribute / `setTheme()`). Use it to brand a single response without changing host configuration.\",\n \"- Assign to `aktion.theme` so the runtime picks it up:\",\n \" `theme = $theme({ colors: { primary: \\\"#0969da\\\" }, radius: { button: \\\"6px\\\" } })`\",\n \"- Tokens MUST use the structured form. Top-level groups: `colors`, `radius`, `font`, `motion`, `elevation` (plus metadata: `name`, `direction`).\",\n \"- Common tokens (each lives inside its group): `colors.primary`, `colors.primaryHover`, `colors.primaryText`, `colors.accent`, `colors.bg`, `colors.surface`, `colors.text`, `colors.textMuted`, `colors.border`, `colors.focusRing`; `radius.md`, `radius.button`, `radius.input`; `font.family`, `font.familyHeading`, `font.sizeBase`, `font.weightHeading`; `motion.transitionDuration`; `elevation.md`.\",\n \"- The legacy flat-shape form (`$theme({colorPrimary: ...})`) and free-form `--css-vars` are removed in Aktion 0.5 — the runtime drops them and the schema validator surfaces a migration warning.\",\n \"- Tokens are CSS values (`\\\"#0969da\\\"`, `\\\"'Inter', sans-serif\\\"`, `\\\"6px\\\"`, `\\\"600\\\"`). The runtime ignores unknown keys inside a group, so typos fail silent.\",\n \"- Removing the `theme = $theme(...)` line snaps the UI back to the base theme without a reload.\",\n ],\n },\n {\n name: \"Advanced UI\",\n components: [\n \"IconButton\", \"CommandPalette\", \"FilterChips\", \"FieldRepeater\",\n \"VirtualList\", \"QueryBuilder\", \"DiffViewer\", \"JsonTree\", \"Gantt\",\n \"Truncate\", \"InlineEdit\", \"NotificationBell\",\n ],\n notes: [\n \"- `IconButton(icon, label, action?, variant?, size?, disabled?)` — accessible icon-only control.\",\n \"- `CommandPalette(items, open?, placeholder?, shortcut?)` — Cmd-K searchable actions.\",\n \"- `FilterChips(chips, onRemove?, onClear?)` — applied filter pills with remove.\",\n \"- `FieldRepeater(items, fields, onAdd?, onRemove?)` — dynamic form rows.\",\n \"- `VirtualList(items, itemHeight?, renderItem)` — windowed long lists.\",\n \"- `QueryBuilder(fields, value?)` — visual AND/OR filter builder.\",\n \"- `DiffViewer(left, right, mode?)` — side-by-side or unified diff.\",\n \"- `JsonTree(data)` — collapsible JSON inspector.\",\n \"- `Gantt(tasks, startDate?, endDate?)` — horizontal schedule timeline.\",\n \"- `Truncate(text, maxLines?)` / `InlineEdit(value, onSave?)` / `NotificationBell(count?, items?)`.\",\n ],\n },\n {\n name: \"Routing\",\n components: [\"NavLink\"],\n notes: [\n \"- Declare routes with the `$router({...})` call form: `pages = $router({ \\\"/\\\": Dashboard(), \\\"/orders/:id\\\": OrderDetail({ id: params.id }), default: NotFound() })`. The matched arm's `params` object is in scope on the right-hand side; nest `$router` inside components for layout-preserving sub-routes.\",\n \"- `Redirect(path)` is a router-aware component: returning it from a route's body navigates and unmounts the rest of the subtree.\",\n \"- `NavLink(label, { to })` is a thin link wrapper that reads `route.path` and dispatches `route.navigate(to)` — use it for sidebars, navbars and breadcrumbs.\",\n \"- Read URL params via `route.params.<name>` (e.g. `route.params.id` for `/users/:id`) and the current path via `route.path`.\",\n ],\n },\n {\n name: \"Helpers\",\n components: [\"Async\", \"Show\", \"Portal\", \"Redirect\", \"Lazy\", \"ErrorBoundary\"],\n notes: [\n \"- `Async(resource, { loading:, error:, empty:, data: })` switches an `$http({...})` resource on its `state` field (`empty` shows for `null`/empty-array data).\",\n \"- `Show(when, { fallback?, children })` is sugar over `if (expr) { children } else { fallback }`.\",\n \"- `Portal(target?, children)` renders into a different DOM subtree (defaults to `document.body`).\",\n \"- `Redirect(path)` is a router-aware component — see Routing.\",\n \"- `Lazy(loader, fallback?)` defers children until `loader` resolves.\",\n \"- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants.\",\n ],\n },\n {\n name: \"Behaviour wrappers\",\n components: [\n \"OnClick\", \"OnMouse\", \"OnKeyboard\", \"OnFocus\", \"OnIntersect\", \"Css\", \"Link\",\n ],\n notes: [\n \"- Wrappers compose: any built-in component can be made clickable, hoverable, observable, or restyled by wrapping it in one of these primitives — no need for the underlying component to grow another prop.\",\n \"- `OnClick(child, { onClick, disabled?, stopPropagation? })` makes any component clickable / tappable (touch devices fire `click` too). Use for clickable cards, list rows, media tiles, and any custom layout that needs a tap target without a `<button>` baseline.\",\n \"- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` attaches any combination of mouse / pointer / drag listeners. Pass `draggable: true` to make the wrapper itself draggable. Scroll / wheel listeners default to `{ passive: true }` for smooth scrolling.\",\n \"- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })` attaches keyboard listeners. The wrapper is focusable by default; pass `focusable: false` when the child is already focusable (input, button).\",\n \"- `OnFocus(child, { onFocus?, onBlur? })` tracks focus moving into or out of a subtree (uses bubbling `focusin` / `focusout` so descendants count).\",\n \"- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` is the IntersectionObserver wrapper — perfect for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.\",\n \"- `Css(child, { style?, class? })` merges raw class tokens and inline styles onto the wrapped child. Reach for it ONLY when the standard component props can't express the styling — prefer `Box`/`Stack`/`Grid` for layout and `$theme(...)` for tokens.\",\n \"- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links.\",\n ],\n },\n {\n name: \"Escape hatches\",\n components: [\"HTMLTag\", \"Styles\"],\n notes: [\n \"- **Use only as a last resort.** Reach for these primitives when the standard catalogue cannot express the markup or styling you need; for everything else (typography, layout, surfaces, controls) the dedicated components produce a more consistent UI for fewer tokens.\",\n \"- `HTMLTag(tag, attributes?, children?)` renders an allow-listed HTML tag with the given attribute object and child nodes (e.g. `HTMLTag(\\\"section\\\", attributes: {class: \\\"hero\\\", \\\"data-id\\\": 1}, children: [Text(\\\"Hello\\\")])`). Tag names outside the allow-list collapse to `div`; `on*` attributes, `javascript:` URLs in `href`/`src`, and `expression()` / `@import` in inline `style` are stripped.\",\n \"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped.\",\n ],\n },\n];\n\n// Aktion 0.5 §19.1 — fail-fast guard: no library spec may\n// declare more than one `positional: true` prop. Surfaces as a clear\n// SyntaxError at module load so a broken spec never ships.\nassertOnePositionalMax(components);\n\nexport const defaultLibrary: ComponentLibrary = {\n root: \"Column\",\n components,\n componentGroups,\n};\n"],"names":["text","parseRatio","sanitiseInlineStyle","value","BUTTON_VARIANTS","BUTTON_SIZES","normaliseButtonSize","root","body","ctaItems","COL_ALIGN","PALETTE","colorAt","readSeries","createSvg","svgEl","legend","label","message","current","Map","caption","editor","max","name","param"],"mappings":"AA4EO,SAAS,oBAAoB,MAA6B;AAC/D,QAAM,WAAW,KAAK,MAAM,UAAU,CAAC,MAAM,EAAE,eAAe,IAAI;AAClE,MAAI,YAAY,EAAG,QAAO;AAC1B,SAAO,KAAK,MAAM,SAAS,IAAI,IAAI;AACrC;AAEO,SAAS,mBAAmB,MAA2C;AAC5E,QAAM,MAAM,oBAAoB,IAAI;AACpC,SAAO,OAAO,IAAI,KAAK,MAAM,GAAG,IAAI;AACtC;AAOO,SAAS,uBAAuB,OAA2C;AAChF,aAAW,QAAQ,OAAO;AACxB,UAAM,aAAa,KAAK,MAAM,OAAO,CAAC,MAAM,EAAE,eAAe,IAAI;AACjE,QAAI,WAAW,SAAS,GAAG;A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