{"version":3,"file":"chunk-Listbox.mjs","names":["ListboxPrimitive","ScrollArea.Root","ScrollArea.Viewport","_Fragment","Icon.Icon"],"sources":["../../src/components/Listbox/virtual.tsx","../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type RefCallback, useCallback, useLayoutEffect, useRef, useState } from 'react';\n\nimport { log } from '@dxos/log';\n\n/**\n * How a long list mounts its rows (AUDIT §6 group B). `fixed` windows them: only the rows in view (plus an overscan) are\n * mounted, spacer rows stand in for the rest, and every row must be one height (a dev warning names a list whose rows\n * differ). `measured` windows rows of any height, measuring each as it mounts and estimating the rest from those\n * measured so far. `variable` mounts every row with `content-visibility: auto`, so rows of any height skip layout off\n * screen but every row still renders.\n */\nexport type VirtualMode = 'fixed' | 'measured' | 'variable';\n\n/** Whether a mode mounts only the rows in view, so the caller renders the spans and spacers. */\nexport const isWindowed = (mode: VirtualMode | undefined): mode is 'fixed' | 'measured' =>\n  mode === 'fixed' || mode === 'measured';\n\nexport type UseVirtualRowsOptions = {\n  mode?: VirtualMode;\n  /** The number of rows the list holds. */\n  count: number;\n  /** Rows mounted beyond each edge of the view. */\n  overscan?: number;\n  /** A row kept mounted outside the window (e.g. the roving tabstop), so DOM focus is never unmounted. */\n  pinned?: number;\n  /** Selects the rows `fixed` takes its pitch from (default: the list's non-spacer children); e.g. to skip animating rows. */\n  measure?: string;\n  /**\n   * Selects exactly one element per mounted row, in row order (default: the list's non-spacer children); `measured`\n   * observes each one's size and maps it onto the mounted spans to know which row it is.\n   */\n  rows?: string;\n};\n\n/** A run of mounted rows, `[first, last]` inclusive. */\nexport type VirtualSpan = { first: number; last: number };\n\nexport type VirtualRows = {\n  /** Binds the list element; it scrolls itself or is scrolled by its nearest scrolling ancestor. */\n  listRef: RefCallback<HTMLElement>;\n  /** The mounted range, inclusive; the whole list unless windowed. */\n  first: number;\n  last: number;\n  /** Heights of the spacers before and after the mounted rows. */\n  before: number;\n  after: number;\n  /** The mounted runs in row order: the window, plus the `pinned` row's own run when it is outside it. */\n  spans: VirtualSpan[];\n  /** The height a spacer takes in place of the unmounted rows `[from, to)` (between spans). */\n  spacer: (from: number, to: number) => number;\n  /** Scrolls the row at `index` into view, mounting it; for zag's `scrollToIndexFn`. */\n  scrollToIndex: (index: number) => void;\n};\n\nconst DEFAULT_OVERSCAN = 8;\n/** A row height to window with before the first row is measured. */\nconst NOMINAL_ROW = 32;\n\nconst SPACER_ATTRIBUTE = 'data-virtual-spacer';\n\nconst scrollerOf = (list: HTMLElement): HTMLElement => {\n  for (let element: HTMLElement | null = list; element; element = element.parentElement) {\n    const { overflowY } = getComputedStyle(element);\n    if (overflowY === 'auto' || overflowY === 'scroll') {\n      return element;\n    }\n  }\n  return list.ownerDocument.scrollingElement instanceof HTMLElement ? list.ownerDocument.scrollingElement : list;\n};\n\n/** The list's top within its scroller's content, so a list below other content windows from where it starts. */\nconst offsetIn = (list: HTMLElement, scroller: HTMLElement): number =>\n  scroller === list ? 0 : list.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;\n\nconst mountedRows = (list: HTMLElement, selector: string | undefined): HTMLElement[] =>\n  selector\n    ? Array.from(list.querySelectorAll<HTMLElement>(selector))\n    : Array.from(list.children).filter(\n        (child): child is HTMLElement => child instanceof HTMLElement && !child.hasAttribute(SPACER_ATTRIBUTE),\n      );\n\nconst spansOf = (first: number, last: number, pinned: number | undefined): VirtualSpan[] => {\n  if (last < first) {\n    return [];\n  }\n  if (pinned === undefined || (pinned >= first && pinned <= last)) {\n    return [{ first, last }];\n  }\n  return pinned < first\n    ? [\n        { first: pinned, last: pinned },\n        { first, last },\n      ]\n    : [\n        { first, last },\n        { first: pinned, last: pinned },\n      ];\n};\n\n/**\n * Row heights for `measured`: each mounted row's own, and the mean of those for a row not yet mounted. A `fixed` list\n * has one height for every row, the first mounted row's.\n */\nclass RowHeights {\n  #heights = new Map<number, number>();\n  #total = 0;\n  readonly measured: boolean;\n  fixed = NOMINAL_ROW;\n  gap = 0;\n\n  constructor(measured: boolean) {\n    this.measured = measured;\n  }\n\n  /** Records a row's height; returns whether it changed. */\n  set(index: number, height: number): boolean {\n    const previous = this.#heights.get(index);\n    if (previous !== undefined && Math.abs(previous - height) <= 0.5) {\n      return false;\n    }\n    this.#total += height - (previous ?? 0);\n    this.#heights.set(index, height);\n    return true;\n  }\n\n  /** Drops the rows past the end of a list that shrank, so their heights no longer weigh on the estimate. */\n  truncate(count: number): void {\n    for (const [index, height] of this.#heights) {\n      if (index >= count) {\n        this.#heights.delete(index);\n        this.#total -= height;\n      }\n    }\n  }\n\n  get(index: number): number {\n    if (!this.measured) {\n      return this.fixed;\n    }\n    return this.#heights.get(index) ?? (this.#heights.size > 0 ? this.#total / this.#heights.size : NOMINAL_ROW);\n  }\n\n  /** The extent of rows `[from, to)` with the gaps between them. */\n  extent(from: number, to: number): number {\n    if (to <= from) {\n      return 0;\n    }\n    if (!this.measured) {\n      return (to - from) * (this.fixed + this.gap) - this.gap;\n    }\n    let extent = (to - from - 1) * this.gap;\n    for (let index = from; index < to; index++) {\n      extent += this.get(index);\n    }\n    return extent;\n  }\n}\n\n/**\n * Windowing shared by the Next lists (Listbox, OrderedList, Tree). With `fixed` or `measured` it tracks the scroll\n * position of the list's scroller and returns the spans of rows to mount and the spacer heights around them; the caller\n * renders `VirtualSpacer`s and the spans. With `variable` or no mode every row is mounted; `variable` lists set\n * `data-virtual='variable'` so the theme defers off-screen rows.\n */\nexport const useVirtualRows = ({\n  mode,\n  count,\n  overscan = DEFAULT_OVERSCAN,\n  pinned,\n  measure,\n  rows: rowsSelector,\n}: UseVirtualRowsOptions): VirtualRows => {\n  const windowed = isWindowed(mode);\n  const measured = mode === 'measured';\n  const listRef = useRef<HTMLElement | null>(null);\n  const [list, setList] = useState<HTMLElement | null>(null);\n  const heightsRef = useRef<RowHeights | null>(null);\n  if (heightsRef.current?.measured !== measured) {\n    heightsRef.current = new RowHeights(measured);\n  }\n  const heights = heightsRef.current;\n  const warnedRef = useRef(false);\n  const [range, setRange] = useState({ first: 0, last: 2 * overscan });\n  const spansRef = useRef<VirtualSpan[]>([]);\n  // Found once per list: walking the ancestors' computed styles on every scroll event costs a style read each time.\n  const scrollerRef = useRef<HTMLElement | null>(null);\n  const resizeRef = useRef<ResizeObserver | null>(null);\n  const observedRef = useRef(new Map<Element, { index: number; height?: number }>());\n\n  const bind = useCallback<RefCallback<HTMLElement>>((element) => {\n    listRef.current = element;\n    setList(element);\n  }, []);\n\n  const update = useCallback(() => {\n    const element = listRef.current;\n    const scroller = scrollerRef.current;\n    if (!element || !scroller) {\n      return;\n    }\n    const start = Math.max(0, scroller.scrollTop - offsetIn(element, scroller));\n    const end = start + scroller.clientHeight;\n    let first: number;\n    let last: number;\n    if (measured) {\n      // Walked rather than divided, since every row may differ; the first row whose bottom passes the view's top,\n      // through the last row whose top is above its bottom.\n      first = count;\n      last = count - 1;\n      let top = 0;\n      for (let index = 0; index < count; index++) {\n        const bottom = top + heights.get(index);\n        if (first === count && bottom > start) {\n          first = index;\n        }\n        if (top >= end) {\n          last = index - 1;\n          break;\n        }\n        top = bottom + heights.gap;\n      }\n      first = Math.max(0, Math.min(first, count - 1) - overscan);\n      last = Math.min(count - 1, last + overscan);\n    } else {\n      const pitch = heights.fixed + heights.gap;\n      first = Math.max(0, Math.floor(start / pitch) - overscan);\n      last = Math.min(count - 1, Math.ceil(end / pitch) + overscan);\n    }\n    setRange((range) => (range.first === first && range.last === last ? range : { first, last }));\n  }, [count, overscan, measured, heights]);\n\n  // `measured` rows report their own heights through a ResizeObserver, which reads them after layout rather than\n  // forcing a layout on every render. Created before the effect below, so a list's first rows are observed in the\n  // commit that mounts them.\n  useLayoutEffect(() => {\n    if (!measured || !list) {\n      return;\n    }\n    const observed = observedRef.current;\n    const observer = new ResizeObserver((entries) => {\n      let changed = false;\n      for (const entry of entries) {\n        const row = observed.get(entry.target);\n        const height = entry.borderBoxSize[0]?.blockSize;\n        if (row && height !== undefined) {\n          row.height = height;\n          changed = heights.set(row.index, height) || changed;\n        }\n      }\n      if (changed) {\n        update();\n      }\n    });\n    resizeRef.current = observer;\n    return () => {\n      observer.disconnect();\n      observed.clear();\n      resizeRef.current = null;\n    };\n  }, [measured, list, heights, update]);\n\n  // Maps each mounted row element to its index, which reads no layout; a row that moved keeps its element and size, so\n  // no resize reports it at its new index and its last height is carried over here.\n  useLayoutEffect(() => {\n    const observer = resizeRef.current;\n    if (!measured || !list || !observer) {\n      return;\n    }\n    heights.truncate(count);\n    const rows = mountedRows(list, rowsSelector);\n    const indices = spansRef.current.flatMap(({ first, last }) =>\n      Array.from({ length: last - first + 1 }, (_, offset) => first + offset),\n    );\n    // A count that disagrees means the selector is not one element per row, and no height could be attributed.\n    if (rows.length !== indices.length) {\n      return;\n    }\n    const observed = observedRef.current;\n    const mounted = new Set<Element>(rows);\n    for (const element of observed.keys()) {\n      if (!mounted.has(element)) {\n        observer.unobserve(element);\n        observed.delete(element);\n      }\n    }\n    rows.forEach((element, position) => {\n      const index = indices[position];\n      const row = observed.get(element);\n      if (!row) {\n        observed.set(element, { index });\n        observer.observe(element);\n      } else if (row.index !== index) {\n        row.index = index;\n        if (row.height !== undefined) {\n          heights.set(index, row.height);\n        }\n      }\n    });\n  });\n\n  // A `fixed` list's rows are all the first mounted row's height.\n  useLayoutEffect(() => {\n    if (!windowed || measured || !list) {\n      return;\n    }\n    const rows = mountedRows(list, measure);\n    const height = rows[0]?.getBoundingClientRect().height;\n    if (height) {\n      const changed = Math.abs(height - heights.fixed) > 0.5;\n      heights.fixed = height;\n      // The window was computed with the nominal pitch until now.\n      if (changed) {\n        update();\n      }\n      if (process.env.NODE_ENV !== 'production' && !warnedRef.current) {\n        const other = rows.find((row) => Math.abs(row.getBoundingClientRect().height - height) > 0.5);\n        if (other) {\n          warnedRef.current = true;\n          log.warn(\"virtual='fixed' rows differ in height; use virtual='measured'\", {\n            expected: height,\n            actual: other.getBoundingClientRect().height,\n          });\n        }\n      }\n    }\n  });\n\n  useLayoutEffect(() => {\n    if (!windowed || !list) {\n      return;\n    }\n    const scroller = scrollerOf(list);\n    scrollerRef.current = scroller;\n    heights.gap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;\n    update();\n    const observer = new ResizeObserver(update);\n    observer.observe(scroller);\n    scroller.addEventListener('scroll', update, { passive: true });\n    return () => {\n      observer.disconnect();\n      scroller.removeEventListener('scroll', update);\n      scrollerRef.current = null;\n    };\n  }, [windowed, list, heights, update]);\n\n  const scrollToIndex = useCallback(\n    (index: number) => {\n      const element = listRef.current;\n      const scroller = scrollerRef.current;\n      if (!windowed || !element || !scroller) {\n        return;\n      }\n      const top = offsetIn(element, scroller) + heights.extent(0, index) + (index > 0 ? heights.gap : 0);\n      const height = heights.get(index);\n      if (top < scroller.scrollTop) {\n        scroller.scrollTop = top;\n      } else if (top + height > scroller.scrollTop + scroller.clientHeight) {\n        scroller.scrollTop = top + height - scroller.clientHeight;\n      }\n      update();\n    },\n    [windowed, heights, update],\n  );\n\n  if (!windowed) {\n    const spans = spansOf(0, count - 1, undefined);\n    spansRef.current = spans;\n    return {\n      listRef: bind,\n      first: 0,\n      last: count - 1,\n      before: 0,\n      after: 0,\n      spans,\n      spacer: () => 0,\n      scrollToIndex,\n    };\n  }\n\n  const first = Math.min(range.first, Math.max(0, count - 1));\n  const last = Math.min(range.last, count - 1);\n  // A spacer takes the place of its rows and the gaps between them; the grid adds the gap beside it.\n  const spacer = (from: number, to: number) => heights.extent(from, to);\n  const spans = spansOf(first, last, pinned !== undefined && pinned < count ? pinned : undefined);\n  spansRef.current = spans;\n  return {\n    listRef: bind,\n    first,\n    last,\n    before: spacer(0, spans[0]?.first ?? 0),\n    after: spacer((spans.at(-1)?.last ?? -1) + 1, count),\n    spans,\n    spacer,\n    scrollToIndex,\n  };\n};\n\nexport type VirtualSpacerProps = {\n  height: number;\n};\n\n/** Stands in for the unmounted rows of a windowed list; renders nothing when no rows are hidden on its side. */\nexport const VirtualSpacer = ({ height }: VirtualSpacerProps) =>\n  height > 0 ? <div role='none' aria-hidden='true' data-virtual-spacer='' style={{ height }} /> : null;\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { createListCollection } from '@ark-ui/react/collection';\nimport { Listbox as ListboxPrimitive, type UseListboxContext, useListboxContext } from '@ark-ui/react/listbox';\nimport React, {\n  Children,\n  type ComponentPropsWithoutRef,\n  type ReactNode,\n  type RefObject,\n  createContext,\n  forwardRef,\n  useContext,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from 'react';\n\nimport { useComposedRefs } from '@dxos/react-hooks';\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { recipes } from '../../recipes.ts';\nimport { type Size } from '../../sizes.ts';\nimport { composable, composableProps } from '../../util/slots.ts';\nimport { type ContainerProps, containerAttributes } from '../Container/Container.tsx';\nimport { Empty } from '../Empty/Empty.tsx';\nimport * as Icon from '../Icon/Icon.tsx';\nimport * as ScrollArea from '../ScrollArea/ScrollArea.tsx';\nimport { RowContext, handleGridKeyDown, isFromControl, useRowTabStops } from './grid.ts';\nimport { type VirtualMode, VirtualSpacer, isWindowed, useVirtualRows } from './virtual.tsx';\n\ntype ListboxOption = {\n  value: string;\n  label: string;\n  disabled?: boolean;\n  /** Leading icon of the default row. */\n  icon?: string;\n  /** Second line of the default row. */\n  description?: string;\n};\n\n/** `none` keeps zag's focus, keyboard and typeahead with no selection (AUDIT §6 group B: every list runs the machine). */\ntype ListboxSelectionMode = 'single' | 'multiple' | 'extended' | 'none';\n\ntype RootContextValue = {\n  items: readonly ListboxOption[];\n  selectionMode: ListboxSelectionMode;\n  columns?: string;\n  virtual?: VirtualMode;\n  /** Set by Content when it windows its rows; zag calls it to bring a highlighted row it has not mounted into view. */\n  scrollToIndexRef: RefObject<((index: number) => void) | null>;\n};\n\nconst RootContext = createContext<RootContextValue | undefined>(undefined);\n\nconst useRootContext = (part: string) => {\n  const context = useContext(RootContext);\n  if (!context) {\n    throw new Error(`Listbox.${part} must be inside Listbox.Root`);\n  }\n  return context;\n};\n\n//\n// Root\n//\n\ntype ListboxRootProps = ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'onSelect'>> & {\n  items: readonly ListboxOption[];\n  /**\n   * `single` by default; `multiple` toggles each item; `extended` selects one on a click and adds with Cmd/Ctrl or a\n   * Shift range, as a desktop list does; `none` selects nothing but keeps navigation and typeahead.\n   */\n  selectionMode?: ListboxSelectionMode;\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (value: string[]) => void;\n  /** The row keyboard or pointer navigation moved to (null when none). */\n  onHighlightChange?: (value: string | null) => void;\n  /** Clicking the selected item of a single-selection list clears it. */\n  deselectable?: boolean;\n  disabled?: boolean;\n  /** Arrow keys wrap from the last item to the first and back. */\n  loopFocus?: boolean;\n  /**\n   * Custom tracks for every row, declared once: rows become subgrids of these columns and place their children in\n   * order. Without it rows lay out by part (a leading cell, the text over its description, trailing parts).\n   */\n  columns?: string;\n  /** Long lists: `fixed` windows equal-height rows, `measured` windows rows of any height, `variable` defers off-screen rows (`content-visibility`). */\n  virtual?: VirtualMode;\n  size?: Size;\n};\n\n/**\n * Ark listbox: single, multiple or no selection, with keyboard navigation, typeahead and `aria-selected` from zag. A\n * flex column that caps itself at its parent's height, so a long list scrolls in its Content.\n */\nconst ListboxRoot = forwardRef<HTMLDivElement, ListboxRootProps>(\n  (\n    {\n      classNames,\n      items,\n      selectionMode = 'single',\n      value,\n      defaultValue,\n      onValueChange,\n      onHighlightChange,\n      deselectable,\n      disabled,\n      loopFocus,\n      columns,\n      virtual,\n      size,\n      children,\n      ...props\n    },\n    forwardedRef,\n  ) => {\n    const collection = useMemo(\n      () =>\n        createListCollection<ListboxOption>({\n          items: [...items],\n          itemToValue: (item) => item.value,\n          itemToString: (item) => item.label,\n          isItemDisabled: (item) => item.disabled ?? false,\n        }),\n      [items],\n    );\n    const scrollToIndexRef = useRef<((index: number) => void) | null>(null);\n    const context = useMemo<RootContextValue>(\n      () => ({ items, selectionMode, columns, virtual, scrollToIndexRef }),\n      [items, selectionMode, columns, virtual],\n    );\n\n    return (\n      <RootContext.Provider value={context}>\n        <ListboxPrimitive.Root<ListboxOption>\n          {...props}\n          collection={collection}\n          selectionMode={selectionMode}\n          value={value}\n          defaultValue={defaultValue}\n          onValueChange={onValueChange && (({ value }) => onValueChange(value))}\n          onHighlightChange={onHighlightChange && (({ highlightedValue }) => onHighlightChange(highlightedValue))}\n          deselectable={deselectable}\n          disabled={disabled}\n          loopFocus={loopFocus}\n          scrollToIndexFn={isWindowed(virtual) ? ({ index }) => scrollToIndexRef.current?.(index) : undefined}\n          data-size={size}\n          className={mx(recipes.listbox(), classNames)}\n          ref={forwardedRef}\n        >\n          {children}\n        </ListboxPrimitive.Root>\n      </RootContext.Provider>\n    );\n  },\n);\n\nListboxRoot.displayName = 'Listbox.Root';\n\n//\n// Label\n//\n\ntype ListboxLabelProps = ThemedClassName<ListboxPrimitive.LabelProps>;\n\n/** Names the list (`aria-labelledby` on its Content). */\nconst ListboxLabel = forwardRef<HTMLLabelElement, ListboxLabelProps>(({ classNames, ...props }, forwardedRef) => (\n  <ListboxPrimitive.Label {...props} className={mx(recipes.label(), classNames)} ref={forwardedRef} />\n));\n\nListboxLabel.displayName = 'Listbox.Label';\n\n//\n// Viewport\n//\n\n/** True under a `Listbox.Viewport`: the list scrolls itself rather than in its host. */\nconst ViewportContext = createContext(false);\n\ntype ListboxViewportProps = ThemedClassName<Pick<ScrollArea.RootProps, 'mode' | 'width' | 'native'>> & {\n  /** The `Listbox.Content`, which becomes the scrolling element. */\n  children: ReactNode;\n};\n\n/**\n * A thin overlay ScrollArea (decision 5) that grows to fill the Root, for a list that owns its scrolling (a picker, a\n * fixed-height panel). Its `Content` is the scrolling element, so the thumb sits in the Content's end gutter. Omit it\n * inside a host that already scrolls, which would otherwise trap wheel and trackpad gestures in a nested scroller.\n */\nconst ListboxViewport = forwardRef<HTMLDivElement, ListboxViewportProps>(\n  ({ classNames, mode, width, native, children }, forwardedRef) => (\n    <ViewportContext.Provider value={true}>\n      <ScrollArea.Root\n        mode={mode}\n        width={width}\n        native={native}\n        classNames={[recipes.listboxScroll(), classNames]}\n        ref={forwardedRef}\n      >\n        <ScrollArea.Viewport asChild>{children}</ScrollArea.Viewport>\n      </ScrollArea.Root>\n    </ViewportContext.Provider>\n  ),\n);\n\nListboxViewport.displayName = 'Listbox.Viewport';\n\n//\n// Content\n//\n\ntype ListboxContentProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> &\n  Pick<ContainerProps, 'gutter' | 'gap' | 'padBlock'>;\n\n/**\n * The listbox element: zag's content props with the grid keyboard in front of them, a Container's attributes so a\n * `Viewport`'s slot merges onto it, and the Root's `virtual` windowing over its direct children (the rows). Under a\n * `Viewport` it is the scrolling element (`inset` gutter by default); otherwise its host scrolls and the rows inherit the\n * host's rails (`inherit`). A windowed (`virtual`) list measures its scroller, so it needs a `Viewport`.\n */\nconst ListboxContent = composable<HTMLDivElement, ContainerProps & Omit<ComponentPropsWithoutRef<'div'>, 'className'>>(\n  ({ gutter, gap, padBlock, onKeyDown, onFocus, onBlur, children, ...props }, forwardedRef) => {\n    const api = useListboxContext();\n    const { columns, virtual, scrollToIndexRef } = useRootContext('Content');\n    const inViewport = useContext(ViewportContext);\n    const [element, setElement] = useState<HTMLDivElement | null>(null);\n    const rows = Children.toArray(children);\n    const windowing = useVirtualRows({ mode: virtual, count: rows.length });\n    scrollToIndexRef.current = isWindowed(virtual) ? windowing.scrollToIndex : null;\n    const ref = useComposedRefs<HTMLDivElement>(forwardedRef, setElement, windowing.listRef);\n    useRowTabStops(element);\n\n    const { style, ...attributes } = containerAttributes({\n      gutter: gutter ?? (inViewport ? 'inset' : 'inherit'),\n      gap,\n      columns,\n      padBlock,\n    });\n    const {\n      className,\n      style: ownStyle,\n      ...rest\n    } = composableProps(props, {\n      classNames: [recipes.container(), recipes.listboxContent()],\n    });\n    const contentProps = api.getContentProps();\n    return (\n      <div\n        {...contentProps}\n        {...rest}\n        {...attributes}\n        data-scope='listbox'\n        data-part='content'\n        data-virtual={virtual}\n        style={{ ...contentProps.style, ...style, ...ownStyle }}\n        className={className}\n        onFocus={(event) => {\n          contentProps.onFocus?.(event);\n          onFocus?.(event);\n        }}\n        onBlur={(event) => {\n          contentProps.onBlur?.(event);\n          onBlur?.(event);\n        }}\n        onKeyDown={(event) => {\n          onKeyDown?.(event);\n          if (event.defaultPrevented && event.target === event.currentTarget) {\n            return;\n          }\n          if (handleGridKeyDown(event)) {\n            return;\n          }\n          contentProps.onKeyDown?.(event);\n          if (!inViewport && !isWindowed(virtual)) {\n            // zag scrolls the highlighted row into view only when the listbox itself overflows; here the host scrolls.\n            const content = event.currentTarget;\n            requestAnimationFrame(() =>\n              content.querySelector('[data-highlighted]')?.scrollIntoView({ block: 'nearest' }),\n            );\n          }\n        }}\n        ref={ref}\n      >\n        {isWindowed(virtual) ? (\n          <>\n            <VirtualSpacer height={windowing.before} />\n            {rows.slice(windowing.first, windowing.last + 1)}\n            <VirtualSpacer height={windowing.after} />\n          </>\n        ) : (\n          children\n        )}\n      </div>\n    );\n  },\n);\n\nListboxContent.displayName = 'Listbox.Content';\n\n/** True inside a `Listbox.Viewport`, for parts that act on the scrolling element (e.g. drag auto-scroll). */\nconst useListboxViewport = (): boolean => useContext(ViewportContext);\n\n//\n// Empty\n//\n\ntype ListboxEmptyProps = ComponentPropsWithoutRef<typeof Empty>;\n\n/** `Empty`, rendered only while the Root has no items. */\nconst ListboxEmpty = forwardRef<HTMLDivElement, ListboxEmptyProps>((props, forwardedRef) => {\n  const { items } = useRootContext('Empty');\n  return items.length === 0 ? <Empty {...props} ref={forwardedRef} /> : null;\n});\n\nListboxEmpty.displayName = 'Listbox.Empty';\n\n//\n// Item\n//\n\n// The option an Item renders, so its parts default to the option's icon, label and description.\nconst ItemContext = createContext<ListboxOption | undefined>(undefined);\n\nconst useItem = (part: string) => {\n  const item = useContext(ItemContext);\n  if (!item) {\n    throw new Error(`Listbox.${part} must be inside Listbox.Item`);\n  }\n  return item;\n};\n\ntype ListboxItemProps = ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'children'>> & {\n  item: ListboxOption;\n  /** \"You are here\" (`aria-current`), distinct from selection. */\n  current?: boolean;\n  /** Pointer movement highlights the item, as the keyboard does. */\n  highlightOnHover?: boolean;\n  /** Replaces the whole row, composed from `ItemIcon`, `ItemText`, `ItemDescription`, `ItemIndicator` and controls. */\n  children?: ReactNode;\n};\n\n/**\n * A row (`option`) at least one block tall: without children, the option's icon, label and description; with them,\n * the caller's parts, which the theme places by part (leading cells, text over description, then trailing cells) or,\n * under Root `columns`, in order across the shared tracks. Pointer presses on a row control stay with the control: they\n * neither select the row nor take focus from the control.\n */\nconst ListboxItem = forwardRef<HTMLDivElement, ListboxItemProps>(\n  (\n    { classNames, item, current, highlightOnHover, children, style, onMouseDown, onClick, onFocus, ...props },\n    forwardedRef,\n  ) => {\n    const api = useListboxContext();\n    const { columns, selectionMode } = useRootContext('Item');\n    const textId = useId();\n    const row = useMemo(() => ({ textId }), [textId]);\n    // Under Root `columns` the row is a subgrid of the Content's tracks (theme); otherwise it has its own template.\n    const { style: columnsStyle, ...attributes } = containerAttributes(\n      columns ? {} : { columns: 'var(--dx-item-columns)' },\n    );\n    const itemProps = api.getItemProps({ item, highlightOnHover });\n    const content = children ?? (\n      <>\n        {item.icon && <ListboxItemIcon />}\n        <ListboxItemText />\n        {item.description != null && <ListboxItemDescription />}\n      </>\n    );\n\n    return (\n      <ItemContext.Provider value={item}>\n        <RowContext.Provider value={row}>\n          <div\n            {...itemProps}\n            {...props}\n            {...attributes}\n            aria-current={current ? 'true' : undefined}\n            data-scope='listbox'\n            data-part='item'\n            data-selectable={selectionMode === 'none' ? undefined : ''}\n            style={{ ...columnsStyle, ...style }}\n            className={mx(recipes.container(), recipes.row(), recipes.listboxItem(), classNames)}\n            onMouseDown={(event) => {\n              onMouseDown?.(event);\n              if (!isFromControl(event.currentTarget, event.target)) {\n                itemProps.onMouseDown?.(event);\n              }\n            }}\n            onClick={(event) => {\n              onClick?.(event);\n              if (!isFromControl(event.currentTarget, event.target)) {\n                itemProps.onClick?.(event);\n              }\n            }}\n            onFocus={(event) => {\n              onFocus?.(event);\n              // A row control took focus (a click or the grid keyboard): the row is the list's current row.\n              if (event.target !== event.currentTarget && api.highlightedValue !== item.value) {\n                api.highlightValue(item.value);\n              }\n            }}\n            ref={forwardedRef}\n          >\n            {content}\n          </div>\n        </RowContext.Provider>\n      </ItemContext.Provider>\n    );\n  },\n);\n\nListboxItem.displayName = 'Listbox.Item';\n\n//\n// ItemIcon\n//\n\ntype ListboxItemIconProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> &\n  Partial<Pick<Icon.IconProps, 'icon' | 'hue' | 'valence' | 'label'>>;\n\n/** A block-sized leading cell, so the labels of every row start at the same x; `hue` and the rest reach the Icon. */\nconst ListboxItemIcon = forwardRef<HTMLDivElement, ListboxItemIconProps>(\n  ({ classNames, icon, hue, valence, label, children, ...props }, forwardedRef) => {\n    const item = useItem('ItemIcon');\n    const glyph = icon ?? item.icon;\n    return (\n      <div\n        {...props}\n        data-scope='listbox'\n        data-part='item-icon'\n        className={mx(recipes.block(), recipes.listboxItemIcon(), classNames)}\n        ref={forwardedRef}\n      >\n        {children ?? (glyph && <Icon.Icon icon={glyph} hue={hue} valence={valence} label={label} />)}\n      </div>\n    );\n  },\n);\n\nListboxItemIcon.displayName = 'Listbox.ItemIcon';\n\n//\n// ItemText\n//\n\ntype ListboxItemTextProps = ThemedClassName<ComponentPropsWithoutRef<'p'>> & {\n  /** `muted` reads as secondary text, as Typography's tone. */\n  tone?: 'default' | 'muted';\n};\n\n/**\n * The row's label, truncated to one line; the option's `label` by default, which typeahead matches either way. Its id\n * names the row's controls (a Remove button, a disclosure caret).\n */\nconst ListboxItemText = forwardRef<HTMLParagraphElement, ListboxItemTextProps>(\n  ({ classNames, tone, children, ...props }, forwardedRef) => {\n    const item = useItem('ItemText');\n    const row = useContext(RowContext);\n    return (\n      <p\n        id={row?.textId}\n        {...props}\n        data-scope='listbox'\n        data-part='item-text'\n        data-truncate=''\n        data-tone={tone === 'muted' ? tone : undefined}\n        className={mx(recipes.typography(), recipes.listboxItemText(), classNames)}\n        ref={forwardedRef}\n      >\n        {children ?? item.label}\n      </p>\n    );\n  },\n);\n\nListboxItemText.displayName = 'Listbox.ItemText';\n\n//\n// ItemDescription\n//\n\ntype ListboxItemDescriptionProps = ThemedClassName<ComponentPropsWithoutRef<'p'>>;\n\n/** A second line under the text in `--color-fg-muted`; the option's `description` by default. */\nconst ListboxItemDescription = forwardRef<HTMLParagraphElement, ListboxItemDescriptionProps>(\n  ({ classNames, children, ...props }, forwardedRef) => {\n    const item = useItem('ItemDescription');\n    return (\n      <p\n        {...props}\n        data-scope='listbox'\n        data-part='item-description'\n        data-truncate=''\n        data-tone='muted'\n        className={mx(recipes.typography(), recipes.listboxItemDescription(), classNames)}\n        ref={forwardedRef}\n      >\n        {children ?? item.description}\n      </p>\n    );\n  },\n);\n\nListboxItemDescription.displayName = 'Listbox.ItemDescription';\n\n//\n// ItemIndicator\n//\n\ntype ListboxItemIndicatorProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\n/** Shown while its item is selected: a check by default, in an icon-sized cell. */\nconst ListboxItemIndicator = forwardRef<HTMLDivElement, ListboxItemIndicatorProps>(\n  ({ classNames, children, ...props }, forwardedRef) => {\n    const api = useListboxContext();\n    const item = useItem('ItemIndicator');\n    return (\n      <div\n        {...api.getItemIndicatorProps({ item })}\n        {...props}\n        className={mx(recipes.listboxItemIndicator(), classNames)}\n        ref={forwardedRef}\n      >\n        {children ?? <Icon.Icon icon='ph--check--regular' />}\n      </div>\n    );\n  },\n);\n\nListboxItemIndicator.displayName = 'Listbox.ItemIndicator';\n\n//\n// ItemGroup\n//\n\ntype ListboxItemGroupProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\n/**\n * A `group` of items named by the `ItemGroupLabel` inside it; an inheriting Container, so its rows keep the list's\n * rails. Order groups as the Root's `items` are ordered, or keyboard order and reading order diverge.\n */\nconst ListboxItemGroup = forwardRef<HTMLDivElement, ListboxItemGroupProps>(\n  ({ classNames, style, children, ...props }, forwardedRef) => {\n    const { style: containerStyle, ...attributes } = containerAttributes({});\n    return (\n      <ListboxPrimitive.ItemGroup\n        {...props}\n        {...attributes}\n        style={{ ...containerStyle, ...style }}\n        className={mx(recipes.container(), classNames)}\n        data-scope='listbox'\n        data-part='item-group'\n        ref={forwardedRef}\n      >\n        {children}\n      </ListboxPrimitive.ItemGroup>\n    );\n  },\n);\n\nListboxItemGroup.displayName = 'Listbox.ItemGroup';\n\n//\n// ItemGroupLabel\n//\n\ntype ListboxItemGroupLabelProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\n/** A small caption naming its group, like `Select.ItemGroupLabel`. */\nconst ListboxItemGroupLabel = forwardRef<HTMLDivElement, ListboxItemGroupLabelProps>(\n  ({ classNames, ...props }, forwardedRef) => (\n    <ListboxPrimitive.ItemGroupLabel\n      {...props}\n      data-scope='listbox'\n      data-part='item-group-label'\n      className={mx(recipes.popupGroupLabel(), classNames)}\n      ref={forwardedRef}\n    />\n  ),\n);\n\nListboxItemGroupLabel.displayName = 'Listbox.ItemGroupLabel';\n\n//\n// useContext\n//\n\ntype ListboxContext = UseListboxContext<ListboxOption>;\n\n/** Ark's listbox api (`value`, `selectedItems`, `setValue`, `clearValue`, …) for parts inside the Root, e.g. a detail pane. */\nconst useListboxRootContext = (): ListboxContext => useListboxContext();\nexport type {\n  ListboxContentProps as ContentProps,\n  ListboxContext as Context,\n  ListboxEmptyProps as EmptyProps,\n  ListboxItemDescriptionProps as ItemDescriptionProps,\n  ListboxItemGroupLabelProps as ItemGroupLabelProps,\n  ListboxItemGroupProps as ItemGroupProps,\n  ListboxItemIconProps as ItemIconProps,\n  ListboxItemIndicatorProps as ItemIndicatorProps,\n  ListboxItemProps as ItemProps,\n  ListboxItemTextProps as ItemTextProps,\n  ListboxLabelProps as LabelProps,\n  ListboxRootProps as RootProps,\n  ListboxViewportProps as ViewportProps,\n};\n\nexport {\n  ListboxContent as Content,\n  ListboxEmpty as Empty,\n  ListboxItem as Item,\n  ListboxItemDescription as ItemDescription,\n  ListboxItemGroup as ItemGroup,\n  ListboxItemGroupLabel as ItemGroupLabel,\n  ListboxItemIcon as ItemIcon,\n  ListboxItemIndicator as ItemIndicator,\n  ListboxItemText as ItemText,\n  ListboxLabel as Label,\n  ListboxRoot as Root,\n  ListboxViewport as Viewport,\n  useListboxRootContext as useContext,\n  useListboxViewport as useViewport,\n};\nexport type { ListboxOption as Option, ListboxSelectionMode as SelectionMode };\nexport { RowContext, type RowContextValue } from './grid.ts';\nexport * from './virtual.tsx';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAa,cAAc,SACzB,SAAS,WAAW,SAAS;AAuC/B,IAAM,mBAAmB;;AAEzB,IAAM,cAAc;AAEpB,IAAM,mBAAmB;AAEzB,IAAM,cAAc,SAAmC;CACrD,KAAK,IAAI,UAA8B,MAAM,SAAS,UAAU,QAAQ,eAAe;EACrF,MAAM,EAAE,cAAc,iBAAiB,OAAO;EAC9C,IAAI,cAAc,UAAU,cAAc,UACxC,OAAO;CAEX;CACA,OAAO,KAAK,cAAc,4BAA4B,cAAc,KAAK,cAAc,mBAAmB;AAC5G;;AAGA,IAAM,YAAY,MAAmB,aACnC,aAAa,OAAO,IAAI,KAAK,sBAAsB,CAAC,CAAC,MAAM,SAAS,sBAAsB,CAAC,CAAC,MAAM,SAAS;AAE7G,IAAM,eAAe,MAAmB,aACtC,WACI,MAAM,KAAK,KAAK,iBAA8B,QAAQ,CAAC,IACvD,MAAM,KAAK,KAAK,QAAQ,CAAC,CAAC,QACvB,UAAgC,iBAAiB,eAAe,CAAC,MAAM,aAAa,gBAAgB,CACvG;AAEN,IAAM,WAAW,OAAe,MAAc,WAA8C;CAC1F,IAAI,OAAO,OACT,OAAO,CAAC;C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