{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "nav",
  "title": "Nav",
  "description": "Vertical (or wrapping) location list; the cobalt band stretches between items. Labelled groups, icon key cells, nested links under a disclosure, row actions (NavAction), a brand identity block and a footer; a rail of key cells with tooltips inside AppShell. With AppShell it is the sidebar (@keyline-ui/sidebar).",
  "dependencies": [
    "@base-ui/react@1.9.0"
  ],
  "registryDependencies": [
    "@keyline-ui/keyline",
    "utils",
    "@keyline-ui/keyline-motion",
    "@keyline-ui/keyline-render",
    "@keyline-ui/scroll-edges",
    "@keyline-ui/tooltip"
  ],
  "files": [
    {
      "path": "src/registry/keyline/ui/nav.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\n\nimport { cn } from \"@/lib/utils\";\nimport { tokenMs, useStretch } from \"../lib/keyline-motion\";\nimport { resolveClassName, resolveStyle, type PartProps } from \"../lib/keyline-render\";\nimport { useScrollEdges } from \"../lib/scroll-edges\";\nimport { Tooltip, TooltipProvider } from \"./tooltip\";\n\ntype NavItem = {\n  value: string;\n  label: React.ReactNode;\n  href?: string;\n  count?: React.ReactNode;\n  disabled?: boolean;\n  /** A 16px glyph in the item's key cell (authored SVG, aria-hidden). Needed for the shell's rail. */\n  icon?: React.ReactNode;\n  /**\n   * Nested links. The item becomes a disclosure (a button with aria-expanded) over an indented\n   * list on the key column's seam; it is not a destination itself. It opens by itself while one of its links\n   * is current, and while it is closed the band rests on it. On a rail the list is hidden and pressing the\n   * item widens the sidebar with the list open.\n   */\n  items?: NavItem[];\n  /** Open at first render. Default: open when a nested link is current. */\n  defaultOpen?: boolean;\n  /**\n   * A cell at the row's end for the item's own commands: usually a <NavAction> as a MenuTrigger's\n   * render. It is a separate Tab stop beside the item, never inside the link. Hidden on a rail.\n   */\n  action?: React.ReactNode;\n};\ntype NavGroup = { label: string; items: NavItem[] };\n\n/** Set by AppShell when the sidebar is a rail (icons only): labels fly out on hover and focus. */\nconst NavRailContext = React.createContext(false);\n/** Set by AppShell: widens a rail (a nested item pressed on the rail opens its list in the full sidebar). */\nconst NavExpandContext = React.createContext<(() => void) | null>(null);\n\nconst has = (it: NavItem, value: string): boolean => !!it.items?.some((c) => c.value === value || has(c, value));\n\n/* ------------------------------------------------------------------ *\n * CLASSES\n * The list is a stretch row: the engine clones it for a move and drops the clone's data-slot and ARIA, so every\n * style sits on the element it styles (or on the list, counting children: the band is always its first child),\n * and the clone reads the same. What the nav's own state decides (icons, rail, depth, orientation) is chosen here\n * in JS; the root mirrors it as data-kl-icons, data-kl-rail and data-orientation for consumers.\n * ------------------------------------------------------------------ */\n\n/** visually hidden, still the accessible name (the rail's labels) */\nconst srOnly = \"absolute size-px -m-px overflow-hidden p-0 whitespace-nowrap [clip-path:inset(50%)]\";\n\nconst focusRing =\n  \"focus-visible:outline-(length:--kl-ring) focus-visible:outline-offset-(--kl-ring-in) focus-visible:outline-kl-focus focus-visible:outline-solid\";\n\nconst header = cn(\n  \"flex min-h-[52px] items-center gap-2.5 py-0 ps-[calc(14px+var(--kl-c-room,0px))] pe-3.5\",\n  \"border-b-(length:--kl-k3) border-b-kl-line text-[15px] font-(--kl-weight-strong)\",\n  // a header holding an identity is the brand block: ink, the full frame width, the cut on its corner\n  \"has-[>[data-slot=nav-identity]]:border-b-kl-inverse has-[>[data-slot=nav-identity]]:bg-kl-inverse\",\n  \"has-[>[data-slot=nav-identity]]:p-0 has-[>[data-slot=nav-identity]]:text-kl-on-inverse\",\n  \"*:data-[slot=nav-identity]:min-h-[60px] *:data-[slot=nav-identity]:flex-auto\",\n  // a responsive nav wide enough to be a row has no header\n  \"@min-[300px]/kl-nav:hidden\",\n);\n\n/*\n * The list: rows on keylines. The first row after the band draws no top keyline; the last closes on one (a shadow, not\n * a border, so it takes no room: a 1px taller list toggled the shell's scroller, a WebKit ResizeObserver loop). A\n * responsive nav lays it out as a row once the nav is 300px wide (its own width, not the viewport's).\n */\nconst list = cn(\n  \"kl-rows relative isolate m-0 [scrollbar-width:thin] [scrollbar-color:var(--kl-ink-3)_transparent] list-none p-0\",\n  \"[&>li:nth-child(2)]:border-t-0\",\n  \"[&>li:last-child:not(:first-child,.kl-more-fade)]:[box-shadow:0_var(--kl-k1)_0_var(--kl-line)]\",\n  // forced colours drop box-shadows: the closing keyline becomes an outline (no layout change, so no resize loop)\n  \"forced-colors:[&>li:last-child:not(:first-child,.kl-more-fade)]:outline-1\",\n  \"forced-colors:[&>li:last-child:not(:first-child,.kl-more-fade)]:outline-offset-[-1px]\",\n  \"forced-colors:[&>li:last-child:not(:first-child,.kl-more-fade)]:outline-[CanvasText]\",\n  \"forced-colors:[&>li:last-child:not(:first-child,.kl-more-fade)]:outline-solid\",\n  \"@min-[300px]/kl-nav:flex-row @min-[300px]/kl-nav:overflow-x-auto\",\n  \"@min-[300px]/kl-nav:[&>li:not(:first-child,.kl-more-fade)]:flex-none\",\n  \"@min-[300px]/kl-nav:[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-t-0\",\n  \"@min-[300px]/kl-nav:[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-s-(length:--kl-k1)\",\n  \"@min-[300px]/kl-nav:[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-s-kl-seam\",\n);\n/** horizontal: one row of cells that scrolls inside its own frame */\nconst listRow = cn(\n  \"flex-row overflow-x-auto [&>li:not(:first-child,.kl-more-fade)]:flex-none\",\n  \"[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-t-0\",\n  \"[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-s-(length:--kl-k1)\",\n  \"[&>li:not(:first-child,.kl-more-fade)+li:not(.kl-more-fade)]:border-s-kl-seam\",\n);\n\nconst band = \"pointer-events-none absolute -z-1 list-none bg-kl-cobalt\";\n/*\n * With icons, the current item's key cell is ink under the cobalt band: a key pressed in. The ink is the band's own,\n * over the key column (--kl-band-c0/c1: the band's distance from each side), so it travels with the band, edge for\n * edge. A nested row starts past the column, so its band has no ink.\n */\nconst bandInk = cn(\n  \"[background-image:linear-gradient(var(--kl-inverse),var(--kl-inverse))] [background-position:left_top] bg-no-repeat\",\n  \"[background-size:max(0px,calc(44px_-_var(--kl-band-c0,0px)))_100%]\",\n  \"kl-rtl:[background-size:max(0px,calc(44px_-_var(--kl-band-c1,0px)))_100%] kl-rtl:[background-position:right_top]\",\n);\n\n/*\n * An item: a link or a button filling its row. Hover tints only rows the band is NOT on: a closed parent holding the\n * current link carries the band (on-cobalt text) without aria-current, and an opaque tint there hid the band under\n * white text. KEY: a press registers on the frame it lands, before the band or the page answers.\n */\nconst item = cn(\n  \"group/nav-item flex min-h-[44px] w-full cursor-pointer items-center justify-between gap-2 border-0 bg-transparent px-3.5\",\n  \"text-start font-(family-name:--kl-font) text-[14px] font-(--kl-weight-strong) text-inherit no-underline\",\n  \"hover:[&:not([aria-current],[data-kl-covered],[data-kl-holds]):not(:disabled)]:bg-kl-tint\",\n  \"active:[&:not([aria-current],[data-kl-covered],[data-kl-holds],:disabled,[aria-disabled])]:bg-kl-press\",\n  \"data-kl-covered:not-disabled:not-aria-disabled:text-kl-on-cobalt\",\n  \"disabled:cursor-not-allowed disabled:bg-(image:--kl-hatch) disabled:text-kl-dis\",\n  \"aria-disabled:cursor-not-allowed aria-disabled:bg-(image:--kl-hatch) aria-disabled:text-kl-dis\",\n  focusRing,\n);\n/** the covered item's key cell takes the ink fill's colours (a disabled item keeps the disabled ink) */\nconst icon = cn(\n  \"me-3 grid w-11 flex-none place-items-center self-stretch border-e-(length:--kl-k1) border-e-kl-seam [&_svg]:block\",\n  \"group-data-kl-covered/nav-item:border-e-kl-inverse\",\n);\nconst iconCovered = \"group-[[data-kl-covered]:not(:disabled,[aria-disabled])]/nav-item:text-kl-on-inverse\";\n/** on a rail the whole item is the key cell: the current one shows the cobalt band itself (an ink cell here would\n * merge with the ink brand block above it) */\nconst iconRail =\n  \"m-0 w-full border-e-0 group-[[data-kl-covered]:not(:disabled,[aria-disabled])]/nav-item:text-kl-on-cobalt\";\nconst count = \"kl-code flex-none ps-2 font-normal text-inherit\";\nconst countRail = \"absolute end-1 top-[3px] p-0 text-[10px]/none\";\n\nconst caret = \"ms-1 grid w-5 flex-none place-items-center text-kl-ink-2 group-data-kl-covered/nav-item:text-inherit\";\n/* the caret turns a quarter toward the list, with the Accordion's timing; in RTL it points left, so it turns back */\nconst caretGlyph = cn(\n  \"[transition:rotate_var(--kl-t-fold)_var(--kl-ease-in)] kl-rtl:[transform:scaleX(-1)]\",\n  \"group-aria-expanded/nav-item:rotate-90 group-aria-expanded/nav-item:[transition:rotate_var(--kl-t-unfold)_var(--kl-ease-out)]\",\n  \"kl-rtl:group-aria-expanded/nav-item:-rotate-90\",\n);\n\n/** GROUPS: labelled sections; a heavy seam between them (the band still crosses) */\nconst group = \"block not-nth-2:border-t-(length:--kl-k3)\";\nconst groupLabel = \"flex min-h-9 items-center px-3.5 py-2 text-[12px] font-(--kl-weight-display) text-kl-ink-2\";\nconst groupList = cn(\n  \"m-0 flex list-none flex-col p-0\",\n  \"[&>li]:border-t-(length:--kl-k1) [&>li]:border-t-kl-line [&>li:first-child]:border-t-kl-seam\",\n);\n\n/** NESTED LINKS: the fold unfolds on its rows track (Accordion timing); the list inside hangs on the key column's seam */\nconst fold = cn(\n  \"grid grid-rows-[0fr] [transition:grid-template-rows_var(--kl-t-fold)_var(--kl-ease-in)]\",\n  \"data-open:grid-rows-[1fr] data-open:[transition:grid-template-rows_var(--kl-t-unfold)_var(--kl-ease-out)]\",\n);\n// overflow clip, not hidden: a hidden box is still a scroll container, so focusing or scrolling to a row while the\n// list unfolds scrolls the list inside its fold, and as the fold grows the browser clamps that scroll back, sliding\n// the rows under a held pointer (the press lands on two rows and its click on the list, choosing nothing)\nconst sub = cn(\n  \"m-0 flex min-h-0 list-none flex-col overflow-clip border-s-(length:--kl-k1) border-s-kl-seam p-0\",\n  \"[&>li]:border-t-(length:--kl-k1) [&>li]:border-t-kl-line\",\n);\n\n/** ROW ACTIONS: the item and its ⋯ key share one row on a seam; the band covers the item only */\nconst row = \"kl-cells min-w-0 [&>:first-child]:min-w-0 [&>:first-child]:flex-auto\";\n\n// one chevron that turns a quarter (the Accordion's and Collapsible's caret motion), not a path swap\nconst Caret = () => (\n  <svg\n    viewBox=\"0 0 16 16\"\n    width=\"14\"\n    height=\"14\"\n    fill=\"none\"\n    stroke=\"currentColor\"\n    strokeWidth=\"2\"\n    strokeLinecap=\"square\"\n    aria-hidden\n    className={caretGlyph}\n  >\n    <path d=\"m6 4 4 4-4 4\" />\n  </svg>\n);\n\n/**\n * A nested list's fold: it unfolds with the Accordion's timing (--kl-t-unfold, ease-out) and folds\n * with --kl-t-fold (ease-in), staying mounted while it folds. `onReady` fires once it is fully open, so the band\n * can hand off from the parent to the link inside. Open at first render means open with no motion.\n */\nfunction NavFold({ open, onReady, children }: { open: boolean; onReady: () => void; children: React.ReactNode }) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const [mounted, setMounted] = React.useState(open);\n  const [shown, setShown] = React.useState(open);\n  const ready = React.useRef(onReady);\n  ready.current = onReady;\n  const first = React.useRef(true);\n  React.useLayoutEffect(() => {\n    if (first.current) {\n      first.current = false;\n      if (open) ready.current(); // mounted open (first paint, or a rail widening with the list open): already there\n      return;\n    }\n    if (open) {\n      setMounted(true);\n      let t: ReturnType<typeof setTimeout> | undefined;\n      // two frames: the folded state must be painted before the open one, or the rows transition never runs\n      let r = requestAnimationFrame(() => {\n        r = requestAnimationFrame(() => {\n          setShown(true);\n          t = setTimeout(() => ready.current(), tokenMs(ref.current, \"--kl-t-unfold\", 160));\n        });\n      });\n      return () => {\n        cancelAnimationFrame(r);\n        clearTimeout(t);\n      };\n    }\n    setShown(false);\n    const t = setTimeout(() => setMounted(false), tokenMs(ref.current, \"--kl-t-fold\", 120));\n    return () => clearTimeout(t);\n  }, [open]);\n  if (!mounted) return null;\n  return (\n    <div\n      ref={ref}\n      data-slot=\"nav-fold\"\n      className={fold}\n      data-kl-clip=\"\"\n      data-open={shown ? \"\" : undefined}\n      inert={!open}\n    >\n      {children}\n    </div>\n  );\n}\n\ntype NavProps = {\n  /** Flat list of items. Or pass `groups`. */\n  items?: NavItem[];\n  /** Labelled sections, separated by a heavy seam; one cobalt band still runs across all of them. */\n  groups?: NavGroup[];\n  value: string;\n  onValueChange?: (v: string) => void;\n  label: string;\n  header?: React.ReactNode;\n  /** Pinned to the bottom of the nav (who is signed in, a workspace, settings). */\n  footer?: React.ReactNode;\n  layout?: \"control\" | \"cell\";\n  /** responsive: vertical while the nav is narrower than 300px, a row when wider (container query). */\n  orientation?: \"vertical\" | \"horizontal\" | \"responsive\";\n  /**\n   * What renders an `href` item. Default `\"a\"` (a full page load). Pass your router's link, such as\n   * Next's `Link`, so items navigate client-side; it receives the anchor's props (href, className, onClick, aria-*).\n   */\n  linkComponent?: React.ElementType;\n  className?: string;\n};\n\n/**\n * App location. A region frame holding a list of items; the current item is under a cobalt band that\n * STRETCHES between items, vertically in a sidebar and horizontally once the layout turns it into a row\n * (axis follows the list's flex direction). Items are links (`href`) or buttons; current = aria-current.\n *\n * - `groups` label sections (a list per group, named by its label); the band crosses between them.\n * - `icon` puts a glyph in a key cell at the item's start; in AppShell's rail only the key cells show and\n *   the label flies out beside the item on hover and on keyboard focus (it stays the accessible name).\n * - `footer` sits at the bottom of the column.\n */\nfunction Nav({\n  items,\n  groups,\n  value,\n  onValueChange,\n  label,\n  header: headerContent,\n  footer,\n  layout = \"control\",\n  orientation = \"vertical\",\n  linkComponent: Link = \"a\",\n  className,\n}: NavProps) {\n  const ref = React.useRef<HTMLUListElement>(null);\n  const rail = React.useContext(NavRailContext);\n  const expand = React.useContext(NavExpandContext);\n  const id = React.useId();\n  const all = groups ? groups.flatMap((g) => g.items) : (items ?? []);\n  const icons = all.some((i) => i.icon);\n  // nested lists: which are open (a list holding the current link opens when it becomes current)\n  const [open, setOpen] = React.useState<Set<string>>(() => {\n    const o = new Set<string>();\n    const walk = (l: NavItem[]) =>\n      l.forEach((it) => {\n        if (it.items && (it.defaultOpen ?? has(it, value))) o.add(it.value);\n        if (it.items) walk(it.items);\n      });\n    walk(all);\n    return o;\n  });\n  // lists fully unfolded: until then the band rests on the parent, then hands off to the link inside\n  const [ready, setReady] = React.useState<Set<string>>(() => new Set(open));\n  const markReady = (v: string) => setReady((r) => (r.has(v) ? r : new Set([...r, v])));\n  // a disclosure changes the layout, not the selection: the band is placed, never sent travelling\n  const snap = React.useRef(false);\n  const [seen, setSeen] = React.useState(value);\n  if (seen !== value) {\n    setSeen(value);\n    const add: string[] = [];\n    const walk = (l: NavItem[]) =>\n      l.forEach((it) => {\n        if (it.items && has(it, value) && !open.has(it.value)) add.push(it.value);\n        if (it.items) walk(it.items);\n      });\n    walk(all);\n    if (add.length) setOpen(new Set([...open, ...add]));\n  }\n  const isOpen = (it: NavItem) => !rail && open.has(it.value);\n  const toggle = (it: NavItem) => {\n    snap.current = true;\n    if (rail) {\n      setOpen(new Set([...open, it.value]));\n      expand?.();\n      return;\n    }\n    const n = new Set(open);\n    if (n.has(it.value)) {\n      n.delete(it.value);\n      // the selection folds into its parent at the press: its rows stop being items now, not when the fold ends\n      setReady((r) => {\n        const x = new Set(r);\n        x.delete(it.value);\n        return x;\n      });\n    } else n.add(it.value);\n    setOpen(n);\n  };\n  const bandOnParent = (it: NavItem) => !!it.items && (!isOpen(it) || !ready.has(it.value)) && has(it, value);\n  // the band's target, in the order the items are drawn: the current link, or the closed item holding it\n  const shown: NavItem[] = [];\n  const walkShown = (l: NavItem[]) =>\n    l.forEach((it) => {\n      shown.push(it);\n      if (it.items && isOpen(it)) walkShown(it.items);\n    });\n  walkShown(all);\n  const target = shown.findIndex((it) => (it.items ? bandOnParent(it) : it.value === value));\n  useStretch(ref, target, { axis: \"auto\", instant: snap.current });\n  React.useLayoutEffect(() => {\n    snap.current = false;\n  });\n  useScrollEdges(ref);\n\n  // what the nav's state decides for every item: icons, rail, depth\n  const itemClass = (depth: number) =>\n    cn(\n      item,\n      icons && \"gap-0\",\n      icons && depth === 0 && \"ps-0\",\n      depth > 0 && \"min-h-10 ps-3 text-[13px]\",\n      rail && \"relative min-h-12 justify-center p-0\",\n    );\n  const iconEl = (it: NavItem) =>\n    it.icon ? (\n      <span data-slot=\"nav-item-icon\" className={cn(icon, rail ? iconRail : iconCovered)} aria-hidden>\n        {it.icon}\n      </span>\n    ) : null;\n  const labelEl = (it: NavItem) => (\n    <span data-slot=\"nav-item-label\" className={cn(\"min-w-0 flex-auto\", rail && srOnly)}>\n      {it.label}\n    </span>\n  );\n  const countEl = (it: NavItem) =>\n    it.count != null ? (\n      <span data-slot=\"nav-item-count\" className={cn(count, rail && countRail)}>\n        {it.count}\n      </span>\n    ) : null;\n\n  // `live` false: a row inside a folding list, still drawn but no longer an item of the band\n  const itemEl = (it: NavItem, depth = 0, live = true): React.ReactNode => {\n    const current = it.value === value;\n    if (it.items) return parent(it, depth, live);\n    const inner = (\n      <>\n        {iconEl(it)}\n        {labelEl(it)}\n        {countEl(it)}\n      </>\n    );\n    const el = it.href ? (\n      <Link\n        data-slot=\"nav-item\"\n        data-kl-item={live ? \"\" : undefined}\n        href={it.href}\n        aria-current={current ? \"page\" : undefined}\n        aria-disabled={it.disabled || undefined}\n        className={itemClass(depth)}\n        onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n          if (it.disabled) return e.preventDefault();\n          if (onValueChange) {\n            e.preventDefault();\n            onValueChange(it.value);\n          }\n        }}\n      >\n        {inner}\n      </Link>\n    ) : (\n      <button\n        type=\"button\"\n        data-slot=\"nav-item\"\n        data-kl-item={live ? \"\" : undefined}\n        aria-current={current ? \"page\" : undefined}\n        disabled={it.disabled}\n        className={itemClass(depth)}\n        onClick={() => onValueChange?.(it.value)}\n      >\n        {inner}\n      </button>\n    );\n    return rowEl(it, el, depth);\n  };\n  // on a rail the label is visually hidden (still the accessible name) and shown beside the key cell\n  const tip = (it: NavItem, el: React.ReactElement) =>\n    rail && it.icon ? (\n      <Tooltip\n        side=\"inline-end\"\n        delay={150}\n        content={\n          <>\n            {it.label}\n            {it.count != null ? (\n              <span data-slot=\"nav-tooltip-count\" className=\"kl-code ms-2 font-normal\">\n                {it.count}\n              </span>\n            ) : null}\n          </>\n        }\n      >\n        {el}\n      </Tooltip>\n    ) : (\n      el\n    );\n  const rowEl = (it: NavItem, el: React.ReactElement, depth: number, subList?: React.ReactNode) => (\n    // a top-level row of an ungrouped list is a block (a group's rows and a nested list's are list items)\n    <li key={it.value} data-kl-depth={depth || undefined} className={depth === 0 && !groups ? \"block\" : undefined}>\n      {it.action && !rail ? (\n        <div data-slot=\"nav-row\" className={row}>\n          {tip(it, el)}\n          <span data-slot=\"nav-item-action\" className=\"flex flex-none border-s-kl-seam\">\n            {it.action}\n          </span>\n        </div>\n      ) : (\n        tip(it, el)\n      )}\n      {subList}\n    </li>\n  );\n  const parent = (it: NavItem, depth: number, live: boolean) => {\n    const o = isOpen(it);\n    const subId = `${id}-s-${it.value}`;\n    const el = (\n      <button\n        type=\"button\"\n        data-slot=\"nav-item\"\n        data-kl-item={live ? \"\" : undefined}\n        data-kl-holds={bandOnParent(it) ? \"\" : undefined}\n        aria-expanded={rail ? undefined : o}\n        aria-controls={o ? subId : undefined}\n        disabled={it.disabled}\n        className={itemClass(depth)}\n        onClick={() => toggle(it)}\n      >\n        {iconEl(it)}\n        {labelEl(it)}\n        {countEl(it)}\n        {rail ? null : (\n          <span data-slot=\"nav-item-caret\" className={caret} aria-hidden>\n            <Caret />\n          </span>\n        )}\n      </button>\n    );\n    return rowEl(\n      it,\n      el,\n      depth,\n      rail ? null : (\n        <NavFold open={o} onReady={() => markReady(it.value)}>\n          <ul\n            id={subId}\n            data-slot=\"nav-sub\"\n            className={cn(sub, depth > 0 ? \"ms-3\" : icons ? \"ms-[calc(44px_-_var(--kl-k1))]\" : \"ms-3.5\")}\n            aria-label={typeof it.label === \"string\" ? it.label : undefined}\n          >\n            {it.items!.map((c) => itemEl(c, depth + 1, live && o))}\n          </ul>\n        </NavFold>\n      ),\n    );\n  };\n  const tree = (\n    <nav\n      aria-label={label}\n      data-slot=\"nav\"\n      data-kl-layout={layout}\n      data-orientation={orientation}\n      data-kl-rail={rail ? \"\" : undefined}\n      data-kl-icons={icons ? \"\" : undefined}\n      className={cn(\"kl-frame flex min-w-0 flex-col\", orientation === \"responsive\" && \"@container/kl-nav\", className)}\n    >\n      {headerContent ? (\n        <div data-slot=\"nav-header\" className={cn(header, orientation === \"horizontal\" && \"hidden\")}>\n          {headerContent}\n        </div>\n      ) : null}\n      <ul\n        ref={ref}\n        data-slot=\"nav-list\"\n        data-kl-stretch=\"\"\n        className={cn(list, orientation === \"horizontal\" && listRow)}\n      >\n        {/* the band is a presentational list item: a <ul> may only contain <li> (it was a <span>) */}\n        <li data-kl-band=\"\" role=\"presentation\" className={cn(band, icons && !rail && bandInk)} aria-hidden hidden />\n        {groups\n          ? groups.map((g, gi) => (\n              <li key={g.label} data-slot=\"nav-group\" className={group}>\n                <span\n                  id={`${id}-g${gi}`}\n                  data-slot=\"nav-group-label\"\n                  className={cn(groupLabel, icons && \"ps-14\", rail && srOnly)}\n                >\n                  {g.label}\n                </span>\n                <ul\n                  aria-labelledby={`${id}-g${gi}`}\n                  data-slot=\"nav-group-list\"\n                  className={cn(groupList, rail && \"[&>li:first-child]:border-t-0\")}\n                >\n                  {g.items.map((it) => itemEl(it))}\n                </ul>\n              </li>\n            ))\n          : all.map((it) => itemEl(it))}\n      </ul>\n      {footer ? (\n        <div data-slot=\"nav-footer\" className=\"mt-auto border-t-(length:--kl-k3) border-t-kl-line\">\n          {footer}\n        </div>\n      ) : null}\n    </nav>\n  );\n  // one provider for the rail: once a label is showing, scanning down the rail shows the next one at once (no delay,\n  // no fade: the tooltip's data-instant), as a toolbar of hints should behave (each item re-waited 150ms)\n  return rail ? <TooltipProvider delay={150}>{tree}</TooltipProvider> : tree;\n}\n\ntype NavPartState = Record<string, never>;\nconst PART_STATE: NavPartState = {};\n\ntype NavIdentityProps = Omit<PartProps<\"span\", NavPartState>, \"title\" | \"children\"> & {\n  mark: React.ReactNode;\n  title: React.ReactNode;\n  meta?: React.ReactNode;\n};\n\n/**\n * A header or footer identity for a sidebar Nav: a square mark cell, then a title and a meta line (a site\n * code, a role). On a rail only the mark shows; the title and meta stay in the accessibility tree.\n */\nfunction NavIdentity({ mark, title, meta, render, className, style, ...props }: NavIdentityProps): React.ReactElement {\n  const rail = React.useContext(NavRailContext);\n  const own = {\n    \"data-slot\": \"nav-identity\",\n    className: resolveClassName(\"flex min-h-[52px] min-w-0 items-stretch\", className)(PART_STATE),\n    style: resolveStyle(undefined, style)(PART_STATE),\n    children: (\n      <>\n        <span\n          data-slot=\"nav-identity-mark\"\n          aria-hidden\n          className={cn(\n            \"grid w-11 flex-none place-items-center text-[14px] font-(--kl-weight-display)\",\n            // in a footer the mark is a key cell on a seam; in a header it clears the frame's cut\n            rail\n              ? \"m-0 w-full border-0\"\n              : \"in-data-[slot=nav-footer]:border-e-(length:--kl-k1) in-data-[slot=nav-footer]:border-e-kl-seam in-data-[slot=nav-header]:ms-[var(--kl-c-room,0px)]\",\n          )}\n        >\n          {mark}\n        </span>\n        <span\n          data-slot=\"nav-identity-title\"\n          className={cn(\"grid min-w-0 flex-auto content-center gap-0.5 py-2 ps-3 pe-3.5\", rail && srOnly)}\n        >\n          <span data-slot=\"nav-identity-name\" className=\"truncate text-[14px]/[1.2] font-(--kl-weight-display)\">\n            {title}\n          </span>\n          {meta != null ? (\n            <span\n              data-slot=\"nav-identity-meta\"\n              className=\"kl-code truncate text-[11px]/[1.2] text-kl-ink-2 in-data-[slot=nav-header]:text-inherit in-data-[slot=nav-header]:opacity-72\"\n            >\n              {meta}\n            </span>\n          ) : null}\n        </span>\n      </>\n    ),\n  };\n  return useRender({ defaultTagName: \"span\", render, state: PART_STATE, props: mergeProps<\"span\">(props, own) });\n}\n\nconst action = cn(\n  \"grid min-h-10 w-10 cursor-pointer place-items-center border-0 bg-transparent p-0 text-kl-ink-2\",\n  \"hover:not-data-popup-open:bg-kl-tint hover:not-data-popup-open:text-kl-ink\",\n  \"data-popup-open:bg-kl-inverse data-popup-open:text-kl-on-inverse\",\n  \"forced-colors:data-popup-open:bg-[Highlight] forced-colors:data-popup-open:text-[HighlightText] forced-colors:data-popup-open:forced-color-adjust-none\",\n  focusRing,\n);\n\ntype NavActionProps = PartProps<\"button\", NavPartState> & {\n  /** Names the cell (\"More for Saved view: Late arrivals\"). */\n  label: string;\n};\n\n/**\n * The ⋯ key cell of a row action: pass it as a MenuTrigger's render, so the item's commands open in\n * a Menu docked to the row. `label` names it (\"More for Saved view: Late arrivals\").\n */\nfunction NavAction({ label, render, className, style, children, ...props }: NavActionProps): React.ReactElement {\n  const own = {\n    type: \"button\" as const,\n    \"aria-label\": label,\n    \"data-slot\": \"nav-action\",\n    className: resolveClassName(action, className)(PART_STATE),\n    style: resolveStyle(undefined, style)(PART_STATE),\n    children: children ?? (\n      <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"currentColor\" aria-hidden>\n        <rect x=\"2\" y=\"7\" width=\"2.5\" height=\"2.5\" />\n        <rect x=\"6.75\" y=\"7\" width=\"2.5\" height=\"2.5\" />\n        <rect x=\"11.5\" y=\"7\" width=\"2.5\" height=\"2.5\" />\n      </svg>\n    ),\n  };\n  return useRender({ defaultTagName: \"button\", render, state: PART_STATE, props: mergeProps<\"button\">(props, own) });\n}\n\nexport {\n  Nav,\n  NavIdentity,\n  NavAction,\n  NavRailContext,\n  NavExpandContext,\n  type NavItem,\n  type NavGroup,\n  type NavProps,\n  type NavIdentityProps,\n  type NavActionProps,\n};\n",
      "type": "registry:ui",
      "target": "components/keyline/ui/nav.tsx"
    }
  ],
  "type": "registry:ui"
}