{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-modal-search",
  "type": "registry:block",
  "title": "Search modal",
  "description": "Search across the workspace in a modal: the query, result tabs, and results to move through by keyboard.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/modal.json",
    "https://wideset.co/r/tabs.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/modal-search/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/data.ts",
      "content": "import {\n  RiFileChartLine,\n  RiFileTextLine,\n  RiFolderOpenLine,\n  RiImageFill,\n  RiPlayFill,\n} from '@remixicon/react';\n\nimport type { SearchResult } from './search-result';\n\nexport const workspace = 'Lumen Studio';\n\n/** What the search field holds when the modal opens: 8 results, 6 files and 2 people. */\nexport const QUERY = 'Mar';\n\n/** Everything search looks through, most relevant first. */\nexport const index: SearchResult[] = [\n  {\n    id: 'marcus',\n    kind: 'person',\n    title: 'Marcus Bell',\n    detail: 'Active now',\n    initials: 'MB',\n    online: true,\n  },\n  {\n    id: 'marketing-invoices',\n    kind: 'file',\n    title: 'Marketing invoices',\n    detail: 'in Finance • Edited 3d ago',\n    icon: RiFolderOpenLine,\n  },\n  {\n    id: 'logo-mark',\n    kind: 'file',\n    title: 'logo_mark_final.jpg',\n    detail: 'in Brand • Edited 7d ago',\n    icon: RiImageFill,\n  },\n  {\n    id: 'sofia',\n    kind: 'person',\n    title: 'Sofia Marino',\n    detail: 'Active 2d ago',\n    initials: 'SM',\n    online: false,\n  },\n  {\n    id: 'kickoff',\n    kind: 'file',\n    title: 'kickoff_march.mp4',\n    detail: 'in Videos • Added 2d ago',\n    icon: RiPlayFill,\n  },\n  {\n    id: 'forecast',\n    kind: 'file',\n    title: 'March forecast',\n    detail: 'in Reports • Edited 5d ago',\n    icon: RiFileChartLine,\n  },\n  {\n    id: 'market-research',\n    kind: 'file',\n    title: 'Market research 2026',\n    detail: 'in Strategy • Edited 2w ago',\n    icon: RiFolderOpenLine,\n  },\n  {\n    id: 'remarks',\n    kind: 'file',\n    title: 'board_remarks.pdf',\n    detail: 'in Leadership • Added 3w ago',\n    icon: RiFileTextLine,\n  },\n  {\n    id: 'hana',\n    kind: 'person',\n    title: 'Hana Kobayashi',\n    detail: 'Active now',\n    initials: 'HK',\n    online: true,\n  },\n  {\n    id: 'pricing',\n    kind: 'file',\n    title: 'Pricing page copy',\n    detail: 'in Website • Edited 1d ago',\n    icon: RiFileTextLine,\n  },\n  {\n    id: 'priya',\n    kind: 'person',\n    title: 'Priya Raman',\n    detail: 'Active 1h ago',\n    initials: 'PR',\n    online: true,\n  },\n  {\n    id: 'roadmap',\n    kind: 'file',\n    title: 'Q4 roadmap',\n    detail: 'in Strategy • Edited 4d ago',\n    icon: RiFolderOpenLine,\n  },\n  {\n    id: 'onboarding',\n    kind: 'file',\n    title: 'onboarding_tour.mp4',\n    detail: 'in Videos • Added 1w ago',\n    icon: RiPlayFill,\n  },\n  {\n    id: 'jonas',\n    kind: 'person',\n    title: 'Jonas Lindqvist',\n    detail: 'Active 5d ago',\n    initials: 'JL',\n    online: false,\n  },\n];\n"
    },
    {
      "path": "src/blocks/modal-search/highlight.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/highlight.tsx",
      "content": "'use client';\n\n// TODO(custom): the matched part of a result, marked; Wideset has no text highlight and no token for Figma's gold fill.\n\n/**\n * The first place `query` occurs in `text`, marked as Figma marks a search match: a fill the\n * height of the line (hence `inline-block`). Figma's fill (Non-semantic/Fill/Gold/Subtle) has no\n * token in code: yellow subtle stands in.\n */\nexport function Highlight({ text, query }: { text: string; query: string }) {\n  const start = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;\n  if (start < 0) return <>{text}</>;\n  const end = start + query.length;\n\n  return (\n    <>\n      {text.slice(0, start)}\n      <mark className=\"bg-ws-non-semantic-yellow-subtle inline-block text-inherit\">\n        {text.slice(start, end)}\n      </mark>\n      {text.slice(end)}\n    </>\n  );\n}\n"
    },
    {
      "path": "src/blocks/modal-search/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { useState } from 'react';\n\nimport { index, QUERY, workspace } from './data';\nimport { SearchModal } from './search-modal';\n\n/** Search modal: search across the workspace, here over an empty page that reopens it. */\nexport default function ModalSearchBlock() {\n  const [open, setOpen] = useState(true);\n\n  return (\n    <div className=\"ws-block-utility bg-ws-static-foreground flex h-dvh items-center justify-center\">\n      <Button variant=\"secondary\" preset=\"border\" onClick={() => setOpen(true)}>\n        Open search\n      </Button>\n      <SearchModal\n        index={index}\n        workspace={workspace}\n        initialQuery={QUERY}\n        open={open}\n        onOpenChange={setOpen}\n        // A starting point has nowhere to go: opening a result closes the search.\n        onOpenResult={() => setOpen(false)}\n      />\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/modal-search/keyboard-hints.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/keyboard-hints.tsx",
      "content": "'use client';\n\n// TODO(custom): keyboard hints (a key chip and what it does) and the keys they name; Wideset has no Kbd / shortcut component, so the key is the box of Button `xs` Border drawn by hand.\nimport {\n  type RemixiconComponentType,\n  RiArrowDownSLine,\n  RiArrowLeftLine,\n  RiArrowUpSLine,\n} from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\nimport type { KeyboardEvent, ReactNode } from 'react';\n\n/**\n * The hints in the modal's footer strip, as Figma draws them: moving through the modal, going\n * back to where it was opened from, and closing. Esc is the Modal's own; `modalKeys` wires the\n * other two on `Modal.Content`, so every hint does what it says.\n */\nexport function KeyboardHints() {\n  return (\n    <>\n      <div className=\"gap-ws-12 flex items-center\">\n        <Hint\n          keys={\n            <span className=\"gap-ws-3 flex\">\n              <Key icon={RiArrowUpSLine} name=\"Up arrow\" />\n              <Key icon={RiArrowDownSLine} name=\"Down arrow\" />\n            </span>\n          }\n        >\n          Navigate\n        </Hint>\n        <Hint keys={<Key icon={RiArrowLeftLine} name=\"Left arrow\" />}>Return to parent</Hint>\n      </div>\n      <Hint keys={<Key>esc</Key>}>Close</Hint>\n    </>\n  );\n}\n\n/** One hint: the keys, then what they do. */\nfunction Hint({ keys, children }: { keys: ReactNode; children: string }) {\n  return (\n    <span className=\"gap-ws-5 typography-body-md text-ws-static-subtle flex items-center\">\n      {keys}\n      {children}\n    </span>\n  );\n}\n\n/** A key as a `kbd`, 24px high. An icon key names itself for screen readers. */\nfunction Key({\n  icon: Icon,\n  name,\n  children,\n}: {\n  icon?: RemixiconComponentType;\n  name?: string;\n  children?: string;\n}) {\n  return (\n    <kbd\n      className={cn(\n        'font-ws-body border-ws-dynamic-secondary-default bg-ws-static-highlight-subtle shadow-ws-controls-control rounded-ws-control-md h-ws-12 typography-caption-strong-md text-ws-dynamic-secondary-default flex items-center justify-center border',\n        Icon ? 'w-ws-12' : 'px-ws-5',\n      )}\n    >\n      {Icon ? (\n        <>\n          <Icon aria-hidden=\"true\" className=\"size-ws-8 shrink-0\" />\n          <span className=\"sr-only\">{name}</span>\n        </>\n      ) : (\n        children\n      )}\n    </kbd>\n  );\n}\n\n/** Places where the arrows already mean something: a list, a choice, tabs, a menu, a number. */\nconst OWN_ARROWS =\n  'textarea, select, [role=\"combobox\"], [aria-haspopup], [role=\"listbox\"], [role=\"radiogroup\"], [role=\"radio\"], [role=\"tablist\"], [role=\"tab\"], [role=\"menu\"], [role=\"slider\"], input[type=\"number\"], input[type=\"range\"]';\n\nconst FOCUSABLE =\n  'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** In a text field the caret moves with Left, unless it stands at the very start. */\nconst caretAtStart = (target: Element) =>\n  !(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) ||\n  (target.selectionStart === 0 && target.selectionEnd === 0);\n\n/**\n * The keys the hints name, for `Modal.Content`'s `onKeyDown`: Up and Down move to the previous or\n * next control in the modal, Left goes back with `onBack`. Neither takes a key from a place that\n * uses it (a select, a radio group, tabs, a list, a menu), nor one already handled; Left in a text\n * field only once the caret is at its start, so it still moves the caret.\n */\nexport function modalKeys(onBack: () => void) {\n  return (event: KeyboardEvent<HTMLElement>) => {\n    const { key, target, currentTarget } = event;\n    if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n    if (!(target instanceof Element) || target.closest(OWN_ARROWS)) return;\n    if (key === 'ArrowUp' || key === 'ArrowDown') {\n      const controls = [...currentTarget.querySelectorAll<HTMLElement>(FOCUSABLE)].filter(\n        (element) => element.getClientRects().length > 0,\n      );\n      const next =\n        controls[controls.indexOf(target as HTMLElement) + (key === 'ArrowDown' ? 1 : -1)];\n      if (!next) return;\n      event.preventDefault();\n      next.focus();\n    } else if (key === 'ArrowLeft' && !event.shiftKey && caretAtStart(target)) {\n      event.preventDefault();\n      onBack();\n    }\n  };\n}\n"
    },
    {
      "path": "src/blocks/modal-search/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/people.assets.ts",
      "content": "// Portraits of the sample people as small JPEG data URLs (a block ships only .ts and .tsx).\n// Exported from the Wideset Core Figma file by people.cjs: do not edit by hand.\n\n/** A person’s photo by name. People who are not here show their initials. */\nexport const PHOTOS: Record<string, string | undefined> = {\n  'Priya Raman':\n    'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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2yn6M+vj7Ugqi5eEnfktRWVvPuIbaQMqWs4AHrWo9b8dYtkWuLZYC57xQSJKzyspVny6q/QdN6bdQSrjqBRM19SkYJS0nZCT6f1pgl6VTMi8iscyhsryNRW93F/b9LnHpgpJ2+GoZ1ukahdkTXj3kmQtTrhx9SlEk/qayaV0NPlylR4M9yGF7FIGR+tbFt+m3rco960QEHBz5edTO16daYkolJRyhWFAgVwXFt4ZpYzSScTPovhtFtDrcqe87cJqMFK38EIP7qegP3rYS3XIjzTjGAobbjYjyrDA3QOXf71nkKSBygjn/lVqqp+V+lS61Pdm0L7ZflutkXBDbTnOoJU3kpIzt16U+JUlaQpJBSehHjULKcN/oBVsedIguZZcPIDkoO6TXaUWksnAnWm246JvRTXBvbErCXPwnPI9D706UEDTXpph+/zNW5eW6pMQKITHTsE/xeZrOxBSBygbjrTDYVIhX9lkKPc3KOSEnp3iQFZHqkn8qk7S8X1EcdFR1KI9FD/uhIuYxpGF2OO7G252q9tlJbAwNqzrTzkJG2FGsqG/lNLgMmMREyGlNuALQeopawlLMcRw38o6HfNJ2cjmHiKUoOSM02VUJbaHxtnFYTM8UrZQUBZwfE7GlAGANxmk7aQVH7Uqb+YkkbAU6FcYaihs7JT3Jl6QCBnekikfOCfvSpJyjrvWB/5GX3P8iDThpa0nmSFeBNPlqlOtrS2tWWemD1HpTGghtqG3nBUlJPoBk06NHKfv1oSGyWT//Z',\n};\n"
    },
    {
      "path": "src/blocks/modal-search/search-modal.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/search-modal.tsx",
      "content": "'use client';\n\nimport { RiFileLine, RiSearchLine, RiUserLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Modal } from '@/components/ui/wideset/modal/Modal';\nimport { Tabs } from '@/components/ui/wideset/tabs/Tabs';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { type KeyboardEvent, useId, useRef, useState } from 'react';\n\nimport { KeyboardHints } from './keyboard-hints';\nimport { type SearchResult, SearchResultRow } from './search-result';\n\ntype Scope = 'all' | 'files' | 'people';\n\nconst SCOPES = [\n  { value: 'all', label: 'All' },\n  { value: 'files', label: 'Files', icon: RiFileLine },\n  { value: 'people', label: 'People', icon: RiUserLine },\n] as const;\n\nconst inScope = (result: SearchResult, scope: Scope) =>\n  scope === 'all' || (scope === 'people') === (result.kind === 'person');\n\ntype SearchModalProps = {\n  /** Everything search looks through, most relevant first. */\n  index: SearchResult[];\n  /** Names what is searched, for the dialog's title and the field's label. */\n  workspace: string;\n  initialQuery?: string;\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  /** Enter on the highlighted result, or a click on any. */\n  onOpenResult: (result: SearchResult) => void;\n};\n\n/**\n * Figma's Modal `Type=Search`: search across the workspace. The field is the modal's default\n * 40px, the largest control in it; the tabs only narrow the results, so they carry no counts.\n * The field keeps the focus the whole time: typing filters the results, the arrow keys move the\n * highlight (the field points at it for screen readers), Enter opens it and Esc closes; Left,\n * with the caret at the start of the field, goes back from a tab to All and from All to the page.\n * The\n * results keep the height of five rows, so the modal does not jump while the list shrinks and\n * grows.\n */\nexport function SearchModal({\n  index,\n  workspace,\n  initialQuery = '',\n  open,\n  onOpenChange,\n  onOpenResult,\n}: SearchModalProps) {\n  const id = useId();\n  const input = useRef<HTMLInputElement>(null);\n  const [query, setQuery] = useState(initialQuery);\n  const [scope, setScope] = useState<Scope>('all');\n  const [active, setActive] = useState(0);\n\n  const term = query.trim();\n  const found = index.filter((result) => result.title.toLowerCase().includes(term.toLowerCase()));\n  const shown = found.filter((result) => inScope(result, scope));\n  const current = shown[active];\n  const optionId = (result: SearchResult) => `${id}-${result.id}`;\n\n  const search = (value: string) => {\n    setQuery(value);\n    setActive(0);\n  };\n\n  /** Left moves the caret, unless it stands at the start of the field with nothing selected. */\n  const caretAtStart = () =>\n    input.current?.selectionStart === 0 && input.current.selectionEnd === 0;\n\n  const onKeyDown = (event: KeyboardEvent) => {\n    if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n      event.preventDefault();\n      const next = shown[active + (event.key === 'ArrowDown' ? 1 : -1)];\n      if (!next) return;\n      setActive(shown.indexOf(next));\n      document.getElementById(optionId(next))?.scrollIntoView({ block: 'nearest' });\n    } else if (event.key === 'Enter' && event.target === input.current && current) {\n      onOpenResult(current);\n    } else if (\n      event.key === 'ArrowLeft' &&\n      !event.shiftKey &&\n      !event.altKey &&\n      !event.ctrlKey &&\n      !event.metaKey &&\n      event.target === input.current &&\n      caretAtStart()\n    ) {\n      // Back a level: from a tab to All, and from All to the page it was opened from.\n      event.preventDefault();\n      if (scope === 'all') onOpenChange(false);\n      else {\n        setScope('all');\n        setActive(0);\n      }\n    }\n  };\n\n  return (\n    <Modal open={open} onOpenChange={onOpenChange}>\n      {/* No X: the footer names the way out, and a click outside closes it too. */}\n      <Modal.Content className=\"ws-block-utility\"\n        showCloseButton={false}\n        aria-describedby={undefined}\n        onKeyDown={onKeyDown}\n        // Radix would select the query; Figma opens with the caret after it.\n        onOpenAutoFocus={(event) => {\n          event.preventDefault();\n          input.current?.focus();\n        }}\n      >\n        <Modal.Title className=\"sr-only\">Search {workspace}</Modal.Title>\n\n        <div className=\"gap-ws-7 px-ws-11 pt-ws-11 pb-ws-7 flex items-center\">\n          <TextInput\n            ref={input}\n            className=\"min-w-0 flex-1\"\n            value={query}\n            onChange={(event) => search(event.target.value)}\n          >\n            <TextInput.Prefix inner>\n              <TextInput.Icon icon={RiSearchLine} />\n            </TextInput.Prefix>\n            <TextInput.Input\n              type=\"search\"\n              placeholder=\"Search people and files\"\n              aria-label={`Search ${workspace}`}\n              role=\"combobox\"\n              aria-expanded\n              aria-controls={`${id}-results`}\n              aria-activedescendant={current && optionId(current)}\n            />\n          </TextInput>\n          <Button\n            variant=\"secondary\"\n            preset=\"border\"\n            onClick={() => {\n              search('');\n              input.current?.focus();\n            }}\n          >\n            Clear\n          </Button>\n        </div>\n\n        <Tabs\n          value={scope}\n          onValueChange={(value) => {\n            setScope(value as Scope);\n            setActive(0);\n          }}\n          divider={false}\n          className=\"min-h-0\"\n        >\n          {/* The line under the tabs is the header's own, Static/Stroke/Base, edge to edge. */}\n          <div className=\"border-ws-static-base px-ws-11 pt-ws-1 border-b\">\n            <Tabs.List aria-label=\"Results by type\">\n              {SCOPES.map((item) => (\n                <Tabs.Item key={item.value} value={item.value}>\n                  {'icon' in item && <Tabs.Icon icon={item.icon} />}\n                  <Tabs.Label>{item.label}</Tabs.Label>\n                </Tabs.Item>\n              ))}\n            </Tabs.List>\n          </div>\n\n          {/*\n            Five rows tall, as drawn: the list scrolls between its own 20px margins, so a resting\n            list ends on a whole row, not on the line of the next one.\n          */}\n          <Tabs.Content\n            value={scope}\n            className=\"my-ws-11 px-ws-11 ws-scrollbar h-[22.375rem] shrink overflow-y-auto\"\n          >\n            {shown.length === 0 ? (\n              <p role=\"status\" className=\"py-ws-5 typography-body-md text-ws-static-subtle\">\n                {term ? `No results for “${term}”.` : 'Nothing here yet.'}\n              </p>\n            ) : (\n              <ul id={`${id}-results`} role=\"listbox\" aria-label=\"Results\">\n                {shown.map((result, position) => (\n                  <SearchResultRow\n                    key={result.id}\n                    id={optionId(result)}\n                    result={result}\n                    query={term}\n                    active={position === active}\n                    onActivate={() => setActive(position)}\n                    onOpen={() => onOpenResult(result)}\n                  />\n                ))}\n              </ul>\n            )}\n          </Tabs.Content>\n        </Tabs>\n\n        <Modal.Footer variant=\"extension\" className=\"items-center\">\n          <KeyboardHints />\n        </Modal.Footer>\n      </Modal.Content>\n    </Modal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/modal-search/search-result.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/modal-search/search-result.tsx",
      "content": "'use client';\n\n// TODO(custom): a search result row (40px avatar or file tile, title, context line); ListItem is the 32px menu row, Wideset has no larger result row.\nimport type { RemixiconComponentType } from '@remixicon/react';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { Highlight } from './highlight';\nimport { PHOTOS } from './people.assets';\n\nexport type SearchResult = {\n  id: string;\n  /** What is searched and shown first: a person's name or a file's name. */\n  title: string;\n  /** The line under it: when the person was last active, or where the file lives. */\n  detail: string;\n} & (\n  | { kind: 'person'; initials: string; online: boolean }\n  | { kind: 'file'; icon: RemixiconComponentType }\n);\n\n/**\n * One result, an option of the list the search field drives: the field keeps the focus, so the\n * row never takes it and `active` (the arrow keys, or the pointer) is its only highlight. A line\n * splits it from the row above, as in Figma, drawn by the row so the list holds only options.\n */\nexport function SearchResultRow({\n  result,\n  query,\n  active,\n  id,\n  onActivate,\n  onOpen,\n}: {\n  result: SearchResult;\n  query: string;\n  active: boolean;\n  id: string;\n  onActivate: () => void;\n  onOpen: () => void;\n}) {\n  /** A person's photo, when they have one; a file has none. */\n  const photo = result.kind === 'person' ? PHOTOS[result.title] : undefined;\n\n  return (\n    // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- the search field holds the focus and its keys open the active option\n    <li\n      id={id}\n      role=\"option\"\n      aria-selected={active}\n      className=\"border-ws-static-base not-first:mt-ws-5 not-first:pt-ws-5 not-first:border-t\"\n      onPointerMove={onActivate}\n      onClick={onOpen}\n    >\n      <div\n        className={cn(\n          'gap-ws-9 p-ws-5 rounded-ws-container-md flex cursor-pointer items-center',\n          active && 'bg-ws-dynamic-tertiary-alpha-hover',\n        )}\n      >\n        {result.kind === 'person' && photo ? (\n          <Avatar\n            size=\"lg\"\n            aria-hidden=\"true\"\n            src={photo}\n            alt=\"\"\n            initials={result.initials}\n            status={result.online ? 'online' : 'unavailable'}\n          />\n        ) : result.kind === 'person' ? (\n          <Avatar\n            size=\"lg\"\n            aria-hidden=\"true\"\n            initials={result.initials}\n            // Figma's dot for someone away is grey: Avatar's `unavailable` (`offline` is red).\n            status={result.online ? 'online' : 'unavailable'}\n          />\n        ) : (\n          <Avatar size=\"lg\" shape=\"square\" aria-hidden=\"true\" icon={<result.icon />} />\n        )}\n        <div className=\"gap-ws-2 flex min-w-0 flex-col\">\n          <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n            <Highlight text={result.title} query={query} />\n          </span>\n          <span className=\"typography-body-md text-ws-static-subtle truncate\">{result.detail}</span>\n        </div>\n      </div>\n    </li>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
