{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cavemio-web-research",
  "title": "Web research",
  "description": "Watch the agent search: the query types in, page icons stack up as it reads, then it folds into a trail of searches and the pages each one found.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/web-research.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronDown, ChevronRight, Search } from \"lucide-react\";\nimport { NumberRoll } from \"./number-roll\";\nimport { TextMorph } from \"./text-morph\";\n\n/* ─────────────────────────────────────────────────────────\n * WEB RESEARCH: watch the agent search and read\n *\n *   searching  \"Searching\" shimmers; the live query types in\n *   reading    the label morphs to \"Reading\" and \"7 sites\"\n *              rolls up; each page drops its icon into the\n *              stack (the oldest folds away) while its title\n *              rises in underneath as the last one lifts off\n *   done       the line morphs into \"3 searches · 9 sources\":\n *              counts roll, words morph, the title row folds\n *              shut and a chevron opens in; open it for the list\n *   error      \"Search failed\", keeping whatever was found\n *   cancelled  \"Stopped after 2 searches\"\n *   trail      opened, each search is a row on a thin line trail\n *              with its count; a search on one site wears that\n *              site's mark, and the pages it found sit under it\n *              as overlapping marks that fold open into links\n *\n * Feed it the queries and sources as they arrive (tool calls\n * and source parts from the AI SDK); it animates the rest.\n * ───────────────────────────────────────────────────────── */\n\nexport type ResearchStatus =\n  \"searching\" | \"reading\" | \"done\" | \"error\" | \"cancelled\";\n\nexport interface ResearchSource {\n  url: string;\n  title?: string;\n  /** An icon URL; without one, a tinted monogram of the site. */\n  favicon?: string;\n  /** Which search found it (its index in queries), so the trail can group pages under their search. */\n  query?: number;\n}\n\nexport interface ResearchQuery {\n  text: string;\n  /** A search on one site, e.g. \"threadly.com\": the row wears that site's mark and reads \"Searched Threadly for ...\". */\n  site?: string;\n  /** An icon URL for that site. */\n  siteIcon?: string;\n  /** How many it found. */\n  results?: number;\n  /** The word after the count, e.g. \"posts\". Defaults to \"results\". */\n  resultLabel?: string;\n}\n\nexport interface WebResearchProps extends React.HTMLAttributes<HTMLDivElement> {\n  status: ResearchStatus;\n  /** Queries so far, as text or with their site and count; the last one is live while searching. */\n  queries: (string | ResearchQuery)[];\n  /** Pages read so far, in order. */\n  sources: ResearchSource[];\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n}\n\nconst EASE = \"cubic-bezier(0.23,1,0.32,1)\";\nconst MORPH = \"cubic-bezier(0.16,1,0.3,1)\";\nconst STACK = 4;\n// A light that sweeps across the label. A mask, not a text clip, so it reaches letters that are mid-morph.\nconst SHEEN =\n  \"text-foreground [mask-image:linear-gradient(90deg,rgb(0_0_0/0.45)_35%,#000_50%,rgb(0_0_0/0.45)_65%)] [mask-size:200%_100%] animate-[ui-sheen_1.4s_linear_infinite] motion-reduce:animate-none motion-reduce:[mask-image:none] motion-reduce:text-foreground/70\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\nfunction hostname(url: string) {\n  try {\n    return new URL(url).hostname.replace(/^www\\./, \"\");\n  } catch {\n    return url;\n  }\n}\n\nfunction hue(text: string) {\n  let h = 0;\n  for (let i = 0; i < text.length; i++) h = (h * 31 + text.charCodeAt(i)) % 360;\n  return h;\n}\n\nconst asQuery = (q: string | ResearchQuery): ResearchQuery =>\n  typeof q === \"string\" ? { text: q } : q;\nconst siteName = (site: string) => {\n  const parts = hostname(`https://${site}`).split(\".\");\n  const name = parts.length > 1 ? parts[parts.length - 2] : parts[0];\n  return name.length <= 2\n    ? name.toUpperCase()\n    : name.charAt(0).toUpperCase() + name.slice(1);\n};\n\nconst plural = (n: number, word: string) =>\n  `${word}${n === 1 ? \"\" : /(s|sh|ch|x)$/.test(word) ? \"es\" : \"s\"}`;\n\nfunction Favicon({\n  source,\n  className = \"\",\n}: {\n  source: ResearchSource;\n  className?: string;\n}) {\n  const host = hostname(source.url);\n  const [failed, setFailed] = React.useState(false);\n  if (source.favicon && !failed) {\n    return (\n      <img\n        src={source.favicon}\n        alt=\"\"\n        onError={() => setFailed(true)}\n        className={`rounded-full bg-background object-cover ${className}`}\n      />\n    );\n  }\n  const h = hue(host);\n  return (\n    <span\n      aria-hidden=\"true\"\n      className={`flex items-center justify-center rounded-full text-[9.5px] font-semibold leading-none ${className}`}\n      style={{\n        background: `color-mix(in oklab, oklch(0.62 0.13 ${h}) 20%, var(--background))`,\n        color: `oklch(0.5 0.12 ${h})`,\n      }}\n    >\n      {host.charAt(0).toUpperCase()}\n    </span>\n  );\n}\n\n/** Types the newest query in, a few characters a frame; earlier text never re-types. */\nfunction useTyped(text: string, active: boolean, reduced: boolean) {\n  const [shown, setShown] = React.useState(text);\n  React.useEffect(() => {\n    if (!active || reduced) return;\n    let i = 0;\n    let frame = 0;\n    const step = () => {\n      i = Math.min(text.length, i + 2);\n      setShown(text.slice(0, i));\n      if (i < text.length) frame = requestAnimationFrame(step);\n    };\n    frame = requestAnimationFrame(step);\n    return () => cancelAnimationFrame(frame);\n  }, [text, active, reduced]);\n  return !active || reduced ? text : shown;\n}\n\n/** A piece of the line that opens out of nothing and folds back into it (width eases, content blurs in). */\nfunction Reveal({\n  show,\n  reduced,\n  className = \"\",\n  children,\n}: {\n  show: boolean;\n  reduced: boolean;\n  className?: string;\n  children: React.ReactNode;\n}) {\n  return (\n    <span\n      aria-hidden={!show || undefined}\n      className={`grid min-w-0 ${className}`}\n      style={{\n        gridTemplateColumns: show ? \"1fr\" : \"0fr\",\n        opacity: show ? 1 : 0,\n        filter: show ? \"none\" : \"blur(4px)\",\n        transition: reduced\n          ? \"none\"\n          : `grid-template-columns 460ms ${MORPH}, opacity ${show ? \"320ms\" : \"180ms\"} ${MORPH}, filter 320ms ${MORPH}`,\n      }}\n    >\n      <span className=\"min-w-0 whitespace-nowrap [clip-path:inset(-4px_-2px)]\">\n        {children}\n      </span>\n    </span>\n  );\n}\n\n/** One icon in the stack: drops in when it's new, folds away when it's pushed out by a newer one. */\nfunction StackIcon({\n  shown,\n  first,\n  enter,\n  reduced,\n  z,\n  children,\n}: {\n  shown: boolean;\n  first: boolean;\n  enter: boolean;\n  reduced: boolean;\n  z: number;\n  children: React.ReactNode;\n}) {\n  const [entering] = React.useState(enter);\n  return (\n    <span\n      aria-hidden={!shown || undefined}\n      className={`relative flex h-5 shrink-0 ${entering && !reduced ? \"animate-[ui-drop-in_420ms_cubic-bezier(0.23,1,0.32,1)_backwards]\" : \"\"}`}\n      style={{\n        zIndex: z,\n        width: shown ? 20 : 0,\n        marginLeft: shown && !first ? -6 : 0,\n        opacity: shown ? 1 : 0,\n        transform: shown ? \"none\" : \"scale(0.6)\",\n        transition: reduced\n          ? \"none\"\n          : `width 420ms ${MORPH}, margin 420ms ${MORPH}, opacity 260ms ${MORPH}, transform 420ms ${MORPH}`,\n      }}\n    >\n      <span className=\"flex size-5 shrink-0 overflow-hidden rounded-full ring-2 ring-background\">\n        {children}\n      </span>\n    </span>\n  );\n}\n\n/** A one-line ticker: the new text rises in out of a blur while the last one lifts away. */\nfunction Ticker({\n  id,\n  reduced,\n  children,\n}: {\n  id: string;\n  reduced: boolean;\n  children: React.ReactNode;\n}) {\n  const [hasUpdated, setHasUpdated] = React.useState(false);\n  const [current, setCurrent] = React.useState<{\n    id: string;\n    node: React.ReactNode;\n  }>({ id, node: children });\n  const [leaving, setLeaving] = React.useState<\n    { id: string; node: React.ReactNode }[]\n  >([]);\n  if (current.id !== id) {\n    if (!reduced)\n      setLeaving((l) =>\n        l.some((x) => x.id === current.id) ? l : [...l, current],\n      );\n    setCurrent({ id, node: children });\n    if (!hasUpdated) setHasUpdated(true);\n  }\n  const done = React.useCallback(\n    (leftId: string) => setLeaving((l) => l.filter((x) => x.id !== leftId)),\n    [],\n  );\n\n  return (\n    <span className=\"relative block h-4\">\n      {leaving.map((l) => (\n        <Tick key={`out-${l.id}`} id={l.id} out onDone={done}>\n          {l.node}\n        </Tick>\n      ))}\n      <Tick key={id} id={id} enter={hasUpdated && !reduced}>\n        {children}\n      </Tick>\n    </span>\n  );\n}\n\nfunction Tick({\n  id,\n  out = false,\n  enter = false,\n  onDone,\n  children,\n}: {\n  id: string;\n  out?: boolean;\n  enter?: boolean;\n  onDone?: (id: string) => void;\n  children: React.ReactNode;\n}) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  const [entering] = React.useState(enter);\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    if (out) {\n      const animation = el.animate(\n        [\n          { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n          { opacity: 0, filter: \"blur(4px)\", transform: \"translateY(-6px)\" },\n        ],\n        { duration: 220, easing: MORPH, fill: \"forwards\" },\n      );\n      animation.onfinish = () => onDone?.(id);\n      return () => animation.cancel();\n    }\n    if (!entering) return;\n    const animation = el.animate(\n      [\n        { opacity: 0, filter: \"blur(4px)\", transform: \"translateY(6px)\" },\n        { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n      ],\n      { duration: 380, easing: MORPH, delay: 60, fill: \"backwards\" },\n    );\n    return () => animation.cancel();\n  }, [id, out, entering, onDone]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden={out || undefined}\n      className=\"absolute inset-0 truncate text-[11.5px] text-muted-foreground/80\"\n    >\n      {children}\n    </span>\n  );\n}\n\nfunction SourceLink({ source }: { source: ResearchSource }) {\n  return (\n    <a\n      href={source.url}\n      target=\"_blank\"\n      rel=\"noreferrer\"\n      className=\"flex h-7 items-center gap-2.5 rounded-lg px-1.5 outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/40\"\n    >\n      <Favicon source={source} className=\"size-4 shrink-0\" />\n      <span className=\"min-w-0 flex-1 truncate text-[12.5px] text-foreground\">\n        {source.title ?? hostname(source.url)}\n      </span>\n      <span className=\"shrink-0 text-[11.5px] text-muted-foreground\">\n        {hostname(source.url)}\n      </span>\n    </a>\n  );\n}\n\n/** The pages one search found: overlapping marks on a branch of the trail, folding open into links. */\nfunction SourceGroup({\n  sources,\n  reduced,\n}: {\n  sources: ResearchSource[];\n  reduced: boolean;\n}) {\n  const [open, setOpen] = React.useState(false);\n  const listId = React.useId();\n  const shown = sources.slice(0, 5);\n  return (\n    <div className=\"relative mb-1 ml-6\">\n      <span\n        aria-hidden=\"true\"\n        className=\"absolute -left-3.5 -top-1 h-[13px] w-2.5 rounded-bl-[5px] border-b border-l border-border\"\n      />\n      <button\n        type=\"button\"\n        aria-expanded={open}\n        aria-controls={listId}\n        onClick={() => setOpen((o) => !o)}\n        className=\"cursor-pointer group flex h-6 items-center gap-2 rounded-md text-[12px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40\"\n      >\n        Sources\n        <span className=\"flex items-center\">\n          {shown.map((src, i) => (\n            <span\n              key={src.url}\n              className=\"flex size-4 overflow-hidden rounded-full ring-2 ring-background\"\n              style={{ marginLeft: i ? -5 : 0, zIndex: shown.length - i }}\n            >\n              <Favicon source={src} className=\"size-full\" />\n            </span>\n          ))}\n          {sources.length > shown.length && (\n            <span className=\"ml-1 font-mono text-[10px]\">\n              +{sources.length - shown.length}\n            </span>\n          )}\n        </span>\n        <ChevronDown\n          aria-hidden=\"true\"\n          className=\"size-3.5\"\n          style={{\n            transform: open ? \"rotate(180deg)\" : \"none\",\n            transition: reduced ? \"none\" : `transform 320ms ${EASE}`,\n          }}\n        />\n        <span className=\"sr-only\">({sources.length})</span>\n      </button>\n      <div\n        id={listId}\n        inert={!open}\n        className=\"grid\"\n        style={{\n          gridTemplateRows: open ? \"1fr\" : \"0fr\",\n          opacity: open ? 1 : 0,\n          transition: reduced\n            ? \"none\"\n            : `grid-template-rows 380ms ${EASE}, opacity ${open ? \"280ms\" : \"140ms\"} ${EASE}`,\n        }}\n      >\n        <ul className=\"-mx-1.5 min-h-0 overflow-hidden\">\n          {sources.map((src) => (\n            <li key={src.url}>\n              <SourceLink source={src} />\n            </li>\n          ))}\n        </ul>\n      </div>\n    </div>\n  );\n}\n\nexport function WebResearch({\n  status,\n  queries,\n  sources,\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  className = \"\",\n  ...props\n}: WebResearchProps) {\n  const reduced = useReducedMotion();\n  const [ownOpen, setOwnOpen] = React.useState(defaultOpen);\n  const open = openProp ?? ownOpen;\n  const setOpen = (next: boolean) => {\n    if (openProp === undefined) setOwnOpen(next);\n    onOpenChange?.(next);\n  };\n\n  const working = status === \"searching\" || status === \"reading\";\n  const query = queries.length ? asQuery(queries[queries.length - 1]).text : \"\";\n  const typed = useTyped(query, status === \"searching\", reduced);\n  const latest = sources[sources.length - 1];\n  const extra = Math.max(0, sources.length - STACK);\n  // Pages that don't say which search found them are listed after the trail.\n  const ungrouped = sources.filter(\n    (src) =>\n      src.query === undefined || src.query < 0 || src.query >= queries.length,\n  );\n  const listId = React.useId();\n\n  // Icons that arrive after the first paint drop in; the ones already there just sit.\n  const [mounted, setMounted] = React.useState(false);\n  React.useEffect(() => {\n    const timer = window.setTimeout(() => setMounted(true), 0);\n    return () => window.clearTimeout(timer);\n  }, []);\n\n  // One line that rearranges itself: a label, then whichever counts this state needs.\n  const label = {\n    searching: \"Searching\",\n    reading: \"Reading\",\n    error: \"Search failed\",\n    cancelled: \"Stopped after\",\n    done: \"\",\n  }[status];\n  const showSearches = status === \"done\" || status === \"cancelled\";\n  const showSources =\n    sources.length > 0 &&\n    (status === \"reading\" || status === \"done\" || status === \"error\");\n  const showDot = showSources && (status === \"done\" || status === \"error\");\n  const sourceWord =\n    status === \"reading\"\n      ? plural(sources.length, \"site\")\n      : plural(sources.length, \"source\");\n\n  const summary =\n    status === \"searching\"\n      ? `Searching for ${query}`\n      : status === \"reading\"\n        ? `Read ${sources.length} ${sourceWord}`\n        : status === \"error\"\n          ? `Search failed${sources.length ? `, ${sources.length} ${sourceWord}` : \"\"}`\n          : status === \"cancelled\"\n            ? `Stopped after ${queries.length} ${plural(queries.length, \"search\")}`\n            : `Done: ${queries.length} ${plural(queries.length, \"search\")}, ${sources.length} ${sourceWord}`;\n\n  return (\n    <div className={`w-full ${className}`} {...props}>\n      {/* The same row from first search to final summary, so every piece of it can morph; it becomes a button once there's a list to open. */}\n      <button\n        type=\"button\"\n        disabled={working}\n        aria-expanded={working ? undefined : open}\n        aria-controls={working ? undefined : listId}\n        onClick={() => setOpen(!open)}\n        className=\"group flex min-h-9 w-full items-center gap-2.5 rounded-lg py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default\"\n      >\n        <span\n          aria-hidden=\"true\"\n          className=\"relative flex h-5 shrink-0 items-center\"\n        >\n          <StackIcon\n            shown={sources.length === 0}\n            first\n            enter={false}\n            reduced={reduced}\n            z={0}\n          >\n            <span className=\"flex size-full items-center justify-center bg-muted text-muted-foreground\">\n              <Search\n                className={`size-3 ${working ? \"animate-[ui-breathe_1.6s_ease-in-out_infinite] motion-reduce:animate-none\" : \"\"}`}\n                strokeWidth={2.2}\n              />\n            </span>\n          </StackIcon>\n          {sources.map((s, i) => (\n            <StackIcon\n              key={s.url}\n              shown={i >= sources.length - STACK}\n              first={i === Math.max(0, sources.length - STACK)}\n              enter={mounted && working}\n              reduced={reduced}\n              z={i + 1}\n            >\n              <Favicon source={s} className=\"size-full\" />\n            </StackIcon>\n          ))}\n          <Reveal\n            show={extra > 0}\n            reduced={reduced}\n            className=\"relative z-[999]\"\n          >\n            <span className=\"ml-[-6px] flex h-5 min-w-5 items-center justify-center rounded-full bg-muted px-1 font-mono text-[9.5px] text-muted-foreground ring-2 ring-background\">\n              <NumberRoll value={extra} prefix=\"+\" duration={600} />\n            </span>\n          </Reveal>\n        </span>\n\n        <span className=\"min-w-0 flex-1 text-left\">\n          <span\n            className={`flex min-w-0 items-center text-[13px] leading-5 transition-colors duration-300 ${status === \"error\" ? \"text-red-600 dark:text-red-400\" : \"text-muted-foreground\"}`}\n          >\n            <span\n              className={`shrink-0 font-medium transition-colors duration-300 ${working ? SHEEN : \"\"}`}\n            >\n              <TextMorph>{label}</TextMorph>\n            </span>\n            <Reveal show={showSearches} reduced={reduced} className=\"shrink-0\">\n              <span\n                className=\"inline-flex items-baseline transition-[padding] duration-500\"\n                style={{\n                  paddingLeft: label ? 5 : 0,\n                  transitionTimingFunction: MORPH,\n                }}\n              >\n                <NumberRoll value={queries.length} duration={700} />\n                &nbsp;\n                <TextMorph>{plural(queries.length, \"search\")}</TextMorph>\n              </span>\n            </Reveal>\n            <Reveal show={showDot} reduced={reduced} className=\"shrink-0\">\n              <span className=\"px-1.5 opacity-60\">·</span>\n            </Reveal>\n            <Reveal show={showSources} reduced={reduced} className=\"shrink-0\">\n              <span\n                className=\"inline-flex items-baseline transition-[padding] duration-500\"\n                style={{\n                  paddingLeft: showDot ? 0 : 5,\n                  transitionTimingFunction: MORPH,\n                }}\n              >\n                <NumberRoll value={sources.length} duration={700} />\n                &nbsp;\n                <TextMorph>{sourceWord}</TextMorph>\n              </span>\n            </Reveal>\n            <Reveal\n              show={status === \"searching\" && Boolean(query)}\n              reduced={reduced}\n              className=\"shrink\"\n            >\n              <span className=\"block truncate pl-1.5\">“{typed}”</span>\n            </Reveal>\n          </span>\n          {/* The page being read; the row folds shut when the work is done. */}\n          <span\n            aria-hidden={!working || undefined}\n            className=\"grid\"\n            style={{\n              gridTemplateRows: working && latest ? \"1fr\" : \"0fr\",\n              opacity: working && latest ? 1 : 0,\n              transition: reduced\n                ? \"none\"\n                : `grid-template-rows 420ms ${MORPH}, opacity 260ms ${MORPH}`,\n            }}\n          >\n            <span className=\"min-h-0 overflow-hidden\">\n              <span className=\"block pt-0.5\">\n                {latest && (\n                  <Ticker id={latest.url} reduced={reduced}>\n                    {latest.title ?? hostname(latest.url)}{\" \"}\n                    <span className=\"text-muted-foreground/60\">\n                      · {hostname(latest.url)}\n                    </span>\n                  </Ticker>\n                )}\n              </span>\n            </span>\n          </span>\n        </span>\n\n        <Reveal show={!working} reduced={reduced} className=\"shrink-0\">\n          <ChevronRight\n            aria-hidden=\"true\"\n            className=\"size-3.5 text-muted-foreground transition-transform duration-300 group-hover:text-foreground motion-reduce:transition-none\"\n            style={{\n              transform: open ? \"rotate(90deg)\" : \"none\",\n              transitionTimingFunction: EASE,\n            }}\n          />\n        </Reveal>\n      </button>\n      {/* Outside the button, so the button's name stays its visible text. */}\n      <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n        {summary}\n      </span>\n\n      <div\n        id={listId}\n        inert={!open || working}\n        className=\"grid\"\n        style={{\n          gridTemplateRows: open && !working ? \"1fr\" : \"0fr\",\n          transition: reduced ? \"none\" : `grid-template-rows 380ms ${EASE}`,\n        }}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <div className=\"ml-[9px] mt-1 pl-[19px]\">\n            {queries.length > 0 && (\n              <ul className=\"pb-1\">\n                {queries.map((raw, i) => {\n                  const q = asQuery(raw);\n                  const found = sources.filter((src) => src.query === i);\n                  const last =\n                    i === queries.length - 1 && ungrouped.length === 0;\n                  return (\n                    <li key={i} className=\"relative\">\n                      {/* The trail: a thin line down the left, a short branch to each search. */}\n                      <span\n                        aria-hidden=\"true\"\n                        className=\"absolute -left-[19px] top-0 w-px bg-border\"\n                        style={last ? { height: 15 } : { bottom: 0 }}\n                      />\n                      <span\n                        aria-hidden=\"true\"\n                        className=\"absolute -left-[19px] top-[15px] h-px w-3 bg-border\"\n                      />\n                      <div className=\"flex items-start gap-2 py-1.5 text-[12.5px] leading-[18px] text-muted-foreground\">\n                        <span className=\"mt-px flex size-4 shrink-0 items-center justify-center\">\n                          {q.site ? (\n                            <Favicon\n                              source={{\n                                url: `https://${q.site}`,\n                                favicon: q.siteIcon,\n                              }}\n                              className=\"size-4\"\n                            />\n                          ) : (\n                            <Search\n                              aria-hidden=\"true\"\n                              className=\"size-3.5\"\n                              strokeWidth={2.1}\n                            />\n                          )}\n                        </span>\n                        <span className=\"min-w-0 flex-1 text-foreground/85\">\n                          {q.site ? (\n                            <>\n                              Searched {siteName(q.site)} for{\" \"}\n                              <span className=\"font-mono text-[11.5px] text-muted-foreground\">\n                                {q.text}\n                              </span>\n                            </>\n                          ) : (\n                            q.text\n                          )}\n                        </span>\n                        {q.results != null && (\n                          <span className=\"shrink-0 whitespace-nowrap tabular-nums\">\n                            {q.results}{\" \"}\n                            {q.resultLabel ?? plural(q.results, \"result\")}\n                          </span>\n                        )}\n                      </div>\n                      {found.length > 0 && (\n                        <SourceGroup sources={found} reduced={reduced} />\n                      )}\n                    </li>\n                  );\n                })}\n              </ul>\n            )}\n            {ungrouped.length > 0 && (\n              <div\n                className={\n                  queries.length\n                    ? \"border-t border-border/60 pb-1 pt-1.5\"\n                    : \"pb-1\"\n                }\n              >\n                <ul className=\"-mx-1.5 max-h-80 overflow-y-auto overflow-x-hidden px-1.5 [scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]\">\n                  {ungrouped.map((src) => (\n                    <li key={src.url}>\n                      <SourceLink source={src} />\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            )}\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/number-roll.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * NUMBER ROLL: numbers that change like an odometer\n *\n *   rolling   each digit is a column that rolls to its new\n *             value, in the direction the number moved: going\n *             up, a 9 rolls on to 0 instead of spinning back\n *   places    new places slide open from nothing; lost ones\n *             fold away\n *   format    anything Intl.NumberFormat does: currency,\n *             percent, compact (\"1.2K\"), decimals\n *\n * The real number is always there as text for screen readers\n * and copy and paste; the columns are only what you see.\n * ───────────────────────────────────────────────────────── */\n\nexport interface NumberRollProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  value: number;\n  /** Intl.NumberFormat options, e.g. { style: \"currency\", currency: \"USD\" }. */\n  format?: Intl.NumberFormatOptions;\n  locales?: string | string[];\n  prefix?: string;\n  suffix?: string;\n  /** Start from this value and roll to `value` once mounted, e.g. 0 for stats. */\n  from?: number;\n  /** Roll duration in ms. */\n  duration?: number;\n  /** Always roll this way, e.g. \"down\" for a countdown's seconds, which wrap from 00 to 59. Defaults to the way the number moved. */\n  direction?: \"up\" | \"down\";\n}\n\ntype Column = { key: string; char: string; digit: number | null };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst SETS = 5; // the strip repeats 0–9 five times so a roll never runs out of digits\nconst MIDDLE = 20;\n/** The strip as one text node, a digit a line: fifty lines, but one element to lay out instead of fifty. */\nconst STRIP = Array.from({ length: SETS * 10 }, (_, i) => i % 10).join(\"\\n\");\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Digits are keyed by their place counted from the right, so the units column stays the units column. */\nfunction columns(text: string): Column[] {\n  const chars = [...text];\n  const seen = new Map<string, number>();\n  let place = 0;\n  const out: Column[] = [];\n  for (let i = chars.length - 1; i >= 0; i--) {\n    const char = chars[i];\n    if (/\\d/.test(char))\n      out.push({ key: `d${place++}`, char, digit: Number(char) });\n    else {\n      // Symbols are keyed by how many of the same symbol sit to their right, so a comma that shifts is the same comma.\n      const n = seen.get(char) ?? 0;\n      seen.set(char, n + 1);\n      out.push({ key: `s${char}${n}`, char, digit: null });\n    }\n  }\n  return out.reverse();\n}\n\n// Memoised: a parent that re-renders with the same number doesn't rebuild the strips.\nconst Digit = React.memo(function Digit({\n  digit,\n  trend,\n  duration,\n  reduced,\n  rollIn,\n}: {\n  digit: number;\n  trend: number;\n  duration: number;\n  reduced: boolean;\n  rollIn: boolean;\n}) {\n  const [pos, setPos] = React.useState(MIDDLE + (rollIn ? 0 : digit));\n  const [moving, setMoving] = React.useState(false);\n  const posRef = React.useRef(pos);\n  const stripRef = React.useRef<HTMLSpanElement>(null);\n\n  React.useLayoutEffect(() => {\n    const current = posRef.current;\n    const showing = ((current % 10) + 10) % 10;\n    if (showing === digit) return;\n    if (reduced) {\n      posRef.current = MIDDLE + digit;\n      setMoving(false);\n      setPos(MIDDLE + digit);\n      return;\n    }\n    const up = trend > 0 || (trend === 0 && digit > showing);\n    let target = up\n      ? current + ((digit - showing + 10) % 10)\n      : current - ((showing - digit + 10) % 10);\n    // Values arriving faster than a roll (a progress percent) never let it re-centre, so before it runs off the strip,\n    // jump the strip back by whole sets mid-roll (it looks identical) and roll on from there.\n    if (target < 10 || target > SETS * 10 - 11) {\n      const shift = Math.round((target - MIDDLE) / 10) * 10;\n      const strip = stripRef.current;\n      if (strip?.offsetHeight) {\n        let visual = current;\n        try {\n          visual =\n            -new DOMMatrixReadOnly(getComputedStyle(strip).transform).m42 /\n            (strip.offsetHeight / (SETS * 10));\n        } catch {}\n        const transition = strip.style.transition;\n        strip.style.transition = \"none\";\n        strip.style.transform = `translateY(${(-(visual - shift) * 100) / (SETS * 10)}%)`;\n        void strip.offsetHeight;\n        strip.style.transition = transition;\n      }\n      target -= shift;\n    }\n    posRef.current = target;\n    setMoving(true);\n    setPos(target);\n  }, [digit, trend, reduced]);\n\n  // After a roll, quietly re-centre on the middle set so the next roll always has room.\n  const settle = () => {\n    const centred = MIDDLE + (((posRef.current % 10) + 10) % 10);\n    posRef.current = centred;\n    setMoving(false);\n    setPos(centred);\n  };\n\n  return (\n    <span className=\"relative inline-block [clip-path:inset(0)]\">\n      <span className=\"invisible\">{digit}</span>\n      <span\n        ref={stripRef}\n        aria-hidden=\"true\"\n        onTransitionEnd={settle}\n        className=\"absolute inset-x-0 top-0 block whitespace-pre text-center\"\n        style={{\n          transform: `translateY(${(-pos * 100) / (SETS * 10)}%)`,\n          transition: moving ? `transform ${duration}ms ${EASE}` : \"none\",\n        }}\n      >\n        {STRIP}\n      </span>\n    </span>\n  );\n});\n\n/** A place that appeared after the first paint slides open; places that were there from the start just sit. */\nfunction Place({\n  enter,\n  children,\n}: {\n  enter: boolean;\n  children: React.ReactNode;\n}) {\n  const [entering] = React.useState(enter);\n  return (\n    <span\n      className={`inline-block ${entering ? \"[clip-path:inset(0)] animate-[ui-col-in_500ms_cubic-bezier(0.16,1,0.3,1)_both]\" : \"\"}`}\n    >\n      {children}\n    </span>\n  );\n}\n\nexport function NumberRoll({\n  value,\n  format,\n  locales,\n  prefix = \"\",\n  suffix = \"\",\n  from,\n  duration = 900,\n  direction,\n  className = \"\",\n  ...props\n}: NumberRollProps) {\n  const reduced = useReducedMotion();\n  const [shown, setShown] = React.useState(from ?? value);\n  const previous = React.useRef(shown);\n  const mounted = React.useRef(false);\n\n  // Roll from `from` to the real value once on screen (a frame later, so the start is painted).\n  React.useEffect(() => {\n    const frame = requestAnimationFrame(() => setShown(value));\n    return () => cancelAnimationFrame(frame);\n  }, [value]);\n\n  React.useEffect(() => {\n    mounted.current = true;\n  }, []);\n\n  const formatter = React.useMemo(\n    () => new Intl.NumberFormat(locales, format),\n    [locales, format && JSON.stringify(format)],\n  );\n  const text = `${prefix}${formatter.format(shown)}${suffix}`;\n  const cols = React.useMemo(() => columns(text), [text]);\n  const trend =\n    direction === \"up\"\n      ? 1\n      : direction === \"down\"\n        ? -1\n        : Math.sign(shown - previous.current);\n\n  // Places that disappear fold away instead of vanishing.\n  const [leaving, setLeaving] = React.useState<Column[]>([]);\n  const lastCols = React.useRef(cols);\n  React.useLayoutEffect(() => {\n    const gone = lastCols.current.filter(\n      (c) => !cols.some((n) => n.key === c.key),\n    );\n    lastCols.current = cols;\n    previous.current = shown;\n    if (!gone.length || reduced) return;\n    setLeaving(gone);\n    const timer = window.setTimeout(() => setLeaving([]), 420);\n    return () => window.clearTimeout(timer);\n  }, [cols, shown, reduced]);\n\n  return (\n    <span className={`inline-flex tabular-nums ${className}`} {...props}>\n      <span className=\"sr-only\">{`${prefix}${formatter.format(value)}${suffix}`}</span>\n      <span\n        aria-hidden=\"true\"\n        className=\"inline-flex items-baseline whitespace-pre\"\n      >\n        {leaving.map((c) => (\n          <span\n            key={`out-${c.key}`}\n            className=\"inline-block [clip-path:inset(0)] animate-[ui-col-out_400ms_cubic-bezier(0.16,1,0.3,1)_forwards]\"\n          >\n            {c.char}\n          </span>\n        ))}\n        {cols.map((c) => (\n          <Place key={c.key} enter={mounted.current && !reduced}>\n            {c.digit === null ? (\n              c.char\n            ) : (\n              <Digit\n                digit={c.digit}\n                trend={trend}\n                duration={duration}\n                reduced={reduced}\n                rollIn={mounted.current}\n              />\n            )}\n          </Place>\n        ))}\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/text-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * TEXT MORPH: text that changes the way it should\n *\n *   shared   letters both texts share stay alive and slide to\n *            their new place (\"Save\" → \"Saving\" keeps \"Sav\")\n *   new      letters that weren't there rise in out of a blur,\n *            one after another\n *   gone     letters that leave lift away and blur out where\n *            they stood\n *   width    the box eases to its new width, so a button or\n *            pill holding it resizes with it\n *\n * Texts with little in common crossfade as a whole instead of\n * flinging single letters across. The real text is always\n * there for screen readers.\n * ───────────────────────────────────────────────────────── */\n\nexport interface TextMorphProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  children: string;\n  /** Morph time in ms. */\n  duration?: number;\n  /** Where new letters come from: below (\"up\") or above (\"down\"). */\n  direction?: \"up\" | \"down\";\n  /** Ease the box's width too; turn off for text that wraps. */\n  animateWidth?: boolean;\n}\n\ntype Glyph = { key: number; char: string };\ntype Leaving = Glyph & { x: number; y: number };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Keep the letters two texts share (longest common subsequence); everything else is new. */\nfunction morph(\n  previous: Glyph[],\n  text: string,\n  nextKey: () => number,\n): Glyph[] {\n  const a = previous.map((g) => g.char);\n  const b = Array.from(text);\n  const fresh = () => b.map((char) => ({ key: nextKey(), char }));\n  if (!a.length || !b.length) return fresh();\n\n  const dp = Array.from(\n    { length: a.length + 1 },\n    () => new Uint16Array(b.length + 1),\n  );\n  for (let i = a.length - 1; i >= 0; i--)\n    for (let j = b.length - 1; j >= 0; j--)\n      dp[i][j] =\n        a[i] === b[j]\n          ? dp[i + 1][j + 1] + 1\n          : Math.max(dp[i + 1][j], dp[i][j + 1]);\n\n  // Too little in common reads as two different words: crossfade them instead.\n  if (dp[0][0] < Math.min(a.length, b.length) * 0.5) return fresh();\n\n  const out: Glyph[] = [];\n  let i = 0;\n  let j = 0;\n  while (j < b.length) {\n    if (i < a.length && a[i] === b[j]) {\n      out.push(previous[i++]);\n      j++;\n    } else if (i < a.length && dp[i + 1][j] >= dp[i][j + 1]) i++;\n    else out.push({ key: nextKey(), char: b[j++] });\n  }\n  return out;\n}\n\nfunction LeavingGlyph({\n  glyph,\n  lift,\n  duration,\n  onDone,\n}: {\n  glyph: Leaving;\n  lift: number;\n  duration: number;\n  onDone: (key: number) => void;\n}) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const animation = el.animate(\n      [\n        { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n        { opacity: 0, filter: \"blur(4px)\", transform: `translateY(${lift}em)` },\n      ],\n      { duration: duration * 0.6, easing: EASE, fill: \"forwards\" },\n    );\n    animation.onfinish = () => onDone(glyph.key);\n    return () => animation.cancel();\n  }, [glyph.key, lift, duration, onDone]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden=\"true\"\n      className=\"pointer-events-none absolute whitespace-pre\"\n      style={{ left: glyph.x, top: glyph.y }}\n    >\n      {glyph.char}\n    </span>\n  );\n}\n\nexport function TextMorph({\n  children: text,\n  duration = 460,\n  direction = \"up\",\n  animateWidth = true,\n  className = \"\",\n  ...props\n}: TextMorphProps) {\n  const reduced = useReducedMotion();\n  const counter = React.useRef(text.length);\n  const nextKey = React.useCallback(() => ++counter.current, []);\n  const [glyphs, setGlyphs] = React.useState<Glyph[]>(() =>\n    Array.from(text).map((char, i) => ({ key: i + 1, char })),\n  );\n  const [leaving, setLeaving] = React.useState<Leaving[]>([]);\n  const rootRef = React.useRef<HTMLSpanElement>(null);\n  const els = React.useRef(new Map<number, HTMLSpanElement>());\n  const before = React.useRef<{\n    at: Map<number, { x: number; y: number }>;\n    width: number;\n  } | null>(null);\n  const rise = direction === \"up\" ? 0.35 : -0.35;\n\n  // A preference change must also finish an in-flight morph whose target text\n  // already matches the glyphs (including the empty label in a folded receipt).\n  React.useLayoutEffect(() => {\n    if (!reduced) return;\n    before.current = null;\n    const root = rootRef.current;\n    root\n      ?.getAnimations({ subtree: true })\n      .forEach((animation) => animation.cancel());\n    if (root) root.style.whiteSpace = \"\";\n    setLeaving((previous) => (previous.length ? [] : previous));\n  }, [reduced]);\n\n  // 1. The text changed: note where every letter stands, then work out which letters stay.\n  React.useLayoutEffect(() => {\n    if (text === glyphs.map((g) => g.char).join(\"\")) return;\n    const root = rootRef.current;\n    if (!root || reduced) {\n      setLeaving([]);\n      setGlyphs(Array.from(text).map((char) => ({ key: nextKey(), char })));\n      return;\n    }\n    const box = root.getBoundingClientRect();\n    const at = new Map<number, { x: number; y: number }>();\n    els.current.forEach((el, key) => {\n      const r = el.getBoundingClientRect();\n      at.set(key, { x: r.left - box.left, y: r.top - box.top });\n    });\n    before.current = { at, width: box.width };\n    const next = morph(glyphs, text, nextKey);\n    const kept = new Set(next.map((g) => g.key));\n    setLeaving((l) => [\n      ...l,\n      ...glyphs\n        .filter((g) => !kept.has(g.key))\n        .map((g) => ({ ...g, ...(at.get(g.key) ?? { x: 0, y: 0 }) })),\n    ]);\n    setGlyphs(next);\n  }, [text, reduced]);\n\n  // 2. The new letters are in place: glide the ones that stayed, raise the new ones, ease the width.\n  React.useLayoutEffect(() => {\n    const prev = before.current;\n    const root = rootRef.current;\n    if (!prev || !root) return;\n    before.current = null;\n    const box = root.getBoundingClientRect();\n    let order = 0;\n    for (const g of glyphs) {\n      const el = els.current.get(g.key);\n      if (!el) continue;\n      const from = prev.at.get(g.key);\n      if (from) {\n        const r = el.getBoundingClientRect();\n        const dx = from.x - (r.left - box.left);\n        const dy = from.y - (r.top - box.top);\n        if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5)\n          el.animate(\n            [\n              { transform: `translate(${dx}px, ${dy}px)` },\n              { transform: \"none\" },\n            ],\n            { duration, easing: EASE },\n          );\n      } else {\n        el.animate(\n          [\n            {\n              opacity: 0,\n              filter: \"blur(4px)\",\n              transform: `translateY(${rise}em)`,\n            },\n            { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n          ],\n          {\n            duration,\n            easing: EASE,\n            delay: Math.min(order++ * 16, 160),\n            fill: \"backwards\",\n          },\n        );\n      }\n    }\n    if (animateWidth && Math.abs(prev.width - box.width) > 0.5) {\n      // Hold the words on one line while the box is narrower than them, or \"No credits left\" would wrap mid-morph.\n      root.style.whiteSpace = \"nowrap\";\n      const resize = root.animate(\n        [{ width: `${prev.width}px` }, { width: `${box.width}px` }],\n        { duration, easing: EASE },\n      );\n      resize.onfinish = resize.oncancel = () => {\n        root.style.whiteSpace = \"\";\n      };\n    }\n  }, [glyphs, duration, rise, animateWidth]);\n\n  const done = React.useCallback(\n    (key: number) => setLeaving((l) => l.filter((g) => g.key !== key)),\n    [],\n  );\n\n  // Words stay unbroken; lines may only wrap at spaces.\n  const words: Glyph[][] = [];\n  for (const g of glyphs) {\n    if (\n      g.char === \" \" ||\n      !words.length ||\n      words[words.length - 1][0]?.char === \" \"\n    )\n      words.push([g]);\n    else words[words.length - 1].push(g);\n  }\n\n  return (\n    <span\n      ref={rootRef}\n      className={`relative inline-block ${className}`}\n      {...props}\n    >\n      <span className=\"sr-only\">{text}</span>\n      {words.map((word, w) => (\n        <span\n          key={w}\n          aria-hidden=\"true\"\n          className=\"inline-block whitespace-pre\"\n        >\n          {word.map((g) => (\n            <span\n              key={g.key}\n              ref={(el) => {\n                if (el) els.current.set(g.key, el);\n                else els.current.delete(g.key);\n              }}\n              className=\"inline-block\"\n            >\n              {g.char}\n            </span>\n          ))}\n        </span>\n      ))}\n      {leaving.map((g) => (\n        <LeavingGlyph\n          key={`out-${g.key}`}\n          glyph={g}\n          lift={-rise}\n          duration={duration}\n          onDone={done}\n        />\n      ))}\n    </span>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {
    "@keyframes ui-col-in": {
      "from": {
        "max-width": "0",
        "opacity": "0"
      },
      "to": {
        "max-width": "1em",
        "opacity": "1"
      }
    },
    "@keyframes ui-col-out": {
      "from": {
        "max-width": "1em",
        "opacity": "1"
      },
      "to": {
        "max-width": "0",
        "opacity": "0"
      }
    },
    "@keyframes ui-sheen": {
      "from": {
        "mask-position": "150% 0"
      },
      "to": {
        "mask-position": "-50% 0"
      }
    },
    "@keyframes ui-breathe": {
      "0%, 100%": {
        "transform": "scale(0.82)",
        "opacity": "0.55"
      },
      "50%": {
        "transform": "scale(1)",
        "opacity": "1"
      }
    },
    "@keyframes ui-drop-in": {
      "from": {
        "opacity": "0",
        "transform": "translateY(-8px) scale(0.6)"
      },
      "to": {
        "opacity": "1",
        "transform": "none"
      }
    }
  },
  "meta": {
    "cavemio": {
      "component": "web-research",
      "exportName": "WebResearch",
      "categories": [
        "ai"
      ],
      "isNew": false,
      "usage": "import { WebResearch } from \"@/components/web-research\";\n\n<WebResearch status=\"reading\" queries={[\"annual plan discount benchmarks\"]} sources={[{ url, title }]} />",
      "accessibility": "- A polite status region beside the row reads \"Searching for …\", \"Read 6 sites\", then the finished summary. The counts and words are real text for screen readers; the rolling digits are hidden from them.\n- The row is one button from start to finish, disabled while the agent works, so nothing remounts and every piece can morph. Once done it has aria-expanded; the list is hidden from assistive tech and the tab order while folded.\n- The sweep of light is a moving mask, so it also covers letters that are mid-morph. Installs Number roll and Text morph alongside it.\n- Every source is a real link that opens in a new tab, so people can check the agent’s reading.\n- With reduced motion the query appears whole, there is no sweep, nothing rolls or slides, and the list opens instantly.",
      "previewNote": "Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.",
      "documentation": {
        "props": [
          {
            "name": "status",
            "type": "\"searching\" | \"reading\" | \"done\" | \"error\" | \"cancelled\"",
            "description": "– · Where the run is."
          },
          {
            "name": "queries",
            "type": "(string | ResearchQuery)[]",
            "description": "– · Searches so far; the last one types in while searching. As { text, site?, siteIcon?, results?, resultLabel? } a search shows its site’s mark and its count on the trail."
          },
          {
            "name": "sources",
            "type": "{ url; title?; favicon?; query? }[]",
            "description": "– · Pages read, in order. Without a favicon, a monogram tinted from the site name; query (the index of the search that found it) groups it on the trail."
          },
          {
            "name": "open / defaultOpen / onOpenChange",
            "type": "boolean / boolean / (open) => void",
            "description": "– · Whether the finished run shows its list."
          }
        ],
        "useCases": [
          {
            "title": "AI search and answer tools",
            "description": "Show the pages being read while an answer is prepared."
          },
          {
            "title": "Deep research agents",
            "description": "The searches an agent ran and the sources it read, kept after it finishes."
          },
          {
            "title": "Support and docs assistants",
            "description": "Show which pages were searched before the assistant replied."
          },
          {
            "title": "Market and competitor research",
            "description": "A trail of searches per site, with each result a link."
          }
        ],
        "features": [
          {
            "title": "The search types in",
            "description": "“Searching” carries a sweep of light next to the live query as it types."
          },
          {
            "title": "Pages stack up as they are read",
            "description": "Each page drops its icon into an overlapping stack and its title rises in. The label becomes “Reading” and the site count rolls."
          },
          {
            "title": "It folds into a summary",
            "description": "The same line rearranges into “3 searches · 9 sources”, with a chevron that opens the full list."
          },
          {
            "title": "A trail of searches",
            "description": "Each search is a row with its result count, and pages that say which search found them sit under it."
          },
          {
            "title": "Every source is a link",
            "description": "Pages open in a new tab, so people can check what the agent read."
          },
          {
            "title": "Failed and stopped runs",
            "description": "It reads “Search failed” or “Stopped after 2 searches”, and still lists anything found before."
          }
        ],
        "states": [
          {
            "title": "searching",
            "description": "A 1.4s sweep of light crosses \"Searching\" and the newest query opens in after it, typing as it goes."
          },
          {
            "title": "reading",
            "description": "The label morphs to \"Reading\" and \"7 sites\" rolls. Each page’s icon drops into the stack (four shown; the oldest folds away over 420ms and +N rolls) and its title rises out of a 4px blur as the last one lifts off."
          },
          {
            "title": "done",
            "description": "The same line rearranges into \"3 searches · 9 sources\": pieces open and fold over 460ms, counts roll, \"sites\" morphs to \"sources\", the title row folds shut and a chevron opens in. It opens into the queries and the page list."
          },
          {
            "title": "error",
            "description": "The label morphs to \"Search failed\" in red, still counting and listing anything found before it failed."
          },
          {
            "title": "cancelled",
            "description": "\"Stopped after 2 searches\", with what was found."
          },
          {
            "title": "trail",
            "description": "Opened, each search is a row on a thin line trail with its count (\"12 threads\"). A search on one site wears that site’s mark and reads \"Searched Threadly for …\" with the query in mono. Pages that say which search found them sit under it as up to five overlapping marks on a branch; the chevron folds them open into links (380ms). Pages without a search are listed after the trail."
          }
        ]
      }
    }
  },
  "type": "registry:component"
}