@pontive/pontkit-core 1.34.1 → 1.35.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../pont2/src/core/attrs.ts","../../pont2/src/core/names.ts","../../pont2/src/core/host-element.ts","../../pont2/src/core/form-control.ts","../../pont2/src/core/ids.ts","../../pont2/src/core/events.ts","../../pont2/src/core/icons.ts","../../pont2/src/core/controllers/roving-focus.ts","../../pont2/src/core/controllers/action.ts","../../pont2/src/core/controllers/copy.ts","../../pont2/src/primitives/badge/badge.ts","../../pont2/src/primitives/button/button.ts","../../pont2/src/primitives/checkbox/checkbox.ts","../../pont2/src/primitives/input/input.ts","../../pont2/src/primitives/kbd/kbd.ts","../../pont2/src/primitives/label/label.ts","../../pont2/src/primitives/separator/separator.ts","../../pont2/src/primitives/skeleton/skeleton.ts","../../pont2/src/primitives/spinner/spinner.ts","../../pont2/src/primitives/textarea/textarea.ts","../../pont2/src/primitives/alert/alert.ts","../../pont2/src/primitives/avatar/avatar.ts","../../pont2/src/primitives/button-group/button-group.ts","../../pont2/src/primitives/card/card.ts","../../pont2/src/primitives/empty/empty.ts","../../pont2/src/primitives/field/field.ts","../../pont2/src/primitives/input-group/input-group.ts","../../pont2/src/primitives/item/item.ts","../../pont2/src/primitives/native-select/native-select.ts","../../pont2/src/primitives/table/table.ts","../../pont2/src/primitives/input-otp/otp.ts","../../pont2/src/primitives/input-otp/input-otp.ts","../../pont2/src/primitives/progress/progress.ts","../../pont2/src/primitives/radio-group/radio-group.ts","../../pont2/src/primitives/slider/slider-math.ts","../../pont2/src/primitives/slider/slider.ts","../../pont2/src/primitives/switch/switch.ts","../../pont2/src/primitives/tabs/tabs.ts","../../pont2/src/core/popup/position.ts","../../pont2/src/core/popup/anchored.ts","../../pont2/src/core/popup/list.ts","../../pont2/src/core/popup/popup-content.ts","../../pont2/src/core/popup/popup-root.ts","../../pont2/src/primitives/popover/popover.ts","../../pont2/src/primitives/dropdown-menu/dropdown-menu.ts","../../pont2/src/primitives/select/select.ts","../../pont2/src/primitives/combobox/combobox.ts","../../pont2/src/primitives/tooltip/tooltip.ts","../../pont2/src/kit/aliases.ts","../../pont2/src/kit/alert/alert.ts","../../pont2/src/kit/avatar/avatar.ts","../../pont2/src/kit/input-otp/input-otp.ts","../../pont2/src/kit/auth-button/providers.ts","../../pont2/src/kit/auth-button/auth-button.ts","../../pont2/src/kit/auth-field/auth-field.ts","../../pont2/src/kit/auth-field/password-field.ts","../../pont2/src/kit/otp-field/otp-field.ts","../../pont2/src/kit/otp-field/otp-resend.ts","../../pont2/src/kit/link/link.ts","../../pont2/src/kit/divider/divider.ts","../../pont2/src/kit/typography/typography.ts","../../pont2/src/kit/provider-field/provider-field.ts","../../pont2/src/kit/watermark/pontive-logo.ts","../../pont2/src/kit/watermark/watermark.ts","../../pont2/src/kit/block/branding.ts","../../pont2/src/kit/block/block.ts","../../pont2/src/kit/container/container.ts","../../pont2/src/kit/header/header.ts","../../pont2/src/kit/gap/gap.ts","../../pont2/src/kit/logo/logo.ts","../../pont2/src/kit/countdown/countdown.ts","../../pont2/src/kit/edit-identifier/edit-identifier.ts","../../pont2/src/kit/secret/secret.ts","../../pont2/src/kit/qr-code/qr-code.ts","../../pont2/src/kit/recovery-codes/recovery-codes.ts","../../pont2/src/kit/scope-list/scope-value.ts","../../pont2/src/kit/scope-list/scope-list.ts","../../pont2/src/kit/layout/flow-error.ts","../../pont2/src/kit/layout/layout.ts","../../pont2/src/kit/flow-widget/flow-widget.ts","../../pont2/src/kit/flow-widget/preview.ts","../../pont2/src/kit/flow-widget/specimens.ts"],"sourcesContent":["import { noChange } from \"lit\";\nimport { Directive, directive, PartType, type ElementPart, type PartInfo } from \"lit/directive.js\";\n\nexport type AttrValue = string | number | boolean | null | undefined;\nexport type AttrMap = Record<string, AttrValue>;\n\n/**\n * `<button ${attrs({ \"data-provider\": \"google\", \"aria-busy\": loading })}>`\n *\n * Lit has no attribute spread; part functions need one. It plays the role of\n * `{...props}` in a shadcn component: a composing component can put extra\n * attributes on the *same* element a part renders, so it never has to wrap\n * that element. `true` → empty attribute; `false`/`null`/`undefined` → removed;\n * keys dropped since the previous render are removed.\n */\nclass AttrsDirective extends Directive {\n private prev = new Set<string>();\n\n constructor(info: PartInfo) {\n super(info);\n if (info.type !== PartType.ELEMENT) throw new Error(\"attrs() must be used in element position\");\n }\n\n render(_attrs: AttrMap) {\n return noChange;\n }\n\n override update(part: ElementPart, [map]: [AttrMap]) {\n applyAttrs(part.element, map, this.prev);\n this.prev = new Set(Object.keys(map));\n return noChange;\n }\n}\n\nexport const attrs = directive(AttrsDirective);\n\n/** Imperative twin of `attrs()`, for code that holds a node rather than a template. */\nexport function applyAttrs(el: Element, map: AttrMap, previous?: Iterable<string>): void {\n if (previous) for (const k of previous) if (!(k in map)) el.removeAttribute(k);\n for (const [k, v] of Object.entries(map)) {\n if (v === false || v == null) {\n if (el.hasAttribute(k)) el.removeAttribute(k);\n } else {\n const s = v === true ? \"\" : String(v);\n if (el.getAttribute(k) !== s) el.setAttribute(k, s);\n }\n }\n}\n","/**\n * The pont2 namespace, in one place.\n *\n * | Thing | Form | Example |\n * |------------------|-------------------------------|--------------------------------------|\n * | primitive tag | `pont2-prim-<name>` | `pont2-prim-alert`, `pont2-prim-alert-title` |\n * | kit tag | `pont2-<name>` | `pont2-alert` (composite), `pont2-button` (alias) |\n * | identity attr | `data-pont2-<identity>` | `data-pont2-alert` (tier-neutral: \"this is an alert\") |\n * | slot attr | `data-slot=\"<name>\"` | `data-slot=\"item-separator\"` (shadcn's own, unprefixed) |\n * | state attrs | `data-<state>` | `data-checked`, `data-open` (Base UI's own, unprefixed) |\n * | CSS custom prop | `--pont2-sem-<role>` … | `--pont2-sem-color-primary` (docs/11-tokens.md) |\n * | cascade layer | `pont2.<layer>` | `pont2.primitives`, `pont2.kit` |\n * | custom event | `pont2-<name>` | `pont2-open-change` |\n *\n * Two element surfaces share one namespace (docs/10-primitives-and-kit.md):\n *\n * - **primitives** `pont2-prim-*`: shadcn's components, one for one.\n * - **kit** `pont2-*`: what applications use. A kit element is either an\n * *alias* of a primitive (same behaviour, second tag) or a *composite* (a\n * subclass of a primitive that renders the primitive's children from\n * properties). Invariant: **`pont2-<name>` is always a `<name>` at its\n * root**, which is what lets `sel()` / `tags()` match both surfaces at once.\n *\n * The identity attribute is tier-neutral on purpose: it says *what* an element\n * is (an alert), not *which tag* produced it. Recipes and lookups key on it, so\n * a primitive, its alias, a composite built on it and hand-written recipe\n * markup are all styled and found the same way.\n *\n * `data-slot` and the state attributes stay unprefixed on purpose: they are\n * shadcn's and Base UI's public styling contract, and keeping them verbatim\n * is what lets shadcn styles port across mechanically.\n */\nexport const PREFIX = \"pont2\";\n/** Tag segment that marks the primitive surface. */\nexport const PRIM = \"prim\";\n\n/** Kit tag: `tag(\"alert\")` → `pont2-alert`. */\nexport const tag = (name: string) => `${PREFIX}-${name}` as const;\n/** Primitive tag: `primTag(\"alert\")` → `pont2-prim-alert`. */\nexport const primTag = (name: string) => `${PREFIX}-${PRIM}-${name}` as const;\nexport const identityAttr = (identity: string) => `data-${PREFIX}-${identity}` as const;\n\n/**\n * Selector for every element that *is* a `<name>`: its primitive tag, its kit\n * tag (an alias or a composite, which by the kit invariant has that root) and\n * its identity attribute (upgraded elements, parts rendered by composites,\n * hand-written recipe markup).\n *\n * `sel(\"alert\")` → `:is(pont2-prim-alert, pont2-alert, [data-pont2-alert])`\n *\n * Use it for every structural lookup (`closest`, `querySelector`), so a\n * component works whichever surface its parts were written with.\n * Tier 3 shells are the exception: their identity attribute lives on the\n * native child, so look shells up with `tags()`.\n */\nexport const sel = (name: string) => `:is(${primTag(name)}, ${tag(name)}, [${identityAttr(name)}])`;\n\n/** The element tags only, on both surfaces: `:is(pont2-prim-x, pont2-x)`. Use for shells. */\nexport const tags = (name: string) => `:is(${primTag(name)}, ${tag(name)})`;\n\n/**\n * Registers an element once. Re-registration (HMR, a second bundle copy) is a\n * no-op rather than a thrown DOMException, but a *different* class under the\n * same tag is reported, because that means two copies of pont2 are loaded.\n */\nexport function define(name: string, ctor: CustomElementConstructor): void {\n const existing = customElements.get(name);\n if (!existing) {\n customElements.define(name, ctor);\n } else if (existing !== ctor && import.meta.env?.DEV) {\n console.warn(`[pont2] <${name}> is already defined by another class (two pont2 copies loaded?).`);\n }\n}\n\nconst aliases = new Map<CustomElementConstructor, CustomElementConstructor>();\n\n/**\n * Promotes a primitive to the kit surface unchanged: `pont2-<name>` becomes a\n * second tag for `pont2-prim-<name>`.\n *\n * The platform forbids registering one constructor under two names, so the\n * alias is an empty subclass. It inherits everything (identity, slot, role,\n * properties, form association), so it is styled, announced and submitted\n * exactly like the primitive, and `instanceof` the primitive class holds.\n *\n * ```ts\n * defineAlias(\"pont2-button\", Pont2Button); // <pont2-prim-button> → also <pont2-button>\n * ```\n *\n * Returns the alias constructor.\n */\nexport function defineAlias<T extends CustomElementConstructor>(kitTag: `pont2-${string}`, base: T): T {\n if (import.meta.env?.DEV) {\n const expected = kitTag.replace(`${PREFIX}-`, `${PREFIX}-${PRIM}-`);\n const registered = customElements.getName?.(base);\n if (registered && registered !== expected) {\n console.warn(`[pont2] defineAlias(\"${kitTag}\") expects the class registered as <${expected}>, got <${registered}>.`);\n }\n }\n let alias = aliases.get(base) as T | undefined;\n if (!alias) {\n // Static members (properties, identity, formAssociated, nativeSelector…)\n // are inherited through the constructor's prototype chain.\n alias = class extends (base as unknown as new () => HTMLElement) {} as unknown as T;\n Object.defineProperty(alias, \"name\", { value: `${base.name}Alias` });\n aliases.set(base, alias);\n }\n define(kitTag, alias);\n return customElements.get(kitTag) as T;\n}\n","import { LitElement, ReactiveElement, type PropertyValues } from \"lit\";\nimport type { DirectiveResult } from \"lit/directive.js\";\n\nimport { attrs, type AttrMap } from \"./attrs\";\nimport { identityAttr, PREFIX } from \"./names\";\n\n/**\n * # HostElement: the host is the component's root element\n *\n * The base class of every pont2 element. A shadcn component is a function\n * that returns its root element and then disappears. A custom element cannot\n * disappear, so in pont2 **the host *is* the root**: `<pont2-prim-separator>` is the\n * separator, it does not render one.\n *\n * What a subclass gets:\n *\n * | Static / member | Does |\n * |---------------------|----------------------------------------------------------------------|\n * | `static identity` | Stamps `data-pont2-<identity>`. Every class in the chain adds its own, so a subclass keeps its base's styles (`pont2-prim-item-separator` carries `data-pont2-separator` *and* `data-pont2-item-separator`). |\n * | `static slotName` | Stamps `data-slot` (shadcn's convention). Most-derived class wins. An author-written `data-slot` is never overwritten. |\n * | `static role` | Default ARIA role through `ElementInternals`. An author's `role=\"\"` attribute still wins. |\n * | `internals` | `ElementInternals`: default ARIA, custom states, forms (see FormControlElement). |\n * | `setData()` | Writes component-owned `data-*` state on the host (Base UI's presence-style attributes). |\n * | `setState()` | Adds/removes a CustomStateSet entry, matchable as `:state(x)`. |\n * | `static part()` | The same identity, slot and role as attributes, for a composite to put on a plain element (see below). |\n * | `static composite` | Marks a kit composite: it renders its whole subtree from properties (docs/10-primitives-and-kit.md). |\n *\n * Light DOM throughout: `createRenderRoot()` returns `this`. Most Tier 1\n * elements never override `render()`; their children are whatever the author\n * wrote, left exactly where the author wrote them.\n */\nexport abstract class HostElement extends LitElement {\n /** Style identity → `data-pont2-<identity>`. Inherited along the class chain. */\n static identity?: string;\n /** shadcn `data-slot` value. Most-derived wins; never overrides the author. */\n static slotName?: string;\n /** Default ARIA role, set through ElementInternals (author attribute wins). */\n static role?: string;\n\n /**\n * `true` on kit composites (`src/kit/`): the element renders its entire\n * subtree from properties, so author-written children are a mistake (use the\n * `pont2-prim-*` form for custom content). Reported once in development.\n */\n static composite = false;\n\n /**\n * A **part**: this element's identity, `data-slot` and default role as plain\n * attributes, for a template to put on a native element.\n *\n * ```ts\n * html`<div ${AlertTitle.part()}>${this.heading}</div>`\n * // → <div data-pont2-alert-title data-slot=\"alert-title\">…</div>\n * ```\n *\n * The result is styled by the element's recipe and found by `sel()` lookups,\n * exactly like the element itself, so a composite reproduces shadcn's DOM\n * without nesting custom elements. A part carries **attributes only**: use\n * it for Tier 1 elements whose host adds nothing but identity, slot and role.\n * An element with behaviour (state, observers, keyboard, form association)\n * has to be rendered as the element. `extra` adds or overrides attributes.\n */\n static part(extra: AttrMap = {}): DirectiveResult {\n const map: AttrMap = {};\n for (const id of identitiesOf(this)) map[identityAttr(id)] = true;\n if (this.slotName) map[\"data-slot\"] = this.slotName;\n if (this.role) map.role = this.role;\n return attrs({ ...map, ...extra });\n }\n\n protected readonly internals: ElementInternals = this.attachInternals();\n\n protected override createRenderRoot(): HTMLElement {\n return this;\n }\n\n /**\n * Elements that do not override `render()` (most Tier 1 hosts) skip Lit's\n * template rendering entirely. Otherwise lit-html would append a `<!---->`\n * part marker to the author's children: a stray node in a component whose\n * whole point is to add none, and one more node for React to step around.\n */\n protected override update(changed: PropertyValues): void {\n if (this.render === HostElement.prototype.render) {\n ReactiveElement.prototype[\"update\"].call(this, changed);\n return;\n }\n super.update(changed);\n }\n\n override connectedCallback(): void {\n const ctor = this.constructor as typeof HostElement;\n if (ctor.composite && !this.hasUpdated && import.meta.env?.DEV) warnAuthorChildren(this);\n super.connectedCallback();\n\n // Attributes may not be added in a custom element constructor (it would\n // make document.createElement() throw), so identity is stamped on connect.\n for (const id of identitiesOf(ctor)) {\n if (!this.hasAttribute(`data-${PREFIX}-${id}`)) {\n this.setAttribute(`data-${PREFIX}-${id}`, \"\");\n }\n }\n if (ctor.slotName && !this.hasAttribute(\"data-slot\")) {\n this.setAttribute(\"data-slot\", ctor.slotName);\n }\n if (ctor.role && !this.internals.role) this.internals.role = ctor.role;\n }\n\n /**\n * Sets `data-<name>`: a string value, `true` → empty (presence) attribute,\n * `false`/`null`/`undefined` → removed. Base UI exposes state as presence\n * attributes (`data-checked`, `data-disabled`, `data-open`), which is what\n * shadcn's Base UI styles select on, so `true`/`false` is the common call.\n */\n protected setData(name: string, value: string | boolean | null | undefined): void {\n const attr = `data-${name}`;\n if (value === false || value == null) {\n if (this.hasAttribute(attr)) this.removeAttribute(attr);\n } else {\n const v = value === true ? \"\" : value;\n if (this.getAttribute(attr) !== v) this.setAttribute(attr, v);\n }\n }\n\n /** Adds or removes a custom state, matchable in CSS as `:state(<name>)`. */\n protected setState(name: string, on: boolean): void {\n try {\n if (on) this.internals.states.add(name);\n else this.internals.states.delete(name);\n } catch {\n // Very old engines only accepted `--name`; state is a nicety, never load-bearing.\n }\n }\n}\n\nfunction warnAuthorChildren(el: HTMLElement): void {\n const authored = Array.from(el.childNodes).some(\n n => n.nodeType === Node.ELEMENT_NODE || (n.nodeType === Node.TEXT_NODE && n.textContent!.trim() !== \"\"),\n );\n if (authored) {\n console.warn(\n `[pont2] <${el.localName}> is a composite: it renders its content from properties and ignores children. ` +\n `For custom content, write the primitive form instead (the pont2-prim-* elements it is built from).`,\n el,\n );\n }\n}\n\n/** Every `identity` declared along the prototype chain, most-derived first. */\nexport function identitiesOf(ctor: typeof HostElement): string[] {\n const out: string[] = [];\n let c: unknown = ctor;\n while (typeof c === \"function\" && c !== HostElement && c !== LitElement) {\n const k = c as typeof HostElement;\n if (Object.hasOwn(k, \"identity\") && k.identity) out.push(k.identity);\n c = Object.getPrototypeOf(c);\n }\n return out;\n}\n\n/**\n * # ShellElement: Tier 3 (native-bound) host\n *\n * Some shadcn roots must stay *native* elements: `<button>`, `<a>`, `<input>`,\n * `<textarea>`, `<label>`, `<select>`, `<table>`, `<fieldset>`. Their behaviour\n * (implicit form submission, `SubmitEvent.submitter`, autofill, password\n * managers, real links, `for=` labelling, table parsing) cannot be emulated\n * faithfully by a custom element.\n *\n * For those, the host is a **transparent shell**: `display: contents`\n * (`[data-pont2-shell]` in styles/base.css), no role, no styles, no box. It\n * exists only so HTML authors have a tag. Everything styled or announced lives\n * on the one native element inside it. Two nodes is the platform floor for\n * native semantics, and composition never adds a third.\n *\n * Never style a shell, give it a role, or anchor positioning to it. Use\n * `control` (the native element) instead.\n */\nexport abstract class ShellElement extends HostElement {\n static override identity = \"shell\";\n\n /** The single native element this shell stands for. */\n abstract get control(): HTMLElement | null;\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n override blur(): void {\n this.control?.blur();\n }\n}\n\n/**\n * # NativeEnhancer: Tier 3 element form (\"asChild\")\n *\n * `<pont2-prim-button variant=\"outline\"><button>Save</button></pont2-prim-button>`\n *\n * The author writes the native element; the shell applies the recipe to it\n * (attributes only). The native node is never moved, wrapped or re-created,\n * so React, a parent Lit template or server HTML keep owning it. A\n * MutationObserver re-applies the recipe if the child is swapped.\n *\n * This is shadcn's `asChild` / Base UI's `render` prop, expressed in HTML.\n */\nexport abstract class NativeEnhancer<T extends HTMLElement = HTMLElement> extends ShellElement {\n /** Selector for the native child this enhancer applies its recipe to. */\n static nativeSelector = \"*\";\n\n private _observer?: MutationObserver;\n private _warned = false;\n\n override get control(): T | null {\n const sel = (this.constructor as typeof NativeEnhancer).nativeSelector;\n for (const child of Array.from(this.children)) {\n if (child.matches(sel)) return child as T;\n }\n return null;\n }\n\n /** Apply the recipe (attributes / properties) to the native element. */\n protected abstract apply(control: T): void;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._observer ??= new MutationObserver(() => this.requestUpdate());\n this._observer.observe(this, { childList: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._observer?.disconnect();\n }\n\n protected override updated(): void {\n const el = this.control;\n if (el) {\n this.apply(el);\n return;\n }\n if (!this._warned && this.isConnected && this.childNodes.length) {\n this._warned = true;\n const sel = (this.constructor as typeof NativeEnhancer).nativeSelector;\n console.warn(\n `<${this.localName}> enhances a native child element (${sel}) and found none. ` +\n `Write <${this.localName}><${sel.split(\",\")[0].trim()}>…</…></${this.localName}>, ` +\n `or use the recipe attributes on the native element directly.`,\n this,\n );\n }\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement } from \"./host-element\";\n\nexport interface ValidityResult {\n flags: ValidityStateFlags;\n message: string;\n}\n\n/**\n * # FormControlElement: Tier 2 form-associated widget\n *\n * The base for widgets whose host is an ARIA widget root *and* a form control\n * (Checkbox, Switch, RadioGroup, Slider, Select, Combobox, InputOTP …). It is\n * a **form-associated custom element** (FACE), so with no hidden `<input>`:\n *\n * - it submits `name=value` with its `<form>` (`internals.setFormValue`);\n * - it takes part in constraint validation (`setValidity`, `:invalid`,\n * `checkValidity()`, `reportValidity()`, blocking submit when `required`);\n * - it is disabled by `disabled`, by an ancestor `<fieldset disabled>` and by\n * its form, through `formDisabledCallback`;\n * - it resets with its form (`formResetCallback`) and restores on\n * back/forward navigation (`formStateRestoreCallback`);\n * - it is labelable: `<label for>` and wrapping labels work, and `labels`\n * lists them;\n * - the `form=\"id\"` content attribute works natively.\n *\n * Base UI renders a visually hidden `<input>` next to each such widget to get\n * the same effect in React. A FACE makes that node unnecessary, which is\n * one node fewer than shadcn/Base UI.\n *\n * Subclasses implement `formValue()`, `resetToDefault()` and optionally\n * `validate()`; the base syncs internals/data attributes after every update.\n */\nexport abstract class FormControlElement extends HostElement {\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n name: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n readOnly: { type: Boolean, reflect: true, attribute: \"readonly\" },\n formDisabled: { state: true },\n };\n\n declare name: string;\n declare disabled: boolean;\n declare required: boolean;\n declare readOnly: boolean;\n /** Disabled by an ancestor `<fieldset disabled>` or the form. */\n declare protected formDisabled: boolean;\n\n private _customMessage = \"\";\n\n constructor() {\n super();\n this.name = \"\";\n this.disabled = false;\n this.required = false;\n this.readOnly = false;\n this.formDisabled = false;\n }\n\n /* -------------------------------------------------------------- */\n /* Subclass contract */\n /* -------------------------------------------------------------- */\n\n /** What the control submits. `null` submits nothing (an unchecked checkbox). */\n protected abstract formValue(): string | File | FormData | null;\n\n /** Restore the default value (the one in the markup). */\n protected abstract resetToDefault(): void;\n\n /** Built-in constraint check. Return `null` when valid. */\n protected validate(): ValidityResult | null {\n return null;\n }\n\n /** Whether the host itself is a tab stop. Composite widgets with an inner roving tab stop return false. */\n protected get hostFocusable(): boolean {\n return true;\n }\n\n /** Element `reportValidity()` should point at (must be inside the host). */\n protected get validationAnchor(): HTMLElement | undefined {\n return undefined;\n }\n\n /* -------------------------------------------------------------- */\n /* Public form API (mirrors native controls) */\n /* -------------------------------------------------------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n /** `disabled` or disabled by a fieldset/form. */\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n setCustomValidity(message: string): void {\n this._customMessage = message;\n this.syncValidity();\n }\n\n /* -------------------------------------------------------------- */\n /* FACE lifecycle */\n /* -------------------------------------------------------------- */\n\n formResetCallback(): void {\n this.resetToDefault();\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n formStateRestoreCallback(state: string | File | FormData | null): void {\n this.restoreState(state);\n }\n\n /** Override to restore from the value `formValue()` produced. */\n protected restoreState(_state: string | File | FormData | null): void {}\n\n /* -------------------------------------------------------------- */\n /* Sync */\n /* -------------------------------------------------------------- */\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n\n this.internals.ariaDisabled = disabled ? \"true\" : null;\n this.internals.ariaRequired = this.required ? \"true\" : null;\n this.internals.ariaReadOnly = this.readOnly ? \"true\" : null;\n this.setData(\"disabled\", disabled);\n this.setData(\"required\", this.required);\n this.setData(\"readonly\", this.readOnly);\n\n if (this.hostFocusable) {\n if (disabled) this.removeAttribute(\"tabindex\");\n else if (!this.hasAttribute(\"tabindex\")) this.tabIndex = 0;\n }\n\n this.internals.setFormValue(this.formValue());\n this.syncValidity();\n }\n\n protected syncValidity(): void {\n const own = this.validate();\n if (this._customMessage) {\n this.internals.setValidity({ customError: true }, this._customMessage, this.validationAnchor);\n } else if (own) {\n this.internals.setValidity(own.flags, own.message, this.validationAnchor);\n } else {\n this.internals.setValidity({});\n }\n }\n}\n","let counter = 0;\n\n/** A document-unique id, e.g. `pont2-field-3`. Like React's `useId()`. */\nexport function uid(scope = \"id\"): string {\n counter += 1;\n return `pont2-${scope}-${counter}`;\n}\n\n/** Returns `el.id`, assigning a fresh `uid(scope)` first if it has none. */\nexport function ensureId(el: Element, scope = \"id\"): string {\n if (!el.id) el.id = uid(scope);\n return el.id;\n}\n\n/** Adds/removes an id in a space-separated IDREF list attribute (aria-describedby etc.). */\nexport function toggleIdRef(el: Element, attr: string, id: string, on: boolean): void {\n const ids = new Set((el.getAttribute(attr) ?? \"\").split(/\\s+/).filter(Boolean));\n if (on) ids.add(id);\n else ids.delete(id);\n if (ids.size) el.setAttribute(attr, [...ids].join(\" \"));\n else el.removeAttribute(attr);\n}\n","/**\n * Event conventions (docs/02-conventions.md, \"Events\"):\n *\n * - Value-holding widgets fire the platform's own `input` (while the value\n * changes through interaction) and `change` (when it is committed), both\n * bubbling, exactly like native controls. The new value is read from the\n * target (`e.target.checked`, `e.target.value`), so `@change=${…}` in Lit,\n * `onChange` via @lit/react and `addEventListener(\"change\")` all work.\n * - Anything without a native equivalent is a `pont2-<name>` CustomEvent with\n * a typed `detail`, bubbling and composed. Base UI's `onOpenChange(open,\n * details)` becomes `pont2-open-change` with `{ open, reason }`; it is\n * cancelable, and `preventDefault()` keeps the current state (Base UI's\n * `eventDetails.cancel()`).\n * - Events fire only for user-initiated changes, never for property writes,\n * matching native controls (and Base UI's controlled props).\n */\nexport function fireNative(target: EventTarget, type: \"input\" | \"change\"): void {\n target.dispatchEvent(new Event(type, { bubbles: true, composed: type === \"input\" }));\n}\n\nexport function fire<T>(target: EventTarget, type: `pont2-${string}`, detail: T, cancelable = false): boolean {\n return target.dispatchEvent(new CustomEvent<T>(type, { detail, bubbles: true, composed: true, cancelable }));\n}\n\nexport type OpenChangeReason =\n | \"trigger-press\"\n | \"trigger-hover\"\n | \"trigger-focus\"\n | \"outside-press\"\n | \"escape-key\"\n | \"item-press\"\n | \"list-navigation\"\n | \"input-change\"\n | \"focus-out\"\n | \"imperative\";\n\nexport interface OpenChangeDetail {\n open: boolean;\n reason: OpenChangeReason;\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-open-change\": CustomEvent<OpenChangeDetail>;\n }\n}\n","import { html, svg, type SVGTemplateResult, type TemplateResult } from \"lit\";\n\nimport { attrs, type AttrMap } from \"./attrs\";\n\n/**\n * The handful of icons primitives draw themselves (check marks, chevrons,\n * the spinner). shadcn renders these with lucide-react through an\n * `IconPlaceholder`; pont2 inlines the same lucide geometry so it has no icon\n * dependency. Lucide is ISC-licensed (https://lucide.dev/license).\n *\n * Every icon is `aria-hidden` and sized by the component's CSS, as in shadcn\n * (`[&_svg:not([class*='size-'])]:size-4`). Consumers can pass their own SVG\n * anywhere an icon is accepted.\n *\n * Each icon takes optional extra attributes for the `<svg>` itself, e.g.\n * shadcn's button icon marker: `icons.arrowRight({ \"data-icon\": \"inline-end\" })`.\n */\nconst icon = (name: string, body: SVGTemplateResult, extra: AttrMap = {}) => html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n data-icon-name=${name}\n ${attrs(extra)}\n>${body}</svg>`;\n\n// Bodies use Lit's `svg` tag: a nested template is parsed on its own, so an\n// `html` fragment would create <path> in the HTML namespace and draw nothing.\nexport const icons = {\n check: (a?: AttrMap) => icon(\"check\", svg`<path d=\"M20 6 9 17l-5-5\" />`, a),\n minus: (a?: AttrMap) => icon(\"minus\", svg`<path d=\"M5 12h14\" />`, a),\n x: (a?: AttrMap) => icon(\"x\", svg`<path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" />`, a),\n chevronDown: (a?: AttrMap) => icon(\"chevron-down\", svg`<path d=\"m6 9 6 6 6-6\" />`, a),\n chevronUp: (a?: AttrMap) => icon(\"chevron-up\", svg`<path d=\"m18 15-6-6-6 6\" />`, a),\n chevronRight: (a?: AttrMap) => icon(\"chevron-right\", svg`<path d=\"m9 18 6-6-6-6\" />`, a),\n chevronLeft: (a?: AttrMap) => icon(\"chevron-left\", svg`<path d=\"m15 18-6-6 6-6\" />`, a),\n chevronsUpDown: (a?: AttrMap) =>\n icon(\"chevrons-up-down\", svg`<path d=\"m7 15 5 5 5-5\" /><path d=\"m7 9 5-5 5 5\" />`, a),\n search: (a?: AttrMap) => icon(\"search\", svg`<path d=\"m21 21-4.34-4.34\" /><circle cx=\"11\" cy=\"11\" r=\"8\" />`, a),\n circle: (a?: AttrMap) => icon(\"circle\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" />`, a),\n loaderCircle: (a?: AttrMap) => icon(\"loader-circle\", svg`<path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />`, a),\n circleAlert: (a?: AttrMap) =>\n icon(\n \"circle-alert\",\n svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\" /><line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\" />`,\n a,\n ),\n circleX: (a?: AttrMap) =>\n icon(\"circle-x\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"m15 9-6 6\" /><path d=\"m9 9 6 6\" />`, a),\n circleCheck: (a?: AttrMap) =>\n icon(\"circle-check\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"m9 12 2 2 4-4\" />`, a),\n triangleAlert: (a?: AttrMap) =>\n icon(\n \"triangle-alert\",\n svg`<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" /><path d=\"M12 9v4\" /><path d=\"M12 17h.01\" />`,\n a,\n ),\n info: (a?: AttrMap) =>\n icon(\"info\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"M12 16v-4\" /><path d=\"M12 8h.01\" />`, a),\n eye: (a?: AttrMap) =>\n icon(\n \"eye\",\n svg`<path d=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" /><circle cx=\"12\" cy=\"12\" r=\"3\" />`,\n a,\n ),\n eyeOff: (a?: AttrMap) =>\n icon(\n \"eye-off\",\n svg`<path d=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" /><path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" /><path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" /><path d=\"m2 2 20 20\" />`,\n a,\n ),\n pencil: (a?: AttrMap) =>\n icon(\n \"pencil\",\n svg`<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\" /><path d=\"m15 5 4 4\" />`,\n a,\n ),\n copy: (a?: AttrMap) =>\n icon(\n \"copy\",\n svg`<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" /><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />`,\n a,\n ),\n download: (a?: AttrMap) =>\n icon(\n \"download\",\n svg`<path d=\"M12 15V3\" /><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" /><path d=\"m7 10 5 5 5-5\" />`,\n a,\n ),\n arrowRight: (a?: AttrMap) => icon(\"arrow-right\", svg`<path d=\"M5 12h14\" /><path d=\"m12 5 7 7-7 7\" />`, a),\n userRoundKey: (a?: AttrMap) =>\n icon(\n \"user-round-key\",\n svg`<path d=\"M19 11v6\" /><path d=\"M19 13h2\" /><path d=\"M2 21a8 8 0 0 1 12.868-6.349\" /><circle cx=\"10\" cy=\"8\" r=\"5\" /><circle cx=\"19\" cy=\"19\" r=\"2\" />`,\n a,\n ),\n} satisfies Record<string, (a?: AttrMap) => TemplateResult>;\n\nexport type IconName = keyof typeof icons;\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nexport type Orientation = \"horizontal\" | \"vertical\" | \"both\";\n\nexport interface RovingFocusOptions {\n /** Candidate items, in DOM order. Called on every key press, so it may query live. */\n items: () => HTMLElement[];\n orientation?: () => Orientation;\n /** Wrap from last to first (Base UI `loopFocus`, default true). */\n loop?: () => boolean;\n /** Items to skip. Default: `[data-disabled]` / `aria-disabled=\"true\"` / `:disabled`. */\n isDisabled?: (item: HTMLElement) => boolean;\n /** Called after focus moves through the keyboard (radio/tabs use it to activate). */\n onNavigate?: (item: HTMLElement, event: KeyboardEvent) => void;\n}\n\n/** `ltr` unless the nearest `[dir]` ancestor (or the document) says `rtl`. */\nexport function directionOf(el: Element): \"ltr\" | \"rtl\" {\n const owner = el.closest(\"[dir]\");\n const dir = (owner?.getAttribute(\"dir\") ?? document.documentElement.dir ?? \"\").toLowerCase();\n return dir === \"rtl\" ? \"rtl\" : \"ltr\";\n}\n\nconst defaultDisabled = (el: HTMLElement) =>\n el.hasAttribute(\"data-disabled\") ||\n el.getAttribute(\"aria-disabled\") === \"true\" ||\n (el as HTMLButtonElement).disabled === true;\n\n/**\n * Roving tabindex (WAI-ARIA APG \"managing focus within composites\"): exactly\n * one item is a tab stop (`tabindex=\"0\"`), the rest are `-1`, and arrow keys,\n * Home and End move focus between them. Used by RadioGroup, Tabs, ToggleGroup\n * and menus, which is what Base UI's `CompositeRoot` does internally.\n *\n * The host calls `sync(active)` whenever the \"current\" item may have\n * changed (selection, items added or removed).\n */\nexport class RovingFocusController implements ReactiveController {\n private readonly opts: Required<Omit<RovingFocusOptions, \"onNavigate\">> &\n Pick<RovingFocusOptions, \"onNavigate\">;\n\n constructor(\n private readonly host: ReactiveControllerHost & HTMLElement,\n options: RovingFocusOptions,\n ) {\n this.opts = {\n orientation: () => \"both\",\n loop: () => true,\n isDisabled: defaultDisabled,\n ...options,\n };\n host.addController(this);\n }\n\n hostConnected(): void {\n this.host.addEventListener(\"keydown\", this.onKeyDown);\n this.host.addEventListener(\"focusin\", this.onFocusIn);\n }\n\n hostDisconnected(): void {\n this.host.removeEventListener(\"keydown\", this.onKeyDown);\n this.host.removeEventListener(\"focusin\", this.onFocusIn);\n }\n\n /** Make `active` (or the first enabled item) the single tab stop. */\n sync(active?: HTMLElement | null): void {\n const items = this.opts.items();\n const enabled = items.filter(i => !this.opts.isDisabled(i));\n const stop = active && enabled.includes(active) ? active : enabled[0];\n for (const item of items) item.tabIndex = item === stop ? 0 : -1;\n }\n\n /** Focus an item and make it the tab stop. */\n focus(item: HTMLElement, options?: FocusOptions): void {\n this.sync(item);\n item.focus(options);\n }\n\n private onFocusIn = (e: FocusEvent) => {\n const items = this.opts.items();\n const item = items.find(i => i === e.target || i.contains(e.target as Node));\n if (item && !this.opts.isDisabled(item)) this.sync(item);\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n const items = this.opts.items();\n const current = items.findIndex(i => i === e.target || i.contains(e.target as Node));\n if (current < 0) return;\n\n const orientation = this.opts.orientation();\n const rtl = directionOf(this.host) === \"rtl\";\n const horizontal = orientation !== \"vertical\";\n const vertical = orientation !== \"horizontal\";\n\n let step: 1 | -1 | \"first\" | \"last\" | 0 = 0;\n switch (e.key) {\n case \"ArrowRight\":\n if (horizontal) step = rtl ? -1 : 1;\n break;\n case \"ArrowLeft\":\n if (horizontal) step = rtl ? 1 : -1;\n break;\n case \"ArrowDown\":\n if (vertical) step = 1;\n break;\n case \"ArrowUp\":\n if (vertical) step = -1;\n break;\n case \"Home\":\n step = \"first\";\n break;\n case \"End\":\n step = \"last\";\n break;\n }\n if (step === 0) return;\n\n const next = this.findNext(items, current, step);\n if (!next) return;\n e.preventDefault();\n this.focus(next);\n this.opts.onNavigate?.(next, e);\n };\n\n private findNext(items: HTMLElement[], from: number, step: 1 | -1 | \"first\" | \"last\") {\n const ok = (i: HTMLElement) => !this.opts.isDisabled(i);\n if (step === \"first\") return items.find(ok);\n if (step === \"last\") return [...items].reverse().find(ok);\n\n const n = items.length;\n const loop = this.opts.loop();\n for (let k = 1; k <= n; k++) {\n let i = from + step * k;\n if (loop) i = (i + n) % n;\n else if (i < 0 || i >= n) return undefined;\n if (ok(items[i])) return items[i];\n }\n return undefined;\n }\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nimport { fire } from \"../events\";\n\n/**\n * # The action protocol: `pont2-action` + `respondWith()`\n *\n * Some elements start asynchronous work they must not own: a sign-in button\n * starts a login-flow step, but the network call, the session and the next\n * screen belong to whatever hosts the flow (a widget, a layout, the app).\n * The element asks; an ancestor answers.\n *\n * ```\n * element ── pont2-action { action, data, respondWith } ──▶ ancestor (bubbles, composed)\n * ancestor calls detail.respondWith(promise)\n * element: busy until the promise settles\n * element ── pont2-action-success { action, data, result } ──▶\n * or pont2-action-error { action, data, error, message } ──▶\n * ```\n *\n * `respondWith()` must be called **synchronously, inside the listener** (as in\n * a service worker's `FetchEvent`). That is deliberate: the dispatch happens\n * inside the user's click, so work started in the listener still has the\n * click's *transient user activation*, which WebAuthn (passkeys) and\n * `window.open` (OAuth popups) require. Starting the work after an `await`\n * would lose it.\n *\n * ```ts\n * widget.addEventListener(\"pont2-action\", e => {\n * if (e.detail.action) e.detail.respondWith(Auth.processLoginflowEvent({ event: e.detail.action }));\n * });\n * ```\n *\n * Nobody responding is valid: the request event doubles as a click\n * notification (the legacy kit's `<tag>:click`), and an element may then fall\n * back to native behaviour (a submit button lets its form submit).\n *\n * Why an event and not an import: pont2 depends on no auth client, any\n * framework can answer a DOM event, Storybook and tests answer with a fake,\n * and the element never needs to know who is listening (docs/kit/auth-button.md).\n */\n\nexport interface ActionRequestDetail<D = Record<string, unknown>> {\n /** What to do, e.g. a login-flow event id. May be absent (a plain click notification). */\n action: string | undefined;\n /** Context from the element (the provider, the form data…). */\n data: D;\n /** Hand the element the work's promise. Only valid during dispatch, at most once. */\n respondWith(response: unknown): void;\n}\n\nexport interface ActionSuccessDetail<D = Record<string, unknown>> {\n action: string | undefined;\n data: D;\n result: unknown;\n}\n\nexport interface ActionErrorDetail<D = Record<string, unknown>> {\n action: string | undefined;\n data: D;\n error: unknown;\n message: string;\n}\n\nexport class ActionController implements ReactiveController {\n /** True while a response is pending. The host re-renders when it changes. */\n busy = false;\n\n constructor(private host: ReactiveControllerHost & HTMLElement) {\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n /**\n * Fires `pont2-action` from the host. Returns `true` if a listener called\n * `respondWith()` (the element is now busy), `false` otherwise or when\n * already busy (one request at a time).\n */\n request<D extends Record<string, unknown>>(action: string | undefined, data: D): boolean {\n if (this.busy) return false;\n let response: Promise<unknown> | undefined;\n let open = true;\n const detail: ActionRequestDetail<D> = {\n action,\n data,\n respondWith: value => {\n if (!open) throw new DOMException(\"respondWith() must be called synchronously in the listener.\", \"InvalidStateError\");\n if (response) throw new DOMException(\"respondWith() was already called.\", \"InvalidStateError\");\n response = Promise.resolve(value);\n },\n };\n fire(this.host, \"pont2-action\", detail);\n open = false;\n if (!response) return false;\n void this.track(action, data, response);\n return true;\n }\n\n private async track<D>(action: string | undefined, data: D, response: Promise<unknown>): Promise<void> {\n this.setBusy(true);\n try {\n const result = await response;\n fire<ActionSuccessDetail<D>>(this.host, \"pont2-action-success\", { action, data, result });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n fire<ActionErrorDetail<D>>(this.host, \"pont2-action-error\", { action, data, error, message });\n } finally {\n this.setBusy(false);\n }\n }\n\n private setBusy(on: boolean): void {\n this.busy = on;\n this.host.requestUpdate();\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-action\": CustomEvent<ActionRequestDetail>;\n \"pont2-action-success\": CustomEvent<ActionSuccessDetail>;\n \"pont2-action-error\": CustomEvent<ActionErrorDetail>;\n }\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nimport { fire } from \"../events\";\n\nexport interface CopiedDetail {\n /** What was copied, e.g. \"secret\", \"recovery-codes\". Never the copied text. */\n kind: string;\n}\n\nexport interface CopyErrorDetail {\n kind: string;\n error: unknown;\n}\n\n/**\n * Copy-to-clipboard with transient \"copied\" feedback.\n *\n * `copy(text)` writes to the clipboard, sets `copied` for `duration` ms (the\n * host re-renders), and fires `pont2-copied` / `pont2-copy-error`. The events\n * deliberately carry no text: what gets copied here is secret (TOTP secrets,\n * recovery codes), and events are observable by any script on the page.\n */\nexport class CopyController implements ReactiveController {\n copied = false;\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n private host: ReactiveControllerHost & HTMLElement,\n private kind: string,\n private duration = 2000,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n hostDisconnected(): void {\n if (this.timer !== undefined) clearTimeout(this.timer);\n }\n\n async copy(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n } catch (error) {\n fire<CopyErrorDetail>(this.host, \"pont2-copy-error\", { kind: this.kind, error });\n return false;\n }\n this.copied = true;\n this.host.requestUpdate();\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = setTimeout(() => {\n this.copied = false;\n this.timer = undefined;\n this.host.requestUpdate();\n }, this.duration);\n fire<CopiedDetail>(this.host, \"pont2-copied\", { kind: this.kind });\n return true;\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-copied\": CustomEvent<CopiedDetail>;\n \"pont2-copy-error\": CustomEvent<CopyErrorDetail>;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport const BADGE_VARIANTS = [\"default\", \"secondary\", \"destructive\", \"outline\", \"ghost\", \"link\"] as const;\nexport type BadgeVariant = (typeof BADGE_VARIANTS)[number];\n\n/**\n * # Badge: Tier 1 (structural)\n *\n * shadcn: `<Badge variant>` → Base UI `useRender({ defaultTagName: \"span\" })`\n * → `<span data-slot=\"badge\" data-variant>`; with `render={<a/>}` it becomes\n * a link.\n *\n * pont2: `<pont2-prim-badge>` **is** the span. For a link badge, put the recipe on\n * a real anchor: `<a data-pont2-badge data-variant=\"outline\" href=\"…\">`.\n *\n * @tag pont2-prim-badge\n * @attr variant - default | secondary | destructive | outline | ghost | link\n */\nexport class Badge extends HostElement {\n static override identity = \"badge\";\n static override slotName = \"badge\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: BadgeVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\ndefine(\"pont2-prim-badge\", Badge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-badge\": Badge;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer, ShellElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Button: Tier 3 (native-bound)\n *\n * shadcn: `<Button variant size>` → Base UI `<Button>` → a native `<button>`\n * (or, through `render`, the author's `<a>`), with `data-slot=\"button\"`.\n *\n * A button's root must stay native: implicit form submission,\n * `SubmitEvent.submitter`, `name=value` in FormData, password-manager\n * heuristics, middle-click on links. So the styled element is always a native\n * `<button>`/`<a>`, reachable four ways that all share one recipe\n * (button.css, keyed on `[data-pont2-button]`):\n *\n * | Entry point | You write | DOM nodes |\n * |-------------|------------------------------------------------------------------|-----------|\n * | Recipe | `<button data-pont2-button data-variant=\"outline\">` | 1 |\n * | Part | `button({ variant: \"outline\" }, content)` inside a Lit template | 1 |\n * | Enhancer | `<pont2-prim-button variant=\"outline\"><button>…</button></pont2-prim-button>` | shell + 1 |\n * | Base class | `class ProviderButton extends ButtonBase` | shell + 1 |\n */\n\nexport const BUTTON_VARIANTS = [\"default\", \"outline\", \"secondary\", \"ghost\", \"destructive\", \"link\"] as const;\nexport const BUTTON_SIZES = [\"default\", \"xs\", \"sm\", \"lg\", \"icon\", \"icon-xs\", \"icon-sm\", \"icon-lg\"] as const;\nexport type ButtonVariant = (typeof BUTTON_VARIANTS)[number];\nexport type ButtonSize = (typeof BUTTON_SIZES)[number];\n\nexport interface ButtonRecipe {\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n /**\n * Base UI `focusableWhenDisabled`: stay in the tab order while disabled\n * (`aria-disabled` instead of `disabled`). Use it for loading states, so\n * focus is not lost mid-submit.\n */\n focusableWhenDisabled?: boolean;\n}\n\nexport interface ButtonOptions extends ButtonRecipe {\n type?: \"button\" | \"submit\" | \"reset\";\n name?: string;\n value?: string;\n /** Renders an `<a>` instead of a `<button>` (shadcn `render={<a/>}`). */\n href?: string;\n target?: string;\n rel?: string;\n /** Overrides `data-slot` (shadcn `<Button data-slot=\"…\">`). */\n slot?: string;\n /** Extra attributes on the same native element: the `{...props}` spread. */\n attrs?: AttrMap;\n onClick?: (e: MouseEvent) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Recipe (imperative): for code that holds a node */\n/* ------------------------------------------------------------------ */\n\nexport function applyButton(el: HTMLElement, o: ButtonRecipe): void {\n if (!el.hasAttribute(\"data-pont2-button\")) el.setAttribute(\"data-pont2-button\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"button\");\n el.setAttribute(\"data-variant\", o.variant ?? \"default\");\n el.setAttribute(\"data-size\", o.size ?? \"default\");\n\n const disabled = !!o.disabled;\n const native = el instanceof HTMLButtonElement;\n el.toggleAttribute(\"data-disabled\", disabled);\n\n if (native && !o.focusableWhenDisabled) {\n el.disabled = disabled;\n el.removeAttribute(\"aria-disabled\");\n } else {\n if (native) el.disabled = false;\n if (disabled) el.setAttribute(\"aria-disabled\", \"true\");\n else el.removeAttribute(\"aria-disabled\");\n // A disabled link leaves the tab order unless it should stay focusable.\n if (!native) {\n if (disabled && !o.focusableWhenDisabled) el.tabIndex = -1;\n else el.removeAttribute(\"tabindex\");\n }\n }\n}\n\n/** True when a click on `el` must be swallowed (aria-disabled buttons and links). */\nexport function isSoftDisabled(el: Element): boolean {\n return el.getAttribute(\"aria-disabled\") === \"true\" || el.hasAttribute(\"data-disabled\");\n}\n\n/* ------------------------------------------------------------------ */\n/* Part: a template function, the counterpart of a React component */\n/* ------------------------------------------------------------------ */\n\nexport function button(o: ButtonOptions, content: unknown) {\n const variant = o.variant ?? \"default\";\n const size = o.size ?? \"default\";\n const slot = o.slot ?? \"button\";\n const disabled = !!o.disabled;\n const soft = disabled && (o.focusableWhenDisabled || o.href !== undefined);\n\n const onClick = (e: MouseEvent) => {\n if (soft) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n o.onClick?.(e);\n };\n\n if (o.href !== undefined) {\n return html`<a\n data-pont2-button\n data-slot=${slot}\n data-variant=${variant}\n data-size=${size}\n href=${o.href}\n target=${o.target ?? nothing}\n rel=${o.rel ?? nothing}\n ?data-disabled=${disabled}\n aria-disabled=${disabled ? \"true\" : nothing}\n tabindex=${disabled && !o.focusableWhenDisabled ? \"-1\" : nothing}\n ${attrs(o.attrs ?? {})}\n @click=${onClick}\n >${content}</a\n >`;\n }\n\n return html`<button\n data-pont2-button\n data-slot=${slot}\n data-variant=${variant}\n data-size=${size}\n type=${o.type ?? \"button\"}\n name=${o.name ?? nothing}\n .value=${o.value ?? \"\"}\n ?disabled=${disabled && !o.focusableWhenDisabled}\n ?data-disabled=${disabled}\n aria-disabled=${soft ? \"true\" : nothing}\n ${attrs(o.attrs ?? {})}\n @click=${onClick}\n >${content}</button>`;\n}\n\n/* ------------------------------------------------------------------ */\n/* Shared reactive properties */\n/* ------------------------------------------------------------------ */\n\nconst recipeProperties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n size: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n focusableWhenDisabled: { type: Boolean, attribute: \"focusable-when-disabled\" },\n};\n\n/* ------------------------------------------------------------------ */\n/* Element: enhancer (asChild) */\n/* ------------------------------------------------------------------ */\n\n/**\n * `<pont2-prim-button>`: applies the button recipe to the native `<button>` or\n * `<a>` you put inside it.\n *\n * ```html\n * <pont2-prim-button variant=\"outline\"><button type=\"submit\">Continue</button></pont2-prim-button>\n * <pont2-prim-button variant=\"link\"><a href=\"/forgot\">Forgot password?</a></pont2-prim-button>\n * ```\n *\n * @tag pont2-prim-button\n * @attr variant - default | outline | secondary | ghost | destructive | link\n * @attr size - default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lg\n * @attr disabled - Disables the native child (or sets aria-disabled on a link).\n * @attr focusable-when-disabled - Keep the disabled button in the tab order.\n */\nexport class Pont2Button extends NativeEnhancer<HTMLButtonElement | HTMLAnchorElement> {\n static override nativeSelector = \"button, a\";\n static override properties = recipeProperties;\n\n declare variant: ButtonVariant;\n declare size: ButtonSize;\n declare disabled: boolean;\n declare focusableWhenDisabled: boolean;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n this.disabled = false;\n this.focusableWhenDisabled = false;\n // Swallow clicks on soft-disabled controls before author listeners run.\n this.addEventListener(\"click\", this.guard, { capture: true });\n }\n\n private guard = (e: MouseEvent) => {\n const c = this.control;\n if (c && this.disabled && (c === e.target || c.contains(e.target as Node)) && isSoftDisabled(c)) {\n e.preventDefault();\n e.stopImmediatePropagation();\n }\n };\n\n protected apply(control: HTMLButtonElement | HTMLAnchorElement): void {\n applyButton(control, this);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Base class for compositions that ARE buttons */\n/* ------------------------------------------------------------------ */\n\n/**\n * Extend this when your component *is* a button whose content it generates\n * (a provider sign-in button, a submit button with a spinner). Subclasses\n * inherit `variant`/`size`/`disabled`/`type`/`href`… so nothing is forwarded\n * by hand; they implement `renderContent()` and may override\n * `buttonOptions()`. The DOM is always\n * `<host data-pont2-shell> > <button|a data-pont2-button>`.\n */\nexport abstract class ButtonBase extends ShellElement {\n static override properties: PropertyDeclarations = {\n ...recipeProperties,\n type: { type: String },\n name: { type: String },\n value: { type: String },\n href: { type: String },\n target: { type: String },\n rel: { type: String },\n };\n\n declare variant: ButtonVariant;\n declare size: ButtonSize;\n declare disabled: boolean;\n declare focusableWhenDisabled: boolean;\n declare type: \"button\" | \"submit\" | \"reset\";\n declare name?: string;\n declare value?: string;\n declare href?: string;\n declare target?: string;\n declare rel?: string;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n this.disabled = false;\n this.focusableWhenDisabled = false;\n this.type = \"button\";\n }\n\n /** The native element. Focus, tooltips and popovers anchor here, never on the shell. */\n override get control(): HTMLButtonElement | HTMLAnchorElement | null {\n return this.querySelector(\":scope > [data-pont2-button]\");\n }\n\n protected buttonOptions(): ButtonOptions {\n const { variant, size, type, name, value, disabled, focusableWhenDisabled, href, target, rel } = this;\n return { variant, size, type, name, value, disabled, focusableWhenDisabled, href, target, rel };\n }\n\n protected abstract renderContent(): unknown;\n\n override render() {\n return button(this.buttonOptions(), this.renderContent());\n }\n}\n\ndefine(\"pont2-prim-button\", Pont2Button);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-button\": Pont2Button;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Checkbox: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Checkbox>` → Base UI `<Checkbox.Root>` (`<span role=\"checkbox\">`\n * plus a hidden `<input type=\"checkbox\">`) > `<Checkbox.Indicator>` > icon.\n *\n * pont2: the host **is** the `role=\"checkbox\"` root, and it is a\n * form-associated custom element, so there is no hidden input:\n *\n * ```\n * shadcn/Base UI: span[role=checkbox] > span[data-slot=checkbox-indicator] > svg + input[hidden]\n * pont2: pont2-prim-checkbox > span[data-slot=checkbox-indicator] > svg\n * ```\n *\n * State attributes are Base UI's: `data-checked` | `data-unchecked`,\n * `data-indeterminate`, `data-disabled`, `data-readonly`, `data-required`.\n * The CustomStateSet mirrors them (`:state(checked)`).\n *\n * @tag pont2-prim-checkbox\n * @attr checked - Initial checked state (`defaultChecked`); `.checked` is the live state.\n * @attr indeterminate - Mixed state (`aria-checked=\"mixed\"`).\n * @attr name, value, unchecked-value, disabled, required, readonly\n * @fires input - The checked state changed through interaction.\n * @fires change - Same moment as `input`, like a native checkbox.\n */\nexport class Checkbox extends FormControlElement {\n static override identity = \"checkbox\";\n static override slotName = \"checkbox\";\n static override role = \"checkbox\";\n\n static override properties: PropertyDeclarations = {\n ...FormControlElement.properties,\n checked: { type: Boolean },\n indeterminate: { type: Boolean, reflect: true },\n value: { type: String },\n uncheckedValue: { type: String, attribute: \"unchecked-value\" },\n };\n\n declare checked: boolean;\n declare indeterminate: boolean;\n declare value: string;\n declare uncheckedValue: string | undefined;\n\n constructor() {\n super();\n this.checked = false;\n this.indeterminate = false;\n this.value = \"on\";\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"keyup\", this.onKeyUp);\n }\n\n /** Toggle as if the user clicked (fires input/change). */\n toggle(): void {\n if (this.isDisabled || this.readOnly) return;\n this.indeterminate = false;\n this.checked = !this.checked;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected formValue() {\n if (this.checked) return this.value;\n return this.uncheckedValue ?? null;\n }\n\n protected resetToDefault(): void {\n this.checked = this.hasAttribute(\"checked\");\n this.indeterminate = this.hasAttribute(\"indeterminate\");\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n this.checked = state === this.value;\n }\n\n protected override validate(): ValidityResult | null {\n if (this.required && !this.checked) {\n return { flags: { valueMissing: true }, message: \"Please tick this box if you want to proceed.\" };\n }\n return null;\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled || this.readOnly) {\n e.preventDefault();\n return;\n }\n this.toggle();\n };\n\n // Native checkboxes toggle on Space *keyup*; keydown is prevented so the page does not scroll.\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) e.preventDefault();\n };\n private onKeyUp = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) this.click();\n };\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n const on = this.checked && !this.indeterminate;\n this.internals.ariaChecked = this.indeterminate ? \"mixed\" : String(this.checked);\n this.setData(\"checked\", on);\n this.setData(\"unchecked\", !this.checked && !this.indeterminate);\n this.setData(\"indeterminate\", this.indeterminate);\n this.setState(\"checked\", on);\n this.setState(\"indeterminate\", this.indeterminate);\n }\n\n override render() {\n if (!this.checked && !this.indeterminate) return nothing;\n // Base UI <Checkbox.Indicator> (not kept mounted when unchecked).\n return html`<span\n data-pont2-checkbox-indicator\n data-slot=\"checkbox-indicator\"\n ?data-checked=${this.checked && !this.indeterminate}\n ?data-indeterminate=${this.indeterminate}\n >${this.indeterminate ? icons.minus() : icons.check()}</span\n >`;\n }\n}\n\ndefine(\"pont2-prim-checkbox\", Checkbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-checkbox\": Checkbox;\n }\n}\n","import { html, nothing } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Input: Tier 3 (native-bound)\n *\n * shadcn: `<Input>` → Base UI `<Input>` → a native `<input data-slot=\"input\">`.\n *\n * A sign-in kit's inputs must be native and in light DOM: autofill, password\n * managers, `autocomplete=\"one-time-code\"`, form submission, `<label for>`\n * and `aria-describedby` all depend on it.\n *\n * - recipe: `<input data-pont2-input type=\"email\" name=\"email\">`\n * - part: `input({ type: \"email\", name: \"email\" })`\n * - enhancer: `<pont2-prim-input><input type=\"email\" name=\"email\"></pont2-prim-input>`\n */\nexport interface InputOptions {\n id?: string;\n name?: string;\n type?: string;\n value?: string;\n placeholder?: string;\n autocomplete?: string;\n inputmode?: string;\n required?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n invalid?: boolean;\n describedBy?: string;\n slot?: string;\n attrs?: AttrMap;\n onInput?: (e: InputEvent) => void;\n onChange?: (e: Event) => void;\n}\n\nexport function applyInput(el: HTMLInputElement, slot = \"input\"): void {\n if (!el.hasAttribute(\"data-pont2-input\")) el.setAttribute(\"data-pont2-input\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function input(o: InputOptions = {}) {\n return html`<input\n data-pont2-input\n data-slot=${o.slot ?? \"input\"}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n type=${o.type ?? \"text\"}\n .value=${live(o.value ?? \"\")}\n placeholder=${o.placeholder ?? nothing}\n autocomplete=${(o.autocomplete as never) ?? nothing}\n inputmode=${(o.inputmode as never) ?? nothing}\n ?required=${o.required}\n ?disabled=${o.disabled}\n ?readonly=${o.readonly}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-describedby=${o.describedBy ?? nothing}\n ${attrs(o.attrs ?? {})}\n @input=${o.onInput ?? nothing}\n @change=${o.onChange ?? nothing}\n />`;\n}\n\n/**\n * @tag pont2-prim-input\n */\nexport class Pont2Input extends NativeEnhancer<HTMLInputElement> {\n static override nativeSelector = \"input\";\n protected apply(control: HTMLInputElement): void {\n applyInput(control);\n }\n}\n\ndefine(\"pont2-prim-input\", Pont2Input);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input\": Pont2Input;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Kbd, KbdGroup: Tier 1 (structural)\n *\n * shadcn: `<Kbd>` → `<kbd data-slot=\"kbd\">`; `<KbdGroup>` → `<kbd data-slot=\"kbd-group\">`.\n *\n * pont2: the host is the key cap. `<kbd>` has no implicit ARIA role, so a\n * custom element loses no semantics here. (If you need the literal element,\n * use the recipe: `<kbd data-pont2-kbd>⌘</kbd>`.)\n *\n * @tag pont2-prim-kbd\n */\nexport class Kbd extends HostElement {\n static override identity = \"kbd\";\n static override slotName = \"kbd\";\n}\n\n/**\n * @tag pont2-prim-kbd-group\n */\nexport class KbdGroup extends HostElement {\n static override identity = \"kbd-group\";\n static override slotName = \"kbd-group\";\n}\n\ndefine(\"pont2-prim-kbd\", Kbd);\ndefine(\"pont2-prim-kbd-group\", KbdGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-kbd\": Kbd;\n \"pont2-prim-kbd-group\": KbdGroup;\n }\n}\n","import { html, nothing } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Label: Tier 3 (native-bound)\n *\n * shadcn: `<Label>` → a native `<label data-slot=\"label\">`.\n *\n * It must be a real `<label>`: `for=` association, click-to-focus, and\n * labelling form-associated custom elements (Checkbox, Switch …) only work\n * on the native element. So:\n *\n * - recipe: `<label data-pont2-label for=\"email\">Email</label>`\n * - part: `label({ for: \"email\" }, \"Email\")`\n * - enhancer: `<pont2-prim-label><label for=\"email\">Email</label></pont2-prim-label>`\n */\nexport interface LabelOptions {\n for?: string;\n id?: string;\n slot?: string;\n /** Extra identities, e.g. FieldLabel passes `[\"field-label\"]`. */\n identities?: string[];\n attrs?: AttrMap;\n}\n\nexport function applyLabel(el: HTMLLabelElement, slot = \"label\"): void {\n if (!el.hasAttribute(\"data-pont2-label\")) el.setAttribute(\"data-pont2-label\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function label(o: LabelOptions, content: unknown) {\n const extra: AttrMap = {};\n for (const id of o.identities ?? []) extra[`data-pont2-${id}`] = true;\n return html`<label\n data-pont2-label\n data-slot=${o.slot ?? \"label\"}\n for=${o.for ?? nothing}\n id=${o.id ?? nothing}\n ${attrs({ ...extra, ...(o.attrs ?? {}) })}\n >${content}</label\n >`;\n}\n\n/**\n * @tag pont2-prim-label\n */\nexport class Pont2Label extends NativeEnhancer<HTMLLabelElement> {\n static override nativeSelector = \"label\";\n protected apply(control: HTMLLabelElement): void {\n applyLabel(control);\n }\n}\n\ndefine(\"pont2-prim-label\", Pont2Label);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-label\": Pont2Label;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type SeparatorOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # Separator: Tier 1 (structural)\n *\n * shadcn: `<Separator orientation>` → Base UI `<Separator>` →\n * `<div role=\"separator\" aria-orientation data-orientation data-slot=\"separator\">`.\n *\n * pont2: the host **is** that div. No `render()`, no children, one node.\n * Role and orientation are ElementInternals defaults, so an author's own\n * `role=\"none\"` (purely decorative rule) still wins.\n *\n * Subclass it to make a separator with another meaning, e.g.\n * `class ItemSeparator extends Separator { static identity = \"item-separator\" }`:\n * it keeps `data-pont2-separator` (the look) and gains its own slot.\n *\n * @tag pont2-prim-separator\n * @attr orientation - horizontal (default) | vertical\n */\nexport class Separator extends HostElement {\n static override identity = \"separator\";\n static override slotName = \"separator\";\n static override role = \"separator\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n };\n\n declare orientation: SeparatorOrientation;\n\n constructor() {\n super();\n this.orientation = \"horizontal\";\n }\n\n protected override willUpdate(): void {\n const o = this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n this.setData(\"orientation\", o);\n this.internals.ariaOrientation = o;\n }\n}\n\ndefine(\"pont2-prim-separator\", Separator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-separator\": Separator;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Skeleton: Tier 1 (structural)\n *\n * shadcn: `<Skeleton>` → `<div data-slot=\"skeleton\" class=\"animate-pulse bg-muted rounded-md\">`.\n * Size it with your own CSS (`style=\"width:12rem;height:1rem\"` or a class).\n *\n * @tag pont2-prim-skeleton\n */\nexport class Skeleton extends HostElement {\n static override identity = \"skeleton\";\n static override slotName = \"skeleton\";\n}\n\ndefine(\"pont2-prim-skeleton\", Skeleton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-skeleton\": Skeleton;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Spinner: Tier 1 (structural)\n *\n * shadcn: `<Spinner>` → lucide `<Loader2Icon role=\"status\" aria-label=\"Loading\"\n * data-slot=\"spinner\" class=\"size-4 animate-spin\">`, i.e. one `<svg>`.\n *\n * A custom element cannot *be* an `<svg>`, and rendering one inside would add\n * a node. pont2 draws the identical lucide `loader-circle` geometry as a CSS\n * mask on the host, so the spinner is still one node and still `currentColor`.\n * Swap the glyph with `--pont2-spinner-icon: url(…)`.\n *\n * `role=\"status\"` and `aria-label=\"Loading\"` are ElementInternals defaults;\n * write your own `aria-label` to localise it.\n *\n * @tag pont2-prim-spinner\n * @cssprop --pont2-spinner-icon - mask image (default: lucide loader-circle)\n */\nexport class Spinner extends HostElement {\n static override identity = \"spinner\";\n static override slotName = \"spinner\";\n static override role = \"status\";\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.internals.ariaLabel) this.internals.ariaLabel = \"Loading\";\n }\n}\n\ndefine(\"pont2-prim-spinner\", Spinner);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-spinner\": Spinner;\n }\n}\n","import { html, nothing } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Textarea: Tier 3 (native-bound)\n *\n * shadcn: `<Textarea>` → a native `<textarea data-slot=\"textarea\">`, auto-sized\n * with `field-sizing: content`.\n *\n * - recipe: `<textarea data-pont2-textarea name=\"bio\"></textarea>`\n * - part: `textarea({ name: \"bio\" })`\n * - enhancer: `<pont2-prim-textarea><textarea name=\"bio\"></textarea></pont2-prim-textarea>`\n */\nexport interface TextareaOptions {\n id?: string;\n name?: string;\n value?: string;\n placeholder?: string;\n rows?: number;\n required?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n invalid?: boolean;\n describedBy?: string;\n slot?: string;\n attrs?: AttrMap;\n onInput?: (e: InputEvent) => void;\n}\n\nexport function applyTextarea(el: HTMLTextAreaElement, slot = \"textarea\"): void {\n if (!el.hasAttribute(\"data-pont2-textarea\")) el.setAttribute(\"data-pont2-textarea\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function textarea(o: TextareaOptions = {}) {\n return html`<textarea\n data-pont2-textarea\n data-slot=${o.slot ?? \"textarea\"}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n rows=${o.rows ?? nothing}\n placeholder=${o.placeholder ?? nothing}\n ?required=${o.required}\n ?disabled=${o.disabled}\n ?readonly=${o.readonly}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-describedby=${o.describedBy ?? nothing}\n .value=${live(o.value ?? \"\")}\n ${attrs(o.attrs ?? {})}\n @input=${o.onInput ?? nothing}\n ></textarea>`;\n}\n\n/**\n * @tag pont2-prim-textarea\n */\nexport class Pont2Textarea extends NativeEnhancer<HTMLTextAreaElement> {\n static override nativeSelector = \"textarea\";\n protected apply(control: HTMLTextAreaElement): void {\n applyTextarea(control);\n }\n}\n\ndefine(\"pont2-prim-textarea\", Pont2Textarea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-textarea\": Pont2Textarea;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport const ALERT_VARIANTS = [\"default\", \"destructive\"] as const;\nexport type AlertVariant = (typeof ALERT_VARIANTS)[number];\n\n/**\n * # Alert: Tier 1 (structural)\n *\n * shadcn: `<Alert variant>` → `<div role=\"alert\" data-slot=\"alert\">` with\n * `AlertTitle`, `AlertDescription`, `AlertAction` divs inside.\n *\n * pont2: every part is host-as-root. The alert's `role=\"alert\"` is an\n * ElementInternals default, so `role=\"status\"` written by the author (a polite\n * announcement) still wins.\n *\n * @tag pont2-prim-alert\n * @attr variant - default | destructive\n */\nexport class Alert extends HostElement {\n static override identity = \"alert\";\n static override slotName = \"alert\";\n static override role = \"alert\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: AlertVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-alert-title */\nexport class AlertTitle extends HostElement {\n static override identity = \"alert-title\";\n static override slotName = \"alert-title\";\n}\n\n/** @tag pont2-prim-alert-description */\nexport class AlertDescription extends HostElement {\n static override identity = \"alert-description\";\n static override slotName = \"alert-description\";\n}\n\n/** @tag pont2-prim-alert-action */\nexport class AlertAction extends HostElement {\n static override identity = \"alert-action\";\n static override slotName = \"alert-action\";\n}\n\ndefine(\"pont2-prim-alert\", Alert);\ndefine(\"pont2-prim-alert-title\", AlertTitle);\ndefine(\"pont2-prim-alert-description\", AlertDescription);\ndefine(\"pont2-prim-alert-action\", AlertAction);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-alert\": Alert;\n \"pont2-prim-alert-title\": AlertTitle;\n \"pont2-prim-alert-description\": AlertDescription;\n \"pont2-prim-alert-action\": AlertAction;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type AvatarSize = \"default\" | \"sm\" | \"lg\";\n/** Base UI `Avatar.Root` state `imageLoadingStatus`. */\nexport type ImageLoadingStatus = \"idle\" | \"loading\" | \"loaded\" | \"error\";\n\n/**\n * # Avatar: Tier 1 (structural, with image-loading behaviour)\n *\n * shadcn: `<Avatar size>` → Base UI `<Avatar.Root>` (`<span data-slot=\"avatar\"\n * data-size>`) holding `<Avatar.Image>` (an `<img>`, rendered only once it has\n * loaded) and `<Avatar.Fallback>` (a `<span>`, rendered until then).\n *\n * pont2: the host **is** the root span. The image is the author's own native\n * `<img>` (Tier 3: it must stay an `<img>` for `alt`, `srcset`, lazy loading),\n * written as a direct child. The host watches it and exposes Base UI's\n * `imageLoadingStatus` as `data-image-loading-status`; CSS shows the image\n * only when `loaded` and the fallback otherwise. Nothing is added, removed or\n * moved: the image and fallback both stay in the DOM and CSS swaps them.\n *\n * ```html\n * <pont2-prim-avatar>\n * <img src=\"/u/42.png\" alt=\"Ada Lovelace\">\n * <pont2-prim-avatar-fallback>AL</pont2-prim-avatar-fallback>\n * </pont2-prim-avatar>\n * ```\n *\n * @tag pont2-prim-avatar\n * @attr size - default | sm | lg\n * @fires pont2-loading-status-change - `{ status }` when the image status changes (Base UI `onLoadingStatusChange`).\n */\nexport class Avatar extends HostElement {\n static override identity = \"avatar\";\n static override slotName = \"avatar\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n imageLoadingStatus: { state: true },\n };\n\n declare size: AvatarSize;\n /** Base UI's `imageLoadingStatus`; read-only for consumers. */\n declare imageLoadingStatus: ImageLoadingStatus;\n\n private img: HTMLImageElement | null = null;\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.size = \"default\";\n this.imageLoadingStatus = \"idle\";\n }\n\n /** The author's `<img>` (a direct child), if any. */\n get image(): HTMLImageElement | null {\n return this.querySelector(\":scope > img\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.track());\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: [\"src\", \"srcset\"] });\n this.track();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.detach();\n }\n\n private detach() {\n this.img?.removeEventListener(\"load\", this.onLoad);\n this.img?.removeEventListener(\"error\", this.onError);\n this.img = null;\n }\n\n private track() {\n const img = this.image;\n if (img !== this.img) {\n this.detach();\n this.img = img;\n if (img) {\n img.addEventListener(\"load\", this.onLoad);\n img.addEventListener(\"error\", this.onError);\n if (!img.hasAttribute(\"data-pont2-avatar-image\")) img.setAttribute(\"data-pont2-avatar-image\", \"\");\n if (!img.hasAttribute(\"data-slot\")) img.setAttribute(\"data-slot\", \"avatar-image\");\n }\n }\n if (!img || !(img.currentSrc || img.getAttribute(\"src\"))) return this.setStatus(img ? \"error\" : \"idle\");\n if (img.complete) this.setStatus(img.naturalWidth > 0 ? \"loaded\" : \"error\");\n else this.setStatus(\"loading\");\n }\n\n private onLoad = () => this.setStatus(\"loaded\");\n private onError = () => this.setStatus(\"error\");\n\n private setStatus(status: ImageLoadingStatus) {\n if (status === this.imageLoadingStatus) return;\n this.imageLoadingStatus = status;\n this.dispatchEvent(\n new CustomEvent(\"pont2-loading-status-change\", { detail: { status }, bubbles: true, composed: true }),\n );\n }\n\n protected override willUpdate(): void {\n this.setData(\"size\", this.size || \"default\");\n this.setData(\"image-loading-status\", this.imageLoadingStatus);\n }\n}\n\n/**\n * Shown until the avatar's image has loaded (CSS-driven; see Avatar).\n *\n * @tag pont2-prim-avatar-fallback\n */\nexport class AvatarFallback extends HostElement {\n static override identity = \"avatar-fallback\";\n static override slotName = \"avatar-fallback\";\n}\n\n/** @tag pont2-prim-avatar-badge */\nexport class AvatarBadge extends HostElement {\n static override identity = \"avatar-badge\";\n static override slotName = \"avatar-badge\";\n}\n\n/** @tag pont2-prim-avatar-group */\nexport class AvatarGroup extends HostElement {\n static override identity = \"avatar-group\";\n static override slotName = \"avatar-group\";\n}\n\n/** @tag pont2-prim-avatar-group-count */\nexport class AvatarGroupCount extends HostElement {\n static override identity = \"avatar-group-count\";\n static override slotName = \"avatar-group-count\";\n}\n\ndefine(\"pont2-prim-avatar\", Avatar);\ndefine(\"pont2-prim-avatar-fallback\", AvatarFallback);\ndefine(\"pont2-prim-avatar-badge\", AvatarBadge);\ndefine(\"pont2-prim-avatar-group\", AvatarGroup);\ndefine(\"pont2-prim-avatar-group-count\", AvatarGroupCount);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-avatar\": Avatar;\n \"pont2-prim-avatar-fallback\": AvatarFallback;\n \"pont2-prim-avatar-badge\": AvatarBadge;\n \"pont2-prim-avatar-group\": AvatarGroup;\n \"pont2-prim-avatar-group-count\": AvatarGroupCount;\n }\n interface HTMLElementEventMap {\n \"pont2-loading-status-change\": CustomEvent<{ status: ImageLoadingStatus }>;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { Separator } from \"../separator/separator\";\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # ButtonGroup: Tier 1 (structural)\n *\n * shadcn: `<ButtonGroup orientation>` → `<div role=\"group\" data-slot=\"button-group\"\n * data-orientation>`; `ButtonGroupText` (Base UI `useRender`, a div);\n * `ButtonGroupSeparator` (a vertical `Separator`).\n *\n * pont2: host-as-root. Children are whatever you write: recipe buttons,\n * `<pont2-prim-button>` shells, inputs, nested groups. The join rules (square inner\n * corners, collapsed borders) see through Tier 3 shells, because a shell has\n * no box. `ButtonGroupSeparator extends Separator`.\n *\n * @tag pont2-prim-button-group\n * @attr orientation - horizontal (default) | vertical\n */\nexport class ButtonGroup extends HostElement {\n static override identity = \"button-group\";\n static override slotName = \"button-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n };\n\n declare orientation: ButtonGroupOrientation;\n\n constructor() {\n super();\n this.orientation = \"horizontal\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"orientation\", this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\");\n }\n}\n\n/**\n * For a link or label instead of a div, use the recipe on that element:\n * `<label data-pont2-button-group-text data-slot=\"button-group-text\">`.\n *\n * @tag pont2-prim-button-group-text\n */\nexport class ButtonGroupText extends HostElement {\n static override identity = \"button-group-text\";\n static override slotName = \"button-group-text\";\n}\n\n/**\n * A Separator whose default orientation is vertical.\n *\n * @tag pont2-prim-button-group-separator\n */\nexport class ButtonGroupSeparator extends Separator {\n static override identity = \"button-group-separator\";\n static override slotName = \"button-group-separator\";\n\n constructor() {\n super();\n this.orientation = \"vertical\";\n }\n}\n\ndefine(\"pont2-prim-button-group\", ButtonGroup);\ndefine(\"pont2-prim-button-group-text\", ButtonGroupText);\ndefine(\"pont2-prim-button-group-separator\", ButtonGroupSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-button-group\": ButtonGroup;\n \"pont2-prim-button-group-text\": ButtonGroupText;\n \"pont2-prim-button-group-separator\": ButtonGroupSeparator;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type CardSize = \"default\" | \"sm\";\n\n/**\n * # Card: Tier 1 (structural)\n *\n * shadcn: `<Card size>` → `<div data-slot=\"card\" data-size>` and the\n * `CardHeader | CardTitle | CardDescription | CardAction | CardContent |\n * CardFooter` divs. Every part here is host-as-root: same depth as shadcn.\n *\n * @tag pont2-prim-card\n * @attr size - default | sm\n * @cssprop --pont2-card-spacing - padding/gap unit (default 1.5rem)\n * @cssprop --pont2-card-sm-spacing - the same for size=\"sm\" (default 1rem)\n * @cssprop --pont2-card-bg, --pont2-card-fg, --pont2-card-border-color, --pont2-card-radius, --pont2-card-shadow - see docs/11-tokens.md\n */\nexport class Card extends HostElement {\n static override identity = \"card\";\n static override slotName = \"card\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n };\n\n declare size: CardSize;\n\n constructor() {\n super();\n this.size = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"size\", this.size || \"default\");\n }\n}\n\n/** @tag pont2-prim-card-header */\nexport class CardHeader extends HostElement {\n static override identity = \"card-header\";\n static override slotName = \"card-header\";\n}\n\n/** @tag pont2-prim-card-title */\nexport class CardTitle extends HostElement {\n static override identity = \"card-title\";\n static override slotName = \"card-title\";\n}\n\n/** @tag pont2-prim-card-description */\nexport class CardDescription extends HostElement {\n static override identity = \"card-description\";\n static override slotName = \"card-description\";\n}\n\n/** @tag pont2-prim-card-action */\nexport class CardAction extends HostElement {\n static override identity = \"card-action\";\n static override slotName = \"card-action\";\n}\n\n/** @tag pont2-prim-card-content */\nexport class CardContent extends HostElement {\n static override identity = \"card-content\";\n static override slotName = \"card-content\";\n}\n\n/** @tag pont2-prim-card-footer */\nexport class CardFooter extends HostElement {\n static override identity = \"card-footer\";\n static override slotName = \"card-footer\";\n}\n\ndefine(\"pont2-prim-card\", Card);\ndefine(\"pont2-prim-card-header\", CardHeader);\ndefine(\"pont2-prim-card-title\", CardTitle);\ndefine(\"pont2-prim-card-description\", CardDescription);\ndefine(\"pont2-prim-card-action\", CardAction);\ndefine(\"pont2-prim-card-content\", CardContent);\ndefine(\"pont2-prim-card-footer\", CardFooter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-card\": Card;\n \"pont2-prim-card-header\": CardHeader;\n \"pont2-prim-card-title\": CardTitle;\n \"pont2-prim-card-description\": CardDescription;\n \"pont2-prim-card-action\": CardAction;\n \"pont2-prim-card-content\": CardContent;\n \"pont2-prim-card-footer\": CardFooter;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type EmptyMediaVariant = \"default\" | \"icon\";\n\n/**\n * # Empty: Tier 1 (structural)\n *\n * shadcn: `<Empty>` → `<div data-slot=\"empty\">` with `EmptyHeader`,\n * `EmptyMedia` (`data-slot=\"empty-icon\"`, `data-variant`), `EmptyTitle`,\n * `EmptyDescription`, `EmptyContent`, all divs. All host-as-root here.\n *\n * @tag pont2-prim-empty\n */\nexport class Empty extends HostElement {\n static override identity = \"empty\";\n static override slotName = \"empty\";\n}\n\n/** @tag pont2-prim-empty-header */\nexport class EmptyHeader extends HostElement {\n static override identity = \"empty-header\";\n static override slotName = \"empty-header\";\n}\n\n/**\n * Note shadcn's slot name for the media part is `empty-icon` (kept verbatim).\n *\n * @tag pont2-prim-empty-media\n * @attr variant - default | icon\n */\nexport class EmptyMedia extends HostElement {\n static override identity = \"empty-media\";\n static override slotName = \"empty-icon\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: EmptyMediaVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-empty-title */\nexport class EmptyTitle extends HostElement {\n static override identity = \"empty-title\";\n static override slotName = \"empty-title\";\n}\n\n/** @tag pont2-prim-empty-description */\nexport class EmptyDescription extends HostElement {\n static override identity = \"empty-description\";\n static override slotName = \"empty-description\";\n}\n\n/** @tag pont2-prim-empty-content */\nexport class EmptyContent extends HostElement {\n static override identity = \"empty-content\";\n static override slotName = \"empty-content\";\n}\n\ndefine(\"pont2-prim-empty\", Empty);\ndefine(\"pont2-prim-empty-header\", EmptyHeader);\ndefine(\"pont2-prim-empty-media\", EmptyMedia);\ndefine(\"pont2-prim-empty-title\", EmptyTitle);\ndefine(\"pont2-prim-empty-description\", EmptyDescription);\ndefine(\"pont2-prim-empty-content\", EmptyContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-empty\": Empty;\n \"pont2-prim-empty-header\": EmptyHeader;\n \"pont2-prim-empty-media\": EmptyMedia;\n \"pont2-prim-empty-title\": EmptyTitle;\n \"pont2-prim-empty-description\": EmptyDescription;\n \"pont2-prim-empty-content\": EmptyContent;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { HostElement, NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { applyLabel } from \"../label/label\";\n\n/**\n * # Field family\n *\n * shadcn's `field.tsx` is plain markup (no Base UI primitive):\n *\n * | shadcn | renders | pont2 | tier |\n * |-------------------|--------------------------------------------|-------------------------------|------|\n * | FieldSet | `<fieldset data-slot=\"field-set\">` | recipe/part on `<fieldset>`, `<pont2-prim-field-set>` enhancer | 3 |\n * | FieldLegend | `<legend data-slot=\"field-legend\" data-variant>` | recipe/part on `<legend>` only | 3 |\n * | FieldGroup | `<div data-slot=\"field-group\">` | `<pont2-prim-field-group>` | 1 |\n * | Field | `<div role=\"group\" data-slot=\"field\" data-orientation>` | `<pont2-prim-field>` | 1 |\n * | FieldContent | `<div data-slot=\"field-content\">` | `<pont2-prim-field-content>` | 1 |\n * | FieldLabel | `<label data-slot=\"field-label\">` (Label) | recipe/part on `<label>`, `<pont2-prim-field-label>` enhancer | 3 |\n * | FieldTitle | `<div data-slot=\"field-label\">` | `<pont2-prim-field-title>` | 1 |\n * | FieldDescription | `<p data-slot=\"field-description\">` | `<pont2-prim-field-description>` | 1 |\n * | FieldSeparator | `<div data-slot=\"field-separator\">` > Separator + `<span>` | `<pont2-prim-field-separator>` (lines drawn in CSS) | 1 |\n * | FieldError | `<div role=\"alert\" data-slot=\"field-error\">` | `<pont2-prim-field-error>` | 1 |\n *\n * Like shadcn, the family does no id wiring: you write `for`/`id` and\n * `aria-describedby` yourself (Base UI's own `Field` primitive does wire ids;\n * shadcn's Field does not use it). See docs/primitives/field.md.\n */\n\n/* ------------------------------------------------------------------ */\n/* FieldSet / FieldLegend (native) */\n/* ------------------------------------------------------------------ */\n\nexport function applyFieldSet(el: HTMLFieldSetElement): void {\n if (!el.hasAttribute(\"data-pont2-field-set\")) el.setAttribute(\"data-pont2-field-set\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"field-set\");\n}\n\nexport function fieldSet(o: { disabled?: boolean; attrs?: AttrMap }, content: unknown) {\n return html`<fieldset data-pont2-field-set data-slot=\"field-set\" ?disabled=${o.disabled} ${attrs(o.attrs ?? {})}>\n ${content}\n </fieldset>`;\n}\n\nexport function fieldLegend(o: { variant?: \"legend\" | \"label\"; attrs?: AttrMap }, content: unknown) {\n return html`<legend\n data-pont2-field-legend\n data-slot=\"field-legend\"\n data-variant=${o.variant ?? \"legend\"}\n ${attrs(o.attrs ?? {})}\n >${content}</legend\n >`;\n}\n\n/**\n * Applies the FieldSet recipe to the `<fieldset>` inside it. The legend must\n * be a direct child of that `<fieldset>` to name it, so write\n * `<legend data-pont2-field-legend>` (there is no legend element).\n *\n * @tag pont2-prim-field-set\n */\nexport class FieldSetElement extends NativeEnhancer<HTMLFieldSetElement> {\n static override nativeSelector = \"fieldset\";\n protected apply(control: HTMLFieldSetElement): void {\n applyFieldSet(control);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldGroup / Field / FieldContent */\n/* ------------------------------------------------------------------ */\n\n/** @tag pont2-prim-field-group */\nexport class FieldGroup extends HostElement {\n static override identity = \"field-group\";\n static override slotName = \"field-group\";\n}\n\nexport type FieldOrientation = \"vertical\" | \"horizontal\" | \"responsive\";\n\n/**\n * @tag pont2-prim-field\n * @attr orientation - vertical (default) | horizontal | responsive\n * @attr invalid - Sets `data-invalid` (destructive text colour), like shadcn's `data-invalid`.\n * @attr disabled - Sets `data-disabled` (dims the label/title), like shadcn's `data-disabled`.\n */\nexport class Field extends HostElement {\n static override identity = \"field\";\n static override slotName = \"field\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n invalid: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare orientation: FieldOrientation;\n declare invalid: boolean;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.orientation = \"vertical\";\n this.invalid = false;\n this.disabled = false;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"orientation\", this.orientation || \"vertical\");\n // Only manage the state attributes we own; an author's data-invalid=\"true\" stays.\n if (changed.has(\"invalid\") && (this.invalid || changed.get(\"invalid\"))) this.setData(\"invalid\", this.invalid);\n if (changed.has(\"disabled\") && (this.disabled || changed.get(\"disabled\"))) this.setData(\"disabled\", this.disabled);\n }\n}\n\n/** @tag pont2-prim-field-content */\nexport class FieldContent extends HostElement {\n static override identity = \"field-content\";\n static override slotName = \"field-content\";\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldLabel (native) / FieldTitle */\n/* ------------------------------------------------------------------ */\n\nexport function applyFieldLabel(el: HTMLLabelElement): void {\n applyLabel(el, \"field-label\");\n if (!el.hasAttribute(\"data-pont2-field-label\")) el.setAttribute(\"data-pont2-field-label\", \"\");\n}\n\n/** `<label data-pont2-label data-pont2-field-label data-slot=\"field-label\">` */\nexport function fieldLabel(o: { for?: string; id?: string; attrs?: AttrMap }, content: unknown) {\n return html`<label\n data-pont2-label\n data-pont2-field-label\n data-slot=\"field-label\"\n for=${o.for ?? nothing}\n id=${o.id ?? nothing}\n ${attrs(o.attrs ?? {})}\n >${content}</label\n >`;\n}\n\n/** @tag pont2-prim-field-label */\nexport class FieldLabelElement extends NativeEnhancer<HTMLLabelElement> {\n static override nativeSelector = \"label\";\n protected apply(control: HTMLLabelElement): void {\n applyFieldLabel(control);\n }\n}\n\n/**\n * A label-styled title for a field that has no single control to label\n * (shadcn gives it `data-slot=\"field-label\"` too, kept verbatim).\n *\n * @tag pont2-prim-field-title\n */\nexport class FieldTitle extends HostElement {\n static override identity = \"field-title\";\n static override slotName = \"field-label\";\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldDescription / FieldSeparator / FieldError */\n/* ------------------------------------------------------------------ */\n\n/** @tag pont2-prim-field-description */\nexport class FieldDescription extends HostElement {\n static override identity = \"field-description\";\n static override slotName = \"field-description\";\n}\n\n/**\n * shadcn renders `div > Separator + span`. pont2 draws the two rule halves\n * with `::before`/`::after`, so the only nodes are the host and your text.\n * `data-content` is set when the separator has text, as in shadcn.\n *\n * @tag pont2-prim-field-separator\n */\nexport class FieldSeparator extends HostElement {\n static override identity = \"field-separator\";\n static override slotName = \"field-separator\";\n\n private observer?: MutationObserver;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.observe(this, { childList: true, characterData: true, subtree: true });\n this.sync();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n private sync() {\n this.setAttribute(\"data-content\", String(!!this.textContent?.trim() || this.children.length > 0));\n }\n}\n\nexport interface FieldErrorItem {\n message?: string;\n}\n\n/**\n * Write the message as children, or set `.errors` (shadcn's `errors` prop:\n * de-duplicated by message; one renders as text, several as a list). Hidden\n * while empty, like shadcn returning `null`.\n *\n * @tag pont2-prim-field-error\n */\nexport class FieldError extends HostElement {\n static override identity = \"field-error\";\n static override slotName = \"field-error\";\n static override role = \"alert\";\n\n static override properties: PropertyDeclarations = {\n errors: { attribute: false },\n };\n\n declare errors: Array<FieldErrorItem | undefined> | undefined;\n\n override render() {\n if (!this.errors?.length) return nothing;\n const unique = [...new Map(this.errors.map(e => [e?.message, e])).values()].filter(e => e?.message);\n if (unique.length === 1) return unique[0]!.message;\n return html`<ul data-slot=\"field-error-list\">\n ${unique.map(e => html`<li>${e!.message}</li>`)}\n </ul>`;\n }\n}\n\ndefine(\"pont2-prim-field-set\", FieldSetElement);\ndefine(\"pont2-prim-field-group\", FieldGroup);\ndefine(\"pont2-prim-field\", Field);\ndefine(\"pont2-prim-field-content\", FieldContent);\ndefine(\"pont2-prim-field-label\", FieldLabelElement);\ndefine(\"pont2-prim-field-title\", FieldTitle);\ndefine(\"pont2-prim-field-description\", FieldDescription);\ndefine(\"pont2-prim-field-separator\", FieldSeparator);\ndefine(\"pont2-prim-field-error\", FieldError);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-field-set\": FieldSetElement;\n \"pont2-prim-field-group\": FieldGroup;\n \"pont2-prim-field\": Field;\n \"pont2-prim-field-content\": FieldContent;\n \"pont2-prim-field-label\": FieldLabelElement;\n \"pont2-prim-field-title\": FieldTitle;\n \"pont2-prim-field-description\": FieldDescription;\n \"pont2-prim-field-separator\": FieldSeparator;\n \"pont2-prim-field-error\": FieldError;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement, NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { applyButton, button, Pont2Button, type ButtonOptions } from \"../button/button\";\nimport { applyInput, input, type InputOptions } from \"../input/input\";\nimport { applyTextarea, textarea, type TextareaOptions } from \"../textarea/textarea\";\n\nexport type InputGroupAddonAlign = \"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\";\nexport type InputGroupButtonSize = \"xs\" | \"sm\" | \"icon-xs\" | \"icon-sm\";\n\n/**\n * # InputGroup family\n *\n * shadcn: `InputGroup` (`div role=\"group\" data-slot=\"input-group\"`),\n * `InputGroupAddon` (`div role=\"group\" data-align`, click focuses the input),\n * `InputGroupText` (a `span`), and the controls `InputGroupInput` /\n * `InputGroupTextarea` / `InputGroupButton`, which are shadcn's `Input`,\n * `Textarea` and `Button` with extra classes and\n * `data-slot=\"input-group-control\"` (button: ghost, size xs).\n *\n * pont2:\n * - `<pont2-prim-input-group>`, `<pont2-prim-input-group-addon>`, `<pont2-prim-input-group-text>`\n * are host-as-root (Tier 1).\n * - The controls stay native (Tier 3): the Input/Textarea/Button recipe plus\n * an extra identity. Write them as recipes\n * (`<input data-pont2-input data-pont2-input-group-input data-slot=\"input-group-control\">`),\n * parts (`inputGroupInput()`), or enhancers (`<pont2-prim-input-group-input><input></…>`).\n *\n * Like shadcn, the control must be a *direct* child of the group for the\n * group's `has-[>input]` padding rules; with an enhancer the shell is\n * `display: contents` and the rules also match through it.\n */\n\n/**\n * @tag pont2-prim-input-group\n * @attr disabled - Sets `data-disabled` (dims addons), like shadcn's `data-disabled=\"true\"`.\n */\nexport class InputGroup extends HostElement {\n static override identity = \"input-group\";\n static override slotName = \"input-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n disabled: { type: Boolean, reflect: true },\n };\n\n declare disabled: boolean;\n\n constructor() {\n super();\n this.disabled = false;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && (this.disabled || changed.get(\"disabled\"))) this.setData(\"disabled\", this.disabled);\n }\n}\n\n/**\n * @tag pont2-prim-input-group-addon\n * @attr align - inline-start (default) | inline-end | block-start | block-end\n */\nexport class InputGroupAddon extends HostElement {\n static override identity = \"input-group-addon\";\n static override slotName = \"input-group-addon\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n align: { type: String, reflect: true },\n };\n\n declare align: InputGroupAddonAlign;\n\n constructor() {\n super();\n this.align = \"inline-start\";\n // shadcn: clicking the addon (but not a button in it) focuses the group's input.\n this.addEventListener(\"click\", e => {\n if ((e.target as HTMLElement).closest(\"button\")) return;\n this.parentElement?.querySelector(\"input\")?.focus();\n });\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"inline-start\");\n }\n}\n\n/** shadcn's InputGroupText has no data-slot; pont2 keeps it that way. @tag pont2-prim-input-group-text */\nexport class InputGroupText extends HostElement {\n static override identity = \"input-group-text\";\n}\n\n/* ------------------------------------------------------------------ */\n/* Controls (native) */\n/* ------------------------------------------------------------------ */\n\nconst CONTROL = \"input-group-control\";\n\nfunction markControl(el: HTMLElement, identity: string) {\n if (!el.hasAttribute(`data-pont2-${identity}`)) el.setAttribute(`data-pont2-${identity}`, \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", CONTROL);\n}\n\nexport function inputGroupInput(o: InputOptions = {}) {\n return input({ ...o, slot: CONTROL, attrs: { \"data-pont2-input-group-input\": true, ...(o.attrs ?? {}) } });\n}\n\nexport function inputGroupTextarea(o: TextareaOptions = {}) {\n return textarea({ ...o, slot: CONTROL, attrs: { \"data-pont2-input-group-textarea\": true, ...(o.attrs ?? {}) } });\n}\n\nexport interface InputGroupButtonOptions extends Omit<ButtonOptions, \"size\"> {\n size?: InputGroupButtonSize;\n}\n\n/** shadcn defaults: `variant=\"ghost\"`, `size=\"xs\"`, `type=\"button\"`. */\nexport function inputGroupButton(o: InputGroupButtonOptions, content: unknown) {\n return button(\n {\n variant: \"ghost\",\n ...o,\n size: (o.size ?? \"xs\") as ButtonOptions[\"size\"],\n attrs: { \"data-pont2-input-group-button\": true, ...(o.attrs ?? {}) },\n },\n content,\n );\n}\n\n/** @tag pont2-prim-input-group-input */\nexport class InputGroupInput extends NativeEnhancer<HTMLInputElement> {\n static override nativeSelector = \"input\";\n protected apply(control: HTMLInputElement): void {\n if (!control.hasAttribute(\"data-slot\")) control.setAttribute(\"data-slot\", CONTROL);\n applyInput(control, CONTROL);\n markControl(control, \"input-group-input\");\n }\n}\n\n/** @tag pont2-prim-input-group-textarea */\nexport class InputGroupTextarea extends NativeEnhancer<HTMLTextAreaElement> {\n static override nativeSelector = \"textarea\";\n protected apply(control: HTMLTextAreaElement): void {\n if (!control.hasAttribute(\"data-slot\")) control.setAttribute(\"data-slot\", CONTROL);\n applyTextarea(control, CONTROL);\n markControl(control, \"input-group-textarea\");\n }\n}\n\n/**\n * `<pont2-prim-button>` with shadcn's InputGroupButton defaults (ghost, xs) and its\n * extra recipe. It *is* a Pont2Button enhancer, so everything else is inherited.\n *\n * @tag pont2-prim-input-group-button\n * @attr size - xs (default) | sm | icon-xs | icon-sm\n */\nexport class InputGroupButton extends Pont2Button {\n constructor() {\n super();\n this.variant = \"ghost\";\n this.size = \"xs\";\n }\n\n protected override apply(control: HTMLButtonElement | HTMLAnchorElement): void {\n applyButton(control, this);\n if (!control.hasAttribute(\"data-pont2-input-group-button\")) control.setAttribute(\"data-pont2-input-group-button\", \"\");\n if (control instanceof HTMLButtonElement && !control.hasAttribute(\"type\")) control.type = \"button\";\n }\n}\n\ndefine(\"pont2-prim-input-group\", InputGroup);\ndefine(\"pont2-prim-input-group-addon\", InputGroupAddon);\ndefine(\"pont2-prim-input-group-text\", InputGroupText);\ndefine(\"pont2-prim-input-group-input\", InputGroupInput);\ndefine(\"pont2-prim-input-group-textarea\", InputGroupTextarea);\ndefine(\"pont2-prim-input-group-button\", InputGroupButton);\n\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input-group\": InputGroup;\n \"pont2-prim-input-group-addon\": InputGroupAddon;\n \"pont2-prim-input-group-text\": InputGroupText;\n \"pont2-prim-input-group-input\": InputGroupInput;\n \"pont2-prim-input-group-textarea\": InputGroupTextarea;\n \"pont2-prim-input-group-button\": InputGroupButton;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { Separator } from \"../separator/separator\";\n\nexport type ItemVariant = \"default\" | \"outline\" | \"muted\";\nexport type ItemSize = \"default\" | \"sm\" | \"xs\";\nexport type ItemMediaVariant = \"default\" | \"icon\" | \"image\";\n\n/**\n * # Item family: Tier 1 (structural)\n *\n * shadcn: `ItemGroup` (`div role=\"list\"`), `Item` (Base UI `useRender`, a div\n * by default, or the author's `<a>` through `render`), `ItemMedia`,\n * `ItemContent`, `ItemTitle`, `ItemDescription` (a `p`), `ItemActions`,\n * `ItemHeader`, `ItemFooter`, and `ItemSeparator` (a `Separator`).\n *\n * pont2: every part is host-as-root. A link item is the recipe on a real\n * anchor: `<a data-pont2-item data-variant=\"outline\" href=\"…\">`.\n * `ItemSeparator extends Separator`, so it *is* a separator (one node, role\n * separator) that keeps the separator look and adds `data-slot=\"item-separator\"`.\n */\n\n/** @tag pont2-prim-item-group */\nexport class ItemGroup extends HostElement {\n static override identity = \"item-group\";\n static override slotName = \"item-group\";\n static override role = \"list\";\n}\n\n/** @tag pont2-prim-item-separator */\nexport class ItemSeparator extends Separator {\n static override identity = \"item-separator\";\n static override slotName = \"item-separator\";\n}\n\n/**\n * @tag pont2-prim-item\n * @attr variant - default | outline | muted\n * @attr size - default | sm | xs\n */\nexport class Item extends HostElement {\n static override identity = \"item\";\n static override slotName = \"item\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n size: { type: String, reflect: true },\n };\n\n declare variant: ItemVariant;\n declare size: ItemSize;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n this.setData(\"size\", this.size || \"default\");\n }\n}\n\n/**\n * @tag pont2-prim-item-media\n * @attr variant - default | icon | image\n */\nexport class ItemMedia extends HostElement {\n static override identity = \"item-media\";\n static override slotName = \"item-media\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: ItemMediaVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-item-content */\nexport class ItemContent extends HostElement {\n static override identity = \"item-content\";\n static override slotName = \"item-content\";\n}\n\n/** @tag pont2-prim-item-title */\nexport class ItemTitle extends HostElement {\n static override identity = \"item-title\";\n static override slotName = \"item-title\";\n}\n\n/** @tag pont2-prim-item-description */\nexport class ItemDescription extends HostElement {\n static override identity = \"item-description\";\n static override slotName = \"item-description\";\n}\n\n/** @tag pont2-prim-item-actions */\nexport class ItemActions extends HostElement {\n static override identity = \"item-actions\";\n static override slotName = \"item-actions\";\n}\n\n/** @tag pont2-prim-item-header */\nexport class ItemHeader extends HostElement {\n static override identity = \"item-header\";\n static override slotName = \"item-header\";\n}\n\n/** @tag pont2-prim-item-footer */\nexport class ItemFooter extends HostElement {\n static override identity = \"item-footer\";\n static override slotName = \"item-footer\";\n}\n\ndefine(\"pont2-prim-item-group\", ItemGroup);\ndefine(\"pont2-prim-item-separator\", ItemSeparator);\ndefine(\"pont2-prim-item\", Item);\ndefine(\"pont2-prim-item-media\", ItemMedia);\ndefine(\"pont2-prim-item-content\", ItemContent);\ndefine(\"pont2-prim-item-title\", ItemTitle);\ndefine(\"pont2-prim-item-description\", ItemDescription);\ndefine(\"pont2-prim-item-actions\", ItemActions);\ndefine(\"pont2-prim-item-header\", ItemHeader);\ndefine(\"pont2-prim-item-footer\", ItemFooter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-item-group\": ItemGroup;\n \"pont2-prim-item-separator\": ItemSeparator;\n \"pont2-prim-item\": Item;\n \"pont2-prim-item-media\": ItemMedia;\n \"pont2-prim-item-content\": ItemContent;\n \"pont2-prim-item-title\": ItemTitle;\n \"pont2-prim-item-description\": ItemDescription;\n \"pont2-prim-item-actions\": ItemActions;\n \"pont2-prim-item-header\": ItemHeader;\n \"pont2-prim-item-footer\": ItemFooter;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type NativeSelectSize = \"default\" | \"sm\";\n\n/**\n * # NativeSelect: Tier 1 wrapper + native `<select>`\n *\n * shadcn: `<NativeSelect size>` renders\n * `div[data-slot=native-select-wrapper][data-size] > select[data-slot=native-select][data-size] + svg[data-slot=native-select-icon]`;\n * `NativeSelectOption` / `NativeSelectOptGroup` are `<option>` / `<optgroup>`.\n *\n * pont2: `<pont2-prim-native-select>` **is** the wrapper div; you write the native\n * `<select>` (and its options) inside, and the host applies the recipe to it.\n * The chevron is drawn by the wrapper's `::after`, so the DOM is\n * `pont2-prim-native-select > select`: one node fewer than shadcn, and the select\n * stays a real form control (submission, autofill, mobile pickers).\n *\n * ```html\n * <pont2-prim-native-select>\n * <select name=\"country\"><option>Norway</option><option>Japan</option></select>\n * </pont2-prim-native-select>\n * ```\n *\n * @tag pont2-prim-native-select\n * @attr size - default | sm\n * @cssprop --pont2-native-select-icon - mask image for the chevron\n */\nexport class NativeSelect extends HostElement {\n static override identity = \"native-select-wrapper\";\n static override slotName = \"native-select-wrapper\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n };\n\n declare size: NativeSelectSize;\n\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.size = \"default\";\n }\n\n /** The native `<select>`. */\n get control(): HTMLSelectElement | null {\n return this.querySelector(\":scope > select\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n protected override willUpdate(): void {\n const size = this.size || \"default\";\n this.setData(\"size\", size);\n const select = this.control;\n if (select) applyNativeSelect(select, size);\n }\n}\n\nexport function applyNativeSelect(el: HTMLSelectElement, size: NativeSelectSize = \"default\"): void {\n if (!el.hasAttribute(\"data-pont2-native-select\")) el.setAttribute(\"data-pont2-native-select\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"native-select\");\n el.setAttribute(\"data-size\", size);\n}\n\nexport interface NativeSelectOptions {\n size?: NativeSelectSize;\n id?: string;\n name?: string;\n disabled?: boolean;\n required?: boolean;\n invalid?: boolean;\n attrs?: AttrMap;\n onChange?: (e: Event) => void;\n}\n\n/** Part: the wrapper div and the select in one template (options are the content). */\nexport function nativeSelect(o: NativeSelectOptions, options: unknown) {\n const size = o.size ?? \"default\";\n return html`<div data-pont2-native-select-wrapper data-slot=\"native-select-wrapper\" data-size=${size}>\n <select\n data-pont2-native-select\n data-slot=\"native-select\"\n data-size=${size}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n ?disabled=${o.disabled}\n ?required=${o.required}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n ${attrs(o.attrs ?? {})}\n @change=${o.onChange ?? nothing}\n >\n ${options}\n </select>\n </div>`;\n}\n\ndefine(\"pont2-prim-native-select\", NativeSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-native-select\": NativeSelect;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Table: Tier 1 container + native table (recipe)\n *\n * shadcn: `<Table>` → `<div data-slot=\"table-container\"><table data-slot=\"table\">`,\n * and `TableHeader | TableBody | TableFooter | TableRow | TableHead |\n * TableCell | TableCaption` are the native `thead | tbody | tfoot | tr | th |\n * td | caption` with a `data-slot` each.\n *\n * Table parts cannot be custom elements: the HTML parser \"foster-parents\"\n * unknown elements out of a `<table>` (`<table><pont2-tr>` puts the\n * `pont2-tr` *before* the table). And `colspan`, `headers`, `scope` and the\n * native table semantics only exist on the native elements.\n *\n * So `<pont2-prim-table>` **is** the container div (host-as-root), and you write a\n * plain native `<table>` inside it:\n *\n * ```html\n * <pont2-prim-table>\n * <table>\n * <caption>Recent invoices</caption>\n * <thead><tr><th>Invoice</th><th>Amount</th></tr></thead>\n * <tbody><tr><td>INV001</td><td>$250.00</td></tr></tbody>\n * </table>\n * </pont2-prim-table>\n * ```\n *\n * The host stamps each part's recipe (`data-pont2-table-*` + shadcn's\n * `data-slot`) onto the native elements of *its own* table (not nested ones),\n * and keeps doing so as rows are added. Styling also works before upgrade and\n * with no JS, through `pont2-prim-table > table …` selectors, and outside the\n * element via the recipe attributes (`applyTable()`).\n *\n * @tag pont2-prim-table\n */\nexport class Table extends HostElement {\n static override identity = \"table-container\";\n static override slotName = \"table-container\";\n\n private observer?: MutationObserver;\n\n /** The native `<table>` this container holds. */\n get table(): HTMLTableElement | null {\n return this.querySelector(\":scope > table\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.stamp());\n this.observer.observe(this, { childList: true, subtree: true });\n this.stamp();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n private stamp() {\n const t = this.table;\n if (t) applyTable(t);\n }\n}\n\nconst PARTS: Record<string, string> = {\n CAPTION: \"table-caption\",\n THEAD: \"table-header\",\n TBODY: \"table-body\",\n TFOOT: \"table-footer\",\n TR: \"table-row\",\n TH: \"table-head\",\n TD: \"table-cell\",\n};\n\nfunction mark(el: Element, part: string) {\n if (!el.hasAttribute(`data-pont2-${part}`)) el.setAttribute(`data-pont2-${part}`, \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", part);\n}\n\n/**\n * Applies the table recipe to a native `<table>` and its own sections, rows\n * and cells (not those of nested tables). Idempotent.\n */\nexport function applyTable(table: HTMLTableElement): void {\n mark(table, \"table\");\n if (table.caption) mark(table.caption, PARTS.CAPTION);\n for (const section of [table.tHead, ...Array.from(table.tBodies), table.tFoot]) {\n if (section) mark(section, PARTS[section.tagName]);\n }\n for (const row of Array.from(table.rows)) {\n mark(row, PARTS.TR);\n for (const cell of Array.from(row.cells)) mark(cell, PARTS[cell.tagName]);\n }\n}\n\ndefine(\"pont2-prim-table\", Table);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-table\": Table;\n }\n}\n","/**\n * Pure InputOTP helpers (no DOM), unit-tested in node.\n *\n * `pattern` is a whole-string regular expression source, like the input-otp\n * library's `REGEXP_ONLY_DIGITS` (`^\\d+$`); each character is tested on its\n * own, so pasted \"123-456\" or \"12 34 56\" is cleaned to \"123456\".\n */\nexport const REGEXP_ONLY_DIGITS = \"^\\\\d+$\";\nexport const REGEXP_ONLY_CHARS = \"^[a-zA-Z]+$\";\nexport const REGEXP_ONLY_DIGITS_AND_CHARS = \"^[a-zA-Z0-9]+$\";\n\nexport function sanitizeOtp(raw: string, maxLength: number, pattern: string | null = REGEXP_ONLY_DIGITS): string {\n let re: RegExp | null = null;\n if (pattern) {\n try {\n re = new RegExp(pattern);\n } catch {\n re = null;\n }\n }\n let out = \"\";\n for (const ch of Array.from(raw)) {\n if (out.length >= maxLength) break;\n if (/\\s/.test(ch)) continue;\n if (re && !re.test(ch)) continue;\n out += ch;\n }\n return out;\n}\n\nexport interface OtpSlotState {\n char: string | null;\n isActive: boolean;\n hasFakeCaret: boolean;\n}\n\n/**\n * Per-slot state, as input-otp computes it: while focused, the slot(s) under\n * the selection are active; a collapsed selection on an empty slot shows the\n * fake caret. A full value with the caret at the end activates the last slot.\n */\nexport function otpSlots(\n value: string,\n maxLength: number,\n focused: boolean,\n selStart: number | null,\n selEnd: number | null,\n): OtpSlotState[] {\n const chars = Array.from(value);\n let start = selStart ?? chars.length;\n let end = selEnd ?? start;\n if (start === end && start >= maxLength) {\n start = maxLength - 1;\n end = maxLength;\n }\n const collapsed = start === end;\n return Array.from({ length: maxLength }, (_, i) => {\n const char = chars[i] ?? null;\n const isActive = focused && (collapsed ? i === start : i >= start && i < end);\n return { char, isActive, hasFakeCaret: isActive && collapsed && char === null };\n });\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define, sel } from \"../../core/names\";\nimport { REGEXP_ONLY_DIGITS, otpSlots, sanitizeOtp, type OtpSlotState } from \"./otp\";\n\nexport { REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from \"./otp\";\n\nconst ROOT = sel(\"input-otp\");\nconst SLOT = sel(\"input-otp-slot\");\nconst FORWARDED = [\"aria-label\", \"aria-labelledby\", \"aria-describedby\", \"aria-invalid\"] as const;\n\nexport interface OtpCompleteDetail {\n value: string;\n}\n\n/**\n * # InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator\n *\n * shadcn wraps the `input-otp` library: a container `div` holding the author's\n * groups/slots plus ONE real `<input>` stretched transparently over them; the\n * slots only *draw* the characters and a fake caret.\n * ```\n * shadcn: div.cn-input-otp > [InputOTPGroup > InputOTPSlot ×n, InputOTPSeparator] + div > input[data-slot=input-otp]\n * pont2: pont2-prim-input-otp > [pont2-prim-input-otp-group > pont2-prim-input-otp-slot ×n, pont2-prim-input-otp-separator] + div > input[data-slot=input-otp]\n * ```\n * Same shape, same reason: the single native `<input autocomplete=\"one-time-code\">`\n * is what SMS autofill (iOS/Android), password managers, paste and form\n * submission need. It is a Tier 3 core inside a Tier 1 container; the slots\n * are Tier 1 hosts the container pushes state into.\n *\n * The input is rendered by the host (after the author's children, where\n * input-otp puts it), so the author never writes it; `name`, `required`,\n * `disabled`, `autocomplete`, `inputmode`, `pattern` and the ARIA naming\n * attributes are forwarded to it.\n *\n * @tag pont2-prim-input-otp\n * @attr maxlength - Number of characters (default 6).\n * @attr pattern - Per-character regex source (default `^\\d+$`, digits). `pattern=\"\"` accepts anything.\n * @attr value - Default value; `.value` is live.\n * @attr name, required, disabled, autocomplete (one-time-code), inputmode, input-id\n * @fires input, change - Native events from the inner input (bubble through the host).\n * @fires pont2-complete - `{ value }` when every slot is filled (input-otp `onComplete`).\n */\nexport class InputOTP extends HostElement {\n static override identity = \"input-otp\";\n\n static override properties: PropertyDeclarations = {\n maxLength: { type: Number, attribute: \"maxlength\" },\n pattern: { type: String },\n defaultValue: { type: String, attribute: \"value\" },\n name: { type: String },\n required: { type: Boolean },\n disabled: { type: Boolean, reflect: true },\n autocomplete: { type: String },\n keyboardMode: { type: String, attribute: \"inputmode\" },\n inputId: { type: String, attribute: \"input-id\" },\n current: { state: true },\n forwarded: { state: true },\n };\n\n declare maxLength: number;\n declare pattern: string | null;\n declare defaultValue: string | null;\n declare name: string | null;\n declare required: boolean;\n declare disabled: boolean;\n declare autocomplete: string;\n /** Forwarded to the input as `inputmode` (named so it does not shadow HTMLElement.inputMode). */\n declare keyboardMode: string | null;\n declare inputId: string | null;\n declare protected current: string;\n declare protected forwarded: Record<string, string | null>;\n\n private dirty = false;\n private focused = false;\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.maxLength = 6;\n this.pattern = REGEXP_ONLY_DIGITS;\n this.defaultValue = null;\n this.name = null;\n this.required = false;\n this.disabled = false;\n this.autocomplete = \"one-time-code\";\n this.keyboardMode = null;\n this.inputId = null;\n this.current = \"\";\n this.forwarded = {};\n }\n\n /** The native input (the real form control). */\n get input(): HTMLInputElement | null {\n return this.querySelector(\":scope > [data-pont2-input-otp-input-wrapper] > input\");\n }\n\n get value(): string {\n return this.current;\n }\n set value(v: string) {\n this.dirty = true;\n this.current = sanitizeOtp(String(v ?? \"\"), this.maxLength, this.pattern || null);\n }\n\n override focus(options?: FocusOptions): void {\n this.input?.focus(options);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.readForwarded();\n this.observer ??= new MutationObserver(m => {\n if (m.some(r => r.type === \"attributes\" && r.target === this)) this.readForwarded();\n else this.syncSlots();\n });\n this.observer.observe(this, { attributes: true, attributeFilter: [...FORWARDED], childList: true, subtree: true });\n document.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n document.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n\n private readForwarded(): void {\n const f: Record<string, string | null> = {};\n for (const a of FORWARDED) f[a] = this.getAttribute(a);\n this.forwarded = f;\n }\n\n private get slots(): InputOTPSlot[] {\n return Array.from(this.querySelectorAll<InputOTPSlot>(SLOT)).filter(s => s.closest(ROOT) === this);\n }\n\n /** Push per-slot state into the slot elements. */\n private syncSlots(): void {\n const input = this.input;\n const states = otpSlots(this.current, this.maxLength, this.focused, input?.selectionStart ?? null, input?.selectionEnd ?? null);\n const invalid = this.forwarded[\"aria-invalid\"] === \"true\";\n this.slots.forEach((slot, order) => {\n const i = slot.hasAttribute(\"index\") ? Number(slot.getAttribute(\"index\")) : order;\n if (typeof slot.sync === \"function\") slot.sync(states[i] ?? { char: null, isActive: false, hasFakeCaret: false }, invalid);\n });\n }\n\n /* -------------------------------------------------------------- */\n /* Input handling (what input-otp does) */\n /* -------------------------------------------------------------- */\n\n private setFromInput(raw: string, input: HTMLInputElement): void {\n const clean = sanitizeOtp(raw, this.maxLength, this.pattern || null);\n if (clean !== input.value) {\n input.value = clean;\n input.setSelectionRange(clean.length, clean.length);\n }\n const was = this.current;\n this.dirty = true;\n this.current = clean;\n if (clean !== was && clean.length === this.maxLength) {\n fire<OtpCompleteDetail>(this, \"pont2-complete\", { value: clean });\n }\n this.syncSlots();\n }\n\n private onInput = (e: Event) => {\n this.setFromInput((e.target as HTMLInputElement).value, e.target as HTMLInputElement);\n };\n\n private onPaste = (e: ClipboardEvent) => {\n const input = e.target as HTMLInputElement;\n const text = e.clipboardData?.getData(\"text/plain\");\n if (text == null) return;\n // The native maxlength would truncate \"123-456\" before we could clean it.\n e.preventDefault();\n const start = input.selectionStart ?? input.value.length;\n const end = input.selectionEnd ?? start;\n this.setFromInput(input.value.slice(0, start) + text + input.value.slice(end), input);\n input.dispatchEvent(new Event(\"input\", { bubbles: true, composed: true }));\n };\n\n private placeCaret = () => {\n const input = this.input;\n if (!input) return;\n const n = input.value.length;\n // Full: select the last character so the next key replaces it (input-otp behaviour).\n if (n >= this.maxLength) input.setSelectionRange(this.maxLength - 1, this.maxLength);\n else input.setSelectionRange(n, n);\n this.syncSlots();\n };\n\n private onFocus = () => {\n this.focused = true;\n this.setData(\"focused\", true);\n requestAnimationFrame(this.placeCaret);\n };\n\n private onBlur = () => {\n this.focused = false;\n this.setData(\"focused\", false);\n this.syncSlots();\n };\n\n private onSelectionChange = () => {\n if (this.focused && document.activeElement === this.input) this.syncSlots();\n };\n\n /* -------------------------------------------------------------- */\n /* Render */\n /* -------------------------------------------------------------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) {\n this.current = sanitizeOtp(this.defaultValue ?? \"\", this.maxLength, this.pattern || null);\n }\n this.setData(\"disabled\", this.disabled);\n this.setData(\"complete\", this.current.length === this.maxLength);\n }\n\n protected override updated(): void {\n this.syncSlots();\n }\n\n override render() {\n const digits = this.pattern === REGEXP_ONLY_DIGITS;\n const f = this.forwarded;\n return html`<div data-pont2-input-otp-input-wrapper>\n <input\n data-pont2-input-otp-input\n data-slot=\"input-otp\"\n id=${this.inputId ?? nothing}\n name=${this.name ?? nothing}\n .value=${live(this.current)}\n maxlength=${this.maxLength}\n pattern=${this.pattern || nothing}\n inputmode=${(this.keyboardMode ?? (digits ? \"numeric\" : \"text\")) as never}\n autocomplete=${this.autocomplete as never}\n spellcheck=\"false\"\n autocapitalize=\"off\"\n ?required=${this.required}\n ?disabled=${this.disabled}\n aria-label=${f[\"aria-label\"] ?? nothing}\n aria-labelledby=${f[\"aria-labelledby\"] ?? nothing}\n aria-describedby=${f[\"aria-describedby\"] ?? nothing}\n aria-invalid=${f[\"aria-invalid\"] ?? nothing}\n @input=${this.onInput}\n @paste=${this.onPaste}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n @click=${this.placeCaret}\n />\n </div>`;\n }\n}\n\n/**\n * @tag pont2-prim-input-otp-group\n */\nexport class InputOTPGroup extends HostElement {\n static override identity = \"input-otp-group\";\n static override slotName = \"input-otp-group\";\n}\n\n/**\n * Draws one character (and the fake caret). Purely visual: the native input\n * is what assistive technology and autofill interact with.\n *\n * @tag pont2-prim-input-otp-slot\n * @attr index - Character position; defaults to the slot's order in the InputOTP.\n */\nexport class InputOTPSlot extends HostElement {\n static override identity = \"input-otp-slot\";\n static override slotName = \"input-otp-slot\";\n\n static override properties: PropertyDeclarations = {\n state: { state: true },\n };\n\n declare protected state: OtpSlotState;\n\n constructor() {\n super();\n this.state = { char: null, isActive: false, hasFakeCaret: false };\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as InputOTP | null)?.requestUpdate();\n }\n\n /** @internal Called by the InputOTP. */\n sync(state: OtpSlotState, invalid: boolean): void {\n this.state = state;\n this.setData(\"active\", state.isActive ? \"true\" : \"false\");\n this.setData(\"filled\", state.char != null);\n this.setData(\"invalid\", invalid);\n }\n\n override render() {\n const { char, hasFakeCaret } = this.state;\n return html`${char ?? nothing}${hasFakeCaret\n ? html`<div data-pont2-input-otp-caret><div data-pont2-input-otp-caret-line></div></div>`\n : nothing}`;\n }\n}\n\n/**\n * @tag pont2-prim-input-otp-separator\n */\nexport class InputOTPSeparator extends HostElement {\n static override identity = \"input-otp-separator\";\n static override slotName = \"input-otp-separator\";\n static override role = \"separator\";\n\n override render() {\n return icons.minus();\n }\n}\n\ndefine(\"pont2-prim-input-otp\", InputOTP);\ndefine(\"pont2-prim-input-otp-group\", InputOTPGroup);\ndefine(\"pont2-prim-input-otp-slot\", InputOTPSlot);\ndefine(\"pont2-prim-input-otp-separator\", InputOTPSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input-otp\": InputOTP;\n \"pont2-prim-input-otp-group\": InputOTPGroup;\n \"pont2-prim-input-otp-slot\": InputOTPSlot;\n \"pont2-prim-input-otp-separator\": InputOTPSeparator;\n }\n interface HTMLElementEventMap {\n \"pont2-complete\": CustomEvent<OtpCompleteDetail>;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\n\nexport type ProgressStatus = \"progressing\" | \"complete\" | \"indeterminate\";\n\nconst ROOT = sel(\"progress\");\n\n/**\n * # Progress, ProgressLabel, ProgressValue: Tier 1/2 (status widget)\n *\n * shadcn: `<Progress value>` → Base UI `<Progress.Root>` (div[role=progressbar])\n * holding the author's children, then `<Progress.Track>` > `<Progress.Indicator>`\n * which shadcn always appends. `<ProgressLabel>` / `<ProgressValue>` are optional\n * children (span).\n *\n * pont2:\n * ```\n * pont2-prim-progress[role=progressbar] ← root; aria-value* via ElementInternals\n * pont2-prim-progress-label? pont2-prim-progress-value? ← author-written, never moved\n * div[data-slot=progress-track] > div[data-slot=progress-indicator] ← rendered last, as shadcn does\n * ```\n * Status attributes are Base UI's: `data-progressing` | `data-complete` |\n * `data-indeterminate`, on every part. No `value` attribute = indeterminate.\n *\n * @tag pont2-prim-progress\n * @attr value - Current value; omit for indeterminate.\n * @attr min, max - Range (default 0–100).\n */\nexport class Progress extends HostElement {\n static override identity = \"progress\";\n static override slotName = \"progress\";\n static override role = \"progressbar\";\n\n static override properties: PropertyDeclarations = {\n value: { type: Number },\n min: { type: Number },\n max: { type: Number },\n };\n\n declare value: number | null;\n declare min: number;\n declare max: number;\n\n constructor() {\n super();\n this.value = null;\n this.min = 0;\n this.max = 100;\n }\n\n get status(): ProgressStatus {\n if (this.value == null || Number.isNaN(this.value)) return \"indeterminate\";\n return this.value >= this.max ? \"complete\" : \"progressing\";\n }\n\n /** 0..1, or null when indeterminate. */\n get fraction(): number | null {\n if (this.status === \"indeterminate\") return null;\n const span = this.max - this.min;\n return span > 0 ? Math.min(1, Math.max(0, (this.value! - this.min) / span)) : 0;\n }\n\n /** The value as Base UI formats it by default: a locale percentage. */\n get formattedValue(): string {\n const f = this.fraction;\n return f == null ? \"\" : new Intl.NumberFormat(undefined, { style: \"percent\" }).format(f);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n const status = this.status;\n const i = this.internals;\n i.ariaValueMin = String(this.min);\n i.ariaValueMax = String(this.max);\n i.ariaValueNow = status === \"indeterminate\" ? null : String(this.value);\n i.ariaValueText = status === \"indeterminate\" ? null : this.formattedValue;\n for (const s of [\"progressing\", \"complete\", \"indeterminate\"] as const) this.setData(s, s === status);\n }\n\n protected override updated(): void {\n const labels = this.own<ProgressLabel>(sel(\"progress-label\"));\n if (\"ariaLabelledByElements\" in ElementInternals.prototype) {\n (this.internals as unknown as { ariaLabelledByElements: Element[] | null }).ariaLabelledByElements = labels.length ? labels : null;\n } else if (labels.length && !this.hasAttribute(\"aria-labelledby\")) {\n this.setAttribute(\"aria-labelledby\", labels.map(l => ensureId(l, \"progress-label\")).join(\" \"));\n }\n const parts = [...labels, ...this.own<ProgressValue>(sel(\"progress-value\"))];\n for (const p of parts) if (typeof p.sync === \"function\") p.sync(this.status, this.formattedValue);\n }\n\n private own<T extends Element>(sel: string): T[] {\n return Array.from(this.querySelectorAll<T>(sel)).filter(el => el.closest(ROOT) === this);\n }\n\n override render() {\n const s = this.status;\n const f = this.fraction;\n return html`<div\n data-pont2-progress-track\n data-slot=\"progress-track\"\n ?data-progressing=${s === \"progressing\"}\n ?data-complete=${s === \"complete\"}\n ?data-indeterminate=${s === \"indeterminate\"}\n >\n <div\n data-pont2-progress-indicator\n data-slot=\"progress-indicator\"\n ?data-progressing=${s === \"progressing\"}\n ?data-complete=${s === \"complete\"}\n ?data-indeterminate=${s === \"indeterminate\"}\n style=${f == null ? nothing : styleMap({ insetInlineStart: \"0\", width: `${f * 100}%` })}\n ></div>\n </div>`;\n }\n}\n\n/** Shared status sync for the optional parts. */\nabstract class ProgressPart extends HostElement {\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as Progress | null)?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(status: ProgressStatus, _formatted: string): void {\n for (const s of [\"progressing\", \"complete\", \"indeterminate\"] as const) this.setData(s, s === status);\n }\n}\n\n/**\n * Labels the progress bar (the root's accessible name points at it).\n * @tag pont2-prim-progress-label\n */\nexport class ProgressLabel extends ProgressPart {\n static override identity = \"progress-label\";\n static override slotName = \"progress-label\";\n}\n\n/**\n * Shows the formatted value (\"45%\") unless you write your own text inside it.\n * @tag pont2-prim-progress-value\n */\nexport class ProgressValue extends ProgressPart {\n static override identity = \"progress-value\";\n static override slotName = \"progress-value\";\n\n static override properties: PropertyDeclarations = {\n formatted: { state: true },\n };\n\n declare protected formatted: string;\n private authored = false;\n\n constructor() {\n super();\n this.formatted = \"\";\n }\n\n override connectedCallback(): void {\n // Author text wins (Base UI's `children`); decided once, before the first render.\n if (!this.hasUpdated) this.authored = (this.textContent ?? \"\").trim() !== \"\";\n super.connectedCallback();\n this.setAttribute(\"aria-hidden\", this.getAttribute(\"aria-hidden\") ?? \"true\");\n }\n\n override sync(status: ProgressStatus, formatted: string): void {\n super.sync(status, formatted);\n this.formatted = formatted;\n }\n\n override render() {\n return this.authored ? nothing : this.formatted;\n }\n}\n\ndefine(\"pont2-prim-progress\", Progress);\ndefine(\"pont2-prim-progress-label\", ProgressLabel);\ndefine(\"pont2-prim-progress-value\", ProgressValue);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-progress\": Progress;\n \"pont2-prim-progress-label\": ProgressLabel;\n \"pont2-prim-progress-value\": ProgressValue;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { RovingFocusController, type Orientation } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define, sel } from \"../../core/names\";\n\n/**\n * # RadioGroup, RadioGroupItem: Tier 2 (widgets)\n *\n * shadcn: `<RadioGroup>` → Base UI `<RadioGroup>` (`<div role=\"radiogroup\">`\n * plus a hidden input) and `<RadioGroupItem value>` → Base UI `<Radio.Root>`\n * (`<span role=\"radio\">`) > `<Radio.Indicator>` > `<span>` (the dot).\n *\n * pont2:\n * ```\n * pont2-prim-radio-group[role=radiogroup] ← form-associated: submits name=value\n * pont2-prim-radio-group-item[role=radio] ← author-written, never moved\n * span[data-slot=radio-group-indicator] ← rendered while checked\n * span[data-pont2-radio-group-indicator-icon]\n * ```\n *\n * The group owns the value, the form value, validity and the roving tab stop.\n * Items are independent stateful widgets nested inside it, which is the one\n * kind of nesting the architecture keeps (04-composition.md); they find their\n * group with `closest()` and report presses to it. Items are also\n * form-associated (submitting nothing) purely so that they are *labelable*:\n * shadcn's `<RadioGroupItem id=\"r1\"/><Label htmlFor=\"r1\">` works unchanged.\n *\n * Keyboard (Base UI / APG): Tab enters at the checked item (or the first),\n * arrows move focus **and select** (wrapping), Space selects the focused item.\n */\nexport class RadioGroup extends FormControlElement {\n static override identity = \"radio-group\";\n static override slotName = \"radio-group\";\n static override role = \"radiogroup\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n orientation: { type: String },\n };\n\n /** The selected item's value; `\"\"` when nothing is selected. */\n declare value: string;\n /** Arrow-key axis. Base UI accepts both axes by default. */\n declare orientation: Orientation | undefined;\n\n private roving = new RovingFocusController(this, {\n items: () => this.items,\n orientation: () => this.orientation ?? \"both\",\n onNavigate: item => this.selectItem(item as RadioGroupItem),\n });\n\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n /** The items that belong to this group (not to a nested group). */\n get items(): RadioGroupItem[] {\n return Array.from(this.querySelectorAll<RadioGroupItem>(sel(\"radio-group-item\"))).filter(\n i => i.closest(sel(\"radio-group\")) === this,\n );\n }\n\n protected override get hostFocusable(): boolean {\n return false;\n }\n\n protected override get validationAnchor(): HTMLElement | undefined {\n return this.items[0];\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true, subtree: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n /** Called by an item when it is pressed. */\n selectItem(item: RadioGroupItem): void {\n if (this.isDisabled || this.readOnly || item.disabled) return;\n if (item.value === this.value) return;\n this.value = item.value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n /** Called by items when they connect, so a late-upgrading item is synced. */\n itemsChanged(): void {\n this.requestUpdate();\n }\n\n protected formValue() {\n return this.value || null;\n }\n\n protected resetToDefault(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n protected override validate(): ValidityResult | null {\n return this.required && !this.value\n ? { flags: { valueMissing: true }, message: \"Please select one of these options.\" }\n : null;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaOrientation = this.orientation === \"horizontal\" || this.orientation === \"vertical\" ? this.orientation : null;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n let checked: RadioGroupItem | null = null;\n for (const item of this.items) {\n item.checked = !!this.value && item.value === this.value;\n item.groupDisabled = disabled;\n item.groupReadOnly = this.readOnly;\n item.groupRequired = this.required;\n if (item.checked) checked = item;\n }\n this.roving.sync(checked);\n }\n}\n\n/**\n * @tag pont2-prim-radio-group-item\n * @attr value - The value the group takes when this item is selected.\n * @attr disabled\n */\nexport class RadioGroupItem extends HostElement {\n static formAssociated = true;\n static override identity = \"radio-group-item\";\n static override slotName = \"radio-group-item\";\n static override role = \"radio\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n checked: { state: true },\n groupDisabled: { state: true },\n groupReadOnly: { state: true },\n groupRequired: { state: true },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare disabled: boolean;\n declare checked: boolean;\n declare groupDisabled: boolean;\n declare groupReadOnly: boolean;\n declare groupRequired: boolean;\n declare protected formDisabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.checked = false;\n this.groupDisabled = false;\n this.groupReadOnly = false;\n this.groupRequired = false;\n this.formDisabled = false;\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n }\n\n get group(): RadioGroup | null {\n return this.closest(sel(\"radio-group\")) as RadioGroup | null;\n }\n\n get isDisabled(): boolean {\n return this.disabled || this.groupDisabled || this.formDisabled;\n }\n\n get labels(): NodeList {\n return this.internals.labels;\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.group?.itemsChanged();\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled) {\n e.preventDefault();\n return;\n }\n this.group?.selectItem(this);\n // A press focuses the item, as a native radio does (also when it came from a <label>).\n if (document.activeElement !== this) this.focus();\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this) return;\n if (e.key === \" \") {\n e.preventDefault();\n this.click();\n }\n // Enter does not select a radio (native behaviour); it would submit the form natively,\n // so mirror that through the form's implicit submission.\n if (e.key === \"Enter\") this.internals.form?.requestSubmit();\n };\n\n protected override willUpdate(): void {\n const disabled = this.isDisabled;\n this.internals.ariaChecked = String(this.checked);\n this.internals.ariaDisabled = disabled ? \"true\" : null;\n this.internals.ariaReadOnly = this.groupReadOnly ? \"true\" : null;\n this.internals.ariaRequired = this.groupRequired ? \"true\" : null;\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n this.setData(\"disabled\", disabled);\n this.setData(\"readonly\", this.groupReadOnly);\n this.setData(\"required\", this.groupRequired);\n this.setState(\"checked\", this.checked);\n // The group decides the tab stop; a disabled item is never one.\n if (disabled) this.tabIndex = -1;\n else if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n override render() {\n if (!this.checked) return nothing;\n return html`<span data-pont2-radio-group-indicator data-slot=\"radio-group-indicator\" data-checked\n ><span data-pont2-radio-group-indicator-icon></span\n ></span>`;\n }\n}\n\ndefine(\"pont2-prim-radio-group\", RadioGroup);\ndefine(\"pont2-prim-radio-group-item\", RadioGroupItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-radio-group\": RadioGroup;\n \"pont2-prim-radio-group-item\": RadioGroupItem;\n }\n}\n","/**\n * Pure slider maths (no DOM), shared by <pont2-prim-slider> and unit-tested in node.\n * Mirrors Base UI's Slider value handling: values are clamped to [min, max],\n * snapped to `step` measured from `min`, and in a range slider a thumb can\n * neither cross nor come closer than `minStepsBetweenValues * step` to its\n * neighbours.\n */\n\nexport interface SliderRange {\n min: number;\n max: number;\n step: number;\n}\n\nexport const clamp = (v: number, min: number, max: number) => Math.min(max, Math.max(min, v));\n\n/** Decimal places of a number, so 0.1 + 0.2 snaps to 0.3 rather than 0.30000000000000004. */\nexport function decimals(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const s = String(n);\n if (s.includes(\"e-\")) return Number(s.split(\"e-\")[1]);\n const i = s.indexOf(\".\");\n return i < 0 ? 0 : s.length - i - 1;\n}\n\nexport function snap(value: number, { min, max, step }: SliderRange): number {\n if (!(step > 0)) return clamp(value, min, max);\n const snapped = Math.round((value - min) / step) * step + min;\n const d = Math.max(decimals(step), decimals(min));\n return clamp(Number(snapped.toFixed(d)), min, max);\n}\n\n/** 0..1 position of a value along the track. */\nexport function fraction(value: number, { min, max }: Pick<SliderRange, \"min\" | \"max\">): number {\n if (max <= min) return 0;\n return clamp((value - min) / (max - min), 0, 1);\n}\n\n/** Value at a 0..1 position along the track (before snapping). */\nexport function valueAt(f: number, { min, max }: Pick<SliderRange, \"min\" | \"max\">): number {\n return min + clamp(f, 0, 1) * (max - min);\n}\n\n/** Index of the thumb a pointer press at `value` should grab. Ties go to the later thumb when pressing above it. */\nexport function closestThumb(values: number[], value: number): number {\n let best = 0;\n let bestDist = Infinity;\n values.forEach((v, i) => {\n const d = Math.abs(v - value);\n if (d < bestDist || (d === bestDist && value > v)) {\n best = i;\n bestDist = d;\n }\n });\n return best;\n}\n\n/**\n * Sets thumb `index` to `value`, keeping the values ordered: the thumb is\n * clamped between its neighbours (Base UI's default \"none\" collision\n * behaviour), `minSteps` steps apart.\n */\nexport function setThumb(\n values: number[],\n index: number,\n value: number,\n range: SliderRange,\n minSteps = 0,\n): number[] {\n const gap = minSteps * range.step;\n const lo = index > 0 ? values[index - 1] + gap : range.min;\n const hi = index < values.length - 1 ? values[index + 1] - gap : range.max;\n const next = values.slice();\n next[index] = clamp(snap(value, range), lo, hi);\n return next;\n}\n\nexport type SliderKey = \"ArrowUp\" | \"ArrowDown\" | \"ArrowLeft\" | \"ArrowRight\" | \"PageUp\" | \"PageDown\" | \"Home\" | \"End\";\n\n/**\n * The value a key press moves a thumb to (APG slider pattern).\n * `rtl` flips Left/Right for horizontal sliders. Shift+Arrow moves by `largeStep`.\n */\nexport function keyValue(\n key: string,\n current: number,\n range: SliderRange & { largeStep: number },\n opts: { shift?: boolean; rtl?: boolean; vertical?: boolean } = {},\n): number | null {\n const small = opts.shift ? range.largeStep : range.step;\n const flip = opts.rtl && !opts.vertical ? -1 : 1;\n switch (key) {\n case \"ArrowUp\":\n return current + small;\n case \"ArrowDown\":\n return current - small;\n case \"ArrowRight\":\n return current + small * flip;\n case \"ArrowLeft\":\n return current - small * flip;\n case \"PageUp\":\n return current + range.largeStep;\n case \"PageDown\":\n return current - range.largeStep;\n case \"Home\":\n return range.min;\n case \"End\":\n return range.max;\n default:\n return null;\n }\n}\n\n/** Parses `value=\"25\"` or `value=\"25, 75\"` (the default value attribute). */\nexport function parseValues(attr: string | null | undefined, fallback: number): number[] {\n if (attr == null || attr.trim() === \"\") return [fallback];\n const out = attr\n .split(\",\")\n .map(s => Number(s.trim()))\n .filter(n => Number.isFinite(n));\n return out.length ? out.sort((a, b) => a - b) : [fallback];\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { directionOf } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement } from \"../../core/form-control\";\nimport { ensureId } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { closestThumb, fraction, keyValue, parseValues, setThumb, valueAt, type SliderRange } from \"./slider-math\";\n\nexport type SliderOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # Slider: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Slider defaultValue min max>` → Base UI\n * ```\n * Slider.Root div[data-slot=slider][data-orientation]\n * Control div\n * Track div[data-slot=slider-track]\n * Indicator div[data-slot=slider-range]\n * Thumb ×n div[data-slot=slider-thumb] > input[type=range] (the input carries role=slider)\n * ```\n * pont2:\n * ```\n * pont2-prim-slider ← root, form-associated (submits name=value per thumb)\n * div[data-slot=slider-control]\n * div[data-slot=slider-track] > div[data-slot=slider-range]\n * div[data-slot=slider-thumb][role=slider] ×n\n * ```\n * The thumbs carry `role=\"slider\"` and the ARIA values themselves, so Base UI's\n * per-thumb hidden `<input type=\"range\">` is not needed (one node fewer per\n * thumb); the root is the form control. Everything inside the root is\n * rendered by the slider (shadcn's Slider takes no children either).\n *\n * Single value: `value=\"40\"`. Range: `value=\"20, 80\"` (one thumb per value).\n * With no value, one thumb at `min`. Thumbs never cross.\n *\n * Keyboard (APG / Base UI): ←/↓ −step, →/↑ +step (← and → swap in RTL),\n * Shift+arrow and PageUp/PageDown ±largeStep, Home/End min/max.\n * Pointer: press anywhere on the control moves the closest thumb, then drags.\n *\n * @tag pont2-prim-slider\n * @attr value - Default value(s), comma-separated for a range. `.value` / `.values` are live.\n * @attr min, max, step, large-step, min-steps-between-values\n * @attr orientation - horizontal (default) | vertical\n * @attr name, disabled, readonly\n * @fires input - While the value changes (keyboard or drag).\n * @fires change - When a change is committed (key press, pointer release). Base UI `onValueCommitted`.\n */\nexport class Slider extends FormControlElement {\n static override identity = \"slider\";\n static override slotName = \"slider\";\n\n static override properties: PropertyDeclarations = {\n defaultValue: { type: String, attribute: \"value\" },\n min: { type: Number },\n max: { type: Number },\n step: { type: Number },\n largeStep: { type: Number, attribute: \"large-step\" },\n minStepsBetweenValues: { type: Number, attribute: \"min-steps-between-values\" },\n orientation: { type: String, reflect: true },\n values: { attribute: false },\n activeThumb: { state: true },\n };\n\n declare defaultValue: string | null;\n declare min: number;\n declare max: number;\n declare step: number;\n declare largeStep: number;\n declare minStepsBetweenValues: number;\n declare orientation: SliderOrientation;\n /** Live values, ascending; one per thumb. */\n declare values: number[];\n declare protected activeThumb: number;\n\n private dirty = false;\n private dragging = -1;\n\n constructor() {\n super();\n this.defaultValue = null;\n this.min = 0;\n this.max = 100;\n this.step = 1;\n this.largeStep = 10;\n this.minStepsBetweenValues = 0;\n this.orientation = \"horizontal\";\n this.values = [0];\n this.activeThumb = -1;\n }\n\n /** A number for a single-thumb slider, an array for a range (Base UI's shape). */\n get value(): number | number[] {\n return this.values.length === 1 ? this.values[0] : this.values.slice();\n }\n set value(v: number | number[]) {\n this.dirty = true;\n const arr = Array.isArray(v) ? v.slice() : [v];\n this.values = arr.map(n => setThumb([n], 0, n, this.range)[0]).sort((a, b) => a - b);\n }\n\n private get range(): SliderRange {\n return { min: this.min, max: this.max, step: this.step };\n }\n\n protected override get hostFocusable(): boolean {\n return false;\n }\n\n protected override get validationAnchor(): HTMLElement | undefined {\n return this.thumbs[0];\n }\n\n private get thumbs(): HTMLElement[] {\n return Array.from(this.querySelectorAll<HTMLElement>(\":scope > [data-slot=slider-control] > [data-slot=slider-thumb]\"));\n }\n\n private get control(): HTMLElement | null {\n return this.querySelector(\":scope > [data-slot=slider-control]\");\n }\n\n /* -------------------------------------------------------------- */\n /* Form */\n /* -------------------------------------------------------------- */\n\n protected formValue() {\n if (!this.name) return null;\n if (this.values.length === 1) return String(this.values[0]);\n const fd = new FormData();\n for (const v of this.values) fd.append(this.name, String(v));\n return fd;\n }\n\n protected resetToDefault(): void {\n this.dirty = false;\n this.values = this.initialValues();\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state === \"string\") this.value = Number(state);\n else if (state instanceof FormData) this.value = state.getAll(this.name).map(Number);\n }\n\n private initialValues(): number[] {\n return parseValues(this.defaultValue, this.min).map(v => setThumb([v], 0, v, this.range)[0]);\n }\n\n /* -------------------------------------------------------------- */\n /* Interaction */\n /* -------------------------------------------------------------- */\n\n private commit(index: number, raw: number, final: boolean): void {\n const next = setThumb(this.values, index, raw, this.range, this.minStepsBetweenValues);\n const changed = next[index] !== this.values[index];\n if (changed) {\n this.dirty = true;\n this.values = next;\n fireNative(this, \"input\");\n }\n if (final && (changed || this.dragging >= 0)) fireNative(this, \"change\");\n }\n\n private onKeyDown = (e: KeyboardEvent, index: number) => {\n if (this.isDisabled || this.readOnly) return;\n const vertical = this.orientation === \"vertical\";\n const v = keyValue(e.key, this.values[index], { ...this.range, largeStep: this.largeStep }, {\n shift: e.shiftKey,\n rtl: directionOf(this) === \"rtl\",\n vertical,\n });\n if (v == null) return;\n e.preventDefault();\n this.commit(index, v, true);\n };\n\n private valueFromPointer(e: PointerEvent): number {\n const rect = this.control!.getBoundingClientRect();\n const thumb = this.thumbs[0]?.getBoundingClientRect();\n // thumbAlignment=\"edge\": thumbs travel within the control, inset by half a thumb at each end.\n if (this.orientation === \"vertical\") {\n const t = thumb?.height ?? 0;\n return valueAt(1 - (e.clientY - rect.top - t / 2) / Math.max(1, rect.height - t), this.range);\n }\n const t = thumb?.width ?? 0;\n let f = (e.clientX - rect.left - t / 2) / Math.max(1, rect.width - t);\n if (directionOf(this) === \"rtl\") f = 1 - f;\n return valueAt(f, this.range);\n }\n\n private onPointerDown = (e: PointerEvent) => {\n if (this.isDisabled || this.readOnly || e.button !== 0) return;\n const control = this.control!;\n const raw = this.valueFromPointer(e);\n const onThumb = (e.target as HTMLElement).closest?.(\"[data-slot=slider-thumb]\") as HTMLElement | null;\n const index = onThumb ? this.thumbs.indexOf(onThumb) : closestThumb(this.values, raw);\n this.dragging = index;\n this.activeThumb = index;\n control.setPointerCapture(e.pointerId);\n e.preventDefault();\n this.thumbs[index]?.focus({ preventScroll: true });\n if (!onThumb) this.commit(index, raw, false);\n };\n\n private onPointerMove = (e: PointerEvent) => {\n if (this.dragging < 0) return;\n this.commit(this.dragging, this.valueFromPointer(e), false);\n };\n\n private onPointerUp = (e: PointerEvent) => {\n if (this.dragging < 0) return;\n this.control?.releasePointerCapture(e.pointerId);\n this.commit(this.dragging, this.values[this.dragging], true);\n this.dragging = -1;\n this.activeThumb = -1;\n };\n\n /* -------------------------------------------------------------- */\n /* Render */\n /* -------------------------------------------------------------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n if (!this.dirty && (changed.has(\"defaultValue\") || changed.has(\"min\") || changed.has(\"max\") || !this.hasUpdated)) {\n this.values = this.initialValues();\n }\n this.setData(\"orientation\", this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\");\n this.setData(\"dragging\", this.dragging >= 0);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // Label the thumbs: <label for=\"slider-id\"> labels the root (it is form-associated);\n // the thumbs, which hold the focus, are labelled by the same elements.\n const labels = Array.from(this.labels) as HTMLElement[];\n const ids = labels.map(l => ensureId(l, \"slider-label\")).join(\" \");\n for (const t of this.thumbs) {\n if (ids) t.setAttribute(\"aria-labelledby\", ids);\n else t.removeAttribute(\"aria-labelledby\");\n }\n }\n\n override render() {\n const vertical = this.orientation === \"vertical\";\n const o = vertical ? \"vertical\" : \"horizontal\";\n const disabled = this.isDisabled;\n const fr = this.values.map(v => fraction(v, this.range));\n const thumbPos = (f: number) => `calc(${f} * (100% - var(--_pont2-slider-thumb)))`;\n const start = this.values.length > 1 ? fr[0] : 0;\n const end = fr[fr.length - 1];\n // Range: between thumb centres; single: from the start to the thumb centre.\n const rangeStyle = vertical\n ? { bottom: this.values.length > 1 ? `calc(${thumbPos(start)} + var(--_pont2-slider-thumb) / 2)` : \"0\", top: `calc(100% - ${thumbPos(end)} - var(--_pont2-slider-thumb) / 2)` }\n : { insetInlineStart: this.values.length > 1 ? `calc(${thumbPos(start)} + var(--_pont2-slider-thumb) / 2)` : \"0\", insetInlineEnd: `calc(100% - ${thumbPos(end)} - var(--_pont2-slider-thumb) / 2)` };\n const label = this.getAttribute(\"aria-label\");\n const names = this.values.length === 2 ? [\"Minimum\", \"Maximum\"] : [];\n\n return html`<div\n data-pont2-slider-control\n data-slot=\"slider-control\"\n data-orientation=${o}\n ?data-disabled=${disabled}\n @pointerdown=${this.onPointerDown}\n @pointermove=${this.onPointerMove}\n @pointerup=${this.onPointerUp}\n @pointercancel=${this.onPointerUp}\n >\n <div data-pont2-slider-track data-slot=\"slider-track\" data-orientation=${o} ?data-disabled=${disabled}>\n <div data-pont2-slider-range data-slot=\"slider-range\" data-orientation=${o} ?data-disabled=${disabled} style=${styleMap(rangeStyle)}></div>\n </div>\n ${repeat(\n this.values,\n (_v, i) => i,\n (v, i) => html`<div\n data-pont2-slider-thumb\n data-slot=\"slider-thumb\"\n data-index=${i}\n data-orientation=${o}\n ?data-disabled=${disabled}\n ?data-dragging=${this.activeThumb === i}\n role=\"slider\"\n tabindex=${disabled ? -1 : 0}\n aria-valuemin=${this.min}\n aria-valuemax=${this.max}\n aria-valuenow=${v}\n aria-orientation=${o}\n aria-disabled=${disabled ? \"true\" : \"false\"}\n aria-label=${label ? (names[i] ? `${label} ${names[i].toLowerCase()}` : label) : (names[i] ?? nothing)}\n style=${styleMap(vertical ? { bottom: thumbPos(fr[i]) } : { insetInlineStart: thumbPos(fr[i]) })}\n @keydown=${(e: KeyboardEvent) => this.onKeyDown(e, i)}\n ></div>`,\n )}\n </div>`;\n }\n}\n\ndefine(\"pont2-prim-slider\", Slider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-slider\": Slider;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { define } from \"../../core/names\";\n\nexport type SwitchSize = \"default\" | \"sm\";\n\n/**\n * # Switch: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Switch size>` → Base UI `<Switch.Root>` (`<span role=\"switch\">`\n * plus a hidden `<input type=\"checkbox\">`) > `<Switch.Thumb>` (`<span>`).\n *\n * pont2: the host **is** the `role=\"switch\"` root and a form-associated\n * custom element (no hidden input); it renders only the thumb.\n *\n * ```\n * shadcn/Base UI: span[role=switch][data-slot=switch] > span[data-slot=switch-thumb] + input[hidden]\n * pont2: pont2-prim-switch > span[data-slot=switch-thumb]\n * ```\n *\n * State attributes (Base UI): `data-checked` | `data-unchecked`, `data-disabled`,\n * `data-readonly`, `data-required`, on the root and the thumb. `data-size`\n * is shadcn's.\n *\n * @tag pont2-prim-switch\n * @attr checked - Initial state (`defaultChecked`); `.checked` is the live state.\n * @attr size - default | sm\n * @attr name, value, unchecked-value, disabled, required, readonly\n * @fires input - The state changed through interaction.\n * @fires change - Same moment as `input`, like a native checkbox.\n */\nexport class Switch extends FormControlElement {\n static override identity = \"switch\";\n static override slotName = \"switch\";\n static override role = \"switch\";\n\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean },\n size: { type: String, reflect: true },\n value: { type: String },\n uncheckedValue: { type: String, attribute: \"unchecked-value\" },\n };\n\n declare checked: boolean;\n declare size: SwitchSize;\n declare value: string;\n declare uncheckedValue: string | undefined;\n\n constructor() {\n super();\n this.checked = false;\n this.size = \"default\";\n this.value = \"on\";\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"keyup\", this.onKeyUp);\n }\n\n /** Toggle as if the user clicked (fires input/change). */\n toggle(): void {\n if (this.isDisabled || this.readOnly) return;\n this.checked = !this.checked;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected formValue() {\n return this.checked ? this.value : (this.uncheckedValue ?? null);\n }\n\n protected resetToDefault(): void {\n this.checked = this.hasAttribute(\"checked\");\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n this.checked = state === this.value;\n }\n\n protected override validate(): ValidityResult | null {\n return this.required && !this.checked\n ? { flags: { valueMissing: true }, message: \"Please turn this on if you want to proceed.\" }\n : null;\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled || this.readOnly) {\n e.preventDefault();\n return;\n }\n this.toggle();\n };\n\n // Base UI's switch behaves like a button: Enter activates on keydown, Space on keyup.\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this) return;\n if (e.key === \" \") e.preventDefault();\n if (e.key === \"Enter\") {\n e.preventDefault();\n this.click();\n }\n };\n private onKeyUp = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) this.click();\n };\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n this.setData(\"size\", this.size === \"sm\" ? \"sm\" : \"default\");\n this.setState(\"checked\", this.checked);\n }\n\n override render() {\n return html`<span\n data-pont2-switch-thumb\n data-slot=\"switch-thumb\"\n ?data-checked=${this.checked}\n ?data-unchecked=${!this.checked}\n ?data-disabled=${this.isDisabled}\n ></span>`;\n }\n}\n\ndefine(\"pont2-prim-switch\", Switch);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-switch\": Switch;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { RovingFocusController, type Orientation } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\n\nexport type TabsOrientation = \"horizontal\" | \"vertical\";\nexport type TabsListVariant = \"default\" | \"line\";\ntype ActivationDirection = \"left\" | \"right\" | \"up\" | \"down\" | \"none\";\n\nconst ROOT = sel(\"tabs\");\nconst TRIGGER = sel(\"tabs-trigger\");\nconst PANEL = sel(\"tabs-content\");\n\n/**\n * Wires an IDREF relation through ElementInternals when the engine supports\n * element reflection there, so no author-facing attribute is written; falls\n * back to the plain attribute (with generated ids) otherwise.\n */\nfunction relate(internals: ElementInternals, host: HTMLElement, prop: \"ariaControlsElements\" | \"ariaLabelledByElements\", attr: string, targets: Element[]) {\n if (prop in ElementInternals.prototype) {\n (internals as unknown as Record<string, Element[] | null>)[prop] = targets.length ? targets : null;\n } else if (targets.length) {\n host.setAttribute(attr, targets.map(t => ensureId(t, \"tabs\")).join(\" \"));\n } else {\n host.removeAttribute(attr);\n }\n}\n\n/**\n * # Tabs, TabsList, TabsTrigger, TabsContent: Tier 2 (widgets)\n *\n * shadcn: `<Tabs>` → Base UI `<Tabs.Root>` (div) > `<Tabs.List>` (div[role=tablist])\n * > `<Tabs.Tab>` (button[role=tab]) …, and `<Tabs.Panel>` (div[role=tabpanel]).\n *\n * pont2: every part is host-as-root, written by the author and never moved:\n * ```\n * pont2-prim-tabs[data-orientation]\n * pont2-prim-tabs-list[role=tablist][data-variant]\n * pont2-prim-tabs-trigger[role=tab][value] ×n (data-active on the active one)\n * pont2-prim-tabs-content[role=tabpanel][value] ×n (hidden unless active)\n * ```\n * The root owns the value; triggers and panels are matched by `value`.\n * ARIA relations (`aria-controls`, `aria-labelledby`) are wired through\n * ElementInternals, so the author's markup is not rewritten.\n *\n * Keyboard (Base UI / APG): the list is one tab stop (roving tabindex);\n * arrows along the orientation move focus (wrapping), Home/End jump, and\n * Enter/Space activate. With `activate-on-focus` on the list, moving focus\n * also activates (Base UI default: off).\n *\n * @tag pont2-prim-tabs\n * @attr value - The default active tab value; `.value` is live. Defaults to the first enabled trigger.\n * @attr orientation - horizontal (default) | vertical\n * @fires input, change - The active tab changed through interaction.\n */\nexport class Tabs extends HostElement {\n static override identity = \"tabs\";\n static override slotName = \"tabs\";\n\n static override properties: PropertyDeclarations = {\n defaultValue: { type: String, attribute: \"value\" },\n orientation: { type: String, reflect: true },\n current: { state: true },\n };\n\n declare defaultValue: string | null;\n declare orientation: TabsOrientation;\n declare protected current: string;\n\n /** The active tab's value. Setting it activates that tab without firing events. */\n get value(): string {\n return this.current;\n }\n set value(v: string) {\n this.dirty = true;\n this.current = v;\n }\n\n private dirty = false;\n private direction: ActivationDirection = \"none\";\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.defaultValue = null;\n this.orientation = \"horizontal\";\n this.current = \"\";\n }\n\n get triggers(): TabsTrigger[] {\n return this.own<TabsTrigger>(TRIGGER);\n }\n get panels(): TabsContent[] {\n return this.own<TabsContent>(PANEL);\n }\n get lists(): TabsList[] {\n return this.own<TabsList>(sel(\"tabs-list\"));\n }\n\n private own<T extends Element>(sel: string): T[] {\n return Array.from(this.querySelectorAll<T>(sel)).filter(el => el.closest(ROOT) === this);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: [\"value\", \"disabled\"] });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n /** Activate a trigger as the user would (fires input/change). */\n select(trigger: TabsTrigger): void {\n if (trigger.disabled || trigger.value === this.value) return;\n const triggers = this.triggers;\n const from = triggers.findIndex(t => t.value === this.value);\n const to = triggers.indexOf(trigger);\n const vertical = this.orientation === \"vertical\";\n this.direction = from < 0 || to === from ? \"none\" : to > from ? (vertical ? \"down\" : \"right\") : vertical ? \"up\" : \"left\";\n this.value = trigger.value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) {\n this.current = this.defaultValue ?? \"\";\n }\n }\n\n protected override updated(): void {\n const o = this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n const triggers = this.triggers;\n const panels = this.panels;\n // No (matching) value: fall back to the first enabled trigger, like Base UI.\n let value = this.current;\n if (!triggers.some(t => t.getAttribute(\"value\") === value)) {\n value = triggers.find(t => !t.hasAttribute(\"disabled\"))?.getAttribute(\"value\") ?? \"\";\n }\n\n this.setData(\"orientation\", o);\n this.setData(\"activation-direction\", this.direction);\n // Parts that have not upgraded yet are skipped; they request an update on connect.\n const ready = (el: Element) => typeof (el as TabsTrigger).sync === \"function\";\n for (const list of this.lists) if (ready(list)) list.sync(o, this.direction);\n\n let active: TabsTrigger | null = null;\n for (const t of triggers) {\n const on = t.getAttribute(\"value\") === value;\n const panel = panels.find(p => p.getAttribute(\"value\") === t.getAttribute(\"value\")) ?? null;\n if (ready(t)) t.sync(on, o, panel);\n if (on) active = t;\n }\n for (const p of panels) {\n const trigger = triggers.find(t => t.getAttribute(\"value\") === p.getAttribute(\"value\")) ?? null;\n if (ready(p)) p.sync(p.getAttribute(\"value\") === value, o, trigger);\n }\n for (const list of this.lists) if (ready(list)) list.focusSync(active);\n }\n}\n\n/**\n * @tag pont2-prim-tabs-list\n * @attr variant - default | line\n * @attr activate-on-focus - Arrow-key focus also activates the tab (Base UI `activateOnFocus`).\n * @attr loop - Set `loop=\"false\"` to stop focus wrapping (Base UI `loopFocus`).\n */\nexport class TabsList extends HostElement {\n static override identity = \"tabs-list\";\n static override slotName = \"tabs-list\";\n static override role = \"tablist\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n activateOnFocus: { type: Boolean, attribute: \"activate-on-focus\" },\n loop: { type: String },\n };\n\n declare variant: TabsListVariant;\n declare activateOnFocus: boolean;\n declare loop: string | null;\n\n private orientation: Orientation = \"horizontal\";\n\n private roving = new RovingFocusController(this, {\n items: () => this.root?.triggers.filter(t => this.contains(t)) ?? [],\n orientation: () => this.orientation,\n loop: () => this.loop !== \"false\",\n onNavigate: item => {\n if (this.activateOnFocus) this.root?.select(item as TabsTrigger);\n },\n });\n\n constructor() {\n super();\n this.variant = \"default\";\n this.activateOnFocus = false;\n this.loop = null;\n }\n\n get root(): Tabs | null {\n return this.closest(ROOT) as Tabs | null;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.root?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(orientation: TabsOrientation, direction: ActivationDirection): void {\n this.orientation = orientation;\n this.internals.ariaOrientation = orientation;\n this.setData(\"orientation\", orientation);\n this.setData(\"activation-direction\", direction);\n }\n\n /** @internal Called by the root. */\n focusSync(active: HTMLElement | null): void {\n // Keep the roving stop on the focused tab while the user is navigating.\n const focused = this.root?.triggers.find(t => t === document.activeElement);\n this.roving.sync(focused ?? active);\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant === \"line\" ? \"line\" : \"default\");\n }\n}\n\n/**\n * @tag pont2-prim-tabs-trigger\n * @attr value - Identifies the tab and its panel.\n * @attr disabled\n */\nexport class TabsTrigger extends HostElement {\n static override identity = \"tabs-trigger\";\n static override slotName = \"tabs-trigger\";\n static override role = \"tab\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n }\n\n get root(): Tabs | null {\n return this.closest(ROOT) as Tabs | null;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.root?.requestUpdate();\n }\n\n private onClick = () => {\n if (!this.disabled) this.root?.select(this);\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this || this.disabled) return;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n this.root?.select(this);\n }\n };\n\n /** @internal Called by the root. */\n sync(active: boolean, orientation: TabsOrientation, panel: Element | null): void {\n this.internals.ariaSelected = String(active);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n relate(this.internals, this, \"ariaControlsElements\", \"aria-controls\", panel ? [panel] : []);\n this.setData(\"active\", active);\n this.setData(\"disabled\", this.disabled);\n this.setData(\"orientation\", orientation);\n this.setState(\"active\", active);\n }\n}\n\n/**\n * @tag pont2-prim-tabs-content\n * @attr value - The trigger value this panel belongs to.\n */\nexport class TabsContent extends HostElement {\n static override identity = \"tabs-content\";\n static override slotName = \"tabs-content\";\n static override role = \"tabpanel\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n };\n\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as Tabs | null)?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(active: boolean, orientation: TabsOrientation, trigger: Element | null): void {\n relate(this.internals, this, \"ariaLabelledByElements\", \"aria-labelledby\", trigger ? [trigger] : []);\n // Base UI unmounts inactive panels; pont2 never removes author children, so it hides them.\n this.hidden = !active;\n this.setData(\"hidden\", !active);\n this.setData(\"orientation\", orientation);\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = 0;\n }\n}\n\ndefine(\"pont2-prim-tabs\", Tabs);\ndefine(\"pont2-prim-tabs-list\", TabsList);\ndefine(\"pont2-prim-tabs-trigger\", TabsTrigger);\ndefine(\"pont2-prim-tabs-content\", TabsContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-tabs\": Tabs;\n \"pont2-prim-tabs-list\": TabsList;\n \"pont2-prim-tabs-trigger\": TabsTrigger;\n \"pont2-prim-tabs-content\": TabsContent;\n }\n}\n","/**\n * Pure anchored-positioning maths (no DOM). The same model as Floating UI /\n * Base UI's `<Positioner>`: place the floating box on a `side` of the anchor,\n * `align` it along that side, then `flip` to the opposite side and `shift`\n * along the cross axis to stay inside the viewport minus `collisionPadding`.\n *\n * Unit-tested in node: position.test.ts.\n */\n\nexport type PhysicalSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/** Base UI sides: physical, or logical (`inline-start`/`inline-end` follow `dir`). */\nexport type Side = PhysicalSide | \"inline-start\" | \"inline-end\";\nexport type Align = \"start\" | \"center\" | \"end\";\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface PositionInput {\n anchor: Rect;\n floating: Size;\n viewport: Rect;\n side?: Side;\n align?: Align;\n /** Gap between anchor and floating box, on the main axis (px). */\n sideOffset?: number;\n /** Offset along the cross axis (px). Positive moves towards `end` for start/center, towards `start` for end. */\n alignOffset?: number;\n /** Minimum distance kept from the viewport edges (px). Base UI default: 5. */\n collisionPadding?: number;\n flip?: boolean;\n shift?: boolean;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport interface PositionResult {\n x: number;\n y: number;\n /** The side actually used, in the vocabulary it was requested in (logical stays logical). */\n side: Side;\n physicalSide: PhysicalSide;\n align: Align;\n /** Space between the floating box's anchored edge and the viewport edge (Base UI `--available-*`). */\n availableWidth: number;\n availableHeight: number;\n /** `--transform-origin`: the point of the anchor the box grows from. */\n transformOrigin: string;\n}\n\nconst OPPOSITE: Record<PhysicalSide, PhysicalSide> = { top: \"bottom\", bottom: \"top\", left: \"right\", right: \"left\" };\n\nexport function toPhysical(side: Side, dir: \"ltr\" | \"rtl\"): PhysicalSide {\n if (side === \"inline-start\") return dir === \"rtl\" ? \"right\" : \"left\";\n if (side === \"inline-end\") return dir === \"rtl\" ? \"left\" : \"right\";\n return side;\n}\n\nfunction toRequestedVocabulary(physical: PhysicalSide, requested: Side, dir: \"ltr\" | \"rtl\"): Side {\n if (requested !== \"inline-start\" && requested !== \"inline-end\") return physical;\n const start = dir === \"rtl\" ? \"right\" : \"left\";\n return physical === start ? \"inline-start\" : \"inline-end\";\n}\n\nconst isVertical = (s: PhysicalSide) => s === \"top\" || s === \"bottom\";\n\n/** Free space between the anchor (plus offset) and the padded viewport edge on `side`. */\nexport function spaceOn(side: PhysicalSide, anchor: Rect, viewport: Rect, offset: number, pad: number): number {\n switch (side) {\n case \"bottom\":\n return viewport.y + viewport.height - pad - (anchor.y + anchor.height + offset);\n case \"top\":\n return anchor.y - offset - (viewport.y + pad);\n case \"right\":\n return viewport.x + viewport.width - pad - (anchor.x + anchor.width + offset);\n case \"left\":\n return anchor.x - offset - (viewport.x + pad);\n }\n}\n\nexport function computePosition(input: PositionInput): PositionResult {\n const {\n anchor,\n floating,\n viewport,\n side: requested = \"bottom\",\n align = \"center\",\n sideOffset = 0,\n alignOffset = 0,\n collisionPadding = 5,\n flip = true,\n shift = true,\n dir = \"ltr\",\n } = input;\n const pad = collisionPadding;\n\n let side = toPhysical(requested, dir);\n\n // --- flip ------------------------------------------------------------\n if (flip) {\n const need = isVertical(side) ? floating.height : floating.width;\n const here = spaceOn(side, anchor, viewport, sideOffset, pad);\n const there = spaceOn(OPPOSITE[side], anchor, viewport, sideOffset, pad);\n if (here < need && there > here) side = OPPOSITE[side];\n }\n\n // --- main axis -------------------------------------------------------\n let x = 0;\n let y = 0;\n switch (side) {\n case \"bottom\":\n y = anchor.y + anchor.height + sideOffset;\n break;\n case \"top\":\n y = anchor.y - floating.height - sideOffset;\n break;\n case \"right\":\n x = anchor.x + anchor.width + sideOffset;\n break;\n case \"left\":\n x = anchor.x - floating.width - sideOffset;\n break;\n }\n\n // --- cross axis (align) ---------------------------------------------\n if (isVertical(side)) {\n // `start` is the inline-start edge, so it mirrors in RTL.\n const startEdge = dir === \"rtl\" ? anchor.x + anchor.width - floating.width : anchor.x;\n const endEdge = dir === \"rtl\" ? anchor.x : anchor.x + anchor.width - floating.width;\n const sign = dir === \"rtl\" ? -1 : 1;\n if (align === \"start\") x = startEdge + sign * alignOffset;\n else if (align === \"end\") x = endEdge - sign * alignOffset;\n else x = anchor.x + (anchor.width - floating.width) / 2 + sign * alignOffset;\n } else {\n if (align === \"start\") y = anchor.y + alignOffset;\n else if (align === \"end\") y = anchor.y + anchor.height - floating.height - alignOffset;\n else y = anchor.y + (anchor.height - floating.height) / 2 + alignOffset;\n }\n\n // --- shift (keep inside the padded viewport on the cross axis) -------\n if (shift) {\n if (isVertical(side)) {\n const min = viewport.x + pad;\n const max = viewport.x + viewport.width - pad - floating.width;\n x = max < min ? min : Math.min(Math.max(x, min), max);\n } else {\n const min = viewport.y + pad;\n const max = viewport.y + viewport.height - pad - floating.height;\n y = max < min ? min : Math.min(Math.max(y, min), max);\n }\n }\n\n // --- available space (Base UI --available-width / --available-height) -\n const mainSpace = Math.max(0, spaceOn(side, anchor, viewport, sideOffset, pad));\n const availableHeight = isVertical(side) ? mainSpace : Math.max(0, viewport.height - 2 * pad);\n const availableWidth = isVertical(side) ? Math.max(0, viewport.width - 2 * pad) : mainSpace;\n\n // --- transform origin: the anchor edge the box grows out of -----------\n const ax = anchor.x + anchor.width / 2 - x;\n const ay = anchor.y + anchor.height / 2 - y;\n const transformOrigin =\n side === \"bottom\"\n ? `${round(ax)}px ${-sideOffset}px`\n : side === \"top\"\n ? `${round(ax)}px ${floating.height + sideOffset}px`\n : side === \"right\"\n ? `${-sideOffset}px ${round(ay)}px`\n : `${floating.width + sideOffset}px ${round(ay)}px`;\n\n return {\n x: round(x),\n y: round(y),\n side: toRequestedVocabulary(side, requested, dir),\n physicalSide: side,\n align,\n availableWidth: round(availableWidth),\n availableHeight: round(availableHeight),\n transformOrigin,\n };\n}\n\n/**\n * Base UI Select's `alignItemWithTrigger`: place the popup so the selected\n * item sits exactly over the trigger (macOS-style). Returns `null` when that\n * is impossible inside the padded viewport, so the caller falls back to\n * normal side positioning (Base UI does the same).\n */\nexport function alignItemWithAnchor(input: {\n anchor: Rect;\n floating: Size;\n viewport: Rect;\n /** Offset of the item's top edge from the floating box's top edge (scroll already subtracted). */\n itemTop: number;\n itemHeight: number;\n collisionPadding?: number;\n}): { x: number; y: number } | null {\n const pad = input.collisionPadding ?? 5;\n const { anchor, floating, viewport } = input;\n const y = anchor.y + anchor.height / 2 - (input.itemTop + input.itemHeight / 2);\n const min = viewport.y + pad;\n const max = viewport.y + viewport.height - pad - floating.height;\n if (max < min) return null;\n if (y < min || y > max) return null;\n return { x: round(anchor.x), y: round(y) };\n}\n\nconst round = (n: number) => Math.round(n * 100) / 100;\n","import { directionOf } from \"../controllers/roving-focus\";\nimport { alignItemWithAnchor, computePosition, type Align, type Rect, type Side } from \"./position\";\n\nexport interface AnchoredOptions {\n side: Side;\n align: Align;\n sideOffset: number;\n alignOffset: number;\n collisionPadding: number;\n /** Select's `alignItemWithTrigger`: the item to lay over the anchor, if any. */\n alignItem?: HTMLElement | null;\n}\n\n/**\n * Keeps a floating element (a `popover` in the top layer, so `position:\n * fixed` against the viewport) attached to an anchor element.\n *\n * It only *writes CSS custom properties and data attributes* on the floating\n * element; the stylesheet turns them into `left`/`top`. Base UI's variables\n * are written under pont2's namespace (read by pont2 CSS) and also verbatim,\n * so shadcn classes (`max-h-(--available-height)`, `w-(--anchor-width)`,\n * `origin-(--transform-origin)`) port unchanged into app CSS:\n *\n * | Written | Meaning |\n * |-------------------------|--------------------------------------------|\n * | `--pont2-popup-x/y` | viewport position of the box (px) |\n * | `--pont2-anchor-width/height` (+ `--anchor-*`) | size of the anchor |\n * | `--pont2-available-width/height` (+ `--available-*`) | room left before the collision padding |\n * | `--pont2-transform-origin` (+ `--transform-origin`) | the anchor point the box grows from |\n * | `--pont2-arrow-x/y` | anchor centre relative to the box (for arrows) |\n * | `data-side`, `data-align` | the side/alignment actually used (after flip) |\n *\n * Updates are batched to one per animation frame and re-run on scroll (any\n * ancestor, captured), resize, and size changes of either element.\n */\nexport class AnchoredPositioner {\n private frame = 0;\n private running = false;\n private ro?: ResizeObserver;\n private observedAnchor: Element | null = null;\n\n constructor(\n private readonly floating: HTMLElement,\n private readonly anchor: () => Element | null,\n private readonly options: () => AnchoredOptions,\n ) {}\n\n start(): void {\n if (this.running) {\n this.update();\n return;\n }\n this.running = true;\n window.addEventListener(\"scroll\", this.schedule, { capture: true, passive: true });\n window.addEventListener(\"resize\", this.schedule, { passive: true });\n this.ro = new ResizeObserver(this.schedule);\n this.ro.observe(this.floating);\n this.observeAnchor();\n this.update();\n }\n\n stop(): void {\n if (!this.running) return;\n this.running = false;\n cancelAnimationFrame(this.frame);\n window.removeEventListener(\"scroll\", this.schedule, { capture: true });\n window.removeEventListener(\"resize\", this.schedule);\n this.ro?.disconnect();\n this.observedAnchor = null;\n }\n\n private observeAnchor() {\n const a = this.anchor();\n if (a && a !== this.observedAnchor) {\n this.ro?.observe(a);\n this.observedAnchor = a;\n }\n }\n\n private schedule = () => {\n if (!this.running) return;\n cancelAnimationFrame(this.frame);\n this.frame = requestAnimationFrame(() => this.update());\n };\n\n /** Measure and write synchronously (also called right after showPopover, before first paint). */\n update(): void {\n const anchorEl = this.anchor();\n if (!anchorEl || !this.floating.isConnected) return;\n this.observeAnchor();\n\n const a = anchorEl.getBoundingClientRect();\n const anchor: Rect = { x: a.left, y: a.top, width: a.width, height: a.height };\n // offsetWidth/Height ignore transforms, so a running zoom-in animation\n // does not feed back into the measurement.\n const floating = { width: this.floating.offsetWidth, height: this.floating.offsetHeight };\n const viewport: Rect = {\n x: 0,\n y: 0,\n width: document.documentElement.clientWidth,\n height: window.innerHeight,\n };\n const o = this.options();\n const style = this.floating.style;\n // Each Base UI variable is written twice: `--pont2-<name>` (what pont2's\n // own CSS reads, per the --pont2- namespace rule) and Base UI's verbatim\n // `--<name>`, so shadcn classes such as `max-h-(--available-height)` port\n // unchanged into consumer CSS.\n const set = (name: string, value: string) => {\n style.setProperty(`--pont2-${name}`, value);\n style.setProperty(`--${name}`, value);\n };\n set(\"anchor-width\", `${a.width}px`);\n set(\"anchor-height\", `${a.height}px`);\n\n if (o.alignItem) {\n const f = this.floating.getBoundingClientRect();\n const it = o.alignItem.getBoundingClientRect();\n const aligned = alignItemWithAnchor({\n anchor,\n floating,\n viewport,\n itemTop: it.top - f.top,\n itemHeight: it.height,\n collisionPadding: o.collisionPadding,\n });\n if (aligned) {\n style.setProperty(\"--pont2-popup-x\", `${aligned.x}px`);\n style.setProperty(\"--pont2-popup-y\", `${aligned.y}px`);\n set(\"available-height\", `${viewport.height - 2 * o.collisionPadding}px`);\n set(\"available-width\", `${viewport.width - 2 * o.collisionPadding}px`);\n set(\"transform-origin\", \"center\");\n this.floating.setAttribute(\"data-side\", \"none\");\n this.floating.setAttribute(\"data-align\", \"center\");\n return;\n }\n }\n\n const r = computePosition({\n anchor,\n floating,\n viewport,\n side: o.side,\n align: o.align,\n sideOffset: o.sideOffset,\n alignOffset: o.alignOffset,\n collisionPadding: o.collisionPadding,\n dir: directionOf(anchorEl),\n });\n style.setProperty(\"--pont2-popup-x\", `${r.x}px`);\n style.setProperty(\"--pont2-popup-y\", `${r.y}px`);\n set(\"available-width\", `${r.availableWidth}px`);\n set(\"available-height\", `${r.availableHeight}px`);\n set(\"transform-origin\", r.transformOrigin);\n style.setProperty(\"--pont2-arrow-x\", `${a.left + a.width / 2 - r.x}px`);\n style.setProperty(\"--pont2-arrow-y\", `${a.top + a.height / 2 - r.y}px`);\n if (this.floating.getAttribute(\"data-side\") !== r.side) this.floating.setAttribute(\"data-side\", r.side);\n if (this.floating.getAttribute(\"data-align\") !== r.align) this.floating.setAttribute(\"data-align\", r.align);\n }\n}\n","/**\n * List navigation and typeahead for popup lists (menus, select, combobox).\n *\n * Two focus models, as in Base UI:\n * - **real focus** (Menu, Select): the highlighted item *is* `document.activeElement`;\n * items carry `tabindex=\"-1\"` and `data-highlighted` follows focus;\n * - **virtual focus** (Combobox): focus stays in the `<input>`; the highlighted\n * item gets `data-highlighted` and the input points at it with\n * `aria-activedescendant`.\n *\n * Both share `moveIndex()` and `Typeahead`.\n */\n\nexport const isItemDisabled = (el: Element) =>\n el.hasAttribute(\"data-disabled\") || el.getAttribute(\"aria-disabled\") === \"true\";\n\nexport const isItemVisible = (el: HTMLElement) => !el.hidden && !el.closest(\"[hidden]\");\n\nexport type Move = \"next\" | \"prev\" | \"first\" | \"last\";\n\n/** Index of the next enabled item in `direction` from `current` (−1 = none yet). */\nexport function moveIndex(\n items: readonly Element[],\n current: number,\n move: Move,\n { loop = true, isDisabled = isItemDisabled }: { loop?: boolean; isDisabled?: (el: Element) => boolean } = {},\n): number {\n const n = items.length;\n if (!n) return -1;\n const ok = (i: number) => !isDisabled(items[i]);\n if (move === \"first\") {\n for (let i = 0; i < n; i++) if (ok(i)) return i;\n return -1;\n }\n if (move === \"last\") {\n for (let i = n - 1; i >= 0; i--) if (ok(i)) return i;\n return -1;\n }\n const step = move === \"next\" ? 1 : -1;\n if (current < 0) return moveIndex(items, -1, step === 1 ? \"first\" : \"last\", { loop, isDisabled });\n for (let k = 1; k <= n; k++) {\n let i = current + step * k;\n if (loop) i = (i + n) % n;\n else if (i < 0 || i >= n) return current;\n if (ok(i)) return i;\n }\n return current;\n}\n\n/** Keyboard key → move, for a vertical list. */\nexport function keyToMove(key: string): Move | null {\n switch (key) {\n case \"ArrowDown\":\n return \"next\";\n case \"ArrowUp\":\n return \"prev\";\n case \"Home\":\n return \"first\";\n case \"End\":\n return \"last\";\n default:\n return null;\n }\n}\n\n/**\n * Typeahead (APG): printable keys typed within 500ms build a prefix; the\n * first enabled item after the current one whose label starts with it wins.\n * Repeating one character cycles through items starting with it.\n */\nexport class Typeahead {\n private buffer = \"\";\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(private readonly timeout = 500) {}\n\n /** Whether a keyboard event is a typeahead character. */\n static isChar(e: KeyboardEvent): boolean {\n return e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && e.key !== \" \";\n }\n\n get active(): boolean {\n return this.buffer.length > 0;\n }\n\n match(\n key: string,\n items: readonly Element[],\n current: number,\n label: (el: Element) => string = el => el.textContent ?? \"\",\n ): number {\n clearTimeout(this.timer);\n this.timer = setTimeout(() => (this.buffer = \"\"), this.timeout);\n this.buffer += key.toLowerCase();\n\n const repeated = this.buffer.split(\"\").every(c => c === this.buffer[0]);\n const search = repeated ? this.buffer[0] : this.buffer;\n const n = items.length;\n const start = repeated || current < 0 ? current + 1 : current;\n for (let k = 0; k < n; k++) {\n const i = (start + k + n) % n;\n const el = items[i];\n if (isItemDisabled(el)) continue;\n if (label(el).trim().toLowerCase().startsWith(search)) return i;\n }\n return -1;\n }\n\n reset(): void {\n clearTimeout(this.timer);\n this.buffer = \"\";\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport type { OpenChangeReason } from \"../events\";\nimport { HostElement } from \"../host-element\";\nimport { AnchoredPositioner } from \"./anchored\";\nimport type { Align, Side } from \"./position\";\n\n/** Popups currently open, bottom → top. Escape and outside presses are resolved against it. */\nconst stack: PopupContent[] = [];\n\nlet globalListeners = false;\nfunction installGlobalListeners() {\n if (globalListeners) return;\n globalListeners = true;\n\n // Escape closes only the top-most popup (a submenu before its menu).\n document.addEventListener(\"keydown\", e => {\n if (e.key !== \"Escape\" || e.defaultPrevented) return;\n const top = stack.at(-1);\n if (!top) return;\n e.preventDefault();\n e.stopPropagation();\n top.requestClose(\"escape-key\");\n });\n\n // Outside press: captured on pointerdown, before focus moves (Base UI\n // dismisses on pointerdown for mouse too).\n document.addEventListener(\n \"pointerdown\",\n e => {\n const path = e.composedPath();\n for (const popup of [...stack].reverse()) {\n if (popup.containsPath(path)) break; // inside: this one and everything below stay\n popup.requestClose(\"outside-press\");\n }\n },\n true,\n );\n}\n\n/**\n * # PopupContent: base for every popup surface\n *\n * DropdownMenuContent, SelectContent, ComboboxContent, PopoverContent and\n * TooltipContent all extend it. The host **is** the popup (shadcn's\n * `data-slot=\"…-content\"` element); Base UI's separate `Portal` and\n * `Positioner` wrappers have no counterpart, because:\n *\n * - **Portal → the native Popover API.** The host carries `popover=\"manual\"`\n * and `showPopover()` lifts it into the browser's top layer: it escapes\n * `overflow: hidden` and stacking contexts *without moving the node*. It\n * stays exactly where the author wrote it, so React/Lit/server HTML keep\n * owning it, and it inherits CSS custom properties from its real ancestors.\n * - **Positioner → AnchoredPositioner**, which writes position variables on\n * this same element (see anchored.ts).\n *\n * Base UI DOM: Portal > Positioner div > Popup div[data-slot=…-content] > children\n * pont2 DOM: pont2-…-content[popover][data-slot=…-content] > children\n *\n * Open/close states are Base UI's: `data-open` / `data-closed`, plus\n * `data-starting-style` (first frame after opening) and `data-ending-style`\n * (while closing). On close the element stays in the top layer until its\n * CSS animations/transitions finish, then `hidePopover()` runs, so shadcn's\n * `animate-out` classes port as plain keyframes.\n *\n * The content never decides it is open; its root does. It *requests*\n * closing (Escape, outside press, Tab) through `onRequestClose`, which the\n * root turns into a cancelable `pont2-open-change` event.\n */\nexport abstract class PopupContent extends HostElement {\n static override identity = \"popup\";\n\n static override properties: PropertyDeclarations = {\n side: { type: String, reflect: false },\n align: { type: String, reflect: false },\n sideOffset: { type: Number, attribute: \"side-offset\" },\n alignOffset: { type: Number, attribute: \"align-offset\" },\n collisionPadding: { type: Number, attribute: \"collision-padding\" },\n };\n\n declare side: Side;\n declare align: Align;\n declare sideOffset: number;\n declare alignOffset: number;\n declare collisionPadding: number;\n\n /** Set by the root: asked to close for `reason`. */\n onRequestClose?: (reason: OpenChangeReason) => void;\n /** Set by the root: elements that do not count as \"outside\" (the trigger). */\n insideElements: () => (Element | null | undefined)[] = () => [];\n /** Set by the root: what the popup is anchored to. */\n anchorElement: () => Element | null = () => null;\n\n protected readonly positioner = new AnchoredPositioner(\n this,\n () => this.anchorElement(),\n () => ({\n side: this.side,\n align: this.align,\n sideOffset: this.sideOffset,\n alignOffset: this.alignOffset,\n collisionPadding: this.collisionPadding,\n alignItem: this.alignItem(),\n }),\n );\n\n private closing?: Promise<void>;\n private generation = 0;\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 0;\n this.alignOffset = 0;\n this.collisionPadding = 5;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n installGlobalListeners();\n if (!this.hasAttribute(\"popover\")) this.setAttribute(\"popover\", \"manual\");\n if (!this.isOpen) this.setData(\"closed\", true);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.positioner.stop();\n const i = stack.indexOf(this);\n if (i >= 0) stack.splice(i, 1);\n }\n\n get isOpen(): boolean {\n return this.hasAttribute(\"data-open\");\n }\n\n /** Select overrides this to lay the selected item over the trigger. */\n protected alignItem(): HTMLElement | null {\n return null;\n }\n\n /** True if the event path is inside this popup or one of its inside elements. */\n containsPath(path: EventTarget[]): boolean {\n if (path.includes(this)) return true;\n return this.insideElements().some(el => el && path.includes(el));\n }\n\n requestClose(reason: OpenChangeReason): void {\n this.onRequestClose?.(reason);\n }\n\n /** Re-measure (e.g. after the content changed size). */\n reposition(): void {\n if (this.isOpen) this.positioner.update();\n }\n\n show(): void {\n this.generation++;\n this.closing = undefined;\n this.setData(\"ending-style\", false);\n this.setData(\"closed\", false);\n this.setData(\"open\", true);\n if (!this.matches(\":popover-open\")) {\n this.setData(\"starting-style\", true);\n try {\n this.showPopover();\n } catch {\n /* already open, or not connected */\n }\n requestAnimationFrame(() => this.setData(\"starting-style\", false));\n }\n if (!stack.includes(this)) stack.push(this);\n this.positioner.start();\n }\n\n /** Starts the close; resolves once the exit animation finished and the popover is hidden. */\n hide(): Promise<void> {\n if (!this.isOpen && !this.closing) {\n this.setData(\"closed\", true);\n return Promise.resolve();\n }\n if (this.closing) return this.closing;\n const gen = ++this.generation;\n this.setData(\"open\", false);\n this.setData(\"closed\", true);\n this.setData(\"ending-style\", true);\n const i = stack.indexOf(this);\n if (i >= 0) stack.splice(i, 1);\n\n this.closing = (async () => {\n // Let the closed styles apply, then wait for whatever they animate.\n await new Promise(r => requestAnimationFrame(() => r(null)));\n const anims = this.getAnimations().filter(a => a.playState !== \"finished\");\n await Promise.allSettled(anims.map(a => a.finished));\n if (gen !== this.generation) return; // re-opened meanwhile\n this.setData(\"ending-style\", false);\n this.positioner.stop();\n try {\n this.hidePopover();\n } catch {\n /* not open */\n }\n this.closing = undefined;\n })();\n return this.closing;\n }\n}\n\n/** Open popups, bottom → top (read-only view, for tests and devtools). */\nexport const openPopups = (): readonly PopupContent[] => stack;\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { fire, type OpenChangeDetail, type OpenChangeReason } from \"../events\";\nimport { HostElement, NativeEnhancer } from \"../host-element\";\nimport { ensureId } from \"../ids\";\nimport type { PopupContent } from \"./popup-content\";\n\n/**\n * Finds the first element matching `selector` under `root` that belongs to\n * `root` itself, i.e. whose closest `rootSelector` ancestor is `root` (so a\n * DropdownMenu never picks up its submenu's trigger or content).\n */\nexport function ownQuery<T extends Element>(root: Element, selector: string, rootSelector: string): T | null {\n for (const el of Array.from(root.querySelectorAll<T>(selector))) {\n if (el.parentElement?.closest(rootSelector) === root) return el;\n }\n return null;\n}\n\n/** All matches that belong to `root` (see ownQuery). */\nexport function ownQueryAll<T extends Element>(root: Element, selector: string, rootSelector: string): T[] {\n return Array.from(root.querySelectorAll<T>(selector)).filter(\n el => el.parentElement?.closest(rootSelector) === root,\n );\n}\n\n/**\n * # PopupRoot: the coordinator of a popup family\n *\n * Base UI's `<Menu.Root>`, `<Popover.Root>`, `<Select.Root>` render **no\n * element**; they are React context providers. A custom element cannot\n * render nothing, so pont2's roots are *coordinators*: they exist in the\n * DOM (authors need a tag to group trigger and content) but have no box and\n * no role:\n *\n * `[data-pont2-popup-root] { display: contents }` (core/popup/popup.css)\n *\n * That is the same reasoning as a Tier 3 shell, applied to an element whose\n * shadcn counterpart has no DOM at all. Instead of context, the root finds\n * its parts by DOM lookup (`ownQuery`), wires their ARIA, and owns the one\n * piece of state: `open`.\n *\n * `open` changes requested by the user (trigger press, Escape, outside press,\n * item press…) go through `setOpen(open, reason)`, which fires a cancelable\n * `pont2-open-change` ({ open, reason }) first: Base UI's\n * `onOpenChange(open, eventDetails)` + `eventDetails.cancel()`. Writing the\n * `open` property directly is the controlled form and fires nothing.\n */\nexport abstract class PopupRoot extends HostElement {\n static override identity = \"popup-root\";\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare open: boolean;\n declare disabled: boolean;\n\n /** Why the popup last opened/closed (drives focus management). */\n protected lastReason: OpenChangeReason = \"imperative\";\n /** Whether the last open was keyboard-initiated (focus the first item, not the popup). */\n protected openedByKeyboard = false;\n\n constructor() {\n super();\n this.open = false;\n this.disabled = false;\n }\n\n /** The element the popup anchors to and returns focus to (a native button / input). */\n abstract get triggerElement(): HTMLElement | null;\n abstract get contentElement(): PopupContent | null;\n /** `aria-haspopup` value for the trigger. */\n protected abstract get popupKind(): \"menu\" | \"listbox\" | \"dialog\" | \"true\";\n\n /**\n * Request an open-state change, as the user did. Returns false if a\n * `pont2-open-change` listener cancelled it.\n */\n setOpen(open: boolean, reason: OpenChangeReason, opts: { keyboard?: boolean } = {}): boolean {\n if (open === this.open) return true;\n if (open && this.disabled) return false;\n const allowed = fire<OpenChangeDetail>(this, \"pont2-open-change\", { open, reason }, true);\n if (!allowed) return false;\n this.lastReason = reason;\n this.openedByKeyboard = !!opts.keyboard;\n this.open = open;\n return true;\n }\n\n toggle(reason: OpenChangeReason = \"trigger-press\", opts: { keyboard?: boolean } = {}): void {\n this.setOpen(!this.open, reason, opts);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Parts may upgrade after the root; wire once everything is defined.\n queueMicrotask(() => this.wire());\n }\n\n /** Connect trigger and content (idempotent). Call when parts change. */\n wire(): void {\n const content = this.contentElement;\n const trigger = this.triggerElement;\n if (content) {\n ensureId(content, \"popup\");\n content.onRequestClose = reason => this.setOpen(false, reason);\n content.anchorElement = () => this.anchorElement();\n content.insideElements = () => [this.triggerElement, ...this.extraInsideElements()];\n }\n if (trigger) {\n trigger.setAttribute(\"aria-haspopup\", this.popupKind);\n trigger.setAttribute(\"aria-expanded\", String(this.open));\n if (content) trigger.setAttribute(\"aria-controls\", content.id);\n trigger.toggleAttribute(\"data-popup-open\", this.open);\n trigger.toggleAttribute(\"data-disabled\", this.disabled);\n }\n }\n\n /** What the content positions against. Defaults to the trigger. */\n protected anchorElement(): Element | null {\n return this.triggerElement;\n }\n\n /** Further elements whose presses are not \"outside\" (e.g. a combobox input group). */\n protected extraInsideElements(): (Element | null)[] {\n return [];\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.wire();\n if (!changed.has(\"open\")) return;\n const content = this.contentElement;\n if (!content) return;\n if (this.open) {\n content.show();\n this.afterOpen();\n } else if (changed.get(\"open\") !== undefined) {\n const hadFocus = content.contains(document.activeElement) || document.activeElement === document.body;\n void content.hide();\n this.afterClose(hadFocus);\n }\n }\n\n /** Focus management after opening. Default: focus the popup itself. */\n protected afterOpen(): void {}\n\n /** Focus management after closing. Default: return focus to the trigger if it was inside. */\n protected afterClose(focusWasInside: boolean): void {\n if (focusWasInside && this.lastReason !== \"outside-press\") this.triggerElement?.focus({ preventScroll: true });\n }\n}\n\n/**\n * Trigger enhancer: `<pont2-x-trigger><button>…</button></pont2-x-trigger>`.\n * The native button is the trigger (Tier 3). It gets `data-slot`, and its\n * root sets `aria-haspopup` / `aria-expanded` / `aria-controls` /\n * `data-popup-open` on it. Pressing it toggles the root.\n */\nexport abstract class PopupTrigger extends NativeEnhancer<HTMLButtonElement> {\n static override nativeSelector = \"button\";\n /** Tag of the root this trigger belongs to. */\n static rootTag = \"\";\n /**\n * `data-slot` written on the *native button* (e.g. \"dropdown-menu-trigger\").\n * Deliberately not `slotName`: that would stamp the shell, and a shell is\n * never styled or selected.\n */\n static controlSlot = \"trigger\";\n\n get root(): PopupRoot | null {\n return this.closest((this.constructor as typeof PopupTrigger).rootTag) as PopupRoot | null;\n }\n\n constructor() {\n super();\n // Wrappers, not method references: subclass overrides are installed after\n // this constructor runs.\n this.addEventListener(\"click\", e => this.onClick(e));\n this.addEventListener(\"keydown\", e => this.onKeyDown(e));\n }\n\n protected apply(control: HTMLButtonElement): void {\n const slot = (this.constructor as typeof PopupTrigger).controlSlot;\n if (!control.hasAttribute(\"data-slot\") || control.getAttribute(\"data-slot\") === \"button\") {\n control.setAttribute(\"data-slot\", slot);\n }\n if (!control.hasAttribute(\"type\")) control.type = \"button\";\n this.root?.wire();\n }\n\n protected onClick(e: MouseEvent): void {\n const c = this.control;\n if (!c || !(c === e.target || c.contains(e.target as Node)) || c.disabled) return;\n // `detail === 0`: activated by keyboard (Enter/Space), not a pointer.\n this.root?.toggle(\"trigger-press\", { keyboard: e.detail === 0 });\n }\n\n protected onKeyDown(_e: KeyboardEvent): void {}\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\n\nconst ROOT = sel(\"popover\");\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * # Popover\n *\n * shadcn: `<Popover>` (Base UI `Popover.Root`, renders nothing) >\n * `<PopoverTrigger>` (a `<button>`) + `<PopoverContent>` (Portal > Positioner >\n * `<div data-slot=\"popover-content\">`), with `PopoverHeader/Title/Description`.\n *\n * pont2:\n * ```html\n * <pont2-prim-popover> coordinator, display: contents\n * <pont2-prim-popover-trigger><button data-pont2-button data-variant=\"outline\">Open</button></pont2-prim-popover-trigger>\n * <pont2-prim-popover-content> the popup itself: [popover], role=dialog\n * <pont2-prim-popover-header>\n * <pont2-prim-popover-title>Dimensions</pont2-prim-popover-title>\n * <pont2-prim-popover-description>Set the dimensions for the layer.</pont2-prim-popover-description>\n * </pont2-prim-popover-header>\n * …\n * </pont2-prim-popover-content>\n * </pont2-prim-popover>\n * ```\n *\n * @tag pont2-prim-popover\n * @attr open - Open state (initially: Base UI `defaultOpen`; property: controlled `open`).\n * @fires pont2-open-change - cancelable, `{ open, reason }`.\n */\nexport class Popover extends PopupRoot {\n static override identity = \"popover\";\n\n get triggerElement(): HTMLButtonElement | null {\n return ownQuery<PopoverTrigger>(this, tags(\"popover-trigger\"), ROOT)?.control ?? null;\n }\n get contentElement(): PopoverContent | null {\n return ownQuery<PopoverContent>(this, sel(\"popover-content\"), ROOT);\n }\n protected get popupKind() {\n return \"dialog\" as const;\n }\n\n protected override afterOpen(): void {\n const content = this.contentElement;\n if (!content) return;\n // Base UI Popover: focus the first focusable element in the popup, else the popup.\n const first = content.querySelector<HTMLElement>(FOCUSABLE);\n (first ?? content).focus({ preventScroll: true });\n }\n}\n\n/** @tag pont2-prim-popover-trigger */\nexport class PopoverTrigger extends PopupTrigger {\n static override rootTag = ROOT;\n static override controlSlot = \"popover-trigger\";\n}\n\n/**\n * The popup. Non-modal, like Base UI's default: closes on Escape, on a press\n * outside, and when focus leaves both the popup and its trigger.\n *\n * @tag pont2-prim-popover-content\n * @attr side - bottom (default) | top | left | right | inline-start | inline-end\n * @attr align - center (default) | start | end\n * @attr side-offset - default 4\n * @attr align-offset - default 0\n * @cssprop --pont2-popover-bg, --pont2-popover-fg, --pont2-popover-border-color, --pont2-popover-radius, --pont2-popover-shadow - see docs/11-tokens.md\n * @cssprop --pont2-popover-width, --pont2-popover-padding-x, --pont2-popover-padding-y, --pont2-popover-gap - sizes (defaults 18rem, 1rem, 1rem, 1rem)\n */\nexport class PopoverContent extends PopupContent {\n static override identity = \"popover-content\";\n static override slotName = \"popover-content\";\n static override role = \"dialog\";\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 4;\n this.addEventListener(\"focusout\", this.onFocusOut);\n }\n\n override show(): void {\n this.tabIndex = -1;\n const title = this.querySelector(`${sel(\"popover-title\")}, [data-slot=popover-title]`);\n const desc = this.querySelector(`${sel(\"popover-description\")}, [data-slot=popover-description]`);\n if (title && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(title, \"popover-title\"));\n if (desc && !this.hasAttribute(\"aria-describedby\")) this.setAttribute(\"aria-describedby\", ensureId(desc, \"popover-desc\"));\n super.show();\n }\n\n private onFocusOut = (e: FocusEvent) => {\n const to = e.relatedTarget as Node | null;\n if (!to || !this.isOpen) return; // focus went to the page/body: keep open (Base UI)\n if (this.contains(to) || this.insideElements().some(el => el?.contains(to))) return;\n this.requestClose(\"focus-out\");\n };\n}\n\n/** @tag pont2-prim-popover-header */\nexport class PopoverHeader extends HostElement {\n static override identity = \"popover-header\";\n static override slotName = \"popover-header\";\n}\n\n/** Base UI `Popover.Title` renders an `<h2>`; pont2 keeps the heading semantics through internals. @tag pont2-prim-popover-title */\nexport class PopoverTitle extends HostElement {\n static override identity = \"popover-title\";\n static override slotName = \"popover-title\";\n static override role = \"heading\";\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.internals.ariaLevel) this.internals.ariaLevel = \"2\";\n }\n}\n\n/** Base UI `Popover.Description` renders a `<p>`. @tag pont2-prim-popover-description */\nexport class PopoverDescription extends HostElement {\n static override identity = \"popover-description\";\n static override slotName = \"popover-description\";\n}\n\ndefine(\"pont2-prim-popover\", Popover);\ndefine(\"pont2-prim-popover-trigger\", PopoverTrigger);\ndefine(\"pont2-prim-popover-content\", PopoverContent);\ndefine(\"pont2-prim-popover-header\", PopoverHeader);\ndefine(\"pont2-prim-popover-title\", PopoverTitle);\ndefine(\"pont2-prim-popover-description\", PopoverDescription);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-popover\": Popover;\n \"pont2-prim-popover-trigger\": PopoverTrigger;\n \"pont2-prim-popover-content\": PopoverContent;\n \"pont2-prim-popover-header\": PopoverHeader;\n \"pont2-prim-popover-title\": PopoverTitle;\n \"pont2-prim-popover-description\": PopoverDescription;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { directionOf } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex, Typeahead } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOTS = `${sel(\"dropdown-menu\")}, ${sel(\"dropdown-menu-sub\")}`;\nconst CONTENT = \"[data-pont2-dropdown-menu-content]\";\nconst ITEM = \"[data-pont2-menu-item]\";\n\n/** Boolean attribute that defaults to true and is turned off with `=\"false\"`. */\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\ntype FocusTarget = \"first\" | \"last\" | \"popup\";\n\n/* ==================================================================== */\n/* Roots */\n/* ==================================================================== */\n\n/**\n * # DropdownMenu\n *\n * shadcn: `<DropdownMenu>` = Base UI `Menu.Root` (renders nothing).\n *\n * ```html\n * <pont2-prim-dropdown-menu>\n * <pont2-prim-dropdown-menu-trigger><button data-pont2-button data-variant=\"outline\">Open</button></pont2-prim-dropdown-menu-trigger>\n * <pont2-prim-dropdown-menu-content>\n * <pont2-prim-dropdown-menu-group>\n * <pont2-prim-dropdown-menu-label>My Account</pont2-prim-dropdown-menu-label>\n * <pont2-prim-dropdown-menu-item>Profile <pont2-prim-dropdown-menu-shortcut>⇧⌘P</pont2-prim-dropdown-menu-shortcut></pont2-prim-dropdown-menu-item>\n * </pont2-prim-dropdown-menu-group>\n * </pont2-prim-dropdown-menu-content>\n * </pont2-prim-dropdown-menu>\n * ```\n *\n * @tag pont2-prim-dropdown-menu\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class DropdownMenu extends PopupRoot {\n static override identity = \"dropdown-menu\";\n\n /** Where focus goes when the menu opens (set by the trigger's key handling). */\n focusOnOpen: FocusTarget = \"popup\";\n\n get triggerElement(): HTMLElement | null {\n return ownQuery<DropdownMenuTrigger>(this, tags(\"dropdown-menu-trigger\"), ROOTS)?.control ?? null;\n }\n get contentElement(): DropdownMenuContent | null {\n return ownQuery<DropdownMenuContent>(this, sel(\"dropdown-menu-content\"), ROOTS);\n }\n protected get popupKind() {\n return \"menu\" as const;\n }\n\n openWith(focus: FocusTarget, reason: \"trigger-press\" | \"list-navigation\" = \"trigger-press\"): void {\n this.focusOnOpen = focus;\n if (this.open) this.contentElement?.focusTarget(focus);\n else this.setOpen(true, reason, { keyboard: focus !== \"popup\" });\n }\n\n override toggle(reason: \"trigger-press\" = \"trigger-press\", opts: { keyboard?: boolean } = {}): void {\n // Base UI: opening with Enter/Space highlights the first item.\n this.focusOnOpen = opts.keyboard ? \"first\" : \"popup\";\n super.toggle(reason, opts);\n }\n\n protected override afterOpen(): void {\n this.contentElement?.focusTarget(this.focusOnOpen);\n }\n}\n\n/**\n * # DropdownMenuSub\n *\n * Base UI `Menu.SubmenuRoot` (renders nothing). Its trigger is a\n * `pont2-prim-dropdown-menu-sub-trigger` (a menuitem), its popup a\n * `pont2-prim-dropdown-menu-sub-content`.\n *\n * @tag pont2-prim-dropdown-menu-sub\n */\nexport class DropdownMenuSub extends PopupRoot {\n static override identity = \"dropdown-menu-sub\";\n\n focusOnOpen: FocusTarget = \"popup\";\n\n get triggerElement(): DropdownMenuSubTrigger | null {\n return ownQuery<DropdownMenuSubTrigger>(this, sel(\"dropdown-menu-sub-trigger\"), ROOTS);\n }\n get contentElement(): DropdownMenuSubContent | null {\n return ownQuery<DropdownMenuSubContent>(this, sel(\"dropdown-menu-sub-content\"), ROOTS);\n }\n protected get popupKind() {\n return \"menu\" as const;\n }\n\n openWith(focus: FocusTarget, reason: \"trigger-press\" | \"trigger-hover\" | \"list-navigation\"): void {\n this.focusOnOpen = focus;\n if (this.open) this.contentElement?.focusTarget(focus);\n else this.setOpen(true, reason, { keyboard: focus !== \"popup\" });\n }\n\n protected override afterOpen(): void {\n if (this.focusOnOpen !== \"popup\") this.contentElement?.focusTarget(this.focusOnOpen);\n }\n}\n\n/* ==================================================================== */\n/* Trigger */\n/* ==================================================================== */\n\n/**\n * Tier 3 enhancer around a native `<button>`; combine freely with the\n * button recipe (`<button data-pont2-button data-variant=\"outline\">`).\n * ArrowDown/ArrowUp open the menu and highlight the first/last item.\n *\n * @tag pont2-prim-dropdown-menu-trigger\n */\nexport class DropdownMenuTrigger extends PopupTrigger {\n static override rootTag = sel(\"dropdown-menu\");\n static override controlSlot = \"dropdown-menu-trigger\";\n\n protected override onKeyDown(e: KeyboardEvent): void {\n const root = this.root as DropdownMenu | null;\n if (!root || !this.control || e.target !== this.control) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n root.openWith(e.key === \"ArrowDown\" ? \"first\" : \"last\", \"list-navigation\");\n }\n }\n}\n\n/* ==================================================================== */\n/* Content */\n/* ==================================================================== */\n\n/**\n * The menu popup: Base UI `Menu.Popup` (`role=\"menu\"`). Items get real\n * focus (roving), so the highlighted item is `document.activeElement`.\n *\n * @tag pont2-prim-dropdown-menu-content\n * @attr side - bottom (default) … @attr align - start (default) …\n * @attr side-offset - 4 @attr align-offset - 0\n * @cssprop --pont2-dropdown-menu-bg, --pont2-dropdown-menu-fg, --pont2-dropdown-menu-border-color, --pont2-dropdown-menu-radius, --pont2-dropdown-menu-shadow - see docs/11-tokens.md\n * @cssprop --pont2-dropdown-menu-min-width, --pont2-dropdown-menu-padding-x, --pont2-dropdown-menu-padding-y - sizes (defaults 8rem, 0.25rem, 0.25rem)\n * @cssprop --pont2-dropdown-menu-sub-content-shadow - submenu shadow (default: the menu shadow token, else shadow-lg)\n * @cssprop --pont2-dropdown-menu-item-radius, --pont2-dropdown-menu-item-bg-focus, --pont2-dropdown-menu-item-fg-focus - items, inherited from the content\n * @cssprop --pont2-dropdown-menu-item-destructive-fg, --pont2-dropdown-menu-item-destructive-bg-focus - variant=\"destructive\" items\n */\nexport class DropdownMenuContent extends PopupContent {\n static override identity = \"dropdown-menu-content\";\n static override slotName = \"dropdown-menu-content\";\n static override role = \"menu\";\n\n private typeahead = new Typeahead();\n private subCloseTimer = 0;\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"start\";\n this.sideOffset = 4;\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"pointerleave\", this.onPointerLeave);\n this.addEventListener(\"pointerenter\", () => this.cancelSubClose());\n }\n\n /** This menu's own items (not its submenus'), visible, in order. */\n get items(): MenuItemBase[] {\n return Array.from(this.querySelectorAll<MenuItemBase>(ITEM)).filter(\n i => i.closest(CONTENT) === this && isItemVisible(i),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.internals.ariaOrientation = \"vertical\";\n }\n\n override show(): void {\n this.tabIndex = -1;\n super.show();\n }\n\n override hide(): Promise<void> {\n this.closeSubs();\n return super.hide();\n }\n\n focusTarget(target: FocusTarget): void {\n const items = this.items;\n const i = target === \"popup\" ? -1 : moveIndex(items, -1, target);\n (i >= 0 ? items[i] : this).focus({ preventScroll: i < 0 });\n }\n\n /** Close open submenus of this menu, optionally keeping one. */\n closeSubs(except?: Element | null): void {\n for (const sub of Array.from(this.querySelectorAll<DropdownMenuSub>(sel(\"dropdown-menu-sub\")))) {\n if (sub === except || sub.parentElement?.closest(CONTENT) !== this) continue;\n if (sub.open) sub.open = false;\n }\n }\n\n /** Called when the pointer rests on one of this menu's items. */\n scheduleSubClose(keep: Element | null): void {\n this.cancelSubClose();\n this.subCloseTimer = window.setTimeout(() => this.closeSubs(keep), 120);\n }\n\n cancelSubClose(): void {\n clearTimeout(this.subCloseTimer);\n }\n\n private onPointerLeave = () => {\n // Base UI: the highlight leaves with the pointer; focus stays in the menu.\n if (this.contains(document.activeElement) && document.activeElement !== this) {\n const active = document.activeElement as HTMLElement;\n if (active.closest(CONTENT) === this && !(active instanceof DropdownMenuSubTrigger && active.isSubOpen)) {\n this.focus({ preventScroll: true });\n }\n }\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n // Keys from a nested submenu are handled by that submenu.\n const owner = (e.target as Element).closest(CONTENT);\n if (owner !== this || e.defaultPrevented) return;\n\n const items = this.items;\n const current = items.indexOf(e.target as MenuItemBase);\n const rtl = directionOf(this) === \"rtl\";\n\n if (e.key === \"Tab\") {\n // Base UI: Tab closes the whole menu; focusing the trigger first lets the\n // browser's default Tab move on from it, like leaving any other control.\n const top = this.closest<DropdownMenu>(sel(\"dropdown-menu\"));\n top?.setOpen(false, \"focus-out\");\n top?.triggerElement?.focus();\n return;\n }\n\n const closeKey = rtl ? \"ArrowRight\" : \"ArrowLeft\";\n if (e.key === closeKey && this instanceof DropdownMenuSubContent) {\n e.preventDefault();\n const sub = this.closest<DropdownMenuSub>(sel(\"dropdown-menu-sub\"));\n sub?.setOpen(false, \"list-navigation\");\n sub?.triggerElement?.focus();\n return;\n }\n\n const move = keyToMove(e.key);\n if (move) {\n e.preventDefault();\n const next = moveIndex(items, current, move);\n if (next >= 0) items[next].focus();\n return;\n }\n\n if ((e.key === \"Enter\" || e.key === \" \") && current >= 0) {\n e.preventDefault();\n if (e.key === \" \" && this.typeahead.active) return;\n items[current].click();\n return;\n }\n\n if (Typeahead.isChar(e)) {\n const i = this.typeahead.match(e.key, items, current, el => (el as MenuItemBase).label);\n if (i >= 0) items[i].focus();\n }\n };\n}\n\n/** @tag pont2-prim-dropdown-menu-sub-content */\nexport class DropdownMenuSubContent extends DropdownMenuContent {\n static override identity = \"dropdown-menu-sub-content\";\n static override slotName = \"dropdown-menu-sub-content\";\n\n constructor() {\n super();\n this.side = \"inline-end\";\n this.align = \"start\";\n this.sideOffset = 0;\n this.alignOffset = -3;\n this.addEventListener(\"pointerenter\", () =>\n this.parentElement?.closest<DropdownMenuContent>(CONTENT)?.cancelSubClose(),\n );\n }\n}\n\n/* ==================================================================== */\n/* Items */\n/* ==================================================================== */\n\n/**\n * Shared behaviour of every menu item (Base UI `Menu.Item` and friends):\n * host-as-root `role=menuitem*`, `tabindex=-1`, focus ⇄ `data-highlighted`,\n * pointer hover highlights, click activates and (optionally) closes the menu.\n */\nexport abstract class MenuItemBase extends HostElement {\n static override identity = \"menu-item\";\n static override role = \"menuitem\";\n\n static override properties: PropertyDeclarations = {\n disabled: { type: Boolean, reflect: true },\n inset: { type: Boolean, reflect: true },\n closeOnClick: { attribute: \"close-on-click\", converter: trueUnlessFalse },\n };\n\n declare disabled: boolean;\n declare inset: boolean;\n declare closeOnClick: boolean;\n\n constructor() {\n super();\n this.disabled = false;\n this.inset = false;\n this.closeOnClick = true;\n this.addEventListener(\"focus\", () => this.setData(\"highlighted\", true));\n this.addEventListener(\"blur\", () => this.setData(\"highlighted\", false));\n this.addEventListener(\"pointermove\", this.onPointerMove);\n this.addEventListener(\"click\", this.onClick);\n }\n\n /** Text used by typeahead (Base UI `label`): the `label` attribute, else the text content. */\n get label(): string {\n return this.getAttribute(\"label\") ?? (this.textContent ?? \"\").trim();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n protected get menu(): DropdownMenuContent | null {\n return this.closest<DropdownMenuContent>(CONTENT);\n }\n\n private onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === \"touch\" || this.disabled) return;\n if (document.activeElement !== this) this.focus({ preventScroll: true });\n this.menu?.scheduleSubClose(this instanceof DropdownMenuSubTrigger ? this.parentElement : null);\n };\n\n private onClick = (e: MouseEvent) => {\n if (this.disabled || isItemDisabled(this)) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n this.activate();\n if (this.closeOnClick) {\n this.closest<DropdownMenu>(sel(\"dropdown-menu\"))?.setOpen(false, \"item-press\");\n }\n };\n\n /** What pressing the item does beyond firing `click`. */\n protected activate(): void {}\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"disabled\", this.disabled);\n this.setData(\"inset\", this.inset);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n }\n}\n\n/**\n * Base UI `Menu.Item`. Listen for `click` to act on it.\n *\n * @tag pont2-prim-dropdown-menu-item\n * @attr variant - default | destructive\n * @attr inset, disabled, close-on-click=\"false\"\n */\nexport class DropdownMenuItem extends MenuItemBase {\n static override identity = \"dropdown-menu-item\";\n static override slotName = \"dropdown-menu-item\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n declare variant: \"default\" | \"destructive\";\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\nconst indicator = (slot: string, on: boolean) =>\n html`<span data-pont2-dropdown-menu-item-indicator data-slot=${slot}>${on ? icons.check() : nothing}</span>`;\n\n/**\n * Base UI `Menu.CheckboxItem` (`role=menuitemcheckbox`). Stays open on\n * click by default, like Base UI. Fires `change` when toggled.\n *\n * @tag pont2-prim-dropdown-menu-checkbox-item\n * @attr checked\n * @fires change\n */\nexport class DropdownMenuCheckboxItem extends MenuItemBase {\n static override identity = \"dropdown-menu-checkbox-item\";\n static override slotName = \"dropdown-menu-checkbox-item\";\n static override role = \"menuitemcheckbox\";\n\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean, reflect: true },\n };\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n this.closeOnClick = false;\n }\n\n protected override activate(): void {\n this.checked = !this.checked;\n fireNative(this, \"change\");\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n }\n\n override render() {\n return indicator(\"dropdown-menu-checkbox-item-indicator\", this.checked);\n }\n}\n\n/**\n * Base UI `Menu.RadioGroup` (`role=group`). Holds `value`; fires `change`\n * when a radio item is picked.\n *\n * @tag pont2-prim-dropdown-menu-radio-group\n * @attr value\n * @fires change\n */\nexport class DropdownMenuRadioGroup extends HostElement {\n static override identity = \"dropdown-menu-radio-group\";\n static override slotName = \"dropdown-menu-radio-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String, reflect: true },\n };\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n select(value: string): void {\n if (value === this.value) return;\n this.value = value;\n fireNative(this, \"change\");\n }\n\n protected override updated(): void {\n for (const item of Array.from(this.querySelectorAll<DropdownMenuRadioItem>(sel(\"dropdown-menu-radio-item\")))) {\n if (item.closest(sel(\"dropdown-menu-radio-group\")) === this) item.requestUpdate();\n }\n }\n}\n\n/**\n * Base UI `Menu.RadioItem` (`role=menuitemradio`).\n *\n * @tag pont2-prim-dropdown-menu-radio-item\n * @attr value\n */\nexport class DropdownMenuRadioItem extends MenuItemBase {\n static override identity = \"dropdown-menu-radio-item\";\n static override slotName = \"dropdown-menu-radio-item\";\n static override role = \"menuitemradio\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n };\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n this.closeOnClick = false;\n }\n\n get group(): DropdownMenuRadioGroup | null {\n return this.closest(sel(\"dropdown-menu-radio-group\"));\n }\n get checked(): boolean {\n return !!this.group && this.group.value === this.value;\n }\n\n protected override activate(): void {\n this.group?.select(this.value);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n }\n\n override render() {\n return indicator(\"dropdown-menu-radio-item-indicator\", this.checked);\n }\n}\n\n/**\n * Base UI `Menu.SubmenuTrigger`: a menuitem that opens a submenu on hover\n * (100 ms), click, Enter/Space, or ArrowRight (ArrowLeft in RTL). Renders the\n * chevron after your content, as shadcn does.\n *\n * @tag pont2-prim-dropdown-menu-sub-trigger\n */\nexport class DropdownMenuSubTrigger extends MenuItemBase {\n static override identity = \"dropdown-menu-sub-trigger\";\n static override slotName = \"dropdown-menu-sub-trigger\";\n\n private hoverTimer = 0;\n\n constructor() {\n super();\n this.closeOnClick = false;\n this.addEventListener(\"keydown\", this.onKey);\n this.addEventListener(\"pointerenter\", this.onEnter);\n this.addEventListener(\"pointerleave\", () => clearTimeout(this.hoverTimer));\n }\n\n get sub(): DropdownMenuSub | null {\n return this.closest(sel(\"dropdown-menu-sub\"));\n }\n get isSubOpen(): boolean {\n return !!this.sub?.open;\n }\n\n protected override activate(): void {\n this.sub?.openWith(\"first\", \"trigger-press\");\n }\n\n private onEnter = (e: PointerEvent) => {\n if (e.pointerType === \"touch\" || this.disabled) return;\n clearTimeout(this.hoverTimer);\n this.hoverTimer = window.setTimeout(() => this.sub?.openWith(\"popup\", \"trigger-hover\"), 100);\n };\n\n private onKey = (e: KeyboardEvent) => {\n if (e.target !== this || this.disabled) return;\n const openKey = directionOf(this) === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n if (e.key === openKey) {\n e.preventDefault();\n e.stopPropagation();\n this.sub?.openWith(\"first\", \"list-navigation\");\n }\n };\n\n override render() {\n return icons.chevronRight();\n }\n}\n\n/** Base UI `Menu.Group` (`role=group`, labelled by its label). @tag pont2-prim-dropdown-menu-group */\nexport class DropdownMenuGroup extends HostElement {\n static override identity = \"dropdown-menu-group\";\n static override slotName = \"dropdown-menu-group\";\n static override role = \"group\";\n\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"dropdown-menu-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) {\n this.setAttribute(\"aria-labelledby\", ensureId(label, \"menu-label\"));\n }\n });\n }\n}\n\n/** Base UI `Menu.GroupLabel`. @tag pont2-prim-dropdown-menu-label @attr inset */\nexport class DropdownMenuLabel extends HostElement {\n static override identity = \"dropdown-menu-label\";\n static override slotName = \"dropdown-menu-label\";\n static override properties: PropertyDeclarations = { inset: { type: Boolean, reflect: true } };\n declare inset: boolean;\n constructor() {\n super();\n this.inset = false;\n }\n protected override willUpdate(): void {\n this.setData(\"inset\", this.inset);\n }\n}\n\n/**\n * Base UI `Menu.Separator`. **Is a** Separator (`extends Separator`), so it\n * carries `data-pont2-separator` (the look) and its own slot.\n *\n * @tag pont2-prim-dropdown-menu-separator\n */\nexport class DropdownMenuSeparator extends Separator {\n static override identity = \"dropdown-menu-separator\";\n static override slotName = \"dropdown-menu-separator\";\n}\n\n/** shadcn `DropdownMenuShortcut` (a `<span>`). @tag pont2-prim-dropdown-menu-shortcut */\nexport class DropdownMenuShortcut extends HostElement {\n static override identity = \"dropdown-menu-shortcut\";\n static override slotName = \"dropdown-menu-shortcut\";\n}\n\ndefine(\"pont2-prim-dropdown-menu\", DropdownMenu);\ndefine(\"pont2-prim-dropdown-menu-sub\", DropdownMenuSub);\ndefine(\"pont2-prim-dropdown-menu-trigger\", DropdownMenuTrigger);\ndefine(\"pont2-prim-dropdown-menu-content\", DropdownMenuContent);\ndefine(\"pont2-prim-dropdown-menu-sub-content\", DropdownMenuSubContent);\ndefine(\"pont2-prim-dropdown-menu-item\", DropdownMenuItem);\ndefine(\"pont2-prim-dropdown-menu-checkbox-item\", DropdownMenuCheckboxItem);\ndefine(\"pont2-prim-dropdown-menu-radio-group\", DropdownMenuRadioGroup);\ndefine(\"pont2-prim-dropdown-menu-radio-item\", DropdownMenuRadioItem);\ndefine(\"pont2-prim-dropdown-menu-sub-trigger\", DropdownMenuSubTrigger);\ndefine(\"pont2-prim-dropdown-menu-group\", DropdownMenuGroup);\ndefine(\"pont2-prim-dropdown-menu-label\", DropdownMenuLabel);\ndefine(\"pont2-prim-dropdown-menu-separator\", DropdownMenuSeparator);\ndefine(\"pont2-prim-dropdown-menu-shortcut\", DropdownMenuShortcut);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-dropdown-menu\": DropdownMenu;\n \"pont2-prim-dropdown-menu-sub\": DropdownMenuSub;\n \"pont2-prim-dropdown-menu-trigger\": DropdownMenuTrigger;\n \"pont2-prim-dropdown-menu-content\": DropdownMenuContent;\n \"pont2-prim-dropdown-menu-sub-content\": DropdownMenuSubContent;\n \"pont2-prim-dropdown-menu-item\": DropdownMenuItem;\n \"pont2-prim-dropdown-menu-checkbox-item\": DropdownMenuCheckboxItem;\n \"pont2-prim-dropdown-menu-radio-group\": DropdownMenuRadioGroup;\n \"pont2-prim-dropdown-menu-radio-item\": DropdownMenuRadioItem;\n \"pont2-prim-dropdown-menu-sub-trigger\": DropdownMenuSubTrigger;\n \"pont2-prim-dropdown-menu-group\": DropdownMenuGroup;\n \"pont2-prim-dropdown-menu-label\": DropdownMenuLabel;\n \"pont2-prim-dropdown-menu-separator\": DropdownMenuSeparator;\n \"pont2-prim-dropdown-menu-shortcut\": DropdownMenuShortcut;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { HostElement, ShellElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex, Typeahead } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOT = sel(\"select\");\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\n/**\n * # Select\n *\n * shadcn: `<Select>` = Base UI `Select.Root` (renders a hidden `<input>` for\n * forms, nothing else) > `<SelectTrigger>` (`<button role=combobox>` with\n * `<SelectValue>` + chevron) + `<SelectContent>` (Portal > Positioner > Popup >\n * List > items).\n *\n * pont2:\n * ```html\n * <pont2-prim-select name=\"fruit\" value=\"apple\"> coordinator + form-associated, display: contents\n * <pont2-prim-select-trigger placeholder=\"Select a fruit\"></pont2-prim-select-trigger> shell > native <button>\n * <pont2-prim-select-content> the popup: [popover], role=listbox\n * <pont2-prim-select-group>\n * <pont2-prim-select-label>Fruits</pont2-prim-select-label>\n * <pont2-prim-select-item value=\"apple\">Apple</pont2-prim-select-item>\n * </pont2-prim-select-group>\n * </pont2-prim-select-content>\n * </pont2-prim-select>\n * ```\n *\n * The **root is the form control** (a form-associated custom element):\n * `name`/`value` submit with the form, `required` blocks submission,\n * `<fieldset disabled>` and form reset work, and `<label for=\"…\">` targets it\n * (the label's text becomes the trigger's accessible name). That replaces\n * Base UI's hidden `<input>`, one node fewer.\n *\n * @tag pont2-prim-select\n * @attr value - selected value (initially: Base UI `defaultValue`)\n * @attr name, required, disabled, open\n * @fires input, change - the user picked a value (read `.value`)\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class Select extends PopupRoot {\n static formAssociated = true;\n static override identity = \"select\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n name: { type: String, reflect: true },\n required: { type: Boolean, reflect: true },\n /** `aria-invalid` on the root is forwarded to the native trigger (which you do not write). */\n invalid: { type: String, attribute: \"aria-invalid\" },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare name: string;\n declare required: boolean;\n declare invalid: string | null;\n declare protected formDisabled: boolean;\n\n private typeahead = new Typeahead();\n private focusSelectedOnOpen = true;\n\n constructor() {\n super();\n this.value = \"\";\n this.name = \"\";\n this.required = false;\n this.formDisabled = false;\n // A <label for> click lands on the (box-less) root: forward focus to the trigger.\n this.addEventListener(\"click\", e => {\n if (e.target === this) this.triggerElement?.focus();\n });\n }\n\n /* ---------------- parts ---------------- */\n\n get triggerElement(): HTMLButtonElement | null {\n return ownQuery<SelectTrigger>(this, tags(\"select-trigger\"), ROOT)?.control ?? null;\n }\n get triggerHost(): SelectTrigger | null {\n return ownQuery<SelectTrigger>(this, tags(\"select-trigger\"), ROOT);\n }\n get contentElement(): SelectContent | null {\n return ownQuery<SelectContent>(this, sel(\"select-content\"), ROOT);\n }\n protected get popupKind() {\n return \"listbox\" as const;\n }\n get items(): SelectItem[] {\n return Array.from(this.querySelectorAll<SelectItem>(sel(\"select-item\"))).filter(\n i => i.closest(ROOT) === this && isItemVisible(i),\n );\n }\n get selectedItem(): SelectItem | null {\n return this.items.find(i => i.value === this.value) ?? null;\n }\n\n /* ---------------- form-associated API ---------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n formResetCallback(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n }\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n formStateRestoreCallback(state: string | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n /* ---------------- behaviour ---------------- */\n\n override wire(): void {\n super.wire();\n // Labels of the (box-less) root name the trigger button.\n const trigger = this.triggerElement;\n if (trigger) {\n const ids = Array.from(this.internals.labels as NodeListOf<HTMLElement>).map(l => ensureId(l, \"select-label\"));\n if (ids.length && !trigger.hasAttribute(\"aria-label\")) trigger.setAttribute(\"aria-labelledby\", ids.join(\" \"));\n }\n }\n\n /** Pick `value` as the user did: updates, fires input/change, closes. */\n select(value: string): void {\n const changed = value !== this.value;\n this.value = value;\n if (changed) {\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n this.setOpen(false, \"item-press\");\n }\n\n /** Called by the trigger for keys pressed while it has focus. */\n handleTriggerKey(e: KeyboardEvent): void {\n if (this.isDisabled) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n this.setOpen(true, \"list-navigation\", { keyboard: true });\n return;\n }\n // Base UI: typing on a closed select picks the matching item directly.\n if (!this.open && Typeahead.isChar(e)) {\n const items = this.items;\n const i = this.typeahead.match(e.key, items, items.indexOf(this.selectedItem!), el => (el as SelectItem).label);\n if (i >= 0 && items[i].value !== this.value) {\n this.value = items[i].value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n }\n }\n\n override setOpen(open: boolean, reason: Parameters<PopupRoot[\"setOpen\"]>[1], opts?: { keyboard?: boolean }): boolean {\n if (open && this.isDisabled) return false;\n return super.setOpen(open, reason, opts);\n }\n\n protected override afterOpen(): void {\n const content = this.contentElement;\n if (!content) return;\n const target = (this.focusSelectedOnOpen && this.selectedItem) || (this.openedByKeyboard ? this.items.find(i => !isItemDisabled(i)) : null);\n (target ?? content).focus({ preventScroll: true });\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n this.setData(\"disabled\", disabled);\n this.setData(\"required\", this.required);\n this.internals.setFormValue(this.value || null);\n if (this.required && !this.value) {\n this.internals.setValidity({ valueMissing: true }, \"Please select an item in the list.\", this.triggerElement ?? undefined);\n } else {\n this.internals.setValidity({});\n }\n if (changed.has(\"value\") || changed.has(\"disabled\") || changed.has(\"formDisabled\") || changed.has(\"invalid\")) {\n for (const item of this.items) item.requestUpdate();\n this.triggerHost?.requestUpdate();\n }\n }\n}\n\n/* ==================================================================== */\n\n/**\n * shadcn `SelectTrigger` + `SelectValue`. Tier 3, **self-rendering**: the\n * trigger generates all of its content (the selected item's label or the\n * placeholder, then the chevron), so it renders its own native `<button>`\n * rather than enhancing one you write (docs/02-conventions.md, \"Tier 3\n * entry points\").\n *\n * ```\n * shadcn: button[data-slot=select-trigger][role=combobox] > span[data-slot=select-value] + svg\n * pont2: pont2-prim-select-trigger (shell) > button[data-slot=select-trigger][role=combobox] > span[data-slot=select-value] + svg\n * ```\n *\n * @tag pont2-prim-select-trigger\n * @attr placeholder - shown when no value is selected (Base UI `Select.Value` placeholder)\n * @attr size - default | sm\n */\nexport class SelectTrigger extends ShellElement {\n static override properties: PropertyDeclarations = {\n placeholder: { type: String },\n size: { type: String },\n };\n declare placeholder: string;\n declare size: \"default\" | \"sm\";\n\n constructor() {\n super();\n this.placeholder = \"\";\n this.size = \"default\";\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n\n override get control(): HTMLButtonElement | null {\n return this.querySelector(\":scope > [data-pont2-select-trigger]\");\n }\n\n private onClick = (e: MouseEvent) => {\n const root = this.root;\n if (!root || root.isDisabled) return;\n root.toggle(\"trigger-press\", { keyboard: e.detail === 0 });\n };\n\n private onKeyDown = (e: KeyboardEvent) => this.root?.handleTriggerKey(e);\n\n protected override updated(): void {\n this.root?.wire();\n }\n\n override render() {\n const root = this.root;\n const item = root?.selectedItem ?? null;\n const disabled = !!root?.isDisabled;\n return html`<button\n type=\"button\"\n role=\"combobox\"\n data-pont2-select-trigger\n data-slot=\"select-trigger\"\n data-size=${this.size || \"default\"}\n ?data-placeholder=${!item}\n aria-invalid=${root?.invalid ?? nothing}\n ?disabled=${disabled}\n ?data-disabled=${disabled}\n @click=${this.onClick}\n @keydown=${this.onKeyDown}\n ><span data-pont2-select-value data-slot=\"select-value\" ?data-placeholder=${!item}\n >${item ? item.labelNodes() : this.placeholder}</span\n >${icons.chevronDown()}</button>`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * The popup (`role=listbox`). By default the selected item is laid over the\n * trigger (Base UI `alignItemWithTrigger`, macOS-style); when that cannot fit\n * it falls back to opening below the trigger.\n *\n * @tag pont2-prim-select-content\n * @attr align-item-with-trigger - default true; `=\"false\"` always opens on `side`\n * @attr side - bottom @attr align - center @attr side-offset - 4\n */\nexport class SelectContent extends PopupContent {\n static override identity = \"select-content\";\n static override slotName = \"select-content\";\n static override role = \"listbox\";\n\n static override properties: PropertyDeclarations = {\n alignItemWithTrigger: { attribute: \"align-item-with-trigger\", converter: trueUnlessFalse },\n };\n declare alignItemWithTrigger: boolean;\n\n private typeahead = new Typeahead();\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 4;\n this.alignItemWithTrigger = true;\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"pointerleave\", () => {\n if (this.contains(document.activeElement)) this.focus({ preventScroll: true });\n });\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n\n protected override alignItem(): HTMLElement | null {\n if (!this.alignItemWithTrigger) return null;\n const root = this.root;\n return root?.selectedItem ?? root?.items[0] ?? null;\n }\n\n protected override willUpdate(): void {\n this.setData(\"align-trigger\", this.alignItemWithTrigger ? \"true\" : \"false\");\n }\n\n override show(): void {\n this.tabIndex = -1;\n super.show();\n // Bring the selected item into view inside the list, then re-measure.\n const item = this.root?.selectedItem;\n if (item) {\n const top = item.offsetTop;\n if (top < this.scrollTop || top + item.offsetHeight > this.scrollTop + this.clientHeight) {\n this.scrollTop = top - (this.clientHeight - item.offsetHeight) / 2;\n }\n }\n this.positioner.update();\n }\n\n private onKeyDown = (e: KeyboardEvent) => {\n const root = this.root;\n if (!root || e.defaultPrevented) return;\n const items = root.items;\n const current = items.indexOf(e.target as SelectItem);\n\n if (e.key === \"Tab\") {\n root.setOpen(false, \"focus-out\");\n root.triggerElement?.focus();\n return;\n }\n const move = keyToMove(e.key);\n if (move) {\n e.preventDefault();\n const next = moveIndex(items, current, move, { loop: false });\n if (next >= 0) items[next].focus();\n return;\n }\n if ((e.key === \"Enter\" || e.key === \" \") && current >= 0) {\n e.preventDefault();\n if (e.key === \" \" && this.typeahead.active) return;\n items[current].click();\n return;\n }\n if (Typeahead.isChar(e)) {\n const i = this.typeahead.match(e.key, items, current, el => (el as SelectItem).label);\n if (i >= 0) items[i].focus();\n }\n };\n}\n\n/* ==================================================================== */\n\n/**\n * Base UI `Select.Item` (`role=option`): host-as-root. Your content is the\n * item text (Base UI `ItemText`); the check indicator is rendered after it\n * when selected.\n *\n * @tag pont2-prim-select-item\n * @attr value - required\n * @attr label - text for typeahead and the trigger (defaults to the text content)\n * @attr disabled\n */\nexport class SelectItem extends HostElement {\n static override identity = \"select-item\";\n static override slotName = \"select-item\";\n static override role = \"option\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"focus\", () => this.setData(\"highlighted\", true));\n this.addEventListener(\"blur\", () => this.setData(\"highlighted\", false));\n this.addEventListener(\"pointermove\", e => {\n if (e.pointerType !== \"touch\" && !this.disabled && document.activeElement !== this) this.focus({ preventScroll: true });\n });\n this.addEventListener(\"click\", e => {\n if (this.disabled) {\n e.stopImmediatePropagation();\n return;\n }\n this.root?.select(this.value);\n });\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n get selected(): boolean {\n return !!this.root && this.root.value === this.value;\n }\n get label(): string {\n return this.getAttribute(\"label\") ?? this.textOf();\n }\n\n private textOf(): string {\n let t = \"\";\n for (const n of Array.from(this.childNodes)) {\n if (n instanceof Comment) continue; // lit-html part markers\n if (n instanceof Element && n.hasAttribute(\"data-pont2-select-item-indicator\")) continue;\n t += n.textContent ?? \"\";\n }\n return t.trim();\n }\n\n /** Copies of the author's content, for the trigger to display (Base UI renders the item label). */\n labelNodes(): Node[] {\n if (this.hasAttribute(\"label\")) return [document.createTextNode(this.getAttribute(\"label\")!)];\n return Array.from(this.childNodes)\n .filter(n => !(n instanceof Comment) && !(n instanceof Element && n.hasAttribute(\"data-pont2-select-item-indicator\")))\n .map(n => {\n const c = n.cloneNode(true);\n if (c instanceof Element) c.removeAttribute(\"id\");\n return c;\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n protected override willUpdate(): void {\n const selected = this.selected;\n this.internals.ariaSelected = String(selected);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n this.setData(\"selected\", selected);\n this.setData(\"disabled\", this.disabled);\n }\n\n override render() {\n return this.selected\n ? html`<span data-pont2-select-item-indicator data-slot=\"select-item-indicator\">${icons.check()}</span>`\n : nothing;\n }\n}\n\n/** Base UI `Select.Group` (`role=group`). @tag pont2-prim-select-group */\nexport class SelectGroup extends HostElement {\n static override identity = \"select-group\";\n static override slotName = \"select-group\";\n static override role = \"group\";\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"select-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(label, \"select-group-label\"));\n });\n }\n}\n\n/** Base UI `Select.GroupLabel`. @tag pont2-prim-select-label */\nexport class SelectLabel extends HostElement {\n static override identity = \"select-label\";\n static override slotName = \"select-label\";\n}\n\n/** Base UI `Select.Separator`; is-a Separator. @tag pont2-prim-select-separator */\nexport class SelectSeparator extends Separator {\n static override identity = \"select-separator\";\n static override slotName = \"select-separator\";\n}\n\ndefine(\"pont2-prim-select\", Select);\ndefine(\"pont2-prim-select-trigger\", SelectTrigger);\ndefine(\"pont2-prim-select-content\", SelectContent);\ndefine(\"pont2-prim-select-item\", SelectItem);\ndefine(\"pont2-prim-select-group\", SelectGroup);\ndefine(\"pont2-prim-select-label\", SelectLabel);\ndefine(\"pont2-prim-select-separator\", SelectSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-select\": Select;\n \"pont2-prim-select-trigger\": SelectTrigger;\n \"pont2-prim-select-content\": SelectContent;\n \"pont2-prim-select-item\": SelectItem;\n \"pont2-prim-select-group\": SelectGroup;\n \"pont2-prim-select-label\": SelectLabel;\n \"pont2-prim-select-separator\": SelectSeparator;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId, uid } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOT = sel(\"combobox\");\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\n/**\n * # Combobox (single selection)\n *\n * shadcn: `<Combobox>` = Base UI `Combobox.Root` (a hidden `<input>` for\n * forms, nothing else) > `<ComboboxInput>` (InputGroup > `<input\n * role=combobox>` + addon > trigger/clear buttons) + `<ComboboxContent>`\n * (Portal > Positioner > Popup) > `<ComboboxList role=listbox>` > items,\n * `<ComboboxEmpty>`, groups.\n *\n * pont2:\n * ```html\n * <pont2-prim-combobox name=\"framework\"> coordinator + form-associated, display: contents\n * <pont2-prim-combobox-input placeholder=\"Select a framework\"></pont2-prim-combobox-input> is the InputGroup; renders the native input + buttons\n * <pont2-prim-combobox-content> the popup: [popover]\n * <pont2-prim-combobox-empty>No items found.</pont2-prim-combobox-empty>\n * <pont2-prim-combobox-list> role=listbox\n * <pont2-prim-combobox-item value=\"next\">Next.js</pont2-prim-combobox-item>\n * </pont2-prim-combobox-list>\n * </pont2-prim-combobox-content>\n * </pont2-prim-combobox>\n * ```\n *\n * **Which element submits?** The root (a form-associated custom element)\n * submits `name` = the *selected item's value*, exactly what Base UI's hidden\n * input submits. The native `<input>` is the typing surface (IME, caret,\n * mobile keyboards, screen-reader combobox semantics) and has no `name`, so\n * the half-typed query never reaches the server.\n *\n * Focus stays in the input; the highlighted item is announced with\n * `aria-activedescendant` (virtual focus), as in Base UI.\n *\n * Not implemented yet: `multiple` with chips (`ComboboxChips`), async items,\n * `autoHighlight`, creatable items. See docs/primitives/combobox.md.\n *\n * @tag pont2-prim-combobox\n * @attr value - selected value (initially: Base UI `defaultValue`)\n * @attr name, required, disabled, open\n * @fires input, change - the user picked (or cleared) a value\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class Combobox extends PopupRoot {\n static formAssociated = true;\n static override identity = \"combobox\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n name: { type: String, reflect: true },\n required: { type: Boolean, reflect: true },\n query: { state: true },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare name: string;\n declare required: boolean;\n /** What the user typed since the popup opened; filters the items. */\n declare query: string;\n declare protected formDisabled: boolean;\n\n /** The virtually focused item. */\n highlighted: ComboboxItem | null = null;\n\n constructor() {\n super();\n this.value = \"\";\n this.name = \"\";\n this.required = false;\n this.query = \"\";\n this.formDisabled = false;\n this.addEventListener(\"click\", e => {\n if (e.target === this) this.inputElement?.focus(); // <label for> on the root\n });\n }\n\n /* ---------------- parts ---------------- */\n\n get inputHost(): ComboboxInput | null {\n return ownQuery<ComboboxInput>(this, sel(\"combobox-input\"), ROOT);\n }\n get inputElement(): HTMLInputElement | null {\n return this.inputHost?.control ?? null;\n }\n /** The input is the combobox element: it gets aria-expanded/controls and receives focus back. */\n get triggerElement(): HTMLInputElement | null {\n return this.inputElement;\n }\n get contentElement(): ComboboxContent | null {\n return ownQuery<ComboboxContent>(this, sel(\"combobox-content\"), ROOT);\n }\n get listElement(): ComboboxList | null {\n return ownQuery<ComboboxList>(this, sel(\"combobox-list\"), ROOT);\n }\n protected get popupKind() {\n return \"listbox\" as const;\n }\n protected override anchorElement(): Element | null {\n return this.inputHost;\n }\n protected override extraInsideElements(): (Element | null)[] {\n return [this.inputHost];\n }\n\n get allItems(): ComboboxItem[] {\n return Array.from(this.querySelectorAll<ComboboxItem>(sel(\"combobox-item\"))).filter(i => i.closest(ROOT) === this);\n }\n /** Items matching the current query. */\n get items(): ComboboxItem[] {\n return this.allItems.filter(i => isItemVisible(i));\n }\n get selectedItem(): ComboboxItem | null {\n return this.allItems.find(i => i.value === this.value) ?? null;\n }\n\n /* ---------------- form-associated API ---------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n formResetCallback(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n this.syncInputText();\n }\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n formStateRestoreCallback(state: string | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n /* ---------------- behaviour ---------------- */\n\n /** Base UI default filter: case- and accent-insensitive \"contains\". */\n static filter(label: string, query: string): boolean {\n const norm = (s: string) => s.normalize(\"NFD\").replace(/\\p{Diacritic}/gu, \"\").toLowerCase();\n return norm(label).includes(norm(query.trim()));\n }\n\n select(item: ComboboxItem | null): void {\n const value = item?.value ?? \"\";\n const changed = value !== this.value;\n this.value = value;\n this.query = \"\";\n this.syncInputText();\n if (changed) {\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n this.setOpen(false, \"item-press\");\n }\n\n /** Show the selected item's label in the input (after select/close/reset). */\n syncInputText(): void {\n const input = this.inputElement;\n if (input) input.value = this.selectedItem?.label ?? \"\";\n }\n\n highlight(item: ComboboxItem | null, scroll = true): void {\n if (this.highlighted === item) return;\n this.highlighted?.setHighlighted(false);\n this.highlighted = item;\n item?.setHighlighted(true);\n const input = this.inputElement;\n if (input) {\n if (item) input.setAttribute(\"aria-activedescendant\", ensureId(item, \"combobox-item\"));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n if (item && scroll) item.scrollIntoView({ block: \"nearest\" });\n }\n\n /** From the input: the user typed. */\n handleQuery(text: string): void {\n this.query = text;\n if (!this.open) this.setOpen(true, \"input-change\");\n // Keep the highlight only if it is still visible.\n this.applyFilter();\n if (this.highlighted && !isItemVisible(this.highlighted)) this.highlight(null);\n }\n\n /** From the input: keyboard. */\n handleKey(e: KeyboardEvent): void {\n if (this.isDisabled) return;\n const move = e.key === \"ArrowDown\" || e.key === \"ArrowUp\" ? keyToMove(e.key) : null;\n if (move) {\n e.preventDefault();\n if (!this.open) {\n this.setOpen(true, \"list-navigation\", { keyboard: true });\n this.applyFilter();\n }\n const items = this.items;\n const current = this.highlighted ? items.indexOf(this.highlighted) : -1;\n const next = moveIndex(items, current, move);\n this.highlight(next >= 0 ? items[next] : null);\n return;\n }\n if (e.key === \"Enter\" && this.open) {\n e.preventDefault(); // never submit the form while choosing\n if (this.highlighted && !isItemDisabled(this.highlighted)) this.select(this.highlighted);\n return;\n }\n if (e.key === \"Tab\" && this.open) this.setOpen(false, \"focus-out\");\n }\n\n /** Hide items (and empty groups) that do not match the query. */\n applyFilter(): void {\n const q = this.query;\n let visible = 0;\n for (const item of this.allItems) {\n const show = !q || Combobox.filter(item.label, q);\n item.hidden = !show;\n if (show) visible++;\n }\n for (const group of Array.from(this.querySelectorAll<HTMLElement>(sel(\"combobox-group\")))) {\n if (group.closest(ROOT) !== this) continue;\n group.hidden = !group.querySelector(`${sel(\"combobox-item\")}:not([hidden])`);\n }\n const empty = visible === 0;\n this.listElement?.toggleAttribute(\"data-empty\", empty);\n this.contentElement?.toggleAttribute(\"data-empty\", empty);\n this.contentElement?.reposition();\n }\n\n override wire(): void {\n super.wire();\n const input = this.inputElement;\n const list = this.listElement;\n if (input && list) input.setAttribute(\"aria-controls\", ensureId(list, \"combobox-list\"));\n if (input) {\n const ids = Array.from(this.internals.labels as NodeListOf<HTMLElement>).map(l => ensureId(l, \"combobox-label\"));\n if (ids.length && !input.hasAttribute(\"aria-label\")) input.setAttribute(\"aria-labelledby\", ids.join(\" \"));\n }\n }\n\n protected override afterOpen(): void {\n this.applyFilter();\n if (this.openedByKeyboard && !this.highlighted) {\n const sel = this.selectedItem;\n this.highlight(sel && isItemVisible(sel) ? sel : null);\n }\n }\n\n protected override afterClose(): void {\n this.highlight(null);\n this.query = \"\";\n this.syncInputText();\n // Unfiltered again for next time, once the exit animation is done.\n setTimeout(() => {\n if (!this.open) this.applyFilter();\n }, 200);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.setData(\"disabled\", this.isDisabled);\n this.internals.setFormValue(this.value || null);\n if (this.required && !this.value) {\n this.internals.setValidity({ valueMissing: true }, \"Please select an item in the list.\", this.inputElement ?? undefined);\n } else {\n this.internals.setValidity({});\n }\n if (changed.has(\"value\")) {\n for (const item of this.allItems) item.requestUpdate();\n if (changed.get(\"value\") === undefined) queueMicrotask(() => this.syncInputText());\n }\n if (changed.has(\"disabled\") || changed.has(\"formDisabled\")) this.inputHost?.requestUpdate();\n }\n}\n\n/* ==================================================================== */\n\n/**\n * shadcn `ComboboxInput`: an InputGroup holding the native `<input>` and an\n * inline-end addon with the trigger (and optionally clear) button. The host\n * **is** the InputGroup (`role=group`, `data-slot=\"input-group\"`); it renders\n * the input and buttons because shadcn's ComboboxInput generates them too.\n *\n * ```\n * shadcn: div[data-slot=input-group] > input + div[data-slot=input-group-addon] > button[data-slot=input-group-button]\n * pont2: pont2-prim-combobox-input > input + div[data-slot=input-group-addon] > button[data-slot=input-group-button]\n * ```\n *\n * @tag pont2-prim-combobox-input\n * @attr placeholder\n * @attr show-trigger - default true; `=\"false\"` hides the chevron button\n * @attr show-clear - shows a clear (×) button while a value is selected\n */\nexport class ComboboxInput extends HostElement {\n static override identity = \"combobox-input\";\n static override slotName = \"input-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n placeholder: { type: String },\n showTrigger: { attribute: \"show-trigger\", converter: trueUnlessFalse },\n showClear: { type: Boolean, attribute: \"show-clear\" },\n };\n declare placeholder: string;\n declare showTrigger: boolean;\n declare showClear: boolean;\n\n private readonly inputId = uid(\"combobox-input\");\n\n constructor() {\n super();\n this.placeholder = \"\";\n this.showTrigger = true;\n this.showClear = false;\n }\n\n get root(): Combobox | null {\n return this.closest(ROOT);\n }\n get control(): HTMLInputElement | null {\n return this.querySelector(\":scope > input\");\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n protected override updated(): void {\n this.root?.wire();\n }\n\n private onInput = (e: Event) => this.root?.handleQuery((e.target as HTMLInputElement).value);\n private onKeyDown = (e: KeyboardEvent) => this.root?.handleKey(e);\n private onInputClick = () => {\n const root = this.root;\n if (root && !root.open) root.setOpen(true, \"trigger-press\");\n };\n private onFocusOut = (e: FocusEvent) => {\n const root = this.root;\n const to = e.relatedTarget as Node | null;\n if (!root?.open) return;\n if (to && (this.contains(to) || root.contentElement?.contains(to))) return;\n root.setOpen(false, \"focus-out\");\n };\n private onTrigger = () => {\n const root = this.root;\n if (!root) return;\n root.query = \"\";\n root.toggle(\"trigger-press\");\n this.control?.focus();\n };\n private onClear = () => {\n const root = this.root;\n if (!root) return;\n root.select(null);\n this.control?.focus();\n };\n private onAddonClick = (e: MouseEvent) => {\n // InputGroupAddon: clicks on the addon (not its buttons) focus the input.\n if (!(e.target as Element).closest(\"button\")) this.control?.focus();\n };\n\n override render() {\n const root = this.root;\n const disabled = !!root?.isDisabled;\n const hasValue = !!root?.value;\n return html`<input\n id=${this.inputId}\n data-pont2-combobox-input-control\n data-slot=\"input-group-control\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n placeholder=${this.placeholder || nothing}\n ?disabled=${disabled}\n aria-invalid=${root?.getAttribute(\"aria-invalid\") ?? nothing}\n @input=${this.onInput}\n @keydown=${this.onKeyDown}\n @click=${this.onInputClick}\n @focusout=${this.onFocusOut}\n /><div data-pont2-combobox-input-addon data-slot=\"input-group-addon\" data-align=\"inline-end\" role=\"group\" @click=${this.onAddonClick}>\n ${this.showTrigger && !(this.showClear && hasValue)\n ? html`<button\n type=\"button\"\n tabindex=\"-1\"\n data-pont2-button\n data-variant=\"ghost\"\n data-size=\"icon-xs\"\n data-slot=\"input-group-button\"\n data-combobox-trigger\n aria-label=\"Open\"\n ?disabled=${disabled}\n @mousedown=${(e: Event) => e.preventDefault()}\n @click=${this.onTrigger}\n >${icons.chevronDown()}</button>`\n : nothing}\n ${this.showClear && hasValue\n ? html`<button\n type=\"button\"\n data-pont2-button\n data-variant=\"ghost\"\n data-size=\"icon-xs\"\n data-slot=\"combobox-clear\"\n aria-label=\"Clear\"\n ?disabled=${disabled}\n @mousedown=${(e: Event) => e.preventDefault()}\n @click=${this.onClear}\n >${icons.x()}</button>`\n : nothing}\n </div>`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * The popup (Base UI `Combobox.Popup`, no role of its own: the list inside\n * is the listbox). Opens below the input, start-aligned, 6px away.\n *\n * @tag pont2-prim-combobox-content\n */\nexport class ComboboxContent extends PopupContent {\n static override identity = \"combobox-content\";\n static override slotName = \"combobox-content\";\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"start\";\n this.sideOffset = 6;\n // Keep focus in the input while the pointer interacts with the list.\n this.addEventListener(\"mousedown\", e => e.preventDefault());\n }\n}\n\n/** Base UI `Combobox.List` (`role=listbox`). @tag pont2-prim-combobox-list */\nexport class ComboboxList extends HostElement {\n static override identity = \"combobox-list\";\n static override slotName = \"combobox-list\";\n static override role = \"listbox\";\n}\n\n/**\n * Base UI `Combobox.Item` (`role=option`), host-as-root, never focused\n * (virtual focus). The check indicator is rendered after your content when\n * selected.\n *\n * @tag pont2-prim-combobox-item\n * @attr value, label, disabled\n */\nexport class ComboboxItem extends HostElement {\n static override identity = \"combobox-item\";\n static override slotName = \"combobox-item\";\n static override role = \"option\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"pointermove\", e => {\n if (e.pointerType !== \"touch\" && !this.disabled) this.root?.highlight(this, false);\n });\n this.addEventListener(\"click\", () => {\n if (!this.disabled) this.root?.select(this);\n });\n }\n\n get root(): Combobox | null {\n return this.closest(ROOT);\n }\n get selected(): boolean {\n return !!this.root && !!this.root.value && this.root.value === this.value;\n }\n get label(): string {\n if (this.hasAttribute(\"label\")) return this.getAttribute(\"label\")!;\n let t = \"\";\n for (const n of Array.from(this.childNodes)) {\n if (n instanceof Comment) continue; // lit-html part markers\n if (n instanceof Element && n.hasAttribute(\"data-pont2-combobox-item-indicator\")) continue;\n t += n.textContent ?? \"\";\n }\n return t.trim();\n }\n\n setHighlighted(on: boolean): void {\n this.setData(\"highlighted\", on);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n ensureId(this, \"combobox-item\");\n }\n\n protected override willUpdate(): void {\n const selected = this.selected;\n this.internals.ariaSelected = String(selected);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n this.setData(\"selected\", selected);\n this.setData(\"disabled\", this.disabled);\n }\n\n override render() {\n return this.selected\n ? html`<span data-pont2-combobox-item-indicator data-slot=\"combobox-item-indicator\">${icons.check()}</span>`\n : nothing;\n }\n}\n\n/** Base UI `Combobox.Empty`: shown only while no item matches. @tag pont2-prim-combobox-empty */\nexport class ComboboxEmpty extends HostElement {\n static override identity = \"combobox-empty\";\n static override slotName = \"combobox-empty\";\n override connectedCallback(): void {\n super.connectedCallback();\n // Announced politely when it appears (Base UI renders it with role=status).\n this.internals.role = \"status\";\n this.internals.ariaLive = \"polite\";\n }\n}\n\n/** Base UI `Combobox.Group`. @tag pont2-prim-combobox-group */\nexport class ComboboxGroup extends HostElement {\n static override identity = \"combobox-group\";\n static override slotName = \"combobox-group\";\n static override role = \"group\";\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"combobox-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(label, \"combobox-group-label\"));\n });\n }\n}\n\n/** Base UI `Combobox.GroupLabel`. @tag pont2-prim-combobox-label */\nexport class ComboboxLabel extends HostElement {\n static override identity = \"combobox-label\";\n static override slotName = \"combobox-label\";\n}\n\n/** Base UI `Combobox.Separator`; is-a Separator. @tag pont2-prim-combobox-separator */\nexport class ComboboxSeparator extends Separator {\n static override identity = \"combobox-separator\";\n static override slotName = \"combobox-separator\";\n}\n\ndefine(\"pont2-prim-combobox\", Combobox);\ndefine(\"pont2-prim-combobox-input\", ComboboxInput);\ndefine(\"pont2-prim-combobox-content\", ComboboxContent);\ndefine(\"pont2-prim-combobox-list\", ComboboxList);\ndefine(\"pont2-prim-combobox-item\", ComboboxItem);\ndefine(\"pont2-prim-combobox-empty\", ComboboxEmpty);\ndefine(\"pont2-prim-combobox-group\", ComboboxGroup);\ndefine(\"pont2-prim-combobox-label\", ComboboxLabel);\ndefine(\"pont2-prim-combobox-separator\", ComboboxSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-combobox\": Combobox;\n \"pont2-prim-combobox-input\": ComboboxInput;\n \"pont2-prim-combobox-content\": ComboboxContent;\n \"pont2-prim-combobox-list\": ComboboxList;\n \"pont2-prim-combobox-item\": ComboboxItem;\n \"pont2-prim-combobox-empty\": ComboboxEmpty;\n \"pont2-prim-combobox-group\": ComboboxGroup;\n \"pont2-prim-combobox-label\": ComboboxLabel;\n \"pont2-prim-combobox-separator\": ComboboxSeparator;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\n\nconst ROOT = sel(\"tooltip\");\n\n/**\n * # Tooltip\n *\n * shadcn: `<TooltipProvider delay={0}>` > `<Tooltip>` (Base UI `Tooltip.Root`,\n * renders nothing) > `<TooltipTrigger>` (a `<button>`) + `<TooltipContent>`\n * (Portal > Positioner > Popup > children + `<Tooltip.Arrow>`).\n *\n * pont2: no Provider (a per-root `delay`, default 0 like shadcn's provider);\n * the arrow is the content's `::before`, so the popup is one node.\n *\n * ```html\n * <pont2-prim-tooltip>\n * <pont2-prim-tooltip-trigger><button data-pont2-button data-variant=\"outline\">Hover</button></pont2-prim-tooltip-trigger>\n * <pont2-prim-tooltip-content>Add to library</pont2-prim-tooltip-content>\n * </pont2-prim-tooltip>\n * ```\n *\n * Opens on pointer hover and on keyboard focus; closes on leave, blur,\n * Escape or press. The trigger is described by the content\n * (`aria-describedby`) while it is open.\n *\n * @tag pont2-prim-tooltip\n * @attr delay - ms before opening on hover (default 0)\n * @attr close-delay - ms before closing (default 0)\n */\nexport class Tooltip extends PopupRoot {\n static override identity = \"tooltip\";\n\n static override properties: PropertyDeclarations = {\n delay: { type: Number },\n closeDelay: { type: Number, attribute: \"close-delay\" },\n };\n declare delay: number;\n declare closeDelay: number;\n\n private timer = 0;\n\n constructor() {\n super();\n this.delay = 0;\n this.closeDelay = 0;\n }\n\n get triggerElement(): HTMLElement | null {\n return ownQuery<TooltipTrigger>(this, tags(\"tooltip-trigger\"), ROOT)?.control ?? null;\n }\n get contentElement(): TooltipContent | null {\n return ownQuery<TooltipContent>(this, sel(\"tooltip-content\"), ROOT);\n }\n protected get popupKind() {\n return \"true\" as const;\n }\n\n /** A tooltip is not a popup the trigger \"has\": no aria-haspopup/expanded, just a description. */\n override wire(): void {\n const content = this.contentElement;\n const trigger = this.triggerElement;\n if (content) {\n ensureId(content, \"tooltip\");\n content.onRequestClose = reason => this.setOpen(false, reason);\n content.anchorElement = () => this.triggerElement;\n content.insideElements = () => [];\n }\n if (trigger && content) {\n const ids = new Set((trigger.getAttribute(\"aria-describedby\") ?? \"\").split(/\\s+/).filter(Boolean));\n if (this.open) ids.add(content.id);\n else ids.delete(content.id);\n if (ids.size) trigger.setAttribute(\"aria-describedby\", [...ids].join(\" \"));\n else trigger.removeAttribute(\"aria-describedby\");\n trigger.toggleAttribute(\"data-popup-open\", this.open);\n }\n }\n\n schedule(open: boolean, reason: \"trigger-hover\" | \"trigger-focus\" | \"focus-out\"): void {\n clearTimeout(this.timer);\n const ms = open ? this.delay : this.closeDelay;\n if (ms <= 0) this.setOpen(open, reason);\n else this.timer = window.setTimeout(() => this.setOpen(open, reason), ms);\n }\n\n // Focus stays where it is: a tooltip never takes focus.\n protected override afterClose(): void {}\n}\n\n/** @tag pont2-prim-tooltip-trigger */\nexport class TooltipTrigger extends PopupTrigger {\n static override rootTag = ROOT;\n static override controlSlot = \"tooltip-trigger\";\n\n constructor() {\n super();\n this.addEventListener(\"pointerenter\", e => {\n if (e.pointerType !== \"touch\") (this.root as Tooltip | null)?.schedule(true, \"trigger-hover\");\n });\n this.addEventListener(\"pointerleave\", () => (this.root as Tooltip | null)?.schedule(false, \"trigger-hover\"));\n this.addEventListener(\"focusin\", e => {\n if ((e.target as Element).matches(\":focus-visible\")) (this.root as Tooltip | null)?.schedule(true, \"trigger-focus\");\n });\n this.addEventListener(\"focusout\", () => (this.root as Tooltip | null)?.schedule(false, \"focus-out\"));\n }\n\n /** Pressing the trigger closes the tooltip (Base UI), it never toggles it open. */\n protected override onClick(): void {\n const root = this.root;\n if (root?.open) root.setOpen(false, \"trigger-press\");\n }\n}\n\n/**\n * The tooltip popup (`role=tooltip`), `side=\"top\"` by default.\n *\n * @tag pont2-prim-tooltip-content\n * @cssprop --pont2-tooltip-bg, --pont2-tooltip-fg, --pont2-tooltip-radius - see docs/11-tokens.md (the arrow shares the background)\n * @cssprop --pont2-tooltip-max-width, --pont2-tooltip-padding-x, --pont2-tooltip-padding-y - sizes (defaults 20rem, 0.75rem, 0.375rem)\n */\nexport class TooltipContent extends PopupContent {\n static override identity = \"tooltip-content\";\n static override slotName = \"tooltip-content\";\n static override role = \"tooltip\";\n\n constructor() {\n super();\n this.side = \"top\";\n this.align = \"center\";\n this.sideOffset = 4;\n }\n}\n\ndefine(\"pont2-prim-tooltip\", Tooltip);\ndefine(\"pont2-prim-tooltip-trigger\", TooltipTrigger);\ndefine(\"pont2-prim-tooltip-content\", TooltipContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-tooltip\": Tooltip;\n \"pont2-prim-tooltip-trigger\": TooltipTrigger;\n \"pont2-prim-tooltip-content\": TooltipContent;\n }\n}\n\n","import { defineAlias } from \"../core/names\";\nimport { Badge } from \"../primitives/badge/badge\";\nimport { Pont2Button } from \"../primitives/button/button\";\nimport { Checkbox } from \"../primitives/checkbox/checkbox\";\nimport { Pont2Input } from \"../primitives/input/input\";\nimport { Kbd, KbdGroup } from \"../primitives/kbd/kbd\";\nimport { Pont2Label } from \"../primitives/label/label\";\nimport { NativeSelect } from \"../primitives/native-select/native-select\";\nimport { Separator } from \"../primitives/separator/separator\";\nimport { Skeleton } from \"../primitives/skeleton/skeleton\";\nimport { Slider } from \"../primitives/slider/slider\";\nimport { Spinner } from \"../primitives/spinner/spinner\";\nimport { Switch } from \"../primitives/switch/switch\";\nimport { Table } from \"../primitives/table/table\";\nimport { Pont2Textarea } from \"../primitives/textarea/textarea\";\n\n/**\n * # Kit aliases: primitives promoted to the kit surface unchanged\n *\n * Each line gives a primitive a second tag without the `prim` segment.\n * The alias is an empty subclass (see `defineAlias`), so it behaves, styles,\n * announces and submits exactly like the primitive.\n *\n * What may be aliased (docs/10-primitives-and-kit.md, \"Promotion rules\"):\n *\n * 1. **Whole families only.** Every tag a primitive folder defines is aliased\n * together, so kit markup never mixes `pont2-*` and `pont2-prim-*`.\n * 2. **Only families that can never get a same-name composite**, because\n * turning an alias into a composite later is a breaking change. In\n * practice: families with no structural children to abstract (a button,\n * an input, a switch). A family with title/description/item children\n * (Card, Field, Select…) stays primitive-only until it is decided whether\n * it gets a composite.\n * 3. The alias tag is listed in the primitive's CSS selectors, so it is\n * styled before upgrade like the primitive tag (guardrail-checked).\n */\ndefineAlias(\"pont2-badge\", Badge);\ndefineAlias(\"pont2-button\", Pont2Button);\ndefineAlias(\"pont2-checkbox\", Checkbox);\ndefineAlias(\"pont2-input\", Pont2Input);\ndefineAlias(\"pont2-kbd\", Kbd);\ndefineAlias(\"pont2-kbd-group\", KbdGroup);\ndefineAlias(\"pont2-label\", Pont2Label);\ndefineAlias(\"pont2-native-select\", NativeSelect);\ndefineAlias(\"pont2-separator\", Separator);\ndefineAlias(\"pont2-skeleton\", Skeleton);\ndefineAlias(\"pont2-slider\", Slider);\ndefineAlias(\"pont2-spinner\", Spinner);\ndefineAlias(\"pont2-switch\", Switch);\ndefineAlias(\"pont2-table\", Table);\ndefineAlias(\"pont2-textarea\", Pont2Textarea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-badge\": Badge;\n \"pont2-button\": Pont2Button;\n \"pont2-checkbox\": Checkbox;\n \"pont2-input\": Pont2Input;\n \"pont2-kbd\": Kbd;\n \"pont2-kbd-group\": KbdGroup;\n \"pont2-label\": Pont2Label;\n \"pont2-native-select\": NativeSelect;\n \"pont2-separator\": Separator;\n \"pont2-skeleton\": Skeleton;\n \"pont2-slider\": Slider;\n \"pont2-spinner\": Spinner;\n \"pont2-switch\": Switch;\n \"pont2-table\": Table;\n \"pont2-textarea\": Pont2Textarea;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { Alert, AlertDescription, AlertTitle } from \"../../primitives/alert/alert\";\n\nexport const ALERT_STATUSES = [\"default\", \"error\", \"warning\", \"success\", \"info\"] as const;\nexport type AlertStatus = (typeof ALERT_STATUSES)[number];\n\nconst STATUS_ICON: Record<AlertStatus, () => TemplateResult> = {\n default: icons.circleAlert,\n error: icons.circleX,\n warning: icons.triangleAlert,\n success: icons.circleCheck,\n info: icons.info,\n};\n\n/**\n * # `<pont2-alert>`: kit composite over `<pont2-prim-alert>`\n *\n * The props-driven form of shadcn's Alert, and pont2's version of the legacy\n * `pont-alert` (which composed `pont-callout`, the legacy shadcn alert).\n *\n * ```html\n * <pont2-alert status=\"error\" icon heading=\"Payment failed\"\n * description=\"Check your card details and try again.\"></pont2-alert>\n * ```\n *\n * renders exactly the DOM the primitive form produces:\n *\n * ```html\n * <pont2-alert data-pont2-alert data-slot=\"alert\" data-variant=\"destructive\" data-status=\"error\">\n * <svg …/>\n * <div data-pont2-alert-title data-slot=\"alert-title\">Payment failed</div>\n * <div data-pont2-alert-description data-slot=\"alert-description\">Check your…</div>\n * </pont2-alert>\n * ```\n *\n * - **It is a primitive Alert** (`extends Alert`): same identity, slot, recipe\n * and `variant`. Title and description are rendered as *parts* (plain divs\n * with the primitive's attributes), not nested elements.\n * - **What it adds** over shadcn: `status` (`error` maps to shadcn's\n * `destructive` variant; `warning`/`success`/`info` are coloured in\n * `@layer pont2.kit` with the `--pont2-sem-color-success|warning|info` tokens), a\n * status icon, and a status-appropriate role (`alert` for error/warning,\n * `status` otherwise, as the legacy `pont-alert` did). An author `role`\n * attribute still wins.\n * - **What it leaves out:** rich content (links, an action button). Use the\n * primitive form for those; a composite ignores author children.\n *\n * `heading` instead of `title`: `title` is a global HTML attribute that shows\n * a native tooltip, so the attribute would leak onto the whole alert.\n *\n * @tag pont2-alert\n * @attr status - default | error | warning | success | info\n * @attr heading - the alert title text\n * @attr description - the description text\n * @attr icon - show the status icon\n * @cssprop --pont2-alert-warning-fg, --pont2-alert-success-fg, --pont2-alert-info-fg - status colours (default the sem status colours)\n */\nexport class KitAlert extends Alert {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n status: { type: String, reflect: true },\n heading: { type: String },\n description: { type: String },\n icon: { type: Boolean, reflect: true },\n };\n\n declare status: AlertStatus;\n declare heading: string;\n declare description: string;\n declare icon: boolean;\n\n constructor() {\n super();\n this.status = \"default\";\n this.heading = \"\";\n this.description = \"\";\n this.icon = false;\n }\n\n protected override willUpdate(): void {\n const status = ALERT_STATUSES.includes(this.status) ? this.status : \"default\";\n // The primitive's `variant` stays its public styling contract; status drives it.\n this.variant = status === \"error\" ? \"destructive\" : \"default\";\n super.willUpdate();\n this.setData(\"status\", status);\n this.internals.role = status === \"error\" || status === \"warning\" ? \"alert\" : \"status\";\n }\n\n protected override render() {\n const status = ALERT_STATUSES.includes(this.status) ? this.status : \"default\";\n return html`${this.icon ? STATUS_ICON[status]() : nothing}${this.heading\n ? html`<div ${AlertTitle.part()}>${this.heading}</div>`\n : nothing}${this.description ? html`<div ${AlertDescription.part()}>${this.description}</div>` : nothing}`;\n }\n}\n\ndefine(\"pont2-alert\", KitAlert);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-alert\": KitAlert;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { Avatar, AvatarBadge, AvatarFallback } from \"../../primitives/avatar/avatar\";\n\n/** \"Ada Lovelace\" → \"AL\", \"ada\" → \"A\". At most two letters, upper-cased. */\nexport function initials(name: string): string {\n const words = name.trim().split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0], words[words.length - 1]] : words;\n return letters.map(w => Array.from(w)[0] ?? \"\").join(\"\").toLocaleUpperCase();\n}\n\n/**\n * # `<pont2-avatar>`: kit composite over `<pont2-prim-avatar>`\n *\n * ```html\n * <pont2-avatar src=\"/u/42.png\" alt=\"Ada Lovelace\" badge></pont2-avatar>\n * ```\n *\n * renders the primitive's DOM:\n *\n * ```html\n * <pont2-avatar data-pont2-avatar data-slot=\"avatar\" data-size=\"default\" data-image-loading-status=\"loaded\">\n * <img src=\"/u/42.png\" alt=\"Ada Lovelace\" data-pont2-avatar-image data-slot=\"avatar-image\">\n * <span data-pont2-avatar-fallback data-slot=\"avatar-fallback\">AL</span>\n * <span data-pont2-avatar-badge data-slot=\"avatar-badge\"></span>\n * </pont2-avatar>\n * ```\n *\n * - **It is a primitive Avatar** (`extends Avatar`): the primitive watches the\n * rendered `<img>` and swaps image and fallback on\n * `data-image-loading-status` as usual.\n * - **Fallback text:** `fallback`, else the initials of `alt`. When `alt` is\n * set the fallback is announced as an image named by `alt` (not as \"AL\"):\n * only one of image and fallback is ever displayed, so nothing is read twice.\n * - **Badge:** `badge` shows shadcn's status dot. For an icon inside the\n * badge, use the primitive form.\n *\n * @tag pont2-avatar\n * @attr src - image URL (no image is rendered without it)\n * @attr alt - image alternative text; also the source of the default initials\n * @attr fallback - fallback text (defaults to the initials of `alt`)\n * @attr size - default | sm | lg (primitive)\n * @attr badge - show the badge dot\n */\nexport class KitAvatar extends Avatar {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n src: { type: String },\n alt: { type: String },\n fallback: { type: String },\n badge: { type: Boolean, reflect: true },\n };\n\n declare src: string;\n declare alt: string;\n declare fallback: string;\n declare badge: boolean;\n\n constructor() {\n super();\n this.src = \"\";\n this.alt = \"\";\n this.fallback = \"\";\n this.badge = false;\n }\n\n protected override render() {\n const text = this.fallback || initials(this.alt);\n return html`${this.src ? html`<img src=${this.src} alt=${this.alt} />` : nothing}<span\n ${AvatarFallback.part(this.alt ? { role: \"img\", \"aria-label\": this.alt } : {})}\n >${text}</span\n >${this.badge ? html`<span ${AvatarBadge.part()}></span>` : nothing}`;\n }\n}\n\ndefine(\"pont2-avatar\", KitAvatar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-avatar\": KitAvatar;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { InputOTP, InputOTPGroup, InputOTPSeparator } from \"../../primitives/input-otp/input-otp\";\n\n/** `groupSizes(6, 3)` → `[3, 3]`; `groupSizes(7, 3)` → `[3, 3, 1]`; size ≤ 0 → one group. */\nexport function groupSizes(length: number, size: number): number[] {\n const n = Math.max(0, Math.floor(length));\n const g = Math.floor(size);\n if (!(g > 0) || g >= n) return n ? [n] : [];\n const out: number[] = [];\n for (let left = n; left > 0; left -= g) out.push(Math.min(g, left));\n return out;\n}\n\n/**\n * The slot structure for `length` characters: groups of `groupSize` (one group\n * when 0), separators between groups when `separator`. Groups and separators\n * are parts; slots are `pont2-prim-input-otp-slot` elements (they have\n * behaviour). Shared with the OTP field (kit/otp-field).\n */\nexport function otpGroups(length: number, groupSize: number, separator: boolean) {\n let index = 0;\n return groupSizes(length, groupSize).map((n, g) => {\n const slots = Array.from({ length: n }, () => {\n const i = index++;\n return html`<pont2-prim-input-otp-slot index=${i}></pont2-prim-input-otp-slot>`;\n });\n const sep = g > 0 && separator ? html`<div ${InputOTPSeparator.part()}>${icons.minus()}</div>` : nothing;\n return html`${sep}<div ${InputOTPGroup.part()}>${slots}</div>`;\n });\n}\n\n/**\n * # `<pont2-input-otp>`: kit composite over `<pont2-prim-input-otp>`\n *\n * ```html\n * <pont2-input-otp name=\"code\" maxlength=\"6\" group-size=\"3\" separator aria-label=\"Verification code\"></pont2-input-otp>\n * ```\n *\n * renders the primitive's DOM, which is shadcn's:\n *\n * ```html\n * <pont2-input-otp data-pont2-input-otp …>\n * <div data-pont2-input-otp-group data-slot=\"input-otp-group\">\n * <pont2-prim-input-otp-slot index=\"0\"></pont2-prim-input-otp-slot> ×3\n * </div>\n * <div data-pont2-input-otp-separator data-slot=\"input-otp-separator\" role=\"separator\"><svg/></div>\n * <div data-pont2-input-otp-group …> …×3 </div>\n * <div data-pont2-input-otp-input-wrapper><input data-slot=\"input-otp\" autocomplete=\"one-time-code\" …></div>\n * </pont2-input-otp>\n * ```\n *\n * - **It is a primitive InputOTP** (`extends InputOTP`): the one native input,\n * form participation, paste cleaning, `pont2-complete` and every primitive\n * attribute (`maxlength`, `pattern`, `value`, `name`, `required`,\n * `disabled`, `aria-*`) work unchanged.\n * - **What it adds:** the slots are generated from `maxlength`, split into\n * groups of `group-size` (one group when absent), with a separator between\n * groups when `separator` is set.\n * - Groups and separators are **parts** (plain divs). Slots are rendered as\n * `pont2-prim-input-otp-slot` **elements**, because each slot has behaviour\n * (it draws its character and the fake caret from state the root pushes in).\n *\n * @tag pont2-input-otp\n * @attr group-size - characters per group (default: all in one group)\n * @attr separator - draw a separator between groups\n */\nexport class KitInputOTP extends InputOTP {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n groupSize: { type: Number, attribute: \"group-size\" },\n separator: { type: Boolean },\n };\n\n declare groupSize: number;\n declare separator: boolean;\n\n constructor() {\n super();\n this.groupSize = 0;\n this.separator = false;\n }\n\n override render() {\n // The primitive renders the native input last, where input-otp puts it.\n return html`${otpGroups(this.maxLength, this.groupSize, this.separator)}${super.render()}`;\n }\n}\n\ndefine(\"pont2-input-otp\", KitInputOTP);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-input-otp\": KitInputOTP;\n }\n}\n","import { html, svg, type SVGTemplateResult } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\n\n/**\n * Sign-in providers: display names and brand marks.\n *\n * The marks are Simple Icons (https://simpleicons.org, CC0-1.0), the same\n * geometry the legacy kit ships (src/components/renderers/auth/button/\n * button.defs.ts). pont2 keeps its own copy because it imports nothing from\n * the legacy kit (docs/08-parallel-constraints.md).\n */\nexport const AUTH_PROVIDERS = [\"apple\", \"discord\", \"facebook\", \"github\", \"google\", \"linkedin\", \"meta\", \"microsoft\", \"x\"] as const;\nexport type AuthProvider = (typeof AUTH_PROVIDERS)[number];\n\nexport const PROVIDER_NAMES: Record<AuthProvider, string> = {\n apple: \"Apple\",\n discord: \"Discord\",\n facebook: \"Facebook\",\n github: \"GitHub\",\n google: \"Google\",\n linkedin: \"LinkedIn\",\n meta: \"Meta\",\n microsoft: \"Microsoft\",\n x: \"X\",\n};\n\nconst MARKS: Record<AuthProvider, SVGTemplateResult> = {\n apple: svg`<path d=\"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701\" />`,\n discord: svg`<path d=\"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z\" />`,\n facebook: svg`<path d=\"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z\" />`,\n github: svg`<path d=\"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\" />`,\n google: svg`<path d=\"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z\" />`,\n linkedin: svg`<path d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z\" />`,\n meta: svg`<path d=\"M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z\" />`,\n microsoft: svg`<path d=\"M11.4 24H0V12.6h11.4V24zM24 24H12.6V12.6H24V24zM11.4 11.4H0V0h11.4v11.4zM24 11.4H12.6V0H24v11.4z\" />`,\n x: svg`<path d=\"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.763l7.726-8.835L1.254 2.25H8.08l4.713 6.231 5.45-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z\" />`,\n};\n\nexport const isAuthProvider = (p: unknown): p is AuthProvider => AUTH_PROVIDERS.includes(p as AuthProvider);\n\n/** A provider's brand mark as an `<svg>` (filled with `currentColor`, aria-hidden). */\nexport function providerIcon(provider: AuthProvider, extra: AttrMap = {}) {\n return html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n data-provider-icon=${provider}\n ${attrs(extra)}\n >${MARKS[provider]}</svg>`;\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { ButtonBase, type ButtonOptions } from \"../../primitives/button/button\";\nimport { Spinner } from \"../../primitives/spinner/spinner\";\nimport { PROVIDER_NAMES, isAuthProvider, providerIcon, type AuthProvider } from \"./providers\";\n\nexport { AUTH_PROVIDERS, PROVIDER_NAMES, providerIcon, type AuthProvider } from \"./providers\";\n\n/** What the button shows: the legacy kit's `content` prop. */\nexport const AUTH_BUTTON_CONTENTS = [\"label\", \"icon-label\", \"icon\"] as const;\nexport type AuthButtonContent = (typeof AUTH_BUTTON_CONTENTS)[number];\nexport type AuthButtonIconAlign = \"start\" | \"end\";\n\n/**\n * # AuthButton: the shared base of the auth-flow buttons\n *\n * An auth button **is a Button** (`extends ButtonBase`: variant, size,\n * disabled, type… inherited, nothing forwarded) and **has action behaviour**\n * (`ActionController`: the `pont2-action` request/response protocol, see\n * core/controllers/action.ts). Its DOM is the button primitive's:\n *\n * ```html\n * <pont2-provider-button provider=\"google\" data-pont2-shell> ← display: contents\n * <button data-pont2-button data-slot=\"button\" data-variant=\"outline\" data-provider=\"google\" type=\"button\">\n * <svg data-icon=\"inline-start\" …/>Continue with Google\n * </button>\n * </pont2-provider-button>\n * ```\n *\n * Two nodes; the legacy `pont-provider-button > pont-button > button` has three.\n *\n * While busy (a `respondWith()` promise is pending, or `loading` is set) the\n * button shows a spinner in place of its icon, sets `aria-busy`, and is\n * disabled *focusably* (`aria-disabled`, Base UI's `focusableWhenDisabled`),\n * so keyboard focus is not lost mid-request and a second press is ignored.\n *\n * Subclasses provide the default copy, the icon, and what a press does.\n */\nexport abstract class AuthButton extends ButtonBase {\n static override composite = true;\n\n // Lit merges these with ButtonBase's (variant, size, disabled, type …).\n static override properties: PropertyDeclarations = {\n content: { type: String },\n iconAlign: { type: String, attribute: \"icon-align\" },\n label: { type: String },\n event: { type: String },\n loading: { type: Boolean, reflect: true },\n };\n\n /**\n * `label` (default), `icon-label` or `icon` (icon only; the label becomes the\n * accessible name). Icon-only keeps the text size, as shadcn's login blocks\n * do: at the default size it is already near-square (38×36px, as shadcn's),\n * and it can still stretch to fill a grid cell (`w-full`). Set\n * `size=\"icon\"` for a fixed square.\n */\n declare content: AuthButtonContent;\n declare iconAlign: AuthButtonIconAlign;\n /** Visible text (and accessible name). Each button has a default. */\n declare label: string;\n /** The action requested on press (a login-flow event id). */\n declare event: string | undefined;\n /** Busy state set by the owner, in addition to a pending `respondWith()`. */\n declare loading: boolean;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.content = \"label\";\n this.iconAlign = \"start\";\n this.label = \"\";\n this.event = undefined;\n this.loading = false;\n }\n\n /** True while a request is pending or `loading` is set. */\n get busy(): boolean {\n return this.loading || this.action.busy;\n }\n\n /** The text used when `label` is empty. */\n protected abstract defaultLabel(): string;\n /** The button's icon, with the attributes shadcn's button CSS keys on. */\n protected abstract renderIcon(attrs: Record<string, string>): TemplateResult | typeof nothing;\n /** Data sent with the `pont2-action` request. */\n protected actionData(): Record<string, unknown> {\n return {};\n }\n /** What a press does. The default requests the action. */\n protected onPress(_e: MouseEvent): void {\n this.action.request(this.event, this.actionData());\n }\n\n protected get text(): string {\n return this.label || this.defaultLabel();\n }\n\n protected override buttonOptions(): ButtonOptions {\n const base = super.buttonOptions();\n const iconOnly = this.content === \"icon\";\n const busy = this.busy;\n return {\n ...base,\n disabled: base.disabled || busy,\n // Busy is a transient disabled state: keep focus where the user left it.\n focusableWhenDisabled: base.focusableWhenDisabled || (busy && !base.disabled),\n attrs: {\n \"data-event\": this.event,\n \"data-loading\": busy,\n \"aria-busy\": busy ? \"true\" : null,\n \"aria-label\": iconOnly ? this.text : null,\n ...this.extraAttrs(),\n },\n onClick: e => this.onPress(e),\n };\n }\n\n /** Extra attributes for the native button (`data-provider` …). */\n protected extraAttrs(): Record<string, string | boolean | null | undefined> {\n return {};\n }\n\n protected override renderContent() {\n const showIcon = this.content !== \"label\";\n const showLabel = this.content !== \"icon\";\n // The icon slot holds the spinner while busy, even for label-only buttons.\n const slot = this.content === \"icon\" ? null : this.iconAlign === \"end\" ? \"inline-end\" : \"inline-start\";\n const mark = (a: Record<string, string>) =>\n this.busy\n ? html`<span ${Spinner.part({ ...a, role: false, \"aria-hidden\": \"true\" })}></span>`\n : showIcon\n ? this.renderIcon(a)\n : nothing;\n const icon = mark(slot ? { \"data-icon\": slot } : {});\n return this.iconAlign === \"end\"\n ? html`${showLabel ? this.text : nothing}${icon}`\n : html`${icon}${showLabel ? this.text : nothing}`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-provider-button>`: sign in with an identity provider\n *\n * ```html\n * <pont2-provider-button provider=\"google\" event=\"oauth_google\"></pont2-provider-button>\n * ```\n *\n * Defaults: `variant=\"outline\"`, `content=\"icon-label\"`, label\n * \"`prompt` + provider name\" (\"Continue with Google\"). Pressing requests\n * `event` with `{ provider }` (see AuthButton).\n *\n * @tag pont2-provider-button\n * @attr provider - apple | discord | facebook | github | google | linkedin | meta | microsoft | x\n * @attr prompt - text before the provider name in the default label (default \"Continue with\")\n * @attr label - replaces the whole default label\n * @attr event - the action requested on press\n * @attr content - label | icon-label (default) | icon\n * @attr icon-align - start (default) | end\n * @attr loading - busy state set by the owner\n * @fires pont2-action - `{ action, data: { provider }, respondWith }` on press\n * @fires pont2-action-success - `{ action, data, result }`\n * @fires pont2-action-error - `{ action, data, error, message }`\n */\nexport class ProviderButton extends AuthButton {\n static override properties: PropertyDeclarations = {\n provider: { type: String, reflect: true },\n prompt: { type: String },\n };\n\n declare provider: AuthProvider;\n declare prompt: string;\n\n constructor() {\n super();\n this.variant = \"outline\";\n this.content = \"icon-label\";\n this.prompt = \"Continue with\";\n }\n\n protected defaultLabel(): string {\n const name = isAuthProvider(this.provider) ? PROVIDER_NAMES[this.provider] : (this.provider ?? \"\");\n return `${this.prompt || \"Continue with\"} ${name}`.trim();\n }\n\n protected renderIcon(a: Record<string, string>) {\n return isAuthProvider(this.provider) ? providerIcon(this.provider, a) : nothing;\n }\n\n protected override actionData() {\n return { provider: this.provider };\n }\n\n protected override extraAttrs() {\n return { \"data-provider\": this.provider };\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-passkey-button>`: sign in with a passkey\n *\n * ```html\n * <pont2-passkey-button event=\"passkey_login\"></pont2-passkey-button>\n * ```\n *\n * Defaults: `variant=\"secondary\"`, `content=\"label\"`, label \"Continue with\n * Passkey\", icon lucide `user-round-key`. Pressing requests `event`.\n *\n * The listener must start the WebAuthn call synchronously (call\n * `respondWith()` with the promise straight away). The request is dispatched\n * inside the click, so the call keeps the user activation that\n * `navigator.credentials.get()` needs in Safari.\n *\n * @tag pont2-passkey-button\n * @attr label, event, content, icon-align, loading - see ProviderButton\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class PasskeyButton extends AuthButton {\n constructor() {\n super();\n this.variant = \"secondary\";\n }\n\n protected defaultLabel(): string {\n return \"Continue with Passkey\";\n }\n\n protected renderIcon(a: Record<string, string>) {\n return icons.userRoundKey(a);\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-submit-button>`: submit an auth form\n *\n * ```html\n * <form>\n * …fields…\n * <pont2-submit-button event=\"submit_password\"></pont2-submit-button>\n * </form>\n * ```\n *\n * A real `<button type=\"submit\">`, so the browser's own submission rules\n * apply: Enter in a field submits, constraint validation (`required`,\n * `type=\"email\"` …) blocks an invalid form, and `SubmitEvent.submitter` is\n * this button.\n *\n * When its form **submits** (not merely when it is clicked), the button\n * requests `event` with `{ form, formData }` (the FormData includes this\n * button's `name`/`value`, if any):\n *\n * - a listener calls `respondWith()` → the native submission is prevented\n * (the flow is handled in-page) and the button is busy until it settles;\n * - nobody responds → the form submits natively (progressive enhancement:\n * a plain `<form action>` still works).\n *\n * A submission without a submitter (`form.requestSubmit()`, e.g. an OTP\n * auto-submit) is handled by the form's **default button** (its first submit\n * button), as the browser does for implicit submission.\n *\n * Outside a form, a press requests the action directly.\n *\n * Defaults: `variant=\"default\"`, `content=\"label\"`, `icon-align=\"end\"`,\n * label \"Submit\", icon lucide `arrow-right`.\n *\n * @tag pont2-submit-button\n * @attr label, event, content, icon-align, loading - see ProviderButton\n * @fires pont2-action - `{ action, data: { form, formData }, respondWith }` on submit\n * @fires pont2-action-success, pont2-action-error\n */\nexport class SubmitButton extends AuthButton {\n constructor() {\n super();\n this.type = \"submit\";\n this.iconAlign = \"end\";\n }\n\n protected defaultLabel(): string {\n return \"Submit\";\n }\n\n protected renderIcon(a: Record<string, string>) {\n return icons.arrowRight(a);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Capture on the document: runs before the form's own submit listeners,\n // and catches implicit submission (Enter) where this is the default button.\n document.addEventListener(\"submit\", this.onSubmit, true);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"submit\", this.onSubmit, true);\n }\n\n protected override onPress(_e: MouseEvent): void {\n const c = this.control;\n // In a form, the submit event drives the request (after validation passes).\n if (c instanceof HTMLButtonElement && c.form && this.type === \"submit\") return;\n this.action.request(this.event, {});\n }\n\n private onSubmit = (e: SubmitEvent) => {\n const c = this.control;\n const form = c instanceof HTMLButtonElement ? c.form : null;\n if (!c || !form || form !== e.target) return;\n // A submit without a submitter (`form.requestSubmit()`, an OTP auto-submit)\n // belongs to the form's default button, as implicit submission does.\n const isDefault = !e.submitter && Array.from(form.elements).find(el => (el as HTMLButtonElement).type === \"submit\") === c;\n if (e.submitter !== c && !isDefault) return;\n if (this.busy) {\n e.preventDefault(); // a second submit while the first is pending\n return;\n }\n const formData = new FormData(form, c);\n if (this.action.request(this.event, { form, formData })) e.preventDefault();\n };\n}\n\ndefine(\"pont2-provider-button\", ProviderButton);\ndefine(\"pont2-passkey-button\", PasskeyButton);\ndefine(\"pont2-submit-button\", SubmitButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-provider-button\": ProviderButton;\n \"pont2-passkey-button\": PasskeyButton;\n \"pont2-submit-button\": SubmitButton;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues, type TemplateResult } from \"lit\";\n\nimport { fire } from \"../../core/events\";\nimport { uid } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { Field, FieldDescription, FieldError, fieldLabel } from \"../../primitives/field/field\";\nimport { input, type InputOptions } from \"../../primitives/input/input\";\n\n/* ==================================================================== */\n/* Messages */\n/* ==================================================================== */\n\nconst cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n\n/**\n * Default error copy, identical to the legacy kit's (field.defs.ts), so\n * existing screens read the same. Every message is overridable per field\n * (`required-error`, `format-error` …). Localised copy is expected from the\n * render spec / widget.\n */\nexport const fieldMessages = {\n required: (label: string) => `${cap(label)} is a required field.`,\n format: (label: string) => `Please enter a valid ${label.toLowerCase()}.`,\n minlength: (label: string, n?: number) =>\n n ? `${cap(label)} must be at least ${n} characters.` : `Please enter a longer ${label.toLowerCase()}.`,\n maxlength: (label: string, n?: number) =>\n n ? `${cap(label)} can have at most ${n} characters.` : `Please enter a shorter ${label.toLowerCase()}.`,\n};\n\n/* ==================================================================== */\n/* Types */\n/* ==================================================================== */\n\nexport type FieldIssueType = \"required\" | \"minlength\" | \"maxlength\" | \"format\" | \"rule\" | \"match\" | \"incomplete\";\n\nexport interface FieldIssue {\n type: FieldIssueType;\n message: string;\n}\n\n/** `pont2-field-validate` detail. The value is deliberately not included (passwords). */\nexport interface FieldValidateDetail {\n name: string;\n valid: boolean;\n issues: FieldIssue[];\n}\n\n/** \"default\": every rule; \"simple\": `required` only (the legacy `validation` attribute). */\nexport type FieldValidationMode = \"default\" | \"simple\";\n\n/** Compiles a pattern source, preferring Unicode mode (needed for `\\p{L}`). */\nexport function compilePattern(source: string): RegExp | null {\n if (!source) return null;\n try {\n return new RegExp(source, \"u\");\n } catch {\n try {\n return new RegExp(source);\n } catch {\n return null;\n }\n }\n}\n\n/** Positive integers only (legacy: values ≤ 0 are ignored). */\nconst positive = { fromAttribute: (v: string | null) => (v != null && Number(v) > 0 ? Number(v) : undefined) };\n\n/* The first invalid field of a validation pass takes focus (see onInvalid). */\nlet focusClaimed = false;\n\n/* ==================================================================== */\n/* AuthField */\n/* ==================================================================== */\n\n/**\n * # AuthField: the shared base of the auth-flow text fields\n *\n * An auth field **is a Field** (`extends Field`: the host is shadcn's\n * `div[role=group][data-slot=field]`, styled by the field recipe, with\n * `data-invalid` / `data-disabled`) that renders its label, control,\n * description and error from properties, as parts:\n *\n * ```html\n * <pont2-email-field data-pont2-field data-slot=\"field\" data-orientation=\"vertical\" [data-invalid]>\n * <label data-pont2-label data-pont2-field-label data-slot=\"field-label\" for=\"…-input\">Email</label>\n * <input data-pont2-input data-slot=\"input\" id=\"…-input\" name=\"email\" type=\"email\"\n * autocomplete=\"email\" aria-describedby=\"…-description …-error\" [aria-invalid=\"true\"]>\n * <p data-pont2-field-description data-slot=\"field-description\" id=\"…-description\">…</p>\n * <div data-pont2-field-error data-slot=\"field-error\" role=\"alert\" id=\"…-error\">Please enter a valid email.</div>\n * </pont2-email-field>\n * ```\n *\n * **The native `<input name>` is the form control.** There is no hidden\n * input and no form-association: the form's own FormData, autofill and\n * password managers, `form.reset()` and `<fieldset disabled>` all work\n * natively.\n *\n * **Validation is the platform's.** The field computes its issues on every\n * change and mirrors the first into `input.setCustomValidity()`, so\n * `form.checkValidity()`, `:invalid` and interactive validation are always\n * right, and the submit button never sends an invalid form. The field cancels\n * the browser's bubble (`invalid` event) and shows its own error instead.\n * Errors are **shown** after the user commits a change (`change`), when the\n * form is submitted, or on `reportValidity()`; once shown they update live\n * while typing.\n *\n * **Normalisation** (trimming, lower-casing an email…) is applied to the\n * submitted value through the form's `formdata` event, without rewriting what\n * the user sees.\n *\n * Subclasses supply defaults and rules through the protected hooks.\n *\n * @fires pont2-field-validate - `{ name, valid, issues }` whenever validity is shown (change, submit, reportValidity)\n */\nexport abstract class AuthField extends Field {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n inputId: { type: String, attribute: \"input-id\" },\n name: { type: String },\n defaultValue: { type: String, attribute: \"value\" },\n label: { type: String },\n placeholder: { type: String },\n description: { type: String },\n mark: { type: String },\n caret: { type: Boolean },\n autocomplete: { type: String },\n required: { type: Boolean, reflect: true },\n validation: { type: String },\n pattern: { type: String },\n minlength: { attribute: \"minlength\", converter: positive },\n maxlength: { attribute: \"maxlength\", converter: positive },\n requiredError: { type: String, attribute: \"required-error\" },\n formatError: { type: String, attribute: \"format-error\" },\n minlengthError: { type: String, attribute: \"minlength-error\" },\n maxlengthError: { type: String, attribute: \"maxlength-error\" },\n current: { state: true },\n shown: { state: true },\n };\n\n /** `id` of the native input (generated when absent), for `<label for>` elsewhere. */\n declare inputId: string;\n /** Form-data key. Each field has a default (`email`, `password`, `login_id` …). */\n declare name: string;\n /** Initial value (the `value` attribute, as on a native input). `.value` is live. */\n declare defaultValue: string;\n declare label: string;\n declare placeholder: string;\n declare description: string;\n /** Text after the label, e.g. \"(optional)\". */\n declare mark: string;\n /** Show a `*` after the label when `required` (and no `mark`). */\n declare caret: boolean;\n declare autocomplete: string;\n declare required: boolean;\n declare validation: FieldValidationMode;\n /** Regex source for the format rule. Each field has a default where the legacy kit had one. */\n declare pattern: string;\n declare minlength: number | undefined;\n declare maxlength: number | undefined;\n declare requiredError: string;\n declare formatError: string;\n declare minlengthError: string;\n declare maxlengthError: string;\n\n declare protected current: string;\n /** Whether issues are displayed (after change / submit / reportValidity). */\n declare protected shown: boolean;\n\n private dirty = false;\n private generatedId = uid(\"auth-field\");\n private boundForm: HTMLFormElement | null = null;\n\n constructor() {\n super();\n this.inputId = \"\";\n this.name = \"\";\n this.defaultValue = \"\";\n this.label = \"\";\n this.placeholder = \"\";\n this.description = \"\";\n this.mark = \"\";\n this.caret = false;\n this.autocomplete = \"\";\n this.required = false;\n this.validation = \"default\";\n this.pattern = \"\";\n this.minlength = undefined;\n this.maxlength = undefined;\n this.requiredError = \"\";\n this.formatError = \"\";\n this.minlengthError = \"\";\n this.maxlengthError = \"\";\n this.current = \"\";\n this.shown = false;\n }\n\n /* ---------------------------------------------------------------- */\n /* Hooks for subclasses */\n /* ---------------------------------------------------------------- */\n\n protected abstract defaultName(): string;\n protected abstract defaultLabel(): string;\n protected inputType(): string {\n return \"text\";\n }\n protected defaultAutocomplete(): string {\n return \"\";\n }\n protected defaultPattern(): string {\n return \"\";\n }\n /** Extra attributes for the input (inputmode, autocapitalize, spellcheck …). */\n protected inputAttrs(): Record<string, string | boolean | null | undefined> {\n return {};\n }\n /** The submitted form of a raw value. Identity by default. */\n normalizeValue(raw: string): string {\n return raw;\n }\n /**\n * Rules for a non-empty value, after `required`. The default is the legacy\n * order: minlength, then maxlength, then the format pattern; first failure only.\n */\n protected valueIssues(value: string): FieldIssue[] {\n const label = this.text;\n if (this.minlength && value.length < this.minlength) {\n return [{ type: \"minlength\", message: this.minlengthError || fieldMessages.minlength(label, this.minlength) }];\n }\n if (this.maxlength && value.length > Math.max(this.maxlength, this.minlength ?? 0)) {\n return [{ type: \"maxlength\", message: this.maxlengthError || fieldMessages.maxlength(label, this.maxlength) }];\n }\n const re = compilePattern(this.pattern || this.defaultPattern());\n if (re && !re.test(value)) return [{ type: \"format\", message: this.formatError || fieldMessages.format(label) }];\n return [];\n }\n\n /* ---------------------------------------------------------------- */\n /* Public API */\n /* ---------------------------------------------------------------- */\n\n /** The native input. */\n get control(): HTMLInputElement | null {\n return this.querySelector<HTMLInputElement>(`input[data-auth-field-control]`);\n }\n\n /** The normalised value (what is submitted). */\n get value(): string {\n return this.normalizeValue(this.current);\n }\n set value(v: string) {\n this.dirty = true;\n this.setCurrent(String(v ?? \"\"));\n }\n\n /** The effective form-data key. */\n get fieldName(): string {\n return this.name || this.defaultName();\n }\n\n /** The effective label text. */\n get text(): string {\n return this.label || this.defaultLabel();\n }\n\n /** Current issues (empty when valid). Independent of whether they are shown. */\n get issues(): FieldIssue[] {\n return this.computeIssues();\n }\n\n checkValidity(): boolean {\n return this.computeIssues().length === 0;\n }\n\n /** Shows the field's errors (or clears them) and returns validity. Legacy name: `validate()`. */\n reportValidity(): boolean {\n this.show();\n return this.checkValidity();\n }\n\n validate(): boolean {\n return this.reportValidity();\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n /* ---------------------------------------------------------------- */\n /* Validation */\n /* ---------------------------------------------------------------- */\n\n protected computeIssues(): FieldIssue[] {\n if (this.disabled) return [];\n const value = this.normalizeValue(this.current);\n if (!value) {\n return this.required ? [{ type: \"required\", message: this.requiredError || fieldMessages.required(this.text) }] : [];\n }\n if (this.validation === \"simple\") return [];\n return this.valueIssues(value);\n }\n\n private show(): void {\n this.shown = true;\n const issues = this.computeIssues();\n fire<FieldValidateDetail>(this, \"pont2-field-validate\", { name: this.fieldName, valid: !issues.length, issues });\n }\n\n /* ---------------------------------------------------------------- */\n /* Events */\n /* ---------------------------------------------------------------- */\n\n protected onInput = (e: Event) => {\n this.dirty = true;\n this.setCurrent((e.target as HTMLInputElement).value);\n };\n\n /**\n * Sets the raw value and mirrors validity to the input **synchronously**:\n * code that submits in the same task (an OTP auto-submit, `requestSubmit()`\n * in an `input` listener) must not see the previous render's validity.\n */\n protected setCurrent(raw: string): void {\n this.current = raw;\n this.syncValidity();\n }\n\n protected syncValidity(): void {\n this.control?.setCustomValidity(this.computeIssues()[0]?.message ?? \"\");\n }\n\n protected onChange = () => this.show();\n\n private onInvalid = (e: Event) => {\n // Our inline error replaces the browser's bubble.\n e.preventDefault();\n this.show();\n if (!focusClaimed) {\n focusClaimed = true;\n this.control?.focus();\n // The pass fires one `invalid` per control, possibly with microtask\n // checkpoints in between, so release on the next task.\n setTimeout(() => (focusClaimed = false));\n }\n };\n\n private onFormData = (e: FormDataEvent) => {\n const c = this.control;\n if (!c || c.disabled || !c.name) return;\n e.formData.set(c.name, this.value);\n };\n\n protected onReset = () => {\n // `reset` fires before the controls are reset.\n setTimeout(() => {\n this.dirty = false;\n this.shown = false;\n this.current = this.control?.value ?? this.defaultValue;\n });\n };\n\n private bindForm(form: HTMLFormElement | null): void {\n if (form === this.boundForm) return;\n this.boundForm?.removeEventListener(\"formdata\", this.onFormData);\n this.boundForm?.removeEventListener(\"reset\", this.onReset);\n this.boundForm = form;\n form?.addEventListener(\"formdata\", this.onFormData);\n form?.addEventListener(\"reset\", this.onReset);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.bindForm(null);\n }\n\n /* ---------------------------------------------------------------- */\n /* Render */\n /* ---------------------------------------------------------------- */\n\n protected get controlId(): string {\n return this.inputId || `${this.id || this.generatedId}-input`;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) this.current = this.defaultValue ?? \"\";\n this.invalid = this.shown && this.computeIssues().length > 0;\n super.willUpdate(changed);\n }\n\n protected override updated(): void {\n const c = this.control;\n if (c) {\n // The platform's validity mirrors ours: blocks submission, drives :invalid.\n this.syncValidity();\n this.bindForm(c.form);\n }\n }\n\n /** Options for the control part; subclasses render it differently (password: input group). */\n protected controlOptions(describedBy: string | undefined): InputOptions {\n return {\n id: this.controlId,\n name: this.fieldName,\n type: this.inputType(),\n value: this.current,\n placeholder: this.placeholder || undefined,\n autocomplete: this.autocomplete || this.defaultAutocomplete() || undefined,\n required: this.required,\n disabled: this.disabled,\n invalid: this.invalid,\n describedBy,\n attrs: {\n \"data-auth-field-control\": true,\n // The default value, so form.reset() restores it natively.\n value: this.defaultValue || null,\n ...this.inputAttrs(),\n },\n onInput: this.onInput,\n onChange: this.onChange,\n };\n }\n\n protected renderControl(o: InputOptions): TemplateResult {\n return input(o);\n }\n\n protected renderLabel(): TemplateResult | typeof nothing {\n const mark = this.mark\n ? html`<span data-slot=\"field-mark\">${this.mark}</span>`\n : this.caret && this.required\n ? html`<span data-slot=\"field-mark\" data-caret aria-hidden=\"true\">*</span>`\n : nothing;\n return fieldLabel({ for: this.controlId }, html`${this.text}${mark}`);\n }\n\n protected renderError(id: string, issues: FieldIssue[]): TemplateResult {\n const messages = [...new Set(issues.map(i => i.message))];\n return html`<div ${FieldError.part({ id })}>${messages.length === 1\n ? messages[0]\n : html`<ul data-slot=\"field-error-list\">${messages.map(m => html`<li>${m}</li>`)}</ul>`}</div>`;\n }\n\n override render() {\n const id = this.controlId;\n const descId = `${id}-description`;\n const errId = `${id}-error`;\n const issues = this.shown ? this.computeIssues() : [];\n const describedBy = [this.description ? descId : \"\", issues.length ? errId : \"\"].filter(Boolean).join(\" \") || undefined;\n return html`${this.renderLabel()}${this.renderControl(this.controlOptions(describedBy))}${this.description\n ? html`<p ${FieldDescription.part({ id: descId })}>${this.description}</p>`\n : nothing}${issues.length ? this.renderError(errId, issues) : nothing}`;\n }\n\n /** The `invalid` event does not bubble, so it is listened to on the input itself. */\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"invalid\", this.onInvalid, true);\n }\n}\n\n/* ==================================================================== */\n/* Text fields */\n/* ==================================================================== */\n\n/**\n * `<pont2-email-field>`: `type=\"email\"`, `autocomplete=\"email\"`, name\n * `email`. Normalised to trimmed lower case. Format rule: the legacy pattern\n * `^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$`.\n *\n * @tag pont2-email-field\n */\nexport class EmailField extends AuthField {\n protected defaultName() {\n return \"email\";\n }\n protected defaultLabel() {\n return \"Email\";\n }\n protected override inputType() {\n return \"email\";\n }\n protected override defaultAutocomplete() {\n return \"email\";\n }\n protected override defaultPattern() {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.source;\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\n/**\n * `<pont2-phone-field>`: `type=\"tel\"`, `autocomplete=\"tel\"`, name `phone`.\n * Normalised by removing whitespace. Format rule: the legacy pattern.\n *\n * @tag pont2-phone-field\n */\nexport class PhoneField extends AuthField {\n protected defaultName() {\n return \"phone\";\n }\n protected defaultLabel() {\n return \"Phone\";\n }\n protected override inputType() {\n return \"tel\";\n }\n protected override defaultAutocomplete() {\n return \"tel\";\n }\n protected override defaultPattern() {\n return /^\\+?(\\d[\\d-.() ]+)?(\\([\\d-.() ]+\\))?[\\d-.() ]+\\d$/.source;\n }\n override normalizeValue(raw: string) {\n return raw.replace(/\\s+/g, \"\");\n }\n}\n\n/**\n * `<pont2-username-field>`: `autocomplete=\"username\"`, name `username`,\n * no autocapitalisation or spellcheck. Normalised to trimmed lower case.\n * Rules: `minlength`, `maxlength`, then the pattern `^[a-z0-9_]*$`.\n *\n * @tag pont2-username-field\n */\nexport class UsernameField extends AuthField {\n protected defaultName() {\n return \"username\";\n }\n protected defaultLabel() {\n return \"Username\";\n }\n protected override defaultAutocomplete() {\n return \"username\";\n }\n protected override defaultPattern() {\n return /^[a-z0-9_]*$/.source;\n }\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\n/**\n * `<pont2-name-field>`: `autocomplete=\"name\"`, name `name`. Normalised by\n * trimming and collapsing whitespace. Rules: `minlength`, `maxlength`, then\n * the Unicode pattern `^[\\p{L} .'-]*$` (letters in any script).\n *\n * @tag pont2-name-field\n */\nexport class NameField extends AuthField {\n protected defaultName() {\n return \"name\";\n }\n protected defaultLabel() {\n return \"Name\";\n }\n protected override defaultAutocomplete() {\n return \"name\";\n }\n protected override defaultPattern() {\n return /^[\\p{L} .'-]*$/u.source;\n }\n override normalizeValue(raw: string) {\n return raw.trim().replace(/\\s+/g, \" \");\n }\n}\n\nexport const IDENTIFIER_KINDS = [\"email\", \"phone\", \"username\"] as const;\nexport type IdentifierKind = (typeof IDENTIFIER_KINDS)[number];\n\n/** `[\"email\",\"phone\"]` → \"Email or phone\"; three → \"Email, phone, or username\" (legacy copy). */\nexport function identifierLabel(kinds: readonly IdentifierKind[]): string {\n if (!kinds.length) return \"Identifier\";\n const list =\n kinds.length === 1\n ? kinds[0]\n : kinds.length === 2\n ? `${kinds[0]} or ${kinds[1]}`\n : `${kinds.slice(0, -1).join(\", \")}, or ${kinds[kinds.length - 1]}`;\n return list.charAt(0).toUpperCase() + list.slice(1);\n}\n\n/**\n * `<pont2-identifier-field>`: the sign-in identifier (email, phone or\n * username), submitted as `login_id` (the platform's contract).\n *\n * `identifiers` (attribute: space- or comma-separated; property: array) picks\n * the label (\"Email or phone\") and the input type: `email` or `tel` when it\n * is exactly one of those, `text` otherwise. `autocomplete=\"username\"`, which\n * is what password managers look for next to a password. Normalised to\n * trimmed lower case. Rule: `required` only (no format), as in the legacy kit.\n *\n * @tag pont2-identifier-field\n * @attr identifiers - e.g. \"email phone username\"\n */\nexport class IdentifierField extends AuthField {\n static override properties: PropertyDeclarations = {\n identifiers: {\n converter: {\n fromAttribute: (v: string | null) =>\n (v ?? \"\")\n .split(/[\\s,]+/)\n .filter((k): k is IdentifierKind => IDENTIFIER_KINDS.includes(k as IdentifierKind)),\n },\n },\n };\n\n declare identifiers: IdentifierKind[];\n\n constructor() {\n super();\n this.identifiers = [];\n }\n\n protected defaultName() {\n return \"login_id\";\n }\n protected defaultLabel() {\n return identifierLabel(this.identifiers ?? []);\n }\n protected override inputType() {\n const k = this.identifiers ?? [];\n return k.length === 1 && k[0] === \"email\" ? \"email\" : k.length === 1 && k[0] === \"phone\" ? \"tel\" : \"text\";\n }\n protected override defaultAutocomplete() {\n return \"username\";\n }\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n protected override valueIssues() {\n return [];\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\ndefine(\"pont2-email-field\", EmailField);\ndefine(\"pont2-phone-field\", PhoneField);\ndefine(\"pont2-username-field\", UsernameField);\ndefine(\"pont2-name-field\", NameField);\ndefine(\"pont2-identifier-field\", IdentifierField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-email-field\": EmailField;\n \"pont2-phone-field\": PhoneField;\n \"pont2-username-field\": UsernameField;\n \"pont2-name-field\": NameField;\n \"pont2-identifier-field\": IdentifierField;\n }\n interface HTMLElementEventMap {\n \"pont2-field-validate\": CustomEvent<FieldValidateDetail>;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\nimport { InputGroup, InputGroupAddon, inputGroupButton, inputGroupInput } from \"../../primitives/input-group/input-group\";\nimport type { InputOptions } from \"../../primitives/input/input\";\nimport { AuthField, fieldMessages, type FieldIssue } from \"./auth-field\";\n\n/* ==================================================================== */\n/* Password rules */\n/* ==================================================================== */\n\nexport type PasswordRuleName = \"uppercase\" | \"lowercase\" | \"number\" | \"special\";\n\n/** A rule: a named one, or your own `pattern`, each with an optional message. */\nexport type PasswordRule = { name: PasswordRuleName; error?: string } | { pattern: string; error?: string };\n\n/** The legacy named patterns (field.defs.ts). */\nexport const PASSWORD_RULE_PATTERNS: Record<PasswordRuleName, RegExp> = {\n uppercase: /[A-Z]/,\n lowercase: /[a-z]/,\n number: /[0-9]/,\n special: /[!@#$%^&*()_=+{}[\\]|\\\\;:\"<>,./?-]/,\n};\n\nexport const DEFAULT_PASSWORD_RULES: PasswordRule[] = [\n { name: \"uppercase\", error: \"Must contain an uppercase letter.\" },\n { name: \"lowercase\", error: \"Must contain a lowercase letter.\" },\n { name: \"number\", error: \"Must contain a number.\" },\n { name: \"special\", error: \"Must contain a special character.\" },\n];\n\nconst ruleRegExp = (r: PasswordRule): RegExp | null => {\n if (\"name\" in r) return PASSWORD_RULE_PATTERNS[r.name] ?? null;\n try {\n return new RegExp(r.pattern, \"u\");\n } catch {\n return null;\n }\n};\n\n/** `rules` attribute: JSON, e.g. `rules='[{\"name\":\"number\"},{\"pattern\":\".{12,}\",\"error\":\"12+ characters\"}]'`. */\nconst rulesConverter = {\n fromAttribute: (v: string | null): PasswordRule[] => {\n if (v == null) return DEFAULT_PASSWORD_RULES;\n try {\n const parsed = JSON.parse(v);\n return Array.isArray(parsed) ? parsed : DEFAULT_PASSWORD_RULES;\n } catch {\n return DEFAULT_PASSWORD_RULES;\n }\n },\n};\n\n/* ==================================================================== */\n/* SecretField: the show/hide toggle shared by password and confirm */\n/* ==================================================================== */\n\nexport type SecretFieldVariant = \"toggle\" | \"simple\";\n\n/**\n * A field whose value is secret: `type=\"password\"`, and with\n * `variant=\"toggle\"` (default) a show/hide button, built as shadcn builds it,\n * from InputGroup parts:\n *\n * ```html\n * <div data-pont2-input-group data-slot=\"input-group\" role=\"group\">\n * <input data-pont2-input data-pont2-input-group-input data-slot=\"input-group-control\" type=\"password\" …>\n * <div data-pont2-input-group-addon data-slot=\"input-group-addon\" data-align=\"inline-end\" role=\"group\">\n * <button data-pont2-button data-pont2-input-group-button data-variant=\"ghost\" data-size=\"icon-xs\"\n * aria-label=\"Show password\" aria-pressed=\"false\" aria-controls=\"…-input\"><svg/></button>\n * </div>\n * </div>\n * ```\n *\n * The toggle is a *toggle button* (`aria-pressed`, a stable name), the\n * WAI-ARIA pattern, rather than a button whose name flips. The value is\n * never normalised.\n *\n * @attr variant - toggle (default) | simple\n * @attr show-label - the toggle's accessible name (default \"Show password\")\n */\nexport abstract class SecretField extends AuthField {\n static override properties: PropertyDeclarations = {\n variant: { type: String },\n showLabel: { type: String, attribute: \"show-label\" },\n revealed: { type: Boolean, reflect: true },\n };\n\n declare variant: SecretFieldVariant;\n declare showLabel: string;\n /** Whether the value is currently shown as text. */\n declare revealed: boolean;\n\n constructor() {\n super();\n this.variant = \"toggle\";\n this.showLabel = \"\";\n this.revealed = false;\n }\n\n protected override inputType() {\n return this.variant === \"toggle\" && this.revealed ? \"text\" : \"password\";\n }\n\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n\n private toggle = () => {\n this.revealed = !this.revealed;\n // Keep the caret where it was (the input is re-rendered with a new type).\n void this.updateComplete.then(() => this.control?.focus());\n };\n\n protected override renderControl(o: InputOptions): TemplateResult {\n if (this.variant !== \"toggle\") return super.renderControl(o);\n return html`<div ${InputGroup.part({ \"data-disabled\": this.disabled })}>\n ${inputGroupInput(o)}\n <div ${InputGroupAddon.part({ \"data-align\": \"inline-end\" })}>\n ${inputGroupButton(\n {\n size: \"icon-xs\",\n disabled: this.disabled,\n attrs: {\n \"aria-label\": this.showLabel || \"Show password\",\n \"aria-pressed\": String(this.revealed),\n \"aria-controls\": this.controlId,\n },\n onClick: this.toggle,\n },\n this.revealed ? icons.eyeOff() : icons.eye(),\n )}\n </div>\n </div>`;\n }\n}\n\n/* ==================================================================== */\n/* PasswordField */\n/* ==================================================================== */\n\n/**\n * # `<pont2-password-field>`\n *\n * `autocomplete=\"current-password\"` by default (set `new-password` on\n * sign-up screens), name `password`. Rules: `minlength`, `maxlength`, then\n * **every** `rules` entry; all failing rules are listed (shadcn's FieldError\n * list). Defaults are the legacy four: uppercase, lowercase, number, special.\n *\n * `forgot` adds a \"Forgot your password?\" link-styled button beside the label\n * (shadcn's login block layout). It requests `forgot-event` through the\n * action protocol (`pont2-action` with `data: { forgot: true }`), exactly\n * like the auth buttons, and is busy until the response settles.\n *\n * @tag pont2-password-field\n * @attr rules - JSON array of `{ name }` / `{ pattern }` rules with optional `error`; `rules=\"[]\"` disables them\n * @attr forgot - show the forgot-password link\n * @attr forgot-label - its text (default \"Forgot your password?\")\n * @attr forgot-event - the action it requests\n * @fires pont2-action, pont2-action-success, pont2-action-error - from the forgot link\n */\nexport class PasswordField extends SecretField {\n static override properties: PropertyDeclarations = {\n rules: { converter: rulesConverter },\n forgot: { type: Boolean },\n forgotLabel: { type: String, attribute: \"forgot-label\" },\n forgotEvent: { type: String, attribute: \"forgot-event\" },\n };\n\n declare rules: PasswordRule[];\n declare forgot: boolean;\n declare forgotLabel: string;\n declare forgotEvent: string | undefined;\n\n protected readonly forgotAction = new ActionController(this);\n\n constructor() {\n super();\n this.rules = DEFAULT_PASSWORD_RULES;\n this.forgot = false;\n this.forgotLabel = \"\";\n this.forgotEvent = undefined;\n }\n\n protected defaultName() {\n return \"password\";\n }\n protected defaultLabel() {\n return \"Password\";\n }\n protected override defaultAutocomplete() {\n return \"current-password\";\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n const label = this.text;\n if (this.minlength && value.length < this.minlength) {\n return [{ type: \"minlength\", message: this.minlengthError || fieldMessages.minlength(label, this.minlength) }];\n }\n if (this.maxlength && value.length > Math.max(this.maxlength, this.minlength ?? 0)) {\n return [{ type: \"maxlength\", message: this.maxlengthError || fieldMessages.maxlength(label, this.maxlength) }];\n }\n const failing = (this.rules ?? []).filter(r => {\n const re = ruleRegExp(r);\n return re ? !re.test(value) : false;\n });\n if (!failing.length) return [];\n const messages = failing.map(r => r.error).filter((m): m is string => !!m);\n return messages.length\n ? messages.map(message => ({ type: \"rule\" as const, message }))\n : [{ type: \"rule\", message: this.formatError || fieldMessages.format(label) }];\n }\n\n protected override renderLabel(): TemplateResult | typeof nothing {\n if (!this.forgot) return super.renderLabel();\n const busy = this.forgotAction.busy;\n return html`<div data-pont2-auth-field-label-row>\n ${super.renderLabel()}\n ${button(\n {\n variant: \"link\",\n size: \"sm\",\n slot: \"field-forgot\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: { \"data-event\": this.forgotEvent, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: () => this.forgotAction.request(this.forgotEvent, { forgot: true, name: this.fieldName }),\n },\n this.forgotLabel || \"Forgot your password?\",\n )}\n </div>`;\n }\n}\n\n/* ==================================================================== */\n/* ConfirmField */\n/* ==================================================================== */\n\n/**\n * # `<pont2-confirm-field>`: repeat a password\n *\n * Valid when its value equals the `pair` field's (default: the first\n * `pont2-password-field` in the same form, else in the document). It\n * re-validates as either changes. `autocomplete=\"new-password\"`, name\n * `confirm`. Unlike the legacy kit, the pair's value is never put in an event.\n *\n * @tag pont2-confirm-field\n * @attr pair - CSS selector of the field to match (default \"pont2-password-field\")\n * @attr match-error - default \"Passwords do not match.\"\n */\nexport class ConfirmField extends SecretField {\n static override properties: PropertyDeclarations = {\n pair: { type: String },\n matchError: { type: String, attribute: \"match-error\" },\n };\n\n declare pair: string;\n declare matchError: string;\n\n private scope: Document | HTMLFormElement | null = null;\n\n constructor() {\n super();\n this.pair = \"pont2-password-field\";\n this.matchError = \"\";\n }\n\n protected defaultName() {\n return \"confirm\";\n }\n protected defaultLabel() {\n return \"Confirm Password\";\n }\n protected override defaultAutocomplete() {\n return \"new-password\";\n }\n\n /** The element being matched (a pont2 field or any element with `.value`). */\n get pairElement(): (Element & { value?: string }) | null {\n const root = this.closest(\"form\") ?? document;\n return this.pair ? root.querySelector(this.pair) : null;\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n const other = this.pairElement?.value ?? \"\";\n return value === other ? [] : [{ type: \"match\", message: this.matchError || \"Passwords do not match.\" }];\n }\n\n // Re-validate when the pair changes (its input events bubble through the form).\n private onScopeInput = (e: Event) => {\n const pair = this.pairElement;\n if (pair && e.target instanceof Node && pair.contains(e.target)) this.requestUpdate();\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.scope = this.closest(\"form\") ?? document;\n this.scope.addEventListener(\"input\", this.onScopeInput);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.scope?.removeEventListener(\"input\", this.onScopeInput);\n this.scope = null;\n }\n}\n\ndefine(\"pont2-password-field\", PasswordField);\ndefine(\"pont2-confirm-field\", ConfirmField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-password-field\": PasswordField;\n \"pont2-confirm-field\": ConfirmField;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { define } from \"../../core/names\";\nimport type { InputOTP } from \"../../primitives/input-otp/input-otp\";\nimport { REGEXP_ONLY_DIGITS } from \"../../primitives/input-otp/otp\";\nimport type { InputOptions } from \"../../primitives/input/input\";\nimport { AuthField, type FieldIssue } from \"../auth-field/auth-field\";\nimport { otpGroups } from \"../input-otp/input-otp\";\n\n/** The legacy `pont-otp` layouts, kept for render-spec parity. */\nexport type OtpLayout = \"digits_only\" | \"simple\" | \"with_separator\" | \"with_spacing\";\n\n/**\n * # `<pont2-otp-field>`: a verification-code field\n *\n * ```html\n * <form>\n * <pont2-otp-field label=\"Verification code\" length=\"6\" layout=\"with_separator\" required></pont2-otp-field>\n * <pont2-submit-button event=\"verify_code\" label=\"Verify\"></pont2-submit-button>\n * </form>\n * ```\n *\n * **Is a Field** (`extends AuthField extends Field`) holding the Input OTP\n * primitive, as shadcn composes it (`<Field><FieldLabel/><InputOTP/>\n * <FieldDescription/></Field>`):\n *\n * ```html\n * <pont2-otp-field data-pont2-field data-slot=\"field\">\n * <label data-pont2-field-label for=\"…-input\">Verification code</label>\n * <pont2-prim-input-otp maxlength=\"6\" name=\"code\" input-id=\"…-input\" …>\n * <div data-pont2-input-otp-group …> <pont2-prim-input-otp-slot index=\"0\"> …×3 </div>\n * <div data-pont2-input-otp-separator …><svg/></div>\n * <div data-pont2-input-otp-group …> …×3 </div>\n * <div data-pont2-input-otp-input-wrapper><input autocomplete=\"one-time-code\" name=\"code\" …></div>\n * </pont2-prim-input-otp>\n * <div data-pont2-field-error role=\"alert\">Please enter the complete verification code.</div>\n * </pont2-otp-field>\n * ```\n *\n * The Input OTP is rendered as its **primitive element** (it has behaviour);\n * its groups and separators are parts, and its slots are elements (kit/input-otp).\n * Everything an auth field does applies: the one native\n * `autocomplete=\"one-time-code\"` input is the form control, validation is\n * native (`required`, then *incomplete*), errors are inline.\n *\n * **Auto-submit** (`auto-submit`): when every slot is filled,\n * - with `event`: requests it through the action protocol, with the same\n * `data: { form, formData }` shape as the submit button (so one flow\n * handler serves both);\n * - without `event`: submits the enclosing form (`form.requestSubmit()`), so\n * its submit button handles the request.\n *\n * @tag pont2-otp-field\n * @attr length - number of characters (default 6)\n * @attr layout - digits_only (one group, default) | simple (2 groups) | with_separator (3 groups) | with_spacing (one slot per group)\n * @attr group-size, separator - explicit grouping (override `layout`)\n * @attr pattern - per-character regex source (default digits; `pattern=\"\"` accepts anything)\n * @attr auto-submit - submit when complete\n * @attr event - the action requested on auto-submit\n * @attr incomplete-error - default \"Please enter the complete verification code.\"\n * @fires pont2-complete - from the Input OTP, `{ value }`\n * @fires pont2-action, pont2-action-success, pont2-action-error - on auto-submit with `event`\n */\nexport class OtpField extends AuthField {\n static override properties: PropertyDeclarations = {\n length: { type: Number },\n layout: { type: String },\n groupSize: { type: Number, attribute: \"group-size\" },\n separator: { type: Boolean },\n autoSubmit: { type: Boolean, attribute: \"auto-submit\" },\n event: { type: String },\n incompleteError: { type: String, attribute: \"incomplete-error\" },\n };\n\n declare length: number;\n declare layout: OtpLayout;\n declare groupSize: number | undefined;\n declare separator: boolean | undefined;\n declare autoSubmit: boolean;\n declare event: string | undefined;\n declare incompleteError: string;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.length = 6;\n this.layout = \"digits_only\";\n this.groupSize = undefined;\n this.separator = undefined;\n this.autoSubmit = false;\n this.event = undefined;\n this.incompleteError = \"\";\n this.pattern = REGEXP_ONLY_DIGITS;\n this.requiredError = \"\";\n // The input lives inside the Input OTP; its events bubble to us.\n this.addEventListener(\"input\", e => {\n if (e.target === this.control) this.onInput(e);\n });\n this.addEventListener(\"change\", e => {\n if (e.target === this.control) this.onChange();\n });\n this.addEventListener(\"pont2-complete\", e => this.onComplete(e.detail.value));\n }\n\n protected defaultName() {\n return \"code\";\n }\n protected defaultLabel() {\n return \"Code\";\n }\n\n /** The Input OTP primitive element. */\n get otp(): InputOTP | null {\n return this.querySelector(\"pont2-prim-input-otp\");\n }\n\n override get control(): HTMLInputElement | null {\n return this.otp?.input ?? null;\n }\n\n /** `true` while an auto-submit request is pending. */\n get busy(): boolean {\n return this.action.busy;\n }\n\n protected override computeIssues(): FieldIssue[] {\n if (this.disabled) return [];\n const value = this.current;\n if (!value) {\n return this.required ? [{ type: \"required\", message: this.requiredError || \"Code is required.\" }] : [];\n }\n if (this.validation === \"simple\") return [];\n return this.valueIssues(value);\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n return value.length === this.length\n ? []\n : [{ type: \"incomplete\", message: this.incompleteError || \"Please enter the complete verification code.\" }];\n }\n\n /** Group size and separators from `layout`, unless set explicitly. */\n get grouping(): { size: number; separator: boolean } {\n const n = this.length;\n const byLayout: Record<OtpLayout, { size: number; separator: boolean }> = {\n digits_only: { size: 0, separator: false },\n simple: { size: Math.ceil(n / 2), separator: true },\n with_separator: { size: Math.ceil(n / 3), separator: true },\n with_spacing: { size: 1, separator: false },\n };\n const base = byLayout[this.layout] ?? byLayout.digits_only;\n return { size: this.groupSize ?? base.size, separator: this.separator ?? base.separator };\n }\n\n private onComplete(value: string): void {\n this.setCurrent(value);\n if (!this.autoSubmit) return;\n const form = this.control?.form ?? null;\n if (this.event) {\n const formData = form ? new FormData(form) : new FormData();\n if (!form) formData.set(this.fieldName, value);\n this.action.request(this.event, { form, formData });\n } else {\n form?.requestSubmit();\n }\n }\n\n protected override onReset = () => {\n setTimeout(() => {\n const otp = this.otp;\n if (otp) otp.value = this.defaultValue;\n this.shown = false;\n this.current = this.defaultValue;\n });\n };\n\n protected override renderLabel(): TemplateResult | typeof nothing {\n // The label is optional for a code field; the input is then named by aria-label.\n return this.label ? super.renderLabel() : nothing;\n }\n\n protected override renderControl(o: InputOptions): TemplateResult {\n const { size, separator } = this.grouping;\n return html`<pont2-prim-input-otp\n input-id=${o.id!}\n name=${o.name ?? nothing}\n maxlength=${this.length}\n pattern=${this.pattern}\n value=${this.defaultValue || nothing}\n ?required=${this.required}\n ?disabled=${this.disabled}\n aria-label=${this.label ? nothing : \"Verification code\"}\n aria-describedby=${o.describedBy ?? nothing}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-busy=${this.busy ? \"true\" : nothing}\n >${otpGroups(this.length, size, separator)}</pont2-prim-input-otp\n >`;\n }\n}\n\ndefine(\"pont2-otp-field\", OtpField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-otp-field\": OtpField;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/**\n * # `<pont2-otp-resend>`: \"Resend code in 42s\", then a resend link\n *\n * ```html\n * <pont2-otp-resend event=\"resend_code\" duration=\"60\"></pont2-otp-resend>\n * ```\n *\n * ```html\n * <pont2-otp-resend data-pont2-otp-resend data-slot=\"otp-resend\">\n * <span data-slot=\"otp-resend-countdown\" role=\"timer\">Resend code in 42s</span>\n * ⟶ when it reaches 0:\n * <button data-pont2-button data-variant=\"link\" data-slot=\"otp-resend-button\" type=\"button\">Resend code</button>\n * </pont2-otp-resend>\n * ```\n *\n * The root is a plain row, so this is a new-name composite on `HostElement`\n * (06-higher-layers: layout renderers). The button is the button primitive's\n * part and requests `event` through the action protocol (`data: { resend:\n * true }`); the countdown restarts when it is pressed, as in the legacy kit.\n *\n * The countdown is `role=\"timer\"` (not announced every second). When it\n * ends, the button appears; focus is not moved.\n *\n * @tag pont2-otp-resend\n * @attr duration - seconds before the button appears (default 60; 0 shows it at once)\n * @attr event - the action requested on press\n * @attr label - button text (default \"Resend code\")\n * @attr countdown-text - text before the seconds (default \"Resend code in \")\n * @cssprop --pont2-otp-resend-fg - the row's text (default muted-foreground)\n * @cssprop --pont2-otp-resend-button-fg, --pont2-otp-resend-button-fg-hover - the link (default the row's colour; primary on hover)\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class OtpResend extends HostElement {\n static override identity = \"otp-resend\";\n static override slotName = \"otp-resend\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n duration: { type: Number },\n event: { type: String },\n label: { type: String },\n countdownText: { type: String, attribute: \"countdown-text\" },\n remaining: { state: true },\n };\n\n declare duration: number;\n declare event: string | undefined;\n declare label: string;\n declare countdownText: string;\n /** Seconds left. */\n declare remaining: number;\n\n protected readonly action = new ActionController(this);\n private timer: ReturnType<typeof setInterval> | undefined;\n\n constructor() {\n super();\n this.duration = 60;\n this.event = undefined;\n this.label = \"\";\n this.countdownText = \"\";\n this.remaining = 0;\n }\n\n /** Starts (or restarts) the countdown from `duration`. */\n restart(): void {\n this.stop();\n this.remaining = Math.max(0, Math.floor(this.duration || 0));\n if (this.remaining > 0) {\n this.timer = setInterval(() => {\n this.remaining = Math.max(0, this.remaining - 1);\n if (!this.remaining) this.stop();\n }, 1000);\n }\n }\n\n private stop(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.restart();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stop();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"duration\") && this.hasUpdated) this.restart();\n }\n\n private press = () => {\n this.action.request(this.event, { resend: true });\n this.restart();\n };\n\n override render() {\n if (this.remaining > 0) {\n return html`<span data-slot=\"otp-resend-countdown\" role=\"timer\"\n >${this.countdownText || \"Resend code in \"}${this.remaining}s</span\n >`;\n }\n const busy = this.action.busy;\n return button(\n {\n variant: \"link\",\n slot: \"otp-resend-button\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: { \"data-event\": this.event, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: this.press,\n },\n this.label || \"Resend code\",\n );\n }\n}\n\ndefine(\"pont2-otp-resend\", OtpResend);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-otp-resend\": OtpResend;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\nexport type LinkAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-link>`: \"Don't have an account? Sign up\"\n *\n * ```html\n * <pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>\n * <pont2-link label=\"Privacy policy\" href=\"/privacy\" target=\"_blank\"></pont2-link>\n * ```\n *\n * shadcn's login blocks write this as `<div class=\"text-center text-sm\">\n * Don't have an account? <a class=\"underline underline-offset-4\">Sign\n * up</a></div>`. pont2's host is that row; the link is the button\n * primitive's part:\n *\n * - **with `href`**: a real `<a href>` (navigation, middle-click, \"open in\n * new tab\" work), styled as a link;\n * - **otherwise**: a `<button type=\"button\">` that requests `event` through\n * the action protocol (`data: { service }`), busy until it settles, like\n * the auth buttons. The legacy `service=\"other\"` (no auth call) maps to:\n * don't set `event`, or don't respond.\n *\n * @tag pont2-link\n * @attr label - link text (default \"Link\")\n * @attr prompt - text before the link\n * @attr event - the action requested on press (button form)\n * @attr service - auth (default) | other: passed in the request's data\n * @attr href, target, rel - render a real link instead\n * @attr align - start | center (default) | end\n * @attr disabled, loading\n * @cssprop --pont2-link-fg - the row's text (default muted-foreground)\n * @cssprop --pont2-link-button-fg, --pont2-link-button-fg-hover - the link (default the row's colour; primary on hover)\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class Link extends HostElement {\n static override identity = \"link\";\n static override slotName = \"link\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n label: { type: String },\n prompt: { type: String },\n event: { type: String },\n service: { type: String },\n href: { type: String },\n target: { type: String },\n rel: { type: String },\n align: { type: String },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n };\n\n declare label: string;\n declare prompt: string;\n declare event: string | undefined;\n declare service: \"auth\" | \"other\";\n declare href: string | undefined;\n declare target: string | undefined;\n declare rel: string | undefined;\n declare align: LinkAlign;\n declare disabled: boolean;\n declare loading: boolean;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.label = \"\";\n this.prompt = \"\";\n this.event = undefined;\n this.service = \"auth\";\n this.href = undefined;\n this.target = undefined;\n this.rel = undefined;\n this.align = \"center\";\n this.disabled = false;\n this.loading = false;\n }\n\n get busy(): boolean {\n return this.loading || this.action.busy;\n }\n\n /** The native `<a>` or `<button>`. */\n get control(): HTMLAnchorElement | HTMLButtonElement | null {\n return this.querySelector(\"[data-pont2-button]\");\n }\n\n protected override willUpdate(_changed: PropertyValues): void {\n this.setData(\"align\", this.align || \"center\");\n }\n\n override render() {\n const busy = this.busy;\n return html`${this.prompt ? html`<span data-slot=\"link-prompt\">${this.prompt}</span>` : nothing}${button(\n {\n variant: \"link\",\n slot: \"link-button\",\n href: this.href,\n target: this.target,\n rel: this.rel ?? (this.target === \"_blank\" ? \"noopener noreferrer\" : undefined),\n disabled: this.disabled || busy,\n focusableWhenDisabled: busy && !this.disabled,\n attrs: { \"data-event\": this.event, \"data-service\": this.service, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: this.href === undefined ? () => this.action.request(this.event, { service: this.service }) : undefined,\n },\n this.label || \"Link\",\n )}`;\n }\n}\n\ndefine(\"pont2-link\", Link);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-link\": Link;\n }\n}\n","import { type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { FieldSeparator } from \"../../primitives/field/field\";\n\n/**\n * # `<pont2-divider>`: \"Or continue with\"\n *\n * ```html\n * <pont2-divider label=\"Or continue with\"></pont2-divider>\n * ```\n *\n * **Is a FieldSeparator** (`extends FieldSeparator`), as shadcn's login\n * blocks write it (`<FieldSeparator>Or continue with</FieldSeparator>`): one\n * node, the rule halves drawn by the primitive's `::before`/`::after`, the\n * label a text node. Without a label it is a plain rule\n * (`data-content=\"false\"`).\n *\n * @tag pont2-divider\n * @attr label - text in the middle\n */\nexport class Divider extends FieldSeparator {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n label: { type: String },\n };\n\n declare label: string;\n\n constructor() {\n super();\n this.label = \"\";\n }\n\n override render() {\n return this.label;\n }\n}\n\ndefine(\"pont2-divider\", Divider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-divider\": Divider;\n }\n}\n","import { html, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ShellElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type TitleLevel = \"1\" | \"2\" | \"3\" | \"4\";\nexport type TextAlign = \"auto\" | \"start\" | \"center\" | \"end\";\n\n/**\n * Title and subtitle: a heading and its supporting line.\n *\n * shadcn has no typography *components* (its typography page is classes), and\n * its login blocks write `<h1 class=\"text-2xl font-bold\">Welcome back</h1>\n * <p class=\"text-muted-foreground text-balance\">Login to your Acme Inc\n * account</p>`. pont2 keeps the **native** `<h1>`–`<h4>` / `<p>` (document\n * outline, heading navigation, reader modes), so these are Tier 3 shells:\n * the host has no box (`display: contents`), the native element is styled.\n *\n * The text comes from `content` (the legacy attribute, and what render\n * specs emit); a composite owns its children.\n */\nabstract class TextShell extends ShellElement {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n content: { type: String },\n align: { type: String },\n };\n\n declare content: string;\n declare align: TextAlign;\n\n constructor() {\n super();\n this.content = \"\";\n this.align = \"auto\";\n }\n\n override get control(): HTMLElement | null {\n return this.firstElementChild as HTMLElement | null;\n }\n\n}\n\n/**\n * # `<pont2-title>`\n *\n * ```html\n * <pont2-title level=\"1\" content=\"Welcome back\"></pont2-title>\n * → <pont2-title data-pont2-shell><h1 data-pont2-title data-level=\"1\" data-align=\"auto\">Welcome back</h1></pont2-title>\n * ```\n *\n * Sizes follow shadcn's auth blocks: level 1 is the block heading (`text-2xl\n * font-bold`), 2–4 step down (`text-xl`/`text-lg`/`text-base`, semibold).\n *\n * @tag pont2-title\n * @attr level - 1 (default) | 2 | 3 | 4: the native heading level\n * @attr content - the heading text\n * @attr align - auto (default: inherit) | start | center | end\n * @cssprop --pont2-title-fg, --pont2-title-font-weight - colour and weight (default foreground, semibold)\n * @cssprop --pont2-title-h1-font-size … --pont2-title-h4-font-size - size per level (default text-2xl, -xl, -lg, -base)\n * @cssprop --pont2-title-h1-font-weight - level 1 weight (default the title weight, else bold)\n */\nexport class Title extends TextShell {\n static override properties: PropertyDeclarations = {\n level: { type: String },\n };\n\n declare level: TitleLevel;\n\n constructor() {\n super();\n this.level = \"1\";\n }\n\n override render(): TemplateResult {\n const level = ([\"1\", \"2\", \"3\", \"4\"] as const).includes(this.level) ? this.level : \"1\";\n const a = this.align || \"auto\";\n const c = this.content;\n switch (level) {\n case \"2\":\n return html`<h2 data-pont2-title data-level=\"2\" data-align=${a}>${c}</h2>`;\n case \"3\":\n return html`<h3 data-pont2-title data-level=\"3\" data-align=${a}>${c}</h3>`;\n case \"4\":\n return html`<h4 data-pont2-title data-level=\"4\" data-align=${a}>${c}</h4>`;\n default:\n return html`<h1 data-pont2-title data-level=\"1\" data-align=${a}>${c}</h1>`;\n }\n }\n}\n\n/**\n * # `<pont2-subtitle>`\n *\n * ```html\n * <pont2-subtitle content=\"Login to your Acme Inc account\"></pont2-subtitle>\n * → <pont2-subtitle data-pont2-shell><p data-pont2-subtitle data-align=\"auto\">…</p></pont2-subtitle>\n * ```\n *\n * shadcn's block description: `text-muted-foreground text-balance` (text-sm).\n *\n * @tag pont2-subtitle\n * @attr content, align - as Title\n * @cssprop --pont2-subtitle-fg, --pont2-subtitle-font-size - colour and size (default muted-foreground, text-sm)\n */\nexport class Subtitle extends TextShell {\n override render(): TemplateResult {\n return html`<p data-pont2-subtitle data-align=${this.align || \"auto\"}>${this.content}</p>`;\n }\n}\n\ndefine(\"pont2-title\", Title);\ndefine(\"pont2-subtitle\", Subtitle);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-title\": Title;\n \"pont2-subtitle\": Subtitle;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\n\nimport { define } from \"../../core/names\";\nimport type { ButtonSize, ButtonVariant } from \"../../primitives/button/button\";\nimport { Field } from \"../../primitives/field/field\";\nimport type { AuthButtonContent, AuthButtonIconAlign } from \"../auth-button/auth-button\";\nimport \"../auth-button/auth-button\";\nimport { AUTH_PROVIDERS, type AuthProvider } from \"../auth-button/providers\";\n\n/** Per-provider settings that override the field-wide ones (the legacy `overrides`). */\nexport interface ProviderOverride {\n provider: AuthProvider;\n label?: string;\n prompt?: string;\n event?: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n content?: AuthButtonContent;\n iconAlign?: AuthButtonIconAlign;\n disabled?: boolean;\n loading?: boolean;\n}\n\n/** The legacy column layouts of a 12-column grid, by provider count. */\nexport type ProviderColumns = \"one\" | \"three\" | \"four\" | \"two-three\" | \"three-four\";\n\n/** 1–2 → one per row; multiples of 3 → three; 5 → 2 + 3; 7 → 3 + 4; otherwise four (legacy rule). */\nexport function providerColumns(count: number): ProviderColumns {\n if (count < 3) return \"one\";\n if (count % 3 === 0) return \"three\";\n if (count === 5) return \"two-three\";\n if (count === 7) return \"three-four\";\n return \"four\";\n}\n\n/** The legacy default event per provider: the platform's OAuth sign-in action. */\nexport const providerEvent = (p: AuthProvider) => `signin_with_oauth(${p})`;\n\nconst listConverter = {\n fromAttribute: (v: string | null): AuthProvider[] =>\n (v ?? \"\").split(/[\\s,]+/).filter((p): p is AuthProvider => AUTH_PROVIDERS.includes(p as AuthProvider)),\n};\n\nconst jsonArray = {\n fromAttribute: (v: string | null): ProviderOverride[] => {\n try {\n const parsed = JSON.parse(v ?? \"[]\");\n return Array.isArray(parsed) ? parsed : [];\n } catch {\n return [];\n }\n },\n};\n\n/**\n * # `<pont2-provider-field>`: the \"continue with…\" button grid\n *\n * ```html\n * <pont2-provider-field providers=\"apple google meta\"></pont2-provider-field>\n * ```\n *\n * **Is a Field** (`extends Field`), as in shadcn's login blocks (`<Field\n * className=\"grid grid-cols-3 gap-4\">` holding the buttons), laid out on the\n * legacy kit's 12-column grid (`data-columns`, see `providerColumns`). It\n * renders one **`<pont2-provider-button>` element** per provider:\n *\n * ```html\n * <pont2-provider-field data-pont2-field data-slot=\"field\" role=\"group\" data-columns=\"three\">\n * <pont2-provider-button provider=\"apple\" content=\"icon\" event=\"signin_with_oauth(apple)\" data-pont2-shell>\n * <button data-pont2-button data-variant=\"outline\" data-provider=\"apple\" aria-label=\"Continue with Apple\">…</button>\n * </pont2-provider-button>\n * …\n * </pont2-provider-field>\n * ```\n *\n * Nesting kit elements is normally forbidden in kit templates. This is the\n * documented exception (docs/10-primitives-and-kit.md §5): each button is an\n * **independent, stateful** element (its own busy state and action request),\n * repeated per item, and its host is `display: contents`, so the grid items\n * are the native buttons and the DOM is shadcn's.\n *\n * Field-wide settings apply to every button; `overrides` (JSON attribute or\n * array property) replaces them for one provider. With more than two\n * providers the buttons default to icon-only (legacy).\n *\n * @tag pont2-provider-field\n * @attr providers - e.g. \"apple google github\" (duplicates and unknown names are dropped)\n * @attr event - one event for every button (default: `signin_with_oauth(<provider>)` each)\n * @attr variant, size, content, icon-align, prompt, label, disabled, loading - passed to every button\n * @attr overrides - JSON array of per-provider settings, e.g. `[{\"provider\":\"google\",\"label\":\"Google Workspace\"}]`\n */\nexport class ProviderField extends Field {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n providers: { converter: listConverter },\n overrides: { converter: jsonArray },\n event: { type: String },\n variant: { type: String },\n size: { type: String },\n content: { type: String },\n iconAlign: { type: String, attribute: \"icon-align\" },\n prompt: { type: String },\n label: { type: String },\n loading: { type: Boolean },\n };\n\n declare providers: AuthProvider[];\n declare overrides: ProviderOverride[];\n declare event: string | undefined;\n declare variant: ButtonVariant | undefined;\n declare size: ButtonSize | undefined;\n declare content: AuthButtonContent | undefined;\n declare iconAlign: AuthButtonIconAlign | undefined;\n declare prompt: string | undefined;\n declare label: string | undefined;\n declare loading: boolean;\n\n constructor() {\n super();\n this.providers = [];\n this.overrides = [];\n this.event = undefined;\n this.variant = undefined;\n this.size = undefined;\n this.content = undefined;\n this.iconAlign = undefined;\n this.prompt = undefined;\n this.label = undefined;\n this.loading = false;\n }\n\n /** The providers actually rendered: known names, first occurrence only. */\n get list(): AuthProvider[] {\n return [...new Set((this.providers ?? []).filter(p => AUTH_PROVIDERS.includes(p)))];\n }\n\n /** The rendered `<pont2-provider-button>` elements. */\n get buttons(): HTMLElementTagNameMap[\"pont2-provider-button\"][] {\n return Array.from(this.querySelectorAll(\":scope > pont2-provider-button\"));\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"columns\", providerColumns(this.list.length));\n }\n\n override render() {\n const list = this.list;\n const overrides = new Map((this.overrides ?? []).map(o => [o.provider, o]));\n const iconOnly = list.length > 2 ? \"icon\" : undefined;\n return repeat(\n list,\n p => p,\n p => {\n const o = overrides.get(p) ?? ({ provider: p } as ProviderOverride);\n const opt = <T>(v: T | undefined) => (v === undefined || v === null || v === \"\" ? nothing : v);\n return html`<pont2-provider-button\n provider=${p}\n event=${o.event ?? this.event ?? providerEvent(p)}\n variant=${opt(o.variant ?? this.variant)}\n size=${opt(o.size ?? this.size)}\n content=${opt(o.content ?? this.content ?? iconOnly)}\n icon-align=${opt(o.iconAlign ?? this.iconAlign)}\n prompt=${opt(o.prompt ?? this.prompt)}\n label=${opt(o.label ?? this.label)}\n ?disabled=${!!(o.disabled || this.disabled)}\n ?loading=${!!(o.loading || this.loading)}\n ></pont2-provider-button>`;\n },\n );\n }\n}\n\ndefine(\"pont2-provider-field\", ProviderField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-provider-field\": ProviderField;\n }\n}\n","import { html, svg } from \"lit\";\n\n/**\n * The Pontive logo (mark + wordmark), the same geometry as the legacy\n * watermark. Pontive's own asset, so it is inlined (no image request) and the\n * mark and wordmark can be coloured separately in CSS.\n */\nexport const PONTIVE_MARK = svg`<polygon points=\"113.15,120.26 72.47,190.69 72.46,190.71 61.31,210.02 34.66,256.16 0,196.08 78.48,60.19\" /><polygon points=\"256.23,117.67 179.4,250.76 107.12,250.76 72.46,190.71 72.47,190.69 144.73,190.69 186.89,117.67 153.68,60.07 78.48,60.07 34.65,0 188.35,0\" />`;\nexport const PONTIVE_WORDMARK = svg`<path d=\"M305.95,36.62h76.01c37.22,0,63.16,24.13,63.16,58.64c0,35.19-25.94,59.77-63.16,59.77h-40.83v62.03h-35.19V36.62z M381.51,123.46c16.24,0,27.52-11.28,27.52-27.74c0-16.24-11.28-27.52-27.52-27.52h-40.37v55.26H381.51z\" /><path d=\"M454.59,143.76c0-45.11,31.58-75.79,76.91-75.79c45.34,0,76.91,30.68,76.91,75.79c0,45.34-31.58,75.79-76.91,75.79C486.17,219.54,454.59,189.09,454.59,143.76z M531.51,187.74c24.13,0,41.05-17.59,41.05-43.98c0-26.16-16.92-43.98-41.05-43.98c-23.91,0-40.83,17.82-40.83,43.98C490.68,170.15,507.6,187.74,531.51,187.74z\" /><path d=\"M635.48,70.45h34.96v18.72c3.61-8.8,17.14-21.2,40.37-21.2c33.38,0,59.1,25.71,59.1,63.83v85.26h-35.19v-84.58c0-19.85-12.86-33.16-32.03-33.16c-19.17,0-32.03,13.31-32.03,33.16v84.58h-35.19V70.45z\" /><path d=\"M815.02,102.03h-27.07V70.45h27.07V36.62h35.19v33.83h26.84v31.58h-26.84v115.03h-35.19V102.03z\" /><path d=\"M899.6,36.62h35.19V68.2H899.6V36.62z M899.6,89.85h35.19v127.21H899.6V89.85z\" /><path d=\"M955.09,70.45h36.31l39.7,103.76l39.47-103.76h36.31l-58.19,146.61h-35.19L955.09,70.45z\" /><path d=\"M1117.49,144.21c0-45.56,32.03-76.24,76.46-76.24c49.85,0,81.65,39.25,76.24,87.29h-116.16c2.48,20.53,20.3,33.16,39.47,33.16c15.56,0,30.68-8.12,37.22-22.33h36.99c-9.92,32.48-36.99,53.46-74.66,53.46C1148.39,219.54,1117.49,188.87,1117.49,144.21z M1232.75,127.97c-5.64-17.59-20.07-28.87-38.34-28.87c-18.5,0-33.38,11.05-38.8,29.1L1232.75,127.97z\" />`;\n\nexport const pontiveLogo = () => html`<svg\n data-slot=\"watermark-logo\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 1270.79 256.16\"\n role=\"img\"\n aria-label=\"Pontive\"\n><g data-logo-mark>${PONTIVE_MARK}</g><g data-logo-wordmark>${PONTIVE_WORDMARK}</g></svg>`;\n","import { html, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { pontiveLogo } from \"./pontive-logo\";\n\nexport type WatermarkVariant = \"brand\" | \"theme\" | \"muted\";\nexport type WatermarkLogoAlign = \"start\" | \"end\";\n\n/** The watermark's content (label + logo), shared with the block's footer. */\nexport function watermarkContent(label: string, logoAlign: WatermarkLogoAlign): TemplateResult {\n const text = html`<span data-slot=\"watermark-label\">${label || \"Powered by\"}</span>`;\n return logoAlign === \"start\" ? html`${pontiveLogo()}${text}` : html`${text}${pontiveLogo()}`;\n}\n\n/**\n * # `<pont2-watermark>`: \"Powered by [Pontive]\"\n *\n * ```html\n * <pont2-watermark variant=\"muted\"></pont2-watermark>\n * → <pont2-watermark data-pont2-watermark data-slot=\"watermark\" data-variant=\"muted\">\n * <span data-slot=\"watermark-label\">Powered by</span><svg data-slot=\"watermark-logo\" role=\"img\" aria-label=\"Pontive\">…</svg>\n * </pont2-watermark>\n * ```\n *\n * Host-as-root (the legacy element wrapped a `<span>` in its tag). The block\n * renders the same content as a *part* in its footer (`Watermark.part()` +\n * `watermarkContent()`), so the screen shell needs no nested element.\n *\n * @tag pont2-watermark\n * @attr variant - brand (default: the mark in Pontive indigo) | theme (currentColor) | muted (muted text)\n * @attr logo-align - start | end (default)\n * @attr label - default \"Powered by\"\n * @cssprop --pont2-watermark-brand-icon-color - the mark in the brand variant (default #6366f1)\n * @cssprop --pont2-watermark-muted-fg - text and mark in the muted variant (default muted-foreground)\n */\nexport class Watermark extends HostElement {\n static override identity = \"watermark\";\n static override slotName = \"watermark\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n logoAlign: { type: String, attribute: \"logo-align\" },\n label: { type: String },\n };\n\n declare variant: WatermarkVariant;\n declare logoAlign: WatermarkLogoAlign;\n declare label: string;\n\n constructor() {\n super();\n this.variant = \"brand\";\n this.logoAlign = \"end\";\n this.label = \"\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"brand\");\n }\n\n override render() {\n return watermarkContent(this.label, this.logoAlign);\n }\n}\n\ndefine(\"pont2-watermark\", Watermark);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-watermark\": Watermark;\n }\n}\n","import { ContextConsumer, createContext } from \"@lit/context\";\nimport type { ReactiveElement } from \"lit\";\n\n/**\n * Account-level branding entitlements, the pont2 side of\n * docs/branding-entitlements.md (same rule, same shape):\n *\n * > A branding entitlement is a fact about the account, resolved by the\n * > backend, delivered as context. An element that renders branding *asks*\n * > for it. It is never *told* by its own markup.\n *\n * So there is no attribute, property or other escape hatch on any pont2\n * element; the flow host (the future pont2 widgets/layout) provides\n * `brandingContext` from the backend response, and Storybook provides it with\n * a `ContextProvider`.\n *\n * The context is the Context Community Protocol (`context-request` events)\n * through `@lit/context`. Its key is `pont2:branding`, separate from the\n * legacy `pont:branding` (docs/08-parallel-constraints.md §4).\n */\nexport interface BrandingEntitlements {\n /** Whether the Pontive watermark must be rendered on the screen shell. */\n showWatermark: boolean;\n}\n\n/** Fail closed: no provider, or an old backend, means the watermark shows. */\nexport const DEFAULT_BRANDING: BrandingEntitlements = { showWatermark: true };\n\nexport const brandingContext = createContext<BrandingEntitlements>(\"pont2:branding\");\n\n/**\n * Reads the entitlements for one element (subscribing, so a late or changed\n * provider value re-renders it). Deliberately no attribute override.\n */\nexport class BrandingController {\n private consumer: ContextConsumer<typeof brandingContext, ReactiveElement>;\n\n constructor(host: ReactiveElement) {\n this.consumer = new ContextConsumer(host, { context: brandingContext, subscribe: true });\n }\n\n get showWatermark(): boolean {\n return this.consumer.value?.showWatermark ?? DEFAULT_BRANDING.showWatermark;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { Card, CardFooter } from \"../../primitives/card/card\";\nimport { Watermark, watermarkContent } from \"../watermark/watermark\";\nimport { BrandingController } from \"./branding\";\n\nexport { BrandingController, brandingContext, DEFAULT_BRANDING, type BrandingEntitlements } from \"./branding\";\n\nexport type BlockAlign = \"stretch\" | \"start\" | \"center\" | \"end\";\nexport type BlockJustify = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-block>`: the screen shell\n *\n * ```html\n * <pont2-block>\n * <pont2-header>…</pont2-header>\n * <form>…</form>\n * </pont2-block>\n * ```\n *\n * **Is a Card** (`extends Card`): the host is the card, the screen's content\n * is its children, **left where they are**, and the block adds one thing of\n * its own, the watermark footer:\n *\n * ```html\n * <pont2-block data-pont2-card data-slot=\"card\" data-align=\"stretch\" data-justify=\"start\">\n * …the screen (author / render-spec content)…\n * <div data-pont2-card-footer data-slot=\"card-footer\" data-border=\"top\">\n * <span data-pont2-watermark data-slot=\"watermark\" data-variant=\"muted\">Powered by <svg/></span>\n * </div>\n * </pont2-block>\n * ```\n *\n * The legacy `pont-block` rendered `pont-card > [card] > pont-card-content >\n * [card-content]` and then **moved** the spec's children into it\n * (`moveLightDomChildrenInto`), the relocation pattern host-as-root exists to\n * remove. pont2 moves nothing: the card's inline padding (CardContent's\n * `px-(--card-spacing)`) is on the host, and the footer bleeds to the edges.\n *\n * **Watermark entitlement** (docs/branding-entitlements.md): the footer is\n * rendered unless the branding context says `showWatermark: false`. There is\n * no attribute or property for it, and it fails closed. It is part of the\n * shell, not the content, so a screen author cannot delete it.\n *\n * Not a props-driven composite (`composite = false`): a block *contains* the\n * screen. Lit renders the footer after the author's children.\n *\n * @tag pont2-block\n * @attr align - stretch (default) | start | center | end: the content's cross-axis alignment\n * @attr justify - start (default) | center | end: when the block is taller than its content\n * @attr size - default | sm (the Card primitive's spacing)\n * @cssprop --pont2-block-max-width - max width on wider screens (default 24rem)\n * @cssprop --pont2-block-gap - gap between children (default 1rem)\n * @cssprop --pont2-block-bg, --pont2-block-fg, --pont2-block-border-color, --pont2-block-radius, --pont2-block-shadow, --pont2-block-spacing - the screen card (fall back to the Card's tokens)\n * @cssprop --pont2-block-footer-bg - the watermark band\n */\nexport class Block extends Card {\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n align: { type: String },\n justify: { type: String },\n };\n\n declare align: BlockAlign;\n declare justify: BlockJustify;\n\n private branding = new BrandingController(this);\n\n constructor() {\n super();\n this.align = \"stretch\";\n this.justify = \"start\";\n }\n\n protected override willUpdate(): void {\n super.willUpdate();\n this.setData(\"align\", this.align || \"stretch\");\n this.setData(\"justify\", this.justify || \"start\");\n }\n\n override render() {\n if (!this.branding.showWatermark) return nothing;\n return html`<div ${CardFooter.part({ \"data-border\": \"top\", \"data-block-footer\": true })}>\n <span ${Watermark.part({ \"data-variant\": \"muted\" })}>${watermarkContent(\"\", \"end\")}</span>\n </div>`;\n }\n}\n\ndefine(\"pont2-block\", Block);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-block\": Block;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/** The legacy render-spec values. */\nexport type ContainerType = \"flex_column\" | \"flex_row\";\nexport type ContainerAlign = \"stretch\" | \"start\" | \"center\" | \"end\";\nexport type ContainerJustify = \"start\" | \"center\" | \"end\" | \"between\";\n\n/**\n * # `<pont2-container>`: a flex group of screen elements\n *\n * ```html\n * <pont2-container type=\"flex_row\" justify=\"between\">…</pont2-container>\n * → <pont2-container data-pont2-container data-slot=\"container\" data-type=\"flex_row\" data-justify=\"between\">…</pont2-container>\n * ```\n *\n * Tier 1 host-as-root: the host is the flex box and the children stay where\n * they are (the legacy element rendered an inner `div` and moved the children\n * into it). Not a composite: it contains content.\n *\n * @tag pont2-container\n * @attr type - flex_column (default) | flex_row\n * @attr align - stretch (default) | start | center | end (cross axis)\n * @attr justify - start (default) | center | end | between (main axis)\n * @cssprop --pont2-container-gap - default 1rem\n */\nexport class Container extends HostElement {\n static override identity = \"container\";\n static override slotName = \"container\";\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n type: { type: String },\n align: { type: String },\n justify: { type: String },\n };\n\n declare type: ContainerType;\n declare align: ContainerAlign;\n declare justify: ContainerJustify;\n\n constructor() {\n super();\n this.type = \"flex_column\";\n this.align = \"stretch\";\n this.justify = \"start\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"type\", this.type === \"flex_row\" ? \"flex_row\" : \"flex_column\");\n this.setData(\"align\", this.align || \"stretch\");\n this.setData(\"justify\", this.justify || \"start\");\n }\n}\n\ndefine(\"pont2-container\", Container);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-container\": Container;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type HeaderAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-header>`: the screen's heading group (logo, title, subtitle)\n *\n * ```html\n * <pont2-header>\n * <pont2-logo image-url=\"/logo.svg\"></pont2-logo>\n * <pont2-title content=\"Welcome back\"></pont2-title>\n * <pont2-subtitle content=\"Login to your Acme Inc account\"></pont2-subtitle>\n * </pont2-header>\n * ```\n *\n * shadcn's login blocks: `<div class=\"flex flex-col items-center gap-2\n * text-center\">`. Tier 1 host-as-root (the legacy element moved its children\n * into an inner `div`); `align` sets both the boxes' and the text's alignment,\n * as the legacy header does. Not a composite: it contains content.\n *\n * @tag pont2-header\n * @attr align - start | center (default) | end\n * @cssprop --pont2-header-gap - default 0.5rem\n */\nexport class Header extends HostElement {\n static override identity = \"header\";\n static override slotName = \"header\";\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n align: { type: String },\n };\n\n declare align: HeaderAlign;\n\n constructor() {\n super();\n this.align = \"center\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"center\");\n }\n}\n\ndefine(\"pont2-header\", Header);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-header\": Header;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type GapType = \"vertical\" | \"horizontal\";\n\n/**\n * # `<pont2-gap>`: a fixed spacer\n *\n * ```html\n * <pont2-gap size=\"24px\"></pont2-gap>\n * → <pont2-gap data-pont2-gap data-type=\"vertical\" style=\"--pont2-gap-size: 24px\"></pont2-gap>\n * ```\n *\n * The host *is* the spacer (the legacy element rendered a sized `div` inside\n * itself). The size is any CSS length, passed through the `--pont2-gap-size`\n * custom property on the host, so no inline width/height overrides author CSS.\n * Decorative: `aria-hidden`.\n *\n * @tag pont2-gap\n * @attr size - CSS length (default 8px)\n * @attr type - vertical (default: takes height) | horizontal (takes width)\n */\nexport class Gap extends HostElement {\n static override identity = \"gap\";\n static override slotName = \"gap\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n size: { type: String },\n type: { type: String },\n };\n\n declare size: string;\n declare type: GapType;\n\n constructor() {\n super();\n this.size = \"8px\";\n this.type = \"vertical\";\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.internals.ariaHidden = \"true\";\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"type\", this.type === \"horizontal\" ? \"horizontal\" : \"vertical\");\n if (changed.has(\"size\")) this.style.setProperty(\"--pont2-gap-size\", this.size || \"8px\");\n }\n}\n\ndefine(\"pont2-gap\", Gap);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-gap\": Gap;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type LogoAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * A logo source as an `<img src>`: URLs and `data:` URIs pass through; a bare\n * base64 string is treated as an SVG (the legacy `resolveIconSource` rule).\n * `{{theme}}` in a URL is replaced with `light` or `dark`.\n */\nexport function logoSource(raw: string | undefined, theme: \"light\" | \"dark\"): string {\n if (!raw) return \"\";\n const url = raw.replace(\"{{theme}}\", theme);\n if (/^(https?:|data:|blob:|\\/|\\.{1,2}\\/)/.test(url)) return url;\n return `data:image/svg+xml;base64,${url}`;\n}\n\n/**\n * # `<pont2-logo>`: the application's logo\n *\n * ```html\n * <pont2-logo image-url=\"https://cdn.example.com/logo-{{theme}}.svg\" alt=\"Acme\"></pont2-logo>\n * → <pont2-logo data-pont2-logo data-slot=\"logo\" data-align=\"center\">\n * <img data-logo-theme=\"light\" src=\"…logo-light.svg\" alt=\"Acme\">\n * <img data-logo-theme=\"dark\" src=\"…logo-dark.svg\" alt=\"Acme\"> (only when it differs)\n * </pont2-logo>\n * ```\n *\n * **Always an `<img>`.** The legacy element decoded base64 SVG and injected\n * it as markup (`unsafeSVG`), which runs whatever the SVG contains in the\n * page. An `<img>` renders the same SVG sandboxed (no script, no external\n * fetches), and needs no decoding.\n *\n * **Dark mode by CSS**, not by watching `<html data-theme>`: when the dark\n * source differs (`image-url-dark`, or `{{theme}}` in the URL), both images\n * are rendered and the stylesheet shows the right one under `.dark` /\n * `[data-theme=\"dark\"]` (the pont2 dark-mode switches).\n *\n * @tag pont2-logo\n * @attr image-url - URL, `data:` URI or bare base64 SVG; `{{theme}}` is replaced\n * @attr image-url-dark - dark-mode source (default: `image-url` with `{{theme}}` = dark)\n * @attr alt - default \"Logo\" (legacy); set the brand name\n * @attr align - start | center (default) | end\n * @attr width, height - CSS lengths for the image\n */\nexport class Logo extends HostElement {\n static override identity = \"logo\";\n static override slotName = \"logo\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n imageUrl: { type: String, attribute: \"image-url\" },\n imageUrlDark: { type: String, attribute: \"image-url-dark\" },\n alt: { type: String },\n align: { type: String },\n width: { type: String },\n height: { type: String },\n };\n\n declare imageUrl: string;\n declare imageUrlDark: string;\n declare alt: string;\n declare align: LogoAlign;\n declare width: string;\n declare height: string;\n\n constructor() {\n super();\n this.imageUrl = \"\";\n this.imageUrlDark = \"\";\n this.alt = \"\";\n this.align = \"center\";\n this.width = \"\";\n this.height = \"\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"center\");\n }\n\n override render() {\n const light = logoSource(this.imageUrl, \"light\");\n if (!light) return nothing;\n const dark = logoSource(this.imageUrlDark || this.imageUrl, \"dark\");\n const style = styleMap({ width: this.width || undefined, height: this.height || undefined });\n const alt = this.alt || \"Logo\";\n return html`<img data-logo-theme=\"light\" src=${light} alt=${alt} style=${style} />${dark !== light\n ? html`<img data-logo-theme=\"dark\" src=${dark} alt=${alt} style=${style} />`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-logo\", Logo);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-logo\": Logo;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport interface CountdownEndDetail {\n /** Where the countdown will navigate (already resolved), or null. */\n url: string | null;\n}\n\n/** Resolves `raw` against the page and accepts only http(s) URLs (no `javascript:`, `data:` …). */\nexport function safeRedirect(raw: string, base = globalThis.location?.href): string | null {\n if (!raw) return null;\n try {\n const url = new URL(raw, base);\n return url.protocol === \"http:\" || url.protocol === \"https:\" ? url.href : null;\n } catch {\n return null;\n }\n}\n\n/**\n * # `<pont2-countdown>`: \"Redirecting in 5s…\"\n *\n * ```html\n * <pont2-countdown content=\"Redirecting you in\" duration=\"5\" redirect-url=\"/dashboard\"></pont2-countdown>\n * → <pont2-countdown data-pont2-countdown data-slot=\"countdown\" role=\"timer\">Redirecting you in 5s…</pont2-countdown>\n * ```\n *\n * Host-as-root (the legacy element rendered a `div` inside its tag). Counts\n * down once a second; at zero it fires a **cancelable** `pont2-countdown-end`\n * and, unless a listener prevents it, navigates to `redirect-url`.\n *\n * **Only http(s) URLs are followed.** Render specs are author-editable HTML,\n * so a `javascript:` or `data:` redirect would be script injection; those are\n * refused (the event still fires, with `url: null`). The legacy element\n * assigned `location.href` unconditionally and defaulted to `/`; pont2 has no\n * default: without `redirect-url` it only fires the event.\n *\n * `role=\"timer\"`: assistive technology is not interrupted every second.\n *\n * @tag pont2-countdown\n * @attr duration - seconds (default 5)\n * @attr content - text before the seconds\n * @attr redirect-url - where to go at zero (http/https, relative URLs resolve against the page)\n * @fires pont2-countdown-end - `{ url }`, cancelable: `preventDefault()` stops the redirect\n */\nexport class Countdown extends HostElement {\n static override identity = \"countdown\";\n static override slotName = \"countdown\";\n static override role = \"timer\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n duration: { type: Number },\n content: { type: String },\n redirectUrl: { type: String, attribute: \"redirect-url\" },\n remaining: { state: true },\n };\n\n declare duration: number;\n declare content: string;\n declare redirectUrl: string;\n /** Seconds left. */\n declare remaining: number;\n\n private timer: ReturnType<typeof setInterval> | undefined;\n\n constructor() {\n super();\n this.duration = 5;\n this.content = \"\";\n this.redirectUrl = \"\";\n this.remaining = 0;\n }\n\n /** (Re)starts from `duration`. */\n restart(): void {\n this.stop();\n this.remaining = Math.max(0, Math.floor(this.duration || 0));\n if (!this.remaining) {\n this.end();\n return;\n }\n this.timer = setInterval(() => {\n this.remaining -= 1;\n if (this.remaining <= 0) {\n this.stop();\n this.end();\n }\n }, 1000);\n }\n\n private stop(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n private end(): void {\n const url = safeRedirect(this.redirectUrl);\n const go = fire<CountdownEndDetail>(this, \"pont2-countdown-end\", { url }, true);\n if (go && url) location.assign(url);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.restart();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stop();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"duration\") && this.hasUpdated) this.restart();\n }\n\n override render() {\n return html`${this.content ? `${this.content} ` : \"\"}${this.remaining}s…`;\n }\n}\n\ndefine(\"pont2-countdown\", Countdown);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-countdown\": Countdown;\n }\n interface HTMLElementEventMap {\n \"pont2-countdown-end\": CustomEvent<CountdownEndDetail>;\n }\n}\n","import { html, type PropertyDeclarations } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/**\n * # `<pont2-edit-identifier>`: \"ada@example.com ✎\"\n *\n * The identifier the user entered on the previous step, with a button to go\n * back and change it.\n *\n * ```html\n * <pont2-edit-identifier identifier=\"ada@example.com\" event=\"change_identifier\"></pont2-edit-identifier>\n * → <pont2-edit-identifier data-pont2-edit-identifier data-slot=\"edit-identifier\">\n * <span data-slot=\"edit-identifier-value\">ada@example.com</span>\n * <button data-pont2-button data-variant=\"ghost\" data-size=\"icon-xs\" aria-label=\"Change ada@example.com\" type=\"button\"><svg/></button>\n * </pont2-edit-identifier>\n * ```\n *\n * The button is the button primitive's part and requests `event` through the\n * action protocol (`data: { identifier }`), busy until it settles. The\n * legacy element made the *whole* element a click target and its icon button\n * had no accessible name; here only the button acts, and it is named\n * (\"Change ada@example.com\", `label` + the identifier).\n *\n * @tag pont2-edit-identifier\n * @attr identifier - the value shown\n * @attr event - the action requested on press\n * @attr label - the button's accessible name prefix (default \"Change\")\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class EditIdentifier extends HostElement {\n static override identity = \"edit-identifier\";\n static override slotName = \"edit-identifier\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n identifier: { type: String },\n event: { type: String },\n label: { type: String },\n };\n\n declare identifier: string;\n declare event: string | undefined;\n declare label: string;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.identifier = \"\";\n this.event = undefined;\n this.label = \"\";\n }\n\n get control(): HTMLButtonElement | null {\n return this.querySelector(\"[data-pont2-button]\");\n }\n\n override render() {\n const busy = this.action.busy;\n return html`<span data-slot=\"edit-identifier-value\">${this.identifier}</span>${button(\n {\n variant: \"ghost\",\n size: \"icon-xs\",\n slot: \"edit-identifier-button\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: {\n \"aria-label\": `${this.label || \"Change\"} ${this.identifier}`.trim(),\n \"data-event\": this.event,\n \"aria-busy\": busy ? \"true\" : null,\n },\n onClick: () => this.action.request(this.event, { identifier: this.identifier }),\n },\n icons.pencil(),\n )}`;\n }\n}\n\ndefine(\"pont2-edit-identifier\", EditIdentifier);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-edit-identifier\": EditIdentifier;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { CopyController } from \"../../core/controllers/copy\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { uid } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { InputGroup, InputGroupAddon, inputGroupButton, inputGroupInput } from \"../../primitives/input-group/input-group\";\n\n/**\n * # `<pont2-secret>`: the \"Can't scan?\" manual TOTP secret\n *\n * ```html\n * <pont2-secret secret=\"JBSWY3DPEHPK3PXP\" issuer=\"Acme\" account=\"ada@example.com\"></pont2-secret>\n * ```\n *\n * ```html\n * <pont2-secret data-pont2-secret data-slot=\"secret\">\n * <p data-slot=\"secret-title\">Can't scan?</p>\n * <div data-pont2-input-group …>\n * <input data-pont2-input-group-input readonly value=\"JBSWY3DPEHPK3PXP\" aria-label=\"Manual secret\">\n * <div data-pont2-input-group-addon data-align=\"inline-end\">\n * <button … aria-label=\"Copy secret\"><svg/></button>\n * </div>\n * </div>\n * <span data-slot=\"secret-copied\" role=\"status\">Copied!</span> (after copying)\n * <dl data-slot=\"secret-metadata\"><div><dt>Issuer</dt><dd>Acme</dd></div><div><dt>Account</dt><dd>…</dd></div></dl>\n * </pont2-secret>\n * ```\n *\n * Built from InputGroup parts (shadcn's input + addon button). Differences\n * from the legacy element, each deliberate:\n * - the input is **readonly**, not disabled: it can be focused and selected\n * (copy by hand, screen readers read it); monospace, spaced for reading;\n * - \"Copied!\" is a `role=\"status\"` live region, so it is announced;\n * - the copy events (`pont2-copied` / `pont2-copy-error`, `{ kind: \"secret\" }`)\n * **do not carry the secret** (the legacy `pont-secret:copied` did);\n * - issuer/account are a description list (`<dl>`), their semantic form.\n *\n * @tag pont2-secret\n * @attr secret, issuer, account\n * @attr title-text - default \"Can't scan?\" (`title` would be a native tooltip)\n * @attr secret-label, issuer-label, account-label, copy-label, copied-text - copy\n * @attr disabled - disables the copy button\n * @fires pont2-copied, pont2-copy-error - `{ kind: \"secret\" }`\n */\nexport class Secret extends HostElement {\n static override identity = \"secret\";\n static override slotName = \"secret\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n secret: { type: String },\n issuer: { type: String },\n account: { type: String },\n titleText: { type: String, attribute: \"title-text\" },\n secretLabel: { type: String, attribute: \"secret-label\" },\n issuerLabel: { type: String, attribute: \"issuer-label\" },\n accountLabel: { type: String, attribute: \"account-label\" },\n copyLabel: { type: String, attribute: \"copy-label\" },\n copiedText: { type: String, attribute: \"copied-text\" },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare secret: string;\n declare issuer: string;\n declare account: string;\n declare titleText: string;\n declare secretLabel: string;\n declare issuerLabel: string;\n declare accountLabel: string;\n declare copyLabel: string;\n declare copiedText: string;\n declare disabled: boolean;\n\n protected readonly clipboard = new CopyController(this, \"secret\");\n private inputId = uid(\"secret\");\n\n constructor() {\n super();\n this.secret = \"\";\n this.issuer = \"\";\n this.account = \"\";\n this.titleText = \"\";\n this.secretLabel = \"\";\n this.issuerLabel = \"\";\n this.accountLabel = \"\";\n this.copyLabel = \"\";\n this.copiedText = \"\";\n this.disabled = false;\n }\n\n /** Copies the secret (also what the button does). */\n copy(): Promise<boolean> {\n return this.secret && !this.disabled ? this.clipboard.copy(this.secret) : Promise.resolve(false);\n }\n\n override render() {\n const copied = this.clipboard.copied;\n const meta = (label: string, value: string) =>\n value ? html`<div><dt>${label}</dt><dd>${value}</dd></div>` : nothing;\n return html`<p data-slot=\"secret-title\">${this.titleText || \"Can't scan?\"}</p>\n <div ${InputGroup.part()}>\n ${inputGroupInput({\n id: this.inputId,\n value: this.secret,\n readonly: true,\n attrs: { \"aria-label\": this.secretLabel || \"Manual secret\", spellcheck: \"false\", \"data-secret\": true },\n })}\n <div ${InputGroupAddon.part({ \"data-align\": \"inline-end\" })}>\n ${inputGroupButton(\n {\n size: \"icon-xs\",\n disabled: this.disabled || !this.secret,\n attrs: { \"aria-label\": this.copyLabel || \"Copy secret\", \"aria-controls\": this.inputId },\n onClick: () => void this.copy(),\n },\n copied ? icons.check() : icons.copy(),\n )}\n </div>\n </div>\n <span data-slot=\"secret-copied\" role=\"status\">${copied ? this.copiedText || \"Copied!\" : \"\"}</span>\n ${this.issuer || this.account\n ? html`<dl data-slot=\"secret-metadata\">\n ${meta(this.issuerLabel || \"Issuer\", this.issuer)}${meta(this.accountLabel || \"Account\", this.account)}\n </dl>`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-secret\", Secret);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-secret\": Secret;\n }\n}\n","import { html, nothing, svg, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport QRCode from \"qrcode\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\nexport type QrErrorCorrection = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/** Quiet zone, in modules, around the code (the QR spec asks for 4). */\nconst QUIET = 4;\n\n/**\n * One SVG path covering every dark module of `text`'s QR code, plus the\n * code's size. `null` when the text cannot be encoded.\n */\nexport function qrPath(text: string, level: QrErrorCorrection): { d: string; size: number } | null {\n if (!text) return null;\n try {\n const { modules } = QRCode.create(text, { errorCorrectionLevel: level });\n const n = modules.size;\n let d = \"\";\n for (let y = 0; y < n; y++) {\n for (let x = 0; x < n; x++) {\n if (modules.data[y * n + x]) d += `M${x + QUIET} ${y + QUIET}h1v1h-1z`;\n }\n }\n return { d, size: n + QUIET * 2 };\n } catch {\n return null;\n }\n}\n\nexport interface QrDetail {\n url: string;\n}\n\n/**\n * # `<pont2-qr-code>`: the authenticator-app enrolment QR code\n *\n * ```html\n * <pont2-qr-code url=\"otpauth://totp/Acme:ada@example.com?secret=…&issuer=Acme\" timeout=\"30\"></pont2-qr-code>\n * ```\n *\n * ```html\n * <pont2-qr-code data-pont2-qr-code data-slot=\"qr-code\" [data-obscured]>\n * <svg data-slot=\"qr-code-image\" role=\"img\" aria-label=\"QR code\" viewBox=\"0 0 37 37\">\n * <rect …white…/><path d=\"M4 4h1v1h-1z…\"/>\n * </svg>\n * <div data-slot=\"qr-code-overlay\"> (when obscured)\n * <button data-pont2-button type=\"button\">Show QR code</button>\n * </div>\n * </pont2-qr-code>\n * ```\n *\n * **An SVG built from the code's modules** (`qrcode`'s `create()` matrix →\n * one `<path>`), not a canvas: crisp at any size and zoom, no pixel-ratio\n * maths, nothing injected as markup. Always dark-on-white with the\n * 4-module quiet zone, whatever the theme: inverted codes do not scan\n * everywhere.\n *\n * **Obscured after `timeout` seconds** (it encodes the TOTP secret): the\n * code fades and a \"Show QR code\" button brings it back for another\n * `timeout`. `timeout=\"0\"` never obscures.\n *\n * @tag pont2-qr-code\n * @attr url - the text to encode (an `otpauth://` URI)\n * @attr timeout - seconds before obscuring (default 10)\n * @attr error-correction - L | M (default) | Q | H\n * @attr label - accessible name of the image (default \"QR code\")\n * @attr reveal-label - the button text (default \"Show QR code\")\n * @attr disabled - never obscures, and disables the button\n * @cssprop --pont2-qr-code-width - the image width (default 12rem)\n * @fires pont2-qr-obscured, pont2-qr-revealed - `{ url }`\n * @fires pont2-qr-error - `{ url }` when the text cannot be encoded\n */\nexport class QrCode extends HostElement {\n static override identity = \"qr-code\";\n static override slotName = \"qr-code\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n url: { type: String },\n timeout: { type: Number },\n errorCorrection: { type: String, attribute: \"error-correction\" },\n label: { type: String },\n revealLabel: { type: String, attribute: \"reveal-label\" },\n disabled: { type: Boolean, reflect: true },\n obscured: { state: true },\n };\n\n declare url: string;\n declare timeout: number;\n declare errorCorrection: QrErrorCorrection;\n declare label: string;\n declare revealLabel: string;\n declare disabled: boolean;\n declare obscured: boolean;\n\n private timer: ReturnType<typeof setTimeout> | undefined;\n private path: ReturnType<typeof qrPath> = null;\n\n constructor() {\n super();\n this.url = \"\";\n this.timeout = 10;\n this.errorCorrection = \"M\";\n this.label = \"\";\n this.revealLabel = \"\";\n this.disabled = false;\n this.obscured = false;\n }\n\n /** Shows the code again and restarts the timeout. */\n reveal(): void {\n this.obscured = false;\n this.startTimer();\n }\n\n private startTimer(): void {\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = undefined;\n if (!(this.timeout > 0) || this.disabled) return;\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.obscured = true;\n fire<QrDetail>(this, \"pont2-qr-obscured\", { url: this.url });\n }, this.timeout * 1000);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.startTimer();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.timer !== undefined) clearTimeout(this.timer);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"url\") || changed.has(\"errorCorrection\")) {\n this.path = qrPath(this.url, this.errorCorrection || \"M\");\n if (this.url && !this.path) fire<QrDetail>(this, \"pont2-qr-error\", { url: this.url });\n if (this.hasUpdated) this.reveal();\n } else if ((changed.has(\"timeout\") || changed.has(\"disabled\")) && this.hasUpdated) {\n this.reveal();\n }\n this.setData(\"obscured\", this.obscured && !this.disabled);\n }\n\n private onReveal = () => {\n this.reveal();\n fire<QrDetail>(this, \"pont2-qr-revealed\", { url: this.url });\n };\n\n override render() {\n const p = this.path;\n if (!p) return nothing;\n const obscured = this.obscured && !this.disabled;\n return html`<svg\n data-slot=\"qr-code-image\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 ${p.size} ${p.size}\"\n shape-rendering=\"crispEdges\"\n role=\"img\"\n aria-label=${this.label || \"QR code\"}\n aria-hidden=${obscured ? \"true\" : nothing}\n >${svg`<rect width=\"${p.size}\" height=\"${p.size}\" fill=\"#fff\" /><path d=\"${p.d}\" fill=\"#000\" />`}</svg\n >${obscured\n ? html`<div data-slot=\"qr-code-overlay\">\n ${button(\n { variant: \"default\", slot: \"qr-code-reveal\", onClick: this.onReveal },\n this.revealLabel || \"Show QR code\",\n )}\n </div>`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-qr-code\", QrCode);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-qr-code\": QrCode;\n }\n interface HTMLElementEventMap {\n \"pont2-qr-obscured\": CustomEvent<QrDetail>;\n \"pont2-qr-revealed\": CustomEvent<QrDetail>;\n \"pont2-qr-error\": CustomEvent<QrDetail>;\n }\n}\n","import { html, type PropertyDeclarations } from \"lit\";\n\nimport { CopyController } from \"../../core/controllers/copy\";\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/** `codes` attribute: JSON array, or whitespace/comma separated. */\nconst codesConverter = {\n fromAttribute: (v: string | null): string[] => {\n const raw = (v ?? \"\").trim();\n if (!raw) return [];\n if (raw.startsWith(\"[\")) {\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed.map(String) : [];\n } catch {\n return [];\n }\n }\n return raw.split(/[\\s,]+/).filter(Boolean);\n },\n};\n\n/**\n * # `<pont2-recovery-codes>`: one-time recovery codes after MFA enrolment\n *\n * ```html\n * <pont2-recovery-codes codes='[\"a1b2-c3d4\",\"e5f6-g7h8\"]'></pont2-recovery-codes>\n * ```\n *\n * ```html\n * <pont2-recovery-codes data-pont2-recovery-codes data-slot=\"recovery-codes\">\n * <p data-slot=\"recovery-codes-title\">Recovery codes</p>\n * <p data-slot=\"recovery-codes-description\">Use these codes if you lose access…</p>\n * <ul data-slot=\"recovery-codes-list\"><li>a1b2-c3d4</li>…</ul>\n * <div data-slot=\"recovery-codes-actions\">\n * <button data-pont2-button data-variant=\"outline\">Copy codes</button>\n * <button data-pont2-button data-variant=\"outline\">Download codes</button>\n * </div>\n * <span data-slot=\"recovery-codes-copied\" role=\"status\">Copied!</span>\n * </pont2-recovery-codes>\n * ```\n *\n * Buttons are the button primitive's parts, the list is a monospace grid,\n * \"Copied!\" is announced (`role=\"status\"`). Events carry **no codes**\n * (`pont2-copied` / `pont2-copy-error` with `{ kind: \"recovery-codes\" }`,\n * `pont2-recovery-codes-downloaded`); the legacy events included them.\n *\n * @tag pont2-recovery-codes\n * @attr codes - JSON array or whitespace-separated list; `.codes` is an array\n * @attr title-text, description, empty-text, copy-label, download-label, copied-text - copy\n * @attr filename - download file name (default \"recovery-codes.txt\")\n * @attr disabled\n * @cssprop --pont2-recovery-codes-list-bg, --pont2-recovery-codes-list-radius - the code list's surface (default muted, radius-md)\n * @fires pont2-copied, pont2-copy-error, pont2-recovery-codes-downloaded\n */\nexport class RecoveryCodes extends HostElement {\n static override identity = \"recovery-codes\";\n static override slotName = \"recovery-codes\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n codes: { converter: codesConverter },\n titleText: { type: String, attribute: \"title-text\" },\n description: { type: String },\n emptyText: { type: String, attribute: \"empty-text\" },\n copyLabel: { type: String, attribute: \"copy-label\" },\n downloadLabel: { type: String, attribute: \"download-label\" },\n copiedText: { type: String, attribute: \"copied-text\" },\n filename: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare codes: string[];\n declare titleText: string;\n declare description: string;\n declare emptyText: string;\n declare copyLabel: string;\n declare downloadLabel: string;\n declare copiedText: string;\n declare filename: string;\n declare disabled: boolean;\n\n protected readonly clipboard = new CopyController(this, \"recovery-codes\");\n\n constructor() {\n super();\n this.codes = [];\n this.titleText = \"\";\n this.description = \"\";\n this.emptyText = \"\";\n this.copyLabel = \"\";\n this.downloadLabel = \"\";\n this.copiedText = \"\";\n this.filename = \"\";\n this.disabled = false;\n }\n\n private get text(): string {\n return (this.codes ?? []).join(\"\\n\");\n }\n\n copy(): Promise<boolean> {\n return this.codes?.length && !this.disabled ? this.clipboard.copy(this.text) : Promise.resolve(false);\n }\n\n download(): void {\n if (!this.codes?.length || this.disabled) return;\n const url = URL.createObjectURL(new Blob([this.text], { type: \"text/plain\" }));\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = this.filename || \"recovery-codes.txt\";\n a.click();\n setTimeout(() => URL.revokeObjectURL(url));\n fire(this, \"pont2-recovery-codes-downloaded\", {});\n }\n\n override render() {\n const codes = this.codes ?? [];\n const off = this.disabled || !codes.length;\n return html`<p data-slot=\"recovery-codes-title\">${this.titleText || \"Recovery codes\"}</p>\n <p data-slot=\"recovery-codes-description\">\n ${this.description || \"Use these codes if you lose access to your authenticator app.\"}\n </p>\n ${codes.length\n ? html`<ul data-slot=\"recovery-codes-list\">${codes.map(c => html`<li>${c}</li>`)}</ul>`\n : html`<p data-slot=\"recovery-codes-empty\">${this.emptyText || \"No recovery codes available.\"}</p>`}\n <div data-slot=\"recovery-codes-actions\">\n ${button(\n { variant: \"outline\", disabled: off, onClick: () => void this.copy() },\n html`${this.clipboard.copied ? icons.check({ \"data-icon\": \"inline-start\" }) : icons.copy({ \"data-icon\": \"inline-start\" })}${this.copyLabel || \"Copy codes\"}`,\n )}\n ${button(\n { variant: \"outline\", disabled: off, onClick: () => this.download() },\n html`${icons.download({ \"data-icon\": \"inline-start\" })}${this.downloadLabel || \"Download codes\"}`,\n )}\n </div>\n <span data-slot=\"recovery-codes-copied\" role=\"status\"\n >${this.clipboard.copied ? this.copiedText || \"Copied!\" : \"\"}</span\n >`;\n }\n}\n\ndefine(\"pont2-recovery-codes\", RecoveryCodes);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-recovery-codes\": RecoveryCodes;\n }\n interface HTMLElementEventMap {\n \"pont2-recovery-codes-downloaded\": CustomEvent<Record<string, never>>;\n }\n}\n","/**\n * Pure value logic of the scope list (ported from the legacy\n * scope-list.value.ts, which has the same tests).\n */\nexport interface ConsentScope {\n scope: string;\n label: string;\n granted?: boolean;\n required?: boolean;\n}\n\n/** Drops malformed and duplicate entries; trims names; label defaults to the scope. */\nexport function normalizeScopes(scopes: unknown): ConsentScope[] {\n if (!Array.isArray(scopes)) return [];\n const seen = new Set<string>();\n return scopes.flatMap(s => {\n if (!s || typeof s !== \"object\") return [];\n const { scope, label, granted, required } = s as Record<string, unknown>;\n if (typeof scope !== \"string\" || !scope.trim()) return [];\n const name = scope.trim();\n if (seen.has(name)) return [];\n seen.add(name);\n return [{ scope: name, label: typeof label === \"string\" && label ? label : name, granted: granted === true, required: required === true }];\n });\n}\n\n/** Required scopes are always ticked; others unless the user unticked them. */\nexport function isScopeChecked(scope: ConsentScope, unticked: ReadonlySet<string>): boolean {\n return !!scope.required || !unticked.has(scope.scope);\n}\n\n/** The submitted value: ticked scope names, space-separated (OAuth `scope` syntax). */\nexport function scopeListValue(scopes: ConsentScope[], unticked: ReadonlySet<string>): string {\n return Array.from(new Set(scopes.filter(s => isScopeChecked(s, unticked)).map(s => s.scope))).join(\" \");\n}\n","import { html, type PropertyDeclarations } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\n\nimport { FormControlElement } from \"../../core/form-control\";\nimport { define } from \"../../core/names\";\nimport type { Checkbox } from \"../../primitives/checkbox/checkbox\";\nimport { isScopeChecked, normalizeScopes, scopeListValue, type ConsentScope } from \"./scope-value\";\n\nexport { isScopeChecked, normalizeScopes, scopeListValue, type ConsentScope } from \"./scope-value\";\n\nconst scopesConverter = {\n fromAttribute: (v: string | null): ConsentScope[] => {\n try {\n return normalizeScopes(JSON.parse(v ?? \"[]\"));\n } catch {\n return [];\n }\n },\n};\n\n/**\n * # `<pont2-scope-list>`: OAuth consent scopes\n *\n * ```html\n * <form>\n * <pont2-scope-list name=\"scope\"\n * scopes='[{\"scope\":\"openid\",\"label\":\"Sign you in\",\"required\":true},{\"scope\":\"email\",\"label\":\"See your email\"}]'>\n * </pont2-scope-list>\n * </form>\n * → FormData: scope=openid email\n * ```\n *\n * ```html\n * <pont2-scope-list data-pont2-scope-list data-slot=\"scope-list\" role=\"list\">\n * <div role=\"listitem\" data-slot=\"scope-list-item\" data-scope=\"openid\" data-required>\n * <label data-slot=\"scope-list-label\">\n * <pont2-prim-checkbox checked disabled required></pont2-prim-checkbox>\n * <span data-slot=\"scope-list-text\">Sign you in</span>\n * </label>\n * </div>\n * …\n * </pont2-scope-list>\n * ```\n *\n * **Form-associated** (`extends FormControlElement`): it submits the ticked\n * scopes, space-separated (OAuth `scope` syntax), under `name` (default\n * `scope`), resets, restores and follows `<fieldset disabled>` natively. The\n * legacy element exposed `.value` for its custom form to read.\n *\n * Each row is a **Checkbox primitive element** (it has behaviour) inside a\n * native `<label>`; the checkboxes have no `name`, so only the list submits.\n * Required scopes are always ticked and disabled. Scopes default to ticked;\n * the user unticks what they do not grant.\n *\n * @tag pont2-scope-list\n * @attr scopes - JSON array of `{ scope, label?, required?, granted? }`; `.scopes` is an array\n * @attr name - default \"scope\"\n * @attr disabled\n * @fires input, change - when a scope is toggled (read `.value`)\n */\nexport class ScopeList extends FormControlElement {\n static override identity = \"scope-list\";\n static override slotName = \"scope-list\";\n static override role = \"list\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n scopes: { converter: scopesConverter },\n unticked: { state: true },\n };\n\n declare scopes: ConsentScope[];\n declare protected unticked: Set<string>;\n\n constructor() {\n super();\n this.name = \"scope\";\n this.scopes = [];\n this.unticked = new Set();\n }\n\n /** The normalised scope list. */\n get list(): ConsentScope[] {\n return normalizeScopes(this.scopes);\n }\n\n /** The submitted value: ticked scopes, space-separated. */\n get value(): string {\n return scopeListValue(this.list, this.unticked);\n }\n\n protected override get hostFocusable(): boolean {\n return false; // the checkboxes are the tab stops\n }\n\n protected formValue(): string | null {\n return this.name ? this.value : null;\n }\n\n protected resetToDefault(): void {\n this.unticked = new Set();\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state !== \"string\") return;\n const ticked = new Set(state.split(\" \"));\n this.unticked = new Set(this.list.filter(s => !ticked.has(s.scope)).map(s => s.scope));\n }\n\n private toggle(scope: string, e: Event): void {\n e.stopPropagation(); // the list's own input/change replace the checkbox's\n const next = new Set(this.unticked);\n if ((e.target as Checkbox).checked) next.delete(scope);\n else next.add(scope);\n this.unticked = next;\n // As native controls: `input` then `change`, from the list itself.\n this.dispatchEvent(new Event(\"input\", { bubbles: true, composed: true }));\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n override render() {\n return repeat(\n this.list,\n s => s.scope,\n s => html`<div\n role=\"listitem\"\n data-slot=\"scope-list-item\"\n data-scope=${s.scope}\n ?data-required=${s.required}\n ?data-granted=${s.granted}\n >\n <label data-slot=\"scope-list-label\">\n <pont2-prim-checkbox\n .checked=${isScopeChecked(s, this.unticked)}\n ?disabled=${this.isDisabled || s.required}\n ?required=${s.required}\n @input=${(e: Event) => e.stopPropagation()}\n @change=${(e: Event) => this.toggle(s.scope, e)}\n ></pont2-prim-checkbox>\n <span data-slot=\"scope-list-text\">${s.label}</span>\n </label>\n </div>`,\n );\n }\n}\n\ndefine(\"pont2-scope-list\", ScopeList);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-scope-list\": ScopeList;\n }\n}\n","/**\n * Turning a failed flow request into words for the user: the legacy\n * `describeFlowError` (src/utils/flow-error.ts), ported (pont2 imports nothing\n * from the legacy kit), with the same English and the same message codes, so\n * a flow's localised `messages` (keyed by code) apply unchanged.\n */\n\nexport type FlowMessageCode =\n | \"connection_failed\"\n | \"too_many_attempts\"\n | \"server_error\"\n | \"generic_error\"\n | \"flow_ended\"\n | \"passkey_cancelled\"\n | \"start_again\"\n | \"continued_elsewhere_title\"\n | \"continued_elsewhere_subtitle\"\n | \"continue_here\";\n\nexport const FLOW_MESSAGES_EN: Record<FlowMessageCode, string> = {\n connection_failed: \"We couldn't reach the server. Check your connection and try again.\",\n too_many_attempts: \"Too many attempts. Try again later.\",\n server_error: \"Something went wrong on our side. Please try again.\",\n generic_error: \"Something went wrong. Please try again.\",\n flow_ended: \"This sign-in could not be completed.\",\n passkey_cancelled: \"The passkey request was cancelled or timed out. Please try again.\",\n start_again: \"Start again\",\n continued_elsewhere_title: \"You continued in another tab\",\n continued_elsewhere_subtitle: \"You can close this one.\",\n continue_here: \"Continue here instead\",\n};\n\nexport interface FlowErrorDescription {\n message: string;\n /** The flow is over (409): offer \"Start again\". */\n restartable: boolean;\n}\n\nconst FLOW_ENDED_STATUS = 409;\n\n/**\n * - a cancelled or timed-out WebAuthn prompt (`NotAllowedError` / `AbortError`) → passkey_cancelled\n * - 409 → the server's sentence, else flow_ended; restartable\n * - no response at all (NETWORK_ERROR / TIMEOUT) → connection_failed\n * - 429 → too_many_attempts; ≥ 500 → server_error\n * - anything else → the server's sentence, else generic_error\n */\nexport function describeFlowError(\n error: unknown,\n messages: Partial<Record<string, string>> = {},\n): FlowErrorDescription {\n const msg = (code: FlowMessageCode) => messages[code] || FLOW_MESSAGES_EN[code];\n if (typeof DOMException !== \"undefined\" && error instanceof DOMException) {\n if (error.name === \"NotAllowedError\" || error.name === \"AbortError\") {\n return { message: msg(\"passkey_cancelled\"), restartable: false };\n }\n }\n const { status, code, message } = readError(error);\n if (status === FLOW_ENDED_STATUS) return { message: serverSentence(message) ?? msg(\"flow_ended\"), restartable: true };\n if (status === undefined && (code === \"NETWORK_ERROR\" || code === \"TIMEOUT\")) {\n return { message: msg(\"connection_failed\"), restartable: false };\n }\n if (status === 429) return { message: msg(\"too_many_attempts\"), restartable: false };\n if (status !== undefined && status >= 500) return { message: msg(\"server_error\"), restartable: false };\n return { message: serverSentence(message) ?? msg(\"generic_error\"), restartable: false };\n}\n\nfunction readError(error: unknown): { status?: number; code?: string; message?: string } {\n if (typeof error === \"string\") return { message: error };\n if (!error || typeof error !== \"object\") return {};\n const e = error as { status?: unknown; code?: unknown; message?: unknown };\n return {\n status: typeof e.status === \"number\" ? e.status : undefined,\n code: typeof e.code === \"string\" ? e.code : undefined,\n message: typeof e.message === \"string\" ? e.message : undefined,\n };\n}\n\n/** A server message fit to show: a sentence, not \"HTTP 400\" or something with code in backticks. */\nfunction serverSentence(message?: string): string | undefined {\n const text = message?.trim();\n if (!text) return undefined;\n if (/^HTTP \\d{3}\\b/.test(text) || text.includes(\"`\")) return undefined;\n const sentence = text.charAt(0).toUpperCase() + text.slice(1);\n return /[.!?。!?]$/u.test(sentence) ? sentence : `${sentence}.`;\n}\n","import { ContextProvider } from \"@lit/context\";\nimport { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport type { ActionErrorDetail, ActionRequestDetail } from \"../../core/controllers/action\";\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { brandingContext, DEFAULT_BRANDING, type BrandingEntitlements } from \"../block/branding\";\nimport { describeFlowError, FLOW_MESSAGES_EN } from \"./flow-error\";\n\nexport { describeFlowError, FLOW_MESSAGES_EN, type FlowErrorDescription, type FlowMessageCode } from \"./flow-error\";\n\n/**\n * What the layout needs from an auth client: one method. `Auth` from\n * `@pontive/oidc-client` satisfies it structurally, so pont2 never imports an\n * auth client (option (b), docs/kit/layout.md).\n */\nexport interface FlowClient {\n processLoginflowEvent(request: FlowEventRequest): Promise<FlowEventResponse>;\n}\n\nexport interface FlowEventRequest {\n event: string;\n data?: Record<string, unknown>;\n}\n\n/** The parts of the SDK's `ProcessEventResponse` the layout reads. */\nexport interface FlowEventResponse {\n state?: string;\n render_spec?: unknown;\n [key: string]: unknown;\n}\n\nexport interface UnregisteredElementDetail {\n tag: string;\n}\n\n/** FormData → the plain object the flow API takes (last value wins, files dropped). */\nexport function formDataToObject(fd: FormData | undefined | null): Record<string, unknown> | undefined {\n if (!fd) return undefined;\n const out: Record<string, unknown> = {};\n for (const [k, v] of fd.entries()) if (typeof v === \"string\") out[k] = v;\n return Object.keys(out).length ? out : undefined;\n}\n\nconst BANNER = \"data-flow-error\";\nconst reported = new Set<string>();\n\n/**\n * # `<pont2-layout>`: renders a flow screen and runs its requests\n *\n * ```ts\n * import { Auth } from \"@pontive/oidc-client\";\n * const layout = document.createElement(\"pont2-layout\");\n * layout.client = Auth; // anything with processLoginflowEvent()\n * layout.branding = response.branding; // the account's entitlements (fail closed)\n * layout.renderSpec = response.render_spec; // the server's HTML for the screen\n * ```\n *\n * ```html\n * <pont2-layout data-pont2-layout data-slot=\"layout\">\n * <form data-slot=\"layout-form\" aria-busy=\"false\">\n * …the render spec (e.g. <pont2-block>…</pont2-block>)…\n * </form>\n * </pont2-layout>\n * ```\n *\n * The **flow host** for one screen. It:\n *\n * 1. **renders the spec** (server HTML) inside one native `<form>`, upgrading\n * pont2 elements and reporting tags this bundle does not define\n * (`pont2-unregistered-element` on `document`, once per tag);\n * 2. **answers every `pont2-action`** from inside the screen (submit, provider,\n * passkey, link, OTP, resend, forgot, edit-identifier) with\n * `client.processLoginflowEvent({ event, data })`, where `data` is the\n * form's normalised FormData when the request carries one (submit, OTP\n * auto-submit); while a request is pending, another one joins it (no double\n * submit) and the form is `aria-busy`;\n * 3. **renders the next screen** when a response carries `render_spec`;\n * 4. **shows flow errors** (every `pont2-action-error` from inside) as an\n * error `pont2-alert` banner at the top of the screen, with \"Start again\"\n * (`pont2-layout-restart`) when the flow is over (409);\n * 5. **provides the branding entitlements** (`pont2:branding` context) to the\n * screen's block. Fails closed: without `branding`, the watermark shows.\n *\n * Trust boundary: the render spec is **server HTML** and is inserted as such\n * (as in the legacy `pont-layout`); everything a user types goes through\n * native inputs, never into markup. The spec must not contain its own\n * `<form>` (the layout's form is the one form).\n *\n * @tag pont2-layout\n * @prop client - `FlowClient` (e.g. the SDK's `Auth`). Without one, actions are not answered.\n * @prop renderSpec - the screen's HTML\n * @prop branding - `BrandingEntitlements` (attribute-less on purpose)\n * @prop messages - localised flow messages by code (the flow's `messages`)\n * @fires pont2-flow-response - `{ action, result }` after every successful request\n * @fires pont2-layout-restart - \"Start again\" pressed (the widget restarts the flow)\n * @fires pont2-unregistered-element - on `document`, `{ tag }`\n */\nexport class Layout extends HostElement {\n static override identity = \"layout\";\n static override slotName = \"layout\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n client: { attribute: false },\n renderSpec: { attribute: false },\n branding: { attribute: false },\n messages: { attribute: false },\n busy: { state: true },\n };\n\n declare client: FlowClient | undefined;\n declare renderSpec: string;\n declare branding: BrandingEntitlements;\n declare messages: Partial<Record<string, string>>;\n declare protected busy: boolean;\n\n private provider = new ContextProvider(this, { context: brandingContext, initialValue: DEFAULT_BRANDING });\n private pending: Promise<FlowEventResponse> | null = null;\n\n constructor() {\n super();\n this.client = undefined;\n this.renderSpec = \"\";\n this.branding = DEFAULT_BRANDING;\n this.messages = {};\n this.busy = false;\n this.addEventListener(\"pont2-action\", e => this.onAction(e));\n this.addEventListener(\"pont2-action-error\", e => this.onError(e));\n }\n\n /** The layout's form (holds the screen). */\n get form(): HTMLFormElement | null {\n return this.querySelector(\":scope > form\");\n }\n\n /** Runs one flow request (what a `pont2-action` from inside triggers). */\n run(event: string, data?: Record<string, unknown>): Promise<FlowEventResponse> {\n const client = this.client;\n if (!client) return Promise.reject(new Error(\"pont2-layout has no client\"));\n if (this.pending) return this.pending;\n this.clearBanner();\n this.busy = true;\n // Synchronously, not on the next render: the request has started now.\n this.form?.setAttribute(\"aria-busy\", \"true\");\n const request = client\n .processLoginflowEvent(data ? { event, data } : { event })\n .then(result => {\n if (typeof result?.render_spec === \"string\" && result.render_spec) this.renderSpec = result.render_spec;\n fire(this, \"pont2-flow-response\", { action: event, result });\n return result;\n })\n .finally(() => {\n this.pending = null;\n this.busy = false;\n this.form?.setAttribute(\"aria-busy\", \"false\");\n });\n this.pending = request;\n return request;\n }\n\n private onAction(e: CustomEvent<ActionRequestDetail>): void {\n const { action, data } = e.detail;\n if (!action || !this.client) return;\n e.detail.respondWith(this.run(action, formDataToObject(data.formData as FormData | undefined)));\n }\n\n private onError(e: CustomEvent<ActionErrorDetail>): void {\n const { message, restartable } = describeFlowError(e.detail.error, this.messages);\n this.showError(message, restartable);\n }\n\n /** Shows a flow error at the top of the screen (after its logo/header). */\n showError(message: string, restartable = false): void {\n const form = this.form;\n if (!form) return;\n this.clearBanner();\n const alert = document.createElement(\"pont2-alert\");\n alert.setAttribute(\"status\", \"error\");\n alert.setAttribute(\"icon\", \"\");\n alert.setAttribute(\"description\", message);\n alert.setAttribute(BANNER, \"\");\n const banner: HTMLElement[] = [alert];\n if (restartable) {\n const shell = document.createElement(\"pont2-button\");\n shell.setAttribute(\"variant\", \"outline\");\n shell.setAttribute(BANNER, \"\");\n const b = document.createElement(\"button\");\n b.type = \"button\";\n b.textContent = this.messages.start_again || FLOW_MESSAGES_EN.start_again;\n b.addEventListener(\"click\", () => fire(this, \"pont2-layout-restart\", {}));\n shell.append(b);\n banner.push(shell);\n }\n const block = form.querySelector(\":scope > pont2-block\");\n const parent = block ?? form;\n let anchor = parent.firstElementChild;\n while (anchor && /^pont2-(logo|header)$/.test(anchor.localName)) anchor = anchor.nextElementSibling;\n for (const el of banner) parent.insertBefore(el, anchor);\n }\n\n private clearBanner(): void {\n this.form?.querySelectorAll(`[${BANNER}]`).forEach(el => el.remove());\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"branding\")) this.provider.setValue(this.branding ?? DEFAULT_BRANDING);\n this.setData(\"busy\", this.busy);\n }\n\n protected override updated(changed: PropertyValues): void {\n const form = this.form;\n if (!form) return;\n form.setAttribute(\"aria-busy\", String(this.busy));\n if (changed.has(\"renderSpec\")) this.renderScreen(form);\n }\n\n private renderScreen(form: HTMLFormElement): void {\n form.innerHTML = this.renderSpec || \"\";\n for (const el of Array.from(form.querySelectorAll(\"*\"))) {\n if (!el.localName.includes(\"-\")) continue;\n if (customElements.get(el.localName)) customElements.upgrade(el);\n else if (!reported.has(el.localName)) {\n reported.add(el.localName);\n console.warn(`[pont2] <${el.localName}> is in the render spec but is not defined in this bundle.`);\n document.dispatchEvent(\n new CustomEvent<UnregisteredElementDetail>(\"pont2-unregistered-element\", { detail: { tag: el.localName } }),\n );\n }\n }\n }\n\n override render() {\n // The form's children are the render spec, written by renderScreen(), never by this template.\n return html`<form data-slot=\"layout-form\"></form>`;\n }\n}\n\ndefine(\"pont2-layout\", Layout);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-layout\": Layout;\n }\n interface HTMLElementEventMap {\n \"pont2-flow-response\": CustomEvent<{ action: string; result: FlowEventResponse }>;\n \"pont2-layout-restart\": CustomEvent<Record<string, never>>;\n }\n interface DocumentEventMap {\n \"pont2-unregistered-element\": CustomEvent<UnregisteredElementDetail>;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { Spinner } from \"../../primitives/spinner/spinner\";\nimport { DEFAULT_BRANDING, type BrandingEntitlements } from \"../block/branding\";\nimport { describeFlowError, FLOW_MESSAGES_EN, type FlowMessageCode } from \"../layout/flow-error\";\nimport type { FlowClient, Layout } from \"../layout/layout\";\nimport \"../layout/layout\";\n\n/**\n * What a widget needs from an auth client: the layout's `processLoginflowEvent`\n * plus `startLoginflow`, and optionally `whenConfigured`. The SDK's `Auth`\n * satisfies it structurally (docs/kit/layout.md, option (b)).\n */\nexport interface WidgetClient extends FlowClient {\n startLoginflow(flowId?: string): Promise<FlowStart>;\n whenConfigured?(): Promise<void>;\n}\n\n/** The parts of the SDK's `StartLoginflowResponse` a widget reads. */\nexport interface FlowStart {\n render_spec?: unknown;\n messages?: Record<string, string>;\n [key: string]: unknown;\n}\n\n/** The parts of the SDK's `FlowStateChangeEvent` a widget reads. */\nexport interface FlowStateEvent {\n eventType: string;\n flowType?: string;\n render_spec?: unknown;\n messages?: Record<string, string>;\n [key: string]: unknown;\n}\n\n/**\n * Feeds the SDK's asynchronous flow-state changes (a resumed flow, a flow an\n * emailed link continued, \"continued in another tab\") to every connected\n * pont2 flow widget of that `flowType`.\n *\n * The SDK reports them only through the one `onFlowStateChange` callback of\n * `Auth.configure()` (which replaces the whole configuration), so the widget\n * cannot subscribe by itself; the app that configures `Auth` passes this:\n *\n * ```ts\n * Auth.configure({ …config, onFlowStateChange: dispatchFlowState });\n * ```\n */\nexport function dispatchFlowState(event: FlowStateEvent): void {\n document.dispatchEvent(new CustomEvent<FlowStateEvent>(\"pont2-flow-state\", { detail: event }));\n}\n\n/** Text placed in a double-quoted attribute of markup built as a string. */\nexport function escapeAttr(value: string): string {\n return value.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\n\n/** How long to wait for `client.whenConfigured()` before warning and trying anyway. */\nconst CONFIGURE_TIMEOUT = 5000;\n\n/**\n * # FlowWidget: the base of `<pont2-signin>` / `<pont2-signup>`\n *\n * ```ts\n * import { Auth } from \"@pontive/oidc-client\";\n * import { dispatchFlowState } from \"@pontive/pontkit-core/pont2\";\n *\n * Auth.configure({ …, onFlowStateChange: dispatchFlowState });\n * document.querySelector(\"pont2-signin\")!.client = Auth;\n * ```\n *\n * ```html\n * <pont2-signin data-pont2-flow-widget data-slot=\"flow-widget\" data-state=\"screen\">\n * <pont2-layout>…the current screen…</pont2-layout>\n * </pont2-signin>\n * ```\n *\n * It **starts the flow** (`client.startLoginflow(flowId)`, after\n * `client.whenConfigured()` when the client has one), renders **one\n * `pont2-layout`** with the screen, the client, the branding entitlements and\n * the flow's localised messages, and keeps it current:\n *\n * - each request's next screen is rendered by the layout itself;\n * - asynchronous changes arrive through `dispatchFlowState` (see above): a new\n * `render_spec`, new `messages`, or `flow_continued_elsewhere`, which shows\n * \"You continued in another tab\" with a \"Continue here instead\" link\n * (`continue_here`, handled by the SDK);\n * - \"Start again\" in the layout (`pont2-layout-restart`), or `restart()`,\n * starts the flow over;\n * - a flow that fails to start shows the error in the layout, restartable.\n *\n * Until the first screen arrives it shows a spinner (`data-state=\"loading\"`).\n *\n * Nesting `pont2-layout` in a kit template is the allow-listed case (docs/10\n * §5 rule 6): the layout is the stateful flow host, one per widget.\n *\n * @prop client - `WidgetClient` (e.g. the SDK's `Auth`); the flow starts once it is set and the widget is connected\n * @prop branding - `BrandingEntitlements` from the backend (attribute-less; fails closed)\n * @attr flow-id - the flow to start (each widget has a default)\n * @fires pont2-flow-response - (from the layout) after every successful request\n */\nexport abstract class FlowWidget extends HostElement {\n static override identity = \"flow-widget\";\n static override slotName = \"flow-widget\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n client: { attribute: false },\n branding: { attribute: false },\n flowId: { type: String, attribute: \"flow-id\" },\n renderSpec: { state: true },\n messages: { state: true },\n starting: { state: true },\n startError: { state: true },\n };\n\n declare client: WidgetClient | undefined;\n declare branding: BrandingEntitlements;\n declare flowId: string;\n declare protected renderSpec: string;\n declare protected messages: Partial<Record<string, string>>;\n declare protected starting: boolean;\n declare protected startError: { message: string } | null;\n\n /** The SDK's `flowType` this widget runs (\"signin\", \"signup\"): which flow-state events apply. */\n protected abstract readonly flowType: string;\n\n private started = false;\n\n constructor() {\n super();\n this.client = undefined;\n this.branding = DEFAULT_BRANDING;\n this.flowId = \"\";\n this.renderSpec = \"\";\n this.messages = {};\n this.starting = false;\n this.startError = null;\n this.addEventListener(\"pont2-layout-restart\", () => void this.restart());\n }\n\n /** The widget's layout. */\n get layout(): Layout | null {\n return this.querySelector(\"pont2-layout\");\n }\n\n /** Starts the flow over. */\n async restart(): Promise<void> {\n this.started = false;\n await this.start();\n }\n\n /** Applies an SDK flow-state change (what `dispatchFlowState` delivers). */\n applyFlowState(event: FlowStateEvent): void {\n if (event.flowType && event.flowType !== this.flowType) return;\n if (event.messages) this.messages = { ...event.messages };\n if (event.eventType === \"flow_continued_elsewhere\") {\n this.startError = null;\n this.renderSpec = this.continuedElsewhereSpec();\n return;\n }\n if (typeof event.render_spec === \"string\" && event.render_spec) {\n this.startError = null;\n this.renderSpec = event.render_spec;\n }\n }\n\n private msg(code: FlowMessageCode): string {\n return this.messages[code] || FLOW_MESSAGES_EN[code];\n }\n\n private continuedElsewhereSpec(): string {\n return `<pont2-block>\n <pont2-header>\n <pont2-title content=\"${escapeAttr(this.msg(\"continued_elsewhere_title\"))}\"></pont2-title>\n <pont2-subtitle content=\"${escapeAttr(this.msg(\"continued_elsewhere_subtitle\"))}\"></pont2-subtitle>\n </pont2-header>\n <pont2-link label=\"${escapeAttr(this.msg(\"continue_here\"))}\" event=\"continue_here\"></pont2-link>\n</pont2-block>`;\n }\n\n private onFlowState = (e: Event) => this.applyFlowState((e as CustomEvent<FlowStateEvent>).detail);\n\n override connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener(\"pont2-flow-state\", this.onFlowState);\n void this.start();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"pont2-flow-state\", this.onFlowState);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"state\", this.startError ? \"error\" : this.renderSpec ? \"screen\" : \"loading\");\n // Only a newly set client starts the flow; a failed start waits for \"Start again\"\n // (re-renders must never retry on their own).\n if (changed.has(\"client\") && this.client && this.isConnected && !this.started) void this.start();\n }\n\n protected override updated(changed: PropertyValues): void {\n // The layout renders its form on its own update; show the error once it has.\n if (changed.has(\"startError\") && this.startError) {\n const { message } = this.startError;\n const layout = this.layout;\n void layout?.updateComplete.then(() => layout.showError(message, true));\n }\n }\n\n private async start(): Promise<void> {\n const client = this.client;\n if (!client || this.started) return;\n this.started = true;\n this.starting = true;\n this.startError = null;\n try {\n if (client.whenConfigured) {\n const configured = await Promise.race([\n client.whenConfigured().then(() => true),\n new Promise<false>(r => setTimeout(() => r(false), CONFIGURE_TIMEOUT)),\n ]);\n if (!configured) console.warn(`[pont2] <${this.localName}>: the client is not configured after ${CONFIGURE_TIMEOUT}ms.`);\n }\n const res = await client.startLoginflow(this.flowId || this.defaultFlowId());\n if (res?.messages) this.messages = { ...res.messages };\n if (typeof res?.render_spec === \"string\") this.renderSpec = res.render_spec;\n } catch (err) {\n console.error(`[pont2] <${this.localName}>: starting the flow failed:`, err);\n this.started = false;\n // An empty shell to show the error in, with \"Start again\" (restartable).\n this.renderSpec = \"<pont2-block></pont2-block>\";\n this.startError = { message: describeFlowError(err, this.messages).message };\n } finally {\n this.starting = false;\n }\n }\n\n /** The flow id used when `flow-id` is not set. */\n protected abstract defaultFlowId(): string;\n\n override render() {\n if (!this.renderSpec) {\n return html`<div data-slot=\"flow-widget-loading\">\n <span ${Spinner.part({ \"aria-label\": \"Loading\" })}></span>\n </div>`;\n }\n return html`<pont2-layout\n .client=${this.client}\n .branding=${this.branding}\n .messages=${this.messages}\n .renderSpec=${this.renderSpec}\n ></pont2-layout>`;\n }\n}\n\n/**\n * # `<pont2-signin>`: the sign-in widget\n *\n * Runs `sys_signin-flow-passkey` (the legacy default) unless `flow-id` says otherwise.\n *\n * @tag pont2-signin\n */\nexport class SignIn extends FlowWidget {\n protected readonly flowType = \"signin\";\n protected defaultFlowId() {\n return \"sys_signin-flow-passkey\";\n }\n}\n\n/**\n * # `<pont2-signup>`: the sign-up widget\n *\n * Runs `sys_signup-flow` (the legacy default) unless `flow-id` says otherwise.\n *\n * @tag pont2-signup\n */\nexport class SignUp extends FlowWidget {\n protected readonly flowType = \"signup\";\n protected defaultFlowId() {\n return \"sys_signup-flow\";\n }\n}\n\ndefine(\"pont2-signin\", SignIn);\ndefine(\"pont2-signup\", SignUp);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-signin\": SignIn;\n \"pont2-signup\": SignUp;\n }\n interface DocumentEventMap {\n \"pont2-flow-state\": CustomEvent<FlowStateEvent>;\n }\n}\n","/**\n * Previewing pont2 screens without a server: what the dashboard's branding\n * editor shows (docs/12-theming-integration.md §3).\n *\n * The backend does not emit pont2 render specs yet (docs/09 decision 2), so a\n * preview cannot ask a real flow for its screens. These sample screens are\n * written the way a render spec would write them, and between them they use\n * every auth element whose tokens a brand is likely to change.\n *\n * Preview inside a real `<pont2-signin>` / `<pont2-signup>`, not a bare\n * `pont2-layout`: widget-scope theme values (`widgets.signin` …) apply to the\n * widget's tag, so only a widget shows them.\n *\n * ```ts\n * import { previewClient, PREVIEW_SCREENS } from \"@pontive/pontkit-core/pont2\";\n *\n * const widget = document.querySelector(\"pont2-signin\")!;\n * widget.client = previewClient(PREVIEW_SCREENS.signin.spec);\n * // switching screens later:\n * widget.client = previewClient(PREVIEW_SCREENS.verify.spec);\n * void widget.restart();\n * ```\n *\n * Pure data and a plain object: no DOM, no Lit, no network.\n */\nimport type { FlowEventRequest, FlowEventResponse } from \"../layout/layout\";\nimport type { FlowStart, WidgetClient } from \"./flow-widget\";\n\nexport interface PreviewScreen {\n /** A name for a screen picker. */\n label: string;\n /** The widget to preview it in (its tag is `pont2-<flow>`). */\n flow: \"signin\" | \"signup\";\n /** The screen, as a render spec would write it. */\n spec: string;\n}\n\nconst signin = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Welcome back\"></pont2-title>\n <pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>\n </pont2-header>\n <pont2-provider-field providers=\"google apple github\"></pont2-provider-field>\n <pont2-divider label=\"Or continue with\"></pont2-divider>\n <pont2-identifier-field identifiers=\"email username\" required></pont2-identifier-field>\n <pont2-submit-button event=\"submit_identifier\" label=\"Continue\"></pont2-submit-button>\n <pont2-passkey-button content=\"icon-label\" event=\"passkey\"></pont2-passkey-button>\n <pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>\n</pont2-block>`;\n\nconst password = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Enter your password\"></pont2-title>\n </pont2-header>\n <pont2-edit-identifier identifier=\"ada@example.com\" event=\"change_identifier\"></pont2-edit-identifier>\n <pont2-password-field required rules=\"[]\" forgot forgot-event=\"forgot_password\"></pont2-password-field>\n <pont2-submit-button event=\"submit_password\" label=\"Sign in\"></pont2-submit-button>\n</pont2-block>`;\n\nconst verify = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Check your email\"></pont2-title>\n <pont2-subtitle content=\"We sent a 6-digit code to ada@example.com\"></pont2-subtitle>\n </pont2-header>\n <pont2-alert status=\"info\" icon description=\"The code expires in 10 minutes.\"></pont2-alert>\n <pont2-container align=\"center\">\n <pont2-otp-field layout=\"simple\" required></pont2-otp-field>\n </pont2-container>\n <pont2-submit-button event=\"verify_code\" label=\"Verify\"></pont2-submit-button>\n <pont2-otp-resend duration=\"30\" event=\"resend_code\"></pont2-otp-resend>\n</pont2-block>`;\n\nconst signup = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Create an account\"></pont2-title>\n <pont2-subtitle content=\"It only takes a minute\"></pont2-subtitle>\n </pont2-header>\n <pont2-name-field required></pont2-name-field>\n <pont2-email-field required></pont2-email-field>\n <pont2-password-field required></pont2-password-field>\n <pont2-confirm-field required></pont2-confirm-field>\n <pont2-submit-button event=\"submit_signup\" label=\"Create account\"></pont2-submit-button>\n <pont2-link prompt=\"Already have an account?\" label=\"Sign in\" event=\"goto_signin\"></pont2-link>\n</pont2-block>`;\n\n/** Sample screens for a branding preview, keyed by id. */\nexport const PREVIEW_SCREENS = {\n signin: { label: \"Sign in\", flow: \"signin\", spec: signin },\n password: { label: \"Password\", flow: \"signin\", spec: password },\n verify: { label: \"Verification code\", flow: \"signin\", spec: verify },\n signup: { label: \"Sign up\", flow: \"signup\", spec: signup },\n} as const satisfies Record<string, PreviewScreen>;\n\nexport type PreviewScreenId = keyof typeof PREVIEW_SCREENS;\n\nexport interface PreviewClientOptions {\n /** How long each request stays busy, in ms, so busy states can be seen (default 600). */\n delay?: number;\n /** The flow's localised messages (flow errors, \"Start again\" …). */\n messages?: Record<string, string>;\n}\n\n/**\n * A `WidgetClient` that shows one screen and never leaves it. Every request\n * (a submit, a provider button, a link) is busy for `delay` ms and then\n * resolves without a new screen, so the screen and what was typed stay put.\n * Nothing is sent anywhere.\n */\nexport function previewClient(spec: string, options: PreviewClientOptions = {}): WidgetClient {\n const delay = options.delay ?? 600;\n const messages = { ...options.messages };\n return {\n async whenConfigured() {},\n async startLoginflow(): Promise<FlowStart> {\n return { render_spec: spec, messages };\n },\n processLoginflowEvent(_request: FlowEventRequest): Promise<FlowEventResponse> {\n return new Promise(resolve => setTimeout(() => resolve({ state: \"preview\" }), delay));\n },\n };\n}\n","/**\n * Preview specimens: one component at a time, for the dashboard's Component\n * scope (docs/14-dashboard-branding.md §\"Previews\").\n *\n * `PREVIEW_SCREENS` shows whole sign-in screens, which is right for the\n * Global scope. When the branding editor is open on one component (\"Button\",\n * \"Alert\" …) it shows that component's specimen instead: its variants, sizes\n * and states side by side, so every token in its panel has something visible\n * to change.\n *\n * - **Keyed by token component** (a manifest `component`, `tokens.json`), not\n * by tag: that is what the editor's items are. A guardrail checks every key\n * is one.\n * - **pont2 owns the markup.** The dashboard renders `html` as given and never\n * writes pont2 markup itself, so a markup change here never needs a\n * dashboard change.\n * - Specimens sit at the global scope (no widget around them): the editor's\n * Component scope edits `:root` tokens.\n * - Nothing in a specimen reaches a server: there is no flow host, so action\n * buttons only show their busy state, if anything.\n *\n * Pure data: no DOM, no Lit, no network.\n */\n\nexport interface PreviewSpecimen {\n /** A name for the specimen. */\n label: string;\n /** The markup to render, inside a `<form>` that does not submit. */\n html: string;\n}\n\nconst row = (items: string) => `<div style=\"display:flex;flex-wrap:wrap;gap:.75rem;align-items:center\">${items}</div>`;\nconst stack = (items: string, width = \"24rem\") =>\n `<div style=\"display:grid;gap:1.5rem;max-width:${width}\">${items}</div>`;\nconst caption = (text: string) =>\n `<p style=\"margin:0 0 .5rem;font-size:.75rem;opacity:.6\">${text}</p>`;\nconst section = (title: string, body: string) => `<section>${caption(title)}${body}</section>`;\n\nconst VARIANTS = [\"default\", \"secondary\", \"outline\", \"ghost\", \"destructive\", \"link\"];\nconst SIZES = [\"xs\", \"sm\", \"default\", \"lg\"];\n\nconst button = stack(\n [\n section(\n \"Variants\",\n row(VARIANTS.map(v => `<button type=\"button\" data-pont2-button data-variant=\"${v}\">${v[0].toUpperCase()}${v.slice(1)}</button>`).join(\"\")),\n ),\n section(\n \"Sizes\",\n row(SIZES.map(s => `<button type=\"button\" data-pont2-button data-size=\"${s}\">Size ${s}</button>`).join(\"\")),\n ),\n section(\n \"Disabled\",\n row(`<button type=\"button\" data-pont2-button disabled>Default</button><button type=\"button\" data-pont2-button data-variant=\"outline\" disabled>Outline</button>`),\n ),\n ].join(\"\"),\n \"40rem\",\n);\n\nconst field = (id: string, label: string, input: string, description = \"\") =>\n `<pont2-prim-field>\n <label data-pont2-label data-pont2-field-label data-slot=\"field-label\" for=\"${id}\">${label}</label>\n ${input}\n ${description ? `<pont2-prim-field-description>${description}</pont2-prim-field-description>` : \"\"}\n </pont2-prim-field>`;\n\nconst inputs = stack(\n [\n section(\"Default\", `<input data-pont2-input id=\"s-input\" placeholder=\"you@example.com\">`),\n section(\"Filled\", `<input data-pont2-input value=\"ada@example.com\">`),\n section(\"Invalid\", `<input data-pont2-input aria-invalid=\"true\" value=\"not-an-email\">`),\n section(\"Disabled\", `<input data-pont2-input disabled value=\"Disabled\">`),\n ].join(\"\"),\n);\n\nconst fields = stack(\n [\n field(\"s-email\", \"Email\", `<input data-pont2-input id=\"s-email\" type=\"email\" placeholder=\"you@example.com\">`, \"We'll never share it.\"),\n field(\"s-name\", \"Name\", `<input data-pont2-input id=\"s-name\" aria-invalid=\"true\">`, \"This field is required.\"),\n `<pont2-email-field required></pont2-email-field>`,\n `<pont2-password-field required rules=\"[]\" forgot></pont2-password-field>`,\n ].join(\"\"),\n);\n\nconst checkbox = stack(\n [\n row(`<pont2-checkbox id=\"s-c1\" checked></pont2-checkbox><label data-pont2-label for=\"s-c1\">Remember me</label>`),\n row(`<pont2-checkbox id=\"s-c2\"></pont2-checkbox><label data-pont2-label for=\"s-c2\">Unchecked</label>`),\n row(`<pont2-checkbox id=\"s-c3\" aria-invalid=\"true\"></pont2-checkbox><label data-pont2-label for=\"s-c3\">Invalid</label>`),\n row(`<pont2-checkbox id=\"s-c4\" checked disabled></pont2-checkbox><label data-pont2-label for=\"s-c4\">Disabled</label>`),\n ].join(\"\"),\n);\n\nconst alerts = stack(\n [\n `<pont2-alert icon heading=\"Default\" description=\"A neutral message.\"></pont2-alert>`,\n `<pont2-alert icon status=\"info\" heading=\"New sign-in\" description=\"We noticed a sign-in from a new device.\"></pont2-alert>`,\n `<pont2-alert icon status=\"success\" heading=\"Saved\" description=\"Your changes have been saved.\"></pont2-alert>`,\n `<pont2-alert icon status=\"warning\" heading=\"Almost out\" description=\"Your code expires in one minute.\"></pont2-alert>`,\n `<pont2-alert icon status=\"error\" heading=\"Sign-in failed\" description=\"Check your email and password.\"></pont2-alert>`,\n ].join(\"\"),\n \"28rem\",\n);\n\nconst badges = row(\n [\"default\", \"secondary\", \"outline\", \"destructive\", \"ghost\", \"link\"]\n .map(v => `<pont2-badge variant=\"${v}\">${v}</pont2-badge>`)\n .join(\"\"),\n);\n\nconst block = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Welcome back\"></pont2-title>\n <pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>\n </pont2-header>\n <pont2-email-field required></pont2-email-field>\n <pont2-submit-button event=\"submit\" label=\"Continue\"></pont2-submit-button>\n</pont2-block>`;\n\nconst typography = stack(\n [\n `<pont2-title content=\"Welcome back\"></pont2-title>`,\n `<pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>`,\n ].join(\"\"),\n);\n\nexport const PREVIEW_SPECIMENS: Readonly<Record<string, PreviewSpecimen>> = {\n button: { label: \"Button\", html: button },\n \"provider-button\": {\n label: \"Provider buttons\",\n html: stack(\n [\n `<pont2-provider-button provider=\"google\"></pont2-provider-button>`,\n `<pont2-provider-button provider=\"apple\"></pont2-provider-button>`,\n row(`<pont2-provider-button provider=\"google\" content=\"icon\"></pont2-provider-button><pont2-provider-button provider=\"github\" content=\"icon\"></pont2-provider-button>`),\n `<pont2-passkey-button content=\"icon-label\"></pont2-passkey-button>`,\n ].join(\"\"),\n ),\n },\n input: { label: \"Input\", html: inputs },\n field: { label: \"Field\", html: fields },\n label: { label: \"Label\", html: fields },\n checkbox: { label: \"Checkbox\", html: checkbox },\n \"input-otp\": {\n label: \"One-time code\",\n html: stack(\n [\n `<pont2-input-otp aria-label=\"Verification code\"></pont2-input-otp>`,\n `<pont2-input-otp group-size=\"3\" separator aria-label=\"Code\"></pont2-input-otp>`,\n ].join(\"\"),\n ),\n },\n \"otp-resend\": { label: \"Resend code\", html: `<pont2-otp-resend duration=\"5\" event=\"resend_code\"></pont2-otp-resend>` },\n link: {\n label: \"Link\",\n html: stack(\n [\n `<pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>`,\n `<pont2-link label=\"Forgot password?\" event=\"forgot\"></pont2-link>`,\n ].join(\"\"),\n ),\n },\n alert: { label: \"Alert\", html: alerts },\n separator: {\n label: \"Separator\",\n html: stack(`<pont2-separator></pont2-separator><pont2-divider label=\"Or continue with\"></pont2-divider>`),\n },\n badge: { label: \"Badge\", html: badges },\n block: { label: \"Block\", html: block },\n header: { label: \"Header\", html: block },\n container: { label: \"Container\", html: block },\n title: { label: \"Title\", html: typography },\n subtitle: { label: \"Subtitle\", html: typography },\n avatar: {\n label: \"Avatar\",\n html: row(\n `<pont2-avatar alt=\"Ada Lovelace\" size=\"sm\"></pont2-avatar><pont2-avatar alt=\"Grace Hopper\"></pont2-avatar><pont2-avatar alt=\"Katherine Johnson\" size=\"lg\"></pont2-avatar>`,\n ),\n },\n \"qr-code\": {\n label: \"QR code\",\n html: `<pont2-qr-code url=\"otpauth://totp/Pontive:ada@example.com?secret=JBSWY3DPEHPK3PXP\" timeout=\"0\" label=\"Scan with your authenticator app\"></pont2-qr-code>`,\n },\n \"recovery-codes\": {\n label: \"Recovery codes\",\n html: `<pont2-recovery-codes codes='[\"3f9a-81c2\",\"7d01-4be9\",\"a6c4-02f7\",\"5e88-c13d\",\"90b2-7fa6\",\"1c5e-d840\"]'></pont2-recovery-codes>`,\n },\n watermark: {\n label: \"Watermark\",\n html: stack(`<pont2-watermark></pont2-watermark><pont2-watermark variant=\"muted\" label=\"Secured by\"></pont2-watermark>`),\n },\n};\n"],"names":["AttrsDirective","Directive","info","PartType","_attrs","noChange","part","map","applyAttrs","attrs","directive","el","previous","k","v","s","PREFIX","PRIM","tag","name","primTag","identityAttr","identity","sel","tags","define","ctor","aliases","defineAlias","kitTag","base","alias","_HostElement","LitElement","extra","id","identitiesOf","changed","ReactiveElement","value","attr","on","HostElement","out","c","_ShellElement","options","_a","ShellElement","_NativeEnhancer","child","NativeEnhancer","_FormControlElement","message","disabled","state","_state","own","FormControlElement","counter","uid","scope","ensureId","toggleIdRef","ids","fireNative","target","type","fire","detail","cancelable","icon","body","html","icons","a","svg","directionOf","owner","defaultDisabled","RovingFocusController","host","e","item","i","items","current","orientation","rtl","horizontal","vertical","step","next","_b","active","enabled","stop","from","ok","loop","ActionController","action","data","response","open","result","error","CopyController","kind","duration","text","BADGE_VARIANTS","_Badge","Badge","BUTTON_VARIANTS","BUTTON_SIZES","applyButton","o","native","isSoftDisabled","button","content","variant","size","slot","soft","onClick","nothing","recipeProperties","_Pont2Button","control","Pont2Button","_ButtonBase","focusableWhenDisabled","href","rel","ButtonBase","_Checkbox","Checkbox","applyInput","input","live","_Pont2Input","Pont2Input","_Kbd","Kbd","_KbdGroup","KbdGroup","applyLabel","label","_Pont2Label","Pont2Label","_Separator","Separator","_Skeleton","Skeleton","_Spinner","Spinner","applyTextarea","textarea","_Pont2Textarea","Pont2Textarea","ALERT_VARIANTS","_Alert","Alert","_AlertTitle","AlertTitle","_AlertDescription","AlertDescription","_AlertAction","AlertAction","_Avatar","img","status","Avatar","_AvatarFallback","AvatarFallback","_AvatarBadge","AvatarBadge","_AvatarGroup","AvatarGroup","_AvatarGroupCount","AvatarGroupCount","_ButtonGroup","ButtonGroup","_ButtonGroupText","ButtonGroupText","_ButtonGroupSeparator","ButtonGroupSeparator","_Card","Card","_CardHeader","CardHeader","_CardTitle","CardTitle","_CardDescription","CardDescription","_CardAction","CardAction","_CardContent","CardContent","_CardFooter","CardFooter","_Empty","Empty","_EmptyHeader","EmptyHeader","_EmptyMedia","EmptyMedia","_EmptyTitle","EmptyTitle","_EmptyDescription","EmptyDescription","_EmptyContent","EmptyContent","applyFieldSet","fieldSet","fieldLegend","_FieldSetElement","FieldSetElement","_FieldGroup","FieldGroup","_Field","Field","_FieldContent","FieldContent","applyFieldLabel","fieldLabel","_FieldLabelElement","FieldLabelElement","_FieldTitle","FieldTitle","_FieldDescription","FieldDescription","_FieldSeparator","FieldSeparator","_FieldError","unique","FieldError","_InputGroup","InputGroup","_InputGroupAddon","InputGroupAddon","_InputGroupText","InputGroupText","CONTROL","markControl","inputGroupInput","inputGroupTextarea","inputGroupButton","_InputGroupInput","InputGroupInput","_InputGroupTextarea","InputGroupTextarea","InputGroupButton","_ItemGroup","ItemGroup","_ItemSeparator","ItemSeparator","_Item","Item","_ItemMedia","ItemMedia","_ItemContent","ItemContent","_ItemTitle","ItemTitle","_ItemDescription","ItemDescription","_ItemActions","ItemActions","_ItemHeader","ItemHeader","_ItemFooter","ItemFooter","_NativeSelect","select","applyNativeSelect","NativeSelect","nativeSelect","_Table","Table","PARTS","mark","applyTable","table","section","row","cell","REGEXP_ONLY_DIGITS","REGEXP_ONLY_CHARS","REGEXP_ONLY_DIGITS_AND_CHARS","sanitizeOtp","raw","maxLength","pattern","re","ch","otpSlots","focused","selStart","selEnd","chars","start","end","collapsed","_","char","isActive","ROOT","SLOT","FORWARDED","_InputOTP","n","m","r","f","states","invalid","order","clean","was","digits","InputOTP","_InputOTPGroup","InputOTPGroup","_InputOTPSlot","hasFakeCaret","InputOTPSlot","_InputOTPSeparator","InputOTPSeparator","_Progress","span","labels","l","parts","p","styleMap","Progress","ProgressPart","_formatted","_ProgressLabel","ProgressLabel","_ProgressValue","formatted","ProgressValue","_RadioGroup","checked","RadioGroup","_RadioGroupItem","RadioGroupItem","clamp","min","max","decimals","snap","snapped","d","fraction","valueAt","closestThumb","values","best","bestDist","setThumb","index","range","minSteps","gap","lo","hi","keyValue","key","opts","small","flip","parseValues","fallback","b","_Slider","onThumb","_c","arr","fd","final","rect","thumb","t","fr","thumbPos","rangeStyle","names","repeat","_v","Slider","_Switch","Switch","TRIGGER","PANEL","relate","internals","prop","targets","_Tabs","trigger","triggers","to","panels","ready","list","panel","Tabs","_TabsList","direction","TabsList","_TabsTrigger","TabsTrigger","_TabsContent","TabsContent","OPPOSITE","toPhysical","side","dir","toRequestedVocabulary","physical","requested","isVertical","spaceOn","anchor","viewport","offset","pad","computePosition","floating","align","sideOffset","alignOffset","collisionPadding","shift","need","here","there","x","y","startEdge","endEdge","sign","mainSpace","availableHeight","availableWidth","ax","ay","transformOrigin","round","alignItemWithAnchor","AnchoredPositioner","anchorEl","style","set","it","aligned","isItemDisabled","isItemVisible","moveIndex","move","isDisabled","keyToMove","Typeahead","timeout","repeated","search","stack","globalListeners","installGlobalListeners","top","path","popup","_PopupContent","reason","gen","anims","PopupContent","openPopups","ownQuery","root","selector","rootSelector","ownQueryAll","_PopupRoot","hadFocus","focusWasInside","PopupRoot","_PopupTrigger","_e","PopupTrigger","FOCUSABLE","_Popover","Popover","_PopoverTrigger","PopoverTrigger","_PopoverContent","title","desc","PopoverContent","_PopoverHeader","PopoverHeader","_PopoverTitle","PopoverTitle","_PopoverDescription","PopoverDescription","ROOTS","CONTENT","ITEM","trueUnlessFalse","_DropdownMenu","focus","DropdownMenu","_DropdownMenuSub","DropdownMenuSub","_DropdownMenuTrigger","DropdownMenuTrigger","_DropdownMenuContent","DropdownMenuSubTrigger","closeKey","DropdownMenuSubContent","sub","except","keep","DropdownMenuContent","_DropdownMenuSubContent","_MenuItemBase","MenuItemBase","_DropdownMenuItem","DropdownMenuItem","indicator","_DropdownMenuCheckboxItem","DropdownMenuCheckboxItem","_DropdownMenuRadioGroup","DropdownMenuRadioGroup","_DropdownMenuRadioItem","DropdownMenuRadioItem","_DropdownMenuSubTrigger","openKey","_DropdownMenuGroup","DropdownMenuGroup","_DropdownMenuLabel","DropdownMenuLabel","_DropdownMenuSeparator","DropdownMenuSeparator","_DropdownMenuShortcut","DropdownMenuShortcut","_Select","Select","_SelectTrigger","SelectTrigger","_SelectContent","SelectContent","_SelectItem","selected","SelectItem","_SelectGroup","SelectGroup","_SelectLabel","SelectLabel","_SelectSeparator","SelectSeparator","_Combobox","query","norm","scroll","q","visible","show","group","empty","Combobox","_ComboboxInput","hasValue","ComboboxInput","_ComboboxContent","ComboboxContent","_ComboboxList","ComboboxList","_ComboboxItem","ComboboxItem","_ComboboxEmpty","ComboboxEmpty","_ComboboxGroup","ComboboxGroup","_ComboboxLabel","ComboboxLabel","_ComboboxSeparator","ComboboxSeparator","_Tooltip","ms","Tooltip","_TooltipTrigger","TooltipTrigger","_TooltipContent","TooltipContent","ALERT_STATUSES","STATUS_ICON","_KitAlert","KitAlert","initials","words","w","_KitAvatar","KitAvatar","groupSizes","length","g","left","otpGroups","groupSize","separator","slots","sep","_KitInputOTP","KitInputOTP","AUTH_PROVIDERS","PROVIDER_NAMES","MARKS","isAuthProvider","providerIcon","provider","AUTH_BUTTON_CONTENTS","_AuthButton","iconOnly","busy","showIcon","showLabel","AuthButton","_ProviderButton","ProviderButton","PasskeyButton","SubmitButton","form","isDefault","formData","cap","fieldMessages","compilePattern","source","positive","focusClaimed","_AuthField","issues","describedBy","messages","descId","errId","AuthField","EmailField","PhoneField","UsernameField","NameField","IDENTIFIER_KINDS","identifierLabel","kinds","_IdentifierField","IdentifierField","PASSWORD_RULE_PATTERNS","DEFAULT_PASSWORD_RULES","ruleRegExp","rulesConverter","parsed","_SecretField","SecretField","_PasswordField","failing","PasswordField","_ConfirmField","pair","other","ConfirmField","_OtpField","otp","byLayout","OtpField","_OtpResend","OtpResend","_Link","_changed","Link","_Divider","Divider","_TextShell","TextShell","_Title","level","Title","Subtitle","providerColumns","count","providerEvent","listConverter","jsonArray","_ProviderField","overrides","opt","ProviderField","PONTIVE_MARK","PONTIVE_WORDMARK","pontiveLogo","watermarkContent","logoAlign","_Watermark","Watermark","DEFAULT_BRANDING","brandingContext","createContext","BrandingController","ContextConsumer","_Block","Block","_Container","Container","_Header","Header","_Gap","Gap","logoSource","theme","url","_Logo","light","dark","alt","Logo","safeRedirect","_Countdown","Countdown","_EditIdentifier","EditIdentifier","_Secret","copied","meta","Secret","QUIET","qrPath","modules","QRCode","_QrCode","obscured","QrCode","codesConverter","_RecoveryCodes","codes","off","RecoveryCodes","normalizeScopes","scopes","seen","granted","required","isScopeChecked","unticked","scopeListValue","scopesConverter","_ScopeList","ticked","ScopeList","FLOW_MESSAGES_EN","FLOW_ENDED_STATUS","describeFlowError","msg","code","readError","serverSentence","sentence","formDataToObject","BANNER","reported","_Layout","ContextProvider","event","client","request","restartable","alert","banner","shell","parent","Layout","dispatchFlowState","escapeAttr","CONFIGURE_TIMEOUT","_FlowWidget","layout","res","err","FlowWidget","SignIn","SignUp","signin","password","verify","signup","PREVIEW_SCREENS","previewClient","spec","delay","_request","resolve","width","caption","VARIANTS","SIZES","field","description","inputs","fields","checkbox","alerts","badges","block","typography","PREVIEW_SPECIMENS"],"mappings":";;;;;;;AAeA,MAAMA,WAAuBC,GAAU;AAAA,EAGrC,YAAYC,GAAgB;AAE1B,QADA,MAAMA,CAAI,GAHZ,KAAQ,2BAAW,IAAA,GAIbA,EAAK,SAASC,GAAS,QAAS,OAAM,IAAI,MAAM,0CAA0C;AAAA,EAChG;AAAA,EAEA,OAAOC,GAAiB;AACtB,WAAOC;AAAA,EACT;AAA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,EAAE,OAAO,SAAS,MAAMwV,GAAA;AAAA,EAC/B,OAAO,EAAE,OAAO,SAAS,MAAMC,GAAA;AAAA,EAC/B,QAAQ,EAAE,OAAO,UAAU,MAAMA,GAAA;AAAA,EACjC,WAAW,EAAE,OAAO,aAAa,MAAMA,GAAA;AAAA,EACvC,OAAO,EAAE,OAAO,SAAS,MAAMC,GAAA;AAAA,EAC/B,UAAU,EAAE,OAAO,YAAY,MAAMA,GAAA;AAAA,EACrC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,MAAMlhB;AAAA,MACJ;AAAA,IAAA;AAAA,EACF;AAAA,EAEF,WAAW;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,kBAAkB;AAAA,IAChB,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,WAAW;AAAA,IACT,OAAO;AAAA,IACP,MAAMwL,EAAM,2GAA2G;AAAA,EAAA;AAE3H;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../pont2/src/core/attrs.ts","../../pont2/src/core/names.ts","../../pont2/src/core/host-element.ts","../../pont2/src/core/form-control.ts","../../pont2/src/core/ids.ts","../../pont2/src/core/events.ts","../../pont2/src/core/icons.ts","../../pont2/src/core/messages.ts","../../pont2/src/core/url.ts","../../pont2/src/core/controllers/roving-focus.ts","../../pont2/src/core/controllers/action.ts","../../pont2/src/core/controllers/copy.ts","../../pont2/src/primitives/badge/badge.ts","../../pont2/src/primitives/button/button.ts","../../pont2/src/primitives/checkbox/checkbox.ts","../../pont2/src/primitives/input/input.ts","../../pont2/src/primitives/kbd/kbd.ts","../../pont2/src/primitives/label/label.ts","../../pont2/src/primitives/separator/separator.ts","../../pont2/src/primitives/skeleton/skeleton.ts","../../pont2/src/primitives/spinner/spinner.ts","../../pont2/src/primitives/textarea/textarea.ts","../../pont2/src/primitives/alert/alert.ts","../../pont2/src/primitives/avatar/avatar.ts","../../pont2/src/primitives/button-group/button-group.ts","../../pont2/src/primitives/card/card.ts","../../pont2/src/primitives/empty/empty.ts","../../pont2/src/primitives/field/field.ts","../../pont2/src/primitives/input-group/input-group.ts","../../pont2/src/primitives/item/item.ts","../../pont2/src/primitives/native-select/native-select.ts","../../pont2/src/primitives/table/table.ts","../../pont2/src/primitives/input-otp/otp.ts","../../pont2/src/primitives/input-otp/input-otp.ts","../../pont2/src/primitives/progress/progress.ts","../../pont2/src/primitives/radio-group/radio-group.ts","../../pont2/src/primitives/slider/slider-math.ts","../../pont2/src/primitives/slider/slider.ts","../../pont2/src/primitives/switch/switch.ts","../../pont2/src/primitives/tabs/tabs.ts","../../pont2/src/core/popup/position.ts","../../pont2/src/core/popup/anchored.ts","../../pont2/src/core/popup/list.ts","../../pont2/src/core/popup/popup-content.ts","../../pont2/src/core/popup/popup-root.ts","../../pont2/src/primitives/popover/popover.ts","../../pont2/src/primitives/dropdown-menu/dropdown-menu.ts","../../pont2/src/primitives/select/select.ts","../../pont2/src/primitives/combobox/combobox.ts","../../pont2/src/primitives/tooltip/tooltip.ts","../../pont2/src/kit/aliases.ts","../../pont2/src/kit/alert/alert.ts","../../pont2/src/kit/avatar/avatar.ts","../../pont2/src/kit/input-otp/input-otp.ts","../../pont2/src/kit/auth-button/providers.ts","../../pont2/src/kit/auth-button/auth-button.ts","../../pont2/src/kit/auth-field/auth-field.ts","../../pont2/src/kit/auth-field/password-field.ts","../../pont2/src/kit/otp-field/otp-field.ts","../../pont2/src/kit/otp-field/otp-resend.ts","../../pont2/src/kit/link/link.ts","../../pont2/src/kit/divider/divider.ts","../../pont2/src/kit/typography/typography.ts","../../pont2/src/kit/provider-field/provider-field.ts","../../pont2/src/kit/watermark/pontive-logo.ts","../../pont2/src/kit/watermark/watermark.ts","../../pont2/src/kit/block/branding.ts","../../pont2/src/kit/block/block.ts","../../pont2/src/kit/container/container.ts","../../pont2/src/kit/header/header.ts","../../pont2/src/kit/gap/gap.ts","../../pont2/src/kit/logo/logo.ts","../../pont2/src/kit/countdown/countdown.ts","../../pont2/src/kit/edit-identifier/edit-identifier.ts","../../pont2/src/kit/secret/secret.ts","../../pont2/src/kit/qr-code/qr-code.ts","../../pont2/src/kit/recovery-codes/recovery-codes.ts","../../pont2/src/kit/scope-list/scope-value.ts","../../pont2/src/kit/scope-list/scope-list.ts","../../pont2/src/kit/layout/flow-error.ts","../../pont2/src/kit/layout/layout.ts","../../pont2/src/kit/consent/consent-api.ts","../../pont2/src/kit/consent/consent.ts","../../pont2/src/kit/flow-widget/flow-widget.ts","../../pont2/src/kit/flow-widget/preview.ts","../../pont2/src/kit/flow-widget/specimens.ts"],"sourcesContent":["import { noChange } from \"lit\";\nimport { Directive, directive, PartType, type ElementPart, type PartInfo } from \"lit/directive.js\";\n\nexport type AttrValue = string | number | boolean | null | undefined;\nexport type AttrMap = Record<string, AttrValue>;\n\n/**\n * `<button ${attrs({ \"data-provider\": \"google\", \"aria-busy\": loading })}>`\n *\n * Lit has no attribute spread; part functions need one. It plays the role of\n * `{...props}` in a shadcn component: a composing component can put extra\n * attributes on the *same* element a part renders, so it never has to wrap\n * that element. `true` → empty attribute; `false`/`null`/`undefined` → removed;\n * keys dropped since the previous render are removed.\n */\nclass AttrsDirective extends Directive {\n private prev = new Set<string>();\n\n constructor(info: PartInfo) {\n super(info);\n if (info.type !== PartType.ELEMENT) throw new Error(\"attrs() must be used in element position\");\n }\n\n render(_attrs: AttrMap) {\n return noChange;\n }\n\n override update(part: ElementPart, [map]: [AttrMap]) {\n applyAttrs(part.element, map, this.prev);\n this.prev = new Set(Object.keys(map));\n return noChange;\n }\n}\n\nexport const attrs = directive(AttrsDirective);\n\n/** Imperative twin of `attrs()`, for code that holds a node rather than a template. */\nexport function applyAttrs(el: Element, map: AttrMap, previous?: Iterable<string>): void {\n if (previous) for (const k of previous) if (!(k in map)) el.removeAttribute(k);\n for (const [k, v] of Object.entries(map)) {\n if (v === false || v == null) {\n if (el.hasAttribute(k)) el.removeAttribute(k);\n } else {\n const s = v === true ? \"\" : String(v);\n if (el.getAttribute(k) !== s) el.setAttribute(k, s);\n }\n }\n}\n","/**\n * The pont2 namespace, in one place.\n *\n * | Thing | Form | Example |\n * |------------------|-------------------------------|--------------------------------------|\n * | primitive tag | `pont2-prim-<name>` | `pont2-prim-alert`, `pont2-prim-alert-title` |\n * | kit tag | `pont2-<name>` | `pont2-alert` (composite), `pont2-button` (alias) |\n * | identity attr | `data-pont2-<identity>` | `data-pont2-alert` (tier-neutral: \"this is an alert\") |\n * | slot attr | `data-slot=\"<name>\"` | `data-slot=\"item-separator\"` (shadcn's own, unprefixed) |\n * | state attrs | `data-<state>` | `data-checked`, `data-open` (Base UI's own, unprefixed) |\n * | CSS custom prop | `--pont2-sem-<role>` … | `--pont2-sem-color-primary` (docs/11-tokens.md) |\n * | cascade layer | `pont2.<layer>` | `pont2.primitives`, `pont2.kit` |\n * | custom event | `pont2-<name>` | `pont2-open-change` |\n *\n * Two element surfaces share one namespace (docs/10-primitives-and-kit.md):\n *\n * - **primitives** `pont2-prim-*`: shadcn's components, one for one.\n * - **kit** `pont2-*`: what applications use. A kit element is either an\n * *alias* of a primitive (same behaviour, second tag) or a *composite* (a\n * subclass of a primitive that renders the primitive's children from\n * properties). Invariant: **`pont2-<name>` is always a `<name>` at its\n * root**, which is what lets `sel()` / `tags()` match both surfaces at once.\n *\n * The identity attribute is tier-neutral on purpose: it says *what* an element\n * is (an alert), not *which tag* produced it. Recipes and lookups key on it, so\n * a primitive, its alias, a composite built on it and hand-written recipe\n * markup are all styled and found the same way.\n *\n * `data-slot` and the state attributes stay unprefixed on purpose: they are\n * shadcn's and Base UI's public styling contract, and keeping them verbatim\n * is what lets shadcn styles port across mechanically.\n */\nexport const PREFIX = \"pont2\";\n/** Tag segment that marks the primitive surface. */\nexport const PRIM = \"prim\";\n\n/** Kit tag: `tag(\"alert\")` → `pont2-alert`. */\nexport const tag = (name: string) => `${PREFIX}-${name}` as const;\n/** Primitive tag: `primTag(\"alert\")` → `pont2-prim-alert`. */\nexport const primTag = (name: string) => `${PREFIX}-${PRIM}-${name}` as const;\nexport const identityAttr = (identity: string) => `data-${PREFIX}-${identity}` as const;\n\n/**\n * Selector for every element that *is* a `<name>`: its primitive tag, its kit\n * tag (an alias or a composite, which by the kit invariant has that root) and\n * its identity attribute (upgraded elements, parts rendered by composites,\n * hand-written recipe markup).\n *\n * `sel(\"alert\")` → `:is(pont2-prim-alert, pont2-alert, [data-pont2-alert])`\n *\n * Use it for every structural lookup (`closest`, `querySelector`), so a\n * component works whichever surface its parts were written with.\n * Tier 3 shells are the exception: their identity attribute lives on the\n * native child, so look shells up with `tags()`.\n */\nexport const sel = (name: string) => `:is(${primTag(name)}, ${tag(name)}, [${identityAttr(name)}])`;\n\n/** The element tags only, on both surfaces: `:is(pont2-prim-x, pont2-x)`. Use for shells. */\nexport const tags = (name: string) => `:is(${primTag(name)}, ${tag(name)})`;\n\n/**\n * Registers an element once. Re-registration (HMR, a second bundle copy) is a\n * no-op rather than a thrown DOMException, but a *different* class under the\n * same tag is reported, because that means two copies of pont2 are loaded.\n */\nexport function define(name: string, ctor: CustomElementConstructor): void {\n const existing = customElements.get(name);\n if (!existing) {\n customElements.define(name, ctor);\n } else if (existing !== ctor && import.meta.env?.DEV) {\n console.warn(`[pont2] <${name}> is already defined by another class (two pont2 copies loaded?).`);\n }\n}\n\nconst aliases = new Map<CustomElementConstructor, CustomElementConstructor>();\n\n/**\n * Promotes a primitive to the kit surface unchanged: `pont2-<name>` becomes a\n * second tag for `pont2-prim-<name>`.\n *\n * The platform forbids registering one constructor under two names, so the\n * alias is an empty subclass. It inherits everything (identity, slot, role,\n * properties, form association), so it is styled, announced and submitted\n * exactly like the primitive, and `instanceof` the primitive class holds.\n *\n * ```ts\n * defineAlias(\"pont2-button\", Pont2Button); // <pont2-prim-button> → also <pont2-button>\n * ```\n *\n * Returns the alias constructor.\n */\nexport function defineAlias<T extends CustomElementConstructor>(kitTag: `pont2-${string}`, base: T): T {\n if (import.meta.env?.DEV) {\n const expected = kitTag.replace(`${PREFIX}-`, `${PREFIX}-${PRIM}-`);\n const registered = customElements.getName?.(base);\n if (registered && registered !== expected) {\n console.warn(`[pont2] defineAlias(\"${kitTag}\") expects the class registered as <${expected}>, got <${registered}>.`);\n }\n }\n let alias = aliases.get(base) as T | undefined;\n if (!alias) {\n // Static members (properties, identity, formAssociated, nativeSelector…)\n // are inherited through the constructor's prototype chain.\n alias = class extends (base as unknown as new () => HTMLElement) {} as unknown as T;\n Object.defineProperty(alias, \"name\", { value: `${base.name}Alias` });\n aliases.set(base, alias);\n }\n define(kitTag, alias);\n return customElements.get(kitTag) as T;\n}\n","import { LitElement, ReactiveElement, type PropertyValues } from \"lit\";\nimport type { DirectiveResult } from \"lit/directive.js\";\n\nimport { attrs, type AttrMap } from \"./attrs\";\nimport { identityAttr, PREFIX } from \"./names\";\n\n/**\n * # HostElement: the host is the component's root element\n *\n * The base class of every pont2 element. A shadcn component is a function\n * that returns its root element and then disappears. A custom element cannot\n * disappear, so in pont2 **the host *is* the root**: `<pont2-prim-separator>` is the\n * separator, it does not render one.\n *\n * What a subclass gets:\n *\n * | Static / member | Does |\n * |---------------------|----------------------------------------------------------------------|\n * | `static identity` | Stamps `data-pont2-<identity>`. Every class in the chain adds its own, so a subclass keeps its base's styles (`pont2-prim-item-separator` carries `data-pont2-separator` *and* `data-pont2-item-separator`). |\n * | `static slotName` | Stamps `data-slot` (shadcn's convention). Most-derived class wins. An author-written `data-slot` is never overwritten. |\n * | `static role` | Default ARIA role through `ElementInternals`. An author's `role=\"\"` attribute still wins. |\n * | `internals` | `ElementInternals`: default ARIA, custom states, forms (see FormControlElement). |\n * | `setData()` | Writes component-owned `data-*` state on the host (Base UI's presence-style attributes). |\n * | `setState()` | Adds/removes a CustomStateSet entry, matchable as `:state(x)`. |\n * | `static part()` | The same identity, slot and role as attributes, for a composite to put on a plain element (see below). |\n * | `static composite` | Marks a kit composite: it renders its whole subtree from properties (docs/10-primitives-and-kit.md). |\n *\n * Light DOM throughout: `createRenderRoot()` returns `this`. Most Tier 1\n * elements never override `render()`; their children are whatever the author\n * wrote, left exactly where the author wrote them.\n */\nexport abstract class HostElement extends LitElement {\n /** Style identity → `data-pont2-<identity>`. Inherited along the class chain. */\n static identity?: string;\n /** shadcn `data-slot` value. Most-derived wins; never overrides the author. */\n static slotName?: string;\n /** Default ARIA role, set through ElementInternals (author attribute wins). */\n static role?: string;\n\n /**\n * `true` on kit composites (`src/kit/`): the element renders its entire\n * subtree from properties, so author-written children are a mistake (use the\n * `pont2-prim-*` form for custom content). Reported once in development.\n */\n static composite = false;\n\n /**\n * A **part**: this element's identity, `data-slot` and default role as plain\n * attributes, for a template to put on a native element.\n *\n * ```ts\n * html`<div ${AlertTitle.part()}>${this.heading}</div>`\n * // → <div data-pont2-alert-title data-slot=\"alert-title\">…</div>\n * ```\n *\n * The result is styled by the element's recipe and found by `sel()` lookups,\n * exactly like the element itself, so a composite reproduces shadcn's DOM\n * without nesting custom elements. A part carries **attributes only**: use\n * it for Tier 1 elements whose host adds nothing but identity, slot and role.\n * An element with behaviour (state, observers, keyboard, form association)\n * has to be rendered as the element. `extra` adds or overrides attributes.\n */\n static part(extra: AttrMap = {}): DirectiveResult {\n const map: AttrMap = {};\n for (const id of identitiesOf(this)) map[identityAttr(id)] = true;\n if (this.slotName) map[\"data-slot\"] = this.slotName;\n if (this.role) map.role = this.role;\n return attrs({ ...map, ...extra });\n }\n\n protected readonly internals: ElementInternals = this.attachInternals();\n\n protected override createRenderRoot(): HTMLElement {\n return this;\n }\n\n /**\n * Elements that do not override `render()` (most Tier 1 hosts) skip Lit's\n * template rendering entirely. Otherwise lit-html would append a `<!---->`\n * part marker to the author's children: a stray node in a component whose\n * whole point is to add none, and one more node for React to step around.\n */\n protected override update(changed: PropertyValues): void {\n if (this.render === HostElement.prototype.render) {\n ReactiveElement.prototype[\"update\"].call(this, changed);\n return;\n }\n super.update(changed);\n }\n\n override connectedCallback(): void {\n const ctor = this.constructor as typeof HostElement;\n if (ctor.composite && !this.hasUpdated && import.meta.env?.DEV) warnAuthorChildren(this);\n super.connectedCallback();\n\n // Attributes may not be added in a custom element constructor (it would\n // make document.createElement() throw), so identity is stamped on connect.\n for (const id of identitiesOf(ctor)) {\n if (!this.hasAttribute(`data-${PREFIX}-${id}`)) {\n this.setAttribute(`data-${PREFIX}-${id}`, \"\");\n }\n }\n if (ctor.slotName && !this.hasAttribute(\"data-slot\")) {\n this.setAttribute(\"data-slot\", ctor.slotName);\n }\n if (ctor.role && !this.internals.role) this.internals.role = ctor.role;\n }\n\n /**\n * Sets `data-<name>`: a string value, `true` → empty (presence) attribute,\n * `false`/`null`/`undefined` → removed. Base UI exposes state as presence\n * attributes (`data-checked`, `data-disabled`, `data-open`), which is what\n * shadcn's Base UI styles select on, so `true`/`false` is the common call.\n */\n protected setData(name: string, value: string | boolean | null | undefined): void {\n const attr = `data-${name}`;\n if (value === false || value == null) {\n if (this.hasAttribute(attr)) this.removeAttribute(attr);\n } else {\n const v = value === true ? \"\" : value;\n if (this.getAttribute(attr) !== v) this.setAttribute(attr, v);\n }\n }\n\n /** Adds or removes a custom state, matchable in CSS as `:state(<name>)`. */\n protected setState(name: string, on: boolean): void {\n try {\n if (on) this.internals.states.add(name);\n else this.internals.states.delete(name);\n } catch {\n // Very old engines only accepted `--name`; state is a nicety, never load-bearing.\n }\n }\n}\n\nfunction warnAuthorChildren(el: HTMLElement): void {\n const authored = Array.from(el.childNodes).some(\n n => n.nodeType === Node.ELEMENT_NODE || (n.nodeType === Node.TEXT_NODE && n.textContent!.trim() !== \"\"),\n );\n if (authored) {\n console.warn(\n `[pont2] <${el.localName}> is a composite: it renders its content from properties and ignores children. ` +\n `For custom content, write the primitive form instead (the pont2-prim-* elements it is built from).`,\n el,\n );\n }\n}\n\n/** Every `identity` declared along the prototype chain, most-derived first. */\nexport function identitiesOf(ctor: typeof HostElement): string[] {\n const out: string[] = [];\n let c: unknown = ctor;\n while (typeof c === \"function\" && c !== HostElement && c !== LitElement) {\n const k = c as typeof HostElement;\n if (Object.hasOwn(k, \"identity\") && k.identity) out.push(k.identity);\n c = Object.getPrototypeOf(c);\n }\n return out;\n}\n\n/**\n * # ShellElement: Tier 3 (native-bound) host\n *\n * Some shadcn roots must stay *native* elements: `<button>`, `<a>`, `<input>`,\n * `<textarea>`, `<label>`, `<select>`, `<table>`, `<fieldset>`. Their behaviour\n * (implicit form submission, `SubmitEvent.submitter`, autofill, password\n * managers, real links, `for=` labelling, table parsing) cannot be emulated\n * faithfully by a custom element.\n *\n * For those, the host is a **transparent shell**: `display: contents`\n * (`[data-pont2-shell]` in styles/base.css), no role, no styles, no box. It\n * exists only so HTML authors have a tag. Everything styled or announced lives\n * on the one native element inside it. Two nodes is the platform floor for\n * native semantics, and composition never adds a third.\n *\n * Never style a shell, give it a role, or anchor positioning to it. Use\n * `control` (the native element) instead.\n */\nexport abstract class ShellElement extends HostElement {\n static override identity = \"shell\";\n\n /** The single native element this shell stands for. */\n abstract get control(): HTMLElement | null;\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n override blur(): void {\n this.control?.blur();\n }\n}\n\n/**\n * # NativeEnhancer: Tier 3 element form (\"asChild\")\n *\n * `<pont2-prim-button variant=\"outline\"><button>Save</button></pont2-prim-button>`\n *\n * The author writes the native element; the shell applies the recipe to it\n * (attributes only). The native node is never moved, wrapped or re-created,\n * so React, a parent Lit template or server HTML keep owning it. A\n * MutationObserver re-applies the recipe if the child is swapped.\n *\n * This is shadcn's `asChild` / Base UI's `render` prop, expressed in HTML.\n */\nexport abstract class NativeEnhancer<T extends HTMLElement = HTMLElement> extends ShellElement {\n /** Selector for the native child this enhancer applies its recipe to. */\n static nativeSelector = \"*\";\n\n private _observer?: MutationObserver;\n private _warned = false;\n\n override get control(): T | null {\n const sel = (this.constructor as typeof NativeEnhancer).nativeSelector;\n for (const child of Array.from(this.children)) {\n if (child.matches(sel)) return child as T;\n }\n return null;\n }\n\n /** Apply the recipe (attributes / properties) to the native element. */\n protected abstract apply(control: T): void;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._observer ??= new MutationObserver(() => this.requestUpdate());\n this._observer.observe(this, { childList: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._observer?.disconnect();\n }\n\n protected override updated(): void {\n const el = this.control;\n if (el) {\n this.apply(el);\n return;\n }\n if (!this._warned && this.isConnected && this.childNodes.length) {\n this._warned = true;\n const sel = (this.constructor as typeof NativeEnhancer).nativeSelector;\n console.warn(\n `<${this.localName}> enhances a native child element (${sel}) and found none. ` +\n `Write <${this.localName}><${sel.split(\",\")[0].trim()}>…</…></${this.localName}>, ` +\n `or use the recipe attributes on the native element directly.`,\n this,\n );\n }\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement } from \"./host-element\";\n\nexport interface ValidityResult {\n flags: ValidityStateFlags;\n message: string;\n}\n\n/**\n * # FormControlElement: Tier 2 form-associated widget\n *\n * The base for widgets whose host is an ARIA widget root *and* a form control\n * (Checkbox, Switch, RadioGroup, Slider, Select, Combobox, InputOTP …). It is\n * a **form-associated custom element** (FACE), so with no hidden `<input>`:\n *\n * - it submits `name=value` with its `<form>` (`internals.setFormValue`);\n * - it takes part in constraint validation (`setValidity`, `:invalid`,\n * `checkValidity()`, `reportValidity()`, blocking submit when `required`);\n * - it is disabled by `disabled`, by an ancestor `<fieldset disabled>` and by\n * its form, through `formDisabledCallback`;\n * - it resets with its form (`formResetCallback`) and restores on\n * back/forward navigation (`formStateRestoreCallback`);\n * - it is labelable: `<label for>` and wrapping labels work, and `labels`\n * lists them;\n * - the `form=\"id\"` content attribute works natively.\n *\n * Base UI renders a visually hidden `<input>` next to each such widget to get\n * the same effect in React. A FACE makes that node unnecessary, which is\n * one node fewer than shadcn/Base UI.\n *\n * Subclasses implement `formValue()`, `resetToDefault()` and optionally\n * `validate()`; the base syncs internals/data attributes after every update.\n */\nexport abstract class FormControlElement extends HostElement {\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n name: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n readOnly: { type: Boolean, reflect: true, attribute: \"readonly\" },\n formDisabled: { state: true },\n };\n\n declare name: string;\n declare disabled: boolean;\n declare required: boolean;\n declare readOnly: boolean;\n /** Disabled by an ancestor `<fieldset disabled>` or the form. */\n declare protected formDisabled: boolean;\n\n private _customMessage = \"\";\n\n constructor() {\n super();\n this.name = \"\";\n this.disabled = false;\n this.required = false;\n this.readOnly = false;\n this.formDisabled = false;\n }\n\n /* -------------------------------------------------------------- */\n /* Subclass contract */\n /* -------------------------------------------------------------- */\n\n /** What the control submits. `null` submits nothing (an unchecked checkbox). */\n protected abstract formValue(): string | File | FormData | null;\n\n /** Restore the default value (the one in the markup). */\n protected abstract resetToDefault(): void;\n\n /** Built-in constraint check. Return `null` when valid. */\n protected validate(): ValidityResult | null {\n return null;\n }\n\n /** Whether the host itself is a tab stop. Composite widgets with an inner roving tab stop return false. */\n protected get hostFocusable(): boolean {\n return true;\n }\n\n /** Element `reportValidity()` should point at (must be inside the host). */\n protected get validationAnchor(): HTMLElement | undefined {\n return undefined;\n }\n\n /* -------------------------------------------------------------- */\n /* Public form API (mirrors native controls) */\n /* -------------------------------------------------------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n /** `disabled` or disabled by a fieldset/form. */\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n setCustomValidity(message: string): void {\n this._customMessage = message;\n this.syncValidity();\n }\n\n /* -------------------------------------------------------------- */\n /* FACE lifecycle */\n /* -------------------------------------------------------------- */\n\n formResetCallback(): void {\n this.resetToDefault();\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n formStateRestoreCallback(state: string | File | FormData | null): void {\n this.restoreState(state);\n }\n\n /** Override to restore from the value `formValue()` produced. */\n protected restoreState(_state: string | File | FormData | null): void {}\n\n /* -------------------------------------------------------------- */\n /* Sync */\n /* -------------------------------------------------------------- */\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n\n this.internals.ariaDisabled = disabled ? \"true\" : null;\n this.internals.ariaRequired = this.required ? \"true\" : null;\n this.internals.ariaReadOnly = this.readOnly ? \"true\" : null;\n this.setData(\"disabled\", disabled);\n this.setData(\"required\", this.required);\n this.setData(\"readonly\", this.readOnly);\n\n if (this.hostFocusable) {\n if (disabled) this.removeAttribute(\"tabindex\");\n else if (!this.hasAttribute(\"tabindex\")) this.tabIndex = 0;\n }\n\n this.internals.setFormValue(this.formValue());\n this.syncValidity();\n }\n\n protected syncValidity(): void {\n const own = this.validate();\n if (this._customMessage) {\n this.internals.setValidity({ customError: true }, this._customMessage, this.validationAnchor);\n } else if (own) {\n this.internals.setValidity(own.flags, own.message, this.validationAnchor);\n } else {\n this.internals.setValidity({});\n }\n }\n}\n","let counter = 0;\n\n/** A document-unique id, e.g. `pont2-field-3`. Like React's `useId()`. */\nexport function uid(scope = \"id\"): string {\n counter += 1;\n return `pont2-${scope}-${counter}`;\n}\n\n/** Returns `el.id`, assigning a fresh `uid(scope)` first if it has none. */\nexport function ensureId(el: Element, scope = \"id\"): string {\n if (!el.id) el.id = uid(scope);\n return el.id;\n}\n\n/** Adds/removes an id in a space-separated IDREF list attribute (aria-describedby etc.). */\nexport function toggleIdRef(el: Element, attr: string, id: string, on: boolean): void {\n const ids = new Set((el.getAttribute(attr) ?? \"\").split(/\\s+/).filter(Boolean));\n if (on) ids.add(id);\n else ids.delete(id);\n if (ids.size) el.setAttribute(attr, [...ids].join(\" \"));\n else el.removeAttribute(attr);\n}\n","/**\n * Event conventions (docs/02-conventions.md, \"Events\"):\n *\n * - Value-holding widgets fire the platform's own `input` (while the value\n * changes through interaction) and `change` (when it is committed), both\n * bubbling, exactly like native controls. The new value is read from the\n * target (`e.target.checked`, `e.target.value`), so `@change=${…}` in Lit,\n * `onChange` via @lit/react and `addEventListener(\"change\")` all work.\n * - Anything without a native equivalent is a `pont2-<name>` CustomEvent with\n * a typed `detail`, bubbling and composed. Base UI's `onOpenChange(open,\n * details)` becomes `pont2-open-change` with `{ open, reason }`; it is\n * cancelable, and `preventDefault()` keeps the current state (Base UI's\n * `eventDetails.cancel()`).\n * - Events fire only for user-initiated changes, never for property writes,\n * matching native controls (and Base UI's controlled props).\n */\nexport function fireNative(target: EventTarget, type: \"input\" | \"change\"): void {\n target.dispatchEvent(new Event(type, { bubbles: true, composed: type === \"input\" }));\n}\n\nexport function fire<T>(target: EventTarget, type: `pont2-${string}`, detail: T, cancelable = false): boolean {\n return target.dispatchEvent(new CustomEvent<T>(type, { detail, bubbles: true, composed: true, cancelable }));\n}\n\nexport type OpenChangeReason =\n | \"trigger-press\"\n | \"trigger-hover\"\n | \"trigger-focus\"\n | \"outside-press\"\n | \"escape-key\"\n | \"item-press\"\n | \"list-navigation\"\n | \"input-change\"\n | \"focus-out\"\n | \"imperative\";\n\nexport interface OpenChangeDetail {\n open: boolean;\n reason: OpenChangeReason;\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-open-change\": CustomEvent<OpenChangeDetail>;\n }\n}\n","import { html, svg, type SVGTemplateResult, type TemplateResult } from \"lit\";\n\nimport { attrs, type AttrMap } from \"./attrs\";\n\n/**\n * The handful of icons primitives draw themselves (check marks, chevrons,\n * the spinner). shadcn renders these with lucide-react through an\n * `IconPlaceholder`; pont2 inlines the same lucide geometry so it has no icon\n * dependency. Lucide is ISC-licensed (https://lucide.dev/license).\n *\n * Every icon is `aria-hidden` and sized by the component's CSS, as in shadcn\n * (`[&_svg:not([class*='size-'])]:size-4`). Consumers can pass their own SVG\n * anywhere an icon is accepted.\n *\n * Each icon takes optional extra attributes for the `<svg>` itself, e.g.\n * shadcn's button icon marker: `icons.arrowRight({ \"data-icon\": \"inline-end\" })`.\n */\nconst icon = (name: string, body: SVGTemplateResult, extra: AttrMap = {}) => html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n data-icon-name=${name}\n ${attrs(extra)}\n>${body}</svg>`;\n\n// Bodies use Lit's `svg` tag: a nested template is parsed on its own, so an\n// `html` fragment would create <path> in the HTML namespace and draw nothing.\nexport const icons = {\n check: (a?: AttrMap) => icon(\"check\", svg`<path d=\"M20 6 9 17l-5-5\" />`, a),\n minus: (a?: AttrMap) => icon(\"minus\", svg`<path d=\"M5 12h14\" />`, a),\n x: (a?: AttrMap) => icon(\"x\", svg`<path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" />`, a),\n chevronDown: (a?: AttrMap) => icon(\"chevron-down\", svg`<path d=\"m6 9 6 6 6-6\" />`, a),\n chevronUp: (a?: AttrMap) => icon(\"chevron-up\", svg`<path d=\"m18 15-6-6-6 6\" />`, a),\n chevronRight: (a?: AttrMap) => icon(\"chevron-right\", svg`<path d=\"m9 18 6-6-6-6\" />`, a),\n chevronLeft: (a?: AttrMap) => icon(\"chevron-left\", svg`<path d=\"m15 18-6-6 6-6\" />`, a),\n chevronsUpDown: (a?: AttrMap) =>\n icon(\"chevrons-up-down\", svg`<path d=\"m7 15 5 5 5-5\" /><path d=\"m7 9 5-5 5 5\" />`, a),\n search: (a?: AttrMap) => icon(\"search\", svg`<path d=\"m21 21-4.34-4.34\" /><circle cx=\"11\" cy=\"11\" r=\"8\" />`, a),\n circle: (a?: AttrMap) => icon(\"circle\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" />`, a),\n loaderCircle: (a?: AttrMap) => icon(\"loader-circle\", svg`<path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />`, a),\n circleAlert: (a?: AttrMap) =>\n icon(\n \"circle-alert\",\n svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\" /><line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\" />`,\n a,\n ),\n circleX: (a?: AttrMap) =>\n icon(\"circle-x\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"m15 9-6 6\" /><path d=\"m9 9 6 6\" />`, a),\n circleCheck: (a?: AttrMap) =>\n icon(\"circle-check\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"m9 12 2 2 4-4\" />`, a),\n triangleAlert: (a?: AttrMap) =>\n icon(\n \"triangle-alert\",\n svg`<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" /><path d=\"M12 9v4\" /><path d=\"M12 17h.01\" />`,\n a,\n ),\n info: (a?: AttrMap) =>\n icon(\"info\", svg`<circle cx=\"12\" cy=\"12\" r=\"10\" /><path d=\"M12 16v-4\" /><path d=\"M12 8h.01\" />`, a),\n eye: (a?: AttrMap) =>\n icon(\n \"eye\",\n svg`<path d=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" /><circle cx=\"12\" cy=\"12\" r=\"3\" />`,\n a,\n ),\n eyeOff: (a?: AttrMap) =>\n icon(\n \"eye-off\",\n svg`<path d=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" /><path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" /><path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" /><path d=\"m2 2 20 20\" />`,\n a,\n ),\n pencil: (a?: AttrMap) =>\n icon(\n \"pencil\",\n svg`<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\" /><path d=\"m15 5 4 4\" />`,\n a,\n ),\n copy: (a?: AttrMap) =>\n icon(\n \"copy\",\n svg`<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" /><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />`,\n a,\n ),\n download: (a?: AttrMap) =>\n icon(\n \"download\",\n svg`<path d=\"M12 15V3\" /><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" /><path d=\"m7 10 5 5 5-5\" />`,\n a,\n ),\n arrowRight: (a?: AttrMap) => icon(\"arrow-right\", svg`<path d=\"M5 12h14\" /><path d=\"m12 5 7 7-7 7\" />`, a),\n userRoundKey: (a?: AttrMap) =>\n icon(\n \"user-round-key\",\n svg`<path d=\"M19 11v6\" /><path d=\"M19 13h2\" /><path d=\"M2 21a8 8 0 0 1 12.868-6.349\" /><circle cx=\"10\" cy=\"8\" r=\"5\" /><circle cx=\"19\" cy=\"19\" r=\"2\" />`,\n a,\n ),\n} satisfies Record<string, (a?: AttrMap) => TemplateResult>;\n\nexport type IconName = keyof typeof icons;\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\n/**\n * # The kit's own words: a message table (decision D8 of the migration plan)\n *\n * Text no render spec carries, which a kit element writes itself: a connection\n * error, \"Start again\", the password toggle's and the spinner's labels. The\n * sign-in runtime sends it with every flow response, already in the flow's\n * language and the instance's wording (branding-svc `pkg/message`, the codes\n * marked Client; the SDK exposes them as `messages` on start results and flow\n * events). Whatever receives a set calls `setMessages`, and every place that\n * would write English reads `msg(code)` instead.\n *\n * English is the fallback. It is only needed before the page has heard from the\n * server, for example when a flow fails to start because the network is down.\n * Once a set has arrived it is kept, so a later failure that never reaches the\n * server is still worded in the page's language.\n *\n * The table is **page-wide**, as in the legacy kit (`src/i18n/messages.ts`,\n * ported, carry-over §2): every widget on a page speaks the same language, and\n * a set one widget receives (or a stopped instance's refusal, §6) applies to all.\n * Elements that render `msg()` add a `MessagesController`, so text that arrives\n * after they first rendered reaches them.\n *\n * The account widgets' codes (carry-over §3) join this table when they are\n * built (migration tracker I-2, W-7…W-10).\n */\n\nexport const KIT_MESSAGES_EN = {\n connection_failed: \"We couldn't reach the server. Check your connection and try again.\",\n too_many_attempts: \"Too many attempts. Try again later.\",\n server_error: \"Something went wrong on our side. Please try again.\",\n instance_unavailable: \"This app isn't available right now.\",\n generic_error: \"Something went wrong. Please try again.\",\n flow_ended: \"This sign-in could not be completed.\",\n passkey_cancelled: \"The passkey request was cancelled or timed out. Please try again.\",\n start_again: \"Start again\",\n continued_elsewhere_title: \"You continued in another tab\",\n continued_elsewhere_subtitle: \"You can close this one.\",\n continue_here: \"Continue here instead\",\n show_password: \"Show password\",\n hide_password: \"Hide password\",\n loading: \"Loading\",\n} as const;\n\nexport type KitMessageCode = keyof typeof KIT_MESSAGES_EN;\n\nlet current: Partial<Record<string, string>> = {};\nlet currentLocaleTag: string | undefined;\nconst listeners = new Set<() => void>();\n\n/**\n * Records a set the server sent. Sets merge (a flow response and, later, the\n * widget-messages read carry different codes for the same language). An empty or\n * missing set changes nothing: a response without one says nothing about the\n * language having changed.\n */\nexport function setMessages(messages?: Record<string, string> | null, locale?: string): void {\n if (!messages || Object.keys(messages).length === 0) return;\n current = { ...current, ...messages };\n if (locale) currentLocaleTag = locale;\n listeners.forEach(listener => listener());\n}\n\n/**\n * The text for a code in the language the page was last served in. A code\n * outside the kit's table needs a `fallback`; without one, the code itself is\n * returned (visible, rather than an empty string).\n */\nexport function msg(code: KitMessageCode): string;\nexport function msg(code: string, fallback: string): string;\nexport function msg(code: string, fallback?: string): string {\n const text = current[code]?.trim();\n return text || fallback || (KIT_MESSAGES_EN as Record<string, string>)[code] || code;\n}\n\n/** The language the page was last served in, for formatting; undefined until the server has said. */\nexport function currentLocale(): string | undefined {\n return currentLocaleTag;\n}\n\n/** Calls `listener` whenever a set arrives. Returns the unsubscribe. */\nexport function onMessagesChanged(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\n/** Forgets every set. For tests and stories. */\nexport function resetMessages(): void {\n current = {};\n currentLocaleTag = undefined;\n listeners.forEach(listener => listener());\n}\n\n/** Re-renders its host whenever a set arrives. Add it to every element that renders `msg()`. */\nexport class MessagesController implements ReactiveController {\n private unsubscribe?: () => void;\n\n constructor(private readonly host: ReactiveControllerHost) {\n host.addController(this);\n }\n\n hostConnected(): void {\n this.unsubscribe = onMessagesChanged(() => this.host.requestUpdate());\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n}\n","/**\n * URLs a kit element may navigate to or link to.\n *\n * Render specs and attributes are data, so an `href` or a redirect target can\n * be anything, including `javascript:` or `data:`. Every element that turns\n * one into navigation (`pont2-link[href]`, `pont2-countdown[redirect-url]`)\n * goes through `safeUrl` and treats `null` as \"don't navigate\".\n */\n\n/** Resolves `raw` against `base` (the page) and accepts only http(s); otherwise `null`. */\nexport function safeUrl(raw: string | null | undefined, base = globalThis.location?.href): string | null {\n if (!raw) return null;\n try {\n const url = new URL(raw, base);\n return url.protocol === \"http:\" || url.protocol === \"https:\" ? url.href : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Stricter than `safeUrl`: an **absolute** http(s) URL with a host, or `null`.\n * For links to pages outside the flow (`pont2-external-link`), whose href is\n * usually a server placeholder filled from the app's settings\n * (`{{consent_privacy_policy_url}}`): empty, still a placeholder, relative or\n * a code-running scheme must not become a link. The legacy\n * `safeExternalHref`, ported.\n */\nexport function safeExternalUrl(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const value = raw.trim();\n if (!value) return null;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") return null;\n return url.hostname ? url.href : null;\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nexport type Orientation = \"horizontal\" | \"vertical\" | \"both\";\n\nexport interface RovingFocusOptions {\n /** Candidate items, in DOM order. Called on every key press, so it may query live. */\n items: () => HTMLElement[];\n orientation?: () => Orientation;\n /** Wrap from last to first (Base UI `loopFocus`, default true). */\n loop?: () => boolean;\n /** Items to skip. Default: `[data-disabled]` / `aria-disabled=\"true\"` / `:disabled`. */\n isDisabled?: (item: HTMLElement) => boolean;\n /** Called after focus moves through the keyboard (radio/tabs use it to activate). */\n onNavigate?: (item: HTMLElement, event: KeyboardEvent) => void;\n}\n\n/** `ltr` unless the nearest `[dir]` ancestor (or the document) says `rtl`. */\nexport function directionOf(el: Element): \"ltr\" | \"rtl\" {\n const owner = el.closest(\"[dir]\");\n const dir = (owner?.getAttribute(\"dir\") ?? document.documentElement.dir ?? \"\").toLowerCase();\n return dir === \"rtl\" ? \"rtl\" : \"ltr\";\n}\n\nconst defaultDisabled = (el: HTMLElement) =>\n el.hasAttribute(\"data-disabled\") ||\n el.getAttribute(\"aria-disabled\") === \"true\" ||\n (el as HTMLButtonElement).disabled === true;\n\n/**\n * Roving tabindex (WAI-ARIA APG \"managing focus within composites\"): exactly\n * one item is a tab stop (`tabindex=\"0\"`), the rest are `-1`, and arrow keys,\n * Home and End move focus between them. Used by RadioGroup, Tabs, ToggleGroup\n * and menus, which is what Base UI's `CompositeRoot` does internally.\n *\n * The host calls `sync(active)` whenever the \"current\" item may have\n * changed (selection, items added or removed).\n */\nexport class RovingFocusController implements ReactiveController {\n private readonly opts: Required<Omit<RovingFocusOptions, \"onNavigate\">> &\n Pick<RovingFocusOptions, \"onNavigate\">;\n\n constructor(\n private readonly host: ReactiveControllerHost & HTMLElement,\n options: RovingFocusOptions,\n ) {\n this.opts = {\n orientation: () => \"both\",\n loop: () => true,\n isDisabled: defaultDisabled,\n ...options,\n };\n host.addController(this);\n }\n\n hostConnected(): void {\n this.host.addEventListener(\"keydown\", this.onKeyDown);\n this.host.addEventListener(\"focusin\", this.onFocusIn);\n }\n\n hostDisconnected(): void {\n this.host.removeEventListener(\"keydown\", this.onKeyDown);\n this.host.removeEventListener(\"focusin\", this.onFocusIn);\n }\n\n /** Make `active` (or the first enabled item) the single tab stop. */\n sync(active?: HTMLElement | null): void {\n const items = this.opts.items();\n const enabled = items.filter(i => !this.opts.isDisabled(i));\n const stop = active && enabled.includes(active) ? active : enabled[0];\n for (const item of items) item.tabIndex = item === stop ? 0 : -1;\n }\n\n /** Focus an item and make it the tab stop. */\n focus(item: HTMLElement, options?: FocusOptions): void {\n this.sync(item);\n item.focus(options);\n }\n\n private onFocusIn = (e: FocusEvent) => {\n const items = this.opts.items();\n const item = items.find(i => i === e.target || i.contains(e.target as Node));\n if (item && !this.opts.isDisabled(item)) this.sync(item);\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n const items = this.opts.items();\n const current = items.findIndex(i => i === e.target || i.contains(e.target as Node));\n if (current < 0) return;\n\n const orientation = this.opts.orientation();\n const rtl = directionOf(this.host) === \"rtl\";\n const horizontal = orientation !== \"vertical\";\n const vertical = orientation !== \"horizontal\";\n\n let step: 1 | -1 | \"first\" | \"last\" | 0 = 0;\n switch (e.key) {\n case \"ArrowRight\":\n if (horizontal) step = rtl ? -1 : 1;\n break;\n case \"ArrowLeft\":\n if (horizontal) step = rtl ? 1 : -1;\n break;\n case \"ArrowDown\":\n if (vertical) step = 1;\n break;\n case \"ArrowUp\":\n if (vertical) step = -1;\n break;\n case \"Home\":\n step = \"first\";\n break;\n case \"End\":\n step = \"last\";\n break;\n }\n if (step === 0) return;\n\n const next = this.findNext(items, current, step);\n if (!next) return;\n e.preventDefault();\n this.focus(next);\n this.opts.onNavigate?.(next, e);\n };\n\n private findNext(items: HTMLElement[], from: number, step: 1 | -1 | \"first\" | \"last\") {\n const ok = (i: HTMLElement) => !this.opts.isDisabled(i);\n if (step === \"first\") return items.find(ok);\n if (step === \"last\") return [...items].reverse().find(ok);\n\n const n = items.length;\n const loop = this.opts.loop();\n for (let k = 1; k <= n; k++) {\n let i = from + step * k;\n if (loop) i = (i + n) % n;\n else if (i < 0 || i >= n) return undefined;\n if (ok(items[i])) return items[i];\n }\n return undefined;\n }\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nimport { fire } from \"../events\";\n\n/**\n * # The action protocol: `pont2-action` + `respondWith()`\n *\n * Some elements start asynchronous work they must not own: a sign-in button\n * starts a login-flow step, but the network call, the session and the next\n * screen belong to whatever hosts the flow (a widget, a layout, the app).\n * The element asks; an ancestor answers.\n *\n * ```\n * element ── pont2-action { action, data, respondWith } ──▶ ancestor (bubbles, composed)\n * ancestor calls detail.respondWith(promise)\n * element: busy until the promise settles\n * element ── pont2-action-success { action, data, result } ──▶\n * or pont2-action-error { action, data, error, message } ──▶\n * ```\n *\n * `respondWith()` must be called **synchronously, inside the listener** (as in\n * a service worker's `FetchEvent`). That is deliberate: the dispatch happens\n * inside the user's click, so work started in the listener still has the\n * click's *transient user activation*, which WebAuthn (passkeys) and\n * `window.open` (OAuth popups) require. Starting the work after an `await`\n * would lose it.\n *\n * ```ts\n * widget.addEventListener(\"pont2-action\", e => {\n * if (e.detail.action) e.detail.respondWith(Auth.processLoginflowEvent({ event: e.detail.action }));\n * });\n * ```\n *\n * Nobody responding is valid: the request event doubles as a click\n * notification (the legacy kit's `<tag>:click`), and an element may then fall\n * back to native behaviour (a submit button lets its form submit).\n *\n * Why an event and not an import: pont2 depends on no auth client, any\n * framework can answer a DOM event, Storybook and tests answer with a fake,\n * and the element never needs to know who is listening (docs/kit/auth-button.md).\n */\n\nexport interface ActionRequestDetail<D = Record<string, unknown>> {\n /** What to do, e.g. a login-flow event id. May be absent (a plain click notification). */\n action: string | undefined;\n /** Context from the element (the provider, the form data…). */\n data: D;\n /** Hand the element the work's promise. Only valid during dispatch, at most once. */\n respondWith(response: unknown): void;\n}\n\nexport interface ActionSuccessDetail<D = Record<string, unknown>> {\n action: string | undefined;\n data: D;\n result: unknown;\n}\n\nexport interface ActionErrorDetail<D = Record<string, unknown>> {\n action: string | undefined;\n data: D;\n error: unknown;\n message: string;\n}\n\nexport class ActionController implements ReactiveController {\n /** True while a response is pending. The host re-renders when it changes. */\n busy = false;\n\n constructor(private host: ReactiveControllerHost & HTMLElement) {\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n /**\n * Fires `pont2-action` from the host. Returns `true` if a listener called\n * `respondWith()` (the element is now busy), `false` otherwise or when\n * already busy (one request at a time).\n */\n request<D extends Record<string, unknown>>(action: string | undefined, data: D): boolean {\n if (this.busy) return false;\n let response: Promise<unknown> | undefined;\n let open = true;\n const detail: ActionRequestDetail<D> = {\n action,\n data,\n respondWith: value => {\n if (!open) throw new DOMException(\"respondWith() must be called synchronously in the listener.\", \"InvalidStateError\");\n if (response) throw new DOMException(\"respondWith() was already called.\", \"InvalidStateError\");\n response = Promise.resolve(value);\n },\n };\n fire(this.host, \"pont2-action\", detail);\n open = false;\n if (!response) return false;\n void this.track(action, data, response);\n return true;\n }\n\n private async track<D>(action: string | undefined, data: D, response: Promise<unknown>): Promise<void> {\n this.setBusy(true);\n try {\n const result = await response;\n fire<ActionSuccessDetail<D>>(this.host, \"pont2-action-success\", { action, data, result });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n fire<ActionErrorDetail<D>>(this.host, \"pont2-action-error\", { action, data, error, message });\n } finally {\n this.setBusy(false);\n }\n }\n\n private setBusy(on: boolean): void {\n this.busy = on;\n this.host.requestUpdate();\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-action\": CustomEvent<ActionRequestDetail>;\n \"pont2-action-success\": CustomEvent<ActionSuccessDetail>;\n \"pont2-action-error\": CustomEvent<ActionErrorDetail>;\n }\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\n\nimport { fire } from \"../events\";\n\nexport interface CopiedDetail {\n /** What was copied, e.g. \"secret\", \"recovery-codes\". Never the copied text. */\n kind: string;\n}\n\nexport interface CopyErrorDetail {\n kind: string;\n error: unknown;\n}\n\n/**\n * Copy-to-clipboard with transient \"copied\" feedback.\n *\n * `copy(text)` writes to the clipboard, sets `copied` for `duration` ms (the\n * host re-renders), and fires `pont2-copied` / `pont2-copy-error`. The events\n * deliberately carry no text: what gets copied here is secret (TOTP secrets,\n * recovery codes), and events are observable by any script on the page.\n */\nexport class CopyController implements ReactiveController {\n copied = false;\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n private host: ReactiveControllerHost & HTMLElement,\n private kind: string,\n private duration = 2000,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n hostDisconnected(): void {\n if (this.timer !== undefined) clearTimeout(this.timer);\n }\n\n async copy(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n } catch (error) {\n fire<CopyErrorDetail>(this.host, \"pont2-copy-error\", { kind: this.kind, error });\n return false;\n }\n this.copied = true;\n this.host.requestUpdate();\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = setTimeout(() => {\n this.copied = false;\n this.timer = undefined;\n this.host.requestUpdate();\n }, this.duration);\n fire<CopiedDetail>(this.host, \"pont2-copied\", { kind: this.kind });\n return true;\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n \"pont2-copied\": CustomEvent<CopiedDetail>;\n \"pont2-copy-error\": CustomEvent<CopyErrorDetail>;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport const BADGE_VARIANTS = [\"default\", \"secondary\", \"destructive\", \"outline\", \"ghost\", \"link\"] as const;\nexport type BadgeVariant = (typeof BADGE_VARIANTS)[number];\n\n/**\n * # Badge: Tier 1 (structural)\n *\n * shadcn: `<Badge variant>` → Base UI `useRender({ defaultTagName: \"span\" })`\n * → `<span data-slot=\"badge\" data-variant>`; with `render={<a/>}` it becomes\n * a link.\n *\n * pont2: `<pont2-prim-badge>` **is** the span. For a link badge, put the recipe on\n * a real anchor: `<a data-pont2-badge data-variant=\"outline\" href=\"…\">`.\n *\n * @tag pont2-prim-badge\n * @attr variant - default | secondary | destructive | outline | ghost | link\n */\nexport class Badge extends HostElement {\n static override identity = \"badge\";\n static override slotName = \"badge\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: BadgeVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\ndefine(\"pont2-prim-badge\", Badge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-badge\": Badge;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer, ShellElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Button: Tier 3 (native-bound)\n *\n * shadcn: `<Button variant size>` → Base UI `<Button>` → a native `<button>`\n * (or, through `render`, the author's `<a>`), with `data-slot=\"button\"`.\n *\n * A button's root must stay native: implicit form submission,\n * `SubmitEvent.submitter`, `name=value` in FormData, password-manager\n * heuristics, middle-click on links. So the styled element is always a native\n * `<button>`/`<a>`, reachable four ways that all share one recipe\n * (button.css, keyed on `[data-pont2-button]`):\n *\n * | Entry point | You write | DOM nodes |\n * |-------------|------------------------------------------------------------------|-----------|\n * | Recipe | `<button data-pont2-button data-variant=\"outline\">` | 1 |\n * | Part | `button({ variant: \"outline\" }, content)` inside a Lit template | 1 |\n * | Enhancer | `<pont2-prim-button variant=\"outline\"><button>…</button></pont2-prim-button>` | shell + 1 |\n * | Base class | `class ProviderButton extends ButtonBase` | shell + 1 |\n */\n\nexport const BUTTON_VARIANTS = [\"default\", \"outline\", \"secondary\", \"ghost\", \"destructive\", \"link\"] as const;\nexport const BUTTON_SIZES = [\"default\", \"xs\", \"sm\", \"lg\", \"icon\", \"icon-xs\", \"icon-sm\", \"icon-lg\"] as const;\nexport type ButtonVariant = (typeof BUTTON_VARIANTS)[number];\nexport type ButtonSize = (typeof BUTTON_SIZES)[number];\n\nexport interface ButtonRecipe {\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n /**\n * Base UI `focusableWhenDisabled`: stay in the tab order while disabled\n * (`aria-disabled` instead of `disabled`). Use it for loading states, so\n * focus is not lost mid-submit.\n */\n focusableWhenDisabled?: boolean;\n}\n\nexport interface ButtonOptions extends ButtonRecipe {\n type?: \"button\" | \"submit\" | \"reset\";\n name?: string;\n value?: string;\n /** Renders an `<a>` instead of a `<button>` (shadcn `render={<a/>}`). */\n href?: string;\n target?: string;\n rel?: string;\n /** Overrides `data-slot` (shadcn `<Button data-slot=\"…\">`). */\n slot?: string;\n /** Extra attributes on the same native element: the `{...props}` spread. */\n attrs?: AttrMap;\n onClick?: (e: MouseEvent) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Recipe (imperative): for code that holds a node */\n/* ------------------------------------------------------------------ */\n\nexport function applyButton(el: HTMLElement, o: ButtonRecipe): void {\n if (!el.hasAttribute(\"data-pont2-button\")) el.setAttribute(\"data-pont2-button\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"button\");\n el.setAttribute(\"data-variant\", o.variant ?? \"default\");\n el.setAttribute(\"data-size\", o.size ?? \"default\");\n\n const disabled = !!o.disabled;\n const native = el instanceof HTMLButtonElement;\n el.toggleAttribute(\"data-disabled\", disabled);\n\n if (native && !o.focusableWhenDisabled) {\n el.disabled = disabled;\n el.removeAttribute(\"aria-disabled\");\n } else {\n if (native) el.disabled = false;\n if (disabled) el.setAttribute(\"aria-disabled\", \"true\");\n else el.removeAttribute(\"aria-disabled\");\n // A disabled link leaves the tab order unless it should stay focusable.\n if (!native) {\n if (disabled && !o.focusableWhenDisabled) el.tabIndex = -1;\n else el.removeAttribute(\"tabindex\");\n }\n }\n}\n\n/** True when a click on `el` must be swallowed (aria-disabled buttons and links). */\nexport function isSoftDisabled(el: Element): boolean {\n return el.getAttribute(\"aria-disabled\") === \"true\" || el.hasAttribute(\"data-disabled\");\n}\n\n/* ------------------------------------------------------------------ */\n/* Part: a template function, the counterpart of a React component */\n/* ------------------------------------------------------------------ */\n\nexport function button(o: ButtonOptions, content: unknown) {\n const variant = o.variant ?? \"default\";\n const size = o.size ?? \"default\";\n const slot = o.slot ?? \"button\";\n const disabled = !!o.disabled;\n const soft = disabled && (o.focusableWhenDisabled || o.href !== undefined);\n\n const onClick = (e: MouseEvent) => {\n if (soft) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n o.onClick?.(e);\n };\n\n if (o.href !== undefined) {\n return html`<a\n data-pont2-button\n data-slot=${slot}\n data-variant=${variant}\n data-size=${size}\n href=${o.href}\n target=${o.target ?? nothing}\n rel=${o.rel ?? nothing}\n ?data-disabled=${disabled}\n aria-disabled=${disabled ? \"true\" : nothing}\n tabindex=${disabled && !o.focusableWhenDisabled ? \"-1\" : nothing}\n ${attrs(o.attrs ?? {})}\n @click=${onClick}\n >${content}</a\n >`;\n }\n\n return html`<button\n data-pont2-button\n data-slot=${slot}\n data-variant=${variant}\n data-size=${size}\n type=${o.type ?? \"button\"}\n name=${o.name ?? nothing}\n .value=${o.value ?? \"\"}\n ?disabled=${disabled && !o.focusableWhenDisabled}\n ?data-disabled=${disabled}\n aria-disabled=${soft ? \"true\" : nothing}\n ${attrs(o.attrs ?? {})}\n @click=${onClick}\n >${content}</button>`;\n}\n\n/* ------------------------------------------------------------------ */\n/* Shared reactive properties */\n/* ------------------------------------------------------------------ */\n\nconst recipeProperties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n size: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n focusableWhenDisabled: { type: Boolean, attribute: \"focusable-when-disabled\" },\n};\n\n/* ------------------------------------------------------------------ */\n/* Element: enhancer (asChild) */\n/* ------------------------------------------------------------------ */\n\n/**\n * `<pont2-prim-button>`: applies the button recipe to the native `<button>` or\n * `<a>` you put inside it.\n *\n * ```html\n * <pont2-prim-button variant=\"outline\"><button type=\"submit\">Continue</button></pont2-prim-button>\n * <pont2-prim-button variant=\"link\"><a href=\"/forgot\">Forgot password?</a></pont2-prim-button>\n * ```\n *\n * @tag pont2-prim-button\n * @attr variant - default | outline | secondary | ghost | destructive | link\n * @attr size - default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lg\n * @attr disabled - Disables the native child (or sets aria-disabled on a link).\n * @attr focusable-when-disabled - Keep the disabled button in the tab order.\n */\nexport class Pont2Button extends NativeEnhancer<HTMLButtonElement | HTMLAnchorElement> {\n static override nativeSelector = \"button, a\";\n static override properties = recipeProperties;\n\n declare variant: ButtonVariant;\n declare size: ButtonSize;\n declare disabled: boolean;\n declare focusableWhenDisabled: boolean;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n this.disabled = false;\n this.focusableWhenDisabled = false;\n // Swallow clicks on soft-disabled controls before author listeners run.\n this.addEventListener(\"click\", this.guard, { capture: true });\n }\n\n private guard = (e: MouseEvent) => {\n const c = this.control;\n if (c && this.disabled && (c === e.target || c.contains(e.target as Node)) && isSoftDisabled(c)) {\n e.preventDefault();\n e.stopImmediatePropagation();\n }\n };\n\n protected apply(control: HTMLButtonElement | HTMLAnchorElement): void {\n applyButton(control, this);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Base class for compositions that ARE buttons */\n/* ------------------------------------------------------------------ */\n\n/**\n * Extend this when your component *is* a button whose content it generates\n * (a provider sign-in button, a submit button with a spinner). Subclasses\n * inherit `variant`/`size`/`disabled`/`type`/`href`… so nothing is forwarded\n * by hand; they implement `renderContent()` and may override\n * `buttonOptions()`. The DOM is always\n * `<host data-pont2-shell> > <button|a data-pont2-button>`.\n */\nexport abstract class ButtonBase extends ShellElement {\n static override properties: PropertyDeclarations = {\n ...recipeProperties,\n type: { type: String },\n name: { type: String },\n value: { type: String },\n href: { type: String },\n target: { type: String },\n rel: { type: String },\n };\n\n declare variant: ButtonVariant;\n declare size: ButtonSize;\n declare disabled: boolean;\n declare focusableWhenDisabled: boolean;\n declare type: \"button\" | \"submit\" | \"reset\";\n declare name?: string;\n declare value?: string;\n declare href?: string;\n declare target?: string;\n declare rel?: string;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n this.disabled = false;\n this.focusableWhenDisabled = false;\n this.type = \"button\";\n }\n\n /** The native element. Focus, tooltips and popovers anchor here, never on the shell. */\n override get control(): HTMLButtonElement | HTMLAnchorElement | null {\n return this.querySelector(\":scope > [data-pont2-button]\");\n }\n\n protected buttonOptions(): ButtonOptions {\n const { variant, size, type, name, value, disabled, focusableWhenDisabled, href, target, rel } = this;\n return { variant, size, type, name, value, disabled, focusableWhenDisabled, href, target, rel };\n }\n\n protected abstract renderContent(): unknown;\n\n override render() {\n return button(this.buttonOptions(), this.renderContent());\n }\n}\n\ndefine(\"pont2-prim-button\", Pont2Button);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-button\": Pont2Button;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Checkbox: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Checkbox>` → Base UI `<Checkbox.Root>` (`<span role=\"checkbox\">`\n * plus a hidden `<input type=\"checkbox\">`) > `<Checkbox.Indicator>` > icon.\n *\n * pont2: the host **is** the `role=\"checkbox\"` root, and it is a\n * form-associated custom element, so there is no hidden input:\n *\n * ```\n * shadcn/Base UI: span[role=checkbox] > span[data-slot=checkbox-indicator] > svg + input[hidden]\n * pont2: pont2-prim-checkbox > span[data-slot=checkbox-indicator] > svg\n * ```\n *\n * State attributes are Base UI's: `data-checked` | `data-unchecked`,\n * `data-indeterminate`, `data-disabled`, `data-readonly`, `data-required`.\n * The CustomStateSet mirrors them (`:state(checked)`).\n *\n * @tag pont2-prim-checkbox\n * @attr checked - Initial checked state (`defaultChecked`); `.checked` is the live state.\n * @attr indeterminate - Mixed state (`aria-checked=\"mixed\"`).\n * @attr name, value, unchecked-value, disabled, required, readonly\n * @fires input - The checked state changed through interaction.\n * @fires change - Same moment as `input`, like a native checkbox.\n */\nexport class Checkbox extends FormControlElement {\n static override identity = \"checkbox\";\n static override slotName = \"checkbox\";\n static override role = \"checkbox\";\n\n static override properties: PropertyDeclarations = {\n ...FormControlElement.properties,\n checked: { type: Boolean },\n indeterminate: { type: Boolean, reflect: true },\n value: { type: String },\n uncheckedValue: { type: String, attribute: \"unchecked-value\" },\n };\n\n declare checked: boolean;\n declare indeterminate: boolean;\n declare value: string;\n declare uncheckedValue: string | undefined;\n\n constructor() {\n super();\n this.checked = false;\n this.indeterminate = false;\n this.value = \"on\";\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"keyup\", this.onKeyUp);\n }\n\n /** Toggle as if the user clicked (fires input/change). */\n toggle(): void {\n if (this.isDisabled || this.readOnly) return;\n this.indeterminate = false;\n this.checked = !this.checked;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected formValue() {\n if (this.checked) return this.value;\n return this.uncheckedValue ?? null;\n }\n\n protected resetToDefault(): void {\n this.checked = this.hasAttribute(\"checked\");\n this.indeterminate = this.hasAttribute(\"indeterminate\");\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n this.checked = state === this.value;\n }\n\n protected override validate(): ValidityResult | null {\n if (this.required && !this.checked) {\n return { flags: { valueMissing: true }, message: \"Please tick this box if you want to proceed.\" };\n }\n return null;\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled || this.readOnly) {\n e.preventDefault();\n return;\n }\n this.toggle();\n };\n\n // Native checkboxes toggle on Space *keyup*; keydown is prevented so the page does not scroll.\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) e.preventDefault();\n };\n private onKeyUp = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) this.click();\n };\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n const on = this.checked && !this.indeterminate;\n this.internals.ariaChecked = this.indeterminate ? \"mixed\" : String(this.checked);\n this.setData(\"checked\", on);\n this.setData(\"unchecked\", !this.checked && !this.indeterminate);\n this.setData(\"indeterminate\", this.indeterminate);\n this.setState(\"checked\", on);\n this.setState(\"indeterminate\", this.indeterminate);\n }\n\n override render() {\n if (!this.checked && !this.indeterminate) return nothing;\n // Base UI <Checkbox.Indicator> (not kept mounted when unchecked).\n return html`<span\n data-pont2-checkbox-indicator\n data-slot=\"checkbox-indicator\"\n ?data-checked=${this.checked && !this.indeterminate}\n ?data-indeterminate=${this.indeterminate}\n >${this.indeterminate ? icons.minus() : icons.check()}</span\n >`;\n }\n}\n\ndefine(\"pont2-prim-checkbox\", Checkbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-checkbox\": Checkbox;\n }\n}\n","import { html, nothing } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Input: Tier 3 (native-bound)\n *\n * shadcn: `<Input>` → Base UI `<Input>` → a native `<input data-slot=\"input\">`.\n *\n * A sign-in kit's inputs must be native and in light DOM: autofill, password\n * managers, `autocomplete=\"one-time-code\"`, form submission, `<label for>`\n * and `aria-describedby` all depend on it.\n *\n * - recipe: `<input data-pont2-input type=\"email\" name=\"email\">`\n * - part: `input({ type: \"email\", name: \"email\" })`\n * - enhancer: `<pont2-prim-input><input type=\"email\" name=\"email\"></pont2-prim-input>`\n */\nexport interface InputOptions {\n id?: string;\n name?: string;\n type?: string;\n value?: string;\n placeholder?: string;\n autocomplete?: string;\n inputmode?: string;\n required?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n invalid?: boolean;\n describedBy?: string;\n slot?: string;\n attrs?: AttrMap;\n onInput?: (e: InputEvent) => void;\n onChange?: (e: Event) => void;\n}\n\nexport function applyInput(el: HTMLInputElement, slot = \"input\"): void {\n if (!el.hasAttribute(\"data-pont2-input\")) el.setAttribute(\"data-pont2-input\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function input(o: InputOptions = {}) {\n return html`<input\n data-pont2-input\n data-slot=${o.slot ?? \"input\"}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n type=${o.type ?? \"text\"}\n .value=${live(o.value ?? \"\")}\n placeholder=${o.placeholder ?? nothing}\n autocomplete=${(o.autocomplete as never) ?? nothing}\n inputmode=${(o.inputmode as never) ?? nothing}\n ?required=${o.required}\n ?disabled=${o.disabled}\n ?readonly=${o.readonly}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-describedby=${o.describedBy ?? nothing}\n ${attrs(o.attrs ?? {})}\n @input=${o.onInput ?? nothing}\n @change=${o.onChange ?? nothing}\n />`;\n}\n\n/**\n * @tag pont2-prim-input\n */\nexport class Pont2Input extends NativeEnhancer<HTMLInputElement> {\n static override nativeSelector = \"input\";\n protected apply(control: HTMLInputElement): void {\n applyInput(control);\n }\n}\n\ndefine(\"pont2-prim-input\", Pont2Input);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input\": Pont2Input;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Kbd, KbdGroup: Tier 1 (structural)\n *\n * shadcn: `<Kbd>` → `<kbd data-slot=\"kbd\">`; `<KbdGroup>` → `<kbd data-slot=\"kbd-group\">`.\n *\n * pont2: the host is the key cap. `<kbd>` has no implicit ARIA role, so a\n * custom element loses no semantics here. (If you need the literal element,\n * use the recipe: `<kbd data-pont2-kbd>⌘</kbd>`.)\n *\n * @tag pont2-prim-kbd\n */\nexport class Kbd extends HostElement {\n static override identity = \"kbd\";\n static override slotName = \"kbd\";\n}\n\n/**\n * @tag pont2-prim-kbd-group\n */\nexport class KbdGroup extends HostElement {\n static override identity = \"kbd-group\";\n static override slotName = \"kbd-group\";\n}\n\ndefine(\"pont2-prim-kbd\", Kbd);\ndefine(\"pont2-prim-kbd-group\", KbdGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-kbd\": Kbd;\n \"pont2-prim-kbd-group\": KbdGroup;\n }\n}\n","import { html, nothing } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Label: Tier 3 (native-bound)\n *\n * shadcn: `<Label>` → a native `<label data-slot=\"label\">`.\n *\n * It must be a real `<label>`: `for=` association, click-to-focus, and\n * labelling form-associated custom elements (Checkbox, Switch …) only work\n * on the native element. So:\n *\n * - recipe: `<label data-pont2-label for=\"email\">Email</label>`\n * - part: `label({ for: \"email\" }, \"Email\")`\n * - enhancer: `<pont2-prim-label><label for=\"email\">Email</label></pont2-prim-label>`\n */\nexport interface LabelOptions {\n for?: string;\n id?: string;\n slot?: string;\n /** Extra identities, e.g. FieldLabel passes `[\"field-label\"]`. */\n identities?: string[];\n attrs?: AttrMap;\n}\n\nexport function applyLabel(el: HTMLLabelElement, slot = \"label\"): void {\n if (!el.hasAttribute(\"data-pont2-label\")) el.setAttribute(\"data-pont2-label\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function label(o: LabelOptions, content: unknown) {\n const extra: AttrMap = {};\n for (const id of o.identities ?? []) extra[`data-pont2-${id}`] = true;\n return html`<label\n data-pont2-label\n data-slot=${o.slot ?? \"label\"}\n for=${o.for ?? nothing}\n id=${o.id ?? nothing}\n ${attrs({ ...extra, ...(o.attrs ?? {}) })}\n >${content}</label\n >`;\n}\n\n/**\n * @tag pont2-prim-label\n */\nexport class Pont2Label extends NativeEnhancer<HTMLLabelElement> {\n static override nativeSelector = \"label\";\n protected apply(control: HTMLLabelElement): void {\n applyLabel(control);\n }\n}\n\ndefine(\"pont2-prim-label\", Pont2Label);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-label\": Pont2Label;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type SeparatorOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # Separator: Tier 1 (structural)\n *\n * shadcn: `<Separator orientation>` → Base UI `<Separator>` →\n * `<div role=\"separator\" aria-orientation data-orientation data-slot=\"separator\">`.\n *\n * pont2: the host **is** that div. No `render()`, no children, one node.\n * Role and orientation are ElementInternals defaults, so an author's own\n * `role=\"none\"` (purely decorative rule) still wins.\n *\n * Subclass it to make a separator with another meaning, e.g.\n * `class ItemSeparator extends Separator { static identity = \"item-separator\" }`:\n * it keeps `data-pont2-separator` (the look) and gains its own slot.\n *\n * @tag pont2-prim-separator\n * @attr orientation - horizontal (default) | vertical\n */\nexport class Separator extends HostElement {\n static override identity = \"separator\";\n static override slotName = \"separator\";\n static override role = \"separator\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n };\n\n declare orientation: SeparatorOrientation;\n\n constructor() {\n super();\n this.orientation = \"horizontal\";\n }\n\n protected override willUpdate(): void {\n const o = this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n this.setData(\"orientation\", o);\n this.internals.ariaOrientation = o;\n }\n}\n\ndefine(\"pont2-prim-separator\", Separator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-separator\": Separator;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Skeleton: Tier 1 (structural)\n *\n * shadcn: `<Skeleton>` → `<div data-slot=\"skeleton\" class=\"animate-pulse bg-muted rounded-md\">`.\n * Size it with your own CSS (`style=\"width:12rem;height:1rem\"` or a class).\n *\n * @tag pont2-prim-skeleton\n */\nexport class Skeleton extends HostElement {\n static override identity = \"skeleton\";\n static override slotName = \"skeleton\";\n}\n\ndefine(\"pont2-prim-skeleton\", Skeleton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-skeleton\": Skeleton;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Spinner: Tier 1 (structural)\n *\n * shadcn: `<Spinner>` → lucide `<Loader2Icon role=\"status\" aria-label=\"Loading\"\n * data-slot=\"spinner\" class=\"size-4 animate-spin\">`, i.e. one `<svg>`.\n *\n * A custom element cannot *be* an `<svg>`, and rendering one inside would add\n * a node. pont2 draws the identical lucide `loader-circle` geometry as a CSS\n * mask on the host, so the spinner is still one node and still `currentColor`.\n * Swap the glyph with `--pont2-spinner-icon: url(…)`.\n *\n * `role=\"status\"` and `aria-label=\"Loading\"` are ElementInternals defaults;\n * write your own `aria-label` to localise it.\n *\n * @tag pont2-prim-spinner\n * @cssprop --pont2-spinner-icon - mask image (default: lucide loader-circle)\n */\nexport class Spinner extends HostElement {\n static override identity = \"spinner\";\n static override slotName = \"spinner\";\n static override role = \"status\";\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.internals.ariaLabel) this.internals.ariaLabel = \"Loading\";\n }\n}\n\ndefine(\"pont2-prim-spinner\", Spinner);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-spinner\": Spinner;\n }\n}\n","import { html, nothing } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Textarea: Tier 3 (native-bound)\n *\n * shadcn: `<Textarea>` → a native `<textarea data-slot=\"textarea\">`, auto-sized\n * with `field-sizing: content`.\n *\n * - recipe: `<textarea data-pont2-textarea name=\"bio\"></textarea>`\n * - part: `textarea({ name: \"bio\" })`\n * - enhancer: `<pont2-prim-textarea><textarea name=\"bio\"></textarea></pont2-prim-textarea>`\n */\nexport interface TextareaOptions {\n id?: string;\n name?: string;\n value?: string;\n placeholder?: string;\n rows?: number;\n required?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n invalid?: boolean;\n describedBy?: string;\n slot?: string;\n attrs?: AttrMap;\n onInput?: (e: InputEvent) => void;\n}\n\nexport function applyTextarea(el: HTMLTextAreaElement, slot = \"textarea\"): void {\n if (!el.hasAttribute(\"data-pont2-textarea\")) el.setAttribute(\"data-pont2-textarea\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", slot);\n}\n\nexport function textarea(o: TextareaOptions = {}) {\n return html`<textarea\n data-pont2-textarea\n data-slot=${o.slot ?? \"textarea\"}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n rows=${o.rows ?? nothing}\n placeholder=${o.placeholder ?? nothing}\n ?required=${o.required}\n ?disabled=${o.disabled}\n ?readonly=${o.readonly}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-describedby=${o.describedBy ?? nothing}\n .value=${live(o.value ?? \"\")}\n ${attrs(o.attrs ?? {})}\n @input=${o.onInput ?? nothing}\n ></textarea>`;\n}\n\n/**\n * @tag pont2-prim-textarea\n */\nexport class Pont2Textarea extends NativeEnhancer<HTMLTextAreaElement> {\n static override nativeSelector = \"textarea\";\n protected apply(control: HTMLTextAreaElement): void {\n applyTextarea(control);\n }\n}\n\ndefine(\"pont2-prim-textarea\", Pont2Textarea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-textarea\": Pont2Textarea;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport const ALERT_VARIANTS = [\"default\", \"destructive\"] as const;\nexport type AlertVariant = (typeof ALERT_VARIANTS)[number];\n\n/**\n * # Alert: Tier 1 (structural)\n *\n * shadcn: `<Alert variant>` → `<div role=\"alert\" data-slot=\"alert\">` with\n * `AlertTitle`, `AlertDescription`, `AlertAction` divs inside.\n *\n * pont2: every part is host-as-root. The alert's `role=\"alert\"` is an\n * ElementInternals default, so `role=\"status\"` written by the author (a polite\n * announcement) still wins.\n *\n * @tag pont2-prim-alert\n * @attr variant - default | destructive\n */\nexport class Alert extends HostElement {\n static override identity = \"alert\";\n static override slotName = \"alert\";\n static override role = \"alert\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: AlertVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-alert-title */\nexport class AlertTitle extends HostElement {\n static override identity = \"alert-title\";\n static override slotName = \"alert-title\";\n}\n\n/** @tag pont2-prim-alert-description */\nexport class AlertDescription extends HostElement {\n static override identity = \"alert-description\";\n static override slotName = \"alert-description\";\n}\n\n/** @tag pont2-prim-alert-action */\nexport class AlertAction extends HostElement {\n static override identity = \"alert-action\";\n static override slotName = \"alert-action\";\n}\n\ndefine(\"pont2-prim-alert\", Alert);\ndefine(\"pont2-prim-alert-title\", AlertTitle);\ndefine(\"pont2-prim-alert-description\", AlertDescription);\ndefine(\"pont2-prim-alert-action\", AlertAction);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-alert\": Alert;\n \"pont2-prim-alert-title\": AlertTitle;\n \"pont2-prim-alert-description\": AlertDescription;\n \"pont2-prim-alert-action\": AlertAction;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type AvatarSize = \"default\" | \"sm\" | \"lg\";\n/** Base UI `Avatar.Root` state `imageLoadingStatus`. */\nexport type ImageLoadingStatus = \"idle\" | \"loading\" | \"loaded\" | \"error\";\n\n/**\n * # Avatar: Tier 1 (structural, with image-loading behaviour)\n *\n * shadcn: `<Avatar size>` → Base UI `<Avatar.Root>` (`<span data-slot=\"avatar\"\n * data-size>`) holding `<Avatar.Image>` (an `<img>`, rendered only once it has\n * loaded) and `<Avatar.Fallback>` (a `<span>`, rendered until then).\n *\n * pont2: the host **is** the root span. The image is the author's own native\n * `<img>` (Tier 3: it must stay an `<img>` for `alt`, `srcset`, lazy loading),\n * written as a direct child. The host watches it and exposes Base UI's\n * `imageLoadingStatus` as `data-image-loading-status`; CSS shows the image\n * only when `loaded` and the fallback otherwise. Nothing is added, removed or\n * moved: the image and fallback both stay in the DOM and CSS swaps them.\n *\n * ```html\n * <pont2-prim-avatar>\n * <img src=\"/u/42.png\" alt=\"Ada Lovelace\">\n * <pont2-prim-avatar-fallback>AL</pont2-prim-avatar-fallback>\n * </pont2-prim-avatar>\n * ```\n *\n * @tag pont2-prim-avatar\n * @attr size - default | sm | lg\n * @fires pont2-loading-status-change - `{ status }` when the image status changes (Base UI `onLoadingStatusChange`).\n */\nexport class Avatar extends HostElement {\n static override identity = \"avatar\";\n static override slotName = \"avatar\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n imageLoadingStatus: { state: true },\n };\n\n declare size: AvatarSize;\n /** Base UI's `imageLoadingStatus`; read-only for consumers. */\n declare imageLoadingStatus: ImageLoadingStatus;\n\n private img: HTMLImageElement | null = null;\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.size = \"default\";\n this.imageLoadingStatus = \"idle\";\n }\n\n /** The author's `<img>` (a direct child), if any. */\n get image(): HTMLImageElement | null {\n return this.querySelector(\":scope > img\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.track());\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: [\"src\", \"srcset\"] });\n this.track();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.detach();\n }\n\n private detach() {\n this.img?.removeEventListener(\"load\", this.onLoad);\n this.img?.removeEventListener(\"error\", this.onError);\n this.img = null;\n }\n\n private track() {\n const img = this.image;\n if (img !== this.img) {\n this.detach();\n this.img = img;\n if (img) {\n img.addEventListener(\"load\", this.onLoad);\n img.addEventListener(\"error\", this.onError);\n if (!img.hasAttribute(\"data-pont2-avatar-image\")) img.setAttribute(\"data-pont2-avatar-image\", \"\");\n if (!img.hasAttribute(\"data-slot\")) img.setAttribute(\"data-slot\", \"avatar-image\");\n }\n }\n if (!img || !(img.currentSrc || img.getAttribute(\"src\"))) return this.setStatus(img ? \"error\" : \"idle\");\n if (img.complete) this.setStatus(img.naturalWidth > 0 ? \"loaded\" : \"error\");\n else this.setStatus(\"loading\");\n }\n\n private onLoad = () => this.setStatus(\"loaded\");\n private onError = () => this.setStatus(\"error\");\n\n private setStatus(status: ImageLoadingStatus) {\n if (status === this.imageLoadingStatus) return;\n this.imageLoadingStatus = status;\n this.dispatchEvent(\n new CustomEvent(\"pont2-loading-status-change\", { detail: { status }, bubbles: true, composed: true }),\n );\n }\n\n protected override willUpdate(): void {\n this.setData(\"size\", this.size || \"default\");\n this.setData(\"image-loading-status\", this.imageLoadingStatus);\n }\n}\n\n/**\n * Shown until the avatar's image has loaded (CSS-driven; see Avatar).\n *\n * @tag pont2-prim-avatar-fallback\n */\nexport class AvatarFallback extends HostElement {\n static override identity = \"avatar-fallback\";\n static override slotName = \"avatar-fallback\";\n}\n\n/** @tag pont2-prim-avatar-badge */\nexport class AvatarBadge extends HostElement {\n static override identity = \"avatar-badge\";\n static override slotName = \"avatar-badge\";\n}\n\n/** @tag pont2-prim-avatar-group */\nexport class AvatarGroup extends HostElement {\n static override identity = \"avatar-group\";\n static override slotName = \"avatar-group\";\n}\n\n/** @tag pont2-prim-avatar-group-count */\nexport class AvatarGroupCount extends HostElement {\n static override identity = \"avatar-group-count\";\n static override slotName = \"avatar-group-count\";\n}\n\ndefine(\"pont2-prim-avatar\", Avatar);\ndefine(\"pont2-prim-avatar-fallback\", AvatarFallback);\ndefine(\"pont2-prim-avatar-badge\", AvatarBadge);\ndefine(\"pont2-prim-avatar-group\", AvatarGroup);\ndefine(\"pont2-prim-avatar-group-count\", AvatarGroupCount);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-avatar\": Avatar;\n \"pont2-prim-avatar-fallback\": AvatarFallback;\n \"pont2-prim-avatar-badge\": AvatarBadge;\n \"pont2-prim-avatar-group\": AvatarGroup;\n \"pont2-prim-avatar-group-count\": AvatarGroupCount;\n }\n interface HTMLElementEventMap {\n \"pont2-loading-status-change\": CustomEvent<{ status: ImageLoadingStatus }>;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { Separator } from \"../separator/separator\";\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # ButtonGroup: Tier 1 (structural)\n *\n * shadcn: `<ButtonGroup orientation>` → `<div role=\"group\" data-slot=\"button-group\"\n * data-orientation>`; `ButtonGroupText` (Base UI `useRender`, a div);\n * `ButtonGroupSeparator` (a vertical `Separator`).\n *\n * pont2: host-as-root. Children are whatever you write: recipe buttons,\n * `<pont2-prim-button>` shells, inputs, nested groups. The join rules (square inner\n * corners, collapsed borders) see through Tier 3 shells, because a shell has\n * no box. `ButtonGroupSeparator extends Separator`.\n *\n * @tag pont2-prim-button-group\n * @attr orientation - horizontal (default) | vertical\n */\nexport class ButtonGroup extends HostElement {\n static override identity = \"button-group\";\n static override slotName = \"button-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n };\n\n declare orientation: ButtonGroupOrientation;\n\n constructor() {\n super();\n this.orientation = \"horizontal\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"orientation\", this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\");\n }\n}\n\n/**\n * For a link or label instead of a div, use the recipe on that element:\n * `<label data-pont2-button-group-text data-slot=\"button-group-text\">`.\n *\n * @tag pont2-prim-button-group-text\n */\nexport class ButtonGroupText extends HostElement {\n static override identity = \"button-group-text\";\n static override slotName = \"button-group-text\";\n}\n\n/**\n * A Separator whose default orientation is vertical.\n *\n * @tag pont2-prim-button-group-separator\n */\nexport class ButtonGroupSeparator extends Separator {\n static override identity = \"button-group-separator\";\n static override slotName = \"button-group-separator\";\n\n constructor() {\n super();\n this.orientation = \"vertical\";\n }\n}\n\ndefine(\"pont2-prim-button-group\", ButtonGroup);\ndefine(\"pont2-prim-button-group-text\", ButtonGroupText);\ndefine(\"pont2-prim-button-group-separator\", ButtonGroupSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-button-group\": ButtonGroup;\n \"pont2-prim-button-group-text\": ButtonGroupText;\n \"pont2-prim-button-group-separator\": ButtonGroupSeparator;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type CardSize = \"default\" | \"sm\";\n\n/**\n * # Card: Tier 1 (structural)\n *\n * shadcn: `<Card size>` → `<div data-slot=\"card\" data-size>` and the\n * `CardHeader | CardTitle | CardDescription | CardAction | CardContent |\n * CardFooter` divs. Every part here is host-as-root: same depth as shadcn.\n *\n * @tag pont2-prim-card\n * @attr size - default | sm\n * @cssprop --pont2-card-spacing - padding/gap unit (default 1.5rem)\n * @cssprop --pont2-card-sm-spacing - the same for size=\"sm\" (default 1rem)\n * @cssprop --pont2-card-bg, --pont2-card-fg, --pont2-card-border-color, --pont2-card-radius, --pont2-card-shadow - see docs/11-tokens.md\n */\nexport class Card extends HostElement {\n static override identity = \"card\";\n static override slotName = \"card\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n };\n\n declare size: CardSize;\n\n constructor() {\n super();\n this.size = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"size\", this.size || \"default\");\n }\n}\n\n/** @tag pont2-prim-card-header */\nexport class CardHeader extends HostElement {\n static override identity = \"card-header\";\n static override slotName = \"card-header\";\n}\n\n/** @tag pont2-prim-card-title */\nexport class CardTitle extends HostElement {\n static override identity = \"card-title\";\n static override slotName = \"card-title\";\n}\n\n/** @tag pont2-prim-card-description */\nexport class CardDescription extends HostElement {\n static override identity = \"card-description\";\n static override slotName = \"card-description\";\n}\n\n/** @tag pont2-prim-card-action */\nexport class CardAction extends HostElement {\n static override identity = \"card-action\";\n static override slotName = \"card-action\";\n}\n\n/** @tag pont2-prim-card-content */\nexport class CardContent extends HostElement {\n static override identity = \"card-content\";\n static override slotName = \"card-content\";\n}\n\n/** @tag pont2-prim-card-footer */\nexport class CardFooter extends HostElement {\n static override identity = \"card-footer\";\n static override slotName = \"card-footer\";\n}\n\ndefine(\"pont2-prim-card\", Card);\ndefine(\"pont2-prim-card-header\", CardHeader);\ndefine(\"pont2-prim-card-title\", CardTitle);\ndefine(\"pont2-prim-card-description\", CardDescription);\ndefine(\"pont2-prim-card-action\", CardAction);\ndefine(\"pont2-prim-card-content\", CardContent);\ndefine(\"pont2-prim-card-footer\", CardFooter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-card\": Card;\n \"pont2-prim-card-header\": CardHeader;\n \"pont2-prim-card-title\": CardTitle;\n \"pont2-prim-card-description\": CardDescription;\n \"pont2-prim-card-action\": CardAction;\n \"pont2-prim-card-content\": CardContent;\n \"pont2-prim-card-footer\": CardFooter;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type EmptyMediaVariant = \"default\" | \"icon\";\n\n/**\n * # Empty: Tier 1 (structural)\n *\n * shadcn: `<Empty>` → `<div data-slot=\"empty\">` with `EmptyHeader`,\n * `EmptyMedia` (`data-slot=\"empty-icon\"`, `data-variant`), `EmptyTitle`,\n * `EmptyDescription`, `EmptyContent`, all divs. All host-as-root here.\n *\n * @tag pont2-prim-empty\n */\nexport class Empty extends HostElement {\n static override identity = \"empty\";\n static override slotName = \"empty\";\n}\n\n/** @tag pont2-prim-empty-header */\nexport class EmptyHeader extends HostElement {\n static override identity = \"empty-header\";\n static override slotName = \"empty-header\";\n}\n\n/**\n * Note shadcn's slot name for the media part is `empty-icon` (kept verbatim).\n *\n * @tag pont2-prim-empty-media\n * @attr variant - default | icon\n */\nexport class EmptyMedia extends HostElement {\n static override identity = \"empty-media\";\n static override slotName = \"empty-icon\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: EmptyMediaVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-empty-title */\nexport class EmptyTitle extends HostElement {\n static override identity = \"empty-title\";\n static override slotName = \"empty-title\";\n}\n\n/** @tag pont2-prim-empty-description */\nexport class EmptyDescription extends HostElement {\n static override identity = \"empty-description\";\n static override slotName = \"empty-description\";\n}\n\n/** @tag pont2-prim-empty-content */\nexport class EmptyContent extends HostElement {\n static override identity = \"empty-content\";\n static override slotName = \"empty-content\";\n}\n\ndefine(\"pont2-prim-empty\", Empty);\ndefine(\"pont2-prim-empty-header\", EmptyHeader);\ndefine(\"pont2-prim-empty-media\", EmptyMedia);\ndefine(\"pont2-prim-empty-title\", EmptyTitle);\ndefine(\"pont2-prim-empty-description\", EmptyDescription);\ndefine(\"pont2-prim-empty-content\", EmptyContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-empty\": Empty;\n \"pont2-prim-empty-header\": EmptyHeader;\n \"pont2-prim-empty-media\": EmptyMedia;\n \"pont2-prim-empty-title\": EmptyTitle;\n \"pont2-prim-empty-description\": EmptyDescription;\n \"pont2-prim-empty-content\": EmptyContent;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { HostElement, NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { applyLabel } from \"../label/label\";\n\n/**\n * # Field family\n *\n * shadcn's `field.tsx` is plain markup (no Base UI primitive):\n *\n * | shadcn | renders | pont2 | tier |\n * |-------------------|--------------------------------------------|-------------------------------|------|\n * | FieldSet | `<fieldset data-slot=\"field-set\">` | recipe/part on `<fieldset>`, `<pont2-prim-field-set>` enhancer | 3 |\n * | FieldLegend | `<legend data-slot=\"field-legend\" data-variant>` | recipe/part on `<legend>` only | 3 |\n * | FieldGroup | `<div data-slot=\"field-group\">` | `<pont2-prim-field-group>` | 1 |\n * | Field | `<div role=\"group\" data-slot=\"field\" data-orientation>` | `<pont2-prim-field>` | 1 |\n * | FieldContent | `<div data-slot=\"field-content\">` | `<pont2-prim-field-content>` | 1 |\n * | FieldLabel | `<label data-slot=\"field-label\">` (Label) | recipe/part on `<label>`, `<pont2-prim-field-label>` enhancer | 3 |\n * | FieldTitle | `<div data-slot=\"field-label\">` | `<pont2-prim-field-title>` | 1 |\n * | FieldDescription | `<p data-slot=\"field-description\">` | `<pont2-prim-field-description>` | 1 |\n * | FieldSeparator | `<div data-slot=\"field-separator\">` > Separator + `<span>` | `<pont2-prim-field-separator>` (lines drawn in CSS) | 1 |\n * | FieldError | `<div role=\"alert\" data-slot=\"field-error\">` | `<pont2-prim-field-error>` | 1 |\n *\n * Like shadcn, the family does no id wiring: you write `for`/`id` and\n * `aria-describedby` yourself (Base UI's own `Field` primitive does wire ids;\n * shadcn's Field does not use it). See docs/primitives/field.md.\n */\n\n/* ------------------------------------------------------------------ */\n/* FieldSet / FieldLegend (native) */\n/* ------------------------------------------------------------------ */\n\nexport function applyFieldSet(el: HTMLFieldSetElement): void {\n if (!el.hasAttribute(\"data-pont2-field-set\")) el.setAttribute(\"data-pont2-field-set\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"field-set\");\n}\n\nexport function fieldSet(o: { disabled?: boolean; attrs?: AttrMap }, content: unknown) {\n return html`<fieldset data-pont2-field-set data-slot=\"field-set\" ?disabled=${o.disabled} ${attrs(o.attrs ?? {})}>\n ${content}\n </fieldset>`;\n}\n\nexport function fieldLegend(o: { variant?: \"legend\" | \"label\"; attrs?: AttrMap }, content: unknown) {\n return html`<legend\n data-pont2-field-legend\n data-slot=\"field-legend\"\n data-variant=${o.variant ?? \"legend\"}\n ${attrs(o.attrs ?? {})}\n >${content}</legend\n >`;\n}\n\n/**\n * Applies the FieldSet recipe to the `<fieldset>` inside it. The legend must\n * be a direct child of that `<fieldset>` to name it, so write\n * `<legend data-pont2-field-legend>` (there is no legend element).\n *\n * @tag pont2-prim-field-set\n */\nexport class FieldSetElement extends NativeEnhancer<HTMLFieldSetElement> {\n static override nativeSelector = \"fieldset\";\n protected apply(control: HTMLFieldSetElement): void {\n applyFieldSet(control);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldGroup / Field / FieldContent */\n/* ------------------------------------------------------------------ */\n\n/** @tag pont2-prim-field-group */\nexport class FieldGroup extends HostElement {\n static override identity = \"field-group\";\n static override slotName = \"field-group\";\n}\n\nexport type FieldOrientation = \"vertical\" | \"horizontal\" | \"responsive\";\n\n/**\n * @tag pont2-prim-field\n * @attr orientation - vertical (default) | horizontal | responsive\n * @attr invalid - Sets `data-invalid` (destructive text colour), like shadcn's `data-invalid`.\n * @attr disabled - Sets `data-disabled` (dims the label/title), like shadcn's `data-disabled`.\n */\nexport class Field extends HostElement {\n static override identity = \"field\";\n static override slotName = \"field\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n orientation: { type: String, reflect: true },\n invalid: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare orientation: FieldOrientation;\n declare invalid: boolean;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.orientation = \"vertical\";\n this.invalid = false;\n this.disabled = false;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"orientation\", this.orientation || \"vertical\");\n // Only manage the state attributes we own; an author's data-invalid=\"true\" stays.\n if (changed.has(\"invalid\") && (this.invalid || changed.get(\"invalid\"))) this.setData(\"invalid\", this.invalid);\n if (changed.has(\"disabled\") && (this.disabled || changed.get(\"disabled\"))) this.setData(\"disabled\", this.disabled);\n }\n}\n\n/** @tag pont2-prim-field-content */\nexport class FieldContent extends HostElement {\n static override identity = \"field-content\";\n static override slotName = \"field-content\";\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldLabel (native) / FieldTitle */\n/* ------------------------------------------------------------------ */\n\nexport function applyFieldLabel(el: HTMLLabelElement): void {\n applyLabel(el, \"field-label\");\n if (!el.hasAttribute(\"data-pont2-field-label\")) el.setAttribute(\"data-pont2-field-label\", \"\");\n}\n\n/** `<label data-pont2-label data-pont2-field-label data-slot=\"field-label\">` */\nexport function fieldLabel(o: { for?: string; id?: string; attrs?: AttrMap }, content: unknown) {\n return html`<label\n data-pont2-label\n data-pont2-field-label\n data-slot=\"field-label\"\n for=${o.for ?? nothing}\n id=${o.id ?? nothing}\n ${attrs(o.attrs ?? {})}\n >${content}</label\n >`;\n}\n\n/** @tag pont2-prim-field-label */\nexport class FieldLabelElement extends NativeEnhancer<HTMLLabelElement> {\n static override nativeSelector = \"label\";\n protected apply(control: HTMLLabelElement): void {\n applyFieldLabel(control);\n }\n}\n\n/**\n * A label-styled title for a field that has no single control to label\n * (shadcn gives it `data-slot=\"field-label\"` too, kept verbatim).\n *\n * @tag pont2-prim-field-title\n */\nexport class FieldTitle extends HostElement {\n static override identity = \"field-title\";\n static override slotName = \"field-label\";\n}\n\n/* ------------------------------------------------------------------ */\n/* FieldDescription / FieldSeparator / FieldError */\n/* ------------------------------------------------------------------ */\n\n/** @tag pont2-prim-field-description */\nexport class FieldDescription extends HostElement {\n static override identity = \"field-description\";\n static override slotName = \"field-description\";\n}\n\n/**\n * shadcn renders `div > Separator + span`. pont2 draws the two rule halves\n * with `::before`/`::after`, so the only nodes are the host and your text.\n * `data-content` is set when the separator has text, as in shadcn.\n *\n * @tag pont2-prim-field-separator\n */\nexport class FieldSeparator extends HostElement {\n static override identity = \"field-separator\";\n static override slotName = \"field-separator\";\n\n private observer?: MutationObserver;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.observe(this, { childList: true, characterData: true, subtree: true });\n this.sync();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n private sync() {\n this.setAttribute(\"data-content\", String(!!this.textContent?.trim() || this.children.length > 0));\n }\n}\n\nexport interface FieldErrorItem {\n message?: string;\n}\n\n/**\n * Write the message as children, or set `.errors` (shadcn's `errors` prop:\n * de-duplicated by message; one renders as text, several as a list). Hidden\n * while empty, like shadcn returning `null`.\n *\n * @tag pont2-prim-field-error\n */\nexport class FieldError extends HostElement {\n static override identity = \"field-error\";\n static override slotName = \"field-error\";\n static override role = \"alert\";\n\n static override properties: PropertyDeclarations = {\n errors: { attribute: false },\n };\n\n declare errors: Array<FieldErrorItem | undefined> | undefined;\n\n override render() {\n if (!this.errors?.length) return nothing;\n const unique = [...new Map(this.errors.map(e => [e?.message, e])).values()].filter(e => e?.message);\n if (unique.length === 1) return unique[0]!.message;\n return html`<ul data-slot=\"field-error-list\">\n ${unique.map(e => html`<li>${e!.message}</li>`)}\n </ul>`;\n }\n}\n\ndefine(\"pont2-prim-field-set\", FieldSetElement);\ndefine(\"pont2-prim-field-group\", FieldGroup);\ndefine(\"pont2-prim-field\", Field);\ndefine(\"pont2-prim-field-content\", FieldContent);\ndefine(\"pont2-prim-field-label\", FieldLabelElement);\ndefine(\"pont2-prim-field-title\", FieldTitle);\ndefine(\"pont2-prim-field-description\", FieldDescription);\ndefine(\"pont2-prim-field-separator\", FieldSeparator);\ndefine(\"pont2-prim-field-error\", FieldError);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-field-set\": FieldSetElement;\n \"pont2-prim-field-group\": FieldGroup;\n \"pont2-prim-field\": Field;\n \"pont2-prim-field-content\": FieldContent;\n \"pont2-prim-field-label\": FieldLabelElement;\n \"pont2-prim-field-title\": FieldTitle;\n \"pont2-prim-field-description\": FieldDescription;\n \"pont2-prim-field-separator\": FieldSeparator;\n \"pont2-prim-field-error\": FieldError;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement, NativeEnhancer } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { applyButton, button, Pont2Button, type ButtonOptions } from \"../button/button\";\nimport { applyInput, input, type InputOptions } from \"../input/input\";\nimport { applyTextarea, textarea, type TextareaOptions } from \"../textarea/textarea\";\n\nexport type InputGroupAddonAlign = \"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\";\nexport type InputGroupButtonSize = \"xs\" | \"sm\" | \"icon-xs\" | \"icon-sm\";\n\n/**\n * # InputGroup family\n *\n * shadcn: `InputGroup` (`div role=\"group\" data-slot=\"input-group\"`),\n * `InputGroupAddon` (`div role=\"group\" data-align`, click focuses the input),\n * `InputGroupText` (a `span`), and the controls `InputGroupInput` /\n * `InputGroupTextarea` / `InputGroupButton`, which are shadcn's `Input`,\n * `Textarea` and `Button` with extra classes and\n * `data-slot=\"input-group-control\"` (button: ghost, size xs).\n *\n * pont2:\n * - `<pont2-prim-input-group>`, `<pont2-prim-input-group-addon>`, `<pont2-prim-input-group-text>`\n * are host-as-root (Tier 1).\n * - The controls stay native (Tier 3): the Input/Textarea/Button recipe plus\n * an extra identity. Write them as recipes\n * (`<input data-pont2-input data-pont2-input-group-input data-slot=\"input-group-control\">`),\n * parts (`inputGroupInput()`), or enhancers (`<pont2-prim-input-group-input><input></…>`).\n *\n * Like shadcn, the control must be a *direct* child of the group for the\n * group's `has-[>input]` padding rules; with an enhancer the shell is\n * `display: contents` and the rules also match through it.\n */\n\n/**\n * @tag pont2-prim-input-group\n * @attr disabled - Sets `data-disabled` (dims addons), like shadcn's `data-disabled=\"true\"`.\n */\nexport class InputGroup extends HostElement {\n static override identity = \"input-group\";\n static override slotName = \"input-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n disabled: { type: Boolean, reflect: true },\n };\n\n declare disabled: boolean;\n\n constructor() {\n super();\n this.disabled = false;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && (this.disabled || changed.get(\"disabled\"))) this.setData(\"disabled\", this.disabled);\n }\n}\n\n/**\n * @tag pont2-prim-input-group-addon\n * @attr align - inline-start (default) | inline-end | block-start | block-end\n */\nexport class InputGroupAddon extends HostElement {\n static override identity = \"input-group-addon\";\n static override slotName = \"input-group-addon\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n align: { type: String, reflect: true },\n };\n\n declare align: InputGroupAddonAlign;\n\n constructor() {\n super();\n this.align = \"inline-start\";\n // shadcn: clicking the addon (but not a button in it) focuses the group's input.\n this.addEventListener(\"click\", e => {\n if ((e.target as HTMLElement).closest(\"button\")) return;\n this.parentElement?.querySelector(\"input\")?.focus();\n });\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"inline-start\");\n }\n}\n\n/** shadcn's InputGroupText has no data-slot; pont2 keeps it that way. @tag pont2-prim-input-group-text */\nexport class InputGroupText extends HostElement {\n static override identity = \"input-group-text\";\n}\n\n/* ------------------------------------------------------------------ */\n/* Controls (native) */\n/* ------------------------------------------------------------------ */\n\nconst CONTROL = \"input-group-control\";\n\nfunction markControl(el: HTMLElement, identity: string) {\n if (!el.hasAttribute(`data-pont2-${identity}`)) el.setAttribute(`data-pont2-${identity}`, \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", CONTROL);\n}\n\nexport function inputGroupInput(o: InputOptions = {}) {\n return input({ ...o, slot: CONTROL, attrs: { \"data-pont2-input-group-input\": true, ...(o.attrs ?? {}) } });\n}\n\nexport function inputGroupTextarea(o: TextareaOptions = {}) {\n return textarea({ ...o, slot: CONTROL, attrs: { \"data-pont2-input-group-textarea\": true, ...(o.attrs ?? {}) } });\n}\n\nexport interface InputGroupButtonOptions extends Omit<ButtonOptions, \"size\"> {\n size?: InputGroupButtonSize;\n}\n\n/** shadcn defaults: `variant=\"ghost\"`, `size=\"xs\"`, `type=\"button\"`. */\nexport function inputGroupButton(o: InputGroupButtonOptions, content: unknown) {\n return button(\n {\n variant: \"ghost\",\n ...o,\n size: (o.size ?? \"xs\") as ButtonOptions[\"size\"],\n attrs: { \"data-pont2-input-group-button\": true, ...(o.attrs ?? {}) },\n },\n content,\n );\n}\n\n/** @tag pont2-prim-input-group-input */\nexport class InputGroupInput extends NativeEnhancer<HTMLInputElement> {\n static override nativeSelector = \"input\";\n protected apply(control: HTMLInputElement): void {\n if (!control.hasAttribute(\"data-slot\")) control.setAttribute(\"data-slot\", CONTROL);\n applyInput(control, CONTROL);\n markControl(control, \"input-group-input\");\n }\n}\n\n/** @tag pont2-prim-input-group-textarea */\nexport class InputGroupTextarea extends NativeEnhancer<HTMLTextAreaElement> {\n static override nativeSelector = \"textarea\";\n protected apply(control: HTMLTextAreaElement): void {\n if (!control.hasAttribute(\"data-slot\")) control.setAttribute(\"data-slot\", CONTROL);\n applyTextarea(control, CONTROL);\n markControl(control, \"input-group-textarea\");\n }\n}\n\n/**\n * `<pont2-prim-button>` with shadcn's InputGroupButton defaults (ghost, xs) and its\n * extra recipe. It *is* a Pont2Button enhancer, so everything else is inherited.\n *\n * @tag pont2-prim-input-group-button\n * @attr size - xs (default) | sm | icon-xs | icon-sm\n */\nexport class InputGroupButton extends Pont2Button {\n constructor() {\n super();\n this.variant = \"ghost\";\n this.size = \"xs\";\n }\n\n protected override apply(control: HTMLButtonElement | HTMLAnchorElement): void {\n applyButton(control, this);\n if (!control.hasAttribute(\"data-pont2-input-group-button\")) control.setAttribute(\"data-pont2-input-group-button\", \"\");\n if (control instanceof HTMLButtonElement && !control.hasAttribute(\"type\")) control.type = \"button\";\n }\n}\n\ndefine(\"pont2-prim-input-group\", InputGroup);\ndefine(\"pont2-prim-input-group-addon\", InputGroupAddon);\ndefine(\"pont2-prim-input-group-text\", InputGroupText);\ndefine(\"pont2-prim-input-group-input\", InputGroupInput);\ndefine(\"pont2-prim-input-group-textarea\", InputGroupTextarea);\ndefine(\"pont2-prim-input-group-button\", InputGroupButton);\n\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input-group\": InputGroup;\n \"pont2-prim-input-group-addon\": InputGroupAddon;\n \"pont2-prim-input-group-text\": InputGroupText;\n \"pont2-prim-input-group-input\": InputGroupInput;\n \"pont2-prim-input-group-textarea\": InputGroupTextarea;\n \"pont2-prim-input-group-button\": InputGroupButton;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { Separator } from \"../separator/separator\";\n\nexport type ItemVariant = \"default\" | \"outline\" | \"muted\";\nexport type ItemSize = \"default\" | \"sm\" | \"xs\";\nexport type ItemMediaVariant = \"default\" | \"icon\" | \"image\";\n\n/**\n * # Item family: Tier 1 (structural)\n *\n * shadcn: `ItemGroup` (`div role=\"list\"`), `Item` (Base UI `useRender`, a div\n * by default, or the author's `<a>` through `render`), `ItemMedia`,\n * `ItemContent`, `ItemTitle`, `ItemDescription` (a `p`), `ItemActions`,\n * `ItemHeader`, `ItemFooter`, and `ItemSeparator` (a `Separator`).\n *\n * pont2: every part is host-as-root. A link item is the recipe on a real\n * anchor: `<a data-pont2-item data-variant=\"outline\" href=\"…\">`.\n * `ItemSeparator extends Separator`, so it *is* a separator (one node, role\n * separator) that keeps the separator look and adds `data-slot=\"item-separator\"`.\n */\n\n/** @tag pont2-prim-item-group */\nexport class ItemGroup extends HostElement {\n static override identity = \"item-group\";\n static override slotName = \"item-group\";\n static override role = \"list\";\n}\n\n/** @tag pont2-prim-item-separator */\nexport class ItemSeparator extends Separator {\n static override identity = \"item-separator\";\n static override slotName = \"item-separator\";\n}\n\n/**\n * @tag pont2-prim-item\n * @attr variant - default | outline | muted\n * @attr size - default | sm | xs\n */\nexport class Item extends HostElement {\n static override identity = \"item\";\n static override slotName = \"item\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n size: { type: String, reflect: true },\n };\n\n declare variant: ItemVariant;\n declare size: ItemSize;\n\n constructor() {\n super();\n this.variant = \"default\";\n this.size = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n this.setData(\"size\", this.size || \"default\");\n }\n}\n\n/**\n * @tag pont2-prim-item-media\n * @attr variant - default | icon | image\n */\nexport class ItemMedia extends HostElement {\n static override identity = \"item-media\";\n static override slotName = \"item-media\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n\n declare variant: ItemMediaVariant;\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\n/** @tag pont2-prim-item-content */\nexport class ItemContent extends HostElement {\n static override identity = \"item-content\";\n static override slotName = \"item-content\";\n}\n\n/** @tag pont2-prim-item-title */\nexport class ItemTitle extends HostElement {\n static override identity = \"item-title\";\n static override slotName = \"item-title\";\n}\n\n/** @tag pont2-prim-item-description */\nexport class ItemDescription extends HostElement {\n static override identity = \"item-description\";\n static override slotName = \"item-description\";\n}\n\n/** @tag pont2-prim-item-actions */\nexport class ItemActions extends HostElement {\n static override identity = \"item-actions\";\n static override slotName = \"item-actions\";\n}\n\n/** @tag pont2-prim-item-header */\nexport class ItemHeader extends HostElement {\n static override identity = \"item-header\";\n static override slotName = \"item-header\";\n}\n\n/** @tag pont2-prim-item-footer */\nexport class ItemFooter extends HostElement {\n static override identity = \"item-footer\";\n static override slotName = \"item-footer\";\n}\n\ndefine(\"pont2-prim-item-group\", ItemGroup);\ndefine(\"pont2-prim-item-separator\", ItemSeparator);\ndefine(\"pont2-prim-item\", Item);\ndefine(\"pont2-prim-item-media\", ItemMedia);\ndefine(\"pont2-prim-item-content\", ItemContent);\ndefine(\"pont2-prim-item-title\", ItemTitle);\ndefine(\"pont2-prim-item-description\", ItemDescription);\ndefine(\"pont2-prim-item-actions\", ItemActions);\ndefine(\"pont2-prim-item-header\", ItemHeader);\ndefine(\"pont2-prim-item-footer\", ItemFooter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-item-group\": ItemGroup;\n \"pont2-prim-item-separator\": ItemSeparator;\n \"pont2-prim-item\": Item;\n \"pont2-prim-item-media\": ItemMedia;\n \"pont2-prim-item-content\": ItemContent;\n \"pont2-prim-item-title\": ItemTitle;\n \"pont2-prim-item-description\": ItemDescription;\n \"pont2-prim-item-actions\": ItemActions;\n \"pont2-prim-item-header\": ItemHeader;\n \"pont2-prim-item-footer\": ItemFooter;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type NativeSelectSize = \"default\" | \"sm\";\n\n/**\n * # NativeSelect: Tier 1 wrapper + native `<select>`\n *\n * shadcn: `<NativeSelect size>` renders\n * `div[data-slot=native-select-wrapper][data-size] > select[data-slot=native-select][data-size] + svg[data-slot=native-select-icon]`;\n * `NativeSelectOption` / `NativeSelectOptGroup` are `<option>` / `<optgroup>`.\n *\n * pont2: `<pont2-prim-native-select>` **is** the wrapper div; you write the native\n * `<select>` (and its options) inside, and the host applies the recipe to it.\n * The chevron is drawn by the wrapper's `::after`, so the DOM is\n * `pont2-prim-native-select > select`: one node fewer than shadcn, and the select\n * stays a real form control (submission, autofill, mobile pickers).\n *\n * ```html\n * <pont2-prim-native-select>\n * <select name=\"country\"><option>Norway</option><option>Japan</option></select>\n * </pont2-prim-native-select>\n * ```\n *\n * @tag pont2-prim-native-select\n * @attr size - default | sm\n * @cssprop --pont2-native-select-icon - mask image for the chevron\n */\nexport class NativeSelect extends HostElement {\n static override identity = \"native-select-wrapper\";\n static override slotName = \"native-select-wrapper\";\n\n static override properties: PropertyDeclarations = {\n size: { type: String, reflect: true },\n };\n\n declare size: NativeSelectSize;\n\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.size = \"default\";\n }\n\n /** The native `<select>`. */\n get control(): HTMLSelectElement | null {\n return this.querySelector(\":scope > select\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n protected override willUpdate(): void {\n const size = this.size || \"default\";\n this.setData(\"size\", size);\n const select = this.control;\n if (select) applyNativeSelect(select, size);\n }\n}\n\nexport function applyNativeSelect(el: HTMLSelectElement, size: NativeSelectSize = \"default\"): void {\n if (!el.hasAttribute(\"data-pont2-native-select\")) el.setAttribute(\"data-pont2-native-select\", \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", \"native-select\");\n el.setAttribute(\"data-size\", size);\n}\n\nexport interface NativeSelectOptions {\n size?: NativeSelectSize;\n id?: string;\n name?: string;\n disabled?: boolean;\n required?: boolean;\n invalid?: boolean;\n attrs?: AttrMap;\n onChange?: (e: Event) => void;\n}\n\n/** Part: the wrapper div and the select in one template (options are the content). */\nexport function nativeSelect(o: NativeSelectOptions, options: unknown) {\n const size = o.size ?? \"default\";\n return html`<div data-pont2-native-select-wrapper data-slot=\"native-select-wrapper\" data-size=${size}>\n <select\n data-pont2-native-select\n data-slot=\"native-select\"\n data-size=${size}\n id=${o.id ?? nothing}\n name=${o.name ?? nothing}\n ?disabled=${o.disabled}\n ?required=${o.required}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n ${attrs(o.attrs ?? {})}\n @change=${o.onChange ?? nothing}\n >\n ${options}\n </select>\n </div>`;\n}\n\ndefine(\"pont2-prim-native-select\", NativeSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-native-select\": NativeSelect;\n }\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/**\n * # Table: Tier 1 container + native table (recipe)\n *\n * shadcn: `<Table>` → `<div data-slot=\"table-container\"><table data-slot=\"table\">`,\n * and `TableHeader | TableBody | TableFooter | TableRow | TableHead |\n * TableCell | TableCaption` are the native `thead | tbody | tfoot | tr | th |\n * td | caption` with a `data-slot` each.\n *\n * Table parts cannot be custom elements: the HTML parser \"foster-parents\"\n * unknown elements out of a `<table>` (`<table><pont2-tr>` puts the\n * `pont2-tr` *before* the table). And `colspan`, `headers`, `scope` and the\n * native table semantics only exist on the native elements.\n *\n * So `<pont2-prim-table>` **is** the container div (host-as-root), and you write a\n * plain native `<table>` inside it:\n *\n * ```html\n * <pont2-prim-table>\n * <table>\n * <caption>Recent invoices</caption>\n * <thead><tr><th>Invoice</th><th>Amount</th></tr></thead>\n * <tbody><tr><td>INV001</td><td>$250.00</td></tr></tbody>\n * </table>\n * </pont2-prim-table>\n * ```\n *\n * The host stamps each part's recipe (`data-pont2-table-*` + shadcn's\n * `data-slot`) onto the native elements of *its own* table (not nested ones),\n * and keeps doing so as rows are added. Styling also works before upgrade and\n * with no JS, through `pont2-prim-table > table …` selectors, and outside the\n * element via the recipe attributes (`applyTable()`).\n *\n * @tag pont2-prim-table\n */\nexport class Table extends HostElement {\n static override identity = \"table-container\";\n static override slotName = \"table-container\";\n\n private observer?: MutationObserver;\n\n /** The native `<table>` this container holds. */\n get table(): HTMLTableElement | null {\n return this.querySelector(\":scope > table\");\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.stamp());\n this.observer.observe(this, { childList: true, subtree: true });\n this.stamp();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n private stamp() {\n const t = this.table;\n if (t) applyTable(t);\n }\n}\n\nconst PARTS: Record<string, string> = {\n CAPTION: \"table-caption\",\n THEAD: \"table-header\",\n TBODY: \"table-body\",\n TFOOT: \"table-footer\",\n TR: \"table-row\",\n TH: \"table-head\",\n TD: \"table-cell\",\n};\n\nfunction mark(el: Element, part: string) {\n if (!el.hasAttribute(`data-pont2-${part}`)) el.setAttribute(`data-pont2-${part}`, \"\");\n if (!el.hasAttribute(\"data-slot\")) el.setAttribute(\"data-slot\", part);\n}\n\n/**\n * Applies the table recipe to a native `<table>` and its own sections, rows\n * and cells (not those of nested tables). Idempotent.\n */\nexport function applyTable(table: HTMLTableElement): void {\n mark(table, \"table\");\n if (table.caption) mark(table.caption, PARTS.CAPTION);\n for (const section of [table.tHead, ...Array.from(table.tBodies), table.tFoot]) {\n if (section) mark(section, PARTS[section.tagName]);\n }\n for (const row of Array.from(table.rows)) {\n mark(row, PARTS.TR);\n for (const cell of Array.from(row.cells)) mark(cell, PARTS[cell.tagName]);\n }\n}\n\ndefine(\"pont2-prim-table\", Table);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-table\": Table;\n }\n}\n","/**\n * Pure InputOTP helpers (no DOM), unit-tested in node.\n *\n * `pattern` is a whole-string regular expression source, like the input-otp\n * library's `REGEXP_ONLY_DIGITS` (`^\\d+$`); each character is tested on its\n * own, so pasted \"123-456\" or \"12 34 56\" is cleaned to \"123456\".\n */\nexport const REGEXP_ONLY_DIGITS = \"^\\\\d+$\";\nexport const REGEXP_ONLY_CHARS = \"^[a-zA-Z]+$\";\nexport const REGEXP_ONLY_DIGITS_AND_CHARS = \"^[a-zA-Z0-9]+$\";\n\nexport function sanitizeOtp(raw: string, maxLength: number, pattern: string | null = REGEXP_ONLY_DIGITS): string {\n let re: RegExp | null = null;\n if (pattern) {\n try {\n re = new RegExp(pattern);\n } catch {\n re = null;\n }\n }\n let out = \"\";\n for (const ch of Array.from(raw)) {\n if (out.length >= maxLength) break;\n if (/\\s/.test(ch)) continue;\n if (re && !re.test(ch)) continue;\n out += ch;\n }\n return out;\n}\n\nexport interface OtpSlotState {\n char: string | null;\n isActive: boolean;\n hasFakeCaret: boolean;\n}\n\n/**\n * Per-slot state, as input-otp computes it: while focused, the slot(s) under\n * the selection are active; a collapsed selection on an empty slot shows the\n * fake caret. A full value with the caret at the end activates the last slot.\n */\nexport function otpSlots(\n value: string,\n maxLength: number,\n focused: boolean,\n selStart: number | null,\n selEnd: number | null,\n): OtpSlotState[] {\n const chars = Array.from(value);\n let start = selStart ?? chars.length;\n let end = selEnd ?? start;\n if (start === end && start >= maxLength) {\n start = maxLength - 1;\n end = maxLength;\n }\n const collapsed = start === end;\n return Array.from({ length: maxLength }, (_, i) => {\n const char = chars[i] ?? null;\n const isActive = focused && (collapsed ? i === start : i >= start && i < end);\n return { char, isActive, hasFakeCaret: isActive && collapsed && char === null };\n });\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { live } from \"lit/directives/live.js\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define, sel } from \"../../core/names\";\nimport { REGEXP_ONLY_DIGITS, otpSlots, sanitizeOtp, type OtpSlotState } from \"./otp\";\n\nexport { REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from \"./otp\";\n\nconst ROOT = sel(\"input-otp\");\nconst SLOT = sel(\"input-otp-slot\");\nconst FORWARDED = [\"aria-label\", \"aria-labelledby\", \"aria-describedby\", \"aria-invalid\"] as const;\n\nexport interface OtpCompleteDetail {\n value: string;\n}\n\n/**\n * # InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator\n *\n * shadcn wraps the `input-otp` library: a container `div` holding the author's\n * groups/slots plus ONE real `<input>` stretched transparently over them; the\n * slots only *draw* the characters and a fake caret.\n * ```\n * shadcn: div.cn-input-otp > [InputOTPGroup > InputOTPSlot ×n, InputOTPSeparator] + div > input[data-slot=input-otp]\n * pont2: pont2-prim-input-otp > [pont2-prim-input-otp-group > pont2-prim-input-otp-slot ×n, pont2-prim-input-otp-separator] + div > input[data-slot=input-otp]\n * ```\n * Same shape, same reason: the single native `<input autocomplete=\"one-time-code\">`\n * is what SMS autofill (iOS/Android), password managers, paste and form\n * submission need. It is a Tier 3 core inside a Tier 1 container; the slots\n * are Tier 1 hosts the container pushes state into.\n *\n * The input is rendered by the host (after the author's children, where\n * input-otp puts it), so the author never writes it; `name`, `required`,\n * `disabled`, `autocomplete`, `inputmode`, `pattern` and the ARIA naming\n * attributes are forwarded to it.\n *\n * @tag pont2-prim-input-otp\n * @attr maxlength - Number of characters (default 6).\n * @attr pattern - Per-character regex source (default `^\\d+$`, digits). `pattern=\"\"` accepts anything.\n * @attr value - Default value; `.value` is live.\n * @attr name, required, disabled, autocomplete (one-time-code), inputmode, input-id\n * @fires input, change - Native events from the inner input (bubble through the host).\n * @fires pont2-complete - `{ value }` when every slot is filled (input-otp `onComplete`).\n */\nexport class InputOTP extends HostElement {\n static override identity = \"input-otp\";\n\n static override properties: PropertyDeclarations = {\n maxLength: { type: Number, attribute: \"maxlength\" },\n pattern: { type: String },\n defaultValue: { type: String, attribute: \"value\" },\n name: { type: String },\n required: { type: Boolean },\n disabled: { type: Boolean, reflect: true },\n autocomplete: { type: String },\n keyboardMode: { type: String, attribute: \"inputmode\" },\n inputId: { type: String, attribute: \"input-id\" },\n current: { state: true },\n forwarded: { state: true },\n };\n\n declare maxLength: number;\n declare pattern: string | null;\n declare defaultValue: string | null;\n declare name: string | null;\n declare required: boolean;\n declare disabled: boolean;\n declare autocomplete: string;\n /** Forwarded to the input as `inputmode` (named so it does not shadow HTMLElement.inputMode). */\n declare keyboardMode: string | null;\n declare inputId: string | null;\n declare protected current: string;\n declare protected forwarded: Record<string, string | null>;\n\n private dirty = false;\n private focused = false;\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.maxLength = 6;\n this.pattern = REGEXP_ONLY_DIGITS;\n this.defaultValue = null;\n this.name = null;\n this.required = false;\n this.disabled = false;\n this.autocomplete = \"one-time-code\";\n this.keyboardMode = null;\n this.inputId = null;\n this.current = \"\";\n this.forwarded = {};\n }\n\n /** The native input (the real form control). */\n get input(): HTMLInputElement | null {\n return this.querySelector(\":scope > [data-pont2-input-otp-input-wrapper] > input\");\n }\n\n get value(): string {\n return this.current;\n }\n set value(v: string) {\n this.dirty = true;\n this.current = sanitizeOtp(String(v ?? \"\"), this.maxLength, this.pattern || null);\n }\n\n override focus(options?: FocusOptions): void {\n this.input?.focus(options);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.readForwarded();\n this.observer ??= new MutationObserver(m => {\n if (m.some(r => r.type === \"attributes\" && r.target === this)) this.readForwarded();\n else this.syncSlots();\n });\n this.observer.observe(this, { attributes: true, attributeFilter: [...FORWARDED], childList: true, subtree: true });\n document.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n document.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n\n private readForwarded(): void {\n const f: Record<string, string | null> = {};\n for (const a of FORWARDED) f[a] = this.getAttribute(a);\n this.forwarded = f;\n }\n\n private get slots(): InputOTPSlot[] {\n return Array.from(this.querySelectorAll<InputOTPSlot>(SLOT)).filter(s => s.closest(ROOT) === this);\n }\n\n /** Push per-slot state into the slot elements. */\n private syncSlots(): void {\n const input = this.input;\n const states = otpSlots(this.current, this.maxLength, this.focused, input?.selectionStart ?? null, input?.selectionEnd ?? null);\n const invalid = this.forwarded[\"aria-invalid\"] === \"true\";\n this.slots.forEach((slot, order) => {\n const i = slot.hasAttribute(\"index\") ? Number(slot.getAttribute(\"index\")) : order;\n if (typeof slot.sync === \"function\") slot.sync(states[i] ?? { char: null, isActive: false, hasFakeCaret: false }, invalid);\n });\n }\n\n /* -------------------------------------------------------------- */\n /* Input handling (what input-otp does) */\n /* -------------------------------------------------------------- */\n\n private setFromInput(raw: string, input: HTMLInputElement): void {\n const clean = sanitizeOtp(raw, this.maxLength, this.pattern || null);\n if (clean !== input.value) {\n input.value = clean;\n input.setSelectionRange(clean.length, clean.length);\n }\n const was = this.current;\n this.dirty = true;\n this.current = clean;\n if (clean !== was && clean.length === this.maxLength) {\n fire<OtpCompleteDetail>(this, \"pont2-complete\", { value: clean });\n }\n this.syncSlots();\n }\n\n private onInput = (e: Event) => {\n this.setFromInput((e.target as HTMLInputElement).value, e.target as HTMLInputElement);\n };\n\n private onPaste = (e: ClipboardEvent) => {\n const input = e.target as HTMLInputElement;\n const text = e.clipboardData?.getData(\"text/plain\");\n if (text == null) return;\n // The native maxlength would truncate \"123-456\" before we could clean it.\n e.preventDefault();\n const start = input.selectionStart ?? input.value.length;\n const end = input.selectionEnd ?? start;\n this.setFromInput(input.value.slice(0, start) + text + input.value.slice(end), input);\n input.dispatchEvent(new Event(\"input\", { bubbles: true, composed: true }));\n };\n\n private placeCaret = () => {\n const input = this.input;\n if (!input) return;\n const n = input.value.length;\n // Full: select the last character so the next key replaces it (input-otp behaviour).\n if (n >= this.maxLength) input.setSelectionRange(this.maxLength - 1, this.maxLength);\n else input.setSelectionRange(n, n);\n this.syncSlots();\n };\n\n private onFocus = () => {\n this.focused = true;\n this.setData(\"focused\", true);\n requestAnimationFrame(this.placeCaret);\n };\n\n private onBlur = () => {\n this.focused = false;\n this.setData(\"focused\", false);\n this.syncSlots();\n };\n\n private onSelectionChange = () => {\n if (this.focused && document.activeElement === this.input) this.syncSlots();\n };\n\n /* -------------------------------------------------------------- */\n /* Render */\n /* -------------------------------------------------------------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) {\n this.current = sanitizeOtp(this.defaultValue ?? \"\", this.maxLength, this.pattern || null);\n }\n this.setData(\"disabled\", this.disabled);\n this.setData(\"complete\", this.current.length === this.maxLength);\n }\n\n protected override updated(): void {\n this.syncSlots();\n }\n\n override render() {\n const digits = this.pattern === REGEXP_ONLY_DIGITS;\n const f = this.forwarded;\n return html`<div data-pont2-input-otp-input-wrapper>\n <input\n data-pont2-input-otp-input\n data-slot=\"input-otp\"\n id=${this.inputId ?? nothing}\n name=${this.name ?? nothing}\n .value=${live(this.current)}\n maxlength=${this.maxLength}\n pattern=${this.pattern || nothing}\n inputmode=${(this.keyboardMode ?? (digits ? \"numeric\" : \"text\")) as never}\n autocomplete=${this.autocomplete as never}\n spellcheck=\"false\"\n autocapitalize=\"off\"\n ?required=${this.required}\n ?disabled=${this.disabled}\n aria-label=${f[\"aria-label\"] ?? nothing}\n aria-labelledby=${f[\"aria-labelledby\"] ?? nothing}\n aria-describedby=${f[\"aria-describedby\"] ?? nothing}\n aria-invalid=${f[\"aria-invalid\"] ?? nothing}\n @input=${this.onInput}\n @paste=${this.onPaste}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n @click=${this.placeCaret}\n />\n </div>`;\n }\n}\n\n/**\n * @tag pont2-prim-input-otp-group\n */\nexport class InputOTPGroup extends HostElement {\n static override identity = \"input-otp-group\";\n static override slotName = \"input-otp-group\";\n}\n\n/**\n * Draws one character (and the fake caret). Purely visual: the native input\n * is what assistive technology and autofill interact with.\n *\n * @tag pont2-prim-input-otp-slot\n * @attr index - Character position; defaults to the slot's order in the InputOTP.\n */\nexport class InputOTPSlot extends HostElement {\n static override identity = \"input-otp-slot\";\n static override slotName = \"input-otp-slot\";\n\n static override properties: PropertyDeclarations = {\n state: { state: true },\n };\n\n declare protected state: OtpSlotState;\n\n constructor() {\n super();\n this.state = { char: null, isActive: false, hasFakeCaret: false };\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as InputOTP | null)?.requestUpdate();\n }\n\n /** @internal Called by the InputOTP. */\n sync(state: OtpSlotState, invalid: boolean): void {\n this.state = state;\n this.setData(\"active\", state.isActive ? \"true\" : \"false\");\n this.setData(\"filled\", state.char != null);\n this.setData(\"invalid\", invalid);\n }\n\n override render() {\n const { char, hasFakeCaret } = this.state;\n return html`${char ?? nothing}${hasFakeCaret\n ? html`<div data-pont2-input-otp-caret><div data-pont2-input-otp-caret-line></div></div>`\n : nothing}`;\n }\n}\n\n/**\n * @tag pont2-prim-input-otp-separator\n */\nexport class InputOTPSeparator extends HostElement {\n static override identity = \"input-otp-separator\";\n static override slotName = \"input-otp-separator\";\n static override role = \"separator\";\n\n override render() {\n return icons.minus();\n }\n}\n\ndefine(\"pont2-prim-input-otp\", InputOTP);\ndefine(\"pont2-prim-input-otp-group\", InputOTPGroup);\ndefine(\"pont2-prim-input-otp-slot\", InputOTPSlot);\ndefine(\"pont2-prim-input-otp-separator\", InputOTPSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-input-otp\": InputOTP;\n \"pont2-prim-input-otp-group\": InputOTPGroup;\n \"pont2-prim-input-otp-slot\": InputOTPSlot;\n \"pont2-prim-input-otp-separator\": InputOTPSeparator;\n }\n interface HTMLElementEventMap {\n \"pont2-complete\": CustomEvent<OtpCompleteDetail>;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\n\nexport type ProgressStatus = \"progressing\" | \"complete\" | \"indeterminate\";\n\nconst ROOT = sel(\"progress\");\n\n/**\n * # Progress, ProgressLabel, ProgressValue: Tier 1/2 (status widget)\n *\n * shadcn: `<Progress value>` → Base UI `<Progress.Root>` (div[role=progressbar])\n * holding the author's children, then `<Progress.Track>` > `<Progress.Indicator>`\n * which shadcn always appends. `<ProgressLabel>` / `<ProgressValue>` are optional\n * children (span).\n *\n * pont2:\n * ```\n * pont2-prim-progress[role=progressbar] ← root; aria-value* via ElementInternals\n * pont2-prim-progress-label? pont2-prim-progress-value? ← author-written, never moved\n * div[data-slot=progress-track] > div[data-slot=progress-indicator] ← rendered last, as shadcn does\n * ```\n * Status attributes are Base UI's: `data-progressing` | `data-complete` |\n * `data-indeterminate`, on every part. No `value` attribute = indeterminate.\n *\n * @tag pont2-prim-progress\n * @attr value - Current value; omit for indeterminate.\n * @attr min, max - Range (default 0–100).\n */\nexport class Progress extends HostElement {\n static override identity = \"progress\";\n static override slotName = \"progress\";\n static override role = \"progressbar\";\n\n static override properties: PropertyDeclarations = {\n value: { type: Number },\n min: { type: Number },\n max: { type: Number },\n };\n\n declare value: number | null;\n declare min: number;\n declare max: number;\n\n constructor() {\n super();\n this.value = null;\n this.min = 0;\n this.max = 100;\n }\n\n get status(): ProgressStatus {\n if (this.value == null || Number.isNaN(this.value)) return \"indeterminate\";\n return this.value >= this.max ? \"complete\" : \"progressing\";\n }\n\n /** 0..1, or null when indeterminate. */\n get fraction(): number | null {\n if (this.status === \"indeterminate\") return null;\n const span = this.max - this.min;\n return span > 0 ? Math.min(1, Math.max(0, (this.value! - this.min) / span)) : 0;\n }\n\n /** The value as Base UI formats it by default: a locale percentage. */\n get formattedValue(): string {\n const f = this.fraction;\n return f == null ? \"\" : new Intl.NumberFormat(undefined, { style: \"percent\" }).format(f);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n const status = this.status;\n const i = this.internals;\n i.ariaValueMin = String(this.min);\n i.ariaValueMax = String(this.max);\n i.ariaValueNow = status === \"indeterminate\" ? null : String(this.value);\n i.ariaValueText = status === \"indeterminate\" ? null : this.formattedValue;\n for (const s of [\"progressing\", \"complete\", \"indeterminate\"] as const) this.setData(s, s === status);\n }\n\n protected override updated(): void {\n const labels = this.own<ProgressLabel>(sel(\"progress-label\"));\n if (\"ariaLabelledByElements\" in ElementInternals.prototype) {\n (this.internals as unknown as { ariaLabelledByElements: Element[] | null }).ariaLabelledByElements = labels.length ? labels : null;\n } else if (labels.length && !this.hasAttribute(\"aria-labelledby\")) {\n this.setAttribute(\"aria-labelledby\", labels.map(l => ensureId(l, \"progress-label\")).join(\" \"));\n }\n const parts = [...labels, ...this.own<ProgressValue>(sel(\"progress-value\"))];\n for (const p of parts) if (typeof p.sync === \"function\") p.sync(this.status, this.formattedValue);\n }\n\n private own<T extends Element>(sel: string): T[] {\n return Array.from(this.querySelectorAll<T>(sel)).filter(el => el.closest(ROOT) === this);\n }\n\n override render() {\n const s = this.status;\n const f = this.fraction;\n return html`<div\n data-pont2-progress-track\n data-slot=\"progress-track\"\n ?data-progressing=${s === \"progressing\"}\n ?data-complete=${s === \"complete\"}\n ?data-indeterminate=${s === \"indeterminate\"}\n >\n <div\n data-pont2-progress-indicator\n data-slot=\"progress-indicator\"\n ?data-progressing=${s === \"progressing\"}\n ?data-complete=${s === \"complete\"}\n ?data-indeterminate=${s === \"indeterminate\"}\n style=${f == null ? nothing : styleMap({ insetInlineStart: \"0\", width: `${f * 100}%` })}\n ></div>\n </div>`;\n }\n}\n\n/** Shared status sync for the optional parts. */\nabstract class ProgressPart extends HostElement {\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as Progress | null)?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(status: ProgressStatus, _formatted: string): void {\n for (const s of [\"progressing\", \"complete\", \"indeterminate\"] as const) this.setData(s, s === status);\n }\n}\n\n/**\n * Labels the progress bar (the root's accessible name points at it).\n * @tag pont2-prim-progress-label\n */\nexport class ProgressLabel extends ProgressPart {\n static override identity = \"progress-label\";\n static override slotName = \"progress-label\";\n}\n\n/**\n * Shows the formatted value (\"45%\") unless you write your own text inside it.\n * @tag pont2-prim-progress-value\n */\nexport class ProgressValue extends ProgressPart {\n static override identity = \"progress-value\";\n static override slotName = \"progress-value\";\n\n static override properties: PropertyDeclarations = {\n formatted: { state: true },\n };\n\n declare protected formatted: string;\n private authored = false;\n\n constructor() {\n super();\n this.formatted = \"\";\n }\n\n override connectedCallback(): void {\n // Author text wins (Base UI's `children`); decided once, before the first render.\n if (!this.hasUpdated) this.authored = (this.textContent ?? \"\").trim() !== \"\";\n super.connectedCallback();\n this.setAttribute(\"aria-hidden\", this.getAttribute(\"aria-hidden\") ?? \"true\");\n }\n\n override sync(status: ProgressStatus, formatted: string): void {\n super.sync(status, formatted);\n this.formatted = formatted;\n }\n\n override render() {\n return this.authored ? nothing : this.formatted;\n }\n}\n\ndefine(\"pont2-prim-progress\", Progress);\ndefine(\"pont2-prim-progress-label\", ProgressLabel);\ndefine(\"pont2-prim-progress-value\", ProgressValue);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-progress\": Progress;\n \"pont2-prim-progress-label\": ProgressLabel;\n \"pont2-prim-progress-value\": ProgressValue;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { RovingFocusController, type Orientation } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define, sel } from \"../../core/names\";\n\n/**\n * # RadioGroup, RadioGroupItem: Tier 2 (widgets)\n *\n * shadcn: `<RadioGroup>` → Base UI `<RadioGroup>` (`<div role=\"radiogroup\">`\n * plus a hidden input) and `<RadioGroupItem value>` → Base UI `<Radio.Root>`\n * (`<span role=\"radio\">`) > `<Radio.Indicator>` > `<span>` (the dot).\n *\n * pont2:\n * ```\n * pont2-prim-radio-group[role=radiogroup] ← form-associated: submits name=value\n * pont2-prim-radio-group-item[role=radio] ← author-written, never moved\n * span[data-slot=radio-group-indicator] ← rendered while checked\n * span[data-pont2-radio-group-indicator-icon]\n * ```\n *\n * The group owns the value, the form value, validity and the roving tab stop.\n * Items are independent stateful widgets nested inside it, which is the one\n * kind of nesting the architecture keeps (04-composition.md); they find their\n * group with `closest()` and report presses to it. Items are also\n * form-associated (submitting nothing) purely so that they are *labelable*:\n * shadcn's `<RadioGroupItem id=\"r1\"/><Label htmlFor=\"r1\">` works unchanged.\n *\n * Keyboard (Base UI / APG): Tab enters at the checked item (or the first),\n * arrows move focus **and select** (wrapping), Space selects the focused item.\n */\nexport class RadioGroup extends FormControlElement {\n static override identity = \"radio-group\";\n static override slotName = \"radio-group\";\n static override role = \"radiogroup\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n orientation: { type: String },\n };\n\n /** The selected item's value; `\"\"` when nothing is selected. */\n declare value: string;\n /** Arrow-key axis. Base UI accepts both axes by default. */\n declare orientation: Orientation | undefined;\n\n private roving = new RovingFocusController(this, {\n items: () => this.items,\n orientation: () => this.orientation ?? \"both\",\n onNavigate: item => this.selectItem(item as RadioGroupItem),\n });\n\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n /** The items that belong to this group (not to a nested group). */\n get items(): RadioGroupItem[] {\n return Array.from(this.querySelectorAll<RadioGroupItem>(sel(\"radio-group-item\"))).filter(\n i => i.closest(sel(\"radio-group\")) === this,\n );\n }\n\n protected override get hostFocusable(): boolean {\n return false;\n }\n\n protected override get validationAnchor(): HTMLElement | undefined {\n return this.items[0];\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true, subtree: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n /** Called by an item when it is pressed. */\n selectItem(item: RadioGroupItem): void {\n if (this.isDisabled || this.readOnly || item.disabled) return;\n if (item.value === this.value) return;\n this.value = item.value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n /** Called by items when they connect, so a late-upgrading item is synced. */\n itemsChanged(): void {\n this.requestUpdate();\n }\n\n protected formValue() {\n return this.value || null;\n }\n\n protected resetToDefault(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n protected override validate(): ValidityResult | null {\n return this.required && !this.value\n ? { flags: { valueMissing: true }, message: \"Please select one of these options.\" }\n : null;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaOrientation = this.orientation === \"horizontal\" || this.orientation === \"vertical\" ? this.orientation : null;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n let checked: RadioGroupItem | null = null;\n for (const item of this.items) {\n item.checked = !!this.value && item.value === this.value;\n item.groupDisabled = disabled;\n item.groupReadOnly = this.readOnly;\n item.groupRequired = this.required;\n if (item.checked) checked = item;\n }\n this.roving.sync(checked);\n }\n}\n\n/**\n * @tag pont2-prim-radio-group-item\n * @attr value - The value the group takes when this item is selected.\n * @attr disabled\n */\nexport class RadioGroupItem extends HostElement {\n static formAssociated = true;\n static override identity = \"radio-group-item\";\n static override slotName = \"radio-group-item\";\n static override role = \"radio\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n checked: { state: true },\n groupDisabled: { state: true },\n groupReadOnly: { state: true },\n groupRequired: { state: true },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare disabled: boolean;\n declare checked: boolean;\n declare groupDisabled: boolean;\n declare groupReadOnly: boolean;\n declare groupRequired: boolean;\n declare protected formDisabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.checked = false;\n this.groupDisabled = false;\n this.groupReadOnly = false;\n this.groupRequired = false;\n this.formDisabled = false;\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n }\n\n get group(): RadioGroup | null {\n return this.closest(sel(\"radio-group\")) as RadioGroup | null;\n }\n\n get isDisabled(): boolean {\n return this.disabled || this.groupDisabled || this.formDisabled;\n }\n\n get labels(): NodeList {\n return this.internals.labels;\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.group?.itemsChanged();\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled) {\n e.preventDefault();\n return;\n }\n this.group?.selectItem(this);\n // A press focuses the item, as a native radio does (also when it came from a <label>).\n if (document.activeElement !== this) this.focus();\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this) return;\n if (e.key === \" \") {\n e.preventDefault();\n this.click();\n }\n // Enter does not select a radio (native behaviour); it would submit the form natively,\n // so mirror that through the form's implicit submission.\n if (e.key === \"Enter\") this.internals.form?.requestSubmit();\n };\n\n protected override willUpdate(): void {\n const disabled = this.isDisabled;\n this.internals.ariaChecked = String(this.checked);\n this.internals.ariaDisabled = disabled ? \"true\" : null;\n this.internals.ariaReadOnly = this.groupReadOnly ? \"true\" : null;\n this.internals.ariaRequired = this.groupRequired ? \"true\" : null;\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n this.setData(\"disabled\", disabled);\n this.setData(\"readonly\", this.groupReadOnly);\n this.setData(\"required\", this.groupRequired);\n this.setState(\"checked\", this.checked);\n // The group decides the tab stop; a disabled item is never one.\n if (disabled) this.tabIndex = -1;\n else if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n override render() {\n if (!this.checked) return nothing;\n return html`<span data-pont2-radio-group-indicator data-slot=\"radio-group-indicator\" data-checked\n ><span data-pont2-radio-group-indicator-icon></span\n ></span>`;\n }\n}\n\ndefine(\"pont2-prim-radio-group\", RadioGroup);\ndefine(\"pont2-prim-radio-group-item\", RadioGroupItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-radio-group\": RadioGroup;\n \"pont2-prim-radio-group-item\": RadioGroupItem;\n }\n}\n","/**\n * Pure slider maths (no DOM), shared by <pont2-prim-slider> and unit-tested in node.\n * Mirrors Base UI's Slider value handling: values are clamped to [min, max],\n * snapped to `step` measured from `min`, and in a range slider a thumb can\n * neither cross nor come closer than `minStepsBetweenValues * step` to its\n * neighbours.\n */\n\nexport interface SliderRange {\n min: number;\n max: number;\n step: number;\n}\n\nexport const clamp = (v: number, min: number, max: number) => Math.min(max, Math.max(min, v));\n\n/** Decimal places of a number, so 0.1 + 0.2 snaps to 0.3 rather than 0.30000000000000004. */\nexport function decimals(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const s = String(n);\n if (s.includes(\"e-\")) return Number(s.split(\"e-\")[1]);\n const i = s.indexOf(\".\");\n return i < 0 ? 0 : s.length - i - 1;\n}\n\nexport function snap(value: number, { min, max, step }: SliderRange): number {\n if (!(step > 0)) return clamp(value, min, max);\n const snapped = Math.round((value - min) / step) * step + min;\n const d = Math.max(decimals(step), decimals(min));\n return clamp(Number(snapped.toFixed(d)), min, max);\n}\n\n/** 0..1 position of a value along the track. */\nexport function fraction(value: number, { min, max }: Pick<SliderRange, \"min\" | \"max\">): number {\n if (max <= min) return 0;\n return clamp((value - min) / (max - min), 0, 1);\n}\n\n/** Value at a 0..1 position along the track (before snapping). */\nexport function valueAt(f: number, { min, max }: Pick<SliderRange, \"min\" | \"max\">): number {\n return min + clamp(f, 0, 1) * (max - min);\n}\n\n/** Index of the thumb a pointer press at `value` should grab. Ties go to the later thumb when pressing above it. */\nexport function closestThumb(values: number[], value: number): number {\n let best = 0;\n let bestDist = Infinity;\n values.forEach((v, i) => {\n const d = Math.abs(v - value);\n if (d < bestDist || (d === bestDist && value > v)) {\n best = i;\n bestDist = d;\n }\n });\n return best;\n}\n\n/**\n * Sets thumb `index` to `value`, keeping the values ordered: the thumb is\n * clamped between its neighbours (Base UI's default \"none\" collision\n * behaviour), `minSteps` steps apart.\n */\nexport function setThumb(\n values: number[],\n index: number,\n value: number,\n range: SliderRange,\n minSteps = 0,\n): number[] {\n const gap = minSteps * range.step;\n const lo = index > 0 ? values[index - 1] + gap : range.min;\n const hi = index < values.length - 1 ? values[index + 1] - gap : range.max;\n const next = values.slice();\n next[index] = clamp(snap(value, range), lo, hi);\n return next;\n}\n\nexport type SliderKey = \"ArrowUp\" | \"ArrowDown\" | \"ArrowLeft\" | \"ArrowRight\" | \"PageUp\" | \"PageDown\" | \"Home\" | \"End\";\n\n/**\n * The value a key press moves a thumb to (APG slider pattern).\n * `rtl` flips Left/Right for horizontal sliders. Shift+Arrow moves by `largeStep`.\n */\nexport function keyValue(\n key: string,\n current: number,\n range: SliderRange & { largeStep: number },\n opts: { shift?: boolean; rtl?: boolean; vertical?: boolean } = {},\n): number | null {\n const small = opts.shift ? range.largeStep : range.step;\n const flip = opts.rtl && !opts.vertical ? -1 : 1;\n switch (key) {\n case \"ArrowUp\":\n return current + small;\n case \"ArrowDown\":\n return current - small;\n case \"ArrowRight\":\n return current + small * flip;\n case \"ArrowLeft\":\n return current - small * flip;\n case \"PageUp\":\n return current + range.largeStep;\n case \"PageDown\":\n return current - range.largeStep;\n case \"Home\":\n return range.min;\n case \"End\":\n return range.max;\n default:\n return null;\n }\n}\n\n/** Parses `value=\"25\"` or `value=\"25, 75\"` (the default value attribute). */\nexport function parseValues(attr: string | null | undefined, fallback: number): number[] {\n if (attr == null || attr.trim() === \"\") return [fallback];\n const out = attr\n .split(\",\")\n .map(s => Number(s.trim()))\n .filter(n => Number.isFinite(n));\n return out.length ? out.sort((a, b) => a - b) : [fallback];\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { directionOf } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement } from \"../../core/form-control\";\nimport { ensureId } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { closestThumb, fraction, keyValue, parseValues, setThumb, valueAt, type SliderRange } from \"./slider-math\";\n\nexport type SliderOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * # Slider: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Slider defaultValue min max>` → Base UI\n * ```\n * Slider.Root div[data-slot=slider][data-orientation]\n * Control div\n * Track div[data-slot=slider-track]\n * Indicator div[data-slot=slider-range]\n * Thumb ×n div[data-slot=slider-thumb] > input[type=range] (the input carries role=slider)\n * ```\n * pont2:\n * ```\n * pont2-prim-slider ← root, form-associated (submits name=value per thumb)\n * div[data-slot=slider-control]\n * div[data-slot=slider-track] > div[data-slot=slider-range]\n * div[data-slot=slider-thumb][role=slider] ×n\n * ```\n * The thumbs carry `role=\"slider\"` and the ARIA values themselves, so Base UI's\n * per-thumb hidden `<input type=\"range\">` is not needed (one node fewer per\n * thumb); the root is the form control. Everything inside the root is\n * rendered by the slider (shadcn's Slider takes no children either).\n *\n * Single value: `value=\"40\"`. Range: `value=\"20, 80\"` (one thumb per value).\n * With no value, one thumb at `min`. Thumbs never cross.\n *\n * Keyboard (APG / Base UI): ←/↓ −step, →/↑ +step (← and → swap in RTL),\n * Shift+arrow and PageUp/PageDown ±largeStep, Home/End min/max.\n * Pointer: press anywhere on the control moves the closest thumb, then drags.\n *\n * @tag pont2-prim-slider\n * @attr value - Default value(s), comma-separated for a range. `.value` / `.values` are live.\n * @attr min, max, step, large-step, min-steps-between-values\n * @attr orientation - horizontal (default) | vertical\n * @attr name, disabled, readonly\n * @fires input - While the value changes (keyboard or drag).\n * @fires change - When a change is committed (key press, pointer release). Base UI `onValueCommitted`.\n */\nexport class Slider extends FormControlElement {\n static override identity = \"slider\";\n static override slotName = \"slider\";\n\n static override properties: PropertyDeclarations = {\n defaultValue: { type: String, attribute: \"value\" },\n min: { type: Number },\n max: { type: Number },\n step: { type: Number },\n largeStep: { type: Number, attribute: \"large-step\" },\n minStepsBetweenValues: { type: Number, attribute: \"min-steps-between-values\" },\n orientation: { type: String, reflect: true },\n values: { attribute: false },\n activeThumb: { state: true },\n };\n\n declare defaultValue: string | null;\n declare min: number;\n declare max: number;\n declare step: number;\n declare largeStep: number;\n declare minStepsBetweenValues: number;\n declare orientation: SliderOrientation;\n /** Live values, ascending; one per thumb. */\n declare values: number[];\n declare protected activeThumb: number;\n\n private dirty = false;\n private dragging = -1;\n\n constructor() {\n super();\n this.defaultValue = null;\n this.min = 0;\n this.max = 100;\n this.step = 1;\n this.largeStep = 10;\n this.minStepsBetweenValues = 0;\n this.orientation = \"horizontal\";\n this.values = [0];\n this.activeThumb = -1;\n }\n\n /** A number for a single-thumb slider, an array for a range (Base UI's shape). */\n get value(): number | number[] {\n return this.values.length === 1 ? this.values[0] : this.values.slice();\n }\n set value(v: number | number[]) {\n this.dirty = true;\n const arr = Array.isArray(v) ? v.slice() : [v];\n this.values = arr.map(n => setThumb([n], 0, n, this.range)[0]).sort((a, b) => a - b);\n }\n\n private get range(): SliderRange {\n return { min: this.min, max: this.max, step: this.step };\n }\n\n protected override get hostFocusable(): boolean {\n return false;\n }\n\n protected override get validationAnchor(): HTMLElement | undefined {\n return this.thumbs[0];\n }\n\n private get thumbs(): HTMLElement[] {\n return Array.from(this.querySelectorAll<HTMLElement>(\":scope > [data-slot=slider-control] > [data-slot=slider-thumb]\"));\n }\n\n private get control(): HTMLElement | null {\n return this.querySelector(\":scope > [data-slot=slider-control]\");\n }\n\n /* -------------------------------------------------------------- */\n /* Form */\n /* -------------------------------------------------------------- */\n\n protected formValue() {\n if (!this.name) return null;\n if (this.values.length === 1) return String(this.values[0]);\n const fd = new FormData();\n for (const v of this.values) fd.append(this.name, String(v));\n return fd;\n }\n\n protected resetToDefault(): void {\n this.dirty = false;\n this.values = this.initialValues();\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state === \"string\") this.value = Number(state);\n else if (state instanceof FormData) this.value = state.getAll(this.name).map(Number);\n }\n\n private initialValues(): number[] {\n return parseValues(this.defaultValue, this.min).map(v => setThumb([v], 0, v, this.range)[0]);\n }\n\n /* -------------------------------------------------------------- */\n /* Interaction */\n /* -------------------------------------------------------------- */\n\n private commit(index: number, raw: number, final: boolean): void {\n const next = setThumb(this.values, index, raw, this.range, this.minStepsBetweenValues);\n const changed = next[index] !== this.values[index];\n if (changed) {\n this.dirty = true;\n this.values = next;\n fireNative(this, \"input\");\n }\n if (final && (changed || this.dragging >= 0)) fireNative(this, \"change\");\n }\n\n private onKeyDown = (e: KeyboardEvent, index: number) => {\n if (this.isDisabled || this.readOnly) return;\n const vertical = this.orientation === \"vertical\";\n const v = keyValue(e.key, this.values[index], { ...this.range, largeStep: this.largeStep }, {\n shift: e.shiftKey,\n rtl: directionOf(this) === \"rtl\",\n vertical,\n });\n if (v == null) return;\n e.preventDefault();\n this.commit(index, v, true);\n };\n\n private valueFromPointer(e: PointerEvent): number {\n const rect = this.control!.getBoundingClientRect();\n const thumb = this.thumbs[0]?.getBoundingClientRect();\n // thumbAlignment=\"edge\": thumbs travel within the control, inset by half a thumb at each end.\n if (this.orientation === \"vertical\") {\n const t = thumb?.height ?? 0;\n return valueAt(1 - (e.clientY - rect.top - t / 2) / Math.max(1, rect.height - t), this.range);\n }\n const t = thumb?.width ?? 0;\n let f = (e.clientX - rect.left - t / 2) / Math.max(1, rect.width - t);\n if (directionOf(this) === \"rtl\") f = 1 - f;\n return valueAt(f, this.range);\n }\n\n private onPointerDown = (e: PointerEvent) => {\n if (this.isDisabled || this.readOnly || e.button !== 0) return;\n const control = this.control!;\n const raw = this.valueFromPointer(e);\n const onThumb = (e.target as HTMLElement).closest?.(\"[data-slot=slider-thumb]\") as HTMLElement | null;\n const index = onThumb ? this.thumbs.indexOf(onThumb) : closestThumb(this.values, raw);\n this.dragging = index;\n this.activeThumb = index;\n control.setPointerCapture(e.pointerId);\n e.preventDefault();\n this.thumbs[index]?.focus({ preventScroll: true });\n if (!onThumb) this.commit(index, raw, false);\n };\n\n private onPointerMove = (e: PointerEvent) => {\n if (this.dragging < 0) return;\n this.commit(this.dragging, this.valueFromPointer(e), false);\n };\n\n private onPointerUp = (e: PointerEvent) => {\n if (this.dragging < 0) return;\n this.control?.releasePointerCapture(e.pointerId);\n this.commit(this.dragging, this.values[this.dragging], true);\n this.dragging = -1;\n this.activeThumb = -1;\n };\n\n /* -------------------------------------------------------------- */\n /* Render */\n /* -------------------------------------------------------------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n if (!this.dirty && (changed.has(\"defaultValue\") || changed.has(\"min\") || changed.has(\"max\") || !this.hasUpdated)) {\n this.values = this.initialValues();\n }\n this.setData(\"orientation\", this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\");\n this.setData(\"dragging\", this.dragging >= 0);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // Label the thumbs: <label for=\"slider-id\"> labels the root (it is form-associated);\n // the thumbs, which hold the focus, are labelled by the same elements.\n const labels = Array.from(this.labels) as HTMLElement[];\n const ids = labels.map(l => ensureId(l, \"slider-label\")).join(\" \");\n for (const t of this.thumbs) {\n if (ids) t.setAttribute(\"aria-labelledby\", ids);\n else t.removeAttribute(\"aria-labelledby\");\n }\n }\n\n override render() {\n const vertical = this.orientation === \"vertical\";\n const o = vertical ? \"vertical\" : \"horizontal\";\n const disabled = this.isDisabled;\n const fr = this.values.map(v => fraction(v, this.range));\n const thumbPos = (f: number) => `calc(${f} * (100% - var(--_pont2-slider-thumb)))`;\n const start = this.values.length > 1 ? fr[0] : 0;\n const end = fr[fr.length - 1];\n // Range: between thumb centres; single: from the start to the thumb centre.\n const rangeStyle = vertical\n ? { bottom: this.values.length > 1 ? `calc(${thumbPos(start)} + var(--_pont2-slider-thumb) / 2)` : \"0\", top: `calc(100% - ${thumbPos(end)} - var(--_pont2-slider-thumb) / 2)` }\n : { insetInlineStart: this.values.length > 1 ? `calc(${thumbPos(start)} + var(--_pont2-slider-thumb) / 2)` : \"0\", insetInlineEnd: `calc(100% - ${thumbPos(end)} - var(--_pont2-slider-thumb) / 2)` };\n const label = this.getAttribute(\"aria-label\");\n const names = this.values.length === 2 ? [\"Minimum\", \"Maximum\"] : [];\n\n return html`<div\n data-pont2-slider-control\n data-slot=\"slider-control\"\n data-orientation=${o}\n ?data-disabled=${disabled}\n @pointerdown=${this.onPointerDown}\n @pointermove=${this.onPointerMove}\n @pointerup=${this.onPointerUp}\n @pointercancel=${this.onPointerUp}\n >\n <div data-pont2-slider-track data-slot=\"slider-track\" data-orientation=${o} ?data-disabled=${disabled}>\n <div data-pont2-slider-range data-slot=\"slider-range\" data-orientation=${o} ?data-disabled=${disabled} style=${styleMap(rangeStyle)}></div>\n </div>\n ${repeat(\n this.values,\n (_v, i) => i,\n (v, i) => html`<div\n data-pont2-slider-thumb\n data-slot=\"slider-thumb\"\n data-index=${i}\n data-orientation=${o}\n ?data-disabled=${disabled}\n ?data-dragging=${this.activeThumb === i}\n role=\"slider\"\n tabindex=${disabled ? -1 : 0}\n aria-valuemin=${this.min}\n aria-valuemax=${this.max}\n aria-valuenow=${v}\n aria-orientation=${o}\n aria-disabled=${disabled ? \"true\" : \"false\"}\n aria-label=${label ? (names[i] ? `${label} ${names[i].toLowerCase()}` : label) : (names[i] ?? nothing)}\n style=${styleMap(vertical ? { bottom: thumbPos(fr[i]) } : { insetInlineStart: thumbPos(fr[i]) })}\n @keydown=${(e: KeyboardEvent) => this.onKeyDown(e, i)}\n ></div>`,\n )}\n </div>`;\n }\n}\n\ndefine(\"pont2-prim-slider\", Slider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-slider\": Slider;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { FormControlElement, type ValidityResult } from \"../../core/form-control\";\nimport { define } from \"../../core/names\";\n\nexport type SwitchSize = \"default\" | \"sm\";\n\n/**\n * # Switch: Tier 2 (widget, form-associated)\n *\n * shadcn: `<Switch size>` → Base UI `<Switch.Root>` (`<span role=\"switch\">`\n * plus a hidden `<input type=\"checkbox\">`) > `<Switch.Thumb>` (`<span>`).\n *\n * pont2: the host **is** the `role=\"switch\"` root and a form-associated\n * custom element (no hidden input); it renders only the thumb.\n *\n * ```\n * shadcn/Base UI: span[role=switch][data-slot=switch] > span[data-slot=switch-thumb] + input[hidden]\n * pont2: pont2-prim-switch > span[data-slot=switch-thumb]\n * ```\n *\n * State attributes (Base UI): `data-checked` | `data-unchecked`, `data-disabled`,\n * `data-readonly`, `data-required`, on the root and the thumb. `data-size`\n * is shadcn's.\n *\n * @tag pont2-prim-switch\n * @attr checked - Initial state (`defaultChecked`); `.checked` is the live state.\n * @attr size - default | sm\n * @attr name, value, unchecked-value, disabled, required, readonly\n * @fires input - The state changed through interaction.\n * @fires change - Same moment as `input`, like a native checkbox.\n */\nexport class Switch extends FormControlElement {\n static override identity = \"switch\";\n static override slotName = \"switch\";\n static override role = \"switch\";\n\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean },\n size: { type: String, reflect: true },\n value: { type: String },\n uncheckedValue: { type: String, attribute: \"unchecked-value\" },\n };\n\n declare checked: boolean;\n declare size: SwitchSize;\n declare value: string;\n declare uncheckedValue: string | undefined;\n\n constructor() {\n super();\n this.checked = false;\n this.size = \"default\";\n this.value = \"on\";\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"keyup\", this.onKeyUp);\n }\n\n /** Toggle as if the user clicked (fires input/change). */\n toggle(): void {\n if (this.isDisabled || this.readOnly) return;\n this.checked = !this.checked;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected formValue() {\n return this.checked ? this.value : (this.uncheckedValue ?? null);\n }\n\n protected resetToDefault(): void {\n this.checked = this.hasAttribute(\"checked\");\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n this.checked = state === this.value;\n }\n\n protected override validate(): ValidityResult | null {\n return this.required && !this.checked\n ? { flags: { valueMissing: true }, message: \"Please turn this on if you want to proceed.\" }\n : null;\n }\n\n private onClick = (e: MouseEvent) => {\n if (this.isDisabled || this.readOnly) {\n e.preventDefault();\n return;\n }\n this.toggle();\n };\n\n // Base UI's switch behaves like a button: Enter activates on keydown, Space on keyup.\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this) return;\n if (e.key === \" \") e.preventDefault();\n if (e.key === \"Enter\") {\n e.preventDefault();\n this.click();\n }\n };\n private onKeyUp = (e: KeyboardEvent) => {\n if (e.key === \" \" && e.target === this) this.click();\n };\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n this.setData(\"size\", this.size === \"sm\" ? \"sm\" : \"default\");\n this.setState(\"checked\", this.checked);\n }\n\n override render() {\n return html`<span\n data-pont2-switch-thumb\n data-slot=\"switch-thumb\"\n ?data-checked=${this.checked}\n ?data-unchecked=${!this.checked}\n ?data-disabled=${this.isDisabled}\n ></span>`;\n }\n}\n\ndefine(\"pont2-prim-switch\", Switch);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-switch\": Switch;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { RovingFocusController, type Orientation } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\n\nexport type TabsOrientation = \"horizontal\" | \"vertical\";\nexport type TabsListVariant = \"default\" | \"line\";\ntype ActivationDirection = \"left\" | \"right\" | \"up\" | \"down\" | \"none\";\n\nconst ROOT = sel(\"tabs\");\nconst TRIGGER = sel(\"tabs-trigger\");\nconst PANEL = sel(\"tabs-content\");\n\n/**\n * Wires an IDREF relation through ElementInternals when the engine supports\n * element reflection there, so no author-facing attribute is written; falls\n * back to the plain attribute (with generated ids) otherwise.\n */\nfunction relate(internals: ElementInternals, host: HTMLElement, prop: \"ariaControlsElements\" | \"ariaLabelledByElements\", attr: string, targets: Element[]) {\n if (prop in ElementInternals.prototype) {\n (internals as unknown as Record<string, Element[] | null>)[prop] = targets.length ? targets : null;\n } else if (targets.length) {\n host.setAttribute(attr, targets.map(t => ensureId(t, \"tabs\")).join(\" \"));\n } else {\n host.removeAttribute(attr);\n }\n}\n\n/**\n * # Tabs, TabsList, TabsTrigger, TabsContent: Tier 2 (widgets)\n *\n * shadcn: `<Tabs>` → Base UI `<Tabs.Root>` (div) > `<Tabs.List>` (div[role=tablist])\n * > `<Tabs.Tab>` (button[role=tab]) …, and `<Tabs.Panel>` (div[role=tabpanel]).\n *\n * pont2: every part is host-as-root, written by the author and never moved:\n * ```\n * pont2-prim-tabs[data-orientation]\n * pont2-prim-tabs-list[role=tablist][data-variant]\n * pont2-prim-tabs-trigger[role=tab][value] ×n (data-active on the active one)\n * pont2-prim-tabs-content[role=tabpanel][value] ×n (hidden unless active)\n * ```\n * The root owns the value; triggers and panels are matched by `value`.\n * ARIA relations (`aria-controls`, `aria-labelledby`) are wired through\n * ElementInternals, so the author's markup is not rewritten.\n *\n * Keyboard (Base UI / APG): the list is one tab stop (roving tabindex);\n * arrows along the orientation move focus (wrapping), Home/End jump, and\n * Enter/Space activate. With `activate-on-focus` on the list, moving focus\n * also activates (Base UI default: off).\n *\n * @tag pont2-prim-tabs\n * @attr value - The default active tab value; `.value` is live. Defaults to the first enabled trigger.\n * @attr orientation - horizontal (default) | vertical\n * @fires input, change - The active tab changed through interaction.\n */\nexport class Tabs extends HostElement {\n static override identity = \"tabs\";\n static override slotName = \"tabs\";\n\n static override properties: PropertyDeclarations = {\n defaultValue: { type: String, attribute: \"value\" },\n orientation: { type: String, reflect: true },\n current: { state: true },\n };\n\n declare defaultValue: string | null;\n declare orientation: TabsOrientation;\n declare protected current: string;\n\n /** The active tab's value. Setting it activates that tab without firing events. */\n get value(): string {\n return this.current;\n }\n set value(v: string) {\n this.dirty = true;\n this.current = v;\n }\n\n private dirty = false;\n private direction: ActivationDirection = \"none\";\n private observer?: MutationObserver;\n\n constructor() {\n super();\n this.defaultValue = null;\n this.orientation = \"horizontal\";\n this.current = \"\";\n }\n\n get triggers(): TabsTrigger[] {\n return this.own<TabsTrigger>(TRIGGER);\n }\n get panels(): TabsContent[] {\n return this.own<TabsContent>(PANEL);\n }\n get lists(): TabsList[] {\n return this.own<TabsList>(sel(\"tabs-list\"));\n }\n\n private own<T extends Element>(sel: string): T[] {\n return Array.from(this.querySelectorAll<T>(sel)).filter(el => el.closest(ROOT) === this);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.observer ??= new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: [\"value\", \"disabled\"] });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n /** Activate a trigger as the user would (fires input/change). */\n select(trigger: TabsTrigger): void {\n if (trigger.disabled || trigger.value === this.value) return;\n const triggers = this.triggers;\n const from = triggers.findIndex(t => t.value === this.value);\n const to = triggers.indexOf(trigger);\n const vertical = this.orientation === \"vertical\";\n this.direction = from < 0 || to === from ? \"none\" : to > from ? (vertical ? \"down\" : \"right\") : vertical ? \"up\" : \"left\";\n this.value = trigger.value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) {\n this.current = this.defaultValue ?? \"\";\n }\n }\n\n protected override updated(): void {\n const o = this.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n const triggers = this.triggers;\n const panels = this.panels;\n // No (matching) value: fall back to the first enabled trigger, like Base UI.\n let value = this.current;\n if (!triggers.some(t => t.getAttribute(\"value\") === value)) {\n value = triggers.find(t => !t.hasAttribute(\"disabled\"))?.getAttribute(\"value\") ?? \"\";\n }\n\n this.setData(\"orientation\", o);\n this.setData(\"activation-direction\", this.direction);\n // Parts that have not upgraded yet are skipped; they request an update on connect.\n const ready = (el: Element) => typeof (el as TabsTrigger).sync === \"function\";\n for (const list of this.lists) if (ready(list)) list.sync(o, this.direction);\n\n let active: TabsTrigger | null = null;\n for (const t of triggers) {\n const on = t.getAttribute(\"value\") === value;\n const panel = panels.find(p => p.getAttribute(\"value\") === t.getAttribute(\"value\")) ?? null;\n if (ready(t)) t.sync(on, o, panel);\n if (on) active = t;\n }\n for (const p of panels) {\n const trigger = triggers.find(t => t.getAttribute(\"value\") === p.getAttribute(\"value\")) ?? null;\n if (ready(p)) p.sync(p.getAttribute(\"value\") === value, o, trigger);\n }\n for (const list of this.lists) if (ready(list)) list.focusSync(active);\n }\n}\n\n/**\n * @tag pont2-prim-tabs-list\n * @attr variant - default | line\n * @attr activate-on-focus - Arrow-key focus also activates the tab (Base UI `activateOnFocus`).\n * @attr loop - Set `loop=\"false\"` to stop focus wrapping (Base UI `loopFocus`).\n */\nexport class TabsList extends HostElement {\n static override identity = \"tabs-list\";\n static override slotName = \"tabs-list\";\n static override role = \"tablist\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n activateOnFocus: { type: Boolean, attribute: \"activate-on-focus\" },\n loop: { type: String },\n };\n\n declare variant: TabsListVariant;\n declare activateOnFocus: boolean;\n declare loop: string | null;\n\n private orientation: Orientation = \"horizontal\";\n\n private roving = new RovingFocusController(this, {\n items: () => this.root?.triggers.filter(t => this.contains(t)) ?? [],\n orientation: () => this.orientation,\n loop: () => this.loop !== \"false\",\n onNavigate: item => {\n if (this.activateOnFocus) this.root?.select(item as TabsTrigger);\n },\n });\n\n constructor() {\n super();\n this.variant = \"default\";\n this.activateOnFocus = false;\n this.loop = null;\n }\n\n get root(): Tabs | null {\n return this.closest(ROOT) as Tabs | null;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.root?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(orientation: TabsOrientation, direction: ActivationDirection): void {\n this.orientation = orientation;\n this.internals.ariaOrientation = orientation;\n this.setData(\"orientation\", orientation);\n this.setData(\"activation-direction\", direction);\n }\n\n /** @internal Called by the root. */\n focusSync(active: HTMLElement | null): void {\n // Keep the roving stop on the focused tab while the user is navigating.\n const focused = this.root?.triggers.find(t => t === document.activeElement);\n this.roving.sync(focused ?? active);\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant === \"line\" ? \"line\" : \"default\");\n }\n}\n\n/**\n * @tag pont2-prim-tabs-trigger\n * @attr value - Identifies the tab and its panel.\n * @attr disabled\n */\nexport class TabsTrigger extends HostElement {\n static override identity = \"tabs-trigger\";\n static override slotName = \"tabs-trigger\";\n static override role = \"tab\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"click\", this.onClick);\n this.addEventListener(\"keydown\", this.onKeyDown);\n }\n\n get root(): Tabs | null {\n return this.closest(ROOT) as Tabs | null;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.root?.requestUpdate();\n }\n\n private onClick = () => {\n if (!this.disabled) this.root?.select(this);\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== this || this.disabled) return;\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n this.root?.select(this);\n }\n };\n\n /** @internal Called by the root. */\n sync(active: boolean, orientation: TabsOrientation, panel: Element | null): void {\n this.internals.ariaSelected = String(active);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n relate(this.internals, this, \"ariaControlsElements\", \"aria-controls\", panel ? [panel] : []);\n this.setData(\"active\", active);\n this.setData(\"disabled\", this.disabled);\n this.setData(\"orientation\", orientation);\n this.setState(\"active\", active);\n }\n}\n\n/**\n * @tag pont2-prim-tabs-content\n * @attr value - The trigger value this panel belongs to.\n */\nexport class TabsContent extends HostElement {\n static override identity = \"tabs-content\";\n static override slotName = \"tabs-content\";\n static override role = \"tabpanel\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n };\n\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n (this.closest(ROOT) as Tabs | null)?.requestUpdate();\n }\n\n /** @internal Called by the root. */\n sync(active: boolean, orientation: TabsOrientation, trigger: Element | null): void {\n relate(this.internals, this, \"ariaLabelledByElements\", \"aria-labelledby\", trigger ? [trigger] : []);\n // Base UI unmounts inactive panels; pont2 never removes author children, so it hides them.\n this.hidden = !active;\n this.setData(\"hidden\", !active);\n this.setData(\"orientation\", orientation);\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = 0;\n }\n}\n\ndefine(\"pont2-prim-tabs\", Tabs);\ndefine(\"pont2-prim-tabs-list\", TabsList);\ndefine(\"pont2-prim-tabs-trigger\", TabsTrigger);\ndefine(\"pont2-prim-tabs-content\", TabsContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-tabs\": Tabs;\n \"pont2-prim-tabs-list\": TabsList;\n \"pont2-prim-tabs-trigger\": TabsTrigger;\n \"pont2-prim-tabs-content\": TabsContent;\n }\n}\n","/**\n * Pure anchored-positioning maths (no DOM). The same model as Floating UI /\n * Base UI's `<Positioner>`: place the floating box on a `side` of the anchor,\n * `align` it along that side, then `flip` to the opposite side and `shift`\n * along the cross axis to stay inside the viewport minus `collisionPadding`.\n *\n * Unit-tested in node: position.test.ts.\n */\n\nexport type PhysicalSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/** Base UI sides: physical, or logical (`inline-start`/`inline-end` follow `dir`). */\nexport type Side = PhysicalSide | \"inline-start\" | \"inline-end\";\nexport type Align = \"start\" | \"center\" | \"end\";\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface PositionInput {\n anchor: Rect;\n floating: Size;\n viewport: Rect;\n side?: Side;\n align?: Align;\n /** Gap between anchor and floating box, on the main axis (px). */\n sideOffset?: number;\n /** Offset along the cross axis (px). Positive moves towards `end` for start/center, towards `start` for end. */\n alignOffset?: number;\n /** Minimum distance kept from the viewport edges (px). Base UI default: 5. */\n collisionPadding?: number;\n flip?: boolean;\n shift?: boolean;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport interface PositionResult {\n x: number;\n y: number;\n /** The side actually used, in the vocabulary it was requested in (logical stays logical). */\n side: Side;\n physicalSide: PhysicalSide;\n align: Align;\n /** Space between the floating box's anchored edge and the viewport edge (Base UI `--available-*`). */\n availableWidth: number;\n availableHeight: number;\n /** `--transform-origin`: the point of the anchor the box grows from. */\n transformOrigin: string;\n}\n\nconst OPPOSITE: Record<PhysicalSide, PhysicalSide> = { top: \"bottom\", bottom: \"top\", left: \"right\", right: \"left\" };\n\nexport function toPhysical(side: Side, dir: \"ltr\" | \"rtl\"): PhysicalSide {\n if (side === \"inline-start\") return dir === \"rtl\" ? \"right\" : \"left\";\n if (side === \"inline-end\") return dir === \"rtl\" ? \"left\" : \"right\";\n return side;\n}\n\nfunction toRequestedVocabulary(physical: PhysicalSide, requested: Side, dir: \"ltr\" | \"rtl\"): Side {\n if (requested !== \"inline-start\" && requested !== \"inline-end\") return physical;\n const start = dir === \"rtl\" ? \"right\" : \"left\";\n return physical === start ? \"inline-start\" : \"inline-end\";\n}\n\nconst isVertical = (s: PhysicalSide) => s === \"top\" || s === \"bottom\";\n\n/** Free space between the anchor (plus offset) and the padded viewport edge on `side`. */\nexport function spaceOn(side: PhysicalSide, anchor: Rect, viewport: Rect, offset: number, pad: number): number {\n switch (side) {\n case \"bottom\":\n return viewport.y + viewport.height - pad - (anchor.y + anchor.height + offset);\n case \"top\":\n return anchor.y - offset - (viewport.y + pad);\n case \"right\":\n return viewport.x + viewport.width - pad - (anchor.x + anchor.width + offset);\n case \"left\":\n return anchor.x - offset - (viewport.x + pad);\n }\n}\n\nexport function computePosition(input: PositionInput): PositionResult {\n const {\n anchor,\n floating,\n viewport,\n side: requested = \"bottom\",\n align = \"center\",\n sideOffset = 0,\n alignOffset = 0,\n collisionPadding = 5,\n flip = true,\n shift = true,\n dir = \"ltr\",\n } = input;\n const pad = collisionPadding;\n\n let side = toPhysical(requested, dir);\n\n // --- flip ------------------------------------------------------------\n if (flip) {\n const need = isVertical(side) ? floating.height : floating.width;\n const here = spaceOn(side, anchor, viewport, sideOffset, pad);\n const there = spaceOn(OPPOSITE[side], anchor, viewport, sideOffset, pad);\n if (here < need && there > here) side = OPPOSITE[side];\n }\n\n // --- main axis -------------------------------------------------------\n let x = 0;\n let y = 0;\n switch (side) {\n case \"bottom\":\n y = anchor.y + anchor.height + sideOffset;\n break;\n case \"top\":\n y = anchor.y - floating.height - sideOffset;\n break;\n case \"right\":\n x = anchor.x + anchor.width + sideOffset;\n break;\n case \"left\":\n x = anchor.x - floating.width - sideOffset;\n break;\n }\n\n // --- cross axis (align) ---------------------------------------------\n if (isVertical(side)) {\n // `start` is the inline-start edge, so it mirrors in RTL.\n const startEdge = dir === \"rtl\" ? anchor.x + anchor.width - floating.width : anchor.x;\n const endEdge = dir === \"rtl\" ? anchor.x : anchor.x + anchor.width - floating.width;\n const sign = dir === \"rtl\" ? -1 : 1;\n if (align === \"start\") x = startEdge + sign * alignOffset;\n else if (align === \"end\") x = endEdge - sign * alignOffset;\n else x = anchor.x + (anchor.width - floating.width) / 2 + sign * alignOffset;\n } else {\n if (align === \"start\") y = anchor.y + alignOffset;\n else if (align === \"end\") y = anchor.y + anchor.height - floating.height - alignOffset;\n else y = anchor.y + (anchor.height - floating.height) / 2 + alignOffset;\n }\n\n // --- shift (keep inside the padded viewport on the cross axis) -------\n if (shift) {\n if (isVertical(side)) {\n const min = viewport.x + pad;\n const max = viewport.x + viewport.width - pad - floating.width;\n x = max < min ? min : Math.min(Math.max(x, min), max);\n } else {\n const min = viewport.y + pad;\n const max = viewport.y + viewport.height - pad - floating.height;\n y = max < min ? min : Math.min(Math.max(y, min), max);\n }\n }\n\n // --- available space (Base UI --available-width / --available-height) -\n const mainSpace = Math.max(0, spaceOn(side, anchor, viewport, sideOffset, pad));\n const availableHeight = isVertical(side) ? mainSpace : Math.max(0, viewport.height - 2 * pad);\n const availableWidth = isVertical(side) ? Math.max(0, viewport.width - 2 * pad) : mainSpace;\n\n // --- transform origin: the anchor edge the box grows out of -----------\n const ax = anchor.x + anchor.width / 2 - x;\n const ay = anchor.y + anchor.height / 2 - y;\n const transformOrigin =\n side === \"bottom\"\n ? `${round(ax)}px ${-sideOffset}px`\n : side === \"top\"\n ? `${round(ax)}px ${floating.height + sideOffset}px`\n : side === \"right\"\n ? `${-sideOffset}px ${round(ay)}px`\n : `${floating.width + sideOffset}px ${round(ay)}px`;\n\n return {\n x: round(x),\n y: round(y),\n side: toRequestedVocabulary(side, requested, dir),\n physicalSide: side,\n align,\n availableWidth: round(availableWidth),\n availableHeight: round(availableHeight),\n transformOrigin,\n };\n}\n\n/**\n * Base UI Select's `alignItemWithTrigger`: place the popup so the selected\n * item sits exactly over the trigger (macOS-style). Returns `null` when that\n * is impossible inside the padded viewport, so the caller falls back to\n * normal side positioning (Base UI does the same).\n */\nexport function alignItemWithAnchor(input: {\n anchor: Rect;\n floating: Size;\n viewport: Rect;\n /** Offset of the item's top edge from the floating box's top edge (scroll already subtracted). */\n itemTop: number;\n itemHeight: number;\n collisionPadding?: number;\n}): { x: number; y: number } | null {\n const pad = input.collisionPadding ?? 5;\n const { anchor, floating, viewport } = input;\n const y = anchor.y + anchor.height / 2 - (input.itemTop + input.itemHeight / 2);\n const min = viewport.y + pad;\n const max = viewport.y + viewport.height - pad - floating.height;\n if (max < min) return null;\n if (y < min || y > max) return null;\n return { x: round(anchor.x), y: round(y) };\n}\n\nconst round = (n: number) => Math.round(n * 100) / 100;\n","import { directionOf } from \"../controllers/roving-focus\";\nimport { alignItemWithAnchor, computePosition, type Align, type Rect, type Side } from \"./position\";\n\nexport interface AnchoredOptions {\n side: Side;\n align: Align;\n sideOffset: number;\n alignOffset: number;\n collisionPadding: number;\n /** Select's `alignItemWithTrigger`: the item to lay over the anchor, if any. */\n alignItem?: HTMLElement | null;\n}\n\n/**\n * Keeps a floating element (a `popover` in the top layer, so `position:\n * fixed` against the viewport) attached to an anchor element.\n *\n * It only *writes CSS custom properties and data attributes* on the floating\n * element; the stylesheet turns them into `left`/`top`. Base UI's variables\n * are written under pont2's namespace (read by pont2 CSS) and also verbatim,\n * so shadcn classes (`max-h-(--available-height)`, `w-(--anchor-width)`,\n * `origin-(--transform-origin)`) port unchanged into app CSS:\n *\n * | Written | Meaning |\n * |-------------------------|--------------------------------------------|\n * | `--pont2-popup-x/y` | viewport position of the box (px) |\n * | `--pont2-anchor-width/height` (+ `--anchor-*`) | size of the anchor |\n * | `--pont2-available-width/height` (+ `--available-*`) | room left before the collision padding |\n * | `--pont2-transform-origin` (+ `--transform-origin`) | the anchor point the box grows from |\n * | `--pont2-arrow-x/y` | anchor centre relative to the box (for arrows) |\n * | `data-side`, `data-align` | the side/alignment actually used (after flip) |\n *\n * Updates are batched to one per animation frame and re-run on scroll (any\n * ancestor, captured), resize, and size changes of either element.\n */\nexport class AnchoredPositioner {\n private frame = 0;\n private running = false;\n private ro?: ResizeObserver;\n private observedAnchor: Element | null = null;\n\n constructor(\n private readonly floating: HTMLElement,\n private readonly anchor: () => Element | null,\n private readonly options: () => AnchoredOptions,\n ) {}\n\n start(): void {\n if (this.running) {\n this.update();\n return;\n }\n this.running = true;\n window.addEventListener(\"scroll\", this.schedule, { capture: true, passive: true });\n window.addEventListener(\"resize\", this.schedule, { passive: true });\n this.ro = new ResizeObserver(this.schedule);\n this.ro.observe(this.floating);\n this.observeAnchor();\n this.update();\n }\n\n stop(): void {\n if (!this.running) return;\n this.running = false;\n cancelAnimationFrame(this.frame);\n window.removeEventListener(\"scroll\", this.schedule, { capture: true });\n window.removeEventListener(\"resize\", this.schedule);\n this.ro?.disconnect();\n this.observedAnchor = null;\n }\n\n private observeAnchor() {\n const a = this.anchor();\n if (a && a !== this.observedAnchor) {\n this.ro?.observe(a);\n this.observedAnchor = a;\n }\n }\n\n private schedule = () => {\n if (!this.running) return;\n cancelAnimationFrame(this.frame);\n this.frame = requestAnimationFrame(() => this.update());\n };\n\n /** Measure and write synchronously (also called right after showPopover, before first paint). */\n update(): void {\n const anchorEl = this.anchor();\n if (!anchorEl || !this.floating.isConnected) return;\n this.observeAnchor();\n\n const a = anchorEl.getBoundingClientRect();\n const anchor: Rect = { x: a.left, y: a.top, width: a.width, height: a.height };\n // offsetWidth/Height ignore transforms, so a running zoom-in animation\n // does not feed back into the measurement.\n const floating = { width: this.floating.offsetWidth, height: this.floating.offsetHeight };\n const viewport: Rect = {\n x: 0,\n y: 0,\n width: document.documentElement.clientWidth,\n height: window.innerHeight,\n };\n const o = this.options();\n const style = this.floating.style;\n // Each Base UI variable is written twice: `--pont2-<name>` (what pont2's\n // own CSS reads, per the --pont2- namespace rule) and Base UI's verbatim\n // `--<name>`, so shadcn classes such as `max-h-(--available-height)` port\n // unchanged into consumer CSS.\n const set = (name: string, value: string) => {\n style.setProperty(`--pont2-${name}`, value);\n style.setProperty(`--${name}`, value);\n };\n set(\"anchor-width\", `${a.width}px`);\n set(\"anchor-height\", `${a.height}px`);\n\n if (o.alignItem) {\n const f = this.floating.getBoundingClientRect();\n const it = o.alignItem.getBoundingClientRect();\n const aligned = alignItemWithAnchor({\n anchor,\n floating,\n viewport,\n itemTop: it.top - f.top,\n itemHeight: it.height,\n collisionPadding: o.collisionPadding,\n });\n if (aligned) {\n style.setProperty(\"--pont2-popup-x\", `${aligned.x}px`);\n style.setProperty(\"--pont2-popup-y\", `${aligned.y}px`);\n set(\"available-height\", `${viewport.height - 2 * o.collisionPadding}px`);\n set(\"available-width\", `${viewport.width - 2 * o.collisionPadding}px`);\n set(\"transform-origin\", \"center\");\n this.floating.setAttribute(\"data-side\", \"none\");\n this.floating.setAttribute(\"data-align\", \"center\");\n return;\n }\n }\n\n const r = computePosition({\n anchor,\n floating,\n viewport,\n side: o.side,\n align: o.align,\n sideOffset: o.sideOffset,\n alignOffset: o.alignOffset,\n collisionPadding: o.collisionPadding,\n dir: directionOf(anchorEl),\n });\n style.setProperty(\"--pont2-popup-x\", `${r.x}px`);\n style.setProperty(\"--pont2-popup-y\", `${r.y}px`);\n set(\"available-width\", `${r.availableWidth}px`);\n set(\"available-height\", `${r.availableHeight}px`);\n set(\"transform-origin\", r.transformOrigin);\n style.setProperty(\"--pont2-arrow-x\", `${a.left + a.width / 2 - r.x}px`);\n style.setProperty(\"--pont2-arrow-y\", `${a.top + a.height / 2 - r.y}px`);\n if (this.floating.getAttribute(\"data-side\") !== r.side) this.floating.setAttribute(\"data-side\", r.side);\n if (this.floating.getAttribute(\"data-align\") !== r.align) this.floating.setAttribute(\"data-align\", r.align);\n }\n}\n","/**\n * List navigation and typeahead for popup lists (menus, select, combobox).\n *\n * Two focus models, as in Base UI:\n * - **real focus** (Menu, Select): the highlighted item *is* `document.activeElement`;\n * items carry `tabindex=\"-1\"` and `data-highlighted` follows focus;\n * - **virtual focus** (Combobox): focus stays in the `<input>`; the highlighted\n * item gets `data-highlighted` and the input points at it with\n * `aria-activedescendant`.\n *\n * Both share `moveIndex()` and `Typeahead`.\n */\n\nexport const isItemDisabled = (el: Element) =>\n el.hasAttribute(\"data-disabled\") || el.getAttribute(\"aria-disabled\") === \"true\";\n\nexport const isItemVisible = (el: HTMLElement) => !el.hidden && !el.closest(\"[hidden]\");\n\nexport type Move = \"next\" | \"prev\" | \"first\" | \"last\";\n\n/** Index of the next enabled item in `direction` from `current` (−1 = none yet). */\nexport function moveIndex(\n items: readonly Element[],\n current: number,\n move: Move,\n { loop = true, isDisabled = isItemDisabled }: { loop?: boolean; isDisabled?: (el: Element) => boolean } = {},\n): number {\n const n = items.length;\n if (!n) return -1;\n const ok = (i: number) => !isDisabled(items[i]);\n if (move === \"first\") {\n for (let i = 0; i < n; i++) if (ok(i)) return i;\n return -1;\n }\n if (move === \"last\") {\n for (let i = n - 1; i >= 0; i--) if (ok(i)) return i;\n return -1;\n }\n const step = move === \"next\" ? 1 : -1;\n if (current < 0) return moveIndex(items, -1, step === 1 ? \"first\" : \"last\", { loop, isDisabled });\n for (let k = 1; k <= n; k++) {\n let i = current + step * k;\n if (loop) i = (i + n) % n;\n else if (i < 0 || i >= n) return current;\n if (ok(i)) return i;\n }\n return current;\n}\n\n/** Keyboard key → move, for a vertical list. */\nexport function keyToMove(key: string): Move | null {\n switch (key) {\n case \"ArrowDown\":\n return \"next\";\n case \"ArrowUp\":\n return \"prev\";\n case \"Home\":\n return \"first\";\n case \"End\":\n return \"last\";\n default:\n return null;\n }\n}\n\n/**\n * Typeahead (APG): printable keys typed within 500ms build a prefix; the\n * first enabled item after the current one whose label starts with it wins.\n * Repeating one character cycles through items starting with it.\n */\nexport class Typeahead {\n private buffer = \"\";\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(private readonly timeout = 500) {}\n\n /** Whether a keyboard event is a typeahead character. */\n static isChar(e: KeyboardEvent): boolean {\n return e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && e.key !== \" \";\n }\n\n get active(): boolean {\n return this.buffer.length > 0;\n }\n\n match(\n key: string,\n items: readonly Element[],\n current: number,\n label: (el: Element) => string = el => el.textContent ?? \"\",\n ): number {\n clearTimeout(this.timer);\n this.timer = setTimeout(() => (this.buffer = \"\"), this.timeout);\n this.buffer += key.toLowerCase();\n\n const repeated = this.buffer.split(\"\").every(c => c === this.buffer[0]);\n const search = repeated ? this.buffer[0] : this.buffer;\n const n = items.length;\n const start = repeated || current < 0 ? current + 1 : current;\n for (let k = 0; k < n; k++) {\n const i = (start + k + n) % n;\n const el = items[i];\n if (isItemDisabled(el)) continue;\n if (label(el).trim().toLowerCase().startsWith(search)) return i;\n }\n return -1;\n }\n\n reset(): void {\n clearTimeout(this.timer);\n this.buffer = \"\";\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport type { OpenChangeReason } from \"../events\";\nimport { HostElement } from \"../host-element\";\nimport { AnchoredPositioner } from \"./anchored\";\nimport type { Align, Side } from \"./position\";\n\n/** Popups currently open, bottom → top. Escape and outside presses are resolved against it. */\nconst stack: PopupContent[] = [];\n\nlet globalListeners = false;\nfunction installGlobalListeners() {\n if (globalListeners) return;\n globalListeners = true;\n\n // Escape closes only the top-most popup (a submenu before its menu).\n document.addEventListener(\"keydown\", e => {\n if (e.key !== \"Escape\" || e.defaultPrevented) return;\n const top = stack.at(-1);\n if (!top) return;\n e.preventDefault();\n e.stopPropagation();\n top.requestClose(\"escape-key\");\n });\n\n // Outside press: captured on pointerdown, before focus moves (Base UI\n // dismisses on pointerdown for mouse too).\n document.addEventListener(\n \"pointerdown\",\n e => {\n const path = e.composedPath();\n for (const popup of [...stack].reverse()) {\n if (popup.containsPath(path)) break; // inside: this one and everything below stay\n popup.requestClose(\"outside-press\");\n }\n },\n true,\n );\n}\n\n/**\n * # PopupContent: base for every popup surface\n *\n * DropdownMenuContent, SelectContent, ComboboxContent, PopoverContent and\n * TooltipContent all extend it. The host **is** the popup (shadcn's\n * `data-slot=\"…-content\"` element); Base UI's separate `Portal` and\n * `Positioner` wrappers have no counterpart, because:\n *\n * - **Portal → the native Popover API.** The host carries `popover=\"manual\"`\n * and `showPopover()` lifts it into the browser's top layer: it escapes\n * `overflow: hidden` and stacking contexts *without moving the node*. It\n * stays exactly where the author wrote it, so React/Lit/server HTML keep\n * owning it, and it inherits CSS custom properties from its real ancestors.\n * - **Positioner → AnchoredPositioner**, which writes position variables on\n * this same element (see anchored.ts).\n *\n * Base UI DOM: Portal > Positioner div > Popup div[data-slot=…-content] > children\n * pont2 DOM: pont2-…-content[popover][data-slot=…-content] > children\n *\n * Open/close states are Base UI's: `data-open` / `data-closed`, plus\n * `data-starting-style` (first frame after opening) and `data-ending-style`\n * (while closing). On close the element stays in the top layer until its\n * CSS animations/transitions finish, then `hidePopover()` runs, so shadcn's\n * `animate-out` classes port as plain keyframes.\n *\n * The content never decides it is open; its root does. It *requests*\n * closing (Escape, outside press, Tab) through `onRequestClose`, which the\n * root turns into a cancelable `pont2-open-change` event.\n */\nexport abstract class PopupContent extends HostElement {\n static override identity = \"popup\";\n\n static override properties: PropertyDeclarations = {\n side: { type: String, reflect: false },\n align: { type: String, reflect: false },\n sideOffset: { type: Number, attribute: \"side-offset\" },\n alignOffset: { type: Number, attribute: \"align-offset\" },\n collisionPadding: { type: Number, attribute: \"collision-padding\" },\n };\n\n declare side: Side;\n declare align: Align;\n declare sideOffset: number;\n declare alignOffset: number;\n declare collisionPadding: number;\n\n /** Set by the root: asked to close for `reason`. */\n onRequestClose?: (reason: OpenChangeReason) => void;\n /** Set by the root: elements that do not count as \"outside\" (the trigger). */\n insideElements: () => (Element | null | undefined)[] = () => [];\n /** Set by the root: what the popup is anchored to. */\n anchorElement: () => Element | null = () => null;\n\n protected readonly positioner = new AnchoredPositioner(\n this,\n () => this.anchorElement(),\n () => ({\n side: this.side,\n align: this.align,\n sideOffset: this.sideOffset,\n alignOffset: this.alignOffset,\n collisionPadding: this.collisionPadding,\n alignItem: this.alignItem(),\n }),\n );\n\n private closing?: Promise<void>;\n private generation = 0;\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 0;\n this.alignOffset = 0;\n this.collisionPadding = 5;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n installGlobalListeners();\n if (!this.hasAttribute(\"popover\")) this.setAttribute(\"popover\", \"manual\");\n if (!this.isOpen) this.setData(\"closed\", true);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.positioner.stop();\n const i = stack.indexOf(this);\n if (i >= 0) stack.splice(i, 1);\n }\n\n get isOpen(): boolean {\n return this.hasAttribute(\"data-open\");\n }\n\n /** Select overrides this to lay the selected item over the trigger. */\n protected alignItem(): HTMLElement | null {\n return null;\n }\n\n /** True if the event path is inside this popup or one of its inside elements. */\n containsPath(path: EventTarget[]): boolean {\n if (path.includes(this)) return true;\n return this.insideElements().some(el => el && path.includes(el));\n }\n\n requestClose(reason: OpenChangeReason): void {\n this.onRequestClose?.(reason);\n }\n\n /** Re-measure (e.g. after the content changed size). */\n reposition(): void {\n if (this.isOpen) this.positioner.update();\n }\n\n show(): void {\n this.generation++;\n this.closing = undefined;\n this.setData(\"ending-style\", false);\n this.setData(\"closed\", false);\n this.setData(\"open\", true);\n if (!this.matches(\":popover-open\")) {\n this.setData(\"starting-style\", true);\n try {\n this.showPopover();\n } catch {\n /* already open, or not connected */\n }\n requestAnimationFrame(() => this.setData(\"starting-style\", false));\n }\n if (!stack.includes(this)) stack.push(this);\n this.positioner.start();\n }\n\n /** Starts the close; resolves once the exit animation finished and the popover is hidden. */\n hide(): Promise<void> {\n if (!this.isOpen && !this.closing) {\n this.setData(\"closed\", true);\n return Promise.resolve();\n }\n if (this.closing) return this.closing;\n const gen = ++this.generation;\n this.setData(\"open\", false);\n this.setData(\"closed\", true);\n this.setData(\"ending-style\", true);\n const i = stack.indexOf(this);\n if (i >= 0) stack.splice(i, 1);\n\n this.closing = (async () => {\n // Let the closed styles apply, then wait for whatever they animate.\n await new Promise(r => requestAnimationFrame(() => r(null)));\n const anims = this.getAnimations().filter(a => a.playState !== \"finished\");\n await Promise.allSettled(anims.map(a => a.finished));\n if (gen !== this.generation) return; // re-opened meanwhile\n this.setData(\"ending-style\", false);\n this.positioner.stop();\n try {\n this.hidePopover();\n } catch {\n /* not open */\n }\n this.closing = undefined;\n })();\n return this.closing;\n }\n}\n\n/** Open popups, bottom → top (read-only view, for tests and devtools). */\nexport const openPopups = (): readonly PopupContent[] => stack;\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { fire, type OpenChangeDetail, type OpenChangeReason } from \"../events\";\nimport { HostElement, NativeEnhancer } from \"../host-element\";\nimport { ensureId } from \"../ids\";\nimport type { PopupContent } from \"./popup-content\";\n\n/**\n * Finds the first element matching `selector` under `root` that belongs to\n * `root` itself, i.e. whose closest `rootSelector` ancestor is `root` (so a\n * DropdownMenu never picks up its submenu's trigger or content).\n */\nexport function ownQuery<T extends Element>(root: Element, selector: string, rootSelector: string): T | null {\n for (const el of Array.from(root.querySelectorAll<T>(selector))) {\n if (el.parentElement?.closest(rootSelector) === root) return el;\n }\n return null;\n}\n\n/** All matches that belong to `root` (see ownQuery). */\nexport function ownQueryAll<T extends Element>(root: Element, selector: string, rootSelector: string): T[] {\n return Array.from(root.querySelectorAll<T>(selector)).filter(\n el => el.parentElement?.closest(rootSelector) === root,\n );\n}\n\n/**\n * # PopupRoot: the coordinator of a popup family\n *\n * Base UI's `<Menu.Root>`, `<Popover.Root>`, `<Select.Root>` render **no\n * element**; they are React context providers. A custom element cannot\n * render nothing, so pont2's roots are *coordinators*: they exist in the\n * DOM (authors need a tag to group trigger and content) but have no box and\n * no role:\n *\n * `[data-pont2-popup-root] { display: contents }` (core/popup/popup.css)\n *\n * That is the same reasoning as a Tier 3 shell, applied to an element whose\n * shadcn counterpart has no DOM at all. Instead of context, the root finds\n * its parts by DOM lookup (`ownQuery`), wires their ARIA, and owns the one\n * piece of state: `open`.\n *\n * `open` changes requested by the user (trigger press, Escape, outside press,\n * item press…) go through `setOpen(open, reason)`, which fires a cancelable\n * `pont2-open-change` ({ open, reason }) first: Base UI's\n * `onOpenChange(open, eventDetails)` + `eventDetails.cancel()`. Writing the\n * `open` property directly is the controlled form and fires nothing.\n */\nexport abstract class PopupRoot extends HostElement {\n static override identity = \"popup-root\";\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare open: boolean;\n declare disabled: boolean;\n\n /** Why the popup last opened/closed (drives focus management). */\n protected lastReason: OpenChangeReason = \"imperative\";\n /** Whether the last open was keyboard-initiated (focus the first item, not the popup). */\n protected openedByKeyboard = false;\n\n constructor() {\n super();\n this.open = false;\n this.disabled = false;\n }\n\n /** The element the popup anchors to and returns focus to (a native button / input). */\n abstract get triggerElement(): HTMLElement | null;\n abstract get contentElement(): PopupContent | null;\n /** `aria-haspopup` value for the trigger. */\n protected abstract get popupKind(): \"menu\" | \"listbox\" | \"dialog\" | \"true\";\n\n /**\n * Request an open-state change, as the user did. Returns false if a\n * `pont2-open-change` listener cancelled it.\n */\n setOpen(open: boolean, reason: OpenChangeReason, opts: { keyboard?: boolean } = {}): boolean {\n if (open === this.open) return true;\n if (open && this.disabled) return false;\n const allowed = fire<OpenChangeDetail>(this, \"pont2-open-change\", { open, reason }, true);\n if (!allowed) return false;\n this.lastReason = reason;\n this.openedByKeyboard = !!opts.keyboard;\n this.open = open;\n return true;\n }\n\n toggle(reason: OpenChangeReason = \"trigger-press\", opts: { keyboard?: boolean } = {}): void {\n this.setOpen(!this.open, reason, opts);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Parts may upgrade after the root; wire once everything is defined.\n queueMicrotask(() => this.wire());\n }\n\n /** Connect trigger and content (idempotent). Call when parts change. */\n wire(): void {\n const content = this.contentElement;\n const trigger = this.triggerElement;\n if (content) {\n ensureId(content, \"popup\");\n content.onRequestClose = reason => this.setOpen(false, reason);\n content.anchorElement = () => this.anchorElement();\n content.insideElements = () => [this.triggerElement, ...this.extraInsideElements()];\n }\n if (trigger) {\n trigger.setAttribute(\"aria-haspopup\", this.popupKind);\n trigger.setAttribute(\"aria-expanded\", String(this.open));\n if (content) trigger.setAttribute(\"aria-controls\", content.id);\n trigger.toggleAttribute(\"data-popup-open\", this.open);\n trigger.toggleAttribute(\"data-disabled\", this.disabled);\n }\n }\n\n /** What the content positions against. Defaults to the trigger. */\n protected anchorElement(): Element | null {\n return this.triggerElement;\n }\n\n /** Further elements whose presses are not \"outside\" (e.g. a combobox input group). */\n protected extraInsideElements(): (Element | null)[] {\n return [];\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.wire();\n if (!changed.has(\"open\")) return;\n const content = this.contentElement;\n if (!content) return;\n if (this.open) {\n content.show();\n this.afterOpen();\n } else if (changed.get(\"open\") !== undefined) {\n const hadFocus = content.contains(document.activeElement) || document.activeElement === document.body;\n void content.hide();\n this.afterClose(hadFocus);\n }\n }\n\n /** Focus management after opening. Default: focus the popup itself. */\n protected afterOpen(): void {}\n\n /** Focus management after closing. Default: return focus to the trigger if it was inside. */\n protected afterClose(focusWasInside: boolean): void {\n if (focusWasInside && this.lastReason !== \"outside-press\") this.triggerElement?.focus({ preventScroll: true });\n }\n}\n\n/**\n * Trigger enhancer: `<pont2-x-trigger><button>…</button></pont2-x-trigger>`.\n * The native button is the trigger (Tier 3). It gets `data-slot`, and its\n * root sets `aria-haspopup` / `aria-expanded` / `aria-controls` /\n * `data-popup-open` on it. Pressing it toggles the root.\n */\nexport abstract class PopupTrigger extends NativeEnhancer<HTMLButtonElement> {\n static override nativeSelector = \"button\";\n /** Tag of the root this trigger belongs to. */\n static rootTag = \"\";\n /**\n * `data-slot` written on the *native button* (e.g. \"dropdown-menu-trigger\").\n * Deliberately not `slotName`: that would stamp the shell, and a shell is\n * never styled or selected.\n */\n static controlSlot = \"trigger\";\n\n get root(): PopupRoot | null {\n return this.closest((this.constructor as typeof PopupTrigger).rootTag) as PopupRoot | null;\n }\n\n constructor() {\n super();\n // Wrappers, not method references: subclass overrides are installed after\n // this constructor runs.\n this.addEventListener(\"click\", e => this.onClick(e));\n this.addEventListener(\"keydown\", e => this.onKeyDown(e));\n }\n\n protected apply(control: HTMLButtonElement): void {\n const slot = (this.constructor as typeof PopupTrigger).controlSlot;\n if (!control.hasAttribute(\"data-slot\") || control.getAttribute(\"data-slot\") === \"button\") {\n control.setAttribute(\"data-slot\", slot);\n }\n if (!control.hasAttribute(\"type\")) control.type = \"button\";\n this.root?.wire();\n }\n\n protected onClick(e: MouseEvent): void {\n const c = this.control;\n if (!c || !(c === e.target || c.contains(e.target as Node)) || c.disabled) return;\n // `detail === 0`: activated by keyboard (Enter/Space), not a pointer.\n this.root?.toggle(\"trigger-press\", { keyboard: e.detail === 0 });\n }\n\n protected onKeyDown(_e: KeyboardEvent): void {}\n}\n","import { HostElement } from \"../../core/host-element\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\n\nconst ROOT = sel(\"popover\");\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * # Popover\n *\n * shadcn: `<Popover>` (Base UI `Popover.Root`, renders nothing) >\n * `<PopoverTrigger>` (a `<button>`) + `<PopoverContent>` (Portal > Positioner >\n * `<div data-slot=\"popover-content\">`), with `PopoverHeader/Title/Description`.\n *\n * pont2:\n * ```html\n * <pont2-prim-popover> coordinator, display: contents\n * <pont2-prim-popover-trigger><button data-pont2-button data-variant=\"outline\">Open</button></pont2-prim-popover-trigger>\n * <pont2-prim-popover-content> the popup itself: [popover], role=dialog\n * <pont2-prim-popover-header>\n * <pont2-prim-popover-title>Dimensions</pont2-prim-popover-title>\n * <pont2-prim-popover-description>Set the dimensions for the layer.</pont2-prim-popover-description>\n * </pont2-prim-popover-header>\n * …\n * </pont2-prim-popover-content>\n * </pont2-prim-popover>\n * ```\n *\n * @tag pont2-prim-popover\n * @attr open - Open state (initially: Base UI `defaultOpen`; property: controlled `open`).\n * @fires pont2-open-change - cancelable, `{ open, reason }`.\n */\nexport class Popover extends PopupRoot {\n static override identity = \"popover\";\n\n get triggerElement(): HTMLButtonElement | null {\n return ownQuery<PopoverTrigger>(this, tags(\"popover-trigger\"), ROOT)?.control ?? null;\n }\n get contentElement(): PopoverContent | null {\n return ownQuery<PopoverContent>(this, sel(\"popover-content\"), ROOT);\n }\n protected get popupKind() {\n return \"dialog\" as const;\n }\n\n protected override afterOpen(): void {\n const content = this.contentElement;\n if (!content) return;\n // Base UI Popover: focus the first focusable element in the popup, else the popup.\n const first = content.querySelector<HTMLElement>(FOCUSABLE);\n (first ?? content).focus({ preventScroll: true });\n }\n}\n\n/** @tag pont2-prim-popover-trigger */\nexport class PopoverTrigger extends PopupTrigger {\n static override rootTag = ROOT;\n static override controlSlot = \"popover-trigger\";\n}\n\n/**\n * The popup. Non-modal, like Base UI's default: closes on Escape, on a press\n * outside, and when focus leaves both the popup and its trigger.\n *\n * @tag pont2-prim-popover-content\n * @attr side - bottom (default) | top | left | right | inline-start | inline-end\n * @attr align - center (default) | start | end\n * @attr side-offset - default 4\n * @attr align-offset - default 0\n * @cssprop --pont2-popover-bg, --pont2-popover-fg, --pont2-popover-border-color, --pont2-popover-radius, --pont2-popover-shadow - see docs/11-tokens.md\n * @cssprop --pont2-popover-width, --pont2-popover-padding-x, --pont2-popover-padding-y, --pont2-popover-gap - sizes (defaults 18rem, 1rem, 1rem, 1rem)\n */\nexport class PopoverContent extends PopupContent {\n static override identity = \"popover-content\";\n static override slotName = \"popover-content\";\n static override role = \"dialog\";\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 4;\n this.addEventListener(\"focusout\", this.onFocusOut);\n }\n\n override show(): void {\n this.tabIndex = -1;\n const title = this.querySelector(`${sel(\"popover-title\")}, [data-slot=popover-title]`);\n const desc = this.querySelector(`${sel(\"popover-description\")}, [data-slot=popover-description]`);\n if (title && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(title, \"popover-title\"));\n if (desc && !this.hasAttribute(\"aria-describedby\")) this.setAttribute(\"aria-describedby\", ensureId(desc, \"popover-desc\"));\n super.show();\n }\n\n private onFocusOut = (e: FocusEvent) => {\n const to = e.relatedTarget as Node | null;\n if (!to || !this.isOpen) return; // focus went to the page/body: keep open (Base UI)\n if (this.contains(to) || this.insideElements().some(el => el?.contains(to))) return;\n this.requestClose(\"focus-out\");\n };\n}\n\n/** @tag pont2-prim-popover-header */\nexport class PopoverHeader extends HostElement {\n static override identity = \"popover-header\";\n static override slotName = \"popover-header\";\n}\n\n/** Base UI `Popover.Title` renders an `<h2>`; pont2 keeps the heading semantics through internals. @tag pont2-prim-popover-title */\nexport class PopoverTitle extends HostElement {\n static override identity = \"popover-title\";\n static override slotName = \"popover-title\";\n static override role = \"heading\";\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.internals.ariaLevel) this.internals.ariaLevel = \"2\";\n }\n}\n\n/** Base UI `Popover.Description` renders a `<p>`. @tag pont2-prim-popover-description */\nexport class PopoverDescription extends HostElement {\n static override identity = \"popover-description\";\n static override slotName = \"popover-description\";\n}\n\ndefine(\"pont2-prim-popover\", Popover);\ndefine(\"pont2-prim-popover-trigger\", PopoverTrigger);\ndefine(\"pont2-prim-popover-content\", PopoverContent);\ndefine(\"pont2-prim-popover-header\", PopoverHeader);\ndefine(\"pont2-prim-popover-title\", PopoverTitle);\ndefine(\"pont2-prim-popover-description\", PopoverDescription);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-popover\": Popover;\n \"pont2-prim-popover-trigger\": PopoverTrigger;\n \"pont2-prim-popover-content\": PopoverContent;\n \"pont2-prim-popover-header\": PopoverHeader;\n \"pont2-prim-popover-title\": PopoverTitle;\n \"pont2-prim-popover-description\": PopoverDescription;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { directionOf } from \"../../core/controllers/roving-focus\";\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex, Typeahead } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOTS = `${sel(\"dropdown-menu\")}, ${sel(\"dropdown-menu-sub\")}`;\nconst CONTENT = \"[data-pont2-dropdown-menu-content]\";\nconst ITEM = \"[data-pont2-menu-item]\";\n\n/** Boolean attribute that defaults to true and is turned off with `=\"false\"`. */\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\ntype FocusTarget = \"first\" | \"last\" | \"popup\";\n\n/* ==================================================================== */\n/* Roots */\n/* ==================================================================== */\n\n/**\n * # DropdownMenu\n *\n * shadcn: `<DropdownMenu>` = Base UI `Menu.Root` (renders nothing).\n *\n * ```html\n * <pont2-prim-dropdown-menu>\n * <pont2-prim-dropdown-menu-trigger><button data-pont2-button data-variant=\"outline\">Open</button></pont2-prim-dropdown-menu-trigger>\n * <pont2-prim-dropdown-menu-content>\n * <pont2-prim-dropdown-menu-group>\n * <pont2-prim-dropdown-menu-label>My Account</pont2-prim-dropdown-menu-label>\n * <pont2-prim-dropdown-menu-item>Profile <pont2-prim-dropdown-menu-shortcut>⇧⌘P</pont2-prim-dropdown-menu-shortcut></pont2-prim-dropdown-menu-item>\n * </pont2-prim-dropdown-menu-group>\n * </pont2-prim-dropdown-menu-content>\n * </pont2-prim-dropdown-menu>\n * ```\n *\n * @tag pont2-prim-dropdown-menu\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class DropdownMenu extends PopupRoot {\n static override identity = \"dropdown-menu\";\n\n /** Where focus goes when the menu opens (set by the trigger's key handling). */\n focusOnOpen: FocusTarget = \"popup\";\n\n get triggerElement(): HTMLElement | null {\n return ownQuery<DropdownMenuTrigger>(this, tags(\"dropdown-menu-trigger\"), ROOTS)?.control ?? null;\n }\n get contentElement(): DropdownMenuContent | null {\n return ownQuery<DropdownMenuContent>(this, sel(\"dropdown-menu-content\"), ROOTS);\n }\n protected get popupKind() {\n return \"menu\" as const;\n }\n\n openWith(focus: FocusTarget, reason: \"trigger-press\" | \"list-navigation\" = \"trigger-press\"): void {\n this.focusOnOpen = focus;\n if (this.open) this.contentElement?.focusTarget(focus);\n else this.setOpen(true, reason, { keyboard: focus !== \"popup\" });\n }\n\n override toggle(reason: \"trigger-press\" = \"trigger-press\", opts: { keyboard?: boolean } = {}): void {\n // Base UI: opening with Enter/Space highlights the first item.\n this.focusOnOpen = opts.keyboard ? \"first\" : \"popup\";\n super.toggle(reason, opts);\n }\n\n protected override afterOpen(): void {\n this.contentElement?.focusTarget(this.focusOnOpen);\n }\n}\n\n/**\n * # DropdownMenuSub\n *\n * Base UI `Menu.SubmenuRoot` (renders nothing). Its trigger is a\n * `pont2-prim-dropdown-menu-sub-trigger` (a menuitem), its popup a\n * `pont2-prim-dropdown-menu-sub-content`.\n *\n * @tag pont2-prim-dropdown-menu-sub\n */\nexport class DropdownMenuSub extends PopupRoot {\n static override identity = \"dropdown-menu-sub\";\n\n focusOnOpen: FocusTarget = \"popup\";\n\n get triggerElement(): DropdownMenuSubTrigger | null {\n return ownQuery<DropdownMenuSubTrigger>(this, sel(\"dropdown-menu-sub-trigger\"), ROOTS);\n }\n get contentElement(): DropdownMenuSubContent | null {\n return ownQuery<DropdownMenuSubContent>(this, sel(\"dropdown-menu-sub-content\"), ROOTS);\n }\n protected get popupKind() {\n return \"menu\" as const;\n }\n\n openWith(focus: FocusTarget, reason: \"trigger-press\" | \"trigger-hover\" | \"list-navigation\"): void {\n this.focusOnOpen = focus;\n if (this.open) this.contentElement?.focusTarget(focus);\n else this.setOpen(true, reason, { keyboard: focus !== \"popup\" });\n }\n\n protected override afterOpen(): void {\n if (this.focusOnOpen !== \"popup\") this.contentElement?.focusTarget(this.focusOnOpen);\n }\n}\n\n/* ==================================================================== */\n/* Trigger */\n/* ==================================================================== */\n\n/**\n * Tier 3 enhancer around a native `<button>`; combine freely with the\n * button recipe (`<button data-pont2-button data-variant=\"outline\">`).\n * ArrowDown/ArrowUp open the menu and highlight the first/last item.\n *\n * @tag pont2-prim-dropdown-menu-trigger\n */\nexport class DropdownMenuTrigger extends PopupTrigger {\n static override rootTag = sel(\"dropdown-menu\");\n static override controlSlot = \"dropdown-menu-trigger\";\n\n protected override onKeyDown(e: KeyboardEvent): void {\n const root = this.root as DropdownMenu | null;\n if (!root || !this.control || e.target !== this.control) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n root.openWith(e.key === \"ArrowDown\" ? \"first\" : \"last\", \"list-navigation\");\n }\n }\n}\n\n/* ==================================================================== */\n/* Content */\n/* ==================================================================== */\n\n/**\n * The menu popup: Base UI `Menu.Popup` (`role=\"menu\"`). Items get real\n * focus (roving), so the highlighted item is `document.activeElement`.\n *\n * @tag pont2-prim-dropdown-menu-content\n * @attr side - bottom (default) … @attr align - start (default) …\n * @attr side-offset - 4 @attr align-offset - 0\n * @cssprop --pont2-dropdown-menu-bg, --pont2-dropdown-menu-fg, --pont2-dropdown-menu-border-color, --pont2-dropdown-menu-radius, --pont2-dropdown-menu-shadow - see docs/11-tokens.md\n * @cssprop --pont2-dropdown-menu-min-width, --pont2-dropdown-menu-padding-x, --pont2-dropdown-menu-padding-y - sizes (defaults 8rem, 0.25rem, 0.25rem)\n * @cssprop --pont2-dropdown-menu-sub-content-shadow - submenu shadow (default: the menu shadow token, else shadow-lg)\n * @cssprop --pont2-dropdown-menu-item-radius, --pont2-dropdown-menu-item-bg-focus, --pont2-dropdown-menu-item-fg-focus - items, inherited from the content\n * @cssprop --pont2-dropdown-menu-item-destructive-fg, --pont2-dropdown-menu-item-destructive-bg-focus - variant=\"destructive\" items\n */\nexport class DropdownMenuContent extends PopupContent {\n static override identity = \"dropdown-menu-content\";\n static override slotName = \"dropdown-menu-content\";\n static override role = \"menu\";\n\n private typeahead = new Typeahead();\n private subCloseTimer = 0;\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"start\";\n this.sideOffset = 4;\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"pointerleave\", this.onPointerLeave);\n this.addEventListener(\"pointerenter\", () => this.cancelSubClose());\n }\n\n /** This menu's own items (not its submenus'), visible, in order. */\n get items(): MenuItemBase[] {\n return Array.from(this.querySelectorAll<MenuItemBase>(ITEM)).filter(\n i => i.closest(CONTENT) === this && isItemVisible(i),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.internals.ariaOrientation = \"vertical\";\n }\n\n override show(): void {\n this.tabIndex = -1;\n super.show();\n }\n\n override hide(): Promise<void> {\n this.closeSubs();\n return super.hide();\n }\n\n focusTarget(target: FocusTarget): void {\n const items = this.items;\n const i = target === \"popup\" ? -1 : moveIndex(items, -1, target);\n (i >= 0 ? items[i] : this).focus({ preventScroll: i < 0 });\n }\n\n /** Close open submenus of this menu, optionally keeping one. */\n closeSubs(except?: Element | null): void {\n for (const sub of Array.from(this.querySelectorAll<DropdownMenuSub>(sel(\"dropdown-menu-sub\")))) {\n if (sub === except || sub.parentElement?.closest(CONTENT) !== this) continue;\n if (sub.open) sub.open = false;\n }\n }\n\n /** Called when the pointer rests on one of this menu's items. */\n scheduleSubClose(keep: Element | null): void {\n this.cancelSubClose();\n this.subCloseTimer = window.setTimeout(() => this.closeSubs(keep), 120);\n }\n\n cancelSubClose(): void {\n clearTimeout(this.subCloseTimer);\n }\n\n private onPointerLeave = () => {\n // Base UI: the highlight leaves with the pointer; focus stays in the menu.\n if (this.contains(document.activeElement) && document.activeElement !== this) {\n const active = document.activeElement as HTMLElement;\n if (active.closest(CONTENT) === this && !(active instanceof DropdownMenuSubTrigger && active.isSubOpen)) {\n this.focus({ preventScroll: true });\n }\n }\n };\n\n private onKeyDown = (e: KeyboardEvent) => {\n // Keys from a nested submenu are handled by that submenu.\n const owner = (e.target as Element).closest(CONTENT);\n if (owner !== this || e.defaultPrevented) return;\n\n const items = this.items;\n const current = items.indexOf(e.target as MenuItemBase);\n const rtl = directionOf(this) === \"rtl\";\n\n if (e.key === \"Tab\") {\n // Base UI: Tab closes the whole menu; focusing the trigger first lets the\n // browser's default Tab move on from it, like leaving any other control.\n const top = this.closest<DropdownMenu>(sel(\"dropdown-menu\"));\n top?.setOpen(false, \"focus-out\");\n top?.triggerElement?.focus();\n return;\n }\n\n const closeKey = rtl ? \"ArrowRight\" : \"ArrowLeft\";\n if (e.key === closeKey && this instanceof DropdownMenuSubContent) {\n e.preventDefault();\n const sub = this.closest<DropdownMenuSub>(sel(\"dropdown-menu-sub\"));\n sub?.setOpen(false, \"list-navigation\");\n sub?.triggerElement?.focus();\n return;\n }\n\n const move = keyToMove(e.key);\n if (move) {\n e.preventDefault();\n const next = moveIndex(items, current, move);\n if (next >= 0) items[next].focus();\n return;\n }\n\n if ((e.key === \"Enter\" || e.key === \" \") && current >= 0) {\n e.preventDefault();\n if (e.key === \" \" && this.typeahead.active) return;\n items[current].click();\n return;\n }\n\n if (Typeahead.isChar(e)) {\n const i = this.typeahead.match(e.key, items, current, el => (el as MenuItemBase).label);\n if (i >= 0) items[i].focus();\n }\n };\n}\n\n/** @tag pont2-prim-dropdown-menu-sub-content */\nexport class DropdownMenuSubContent extends DropdownMenuContent {\n static override identity = \"dropdown-menu-sub-content\";\n static override slotName = \"dropdown-menu-sub-content\";\n\n constructor() {\n super();\n this.side = \"inline-end\";\n this.align = \"start\";\n this.sideOffset = 0;\n this.alignOffset = -3;\n this.addEventListener(\"pointerenter\", () =>\n this.parentElement?.closest<DropdownMenuContent>(CONTENT)?.cancelSubClose(),\n );\n }\n}\n\n/* ==================================================================== */\n/* Items */\n/* ==================================================================== */\n\n/**\n * Shared behaviour of every menu item (Base UI `Menu.Item` and friends):\n * host-as-root `role=menuitem*`, `tabindex=-1`, focus ⇄ `data-highlighted`,\n * pointer hover highlights, click activates and (optionally) closes the menu.\n */\nexport abstract class MenuItemBase extends HostElement {\n static override identity = \"menu-item\";\n static override role = \"menuitem\";\n\n static override properties: PropertyDeclarations = {\n disabled: { type: Boolean, reflect: true },\n inset: { type: Boolean, reflect: true },\n closeOnClick: { attribute: \"close-on-click\", converter: trueUnlessFalse },\n };\n\n declare disabled: boolean;\n declare inset: boolean;\n declare closeOnClick: boolean;\n\n constructor() {\n super();\n this.disabled = false;\n this.inset = false;\n this.closeOnClick = true;\n this.addEventListener(\"focus\", () => this.setData(\"highlighted\", true));\n this.addEventListener(\"blur\", () => this.setData(\"highlighted\", false));\n this.addEventListener(\"pointermove\", this.onPointerMove);\n this.addEventListener(\"click\", this.onClick);\n }\n\n /** Text used by typeahead (Base UI `label`): the `label` attribute, else the text content. */\n get label(): string {\n return this.getAttribute(\"label\") ?? (this.textContent ?? \"\").trim();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n protected get menu(): DropdownMenuContent | null {\n return this.closest<DropdownMenuContent>(CONTENT);\n }\n\n private onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === \"touch\" || this.disabled) return;\n if (document.activeElement !== this) this.focus({ preventScroll: true });\n this.menu?.scheduleSubClose(this instanceof DropdownMenuSubTrigger ? this.parentElement : null);\n };\n\n private onClick = (e: MouseEvent) => {\n if (this.disabled || isItemDisabled(this)) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n this.activate();\n if (this.closeOnClick) {\n this.closest<DropdownMenu>(sel(\"dropdown-menu\"))?.setOpen(false, \"item-press\");\n }\n };\n\n /** What pressing the item does beyond firing `click`. */\n protected activate(): void {}\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"disabled\", this.disabled);\n this.setData(\"inset\", this.inset);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n }\n}\n\n/**\n * Base UI `Menu.Item`. Listen for `click` to act on it.\n *\n * @tag pont2-prim-dropdown-menu-item\n * @attr variant - default | destructive\n * @attr inset, disabled, close-on-click=\"false\"\n */\nexport class DropdownMenuItem extends MenuItemBase {\n static override identity = \"dropdown-menu-item\";\n static override slotName = \"dropdown-menu-item\";\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n };\n declare variant: \"default\" | \"destructive\";\n\n constructor() {\n super();\n this.variant = \"default\";\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"variant\", this.variant || \"default\");\n }\n}\n\nconst indicator = (slot: string, on: boolean) =>\n html`<span data-pont2-dropdown-menu-item-indicator data-slot=${slot}>${on ? icons.check() : nothing}</span>`;\n\n/**\n * Base UI `Menu.CheckboxItem` (`role=menuitemcheckbox`). Stays open on\n * click by default, like Base UI. Fires `change` when toggled.\n *\n * @tag pont2-prim-dropdown-menu-checkbox-item\n * @attr checked\n * @fires change\n */\nexport class DropdownMenuCheckboxItem extends MenuItemBase {\n static override identity = \"dropdown-menu-checkbox-item\";\n static override slotName = \"dropdown-menu-checkbox-item\";\n static override role = \"menuitemcheckbox\";\n\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean, reflect: true },\n };\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n this.closeOnClick = false;\n }\n\n protected override activate(): void {\n this.checked = !this.checked;\n fireNative(this, \"change\");\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n }\n\n override render() {\n return indicator(\"dropdown-menu-checkbox-item-indicator\", this.checked);\n }\n}\n\n/**\n * Base UI `Menu.RadioGroup` (`role=group`). Holds `value`; fires `change`\n * when a radio item is picked.\n *\n * @tag pont2-prim-dropdown-menu-radio-group\n * @attr value\n * @fires change\n */\nexport class DropdownMenuRadioGroup extends HostElement {\n static override identity = \"dropdown-menu-radio-group\";\n static override slotName = \"dropdown-menu-radio-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String, reflect: true },\n };\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n }\n\n select(value: string): void {\n if (value === this.value) return;\n this.value = value;\n fireNative(this, \"change\");\n }\n\n protected override updated(): void {\n for (const item of Array.from(this.querySelectorAll<DropdownMenuRadioItem>(sel(\"dropdown-menu-radio-item\")))) {\n if (item.closest(sel(\"dropdown-menu-radio-group\")) === this) item.requestUpdate();\n }\n }\n}\n\n/**\n * Base UI `Menu.RadioItem` (`role=menuitemradio`).\n *\n * @tag pont2-prim-dropdown-menu-radio-item\n * @attr value\n */\nexport class DropdownMenuRadioItem extends MenuItemBase {\n static override identity = \"dropdown-menu-radio-item\";\n static override slotName = \"dropdown-menu-radio-item\";\n static override role = \"menuitemradio\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n };\n declare value: string;\n\n constructor() {\n super();\n this.value = \"\";\n this.closeOnClick = false;\n }\n\n get group(): DropdownMenuRadioGroup | null {\n return this.closest(sel(\"dropdown-menu-radio-group\"));\n }\n get checked(): boolean {\n return !!this.group && this.group.value === this.value;\n }\n\n protected override activate(): void {\n this.group?.select(this.value);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.internals.ariaChecked = String(this.checked);\n this.setData(\"checked\", this.checked);\n this.setData(\"unchecked\", !this.checked);\n }\n\n override render() {\n return indicator(\"dropdown-menu-radio-item-indicator\", this.checked);\n }\n}\n\n/**\n * Base UI `Menu.SubmenuTrigger`: a menuitem that opens a submenu on hover\n * (100 ms), click, Enter/Space, or ArrowRight (ArrowLeft in RTL). Renders the\n * chevron after your content, as shadcn does.\n *\n * @tag pont2-prim-dropdown-menu-sub-trigger\n */\nexport class DropdownMenuSubTrigger extends MenuItemBase {\n static override identity = \"dropdown-menu-sub-trigger\";\n static override slotName = \"dropdown-menu-sub-trigger\";\n\n private hoverTimer = 0;\n\n constructor() {\n super();\n this.closeOnClick = false;\n this.addEventListener(\"keydown\", this.onKey);\n this.addEventListener(\"pointerenter\", this.onEnter);\n this.addEventListener(\"pointerleave\", () => clearTimeout(this.hoverTimer));\n }\n\n get sub(): DropdownMenuSub | null {\n return this.closest(sel(\"dropdown-menu-sub\"));\n }\n get isSubOpen(): boolean {\n return !!this.sub?.open;\n }\n\n protected override activate(): void {\n this.sub?.openWith(\"first\", \"trigger-press\");\n }\n\n private onEnter = (e: PointerEvent) => {\n if (e.pointerType === \"touch\" || this.disabled) return;\n clearTimeout(this.hoverTimer);\n this.hoverTimer = window.setTimeout(() => this.sub?.openWith(\"popup\", \"trigger-hover\"), 100);\n };\n\n private onKey = (e: KeyboardEvent) => {\n if (e.target !== this || this.disabled) return;\n const openKey = directionOf(this) === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n if (e.key === openKey) {\n e.preventDefault();\n e.stopPropagation();\n this.sub?.openWith(\"first\", \"list-navigation\");\n }\n };\n\n override render() {\n return icons.chevronRight();\n }\n}\n\n/** Base UI `Menu.Group` (`role=group`, labelled by its label). @tag pont2-prim-dropdown-menu-group */\nexport class DropdownMenuGroup extends HostElement {\n static override identity = \"dropdown-menu-group\";\n static override slotName = \"dropdown-menu-group\";\n static override role = \"group\";\n\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"dropdown-menu-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) {\n this.setAttribute(\"aria-labelledby\", ensureId(label, \"menu-label\"));\n }\n });\n }\n}\n\n/** Base UI `Menu.GroupLabel`. @tag pont2-prim-dropdown-menu-label @attr inset */\nexport class DropdownMenuLabel extends HostElement {\n static override identity = \"dropdown-menu-label\";\n static override slotName = \"dropdown-menu-label\";\n static override properties: PropertyDeclarations = { inset: { type: Boolean, reflect: true } };\n declare inset: boolean;\n constructor() {\n super();\n this.inset = false;\n }\n protected override willUpdate(): void {\n this.setData(\"inset\", this.inset);\n }\n}\n\n/**\n * Base UI `Menu.Separator`. **Is a** Separator (`extends Separator`), so it\n * carries `data-pont2-separator` (the look) and its own slot.\n *\n * @tag pont2-prim-dropdown-menu-separator\n */\nexport class DropdownMenuSeparator extends Separator {\n static override identity = \"dropdown-menu-separator\";\n static override slotName = \"dropdown-menu-separator\";\n}\n\n/** shadcn `DropdownMenuShortcut` (a `<span>`). @tag pont2-prim-dropdown-menu-shortcut */\nexport class DropdownMenuShortcut extends HostElement {\n static override identity = \"dropdown-menu-shortcut\";\n static override slotName = \"dropdown-menu-shortcut\";\n}\n\ndefine(\"pont2-prim-dropdown-menu\", DropdownMenu);\ndefine(\"pont2-prim-dropdown-menu-sub\", DropdownMenuSub);\ndefine(\"pont2-prim-dropdown-menu-trigger\", DropdownMenuTrigger);\ndefine(\"pont2-prim-dropdown-menu-content\", DropdownMenuContent);\ndefine(\"pont2-prim-dropdown-menu-sub-content\", DropdownMenuSubContent);\ndefine(\"pont2-prim-dropdown-menu-item\", DropdownMenuItem);\ndefine(\"pont2-prim-dropdown-menu-checkbox-item\", DropdownMenuCheckboxItem);\ndefine(\"pont2-prim-dropdown-menu-radio-group\", DropdownMenuRadioGroup);\ndefine(\"pont2-prim-dropdown-menu-radio-item\", DropdownMenuRadioItem);\ndefine(\"pont2-prim-dropdown-menu-sub-trigger\", DropdownMenuSubTrigger);\ndefine(\"pont2-prim-dropdown-menu-group\", DropdownMenuGroup);\ndefine(\"pont2-prim-dropdown-menu-label\", DropdownMenuLabel);\ndefine(\"pont2-prim-dropdown-menu-separator\", DropdownMenuSeparator);\ndefine(\"pont2-prim-dropdown-menu-shortcut\", DropdownMenuShortcut);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-dropdown-menu\": DropdownMenu;\n \"pont2-prim-dropdown-menu-sub\": DropdownMenuSub;\n \"pont2-prim-dropdown-menu-trigger\": DropdownMenuTrigger;\n \"pont2-prim-dropdown-menu-content\": DropdownMenuContent;\n \"pont2-prim-dropdown-menu-sub-content\": DropdownMenuSubContent;\n \"pont2-prim-dropdown-menu-item\": DropdownMenuItem;\n \"pont2-prim-dropdown-menu-checkbox-item\": DropdownMenuCheckboxItem;\n \"pont2-prim-dropdown-menu-radio-group\": DropdownMenuRadioGroup;\n \"pont2-prim-dropdown-menu-radio-item\": DropdownMenuRadioItem;\n \"pont2-prim-dropdown-menu-sub-trigger\": DropdownMenuSubTrigger;\n \"pont2-prim-dropdown-menu-group\": DropdownMenuGroup;\n \"pont2-prim-dropdown-menu-label\": DropdownMenuLabel;\n \"pont2-prim-dropdown-menu-separator\": DropdownMenuSeparator;\n \"pont2-prim-dropdown-menu-shortcut\": DropdownMenuShortcut;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { HostElement, ShellElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex, Typeahead } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOT = sel(\"select\");\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\n/**\n * # Select\n *\n * shadcn: `<Select>` = Base UI `Select.Root` (renders a hidden `<input>` for\n * forms, nothing else) > `<SelectTrigger>` (`<button role=combobox>` with\n * `<SelectValue>` + chevron) + `<SelectContent>` (Portal > Positioner > Popup >\n * List > items).\n *\n * pont2:\n * ```html\n * <pont2-prim-select name=\"fruit\" value=\"apple\"> coordinator + form-associated, display: contents\n * <pont2-prim-select-trigger placeholder=\"Select a fruit\"></pont2-prim-select-trigger> shell > native <button>\n * <pont2-prim-select-content> the popup: [popover], role=listbox\n * <pont2-prim-select-group>\n * <pont2-prim-select-label>Fruits</pont2-prim-select-label>\n * <pont2-prim-select-item value=\"apple\">Apple</pont2-prim-select-item>\n * </pont2-prim-select-group>\n * </pont2-prim-select-content>\n * </pont2-prim-select>\n * ```\n *\n * The **root is the form control** (a form-associated custom element):\n * `name`/`value` submit with the form, `required` blocks submission,\n * `<fieldset disabled>` and form reset work, and `<label for=\"…\">` targets it\n * (the label's text becomes the trigger's accessible name). That replaces\n * Base UI's hidden `<input>`, one node fewer.\n *\n * @tag pont2-prim-select\n * @attr value - selected value (initially: Base UI `defaultValue`)\n * @attr name, required, disabled, open\n * @fires input, change - the user picked a value (read `.value`)\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class Select extends PopupRoot {\n static formAssociated = true;\n static override identity = \"select\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n name: { type: String, reflect: true },\n required: { type: Boolean, reflect: true },\n /** `aria-invalid` on the root is forwarded to the native trigger (which you do not write). */\n invalid: { type: String, attribute: \"aria-invalid\" },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare name: string;\n declare required: boolean;\n declare invalid: string | null;\n declare protected formDisabled: boolean;\n\n private typeahead = new Typeahead();\n private focusSelectedOnOpen = true;\n\n constructor() {\n super();\n this.value = \"\";\n this.name = \"\";\n this.required = false;\n this.formDisabled = false;\n // A <label for> click lands on the (box-less) root: forward focus to the trigger.\n this.addEventListener(\"click\", e => {\n if (e.target === this) this.triggerElement?.focus();\n });\n }\n\n /* ---------------- parts ---------------- */\n\n get triggerElement(): HTMLButtonElement | null {\n return ownQuery<SelectTrigger>(this, tags(\"select-trigger\"), ROOT)?.control ?? null;\n }\n get triggerHost(): SelectTrigger | null {\n return ownQuery<SelectTrigger>(this, tags(\"select-trigger\"), ROOT);\n }\n get contentElement(): SelectContent | null {\n return ownQuery<SelectContent>(this, sel(\"select-content\"), ROOT);\n }\n protected get popupKind() {\n return \"listbox\" as const;\n }\n get items(): SelectItem[] {\n return Array.from(this.querySelectorAll<SelectItem>(sel(\"select-item\"))).filter(\n i => i.closest(ROOT) === this && isItemVisible(i),\n );\n }\n get selectedItem(): SelectItem | null {\n return this.items.find(i => i.value === this.value) ?? null;\n }\n\n /* ---------------- form-associated API ---------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n formResetCallback(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n }\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n formStateRestoreCallback(state: string | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n /* ---------------- behaviour ---------------- */\n\n override wire(): void {\n super.wire();\n // Labels of the (box-less) root name the trigger button.\n const trigger = this.triggerElement;\n if (trigger) {\n const ids = Array.from(this.internals.labels as NodeListOf<HTMLElement>).map(l => ensureId(l, \"select-label\"));\n if (ids.length && !trigger.hasAttribute(\"aria-label\")) trigger.setAttribute(\"aria-labelledby\", ids.join(\" \"));\n }\n }\n\n /** Pick `value` as the user did: updates, fires input/change, closes. */\n select(value: string): void {\n const changed = value !== this.value;\n this.value = value;\n if (changed) {\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n this.setOpen(false, \"item-press\");\n }\n\n /** Called by the trigger for keys pressed while it has focus. */\n handleTriggerKey(e: KeyboardEvent): void {\n if (this.isDisabled) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n this.setOpen(true, \"list-navigation\", { keyboard: true });\n return;\n }\n // Base UI: typing on a closed select picks the matching item directly.\n if (!this.open && Typeahead.isChar(e)) {\n const items = this.items;\n const i = this.typeahead.match(e.key, items, items.indexOf(this.selectedItem!), el => (el as SelectItem).label);\n if (i >= 0 && items[i].value !== this.value) {\n this.value = items[i].value;\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n }\n }\n\n override setOpen(open: boolean, reason: Parameters<PopupRoot[\"setOpen\"]>[1], opts?: { keyboard?: boolean }): boolean {\n if (open && this.isDisabled) return false;\n return super.setOpen(open, reason, opts);\n }\n\n protected override afterOpen(): void {\n const content = this.contentElement;\n if (!content) return;\n const target = (this.focusSelectedOnOpen && this.selectedItem) || (this.openedByKeyboard ? this.items.find(i => !isItemDisabled(i)) : null);\n (target ?? content).focus({ preventScroll: true });\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const disabled = this.isDisabled;\n this.setData(\"disabled\", disabled);\n this.setData(\"required\", this.required);\n this.internals.setFormValue(this.value || null);\n if (this.required && !this.value) {\n this.internals.setValidity({ valueMissing: true }, \"Please select an item in the list.\", this.triggerElement ?? undefined);\n } else {\n this.internals.setValidity({});\n }\n if (changed.has(\"value\") || changed.has(\"disabled\") || changed.has(\"formDisabled\") || changed.has(\"invalid\")) {\n for (const item of this.items) item.requestUpdate();\n this.triggerHost?.requestUpdate();\n }\n }\n}\n\n/* ==================================================================== */\n\n/**\n * shadcn `SelectTrigger` + `SelectValue`. Tier 3, **self-rendering**: the\n * trigger generates all of its content (the selected item's label or the\n * placeholder, then the chevron), so it renders its own native `<button>`\n * rather than enhancing one you write (docs/02-conventions.md, \"Tier 3\n * entry points\").\n *\n * ```\n * shadcn: button[data-slot=select-trigger][role=combobox] > span[data-slot=select-value] + svg\n * pont2: pont2-prim-select-trigger (shell) > button[data-slot=select-trigger][role=combobox] > span[data-slot=select-value] + svg\n * ```\n *\n * @tag pont2-prim-select-trigger\n * @attr placeholder - shown when no value is selected (Base UI `Select.Value` placeholder)\n * @attr size - default | sm\n */\nexport class SelectTrigger extends ShellElement {\n static override properties: PropertyDeclarations = {\n placeholder: { type: String },\n size: { type: String },\n };\n declare placeholder: string;\n declare size: \"default\" | \"sm\";\n\n constructor() {\n super();\n this.placeholder = \"\";\n this.size = \"default\";\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n\n override get control(): HTMLButtonElement | null {\n return this.querySelector(\":scope > [data-pont2-select-trigger]\");\n }\n\n private onClick = (e: MouseEvent) => {\n const root = this.root;\n if (!root || root.isDisabled) return;\n root.toggle(\"trigger-press\", { keyboard: e.detail === 0 });\n };\n\n private onKeyDown = (e: KeyboardEvent) => this.root?.handleTriggerKey(e);\n\n protected override updated(): void {\n this.root?.wire();\n }\n\n override render() {\n const root = this.root;\n const item = root?.selectedItem ?? null;\n const disabled = !!root?.isDisabled;\n return html`<button\n type=\"button\"\n role=\"combobox\"\n data-pont2-select-trigger\n data-slot=\"select-trigger\"\n data-size=${this.size || \"default\"}\n ?data-placeholder=${!item}\n aria-invalid=${root?.invalid ?? nothing}\n ?disabled=${disabled}\n ?data-disabled=${disabled}\n @click=${this.onClick}\n @keydown=${this.onKeyDown}\n ><span data-pont2-select-value data-slot=\"select-value\" ?data-placeholder=${!item}\n >${item ? item.labelNodes() : this.placeholder}</span\n >${icons.chevronDown()}</button>`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * The popup (`role=listbox`). By default the selected item is laid over the\n * trigger (Base UI `alignItemWithTrigger`, macOS-style); when that cannot fit\n * it falls back to opening below the trigger.\n *\n * @tag pont2-prim-select-content\n * @attr align-item-with-trigger - default true; `=\"false\"` always opens on `side`\n * @attr side - bottom @attr align - center @attr side-offset - 4\n */\nexport class SelectContent extends PopupContent {\n static override identity = \"select-content\";\n static override slotName = \"select-content\";\n static override role = \"listbox\";\n\n static override properties: PropertyDeclarations = {\n alignItemWithTrigger: { attribute: \"align-item-with-trigger\", converter: trueUnlessFalse },\n };\n declare alignItemWithTrigger: boolean;\n\n private typeahead = new Typeahead();\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"center\";\n this.sideOffset = 4;\n this.alignItemWithTrigger = true;\n this.addEventListener(\"keydown\", this.onKeyDown);\n this.addEventListener(\"pointerleave\", () => {\n if (this.contains(document.activeElement)) this.focus({ preventScroll: true });\n });\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n\n protected override alignItem(): HTMLElement | null {\n if (!this.alignItemWithTrigger) return null;\n const root = this.root;\n return root?.selectedItem ?? root?.items[0] ?? null;\n }\n\n protected override willUpdate(): void {\n this.setData(\"align-trigger\", this.alignItemWithTrigger ? \"true\" : \"false\");\n }\n\n override show(): void {\n this.tabIndex = -1;\n super.show();\n // Bring the selected item into view inside the list, then re-measure.\n const item = this.root?.selectedItem;\n if (item) {\n const top = item.offsetTop;\n if (top < this.scrollTop || top + item.offsetHeight > this.scrollTop + this.clientHeight) {\n this.scrollTop = top - (this.clientHeight - item.offsetHeight) / 2;\n }\n }\n this.positioner.update();\n }\n\n private onKeyDown = (e: KeyboardEvent) => {\n const root = this.root;\n if (!root || e.defaultPrevented) return;\n const items = root.items;\n const current = items.indexOf(e.target as SelectItem);\n\n if (e.key === \"Tab\") {\n root.setOpen(false, \"focus-out\");\n root.triggerElement?.focus();\n return;\n }\n const move = keyToMove(e.key);\n if (move) {\n e.preventDefault();\n const next = moveIndex(items, current, move, { loop: false });\n if (next >= 0) items[next].focus();\n return;\n }\n if ((e.key === \"Enter\" || e.key === \" \") && current >= 0) {\n e.preventDefault();\n if (e.key === \" \" && this.typeahead.active) return;\n items[current].click();\n return;\n }\n if (Typeahead.isChar(e)) {\n const i = this.typeahead.match(e.key, items, current, el => (el as SelectItem).label);\n if (i >= 0) items[i].focus();\n }\n };\n}\n\n/* ==================================================================== */\n\n/**\n * Base UI `Select.Item` (`role=option`): host-as-root. Your content is the\n * item text (Base UI `ItemText`); the check indicator is rendered after it\n * when selected.\n *\n * @tag pont2-prim-select-item\n * @attr value - required\n * @attr label - text for typeahead and the trigger (defaults to the text content)\n * @attr disabled\n */\nexport class SelectItem extends HostElement {\n static override identity = \"select-item\";\n static override slotName = \"select-item\";\n static override role = \"option\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"focus\", () => this.setData(\"highlighted\", true));\n this.addEventListener(\"blur\", () => this.setData(\"highlighted\", false));\n this.addEventListener(\"pointermove\", e => {\n if (e.pointerType !== \"touch\" && !this.disabled && document.activeElement !== this) this.focus({ preventScroll: true });\n });\n this.addEventListener(\"click\", e => {\n if (this.disabled) {\n e.stopImmediatePropagation();\n return;\n }\n this.root?.select(this.value);\n });\n }\n\n get root(): Select | null {\n return this.closest(ROOT);\n }\n get selected(): boolean {\n return !!this.root && this.root.value === this.value;\n }\n get label(): string {\n return this.getAttribute(\"label\") ?? this.textOf();\n }\n\n private textOf(): string {\n let t = \"\";\n for (const n of Array.from(this.childNodes)) {\n if (n instanceof Comment) continue; // lit-html part markers\n if (n instanceof Element && n.hasAttribute(\"data-pont2-select-item-indicator\")) continue;\n t += n.textContent ?? \"\";\n }\n return t.trim();\n }\n\n /** Copies of the author's content, for the trigger to display (Base UI renders the item label). */\n labelNodes(): Node[] {\n if (this.hasAttribute(\"label\")) return [document.createTextNode(this.getAttribute(\"label\")!)];\n return Array.from(this.childNodes)\n .filter(n => !(n instanceof Comment) && !(n instanceof Element && n.hasAttribute(\"data-pont2-select-item-indicator\")))\n .map(n => {\n const c = n.cloneNode(true);\n if (c instanceof Element) c.removeAttribute(\"id\");\n return c;\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabindex\")) this.tabIndex = -1;\n }\n\n protected override willUpdate(): void {\n const selected = this.selected;\n this.internals.ariaSelected = String(selected);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n this.setData(\"selected\", selected);\n this.setData(\"disabled\", this.disabled);\n }\n\n override render() {\n return this.selected\n ? html`<span data-pont2-select-item-indicator data-slot=\"select-item-indicator\">${icons.check()}</span>`\n : nothing;\n }\n}\n\n/** Base UI `Select.Group` (`role=group`). @tag pont2-prim-select-group */\nexport class SelectGroup extends HostElement {\n static override identity = \"select-group\";\n static override slotName = \"select-group\";\n static override role = \"group\";\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"select-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(label, \"select-group-label\"));\n });\n }\n}\n\n/** Base UI `Select.GroupLabel`. @tag pont2-prim-select-label */\nexport class SelectLabel extends HostElement {\n static override identity = \"select-label\";\n static override slotName = \"select-label\";\n}\n\n/** Base UI `Select.Separator`; is-a Separator. @tag pont2-prim-select-separator */\nexport class SelectSeparator extends Separator {\n static override identity = \"select-separator\";\n static override slotName = \"select-separator\";\n}\n\ndefine(\"pont2-prim-select\", Select);\ndefine(\"pont2-prim-select-trigger\", SelectTrigger);\ndefine(\"pont2-prim-select-content\", SelectContent);\ndefine(\"pont2-prim-select-item\", SelectItem);\ndefine(\"pont2-prim-select-group\", SelectGroup);\ndefine(\"pont2-prim-select-label\", SelectLabel);\ndefine(\"pont2-prim-select-separator\", SelectSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-select\": Select;\n \"pont2-prim-select-trigger\": SelectTrigger;\n \"pont2-prim-select-content\": SelectContent;\n \"pont2-prim-select-item\": SelectItem;\n \"pont2-prim-select-group\": SelectGroup;\n \"pont2-prim-select-label\": SelectLabel;\n \"pont2-prim-select-separator\": SelectSeparator;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fireNative } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { ensureId, uid } from \"../../core/ids\";\nimport { define, sel } from \"../../core/names\";\nimport { isItemDisabled, isItemVisible, keyToMove, moveIndex } from \"../../core/popup/list\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot } from \"../../core/popup/popup-root\";\nimport { Separator } from \"../separator/separator\";\n\nconst ROOT = sel(\"combobox\");\nconst trueUnlessFalse = { fromAttribute: (v: string | null) => v !== \"false\", toAttribute: (v: boolean) => String(v) };\n\n/**\n * # Combobox (single selection)\n *\n * shadcn: `<Combobox>` = Base UI `Combobox.Root` (a hidden `<input>` for\n * forms, nothing else) > `<ComboboxInput>` (InputGroup > `<input\n * role=combobox>` + addon > trigger/clear buttons) + `<ComboboxContent>`\n * (Portal > Positioner > Popup) > `<ComboboxList role=listbox>` > items,\n * `<ComboboxEmpty>`, groups.\n *\n * pont2:\n * ```html\n * <pont2-prim-combobox name=\"framework\"> coordinator + form-associated, display: contents\n * <pont2-prim-combobox-input placeholder=\"Select a framework\"></pont2-prim-combobox-input> is the InputGroup; renders the native input + buttons\n * <pont2-prim-combobox-content> the popup: [popover]\n * <pont2-prim-combobox-empty>No items found.</pont2-prim-combobox-empty>\n * <pont2-prim-combobox-list> role=listbox\n * <pont2-prim-combobox-item value=\"next\">Next.js</pont2-prim-combobox-item>\n * </pont2-prim-combobox-list>\n * </pont2-prim-combobox-content>\n * </pont2-prim-combobox>\n * ```\n *\n * **Which element submits?** The root (a form-associated custom element)\n * submits `name` = the *selected item's value*, exactly what Base UI's hidden\n * input submits. The native `<input>` is the typing surface (IME, caret,\n * mobile keyboards, screen-reader combobox semantics) and has no `name`, so\n * the half-typed query never reaches the server.\n *\n * Focus stays in the input; the highlighted item is announced with\n * `aria-activedescendant` (virtual focus), as in Base UI.\n *\n * Not implemented yet: `multiple` with chips (`ComboboxChips`), async items,\n * `autoHighlight`, creatable items. See docs/primitives/combobox.md.\n *\n * @tag pont2-prim-combobox\n * @attr value - selected value (initially: Base UI `defaultValue`)\n * @attr name, required, disabled, open\n * @fires input, change - the user picked (or cleared) a value\n * @fires pont2-open-change - cancelable `{ open, reason }`\n */\nexport class Combobox extends PopupRoot {\n static formAssociated = true;\n static override identity = \"combobox\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n name: { type: String, reflect: true },\n required: { type: Boolean, reflect: true },\n query: { state: true },\n formDisabled: { state: true },\n };\n\n declare value: string;\n declare name: string;\n declare required: boolean;\n /** What the user typed since the popup opened; filters the items. */\n declare query: string;\n declare protected formDisabled: boolean;\n\n /** The virtually focused item. */\n highlighted: ComboboxItem | null = null;\n\n constructor() {\n super();\n this.value = \"\";\n this.name = \"\";\n this.required = false;\n this.query = \"\";\n this.formDisabled = false;\n this.addEventListener(\"click\", e => {\n if (e.target === this) this.inputElement?.focus(); // <label for> on the root\n });\n }\n\n /* ---------------- parts ---------------- */\n\n get inputHost(): ComboboxInput | null {\n return ownQuery<ComboboxInput>(this, sel(\"combobox-input\"), ROOT);\n }\n get inputElement(): HTMLInputElement | null {\n return this.inputHost?.control ?? null;\n }\n /** The input is the combobox element: it gets aria-expanded/controls and receives focus back. */\n get triggerElement(): HTMLInputElement | null {\n return this.inputElement;\n }\n get contentElement(): ComboboxContent | null {\n return ownQuery<ComboboxContent>(this, sel(\"combobox-content\"), ROOT);\n }\n get listElement(): ComboboxList | null {\n return ownQuery<ComboboxList>(this, sel(\"combobox-list\"), ROOT);\n }\n protected get popupKind() {\n return \"listbox\" as const;\n }\n protected override anchorElement(): Element | null {\n return this.inputHost;\n }\n protected override extraInsideElements(): (Element | null)[] {\n return [this.inputHost];\n }\n\n get allItems(): ComboboxItem[] {\n return Array.from(this.querySelectorAll<ComboboxItem>(sel(\"combobox-item\"))).filter(i => i.closest(ROOT) === this);\n }\n /** Items matching the current query. */\n get items(): ComboboxItem[] {\n return this.allItems.filter(i => isItemVisible(i));\n }\n get selectedItem(): ComboboxItem | null {\n return this.allItems.find(i => i.value === this.value) ?? null;\n }\n\n /* ---------------- form-associated API ---------------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get labels(): NodeList {\n return this.internals.labels;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get isDisabled(): boolean {\n return this.disabled || this.formDisabled;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n formResetCallback(): void {\n this.value = this.getAttribute(\"value\") ?? \"\";\n this.syncInputText();\n }\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n formStateRestoreCallback(state: string | null): void {\n if (typeof state === \"string\") this.value = state;\n }\n\n /* ---------------- behaviour ---------------- */\n\n /** Base UI default filter: case- and accent-insensitive \"contains\". */\n static filter(label: string, query: string): boolean {\n const norm = (s: string) => s.normalize(\"NFD\").replace(/\\p{Diacritic}/gu, \"\").toLowerCase();\n return norm(label).includes(norm(query.trim()));\n }\n\n select(item: ComboboxItem | null): void {\n const value = item?.value ?? \"\";\n const changed = value !== this.value;\n this.value = value;\n this.query = \"\";\n this.syncInputText();\n if (changed) {\n fireNative(this, \"input\");\n fireNative(this, \"change\");\n }\n this.setOpen(false, \"item-press\");\n }\n\n /** Show the selected item's label in the input (after select/close/reset). */\n syncInputText(): void {\n const input = this.inputElement;\n if (input) input.value = this.selectedItem?.label ?? \"\";\n }\n\n highlight(item: ComboboxItem | null, scroll = true): void {\n if (this.highlighted === item) return;\n this.highlighted?.setHighlighted(false);\n this.highlighted = item;\n item?.setHighlighted(true);\n const input = this.inputElement;\n if (input) {\n if (item) input.setAttribute(\"aria-activedescendant\", ensureId(item, \"combobox-item\"));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n if (item && scroll) item.scrollIntoView({ block: \"nearest\" });\n }\n\n /** From the input: the user typed. */\n handleQuery(text: string): void {\n this.query = text;\n if (!this.open) this.setOpen(true, \"input-change\");\n // Keep the highlight only if it is still visible.\n this.applyFilter();\n if (this.highlighted && !isItemVisible(this.highlighted)) this.highlight(null);\n }\n\n /** From the input: keyboard. */\n handleKey(e: KeyboardEvent): void {\n if (this.isDisabled) return;\n const move = e.key === \"ArrowDown\" || e.key === \"ArrowUp\" ? keyToMove(e.key) : null;\n if (move) {\n e.preventDefault();\n if (!this.open) {\n this.setOpen(true, \"list-navigation\", { keyboard: true });\n this.applyFilter();\n }\n const items = this.items;\n const current = this.highlighted ? items.indexOf(this.highlighted) : -1;\n const next = moveIndex(items, current, move);\n this.highlight(next >= 0 ? items[next] : null);\n return;\n }\n if (e.key === \"Enter\" && this.open) {\n e.preventDefault(); // never submit the form while choosing\n if (this.highlighted && !isItemDisabled(this.highlighted)) this.select(this.highlighted);\n return;\n }\n if (e.key === \"Tab\" && this.open) this.setOpen(false, \"focus-out\");\n }\n\n /** Hide items (and empty groups) that do not match the query. */\n applyFilter(): void {\n const q = this.query;\n let visible = 0;\n for (const item of this.allItems) {\n const show = !q || Combobox.filter(item.label, q);\n item.hidden = !show;\n if (show) visible++;\n }\n for (const group of Array.from(this.querySelectorAll<HTMLElement>(sel(\"combobox-group\")))) {\n if (group.closest(ROOT) !== this) continue;\n group.hidden = !group.querySelector(`${sel(\"combobox-item\")}:not([hidden])`);\n }\n const empty = visible === 0;\n this.listElement?.toggleAttribute(\"data-empty\", empty);\n this.contentElement?.toggleAttribute(\"data-empty\", empty);\n this.contentElement?.reposition();\n }\n\n override wire(): void {\n super.wire();\n const input = this.inputElement;\n const list = this.listElement;\n if (input && list) input.setAttribute(\"aria-controls\", ensureId(list, \"combobox-list\"));\n if (input) {\n const ids = Array.from(this.internals.labels as NodeListOf<HTMLElement>).map(l => ensureId(l, \"combobox-label\"));\n if (ids.length && !input.hasAttribute(\"aria-label\")) input.setAttribute(\"aria-labelledby\", ids.join(\" \"));\n }\n }\n\n protected override afterOpen(): void {\n this.applyFilter();\n if (this.openedByKeyboard && !this.highlighted) {\n const sel = this.selectedItem;\n this.highlight(sel && isItemVisible(sel) ? sel : null);\n }\n }\n\n protected override afterClose(): void {\n this.highlight(null);\n this.query = \"\";\n this.syncInputText();\n // Unfiltered again for next time, once the exit animation is done.\n setTimeout(() => {\n if (!this.open) this.applyFilter();\n }, 200);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.setData(\"disabled\", this.isDisabled);\n this.internals.setFormValue(this.value || null);\n if (this.required && !this.value) {\n this.internals.setValidity({ valueMissing: true }, \"Please select an item in the list.\", this.inputElement ?? undefined);\n } else {\n this.internals.setValidity({});\n }\n if (changed.has(\"value\")) {\n for (const item of this.allItems) item.requestUpdate();\n if (changed.get(\"value\") === undefined) queueMicrotask(() => this.syncInputText());\n }\n if (changed.has(\"disabled\") || changed.has(\"formDisabled\")) this.inputHost?.requestUpdate();\n }\n}\n\n/* ==================================================================== */\n\n/**\n * shadcn `ComboboxInput`: an InputGroup holding the native `<input>` and an\n * inline-end addon with the trigger (and optionally clear) button. The host\n * **is** the InputGroup (`role=group`, `data-slot=\"input-group\"`); it renders\n * the input and buttons because shadcn's ComboboxInput generates them too.\n *\n * ```\n * shadcn: div[data-slot=input-group] > input + div[data-slot=input-group-addon] > button[data-slot=input-group-button]\n * pont2: pont2-prim-combobox-input > input + div[data-slot=input-group-addon] > button[data-slot=input-group-button]\n * ```\n *\n * @tag pont2-prim-combobox-input\n * @attr placeholder\n * @attr show-trigger - default true; `=\"false\"` hides the chevron button\n * @attr show-clear - shows a clear (×) button while a value is selected\n */\nexport class ComboboxInput extends HostElement {\n static override identity = \"combobox-input\";\n static override slotName = \"input-group\";\n static override role = \"group\";\n\n static override properties: PropertyDeclarations = {\n placeholder: { type: String },\n showTrigger: { attribute: \"show-trigger\", converter: trueUnlessFalse },\n showClear: { type: Boolean, attribute: \"show-clear\" },\n };\n declare placeholder: string;\n declare showTrigger: boolean;\n declare showClear: boolean;\n\n private readonly inputId = uid(\"combobox-input\");\n\n constructor() {\n super();\n this.placeholder = \"\";\n this.showTrigger = true;\n this.showClear = false;\n }\n\n get root(): Combobox | null {\n return this.closest(ROOT);\n }\n get control(): HTMLInputElement | null {\n return this.querySelector(\":scope > input\");\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n protected override updated(): void {\n this.root?.wire();\n }\n\n private onInput = (e: Event) => this.root?.handleQuery((e.target as HTMLInputElement).value);\n private onKeyDown = (e: KeyboardEvent) => this.root?.handleKey(e);\n private onInputClick = () => {\n const root = this.root;\n if (root && !root.open) root.setOpen(true, \"trigger-press\");\n };\n private onFocusOut = (e: FocusEvent) => {\n const root = this.root;\n const to = e.relatedTarget as Node | null;\n if (!root?.open) return;\n if (to && (this.contains(to) || root.contentElement?.contains(to))) return;\n root.setOpen(false, \"focus-out\");\n };\n private onTrigger = () => {\n const root = this.root;\n if (!root) return;\n root.query = \"\";\n root.toggle(\"trigger-press\");\n this.control?.focus();\n };\n private onClear = () => {\n const root = this.root;\n if (!root) return;\n root.select(null);\n this.control?.focus();\n };\n private onAddonClick = (e: MouseEvent) => {\n // InputGroupAddon: clicks on the addon (not its buttons) focus the input.\n if (!(e.target as Element).closest(\"button\")) this.control?.focus();\n };\n\n override render() {\n const root = this.root;\n const disabled = !!root?.isDisabled;\n const hasValue = !!root?.value;\n return html`<input\n id=${this.inputId}\n data-pont2-combobox-input-control\n data-slot=\"input-group-control\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n placeholder=${this.placeholder || nothing}\n ?disabled=${disabled}\n aria-invalid=${root?.getAttribute(\"aria-invalid\") ?? nothing}\n @input=${this.onInput}\n @keydown=${this.onKeyDown}\n @click=${this.onInputClick}\n @focusout=${this.onFocusOut}\n /><div data-pont2-combobox-input-addon data-slot=\"input-group-addon\" data-align=\"inline-end\" role=\"group\" @click=${this.onAddonClick}>\n ${this.showTrigger && !(this.showClear && hasValue)\n ? html`<button\n type=\"button\"\n tabindex=\"-1\"\n data-pont2-button\n data-variant=\"ghost\"\n data-size=\"icon-xs\"\n data-slot=\"input-group-button\"\n data-combobox-trigger\n aria-label=\"Open\"\n ?disabled=${disabled}\n @mousedown=${(e: Event) => e.preventDefault()}\n @click=${this.onTrigger}\n >${icons.chevronDown()}</button>`\n : nothing}\n ${this.showClear && hasValue\n ? html`<button\n type=\"button\"\n data-pont2-button\n data-variant=\"ghost\"\n data-size=\"icon-xs\"\n data-slot=\"combobox-clear\"\n aria-label=\"Clear\"\n ?disabled=${disabled}\n @mousedown=${(e: Event) => e.preventDefault()}\n @click=${this.onClear}\n >${icons.x()}</button>`\n : nothing}\n </div>`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * The popup (Base UI `Combobox.Popup`, no role of its own: the list inside\n * is the listbox). Opens below the input, start-aligned, 6px away.\n *\n * @tag pont2-prim-combobox-content\n */\nexport class ComboboxContent extends PopupContent {\n static override identity = \"combobox-content\";\n static override slotName = \"combobox-content\";\n\n constructor() {\n super();\n this.side = \"bottom\";\n this.align = \"start\";\n this.sideOffset = 6;\n // Keep focus in the input while the pointer interacts with the list.\n this.addEventListener(\"mousedown\", e => e.preventDefault());\n }\n}\n\n/** Base UI `Combobox.List` (`role=listbox`). @tag pont2-prim-combobox-list */\nexport class ComboboxList extends HostElement {\n static override identity = \"combobox-list\";\n static override slotName = \"combobox-list\";\n static override role = \"listbox\";\n}\n\n/**\n * Base UI `Combobox.Item` (`role=option`), host-as-root, never focused\n * (virtual focus). The check indicator is rendered after your content when\n * selected.\n *\n * @tag pont2-prim-combobox-item\n * @attr value, label, disabled\n */\nexport class ComboboxItem extends HostElement {\n static override identity = \"combobox-item\";\n static override slotName = \"combobox-item\";\n static override role = \"option\";\n\n static override properties: PropertyDeclarations = {\n value: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n declare value: string;\n declare disabled: boolean;\n\n constructor() {\n super();\n this.value = \"\";\n this.disabled = false;\n this.addEventListener(\"pointermove\", e => {\n if (e.pointerType !== \"touch\" && !this.disabled) this.root?.highlight(this, false);\n });\n this.addEventListener(\"click\", () => {\n if (!this.disabled) this.root?.select(this);\n });\n }\n\n get root(): Combobox | null {\n return this.closest(ROOT);\n }\n get selected(): boolean {\n return !!this.root && !!this.root.value && this.root.value === this.value;\n }\n get label(): string {\n if (this.hasAttribute(\"label\")) return this.getAttribute(\"label\")!;\n let t = \"\";\n for (const n of Array.from(this.childNodes)) {\n if (n instanceof Comment) continue; // lit-html part markers\n if (n instanceof Element && n.hasAttribute(\"data-pont2-combobox-item-indicator\")) continue;\n t += n.textContent ?? \"\";\n }\n return t.trim();\n }\n\n setHighlighted(on: boolean): void {\n this.setData(\"highlighted\", on);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n ensureId(this, \"combobox-item\");\n }\n\n protected override willUpdate(): void {\n const selected = this.selected;\n this.internals.ariaSelected = String(selected);\n this.internals.ariaDisabled = this.disabled ? \"true\" : null;\n this.setData(\"selected\", selected);\n this.setData(\"disabled\", this.disabled);\n }\n\n override render() {\n return this.selected\n ? html`<span data-pont2-combobox-item-indicator data-slot=\"combobox-item-indicator\">${icons.check()}</span>`\n : nothing;\n }\n}\n\n/** Base UI `Combobox.Empty`: shown only while no item matches. @tag pont2-prim-combobox-empty */\nexport class ComboboxEmpty extends HostElement {\n static override identity = \"combobox-empty\";\n static override slotName = \"combobox-empty\";\n override connectedCallback(): void {\n super.connectedCallback();\n // Announced politely when it appears (Base UI renders it with role=status).\n this.internals.role = \"status\";\n this.internals.ariaLive = \"polite\";\n }\n}\n\n/** Base UI `Combobox.Group`. @tag pont2-prim-combobox-group */\nexport class ComboboxGroup extends HostElement {\n static override identity = \"combobox-group\";\n static override slotName = \"combobox-group\";\n static override role = \"group\";\n override connectedCallback(): void {\n super.connectedCallback();\n queueMicrotask(() => {\n const label = this.querySelector(`:scope > ${sel(\"combobox-label\")}`);\n if (label && !this.hasAttribute(\"aria-labelledby\")) this.setAttribute(\"aria-labelledby\", ensureId(label, \"combobox-group-label\"));\n });\n }\n}\n\n/** Base UI `Combobox.GroupLabel`. @tag pont2-prim-combobox-label */\nexport class ComboboxLabel extends HostElement {\n static override identity = \"combobox-label\";\n static override slotName = \"combobox-label\";\n}\n\n/** Base UI `Combobox.Separator`; is-a Separator. @tag pont2-prim-combobox-separator */\nexport class ComboboxSeparator extends Separator {\n static override identity = \"combobox-separator\";\n static override slotName = \"combobox-separator\";\n}\n\ndefine(\"pont2-prim-combobox\", Combobox);\ndefine(\"pont2-prim-combobox-input\", ComboboxInput);\ndefine(\"pont2-prim-combobox-content\", ComboboxContent);\ndefine(\"pont2-prim-combobox-list\", ComboboxList);\ndefine(\"pont2-prim-combobox-item\", ComboboxItem);\ndefine(\"pont2-prim-combobox-empty\", ComboboxEmpty);\ndefine(\"pont2-prim-combobox-group\", ComboboxGroup);\ndefine(\"pont2-prim-combobox-label\", ComboboxLabel);\ndefine(\"pont2-prim-combobox-separator\", ComboboxSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-combobox\": Combobox;\n \"pont2-prim-combobox-input\": ComboboxInput;\n \"pont2-prim-combobox-content\": ComboboxContent;\n \"pont2-prim-combobox-list\": ComboboxList;\n \"pont2-prim-combobox-item\": ComboboxItem;\n \"pont2-prim-combobox-empty\": ComboboxEmpty;\n \"pont2-prim-combobox-group\": ComboboxGroup;\n \"pont2-prim-combobox-label\": ComboboxLabel;\n \"pont2-prim-combobox-separator\": ComboboxSeparator;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { ensureId } from \"../../core/ids\";\nimport { define, sel, tags } from \"../../core/names\";\nimport { PopupContent } from \"../../core/popup/popup-content\";\nimport { ownQuery, PopupRoot, PopupTrigger } from \"../../core/popup/popup-root\";\n\nconst ROOT = sel(\"tooltip\");\n\n/**\n * # Tooltip\n *\n * shadcn: `<TooltipProvider delay={0}>` > `<Tooltip>` (Base UI `Tooltip.Root`,\n * renders nothing) > `<TooltipTrigger>` (a `<button>`) + `<TooltipContent>`\n * (Portal > Positioner > Popup > children + `<Tooltip.Arrow>`).\n *\n * pont2: no Provider (a per-root `delay`, default 0 like shadcn's provider);\n * the arrow is the content's `::before`, so the popup is one node.\n *\n * ```html\n * <pont2-prim-tooltip>\n * <pont2-prim-tooltip-trigger><button data-pont2-button data-variant=\"outline\">Hover</button></pont2-prim-tooltip-trigger>\n * <pont2-prim-tooltip-content>Add to library</pont2-prim-tooltip-content>\n * </pont2-prim-tooltip>\n * ```\n *\n * Opens on pointer hover and on keyboard focus; closes on leave, blur,\n * Escape or press. The trigger is described by the content\n * (`aria-describedby`) while it is open.\n *\n * @tag pont2-prim-tooltip\n * @attr delay - ms before opening on hover (default 0)\n * @attr close-delay - ms before closing (default 0)\n */\nexport class Tooltip extends PopupRoot {\n static override identity = \"tooltip\";\n\n static override properties: PropertyDeclarations = {\n delay: { type: Number },\n closeDelay: { type: Number, attribute: \"close-delay\" },\n };\n declare delay: number;\n declare closeDelay: number;\n\n private timer = 0;\n\n constructor() {\n super();\n this.delay = 0;\n this.closeDelay = 0;\n }\n\n get triggerElement(): HTMLElement | null {\n return ownQuery<TooltipTrigger>(this, tags(\"tooltip-trigger\"), ROOT)?.control ?? null;\n }\n get contentElement(): TooltipContent | null {\n return ownQuery<TooltipContent>(this, sel(\"tooltip-content\"), ROOT);\n }\n protected get popupKind() {\n return \"true\" as const;\n }\n\n /** A tooltip is not a popup the trigger \"has\": no aria-haspopup/expanded, just a description. */\n override wire(): void {\n const content = this.contentElement;\n const trigger = this.triggerElement;\n if (content) {\n ensureId(content, \"tooltip\");\n content.onRequestClose = reason => this.setOpen(false, reason);\n content.anchorElement = () => this.triggerElement;\n content.insideElements = () => [];\n }\n if (trigger && content) {\n const ids = new Set((trigger.getAttribute(\"aria-describedby\") ?? \"\").split(/\\s+/).filter(Boolean));\n if (this.open) ids.add(content.id);\n else ids.delete(content.id);\n if (ids.size) trigger.setAttribute(\"aria-describedby\", [...ids].join(\" \"));\n else trigger.removeAttribute(\"aria-describedby\");\n trigger.toggleAttribute(\"data-popup-open\", this.open);\n }\n }\n\n schedule(open: boolean, reason: \"trigger-hover\" | \"trigger-focus\" | \"focus-out\"): void {\n clearTimeout(this.timer);\n const ms = open ? this.delay : this.closeDelay;\n if (ms <= 0) this.setOpen(open, reason);\n else this.timer = window.setTimeout(() => this.setOpen(open, reason), ms);\n }\n\n // Focus stays where it is: a tooltip never takes focus.\n protected override afterClose(): void {}\n}\n\n/** @tag pont2-prim-tooltip-trigger */\nexport class TooltipTrigger extends PopupTrigger {\n static override rootTag = ROOT;\n static override controlSlot = \"tooltip-trigger\";\n\n constructor() {\n super();\n this.addEventListener(\"pointerenter\", e => {\n if (e.pointerType !== \"touch\") (this.root as Tooltip | null)?.schedule(true, \"trigger-hover\");\n });\n this.addEventListener(\"pointerleave\", () => (this.root as Tooltip | null)?.schedule(false, \"trigger-hover\"));\n this.addEventListener(\"focusin\", e => {\n if ((e.target as Element).matches(\":focus-visible\")) (this.root as Tooltip | null)?.schedule(true, \"trigger-focus\");\n });\n this.addEventListener(\"focusout\", () => (this.root as Tooltip | null)?.schedule(false, \"focus-out\"));\n }\n\n /** Pressing the trigger closes the tooltip (Base UI), it never toggles it open. */\n protected override onClick(): void {\n const root = this.root;\n if (root?.open) root.setOpen(false, \"trigger-press\");\n }\n}\n\n/**\n * The tooltip popup (`role=tooltip`), `side=\"top\"` by default.\n *\n * @tag pont2-prim-tooltip-content\n * @cssprop --pont2-tooltip-bg, --pont2-tooltip-fg, --pont2-tooltip-radius - see docs/11-tokens.md (the arrow shares the background)\n * @cssprop --pont2-tooltip-max-width, --pont2-tooltip-padding-x, --pont2-tooltip-padding-y - sizes (defaults 20rem, 0.75rem, 0.375rem)\n */\nexport class TooltipContent extends PopupContent {\n static override identity = \"tooltip-content\";\n static override slotName = \"tooltip-content\";\n static override role = \"tooltip\";\n\n constructor() {\n super();\n this.side = \"top\";\n this.align = \"center\";\n this.sideOffset = 4;\n }\n}\n\ndefine(\"pont2-prim-tooltip\", Tooltip);\ndefine(\"pont2-prim-tooltip-trigger\", TooltipTrigger);\ndefine(\"pont2-prim-tooltip-content\", TooltipContent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-prim-tooltip\": Tooltip;\n \"pont2-prim-tooltip-trigger\": TooltipTrigger;\n \"pont2-prim-tooltip-content\": TooltipContent;\n }\n}\n\n","import { defineAlias } from \"../core/names\";\nimport { Badge } from \"../primitives/badge/badge\";\nimport { Pont2Button } from \"../primitives/button/button\";\nimport { Checkbox } from \"../primitives/checkbox/checkbox\";\nimport { Pont2Input } from \"../primitives/input/input\";\nimport { Kbd, KbdGroup } from \"../primitives/kbd/kbd\";\nimport { Pont2Label } from \"../primitives/label/label\";\nimport { NativeSelect } from \"../primitives/native-select/native-select\";\nimport { Separator } from \"../primitives/separator/separator\";\nimport { Skeleton } from \"../primitives/skeleton/skeleton\";\nimport { Slider } from \"../primitives/slider/slider\";\nimport { Spinner } from \"../primitives/spinner/spinner\";\nimport { Switch } from \"../primitives/switch/switch\";\nimport { Table } from \"../primitives/table/table\";\nimport { Pont2Textarea } from \"../primitives/textarea/textarea\";\n\n/**\n * # Kit aliases: primitives promoted to the kit surface unchanged\n *\n * Each line gives a primitive a second tag without the `prim` segment.\n * The alias is an empty subclass (see `defineAlias`), so it behaves, styles,\n * announces and submits exactly like the primitive.\n *\n * What may be aliased (docs/10-primitives-and-kit.md, \"Promotion rules\"):\n *\n * 1. **Whole families only.** Every tag a primitive folder defines is aliased\n * together, so kit markup never mixes `pont2-*` and `pont2-prim-*`.\n * 2. **Only families that can never get a same-name composite**, because\n * turning an alias into a composite later is a breaking change. In\n * practice: families with no structural children to abstract (a button,\n * an input, a switch). A family with title/description/item children\n * (Card, Field, Select…) stays primitive-only until it is decided whether\n * it gets a composite.\n * 3. The alias tag is listed in the primitive's CSS selectors, so it is\n * styled before upgrade like the primitive tag (guardrail-checked).\n */\ndefineAlias(\"pont2-badge\", Badge);\ndefineAlias(\"pont2-button\", Pont2Button);\ndefineAlias(\"pont2-checkbox\", Checkbox);\ndefineAlias(\"pont2-input\", Pont2Input);\ndefineAlias(\"pont2-kbd\", Kbd);\ndefineAlias(\"pont2-kbd-group\", KbdGroup);\ndefineAlias(\"pont2-label\", Pont2Label);\ndefineAlias(\"pont2-native-select\", NativeSelect);\ndefineAlias(\"pont2-separator\", Separator);\ndefineAlias(\"pont2-skeleton\", Skeleton);\ndefineAlias(\"pont2-slider\", Slider);\ndefineAlias(\"pont2-spinner\", Spinner);\ndefineAlias(\"pont2-switch\", Switch);\ndefineAlias(\"pont2-table\", Table);\ndefineAlias(\"pont2-textarea\", Pont2Textarea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-badge\": Badge;\n \"pont2-button\": Pont2Button;\n \"pont2-checkbox\": Checkbox;\n \"pont2-input\": Pont2Input;\n \"pont2-kbd\": Kbd;\n \"pont2-kbd-group\": KbdGroup;\n \"pont2-label\": Pont2Label;\n \"pont2-native-select\": NativeSelect;\n \"pont2-separator\": Separator;\n \"pont2-skeleton\": Skeleton;\n \"pont2-slider\": Slider;\n \"pont2-spinner\": Spinner;\n \"pont2-switch\": Switch;\n \"pont2-table\": Table;\n \"pont2-textarea\": Pont2Textarea;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { Alert, AlertDescription, AlertTitle } from \"../../primitives/alert/alert\";\n\nexport const ALERT_STATUSES = [\"default\", \"error\", \"warning\", \"success\", \"info\"] as const;\nexport type AlertStatus = (typeof ALERT_STATUSES)[number];\n\nconst STATUS_ICON: Record<AlertStatus, () => TemplateResult> = {\n default: icons.circleAlert,\n error: icons.circleX,\n warning: icons.triangleAlert,\n success: icons.circleCheck,\n info: icons.info,\n};\n\n/**\n * # `<pont2-alert>`: kit composite over `<pont2-prim-alert>`\n *\n * The props-driven form of shadcn's Alert, and pont2's version of the legacy\n * `pont-alert` (which composed `pont-callout`, the legacy shadcn alert).\n *\n * ```html\n * <pont2-alert status=\"error\" icon heading=\"Payment failed\"\n * description=\"Check your card details and try again.\"></pont2-alert>\n * ```\n *\n * renders exactly the DOM the primitive form produces:\n *\n * ```html\n * <pont2-alert data-pont2-alert data-slot=\"alert\" data-variant=\"destructive\" data-status=\"error\">\n * <svg …/>\n * <div data-pont2-alert-title data-slot=\"alert-title\">Payment failed</div>\n * <div data-pont2-alert-description data-slot=\"alert-description\">Check your…</div>\n * </pont2-alert>\n * ```\n *\n * - **It is a primitive Alert** (`extends Alert`): same identity, slot, recipe\n * and `variant`. Title and description are rendered as *parts* (plain divs\n * with the primitive's attributes), not nested elements.\n * - **What it adds** over shadcn: `status` (`error` maps to shadcn's\n * `destructive` variant; `warning`/`success`/`info` are coloured in\n * `@layer pont2.kit` with the `--pont2-sem-color-success|warning|info` tokens), a\n * status icon, and a status-appropriate role (`alert` for error/warning,\n * `status` otherwise, as the legacy `pont-alert` did). An author `role`\n * attribute still wins.\n * - **What it leaves out:** rich content (links, an action button). Use the\n * primitive form for those; a composite ignores author children.\n *\n * `heading` instead of `title`: `title` is a global HTML attribute that shows\n * a native tooltip, so the attribute would leak onto the whole alert.\n *\n * @tag pont2-alert\n * @attr status - default | error | warning | success | info\n * @attr heading - the alert title text\n * @attr description - the description text\n * @attr icon - show the status icon\n * @cssprop --pont2-alert-warning-fg, --pont2-alert-success-fg, --pont2-alert-info-fg - status colours (default the sem status colours)\n */\nexport class KitAlert extends Alert {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n status: { type: String, reflect: true },\n heading: { type: String },\n description: { type: String },\n icon: { type: Boolean, reflect: true },\n };\n\n declare status: AlertStatus;\n declare heading: string;\n declare description: string;\n declare icon: boolean;\n\n constructor() {\n super();\n this.status = \"default\";\n this.heading = \"\";\n this.description = \"\";\n this.icon = false;\n }\n\n protected override willUpdate(): void {\n const status = ALERT_STATUSES.includes(this.status) ? this.status : \"default\";\n // The primitive's `variant` stays its public styling contract; status drives it.\n this.variant = status === \"error\" ? \"destructive\" : \"default\";\n super.willUpdate();\n this.setData(\"status\", status);\n this.internals.role = status === \"error\" || status === \"warning\" ? \"alert\" : \"status\";\n }\n\n protected override render() {\n const status = ALERT_STATUSES.includes(this.status) ? this.status : \"default\";\n return html`${this.icon ? STATUS_ICON[status]() : nothing}${this.heading\n ? html`<div ${AlertTitle.part()}>${this.heading}</div>`\n : nothing}${this.description ? html`<div ${AlertDescription.part()}>${this.description}</div>` : nothing}`;\n }\n}\n\ndefine(\"pont2-alert\", KitAlert);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-alert\": KitAlert;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { Avatar, AvatarBadge, AvatarFallback } from \"../../primitives/avatar/avatar\";\n\n/** \"Ada Lovelace\" → \"AL\", \"ada\" → \"A\". At most two letters, upper-cased. */\nexport function initials(name: string): string {\n const words = name.trim().split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0], words[words.length - 1]] : words;\n return letters.map(w => Array.from(w)[0] ?? \"\").join(\"\").toLocaleUpperCase();\n}\n\n/**\n * # `<pont2-avatar>`: kit composite over `<pont2-prim-avatar>`\n *\n * ```html\n * <pont2-avatar src=\"/u/42.png\" alt=\"Ada Lovelace\" badge></pont2-avatar>\n * ```\n *\n * renders the primitive's DOM:\n *\n * ```html\n * <pont2-avatar data-pont2-avatar data-slot=\"avatar\" data-size=\"default\" data-image-loading-status=\"loaded\">\n * <img src=\"/u/42.png\" alt=\"Ada Lovelace\" data-pont2-avatar-image data-slot=\"avatar-image\">\n * <span data-pont2-avatar-fallback data-slot=\"avatar-fallback\">AL</span>\n * <span data-pont2-avatar-badge data-slot=\"avatar-badge\"></span>\n * </pont2-avatar>\n * ```\n *\n * - **It is a primitive Avatar** (`extends Avatar`): the primitive watches the\n * rendered `<img>` and swaps image and fallback on\n * `data-image-loading-status` as usual.\n * - **Fallback text:** `fallback`, else the initials of `alt`. When `alt` is\n * set the fallback is announced as an image named by `alt` (not as \"AL\"):\n * only one of image and fallback is ever displayed, so nothing is read twice.\n * - **Badge:** `badge` shows shadcn's status dot. For an icon inside the\n * badge, use the primitive form.\n *\n * @tag pont2-avatar\n * @attr src - image URL (no image is rendered without it)\n * @attr alt - image alternative text; also the source of the default initials\n * @attr fallback - fallback text (defaults to the initials of `alt`)\n * @attr size - default | sm | lg (primitive)\n * @attr badge - show the badge dot\n */\nexport class KitAvatar extends Avatar {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n src: { type: String },\n alt: { type: String },\n fallback: { type: String },\n badge: { type: Boolean, reflect: true },\n };\n\n declare src: string;\n declare alt: string;\n declare fallback: string;\n declare badge: boolean;\n\n constructor() {\n super();\n this.src = \"\";\n this.alt = \"\";\n this.fallback = \"\";\n this.badge = false;\n }\n\n protected override render() {\n const text = this.fallback || initials(this.alt);\n return html`${this.src ? html`<img src=${this.src} alt=${this.alt} />` : nothing}<span\n ${AvatarFallback.part(this.alt ? { role: \"img\", \"aria-label\": this.alt } : {})}\n >${text}</span\n >${this.badge ? html`<span ${AvatarBadge.part()}></span>` : nothing}`;\n }\n}\n\ndefine(\"pont2-avatar\", KitAvatar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-avatar\": KitAvatar;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { InputOTP, InputOTPGroup, InputOTPSeparator } from \"../../primitives/input-otp/input-otp\";\n\n/** `groupSizes(6, 3)` → `[3, 3]`; `groupSizes(7, 3)` → `[3, 3, 1]`; size ≤ 0 → one group. */\nexport function groupSizes(length: number, size: number): number[] {\n const n = Math.max(0, Math.floor(length));\n const g = Math.floor(size);\n if (!(g > 0) || g >= n) return n ? [n] : [];\n const out: number[] = [];\n for (let left = n; left > 0; left -= g) out.push(Math.min(g, left));\n return out;\n}\n\n/**\n * The slot structure for `length` characters: groups of `groupSize` (one group\n * when 0), separators between groups when `separator`. Groups and separators\n * are parts; slots are `pont2-prim-input-otp-slot` elements (they have\n * behaviour). Shared with the OTP field (kit/otp-field).\n */\nexport function otpGroups(length: number, groupSize: number, separator: boolean) {\n let index = 0;\n return groupSizes(length, groupSize).map((n, g) => {\n const slots = Array.from({ length: n }, () => {\n const i = index++;\n return html`<pont2-prim-input-otp-slot index=${i}></pont2-prim-input-otp-slot>`;\n });\n const sep = g > 0 && separator ? html`<div ${InputOTPSeparator.part()}>${icons.minus()}</div>` : nothing;\n return html`${sep}<div ${InputOTPGroup.part()}>${slots}</div>`;\n });\n}\n\n/**\n * # `<pont2-input-otp>`: kit composite over `<pont2-prim-input-otp>`\n *\n * ```html\n * <pont2-input-otp name=\"code\" maxlength=\"6\" group-size=\"3\" separator aria-label=\"Verification code\"></pont2-input-otp>\n * ```\n *\n * renders the primitive's DOM, which is shadcn's:\n *\n * ```html\n * <pont2-input-otp data-pont2-input-otp …>\n * <div data-pont2-input-otp-group data-slot=\"input-otp-group\">\n * <pont2-prim-input-otp-slot index=\"0\"></pont2-prim-input-otp-slot> ×3\n * </div>\n * <div data-pont2-input-otp-separator data-slot=\"input-otp-separator\" role=\"separator\"><svg/></div>\n * <div data-pont2-input-otp-group …> …×3 </div>\n * <div data-pont2-input-otp-input-wrapper><input data-slot=\"input-otp\" autocomplete=\"one-time-code\" …></div>\n * </pont2-input-otp>\n * ```\n *\n * - **It is a primitive InputOTP** (`extends InputOTP`): the one native input,\n * form participation, paste cleaning, `pont2-complete` and every primitive\n * attribute (`maxlength`, `pattern`, `value`, `name`, `required`,\n * `disabled`, `aria-*`) work unchanged.\n * - **What it adds:** the slots are generated from `maxlength`, split into\n * groups of `group-size` (one group when absent), with a separator between\n * groups when `separator` is set.\n * - Groups and separators are **parts** (plain divs). Slots are rendered as\n * `pont2-prim-input-otp-slot` **elements**, because each slot has behaviour\n * (it draws its character and the fake caret from state the root pushes in).\n *\n * @tag pont2-input-otp\n * @attr group-size - characters per group (default: all in one group)\n * @attr separator - draw a separator between groups\n */\nexport class KitInputOTP extends InputOTP {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n groupSize: { type: Number, attribute: \"group-size\" },\n separator: { type: Boolean },\n };\n\n declare groupSize: number;\n declare separator: boolean;\n\n constructor() {\n super();\n this.groupSize = 0;\n this.separator = false;\n }\n\n override render() {\n // The primitive renders the native input last, where input-otp puts it.\n return html`${otpGroups(this.maxLength, this.groupSize, this.separator)}${super.render()}`;\n }\n}\n\ndefine(\"pont2-input-otp\", KitInputOTP);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-input-otp\": KitInputOTP;\n }\n}\n","import { html, svg, type SVGTemplateResult } from \"lit\";\n\nimport { attrs, type AttrMap } from \"../../core/attrs\";\n\n/**\n * Sign-in providers: display names and brand marks.\n *\n * The marks are Simple Icons (https://simpleicons.org, CC0-1.0), the same\n * geometry the legacy kit ships (src/components/renderers/auth/button/\n * button.defs.ts). pont2 keeps its own copy because it imports nothing from\n * the legacy kit (docs/08-parallel-constraints.md).\n */\nexport const AUTH_PROVIDERS = [\"apple\", \"discord\", \"facebook\", \"github\", \"google\", \"linkedin\", \"meta\", \"microsoft\", \"x\"] as const;\nexport type AuthProvider = (typeof AUTH_PROVIDERS)[number];\n\nexport const PROVIDER_NAMES: Record<AuthProvider, string> = {\n apple: \"Apple\",\n discord: \"Discord\",\n facebook: \"Facebook\",\n github: \"GitHub\",\n google: \"Google\",\n linkedin: \"LinkedIn\",\n meta: \"Meta\",\n microsoft: \"Microsoft\",\n x: \"X\",\n};\n\nconst MARKS: Record<AuthProvider, SVGTemplateResult> = {\n apple: svg`<path d=\"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701\" />`,\n discord: svg`<path d=\"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z\" />`,\n facebook: svg`<path d=\"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z\" />`,\n github: svg`<path d=\"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\" />`,\n google: svg`<path d=\"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z\" />`,\n linkedin: svg`<path d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z\" />`,\n meta: svg`<path d=\"M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z\" />`,\n microsoft: svg`<path d=\"M11.4 24H0V12.6h11.4V24zM24 24H12.6V12.6H24V24zM11.4 11.4H0V0h11.4v11.4zM24 11.4H12.6V0H24v11.4z\" />`,\n x: svg`<path d=\"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.763l7.726-8.835L1.254 2.25H8.08l4.713 6.231 5.45-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z\" />`,\n};\n\nexport const isAuthProvider = (p: unknown): p is AuthProvider => AUTH_PROVIDERS.includes(p as AuthProvider);\n\n/** A provider's brand mark as an `<svg>` (filled with `currentColor`, aria-hidden). */\nexport function providerIcon(provider: AuthProvider, extra: AttrMap = {}) {\n return html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n data-provider-icon=${provider}\n ${attrs(extra)}\n >${MARKS[provider]}</svg>`;\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { ButtonBase, type ButtonOptions } from \"../../primitives/button/button\";\nimport { Spinner } from \"../../primitives/spinner/spinner\";\nimport { PROVIDER_NAMES, isAuthProvider, providerIcon, type AuthProvider } from \"./providers\";\n\nexport { AUTH_PROVIDERS, PROVIDER_NAMES, providerIcon, type AuthProvider } from \"./providers\";\n\n/** What the button shows: the legacy kit's `content` prop. */\nexport const AUTH_BUTTON_CONTENTS = [\"label\", \"icon-label\", \"icon\"] as const;\nexport type AuthButtonContent = (typeof AUTH_BUTTON_CONTENTS)[number];\nexport type AuthButtonIconAlign = \"start\" | \"end\";\n\n/**\n * # AuthButton: the shared base of the auth-flow buttons\n *\n * An auth button **is a Button** (`extends ButtonBase`: variant, size,\n * disabled, type… inherited, nothing forwarded) and **has action behaviour**\n * (`ActionController`: the `pont2-action` request/response protocol, see\n * core/controllers/action.ts). Its DOM is the button primitive's:\n *\n * ```html\n * <pont2-provider-button provider=\"google\" data-pont2-shell> ← display: contents\n * <button data-pont2-button data-slot=\"button\" data-variant=\"outline\" data-provider=\"google\" type=\"button\">\n * <svg data-icon=\"inline-start\" …/>Continue with Google\n * </button>\n * </pont2-provider-button>\n * ```\n *\n * Two nodes; the legacy `pont-provider-button > pont-button > button` has three.\n *\n * While busy (a `respondWith()` promise is pending, or `loading` is set) the\n * button shows a spinner in place of its icon, sets `aria-busy`, and is\n * disabled *focusably* (`aria-disabled`, Base UI's `focusableWhenDisabled`),\n * so keyboard focus is not lost mid-request and a second press is ignored.\n *\n * Subclasses provide the default copy, the icon, and what a press does.\n */\nexport abstract class AuthButton extends ButtonBase {\n static override composite = true;\n\n // Lit merges these with ButtonBase's (variant, size, disabled, type …).\n static override properties: PropertyDeclarations = {\n content: { type: String },\n iconAlign: { type: String, attribute: \"icon-align\" },\n label: { type: String },\n event: { type: String },\n loading: { type: Boolean, reflect: true },\n };\n\n /**\n * `label` (default), `icon-label` or `icon` (icon only; the label becomes the\n * accessible name). Icon-only keeps the text size, as shadcn's login blocks\n * do: at the default size it is already near-square (38×36px, as shadcn's),\n * and it can still stretch to fill a grid cell (`w-full`). Set\n * `size=\"icon\"` for a fixed square.\n */\n declare content: AuthButtonContent;\n declare iconAlign: AuthButtonIconAlign;\n /** Visible text (and accessible name). Each button has a default. */\n declare label: string;\n /** The action requested on press (a login-flow event id). */\n declare event: string | undefined;\n /** Busy state set by the owner, in addition to a pending `respondWith()`. */\n declare loading: boolean;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.content = \"label\";\n this.iconAlign = \"start\";\n this.label = \"\";\n this.event = undefined;\n this.loading = false;\n }\n\n /** True while a request is pending or `loading` is set. */\n get busy(): boolean {\n return this.loading || this.action.busy;\n }\n\n /** The text used when `label` is empty. */\n protected abstract defaultLabel(): string;\n /** The button's icon, with the attributes shadcn's button CSS keys on. */\n protected abstract renderIcon(attrs: Record<string, string>): TemplateResult | typeof nothing;\n /** Data sent with the `pont2-action` request. */\n protected actionData(): Record<string, unknown> {\n return {};\n }\n /** What a press does. The default requests the action. */\n protected onPress(_e: MouseEvent): void {\n this.action.request(this.event, this.actionData());\n }\n\n protected get text(): string {\n return this.label || this.defaultLabel();\n }\n\n protected override buttonOptions(): ButtonOptions {\n const base = super.buttonOptions();\n const iconOnly = this.content === \"icon\";\n const busy = this.busy;\n return {\n ...base,\n disabled: base.disabled || busy,\n // Busy is a transient disabled state: keep focus where the user left it.\n focusableWhenDisabled: base.focusableWhenDisabled || (busy && !base.disabled),\n attrs: {\n \"data-event\": this.event,\n \"data-loading\": busy,\n \"aria-busy\": busy ? \"true\" : null,\n \"aria-label\": iconOnly ? this.text : null,\n ...this.extraAttrs(),\n },\n onClick: e => this.onPress(e),\n };\n }\n\n /** Extra attributes for the native button (`data-provider` …). */\n protected extraAttrs(): Record<string, string | boolean | null | undefined> {\n return {};\n }\n\n protected override renderContent() {\n const showIcon = this.content !== \"label\";\n const showLabel = this.content !== \"icon\";\n // The icon slot holds the spinner while busy, even for label-only buttons.\n const slot = this.content === \"icon\" ? null : this.iconAlign === \"end\" ? \"inline-end\" : \"inline-start\";\n const mark = (a: Record<string, string>) =>\n this.busy\n ? html`<span ${Spinner.part({ ...a, role: false, \"aria-hidden\": \"true\" })}></span>`\n : showIcon\n ? this.renderIcon(a)\n : nothing;\n const icon = mark(slot ? { \"data-icon\": slot } : {});\n return this.iconAlign === \"end\"\n ? html`${showLabel ? this.text : nothing}${icon}`\n : html`${icon}${showLabel ? this.text : nothing}`;\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-provider-button>`: sign in with an identity provider\n *\n * ```html\n * <pont2-provider-button provider=\"google\" event=\"oauth_google\"></pont2-provider-button>\n * ```\n *\n * Defaults: `variant=\"outline\"`, `content=\"icon-label\"`, label\n * \"`prompt` + provider name\" (\"Continue with Google\"). Pressing requests\n * `event` with `{ provider }` (see AuthButton).\n *\n * @tag pont2-provider-button\n * @attr provider - apple | discord | facebook | github | google | linkedin | meta | microsoft | x\n * @attr prompt - text before the provider name in the default label (default \"Continue with\")\n * @attr label - replaces the whole default label\n * @attr event - the action requested on press\n * @attr content - label | icon-label (default) | icon\n * @attr icon-align - start (default) | end\n * @attr loading - busy state set by the owner\n * @fires pont2-action - `{ action, data: { provider }, respondWith }` on press\n * @fires pont2-action-success - `{ action, data, result }`\n * @fires pont2-action-error - `{ action, data, error, message }`\n */\nexport class ProviderButton extends AuthButton {\n static override properties: PropertyDeclarations = {\n provider: { type: String, reflect: true },\n prompt: { type: String },\n };\n\n declare provider: AuthProvider;\n declare prompt: string;\n\n constructor() {\n super();\n this.variant = \"outline\";\n this.content = \"icon-label\";\n this.prompt = \"Continue with\";\n }\n\n protected defaultLabel(): string {\n const name = isAuthProvider(this.provider) ? PROVIDER_NAMES[this.provider] : (this.provider ?? \"\");\n return `${this.prompt || \"Continue with\"} ${name}`.trim();\n }\n\n protected renderIcon(a: Record<string, string>) {\n return isAuthProvider(this.provider) ? providerIcon(this.provider, a) : nothing;\n }\n\n protected override actionData() {\n return { provider: this.provider };\n }\n\n protected override extraAttrs() {\n return { \"data-provider\": this.provider };\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-passkey-button>`: sign in with a passkey\n *\n * ```html\n * <pont2-passkey-button event=\"passkey_login\"></pont2-passkey-button>\n * ```\n *\n * Defaults: `variant=\"secondary\"`, `content=\"label\"`, label \"Continue with\n * Passkey\", icon lucide `user-round-key`. Pressing requests `event`.\n *\n * The listener must start the WebAuthn call synchronously (call\n * `respondWith()` with the promise straight away). The request is dispatched\n * inside the click, so the call keeps the user activation that\n * `navigator.credentials.get()` needs in Safari.\n *\n * @tag pont2-passkey-button\n * @attr label, event, content, icon-align, loading - see ProviderButton\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class PasskeyButton extends AuthButton {\n constructor() {\n super();\n this.variant = \"secondary\";\n }\n\n protected defaultLabel(): string {\n return \"Continue with Passkey\";\n }\n\n protected renderIcon(a: Record<string, string>) {\n return icons.userRoundKey(a);\n }\n}\n\n/* ==================================================================== */\n\n/**\n * # `<pont2-submit-button>`: submit an auth form\n *\n * ```html\n * <form>\n * …fields…\n * <pont2-submit-button event=\"submit_password\"></pont2-submit-button>\n * </form>\n * ```\n *\n * A real `<button type=\"submit\">`, so the browser's own submission rules\n * apply: Enter in a field submits, constraint validation (`required`,\n * `type=\"email\"` …) blocks an invalid form, and `SubmitEvent.submitter` is\n * this button.\n *\n * When its form **submits** (not merely when it is clicked), the button\n * requests `event` with `{ form, formData }` (the FormData includes this\n * button's `name`/`value`, if any):\n *\n * - a listener calls `respondWith()` → the native submission is prevented\n * (the flow is handled in-page) and the button is busy until it settles;\n * - nobody responds → the form submits natively (progressive enhancement:\n * a plain `<form action>` still works).\n *\n * A submission without a submitter (`form.requestSubmit()`, e.g. an OTP\n * auto-submit) is handled by the form's **default button** (its first submit\n * button), as the browser does for implicit submission.\n *\n * Outside a form, a press requests the action directly.\n *\n * Defaults: `variant=\"default\"`, `content=\"label\"`, `icon-align=\"end\"`,\n * label \"Submit\", icon lucide `arrow-right`.\n *\n * @tag pont2-submit-button\n * @attr label, event, content, icon-align, loading - see ProviderButton\n * @fires pont2-action - `{ action, data: { form, formData }, respondWith }` on submit\n * @fires pont2-action-success, pont2-action-error\n */\nexport class SubmitButton extends AuthButton {\n constructor() {\n super();\n this.type = \"submit\";\n this.iconAlign = \"end\";\n }\n\n protected defaultLabel(): string {\n return \"Submit\";\n }\n\n protected renderIcon(a: Record<string, string>) {\n return icons.arrowRight(a);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Capture on the document: runs before the form's own submit listeners,\n // and catches implicit submission (Enter) where this is the default button.\n document.addEventListener(\"submit\", this.onSubmit, true);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"submit\", this.onSubmit, true);\n }\n\n protected override onPress(_e: MouseEvent): void {\n const c = this.control;\n // In a form, the submit event drives the request (after validation passes).\n if (c instanceof HTMLButtonElement && c.form && this.type === \"submit\") return;\n this.action.request(this.event, {});\n }\n\n private onSubmit = (e: SubmitEvent) => {\n const c = this.control;\n const form = c instanceof HTMLButtonElement ? c.form : null;\n if (!c || !form || form !== e.target) return;\n // A submit without a submitter (`form.requestSubmit()`, an OTP auto-submit)\n // belongs to the form's default button, as implicit submission does.\n const isDefault = !e.submitter && Array.from(form.elements).find(el => (el as HTMLButtonElement).type === \"submit\") === c;\n if (e.submitter !== c && !isDefault) return;\n if (this.busy) {\n e.preventDefault(); // a second submit while the first is pending\n return;\n }\n const formData = new FormData(form, c);\n if (this.action.request(this.event, { form, formData })) e.preventDefault();\n };\n}\n\ndefine(\"pont2-provider-button\", ProviderButton);\ndefine(\"pont2-passkey-button\", PasskeyButton);\ndefine(\"pont2-submit-button\", SubmitButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-provider-button\": ProviderButton;\n \"pont2-passkey-button\": PasskeyButton;\n \"pont2-submit-button\": SubmitButton;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues, type TemplateResult } from \"lit\";\n\nimport { fire } from \"../../core/events\";\nimport { uid } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { Field, FieldDescription, FieldError, fieldLabel } from \"../../primitives/field/field\";\nimport { input, type InputOptions } from \"../../primitives/input/input\";\n\n/* ==================================================================== */\n/* Messages */\n/* ==================================================================== */\n\nconst cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();\n\n/**\n * Default error copy, identical to the legacy kit's (field.defs.ts), so\n * existing screens read the same. Every message is overridable per field\n * (`required-error`, `format-error` …). Localised copy is expected from the\n * render spec / widget.\n */\nexport const fieldMessages = {\n required: (label: string) => `${cap(label)} is a required field.`,\n format: (label: string) => `Please enter a valid ${label.toLowerCase()}.`,\n minlength: (label: string, n?: number) =>\n n ? `${cap(label)} must be at least ${n} characters.` : `Please enter a longer ${label.toLowerCase()}.`,\n maxlength: (label: string, n?: number) =>\n n ? `${cap(label)} can have at most ${n} characters.` : `Please enter a shorter ${label.toLowerCase()}.`,\n};\n\n/* ==================================================================== */\n/* Types */\n/* ==================================================================== */\n\nexport type FieldIssueType = \"required\" | \"minlength\" | \"maxlength\" | \"format\" | \"rule\" | \"match\" | \"incomplete\";\n\nexport interface FieldIssue {\n type: FieldIssueType;\n message: string;\n}\n\n/** `pont2-field-validate` detail. The value is deliberately not included (passwords). */\nexport interface FieldValidateDetail {\n name: string;\n valid: boolean;\n issues: FieldIssue[];\n}\n\n/** \"default\": every rule; \"simple\": `required` only (the legacy `validation` attribute). */\nexport type FieldValidationMode = \"default\" | \"simple\";\n\n/** Compiles a pattern source, preferring Unicode mode (needed for `\\p{L}`). */\nexport function compilePattern(source: string): RegExp | null {\n if (!source) return null;\n try {\n return new RegExp(source, \"u\");\n } catch {\n try {\n return new RegExp(source);\n } catch {\n return null;\n }\n }\n}\n\n/** Positive integers only (legacy: values ≤ 0 are ignored). */\nconst positive = { fromAttribute: (v: string | null) => (v != null && Number(v) > 0 ? Number(v) : undefined) };\n\n/* The first invalid field of a validation pass takes focus (see onInvalid). */\nlet focusClaimed = false;\n\n/* ==================================================================== */\n/* AuthField */\n/* ==================================================================== */\n\n/**\n * # AuthField: the shared base of the auth-flow text fields\n *\n * An auth field **is a Field** (`extends Field`: the host is shadcn's\n * `div[role=group][data-slot=field]`, styled by the field recipe, with\n * `data-invalid` / `data-disabled`) that renders its label, control,\n * description and error from properties, as parts:\n *\n * ```html\n * <pont2-email-field data-pont2-field data-slot=\"field\" data-orientation=\"vertical\" [data-invalid]>\n * <label data-pont2-label data-pont2-field-label data-slot=\"field-label\" for=\"…-input\">Email</label>\n * <input data-pont2-input data-slot=\"input\" id=\"…-input\" name=\"email\" type=\"email\"\n * autocomplete=\"email\" aria-describedby=\"…-description …-error\" [aria-invalid=\"true\"]>\n * <p data-pont2-field-description data-slot=\"field-description\" id=\"…-description\">…</p>\n * <div data-pont2-field-error data-slot=\"field-error\" role=\"alert\" id=\"…-error\">Please enter a valid email.</div>\n * </pont2-email-field>\n * ```\n *\n * **The native `<input name>` is the form control.** There is no hidden\n * input and no form-association: the form's own FormData, autofill and\n * password managers, `form.reset()` and `<fieldset disabled>` all work\n * natively.\n *\n * **Validation is the platform's.** The field computes its issues on every\n * change and mirrors the first into `input.setCustomValidity()`, so\n * `form.checkValidity()`, `:invalid` and interactive validation are always\n * right, and the submit button never sends an invalid form. The field cancels\n * the browser's bubble (`invalid` event) and shows its own error instead.\n * Errors are **shown** after the user commits a change (`change`), when the\n * form is submitted, or on `reportValidity()`; once shown they update live\n * while typing.\n *\n * **Normalisation** (trimming, lower-casing an email…) is applied to the\n * submitted value through the form's `formdata` event, without rewriting what\n * the user sees.\n *\n * Subclasses supply defaults and rules through the protected hooks.\n *\n * @fires pont2-field-validate - `{ name, valid, issues }` whenever validity is shown (change, submit, reportValidity)\n */\nexport abstract class AuthField extends Field {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n inputId: { type: String, attribute: \"input-id\" },\n name: { type: String },\n defaultValue: { type: String, attribute: \"value\" },\n label: { type: String },\n placeholder: { type: String },\n description: { type: String },\n mark: { type: String },\n caret: { type: Boolean },\n autocomplete: { type: String },\n required: { type: Boolean, reflect: true },\n validation: { type: String },\n pattern: { type: String },\n minlength: { attribute: \"minlength\", converter: positive },\n maxlength: { attribute: \"maxlength\", converter: positive },\n requiredError: { type: String, attribute: \"required-error\" },\n formatError: { type: String, attribute: \"format-error\" },\n minlengthError: { type: String, attribute: \"minlength-error\" },\n maxlengthError: { type: String, attribute: \"maxlength-error\" },\n current: { state: true },\n shown: { state: true },\n };\n\n /** `id` of the native input (generated when absent), for `<label for>` elsewhere. */\n declare inputId: string;\n /** Form-data key. Each field has a default (`email`, `password`, `login_id` …). */\n declare name: string;\n /** Initial value (the `value` attribute, as on a native input). `.value` is live. */\n declare defaultValue: string;\n declare label: string;\n declare placeholder: string;\n declare description: string;\n /** Text after the label, e.g. \"(optional)\". */\n declare mark: string;\n /** Show a `*` after the label when `required` (and no `mark`). */\n declare caret: boolean;\n declare autocomplete: string;\n declare required: boolean;\n declare validation: FieldValidationMode;\n /** Regex source for the format rule. Each field has a default where the legacy kit had one. */\n declare pattern: string;\n declare minlength: number | undefined;\n declare maxlength: number | undefined;\n declare requiredError: string;\n declare formatError: string;\n declare minlengthError: string;\n declare maxlengthError: string;\n\n declare protected current: string;\n /** Whether issues are displayed (after change / submit / reportValidity). */\n declare protected shown: boolean;\n\n private dirty = false;\n private generatedId = uid(\"auth-field\");\n private boundForm: HTMLFormElement | null = null;\n\n constructor() {\n super();\n this.inputId = \"\";\n this.name = \"\";\n this.defaultValue = \"\";\n this.label = \"\";\n this.placeholder = \"\";\n this.description = \"\";\n this.mark = \"\";\n this.caret = false;\n this.autocomplete = \"\";\n this.required = false;\n this.validation = \"default\";\n this.pattern = \"\";\n this.minlength = undefined;\n this.maxlength = undefined;\n this.requiredError = \"\";\n this.formatError = \"\";\n this.minlengthError = \"\";\n this.maxlengthError = \"\";\n this.current = \"\";\n this.shown = false;\n }\n\n /* ---------------------------------------------------------------- */\n /* Hooks for subclasses */\n /* ---------------------------------------------------------------- */\n\n protected abstract defaultName(): string;\n protected abstract defaultLabel(): string;\n protected inputType(): string {\n return \"text\";\n }\n protected defaultAutocomplete(): string {\n return \"\";\n }\n protected defaultPattern(): string {\n return \"\";\n }\n /** Extra attributes for the input (inputmode, autocapitalize, spellcheck …). */\n protected inputAttrs(): Record<string, string | boolean | null | undefined> {\n return {};\n }\n /** The submitted form of a raw value. Identity by default. */\n normalizeValue(raw: string): string {\n return raw;\n }\n /**\n * Rules for a non-empty value, after `required`. The default is the legacy\n * order: minlength, then maxlength, then the format pattern; first failure only.\n */\n protected valueIssues(value: string): FieldIssue[] {\n const label = this.text;\n if (this.minlength && value.length < this.minlength) {\n return [{ type: \"minlength\", message: this.minlengthError || fieldMessages.minlength(label, this.minlength) }];\n }\n if (this.maxlength && value.length > Math.max(this.maxlength, this.minlength ?? 0)) {\n return [{ type: \"maxlength\", message: this.maxlengthError || fieldMessages.maxlength(label, this.maxlength) }];\n }\n const re = compilePattern(this.pattern || this.defaultPattern());\n if (re && !re.test(value)) return [{ type: \"format\", message: this.formatError || fieldMessages.format(label) }];\n return [];\n }\n\n /* ---------------------------------------------------------------- */\n /* Public API */\n /* ---------------------------------------------------------------- */\n\n /** The native input. */\n get control(): HTMLInputElement | null {\n return this.querySelector<HTMLInputElement>(`input[data-auth-field-control]`);\n }\n\n /** The normalised value (what is submitted). */\n get value(): string {\n return this.normalizeValue(this.current);\n }\n set value(v: string) {\n this.dirty = true;\n this.setCurrent(String(v ?? \"\"));\n }\n\n /** The effective form-data key. */\n get fieldName(): string {\n return this.name || this.defaultName();\n }\n\n /** The effective label text. */\n get text(): string {\n return this.label || this.defaultLabel();\n }\n\n /** Current issues (empty when valid). Independent of whether they are shown. */\n get issues(): FieldIssue[] {\n return this.computeIssues();\n }\n\n checkValidity(): boolean {\n return this.computeIssues().length === 0;\n }\n\n /** Shows the field's errors (or clears them) and returns validity. Legacy name: `validate()`. */\n reportValidity(): boolean {\n this.show();\n return this.checkValidity();\n }\n\n validate(): boolean {\n return this.reportValidity();\n }\n\n override focus(options?: FocusOptions): void {\n this.control?.focus(options);\n }\n\n /* ---------------------------------------------------------------- */\n /* Validation */\n /* ---------------------------------------------------------------- */\n\n protected computeIssues(): FieldIssue[] {\n if (this.disabled) return [];\n const value = this.normalizeValue(this.current);\n if (!value) {\n return this.required ? [{ type: \"required\", message: this.requiredError || fieldMessages.required(this.text) }] : [];\n }\n if (this.validation === \"simple\") return [];\n return this.valueIssues(value);\n }\n\n private show(): void {\n this.shown = true;\n const issues = this.computeIssues();\n fire<FieldValidateDetail>(this, \"pont2-field-validate\", { name: this.fieldName, valid: !issues.length, issues });\n }\n\n /* ---------------------------------------------------------------- */\n /* Events */\n /* ---------------------------------------------------------------- */\n\n protected onInput = (e: Event) => {\n this.dirty = true;\n this.setCurrent((e.target as HTMLInputElement).value);\n };\n\n /**\n * Sets the raw value and mirrors validity to the input **synchronously**:\n * code that submits in the same task (an OTP auto-submit, `requestSubmit()`\n * in an `input` listener) must not see the previous render's validity.\n */\n protected setCurrent(raw: string): void {\n this.current = raw;\n this.syncValidity();\n }\n\n protected syncValidity(): void {\n this.control?.setCustomValidity(this.computeIssues()[0]?.message ?? \"\");\n }\n\n protected onChange = () => this.show();\n\n private onInvalid = (e: Event) => {\n // Our inline error replaces the browser's bubble.\n e.preventDefault();\n this.show();\n if (!focusClaimed) {\n focusClaimed = true;\n this.control?.focus();\n // The pass fires one `invalid` per control, possibly with microtask\n // checkpoints in between, so release on the next task.\n setTimeout(() => (focusClaimed = false));\n }\n };\n\n private onFormData = (e: FormDataEvent) => {\n const c = this.control;\n if (!c || c.disabled || !c.name) return;\n e.formData.set(c.name, this.value);\n };\n\n protected onReset = () => {\n // `reset` fires before the controls are reset.\n setTimeout(() => {\n this.dirty = false;\n this.shown = false;\n this.current = this.control?.value ?? this.defaultValue;\n });\n };\n\n private bindForm(form: HTMLFormElement | null): void {\n if (form === this.boundForm) return;\n this.boundForm?.removeEventListener(\"formdata\", this.onFormData);\n this.boundForm?.removeEventListener(\"reset\", this.onReset);\n this.boundForm = form;\n form?.addEventListener(\"formdata\", this.onFormData);\n form?.addEventListener(\"reset\", this.onReset);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.bindForm(null);\n }\n\n /* ---------------------------------------------------------------- */\n /* Render */\n /* ---------------------------------------------------------------- */\n\n protected get controlId(): string {\n return this.inputId || `${this.id || this.generatedId}-input`;\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.dirty && (changed.has(\"defaultValue\") || !this.hasUpdated)) this.current = this.defaultValue ?? \"\";\n this.invalid = this.shown && this.computeIssues().length > 0;\n super.willUpdate(changed);\n }\n\n protected override updated(): void {\n const c = this.control;\n if (c) {\n // The platform's validity mirrors ours: blocks submission, drives :invalid.\n this.syncValidity();\n this.bindForm(c.form);\n }\n }\n\n /** Options for the control part; subclasses render it differently (password: input group). */\n protected controlOptions(describedBy: string | undefined): InputOptions {\n return {\n id: this.controlId,\n name: this.fieldName,\n type: this.inputType(),\n value: this.current,\n placeholder: this.placeholder || undefined,\n autocomplete: this.autocomplete || this.defaultAutocomplete() || undefined,\n required: this.required,\n disabled: this.disabled,\n invalid: this.invalid,\n describedBy,\n attrs: {\n \"data-auth-field-control\": true,\n // The default value, so form.reset() restores it natively.\n value: this.defaultValue || null,\n ...this.inputAttrs(),\n },\n onInput: this.onInput,\n onChange: this.onChange,\n };\n }\n\n protected renderControl(o: InputOptions): TemplateResult {\n return input(o);\n }\n\n protected renderLabel(): TemplateResult | typeof nothing {\n const mark = this.mark\n ? html`<span data-slot=\"field-mark\">${this.mark}</span>`\n : this.caret && this.required\n ? html`<span data-slot=\"field-mark\" data-caret aria-hidden=\"true\">*</span>`\n : nothing;\n return fieldLabel({ for: this.controlId }, html`${this.text}${mark}`);\n }\n\n protected renderError(id: string, issues: FieldIssue[]): TemplateResult {\n const messages = [...new Set(issues.map(i => i.message))];\n return html`<div ${FieldError.part({ id })}>${messages.length === 1\n ? messages[0]\n : html`<ul data-slot=\"field-error-list\">${messages.map(m => html`<li>${m}</li>`)}</ul>`}</div>`;\n }\n\n override render() {\n const id = this.controlId;\n const descId = `${id}-description`;\n const errId = `${id}-error`;\n const issues = this.shown ? this.computeIssues() : [];\n const describedBy = [this.description ? descId : \"\", issues.length ? errId : \"\"].filter(Boolean).join(\" \") || undefined;\n return html`${this.renderLabel()}${this.renderControl(this.controlOptions(describedBy))}${this.description\n ? html`<p ${FieldDescription.part({ id: descId })}>${this.description}</p>`\n : nothing}${issues.length ? this.renderError(errId, issues) : nothing}`;\n }\n\n /** The `invalid` event does not bubble, so it is listened to on the input itself. */\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"invalid\", this.onInvalid, true);\n }\n}\n\n/* ==================================================================== */\n/* Text fields */\n/* ==================================================================== */\n\n/**\n * `<pont2-email-field>`: `type=\"email\"`, `autocomplete=\"email\"`, name\n * `email`. Normalised to trimmed lower case. Format rule: the legacy pattern\n * `^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$`.\n *\n * @tag pont2-email-field\n */\nexport class EmailField extends AuthField {\n protected defaultName() {\n return \"email\";\n }\n protected defaultLabel() {\n return \"Email\";\n }\n protected override inputType() {\n return \"email\";\n }\n protected override defaultAutocomplete() {\n return \"email\";\n }\n protected override defaultPattern() {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.source;\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\n/**\n * `<pont2-phone-field>`: `type=\"tel\"`, `autocomplete=\"tel\"`, name `phone`.\n * Normalised by removing whitespace. Format rule: the legacy pattern.\n *\n * @tag pont2-phone-field\n */\nexport class PhoneField extends AuthField {\n protected defaultName() {\n return \"phone\";\n }\n protected defaultLabel() {\n return \"Phone\";\n }\n protected override inputType() {\n return \"tel\";\n }\n protected override defaultAutocomplete() {\n return \"tel\";\n }\n protected override defaultPattern() {\n return /^\\+?(\\d[\\d-.() ]+)?(\\([\\d-.() ]+\\))?[\\d-.() ]+\\d$/.source;\n }\n override normalizeValue(raw: string) {\n return raw.replace(/\\s+/g, \"\");\n }\n}\n\n/**\n * `<pont2-username-field>`: `autocomplete=\"username\"`, name `username`,\n * no autocapitalisation or spellcheck. Normalised to trimmed lower case.\n * Rules: `minlength`, `maxlength`, then the pattern `^[a-z0-9_]*$`.\n *\n * @tag pont2-username-field\n */\nexport class UsernameField extends AuthField {\n protected defaultName() {\n return \"username\";\n }\n protected defaultLabel() {\n return \"Username\";\n }\n protected override defaultAutocomplete() {\n return \"username\";\n }\n protected override defaultPattern() {\n return /^[a-z0-9_]*$/.source;\n }\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\n/**\n * `<pont2-name-field>`: `autocomplete=\"name\"`, name `name`. Normalised by\n * trimming and collapsing whitespace. Rules: `minlength`, `maxlength`, then\n * the Unicode pattern `^[\\p{L} .'-]*$` (letters in any script).\n *\n * @tag pont2-name-field\n */\nexport class NameField extends AuthField {\n protected defaultName() {\n return \"name\";\n }\n protected defaultLabel() {\n return \"Name\";\n }\n protected override defaultAutocomplete() {\n return \"name\";\n }\n protected override defaultPattern() {\n return /^[\\p{L} .'-]*$/u.source;\n }\n override normalizeValue(raw: string) {\n return raw.trim().replace(/\\s+/g, \" \");\n }\n}\n\nexport const IDENTIFIER_KINDS = [\"email\", \"phone\", \"username\"] as const;\nexport type IdentifierKind = (typeof IDENTIFIER_KINDS)[number];\n\n/** `[\"email\",\"phone\"]` → \"Email or phone\"; three → \"Email, phone, or username\" (legacy copy). */\nexport function identifierLabel(kinds: readonly IdentifierKind[]): string {\n if (!kinds.length) return \"Identifier\";\n const list =\n kinds.length === 1\n ? kinds[0]\n : kinds.length === 2\n ? `${kinds[0]} or ${kinds[1]}`\n : `${kinds.slice(0, -1).join(\", \")}, or ${kinds[kinds.length - 1]}`;\n return list.charAt(0).toUpperCase() + list.slice(1);\n}\n\n/**\n * `<pont2-identifier-field>`: the sign-in identifier (email, phone or\n * username), submitted as `login_id` (the platform's contract).\n *\n * `identifiers` (attribute: space- or comma-separated; property: array) picks\n * the label (\"Email or phone\") and the input type: `email` or `tel` when it\n * is exactly one of those, `text` otherwise. `autocomplete=\"username\"`, which\n * is what password managers look for next to a password. Normalised to\n * trimmed lower case. Rule: `required` only (no format), as in the legacy kit.\n *\n * @tag pont2-identifier-field\n * @attr identifiers - e.g. \"email phone username\"\n */\nexport class IdentifierField extends AuthField {\n static override properties: PropertyDeclarations = {\n identifiers: {\n converter: {\n fromAttribute: (v: string | null) =>\n (v ?? \"\")\n .split(/[\\s,]+/)\n .filter((k): k is IdentifierKind => IDENTIFIER_KINDS.includes(k as IdentifierKind)),\n },\n },\n };\n\n declare identifiers: IdentifierKind[];\n\n constructor() {\n super();\n this.identifiers = [];\n }\n\n protected defaultName() {\n return \"login_id\";\n }\n protected defaultLabel() {\n return identifierLabel(this.identifiers ?? []);\n }\n protected override inputType() {\n const k = this.identifiers ?? [];\n return k.length === 1 && k[0] === \"email\" ? \"email\" : k.length === 1 && k[0] === \"phone\" ? \"tel\" : \"text\";\n }\n protected override defaultAutocomplete() {\n return \"username\";\n }\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n protected override valueIssues() {\n return [];\n }\n override normalizeValue(raw: string) {\n return raw.trim().toLowerCase();\n }\n}\n\ndefine(\"pont2-email-field\", EmailField);\ndefine(\"pont2-phone-field\", PhoneField);\ndefine(\"pont2-username-field\", UsernameField);\ndefine(\"pont2-name-field\", NameField);\ndefine(\"pont2-identifier-field\", IdentifierField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-email-field\": EmailField;\n \"pont2-phone-field\": PhoneField;\n \"pont2-username-field\": UsernameField;\n \"pont2-name-field\": NameField;\n \"pont2-identifier-field\": IdentifierField;\n }\n interface HTMLElementEventMap {\n \"pont2-field-validate\": CustomEvent<FieldValidateDetail>;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { icons } from \"../../core/icons\";\nimport { MessagesController, msg } from \"../../core/messages\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\nimport { InputGroup, InputGroupAddon, inputGroupButton, inputGroupInput } from \"../../primitives/input-group/input-group\";\nimport type { InputOptions } from \"../../primitives/input/input\";\nimport { AuthField, fieldMessages, type FieldIssue } from \"./auth-field\";\n\n/* ==================================================================== */\n/* Password rules */\n/* ==================================================================== */\n\nexport type PasswordRuleName = \"uppercase\" | \"lowercase\" | \"number\" | \"special\";\n\n/** A rule: a named one, or your own `pattern`, each with an optional message. */\nexport type PasswordRule = { name: PasswordRuleName; error?: string } | { pattern: string; error?: string };\n\n/** The legacy named patterns (field.defs.ts). */\nexport const PASSWORD_RULE_PATTERNS: Record<PasswordRuleName, RegExp> = {\n uppercase: /[A-Z]/,\n lowercase: /[a-z]/,\n number: /[0-9]/,\n special: /[!@#$%^&*()_=+{}[\\]|\\\\;:\"<>,./?-]/,\n};\n\nexport const DEFAULT_PASSWORD_RULES: PasswordRule[] = [\n { name: \"uppercase\", error: \"Must contain an uppercase letter.\" },\n { name: \"lowercase\", error: \"Must contain a lowercase letter.\" },\n { name: \"number\", error: \"Must contain a number.\" },\n { name: \"special\", error: \"Must contain a special character.\" },\n];\n\nconst ruleRegExp = (r: PasswordRule): RegExp | null => {\n if (\"name\" in r) return PASSWORD_RULE_PATTERNS[r.name] ?? null;\n try {\n return new RegExp(r.pattern, \"u\");\n } catch {\n return null;\n }\n};\n\n/** `rules` attribute: JSON, e.g. `rules='[{\"name\":\"number\"},{\"pattern\":\".{12,}\",\"error\":\"12+ characters\"}]'`. */\nconst rulesConverter = {\n fromAttribute: (v: string | null): PasswordRule[] => {\n if (v == null) return DEFAULT_PASSWORD_RULES;\n try {\n const parsed = JSON.parse(v);\n return Array.isArray(parsed) ? parsed : DEFAULT_PASSWORD_RULES;\n } catch {\n return DEFAULT_PASSWORD_RULES;\n }\n },\n};\n\n/* ==================================================================== */\n/* SecretField: the show/hide toggle shared by password and confirm */\n/* ==================================================================== */\n\nexport type SecretFieldVariant = \"toggle\" | \"simple\";\n\n/**\n * A field whose value is secret: `type=\"password\"`, and with\n * `variant=\"toggle\"` (default) a show/hide button, built as shadcn builds it,\n * from InputGroup parts:\n *\n * ```html\n * <div data-pont2-input-group data-slot=\"input-group\" role=\"group\">\n * <input data-pont2-input data-pont2-input-group-input data-slot=\"input-group-control\" type=\"password\" …>\n * <div data-pont2-input-group-addon data-slot=\"input-group-addon\" data-align=\"inline-end\" role=\"group\">\n * <button data-pont2-button data-pont2-input-group-button data-variant=\"ghost\" data-size=\"icon-xs\"\n * aria-label=\"Show password\" aria-pressed=\"false\" aria-controls=\"…-input\"><svg/></button>\n * </div>\n * </div>\n * ```\n *\n * The toggle is a *toggle button* (`aria-pressed`, a stable name), the\n * WAI-ARIA pattern, rather than a button whose name flips. The value is\n * never normalised.\n *\n * @attr variant - toggle (default) | simple\n * @attr show-label - the toggle's accessible name (default: the `show_password` message, \"Show password\" in English)\n */\nexport abstract class SecretField extends AuthField {\n static override properties: PropertyDeclarations = {\n variant: { type: String },\n showLabel: { type: String, attribute: \"show-label\" },\n revealed: { type: Boolean, reflect: true },\n };\n\n declare variant: SecretFieldVariant;\n declare showLabel: string;\n /** Whether the value is currently shown as text. */\n declare revealed: boolean;\n\n /** Re-renders when the page's message table changes (the toggle's name). */\n protected readonly messagesController = new MessagesController(this);\n\n constructor() {\n super();\n this.variant = \"toggle\";\n this.showLabel = \"\";\n this.revealed = false;\n }\n\n protected override inputType() {\n return this.variant === \"toggle\" && this.revealed ? \"text\" : \"password\";\n }\n\n protected override inputAttrs() {\n return { autocapitalize: \"none\", spellcheck: \"false\" };\n }\n\n private toggle = () => {\n this.revealed = !this.revealed;\n // Keep the caret where it was (the input is re-rendered with a new type).\n void this.updateComplete.then(() => this.control?.focus());\n };\n\n protected override renderControl(o: InputOptions): TemplateResult {\n if (this.variant !== \"toggle\") return super.renderControl(o);\n return html`<div ${InputGroup.part({ \"data-disabled\": this.disabled })}>\n ${inputGroupInput(o)}\n <div ${InputGroupAddon.part({ \"data-align\": \"inline-end\" })}>\n ${inputGroupButton(\n {\n size: \"icon-xs\",\n disabled: this.disabled,\n attrs: {\n \"aria-label\": this.showLabel || msg(\"show_password\"),\n \"aria-pressed\": String(this.revealed),\n \"aria-controls\": this.controlId,\n },\n onClick: this.toggle,\n },\n this.revealed ? icons.eyeOff() : icons.eye(),\n )}\n </div>\n </div>`;\n }\n}\n\n/* ==================================================================== */\n/* PasswordField */\n/* ==================================================================== */\n\n/**\n * # `<pont2-password-field>`\n *\n * `autocomplete=\"current-password\"` by default (set `new-password` on\n * sign-up screens), name `password`. Rules: `minlength`, `maxlength`, then\n * **every** `rules` entry; all failing rules are listed (shadcn's FieldError\n * list). Defaults are the legacy four: uppercase, lowercase, number, special.\n *\n * `forgot` adds a \"Forgot your password?\" link-styled button beside the label\n * (shadcn's login block layout). It requests `forgot-event` through the\n * action protocol (`pont2-action` with `data: { forgot: true }`), exactly\n * like the auth buttons, and is busy until the response settles.\n *\n * @tag pont2-password-field\n * @attr rules - JSON array of `{ name }` / `{ pattern }` rules with optional `error`; `rules=\"[]\"` disables them\n * @attr forgot - show the forgot-password link\n * @attr forgot-label - its text (default \"Forgot your password?\")\n * @attr forgot-event - the action it requests\n * @fires pont2-action, pont2-action-success, pont2-action-error - from the forgot link\n */\nexport class PasswordField extends SecretField {\n static override properties: PropertyDeclarations = {\n rules: { converter: rulesConverter },\n forgot: { type: Boolean },\n forgotLabel: { type: String, attribute: \"forgot-label\" },\n forgotEvent: { type: String, attribute: \"forgot-event\" },\n };\n\n declare rules: PasswordRule[];\n declare forgot: boolean;\n declare forgotLabel: string;\n declare forgotEvent: string | undefined;\n\n protected readonly forgotAction = new ActionController(this);\n\n constructor() {\n super();\n this.rules = DEFAULT_PASSWORD_RULES;\n this.forgot = false;\n this.forgotLabel = \"\";\n this.forgotEvent = undefined;\n }\n\n protected defaultName() {\n return \"password\";\n }\n protected defaultLabel() {\n return \"Password\";\n }\n protected override defaultAutocomplete() {\n return \"current-password\";\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n const label = this.text;\n if (this.minlength && value.length < this.minlength) {\n return [{ type: \"minlength\", message: this.minlengthError || fieldMessages.minlength(label, this.minlength) }];\n }\n if (this.maxlength && value.length > Math.max(this.maxlength, this.minlength ?? 0)) {\n return [{ type: \"maxlength\", message: this.maxlengthError || fieldMessages.maxlength(label, this.maxlength) }];\n }\n const failing = (this.rules ?? []).filter(r => {\n const re = ruleRegExp(r);\n return re ? !re.test(value) : false;\n });\n if (!failing.length) return [];\n const messages = failing.map(r => r.error).filter((m): m is string => !!m);\n return messages.length\n ? messages.map(message => ({ type: \"rule\" as const, message }))\n : [{ type: \"rule\", message: this.formatError || fieldMessages.format(label) }];\n }\n\n protected override renderLabel(): TemplateResult | typeof nothing {\n if (!this.forgot) return super.renderLabel();\n const busy = this.forgotAction.busy;\n return html`<div data-pont2-auth-field-label-row>\n ${super.renderLabel()}\n ${button(\n {\n variant: \"link\",\n size: \"sm\",\n slot: \"field-forgot\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: { \"data-event\": this.forgotEvent, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: () => this.forgotAction.request(this.forgotEvent, { forgot: true, name: this.fieldName }),\n },\n this.forgotLabel || \"Forgot your password?\",\n )}\n </div>`;\n }\n}\n\n/* ==================================================================== */\n/* ConfirmField */\n/* ==================================================================== */\n\n/**\n * # `<pont2-confirm-field>`: repeat a password\n *\n * Valid when its value equals the `pair` field's (default: the first\n * `pont2-password-field` in the same form, else in the document). It\n * re-validates as either changes. `autocomplete=\"new-password\"`, name\n * `confirm`. Unlike the legacy kit, the pair's value is never put in an event.\n *\n * @tag pont2-confirm-field\n * @attr pair - CSS selector of the field to match (default \"pont2-password-field\")\n * @attr match-error - default \"Passwords do not match.\"\n */\nexport class ConfirmField extends SecretField {\n static override properties: PropertyDeclarations = {\n pair: { type: String },\n matchError: { type: String, attribute: \"match-error\" },\n };\n\n declare pair: string;\n declare matchError: string;\n\n private scope: Document | HTMLFormElement | null = null;\n\n constructor() {\n super();\n this.pair = \"pont2-password-field\";\n this.matchError = \"\";\n }\n\n protected defaultName() {\n return \"confirm\";\n }\n protected defaultLabel() {\n return \"Confirm Password\";\n }\n protected override defaultAutocomplete() {\n return \"new-password\";\n }\n\n /** The element being matched (a pont2 field or any element with `.value`). */\n get pairElement(): (Element & { value?: string }) | null {\n const root = this.closest(\"form\") ?? document;\n return this.pair ? root.querySelector(this.pair) : null;\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n const other = this.pairElement?.value ?? \"\";\n return value === other ? [] : [{ type: \"match\", message: this.matchError || \"Passwords do not match.\" }];\n }\n\n // Re-validate when the pair changes (its input events bubble through the form).\n private onScopeInput = (e: Event) => {\n const pair = this.pairElement;\n if (pair && e.target instanceof Node && pair.contains(e.target)) this.requestUpdate();\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.scope = this.closest(\"form\") ?? document;\n this.scope.addEventListener(\"input\", this.onScopeInput);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.scope?.removeEventListener(\"input\", this.onScopeInput);\n this.scope = null;\n }\n}\n\ndefine(\"pont2-password-field\", PasswordField);\ndefine(\"pont2-confirm-field\", ConfirmField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-password-field\": PasswordField;\n \"pont2-confirm-field\": ConfirmField;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { define } from \"../../core/names\";\nimport type { InputOTP } from \"../../primitives/input-otp/input-otp\";\nimport { REGEXP_ONLY_DIGITS } from \"../../primitives/input-otp/otp\";\nimport type { InputOptions } from \"../../primitives/input/input\";\nimport { AuthField, type FieldIssue } from \"../auth-field/auth-field\";\nimport { otpGroups } from \"../input-otp/input-otp\";\n\n/** The legacy `pont-otp` layouts, kept for render-spec parity. */\nexport type OtpLayout = \"digits_only\" | \"simple\" | \"with_separator\" | \"with_spacing\";\n\n/**\n * # `<pont2-otp-field>`: a verification-code field\n *\n * ```html\n * <form>\n * <pont2-otp-field label=\"Verification code\" length=\"6\" layout=\"with_separator\" required></pont2-otp-field>\n * <pont2-submit-button event=\"verify_code\" label=\"Verify\"></pont2-submit-button>\n * </form>\n * ```\n *\n * **Is a Field** (`extends AuthField extends Field`) holding the Input OTP\n * primitive, as shadcn composes it (`<Field><FieldLabel/><InputOTP/>\n * <FieldDescription/></Field>`):\n *\n * ```html\n * <pont2-otp-field data-pont2-field data-slot=\"field\">\n * <label data-pont2-field-label for=\"…-input\">Verification code</label>\n * <pont2-prim-input-otp maxlength=\"6\" name=\"code\" input-id=\"…-input\" …>\n * <div data-pont2-input-otp-group …> <pont2-prim-input-otp-slot index=\"0\"> …×3 </div>\n * <div data-pont2-input-otp-separator …><svg/></div>\n * <div data-pont2-input-otp-group …> …×3 </div>\n * <div data-pont2-input-otp-input-wrapper><input autocomplete=\"one-time-code\" name=\"code\" …></div>\n * </pont2-prim-input-otp>\n * <div data-pont2-field-error role=\"alert\">Please enter the complete verification code.</div>\n * </pont2-otp-field>\n * ```\n *\n * The Input OTP is rendered as its **primitive element** (it has behaviour);\n * its groups and separators are parts, and its slots are elements (kit/input-otp).\n * Everything an auth field does applies: the one native\n * `autocomplete=\"one-time-code\"` input is the form control, validation is\n * native (`required`, then *incomplete*), errors are inline.\n *\n * **Auto-submit** (`auto-submit`): when every slot is filled,\n * - with `event`: requests it through the action protocol, with the same\n * `data: { form, formData }` shape as the submit button (so one flow\n * handler serves both);\n * - without `event`: submits the enclosing form (`form.requestSubmit()`), so\n * its submit button handles the request.\n *\n * @tag pont2-otp-field\n * @attr length - number of characters (default 6)\n * @attr layout - digits_only (one group, default) | simple (2 groups) | with_separator (3 groups) | with_spacing (one slot per group)\n * @attr group-size, separator - explicit grouping (override `layout`)\n * @attr pattern - per-character regex source (default digits; `pattern=\"\"` accepts anything)\n * @attr auto-submit - submit when complete\n * @attr event - the action requested on auto-submit\n * @attr incomplete-error - default \"Please enter the complete verification code.\"\n * @fires pont2-complete - from the Input OTP, `{ value }`\n * @fires pont2-action, pont2-action-success, pont2-action-error - on auto-submit with `event`\n */\nexport class OtpField extends AuthField {\n static override properties: PropertyDeclarations = {\n length: { type: Number },\n layout: { type: String },\n groupSize: { type: Number, attribute: \"group-size\" },\n separator: { type: Boolean },\n autoSubmit: { type: Boolean, attribute: \"auto-submit\" },\n event: { type: String },\n incompleteError: { type: String, attribute: \"incomplete-error\" },\n };\n\n declare length: number;\n declare layout: OtpLayout;\n declare groupSize: number | undefined;\n declare separator: boolean | undefined;\n declare autoSubmit: boolean;\n declare event: string | undefined;\n declare incompleteError: string;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.length = 6;\n this.layout = \"digits_only\";\n this.groupSize = undefined;\n this.separator = undefined;\n this.autoSubmit = false;\n this.event = undefined;\n this.incompleteError = \"\";\n this.pattern = REGEXP_ONLY_DIGITS;\n this.requiredError = \"\";\n // The input lives inside the Input OTP; its events bubble to us.\n this.addEventListener(\"input\", e => {\n if (e.target === this.control) this.onInput(e);\n });\n this.addEventListener(\"change\", e => {\n if (e.target === this.control) this.onChange();\n });\n this.addEventListener(\"pont2-complete\", e => this.onComplete(e.detail.value));\n }\n\n protected defaultName() {\n return \"code\";\n }\n protected defaultLabel() {\n return \"Code\";\n }\n\n /** The Input OTP primitive element. */\n get otp(): InputOTP | null {\n return this.querySelector(\"pont2-prim-input-otp\");\n }\n\n override get control(): HTMLInputElement | null {\n return this.otp?.input ?? null;\n }\n\n /** `true` while an auto-submit request is pending. */\n get busy(): boolean {\n return this.action.busy;\n }\n\n protected override computeIssues(): FieldIssue[] {\n if (this.disabled) return [];\n const value = this.current;\n if (!value) {\n return this.required ? [{ type: \"required\", message: this.requiredError || \"Code is required.\" }] : [];\n }\n if (this.validation === \"simple\") return [];\n return this.valueIssues(value);\n }\n\n protected override valueIssues(value: string): FieldIssue[] {\n return value.length === this.length\n ? []\n : [{ type: \"incomplete\", message: this.incompleteError || \"Please enter the complete verification code.\" }];\n }\n\n /** Group size and separators from `layout`, unless set explicitly. */\n get grouping(): { size: number; separator: boolean } {\n const n = this.length;\n const byLayout: Record<OtpLayout, { size: number; separator: boolean }> = {\n digits_only: { size: 0, separator: false },\n simple: { size: Math.ceil(n / 2), separator: true },\n with_separator: { size: Math.ceil(n / 3), separator: true },\n with_spacing: { size: 1, separator: false },\n };\n const base = byLayout[this.layout] ?? byLayout.digits_only;\n return { size: this.groupSize ?? base.size, separator: this.separator ?? base.separator };\n }\n\n private onComplete(value: string): void {\n this.setCurrent(value);\n if (!this.autoSubmit) return;\n const form = this.control?.form ?? null;\n if (this.event) {\n const formData = form ? new FormData(form) : new FormData();\n if (!form) formData.set(this.fieldName, value);\n this.action.request(this.event, { form, formData });\n } else {\n form?.requestSubmit();\n }\n }\n\n protected override onReset = () => {\n setTimeout(() => {\n const otp = this.otp;\n if (otp) otp.value = this.defaultValue;\n this.shown = false;\n this.current = this.defaultValue;\n });\n };\n\n protected override renderLabel(): TemplateResult | typeof nothing {\n // The label is optional for a code field; the input is then named by aria-label.\n return this.label ? super.renderLabel() : nothing;\n }\n\n protected override renderControl(o: InputOptions): TemplateResult {\n const { size, separator } = this.grouping;\n return html`<pont2-prim-input-otp\n input-id=${o.id!}\n name=${o.name ?? nothing}\n maxlength=${this.length}\n pattern=${this.pattern}\n value=${this.defaultValue || nothing}\n ?required=${this.required}\n ?disabled=${this.disabled}\n aria-label=${this.label ? nothing : \"Verification code\"}\n aria-describedby=${o.describedBy ?? nothing}\n aria-invalid=${o.invalid ? \"true\" : nothing}\n aria-busy=${this.busy ? \"true\" : nothing}\n >${otpGroups(this.length, size, separator)}</pont2-prim-input-otp\n >`;\n }\n}\n\ndefine(\"pont2-otp-field\", OtpField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-otp-field\": OtpField;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/**\n * # `<pont2-otp-resend>`: \"Resend code in 42s\", then a resend link\n *\n * ```html\n * <pont2-otp-resend event=\"resend_code\" duration=\"60\"></pont2-otp-resend>\n * ```\n *\n * ```html\n * <pont2-otp-resend data-pont2-otp-resend data-slot=\"otp-resend\">\n * <span data-slot=\"otp-resend-countdown\" role=\"timer\">Resend code in 42s</span>\n * ⟶ when it reaches 0:\n * <button data-pont2-button data-variant=\"link\" data-slot=\"otp-resend-button\" type=\"button\">Resend code</button>\n * </pont2-otp-resend>\n * ```\n *\n * The root is a plain row, so this is a new-name composite on `HostElement`\n * (06-higher-layers: layout renderers). The button is the button primitive's\n * part and requests `event` through the action protocol (`data: { resend:\n * true }`); the countdown restarts when it is pressed, as in the legacy kit.\n *\n * The countdown is `role=\"timer\"` (not announced every second). When it\n * ends, the button appears; focus is not moved.\n *\n * @tag pont2-otp-resend\n * @attr duration - seconds before the button appears (default 60; 0 shows it at once)\n * @attr event - the action requested on press\n * @attr label - button text (default \"Resend code\")\n * @attr countdown-text - text before the seconds (default \"Resend code in \")\n * @cssprop --pont2-otp-resend-fg - the row's text (default muted-foreground)\n * @cssprop --pont2-otp-resend-button-fg, --pont2-otp-resend-button-fg-hover - the link (default the row's colour; primary on hover)\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class OtpResend extends HostElement {\n static override identity = \"otp-resend\";\n static override slotName = \"otp-resend\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n duration: { type: Number },\n event: { type: String },\n label: { type: String },\n countdownText: { type: String, attribute: \"countdown-text\" },\n remaining: { state: true },\n };\n\n declare duration: number;\n declare event: string | undefined;\n declare label: string;\n declare countdownText: string;\n /** Seconds left. */\n declare remaining: number;\n\n protected readonly action = new ActionController(this);\n private timer: ReturnType<typeof setInterval> | undefined;\n\n constructor() {\n super();\n this.duration = 60;\n this.event = undefined;\n this.label = \"\";\n this.countdownText = \"\";\n this.remaining = 0;\n }\n\n /** Starts (or restarts) the countdown from `duration`. */\n restart(): void {\n this.stop();\n this.remaining = Math.max(0, Math.floor(this.duration || 0));\n if (this.remaining > 0) {\n this.timer = setInterval(() => {\n this.remaining = Math.max(0, this.remaining - 1);\n if (!this.remaining) this.stop();\n }, 1000);\n }\n }\n\n private stop(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.restart();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stop();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"duration\") && this.hasUpdated) this.restart();\n }\n\n private press = () => {\n this.action.request(this.event, { resend: true });\n this.restart();\n };\n\n override render() {\n if (this.remaining > 0) {\n return html`<span data-slot=\"otp-resend-countdown\" role=\"timer\"\n >${this.countdownText || \"Resend code in \"}${this.remaining}s</span\n >`;\n }\n const busy = this.action.busy;\n return button(\n {\n variant: \"link\",\n slot: \"otp-resend-button\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: { \"data-event\": this.event, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: this.press,\n },\n this.label || \"Resend code\",\n );\n }\n}\n\ndefine(\"pont2-otp-resend\", OtpResend);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-otp-resend\": OtpResend;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { safeExternalUrl, safeUrl } from \"../../core/url\";\nimport { button } from \"../../primitives/button/button\";\n\nexport type LinkAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-link>`: \"Don't have an account? Sign up\"\n *\n * ```html\n * <pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>\n * <pont2-link label=\"Privacy policy\" href=\"/privacy\" target=\"_blank\"></pont2-link>\n * ```\n *\n * shadcn's login blocks write this as `<div class=\"text-center text-sm\">\n * Don't have an account? <a class=\"underline underline-offset-4\">Sign\n * up</a></div>`. pont2's host is that row; the link is the button\n * primitive's part:\n *\n * - **with `href`**: a real `<a href>` (navigation, middle-click, \"open in\n * new tab\" work), styled as a link. Only an http(s) URL, absolute or\n * relative, is linked (`safeUrl`): a `javascript:`, `data:` or other\n * scheme renders **nothing** and the row is hidden (`data-invalid-href`),\n * because an `href` from a render spec is data, not trusted markup;\n * - **otherwise**: a `<button type=\"button\">` that requests `event` through\n * the action protocol (`data: { service }`), busy until it settles, like\n * the auth buttons. The legacy `service=\"other\"` (no auth call) maps to:\n * don't set `event`, or don't respond.\n *\n * @tag pont2-link\n * @attr label - link text (default \"Link\")\n * @attr prompt - text before the link\n * @attr event - the action requested on press (button form)\n * @attr service - auth (default) | other: passed in the request's data\n * @attr href, target, rel - render a real link instead (http(s) only; anything else renders nothing)\n * @attr align - start | center (default) | end\n * @attr disabled, loading\n * @cssprop --pont2-link-fg - the row's text (default muted-foreground)\n * @cssprop --pont2-link-button-fg, --pont2-link-button-fg-hover - the link (default the row's colour; primary on hover)\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class Link extends HostElement {\n static override identity = \"link\";\n static override slotName = \"link\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n label: { type: String },\n prompt: { type: String },\n event: { type: String },\n service: { type: String },\n href: { type: String },\n target: { type: String },\n rel: { type: String },\n align: { type: String },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n };\n\n declare label: string;\n declare prompt: string;\n declare event: string | undefined;\n declare service: \"auth\" | \"other\";\n declare href: string | undefined;\n declare target: string | undefined;\n declare rel: string | undefined;\n declare align: LinkAlign;\n declare disabled: boolean;\n declare loading: boolean;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.label = \"\";\n this.prompt = \"\";\n this.event = undefined;\n this.service = \"auth\";\n this.href = undefined;\n this.target = undefined;\n this.rel = undefined;\n this.align = \"center\";\n this.disabled = false;\n this.loading = false;\n }\n\n get busy(): boolean {\n return this.loading || this.action.busy;\n }\n\n /** The native `<a>` or `<button>`. */\n get control(): HTMLAnchorElement | HTMLButtonElement | null {\n return this.querySelector(\"[data-pont2-button]\");\n }\n\n /** `href` is set but is not an http(s) URL: the link renders nothing. */\n protected get invalidHref(): boolean {\n return this.href !== undefined && safeUrl(this.href) === null;\n }\n\n protected override willUpdate(_changed: PropertyValues): void {\n this.setData(\"align\", this.align || \"center\");\n this.setData(\"invalid-href\", this.invalidHref);\n }\n\n override render() {\n if (this.invalidHref) return nothing;\n const busy = this.busy;\n return html`${this.prompt ? html`<span data-slot=\"link-prompt\">${this.prompt}</span>` : nothing}${button(\n {\n variant: \"link\",\n slot: \"link-button\",\n href: this.href,\n target: this.target,\n rel: this.rel ?? (this.target === \"_blank\" ? \"noopener noreferrer\" : undefined),\n disabled: this.disabled || busy,\n focusableWhenDisabled: busy && !this.disabled,\n attrs: { \"data-event\": this.event, \"data-service\": this.service, \"data-loading\": busy, \"aria-busy\": busy ? \"true\" : null },\n onClick: this.href === undefined ? () => this.action.request(this.event, { service: this.service }) : undefined,\n },\n this.label || \"Link\",\n )}`;\n }\n}\n\ndefine(\"pont2-link\", Link);\n\n/**\n * # `<pont2-external-link>`: a page outside the flow, in a new tab\n *\n * ```html\n * <pont2-external-link label=\"Privacy policy\" href=\"{{consent_privacy_policy_url}}\"></pont2-external-link>\n * ```\n *\n * The consent screen's links to an app's privacy policy, terms or homepage. It\n * is `pont2-link`'s `href` form with the rules of the legacy\n * `pont-external-link` (carry-over §7):\n *\n * - only an **absolute** http(s) URL with a host renders (`safeExternalUrl`).\n * The href is usually a server placeholder filled from the app's settings,\n * so empty, still a placeholder, relative or any other scheme renders\n * **nothing** and the row is hidden (`data-invalid-href`);\n * - it always opens a new tab, with `rel=\"noopener noreferrer\"`;\n * - `label` falls back to the URL;\n * - it never requests an action and fires no event, so it is safe on screens\n * that are not an auth flow.\n *\n * Styled by `pont2-link`'s recipe and tokens, so the two read as one kind of\n * thing on a screen.\n *\n * @tag pont2-external-link\n * @attr href - absolute http(s) URL; anything else renders nothing\n * @attr label - link text (default: the URL)\n * @attr prompt - text before the link\n * @attr align - start | center (default) | end\n */\nexport class ExternalLink extends Link {\n protected override get invalidHref(): boolean {\n return safeExternalUrl(this.href) === null;\n }\n\n override render() {\n const href = safeExternalUrl(this.href);\n if (!href) return nothing;\n return html`${this.prompt ? html`<span data-slot=\"link-prompt\">${this.prompt}</span>` : nothing}${button(\n { variant: \"link\", slot: \"link-button\", href, target: \"_blank\", rel: \"noopener noreferrer\" },\n this.label?.trim() || href,\n )}`;\n }\n}\n\ndefine(\"pont2-external-link\", ExternalLink);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-link\": Link;\n \"pont2-external-link\": ExternalLink;\n }\n}\n","import { type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { FieldSeparator } from \"../../primitives/field/field\";\n\n/**\n * # `<pont2-divider>`: \"Or continue with\"\n *\n * ```html\n * <pont2-divider label=\"Or continue with\"></pont2-divider>\n * ```\n *\n * **Is a FieldSeparator** (`extends FieldSeparator`), as shadcn's login\n * blocks write it (`<FieldSeparator>Or continue with</FieldSeparator>`): one\n * node, the rule halves drawn by the primitive's `::before`/`::after`, the\n * label a text node. Without a label it is a plain rule\n * (`data-content=\"false\"`).\n *\n * @tag pont2-divider\n * @attr label - text in the middle\n */\nexport class Divider extends FieldSeparator {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n label: { type: String },\n };\n\n declare label: string;\n\n constructor() {\n super();\n this.label = \"\";\n }\n\n override render() {\n return this.label;\n }\n}\n\ndefine(\"pont2-divider\", Divider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-divider\": Divider;\n }\n}\n","import { html, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { ShellElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type TitleLevel = \"1\" | \"2\" | \"3\" | \"4\";\nexport type TextAlign = \"auto\" | \"start\" | \"center\" | \"end\";\n\n/**\n * Title and subtitle: a heading and its supporting line.\n *\n * shadcn has no typography *components* (its typography page is classes), and\n * its login blocks write `<h1 class=\"text-2xl font-bold\">Welcome back</h1>\n * <p class=\"text-muted-foreground text-balance\">Login to your Acme Inc\n * account</p>`. pont2 keeps the **native** `<h1>`–`<h4>` / `<p>` (document\n * outline, heading navigation, reader modes), so these are Tier 3 shells:\n * the host has no box (`display: contents`), the native element is styled.\n *\n * The text comes from `content` (the legacy attribute, and what render\n * specs emit); a composite owns its children.\n */\nabstract class TextShell extends ShellElement {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n content: { type: String },\n align: { type: String },\n };\n\n declare content: string;\n declare align: TextAlign;\n\n constructor() {\n super();\n this.content = \"\";\n this.align = \"auto\";\n }\n\n override get control(): HTMLElement | null {\n return this.firstElementChild as HTMLElement | null;\n }\n\n}\n\n/**\n * # `<pont2-title>`\n *\n * ```html\n * <pont2-title level=\"1\" content=\"Welcome back\"></pont2-title>\n * → <pont2-title data-pont2-shell><h1 data-pont2-title data-level=\"1\" data-align=\"auto\">Welcome back</h1></pont2-title>\n * ```\n *\n * Sizes follow shadcn's auth blocks: level 1 is the block heading (`text-2xl\n * font-bold`), 2–4 step down (`text-xl`/`text-lg`/`text-base`, semibold).\n *\n * @tag pont2-title\n * @attr level - 1 (default) | 2 | 3 | 4: the native heading level\n * @attr content - the heading text\n * @attr align - auto (default: inherit) | start | center | end\n * @cssprop --pont2-title-fg, --pont2-title-font-weight - colour and weight (default foreground, semibold)\n * @cssprop --pont2-title-h1-font-size … --pont2-title-h4-font-size - size per level (default text-2xl, -xl, -lg, -base)\n * @cssprop --pont2-title-h1-font-weight - level 1 weight (default the title weight, else bold)\n */\nexport class Title extends TextShell {\n static override properties: PropertyDeclarations = {\n level: { type: String },\n };\n\n declare level: TitleLevel;\n\n constructor() {\n super();\n this.level = \"1\";\n }\n\n override render(): TemplateResult {\n const level = ([\"1\", \"2\", \"3\", \"4\"] as const).includes(this.level) ? this.level : \"1\";\n const a = this.align || \"auto\";\n const c = this.content;\n switch (level) {\n case \"2\":\n return html`<h2 data-pont2-title data-level=\"2\" data-align=${a}>${c}</h2>`;\n case \"3\":\n return html`<h3 data-pont2-title data-level=\"3\" data-align=${a}>${c}</h3>`;\n case \"4\":\n return html`<h4 data-pont2-title data-level=\"4\" data-align=${a}>${c}</h4>`;\n default:\n return html`<h1 data-pont2-title data-level=\"1\" data-align=${a}>${c}</h1>`;\n }\n }\n}\n\n/**\n * # `<pont2-subtitle>`\n *\n * ```html\n * <pont2-subtitle content=\"Login to your Acme Inc account\"></pont2-subtitle>\n * → <pont2-subtitle data-pont2-shell><p data-pont2-subtitle data-align=\"auto\">…</p></pont2-subtitle>\n * ```\n *\n * shadcn's block description: `text-muted-foreground text-balance` (text-sm).\n *\n * @tag pont2-subtitle\n * @attr content, align - as Title\n * @cssprop --pont2-subtitle-fg, --pont2-subtitle-font-size - colour and size (default muted-foreground, text-sm)\n */\nexport class Subtitle extends TextShell {\n override render(): TemplateResult {\n return html`<p data-pont2-subtitle data-align=${this.align || \"auto\"}>${this.content}</p>`;\n }\n}\n\ndefine(\"pont2-title\", Title);\ndefine(\"pont2-subtitle\", Subtitle);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-title\": Title;\n \"pont2-subtitle\": Subtitle;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\n\nimport { define } from \"../../core/names\";\nimport type { ButtonSize, ButtonVariant } from \"../../primitives/button/button\";\nimport { Field } from \"../../primitives/field/field\";\nimport type { AuthButtonContent, AuthButtonIconAlign } from \"../auth-button/auth-button\";\nimport \"../auth-button/auth-button\";\nimport { AUTH_PROVIDERS, type AuthProvider } from \"../auth-button/providers\";\n\n/** Per-provider settings that override the field-wide ones (the legacy `overrides`). */\nexport interface ProviderOverride {\n provider: AuthProvider;\n label?: string;\n prompt?: string;\n event?: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n content?: AuthButtonContent;\n iconAlign?: AuthButtonIconAlign;\n disabled?: boolean;\n loading?: boolean;\n}\n\n/** The legacy column layouts of a 12-column grid, by provider count. */\nexport type ProviderColumns = \"one\" | \"three\" | \"four\" | \"two-three\" | \"three-four\";\n\n/** 1–2 → one per row; multiples of 3 → three; 5 → 2 + 3; 7 → 3 + 4; otherwise four (legacy rule). */\nexport function providerColumns(count: number): ProviderColumns {\n if (count < 3) return \"one\";\n if (count % 3 === 0) return \"three\";\n if (count === 5) return \"two-three\";\n if (count === 7) return \"three-four\";\n return \"four\";\n}\n\n/** The legacy default event per provider: the platform's OAuth sign-in action. */\nexport const providerEvent = (p: AuthProvider) => `signin_with_oauth(${p})`;\n\nconst listConverter = {\n fromAttribute: (v: string | null): AuthProvider[] =>\n (v ?? \"\").split(/[\\s,]+/).filter((p): p is AuthProvider => AUTH_PROVIDERS.includes(p as AuthProvider)),\n};\n\nconst jsonArray = {\n fromAttribute: (v: string | null): ProviderOverride[] => {\n try {\n const parsed = JSON.parse(v ?? \"[]\");\n return Array.isArray(parsed) ? parsed : [];\n } catch {\n return [];\n }\n },\n};\n\n/**\n * # `<pont2-provider-field>`: the \"continue with…\" button grid\n *\n * ```html\n * <pont2-provider-field providers=\"apple google meta\"></pont2-provider-field>\n * ```\n *\n * **Is a Field** (`extends Field`), as in shadcn's login blocks (`<Field\n * className=\"grid grid-cols-3 gap-4\">` holding the buttons), laid out on the\n * legacy kit's 12-column grid (`data-columns`, see `providerColumns`). It\n * renders one **`<pont2-provider-button>` element** per provider:\n *\n * ```html\n * <pont2-provider-field data-pont2-field data-slot=\"field\" role=\"group\" data-columns=\"three\">\n * <pont2-provider-button provider=\"apple\" content=\"icon\" event=\"signin_with_oauth(apple)\" data-pont2-shell>\n * <button data-pont2-button data-variant=\"outline\" data-provider=\"apple\" aria-label=\"Continue with Apple\">…</button>\n * </pont2-provider-button>\n * …\n * </pont2-provider-field>\n * ```\n *\n * Nesting kit elements is normally forbidden in kit templates. This is the\n * documented exception (docs/10-primitives-and-kit.md §5): each button is an\n * **independent, stateful** element (its own busy state and action request),\n * repeated per item, and its host is `display: contents`, so the grid items\n * are the native buttons and the DOM is shadcn's.\n *\n * Field-wide settings apply to every button; `overrides` (JSON attribute or\n * array property) replaces them for one provider. With more than two\n * providers the buttons default to icon-only (legacy).\n *\n * @tag pont2-provider-field\n * @attr providers - e.g. \"apple google github\" (duplicates and unknown names are dropped)\n * @attr event - one event for every button (default: `signin_with_oauth(<provider>)` each)\n * @attr variant, size, content, icon-align, prompt, label, disabled, loading - passed to every button\n * @attr overrides - JSON array of per-provider settings, e.g. `[{\"provider\":\"google\",\"label\":\"Google Workspace\"}]`\n */\nexport class ProviderField extends Field {\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n providers: { converter: listConverter },\n overrides: { converter: jsonArray },\n event: { type: String },\n variant: { type: String },\n size: { type: String },\n content: { type: String },\n iconAlign: { type: String, attribute: \"icon-align\" },\n prompt: { type: String },\n label: { type: String },\n loading: { type: Boolean },\n };\n\n declare providers: AuthProvider[];\n declare overrides: ProviderOverride[];\n declare event: string | undefined;\n declare variant: ButtonVariant | undefined;\n declare size: ButtonSize | undefined;\n declare content: AuthButtonContent | undefined;\n declare iconAlign: AuthButtonIconAlign | undefined;\n declare prompt: string | undefined;\n declare label: string | undefined;\n declare loading: boolean;\n\n constructor() {\n super();\n this.providers = [];\n this.overrides = [];\n this.event = undefined;\n this.variant = undefined;\n this.size = undefined;\n this.content = undefined;\n this.iconAlign = undefined;\n this.prompt = undefined;\n this.label = undefined;\n this.loading = false;\n }\n\n /** The providers actually rendered: known names, first occurrence only. */\n get list(): AuthProvider[] {\n return [...new Set((this.providers ?? []).filter(p => AUTH_PROVIDERS.includes(p)))];\n }\n\n /** The rendered `<pont2-provider-button>` elements. */\n get buttons(): HTMLElementTagNameMap[\"pont2-provider-button\"][] {\n return Array.from(this.querySelectorAll(\":scope > pont2-provider-button\"));\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n this.setData(\"columns\", providerColumns(this.list.length));\n }\n\n override render() {\n const list = this.list;\n const overrides = new Map((this.overrides ?? []).map(o => [o.provider, o]));\n const iconOnly = list.length > 2 ? \"icon\" : undefined;\n return repeat(\n list,\n p => p,\n p => {\n const o = overrides.get(p) ?? ({ provider: p } as ProviderOverride);\n const opt = <T>(v: T | undefined) => (v === undefined || v === null || v === \"\" ? nothing : v);\n return html`<pont2-provider-button\n provider=${p}\n event=${o.event ?? this.event ?? providerEvent(p)}\n variant=${opt(o.variant ?? this.variant)}\n size=${opt(o.size ?? this.size)}\n content=${opt(o.content ?? this.content ?? iconOnly)}\n icon-align=${opt(o.iconAlign ?? this.iconAlign)}\n prompt=${opt(o.prompt ?? this.prompt)}\n label=${opt(o.label ?? this.label)}\n ?disabled=${!!(o.disabled || this.disabled)}\n ?loading=${!!(o.loading || this.loading)}\n ></pont2-provider-button>`;\n },\n );\n }\n}\n\ndefine(\"pont2-provider-field\", ProviderField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-provider-field\": ProviderField;\n }\n}\n","import { html, svg } from \"lit\";\n\n/**\n * The Pontive logo (mark + wordmark), the same geometry as the legacy\n * watermark. Pontive's own asset, so it is inlined (no image request) and the\n * mark and wordmark can be coloured separately in CSS.\n */\nexport const PONTIVE_MARK = svg`<polygon points=\"113.15,120.26 72.47,190.69 72.46,190.71 61.31,210.02 34.66,256.16 0,196.08 78.48,60.19\" /><polygon points=\"256.23,117.67 179.4,250.76 107.12,250.76 72.46,190.71 72.47,190.69 144.73,190.69 186.89,117.67 153.68,60.07 78.48,60.07 34.65,0 188.35,0\" />`;\nexport const PONTIVE_WORDMARK = svg`<path d=\"M305.95,36.62h76.01c37.22,0,63.16,24.13,63.16,58.64c0,35.19-25.94,59.77-63.16,59.77h-40.83v62.03h-35.19V36.62z M381.51,123.46c16.24,0,27.52-11.28,27.52-27.74c0-16.24-11.28-27.52-27.52-27.52h-40.37v55.26H381.51z\" /><path d=\"M454.59,143.76c0-45.11,31.58-75.79,76.91-75.79c45.34,0,76.91,30.68,76.91,75.79c0,45.34-31.58,75.79-76.91,75.79C486.17,219.54,454.59,189.09,454.59,143.76z M531.51,187.74c24.13,0,41.05-17.59,41.05-43.98c0-26.16-16.92-43.98-41.05-43.98c-23.91,0-40.83,17.82-40.83,43.98C490.68,170.15,507.6,187.74,531.51,187.74z\" /><path d=\"M635.48,70.45h34.96v18.72c3.61-8.8,17.14-21.2,40.37-21.2c33.38,0,59.1,25.71,59.1,63.83v85.26h-35.19v-84.58c0-19.85-12.86-33.16-32.03-33.16c-19.17,0-32.03,13.31-32.03,33.16v84.58h-35.19V70.45z\" /><path d=\"M815.02,102.03h-27.07V70.45h27.07V36.62h35.19v33.83h26.84v31.58h-26.84v115.03h-35.19V102.03z\" /><path d=\"M899.6,36.62h35.19V68.2H899.6V36.62z M899.6,89.85h35.19v127.21H899.6V89.85z\" /><path d=\"M955.09,70.45h36.31l39.7,103.76l39.47-103.76h36.31l-58.19,146.61h-35.19L955.09,70.45z\" /><path d=\"M1117.49,144.21c0-45.56,32.03-76.24,76.46-76.24c49.85,0,81.65,39.25,76.24,87.29h-116.16c2.48,20.53,20.3,33.16,39.47,33.16c15.56,0,30.68-8.12,37.22-22.33h36.99c-9.92,32.48-36.99,53.46-74.66,53.46C1148.39,219.54,1117.49,188.87,1117.49,144.21z M1232.75,127.97c-5.64-17.59-20.07-28.87-38.34-28.87c-18.5,0-33.38,11.05-38.8,29.1L1232.75,127.97z\" />`;\n\nexport const pontiveLogo = () => html`<svg\n data-slot=\"watermark-logo\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 1270.79 256.16\"\n role=\"img\"\n aria-label=\"Pontive\"\n><g data-logo-mark>${PONTIVE_MARK}</g><g data-logo-wordmark>${PONTIVE_WORDMARK}</g></svg>`;\n","import { html, type PropertyDeclarations, type TemplateResult } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { pontiveLogo } from \"./pontive-logo\";\n\nexport type WatermarkVariant = \"brand\" | \"theme\" | \"muted\";\nexport type WatermarkLogoAlign = \"start\" | \"end\";\n\n/** The watermark's content (label + logo), shared with the block's footer. */\nexport function watermarkContent(label: string, logoAlign: WatermarkLogoAlign): TemplateResult {\n const text = html`<span data-slot=\"watermark-label\">${label || \"Powered by\"}</span>`;\n return logoAlign === \"start\" ? html`${pontiveLogo()}${text}` : html`${text}${pontiveLogo()}`;\n}\n\n/**\n * # `<pont2-watermark>`: \"Powered by [Pontive]\"\n *\n * ```html\n * <pont2-watermark variant=\"muted\"></pont2-watermark>\n * → <pont2-watermark data-pont2-watermark data-slot=\"watermark\" data-variant=\"muted\">\n * <span data-slot=\"watermark-label\">Powered by</span><svg data-slot=\"watermark-logo\" role=\"img\" aria-label=\"Pontive\">…</svg>\n * </pont2-watermark>\n * ```\n *\n * Host-as-root (the legacy element wrapped a `<span>` in its tag). The block\n * renders the same content as a *part* in its footer (`Watermark.part()` +\n * `watermarkContent()`), so the screen shell needs no nested element.\n *\n * @tag pont2-watermark\n * @attr variant - brand (default: the mark in Pontive indigo) | theme (currentColor) | muted (muted text)\n * @attr logo-align - start | end (default)\n * @attr label - default \"Powered by\"\n * @cssprop --pont2-watermark-brand-icon-color - the mark in the brand variant (default #6366f1)\n * @cssprop --pont2-watermark-muted-fg - text and mark in the muted variant (default muted-foreground)\n */\nexport class Watermark extends HostElement {\n static override identity = \"watermark\";\n static override slotName = \"watermark\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n variant: { type: String, reflect: true },\n logoAlign: { type: String, attribute: \"logo-align\" },\n label: { type: String },\n };\n\n declare variant: WatermarkVariant;\n declare logoAlign: WatermarkLogoAlign;\n declare label: string;\n\n constructor() {\n super();\n this.variant = \"brand\";\n this.logoAlign = \"end\";\n this.label = \"\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"variant\", this.variant || \"brand\");\n }\n\n override render() {\n return watermarkContent(this.label, this.logoAlign);\n }\n}\n\ndefine(\"pont2-watermark\", Watermark);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-watermark\": Watermark;\n }\n}\n","import { ContextConsumer, createContext } from \"@lit/context\";\nimport type { ReactiveElement } from \"lit\";\n\n/**\n * Account-level branding entitlements, the pont2 side of\n * docs/branding-entitlements.md (same rule, same shape):\n *\n * > A branding entitlement is a fact about the account, resolved by the\n * > backend, delivered as context. An element that renders branding *asks*\n * > for it. It is never *told* by its own markup.\n *\n * So there is no attribute, property or other escape hatch on any pont2\n * element; the flow host (the future pont2 widgets/layout) provides\n * `brandingContext` from the backend response, and Storybook provides it with\n * a `ContextProvider`.\n *\n * The context is the Context Community Protocol (`context-request` events)\n * through `@lit/context`. Its key is `pont2:branding`, separate from the\n * legacy `pont:branding` (docs/08-parallel-constraints.md §4).\n */\nexport interface BrandingEntitlements {\n /** Whether the Pontive watermark must be rendered on the screen shell. */\n showWatermark: boolean;\n}\n\n/** Fail closed: no provider, or an old backend, means the watermark shows. */\nexport const DEFAULT_BRANDING: BrandingEntitlements = { showWatermark: true };\n\nexport const brandingContext = createContext<BrandingEntitlements>(\"pont2:branding\");\n\n/**\n * Reads the entitlements for one element (subscribing, so a late or changed\n * provider value re-renders it). Deliberately no attribute override.\n */\nexport class BrandingController {\n private consumer: ContextConsumer<typeof brandingContext, ReactiveElement>;\n\n constructor(host: ReactiveElement) {\n this.consumer = new ContextConsumer(host, { context: brandingContext, subscribe: true });\n }\n\n get showWatermark(): boolean {\n return this.consumer.value?.showWatermark ?? DEFAULT_BRANDING.showWatermark;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { define } from \"../../core/names\";\nimport { Card, CardFooter } from \"../../primitives/card/card\";\nimport { Watermark, watermarkContent } from \"../watermark/watermark\";\nimport { BrandingController } from \"./branding\";\n\nexport { BrandingController, brandingContext, DEFAULT_BRANDING, type BrandingEntitlements } from \"./branding\";\n\nexport type BlockAlign = \"stretch\" | \"start\" | \"center\" | \"end\";\nexport type BlockJustify = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-block>`: the screen shell\n *\n * ```html\n * <pont2-block>\n * <pont2-header>…</pont2-header>\n * <form>…</form>\n * </pont2-block>\n * ```\n *\n * **Is a Card** (`extends Card`): the host is the card, the screen's content\n * is its children, **left where they are**, and the block adds one thing of\n * its own, the watermark footer:\n *\n * ```html\n * <pont2-block data-pont2-card data-slot=\"card\" data-align=\"stretch\" data-justify=\"start\">\n * …the screen (author / render-spec content)…\n * <div data-pont2-card-footer data-slot=\"card-footer\" data-border=\"top\">\n * <span data-pont2-watermark data-slot=\"watermark\" data-variant=\"muted\">Powered by <svg/></span>\n * </div>\n * </pont2-block>\n * ```\n *\n * The legacy `pont-block` rendered `pont-card > [card] > pont-card-content >\n * [card-content]` and then **moved** the spec's children into it\n * (`moveLightDomChildrenInto`), the relocation pattern host-as-root exists to\n * remove. pont2 moves nothing: the card's inline padding (CardContent's\n * `px-(--card-spacing)`) is on the host, and the footer bleeds to the edges.\n *\n * **Watermark entitlement** (docs/branding-entitlements.md): the footer is\n * rendered unless the branding context says `showWatermark: false`. There is\n * no attribute or property for it, and it fails closed. It is part of the\n * shell, not the content, so a screen author cannot delete it.\n *\n * Not a props-driven composite (`composite = false`): a block *contains* the\n * screen. Lit renders the footer after the author's children.\n *\n * @tag pont2-block\n * @attr align - stretch (default) | start | center | end: the content's cross-axis alignment\n * @attr justify - start (default) | center | end: when the block is taller than its content\n * @attr size - default | sm (the Card primitive's spacing)\n * @cssprop --pont2-block-max-width - max width on wider screens (default 24rem)\n * @cssprop --pont2-block-gap - gap between children (default 1rem)\n * @cssprop --pont2-block-bg, --pont2-block-fg, --pont2-block-border-color, --pont2-block-radius, --pont2-block-shadow, --pont2-block-spacing - the screen card (fall back to the Card's tokens)\n * @cssprop --pont2-block-footer-bg - the watermark band\n */\nexport class Block extends Card {\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n align: { type: String },\n justify: { type: String },\n };\n\n declare align: BlockAlign;\n declare justify: BlockJustify;\n\n private branding = new BrandingController(this);\n\n constructor() {\n super();\n this.align = \"stretch\";\n this.justify = \"start\";\n }\n\n protected override willUpdate(): void {\n super.willUpdate();\n this.setData(\"align\", this.align || \"stretch\");\n this.setData(\"justify\", this.justify || \"start\");\n }\n\n override render() {\n if (!this.branding.showWatermark) return nothing;\n return html`<div ${CardFooter.part({ \"data-border\": \"top\", \"data-block-footer\": true })}>\n <span ${Watermark.part({ \"data-variant\": \"muted\" })}>${watermarkContent(\"\", \"end\")}</span>\n </div>`;\n }\n}\n\ndefine(\"pont2-block\", Block);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-block\": Block;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\n/** The legacy render-spec values. */\nexport type ContainerType = \"flex_column\" | \"flex_row\";\nexport type ContainerAlign = \"stretch\" | \"start\" | \"center\" | \"end\";\nexport type ContainerJustify = \"start\" | \"center\" | \"end\" | \"between\";\n\n/**\n * # `<pont2-container>`: a flex group of screen elements\n *\n * ```html\n * <pont2-container type=\"flex_row\" justify=\"between\">…</pont2-container>\n * → <pont2-container data-pont2-container data-slot=\"container\" data-type=\"flex_row\" data-justify=\"between\">…</pont2-container>\n * ```\n *\n * Tier 1 host-as-root: the host is the flex box and the children stay where\n * they are (the legacy element rendered an inner `div` and moved the children\n * into it). Not a composite: it contains content.\n *\n * @tag pont2-container\n * @attr type - flex_column (default) | flex_row\n * @attr align - stretch (default) | start | center | end (cross axis)\n * @attr justify - start (default) | center | end | between (main axis)\n * @cssprop --pont2-container-gap - default 1rem\n */\nexport class Container extends HostElement {\n static override identity = \"container\";\n static override slotName = \"container\";\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n type: { type: String },\n align: { type: String },\n justify: { type: String },\n };\n\n declare type: ContainerType;\n declare align: ContainerAlign;\n declare justify: ContainerJustify;\n\n constructor() {\n super();\n this.type = \"flex_column\";\n this.align = \"stretch\";\n this.justify = \"start\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"type\", this.type === \"flex_row\" ? \"flex_row\" : \"flex_column\");\n this.setData(\"align\", this.align || \"stretch\");\n this.setData(\"justify\", this.justify || \"start\");\n }\n}\n\ndefine(\"pont2-container\", Container);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-container\": Container;\n }\n}\n","import type { PropertyDeclarations } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type HeaderAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * # `<pont2-header>`: the screen's heading group (logo, title, subtitle)\n *\n * ```html\n * <pont2-header>\n * <pont2-logo image-url=\"/logo.svg\"></pont2-logo>\n * <pont2-title content=\"Welcome back\"></pont2-title>\n * <pont2-subtitle content=\"Login to your Acme Inc account\"></pont2-subtitle>\n * </pont2-header>\n * ```\n *\n * shadcn's login blocks: `<div class=\"flex flex-col items-center gap-2\n * text-center\">`. Tier 1 host-as-root (the legacy element moved its children\n * into an inner `div`); `align` sets both the boxes' and the text's alignment,\n * as the legacy header does. Not a composite: it contains content.\n *\n * @tag pont2-header\n * @attr align - start | center (default) | end\n * @cssprop --pont2-header-gap - default 0.5rem\n */\nexport class Header extends HostElement {\n static override identity = \"header\";\n static override slotName = \"header\";\n static override composite = false;\n\n static override properties: PropertyDeclarations = {\n align: { type: String },\n };\n\n declare align: HeaderAlign;\n\n constructor() {\n super();\n this.align = \"center\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"center\");\n }\n}\n\ndefine(\"pont2-header\", Header);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-header\": Header;\n }\n}\n","import type { PropertyDeclarations, PropertyValues } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type GapType = \"vertical\" | \"horizontal\";\n\n/**\n * # `<pont2-gap>`: a fixed spacer\n *\n * ```html\n * <pont2-gap size=\"24px\"></pont2-gap>\n * → <pont2-gap data-pont2-gap data-type=\"vertical\" style=\"--pont2-gap-size: 24px\"></pont2-gap>\n * ```\n *\n * The host *is* the spacer (the legacy element rendered a sized `div` inside\n * itself). The size is any CSS length, passed through the `--pont2-gap-size`\n * custom property on the host, so no inline width/height overrides author CSS.\n * Decorative: `aria-hidden`.\n *\n * @tag pont2-gap\n * @attr size - CSS length (default 8px)\n * @attr type - vertical (default: takes height) | horizontal (takes width)\n */\nexport class Gap extends HostElement {\n static override identity = \"gap\";\n static override slotName = \"gap\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n size: { type: String },\n type: { type: String },\n };\n\n declare size: string;\n declare type: GapType;\n\n constructor() {\n super();\n this.size = \"8px\";\n this.type = \"vertical\";\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.internals.ariaHidden = \"true\";\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"type\", this.type === \"horizontal\" ? \"horizontal\" : \"vertical\");\n if (changed.has(\"size\")) this.style.setProperty(\"--pont2-gap-size\", this.size || \"8px\");\n }\n}\n\ndefine(\"pont2-gap\", Gap);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-gap\": Gap;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\nimport { styleMap } from \"lit/directives/style-map.js\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\n\nexport type LogoAlign = \"start\" | \"center\" | \"end\";\n\n/**\n * A logo source as an `<img src>`: URLs and `data:` URIs pass through; a bare\n * base64 string is treated as an SVG (the legacy `resolveIconSource` rule).\n * `{{theme}}` in a URL is replaced with `light` or `dark`.\n */\nexport function logoSource(raw: string | undefined, theme: \"light\" | \"dark\"): string {\n if (!raw) return \"\";\n const url = raw.replace(\"{{theme}}\", theme);\n if (/^(https?:|data:|blob:|\\/|\\.{1,2}\\/)/.test(url)) return url;\n return `data:image/svg+xml;base64,${url}`;\n}\n\n/**\n * # `<pont2-logo>`: the application's logo\n *\n * ```html\n * <pont2-logo image-url=\"https://cdn.example.com/logo-{{theme}}.svg\" alt=\"Acme\"></pont2-logo>\n * → <pont2-logo data-pont2-logo data-slot=\"logo\" data-align=\"center\">\n * <img data-logo-theme=\"light\" src=\"…logo-light.svg\" alt=\"Acme\">\n * <img data-logo-theme=\"dark\" src=\"…logo-dark.svg\" alt=\"Acme\"> (only when it differs)\n * </pont2-logo>\n * ```\n *\n * **Always an `<img>`.** The legacy element decoded base64 SVG and injected\n * it as markup (`unsafeSVG`), which runs whatever the SVG contains in the\n * page. An `<img>` renders the same SVG sandboxed (no script, no external\n * fetches), and needs no decoding.\n *\n * **Dark mode by CSS**, not by watching `<html data-theme>`: when the dark\n * source differs (`image-url-dark`, or `{{theme}}` in the URL), both images\n * are rendered and the stylesheet shows the right one under `.dark` /\n * `[data-theme=\"dark\"]` (the pont2 dark-mode switches).\n *\n * @tag pont2-logo\n * @attr image-url - URL, `data:` URI or bare base64 SVG; `{{theme}}` is replaced\n * @attr image-url-dark - dark-mode source (default: `image-url` with `{{theme}}` = dark)\n * @attr alt - default \"Logo\" (legacy); set the brand name\n * @attr align - start | center (default) | end\n * @attr width, height - CSS lengths for the image\n */\nexport class Logo extends HostElement {\n static override identity = \"logo\";\n static override slotName = \"logo\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n imageUrl: { type: String, attribute: \"image-url\" },\n imageUrlDark: { type: String, attribute: \"image-url-dark\" },\n alt: { type: String },\n align: { type: String },\n width: { type: String },\n height: { type: String },\n };\n\n declare imageUrl: string;\n declare imageUrlDark: string;\n declare alt: string;\n declare align: LogoAlign;\n declare width: string;\n declare height: string;\n\n constructor() {\n super();\n this.imageUrl = \"\";\n this.imageUrlDark = \"\";\n this.alt = \"\";\n this.align = \"center\";\n this.width = \"\";\n this.height = \"\";\n }\n\n protected override willUpdate(): void {\n this.setData(\"align\", this.align || \"center\");\n }\n\n override render() {\n const light = logoSource(this.imageUrl, \"light\");\n if (!light) return nothing;\n const dark = logoSource(this.imageUrlDark || this.imageUrl, \"dark\");\n const style = styleMap({ width: this.width || undefined, height: this.height || undefined });\n const alt = this.alt || \"Logo\";\n return html`<img data-logo-theme=\"light\" src=${light} alt=${alt} style=${style} />${dark !== light\n ? html`<img data-logo-theme=\"dark\" src=${dark} alt=${alt} style=${style} />`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-logo\", Logo);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-logo\": Logo;\n }\n}\n","import { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { safeUrl } from \"../../core/url\";\n\nexport interface CountdownEndDetail {\n /** Where the countdown will navigate (already resolved), or null. */\n url: string | null;\n}\n\n/** Kept as countdown's export; the check itself is `safeUrl` (core/url.ts), shared with `pont2-link`. */\nexport const safeRedirect = (raw: string, base?: string): string | null => safeUrl(raw, base);\n\n/**\n * # `<pont2-countdown>`: \"Redirecting in 5s…\"\n *\n * ```html\n * <pont2-countdown content=\"Redirecting you in\" duration=\"5\" redirect-url=\"/dashboard\"></pont2-countdown>\n * → <pont2-countdown data-pont2-countdown data-slot=\"countdown\" role=\"timer\">Redirecting you in 5s…</pont2-countdown>\n * ```\n *\n * Host-as-root (the legacy element rendered a `div` inside its tag). Counts\n * down once a second; at zero it fires a **cancelable** `pont2-countdown-end`\n * and, unless a listener prevents it, navigates to `redirect-url`.\n *\n * **Only http(s) URLs are followed.** Render specs are author-editable HTML,\n * so a `javascript:` or `data:` redirect would be script injection; those are\n * refused (the event still fires, with `url: null`). The legacy element\n * assigned `location.href` unconditionally and defaulted to `/`; pont2 has no\n * default: without `redirect-url` it only fires the event.\n *\n * `role=\"timer\"`: assistive technology is not interrupted every second.\n *\n * @tag pont2-countdown\n * @attr duration - seconds (default 5)\n * @attr content - text before the seconds\n * @attr redirect-url - where to go at zero (http/https, relative URLs resolve against the page)\n * @fires pont2-countdown-end - `{ url }`, cancelable: `preventDefault()` stops the redirect\n */\nexport class Countdown extends HostElement {\n static override identity = \"countdown\";\n static override slotName = \"countdown\";\n static override role = \"timer\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n duration: { type: Number },\n content: { type: String },\n redirectUrl: { type: String, attribute: \"redirect-url\" },\n remaining: { state: true },\n };\n\n declare duration: number;\n declare content: string;\n declare redirectUrl: string;\n /** Seconds left. */\n declare remaining: number;\n\n private timer: ReturnType<typeof setInterval> | undefined;\n\n constructor() {\n super();\n this.duration = 5;\n this.content = \"\";\n this.redirectUrl = \"\";\n this.remaining = 0;\n }\n\n /** (Re)starts from `duration`. */\n restart(): void {\n this.stop();\n this.remaining = Math.max(0, Math.floor(this.duration || 0));\n if (!this.remaining) {\n this.end();\n return;\n }\n this.timer = setInterval(() => {\n this.remaining -= 1;\n if (this.remaining <= 0) {\n this.stop();\n this.end();\n }\n }, 1000);\n }\n\n private stop(): void {\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n private end(): void {\n const url = safeRedirect(this.redirectUrl);\n const go = fire<CountdownEndDetail>(this, \"pont2-countdown-end\", { url }, true);\n if (go && url) location.assign(url);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.restart();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.stop();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"duration\") && this.hasUpdated) this.restart();\n }\n\n override render() {\n return html`${this.content ? `${this.content} ` : \"\"}${this.remaining}s…`;\n }\n}\n\ndefine(\"pont2-countdown\", Countdown);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-countdown\": Countdown;\n }\n interface HTMLElementEventMap {\n \"pont2-countdown-end\": CustomEvent<CountdownEndDetail>;\n }\n}\n","import { html, type PropertyDeclarations } from \"lit\";\n\nimport { ActionController } from \"../../core/controllers/action\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/**\n * # `<pont2-edit-identifier>`: \"ada@example.com ✎\"\n *\n * The identifier the user entered on the previous step, with a button to go\n * back and change it.\n *\n * ```html\n * <pont2-edit-identifier identifier=\"ada@example.com\" event=\"change_identifier\"></pont2-edit-identifier>\n * → <pont2-edit-identifier data-pont2-edit-identifier data-slot=\"edit-identifier\">\n * <span data-slot=\"edit-identifier-value\">ada@example.com</span>\n * <button data-pont2-button data-variant=\"ghost\" data-size=\"icon-xs\" aria-label=\"Change ada@example.com\" type=\"button\"><svg/></button>\n * </pont2-edit-identifier>\n * ```\n *\n * The button is the button primitive's part and requests `event` through the\n * action protocol (`data: { identifier }`), busy until it settles. The\n * legacy element made the *whole* element a click target and its icon button\n * had no accessible name; here only the button acts, and it is named\n * (\"Change ada@example.com\", `label` + the identifier).\n *\n * @tag pont2-edit-identifier\n * @attr identifier - the value shown\n * @attr event - the action requested on press\n * @attr label - the button's accessible name prefix (default \"Change\")\n * @fires pont2-action, pont2-action-success, pont2-action-error\n */\nexport class EditIdentifier extends HostElement {\n static override identity = \"edit-identifier\";\n static override slotName = \"edit-identifier\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n identifier: { type: String },\n event: { type: String },\n label: { type: String },\n };\n\n declare identifier: string;\n declare event: string | undefined;\n declare label: string;\n\n protected readonly action = new ActionController(this);\n\n constructor() {\n super();\n this.identifier = \"\";\n this.event = undefined;\n this.label = \"\";\n }\n\n get control(): HTMLButtonElement | null {\n return this.querySelector(\"[data-pont2-button]\");\n }\n\n override render() {\n const busy = this.action.busy;\n return html`<span data-slot=\"edit-identifier-value\">${this.identifier}</span>${button(\n {\n variant: \"ghost\",\n size: \"icon-xs\",\n slot: \"edit-identifier-button\",\n disabled: busy,\n focusableWhenDisabled: busy,\n attrs: {\n \"aria-label\": `${this.label || \"Change\"} ${this.identifier}`.trim(),\n \"data-event\": this.event,\n \"aria-busy\": busy ? \"true\" : null,\n },\n onClick: () => this.action.request(this.event, { identifier: this.identifier }),\n },\n icons.pencil(),\n )}`;\n }\n}\n\ndefine(\"pont2-edit-identifier\", EditIdentifier);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-edit-identifier\": EditIdentifier;\n }\n}\n","import { html, nothing, type PropertyDeclarations } from \"lit\";\n\nimport { CopyController } from \"../../core/controllers/copy\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { uid } from \"../../core/ids\";\nimport { define } from \"../../core/names\";\nimport { InputGroup, InputGroupAddon, inputGroupButton, inputGroupInput } from \"../../primitives/input-group/input-group\";\n\n/**\n * # `<pont2-secret>`: the \"Can't scan?\" manual TOTP secret\n *\n * ```html\n * <pont2-secret secret=\"JBSWY3DPEHPK3PXP\" issuer=\"Acme\" account=\"ada@example.com\"></pont2-secret>\n * ```\n *\n * ```html\n * <pont2-secret data-pont2-secret data-slot=\"secret\">\n * <p data-slot=\"secret-title\">Can't scan?</p>\n * <div data-pont2-input-group …>\n * <input data-pont2-input-group-input readonly value=\"JBSWY3DPEHPK3PXP\" aria-label=\"Manual secret\">\n * <div data-pont2-input-group-addon data-align=\"inline-end\">\n * <button … aria-label=\"Copy secret\"><svg/></button>\n * </div>\n * </div>\n * <span data-slot=\"secret-copied\" role=\"status\">Copied!</span> (after copying)\n * <dl data-slot=\"secret-metadata\"><div><dt>Issuer</dt><dd>Acme</dd></div><div><dt>Account</dt><dd>…</dd></div></dl>\n * </pont2-secret>\n * ```\n *\n * Built from InputGroup parts (shadcn's input + addon button). Differences\n * from the legacy element, each deliberate:\n * - the input is **readonly**, not disabled: it can be focused and selected\n * (copy by hand, screen readers read it); monospace, spaced for reading;\n * - \"Copied!\" is a `role=\"status\"` live region, so it is announced;\n * - the copy events (`pont2-copied` / `pont2-copy-error`, `{ kind: \"secret\" }`)\n * **do not carry the secret** (the legacy `pont-secret:copied` did);\n * - issuer/account are a description list (`<dl>`), their semantic form.\n *\n * @tag pont2-secret\n * @attr secret, issuer, account\n * @attr title-text - default \"Can't scan?\" (`title` would be a native tooltip)\n * @attr secret-label, issuer-label, account-label, copy-label, copied-text - copy\n * @attr disabled - disables the copy button\n * @fires pont2-copied, pont2-copy-error - `{ kind: \"secret\" }`\n */\nexport class Secret extends HostElement {\n static override identity = \"secret\";\n static override slotName = \"secret\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n secret: { type: String },\n issuer: { type: String },\n account: { type: String },\n titleText: { type: String, attribute: \"title-text\" },\n secretLabel: { type: String, attribute: \"secret-label\" },\n issuerLabel: { type: String, attribute: \"issuer-label\" },\n accountLabel: { type: String, attribute: \"account-label\" },\n copyLabel: { type: String, attribute: \"copy-label\" },\n copiedText: { type: String, attribute: \"copied-text\" },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare secret: string;\n declare issuer: string;\n declare account: string;\n declare titleText: string;\n declare secretLabel: string;\n declare issuerLabel: string;\n declare accountLabel: string;\n declare copyLabel: string;\n declare copiedText: string;\n declare disabled: boolean;\n\n protected readonly clipboard = new CopyController(this, \"secret\");\n private inputId = uid(\"secret\");\n\n constructor() {\n super();\n this.secret = \"\";\n this.issuer = \"\";\n this.account = \"\";\n this.titleText = \"\";\n this.secretLabel = \"\";\n this.issuerLabel = \"\";\n this.accountLabel = \"\";\n this.copyLabel = \"\";\n this.copiedText = \"\";\n this.disabled = false;\n }\n\n /** Copies the secret (also what the button does). */\n copy(): Promise<boolean> {\n return this.secret && !this.disabled ? this.clipboard.copy(this.secret) : Promise.resolve(false);\n }\n\n override render() {\n const copied = this.clipboard.copied;\n const meta = (label: string, value: string) =>\n value ? html`<div><dt>${label}</dt><dd>${value}</dd></div>` : nothing;\n return html`<p data-slot=\"secret-title\">${this.titleText || \"Can't scan?\"}</p>\n <div ${InputGroup.part()}>\n ${inputGroupInput({\n id: this.inputId,\n value: this.secret,\n readonly: true,\n attrs: { \"aria-label\": this.secretLabel || \"Manual secret\", spellcheck: \"false\", \"data-secret\": true },\n })}\n <div ${InputGroupAddon.part({ \"data-align\": \"inline-end\" })}>\n ${inputGroupButton(\n {\n size: \"icon-xs\",\n disabled: this.disabled || !this.secret,\n attrs: { \"aria-label\": this.copyLabel || \"Copy secret\", \"aria-controls\": this.inputId },\n onClick: () => void this.copy(),\n },\n copied ? icons.check() : icons.copy(),\n )}\n </div>\n </div>\n <span data-slot=\"secret-copied\" role=\"status\">${copied ? this.copiedText || \"Copied!\" : \"\"}</span>\n ${this.issuer || this.account\n ? html`<dl data-slot=\"secret-metadata\">\n ${meta(this.issuerLabel || \"Issuer\", this.issuer)}${meta(this.accountLabel || \"Account\", this.account)}\n </dl>`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-secret\", Secret);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-secret\": Secret;\n }\n}\n","import { html, nothing, svg, type PropertyDeclarations, type PropertyValues } from \"lit\";\nimport QRCode from \"qrcode\";\n\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\nexport type QrErrorCorrection = \"L\" | \"M\" | \"Q\" | \"H\";\n\n/** Quiet zone, in modules, around the code (the QR spec asks for 4). */\nconst QUIET = 4;\n\n/**\n * One SVG path covering every dark module of `text`'s QR code, plus the\n * code's size. `null` when the text cannot be encoded.\n */\nexport function qrPath(text: string, level: QrErrorCorrection): { d: string; size: number } | null {\n if (!text) return null;\n try {\n const { modules } = QRCode.create(text, { errorCorrectionLevel: level });\n const n = modules.size;\n let d = \"\";\n for (let y = 0; y < n; y++) {\n for (let x = 0; x < n; x++) {\n if (modules.data[y * n + x]) d += `M${x + QUIET} ${y + QUIET}h1v1h-1z`;\n }\n }\n return { d, size: n + QUIET * 2 };\n } catch {\n return null;\n }\n}\n\nexport interface QrDetail {\n url: string;\n}\n\n/**\n * # `<pont2-qr-code>`: the authenticator-app enrolment QR code\n *\n * ```html\n * <pont2-qr-code url=\"otpauth://totp/Acme:ada@example.com?secret=…&issuer=Acme\" timeout=\"30\"></pont2-qr-code>\n * ```\n *\n * ```html\n * <pont2-qr-code data-pont2-qr-code data-slot=\"qr-code\" [data-obscured]>\n * <svg data-slot=\"qr-code-image\" role=\"img\" aria-label=\"QR code\" viewBox=\"0 0 37 37\">\n * <rect …white…/><path d=\"M4 4h1v1h-1z…\"/>\n * </svg>\n * <div data-slot=\"qr-code-overlay\"> (when obscured)\n * <button data-pont2-button type=\"button\">Show QR code</button>\n * </div>\n * </pont2-qr-code>\n * ```\n *\n * **An SVG built from the code's modules** (`qrcode`'s `create()` matrix →\n * one `<path>`), not a canvas: crisp at any size and zoom, no pixel-ratio\n * maths, nothing injected as markup. Always dark-on-white with the\n * 4-module quiet zone, whatever the theme: inverted codes do not scan\n * everywhere.\n *\n * **Obscured after `timeout` seconds** (it encodes the TOTP secret): the\n * code fades and a \"Show QR code\" button brings it back for another\n * `timeout`. `timeout=\"0\"` never obscures.\n *\n * @tag pont2-qr-code\n * @attr url - the text to encode (an `otpauth://` URI)\n * @attr timeout - seconds before obscuring (default 10)\n * @attr error-correction - L | M (default) | Q | H\n * @attr label - accessible name of the image (default \"QR code\")\n * @attr reveal-label - the button text (default \"Show QR code\")\n * @attr disabled - never obscures, and disables the button\n * @cssprop --pont2-qr-code-width - the image width (default 12rem)\n * @fires pont2-qr-obscured, pont2-qr-revealed - `{ url }`\n * @fires pont2-qr-error - `{ url }` when the text cannot be encoded\n */\nexport class QrCode extends HostElement {\n static override identity = \"qr-code\";\n static override slotName = \"qr-code\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n url: { type: String },\n timeout: { type: Number },\n errorCorrection: { type: String, attribute: \"error-correction\" },\n label: { type: String },\n revealLabel: { type: String, attribute: \"reveal-label\" },\n disabled: { type: Boolean, reflect: true },\n obscured: { state: true },\n };\n\n declare url: string;\n declare timeout: number;\n declare errorCorrection: QrErrorCorrection;\n declare label: string;\n declare revealLabel: string;\n declare disabled: boolean;\n declare obscured: boolean;\n\n private timer: ReturnType<typeof setTimeout> | undefined;\n private path: ReturnType<typeof qrPath> = null;\n\n constructor() {\n super();\n this.url = \"\";\n this.timeout = 10;\n this.errorCorrection = \"M\";\n this.label = \"\";\n this.revealLabel = \"\";\n this.disabled = false;\n this.obscured = false;\n }\n\n /** Shows the code again and restarts the timeout. */\n reveal(): void {\n this.obscured = false;\n this.startTimer();\n }\n\n private startTimer(): void {\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = undefined;\n if (!(this.timeout > 0) || this.disabled) return;\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.obscured = true;\n fire<QrDetail>(this, \"pont2-qr-obscured\", { url: this.url });\n }, this.timeout * 1000);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.startTimer();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this.timer !== undefined) clearTimeout(this.timer);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"url\") || changed.has(\"errorCorrection\")) {\n this.path = qrPath(this.url, this.errorCorrection || \"M\");\n if (this.url && !this.path) fire<QrDetail>(this, \"pont2-qr-error\", { url: this.url });\n if (this.hasUpdated) this.reveal();\n } else if ((changed.has(\"timeout\") || changed.has(\"disabled\")) && this.hasUpdated) {\n this.reveal();\n }\n this.setData(\"obscured\", this.obscured && !this.disabled);\n }\n\n private onReveal = () => {\n this.reveal();\n fire<QrDetail>(this, \"pont2-qr-revealed\", { url: this.url });\n };\n\n override render() {\n const p = this.path;\n if (!p) return nothing;\n const obscured = this.obscured && !this.disabled;\n return html`<svg\n data-slot=\"qr-code-image\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 ${p.size} ${p.size}\"\n shape-rendering=\"crispEdges\"\n role=\"img\"\n aria-label=${this.label || \"QR code\"}\n aria-hidden=${obscured ? \"true\" : nothing}\n >${svg`<rect width=\"${p.size}\" height=\"${p.size}\" fill=\"#fff\" /><path d=\"${p.d}\" fill=\"#000\" />`}</svg\n >${obscured\n ? html`<div data-slot=\"qr-code-overlay\">\n ${button(\n { variant: \"default\", slot: \"qr-code-reveal\", onClick: this.onReveal },\n this.revealLabel || \"Show QR code\",\n )}\n </div>`\n : nothing}`;\n }\n}\n\ndefine(\"pont2-qr-code\", QrCode);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-qr-code\": QrCode;\n }\n interface HTMLElementEventMap {\n \"pont2-qr-obscured\": CustomEvent<QrDetail>;\n \"pont2-qr-revealed\": CustomEvent<QrDetail>;\n \"pont2-qr-error\": CustomEvent<QrDetail>;\n }\n}\n","import { html, type PropertyDeclarations } from \"lit\";\n\nimport { CopyController } from \"../../core/controllers/copy\";\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { icons } from \"../../core/icons\";\nimport { define } from \"../../core/names\";\nimport { button } from \"../../primitives/button/button\";\n\n/** `codes` attribute: JSON array, or whitespace/comma separated. */\nconst codesConverter = {\n fromAttribute: (v: string | null): string[] => {\n const raw = (v ?? \"\").trim();\n if (!raw) return [];\n if (raw.startsWith(\"[\")) {\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed.map(String) : [];\n } catch {\n return [];\n }\n }\n return raw.split(/[\\s,]+/).filter(Boolean);\n },\n};\n\n/**\n * # `<pont2-recovery-codes>`: one-time recovery codes after MFA enrolment\n *\n * ```html\n * <pont2-recovery-codes codes='[\"a1b2-c3d4\",\"e5f6-g7h8\"]'></pont2-recovery-codes>\n * ```\n *\n * ```html\n * <pont2-recovery-codes data-pont2-recovery-codes data-slot=\"recovery-codes\">\n * <p data-slot=\"recovery-codes-title\">Recovery codes</p>\n * <p data-slot=\"recovery-codes-description\">Use these codes if you lose access…</p>\n * <ul data-slot=\"recovery-codes-list\"><li>a1b2-c3d4</li>…</ul>\n * <div data-slot=\"recovery-codes-actions\">\n * <button data-pont2-button data-variant=\"outline\">Copy codes</button>\n * <button data-pont2-button data-variant=\"outline\">Download codes</button>\n * </div>\n * <span data-slot=\"recovery-codes-copied\" role=\"status\">Copied!</span>\n * </pont2-recovery-codes>\n * ```\n *\n * Buttons are the button primitive's parts, the list is a monospace grid,\n * \"Copied!\" is announced (`role=\"status\"`). Events carry **no codes**\n * (`pont2-copied` / `pont2-copy-error` with `{ kind: \"recovery-codes\" }`,\n * `pont2-recovery-codes-downloaded`); the legacy events included them.\n *\n * @tag pont2-recovery-codes\n * @attr codes - JSON array or whitespace-separated list; `.codes` is an array\n * @attr title-text, description, empty-text, copy-label, download-label, copied-text - copy\n * @attr filename - download file name (default \"recovery-codes.txt\")\n * @attr disabled\n * @cssprop --pont2-recovery-codes-list-bg, --pont2-recovery-codes-list-radius - the code list's surface (default muted, radius-md)\n * @fires pont2-copied, pont2-copy-error, pont2-recovery-codes-downloaded\n */\nexport class RecoveryCodes extends HostElement {\n static override identity = \"recovery-codes\";\n static override slotName = \"recovery-codes\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n codes: { converter: codesConverter },\n titleText: { type: String, attribute: \"title-text\" },\n description: { type: String },\n emptyText: { type: String, attribute: \"empty-text\" },\n copyLabel: { type: String, attribute: \"copy-label\" },\n downloadLabel: { type: String, attribute: \"download-label\" },\n copiedText: { type: String, attribute: \"copied-text\" },\n filename: { type: String },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare codes: string[];\n declare titleText: string;\n declare description: string;\n declare emptyText: string;\n declare copyLabel: string;\n declare downloadLabel: string;\n declare copiedText: string;\n declare filename: string;\n declare disabled: boolean;\n\n protected readonly clipboard = new CopyController(this, \"recovery-codes\");\n\n constructor() {\n super();\n this.codes = [];\n this.titleText = \"\";\n this.description = \"\";\n this.emptyText = \"\";\n this.copyLabel = \"\";\n this.downloadLabel = \"\";\n this.copiedText = \"\";\n this.filename = \"\";\n this.disabled = false;\n }\n\n private get text(): string {\n return (this.codes ?? []).join(\"\\n\");\n }\n\n copy(): Promise<boolean> {\n return this.codes?.length && !this.disabled ? this.clipboard.copy(this.text) : Promise.resolve(false);\n }\n\n download(): void {\n if (!this.codes?.length || this.disabled) return;\n const url = URL.createObjectURL(new Blob([this.text], { type: \"text/plain\" }));\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = this.filename || \"recovery-codes.txt\";\n a.click();\n setTimeout(() => URL.revokeObjectURL(url));\n fire(this, \"pont2-recovery-codes-downloaded\", {});\n }\n\n override render() {\n const codes = this.codes ?? [];\n const off = this.disabled || !codes.length;\n return html`<p data-slot=\"recovery-codes-title\">${this.titleText || \"Recovery codes\"}</p>\n <p data-slot=\"recovery-codes-description\">\n ${this.description || \"Use these codes if you lose access to your authenticator app.\"}\n </p>\n ${codes.length\n ? html`<ul data-slot=\"recovery-codes-list\">${codes.map(c => html`<li>${c}</li>`)}</ul>`\n : html`<p data-slot=\"recovery-codes-empty\">${this.emptyText || \"No recovery codes available.\"}</p>`}\n <div data-slot=\"recovery-codes-actions\">\n ${button(\n { variant: \"outline\", disabled: off, onClick: () => void this.copy() },\n html`${this.clipboard.copied ? icons.check({ \"data-icon\": \"inline-start\" }) : icons.copy({ \"data-icon\": \"inline-start\" })}${this.copyLabel || \"Copy codes\"}`,\n )}\n ${button(\n { variant: \"outline\", disabled: off, onClick: () => this.download() },\n html`${icons.download({ \"data-icon\": \"inline-start\" })}${this.downloadLabel || \"Download codes\"}`,\n )}\n </div>\n <span data-slot=\"recovery-codes-copied\" role=\"status\"\n >${this.clipboard.copied ? this.copiedText || \"Copied!\" : \"\"}</span\n >`;\n }\n}\n\ndefine(\"pont2-recovery-codes\", RecoveryCodes);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-recovery-codes\": RecoveryCodes;\n }\n interface HTMLElementEventMap {\n \"pont2-recovery-codes-downloaded\": CustomEvent<Record<string, never>>;\n }\n}\n","/**\n * Pure value logic of the scope list (ported from the legacy\n * scope-list.value.ts, which has the same tests).\n */\nexport interface ConsentScope {\n scope: string;\n label: string;\n granted?: boolean;\n required?: boolean;\n}\n\n/** Drops malformed and duplicate entries; trims names; label defaults to the scope. */\nexport function normalizeScopes(scopes: unknown): ConsentScope[] {\n if (!Array.isArray(scopes)) return [];\n const seen = new Set<string>();\n return scopes.flatMap(s => {\n if (!s || typeof s !== \"object\") return [];\n const { scope, label, granted, required } = s as Record<string, unknown>;\n if (typeof scope !== \"string\" || !scope.trim()) return [];\n const name = scope.trim();\n if (seen.has(name)) return [];\n seen.add(name);\n return [{ scope: name, label: typeof label === \"string\" && label ? label : name, granted: granted === true, required: required === true }];\n });\n}\n\n/** Required scopes are always ticked; others unless the user unticked them. */\nexport function isScopeChecked(scope: ConsentScope, unticked: ReadonlySet<string>): boolean {\n return !!scope.required || !unticked.has(scope.scope);\n}\n\n/** The submitted value: ticked scope names, space-separated (OAuth `scope` syntax). */\nexport function scopeListValue(scopes: ConsentScope[], unticked: ReadonlySet<string>): string {\n return Array.from(new Set(scopes.filter(s => isScopeChecked(s, unticked)).map(s => s.scope))).join(\" \");\n}\n","import { html, type PropertyDeclarations } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\n\nimport { FormControlElement } from \"../../core/form-control\";\nimport { define } from \"../../core/names\";\nimport type { Checkbox } from \"../../primitives/checkbox/checkbox\";\nimport { isScopeChecked, normalizeScopes, scopeListValue, type ConsentScope } from \"./scope-value\";\n\nexport { isScopeChecked, normalizeScopes, scopeListValue, type ConsentScope } from \"./scope-value\";\n\nconst scopesConverter = {\n fromAttribute: (v: string | null): ConsentScope[] => {\n try {\n return normalizeScopes(JSON.parse(v ?? \"[]\"));\n } catch {\n return [];\n }\n },\n};\n\n/**\n * # `<pont2-scope-list>`: OAuth consent scopes\n *\n * ```html\n * <form>\n * <pont2-scope-list name=\"scope\"\n * scopes='[{\"scope\":\"openid\",\"label\":\"Sign you in\",\"required\":true},{\"scope\":\"email\",\"label\":\"See your email\"}]'>\n * </pont2-scope-list>\n * </form>\n * → FormData: scope=openid email\n * ```\n *\n * ```html\n * <pont2-scope-list data-pont2-scope-list data-slot=\"scope-list\" role=\"list\">\n * <div role=\"listitem\" data-slot=\"scope-list-item\" data-scope=\"openid\" data-required>\n * <label data-slot=\"scope-list-label\">\n * <pont2-prim-checkbox checked disabled required></pont2-prim-checkbox>\n * <span data-slot=\"scope-list-text\">Sign you in</span>\n * </label>\n * </div>\n * …\n * </pont2-scope-list>\n * ```\n *\n * **Form-associated** (`extends FormControlElement`): it submits the ticked\n * scopes, space-separated (OAuth `scope` syntax), under `name` (default\n * `scope`), resets, restores and follows `<fieldset disabled>` natively. The\n * legacy element exposed `.value` for its custom form to read.\n *\n * Each row is a **Checkbox primitive element** (it has behaviour) inside a\n * native `<label>`; the checkboxes have no `name`, so only the list submits.\n * Required scopes are always ticked and disabled. Scopes default to ticked;\n * the user unticks what they do not grant.\n *\n * @tag pont2-scope-list\n * @attr scopes - JSON array of `{ scope, label?, required?, granted? }`; `.scopes` is an array\n * @attr name - default \"scope\"\n * @attr disabled\n * @fires input, change - when a scope is toggled (read `.value`)\n */\nexport class ScopeList extends FormControlElement {\n static override identity = \"scope-list\";\n static override slotName = \"scope-list\";\n static override role = \"list\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n scopes: { converter: scopesConverter },\n unticked: { state: true },\n };\n\n declare scopes: ConsentScope[];\n declare protected unticked: Set<string>;\n\n constructor() {\n super();\n this.name = \"scope\";\n this.scopes = [];\n this.unticked = new Set();\n }\n\n /** The normalised scope list. */\n get list(): ConsentScope[] {\n return normalizeScopes(this.scopes);\n }\n\n /** The submitted value: ticked scopes, space-separated. */\n get value(): string {\n return scopeListValue(this.list, this.unticked);\n }\n\n protected override get hostFocusable(): boolean {\n return false; // the checkboxes are the tab stops\n }\n\n protected formValue(): string | null {\n return this.name ? this.value : null;\n }\n\n protected resetToDefault(): void {\n this.unticked = new Set();\n }\n\n protected override restoreState(state: string | File | FormData | null): void {\n if (typeof state !== \"string\") return;\n const ticked = new Set(state.split(\" \"));\n this.unticked = new Set(this.list.filter(s => !ticked.has(s.scope)).map(s => s.scope));\n }\n\n private toggle(scope: string, e: Event): void {\n e.stopPropagation(); // the list's own input/change replace the checkbox's\n const next = new Set(this.unticked);\n if ((e.target as Checkbox).checked) next.delete(scope);\n else next.add(scope);\n this.unticked = next;\n // As native controls: `input` then `change`, from the list itself.\n this.dispatchEvent(new Event(\"input\", { bubbles: true, composed: true }));\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n override render() {\n return repeat(\n this.list,\n s => s.scope,\n s => html`<div\n role=\"listitem\"\n data-slot=\"scope-list-item\"\n data-scope=${s.scope}\n ?data-required=${s.required}\n ?data-granted=${s.granted}\n >\n <label data-slot=\"scope-list-label\">\n <pont2-prim-checkbox\n .checked=${isScopeChecked(s, this.unticked)}\n ?disabled=${this.isDisabled || s.required}\n ?required=${s.required}\n @input=${(e: Event) => e.stopPropagation()}\n @change=${(e: Event) => this.toggle(s.scope, e)}\n ></pont2-prim-checkbox>\n <span data-slot=\"scope-list-text\">${s.label}</span>\n </label>\n </div>`,\n );\n }\n}\n\ndefine(\"pont2-scope-list\", ScopeList);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-scope-list\": ScopeList;\n }\n}\n","/**\n * Turning a failed flow request into words for the user: the legacy\n * `describeFlowError` (src/utils/flow-error.ts), ported (pont2 imports nothing\n * from the legacy kit), with the same English and the same message codes, so\n * a flow's localised `messages` (keyed by code) apply unchanged.\n */\n\nimport { KIT_MESSAGES_EN, msg as kitMsg, setMessages } from \"../../core/messages\";\n\nexport type FlowMessageCode =\n | \"connection_failed\"\n | \"too_many_attempts\"\n | \"server_error\"\n | \"instance_unavailable\"\n | \"generic_error\"\n | \"flow_ended\"\n | \"passkey_cancelled\"\n | \"start_again\"\n | \"continued_elsewhere_title\"\n | \"continued_elsewhere_subtitle\"\n | \"continue_here\";\n\n/** The flow codes' English (a subset of `KIT_MESSAGES_EN`, core/messages.ts). */\nexport const FLOW_MESSAGES_EN: Record<FlowMessageCode, string> = {\n connection_failed: KIT_MESSAGES_EN.connection_failed,\n too_many_attempts: KIT_MESSAGES_EN.too_many_attempts,\n server_error: KIT_MESSAGES_EN.server_error,\n instance_unavailable: KIT_MESSAGES_EN.instance_unavailable,\n generic_error: KIT_MESSAGES_EN.generic_error,\n flow_ended: KIT_MESSAGES_EN.flow_ended,\n passkey_cancelled: KIT_MESSAGES_EN.passkey_cancelled,\n start_again: KIT_MESSAGES_EN.start_again,\n continued_elsewhere_title: KIT_MESSAGES_EN.continued_elsewhere_title,\n continued_elsewhere_subtitle: KIT_MESSAGES_EN.continued_elsewhere_subtitle,\n continue_here: KIT_MESSAGES_EN.continue_here,\n};\n\nexport interface FlowErrorDescription {\n message: string;\n /** The flow is over (409): offer \"Start again\". */\n restartable: boolean;\n /** The instance has stopped: nothing will work, so offer nothing to retry. */\n unavailable?: boolean;\n}\n\nconst FLOW_ENDED_STATUS = 409;\n\n/**\n * A stopped instance (paused, or its owner's Pontive account paused, cancelled or\n * deleted) refuses everything it serves to end users with this one code and no\n * reason (pontive-spec 01, \"Who is told why\"; carry-over §6).\n */\nexport const INSTANCE_UNAVAILABLE = \"instance_unavailable\";\n\n/** Whether a failed call was refused because the instance has stopped (its own `code`, or its body's). */\nexport function isInstanceUnavailable(error: unknown): boolean {\n return readError(error).code === INSTANCE_UNAVAILABLE;\n}\n\n/**\n * Keeps the sentence a stopped instance was refused with. Once stopped, the page\n * can no longer ask for its text, so the auth service words the refusal itself\n * (in the page's language and the instance's copy). Kept in the message table,\n * it is what every widget says for the code from then on, including for\n * refusals from services that only send English.\n */\nexport function rememberUnavailable(sentence?: string): void {\n const text = sentence?.trim();\n if (text) setMessages({ [INSTANCE_UNAVAILABLE]: text });\n}\n\n/**\n * - a cancelled or timed-out WebAuthn prompt (`NotAllowedError` / `AbortError`) → passkey_cancelled\n * - `instance_unavailable` → the refusal's own sentence, kept for the page (rememberUnavailable); not restartable\n * - 409 → the server's sentence, else flow_ended; restartable\n * - no response at all (NETWORK_ERROR / TIMEOUT) → connection_failed\n * - 429 → too_many_attempts; ≥ 500 → server_error\n * - anything else → the server's sentence, else generic_error\n *\n * Text comes from `messages` when given (a set a caller holds), else the\n * page-wide message table (core/messages.ts), else English.\n */\nexport function describeFlowError(\n error: unknown,\n messages: Partial<Record<string, string>> = {},\n): FlowErrorDescription {\n const msg = (code: FlowMessageCode) => messages[code] || kitMsg(code);\n if (typeof DOMException !== \"undefined\" && error instanceof DOMException) {\n if (error.name === \"NotAllowedError\" || error.name === \"AbortError\") {\n return { message: msg(\"passkey_cancelled\"), restartable: false };\n }\n }\n const { status, code, message } = readError(error);\n if (code === INSTANCE_UNAVAILABLE) {\n rememberUnavailable(message);\n // The refusal's sentence wins over any set the caller held: it is the newest word.\n return { message: kitMsg(INSTANCE_UNAVAILABLE), restartable: false, unavailable: true };\n }\n if (status === FLOW_ENDED_STATUS) return { message: serverSentence(message) ?? msg(\"flow_ended\"), restartable: true };\n if (status === undefined && (code === \"NETWORK_ERROR\" || code === \"TIMEOUT\")) {\n return { message: msg(\"connection_failed\"), restartable: false };\n }\n if (status === 429) return { message: msg(\"too_many_attempts\"), restartable: false };\n if (status !== undefined && status >= 500) return { message: msg(\"server_error\"), restartable: false };\n return { message: serverSentence(message) ?? msg(\"generic_error\"), restartable: false };\n}\n\nfunction readError(error: unknown): { status?: number; code?: string; message?: string } {\n if (typeof error === \"string\") return { message: error };\n if (!error || typeof error !== \"object\") return {};\n const e = error as { status?: unknown; code?: unknown; message?: unknown; data?: { error?: { code?: unknown; message?: unknown } } };\n const nested = e.data?.error;\n return {\n status: typeof e.status === \"number\" ? e.status : undefined,\n code: typeof e.code === \"string\" ? e.code : typeof nested?.code === \"string\" ? nested.code : undefined,\n message: typeof e.message === \"string\" ? e.message : typeof nested?.message === \"string\" ? nested.message : undefined,\n };\n}\n\n/** A server message fit to show: a sentence, not \"HTTP 400\" or something with code in backticks. */\nfunction serverSentence(message?: string): string | undefined {\n const text = message?.trim();\n if (!text) return undefined;\n if (/^HTTP \\d{3}\\b/.test(text) || text.includes(\"`\")) return undefined;\n const sentence = text.charAt(0).toUpperCase() + text.slice(1);\n return /[.!?。!?]$/u.test(sentence) ? sentence : `${sentence}.`;\n}\n","import { ContextProvider } from \"@lit/context\";\nimport { html, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport type { ActionErrorDetail, ActionRequestDetail } from \"../../core/controllers/action\";\nimport { fire } from \"../../core/events\";\nimport { HostElement } from \"../../core/host-element\";\nimport { msg } from \"../../core/messages\";\nimport { define } from \"../../core/names\";\nimport { brandingContext, DEFAULT_BRANDING, type BrandingEntitlements } from \"../block/branding\";\nimport { describeFlowError } from \"./flow-error\";\n\nexport {\n describeFlowError,\n FLOW_MESSAGES_EN,\n INSTANCE_UNAVAILABLE,\n isInstanceUnavailable,\n rememberUnavailable,\n type FlowErrorDescription,\n type FlowMessageCode,\n} from \"./flow-error\";\n\n/**\n * What the layout needs from an auth client: one method. `Auth` from\n * `@pontive/oidc-client` satisfies it structurally, so pont2 never imports an\n * auth client (option (b), docs/kit/layout.md).\n */\nexport interface FlowClient {\n processLoginflowEvent(request: FlowEventRequest): Promise<FlowEventResponse>;\n}\n\nexport interface FlowEventRequest {\n event: string;\n data?: Record<string, unknown>;\n}\n\n/** The parts of the SDK's `ProcessEventResponse` the layout reads. */\nexport interface FlowEventResponse {\n state?: string;\n render_spec?: unknown;\n}\n\nexport interface UnregisteredElementDetail {\n tag: string;\n}\n\n/** FormData → the plain object the flow API takes (last value wins, files dropped). */\nexport function formDataToObject(fd: FormData | undefined | null): Record<string, unknown> | undefined {\n if (!fd) return undefined;\n const out: Record<string, unknown> = {};\n for (const [k, v] of fd.entries()) if (typeof v === \"string\") out[k] = v;\n return Object.keys(out).length ? out : undefined;\n}\n\nconst BANNER = \"data-flow-error\";\nconst reported = new Set<string>();\n/** One warning per page for an unanswered submission (onFormSubmit). */\nlet warnedUnanswered = false;\n\n/**\n * # `<pont2-layout>`: renders a flow screen and runs its requests\n *\n * ```ts\n * import { Auth } from \"@pontive/oidc-client\";\n * const layout = document.createElement(\"pont2-layout\");\n * layout.client = Auth; // anything with processLoginflowEvent()\n * layout.branding = response.branding; // the account's entitlements (fail closed)\n * layout.renderSpec = response.render_spec; // the server's HTML for the screen\n * ```\n *\n * ```html\n * <pont2-layout data-pont2-layout data-slot=\"layout\">\n * <form data-slot=\"layout-form\" aria-busy=\"false\">\n * …the render spec (e.g. <pont2-block>…</pont2-block>)…\n * </form>\n * </pont2-layout>\n * ```\n *\n * The **flow host** for one screen. It:\n *\n * 1. **renders the spec** (server HTML) inside one native `<form>`, upgrading\n * pont2 elements and reporting tags this bundle does not define\n * (`pont2-unregistered-element` on `document`, once per tag);\n * 2. **answers every `pont2-action`** from inside the screen (submit, provider,\n * passkey, link, OTP, resend, forgot, edit-identifier) with\n * `client.processLoginflowEvent({ event, data })`, where `data` is the\n * form's normalised FormData when the request carries one (submit, OTP\n * auto-submit); while a request is pending, another one joins it (no double\n * submit) and the form is `aria-busy`;\n * 3. **renders the next screen** when a response carries `render_spec`;\n * 4. **shows flow errors** (every `pont2-action-error` from inside) as an\n * error `pont2-alert` banner at the top of the screen, with \"Start again\"\n * (`pont2-layout-restart`) when the flow is over (409);\n * 5. **provides the branding entitlements** (`pont2:branding` context) to the\n * screen's block. Fails closed: without `branding`, the watermark shows.\n *\n * Trust boundary: the render spec is **server HTML** and is inserted as such\n * (as in the legacy `pont-layout`); everything a user types goes through\n * native inputs, never into markup. The spec must not contain its own\n * `<form>` (the layout's form is the one form).\n *\n * @tag pont2-layout\n * @prop client - `FlowClient` (e.g. the SDK's `Auth`). Without one, actions are not answered.\n * @prop renderSpec - the screen's HTML\n * @prop branding - `BrandingEntitlements` (attribute-less on purpose)\n * @prop messages - localised flow messages by code (the flow's `messages`)\n * @fires pont2-flow-response - `{ action, result }` after every successful request\n * @fires pont2-layout-restart - \"Start again\" pressed (the widget restarts the flow)\n * @fires pont2-unregistered-element - on `document`, `{ tag }`\n */\nexport class Layout extends HostElement {\n static override identity = \"layout\";\n static override slotName = \"layout\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n client: { attribute: false },\n renderSpec: { attribute: false },\n branding: { attribute: false },\n messages: { attribute: false },\n busy: { state: true },\n };\n\n declare client: FlowClient | undefined;\n declare renderSpec: string;\n declare branding: BrandingEntitlements;\n declare messages: Partial<Record<string, string>>;\n declare protected busy: boolean;\n\n private provider = new ContextProvider(this, { context: brandingContext, initialValue: DEFAULT_BRANDING });\n private pending: Promise<FlowEventResponse> | null = null;\n\n constructor() {\n super();\n this.client = undefined;\n this.renderSpec = \"\";\n this.branding = DEFAULT_BRANDING;\n this.messages = {};\n this.busy = false;\n this.addEventListener(\"pont2-action\", e => this.onAction(e));\n this.addEventListener(\"pont2-action-error\", e => this.onError(e));\n }\n\n /** The layout's form (holds the screen). */\n get form(): HTMLFormElement | null {\n return this.querySelector(\":scope > form\");\n }\n\n /** Runs one flow request (what a `pont2-action` from inside triggers). */\n run(event: string, data?: Record<string, unknown>): Promise<FlowEventResponse> {\n const client = this.client;\n if (!client) return Promise.reject(new Error(\"pont2-layout has no client\"));\n if (this.pending) return this.pending;\n this.clearBanner();\n this.busy = true;\n // Synchronously, not on the next render: the request has started now.\n this.form?.setAttribute(\"aria-busy\", \"true\");\n const request = client\n .processLoginflowEvent(data ? { event, data } : { event })\n .then(result => {\n if (typeof result?.render_spec === \"string\" && result.render_spec) this.renderSpec = result.render_spec;\n fire(this, \"pont2-flow-response\", { action: event, result });\n return result;\n })\n .finally(() => {\n this.pending = null;\n this.busy = false;\n this.form?.setAttribute(\"aria-busy\", \"false\");\n });\n this.pending = request;\n return request;\n }\n\n private onAction(e: CustomEvent<ActionRequestDetail>): void {\n const { action, data } = e.detail;\n if (!action || !this.client) return;\n e.detail.respondWith(this.run(action, formDataToObject(data.formData as FormData | undefined)));\n }\n\n private onError(e: CustomEvent<ActionErrorDetail>): void {\n const { message, restartable } = describeFlowError(e.detail.error, this.messages);\n this.showError(message, restartable);\n }\n\n /** Shows a flow error at the top of the screen (after its logo/header). */\n showError(message: string, restartable = false): void {\n const form = this.form;\n if (!form) return;\n this.clearBanner();\n const alert = document.createElement(\"pont2-alert\");\n alert.setAttribute(\"status\", \"error\");\n alert.setAttribute(\"icon\", \"\");\n alert.setAttribute(\"description\", message);\n alert.setAttribute(BANNER, \"\");\n const banner: HTMLElement[] = [alert];\n if (restartable) {\n const shell = document.createElement(\"pont2-button\");\n shell.setAttribute(\"variant\", \"outline\");\n shell.setAttribute(BANNER, \"\");\n const b = document.createElement(\"button\");\n b.type = \"button\";\n b.textContent = this.messages.start_again || msg(\"start_again\");\n b.addEventListener(\"click\", () => fire(this, \"pont2-layout-restart\", {}));\n shell.append(b);\n banner.push(shell);\n }\n const block = form.querySelector(\":scope > pont2-block\");\n const parent = block ?? form;\n let anchor = parent.firstElementChild;\n while (anchor && /^pont2-(logo|header)$/.test(anchor.localName)) anchor = anchor.nextElementSibling;\n for (const el of banner) parent.insertBefore(el, anchor);\n }\n\n private clearBanner(): void {\n this.form?.querySelectorAll(`[${BANNER}]`).forEach(el => el.remove());\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"branding\")) this.provider.setValue(this.branding ?? DEFAULT_BRANDING);\n this.setData(\"busy\", this.busy);\n }\n\n protected override updated(changed: PropertyValues): void {\n const form = this.form;\n if (!form) return;\n form.setAttribute(\"aria-busy\", String(this.busy));\n if (changed.has(\"renderSpec\")) this.renderScreen(form);\n }\n\n private renderScreen(form: HTMLFormElement): void {\n form.innerHTML = this.renderSpec || \"\";\n for (const el of Array.from(form.querySelectorAll(\"*\"))) {\n if (!el.localName.includes(\"-\")) continue;\n if (customElements.get(el.localName)) customElements.upgrade(el);\n else if (!reported.has(el.localName)) {\n reported.add(el.localName);\n console.warn(`[pont2] <${el.localName}> is in the render spec but is not defined in this bundle.`);\n document.dispatchEvent(\n new CustomEvent<UnregisteredElementDetail>(\"pont2-unregistered-element\", { detail: { tag: el.localName } }),\n );\n }\n }\n }\n\n /**\n * The layout's form never submits natively. Every submission is either answered here (a\n * `pont2-action` the layout responds to, which prevents it) or it is a mistake: no `client`\n * yet, or a submit button without `event`. A native submission would then be a GET to the\n * current URL with every field, password included, in the query string. So whatever is left\n * unhandled is stopped here, at the form, after the submit buttons' own listeners have run.\n */\n private onFormSubmit = (e: SubmitEvent) => {\n if (e.defaultPrevented) return;\n e.preventDefault();\n if (!warnedUnanswered) {\n warnedUnanswered = true;\n console.warn(\n \"[pont2] a submission in <pont2-layout> was not answered (no client, or the submit button has no `event`). \" +\n \"Native submission is blocked.\",\n );\n }\n };\n\n override render() {\n // The form's children are the render spec, written by renderScreen(), never by this template.\n return html`<form data-slot=\"layout-form\" @submit=${this.onFormSubmit}></form>`;\n }\n}\n\ndefine(\"pont2-layout\", Layout);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-layout\": Layout;\n }\n interface HTMLElementEventMap {\n \"pont2-flow-response\": CustomEvent<{ action: string; result: FlowEventResponse }>;\n \"pont2-layout-restart\": CustomEvent<Record<string, never>>;\n }\n interface DocumentEventMap {\n \"pont2-unregistered-element\": CustomEvent<UnregisteredElementDetail>;\n }\n}\n","/**\n * The consent screen's two calls to auth-api (pontive-spec 40 §4.3), ported\n * from the legacy `pont-consent` (carry-over §8).\n *\n * Plain `fetch` rather than the auth SDK: the screen is not an auth flow. The\n * person already has a session, and the session cookie is what proves the\n * consent request is theirs, so every call is same-origin and carries it.\n *\n * GET {base}/auth/v1/consent/{id}?locales=… → { render_spec, locale?, dir? }\n * POST {base}/auth/v1/consent/{id} { event, data } → { redirect_to } | a view to render\n *\n * Errors use the platform envelope `{ error: { code, message } }` (or flat).\n * A 404 means the request expired, was already answered, or isn't this\n * session's; the server doesn't say which, and the way on is the same.\n */\n\nimport { msg } from \"../../core/messages\";\n\n/** What `GET /auth/v1/consent/{id}` answers, and a re-rendered screen. */\nexport interface ConsentView {\n render_spec: string;\n locale?: string;\n dir?: string;\n}\n\n/** What `POST /auth/v1/consent/{id}` answers. */\nexport type ConsentOutcome = { redirect_to: string } | ConsentView;\n\n/** A refused or failed consent call, shaped as `describeFlowError` reads one (`status`, `code`, `message`). */\nexport class ConsentError extends Error {\n constructor(\n message: string,\n readonly code: string,\n readonly status?: number,\n ) {\n super(message);\n this.name = \"ConsentError\";\n }\n}\n\n/** The person-facing sentence for an expired request (a 404). */\nexport const CONSENT_EXPIRED_EN = \"This request has expired. Go back to the app and try again.\";\n\n/** `consent_expired` from the page's message table, else English. */\nexport const consentExpired = () => msg(\"consent_expired\", CONSENT_EXPIRED_EN);\n\nexport function consentEndpoint(baseUrl: string, id: string): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/auth/v1/consent/${encodeURIComponent(id)}`;\n}\n\n/** Loads the screen for a consent request. */\nexport async function fetchConsent(baseUrl: string, id: string, options: { locales?: string } = {}): Promise<ConsentView> {\n const query = options.locales ? `?${new URLSearchParams({ locales: options.locales })}` : \"\";\n const body = await call(`${consentEndpoint(baseUrl, id)}${query}`, { method: \"GET\" });\n if (isView(body)) return body;\n throw new ConsentError(\"Unexpected consent response.\", \"UNEXPECTED_RESPONSE\");\n}\n\n/**\n * Answers a consent request: `allow` with the ticked scopes (`data.scope`, one\n * space-separated string, which auth-api requires), or `deny`. A 404 is reworded\n * as the expired-request sentence, so the layout's banner shows it as is.\n */\nexport async function submitConsent(\n baseUrl: string,\n id: string,\n event: string,\n data: Record<string, unknown> = {},\n): Promise<ConsentOutcome> {\n let body: unknown;\n try {\n body = await call(consentEndpoint(baseUrl, id), { method: \"POST\", body: JSON.stringify({ event, data }) });\n } catch (err) {\n if (err instanceof ConsentError && err.status === 404) throw new ConsentError(consentExpired(), err.code, err.status);\n throw err;\n }\n if (isObject(body) && typeof body.redirect_to === \"string\" && body.redirect_to) return { redirect_to: body.redirect_to };\n if (isView(body)) return body;\n throw new ConsentError(\"Unexpected consent response.\", \"UNEXPECTED_RESPONSE\");\n}\n\n/**\n * Whether the browser may be sent to a `redirect_to`. It is the app's\n * registered redirect URI, which may be a native app's custom scheme\n * (`com.example.app:/callback`), so this is not limited to http(s); it only\n * refuses the schemes that run code or read local data in this page.\n */\nexport function isNavigableRedirect(url: string, base = globalThis.location?.href): boolean {\n try {\n const { protocol } = new URL(url, base);\n return ![\"javascript:\", \"data:\", \"vbscript:\", \"blob:\", \"file:\"].includes(protocol);\n } catch {\n return false;\n }\n}\n\n/* ------------------------------------------------------------------ */\n\nasync function call(url: string, init: RequestInit): Promise<unknown> {\n let response: Response;\n try {\n response = await fetch(url, {\n ...init,\n credentials: \"same-origin\",\n headers: { Accept: \"application/json\", ...(init.body ? { \"Content-Type\": \"application/json\" } : {}) },\n });\n } catch (err) {\n throw new ConsentError(err instanceof Error ? err.message : String(err), \"NETWORK_ERROR\");\n }\n const body: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const flat = isObject(body) ? body : {};\n const envelope = isObject(flat.error) ? flat.error : {};\n const code = text(envelope.code) ?? text(flat.code) ?? \"API_ERROR\";\n const message = text(envelope.message) ?? text(flat.message) ?? `HTTP ${response.status}: ${response.statusText}`;\n throw new ConsentError(message, code, response.status);\n }\n return body;\n}\n\nfunction isView(body: unknown): body is ConsentView {\n return isObject(body) && typeof body.render_spec === \"string\";\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { MessagesController, msg } from \"../../core/messages\";\nimport { define } from \"../../core/names\";\nimport { Spinner } from \"../../primitives/spinner/spinner\";\nimport { DEFAULT_BRANDING, type BrandingEntitlements } from \"../block/branding\";\nimport { describeFlowError } from \"../layout/flow-error\";\nimport type { FlowClient, FlowEventRequest, FlowEventResponse, Layout } from \"../layout/layout\";\nimport \"../layout/layout\";\nimport { ConsentError, consentExpired, fetchConsent, isNavigableRedirect, submitConsent, type ConsentView } from \"./consent-api\";\n\nexport {\n CONSENT_EXPIRED_EN,\n ConsentError,\n consentEndpoint,\n consentExpired,\n fetchConsent,\n isNavigableRedirect,\n submitConsent,\n type ConsentOutcome,\n type ConsentView,\n} from \"./consent-api\";\n\n/**\n * # `<pont2-consent>`: an app asks for access; the person allows or denies\n *\n * ```html\n * <pont2-consent consent-request=\"cr_123\"></pont2-consent>\n * ```\n *\n * The OAuth consent screen (pontive-spec 40 §4.3), ported from the legacy\n * `pont-consent` (carry-over §8). **Not a flow widget:** the person already has\n * a session, so there is no flow to start and no SDK to wait for. The screen is\n * one consent request, which auth-api renders like a flow view (the built-in\n * `authorize_app` widget in the instance's brand and copy) and answers with a\n * redirect.\n *\n * It still renders through `pont2-layout`, with a consent-specific **client**,\n * so the markup, the error banner, the busy state and the branding entitlement\n * work as on every other screen:\n *\n * - **Load:** `GET {base-url}/auth/v1/consent/{consent-request}?locales=…`, same\n * origin with the session cookie (`fetchConsent`). The view's `locale` and\n * `dir` become the element's `lang` and `dir`.\n * - **Answer:** Allow and Deny are submit buttons naming the `allow` / `deny`\n * event; `pont2-scope-list` submits the ticked scopes as `scope`, one\n * space-separated string. The client posts `{ event, data }`\n * (`submitConsent`) and then either sends the browser to `redirect_to` (the\n * app's redirect URI, which may be a custom scheme; only code-running schemes\n * are refused) or renders the screen the server sent back.\n * - **Errors:** a request that expired, was already answered or isn't this\n * session's (404) says \"This request has expired. Go back to the app and try\n * again.\" (`consent_expired`) and offers nothing to retry. Any other failure\n * is worded by `describeFlowError` and offers \"Start again\", which reloads the\n * request.\n *\n * @tag pont2-consent\n * @attr consent-request - the consent request's id (the page's `consent_request` parameter)\n * @attr base-url - where auth-api is; empty (default) means same origin, which the session cookie needs\n * @attr locales - preferred languages, passed to the load (`?locales=`)\n * @prop branding - the account's branding entitlements (fail closed: the watermark shows)\n */\nexport class Consent extends HostElement {\n static override identity = \"consent\";\n\n static override properties: PropertyDeclarations = {\n consentRequest: { type: String, attribute: \"consent-request\" },\n baseUrl: { type: String, attribute: \"base-url\" },\n locales: { type: String },\n branding: { attribute: false },\n renderSpec: { state: true },\n loadError: { state: true },\n };\n\n declare consentRequest: string;\n declare baseUrl: string;\n declare locales: string;\n declare branding: BrandingEntitlements;\n declare protected renderSpec: string;\n declare protected loadError: { message: string; retryable: boolean } | null;\n\n protected readonly messagesController = new MessagesController(this);\n\n /** Bumped per load, so only the latest answer lands on the screen. */\n private loadSeq = 0;\n /** The request, server and languages last loaded: a change means load again. */\n private loadedKey: string | null = null;\n\n /**\n * What the layout calls for Allow / Deny. Stable for the element's lifetime:\n * the layout keeps it across screens.\n */\n readonly client: FlowClient = {\n processLoginflowEvent: (request: FlowEventRequest) => this.answer(request),\n };\n\n constructor() {\n super();\n this.consentRequest = \"\";\n this.baseUrl = \"\";\n this.locales = \"\";\n this.branding = DEFAULT_BRANDING;\n this.renderSpec = \"\";\n this.loadError = null;\n this.addEventListener(\"pont2-layout-restart\", () => void this.load());\n }\n\n /** The element's layout. */\n get layout(): Layout | null {\n return this.querySelector(\"pont2-layout\");\n }\n\n /** Loads (or reloads) the consent request. */\n async load(): Promise<void> {\n const seq = ++this.loadSeq;\n this.loadError = null;\n try {\n if (!this.consentRequest) throw new ConsentError(\"No consent request was given.\", \"MISSING_REQUEST\");\n const view = await fetchConsent(this.baseUrl, this.consentRequest, { locales: this.locales || undefined });\n if (seq === this.loadSeq) this.show(view);\n } catch (err) {\n if (seq !== this.loadSeq) return;\n console.error(`[pont2] <${this.localName}>: loading the consent request failed:`, err);\n const expired = (err as { status?: number })?.status === 404;\n const { message, unavailable } = describeFlowError(err);\n // An empty shell to show the error in. An expired request stays expired; a stopped instance stays stopped.\n this.renderSpec = \"<pont2-block></pont2-block>\";\n this.loadError = expired ? { message: consentExpired(), retryable: false } : { message, retryable: !unavailable };\n }\n }\n\n private show(view: ConsentView): void {\n if (view.locale) this.lang = view.locale;\n if (view.dir === \"rtl\" || view.dir === \"ltr\") this.dir = view.dir;\n this.renderSpec = view.render_spec;\n }\n\n private async answer({ event, data }: FlowEventRequest): Promise<FlowEventResponse> {\n const outcome = await submitConsent(this.baseUrl, this.consentRequest, event, data);\n if (\"redirect_to\" in outcome) {\n if (!isNavigableRedirect(outcome.redirect_to)) {\n throw new ConsentError(\"Unexpected consent response.\", \"UNSAFE_REDIRECT\");\n }\n location.assign(outcome.redirect_to);\n return {};\n }\n this.show(outcome);\n return { render_spec: outcome.render_spec };\n }\n\n protected override willUpdate(_changed: PropertyValues): void {\n this.setData(\"state\", this.loadError ? \"error\" : this.renderSpec ? \"screen\" : \"loading\");\n // First render, or a different request, server or language: load (again).\n const key = JSON.stringify([this.consentRequest, this.baseUrl, this.locales]);\n if (key !== this.loadedKey) {\n this.loadedKey = key;\n void this.load();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n // The app's placeholder (`<… ><div part=\"fallback\">…</div></…>`, which the pontkit bindings\n // rely on) goes once there is a screen or an error to show (migration tracker F-17).\n if (this.renderSpec) this.querySelector(':scope > [part=\"fallback\"]')?.remove();\n if (changed.has(\"loadError\") && this.loadError) {\n const { message, retryable } = this.loadError;\n const layout = this.layout;\n void layout?.updateComplete.then(() => layout.showError(message, retryable));\n }\n }\n\n override render() {\n if (!this.renderSpec) {\n // The app's own placeholder stands in for the spinner while it is there.\n if (this.querySelector(':scope > [part=\"fallback\"]')) return nothing;\n return html`<div data-slot=\"flow-widget-loading\">\n <span ${Spinner.part({ \"aria-label\": msg(\"loading\") })}></span>\n </div>`;\n }\n return html`<pont2-layout .client=${this.client} .branding=${this.branding} .renderSpec=${this.renderSpec}></pont2-layout>`;\n }\n}\n\ndefine(\"pont2-consent\", Consent);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-consent\": Consent;\n }\n}\n","import { html, nothing, type PropertyDeclarations, type PropertyValues } from \"lit\";\n\nimport { HostElement } from \"../../core/host-element\";\nimport { MessagesController, msg, setMessages } from \"../../core/messages\";\nimport { define } from \"../../core/names\";\nimport { Spinner } from \"../../primitives/spinner/spinner\";\nimport { DEFAULT_BRANDING, type BrandingEntitlements } from \"../block/branding\";\nimport { describeFlowError, type FlowMessageCode } from \"../layout/flow-error\";\nimport type { FlowClient, Layout } from \"../layout/layout\";\nimport \"../layout/layout\";\n\n/**\n * What a widget needs from an auth client: the layout's `processLoginflowEvent`\n * plus `startLoginflow`, and optionally `whenConfigured`. The SDK's `Auth`\n * satisfies it structurally (docs/kit/layout.md, option (b)).\n */\nexport interface WidgetClient extends FlowClient {\n startLoginflow(flowId?: string): Promise<FlowStart>;\n whenConfigured?(): Promise<void>;\n}\n\n/** The parts of the SDK's `StartLoginflowResponse` a widget reads. */\nexport interface FlowStart {\n render_spec?: unknown;\n messages?: Record<string, string>;\n}\n\n/** The parts of the SDK's `FlowStateChangeEvent` a widget reads. */\nexport interface FlowStateEvent {\n eventType: string;\n flowType?: string;\n render_spec?: unknown;\n messages?: Record<string, string>;\n}\n\n/**\n * Feeds the SDK's asynchronous flow-state changes (a resumed flow, a flow an\n * emailed link continued, \"continued in another tab\") to every connected\n * pont2 flow widget of that `flowType`.\n *\n * The SDK reports them only through the one `onFlowStateChange` callback of\n * `Auth.configure()` (which replaces the whole configuration), so the widget\n * cannot subscribe by itself; the app that configures `Auth` passes this:\n *\n * ```ts\n * Auth.configure({ …config, onFlowStateChange: dispatchFlowState });\n * ```\n */\nexport function dispatchFlowState(event: FlowStateEvent): void {\n document.dispatchEvent(new CustomEvent<FlowStateEvent>(\"pont2-flow-state\", { detail: event }));\n}\n\n/** Text placed in a double-quoted attribute of markup built as a string. */\nexport function escapeAttr(value: string): string {\n return value.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\n\n/** How long to wait for `client.whenConfigured()` before warning and trying anyway. */\nconst CONFIGURE_TIMEOUT = 5000;\n\n/**\n * # FlowWidget: the base of `<pont2-signin>` / `<pont2-signup>`\n *\n * ```ts\n * import { Auth } from \"@pontive/oidc-client\";\n * import { dispatchFlowState } from \"@pontive/pontkit-core/pont2\";\n *\n * Auth.configure({ …, onFlowStateChange: dispatchFlowState });\n * document.querySelector(\"pont2-signin\")!.client = Auth;\n * ```\n *\n * ```html\n * <pont2-signin data-pont2-flow-widget data-slot=\"flow-widget\" data-state=\"screen\">\n * <pont2-layout>…the current screen…</pont2-layout>\n * </pont2-signin>\n * ```\n *\n * It **starts the flow** (`client.startLoginflow(flowId)`, after\n * `client.whenConfigured()` when the client has one), renders **one\n * `pont2-layout`** with the screen, the client, the branding entitlements and\n * the flow's localised messages, and keeps it current:\n *\n * - each request's next screen is rendered by the layout itself;\n * - asynchronous changes arrive through `dispatchFlowState` (see above): a new\n * `render_spec`, new `messages`, or `flow_continued_elsewhere`, which shows\n * \"You continued in another tab\" with a \"Continue here instead\" link\n * (`continue_here`, handled by the SDK);\n * - \"Start again\" in the layout (`pont2-layout-restart`), or `restart()`,\n * starts the flow over;\n * - a flow that fails to start shows the error in the layout, restartable.\n *\n * Until the first screen arrives it shows a spinner (`data-state=\"loading\"`).\n *\n * Nesting `pont2-layout` in a kit template is the allow-listed case (docs/10\n * §5 rule 6): the layout is the stateful flow host, one per widget.\n *\n * @prop client - `WidgetClient` (e.g. the SDK's `Auth`); the flow starts once it is set and the widget is connected\n * @prop branding - `BrandingEntitlements` from the backend (attribute-less; fails closed)\n * @attr flow-id - the flow to start (each widget has a default)\n * @fires pont2-flow-response - (from the layout) after every successful request\n */\nexport abstract class FlowWidget extends HostElement {\n static override identity = \"flow-widget\";\n static override slotName = \"flow-widget\";\n static override composite = true;\n\n static override properties: PropertyDeclarations = {\n client: { attribute: false },\n branding: { attribute: false },\n flowId: { type: String, attribute: \"flow-id\" },\n renderSpec: { state: true },\n messages: { state: true },\n starting: { state: true },\n startError: { state: true },\n };\n\n declare client: WidgetClient | undefined;\n declare branding: BrandingEntitlements;\n declare flowId: string;\n declare protected renderSpec: string;\n declare protected messages: Partial<Record<string, string>>;\n declare protected starting: boolean;\n declare protected startError: { message: string; restartable: boolean } | null;\n /** Re-renders when the page's message table changes (the loading label). */\n protected readonly messagesController = new MessagesController(this);\n\n /** The SDK's `flowType` this widget runs (\"signin\", \"signup\"): which flow-state events apply. */\n protected abstract readonly flowType: string;\n\n private started = false;\n\n constructor() {\n super();\n this.client = undefined;\n this.branding = DEFAULT_BRANDING;\n this.flowId = \"\";\n this.renderSpec = \"\";\n this.messages = {};\n this.starting = false;\n this.startError = null;\n this.addEventListener(\"pont2-layout-restart\", () => void this.restart());\n }\n\n /** The widget's layout. */\n get layout(): Layout | null {\n return this.querySelector(\"pont2-layout\");\n }\n\n /** Starts the flow over. */\n async restart(): Promise<void> {\n this.started = false;\n await this.start();\n }\n\n /** Applies an SDK flow-state change (what `dispatchFlowState` delivers). */\n applyFlowState(event: FlowStateEvent): void {\n if (event.flowType && event.flowType !== this.flowType) return;\n if (event.messages) this.receiveMessages(event.messages);\n if (event.eventType === \"flow_continued_elsewhere\") {\n this.startError = null;\n this.renderSpec = this.continuedElsewhereSpec();\n return;\n }\n if (typeof event.render_spec === \"string\" && event.render_spec) {\n this.startError = null;\n this.renderSpec = event.render_spec;\n }\n }\n\n /** A set the flow sent: this widget's, and the page's message table (core/messages.ts). */\n private receiveMessages(messages: Record<string, string>): void {\n this.messages = { ...messages };\n setMessages(messages);\n }\n\n private msg(code: FlowMessageCode): string {\n return this.messages[code] || msg(code);\n }\n\n private continuedElsewhereSpec(): string {\n return `<pont2-block>\n <pont2-header>\n <pont2-title content=\"${escapeAttr(this.msg(\"continued_elsewhere_title\"))}\"></pont2-title>\n <pont2-subtitle content=\"${escapeAttr(this.msg(\"continued_elsewhere_subtitle\"))}\"></pont2-subtitle>\n </pont2-header>\n <pont2-link label=\"${escapeAttr(this.msg(\"continue_here\"))}\" event=\"continue_here\"></pont2-link>\n</pont2-block>`;\n }\n\n private onFlowState = (e: Event) => this.applyFlowState((e as CustomEvent<FlowStateEvent>).detail);\n\n override connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener(\"pont2-flow-state\", this.onFlowState);\n void this.start();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"pont2-flow-state\", this.onFlowState);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n this.setData(\"state\", this.startError ? \"error\" : this.renderSpec ? \"screen\" : \"loading\");\n // Only a newly set client starts the flow; a failed start waits for \"Start again\"\n // (re-renders must never retry on their own).\n if (changed.has(\"client\") && this.client && this.isConnected && !this.started) void this.start();\n }\n\n protected override updated(changed: PropertyValues): void {\n // The app's placeholder (`<… ><div part=\"fallback\">…</div></…>`, which the pontkit bindings\n // rely on) goes once there is a screen or an error to show (migration tracker F-17).\n if (this.renderSpec) this.querySelector(':scope > [part=\"fallback\"]')?.remove();\n // The layout renders its form on its own update; show the error once it has.\n if (changed.has(\"startError\") && this.startError) {\n const { message, restartable } = this.startError;\n const layout = this.layout;\n // \"Start again\", unless the instance has stopped: starting again would only be refused again.\n void layout?.updateComplete.then(() => layout.showError(message, restartable));\n }\n }\n\n private async start(): Promise<void> {\n const client = this.client;\n if (!client || this.started) return;\n this.started = true;\n this.starting = true;\n this.startError = null;\n try {\n if (client.whenConfigured) {\n const configured = await Promise.race([\n client.whenConfigured().then(() => true),\n new Promise<false>(r => setTimeout(() => r(false), CONFIGURE_TIMEOUT)),\n ]);\n if (!configured) console.warn(`[pont2] <${this.localName}>: the client is not configured after ${CONFIGURE_TIMEOUT}ms.`);\n }\n const flowId = this.flowId || this.defaultFlowId();\n // No id at all (an invitation): the SDK picks the flow from the page's path.\n const res = await (flowId ? client.startLoginflow(flowId) : client.startLoginflow());\n if (res?.messages) this.receiveMessages(res.messages);\n if (typeof res?.render_spec === \"string\") this.renderSpec = res.render_spec;\n } catch (err) {\n console.error(`[pont2] <${this.localName}>: starting the flow failed:`, err);\n this.started = false;\n // An empty shell to show the error in, with \"Start again\" (restartable).\n this.renderSpec = \"<pont2-block></pont2-block>\";\n const { message, unavailable } = describeFlowError(err, this.messages);\n this.startError = { message, restartable: !unavailable };\n } finally {\n this.starting = false;\n }\n }\n\n /** The flow id used when `flow-id` is not set; `undefined` lets the SDK choose (an invitation). */\n protected abstract defaultFlowId(): string | undefined;\n\n override render() {\n if (!this.renderSpec) {\n // The app's own placeholder stands in for the spinner while it is there.\n if (this.querySelector(':scope > [part=\"fallback\"]')) return nothing;\n return html`<div data-slot=\"flow-widget-loading\">\n <span ${Spinner.part({ \"aria-label\": msg(\"loading\") })}></span>\n </div>`;\n }\n return html`<pont2-layout\n .client=${this.client}\n .branding=${this.branding}\n .messages=${this.messages}\n .renderSpec=${this.renderSpec}\n ></pont2-layout>`;\n }\n}\n\n/**\n * # `<pont2-signin>`: the sign-in widget\n *\n * Runs `sys_signin-flow-passkey` (the legacy default) unless `flow-id` says otherwise.\n *\n * @tag pont2-signin\n */\nexport class SignIn extends FlowWidget {\n protected readonly flowType = \"signin\";\n protected defaultFlowId() {\n return \"sys_signin-flow-passkey\";\n }\n}\n\n/**\n * # `<pont2-signup>`: the sign-up widget\n *\n * Runs `sys_signup-flow` (the legacy default) unless `flow-id` says otherwise.\n *\n * @tag pont2-signup\n */\nexport class SignUp extends FlowWidget {\n protected readonly flowType = \"signup\";\n protected defaultFlowId() {\n return \"sys_signup-flow\";\n }\n}\n\n/**\n * # `<pont2-invitation>`: accepting an invitation\n *\n * The invitee arrives from an emailed link holding a token and nothing else.\n * They aren't asked who they are, since the invitation already knows: the widget\n * starts the **invitation flow**, which resolves the token, decides whether the\n * invitee signs in or registers, and accepts the invitation once they are\n * authenticated. A port of the legacy `pont-invitation` (migration tracker W-4).\n *\n * It starts with **no flow id**: the SDK takes the invitation flow from the\n * page's path, so the app names that path as `invitationUrl` when it configures\n * the SDK (the legacy provider's `env.invitationUrl`; `<pont2-provider>` will\n * do it, W-1). An invitation answered by the sign-in flow would sign the invitee\n * in and join them to nothing, which is why this is its own element. The page\n * should also drop an existing session before the flow (the legacy\n * `answersInvitation`; the provider's job, W-1).\n *\n * Everything on screen comes from the flow's render spec: the instance's own\n * invitation widgets if it published any, else the built-in ones.\n *\n * @tag pont2-invitation\n */\nexport class Invitation extends FlowWidget {\n protected readonly flowType = \"invitation\";\n protected defaultFlowId() {\n return undefined;\n }\n}\n\ndefine(\"pont2-signin\", SignIn);\ndefine(\"pont2-signup\", SignUp);\ndefine(\"pont2-invitation\", Invitation);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"pont2-signin\": SignIn;\n \"pont2-signup\": SignUp;\n \"pont2-invitation\": Invitation;\n }\n interface DocumentEventMap {\n \"pont2-flow-state\": CustomEvent<FlowStateEvent>;\n }\n}\n","/**\n * Previewing pont2 screens without a server: what the dashboard's branding\n * editor shows (docs/12-theming-integration.md §3).\n *\n * The backend does not emit pont2 render specs yet (docs/09 decision 2), so a\n * preview cannot ask a real flow for its screens. These sample screens are\n * written the way a render spec would write them, and between them they use\n * every auth element whose tokens a brand is likely to change.\n *\n * Preview inside a real `<pont2-signin>` / `<pont2-signup>`, not a bare\n * `pont2-layout`: widget-scope theme values (`widgets.signin` …) apply to the\n * widget's tag, so only a widget shows them.\n *\n * ```ts\n * import { previewClient, PREVIEW_SCREENS } from \"@pontive/pontkit-core/pont2\";\n *\n * const widget = document.querySelector(\"pont2-signin\")!;\n * widget.client = previewClient(PREVIEW_SCREENS.signin.spec);\n * // switching screens later:\n * widget.client = previewClient(PREVIEW_SCREENS.verify.spec);\n * void widget.restart();\n * ```\n *\n * Pure data and a plain object: no DOM, no Lit, no network.\n */\nimport type { FlowEventRequest, FlowEventResponse } from \"../layout/layout\";\nimport type { FlowStart, WidgetClient } from \"./flow-widget\";\n\nexport interface PreviewScreen {\n /** A name for a screen picker. */\n label: string;\n /** The widget to preview it in (its tag is `pont2-<flow>`). */\n flow: \"signin\" | \"signup\";\n /** The screen, as a render spec would write it. */\n spec: string;\n}\n\nconst signin = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Welcome back\"></pont2-title>\n <pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>\n </pont2-header>\n <pont2-provider-field providers=\"google apple github\"></pont2-provider-field>\n <pont2-divider label=\"Or continue with\"></pont2-divider>\n <pont2-identifier-field identifiers=\"email username\" required></pont2-identifier-field>\n <pont2-submit-button event=\"submit_identifier\" label=\"Continue\"></pont2-submit-button>\n <pont2-passkey-button content=\"icon-label\" event=\"passkey\"></pont2-passkey-button>\n <pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>\n</pont2-block>`;\n\nconst password = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Enter your password\"></pont2-title>\n </pont2-header>\n <pont2-edit-identifier identifier=\"ada@example.com\" event=\"change_identifier\"></pont2-edit-identifier>\n <pont2-password-field required rules=\"[]\" forgot forgot-event=\"forgot_password\"></pont2-password-field>\n <pont2-submit-button event=\"submit_password\" label=\"Sign in\"></pont2-submit-button>\n</pont2-block>`;\n\nconst verify = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Check your email\"></pont2-title>\n <pont2-subtitle content=\"We sent a 6-digit code to ada@example.com\"></pont2-subtitle>\n </pont2-header>\n <pont2-alert status=\"info\" icon description=\"The code expires in 10 minutes.\"></pont2-alert>\n <pont2-container align=\"center\">\n <pont2-otp-field layout=\"simple\" required></pont2-otp-field>\n </pont2-container>\n <pont2-submit-button event=\"verify_code\" label=\"Verify\"></pont2-submit-button>\n <pont2-otp-resend duration=\"30\" event=\"resend_code\"></pont2-otp-resend>\n</pont2-block>`;\n\nconst signup = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Create an account\"></pont2-title>\n <pont2-subtitle content=\"It only takes a minute\"></pont2-subtitle>\n </pont2-header>\n <pont2-name-field required></pont2-name-field>\n <pont2-email-field required></pont2-email-field>\n <pont2-password-field required></pont2-password-field>\n <pont2-confirm-field required></pont2-confirm-field>\n <pont2-submit-button event=\"submit_signup\" label=\"Create account\"></pont2-submit-button>\n <pont2-link prompt=\"Already have an account?\" label=\"Sign in\" event=\"goto_signin\"></pont2-link>\n</pont2-block>`;\n\n/** Sample screens for a branding preview, keyed by id. */\nexport const PREVIEW_SCREENS = {\n signin: { label: \"Sign in\", flow: \"signin\", spec: signin },\n password: { label: \"Password\", flow: \"signin\", spec: password },\n verify: { label: \"Verification code\", flow: \"signin\", spec: verify },\n signup: { label: \"Sign up\", flow: \"signup\", spec: signup },\n} as const satisfies Record<string, PreviewScreen>;\n\nexport type PreviewScreenId = keyof typeof PREVIEW_SCREENS;\n\nexport interface PreviewClientOptions {\n /** How long each request stays busy, in ms, so busy states can be seen (default 600). */\n delay?: number;\n /** The flow's localised messages (flow errors, \"Start again\" …). */\n messages?: Record<string, string>;\n}\n\n/**\n * A `WidgetClient` that shows one screen and never leaves it. Every request\n * (a submit, a provider button, a link) is busy for `delay` ms and then\n * resolves without a new screen, so the screen and what was typed stay put.\n * Nothing is sent anywhere.\n */\nexport function previewClient(spec: string, options: PreviewClientOptions = {}): WidgetClient {\n const delay = options.delay ?? 600;\n const messages = { ...options.messages };\n return {\n async whenConfigured() {},\n async startLoginflow(): Promise<FlowStart> {\n return { render_spec: spec, messages };\n },\n processLoginflowEvent(_request: FlowEventRequest): Promise<FlowEventResponse> {\n return new Promise(resolve => setTimeout(() => resolve({ state: \"preview\" }), delay));\n },\n };\n}\n","/**\n * Preview specimens: one component at a time, for the dashboard's Component\n * scope (docs/14-dashboard-branding.md §\"Previews\").\n *\n * `PREVIEW_SCREENS` shows whole sign-in screens, which is right for the\n * Global scope. When the branding editor is open on one component (\"Button\",\n * \"Alert\" …) it shows that component's specimen instead: its variants, sizes\n * and states side by side, so every token in its panel has something visible\n * to change.\n *\n * - **Keyed by token component** (a manifest `component`, `tokens.json`), not\n * by tag: that is what the editor's items are. A guardrail checks every key\n * is one.\n * - **pont2 owns the markup.** The dashboard renders `html` as given and never\n * writes pont2 markup itself, so a markup change here never needs a\n * dashboard change.\n * - Specimens sit at the global scope (no widget around them): the editor's\n * Component scope edits `:root` tokens.\n * - Nothing in a specimen reaches a server: there is no flow host, so action\n * buttons only show their busy state, if anything.\n *\n * Pure data: no DOM, no Lit, no network.\n */\n\nexport interface PreviewSpecimen {\n /** A name for the specimen. */\n label: string;\n /** The markup to render, inside a `<form>` that does not submit. */\n html: string;\n}\n\nconst row = (items: string) => `<div style=\"display:flex;flex-wrap:wrap;gap:.75rem;align-items:center\">${items}</div>`;\nconst stack = (items: string, width = \"24rem\") =>\n `<div style=\"display:grid;gap:1.5rem;max-width:${width}\">${items}</div>`;\nconst caption = (text: string) =>\n `<p style=\"margin:0 0 .5rem;font-size:.75rem;opacity:.6\">${text}</p>`;\nconst section = (title: string, body: string) => `<section>${caption(title)}${body}</section>`;\n\nconst VARIANTS = [\"default\", \"secondary\", \"outline\", \"ghost\", \"destructive\", \"link\"];\nconst SIZES = [\"xs\", \"sm\", \"default\", \"lg\"];\n\nconst button = stack(\n [\n section(\n \"Variants\",\n row(VARIANTS.map(v => `<button type=\"button\" data-pont2-button data-variant=\"${v}\">${v[0].toUpperCase()}${v.slice(1)}</button>`).join(\"\")),\n ),\n section(\n \"Sizes\",\n row(SIZES.map(s => `<button type=\"button\" data-pont2-button data-size=\"${s}\">Size ${s}</button>`).join(\"\")),\n ),\n section(\n \"Disabled\",\n row(`<button type=\"button\" data-pont2-button disabled>Default</button><button type=\"button\" data-pont2-button data-variant=\"outline\" disabled>Outline</button>`),\n ),\n ].join(\"\"),\n \"40rem\",\n);\n\nconst field = (id: string, label: string, input: string, description = \"\") =>\n `<pont2-prim-field>\n <label data-pont2-label data-pont2-field-label data-slot=\"field-label\" for=\"${id}\">${label}</label>\n ${input}\n ${description ? `<pont2-prim-field-description>${description}</pont2-prim-field-description>` : \"\"}\n </pont2-prim-field>`;\n\nconst inputs = stack(\n [\n section(\"Default\", `<input data-pont2-input id=\"s-input\" placeholder=\"you@example.com\">`),\n section(\"Filled\", `<input data-pont2-input value=\"ada@example.com\">`),\n section(\"Invalid\", `<input data-pont2-input aria-invalid=\"true\" value=\"not-an-email\">`),\n section(\"Disabled\", `<input data-pont2-input disabled value=\"Disabled\">`),\n ].join(\"\"),\n);\n\nconst fields = stack(\n [\n field(\"s-email\", \"Email\", `<input data-pont2-input id=\"s-email\" type=\"email\" placeholder=\"you@example.com\">`, \"We'll never share it.\"),\n field(\"s-name\", \"Name\", `<input data-pont2-input id=\"s-name\" aria-invalid=\"true\">`, \"This field is required.\"),\n `<pont2-email-field required></pont2-email-field>`,\n `<pont2-password-field required rules=\"[]\" forgot></pont2-password-field>`,\n ].join(\"\"),\n);\n\nconst checkbox = stack(\n [\n row(`<pont2-checkbox id=\"s-c1\" checked></pont2-checkbox><label data-pont2-label for=\"s-c1\">Remember me</label>`),\n row(`<pont2-checkbox id=\"s-c2\"></pont2-checkbox><label data-pont2-label for=\"s-c2\">Unchecked</label>`),\n row(`<pont2-checkbox id=\"s-c3\" aria-invalid=\"true\"></pont2-checkbox><label data-pont2-label for=\"s-c3\">Invalid</label>`),\n row(`<pont2-checkbox id=\"s-c4\" checked disabled></pont2-checkbox><label data-pont2-label for=\"s-c4\">Disabled</label>`),\n ].join(\"\"),\n);\n\nconst alerts = stack(\n [\n `<pont2-alert icon heading=\"Default\" description=\"A neutral message.\"></pont2-alert>`,\n `<pont2-alert icon status=\"info\" heading=\"New sign-in\" description=\"We noticed a sign-in from a new device.\"></pont2-alert>`,\n `<pont2-alert icon status=\"success\" heading=\"Saved\" description=\"Your changes have been saved.\"></pont2-alert>`,\n `<pont2-alert icon status=\"warning\" heading=\"Almost out\" description=\"Your code expires in one minute.\"></pont2-alert>`,\n `<pont2-alert icon status=\"error\" heading=\"Sign-in failed\" description=\"Check your email and password.\"></pont2-alert>`,\n ].join(\"\"),\n \"28rem\",\n);\n\nconst badges = row(\n [\"default\", \"secondary\", \"outline\", \"destructive\", \"ghost\", \"link\"]\n .map(v => `<pont2-badge variant=\"${v}\">${v}</pont2-badge>`)\n .join(\"\"),\n);\n\nconst block = `<pont2-block>\n <pont2-header>\n <pont2-title content=\"Welcome back\"></pont2-title>\n <pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>\n </pont2-header>\n <pont2-email-field required></pont2-email-field>\n <pont2-submit-button event=\"submit\" label=\"Continue\"></pont2-submit-button>\n</pont2-block>`;\n\nconst typography = stack(\n [\n `<pont2-title content=\"Welcome back\"></pont2-title>`,\n `<pont2-subtitle content=\"Sign in to your account\"></pont2-subtitle>`,\n ].join(\"\"),\n);\n\nexport const PREVIEW_SPECIMENS: Readonly<Record<string, PreviewSpecimen>> = {\n button: { label: \"Button\", html: button },\n \"provider-button\": {\n label: \"Provider buttons\",\n html: stack(\n [\n `<pont2-provider-button provider=\"google\"></pont2-provider-button>`,\n `<pont2-provider-button provider=\"apple\"></pont2-provider-button>`,\n row(`<pont2-provider-button provider=\"google\" content=\"icon\"></pont2-provider-button><pont2-provider-button provider=\"github\" content=\"icon\"></pont2-provider-button>`),\n `<pont2-passkey-button content=\"icon-label\"></pont2-passkey-button>`,\n ].join(\"\"),\n ),\n },\n input: { label: \"Input\", html: inputs },\n field: { label: \"Field\", html: fields },\n label: { label: \"Label\", html: fields },\n checkbox: { label: \"Checkbox\", html: checkbox },\n \"input-otp\": {\n label: \"One-time code\",\n html: stack(\n [\n `<pont2-input-otp aria-label=\"Verification code\"></pont2-input-otp>`,\n `<pont2-input-otp group-size=\"3\" separator aria-label=\"Code\"></pont2-input-otp>`,\n ].join(\"\"),\n ),\n },\n \"otp-resend\": { label: \"Resend code\", html: `<pont2-otp-resend duration=\"5\" event=\"resend_code\"></pont2-otp-resend>` },\n link: {\n label: \"Link\",\n html: stack(\n [\n `<pont2-link prompt=\"Don't have an account?\" label=\"Sign up\" event=\"goto_signup\"></pont2-link>`,\n `<pont2-link label=\"Forgot password?\" event=\"forgot\"></pont2-link>`,\n ].join(\"\"),\n ),\n },\n alert: { label: \"Alert\", html: alerts },\n separator: {\n label: \"Separator\",\n html: stack(`<pont2-separator></pont2-separator><pont2-divider label=\"Or continue with\"></pont2-divider>`),\n },\n badge: { label: \"Badge\", html: badges },\n block: { label: \"Block\", html: block },\n header: { label: \"Header\", html: block },\n container: { label: \"Container\", html: block },\n title: { label: \"Title\", html: typography },\n subtitle: { label: \"Subtitle\", html: typography },\n avatar: {\n label: \"Avatar\",\n html: row(\n `<pont2-avatar alt=\"Ada Lovelace\" size=\"sm\"></pont2-avatar><pont2-avatar alt=\"Grace Hopper\"></pont2-avatar><pont2-avatar alt=\"Katherine Johnson\" size=\"lg\"></pont2-avatar>`,\n ),\n },\n \"qr-code\": {\n label: \"QR code\",\n html: `<pont2-qr-code url=\"otpauth://totp/Pontive:ada@example.com?secret=JBSWY3DPEHPK3PXP\" timeout=\"0\" label=\"Scan with your authenticator app\"></pont2-qr-code>`,\n },\n \"recovery-codes\": {\n label: \"Recovery codes\",\n html: `<pont2-recovery-codes codes='[\"3f9a-81c2\",\"7d01-4be9\",\"a6c4-02f7\",\"5e88-c13d\",\"90b2-7fa6\",\"1c5e-d840\"]'></pont2-recovery-codes>`,\n },\n watermark: {\n label: \"Watermark\",\n html: stack(`<pont2-watermark></pont2-watermark><pont2-watermark variant=\"muted\" label=\"Secured by\"></pont2-watermark>`),\n },\n};\n"],"names":["AttrsDirective","Directive","info","PartType","_attrs","noChange","part","map","applyAttrs","attrs","directive","el","previous","k","v","s","PREFIX","PRIM","tag","name","primTag","identityAttr","identity","sel","tags","define","ctor","aliases","defineAlias","kitTag","base","alias","_HostElement","LitElement","extra","id","identitiesOf","changed","ReactiveElement","value","attr","on","HostElement","out","c","_ShellElement","options","_a","ShellElement","_NativeEnhancer","child","NativeEnhancer","_FormControlElement","message","disabled","state","_state","own","FormControlElement","counter","uid","scope","ensureId","toggleIdRef","ids","fireNative","target","type","fire","detail","cancelable","icon","body","html","icons","a","svg","KIT_MESSAGES_EN","current","currentLocaleTag","listeners","setMessages","messages","locale","listener","msg","code","fallback","currentLocale","onMessagesChanged","resetMessages","MessagesController","host","safeUrl","raw","url","safeExternalUrl","directionOf","owner","defaultDisabled","RovingFocusController","e","item","i","items","orientation","rtl","horizontal","vertical","step","next","_b","active","enabled","stop","from","ok","loop","ActionController","action","data","response","open","result","error","CopyController","kind","duration","text","BADGE_VARIANTS","_Badge","Badge","BUTTON_VARIANTS","BUTTON_SIZES","applyButton","o","native","isSoftDisabled","button","content","variant","size","slot","soft","onClick","nothing","recipeProperties","_Pont2Button","control","Pont2Button","_ButtonBase","focusableWhenDisabled","href","rel","ButtonBase","_Checkbox","Checkbox","applyInput","input","live","_Pont2Input","Pont2Input","_Kbd","Kbd","_KbdGroup","KbdGroup","applyLabel","label","_Pont2Label","Pont2Label","_Separator","Separator","_Skeleton","Skeleton","_Spinner","Spinner","applyTextarea","textarea","_Pont2Textarea","Pont2Textarea","ALERT_VARIANTS","_Alert","Alert","_AlertTitle","AlertTitle","_AlertDescription","AlertDescription","_AlertAction","AlertAction","_Avatar","img","status","Avatar","_AvatarFallback","AvatarFallback","_AvatarBadge","AvatarBadge","_AvatarGroup","AvatarGroup","_AvatarGroupCount","AvatarGroupCount","_ButtonGroup","ButtonGroup","_ButtonGroupText","ButtonGroupText","_ButtonGroupSeparator","ButtonGroupSeparator","_Card","Card","_CardHeader","CardHeader","_CardTitle","CardTitle","_CardDescription","CardDescription","_CardAction","CardAction","_CardContent","CardContent","_CardFooter","CardFooter","_Empty","Empty","_EmptyHeader","EmptyHeader","_EmptyMedia","EmptyMedia","_EmptyTitle","EmptyTitle","_EmptyDescription","EmptyDescription","_EmptyContent","EmptyContent","applyFieldSet","fieldSet","fieldLegend","_FieldSetElement","FieldSetElement","_FieldGroup","FieldGroup","_Field","Field","_FieldContent","FieldContent","applyFieldLabel","fieldLabel","_FieldLabelElement","FieldLabelElement","_FieldTitle","FieldTitle","_FieldDescription","FieldDescription","_FieldSeparator","FieldSeparator","_FieldError","unique","FieldError","_InputGroup","InputGroup","_InputGroupAddon","InputGroupAddon","_InputGroupText","InputGroupText","CONTROL","markControl","inputGroupInput","inputGroupTextarea","inputGroupButton","_InputGroupInput","InputGroupInput","_InputGroupTextarea","InputGroupTextarea","InputGroupButton","_ItemGroup","ItemGroup","_ItemSeparator","ItemSeparator","_Item","Item","_ItemMedia","ItemMedia","_ItemContent","ItemContent","_ItemTitle","ItemTitle","_ItemDescription","ItemDescription","_ItemActions","ItemActions","_ItemHeader","ItemHeader","_ItemFooter","ItemFooter","_NativeSelect","select","applyNativeSelect","NativeSelect","nativeSelect","_Table","Table","PARTS","mark","applyTable","table","section","row","cell","REGEXP_ONLY_DIGITS","REGEXP_ONLY_CHARS","REGEXP_ONLY_DIGITS_AND_CHARS","sanitizeOtp","maxLength","pattern","re","ch","otpSlots","focused","selStart","selEnd","chars","start","end","collapsed","_","char","isActive","ROOT","SLOT","FORWARDED","_InputOTP","n","m","r","f","states","invalid","order","clean","was","digits","InputOTP","_InputOTPGroup","InputOTPGroup","_InputOTPSlot","hasFakeCaret","InputOTPSlot","_InputOTPSeparator","InputOTPSeparator","_Progress","span","labels","l","parts","p","styleMap","Progress","ProgressPart","_formatted","_ProgressLabel","ProgressLabel","_ProgressValue","formatted","ProgressValue","_RadioGroup","checked","RadioGroup","_RadioGroupItem","RadioGroupItem","clamp","min","max","decimals","snap","snapped","d","fraction","valueAt","closestThumb","values","best","bestDist","setThumb","index","range","minSteps","gap","lo","hi","keyValue","key","opts","small","flip","parseValues","b","_Slider","onThumb","_c","arr","fd","final","rect","thumb","t","fr","thumbPos","rangeStyle","names","repeat","_v","Slider","_Switch","Switch","TRIGGER","PANEL","relate","internals","prop","targets","_Tabs","trigger","triggers","to","panels","ready","list","panel","Tabs","_TabsList","direction","TabsList","_TabsTrigger","TabsTrigger","_TabsContent","TabsContent","OPPOSITE","toPhysical","side","dir","toRequestedVocabulary","physical","requested","isVertical","spaceOn","anchor","viewport","offset","pad","computePosition","floating","align","sideOffset","alignOffset","collisionPadding","shift","need","here","there","x","y","startEdge","endEdge","sign","mainSpace","availableHeight","availableWidth","ax","ay","transformOrigin","round","alignItemWithAnchor","AnchoredPositioner","anchorEl","style","set","it","aligned","isItemDisabled","isItemVisible","moveIndex","move","isDisabled","keyToMove","Typeahead","timeout","repeated","search","stack","globalListeners","installGlobalListeners","top","path","popup","_PopupContent","reason","gen","anims","PopupContent","openPopups","ownQuery","root","selector","rootSelector","ownQueryAll","_PopupRoot","hadFocus","focusWasInside","PopupRoot","_PopupTrigger","_e","PopupTrigger","FOCUSABLE","_Popover","Popover","_PopoverTrigger","PopoverTrigger","_PopoverContent","title","desc","PopoverContent","_PopoverHeader","PopoverHeader","_PopoverTitle","PopoverTitle","_PopoverDescription","PopoverDescription","ROOTS","CONTENT","ITEM","trueUnlessFalse","_DropdownMenu","focus","DropdownMenu","_DropdownMenuSub","DropdownMenuSub","_DropdownMenuTrigger","DropdownMenuTrigger","_DropdownMenuContent","DropdownMenuSubTrigger","closeKey","DropdownMenuSubContent","sub","except","keep","DropdownMenuContent","_DropdownMenuSubContent","_MenuItemBase","MenuItemBase","_DropdownMenuItem","DropdownMenuItem","indicator","_DropdownMenuCheckboxItem","DropdownMenuCheckboxItem","_DropdownMenuRadioGroup","DropdownMenuRadioGroup","_DropdownMenuRadioItem","DropdownMenuRadioItem","_DropdownMenuSubTrigger","openKey","_DropdownMenuGroup","DropdownMenuGroup","_DropdownMenuLabel","DropdownMenuLabel","_DropdownMenuSeparator","DropdownMenuSeparator","_DropdownMenuShortcut","DropdownMenuShortcut","_Select","Select","_SelectTrigger","SelectTrigger","_SelectContent","SelectContent","_SelectItem","selected","SelectItem","_SelectGroup","SelectGroup","_SelectLabel","SelectLabel","_SelectSeparator","SelectSeparator","_Combobox","query","norm","scroll","q","visible","show","group","empty","Combobox","_ComboboxInput","hasValue","ComboboxInput","_ComboboxContent","ComboboxContent","_ComboboxList","ComboboxList","_ComboboxItem","ComboboxItem","_ComboboxEmpty","ComboboxEmpty","_ComboboxGroup","ComboboxGroup","_ComboboxLabel","ComboboxLabel","_ComboboxSeparator","ComboboxSeparator","_Tooltip","ms","Tooltip","_TooltipTrigger","TooltipTrigger","_TooltipContent","TooltipContent","ALERT_STATUSES","STATUS_ICON","_KitAlert","KitAlert","initials","words","w","_KitAvatar","KitAvatar","groupSizes","length","g","left","otpGroups","groupSize","separator","slots","sep","_KitInputOTP","KitInputOTP","AUTH_PROVIDERS","PROVIDER_NAMES","MARKS","isAuthProvider","providerIcon","provider","AUTH_BUTTON_CONTENTS","_AuthButton","iconOnly","busy","showIcon","showLabel","AuthButton","_ProviderButton","ProviderButton","PasskeyButton","SubmitButton","form","isDefault","formData","cap","fieldMessages","compilePattern","source","positive","focusClaimed","_AuthField","issues","describedBy","descId","errId","AuthField","EmailField","PhoneField","UsernameField","NameField","IDENTIFIER_KINDS","identifierLabel","kinds","_IdentifierField","IdentifierField","PASSWORD_RULE_PATTERNS","DEFAULT_PASSWORD_RULES","ruleRegExp","rulesConverter","parsed","_SecretField","SecretField","_PasswordField","failing","PasswordField","_ConfirmField","pair","other","ConfirmField","_OtpField","otp","byLayout","OtpField","_OtpResend","OtpResend","_Link","_changed","Link","ExternalLink","_Divider","Divider","_TextShell","TextShell","_Title","level","Title","Subtitle","providerColumns","count","providerEvent","listConverter","jsonArray","_ProviderField","overrides","opt","ProviderField","PONTIVE_MARK","PONTIVE_WORDMARK","pontiveLogo","watermarkContent","logoAlign","_Watermark","Watermark","DEFAULT_BRANDING","brandingContext","createContext","BrandingController","ContextConsumer","_Block","Block","_Container","Container","_Header","Header","_Gap","Gap","logoSource","theme","_Logo","light","dark","alt","Logo","safeRedirect","_Countdown","Countdown","_EditIdentifier","EditIdentifier","_Secret","copied","meta","Secret","QUIET","qrPath","modules","QRCode","_QrCode","obscured","QrCode","codesConverter","_RecoveryCodes","codes","off","RecoveryCodes","normalizeScopes","scopes","seen","granted","required","isScopeChecked","unticked","scopeListValue","scopesConverter","_ScopeList","ticked","ScopeList","FLOW_MESSAGES_EN","FLOW_ENDED_STATUS","INSTANCE_UNAVAILABLE","isInstanceUnavailable","readError","rememberUnavailable","sentence","describeFlowError","kitMsg","serverSentence","nested","formDataToObject","BANNER","reported","warnedUnanswered","_Layout","ContextProvider","event","client","request","restartable","alert","banner","shell","parent","Layout","ConsentError","CONSENT_EXPIRED_EN","consentExpired","consentEndpoint","baseUrl","fetchConsent","call","isView","submitConsent","err","isObject","isNavigableRedirect","protocol","init","flat","envelope","_Consent","seq","view","expired","unavailable","outcome","retryable","layout","Consent","dispatchFlowState","escapeAttr","CONFIGURE_TIMEOUT","_FlowWidget","flowId","res","FlowWidget","SignIn","SignUp","Invitation","signin","password","verify","signup","PREVIEW_SCREENS","previewClient","spec","delay","_request","resolve","width","caption","VARIANTS","SIZES","field","description","inputs","fields","checkbox","alerts","badges","block","typography","PREVIEW_SPECIMENS"],"mappings":";;;;;;;AAeA,MAAMA,WAAuBC,GAAU;AAAA,EAGrC,YAAYC,GAAgB;AAE1B,QADA,MAAMA,CAAI,GAHZ,KAAQ,2BAAW,IAAA,GAIbA,EAAK,SAASC,GAAS,QAAS,OAAM,IAAI,MAAM,0CAA0C;AAAA,EAChG;AAAA,EAEA,OAAOC,GAAiB;AACtB,WAAOC;AAAA,EACT;AAAA,EAES,OAAOC,GAAmB,CAACC,CAAG,GAAc;AACnD,WAAAC,GAAWF,EAAK,SAASC,GAAK,KAAK,IAAI,GACvC,KAAK,OAAO,IAAI,IAAI,OAAO,KAAKA,CAAG,CAAC,GAC7BF;AAAA,EACT;AACF;AAEO,MAAMI,IAAQC,GAAUV,EAAc;AAGtC,SAASQ,GAAWG,GAAaJ,GAAcK,GAAmC;AACvF,MAAIA;AAAU,eAAWC,KAAKD,EAAU,CAAMC,KAAKN,KAAMI,EAAG,gBAAgBE,CAAC;AAC7E,aAAW,CAACA,GAAGC,CAAC,KAAK,OAAO,QAAQP,CAAG;AACrC,QAAIO,MAAM,MAASA,KAAK;AACtB,MAAIH,EAAG,aAAaE,C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