{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "data-grid-lookup",
  "title": "Data Grid Lookup",
  "author": "gridcn",
  "description": "Async lookup cell type for the gridcn data grid: remote options with search as you type, a value and label stored together, abortable requests, and bounded untrusted answers.",
  "dependencies": [],
  "registryDependencies": [
    "@gridcn/data-grid",
    "@gridcn/use-debounce",
    "button",
    "input",
    "popover"
  ],
  "files": [
    {
      "path": "registry/default/blocks/data-grid-lookup/data-grid-lookup.ts",
      "content": "import type { LookupOptions, LookupValue } from \"./lookup-model\";\r\n\r\n// Relative on purpose: the shadcn CLI rewrites import paths, never augmentation module names.\r\ndeclare module \"../data-grid/types\" {\r\n  interface GridCellTypes {\r\n    // `any` lets a column pass `LookupOptions<Row>`\r\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n    lookup: { value: LookupValue; options: LookupOptions<any> };\r\n  }\r\n}\r\n\r\n/** Public entry point — the only module consumers/docs should import from. */\r\nexport { lookupCellType } from \"./lookup-cell-type\";\r\nexport type { LookupFetchRequest, LookupLabels, LookupOption, LookupOptions, LookupResolveRequest, LookupValue } from \"./lookup-model\";\r\n",
      "type": "registry:component",
      "target": "components/data-grid-lookup/data-grid-lookup.ts"
    },
    {
      "path": "registry/default/blocks/data-grid-lookup/lookup-cell-type.tsx",
      "content": "\"use client\";\n\nimport { CellSpan, type CellRenderProps, type CellType } from \"@/registry/default/components/data-grid/data-grid\";\nimport { createFilterMatcher } from \"@/registry/default/components/data-grid/data-grid\";\nimport type { FilterSpec } from \"@/registry/default/components/data-grid/data-grid\";\nimport { SET_FILTER_OPERATORS, TEXT_FILTER_OPERATORS, sortCollator, UnparseableTextError, useOptionalDataGridStoreApi } from \"@/registry/default/components/data-grid/data-grid-sdk\";\nimport { LookupEditor } from \"./lookup-editor\";\nimport { adoptOwner, isUnresolved, MAX_LOOKUP_TEXT, readLookup, MAX_KNOWN_LABELS, recallOption, rememberOption, sanitizeOptions, type LookupOptions, type LookupValue } from \"./lookup-model\";\n\nfunction LookupCell({ value, options, columnId }: CellRenderProps<unknown, LookupValue, LookupOptions>) {\n  const grid = useOptionalDataGridStoreApi();\n  if (grid && options?.fetchOptions) adoptOwner(grid, columnId, options.fetchOptions, options.labelCacheKey);\n  const option = readLookup(value);\n  if (!option) return <CellSpan text=\"\" />;\n  // a shown label pastes back to its key, also from outside the grid\n  if (options?.fetchOptions && !isUnresolved(value)) rememberOption(options.fetchOptions, option);\n  if (isUnresolved(value)) {\n    return (\n      <span data-unresolved=\"\" className=\"block w-full truncate text-muted-foreground\">\n        <bdi>{option.label}</bdi>\n      </span>\n    );\n  }\n  return <CellSpan text={option.label} />;\n}\n\nconst matchers = new WeakMap<FilterSpec, (text: string) => boolean>();\n\nfunction matcherFor(filter: FilterSpec): (text: string) => boolean {\n  let matcher = matchers.get(filter);\n  if (!matcher) {\n    matcher = createFilterMatcher(filter);\n    matchers.set(filter, matcher);\n  }\n  return matcher;\n}\n\nfunction labelOf(value: unknown): string {\n  return readLookup(value)?.label ?? \"\";\n}\n\n/**\n * `lookup`: the stored value is `{ value, label }` (the key and the text the user sees). `toText`\n * copies the label; `fromText` resolves a pasted label or key against the options the editor\n * listed, a cell showed, or `toText` wrote (copy, export, print, fill source, autosize, filter value list), else follows `unresolvedPaste`. Sort, quick search, and the text filter operators\n * read the label; `isAnyOf` and `isNoneOf` match the stored key or the label, so a server that lists keys and a client list of labels both work.\n */\nexport const lookupCellType: CellType<unknown, LookupValue, LookupOptions> = {\n  Cell: LookupCell,\n  Editor: LookupEditor,\n  toText: (value, options) => {\n    const option = readLookup(value);\n    if (!option) return \"\";\n    if (options?.fetchOptions && !isUnresolved(value)) rememberOption(options.fetchOptions, option);\n    return option.label;\n  },\n  fromText: (text, options) => {\n    const trimmed = text.trim().slice(0, MAX_LOOKUP_TEXT);\n    if (trimmed === \"\") return null;\n    const hit = options?.fetchOptions ? recallOption(options.fetchOptions, trimmed) : undefined;\n    if (hit) return hit;\n    if (options?.unresolvedPaste === \"keep\") return { value: trimmed, label: \"\" };\n    if (options?.unresolvedPaste === \"clear\") return null;\n    throw new UnparseableTextError(\"no known option\");\n  },\n  resolveTexts: (texts, options, { signal }) => {\n    const { fetchOptions, resolveLabels } = options ?? {};\n    if (!fetchOptions || !resolveLabels) return;\n    const unknown = new Set<string>();\n    for (const text of texts) {\n      const label = text.trim().slice(0, MAX_LOOKUP_TEXT);\n      if (label !== \"\" && !recallOption(fetchOptions, label) && unknown.size < MAX_KNOWN_LABELS) unknown.add(label);\n    }\n    if (unknown.size === 0) return;\n    return resolveLabels({ labels: [...unknown], signal }).then((answer) => {\n      for (const option of sanitizeOptions(answer, unknown.size, MAX_KNOWN_LABELS)) rememberOption(fetchOptions, option);\n    });\n  },\n  clearValue: () => null,\n  isEmpty: (value) => readLookup(value) === null,\n  compare: (a, b) => sortCollator().compare(labelOf(a), labelOf(b)),\n  toSearchText: (value) => labelOf(value),\n  filter: {\n    operators: [...TEXT_FILTER_OPERATORS, ...SET_FILTER_OPERATORS],\n    match: (value, filter) => {\n      const matches = matcherFor(filter);\n      const label = labelOf(value);\n      if (filter.operator === \"isAnyOf\") return matches(label) || matches(readLookup(value)?.value ?? \"\");\n      if (filter.operator === \"isNoneOf\") return matches(label) && matches(readLookup(value)?.value ?? \"\");\n      return matches(label);\n    },\n  },\n  align: \"start\",\n};\n",
      "type": "registry:component",
      "target": "components/data-grid-lookup/lookup-cell-type.tsx"
    },
    {
      "path": "registry/default/blocks/data-grid-lookup/lookup-editor.tsx",
      "content": "\"use client\";\r\n\r\nimport { useEffect, useId, useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\r\nimport { cn } from \"@/lib/utils\";\r\nimport { Input } from \"@/components/ui/input\";\r\nimport { Button } from \"@/components/ui/button\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\r\nimport { useDebouncedInput } from \"@/registry/default/components/gridcn/use-debounce\";\r\nimport { useCommitGuard, type CellEditorProps } from \"@/registry/default/components/data-grid/data-grid\";\r\nimport { columnLabelText, deepMergeLabels, isComposingKey, useDataGridInputDebounce, useDataGridStoreApi } from \"@/registry/default/components/data-grid/data-grid-sdk\";\r\nimport {\r\n  adoptOwner,\r\n  DEFAULT_LABELS,\r\n  MAX_LOOKUP_TEXT,\r\n  readLookup,\r\n  rememberOption,\r\n  sanitizeOptions,\r\n  type LookupOption,\r\n  type LookupOptions,\r\n  type LookupValue,\r\n} from \"./lookup-model\";\r\n\r\ntype Fetched = { status: \"idle\" | \"loading\" | \"ready\" | \"error\"; options: readonly LookupOption[] };\r\n\r\n/** Opens on edit start. Typing searches `fetchOptions` after a pause; arrow keys move, Enter or a click picks, Escape cancels. */\r\nexport function LookupEditor(props: CellEditorProps<unknown, LookupValue, LookupOptions>) {\r\n  const { value, options, onChange, commit, cancel, column, pending, rejectionCount, initialText, row, rowId } = props;\r\n  const labels = deepMergeLabels(DEFAULT_LABELS, options?.labels);\r\n  const minQueryLength = Math.max(0, options?.minQueryLength ?? 0);\r\n  const providerDelay = useDataGridInputDebounce();\r\n  const delayMs = options?.debounceMs ?? providerDelay;\r\n  const listId = useId();\r\n  const inputRef = useRef<HTMLInputElement>(null);\r\n  const committed = useCommitGuard();\r\n  const current = readLookup(value);\r\n\r\n  const lastRejectionCount = useRef(rejectionCount ?? 0);\r\n  useEffect(() => {\r\n    if ((rejectionCount ?? 0) !== lastRejectionCount.current) committed.reset();\r\n    lastRejectionCount.current = rejectionCount ?? 0;\r\n  }, [rejectionCount, committed]);\r\n\r\n  const [query, setQuery] = useState((initialText ?? \"\").slice(0, MAX_LOOKUP_TEXT));\r\n  const input = useDebouncedInput(query, setQuery, { delayMs });\r\n  const [fetched, setFetched] = useState<Fetched>({ status: \"idle\", options: [] });\r\n  const [active, setActive] = useState(0);\r\n  const [attempt, setAttempt] = useState(0);\r\n  const latest = useRef(options);\r\n  const target = useRef({ row, rowId, columnId: column.id });\r\n  const grid = useDataGridStoreApi();\r\n  useLayoutEffect(() => {\r\n    if (options?.fetchOptions) adoptOwner(grid, column.id, options.fetchOptions);\r\n    latest.current = options;\r\n    target.current = { row, rowId, columnId: column.id };\r\n  });\r\n\r\n  useEffect(() => {\r\n    const el = inputRef.current;\r\n    if (!el) return;\r\n    el.focus({ preventScroll: true });\r\n    const end = el.value.length;\r\n    el.setSelectionRange(end, end);\r\n  }, []);\r\n\r\n  useEffect(() => {\r\n    const fetchOptions = latest.current?.fetchOptions;\r\n    if (!fetchOptions || query.length < minQueryLength) {\r\n      setFetched({ status: \"idle\", options: [] });\r\n      return;\r\n    }\r\n    const controller = new AbortController();\r\n    setFetched((prev) => ({ status: \"loading\", options: prev.options }));\r\n    new Promise<unknown>((resolve) => resolve(fetchOptions({ query, signal: controller.signal, ...target.current })))\r\n      .then((answer) => {\r\n        if (controller.signal.aborted) return;\r\n        const list = sanitizeOptions(answer, latest.current?.maxResults);\r\n        for (const option of list) rememberOption(latest.current?.fetchOptions ?? fetchOptions, option);\r\n        setFetched({ status: \"ready\", options: list });\r\n        setActive(0);\r\n      })\r\n      .catch(() => {\r\n        if (controller.signal.aborted) return;\r\n        setFetched((prev) => ({ status: \"error\", options: prev.options }));\r\n      });\r\n    return () => controller.abort();\r\n  }, [query, minQueryLength, attempt]);\r\n\r\n  const pick = (option: LookupOption) => {\r\n    if (!committed.tryCommit()) return;\r\n    onChange(option);\r\n    commit({ dx: 0, dy: 0 });\r\n  };\r\n\r\n  const typingPending = input.inputValue !== query;\r\n  const list = fetched.options;\r\n  const activeOption = list[Math.min(active, list.length - 1)];\r\n  const optionId = (index: number) => `${listId}-${index}`;\r\n\r\n  const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\r\n    if (isComposingKey(event)) return;\r\n    if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\r\n      event.preventDefault();\r\n      if (list.length === 0) return;\r\n      const step = event.key === \"ArrowDown\" ? 1 : -1;\r\n      setActive((index) => (Math.min(index, list.length - 1) + step + list.length) % list.length);\r\n      return;\r\n    }\r\n    if (event.key === \"Enter\") {\r\n      event.preventDefault();\r\n      if (typingPending) input.flush();\r\n      else if (activeOption && fetched.status === \"ready\") pick(activeOption);\r\n      return;\r\n    }\r\n    if (event.key === \"Escape\") {\r\n      if (committed.tryCommit()) cancel();\r\n      return;\r\n    }\r\n    input.inputProps.onKeyDown(event);\r\n  };\r\n\r\n  let statusText = \"\";\r\n  if (query.length < minQueryLength) statusText = labels.typeMore(minQueryLength - query.length);\r\n  else if (fetched.status === \"loading\") statusText = labels.searching;\r\n  else if (fetched.status === \"error\") statusText = labels.error;\r\n  else if (fetched.status === \"ready\" && list.length === 0) statusText = labels.noResults;\r\n\r\n  return (\r\n    <Popover\r\n      open\r\n      onOpenChange={(next, details) => {\r\n        if (!next && details.reason === \"escape-key\" && isComposingKey(details.event)) {\r\n          details.cancel();\r\n          return;\r\n        }\r\n        if (!next && committed.tryCommit()) cancel();\r\n      }}\r\n    >\r\n      <PopoverTrigger nativeButton={false} render={<span className=\"block w-full min-w-0 truncate\" />}>\r\n        {current?.label ?? \"\"}\r\n      </PopoverTrigger>\r\n      <PopoverContent data-grid-cell-editor=\"\" align=\"start\" className=\"w-64 gap-0 p-0 data-open:animate-none data-closed:animate-none\">\r\n        <div className=\"p-1.5\">\r\n          <Input\r\n            ref={inputRef}\r\n            {...input.inputProps}\r\n            onKeyDown={onKeyDown}\r\n            role=\"combobox\"\r\n            aria-expanded={list.length > 0}\r\n            aria-autocomplete=\"list\"\r\n            aria-controls={listId}\r\n            aria-activedescendant={activeOption ? optionId(Math.min(active, list.length - 1)) : undefined}\r\n            aria-label={columnLabelText(column)}\r\n            aria-busy={pending || fetched.status === \"loading\" || undefined}\r\n            readOnly={pending}\r\n            maxLength={MAX_LOOKUP_TEXT}\r\n            dir=\"auto\"\r\n            placeholder={current?.label}\r\n            className=\"h-8 w-full border-none bg-transparent px-2 shadow-none outline-none focus-visible:ring-0\"\r\n          />\r\n        </div>\r\n        <ul id={listId} role=\"listbox\" aria-label={columnLabelText(column)} className={cn(\"max-h-60 overflow-auto p-1\", list.length === 0 && \"hidden\")}>\r\n          {list.map((option, index) => (\r\n            <li\r\n              key={option.value}\r\n              id={optionId(index)}\r\n              role=\"option\"\r\n              aria-selected={index === Math.min(active, list.length - 1)}\r\n              data-active={index === Math.min(active, list.length - 1) ? \"\" : undefined}\r\n              data-current={option.value === current?.value ? \"\" : undefined}\r\n              className=\"cursor-default truncate rounded-md px-2 py-1.5 text-sm data-active:bg-accent data-active:text-accent-foreground data-current:font-medium\"\r\n              onPointerDown={(event) => event.preventDefault()}\r\n              onPointerEnter={() => setActive(index)}\r\n              onClick={() => pick(option)}\r\n            >\r\n              <bdi>{option.label}</bdi>\r\n            </li>\r\n          ))}\r\n        </ul>\r\n        <div role=\"status\" aria-live=\"polite\" className={cn(\"flex items-center justify-between gap-2 px-3 py-2 text-xs text-muted-foreground\", statusText === \"\" && \"sr-only\")}>\r\n          <span>{statusText}</span>\r\n          {fetched.status === \"error\" && (\r\n            <Button type=\"button\" size=\"xs\" variant=\"ghost\" onClick={() => setAttempt((n) => n + 1)}>\r\n              {labels.retry}\r\n            </Button>\r\n          )}\r\n        </div>\r\n      </PopoverContent>\r\n    </Popover>\r\n  );\r\n}\r\n",
      "type": "registry:component",
      "target": "components/data-grid-lookup/lookup-editor.tsx"
    },
    {
      "path": "registry/default/blocks/data-grid-lookup/lookup-model.ts",
      "content": "import { toSafeText } from \"@/registry/default/components/data-grid/data-grid-sdk\";\n\n/** One choice a server offers: `value` is the stored key, `label` the text the user sees. */\nexport type LookupOption = { value: string; label: string };\n\n/** A lookup cell stores the picked option, or `null` when empty. A bare string is a key without a label (unresolved). */\nexport type LookupValue = LookupOption | string | null;\n\n/** What `fetchOptions` receives. `TData` is the row type of the grid. */\nexport type LookupFetchRequest<TData = unknown> = {\n  /** The text the user typed; `\"\"` asks for the default list. */\n  query: string;\n  /** Aborted when the user types again, closes the editor, or the cell unmounts. */\n  signal: AbortSignal;\n  /** The row being edited, so a dependent lookup can narrow its options. The request does not repeat when a push changes the row during the edit. */\n  row: TData;\n  /** The id of the row being edited. */\n  rowId: string;\n  /** The id of the lookup column. */\n  columnId: string;\n};\n\n/** What `resolveLabels` receives. */\nexport type LookupResolveRequest = {\n  /** The distinct pasted texts that no remembered option matches, trimmed. */\n  labels: readonly string[];\n  /** Aborted when a newer paste supersedes this one. */\n  signal: AbortSignal;\n};\n\n/** Text the editor shows; each field falls back to English. */\nexport type LookupLabels = {\n  searching: string;\n  noResults: string;\n  error: string;\n  retry: string;\n  /** Receives the missing character count. */\n  typeMore: (missing: number) => string;\n};\n\n/** Column `options` of the `lookup` cell type. `TData` is the row type of the grid; it types `request.row`. */\nexport type LookupOptions<TData = unknown> = {\n  /** Resolves the options that match `query`. The labels it lists, and the labels the cells show, paste back to their keys. */\n  fetchOptions: (request: LookupFetchRequest<TData>) => Promise<readonly LookupOption[]>;\n  /**\n   * Resolves pasted labels that no option listed, cell showed, or copy wrote yet: answer the options that match `labels` (exact label, case-insensitive; or key).\n   * A paste calls it once with the distinct unknown labels, held as the `resolveTexts` gate. Labels it does not answer follow `unresolvedPaste`.\n   */\n  resolveLabels?: (request: LookupResolveRequest) => Promise<readonly LookupOption[]>;\n  /** Wait after the last keystroke before a request starts. Default: the grid's `inputDebounceMs`. */\n  debounceMs?: number;\n  /** Fewest typed characters that start a request. Default `0`: the default list loads on open. */\n  minQueryLength?: number;\n  /** Most options shown; extra options are dropped. Default `50`, at most `200`. */\n  maxResults?: number;\n  /** A pasted or imported text that matches no known option: `\"reject\"` keeps the cell value and reports the text to `onValidationError`, `\"clear\"` empties the cell, `\"keep\"` stores the trimmed text as `{ value: text, label: \"\" }`, shown as unresolved. Default `\"reject\"`. */\n  unresolvedPaste?: \"reject\" | \"clear\" | \"keep\";\n  /** Remembered labels drop when this value changes (a new tenant, a renamed record set). Default: labels stay for the life of the grid. */\n  labelCacheKey?: string | number;\n  labels?: Partial<LookupLabels>;\n};\n\nexport const DEFAULT_MAX_RESULTS = 50;\nexport const MAX_RESULTS_LIMIT = 200;\nexport const MAX_LOOKUP_TEXT = 256;\nexport const MAX_KNOWN_LABELS = 5000;\n\nexport const DEFAULT_LABELS: LookupLabels = {\n  searching: \"Searching…\",\n  noResults: \"No results\",\n  error: \"Could not load options\",\n  retry: \"Retry\",\n  typeMore: (missing) => `Type ${missing} more character${missing === 1 ? \"\" : \"s\"}`,\n};\n\nfunction clip(text: string): string {\n  return text.length > MAX_LOOKUP_TEXT ? text.slice(0, MAX_LOOKUP_TEXT) : text;\n}\n\n/** Reads any stored value as an option: a bare key stays visible as its own label (an unresolved value). */\nexport function readLookup(value: unknown): LookupOption | null {\n  if (value == null) return null;\n  if (typeof value === \"object\" && value !== null) {\n    const raw = value as { value?: unknown; label?: unknown };\n    if (typeof raw.value === \"string\" && raw.value !== \"\" && typeof raw.label === \"string\" && raw.label !== \"\" && raw.value.length <= MAX_LOOKUP_TEXT && raw.label.length <= MAX_LOOKUP_TEXT) {\n      return value as LookupOption;\n    }\n  }\n  if (typeof value === \"string\" || (typeof value === \"number\" && Number.isFinite(value))) {\n    const text = clip(toSafeText(value));\n    return text === \"\" ? null : { value: text, label: text };\n  }\n  if (typeof value !== \"object\") return null;\n  const raw = value as { value?: unknown; label?: unknown };\n  if (typeof raw.value !== \"string\" && !(typeof raw.value === \"number\" && Number.isFinite(raw.value))) return null;\n  const key = clip(toSafeText(raw.value));\n  if (key === \"\") return null;\n  const label = typeof raw.label === \"string\" && raw.label !== \"\" ? clip(raw.label) : key;\n  return { value: key, label };\n}\n\n/** True when the stored value carries no label of its own. */\nexport function isUnresolved(value: unknown): boolean {\n  if (readLookup(value) === null) return false;\n  if (typeof value !== \"object\" || value === null) return true;\n  const label = (value as { label?: unknown }).label;\n  return typeof label !== \"string\" || label === \"\";\n}\n\n/** Keeps at most `limit` well-formed options from an untrusted answer; the first of a repeated value wins. */\nexport function sanitizeOptions(answer: unknown, limit: number | undefined, ceiling = MAX_RESULTS_LIMIT): LookupOption[] {\n  if (!Array.isArray(answer)) throw new TypeError(\"fetchOptions must resolve an array of { value, label }\");\n  const max = Math.min(Math.max(1, Math.floor(limit ?? DEFAULT_MAX_RESULTS) || DEFAULT_MAX_RESULTS), ceiling);\n  const seen = new Set<string>();\n  const out: LookupOption[] = [];\n  for (const item of answer) {\n    if (out.length >= max) break;\n    if (typeof item !== \"object\" || item === null) continue;\n    const { value, label } = item as { value?: unknown; label?: unknown };\n    if ((typeof value !== \"string\" && !(typeof value === \"number\" && Number.isFinite(value))) || typeof label !== \"string\") continue;\n    const key = clip(toSafeText(value));\n    if (key === \"\") continue;\n    if (seen.has(key)) continue;\n    seen.add(key);\n    out.push({ value: key, label: label === \"\" ? key : clip(label) });\n  }\n  return out;\n}\n\ntype KnownOptions = { byLabel: Map<string, LookupOption | null>; byValue: Map<string, LookupOption> };\nconst known = new WeakMap<object, KnownOptions>();\n\nfunction dropOldest<T>(map: Map<string, T>): void {\n  if (map.size > MAX_KNOWN_LABELS) map.delete(map.keys().next().value as string);\n}\n\n/** Remembers an option so a copied label pastes back to its key. Bounded: the oldest entry leaves first. */\nexport function rememberOption(owner: object, option: LookupOption): void {\n  let index = known.get(owner);\n  if (!index) {\n    index = { byLabel: new Map(), byValue: new Map() };\n    known.set(owner, index);\n  }\n  const labelKey = option.label.toLowerCase();\n  // runs on every render of a shown cell, the scroll hot path\n  if (index.byValue.get(option.value)?.label === option.label && index.byLabel.has(labelKey)) return;\n  const same = index.byLabel.get(labelKey);\n  index.byLabel.delete(labelKey);\n  // a label shared by two keys is ambiguous and resolves to nothing\n  index.byLabel.set(labelKey, same === null || (same && same.value !== option.value) ? null : option);\n  index.byValue.delete(option.value);\n  index.byValue.set(option.value, option);\n  dropOldest(index.byLabel);\n  dropOldest(index.byValue);\n}\n\ntype ColumnOwner = { owner: object; cacheKey: unknown };\nconst columnOwners = new WeakMap<object, Map<string, ColumnOwner>>();\n\n/** Carries the options remembered for a column of one grid over to its next `fetchOptions` identity, so an inline function keeps its labels. A changed `cacheKey` drops them instead. */\nexport function adoptOwner(grid: object, columnId: string, owner: object, cacheKey?: unknown): void {\n  let owners = columnOwners.get(grid);\n  if (!owners) {\n    owners = new Map();\n    columnOwners.set(grid, owners);\n  }\n  const previous = owners.get(columnId);\n  if (previous?.owner === owner && Object.is(previous.cacheKey, cacheKey)) return;\n  owners.set(columnId, { owner, cacheKey });\n  if (previous && !Object.is(previous.cacheKey, cacheKey)) {\n    known.delete(previous.owner);\n    known.delete(owner);\n    return;\n  }\n  const inherited = previous && known.get(previous.owner);\n  if (!inherited) return;\n  const own = known.get(owner);\n  if (!own) known.set(owner, inherited);\n  else if (own !== inherited) for (const option of inherited.byValue.values()) if (!own.byValue.has(option.value)) rememberOption(owner, option);\n}\n\n/** The remembered option whose label (case-insensitive) or key equals `text`. */\nexport function recallOption(owner: object, text: string): LookupOption | undefined {\n  const index = known.get(owner);\n  const byLabel = index?.byLabel.get(text.toLowerCase());\n  return byLabel === null ? index?.byValue.get(text) : (byLabel ?? index?.byValue.get(text));\n}\n",
      "type": "registry:component",
      "target": "components/data-grid-lookup/lookup-model.ts"
    }
  ],
  "categories": [
    "data"
  ],
  "type": "registry:block"
}
