@roxyapi/ui 0.52.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components-catalog.json +153 -153
- package/dist/cdn/components/endpoint-form.js +4 -4
- package/dist/cdn/components/endpoint-form.js.map +3 -3
- package/dist/cdn/roxy-ui.js +32 -32
- package/dist/cdn/roxy-ui.js.map +3 -3
- package/dist/cdn/widgets.js +1 -1
- package/dist/components/endpoint-form.js +1 -1
- package/dist/components/endpoint-form.js.map +3 -3
- package/dist/forms.json +1 -1
- package/dist/index.cjs +61 -61
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +55 -55
- package/dist/index.js.map +3 -3
- package/dist/schemas/post--angel-numbers-daily.json +1 -1
- package/dist/schemas/post--biorhythm-daily.json +1 -1
- package/dist/schemas/post--crystals-daily.json +1 -1
- package/dist/schemas/post--dreams-daily.json +1 -1
- package/dist/schemas/post--feng-shui-eight-mansions.json +1 -1
- package/dist/schemas/post--feng-shui-flying-stars-natal.json +1 -1
- package/dist/schemas/post--iching-daily-cast.json +1 -1
- package/dist/schemas/post--iching-daily.json +1 -1
- package/dist/schemas/post--kabbalah-compatibility.json +1 -1
- package/dist/schemas/post--kabbalah-gematria.json +1 -1
- package/dist/schemas/post--kabbalah-name-profile.json +1 -1
- package/dist/schemas/post--mesoamerican-astrology-mayan-long-count-convert.json +1 -1
- package/dist/schemas/post--numerology-daily.json +1 -1
- package/dist/schemas/post--numerology-maturity.json +1 -1
- package/dist/schemas/post--tarot-daily.json +1 -1
- package/dist/styles/themes/practitioner.css +5 -5
- package/dist/types/types.gen.d.ts +9 -9
- package/dist/utils/field-schema.d.ts +4 -0
- package/dist/utils/field-schema.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/styles/themes/practitioner.css +5 -5
- package/src/types/types.gen.ts +9 -9
- package/src/utils/field-schema.ts +10 -1
- package/src/version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cdn-endpoint-form.ts", "../../../src/styles/tokens-css.ts", "../../../src/utils/inject-tokens.ts", "../../../../../node_modules/.bun/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/src/css-tag.ts", "../../../../../node_modules/.bun/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/src/reactive-element.ts", "../../../../../node_modules/.bun/lit-html@3.3.3/node_modules/lit-html/src/lit-html.ts", "../../../../../node_modules/.bun/lit-element@4.2.2/node_modules/lit-element/src/lit-element.ts", "../../../../../node_modules/.bun/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../../../../../node_modules/.bun/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/src/decorators/property.ts", "../../../../../node_modules/.bun/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/src/decorators/state.ts", "../../../../../node_modules/.bun/lit-html@3.3.3/node_modules/lit-html/src/directives/if-defined.ts", "../../../../../node_modules/.bun/lit-html@3.3.3/node_modules/lit-html/src/directive.ts", "../../../../../node_modules/.bun/lit-html@3.3.3/node_modules/lit-html/src/directive-helpers.ts", "../../../../../node_modules/.bun/lit-html@3.3.3/node_modules/lit-html/src/directives/live.ts", "../../../src/generated/field-labels-en.ts", "../../../src/generated/api-languages.ts", "../../../src/i18n/lang.ts", "../../../src/utils/string.ts", "../../../src/i18n/registry.ts", "../../../src/i18n/locale-controller.ts", "../../../src/i18n/localized-element.ts", "../../../src/tokens/index.ts", "../../../src/utils/base-styles.ts", "../../../src/utils/disclosure.ts", "../../../src/utils/key-guard.ts", "../../../src/utils/fetch-controller.ts", "../../../src/generated/option-sources.ts", "../../../src/utils/field-schema.ts", "../../../src/utils/localized.ts", "../../../src/utils/combobox-styles.ts", "../../../src/utils/debounce.ts", "../../../src/utils/option-picker.ts", "../../../src/version.ts", "../../../src/components/endpoint-form.ts"],
|
|
4
|
-
"sourcesContent": ["import { injectRoxyTokens } from './utils/inject-tokens.js';\nexport * from './components/endpoint-form.js';\nexport { injectRoxyTokens, ROXY_UI_TOKENS_STYLE_ID } from './utils/inject-tokens.js';\ninjectRoxyTokens();\n", "// Generated by scripts/sync-tokens.ts from tokens.css. Do not edit.\nexport const ROXY_UI_TOKENS_CSS = `/**\n * Roxy UI design tokens. 47 CSS custom properties that every component reads. Light + dark defaults. Host page overrides at :root or per element. No Tailwind, no class-name overrides, no JS theme switcher.\n *\n * Delivery model: this file ships as a global light-DOM stylesheet (linked, or auto-injected by the CDN bundle). Why every rule sits in a cascade layer is the note above the layer statement below. Custom properties inherit through the shadow boundary, so tokens set on a light-DOM ancestor reach every component shadow. The explicit theme blocks therefore target light-DOM selectors (:root, .dark, [data-theme=\"dark\"], a wrapper element), NOT :host (a :host rule in a global sheet matches nothing). The :host([data-theme]) selectors are kept only for the case where this CSS is ever adopted directly into a shadow root; they are inert in global delivery.\n *\n * Light is the default. Dark applies under any of:\n * - prefers-color-scheme: dark\n * - [data-theme=\"dark\"] on the element itself or any ancestor (typically :root)\n * - .dark class on the element itself or any ancestor (typically :root)\n *\n * Explicit choice wins over the OS: the [data-theme] / .dark blocks come after the @media (prefers-color-scheme: dark) block in source order, and a closer ancestor overrides a farther one through normal custom-property inheritance.\n *\n * Motion gating:\n * - --roxy-motion-duration defaults to 200ms. Set to 0ms to disable.\n * - prefers-reduced-motion: reduce forces 0ms regardless of host overrides.\n */\n\n/*\n * Two mechanisms keep the host page in charge of every token, and both are load bearing.\n *\n * The rules below sit in the \\`roxy.tokens\\` cascade layer, and an unlayered declaration beats a\n * layered one at ANY specificity. So a plain \\`:root { --roxy-accent: #8b5cf6 }\\` on the host page\n * wins, and so does the same line written inside a layer of its own, because the layer\n * statement above registers ours first and the CDN bundle injects this sheet at the top of\n * <head>. A host that links this file after its own CSS orders the layers itself:\n * \\`@layer roxy, base, components, utilities;\\` before either sheet.\n *\n * Every selector is ALSO wrapped in :where(), which has ZERO specificity, so a host declaration\n * still wins wherever a layer cannot decide it. Without that, \\`:root.dark\\` and\n * \\`[data-theme=\"dark\"]\\` would carry class and attribute specificity (0,1,1) and outrank a plain\n * \\`:root\\` (0,1,0), and one brand override would hold under prefers-color-scheme and revert\n * under the other two dark signals: one line, three different results.\n *\n * Source order still decides among the rules in THIS file, which is what lets the explicit dark\n * block beat the light defaults when both match.\n */\n\n/* Layer order, named here so it is fixed wherever the two files load: the theme presets in\n * styles/themes/*.css reassign tokens and must win over these defaults. Both files declare it,\n * so either one loading alone still orders the pair. */\n@layer roxy.tokens, roxy.theme;\n\n@layer roxy.tokens {\n\t:where(:root, :host) {\n\t\t/* Native controls follow the theme, and this is the ONLY thing that makes them.\n\t\t *\n\t\t * \\`color-scheme\\` is a real property, not the \\`prefers-color-scheme\\` query above it, and\n\t\t * without it the browser paints every native control in its LIGHT appearance whatever our\n\t\t * tokens say. A <select> looks fine closed, because we colour it ourselves, and then opens a\n\t\t * light popup whose <option> rows inherit our near-white --roxy-fg: white text on white. The\n\t\t * same omission dims a date or time picker's calendar, the number spinner, the autofill\n\t\t * highlight and the scrollbar.\n\t\t *\n\t\t * It belongs HERE and not on the controls, because a per-control fix is one rule per input\n\t\t * type per component, forever, and it still cannot reach the popup: that is rendered by the\n\t\t * OS outside the DOM, so no selector we write applies to it. Declared once per theme trigger,\n\t\t * beside the tokens, it covers every control in every component and on the host page.\n\t\t * \\`color-scheme\\` is inherited, and these selectors match :host, so each shadow root gets it. */\n\t\tcolor-scheme: light;\n\n\t\t/* Color: brand */\n\t\t--roxy-primary: #0f172a;\n\t\t--roxy-secondary: #475569;\n\t\t--roxy-accent: #f59e0b;\n\t\t/* Text-safe accent variant, DERIVED from --roxy-accent so overriding the accent\n\t\t * alone rebrands the whole library. Never hardcode a colour here: a consumer\n\t\t * following the theming recipe sets only --roxy-accent, and a fixed value leaves\n\t\t * the active tab label, the conjunction aspect lines and the focus ring on the\n\t\t * old hue, giving a two-tone palette from a one-line override.\n\t\t *\n\t\t * The raw accent is too light for text (amber-500 is 2.14:1 on white, far under\n\t\t * WCAG AA). Mixing 70% of it into black is measured, not guessed: rasterised to\n\t\t * real pixels, the darkest of the twelve shipped domain accents still lands at\n\t\t * 5.24:1 on white, above AA. At 75% amber falls to 4.46 and fails, so 70 is a\n\t\t * ceiling, not a round number.\n\t\t *\n\t\t * Fills (planet glyphs, chart accents, non-text badges) keep --roxy-accent. */\n\t\t--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);\n\n\t\t/* Color: status. The base value (success, warning, danger, info) is for\n\t\t * fills and tints. The -fg partner is the INK for a tint of that base, and it\n\t\t * is DERIVED from it exactly as --roxy-accent-ink is derived from the accent,\n\t\t * so re-pointing a status colour carries its text with it instead of leaving\n\t\t * the old hue on every rule that reads the ink.\n\t\t *\n\t\t * 70 percent toward black is the ratio the accent already uses, and it is\n\t\t * measured rather than chosen: rasterised to real pixels the four shipped\n\t\t * pairs land between 7.4 and 9.8 to 1 on the card and between 6.5 and 8.1 on\n\t\t * a 12 percent tint of their own base, every one of them above WCAG AA and at\n\t\t * or above the fixed hexes they replace. Use -fg whenever status color hits\n\t\t * text. */\n\t\t--roxy-success: #16a34a;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);\n\t\t--roxy-warning: #ea580c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);\n\t\t--roxy-danger: #dc2626;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);\n\t\t--roxy-info: #0284c7;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);\n\n\t\t/* Color: surface */\n\t\t--roxy-bg: #ffffff;\n\t\t--roxy-surface: #ffffff;\n\t\t--roxy-fg: #0a0a0a;\n\t\t--roxy-muted: #71717a;\n\t\t--roxy-border: #e4e4e7;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);\n\n\t\t/* Typography */\n\t\t--roxy-font-sans:\n\t\t\t\"Geist\", system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto,\n\t\t\tsans-serif;\n\t\t--roxy-font-mono:\n\t\t\t\"Geist Mono\", ui-monospace, \"SF Mono\", Menlo, Consolas, \"Liberation Mono\",\n\t\t\tmonospace;\n\t\t/* Heading/display font. Defaults to the sans stack so nothing changes for an\n\t\t * existing consumer; a preset (the practitioner theme ships a serif) overrides\n\t\t * it to restyle every result heading and the self-fetch form title in one token.\n\t\t * Fonts do not vary by theme, so it is declared once here and inherited by the\n\t\t * dark/light blocks unchanged. */\n\t\t--roxy-font-display: var(--roxy-font-sans);\n\n\t\t--roxy-text-xs: 0.75rem;\n\t\t--roxy-text-sm: 0.875rem;\n\t\t--roxy-text-base: 1rem;\n\t\t--roxy-text-lg: 1.125rem;\n\t\t--roxy-text-xl: 1.5rem;\n\n\t\t--roxy-weight-normal: 400;\n\t\t--roxy-weight-bold: 600;\n\n\t\t--roxy-leading-tight: 1.2;\n\t\t--roxy-leading-normal: 1.5;\n\n\t\t--roxy-tracking-tight: -0.02em;\n\t\t--roxy-tracking-normal: 0em;\n\n\t\t/* Spacing */\n\t\t--roxy-space-xs: 0.25rem;\n\t\t--roxy-space-sm: 0.5rem;\n\t\t--roxy-space-md: 1rem;\n\t\t--roxy-space-lg: 1.5rem;\n\t\t--roxy-space-xl: 2.5rem;\n\n\t\t/* Radius */\n\t\t--roxy-radius-sm: 4px;\n\t\t--roxy-radius-md: 8px;\n\t\t--roxy-radius-lg: 12px;\n\t\t--roxy-radius-full: 9999px;\n\n\t\t/* Shadow */\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.14);\n\n\t\t/* Motion */\n\t\t--roxy-motion-duration: 200ms;\n\t\t--roxy-motion-easing: cubic-bezier(0.4, 0, 0.2, 1);\n\n\t\t/* Heat scale: a single base hue. Consumers mix it with \\`transparent\\` at\n\t\t * increasing percentages to paint cooler-to-hotter tiers. The mix-with-\n\t\t * transparent approach lets the page bg show through and keeps text\n\t\t * colour stable (always --roxy-fg), so the cells read in both themes\n\t\t * without per-tier text colours. */\n\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t}\n\n\t/* Dark theme via system preference */\n\t@media (prefers-color-scheme: dark) {\n\t\t:where(:root, :host) {\n\t\t\tcolor-scheme: dark;\n\t\t\t--roxy-primary: #f8fafc;\n\t\t\t--roxy-secondary: #94a3b8;\n\t\t\t--roxy-accent: #fbbf24;\n\t\t\t--roxy-accent-ink: var(--roxy-accent);\n\n\t\t\t/* The dark blocks mix toward WHITE, and BOTH dark triggers carry the line.\n\t\t\t * Without it a visitor on system dark with no data-theme attribute inherits\n\t\t\t * the light derivation, which lands a dark green on a near-black surface and\n\t\t\t * fails WCAG AA. */\n\t\t\t--roxy-success: #22c55e;\n\t\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);\n\t\t\t--roxy-warning: #fb923c;\n\t\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);\n\t\t\t--roxy-danger: #ef4444;\n\t\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);\n\t\t\t--roxy-info: #38bdf8;\n\t\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);\n\n\t\t\t--roxy-bg: #0a0a0a;\n\t\t\t--roxy-surface: #18181b;\n\t\t\t--roxy-fg: #fafafa;\n\t\t\t--roxy-muted: #a1a1aa;\n\t\t\t--roxy-border: #27272a;\n\t\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 45%, transparent);\n\n\t\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);\n\t\t\t--roxy-shadow-md:\n\t\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.5);\n\t\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.7);\n\n\t\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t\t}\n\t}\n\n\t/* Light theme override. Beats the @media (prefers-color-scheme: dark) block\n\t * when the host explicitly opts back into light. Without this, a dark-mode OS\n\t * pins the tokens to dark even after data-theme=\"light\" is set. The light-DOM\n\t * selectors (:root.light, .light, [data-theme=\"light\"]) set the vars on the\n\t * ancestor or the element itself so they inherit into every component shadow;\n\t * :host([data-theme=\"light\"]) is inert in global delivery and kept only for\n\t * shadow-adopted use. */\n\t:where(\n\t\t:root[data-theme=\"light\"],\n\t\t[data-theme=\"light\"],\n\t\t:root.light,\n\t\t.light,\n\t\t:host([data-theme=\"light\"])\n\t) {\n\t\tcolor-scheme: light;\n\t\t--roxy-primary: #0f172a;\n\t\t--roxy-secondary: #475569;\n\t\t--roxy-accent: #f59e0b;\n\t\t--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);\n\n\t\t--roxy-success: #16a34a;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);\n\t\t--roxy-warning: #ea580c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);\n\t\t--roxy-danger: #dc2626;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);\n\t\t--roxy-info: #0284c7;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);\n\n\t\t--roxy-bg: #ffffff;\n\t\t--roxy-surface: #ffffff;\n\t\t--roxy-fg: #0a0a0a;\n\t\t--roxy-muted: #71717a;\n\t\t--roxy-border: #e4e4e7;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);\n\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.14);\n\t}\n\n\t/* Dark theme via explicit opt-in. The light-DOM selectors (:root.dark, .dark,\n\t * [data-theme=\"dark\"]) set the vars on the ancestor or the element itself so\n\t * they inherit into every component shadow; this is what makes a .dark class on\n\t * any ancestor (Tailwind, shadcn) actually theme the components in global\n\t * delivery. :host([data-theme=\"dark\"]) is inert in global delivery and kept\n\t * only for shadow-adopted use. */\n\t:where(\n\t\t:root[data-theme=\"dark\"],\n\t\t[data-theme=\"dark\"],\n\t\t:root.dark,\n\t\t.dark,\n\t\t:host([data-theme=\"dark\"])\n\t) {\n\t\tcolor-scheme: dark;\n\t\t--roxy-primary: #f8fafc;\n\t\t--roxy-secondary: #94a3b8;\n\t\t--roxy-accent: #fbbf24;\n\t\t--roxy-accent-ink: var(--roxy-accent);\n\n\t\t--roxy-success: #22c55e;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);\n\t\t--roxy-warning: #fb923c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);\n\t\t--roxy-danger: #ef4444;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);\n\t\t--roxy-info: #38bdf8;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);\n\n\t\t--roxy-bg: #0a0a0a;\n\t\t--roxy-surface: #18181b;\n\t\t--roxy-fg: #fafafa;\n\t\t--roxy-muted: #a1a1aa;\n\t\t--roxy-border: #27272a;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 45%, transparent);\n\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.5);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.7);\n\n\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t}\n\n\t/* Reduced motion override */\n\t@media (prefers-reduced-motion: reduce) {\n\t\t:where(:root, :host) {\n\t\t\t--roxy-motion-duration: 0ms;\n\t\t}\n\t}\n}\n`;\n", "import { ROXY_UI_TOKENS_CSS } from '../styles/tokens-css.js';\n\n/** Element id of the injected token stylesheet. Stable so injection is idempotent and so a host page can find, inspect, or remove it. */\nexport const ROXY_UI_TOKENS_STYLE_ID = 'roxy-ui-tokens';\n\n/**\n * Inject the Roxy UI design tokens (light + dark, all theme triggers) into the document head as the cascade's lowest-priority source, so a single CDN script tag yields full theming and dark mode with no separate stylesheet link.\n *\n * @remarks\n * Three invariants hold this safe for every consumer:\n *\n * - SSR-safe: a missing `document` (Node, Lit-SSR, Bun) is a no-op. Only the CDN bundle calls this; the npm/ESM entry (`src/index.ts`) never touches the document, so bundler and server consumers are unaffected.\n * - Idempotent: a second call (two script tags, HMR, re-registration) finds the existing `#roxy-ui-tokens` and returns without duplicating.\n * - Lowest priority, twice over. The tokens sit in the `roxy.tokens` cascade layer, so an unlayered host declaration outranks them at any specificity, and the style is PREPENDED to `<head>`, which registers that layer name ahead of every stylesheet the page brought with it, so a layer of the host's own sorts above it as well. A consumer `:root { --roxy-* }` brand override or a linked `tokens.css` still lands later in source order and still wins ties, so existing pages keep their exact behaviour.\n *\n * @returns The injected (or pre-existing) style element, or `null` under SSR.\n */\nexport function injectRoxyTokens(): HTMLStyleElement | null {\n\tif (typeof document === 'undefined') return null;\n\tconst existing = document.getElementById(ROXY_UI_TOKENS_STYLE_ID);\n\tif (existing) return existing as HTMLStyleElement;\n\tconst style = document.createElement('style');\n\tstyle.id = ROXY_UI_TOKENS_STYLE_ID;\n\tstyle.textContent = ROXY_UI_TOKENS_CSS;\n\tdocument.head.prepend(style);\n\treturn style;\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable<T, K extends keyof T> = Omit<T, K> & {\n -readonly [P in keyof Pick<T, K>]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n });\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<ReactiveUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter<Type = unknown, TypeHint = unknown> =\n | ComplexAttributeConverter<Type>\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter<Type, TypeHint>;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n\n /**\n * When `true`, uses the initial value of the property as the default value,\n * which changes how attributes are handled:\n * - The initial value does *not* reflect, even if the `reflect` option is `true`.\n * Subsequent changes to the property will reflect, even if they are equal to the\n * default value.\n * - When the attribute is removed, the property is set to the default value\n * - The initial value will not trigger an old value in the `changedProperties` map\n * argument to update lifecycle methods.\n *\n * When set, properties must be initialized, either with a field initializer, or an\n * assignment in the constructor. Not initializing the property may lead to\n * improper handling of subsequent property assignments.\n *\n * While this behavior is opt-in, most properties that reflect to attributes should\n * use `useDefault: true` so that their initial values do not reflect.\n */\n useDefault?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;\n\ntype AttributeMap = Map<string, PropertyKey>;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues<this>` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map<PropertyKey, unknown>`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map<PropertyKey, unknown>`, but if a developer uses\n// `PropertyValues<this>` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues<T = any> = T extends object\n ? PropertyValueMap<T>\n : Map<PropertyKey, unknown>;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {\n get<K extends keyof T>(k: K): T[K] | undefined;\n set<K extends keyof T>(key: K, value: T[K]): this;\n has<K extends keyof T>(k: K): boolean;\n delete<K extends keyof T>(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n useDefault: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array<CSSResultOrNative> = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with `<style>` tags when the browser doesn't\n * support adopted StyleSheets. To use such `<style>` tags with the style-src\n * CSP directive, the style-src value must either include 'unsafe-inline' or\n * `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated\n * nonce.\n *\n * To provide a nonce to use on generated `<style>` elements, set\n * `window.litNonce` to a server-generated nonce in your page's HTML, before\n * loading application code:\n *\n * ```html\n * <script>\n * // Generated and unique per request:\n * window.litNonce = 'a1b2c3d4';\n * </script>\n * ```\n * @nocollapse\n * @category styles\n */\n static styles?: CSSResultGroup;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n * @category attributes\n */\n static get observedAttributes() {\n // Ensure we've created all properties\n this.finalize();\n // this.__attributeToPropertyMap is only undefined after finalize() in\n // ReactiveElement itself. ReactiveElement.observedAttributes is only\n // accessed with ReactiveElement as the receiver when a subclass or mixin\n // calls super.observedAttributes\n return (\n this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]\n );\n }\n\n private __instanceProperties?: PropertyValues = undefined;\n\n /**\n * Creates a property accessor on the element prototype if one does not exist\n * and stores a {@linkcode PropertyDeclaration} for the property with the\n * given options. The property setter calls the property's `hasChanged`\n * property option or uses a strict identity check to determine whether or not\n * to request an update.\n *\n * This method may be overridden to customize properties; however,\n * when doing so, it's important to call `super.createProperty` to ensure\n * the property is setup correctly. This method calls\n * `getPropertyDescriptor` internally to get a descriptor to install.\n * To customize what properties do when they are get or set, override\n * `getPropertyDescriptor`. To customize the options for a property,\n * implement `createProperty` like this:\n *\n * ```ts\n * static createProperty(name, options) {\n * options = Object.assign(options, {myOption: true});\n * super.createProperty(name, options);\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n // If this is a state property, force the attribute to false.\n if (options.state) {\n (options as Mutable<PropertyDeclaration, 'attribute'>).attribute = false;\n }\n this.__prepare();\n // Whether this property is wrapping accessors.\n // Helps control the initial value change and reflection logic.\n if (this.prototype.hasOwnProperty(name)) {\n options = Object.create(options);\n options.wrapped = true;\n }\n this.elementProperties.set(name, options);\n if (!options.noAccessor) {\n const key = DEV_MODE\n ? // Use Symbol.for in dev mode to make it easier to maintain state\n // when doing HMR.\n Symbol.for(`${String(name)} (@property() cache)`)\n : Symbol();\n const descriptor = this.getPropertyDescriptor(name, key, options);\n if (descriptor !== undefined) {\n defineProperty(this.prototype, name, descriptor);\n }\n }\n }\n\n /**\n * Returns a property descriptor to be defined on the given named property.\n * If no descriptor is returned, the property will not become an accessor.\n * For example,\n *\n * ```ts\n * class MyElement extends LitElement {\n * static getPropertyDescriptor(name, key, options) {\n * const defaultDescriptor =\n * super.getPropertyDescriptor(name, key, options);\n * const setter = defaultDescriptor.set;\n * return {\n * get: defaultDescriptor.get,\n * set(value) {\n * setter.call(this, value);\n * // custom action.\n * },\n * configurable: true,\n * enumerable: true\n * }\n * }\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n protected static getPropertyDescriptor(\n name: PropertyKey,\n key: string | symbol,\n options: PropertyDeclaration\n ): PropertyDescriptor | undefined {\n const {get, set} = getOwnPropertyDescriptor(this.prototype, name) ?? {\n get(this: ReactiveElement) {\n return this[key as keyof typeof this];\n },\n set(this: ReactiveElement, v: unknown) {\n (this as unknown as Record<string | symbol, unknown>)[key] = v;\n },\n };\n if (DEV_MODE && get == null) {\n if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {\n throw new Error(\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it's actually declared as a value on the prototype. ` +\n `Usually this is due to using @property or @state on a method.`\n );\n }\n issueWarning(\n 'reactive-property-without-getter',\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it does not have a getter. This will be an error in a ` +\n `future version of Lit.`\n );\n }\n return {\n get,\n set(this: ReactiveElement, value: unknown) {\n const oldValue = get?.call(this);\n set?.call(this, value);\n this.requestUpdate(name, oldValue, options);\n },\n configurable: true,\n enumerable: true,\n };\n }\n\n /**\n * Returns the property options associated with the given property.\n * These options are defined with a `PropertyDeclaration` via the `properties`\n * object or the `@property` decorator and are registered in\n * `createProperty(...)`.\n *\n * Note, this method should be considered \"final\" and not overridden. To\n * customize the options for a given property, override\n * {@linkcode createProperty}.\n *\n * @nocollapse\n * @final\n * @category properties\n */\n static getPropertyOptions(name: PropertyKey) {\n return this.elementProperties.get(name) ?? defaultPropertyDeclaration;\n }\n\n // Temporary, until google3 is on TypeScript 5.2\n declare static [Symbol.metadata]: object & Record<PropertyKey, unknown>;\n\n /**\n * Initializes static own properties of the class used in bookkeeping\n * for element properties, initializers, etc.\n *\n * Can be called multiple times by code that needs to ensure these\n * properties exist before using them.\n *\n * This method ensures the superclass is finalized so that inherited\n * property metadata can be copied down.\n * @nocollapse\n */\n private static __prepare() {\n if (\n this.hasOwnProperty(JSCompiler_renameProperty('elementProperties', this))\n ) {\n // Already prepared\n return;\n }\n // Finalize any superclasses\n const superCtor = getPrototypeOf(this) as typeof ReactiveElement;\n superCtor.finalize();\n\n // Create own set of initializers for this class if any exist on the\n // superclass and copy them down. Note, for a small perf boost, avoid\n // creating initializers unless needed.\n if (superCtor._initializers !== undefined) {\n this._initializers = [...superCtor._initializers];\n }\n // Initialize elementProperties from the superclass\n this.elementProperties = new Map(superCtor.elementProperties);\n }\n\n /**\n * Finishes setting up the class so that it's ready to be registered\n * as a custom element and instantiated.\n *\n * This method is called by the ReactiveElement.observedAttributes getter.\n * If you override the observedAttributes getter, you must either call\n * super.observedAttributes to trigger finalization, or call finalize()\n * yourself.\n *\n * @nocollapse\n */\n protected static finalize() {\n if (this.hasOwnProperty(JSCompiler_renameProperty('finalized', this))) {\n return;\n }\n this.finalized = true;\n this.__prepare();\n\n // Create properties from the static properties block:\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n const propKeys = [\n ...getOwnPropertyNames(props),\n ...getOwnPropertySymbols(props),\n ] as Array<keyof typeof props>;\n for (const p of propKeys) {\n this.createProperty(p, props[p]);\n }\n }\n\n // Create properties from standard decorator metadata:\n const metadata = this[Symbol.metadata];\n if (metadata !== null) {\n const properties = litPropertyMetadata.get(metadata);\n if (properties !== undefined) {\n for (const [p, options] of properties) {\n this.elementProperties.set(p, options);\n }\n }\n }\n\n // Create the attribute-to-property map\n this.__attributeToPropertyMap = new Map();\n for (const [p, options] of this.elementProperties) {\n const attr = this.__attributeNameForProperty(p, options);\n if (attr !== undefined) {\n this.__attributeToPropertyMap.set(attr, p);\n }\n }\n\n this.elementStyles = this.finalizeStyles(this.styles);\n\n if (DEV_MODE) {\n if (this.hasOwnProperty('createProperty')) {\n issueWarning(\n 'no-override-create-property',\n 'Overriding ReactiveElement.createProperty() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n if (this.hasOwnProperty('getPropertyDescriptor')) {\n issueWarning(\n 'no-override-get-property-descriptor',\n 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n }\n }\n\n /**\n * Options used when calling `attachShadow`. Set this property to customize\n * the options for the shadowRoot; for example, to create a closed\n * shadowRoot: `{mode: 'closed'}`.\n *\n * Note, these options are used in `createRenderRoot`. If this method\n * is customized, options should be respected if possible.\n * @nocollapse\n * @category rendering\n */\n static shadowRootOptions: ShadowRootInit = {mode: 'open'};\n\n /**\n * Takes the styles the user supplied via the `static styles` property and\n * returns the array of styles to apply to the element.\n * Override this method to integrate into a style management system.\n *\n * Styles are deduplicated preserving the _last_ instance in the list. This\n * is a performance optimization to avoid duplicated styles that can occur\n * especially when composing via subclassing. The last item is kept to try\n * to preserve the cascade order with the assumption that it's most important\n * that last added styles override previous styles.\n *\n * @nocollapse\n * @category styles\n */\n protected static finalizeStyles(\n styles?: CSSResultGroup\n ): Array<CSSResultOrNative> {\n const elementStyles = [];\n if (Array.isArray(styles)) {\n // Dedupe the flattened array in reverse order to preserve the last items.\n // Casting to Array<unknown> works around TS error that\n // appears to come from trying to flatten a type CSSResultArray.\n const set = new Set((styles as Array<unknown>).flat(Infinity).reverse());\n // Then preserve original order by adding the set items in reverse order.\n for (const s of set) {\n elementStyles.unshift(getCompatibleStyle(s as CSSResultOrNative));\n }\n } else if (styles !== undefined) {\n elementStyles.push(getCompatibleStyle(styles));\n }\n return elementStyles;\n }\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n * @category rendering\n */\n readonly renderRoot!: HTMLElement | DocumentFragment;\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static __attributeNameForProperty(\n name: PropertyKey,\n options: PropertyDeclaration\n ) {\n const attribute = options.attribute;\n return attribute === false\n ? undefined\n : typeof attribute === 'string'\n ? attribute\n : typeof name === 'string'\n ? name.toLowerCase()\n : undefined;\n }\n\n // Initialize to an unresolved Promise so we can make sure the element has\n // connected before first update.\n private __updatePromise!: Promise<boolean>;\n\n /**\n * True if there is a pending update as a result of calling `requestUpdate()`.\n * Should only be read.\n * @category updates\n */\n isUpdatePending = false;\n\n /**\n * Is set to `true` after the first update. The element code cannot assume\n * that `renderRoot` exists before the element `hasUpdated`.\n * @category updates\n */\n hasUpdated = false;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n *\n * @internal\n */\n _$changedProperties!: PropertyValues;\n\n /**\n * Records property default values when the\n * `useDefault` option is used.\n */\n private __defaultValues?: Map<PropertyKey, unknown>;\n\n /**\n * Properties that should be reflected when updated.\n */\n private __reflectingProperties?: Set<PropertyKey>;\n\n /**\n * Name of currently reflecting property\n */\n private __reflectingProperty: PropertyKey | null = null;\n\n /**\n * Set of controllers.\n */\n private __controllers?: Set<ReactiveController>;\n\n constructor() {\n super();\n this.__initialize();\n }\n\n /**\n * Internal only override point for customizing work done when elements\n * are constructed.\n */\n private __initialize() {\n this.__updatePromise = new Promise<boolean>(\n (res) => (this.enableUpdating = res)\n );\n this._$changedProperties = new Map();\n // This enqueues a microtask that must run before the first update, so it\n // must be called before requestUpdate()\n this.__saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this.requestUpdate();\n (this.constructor as typeof ReactiveElement)._initializers?.forEach((i) =>\n i(this)\n );\n }\n\n /**\n * Registers a `ReactiveController` to participate in the element's reactive\n * update cycle. The element automatically calls into any registered\n * controllers during its lifecycle callbacks.\n *\n * If the element is connected when `addController()` is called, the\n * controller's `hostConnected()` callback will be immediately called.\n * @category controllers\n */\n addController(controller: ReactiveController) {\n (this.__controllers ??= new Set()).add(controller);\n // If a controller is added after the element has been connected,\n // call hostConnected. Note, re-using existence of `renderRoot` here\n // (which is set in connectedCallback) to avoid the need to track a\n // first connected state.\n if (this.renderRoot !== undefined && this.isConnected) {\n controller.hostConnected?.();\n }\n }\n\n /**\n * Removes a `ReactiveController` from the element.\n * @category controllers\n */\n removeController(controller: ReactiveController) {\n this.__controllers?.delete(controller);\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs.\n */\n private __saveInstanceProperties() {\n const instanceProperties = new Map<PropertyKey, unknown>();\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n for (const p of elementProperties.keys() as IterableIterator<keyof this>) {\n if (this.hasOwnProperty(p)) {\n instanceProperties.set(p, this[p]);\n delete this[p];\n }\n }\n if (instanceProperties.size > 0) {\n this.__instanceProperties = instanceProperties;\n }\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n *\n * @return Returns a node into which to render.\n * @category rendering\n */\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot;\n }\n\n /**\n * On first connection, creates the element's renderRoot, sets up\n * element styling, and enables updating.\n * @category lifecycle\n */\n connectedCallback() {\n // Create renderRoot before controllers `hostConnected`\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n this.enableUpdating(true);\n this.__controllers?.forEach((c) => c.hostConnected?.());\n }\n\n /**\n * Note, this method should be considered final and not overridden. It is\n * overridden on the element instance with a function that triggers the first\n * update.\n * @category updates\n */\n protected enableUpdating(_requestedUpdate: boolean) {}\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n * @category lifecycle\n */\n disconnectedCallback() {\n this.__controllers?.forEach((c) => c.hostDisconnected?.());\n }\n\n /**\n * Synchronizes property values when attributes change.\n *\n * Specifically, when an attribute is set, the corresponding property is set.\n * You should rarely need to implement this callback. If this method is\n * overridden, `super.attributeChangedCallback(name, _old, value)` must be\n * called.\n *\n * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes)\n * on MDN for more information about the `attributeChangedCallback`.\n * @category attributes\n */\n attributeChangedCallback(\n name: string,\n _old: string | null,\n value: string | null\n ) {\n this._$attributeToProperty(name, value);\n }\n\n private __propertyToAttribute(name: PropertyKey, value: unknown) {\n const elemProperties: PropertyDeclarationMap = (\n this.constructor as typeof ReactiveElement\n ).elementProperties;\n const options = elemProperties.get(name)!;\n const attr = (\n this.constructor as typeof ReactiveElement\n ).__attributeNameForProperty(name, options);\n if (attr !== undefined && options.reflect === true) {\n const converter =\n (options.converter as ComplexAttributeConverter)?.toAttribute !==\n undefined\n ? (options.converter as ComplexAttributeConverter)\n : defaultConverter;\n const attrValue = converter.toAttribute!(value, options.type);\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'migration'\n ) &&\n attrValue === undefined\n ) {\n issueWarning(\n 'undefined-attribute-value',\n `The attribute value for the ${name as string} property is ` +\n `undefined on element ${this.localName}. The attribute will be ` +\n `removed, but in the previous version of \\`ReactiveElement\\`, ` +\n `the attribute would not have changed.`\n );\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this.__reflectingProperty = name;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /** @internal */\n _$attributeToProperty(name: string, value: string | null) {\n const ctor = this.constructor as typeof ReactiveElement;\n // Note, hint this as an `AttributeMap` so closure clearly understands\n // the type; it has issues with tracking types through statics\n const propName = (ctor.__attributeToPropertyMap as AttributeMap).get(name);\n // Use tracking info to avoid reflecting a property value to an attribute\n // if it was just set because the attribute changed.\n if (propName !== undefined && this.__reflectingProperty !== propName) {\n const options = ctor.getPropertyOptions(propName);\n const converter =\n typeof options.converter === 'function'\n ? {fromAttribute: options.converter}\n : options.converter?.fromAttribute !== undefined\n ? options.converter\n : defaultConverter;\n // mark state reflecting\n this.__reflectingProperty = propName;\n const convertedValue = converter.fromAttribute!(value, options.type);\n this[propName as keyof this] =\n convertedValue ??\n this.__defaultValues?.get(propName) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (convertedValue as any);\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should be called\n * when an element should update based on some state not triggered by setting\n * a reactive property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored.\n *\n * @param name name of requesting property\n * @param oldValue old value of requesting property\n * @param options property options to use instead of the previously\n * configured options\n * @param useNewValue if true, the newValue argument is used instead of\n * reading the property value. This is important to use if the reactive\n * property is a standard private accessor, as opposed to a plain\n * property, since private members can't be dynamically read by name.\n * @param newValue the new value of the property. This is only used if\n * `useNewValue` is true.\n * @category updates\n */\n requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration,\n useNewValue = false,\n newValue?: unknown\n ): void {\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n if (DEV_MODE && (name as unknown) instanceof Event) {\n issueWarning(\n ``,\n `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`\n );\n }\n const ctor = this.constructor as typeof ReactiveElement;\n if (useNewValue === false) {\n newValue = this[name as keyof this];\n }\n options ??= ctor.getPropertyOptions(name);\n const changed =\n (options.hasChanged ?? notEqual)(newValue, oldValue) ||\n // When there is no change, check a corner case that can occur when\n // 1. there's a initial value which was not reflected\n // 2. the property is subsequently set to this value.\n // For example, `prop: {useDefault: true, reflect: true}`\n // and el.prop = 'foo'. This should be considered a change if the\n // attribute is not set because we will now reflect the property to the attribute.\n (options.useDefault &&\n options.reflect &&\n newValue === this.__defaultValues?.get(name) &&\n !this.hasAttribute(ctor.__attributeNameForProperty(name, options)!));\n if (changed) {\n this._$changeProperty(name, oldValue, options);\n } else {\n // Abort the request if the property should not be considered changed.\n return;\n }\n }\n if (this.isUpdatePending === false) {\n this.__updatePromise = this.__enqueueUpdate();\n }\n }\n\n /**\n * @internal\n */\n _$changeProperty(\n name: PropertyKey,\n oldValue: unknown,\n {useDefault, reflect, wrapped}: PropertyDeclaration,\n initializeValue?: unknown\n ) {\n // Record default value when useDefault is used. This allows us to\n // restore this value when the attribute is removed.\n if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) {\n this.__defaultValues.set(\n name,\n initializeValue ?? oldValue ?? this[name as keyof this]\n );\n // if this is not wrapping an accessor, it must be an initial setting\n // and in this case we do not want to record the change or reflect.\n if (wrapped !== true || initializeValue !== undefined) {\n return;\n }\n }\n // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(\n // vs just Map.set()\n if (!this._$changedProperties.has(name)) {\n // On the initial change, the old value should be `undefined`, except\n // with `useDefault`\n if (!this.hasUpdated && !useDefault) {\n oldValue = undefined;\n }\n this._$changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `__reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (reflect === true && this.__reflectingProperty !== name) {\n (this.__reflectingProperties ??= new Set<PropertyKey>()).add(name);\n }\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async __enqueueUpdate() {\n this.isUpdatePending = true;\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await this.__updatePromise;\n } catch (e) {\n // Refire any previous errors async so they do not disrupt the update\n // cycle. Errors are refired so developers have a chance to observe\n // them, and this can be done by implementing\n // `window.onunhandledrejection`.\n Promise.reject(e);\n }\n const result = this.scheduleUpdate();\n // If `scheduleUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n return !this.isUpdatePending;\n }\n\n /**\n * Schedules an element update. You can override this method to change the\n * timing of updates by returning a Promise. The update will await the\n * returned Promise, and you should resolve the Promise to allow the update\n * to proceed. If this method is overridden, `super.scheduleUpdate()`\n * must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```ts\n * override protected async scheduleUpdate(): Promise<unknown> {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.scheduleUpdate();\n * }\n * ```\n * @category updates\n */\n protected scheduleUpdate(): void | Promise<unknown> {\n const result = this.performUpdate();\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'async-perform-update'\n ) &&\n typeof (result as unknown as Promise<unknown> | undefined)?.then ===\n 'function'\n ) {\n issueWarning(\n 'async-perform-update',\n `Element ${this.localName} returned a Promise from performUpdate(). ` +\n `This behavior is deprecated and will be removed in a future ` +\n `version of ReactiveElement.`\n );\n }\n return result;\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * Call `performUpdate()` to immediately process a pending update. This should\n * generally not be needed, but it can be done in rare cases when you need to\n * update synchronously.\n *\n * @category updates\n */\n protected performUpdate(): void {\n // Abort any update if one is not pending when this is called.\n // This can happen if `performUpdate` is called early to \"flush\"\n // the update.\n if (!this.isUpdatePending) {\n return;\n }\n debugLogEvent?.({kind: 'update'});\n if (!this.hasUpdated) {\n // Create renderRoot before first update. This occurs in `connectedCallback`\n // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n if (DEV_MODE) {\n // Produce warning if any reactive properties on the prototype are\n // shadowed by class fields. Instance fields set before upgrade are\n // deleted by this point, so any own property is caused by class field\n // initialization in the constructor.\n const ctor = this.constructor as typeof ReactiveElement;\n const shadowedProperties = [...ctor.elementProperties.keys()].filter(\n (p) => this.hasOwnProperty(p) && p in getPrototypeOf(this)\n );\n if (shadowedProperties.length) {\n throw new Error(\n `The following properties on element ${this.localName} will not ` +\n `trigger updates as expected because they are set using class ` +\n `fields: ${shadowedProperties.join(', ')}. ` +\n `Native class fields and some compiled output will overwrite ` +\n `accessors used for detecting changes. See ` +\n `https://lit.dev/msg/class-field-shadowing ` +\n `for more information.`\n );\n }\n }\n // Mixin instance properties once, if they exist.\n if (this.__instanceProperties) {\n // TODO (justinfagnani): should we use the stored value? Could a new value\n // have been set since we stored the own property value?\n for (const [p, value] of this.__instanceProperties) {\n this[p as keyof this] = value as this[keyof this];\n }\n this.__instanceProperties = undefined;\n }\n // Trigger initial value reflection and populate the initial\n // `changedProperties` map, but only for the case of properties created\n // via `createProperty` on accessors, which will not have already\n // populated the `changedProperties` map since they are not set.\n // We can't know if these accessors had initializers, so we just set\n // them anyway - a difference from experimental decorators on fields and\n // standard decorators on auto-accessors.\n // For context see:\n // https://github.com/lit/lit/pull/4183#issuecomment-1711959635\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n if (elementProperties.size > 0) {\n for (const [p, options] of elementProperties) {\n const {wrapped} = options;\n const value = this[p as keyof this];\n if (\n wrapped === true &&\n !this._$changedProperties.has(p) &&\n value !== undefined\n ) {\n this._$changeProperty(p, undefined, options, value);\n }\n }\n }\n }\n let shouldUpdate = false;\n const changedProperties = this._$changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.willUpdate(changedProperties);\n this.__controllers?.forEach((c) => c.hostUpdate?.());\n this.update(changedProperties);\n } else {\n this.__markUpdated();\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n // Ensure element can accept additional updates after an exception.\n this.__markUpdated();\n throw e;\n }\n // The update is no longer considered pending and further updates are now allowed.\n if (shouldUpdate) {\n this._$didUpdate(changedProperties);\n }\n }\n\n /**\n * Invoked before `update()` to compute values needed during the update.\n *\n * Implement `willUpdate` to compute property values that depend on other\n * properties and are used in the rest of the update process.\n *\n * ```ts\n * willUpdate(changedProperties) {\n * // only need to check changed properties for an expensive computation.\n * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {\n * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);\n * }\n * }\n *\n * render() {\n * return html`SHA: ${this.sha}`;\n * }\n * ```\n *\n * @category updates\n */\n protected willUpdate(_changedProperties: PropertyValues): void {}\n\n // Note, this is an override point for polyfill-support.\n // @internal\n _$didUpdate(changedProperties: PropertyValues) {\n this.__controllers?.forEach((c) => c.hostUpdated?.());\n if (!this.hasUpdated) {\n this.hasUpdated = true;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n if (\n DEV_MODE &&\n this.isUpdatePending &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'change-in-update'\n )\n ) {\n issueWarning(\n 'change-in-update',\n `Element ${this.localName} scheduled an update ` +\n `(generally because a property was set) ` +\n `after an update completed, causing a new update to be scheduled. ` +\n `This is inefficient and should be avoided unless the next update ` +\n `can only be scheduled as a side effect of the previous update.`\n );\n }\n }\n\n private __markUpdated() {\n this._$changedProperties = new Map();\n this.isUpdatePending = false;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super.getUpdateComplete()`, then any subsequent state.\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n get updateComplete(): Promise<boolean> {\n return this.getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * ```ts\n * class MyElement extends LitElement {\n * override async getUpdateComplete() {\n * const result = await super.getUpdateComplete();\n * await this._myChild.updateComplete;\n * return result;\n * }\n * }\n * ```\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n protected getUpdateComplete(): Promise<boolean> {\n return this.__updatePromise;\n }\n\n /**\n * Controls whether or not `update()` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected update(_changedProperties: PropertyValues) {\n // The forEach() expression will only run when __reflectingProperties is\n // defined, and it returns undefined, setting __reflectingProperties to\n // undefined\n this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) =>\n this.__propertyToAttribute(p, this[p as keyof this])\n ) as undefined;\n this.__markUpdated();\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected updated(_changedProperties: PropertyValues) {}\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * ```ts\n * firstUpdated() {\n * this.renderRoot.getElementById('my-text-area').focus();\n * }\n * ```\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected firstUpdated(_changedProperties: PropertyValues) {}\n}\n// Assigned here to work around a jscompiler bug with static fields\n// when compiling to ES5.\n// https://github.com/google/closure-compiler/issues/3177\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('elementProperties', ReactiveElement)\n] = new Map();\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', ReactiveElement)\n] = new Map();\n\n// Apply polyfills if available\npolyfillSupport?.({ReactiveElement});\n\n// Dev mode warnings...\nif (DEV_MODE) {\n // Default warning set.\n ReactiveElement.enabledWarnings = [\n 'change-in-update',\n 'async-perform-update',\n ];\n const ensureOwnWarnings = function (ctor: typeof ReactiveElement) {\n if (\n !ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings', ctor))\n ) {\n ctor.enabledWarnings = ctor.enabledWarnings!.slice();\n }\n };\n ReactiveElement.enableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n if (!this.enabledWarnings!.includes(warning)) {\n this.enabledWarnings!.push(warning);\n }\n };\n ReactiveElement.disableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n const i = this.enabledWarnings!.indexOf(warning);\n if (i >= 0) {\n this.enabledWarnings!.splice(i, 1);\n }\n };\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for ReactiveElement usage.\n(global.reactiveElementVersions ??= []).push('2.1.2');\nif (DEV_MODE && global.reactiveElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// IMPORTANT: these imports must be type-only\nimport type {Directive, DirectiveResult, PartInfo} from './directive.js';\nimport type {TrustedHTML, TrustedTypesWindow} from 'trusted-types/lib/index.js';\n\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace LitUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | TemplatePrep\n | TemplateInstantiated\n | TemplateInstantiatedAndUpdated\n | TemplateUpdating\n | BeginRender\n | EndRender\n | CommitPartEntry\n | SetPartValue;\n export interface TemplatePrep {\n kind: 'template prep';\n template: Template;\n strings: TemplateStringsArray;\n clonableTemplate: HTMLTemplateElement;\n parts: TemplatePart[];\n }\n export interface BeginRender {\n kind: 'begin render';\n id: number;\n value: unknown;\n container: RenderRootNode;\n options: RenderOptions | undefined;\n part: ChildPart | undefined;\n }\n export interface EndRender {\n kind: 'end render';\n id: number;\n value: unknown;\n container: RenderRootNode;\n options: RenderOptions | undefined;\n part: ChildPart;\n }\n export interface TemplateInstantiated {\n kind: 'template instantiated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateInstantiatedAndUpdated {\n kind: 'template instantiated and updated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateUpdating {\n kind: 'template updating';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface SetPartValue {\n kind: 'set part';\n part: Part;\n value: unknown;\n valueIndex: number;\n values: unknown[];\n templateInstance: TemplateInstance;\n }\n\n export type CommitPartEntry =\n | CommitNothingToChildEntry\n | CommitText\n | CommitNode\n | CommitAttribute\n | CommitProperty\n | CommitBooleanAttribute\n | CommitEventListener\n | CommitToElementBinding;\n\n export interface CommitNothingToChildEntry {\n kind: 'commit nothing to child';\n start: ChildNode;\n end: ChildNode | null;\n parent: Disconnectable | undefined;\n options: RenderOptions | undefined;\n }\n\n export interface CommitText {\n kind: 'commit text';\n node: Text;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitNode {\n kind: 'commit node';\n start: Node;\n parent: Disconnectable | undefined;\n value: Node;\n options: RenderOptions | undefined;\n }\n\n export interface CommitAttribute {\n kind: 'commit attribute';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitProperty {\n kind: 'commit property';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitBooleanAttribute {\n kind: 'commit boolean attribute';\n element: Element;\n name: string;\n value: boolean;\n options: RenderOptions | undefined;\n }\n\n export interface CommitEventListener {\n kind: 'commit event listener';\n element: Element;\n name: string;\n value: unknown;\n oldListener: unknown;\n options: RenderOptions | undefined;\n // True if we're removing the old event listener (e.g. because settings changed, or value is nothing)\n removeListener: boolean;\n // True if we're adding a new event listener (e.g. because first render, or settings changed)\n addListener: boolean;\n }\n\n export interface CommitToElementBinding {\n kind: 'commit to element binding';\n element: Element;\n value: unknown;\n options: RenderOptions | undefined;\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: LitUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<LitUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n });\n}\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? (global.ShadyDOM!.wrap as <T extends Node>(node: T) => T)\n : <T extends Node>(node: T) => node;\n\nconst trustedTypes = (global as unknown as TrustedTypesWindow).trustedTypes;\n\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\n\n/**\n * Used to sanitize any value before it is written into the DOM. This can be\n * used to implement a security policy of allowed and disallowed values in\n * order to prevent XSS attacks.\n *\n * One way of using this callback would be to check attributes and properties\n * against a list of high risk fields, and require that values written to such\n * fields be instances of a class which is safe by construction. Closure's Safe\n * HTML Types is one implementation of this technique (\n * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).\n * The TrustedTypes polyfill in API-only mode could also be used as a basis\n * for this technique (https://github.com/WICG/trusted-types).\n *\n * @param node The HTML node (usually either a #text node or an Element) that\n * is being written to. Note that this is just an exemplar node, the write\n * may take place against another instance of the same class of node.\n * @param name The name of an attribute or property (for example, 'href').\n * @param type Indicates whether the write that's about to be performed will\n * be to a property or a node.\n * @return A function that will sanitize this class of writes.\n */\nexport type SanitizerFactory = (\n node: Node,\n name: string,\n type: 'property' | 'attribute'\n) => ValueSanitizer;\n\n/**\n * A function which can sanitize values that will be written to a specific kind\n * of DOM sink.\n *\n * See SanitizerFactory.\n *\n * @param value The value to sanitize. Will be the actual value passed into\n * the lit-html template literal, so this could be of any type.\n * @return The value to write to the DOM. Usually the same as the input value,\n * unless sanitization is needed.\n */\nexport type ValueSanitizer = (value: unknown) => unknown;\n\nconst identityFunction: ValueSanitizer = (value: unknown) => value;\nconst noopSanitizer: SanitizerFactory = (\n _node: Node,\n _name: string,\n _type: 'property' | 'attribute'\n) => identityFunction;\n\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer: SanitizerFactory) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(\n `Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`\n );\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\n\nconst createSanitizer: SanitizerFactory = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${Math.random().toFixed(9).slice(2)}$`;\n\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\n\nconst d =\n NODE_MODE && global.document === undefined\n ? ({\n createTreeWalker() {\n return {};\n },\n } as unknown as Document)\n : document;\n\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = () => d.createComment('');\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\nconst isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (value as any)?.[Symbol.iterator] === 'function';\n\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\n\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(\n `>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`,\n 'g'\n);\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\n\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\nconst MATHML_RESULT = 3;\n\ntype ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;\n\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n */\nexport type UncompiledTemplateResult<T extends ResultType = ResultType> = {\n // This property needs to remain unminified.\n ['_$litType$']: T;\n strings: TemplateStringsArray;\n values: unknown[];\n};\n\n/**\n * This is a template result that may be either uncompiled or compiled.\n *\n * In the future, TemplateResult will be this type. If you want to explicitly\n * note that a template result is potentially compiled, you can reference this\n * type and it will continue to behave the same through the next major version\n * of Lit. This can be useful for code that wants to prepare for the next\n * major version of Lit.\n */\nexport type MaybeCompiledTemplateResult<T extends ResultType = ResultType> =\n | UncompiledTemplateResult<T>\n | CompiledTemplateResult;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg}.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n * In Lit 4, this type will be an alias of\n * MaybeCompiledTemplateResult, so that code will get type errors if it assumes\n * that Lit templates are not compiled. When deliberately working with only\n * one, use either {@linkcode CompiledTemplateResult} or\n * {@linkcode UncompiledTemplateResult} explicitly.\n */\nexport type TemplateResult<T extends ResultType = ResultType> =\n UncompiledTemplateResult<T>;\n\nexport type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;\n\nexport type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;\n\nexport type MathMLTemplateResult = TemplateResult<typeof MATHML_RESULT>;\n\n/**\n * A TemplateResult that has been compiled by @lit-labs/compiler, skipping the\n * prepare step.\n */\nexport interface CompiledTemplateResult {\n // This is a factory in order to make template initialization lazy\n // and allow ShadyRenderOptions scope to be passed in.\n // This property needs to remain unminified.\n ['_$litType$']: CompiledTemplate;\n values: unknown[];\n}\n\nexport interface CompiledTemplate extends Omit<Template, 'el'> {\n // el is overridden to be optional. We initialize it on first render\n el?: HTMLTemplateElement;\n\n // The prepared HTML string to create a template element from.\n // The type is a TemplateStringsArray to guarantee that the value came from\n // source code, preventing a JSON injection attack.\n h: TemplateStringsArray;\n}\n\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag =\n <T extends ResultType>(type: T) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult<T> => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn(\n 'Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.'\n );\n }\n if (DEV_MODE) {\n // Import static-html.js results in a circular dependency which g3 doesn't\n // handle. Instead we know that static values must have the field\n // `_$litStatic$`.\n if (\n values.some((val) => (val as {_$litStatic$: unknown})?.['_$litStatic$'])\n ) {\n issueWarning(\n '',\n `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\\n` +\n `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`\n );\n }\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n\n/**\n * Interprets a template literal as an SVG fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus not be properly contained within an `<svg>` HTML\n * element.\n */\nexport const svg = tag(SVG_RESULT);\n\n/**\n * Interprets a template literal as MathML fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const num = mathml`<mn>1</mn>`;\n *\n * const eq = html`\n * <math>\n * ${num}\n * </math>`;\n * ```\n *\n * The `mathml` *tag function* should only be used for MathML fragments, or\n * elements that would be contained **inside** a `<math>` HTML element. A common\n * error is placing a `<math>` *element* in a template tagged with the `mathml`\n * tag function. The `<math>` element is an HTML element and should be used\n * within a template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an MathML fragment from the\n * `render()` method, as the MathML fragment will be contained within the\n * element's shadow root and thus not be properly contained within a `<math>`\n * HTML element.\n */\nexport const mathml = tag(MATHML_RESULT);\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - they must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\n/**\n * Object specifying options for controlling lit-html rendering. Note that\n * while `render` may be called multiple times on the same `container` (and\n * `renderBefore` reference node) to efficiently update the rendered content,\n * only the options passed in during the first render are respected during\n * the lifetime of renders to that unique `container` + `renderBefore`\n * combination.\n */\nexport interface RenderOptions {\n /**\n * An object to use as the `this` value for event listeners. It's often\n * useful to set this to the host component rendering a template.\n */\n host?: object;\n /**\n * A DOM node before which to render content in the container.\n */\n renderBefore?: ChildNode | null;\n /**\n * Node used for cloning the template (`importNode` will be called on this\n * node). This controls the `ownerDocument` of the rendered DOM, along with\n * any inherited context. Defaults to the global `document`.\n */\n creationScope?: {importNode(node: Node, deep?: boolean): Node};\n /**\n * The initial connected state for the top-level part being rendered. If no\n * `isConnected` option is set, `AsyncDirective`s will be connected by\n * default. Set to `false` if the initial render occurs in a disconnected tree\n * and `AsyncDirective`s should see `isConnected === false` for their initial\n * render. The `part.setConnected()` method must be used subsequent to initial\n * render to change the connected state of the part.\n */\n isConnected?: boolean;\n}\n\n/**\n * The root DOM node for rendering.\n */\nexport type RenderRootNode = HTMLElement | SVGElement | DocumentFragment;\n\nconst walker = d.createTreeWalker(\n d,\n 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */\n);\n\nlet sanitizerFactoryInternal: SanitizerFactory = noopSanitizer;\n\n//\n// Classes only below here, const variable declarations only above here...\n//\n// Keeping variable declarations and classes together improves minification.\n// Interfaces and type aliases can be interleaved freely.\n//\n\n// Type for classes that have a `_directive` or `_directives[]` field, used by\n// `resolveDirective`\nexport interface DirectiveParent {\n _$parent?: DirectiveParent;\n _$isConnected: boolean;\n __directive?: Directive;\n __directives?: Array<Directive | undefined>;\n}\n\nfunction trustFromTemplateString(\n tsa: TemplateStringsArray,\n stringFromTSA: string\n): TrustedHTML {\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n return policy !== undefined\n ? policy.createHTML(stringFromTSA)\n : (stringFromTSA as unknown as TrustedHTML);\n}\n\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (\n strings: TemplateStringsArray,\n type: ResultType\n): [TrustedHTML, Array<string>] => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames: Array<string> = [];\n let html =\n type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';\n\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex: RegExp | undefined;\n\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName: string | undefined;\n let lastIndex = 0;\n let match!: RegExpExecArray | null;\n\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n } else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n } else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n } else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error(\n 'Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions'\n );\n }\n regex = tagEndRegex;\n }\n } else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n } else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n } else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n } else if (\n regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex\n ) {\n regex = tagEndRegex;\n } else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n } else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(\n attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex,\n 'unexpected parse state B'\n );\n }\n\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end =\n regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName!),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s + marker + (attrNameEndIndex === -2 ? i : end);\n }\n\n const htmlResult: string | TrustedHTML =\n html +\n (strings[l] || '<?>') +\n (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');\n\n // Returned as an array for terseness\n return [trustFromTemplateString(strings, htmlResult), attrNames];\n};\n\n/** @internal */\nexport type {Template};\nclass Template {\n /** @internal */\n el!: HTMLTemplateElement;\n\n parts: Array<TemplatePart> = [];\n\n constructor(\n // This property needs to remain unminified.\n {strings, ['_$litType$']: type}: UncompiledTemplateResult,\n options?: RenderOptions\n ) {\n let node: Node | null;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n\n // Re-parent SVG or MathML nodes into template root\n if (type === SVG_RESULT || type === MATHML_RESULT) {\n const wrapper = this.el.content.firstChild!;\n wrapper.replaceWith(...wrapper.childNodes);\n }\n\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = (node as Element).localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (\n /^(?:textarea|template)$/i!.test(tag) &&\n (node as Element).innerHTML.includes(marker)\n ) {\n const m =\n `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n } else issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if ((node as Element).hasAttributes()) {\n for (const name of (node as Element).getAttributeNames()) {\n if (name.endsWith(boundAttributeSuffix)) {\n const realName = attrNames[attrNameIndex++];\n const value = (node as Element).getAttribute(name)!;\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName)!;\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor:\n m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n (node as Element).removeAttribute(name);\n } else if (name.startsWith(marker)) {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n (node as Element).removeAttribute(name);\n }\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test((node as Element).tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = (node as Element).textContent!.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n (node as Element).textContent = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for child parts\n for (let i = 0; i < lastIndex; i++) {\n (node as Element).append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({type: CHILD_PART, index: ++nodeIndex});\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n (node as Element).append(strings[lastIndex], createMarker());\n }\n }\n } else if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data === markerMatch) {\n parts.push({type: CHILD_PART, index: nodeIndex});\n } else {\n let i = -1;\n while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({type: COMMENT_PART, index: nodeIndex});\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n\n if (DEV_MODE) {\n // If there was a duplicate attribute on a tag, then when the tag is\n // parsed into an element the attribute gets de-duplicated. We can detect\n // this mismatch if we haven't precisely consumed every attribute name\n // when preparing the template. This works because `attrNames` is built\n // from the template string and `attrNameIndex` comes from processing the\n // resulting DOM.\n if (attrNames.length !== attrNameIndex) {\n throw new Error(\n `Detected duplicate attribute bindings. This occurs if your template ` +\n `has duplicate attributes on an element tag. For example ` +\n `\"<input ?disabled=\\${true} ?disabled=\\${false}>\" contains a ` +\n `duplicate \"disabled\" attribute. The error was detected in ` +\n `the following template: \\n` +\n '`' +\n strings.join('${...}') +\n '`'\n );\n }\n }\n\n // We could set walker.currentNode to another node here to prevent a memory\n // leak, but every time we prepare a template, we immediately render it\n // and re-use the walker in new TemplateInstance._clone().\n debugLogEvent &&\n debugLogEvent({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html: TrustedHTML, _options?: RenderOptions) {\n const el = d.createElement('template');\n el.innerHTML = html as unknown as string;\n return el;\n }\n}\n\nexport interface Disconnectable {\n _$parent?: Disconnectable;\n _$disconnectableChildren?: Set<Disconnectable>;\n // Rather than hold connection state on instances, Disconnectables recursively\n // fetch the connection state from the RootPart they are connected in via\n // getters up the Disconnectable tree via _$parent references. This pushes the\n // cost of tracking the isConnected state to `AsyncDirectives`, and avoids\n // needing to pass all Disconnectables (parts, template instances, and\n // directives) their connection state each time it changes, which would be\n // costly for trees that have no AsyncDirectives.\n _$isConnected: boolean;\n}\n\nfunction resolveDirective(\n part: ChildPart | AttributePart | ElementPart,\n value: unknown,\n parent: DirectiveParent = part,\n attributeIndex?: number\n): unknown {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective =\n attributeIndex !== undefined\n ? (parent as AttributePart).__directives?.[attributeIndex]\n : (parent as ChildPart | ElementPart | Directive).__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n (value as DirectiveResult)['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n } else {\n currentDirective = new nextDirectiveConstructor(part as PartInfo);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n ((parent as AttributePart).__directives ??= [])[attributeIndex] =\n currentDirective;\n } else {\n (parent as ChildPart | Directive).__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(\n part,\n currentDirective._$resolve(part, (value as DirectiveResult).values),\n currentDirective,\n attributeIndex\n );\n }\n return value;\n}\n\nexport type {TemplateInstance};\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance implements Disconnectable {\n _$template: Template;\n _$parts: Array<Part | undefined> = [];\n\n /** @internal */\n _$parent: ChildPart;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n constructor(template: Template, parent: ChildPart) {\n this._$template = template;\n this._$parent = parent;\n }\n\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options: RenderOptions | undefined) {\n const {\n el: {content},\n parts: parts,\n } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n\n let node = walker.nextNode()!;\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part: Part | undefined;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(\n node as HTMLElement,\n node.nextSibling,\n this,\n options\n );\n } else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n this,\n options\n );\n } else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node as HTMLElement, this, options);\n }\n this._$parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode()!;\n nodeIndex++;\n }\n }\n // We need to set the currentNode away from the cloned tree so that we\n // don't hold onto the tree even if the tree is detached and should be\n // freed.\n walker.currentNode = d;\n return fragment;\n }\n\n _update(values: Array<unknown>) {\n let i = 0;\n for (const part of this._$parts) {\n if (part !== undefined) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if ((part as AttributePart).strings !== undefined) {\n (part as AttributePart)._$setValue(values, part as AttributePart, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += (part as AttributePart).strings!.length - 2;\n } else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\n\n/*\n * Parts\n */\ntype AttributeTemplatePart = {\n readonly type: typeof ATTRIBUTE_PART;\n readonly index: number;\n readonly name: string;\n readonly ctor: typeof AttributePart;\n readonly strings: ReadonlyArray<string>;\n};\ntype ChildTemplatePart = {\n readonly type: typeof CHILD_PART;\n readonly index: number;\n};\ntype ElementTemplatePart = {\n readonly type: typeof ELEMENT_PART;\n readonly index: number;\n};\ntype CommentTemplatePart = {\n readonly type: typeof COMMENT_PART;\n readonly index: number;\n};\n\n/**\n * A TemplatePart represents a dynamic part in a template, before the template\n * is instantiated. When a template is instantiated Parts are created from\n * TemplateParts.\n */\ntype TemplatePart =\n | ChildTemplatePart\n | AttributeTemplatePart\n | ElementTemplatePart\n | CommentTemplatePart;\n\nexport type Part =\n | ChildPart\n | AttributePart\n | PropertyPart\n | BooleanAttributePart\n | ElementPart\n | EventPart;\n\nexport type {ChildPart};\nclass ChildPart implements Disconnectable {\n readonly type = CHILD_PART;\n readonly options: RenderOptions | undefined;\n _$committedValue: unknown = nothing;\n /** @internal */\n __directive?: Directive;\n /** @internal */\n _$startNode: ChildNode;\n /** @internal */\n _$endNode: ChildNode | null;\n private _textSanitizer: ValueSanitizer | undefined;\n /** @internal */\n _$parent: Disconnectable | undefined;\n /**\n * Connection state for RootParts only (i.e. ChildPart without _$parent\n * returned from top-level `render`). This field is unused otherwise. The\n * intention would be clearer if we made `RootPart` a subclass of `ChildPart`\n * with this field (and a different _$isConnected getter), but the subclass\n * caused a perf regression, possibly due to making call sites polymorphic.\n * @internal\n */\n __isConnected: boolean;\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /** @internal */\n _$notifyConnectionChanged?(\n isConnected: boolean,\n removeFromParent?: boolean,\n from?: number\n ): void;\n /** @internal */\n _$reparentDisconnectables?(parent: Disconnectable): void;\n\n constructor(\n startNode: ChildNode,\n endNode: ChildNode | null,\n parent: TemplateInstance | ChildPart | undefined,\n options: RenderOptions | undefined\n ) {\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode(): Node {\n let parentNode: Node = wrap(this._$startNode).parentNode!;\n const parent = this._$parent;\n if (\n parent !== undefined &&\n parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */\n ) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = (parent as ChildPart | TemplateInstance).parentNode;\n }\n return parentNode;\n }\n\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode(): Node | null {\n return this._$startNode;\n }\n\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode(): Node | null {\n return this._$endNode;\n }\n\n _$setValue(value: unknown, directiveParent: DirectiveParent = this): void {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(\n `This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`\n );\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n } else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n } else if ((value as TemplateResult)['_$litType$'] !== undefined) {\n this._commitTemplateResult(value as TemplateResult);\n } else if ((value as Node).nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(\n `[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`\n );\n console.warn(\n `Attempted to render the template host`,\n value,\n `inside itself. This is almost always a mistake, and in dev mode `,\n `we render some warning text. In production however, we'll `,\n `render it, which will usually result in an error, and sometimes `,\n `in the element disappearing from the DOM.`\n );\n return;\n }\n this._commitNode(value as Node);\n } else if (isIterable(value)) {\n this._commitIterable(value);\n } else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n\n private _insert<T extends Node>(node: T) {\n return wrap(wrap(this._$startNode).parentNode!).insertBefore(\n node,\n this._$endNode\n );\n }\n\n private _commitNode(value: Node): void {\n if (this._$committedValue !== value) {\n this._$clear();\n if (\n ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer\n ) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n } else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n\n private _commitText(value: unknown): void {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (\n this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)\n ) {\n const node = wrap(this._$startNode).nextSibling as Text;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n (node as Text).data = value as string;\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = d.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value as string;\n } else {\n this._commitNode(d.createTextNode(value as string));\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling as Text,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n\n private _commitTemplateResult(\n result: TemplateResult | CompiledTemplateResult\n ): void {\n // This property needs to remain unminified.\n const {values, ['_$litType$']: type} = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template: Template | CompiledTemplate =\n typeof type === 'number'\n ? this._$getTemplate(result as UncompiledTemplateResult)\n : (type.el === undefined &&\n (type.el = Template.createElement(\n trustFromTemplateString(type.h, type.h[0]),\n this.options\n )),\n type);\n\n if ((this._$committedValue as TemplateInstance)?._$template === template) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'template updating',\n template,\n instance: this._$committedValue as TemplateInstance,\n parts: (this._$committedValue as TemplateInstance)._$parts,\n options: this.options,\n values,\n });\n (this._$committedValue as TemplateInstance)._update(values);\n } else {\n const instance = new TemplateInstance(template as Template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result: UncompiledTemplateResult) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n\n private _commitIterable(value: Iterable<unknown>): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue as ChildPart[];\n let partIndex = 0;\n let itemPart: ChildPart | undefined;\n\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push(\n (itemPart = new ChildPart(\n this._insert(createMarker()),\n this._insert(createMarker()),\n this,\n this.options\n ))\n );\n } else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(\n itemPart && wrap(itemPart._$endNode!).nextSibling,\n partIndex\n );\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives\n * in those Parts.\n *\n * @internal\n */\n _$clear(\n start: ChildNode | null = wrap(this._$startNode).nextSibling,\n from?: number\n ) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start !== this._$endNode) {\n // The non-null assertion is safe because if _$startNode.nextSibling is\n // null, then _$endNode is also null, and we would not have entered this\n // loop.\n const n = wrap(start!).nextSibling;\n wrap(start!).remove();\n start = n;\n }\n }\n\n /**\n * Implementation of RootPart's `isConnected`. Note that this method\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected: boolean) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n } else if (DEV_MODE) {\n throw new Error(\n 'part.setConnected() may only be called on a ' +\n 'RootPart returned from render().'\n );\n }\n }\n}\n\n/**\n * A top-level `ChildPart` returned from `render` that manages the connected\n * state of `AsyncDirective`s created throughout the tree below it.\n */\nexport interface RootPart extends ChildPart {\n /**\n * Sets the connection state for `AsyncDirective`s contained within this root\n * ChildPart.\n *\n * lit-html does not automatically monitor the connectedness of DOM rendered;\n * as such, it is the responsibility of the caller to `render` to ensure that\n * `part.setConnected(false)` is called before the part object is potentially\n * discarded, to ensure that `AsyncDirective`s have a chance to dispose of\n * any resources being held. If a `RootPart` that was previously\n * disconnected is subsequently re-connected (and its `AsyncDirective`s should\n * re-connect), `setConnected(true)` should be called.\n *\n * @param isConnected Whether directives within this tree should be connected\n * or not\n */\n setConnected(isConnected: boolean): void;\n}\n\nexport type {AttributePart};\nclass AttributePart implements Disconnectable {\n readonly type:\n | typeof ATTRIBUTE_PART\n | typeof PROPERTY_PART\n | typeof BOOLEAN_ATTRIBUTE_PART\n | typeof EVENT_PART = ATTRIBUTE_PART;\n readonly element: HTMLElement;\n readonly name: string;\n readonly options: RenderOptions | undefined;\n\n /**\n * If this attribute part represents an interpolation, this contains the\n * static strings of the interpolation. For single-value, complete bindings,\n * this is undefined.\n */\n readonly strings?: ReadonlyArray<string>;\n /** @internal */\n _$committedValue: unknown | Array<unknown> = nothing;\n /** @internal */\n __directives?: Array<Directive | undefined>;\n /** @internal */\n _$parent: Disconnectable;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n protected _sanitizer: ValueSanitizer | undefined;\n\n get tagName() {\n return this.element.tagName;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n } else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(\n value: unknown | Array<unknown>,\n directiveParent: DirectiveParent = this,\n valueIndex?: number,\n noCommit?: boolean\n ) {\n const strings = this.strings;\n\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n } else {\n // Interpolation case\n const values = value as Array<unknown>;\n value = strings[0];\n\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex! + i], directiveParent, i);\n\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = (this._$committedValue as Array<unknown>)[i];\n }\n change ||=\n !isPrimitive(v) || v !== (this._$committedValue as Array<unknown>)[i];\n if (v === nothing) {\n value = nothing;\n } else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n (this._$committedValue as Array<unknown>)[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n\n /** @internal */\n _commitValue(value: unknown) {\n if (value === nothing) {\n (wrap(this.element) as Element).removeAttribute(this.name);\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'attribute'\n );\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n (wrap(this.element) as Element).setAttribute(\n this.name,\n (value ?? '') as string\n );\n }\n }\n}\n\nexport type {PropertyPart};\nclass PropertyPart extends AttributePart {\n override readonly type = PROPERTY_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'property'\n );\n }\n value = this._sanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.element as any)[this.name] = value === nothing ? undefined : value;\n }\n}\n\nexport type {BooleanAttributePart};\nclass BooleanAttributePart extends AttributePart {\n override readonly type = BOOLEAN_ATTRIBUTE_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n (wrap(this.element) as Element).toggleAttribute(\n this.name,\n !!value && value !== nothing\n );\n }\n}\n\ntype EventListenerWithOptions = EventListenerOrEventListenerObject &\n Partial<AddEventListenerOptions>;\n\n/**\n * An AttributePart that manages an event listener via add/removeEventListener.\n *\n * This part works by adding itself as the event listener on an element, then\n * delegating to the value passed to it. This reduces the number of calls to\n * add/removeEventListener if the listener changes frequently, such as when an\n * inline function is used as a listener.\n *\n * Because event options are passed when adding listeners, we must take case\n * to add and remove the part as a listener when the event options change.\n */\nexport type {EventPart};\nclass EventPart extends AttributePart {\n override readonly type = EVENT_PART;\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n super(element, name, strings, parent, options);\n\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(\n `A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.'\n );\n }\n }\n\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n override _$setValue(\n newListener: unknown,\n directiveParent: DirectiveParent = this\n ) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener =\n (newListener === nothing && oldListener !== nothing) ||\n (newListener as EventListenerWithOptions).capture !==\n (oldListener as EventListenerWithOptions).capture ||\n (newListener as EventListenerWithOptions).once !==\n (oldListener as EventListenerWithOptions).once ||\n (newListener as EventListenerWithOptions).passive !==\n (oldListener as EventListenerWithOptions).passive;\n\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener =\n newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.name,\n this,\n oldListener as EventListenerWithOptions\n );\n }\n if (shouldAddListener) {\n this.element.addEventListener(\n this.name,\n this,\n newListener as EventListenerWithOptions\n );\n }\n this._$committedValue = newListener;\n }\n\n handleEvent(event: Event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n } else {\n (this._$committedValue as EventListenerObject).handleEvent(event);\n }\n }\n}\n\nexport type {ElementPart};\nclass ElementPart implements Disconnectable {\n readonly type = ELEMENT_PART;\n\n /** @internal */\n __directive?: Directive;\n\n // This is to ensure that every Part has a _$committedValue\n _$committedValue: undefined;\n\n /** @internal */\n _$parent!: Disconnectable;\n\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n options: RenderOptions | undefined;\n\n constructor(\n public element: Element,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this._$parent = parent;\n this.options = options;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n _$setValue(value: unknown): void {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in tests and private-ssr-support\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('3.3.3');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`\n );\n });\n}\n\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (\n value: unknown,\n container: RenderRootNode,\n options?: RenderOptions\n): RootPart => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part: ChildPart = (partOwnerNode as any)['_$litPart$'];\n debugLogEvent &&\n debugLogEvent({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (partOwnerNode as any)['_$litPart$'] = part = new ChildPart(\n container.insertBefore(createMarker(), endNode),\n endNode,\n undefined,\n options ?? {}\n );\n }\n part._$setValue(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part as RootPart;\n};\n\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The main LitElement module, which defines the {@linkcode LitElement} base\n * class and related APIs.\n *\n * LitElement components can define a template and a set of observed\n * properties. Changing an observed property triggers a re-render of the\n * element.\n *\n * Import {@linkcode LitElement} and {@linkcode html} from this module to\n * create a component:\n *\n * ```js\n * import {LitElement, html} from 'lit-element';\n *\n * class MyElement extends LitElement {\n *\n * // Declare observed properties\n * static get properties() {\n * return {\n * adjective: {}\n * }\n * }\n *\n * constructor() {\n * this.adjective = 'awesome';\n * }\n *\n * // Define the element's template\n * render() {\n * return html`<p>your ${adjective} template here</p>`;\n * }\n * }\n *\n * customElements.define('my-element', MyElement);\n * ```\n *\n * `LitElement` extends {@linkcode ReactiveElement} and adds lit-html\n * templating. The `ReactiveElement` class is provided for users that want to\n * build their own custom element base classes that don't use lit-html.\n *\n * @packageDocumentation\n */\nimport {PropertyValues, ReactiveElement} from '@lit/reactive-element';\nimport {render, RenderOptions, noChange, RootPart} from 'lit-html';\nexport * from '@lit/reactive-element';\nexport * from 'lit-html';\n\nimport {LitUnstable} from 'lit-html';\nimport {ReactiveUnstable} from '@lit/reactive-element';\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace Unstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | LitUnstable.DebugLog.Entry\n | ReactiveUnstable.DebugLog.Entry;\n }\n}\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\nconst DEV_MODE = true;\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n/**\n * Base element class that manages element properties and attributes, and\n * renders a lit-html template.\n *\n * To define a component, subclass `LitElement` and implement a\n * `render` method to provide the component's template. Define properties\n * using the {@linkcode LitElement.properties properties} property or the\n * {@linkcode property} decorator.\n */\nexport class LitElement extends ReactiveElement {\n // This property needs to remain unminified.\n static ['_$litElement$'] = true;\n\n /**\n * @category rendering\n */\n readonly renderOptions: RenderOptions = {host: this};\n\n private __childPart: RootPart | undefined = undefined;\n\n /**\n * @category rendering\n */\n protected override createRenderRoot() {\n const renderRoot = super.createRenderRoot();\n // When adoptedStyleSheets are shimmed, they are inserted into the\n // shadowRoot by createRenderRoot. Adjust the renderBefore node so that\n // any styles in Lit content render before adoptedStyleSheets. This is\n // important so that adoptedStyleSheets have precedence over styles in\n // the shadowRoot.\n this.renderOptions.renderBefore ??= renderRoot!.firstChild as ChildNode;\n return renderRoot;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * @param changedProperties Map of changed properties with old values\n * @category updates\n */\n protected override update(changedProperties: PropertyValues) {\n // Setting properties in `render` should not trigger an update. Since\n // updates are allowed after super.update, it's important to call `render`\n // before that.\n const value = this.render();\n if (!this.hasUpdated) {\n this.renderOptions.isConnected = this.isConnected;\n }\n super.update(changedProperties);\n this.__childPart = render(value, this.renderRoot, this.renderOptions);\n }\n\n /**\n * Invoked when the component is added to the document's DOM.\n *\n * In `connectedCallback()` you should setup tasks that should only occur when\n * the element is connected to the document. The most common of these is\n * adding event listeners to nodes external to the element, like a keydown\n * event handler added to the window.\n *\n * ```ts\n * connectedCallback() {\n * super.connectedCallback();\n * addEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * Typically, anything done in `connectedCallback()` should be undone when the\n * element is disconnected, in `disconnectedCallback()`.\n *\n * @category lifecycle\n */\n override connectedCallback() {\n super.connectedCallback();\n this.__childPart?.setConnected(true);\n }\n\n /**\n * Invoked when the component is removed from the document's DOM.\n *\n * This callback is the main signal to the element that it may no longer be\n * used. `disconnectedCallback()` should ensure that nothing is holding a\n * reference to the element (such as event listeners added to nodes external\n * to the element), so that it is free to be garbage collected.\n *\n * ```ts\n * disconnectedCallback() {\n * super.disconnectedCallback();\n * window.removeEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * An element may be re-connected after being disconnected.\n *\n * @category lifecycle\n */\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__childPart?.setConnected(false);\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method may return\n * any value renderable by lit-html's `ChildPart` - typically a\n * `TemplateResult`. Setting properties inside this method will *not* trigger\n * the element to update.\n * @category rendering\n */\n protected render(): unknown {\n return noChange;\n }\n}\n\n/**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See @lit/reactive-element for more information.\n */\n(LitElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', LitElement)\n] = true;\n\n// Install hydration if available\nglobal.litElementHydrateSupport?.({LitElement});\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litElementPolyfillSupportDevMode\n : global.litElementPolyfillSupport;\npolyfillSupport?.({LitElement});\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LE object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-html, since this module re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LE = {\n _$attributeToProperty: (\n el: LitElement,\n name: string,\n value: string | null\n ) => {\n // eslint-disable-next-line\n (el as any)._$attributeToProperty(name, value);\n },\n // eslint-disable-next-line\n _$changedProperties: (el: LitElement) => (el as any)._$changedProperties,\n};\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n(global.litElementVersions ??= []).push('4.2.2');\nif (DEV_MODE && global.litElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport type {Constructor} from './base.js';\n\n/**\n * Allow for custom element classes with private constructors\n */\ntype CustomElementClass = Omit<typeof HTMLElement, 'new'>;\n\nexport type CustomElementDecorator = {\n // legacy\n (cls: CustomElementClass): void;\n\n // standard\n (\n target: CustomElementClass,\n context: ClassDecoratorContext<Constructor<HTMLElement>>\n ): void;\n};\n\n/**\n * Class decorator factory that defines the decorated class as a custom element.\n *\n * ```js\n * @customElement('my-element')\n * class MyElement extends LitElement {\n * render() {\n * return html``;\n * }\n * }\n * ```\n * @category Decorator\n * @param tagName The tag name of the custom element to define.\n */\nexport const customElement =\n (tagName: string): CustomElementDecorator =>\n (\n classOrTarget: CustomElementClass | Constructor<HTMLElement>,\n context?: ClassDecoratorContext<Constructor<HTMLElement>>\n ) => {\n if (context !== undefined) {\n context.addInitializer(() => {\n customElements.define(\n tagName,\n classOrTarget as CustomElementConstructor\n );\n });\n } else {\n customElements.define(tagName, classOrTarget as CustomElementConstructor);\n }\n };\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options, true, v);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options, true, value);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {property} from './property.js';\n\nexport interface StateDeclaration<Type = unknown> {\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n}\n\n/**\n * @deprecated use StateDeclaration\n */\nexport type InternalPropertyDeclaration<Type = unknown> =\n StateDeclaration<Type>;\n\n/**\n * Declares a private or protected reactive property that still triggers\n * updates to the element when it changes. It does not reflect from the\n * corresponding attribute.\n *\n * Properties declared this way must not be used from HTML or HTML templating\n * systems, they're solely for properties internal to the element. These\n * properties may be renamed by optimization tools like closure compiler.\n * @category Decorator\n */\nexport function state(options?: StateDeclaration) {\n return property({\n ...options,\n // Add both `state` and `attribute` because we found a third party\n // controller that is keying off of PropertyOptions.state to determine\n // whether a field is a private internal property or not.\n state: true,\n attribute: false,\n });\n}\n", "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = <T>(value: T) => value ?? nothing;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html.js';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html.js';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal\n */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n _$LH,\n Part,\n DirectiveParent,\n CompiledTemplateResult,\n MaybeCompiledTemplateResult,\n UncompiledTemplateResult,\n} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n MATHML: 3,\n} as const;\n\nexport type TemplateResultType =\n (typeof TemplateResultType)[keyof typeof TemplateResultType];\n\ntype IsTemplateResult = {\n (val: unknown): val is MaybeCompiledTemplateResult;\n <T extends TemplateResultType>(\n val: unknown,\n type: T\n ): val is UncompiledTemplateResult<T>;\n};\n\n/**\n * Tests if a value is a TemplateResult or a CompiledTemplateResult.\n */\nexport const isTemplateResult: IsTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is UncompiledTemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as UncompiledTemplateResult)?.['_$litType$'] !== undefined\n : (value as UncompiledTemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a CompiledTemplateResult.\n */\nexport const isCompiledTemplateResult = (\n value: unknown\n): value is CompiledTemplateResult => {\n return (value as CompiledTemplateResult)?.['_$litType$']?.h != null;\n};\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinel value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being committed.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content and markers.\n *\n * Note: The only difference between this and clearPart() is that this also\n * removes the part's start node. This means that the ChildPart must own its\n * start node, ie it must be a marker node specifically for this part and not an\n * anchor from surrounding content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$clear();\n part._$startNode.remove();\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n DirectiveResult,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {isSingleExpression, setCommittedValue} from '../directive-helpers.js';\n\nclass LiveDirective<T> extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n !(\n partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE\n )\n ) {\n throw new Error(\n 'The `live` directive is not allowed on child or event bindings'\n );\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n\n render(value: T): T {\n return value;\n }\n\n override update(part: AttributePart, [value]: DirectiveParameters<this>) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === (element as any)[name]) {\n return noChange;\n }\n } else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n } else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n\ninterface Live {\n <T>(value: T): DirectiveResult<typeof LiveDirective<T>>;\n}\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * ```js\n * html`<input .value=${live(x)}>`\n * ```\n *\n * `live()` performs a strict equality check against the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live: Live = directive(LiveDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {LiveDirective};\n", "/**\n * GENERATED by `bun run scripts/sync-field-labels.ts`. Do not edit.\n *\n * @remarks\n * The API English label of every request field whose label differs from its humanized wire name, which the form prints on an English page and wherever a translated payload carries no label of its own.\n */\nexport const EN_FIELD_LABELS: Record<string, string> = {\n\tafterSunset: 'Born after sunset',\n\tallowDuplicates: 'Allow duplicate cards',\n\tallowReversals: 'Allow reversed cards',\n\tangelDating: 'How the name of the day is dated',\n\tannualFromYear: 'Annual pillars from year',\n\tannualYears: 'Years of annual pillars',\n\tapproximateDate: 'Approximate date',\n\taspectTypes: 'Aspect types',\n\tatbashOutput: 'AtBash and Albam output',\n\tavasthaInfo: 'Include avastha details',\n\tavoidAnimal: 'Avoid clashes with',\n\tayadiText: 'Ayadi text family',\n\tayanamsaValue: 'Custom ayanamsa value',\n\tbirthData: 'Birth details',\n\tbirthDate: 'Birth date',\n\tbirthLatitude: 'Birth latitude',\n\tbirthLongitude: 'Birth longitude',\n\tbirthTime: 'Birth time',\n\tciphers: 'Ciphers to return',\n\tcontext: 'Where you saw it',\n\tcoordinateSystem: 'Coordinate system',\n\tcorrelation: 'Correlation constant',\n\tcount: 'How many',\n\tcurrentYear: 'Year',\n\tcuts: 'Cut corners',\n\tdasha: 'Dasha lords',\n\tdatetime: 'Date and time',\n\tdayBoundary: 'Day boundary',\n\tdepth: 'Depth, north to south',\n\tdirectionScheme: 'Direction reading',\n\tdivision: 'Divisional chart',\n\tdomainWeights: 'Domain weights',\n\tdoor: 'Door coordinates',\n\tdoorPosition: 'Door position along the side',\n\tdoshaClock: 'How the dosha periods are cut',\n\tendDate: 'End date',\n\tendDatetime: 'End date and time',\n\texpression: 'Expression number',\n\textensions: 'Extended corners',\n\tfacing: 'Facing direction',\n\tfacingDegrees: 'Facing degrees',\n\tfamily: 'Yoga family',\n\tfirstName: 'First name',\n\tfirstNameHebrew: 'First name in Hebrew',\n\tfullName: 'Full name',\n\tgainHouses: 'Gain houses',\n\tgrid: 'Mandala grid',\n\thastaInches: 'Length of one hasta in inches',\n\thoraryNumber: 'Horary number',\n\thourClock: 'Hour clock',\n\thouseSystem: 'House system',\n\tid: 'ID',\n\tinclude: 'Additional bodies',\n\tincludeMatches: 'Include equal value matches',\n\tinterpretation: 'Position meaning',\n\tintervalMinutes: 'Interval in minutes',\n\tisLeapMonth: 'Leap month',\n\tiso2: 'Country code',\n\tkua: 'Kua number',\n\tlang: 'Language',\n\tlatinCiphers: 'Also score the Latin ciphers',\n\tleapDayPolicy: 'Where 29 February falls',\n\tletter: 'Starting letter',\n\tletterAttribution: 'Letter attribution reading',\n\tlifePath: 'Life Path number',\n\tlimit: 'Results per page',\n\tlines: 'Line pattern',\n\tlossHouses: 'Loss houses',\n\tlunarDay: 'Lunar day',\n\tlunarMonth: 'Lunar month',\n\tlunarYear: 'Lunar year',\n\tmembers: 'Group members',\n\tminSignificance: 'Minimum significance',\n\tminStrength: 'Minimum strength',\n\tmisparGadol: 'Mispar gadol method',\n\tmodernPlanets: 'Include modern planets',\n\tmoonWindows: 'Moon windows',\n\tmuhurtaText: 'Muhurta text',\n\tnameHebrew: 'Name in Hebrew',\n\tnatalChart: 'Natal chart',\n\tnodeType: 'Lunar node type',\n\toffset: 'Results to skip',\n\tpolygon: 'Outline',\n\tpositions: 'Spread positions',\n\tq: 'Search',\n\tquestion: 'Your question',\n\trelocationLatitude: 'Relocation latitude',\n\trelocationLongitude: 'Relocation longitude',\n\treturnDate: 'Return date',\n\treturnYear: 'Return year',\n\tritucharyaScheme: 'Season division',\n\trituZodiac: 'Zodiac the season boundaries are measured in',\n\troad: 'Road side',\n\trulingPlanets: 'Ruling planets',\n\tscheme: 'Karaka scheme',\n\tsecondName: 'Second name',\n\tsecondNameHebrew: 'Second name in Hebrew',\n\tsephirotSystem: 'Sephirot reading',\n\tsign: 'Zodiac sign',\n\tsign1: 'First animal sign',\n\tsign2: 'Second animal sign',\n\tsignDoshaScheme: 'Sign humour table',\n\tsignificators: 'Include KP significators',\n\tslopeLowDirection: 'Direction the ground falls toward',\n\tslopeSchool: 'Ground level school',\n\tsoulUrge: 'Soul Urge number',\n\tspreadName: 'Spread name',\n\tstartDate: 'Start date',\n\tstartDatetime: 'Start date and time',\n\tstrictOrbs: 'Use tighter orbs',\n\tsystem: 'Avastha system',\n\ttargetDate: 'Target date',\n\ttargetMonth: 'Target month',\n\ttext: 'Word or name',\n\ttextHebrew: 'Hebrew word or name',\n\ttop: 'Top events per window',\n\ttransitDate: 'Transit date',\n\ttransitTime: 'Transit time',\n\ttransliteration: 'Transliteration scheme',\n\ttreeVariant: 'Tree arrangement',\n\ttype: 'Pattern type',\n\tvyayaFormula: 'Vyaya formula',\n\twater: 'Standing water direction',\n\tweights: 'Layer weights',\n\twidth: 'Width, east to west',\n\tx: 'Distance east',\n\ty: 'Distance north',\n\tyearBearerSystem: 'Year Bearer school',\n\tyearBoundary: 'Year boundary',\n\tyearStart: 'Wheel year start',\n\tzodiac: 'Zodiac sign',\n};\n", "// Generated by scripts/sync-bindings.ts (the `lang` query enum in specs/openapi.json). Do not edit.\n\n/**\n * Every language tag the API accepts on `?lang=`.\n *\n * @remarks\n * A self-fetch resolves the site language from the DOM, which means ANY value a\n * host page happens to carry can reach the query string. The API rejects an\n * unlisted tag with a 400, so a page in a language we do not translate would\n * stop working the moment the language chain was completed. Membership is\n * checked against this list before `lang` is sent, and a miss simply omits the\n * parameter, leaving the endpoint on its English default.\n */\nexport const API_LANGUAGES: readonly string[] = [\"de\",\"en\",\"es\",\"fr\",\"hi\",\"pt\",\"ru\",\"tr\",\"zh-Hans\",\"zh-Hant\"];\n", "/**\n * Where a component's language comes from, and what is safe to send to the API.\n *\n * @remarks\n * Two different answers, and conflating them is the whole reason this file is separate from the catalogue:\n *\n * - {@link resolveLang} answers \"what language is this PAGE in\", and keeps the full tag, because `es-AR` is a legitimate thing for a catalogue to want to differ on.\n * - {@link apiLang} answers \"what may go on the query string\", which is a narrower question with a hard edge: `?lang=es-AR` is a 400, `?lang=es` is a 200.\n *\n * The full tag is not a nicety the catalogue happens to tolerate: `utils/format.ts` hands it to `Intl`, which reads the region and writes `15 de ene de 1990` for `es-AR` where it writes `15 ene 1990` for `es`. Passing the API answer to a formatter demotes every regional visitor to the base language and nothing fails, so the two values are never interchangeable.\n */\n\nimport { API_LANGUAGES } from '../generated/api-languages.js';\n\n/**\n * The site-owner language for an element, resolved through the four-link chain the revamp design specifies.\n *\n * @remarks\n * 1. the element's own `lang` attribute (the explicit per-embed override),\n * 2. the nearest ancestor carrying `lang`, so one wrapper localizes a whole section,\n * 3. `document.documentElement.lang`, which is what makes this work on a real CMS with no markup change at all: WordPress emits `<html lang=\"es-AR\">` on every page of a Spanish site,\n * 4. nothing, which the callers read as English.\n *\n * All four links matter: with only the first, a component on a fully Spanish page renders English chrome and the only remedy is hand-editing every embed.\n *\n * `navigator.language` is deliberately NOT in the chain. It is the VISITOR's preference, not the site's: it fragments the API cache across every locale a visitor might carry and silently serves two people different content from the same URL.\n *\n * Link 2 uses `closest`, which stops at a shadow boundary. A component composed INSIDE another component's shadow root therefore cannot see the host page, which is why every composing component forwards `lang` to its children explicitly.\n */\nexport function resolveLang(el: HTMLElement): string | undefined {\n\t// Native accessor, never a Lit @property: declaring one would shadow\n\t// HTMLElement.lang and break the platform attribute for every consumer.\n\tif (el.lang) return el.lang;\n\tif (typeof document === 'undefined') return undefined;\n\tconst inherited = el.closest?.('[lang]')?.getAttribute('lang');\n\tif (inherited) return inherited;\n\treturn document.documentElement.lang || undefined;\n}\n\n/**\n * Which script a Chinese page is written in, read off the region it names.\n *\n * @remarks\n * Chinese is the one language the API keys by SCRIPT rather than by language alone, because `zh`\n * on its own does not say which of the two a reader can actually read. Real pages almost never\n * write the script: a Taiwanese site writes `zh-TW` and a mainland site writes `zh-CN`, which is\n * what the region-to-script correspondence every internationalisation library ships is for.\n * Without this step both of those degrade to English, which takes the whole Chinese audience off\n * the domains the API answers in Chinese at all.\n *\n * A bare `zh` with neither region nor script resolves to nothing on purpose: guessing a script for\n * a reader who did not name one picks characters half of them cannot read.\n */\nconst ZH_SCRIPT_BY_REGION: Readonly<Record<string, string>> = {\n\ttw: 'hant',\n\thk: 'hant',\n\tmo: 'hant',\n\tcn: 'hans',\n\tsg: 'hans',\n\tmy: 'hans',\n};\n\n/** The API's own spelling of a tag, matched case-insensitively, or undefined when it serves no such language. */\nfunction asApiLang(tag: string): string | undefined {\n\tconst wanted = tag.toLowerCase();\n\treturn API_LANGUAGES.find((l) => l.toLowerCase() === wanted);\n}\n\n/**\n * The value safe to put on `?lang=`, or `undefined` to leave the request on the API default.\n *\n * @remarks\n * Three steps, and the order is load-bearing the moment {@link resolveLang} starts reading `<html lang>`:\n *\n * - **A tag the API serves goes as it is**, matched without regard to case, so `zh-Hant` and `ZH-HANT` both send the spelling the API declares. This comes first because the next step would throw away the very subtag those tags are identified by.\n * - **Chinese resolves its script**, from an explicit script subtag or from the region ({@link ZH_SCRIPT_BY_REGION}), because that is where the language actually lives.\n * - **Everything else drops its region.** A regional tag is a 400, so a Spanish WordPress site would go from English-but-working to broken the day the language chain was completed. `es-AR`, `es-419` and `ES` all send `es`.\n *\n * **An unsupported language is omitted, not sent.** The chain surfaces whatever the host page carries, including languages the API does not translate, and an unlisted tag is the same 400. Omitting it degrades to English, which is the behaviour those pages already had.\n */\nexport function apiLang(el: HTMLElement): string | undefined {\n\tconst tag = resolveLang(el);\n\tif (!tag) return undefined;\n\tconst exact = asApiLang(tag);\n\tif (exact) return exact;\n\tconst parts = tag.toLowerCase().split('-');\n\tconst base = parts[0] as string;\n\tif (base === 'zh') {\n\t\tconst script =\n\t\t\tparts.find((p) => p === 'hans' || p === 'hant') ??\n\t\t\tZH_SCRIPT_BY_REGION[parts[1] ?? ''];\n\t\treturn script ? asApiLang(`zh-${script}`) : undefined;\n\t}\n\treturn asApiLang(base);\n}\n", "/**\n * Shared string helpers used across components. Single source of truth so the\n * same formatting rules apply to every key/label/title that surfaces in the\n * shadow tree.\n *\n * - `lookupKey`: the ONE normalizer every lookup table in this library is keyed\n * and read by (`tokens/index.ts` glyphs and abbreviations, `i18n/` chrome\n * strings).\n * - `capitalize`: title-cases the first character, lowercases the rest. A\n * DISPLAY helper only; it is not a lookup key (see `lookupKey`).\n * - `humanize`: turns an API key (`birth_date`, `birthDate`, `mahadasha-end`)\n * into a label suitable for display (\"Birth date\", \"Mahadasha end\").\n */\n\n/**\n * Fold a name to the canonical key its lookup table is stored under: lower case, every run of spaces, underscores and hyphens collapsed to one space, trimmed.\n *\n * @remarks\n * This exists because a GUESSED key spelling is a defect class this repo has now shipped twice. The glyph tables were keyed off whatever {@link capitalize} happened to produce (`North node`), while the API returns `North Node`, so every call site that reached the table without first calling `capitalize` missed and fell through to a fabricated abbreviation. Aspects hit the same wall from the other side: `/aspects` returns `SEMI SEXTILE` where synastry returns `SEMI_SEXTILE`.\n *\n * One normalizer, applied when a table is DEFINED and again when it is READ, removes the whole class: no call site has to remember a convention, and no table has to guess a spelling. Use it for every new table keyed by an API-supplied name.\n *\n * @example\n * ```ts\n * lookupKey('North Node'); // 'north node'\n * lookupKey('SEMI_SEXTILE'); // 'semi sextile'\n * lookupKey('semi-sextile'); // 'semi sextile'\n * ```\n */\nexport function lookupKey(s: string): string {\n\treturn s\n\t\t.toLowerCase()\n\t\t.replace(/[\\s_-]+/g, ' ')\n\t\t.trim();\n}\n\nexport function capitalize(s: string): string {\n\tif (!s) return '';\n\treturn s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n}\n\nexport function humanize(s: string): string {\n\treturn (\n\t\ts\n\t\t\t.replace(/[_-]+/g, ' ')\n\t\t\t.replace(/([a-z])([A-Z])/g, '$1 $2')\n\t\t\t// Split a trailing/embedded digit off a word so \"person1\" reads \"Person 1\"\n\t\t\t// and every group legend and field label spaces its ordinal.\n\t\t\t.replace(/([a-z])([0-9])/g, '$1 $2')\n\t\t\t.replace(/^\\w/, (c) => c.toUpperCase())\n\t);\n}\n", "/**\n * The chrome-string catalogue: one resolver reading one registry, so a translation can arrive from anywhere without a component changing.\n *\n * @remarks\n * **The key IS the canonical English string**, folded through {@link lookupKey}. There is no invented key vocabulary to keep in sync with the copy, which is the same rule the glyph tables in `tokens/index.ts` follow (they key off the exact value the API returns). Two consequences that are the whole point:\n *\n * - **English costs zero bytes.** A miss returns the source string, so the English build ships no catalogue at all, and a site that never loads a locale payload is byte-identical to one built before this file existed.\n * - **A missing translation degrades to English, never to a key.** The failure mode of a keyed catalogue is a raw `natal.tabs.wheel` on the page; here the worst case is the English word.\n *\n * **The registry lives on `globalThis`, not in module scope, because it has to.** Every `dist/cdn/components/*.js` is a self-contained IIFE with its own copy of this module, so a `Map` here would be invisible to the second component on the page. One global object, written by the locale payload and read by every bundle, is what makes `dist/cdn/locales/es.js` a single download that translates all of them.\n *\n * Load order is not guaranteed on a real host (WordPress enqueues scripts in an order the plugin does not fully control, and a payload may be deferred), so {@link onLocaleChange} lets an element that has already rendered in English re-render when its catalogue lands.\n */\n\nimport { lookupKey } from '../utils/string.js';\n\n/** Shared mutable state, addressed by a name rather than a module binding so every bundle on the page reaches the same object. */\ninterface LocaleRegistry {\n\t/** Language tag (lower case) to catalogue, keyed by {@link lookupKey} of the English source string. */\n\tcatalogs: Record<string, Record<string, string>>;\n\t/**\n\t * Language tag (lower case) to the API's field-label map: `fields` keyed by wire name,\n\t * `enums` keyed `{fieldName}.{value}`.\n\t *\n\t * A SEPARATE key space from `catalogs` on purpose. A chrome string is keyed by the English\n\t * text a component writes, which is a constant in our source; a field label is keyed by a\n\t * name that only the OpenAPI spec knows, computed per operation, so no catalogue keyed on\n\t * English source text can ever reach it. Same registry because the delivery problem is\n\t * identical (a payload that may land after first paint), so it reuses one global object and\n\t * one listener set rather than growing a second of each.\n\t */\n\tfieldLabels: Record<string, FieldLabels>;\n\t/** Language tags whose fetch is in flight or done, so N forms on a page cost ONE request. */\n\trequested: Set<string>;\n\t/** Elements waiting to re-render when a catalogue arrives. */\n\tlisteners: Set<() => void>;\n}\n\n/** The `/languages/field-labels` payload, minus the echoed `lang`. */\nexport interface FieldLabels {\n\tfields: Record<string, string>;\n\tenums: Record<string, string>;\n}\n\nconst GLOBAL_KEY = '__ROXY_UI_I18N__';\n\nfunction registry(): LocaleRegistry {\n\tconst holder = globalThis as unknown as Record<string, LocaleRegistry>;\n\tconst existing = holder[GLOBAL_KEY];\n\tif (existing) return existing;\n\tconst created: LocaleRegistry = {\n\t\tcatalogs: {},\n\t\tfieldLabels: {},\n\t\trequested: new Set(),\n\t\tlisteners: new Set(),\n\t};\n\tholder[GLOBAL_KEY] = created;\n\treturn created;\n}\n\n/**\n * Publish a catalogue for a language tag and wake every mounted element.\n *\n * @remarks\n * The catalogue is authored keyed by the English source string, exactly as it appears at the call site, and normalized here. That keeps the source file readable and diffable against the component that renders it, while the runtime lookup stays a single property read.\n *\n * This is the ONLY way into the registry, so a catalogue can later come from a static file, a server response, or a host page inlining a script tag, without a component knowing the difference.\n */\nexport function registerLocale(\n\tlang: string,\n\tcatalog: Record<string, string>,\n): void {\n\tconst reg = registry();\n\tconst normalized: Record<string, string> = {};\n\tfor (const [source, translated] of Object.entries(catalog)) {\n\t\tnormalized[lookupKey(source)] = translated;\n\t}\n\treg.catalogs[lang.toLowerCase()] = normalized;\n\tfor (const listener of reg.listeners) listener();\n}\n\n/**\n * Replace `{{name}}` placeholders. Copied from the API-side translator so both sides of the product interpolate identically; an unknown placeholder is left verbatim rather than blanked, so a typo in a catalogue is visible instead of silently eating the value.\n */\nexport function interpolate(\n\ttemplate: string,\n\tvars?: Record<string, string | number>,\n): string {\n\tif (!vars) return template;\n\treturn template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key: string) =>\n\t\tkey in vars ? String(vars[key] ?? '') : match,\n\t);\n}\n\n/**\n * The chrome string for `lang`, falling back to the English `source` it is keyed by.\n *\n * @remarks\n * A regional tag resolves against its base language, so `es-AR` and `es-419` both read the `es` catalogue and a site does not have to know which tags we happen to ship. An exact regional catalogue still wins if one is ever registered.\n */\nexport function translate(\n\tlang: string | undefined,\n\tsource: string,\n\tvars?: Record<string, string | number>,\n): string {\n\treturn interpolate(chromeLabel(lang, source) ?? source, vars);\n}\n\n/** A published chrome label, including translations equal to the source; absent on a miss. */\nexport function chromeLabel(\n\tlang: string | undefined,\n\tsource: string,\n): string | undefined {\n\tif (!lang) return undefined;\n\tconst { catalogs } = registry();\n\tconst tag = lang.toLowerCase();\n\tconst catalog = catalogs[tag] ?? catalogs[tag.split('-')[0] as string];\n\treturn catalog?.[lookupKey(source)];\n}\n\n/**\n * Publish a field-label map for a language tag and wake every mounted element.\n *\n * @remarks\n * Exported so a host that already has the payload (a server-rendered page, a test, a WordPress\n * plugin inlining it) can supply it without a network call, exactly as {@link registerLocale}\n * allows for chrome strings.\n */\nexport function registerFieldLabels(lang: string, labels: FieldLabels): void {\n\tconst reg = registry();\n\treg.fieldLabels[lang.toLowerCase()] = labels;\n\tfor (const listener of reg.listeners) listener();\n}\n\n/**\n * Read the registered field-label payload for `lang`, resolving regional tags against their base.\n *\n * @remarks\n * Shared by browser label lookups and build-time manifest generation after importing the locale\n * modules. Returns `undefined` when no payload is registered, leaving English fallback to callers.\n */\nexport function labelsFor(lang: string | undefined): FieldLabels | undefined {\n\tif (!lang) return undefined;\n\tconst { fieldLabels } = registry();\n\tconst tag = lang.toLowerCase();\n\treturn fieldLabels[tag] ?? fieldLabels[tag.split('-')[0] as string];\n}\n\n/**\n * The label for a request field name, or `undefined` when nothing has been published.\n *\n * @remarks\n * Returning `undefined` rather than the name is deliberate: the caller owns the fallback, which is\n * `humanize()`, and that keeps this resolver honest about what it actually knows. A form renders\n * identically to before until a payload arrives.\n */\nexport function fieldLabel(\n\tlang: string | undefined,\n\tname: string,\n): string | undefined {\n\treturn labelsFor(lang)?.fields[name];\n}\n\n/** The label for one selectable option, keyed `{fieldName}.{value}` as the API publishes it. */\nexport function optionLabel(\n\tlang: string | undefined,\n\tfield: string,\n\tvalue: string,\n): string | undefined {\n\treturn labelsFor(lang)?.enums[`${field}.${value}`];\n}\n\n/** Subscribe to catalogue arrivals. Returns the unsubscribe, so an element can drop it on disconnect. */\nexport function onLocaleChange(listener: () => void): () => void {\n\tconst { listeners } = registry();\n\tlisteners.add(listener);\n\treturn () => {\n\t\tlisteners.delete(listener);\n\t};\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { onLocaleChange } from './registry.js';\n\n/**\n * Re-renders its host when a chrome-string catalogue arrives.\n *\n * @remarks\n * Without this the catalogue would have to be on the page BEFORE the elements upgrade, which is not something a component can require of a real host. WordPress orders enqueued scripts by dependency and a site owner can add `defer` to any of them; a CDN embed is two independent `<script src>` tags. Any of those can land the locale payload after the first paint, and the visible result would be a chart that renders in English on a Spanish page for no reason the site owner can see or fix.\n *\n * Mirrors `MarkupDataController`: constructed in {@link RoxyDataElement}'s constructor, subscribes on connect, drops the subscription on disconnect. Registration is idempotent and a re-register of the same language simply re-renders, so a payload loaded twice is harmless.\n */\nexport class LocaleController implements ReactiveController {\n\tprivate readonly host: ReactiveControllerHost;\n\tprivate unsubscribe?: () => void;\n\n\tconstructor(host: ReactiveControllerHost) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.unsubscribe = onLocaleChange(() => this.host.requestUpdate());\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n}\n", "import { LitElement } from 'lit';\nimport { resolveLang } from './lang.js';\nimport { LocaleController } from './locale-controller.js';\nimport { translate } from './registry.js';\n\n/**\n * The base every element that writes WORDS extends: it resolves the page language and translates its own chrome.\n *\n * @remarks\n * This is deliberately smaller than {@link RoxyDataElement}, and the split is what makes the widgets translatable at all. `<roxy-endpoint-form>` and `<roxy-location-search>` are the two declared widgets: they fetch, they hold state, and they are NOT data components, so they cannot inherit the data base without dragging its controlled-mode hydration, its self-fetch controller and its own form rendering (which renders the form, so the form inheriting it would compose itself). They extended `LitElement` directly instead, which meant they had no `t()` and no {@link LocaleController}, so a Spanish page rendered a Spanish result card over an English form and neither widget re-rendered when a deferred locale payload landed.\n *\n * So the mechanism lives here ONCE and all three inherit it. There is no second translator, no second registry and no second way to resolve a language: adding one is how a catalogue entry and a call site drift apart.\n *\n * Two costs are why this is its own module rather than a second export of `utils/base-element.ts`. Every `dist/cdn/components/*.js` is a self-contained IIFE, so importing the data base into the city search would compile `FetchController`, `MarkupDataController` and the interpretation accordion into a bundle that uses none of them. And `utils/base-element.ts` imports THIS file, so putting the class there would close a cycle the moment a widget imported it.\n */\nexport abstract class RoxyLocalizedElement extends LitElement {\n\tconstructor() {\n\t\tsuper();\n\t\t// Re-render if a chrome-string catalogue lands after this element upgraded.\n\t\t// A host page loads the payload as its own script tag, so it can arrive\n\t\t// after first paint and there is nothing the site owner could do about it.\n\t\tnew LocaleController(this);\n\t}\n\n\t/**\n\t * The chrome string for this element's language, keyed by its own English source text.\n\t *\n\t * @remarks\n\t * Pass the English copy, never a key. With no catalogue registered the source string is returned unchanged, so an English page pays nothing and a language we do not ship degrades to English rather than to a visible key.\n\t *\n\t * Chrome only. A value the API returned (a planet, a sign, an aspect, a house system) is NOT translated here: it is rendered as the response carries it, so the words on the chart and the words in the response can never disagree. The same holds for a label derived from a spec field NAME through `humanize()`: a catalogue keyed on English source text cannot reach a string computed per response. A derived name is catalogued only where the set it comes from is CLOSED and small enough to enumerate against the spec, which is true of the nine form group names and of nothing else so far.\n\t *\n\t * @example\n\t * ```ts\n\t * this.t('Aspect grid'); // 'Cuadricula de aspectos' under lang=\"es\"\n\t * this.t('{{count}} planets', { count: 12 }); // '12 planetas'\n\t * ```\n\t */\n\tprotected t(source: string, vars?: Record<string, string | number>): string {\n\t\treturn translate(this.effectiveLang(), source, vars);\n\t}\n\n\t/** {@link RoxyLocalizedElement.t} as a value, bound once, for a shared render helper that has no host of its own and therefore cannot resolve a page language (`utils/hd-reading.ts`). Named `translator` and not `translate` because `HTMLElement.translate` is a real DOM property and shadowing it with a protected member makes every `@customElement` decorator in the library fail to typecheck. */\n\tprotected readonly translator = (\n\t\tsource: string,\n\t\tvars?: Record<string, string | number>,\n\t): string => this.t(source, vars);\n\n\t/**\n\t * Site-owner language for this element: the `lang` attribute, the nearest ancestor carrying one, or the document. Protected so a component that composes another can forward it (a child inside this shadow root cannot reach the host page on its own).\n\t *\n\t * Full tag, region included. The truncation to what `?lang=` accepts happens where the request is built, in `<roxy-endpoint-form>`.\n\t */\n\tprotected effectiveLang(): string | undefined {\n\t\treturn resolveLang(this);\n\t}\n}\n", "/**\n * Symbol constants used across components. Single source of truth so chart\n * wheels, card headers, hexagram displays, and panchang tables stay visually\n * consistent.\n *\n * @remarks\n * **Every table here is keyed by {@link lookupKey} and read ONLY through the accessor beside it.** The raw records are deliberately not exported: a component that indexes a record directly has to guess the key convention, and a guessed spelling renders `No North Node R`, `So South Node R` and `Bl Black Moon Lilith` on a live chart. The API returns `North Node` with a space, while {@link capitalize} produces `North node`, so a call site that indexes without normalising misses the table.\n *\n * **A miss returns `undefined`, never a manufactured abbreviation.** A `?? name.slice(0, 2)` fallback renders a failed lookup as a plausible two-letter code that reads exactly like an intentional abbreviation, so nothing about the output says it is broken. A caller that can omit the glyph should omit it (`?? ''`); a caller that must show something falls back to the FULL name, which is visibly wrong at the size these slots are drawn.\n *\n * `tests/tokens.test.ts` resolves every body, sign and aspect name the committed spec can emit against these tables, so a vocabulary the API gains cannot ship unglyphed.\n */\n\nimport { lookupKey } from '../utils/string.js';\n\n/** Look one name up in a normalized table. The single read path for every map in this file. */\nconst resolve = (\n\ttable: Record<string, string>,\n\tname: string | undefined | null,\n): string | undefined => (name ? table[lookupKey(name)] : undefined);\n\nconst PLANET_GLYPH: Record<string, string> = {\n\tsun: '☉',\n\tmoon: '☽',\n\tmercury: '☿',\n\tvenus: '♀',\n\tearth: '♁',\n\tmars: '♂',\n\tjupiter: '♃',\n\tsaturn: '♄',\n\turanus: '♅',\n\tneptune: '♆',\n\tpluto: '♇',\n\trahu: '☊',\n\tketu: '☋',\n\tascendant: 'Asc',\n\tmidheaven: 'MC',\n\t'part of fortune': '⊗',\n\tvertex: 'Vx',\n\tlagna: 'La',\n\t'north node': '☊',\n\t'south node': '☋',\n\tchiron: '⚷',\n\tlilith: '⚸',\n\t'black moon lilith': '⚸',\n};\n\n/** Astrological glyph for a planet or point, or `undefined` when the library has none for it. */\nexport const planetGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(PLANET_GLYPH, name);\n\nconst PLANET_ABBR: Record<string, string> = {\n\tsun: 'Su',\n\tmoon: 'Mo',\n\tmercury: 'Me',\n\tvenus: 'Ve',\n\tmars: 'Ma',\n\tjupiter: 'Ju',\n\tsaturn: 'Sa',\n\turanus: 'Ur',\n\tneptune: 'Ne',\n\tpluto: 'Pl',\n\trahu: 'Ra',\n\tketu: 'Ke',\n\tascendant: 'Asc',\n\tlagna: 'La',\n};\n\n/** Two-letter graha code for the tight cells of a North/South Indian kundli, or `undefined`. */\nexport const planetAbbr = (\n\tname: string | undefined | null,\n): string | undefined => resolve(PLANET_ABBR, name);\n\nconst SIGN_GLYPH: Record<string, string> = {\n\taries: '♈',\n\ttaurus: '♉',\n\tgemini: '♊',\n\tcancer: '♋',\n\tleo: '♌',\n\tvirgo: '♍',\n\tlibra: '♎',\n\tscorpio: '♏',\n\tsagittarius: '♐',\n\tcapricorn: '♑',\n\taquarius: '♒',\n\tpisces: '♓',\n};\n\n/** Zodiac glyph for a sign name in any case, or `undefined`. */\nexport const signGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(SIGN_GLYPH, name);\n\nconst SIGN_ABBR: Record<string, string> = {\n\taries: 'Ar',\n\ttaurus: 'Ta',\n\tgemini: 'Ge',\n\tcancer: 'Cn',\n\tleo: 'Le',\n\tvirgo: 'Vi',\n\tlibra: 'Li',\n\tscorpio: 'Sc',\n\tsagittarius: 'Sg',\n\tcapricorn: 'Cp',\n\taquarius: 'Aq',\n\tpisces: 'Pi',\n};\n\n/** Two-letter rashi code for kundli cells and grid headers, or `undefined`. */\nexport const signAbbr = (name: string | undefined | null): string | undefined =>\n\tresolve(SIGN_ABBR, name);\n\n/** The twelve signs in zodiacal order. Display values, not lookup keys: read them through {@link signGlyph} / {@link signAbbr}. */\nexport const SIGNS_ORDER = [\n\t'Aries',\n\t'Taurus',\n\t'Gemini',\n\t'Cancer',\n\t'Leo',\n\t'Virgo',\n\t'Libra',\n\t'Scorpio',\n\t'Sagittarius',\n\t'Capricorn',\n\t'Aquarius',\n\t'Pisces',\n] as const;\n\n/**\n * Glyph per aspect. Used by the natal, transit and synastry aspect tables.\n *\n * @remarks\n * These are the nine aspects Unicode itself defines as a set, in its Miscellaneous Symbols block note: `260C, 26BA, 2220, 26B9, 25A1, 25B3, 26BC, 26BB, 260D` for 0, 30, 45, 60, 90, 120, 135, 150 and 180 degrees. That is exactly the vocabulary the API returns, so every aspect resolves to a real glyph and none falls through to a truncated slug.\n *\n * Do not substitute the visually similar maths operators. Unicode lists `⊻` XOR and `⊼` NAND as cross-references FROM the real quincunx and semisextile glyphs, so they look like safe stand-ins and are easy to pair the wrong way round, which renders a 150 degree quincunx with the 30 degree semisextile symbol. An astrologer reads the glyph, not the tooltip.\n */\nconst ASPECT_SYMBOL: Record<string, string> = {\n\tconjunction: '☌',\n\tsemisextile: '⚺',\n\t'semi sextile': '⚺',\n\tsemisquare: '∠',\n\t'semi square': '∠',\n\tsextile: '⚹',\n\tsquare: '□',\n\ttrine: '△',\n\tsesquiquadrate: '⚼',\n\tquincunx: '⚻',\n\topposition: '☍',\n};\n\n/** Aspect glyph for any of the separator forms the endpoints use (`SEMI_SEXTILE`, `SEMI SEXTILE`, `semi-sextile`), or `undefined`. */\nexport const aspectSymbol = (\n\tname: string | undefined | null,\n): string | undefined => resolve(ASPECT_SYMBOL, name);\n\n/** Trigrams used by I Ching hexagrams. Eight trigrams compose 64 hexagrams. */\nconst TRIGRAM_GLYPH: Record<string, string> = {\n\theaven: '☰',\n\tlake: '☱',\n\tfire: '☲',\n\tthunder: '☳',\n\twind: '☴',\n\twater: '☵',\n\tmountain: '☶',\n\tearth: '☷',\n};\n\n/** Trigram glyph for a trigram name in any case, or `undefined`. */\nexport const trigramGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(TRIGRAM_GLYPH, name);\n\n/** Moon phase emoji set. Used by the moon phase card. */\nconst MOON_PHASE_EMOJI: Record<string, string> = {\n\t'new moon': '🌑',\n\t'waxing crescent': '🌒',\n\t'first quarter': '🌓',\n\t'waxing gibbous': '🌔',\n\t'full moon': '🌕',\n\t'waning gibbous': '🌖',\n\t'last quarter': '🌗',\n\t'waning crescent': '🌘',\n};\n\n/**\n * Emoji for a lunar phase, or `undefined`.\n *\n * @remarks\n * The live API suffixes most phase names (`Waxing Gibbous Moon`) and calls the third quarter `Third Quarter Moon`, while only new and full moon carry the suffix in the table. Both reconciliations live here rather than in the card, so any component reading a phase name resolves the same eight phases from the same four spellings.\n */\nexport const moonPhaseEmoji = (\n\tname: string | undefined | null,\n): string | undefined => {\n\tif (!name) return undefined;\n\tconst key = lookupKey(name);\n\tconst bare = key.replace(/ moon$/, '');\n\tconst alias = bare === 'third quarter' ? 'last quarter' : bare;\n\treturn MOON_PHASE_EMOJI[key] ?? MOON_PHASE_EMOJI[alias];\n};\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{--roxy-label-col:minmax(0, 25%);--_success-fg:var(--roxy-success-fg,#09632a);--_warning-fg:var(--roxy-warning-fg,#913304);--_danger-fg:var(--roxy-danger-fg,#881313);--_info-fg:var(--roxy-info-fg,#014f7a);font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([hidden]){display:none}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{transform:translateY(2px)}to{transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted,#71717a)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md,1rem)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm,.5rem);margin-top:var(--roxy-space-md,1rem);display:grid}.roxy-more .roxy-edit{min-height:44px}:host{font-variant-emoji:text}`;\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * The one place the \"publishable key only\" rule lives. Every client-side fetch boundary ({@link ../components/location-search.ts}, {@link ./fetch-controller.ts}) and the self-fetch form ({@link ../components/endpoint-form.ts}) call through here so a refused key is refused identically: no network call, the same visible message, the same `roxy-validation-error` event. Centralising it is what stops the paths drifting into different answers for the same key, one warning and fetching where another refuses.\n */\n\n/** The sample key every copy-paste snippet ships with; pages that offer a live key input search snippets for this exact string, so changing it breaks them. */\nexport const SAMPLE_PUBLISHABLE_KEY = 'pk_live_YOUR_KEY';\n\n/** Each reason a key is refused: the `roxy-validation-error` detail reason and the English source of the message, translated where it renders. */\nexport const KEY_REFUSALS = {\n\tsecret: {\n\t\treason: 'possible-secret-key',\n\t\tmessage:\n\t\t\t'Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.',\n\t},\n\tsample: {\n\t\treason: 'sample-key',\n\t\tmessage:\n\t\t\t'Replace the sample key with your own publishable key from your RoxyAPI account.',\n\t},\n} as const;\n\nexport type KeyRefusal = (typeof KEY_REFUSALS)[keyof typeof KEY_REFUSALS];\n\n/** Why a present key may not be sent (a secret or unprefixed key, or the snippet sample no account owns), or undefined when it may, an absent key included. */\nexport function keyRefusal(\n\tkey: string | undefined | null,\n): KeyRefusal | undefined {\n\tif (!key) return undefined;\n\tif (key === SAMPLE_PUBLISHABLE_KEY) return KEY_REFUSALS.sample;\n\treturn key.startsWith('pk_') ? undefined : KEY_REFUSALS.secret;\n}\n\n/** Dispatch the shared bubbling `roxy-validation-error` for a refused key, and log it once when `warn` is set; the caller shows the message and skips the fetch. */\nexport function dispatchKeyRefusal(\n\thost: EventTarget,\n\trefusal: KeyRefusal,\n\topts: { warn?: boolean } = {},\n): void {\n\tif (opts.warn) console.warn(refusal.message);\n\thost.dispatchEvent(\n\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\tdetail: { reason: refusal.reason, message: refusal.message },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t}),\n\t);\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n\tdispatchKeyRefusal,\n\ttype KeyRefusal,\n\tkeyRefusal,\n} from './key-guard.js';\n\n/**\n * Host slots the controller drives. {@link RoxyDataElement} satisfies this, so the form mixin can attach a controller without the component wiring state by hand.\n *\n * @remarks\n * Intersected with `HTMLElement` because the controller dispatches events on the host. Lit's `ReactiveControllerHost` is the update-lifecycle contract only (`addController`, `requestUpdate`, `updateComplete`) and carries no DOM surface, even though every real host is a `LitElement` and therefore an `HTMLElement`. Declaring the DOM half is what the controller actually needs, and it is declared rather than reached through a `this.host as unknown as EventTarget` double cast, which would assert a capability the type never promised.\n */\ntype FetchHost<T> = ReactiveControllerHost &\n\tHTMLElement & {\n\t\tdata: T | null;\n\t\tloading: boolean;\n\t\terror: string | null;\n\t\t/** The field-level issues of a rejected request, or null when the failure was not about the request body. */\n\t\tissues: ApiIssue[] | null;\n\t};\n\n/** One field the API rejected, as the API reports it: the wire path of the field (`year`, `person1.date`, `members.0.date`) and the reason. */\nexport interface ApiIssue {\n\tpath: string;\n\tmessage: string;\n}\n\n/** A failed request, read once: the message every failure carries and the per-field issues a validation failure adds. */\ninterface ApiFailure {\n\tmessage: string;\n\tissues: ApiIssue[] | null;\n\t/** False when the body carried no `error` sentence and the message is the status line. */\n\tworded: boolean;\n}\n\n/** The public API root, which a component overrides per instance through its `base-url` attribute; exported so every request names one origin. */\nexport const DEFAULT_BASE_URL = 'https://roxyapi.com/api/v2';\n\n/**\n * Turn a failed `Response` into the message to show: the API's own `{ error }` string when the body carries one, else the status line.\n *\n * @remarks\n * Exported so every client-side fetch boundary renders the same words for the same failure, the way {@link keyRefusal} centralizes the key refusal. A boundary that discards the response body cannot tell a rejected request from an empty result, and renders the two identically.\n */\nexport async function readApiError(res: Response): Promise<string> {\n\treturn (await readApiFailure(res)).message;\n}\n\n/**\n * The failure a response carries.\n *\n * @remarks\n * A rejected request answers `{ error, code, issues }`, and `issues` is what makes the error actionable: each names the field by its wire path, which is the same identity the form keys its inputs by, so the message can sit under the input it is about instead of in a banner quoting a path. Only a `validation_error` carries them; every other failure keeps the message alone.\n */\nasync function readApiFailure(res: Response): Promise<ApiFailure> {\n\ttry {\n\t\tconst body = (await res.json()) as {\n\t\t\terror?: string;\n\t\t\tcode?: string;\n\t\t\tissues?: Array<{ path?: unknown; message?: unknown }>;\n\t\t};\n\t\tif (body?.error) {\n\t\t\tconst issues =\n\t\t\t\tbody.code === 'validation_error' && Array.isArray(body.issues)\n\t\t\t\t\t? body.issues\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(i) =>\n\t\t\t\t\t\t\t\t\ttypeof i.path === 'string' && typeof i.message === 'string',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((i) => ({\n\t\t\t\t\t\t\t\tpath: i.path as string,\n\t\t\t\t\t\t\t\tmessage: i.message as string,\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t: null;\n\t\t\treturn {\n\t\t\t\tmessage: body.error,\n\t\t\t\tissues: issues?.length ? issues : null,\n\t\t\t\tworded: true,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Non-JSON error body: fall through to the status line.\n\t}\n\treturn {\n\t\tmessage: `Request failed (${res.status})`,\n\t\tissues: null,\n\t\tworded: false,\n\t};\n}\n\n/** A single request the controller issues on the component's behalf. */\nexport interface RoxyRequest {\n\t/** Path under the API base, e.g. \"/dreams/symbols/water\" or \"/astrology/natal-chart\". */\n\tpath: string;\n\tmethod?: 'GET' | 'POST';\n\t/** JSON body for POST endpoints. */\n\tbody?: unknown;\n\t/** Query string parameters; nullish values are dropped. */\n\tquery?: Record<string, string | number | undefined>;\n}\n\n/**\n * Where an element sends its requests: the key it may present, the API origin, and the host route that proxies them.\n *\n * @remarks\n * Every element that fetches holds these four, and {@link apiFetch} is the one function that turns them into a request, so a list that loads its next page, a form that loads its choices and a component that loads its result reach the API, or the host route standing in for it, the same way.\n */\nexport interface ApiRoute {\n\t/** Browser-safe publishable key; anything else is refused before a request is made. */\n\tpublishableKey?: string;\n\t/** API origin, absolute or relative to the page; {@link DEFAULT_BASE_URL} when unset. */\n\tbaseUrl?: string;\n\t/** Host route that holds the secret key. When set, the request is POSTed there as `{ path, method, body, query }` and no key leaves the browser. */\n\tsubmitUrl?: string;\n\t/** Object the host page attaches to a proxied request as `context`, passed through unread. */\n\tsubmitContext?: Record<string, unknown>;\n}\n\n/** A request the API answered with a failure: its own message, plus the fields it named when it rejected the request, and whether the message is a sentence it wrote rather than the status line. */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly issues: ApiIssue[] | null = null,\n\t\treadonly worded = true,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\n/** The key refusal that applies to a route, or undefined when it may send; a proxy route holds its own key, so none applies there. */\nexport function routeRefusal(route: ApiRoute): KeyRefusal | undefined {\n\treturn route.submitUrl ? undefined : keyRefusal(route.publishableKey);\n}\n\n/** True when a route can reach the API at all: it carries a publishable key it may send, or a proxy route that holds one. */\nexport function canFetch(route: ApiRoute): boolean {\n\treturn !!(route.submitUrl || (route.publishableKey && !routeRefusal(route)));\n}\n\n/**\n * Send one request through a route and resolve to the JSON it answered.\n *\n * @remarks\n * The one place a request is built, so the key refusal, the proxy body and the failure reading cannot drift between the elements that fetch. A refused key throws before anything is sent; a failed response throws an {@link ApiError} carrying the API message and, for a rejected body, the fields it named.\n */\nexport async function apiFetch<T>(\n\troute: ApiRoute,\n\treq: RoxyRequest,\n\tsignal?: AbortSignal,\n): Promise<T> {\n\tconst refusal = routeRefusal(route);\n\tif (refusal) throw new ApiError(refusal.message);\n\tconst res = route.submitUrl\n\t\t? await fetch(route.submitUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t},\n\t\t\t\tbody: proxyBody(req, route.submitContext),\n\t\t\t\tsignal,\n\t\t\t})\n\t\t: await callApi(route, req, signal);\n\tif (!res.ok) {\n\t\tconst failure = await readApiFailure(res);\n\t\tthrow new ApiError(failure.message, failure.issues, failure.worded);\n\t}\n\treturn (await res.json()) as T;\n}\n\n/**\n * The body of a proxied POST: the request, plus the host context under `context` when one is set.\n *\n * @remarks\n * The context is appended rather than declared on {@link RoxyRequest}, so with none set the payload is the request object itself and every route already written against it keeps receiving the same four keys in the same order. A `null` or an empty object would be a fifth key such a route never agreed to read.\n */\nfunction proxyBody(\n\treq: RoxyRequest,\n\tcontext?: Record<string, unknown>,\n): string {\n\treturn JSON.stringify(context ? { ...req, context } : req);\n}\n\n/** Direct call against RoxyAPI with the publishable key (the no-backend path). */\nfunction callApi(\n\troute: ApiRoute,\n\treq: RoxyRequest,\n\tsignal?: AbortSignal,\n): Promise<Response> {\n\t// Resolved against the page, so a same-origin base (\"/api/roxy\") is as valid as an\n\t// absolute one. Every route a host page can name resolves the same way, and a bare\n\t// `new URL()` would reject the relative shape with an opaque \"Invalid URL\".\n\tconst url = new URL(\n\t\t`${route.baseUrl ?? DEFAULT_BASE_URL}${req.path}`,\n\t\tdocument.baseURI,\n\t);\n\tfor (const [k, v] of Object.entries(req.query ?? {})) {\n\t\tif (v != null) url.searchParams.set(k, String(v));\n\t}\n\tconst headers: Record<string, string> = { Accept: 'application/json' };\n\tif (route.publishableKey) headers['X-API-Key'] = route.publishableKey;\n\tif (req.body != null) headers['Content-Type'] = 'application/json';\n\treturn fetch(url, {\n\t\tmethod: req.method ?? 'GET',\n\t\theaders,\n\t\tbody: req.body != null ? JSON.stringify(req.body) : undefined,\n\t\tsignal,\n\t});\n}\n\n/**\n * Client-side fetch for uncontrolled (self-fetching) components: drives `host.data` / `host.loading` / `host.error` and cancels a stale request when a newer one starts or the host disconnects.\n *\n * @remarks\n * Security boundary. The only credential this ever sends is a `pk_` publishable key, which carries a server-side origin allowlist. A secret (`sk_`), legacy unprefixed or sample key is refused before any network call and surfaced as an error, so a server secret cannot leak into a browser request. The request itself goes through {@link apiFetch}, which every other fetch on an element shares.\n *\n * Controlled-mode components never construct this. When a server injects the response as a `<script class=\"roxy-data\">` island, there is no key and no fetch, which is the path server-rendered consumers (WordPress, JSX SSR, static HTML) rely on.\n */\nexport class FetchController<T = unknown>\n\timplements ReactiveController, ApiRoute\n{\n\tprivate readonly host: FetchHost<T>;\n\tprivate abort?: AbortController;\n\n\t/** Browser-safe publishable key. Set by the host from its `publishable-key` attribute. */\n\tpublishableKey?: string;\n\t/** API origin, overridable for self-hosted or proxied deployments. */\n\tbaseUrl = DEFAULT_BASE_URL;\n\t/** Consumer backend route that holds the secret key, set from the host `submit-url` attribute; see {@link ApiRoute.submitUrl}. */\n\tsubmitUrl?: string;\n\t/** Object the host page attaches to the proxied request, set from its `submit-context` attribute; see {@link ApiRoute.submitContext}. */\n\tsubmitContext?: Record<string, unknown>;\n\t/** False when the last failure carried no sentence of its own: a dropped connection, or a body with no `error`. */\n\tworded = true;\n\n\tconstructor(host: FetchHost<T>) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected() {\n\t\tthis.abort?.abort();\n\t\tthis.abort = undefined;\n\t}\n\n\t/**\n\t * Issue the request and resolve once `host.data` (success) or `host.error`\n\t * (failure) is set. A no-op return when the key is refused: the error is\n\t * already surfaced and nothing is sent.\n\t */\n\tasync run(req: RoxyRequest): Promise<void> {\n\t\tthis.worded = true;\n\t\tconst refusal = routeRefusal(this);\n\t\tif (refusal) {\n\t\t\tthis.host.error = refusal.message;\n\t\t\tdispatchKeyRefusal(this.host, refusal);\n\t\t\treturn;\n\t\t}\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.host.loading = true;\n\t\tthis.host.error = null;\n\t\tthis.host.issues = null;\n\t\ttry {\n\t\t\tconst json = await apiFetch<T>(this, req, controller.signal);\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.host.data = json;\n\t\t} catch (err) {\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tif ((err as { name?: string })?.name === 'AbortError') return;\n\t\t\tif (err instanceof ApiError) this.host.issues = err.issues;\n\t\t\tthis.worded = err instanceof ApiError && err.worded;\n\t\t\tthis.host.error = err instanceof Error ? err.message : String(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) this.host.loading = false;\n\t\t}\n\t}\n}\n\n/**\n * Translate flat form values into a {@link RoxyRequest} for an endpoint. The `{name}` segments in the endpoint template are substituted from the values and removed; the rest become the JSON body for POST or query parameters for GET. This is the spec-light request builder the base element uses to turn a `<roxy-endpoint-form>` submission into a self-fetch, so a component needs no per-endpoint glue.\n *\n * @param queryKeys - Names the spec declares as `in: query` for this operation, which `<roxy-endpoint-form>` reports on its `roxy-submit` event. A POST operation can still take query parameters (every localized endpoint takes `?lang=`), and sending one in the JSON body silently drops it, so those names are routed to the query string on POST as well as GET.\n */\nexport function buildRequest(\n\tendpoint: string,\n\tmethod: 'GET' | 'POST',\n\tvalues: Record<string, unknown>,\n\tqueryKeys: readonly string[] = [],\n): RoxyRequest {\n\tconst rest: Record<string, unknown> = { ...values };\n\tconst path = `/${endpoint.replace(/^\\//, '')}`.replace(\n\t\t/\\{([^}]+)\\}/g,\n\t\t(_match, name: string) => {\n\t\t\tconst v = rest[name];\n\t\t\tdelete rest[name];\n\t\t\treturn encodeURIComponent(String(v ?? ''));\n\t\t},\n\t);\n\tconst inQuery = new Set(queryKeys);\n\tconst query: Record<string, string | number | undefined> = {};\n\tconst body: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(rest)) {\n\t\tif (v === undefined || v === '') continue;\n\t\tif (method === 'GET' || inQuery.has(k)) query[k] = v as string | number;\n\t\telse body[k] = v;\n\t}\n\treturn { path, method, query, body: method === 'POST' ? body : undefined };\n}\n", "// Generated by scripts/sync-bindings.ts (bindings.config.ts joined with specs/openapi.json). Do not edit.\n\nimport type { FieldCondition, OptionSource } from '../utils/field-schema.js';\n\n/** `METHOD /path` of a bound operation -> request field -> the collection its choices are read from. */\nexport const OPTION_SOURCES: Record<string, Record<string, OptionSource>> = {\n \"GET /angel-numbers/numbers/{number}\": {\n \"number\": {\n \"path\": \"/angel-numbers/numbers\",\n \"limit\": 50,\n \"lang\": true\n }\n },\n \"GET /astrology/planet-meanings/{id}\": {\n \"id\": {\n \"path\": \"/astrology/planet-meanings\",\n \"lang\": true\n }\n },\n \"GET /astrology/signs/{id}\": {\n \"id\": {\n \"path\": \"/astrology/signs\",\n \"lang\": true\n }\n },\n \"GET /crystals\": {\n \"color\": {\n \"path\": \"/crystals/colors\",\n \"lang\": true\n },\n \"planet\": {\n \"path\": \"/crystals/planets\",\n \"lang\": true\n }\n },\n \"GET /crystals/{id}\": {\n \"id\": {\n \"path\": \"/crystals\",\n \"limit\": 100,\n \"lang\": true\n }\n },\n \"GET /dreams/symbols\": {\n \"letter\": {\n \"path\": \"/dreams/symbols/letters\"\n }\n },\n \"GET /dreams/symbols/{id}\": {\n \"id\": {\n \"path\": \"/dreams/symbols\",\n \"search\": \"q\",\n \"limit\": 50\n }\n },\n \"GET /iching/trigrams/{id}\": {\n \"id\": {\n \"path\": \"/iching/trigrams\",\n \"lang\": true\n }\n },\n \"GET /tarot/cards/{id}\": {\n \"id\": {\n \"path\": \"/tarot/cards\",\n \"limit\": 100,\n \"lang\": true\n }\n }\n};\n\n/** `METHOD /path` of a bound operation -> request field -> the other field and value that disable it. */\nexport const DISABLED_WHEN: Record<string, Record<string, FieldCondition>> = {\n \"GET /tarot/cards\": {\n \"suit\": {\n \"field\": \"arcana\",\n \"value\": \"major\"\n }\n }\n};\n", "/**\n * Pure, framework-free schema layer shared by the self-fetch form. It turns one OpenAPI operation into a digested list of {@link FieldDef}s whose {@link InputKind} decides which input widget renders, with zero Lit or DOM dependency so the build-time slice generator ({@link ../../../scripts/build-schemas.ts}) and the taxonomy-coverage test consume the exact same classification the browser does.\n *\n * @remarks\n * The registry is by SHAPE, never by name: {@link classifyInput} inspects `enum` / `type` / `format` only, so a new API parameter gets a working widget with no code change, and the taxonomy gate fails loudly (via a `null` return) the day a genuinely new shape appears. Name-driven render intent (hidden values, city searches and the Advanced fold) is resolved here too, so browser and server renderers consume the same decisions.\n */\n\nimport { EN_FIELD_LABELS } from '../generated/field-labels-en.js';\nimport { DISABLED_WHEN, OPTION_SOURCES } from '../generated/option-sources.js';\nimport { chromeLabel, fieldLabel, interpolate } from '../i18n/registry.js';\nimport { SIGNS_ORDER } from '../tokens/index.js';\nimport { humanize } from './string.js';\n\n/** A JSON `$ref` node, before resolution against `components.schemas`. */\nexport interface OpenApiSchemaRef {\n\t$ref?: string;\n}\n\n/** The subset of an OpenAPI 3 schema object the form reads. */\nexport interface OpenApiSchema extends OpenApiSchemaRef {\n\t/** A plain name in 3.0, or an ARRAY in 3.1 where nullability is spelled `['number', 'null']`. Read it through {@link scalarType}, never compare it directly. */\n\ttype?: string | string[];\n\tformat?: string;\n\tdescription?: string;\n\tenum?: string[];\n\tdefault?: unknown;\n\tminimum?: number;\n\tmaximum?: number;\n\texclusiveMinimum?: number;\n\texclusiveMaximum?: number;\n\tpattern?: string;\n\tproperties?: Record<string, OpenApiSchema>;\n\trequired?: string[];\n\titems?: OpenApiSchema;\n\tminItems?: number;\n\tmaxItems?: number;\n\texample?: unknown;\n\tanyOf?: OpenApiSchema[];\n\toneOf?: OpenApiSchema[];\n}\n\n/** One operation's request shape, as read from `spec.paths[path][method]`. */\nexport interface OperationSchema {\n\toperationId?: string;\n\tsummary?: string;\n\trequestBody?: {\n\t\tcontent?: Record<string, { schema?: OpenApiSchema | OpenApiSchemaRef }>;\n\t};\n\tparameters?: Array<{\n\t\tname: string;\n\t\tin: string;\n\t\tdescription?: string;\n\t\trequired?: boolean;\n\t\tschema?: OpenApiSchema;\n\t}>;\n}\n\n/** The minimal OpenAPI document surface the form introspects. */\nexport interface OpenApiDoc {\n\tpaths?: Record<string, Record<string, unknown>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/** The fully typed spec document the build-time scripts read from the committed `specs/openapi.json`: every path item value is an {@link OperationSchema}. The runtime form keeps the looser {@link OpenApiDoc} because a live spec fetch is untrusted input it narrows per operation. */\nexport interface SpecDoc {\n\tpaths: Record<string, Record<string, OperationSchema>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/**\n * The widget kind a parameter resolves to. This is the closed set the taxonomy gate enforces: every request parameter in the spec MUST classify to one of these, or {@link classifyInput} returns `null` and the gate fails, forcing a conscious decision when the API grows a new shape.\n */\nexport type InputKind =\n\t| 'tiles'\n\t| 'select'\n\t| 'toggle'\n\t| 'date'\n\t| 'time'\n\t| 'datetime'\n\t| 'number'\n\t| 'text'\n\t| 'array';\n\n/** A single input the form renders, digested from one schema property or parameter. */\nexport interface FieldDef {\n\t/** Unique storage + input key: the property name, or \"group.name\" for a nested object field. */\n\tkey: string;\n\t/** Schema property name (the label source), e.g. \"date\". */\n\tname: string;\n\t/** Contextual English label, overriding the generic name label when it loses the field's meaning. */\n\tlabel?: string;\n\t/** Parent object key for a nested schema (person1/person2); undefined for a flat field. */\n\tgroup?: string;\n\t/** True when the spec declares the field as `in: query`, so it belongs in the query string even on a POST. */\n\tinQuery?: boolean;\n\t/** The resolved widget kind. */\n\tkind: InputKind;\n\trequired: boolean;\n\tdescription?: string;\n\tenum?: string[];\n\tmin?: number;\n\tmax?: number;\n\tdefault?: unknown;\n\t/** Spec `example`, used as the placeholder for a text input. */\n\texample?: unknown;\n\t/** Where the choices for this field are listed, when the API serves them; the form reads them at run time. */\n\tsource?: OptionSource;\n\t/** Hidden value or coordinate supplied by a group's city box; absent for a visible input. */\n\trole?: 'seed' | 'hidden-default' | 'location';\n\t/** A visible timezone input is a city picker writing an IANA zone, never a typed offset. */\n\tcity?: true;\n\t/** True when this input (or its whole group) belongs under Advanced. */\n\tfold?: true;\n\t/** The other field and value that disable this one, when its binding declares them. */\n\tdisabledWhen?: FieldCondition;\n}\n\n/** One request field holding one value: the condition under which a bound form disables another field. */\nexport interface FieldCondition {\n\tfield: string;\n\tvalue: string;\n}\n\n/**\n * A GET collection on the API that lists the choices for one request field.\n *\n * @remarks\n * Two kinds reach a form, both resolved at build time into `generated/option-sources.ts`: a filter whose values the API serves as a list of their own (the letters the dream dictionary holds, the colours the crystal list filters on), and a free-string path identifier (`/dreams/symbols/{id}`), whose choices are the collection one segment up. The spec stays UI-agnostic either way: the first is a hint declared in `scripts/bindings.config.ts`, the second is derived from the paths.\n */\nexport interface OptionSource {\n\t/** Path of the collection, leading slash. */\n\tpath: string;\n\t/** The query parameter that searches the collection, when it has one; absent, the whole collection is read once and filtered as the visitor types. */\n\tsearch?: string;\n\t/** The largest page the collection serves, so a read asks for as much of it as one request allows. */\n\tlimit?: number;\n\t/** True when the collection takes `?lang=`, so its names arrive in the page language. */\n\tlang?: true;\n}\n\n/** One choice a field offers: the wire value, the words a visitor reads, and whether it can be picked. */\nexport interface FieldOption {\n\tvalue: string;\n\tlabel: string;\n\tdisabled?: boolean;\n}\n\n/**\n * A request property that is an ARRAY of objects, each a card of its own on the form.\n *\n * @remarks\n * A penta takes three to five birth records and a custom spread one to ten positions. The item schema expands into one group per record, keyed `{key}.{index}` so the group machinery (legend, city search, validation) treats each record like a `person1`; the model carries `min` records and the form grows to `max`. A comma-separated text box cannot take a birth record, which is what this exists to replace.\n */\nexport interface RepeatDef {\n\t/** The array property name on the wire, e.g. `members`. */\n\tkey: string;\n\tmin: number;\n\tmax: number;\n}\n\n/** One field group, in field order. An absent key denotes the flat top level. */\nexport interface FormGroup {\n\tkey?: string;\n\t/** English legend for a named group; absent for the unlabelled flat top level. */\n\tlabel?: string;\n\tfold?: true;\n\t/** A coordinate pair's city box, with the exact wire keys it fills (including its claimed timezone). */\n\tlocation?: { fields: string[]; required: boolean };\n}\n\n/** The digested form model shared by browser slices and platform-neutral manifests. */\nexport interface FormModel {\n\t/** Concise heading derived from the operation summary, falling back to the path. */\n\ttitle: string;\n\t/** Every request field, including hidden defaults and city-filled coordinates. The `lang` query parameter is intentionally excluded (routed via the element `lang` attribute instead). */\n\tfields: FieldDef[];\n\t/** True when the operation carries a `lang` query parameter, so the form knows to route an effective language to the query string on submit. */\n\thasLang: boolean;\n\t/** Resolved render intent. Optional only for older slices; normalize with withRenderIntent. */\n\tgroups?: FormGroup[];\n\t/** Whether a GET can open on its result without visitor input. */\n\topensOnLoad?: boolean;\n\t/** The array-of-object properties, each already expanded into `min` groups inside `fields`. Absent when the request has none. */\n\trepeats?: RepeatDef[];\n}\n\n/** The group key of the `index`th record of a repeating property, and its inverse. */\nexport const repeatGroup = (key: string, index: number): string =>\n\t`${key}.${index}`;\nexport function parseRepeatGroup(\n\tgroup: string,\n): { key: string; index: number } | null {\n\tconst m = /^(.+)\\.(\\d+)$/.exec(group);\n\treturn m ? { key: m[1] as string, index: Number(m[2]) } : null;\n}\n\n/**\n * A group legend, shared by the browser and published labels. Named objects use the chrome\n * catalogue (whose lookup folds case); repeating records use the array's field label and the\n * catalogued numbered-group template. The defaults produce the same legend in English.\n *\n * Catalogue lookup folds case: `humanize('natalChart')` produces `Natal Chart` and reuses\n * the existing `Natal chart` heading translation. Do not add a capitalized twin, which\n * would overwrite that heading in every locale. A new group with no catalogue entry\n * falls back to its humanized English name, so a missing translation never leaves a key\n * or an empty legend inside translated location labels.\n */\nexport function deriveGroupLabel(\n\tgroup: string,\n\tt: typeof interpolate = interpolate,\n\tfieldText: (name: string) => string = (name) =>\n\t\tEN_FIELD_LABELS[name] ?? humanize(name),\n): string {\n\tconst repeat = parseRepeatGroup(group);\n\treturn repeat\n\t\t? t('{{group}} {{n}}', {\n\t\t\t\tgroup: fieldText(repeat.key),\n\t\t\t\tn: repeat.index + 1,\n\t\t\t})\n\t\t: t(humanize(group));\n}\n\n/**\n * A published label for a model field. Contextual identifier nouns use the existing chrome\n * catalogue; coordinates use their full wire-name label from the API. Missing nouns must\n * stay absent rather than degrading to the generic ID label. Server consumers own English fallback.\n */\nexport function translatedFieldLabel(\n\tlang: string | undefined,\n\tfield: Pick<FieldDef, 'name' | 'label'> & Partial<Pick<FieldDef, 'key'>>,\n): string | undefined {\n\tconst wireName = field.key ?? field.name;\n\tif (splitCoordinateName(wireName)) return fieldLabel(lang, wireName);\n\tif (!field.label) return fieldLabel(lang, field.name);\n\treturn chromeLabel(lang, field.label);\n}\n\n/** The fields of one record of a repeating property, from the fields of its first record. Every record is the same template, so the form grows a repeat by re-keying record zero. */\nexport function repeatFields(\n\tfields: readonly FieldDef[],\n\tkey: string,\n\tindex: number,\n): FieldDef[] {\n\tconst first = repeatGroup(key, 0);\n\treturn fields\n\t\t.filter((f) => f.group === first)\n\t\t.map((f) => ({\n\t\t\t...f,\n\t\t\tkey: `${repeatGroup(key, index)}.${f.name}`,\n\t\t\tgroup: repeatGroup(key, index),\n\t\t}));\n}\n\n/**\n * Tiles or a select for a set of choices, decided by their SHAPE: a letter or a two-character code is a narrow tile, so up to thirty fit a row the way an index bar does, while a word or a name keeps the twelve a zodiac grid needs and anything longer is a select.\n */\nexport function optionKind(values: readonly string[]): 'tiles' | 'select' {\n\treturn values.length <= (isIndex(values) ? 30 : 12) ? 'tiles' : 'select';\n}\n\n/** True for choices that read as an index (letters, two-character codes) rather than words. */\nexport function isIndex(values: readonly string[]): boolean {\n\treturn values.every((v) => v.length <= 2);\n}\n\n/** The latitude+longitude+timezone trio the form suppresses in favour of a city search. Centralised so the render path and tests agree. */\nexport const LOCATION_TRIO = ['latitude', 'longitude', 'timezone'] as const;\n\n/**\n * The coordinate pair that DEFINES a location group. `timezone` is deliberately absent.\n *\n * @remarks\n * A group qualifies for a city search on latitude+longitude alone, because a timezone is not always\n * part of the group that owns the coordinates: `generateRelocationChart` carries two coordinate\n * pairs and exactly ONE top-level `timezone`, which is the BIRTH timezone (relocating does not move\n * the birth moment), so the relocation pair correctly has no timezone of its own. Requiring all\n * three would leave that operation rendering raw number inputs, which is the bug this exists to\n * prevent.\n */\nexport const LOCATION_PAIR = ['latitude', 'longitude'] as const;\n\n/**\n * Split a flat coordinate property into its group prefix and canonical leaf name, or `null` when the\n * name is not a prefixed coordinate.\n *\n * @remarks\n * **Two shapes carry two locations in one request and this handles the second one.** Most\n * multi-location operations nest per person (`person1`/`person2`, `personA`/`personB`), so object\n * nesting alone already groups them. `generateRelocationChart` is the only operation in the spec\n * that instead puts both pairs at the TOP level and distinguishes them by a name prefix\n * (`birthLatitude` / `relocationLatitude`). Keying the grouping off the prefix as well as off the\n * nesting means both shapes converge on the same group machinery, and a future `partnerLatitude`\n * needs no code change.\n *\n * Matching is deliberately restricted to the coordinate pair. A prefix is NOT harvested from any\n * other field name, so `birthDate` stays an ordinary field in the flat group and does not invent a\n * phantom `birth` group with a lone date in it.\n */\nfunction splitCoordinateName(\n\tname: string,\n): { group: string; leaf: (typeof LOCATION_PAIR)[number] } | null {\n\tconst m = name.match(/^(.+?)(Latitude|Longitude)$/);\n\tif (!m) return null;\n\treturn {\n\t\tgroup: m[1],\n\t\tleaf: m[2].toLowerCase() as (typeof LOCATION_PAIR)[number],\n\t};\n}\n\n/** Canonical lowercase zodiac set, derived from {@link SIGNS_ORDER} so sign detection and the glyph map can never disagree. */\nconst ZODIAC_LOWER = SIGNS_ORDER.map((s) => s.toLowerCase());\n\n/** Resolve a `$ref` (one hop is all the spec uses) against the schema map; pass non-refs through. */\nexport function resolveSchema(\n\tschema: OpenApiSchema | OpenApiSchemaRef | undefined,\n\tall: Record<string, OpenApiSchema>,\n): OpenApiSchema | undefined {\n\tif (!schema) return undefined;\n\tif ('$ref' in schema && schema.$ref) {\n\t\tconst name = schema.$ref.split('/').pop();\n\t\treturn name ? all[name] : undefined;\n\t}\n\treturn schema as OpenApiSchema;\n}\n\n/**\n * Collapse an `anyOf`/`oneOf` union to the single member that decides the widget: an enum member wins (so `houseSystem` as enum-or-string renders as a picker), then any concrete-typed member (so timezone as number-or-string resolves to a real kind), else the first member. Non-union schemas pass through untouched.\n */\nfunction representative(s: OpenApiSchema): OpenApiSchema {\n\tconst union = s.anyOf ?? s.oneOf;\n\tif (!union || union.length === 0) return s;\n\treturn (\n\t\tunion.find((m) => Array.isArray(m.enum)) ??\n\t\tunion.find((m) => scalarType(m) && scalarType(m) !== 'null') ??\n\t\tunion[0] ??\n\t\ts\n\t);\n}\n\n/**\n * Map one resolved schema to its {@link InputKind}, or `null` when the shape is genuinely unhandled. The form treats `null` as a plain text fallback (never crashes); the taxonomy gate treats it as a failure (forces a decision). Object schemas are never passed here: an object with `properties` expands into a group of leaf fields upstream, so it has no leaf kind of its own.\n */\n/**\n * The single scalar type name a schema resolves to, across both OpenAPI spellings.\n *\n * @remarks\n * OpenAPI 3.1 expresses a nullable scalar as `type: ['number', 'null']` where 3.0 wrote `type: 'number', nullable: true`. Every direct `type === 'number'` comparison silently stops matching the day the served document switches, and the field then classifies as UNHANDLED rather than as a number, which is how a whole form degrades to text boxes without one test noticing. The `null` member carries no input information, so the remaining single member IS the type.\n */\nexport function scalarType(s: OpenApiSchema): string | undefined {\n\tif (typeof s.type === 'string') return s.type;\n\tif (!Array.isArray(s.type)) return undefined;\n\tconst real = s.type.filter((t) => t !== 'null');\n\treturn real.length === 1 ? real[0] : undefined;\n}\n\nexport function classifyInput(schema: OpenApiSchema): InputKind | null {\n\tconst s = representative(schema);\n\tconst type = scalarType(s);\n\tif (Array.isArray(s.enum)) return optionKind(s.enum);\n\tif (type === 'boolean') return 'toggle';\n\tif (s.format === 'date') return 'date';\n\tif (s.format === 'time') return 'time';\n\tif (s.format === 'date-time') return 'datetime';\n\tif (type === 'integer' || type === 'number') return 'number';\n\tif (type === 'string') return 'text';\n\tif (type === 'array') return 'array';\n\treturn null;\n}\n\n/** True when an enum's values are exactly the twelve zodiac signs (case-insensitive), so the tiles can carry sign glyphs. */\nexport function isZodiacEnum(values: readonly string[]): boolean {\n\tif (values.length !== 12) return false;\n\tconst lower = new Set(values.map((v) => v.toLowerCase()));\n\treturn ZODIAC_LOWER.every((s) => lower.has(s));\n}\n\n/** One digested leaf field from a resolved schema. Shared by the flat and grouped construction paths so params and body props carry identical metadata (min/max included). */\nfunction toField(\n\tname: string,\n\tresolved: OpenApiSchema,\n\topts: { key: string; group?: string; required: boolean; inQuery?: boolean },\n): FieldDef {\n\tconst rep = representative(resolved);\n\treturn {\n\t\tkey: opts.key,\n\t\tname,\n\t\tgroup: opts.group,\n\t\tinQuery: opts.inQuery,\n\t\tkind: classifyInput(resolved) ?? 'text',\n\t\trequired: opts.required,\n\t\tdescription: rep.description ?? resolved.description,\n\t\tenum: rep.enum,\n\t\t// HTML has no exclusive bound, so an exclusive one is the nearest an input can state; the API refuses the bound itself and prints why under the field.\n\t\tmin: rep.minimum ?? rep.exclusiveMinimum,\n\t\tmax: rep.maximum ?? rep.exclusiveMaximum,\n\t\tdefault: resolved.default ?? rep.default,\n\t\texample: resolved.example ?? rep.example,\n\t};\n}\n\n/**\n * Digest one operation into the {@link FormModel} the form renders. This is the single construction path: body properties (nested objects expand to `group.sub` keys) and path+query parameters flow through {@link toField} identically, so a query integer keeps its min/max the same as a body integer. The `lang` query parameter is dropped from `fields` and surfaced as {@link FormModel.hasLang} instead.\n */\nexport function buildFormModel(\n\top: OperationSchema,\n\tschemas: Record<string, OpenApiSchema>,\n\tendpoint: string,\n\tmethod: string = op.requestBody ? 'POST' : 'GET',\n): FormModel {\n\tconst fields: FieldDef[] = [];\n\tconst repeats: RepeatDef[] = [];\n\tlet hasLang = false;\n\n\tconst bodyRef = op.requestBody?.content?.['application/json']?.schema;\n\tconst bodySchema = resolveSchema(bodyRef, schemas);\n\tif (bodySchema?.properties) {\n\t\tconst required = new Set(bodySchema.required ?? []);\n\t\tfor (const [name, sub] of Object.entries(bodySchema.properties)) {\n\t\t\tconst resolved = resolveSchema(sub, schemas) ?? {};\n\t\t\tconst item =\n\t\t\t\tresolved.type === 'array'\n\t\t\t\t\t? resolveSchema(resolved.items, schemas)\n\t\t\t\t\t: undefined;\n\t\t\tif (item?.type === 'object' && item.properties) {\n\t\t\t\tconst min = Math.max(1, resolved.minItems ?? 1);\n\t\t\t\tconst itemRequired = new Set(item.required ?? []);\n\t\t\t\trepeats.push({ key: name, min, max: resolved.maxItems ?? min });\n\t\t\t\tfor (let i = 0; i < min; i++) {\n\t\t\t\t\tfor (const [subName, subSchema] of Object.entries(item.properties)) {\n\t\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\t\tkey: `${repeatGroup(name, i)}.${subName}`,\n\t\t\t\t\t\t\t\tgroup: repeatGroup(name, i),\n\t\t\t\t\t\t\t\trequired: required.has(name) && itemRequired.has(subName),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (resolved.type === 'object' && resolved.properties) {\n\t\t\t\tconst subRequired = new Set(resolved.required ?? []);\n\t\t\t\tfor (const [subName, subSchema] of Object.entries(\n\t\t\t\t\tresolved.properties,\n\t\t\t\t)) {\n\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\t// A list of objects nested inside a group (a plot's polygon points) has no\n\t\t\t\t\t// input a visitor can fill, and a text box for it can only produce a\n\t\t\t\t\t// rejected request; the group's scalar alternative (width and depth) is\n\t\t\t\t\t// what the form offers.\n\t\t\t\t\tif (\n\t\t\t\t\t\tr.type === 'array' &&\n\t\t\t\t\t\tresolveSchema(r.items, schemas)?.type === 'object'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\tkey: `${name}.${subName}`,\n\t\t\t\t\t\t\tgroup: name,\n\t\t\t\t\t\t\trequired: required.has(name) && subRequired.has(subName),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// A prefixed coordinate joins a group named after its prefix and reports the\n\t\t\t\t// canonical leaf name, so the trio logic and the city search match it unchanged.\n\t\t\t\t// `key` stays the ORIGINAL property name because it is the storage and wire\n\t\t\t\t// identity: rewriting it to `birth.latitude` would serialise a body the API\n\t\t\t\t// rejects.\n\t\t\t\tconst coord = splitCoordinateName(name);\n\t\t\t\tconst field = toField(coord?.leaf ?? name, resolved, {\n\t\t\t\t\tkey: name,\n\t\t\t\t\tgroup: coord?.group,\n\t\t\t\t\trequired: required.has(name),\n\t\t\t\t});\n\t\t\t\tif (coord) field.label = `${humanize(coord.group)} ${coord.leaf}`;\n\t\t\t\tfields.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const param of op.parameters ?? []) {\n\t\tif (param.in !== 'path' && param.in !== 'query') continue;\n\t\t// lang is site-owner chrome, not a visitor field: route it through the\n\t\t// element `lang` attribute, never render it in the form.\n\t\tif (param.name === 'lang' && param.in === 'query') {\n\t\t\thasLang = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = resolveSchema(param.schema, schemas) ?? {};\n\t\tconst field = toField(param.name, resolved, {\n\t\t\tkey: param.name,\n\t\t\trequired: !!param.required,\n\t\t\tinQuery: param.in === 'query',\n\t\t});\n\t\t// Only an otherwise bare identifier needs a noun from the spec. A meaningful\n\t\t// name such as `sign` keeps its existing field-label catalogue entry.\n\t\tif (\n\t\t\tparam.in === 'path' &&\n\t\t\tfield.enum &&\n\t\t\t/^(id|identifier|slug)$/i.test(\n\t\t\t\tEN_FIELD_LABELS[field.name] ?? humanize(field.name),\n\t\t\t)\n\t\t) {\n\t\t\tconst noun = /^([A-Za-z][A-Za-z -]*?)\\s+(?:id|identifier|slug)\\b/i\n\t\t\t\t.exec(param.description ?? field.description ?? '')?.[1]\n\t\t\t\t?.trim();\n\t\t\tif (noun) field.label = noun;\n\t\t}\n\t\tfields.push(field);\n\t}\n\n\treturn withRenderIntent(\n\t\t{\n\t\t\ttitle: deriveTitle(op.summary, endpoint),\n\t\t\tfields,\n\t\t\thasLang,\n\t\t\t...(repeats.length > 0 ? { repeats } : {}),\n\t\t},\n\t\tmethod,\n\t\tendpoint,\n\t);\n}\n\n/**\n * Resolve render intent once, shared by spec digestion and compatibility with older schema slices.\n *\n * @remarks\n * A coordinate PAIR defines a city box, not a trio: relocation has two pairs and one birth\n * timezone. Only the first pair may claim a flat timezone; an unclaimed timezone remains a\n * visible city picker writing an IANA zone. Keys always retain their original wire identity.\n * A city box is marked required when any of its own coordinate or timezone fields is required,\n * including a required timezone beside optional Human Design coordinates.\n * Optional named groups stay together under Advanced. With no primary required input, groups\n * and undefaulted flat fields stay open so an either-or request still offers its inputs.\n */\nexport function withRenderIntent(\n\tmodel: FormModel,\n\tmethod: string,\n\tendpoint: string,\n): FormModel {\n\tconst operation = `${method.toUpperCase()} /${endpoint.replace(/^\\//, '')}`;\n\tconst sources = OPTION_SOURCES[operation] ?? {};\n\tconst rules = DISABLED_WHEN[operation] ?? {};\n\tconst fields = model.fields.map((f): FieldDef => {\n\t\tconst field = { ...f };\n\t\tdelete field.role;\n\t\tdelete field.city;\n\t\tdelete field.fold;\n\t\treturn {\n\t\t\t...field,\n\t\t\t...(sources[f.key] && { source: sources[f.key] }),\n\t\t\t...(rules[f.key] && { disabledWhen: rules[f.key] }),\n\t\t};\n\t});\n\tconst groups: FormGroup[] = [...new Set(fields.map((f) => f.group))].map(\n\t\t(key) => (key === undefined ? {} : { key, label: deriveGroupLabel(key) }),\n\t);\n\tconst locations = groups.filter((g) =>\n\t\tLOCATION_PAIR.every((name) =>\n\t\t\tfields.some((f) => f.group === g.key && f.name === name),\n\t\t),\n\t);\n\tfor (const [index, group] of locations.entries()) {\n\t\tconst own = fields.filter((f) => f.group === group.key);\n\t\tconst timezone =\n\t\t\town.find((f) => f.name === 'timezone') ??\n\t\t\t(index === 0\n\t\t\t\t? fields.find((f) => !f.group && f.name === 'timezone')\n\t\t\t\t: undefined);\n\t\tgroup.location = {\n\t\t\tfields: [\n\t\t\t\t...own\n\t\t\t\t\t.filter((f) => (LOCATION_PAIR as readonly string[]).includes(f.name))\n\t\t\t\t\t.map((f) => f.key),\n\t\t\t\t...(timezone ? [timezone.key] : []),\n\t\t\t],\n\t\t\t// Preserve the group's required mark; a claimed flat timezone is still validated by its field.\n\t\t\trequired: own.some(\n\t\t\t\t(f) =>\n\t\t\t\t\t(LOCATION_TRIO as readonly string[]).includes(f.name) && f.required,\n\t\t\t),\n\t\t};\n\t}\n\tfor (const f of fields) {\n\t\tif (f.name === 'seed') f.role = 'seed';\n\t\telse if ((f.name === 'limit' || f.name === 'offset') && !f.required)\n\t\t\tf.role = 'hidden-default';\n\t\telse if (locations.some((g) => g.location?.fields.includes(f.key)))\n\t\t\tf.role = 'location';\n\t\telse if (f.name === 'timezone') f.city = true;\n\t}\n\tconst primaryGroups = groups.filter(\n\t\t(g) =>\n\t\t\tg.key !== undefined &&\n\t\t\t(g.location || fields.some((f) => f.group === g.key && f.required)),\n\t);\n\tconst hasPrimary =\n\t\tfields.some((f) => !f.group && !f.role && f.required) ||\n\t\tprimaryGroups.length > 0 ||\n\t\tlocations.some((g) => g.key === undefined);\n\tfor (const group of groups) {\n\t\tif (group.key !== undefined && hasPrimary && !primaryGroups.includes(group))\n\t\t\tgroup.fold = true;\n\t}\n\tfor (const f of fields) {\n\t\tif (\n\t\t\tf.group\n\t\t\t\t? groups.find((g) => g.key === f.group)?.fold\n\t\t\t\t: !f.role && (hasPrimary ? !f.required : f.default !== undefined)\n\t\t)\n\t\t\tf.fold = true;\n\t}\n\treturn { ...model, fields, groups, opensOnLoad: opensOnLoad(model, method) };\n}\n\n/**\n * Concise form heading. Prefers the operation summary (spec-authored), taking the clause before the first \" - \" so \"Daily horoscope by zodiac sign - Transit-based forecast\" reads as \"Daily horoscope by zodiac sign\", and falls back to the humanized last path segment.\n */\nexport function deriveTitle(\n\tsummary: string | undefined,\n\tendpoint: string,\n): string {\n\tconst lead = summary?.split(' - ')[0]?.trim();\n\tif (lead) return lead;\n\treturn humanize(endpoint.split('/').pop() ?? '');\n}\n\n/**\n * True when a form can show its result before the visitor asks: a read (GET) that needs nothing from them, such as a list, today's phase or a random draw.\n *\n * @remarks\n * The ONE rule the self-fetch component, the hosted embed and the one-tag widget script all ask, so the three never disagree about which forms open on a result. A POST is never one, because a request body with nothing required is usually an either-or the schema cannot state, and sending it empty is a 400 rather than a default reading.\n */\nexport function opensOnLoad(model: FormModel, method: string): boolean {\n\treturn (\n\t\tmethod.toUpperCase() === 'GET' && !model.fields.some((f) => f.required)\n\t);\n}\n\n/**\n * Outcome-first submit-button label keyed off the endpoint intent. A paged collection is searched, chart and reading endpoints \"Generate\", divination endpoints \"Cast\", comparison endpoints \"Compare\", and lookup/reading GETs \"Get reading\". A generic verb beats a bare \"Submit\" on a widget a visitor never set up.\n *\n * Returns the CANONICAL English verb, which is also its catalogue key: the form translates the result rather than this function doing it, because this module is request-context-free and has no element to resolve a page language from. Every verb lives in `i18n/chrome-strings.ts`, and `tests/i18n.test.ts` runs this function over every operation in the committed spec so a new verb cannot be added without a catalogue entry.\n *\n * @param fields - The form fields, when known: a request that pages (`limit`, `offset`) lists a collection, which a visitor searches whatever domain the path names.\n */\nexport function deriveSubmitLabel(\n\tendpoint: string,\n\tfields: readonly FieldDef[] = [],\n): string {\n\tif (fields.some((f) => f.name === 'limit' || f.name === 'offset'))\n\t\treturn 'Search';\n\tconst e = endpoint.toLowerCase();\n\tif (/compat|synastry|guna|connection|penta|composite/.test(e))\n\t\treturn 'Compare';\n\tif (/\\bcast\\b|\\/draw|iching|hexagram|tarot/.test(e)) return 'Cast';\n\tif (/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(e))\n\t\treturn 'Get reading';\n\treturn 'Generate';\n}\n\n/** Deterministic slice filename for one operation, shared by the generator and the runtime loader so both address the same artifact. */\nexport function sliceFileName(method: string, endpoint: string): string {\n\tconst path = endpoint\n\t\t.replace(/^\\//, '')\n\t\t.replace(/[{}]/g, '')\n\t\t.replace(/\\//g, '-');\n\treturn `${method.toLowerCase()}--${path}.json`;\n}\n\n/** The array or count map a collection response carries its entries in: the response itself when it is a list, else its first list, else its first object of counts. */\nfunction entriesOf(json: unknown): unknown[] | Record<string, number> | null {\n\tif (Array.isArray(json)) return json;\n\tif (!json || typeof json !== 'object') return null;\n\tconst values = Object.values(json as Record<string, unknown>);\n\tconst list = values.find(Array.isArray);\n\tif (list) return list as unknown[];\n\tconst counts = values.find(\n\t\t(v) =>\n\t\t\t!!v &&\n\t\t\ttypeof v === 'object' &&\n\t\t\tObject.values(v).every((n) => typeof n === 'number'),\n\t);\n\treturn (counts as Record<string, number> | undefined) ?? null;\n}\n\n/**\n * The choices a collection response offers, read from its shape and never from its name.\n *\n * @remarks\n * Three shapes: a list of strings (each is its own value), a list of records (the value is the record's `id`, else the field's own name, else its `number`; the words are its `name`, else its `english` name, else the value), and a map of counts, where a zero is a choice with nothing behind it. A map keyed by single letters is an index, so the letters it omits are listed too, disabled, and a reader sees the whole alphabet.\n *\n * @param field - The request field the choices fill, which is also where a record may carry its value (an angel number sequence sits in `number`).\n */\nexport function optionsFrom(json: unknown, field = 'id'): FieldOption[] {\n\tconst entries = entriesOf(json);\n\tif (!entries) return [];\n\tif (!Array.isArray(entries)) {\n\t\tconst keys = Object.keys(entries);\n\t\tconst index = keys.length > 0 && keys.every((k) => /^[a-z]$/.test(k));\n\t\tconst all = index ? [...'abcdefghijklmnopqrstuvwxyz'] : keys;\n\t\treturn all.map((k) => ({\n\t\t\tvalue: k,\n\t\t\tlabel: index ? k.toUpperCase() : k,\n\t\t\tdisabled: !entries[k],\n\t\t}));\n\t}\n\tconst out: FieldOption[] = [];\n\tfor (const item of entries) {\n\t\tif (typeof item === 'string') {\n\t\t\tout.push({ value: item, label: item });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item || typeof item !== 'object') continue;\n\t\tconst r = item as Record<string, unknown>;\n\t\tconst raw = r.id ?? r[field] ?? r.number;\n\t\tif (raw == null) continue;\n\t\tconst value = String(raw);\n\t\tconst name = r.name ?? r.english;\n\t\tout.push({ value, label: typeof name === 'string' ? name : value });\n\t}\n\treturn out;\n}\n\n/** The total a paged collection reports, or undefined when it reports none. */\nexport function totalOf(json: unknown): number | undefined {\n\tconst t = (json as { total?: unknown } | null)?.total;\n\treturn typeof t === 'number' ? t : undefined;\n}\n\n/**\n * The collection a free-string path identifier is chosen from: the GET one segment up, as the spec declares it, or undefined when there is none.\n *\n * @remarks\n * Only a FREE string qualifies: an enum already lists its choices, and a pattern, a format or a number type already tells the input what to accept. So `/dreams/symbols/{id}` picks from `/dreams/symbols`, `/crystals/{id}` from `/crystals`, and `/numerology/meanings/{number}`, whose pattern names its twelve values, keeps its input.\n */\nexport function pickerSource(\n\tspec: SpecDoc,\n\tpath: string,\n\tparam: { name: string; required?: boolean; schema?: OpenApiSchema },\n): OptionSource | undefined {\n\tconst s = resolveSchema(param.schema, spec.components?.schemas ?? {}) ?? {};\n\tif (!param.required || scalarType(s) !== 'string') return undefined;\n\tif (s.enum || s.pattern || s.format) return undefined;\n\tconst suffix = `/{${param.name}}`;\n\tif (!path.endsWith(suffix)) return undefined;\n\tconst parent = path.slice(0, -suffix.length);\n\treturn parent ? collectionSource(spec, parent) : undefined;\n}\n\n/** How a GET collection is read for its choices: its search parameter, its largest page and whether it is localized, all from its declared query parameters. */\nexport function collectionSource(\n\tspec: SpecDoc,\n\tpath: string,\n): OptionSource | undefined {\n\tconst op = spec.paths[path]?.get;\n\tif (!op) return undefined;\n\tconst schemas = spec.components?.schemas ?? {};\n\tconst query = (op.parameters ?? []).filter((p) => p.in === 'query');\n\tconst limit = query.find((p) => p.name === 'limit');\n\tconst max = resolveSchema(limit?.schema, schemas)?.maximum;\n\treturn {\n\t\tpath,\n\t\t...(query.some((p) => p.name === 'q') ? { search: 'q' } : {}),\n\t\t...(max !== undefined ? { limit: max } : {}),\n\t\t...(query.some((p) => p.name === 'lang') ? { lang: true as const } : {}),\n\t};\n}\n", "/**\n * The value a READER sees, for a response field the API returns twice.\n *\n * @remarks\n * Several endpoints now echo a display translation beside the canonical value: `nameLocalized` next to `name`, `signLocalized` next to `sign`, `typeLocalized` next to `type`. **The canonical field is deliberately always English, whatever `?lang=` says, so it stays safe to compare against in code**, and the localized one is deliberately absent from an English response.\n *\n * That split is the whole contract, and inverting it breaks charts silently rather than loudly: `planetGlyph`, `signGlyph`, `aspectSymbol`, `ASPECT_CLASS`, `SIGNS_ORDER.indexOf`, every `Map` key and every CSS class fragment is keyed on the English name, so pointing one of them at `nameLocalized` resolves to nothing on a translated page and to the same value on an English one, which is exactly the shape of defect that passes every gate (lesson 24). **The lookup stays on the canonical value; only the printed text node, the `title` and the `aria-label` move.**\n *\n * These two helpers exist so that rule lives in one place rather than as a `??` at every call site, and so an English response, where the localized field simply is not there, degrades by construction instead of by remembering. Both take the KEY of the canonical field and derive its partner, so a mistyped key or a field that is not a display string is a compile error rather than a silent empty string.\n */\n\nimport { fieldLabel, optionLabel } from '../i18n/registry.js';\nimport { humanize } from './string.js';\n\n/**\n * The label for a field NAME, which is a different problem from a field VALUE.\n *\n * @remarks\n * A catalogue keyed on English source text cannot reach a name computed per response, so these read the published field-label payload instead and fall back to {@link humanize}, which is exactly what every caller printed before one existed. A name the payload does not carry therefore renders as it always did rather than as a gap.\n *\n * Here rather than in each component because three of them need the identical pairing: the form that asks for a field, and the two generic renderers that label what came back.\n *\n * @param english - The API English label to print where the payload carries none, INSTEAD of the humanized name; the form passes it, so a field reads as the API names it on an English page too.\n */\nexport function displayField(\n\tlang: string | undefined,\n\tname: string,\n\tenglish?: string,\n): string {\n\treturn fieldLabel(lang, name) ?? english ?? humanize(name);\n}\n\n/**\n * The label for one selectable VALUE of a field, same fallback rule.\n *\n * @param fallback - What to print where the payload carries no label, INSTEAD of the humanized value.\n * The default suits a word (`81-pada` reads as `81 pada`) and not an identifier that carries a number\n * a reader checks against a published table: `humanize` turns `gmt-584283` into `Gmt 584283`, which\n * is neither the label nor the identifier. Pass the raw value for those, so an English page prints\n * what a caller stores and a translated one prints the published word.\n */\nexport function displayOption(\n\tlang: string | undefined,\n\tfield: string,\n\tvalue: string,\n\tfallback?: string,\n): string {\n\treturn optionLabel(lang, field, value) ?? fallback ?? humanize(value);\n}\n\n/** The one naming convention every helper here derives from. Ratified by the API and spreading to more operations, so it is matched as a convention and never as a list of field names. */\nconst LOCALIZED = 'Localized';\n\n/** A response row carrying a canonical English `K` plus the optional localized partner the API writes beside it. */\nexport type Localizable<K extends string> = Partial<\n\tRecord<K | `${K}Localized`, string>\n>;\n\n/** The same pairing where the value is a LIST of names, e.g. `retrogradePlanets`. */\nexport type LocalizableList<K extends string> = Partial<\n\tRecord<K | `${K}Localized`, string[]>\n>;\n\n/**\n * The text to print for `key`: the localized value when the response carried one, else the English one.\n *\n * @param english - What to print in the English case INSTEAD of the raw field, for a canonical value that is an API enum with a display form of its own (`type` is `SEMI_SEXTILE` on the wire and `Semi-sextile` on screen). Omit it wherever the canonical value is already the readable one.\n *\n * @example\n * ```ts\n * display(planet, 'name'); // 'Sol' on ?lang=es, 'Sun' on English\n * planetGlyph(planet.name) ?? display(planet, 'name'); // the lookup stays English, the fallback TEXT does not\n * display(aspect, 'type', formatAspectName(aspect)); // 'Trígono', else 'Trine' and never 'TRINE'\n * ```\n */\nexport function display<\n\tT extends Localizable<K>,\n\tK extends Extract<keyof T, string>,\n>(row: T | null | undefined, key: K, english?: string): string {\n\tconst rec = row as Record<string, unknown> | null | undefined;\n\tconst localized = rec?.[`${key}${LOCALIZED}`];\n\tif (typeof localized === 'string' && localized !== '') return localized;\n\tif (english !== undefined) return english;\n\tconst canonical = rec?.[key];\n\treturn typeof canonical === 'string' ? canonical : '';\n}\n\n/**\n * A list field as `{ value, label }` pairs: the English `value` every lookup is keyed on, and the `label` a reader sees.\n *\n * @remarks\n * The localized array is INDEX-ALIGNED with the canonical one, which is the only thing that makes the pairing possible, so it is zipped by position and neither side is ever sorted, filtered or deduped on its own. A list that is short or absent falls back per item, so a partial translation still resolves every glyph.\n */\nexport function displayList<\n\tT extends LocalizableList<K>,\n\tK extends Extract<keyof T, string>,\n>(row: T | null | undefined, key: K): Array<{ value: string; label: string }> {\n\tconst rec = row as Record<string, unknown> | null | undefined;\n\tconst canonical = rec?.[key];\n\tif (!Array.isArray(canonical)) return [];\n\tconst localized = rec?.[`${key}${LOCALIZED}`];\n\tconst labels = Array.isArray(localized) ? localized : [];\n\treturn canonical.map((value, i) => {\n\t\tconst label = labels[i];\n\t\treturn {\n\t\t\tvalue: String(value),\n\t\t\tlabel: typeof label === 'string' && label !== '' ? label : String(value),\n\t\t};\n\t});\n}\n\n/**\n * Fold every `XLocalized` field into its `X` partner: the reader's value under the canonical NAME, and the duplicate key gone.\n *\n * @remarks\n * For a renderer that has no idea what its fields MEAN and derives its columns from `Object.keys(row)`, which is how `<roxy-data>` started drawing `Planet | Planet Localized | Longitude | Sign | Sign Localized` the day the API began sending both. Two extra columns, headed in English, carrying the same fact twice, on a page whose owner changed nothing. That is a regression rather than a missing feature, so it is repaired at the key layer every render path already funnels through rather than at each of them.\n *\n * Three rules, and each has a way of going wrong:\n *\n * - **A `*Localized` key with no canonical partner stays put.** Suppressing on the name alone deletes data the response carries and nothing else is rendering.\n * - **The canonical key keeps its POSITION**, so a translated response and an English one lay out identically, column for column.\n * - **A row with nothing to fold is returned as the same object**, so the English path is not merely equivalent but untouched.\n *\n * The English value is dropped rather than shown beside its translation because the two are the same fact, and the caller here is generic: it cannot know that `sign` is the value a lookup would be keyed on. A component that needs both halves reads them itself with {@link display}.\n */\nexport function foldLocalized<V>(row: Record<string, V>): Record<string, V> {\n\tlet folded: Record<string, V> | undefined;\n\tfor (const key of Object.keys(row)) {\n\t\tif (!key.endsWith(LOCALIZED)) continue;\n\t\tconst base = key.slice(0, -LOCALIZED.length);\n\t\tif (base === '' || !(base in row)) continue;\n\t\tfolded ??= { ...row };\n\t\tconst value = row[key];\n\t\tif (value !== undefined && value !== null && value !== '')\n\t\t\tfolded[base] = value;\n\t\tdelete folded[key];\n\t}\n\treturn folded ?? row;\n}\n", "import { css } from 'lit';\n\n/** The dropdown of a search-as-you-type box (its spinner, listbox, options and empty row), shared by the city search and the identifier picker so the two read as one family. */\nexport const comboboxStyles = css`.spinner{border:2px solid var(--roxy-muted,#71717a);border-top-color:#0000;border-radius:50%;width:14px;height:14px;animation:.7s linear infinite roxy-spin;position:absolute;top:50%;right:12px;transform:translateY(-50%)}@keyframes roxy-spin{to{transform:translateY(-50%)rotate(360deg)}}@media (prefers-reduced-motion:reduce){.spinner{animation:none}}.results{z-index:50;padding:var(--roxy-space-xs,.25rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);box-shadow:var(--roxy-shadow-md);max-height:22rem;animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));margin:0;list-style:none;position:absolute;top:calc(100% + 4px);left:0;right:0;overflow-y:auto}.option{align-items:center;gap:var(--roxy-space-sm,.5rem);width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);border-radius:var(--roxy-radius-sm,6px);text-align:left;font-family:inherit;font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-fg,#0a0a0a);cursor:pointer;transition:background-color var(--roxy-motion-duration,.2s);background:0 0;border:0;display:flex}.option:hover,.option[aria-selected=true]{background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 10%, transparent)}.empty{padding:var(--roxy-space-md,1rem);color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}`;\n", "/**\n * Lightweight debounce for input handlers. Used by location search.\n *\n * The returned function exposes a `.cancel()` method so callers can clear a\n * pending invocation when the host element disconnects, preventing the timer\n * from firing on a detached node and mutating reactive state after teardown.\n */\nexport interface Debounced<F extends (...args: never[]) => unknown> {\n\t(...args: Parameters<F>): void;\n\tcancel: () => void;\n}\n\nexport function debounce<F extends (...args: never[]) => unknown>(\n\tfn: F,\n\twait: number,\n): Debounced<F> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst debounced = ((...args: Parameters<F>) => {\n\t\tif (timer) clearTimeout(timer);\n\t\ttimer = setTimeout(() => {\n\t\t\ttimer = undefined;\n\t\t\tfn(...args);\n\t\t}, wait);\n\t}) as Debounced<F>;\n\tdebounced.cancel = () => {\n\t\tif (timer) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t}\n\t};\n\treturn debounced;\n}\n", "import {\n\tcss,\n\thtml,\n\tnothing,\n\ttype ReactiveController,\n\ttype ReactiveControllerHost,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { comboboxStyles } from './combobox-styles.js';\nimport { debounce } from './debounce.js';\nimport { type ApiRoute, apiFetch } from './fetch-controller.js';\nimport {\n\ttype FieldOption,\n\ttype OptionSource,\n\toptionsFrom,\n\ttotalOf,\n} from './field-schema.js';\n\n/** How many suggestions a server search asks for while a visitor types. */\nconst SUGGESTIONS = 10;\n\n/** The most pages one collection is read in, a ceiling for a collection that keeps reporting more than it sends. */\nconst MAX_PAGES = 10;\n\n/** One read of each collection per route and language, shared by every form on the page; a failure is evicted so the next mount asks again. */\nconst optionCache = new Map<string, Promise<FieldOption[]>>();\n\n/** The query one read of a collection sends: its largest page, the offset reached, the page language when it is localized, and the search when there is one. */\nfunction sourceQuery(\n\tsource: OptionSource,\n\tlang: string | undefined,\n\textra: Record<string, string | number> = {},\n): Record<string, string | number> {\n\treturn {\n\t\t...(source.limit ? { limit: source.limit } : {}),\n\t\t...(source.lang && lang ? { lang } : {}),\n\t\t...extra,\n\t};\n}\n\n/**\n * Every choice a collection offers, read page by page up to the total it reports, once per route and language.\n *\n * @param field - The request field the choices fill, which is where a record without an `id` carries its value.\n */\nexport function readOptions(\n\troute: ApiRoute,\n\tsource: OptionSource,\n\tfield: string,\n\tlang?: string,\n): Promise<FieldOption[]> {\n\tconst key = JSON.stringify([\n\t\troute.submitUrl ?? route.baseUrl,\n\t\tsource.path,\n\t\tfield,\n\t\tlang,\n\t]);\n\tlet pending = optionCache.get(key);\n\tif (!pending) {\n\t\tpending = readAll(route, source, field, lang).catch((err) => {\n\t\t\toptionCache.delete(key);\n\t\t\tthrow err;\n\t\t});\n\t\toptionCache.set(key, pending);\n\t}\n\treturn pending;\n}\n\nasync function readAll(\n\troute: ApiRoute,\n\tsource: OptionSource,\n\tfield: string,\n\tlang?: string,\n): Promise<FieldOption[]> {\n\tconst out: FieldOption[] = [];\n\tfor (let page = 0; page < MAX_PAGES; page++) {\n\t\tconst json = await apiFetch(route, {\n\t\t\tpath: source.path,\n\t\t\tmethod: 'GET',\n\t\t\tquery: sourceQuery(\n\t\t\t\tsource,\n\t\t\t\tlang,\n\t\t\t\tout.length ? { offset: out.length } : {},\n\t\t\t),\n\t\t});\n\t\tconst got = optionsFrom(json, field);\n\t\tout.push(...got);\n\t\tconst total = totalOf(json);\n\t\tif (\n\t\t\t!source.limit ||\n\t\t\ttotal === undefined ||\n\t\t\tout.length >= total ||\n\t\t\t!got.length\n\t\t)\n\t\t\tbreak;\n\t}\n\treturn out;\n}\n\n/**\n * Drop every cached collection read.\n *\n * @internal Test-only, for the same reason the spec cache has one: the cache is module state shared by every test file in one process.\n */\nexport function resetOptionCache(): void {\n\toptionCache.clear();\n}\n\n/** Folded for matching: lower case with the accents removed, so `cafe` finds `Café`. */\nconst fold = (s: string): string =>\n\ts.normalize('NFD').replace(/\\p{M}/gu, '').toLowerCase();\n\n/** What a picker reads from the element that owns it, at the moment it fetches. */\nexport interface PickerContext {\n\troute: ApiRoute;\n\tlang?: string;\n}\n\n/**\n * A search-as-you-type choice of one entry of a collection, the state behind a WAI-ARIA 1.2 combobox.\n *\n * @remarks\n * A collection with a search parameter is searched as the visitor types, debounced, with the stale request aborted; one without is read once and filtered in place, which also lets the list open on focus before anything is typed. Every request goes through {@link apiFetch}, so a refused key never leaves the page and a failure prints the API message under the box. The host draws it with {@link renderPicker}.\n */\nexport class OptionPicker implements ReactiveController {\n\tquery = '';\n\toptions: FieldOption[] = [];\n\topen = false;\n\thighlight = -1;\n\tloading = false;\n\terror: string | null = null;\n\tprivate abort?: AbortController;\n\tprivate readonly search = debounce((q: string) => {\n\t\tvoid this.searchServer(q);\n\t}, 250);\n\n\tconstructor(\n\t\tprivate readonly host: ReactiveControllerHost,\n\t\tprivate readonly source: OptionSource,\n\t\tprivate readonly field: string,\n\t\tprivate readonly context: () => PickerContext,\n\t\tprivate readonly onPick: (option: FieldOption) => void,\n\t) {\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.search.cancel();\n\t\tthis.abort?.abort();\n\t}\n\n\t/** Show the matches for what the visitor typed: a server search, or the read collection filtered. */\n\tinput(q: string): void {\n\t\tthis.query = q;\n\t\tthis.error = null;\n\t\tif (this.source.search) {\n\t\t\tif (q.trim().length < 2) this.close();\n\t\t\telse this.search(q);\n\t\t} else void this.filter(q);\n\t\tthis.host.requestUpdate();\n\t}\n\n\t/** Open the whole collection on focus when it is read in place, so a visitor can browse before typing. */\n\tfocus(): void {\n\t\tif (!this.source.search && !this.open) void this.filter(this.query);\n\t}\n\n\tclose(): void {\n\t\tthis.open = false;\n\t\tthis.highlight = -1;\n\t\tthis.host.requestUpdate();\n\t}\n\n\tpick(option: FieldOption): void {\n\t\tthis.query = option.label;\n\t\tthis.close();\n\t\tthis.onPick(option);\n\t}\n\n\tkeydown(e: KeyboardEvent): void {\n\t\tconst n = this.options.length;\n\t\tif (e.key === 'Escape') {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\t\tif (e.key === 'ArrowDown' && !this.open) {\n\t\t\te.preventDefault();\n\t\t\tthis.input(this.query);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.open || n === 0) return;\n\t\tif (e.key === 'ArrowDown') this.highlight = (this.highlight + 1) % n;\n\t\telse if (e.key === 'ArrowUp') this.highlight = (this.highlight - 1 + n) % n;\n\t\telse if (e.key === 'Home') this.highlight = 0;\n\t\telse if (e.key === 'End') this.highlight = n - 1;\n\t\telse if (e.key === 'Enter') {\n\t\t\tconst option = this.options[this.highlight] ?? this.options[0];\n\t\t\tif (option) this.pick(option);\n\t\t} else return;\n\t\te.preventDefault();\n\t\tthis.host.requestUpdate();\n\t}\n\n\tprivate async filter(q: string): Promise<void> {\n\t\tconst { route, lang } = this.context();\n\t\tthis.loading = true;\n\t\tthis.host.requestUpdate();\n\t\ttry {\n\t\t\tconst all = await readOptions(route, this.source, this.field, lang);\n\t\t\tif (q !== this.query) return;\n\t\t\tconst needle = fold(q.trim());\n\t\t\tthis.show(\n\t\t\t\tall.filter(\n\t\t\t\t\t(o) =>\n\t\t\t\t\t\tfold(o.label).includes(needle) || fold(o.value).includes(needle),\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tthis.fail(err);\n\t\t} finally {\n\t\t\tthis.loading = false;\n\t\t\tthis.host.requestUpdate();\n\t\t}\n\t}\n\n\tprivate async searchServer(q: string): Promise<void> {\n\t\tconst { route, lang } = this.context();\n\t\tconst search = this.source.search as string;\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.loading = true;\n\t\tthis.host.requestUpdate();\n\t\ttry {\n\t\t\tconst json = await apiFetch(\n\t\t\t\troute,\n\t\t\t\t{\n\t\t\t\t\tpath: this.source.path,\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\tquery: sourceQuery({ ...this.source, limit: SUGGESTIONS }, lang, {\n\t\t\t\t\t\t[search]: q,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tcontroller.signal,\n\t\t\t);\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.show(optionsFrom(json, this.field));\n\t\t} catch (err) {\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.fail(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) {\n\t\t\t\tthis.loading = false;\n\t\t\t\tthis.host.requestUpdate();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate show(options: FieldOption[]): void {\n\t\tthis.options = options;\n\t\tthis.open = true;\n\t\tthis.highlight = options.length ? 0 : -1;\n\t}\n\n\tprivate fail(err: unknown): void {\n\t\tthis.options = [];\n\t\tthis.open = false;\n\t\tthis.error = err instanceof Error ? err.message : String(err);\n\t}\n}\n\n/** The words a picker shows that its owner translates. */\nexport interface PickerText {\n\tplaceholder: string;\n\tempty: string;\n\tloading: string;\n}\n\n/**\n * Draw an {@link OptionPicker} as a WAI-ARIA 1.2 combobox: a text input owning a listbox, the active option announced through `aria-activedescendant`, and the API message under the box when a read fails.\n *\n * @param id - The input id; the listbox and options are named from it, so two pickers on one form never share an id.\n * @param labelledby - The id that names the box when no `<label for>` does.\n */\nexport function renderPicker(\n\tp: OptionPicker,\n\tid: string,\n\ttext: PickerText,\n\taria: { labelledby?: string; describedby?: string; invalid?: boolean } = {},\n): unknown {\n\tconst listbox = `${id}-listbox`;\n\treturn html`<div class=\"picker\"><input id=\"${id}\" type=\"text\" role=\"combobox\" aria-expanded=\"${p.open ? 'true' : 'false'}\" aria-controls=\"${listbox}\" aria-autocomplete=\"list\" aria-labelledby=\"${ifDefined(aria.labelledby)}\" aria-describedby=\"${ifDefined(aria.describedby)}\" aria-invalid=\"${ifDefined(aria.invalid ? 'true' : undefined)}\" aria-activedescendant=\"${p.open && p.highlight >= 0 ? `${id}-opt-${p.highlight}` : ''}\" autocomplete=\"off\" placeholder=\"${text.placeholder}\" .value=\"${p.query}\" @input=\"${(e: Event) => p.input((e.target as HTMLInputElement).value)}\" @keydown=\"${(e: KeyboardEvent) => p.keydown(e)}\" @focus=\"${() => p.focus()}\" @blur=\"${() => p.close()}\"> ${p.loading ? html`<span class=\"spinner\" role=\"status\" aria-label=\"${text.loading}\"></span>` : nothing} ${\n\t\t\t\tp.open\n\t\t\t\t\t? html`<ul id=\"${listbox}\" class=\"results\" role=\"listbox\">${\n\t\t\t\t\t\t\t\tp.options.length === 0\n\t\t\t\t\t\t\t\t\t? html`<li class=\"empty\" role=\"status\">${text.empty}</li>`\n\t\t\t\t\t\t\t\t\t: p.options.map(\n\t\t\t\t\t\t\t\t\t\t\t(o, i) => html`<li id=\"${`${id}-opt-${i}`}\" class=\"option\" role=\"option\" aria-selected=\"${p.highlight === i ? 'true' : 'false'}\" @mousedown=\"${(e: Event) => e.preventDefault()}\" @click=\"${() => p.pick(o)}\">${o.label}</li>`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}</ul>`\n\t\t\t\t\t: nothing\n\t\t\t}</div>${p.error ? html`<small class=\"field-error\" role=\"alert\">${p.error}</small>` : nothing}`;\n}\n\n/** The box that anchors its listbox; the listbox itself is {@link comboboxStyles}. */\nexport const pickerStyles = [\n\tcomboboxStyles,\n\tcss`.picker{position:relative}`,\n];\n", "// Generated by scripts/sync-version.ts. Do not edit.\nexport const ROXY_UI_VERSION = '0.52.0';\n", "import { css, html, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { EN_FIELD_LABELS } from '../generated/field-labels-en.js';\nimport { apiLang } from '../i18n/lang.js';\nimport { RoxyLocalizedElement } from '../i18n/localized-element.js';\nimport { signGlyph } from '../tokens/index.js';\nimport type { SearchCitiesResponse } from '../types/index.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { chevron, disclosureStyles } from '../utils/disclosure.js';\nimport {\n\ttype ApiIssue,\n\ttype ApiRoute,\n\tcanFetch,\n} from '../utils/fetch-controller.js';\nimport {\n\tbuildFormModel,\n\tderiveGroupLabel,\n\tderiveSubmitLabel,\n\ttype FieldDef,\n\ttype FieldOption,\n\ttype FormGroup,\n\ttype FormModel,\n\tisIndex,\n\tisZodiacEnum,\n\ttype OpenApiDoc,\n\ttype OperationSchema,\n\toptionKind,\n\tparseRepeatGroup,\n\ttype RepeatDef,\n\trepeatFields,\n\trepeatGroup,\n\tsliceFileName,\n\twithRenderIntent,\n} from '../utils/field-schema.js';\nimport { dispatchKeyRefusal, keyRefusal } from '../utils/key-guard.js';\nimport { displayField, displayOption } from '../utils/localized.js';\nimport {\n\tOptionPicker,\n\tpickerStyles,\n\treadOptions,\n\trenderPicker,\n} from '../utils/option-picker.js';\nimport { ROXY_UI_VERSION } from '../version.js';\n\n/** Production spec, fetched when no slice is available and no explicit `spec-url` is set. */\nconst PROD_SPEC_URL = 'https://roxyapi.com/api/v2/openapi.json';\n\n/** Version-pinned jsDelivr base for the digested per-operation schema slices, mirroring the wrapper CDN pinning so a slice matches the bundle it ships beside. */\nconst SLICE_BASE = `https://cdn.jsdelivr.net/npm/@roxyapi/ui@${ROXY_UI_VERSION}/dist/schemas`;\n\nconst specCache = new Map<string, Promise<OpenApiDoc>>();\n\n/**\n * A spec fetch that came back with a non-2xx status, carrying the STATUS rather than a sentence.\n *\n * @remarks\n * The visible wording is composed by the element, in the element's language, and never here: {@link loadSpec} shares one cached promise across every form on the page, so a message built at throw time would freeze the first mounter's language onto every later one. Same split as everywhere else in this library, the machine value travels and the display copy is made where the reader is.\n */\nclass SpecHttpError extends Error {\n\tconstructor(readonly status: number) {\n\t\tsuper(`HTTP ${status}`);\n\t}\n}\n\n/** The endpoint is absent from the document that was loaded. Carries the two parts the message names, for the reason {@link SpecHttpError} gives. */\nclass SpecMissingOperationError extends Error {\n\tconstructor(\n\t\treadonly method: string,\n\t\treadonly path: string,\n\t) {\n\t\tsuper(`Endpoint ${method} ${path} not found in OpenAPI spec`);\n\t}\n}\n\n/**\n * Drop every cached spec promise.\n\n * @remarks\n * Test-only, and deliberately NOT re-exported from the package entry. The cache is module state shared by every test file in a single `bun test` process, and it only self-evicts on rejection, so one file that resolves a spec leaves a warm entry that silently satisfies a later file assertion about fetching. That made slice-fallback coverage pass or fail purely on file order.\n\n * @internal\n */\nexport function resetSpecCache(): void {\n\tspecCache.clear();\n}\n\nasync function loadSpec(url: string): Promise<OpenApiDoc> {\n\tlet pending = specCache.get(url);\n\tif (!pending) {\n\t\tpending = fetch(url)\n\t\t\t.then(async (res) => {\n\t\t\t\tif (!res.ok) throw new SpecHttpError(res.status);\n\t\t\t\treturn (await res.json()) as OpenApiDoc;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// Evict the rejected promise BEFORE rethrowing so subsequent\n\t\t\t\t// callers (the user clicking Retry, a remount) hit the network\n\t\t\t\t// again instead of replaying the cached failure forever.\n\t\t\t\tspecCache.delete(url);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\tspecCache.set(url, pending);\n\t}\n\treturn pending;\n}\n\n/** A fresh seed for a hidden `seed` field, so each submit is a new draw unless the caller pinned one. */\nfunction randomSeed(): string {\n\treturn (\n\t\tglobalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2)\n\t);\n}\n\n/** True when the spec describes a place field as where someone was born, as opposed to where an observer or a reader stands. */\nconst isBirthPlace = (f?: FieldDef): boolean =>\n\t/\\bbirth/i.test(f?.description ?? '');\n\n/** True when a grouped field lives inside its group on the wire (`person1.date`), false when the group is only how the form shows it and the key is a flat property (`birthLatitude`). */\nconst isNested = (f: FieldDef): boolean => f.key === `${f.group}.${f.name}`;\n\n/** The city `<roxy-location-search>` reports on `roxy-location-select`. */\ntype PickedCity = SearchCitiesResponse['cities'][number];\n\n/** Parse an array-field text value into a real array: JSON when it parses to one, else comma-separated tokens. */\nfunction parseArrayValue(raw: string): unknown {\n\tconst trimmed = raw.trim();\n\tif (!trimmed) return [];\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t// Not JSON: fall through to comma splitting.\n\t}\n\treturn trimmed\n\t\t.split(',')\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean);\n}\n\n/**\n * Schema-driven form. Pass `endpoint` (e.g. \"vedic-astrology/birth-chart\"). The form digests the operation's request schema into a spec-derived input for each parameter (a zodiac tile grid, a date or time input, a city search, a toggle) with progressive disclosure, and emits a `roxy-submit` CustomEvent carrying the validated payload. The caller decides what to do (call the SDK, render a chart, navigate).\n *\n * @remarks\n * Schema resolution order: an explicit `spec-url` fetches that full spec and digests it (unchanged, the demo path); otherwise the form tries a small version-pinned per-operation slice from the CDN, and on any miss falls back to fetching the production spec. Each input kind is chosen purely from the parameter shape (see {@link ../utils/field-schema.ts}), so a new endpoint gets a working, on-brand form with no per-endpoint code.\n *\n * The visitor-facing `lang` parameter is never rendered: a site owner sets the element `lang` attribute, and the form routes it to the query string on submit. Optional parameters collapse under one Advanced disclosure behind the required ones; when nothing is required, every group and every undefaulted parameter renders in the open and only the defaulted ones collapse, so a request the schema can only describe as one of two optional shapes still shows its inputs. A form whose only required field is an enum submits on selection.\n *\n * **Two languages are in play here and they are different answers.** {@link RoxyLocalizedElement.effectiveLang} is the DISPLAY tag, region included, and it is what every `t()` call and the city search read. {@link RoxyEndpointForm.requestLang} is the WIRE value, region stripped and unsupported languages omitted, and it is what reaches `?lang=`. Swapping them is silent in both directions: the request one demotes every regional visitor, and the display one is a 400.\n *\n * **Field labels and option text ARE translated now, and they arrive over the network rather than from a catalogue.** They are keyed by the WIRE NAME the spec uses, not by the English text, because that English text is itself computed here by `humanize()`: there is no constant for a source-keyed catalogue to key on, which is why the chrome catalogue could never reach them. {@link RoxyEndpointForm.fieldText} and {@link RoxyEndpointForm.optionText} read a map baked into the per-language payload at build time and published through the same registry the chrome strings use. It rides the `locales/{lang}.js` download a translated page already makes, so it costs no extra request, needs no network at render time, and cannot flash English before correcting itself.\n *\n * **`humanize()` remains, as the fallback, and that is what makes this safe.** The payload is cosmetic and never awaited: a form draws immediately, an offline page or a blocked request renders exactly what it rendered before labels existed, and a language with no translation for a given key falls back to English server-side. There is no state in which a missing label breaks a form. Operation SUMMARIES and field DESCRIPTIONS are deliberately NOT in that map: a description is developer-facing reference prose, most of it collapsed behind a disclosure, and the widget already states the same contract language-neutrally through its input type and bounds. GROUP names stay catalogued rather than fetched, because the spec has nine of them: see {@link RoxyEndpointForm.groupName}.\n */\n@customElement('roxy-endpoint-form')\nexport class RoxyEndpointForm extends RoxyLocalizedElement {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tpickerStyles,\n\t\tcss`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);grid-template-columns:minmax(0,1fr);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.fields>*,.field>input,.field>select{min-width:0}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--_danger-fg);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.field-error{color:var(--_danger-fg);font-size:var(--roxy-text-xs,.75rem)}input[aria-invalid=true],select[aria-invalid=true]{border-color:var(--roxy-danger,#dc2626)}input:disabled,select:disabled{cursor:default;color:var(--roxy-muted,#71717a);border-style:dashed}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover:not(:disabled){border-color:var(--roxy-accent,#f59e0b)}.tile:disabled{cursor:default;color:var(--roxy-muted,#71717a);border-style:dashed}.tiles.narrow{gap:var(--roxy-space-xs,.25rem);grid-template-columns:repeat(auto-fill,minmax(2.25rem,1fr))}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.repeat-controls{gap:var(--roxy-space-sm,.5rem);display:flex}.repeat-btn{color:var(--roxy-accent-ink,#b45309);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font:inherit;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;background:0 0}.repeat-btn:hover{border-color:var(--roxy-accent-ink,#b45309)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);min-height:44px;color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`,\n\t];\n\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = 'vedic-astrology/birth-chart';\n\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Explicit OpenAPI spec URL. When set, the form fetches and digests that full spec (the demo path). When empty, it resolves a version-pinned slice first, then the production spec. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl = '';\n\n\t/** Override the submit-button label. Empty derives an outcome-first label from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel = '';\n\n\t/** Browser-safe publishable key, forwarded to the slotted city search so the natal or synastry form can geocode; a key the guard refuses replaces the inputs with the reason. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Where the slotted city search sends its request, absolute or relative to the page. Set it when the page routes its API traffic through its own server, so the one request this form issues on its own reaches that server too. Unset, the search keeps its own default. */\n\t@property({ type: String, attribute: 'location-url' })\n\tlocationUrl?: string;\n\n\t/** Prefill values, keyed by field name (nested per group). Used by `remember` mode and to restore the previous submission. JS property only. */\n\t@property({ attribute: false })\n\tinitialValues?: Record<string, unknown>;\n\n\t/**\n\t * The fields the API rejected on the last submit, by wire path, as the host's fetch reported them. JS property only.\n\t *\n\t * @remarks\n\t * The wire path is the same identity a field is keyed by (`year`, `person1.date`, `members.0.date`, `birthLatitude`), so each issue prints under the input it names and the input is marked invalid; an issue on a whole group (`members.0`) prints on that card, and one the form cannot place prints in the summary alone. Editing a field clears its issue, so a corrected value is not still marked wrong.\n\t */\n\t@property({ attribute: false })\n\tserverIssues: ApiIssue[] | null = null;\n\n\t/** Where the choices for a field are read through, handed in by a component in self-fetch mode so a proxied page reads them through its own route; a placed form reads them with its own publishable key. JS property only. */\n\t@property({ attribute: false })\n\tapiRoute?: ApiRoute;\n\n\t/** Submit once on load when the request needs nothing from the visitor, set by a component in self-fetch mode so a list or today's reading opens on its result. JS property only. */\n\t@property({ attribute: false })\n\tautoload = false;\n\n\t/** Ask a hidden `limit` for the largest page the API serves rather than its default, set by a list component that pages its own rows. JS property only. */\n\t@property({ attribute: false })\n\tfullPages = false;\n\n\t/** The choices read for each optional field the API lists values for, or the read in flight; absent when they could not be read, and the field keeps its plain input. */\n\t@state()\n\tprivate choices: Record<string, FieldOption[] | 'loading'> = {};\n\n\t/** One search-as-you-type picker per required free-string identifier, keyed by field. */\n\tprivate pickers = new Map<string, OptionPicker>();\n\n\t/** Issues the visitor has since edited away, by wire path. */\n\t@state()\n\tprivate clearedIssues = new Set<string>();\n\n\t@state()\n\tprivate fields: FieldDef[] = [];\n\n\tprivate groups: FormGroup[] = [];\n\tprivate modelOpensOnLoad = false;\n\n\t/** The array-of-object request properties, each a set of cards the visitor can grow up to `max` and shrink back to `min`. */\n\t@state()\n\tprivate repeats: RepeatDef[] = [];\n\n\t@state()\n\tprivate formTitle = '';\n\n\t@state()\n\tprivate hasLang = false;\n\n\t@state()\n\tprivate values: Record<string, unknown> = {};\n\n\t@state()\n\tprivate loaded = false;\n\n\t@state()\n\tprivate specError: string | null = null;\n\n\t@state()\n\tprivate validationErrors: string[] = [];\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tvoid this.loadSchema();\n\t}\n\n\tprivate async loadSchema() {\n\t\tthis.specError = null;\n\t\ttry {\n\t\t\tthis.applyModel(await this.resolveModel());\n\t\t} catch (err) {\n\t\t\t// The banner reads in the page language; the event keeps the canonical\n\t\t\t// English, because a listener is code and a developer console is not a\n\t\t\t// localized surface.\n\t\t\tthis.specError = this.specErrorMessage(err);\n\t\t\tthis.loaded = true;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-spec-error', {\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\turl: this.specUrl || PROD_SPEC_URL,\n\t\t\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t},\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** The failure sentence a visitor reads. Composed here rather than at the throw, so the shared spec-cache promise cannot freeze one form's language onto another. A message from anywhere else (a browser network error) is a wire fact and passes through untranslated. */\n\tprivate specErrorMessage(err: unknown): string {\n\t\tif (err instanceof SpecHttpError)\n\t\t\treturn this.t('HTTP error {{status}}', { status: err.status });\n\t\tif (err instanceof SpecMissingOperationError)\n\t\t\treturn this.t('Endpoint {{method}} {{path}} not found in OpenAPI spec', {\n\t\t\t\tmethod: err.method,\n\t\t\t\tpath: err.path,\n\t\t\t});\n\t\treturn err instanceof Error ? err.message : String(err);\n\t}\n\n\t/** Resolve the form model: explicit spec-url wins; else a version-pinned slice; else the production spec. */\n\tprivate async resolveModel(): Promise<FormModel> {\n\t\tif (this.specUrl) return this.modelFromSpec(this.specUrl);\n\t\tconst slice = await this.tryLoadSlice();\n\t\treturn slice ?? this.modelFromSpec(PROD_SPEC_URL);\n\t}\n\n\t/** Fetch and digest one operation from a full OpenAPI document. */\n\tprivate async modelFromSpec(url: string): Promise<FormModel> {\n\t\tconst spec = await loadSpec(url);\n\t\tconst path = `/${this.endpoint.replace(/^\\//, '')}`;\n\t\tconst op = spec.paths?.[path]?.[this.method.toLowerCase()] as\n\t\t\t| OperationSchema\n\t\t\t| undefined;\n\t\tif (!op) throw new SpecMissingOperationError(this.method, path);\n\t\treturn buildFormModel(\n\t\t\top,\n\t\t\tspec.components?.schemas ?? {},\n\t\t\tthis.endpoint,\n\t\t\tthis.method,\n\t\t);\n\t}\n\n\t/** Try the small precomputed slice; return null on any miss so the caller falls back to the full spec. */\n\tprivate async tryLoadSlice(): Promise<FormModel | null> {\n\t\ttry {\n\t\t\tconst res = await fetch(\n\t\t\t\t`${SLICE_BASE}/${sliceFileName(this.method, this.endpoint)}`,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\treturn (await res.json()) as FormModel;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate applyModel(model: FormModel) {\n\t\t// Older slices omit render intent; normalize through the same pure model builder.\n\t\tif (!model.groups || model.opensOnLoad === undefined)\n\t\t\tmodel = withRenderIntent(model, this.method, this.endpoint);\n\t\tthis.fields = model.fields;\n\t\tthis.groups = model.groups ?? [];\n\t\tthis.modelOpensOnLoad = model.opensOnLoad ?? false;\n\t\tthis.repeats = model.repeats ?? [];\n\t\tthis.formTitle = model.title;\n\t\tthis.hasLang = model.hasLang;\n\t\t// Pre-fill: schema defaults first, then any remembered/initial values (only\n\t\t// for fields this endpoint has) so a stale stored payload from another\n\t\t// endpoint cannot inject unknown keys. Remembered values are nested per\n\t\t// group, so read them by group.\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const f of model.fields) {\n\t\t\tconst seed =\n\t\t\t\tthis.fullPages &&\n\t\t\t\tf.name === 'limit' &&\n\t\t\t\tthis.roleOf(f) === 'hidden-default'\n\t\t\t\t\t? (f.max ?? f.default)\n\t\t\t\t\t: f.default;\n\t\t\tif (seed !== undefined) init[f.key] = seed;\n\t\t\tconst remembered =\n\t\t\t\tf.group && isNested(f)\n\t\t\t\t\t? (\n\t\t\t\t\t\t\tthis.initialValues?.[f.group] as\n\t\t\t\t\t\t\t\t| Record<string, unknown>\n\t\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t)?.[f.name]\n\t\t\t\t\t: this.initialValues?.[f.key];\n\t\t\tif (remembered !== undefined) init[f.key] = remembered;\n\t\t}\n\t\tthis.values = this.withoutDisabled(init);\n\t\tthis.loaded = true;\n\t\tthis.loadChoices();\n\t\tif (this.autoload && this.opensOnLoad && canFetch(this.route))\n\t\t\tvoid this.updateComplete.then(() => this.submit());\n\t}\n\n\t/** The route the choices are read through. */\n\tprivate get route(): ApiRoute {\n\t\treturn this.apiRoute ?? { publishableKey: this.publishableKey };\n\t}\n\n\t/** Read the choices of every sourced field when this form can reach the API: a picker for a required identifier, a list read once for an optional filter. */\n\tprivate loadChoices() {\n\t\tfor (const old of this.pickers.values()) this.removeController(old);\n\t\tthis.pickers.clear();\n\t\tif (!canFetch(this.route)) return;\n\t\tconst context = () => ({ route: this.route, lang: this.requestLang() });\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.source) continue;\n\t\t\tif (f.required) {\n\t\t\t\tconst picker = new OptionPicker(this, f.source, f.name, context, (o) =>\n\t\t\t\t\tthis.pickChoice(f, o.value),\n\t\t\t\t);\n\t\t\t\tpicker.query = String(this.values[f.key] ?? '');\n\t\t\t\tthis.pickers.set(f.key, picker);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.choices = { ...this.choices, [f.key]: 'loading' };\n\t\t\treadOptions(this.route, f.source, f.name, this.requestLang()).then(\n\t\t\t\t(options) => {\n\t\t\t\t\tthis.choices = { ...this.choices, [f.key]: options };\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tconst { [f.key]: _, ...rest } = this.choices;\n\t\t\t\t\tthis.choices = rest;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate retryLoadSchema = () => {\n\t\tthis.loaded = false;\n\t\tthis.specError = null;\n\t\tvoid this.loadSchema();\n\t};\n\n\tprivate setValue(name: string, value: unknown) {\n\t\tthis.setValues({ [name]: value });\n\t}\n\n\t/** Writes several values at once and clears the issue on each one the API named. */\n\tprivate setValues(patch: Record<string, unknown>) {\n\t\tthis.values = this.withoutDisabled({ ...this.values, ...patch });\n\t\tconst edited = Object.keys(patch).filter((k) =>\n\t\t\tthis.serverIssues?.some((i) => i.path === k),\n\t\t);\n\t\tif (edited.length)\n\t\t\tthis.clearedIssues = new Set([...this.clearedIssues, ...edited]);\n\t}\n\n\t/** True while another field holds the value this field waits on, so it takes no input and sends nothing. */\n\tprivate isDisabled(f: FieldDef, values = this.values): boolean {\n\t\tconst when = f.disabledWhen;\n\t\treturn !!when && values[when.field] === when.value;\n\t}\n\n\t/** The values with every disabled field dropped, so a choice made before it was disabled is never sent. */\n\tprivate withoutDisabled(values: Record<string, unknown>) {\n\t\tfor (const f of this.fields)\n\t\t\tif (this.isDisabled(f, values)) values[f.key] = undefined;\n\t\treturn values;\n\t}\n\n\t/** The live issues: what the API reported, less what has been edited since. A new report resets the edits. */\n\tprotected willUpdate(changed: Map<PropertyKey, unknown>): void {\n\t\tif (changed.has('serverIssues')) this.clearedIssues = new Set();\n\t\tconst refusal = changed.has('publishableKey')\n\t\t\t? keyRefusal(this.publishableKey)\n\t\t\t: undefined;\n\t\tif (refusal) dispatchKeyRefusal(this, refusal, { warn: true });\n\t}\n\n\tprivate liveIssues(): ApiIssue[] {\n\t\treturn (this.serverIssues ?? []).filter(\n\t\t\t(i) => !this.clearedIssues.has(i.path),\n\t\t);\n\t}\n\n\t/** The issue on exactly this field, if the API named it. */\n\tprivate issueFor(f: FieldDef): ApiIssue | undefined {\n\t\treturn this.liveIssues().find((i) => i.path === f.key);\n\t}\n\n\t/** The issues on the coordinates and timezone a group's city box writes, which have no input of their own to sit under. */\n\tprivate cityIssues(group?: string): ApiIssue[] {\n\t\treturn this.liveIssues().filter((i) => {\n\t\t\tconst f = this.fields.find((x) => x.key === i.path);\n\t\t\treturn (\n\t\t\t\t!!f && this.roleOf(f) === 'location' && this.cityGroup(f) === group\n\t\t\t);\n\t\t});\n\t}\n\n\t/** The issues on a whole group card (`members.0`), as opposed to one of its fields. */\n\tprivate issuesForGroup(group: string): ApiIssue[] {\n\t\treturn this.liveIssues().filter((i) => i.path === group);\n\t}\n\n\t/**\n\t * A field named the way its input is labelled on the form, for a message that sends the visitor back to it.\n\t *\n\t * @remarks\n\t * The group half translates and the field half cannot, which is not a half-measure: this names a block the visitor has to go back to, so the word in the message has to be the word printed on the fieldset legend. A message saying `Person 1` over a legend reading `Persona 1` points at nothing.\n\t */\n\tprivate fieldLabel(f: FieldDef): string {\n\t\tif (this.roleOf(f) === 'location' || f.city)\n\t\t\treturn this.locationLabel(this.cityGroup(f));\n\t\treturn f.group\n\t\t\t? `${this.groupName(f.group)} ${this.fieldText(f.name, f.label)}`\n\t\t\t: this.fieldText(f.name, f.label);\n\t}\n\n\t/** The issues the API reported on a whole card or a city box, printed under it. */\n\tprivate issueLines(issues: ApiIssue[]) {\n\t\treturn issues.map(\n\t\t\t(i) =>\n\t\t\t\thtml`<small part=\"field-error\" class=\"field-error\" role=\"alert\">${i.message}</small>`,\n\t\t);\n\t}\n\n\t/** The inline message under an input, and the attributes that tie it to the input for assistive tech. */\n\tprivate fieldIssue(f: FieldDef) {\n\t\tconst issue = this.issueFor(f);\n\t\treturn issue\n\t\t\t? html`<small part=\"field-error\" class=\"field-error\" id=\"${`roxy-form-${f.key}-error`}\" role=\"alert\">${issue.message}</small>`\n\t\t\t: nothing;\n\t}\n\n\t/**\n\t * The summary of what the API rejected: one line per issue, the field named by\n\t * its label on the form rather than by its wire path, so the reader is sent to\n\t * the input they can see. The message is the API's own and prints as sent.\n\t */\n\tprivate renderIssueSummary() {\n\t\tconst issues = this.liveIssues();\n\t\tif (issues.length === 0) return nothing;\n\t\tconst labelFor = (path: string): string => {\n\t\t\tconst field = this.fields.find((f) => f.key === path);\n\t\t\tif (field) return this.fieldLabel(field);\n\t\t\tconst group = this.groupKeys().find((g) => g === path);\n\t\t\tif (group) return this.groupName(group);\n\t\t\treturn this.fieldText(path.split('.')[0] ?? path);\n\t\t};\n\t\treturn html`<div part=\"validation-error\" class=\"validation-error\" role=\"alert\">${issues.map(\n\t\t\t\t(i) =>\n\t\t\t\t\thtml`<div><strong>${labelFor(i.path)}</strong> ${i.message}</div>`,\n\t\t\t)}</div>`;\n\t}\n\n\t/** The field's render role: a hidden autogenerated seed, a hidden defaulted limit/offset, a suppressed location coordinate, or a normally rendered input. */\n\tprivate roleOf(\n\t\tf: FieldDef,\n\t): 'seed' | 'hidden-default' | 'location' | 'normal' {\n\t\treturn f.role ?? 'normal';\n\t}\n\n\t/** True when the model assigns the field its own input. */\n\tprivate isRendered(f: FieldDef): boolean {\n\t\treturn this.roleOf(f) === 'normal';\n\t}\n\n\t/** Groups in the model's render order, including the flat top level. */\n\tprivate groupKeys(): (string | undefined)[] {\n\t\treturn this.groups.map((g) => g.key);\n\t}\n\n\t/** The city box assigned to this group by the model. */\n\tprivate groupHasLocation(group?: string): boolean {\n\t\treturn !!this.groups.find((g) => g.key === group)?.location;\n\t}\n\n\t/** The group whose city box fills this field, including a claimed flat timezone. */\n\tprivate cityGroup(f: FieldDef): string | undefined {\n\t\treturn (\n\t\t\tthis.groups.find((g) => g.location?.fields.includes(f.key))?.key ??\n\t\t\tf.group\n\t\t);\n\t}\n\n\t/** The field whose spec description says what place a group's city box asks for: its latitude, or a timezone standing alone. */\n\tprivate placeField(group?: string): FieldDef | undefined {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn (\n\t\t\tinGroup.find((f) => f.name === 'latitude') ??\n\t\t\tinGroup.find((f) => f.name === 'timezone')\n\t\t);\n\t}\n\n\t/** Whether the model marks this city box required. */\n\tprivate locationRequired(group?: string): boolean {\n\t\treturn (\n\t\t\tthis.groups.find((g) => g.key === group)?.location?.required ?? false\n\t\t);\n\t}\n\n\t/**\n\t * The single visible required choice, when the whole form reduces to exactly one: no location block, no named group, one required rendered enum or picker. This is what turns the horoscope form into a tap-to-load sign grid and the dream card into type, pick, read; returns null otherwise.\n\t */\n\tprivate get soleChoice(): FieldDef | null {\n\t\tif (this.groupKeys().some((g) => this.groupHasLocation(g))) return null;\n\t\tif (this.groupKeys().some((g) => g !== undefined)) return null;\n\t\tconst req = this.fields.filter((f) => f.required && this.isRendered(f));\n\t\tconst only = req[0];\n\t\tif (req.length !== 1 || !only) return null;\n\t\treturn only.kind === 'tiles' ||\n\t\t\tonly.kind === 'select' ||\n\t\t\tthis.pickers.has(only.key)\n\t\t\t? only\n\t\t\t: null;\n\t}\n\n\t/** True when this form opens on its result, so it stays above the result as a filter bar. */\n\tprivate get opensOnLoad(): boolean {\n\t\treturn this.modelOpensOnLoad;\n\t}\n\n\t/** True for an optional filter on a form that opens on load: a listed choice that submits when picked and clears the other filters. */\n\tprivate isFilter(f: FieldDef): boolean {\n\t\treturn this.opensOnLoad && !f.required && !!(f.enum || f.source);\n\t}\n\n\t/** True when every input on the form sends it by itself (a sole choice, or a filter bar with nothing typed), so it draws no submit button. */\n\tprivate get selfSubmits(): boolean {\n\t\tif (this.soleChoice) return true;\n\t\tif (!this.opensOnLoad) return false;\n\t\tconst shown = this.fields.filter((f) => this.isRendered(f));\n\t\treturn shown.length > 0 && shown.every((f) => this.isFilter(f));\n\t}\n\n\t/** Tiles or a select for a choice field: by the shape of its choices, except that a filter of words is a select, so a list that opens on load keeps its filters to one compact row and only an index (letters, short codes) stays a tile bar. */\n\tprivate choiceKind(f: FieldDef): 'tiles' | 'select' {\n\t\tconst values = this.choicesOf(f).map((o) => o.value);\n\t\tif (this.isFilter(f) && !isIndex(values)) return 'select';\n\t\t// A list the API served is classed here; an enum keeps the kind its schema gave it.\n\t\treturn this.choices[f.key]\n\t\t\t? optionKind(values)\n\t\t\t: (f.kind as 'tiles' | 'select');\n\t}\n\n\t/** The choices a field offers: its enum with the published option text, or the list the API served for it. */\n\tprivate choicesOf(f: FieldDef): FieldOption[] {\n\t\tconst listed = this.choices[f.key];\n\t\tif (Array.isArray(listed)) return listed;\n\t\treturn (f.enum ?? []).map((value) => ({\n\t\t\tvalue,\n\t\t\tlabel: this.optionText(f.name, value),\n\t\t}));\n\t}\n\n\t/** The submit-button label. A caller-supplied one is theirs and is printed verbatim; the derived verb is ours, so it goes through the catalogue. {@link deriveSubmitLabel} returns the canonical English verb, which IS the catalogue key. */\n\tprivate effectiveSubmitLabel(): string {\n\t\treturn (\n\t\t\tthis.submitLabel || this.t(deriveSubmitLabel(this.endpoint, this.fields))\n\t\t);\n\t}\n\n\t/**\n\t * The value this form may put on `?lang=`, or undefined to leave the request on the API default.\n\t *\n\t * @remarks\n\t * NOT the display language, and the name says so: `effectiveLang()` on the base class is the full display tag every `t()` reads. `?lang=es-AR` is a 400 and `?lang=es` is a 200, and the language resolves from `<html lang>` rather than only from an attribute a developer typed, so the unfiltered tag reaching the query string would break every regional and every untranslated locale. {@link apiLang} does both narrowings; this method exists so the submit path reads as one call.\n\t */\n\tprivate requestLang(): string | undefined {\n\t\treturn apiLang(this);\n\t}\n\n\t/**\n\t * The words this form writes over a request field, and the options under it.\n\t *\n\t * @remarks\n\t * `humanize()` is the FALLBACK, not the default, and it stays because it has to: the labels\n\t * arrive over the network and a form must draw before they land, on an offline page, and when\n\t * the request fails. So the worst case is exactly what this form rendered before labels\n\t * existed, and the best case is a translated one, with no state in between where it breaks.\n\t *\n\t * Keyed by WIRE NAME rather than by the English text, because the English text is itself\n\t * computed here by `humanize()`; there is no constant to key on. Same reason the label map is\n\t * a separate key space from the chrome catalogue.\n\t *\n\t * English ships no payload, so the API English label is compiled in and comes before `humanize()`.\n\t * Contextual model labels stay in English; translated picker/context labels are server artifacts.\n\t */\n\tprivate fieldText(name: string, label?: string): string {\n\t\tif (label) return label;\n\t\treturn displayField(this.requestLang(), name, EN_FIELD_LABELS[name]);\n\t}\n\n\t/** The option text under one field, falling back the same way. */\n\tprivate optionText(field: string, value: string): string {\n\t\treturn displayOption(this.requestLang(), field, value);\n\t}\n\n\t/**\n\t * Location-select handler bound to a group: fills that group's coordinate keys plus whichever\n\t * timezone field it owns.\n\t *\n\t * Keys are LOOKED UP from the model rather than built as `group.name`. That assumption held only\n\t * while every group came from object nesting; a prefixed group stores under the original wire\n\t * name (`birthLatitude`), so constructing `birth.latitude` would write a key the request builder\n\t * never reads and the coordinates would silently stay empty.\n\t */\n\tprivate onLocationFor(group?: string) {\n\t\treturn (city: PickedCity) => {\n\t\t\tconst keys =\n\t\t\t\tthis.groups.find((g) => g.key === group)?.location?.fields ?? [];\n\t\t\tconst patch: Record<string, unknown> = {};\n\t\t\tfor (const key of keys) {\n\t\t\t\tconst name = this.fields.find((f) => f.key === key)?.name;\n\t\t\t\tif (name) patch[key] = city[name as keyof PickedCity];\n\t\t\t}\n\t\t\tthis.setValues(patch);\n\t\t};\n\t}\n\n\t/** Records a chosen option, and submits at once when it is the only input the form has or a filter; picking the chosen filter again clears it. */\n\tprivate chooseOption(f: FieldDef, value: string) {\n\t\tif (this.isFilter(f)) {\n\t\t\tthis.setFilter(f, this.values[f.key] === value ? '' : value);\n\t\t\tthis.submit();\n\t\t\treturn;\n\t\t}\n\t\tthis.pickChoice(f, value);\n\t}\n\n\t/** Records a choice and submits when the form reduces to it. */\n\tprivate pickChoice(f: FieldDef, value: string) {\n\t\tthis.setValue(f.key, value);\n\t\tif (value && this.soleChoice?.key === f.key) this.submit();\n\t}\n\n\t/** Sets one filter and clears the others and the text search, so a list is narrowed one way at a time. */\n\tprivate setFilter(f: FieldDef, value: unknown) {\n\t\tconst patch: Record<string, unknown> = { [f.key]: value };\n\t\tfor (const other of this.fields)\n\t\t\tif (\n\t\t\t\tother !== f &&\n\t\t\t\t(this.isFilter(other) ||\n\t\t\t\t\t(this.opensOnLoad && other.kind === 'text' && this.isRendered(other)))\n\t\t\t)\n\t\t\t\tpatch[other.key] = undefined;\n\t\tthis.setValues(patch);\n\t}\n\n\t/** Roving-tabindex arrow-key navigation for a tile radiogroup, modeled on the shared tablist pattern (selection follows focus). */\n\tprivate onTilesKeyDown(f: FieldDef) {\n\t\treturn (e: KeyboardEvent) => {\n\t\t\tconst opts = this.choicesOf(f)\n\t\t\t\t.filter((o) => !o.disabled)\n\t\t\t\t.map((o) => o.value);\n\t\t\tif (opts.length === 0) return;\n\t\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\t\tlet next: number;\n\t\t\tif (e.key === 'Home') next = 0;\n\t\t\telse if (e.key === 'End') next = opts.length - 1;\n\t\t\telse if (e.key === 'ArrowRight' || e.key === 'ArrowDown')\n\t\t\t\tnext = cur === -1 ? 0 : (cur + 1) % opts.length;\n\t\t\telse if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')\n\t\t\t\tnext =\n\t\t\t\t\tcur === -1 ? opts.length - 1 : (cur - 1 + opts.length) % opts.length;\n\t\t\telse return;\n\t\t\te.preventDefault();\n\t\t\tconst value = opts[next];\n\t\t\tif (value === undefined) return;\n\t\t\tthis.chooseOption(f, value);\n\t\t\tconst root = e.currentTarget as HTMLElement;\n\t\t\tconst tile = this.choicesOf(f).findIndex((o) => o.value === value);\n\t\t\trequestAnimationFrame(() =>\n\t\t\t\troot.querySelector<HTMLButtonElement>(`[data-tile='${tile}']`)?.focus(),\n\t\t\t);\n\t\t};\n\t}\n\n\tprivate onSubmit = (e: Event) => {\n\t\te.preventDefault();\n\t\tthis.submit();\n\t};\n\n\t/** Validate, then emit `roxy-submit` with the reconstructed payload, the spec query keys, and whether the form stays above its result. */\n\tprivate submit() {\n\t\tconst missing = this.collectMissing();\n\t\tif (missing.keys.length > 0) {\n\t\t\tthis.validationErrors = missing.labels;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\t\t\tdetail: { missing: missing.keys },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.validationErrors = [];\n\t\tthis.clearedIssues = new Set((this.serverIssues ?? []).map((i) => i.path));\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const f of this.fields) {\n\t\t\tlet v = this.values[f.key];\n\t\t\t// A hidden seed autogenerates per submit unless a value was remembered.\n\t\t\tif (f.name === 'seed' && (v === undefined || v === '')) v = randomSeed();\n\t\t\tif (v === undefined || v === '') continue;\n\t\t\tif (f.kind === 'array' && typeof v === 'string') v = parseArrayValue(v);\n\t\t\tconst repeat = f.group ? parseRepeatGroup(f.group) : null;\n\t\t\tif (repeat) {\n\t\t\t\t// A repeating group serialises as one object per record, in record order.\n\t\t\t\tconst list =\n\t\t\t\t\t(out[repeat.key] as Record<string, unknown>[] | undefined) ?? [];\n\t\t\t\tconst g = list[repeat.index] ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tlist[repeat.index] = g;\n\t\t\t\tout[repeat.key] = list;\n\t\t\t} else if (f.group && isNested(f)) {\n\t\t\t\tconst g = (out[f.group] as Record<string, unknown> | undefined) ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tout[f.group] = g;\n\t\t\t} else {\n\t\t\t\t// The key is the wire identity: a prefixed coordinate (`birthLatitude`) is\n\t\t\t\t// grouped for the form and flat on the wire.\n\t\t\t\tout[f.key] = v;\n\t\t\t}\n\t\t}\n\t\t// The spec knows which parameters belong in the query string; the listener\n\t\t// does not. Report them (including a site-owner lang) so a POST with a query\n\t\t// parameter reaches the API correctly instead of being dropped in the body.\n\t\tconst queryKeys = this.fields.filter((f) => f.inQuery).map((f) => f.name);\n\t\tconst lang = this.requestLang();\n\t\tif (this.hasLang && lang) {\n\t\t\tout.lang = lang;\n\t\t\tqueryKeys.push('lang');\n\t\t}\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('roxy-submit', {\n\t\t\t\tdetail: {\n\t\t\t\t\tendpoint: this.endpoint,\n\t\t\t\t\tvalues: out,\n\t\t\t\t\tqueryKeys,\n\t\t\t\t\tsticky: this.soleChoice != null || this.opensOnLoad,\n\t\t\t\t},\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Required fields left empty, with the location trio collapsed to one entry per group. Seed and hidden defaults never block. */\n\tprivate collectMissing(): { keys: string[]; labels: string[] } {\n\t\tconst keys: string[] = [];\n\t\tconst labels: string[] = [];\n\t\tconst locGroups = new Set<string | undefined>();\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.required) continue;\n\t\t\tconst isLocation = this.roleOf(f) === 'location';\n\t\t\tif (!this.isRendered(f) && !isLocation) continue;\n\t\t\tconst v = this.values[f.key];\n\t\t\tif (v !== undefined && v !== '') continue;\n\t\t\tkeys.push(f.key);\n\t\t\tif (isLocation) {\n\t\t\t\tlocGroups.add(this.cityGroup(f));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlabels.push(this.fieldLabel(f));\n\t\t}\n\t\tfor (const g of locGroups) {\n\t\t\tlabels.push(this.locationLabel(g));\n\t\t}\n\t\treturn { keys, labels };\n\t}\n\n\tprivate reqMark(f: FieldDef) {\n\t\treturn f.required\n\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t: nothing;\n\t}\n\n\t/**\n\t * A description under a field: rendered inline when short, collapsed behind a disclosure showing its first line when long.\n\t *\n\t * @remarks\n\t * Both shapes carry `part=\"hint\"` on their outermost element, so one `::part(hint)` rule reaches every field description on the form. The words are the API reference text for the request field, which is the right register on a developer page and the wrong one on a page written for a client, and hiding them leaves the label, the input and its validation untouched.\n\t */\n\tprivate description(f: FieldDef) {\n\t\tif (!f.description) return nothing;\n\t\tif (f.description.length <= 120) {\n\t\t\treturn html`<small part=\"hint\" class=\"help\">${f.description}</small>`;\n\t\t}\n\t\tconst lead = f.description.split('. ')[0] ?? f.description;\n\t\treturn html`<details part=\"hint\" class=\"help-details\"><summary><span class=\"help-lead\">${lead}</span>${chevron()}</summary><small class=\"help help-full\">${f.description}</small></details>`;\n\t}\n\n\tprivate renderTiles(f: FieldDef) {\n\t\tconst labelId = `roxy-form-${f.key}-label`;\n\t\tconst zodiac = !!f.enum && isZodiacEnum(f.enum);\n\t\tconst opts = this.choicesOf(f);\n\t\tconst narrow = isIndex(opts.map((o) => o.value));\n\t\tconst cur = opts.findIndex((o) => o.value === this.values[f.key]);\n\t\tconst active = cur === -1 ? opts.findIndex((o) => !o.disabled) : cur;\n\t\treturn html`<div class=\"field tiles-field\"><span class=\"label\" id=\"${labelId}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</span><div class=\"${narrow ? 'tiles narrow' : 'tiles'}\" role=\"radiogroup\" aria-labelledby=\"${labelId}\" @keydown=\"${this.onTilesKeyDown(f)}\">${opts.map((opt, i) => {\n\t\t\t\t\tconst selected = this.values[f.key] === opt.value;\n\t\t\t\t\tconst glyph = zodiac ? signGlyph(opt.value) : undefined;\n\t\t\t\t\treturn html`<button type=\"button\" class=\"tile\" role=\"radio\" data-tile=\"${i}\" aria-checked=\"${selected ? 'true' : 'false'}\" tabindex=\"${i === active ? '0' : '-1'}\" ?disabled=\"${!!opt.disabled || this.isDisabled(f)}\" @click=\"${() => this.chooseOption(f, opt.value)}\">${\n\t\t\t\t\t\t\tglyph\n\t\t\t\t\t\t\t\t? html`<span class=\"tile-glyph\" aria-hidden=\"true\">${glyph}</span>`\n\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t} <span class=\"tile-label\">${opt.label}</span></button>`;\n\t\t\t\t})}</div>${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderSelect(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\treturn html`<div part=\"field\" class=\"field\"><label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label> <select id=\"${id}\" ?required=\"${f.required}\" ?disabled=\"${this.isDisabled(f)}\" aria-invalid=\"${ifDefined(this.issueFor(f) ? 'true' : undefined)}\" aria-describedby=\"${ifDefined(this.issueFor(f) ? `${id}-error` : undefined)}\" .value=\"${live((this.values[f.key] ?? '') as string)}\" @change=\"${(e: Event) =>\n\t\t\t\t\tthis.chooseOption(f, (e.target as HTMLSelectElement).value)}\"><option value=\"\">${this.t('Choose')}</option>${this.choicesOf(f).map(\n\t\t\t\t\t(\n\t\t\t\t\t\topt,\n\t\t\t\t\t) => html`<option value=\"${opt.value}\" ?selected=\"${this.values[f.key] === opt.value}\" ?disabled=\"${!!opt.disabled}\">${opt.label}</option>`,\n\t\t\t\t)}</select> ${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\t/** A required identifier picked from its collection as the visitor types; the sole input on its form is named by the form title. */\n\tprivate renderPickerField(f: FieldDef, picker: OptionPicker) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst sole = this.soleChoice?.key === f.key;\n\t\tconst issue = this.issueFor(f);\n\t\treturn html`<div part=\"field\" class=\"field\">${sole ? nothing : html`<label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label>`} ${renderPicker(\n\t\t\t\tpicker,\n\t\t\t\tid,\n\t\t\t\t{\n\t\t\t\t\tplaceholder: this.t('Type to search'),\n\t\t\t\t\tempty: this.t('{{count}} matches', { count: 0 }),\n\t\t\t\t\tloading: this.t('Loading'),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabelledby: sole ? 'roxy-form-title' : undefined,\n\t\t\t\t\tdescribedby: issue ? `${id}-error` : undefined,\n\t\t\t\t\tinvalid: !!issue,\n\t\t\t\t},\n\t\t\t)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderToggle(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst checked = this.values[f.key] === true;\n\t\treturn html`<div part=\"field\" class=\"field\"><div class=\"toggle-row\"><button type=\"button\" id=\"${id}\" class=\"toggle\" role=\"switch\" aria-checked=\"${checked ? 'true' : 'false'}\" @click=\"${() => this.setValue(f.key, !checked)}\"><span class=\"knob\"></span></button> <label class=\"toggle-label\" for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label></div>${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderInput(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst type =\n\t\t\tf.kind === 'datetime'\n\t\t\t\t? 'datetime-local'\n\t\t\t\t: f.kind === 'number'\n\t\t\t\t\t? 'number'\n\t\t\t\t\t: f.kind;\n\t\tconst placeholder =\n\t\t\tf.kind === 'array'\n\t\t\t\t? this.t('Comma separated')\n\t\t\t\t: f.example != null\n\t\t\t\t\t? String(f.example)\n\t\t\t\t\t: '';\n\t\treturn html`<div part=\"field\" class=\"field\"><label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label> <input id=\"${id}\" type=\"${f.kind === 'array' ? 'text' : type}\" ?required=\"${f.required}\" ?disabled=\"${this.isDisabled(f)}\" aria-invalid=\"${ifDefined(this.issueFor(f) ? 'true' : undefined)}\" aria-describedby=\"${ifDefined(this.issueFor(f) ? `${id}-error` : undefined)}\" min=\"${ifDefined(f.min)}\" max=\"${ifDefined(f.max)}\" step=\"${f.kind === 'number' ? 'any' : nothing}\" placeholder=\"${placeholder || nothing}\" .value=\"${(this.values[f.key] ?? '') as string}\" @input=\"${(e: Event) => {\n\t\t\t\t\tconst v = this.coerce(f.kind, (e.target as HTMLInputElement).value);\n\t\t\t\t\tif (this.opensOnLoad && f.kind === 'text') this.setFilter(f, v);\n\t\t\t\t\telse this.setValue(f.key, v);\n\t\t\t\t}}\"> ${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderField(f: FieldDef) {\n\t\t// Only a timezone no coordinate pair claims reaches here; a claimed one is the location block's.\n\t\tif (f.city) return this.renderTimezoneCity(f);\n\t\tconst picker = this.pickers.get(f.key);\n\t\tif (picker) return this.renderPickerField(f, picker);\n\t\tconst listed = this.choices[f.key];\n\t\tif (listed === 'loading')\n\t\t\treturn html`<div class=\"field\"><div class=\"roxy-skeleton\" style=\"height:2.75rem\" aria-label=\"${this.t('Loading')}\" role=\"status\"></div></div>`;\n\t\tif (listed || f.kind === 'tiles' || f.kind === 'select')\n\t\t\treturn this.choiceKind(f) === 'tiles'\n\t\t\t\t? this.renderTiles(f)\n\t\t\t\t: this.renderSelect(f);\n\t\tswitch (f.kind) {\n\t\t\tcase 'toggle':\n\t\t\t\treturn this.renderToggle(f);\n\t\t\tdefault:\n\t\t\t\treturn this.renderInput(f);\n\t\t}\n\t}\n\n\t/** The shared group legend, using this form's chrome and field-label catalogues. */\n\tprivate groupName(group: string): string {\n\t\treturn deriveGroupLabel(\n\t\t\tgroup,\n\t\t\t(source, vars) => this.t(source, vars),\n\t\t\t(name) => this.fieldText(name),\n\t\t);\n\t}\n\n\t/** How many records a repeating property currently shows. */\n\tprivate repeatCount(key: string): number {\n\t\treturn new Set(\n\t\t\tthis.fields\n\t\t\t\t.map((f) => f.group && parseRepeatGroup(f.group))\n\t\t\t\t.filter((r) => r && r.key === key)\n\t\t\t\t.map((r) => (r as { index: number }).index),\n\t\t).size;\n\t}\n\n\t/** Appends a record with the same fields as the first, pre-filled with the schema defaults the first record was. */\n\tprivate addRecord(key: string) {\n\t\tconst index = this.repeatCount(key);\n\t\tconst added = repeatFields(this.fields, key, index);\n\t\tconst template = this.groups.find((g) => g.key === repeatGroup(key, 0));\n\t\tif (template) {\n\t\t\tconst rekey = (k: string) =>\n\t\t\t\tk.replace(`${repeatGroup(key, 0)}.`, `${repeatGroup(key, index)}.`);\n\t\t\tthis.groups = [\n\t\t\t\t...this.groups,\n\t\t\t\t{\n\t\t\t\t\t...template,\n\t\t\t\t\tkey: repeatGroup(key, index),\n\t\t\t\t\tlabel: deriveGroupLabel(repeatGroup(key, index)),\n\t\t\t\t\t...(template.location && {\n\t\t\t\t\t\tlocation: {\n\t\t\t\t\t\t\t...template.location,\n\t\t\t\t\t\t\tfields: template.location.fields.map(rekey),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tconst next = { ...this.values };\n\t\tfor (const f of added) if (f.default !== undefined) next[f.key] = f.default;\n\t\tthis.values = next;\n\t\tthis.fields = [...this.fields, ...added];\n\t}\n\n\t/** Drops the last record and every value it held, so a removed card cannot ride along in the body. */\n\tprivate removeRecord(key: string) {\n\t\tconst group = repeatGroup(key, this.repeatCount(key) - 1);\n\t\tthis.fields = this.fields.filter((f) => f.group !== group);\n\t\tthis.groups = this.groups.filter((g) => g.key !== group);\n\t\tconst next = { ...this.values };\n\t\tfor (const k of Object.keys(next))\n\t\t\tif (k.startsWith(`${group}.`)) delete next[k];\n\t\tthis.values = next;\n\t}\n\n\t/** The add and remove controls under the records of one repeating property, each only where the spec leaves room for it. */\n\tprivate repeatControls(repeat: RepeatDef) {\n\t\tconst count = this.repeatCount(repeat.key);\n\t\tif (repeat.max <= repeat.min) return nothing;\n\t\treturn html`<div class=\"repeat-controls\">${\n\t\t\t\tcount < repeat.max\n\t\t\t\t\t? html`<button type=\"button\" class=\"repeat-btn\" @click=\"${() => this.addRecord(repeat.key)}\"><span aria-hidden=\"true\">+</span> ${this.t('Add')}</button>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tcount > repeat.min\n\t\t\t\t\t? html`<button type=\"button\" class=\"repeat-btn\" @click=\"${() => this.removeRecord(repeat.key)}\"><span aria-hidden=\"true\">−</span> ${this.t('Remove')}</button>`\n\t\t\t\t\t: nothing\n\t\t\t}</div>`;\n\t}\n\n\t/**\n\t * The name of one location block, and of the same block in a validation message, which is why it is a method rather than two literals.\n\t *\n\t * The placeholder carries the group rather than the form concatenating a name in front of a translated noun, so a translator owns the word order: `Person 1 location` is English syntax, and Turkish suffixes the head noun, Hindi takes a genitive, Russian a parenthetical and German a colon. The four shapes are deliberately different and normalizing them breaks three languages.\n\t */\n\tprivate locationLabel(group?: string): string {\n\t\tif (group)\n\t\t\treturn this.t('{{group}} location', { group: this.groupName(group) });\n\t\treturn isBirthPlace(this.placeField(group))\n\t\t\t? this.t('Birth location')\n\t\t\t: this.t('Location');\n\t}\n\n\t/** One city search standing in for a group's raw coordinates. */\n\tprivate locationBlock(group?: string) {\n\t\treturn html`<div class=\"location-block\"><label>${this.locationLabel(group)}${\n\t\t\t\t\tthis.locationRequired(group)\n\t\t\t\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t}</label> ${this.citySearch(group, this.onLocationFor(group))} ${this.issueLines(this.cityIssues(group))}</div>`;\n\t}\n\n\t/** A `timezone` no coordinate pair claims, asked for as a city and labelled as the place: the IANA zone it writes resolves to the offset in force on the requested date. */\n\tprivate renderTimezoneCity(f: FieldDef) {\n\t\treturn html`<div part=\"field\" class=\"field location-block\"><label>${this.locationLabel(f.group)}${this.reqMark(f)}</label> ${this.citySearch(f.group, (city) => this.setValue(f.key, city.timezone))} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\t/** The one city search every location input draws, its placeholder named for the place; `lang` and `endpoint` are forwarded because a shadow root hides the host page from it. */\n\tprivate citySearch(\n\t\tgroup: string | undefined,\n\t\tonPick: (city: PickedCity) => void,\n\t) {\n\t\tconst placeholder = group\n\t\t\t? this.t('{{group}} city', { group: this.groupName(group) })\n\t\t\t: isBirthPlace(this.placeField(group))\n\t\t\t\t? this.t('City of birth')\n\t\t\t\t: undefined;\n\t\treturn html`<roxy-location-search endpoint=\"${ifDefined(this.locationUrl || undefined)}\" publishable-key=\"${ifDefined(this.publishableKey)}\" lang=\"${ifDefined(this.effectiveLang())}\" placeholder=\"${ifDefined(placeholder)}\" @roxy-location-select=\"${(e: CustomEvent<PickedCity>) => onPick(e.detail)}\"></roxy-location-search><small class=\"help\">${this.t('Type a city, then pick it from the list.')}</small>`;\n\t}\n\n\tprivate groupCard(group: string) {\n\t\tconst fields = this.fields.filter(\n\t\t\t(f) => f.group === group && this.isRendered(f),\n\t\t);\n\t\treturn html`<fieldset part=\"group\" class=\"person-group\"><legend>${this.groupName(group)}</legend>${this.groupHasLocation(group) ? this.locationBlock(group) : nothing}<div class=\"fields\">${fields.map((f) => this.renderField(f))}</div>${this.issueLines(this.issuesForGroup(group))}</fieldset>`;\n\t}\n\n\trender() {\n\t\tif (!this.loaded) {\n\t\t\treturn html`<form><div class=\"roxy-skeleton\" style=\"height:8rem\"></div></form>`;\n\t\t}\n\t\tif (this.specError) {\n\t\t\treturn html`<div class=\"spec-error\" role=\"alert\">${this.t('Schema load failed: {{message}}', { message: this.specError })} <button type=\"button\" class=\"submit\" @click=\"${this.retryLoadSchema}\">${this.t('Retry')}</button></div>`;\n\t\t}\n\n\t\t// A refused key can never send, so the reason stands in for inputs nobody could submit.\n\t\tconst refusal = keyRefusal(this.publishableKey);\n\t\tif (refusal) {\n\t\t\treturn html`<form><h2 part=\"title\" class=\"title\" id=\"roxy-form-title\">${this.formTitle}</h2><div part=\"validation-error\" class=\"validation-error\" role=\"alert\">${this.t(refusal.message)}</div></form>`;\n\t\t}\n\n\t\tconst flat = this.fields.filter((f) => !f.group && this.isRendered(f));\n\t\tconst named = this.groupKeys().filter((g): g is string => g !== undefined);\n\t\tconst openFields = flat.filter((f) => !f.fold);\n\t\tconst tuckedFields = flat.filter((f) => f.fold);\n\t\tconst openGroups = named.filter(\n\t\t\t(key) => !this.groups.find((g) => g.key === key)?.fold,\n\t\t);\n\t\tconst tuckedGroups = named.filter(\n\t\t\t(key) => this.groups.find((g) => g.key === key)?.fold,\n\t\t);\n\t\tconst hasAdvanced = tuckedFields.length > 0 || tuckedGroups.length > 0;\n\n\t\treturn html`<form @submit=\"${this.onSubmit}\"><h2 part=\"title\" class=\"title\" id=\"roxy-form-title\">${this.formTitle}</h2>${\n\t\t\t\tthis.validationErrors.length > 0\n\t\t\t\t\t? html`<div part=\"validation-error\" class=\"validation-error\" role=\"alert\"><strong>${this.t('Please complete:')}</strong> ${this.validationErrors.join(', ')}</div>`\n\t\t\t\t\t: nothing\n\t\t\t} ${this.renderIssueSummary()}<div class=\"fields\">${openFields.map((f) => this.renderField(f))}</div>${this.groupHasLocation(undefined) ? this.locationBlock(undefined) : nothing} ${openGroups.map((g) => this.groupCard(g))} ${this.repeats.map((r) => this.repeatControls(r))} ${\n\t\t\t\thasAdvanced\n\t\t\t\t\t? html`<details part=\"advanced\" class=\"advanced\" ?open=\"${this.liveIssues().some((i) =>\n\t\t\t\t\t\t\t\t[...tuckedFields.map((f) => f.key), ...tuckedGroups].some(\n\t\t\t\t\t\t\t\t\t(k) => i.path === k || i.path.startsWith(`${k}.`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)}\"><summary>${this.t('Advanced')}${chevron()}</summary><div class=\"fields\">${tuckedFields.map((f) => this.renderField(f))}</div>${tuckedGroups.map((g) => this.groupCard(g))}</details>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tthis.selfSubmits\n\t\t\t\t\t? nothing\n\t\t\t\t\t: html`<button part=\"submit\" class=\"submit\" type=\"submit\">${this.effectiveSubmitLabel()}</button>`\n\t\t\t}</form>`;\n\t}\n\n\tprivate coerce(kind: string, v: string): unknown {\n\t\tif (v === '') return undefined;\n\t\tif (kind === 'number') {\n\t\t\tconst n = Number(v);\n\t\t\treturn Number.isFinite(n) ? n : undefined;\n\t\t}\n\t\treturn v;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-endpoint-form': RoxyEndpointForm;\n\t}\n}\n"],
|
|
5
|
-
"mappings": "wkBAA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AAS,CAAE,UAAW,EAAM,CAAC,GAxClBnH,EAyCZ,4BAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GA5ClBnH,EA6CZ,wBAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GAhDlBnH,EAiDZ,wBAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GApDlBnH,EAqDZ,yBAIQuH,EAAA,CADPN,EAAM,GAxDKjH,EAyDJ,uBAOAuH,EAAA,CADPN,EAAM,GA/DKjH,EAgEJ,6BAGAuH,EAAA,CADPN,EAAM,GAlEKjH,EAmEJ,sBAOAuH,EAAA,CADPN,EAAM,GAzEKjH,EA0EJ,uBAGAuH,EAAA,CADPN,EAAM,GA5EKjH,EA6EJ,yBAGAuH,EAAA,CADPN,EAAM,GA/EKjH,EAgFJ,uBAGAuH,EAAA,CADPN,EAAM,GAlFKjH,EAmFJ,sBAGAuH,EAAA,CADPN,EAAM,GArFKjH,EAsFJ,sBAGAuH,EAAA,CADPN,EAAM,GAxFKjH,EAyFJ,yBAGAuH,EAAA,CADPN,EAAM,GA3FKjH,EA4FJ,gCA5FIA,EAANuH,EAAA,CADNC,GAAc,oBAAoB,GACtBxH,GjCzJbyH,EAAiB",
|
|
6
|
-
"names": ["cdn_endpoint_form_exports", "__export", "ROXY_UI_TOKENS_STYLE_ID", "RoxyEndpointForm", "injectRoxyTokens", "resetSpecCache", "ROXY_UI_TOKENS_CSS", "ROXY_UI_TOKENS_STYLE_ID", "injectRoxyTokens", "existing", "style", "ROXY_UI_TOKENS_CSS", "global", "globalThis", "supportsAdoptingStyleSheets", "ShadowRoot", "ShadyCSS", "nativeShadow", "Document", "prototype", "CSSStyleSheet", "constructionToken", "Symbol", "cssTagCache", "WeakMap", "CSSResult", "cssText", "strings", "safeToken", "this", "Error", "_strings", "styleSheet", "_styleSheet", "cacheable", "length", "get", "replaceSync", "set", "toString", "unsafeCSS", "value", "String", "css", "values", "reduce", "acc", "v", "idx", "adoptStyles", "renderRoot", "styles", "adoptedStyleSheets", "map", "s", "style", "document", "createElement", "nonce", "setAttribute", "textContent", "appendChild", "getCompatibleStyle", "sheet", "rule", "cssRules", "is", "defineProperty", "getOwnPropertyDescriptor", "getOwnPropertyNames", "getOwnPropertySymbols", "getPrototypeOf", "Object", "global", "globalThis", "trustedTypes", "emptyStringForBooleanAttribute", "emptyScript", "polyfillSupport", "reactiveElementPolyfillSupport", "JSCompiler_renameProperty", "prop", "_obj", "defaultConverter", "value", "type", "Boolean", "Array", "JSON", "stringify", "fromValue", "Number", "parse", "e", "notEqual", "old", "defaultPropertyDeclaration", "attribute", "String", "converter", "reflect", "useDefault", "hasChanged", "Symbol", "metadata", "litPropertyMetadata", "WeakMap", "ReactiveElement", "HTMLElement", "initializer", "this", "__prepare", "_initializers", "push", "observedAttributes", "finalize", "__attributeToPropertyMap", "keys", "name", "options", "state", "prototype", "hasOwnProperty", "create", "wrapped", "elementProperties", "set", "noAccessor", "key", "descriptor", "getPropertyDescriptor", "get", "v", "oldValue", "call", "requestUpdate", "configurable", "enumerable", "superCtor", "Map", "finalized", "props", "properties", "propKeys", "p", "createProperty", "attr", "__attributeNameForProperty", "elementStyles", "finalizeStyles", "styles", "isArray", "Set", "flat", "Infinity", "reverse", "s", "unshift", "getCompatibleStyle", "toLowerCase", "constructor", "super", "__instanceProperties", "isUpdatePending", "hasUpdated", "__reflectingProperty", "__initialize", "__updatePromise", "Promise", "res", "enableUpdating", "_$changedProperties", "__saveInstanceProperties", "forEach", "i", "controller", "__controllers", "add", "renderRoot", "isConnected", "hostConnected", "delete", "instanceProperties", "size", "createRenderRoot", "shadowRoot", "attachShadow", "shadowRootOptions", "adoptStyles", "connectedCallback", "c", "_requestedUpdate", "disconnectedCallback", "hostDisconnected", "_old", "_$attributeToProperty", "attrValue", "toAttribute", "removeAttribute", "setAttribute", "ctor", "propName", "getPropertyOptions", "fromAttribute", "convertedValue", "__defaultValues", "useNewValue", "newValue", "hasAttribute", "_$changeProperty", "__enqueueUpdate", "initializeValue", "has", "__reflectingProperties", "reject", "result", "scheduleUpdate", "performUpdate", "shouldUpdate", "changedProperties", "willUpdate", "hostUpdate", "update", "__markUpdated", "_$didUpdate", "_changedProperties", "hostUpdated", "firstUpdated", "updated", "updateComplete", "getUpdateComplete", "__propertyToAttribute", "mode", "reactiveElementVersions", "global", "globalThis", "wrap", "node", "trustedTypes", "policy", "createPolicy", "createHTML", "s", "boundAttributeSuffix", "marker", "Math", "random", "toFixed", "slice", "markerMatch", "nodeMarker", "d", "document", "createMarker", "createComment", "isPrimitive", "value", "isArray", "Array", "isIterable", "Symbol", "iterator", "SPACE_CHAR", "textEndRegex", "commentEndRegex", "comment2EndRegex", "tagEndRegex", "RegExp", "singleQuoteAttrEndRegex", "doubleQuoteAttrEndRegex", "rawTextElement", "tag", "type", "strings", "values", "_$litType$", "html", "svg", "mathml", "noChange", "for", "nothing", "templateCache", "WeakMap", "walker", "createTreeWalker", "trustFromTemplateString", "tsa", "stringFromTSA", "hasOwnProperty", "Error", "getTemplateHtml", "l", "length", "attrNames", "rawTextEndRegex", "regex", "i", "attrName", "match", "attrNameEndIndex", "lastIndex", "exec", "test", "end", "startsWith", "push", "Template", "constructor", "options", "this", "parts", "nodeIndex", "attrNameIndex", "partCount", "el", "createElement", "currentNode", "content", "wrapper", "firstChild", "replaceWith", "childNodes", "nextNode", "nodeType", "hasAttributes", "name", "getAttributeNames", "endsWith", "realName", "statics", "getAttribute", "split", "m", "index", "ctor", "PropertyPart", "BooleanAttributePart", "EventPart", "AttributePart", "removeAttribute", "tagName", "textContent", "emptyScript", "append", "data", "indexOf", "_options", "innerHTML", "resolveDirective", "part", "parent", "attributeIndex", "currentDirective", "__directives", "__directive", "nextDirectiveConstructor", "_$initialize", "_$resolve", "TemplateInstance", "template", "_$parts", "_$disconnectableChildren", "_$template", "_$parent", "parentNode", "_$isConnected", "fragment", "creationScope", "importNode", "partIndex", "templatePart", "ChildPart", "nextSibling", "ElementPart", "_$setValue", "__isConnected", "startNode", "endNode", "_$committedValue", "_$startNode", "_$endNode", "isConnected", "directiveParent", "_$clear", "_commitText", "_commitTemplateResult", "_commitNode", "_commitIterable", "insertBefore", "_insert", "createTextNode", "result", "_$getTemplate", "h", "_update", "instance", "_clone", "get", "set", "itemParts", "itemPart", "item", "start", "from", "_$notifyConnectionChanged", "n", "remove", "element", "fill", "String", "valueIndex", "noCommit", "change", "v", "_commitValue", "setAttribute", "toggleAttribute", "super", "newListener", "oldListener", "shouldRemoveListener", "capture", "once", "passive", "shouldAddListener", "removeEventListener", "addEventListener", "event", "call", "host", "handleEvent", "_$LH", "_boundAttributeSuffix", "_marker", "_markerMatch", "_HTML_RESULT", "_getTemplateHtml", "_TemplateInstance", "_isIterable", "_resolveDirective", "_ChildPart", "_AttributePart", "_BooleanAttributePart", "_EventPart", "_PropertyPart", "_ElementPart", "polyfillSupport", "litHtmlPolyfillSupport", "litHtmlVersions", "render", "container", "partOwnerNode", "renderBefore", "global", "globalThis", "LitElement", "ReactiveElement", "constructor", "this", "renderOptions", "host", "__childPart", "createRenderRoot", "renderRoot", "super", "renderBefore", "firstChild", "changedProperties", "value", "render", "hasUpdated", "isConnected", "update", "connectedCallback", "setConnected", "disconnectedCallback", "noChange", "litElementHydrateSupport", "polyfillSupport", "litElementPolyfillSupport", "global", "litElementVersions", "push", "customElement", "tagName", "classOrTarget", "context", "addInitializer", "customElements", "define", "defaultPropertyDeclaration", "attribute", "type", "String", "converter", "defaultConverter", "reflect", "hasChanged", "notEqual", "standardProperty", "options", "target", "context", "kind", "metadata", "properties", "globalThis", "litPropertyMetadata", "get", "set", "Map", "Object", "create", "wrapped", "name", "v", "oldValue", "call", "this", "requestUpdate", "_$changeProperty", "value", "Error", "property", "protoOrTarget", "nameOrContext", "proto", "hasOwnProperty", "constructor", "createProperty", "getOwnPropertyDescriptor", "undefined", "state", "options", "property", "attribute", "ifDefined", "value", "nothing", "PartType", "ATTRIBUTE", "CHILD", "PROPERTY", "BOOLEAN_ATTRIBUTE", "EVENT", "ELEMENT", "directive", "c", "values", "_$litDirective$", "Directive", "_partInfo", "_$isConnected", "this", "_$parent", "part", "parent", "attributeIndex", "__part", "__attributeIndex", "props", "update", "_part", "render", "_ChildPart", "ChildPart", "_$LH", "isSingleExpression", "part", "strings", "RESET_VALUE", "setCommittedValue", "part", "value", "_$committedValue", "live", "directive", "Directive", "partInfo", "super", "type", "PartType", "PROPERTY", "ATTRIBUTE", "BOOLEAN_ATTRIBUTE", "Error", "isSingleExpression", "value", "part", "noChange", "nothing", "element", "name", "hasAttribute", "getAttribute", "String", "setCommittedValue", "EN_FIELD_LABELS", "API_LANGUAGES", "resolveLang", "el", "inherited", "ZH_SCRIPT_BY_REGION", "asApiLang", "tag", "wanted", "API_LANGUAGES", "l", "apiLang", "exact", "parts", "base", "script", "p", "lookupKey", "s", "humanize", "s", "c", "GLOBAL_KEY", "registry", "holder", "existing", "created", "interpolate", "template", "vars", "match", "key", "translate", "lang", "source", "chromeLabel", "catalogs", "registry", "tag", "lookupKey", "labelsFor", "lang", "fieldLabels", "registry", "tag", "fieldLabel", "name", "optionLabel", "field", "value", "onLocaleChange", "listener", "listeners", "LocaleController", "host", "onLocaleChange", "RoxyLocalizedElement", "i", "source", "vars", "LocaleController", "translate", "resolveLang", "resolve", "table", "name", "lookupKey", "SIGN_GLYPH", "signGlyph", "name", "resolve", "SIGNS_ORDER", "baseStyles", "i", "chevron", "b", "disclosureStyles", "i", "SAMPLE_PUBLISHABLE_KEY", "KEY_REFUSALS", "keyRefusal", "key", "dispatchKeyRefusal", "host", "refusal", "opts", "DEFAULT_BASE_URL", "readApiFailure", "res", "body", "issues", "i", "ApiError", "message", "worded", "routeRefusal", "route", "keyRefusal", "canFetch", "apiFetch", "req", "signal", "refusal", "proxyBody", "callApi", "failure", "context", "url", "DEFAULT_BASE_URL", "k", "v", "headers", "OPTION_SOURCES", "DISABLED_WHEN", "repeatGroup", "key", "index", "parseRepeatGroup", "group", "m", "deriveGroupLabel", "interpolate", "fieldText", "name", "EN_FIELD_LABELS", "humanize", "repeat", "repeatFields", "fields", "key", "index", "first", "repeatGroup", "f", "optionKind", "values", "isIndex", "v", "LOCATION_TRIO", "LOCATION_PAIR", "splitCoordinateName", "name", "m", "ZODIAC_LOWER", "SIGNS_ORDER", "s", "resolveSchema", "schema", "all", "representative", "union", "scalarType", "real", "t", "classifyInput", "type", "isZodiacEnum", "lower", "toField", "resolved", "opts", "rep", "buildFormModel", "op", "schemas", "endpoint", "method", "repeats", "hasLang", "bodyRef", "bodySchema", "required", "sub", "item", "min", "itemRequired", "i", "subName", "subSchema", "r", "subRequired", "coord", "field", "humanize", "param", "EN_FIELD_LABELS", "noun", "withRenderIntent", "deriveTitle", "model", "operation", "sources", "OPTION_SOURCES", "rules", "DISABLED_WHEN", "groups", "deriveGroupLabel", "locations", "g", "group", "own", "timezone", "primaryGroups", "hasPrimary", "opensOnLoad", "summary", "lead", "deriveSubmitLabel", "sliceFileName", "path", "entriesOf", "json", "list", "n", "optionsFrom", "entries", "keys", "k", "out", "raw", "value", "totalOf", "displayField", "lang", "name", "english", "fieldLabel", "humanize", "displayOption", "field", "value", "fallback", "optionLabel", "comboboxStyles", "i", "debounce", "fn", "wait", "timer", "debounced", "args", "SUGGESTIONS", "MAX_PAGES", "optionCache", "sourceQuery", "source", "lang", "extra", "readOptions", "route", "field", "key", "pending", "readAll", "err", "out", "page", "json", "apiFetch", "got", "optionsFrom", "total", "totalOf", "fold", "s", "OptionPicker", "host", "source", "field", "context", "onPick", "debounce", "q", "option", "e", "n", "route", "lang", "all", "readOptions", "needle", "o", "err", "search", "controller", "json", "apiFetch", "sourceQuery", "SUGGESTIONS", "optionsFrom", "options", "renderPicker", "p", "id", "text", "aria", "listbox", "b", "A", "i", "pickerStyles", "comboboxStyles", "ROXY_UI_VERSION", "PROD_SPEC_URL", "SLICE_BASE", "ROXY_UI_VERSION", "specCache", "SpecHttpError", "status", "SpecMissingOperationError", "method", "path", "resetSpecCache", "loadSpec", "url", "pending", "res", "err", "randomSeed", "isBirthPlace", "f", "isNested", "parseArrayValue", "raw", "trimmed", "parsed", "s", "RoxyEndpointForm", "RoxyLocalizedElement", "spec", "op", "buildFormModel", "sliceFileName", "model", "withRenderIntent", "init", "seed", "remembered", "canFetch", "old", "context", "picker", "OptionPicker", "readOptions", "options", "_", "rest", "name", "value", "patch", "edited", "k", "i", "values", "when", "changed", "refusal", "keyRefusal", "dispatchKeyRefusal", "group", "x", "issues", "b", "issue", "A", "labelFor", "field", "g", "inGroup", "req", "only", "shown", "o", "isIndex", "optionKind", "listed", "deriveSubmitLabel", "apiLang", "label", "displayField", "EN_FIELD_LABELS", "displayOption", "city", "keys", "key", "other", "e", "opts", "cur", "next", "root", "tile", "missing", "out", "v", "repeat", "parseRepeatGroup", "list", "queryKeys", "lang", "labels", "locGroups", "isLocation", "lead", "chevron", "labelId", "zodiac", "isZodiacEnum", "narrow", "active", "opt", "selected", "glyph", "signGlyph", "id", "l", "sole", "renderPicker", "checked", "type", "placeholder", "deriveGroupLabel", "source", "vars", "index", "added", "repeatFields", "template", "repeatGroup", "rekey", "count", "onPick", "fields", "flat", "named", "openFields", "tuckedFields", "openGroups", "tuckedGroups", "hasAdvanced", "r", "kind", "n", "baseStyles", "disclosureStyles", "pickerStyles", "__decorateClass", "t", "injectRoxyTokens"]
|
|
4
|
+
"sourcesContent": ["import { injectRoxyTokens } from './utils/inject-tokens.js';\nexport * from './components/endpoint-form.js';\nexport { injectRoxyTokens, ROXY_UI_TOKENS_STYLE_ID } from './utils/inject-tokens.js';\ninjectRoxyTokens();\n", "// Generated by scripts/sync-tokens.ts from tokens.css. Do not edit.\nexport const ROXY_UI_TOKENS_CSS = `/**\n * Roxy UI design tokens. 47 CSS custom properties that every component reads. Light + dark defaults. Host page overrides at :root or per element. No Tailwind, no class-name overrides, no JS theme switcher.\n *\n * Delivery model: this file ships as a global light-DOM stylesheet (linked, or auto-injected by the CDN bundle). Why every rule sits in a cascade layer is the note above the layer statement below. Custom properties inherit through the shadow boundary, so tokens set on a light-DOM ancestor reach every component shadow. The explicit theme blocks therefore target light-DOM selectors (:root, .dark, [data-theme=\"dark\"], a wrapper element), NOT :host (a :host rule in a global sheet matches nothing). The :host([data-theme]) selectors are kept only for the case where this CSS is ever adopted directly into a shadow root; they are inert in global delivery.\n *\n * Light is the default. Dark applies under any of:\n * - prefers-color-scheme: dark\n * - [data-theme=\"dark\"] on the element itself or any ancestor (typically :root)\n * - .dark class on the element itself or any ancestor (typically :root)\n *\n * Explicit choice wins over the OS: the [data-theme] / .dark blocks come after the @media (prefers-color-scheme: dark) block in source order, and a closer ancestor overrides a farther one through normal custom-property inheritance.\n *\n * Motion gating:\n * - --roxy-motion-duration defaults to 200ms. Set to 0ms to disable.\n * - prefers-reduced-motion: reduce forces 0ms regardless of host overrides.\n */\n\n/*\n * Two mechanisms keep the host page in charge of every token, and both are load bearing.\n *\n * The rules below sit in the \\`roxy.tokens\\` cascade layer, and an unlayered declaration beats a\n * layered one at ANY specificity. So a plain \\`:root { --roxy-accent: #8b5cf6 }\\` on the host page\n * wins, and so does the same line written inside a layer of its own, because the layer\n * statement above registers ours first and the CDN bundle injects this sheet at the top of\n * <head>. A host that links this file after its own CSS orders the layers itself:\n * \\`@layer roxy, base, components, utilities;\\` before either sheet.\n *\n * Every selector is ALSO wrapped in :where(), which has ZERO specificity, so a host declaration\n * still wins wherever a layer cannot decide it. Without that, \\`:root.dark\\` and\n * \\`[data-theme=\"dark\"]\\` would carry class and attribute specificity (0,1,1) and outrank a plain\n * \\`:root\\` (0,1,0), and one brand override would hold under prefers-color-scheme and revert\n * under the other two dark signals: one line, three different results.\n *\n * Source order still decides among the rules in THIS file, which is what lets the explicit dark\n * block beat the light defaults when both match.\n */\n\n/* Layer order, named here so it is fixed wherever the two files load: the theme presets in\n * styles/themes/*.css reassign tokens and must win over these defaults. Both files declare it,\n * so either one loading alone still orders the pair. */\n@layer roxy.tokens, roxy.theme;\n\n@layer roxy.tokens {\n\t:where(:root, :host) {\n\t\t/* Native controls follow the theme, and this is the ONLY thing that makes them.\n\t\t *\n\t\t * \\`color-scheme\\` is a real property, not the \\`prefers-color-scheme\\` query above it, and\n\t\t * without it the browser paints every native control in its LIGHT appearance whatever our\n\t\t * tokens say. A <select> looks fine closed, because we colour it ourselves, and then opens a\n\t\t * light popup whose <option> rows inherit our near-white --roxy-fg: white text on white. The\n\t\t * same omission dims a date or time picker's calendar, the number spinner, the autofill\n\t\t * highlight and the scrollbar.\n\t\t *\n\t\t * It belongs HERE and not on the controls, because a per-control fix is one rule per input\n\t\t * type per component, forever, and it still cannot reach the popup: that is rendered by the\n\t\t * OS outside the DOM, so no selector we write applies to it. Declared once per theme trigger,\n\t\t * beside the tokens, it covers every control in every component and on the host page.\n\t\t * \\`color-scheme\\` is inherited, and these selectors match :host, so each shadow root gets it. */\n\t\tcolor-scheme: light;\n\n\t\t/* Color: brand */\n\t\t--roxy-primary: #0f172a;\n\t\t--roxy-secondary: #475569;\n\t\t--roxy-accent: #f59e0b;\n\t\t/* Text-safe accent variant, DERIVED from --roxy-accent so overriding the accent\n\t\t * alone rebrands the whole library. Never hardcode a colour here: a consumer\n\t\t * following the theming recipe sets only --roxy-accent, and a fixed value leaves\n\t\t * the active tab label, the conjunction aspect lines and the focus ring on the\n\t\t * old hue, giving a two-tone palette from a one-line override.\n\t\t *\n\t\t * The raw accent is too light for text (amber-500 is 2.14:1 on white, far under\n\t\t * WCAG AA). Mixing 70% of it into black is measured, not guessed: rasterised to\n\t\t * real pixels, the darkest of the twelve shipped domain accents still lands at\n\t\t * 5.24:1 on white, above AA. At 75% amber falls to 4.46 and fails, so 70 is a\n\t\t * ceiling, not a round number.\n\t\t *\n\t\t * Fills (planet glyphs, chart accents, non-text badges) keep --roxy-accent. */\n\t\t--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);\n\n\t\t/* Color: status. The base value (success, warning, danger, info) is for\n\t\t * fills and tints. The -fg partner is the INK for a tint of that base, and it\n\t\t * is DERIVED from it exactly as --roxy-accent-ink is derived from the accent,\n\t\t * so re-pointing a status colour carries its text with it instead of leaving\n\t\t * the old hue on every rule that reads the ink.\n\t\t *\n\t\t * 70 percent toward black is the ratio the accent already uses, and it is\n\t\t * measured rather than chosen: rasterised to real pixels the four shipped\n\t\t * pairs land between 7.4 and 9.8 to 1 on the card and between 6.5 and 8.1 on\n\t\t * a 12 percent tint of their own base, every one of them above WCAG AA and at\n\t\t * or above the fixed hexes they replace. Use -fg whenever status color hits\n\t\t * text. */\n\t\t--roxy-success: #16a34a;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);\n\t\t--roxy-warning: #ea580c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);\n\t\t--roxy-danger: #dc2626;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);\n\t\t--roxy-info: #0284c7;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);\n\n\t\t/* Color: surface */\n\t\t--roxy-bg: #ffffff;\n\t\t--roxy-surface: #ffffff;\n\t\t--roxy-fg: #0a0a0a;\n\t\t--roxy-muted: #71717a;\n\t\t--roxy-border: #e4e4e7;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);\n\n\t\t/* Typography */\n\t\t--roxy-font-sans:\n\t\t\t\"Geist\", system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto,\n\t\t\tsans-serif;\n\t\t--roxy-font-mono:\n\t\t\t\"Geist Mono\", ui-monospace, \"SF Mono\", Menlo, Consolas, \"Liberation Mono\",\n\t\t\tmonospace;\n\t\t/* Heading/display font. Defaults to the sans stack so nothing changes for an\n\t\t * existing consumer; a preset (the practitioner theme ships a serif) overrides\n\t\t * it to restyle every result heading and the self-fetch form title in one token.\n\t\t * Fonts do not vary by theme, so it is declared once here and inherited by the\n\t\t * dark/light blocks unchanged. */\n\t\t--roxy-font-display: var(--roxy-font-sans);\n\n\t\t--roxy-text-xs: 0.75rem;\n\t\t--roxy-text-sm: 0.875rem;\n\t\t--roxy-text-base: 1rem;\n\t\t--roxy-text-lg: 1.125rem;\n\t\t--roxy-text-xl: 1.5rem;\n\n\t\t--roxy-weight-normal: 400;\n\t\t--roxy-weight-bold: 600;\n\n\t\t--roxy-leading-tight: 1.2;\n\t\t--roxy-leading-normal: 1.5;\n\n\t\t--roxy-tracking-tight: -0.02em;\n\t\t--roxy-tracking-normal: 0em;\n\n\t\t/* Spacing */\n\t\t--roxy-space-xs: 0.25rem;\n\t\t--roxy-space-sm: 0.5rem;\n\t\t--roxy-space-md: 1rem;\n\t\t--roxy-space-lg: 1.5rem;\n\t\t--roxy-space-xl: 2.5rem;\n\n\t\t/* Radius */\n\t\t--roxy-radius-sm: 4px;\n\t\t--roxy-radius-md: 8px;\n\t\t--roxy-radius-lg: 12px;\n\t\t--roxy-radius-full: 9999px;\n\n\t\t/* Shadow */\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.14);\n\n\t\t/* Motion */\n\t\t--roxy-motion-duration: 200ms;\n\t\t--roxy-motion-easing: cubic-bezier(0.4, 0, 0.2, 1);\n\n\t\t/* Heat scale: a single base hue. Consumers mix it with \\`transparent\\` at\n\t\t * increasing percentages to paint cooler-to-hotter tiers. The mix-with-\n\t\t * transparent approach lets the page bg show through and keeps text\n\t\t * colour stable (always --roxy-fg), so the cells read in both themes\n\t\t * without per-tier text colours. */\n\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t}\n\n\t/* Dark theme via system preference */\n\t@media (prefers-color-scheme: dark) {\n\t\t:where(:root, :host) {\n\t\t\tcolor-scheme: dark;\n\t\t\t--roxy-primary: #f8fafc;\n\t\t\t--roxy-secondary: #94a3b8;\n\t\t\t--roxy-accent: #fbbf24;\n\t\t\t--roxy-accent-ink: var(--roxy-accent);\n\n\t\t\t/* The dark blocks mix toward WHITE, and BOTH dark triggers carry the line.\n\t\t\t * Without it a visitor on system dark with no data-theme attribute inherits\n\t\t\t * the light derivation, which lands a dark green on a near-black surface and\n\t\t\t * fails WCAG AA. */\n\t\t\t--roxy-success: #22c55e;\n\t\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);\n\t\t\t--roxy-warning: #fb923c;\n\t\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);\n\t\t\t--roxy-danger: #ef4444;\n\t\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);\n\t\t\t--roxy-info: #38bdf8;\n\t\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);\n\n\t\t\t--roxy-bg: #0a0a0a;\n\t\t\t--roxy-surface: #18181b;\n\t\t\t--roxy-fg: #fafafa;\n\t\t\t--roxy-muted: #a1a1aa;\n\t\t\t--roxy-border: #27272a;\n\t\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 45%, transparent);\n\n\t\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);\n\t\t\t--roxy-shadow-md:\n\t\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.5);\n\t\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.7);\n\n\t\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t\t}\n\t}\n\n\t/* Light theme override. Beats the @media (prefers-color-scheme: dark) block\n\t * when the host explicitly opts back into light. Without this, a dark-mode OS\n\t * pins the tokens to dark even after data-theme=\"light\" is set. The light-DOM\n\t * selectors (:root.light, .light, [data-theme=\"light\"]) set the vars on the\n\t * ancestor or the element itself so they inherit into every component shadow;\n\t * :host([data-theme=\"light\"]) is inert in global delivery and kept only for\n\t * shadow-adopted use. */\n\t:where(\n\t\t:root[data-theme=\"light\"],\n\t\t[data-theme=\"light\"],\n\t\t:root.light,\n\t\t.light,\n\t\t:host([data-theme=\"light\"])\n\t) {\n\t\tcolor-scheme: light;\n\t\t--roxy-primary: #0f172a;\n\t\t--roxy-secondary: #475569;\n\t\t--roxy-accent: #f59e0b;\n\t\t--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);\n\n\t\t--roxy-success: #16a34a;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);\n\t\t--roxy-warning: #ea580c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);\n\t\t--roxy-danger: #dc2626;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);\n\t\t--roxy-info: #0284c7;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);\n\n\t\t--roxy-bg: #ffffff;\n\t\t--roxy-surface: #ffffff;\n\t\t--roxy-fg: #0a0a0a;\n\t\t--roxy-muted: #71717a;\n\t\t--roxy-border: #e4e4e7;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);\n\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.14);\n\t}\n\n\t/* Dark theme via explicit opt-in. The light-DOM selectors (:root.dark, .dark,\n\t * [data-theme=\"dark\"]) set the vars on the ancestor or the element itself so\n\t * they inherit into every component shadow; this is what makes a .dark class on\n\t * any ancestor (Tailwind, shadcn) actually theme the components in global\n\t * delivery. :host([data-theme=\"dark\"]) is inert in global delivery and kept\n\t * only for shadow-adopted use. */\n\t:where(\n\t\t:root[data-theme=\"dark\"],\n\t\t[data-theme=\"dark\"],\n\t\t:root.dark,\n\t\t.dark,\n\t\t:host([data-theme=\"dark\"])\n\t) {\n\t\tcolor-scheme: dark;\n\t\t--roxy-primary: #f8fafc;\n\t\t--roxy-secondary: #94a3b8;\n\t\t--roxy-accent: #fbbf24;\n\t\t--roxy-accent-ink: var(--roxy-accent);\n\n\t\t--roxy-success: #22c55e;\n\t\t--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);\n\t\t--roxy-warning: #fb923c;\n\t\t--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);\n\t\t--roxy-danger: #ef4444;\n\t\t--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);\n\t\t--roxy-info: #38bdf8;\n\t\t--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);\n\n\t\t--roxy-bg: #0a0a0a;\n\t\t--roxy-surface: #18181b;\n\t\t--roxy-fg: #fafafa;\n\t\t--roxy-muted: #a1a1aa;\n\t\t--roxy-border: #27272a;\n\t\t--roxy-ring: color-mix(in srgb, var(--roxy-accent) 45%, transparent);\n\n\t\t--roxy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);\n\t\t--roxy-shadow-md:\n\t\t\t0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.5);\n\t\t--roxy-shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.7);\n\n\t\t--roxy-heat: var(--roxy-danger, #ef4444);\n\t}\n\n\t/* Reduced motion override */\n\t@media (prefers-reduced-motion: reduce) {\n\t\t:where(:root, :host) {\n\t\t\t--roxy-motion-duration: 0ms;\n\t\t}\n\t}\n}\n`;\n", "import { ROXY_UI_TOKENS_CSS } from '../styles/tokens-css.js';\n\n/** Element id of the injected token stylesheet. Stable so injection is idempotent and so a host page can find, inspect, or remove it. */\nexport const ROXY_UI_TOKENS_STYLE_ID = 'roxy-ui-tokens';\n\n/**\n * Inject the Roxy UI design tokens (light + dark, all theme triggers) into the document head as the cascade's lowest-priority source, so a single CDN script tag yields full theming and dark mode with no separate stylesheet link.\n *\n * @remarks\n * Three invariants hold this safe for every consumer:\n *\n * - SSR-safe: a missing `document` (Node, Lit-SSR, Bun) is a no-op. Only the CDN bundle calls this; the npm/ESM entry (`src/index.ts`) never touches the document, so bundler and server consumers are unaffected.\n * - Idempotent: a second call (two script tags, HMR, re-registration) finds the existing `#roxy-ui-tokens` and returns without duplicating.\n * - Lowest priority, twice over. The tokens sit in the `roxy.tokens` cascade layer, so an unlayered host declaration outranks them at any specificity, and the style is PREPENDED to `<head>`, which registers that layer name ahead of every stylesheet the page brought with it, so a layer of the host's own sorts above it as well. A consumer `:root { --roxy-* }` brand override or a linked `tokens.css` still lands later in source order and still wins ties, so existing pages keep their exact behaviour.\n *\n * @returns The injected (or pre-existing) style element, or `null` under SSR.\n */\nexport function injectRoxyTokens(): HTMLStyleElement | null {\n\tif (typeof document === 'undefined') return null;\n\tconst existing = document.getElementById(ROXY_UI_TOKENS_STYLE_ID);\n\tif (existing) return existing as HTMLStyleElement;\n\tconst style = document.createElement('style');\n\tstyle.id = ROXY_UI_TOKENS_STYLE_ID;\n\tstyle.textContent = ROXY_UI_TOKENS_CSS;\n\tdocument.head.prepend(style);\n\treturn style;\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable<T, K extends keyof T> = Omit<T, K> & {\n -readonly [P in keyof Pick<T, K>]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n });\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<ReactiveUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter<Type = unknown, TypeHint = unknown> =\n | ComplexAttributeConverter<Type>\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter<Type, TypeHint>;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n\n /**\n * When `true`, uses the initial value of the property as the default value,\n * which changes how attributes are handled:\n * - The initial value does *not* reflect, even if the `reflect` option is `true`.\n * Subsequent changes to the property will reflect, even if they are equal to the\n * default value.\n * - When the attribute is removed, the property is set to the default value\n * - The initial value will not trigger an old value in the `changedProperties` map\n * argument to update lifecycle methods.\n *\n * When set, properties must be initialized, either with a field initializer, or an\n * assignment in the constructor. Not initializing the property may lead to\n * improper handling of subsequent property assignments.\n *\n * While this behavior is opt-in, most properties that reflect to attributes should\n * use `useDefault: true` so that their initial values do not reflect.\n */\n useDefault?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;\n\ntype AttributeMap = Map<string, PropertyKey>;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues<this>` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map<PropertyKey, unknown>`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map<PropertyKey, unknown>`, but if a developer uses\n// `PropertyValues<this>` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues<T = any> = T extends object\n ? PropertyValueMap<T>\n : Map<PropertyKey, unknown>;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {\n get<K extends keyof T>(k: K): T[K] | undefined;\n set<K extends keyof T>(key: K, value: T[K]): this;\n has<K extends keyof T>(k: K): boolean;\n delete<K extends keyof T>(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n useDefault: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array<CSSResultOrNative> = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with `<style>` tags when the browser doesn't\n * support adopted StyleSheets. To use such `<style>` tags with the style-src\n * CSP directive, the style-src value must either include 'unsafe-inline' or\n * `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated\n * nonce.\n *\n * To provide a nonce to use on generated `<style>` elements, set\n * `window.litNonce` to a server-generated nonce in your page's HTML, before\n * loading application code:\n *\n * ```html\n * <script>\n * // Generated and unique per request:\n * window.litNonce = 'a1b2c3d4';\n * </script>\n * ```\n * @nocollapse\n * @category styles\n */\n static styles?: CSSResultGroup;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n * @category attributes\n */\n static get observedAttributes() {\n // Ensure we've created all properties\n this.finalize();\n // this.__attributeToPropertyMap is only undefined after finalize() in\n // ReactiveElement itself. ReactiveElement.observedAttributes is only\n // accessed with ReactiveElement as the receiver when a subclass or mixin\n // calls super.observedAttributes\n return (\n this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]\n );\n }\n\n private __instanceProperties?: PropertyValues = undefined;\n\n /**\n * Creates a property accessor on the element prototype if one does not exist\n * and stores a {@linkcode PropertyDeclaration} for the property with the\n * given options. The property setter calls the property's `hasChanged`\n * property option or uses a strict identity check to determine whether or not\n * to request an update.\n *\n * This method may be overridden to customize properties; however,\n * when doing so, it's important to call `super.createProperty` to ensure\n * the property is setup correctly. This method calls\n * `getPropertyDescriptor` internally to get a descriptor to install.\n * To customize what properties do when they are get or set, override\n * `getPropertyDescriptor`. To customize the options for a property,\n * implement `createProperty` like this:\n *\n * ```ts\n * static createProperty(name, options) {\n * options = Object.assign(options, {myOption: true});\n * super.createProperty(name, options);\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n // If this is a state property, force the attribute to false.\n if (options.state) {\n (options as Mutable<PropertyDeclaration, 'attribute'>).attribute = false;\n }\n this.__prepare();\n // Whether this property is wrapping accessors.\n // Helps control the initial value change and reflection logic.\n if (this.prototype.hasOwnProperty(name)) {\n options = Object.create(options);\n options.wrapped = true;\n }\n this.elementProperties.set(name, options);\n if (!options.noAccessor) {\n const key = DEV_MODE\n ? // Use Symbol.for in dev mode to make it easier to maintain state\n // when doing HMR.\n Symbol.for(`${String(name)} (@property() cache)`)\n : Symbol();\n const descriptor = this.getPropertyDescriptor(name, key, options);\n if (descriptor !== undefined) {\n defineProperty(this.prototype, name, descriptor);\n }\n }\n }\n\n /**\n * Returns a property descriptor to be defined on the given named property.\n * If no descriptor is returned, the property will not become an accessor.\n * For example,\n *\n * ```ts\n * class MyElement extends LitElement {\n * static getPropertyDescriptor(name, key, options) {\n * const defaultDescriptor =\n * super.getPropertyDescriptor(name, key, options);\n * const setter = defaultDescriptor.set;\n * return {\n * get: defaultDescriptor.get,\n * set(value) {\n * setter.call(this, value);\n * // custom action.\n * },\n * configurable: true,\n * enumerable: true\n * }\n * }\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n protected static getPropertyDescriptor(\n name: PropertyKey,\n key: string | symbol,\n options: PropertyDeclaration\n ): PropertyDescriptor | undefined {\n const {get, set} = getOwnPropertyDescriptor(this.prototype, name) ?? {\n get(this: ReactiveElement) {\n return this[key as keyof typeof this];\n },\n set(this: ReactiveElement, v: unknown) {\n (this as unknown as Record<string | symbol, unknown>)[key] = v;\n },\n };\n if (DEV_MODE && get == null) {\n if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {\n throw new Error(\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it's actually declared as a value on the prototype. ` +\n `Usually this is due to using @property or @state on a method.`\n );\n }\n issueWarning(\n 'reactive-property-without-getter',\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it does not have a getter. This will be an error in a ` +\n `future version of Lit.`\n );\n }\n return {\n get,\n set(this: ReactiveElement, value: unknown) {\n const oldValue = get?.call(this);\n set?.call(this, value);\n this.requestUpdate(name, oldValue, options);\n },\n configurable: true,\n enumerable: true,\n };\n }\n\n /**\n * Returns the property options associated with the given property.\n * These options are defined with a `PropertyDeclaration` via the `properties`\n * object or the `@property` decorator and are registered in\n * `createProperty(...)`.\n *\n * Note, this method should be considered \"final\" and not overridden. To\n * customize the options for a given property, override\n * {@linkcode createProperty}.\n *\n * @nocollapse\n * @final\n * @category properties\n */\n static getPropertyOptions(name: PropertyKey) {\n return this.elementProperties.get(name) ?? defaultPropertyDeclaration;\n }\n\n // Temporary, until google3 is on TypeScript 5.2\n declare static [Symbol.metadata]: object & Record<PropertyKey, unknown>;\n\n /**\n * Initializes static own properties of the class used in bookkeeping\n * for element properties, initializers, etc.\n *\n * Can be called multiple times by code that needs to ensure these\n * properties exist before using them.\n *\n * This method ensures the superclass is finalized so that inherited\n * property metadata can be copied down.\n * @nocollapse\n */\n private static __prepare() {\n if (\n this.hasOwnProperty(JSCompiler_renameProperty('elementProperties', this))\n ) {\n // Already prepared\n return;\n }\n // Finalize any superclasses\n const superCtor = getPrototypeOf(this) as typeof ReactiveElement;\n superCtor.finalize();\n\n // Create own set of initializers for this class if any exist on the\n // superclass and copy them down. Note, for a small perf boost, avoid\n // creating initializers unless needed.\n if (superCtor._initializers !== undefined) {\n this._initializers = [...superCtor._initializers];\n }\n // Initialize elementProperties from the superclass\n this.elementProperties = new Map(superCtor.elementProperties);\n }\n\n /**\n * Finishes setting up the class so that it's ready to be registered\n * as a custom element and instantiated.\n *\n * This method is called by the ReactiveElement.observedAttributes getter.\n * If you override the observedAttributes getter, you must either call\n * super.observedAttributes to trigger finalization, or call finalize()\n * yourself.\n *\n * @nocollapse\n */\n protected static finalize() {\n if (this.hasOwnProperty(JSCompiler_renameProperty('finalized', this))) {\n return;\n }\n this.finalized = true;\n this.__prepare();\n\n // Create properties from the static properties block:\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n const propKeys = [\n ...getOwnPropertyNames(props),\n ...getOwnPropertySymbols(props),\n ] as Array<keyof typeof props>;\n for (const p of propKeys) {\n this.createProperty(p, props[p]);\n }\n }\n\n // Create properties from standard decorator metadata:\n const metadata = this[Symbol.metadata];\n if (metadata !== null) {\n const properties = litPropertyMetadata.get(metadata);\n if (properties !== undefined) {\n for (const [p, options] of properties) {\n this.elementProperties.set(p, options);\n }\n }\n }\n\n // Create the attribute-to-property map\n this.__attributeToPropertyMap = new Map();\n for (const [p, options] of this.elementProperties) {\n const attr = this.__attributeNameForProperty(p, options);\n if (attr !== undefined) {\n this.__attributeToPropertyMap.set(attr, p);\n }\n }\n\n this.elementStyles = this.finalizeStyles(this.styles);\n\n if (DEV_MODE) {\n if (this.hasOwnProperty('createProperty')) {\n issueWarning(\n 'no-override-create-property',\n 'Overriding ReactiveElement.createProperty() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n if (this.hasOwnProperty('getPropertyDescriptor')) {\n issueWarning(\n 'no-override-get-property-descriptor',\n 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n }\n }\n\n /**\n * Options used when calling `attachShadow`. Set this property to customize\n * the options for the shadowRoot; for example, to create a closed\n * shadowRoot: `{mode: 'closed'}`.\n *\n * Note, these options are used in `createRenderRoot`. If this method\n * is customized, options should be respected if possible.\n * @nocollapse\n * @category rendering\n */\n static shadowRootOptions: ShadowRootInit = {mode: 'open'};\n\n /**\n * Takes the styles the user supplied via the `static styles` property and\n * returns the array of styles to apply to the element.\n * Override this method to integrate into a style management system.\n *\n * Styles are deduplicated preserving the _last_ instance in the list. This\n * is a performance optimization to avoid duplicated styles that can occur\n * especially when composing via subclassing. The last item is kept to try\n * to preserve the cascade order with the assumption that it's most important\n * that last added styles override previous styles.\n *\n * @nocollapse\n * @category styles\n */\n protected static finalizeStyles(\n styles?: CSSResultGroup\n ): Array<CSSResultOrNative> {\n const elementStyles = [];\n if (Array.isArray(styles)) {\n // Dedupe the flattened array in reverse order to preserve the last items.\n // Casting to Array<unknown> works around TS error that\n // appears to come from trying to flatten a type CSSResultArray.\n const set = new Set((styles as Array<unknown>).flat(Infinity).reverse());\n // Then preserve original order by adding the set items in reverse order.\n for (const s of set) {\n elementStyles.unshift(getCompatibleStyle(s as CSSResultOrNative));\n }\n } else if (styles !== undefined) {\n elementStyles.push(getCompatibleStyle(styles));\n }\n return elementStyles;\n }\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n * @category rendering\n */\n readonly renderRoot!: HTMLElement | DocumentFragment;\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static __attributeNameForProperty(\n name: PropertyKey,\n options: PropertyDeclaration\n ) {\n const attribute = options.attribute;\n return attribute === false\n ? undefined\n : typeof attribute === 'string'\n ? attribute\n : typeof name === 'string'\n ? name.toLowerCase()\n : undefined;\n }\n\n // Initialize to an unresolved Promise so we can make sure the element has\n // connected before first update.\n private __updatePromise!: Promise<boolean>;\n\n /**\n * True if there is a pending update as a result of calling `requestUpdate()`.\n * Should only be read.\n * @category updates\n */\n isUpdatePending = false;\n\n /**\n * Is set to `true` after the first update. The element code cannot assume\n * that `renderRoot` exists before the element `hasUpdated`.\n * @category updates\n */\n hasUpdated = false;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n *\n * @internal\n */\n _$changedProperties!: PropertyValues;\n\n /**\n * Records property default values when the\n * `useDefault` option is used.\n */\n private __defaultValues?: Map<PropertyKey, unknown>;\n\n /**\n * Properties that should be reflected when updated.\n */\n private __reflectingProperties?: Set<PropertyKey>;\n\n /**\n * Name of currently reflecting property\n */\n private __reflectingProperty: PropertyKey | null = null;\n\n /**\n * Set of controllers.\n */\n private __controllers?: Set<ReactiveController>;\n\n constructor() {\n super();\n this.__initialize();\n }\n\n /**\n * Internal only override point for customizing work done when elements\n * are constructed.\n */\n private __initialize() {\n this.__updatePromise = new Promise<boolean>(\n (res) => (this.enableUpdating = res)\n );\n this._$changedProperties = new Map();\n // This enqueues a microtask that must run before the first update, so it\n // must be called before requestUpdate()\n this.__saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this.requestUpdate();\n (this.constructor as typeof ReactiveElement)._initializers?.forEach((i) =>\n i(this)\n );\n }\n\n /**\n * Registers a `ReactiveController` to participate in the element's reactive\n * update cycle. The element automatically calls into any registered\n * controllers during its lifecycle callbacks.\n *\n * If the element is connected when `addController()` is called, the\n * controller's `hostConnected()` callback will be immediately called.\n * @category controllers\n */\n addController(controller: ReactiveController) {\n (this.__controllers ??= new Set()).add(controller);\n // If a controller is added after the element has been connected,\n // call hostConnected. Note, re-using existence of `renderRoot` here\n // (which is set in connectedCallback) to avoid the need to track a\n // first connected state.\n if (this.renderRoot !== undefined && this.isConnected) {\n controller.hostConnected?.();\n }\n }\n\n /**\n * Removes a `ReactiveController` from the element.\n * @category controllers\n */\n removeController(controller: ReactiveController) {\n this.__controllers?.delete(controller);\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs.\n */\n private __saveInstanceProperties() {\n const instanceProperties = new Map<PropertyKey, unknown>();\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n for (const p of elementProperties.keys() as IterableIterator<keyof this>) {\n if (this.hasOwnProperty(p)) {\n instanceProperties.set(p, this[p]);\n delete this[p];\n }\n }\n if (instanceProperties.size > 0) {\n this.__instanceProperties = instanceProperties;\n }\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n *\n * @return Returns a node into which to render.\n * @category rendering\n */\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot;\n }\n\n /**\n * On first connection, creates the element's renderRoot, sets up\n * element styling, and enables updating.\n * @category lifecycle\n */\n connectedCallback() {\n // Create renderRoot before controllers `hostConnected`\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n this.enableUpdating(true);\n this.__controllers?.forEach((c) => c.hostConnected?.());\n }\n\n /**\n * Note, this method should be considered final and not overridden. It is\n * overridden on the element instance with a function that triggers the first\n * update.\n * @category updates\n */\n protected enableUpdating(_requestedUpdate: boolean) {}\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n * @category lifecycle\n */\n disconnectedCallback() {\n this.__controllers?.forEach((c) => c.hostDisconnected?.());\n }\n\n /**\n * Synchronizes property values when attributes change.\n *\n * Specifically, when an attribute is set, the corresponding property is set.\n * You should rarely need to implement this callback. If this method is\n * overridden, `super.attributeChangedCallback(name, _old, value)` must be\n * called.\n *\n * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes)\n * on MDN for more information about the `attributeChangedCallback`.\n * @category attributes\n */\n attributeChangedCallback(\n name: string,\n _old: string | null,\n value: string | null\n ) {\n this._$attributeToProperty(name, value);\n }\n\n private __propertyToAttribute(name: PropertyKey, value: unknown) {\n const elemProperties: PropertyDeclarationMap = (\n this.constructor as typeof ReactiveElement\n ).elementProperties;\n const options = elemProperties.get(name)!;\n const attr = (\n this.constructor as typeof ReactiveElement\n ).__attributeNameForProperty(name, options);\n if (attr !== undefined && options.reflect === true) {\n const converter =\n (options.converter as ComplexAttributeConverter)?.toAttribute !==\n undefined\n ? (options.converter as ComplexAttributeConverter)\n : defaultConverter;\n const attrValue = converter.toAttribute!(value, options.type);\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'migration'\n ) &&\n attrValue === undefined\n ) {\n issueWarning(\n 'undefined-attribute-value',\n `The attribute value for the ${name as string} property is ` +\n `undefined on element ${this.localName}. The attribute will be ` +\n `removed, but in the previous version of \\`ReactiveElement\\`, ` +\n `the attribute would not have changed.`\n );\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this.__reflectingProperty = name;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /** @internal */\n _$attributeToProperty(name: string, value: string | null) {\n const ctor = this.constructor as typeof ReactiveElement;\n // Note, hint this as an `AttributeMap` so closure clearly understands\n // the type; it has issues with tracking types through statics\n const propName = (ctor.__attributeToPropertyMap as AttributeMap).get(name);\n // Use tracking info to avoid reflecting a property value to an attribute\n // if it was just set because the attribute changed.\n if (propName !== undefined && this.__reflectingProperty !== propName) {\n const options = ctor.getPropertyOptions(propName);\n const converter =\n typeof options.converter === 'function'\n ? {fromAttribute: options.converter}\n : options.converter?.fromAttribute !== undefined\n ? options.converter\n : defaultConverter;\n // mark state reflecting\n this.__reflectingProperty = propName;\n const convertedValue = converter.fromAttribute!(value, options.type);\n this[propName as keyof this] =\n convertedValue ??\n this.__defaultValues?.get(propName) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (convertedValue as any);\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should be called\n * when an element should update based on some state not triggered by setting\n * a reactive property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored.\n *\n * @param name name of requesting property\n * @param oldValue old value of requesting property\n * @param options property options to use instead of the previously\n * configured options\n * @param useNewValue if true, the newValue argument is used instead of\n * reading the property value. This is important to use if the reactive\n * property is a standard private accessor, as opposed to a plain\n * property, since private members can't be dynamically read by name.\n * @param newValue the new value of the property. This is only used if\n * `useNewValue` is true.\n * @category updates\n */\n requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration,\n useNewValue = false,\n newValue?: unknown\n ): void {\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n if (DEV_MODE && (name as unknown) instanceof Event) {\n issueWarning(\n ``,\n `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`\n );\n }\n const ctor = this.constructor as typeof ReactiveElement;\n if (useNewValue === false) {\n newValue = this[name as keyof this];\n }\n options ??= ctor.getPropertyOptions(name);\n const changed =\n (options.hasChanged ?? notEqual)(newValue, oldValue) ||\n // When there is no change, check a corner case that can occur when\n // 1. there's a initial value which was not reflected\n // 2. the property is subsequently set to this value.\n // For example, `prop: {useDefault: true, reflect: true}`\n // and el.prop = 'foo'. This should be considered a change if the\n // attribute is not set because we will now reflect the property to the attribute.\n (options.useDefault &&\n options.reflect &&\n newValue === this.__defaultValues?.get(name) &&\n !this.hasAttribute(ctor.__attributeNameForProperty(name, options)!));\n if (changed) {\n this._$changeProperty(name, oldValue, options);\n } else {\n // Abort the request if the property should not be considered changed.\n return;\n }\n }\n if (this.isUpdatePending === false) {\n this.__updatePromise = this.__enqueueUpdate();\n }\n }\n\n /**\n * @internal\n */\n _$changeProperty(\n name: PropertyKey,\n oldValue: unknown,\n {useDefault, reflect, wrapped}: PropertyDeclaration,\n initializeValue?: unknown\n ) {\n // Record default value when useDefault is used. This allows us to\n // restore this value when the attribute is removed.\n if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) {\n this.__defaultValues.set(\n name,\n initializeValue ?? oldValue ?? this[name as keyof this]\n );\n // if this is not wrapping an accessor, it must be an initial setting\n // and in this case we do not want to record the change or reflect.\n if (wrapped !== true || initializeValue !== undefined) {\n return;\n }\n }\n // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(\n // vs just Map.set()\n if (!this._$changedProperties.has(name)) {\n // On the initial change, the old value should be `undefined`, except\n // with `useDefault`\n if (!this.hasUpdated && !useDefault) {\n oldValue = undefined;\n }\n this._$changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `__reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (reflect === true && this.__reflectingProperty !== name) {\n (this.__reflectingProperties ??= new Set<PropertyKey>()).add(name);\n }\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async __enqueueUpdate() {\n this.isUpdatePending = true;\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await this.__updatePromise;\n } catch (e) {\n // Refire any previous errors async so they do not disrupt the update\n // cycle. Errors are refired so developers have a chance to observe\n // them, and this can be done by implementing\n // `window.onunhandledrejection`.\n Promise.reject(e);\n }\n const result = this.scheduleUpdate();\n // If `scheduleUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n return !this.isUpdatePending;\n }\n\n /**\n * Schedules an element update. You can override this method to change the\n * timing of updates by returning a Promise. The update will await the\n * returned Promise, and you should resolve the Promise to allow the update\n * to proceed. If this method is overridden, `super.scheduleUpdate()`\n * must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```ts\n * override protected async scheduleUpdate(): Promise<unknown> {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.scheduleUpdate();\n * }\n * ```\n * @category updates\n */\n protected scheduleUpdate(): void | Promise<unknown> {\n const result = this.performUpdate();\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'async-perform-update'\n ) &&\n typeof (result as unknown as Promise<unknown> | undefined)?.then ===\n 'function'\n ) {\n issueWarning(\n 'async-perform-update',\n `Element ${this.localName} returned a Promise from performUpdate(). ` +\n `This behavior is deprecated and will be removed in a future ` +\n `version of ReactiveElement.`\n );\n }\n return result;\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * Call `performUpdate()` to immediately process a pending update. This should\n * generally not be needed, but it can be done in rare cases when you need to\n * update synchronously.\n *\n * @category updates\n */\n protected performUpdate(): void {\n // Abort any update if one is not pending when this is called.\n // This can happen if `performUpdate` is called early to \"flush\"\n // the update.\n if (!this.isUpdatePending) {\n return;\n }\n debugLogEvent?.({kind: 'update'});\n if (!this.hasUpdated) {\n // Create renderRoot before first update. This occurs in `connectedCallback`\n // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n if (DEV_MODE) {\n // Produce warning if any reactive properties on the prototype are\n // shadowed by class fields. Instance fields set before upgrade are\n // deleted by this point, so any own property is caused by class field\n // initialization in the constructor.\n const ctor = this.constructor as typeof ReactiveElement;\n const shadowedProperties = [...ctor.elementProperties.keys()].filter(\n (p) => this.hasOwnProperty(p) && p in getPrototypeOf(this)\n );\n if (shadowedProperties.length) {\n throw new Error(\n `The following properties on element ${this.localName} will not ` +\n `trigger updates as expected because they are set using class ` +\n `fields: ${shadowedProperties.join(', ')}. ` +\n `Native class fields and some compiled output will overwrite ` +\n `accessors used for detecting changes. See ` +\n `https://lit.dev/msg/class-field-shadowing ` +\n `for more information.`\n );\n }\n }\n // Mixin instance properties once, if they exist.\n if (this.__instanceProperties) {\n // TODO (justinfagnani): should we use the stored value? Could a new value\n // have been set since we stored the own property value?\n for (const [p, value] of this.__instanceProperties) {\n this[p as keyof this] = value as this[keyof this];\n }\n this.__instanceProperties = undefined;\n }\n // Trigger initial value reflection and populate the initial\n // `changedProperties` map, but only for the case of properties created\n // via `createProperty` on accessors, which will not have already\n // populated the `changedProperties` map since they are not set.\n // We can't know if these accessors had initializers, so we just set\n // them anyway - a difference from experimental decorators on fields and\n // standard decorators on auto-accessors.\n // For context see:\n // https://github.com/lit/lit/pull/4183#issuecomment-1711959635\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n if (elementProperties.size > 0) {\n for (const [p, options] of elementProperties) {\n const {wrapped} = options;\n const value = this[p as keyof this];\n if (\n wrapped === true &&\n !this._$changedProperties.has(p) &&\n value !== undefined\n ) {\n this._$changeProperty(p, undefined, options, value);\n }\n }\n }\n }\n let shouldUpdate = false;\n const changedProperties = this._$changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.willUpdate(changedProperties);\n this.__controllers?.forEach((c) => c.hostUpdate?.());\n this.update(changedProperties);\n } else {\n this.__markUpdated();\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n // Ensure element can accept additional updates after an exception.\n this.__markUpdated();\n throw e;\n }\n // The update is no longer considered pending and further updates are now allowed.\n if (shouldUpdate) {\n this._$didUpdate(changedProperties);\n }\n }\n\n /**\n * Invoked before `update()` to compute values needed during the update.\n *\n * Implement `willUpdate` to compute property values that depend on other\n * properties and are used in the rest of the update process.\n *\n * ```ts\n * willUpdate(changedProperties) {\n * // only need to check changed properties for an expensive computation.\n * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {\n * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);\n * }\n * }\n *\n * render() {\n * return html`SHA: ${this.sha}`;\n * }\n * ```\n *\n * @category updates\n */\n protected willUpdate(_changedProperties: PropertyValues): void {}\n\n // Note, this is an override point for polyfill-support.\n // @internal\n _$didUpdate(changedProperties: PropertyValues) {\n this.__controllers?.forEach((c) => c.hostUpdated?.());\n if (!this.hasUpdated) {\n this.hasUpdated = true;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n if (\n DEV_MODE &&\n this.isUpdatePending &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'change-in-update'\n )\n ) {\n issueWarning(\n 'change-in-update',\n `Element ${this.localName} scheduled an update ` +\n `(generally because a property was set) ` +\n `after an update completed, causing a new update to be scheduled. ` +\n `This is inefficient and should be avoided unless the next update ` +\n `can only be scheduled as a side effect of the previous update.`\n );\n }\n }\n\n private __markUpdated() {\n this._$changedProperties = new Map();\n this.isUpdatePending = false;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super.getUpdateComplete()`, then any subsequent state.\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n get updateComplete(): Promise<boolean> {\n return this.getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * ```ts\n * class MyElement extends LitElement {\n * override async getUpdateComplete() {\n * const result = await super.getUpdateComplete();\n * await this._myChild.updateComplete;\n * return result;\n * }\n * }\n * ```\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n protected getUpdateComplete(): Promise<boolean> {\n return this.__updatePromise;\n }\n\n /**\n * Controls whether or not `update()` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected update(_changedProperties: PropertyValues) {\n // The forEach() expression will only run when __reflectingProperties is\n // defined, and it returns undefined, setting __reflectingProperties to\n // undefined\n this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) =>\n this.__propertyToAttribute(p, this[p as keyof this])\n ) as undefined;\n this.__markUpdated();\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected updated(_changedProperties: PropertyValues) {}\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * ```ts\n * firstUpdated() {\n * this.renderRoot.getElementById('my-text-area').focus();\n * }\n * ```\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected firstUpdated(_changedProperties: PropertyValues) {}\n}\n// Assigned here to work around a jscompiler bug with static fields\n// when compiling to ES5.\n// https://github.com/google/closure-compiler/issues/3177\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('elementProperties', ReactiveElement)\n] = new Map();\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', ReactiveElement)\n] = new Map();\n\n// Apply polyfills if available\npolyfillSupport?.({ReactiveElement});\n\n// Dev mode warnings...\nif (DEV_MODE) {\n // Default warning set.\n ReactiveElement.enabledWarnings = [\n 'change-in-update',\n 'async-perform-update',\n ];\n const ensureOwnWarnings = function (ctor: typeof ReactiveElement) {\n if (\n !ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings', ctor))\n ) {\n ctor.enabledWarnings = ctor.enabledWarnings!.slice();\n }\n };\n ReactiveElement.enableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n if (!this.enabledWarnings!.includes(warning)) {\n this.enabledWarnings!.push(warning);\n }\n };\n ReactiveElement.disableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n const i = this.enabledWarnings!.indexOf(warning);\n if (i >= 0) {\n this.enabledWarnings!.splice(i, 1);\n }\n };\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for ReactiveElement usage.\n(global.reactiveElementVersions ??= []).push('2.1.2');\nif (DEV_MODE && global.reactiveElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// IMPORTANT: these imports must be type-only\nimport type {Directive, DirectiveResult, PartInfo} from './directive.js';\nimport type {TrustedHTML, TrustedTypesWindow} from 'trusted-types/lib/index.js';\n\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace LitUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | TemplatePrep\n | TemplateInstantiated\n | TemplateInstantiatedAndUpdated\n | TemplateUpdating\n | BeginRender\n | EndRender\n | CommitPartEntry\n | SetPartValue;\n export interface TemplatePrep {\n kind: 'template prep';\n template: Template;\n strings: TemplateStringsArray;\n clonableTemplate: HTMLTemplateElement;\n parts: TemplatePart[];\n }\n export interface BeginRender {\n kind: 'begin render';\n id: number;\n value: unknown;\n container: RenderRootNode;\n options: RenderOptions | undefined;\n part: ChildPart | undefined;\n }\n export interface EndRender {\n kind: 'end render';\n id: number;\n value: unknown;\n container: RenderRootNode;\n options: RenderOptions | undefined;\n part: ChildPart;\n }\n export interface TemplateInstantiated {\n kind: 'template instantiated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateInstantiatedAndUpdated {\n kind: 'template instantiated and updated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateUpdating {\n kind: 'template updating';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface SetPartValue {\n kind: 'set part';\n part: Part;\n value: unknown;\n valueIndex: number;\n values: unknown[];\n templateInstance: TemplateInstance;\n }\n\n export type CommitPartEntry =\n | CommitNothingToChildEntry\n | CommitText\n | CommitNode\n | CommitAttribute\n | CommitProperty\n | CommitBooleanAttribute\n | CommitEventListener\n | CommitToElementBinding;\n\n export interface CommitNothingToChildEntry {\n kind: 'commit nothing to child';\n start: ChildNode;\n end: ChildNode | null;\n parent: Disconnectable | undefined;\n options: RenderOptions | undefined;\n }\n\n export interface CommitText {\n kind: 'commit text';\n node: Text;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitNode {\n kind: 'commit node';\n start: Node;\n parent: Disconnectable | undefined;\n value: Node;\n options: RenderOptions | undefined;\n }\n\n export interface CommitAttribute {\n kind: 'commit attribute';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitProperty {\n kind: 'commit property';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitBooleanAttribute {\n kind: 'commit boolean attribute';\n element: Element;\n name: string;\n value: boolean;\n options: RenderOptions | undefined;\n }\n\n export interface CommitEventListener {\n kind: 'commit event listener';\n element: Element;\n name: string;\n value: unknown;\n oldListener: unknown;\n options: RenderOptions | undefined;\n // True if we're removing the old event listener (e.g. because settings changed, or value is nothing)\n removeListener: boolean;\n // True if we're adding a new event listener (e.g. because first render, or settings changed)\n addListener: boolean;\n }\n\n export interface CommitToElementBinding {\n kind: 'commit to element binding';\n element: Element;\n value: unknown;\n options: RenderOptions | undefined;\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: LitUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<LitUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n });\n}\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? (global.ShadyDOM!.wrap as <T extends Node>(node: T) => T)\n : <T extends Node>(node: T) => node;\n\nconst trustedTypes = (global as unknown as TrustedTypesWindow).trustedTypes;\n\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\n\n/**\n * Used to sanitize any value before it is written into the DOM. This can be\n * used to implement a security policy of allowed and disallowed values in\n * order to prevent XSS attacks.\n *\n * One way of using this callback would be to check attributes and properties\n * against a list of high risk fields, and require that values written to such\n * fields be instances of a class which is safe by construction. Closure's Safe\n * HTML Types is one implementation of this technique (\n * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).\n * The TrustedTypes polyfill in API-only mode could also be used as a basis\n * for this technique (https://github.com/WICG/trusted-types).\n *\n * @param node The HTML node (usually either a #text node or an Element) that\n * is being written to. Note that this is just an exemplar node, the write\n * may take place against another instance of the same class of node.\n * @param name The name of an attribute or property (for example, 'href').\n * @param type Indicates whether the write that's about to be performed will\n * be to a property or a node.\n * @return A function that will sanitize this class of writes.\n */\nexport type SanitizerFactory = (\n node: Node,\n name: string,\n type: 'property' | 'attribute'\n) => ValueSanitizer;\n\n/**\n * A function which can sanitize values that will be written to a specific kind\n * of DOM sink.\n *\n * See SanitizerFactory.\n *\n * @param value The value to sanitize. Will be the actual value passed into\n * the lit-html template literal, so this could be of any type.\n * @return The value to write to the DOM. Usually the same as the input value,\n * unless sanitization is needed.\n */\nexport type ValueSanitizer = (value: unknown) => unknown;\n\nconst identityFunction: ValueSanitizer = (value: unknown) => value;\nconst noopSanitizer: SanitizerFactory = (\n _node: Node,\n _name: string,\n _type: 'property' | 'attribute'\n) => identityFunction;\n\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer: SanitizerFactory) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(\n `Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`\n );\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\n\nconst createSanitizer: SanitizerFactory = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${Math.random().toFixed(9).slice(2)}$`;\n\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\n\nconst d =\n NODE_MODE && global.document === undefined\n ? ({\n createTreeWalker() {\n return {};\n },\n } as unknown as Document)\n : document;\n\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = () => d.createComment('');\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\nconst isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (value as any)?.[Symbol.iterator] === 'function';\n\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\n\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(\n `>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`,\n 'g'\n);\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\n\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\nconst MATHML_RESULT = 3;\n\ntype ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;\n\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n */\nexport type UncompiledTemplateResult<T extends ResultType = ResultType> = {\n // This property needs to remain unminified.\n ['_$litType$']: T;\n strings: TemplateStringsArray;\n values: unknown[];\n};\n\n/**\n * This is a template result that may be either uncompiled or compiled.\n *\n * In the future, TemplateResult will be this type. If you want to explicitly\n * note that a template result is potentially compiled, you can reference this\n * type and it will continue to behave the same through the next major version\n * of Lit. This can be useful for code that wants to prepare for the next\n * major version of Lit.\n */\nexport type MaybeCompiledTemplateResult<T extends ResultType = ResultType> =\n | UncompiledTemplateResult<T>\n | CompiledTemplateResult;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg}.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n * In Lit 4, this type will be an alias of\n * MaybeCompiledTemplateResult, so that code will get type errors if it assumes\n * that Lit templates are not compiled. When deliberately working with only\n * one, use either {@linkcode CompiledTemplateResult} or\n * {@linkcode UncompiledTemplateResult} explicitly.\n */\nexport type TemplateResult<T extends ResultType = ResultType> =\n UncompiledTemplateResult<T>;\n\nexport type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;\n\nexport type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;\n\nexport type MathMLTemplateResult = TemplateResult<typeof MATHML_RESULT>;\n\n/**\n * A TemplateResult that has been compiled by @lit-labs/compiler, skipping the\n * prepare step.\n */\nexport interface CompiledTemplateResult {\n // This is a factory in order to make template initialization lazy\n // and allow ShadyRenderOptions scope to be passed in.\n // This property needs to remain unminified.\n ['_$litType$']: CompiledTemplate;\n values: unknown[];\n}\n\nexport interface CompiledTemplate extends Omit<Template, 'el'> {\n // el is overridden to be optional. We initialize it on first render\n el?: HTMLTemplateElement;\n\n // The prepared HTML string to create a template element from.\n // The type is a TemplateStringsArray to guarantee that the value came from\n // source code, preventing a JSON injection attack.\n h: TemplateStringsArray;\n}\n\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag =\n <T extends ResultType>(type: T) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult<T> => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn(\n 'Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.'\n );\n }\n if (DEV_MODE) {\n // Import static-html.js results in a circular dependency which g3 doesn't\n // handle. Instead we know that static values must have the field\n // `_$litStatic$`.\n if (\n values.some((val) => (val as {_$litStatic$: unknown})?.['_$litStatic$'])\n ) {\n issueWarning(\n '',\n `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\\n` +\n `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`\n );\n }\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n\n/**\n * Interprets a template literal as an SVG fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus not be properly contained within an `<svg>` HTML\n * element.\n */\nexport const svg = tag(SVG_RESULT);\n\n/**\n * Interprets a template literal as MathML fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const num = mathml`<mn>1</mn>`;\n *\n * const eq = html`\n * <math>\n * ${num}\n * </math>`;\n * ```\n *\n * The `mathml` *tag function* should only be used for MathML fragments, or\n * elements that would be contained **inside** a `<math>` HTML element. A common\n * error is placing a `<math>` *element* in a template tagged with the `mathml`\n * tag function. The `<math>` element is an HTML element and should be used\n * within a template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an MathML fragment from the\n * `render()` method, as the MathML fragment will be contained within the\n * element's shadow root and thus not be properly contained within a `<math>`\n * HTML element.\n */\nexport const mathml = tag(MATHML_RESULT);\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - they must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\n/**\n * Object specifying options for controlling lit-html rendering. Note that\n * while `render` may be called multiple times on the same `container` (and\n * `renderBefore` reference node) to efficiently update the rendered content,\n * only the options passed in during the first render are respected during\n * the lifetime of renders to that unique `container` + `renderBefore`\n * combination.\n */\nexport interface RenderOptions {\n /**\n * An object to use as the `this` value for event listeners. It's often\n * useful to set this to the host component rendering a template.\n */\n host?: object;\n /**\n * A DOM node before which to render content in the container.\n */\n renderBefore?: ChildNode | null;\n /**\n * Node used for cloning the template (`importNode` will be called on this\n * node). This controls the `ownerDocument` of the rendered DOM, along with\n * any inherited context. Defaults to the global `document`.\n */\n creationScope?: {importNode(node: Node, deep?: boolean): Node};\n /**\n * The initial connected state for the top-level part being rendered. If no\n * `isConnected` option is set, `AsyncDirective`s will be connected by\n * default. Set to `false` if the initial render occurs in a disconnected tree\n * and `AsyncDirective`s should see `isConnected === false` for their initial\n * render. The `part.setConnected()` method must be used subsequent to initial\n * render to change the connected state of the part.\n */\n isConnected?: boolean;\n}\n\n/**\n * The root DOM node for rendering.\n */\nexport type RenderRootNode = HTMLElement | SVGElement | DocumentFragment;\n\nconst walker = d.createTreeWalker(\n d,\n 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */\n);\n\nlet sanitizerFactoryInternal: SanitizerFactory = noopSanitizer;\n\n//\n// Classes only below here, const variable declarations only above here...\n//\n// Keeping variable declarations and classes together improves minification.\n// Interfaces and type aliases can be interleaved freely.\n//\n\n// Type for classes that have a `_directive` or `_directives[]` field, used by\n// `resolveDirective`\nexport interface DirectiveParent {\n _$parent?: DirectiveParent;\n _$isConnected: boolean;\n __directive?: Directive;\n __directives?: Array<Directive | undefined>;\n}\n\nfunction trustFromTemplateString(\n tsa: TemplateStringsArray,\n stringFromTSA: string\n): TrustedHTML {\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n return policy !== undefined\n ? policy.createHTML(stringFromTSA)\n : (stringFromTSA as unknown as TrustedHTML);\n}\n\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (\n strings: TemplateStringsArray,\n type: ResultType\n): [TrustedHTML, Array<string>] => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames: Array<string> = [];\n let html =\n type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';\n\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex: RegExp | undefined;\n\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName: string | undefined;\n let lastIndex = 0;\n let match!: RegExpExecArray | null;\n\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n } else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n } else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n } else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error(\n 'Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions'\n );\n }\n regex = tagEndRegex;\n }\n } else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n } else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n } else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n } else if (\n regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex\n ) {\n regex = tagEndRegex;\n } else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n } else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(\n attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex,\n 'unexpected parse state B'\n );\n }\n\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end =\n regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName!),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s + marker + (attrNameEndIndex === -2 ? i : end);\n }\n\n const htmlResult: string | TrustedHTML =\n html +\n (strings[l] || '<?>') +\n (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');\n\n // Returned as an array for terseness\n return [trustFromTemplateString(strings, htmlResult), attrNames];\n};\n\n/** @internal */\nexport type {Template};\nclass Template {\n /** @internal */\n el!: HTMLTemplateElement;\n\n parts: Array<TemplatePart> = [];\n\n constructor(\n // This property needs to remain unminified.\n {strings, ['_$litType$']: type}: UncompiledTemplateResult,\n options?: RenderOptions\n ) {\n let node: Node | null;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n\n // Re-parent SVG or MathML nodes into template root\n if (type === SVG_RESULT || type === MATHML_RESULT) {\n const wrapper = this.el.content.firstChild!;\n wrapper.replaceWith(...wrapper.childNodes);\n }\n\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = (node as Element).localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (\n /^(?:textarea|template)$/i!.test(tag) &&\n (node as Element).innerHTML.includes(marker)\n ) {\n const m =\n `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n } else issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if ((node as Element).hasAttributes()) {\n for (const name of (node as Element).getAttributeNames()) {\n if (name.endsWith(boundAttributeSuffix)) {\n const realName = attrNames[attrNameIndex++];\n const value = (node as Element).getAttribute(name)!;\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName)!;\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor:\n m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n (node as Element).removeAttribute(name);\n } else if (name.startsWith(marker)) {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n (node as Element).removeAttribute(name);\n }\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test((node as Element).tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = (node as Element).textContent!.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n (node as Element).textContent = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for child parts\n for (let i = 0; i < lastIndex; i++) {\n (node as Element).append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({type: CHILD_PART, index: ++nodeIndex});\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n (node as Element).append(strings[lastIndex], createMarker());\n }\n }\n } else if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data === markerMatch) {\n parts.push({type: CHILD_PART, index: nodeIndex});\n } else {\n let i = -1;\n while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({type: COMMENT_PART, index: nodeIndex});\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n\n if (DEV_MODE) {\n // If there was a duplicate attribute on a tag, then when the tag is\n // parsed into an element the attribute gets de-duplicated. We can detect\n // this mismatch if we haven't precisely consumed every attribute name\n // when preparing the template. This works because `attrNames` is built\n // from the template string and `attrNameIndex` comes from processing the\n // resulting DOM.\n if (attrNames.length !== attrNameIndex) {\n throw new Error(\n `Detected duplicate attribute bindings. This occurs if your template ` +\n `has duplicate attributes on an element tag. For example ` +\n `\"<input ?disabled=\\${true} ?disabled=\\${false}>\" contains a ` +\n `duplicate \"disabled\" attribute. The error was detected in ` +\n `the following template: \\n` +\n '`' +\n strings.join('${...}') +\n '`'\n );\n }\n }\n\n // We could set walker.currentNode to another node here to prevent a memory\n // leak, but every time we prepare a template, we immediately render it\n // and re-use the walker in new TemplateInstance._clone().\n debugLogEvent &&\n debugLogEvent({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html: TrustedHTML, _options?: RenderOptions) {\n const el = d.createElement('template');\n el.innerHTML = html as unknown as string;\n return el;\n }\n}\n\nexport interface Disconnectable {\n _$parent?: Disconnectable;\n _$disconnectableChildren?: Set<Disconnectable>;\n // Rather than hold connection state on instances, Disconnectables recursively\n // fetch the connection state from the RootPart they are connected in via\n // getters up the Disconnectable tree via _$parent references. This pushes the\n // cost of tracking the isConnected state to `AsyncDirectives`, and avoids\n // needing to pass all Disconnectables (parts, template instances, and\n // directives) their connection state each time it changes, which would be\n // costly for trees that have no AsyncDirectives.\n _$isConnected: boolean;\n}\n\nfunction resolveDirective(\n part: ChildPart | AttributePart | ElementPart,\n value: unknown,\n parent: DirectiveParent = part,\n attributeIndex?: number\n): unknown {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective =\n attributeIndex !== undefined\n ? (parent as AttributePart).__directives?.[attributeIndex]\n : (parent as ChildPart | ElementPart | Directive).__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n (value as DirectiveResult)['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n } else {\n currentDirective = new nextDirectiveConstructor(part as PartInfo);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n ((parent as AttributePart).__directives ??= [])[attributeIndex] =\n currentDirective;\n } else {\n (parent as ChildPart | Directive).__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(\n part,\n currentDirective._$resolve(part, (value as DirectiveResult).values),\n currentDirective,\n attributeIndex\n );\n }\n return value;\n}\n\nexport type {TemplateInstance};\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance implements Disconnectable {\n _$template: Template;\n _$parts: Array<Part | undefined> = [];\n\n /** @internal */\n _$parent: ChildPart;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n constructor(template: Template, parent: ChildPart) {\n this._$template = template;\n this._$parent = parent;\n }\n\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options: RenderOptions | undefined) {\n const {\n el: {content},\n parts: parts,\n } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n\n let node = walker.nextNode()!;\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part: Part | undefined;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(\n node as HTMLElement,\n node.nextSibling,\n this,\n options\n );\n } else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n this,\n options\n );\n } else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node as HTMLElement, this, options);\n }\n this._$parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode()!;\n nodeIndex++;\n }\n }\n // We need to set the currentNode away from the cloned tree so that we\n // don't hold onto the tree even if the tree is detached and should be\n // freed.\n walker.currentNode = d;\n return fragment;\n }\n\n _update(values: Array<unknown>) {\n let i = 0;\n for (const part of this._$parts) {\n if (part !== undefined) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if ((part as AttributePart).strings !== undefined) {\n (part as AttributePart)._$setValue(values, part as AttributePart, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += (part as AttributePart).strings!.length - 2;\n } else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\n\n/*\n * Parts\n */\ntype AttributeTemplatePart = {\n readonly type: typeof ATTRIBUTE_PART;\n readonly index: number;\n readonly name: string;\n readonly ctor: typeof AttributePart;\n readonly strings: ReadonlyArray<string>;\n};\ntype ChildTemplatePart = {\n readonly type: typeof CHILD_PART;\n readonly index: number;\n};\ntype ElementTemplatePart = {\n readonly type: typeof ELEMENT_PART;\n readonly index: number;\n};\ntype CommentTemplatePart = {\n readonly type: typeof COMMENT_PART;\n readonly index: number;\n};\n\n/**\n * A TemplatePart represents a dynamic part in a template, before the template\n * is instantiated. When a template is instantiated Parts are created from\n * TemplateParts.\n */\ntype TemplatePart =\n | ChildTemplatePart\n | AttributeTemplatePart\n | ElementTemplatePart\n | CommentTemplatePart;\n\nexport type Part =\n | ChildPart\n | AttributePart\n | PropertyPart\n | BooleanAttributePart\n | ElementPart\n | EventPart;\n\nexport type {ChildPart};\nclass ChildPart implements Disconnectable {\n readonly type = CHILD_PART;\n readonly options: RenderOptions | undefined;\n _$committedValue: unknown = nothing;\n /** @internal */\n __directive?: Directive;\n /** @internal */\n _$startNode: ChildNode;\n /** @internal */\n _$endNode: ChildNode | null;\n private _textSanitizer: ValueSanitizer | undefined;\n /** @internal */\n _$parent: Disconnectable | undefined;\n /**\n * Connection state for RootParts only (i.e. ChildPart without _$parent\n * returned from top-level `render`). This field is unused otherwise. The\n * intention would be clearer if we made `RootPart` a subclass of `ChildPart`\n * with this field (and a different _$isConnected getter), but the subclass\n * caused a perf regression, possibly due to making call sites polymorphic.\n * @internal\n */\n __isConnected: boolean;\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /** @internal */\n _$notifyConnectionChanged?(\n isConnected: boolean,\n removeFromParent?: boolean,\n from?: number\n ): void;\n /** @internal */\n _$reparentDisconnectables?(parent: Disconnectable): void;\n\n constructor(\n startNode: ChildNode,\n endNode: ChildNode | null,\n parent: TemplateInstance | ChildPart | undefined,\n options: RenderOptions | undefined\n ) {\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode(): Node {\n let parentNode: Node = wrap(this._$startNode).parentNode!;\n const parent = this._$parent;\n if (\n parent !== undefined &&\n parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */\n ) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = (parent as ChildPart | TemplateInstance).parentNode;\n }\n return parentNode;\n }\n\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode(): Node | null {\n return this._$startNode;\n }\n\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode(): Node | null {\n return this._$endNode;\n }\n\n _$setValue(value: unknown, directiveParent: DirectiveParent = this): void {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(\n `This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`\n );\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n } else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n } else if ((value as TemplateResult)['_$litType$'] !== undefined) {\n this._commitTemplateResult(value as TemplateResult);\n } else if ((value as Node).nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(\n `[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`\n );\n console.warn(\n `Attempted to render the template host`,\n value,\n `inside itself. This is almost always a mistake, and in dev mode `,\n `we render some warning text. In production however, we'll `,\n `render it, which will usually result in an error, and sometimes `,\n `in the element disappearing from the DOM.`\n );\n return;\n }\n this._commitNode(value as Node);\n } else if (isIterable(value)) {\n this._commitIterable(value);\n } else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n\n private _insert<T extends Node>(node: T) {\n return wrap(wrap(this._$startNode).parentNode!).insertBefore(\n node,\n this._$endNode\n );\n }\n\n private _commitNode(value: Node): void {\n if (this._$committedValue !== value) {\n this._$clear();\n if (\n ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer\n ) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n } else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n\n private _commitText(value: unknown): void {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (\n this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)\n ) {\n const node = wrap(this._$startNode).nextSibling as Text;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n (node as Text).data = value as string;\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = d.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value as string;\n } else {\n this._commitNode(d.createTextNode(value as string));\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling as Text,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n\n private _commitTemplateResult(\n result: TemplateResult | CompiledTemplateResult\n ): void {\n // This property needs to remain unminified.\n const {values, ['_$litType$']: type} = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template: Template | CompiledTemplate =\n typeof type === 'number'\n ? this._$getTemplate(result as UncompiledTemplateResult)\n : (type.el === undefined &&\n (type.el = Template.createElement(\n trustFromTemplateString(type.h, type.h[0]),\n this.options\n )),\n type);\n\n if ((this._$committedValue as TemplateInstance)?._$template === template) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'template updating',\n template,\n instance: this._$committedValue as TemplateInstance,\n parts: (this._$committedValue as TemplateInstance)._$parts,\n options: this.options,\n values,\n });\n (this._$committedValue as TemplateInstance)._update(values);\n } else {\n const instance = new TemplateInstance(template as Template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result: UncompiledTemplateResult) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n\n private _commitIterable(value: Iterable<unknown>): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue as ChildPart[];\n let partIndex = 0;\n let itemPart: ChildPart | undefined;\n\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push(\n (itemPart = new ChildPart(\n this._insert(createMarker()),\n this._insert(createMarker()),\n this,\n this.options\n ))\n );\n } else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(\n itemPart && wrap(itemPart._$endNode!).nextSibling,\n partIndex\n );\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives\n * in those Parts.\n *\n * @internal\n */\n _$clear(\n start: ChildNode | null = wrap(this._$startNode).nextSibling,\n from?: number\n ) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start !== this._$endNode) {\n // The non-null assertion is safe because if _$startNode.nextSibling is\n // null, then _$endNode is also null, and we would not have entered this\n // loop.\n const n = wrap(start!).nextSibling;\n wrap(start!).remove();\n start = n;\n }\n }\n\n /**\n * Implementation of RootPart's `isConnected`. Note that this method\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected: boolean) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n } else if (DEV_MODE) {\n throw new Error(\n 'part.setConnected() may only be called on a ' +\n 'RootPart returned from render().'\n );\n }\n }\n}\n\n/**\n * A top-level `ChildPart` returned from `render` that manages the connected\n * state of `AsyncDirective`s created throughout the tree below it.\n */\nexport interface RootPart extends ChildPart {\n /**\n * Sets the connection state for `AsyncDirective`s contained within this root\n * ChildPart.\n *\n * lit-html does not automatically monitor the connectedness of DOM rendered;\n * as such, it is the responsibility of the caller to `render` to ensure that\n * `part.setConnected(false)` is called before the part object is potentially\n * discarded, to ensure that `AsyncDirective`s have a chance to dispose of\n * any resources being held. If a `RootPart` that was previously\n * disconnected is subsequently re-connected (and its `AsyncDirective`s should\n * re-connect), `setConnected(true)` should be called.\n *\n * @param isConnected Whether directives within this tree should be connected\n * or not\n */\n setConnected(isConnected: boolean): void;\n}\n\nexport type {AttributePart};\nclass AttributePart implements Disconnectable {\n readonly type:\n | typeof ATTRIBUTE_PART\n | typeof PROPERTY_PART\n | typeof BOOLEAN_ATTRIBUTE_PART\n | typeof EVENT_PART = ATTRIBUTE_PART;\n readonly element: HTMLElement;\n readonly name: string;\n readonly options: RenderOptions | undefined;\n\n /**\n * If this attribute part represents an interpolation, this contains the\n * static strings of the interpolation. For single-value, complete bindings,\n * this is undefined.\n */\n readonly strings?: ReadonlyArray<string>;\n /** @internal */\n _$committedValue: unknown | Array<unknown> = nothing;\n /** @internal */\n __directives?: Array<Directive | undefined>;\n /** @internal */\n _$parent: Disconnectable;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n protected _sanitizer: ValueSanitizer | undefined;\n\n get tagName() {\n return this.element.tagName;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n } else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(\n value: unknown | Array<unknown>,\n directiveParent: DirectiveParent = this,\n valueIndex?: number,\n noCommit?: boolean\n ) {\n const strings = this.strings;\n\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n } else {\n // Interpolation case\n const values = value as Array<unknown>;\n value = strings[0];\n\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex! + i], directiveParent, i);\n\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = (this._$committedValue as Array<unknown>)[i];\n }\n change ||=\n !isPrimitive(v) || v !== (this._$committedValue as Array<unknown>)[i];\n if (v === nothing) {\n value = nothing;\n } else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n (this._$committedValue as Array<unknown>)[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n\n /** @internal */\n _commitValue(value: unknown) {\n if (value === nothing) {\n (wrap(this.element) as Element).removeAttribute(this.name);\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'attribute'\n );\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n (wrap(this.element) as Element).setAttribute(\n this.name,\n (value ?? '') as string\n );\n }\n }\n}\n\nexport type {PropertyPart};\nclass PropertyPart extends AttributePart {\n override readonly type = PROPERTY_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'property'\n );\n }\n value = this._sanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.element as any)[this.name] = value === nothing ? undefined : value;\n }\n}\n\nexport type {BooleanAttributePart};\nclass BooleanAttributePart extends AttributePart {\n override readonly type = BOOLEAN_ATTRIBUTE_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n (wrap(this.element) as Element).toggleAttribute(\n this.name,\n !!value && value !== nothing\n );\n }\n}\n\ntype EventListenerWithOptions = EventListenerOrEventListenerObject &\n Partial<AddEventListenerOptions>;\n\n/**\n * An AttributePart that manages an event listener via add/removeEventListener.\n *\n * This part works by adding itself as the event listener on an element, then\n * delegating to the value passed to it. This reduces the number of calls to\n * add/removeEventListener if the listener changes frequently, such as when an\n * inline function is used as a listener.\n *\n * Because event options are passed when adding listeners, we must take case\n * to add and remove the part as a listener when the event options change.\n */\nexport type {EventPart};\nclass EventPart extends AttributePart {\n override readonly type = EVENT_PART;\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n super(element, name, strings, parent, options);\n\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(\n `A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.'\n );\n }\n }\n\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n override _$setValue(\n newListener: unknown,\n directiveParent: DirectiveParent = this\n ) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener =\n (newListener === nothing && oldListener !== nothing) ||\n (newListener as EventListenerWithOptions).capture !==\n (oldListener as EventListenerWithOptions).capture ||\n (newListener as EventListenerWithOptions).once !==\n (oldListener as EventListenerWithOptions).once ||\n (newListener as EventListenerWithOptions).passive !==\n (oldListener as EventListenerWithOptions).passive;\n\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener =\n newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.name,\n this,\n oldListener as EventListenerWithOptions\n );\n }\n if (shouldAddListener) {\n this.element.addEventListener(\n this.name,\n this,\n newListener as EventListenerWithOptions\n );\n }\n this._$committedValue = newListener;\n }\n\n handleEvent(event: Event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n } else {\n (this._$committedValue as EventListenerObject).handleEvent(event);\n }\n }\n}\n\nexport type {ElementPart};\nclass ElementPart implements Disconnectable {\n readonly type = ELEMENT_PART;\n\n /** @internal */\n __directive?: Directive;\n\n // This is to ensure that every Part has a _$committedValue\n _$committedValue: undefined;\n\n /** @internal */\n _$parent!: Disconnectable;\n\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n options: RenderOptions | undefined;\n\n constructor(\n public element: Element,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this._$parent = parent;\n this.options = options;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n _$setValue(value: unknown): void {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in tests and private-ssr-support\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('3.3.3');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`\n );\n });\n}\n\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (\n value: unknown,\n container: RenderRootNode,\n options?: RenderOptions\n): RootPart => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part: ChildPart = (partOwnerNode as any)['_$litPart$'];\n debugLogEvent &&\n debugLogEvent({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (partOwnerNode as any)['_$litPart$'] = part = new ChildPart(\n container.insertBefore(createMarker(), endNode),\n endNode,\n undefined,\n options ?? {}\n );\n }\n part._$setValue(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part as RootPart;\n};\n\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The main LitElement module, which defines the {@linkcode LitElement} base\n * class and related APIs.\n *\n * LitElement components can define a template and a set of observed\n * properties. Changing an observed property triggers a re-render of the\n * element.\n *\n * Import {@linkcode LitElement} and {@linkcode html} from this module to\n * create a component:\n *\n * ```js\n * import {LitElement, html} from 'lit-element';\n *\n * class MyElement extends LitElement {\n *\n * // Declare observed properties\n * static get properties() {\n * return {\n * adjective: {}\n * }\n * }\n *\n * constructor() {\n * this.adjective = 'awesome';\n * }\n *\n * // Define the element's template\n * render() {\n * return html`<p>your ${adjective} template here</p>`;\n * }\n * }\n *\n * customElements.define('my-element', MyElement);\n * ```\n *\n * `LitElement` extends {@linkcode ReactiveElement} and adds lit-html\n * templating. The `ReactiveElement` class is provided for users that want to\n * build their own custom element base classes that don't use lit-html.\n *\n * @packageDocumentation\n */\nimport {PropertyValues, ReactiveElement} from '@lit/reactive-element';\nimport {render, RenderOptions, noChange, RootPart} from 'lit-html';\nexport * from '@lit/reactive-element';\nexport * from 'lit-html';\n\nimport {LitUnstable} from 'lit-html';\nimport {ReactiveUnstable} from '@lit/reactive-element';\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace Unstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | LitUnstable.DebugLog.Entry\n | ReactiveUnstable.DebugLog.Entry;\n }\n}\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\nconst DEV_MODE = true;\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n/**\n * Base element class that manages element properties and attributes, and\n * renders a lit-html template.\n *\n * To define a component, subclass `LitElement` and implement a\n * `render` method to provide the component's template. Define properties\n * using the {@linkcode LitElement.properties properties} property or the\n * {@linkcode property} decorator.\n */\nexport class LitElement extends ReactiveElement {\n // This property needs to remain unminified.\n static ['_$litElement$'] = true;\n\n /**\n * @category rendering\n */\n readonly renderOptions: RenderOptions = {host: this};\n\n private __childPart: RootPart | undefined = undefined;\n\n /**\n * @category rendering\n */\n protected override createRenderRoot() {\n const renderRoot = super.createRenderRoot();\n // When adoptedStyleSheets are shimmed, they are inserted into the\n // shadowRoot by createRenderRoot. Adjust the renderBefore node so that\n // any styles in Lit content render before adoptedStyleSheets. This is\n // important so that adoptedStyleSheets have precedence over styles in\n // the shadowRoot.\n this.renderOptions.renderBefore ??= renderRoot!.firstChild as ChildNode;\n return renderRoot;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * @param changedProperties Map of changed properties with old values\n * @category updates\n */\n protected override update(changedProperties: PropertyValues) {\n // Setting properties in `render` should not trigger an update. Since\n // updates are allowed after super.update, it's important to call `render`\n // before that.\n const value = this.render();\n if (!this.hasUpdated) {\n this.renderOptions.isConnected = this.isConnected;\n }\n super.update(changedProperties);\n this.__childPart = render(value, this.renderRoot, this.renderOptions);\n }\n\n /**\n * Invoked when the component is added to the document's DOM.\n *\n * In `connectedCallback()` you should setup tasks that should only occur when\n * the element is connected to the document. The most common of these is\n * adding event listeners to nodes external to the element, like a keydown\n * event handler added to the window.\n *\n * ```ts\n * connectedCallback() {\n * super.connectedCallback();\n * addEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * Typically, anything done in `connectedCallback()` should be undone when the\n * element is disconnected, in `disconnectedCallback()`.\n *\n * @category lifecycle\n */\n override connectedCallback() {\n super.connectedCallback();\n this.__childPart?.setConnected(true);\n }\n\n /**\n * Invoked when the component is removed from the document's DOM.\n *\n * This callback is the main signal to the element that it may no longer be\n * used. `disconnectedCallback()` should ensure that nothing is holding a\n * reference to the element (such as event listeners added to nodes external\n * to the element), so that it is free to be garbage collected.\n *\n * ```ts\n * disconnectedCallback() {\n * super.disconnectedCallback();\n * window.removeEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * An element may be re-connected after being disconnected.\n *\n * @category lifecycle\n */\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__childPart?.setConnected(false);\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method may return\n * any value renderable by lit-html's `ChildPart` - typically a\n * `TemplateResult`. Setting properties inside this method will *not* trigger\n * the element to update.\n * @category rendering\n */\n protected render(): unknown {\n return noChange;\n }\n}\n\n/**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See @lit/reactive-element for more information.\n */\n(LitElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', LitElement)\n] = true;\n\n// Install hydration if available\nglobal.litElementHydrateSupport?.({LitElement});\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litElementPolyfillSupportDevMode\n : global.litElementPolyfillSupport;\npolyfillSupport?.({LitElement});\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LE object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-html, since this module re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LE = {\n _$attributeToProperty: (\n el: LitElement,\n name: string,\n value: string | null\n ) => {\n // eslint-disable-next-line\n (el as any)._$attributeToProperty(name, value);\n },\n // eslint-disable-next-line\n _$changedProperties: (el: LitElement) => (el as any)._$changedProperties,\n};\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n(global.litElementVersions ??= []).push('4.2.2');\nif (DEV_MODE && global.litElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport type {Constructor} from './base.js';\n\n/**\n * Allow for custom element classes with private constructors\n */\ntype CustomElementClass = Omit<typeof HTMLElement, 'new'>;\n\nexport type CustomElementDecorator = {\n // legacy\n (cls: CustomElementClass): void;\n\n // standard\n (\n target: CustomElementClass,\n context: ClassDecoratorContext<Constructor<HTMLElement>>\n ): void;\n};\n\n/**\n * Class decorator factory that defines the decorated class as a custom element.\n *\n * ```js\n * @customElement('my-element')\n * class MyElement extends LitElement {\n * render() {\n * return html``;\n * }\n * }\n * ```\n * @category Decorator\n * @param tagName The tag name of the custom element to define.\n */\nexport const customElement =\n (tagName: string): CustomElementDecorator =>\n (\n classOrTarget: CustomElementClass | Constructor<HTMLElement>,\n context?: ClassDecoratorContext<Constructor<HTMLElement>>\n ) => {\n if (context !== undefined) {\n context.addInitializer(() => {\n customElements.define(\n tagName,\n classOrTarget as CustomElementConstructor\n );\n });\n } else {\n customElements.define(tagName, classOrTarget as CustomElementConstructor);\n }\n };\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {\n type PropertyDeclaration,\n type ReactiveElement,\n defaultConverter,\n notEqual,\n} from '../reactive-element.js';\nimport type {Interface} from './base.js';\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n globalThis.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !globalThis.litIssuedWarnings!.has(warning) &&\n !globalThis.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n globalThis.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n// Overloads for property decorator so that TypeScript can infer the correct\n// return type when a decorator is used as an accessor decorator or a setter\n// decorator.\nexport type PropertyDecorator = {\n // accessor decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: ClassAccessorDecoratorTarget<C, V>,\n context: ClassAccessorDecoratorContext<C, V>\n ): ClassAccessorDecoratorResult<C, V>;\n\n // setter decorator signature\n <C extends Interface<ReactiveElement>, V>(\n target: (value: V) => void,\n context: ClassSetterDecoratorContext<C, V>\n ): (this: C, value: V) => void;\n\n // legacy decorator signature\n (\n protoOrDescriptor: Object,\n name: PropertyKey,\n descriptor?: PropertyDescriptor\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any;\n};\n\nconst legacyProperty = (\n options: PropertyDeclaration | undefined,\n proto: Object,\n name: PropertyKey\n) => {\n const hasOwnProperty = proto.hasOwnProperty(name);\n (proto.constructor as typeof ReactiveElement).createProperty(name, options);\n // For accessors (which have a descriptor on the prototype) we need to\n // return a descriptor, otherwise TypeScript overwrites the descriptor we\n // define in createProperty() with the original descriptor. We don't do this\n // for fields, which don't have a descriptor, because this could overwrite\n // descriptor defined by other decorators.\n return hasOwnProperty\n ? Object.getOwnPropertyDescriptor(proto, name)\n : undefined;\n};\n\n// This is duplicated from a similar variable in reactive-element.ts, but\n// actually makes sense to have this default defined with the decorator, so\n// that different decorators could have different defaults.\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n// Temporary type, until google3 is on TypeScript 5.2\ntype StandardPropertyContext<C, V> = (\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n) & {metadata: object};\n\n/**\n * Wraps a class accessor or setter so that `requestUpdate()` is called with the\n * property name and old value when the accessor is set.\n */\nexport const standardProperty = <C extends Interface<ReactiveElement>, V>(\n options: PropertyDeclaration = defaultPropertyDeclaration,\n target: ClassAccessorDecoratorTarget<C, V> | ((value: V) => void),\n context: StandardPropertyContext<C, V>\n): ClassAccessorDecoratorResult<C, V> | ((this: C, value: V) => void) => {\n const {kind, metadata} = context;\n\n if (DEV_MODE && metadata == null) {\n issueWarning(\n 'missing-class-metadata',\n `The class ${target} is missing decorator metadata. This ` +\n `could mean that you're using a compiler that supports decorators ` +\n `but doesn't support decorator metadata, such as TypeScript 5.1. ` +\n `Please update your compiler.`\n );\n }\n\n // Store the property options\n let properties = globalThis.litPropertyMetadata.get(metadata);\n if (properties === undefined) {\n globalThis.litPropertyMetadata.set(metadata, (properties = new Map()));\n }\n if (kind === 'setter') {\n options = Object.create(options);\n options.wrapped = true;\n }\n properties.set(context.name, options);\n\n if (kind === 'accessor') {\n // Standard decorators cannot dynamically modify the class, so we can't\n // replace a field with accessors. The user must use the new `accessor`\n // keyword instead.\n const {name} = context;\n return {\n set(this: ReactiveElement, v: V) {\n const oldValue = (\n target as ClassAccessorDecoratorTarget<C, V>\n ).get.call(this as unknown as C);\n (target as ClassAccessorDecoratorTarget<C, V>).set.call(\n this as unknown as C,\n v\n );\n this.requestUpdate(name, oldValue, options, true, v);\n },\n init(this: ReactiveElement, v: V): V {\n if (v !== undefined) {\n this._$changeProperty(name, undefined, options, v);\n }\n return v;\n },\n } as unknown as ClassAccessorDecoratorResult<C, V>;\n } else if (kind === 'setter') {\n const {name} = context;\n return function (this: ReactiveElement, value: V) {\n const oldValue = this[name as keyof ReactiveElement];\n (target as (value: V) => void).call(this, value);\n this.requestUpdate(name, oldValue, options, true, value);\n } as unknown as (this: C, value: V) => void;\n }\n throw new Error(`Unsupported decorator location: ${kind}`);\n};\n\n/**\n * A class field or accessor decorator which creates a reactive property that\n * reflects a corresponding attribute value. When a decorated property is set\n * the element will update and render. A {@linkcode PropertyDeclaration} may\n * optionally be supplied to configure property features.\n *\n * This decorator should only be used for public fields. As public fields,\n * properties should be considered as primarily settable by element users,\n * either via attribute or the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the {@linkcode state} decorator.\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating public\n * properties should typically not be done for non-primitive (object or array)\n * properties. In other cases when an element needs to manage state, a private\n * property decorated via the {@linkcode state} decorator should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n *\n * ```ts\n * class MyElement {\n * @property({ type: Boolean })\n * clicked = false;\n * }\n * ```\n * @category Decorator\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration): PropertyDecorator {\n return <C extends Interface<ReactiveElement>, V>(\n protoOrTarget:\n | object\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext:\n | PropertyKey\n | ClassAccessorDecoratorContext<C, V>\n | ClassSetterDecoratorContext<C, V>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): any => {\n return (\n typeof nameOrContext === 'object'\n ? standardProperty<C, V>(\n options,\n protoOrTarget as\n | ClassAccessorDecoratorTarget<C, V>\n | ((value: V) => void),\n nameOrContext as StandardPropertyContext<C, V>\n )\n : legacyProperty(\n options,\n protoOrTarget as Object,\n nameOrContext as PropertyKey\n )\n ) as PropertyDecorator;\n };\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {property} from './property.js';\n\nexport interface StateDeclaration<Type = unknown> {\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n}\n\n/**\n * @deprecated use StateDeclaration\n */\nexport type InternalPropertyDeclaration<Type = unknown> =\n StateDeclaration<Type>;\n\n/**\n * Declares a private or protected reactive property that still triggers\n * updates to the element when it changes. It does not reflect from the\n * corresponding attribute.\n *\n * Properties declared this way must not be used from HTML or HTML templating\n * systems, they're solely for properties internal to the element. These\n * properties may be renamed by optimization tools like closure compiler.\n * @category Decorator\n */\nexport function state(options?: StateDeclaration) {\n return property({\n ...options,\n // Add both `state` and `attribute` because we found a third party\n // controller that is keying off of PropertyOptions.state to determine\n // whether a field is a private internal property or not.\n state: true,\n attribute: false,\n });\n}\n", "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = <T>(value: T) => value ?? nothing;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html.js';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html.js';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal\n */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n _$LH,\n Part,\n DirectiveParent,\n CompiledTemplateResult,\n MaybeCompiledTemplateResult,\n UncompiledTemplateResult,\n} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n MATHML: 3,\n} as const;\n\nexport type TemplateResultType =\n (typeof TemplateResultType)[keyof typeof TemplateResultType];\n\ntype IsTemplateResult = {\n (val: unknown): val is MaybeCompiledTemplateResult;\n <T extends TemplateResultType>(\n val: unknown,\n type: T\n ): val is UncompiledTemplateResult<T>;\n};\n\n/**\n * Tests if a value is a TemplateResult or a CompiledTemplateResult.\n */\nexport const isTemplateResult: IsTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is UncompiledTemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as UncompiledTemplateResult)?.['_$litType$'] !== undefined\n : (value as UncompiledTemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a CompiledTemplateResult.\n */\nexport const isCompiledTemplateResult = (\n value: unknown\n): value is CompiledTemplateResult => {\n return (value as CompiledTemplateResult)?.['_$litType$']?.h != null;\n};\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinel value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being committed.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content and markers.\n *\n * Note: The only difference between this and clearPart() is that this also\n * removes the part's start node. This means that the ChildPart must own its\n * start node, ie it must be a marker node specifically for this part and not an\n * anchor from surrounding content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$clear();\n part._$startNode.remove();\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n DirectiveResult,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {isSingleExpression, setCommittedValue} from '../directive-helpers.js';\n\nclass LiveDirective<T> extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n !(\n partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE\n )\n ) {\n throw new Error(\n 'The `live` directive is not allowed on child or event bindings'\n );\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n\n render(value: T): T {\n return value;\n }\n\n override update(part: AttributePart, [value]: DirectiveParameters<this>) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === (element as any)[name]) {\n return noChange;\n }\n } else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n } else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n\ninterface Live {\n <T>(value: T): DirectiveResult<typeof LiveDirective<T>>;\n}\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * ```js\n * html`<input .value=${live(x)}>`\n * ```\n *\n * `live()` performs a strict equality check against the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live: Live = directive(LiveDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {LiveDirective};\n", "/**\n * GENERATED by `bun run scripts/sync-field-labels.ts`. Do not edit.\n *\n * @remarks\n * The API English label of every request field whose label differs from its humanized wire name, which the form prints on an English page and wherever a translated payload carries no label of its own.\n */\nexport const EN_FIELD_LABELS: Record<string, string> = {\n\tafterSunset: 'Born after sunset',\n\tallowDuplicates: 'Allow duplicate cards',\n\tallowReversals: 'Allow reversed cards',\n\tangelDating: 'How the name of the day is dated',\n\tannualFromYear: 'Annual pillars from year',\n\tannualYears: 'Years of annual pillars',\n\tapproximateDate: 'Approximate date',\n\taspectTypes: 'Aspect types',\n\tatbashOutput: 'AtBash and Albam output',\n\tavasthaInfo: 'Include avastha details',\n\tavoidAnimal: 'Avoid clashes with',\n\tayadiText: 'Ayadi text family',\n\tayanamsaValue: 'Custom ayanamsa value',\n\tbirthData: 'Birth details',\n\tbirthDate: 'Birth date',\n\tbirthLatitude: 'Birth latitude',\n\tbirthLongitude: 'Birth longitude',\n\tbirthTime: 'Birth time',\n\tciphers: 'Ciphers to return',\n\tcontext: 'Where you saw it',\n\tcoordinateSystem: 'Coordinate system',\n\tcorrelation: 'Correlation constant',\n\tcount: 'How many',\n\tcurrentYear: 'Year',\n\tcuts: 'Cut corners',\n\tdasha: 'Dasha lords',\n\tdatetime: 'Date and time',\n\tdayBoundary: 'Day boundary',\n\tdepth: 'Depth, north to south',\n\tdirectionScheme: 'Direction reading',\n\tdivision: 'Divisional chart',\n\tdomainWeights: 'Domain weights',\n\tdoor: 'Door coordinates',\n\tdoorPosition: 'Door position along the side',\n\tdoshaClock: 'How the dosha periods are cut',\n\tendDate: 'End date',\n\tendDatetime: 'End date and time',\n\texpression: 'Expression number',\n\textensions: 'Extended corners',\n\tfacing: 'Facing direction',\n\tfacingDegrees: 'Facing degrees',\n\tfamily: 'Yoga family',\n\tfirstName: 'First name',\n\tfirstNameHebrew: 'First name in Hebrew',\n\tfullName: 'Full name',\n\tgainHouses: 'Gain houses',\n\tgrid: 'Mandala grid',\n\thastaInches: 'Length of one hasta in inches',\n\thoraryNumber: 'Horary number',\n\thourClock: 'Hour clock',\n\thouseSystem: 'House system',\n\tid: 'ID',\n\tinclude: 'Additional bodies',\n\tincludeMatches: 'Include equal value matches',\n\tinterpretation: 'Position meaning',\n\tintervalMinutes: 'Interval in minutes',\n\tisLeapMonth: 'Leap month',\n\tiso2: 'Country code',\n\tkua: 'Kua number',\n\tlang: 'Language',\n\tlatinCiphers: 'Also score the Latin ciphers',\n\tleapDayPolicy: 'Where 29 February falls',\n\tletter: 'Starting letter',\n\tletterAttribution: 'Letter attribution reading',\n\tlifePath: 'Life Path number',\n\tlimit: 'Results per page',\n\tlines: 'Line pattern',\n\tlossHouses: 'Loss houses',\n\tlunarDay: 'Lunar day',\n\tlunarMonth: 'Lunar month',\n\tlunarYear: 'Lunar year',\n\tmembers: 'Group members',\n\tminSignificance: 'Minimum significance',\n\tminStrength: 'Minimum strength',\n\tmisparGadol: 'Mispar gadol method',\n\tmodernPlanets: 'Include modern planets',\n\tmoonWindows: 'Moon windows',\n\tmuhurtaText: 'Muhurta text',\n\tnameHebrew: 'Name in Hebrew',\n\tnatalChart: 'Natal chart',\n\tnodeType: 'Lunar node type',\n\toffset: 'Results to skip',\n\tpolygon: 'Outline',\n\tpositions: 'Spread positions',\n\tq: 'Search',\n\tquestion: 'Your question',\n\trelocationLatitude: 'Relocation latitude',\n\trelocationLongitude: 'Relocation longitude',\n\treturnDate: 'Return date',\n\treturnYear: 'Return year',\n\tritucharyaScheme: 'Season division',\n\trituZodiac: 'Zodiac the season boundaries are measured in',\n\troad: 'Road side',\n\trulingPlanets: 'Ruling planets',\n\tscheme: 'Karaka scheme',\n\tsecondName: 'Second name',\n\tsecondNameHebrew: 'Second name in Hebrew',\n\tsephirotSystem: 'Sephirot reading',\n\tsign: 'Zodiac sign',\n\tsign1: 'First animal sign',\n\tsign2: 'Second animal sign',\n\tsignDoshaScheme: 'Sign humour table',\n\tsignificators: 'Include KP significators',\n\tslopeLowDirection: 'Direction the ground falls toward',\n\tslopeSchool: 'Ground level school',\n\tsoulUrge: 'Soul Urge number',\n\tspreadName: 'Spread name',\n\tstartDate: 'Start date',\n\tstartDatetime: 'Start date and time',\n\tstrictOrbs: 'Use tighter orbs',\n\tsystem: 'Avastha system',\n\ttargetDate: 'Target date',\n\ttargetMonth: 'Target month',\n\ttext: 'Word or name',\n\ttextHebrew: 'Hebrew word or name',\n\ttop: 'Top events per window',\n\ttransitDate: 'Transit date',\n\ttransitTime: 'Transit time',\n\ttransliteration: 'Transliteration scheme',\n\ttreeVariant: 'Tree arrangement',\n\ttype: 'Pattern type',\n\tvyayaFormula: 'Vyaya formula',\n\twater: 'Standing water direction',\n\tweights: 'Layer weights',\n\twidth: 'Width, east to west',\n\tx: 'Distance east',\n\ty: 'Distance north',\n\tyearBearerSystem: 'Year Bearer school',\n\tyearBoundary: 'Year boundary',\n\tyearStart: 'Wheel year start',\n\tzodiac: 'Zodiac sign',\n};\n", "// Generated by scripts/sync-bindings.ts (the `lang` query enum in specs/openapi.json). Do not edit.\n\n/**\n * Every language tag the API accepts on `?lang=`.\n *\n * @remarks\n * A self-fetch resolves the site language from the DOM, which means ANY value a\n * host page happens to carry can reach the query string. The API rejects an\n * unlisted tag with a 400, so a page in a language we do not translate would\n * stop working the moment the language chain was completed. Membership is\n * checked against this list before `lang` is sent, and a miss simply omits the\n * parameter, leaving the endpoint on its English default.\n */\nexport const API_LANGUAGES: readonly string[] = [\"de\",\"en\",\"es\",\"fr\",\"hi\",\"pt\",\"ru\",\"tr\",\"zh-Hans\",\"zh-Hant\"];\n", "/**\n * Where a component's language comes from, and what is safe to send to the API.\n *\n * @remarks\n * Two different answers, and conflating them is the whole reason this file is separate from the catalogue:\n *\n * - {@link resolveLang} answers \"what language is this PAGE in\", and keeps the full tag, because `es-AR` is a legitimate thing for a catalogue to want to differ on.\n * - {@link apiLang} answers \"what may go on the query string\", which is a narrower question with a hard edge: `?lang=es-AR` is a 400, `?lang=es` is a 200.\n *\n * The full tag is not a nicety the catalogue happens to tolerate: `utils/format.ts` hands it to `Intl`, which reads the region and writes `15 de ene de 1990` for `es-AR` where it writes `15 ene 1990` for `es`. Passing the API answer to a formatter demotes every regional visitor to the base language and nothing fails, so the two values are never interchangeable.\n */\n\nimport { API_LANGUAGES } from '../generated/api-languages.js';\n\n/**\n * The site-owner language for an element, resolved through the four-link chain the revamp design specifies.\n *\n * @remarks\n * 1. the element's own `lang` attribute (the explicit per-embed override),\n * 2. the nearest ancestor carrying `lang`, so one wrapper localizes a whole section,\n * 3. `document.documentElement.lang`, which is what makes this work on a real CMS with no markup change at all: WordPress emits `<html lang=\"es-AR\">` on every page of a Spanish site,\n * 4. nothing, which the callers read as English.\n *\n * All four links matter: with only the first, a component on a fully Spanish page renders English chrome and the only remedy is hand-editing every embed.\n *\n * `navigator.language` is deliberately NOT in the chain. It is the VISITOR's preference, not the site's: it fragments the API cache across every locale a visitor might carry and silently serves two people different content from the same URL.\n *\n * Link 2 uses `closest`, which stops at a shadow boundary. A component composed INSIDE another component's shadow root therefore cannot see the host page, which is why every composing component forwards `lang` to its children explicitly.\n */\nexport function resolveLang(el: HTMLElement): string | undefined {\n\t// Native accessor, never a Lit @property: declaring one would shadow\n\t// HTMLElement.lang and break the platform attribute for every consumer.\n\tif (el.lang) return el.lang;\n\tif (typeof document === 'undefined') return undefined;\n\tconst inherited = el.closest?.('[lang]')?.getAttribute('lang');\n\tif (inherited) return inherited;\n\treturn document.documentElement.lang || undefined;\n}\n\n/**\n * Which script a Chinese page is written in, read off the region it names.\n *\n * @remarks\n * Chinese is the one language the API keys by SCRIPT rather than by language alone, because `zh`\n * on its own does not say which of the two a reader can actually read. Real pages almost never\n * write the script: a Taiwanese site writes `zh-TW` and a mainland site writes `zh-CN`, which is\n * what the region-to-script correspondence every internationalisation library ships is for.\n * Without this step both of those degrade to English, which takes the whole Chinese audience off\n * the domains the API answers in Chinese at all.\n *\n * A bare `zh` with neither region nor script resolves to nothing on purpose: guessing a script for\n * a reader who did not name one picks characters half of them cannot read.\n */\nconst ZH_SCRIPT_BY_REGION: Readonly<Record<string, string>> = {\n\ttw: 'hant',\n\thk: 'hant',\n\tmo: 'hant',\n\tcn: 'hans',\n\tsg: 'hans',\n\tmy: 'hans',\n};\n\n/** The API's own spelling of a tag, matched case-insensitively, or undefined when it serves no such language. */\nfunction asApiLang(tag: string): string | undefined {\n\tconst wanted = tag.toLowerCase();\n\treturn API_LANGUAGES.find((l) => l.toLowerCase() === wanted);\n}\n\n/**\n * The value safe to put on `?lang=`, or `undefined` to leave the request on the API default.\n *\n * @remarks\n * Three steps, and the order is load-bearing the moment {@link resolveLang} starts reading `<html lang>`:\n *\n * - **A tag the API serves goes as it is**, matched without regard to case, so `zh-Hant` and `ZH-HANT` both send the spelling the API declares. This comes first because the next step would throw away the very subtag those tags are identified by.\n * - **Chinese resolves its script**, from an explicit script subtag or from the region ({@link ZH_SCRIPT_BY_REGION}), because that is where the language actually lives.\n * - **Everything else drops its region.** A regional tag is a 400, so a Spanish WordPress site would go from English-but-working to broken the day the language chain was completed. `es-AR`, `es-419` and `ES` all send `es`.\n *\n * **An unsupported language is omitted, not sent.** The chain surfaces whatever the host page carries, including languages the API does not translate, and an unlisted tag is the same 400. Omitting it degrades to English, which is the behaviour those pages already had.\n */\nexport function apiLang(el: HTMLElement): string | undefined {\n\tconst tag = resolveLang(el);\n\tif (!tag) return undefined;\n\tconst exact = asApiLang(tag);\n\tif (exact) return exact;\n\tconst parts = tag.toLowerCase().split('-');\n\tconst base = parts[0] as string;\n\tif (base === 'zh') {\n\t\tconst script =\n\t\t\tparts.find((p) => p === 'hans' || p === 'hant') ??\n\t\t\tZH_SCRIPT_BY_REGION[parts[1] ?? ''];\n\t\treturn script ? asApiLang(`zh-${script}`) : undefined;\n\t}\n\treturn asApiLang(base);\n}\n", "/**\n * Shared string helpers used across components. Single source of truth so the\n * same formatting rules apply to every key/label/title that surfaces in the\n * shadow tree.\n *\n * - `lookupKey`: the ONE normalizer every lookup table in this library is keyed\n * and read by (`tokens/index.ts` glyphs and abbreviations, `i18n/` chrome\n * strings).\n * - `capitalize`: title-cases the first character, lowercases the rest. A\n * DISPLAY helper only; it is not a lookup key (see `lookupKey`).\n * - `humanize`: turns an API key (`birth_date`, `birthDate`, `mahadasha-end`)\n * into a label suitable for display (\"Birth date\", \"Mahadasha end\").\n */\n\n/**\n * Fold a name to the canonical key its lookup table is stored under: lower case, every run of spaces, underscores and hyphens collapsed to one space, trimmed.\n *\n * @remarks\n * This exists because a GUESSED key spelling is a defect class this repo has now shipped twice. The glyph tables were keyed off whatever {@link capitalize} happened to produce (`North node`), while the API returns `North Node`, so every call site that reached the table without first calling `capitalize` missed and fell through to a fabricated abbreviation. Aspects hit the same wall from the other side: `/aspects` returns `SEMI SEXTILE` where synastry returns `SEMI_SEXTILE`.\n *\n * One normalizer, applied when a table is DEFINED and again when it is READ, removes the whole class: no call site has to remember a convention, and no table has to guess a spelling. Use it for every new table keyed by an API-supplied name.\n *\n * @example\n * ```ts\n * lookupKey('North Node'); // 'north node'\n * lookupKey('SEMI_SEXTILE'); // 'semi sextile'\n * lookupKey('semi-sextile'); // 'semi sextile'\n * ```\n */\nexport function lookupKey(s: string): string {\n\treturn s\n\t\t.toLowerCase()\n\t\t.replace(/[\\s_-]+/g, ' ')\n\t\t.trim();\n}\n\nexport function capitalize(s: string): string {\n\tif (!s) return '';\n\treturn s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n}\n\nexport function humanize(s: string): string {\n\treturn (\n\t\ts\n\t\t\t.replace(/[_-]+/g, ' ')\n\t\t\t.replace(/([a-z])([A-Z])/g, '$1 $2')\n\t\t\t// Split a trailing/embedded digit off a word so \"person1\" reads \"Person 1\"\n\t\t\t// and every group legend and field label spaces its ordinal.\n\t\t\t.replace(/([a-z])([0-9])/g, '$1 $2')\n\t\t\t.replace(/^\\w/, (c) => c.toUpperCase())\n\t);\n}\n", "/**\n * The chrome-string catalogue: one resolver reading one registry, so a translation can arrive from anywhere without a component changing.\n *\n * @remarks\n * **The key IS the canonical English string**, folded through {@link lookupKey}. There is no invented key vocabulary to keep in sync with the copy, which is the same rule the glyph tables in `tokens/index.ts` follow (they key off the exact value the API returns). Two consequences that are the whole point:\n *\n * - **English costs zero bytes.** A miss returns the source string, so the English build ships no catalogue at all, and a site that never loads a locale payload is byte-identical to one built before this file existed.\n * - **A missing translation degrades to English, never to a key.** The failure mode of a keyed catalogue is a raw `natal.tabs.wheel` on the page; here the worst case is the English word.\n *\n * **The registry lives on `globalThis`, not in module scope, because it has to.** Every `dist/cdn/components/*.js` is a self-contained IIFE with its own copy of this module, so a `Map` here would be invisible to the second component on the page. One global object, written by the locale payload and read by every bundle, is what makes `dist/cdn/locales/es.js` a single download that translates all of them.\n *\n * Load order is not guaranteed on a real host (WordPress enqueues scripts in an order the plugin does not fully control, and a payload may be deferred), so {@link onLocaleChange} lets an element that has already rendered in English re-render when its catalogue lands.\n */\n\nimport { lookupKey } from '../utils/string.js';\n\n/** Shared mutable state, addressed by a name rather than a module binding so every bundle on the page reaches the same object. */\ninterface LocaleRegistry {\n\t/** Language tag (lower case) to catalogue, keyed by {@link lookupKey} of the English source string. */\n\tcatalogs: Record<string, Record<string, string>>;\n\t/**\n\t * Language tag (lower case) to the API's field-label map: `fields` keyed by wire name,\n\t * `enums` keyed `{fieldName}.{value}`.\n\t *\n\t * A SEPARATE key space from `catalogs` on purpose. A chrome string is keyed by the English\n\t * text a component writes, which is a constant in our source; a field label is keyed by a\n\t * name that only the OpenAPI spec knows, computed per operation, so no catalogue keyed on\n\t * English source text can ever reach it. Same registry because the delivery problem is\n\t * identical (a payload that may land after first paint), so it reuses one global object and\n\t * one listener set rather than growing a second of each.\n\t */\n\tfieldLabels: Record<string, FieldLabels>;\n\t/** Language tags whose fetch is in flight or done, so N forms on a page cost ONE request. */\n\trequested: Set<string>;\n\t/** Elements waiting to re-render when a catalogue arrives. */\n\tlisteners: Set<() => void>;\n}\n\n/** The `/languages/field-labels` payload, minus the echoed `lang`. */\nexport interface FieldLabels {\n\tfields: Record<string, string>;\n\tenums: Record<string, string>;\n}\n\nconst GLOBAL_KEY = '__ROXY_UI_I18N__';\n\nfunction registry(): LocaleRegistry {\n\tconst holder = globalThis as unknown as Record<string, LocaleRegistry>;\n\tconst existing = holder[GLOBAL_KEY];\n\tif (existing) return existing;\n\tconst created: LocaleRegistry = {\n\t\tcatalogs: {},\n\t\tfieldLabels: {},\n\t\trequested: new Set(),\n\t\tlisteners: new Set(),\n\t};\n\tholder[GLOBAL_KEY] = created;\n\treturn created;\n}\n\n/**\n * Publish a catalogue for a language tag and wake every mounted element.\n *\n * @remarks\n * The catalogue is authored keyed by the English source string, exactly as it appears at the call site, and normalized here. That keeps the source file readable and diffable against the component that renders it, while the runtime lookup stays a single property read.\n *\n * This is the ONLY way into the registry, so a catalogue can later come from a static file, a server response, or a host page inlining a script tag, without a component knowing the difference.\n */\nexport function registerLocale(\n\tlang: string,\n\tcatalog: Record<string, string>,\n): void {\n\tconst reg = registry();\n\tconst normalized: Record<string, string> = {};\n\tfor (const [source, translated] of Object.entries(catalog)) {\n\t\tnormalized[lookupKey(source)] = translated;\n\t}\n\treg.catalogs[lang.toLowerCase()] = normalized;\n\tfor (const listener of reg.listeners) listener();\n}\n\n/**\n * Replace `{{name}}` placeholders. Copied from the API-side translator so both sides of the product interpolate identically; an unknown placeholder is left verbatim rather than blanked, so a typo in a catalogue is visible instead of silently eating the value.\n */\nexport function interpolate(\n\ttemplate: string,\n\tvars?: Record<string, string | number>,\n): string {\n\tif (!vars) return template;\n\treturn template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key: string) =>\n\t\tkey in vars ? String(vars[key] ?? '') : match,\n\t);\n}\n\n/**\n * The chrome string for `lang`, falling back to the English `source` it is keyed by.\n *\n * @remarks\n * A regional tag resolves against its base language, so `es-AR` and `es-419` both read the `es` catalogue and a site does not have to know which tags we happen to ship. An exact regional catalogue still wins if one is ever registered.\n */\nexport function translate(\n\tlang: string | undefined,\n\tsource: string,\n\tvars?: Record<string, string | number>,\n): string {\n\treturn interpolate(chromeLabel(lang, source) ?? source, vars);\n}\n\n/** A published chrome label, including translations equal to the source; absent on a miss. */\nexport function chromeLabel(\n\tlang: string | undefined,\n\tsource: string,\n): string | undefined {\n\tif (!lang) return undefined;\n\tconst { catalogs } = registry();\n\tconst tag = lang.toLowerCase();\n\tconst catalog = catalogs[tag] ?? catalogs[tag.split('-')[0] as string];\n\treturn catalog?.[lookupKey(source)];\n}\n\n/**\n * Publish a field-label map for a language tag and wake every mounted element.\n *\n * @remarks\n * Exported so a host that already has the payload (a server-rendered page, a test, a WordPress\n * plugin inlining it) can supply it without a network call, exactly as {@link registerLocale}\n * allows for chrome strings.\n */\nexport function registerFieldLabels(lang: string, labels: FieldLabels): void {\n\tconst reg = registry();\n\treg.fieldLabels[lang.toLowerCase()] = labels;\n\tfor (const listener of reg.listeners) listener();\n}\n\n/**\n * Read the registered field-label payload for `lang`, resolving regional tags against their base.\n *\n * @remarks\n * Shared by browser label lookups and build-time manifest generation after importing the locale\n * modules. Returns `undefined` when no payload is registered, leaving English fallback to callers.\n */\nexport function labelsFor(lang: string | undefined): FieldLabels | undefined {\n\tif (!lang) return undefined;\n\tconst { fieldLabels } = registry();\n\tconst tag = lang.toLowerCase();\n\treturn fieldLabels[tag] ?? fieldLabels[tag.split('-')[0] as string];\n}\n\n/**\n * The label for a request field name, or `undefined` when nothing has been published.\n *\n * @remarks\n * Returning `undefined` rather than the name is deliberate: the caller owns the fallback, which is\n * `humanize()`, and that keeps this resolver honest about what it actually knows. A form renders\n * identically to before until a payload arrives.\n */\nexport function fieldLabel(\n\tlang: string | undefined,\n\tname: string,\n): string | undefined {\n\treturn labelsFor(lang)?.fields[name];\n}\n\n/** The label for one selectable option, keyed `{fieldName}.{value}` as the API publishes it. */\nexport function optionLabel(\n\tlang: string | undefined,\n\tfield: string,\n\tvalue: string,\n): string | undefined {\n\treturn labelsFor(lang)?.enums[`${field}.${value}`];\n}\n\n/** Subscribe to catalogue arrivals. Returns the unsubscribe, so an element can drop it on disconnect. */\nexport function onLocaleChange(listener: () => void): () => void {\n\tconst { listeners } = registry();\n\tlisteners.add(listener);\n\treturn () => {\n\t\tlisteners.delete(listener);\n\t};\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { onLocaleChange } from './registry.js';\n\n/**\n * Re-renders its host when a chrome-string catalogue arrives.\n *\n * @remarks\n * Without this the catalogue would have to be on the page BEFORE the elements upgrade, which is not something a component can require of a real host. WordPress orders enqueued scripts by dependency and a site owner can add `defer` to any of them; a CDN embed is two independent `<script src>` tags. Any of those can land the locale payload after the first paint, and the visible result would be a chart that renders in English on a Spanish page for no reason the site owner can see or fix.\n *\n * Mirrors `MarkupDataController`: constructed in {@link RoxyDataElement}'s constructor, subscribes on connect, drops the subscription on disconnect. Registration is idempotent and a re-register of the same language simply re-renders, so a payload loaded twice is harmless.\n */\nexport class LocaleController implements ReactiveController {\n\tprivate readonly host: ReactiveControllerHost;\n\tprivate unsubscribe?: () => void;\n\n\tconstructor(host: ReactiveControllerHost) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.unsubscribe = onLocaleChange(() => this.host.requestUpdate());\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n}\n", "import { LitElement } from 'lit';\nimport { resolveLang } from './lang.js';\nimport { LocaleController } from './locale-controller.js';\nimport { translate } from './registry.js';\n\n/**\n * The base every element that writes WORDS extends: it resolves the page language and translates its own chrome.\n *\n * @remarks\n * This is deliberately smaller than {@link RoxyDataElement}, and the split is what makes the widgets translatable at all. `<roxy-endpoint-form>` and `<roxy-location-search>` are the two declared widgets: they fetch, they hold state, and they are NOT data components, so they cannot inherit the data base without dragging its controlled-mode hydration, its self-fetch controller and its own form rendering (which renders the form, so the form inheriting it would compose itself). They extended `LitElement` directly instead, which meant they had no `t()` and no {@link LocaleController}, so a Spanish page rendered a Spanish result card over an English form and neither widget re-rendered when a deferred locale payload landed.\n *\n * So the mechanism lives here ONCE and all three inherit it. There is no second translator, no second registry and no second way to resolve a language: adding one is how a catalogue entry and a call site drift apart.\n *\n * Two costs are why this is its own module rather than a second export of `utils/base-element.ts`. Every `dist/cdn/components/*.js` is a self-contained IIFE, so importing the data base into the city search would compile `FetchController`, `MarkupDataController` and the interpretation accordion into a bundle that uses none of them. And `utils/base-element.ts` imports THIS file, so putting the class there would close a cycle the moment a widget imported it.\n */\nexport abstract class RoxyLocalizedElement extends LitElement {\n\tconstructor() {\n\t\tsuper();\n\t\t// Re-render if a chrome-string catalogue lands after this element upgraded.\n\t\t// A host page loads the payload as its own script tag, so it can arrive\n\t\t// after first paint and there is nothing the site owner could do about it.\n\t\tnew LocaleController(this);\n\t}\n\n\t/**\n\t * The chrome string for this element's language, keyed by its own English source text.\n\t *\n\t * @remarks\n\t * Pass the English copy, never a key. With no catalogue registered the source string is returned unchanged, so an English page pays nothing and a language we do not ship degrades to English rather than to a visible key.\n\t *\n\t * Chrome only. A value the API returned (a planet, a sign, an aspect, a house system) is NOT translated here: it is rendered as the response carries it, so the words on the chart and the words in the response can never disagree. The same holds for a label derived from a spec field NAME through `humanize()`: a catalogue keyed on English source text cannot reach a string computed per response. A derived name is catalogued only where the set it comes from is CLOSED and small enough to enumerate against the spec, which is true of the nine form group names and of nothing else so far.\n\t *\n\t * @example\n\t * ```ts\n\t * this.t('Aspect grid'); // 'Cuadricula de aspectos' under lang=\"es\"\n\t * this.t('{{count}} planets', { count: 12 }); // '12 planetas'\n\t * ```\n\t */\n\tprotected t(source: string, vars?: Record<string, string | number>): string {\n\t\treturn translate(this.effectiveLang(), source, vars);\n\t}\n\n\t/** {@link RoxyLocalizedElement.t} as a value, bound once, for a shared render helper that has no host of its own and therefore cannot resolve a page language (`utils/hd-reading.ts`). Named `translator` and not `translate` because `HTMLElement.translate` is a real DOM property and shadowing it with a protected member makes every `@customElement` decorator in the library fail to typecheck. */\n\tprotected readonly translator = (\n\t\tsource: string,\n\t\tvars?: Record<string, string | number>,\n\t): string => this.t(source, vars);\n\n\t/**\n\t * Site-owner language for this element: the `lang` attribute, the nearest ancestor carrying one, or the document. Protected so a component that composes another can forward it (a child inside this shadow root cannot reach the host page on its own).\n\t *\n\t * Full tag, region included. The truncation to what `?lang=` accepts happens where the request is built, in `<roxy-endpoint-form>`.\n\t */\n\tprotected effectiveLang(): string | undefined {\n\t\treturn resolveLang(this);\n\t}\n}\n", "/**\n * Symbol constants used across components. Single source of truth so chart\n * wheels, card headers, hexagram displays, and panchang tables stay visually\n * consistent.\n *\n * @remarks\n * **Every table here is keyed by {@link lookupKey} and read ONLY through the accessor beside it.** The raw records are deliberately not exported: a component that indexes a record directly has to guess the key convention, and a guessed spelling renders `No North Node R`, `So South Node R` and `Bl Black Moon Lilith` on a live chart. The API returns `North Node` with a space, while {@link capitalize} produces `North node`, so a call site that indexes without normalising misses the table.\n *\n * **A miss returns `undefined`, never a manufactured abbreviation.** A `?? name.slice(0, 2)` fallback renders a failed lookup as a plausible two-letter code that reads exactly like an intentional abbreviation, so nothing about the output says it is broken. A caller that can omit the glyph should omit it (`?? ''`); a caller that must show something falls back to the FULL name, which is visibly wrong at the size these slots are drawn.\n *\n * `tests/tokens.test.ts` resolves every body, sign and aspect name the committed spec can emit against these tables, so a vocabulary the API gains cannot ship unglyphed.\n */\n\nimport { lookupKey } from '../utils/string.js';\n\n/** Look one name up in a normalized table. The single read path for every map in this file. */\nconst resolve = (\n\ttable: Record<string, string>,\n\tname: string | undefined | null,\n): string | undefined => (name ? table[lookupKey(name)] : undefined);\n\nconst PLANET_GLYPH: Record<string, string> = {\n\tsun: '☉',\n\tmoon: '☽',\n\tmercury: '☿',\n\tvenus: '♀',\n\tearth: '♁',\n\tmars: '♂',\n\tjupiter: '♃',\n\tsaturn: '♄',\n\turanus: '♅',\n\tneptune: '♆',\n\tpluto: '♇',\n\trahu: '☊',\n\tketu: '☋',\n\tascendant: 'Asc',\n\tmidheaven: 'MC',\n\t'part of fortune': '⊗',\n\tvertex: 'Vx',\n\tlagna: 'La',\n\t'north node': '☊',\n\t'south node': '☋',\n\tchiron: '⚷',\n\tlilith: '⚸',\n\t'black moon lilith': '⚸',\n};\n\n/** Astrological glyph for a planet or point, or `undefined` when the library has none for it. */\nexport const planetGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(PLANET_GLYPH, name);\n\nconst PLANET_ABBR: Record<string, string> = {\n\tsun: 'Su',\n\tmoon: 'Mo',\n\tmercury: 'Me',\n\tvenus: 'Ve',\n\tmars: 'Ma',\n\tjupiter: 'Ju',\n\tsaturn: 'Sa',\n\turanus: 'Ur',\n\tneptune: 'Ne',\n\tpluto: 'Pl',\n\trahu: 'Ra',\n\tketu: 'Ke',\n\tascendant: 'Asc',\n\tlagna: 'La',\n};\n\n/** Two-letter graha code for the tight cells of a North/South Indian kundli, or `undefined`. */\nexport const planetAbbr = (\n\tname: string | undefined | null,\n): string | undefined => resolve(PLANET_ABBR, name);\n\nconst SIGN_GLYPH: Record<string, string> = {\n\taries: '♈',\n\ttaurus: '♉',\n\tgemini: '♊',\n\tcancer: '♋',\n\tleo: '♌',\n\tvirgo: '♍',\n\tlibra: '♎',\n\tscorpio: '♏',\n\tsagittarius: '♐',\n\tcapricorn: '♑',\n\taquarius: '♒',\n\tpisces: '♓',\n};\n\n/** Zodiac glyph for a sign name in any case, or `undefined`. */\nexport const signGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(SIGN_GLYPH, name);\n\nconst SIGN_ABBR: Record<string, string> = {\n\taries: 'Ar',\n\ttaurus: 'Ta',\n\tgemini: 'Ge',\n\tcancer: 'Cn',\n\tleo: 'Le',\n\tvirgo: 'Vi',\n\tlibra: 'Li',\n\tscorpio: 'Sc',\n\tsagittarius: 'Sg',\n\tcapricorn: 'Cp',\n\taquarius: 'Aq',\n\tpisces: 'Pi',\n};\n\n/** Two-letter rashi code for kundli cells and grid headers, or `undefined`. */\nexport const signAbbr = (name: string | undefined | null): string | undefined =>\n\tresolve(SIGN_ABBR, name);\n\n/** The twelve signs in zodiacal order. Display values, not lookup keys: read them through {@link signGlyph} / {@link signAbbr}. */\nexport const SIGNS_ORDER = [\n\t'Aries',\n\t'Taurus',\n\t'Gemini',\n\t'Cancer',\n\t'Leo',\n\t'Virgo',\n\t'Libra',\n\t'Scorpio',\n\t'Sagittarius',\n\t'Capricorn',\n\t'Aquarius',\n\t'Pisces',\n] as const;\n\n/**\n * Glyph per aspect. Used by the natal, transit and synastry aspect tables.\n *\n * @remarks\n * These are the nine aspects Unicode itself defines as a set, in its Miscellaneous Symbols block note: `260C, 26BA, 2220, 26B9, 25A1, 25B3, 26BC, 26BB, 260D` for 0, 30, 45, 60, 90, 120, 135, 150 and 180 degrees. That is exactly the vocabulary the API returns, so every aspect resolves to a real glyph and none falls through to a truncated slug.\n *\n * Do not substitute the visually similar maths operators. Unicode lists `⊻` XOR and `⊼` NAND as cross-references FROM the real quincunx and semisextile glyphs, so they look like safe stand-ins and are easy to pair the wrong way round, which renders a 150 degree quincunx with the 30 degree semisextile symbol. An astrologer reads the glyph, not the tooltip.\n */\nconst ASPECT_SYMBOL: Record<string, string> = {\n\tconjunction: '☌',\n\tsemisextile: '⚺',\n\t'semi sextile': '⚺',\n\tsemisquare: '∠',\n\t'semi square': '∠',\n\tsextile: '⚹',\n\tsquare: '□',\n\ttrine: '△',\n\tsesquiquadrate: '⚼',\n\tquincunx: '⚻',\n\topposition: '☍',\n};\n\n/** Aspect glyph for any of the separator forms the endpoints use (`SEMI_SEXTILE`, `SEMI SEXTILE`, `semi-sextile`), or `undefined`. */\nexport const aspectSymbol = (\n\tname: string | undefined | null,\n): string | undefined => resolve(ASPECT_SYMBOL, name);\n\n/** Trigrams used by I Ching hexagrams. Eight trigrams compose 64 hexagrams. */\nconst TRIGRAM_GLYPH: Record<string, string> = {\n\theaven: '☰',\n\tlake: '☱',\n\tfire: '☲',\n\tthunder: '☳',\n\twind: '☴',\n\twater: '☵',\n\tmountain: '☶',\n\tearth: '☷',\n};\n\n/** Trigram glyph for a trigram name in any case, or `undefined`. */\nexport const trigramGlyph = (\n\tname: string | undefined | null,\n): string | undefined => resolve(TRIGRAM_GLYPH, name);\n\n/** Moon phase emoji set. Used by the moon phase card. */\nconst MOON_PHASE_EMOJI: Record<string, string> = {\n\t'new moon': '🌑',\n\t'waxing crescent': '🌒',\n\t'first quarter': '🌓',\n\t'waxing gibbous': '🌔',\n\t'full moon': '🌕',\n\t'waning gibbous': '🌖',\n\t'last quarter': '🌗',\n\t'waning crescent': '🌘',\n};\n\n/**\n * Emoji for a lunar phase, or `undefined`.\n *\n * @remarks\n * The live API suffixes most phase names (`Waxing Gibbous Moon`) and calls the third quarter `Third Quarter Moon`, while only new and full moon carry the suffix in the table. Both reconciliations live here rather than in the card, so any component reading a phase name resolves the same eight phases from the same four spellings.\n */\nexport const moonPhaseEmoji = (\n\tname: string | undefined | null,\n): string | undefined => {\n\tif (!name) return undefined;\n\tconst key = lookupKey(name);\n\tconst bare = key.replace(/ moon$/, '');\n\tconst alias = bare === 'third quarter' ? 'last quarter' : bare;\n\treturn MOON_PHASE_EMOJI[key] ?? MOON_PHASE_EMOJI[alias];\n};\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{--roxy-label-col:minmax(0, 25%);--_success-fg:var(--roxy-success-fg,#09632a);--_warning-fg:var(--roxy-warning-fg,#913304);--_danger-fg:var(--roxy-danger-fg,#881313);--_info-fg:var(--roxy-info-fg,#014f7a);font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([hidden]){display:none}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{transform:translateY(2px)}to{transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted,#71717a)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md,1rem)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm,.5rem);margin-top:var(--roxy-space-md,1rem);display:grid}.roxy-more .roxy-edit{min-height:44px}:host{font-variant-emoji:text}`;\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * The one place the \"publishable key only\" rule lives. Every client-side fetch boundary ({@link ../components/location-search.ts}, {@link ./fetch-controller.ts}) and the self-fetch form ({@link ../components/endpoint-form.ts}) call through here so a refused key is refused identically: no network call, the same visible message, the same `roxy-validation-error` event. Centralising it is what stops the paths drifting into different answers for the same key, one warning and fetching where another refuses.\n */\n\n/** The sample key every copy-paste snippet ships with; pages that offer a live key input search snippets for this exact string, so changing it breaks them. */\nexport const SAMPLE_PUBLISHABLE_KEY = 'pk_live_YOUR_KEY';\n\n/** Each reason a key is refused: the `roxy-validation-error` detail reason and the English source of the message, translated where it renders. */\nexport const KEY_REFUSALS = {\n\tsecret: {\n\t\treason: 'possible-secret-key',\n\t\tmessage:\n\t\t\t'Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.',\n\t},\n\tsample: {\n\t\treason: 'sample-key',\n\t\tmessage:\n\t\t\t'Replace the sample key with your own publishable key from your RoxyAPI account.',\n\t},\n} as const;\n\nexport type KeyRefusal = (typeof KEY_REFUSALS)[keyof typeof KEY_REFUSALS];\n\n/** Why a present key may not be sent (a secret or unprefixed key, or the snippet sample no account owns), or undefined when it may, an absent key included. */\nexport function keyRefusal(\n\tkey: string | undefined | null,\n): KeyRefusal | undefined {\n\tif (!key) return undefined;\n\tif (key === SAMPLE_PUBLISHABLE_KEY) return KEY_REFUSALS.sample;\n\treturn key.startsWith('pk_') ? undefined : KEY_REFUSALS.secret;\n}\n\n/** Dispatch the shared bubbling `roxy-validation-error` for a refused key, and log it once when `warn` is set; the caller shows the message and skips the fetch. */\nexport function dispatchKeyRefusal(\n\thost: EventTarget,\n\trefusal: KeyRefusal,\n\topts: { warn?: boolean } = {},\n): void {\n\tif (opts.warn) console.warn(refusal.message);\n\thost.dispatchEvent(\n\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\tdetail: { reason: refusal.reason, message: refusal.message },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t}),\n\t);\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n\tdispatchKeyRefusal,\n\ttype KeyRefusal,\n\tkeyRefusal,\n} from './key-guard.js';\n\n/**\n * Host slots the controller drives. {@link RoxyDataElement} satisfies this, so the form mixin can attach a controller without the component wiring state by hand.\n *\n * @remarks\n * Intersected with `HTMLElement` because the controller dispatches events on the host. Lit's `ReactiveControllerHost` is the update-lifecycle contract only (`addController`, `requestUpdate`, `updateComplete`) and carries no DOM surface, even though every real host is a `LitElement` and therefore an `HTMLElement`. Declaring the DOM half is what the controller actually needs, and it is declared rather than reached through a `this.host as unknown as EventTarget` double cast, which would assert a capability the type never promised.\n */\ntype FetchHost<T> = ReactiveControllerHost &\n\tHTMLElement & {\n\t\tdata: T | null;\n\t\tloading: boolean;\n\t\terror: string | null;\n\t\t/** The field-level issues of a rejected request, or null when the failure was not about the request body. */\n\t\tissues: ApiIssue[] | null;\n\t};\n\n/** One field the API rejected, as the API reports it: the wire path of the field (`year`, `person1.date`, `members.0.date`) and the reason. */\nexport interface ApiIssue {\n\tpath: string;\n\tmessage: string;\n}\n\n/** A failed request, read once: the message every failure carries and the per-field issues a validation failure adds. */\ninterface ApiFailure {\n\tmessage: string;\n\tissues: ApiIssue[] | null;\n\t/** False when the body carried no `error` sentence and the message is the status line. */\n\tworded: boolean;\n}\n\n/** The public API root, which a component overrides per instance through its `base-url` attribute; exported so every request names one origin. */\nexport const DEFAULT_BASE_URL = 'https://roxyapi.com/api/v2';\n\n/**\n * Turn a failed `Response` into the message to show: the API's own `{ error }` string when the body carries one, else the status line.\n *\n * @remarks\n * Exported so every client-side fetch boundary renders the same words for the same failure, the way {@link keyRefusal} centralizes the key refusal. A boundary that discards the response body cannot tell a rejected request from an empty result, and renders the two identically.\n */\nexport async function readApiError(res: Response): Promise<string> {\n\treturn (await readApiFailure(res)).message;\n}\n\n/**\n * The failure a response carries.\n *\n * @remarks\n * A rejected request answers `{ error, code, issues }`, and `issues` is what makes the error actionable: each names the field by its wire path, which is the same identity the form keys its inputs by, so the message can sit under the input it is about instead of in a banner quoting a path. Only a `validation_error` carries them; every other failure keeps the message alone.\n */\nasync function readApiFailure(res: Response): Promise<ApiFailure> {\n\ttry {\n\t\tconst body = (await res.json()) as {\n\t\t\terror?: string;\n\t\t\tcode?: string;\n\t\t\tissues?: Array<{ path?: unknown; message?: unknown }>;\n\t\t};\n\t\tif (body?.error) {\n\t\t\tconst issues =\n\t\t\t\tbody.code === 'validation_error' && Array.isArray(body.issues)\n\t\t\t\t\t? body.issues\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(i) =>\n\t\t\t\t\t\t\t\t\ttypeof i.path === 'string' && typeof i.message === 'string',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((i) => ({\n\t\t\t\t\t\t\t\tpath: i.path as string,\n\t\t\t\t\t\t\t\tmessage: i.message as string,\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t: null;\n\t\t\treturn {\n\t\t\t\tmessage: body.error,\n\t\t\t\tissues: issues?.length ? issues : null,\n\t\t\t\tworded: true,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Non-JSON error body: fall through to the status line.\n\t}\n\treturn {\n\t\tmessage: `Request failed (${res.status})`,\n\t\tissues: null,\n\t\tworded: false,\n\t};\n}\n\n/** A single request the controller issues on the component's behalf. */\nexport interface RoxyRequest {\n\t/** Path under the API base, e.g. \"/dreams/symbols/water\" or \"/astrology/natal-chart\". */\n\tpath: string;\n\tmethod?: 'GET' | 'POST';\n\t/** JSON body for POST endpoints. */\n\tbody?: unknown;\n\t/** Query string parameters; nullish values are dropped. */\n\tquery?: Record<string, string | number | undefined>;\n}\n\n/**\n * Where an element sends its requests: the key it may present, the API origin, and the host route that proxies them.\n *\n * @remarks\n * Every element that fetches holds these four, and {@link apiFetch} is the one function that turns them into a request, so a list that loads its next page, a form that loads its choices and a component that loads its result reach the API, or the host route standing in for it, the same way.\n */\nexport interface ApiRoute {\n\t/** Browser-safe publishable key; anything else is refused before a request is made. */\n\tpublishableKey?: string;\n\t/** API origin, absolute or relative to the page; {@link DEFAULT_BASE_URL} when unset. */\n\tbaseUrl?: string;\n\t/** Host route that holds the secret key. When set, the request is POSTed there as `{ path, method, body, query }` and no key leaves the browser. */\n\tsubmitUrl?: string;\n\t/** Object the host page attaches to a proxied request as `context`, passed through unread. */\n\tsubmitContext?: Record<string, unknown>;\n}\n\n/** A request the API answered with a failure: its own message, plus the fields it named when it rejected the request, and whether the message is a sentence it wrote rather than the status line. */\nexport class ApiError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly issues: ApiIssue[] | null = null,\n\t\treadonly worded = true,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\n/** The key refusal that applies to a route, or undefined when it may send; a proxy route holds its own key, so none applies there. */\nexport function routeRefusal(route: ApiRoute): KeyRefusal | undefined {\n\treturn route.submitUrl ? undefined : keyRefusal(route.publishableKey);\n}\n\n/** True when a route can reach the API at all: it carries a publishable key it may send, or a proxy route that holds one. */\nexport function canFetch(route: ApiRoute): boolean {\n\treturn !!(route.submitUrl || (route.publishableKey && !routeRefusal(route)));\n}\n\n/**\n * Send one request through a route and resolve to the JSON it answered.\n *\n * @remarks\n * The one place a request is built, so the key refusal, the proxy body and the failure reading cannot drift between the elements that fetch. A refused key throws before anything is sent; a failed response throws an {@link ApiError} carrying the API message and, for a rejected body, the fields it named.\n */\nexport async function apiFetch<T>(\n\troute: ApiRoute,\n\treq: RoxyRequest,\n\tsignal?: AbortSignal,\n): Promise<T> {\n\tconst refusal = routeRefusal(route);\n\tif (refusal) throw new ApiError(refusal.message);\n\tconst res = route.submitUrl\n\t\t? await fetch(route.submitUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t},\n\t\t\t\tbody: proxyBody(req, route.submitContext),\n\t\t\t\tsignal,\n\t\t\t})\n\t\t: await callApi(route, req, signal);\n\tif (!res.ok) {\n\t\tconst failure = await readApiFailure(res);\n\t\tthrow new ApiError(failure.message, failure.issues, failure.worded);\n\t}\n\treturn (await res.json()) as T;\n}\n\n/**\n * The body of a proxied POST: the request, plus the host context under `context` when one is set.\n *\n * @remarks\n * The context is appended rather than declared on {@link RoxyRequest}, so with none set the payload is the request object itself and every route already written against it keeps receiving the same four keys in the same order. A `null` or an empty object would be a fifth key such a route never agreed to read.\n */\nfunction proxyBody(\n\treq: RoxyRequest,\n\tcontext?: Record<string, unknown>,\n): string {\n\treturn JSON.stringify(context ? { ...req, context } : req);\n}\n\n/** Direct call against RoxyAPI with the publishable key (the no-backend path). */\nfunction callApi(\n\troute: ApiRoute,\n\treq: RoxyRequest,\n\tsignal?: AbortSignal,\n): Promise<Response> {\n\t// Resolved against the page, so a same-origin base (\"/api/roxy\") is as valid as an\n\t// absolute one. Every route a host page can name resolves the same way, and a bare\n\t// `new URL()` would reject the relative shape with an opaque \"Invalid URL\".\n\tconst url = new URL(\n\t\t`${route.baseUrl ?? DEFAULT_BASE_URL}${req.path}`,\n\t\tdocument.baseURI,\n\t);\n\tfor (const [k, v] of Object.entries(req.query ?? {})) {\n\t\tif (v != null) url.searchParams.set(k, String(v));\n\t}\n\tconst headers: Record<string, string> = { Accept: 'application/json' };\n\tif (route.publishableKey) headers['X-API-Key'] = route.publishableKey;\n\tif (req.body != null) headers['Content-Type'] = 'application/json';\n\treturn fetch(url, {\n\t\tmethod: req.method ?? 'GET',\n\t\theaders,\n\t\tbody: req.body != null ? JSON.stringify(req.body) : undefined,\n\t\tsignal,\n\t});\n}\n\n/**\n * Client-side fetch for uncontrolled (self-fetching) components: drives `host.data` / `host.loading` / `host.error` and cancels a stale request when a newer one starts or the host disconnects.\n *\n * @remarks\n * Security boundary. The only credential this ever sends is a `pk_` publishable key, which carries a server-side origin allowlist. A secret (`sk_`), legacy unprefixed or sample key is refused before any network call and surfaced as an error, so a server secret cannot leak into a browser request. The request itself goes through {@link apiFetch}, which every other fetch on an element shares.\n *\n * Controlled-mode components never construct this. When a server injects the response as a `<script class=\"roxy-data\">` island, there is no key and no fetch, which is the path server-rendered consumers (WordPress, JSX SSR, static HTML) rely on.\n */\nexport class FetchController<T = unknown>\n\timplements ReactiveController, ApiRoute\n{\n\tprivate readonly host: FetchHost<T>;\n\tprivate abort?: AbortController;\n\n\t/** Browser-safe publishable key. Set by the host from its `publishable-key` attribute. */\n\tpublishableKey?: string;\n\t/** API origin, overridable for self-hosted or proxied deployments. */\n\tbaseUrl = DEFAULT_BASE_URL;\n\t/** Consumer backend route that holds the secret key, set from the host `submit-url` attribute; see {@link ApiRoute.submitUrl}. */\n\tsubmitUrl?: string;\n\t/** Object the host page attaches to the proxied request, set from its `submit-context` attribute; see {@link ApiRoute.submitContext}. */\n\tsubmitContext?: Record<string, unknown>;\n\t/** False when the last failure carried no sentence of its own: a dropped connection, or a body with no `error`. */\n\tworded = true;\n\n\tconstructor(host: FetchHost<T>) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected() {\n\t\tthis.abort?.abort();\n\t\tthis.abort = undefined;\n\t}\n\n\t/**\n\t * Issue the request and resolve once `host.data` (success) or `host.error`\n\t * (failure) is set. A no-op return when the key is refused: the error is\n\t * already surfaced and nothing is sent.\n\t */\n\tasync run(req: RoxyRequest): Promise<void> {\n\t\tthis.worded = true;\n\t\tconst refusal = routeRefusal(this);\n\t\tif (refusal) {\n\t\t\tthis.host.error = refusal.message;\n\t\t\tdispatchKeyRefusal(this.host, refusal);\n\t\t\treturn;\n\t\t}\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.host.loading = true;\n\t\tthis.host.error = null;\n\t\tthis.host.issues = null;\n\t\ttry {\n\t\t\tconst json = await apiFetch<T>(this, req, controller.signal);\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.host.data = json;\n\t\t} catch (err) {\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tif ((err as { name?: string })?.name === 'AbortError') return;\n\t\t\tif (err instanceof ApiError) this.host.issues = err.issues;\n\t\t\tthis.worded = err instanceof ApiError && err.worded;\n\t\t\tthis.host.error = err instanceof Error ? err.message : String(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) this.host.loading = false;\n\t\t}\n\t}\n}\n\n/**\n * Translate flat form values into a {@link RoxyRequest} for an endpoint. The `{name}` segments in the endpoint template are substituted from the values and removed; the rest become the JSON body for POST or query parameters for GET. This is the spec-light request builder the base element uses to turn a `<roxy-endpoint-form>` submission into a self-fetch, so a component needs no per-endpoint glue.\n *\n * @param queryKeys - Names the spec declares as `in: query` for this operation, which `<roxy-endpoint-form>` reports on its `roxy-submit` event. A POST operation can still take query parameters (every localized endpoint takes `?lang=`), and sending one in the JSON body silently drops it, so those names are routed to the query string on POST as well as GET.\n */\nexport function buildRequest(\n\tendpoint: string,\n\tmethod: 'GET' | 'POST',\n\tvalues: Record<string, unknown>,\n\tqueryKeys: readonly string[] = [],\n): RoxyRequest {\n\tconst rest: Record<string, unknown> = { ...values };\n\tconst path = `/${endpoint.replace(/^\\//, '')}`.replace(\n\t\t/\\{([^}]+)\\}/g,\n\t\t(_match, name: string) => {\n\t\t\tconst v = rest[name];\n\t\t\tdelete rest[name];\n\t\t\treturn encodeURIComponent(String(v ?? ''));\n\t\t},\n\t);\n\tconst inQuery = new Set(queryKeys);\n\tconst query: Record<string, string | number | undefined> = {};\n\tconst body: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(rest)) {\n\t\tif (v === undefined || v === '') continue;\n\t\tif (method === 'GET' || inQuery.has(k)) query[k] = v as string | number;\n\t\telse body[k] = v;\n\t}\n\treturn { path, method, query, body: method === 'POST' ? body : undefined };\n}\n", "// Generated by scripts/sync-bindings.ts (bindings.config.ts joined with specs/openapi.json). Do not edit.\n\nimport type { FieldCondition, OptionSource } from '../utils/field-schema.js';\n\n/** `METHOD /path` of a bound operation -> request field -> the collection its choices are read from. */\nexport const OPTION_SOURCES: Record<string, Record<string, OptionSource>> = {\n \"GET /angel-numbers/numbers/{number}\": {\n \"number\": {\n \"path\": \"/angel-numbers/numbers\",\n \"limit\": 50,\n \"lang\": true\n }\n },\n \"GET /astrology/planet-meanings/{id}\": {\n \"id\": {\n \"path\": \"/astrology/planet-meanings\",\n \"lang\": true\n }\n },\n \"GET /astrology/signs/{id}\": {\n \"id\": {\n \"path\": \"/astrology/signs\",\n \"lang\": true\n }\n },\n \"GET /crystals\": {\n \"color\": {\n \"path\": \"/crystals/colors\",\n \"lang\": true\n },\n \"planet\": {\n \"path\": \"/crystals/planets\",\n \"lang\": true\n }\n },\n \"GET /crystals/{id}\": {\n \"id\": {\n \"path\": \"/crystals\",\n \"limit\": 100,\n \"lang\": true\n }\n },\n \"GET /dreams/symbols\": {\n \"letter\": {\n \"path\": \"/dreams/symbols/letters\"\n }\n },\n \"GET /dreams/symbols/{id}\": {\n \"id\": {\n \"path\": \"/dreams/symbols\",\n \"search\": \"q\",\n \"limit\": 50\n }\n },\n \"GET /iching/trigrams/{id}\": {\n \"id\": {\n \"path\": \"/iching/trigrams\",\n \"lang\": true\n }\n },\n \"GET /tarot/cards/{id}\": {\n \"id\": {\n \"path\": \"/tarot/cards\",\n \"limit\": 100,\n \"lang\": true\n }\n }\n};\n\n/** `METHOD /path` of a bound operation -> request field -> the other field and value that disable it. */\nexport const DISABLED_WHEN: Record<string, Record<string, FieldCondition>> = {\n \"GET /tarot/cards\": {\n \"suit\": {\n \"field\": \"arcana\",\n \"value\": \"major\"\n }\n }\n};\n", "/**\n * Pure, framework-free schema layer shared by the self-fetch form. It turns one OpenAPI operation into a digested list of {@link FieldDef}s whose {@link InputKind} decides which input widget renders, with zero Lit or DOM dependency so the build-time slice generator ({@link ../../../scripts/build-schemas.ts}) and the taxonomy-coverage test consume the exact same classification the browser does.\n *\n * @remarks\n * The registry is by SHAPE, never by name: {@link classifyInput} inspects `enum` / `type` / `format` only, so a new API parameter gets a working widget with no code change, and the taxonomy gate fails loudly (via a `null` return) the day a genuinely new shape appears. Name-driven render intent (hidden values, city searches and the Advanced fold) is resolved here too, so browser and server renderers consume the same decisions.\n */\n\nimport { EN_FIELD_LABELS } from '../generated/field-labels-en.js';\nimport { DISABLED_WHEN, OPTION_SOURCES } from '../generated/option-sources.js';\nimport { chromeLabel, fieldLabel, interpolate } from '../i18n/registry.js';\nimport { SIGNS_ORDER } from '../tokens/index.js';\nimport { humanize } from './string.js';\n\n/** A JSON `$ref` node, before resolution against `components.schemas`. */\nexport interface OpenApiSchemaRef {\n\t$ref?: string;\n}\n\n/** The subset of an OpenAPI 3 schema object the form reads. */\nexport interface OpenApiSchema extends OpenApiSchemaRef {\n\t/** A plain name in 3.0, or an ARRAY in 3.1 where nullability is spelled `['number', 'null']`. Read it through {@link scalarType}, never compare it directly. */\n\ttype?: string | string[];\n\tformat?: string;\n\tdescription?: string;\n\tenum?: string[];\n\tdefault?: unknown;\n\tminimum?: number;\n\tmaximum?: number;\n\texclusiveMinimum?: number;\n\texclusiveMaximum?: number;\n\tpattern?: string;\n\tproperties?: Record<string, OpenApiSchema>;\n\trequired?: string[];\n\titems?: OpenApiSchema;\n\tminItems?: number;\n\tmaxItems?: number;\n\texample?: unknown;\n\tanyOf?: OpenApiSchema[];\n\toneOf?: OpenApiSchema[];\n}\n\n/** One operation's request shape, as read from `spec.paths[path][method]`. */\nexport interface OperationSchema {\n\toperationId?: string;\n\tsummary?: string;\n\t/** Input sets of an either-or body; read into {@link FormModel.requiredAnyOf}. */\n\t'x-required-any-of'?: string[][];\n\trequestBody?: {\n\t\tcontent?: Record<string, { schema?: OpenApiSchema | OpenApiSchemaRef }>;\n\t};\n\tparameters?: Array<{\n\t\tname: string;\n\t\tin: string;\n\t\tdescription?: string;\n\t\trequired?: boolean;\n\t\tschema?: OpenApiSchema;\n\t}>;\n}\n\n/** The minimal OpenAPI document surface the form introspects. */\nexport interface OpenApiDoc {\n\tpaths?: Record<string, Record<string, unknown>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/** The fully typed spec document the build-time scripts read from the committed `specs/openapi.json`: every path item value is an {@link OperationSchema}. The runtime form keeps the looser {@link OpenApiDoc} because a live spec fetch is untrusted input it narrows per operation. */\nexport interface SpecDoc {\n\tpaths: Record<string, Record<string, OperationSchema>>;\n\tcomponents?: { schemas?: Record<string, OpenApiSchema> };\n}\n\n/**\n * The widget kind a parameter resolves to. This is the closed set the taxonomy gate enforces: every request parameter in the spec MUST classify to one of these, or {@link classifyInput} returns `null` and the gate fails, forcing a conscious decision when the API grows a new shape.\n */\nexport type InputKind =\n\t| 'tiles'\n\t| 'select'\n\t| 'toggle'\n\t| 'date'\n\t| 'time'\n\t| 'datetime'\n\t| 'number'\n\t| 'text'\n\t| 'array';\n\n/** A single input the form renders, digested from one schema property or parameter. */\nexport interface FieldDef {\n\t/** Unique storage + input key: the property name, or \"group.name\" for a nested object field. */\n\tkey: string;\n\t/** Schema property name (the label source), e.g. \"date\". */\n\tname: string;\n\t/** Contextual English label, overriding the generic name label when it loses the field's meaning. */\n\tlabel?: string;\n\t/** Parent object key for a nested schema (person1/person2); undefined for a flat field. */\n\tgroup?: string;\n\t/** True when the spec declares the field as `in: query`, so it belongs in the query string even on a POST. */\n\tinQuery?: boolean;\n\t/** The resolved widget kind. */\n\tkind: InputKind;\n\trequired: boolean;\n\tdescription?: string;\n\tenum?: string[];\n\tmin?: number;\n\tmax?: number;\n\tdefault?: unknown;\n\t/** Spec `example`, used as the placeholder for a text input. */\n\texample?: unknown;\n\t/** Where the choices for this field are listed, when the API serves them; the form reads them at run time. */\n\tsource?: OptionSource;\n\t/** Hidden value or coordinate supplied by a group's city box; absent for a visible input. */\n\trole?: 'seed' | 'hidden-default' | 'location';\n\t/** A visible timezone input is a city picker writing an IANA zone, never a typed offset. */\n\tcity?: true;\n\t/** True when this input (or its whole group) belongs under Advanced. */\n\tfold?: true;\n\t/** The other field and value that disable this one, when its binding declares them. */\n\tdisabledWhen?: FieldCondition;\n}\n\n/** One request field holding one value: the condition under which a bound form disables another field. */\nexport interface FieldCondition {\n\tfield: string;\n\tvalue: string;\n}\n\n/**\n * A GET collection on the API that lists the choices for one request field.\n *\n * @remarks\n * Two kinds reach a form, both resolved at build time into `generated/option-sources.ts`: a filter whose values the API serves as a list of their own (the letters the dream dictionary holds, the colours the crystal list filters on), and a free-string path identifier (`/dreams/symbols/{id}`), whose choices are the collection one segment up. The spec stays UI-agnostic either way: the first is a hint declared in `scripts/bindings.config.ts`, the second is derived from the paths.\n */\nexport interface OptionSource {\n\t/** Path of the collection, leading slash. */\n\tpath: string;\n\t/** The query parameter that searches the collection, when it has one; absent, the whole collection is read once and filtered as the visitor types. */\n\tsearch?: string;\n\t/** The largest page the collection serves, so a read asks for as much of it as one request allows. */\n\tlimit?: number;\n\t/** True when the collection takes `?lang=`, so its names arrive in the page language. */\n\tlang?: true;\n}\n\n/** One choice a field offers: the wire value, the words a visitor reads, and whether it can be picked. */\nexport interface FieldOption {\n\tvalue: string;\n\tlabel: string;\n\tdisabled?: boolean;\n}\n\n/**\n * A request property that is an ARRAY of objects, each a card of its own on the form.\n *\n * @remarks\n * A penta takes three to five birth records and a custom spread one to ten positions. The item schema expands into one group per record, keyed `{key}.{index}` so the group machinery (legend, city search, validation) treats each record like a `person1`; the model carries `min` records and the form grows to `max`. A comma-separated text box cannot take a birth record, which is what this exists to replace.\n */\nexport interface RepeatDef {\n\t/** The array property name on the wire, e.g. `members`. */\n\tkey: string;\n\tmin: number;\n\tmax: number;\n}\n\n/** One field group, in field order. An absent key denotes the flat top level. */\nexport interface FormGroup {\n\tkey?: string;\n\t/** English legend for a named group; absent for the unlabelled flat top level. */\n\tlabel?: string;\n\tfold?: true;\n\t/** A coordinate pair's city box, with the exact wire keys it fills (including its claimed timezone). */\n\tlocation?: { fields: string[]; required: boolean };\n}\n\n/** The digested form model shared by browser slices and platform-neutral manifests. */\nexport interface FormModel {\n\t/** Concise heading derived from the operation summary, falling back to the path. */\n\ttitle: string;\n\t/** Every request field, including hidden defaults and city-filled coordinates. The `lang` query parameter is intentionally excluded (routed via the element `lang` attribute instead). */\n\tfields: FieldDef[];\n\t/** True when the operation carries a `lang` query parameter, so the form knows to route an effective language to the query string on submit. */\n\thasLang: boolean;\n\t/** Resolved render intent. Optional only for older slices; normalize with withRenderIntent. */\n\tgroups?: FormGroup[];\n\t/** Whether a GET can open on its result without visitor input. */\n\topensOnLoad?: boolean;\n\t/** The array-of-object properties, each already expanded into `min` groups inside `fields`. Absent when the request has none. */\n\trepeats?: RepeatDef[];\n\t/** Wire-key sets of an either-or body: any ONE complete set is a valid request. The first set is the one the form asks for, so its fields are marked `required`. Absent when the request has none. */\n\trequiredAnyOf?: string[][];\n}\n\n/** The group key of the `index`th record of a repeating property, and its inverse. */\nexport const repeatGroup = (key: string, index: number): string =>\n\t`${key}.${index}`;\nexport function parseRepeatGroup(\n\tgroup: string,\n): { key: string; index: number } | null {\n\tconst m = /^(.+)\\.(\\d+)$/.exec(group);\n\treturn m ? { key: m[1] as string, index: Number(m[2]) } : null;\n}\n\n/**\n * A group legend, shared by the browser and published labels. Named objects use the chrome\n * catalogue (whose lookup folds case); repeating records use the array's field label and the\n * catalogued numbered-group template. The defaults produce the same legend in English.\n *\n * Catalogue lookup folds case: `humanize('natalChart')` produces `Natal Chart` and reuses\n * the existing `Natal chart` heading translation. Do not add a capitalized twin, which\n * would overwrite that heading in every locale. A new group with no catalogue entry\n * falls back to its humanized English name, so a missing translation never leaves a key\n * or an empty legend inside translated location labels.\n */\nexport function deriveGroupLabel(\n\tgroup: string,\n\tt: typeof interpolate = interpolate,\n\tfieldText: (name: string) => string = (name) =>\n\t\tEN_FIELD_LABELS[name] ?? humanize(name),\n): string {\n\tconst repeat = parseRepeatGroup(group);\n\treturn repeat\n\t\t? t('{{group}} {{n}}', {\n\t\t\t\tgroup: fieldText(repeat.key),\n\t\t\t\tn: repeat.index + 1,\n\t\t\t})\n\t\t: t(humanize(group));\n}\n\n/**\n * A published label for a model field. Contextual identifier nouns use the existing chrome\n * catalogue; coordinates use their full wire-name label from the API. Missing nouns must\n * stay absent rather than degrading to the generic ID label. Server consumers own English fallback.\n */\nexport function translatedFieldLabel(\n\tlang: string | undefined,\n\tfield: Pick<FieldDef, 'name' | 'label'> & Partial<Pick<FieldDef, 'key'>>,\n): string | undefined {\n\tconst wireName = field.key ?? field.name;\n\tif (splitCoordinateName(wireName)) return fieldLabel(lang, wireName);\n\tif (!field.label) return fieldLabel(lang, field.name);\n\treturn chromeLabel(lang, field.label);\n}\n\n/** The fields of one record of a repeating property, from the fields of its first record. Every record is the same template, so the form grows a repeat by re-keying record zero. */\nexport function repeatFields(\n\tfields: readonly FieldDef[],\n\tkey: string,\n\tindex: number,\n): FieldDef[] {\n\tconst first = repeatGroup(key, 0);\n\treturn fields\n\t\t.filter((f) => f.group === first)\n\t\t.map((f) => ({\n\t\t\t...f,\n\t\t\tkey: `${repeatGroup(key, index)}.${f.name}`,\n\t\t\tgroup: repeatGroup(key, index),\n\t\t}));\n}\n\n/**\n * Tiles or a select for a set of choices, decided by their SHAPE: a letter or a two-character code is a narrow tile, so up to thirty fit a row the way an index bar does, while a word or a name keeps the twelve a zodiac grid needs and anything longer is a select.\n */\nexport function optionKind(values: readonly string[]): 'tiles' | 'select' {\n\treturn values.length <= (isIndex(values) ? 30 : 12) ? 'tiles' : 'select';\n}\n\n/** True for choices that read as an index (letters, two-character codes) rather than words. */\nexport function isIndex(values: readonly string[]): boolean {\n\treturn values.every((v) => v.length <= 2);\n}\n\n/** The latitude+longitude+timezone trio the form suppresses in favour of a city search. Centralised so the render path and tests agree. */\nexport const LOCATION_TRIO = ['latitude', 'longitude', 'timezone'] as const;\n\n/**\n * The coordinate pair that DEFINES a location group. `timezone` is deliberately absent.\n *\n * @remarks\n * A group qualifies for a city search on latitude+longitude alone, because a timezone is not always\n * part of the group that owns the coordinates: `generateRelocationChart` carries two coordinate\n * pairs and exactly ONE top-level `timezone`, which is the BIRTH timezone (relocating does not move\n * the birth moment), so the relocation pair correctly has no timezone of its own. Requiring all\n * three would leave that operation rendering raw number inputs, which is the bug this exists to\n * prevent.\n */\nexport const LOCATION_PAIR = ['latitude', 'longitude'] as const;\n\n/**\n * Split a flat coordinate property into its group prefix and canonical leaf name, or `null` when the\n * name is not a prefixed coordinate.\n *\n * @remarks\n * **Two shapes carry two locations in one request and this handles the second one.** Most\n * multi-location operations nest per person (`person1`/`person2`, `personA`/`personB`), so object\n * nesting alone already groups them. `generateRelocationChart` is the only operation in the spec\n * that instead puts both pairs at the TOP level and distinguishes them by a name prefix\n * (`birthLatitude` / `relocationLatitude`). Keying the grouping off the prefix as well as off the\n * nesting means both shapes converge on the same group machinery, and a future `partnerLatitude`\n * needs no code change.\n *\n * Matching is deliberately restricted to the coordinate pair. A prefix is NOT harvested from any\n * other field name, so `birthDate` stays an ordinary field in the flat group and does not invent a\n * phantom `birth` group with a lone date in it.\n */\nfunction splitCoordinateName(\n\tname: string,\n): { group: string; leaf: (typeof LOCATION_PAIR)[number] } | null {\n\tconst m = name.match(/^(.+?)(Latitude|Longitude)$/);\n\tif (!m) return null;\n\treturn {\n\t\tgroup: m[1],\n\t\tleaf: m[2].toLowerCase() as (typeof LOCATION_PAIR)[number],\n\t};\n}\n\n/** Canonical lowercase zodiac set, derived from {@link SIGNS_ORDER} so sign detection and the glyph map can never disagree. */\nconst ZODIAC_LOWER = SIGNS_ORDER.map((s) => s.toLowerCase());\n\n/** Resolve a `$ref` (one hop is all the spec uses) against the schema map; pass non-refs through. */\nexport function resolveSchema(\n\tschema: OpenApiSchema | OpenApiSchemaRef | undefined,\n\tall: Record<string, OpenApiSchema>,\n): OpenApiSchema | undefined {\n\tif (!schema) return undefined;\n\tif ('$ref' in schema && schema.$ref) {\n\t\tconst name = schema.$ref.split('/').pop();\n\t\treturn name ? all[name] : undefined;\n\t}\n\treturn schema as OpenApiSchema;\n}\n\n/**\n * Collapse an `anyOf`/`oneOf` union to the single member that decides the widget: an enum member wins (so `houseSystem` as enum-or-string renders as a picker), then any concrete-typed member (so timezone as number-or-string resolves to a real kind), else the first member. Non-union schemas pass through untouched.\n */\nfunction representative(s: OpenApiSchema): OpenApiSchema {\n\tconst union = s.anyOf ?? s.oneOf;\n\tif (!union || union.length === 0) return s;\n\treturn (\n\t\tunion.find((m) => Array.isArray(m.enum)) ??\n\t\tunion.find((m) => scalarType(m) && scalarType(m) !== 'null') ??\n\t\tunion[0] ??\n\t\ts\n\t);\n}\n\n/**\n * Map one resolved schema to its {@link InputKind}, or `null` when the shape is genuinely unhandled. The form treats `null` as a plain text fallback (never crashes); the taxonomy gate treats it as a failure (forces a decision). Object schemas are never passed here: an object with `properties` expands into a group of leaf fields upstream, so it has no leaf kind of its own.\n */\n/**\n * The single scalar type name a schema resolves to, across both OpenAPI spellings.\n *\n * @remarks\n * OpenAPI 3.1 expresses a nullable scalar as `type: ['number', 'null']` where 3.0 wrote `type: 'number', nullable: true`. Every direct `type === 'number'` comparison silently stops matching the day the served document switches, and the field then classifies as UNHANDLED rather than as a number, which is how a whole form degrades to text boxes without one test noticing. The `null` member carries no input information, so the remaining single member IS the type.\n */\nexport function scalarType(s: OpenApiSchema): string | undefined {\n\tif (typeof s.type === 'string') return s.type;\n\tif (!Array.isArray(s.type)) return undefined;\n\tconst real = s.type.filter((t) => t !== 'null');\n\treturn real.length === 1 ? real[0] : undefined;\n}\n\nexport function classifyInput(schema: OpenApiSchema): InputKind | null {\n\tconst s = representative(schema);\n\tconst type = scalarType(s);\n\tif (Array.isArray(s.enum)) return optionKind(s.enum);\n\tif (type === 'boolean') return 'toggle';\n\tif (s.format === 'date') return 'date';\n\tif (s.format === 'time') return 'time';\n\tif (s.format === 'date-time') return 'datetime';\n\tif (type === 'integer' || type === 'number') return 'number';\n\tif (type === 'string') return 'text';\n\tif (type === 'array') return 'array';\n\treturn null;\n}\n\n/** True when an enum's values are exactly the twelve zodiac signs (case-insensitive), so the tiles can carry sign glyphs. */\nexport function isZodiacEnum(values: readonly string[]): boolean {\n\tif (values.length !== 12) return false;\n\tconst lower = new Set(values.map((v) => v.toLowerCase()));\n\treturn ZODIAC_LOWER.every((s) => lower.has(s));\n}\n\n/** One digested leaf field from a resolved schema. Shared by the flat and grouped construction paths so params and body props carry identical metadata (min/max included). */\nfunction toField(\n\tname: string,\n\tresolved: OpenApiSchema,\n\topts: { key: string; group?: string; required: boolean; inQuery?: boolean },\n): FieldDef {\n\tconst rep = representative(resolved);\n\treturn {\n\t\tkey: opts.key,\n\t\tname,\n\t\tgroup: opts.group,\n\t\tinQuery: opts.inQuery,\n\t\tkind: classifyInput(resolved) ?? 'text',\n\t\trequired: opts.required,\n\t\tdescription: rep.description ?? resolved.description,\n\t\tenum: rep.enum,\n\t\t// HTML has no exclusive bound, so an exclusive one is the nearest an input can state; the API refuses the bound itself and prints why under the field.\n\t\tmin: rep.minimum ?? rep.exclusiveMinimum,\n\t\tmax: rep.maximum ?? rep.exclusiveMaximum,\n\t\tdefault: resolved.default ?? rep.default,\n\t\texample: resolved.example ?? rep.example,\n\t};\n}\n\n/**\n * Digest one operation into the {@link FormModel} the form renders. This is the single construction path: body properties (nested objects expand to `group.sub` keys) and path+query parameters flow through {@link toField} identically, so a query integer keeps its min/max the same as a body integer. The `lang` query parameter is dropped from `fields` and surfaced as {@link FormModel.hasLang} instead.\n */\nexport function buildFormModel(\n\top: OperationSchema,\n\tschemas: Record<string, OpenApiSchema>,\n\tendpoint: string,\n\tmethod: string = op.requestBody ? 'POST' : 'GET',\n): FormModel {\n\tconst fields: FieldDef[] = [];\n\tconst repeats: RepeatDef[] = [];\n\tlet hasLang = false;\n\n\tconst bodyRef = op.requestBody?.content?.['application/json']?.schema;\n\tconst bodySchema = resolveSchema(bodyRef, schemas);\n\tconst anyOf = op['x-required-any-of'];\n\tif (bodySchema?.properties) {\n\t\tconst required = new Set([\n\t\t\t...(bodySchema.required ?? []),\n\t\t\t...(anyOf?.[0] ?? []),\n\t\t]);\n\t\tfor (const [name, sub] of Object.entries(bodySchema.properties)) {\n\t\t\tconst resolved = resolveSchema(sub, schemas) ?? {};\n\t\t\tconst item =\n\t\t\t\tresolved.type === 'array'\n\t\t\t\t\t? resolveSchema(resolved.items, schemas)\n\t\t\t\t\t: undefined;\n\t\t\tif (item?.type === 'object' && item.properties) {\n\t\t\t\tconst min = Math.max(1, resolved.minItems ?? 1);\n\t\t\t\tconst itemRequired = new Set(item.required ?? []);\n\t\t\t\trepeats.push({ key: name, min, max: resolved.maxItems ?? min });\n\t\t\t\tfor (let i = 0; i < min; i++) {\n\t\t\t\t\tfor (const [subName, subSchema] of Object.entries(item.properties)) {\n\t\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\t\tkey: `${repeatGroup(name, i)}.${subName}`,\n\t\t\t\t\t\t\t\tgroup: repeatGroup(name, i),\n\t\t\t\t\t\t\t\trequired: required.has(name) && itemRequired.has(subName),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (resolved.type === 'object' && resolved.properties) {\n\t\t\t\tconst subRequired = new Set(resolved.required ?? []);\n\t\t\t\tfor (const [subName, subSchema] of Object.entries(\n\t\t\t\t\tresolved.properties,\n\t\t\t\t)) {\n\t\t\t\t\tconst r = resolveSchema(subSchema, schemas) ?? {};\n\t\t\t\t\t// A list of objects nested inside a group (a plot's polygon points) has no\n\t\t\t\t\t// input a visitor can fill, and a text box for it can only produce a\n\t\t\t\t\t// rejected request; the group's scalar alternative (width and depth) is\n\t\t\t\t\t// what the form offers.\n\t\t\t\t\tif (\n\t\t\t\t\t\tr.type === 'array' &&\n\t\t\t\t\t\tresolveSchema(r.items, schemas)?.type === 'object'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\ttoField(subName, r, {\n\t\t\t\t\t\t\tkey: `${name}.${subName}`,\n\t\t\t\t\t\t\tgroup: name,\n\t\t\t\t\t\t\trequired: required.has(name) && subRequired.has(subName),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// A prefixed coordinate joins a group named after its prefix and reports the\n\t\t\t\t// canonical leaf name, so the trio logic and the city search match it unchanged.\n\t\t\t\t// `key` stays the ORIGINAL property name because it is the storage and wire\n\t\t\t\t// identity: rewriting it to `birth.latitude` would serialise a body the API\n\t\t\t\t// rejects.\n\t\t\t\tconst coord = splitCoordinateName(name);\n\t\t\t\tconst field = toField(coord?.leaf ?? name, resolved, {\n\t\t\t\t\tkey: name,\n\t\t\t\t\tgroup: coord?.group,\n\t\t\t\t\trequired: required.has(name),\n\t\t\t\t});\n\t\t\t\tif (coord) field.label = `${humanize(coord.group)} ${coord.leaf}`;\n\t\t\t\tfields.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const param of op.parameters ?? []) {\n\t\tif (param.in !== 'path' && param.in !== 'query') continue;\n\t\t// lang is site-owner chrome, not a visitor field: route it through the\n\t\t// element `lang` attribute, never render it in the form.\n\t\tif (param.name === 'lang' && param.in === 'query') {\n\t\t\thasLang = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = resolveSchema(param.schema, schemas) ?? {};\n\t\tconst field = toField(param.name, resolved, {\n\t\t\tkey: param.name,\n\t\t\trequired: !!param.required,\n\t\t\tinQuery: param.in === 'query',\n\t\t});\n\t\t// Only an otherwise bare identifier needs a noun from the spec. A meaningful\n\t\t// name such as `sign` keeps its existing field-label catalogue entry.\n\t\tif (\n\t\t\tparam.in === 'path' &&\n\t\t\tfield.enum &&\n\t\t\t/^(id|identifier|slug)$/i.test(\n\t\t\t\tEN_FIELD_LABELS[field.name] ?? humanize(field.name),\n\t\t\t)\n\t\t) {\n\t\t\tconst noun = /^([A-Za-z][A-Za-z -]*?)\\s+(?:id|identifier|slug)\\b/i\n\t\t\t\t.exec(param.description ?? field.description ?? '')?.[1]\n\t\t\t\t?.trim();\n\t\t\tif (noun) field.label = noun;\n\t\t}\n\t\tfields.push(field);\n\t}\n\n\treturn withRenderIntent(\n\t\t{\n\t\t\ttitle: deriveTitle(op.summary, endpoint),\n\t\t\tfields,\n\t\t\thasLang,\n\t\t\t...(repeats.length > 0 ? { repeats } : {}),\n\t\t\t...(anyOf ? { requiredAnyOf: anyOf } : {}),\n\t\t},\n\t\tmethod,\n\t\tendpoint,\n\t);\n}\n\n/**\n * Resolve render intent once, shared by spec digestion and compatibility with older schema slices.\n *\n * @remarks\n * A coordinate PAIR defines a city box, not a trio: relocation has two pairs and one birth\n * timezone. Only the first pair may claim a flat timezone; an unclaimed timezone remains a\n * visible city picker writing an IANA zone. Keys always retain their original wire identity.\n * A city box is marked required when any of its own coordinate or timezone fields is required,\n * including a required timezone beside optional Human Design coordinates.\n * Optional named groups stay together under Advanced. With no primary required input, groups\n * and undefaulted flat fields stay open so an either-or request still offers its inputs.\n */\nexport function withRenderIntent(\n\tmodel: FormModel,\n\tmethod: string,\n\tendpoint: string,\n): FormModel {\n\tconst operation = `${method.toUpperCase()} /${endpoint.replace(/^\\//, '')}`;\n\tconst sources = OPTION_SOURCES[operation] ?? {};\n\tconst rules = DISABLED_WHEN[operation] ?? {};\n\tconst fields = model.fields.map((f): FieldDef => {\n\t\tconst field = { ...f };\n\t\tdelete field.role;\n\t\tdelete field.city;\n\t\tdelete field.fold;\n\t\treturn {\n\t\t\t...field,\n\t\t\t...(sources[f.key] && { source: sources[f.key] }),\n\t\t\t...(rules[f.key] && { disabledWhen: rules[f.key] }),\n\t\t};\n\t});\n\tconst groups: FormGroup[] = [...new Set(fields.map((f) => f.group))].map(\n\t\t(key) => (key === undefined ? {} : { key, label: deriveGroupLabel(key) }),\n\t);\n\tconst locations = groups.filter((g) =>\n\t\tLOCATION_PAIR.every((name) =>\n\t\t\tfields.some((f) => f.group === g.key && f.name === name),\n\t\t),\n\t);\n\tfor (const [index, group] of locations.entries()) {\n\t\tconst own = fields.filter((f) => f.group === group.key);\n\t\tconst timezone =\n\t\t\town.find((f) => f.name === 'timezone') ??\n\t\t\t(index === 0\n\t\t\t\t? fields.find((f) => !f.group && f.name === 'timezone')\n\t\t\t\t: undefined);\n\t\tgroup.location = {\n\t\t\tfields: [\n\t\t\t\t...own\n\t\t\t\t\t.filter((f) => (LOCATION_PAIR as readonly string[]).includes(f.name))\n\t\t\t\t\t.map((f) => f.key),\n\t\t\t\t...(timezone ? [timezone.key] : []),\n\t\t\t],\n\t\t\t// Preserve the group's required mark; a claimed flat timezone is still validated by its field.\n\t\t\trequired: own.some(\n\t\t\t\t(f) =>\n\t\t\t\t\t(LOCATION_TRIO as readonly string[]).includes(f.name) && f.required,\n\t\t\t),\n\t\t};\n\t}\n\tfor (const f of fields) {\n\t\tif (f.name === 'seed') f.role = 'seed';\n\t\telse if ((f.name === 'limit' || f.name === 'offset') && !f.required)\n\t\t\tf.role = 'hidden-default';\n\t\telse if (locations.some((g) => g.location?.fields.includes(f.key)))\n\t\t\tf.role = 'location';\n\t\telse if (f.name === 'timezone') f.city = true;\n\t}\n\tconst primaryGroups = groups.filter(\n\t\t(g) =>\n\t\t\tg.key !== undefined &&\n\t\t\t(g.location || fields.some((f) => f.group === g.key && f.required)),\n\t);\n\tconst hasPrimary =\n\t\tfields.some((f) => !f.group && !f.role && f.required) ||\n\t\tprimaryGroups.length > 0 ||\n\t\tlocations.some((g) => g.key === undefined);\n\tfor (const group of groups) {\n\t\tif (group.key !== undefined && hasPrimary && !primaryGroups.includes(group))\n\t\t\tgroup.fold = true;\n\t}\n\tfor (const f of fields) {\n\t\tif (\n\t\t\tf.group\n\t\t\t\t? groups.find((g) => g.key === f.group)?.fold\n\t\t\t\t: !f.role && (hasPrimary ? !f.required : f.default !== undefined)\n\t\t)\n\t\t\tf.fold = true;\n\t}\n\treturn { ...model, fields, groups, opensOnLoad: opensOnLoad(model, method) };\n}\n\n/**\n * Concise form heading. Prefers the operation summary (spec-authored), taking the clause before the first \" - \" so \"Daily horoscope by zodiac sign - Transit-based forecast\" reads as \"Daily horoscope by zodiac sign\", and falls back to the humanized last path segment.\n */\nexport function deriveTitle(\n\tsummary: string | undefined,\n\tendpoint: string,\n): string {\n\tconst lead = summary?.split(' - ')[0]?.trim();\n\tif (lead) return lead;\n\treturn humanize(endpoint.split('/').pop() ?? '');\n}\n\n/**\n * True when a form can show its result before the visitor asks: a read (GET) that needs nothing from them, such as a list, today's phase or a random draw.\n *\n * @remarks\n * The ONE rule the self-fetch component, the hosted embed and the one-tag widget script all ask, so the three never disagree about which forms open on a result. A POST is never one, because a request body with nothing required is usually an either-or the schema cannot state, and sending it empty is a 400 rather than a default reading.\n */\nexport function opensOnLoad(model: FormModel, method: string): boolean {\n\treturn (\n\t\tmethod.toUpperCase() === 'GET' && !model.fields.some((f) => f.required)\n\t);\n}\n\n/**\n * Outcome-first submit-button label keyed off the endpoint intent. A paged collection is searched, chart and reading endpoints \"Generate\", divination endpoints \"Cast\", comparison endpoints \"Compare\", and lookup/reading GETs \"Get reading\". A generic verb beats a bare \"Submit\" on a widget a visitor never set up.\n *\n * Returns the CANONICAL English verb, which is also its catalogue key: the form translates the result rather than this function doing it, because this module is request-context-free and has no element to resolve a page language from. Every verb lives in `i18n/chrome-strings.ts`, and `tests/i18n.test.ts` runs this function over every operation in the committed spec so a new verb cannot be added without a catalogue entry.\n *\n * @param fields - The form fields, when known: a request that pages (`limit`, `offset`) lists a collection, which a visitor searches whatever domain the path names.\n */\nexport function deriveSubmitLabel(\n\tendpoint: string,\n\tfields: readonly FieldDef[] = [],\n): string {\n\tif (fields.some((f) => f.name === 'limit' || f.name === 'offset'))\n\t\treturn 'Search';\n\tconst e = endpoint.toLowerCase();\n\tif (/compat|synastry|guna|connection|penta|composite/.test(e))\n\t\treturn 'Compare';\n\tif (/\\bcast\\b|\\/draw|iching|hexagram|tarot/.test(e)) return 'Cast';\n\tif (/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(e))\n\t\treturn 'Get reading';\n\treturn 'Generate';\n}\n\n/** Deterministic slice filename for one operation, shared by the generator and the runtime loader so both address the same artifact. */\nexport function sliceFileName(method: string, endpoint: string): string {\n\tconst path = endpoint\n\t\t.replace(/^\\//, '')\n\t\t.replace(/[{}]/g, '')\n\t\t.replace(/\\//g, '-');\n\treturn `${method.toLowerCase()}--${path}.json`;\n}\n\n/** The array or count map a collection response carries its entries in: the response itself when it is a list, else its first list, else its first object of counts. */\nfunction entriesOf(json: unknown): unknown[] | Record<string, number> | null {\n\tif (Array.isArray(json)) return json;\n\tif (!json || typeof json !== 'object') return null;\n\tconst values = Object.values(json as Record<string, unknown>);\n\tconst list = values.find(Array.isArray);\n\tif (list) return list as unknown[];\n\tconst counts = values.find(\n\t\t(v) =>\n\t\t\t!!v &&\n\t\t\ttypeof v === 'object' &&\n\t\t\tObject.values(v).every((n) => typeof n === 'number'),\n\t);\n\treturn (counts as Record<string, number> | undefined) ?? null;\n}\n\n/**\n * The choices a collection response offers, read from its shape and never from its name.\n *\n * @remarks\n * Three shapes: a list of strings (each is its own value), a list of records (the value is the record's `id`, else the field's own name, else its `number`; the words are its `name`, else its `english` name, else the value), and a map of counts, where a zero is a choice with nothing behind it. A map keyed by single letters is an index, so the letters it omits are listed too, disabled, and a reader sees the whole alphabet.\n *\n * @param field - The request field the choices fill, which is also where a record may carry its value (an angel number sequence sits in `number`).\n */\nexport function optionsFrom(json: unknown, field = 'id'): FieldOption[] {\n\tconst entries = entriesOf(json);\n\tif (!entries) return [];\n\tif (!Array.isArray(entries)) {\n\t\tconst keys = Object.keys(entries);\n\t\tconst index = keys.length > 0 && keys.every((k) => /^[a-z]$/.test(k));\n\t\tconst all = index ? [...'abcdefghijklmnopqrstuvwxyz'] : keys;\n\t\treturn all.map((k) => ({\n\t\t\tvalue: k,\n\t\t\tlabel: index ? k.toUpperCase() : k,\n\t\t\tdisabled: !entries[k],\n\t\t}));\n\t}\n\tconst out: FieldOption[] = [];\n\tfor (const item of entries) {\n\t\tif (typeof item === 'string') {\n\t\t\tout.push({ value: item, label: item });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item || typeof item !== 'object') continue;\n\t\tconst r = item as Record<string, unknown>;\n\t\tconst raw = r.id ?? r[field] ?? r.number;\n\t\tif (raw == null) continue;\n\t\tconst value = String(raw);\n\t\tconst name = r.name ?? r.english;\n\t\tout.push({ value, label: typeof name === 'string' ? name : value });\n\t}\n\treturn out;\n}\n\n/** The total a paged collection reports, or undefined when it reports none. */\nexport function totalOf(json: unknown): number | undefined {\n\tconst t = (json as { total?: unknown } | null)?.total;\n\treturn typeof t === 'number' ? t : undefined;\n}\n\n/**\n * The collection a free-string path identifier is chosen from: the GET one segment up, as the spec declares it, or undefined when there is none.\n *\n * @remarks\n * Only a FREE string qualifies: an enum already lists its choices, and a pattern, a format or a number type already tells the input what to accept. So `/dreams/symbols/{id}` picks from `/dreams/symbols`, `/crystals/{id}` from `/crystals`, and `/numerology/meanings/{number}`, whose pattern names its twelve values, keeps its input.\n */\nexport function pickerSource(\n\tspec: SpecDoc,\n\tpath: string,\n\tparam: { name: string; required?: boolean; schema?: OpenApiSchema },\n): OptionSource | undefined {\n\tconst s = resolveSchema(param.schema, spec.components?.schemas ?? {}) ?? {};\n\tif (!param.required || scalarType(s) !== 'string') return undefined;\n\tif (s.enum || s.pattern || s.format) return undefined;\n\tconst suffix = `/{${param.name}}`;\n\tif (!path.endsWith(suffix)) return undefined;\n\tconst parent = path.slice(0, -suffix.length);\n\treturn parent ? collectionSource(spec, parent) : undefined;\n}\n\n/** How a GET collection is read for its choices: its search parameter, its largest page and whether it is localized, all from its declared query parameters. */\nexport function collectionSource(\n\tspec: SpecDoc,\n\tpath: string,\n): OptionSource | undefined {\n\tconst op = spec.paths[path]?.get;\n\tif (!op) return undefined;\n\tconst schemas = spec.components?.schemas ?? {};\n\tconst query = (op.parameters ?? []).filter((p) => p.in === 'query');\n\tconst limit = query.find((p) => p.name === 'limit');\n\tconst max = resolveSchema(limit?.schema, schemas)?.maximum;\n\treturn {\n\t\tpath,\n\t\t...(query.some((p) => p.name === 'q') ? { search: 'q' } : {}),\n\t\t...(max !== undefined ? { limit: max } : {}),\n\t\t...(query.some((p) => p.name === 'lang') ? { lang: true as const } : {}),\n\t};\n}\n", "/**\n * The value a READER sees, for a response field the API returns twice.\n *\n * @remarks\n * Several endpoints now echo a display translation beside the canonical value: `nameLocalized` next to `name`, `signLocalized` next to `sign`, `typeLocalized` next to `type`. **The canonical field is deliberately always English, whatever `?lang=` says, so it stays safe to compare against in code**, and the localized one is deliberately absent from an English response.\n *\n * That split is the whole contract, and inverting it breaks charts silently rather than loudly: `planetGlyph`, `signGlyph`, `aspectSymbol`, `ASPECT_CLASS`, `SIGNS_ORDER.indexOf`, every `Map` key and every CSS class fragment is keyed on the English name, so pointing one of them at `nameLocalized` resolves to nothing on a translated page and to the same value on an English one, which is exactly the shape of defect that passes every gate (lesson 24). **The lookup stays on the canonical value; only the printed text node, the `title` and the `aria-label` move.**\n *\n * These two helpers exist so that rule lives in one place rather than as a `??` at every call site, and so an English response, where the localized field simply is not there, degrades by construction instead of by remembering. Both take the KEY of the canonical field and derive its partner, so a mistyped key or a field that is not a display string is a compile error rather than a silent empty string.\n */\n\nimport { fieldLabel, optionLabel } from '../i18n/registry.js';\nimport { humanize } from './string.js';\n\n/**\n * The label for a field NAME, which is a different problem from a field VALUE.\n *\n * @remarks\n * A catalogue keyed on English source text cannot reach a name computed per response, so these read the published field-label payload instead and fall back to {@link humanize}, which is exactly what every caller printed before one existed. A name the payload does not carry therefore renders as it always did rather than as a gap.\n *\n * Here rather than in each component because three of them need the identical pairing: the form that asks for a field, and the two generic renderers that label what came back.\n *\n * @param english - The API English label to print where the payload carries none, INSTEAD of the humanized name; the form passes it, so a field reads as the API names it on an English page too.\n */\nexport function displayField(\n\tlang: string | undefined,\n\tname: string,\n\tenglish?: string,\n): string {\n\treturn fieldLabel(lang, name) ?? english ?? humanize(name);\n}\n\n/**\n * The label for one selectable VALUE of a field, same fallback rule.\n *\n * @param fallback - What to print where the payload carries no label, INSTEAD of the humanized value.\n * The default suits a word (`81-pada` reads as `81 pada`) and not an identifier that carries a number\n * a reader checks against a published table: `humanize` turns `gmt-584283` into `Gmt 584283`, which\n * is neither the label nor the identifier. Pass the raw value for those, so an English page prints\n * what a caller stores and a translated one prints the published word.\n */\nexport function displayOption(\n\tlang: string | undefined,\n\tfield: string,\n\tvalue: string,\n\tfallback?: string,\n): string {\n\treturn optionLabel(lang, field, value) ?? fallback ?? humanize(value);\n}\n\n/** The one naming convention every helper here derives from. Ratified by the API and spreading to more operations, so it is matched as a convention and never as a list of field names. */\nconst LOCALIZED = 'Localized';\n\n/** A response row carrying a canonical English `K` plus the optional localized partner the API writes beside it. */\nexport type Localizable<K extends string> = Partial<\n\tRecord<K | `${K}Localized`, string>\n>;\n\n/** The same pairing where the value is a LIST of names, e.g. `retrogradePlanets`. */\nexport type LocalizableList<K extends string> = Partial<\n\tRecord<K | `${K}Localized`, string[]>\n>;\n\n/**\n * The text to print for `key`: the localized value when the response carried one, else the English one.\n *\n * @param english - What to print in the English case INSTEAD of the raw field, for a canonical value that is an API enum with a display form of its own (`type` is `SEMI_SEXTILE` on the wire and `Semi-sextile` on screen). Omit it wherever the canonical value is already the readable one.\n *\n * @example\n * ```ts\n * display(planet, 'name'); // 'Sol' on ?lang=es, 'Sun' on English\n * planetGlyph(planet.name) ?? display(planet, 'name'); // the lookup stays English, the fallback TEXT does not\n * display(aspect, 'type', formatAspectName(aspect)); // 'Trígono', else 'Trine' and never 'TRINE'\n * ```\n */\nexport function display<\n\tT extends Localizable<K>,\n\tK extends Extract<keyof T, string>,\n>(row: T | null | undefined, key: K, english?: string): string {\n\tconst rec = row as Record<string, unknown> | null | undefined;\n\tconst localized = rec?.[`${key}${LOCALIZED}`];\n\tif (typeof localized === 'string' && localized !== '') return localized;\n\tif (english !== undefined) return english;\n\tconst canonical = rec?.[key];\n\treturn typeof canonical === 'string' ? canonical : '';\n}\n\n/**\n * A list field as `{ value, label }` pairs: the English `value` every lookup is keyed on, and the `label` a reader sees.\n *\n * @remarks\n * The localized array is INDEX-ALIGNED with the canonical one, which is the only thing that makes the pairing possible, so it is zipped by position and neither side is ever sorted, filtered or deduped on its own. A list that is short or absent falls back per item, so a partial translation still resolves every glyph.\n */\nexport function displayList<\n\tT extends LocalizableList<K>,\n\tK extends Extract<keyof T, string>,\n>(row: T | null | undefined, key: K): Array<{ value: string; label: string }> {\n\tconst rec = row as Record<string, unknown> | null | undefined;\n\tconst canonical = rec?.[key];\n\tif (!Array.isArray(canonical)) return [];\n\tconst localized = rec?.[`${key}${LOCALIZED}`];\n\tconst labels = Array.isArray(localized) ? localized : [];\n\treturn canonical.map((value, i) => {\n\t\tconst label = labels[i];\n\t\treturn {\n\t\t\tvalue: String(value),\n\t\t\tlabel: typeof label === 'string' && label !== '' ? label : String(value),\n\t\t};\n\t});\n}\n\n/**\n * Fold every `XLocalized` field into its `X` partner: the reader's value under the canonical NAME, and the duplicate key gone.\n *\n * @remarks\n * For a renderer that has no idea what its fields MEAN and derives its columns from `Object.keys(row)`, which is how `<roxy-data>` started drawing `Planet | Planet Localized | Longitude | Sign | Sign Localized` the day the API began sending both. Two extra columns, headed in English, carrying the same fact twice, on a page whose owner changed nothing. That is a regression rather than a missing feature, so it is repaired at the key layer every render path already funnels through rather than at each of them.\n *\n * Three rules, and each has a way of going wrong:\n *\n * - **A `*Localized` key with no canonical partner stays put.** Suppressing on the name alone deletes data the response carries and nothing else is rendering.\n * - **The canonical key keeps its POSITION**, so a translated response and an English one lay out identically, column for column.\n * - **A row with nothing to fold is returned as the same object**, so the English path is not merely equivalent but untouched.\n *\n * The English value is dropped rather than shown beside its translation because the two are the same fact, and the caller here is generic: it cannot know that `sign` is the value a lookup would be keyed on. A component that needs both halves reads them itself with {@link display}.\n */\nexport function foldLocalized<V>(row: Record<string, V>): Record<string, V> {\n\tlet folded: Record<string, V> | undefined;\n\tfor (const key of Object.keys(row)) {\n\t\tif (!key.endsWith(LOCALIZED)) continue;\n\t\tconst base = key.slice(0, -LOCALIZED.length);\n\t\tif (base === '' || !(base in row)) continue;\n\t\tfolded ??= { ...row };\n\t\tconst value = row[key];\n\t\tif (value !== undefined && value !== null && value !== '')\n\t\t\tfolded[base] = value;\n\t\tdelete folded[key];\n\t}\n\treturn folded ?? row;\n}\n", "import { css } from 'lit';\n\n/** The dropdown of a search-as-you-type box (its spinner, listbox, options and empty row), shared by the city search and the identifier picker so the two read as one family. */\nexport const comboboxStyles = css`.spinner{border:2px solid var(--roxy-muted,#71717a);border-top-color:#0000;border-radius:50%;width:14px;height:14px;animation:.7s linear infinite roxy-spin;position:absolute;top:50%;right:12px;transform:translateY(-50%)}@keyframes roxy-spin{to{transform:translateY(-50%)rotate(360deg)}}@media (prefers-reduced-motion:reduce){.spinner{animation:none}}.results{z-index:50;padding:var(--roxy-space-xs,.25rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);box-shadow:var(--roxy-shadow-md);max-height:22rem;animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));margin:0;list-style:none;position:absolute;top:calc(100% + 4px);left:0;right:0;overflow-y:auto}.option{align-items:center;gap:var(--roxy-space-sm,.5rem);width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);border-radius:var(--roxy-radius-sm,6px);text-align:left;font-family:inherit;font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-fg,#0a0a0a);cursor:pointer;transition:background-color var(--roxy-motion-duration,.2s);background:0 0;border:0;display:flex}.option:hover,.option[aria-selected=true]{background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 10%, transparent)}.empty{padding:var(--roxy-space-md,1rem);color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}`;\n", "/**\n * Lightweight debounce for input handlers. Used by location search.\n *\n * The returned function exposes a `.cancel()` method so callers can clear a\n * pending invocation when the host element disconnects, preventing the timer\n * from firing on a detached node and mutating reactive state after teardown.\n */\nexport interface Debounced<F extends (...args: never[]) => unknown> {\n\t(...args: Parameters<F>): void;\n\tcancel: () => void;\n}\n\nexport function debounce<F extends (...args: never[]) => unknown>(\n\tfn: F,\n\twait: number,\n): Debounced<F> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst debounced = ((...args: Parameters<F>) => {\n\t\tif (timer) clearTimeout(timer);\n\t\ttimer = setTimeout(() => {\n\t\t\ttimer = undefined;\n\t\t\tfn(...args);\n\t\t}, wait);\n\t}) as Debounced<F>;\n\tdebounced.cancel = () => {\n\t\tif (timer) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t}\n\t};\n\treturn debounced;\n}\n", "import {\n\tcss,\n\thtml,\n\tnothing,\n\ttype ReactiveController,\n\ttype ReactiveControllerHost,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { comboboxStyles } from './combobox-styles.js';\nimport { debounce } from './debounce.js';\nimport { type ApiRoute, apiFetch } from './fetch-controller.js';\nimport {\n\ttype FieldOption,\n\ttype OptionSource,\n\toptionsFrom,\n\ttotalOf,\n} from './field-schema.js';\n\n/** How many suggestions a server search asks for while a visitor types. */\nconst SUGGESTIONS = 10;\n\n/** The most pages one collection is read in, a ceiling for a collection that keeps reporting more than it sends. */\nconst MAX_PAGES = 10;\n\n/** One read of each collection per route and language, shared by every form on the page; a failure is evicted so the next mount asks again. */\nconst optionCache = new Map<string, Promise<FieldOption[]>>();\n\n/** The query one read of a collection sends: its largest page, the offset reached, the page language when it is localized, and the search when there is one. */\nfunction sourceQuery(\n\tsource: OptionSource,\n\tlang: string | undefined,\n\textra: Record<string, string | number> = {},\n): Record<string, string | number> {\n\treturn {\n\t\t...(source.limit ? { limit: source.limit } : {}),\n\t\t...(source.lang && lang ? { lang } : {}),\n\t\t...extra,\n\t};\n}\n\n/**\n * Every choice a collection offers, read page by page up to the total it reports, once per route and language.\n *\n * @param field - The request field the choices fill, which is where a record without an `id` carries its value.\n */\nexport function readOptions(\n\troute: ApiRoute,\n\tsource: OptionSource,\n\tfield: string,\n\tlang?: string,\n): Promise<FieldOption[]> {\n\tconst key = JSON.stringify([\n\t\troute.submitUrl ?? route.baseUrl,\n\t\tsource.path,\n\t\tfield,\n\t\tlang,\n\t]);\n\tlet pending = optionCache.get(key);\n\tif (!pending) {\n\t\tpending = readAll(route, source, field, lang).catch((err) => {\n\t\t\toptionCache.delete(key);\n\t\t\tthrow err;\n\t\t});\n\t\toptionCache.set(key, pending);\n\t}\n\treturn pending;\n}\n\nasync function readAll(\n\troute: ApiRoute,\n\tsource: OptionSource,\n\tfield: string,\n\tlang?: string,\n): Promise<FieldOption[]> {\n\tconst out: FieldOption[] = [];\n\tfor (let page = 0; page < MAX_PAGES; page++) {\n\t\tconst json = await apiFetch(route, {\n\t\t\tpath: source.path,\n\t\t\tmethod: 'GET',\n\t\t\tquery: sourceQuery(\n\t\t\t\tsource,\n\t\t\t\tlang,\n\t\t\t\tout.length ? { offset: out.length } : {},\n\t\t\t),\n\t\t});\n\t\tconst got = optionsFrom(json, field);\n\t\tout.push(...got);\n\t\tconst total = totalOf(json);\n\t\tif (\n\t\t\t!source.limit ||\n\t\t\ttotal === undefined ||\n\t\t\tout.length >= total ||\n\t\t\t!got.length\n\t\t)\n\t\t\tbreak;\n\t}\n\treturn out;\n}\n\n/**\n * Drop every cached collection read.\n *\n * @internal Test-only, for the same reason the spec cache has one: the cache is module state shared by every test file in one process.\n */\nexport function resetOptionCache(): void {\n\toptionCache.clear();\n}\n\n/** Folded for matching: lower case with the accents removed, so `cafe` finds `Café`. */\nconst fold = (s: string): string =>\n\ts.normalize('NFD').replace(/\\p{M}/gu, '').toLowerCase();\n\n/** What a picker reads from the element that owns it, at the moment it fetches. */\nexport interface PickerContext {\n\troute: ApiRoute;\n\tlang?: string;\n}\n\n/**\n * A search-as-you-type choice of one entry of a collection, the state behind a WAI-ARIA 1.2 combobox.\n *\n * @remarks\n * A collection with a search parameter is searched as the visitor types, debounced, with the stale request aborted; one without is read once and filtered in place, which also lets the list open on focus before anything is typed. Every request goes through {@link apiFetch}, so a refused key never leaves the page and a failure prints the API message under the box. The host draws it with {@link renderPicker}.\n */\nexport class OptionPicker implements ReactiveController {\n\tquery = '';\n\toptions: FieldOption[] = [];\n\topen = false;\n\thighlight = -1;\n\tloading = false;\n\terror: string | null = null;\n\tprivate abort?: AbortController;\n\tprivate readonly search = debounce((q: string) => {\n\t\tvoid this.searchServer(q);\n\t}, 250);\n\n\tconstructor(\n\t\tprivate readonly host: ReactiveControllerHost,\n\t\tprivate readonly source: OptionSource,\n\t\tprivate readonly field: string,\n\t\tprivate readonly context: () => PickerContext,\n\t\tprivate readonly onPick: (option: FieldOption) => void,\n\t) {\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.search.cancel();\n\t\tthis.abort?.abort();\n\t}\n\n\t/** Show the matches for what the visitor typed: a server search, or the read collection filtered. */\n\tinput(q: string): void {\n\t\tthis.query = q;\n\t\tthis.error = null;\n\t\tif (this.source.search) {\n\t\t\tif (q.trim().length < 2) this.close();\n\t\t\telse this.search(q);\n\t\t} else void this.filter(q);\n\t\tthis.host.requestUpdate();\n\t}\n\n\t/** Open the whole collection on focus when it is read in place, so a visitor can browse before typing. */\n\tfocus(): void {\n\t\tif (!this.source.search && !this.open) void this.filter(this.query);\n\t}\n\n\tclose(): void {\n\t\tthis.open = false;\n\t\tthis.highlight = -1;\n\t\tthis.host.requestUpdate();\n\t}\n\n\tpick(option: FieldOption): void {\n\t\tthis.query = option.label;\n\t\tthis.close();\n\t\tthis.onPick(option);\n\t}\n\n\tkeydown(e: KeyboardEvent): void {\n\t\tconst n = this.options.length;\n\t\tif (e.key === 'Escape') {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\t\tif (e.key === 'ArrowDown' && !this.open) {\n\t\t\te.preventDefault();\n\t\t\tthis.input(this.query);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.open || n === 0) return;\n\t\tif (e.key === 'ArrowDown') this.highlight = (this.highlight + 1) % n;\n\t\telse if (e.key === 'ArrowUp') this.highlight = (this.highlight - 1 + n) % n;\n\t\telse if (e.key === 'Home') this.highlight = 0;\n\t\telse if (e.key === 'End') this.highlight = n - 1;\n\t\telse if (e.key === 'Enter') {\n\t\t\tconst option = this.options[this.highlight] ?? this.options[0];\n\t\t\tif (option) this.pick(option);\n\t\t} else return;\n\t\te.preventDefault();\n\t\tthis.host.requestUpdate();\n\t}\n\n\tprivate async filter(q: string): Promise<void> {\n\t\tconst { route, lang } = this.context();\n\t\tthis.loading = true;\n\t\tthis.host.requestUpdate();\n\t\ttry {\n\t\t\tconst all = await readOptions(route, this.source, this.field, lang);\n\t\t\tif (q !== this.query) return;\n\t\t\tconst needle = fold(q.trim());\n\t\t\tthis.show(\n\t\t\t\tall.filter(\n\t\t\t\t\t(o) =>\n\t\t\t\t\t\tfold(o.label).includes(needle) || fold(o.value).includes(needle),\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tthis.fail(err);\n\t\t} finally {\n\t\t\tthis.loading = false;\n\t\t\tthis.host.requestUpdate();\n\t\t}\n\t}\n\n\tprivate async searchServer(q: string): Promise<void> {\n\t\tconst { route, lang } = this.context();\n\t\tconst search = this.source.search as string;\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.loading = true;\n\t\tthis.host.requestUpdate();\n\t\ttry {\n\t\t\tconst json = await apiFetch(\n\t\t\t\troute,\n\t\t\t\t{\n\t\t\t\t\tpath: this.source.path,\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\tquery: sourceQuery({ ...this.source, limit: SUGGESTIONS }, lang, {\n\t\t\t\t\t\t[search]: q,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tcontroller.signal,\n\t\t\t);\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.show(optionsFrom(json, this.field));\n\t\t} catch (err) {\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.fail(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) {\n\t\t\t\tthis.loading = false;\n\t\t\t\tthis.host.requestUpdate();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate show(options: FieldOption[]): void {\n\t\tthis.options = options;\n\t\tthis.open = true;\n\t\tthis.highlight = options.length ? 0 : -1;\n\t}\n\n\tprivate fail(err: unknown): void {\n\t\tthis.options = [];\n\t\tthis.open = false;\n\t\tthis.error = err instanceof Error ? err.message : String(err);\n\t}\n}\n\n/** The words a picker shows that its owner translates. */\nexport interface PickerText {\n\tplaceholder: string;\n\tempty: string;\n\tloading: string;\n}\n\n/**\n * Draw an {@link OptionPicker} as a WAI-ARIA 1.2 combobox: a text input owning a listbox, the active option announced through `aria-activedescendant`, and the API message under the box when a read fails.\n *\n * @param id - The input id; the listbox and options are named from it, so two pickers on one form never share an id.\n * @param labelledby - The id that names the box when no `<label for>` does.\n */\nexport function renderPicker(\n\tp: OptionPicker,\n\tid: string,\n\ttext: PickerText,\n\taria: { labelledby?: string; describedby?: string; invalid?: boolean } = {},\n): unknown {\n\tconst listbox = `${id}-listbox`;\n\treturn html`<div class=\"picker\"><input id=\"${id}\" type=\"text\" role=\"combobox\" aria-expanded=\"${p.open ? 'true' : 'false'}\" aria-controls=\"${listbox}\" aria-autocomplete=\"list\" aria-labelledby=\"${ifDefined(aria.labelledby)}\" aria-describedby=\"${ifDefined(aria.describedby)}\" aria-invalid=\"${ifDefined(aria.invalid ? 'true' : undefined)}\" aria-activedescendant=\"${p.open && p.highlight >= 0 ? `${id}-opt-${p.highlight}` : ''}\" autocomplete=\"off\" placeholder=\"${text.placeholder}\" .value=\"${p.query}\" @input=\"${(e: Event) => p.input((e.target as HTMLInputElement).value)}\" @keydown=\"${(e: KeyboardEvent) => p.keydown(e)}\" @focus=\"${() => p.focus()}\" @blur=\"${() => p.close()}\"> ${p.loading ? html`<span class=\"spinner\" role=\"status\" aria-label=\"${text.loading}\"></span>` : nothing} ${\n\t\t\t\tp.open\n\t\t\t\t\t? html`<ul id=\"${listbox}\" class=\"results\" role=\"listbox\">${\n\t\t\t\t\t\t\t\tp.options.length === 0\n\t\t\t\t\t\t\t\t\t? html`<li class=\"empty\" role=\"status\">${text.empty}</li>`\n\t\t\t\t\t\t\t\t\t: p.options.map(\n\t\t\t\t\t\t\t\t\t\t\t(o, i) => html`<li id=\"${`${id}-opt-${i}`}\" class=\"option\" role=\"option\" aria-selected=\"${p.highlight === i ? 'true' : 'false'}\" @mousedown=\"${(e: Event) => e.preventDefault()}\" @click=\"${() => p.pick(o)}\">${o.label}</li>`,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}</ul>`\n\t\t\t\t\t: nothing\n\t\t\t}</div>${p.error ? html`<small class=\"field-error\" role=\"alert\">${p.error}</small>` : nothing}`;\n}\n\n/** The box that anchors its listbox; the listbox itself is {@link comboboxStyles}. */\nexport const pickerStyles = [\n\tcomboboxStyles,\n\tcss`.picker{position:relative}`,\n];\n", "// Generated by scripts/sync-version.ts. Do not edit.\nexport const ROXY_UI_VERSION = '0.53.0';\n", "import { css, html, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { EN_FIELD_LABELS } from '../generated/field-labels-en.js';\nimport { apiLang } from '../i18n/lang.js';\nimport { RoxyLocalizedElement } from '../i18n/localized-element.js';\nimport { signGlyph } from '../tokens/index.js';\nimport type { SearchCitiesResponse } from '../types/index.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { chevron, disclosureStyles } from '../utils/disclosure.js';\nimport {\n\ttype ApiIssue,\n\ttype ApiRoute,\n\tcanFetch,\n} from '../utils/fetch-controller.js';\nimport {\n\tbuildFormModel,\n\tderiveGroupLabel,\n\tderiveSubmitLabel,\n\ttype FieldDef,\n\ttype FieldOption,\n\ttype FormGroup,\n\ttype FormModel,\n\tisIndex,\n\tisZodiacEnum,\n\ttype OpenApiDoc,\n\ttype OperationSchema,\n\toptionKind,\n\tparseRepeatGroup,\n\ttype RepeatDef,\n\trepeatFields,\n\trepeatGroup,\n\tsliceFileName,\n\twithRenderIntent,\n} from '../utils/field-schema.js';\nimport { dispatchKeyRefusal, keyRefusal } from '../utils/key-guard.js';\nimport { displayField, displayOption } from '../utils/localized.js';\nimport {\n\tOptionPicker,\n\tpickerStyles,\n\treadOptions,\n\trenderPicker,\n} from '../utils/option-picker.js';\nimport { ROXY_UI_VERSION } from '../version.js';\n\n/** Production spec, fetched when no slice is available and no explicit `spec-url` is set. */\nconst PROD_SPEC_URL = 'https://roxyapi.com/api/v2/openapi.json';\n\n/** Version-pinned jsDelivr base for the digested per-operation schema slices, mirroring the wrapper CDN pinning so a slice matches the bundle it ships beside. */\nconst SLICE_BASE = `https://cdn.jsdelivr.net/npm/@roxyapi/ui@${ROXY_UI_VERSION}/dist/schemas`;\n\nconst specCache = new Map<string, Promise<OpenApiDoc>>();\n\n/**\n * A spec fetch that came back with a non-2xx status, carrying the STATUS rather than a sentence.\n *\n * @remarks\n * The visible wording is composed by the element, in the element's language, and never here: {@link loadSpec} shares one cached promise across every form on the page, so a message built at throw time would freeze the first mounter's language onto every later one. Same split as everywhere else in this library, the machine value travels and the display copy is made where the reader is.\n */\nclass SpecHttpError extends Error {\n\tconstructor(readonly status: number) {\n\t\tsuper(`HTTP ${status}`);\n\t}\n}\n\n/** The endpoint is absent from the document that was loaded. Carries the two parts the message names, for the reason {@link SpecHttpError} gives. */\nclass SpecMissingOperationError extends Error {\n\tconstructor(\n\t\treadonly method: string,\n\t\treadonly path: string,\n\t) {\n\t\tsuper(`Endpoint ${method} ${path} not found in OpenAPI spec`);\n\t}\n}\n\n/**\n * Drop every cached spec promise.\n\n * @remarks\n * Test-only, and deliberately NOT re-exported from the package entry. The cache is module state shared by every test file in a single `bun test` process, and it only self-evicts on rejection, so one file that resolves a spec leaves a warm entry that silently satisfies a later file assertion about fetching. That made slice-fallback coverage pass or fail purely on file order.\n\n * @internal\n */\nexport function resetSpecCache(): void {\n\tspecCache.clear();\n}\n\nasync function loadSpec(url: string): Promise<OpenApiDoc> {\n\tlet pending = specCache.get(url);\n\tif (!pending) {\n\t\tpending = fetch(url)\n\t\t\t.then(async (res) => {\n\t\t\t\tif (!res.ok) throw new SpecHttpError(res.status);\n\t\t\t\treturn (await res.json()) as OpenApiDoc;\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// Evict the rejected promise BEFORE rethrowing so subsequent\n\t\t\t\t// callers (the user clicking Retry, a remount) hit the network\n\t\t\t\t// again instead of replaying the cached failure forever.\n\t\t\t\tspecCache.delete(url);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\tspecCache.set(url, pending);\n\t}\n\treturn pending;\n}\n\n/** A fresh seed for a hidden `seed` field, so each submit is a new draw unless the caller pinned one. */\nfunction randomSeed(): string {\n\treturn (\n\t\tglobalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2)\n\t);\n}\n\n/** True when the spec describes a place field as where someone was born, as opposed to where an observer or a reader stands. */\nconst isBirthPlace = (f?: FieldDef): boolean =>\n\t/\\bbirth/i.test(f?.description ?? '');\n\n/** True when a grouped field lives inside its group on the wire (`person1.date`), false when the group is only how the form shows it and the key is a flat property (`birthLatitude`). */\nconst isNested = (f: FieldDef): boolean => f.key === `${f.group}.${f.name}`;\n\n/** The city `<roxy-location-search>` reports on `roxy-location-select`. */\ntype PickedCity = SearchCitiesResponse['cities'][number];\n\n/** Parse an array-field text value into a real array: JSON when it parses to one, else comma-separated tokens. */\nfunction parseArrayValue(raw: string): unknown {\n\tconst trimmed = raw.trim();\n\tif (!trimmed) return [];\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t// Not JSON: fall through to comma splitting.\n\t}\n\treturn trimmed\n\t\t.split(',')\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean);\n}\n\n/**\n * Schema-driven form. Pass `endpoint` (e.g. \"vedic-astrology/birth-chart\"). The form digests the operation's request schema into a spec-derived input for each parameter (a zodiac tile grid, a date or time input, a city search, a toggle) with progressive disclosure, and emits a `roxy-submit` CustomEvent carrying the validated payload. The caller decides what to do (call the SDK, render a chart, navigate).\n *\n * @remarks\n * Schema resolution order: an explicit `spec-url` fetches that full spec and digests it (unchanged, the demo path); otherwise the form tries a small version-pinned per-operation slice from the CDN, and on any miss falls back to fetching the production spec. Each input kind is chosen purely from the parameter shape (see {@link ../utils/field-schema.ts}), so a new endpoint gets a working, on-brand form with no per-endpoint code.\n *\n * The visitor-facing `lang` parameter is never rendered: a site owner sets the element `lang` attribute, and the form routes it to the query string on submit. Optional parameters collapse under one Advanced disclosure behind the required ones; when nothing is required, every group and every undefaulted parameter renders in the open and only the defaulted ones collapse, so a request the schema can only describe as one of two optional shapes still shows its inputs. A form whose only required field is an enum submits on selection.\n *\n * **Two languages are in play here and they are different answers.** {@link RoxyLocalizedElement.effectiveLang} is the DISPLAY tag, region included, and it is what every `t()` call and the city search read. {@link RoxyEndpointForm.requestLang} is the WIRE value, region stripped and unsupported languages omitted, and it is what reaches `?lang=`. Swapping them is silent in both directions: the request one demotes every regional visitor, and the display one is a 400.\n *\n * **Field labels and option text ARE translated now, and they arrive over the network rather than from a catalogue.** They are keyed by the WIRE NAME the spec uses, not by the English text, because that English text is itself computed here by `humanize()`: there is no constant for a source-keyed catalogue to key on, which is why the chrome catalogue could never reach them. {@link RoxyEndpointForm.fieldText} and {@link RoxyEndpointForm.optionText} read a map baked into the per-language payload at build time and published through the same registry the chrome strings use. It rides the `locales/{lang}.js` download a translated page already makes, so it costs no extra request, needs no network at render time, and cannot flash English before correcting itself.\n *\n * **`humanize()` remains, as the fallback, and that is what makes this safe.** The payload is cosmetic and never awaited: a form draws immediately, an offline page or a blocked request renders exactly what it rendered before labels existed, and a language with no translation for a given key falls back to English server-side. There is no state in which a missing label breaks a form. Operation SUMMARIES and field DESCRIPTIONS are deliberately NOT in that map: a description is developer-facing reference prose, most of it collapsed behind a disclosure, and the widget already states the same contract language-neutrally through its input type and bounds. GROUP names stay catalogued rather than fetched, because the spec has nine of them: see {@link RoxyEndpointForm.groupName}.\n */\n@customElement('roxy-endpoint-form')\nexport class RoxyEndpointForm extends RoxyLocalizedElement {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tpickerStyles,\n\t\tcss`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);grid-template-columns:minmax(0,1fr);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.fields>*,.field>input,.field>select{min-width:0}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--_danger-fg);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.field-error{color:var(--_danger-fg);font-size:var(--roxy-text-xs,.75rem)}input[aria-invalid=true],select[aria-invalid=true]{border-color:var(--roxy-danger,#dc2626)}input:disabled,select:disabled{cursor:default;color:var(--roxy-muted,#71717a);border-style:dashed}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover:not(:disabled){border-color:var(--roxy-accent,#f59e0b)}.tile:disabled{cursor:default;color:var(--roxy-muted,#71717a);border-style:dashed}.tiles.narrow{gap:var(--roxy-space-xs,.25rem);grid-template-columns:repeat(auto-fill,minmax(2.25rem,1fr))}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.repeat-controls{gap:var(--roxy-space-sm,.5rem);display:flex}.repeat-btn{color:var(--roxy-accent-ink,#b45309);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font:inherit;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;background:0 0}.repeat-btn:hover{border-color:var(--roxy-accent-ink,#b45309)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);min-height:44px;color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`,\n\t];\n\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = 'vedic-astrology/birth-chart';\n\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Explicit OpenAPI spec URL. When set, the form fetches and digests that full spec (the demo path). When empty, it resolves a version-pinned slice first, then the production spec. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl = '';\n\n\t/** Override the submit-button label. Empty derives an outcome-first label from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel = '';\n\n\t/** Browser-safe publishable key, forwarded to the slotted city search so the natal or synastry form can geocode; a key the guard refuses replaces the inputs with the reason. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Where the slotted city search sends its request, absolute or relative to the page. Set it when the page routes its API traffic through its own server, so the one request this form issues on its own reaches that server too. Unset, the search keeps its own default. */\n\t@property({ type: String, attribute: 'location-url' })\n\tlocationUrl?: string;\n\n\t/** Prefill values, keyed by field name (nested per group). Used by `remember` mode and to restore the previous submission. JS property only. */\n\t@property({ attribute: false })\n\tinitialValues?: Record<string, unknown>;\n\n\t/**\n\t * The fields the API rejected on the last submit, by wire path, as the host's fetch reported them. JS property only.\n\t *\n\t * @remarks\n\t * The wire path is the same identity a field is keyed by (`year`, `person1.date`, `members.0.date`, `birthLatitude`), so each issue prints under the input it names and the input is marked invalid; an issue on a whole group (`members.0`) prints on that card, and one the form cannot place prints in the summary alone. Editing a field clears its issue, so a corrected value is not still marked wrong.\n\t */\n\t@property({ attribute: false })\n\tserverIssues: ApiIssue[] | null = null;\n\n\t/** Where the choices for a field are read through, handed in by a component in self-fetch mode so a proxied page reads them through its own route; a placed form reads them with its own publishable key. JS property only. */\n\t@property({ attribute: false })\n\tapiRoute?: ApiRoute;\n\n\t/** Submit once on load when the request needs nothing from the visitor, set by a component in self-fetch mode so a list or today's reading opens on its result. JS property only. */\n\t@property({ attribute: false })\n\tautoload = false;\n\n\t/** Ask a hidden `limit` for the largest page the API serves rather than its default, set by a list component that pages its own rows. JS property only. */\n\t@property({ attribute: false })\n\tfullPages = false;\n\n\t/** The choices read for each optional field the API lists values for, or the read in flight; absent when they could not be read, and the field keeps its plain input. */\n\t@state()\n\tprivate choices: Record<string, FieldOption[] | 'loading'> = {};\n\n\t/** One search-as-you-type picker per required free-string identifier, keyed by field. */\n\tprivate pickers = new Map<string, OptionPicker>();\n\n\t/** Issues the visitor has since edited away, by wire path. */\n\t@state()\n\tprivate clearedIssues = new Set<string>();\n\n\t@state()\n\tprivate fields: FieldDef[] = [];\n\n\tprivate groups: FormGroup[] = [];\n\tprivate modelOpensOnLoad = false;\n\n\t/** The array-of-object request properties, each a set of cards the visitor can grow up to `max` and shrink back to `min`. */\n\t@state()\n\tprivate repeats: RepeatDef[] = [];\n\n\t@state()\n\tprivate formTitle = '';\n\n\t@state()\n\tprivate hasLang = false;\n\n\t@state()\n\tprivate values: Record<string, unknown> = {};\n\n\t@state()\n\tprivate loaded = false;\n\n\t@state()\n\tprivate specError: string | null = null;\n\n\t@state()\n\tprivate validationErrors: string[] = [];\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tvoid this.loadSchema();\n\t}\n\n\tprivate async loadSchema() {\n\t\tthis.specError = null;\n\t\ttry {\n\t\t\tthis.applyModel(await this.resolveModel());\n\t\t} catch (err) {\n\t\t\t// The banner reads in the page language; the event keeps the canonical\n\t\t\t// English, because a listener is code and a developer console is not a\n\t\t\t// localized surface.\n\t\t\tthis.specError = this.specErrorMessage(err);\n\t\t\tthis.loaded = true;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-spec-error', {\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\turl: this.specUrl || PROD_SPEC_URL,\n\t\t\t\t\t\tmessage: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t},\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** The failure sentence a visitor reads. Composed here rather than at the throw, so the shared spec-cache promise cannot freeze one form's language onto another. A message from anywhere else (a browser network error) is a wire fact and passes through untranslated. */\n\tprivate specErrorMessage(err: unknown): string {\n\t\tif (err instanceof SpecHttpError)\n\t\t\treturn this.t('HTTP error {{status}}', { status: err.status });\n\t\tif (err instanceof SpecMissingOperationError)\n\t\t\treturn this.t('Endpoint {{method}} {{path}} not found in OpenAPI spec', {\n\t\t\t\tmethod: err.method,\n\t\t\t\tpath: err.path,\n\t\t\t});\n\t\treturn err instanceof Error ? err.message : String(err);\n\t}\n\n\t/** Resolve the form model: explicit spec-url wins; else a version-pinned slice; else the production spec. */\n\tprivate async resolveModel(): Promise<FormModel> {\n\t\tif (this.specUrl) return this.modelFromSpec(this.specUrl);\n\t\tconst slice = await this.tryLoadSlice();\n\t\treturn slice ?? this.modelFromSpec(PROD_SPEC_URL);\n\t}\n\n\t/** Fetch and digest one operation from a full OpenAPI document. */\n\tprivate async modelFromSpec(url: string): Promise<FormModel> {\n\t\tconst spec = await loadSpec(url);\n\t\tconst path = `/${this.endpoint.replace(/^\\//, '')}`;\n\t\tconst op = spec.paths?.[path]?.[this.method.toLowerCase()] as\n\t\t\t| OperationSchema\n\t\t\t| undefined;\n\t\tif (!op) throw new SpecMissingOperationError(this.method, path);\n\t\treturn buildFormModel(\n\t\t\top,\n\t\t\tspec.components?.schemas ?? {},\n\t\t\tthis.endpoint,\n\t\t\tthis.method,\n\t\t);\n\t}\n\n\t/** Try the small precomputed slice; return null on any miss so the caller falls back to the full spec. */\n\tprivate async tryLoadSlice(): Promise<FormModel | null> {\n\t\ttry {\n\t\t\tconst res = await fetch(\n\t\t\t\t`${SLICE_BASE}/${sliceFileName(this.method, this.endpoint)}`,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\treturn (await res.json()) as FormModel;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate applyModel(model: FormModel) {\n\t\t// Older slices omit render intent; normalize through the same pure model builder.\n\t\tif (!model.groups || model.opensOnLoad === undefined)\n\t\t\tmodel = withRenderIntent(model, this.method, this.endpoint);\n\t\tthis.fields = model.fields;\n\t\tthis.groups = model.groups ?? [];\n\t\tthis.modelOpensOnLoad = model.opensOnLoad ?? false;\n\t\tthis.repeats = model.repeats ?? [];\n\t\tthis.formTitle = model.title;\n\t\tthis.hasLang = model.hasLang;\n\t\t// Pre-fill: schema defaults first, then any remembered/initial values (only\n\t\t// for fields this endpoint has) so a stale stored payload from another\n\t\t// endpoint cannot inject unknown keys. Remembered values are nested per\n\t\t// group, so read them by group.\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const f of model.fields) {\n\t\t\tconst seed =\n\t\t\t\tthis.fullPages &&\n\t\t\t\tf.name === 'limit' &&\n\t\t\t\tthis.roleOf(f) === 'hidden-default'\n\t\t\t\t\t? (f.max ?? f.default)\n\t\t\t\t\t: f.default;\n\t\t\tif (seed !== undefined) init[f.key] = seed;\n\t\t\tconst remembered =\n\t\t\t\tf.group && isNested(f)\n\t\t\t\t\t? (\n\t\t\t\t\t\t\tthis.initialValues?.[f.group] as\n\t\t\t\t\t\t\t\t| Record<string, unknown>\n\t\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t)?.[f.name]\n\t\t\t\t\t: this.initialValues?.[f.key];\n\t\t\tif (remembered !== undefined) init[f.key] = remembered;\n\t\t}\n\t\tthis.values = this.withoutDisabled(init);\n\t\tthis.loaded = true;\n\t\tthis.loadChoices();\n\t\tif (this.autoload && this.opensOnLoad && canFetch(this.route))\n\t\t\tvoid this.updateComplete.then(() => this.submit());\n\t}\n\n\t/** The route the choices are read through. */\n\tprivate get route(): ApiRoute {\n\t\treturn this.apiRoute ?? { publishableKey: this.publishableKey };\n\t}\n\n\t/** Read the choices of every sourced field when this form can reach the API: a picker for a required identifier, a list read once for an optional filter. */\n\tprivate loadChoices() {\n\t\tfor (const old of this.pickers.values()) this.removeController(old);\n\t\tthis.pickers.clear();\n\t\tif (!canFetch(this.route)) return;\n\t\tconst context = () => ({ route: this.route, lang: this.requestLang() });\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.source) continue;\n\t\t\tif (f.required) {\n\t\t\t\tconst picker = new OptionPicker(this, f.source, f.name, context, (o) =>\n\t\t\t\t\tthis.pickChoice(f, o.value),\n\t\t\t\t);\n\t\t\t\tpicker.query = String(this.values[f.key] ?? '');\n\t\t\t\tthis.pickers.set(f.key, picker);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.choices = { ...this.choices, [f.key]: 'loading' };\n\t\t\treadOptions(this.route, f.source, f.name, this.requestLang()).then(\n\t\t\t\t(options) => {\n\t\t\t\t\tthis.choices = { ...this.choices, [f.key]: options };\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tconst { [f.key]: _, ...rest } = this.choices;\n\t\t\t\t\tthis.choices = rest;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate retryLoadSchema = () => {\n\t\tthis.loaded = false;\n\t\tthis.specError = null;\n\t\tvoid this.loadSchema();\n\t};\n\n\tprivate setValue(name: string, value: unknown) {\n\t\tthis.setValues({ [name]: value });\n\t}\n\n\t/** Writes several values at once and clears the issue on each one the API named. */\n\tprivate setValues(patch: Record<string, unknown>) {\n\t\tthis.values = this.withoutDisabled({ ...this.values, ...patch });\n\t\tconst edited = Object.keys(patch).filter((k) =>\n\t\t\tthis.serverIssues?.some((i) => i.path === k),\n\t\t);\n\t\tif (edited.length)\n\t\t\tthis.clearedIssues = new Set([...this.clearedIssues, ...edited]);\n\t}\n\n\t/** True while another field holds the value this field waits on, so it takes no input and sends nothing. */\n\tprivate isDisabled(f: FieldDef, values = this.values): boolean {\n\t\tconst when = f.disabledWhen;\n\t\treturn !!when && values[when.field] === when.value;\n\t}\n\n\t/** The values with every disabled field dropped, so a choice made before it was disabled is never sent. */\n\tprivate withoutDisabled(values: Record<string, unknown>) {\n\t\tfor (const f of this.fields)\n\t\t\tif (this.isDisabled(f, values)) values[f.key] = undefined;\n\t\treturn values;\n\t}\n\n\t/** The live issues: what the API reported, less what has been edited since. A new report resets the edits. */\n\tprotected willUpdate(changed: Map<PropertyKey, unknown>): void {\n\t\tif (changed.has('serverIssues')) this.clearedIssues = new Set();\n\t\tconst refusal = changed.has('publishableKey')\n\t\t\t? keyRefusal(this.publishableKey)\n\t\t\t: undefined;\n\t\tif (refusal) dispatchKeyRefusal(this, refusal, { warn: true });\n\t}\n\n\tprivate liveIssues(): ApiIssue[] {\n\t\treturn (this.serverIssues ?? []).filter(\n\t\t\t(i) => !this.clearedIssues.has(i.path),\n\t\t);\n\t}\n\n\t/** The issue on exactly this field, if the API named it. */\n\tprivate issueFor(f: FieldDef): ApiIssue | undefined {\n\t\treturn this.liveIssues().find((i) => i.path === f.key);\n\t}\n\n\t/** The issues on the coordinates and timezone a group's city box writes, which have no input of their own to sit under. */\n\tprivate cityIssues(group?: string): ApiIssue[] {\n\t\treturn this.liveIssues().filter((i) => {\n\t\t\tconst f = this.fields.find((x) => x.key === i.path);\n\t\t\treturn (\n\t\t\t\t!!f && this.roleOf(f) === 'location' && this.cityGroup(f) === group\n\t\t\t);\n\t\t});\n\t}\n\n\t/** The issues on a whole group card (`members.0`), as opposed to one of its fields. */\n\tprivate issuesForGroup(group: string): ApiIssue[] {\n\t\treturn this.liveIssues().filter((i) => i.path === group);\n\t}\n\n\t/**\n\t * A field named the way its input is labelled on the form, for a message that sends the visitor back to it.\n\t *\n\t * @remarks\n\t * The group half translates and the field half cannot, which is not a half-measure: this names a block the visitor has to go back to, so the word in the message has to be the word printed on the fieldset legend. A message saying `Person 1` over a legend reading `Persona 1` points at nothing.\n\t */\n\tprivate fieldLabel(f: FieldDef): string {\n\t\tif (this.roleOf(f) === 'location' || f.city)\n\t\t\treturn this.locationLabel(this.cityGroup(f));\n\t\treturn f.group\n\t\t\t? `${this.groupName(f.group)} ${this.fieldText(f.name, f.label)}`\n\t\t\t: this.fieldText(f.name, f.label);\n\t}\n\n\t/** The issues the API reported on a whole card or a city box, printed under it. */\n\tprivate issueLines(issues: ApiIssue[]) {\n\t\treturn issues.map(\n\t\t\t(i) =>\n\t\t\t\thtml`<small part=\"field-error\" class=\"field-error\" role=\"alert\">${i.message}</small>`,\n\t\t);\n\t}\n\n\t/** The inline message under an input, and the attributes that tie it to the input for assistive tech. */\n\tprivate fieldIssue(f: FieldDef) {\n\t\tconst issue = this.issueFor(f);\n\t\treturn issue\n\t\t\t? html`<small part=\"field-error\" class=\"field-error\" id=\"${`roxy-form-${f.key}-error`}\" role=\"alert\">${issue.message}</small>`\n\t\t\t: nothing;\n\t}\n\n\t/**\n\t * The summary of what the API rejected: one line per issue, the field named by\n\t * its label on the form rather than by its wire path, so the reader is sent to\n\t * the input they can see. The message is the API's own and prints as sent.\n\t */\n\tprivate renderIssueSummary() {\n\t\tconst issues = this.liveIssues();\n\t\tif (issues.length === 0) return nothing;\n\t\tconst labelFor = (path: string): string => {\n\t\t\tconst field = this.fields.find((f) => f.key === path);\n\t\t\tif (field) return this.fieldLabel(field);\n\t\t\tconst group = this.groupKeys().find((g) => g === path);\n\t\t\tif (group) return this.groupName(group);\n\t\t\treturn this.fieldText(path.split('.')[0] ?? path);\n\t\t};\n\t\treturn html`<div part=\"validation-error\" class=\"validation-error\" role=\"alert\">${issues.map(\n\t\t\t\t(i) =>\n\t\t\t\t\thtml`<div><strong>${labelFor(i.path)}</strong> ${i.message}</div>`,\n\t\t\t)}</div>`;\n\t}\n\n\t/** The field's render role: a hidden autogenerated seed, a hidden defaulted limit/offset, a suppressed location coordinate, or a normally rendered input. */\n\tprivate roleOf(\n\t\tf: FieldDef,\n\t): 'seed' | 'hidden-default' | 'location' | 'normal' {\n\t\treturn f.role ?? 'normal';\n\t}\n\n\t/** True when the model assigns the field its own input. */\n\tprivate isRendered(f: FieldDef): boolean {\n\t\treturn this.roleOf(f) === 'normal';\n\t}\n\n\t/** Groups in the model's render order, including the flat top level. */\n\tprivate groupKeys(): (string | undefined)[] {\n\t\treturn this.groups.map((g) => g.key);\n\t}\n\n\t/** The city box assigned to this group by the model. */\n\tprivate groupHasLocation(group?: string): boolean {\n\t\treturn !!this.groups.find((g) => g.key === group)?.location;\n\t}\n\n\t/** The group whose city box fills this field, including a claimed flat timezone. */\n\tprivate cityGroup(f: FieldDef): string | undefined {\n\t\treturn (\n\t\t\tthis.groups.find((g) => g.location?.fields.includes(f.key))?.key ??\n\t\t\tf.group\n\t\t);\n\t}\n\n\t/** The field whose spec description says what place a group's city box asks for: its latitude, or a timezone standing alone. */\n\tprivate placeField(group?: string): FieldDef | undefined {\n\t\tconst inGroup = this.fields.filter((f) => f.group === group);\n\t\treturn (\n\t\t\tinGroup.find((f) => f.name === 'latitude') ??\n\t\t\tinGroup.find((f) => f.name === 'timezone')\n\t\t);\n\t}\n\n\t/** Whether the model marks this city box required. */\n\tprivate locationRequired(group?: string): boolean {\n\t\treturn (\n\t\t\tthis.groups.find((g) => g.key === group)?.location?.required ?? false\n\t\t);\n\t}\n\n\t/**\n\t * The single visible required choice, when the whole form reduces to exactly one: no location block, no named group, one required rendered enum or picker. This is what turns the horoscope form into a tap-to-load sign grid and the dream card into type, pick, read; returns null otherwise.\n\t */\n\tprivate get soleChoice(): FieldDef | null {\n\t\tif (this.groupKeys().some((g) => this.groupHasLocation(g))) return null;\n\t\tif (this.groupKeys().some((g) => g !== undefined)) return null;\n\t\tconst req = this.fields.filter((f) => f.required && this.isRendered(f));\n\t\tconst only = req[0];\n\t\tif (req.length !== 1 || !only) return null;\n\t\treturn only.kind === 'tiles' ||\n\t\t\tonly.kind === 'select' ||\n\t\t\tthis.pickers.has(only.key)\n\t\t\t? only\n\t\t\t: null;\n\t}\n\n\t/** True when this form opens on its result, so it stays above the result as a filter bar. */\n\tprivate get opensOnLoad(): boolean {\n\t\treturn this.modelOpensOnLoad;\n\t}\n\n\t/** True for an optional filter on a form that opens on load: a listed choice that submits when picked and clears the other filters. */\n\tprivate isFilter(f: FieldDef): boolean {\n\t\treturn this.opensOnLoad && !f.required && !!(f.enum || f.source);\n\t}\n\n\t/** True when every input on the form sends it by itself (a sole choice, or a filter bar with nothing typed), so it draws no submit button. */\n\tprivate get selfSubmits(): boolean {\n\t\tif (this.soleChoice) return true;\n\t\tif (!this.opensOnLoad) return false;\n\t\tconst shown = this.fields.filter((f) => this.isRendered(f));\n\t\treturn shown.length > 0 && shown.every((f) => this.isFilter(f));\n\t}\n\n\t/** Tiles or a select for a choice field: by the shape of its choices, except that a filter of words is a select, so a list that opens on load keeps its filters to one compact row and only an index (letters, short codes) stays a tile bar. */\n\tprivate choiceKind(f: FieldDef): 'tiles' | 'select' {\n\t\tconst values = this.choicesOf(f).map((o) => o.value);\n\t\tif (this.isFilter(f) && !isIndex(values)) return 'select';\n\t\t// A list the API served is classed here; an enum keeps the kind its schema gave it.\n\t\treturn this.choices[f.key]\n\t\t\t? optionKind(values)\n\t\t\t: (f.kind as 'tiles' | 'select');\n\t}\n\n\t/** The choices a field offers: its enum with the published option text, or the list the API served for it. */\n\tprivate choicesOf(f: FieldDef): FieldOption[] {\n\t\tconst listed = this.choices[f.key];\n\t\tif (Array.isArray(listed)) return listed;\n\t\treturn (f.enum ?? []).map((value) => ({\n\t\t\tvalue,\n\t\t\tlabel: this.optionText(f.name, value),\n\t\t}));\n\t}\n\n\t/** The submit-button label. A caller-supplied one is theirs and is printed verbatim; the derived verb is ours, so it goes through the catalogue. {@link deriveSubmitLabel} returns the canonical English verb, which IS the catalogue key. */\n\tprivate effectiveSubmitLabel(): string {\n\t\treturn (\n\t\t\tthis.submitLabel || this.t(deriveSubmitLabel(this.endpoint, this.fields))\n\t\t);\n\t}\n\n\t/**\n\t * The value this form may put on `?lang=`, or undefined to leave the request on the API default.\n\t *\n\t * @remarks\n\t * NOT the display language, and the name says so: `effectiveLang()` on the base class is the full display tag every `t()` reads. `?lang=es-AR` is a 400 and `?lang=es` is a 200, and the language resolves from `<html lang>` rather than only from an attribute a developer typed, so the unfiltered tag reaching the query string would break every regional and every untranslated locale. {@link apiLang} does both narrowings; this method exists so the submit path reads as one call.\n\t */\n\tprivate requestLang(): string | undefined {\n\t\treturn apiLang(this);\n\t}\n\n\t/**\n\t * The words this form writes over a request field, and the options under it.\n\t *\n\t * @remarks\n\t * `humanize()` is the FALLBACK, not the default, and it stays because it has to: the labels\n\t * arrive over the network and a form must draw before they land, on an offline page, and when\n\t * the request fails. So the worst case is exactly what this form rendered before labels\n\t * existed, and the best case is a translated one, with no state in between where it breaks.\n\t *\n\t * Keyed by WIRE NAME rather than by the English text, because the English text is itself\n\t * computed here by `humanize()`; there is no constant to key on. Same reason the label map is\n\t * a separate key space from the chrome catalogue.\n\t *\n\t * English ships no payload, so the API English label is compiled in and comes before `humanize()`.\n\t * Contextual model labels stay in English; translated picker/context labels are server artifacts.\n\t */\n\tprivate fieldText(name: string, label?: string): string {\n\t\tif (label) return label;\n\t\treturn displayField(this.requestLang(), name, EN_FIELD_LABELS[name]);\n\t}\n\n\t/** The option text under one field, falling back the same way. */\n\tprivate optionText(field: string, value: string): string {\n\t\treturn displayOption(this.requestLang(), field, value);\n\t}\n\n\t/**\n\t * Location-select handler bound to a group: fills that group's coordinate keys plus whichever\n\t * timezone field it owns.\n\t *\n\t * Keys are LOOKED UP from the model rather than built as `group.name`. That assumption held only\n\t * while every group came from object nesting; a prefixed group stores under the original wire\n\t * name (`birthLatitude`), so constructing `birth.latitude` would write a key the request builder\n\t * never reads and the coordinates would silently stay empty.\n\t */\n\tprivate onLocationFor(group?: string) {\n\t\treturn (city: PickedCity) => {\n\t\t\tconst keys =\n\t\t\t\tthis.groups.find((g) => g.key === group)?.location?.fields ?? [];\n\t\t\tconst patch: Record<string, unknown> = {};\n\t\t\tfor (const key of keys) {\n\t\t\t\tconst name = this.fields.find((f) => f.key === key)?.name;\n\t\t\t\tif (name) patch[key] = city[name as keyof PickedCity];\n\t\t\t}\n\t\t\tthis.setValues(patch);\n\t\t};\n\t}\n\n\t/** Records a chosen option, and submits at once when it is the only input the form has or a filter; picking the chosen filter again clears it. */\n\tprivate chooseOption(f: FieldDef, value: string) {\n\t\tif (this.isFilter(f)) {\n\t\t\tthis.setFilter(f, this.values[f.key] === value ? '' : value);\n\t\t\tthis.submit();\n\t\t\treturn;\n\t\t}\n\t\tthis.pickChoice(f, value);\n\t}\n\n\t/** Records a choice and submits when the form reduces to it. */\n\tprivate pickChoice(f: FieldDef, value: string) {\n\t\tthis.setValue(f.key, value);\n\t\tif (value && this.soleChoice?.key === f.key) this.submit();\n\t}\n\n\t/** Sets one filter and clears the others and the text search, so a list is narrowed one way at a time. */\n\tprivate setFilter(f: FieldDef, value: unknown) {\n\t\tconst patch: Record<string, unknown> = { [f.key]: value };\n\t\tfor (const other of this.fields)\n\t\t\tif (\n\t\t\t\tother !== f &&\n\t\t\t\t(this.isFilter(other) ||\n\t\t\t\t\t(this.opensOnLoad && other.kind === 'text' && this.isRendered(other)))\n\t\t\t)\n\t\t\t\tpatch[other.key] = undefined;\n\t\tthis.setValues(patch);\n\t}\n\n\t/** Roving-tabindex arrow-key navigation for a tile radiogroup, modeled on the shared tablist pattern (selection follows focus). */\n\tprivate onTilesKeyDown(f: FieldDef) {\n\t\treturn (e: KeyboardEvent) => {\n\t\t\tconst opts = this.choicesOf(f)\n\t\t\t\t.filter((o) => !o.disabled)\n\t\t\t\t.map((o) => o.value);\n\t\t\tif (opts.length === 0) return;\n\t\t\tconst cur = opts.indexOf(this.values[f.key] as string);\n\t\t\tlet next: number;\n\t\t\tif (e.key === 'Home') next = 0;\n\t\t\telse if (e.key === 'End') next = opts.length - 1;\n\t\t\telse if (e.key === 'ArrowRight' || e.key === 'ArrowDown')\n\t\t\t\tnext = cur === -1 ? 0 : (cur + 1) % opts.length;\n\t\t\telse if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')\n\t\t\t\tnext =\n\t\t\t\t\tcur === -1 ? opts.length - 1 : (cur - 1 + opts.length) % opts.length;\n\t\t\telse return;\n\t\t\te.preventDefault();\n\t\t\tconst value = opts[next];\n\t\t\tif (value === undefined) return;\n\t\t\tthis.chooseOption(f, value);\n\t\t\tconst root = e.currentTarget as HTMLElement;\n\t\t\tconst tile = this.choicesOf(f).findIndex((o) => o.value === value);\n\t\t\trequestAnimationFrame(() =>\n\t\t\t\troot.querySelector<HTMLButtonElement>(`[data-tile='${tile}']`)?.focus(),\n\t\t\t);\n\t\t};\n\t}\n\n\tprivate onSubmit = (e: Event) => {\n\t\te.preventDefault();\n\t\tthis.submit();\n\t};\n\n\t/** Validate, then emit `roxy-submit` with the reconstructed payload, the spec query keys, and whether the form stays above its result. */\n\tprivate submit() {\n\t\tconst missing = this.collectMissing();\n\t\tif (missing.keys.length > 0) {\n\t\t\tthis.validationErrors = missing.labels;\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\t\t\tdetail: { missing: missing.keys },\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcomposed: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.validationErrors = [];\n\t\tthis.clearedIssues = new Set((this.serverIssues ?? []).map((i) => i.path));\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const f of this.fields) {\n\t\t\tlet v = this.values[f.key];\n\t\t\t// A hidden seed autogenerates per submit unless a value was remembered.\n\t\t\tif (f.name === 'seed' && (v === undefined || v === '')) v = randomSeed();\n\t\t\tif (v === undefined || v === '') continue;\n\t\t\tif (f.kind === 'array' && typeof v === 'string') v = parseArrayValue(v);\n\t\t\tconst repeat = f.group ? parseRepeatGroup(f.group) : null;\n\t\t\tif (repeat) {\n\t\t\t\t// A repeating group serialises as one object per record, in record order.\n\t\t\t\tconst list =\n\t\t\t\t\t(out[repeat.key] as Record<string, unknown>[] | undefined) ?? [];\n\t\t\t\tconst g = list[repeat.index] ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tlist[repeat.index] = g;\n\t\t\t\tout[repeat.key] = list;\n\t\t\t} else if (f.group && isNested(f)) {\n\t\t\t\tconst g = (out[f.group] as Record<string, unknown> | undefined) ?? {};\n\t\t\t\tg[f.name] = v;\n\t\t\t\tout[f.group] = g;\n\t\t\t} else {\n\t\t\t\t// The key is the wire identity: a prefixed coordinate (`birthLatitude`) is\n\t\t\t\t// grouped for the form and flat on the wire.\n\t\t\t\tout[f.key] = v;\n\t\t\t}\n\t\t}\n\t\t// The spec knows which parameters belong in the query string; the listener\n\t\t// does not. Report them (including a site-owner lang) so a POST with a query\n\t\t// parameter reaches the API correctly instead of being dropped in the body.\n\t\tconst queryKeys = this.fields.filter((f) => f.inQuery).map((f) => f.name);\n\t\tconst lang = this.requestLang();\n\t\tif (this.hasLang && lang) {\n\t\t\tout.lang = lang;\n\t\t\tqueryKeys.push('lang');\n\t\t}\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('roxy-submit', {\n\t\t\t\tdetail: {\n\t\t\t\t\tendpoint: this.endpoint,\n\t\t\t\t\tvalues: out,\n\t\t\t\t\tqueryKeys,\n\t\t\t\t\tsticky: this.soleChoice != null || this.opensOnLoad,\n\t\t\t\t},\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Required fields left empty, with the location trio collapsed to one entry per group. Seed and hidden defaults never block. */\n\tprivate collectMissing(): { keys: string[]; labels: string[] } {\n\t\tconst keys: string[] = [];\n\t\tconst labels: string[] = [];\n\t\tconst locGroups = new Set<string | undefined>();\n\t\tfor (const f of this.fields) {\n\t\t\tif (!f.required) continue;\n\t\t\tconst isLocation = this.roleOf(f) === 'location';\n\t\t\tif (!this.isRendered(f) && !isLocation) continue;\n\t\t\tconst v = this.values[f.key];\n\t\t\tif (v !== undefined && v !== '') continue;\n\t\t\tkeys.push(f.key);\n\t\t\tif (isLocation) {\n\t\t\t\tlocGroups.add(this.cityGroup(f));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlabels.push(this.fieldLabel(f));\n\t\t}\n\t\tfor (const g of locGroups) {\n\t\t\tlabels.push(this.locationLabel(g));\n\t\t}\n\t\treturn { keys, labels };\n\t}\n\n\tprivate reqMark(f: FieldDef) {\n\t\treturn f.required\n\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t: nothing;\n\t}\n\n\t/**\n\t * A description under a field: rendered inline when short, collapsed behind a disclosure showing its first line when long.\n\t *\n\t * @remarks\n\t * Both shapes carry `part=\"hint\"` on their outermost element, so one `::part(hint)` rule reaches every field description on the form. The words are the API reference text for the request field, which is the right register on a developer page and the wrong one on a page written for a client, and hiding them leaves the label, the input and its validation untouched.\n\t */\n\tprivate description(f: FieldDef) {\n\t\tif (!f.description) return nothing;\n\t\tif (f.description.length <= 120) {\n\t\t\treturn html`<small part=\"hint\" class=\"help\">${f.description}</small>`;\n\t\t}\n\t\tconst lead = f.description.split('. ')[0] ?? f.description;\n\t\treturn html`<details part=\"hint\" class=\"help-details\"><summary><span class=\"help-lead\">${lead}</span>${chevron()}</summary><small class=\"help help-full\">${f.description}</small></details>`;\n\t}\n\n\tprivate renderTiles(f: FieldDef) {\n\t\tconst labelId = `roxy-form-${f.key}-label`;\n\t\tconst zodiac = !!f.enum && isZodiacEnum(f.enum);\n\t\tconst opts = this.choicesOf(f);\n\t\tconst narrow = isIndex(opts.map((o) => o.value));\n\t\tconst cur = opts.findIndex((o) => o.value === this.values[f.key]);\n\t\tconst active = cur === -1 ? opts.findIndex((o) => !o.disabled) : cur;\n\t\treturn html`<div class=\"field tiles-field\"><span class=\"label\" id=\"${labelId}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</span><div class=\"${narrow ? 'tiles narrow' : 'tiles'}\" role=\"radiogroup\" aria-labelledby=\"${labelId}\" @keydown=\"${this.onTilesKeyDown(f)}\">${opts.map((opt, i) => {\n\t\t\t\t\tconst selected = this.values[f.key] === opt.value;\n\t\t\t\t\tconst glyph = zodiac ? signGlyph(opt.value) : undefined;\n\t\t\t\t\treturn html`<button type=\"button\" class=\"tile\" role=\"radio\" data-tile=\"${i}\" aria-checked=\"${selected ? 'true' : 'false'}\" tabindex=\"${i === active ? '0' : '-1'}\" ?disabled=\"${!!opt.disabled || this.isDisabled(f)}\" @click=\"${() => this.chooseOption(f, opt.value)}\">${\n\t\t\t\t\t\t\tglyph\n\t\t\t\t\t\t\t\t? html`<span class=\"tile-glyph\" aria-hidden=\"true\">${glyph}</span>`\n\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t} <span class=\"tile-label\">${opt.label}</span></button>`;\n\t\t\t\t})}</div>${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderSelect(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\treturn html`<div part=\"field\" class=\"field\"><label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label> <select id=\"${id}\" ?required=\"${f.required}\" ?disabled=\"${this.isDisabled(f)}\" aria-invalid=\"${ifDefined(this.issueFor(f) ? 'true' : undefined)}\" aria-describedby=\"${ifDefined(this.issueFor(f) ? `${id}-error` : undefined)}\" .value=\"${live((this.values[f.key] ?? '') as string)}\" @change=\"${(e: Event) =>\n\t\t\t\t\tthis.chooseOption(f, (e.target as HTMLSelectElement).value)}\"><option value=\"\">${this.t('Choose')}</option>${this.choicesOf(f).map(\n\t\t\t\t\t(\n\t\t\t\t\t\topt,\n\t\t\t\t\t) => html`<option value=\"${opt.value}\" ?selected=\"${this.values[f.key] === opt.value}\" ?disabled=\"${!!opt.disabled}\">${opt.label}</option>`,\n\t\t\t\t)}</select> ${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\t/** A required identifier picked from its collection as the visitor types; the sole input on its form is named by the form title. */\n\tprivate renderPickerField(f: FieldDef, picker: OptionPicker) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst sole = this.soleChoice?.key === f.key;\n\t\tconst issue = this.issueFor(f);\n\t\treturn html`<div part=\"field\" class=\"field\">${sole ? nothing : html`<label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label>`} ${renderPicker(\n\t\t\t\tpicker,\n\t\t\t\tid,\n\t\t\t\t{\n\t\t\t\t\tplaceholder: this.t('Type to search'),\n\t\t\t\t\tempty: this.t('{{count}} matches', { count: 0 }),\n\t\t\t\t\tloading: this.t('Loading'),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabelledby: sole ? 'roxy-form-title' : undefined,\n\t\t\t\t\tdescribedby: issue ? `${id}-error` : undefined,\n\t\t\t\t\tinvalid: !!issue,\n\t\t\t\t},\n\t\t\t)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderToggle(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst checked = this.values[f.key] === true;\n\t\treturn html`<div part=\"field\" class=\"field\"><div class=\"toggle-row\"><button type=\"button\" id=\"${id}\" class=\"toggle\" role=\"switch\" aria-checked=\"${checked ? 'true' : 'false'}\" @click=\"${() => this.setValue(f.key, !checked)}\"><span class=\"knob\"></span></button> <label class=\"toggle-label\" for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label></div>${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderInput(f: FieldDef) {\n\t\tconst id = `roxy-form-${f.key}`;\n\t\tconst type =\n\t\t\tf.kind === 'datetime'\n\t\t\t\t? 'datetime-local'\n\t\t\t\t: f.kind === 'number'\n\t\t\t\t\t? 'number'\n\t\t\t\t\t: f.kind;\n\t\tconst placeholder =\n\t\t\tf.kind === 'array'\n\t\t\t\t? this.t('Comma separated')\n\t\t\t\t: f.example != null\n\t\t\t\t\t? String(f.example)\n\t\t\t\t\t: '';\n\t\treturn html`<div part=\"field\" class=\"field\"><label for=\"${id}\">${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label> <input id=\"${id}\" type=\"${f.kind === 'array' ? 'text' : type}\" ?required=\"${f.required}\" ?disabled=\"${this.isDisabled(f)}\" aria-invalid=\"${ifDefined(this.issueFor(f) ? 'true' : undefined)}\" aria-describedby=\"${ifDefined(this.issueFor(f) ? `${id}-error` : undefined)}\" min=\"${ifDefined(f.min)}\" max=\"${ifDefined(f.max)}\" step=\"${f.kind === 'number' ? 'any' : nothing}\" placeholder=\"${placeholder || nothing}\" .value=\"${(this.values[f.key] ?? '') as string}\" @input=\"${(e: Event) => {\n\t\t\t\t\tconst v = this.coerce(f.kind, (e.target as HTMLInputElement).value);\n\t\t\t\t\tif (this.opensOnLoad && f.kind === 'text') this.setFilter(f, v);\n\t\t\t\t\telse this.setValue(f.key, v);\n\t\t\t\t}}\"> ${this.description(f)} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\tprivate renderField(f: FieldDef) {\n\t\t// Only a timezone no coordinate pair claims reaches here; a claimed one is the location block's.\n\t\tif (f.city) return this.renderTimezoneCity(f);\n\t\tconst picker = this.pickers.get(f.key);\n\t\tif (picker) return this.renderPickerField(f, picker);\n\t\tconst listed = this.choices[f.key];\n\t\tif (listed === 'loading')\n\t\t\treturn html`<div class=\"field\"><div class=\"roxy-skeleton\" style=\"height:2.75rem\" aria-label=\"${this.t('Loading')}\" role=\"status\"></div></div>`;\n\t\tif (listed || f.kind === 'tiles' || f.kind === 'select')\n\t\t\treturn this.choiceKind(f) === 'tiles'\n\t\t\t\t? this.renderTiles(f)\n\t\t\t\t: this.renderSelect(f);\n\t\tswitch (f.kind) {\n\t\t\tcase 'toggle':\n\t\t\t\treturn this.renderToggle(f);\n\t\t\tdefault:\n\t\t\t\treturn this.renderInput(f);\n\t\t}\n\t}\n\n\t/** The shared group legend, using this form's chrome and field-label catalogues. */\n\tprivate groupName(group: string): string {\n\t\treturn deriveGroupLabel(\n\t\t\tgroup,\n\t\t\t(source, vars) => this.t(source, vars),\n\t\t\t(name) => this.fieldText(name),\n\t\t);\n\t}\n\n\t/** How many records a repeating property currently shows. */\n\tprivate repeatCount(key: string): number {\n\t\treturn new Set(\n\t\t\tthis.fields\n\t\t\t\t.map((f) => f.group && parseRepeatGroup(f.group))\n\t\t\t\t.filter((r) => r && r.key === key)\n\t\t\t\t.map((r) => (r as { index: number }).index),\n\t\t).size;\n\t}\n\n\t/** Appends a record with the same fields as the first, pre-filled with the schema defaults the first record was. */\n\tprivate addRecord(key: string) {\n\t\tconst index = this.repeatCount(key);\n\t\tconst added = repeatFields(this.fields, key, index);\n\t\tconst template = this.groups.find((g) => g.key === repeatGroup(key, 0));\n\t\tif (template) {\n\t\t\tconst rekey = (k: string) =>\n\t\t\t\tk.replace(`${repeatGroup(key, 0)}.`, `${repeatGroup(key, index)}.`);\n\t\t\tthis.groups = [\n\t\t\t\t...this.groups,\n\t\t\t\t{\n\t\t\t\t\t...template,\n\t\t\t\t\tkey: repeatGroup(key, index),\n\t\t\t\t\tlabel: deriveGroupLabel(repeatGroup(key, index)),\n\t\t\t\t\t...(template.location && {\n\t\t\t\t\t\tlocation: {\n\t\t\t\t\t\t\t...template.location,\n\t\t\t\t\t\t\tfields: template.location.fields.map(rekey),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tconst next = { ...this.values };\n\t\tfor (const f of added) if (f.default !== undefined) next[f.key] = f.default;\n\t\tthis.values = next;\n\t\tthis.fields = [...this.fields, ...added];\n\t}\n\n\t/** Drops the last record and every value it held, so a removed card cannot ride along in the body. */\n\tprivate removeRecord(key: string) {\n\t\tconst group = repeatGroup(key, this.repeatCount(key) - 1);\n\t\tthis.fields = this.fields.filter((f) => f.group !== group);\n\t\tthis.groups = this.groups.filter((g) => g.key !== group);\n\t\tconst next = { ...this.values };\n\t\tfor (const k of Object.keys(next))\n\t\t\tif (k.startsWith(`${group}.`)) delete next[k];\n\t\tthis.values = next;\n\t}\n\n\t/** The add and remove controls under the records of one repeating property, each only where the spec leaves room for it. */\n\tprivate repeatControls(repeat: RepeatDef) {\n\t\tconst count = this.repeatCount(repeat.key);\n\t\tif (repeat.max <= repeat.min) return nothing;\n\t\treturn html`<div class=\"repeat-controls\">${\n\t\t\t\tcount < repeat.max\n\t\t\t\t\t? html`<button type=\"button\" class=\"repeat-btn\" @click=\"${() => this.addRecord(repeat.key)}\"><span aria-hidden=\"true\">+</span> ${this.t('Add')}</button>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tcount > repeat.min\n\t\t\t\t\t? html`<button type=\"button\" class=\"repeat-btn\" @click=\"${() => this.removeRecord(repeat.key)}\"><span aria-hidden=\"true\">−</span> ${this.t('Remove')}</button>`\n\t\t\t\t\t: nothing\n\t\t\t}</div>`;\n\t}\n\n\t/**\n\t * The name of one location block, and of the same block in a validation message, which is why it is a method rather than two literals.\n\t *\n\t * The placeholder carries the group rather than the form concatenating a name in front of a translated noun, so a translator owns the word order: `Person 1 location` is English syntax, and Turkish suffixes the head noun, Hindi takes a genitive, Russian a parenthetical and German a colon. The four shapes are deliberately different and normalizing them breaks three languages.\n\t */\n\tprivate locationLabel(group?: string): string {\n\t\tif (group)\n\t\t\treturn this.t('{{group}} location', { group: this.groupName(group) });\n\t\treturn isBirthPlace(this.placeField(group))\n\t\t\t? this.t('Birth location')\n\t\t\t: this.t('Location');\n\t}\n\n\t/** One city search standing in for a group's raw coordinates. */\n\tprivate locationBlock(group?: string) {\n\t\treturn html`<div class=\"location-block\"><label>${this.locationLabel(group)}${\n\t\t\t\t\tthis.locationRequired(group)\n\t\t\t\t\t\t? html`<span class=\"req\" aria-hidden=\"true\">*</span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t}</label> ${this.citySearch(group, this.onLocationFor(group))} ${this.issueLines(this.cityIssues(group))}</div>`;\n\t}\n\n\t/** A `timezone` no coordinate pair claims, asked for as a city and labelled as the place: the IANA zone it writes resolves to the offset in force on the requested date. */\n\tprivate renderTimezoneCity(f: FieldDef) {\n\t\treturn html`<div part=\"field\" class=\"field location-block\"><label>${this.locationLabel(f.group)}${this.reqMark(f)}</label> ${this.citySearch(f.group, (city) => this.setValue(f.key, city.timezone))} ${this.fieldIssue(f)}</div>`;\n\t}\n\n\t/** The one city search every location input draws, its placeholder named for the place; `lang` and `endpoint` are forwarded because a shadow root hides the host page from it. */\n\tprivate citySearch(\n\t\tgroup: string | undefined,\n\t\tonPick: (city: PickedCity) => void,\n\t) {\n\t\tconst placeholder = group\n\t\t\t? this.t('{{group}} city', { group: this.groupName(group) })\n\t\t\t: isBirthPlace(this.placeField(group))\n\t\t\t\t? this.t('City of birth')\n\t\t\t\t: undefined;\n\t\treturn html`<roxy-location-search endpoint=\"${ifDefined(this.locationUrl || undefined)}\" publishable-key=\"${ifDefined(this.publishableKey)}\" lang=\"${ifDefined(this.effectiveLang())}\" placeholder=\"${ifDefined(placeholder)}\" @roxy-location-select=\"${(e: CustomEvent<PickedCity>) => onPick(e.detail)}\"></roxy-location-search><small class=\"help\">${this.t('Type a city, then pick it from the list.')}</small>`;\n\t}\n\n\tprivate groupCard(group: string) {\n\t\tconst fields = this.fields.filter(\n\t\t\t(f) => f.group === group && this.isRendered(f),\n\t\t);\n\t\treturn html`<fieldset part=\"group\" class=\"person-group\"><legend>${this.groupName(group)}</legend>${this.groupHasLocation(group) ? this.locationBlock(group) : nothing}<div class=\"fields\">${fields.map((f) => this.renderField(f))}</div>${this.issueLines(this.issuesForGroup(group))}</fieldset>`;\n\t}\n\n\trender() {\n\t\tif (!this.loaded) {\n\t\t\treturn html`<form><div class=\"roxy-skeleton\" style=\"height:8rem\"></div></form>`;\n\t\t}\n\t\tif (this.specError) {\n\t\t\treturn html`<div class=\"spec-error\" role=\"alert\">${this.t('Schema load failed: {{message}}', { message: this.specError })} <button type=\"button\" class=\"submit\" @click=\"${this.retryLoadSchema}\">${this.t('Retry')}</button></div>`;\n\t\t}\n\n\t\t// A refused key can never send, so the reason stands in for inputs nobody could submit.\n\t\tconst refusal = keyRefusal(this.publishableKey);\n\t\tif (refusal) {\n\t\t\treturn html`<form><h2 part=\"title\" class=\"title\" id=\"roxy-form-title\">${this.formTitle}</h2><div part=\"validation-error\" class=\"validation-error\" role=\"alert\">${this.t(refusal.message)}</div></form>`;\n\t\t}\n\n\t\tconst flat = this.fields.filter((f) => !f.group && this.isRendered(f));\n\t\tconst named = this.groupKeys().filter((g): g is string => g !== undefined);\n\t\tconst openFields = flat.filter((f) => !f.fold);\n\t\tconst tuckedFields = flat.filter((f) => f.fold);\n\t\tconst openGroups = named.filter(\n\t\t\t(key) => !this.groups.find((g) => g.key === key)?.fold,\n\t\t);\n\t\tconst tuckedGroups = named.filter(\n\t\t\t(key) => this.groups.find((g) => g.key === key)?.fold,\n\t\t);\n\t\tconst hasAdvanced = tuckedFields.length > 0 || tuckedGroups.length > 0;\n\n\t\treturn html`<form @submit=\"${this.onSubmit}\"><h2 part=\"title\" class=\"title\" id=\"roxy-form-title\">${this.formTitle}</h2>${\n\t\t\t\tthis.validationErrors.length > 0\n\t\t\t\t\t? html`<div part=\"validation-error\" class=\"validation-error\" role=\"alert\"><strong>${this.t('Please complete:')}</strong> ${this.validationErrors.join(', ')}</div>`\n\t\t\t\t\t: nothing\n\t\t\t} ${this.renderIssueSummary()}<div class=\"fields\">${openFields.map((f) => this.renderField(f))}</div>${this.groupHasLocation(undefined) ? this.locationBlock(undefined) : nothing} ${openGroups.map((g) => this.groupCard(g))} ${this.repeats.map((r) => this.repeatControls(r))} ${\n\t\t\t\thasAdvanced\n\t\t\t\t\t? html`<details part=\"advanced\" class=\"advanced\" ?open=\"${this.liveIssues().some((i) =>\n\t\t\t\t\t\t\t\t[...tuckedFields.map((f) => f.key), ...tuckedGroups].some(\n\t\t\t\t\t\t\t\t\t(k) => i.path === k || i.path.startsWith(`${k}.`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)}\"><summary>${this.t('Advanced')}${chevron()}</summary><div class=\"fields\">${tuckedFields.map((f) => this.renderField(f))}</div>${tuckedGroups.map((g) => this.groupCard(g))}</details>`\n\t\t\t\t\t: nothing\n\t\t\t} ${\n\t\t\t\tthis.selfSubmits\n\t\t\t\t\t? nothing\n\t\t\t\t\t: html`<button part=\"submit\" class=\"submit\" type=\"submit\">${this.effectiveSubmitLabel()}</button>`\n\t\t\t}</form>`;\n\t}\n\n\tprivate coerce(kind: string, v: string): unknown {\n\t\tif (v === '') return undefined;\n\t\tif (kind === 'number') {\n\t\t\tconst n = Number(v);\n\t\t\treturn Number.isFinite(n) ? n : undefined;\n\t\t}\n\t\treturn v;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-endpoint-form': RoxyEndpointForm;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "wkBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,6BAAAE,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,mBAAA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AAM,CAAC,GA/BlBnH,EAgCZ,6BASAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GAxClBnH,EAyCZ,4BAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GA5ClBnH,EA6CZ,wBAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GAhDlBnH,EAiDZ,wBAIAuH,EAAA,CADCJ,EAAS,CAAE,UAAW,EAAM,CAAC,GApDlBnH,EAqDZ,yBAIQuH,EAAA,CADPN,EAAM,GAxDKjH,EAyDJ,uBAOAuH,EAAA,CADPN,EAAM,GA/DKjH,EAgEJ,6BAGAuH,EAAA,CADPN,EAAM,GAlEKjH,EAmEJ,sBAOAuH,EAAA,CADPN,EAAM,GAzEKjH,EA0EJ,uBAGAuH,EAAA,CADPN,EAAM,GA5EKjH,EA6EJ,yBAGAuH,EAAA,CADPN,EAAM,GA/EKjH,EAgFJ,uBAGAuH,EAAA,CADPN,EAAM,GAlFKjH,EAmFJ,sBAGAuH,EAAA,CADPN,EAAM,GArFKjH,EAsFJ,sBAGAuH,EAAA,CADPN,EAAM,GAxFKjH,EAyFJ,yBAGAuH,EAAA,CADPN,EAAM,GA3FKjH,EA4FJ,gCA5FIA,EAANuH,EAAA,CADNC,GAAc,oBAAoB,GACtBxH,GjCzJbyH,EAAiB",
|
|
6
|
+
"names": ["cdn_endpoint_form_exports", "__export", "ROXY_UI_TOKENS_STYLE_ID", "RoxyEndpointForm", "injectRoxyTokens", "resetSpecCache", "ROXY_UI_TOKENS_CSS", "ROXY_UI_TOKENS_STYLE_ID", "injectRoxyTokens", "existing", "style", "ROXY_UI_TOKENS_CSS", "global", "globalThis", "supportsAdoptingStyleSheets", "ShadowRoot", "ShadyCSS", "nativeShadow", "Document", "prototype", "CSSStyleSheet", "constructionToken", "Symbol", "cssTagCache", "WeakMap", "CSSResult", "cssText", "strings", "safeToken", "this", "Error", "_strings", "styleSheet", "_styleSheet", "cacheable", "length", "get", "replaceSync", "set", "toString", "unsafeCSS", "value", "String", "css", "values", "reduce", "acc", "v", "idx", "adoptStyles", "renderRoot", "styles", "adoptedStyleSheets", "map", "s", "style", "document", "createElement", "nonce", "setAttribute", "textContent", "appendChild", "getCompatibleStyle", "sheet", "rule", "cssRules", "is", "defineProperty", "getOwnPropertyDescriptor", "getOwnPropertyNames", "getOwnPropertySymbols", "getPrototypeOf", "Object", "global", "globalThis", "trustedTypes", "emptyStringForBooleanAttribute", "emptyScript", "polyfillSupport", "reactiveElementPolyfillSupport", "JSCompiler_renameProperty", "prop", "_obj", "defaultConverter", "value", "type", "Boolean", "Array", "JSON", "stringify", "fromValue", "Number", "parse", "e", "notEqual", "old", "defaultPropertyDeclaration", "attribute", "String", "converter", "reflect", "useDefault", "hasChanged", "Symbol", "metadata", "litPropertyMetadata", "WeakMap", "ReactiveElement", "HTMLElement", "initializer", "this", "__prepare", "_initializers", "push", "observedAttributes", "finalize", "__attributeToPropertyMap", "keys", "name", "options", "state", "prototype", "hasOwnProperty", "create", "wrapped", "elementProperties", "set", "noAccessor", "key", "descriptor", "getPropertyDescriptor", "get", "v", "oldValue", "call", "requestUpdate", "configurable", "enumerable", "superCtor", "Map", "finalized", "props", "properties", "propKeys", "p", "createProperty", "attr", "__attributeNameForProperty", "elementStyles", "finalizeStyles", "styles", "isArray", "Set", "flat", "Infinity", "reverse", "s", "unshift", "getCompatibleStyle", "toLowerCase", "constructor", "super", "__instanceProperties", "isUpdatePending", "hasUpdated", "__reflectingProperty", "__initialize", "__updatePromise", "Promise", "res", "enableUpdating", "_$changedProperties", "__saveInstanceProperties", "forEach", "i", "controller", "__controllers", "add", "renderRoot", "isConnected", "hostConnected", "delete", "instanceProperties", "size", "createRenderRoot", "shadowRoot", "attachShadow", "shadowRootOptions", "adoptStyles", "connectedCallback", "c", "_requestedUpdate", "disconnectedCallback", "hostDisconnected", "_old", "_$attributeToProperty", "attrValue", "toAttribute", "removeAttribute", "setAttribute", "ctor", "propName", "getPropertyOptions", "fromAttribute", "convertedValue", "__defaultValues", "useNewValue", "newValue", "hasAttribute", "_$changeProperty", "__enqueueUpdate", "initializeValue", "has", "__reflectingProperties", "reject", "result", "scheduleUpdate", "performUpdate", "shouldUpdate", "changedProperties", "willUpdate", "hostUpdate", "update", "__markUpdated", "_$didUpdate", "_changedProperties", "hostUpdated", "firstUpdated", "updated", "updateComplete", "getUpdateComplete", "__propertyToAttribute", "mode", "reactiveElementVersions", "global", "globalThis", "wrap", "node", "trustedTypes", "policy", "createPolicy", "createHTML", "s", "boundAttributeSuffix", "marker", "Math", "random", "toFixed", "slice", "markerMatch", "nodeMarker", "d", "document", "createMarker", "createComment", "isPrimitive", "value", "isArray", "Array", "isIterable", "Symbol", "iterator", "SPACE_CHAR", "textEndRegex", "commentEndRegex", "comment2EndRegex", "tagEndRegex", "RegExp", "singleQuoteAttrEndRegex", "doubleQuoteAttrEndRegex", "rawTextElement", "tag", "type", "strings", "values", "_$litType$", "html", "svg", "mathml", "noChange", "for", "nothing", "templateCache", "WeakMap", "walker", "createTreeWalker", "trustFromTemplateString", "tsa", "stringFromTSA", "hasOwnProperty", "Error", "getTemplateHtml", "l", "length", "attrNames", "rawTextEndRegex", "regex", "i", "attrName", "match", "attrNameEndIndex", "lastIndex", "exec", "test", "end", "startsWith", "push", "Template", "constructor", "options", "this", "parts", "nodeIndex", "attrNameIndex", "partCount", "el", "createElement", "currentNode", "content", "wrapper", "firstChild", "replaceWith", "childNodes", "nextNode", "nodeType", "hasAttributes", "name", "getAttributeNames", "endsWith", "realName", "statics", "getAttribute", "split", "m", "index", "ctor", "PropertyPart", "BooleanAttributePart", "EventPart", "AttributePart", "removeAttribute", "tagName", "textContent", "emptyScript", "append", "data", "indexOf", "_options", "innerHTML", "resolveDirective", "part", "parent", "attributeIndex", "currentDirective", "__directives", "__directive", "nextDirectiveConstructor", "_$initialize", "_$resolve", "TemplateInstance", "template", "_$parts", "_$disconnectableChildren", "_$template", "_$parent", "parentNode", "_$isConnected", "fragment", "creationScope", "importNode", "partIndex", "templatePart", "ChildPart", "nextSibling", "ElementPart", "_$setValue", "__isConnected", "startNode", "endNode", "_$committedValue", "_$startNode", "_$endNode", "isConnected", "directiveParent", "_$clear", "_commitText", "_commitTemplateResult", "_commitNode", "_commitIterable", "insertBefore", "_insert", "createTextNode", "result", "_$getTemplate", "h", "_update", "instance", "_clone", "get", "set", "itemParts", "itemPart", "item", "start", "from", "_$notifyConnectionChanged", "n", "remove", "element", "fill", "String", "valueIndex", "noCommit", "change", "v", "_commitValue", "setAttribute", "toggleAttribute", "super", "newListener", "oldListener", "shouldRemoveListener", "capture", "once", "passive", "shouldAddListener", "removeEventListener", "addEventListener", "event", "call", "host", "handleEvent", "_$LH", "_boundAttributeSuffix", "_marker", "_markerMatch", "_HTML_RESULT", "_getTemplateHtml", "_TemplateInstance", "_isIterable", "_resolveDirective", "_ChildPart", "_AttributePart", "_BooleanAttributePart", "_EventPart", "_PropertyPart", "_ElementPart", "polyfillSupport", "litHtmlPolyfillSupport", "litHtmlVersions", "render", "container", "partOwnerNode", "renderBefore", "global", "globalThis", "LitElement", "ReactiveElement", "constructor", "this", "renderOptions", "host", "__childPart", "createRenderRoot", "renderRoot", "super", "renderBefore", "firstChild", "changedProperties", "value", "render", "hasUpdated", "isConnected", "update", "connectedCallback", "setConnected", "disconnectedCallback", "noChange", "litElementHydrateSupport", "polyfillSupport", "litElementPolyfillSupport", "global", "litElementVersions", "push", "customElement", "tagName", "classOrTarget", "context", "addInitializer", "customElements", "define", "defaultPropertyDeclaration", "attribute", "type", "String", "converter", "defaultConverter", "reflect", "hasChanged", "notEqual", "standardProperty", "options", "target", "context", "kind", "metadata", "properties", "globalThis", "litPropertyMetadata", "get", "set", "Map", "Object", "create", "wrapped", "name", "v", "oldValue", "call", "this", "requestUpdate", "_$changeProperty", "value", "Error", "property", "protoOrTarget", "nameOrContext", "proto", "hasOwnProperty", "constructor", "createProperty", "getOwnPropertyDescriptor", "undefined", "state", "options", "property", "attribute", "ifDefined", "value", "nothing", "PartType", "ATTRIBUTE", "CHILD", "PROPERTY", "BOOLEAN_ATTRIBUTE", "EVENT", "ELEMENT", "directive", "c", "values", "_$litDirective$", "Directive", "_partInfo", "_$isConnected", "this", "_$parent", "part", "parent", "attributeIndex", "__part", "__attributeIndex", "props", "update", "_part", "render", "_ChildPart", "ChildPart", "_$LH", "isSingleExpression", "part", "strings", "RESET_VALUE", "setCommittedValue", "part", "value", "_$committedValue", "live", "directive", "Directive", "partInfo", "super", "type", "PartType", "PROPERTY", "ATTRIBUTE", "BOOLEAN_ATTRIBUTE", "Error", "isSingleExpression", "value", "part", "noChange", "nothing", "element", "name", "hasAttribute", "getAttribute", "String", "setCommittedValue", "EN_FIELD_LABELS", "API_LANGUAGES", "resolveLang", "el", "inherited", "ZH_SCRIPT_BY_REGION", "asApiLang", "tag", "wanted", "API_LANGUAGES", "l", "apiLang", "exact", "parts", "base", "script", "p", "lookupKey", "s", "humanize", "s", "c", "GLOBAL_KEY", "registry", "holder", "existing", "created", "interpolate", "template", "vars", "match", "key", "translate", "lang", "source", "chromeLabel", "catalogs", "registry", "tag", "lookupKey", "labelsFor", "lang", "fieldLabels", "registry", "tag", "fieldLabel", "name", "optionLabel", "field", "value", "onLocaleChange", "listener", "listeners", "LocaleController", "host", "onLocaleChange", "RoxyLocalizedElement", "i", "source", "vars", "LocaleController", "translate", "resolveLang", "resolve", "table", "name", "lookupKey", "SIGN_GLYPH", "signGlyph", "name", "resolve", "SIGNS_ORDER", "baseStyles", "i", "chevron", "b", "disclosureStyles", "i", "SAMPLE_PUBLISHABLE_KEY", "KEY_REFUSALS", "keyRefusal", "key", "dispatchKeyRefusal", "host", "refusal", "opts", "DEFAULT_BASE_URL", "readApiFailure", "res", "body", "issues", "i", "ApiError", "message", "worded", "routeRefusal", "route", "keyRefusal", "canFetch", "apiFetch", "req", "signal", "refusal", "proxyBody", "callApi", "failure", "context", "url", "DEFAULT_BASE_URL", "k", "v", "headers", "OPTION_SOURCES", "DISABLED_WHEN", "repeatGroup", "key", "index", "parseRepeatGroup", "group", "m", "deriveGroupLabel", "interpolate", "fieldText", "name", "EN_FIELD_LABELS", "humanize", "repeat", "repeatFields", "fields", "key", "index", "first", "repeatGroup", "f", "optionKind", "values", "isIndex", "v", "LOCATION_TRIO", "LOCATION_PAIR", "splitCoordinateName", "name", "m", "ZODIAC_LOWER", "SIGNS_ORDER", "s", "resolveSchema", "schema", "all", "representative", "union", "scalarType", "real", "t", "classifyInput", "type", "isZodiacEnum", "lower", "toField", "resolved", "opts", "rep", "buildFormModel", "op", "schemas", "endpoint", "method", "repeats", "hasLang", "bodyRef", "bodySchema", "anyOf", "required", "sub", "item", "min", "itemRequired", "i", "subName", "subSchema", "r", "subRequired", "coord", "field", "humanize", "param", "EN_FIELD_LABELS", "noun", "withRenderIntent", "deriveTitle", "model", "operation", "sources", "OPTION_SOURCES", "rules", "DISABLED_WHEN", "groups", "deriveGroupLabel", "locations", "g", "group", "own", "timezone", "primaryGroups", "hasPrimary", "opensOnLoad", "summary", "lead", "deriveSubmitLabel", "sliceFileName", "path", "entriesOf", "json", "list", "n", "optionsFrom", "entries", "keys", "k", "out", "raw", "value", "totalOf", "displayField", "lang", "name", "english", "fieldLabel", "humanize", "displayOption", "field", "value", "fallback", "optionLabel", "comboboxStyles", "i", "debounce", "fn", "wait", "timer", "debounced", "args", "SUGGESTIONS", "MAX_PAGES", "optionCache", "sourceQuery", "source", "lang", "extra", "readOptions", "route", "field", "key", "pending", "readAll", "err", "out", "page", "json", "apiFetch", "got", "optionsFrom", "total", "totalOf", "fold", "s", "OptionPicker", "host", "source", "field", "context", "onPick", "debounce", "q", "option", "e", "n", "route", "lang", "all", "readOptions", "needle", "o", "err", "search", "controller", "json", "apiFetch", "sourceQuery", "SUGGESTIONS", "optionsFrom", "options", "renderPicker", "p", "id", "text", "aria", "listbox", "b", "A", "i", "pickerStyles", "comboboxStyles", "ROXY_UI_VERSION", "PROD_SPEC_URL", "SLICE_BASE", "ROXY_UI_VERSION", "specCache", "SpecHttpError", "status", "SpecMissingOperationError", "method", "path", "resetSpecCache", "loadSpec", "url", "pending", "res", "err", "randomSeed", "isBirthPlace", "f", "isNested", "parseArrayValue", "raw", "trimmed", "parsed", "s", "RoxyEndpointForm", "RoxyLocalizedElement", "spec", "op", "buildFormModel", "sliceFileName", "model", "withRenderIntent", "init", "seed", "remembered", "canFetch", "old", "context", "picker", "OptionPicker", "readOptions", "options", "_", "rest", "name", "value", "patch", "edited", "k", "i", "values", "when", "changed", "refusal", "keyRefusal", "dispatchKeyRefusal", "group", "x", "issues", "b", "issue", "A", "labelFor", "field", "g", "inGroup", "req", "only", "shown", "o", "isIndex", "optionKind", "listed", "deriveSubmitLabel", "apiLang", "label", "displayField", "EN_FIELD_LABELS", "displayOption", "city", "keys", "key", "other", "e", "opts", "cur", "next", "root", "tile", "missing", "out", "v", "repeat", "parseRepeatGroup", "list", "queryKeys", "lang", "labels", "locGroups", "isLocation", "lead", "chevron", "labelId", "zodiac", "isZodiacEnum", "narrow", "active", "opt", "selected", "glyph", "signGlyph", "id", "l", "sole", "renderPicker", "checked", "type", "placeholder", "deriveGroupLabel", "source", "vars", "index", "added", "repeatFields", "template", "repeatGroup", "rekey", "count", "onPick", "fields", "flat", "named", "openFields", "tuckedFields", "openGroups", "tuckedGroups", "hasAdvanced", "r", "kind", "n", "baseStyles", "disclosureStyles", "pickerStyles", "__decorateClass", "t", "injectRoxyTokens"]
|
|
7
7
|
}
|