{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shell",
  "type": "registry:ui",
  "title": "<ui-shell>",
  "description": "ui-shell component. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [
    "lit@^3.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-mega-menu",
    "@kanok-ui/core-overlay",
    "@kanok-ui/core-popup",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-events",
    "@kanok-ui/shared-field",
    "@kanok-ui/shared-localize",
    "@kanok-ui/shared-navigate",
    "@kanok-ui/shared-slots",
    "@kanok-ui/tooltip",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/shell/content.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/content.ts",
      "content": "import { customElement } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport type { UiSideNav } from './side-nav.ts';\n\n/**\n * Carbon `Content`: the `<main id=\"main-content\">` area, offset by the 48px header (and by a\n * `fixed` or `rail` side nav). 32px padding.\n *\n * @slot - Page content\n */\n@customElement('ui-content')\nexport class UiContent extends UiElement {\n    static override readonly styles = css`\n        /*\n         * No margin or padding on :host — a page-wide CSS reset would remove them. Beside the side nav the host\n         * is shifted and narrowed instead (--_nav); the 48px under the header is the part's top margin, which\n         * collapses through the host, and the 32px padding is the part's.\n         */\n        :host {\n            --_nav: 0px;\n\n            position: relative;\n            display: block;\n            inset-inline-start: var(--_nav);\n            inline-size: calc(100% - var(--_nav));\n            background-color: var(--ui-canvas);\n            color: var(--ui-ink);\n            font-family: var(--ui-font-family);\n        }\n\n        .base {\n            margin-block-start: 48px;\n            padding: 32px;\n        }\n\n        :host([data-side-nav='fixed']) {\n            --_nav: 256px;\n        }\n\n        :host([data-side-nav='rail']) {\n            --_nav: 48px;\n        }\n\n        @media (min-width: 1056px) {\n            :host([data-side-nav='default']) {\n                --_nav: 256px;\n            }\n        }\n    `;\n\n    /** Follows the side nav's mode when the page switches it (rail / fixed / collapsible). */\n    private navObserver?: MutationObserver;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.id) this.id = 'main-content';\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'main');\n        this.syncSideNav();\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.navObserver?.disconnect();\n        this.navObserver = undefined;\n    }\n\n    /** Offset by the sibling side nav's mode (fixed 256 / rail 48 / default 256 from lg / collapsible 0), on the page or in the same shadow root (a micro app). */\n    private syncSideNav() {\n        const root = this.getRootNode() as Document | ShadowRoot;\n        const nav = root.querySelector?.<UiSideNav>('ui-side-nav') ?? this.ownerDocument.querySelector<UiSideNav>('ui-side-nav');\n        if (!nav) return;\n        if (!this.navObserver) {\n            this.navObserver = new MutationObserver(() => this.syncSideNav());\n            this.navObserver.observe(nav, { attributes: true, attributeFilter: ['rail', 'fixed', 'collapsible'] });\n        }\n        this.dataset.sideNav = sideNavMode(nav);\n    }\n\n    override render() {\n        return html`<div class=\"base\"><slot @slotchange=${() => this.syncSideNav()}></slot></div>`;\n    }\n}\n\n/** How a side nav sits beside the content: pushing it 256 (fixed) / 48 (rail) / 256 from lg (default), or over it (collapsible). */\nfunction sideNavMode(nav: UiSideNav) {\n    if (nav.fixed) return 'fixed';\n    if (nav.rail) return 'rail';\n    return nav.collapsible ? 'collapsible' : 'default';\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-content': UiContent;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-global-action.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-global-action.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html } from 'lit';\nimport type { UiHeaderPanel } from './header-panel.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport '../tooltip/tooltip.ts';\n\n/**\n * Carbon `HeaderGlobalAction`: a 48px icon button in the header, named by `label` through an icon\n * tooltip. `active` shows the pressed state used while its `<ui-header-panel>` is open.\n *\n * @slot - 20px icon\n * @csspart base - The button\n * @cssprop --ui-header-action-radius - Corners of the button's hover fill and focus box (default 0; Kanok: 6px)\n */\n@customElement('ui-header-global-action')\nexport class UiHeaderGlobalAction extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n            block-size: 100%;\n        }\n\n        ui-tooltip {\n            display: block;\n            block-size: 100%;\n        }\n\n        button {\n            display: inline-flex;\n            align-items: center;\n            justify-content: center;\n            box-sizing: border-box;\n            inline-size: 48px;\n            block-size: 48px;\n            padding: 0;\n            border: 1px solid transparent;\n            border-radius: var(--ui-header-action-radius, 0); /* a design can round the hover and focus box (Carbon: square) */\n            background: transparent;\n            color: var(--ui-icon-secondary);\n            cursor: pointer;\n            outline: none;\n            transition:\n                background-color var(--ui-duration-moderate),\n                border-color var(--ui-duration-moderate);\n        }\n\n        button:hover {\n            background-color: var(--ui-canvas-hover);\n            color: var(--ui-icon-primary);\n        }\n\n        button:active {\n            background-color: var(--ui-canvas-active);\n            color: var(--ui-icon-primary);\n        }\n\n        button:focus-visible {\n            border-color: var(--ui-focus);\n        }\n\n        :host([active]) button {\n            background-color: var(--ui-surface-1);\n            border-block-end-color: transparent;\n            border-inline-color: var(--ui-border-subtle-1);\n            color: var(--ui-icon-primary);\n        }\n\n        ::slotted(svg) {\n            width: 20px;\n            height: 20px;\n            fill: currentColor;\n        }\n    `;\n\n    @property() label = '';\n\n    @property({ type: Boolean, reflect: true }) active = false;\n\n    @property({ attribute: 'tooltip-placement' }) tooltipPlacement: 'bottom' | 'bottom-start' | 'bottom-end' = 'bottom';\n\n    /**\n     * Id of the `<ui-header-panel>` this action opens. Clicking toggles the panel, `active` follows it,\n     * and the button reports `aria-expanded` (a disclosure) instead of `aria-pressed` (a toggle).\n     * The button has an explicit tabindex, as Carbon's (cds-button): Safari then focuses it on click and Tab reaches it.\n     */\n    @property() panel = '';\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.addEventListener('click', this.onClick);\n        this.root = this.getRootNode() as Document | ShadowRoot;\n        this.root.addEventListener('ui-toggle', this.onPanelToggle);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('click', this.onClick);\n        // the root it listened on: once removed, getRootNode() is the detached subtree, not the document\n        this.root?.removeEventListener('ui-toggle', this.onPanelToggle);\n        this.root = undefined;\n    }\n\n    /** The document or shadow root whose panels this action follows. */\n    private root?: Document | ShadowRoot;\n\n    private get panelElement() {\n        if (!this.panel) return null;\n        return (this.getRootNode() as Document | ShadowRoot).getElementById(this.panel) as UiHeaderPanel | null;\n    }\n\n    private readonly onClick = () => {\n        const panel = this.panelElement;\n        if (panel) panel.expanded = !panel.expanded;\n    };\n\n    /** The panel also closes itself (Escape, focus leaving); keep `active` in step. */\n    private readonly onPanelToggle = (event: Event) => {\n        if (this.panel && (event.target as Element | null)?.id === this.panel) this.active = (event as CustomEvent<{ expanded: boolean }>).detail.expanded;\n    };\n\n    override render() {\n        const disclosure = this.panel !== '';\n        return html`<ui-tooltip as-label text=${this.label} placement=${this.tooltipPlacement}>\n            <button\n                part=\"base\"\n                type=\"button\"\n                tabindex=\"0\"\n                aria-expanded=${ifDefined(disclosure ? String(this.active) : undefined)}\n                aria-pressed=${ifDefined(!disclosure && this.active ? 'true' : undefined)}\n            ><slot></slot></button>\n        </ui-tooltip>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-global-action': UiHeaderGlobalAction;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-global-bar.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-global-bar.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport { LocalizeController } from '../shared/localize.ts';\n\n/**\n * Carbon `HeaderGlobalBar`: right-aligned area for `<ui-header-global-action>`s.\n *\n * @slot - Global actions\n */\n@customElement('ui-header-global-bar')\nexport class UiHeaderGlobalBar extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: flex;\n            flex: 1 1 0%;\n            justify-content: flex-end;\n            block-size: 100%;\n        }\n    `;\n\n    @property() label = '';\n\n    private readonly localize = new LocalizeController(this);\n\n    override render() {\n        return html`<div role=\"group\" aria-label=${this.label || this.localize.t.common.globalActions} style=\"display: flex; height: 100%\"><slot></slot></div>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-global-bar': UiHeaderGlobalBar;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-mega-group.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-mega-group.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html, nothing } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { uid } from '../shared/field.ts';\n\n/**\n * A column of a `<ui-header-mega-menu>` panel: a small `heading` (Vercel's \"Learn\", \"Build\", \"Explore\") over a list of\n * `<ui-header-mega-item>`s, the list named by the heading.\n *\n * @slot - `<ui-header-mega-item>` elements\n * @csspart heading - The heading\n * @csspart list - The list of links\n * @cssprop --ui-mega-heading-font - The heading's type (default Carbon's 12px caption; Kanok: 14px)\n */\n@customElement('ui-header-mega-group')\nexport class UiHeaderMegaGroup extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n            min-inline-size: 0;\n        }\n\n        .heading {\n            margin: 0 0 8px;\n            color: var(--ui-ink-muted);\n            font: var(--ui-mega-heading-font, var(--ui-font-caption));\n            letter-spacing: var(--ui-tracking-caption, 0.32px);\n        }\n\n        .list {\n            display: flex;\n            flex-direction: column;\n            gap: 2px;\n            margin: 0;\n            padding: 0;\n        }\n    `;\n\n    @property() heading = '';\n\n    private readonly headingId = uid('ui-header-mega-group');\n\n    override render() {\n        return html`\n            ${this.heading ? html`<p class=\"heading\" part=\"heading\" id=${this.headingId}>${this.heading}</p>` : nothing}\n            <div class=\"list\" part=\"list\" role=\"list\" aria-labelledby=${ifDefined(this.heading ? this.headingId : undefined)}><slot></slot></div>\n        `;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-mega-group': UiHeaderMegaGroup;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-mega-item.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-mega-item.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, nothing } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * One link of a `<ui-header-mega-group>`: a title (the default slot), and optionally an icon (`icon` slot) and a\n * one-line `description` under the title (Vercel's Products menu). `current` marks the page (`aria-current=\"page\"`).\n * Following it closes the mega menu.\n *\n * @slot - The title\n * @slot icon - An icon before the title (20px)\n * @csspart base - The link\n * @csspart description - The line under the title\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n * @cssprop --ui-mega-item-font - The title's type (default Carbon's body 14px; Kanok: 20px, as Vercel)\n * @cssprop --ui-mega-item-ink - The title's colour (default `--ui-ink-muted`; Kanok: `--ui-ink`); hovered or current it is `--ui-ink`\n * @cssprop --ui-mega-item-hover-background - The row's fill while hovered (default `--ui-layer-hover-1`; Kanok: `--ui-canvas-hover`)\n * @cssprop --ui-mega-item-radius - The row's corners (default 0; Kanok: 8px)\n */\n@customElement('ui-header-mega-item')\nexport class UiHeaderMegaItem extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n        }\n\n        a {\n            display: flex;\n            align-items: flex-start;\n            gap: 12px;\n            box-sizing: border-box;\n            margin-inline: -8px;\n            padding: 8px;\n            border-radius: var(--ui-mega-item-radius, 0);\n            color: var(--ui-mega-item-ink, var(--ui-ink-muted));\n            text-decoration: none;\n            outline: none;\n            transition:\n                background-color var(--ui-duration-moderate),\n                color var(--ui-duration-moderate);\n        }\n\n        a:hover {\n            background-color: var(--ui-mega-item-hover-background, var(--ui-layer-hover-1));\n            color: var(--ui-ink);\n        }\n\n        a:focus-visible {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: -2px;\n        }\n\n        :host([current]) a {\n            color: var(--ui-ink);\n        }\n\n        .icon {\n            display: none;\n            flex: none;\n            place-items: center;\n            inline-size: 20px;\n            block-size: 20px;\n            margin-block-start: 2px;\n            fill: currentColor;\n        }\n\n        .icon.filled {\n            display: grid;\n        }\n\n        .text {\n            display: flex;\n            flex-direction: column;\n            gap: 2px;\n            min-inline-size: 0;\n        }\n\n        .title {\n            font: var(--ui-mega-item-font, var(--ui-font-body-sm));\n            letter-spacing: var(--ui-tracking-body);\n        }\n\n        :host([current]) .title {\n            font-weight: 600;\n        }\n\n        .description {\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-body-sm);\n            letter-spacing: var(--ui-tracking-body);\n        }\n\n        @media (forced-colors: active) {\n            :host([current]) a {\n                outline: 1px solid Highlight;\n            }\n        }\n    `;\n\n    @property() href = '#';\n\n    /** A line under the title. */\n    @property() description = '';\n\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n    private hasIcon = false;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('current')) (this.closest('ui-header-mega-menu') as LitElement | null)?.requestUpdate();\n    }\n\n    private onIconSlotChange(event: Event) {\n        this.hasIcon = (event.target as HTMLSlotElement).assignedNodes().length > 0;\n        this.requestUpdate();\n    }\n\n    override render() {\n        return html`<a part=\"base\" href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} aria-current=${ifDefined(this.current ? 'page' : undefined)} @click=${followLink}>\n            <span class=\"icon ${this.hasIcon ? 'filled' : ''}\" aria-hidden=\"true\"><slot name=\"icon\" @slotchange=${this.onIconSlotChange}></slot></span>\n            <span class=\"text\"><span class=\"title\"><slot></slot></span>${this.description ? html`<span class=\"description\" part=\"description\">${this.description}</span>` : nothing}</span>\n        </a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-mega-item': UiHeaderMegaItem;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-mega-menu.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-mega-menu.ts",
      "content": "import { customElement, property, query, state } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, isServer, nothing } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { hasData, uid } from '../shared/field.ts';\nimport { chevron, headerTriggerStyles } from './shell-shared.ts';\nimport type { OpenDetail } from '../shared/events.ts';\nimport { outsidePress } from '../../core/popup.ts';\nimport { MEGA_HOVER_CLOSE_MS, megaClosed, megaClosesOnLeave, megaHoverDelay, megaHoverPointer, megaTriggerPress, type MegaOpenedBy, type MegaState } from '../../core/mega-menu.ts';\n\n/** Where the panel goes: under the header, as wide as it. */\ninterface PanelBox {\n    top: number;\n    left: number;\n    width: number;\n}\n\n/**\n * A header menu-bar entry that opens a full-width panel of `<ui-header-mega-group>` columns under the header (a mega\n * menu, as Vercel's): put it in `<ui-header-nav>` next to `<ui-header-menu-item>`s and `<ui-header-menu>`s.\n *\n * - With a mouse, resting on it opens the panel after 150ms; while another one is open, moving to it switches at once;\n *   leaving the entry and its panel closes a panel the pointer opened, after 300ms. A finger opens it by a tap.\n * - Click / Enter / Space toggle it (a panel the pointer opened stays open); ↓ opens it and moves to the first link.\n * - Escape, clicking outside, Tab out of it and following one of its links close it; Escape and a link return focus to it.\n * - One panel at a time: opening it closes the other menus of the bar.\n * - A disclosure (APG disclosure navigation): the links stay links, so the button has no `aria-haspopup`.\n * - In a narrow `<ui-header-nav collapse>` (and in the side nav's copy of the bar) it is an accordion row instead.\n *\n * While closed it shows the current-page bar when one of its items is `current`; `current` shows it always.\n *\n * @slot - `<ui-header-mega-group>` elements\n * @fires ui-toggle - detail: { open }\n * @csspart trigger - The menu-bar entry\n * @csspart panel - The panel under the header\n * @csspart content - The grid of groups inside the panel\n * @cssprop --ui-mega-panel-background - The panel's fill (default the overlay's, `--ui-surface-1`; Kanok: the page's white)\n * @cssprop --ui-mega-panel-shadow - Its shadow (default Carbon's menu shadow; Kanok: a soft one)\n * @cssprop --ui-mega-panel-border - Its bottom edge (default none; Kanok: a hairline)\n * @cssprop --ui-mega-column-width - The narrowest a group column gets (default 240px)\n * @cssprop --ui-mega-gap - Between the columns (default 32px)\n * @cssprop --ui-mega-padding - Around the columns (default 24px 32px 32px)\n */\n@customElement('ui-header-mega-menu')\nexport class UiHeaderMegaMenu extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = [\n        headerTriggerStyles,\n        css`\n            :host {\n                position: relative;\n                display: block;\n                block-size: 100%;\n            }\n\n            /* a manual popover: the top layer, above a host app's own fixed bars whatever their z-index */\n            .panel {\n                position: fixed;\n                inset: auto;\n                box-sizing: border-box;\n                margin: 0;\n                padding: 0;\n                border: 0;\n                color: var(--ui-ink);\n                max-block-size: calc(100vh - var(--_top, 48px));\n                overflow-y: auto;\n                border-block-end: var(--ui-mega-panel-border, none);\n                background-color: var(--ui-mega-panel-background, var(--ui-overlay-background, var(--ui-surface-1)));\n                box-shadow: var(--ui-mega-panel-shadow, 0 4px 8px 0 rgb(0 0 0 / 0.5));\n                animation: ui-mega-in var(--ui-duration-fast, 110ms) var(--ui-easing);\n            }\n\n            .panel[hidden] {\n                display: none;\n            }\n\n            @keyframes ui-mega-in {\n                from {\n                    opacity: 0;\n                    transform: translateY(-4px);\n                }\n            }\n\n            @media (prefers-reduced-motion: reduce) {\n                .panel {\n                    animation: none;\n                }\n            }\n\n            .content {\n                display: grid;\n                grid-template-columns: repeat(auto-fill, minmax(var(--ui-mega-column-width, 240px), 1fr));\n                gap: var(--ui-mega-gap, 32px);\n                box-sizing: border-box;\n                padding: var(--ui-mega-padding, 24px 32px 32px);\n            }\n\n            /* a narrow collapsed bar (and the side nav's copy): an accordion row, its groups stacked under it */\n            :host([data-in-side-nav]) {\n                block-size: auto;\n            }\n\n            :host([data-in-side-nav]) .trigger {\n                inline-size: 100%;\n                block-size: 48px;\n                justify-content: space-between;\n            }\n\n            :host([data-in-side-nav]) .panel {\n                position: static;\n                inline-size: auto;\n                max-block-size: none;\n                overflow: visible;\n                border: none;\n                background-color: transparent;\n                box-shadow: none;\n                animation: none;\n            }\n\n            :host([data-in-side-nav]) .content {\n                grid-template-columns: minmax(0, 1fr);\n                gap: 24px;\n                padding: 8px 16px 24px;\n            }\n\n            @media (forced-colors: active) {\n                .panel {\n                    border-block-end: 1px solid CanvasText;\n                }\n            }\n        `,\n    ];\n\n    @property() label = '';\n\n    @property({ type: Boolean, reflect: true }) open = false;\n\n    /** Mark the menu as the current section even while open. */\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    @state() private box: PanelBox | null = null;\n\n    @query('.trigger') private readonly trigger!: HTMLButtonElement;\n\n    private readonly panelId = uid('ui-header-mega-menu');\n\n    private openedBy: MegaOpenedBy | null = null;\n\n    private openTimer?: ReturnType<typeof setTimeout>;\n\n    private closeTimer?: ReturnType<typeof setTimeout>;\n\n    private stopOutside?: () => void;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n        this.addEventListener('pointerenter', this.onPointerEnter);\n        this.addEventListener('pointerleave', this.onPointerLeave);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('pointerenter', this.onPointerEnter);\n        this.removeEventListener('pointerleave', this.onPointerLeave);\n        this.clearTimers();\n        this.stopListening();\n    }\n\n    private get collapsed() {\n        return hasData(this, 'inSideNav');\n    }\n\n    private get megaState(): MegaState {\n        return { open: this.open, openedBy: this.openedBy };\n    }\n\n    private apply(next: MegaState) {\n        this.openedBy = next.openedBy;\n        if (next.open && !this.collapsed) this.closeOthers();\n        this.open = next.open;\n    }\n\n    /** The bar's other menus (one panel at a time). */\n    private others() {\n        const bar = this.parentElement;\n        if (!bar) return [];\n        return [...bar.children].filter((el): el is HTMLElement & { open: boolean } => el !== this && (el.localName === 'ui-header-mega-menu' || el.localName === 'ui-header-menu'));\n    }\n\n    private closeOthers() {\n        for (const other of this.others()) other.open = false;\n    }\n\n    private clearTimers() {\n        clearTimeout(this.openTimer);\n        clearTimeout(this.closeTimer);\n    }\n\n    private readonly onPointerEnter = (event: PointerEvent) => {\n        if (this.collapsed || !megaHoverPointer(event.pointerType)) return;\n        this.clearTimers();\n        if (this.open) return;\n        const delay = megaHoverDelay(this.others().some((other) => other.open));\n        if (delay === 0) this.apply({ open: true, openedBy: 'hover' });\n        else this.openTimer = setTimeout(() => this.apply({ open: true, openedBy: 'hover' }), delay);\n    };\n\n    private readonly onPointerLeave = (event: PointerEvent) => {\n        if (this.collapsed || !megaHoverPointer(event.pointerType)) return;\n        clearTimeout(this.openTimer);\n        if (!megaClosesOnLeave(this.megaState)) return;\n        this.closeTimer = setTimeout(() => {\n            if (megaClosesOnLeave(this.megaState)) this.apply(megaClosed);\n        }, MEGA_HOVER_CLOSE_MS);\n    };\n\n    private onTriggerClick(event: MouseEvent) {\n        this.clearTimers();\n        // a click from Enter / Space has no pointer position (detail 0)\n        this.apply(megaTriggerPress(this.megaState, event.detail === 0 ? 'keyboard' : 'click'));\n    }\n\n    private async onTriggerKeydown(event: KeyboardEvent) {\n        if (event.key !== 'ArrowDown') return;\n        event.preventDefault();\n        if (!this.open) this.apply({ open: true, openedBy: 'keyboard' });\n        await this.updateComplete;\n        this.querySelector<HTMLElement>('ui-header-mega-item')?.focus();\n    }\n\n    protected override willUpdate(changed: Map<string, unknown>) {\n        // placed before the render that shows it: no frame at the wrong place\n        if (changed.has('open') && this.open && !this.collapsed) this.place();\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (!changed.has('open')) return;\n        this.syncPopover();\n        if (this.open) this.startListening();\n        else {\n            this.openedBy = null;\n            this.clearTimers();\n            this.stopListening();\n        }\n        if (changed.get('open') !== undefined) {\n            this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { open: this.open }, bubbles: true, composed: true }));\n        }\n    }\n\n    /** Shows the panel in the top layer while open (not in the narrow sheet, where it is an accordion row). */\n    private syncPopover() {\n        const panel = this.shadowRoot?.querySelector<HTMLElement>('.panel');\n        if (!panel?.hasAttribute('popover')) return;\n        const shown = panel.matches(':popover-open');\n        if (this.open && !shown) panel.showPopover();\n        else if (!this.open && shown) panel.hidePopover();\n    }\n\n    private startListening() {\n        if (this.collapsed) return;\n        // a finger scroll doesn't close it: only a tap outside does\n        this.stopOutside ??= outsidePress(document, this.onDocumentPointerDown);\n        document.addEventListener('keydown', this.onKeydown, true);\n        window.addEventListener('resize', this.place);\n        window.addEventListener('scroll', this.place, { capture: true, passive: true });\n    }\n\n    private stopListening() {\n        this.stopOutside?.();\n        this.stopOutside = undefined;\n        document.removeEventListener('keydown', this.onKeydown, true);\n        window.removeEventListener('resize', this.place);\n        window.removeEventListener('scroll', this.place, { capture: true });\n    }\n\n    /** Under the header and as wide as it (the page's width without one): a header inside a host app's frame still fits. */\n    private readonly place = () => {\n        const header = this.closest('ui-header')?.shadowRoot?.querySelector('header') ?? null;\n        const rect = (header ?? this).getBoundingClientRect();\n        this.box = header ? { top: rect.bottom, left: rect.left, width: rect.width } : { top: rect.bottom, left: 0, width: document.documentElement.clientWidth };\n    };\n\n    private readonly onDocumentPointerDown = (event: PointerEvent) => {\n        if (!event.composedPath().includes(this)) this.apply(megaClosed);\n    };\n\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (event.key !== 'Escape') return;\n        event.stopPropagation();\n        this.apply(megaClosed);\n        this.trigger.focus();\n    };\n\n    private onFocusOut(event: FocusEvent) {\n        if (this.collapsed) return;\n        const next = event.relatedTarget as Node | null;\n        if (next && !this.contains(next) && !this.shadowRoot?.contains(next)) this.apply(megaClosed);\n    }\n\n    private onPanelClick(event: MouseEvent) {\n        if (this.collapsed || !(event.target as Element).closest('ui-header-mega-item')) return;\n        this.apply(megaClosed);\n        this.trigger.focus();\n    }\n\n    override render() {\n        // the server renders no current bar from the items (no DOM to read there); the page's first update draws it\n        const current = this.current || (!isServer && !this.open && [...this.querySelectorAll<HTMLElement & { current: boolean }>('ui-header-mega-item')].some((item) => item.current));\n        const box = this.box && !this.collapsed ? { top: `${this.box.top}px`, left: `${this.box.left}px`, width: `${this.box.width}px`, '--_top': `${this.box.top}px` } : {};\n        return html`\n            <button class=\"trigger ${current ? 'current' : ''}\" part=\"trigger\" type=\"button\" tabindex=\"0\" aria-expanded=${this.open ? 'true' : 'false'} aria-controls=${this.panelId} @click=${this.onTriggerClick} @keydown=${this.onTriggerKeydown} @focusout=${this.onFocusOut}>\n                ${this.label}${chevron}\n            </button>\n            <div class=\"panel\" part=\"panel\" id=${this.panelId} popover=${this.collapsed ? nothing : 'manual'} ?hidden=${this.collapsed && !this.open} style=${styleMap(box)} @focusout=${this.onFocusOut} @click=${this.onPanelClick}>\n                <div class=\"content\" part=\"content\"><slot @slotchange=${() => this.requestUpdate()}></slot></div>\n            </div>\n        `;\n    }\n}\n\nexport interface UiHeaderMegaMenuEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<OpenDetail>;\n}\n\n/** Typed listeners for UiHeaderMegaMenu's events (declaration merging with the class). */\nexport interface UiHeaderMegaMenu {\n    addEventListener<K extends keyof UiHeaderMegaMenuEventMap>(type: K, listener: (this: UiHeaderMegaMenu, event: UiHeaderMegaMenuEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiHeaderMegaMenuEventMap>(type: K, listener: (this: UiHeaderMegaMenu, event: UiHeaderMegaMenuEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-mega-menu': UiHeaderMegaMenu;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-menu-button.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-menu-button.ts",
      "content": "import { html, LitElement, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport type { HeaderMenuButtonToggleDetail } from './shell-shared.ts';\n\nconst menuIcon = html`<svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><path d=\"M2 14.8h16v1.2H2zm0-5.4h16v1.2H2zM2 4h16v1.2H2z\" /></svg>`;\n\nconst closeIcon = html`<svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><path d=\"M15 5.8 14.2 5 10 9.2 5.8 5 5 5.8 9.2 10 5 14.2l.8.8 4.2-4.2 4.2 4.2.8-.8L10.8 10z\" /></svg>`;\n\n/**\n * Carbon `HeaderMenuButton`: the hamburger that opens / closes a `<ui-side-nav>` below the `lg`\n * breakpoint (hidden above it unless `collapsible`). As Carbon web components, the side nav in the\n * same document (or shadow root) follows it by itself and keeps `active` in step; call\n * `preventDefault()` on `ui-toggle` to handle it yourself.\n *\n * @fires ui-toggle - cancelable; detail: { active } the state the user asked for\n * @csspart base - The button\n */\n@customElement('ui-header-menu-button')\nexport class UiHeaderMenuButton extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: flex;\n            block-size: 100%;\n        }\n\n        @media (min-width: 1056px) {\n            :host(:not([collapsible])) {\n                display: none;\n            }\n        }\n\n        button {\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            box-sizing: border-box;\n            inline-size: 48px;\n            block-size: 48px;\n            padding: 0;\n            border: 1px solid transparent;\n            background: transparent;\n            color: var(--ui-icon-primary);\n            cursor: pointer;\n            outline: none;\n            transition:\n                background-color var(--ui-duration-moderate),\n                border-color var(--ui-duration-moderate);\n        }\n\n        button:hover {\n            background-color: var(--ui-canvas-hover);\n        }\n\n        button:active {\n            background-color: var(--ui-canvas-active);\n        }\n\n        button:focus-visible {\n            border-color: var(--ui-focus);\n        }\n\n        :host([active]) button {\n            background-color: var(--ui-surface-1);\n            border-block-end-color: transparent;\n            border-inline-color: var(--ui-border-subtle-1);\n        }\n\n        svg {\n            width: 20px;\n            height: 20px;\n            fill: currentColor;\n        }\n    `;\n\n    @property({ type: Boolean, reflect: true }) active = false;\n\n    /** Keep the button at every width (a collapsible, non-fixed side nav). */\n    @property({ type: Boolean, reflect: true }) collapsible = false;\n\n    @property({ attribute: 'open-label' }) openLabel = '';\n\n    @property({ attribute: 'close-label' }) closeLabel = '';\n\n    private readonly localize = new LocalizeController(this);\n\n    private toggle() {\n        this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { active: !this.active }, bubbles: true, composed: true, cancelable: true }));\n    }\n\n    override render() {\n        const label = this.active ? this.closeLabel || this.localize.t.common.closeMenu : this.openLabel || this.localize.t.common.openMenu;\n        return html`<button part=\"base\" type=\"button\" aria-label=${label} aria-expanded=${this.active ? 'true' : 'false'} @click=${this.toggle}>${this.active ? closeIcon : menuIcon}</button>`;\n    }\n}\n\nexport interface UiHeaderMenuButtonEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<HeaderMenuButtonToggleDetail>;\n}\n\n/** Typed listeners for UiHeaderMenuButton's events (declaration merging with the class). */\nexport interface UiHeaderMenuButton {\n    addEventListener<K extends keyof UiHeaderMenuButtonEventMap>(type: K, listener: (this: UiHeaderMenuButton, event: UiHeaderMenuButtonEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiHeaderMenuButtonEventMap>(type: K, listener: (this: UiHeaderMenuButton, event: UiHeaderMenuButtonEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-menu-button': UiHeaderMenuButton;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-menu-item.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-menu-item.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, nothing } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * Carbon `HeaderMenuItem`: one link of the header menu bar (or of a `<ui-header-menu>`\n * dropdown). `current` marks the page (`aria-current=\"page\"`, 3px bar).\n *\n * @slot - Link text\n * @csspart base - The link\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n */\n@customElement('ui-header-menu-item')\nexport class UiHeaderMenuItem extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n            block-size: 100%;\n        }\n\n        a {\n            position: relative;\n            display: flex;\n            align-items: center;\n            box-sizing: border-box;\n            block-size: 100%;\n            padding: 0 16px;\n            border: 2px solid transparent;\n            background-color: var(--ui-canvas);\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-body-sm);\n            line-height: 18px;\n            letter-spacing: 0;\n            text-decoration: none;\n            white-space: nowrap;\n            user-select: none;\n            outline: none;\n            transition:\n                background-color var(--ui-duration-moderate),\n                border-color var(--ui-duration-moderate),\n                color var(--ui-duration-moderate);\n        }\n\n        a:hover {\n            background-color: var(--ui-canvas-hover);\n            color: var(--ui-ink);\n        }\n\n        a:active {\n            background-color: var(--ui-canvas-active);\n            color: var(--ui-ink);\n        }\n\n        a:focus-visible {\n            border-color: var(--ui-focus);\n        }\n\n        :host([current]) a {\n            color: var(--ui-ink);\n        }\n\n        :host([current]) a::after {\n            content: '';\n            position: absolute;\n            inset-block-end: -2px;\n            inset-inline-start: -2px;\n            inline-size: calc(100% + 4px);\n            block-size: 3px;\n            background-color: var(--ui-nav-current-mark, var(--ui-primary)); /* border-interactive; the side nav's setting */\n        }\n\n        /* inside a dropdown / the side nav: 48px rows on the layer, bar on the start edge */\n        :host([data-in-menu]) {\n            block-size: 48px;\n        }\n\n        :host([data-in-menu]) a {\n            background-color: var(--ui-surface-1);\n        }\n\n        :host([data-in-menu]) a:hover {\n            background-color: var(--ui-layer-hover-1);\n        }\n\n        :host([data-in-menu][current]) a {\n            background-color: var(--ui-layer-selected-1);\n        }\n\n        :host([data-in-menu][current]) a::after,\n        :host([data-in-side-nav][current]) a::after {\n            inset-block-start: -2px;\n            inset-inline-start: -2px;\n            inline-size: 3px;\n            block-size: calc(100% + 4px);\n        }\n\n        .text {\n            overflow: hidden;\n            text-overflow: ellipsis;\n        }\n\n        @media (forced-colors: active) {\n            :host([current]) a::after {\n                background-color: Highlight;\n            }\n        }\n    `;\n\n    @property() href = '#';\n\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('current')) (this.parentElement?.closest('ui-header-menu') as LitElement | null)?.requestUpdate();\n    }\n\n    override render() {\n        return html`<a part=\"base\" href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} aria-current=${ifDefined(this.current ? 'page' : undefined)} @click=${followLink}><span class=\"text\"><slot></slot></span></a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-menu-item': UiHeaderMenuItem;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-menu.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-menu.ts",
      "content": "import { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html } from 'lit';\nimport type { UiHeaderMenuItem } from './header-menu-item.ts';\nimport { uid } from '../shared/field.ts';\nimport { chevron, headerTriggerStyles } from './shell-shared.ts';\nimport type { OpenDetail } from '../shared/events.ts';\nimport { outsidePress } from '../../core/popup.ts';\n\n/**\n * Carbon `HeaderMenu`: a menu-bar entry that opens a 200px dropdown of `<ui-header-menu-item>`s.\n * Click / Enter / Space toggle; Escape and clicking outside close and return focus. Following one of\n * its links closes it too (Carbon toggles on any click in the menu), so a client-side route change\n * doesn't leave it open; focus goes back to the title rather than staying on a hidden link.\n * A disclosure (APG disclosure navigation): the links stay links, so the button has no `aria-haspopup`.\n * While closed it shows the current-page bar when one of its items is `current` (Carbon\n * `hasActiveDescendant`); `current` shows it always (Carbon `isActive`).\n *\n * @slot - `<ui-header-menu-item>` elements\n * @fires ui-toggle - detail: { open }\n * @csspart trigger - The title button\n * @csspart menu - The dropdown list\n */\n@customElement('ui-header-menu')\nexport class UiHeaderMenu extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = [headerTriggerStyles, css`\n        :host {\n            position: relative;\n            display: block;\n            block-size: 100%;\n        }\n\n        .menu {\n            display: none;\n            margin: 0;\n            padding: 0;\n            list-style: none;\n        }\n\n        .trigger[aria-expanded='true'] + .menu {\n            position: absolute;\n            z-index: 8001;\n            inset-block-end: 0;\n            inset-inline-start: 0;\n            display: flex;\n            flex-direction: column;\n            inline-size: 200px;\n            background-color: var(--ui-overlay-background, var(--ui-surface-1));\n            box-shadow: 0 4px 8px 0 rgb(0 0 0 / 0.5);\n            transform: translateY(100%);\n        }\n\n        :host([data-in-side-nav]) .trigger[aria-expanded='true'] + .menu {\n            position: static;\n            inline-size: 100%;\n            box-shadow: none;\n            transform: none;\n        }\n    `];\n\n    @property() label = '';\n\n    @property({ type: Boolean, reflect: true }) open = false;\n\n    /** Mark the menu as the current section even while open (Carbon `isActive`). */\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    @query('.trigger') private readonly trigger!: HTMLButtonElement;\n\n    @queryAssignedElements({ selector: 'ui-header-menu-item' }) private readonly items!: UiHeaderMenuItem[];\n\n    private readonly menuId = uid('ui-header-menu');\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.stopListening();\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        for (const item of this.items) item.toggleAttribute('data-in-menu', true);\n        if (!changed.has('open')) return;\n        if (this.open) {\n            // a finger scroll doesn't close it: only a tap outside does\n            this.stopOutside ??= outsidePress(document, this.onDocumentPointerDown);\n            document.addEventListener('keydown', this.onKeydown, true);\n        } else this.stopListening();\n        if (changed.get('open') !== undefined) {\n            this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { open: this.open }, bubbles: true, composed: true }));\n        }\n    }\n\n    private stopListening() {\n        this.stopOutside?.();\n        this.stopOutside = undefined;\n        document.removeEventListener('keydown', this.onKeydown, true);\n    }\n\n    private stopOutside?: () => void;\n\n    private readonly onDocumentPointerDown = (event: PointerEvent) => {\n        if (!event.composedPath().includes(this)) this.open = false;\n    };\n\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (event.key !== 'Escape') return;\n        event.stopPropagation();\n        this.open = false;\n        this.trigger.focus();\n    };\n\n    private onFocusOut(event: FocusEvent) {\n        const next = event.relatedTarget as Node | null;\n        if (next && !this.contains(next) && !this.shadowRoot?.contains(next)) this.open = false;\n    }\n\n    private onItemClick(event: MouseEvent) {\n        if (!this.open || !(event.target as Element).closest('ui-header-menu-item')) return;\n        this.open = false;\n        this.trigger.focus();\n    }\n\n    override render() {\n        const current = this.current || (!this.open && this.items.some((i) => i.current));\n        return html`\n            <button class=\"trigger ${current ? 'current' : ''}\" part=\"trigger\" type=\"button\" tabindex=\"0\" aria-expanded=${this.open ? 'true' : 'false'} aria-controls=${this.menuId} @click=${() => (this.open = !this.open)} @focusout=${this.onFocusOut}>\n                ${this.label}${chevron}\n            </button>\n            <div class=\"menu\" part=\"menu\" id=${this.menuId} role=\"list\" aria-label=${this.label} @focusout=${this.onFocusOut} @click=${this.onItemClick}><slot @slotchange=${() => this.requestUpdate()}></slot></div>\n        `;\n    }\n}\n\nexport interface UiHeaderMenuEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<OpenDetail>;\n}\n\n/** Typed listeners for UiHeaderMenu's events (declaration merging with the class). */\nexport interface UiHeaderMenu {\n    addEventListener<K extends keyof UiHeaderMenuEventMap>(type: K, listener: (this: UiHeaderMenu, event: UiHeaderMenuEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiHeaderMenuEventMap>(type: K, listener: (this: UiHeaderMenu, event: UiHeaderMenuEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-menu': UiHeaderMenu;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-name.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-name.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, nothing } from 'lit';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * Carbon `HeaderName`: the product link at the start of the header (`prefix` in regular weight,\n * then the name in 600). Carbon's default prefix is \"IBM\"; here it is empty.\n *\n * @slot - Product name\n * @csspart base - The link\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n */\n@customElement('ui-header-name')\nexport class UiHeaderName extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n            block-size: 100%;\n        }\n\n        a {\n            display: flex;\n            align-items: center;\n            box-sizing: border-box;\n            block-size: 100%;\n            padding: 0 32px 0 16px;\n            border: 2px solid transparent;\n            color: var(--ui-ink);\n            font: var(--ui-font-body-sm);\n            font-weight: 600;\n            line-height: 20px;\n            letter-spacing: 0.1px;\n            text-decoration: none;\n            outline: none;\n            user-select: none;\n            transition: border-color var(--ui-duration-moderate);\n        }\n\n        a:focus-visible {\n            border-color: var(--ui-focus);\n        }\n\n        .prefix {\n            font-weight: 400;\n        }\n\n        :host(:dir(ltr)) ::slotted(*),\n        ::slotted(*) {\n            display: contents;\n        }\n    `;\n\n    @property() href = '/';\n\n    @property() prefix = '';\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n\n    override render() {\n        const prefix = this.prefix ? html`<span class=\"prefix\">${this.prefix}</span>&nbsp;` : nothing;\n        return html`<a part=\"base\" href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} @click=${followLink}>${prefix}<span><slot></slot></span></a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-name': UiHeaderName;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-nav.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-nav.ts",
      "content": "import { customElement, property, query, state } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html, isServer } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { hasData } from '../shared/field.ts';\nimport { lockScroll, unlockScroll } from '../../core/overlay.ts';\n\nconst menuIcon = html`<svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><path d=\"M2 14.8h16v1.2H2zm0-5.4h16v1.2H2zM2 4h16v1.2H2z\" /></svg>`;\nconst closeIcon = html`<svg viewBox=\"0 0 20 20\" aria-hidden=\"true\"><path d=\"M15 5.8 14.2 5 10 9.2 5.8 5 5 5.8 9.2 10 5 14.2l.8.8 4.2-4.2 4.2 4.2.8-.8L10.8 10z\" /></svg>`;\n\n/** Below Carbon's `lg` breakpoint the bar doesn't fit the header. */\nconst NARROW = '(max-width: 1055.98px)';\n\n/** The menus of the bar, which take the vertical (side-nav) look in the narrow sheet. */\nconst BAR_ITEMS = 'ui-header-menu-item, ui-header-menu, ui-header-mega-menu';\n\n/**\n * Carbon `HeaderNavigation`: the main menu bar (`<nav>` + list), shown from the `lg` breakpoint.\n * Children: `<ui-header-menu-item>`, `<ui-header-menu>` and `<ui-header-mega-menu>`.\n *\n * Below `lg` Carbon hides it (its copy goes in the side nav). With `collapse` it stays instead, as a menu button that\n * opens the bar as a full-screen sheet under the header (a mega menu becomes an accordion row) — for a header with no\n * side nav, such as an app inside another product's shell. While the sheet is open the page behind is inert and\n * doesn't scroll (focus stays in the header and the sheet), Escape closes it and returns focus to the button, and\n * following a link closes it.\n *\n * @slot - Menu items\n * @csspart base - The `<nav>`\n * @csspart list - The menu bar list\n * @csspart menu-button - With `collapse`, below `lg`: the button that opens the sheet\n * @csspart sheet - With `collapse`, below `lg`: the sheet under the header\n */\n@customElement('ui-header-nav')\nexport class UiHeaderNav extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: none;\n            position: relative;\n            block-size: 100%;\n        }\n\n        @media (min-width: 1056px) {\n            :host {\n                display: block;\n            }\n        }\n\n        :host([data-in-side-nav]),\n        :host([data-collapsed]) {\n            display: block;\n        }\n\n        /* Carbon side-nav__header-navigation: the copy in the side nav is for small screens only; at lg the header shows the original */\n        @media (min-width: 1056px) {\n            :host([data-in-side-nav]) {\n                display: none;\n            }\n        }\n\n        :host::before {\n            content: '';\n            position: absolute;\n            inset-block-start: 50%;\n            inset-inline-start: 0;\n            display: block;\n            inline-size: 1px;\n            block-size: 24px;\n            background-color: var(--ui-border-subtle-1);\n            transform: translateY(-50%);\n        }\n\n        :host([data-in-side-nav])::before,\n        :host([data-collapsed])::before {\n            display: none;\n        }\n\n        /*\n         * Carbon header__nav and header__menu-bar: full height, so the items and their current-page bar reach the\n         * header's bottom edge; 16px after the divider — on this part, not :host, so a page-wide CSS reset can't remove it.\n         */\n        [part='base'] {\n            block-size: 100%;\n            padding-inline-start: 16px;\n        }\n\n        :host([data-in-side-nav]) [part='base'],\n        :host([data-collapsed]) [part='base'] {\n            padding-inline-start: 0;\n        }\n\n        .bar {\n            display: flex;\n            block-size: 100%;\n            margin: 0;\n            padding: 0;\n            list-style: none;\n        }\n\n        :host([data-in-side-nav]) .bar,\n        :host([data-collapsed]) .bar {\n            flex-direction: column;\n        }\n\n        /* in the sheet (as tall as the window) the rows keep their own height */\n        :host([data-collapsed]) .bar {\n            block-size: auto;\n        }\n\n        /* the menu button: as <ui-header-menu-button> */\n        .menu-button {\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            box-sizing: border-box;\n            inline-size: 48px;\n            block-size: 48px;\n            padding: 0;\n            border: 1px solid transparent;\n            background: transparent;\n            color: var(--ui-icon-primary);\n            cursor: pointer;\n            outline: none;\n            transition:\n                background-color var(--ui-duration-moderate),\n                border-color var(--ui-duration-moderate);\n        }\n\n        .menu-button:hover {\n            background-color: var(--ui-canvas-hover);\n        }\n\n        .menu-button:active {\n            background-color: var(--ui-canvas-active);\n        }\n\n        .menu-button:focus-visible {\n            border-color: var(--ui-focus);\n        }\n\n        .menu-button[aria-expanded='true'] {\n            background-color: var(--ui-surface-1);\n            border-block-end-color: transparent;\n            border-inline-color: var(--ui-border-subtle-1);\n        }\n\n        .menu-button svg {\n            width: 20px;\n            height: 20px;\n            fill: currentColor;\n        }\n\n        /* a manual popover: the top layer, above a host app's own fixed bars whatever their z-index */\n        .sheet {\n            position: fixed;\n            inset: auto;\n            inset-block-end: 0;\n            box-sizing: border-box;\n            block-size: auto; /* not the popover's fit-content: from under the header to the bottom */\n            margin: 0;\n            padding: 8px 0;\n            border: 0;\n            color: var(--ui-ink);\n            overflow-y: auto;\n            overscroll-behavior: contain;\n            border-block-start: 1px solid var(--ui-border-subtle-1);\n            background-color: var(--ui-mega-panel-background, var(--ui-overlay-background, var(--ui-surface-1)));\n        }\n\n    `;\n\n    @property() label = '';\n\n    /** Below `lg`, a menu button and a full-screen sheet instead of hiding (a header with no side nav). */\n    @property({ type: Boolean, reflect: true }) collapse = false;\n\n    @state() private narrow = false;\n\n    @state() private sheetOpen = false;\n\n    @state() private sheetBox: { top: number; left: number; width: number } | null = null;\n\n    @query('.menu-button') private readonly menuButton!: HTMLButtonElement | null;\n\n    private readonly localize = new LocalizeController(this);\n\n    private media?: MediaQueryList;\n\n    /** The page's elements this nav made inert while its sheet is open. */\n    private inerted: HTMLElement[] = [];\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (isServer) return;\n        this.media = globalThis.matchMedia?.(NARROW);\n        this.narrow = this.media?.matches ?? false;\n        this.media?.addEventListener('change', this.onMediaChange);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.media?.removeEventListener('change', this.onMediaChange);\n        this.closeSheet(false);\n    }\n\n    private readonly onMediaChange = (event: MediaQueryListEvent) => {\n        this.narrow = event.matches;\n    };\n\n    private get collapsed() {\n        return this.collapse && this.narrow && !hasData(this, 'inSideNav');\n    }\n\n    protected override willUpdate(changed: Map<string, unknown>) {\n        if ((changed.has('narrow') || changed.has('collapse')) && !this.collapsed && this.sheetOpen) this.closeSheet(false);\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('narrow') || changed.has('collapse')) this.markItems();\n        if (changed.has('sheetOpen')) this.syncSheet();\n    }\n\n    /** In the sheet the bar's menus take the vertical look (the side nav's copy of the bar); outside it they go back. */\n    private markItems() {\n        const collapsed = this.collapsed;\n        const flipped = collapsed !== hasData(this, 'collapsed');\n        this.toggleAttribute('data-collapsed', collapsed);\n        for (const item of this.querySelectorAll<HTMLElement & { open?: boolean }>(`:scope > :is(${BAR_ITEMS})`)) {\n            // an open dropdown or panel doesn't carry over between the bar and the sheet; each redraws for its new place\n            if (flipped && item.open) item.open = false;\n            if (flipped) (item as HTMLElement & { requestUpdate?: () => void }).requestUpdate?.();\n            if (collapsed) {\n                item.toggleAttribute('data-in-side-nav', true);\n                item.toggleAttribute('data-in-collapsed-nav', true);\n            } else if (hasData(item, 'inCollapsedNav')) {\n                delete item.dataset.inSideNav;\n                delete item.dataset.inCollapsedNav;\n            }\n        }\n    }\n\n    private syncSheet() {\n        const root = document.documentElement;\n        const sheet = this.shadowRoot?.querySelector<HTMLElement>('.sheet');\n        if (sheet?.matches(':popover-open') !== this.sheetOpen) sheet?.togglePopover(this.sheetOpen);\n        if (this.sheetOpen) {\n            lockScroll(this, root);\n            this.setPageInert(true);\n            document.addEventListener('keydown', this.onKeydown, true);\n            window.addEventListener('resize', this.placeSheet);\n        } else {\n            unlockScroll(this, root);\n            this.setPageInert(false);\n            document.removeEventListener('keydown', this.onKeydown, true);\n            window.removeEventListener('resize', this.placeSheet);\n        }\n    }\n\n    /** The page outside the header is inert while the sheet is open: Tab stays in the header and the sheet. */\n    private setPageInert(on: boolean) {\n        for (const el of this.inerted) el.inert = false;\n        this.inerted = [];\n        if (!on) return;\n        let node: HTMLElement = this.closest<HTMLElement>('ui-header') ?? this;\n        while (node.parentElement && node !== document.body) {\n            for (const sibling of node.parentElement.children) {\n                if (sibling !== node && sibling instanceof HTMLElement && !sibling.inert) {\n                    sibling.inert = true;\n                    this.inerted.push(sibling);\n                }\n            }\n            node = node.parentElement;\n        }\n    }\n\n    /** Under the header, as wide as it, to the bottom of the window. */\n    private readonly placeSheet = () => {\n        const header = this.closest('ui-header')?.shadowRoot?.querySelector('header') ?? null;\n        const rect = (header ?? this).getBoundingClientRect();\n        this.sheetBox = { top: rect.bottom, left: header ? rect.left : 0, width: header ? rect.width : document.documentElement.clientWidth };\n    };\n\n    private openSheet() {\n        this.placeSheet();\n        this.sheetOpen = true;\n    }\n\n    private closeSheet(refocus: boolean) {\n        if (!this.sheetOpen) return;\n        this.sheetOpen = false;\n        if (refocus) this.menuButton?.focus();\n    }\n\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (event.key !== 'Escape') return;\n        event.stopPropagation();\n        this.closeSheet(true);\n    };\n\n    private onSheetClick(event: MouseEvent) {\n        if ((event.target as Element).closest('ui-header-menu-item, ui-header-mega-item')) this.closeSheet(true);\n    }\n\n    private renderCollapsed(list: unknown) {\n        const label = this.sheetOpen ? this.localize.t.common.closeMenu : this.localize.t.common.openMenu;\n        const box = this.sheetBox ? { top: `${this.sheetBox.top}px`, left: `${this.sheetBox.left}px`, width: `${this.sheetBox.width}px` } : {};\n        return html`<nav part=\"base\" aria-label=${this.label || this.localize.t.common.mainNavigation}>\n            <button class=\"menu-button\" part=\"menu-button\" type=\"button\" aria-label=${label} aria-expanded=${this.sheetOpen ? 'true' : 'false'} aria-controls=\"sheet\" @click=${() => (this.sheetOpen ? this.closeSheet(false) : this.openSheet())}>\n                ${this.sheetOpen ? closeIcon : menuIcon}\n            </button>\n            <div class=\"sheet\" part=\"sheet\" id=\"sheet\" popover=\"manual\" style=${styleMap(box)} @click=${this.onSheetClick}>${list}</div>\n        </nav>`;\n    }\n\n    override render() {\n        const list = html`<div class=\"bar\" part=\"list\" role=\"list\"><slot @slotchange=${() => this.markItems()}></slot></div>`;\n        if (this.collapsed) return this.renderCollapsed(list);\n        // inside the side nav it is part of that landmark, not a second \"Main navigation\"\n        if (hasData(this, 'inSideNav')) return html`<div part=\"base\">${list}</div>`;\n        return html`<nav part=\"base\" aria-label=${this.label || this.localize.t.common.mainNavigation}>${list}</nav>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-nav': UiHeaderNav;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header-panel.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header-panel.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport { UiHeaderGlobalAction } from './header-global-action.ts';\nimport { deepActiveElement } from '../shared/field.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport type { ExpandedDetail } from '../shared/events.ts';\nimport { outsidePress } from '../../core/popup.ts';\n\n/**\n * Carbon `HeaderPanel`: a 256px panel that slides in under the header on the end side (app\n * switcher, notifications). Escape, focus leaving and a click outside it (not on the action that\n * opens it) close it (`ui-toggle`; Carbon `HeaderPanel`); set `expanded`.\n *\n * @slot - Panel content (e.g. `<ui-switcher>`)\n * @fires ui-toggle - detail: { expanded }\n * @csspart base - The panel\n */\n@customElement('ui-header-panel')\nexport class UiHeaderPanel extends UiElement {\n    static override readonly styles = css`\n        :host {\n            position: fixed;\n            inset-block: 48px 0;\n            inset-inline-end: 0;\n            z-index: 8000;\n            box-sizing: border-box;\n            inline-size: 0;\n            overflow: hidden;\n            background-color: var(--ui-surface-1);\n            color: var(--ui-ink-muted);\n            font-family: var(--ui-font-family);\n            transition: inline-size var(--ui-duration-moderate) cubic-bezier(0.2, 0, 1, 0.9);\n        }\n\n        :host([expanded]) {\n            inline-size: 256px;\n            overflow-y: auto;\n            overscroll-behavior: contain;\n        }\n\n        /* the side borders, on the content part rather than :host so a page-wide CSS reset can't remove them */\n        [part='base'] {\n            box-sizing: border-box;\n            min-block-size: 100%;\n            border-inline: 1px solid var(--ui-border-subtle-1);\n        }\n    `;\n\n    @property({ type: Boolean, reflect: true }) expanded = false;\n\n    @property() label = '';\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.addEventListener('keydown', this.onKeydown);\n        this.addEventListener('focusout', this.onFocusOut);\n        // a finger scroll doesn't close it: only a tap outside does\n        this.stopOutside = outsidePress(document, this.onDocumentPointerDown);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('keydown', this.onKeydown);\n        this.removeEventListener('focusout', this.onFocusOut);\n        this.stopOutside?.();\n        this.stopOutside = undefined;\n    }\n\n    /** A click outside closes it — not one on its own global action, which toggles it (Carbon HeaderPanel's window click). */\n    private stopOutside?: () => void;\n\n    private readonly onDocumentPointerDown = (event: PointerEvent) => {\n        if (!this.expanded) return;\n        const path = event.composedPath();\n        if (path.includes(this)) return;\n        if (path.some((node) => node instanceof UiHeaderGlobalAction && node.panel !== '' && node.panel === this.id)) return;\n        this.expanded = false;\n    };\n\n    /** What had focus when the panel opened (normally its global action), for Escape to return to. */\n    private returnFocus: HTMLElement | null = null;\n\n    protected override willUpdate(changed: Map<string, unknown>) {\n        if (changed.has('expanded') && this.expanded) this.returnFocus = deepActiveElement();\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('expanded') && changed.get('expanded') !== undefined) {\n            this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { expanded: this.expanded }, bubbles: true, composed: true }));\n        }\n    }\n\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (event.key !== 'Escape' || !this.expanded) return;\n        this.expanded = false;\n        this.returnFocus?.focus(); // WCAG 2.4.3: don't drop focus to <body> when the panel hides\n        this.returnFocus = null;\n    };\n\n    private readonly onFocusOut = (event: FocusEvent) => {\n        const next = event.relatedTarget as Node | null;\n        if (next && !this.contains(next)) this.expanded = false;\n    };\n\n    override render() {\n        return html`<div part=\"base\" role=${ifDefined(this.label ? 'region' : undefined)} aria-label=${ifDefined(this.label || undefined)} ?hidden=${!this.expanded}><slot></slot></div>`;\n    }\n}\n\nexport interface UiHeaderPanelEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<ExpandedDetail>;\n}\n\n/** Typed listeners for UiHeaderPanel's events (declaration merging with the class). */\nexport interface UiHeaderPanel {\n    addEventListener<K extends keyof UiHeaderPanelEventMap>(type: K, listener: (this: UiHeaderPanel, event: UiHeaderPanelEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiHeaderPanelEventMap>(type: K, listener: (this: UiHeaderPanel, event: UiHeaderPanelEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header-panel': UiHeaderPanel;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/header.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/header.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\n/**\n * Carbon `Header`: the fixed 48px top bar (`role=banner`). Slot in order: `<ui-skip-to-content>`,\n * `<ui-header-menu-button>`, `<ui-header-name>`, `<ui-header-nav>`, `<ui-header-global-bar>`.\n *\n * @slot - Header content\n * @csspart base - The `<header>`\n */\n@customElement('ui-header')\nexport class UiHeader extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n            font-family: var(--ui-font-family);\n        }\n\n        header {\n            position: fixed;\n            inset-block-start: 0;\n            inset-inline: 0;\n            z-index: 8000;\n            display: flex;\n            align-items: center;\n            box-sizing: border-box;\n            block-size: 48px;\n            border-block-end: 1px solid var(--ui-border-subtle-1);\n            background-color: var(--ui-canvas);\n        }\n\n        @media (forced-colors: active) {\n            header {\n                border-block-end-color: CanvasText;\n            }\n        }\n    `;\n\n    /** Accessible name of the banner, e.g. the product name. */\n    @property() label = '';\n\n    override render() {\n        return html`<header part=\"base\" aria-label=${ifDefined(this.label || undefined)}><slot></slot></header>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-header': UiHeader;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/shell-shared.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/shell-shared.ts",
      "content": "/** Parts more than one shell element uses. */\nimport { html, css } from 'lit';\n\nexport const chevron = html`<svg class=\"chevron\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M8 11 3 6l.7-.7L8 9.6l4.3-4.3.7.7z\" /></svg>`;\n\n/** The top item of a header menu (`<ui-header-menu>`, `<ui-header-mega-menu>`): Carbon header__menu-title, its chevron and current-page bar. */\nexport const headerTriggerStyles = css`\n    .trigger {\n        position: relative;\n        display: flex;\n        align-items: center;\n        box-sizing: border-box;\n        block-size: 100%;\n        padding: 0 16px;\n        border: 2px solid transparent;\n        background-color: var(--ui-canvas);\n        color: var(--ui-ink-muted);\n        font: var(--ui-font-body-sm);\n        line-height: 18px;\n        white-space: nowrap;\n        cursor: pointer;\n        outline: none;\n        user-select: none;\n    }\n\n    .trigger:hover {\n        background-color: var(--ui-canvas-hover);\n        color: var(--ui-ink);\n    }\n\n    .trigger:focus-visible {\n        border-color: var(--ui-focus);\n    }\n\n    .trigger[aria-expanded='true'] {\n        z-index: 8002;\n        background-color: var(--ui-surface-1);\n    }\n\n    /* Carbon header__menu-item--current on the title: the 3px border-interactive bar (the text stays secondary, as Carbon's a.header__menu-item colour wins) */\n    .trigger.current::after {\n        content: '';\n        position: absolute;\n        inset-block-end: -2px;\n        inset-inline-start: -2px;\n        inline-size: calc(100% + 4px);\n        block-size: 3px;\n        background-color: var(--ui-nav-current-mark, var(--ui-primary)); /* border-interactive; the side nav's setting */\n    }\n\n    /* side nav copy (Carbon side-nav__header-navigation): the bar on the start edge */\n    :host([data-in-side-nav]) .trigger.current::after {\n        inline-size: 3px;\n        block-size: calc(100% + 4px);\n    }\n\n    @media (forced-colors: active) {\n        .trigger.current::after {\n            background-color: Highlight;\n        }\n    }\n\n    .chevron {\n        width: 16px;\n        height: 16px;\n        margin-inline-start: 8px;\n        fill: var(--ui-icon-secondary);\n        transition:\n            transform var(--ui-duration-moderate),\n            fill var(--ui-duration-moderate);\n    }\n\n    .trigger[aria-expanded='true'] .chevron {\n        transform: rotate(180deg);\n    }\n`;\n\nexport const sideNavLinkStyles = css`\n    :host {\n        display: block;\n        inline-size: 100%;\n        overflow: hidden;\n    }\n\n    /* --ui-nav-item-*: Carbon rows run edge to edge, square; a design can inset and round them */\n    a {\n        position: relative;\n        display: flex;\n        align-items: center;\n        box-sizing: border-box;\n        min-block-size: 32px;\n        margin-inline: var(--ui-nav-item-inset, 0);\n        padding: 0 16px;\n        border-radius: var(--ui-nav-item-radius, 0);\n        color: var(--ui-ink-muted);\n        text-decoration: none;\n        outline: none;\n        transition:\n            color var(--ui-duration-moderate),\n            background-color var(--ui-duration-moderate),\n            outline var(--ui-duration-moderate);\n    }\n\n    :host([large]) a {\n        block-size: 48px;\n    }\n\n    a:hover {\n        background-color: var(--ui-canvas-hover);\n    }\n\n    a:hover .text {\n        color: var(--ui-ink);\n    }\n\n    a:focus-visible {\n        outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n        outline-offset: -2px;\n    }\n\n    /* the current page: a fill and a bar on the start edge (--ui-nav-current-*; Kanok: the tint alone, no bar) */\n    :host([current]) a {\n        background-color: var(--ui-nav-current-background, var(--ui-canvas-selected));\n    }\n\n    :host([current]) a::before {\n        content: '';\n        position: absolute;\n        inset-block: var(--ui-nav-current-mark-inset, 0);\n        inset-inline-start: 0;\n        inline-size: var(--ui-nav-current-mark-width, 3px);\n        border-radius: var(--ui-nav-current-mark-radius, 0);\n        background-color: var(--ui-nav-current-mark, var(--ui-primary)); /* border-interactive */\n    }\n\n    :host([current]) .text {\n        color: var(--ui-ink);\n        font-weight: 600;\n    }\n\n    .icon {\n        display: none;\n        flex: 0 0 16px;\n        align-items: center;\n        justify-content: center;\n        margin-inline-end: 24px;\n    }\n\n    :host([data-icon]) .icon {\n        display: flex;\n    }\n\n    ::slotted([slot='icon']) {\n        width: 16px;\n        height: 16px;\n        fill: var(--ui-icon-secondary);\n    }\n\n    :host([current]) ::slotted([slot='icon']) {\n        fill: var(--ui-icon-primary);\n    }\n\n    .text {\n        overflow: hidden;\n        color: var(--ui-ink-muted);\n        font: var(--ui-font-body-sm);\n        line-height: 20px;\n        letter-spacing: 0.1px;\n        text-overflow: ellipsis;\n        white-space: nowrap;\n        user-select: none;\n    }\n\n    @media (forced-colors: active) {\n        :host([current]) a::before {\n            inline-size: 3px; /* shown here even where a design hides it: the tint is gone in forced colours */\n            background-color: Highlight;\n        }\n    }\n`;\n\n/** `ui-toggle` of the hamburger: the state the user asked for (the side nav follows it unless cancelled). */\nexport interface HeaderMenuButtonToggleDetail {\n    active: boolean;\n}\n"
    },
    {
      "path": "src/primitives/shell/shell.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/shell.ts",
      "content": "/*\n * Carbon UI Shell: header (48px, fixed), side navigation (256px / 48px rail), header panel\n * (256px, right) and the content area. Geometry follows @carbon/styles `components/ui-shell`\n * (mini-unit = 8px, `lg` breakpoint = 1056px, z-index header 8000).\n *\n * One element per file in this folder; this module is the entry point (package export, React wrappers, index).\n */\nimport '../tooltip/tooltip.ts';\nexport * from './skip-to-content.ts';\nexport * from './header.ts';\nexport * from './header-name.ts';\nexport * from './header-menu-button.ts';\nexport * from './header-nav.ts';\nexport * from './header-menu-item.ts';\nexport * from './header-menu.ts';\nexport * from './header-mega-menu.ts';\nexport * from './header-mega-group.ts';\nexport * from './header-mega-item.ts';\nexport * from './header-global-bar.ts';\nexport * from './header-global-action.ts';\nexport * from './header-panel.ts';\nexport * from './switcher.ts';\nexport * from './switcher-item.ts';\nexport * from './side-nav.ts';\nexport * from './side-nav-items.ts';\nexport * from './side-nav-divider.ts';\nexport * from './side-nav-link.ts';\nexport * from './side-nav-menu.ts';\nexport * from './side-nav-menu-item.ts';\nexport * from './content.ts';\nexport type { HeaderMenuButtonToggleDetail } from './shell-shared.ts';\n"
    },
    {
      "path": "src/primitives/shell/side-nav-divider.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav-divider.ts",
      "content": "import { customElement } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\n\n/** Carbon `SideNavDivider`: a list item holding a 1px rule with 8px / 16px margins (Carbon renders `<li><hr></li>`). */\n@customElement('ui-side-nav-divider')\nexport class UiSideNavDivider extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n        }\n\n        hr {\n            block-size: 1px;\n            margin: 8px 16px;\n            border: none;\n            background-color: var(--ui-border-subtle-1);\n        }\n    `;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    override render() {\n        return html`<hr />`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav-divider': UiSideNavDivider;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/side-nav-items.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav-items.ts",
      "content": "import { customElement } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\n\n/**\n * Carbon `SideNavItems`: the scrolling list inside `<ui-side-nav>`.\n *\n * @slot - `<ui-side-nav-link>`, `<ui-side-nav-menu>`, `<ui-side-nav-divider>`\n */\n@customElement('ui-side-nav-items')\nexport class UiSideNavItems extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n            flex: 1 1 0%;\n            overflow: hidden auto;\n        }\n\n        /* 16px above the first item, on the list rather than :host so a page-wide CSS reset can't remove it */\n        .list {\n            margin: 0;\n            padding: 16px 0 0;\n            list-style: none;\n        }\n    `;\n\n    override render() {\n        return html`<div class=\"list\" role=\"list\"><slot></slot></div>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav-items': UiSideNavItems;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/side-nav-link.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav-link.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, html, nothing } from 'lit';\nimport { sideNavLinkStyles } from './shell-shared.ts';\nimport { SlotController } from '../shared/slots.ts';\nimport { hasData } from '../shared/field.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * Carbon `SideNavLink`: a navigation link with an optional 16px icon. `current` marks the page.\n * In a collapsed (non-rail) side nav the link leaves the tab order, like Carbon.\n *\n * @slot - Link text\n * @slot icon - 16px icon\n * @csspart base - The link\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n * @cssprop --ui-nav-item-inset - Space each side of a row (default 0; Kanok: 8px)\n * @cssprop --ui-nav-item-radius - Corner radius of a row (default 0; Kanok: 6px)\n * @cssprop --ui-nav-current-background - Fill of the current page's row (default `--ui-canvas-selected`)\n * @cssprop --ui-nav-current-mark - Colour of its start-edge bar (default `--ui-primary`; Kanok: `--ui-border-interactive`)\n * @cssprop --ui-nav-current-mark-width / --ui-nav-current-mark-inset / --ui-nav-current-mark-radius - The bar's width (3px; Kanok: 0, the tinted row alone — forced colours still show it), top and bottom inset (0) and corners (0)\n */\n@customElement('ui-side-nav-link')\nexport class UiSideNavLink extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = sideNavLinkStyles;\n\n    @property() href = '#';\n\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n    /** 48px row. */\n    @property({ type: Boolean, reflect: true }) large = false;\n\n    private readonly slots = new SlotController(this);\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated() {\n        this.toggleAttribute('data-icon', this.slots.has('icon'));\n    }\n\n    override render() {\n        const collapsed = hasData(this, 'collapsed') && !this.closest('ui-side-nav')?.hasAttribute('rail');\n        return html`<a part=\"base\" href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} aria-current=${ifDefined(this.current ? 'page' : undefined)} tabindex=${collapsed ? -1 : 0} @click=${followLink}>\n            <span class=\"icon\"><slot name=\"icon\"></slot></span><span class=\"text\"><slot></slot></span>\n        </a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav-link': UiSideNavLink;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/side-nav-menu-item.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav-menu-item.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, nothing } from 'lit';\nimport { sideNavLinkStyles } from './shell-shared.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * Carbon `SideNavMenuItem`: a link inside a `<ui-side-nav-menu>` (32px, indented 32px, or 72px\n * when the parent has an icon).\n *\n * @slot - Link text\n * @csspart base - The link\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n * @cssprop --ui-nav-item-inset / --ui-nav-item-radius / --ui-nav-current-* - As on `<ui-side-nav-link>`\n */\n@customElement('ui-side-nav-menu-item')\nexport class UiSideNavMenuItem extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = [sideNavLinkStyles, css`\n        a {\n            block-size: 32px;\n            padding-inline-start: 32px;\n        }\n\n        :host([data-parent-icon]) a {\n            padding-inline-start: 72px;\n        }\n\n        .text {\n            font-weight: 400;\n        }\n    `];\n\n    @property() href = '#';\n\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('current')) (this.parentElement?.closest('ui-side-nav-menu') as LitElement | null)?.requestUpdate();\n    }\n\n    override render() {\n        return html`<a part=\"base\" href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} aria-current=${ifDefined(this.current ? 'page' : undefined)} @click=${followLink}><span class=\"text\"><slot></slot></span></a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav-menu-item': UiSideNavMenuItem;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/side-nav-menu.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav-menu.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html } from 'lit';\nimport { SlotController } from '../shared/slots.ts';\nimport { uid } from '../shared/field.ts';\nimport type { UiSideNavMenuItem } from './side-nav-menu-item.ts';\nimport { chevron } from './shell-shared.ts';\nimport type { ExpandedDetail } from '../shared/events.ts';\n\n/**\n * Carbon `SideNavMenu`: a collapsible group of `<ui-side-nav-menu-item>`s with a title, optional\n * icon and chevron. Shows as active (bar + bold) while collapsed if a child is `current`.\n *\n * @slot - `<ui-side-nav-menu-item>` elements\n * @slot icon - 16px icon\n * @fires ui-toggle - detail: { expanded }\n * @csspart trigger - The title button\n * @csspart menu - The list of items\n * @cssprop --ui-nav-item-inset / --ui-nav-item-radius / --ui-nav-current-* - As on `<ui-side-nav-link>`\n */\n@customElement('ui-side-nav-menu')\nexport class UiSideNavMenu extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n            inline-size: 100%;\n            overflow: hidden;\n        }\n\n        .trigger {\n            position: relative;\n            display: flex;\n            align-items: center;\n            box-sizing: border-box;\n            inline-size: calc(100% - 2 * var(--ui-nav-item-inset, 0px));\n            block-size: 32px;\n            margin-inline: var(--ui-nav-item-inset, 0);\n            padding: 0 16px;\n            border: none;\n            border-radius: var(--ui-nav-item-radius, 0);\n            background: transparent;\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-body-emphasis);\n            line-height: 18px; /* heading-compact-01 */\n            letter-spacing: var(--ui-tracking-body);\n            text-align: start;\n            cursor: pointer;\n            outline: none;\n            user-select: none;\n            transition:\n                color var(--ui-duration-moderate),\n                background-color var(--ui-duration-moderate);\n        }\n\n        :host([large]) .trigger {\n            block-size: 48px;\n        }\n\n        .trigger:hover {\n            background-color: var(--ui-canvas-hover);\n            color: var(--ui-ink);\n        }\n\n        .trigger:focus-visible {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: -2px;\n        }\n\n        :host([data-active]) .trigger[aria-expanded='false'] {\n            background-color: var(--ui-nav-current-background, var(--ui-canvas-selected));\n            color: var(--ui-ink);\n        }\n\n        :host([data-active]) .trigger[aria-expanded='false']::before {\n            content: '';\n            position: absolute;\n            inset-block: var(--ui-nav-current-mark-inset, 0);\n            inset-inline-start: 0;\n            inline-size: var(--ui-nav-current-mark-width, 3px);\n            border-radius: var(--ui-nav-current-mark-radius, 0);\n            background-color: var(--ui-nav-current-mark, var(--ui-primary));\n        }\n\n        :host([data-active]) .title {\n            color: var(--ui-ink);\n            font-weight: 600;\n        }\n\n        .icon {\n            display: none;\n            flex: 0 0 16px;\n            align-items: center;\n            justify-content: center;\n            margin-inline-end: 24px;\n        }\n\n        :host([data-icon]) .icon {\n            display: flex;\n        }\n\n        ::slotted([slot='icon']) {\n            width: 16px;\n            height: 16px;\n            fill: var(--ui-icon-secondary);\n        }\n\n        :host([data-active]) ::slotted([slot='icon']) {\n            fill: var(--ui-icon-primary);\n        }\n\n        .title {\n            overflow: hidden;\n            text-overflow: ellipsis;\n            white-space: nowrap;\n        }\n\n        .chevron-box {\n            display: flex;\n            flex: 1;\n            justify-content: flex-end;\n        }\n\n        .chevron {\n            width: 16px;\n            height: 16px;\n            fill: var(--ui-icon-secondary);\n            transition: transform var(--ui-duration-moderate);\n        }\n\n        .trigger[aria-expanded='true'] .chevron {\n            transform: rotate(180deg);\n        }\n\n        .menu {\n            display: block;\n            max-block-size: 0;\n            margin: 0;\n            padding: 0;\n            list-style: none;\n            visibility: hidden;\n        }\n\n        .trigger[aria-expanded='true'] + .menu {\n            max-block-size: 1500px;\n            visibility: inherit;\n        }\n\n        @media (forced-colors: active) {\n            :host([data-active]) .trigger[aria-expanded='false']::before {\n                inline-size: 3px; /* shown here even where a design hides it: the tint is gone in forced colours */\n                background-color: Highlight;\n            }\n        }\n    `;\n\n    @property() label = '';\n\n    @property({ type: Boolean, reflect: true }) expanded = false;\n\n    @property({ type: Boolean, reflect: true }) large = false;\n\n    private readonly slots = new SlotController(this);\n    private readonly menuId = uid('ui-side-nav-menu');\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        this.toggleAttribute('data-icon', this.slots.has('icon'));\n        const items = [...this.querySelectorAll<UiSideNavMenuItem>(':scope > ui-side-nav-menu-item')];\n        for (const item of items) item.toggleAttribute('data-parent-icon', this.slots.has('icon'));\n        this.toggleAttribute('data-active', items.some((i) => i.current));\n        if (changed.has('expanded') && changed.get('expanded') !== undefined) {\n            this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { expanded: this.expanded }, bubbles: true, composed: true }));\n        }\n    }\n\n    override render() {\n        return html`\n            <button class=\"trigger\" part=\"trigger\" type=\"button\" aria-expanded=${this.expanded ? 'true' : 'false'} aria-controls=${this.menuId} @click=${() => (this.expanded = !this.expanded)}>\n                <span class=\"icon\"><slot name=\"icon\"></slot></span>\n                <span class=\"title\">${this.label}</span>\n                <span class=\"chevron-box\">${chevron}</span>\n            </button>\n            <div class=\"menu\" part=\"menu\" id=${this.menuId} role=\"list\"><slot @slotchange=${() => this.requestUpdate()}></slot></div>\n        `;\n    }\n}\n\nexport interface UiSideNavMenuEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<ExpandedDetail>;\n}\n\n/** Typed listeners for UiSideNavMenu's events (declaration merging with the class). */\nexport interface UiSideNavMenu {\n    addEventListener<K extends keyof UiSideNavMenuEventMap>(type: K, listener: (this: UiSideNavMenu, event: UiSideNavMenuEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiSideNavMenuEventMap>(type: K, listener: (this: UiSideNavMenu, event: UiSideNavMenuEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav-menu': UiSideNavMenu;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/side-nav.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/side-nav.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { UiHeaderMenuButton } from './header-menu-button.ts';\nimport type { HeaderMenuButtonToggleDetail } from './shell-shared.ts';\nimport { hasData, deepActiveElement } from '../shared/field.ts';\nimport type { ExpandedDetail } from '../shared/events.ts';\n\n/** Carbon's `lg` breakpoint: the side nav pushes the content from here up. */\nconst LG = '(min-width: 1056px)';\n\n/**\n * Carbon `SideNav`: the left navigation. Modes: default (slides over the page below `lg`, 256px\n * from `lg` when `expanded`), `rail` (48px icons, expands on hover / focus) and `fixed` + `expanded`\n * (always 256px, pushes `<ui-content>`; `fixed` alone slides the nav out of view while `<ui-content>`\n * keeps its 256px offset). `collapsible` (Carbon `isPersistent={false}`) keeps it closed on\n * large screens too until the hamburger opens it over the page. Escape collapses; below `lg` an\n * overlay covers the page while expanded. The `<ui-header-menu-button>` in the same document (or\n * shadow root) opens and closes it, and follows it (Carbon web components).\n * Children: `<ui-side-nav-items>` holding links, menus and dividers.\n *\n * @slot - `<ui-side-nav-items>`\n * @fires ui-toggle - detail: { expanded } after a user action changed the state\n * @csspart base - The `<nav>`\n * @csspart overlay - The page overlay (below `lg`)\n */\n@customElement('ui-side-nav')\nexport class UiSideNav extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: contents;\n            font-family: var(--ui-font-family);\n        }\n\n        nav {\n            position: fixed;\n            inset-block: 48px 0;\n            inset-inline-start: 0;\n            z-index: 8000;\n            display: flex;\n            flex-direction: column;\n            box-sizing: border-box;\n            inline-size: 0;\n            max-inline-size: 256px;\n            overflow: hidden;\n            background-color: var(--ui-canvas);\n            color: var(--ui-ink-muted);\n            outline: none;\n            /* Carbon .cds--side-nav: 110ms with the exit easing */\n            transition:\n                inline-size var(--ui-duration-moderate) var(--ui-easing-exit),\n                transform var(--ui-duration-moderate) var(--ui-easing-exit);\n            will-change: inline-size;\n        }\n\n        @media (min-width: 1056px) {\n            nav {\n                inline-size: 256px;\n            }\n        }\n\n        :host([rail]) nav {\n            inline-size: 48px;\n        }\n\n        :host([expanded]) nav,\n        :host([data-hover-expanded]) nav {\n            inline-size: 256px;\n        }\n\n        :host([fixed]) nav {\n            inline-size: 256px;\n        }\n\n        /* Carbon side-nav--hidden (isPersistent={false}): closed on large screens too until expanded */\n        @media (min-width: 1056px) {\n            :host([collapsible]:not([expanded], [fixed], [rail])) nav {\n                inline-size: 0;\n            }\n        }\n\n        :host([fixed]:not([expanded])) nav {\n            transform: translateX(-256px);\n        }\n\n        :host(:dir(rtl)[fixed]:not([expanded])) nav {\n            transform: translateX(256px);\n        }\n\n        .overlay {\n            position: fixed;\n            inset-block-start: 48px;\n            inset-inline-start: 0;\n            inline-size: 0;\n            block-size: 0;\n            background-color: transparent;\n            opacity: 0;\n            /* Carbon .cds--side-nav__overlay: $transition-expansion (300ms) with $standard-easing (no tokens for either) */\n            transition:\n                opacity 300ms cubic-bezier(0.5, 0, 0.1, 1),\n                background-color 300ms cubic-bezier(0.5, 0, 0.1, 1);\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n            .overlay {\n                transition: none;\n            }\n        }\n\n        @media (max-width: 1055.98px) {\n            :host([expanded]:not([fixed])) .overlay {\n                z-index: 6000;\n                inline-size: 100vw;\n                block-size: 100vh;\n                background-color: var(--ui-overlay);\n                opacity: 1;\n            }\n        }\n\n        @media (forced-colors: active) {\n            nav {\n                border-inline-end: 1px solid CanvasText;\n            }\n        }\n    `;\n\n    @property({ type: Boolean, reflect: true }) expanded = false;\n\n    /** 48px icon rail that expands on hover / focus. */\n    @property({ type: Boolean, reflect: true }) rail = false;\n\n    /**\n     * With `expanded`: always 256px wide, pushing `<ui-content>` aside (no overlay). Set both — without `expanded`\n     * the nav slides out of view while `<ui-content>` keeps its 256px offset.\n     */\n    @property({ type: Boolean, reflect: true }) fixed = false;\n\n    /** Closed on large screens too until the hamburger opens it over the page (Carbon `isPersistent={false}`); `<ui-content>` isn't pushed aside. */\n    @property({ type: Boolean, reflect: true }) collapsible = false;\n\n    @property() label = '';\n\n    private readonly localize = new LocalizeController(this);\n\n    /** What had focus when the nav was expanded (normally the header's menu button), for Escape to return to. */\n    private returnFocus: HTMLElement | null = null;\n\n    private mediaQuery?: MediaQueryList;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.addEventListener('keydown', this.onKeydown);\n        // the nav opens / closes with the large breakpoint; re-render so links and `inert` follow it\n        this.mediaQuery ??= matchMedia(LG);\n        this.mediaQuery.addEventListener('change', this.onMediaChange);\n        this.root = this.getRootNode() as Document | ShadowRoot;\n        this.root.addEventListener('ui-toggle', this.onMenuButtonToggle);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('keydown', this.onKeydown);\n        this.mediaQuery?.removeEventListener('change', this.onMediaChange);\n        this.root?.removeEventListener('ui-toggle', this.onMenuButtonToggle);\n        this.root = undefined;\n    }\n\n    /** The document or shadow root this nav and its hamburger live in. */\n    private root?: Document | ShadowRoot;\n\n    /** Carbon web components: the hamburger opens / closes the nav by itself unless the page cancels `ui-toggle`. */\n    private readonly onMenuButtonToggle = (event: Event) => {\n        if (event.defaultPrevented || !(event.target instanceof UiHeaderMenuButton)) return;\n        this.setExpanded((event as CustomEvent<HeaderMenuButtonToggleDetail>).detail.active);\n    };\n\n    /** The hamburgers follow the nav: `active` while it is expanded, kept at large widths for a collapsible nav. */\n    private syncMenuButtons() {\n        for (const button of this.root?.querySelectorAll?.('ui-header-menu-button') ?? []) {\n            button.active = this.expanded;\n            if (this.collapsible) button.collapsible = true;\n        }\n    }\n\n    private readonly onMediaChange = () => this.requestUpdate();\n\n    /** Shown at full width (or as the rail's icon strip): anything else is 0px wide. */\n    private get open() {\n        return this.expanded || hasData(this, 'hoverExpanded') || this.fixed || (!this.rail && !this.collapsible && !!this.mediaQuery?.matches);\n    }\n\n    protected override willUpdate(changed: Map<string, unknown>) {\n        if (changed.has('expanded') && this.expanded) this.returnFocus = deepActiveElement();\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('expanded') || changed.has('collapsible')) this.syncMenuButtons();\n        const open = this.open;\n        for (const el of this.querySelectorAll<HTMLElement & { requestUpdate?: () => void }>('ui-side-nav-link, ui-side-nav-menu, ui-side-nav-menu-item, ui-header-nav, ui-header-menu, ui-header-menu-item')) {\n            if (el.dataset.inSideNav === undefined) {\n                el.toggleAttribute('data-in-side-nav', true);\n                el.requestUpdate?.(); // ui-header-nav renders no landmark of its own there\n            }\n            if ((el.dataset.collapsed !== undefined) === open) {\n                el.toggleAttribute('data-collapsed', !open);\n                el.requestUpdate?.(); // the items read data-collapsed while rendering\n            }\n        }\n    }\n\n    private setExpanded(expanded: boolean) {\n        if (this.expanded === expanded) return;\n        this.expanded = expanded;\n        this.dispatchEvent(new CustomEvent('ui-toggle', { detail: { expanded }, bubbles: true, composed: true }));\n    }\n\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (event.key !== 'Escape' || !this.expanded) return;\n        this.setExpanded(false);\n        this.returnFocus?.focus(); // WCAG 2.4.3: focus was inside the nav that just collapsed\n        this.returnFocus = null;\n    };\n\n    /** Rail: hover and keyboard focus expand it temporarily. */\n    private hoverExpand(on: boolean) {\n        if (!this.rail) return;\n        this.toggleAttribute('data-hover-expanded', on);\n        this.requestUpdate();\n    }\n\n    private onFocusOut(event: FocusEvent) {\n        const next = event.relatedTarget as Node | null;\n        if (next && (this.contains(next) || this.shadowRoot?.contains(next))) return;\n        this.hoverExpand(false);\n        // over the page (small screens, or a collapsible nav at any width): leaving it closes it (Carbon)\n        if (!this.fixed && this.expanded && (this.collapsible || !this.mediaQuery?.matches)) this.setExpanded(false);\n    }\n\n    override render() {\n        return html`\n            <div class=\"overlay\" part=\"overlay\" @click=${() => this.setExpanded(false)}></div>\n            <nav\n                part=\"base\"\n                aria-label=${this.label || this.localize.t.common.sideNavigation}\n                tabindex=\"-1\"\n                ?inert=${!this.open && !this.rail}\n                @pointerenter=${() => this.hoverExpand(true)}\n                @pointerleave=${() => this.hoverExpand(false)}\n                @focusin=${() => this.hoverExpand(true)}\n                @focusout=${this.onFocusOut}\n            >\n                <slot @slotchange=${() => this.requestUpdate()}></slot>\n            </nav>\n        `;\n    }\n}\n\nexport interface UiSideNavEventMap extends HTMLElementEventMap {\n    'ui-toggle': CustomEvent<ExpandedDetail>;\n}\n\n/** Typed listeners for UiSideNav's events (declaration merging with the class). */\nexport interface UiSideNav {\n    addEventListener<K extends keyof UiSideNavEventMap>(type: K, listener: (this: UiSideNav, event: UiSideNavEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiSideNavEventMap>(type: K, listener: (this: UiSideNav, event: UiSideNavEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-side-nav': UiSideNav;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/skip-to-content.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/skip-to-content.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html } from 'lit';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { focusFragmentTarget } from '../shared/navigate.ts';\n\n/**\n * Carbon `SkipToContent`: a link that appears on first Tab and jumps to `href` (`#main-content`,\n * the id `<ui-content>` sets). Put it first inside `<ui-header>`.\n *\n * @slot - Link text (defaults to the translation)\n */\n@customElement('ui-skip-to-content')\nexport class UiSkipToContent extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        a {\n            position: absolute;\n            inset-block-start: 0;\n            inset-inline-start: 0;\n            overflow: hidden;\n            margin: -1px;\n            padding: 0;\n            border: 0;\n            inline-size: 1px;\n            block-size: 1px;\n            clip-path: inset(50%);\n            white-space: nowrap;\n            font: var(--ui-font-body-sm);\n            text-decoration: none;\n        }\n\n        a:focus {\n            z-index: 9999;\n            display: flex;\n            box-sizing: border-box;\n            align-items: center;\n            padding: 0 1rem;\n            margin: 0;\n            border: 4px solid var(--ui-focus);\n            background-color: var(--ui-canvas);\n            color: var(--ui-ink-muted);\n            inline-size: auto;\n            block-size: 48px;\n            clip-path: none;\n            outline: none;\n        }\n    `;\n\n    @property() href = '#main-content';\n\n    private readonly localize = new LocalizeController(this);\n\n    /** In a micro app the target is in a shadow root, where the browser's own jump can't see it. */\n    private onClick(event: MouseEvent) {\n        if (focusFragmentTarget(event.currentTarget as Element, this.href)) event.preventDefault();\n    }\n\n    override render() {\n        return html`<a href=${this.href} @click=${this.onClick}><slot>${this.localize.t.common.skipToContent}</slot></a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-skip-to-content': UiSkipToContent;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/switcher-item.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/switcher-item.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { LitElement, css, html, nothing } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { followLink } from '../shared/navigate.ts';\n\n/**\n * Carbon `SwitcherItem`: one link of a `<ui-switcher>`; `selected` marks the current app (`aria-current=\"page\"`).\n *\n * @slot - Link text\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n */\n@customElement('ui-switcher-item')\nexport class UiSwitcherItem extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: block;\n            inline-size: 100%;\n            block-size: 32px;\n        }\n\n        a {\n            display: block;\n            box-sizing: border-box;\n            block-size: 32px;\n            padding: 6px 16px;\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-body-emphasis);\n            line-height: 18px;\n            letter-spacing: var(--ui-tracking-body);\n            text-decoration: none;\n            white-space: nowrap;\n            overflow: hidden;\n            text-overflow: ellipsis;\n        }\n\n        a:hover {\n            background: var(--ui-layer-hover-1);\n            color: var(--ui-ink);\n        }\n\n        a:focus-visible {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: -2px;\n        }\n\n        a:active {\n            background: var(--ui-layer-active-1);\n            color: var(--ui-ink);\n        }\n\n        :host([selected]) a,\n        :host([selected]) a:hover {\n            background: var(--ui-layer-selected-1);\n            color: var(--ui-ink);\n        }\n    `;\n\n    @property() href = '#';\n\n    @property({ type: Boolean, reflect: true }) selected = false;\n\n    /** Where the link opens (`_blank` for a new tab), as on `<a>`. */\n    @property() target = '';\n\n    /** The link's relation (`noopener`, `external` …), as on `<a>`. */\n    @property() rel = '';\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    override render() {\n        return html`<a href=${this.href} target=${this.target || nothing} rel=${this.rel || nothing} aria-current=${ifDefined(this.selected ? 'page' : undefined)} @click=${followLink}><slot></slot></a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-switcher-item': UiSwitcherItem;\n    }\n}\n"
    },
    {
      "path": "src/primitives/shell/switcher.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/shell/switcher.ts",
      "content": "import { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { css, html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\n/**\n * Carbon `Switcher` + `SwitcherItem`: the app list inside a header panel. Put `<ui-switcher-item>`s\n * (and `<hr>` dividers) in the default slot; `selected` marks the current app.\n *\n * @slot - `<ui-switcher-item>` and `<hr>` elements\n */\n@customElement('ui-switcher')\nexport class UiSwitcher extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: flex;\n            flex-direction: column;\n            color: var(--ui-ink-muted);\n        }\n\n        /* 16px above the first item, on the list rather than :host so a page-wide CSS reset can't remove it */\n        [role='list'] {\n            padding-block-start: 16px;\n        }\n\n        ::slotted(hr) {\n            display: block;\n            inline-size: 224px;\n            block-size: 1px;\n            margin: 8px 16px;\n            border: none;\n            background: var(--ui-border-subtle-1);\n        }\n    `;\n\n    @property() label = '';\n\n    override render() {\n        return html`<div role=\"list\" aria-label=${ifDefined(this.label || undefined)}><slot></slot></div>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-switcher': UiSwitcher;\n    }\n}\n"
    }
  ]
}
