{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chat-composer",
  "title": "Chat composer",
  "description": "Prompt input with an auto-growing textarea, attachment chips from picker, paste or drop, a slash-command menu, model and mode selectors, a token ring against the context limit, Enter or Cmd+Enter to send and a Stop button while streaming.",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json",
    "https://goodui.dev/r/model-picker.json",
    "https://goodui.dev/r/sounds.json"
  ],
  "files": [
    {
      "path": "registry/components/ai/chat-composer.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\"\nimport { File, FileText, Image as ImageIcon, Paperclip, Slash, X } from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\nimport type { SoundName } from \"@/lib/goodui-sounds\"\nimport { ModelPicker, type ModelOption } from \"@/components/goodui/model-picker\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, spring } from \"@/lib/goodui-motion\"\n\n/*\n * Prompt composer for AI chat: an auto-growing textarea with attachment chips (button, paste or drop),\n * a slash-command menu, model and mode selectors, a token counter against the context limit, Enter or\n * Cmd/Ctrl+Enter to send and a Stop button while the answer streams.\n */\n\n/* The halo: a thin spinning light on the edge plus a blurred copy under it. Focus shows it, streaming speeds it up. */\nconst CSS = `\n@property --pc-composer-a{syntax:\"<angle>\";inherits:true;initial-value:0deg}\n@keyframes pc-composer-spin{to{--pc-composer-a:360deg}}\n.pc-composer{--pc-composer-glow:conic-gradient(from var(--pc-composer-a),var(--chart-1),var(--chart-4),var(--chart-5),var(--chart-2),var(--chart-1))}\n.pc-composer[data-halo]::before,.pc-composer[data-halo]::after{content:\"\";position:absolute;inset:-1px;border-radius:inherit;background:var(--pc-composer-glow);opacity:0;pointer-events:none;transition:opacity 240ms var(--pc-ease-out)}\n.pc-composer[data-halo]::before{padding:1.5px;-webkit-mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}\n.pc-composer[data-halo]::after{z-index:-2;inset:2px;filter:blur(14px)}\n.pc-composer-bg{position:absolute;inset:0;z-index:-1;border-radius:inherit;background:var(--card);pointer-events:none}\n.pc-composer[data-halo]:is(:focus-within,[data-dragging],[data-streaming])::before{opacity:1}\n.pc-composer[data-halo]:is(:focus-within,[data-dragging],[data-streaming])::after{opacity:.38}\n.dark .pc-composer[data-halo]:is(:focus-within,[data-dragging],[data-streaming])::after{opacity:.3}\n.pc-composer[data-halo]:is(:focus-within,[data-dragging],[data-streaming]){animation:pc-composer-spin 6s linear infinite}\n.pc-composer[data-halo][data-streaming]{animation-duration:1.8s}\n@media (prefers-reduced-motion:reduce){.pc-composer[data-halo]{animation:none!important}.pc-composer[data-halo]::before,.pc-composer[data-halo]::after{transition:none}}\n.pc-composer-ring{transition:stroke-dashoffset .35s var(--pc-ease-out),stroke .2s}\n@media (prefers-reduced-motion:reduce){.pc-composer-ring{transition:none}}\n`\n\nexport type ComposerAttachment = {\n  id: string\n  name: string\n  /** Bytes, shown as KB/MB. */\n  size?: number\n  /** MIME type; images get a thumbnail when `url` is set. */\n  type?: string\n  /** Preview URL for images (object URL or remote). */\n  url?: string\n  file?: File\n}\n\nexport type SlashCommand = { name: string; description?: string; icon?: React.ReactNode }\nexport type ComposerMode = { id: string; label: string; icon?: React.ReactNode }\n\nexport type ChatComposerLabels = {\n  placeholder: string\n  send: string\n  stop: string\n  attach: string\n  remove: (name: string) => string\n  commands: string\n  noCommands: string\n  modes: string\n  tokens: (used: string, max: string) => string\n  overLimit: string\n  hint: string\n}\nconst DEFAULT_LABELS: ChatComposerLabels = {\n  placeholder: \"Message…\",\n  send: \"Send message\",\n  stop: \"Stop generating\",\n  attach: \"Attach files\",\n  remove: (name) => `Remove ${name}`,\n  commands: \"Commands\",\n  noCommands: \"No matching command\",\n  modes: \"Mode\",\n  tokens: (used, max) => `${used} of ${max} tokens`,\n  overLimit: \"Over the token limit\",\n  hint: \"Enter to send, Shift+Enter for a new line\",\n}\n\nexport type ChatComposerProps = Omit<React.ComponentProps<\"form\">, \"onSubmit\" | \"defaultValue\" | \"onDrop\" | \"onDragOver\" | \"onDragLeave\" | \"onKeyDown\" | \"onPaste\"> & {\n  /** Key handler on the textarea; call preventDefault to override the Enter behavior. */\n  onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void\n  /** Paste handler on the textarea; pasted files become attachments when `accept` is set. */\n  onPaste?: (e: React.ClipboardEvent<HTMLTextAreaElement>) => void\n  value?: string\n  defaultValue?: string\n  onValueChange?: (value: string) => void\n  /** Called with the trimmed text and the attachments, model and mode in effect. Clears the field when uncontrolled. */\n  onSubmit?: (text: string, meta: { attachments: ComposerAttachment[]; model?: string; mode?: string }) => void\n  /** The answer is streaming: the send button becomes Stop and calls onStop. */\n  streaming?: boolean\n  onStop?: () => void\n  attachments?: ComposerAttachment[]\n  defaultAttachments?: ComposerAttachment[]\n  onAttachmentsChange?: (attachments: ComposerAttachment[]) => void\n  /** Accept attribute for the file picker, e.g. \"image/*,.pdf\". Omit to hide the attach button. */\n  accept?: string\n  maxAttachments?: number\n  /** Typing \"/\" at the start opens this list. */\n  commands?: SlashCommand[]\n  /** Runs when a command is picked; by default the command is inserted as \"/name \". */\n  onCommand?: (command: SlashCommand) => void\n  /** Models for a built-in ModelPicker in the footer. */\n  models?: ModelOption[]\n  model?: string\n  defaultModel?: string\n  onModelChange?: (id: string) => void\n  /** Modes shown as a segmented control, e.g. Chat / Research / Code. */\n  modes?: ComposerMode[]\n  mode?: string\n  defaultMode?: string\n  onModeChange?: (id: string) => void\n  /** Context limit; shows the counter and blocks sending above it. */\n  maxTokens?: number\n  /** Your tokenizer; defaults to about one token per four characters. */\n  countTokens?: (text: string) => number\n  /** Textarea placeholder; also its accessible name. */\n  placeholder?: string\n  minRows?: number\n  maxRows?: number\n  /** Enter sends (Shift+Enter adds a line). false: only Cmd/Ctrl+Enter sends. */\n  submitOnEnter?: boolean\n  disabled?: boolean\n  autoFocus?: boolean\n  /** Extra controls at the start of the footer. */\n  footer?: React.ReactNode\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<ChatComposerLabels>\n  /** Spinning colored light on the edge while focused, faster while streaming. false keeps a plain focus ring. */\n  halo?: boolean\n  /** Plays \"send\" on submit when the visitor has sounds on (lib/goodui-sounds); a sound name picks another. Off by default. */\n  sound?: boolean | SoundName\n}\n\n// Optional UI sound: the sound module is loaded only when `sound` is on, so silent apps pay nothing.\nfunction useCue(sound: boolean | SoundName | undefined) {\n  React.useEffect(() => {\n    if (sound) void import(\"@/lib/goodui-sounds\")\n  }, [sound])\n  return React.useCallback(\n    (fallback: SoundName) => {\n      if (!sound) return\n      void import(\"@/lib/goodui-sounds\").then((m) => m.play(sound === true ? fallback : sound))\n    },\n    [sound],\n  )\n}\n\nconst fmtSize = (n: number) => (n >= 1048576 ? `${(n / 1048576).toFixed(1)} MB` : n >= 1024 ? `${Math.round(n / 1024)} KB` : `${n} B`)\nconst compact = new Intl.NumberFormat(\"en-US\", { notation: \"compact\", maximumFractionDigits: 1 })\nlet seq = 0\n\nfunction toAttachment(file: File): ComposerAttachment {\n  return { id: `a${++seq}-${file.name}`, name: file.name, size: file.size, type: file.type, file, url: file.type.startsWith(\"image/\") ? URL.createObjectURL(file) : undefined }\n}\n\nfunction FileIcon({ type }: { type?: string }) {\n  const Icon = type?.startsWith(\"image/\") ? ImageIcon : type?.includes(\"pdf\") || type?.startsWith(\"text/\") ? FileText : File\n  return <Icon className=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n}\n\n/** Auto-growing prompt input with attachments, slash commands, model and mode pickers, token counter and stop. */\nexport function ChatComposer({\n  value: valueProp,\n  defaultValue = \"\",\n  onValueChange,\n  onSubmit,\n  streaming = false,\n  onStop,\n  attachments: attachmentsProp,\n  defaultAttachments = [],\n  onAttachmentsChange,\n  accept,\n  maxAttachments = 10,\n  commands,\n  onCommand,\n  models,\n  model: modelProp,\n  defaultModel,\n  onModelChange,\n  modes,\n  mode: modeProp,\n  defaultMode,\n  onModeChange,\n  maxTokens,\n  countTokens,\n  placeholder,\n  minRows = 1,\n  maxRows = 8,\n  submitOnEnter = true,\n  disabled,\n  autoFocus,\n  footer,\n  labels,\n  halo = true,\n  sound,\n  className,\n  onKeyDown,\n  onPaste,\n  ...props\n}: ChatComposerProps) {\n  const l = { ...useLabels(\"chat-composer\", DEFAULT_LABELS, labels), ...(placeholder !== undefined ? { placeholder } : {}) }\n  const reduce = useReducedMotion() ?? false\n  const cue = useCue(sound)\n  const uid = React.useId()\n  const [innerValue, setInnerValue] = React.useState(defaultValue)\n  const value = valueProp ?? innerValue\n  const [innerFiles, setInnerFiles] = React.useState(defaultAttachments)\n  const attachments = attachmentsProp ?? innerFiles\n  const [innerModel, setInnerModel] = React.useState(defaultModel ?? models?.[0]?.id)\n  const model = modelProp ?? innerModel\n  const [innerMode, setInnerMode] = React.useState(defaultMode ?? modes?.[0]?.id)\n  const mode = modeProp ?? innerMode\n  const [active, setActive] = React.useState(0)\n  const [dragging, setDragging] = React.useState(false)\n  const taRef = React.useRef<HTMLTextAreaElement>(null)\n  const fileRef = React.useRef<HTMLInputElement>(null)\n  const grown = React.useRef(false)\n\n  const setValue = (v: string) => {\n    if (valueProp === undefined) setInnerValue(v)\n    onValueChange?.(v)\n  }\n  const setFiles = (next: ComposerAttachment[]) => {\n    if (attachmentsProp === undefined) setInnerFiles(next)\n    onAttachmentsChange?.(next)\n  }\n  const addFiles = (files: FileList | File[]) => {\n    const room = Math.max(0, maxAttachments - attachments.length)\n    const added = Array.from(files).slice(0, room).map(toAttachment)\n    if (added.length) setFiles([...attachments, ...added])\n  }\n  const removeFile = (id: string) => setFiles(attachments.filter((a) => a.id !== id))\n\n  // Auto-grow between minRows and maxRows.\n  React.useLayoutEffect(() => {\n    const ta = taRef.current\n    if (!ta) return\n    const line = parseFloat(getComputedStyle(ta).lineHeight) || 24\n    const from = ta.offsetHeight\n    ta.style.height = \"0px\"\n    const pad = ta.offsetHeight - ta.clientHeight\n    const to = Math.min(Math.max(ta.scrollHeight, line * minRows + pad), line * maxRows + pad)\n    // First layout and reduced motion set the height directly; after that it springs.\n    if (reduce || !grown.current || from === to) {\n      grown.current = true\n      ta.style.height = `${to}px`\n      return\n    }\n    ta.style.height = `${from}px`\n    const controls = animate(ta, { height: to }, spring.ui)\n    return () => controls.stop()\n  }, [value, minRows, maxRows, reduce])\n\n  // Slash commands: \"/\" at the start, filtered by what follows until the first space.\n  const query = commands && /^\\/[^\\s]*$/.test(value) ? value.slice(1).toLowerCase() : null\n  const matches = React.useMemo(() => (query === null ? [] : (commands ?? []).filter((c) => c.name.toLowerCase().startsWith(query))), [commands, query])\n  const menuOpen = query !== null\n  React.useEffect(() => setActive(0), [query])\n\n  const pick = (c: SlashCommand) => {\n    if (onCommand) onCommand(c)\n    setValue(`/${c.name} `)\n    taRef.current?.focus()\n  }\n\n  const used = React.useMemo(() => (countTokens ? countTokens(value) : Math.ceil(value.trim().length / 4)), [countTokens, value])\n  const ratio = maxTokens ? used / maxTokens : 0\n  const over = !!maxTokens && used > maxTokens\n  const canSend = !disabled && !over && (value.trim().length > 0 || attachments.length > 0)\n\n  const submit = () => {\n    if (streaming) return onStop?.()\n    if (!canSend) return\n    onSubmit?.(value.trim(), { attachments, model, mode })\n    cue(\"send\")\n    if (valueProp === undefined) setInnerValue(\"\")\n    if (attachmentsProp === undefined) setInnerFiles([])\n    onValueChange?.(\"\")\n  }\n\n  const keyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n    onKeyDown?.(e)\n    if (e.defaultPrevented) return\n    if (menuOpen && matches.length) {\n      if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n        e.preventDefault()\n        setActive((a) => (a + (e.key === \"ArrowDown\" ? 1 : -1) + matches.length) % matches.length)\n        return\n      }\n      if (e.key === \"Enter\" || e.key === \"Tab\") {\n        e.preventDefault()\n        const c = matches[active]\n        if (c) pick(c)\n        return\n      }\n      if (e.key === \"Escape\") {\n        e.preventDefault()\n        setValue(value + \" \")\n        return\n      }\n    }\n    if (e.key === \"Enter\" && ((e.metaKey || e.ctrlKey) || (submitOnEnter && !e.shiftKey && !e.nativeEvent.isComposing))) {\n      e.preventDefault()\n      submit()\n    }\n  }\n\n  const paste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n    onPaste?.(e)\n    if (e.clipboardData.files.length && accept) {\n      e.preventDefault()\n      addFiles(e.clipboardData.files)\n    }\n  }\n\n  const ringR = 7\n  const ringC = 2 * Math.PI * ringR\n  const tokenTone = over ? \"text-rose-700 dark:text-rose-400\" : ratio >= 0.85 ? \"text-amber-700 dark:text-amber-400\" : \"text-muted-foreground\"\n\n  return (\n    <form\n      className={cn(\n        \"pc-composer relative isolate flex w-full flex-col rounded-2xl text-card-foreground shadow-[var(--pc-e2)]\",\n        !halo && \"transition-shadow focus-within:ring-3 focus-within:ring-ring/40\",\n        !halo && dragging && \"ring-3 ring-ring/40\",\n        disabled && \"opacity-60\",\n        className,\n      )}\n      data-dragging={dragging || undefined}\n      data-streaming={streaming || undefined}\n      data-halo={halo || undefined}\n      onSubmit={(e) => {\n        e.preventDefault()\n        submit()\n      }}\n      onDragOver={(e) => {\n        if (!accept) return\n        e.preventDefault()\n        setDragging(true)\n      }}\n      onDragLeave={() => setDragging(false)}\n      onDrop={(e) => {\n        if (!accept) return\n        e.preventDefault()\n        setDragging(false)\n        addFiles(e.dataTransfer.files)\n      }}\n      {...props}\n    >\n      <GooduiTokens />\n      <style href=\"pc-chat-composer\" precedence=\"default\">\n        {CSS}\n      </style>\n      <span className=\"pc-composer-bg\" aria-hidden=\"true\" />\n\n      <AnimatePresence>\n        {menuOpen && (\n          <motion.div\n            key=\"commands\"\n            role=\"listbox\"\n            id={`${uid}-commands`}\n            aria-label={l.commands}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6, scale: 0.98 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={reduce ? { opacity: 0, transition: { duration: 0.1 } } : { opacity: 0, y: 4, transition: { duration: 0.12 } }}\n            transition={reduce ? { duration: 0 } : spring.snap}\n            className=\"absolute inset-x-2 bottom-full z-30 mb-2 max-h-60 origin-bottom overflow-y-auto rounded-xl border bg-popover p-1 text-popover-foreground shadow-[var(--pc-e3)]\"\n          >\n            <div role=\"presentation\" className=\"px-2 pt-1.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase\">\n              {l.commands}\n            </div>\n            {matches.length === 0 && (\n              <div role=\"presentation\" className=\"px-2 py-2 text-sm text-muted-foreground\">\n                {l.noCommands}\n              </div>\n            )}\n            {matches.map((c, i) => (\n              <div\n                key={c.name}\n                role=\"option\"\n                aria-selected={i === active}\n                onPointerMove={() => setActive(i)}\n                onMouseDown={(e) => e.preventDefault()}\n                onClick={() => pick(c)}\n                className=\"relative flex cursor-pointer items-center gap-2.5 rounded-lg px-2 py-1.5\"\n              >\n                {i === active && <motion.span layoutId={`${uid}-cmd`} className=\"absolute inset-0 rounded-lg bg-muted\" transition={reduce ? { duration: 0 } : spring.snap} />}\n                <span className=\"relative grid size-6 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground [&_svg]:size-3.5\">{c.icon ?? <Slash />}</span>\n                <span className=\"relative min-w-0 flex-1\">\n                  <span className=\"font-mono text-sm font-medium\">/{c.name}</span>\n                  {c.description && <span className=\"ms-2 truncate text-xs text-muted-foreground\">{c.description}</span>}\n                </span>\n              </div>\n            ))}\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      <AnimatePresence initial={false}>\n        {attachments.length > 0 && (\n          <motion.ul\n            key=\"files\"\n            initial={{ opacity: 0, height: 0 }}\n            animate={{ opacity: 1, height: \"auto\" }}\n            exit={{ opacity: 0, height: 0 }}\n            transition={reduce ? { duration: 0 } : spring.ui}\n            className=\"flex flex-wrap gap-1.5 overflow-hidden px-2 pt-2\"\n          >\n            <AnimatePresence initial={false}>\n              {attachments.map((a) => (\n                <motion.li\n                  key={a.id}\n                  layout\n                  initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.95, y: 8, filter: \"blur(4px)\" }}\n                  animate={{ opacity: 1, scale: 1, y: 0, filter: \"blur(0px)\" }}\n                  exit={reduce ? { opacity: 0, transition: { duration: 0.1 } } : { opacity: 0, scale: 0.95, filter: \"blur(4px)\", transition: { duration: 0.14 } }}\n                  transition={reduce ? { duration: 0 } : spring.morph}\n                  className=\"flex h-9 max-w-full items-center gap-2 rounded-lg bg-background ps-1.5 pe-1 text-xs shadow-[var(--pc-e1)]\"\n                >\n                  {a.url ? (\n                    // eslint-disable-next-line @next/next/no-img-element\n                    <img src={a.url} alt=\"\" className=\"size-6 rounded-md object-cover\" />\n                  ) : (\n                    <span className=\"grid size-6 place-items-center rounded-md bg-muted\">\n                      <FileIcon type={a.type} />\n                    </span>\n                  )}\n                  <span className=\"flex min-w-0 flex-col leading-tight\">\n                    <span className=\"max-w-40 truncate font-medium\">{a.name}</span>\n                    {a.size !== undefined && <span className=\"text-[10px] text-muted-foreground\">{fmtSize(a.size)}</span>}\n                  </span>\n                  <button\n                    type=\"button\"\n                    aria-label={l.remove(a.name)}\n                    onClick={() => removeFile(a.id)}\n                    className=\"pc-press grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50\"\n                  >\n                    <X className=\"size-3.5\" aria-hidden=\"true\" />\n                  </button>\n                </motion.li>\n              ))}\n            </AnimatePresence>\n          </motion.ul>\n        )}\n      </AnimatePresence>\n\n      <textarea\n        ref={taRef}\n        value={value}\n        onChange={(e) => setValue(e.target.value)}\n        onKeyDown={keyDown}\n        onPaste={paste}\n        rows={minRows}\n        placeholder={l.placeholder}\n        aria-label={l.placeholder}\n        aria-describedby={`${uid}-hint`}\n        disabled={disabled}\n        autoFocus={autoFocus}\n        className=\"w-full resize-none bg-transparent px-4 pt-3 pb-1 text-[15px] leading-6 outline-none placeholder:text-muted-foreground\"\n      />\n      <span id={`${uid}-hint`} className=\"sr-only\">\n        {l.hint}\n      </span>\n\n      <div className=\"flex items-end gap-1 px-2 pb-2\">\n        <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-1\">\n          {accept && (\n            <>\n              <input ref={fileRef} type=\"file\" accept={accept} multiple hidden tabIndex={-1} onChange={(e) => e.target.files && addFiles(e.target.files)} />\n              <button\n                type=\"button\"\n                aria-label={l.attach}\n                title={l.attach}\n                disabled={disabled}\n                onClick={() => fileRef.current?.click()}\n                className=\"pc-press grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50\"\n              >\n                <Paperclip className=\"size-4\" aria-hidden=\"true\" />\n              </button>\n            </>\n          )}\n          {footer}\n          {models && models.length > 0 && (\n            <ModelPicker\n              models={models}\n              value={model}\n              onValueChange={(id) => {\n                if (modelProp === undefined) setInnerModel(id)\n                onModelChange?.(id)\n              }}\n              variant=\"ghost\"\n              size=\"sm\"\n              align=\"start\"\n              disabled={disabled}\n            />\n          )}\n          {modes && modes.length > 0 && (\n            <div role=\"radiogroup\" aria-label={l.modes} className=\"flex items-center rounded-lg bg-muted/70 p-0.5\">\n              {modes.map((m) => (\n                <button\n                  key={m.id}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={mode === m.id}\n                  disabled={disabled}\n                  onClick={() => {\n                    if (modeProp === undefined) setInnerMode(m.id)\n                    onModeChange?.(m.id)\n                  }}\n                  className={cn(\n                    \"pc-press relative inline-flex h-7 items-center gap-1 rounded-md px-2 text-xs font-medium whitespace-nowrap outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5\",\n                    mode === m.id ? \"text-foreground\" : \"text-foreground/65 hover:text-foreground\",\n                  )}\n                >\n                  {mode === m.id && <motion.span layoutId={`${uid}-mode`} className=\"absolute inset-0 rounded-md bg-background shadow-[var(--pc-e1)]\" transition={reduce ? { duration: 0 } : spring.snap} />}\n                  <span className=\"relative inline-flex items-center gap-1\">\n                    {m.icon}\n                    {m.label}\n                  </span>\n                </button>\n              ))}\n            </div>\n          )}\n        </div>\n        <div className=\"flex shrink-0 items-center gap-2\">\n          {maxTokens !== undefined && (\n            <span className={cn(\"inline-flex items-center gap-1.5 text-[11px] tabular-nums\", tokenTone)} title={over ? l.overLimit : undefined}>\n              <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" aria-hidden=\"true\" className=\"-rotate-90\">\n                <circle cx=\"9\" cy=\"9\" r={ringR} fill=\"none\" stroke=\"currentColor\" strokeOpacity=\"0.2\" strokeWidth=\"2\" />\n                <circle cx=\"9\" cy=\"9\" r={ringR} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeDasharray={ringC} strokeDashoffset={ringC * (1 - Math.min(1, ratio))} className=\"pc-composer-ring\" />\n              </svg>\n              <span aria-hidden=\"true\" dir=\"ltr\">\n                {compact.format(used)} / {compact.format(maxTokens)}\n              </span>\n              <span className=\"sr-only\">{over ? l.overLimit : l.tokens(compact.format(used), compact.format(maxTokens))}</span>\n            </span>\n          )}\n          <button\n            type={streaming ? \"button\" : \"submit\"}\n            aria-label={streaming ? l.stop : l.send}\n            title={streaming ? l.stop : l.send}\n            disabled={streaming ? disabled : !canSend}\n            onClick={streaming ? onStop : undefined}\n            className={cn(\n              \"pc-press relative grid size-8 shrink-0 place-items-center rounded-lg outline-none focus-visible:ring-3 focus-visible:ring-ring/50\",\n              streaming ? \"bg-foreground text-background\" : \"bg-primary text-primary-foreground disabled:opacity-35\",\n            )}\n          >\n            {/* One shape: the arrow's stem widens into the stop square while its head draws away. */}\n            <span className=\"relative grid size-4 place-items-center\" aria-hidden=\"true\">\n              <motion.span\n                className=\"block bg-current\"\n                initial={false}\n                animate={streaming ? { width: 11, height: 11, borderRadius: 2.5 } : { width: 2.25, height: 13, borderRadius: 1.2 }}\n                transition={reduce ? { duration: 0 } : spring.ui}\n              />\n              <svg viewBox=\"0 0 16 16\" className=\"absolute inset-0 size-4\" fill=\"none\">\n                <motion.path\n                  d=\"M3.2 7.4 8 2.6l4.8 4.8\"\n                  stroke=\"currentColor\"\n                  strokeWidth=\"2.25\"\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                  initial={false}\n                  animate={streaming ? { pathLength: 0, opacity: 0 } : { pathLength: 1, opacity: 1 }}\n                  transition={reduce ? { duration: 0 } : spring.snap}\n                />\n              </svg>\n            </span>\n          </button>\n        </div>\n      </div>\n    </form>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/chat-composer.tsx"
    }
  ],
  "categories": [
    "components",
    "ai"
  ],
  "type": "registry:component"
}
