{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-header",
  "type": "registry:ui",
  "title": "react-tw/header.tsx",
  "description": "Inside a SideNav (Carbon side-nav__header-navigation): the header menu bar copied there for small 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": [
    "@purpurabog/ui@^2.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-overlay",
    "@kanok-ui/tw-i18n",
    "@kanok-ui/tw-refs",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-tooltip",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/header.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/header.tsx",
      "content": "import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, type ComponentProps, type MouseEvent, type ReactNode, type Ref } from 'react';\nimport { Header as HeaderPrimitive, Shell as ShellPrimitive } from '@purpurabog/ui/headless';\nimport { lockScroll, unlockScroll } from '../core/overlay.ts';\nimport { useTranslation } from './lib/i18n.ts';\nimport { useMergedRefs } from './lib/refs.ts';\nimport { cn } from './lib/utils.ts';\nimport { Tooltip } from './tooltip.tsx';\n\n/*\n * Carbon UI Shell header as React + Tailwind components, the look and rules of `<ui-header>` and its\n * parts: the fixed 48px bar, product name, menu bar with dropdowns, global actions and the panel that\n * slides in under the header (app switcher, notifications). Geometry from @carbon/styles ui-shell:\n * the `lg` breakpoint is 1056px (Tailwind's own `lg` is 1024px, so `min-[1056px]:` here). The\n * behaviour (menu keys, outside clicks, focus return, the skip link) is the headless `Header`'s.\n */\n\ntype LinkProps = Omit<ComponentProps<'a'>, 'children' | 'className'>;\n\nconst menuIcon = <path d=\"M2 14.8h16v1.2H2zm0-5.4h16v1.2H2zM2 4h16v1.2H2z\" />;\nconst closeIcon = <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\" />;\n\n/** Carbon `SkipToContent`: a link that appears on the first Tab and jumps to the content (`#main-content`). Put it first in the Header. */\nexport function SkipToContent({ href = '#main-content', lang, children, ...rest }: Readonly<Omit<ComponentProps<'a'>, 'href' | 'lang' | 'children'> & { href?: string; lang?: string; children?: ReactNode }>) {\n    const t = useTranslation(lang).common;\n    return (\n        <HeaderPrimitive.SkipToContent {...rest}\n            href={href}\n            className={cn(\n                'absolute start-0 top-0 -m-px size-px overflow-hidden border-0 p-0 whitespace-nowrap no-underline [clip-path:inset(50%)] [font:var(--ui-font-body-sm)]',\n                'focus:z-[9999] focus:m-0 focus:box-border focus:flex focus:h-12 focus:w-auto focus:items-center focus:border-4 focus:border-solid focus:border-focus focus:bg-canvas focus:px-4 focus:text-ink-muted focus:outline-none focus:[clip-path:none]',\n            )}\n        >\n            {children ?? t.skipToContent}\n        </HeaderPrimitive.SkipToContent>\n    );\n}\n\n/** Carbon `Header`: the fixed 48px top bar (a banner landmark). In order: SkipToContent, HeaderMenuButton, HeaderName, HeaderNavigation, HeaderGlobalBar. */\nexport function Header({ 'aria-label': label, className, children, ...rest }: Readonly<Omit<ComponentProps<'header'>, 'aria-label' | 'className' | 'children'> & { 'aria-label'?: string; className?: string; children: ReactNode }>) {\n    return (\n        // data-ui-header (the primitive's): the toaster starts below it, as below <ui-header>\n        <HeaderPrimitive.Root {...rest}\n            aria-label={label}\n            className={cn('fixed inset-x-0 top-0 z-[8000] box-border flex h-12 items-center border-b border-solid border-border-subtle-1 bg-canvas font-sans forced-colors:border-b-[CanvasText]', className)}\n        >\n            {children}\n        </HeaderPrimitive.Root>\n    );\n}\n\n/** Carbon `HeaderName`: the product link at the start (`prefix` in regular weight, then the name in 600). */\nexport function HeaderName({ href = '/', prefix, children, ...rest }: LinkProps & { prefix?: string; children: ReactNode }) {\n    return (\n        <a\n            {...rest}\n            href={href}\n            className=\"box-border flex h-full items-center border-2 border-solid border-transparent pt-0 pr-8 pb-0 pl-4 font-semibold! leading-5! tracking-[0.1px] text-ink no-underline outline-none select-none [font:var(--ui-font-body-sm)] transition-[border-color] duration-(--ui-duration-moderate) ease-[ease] focus-visible:border-focus\"\n        >\n            {prefix ? (\n                <>\n                    <span className=\"font-normal\">{prefix}</span>&nbsp;\n                </>\n            ) : null}\n            <span>{children}</span>\n        </a>\n    );\n}\n\nexport interface HeaderMenuButtonProps extends Omit<ComponentProps<'button'>, 'active' | 'onToggle' | 'collapsible' | 'openLabel' | 'closeLabel' | 'aria-controls' | 'lang'> {\n    /** The side nav it controls is open. */\n    active?: boolean;\n    /** The user asked for the other state. */\n    onToggle?: (active: boolean) => void;\n    /** Keep the button at every width (a collapsible, non-fixed side nav). */\n    collapsible?: boolean;\n    openLabel?: string;\n    closeLabel?: string;\n    /** Id of the side nav it controls. */\n    'aria-controls'?: string;\n    lang?: string;\n}\n\n/** The 48px menu button (HeaderMenuButton, and the collapsed HeaderNavigation's): `active` while what it opens is open. */\nconst menuButtonClass = (active: boolean) =>\n    cn(\n        'box-border flex size-12 shrink-0 cursor-pointer items-center justify-center border border-solid border-transparent bg-transparent p-0 text-icon-primary outline-none transition-[background-color,border-color] duration-(--ui-duration-moderate) ease-[ease]',\n        'hover:bg-canvas-hover focus-visible:border-focus active:bg-canvas-active',\n        active && 'border-x-border-subtle-1 border-b-transparent bg-surface-1 hover:bg-surface-1',\n    );\n\n/** Carbon `HeaderMenuButton`: the hamburger that opens the side nav below the `lg` breakpoint (hidden above it unless `collapsible`). */\nexport function HeaderMenuButton({ active: activeProp, onToggle, collapsible = false, openLabel, closeLabel, 'aria-controls': controls, lang, ...rest }: Readonly<HeaderMenuButtonProps>) {\n    const t = useTranslation(lang).common;\n    // inside a headless Shell.Root it follows (and toggles) the shell's side nav\n    const shell = ShellPrimitive.useShellContext();\n    const active = activeProp ?? shell?.sideNavExpanded ?? false;\n    const label = active ? closeLabel || t.closeMenu : openLabel || t.openMenu;\n    return (\n        <HeaderPrimitive.MenuButton {...rest}\n            active={active}\n            onToggle={onToggle}\n            aria-label={label}\n            title={label}\n            aria-controls={controls}\n            className={cn(menuButtonClass(active), !collapsible && 'min-[1056px]:hidden')}\n        >\n            <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" className=\"size-5 fill-current\">\n                {active ? closeIcon : menuIcon}\n            </svg>\n        </HeaderPrimitive.MenuButton>\n    );\n}\n\n/**\n * Inside a SideNav (Carbon side-nav__header-navigation): the header menu bar copied there for small\n * screens — a column, no landmark of its own, hidden from `lg` where the header shows the original;\n * the current bars run down the start edge.\n */\nexport const InSideNav = createContext(false);\n\n/** A dropdown or mega panel of the menu bar, as the others see it: one open at a time (as `<ui-header-mega-menu>` closes the bar's others). */\nexport interface BarMenu {\n    readonly isOpen: () => boolean;\n    readonly close: () => void;\n}\n\n/** The menus of one HeaderNavigation. */\nconst HeaderBar = createContext<Set<BarMenu> | null>(null);\n\n/** Joins the enclosing HeaderNavigation's menus (outside one: alone); `close` closes this one. */\nexport function useBarMenu(open: boolean, close: () => void) {\n    const bar = useContext(HeaderBar);\n    const live = useRef({ open, close });\n    useLayoutEffect(() => {\n        live.current = { open, close };\n    });\n    const [self] = useState<BarMenu>(() => ({ isOpen: () => live.current.open, close: () => live.current.close() }));\n    useEffect(() => {\n        if (!bar) return;\n        bar.add(self);\n        return () => {\n            bar.delete(self);\n        };\n    }, [bar, self]);\n    const others = () => [...(bar ?? [])].filter((menu) => menu !== self && menu.isOpen());\n    return {\n        anotherOpen: () => others().length > 0,\n        closeOthers: () => {\n            for (const menu of others()) menu.close();\n        },\n    };\n}\n\n/** Puts `el` (a fixed box) under the closest `<header>`, as wide as it (the page's width without one), as the Lit mega panel and sheet. */\nexport function placeUnderHeader(el: HTMLElement, from: HTMLElement) {\n    const header = from.closest('header');\n    const rect = (header ?? from).getBoundingClientRect();\n    el.style.top = `${rect.bottom}px`;\n    el.style.left = `${header ? rect.left : 0}px`;\n    el.style.width = `${header ? rect.width : document.documentElement.clientWidth}px`;\n}\n\n/** Takes back what placeUnderHeader set (a closed or collapsed box lays out by its classes again). */\nexport function clearPlacement(el: HTMLElement) {\n    for (const name of ['top', 'left', 'width', '--_top']) el.style.removeProperty(name);\n}\n\n/** Below Carbon's `lg` breakpoint the bar doesn't fit the header (Lit `<ui-header-nav collapse>`). */\nconst NARROW = '(max-width: 1055.98px)';\n\nconst subscribeNarrow = (onChange: () => void) => {\n    const query = matchMedia(NARROW);\n    query.addEventListener('change', onChange);\n    return () => query.removeEventListener('change', onChange);\n};\n\n/** Below `lg` (false on the server and while hydrating). */\nconst useNarrow = () =>\n    useSyncExternalStore(\n        subscribeNarrow,\n        () => matchMedia(NARROW).matches,\n        () => false,\n    );\n\nconst NAV_CLASS = \"relative hidden h-full ps-4 before:absolute before:start-0 before:top-1/2 before:block before:h-6 before:w-px before:bg-border-subtle-1 before:[transform:translateY(-50%)] before:content-[''] min-[1056px]:block\";\nconst BAR_CLASS = 'm-0 flex h-full list-none p-0';\nconst COLUMN_CLASS = 'm-0 flex list-none flex-col p-0';\n\nexport interface HeaderNavigationProps extends Omit<ComponentProps<'nav'>, 'aria-label' | 'lang' | 'children'> {\n    /** Names the landmark (default \"Main navigation\"; Lit `label`). */\n    'aria-label'?: string;\n    lang?: string;\n    /** Below `lg`, a menu button and a full-screen sheet instead of hiding: a header with no side nav (Lit `collapse`). */\n    collapse?: boolean;\n    children: ReactNode;\n}\n\n/**\n * Carbon `HeaderNavigation`: the main menu bar, shown from the `lg` breakpoint. Children: HeaderMenuItem, HeaderMenu\n * and HeaderMegaMenu. With `collapse` it stays below `lg` as a menu button that opens the bar as a sheet under the\n * header (the menus take their side-nav look; a mega menu is an accordion row), as `<ui-header-nav collapse>`.\n */\nexport function HeaderNavigation({ 'aria-label': label, lang, collapse = false, children, ref, ...rest }: Readonly<HeaderNavigationProps>) {\n    const t = useTranslation(lang).common;\n    const inSideNav = useContext(InSideNav);\n    const [bar] = useState(() => new Set<BarMenu>());\n    let body: ReactNode;\n    if (inSideNav) {\n        // part of the side nav's landmark, not a second \"Main navigation\"\n        body = (\n            <div {...rest} ref={ref as Ref<HTMLDivElement> | undefined} className=\"relative block h-full min-[1056px]:hidden\">\n                <ul className=\"m-0 flex h-full list-none flex-col p-0\">\n                    {children}\n                </ul>\n            </div>\n        );\n    } else if (collapse) {\n        body = (\n            <CollapsibleNavigation {...rest} navRef={ref} label={label || t.mainNavigation} openLabel={t.openMenu} closeLabel={t.closeMenu} bar={bar}>\n                {children}\n            </CollapsibleNavigation>\n        );\n    } else {\n        body = (\n            <nav {...rest} ref={ref} aria-label={label || t.mainNavigation} className={NAV_CLASS}>\n                <ul className={BAR_CLASS}>\n                    {children}\n                </ul>\n            </nav>\n        );\n    }\n    return <HeaderBar.Provider value={bar}>{body}</HeaderBar.Provider>;\n}\n\n/** The page outside the header made inert (Tab stays in the header and its sheet), as Lit's setPageInert; returns what it changed. */\nfunction inertPage(from: HTMLElement) {\n    const changed: HTMLElement[] = [];\n    let node: HTMLElement = from.closest('header') ?? from;\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                changed.push(sibling);\n            }\n        }\n        node = node.parentElement;\n    }\n    return changed;\n}\n\n/** An open dropdown or panel doesn't carry over between the bar and the sheet (as Lit's markItems). */\nfunction useCloseOnFlip(bar: Set<BarMenu>, narrow: boolean) {\n    const was = useRef(narrow);\n    useLayoutEffect(() => {\n        if (was.current === narrow) return;\n        was.current = narrow;\n        for (const menu of bar) if (menu.isOpen()) menu.close();\n    }, [bar, narrow]);\n}\n\ninterface CollapsibleNavigationProps extends Omit<HeaderNavigationProps, 'aria-label' | 'lang' | 'collapse' | 'ref'> {\n    navRef: Ref<HTMLElement> | undefined;\n    label: string;\n    openLabel: string;\n    closeLabel: string;\n    bar: Set<BarMenu>;\n}\n\n/**\n * HeaderNavigation with `collapse`: the bar from `lg`; below it a menu button and a sheet (a manual popover: the top\n * layer) from under the header to the bottom of the window. While the sheet is open the page behind is inert and\n * doesn't scroll; Escape closes it and focuses the button, following a link closes it, widening past `lg` closes it.\n */\nfunction CollapsibleNavigation({ navRef, label, openLabel, closeLabel, bar, children, ...rest }: Readonly<CollapsibleNavigationProps>) {\n    const narrow = useNarrow();\n    const [sheetOpen, setSheetOpen] = useState(false);\n    // widening past lg closes it (the bar is back)\n    if (!narrow && sheetOpen) setSheetOpen(false);\n    const sheetId = useId();\n    const nav = useRef<HTMLElement>(null);\n    const ref = useMergedRefs(nav, navRef);\n    const button = useRef<HTMLButtonElement>(null);\n    const sheet = useRef<HTMLDivElement>(null);\n    useCloseOnFlip(bar, narrow);\n    useLayoutEffect(() => {\n        const box = sheet.current;\n        const at = nav.current;\n        if (!sheetOpen || !box || !at) return;\n        // placed before it shows: no frame at the wrong place\n        const place = () => placeUnderHeader(box, at);\n        place();\n        box.showPopover();\n        const root = document.documentElement;\n        lockScroll(box, root);\n        const inerted = inertPage(at);\n        const onKey = (event: KeyboardEvent) => {\n            if (event.key !== 'Escape') return;\n            event.stopPropagation();\n            setSheetOpen(false);\n            button.current?.focus();\n        };\n        document.addEventListener('keydown', onKey, true);\n        window.addEventListener('resize', place);\n        return () => {\n            if (box.matches(':popover-open')) box.hidePopover();\n            clearPlacement(box);\n            unlockScroll(box, root);\n            for (const el of inerted) el.inert = false;\n            document.removeEventListener('keydown', onKey, true);\n            window.removeEventListener('resize', place);\n        };\n    }, [sheetOpen]);\n    const onSheetClick = (event: MouseEvent<HTMLDivElement>) => {\n        if (!sheetOpen || !(event.target as Element).closest('a[href]')) return;\n        setSheetOpen(false);\n        button.current?.focus();\n    };\n    const buttonLabel = sheetOpen ? closeLabel : openLabel;\n    const buttonIcon = sheetOpen ? closeIcon : menuIcon;\n    return (\n        <nav {...rest} ref={ref} aria-label={label} className={narrow ? 'relative block h-full' : NAV_CLASS}>\n            {narrow && (\n                <button ref={button} type=\"button\" aria-label={buttonLabel} aria-expanded={sheetOpen} aria-controls={sheetId} className={menuButtonClass(sheetOpen)} onClick={() => setSheetOpen(!sheetOpen)}>\n                    <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" className=\"size-5 fill-current\">\n                        {buttonIcon}\n                    </svg>\n                </button>\n            )}\n            {/* the same tree at every width, so the menus keep their state across the flip until useCloseOnFlip closes them; from lg it adds no box */}\n            <div /* NOSONAR: following one of its links closes the sheet; the links take the keyboard */\n                ref={sheet}\n                id={sheetId}\n                popover={narrow ? 'manual' : undefined}\n                className={narrow ? SHEET_CLASS : 'contents'}\n                onClick={onSheetClick}\n            >\n                <InSideNav.Provider value={narrow}>\n                    <ul className={narrow ? COLUMN_CLASS : BAR_CLASS}>{children}</ul>\n                </InSideNav.Provider>\n            </div>\n        </nav>\n    );\n}\n\n/** The narrow sheet (Lit `.sheet`): under the header to the bottom of the window (`block-size: auto`, not the popover's fit-content), scrolling. */\nconst SHEET_CLASS =\n    'fixed inset-auto bottom-0 m-0 box-border h-auto overflow-y-auto overscroll-contain border-x-0 border-t border-b-0 border-solid border-t-border-subtle-1 bg-[color:var(--ui-mega-panel-background,var(--ui-overlay-background,var(--ui-surface-1)))] px-0 py-2 text-ink';\n\nexport interface HeaderMenuItemProps extends LinkProps {\n    /** The current page (`aria-current=\"page\"`, the 3px bar). */\n    current?: boolean;\n    children: ReactNode;\n}\n\n// the current item's bar: border-interactive, or the side nav's setting (--ui-nav-current-mark)\nconst currentBar = \"after:absolute after:-start-0.5 after:bg-[color:var(--ui-nav-current-mark,var(--ui-primary))] after:content-[''] forced-colors:after:bg-[Highlight]\";\n\n/** Carbon `HeaderMenuItem`: one link of the menu bar or of a HeaderMenu dropdown; `current` marks the page. */\nexport function HeaderMenuItem({ href = '#', current = false, children, ...rest }: Readonly<HeaderMenuItemProps>) {\n    // inside a HeaderMenu dropdown: 48px rows on the layer, the current bar on the start edge (following the link closes the menu: the primitive's)\n    const inMenu = HeaderPrimitive.useOptionalMenuContext() !== null;\n    const inSideNav = useContext(InSideNav);\n    const startBar = inMenu || inSideNav;\n    return (\n        <li className={cn('block h-full', inMenu && 'h-12')}>\n            <HeaderPrimitive.MenuItem\n                {...rest}\n                href={href}\n                current={current}\n                className={cn(\n                    'relative box-border flex h-full items-center border-2 border-solid border-transparent bg-canvas px-4 leading-[18px]! tracking-normal whitespace-nowrap text-ink-muted no-underline outline-none select-none [font:var(--ui-font-body-sm)]',\n                    'transition-[background-color,border-color,color] duration-(--ui-duration-moderate) ease-[ease] hover:bg-canvas-hover hover:text-ink focus-visible:border-focus active:bg-canvas-active active:text-ink',\n                    inMenu && 'bg-surface-1 hover:bg-layer-hover-1',\n                    current && cn('text-ink', currentBar, inMenu && 'bg-layer-selected-1', startBar ? 'after:-top-0.5 after:h-[calc(100%+4px)] after:w-[3px]' : 'after:-bottom-0.5 after:h-[3px] after:w-[calc(100%+4px)]'),\n                )}\n            >\n                <span className=\"overflow-hidden text-ellipsis\">{children}</span>\n            </HeaderPrimitive.MenuItem>\n        </li>\n    );\n}\n\nexport interface HeaderMenuProps extends Omit<ComponentProps<'li'>, 'label' | 'open' | 'defaultOpen' | 'onToggle' | 'current' | 'children'> {\n    label: string;\n    /** Open (controlled). */\n    open?: boolean;\n    defaultOpen?: boolean;\n    onToggle?: (open: boolean) => void;\n    /** Mark the menu as the current section even while open (Carbon `isActive`). */\n    current?: boolean;\n    /** `<HeaderMenuItem>`s. */\n    children: ReactNode;\n}\n\n/** The menu title's chevron, turned while open. */\nexport const chevron = (open: boolean) => (\n    <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\" className={cn('ms-2 size-4 fill-icon-secondary transition-[transform,fill] duration-(--ui-duration-moderate) ease-[ease]', open && '[transform:rotate(180deg)]')}>\n        <path d=\"M8 11 3 6l.7-.7L8 9.6l4.3-4.3.7.7z\" />\n    </svg>\n);\n\n/** The title of a HeaderMenu or HeaderMegaMenu (Carbon header__menu-title; Lit headerTriggerStyles): open, showing the current bar, in the side nav. */\nexport const menuTitleClass = (open: boolean, current: boolean, inSideNav: boolean) =>\n    cn(\n        'relative box-border flex h-full cursor-pointer items-center border-2 border-solid border-transparent bg-canvas px-4 leading-[18px]! whitespace-nowrap text-ink-muted outline-none select-none [font:var(--ui-font-body-sm)]',\n        'hover:bg-canvas-hover hover:text-ink focus-visible:border-focus',\n        open && 'z-[8002] bg-surface-1 hover:bg-surface-1',\n        current && cn(currentBar, 'after:-bottom-0.5', inSideNav ? 'after:h-[calc(100%+4px)] after:w-[3px]' : 'after:h-[3px] after:w-[calc(100%+4px)]'),\n    );\n\n/**\n * Carbon `HeaderMenu`: a menu-bar entry that opens a 200px dropdown of HeaderMenuItems — a disclosure\n * (the links stay links). Click / Enter / Space toggle; Esc and a click outside close (Esc returns focus);\n * following one of its links closes it and focuses the title. Closed, it shows the current-page bar\n * when one of its items is `current`; `current` shows it always.\n */\nexport function HeaderMenu({ label, open, defaultOpen = false, onToggle, current = false, children, ref, ...rest }: Readonly<HeaderMenuProps>) {\n    return (\n        <HeaderPrimitive.Menu {...rest} ref={ref} open={open} defaultOpen={defaultOpen} onOpenChange={onToggle} current={current} className=\"relative block h-full\">\n            <HeaderMenuBody label={label}>{children}</HeaderMenuBody>\n        </HeaderPrimitive.Menu>\n    );\n}\n\n/** The title and the dropdown, inside the menu's primitive (they follow its open and current state). */\nfunction HeaderMenuBody({ label, children }: Readonly<{ label: string; children: ReactNode }>) {\n    const { open, current: showCurrent, setOpen } = HeaderPrimitive.useMenuContext();\n    const inSideNav = useContext(InSideNav);\n    // a mega panel of the bar opening closes it (as `<ui-header-mega-menu>` closes the bar's `<ui-header-menu>`s)\n    useBarMenu(open, () => setOpen(false));\n    return (\n        <>\n            <HeaderPrimitive.MenuTrigger className={menuTitleClass(open, showCurrent, inSideNav)}>\n                {label}\n                {chevron(open)}\n            </HeaderPrimitive.MenuTrigger>\n            <HeaderPrimitive.MenuPopup\n                aria-label={label}\n                className={cn(\n                    'm-0 hidden list-none p-0',\n                    open && 'absolute start-0 bottom-0 z-[8001] flex w-[200px] flex-col bg-[var(--ui-overlay-background,var(--ui-surface-1))] shadow-[0_4px_8px_0_rgb(0_0_0/0.5)] [transform:translateY(100%)]',\n                    open && inSideNav && 'static w-full shadow-none [transform:none]',\n                )}\n            >\n                {children}\n            </HeaderPrimitive.MenuPopup>\n        </>\n    );\n}\n\n/** Carbon `HeaderGlobalBar`: the right-aligned group of HeaderGlobalActions. */\nexport function HeaderGlobalBar({ 'aria-label': label, lang, children, ...rest }: Readonly<Omit<ComponentProps<'div'>, 'aria-label' | 'lang' | 'children'> & { 'aria-label'?: string; lang?: string; children: ReactNode }>) {\n    const t = useTranslation(lang).common;\n    return (\n        <div {...rest} className=\"flex h-full flex-[1_1_0%] justify-end\">\n            <div /* NOSONAR: as <ui-header-global-bar>: the global actions form a named group */ role=\"group\" aria-label={label || t.globalActions} className=\"flex h-full\">\n                {children}\n            </div>\n        </div>\n    );\n}\n\nexport interface HeaderGlobalActionProps extends Omit<ComponentProps<'button'>, 'label' | 'active' | 'expanded' | 'aria-controls' | 'onClick' | 'tooltipPlacement' | 'children'> {\n    /** Required: the accessible name and the tooltip text. */\n    label: string;\n    /** Pressed look and `aria-pressed` (a toggle). */\n    active?: boolean;\n    /** The panel it opens is open: the pressed look and `aria-expanded` (a disclosure). */\n    expanded?: boolean;\n    /** Id of the panel it opens. */\n    'aria-controls'?: string;\n    onClick?: () => void;\n    tooltipPlacement?: 'bottom' | 'bottom-start' | 'bottom-end';\n    /** The 20px icon. */\n    children: ReactNode;\n}\n\n/** Carbon `HeaderGlobalAction`: a 48px icon button in the header, named by its icon tooltip. */\nexport function HeaderGlobalAction({ label, active = false, expanded, 'aria-controls': controls, onClick, tooltipPlacement = 'bottom', children, ...rest }: Readonly<HeaderGlobalActionProps>) {\n    const disclosure = expanded !== undefined;\n    const pressed = disclosure ? expanded : active;\n    return (\n        <Tooltip text={label} asLabel placement={tooltipPlacement} className=\"block h-full\">\n            <HeaderPrimitive.GlobalAction {...rest}\n                active={active}\n                expanded={expanded}\n                aria-controls={controls}\n                onClick={onClick}\n                className={cn(\n                    'box-border inline-flex size-12 cursor-pointer items-center justify-center rounded-[var(--ui-header-action-radius,0px)] border border-solid border-transparent bg-transparent p-0 text-icon-secondary outline-none transition-[background-color,border-color] duration-(--ui-duration-moderate) ease-[ease] [&_svg]:size-5 [&_svg]:fill-current',\n                    'hover:bg-canvas-hover hover:text-icon-primary focus-visible:border-focus active:bg-canvas-active active:text-icon-primary',\n                    pressed && 'border-x-border-subtle-1 border-b-transparent bg-surface-1 text-icon-primary hover:bg-surface-1',\n                )}\n            >\n                {children}\n            </HeaderPrimitive.GlobalAction>\n        </Tooltip>\n    );\n}\n\nexport type HeaderPanelCloseReason = HeaderPrimitive.PanelCloseReason;\n\nexport interface HeaderPanelProps extends Omit<ComponentProps<'div'>, 'expanded' | 'onClose' | 'aria-label' | 'id' | 'children'> {\n    expanded: boolean;\n    /** Esc (focus goes back to what opened it), focus leaving the panel, or a click outside it (not on its action, `aria-controls` = its `id`). */\n    onClose?: (reason: HeaderPanelCloseReason) => void;\n    /** Names the panel (a region landmark). */\n    'aria-label'?: string;\n    id?: string;\n    children?: ReactNode;\n}\n\n/** Carbon `HeaderPanel`: a 256px panel that slides in under the header on the end side (app switcher, notifications). */\nexport function HeaderPanel({ expanded, onClose, 'aria-label': label, id, children, ...rest }: Readonly<HeaderPanelProps>) {\n    return (\n        <HeaderPrimitive.Panel {...rest}\n            id={id}\n            expanded={expanded}\n            onClose={onClose}\n            className={cn(\n                'fixed end-0 top-12 bottom-0 z-[8000] box-border w-0 overflow-hidden bg-surface-1 font-sans text-ink-muted transition-[inline-size] duration-(--ui-duration-moderate) ease-[cubic-bezier(0.2,0,1,0.9)]',\n                expanded && 'w-64 overflow-y-auto overscroll-contain',\n            )}\n        >\n            {/* a region landmark once named */}\n            <HeaderPrimitive.PanelContent aria-label={label} className=\"box-border min-h-full border-x border-solid border-border-subtle-1\">\n                {children}\n            </HeaderPrimitive.PanelContent>\n        </HeaderPrimitive.Panel>\n    );\n}\n"
    }
  ]
}
