{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-chat",
  "title": "AI Chat",
  "description": "The complete Shipbits chat and agent frontend, with a local demo adapter.",
  "dependencies": [
    "@base-ui/react@^1.9.0",
    "@shadcn/react@^0.3.1",
    "class-variance-authority@^0.7.1",
    "cn@^0.4.0",
    "lucide-react@^1.56.0",
    "react-markdown@^10.1.0",
    "remark-gfm@^4.0.1",
    "shiki@^4.5.0",
    "tw-animate-css@^1.4.0"
  ],
  "files": [
    {
      "path": "components/ai-chat/atoms.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useRef, useState, type ReactElement } from \"react\"\nimport { Check, Copy, FileText, AudioLines, X, ChevronDown } from \"lucide-react\"\nimport { Button } from \"../ui/button\"\nimport { cn } from \"cn\"\nimport {\n  Attachment,\n  AttachmentContent,\n  AttachmentTitle,\n  AttachmentDescription,\n  AttachmentMedia,\n  AttachmentAction,\n} from \"../ui/attachment\"\nimport {\n  DropdownMenu,\n  DropdownMenuTrigger,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuItem,\n} from \"../ui/dropdown-menu\"\nimport { avatarPixels } from \"./state\"\nimport type { ChatAttachment } from \"./types\"\n\nexport function AgentAvatar({\n  seed = \"shipbits\",\n  active = false,\n}: {\n  seed?: string\n  active?: boolean\n}): ReactElement {\n  const pixels = avatarPixels(seed)\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 25 25\"\n      className=\"size-7 shrink-0 rounded-full data-[active=true]:animate-[sb-chat-avatar_6s_ease-in-out_infinite] motion-reduce:animate-none\"\n      data-active={active}\n    >\n      {pixels.map((pixel, index) => (\n        <rect\n          key={index}\n          x={(index % 5) * 5}\n          y={Math.floor(index / 5) * 5}\n          width=\"5\"\n          height=\"5\"\n          fill={`hsl(${210 + (pixel % 100)} ${45 + (pixel % 25)}% ${32 + (pixel % 45)}%)`}\n        />\n      ))}\n    </svg>\n  )\n}\n\nexport function CopyAction({\n  text,\n  label = \"Copy\",\n  compact = false,\n}: {\n  text: string\n  label?: string\n  compact?: boolean\n}): ReactElement {\n  const [state, setState] = useState<\"idle\" | \"copied\" | \"failed\">(\"idle\")\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null)\n  const mounted = useRef(true)\n  useEffect(() => {\n    mounted.current = true\n    return () => {\n      mounted.current = false\n      if (timer.current) clearTimeout(timer.current)\n    }\n  }, [])\n  async function copy(): Promise<void> {\n    try {\n      await navigator.clipboard.writeText(text)\n      if (!mounted.current) return\n      setState(\"copied\")\n    } catch {\n      if (!mounted.current) return\n      setState(\"failed\")\n    }\n    if (timer.current) clearTimeout(timer.current)\n    timer.current = setTimeout(() => setState(\"idle\"), 2200)\n  }\n  return (\n    <span className=\"inline-flex items-center gap-1.5\">\n      <Button\n        type=\"button\"\n        variant=\"ghost\"\n        size={compact ? \"icon-xs\" : \"sm\"}\n        title={state === \"copied\" ? \"Copied\" : label}\n        aria-label={state === \"copied\" ? \"Copied\" : label}\n        onClick={() => void copy()}\n      >\n        {state === \"copied\" ? (\n          <Check data-icon=\"inline-start\" />\n        ) : (\n          <Copy data-icon=\"inline-start\" />\n        )}\n        {!compact && (state === \"copied\" ? \"Copied\" : label)}\n      </Button>\n      <span\n        role=\"status\"\n        className={state === \"failed\" ? \"text-xs text-destructive\" : \"sr-only\"}\n      >\n        {state === \"failed\"\n          ? \"Copy unavailable. Select the text to copy.\"\n          : state === \"copied\"\n            ? \"Copied to clipboard\"\n            : \"\"}\n      </span>\n    </span>\n  )\n}\n\nexport function Choice({\n  value,\n  label,\n  options,\n  onChange,\n  disabled = false,\n}: {\n  value: string\n  label: string\n  options: { id: string; label: string; description?: string }[]\n  onChange: (value: string) => void\n  disabled?: boolean\n}): ReactElement {\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        disabled={disabled}\n        render={<Button variant=\"ghost\" size=\"sm\" />}\n        aria-label={`${label}: ${options.find((item) => item.id === value)?.label ?? value}`}\n      >\n        {options.find((item) => item.id === value)?.label ?? value}\n        <ChevronDown data-icon=\"inline-end\" />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent\n        side=\"top\"\n        align=\"start\"\n        className=\"min-w-44 motion-reduce:animate-none! motion-reduce:transition-none! motion-reduce:[&_*]:animate-none! motion-reduce:[&_*]:scroll-auto! motion-reduce:[&_*]:transition-none! motion-reduce:[&_*::before]:animate-none! motion-reduce:[&_*::before]:transition-none!\"\n      >\n        <DropdownMenuGroup aria-label={label}>\n          {options.map((option) => (\n            <DropdownMenuItem\n              key={option.id}\n              onClick={() => onChange(option.id)}\n            >\n              <span className=\"flex flex-1 flex-col gap-0.5\">\n                <span>{option.label}</span>\n                {option.description && (\n                  <span className=\"text-xs text-muted-foreground\">\n                    {option.description}\n                  </span>\n                )}\n              </span>\n              {option.id === value && <Check aria-hidden=\"true\" />}\n            </DropdownMenuItem>\n          ))}\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  )\n}\n\nfunction AudioPreview({\n  attachment,\n}: {\n  attachment: ChatAttachment\n}): ReactElement | null {\n  const audio = useRef<HTMLAudioElement>(null)\n  useEffect(() => {\n    if (!attachment.file || attachment.url) return\n    const url = URL.createObjectURL(attachment.file)\n    if (audio.current) audio.current.src = url\n    return () => URL.revokeObjectURL(url)\n  }, [attachment.file, attachment.url])\n  return (\n    <audio\n      ref={audio}\n      controls\n      preload=\"metadata\"\n      src={attachment.url}\n      aria-label={`Play ${attachment.name}`}\n      className=\"h-8 w-full min-w-0\"\n    />\n  )\n}\n\nexport function AttachmentList({\n  attachments,\n  onRemove,\n}: {\n  attachments: ChatAttachment[]\n  onRemove?: (id: string) => void\n}): ReactElement {\n  return (\n    <div className=\"flex min-w-0 flex-wrap gap-2\">\n      {attachments.map((attachment) => (\n        <Attachment\n          key={attachment.id}\n          size=\"xs\"\n          className=\"max-w-full\"\n          state=\"done\"\n        >\n          <AttachmentMedia>\n            {attachment.mediaType.startsWith(\"audio/\") ? (\n              <AudioLines aria-hidden=\"true\" />\n            ) : (\n              <FileText aria-hidden=\"true\" />\n            )}\n          </AttachmentMedia>\n          <AttachmentContent>\n            <AttachmentTitle>{attachment.name}</AttachmentTitle>\n            <AttachmentDescription>\n              {attachment.size < 1024 * 1024\n                ? `${Math.max(1, Math.round(attachment.size / 1024))} KB`\n                : `${(attachment.size / 1024 / 1024).toFixed(1)} MB`}\n            </AttachmentDescription>\n          </AttachmentContent>\n          {onRemove && (\n            <AttachmentAction\n              type=\"button\"\n              aria-label={`Remove ${attachment.name}`}\n              onClick={() => onRemove(attachment.id)}\n            >\n              <X />\n            </AttachmentAction>\n          )}\n          {attachment.mediaType.startsWith(\"audio/\") && (\n            <div className=\"w-full min-w-0 px-2 pb-2\">\n              <AudioPreview attachment={attachment} />\n            </div>\n          )}\n        </Attachment>\n      ))}\n    </div>\n  )\n}\n\nexport function ChatLoader({\n  label = \"Thinking\",\n  variant = \"dots\",\n}: {\n  label?: string\n  variant?: \"dots\" | \"bar\" | \"grid\"\n}): ReactElement {\n  const [seconds, setSeconds] = useState(0)\n  useEffect(() => {\n    const began = Date.now()\n    const timer = setInterval(\n      () => setSeconds(Math.floor((Date.now() - began) / 1000)),\n      1000\n    )\n    return () => clearInterval(timer)\n  }, [])\n  return (\n    <div\n      className=\"flex items-center gap-2 text-xs text-muted-foreground\"\n      aria-label={label}\n    >\n      <span>{label}</span>\n      <span\n        className={cn(\n          \"inline-flex items-center gap-[3px] [&_i]:block [&_i]:size-[3px] [&_i]:animate-[sb-chat-pulse_1.4s_ease-in-out_infinite] [&_i]:rounded-full [&_i]:bg-current [&_i]:motion-reduce:animate-none\",\n          variant === \"grid\" &&\n            \"grid grid-cols-[repeat(3,3px)] gap-0.5 [&_i]:rounded-[1px]\",\n          variant === \"bar\" &&\n            \"h-[3px] w-11 overflow-hidden rounded-[3px] bg-border [&_i]:h-[3px] [&_i]:w-4 [&_i]:animate-[sb-chat-sweep_1.7s_ease-in-out_infinite]\"\n        )}\n        aria-hidden=\"true\"\n      >\n        {Array.from(\n          { length: variant === \"grid\" ? 9 : variant === \"bar\" ? 1 : 3 },\n          (_, index) => (\n            <i key={index} style={{ animationDelay: `${index * 110}ms` }} />\n          )\n        )}\n      </span>\n      <span className=\"tabular-nums\" aria-hidden=\"true\">\n        {seconds}s\n      </span>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/atoms.tsx"
    },
    {
      "path": "components/ai-chat/composer.tsx",
      "content": "\"use client\"\n\nimport {\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  type ReactElement,\n  type Dispatch,\n  type SetStateAction,\n} from \"react\"\nimport { ArrowUp, Square, Plus, Mic, X, AudioLines } from \"lucide-react\"\nimport { Button } from \"../ui/button\"\nimport {\n  InputGroup,\n  InputGroupTextarea,\n  InputGroupAddon,\n} from \"../ui/input-group\"\nimport { AttachmentList, Choice } from \"./atoms\"\nimport { validateAttachments } from \"./state\"\nimport { useRecording } from \"./use-recording\"\nimport type { AIChatProps, ChatAttachment, ChatMode } from \"./types\"\n\nexport function ChatComposer({\n  status,\n  models = [],\n  capabilities,\n  maxAttachments = 5,\n  maxAttachmentBytes = 10 * 1024 * 1024,\n  maxRecordingSeconds = 120,\n  onSubmit,\n  onStop,\n  toolbar,\n  draft,\n  onDraftChange: setDraft,\n  focusRequest,\n}: Pick<\n  AIChatProps,\n  | \"status\"\n  | \"models\"\n  | \"capabilities\"\n  | \"maxAttachments\"\n  | \"maxAttachmentBytes\"\n  | \"maxRecordingSeconds\"\n  | \"onSubmit\"\n  | \"onStop\"\n  | \"toolbar\"\n> & {\n  draft: string\n  onDraftChange: Dispatch<SetStateAction<string>>\n  focusRequest: number\n}): ReactElement {\n  const [attachments, setAttachments] = useState<ChatAttachment[]>([])\n  const [modelId, setModelId] = useState(models[0]?.id ?? \"\")\n  const [effort, setEffort] = useState(models[0]?.efforts?.[0] ?? \"\")\n  const [mode, setMode] = useState<ChatMode>(\"agent\")\n  const [error, setError] = useState(\"\")\n  const [submitting, setSubmitting] = useState(false)\n  const input = useRef<HTMLTextAreaElement>(null)\n  const files = useRef<HTMLInputElement>(null)\n  const mounted = useRef(true)\n  const id = useId()\n  const busy = status === \"submitted\" || status === \"streaming\"\n  const model = models.find((item) => item.id === modelId) ?? models[0]\n  const selectedEffort = model?.efforts?.includes(effort)\n    ? effort\n    : (model?.efforts?.[0] ?? \"\")\n\n  useEffect(() => {\n    mounted.current = true\n    return () => {\n      mounted.current = false\n    }\n  }, [])\n  useEffect(() => {\n    if (focusRequest) input.current?.focus()\n  }, [focusRequest])\n  useEffect(() => {\n    if (!input.current) return\n    input.current.style.height = \"auto\"\n    input.current.style.height = `${Math.min(input.current.scrollHeight, 216)}px`\n  }, [draft])\n\n  function addFiles(incoming: File[]): void {\n    const failure = validateAttachments(\n      attachments.length,\n      incoming,\n      maxAttachments,\n      maxAttachmentBytes\n    )\n    if (failure) {\n      setError(failure)\n      return\n    }\n    setError(\"\")\n    const added = incoming.map((file) => ({\n      id: crypto.randomUUID(),\n      name: file.name,\n      size: file.size,\n      mediaType: file.type,\n      file,\n    }))\n    setAttachments((current) => [...current, ...added])\n  }\n  const voice = useRecording((file) => addFiles([file]), maxRecordingSeconds)\n\n  async function submit(): Promise<void> {\n    if (\n      busy ||\n      submitting ||\n      voice.recording ||\n      voice.requesting ||\n      (!draft.trim() && !attachments.length)\n    )\n      return\n    setError(\"\")\n    setSubmitting(true)\n    try {\n      await onSubmit({\n        text: draft.trim(),\n        attachments,\n        modelId: model?.id ?? \"\",\n        effort: selectedEffort,\n        mode,\n      })\n      if (mounted.current) {\n        setDraft((current) => (current === draft ? \"\" : current))\n        const sentIds = new Set(attachments.map((attachment) => attachment.id))\n        setAttachments((current) =>\n          current.filter((attachment) => !sentIds.has(attachment.id))\n        )\n        input.current?.focus()\n      }\n    } catch {\n      if (mounted.current)\n        setError(\"Message was not sent. Your draft is still here. Try again.\")\n    } finally {\n      if (mounted.current) setSubmitting(false)\n    }\n  }\n\n  return (\n    <form\n      onSubmit={(event) => {\n        event.preventDefault()\n        void submit()\n      }}\n      className=\"relative rounded-[20px] bg-foreground/13 p-px before:pointer-events-none before:absolute before:-inset-px before:rounded-[inherit] before:bg-[conic-gradient(from_var(--sb-chat-angle),transparent_35%,#779bb766_46%,#9c91bc99_52%,#b5bc9e66_58%,transparent_69%)] before:opacity-0 before:transition-opacity before:duration-[400ms] before:content-[''] data-[active=true]:before:animate-[sb-chat-beam_8s_linear_infinite] data-[active=true]:before:opacity-80 before:motion-reduce:animate-none before:motion-reduce:transition-none\"\n      data-active={busy}\n    >\n      <input\n        ref={files}\n        type=\"file\"\n        multiple\n        hidden\n        aria-label=\"Attach files\"\n        onChange={(event) => {\n          addFiles(Array.from(event.target.files ?? []))\n          event.target.value = \"\"\n        }}\n      />\n      <InputGroup className=\"relative h-auto rounded-[19px] border-0 bg-[color-mix(in_oklab,var(--background)_96%,var(--foreground))]! opacity-100 shadow-[0_5px_22px_#0000000a]\">\n        {!!attachments.length && (\n          <InputGroupAddon align=\"block-start\">\n            <AttachmentList\n              attachments={attachments}\n              onRemove={(attachmentId) =>\n                setAttachments((current) =>\n                  current.filter((item) => item.id !== attachmentId)\n                )\n              }\n            />\n          </InputGroupAddon>\n        )}\n        <label htmlFor={id} className=\"sr-only\">\n          Message\n        </label>\n        <InputGroupTextarea\n          ref={input}\n          id={id}\n          value={draft}\n          placeholder=\"Ask something. Make something.\"\n          rows={2}\n          className=\"field-sizing-fixed max-h-[216px] min-h-[74px] px-4 pt-4 pb-2 text-[13px] leading-6 max-[480px]:text-base md:text-[13px]\"\n          aria-describedby={error || voice.error ? `${id}-error` : undefined}\n          onChange={(event) => setDraft(event.target.value)}\n          onKeyDown={(event) => {\n            if (\n              event.key === \"Enter\" &&\n              !event.shiftKey &&\n              !event.nativeEvent.isComposing &&\n              event.keyCode !== 229\n            ) {\n              event.preventDefault()\n              void submit()\n            }\n          }}\n        />\n        <InputGroupAddon\n          align=\"block-end\"\n          className=\"gap-1 px-2 pt-[5px] pb-2 [&_button]:text-[11px] max-[480px]:[&_button]:px-1.5 max-[480px]:[&_button]:text-[10px]\"\n        >\n          <div className=\"flex min-w-0 flex-wrap items-center gap-0.5\">\n            {capabilities?.mode !== false && (\n              <Choice\n                label=\"Mode\"\n                value={mode}\n                options={[\n                  { id: \"agent\", label: \"Agent\" },\n                  { id: \"chat\", label: \"Chat\" },\n                ]}\n                onChange={(value) => setMode(value as ChatMode)}\n                disabled={busy}\n              />\n            )}\n            {!!models.length && (\n              <Choice\n                label=\"Model\"\n                value={model?.id ?? \"\"}\n                options={models}\n                onChange={setModelId}\n                disabled={busy}\n              />\n            )}\n            {!!model?.efforts?.length && (\n              <Choice\n                label=\"Effort\"\n                value={selectedEffort}\n                options={model.efforts.map((item) => ({\n                  id: item,\n                  label: item,\n                }))}\n                onChange={setEffort}\n                disabled={busy}\n              />\n            )}\n            {toolbar}\n          </div>\n          <div className=\"ml-auto flex shrink-0 items-center gap-1\">\n            {capabilities?.attachments !== false && (\n              <Button\n                type=\"button\"\n                variant=\"ghost\"\n                size=\"icon-sm\"\n                title=\"Attach files\"\n                aria-label=\"Attach files\"\n                disabled={submitting}\n                onClick={() => files.current?.click()}\n              >\n                <Plus />\n              </Button>\n            )}\n            {capabilities?.recording !== false &&\n              !voice.recording &&\n              !voice.requesting && (\n                <Button\n                  type=\"button\"\n                  variant=\"ghost\"\n                  size=\"icon-sm\"\n                  title=\"Record voice note\"\n                  aria-label=\"Record voice note\"\n                  disabled={\n                    busy || submitting || attachments.length >= maxAttachments\n                  }\n                  onClick={() => void voice.start()}\n                >\n                  <Mic />\n                </Button>\n              )}\n            {busy && onStop ? (\n              <Button\n                type=\"button\"\n                size=\"icon-sm\"\n                aria-label=\"Stop response\"\n                onClick={() => {\n                  onStop()\n                  input.current?.focus()\n                }}\n              >\n                <Square />\n              </Button>\n            ) : (\n              <Button\n                type=\"submit\"\n                size=\"icon-sm\"\n                aria-label=\"Send message\"\n                disabled={\n                  busy ||\n                  submitting ||\n                  voice.recording ||\n                  voice.requesting ||\n                  (!draft.trim() && !attachments.length)\n                }\n              >\n                <ArrowUp />\n              </Button>\n            )}\n          </div>\n        </InputGroupAddon>\n        {(voice.recording || voice.requesting) && (\n          <InputGroupAddon align=\"block-end\" className=\"gap-2\">\n            <AudioLines aria-hidden=\"true\" />\n            <span className=\"text-xs tabular-nums\">\n              {voice.requesting\n                ? \"Waiting for microphone…\"\n                : `Recording ${Math.floor(voice.seconds / 60)}:${String(voice.seconds % 60).padStart(2, \"0\")}`}\n            </span>\n            {voice.recording && (\n              <Button\n                type=\"button\"\n                size=\"sm\"\n                variant=\"secondary\"\n                onClick={() => voice.stop()}\n              >\n                Finish recording\n              </Button>\n            )}\n            <Button\n              type=\"button\"\n              variant=\"ghost\"\n              size=\"icon-xs\"\n              aria-label=\"Cancel recording\"\n              onClick={() => voice.stop(true)}\n            >\n              <X />\n            </Button>\n          </InputGroupAddon>\n        )}\n      </InputGroup>\n      {(error || voice.error) && (\n        <p\n          role=\"alert\"\n          id={`${id}-error`}\n          className=\"mt-2 text-xs text-destructive\"\n        >\n          {error || voice.error}\n        </p>\n      )}\n    </form>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/composer.tsx"
    },
    {
      "path": "components/ai-chat/content.tsx",
      "content": "\"use client\"\n\nimport { memo, useEffect, useState, type ReactElement } from \"react\"\nimport Markdown from \"react-markdown\"\nimport remarkGfm from \"remark-gfm\"\nimport { ExternalLink, Globe, ChevronRight } from \"lucide-react\"\nimport {\n  Popover,\n  PopoverTrigger,\n  PopoverContent,\n  PopoverTitle,\n  PopoverDescription,\n} from \"../ui/popover\"\nimport {\n  Collapsible,\n  CollapsibleTrigger,\n  CollapsibleContent,\n} from \"../ui/collapsible\"\nimport { Button } from \"../ui/button\"\nimport { CopyAction } from \"./atoms\"\nimport type { ChatSource } from \"./types\"\nimport type { ThemedToken } from \"shiki\"\n\nexport const CodeBlock = memo(function CodeBlock({\n  code,\n  language = \"text\",\n}: {\n  code: string\n  language?: string\n}): ReactElement {\n  const [tokens, setTokens] = useState<{\n    code: string\n    lines: ThemedToken[][]\n  } | null>(null)\n  useEffect(() => {\n    let current = true\n    void import(\"./highlight\")\n      .then(({ highlight }) => highlight(code, language))\n      .then((lines) => {\n        if (current) setTokens({ code, lines })\n      })\n      .catch(() => {})\n    return () => {\n      current = false\n    }\n  }, [code, language])\n  return (\n    <div className=\"overflow-hidden rounded-xl border border-border/60 bg-[#121417] text-[#d9dce2] [&_button]:text-[#9b9faa]\">\n      <div className=\"flex items-center justify-between border-b border-white/8 px-3 py-1.5 text-[10px] text-white/45\">\n        <span>{language}</span>\n        <CopyAction text={code} compact label=\"Copy code block\" />\n      </div>\n      <pre className=\"max-h-80 overflow-auto p-3 text-xs leading-6\">\n        <code>\n          {tokens?.code === code\n            ? tokens.lines.map((line, index) => (\n                <span key={index} className=\"block min-h-6\">\n                  {line.map((token, tokenIndex) => (\n                    <span key={tokenIndex} style={{ color: token.color }}>\n                      {token.content}\n                    </span>\n                  ))}\n                </span>\n              ))\n            : code}\n        </code>\n      </pre>\n    </div>\n  )\n})\n\nexport function safeLink(url: string): string | undefined {\n  try {\n    const parsed = new URL(url)\n    return [\"https:\", \"http:\"].includes(parsed.protocol)\n      ? parsed.href\n      : undefined\n  } catch {\n    return undefined\n  }\n}\n\nfunction hostname(url: string): string {\n  try {\n    return new URL(url).hostname.replace(/^www\\./, \"\")\n  } catch {\n    return \"Source\"\n  }\n}\n\nexport function Citation({\n  source,\n  index,\n}: {\n  source: ChatSource\n  index: number\n}): ReactElement {\n  const href = safeLink(source.url)\n  return (\n    <Popover>\n      <PopoverTrigger\n        aria-label={`Source ${index}: ${source.title}`}\n        className=\"mx-0.5 inline-flex h-[15px] min-w-[15px] items-center justify-center rounded-[5px] border border-border bg-muted px-[3px] align-super text-[9px] leading-none text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n      >\n        {index}\n      </PopoverTrigger>\n      <PopoverContent\n        className=\"max-w-[calc(100vw-2rem)] motion-reduce:animate-none! motion-reduce:transition-none! motion-reduce:[&_*]:animate-none! motion-reduce:[&_*]:scroll-auto! motion-reduce:[&_*]:transition-none! motion-reduce:[&_*::before]:animate-none! motion-reduce:[&_*::before]:transition-none!\"\n        sideOffset={8}\n      >\n        <div className=\"flex items-center gap-2 text-[10px] text-muted-foreground\">\n          <Globe className=\"size-3\" aria-hidden=\"true\" />\n          {hostname(source.url)}\n        </div>\n        <PopoverTitle className=\"mt-2 text-sm\">{source.title}</PopoverTitle>\n        {source.description && (\n          <PopoverDescription className=\"mt-2 text-xs leading-relaxed\">\n            {source.description}\n          </PopoverDescription>\n        )}\n        {href && (\n          <a\n            href={href}\n            target=\"_blank\"\n            rel=\"noreferrer\"\n            className=\"mt-3 inline-flex items-center gap-2 rounded-sm text-xs underline underline-offset-4 focus-visible:outline-2\"\n          >\n            Open source\n            <ExternalLink className=\"size-3\" aria-hidden=\"true\" />\n          </a>\n        )}\n      </PopoverContent>\n    </Popover>\n  )\n}\n\nexport const RichText = memo(function RichText({\n  text,\n  sources = [],\n}: {\n  text: string\n  sources?: ChatSource[]\n}): ReactElement {\n  return (\n    <div className=\"text-[13px] leading-[1.85] [overflow-wrap:anywhere] [&_:not(pre)>code]:rounded [&_:not(pre)>code]:border [&_:not(pre)>code]:border-border [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-px [&_:not(pre)>code]:text-[.85em] [&_a]:underline [&_a]:underline-offset-[3px] [&_a]:focus-visible:outline-2 [&_a]:focus-visible:outline-offset-3 [&_a]:focus-visible:outline-ring [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground [&_h1]:text-[1.1em] [&_h1]:font-[550] [&_h1]:tracking-[-.02em] [&_h2]:text-[1.1em] [&_h2]:font-[550] [&_h2]:tracking-[-.02em] [&_h3]:text-[1.1em] [&_h3]:font-[550] [&_h3]:tracking-[-.02em] [&_li+li]:mt-[5px] [&_ol]:list-decimal [&_ol]:pl-5 [&_strong]:font-[550] [&_table]:block [&_table]:max-w-full [&_table]:border-collapse [&_table]:overflow-x-auto [&_table]:text-xs [&_td]:border-b [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:text-left [&_th]:border-b [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:text-left [&_ul]:list-disc [&_ul]:pl-5 [&>*+*]:mt-3\">\n      <Markdown\n        remarkPlugins={[remarkGfm]}\n        skipHtml\n        components={{\n          pre: ({ children }) => <>{children}</>,\n          code: ({ children, className }) => {\n            const content = String(children).replace(/\\n$/, \"\")\n            const language = /language-([\\w-]+)/.exec(className ?? \"\")?.[1]\n            return language || content.includes(\"\\n\") ? (\n              <CodeBlock code={content} language={language} />\n            ) : (\n              <code>{children}</code>\n            )\n          },\n          a: ({ href, children }) => {\n            const source = sources.find((item) => href === `#source-${item.id}`)\n            return source ? (\n              <Citation source={source} index={sources.indexOf(source) + 1} />\n            ) : (\n              <a href={href} target=\"_blank\" rel=\"noreferrer\">\n                {children}\n              </a>\n            )\n          },\n        }}\n      >\n        {text}\n      </Markdown>\n    </div>\n  )\n})\n\nexport function Sources({ sources }: { sources: ChatSource[] }): ReactElement {\n  return (\n    <Collapsible className=\"\">\n      <CollapsibleTrigger\n        render={<Button variant=\"ghost\" size=\"sm\" />}\n        className=\"group gap-2\"\n      >\n        <span className=\"flex -space-x-1\" aria-hidden=\"true\">\n          {sources.slice(0, 3).map((source, index) => (\n            <span\n              key={source.id}\n              className=\"flex size-4 items-center justify-center rounded-full border border-background bg-muted text-[8px]\"\n            >\n              {index + 1}\n            </span>\n          ))}\n        </span>\n        {sources.length} sources\n        <ChevronRight\n          className=\"transition-transform group-data-open:rotate-90 motion-reduce:transition-none\"\n          data-icon=\"inline-end\"\n        />\n      </CollapsibleTrigger>\n      <CollapsibleContent className=\"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 motion-reduce:transition-none data-closed:h-0 data-closed:opacity-0\">\n        <ul className=\"flex flex-col gap-3 pt-3\">\n          {sources.map((source, index) => (\n            <li key={source.id} className=\"flex items-start gap-3 text-xs\">\n              <span className=\"flex size-5 shrink-0 items-center justify-center rounded-md border border-border text-[10px] text-muted-foreground\">\n                {index + 1}\n              </span>\n              <div>\n                <a\n                  className=\"rounded-sm font-medium hover:underline focus-visible:outline-2\"\n                  href={safeLink(source.url)}\n                  target=\"_blank\"\n                  rel=\"noreferrer\"\n                >\n                  {source.title}\n                </a>\n                <p className=\"mt-1 text-[10px] text-muted-foreground\">\n                  {hostname(source.url)}\n                </p>\n              </div>\n            </li>\n          ))}\n        </ul>\n      </CollapsibleContent>\n    </Collapsible>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/content.tsx"
    },
    {
      "path": "components/ai-chat/demo-data.ts",
      "content": "import type { ArtifactPart, ChatMessage, ChatPart, ChatSource } from \"./types\"\n\nexport const demoSources: ChatSource[] = [\n  {\n    id: \"scroll\",\n    title: \"Message Scroller\",\n    url: \"https://ui.shadcn.com/docs/components/base/message-scroller\",\n    description:\n      \"Turn anchoring, streamed content, and preserving the reader’s position.\",\n  },\n  {\n    id: \"recording\",\n    title: \"MediaStream Recording API\",\n    url: \"https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_API\",\n    description:\n      \"Browser media recording and the lifecycle of a captured audio stream.\",\n  },\n]\n\nexport const releasePatch = `--- a/components/composer.tsx\n+++ b/components/composer.tsx\n@@ -18,5 +18,6 @@\n function handleKeyDown(event) {\n-  if (event.key === \"Enter\") {\n+  if (event.key === \"Enter\" && !event.shiftKey\n+      && !event.nativeEvent.isComposing) {\n     event.preventDefault()\n     sendMessage()\n   }\n`\n\nexport function releaseArtifact(approved: boolean): ArtifactPart {\n  const preview = `# Release review\\n\\n${approved ? \"Ready for a final human review.\" : \"Patch held for revision.\"}\\n\\n## Included in this review\\n\\n- Reviewed the composer’s keyboard behavior.\\n- Checked streaming and voice-note lifecycles.\\n- ${approved ? \"Accepted the proposed Enter-key guard in this local demonstration.\" : \"Kept the proposed change out of the local preview.\"}\\n\\n## Next check\\n\\n${approved ? \"Test Enter, Shift+Enter, and an active IME composition before shipping.\" : \"Revise the patch, then request another review.\"}\\n\\n_No repository files were changed. This is the pack’s scripted frontend example._`\n  return {\n    type: \"artifact\",\n    id: \"release-note\",\n    title: approved ? \"Release review.md\" : \"Revision notes.md\",\n    filename: approved ? \"release-review.md\" : \"revision-notes.md\",\n    code: preview,\n    preview,\n    language: \"markdown\",\n  }\n}\n\nexport function reviewParts(): ChatPart[] {\n  return [\n    {\n      type: \"text\",\n      id: \"summary\",\n      text: \"The release is close. I found one keyboard detail worth fixing before it ships.\\n\\n**Keep the reader in control.** The transcript should follow new output only while they’re at the live edge.[1](#source-scroll) Voice notes should finish as local attachments, with the microphone released afterward.[2](#source-recording)\",\n      sources: demoSources,\n    },\n    {\n      type: \"reasoning\",\n      id: \"reasoning\",\n      title: \"Reviewed interaction boundaries\",\n      status: \"success\",\n      detail:\n        \"Checked the supplied composer and transcript fixtures against their intended behavior. Focused on keyboard input, streaming interruptions, and recording cleanup.\",\n      elapsed: \"1.4s\",\n    },\n    {\n      type: \"tool\",\n      id: \"tool\",\n      title: \"inspect_component\",\n      status: \"success\",\n      args: '{\\n  \"component\": \"Composer\",\\n  \"checks\": [\"keyboard\", \"streaming\", \"recording\"]\\n}',\n      result:\n        \"Fixture inspection complete. One Enter-key guard is proposed below. No files were modified.\",\n      elapsed: \"0.8s\",\n    },\n    {\n      type: \"tasks\",\n      id: \"tasks\",\n      title: \"Release checklist\",\n      items: [\n        {\n          id: \"keyboard\",\n          label: \"Review keyboard and composition input\",\n          status: \"success\",\n        },\n        {\n          id: \"scroll\",\n          label: \"Check streaming and attachment boundaries\",\n          status: \"success\",\n        },\n        {\n          id: \"approval\",\n          label: \"Get approval for the proposed patch\",\n          status: \"pending\",\n        },\n      ],\n    },\n    {\n      type: \"diff\",\n      id: \"patch\",\n      filename: \"components/composer.tsx\",\n      patch: releasePatch,\n    },\n    {\n      type: \"approval\",\n      id: \"patch-approval\",\n      approveLabel: \"Approve patch\",\n      title: \"Apply this patch to the demo?\",\n      description:\n        \"Enter sends, Shift+Enter adds a line, and an active composition stays intact. Your decision updates this local preview only.\",\n    },\n    { type: \"sources\", id: \"sources\", sources: demoSources },\n  ]\n}\n\nexport function initialConversation(): ChatMessage[] {\n  return [\n    {\n      id: \"initial-user\",\n      role: \"user\",\n      createdAt: \"2026-10-19T09:41:00Z\",\n      parts: [\n        {\n          type: \"text\",\n          id: \"request\",\n          text: \"Review the release. Check the chat interactions and prepare a small patch if anything needs attention.\",\n        },\n      ],\n    },\n    {\n      id: \"initial-assistant\",\n      role: \"assistant\",\n      createdAt: \"2026-10-19T09:41:02Z\",\n      parts: reviewParts(),\n    },\n  ]\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/demo-data.ts"
    },
    {
      "path": "components/ai-chat/demo.tsx",
      "content": "\"use client\"\n\nimport {\n  useCallback,\n  useEffect,\n  useRef,\n  useState,\n  type ReactElement,\n} from \"react\"\nimport { RotateCcw, Plus } from \"lucide-react\"\nimport { Button } from \"../ui/button\"\nimport { AIChat } from \"../ui/ai-chat\"\nimport {\n  activeParts,\n  addVersion,\n  createRunGuard,\n  decideApproval,\n} from \"./state\"\nimport {\n  initialConversation,\n  releaseArtifact,\n  reviewParts,\n  demoSources,\n} from \"./demo-data\"\nimport type { ChatMessage, ChatPart, ChatStatus, ChatSubmission } from \"./types\"\n\nfunction wait(milliseconds: number, signal: AbortSignal): Promise<boolean> {\n  return new Promise((resolve) => {\n    if (signal.aborted) {\n      resolve(false)\n      return\n    }\n    const abort = (): void => {\n      clearTimeout(timer)\n      resolve(false)\n    }\n    const timer = setTimeout(() => {\n      signal.removeEventListener(\"abort\", abort)\n      resolve(true)\n    }, milliseconds)\n    signal.addEventListener(\"abort\", abort, { once: true })\n  })\n}\n\n/** A local demo adapter; AIChat itself never invents a response or calls a service. */\nexport function AIChatDemo(): ReactElement {\n  const [messages, setMessages] = useState<ChatMessage[]>(initialConversation)\n  const [status, setStatus] = useState<ChatStatus>(\"awaiting-approval\")\n  const [notice, setNotice] = useState(\"\")\n  const [resetKey, setResetKey] = useState(0)\n  const controller = useRef<AbortController | null>(null)\n  const guard = useRef(createRunGuard())\n  const snapshot = useRef(messages)\n  const decisions = useRef(new Set<string>())\n  useEffect(() => {\n    snapshot.current = messages\n  }, [messages])\n  useEffect(\n    () => () => {\n      controller.current?.abort()\n      guard.current.next()\n    },\n    []\n  )\n\n  const stop = useCallback((): void => {\n    controller.current?.abort()\n    guard.current.next()\n    const settle = (parts: ChatPart[]): ChatPart[] =>\n      parts.map((part) =>\n        (part.type === \"tool\" || part.type === \"reasoning\") &&\n        part.status === \"running\"\n          ? { ...part, status: \"pending\", title: `${part.title} · stopped` }\n          : part\n      )\n    setMessages((current) =>\n      current.map((message) =>\n        activeParts(message).some(\n          (part) =>\n            (part.type === \"tool\" || part.type === \"reasoning\") &&\n            part.status === \"running\"\n        )\n          ? message.versions\n            ? {\n                ...message,\n                versions: message.versions.map((version, index) =>\n                  index === (message.activeVersion ?? 0)\n                    ? { ...version, parts: settle(version.parts) }\n                    : version\n                ),\n              }\n            : { ...message, parts: settle(message.parts) }\n          : message\n      )\n    )\n    setStatus(\"idle\")\n  }, [])\n\n  async function streamResponse(\n    messageId: string,\n    parts: ChatPart[],\n    version?: number\n  ): Promise<void> {\n    controller.current?.abort()\n    const abort = new AbortController()\n    controller.current = abort\n    const run = guard.current.next()\n    const update = (next: ChatPart[]): void => {\n      if (!guard.current.isCurrent(run)) return\n      setMessages((current) =>\n        current.map((message) =>\n          message.id !== messageId\n            ? message\n            : version === undefined\n              ? { ...message, parts: next }\n              : {\n                  ...message,\n                  versions: message.versions?.map((item, index) =>\n                    index === version ? { ...item, parts: next } : item\n                  ),\n                }\n        )\n      )\n    }\n    setStatus(\"submitted\")\n    update([\n      {\n        type: \"reasoning\",\n        id: \"running-reasoning\",\n        title: \"Reviewing the supplied fixtures\",\n        status: \"running\",\n        detail: \"This demonstration uses a fixed local release-review fixture.\",\n      },\n    ])\n    if (!(await wait(650, abort.signal))) return\n    update([\n      {\n        type: \"tool\",\n        id: \"running-tool\",\n        title: \"inspect_component\",\n        status: \"running\",\n        args: '{ \"component\": \"Composer\" }',\n      },\n    ])\n    if (!(await wait(650, abort.signal))) return\n    setStatus(\"streaming\")\n    const text = parts.find((part) => part.type === \"text\")\n    if (text?.type === \"text\") {\n      const words = text.text.split(\" \")\n      for (let index = 4; index < words.length + 4; index += 4) {\n        update([{ ...text, text: words.slice(0, index).join(\" \") }])\n        if (!(await wait(65, abort.signal))) return\n      }\n    }\n    update(parts)\n    if (guard.current.isCurrent(run))\n      setStatus(\n        parts.some((part) => part.type === \"approval\" && !part.decision)\n          ? \"awaiting-approval\"\n          : \"idle\"\n      )\n  }\n\n  function submit(submission: ChatSubmission, clear = false): void {\n    stop()\n    const now = new Date().toISOString()\n    const id = crypto.randomUUID()\n    const user: ChatMessage = {\n      id: `${id}-user`,\n      role: \"user\",\n      createdAt: now,\n      parts: [\n        {\n          type: \"text\",\n          id: \"prompt\",\n          text: submission.text || \"Review this attachment.\",\n        },\n        ...(submission.attachments.length\n          ? [\n              {\n                type: \"attachments\" as const,\n                id: \"files\",\n                attachments: submission.attachments,\n              },\n            ]\n          : []),\n      ],\n    }\n    const assistant: ChatMessage = {\n      id,\n      role: \"assistant\",\n      createdAt: now,\n      parts: [],\n    }\n    setMessages((current) => [...(clear ? [] : current), user, assistant])\n    setNotice(\n      submission.attachments.length\n        ? \"Files stay in your browser. The scripted demo does not inspect their contents.\"\n        : \"\"\n    )\n    const parts: ChatPart[] =\n      submission.mode === \"agent\"\n        ? reviewParts()\n        : [\n            {\n              type: \"text\",\n              id: \"summary\",\n              text: \"This is the scripted chat response. For this release review, I would start with **keyboard behavior**, then check scrolling and microphone cleanup.[1](#source-scroll)\\n\\nYour application can stream any response into this same interface through controlled messages and status.\",\n              sources: demoSources,\n            },\n            { type: \"sources\", id: \"sources\", sources: demoSources },\n          ]\n    void streamResponse(id, parts)\n  }\n\n  function retry(messageId: string): void {\n    const original = snapshot.current.find(\n      (message) => message.id === messageId\n    )\n    if (!original) return\n    const next = addVersion(original, [], crypto.randomUUID())\n    const version = next.activeVersion ?? 0\n    setMessages((current) =>\n      current.map((message) => (message.id === messageId ? next : message))\n    )\n    const parts: ChatPart[] = [\n      {\n        type: \"text\",\n        id: \"alternate\",\n        text: \"Here’s a shorter version of the review: **protect input first, then preserve reading position.**\\n\\n1. Send only on Enter outside an active composition.\\n2. Keep Shift+Enter available for a new line.\\n3. Release microphone tracks when a voice note finishes.\\n\\nThe original response is preserved. Use the version arrows below to compare.\",\n        sources: demoSources,\n      },\n      releaseArtifact(false),\n    ]\n    void streamResponse(messageId, parts, version)\n  }\n\n  function approve(\n    messageId: string,\n    partId: string,\n    decision: \"approved\" | \"rejected\"\n  ): void {\n    const original = snapshot.current.find(\n      (message) => message.id === messageId\n    )\n    const key = `${messageId}-${original?.activeVersion ?? 0}-${partId}`\n    if (\n      !original ||\n      decisions.current.has(key) ||\n      activeParts(original).some(\n        (part) =>\n          part.id === partId && part.type === \"approval\" && part.decision\n      )\n    )\n      return\n    stop()\n    decisions.current.add(key)\n    const resolved = decideApproval(original, partId, decision)\n    const approved = decision === \"approved\"\n    const completeTasks = (parts: ChatPart[]): ChatPart[] =>\n      parts.map((part) =>\n        part.type === \"tasks\"\n          ? {\n              ...part,\n              items: part.items.map((item) =>\n                item.id === \"approval\"\n                  ? { ...item, status: approved ? \"success\" : \"error\" }\n                  : item\n              ),\n            }\n          : part\n      )\n    const updated = resolved.versions\n      ? {\n          ...resolved,\n          versions: resolved.versions.map((version, index) =>\n            index === (resolved.activeVersion ?? 0)\n              ? { ...version, parts: completeTasks(version.parts) }\n              : version\n          ),\n        }\n      : { ...resolved, parts: completeTasks(resolved.parts) }\n    const followup: ChatMessage = {\n      id: crypto.randomUUID(),\n      role: \"assistant\",\n      createdAt: new Date().toISOString(),\n      parts: [\n        {\n          type: \"text\",\n          id: \"decision-note\",\n          text: approved\n            ? \"Approved for the local preview. I’ve prepared the release review below; you can inspect, copy, or download it.\"\n            : \"Patch rejected. I’ve kept it out of the local preview and prepared revision notes instead.\",\n        },\n        releaseArtifact(approved),\n      ],\n    }\n    setMessages((current) => [\n      ...current.map((message) =>\n        message.id === messageId ? updated : message\n      ),\n      followup,\n    ])\n    setNotice(\n      approved\n        ? \"Patch accepted in this local demo. No project files changed.\"\n        : \"Patch rejected in this local demo.\"\n    )\n  }\n\n  function reset(): void {\n    stop()\n    setMessages([])\n    decisions.current.clear()\n    setNotice(\"\")\n    setResetKey((value) => value + 1)\n  }\n  return (\n    <div>\n      <div className=\"mb-3 flex flex-wrap items-center justify-between gap-2 px-1\">\n        <span className=\"text-[10px] text-muted-foreground\">\n          Scripted frontend demo · no AI service connected\n        </span>\n        <div className=\"flex items-center gap-1\">\n          <Button\n            type=\"button\"\n            variant=\"ghost\"\n            size=\"sm\"\n            onClick={() => {\n              reset()\n              submit(\n                {\n                  text: \"Review the release. Check the chat interactions and prepare a small patch.\",\n                  attachments: [],\n                  modelId: \"reasoning\",\n                  effort: \"Standard\",\n                  mode: \"agent\",\n                },\n                true\n              )\n            }}\n          >\n            <RotateCcw data-icon=\"inline-start\" />\n            Replay workflow\n          </Button>\n          <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={reset}>\n            <Plus data-icon=\"inline-start\" />\n            New chat\n          </Button>\n        </div>\n      </div>\n      <AIChat\n        key={resetKey}\n        messages={messages}\n        status={status}\n        title=\"Release workspace\"\n        description=\"Release review · Shipbits / chat\"\n        models={[\n          {\n            id: \"reasoning\",\n            label: \"Reasoning\",\n            description: \"Demo model configuration\",\n            efforts: [\"Standard\", \"Deep\"],\n          },\n          {\n            id: \"fast\",\n            label: \"Fast\",\n            description: \"Demo model configuration\",\n            efforts: [\"Low\", \"Standard\"],\n          },\n        ]}\n        suggestions={[\n          \"Review the release\",\n          \"Check the composer’s keyboard behavior\",\n          \"Prepare a launch note\",\n        ]}\n        onSubmit={submit}\n        onStop={stop}\n        onRetry={retry}\n        onApproval={approve}\n        onFeedback={(messageId, feedback) =>\n          setMessages((current) =>\n            current.map((message) =>\n              message.id === messageId\n                ? {\n                    ...message,\n                    feedback:\n                      message.feedback === feedback ? undefined : feedback,\n                  }\n                : message\n            )\n          )\n        }\n        onSelectVersion={(messageId, version) => {\n          stop()\n          setMessages((current) =>\n            current.map((message) =>\n              message.id === messageId && message.versions?.[version]\n                ? { ...message, activeVersion: version }\n                : message\n            )\n          )\n        }}\n        context={{ used: 1260 + messages.length * 180, limit: 32000 }}\n        onContextAction={reset}\n      />\n      <p\n        role=\"status\"\n        className=\"mt-3 min-h-4 px-1 text-[10px] text-muted-foreground\"\n      >\n        {notice}\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/demo.tsx"
    },
    {
      "path": "components/ai-chat/highlight.ts",
      "content": "import type { ThemedToken } from \"shiki\"\n\nconst cache = new Map<string, Promise<ThemedToken[][]>>()\nconst languages = {\n  tsx: () => import(\"shiki/langs/tsx.mjs\"),\n  typescript: () => import(\"shiki/langs/typescript.mjs\"),\n  javascript: () => import(\"shiki/langs/javascript.mjs\"),\n  json: () => import(\"shiki/langs/json.mjs\"),\n  css: () => import(\"shiki/langs/css.mjs\"),\n  bash: () => import(\"shiki/langs/bash.mjs\"),\n  diff: () => import(\"shiki/langs/diff.mjs\"),\n  markdown: () => import(\"shiki/langs/markdown.mjs\"),\n}\n\nasync function createHighlighter() {\n  const [{ createHighlighterCore }, { createJavaScriptRegexEngine }] =\n    await Promise.all([import(\"shiki/core\"), import(\"shiki/engine/javascript\")])\n  return createHighlighterCore({\n    themes: [import(\"shiki/themes/github-dark.mjs\")],\n    langs: [],\n    engine: createJavaScriptRegexEngine(),\n  })\n}\nlet highlighter: ReturnType<typeof createHighlighter> | undefined\n\nexport function highlight(\n  code: string,\n  language: string\n): Promise<ThemedToken[][]> {\n  const lang =\n    language === \"ts\"\n      ? \"typescript\"\n      : language === \"js\"\n        ? \"javascript\"\n        : language === \"sh\"\n          ? \"bash\"\n          : language\n  const key = `${lang}\\0${code}`\n  const existing = cache.get(key)\n  if (existing) return existing\n  const promise = (async () => {\n    highlighter ??= createHighlighter()\n    const engine = await highlighter\n    const load: (() => Promise<unknown>) | undefined = Object.hasOwn(\n      languages,\n      lang\n    )\n      ? languages[lang as keyof typeof languages]\n      : undefined\n    if (load && !engine.getLoadedLanguages().includes(lang))\n      await engine.loadLanguage(\n        await languages[lang as keyof typeof languages]()\n      )\n    return engine.codeToTokens(code, {\n      lang: load ? lang : \"text\",\n      theme: \"github-dark\",\n    }).tokens\n  })()\n  if (cache.size >= 32) cache.delete(cache.keys().next().value!)\n  cache.set(key, promise)\n  void promise.catch(() => {\n    cache.delete(key)\n    highlighter = undefined\n  })\n  return promise\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/highlight.ts"
    },
    {
      "path": "components/ai-chat/state.ts",
      "content": "import type { ChatAttachment, ChatMessage, ChatPart } from \"./types\"\n\nexport function activeParts(message: ChatMessage): ChatPart[] {\n  return message.versions?.[message.activeVersion ?? 0]?.parts ?? message.parts\n}\n\nexport function messageText(message: ChatMessage): string {\n  return activeParts(message)\n    .filter((part) => part.type === \"text\")\n    .map((part) => part.text)\n    .join(\"\\n\\n\")\n}\n\nexport function addVersion(\n  message: ChatMessage,\n  parts: ChatPart[],\n  id: string\n): ChatMessage {\n  const versions = [\n    ...(message.versions ?? [\n      { id: `${message.id}-original`, parts: message.parts },\n    ]),\n    { id, parts },\n  ]\n  return {\n    ...message,\n    versions,\n    activeVersion: versions.length - 1,\n    feedback: undefined,\n  }\n}\n\nexport function decideApproval(\n  message: ChatMessage,\n  partId: string,\n  decision: \"approved\" | \"rejected\"\n): ChatMessage {\n  const update = (parts: ChatPart[]): ChatPart[] =>\n    parts.map((part) =>\n      part.id === partId && part.type === \"approval\" && !part.decision\n        ? { ...part, decision }\n        : part\n    )\n  return message.versions\n    ? {\n        ...message,\n        versions: message.versions.map((version, index) =>\n          index === (message.activeVersion ?? 0)\n            ? { ...version, parts: update(version.parts) }\n            : version\n        ),\n      }\n    : { ...message, parts: update(message.parts) }\n}\n\nexport function validateAttachments(\n  current: number,\n  incoming: Pick<ChatAttachment, \"size\" | \"name\">[],\n  maxCount = 5,\n  maxBytes = 10 * 1024 * 1024\n): string | null {\n  if (current + incoming.length > maxCount)\n    return `You can attach up to ${maxCount} files.`\n  const oversized = incoming.find((file) => file.size > maxBytes)\n  return oversized\n    ? `${oversized.name} exceeds the ${Math.round(maxBytes / 1024 / 1024)} MB limit.`\n    : null\n}\n\nexport interface DiffLine {\n  kind: \"context\" | \"add\" | \"remove\" | \"header\"\n  text: string\n  oldLine?: number\n  newLine?: number\n}\nexport function parseDiff(patch: string): DiffLine[] {\n  let oldLine = 0\n  let newLine = 0\n  return patch.split(\"\\n\").map((text): DiffLine => {\n    const hunk = /^@@ -(\\d+)(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/.exec(text)\n    if (hunk) {\n      oldLine = Number(hunk[1])\n      newLine = Number(hunk[2])\n      return { kind: \"header\", text }\n    }\n    if (/^(---|\\+\\+\\+|diff |index |\\\\)/.test(text))\n      return { kind: \"header\", text }\n    if (text.startsWith(\"+\"))\n      return { kind: \"add\", text: text.slice(1), newLine: newLine++ }\n    if (text.startsWith(\"-\"))\n      return { kind: \"remove\", text: text.slice(1), oldLine: oldLine++ }\n    return {\n      kind: \"context\",\n      text: text.startsWith(\" \") ? text.slice(1) : text,\n      oldLine: oldLine++,\n      newLine: newLine++,\n    }\n  })\n}\n\nexport function avatarPixels(seed: string): number[] {\n  let hash = 2166136261\n  for (const letter of seed)\n    hash = Math.imul(hash ^ letter.charCodeAt(0), 16777619)\n  return Array.from({ length: 25 }, () => {\n    hash ^= hash << 13\n    hash ^= hash >>> 17\n    hash ^= hash << 5\n    return hash >>> 0\n  })\n}\n\n/** Invalidating a run prevents delayed work from changing a newer conversation. */\nexport function createRunGuard(): {\n  next: () => number\n  isCurrent: (id: number) => boolean\n} {\n  let current = 0\n  return { next: () => ++current, isCurrent: (id) => id === current }\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/state.ts"
    },
    {
      "path": "components/ai-chat/types.ts",
      "content": "import type { ReactNode } from \"react\"\n\nexport type ChatStatus =\n  \"idle\" | \"submitted\" | \"streaming\" | \"awaiting-approval\" | \"error\"\nexport type ActivityStatus = \"pending\" | \"running\" | \"success\" | \"error\"\nexport type ChatMode = \"chat\" | \"agent\"\nexport interface ChatAttachment {\n  id: string\n  name: string\n  size: number\n  mediaType: string\n  file?: File\n  url?: string\n}\nexport interface ChatSource {\n  id: string\n  title: string\n  url: string\n  description?: string\n}\nexport interface ChatModel {\n  id: string\n  label: string\n  description?: string\n  efforts?: string[]\n}\nexport interface TextPart {\n  type: \"text\"\n  id: string\n  text: string\n  sources?: ChatSource[]\n}\nexport interface ActivityPart {\n  type: \"reasoning\" | \"tool\"\n  id: string\n  title: string\n  status: ActivityStatus\n  detail?: string\n  args?: string\n  result?: string\n  elapsed?: string\n}\nexport interface TasksPart {\n  type: \"tasks\"\n  id: string\n  title: string\n  items: { id: string; label: string; status: ActivityStatus }[]\n}\nexport interface ApprovalPart {\n  type: \"approval\"\n  id: string\n  title: string\n  description: string\n  approveLabel?: string\n  rejectLabel?: string\n  decision?: \"approved\" | \"rejected\"\n}\nexport interface DiffPart {\n  type: \"diff\"\n  id: string\n  filename: string\n  patch: string\n}\nexport interface ArtifactPart {\n  type: \"artifact\"\n  id: string\n  title: string\n  language: string\n  code: string\n  preview?: string\n  imageUrl?: string\n  filename: string\n}\nexport interface SourcesPart {\n  type: \"sources\"\n  id: string\n  sources: ChatSource[]\n}\nexport interface AttachmentsPart {\n  type: \"attachments\"\n  id: string\n  attachments: ChatAttachment[]\n}\nexport type ChatPart =\n  | TextPart\n  | ActivityPart\n  | TasksPart\n  | ApprovalPart\n  | DiffPart\n  | ArtifactPart\n  | SourcesPart\n  | AttachmentsPart\nexport interface ChatVersion {\n  id: string\n  parts: ChatPart[]\n}\nexport interface ChatMessage {\n  id: string\n  role: \"user\" | \"assistant\"\n  createdAt: string\n  parts: ChatPart[]\n  versions?: ChatVersion[]\n  activeVersion?: number\n  feedback?: \"up\" | \"down\"\n}\nexport interface ChatSubmission {\n  text: string\n  attachments: ChatAttachment[]\n  modelId: string\n  effort: string\n  mode: ChatMode\n}\nexport interface ChatCapabilities {\n  attachments?: boolean\n  recording?: boolean\n  mode?: boolean\n  feedback?: boolean\n}\nexport interface AIChatProps {\n  messages: ChatMessage[]\n  status: ChatStatus\n  onSubmit: (submission: ChatSubmission) => void | Promise<void>\n  onStop?: () => void\n  onRetry?: (messageId: string) => void\n  onFeedback?: (messageId: string, feedback: \"up\" | \"down\") => void\n  onSelectVersion?: (messageId: string, version: number) => void\n  onApproval?: (\n    messageId: string,\n    partId: string,\n    decision: \"approved\" | \"rejected\"\n  ) => void | Promise<void>\n  onContextAction?: () => void\n  renderArtifact?: (artifact: ArtifactPart) => ReactNode\n  toolbar?: ReactNode\n  models?: ChatModel[]\n  suggestions?: string[]\n  capabilities?: ChatCapabilities\n  maxAttachments?: number\n  maxAttachmentBytes?: number\n  maxRecordingSeconds?: number\n  context?: { used: number; limit: number }\n  title?: string\n  description?: string\n  error?: string\n  className?: string\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/types.ts"
    },
    {
      "path": "components/ai-chat/use-recording.ts",
      "content": "\"use client\"\n\nimport { useCallback, useEffect, useRef, useState } from \"react\"\n\ninterface RecordingControls {\n  recording: boolean\n  requesting: boolean\n  seconds: number\n  error: string\n  start: () => Promise<void>\n  stop: (cancel?: boolean) => void\n}\n\nexport function useRecording(\n  onFinish: (file: File) => void,\n  maxSeconds: number\n): RecordingControls {\n  const [recording, setRecording] = useState(false)\n  const [requesting, setRequesting] = useState(false)\n  const [seconds, setSeconds] = useState(0)\n  const [error, setError] = useState(\"\")\n  const recorder = useRef<MediaRecorder | null>(null)\n  const stream = useRef<MediaStream | null>(null)\n  const timer = useRef<ReturnType<typeof setInterval> | null>(null)\n  const generation = useRef(0)\n  const finish = useRef(onFinish)\n  useEffect(() => {\n    finish.current = onFinish\n  }, [onFinish])\n\n  const release = useCallback((): void => {\n    if (timer.current) clearInterval(timer.current)\n    timer.current = null\n    stream.current?.getTracks().forEach((track) => track.stop())\n    stream.current = null\n  }, [])\n\n  const stop = useCallback(\n    (cancel = false): void => {\n      if (cancel) generation.current++\n      if (recorder.current?.state === \"recording\") recorder.current.stop()\n      release()\n      setRecording(false)\n      setRequesting(false)\n    },\n    [release]\n  )\n\n  useEffect(\n    () => () => {\n      generation.current++\n      if (recorder.current?.state === \"recording\") recorder.current.stop()\n      release()\n    },\n    [release]\n  )\n\n  async function start(): Promise<void> {\n    if (requesting || recording) return\n    if (\n      !navigator.mediaDevices?.getUserMedia ||\n      typeof MediaRecorder === \"undefined\"\n    ) {\n      setError(\n        \"Audio recording is unavailable in this browser. Attach an audio file instead.\"\n      )\n      return\n    }\n    const run = ++generation.current\n    setError(\"\")\n    setRequesting(true)\n    try {\n      const captured = await navigator.mediaDevices.getUserMedia({\n        audio: true,\n      })\n      if (run !== generation.current) {\n        captured.getTracks().forEach((track) => track.stop())\n        return\n      }\n      stream.current = captured\n      const mimeType = [\n        \"audio/webm;codecs=opus\",\n        \"audio/mp4\",\n        \"audio/ogg;codecs=opus\",\n      ].find((type) => MediaRecorder.isTypeSupported(type))\n      const media = new MediaRecorder(\n        captured,\n        mimeType ? { mimeType } : undefined\n      )\n      recorder.current = media\n      const chunks: Blob[] = []\n      media.ondataavailable = (event): void => {\n        if (event.data.size) chunks.push(event.data)\n      }\n      media.onstop = (): void => {\n        if (run !== generation.current) return\n        const type = media.mimeType || chunks[0]?.type || \"audio/webm\"\n        const blob = new Blob(chunks, { type })\n        if (blob.size)\n          finish.current(\n            new File(\n              [blob],\n              `Voice note.${type.includes(\"mp4\") ? \"m4a\" : type.includes(\"ogg\") ? \"ogg\" : \"webm\"}`,\n              { type }\n            )\n          )\n      }\n      media.onerror = (): void => {\n        if (run !== generation.current) return\n        setError(\"Recording failed. Please try again.\")\n        stop(true)\n      }\n      media.start(1000)\n      setSeconds(0)\n      setRecording(true)\n      setRequesting(false)\n      const began = Date.now()\n      timer.current = setInterval(() => {\n        const elapsed = Math.floor((Date.now() - began) / 1000)\n        setSeconds(elapsed)\n        if (elapsed >= maxSeconds) stop()\n      }, 250)\n    } catch (cause) {\n      if (run !== generation.current) return\n      release()\n      setRequesting(false)\n      setError(\n        cause instanceof DOMException && cause.name === \"NotAllowedError\"\n          ? \"Microphone access was denied. Allow it in your browser settings to record.\"\n          : \"Could not access a microphone. Check your device and try again.\"\n      )\n    }\n  }\n\n  return { recording, requesting, seconds, error, start, stop }\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/use-recording.ts"
    },
    {
      "path": "components/ai-chat/workbench.tsx",
      "content": "\"use client\"\n\n/* eslint-disable @next/next/no-img-element -- This installable React pack does not depend on Next Image. */\n\nimport { useEffect, useRef, useState, type ReactElement } from \"react\"\nimport { cn } from \"cn\"\nimport {\n  Check,\n  X,\n  ChevronRight,\n  Circle,\n  LoaderCircle,\n  FileCode2,\n  ArrowUpRight,\n  Download,\n  ShieldCheck,\n  ListChecks,\n  Brain,\n  Terminal,\n} from \"lucide-react\"\nimport { Button } from \"../ui/button\"\nimport { Badge } from \"../ui/badge\"\nimport {\n  Collapsible,\n  CollapsibleTrigger,\n  CollapsibleContent,\n} from \"../ui/collapsible\"\nimport {\n  Dialog,\n  DialogTrigger,\n  DialogContent,\n  DialogHeader,\n  DialogTitle,\n  DialogDescription,\n} from \"../ui/dialog\"\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from \"../ui/tabs\"\nimport { CopyAction, AttachmentList } from \"./atoms\"\nimport { RichText, CodeBlock, Sources, safeLink } from \"./content\"\nimport { parseDiff } from \"./state\"\nimport type {\n  ActivityStatus,\n  AIChatProps,\n  ApprovalPart,\n  ArtifactPart,\n  ChatPart,\n  DiffPart,\n} from \"./types\"\n\nexport function StatusMark({\n  status,\n}: {\n  status: ActivityStatus\n}): ReactElement {\n  const Icon =\n    status === \"success\"\n      ? Check\n      : status === \"error\"\n        ? X\n        : status === \"running\"\n          ? LoaderCircle\n          : Circle\n  return (\n    <Icon\n      aria-hidden=\"true\"\n      className={cn(\n        \"size-3.5 shrink-0\",\n        status === \"running\" && \"animate-spin motion-reduce:animate-none\"\n      )}\n    />\n  )\n}\n\nfunction Approval({\n  part,\n  onDecide,\n}: {\n  part: ApprovalPart\n  onDecide?: (decision: \"approved\" | \"rejected\") => void | Promise<void>\n}): ReactElement {\n  const [localDecision, setLocalDecision] = useState<\"approved\" | \"rejected\">()\n  const [pending, setPending] = useState(false)\n  const [error, setError] = useState(\"\")\n  const locked = useRef(false)\n  const mounted = useRef(true)\n  useEffect(() => {\n    mounted.current = true\n    return () => {\n      mounted.current = false\n    }\n  }, [])\n  const resolvedLabel = useRef<HTMLSpanElement>(null)\n  const decision = part.decision ?? localDecision\n  useEffect(() => {\n    if (decision && locked.current) resolvedLabel.current?.focus()\n  }, [decision])\n  async function decide(value: \"approved\" | \"rejected\"): Promise<void> {\n    if (locked.current || decision || !onDecide) return\n    locked.current = true\n    setPending(true)\n    setError(\"\")\n    try {\n      await onDecide(value)\n      if (mounted.current) setLocalDecision(value)\n    } catch {\n      locked.current = false\n      if (mounted.current) setError(\"Decision was not saved. Please try again.\")\n    } finally {\n      if (mounted.current) setPending(false)\n    }\n  }\n  return (\n    <section\n      className=\"rounded-xl border border-foreground/9 bg-foreground/2 p-3\"\n      aria-label=\"Approval request\"\n    >\n      <div className=\"flex items-center gap-2 text-xs font-medium\">\n        <ShieldCheck\n          className=\"size-3.5 text-muted-foreground\"\n          aria-hidden=\"true\"\n        />\n        {part.title}\n      </div>\n      <p className=\"mt-2 text-xs leading-relaxed text-muted-foreground\">\n        {part.description}\n      </p>\n      <div className=\"mt-4 flex items-center gap-2\" aria-live=\"polite\">\n        {decision ? (\n          <span\n            ref={resolvedLabel}\n            tabIndex={-1}\n            className=\"flex items-center gap-2 rounded-sm text-xs outline-none focus-visible:outline-2\"\n          >\n            <StatusMark\n              status={decision === \"approved\" ? \"success\" : \"error\"}\n            />\n            {decision === \"approved\" ? \"Approved\" : \"Rejected\"}\n          </span>\n        ) : (\n          <>\n            <Button\n              type=\"button\"\n              size=\"sm\"\n              disabled={pending || !onDecide}\n              onClick={() => void decide(\"approved\")}\n            >\n              {pending ? \"Saving…\" : (part.approveLabel ?? \"Approve\")}\n            </Button>\n            <Button\n              type=\"button\"\n              size=\"sm\"\n              variant=\"outline\"\n              disabled={pending || !onDecide}\n              onClick={() => void decide(\"rejected\")}\n            >\n              {part.rejectLabel ?? \"Reject\"}\n            </Button>\n          </>\n        )}\n      </div>\n      {error && (\n        <p role=\"alert\" className=\"mt-2 text-xs text-destructive\">\n          {error}\n        </p>\n      )}\n    </section>\n  )\n}\n\nfunction Diff({ part }: { part: DiffPart }): ReactElement {\n  const lines = parseDiff(part.patch)\n  return (\n    <Collapsible className=\"overflow-hidden rounded-xl border border-foreground/9 bg-foreground/2 p-0\">\n      <div className=\"flex items-center gap-2 px-3 py-2\">\n        <CollapsibleTrigger\n          render={<Button variant=\"ghost\" size=\"sm\" />}\n          className=\"group min-w-0 flex-1 justify-start\"\n        >\n          <FileCode2 data-icon=\"inline-start\" />\n          <span className=\"truncate text-xs\">{part.filename}</span>\n          <ChevronRight\n            className=\"ml-auto transition-transform group-data-open:rotate-90 motion-reduce:transition-none\"\n            data-icon=\"inline-end\"\n          />\n        </CollapsibleTrigger>\n        <span className=\"text-[10px] text-muted-foreground tabular-nums\">\n          +{lines.filter((line) => line.kind === \"add\").length} −\n          {lines.filter((line) => line.kind === \"remove\").length}\n        </span>\n        <CopyAction compact text={part.patch} label=\"Copy patch\" />\n      </div>\n      <CollapsibleContent className=\"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 motion-reduce:transition-none data-closed:h-0 data-closed:opacity-0\">\n        <div\n          className=\"max-h-72 overflow-auto border-t border-border/60 py-2 font-mono text-[11px] leading-6\"\n          aria-label={`Diff for ${part.filename}`}\n        >\n          {lines.map((line, index) => (\n            <div\n              key={index}\n              className=\"grid min-w-max grid-cols-[2rem_2rem_1rem_1fr] pr-4 data-[kind=add]:bg-[#68a68d]/10 data-[kind=header]:text-muted-foreground data-[kind=remove]:bg-[#bc7f88]/10\"\n              data-kind={line.kind}\n            >\n              <span className=\"text-center text-muted-foreground/50 select-none\">\n                {line.oldLine}\n              </span>\n              <span className=\"text-center text-muted-foreground/50 select-none\">\n                {line.newLine}\n              </span>\n              <span aria-hidden=\"true\">\n                {line.kind === \"add\" ? \"+\" : line.kind === \"remove\" ? \"−\" : \"\"}\n              </span>\n              <span className=\"whitespace-pre\">{line.text}</span>\n            </div>\n          ))}\n        </div>\n      </CollapsibleContent>\n    </Collapsible>\n  )\n}\n\nfunction Artifact({\n  part,\n  renderArtifact,\n}: {\n  part: ArtifactPart\n  renderArtifact?: AIChatProps[\"renderArtifact\"]\n}): ReactElement {\n  function download(): void {\n    const url = URL.createObjectURL(\n      new Blob([part.code], { type: \"text/plain;charset=utf-8\" })\n    )\n    const anchor = document.createElement(\"a\")\n    anchor.href = url\n    anchor.download = part.filename\n    anchor.click()\n    setTimeout(() => URL.revokeObjectURL(url), 1000)\n  }\n  const hasPreview = !!(part.preview || part.imageUrl || renderArtifact)\n  return (\n    <Dialog>\n      <DialogTrigger\n        render={<Button variant=\"outline\" />}\n        className=\"h-auto min-h-16 w-full justify-start gap-3 rounded-xl px-4 py-4\"\n      >\n        <span className=\"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border/80 bg-muted\">\n          <FileCode2 aria-hidden=\"true\" className=\"size-4\" />\n        </span>\n        <span className=\"flex min-w-0 flex-1 flex-col gap-1 text-left\">\n          <span className=\"truncate text-xs font-medium\">{part.title}</span>\n          <span className=\"text-[10px] text-muted-foreground\">\n            {part.filename} · Open artifact\n          </span>\n        </span>\n        <ArrowUpRight data-icon=\"inline-end\" />\n      </DialogTrigger>\n      <DialogContent className=\"flex max-h-[85dvh] max-w-[calc(100vw-1.5rem)] flex-col overflow-hidden motion-reduce:animate-none! motion-reduce:transition-none! sm:max-w-3xl motion-reduce:[&_*]:animate-none! motion-reduce:[&_*]:scroll-auto! motion-reduce:[&_*]:transition-none! motion-reduce:[&_*::before]:animate-none! motion-reduce:[&_*::before]:transition-none!\">\n        <DialogHeader>\n          <DialogTitle>{part.title}</DialogTitle>\n          <DialogDescription>{part.filename}</DialogDescription>\n        </DialogHeader>\n        <Tabs\n          defaultValue={hasPreview ? \"preview\" : \"code\"}\n          className=\"min-h-0 overflow-hidden\"\n        >\n          <div className=\"flex flex-wrap items-center justify-between gap-2\">\n            <TabsList>\n              {hasPreview && <TabsTrigger value=\"preview\">Preview</TabsTrigger>}\n              <TabsTrigger value=\"code\">Code</TabsTrigger>\n            </TabsList>\n            <div className=\"flex gap-1\">\n              <CopyAction text={part.code} label=\"Copy artifact\" />\n              <Button\n                type=\"button\"\n                variant=\"ghost\"\n                size=\"sm\"\n                onClick={download}\n              >\n                <Download data-icon=\"inline-start\" />\n                Download\n              </Button>\n            </div>\n          </div>\n          {hasPreview && (\n            <TabsContent\n              value=\"preview\"\n              className=\"max-h-[55dvh] overflow-auto rounded-xl border border-border/60 p-5 sm:p-8\"\n            >\n              {renderArtifact ? (\n                renderArtifact(part)\n              ) : part.imageUrl && safeLink(part.imageUrl) ? (\n                <img\n                  src={safeLink(part.imageUrl)}\n                  alt={part.title}\n                  className=\"max-h-96 max-w-full rounded-lg object-contain\"\n                />\n              ) : (\n                <RichText text={part.preview ?? \"\"} />\n              )}\n            </TabsContent>\n          )}\n          <TabsContent value=\"code\" className=\"min-h-0 overflow-auto\">\n            <CodeBlock code={part.code} language={part.language} />\n          </TabsContent>\n        </Tabs>\n      </DialogContent>\n    </Dialog>\n  )\n}\n\nexport function ChatPartView({\n  part,\n  messageId,\n  onApproval,\n  renderArtifact,\n}: {\n  part: ChatPart\n  messageId: string\n  onApproval?: AIChatProps[\"onApproval\"]\n  renderArtifact?: AIChatProps[\"renderArtifact\"]\n}): ReactElement {\n  switch (part.type) {\n    case \"text\":\n      return <RichText text={part.text} sources={part.sources} />\n    case \"attachments\":\n      return <AttachmentList attachments={part.attachments} />\n    case \"sources\":\n      return <Sources sources={part.sources} />\n    case \"approval\":\n      return (\n        <Approval\n          part={part}\n          onDecide={\n            onApproval\n              ? (decision) => onApproval(messageId, part.id, decision)\n              : undefined\n          }\n        />\n      )\n    case \"artifact\":\n      return <Artifact part={part} renderArtifact={renderArtifact} />\n    case \"diff\":\n      return <Diff part={part} />\n    case \"tasks\":\n      return (\n        <Collapsible className=\"rounded-xl border border-foreground/9 bg-foreground/2 p-3\">\n          <CollapsibleTrigger\n            render={<Button variant=\"ghost\" size=\"sm\" />}\n            className=\"group w-full justify-start\"\n          >\n            <ListChecks data-icon=\"inline-start\" />\n            <span className=\"flex-1 text-left text-xs\">{part.title}</span>\n            <span className=\"text-[10px] text-muted-foreground\">\n              {part.items.filter((item) => item.status === \"success\").length}/\n              {part.items.length}\n            </span>\n            <ChevronRight\n              data-icon=\"inline-end\"\n              className=\"transition-transform group-data-open:rotate-90 motion-reduce:transition-none\"\n            />\n          </CollapsibleTrigger>\n          <CollapsibleContent className=\"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 motion-reduce:transition-none data-closed:h-0 data-closed:opacity-0\">\n            <ul className=\"mt-3 flex flex-col gap-3 px-2\">\n              {part.items.map((item) => (\n                <li\n                  key={item.id}\n                  className=\"flex items-center gap-2 text-xs text-muted-foreground\"\n                >\n                  <StatusMark status={item.status} />\n                  <span>{item.label}</span>\n                  <span className=\"sr-only\">{item.status}</span>\n                </li>\n              ))}\n            </ul>\n          </CollapsibleContent>\n        </Collapsible>\n      )\n    case \"tool\":\n    case \"reasoning\":\n      return (\n        <Collapsible className=\"border-b border-foreground/6 pb-1\">\n          <CollapsibleTrigger\n            render={<Button variant=\"ghost\" size=\"sm\" />}\n            className=\"group h-auto w-full justify-start py-2\"\n          >\n            <StatusMark status={part.status} />\n            <span className=\"flex-1 text-left text-xs\">{part.title}</span>\n            {part.elapsed && (\n              <span className=\"text-[10px] text-muted-foreground\">\n                {part.elapsed}\n              </span>\n            )}\n            <Badge variant=\"secondary\" className=\"text-[9px]\">\n              {part.status}\n            </Badge>\n            <ChevronRight\n              data-icon=\"inline-end\"\n              className=\"transition-transform group-data-open:rotate-90 motion-reduce:transition-none\"\n            />\n          </CollapsibleTrigger>\n          <CollapsibleContent className=\"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 motion-reduce:transition-none data-closed:h-0 data-closed:opacity-0\">\n            <div className=\"mt-2 ml-3 flex flex-col gap-3 border-l border-border pl-4 text-xs leading-relaxed text-muted-foreground\">\n              <span className=\"flex items-center gap-2 text-[10px]\">\n                {part.type === \"reasoning\" ? (\n                  <Brain className=\"size-3\" />\n                ) : (\n                  <Terminal className=\"size-3\" />\n                )}\n                {part.type === \"reasoning\"\n                  ? \"Activity summary\"\n                  : \"Tool details\"}\n              </span>\n              {part.detail && <p>{part.detail}</p>}\n              {part.args && (\n                <div>\n                  <p className=\"mb-1 text-[10px]\">Arguments</p>\n                  <CodeBlock code={part.args} language=\"json\" />\n                </div>\n              )}\n              {part.result && (\n                <div>\n                  <p className=\"mb-1 text-[10px]\">Result</p>\n                  <p className=\"whitespace-pre-wrap\">{part.result}</p>\n                </div>\n              )}\n            </div>\n          </CollapsibleContent>\n        </Collapsible>\n      )\n  }\n}\n",
      "type": "registry:component",
      "target": "@components/ai-chat/workbench.tsx"
    },
    {
      "path": "components/ui/ai-chat.tsx",
      "content": "\"use client\"\n\nimport { memo, useId, useState, type ReactElement } from \"react\"\nimport {\n  RotateCcw,\n  ThumbsUp,\n  ThumbsDown,\n  ChevronLeft,\n  ChevronRight,\n  Sparkles,\n} from \"lucide-react\"\nimport { cn } from \"cn\"\nimport { Button } from \"./button\"\nimport { Message, MessageContent, MessageFooter } from \"./message\"\nimport { Bubble, BubbleContent } from \"./bubble\"\nimport { Marker, MarkerContent } from \"./marker\"\nimport {\n  MessageScrollerProvider,\n  MessageScroller,\n  MessageScrollerViewport,\n  MessageScrollerContent,\n  MessageScrollerItem,\n  MessageScrollerButton,\n} from \"./message-scroller\"\nimport {\n  Popover,\n  PopoverTrigger,\n  PopoverContent,\n  PopoverTitle,\n  PopoverDescription,\n} from \"./popover\"\nimport { AgentAvatar, CopyAction, ChatLoader } from \"../ai-chat/atoms\"\nimport { ChatComposer } from \"../ai-chat/composer\"\nimport { ChatPartView } from \"../ai-chat/workbench\"\nimport { activeParts, messageText } from \"../ai-chat/state\"\nimport type { AIChatProps, ChatMessage } from \"../ai-chat/types\"\n\nexport type * from \"../ai-chat/types\"\n\nconst ChatRow = memo(function ChatRow({\n  message,\n  busy,\n  canRetry,\n  onRetry,\n  onFeedback,\n  onSelectVersion,\n  onApproval,\n  renderArtifact,\n}: { message: ChatMessage; busy: boolean; canRetry: boolean } & Pick<\n  AIChatProps,\n  \"onRetry\" | \"onFeedback\" | \"onSelectVersion\" | \"onApproval\" | \"renderArtifact\"\n>): ReactElement {\n  const user = message.role === \"user\"\n  const parts = activeParts(message)\n  const text = messageText(message)\n  return (\n    <Message align={user ? \"end\" : \"start\"} className=\"group/chat-message\">\n      {!user && (\n        <span className=\"mt-0.5 hidden shrink-0 sm:block\">\n          <AgentAvatar />\n        </span>\n      )}\n      <MessageContent>\n        {user ? (\n          <Bubble variant=\"secondary\" align=\"end\">\n            <BubbleContent>\n              <div className=\"flex min-w-0 flex-col gap-3\">\n                {parts.map((part) => (\n                  <ChatPartView\n                    key={part.id}\n                    part={part}\n                    messageId={message.id}\n                  />\n                ))}\n              </div>\n            </BubbleContent>\n          </Bubble>\n        ) : (\n          <div className=\"flex min-w-0 flex-col gap-4\">\n            {parts.map((part) => (\n              <ChatPartView\n                key={part.id}\n                part={part}\n                messageId={message.id}\n                onApproval={onApproval}\n                renderArtifact={renderArtifact}\n              />\n            ))}\n          </div>\n        )}\n        <MessageFooter className=\"gap-1 opacity-45 transition-opacity duration-200 group-focus-within/chat-message:opacity-100 group-hover/chat-message:opacity-100 [&_button[aria-pressed=true]]:bg-muted [&_button[aria-pressed=true]]:text-foreground [@media(hover:none)]:opacity-80\">\n          <time\n            className=\"mr-2 text-[10px] font-normal text-muted-foreground/60\"\n            dateTime={message.createdAt}\n          >\n            {message.createdAt.slice(11, 16)}\n          </time>\n          {!user && (\n            <>\n              {text && <CopyAction compact label=\"Copy response\" text={text} />}\n              {onRetry && (\n                <Button\n                  type=\"button\"\n                  variant=\"ghost\"\n                  size=\"icon-xs\"\n                  title=\"Retry response\"\n                  aria-label=\"Retry response\"\n                  disabled={busy || !canRetry}\n                  onClick={() => onRetry(message.id)}\n                >\n                  <RotateCcw />\n                </Button>\n              )}\n              {onFeedback && (\n                <>\n                  <Button\n                    type=\"button\"\n                    variant=\"ghost\"\n                    size=\"icon-xs\"\n                    title=\"Helpful\"\n                    aria-label=\"Helpful\"\n                    aria-pressed={message.feedback === \"up\"}\n                    onClick={() => onFeedback(message.id, \"up\")}\n                  >\n                    <ThumbsUp />\n                  </Button>\n                  <Button\n                    type=\"button\"\n                    variant=\"ghost\"\n                    size=\"icon-xs\"\n                    title=\"Not helpful\"\n                    aria-label=\"Not helpful\"\n                    aria-pressed={message.feedback === \"down\"}\n                    onClick={() => onFeedback(message.id, \"down\")}\n                  >\n                    <ThumbsDown />\n                  </Button>\n                </>\n              )}\n              {!!message.versions?.length && onSelectVersion && (\n                <span className=\"ml-1 flex items-center gap-1\">\n                  <Button\n                    type=\"button\"\n                    variant=\"ghost\"\n                    size=\"icon-xs\"\n                    aria-label=\"Previous response version\"\n                    disabled={busy || !(message.activeVersion ?? 0)}\n                    onClick={() =>\n                      onSelectVersion(\n                        message.id,\n                        (message.activeVersion ?? 0) - 1\n                      )\n                    }\n                  >\n                    <ChevronLeft />\n                  </Button>\n                  <span className=\"text-[10px] tabular-nums\">\n                    {(message.activeVersion ?? 0) + 1}/{message.versions.length}\n                  </span>\n                  <Button\n                    type=\"button\"\n                    variant=\"ghost\"\n                    size=\"icon-xs\"\n                    aria-label=\"Next response version\"\n                    disabled={\n                      busy ||\n                      (message.activeVersion ?? 0) >=\n                        message.versions.length - 1\n                    }\n                    onClick={() =>\n                      onSelectVersion(\n                        message.id,\n                        (message.activeVersion ?? 0) + 1\n                      )\n                    }\n                  >\n                    <ChevronRight />\n                  </Button>\n                </span>\n              )}\n            </>\n          )}\n        </MessageFooter>\n      </MessageContent>\n    </Message>\n  )\n})\n\nexport function AIChat({\n  messages,\n  status,\n  title = \"Workspace\",\n  description = \"Your ideas, a little further.\",\n  suggestions = [\n    \"Review a release\",\n    \"Explain a code change\",\n    \"Draft a launch note\",\n  ],\n  context,\n  onContextAction,\n  capabilities,\n  className,\n  ...props\n}: AIChatProps): ReactElement {\n  const [draft, setDraft] = useState(\"\")\n  const [focusRequest, setFocusRequest] = useState(0)\n  const titleId = useId()\n  const busy = status === \"submitted\" || status === \"streaming\"\n  const latestAssistant = messages.findLast(\n    (message) => message.role === \"assistant\"\n  )?.id\n  const contextPercent =\n    context && context.limit > 0\n      ? Math.min(100, Math.max(0, (context.used / context.limit) * 100))\n      : 0\n  return (\n    <section\n      aria-labelledby={titleId}\n      className={cn(\n        \"isolate flex h-[min(740px,80dvh)] min-h-[480px] min-w-0 flex-col overflow-hidden rounded-2xl border border-border/40 bg-card/25 font-[inherit] motion-reduce:animate-none! motion-reduce:transition-none! motion-reduce:[&_*]:animate-none! motion-reduce:[&_*]:scroll-auto! motion-reduce:[&_*]:transition-none! motion-reduce:[&_*::before]:animate-none! motion-reduce:[&_*::before]:transition-none!\",\n        className\n      )}\n    >\n      <header className=\"flex shrink-0 items-center gap-2.5 border-b border-border/40 px-4 py-3 sm:px-6\">\n        <span className=\"flex size-6 items-center justify-center rounded-md border border-border/70\">\n          <Sparkles\n            className=\"size-3 text-muted-foreground\"\n            aria-hidden=\"true\"\n          />\n        </span>\n        <span id={titleId} className=\"text-xs font-medium\">\n          {title}\n        </span>\n        <span className=\"ml-auto flex items-center gap-1.5 text-[10px] text-muted-foreground\">\n          <span className=\"size-1 rounded-full bg-foreground/40\" />\n          {status === \"idle\"\n            ? \"Ready\"\n            : status === \"submitted\"\n              ? \"Thinking\"\n              : status === \"streaming\"\n                ? \"Responding\"\n                : status === \"awaiting-approval\"\n                  ? \"Your decision\"\n                  : \"Interrupted\"}\n        </span>\n      </header>\n      <MessageScrollerProvider autoScroll defaultScrollPosition=\"start\">\n        <MessageScroller className=\"min-h-0 flex-1\">\n          <MessageScrollerViewport className=\"max-[480px]:overscroll-y-auto\">\n            <MessageScrollerContent\n              aria-live=\"off\"\n              className=\"mx-auto max-w-3xl gap-7 px-4 py-6 sm:px-8 sm:py-8\"\n            >\n              {!messages.length ? (\n                <MessageScrollerItem>\n                  <div className=\"flex min-h-52 flex-col items-center justify-center gap-4 py-6 text-center\">\n                    <AgentAvatar />\n                    <div>\n                      <h2 className=\"text-xl font-medium tracking-tight\">\n                        What are we making?\n                      </h2>\n                      <p className=\"mt-2 text-xs text-muted-foreground\">\n                        {description}\n                      </p>\n                    </div>\n                  </div>\n                </MessageScrollerItem>\n              ) : (\n                <MessageScrollerItem>\n                  <Marker>\n                    <MarkerContent className=\"text-[10px] text-muted-foreground/50\">\n                      {description}\n                    </MarkerContent>\n                  </Marker>\n                </MessageScrollerItem>\n              )}\n              {messages.map((message) => (\n                <MessageScrollerItem\n                  key={message.id}\n                  messageId={message.id}\n                  scrollAnchor={message.role === \"user\"}\n                >\n                  <ChatRow\n                    message={message}\n                    busy={busy}\n                    canRetry={message.id === latestAssistant}\n                    onRetry={props.onRetry}\n                    onFeedback={\n                      capabilities?.feedback === false\n                        ? undefined\n                        : props.onFeedback\n                    }\n                    onSelectVersion={props.onSelectVersion}\n                    onApproval={props.onApproval}\n                    renderArtifact={props.renderArtifact}\n                  />\n                </MessageScrollerItem>\n              ))}\n              {busy && (\n                <MessageScrollerItem messageId=\"chat-processing\">\n                  <div className=\"flex items-center gap-3\">\n                    <AgentAvatar active />\n                    <ChatLoader\n                      label={\n                        status === \"submitted\"\n                          ? \"Considering the request\"\n                          : \"Working on the response\"\n                      }\n                      variant={status === \"submitted\" ? \"grid\" : \"bar\"}\n                    />\n                  </div>\n                </MessageScrollerItem>\n              )}\n              {props.error && (\n                <MessageScrollerItem>\n                  <p\n                    role=\"alert\"\n                    className=\"rounded-lg border border-destructive/25 p-3 text-xs text-destructive\"\n                  >\n                    {props.error}\n                  </p>\n                </MessageScrollerItem>\n              )}\n            </MessageScrollerContent>\n          </MessageScrollerViewport>\n          <MessageScrollerButton\n            size=\"sm\"\n            variant=\"outline\"\n            className=\"w-auto gap-2 rounded-full px-3 text-xs\"\n          >\n            Jump to latest\n          </MessageScrollerButton>\n        </MessageScroller>\n      </MessageScrollerProvider>\n      <footer className=\"shrink-0 px-3 pt-2 pb-3 sm:px-7 sm:pb-4\">\n        {!messages.length && (\n          <div className=\"mb-4 flex flex-wrap justify-center gap-2\">\n            {suggestions.map((text) => (\n              <Button\n                key={text}\n                type=\"button\"\n                size=\"sm\"\n                variant=\"outline\"\n                onClick={() => {\n                  setDraft(text)\n                  setFocusRequest((value) => value + 1)\n                }}\n              >\n                {text}\n              </Button>\n            ))}\n          </div>\n        )}\n        <ChatComposer\n          status={status}\n          capabilities={capabilities}\n          draft={draft}\n          onDraftChange={setDraft}\n          focusRequest={focusRequest}\n          {...props}\n        />\n        <div className=\"mt-2 flex min-h-5 items-center justify-between gap-2 px-1 text-[9px] text-muted-foreground/60\">\n          <span>Enter to send · Shift + Enter for a new line</span>\n          {context && context.limit > 0 && (\n            <Popover>\n              <PopoverTrigger\n                className=\"inline-flex items-center gap-1.5 rounded-sm tabular-nums focus-visible:outline-2\"\n                aria-label={`Context usage ${Math.round(contextPercent)} percent`}\n              >\n                <svg viewBox=\"0 0 16 16\" className=\"size-3\" aria-hidden=\"true\">\n                  <circle\n                    cx=\"8\"\n                    cy=\"8\"\n                    r=\"6\"\n                    fill=\"none\"\n                    stroke=\"currentColor\"\n                    opacity=\".2\"\n                    strokeWidth=\"2\"\n                  />\n                  <circle\n                    cx=\"8\"\n                    cy=\"8\"\n                    r=\"6\"\n                    fill=\"none\"\n                    stroke=\"currentColor\"\n                    strokeWidth=\"2\"\n                    strokeDasharray={`${contextPercent * 0.377} 38`}\n                    transform=\"rotate(-90 8 8)\"\n                  />\n                </svg>\n                {Math.round(contextPercent)}%\n              </PopoverTrigger>\n              <PopoverContent\n                side=\"top\"\n                className=\"motion-reduce:animate-none! motion-reduce:transition-none! motion-reduce:[&_*]:animate-none! motion-reduce:[&_*]:scroll-auto! motion-reduce:[&_*]:transition-none! motion-reduce:[&_*::before]:animate-none! motion-reduce:[&_*::before]:transition-none!\"\n              >\n                <PopoverTitle>Conversation context</PopoverTitle>\n                <PopoverDescription className=\"mt-2 text-xs\">\n                  {context.used.toLocaleString()} of{\" \"}\n                  {context.limit.toLocaleString()} tokens used. Supplied by your\n                  application.\n                </PopoverDescription>\n                {onContextAction && (\n                  <Button\n                    type=\"button\"\n                    size=\"sm\"\n                    variant=\"outline\"\n                    className=\"mt-3\"\n                    onClick={onContextAction}\n                  >\n                    Start fresh\n                  </Button>\n                )}\n              </PopoverContent>\n            </Popover>\n          )}\n        </div>\n      </footer>\n      <span role=\"status\" className=\"sr-only\">\n        {status === \"streaming\"\n          ? \"Assistant is responding\"\n          : status === \"awaiting-approval\"\n            ? \"Approval requested\"\n            : status === \"idle\"\n              ? \"Ready\"\n              : status === \"error\"\n                ? \"Response interrupted\"\n                : \"Request submitted\"}\n      </span>\n    </section>\n  )\n}\n",
      "type": "registry:ui",
      "target": "@ui/ai-chat.tsx"
    },
    {
      "path": "components/ui/button.tsx",
      "content": "import { Button as ButtonPrimitive } from \"@base-ui/react/button\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nconst buttonVariants = cva(\n  \"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground hover:bg-primary/80\",\n        outline:\n          \"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50\",\n        secondary:\n          \"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground\",\n        ghost:\n          \"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50\",\n        destructive:\n          \"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n      size: {\n        default:\n          \"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        xs: \"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3\",\n        sm: \"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5\",\n        lg: \"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        icon: \"size-8\",\n        \"icon-xs\":\n          \"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3\",\n        \"icon-sm\":\n          \"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg\",\n        \"icon-lg\": \"size-9\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"default\",\n    },\n  }\n)\n\nfunction Button({\n  className,\n  variant = \"default\",\n  size = \"default\",\n  ...props\n}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {\n  return (\n    <ButtonPrimitive\n      data-slot=\"button\"\n      className={cn(buttonVariants({ variant, size, className }))}\n      {...props}\n    />\n  )\n}\n\nexport { Button, buttonVariants }\n",
      "type": "registry:ui",
      "target": "@ui/button.tsx"
    },
    {
      "path": "components/ui/message.tsx",
      "content": "import * as React from \"react\"\nimport { cn } from \"cn\"\n\nfunction MessageGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"message-group\"\n      className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction Message({\n  className,\n  align = \"start\",\n  ...props\n}: React.ComponentProps<\"div\"> & { align?: \"start\" | \"end\" }) {\n  return (\n    <div\n      data-slot=\"message\"\n      data-align={align}\n      className={cn(\n        \"group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageAvatar({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"message-avatar\"\n      className={cn(\n        \"flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageContent({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"message-content\"\n      className={cn(\n        \"flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"message-header\"\n      className={cn(\n        \"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"message-footer\"\n      className={cn(\n        \"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0 group-data-[align=end]/message:justify-end\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  MessageGroup,\n  Message,\n  MessageAvatar,\n  MessageContent,\n  MessageFooter,\n  MessageHeader,\n}\n",
      "type": "registry:ui",
      "target": "@ui/message.tsx"
    },
    {
      "path": "components/ui/bubble.tsx",
      "content": "import * as React from \"react\"\nimport { mergeProps } from \"@base-ui/react/merge-props\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nfunction BubbleGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"bubble-group\"\n      className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n      {...props}\n    />\n  )\n}\n\nconst bubbleVariants = cva(\n  \"group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full\",\n  {\n    variants: {\n      variant: {\n        default:\n          \"*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80\",\n        secondary:\n          \"*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]\",\n        muted:\n          \"*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]\",\n        tinted:\n          \"*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]\",\n        outline:\n          \"*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30\",\n        ghost:\n          \"border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50\",\n        destructive:\n          \"*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\nfunction Bubble({\n  variant = \"default\",\n  align = \"start\",\n  className,\n  ...props\n}: React.ComponentProps<\"div\"> &\n  VariantProps<typeof bubbleVariants> & {\n    align?: \"start\" | \"end\"\n  }) {\n  return (\n    <div\n      data-slot=\"bubble\"\n      data-variant={variant}\n      data-align={align}\n      className={cn(bubbleVariants({ variant }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction BubbleContent({\n  className,\n  render,\n  ...props\n}: useRender.ComponentProps<\"div\">) {\n  return useRender({\n    defaultTagName: \"div\",\n    props: mergeProps<\"div\">(\n      {\n        className: cn(\n          \"w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50\",\n          className\n        ),\n      },\n      props\n    ),\n    render,\n    state: {\n      slot: \"bubble-content\",\n    },\n  })\n}\n\nconst bubbleReactionsVariants = cva(\n  \"absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0\",\n  {\n    variants: {\n      side: {\n        top: \"top-0 -translate-y-3/4\",\n        bottom: \"bottom-0 translate-y-3/4\",\n      },\n      align: {\n        start: \"left-3\",\n        end: \"right-3\",\n      },\n    },\n    defaultVariants: {\n      side: \"bottom\",\n      align: \"end\",\n    },\n  }\n)\n\nfunction BubbleReactions({\n  side = \"bottom\",\n  align = \"end\",\n  className,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  align?: \"start\" | \"end\"\n  side?: \"top\" | \"bottom\"\n}) {\n  return (\n    <div\n      data-slot=\"bubble-reactions\"\n      data-align={align}\n      data-side={side}\n      className={cn(bubbleReactionsVariants({ side, align }), className)}\n      {...props}\n    />\n  )\n}\n\nexport { BubbleGroup, Bubble, BubbleContent, BubbleReactions }\n",
      "type": "registry:ui",
      "target": "@ui/bubble.tsx"
    },
    {
      "path": "components/ui/marker.tsx",
      "content": "import * as React from \"react\"\nimport { mergeProps } from \"@base-ui/react/merge-props\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nconst markerVariants = cva(\n  \"group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground\",\n  {\n    variants: {\n      variant: {\n        default: \"\",\n        separator:\n          \"before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border\",\n        border: \"border-b border-border pb-2\",\n      },\n    },\n  }\n)\n\nfunction Marker({\n  className,\n  variant = \"default\",\n  render,\n  ...props\n}: useRender.ComponentProps<\"div\"> & VariantProps<typeof markerVariants>) {\n  return useRender({\n    defaultTagName: \"div\",\n    props: mergeProps<\"div\">(\n      {\n        className: cn(markerVariants({ variant, className })),\n      },\n      props\n    ),\n    render,\n    state: {\n      slot: \"marker\",\n      variant,\n    },\n  })\n}\n\nfunction MarkerIcon({ className, ...props }: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"marker-icon\"\n      aria-hidden=\"true\"\n      className={cn(\n        \"size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MarkerContent({ className, ...props }: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"marker-content\"\n      className={cn(\n        \"min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Marker, MarkerIcon, MarkerContent, markerVariants }\n",
      "type": "registry:ui",
      "target": "@ui/marker.tsx"
    },
    {
      "path": "components/ui/popover.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\"\nimport { cn } from \"cn\"\n\nfunction Popover({ ...props }: PopoverPrimitive.Root.Props) {\n  return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />\n}\n\nfunction PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {\n  return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />\n}\n\nfunction PopoverContent({\n  className,\n  align = \"center\",\n  alignOffset = 0,\n  side = \"bottom\",\n  sideOffset = 4,\n  ...props\n}: PopoverPrimitive.Popup.Props &\n  Pick<\n    PopoverPrimitive.Positioner.Props,\n    \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\"\n  >) {\n  return (\n    <PopoverPrimitive.Portal>\n      <PopoverPrimitive.Positioner\n        align={align}\n        alignOffset={alignOffset}\n        side={side}\n        sideOffset={sideOffset}\n        className=\"isolate z-50\"\n      >\n        <PopoverPrimitive.Popup\n          data-slot=\"popover-content\"\n          className={cn(\n            \"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n            className\n          )}\n          {...props}\n        />\n      </PopoverPrimitive.Positioner>\n    </PopoverPrimitive.Portal>\n  )\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"popover-header\"\n      className={cn(\"flex flex-col gap-0.5 text-sm\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {\n  return (\n    <PopoverPrimitive.Title\n      data-slot=\"popover-title\"\n      className={cn(\"font-medium\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction PopoverDescription({\n  className,\n  ...props\n}: PopoverPrimitive.Description.Props) {\n  return (\n    <PopoverPrimitive.Description\n      data-slot=\"popover-description\"\n      className={cn(\"text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Popover,\n  PopoverContent,\n  PopoverDescription,\n  PopoverHeader,\n  PopoverTitle,\n  PopoverTrigger,\n}\n",
      "type": "registry:ui",
      "target": "@ui/popover.tsx"
    },
    {
      "path": "components/ui/dropdown-menu.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\"\nimport { cn } from \"cn\"\nimport { ChevronRightIcon, CheckIcon } from \"lucide-react\"\n\nfunction DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {\n  return <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />\n}\n\nfunction DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {\n  return <MenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n  return <MenuPrimitive.Trigger data-slot=\"dropdown-menu-trigger\" {...props} />\n}\n\nfunction DropdownMenuContent({\n  align = \"start\",\n  alignOffset = 0,\n  side = \"bottom\",\n  sideOffset = 4,\n  className,\n  ...props\n}: MenuPrimitive.Popup.Props &\n  Pick<\n    MenuPrimitive.Positioner.Props,\n    \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\"\n  >) {\n  return (\n    <MenuPrimitive.Portal>\n      <MenuPrimitive.Positioner\n        className=\"isolate z-50 outline-none\"\n        align={align}\n        alignOffset={alignOffset}\n        side={side}\n        sideOffset={sideOffset}\n      >\n        <MenuPrimitive.Popup\n          data-slot=\"dropdown-menu-content\"\n          className={cn(\n            \"z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95\",\n            className\n          )}\n          {...props}\n        />\n      </MenuPrimitive.Positioner>\n    </MenuPrimitive.Portal>\n  )\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n  return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n}\n\nfunction DropdownMenuLabel({\n  className,\n  inset,\n  ...props\n}: MenuPrimitive.GroupLabel.Props & {\n  inset?: boolean\n}) {\n  return (\n    <MenuPrimitive.GroupLabel\n      data-slot=\"dropdown-menu-label\"\n      data-inset={inset}\n      className={cn(\n        \"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DropdownMenuItem({\n  className,\n  inset,\n  variant = \"default\",\n  ...props\n}: MenuPrimitive.Item.Props & {\n  inset?: boolean\n  variant?: \"default\" | \"destructive\"\n}) {\n  return (\n    <MenuPrimitive.Item\n      data-slot=\"dropdown-menu-item\"\n      data-inset={inset}\n      data-variant={variant}\n      className={cn(\n        \"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n  return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />\n}\n\nfunction DropdownMenuSubTrigger({\n  className,\n  inset,\n  children,\n  ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n  inset?: boolean\n}) {\n  return (\n    <MenuPrimitive.SubmenuTrigger\n      data-slot=\"dropdown-menu-sub-trigger\"\n      data-inset={inset}\n      className={cn(\n        \"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      {...props}\n    >\n      {children}\n      <ChevronRightIcon className=\"ml-auto\" />\n    </MenuPrimitive.SubmenuTrigger>\n  )\n}\n\nfunction DropdownMenuSubContent({\n  align = \"start\",\n  alignOffset = -3,\n  side = \"right\",\n  sideOffset = 0,\n  className,\n  ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n  return (\n    <DropdownMenuContent\n      data-slot=\"dropdown-menu-sub-content\"\n      className={cn(\n        \"w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n        className\n      )}\n      align={align}\n      alignOffset={alignOffset}\n      side={side}\n      sideOffset={sideOffset}\n      {...props}\n    />\n  )\n}\n\nfunction DropdownMenuCheckboxItem({\n  className,\n  children,\n  checked,\n  inset,\n  ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n  inset?: boolean\n}) {\n  return (\n    <MenuPrimitive.CheckboxItem\n      data-slot=\"dropdown-menu-checkbox-item\"\n      data-inset={inset}\n      className={cn(\n        \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      checked={checked}\n      {...props}\n    >\n      <span\n        className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n        data-slot=\"dropdown-menu-checkbox-item-indicator\"\n      >\n        <MenuPrimitive.CheckboxItemIndicator>\n          <CheckIcon />\n        </MenuPrimitive.CheckboxItemIndicator>\n      </span>\n      {children}\n    </MenuPrimitive.CheckboxItem>\n  )\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n  return (\n    <MenuPrimitive.RadioGroup\n      data-slot=\"dropdown-menu-radio-group\"\n      {...props}\n    />\n  )\n}\n\nfunction DropdownMenuRadioItem({\n  className,\n  children,\n  inset,\n  ...props\n}: MenuPrimitive.RadioItem.Props & {\n  inset?: boolean\n}) {\n  return (\n    <MenuPrimitive.RadioItem\n      data-slot=\"dropdown-menu-radio-item\"\n      data-inset={inset}\n      className={cn(\n        \"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      {...props}\n    >\n      <span\n        className=\"pointer-events-none absolute right-2 flex items-center justify-center\"\n        data-slot=\"dropdown-menu-radio-item-indicator\"\n      >\n        <MenuPrimitive.RadioItemIndicator>\n          <CheckIcon />\n        </MenuPrimitive.RadioItemIndicator>\n      </span>\n      {children}\n    </MenuPrimitive.RadioItem>\n  )\n}\n\nfunction DropdownMenuSeparator({\n  className,\n  ...props\n}: MenuPrimitive.Separator.Props) {\n  return (\n    <MenuPrimitive.Separator\n      data-slot=\"dropdown-menu-separator\"\n      className={cn(\"-mx-1 my-1 h-px bg-border\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction DropdownMenuShortcut({\n  className,\n  ...props\n}: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"dropdown-menu-shortcut\"\n      className={cn(\n        \"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  DropdownMenu,\n  DropdownMenuPortal,\n  DropdownMenuTrigger,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuLabel,\n  DropdownMenuItem,\n  DropdownMenuCheckboxItem,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuSeparator,\n  DropdownMenuShortcut,\n  DropdownMenuSub,\n  DropdownMenuSubTrigger,\n  DropdownMenuSubContent,\n}\n",
      "type": "registry:ui",
      "target": "@ui/dropdown-menu.tsx"
    },
    {
      "path": "components/ui/collapsible.tsx",
      "content": "\"use client\"\n\nimport { Collapsible as CollapsiblePrimitive } from \"@base-ui/react/collapsible\"\n\nfunction Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {\n  return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />\n}\n\nfunction CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {\n  return (\n    <CollapsiblePrimitive.Trigger data-slot=\"collapsible-trigger\" {...props} />\n  )\n}\n\nfunction CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {\n  return (\n    <CollapsiblePrimitive.Panel data-slot=\"collapsible-content\" {...props} />\n  )\n}\n\nexport { Collapsible, CollapsibleTrigger, CollapsibleContent }\n",
      "type": "registry:ui",
      "target": "@ui/collapsible.tsx"
    },
    {
      "path": "components/ui/tabs.tsx",
      "content": "\"use client\"\n\nimport { Tabs as TabsPrimitive } from \"@base-ui/react/tabs\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nfunction Tabs({\n  className,\n  orientation = \"horizontal\",\n  ...props\n}: TabsPrimitive.Root.Props) {\n  return (\n    <TabsPrimitive.Root\n      data-slot=\"tabs\"\n      data-orientation={orientation}\n      className={cn(\n        \"group/tabs flex gap-2 data-horizontal:flex-col\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nconst tabsListVariants = cva(\n  \"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-muted\",\n        line: \"gap-1 bg-transparent\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\nfunction TabsList({\n  className,\n  variant = \"default\",\n  ...props\n}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {\n  return (\n    <TabsPrimitive.List\n      data-slot=\"tabs-list\"\n      data-variant={variant}\n      className={cn(tabsListVariants({ variant }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {\n  return (\n    <TabsPrimitive.Tab\n      data-slot=\"tabs-trigger\"\n      className={cn(\n        \"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        \"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent\",\n        \"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground\",\n        \"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {\n  return (\n    <TabsPrimitive.Panel\n      data-slot=\"tabs-content\"\n      className={cn(\"flex-1 text-sm outline-none\", className)}\n      {...props}\n    />\n  )\n}\n\nexport { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }\n",
      "type": "registry:ui",
      "target": "@ui/tabs.tsx"
    },
    {
      "path": "components/ui/badge.tsx",
      "content": "import { mergeProps } from \"@base-ui/react/merge-props\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nconst badgeVariants = cva(\n  \"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground [a]:hover:bg-primary/80\",\n        secondary:\n          \"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80\",\n        destructive:\n          \"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20\",\n        outline:\n          \"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground\",\n        ghost:\n          \"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\nfunction Badge({\n  className,\n  variant = \"default\",\n  render,\n  ...props\n}: useRender.ComponentProps<\"span\"> & VariantProps<typeof badgeVariants>) {\n  return useRender({\n    defaultTagName: \"span\",\n    props: mergeProps<\"span\">(\n      {\n        className: cn(badgeVariants({ variant }), className),\n      },\n      props\n    ),\n    render,\n    state: {\n      slot: \"badge\",\n      variant,\n    },\n  })\n}\n\nexport { Badge, badgeVariants }\n",
      "type": "registry:ui",
      "target": "@ui/badge.tsx"
    },
    {
      "path": "components/ui/input.tsx",
      "content": "import * as React from \"react\"\nimport { Input as InputPrimitive } from \"@base-ui/react/input\"\nimport { cn } from \"cn\"\n\nfunction Input({ className, type, ...props }: React.ComponentProps<\"input\">) {\n  return (\n    <InputPrimitive\n      type={type}\n      data-slot=\"input\"\n      className={cn(\n        \"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Input }\n",
      "type": "registry:ui",
      "target": "@ui/input.tsx"
    },
    {
      "path": "components/ui/textarea.tsx",
      "content": "import * as React from \"react\"\nimport { cn } from \"cn\"\n\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\n  return (\n    <textarea\n      data-slot=\"textarea\"\n      className={cn(\n        \"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Textarea }\n",
      "type": "registry:ui",
      "target": "@ui/textarea.tsx"
    },
    {
      "path": "components/ui/message-scroller.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  MessageScroller as MessageScrollerPrimitive,\n  useMessageScroller,\n  useMessageScrollerScrollable,\n  useMessageScrollerVisibility,\n} from \"@shadcn/react/message-scroller\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { ArrowDownIcon } from \"lucide-react\"\n\nfunction MessageScrollerProvider(\n  props: React.ComponentProps<typeof MessageScrollerPrimitive.Provider>\n) {\n  return <MessageScrollerPrimitive.Provider {...props} />\n}\n\nfunction MessageScroller({\n  className,\n  ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Root>) {\n  return (\n    <MessageScrollerPrimitive.Root\n      data-slot=\"message-scroller\"\n      className={cn(\n        \"group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageScrollerViewport({\n  className,\n  ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>) {\n  return (\n    <MessageScrollerPrimitive.Viewport\n      data-slot=\"message-scroller-viewport\"\n      className={cn(\n        \"size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent data-pending-scroll:invisible\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageScrollerContent({\n  className,\n  ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Content>) {\n  return (\n    <MessageScrollerPrimitive.Content\n      data-slot=\"message-scroller-content\"\n      className={cn(\"flex h-max min-h-full flex-col gap-6\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction MessageScrollerItem({\n  className,\n  scrollAnchor = false,\n  ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Item>) {\n  return (\n    <MessageScrollerPrimitive.Item\n      data-slot=\"message-scroller-item\"\n      scrollAnchor={scrollAnchor}\n      className={cn(\n        \"min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction MessageScrollerButton({\n  direction = \"end\",\n  className,\n  children,\n  render,\n  variant = \"secondary\",\n  size = \"icon-sm\",\n  ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Button> &\n  Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n  return (\n    <MessageScrollerPrimitive.Button\n      data-slot=\"message-scroller-button\"\n      data-direction={direction}\n      data-variant={variant}\n      data-size={size}\n      direction={direction}\n      className={cn(\n        \"absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180\",\n        className\n      )}\n      render={render ?? <Button variant={variant} size={size} />}\n      {...props}\n    >\n      {children ?? (\n        <>\n          <ArrowDownIcon />\n          <span className=\"sr-only\">\n            {direction === \"end\" ? \"Scroll to end\" : \"Scroll to start\"}\n          </span>\n        </>\n      )}\n    </MessageScrollerPrimitive.Button>\n  )\n}\n\nexport {\n  MessageScrollerProvider,\n  MessageScroller,\n  MessageScrollerViewport,\n  MessageScrollerContent,\n  MessageScrollerItem,\n  MessageScrollerButton,\n  useMessageScroller,\n  useMessageScrollerScrollable,\n  useMessageScrollerVisibility,\n}\n",
      "type": "registry:ui",
      "target": "@ui/message-scroller.tsx"
    },
    {
      "path": "components/ui/attachment.tsx",
      "content": "import * as React from \"react\"\nimport { mergeProps } from \"@base-ui/react/merge-props\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/components/ui/button\"\n\nconst attachmentVariants = cva(\n  \"group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed\",\n  {\n    variants: {\n      size: {\n        default:\n          \"gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2\",\n        sm: \"gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5\",\n        xs: \"gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1\",\n      },\n      orientation: {\n        horizontal: \"min-w-40 items-center\",\n        vertical: \"w-24 flex-col has-data-[slot=attachment-content]:w-30\",\n      },\n    },\n  }\n)\n\nfunction Attachment({\n  className,\n  state = \"done\",\n  size = \"default\",\n  orientation = \"horizontal\",\n  ...props\n}: React.ComponentProps<\"div\"> &\n  VariantProps<typeof attachmentVariants> & {\n    state?: \"idle\" | \"uploading\" | \"processing\" | \"error\" | \"done\"\n  }) {\n  return (\n    <div\n      data-slot=\"attachment\"\n      data-state={state}\n      data-size={size}\n      data-orientation={orientation}\n      className={cn(attachmentVariants({ size, orientation }), className)}\n      {...props}\n    />\n  )\n}\n\nconst attachmentMediaVariants = cva(\n  \"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5\",\n  {\n    variants: {\n      variant: {\n        icon: \"\",\n        image:\n          \"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover\",\n      },\n    },\n    defaultVariants: {\n      variant: \"icon\",\n    },\n  }\n)\n\nfunction AttachmentMedia({\n  className,\n  variant = \"icon\",\n  ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof attachmentMediaVariants>) {\n  return (\n    <div\n      data-slot=\"attachment-media\"\n      data-variant={variant}\n      className={cn(attachmentMediaVariants({ variant }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentContent({\n  className,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"attachment-content\"\n      className={cn(\n        \"max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentTitle({\n  className,\n  ...props\n}: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"attachment-title\"\n      className={cn(\n        \"block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentDescription({\n  className,\n  ...props\n}: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"attachment-description\"\n      className={cn(\n        \"mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80\",\n        \"max-w-full\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentActions({\n  className,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"attachment-actions\"\n      className={cn(\n        \"relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentAction({\n  className,\n  variant,\n  size = \"icon-xs\",\n  ...props\n}: React.ComponentProps<typeof Button>) {\n  return (\n    <Button\n      data-slot=\"attachment-action\"\n      variant={variant ?? \"ghost\"}\n      size={size}\n      className={cn(className)}\n      {...props}\n    />\n  )\n}\n\nfunction AttachmentTrigger({\n  className,\n  render,\n  type,\n  ...props\n}: useRender.ComponentProps<\"button\">) {\n  return useRender({\n    defaultTagName: \"button\",\n    props: mergeProps<\"button\">(\n      {\n        type: render ? type : (type ?? \"button\"),\n        className: cn(\"absolute inset-0 z-10 outline-none\", className),\n      },\n      props\n    ),\n    render,\n    state: {\n      slot: \"attachment-trigger\",\n    },\n  })\n}\n\nfunction AttachmentGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"attachment-group\"\n      className={cn(\n        \"flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Attachment,\n  AttachmentGroup,\n  AttachmentMedia,\n  AttachmentContent,\n  AttachmentTitle,\n  AttachmentDescription,\n  AttachmentActions,\n  AttachmentAction,\n  AttachmentTrigger,\n}\n",
      "type": "registry:ui",
      "target": "@ui/attachment.tsx"
    },
    {
      "path": "components/ui/dialog.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Dialog as DialogPrimitive } from \"@base-ui/react/dialog\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { XIcon } from \"lucide-react\"\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n  return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n  return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\n\nfunction DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {\n  return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n  return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\n\nfunction DialogOverlay({\n  className,\n  ...props\n}: DialogPrimitive.Backdrop.Props) {\n  return (\n    <DialogPrimitive.Backdrop\n      data-slot=\"dialog-overlay\"\n      className={cn(\n        \"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs motion-reduce:animate-none motion-reduce:transition-none data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DialogContent({\n  className,\n  children,\n  showCloseButton = true,\n  ...props\n}: DialogPrimitive.Popup.Props & {\n  showCloseButton?: boolean\n}) {\n  return (\n    <DialogPortal>\n      <DialogOverlay />\n      <DialogPrimitive.Popup\n        data-slot=\"dialog-content\"\n        className={cn(\n          \"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n          className\n        )}\n        {...props}\n      >\n        {children}\n        {showCloseButton && (\n          <DialogPrimitive.Close\n            data-slot=\"dialog-close\"\n            render={\n              <Button\n                variant=\"ghost\"\n                className=\"absolute top-2 right-2\"\n                size=\"icon-sm\"\n              />\n            }\n          >\n            <XIcon />\n            <span className=\"sr-only\">Close</span>\n          </DialogPrimitive.Close>\n        )}\n      </DialogPrimitive.Popup>\n    </DialogPortal>\n  )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"dialog-header\"\n      className={cn(\"flex flex-col gap-2\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction DialogFooter({\n  className,\n  showCloseButton = false,\n  children,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  showCloseButton?: boolean\n}) {\n  return (\n    <div\n      data-slot=\"dialog-footer\"\n      className={cn(\n        \"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end\",\n        className\n      )}\n      {...props}\n    >\n      {children}\n      {showCloseButton && (\n        <DialogPrimitive.Close render={<Button variant=\"outline\" />}>\n          Close\n        </DialogPrimitive.Close>\n      )}\n    </div>\n  )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n  return (\n    <DialogPrimitive.Title\n      data-slot=\"dialog-title\"\n      className={cn(\n        \"font-heading text-base leading-none font-medium\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DialogDescription({\n  className,\n  ...props\n}: DialogPrimitive.Description.Props) {\n  return (\n    <DialogPrimitive.Description\n      data-slot=\"dialog-description\"\n      className={cn(\n        \"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogOverlay,\n  DialogPortal,\n  DialogTitle,\n  DialogTrigger,\n}\n",
      "type": "registry:ui",
      "target": "@ui/dialog.tsx"
    },
    {
      "path": "components/ui/input-group.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Input } from \"@/components/ui/input\"\nimport { Textarea } from \"@/components/ui/textarea\"\n\nfunction InputGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"input-group\"\n      role=\"group\"\n      className={cn(\n        \"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nconst inputGroupAddonVariants = cva(\n  \"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4\",\n  {\n    variants: {\n      align: {\n        \"inline-start\":\n          \"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]\",\n        \"inline-end\":\n          \"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]\",\n        \"block-start\":\n          \"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2\",\n        \"block-end\":\n          \"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2\",\n      },\n    },\n    defaultVariants: {\n      align: \"inline-start\",\n    },\n  }\n)\n\nfunction InputGroupAddon({\n  className,\n  align = \"inline-start\",\n  ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof inputGroupAddonVariants>) {\n  return (\n    <div\n      role=\"group\"\n      data-slot=\"input-group-addon\"\n      data-align={align}\n      className={cn(inputGroupAddonVariants({ align }), className)}\n      onClick={(e) => {\n        if ((e.target as HTMLElement).closest(\"button\")) {\n          return\n        }\n        e.currentTarget.parentElement?.querySelector(\"input\")?.focus()\n      }}\n      {...props}\n    />\n  )\n}\n\nconst inputGroupButtonVariants = cva(\n  \"flex items-center gap-2 text-sm shadow-none\",\n  {\n    variants: {\n      size: {\n        xs: \"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5\",\n        sm: \"\",\n        \"icon-xs\":\n          \"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0\",\n        \"icon-sm\": \"size-8 p-0 has-[>svg]:p-0\",\n      },\n    },\n    defaultVariants: {\n      size: \"xs\",\n    },\n  }\n)\n\nfunction InputGroupButton({\n  className,\n  type = \"button\",\n  variant = \"ghost\",\n  size = \"xs\",\n  ...props\n}: Omit<React.ComponentProps<typeof Button>, \"size\" | \"type\"> &\n  VariantProps<typeof inputGroupButtonVariants> & {\n    type?: \"button\" | \"submit\" | \"reset\"\n  }) {\n  return (\n    <Button\n      type={type}\n      data-size={size}\n      variant={variant}\n      className={cn(inputGroupButtonVariants({ size }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      className={cn(\n        \"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction InputGroupInput({\n  className,\n  ...props\n}: React.ComponentProps<\"input\">) {\n  return (\n    <Input\n      data-slot=\"input-group-control\"\n      className={cn(\n        \"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction InputGroupTextarea({\n  className,\n  ...props\n}: React.ComponentProps<\"textarea\">) {\n  return (\n    <Textarea\n      data-slot=\"input-group-control\"\n      className={cn(\n        \"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupButton,\n  InputGroupText,\n  InputGroupInput,\n  InputGroupTextarea,\n}\n",
      "type": "registry:ui",
      "target": "@ui/input-group.tsx"
    },
    {
      "path": "docs/ai-chat.md",
      "content": "# AI Chat pack\n\nOne install, one public `AIChat` entry point, and one integrated chat/agent showcase at `/components/ai-chat`.\n\n## Install and start\n\nUse React 19, Tailwind CSS 4, and a configured shadcn Base UI project. In the showcase, Copy install uses that page’s actual origin, including localhost during development. Keep your existing theme and font.\n\n```sh\npnpm dlx shadcn@latest add http://localhost:3000/r/ai-chat.json\n```\n\n```tsx\n\"use client\"\nimport { AIChatDemo } from \"@/components/ai-chat/demo\"\nexport default function Example() { return <AIChatDemo /> }\n```\n\nThis complete local adapter uses scripted fixtures. It does not connect to a model service, inspect attached files, upload recordings, or modify repository files.\n\n## The important execution flow\n\n1. `AIChat` receives `messages` and `status`. Your application owns these values.\n2. The composer collects a draft, local `File` attachments, model, effort, and Chat/Agent mode. Submit calls `onSubmit` with a `ChatSubmission`.\n3. Your adapter appends a user message and streams assistant parts into state. Each part has a `type` discriminator, such as `text`, `tool`, `approval`, or `artifact`; TypeScript uses that field to select the right properties.\n4. `ChatPartView` renders those parts. Message Scroller preserves reading position and offers Jump to latest while the reader is away from the live edge.\n5. Retry, version selection, feedback, approvals, and context actions call your callbacks. They do not secretly perform network or filesystem operations.\n\nStart with the demo adapter to see a complete implementation. It uses `AbortController` to cancel its waits and a run ID to reject stale updates after Stop, Replay, New chat, or unmount. Only the latest assistant response is retryable in the demo. Each retry appends a version; switching versions preserves the original parts.\n\n## Public interface\n\nImport `AIChat`, `AIChatProps`, `ChatMessage`, `ChatPart`, `ChatStatus`, `ChatSubmission`, and other types from your UI `ai-chat` entry.\n\n- Required: `messages`, `status`, `onSubmit`.\n- Optional actions: `onStop`, `onRetry`, `onFeedback`, `onSelectVersion`, `onApproval`, `onContextAction`.\n- Configuration: `models` (with per-model `efforts`), `suggestions`, `capabilities`, `title`, `description`, `error`, `className`.\n- Attachments: `maxAttachments` defaults to 5; `maxAttachmentBytes` defaults to 10 MB; `maxRecordingSeconds` defaults to 120.\n- Context: `{ used, limit }` comes from your host. The component does not estimate token usage.\n- Extension points: `toolbar` accepts React content; `renderArtifact` receives an artifact and returns its preview.\n\nStatus is `idle`, `submitted`, `streaming`, `awaiting-approval`, or `error`. Keep message IDs and part IDs stable during streaming. Update the current part rather than replacing the conversation with fresh IDs.\n\n`onSubmit` may return a promise for accepting a submission. Reject it to retain the draft and display an error. Manage the longer response lifecycle with `status`; the demo starts its asynchronous response separately. In a real adapter, abort your transport in `onStop` and update running activities when generation stops.\n\nText parts render Markdown with tables, lists, code, and safe links. To reference a source inline, use `[1](#source-sourceId)` and include that source in the text part’s `sources` array. Source URLs support HTTP(S). Raw HTML is disabled.\n\nThe `approval` callback receives message ID, part ID, and `approved` or `rejected`. Update the matching part’s `decision`. Its `approveLabel` and `rejectLabel` are optional; the defaults are Approve and Reject. In a real application, perform and validate the requested operation in your backend; this frontend only presents the decision.\n\nArtifacts contain code, a filename, and optional Markdown/image preview. Code is displayed rather than executed. A custom React preview is supplied through `renderArtifact`.\n\n## Audio ownership and cleanup\n\nRecording starts only after pressing Record voice note. `getUserMedia` obtains an audio stream; `MediaRecorder` collects chunks into a `File`. Finish attaches it, Cancel discards it, and the maximum duration automatically finishes it. All tracks and timers are stopped on finish, cancel, failure, or component unmount. A late permission response after cancellation is discarded and its tracks stopped.\n\nPlayback creates a local object URL for that file and revokes it when the preview unmounts. Transcript attachments retain the `File` independently of the cleared composer. The host decides whether and how to upload or transcribe it. HTTPS or localhost is required for microphone access.\n\n## Styling and rendering\n\nThe pack inherits semantic theme tokens and fonts. Styling uses inline Tailwind utilities. The registry installs its `sb-chat` keyframes and angle property into your global stylesheet; there is no standalone chat CSS file. When copying source manually, include those animation definitions from `app/globals.css`. The composer has a quiet spectral border while processing; reduced motion stops autonomous effects. All decorative elements ignore interaction.\n\nMarkdown uses `react-markdown` and `remark-gfm`. Shiki is imported only when a code block mounts; a singleton highlighter, limited language set, and 32-entry cache bound repeated highlighting. Until highlighting completes, plain code remains readable. There is no WebGL dependency.\n\n## File inventory for this checkpoint\n\nCreated reusable source:\n- `components/ui/ai-chat.tsx`: public component, transcript, message actions, context popover.\n- `components/ai-chat/types.ts`: typed public contract and message parts.\n- `components/ai-chat/state.ts`: versions, approvals, attachment rules, avatar seeds, diff parsing, run guards.\n- `components/ai-chat/atoms.tsx`: avatars, copy feedback, selection menus, attachments, loaders.\n- `components/ai-chat/composer.tsx`: draft, files, keyboard input, send/stop, recording controls.\n- `components/ai-chat/use-recording.ts`: microphone lifecycle and cleanup.\n- `components/ai-chat/content.tsx`: Markdown, code blocks, source cards and lists.\n- `components/ai-chat/highlight.ts`: lazy, cached syntax tokenization.\n- `components/ai-chat/workbench.tsx`: activity, task, approval, diff and artifact renderers.\n- `app/globals.css`: shared chat animation definitions, also shipped through the registry item's `css` field.\n- `components/ai-chat/demo-data.ts`: release-review fixtures and artifact contents.\n- `components/ai-chat/demo.tsx`: working local state and cancellation adapter.\n- `components/ai-chat/state.test.ts`: focused Node tests.\n\nCreated shadcn primitives: `components/ui/attachment.tsx`, `badge.tsx`, `bubble.tsx`, `collapsible.tsx`, `dialog.tsx`, `dropdown-menu.tsx`, `input-group.tsx`, `input.tsx`, `marker.tsx`, `message-scroller.tsx`, `message.tsx`, `popover.tsx`, `tabs.tsx`, `textarea.tsx`. The existing `button.tsx` was reused unchanged.\n\nCreated site/distribution files: `app/components/ai-chat/page.tsx`, `components/ai-chat-showcase.tsx`, `components/ai-chat-thumbnail.tsx`, `registry.json`, `public/r/ai-chat.json`, this document, and `docs/ai-chat-shadcn-license.txt` (the copied primitives’ MIT notice, included in the install).\n\nModified: `app/page.tsx` (linked collection card), `app/how-to-use/page.tsx` (pack installation guidance), `components/collection-sidebar.tsx` (active entry), `package.json` (runtime dependencies, registry/test/build scripts), `pnpm-lock.yaml` (resolved dependencies).\n\nDeleted: none. Existing material renderers and the glass folder were not changed.\n\nThe registry bundles runtime modules and primitives, not the website’s header, sidebar, homepage, or test runner. `@components/` and `@ui/` targets respect the receiving project’s aliases, including a `src/` directory. Existing theme tokens are not replaced. Rebuild the payload with `pnpm registry:build`; `pnpm build` does that automatically.\n\n## Verify it\n\n```sh\npnpm test:chat\npnpm lint\npnpm typecheck\npnpm build\n```\n\nManual test: open `/components/ai-chat`, choose Replay workflow, expand the patch, and approve or reject it. Open the resulting artifact, switch between Preview and Code, and copy or download it. Retry the latest response and use its version arrows to recover the original.\n\n### Verification on the available environment\n\n- All nine focused Node tests passed. Lint, explicit typecheck, and the production build passed.\n- Checked 1440 × 900 and 390 × 844 layouts. No horizontal document overflow at mobile width; light and dark theme switching preserved usable controls.\n- Exercised multiline/send/stop, stale-run cancellation, retry/version switching, feedback, model/effort fallback, citations with Escape focus restoration, task/diff expansion, approval/rejection, and artifact Preview/Code/copy.\n- Used real browser `MediaRecorder` with a synthetic audio stream. Finish produced a playable local attachment; finish, cancel, and New chat ended captured tracks. Simulated denied and unsupported recording paths displayed the intended messages. Physical microphone permission prompts and real phone keyboards remain manual checks.\n- A fresh one-command installation exited successfully into a separate `src/`-based application. Its typecheck and production build passed, and its browser-rendered rejection flow produced revision notes. Theme stylesheet hashes were unchanged by installation.\n- An 1.8-second emulated-mobile frame sample recorded 108 frames, median 16.7 ms and p95 16.9 ms, with no frames above 33.4 ms. This measures the available desktop browser under mobile layout emulation, not physical phone performance.\n- Reduced-motion emulation reported no animation for the processing border, loader cells, or model popup. The temporary audio/browser test overrides were removed.\n\n## References\n\n- Visual direction: [Libraries.dev Beam](https://libraries.dev/beam).\n- Interaction references: [SmoothUI chat](https://smoothui.dev/docs/components/ai-conversation) and the supplied screenshots. Shipbits’ chat/workbench implementation is original.\n- Chat primitives: [shadcn/ui](https://ui.shadcn.com/docs/components/base/message-scroller), distributed under its MIT license.\n- Audio implementation: [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder).\n",
      "type": "registry:file",
      "target": "@components/ai-chat/README.md"
    },
    {
      "path": "docs/ai-chat-shadcn-license.txt",
      "content": "MIT License\n\nCopyright (c) 2023 shadcn\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
      "type": "registry:file",
      "target": "@components/ai-chat/LICENSE.shadcn"
    }
  ],
  "css": {
    "@property --sb-chat-angle": {
      "syntax": "\"<angle>\"",
      "initial-value": "0deg",
      "inherits": "false"
    },
    "@keyframes sb-chat-beam": {
      "to": {
        "--sb-chat-angle": "360deg"
      }
    },
    "@keyframes sb-chat-pulse": {
      "0%, 100%": {
        "opacity": ".25"
      },
      "50%": {
        "opacity": ".9"
      }
    },
    "@keyframes sb-chat-sweep": {
      "0%, 100%": {
        "transform": "translateX(-16px)"
      },
      "50%": {
        "transform": "translateX(44px)"
      }
    },
    "@keyframes sb-chat-avatar": {
      "50%": {
        "filter": "hue-rotate(35deg)"
      }
    }
  },
  "docs": "Read the bundled ai-chat README for setup, API details and the working demo. Connect your own backend through callbacks.",
  "type": "registry:block"
}