{
  "$schema": "https://www.cooki-ui.design/schema/registry-item.json",
  "name": "ai-prompt-bar",
  "type": "registry:ui",
  "title": "AI Prompt Bar",
  "description": "Autonomous AI prompt composer with model switcher, attachment drawer, voice dictation, and expanding interactive commands.",
  "category": "ai",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "tags": [
    "ai",
    "prompt",
    "composer",
    "input",
    "chat",
    "model-selector",
    "framer-motion"
  ],
  "files": [
    {
      "path": "registry/ai/ai-prompt-bar/ai-prompt-bar.tsx",
      "type": "registry:ui",
      "target": "components/ui/ai-prompt-bar.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useRef, useEffect, useLayoutEffect } from \"react\";\nimport { motion, AnimatePresence } from \"framer-motion\";\nimport { Plus, Paperclip, AudioLines, ArrowUp, ChevronDown, Globe, Database, X, FileText, Command as CommandIcon, Code, Mail, FileSpreadsheet, Zap, Cpu, Brain } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\n\nexport interface AiModel {\n  id: string;\n  name: string;\n  tag?: string;\n  icon?: React.ReactNode;\n}\n\nexport interface AiSource {\n  id: string;\n  name: string;\n  desc: string;\n  icon: React.ReactNode;\n  brand?: \"figma\" | \"slack\" | \"gmail\" | \"github\" | \"notion\" | \"drive\";\n  connected?: boolean;\n  attach?: boolean;\n}\n\nexport interface AiCommand {\n  id: string;\n  name: string;\n  desc: string;\n  icon?: React.ReactNode;\n}\n\nexport interface AiPromptBarProps {\n  placeholder?: string;\n  variant?: \"rounded\" | \"pill\" | \"glass\" | \"minimal\";\n  models?: AiModel[];\n  defaultModelId?: string;\n  sources?: AiSource[];\n  commands?: AiCommand[];\n  onSend?: (payload: { text: string; model: AiModel; attachments: string[] }) => void;\n  className?: string;\n  disabled?: boolean;\n}\n\n/* Crisp Brand SVG Icons */\nconst BRAND_ICONS = {\n  figma: (\n    <svg width=\"14\" height=\"14\" viewBox=\"0 0 38 57\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M9.5 57A9.5 9.5 0 0 0 19 47.5V38H9.5a9.5 9.5 0 0 0 0 19z\" fill=\"#0ACF83\" />\n      <path d=\"M0 28.5A9.5 9.5 0 0 1 9.5 19H19v19H9.5A9.5 9.5 0 0 1 0 28.5z\" fill=\"#A259FF\" />\n      <path d=\"M0 9.5A9.5 9.5 0 0 1 9.5 0H19v19H9.5A9.5 9.5 0 0 1 0 9.5z\" fill=\"#F24E1E\" />\n      <path d=\"M19 0h9.5a9.5 9.5 0 1 1 0 19H19V0z\" fill=\"#FF7262\" />\n      <path d=\"M38 28.5a9.5 9.5 0 1 1-19 0 9.5 9.5 0 0 1 19 0z\" fill=\"#1ABCFE\" />\n    </svg>\n  ),\n  slack: (\n    <svg width=\"15\" height=\"15\" viewBox=\"0 0 127 127\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z\" fill=\"#E01E5A\" />\n      <path d=\"M47 27.2c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.7 39.7.8 47 .8c7.3 0 13.2 5.9 13.2 13.2v13.2H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.3.7 54.4.7 47.1c0-7.3 5.9-13.2 13.2-13.2H47z\" fill=\"#36C5F0\" />\n      <path d=\"M99.9 47.1c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V47.1zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.9C66.9 6.6 72.8.7 80.1.7c7.3 0 13.2 5.9 13.2 13.2v33.2z\" fill=\"#2EB67D\" />\n      <path d=\"M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z\" fill=\"#ECB22E\" />\n    </svg>\n  ),\n  github: (\n    <svg width=\"15\" height=\"15\" viewBox=\"0 0 98 96\" fill=\"currentColor\" aria-hidden=\"true\">\n      <path fillRule=\"evenodd\" clipRule=\"evenodd\" d=\"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.938-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.869 0 48.854 0z\" />\n    </svg>\n  ),\n  notion: (\n    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n      <path d=\"M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.047-.326L17.86 1.777c-.467-.373-1.213-.653-2.006-.56L2.92 2.244c-.373.047-.467.233-.327.467l1.866 1.497zm1.587 4.155v13.626c0 .84.42 1.307 1.493 1.213l13.727-.793c.84-.047 1.167-.56 1.167-1.353V6.822c0-.793-.373-1.167-1.073-1.12L7.333 6.449c-.84.047-1.287.513-1.287 1.914zm12.934 1.493l.093 11.197c.047.513-.187.793-.653.84l-2.006.14-5.226-7.886v7.373l1.866.14c.42.047.513.327.513.746l-4.573.28c-.373.047-.56-.233-.56-.653V10.749c0-.467.233-.7.746-.746l2.1-.14 5.087 7.746V10.75l-1.633-.14c-.42-.047-.513-.327-.513-.746l4.573-.28c.373-.047.467.28.467.606z\" />\n    </svg>\n  ),\n  drive: (\n    <svg width=\"15\" height=\"13\" viewBox=\"0 0 87.3 78\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8H0c0 1.55.4 3.1 1.2 4.5l5.4 9.35z\" fill=\"#0066DA\" />\n      <path d=\"M43.65 25 29.9 1.2c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44c-.8 1.4-1.2 2.95-1.2 4.5h27.5L43.65 25z\" fill=\"#00AC47\" />\n      <path d=\"M73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l5.4-9.35c.8-1.4 1.2-2.95 1.2-4.5H55.95l6.85 11.85 10.75 5.3z\" fill=\"#EA4335\" />\n      <path d=\"M43.65 25 57.4 1.2C56.05.4 54.5 0 52.95 0H34.35c-1.55 0-3.1.4-4.45 1.2L43.65 25z\" fill=\"#00832D\" />\n      <path d=\"M55.95 53 42.2 29.2l-13.75 23.8h27.5z\" fill=\"#2684FC\" />\n      <path d=\"M73.55 76.8 59.8 53H32.3l13.75 23.8h27.5c1.55 0 3.1-.4 4.45-1.25z\" fill=\"#FFBA00\" />\n    </svg>\n  ),\n  gmail: (\n    <svg width=\"15\" height=\"12\" viewBox=\"0 0 256 193\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M58.182 192.05V93.14L27.507 65.077 0 49.504v125.091c0 9.658 7.825 17.455 17.455 17.455h40.727Z\" fill=\"#4285F4\" />\n      <path d=\"M197.818 192.05h40.727c9.659 0 17.455-7.826 17.455-17.455V49.505l-31.156 17.837-27.026 25.798v98.91Z\" fill=\"#34A853\" />\n      <path d=\"m58.182 93.14-4.174-38.647 4.174-36.989L128 69.868l69.818-52.364 4.669 34.992-4.669 40.644L128 145.504 58.182 93.14Z\" fill=\"#EA4335\" />\n      <path d=\"M197.818 17.504V93.14L256 49.504V26.231c0-21.585-24.64-33.89-41.89-20.945l-16.292 12.218Z\" fill=\"#FBBC04\" />\n      <path d=\"m0 49.504 26.759 20.07L58.182 93.14V17.504L41.89 5.286C24.61-7.66 0 4.646 0 26.23v23.273Z\" fill=\"#C5221F\" />\n    </svg>\n  ),\n};\n\nconst DEFAULT_MODELS: AiModel[] = [\n  { id: \"claude-3-7-sonnet\", name: \"Claude 3.7 Sonnet\", tag: \"Thinking\", icon: <Brain className=\"w-3.5 h-3.5\" /> },\n  { id: \"gpt-4o\", name: \"GPT-4o\", tag: \"Omni\", icon: <Brain className=\"w-3.5 h-3.5\" /> },\n  { id: \"claude-3-5-sonnet\", name: \"Claude 3.5 Sonnet\", tag: \"Artifacts\", icon: <Zap className=\"w-3.5 h-3.5\" /> },\n  { id: \"gemini-1-5-pro\", name: \"Gemini 1.5 Pro\", tag: \"Multimodal\", icon: <Brain className=\"w-3.5 h-3.5\" /> },\n  { id: \"deepseek-r1\", name: \"DeepSeek R1\", tag: \"Reasoning\", icon: <Cpu className=\"w-3.5 h-3.5\" /> },\n  { id: \"llama-3-3\", name: \"Llama 3.3 70B\", tag: \"Open Source\", icon: <Cpu className=\"w-3.5 h-3.5\" /> },\n];\n\nconst DEFAULT_SOURCES: AiSource[] = [\n  { id: \"attach\", name: \"Add photos & files\", desc: \"Upload from your computer\", icon: <Paperclip className=\"w-4 h-4\" />, attach: true },\n  { id: \"web\", name: \"Web search\", desc: \"Real-time Google search & news\", icon: <Globe className=\"w-4 h-4\" /> },\n  { id: \"github\", name: \"GitHub Repos\", desc: \"Search code, issues & PRs\", brand: \"github\", icon: null },\n  { id: \"figma\", name: \"Figma Components\", desc: \"Design-to-code & UI tokens\", brand: \"figma\", icon: null },\n  { id: \"slack\", name: \"Slack Channels\", desc: \"Thread context & team chats\", brand: \"slack\", connected: true, icon: null },\n  { id: \"notion\", name: \"Notion Pages\", desc: \"Docs, wikis & workspace notes\", brand: \"notion\", icon: null },\n  { id: \"drive\", name: \"Google Drive\", desc: \"Read files & Google Sheets\", brand: \"drive\", icon: null },\n  { id: \"db\", name: \"Database Context\", desc: \"PostgreSQL & Supabase schemas\", icon: <Database className=\"w-4 h-4\" /> },\n];\n\nconst DEFAULT_COMMANDS: AiCommand[] = [\n  { id: \"summarize\", name: \"/summarize\", desc: \"Digest current context or thread\", icon: <FileText className=\"w-4 h-4\" /> },\n  { id: \"code-review\", name: \"/code-review\", desc: \"Audit code quality, bugs & performance\", icon: <Code className=\"w-4 h-4\" /> },\n  { id: \"draft-email\", name: \"/draft-email\", desc: \"Draft formal response or status update\", icon: <Mail className=\"w-4 h-4\" /> },\n  { id: \"generate-spec\", name: \"/generate-spec\", desc: \"Create technical PRD & API specs\", icon: <FileSpreadsheet className=\"w-4 h-4\" /> },\n];\n\nconst MOCK_FILES = [\"architecture-spec.pdf\", \"user-churn-q3.csv\", \"ui-kit-v2.fig\"];\n\nconst VARIANT_MAP = {\n  rounded: \"rounded-2xl bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800\",\n  pill: \"rounded-full px-3 py-1 bg-white/80 dark:bg-zinc-950/80 backdrop-blur-md border border-zinc-200/80 dark:border-zinc-800/80 shadow-md\",\n  glass: \"rounded-2xl bg-white/80 dark:bg-zinc-950/80 backdrop-blur-md border border-zinc-200/80 dark:border-zinc-800/80 shadow-md\",\n  minimal: \"rounded-xl bg-zinc-50 dark:bg-zinc-900/60 border border-transparent hover:border-zinc-200 dark:hover:border-zinc-800\",\n};\n\nexport const AiPromptBar: React.FC<AiPromptBarProps> = ({\n  placeholder = \"Ask AI, type @ or /…\",\n  variant = \"rounded\",\n  models = DEFAULT_MODELS,\n  defaultModelId = \"claude-3-7-sonnet\",\n  sources = DEFAULT_SOURCES,\n  commands = DEFAULT_COMMANDS,\n  onSend,\n  className,\n  disabled = false,\n}) => {\n  const [draft, setDraft] = useState(\"\");\n  const [selectedModel, setSelectedModel] = useState<AiModel>(\n    models.find((m) => m.id === defaultModelId) || models[0]\n  );\n  const [attachments, setAttachments] = useState<string[]>([]);\n  const [plusOpen, setPlusOpen] = useState(false);\n  const [modelOpen, setModelOpen] = useState(false);\n  const [listening, setListening] = useState(false);\n  const [menuActiveIndex, setMenuActiveIndex] = useState(0);\n\n  const inputRef = useRef<HTMLTextAreaElement>(null);\n  const controlsRef = useRef<HTMLDivElement>(null);\n\n  // Extract token query for @ or /\n  const tokenMatch = /(^|\\s)([@/])([\\w-]*)$/.exec(draft);\n  const lastWord = draft.split(/\\s+/).pop() || \"\";\n\n  const tokenKind = plusOpen ? \"at\" : tokenMatch ? (tokenMatch[2] === \"@\" ? \"at\" : \"slash\") : null;\n  \n  // Real-time search query calculation\n  const tokenQuery = plusOpen\n    ? (tokenMatch ? tokenMatch[3].toLowerCase() : lastWord.startsWith(\"@\") ? lastWord.slice(1).toLowerCase() : lastWord.toLowerCase())\n    : (tokenMatch ? tokenMatch[3].toLowerCase() : \"\");\n\n  const menuRows = tokenKind === \"at\"\n    ? sources.filter((s) => s.name.toLowerCase().includes(tokenQuery) || s.desc.toLowerCase().includes(tokenQuery))\n    : tokenKind === \"slash\"\n      ? commands.filter((c) => c.name.toLowerCase().includes(tokenQuery) || c.desc.toLowerCase().includes(tokenQuery))\n      : [];\n\n  useEffect(() => {\n    setMenuActiveIndex(0);\n  }, [tokenKind, tokenQuery]);\n\n  // Auto grow input\n  useLayoutEffect(() => {\n    const input = inputRef.current;\n    if (!input) return;\n\n    if (!draft) {\n      input.style.height = \"24px\";\n    } else {\n      input.style.height = \"0px\";\n      const scrollH = input.scrollHeight;\n      input.style.height = `${Math.min(Math.max(scrollH, 24), 120)}px`;\n    }\n  }, [draft]);\n\n  // Dictation mock\n  useEffect(() => {\n    if (!listening) return;\n    const timer = setTimeout(() => {\n      setDraft((prev) => (prev ? `${prev.trim()} Audit user retention trends for Q3` : \"Audit user retention trends for Q3\"));\n      setListening(false);\n      inputRef.current?.focus();\n    }, 2200);\n    return () => clearTimeout(timer);\n  }, [listening]);\n\n  const handleSelectModel = (m: AiModel) => {\n    setSelectedModel(m);\n    setModelOpen(false);\n  };\n\n  const handlePickRow = (item: AiSource | AiCommand) => {\n    if (\"attach\" in item && item.attach) {\n      const nextFile = MOCK_FILES[attachments.length % MOCK_FILES.length];\n      setAttachments((prev) => [...prev, nextFile]);\n      if (tokenMatch) {\n        setDraft(draft.slice(0, tokenMatch.index + tokenMatch[1].length));\n      }\n    } else {\n      const isAt = tokenKind === \"at\";\n      const prefix = isAt ? \"@\" : \"\";\n      \n      if (tokenMatch) {\n        const base = draft.slice(0, tokenMatch.index + tokenMatch[1].length);\n        setDraft(`${base}${prefix}${item.name} `);\n      } else {\n        // Strip trailing search word if user typed query after clicking plus\n        const words = draft.trimEnd().split(/\\s+/);\n        if (words.length > 0 && !draft.endsWith(\" \")) {\n          words.pop();\n        }\n        const base = words.length > 0 ? words.join(\" \") + \" \" : \"\";\n        setDraft(`${base}${prefix}${item.name} `);\n      }\n    }\n    setPlusOpen(false);\n    setTimeout(() => inputRef.current?.focus(), 10);\n  };\n\n  const handleSend = () => {\n    if ((!draft.trim() && attachments.length === 0) || disabled) return;\n    if (onSend) {\n      onSend({ text: draft.trim(), model: selectedModel, attachments });\n    }\n    setDraft(\"\");\n    setAttachments([]);\n    setPlusOpen(false);\n    setModelOpen(false);\n  };\n\n  const isPill = variant === \"pill\";\n  const roundedClass = isPill ? \"rounded-full\" : variant === \"minimal\" ? \"rounded-xl\" : \"rounded-2xl\";\n\n  return (\n    <div className={cn(\"relative w-full max-w-xl mx-auto font-sans text-zinc-900 dark:text-zinc-100\", roundedClass, className)}>\n      {/* ── Dropdown Menus ── */}\n      <AnimatePresence>\n        {/* @ or / Menu */}\n        {tokenKind && (\n          <motion.div\n            initial={{ opacity: 0, y: 6, scale: 0.98 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: 4, scale: 0.98 }}\n            transition={{ duration: 0.15, ease: \"easeOut\" }}\n            className=\"absolute bottom-full left-0 right-0 z-50 mb-2 rounded-2xl bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 shadow-xl overflow-hidden\"\n          >\n            <div className=\"max-h-56 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden p-1 space-y-0.5\">\n              {menuRows.map((row, i) => {\n                const isActive = i === menuActiveIndex;\n                const source = tokenKind === \"at\" ? (row as AiSource) : undefined;\n                return (\n                  <button\n                    key={row.id}\n                    type=\"button\"\n                    onMouseEnter={() => setMenuActiveIndex(i)}\n                    onMouseDown={(e) => {\n                      e.preventDefault();\n                      handlePickRow(row);\n                    }}\n                    className={cn(\n                      \"w-full flex items-center justify-between gap-3 px-3 py-2 rounded-xl text-left text-xs transition-all duration-150 cursor-pointer\",\n                      isActive\n                        ? \"bg-zinc-100 dark:bg-zinc-850 font-semibold\"\n                        : \"hover:bg-zinc-50 dark:hover:bg-zinc-900/60\"\n                    )}\n                  >\n                    <div className=\"flex items-center gap-3 min-w-0\">\n                      <div className=\"shrink-0 w-5 h-5 flex items-center justify-center text-zinc-600 dark:text-zinc-400\">\n                        {source?.brand ? BRAND_ICONS[source.brand] : (row.icon || <Paperclip className=\"w-4 h-4\" />)}\n                      </div>\n                      <span className=\"font-bold text-zinc-900 dark:text-white shrink-0\">{row.name}</span>\n                      <span className=\"text-[12px] text-zinc-400 dark:text-zinc-500 truncate\">{row.desc}</span>\n                    </div>\n\n                    {source?.connected ? (\n                      <span className=\"text-[12px] font-medium text-emerald-600 dark:text-emerald-400 shrink-0\">\n                        Connected\n                      </span>\n                    ) : isActive ? (\n                      <CommandIcon className=\"w-3.5 h-3.5 shrink-0 text-zinc-400\" />\n                    ) : null}\n                  </button>\n                );\n              })}\n              {menuRows.length === 0 && (\n                <div className=\"px-3 py-3 text-center text-xs text-zinc-400 dark:text-zinc-500\">\n                  No matches for &quot;{tokenQuery}&quot;\n                </div>\n              )}\n            </div>\n            <div className=\"px-3 py-2 border-t border-zinc-100 dark:border-zinc-900 text-[11px] text-zinc-400 dark:text-zinc-500\">\n              {tokenKind === \"at\" ? \"Type to search sources & files\" : \"Type to search commands\"}\n            </div>\n          </motion.div>\n        )}\n\n        {/* Model Menu */}\n        {modelOpen && (\n          <motion.div\n            initial={{ opacity: 0, y: 6, scale: 0.96 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: 4, scale: 0.96 }}\n            transition={{ duration: 0.15, ease: \"easeOut\" }}\n            className=\"absolute bottom-full right-0 z-50 mb-2 w-52 p-1.5 rounded-2xl bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 shadow-xl overflow-hidden\"\n          >\n            <div className=\"px-2.5 py-1 text-[10px] font-mono tracking-wider uppercase text-zinc-400 dark:text-zinc-500 border-b border-zinc-100 dark:border-zinc-900 mb-1\">\n              Trending AI Models\n            </div>\n            <div className=\"py-0.5 space-y-0.5 max-h-56 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden\">\n              {models.map((m) => {\n                const isSelected = m.id === selectedModel.id;\n                return (\n                  <button\n                    key={m.id}\n                    type=\"button\"\n                    onMouseDown={(e) => {\n                      e.preventDefault();\n                      handleSelectModel(m);\n                    }}\n                    className={cn(\n                      \"w-full flex items-center justify-between px-3 py-2 rounded-xl text-xs text-left transition-colors duration-150 cursor-pointer\",\n                      isSelected\n                        ? \"bg-zinc-100 dark:bg-zinc-800 font-semibold text-zinc-900 dark:text-white\"\n                        : \"hover:bg-zinc-50 dark:hover:bg-zinc-900 text-zinc-700 dark:text-zinc-300\"\n                    )}\n                  >\n                    <div className=\"flex items-center gap-2\">\n                      {m.icon}\n                      <span>{m.name}</span>\n                    </div>\n                    {m.tag && (\n                      <span className=\"text-[10px] text-zinc-400 dark:text-zinc-500 font-normal\">\n                        {m.tag}\n                      </span>\n                    )}\n                  </button>\n                );\n              })}\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      {/* ── Main Composer Container ── */}\n      <div\n        className={cn(\n          \"relative flex flex-col gap-1.5 p-1.5 transition-all duration-200\",\n          VARIANT_MAP[variant] || VARIANT_MAP.rounded\n        )}\n      >\n        {/* Attachments */}\n        <AnimatePresence>\n          {attachments.length > 0 && (\n            <motion.div\n              initial={{ opacity: 0, height: 0 }}\n              animate={{ opacity: 1, height: \"auto\" }}\n              exit={{ opacity: 0, height: 0 }}\n              className=\"flex flex-wrap gap-1.5 px-2 pt-1\"\n            >\n              {attachments.map((file, idx) => (\n                <motion.span\n                  key={`${file}-${idx}`}\n                  initial={{ scale: 0.9, opacity: 0 }}\n                  animate={{ scale: 1, opacity: 1 }}\n                  exit={{ scale: 0.9, opacity: 0 }}\n                  className=\"flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs bg-zinc-100 dark:bg-zinc-900 text-zinc-800 dark:text-zinc-200 border border-zinc-200/60 dark:border-zinc-800/60\"\n                >\n                  <Paperclip className=\"w-3 h-3 text-zinc-400\" />\n                  <span className=\"max-w-[140px] truncate\">{file}</span>\n                  <button\n                    type=\"button\"\n                    onClick={() => setAttachments((prev) => prev.filter((_, i) => i !== idx))}\n                    className=\"p-0.5 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 text-zinc-400 hover:text-zinc-800 dark:hover:text-zinc-100 transition-colors\"\n                  >\n                    <X className=\"w-3 h-3\" />\n                  </button>\n                </motion.span>\n              ))}\n            </motion.div>\n          )}\n        </AnimatePresence>\n\n        {/* Controls Row */}\n        <div ref={controlsRef} className=\"flex items-center gap-2 w-full px-1\">\n          {/* Plus icon Button */}\n          <button type=\"button\" aria-label=\"Add attachment\"\n            onClick={() => {\n              setModelOpen(false);\n              setPlusOpen((prev) => !prev);\n              inputRef.current?.focus();\n            }}\n            className={cn(\"w-8 h-8 shrink-0 flex items-center justify-center transition-colors text-zinc-500 hover:text-zinc-900 dark:hover:text-zinc-100 hover:bg-zinc-100 dark:hover:bg-zinc-800\", isPill ? \"rounded-full\" : \"rounded-xl\")}\n          >\n            <Plus className=\"w-4 h-4\" />\n          </button>\n\n          {/* Textarea */}\n          <textarea\n            ref={inputRef}\n            rows={1}\n            value={draft}\n            disabled={disabled}\n            onChange={(e) => {\n              setDraft(e.target.value);\n            }}\n            onKeyDown={(e) => {\n              if (tokenKind && menuRows.length > 0) {\n                if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n                  e.preventDefault();\n                  setMenuActiveIndex((prev) => (prev + (e.key === \"ArrowDown\" ? 1 : menuRows.length - 1)) % menuRows.length);\n                  return;\n                }\n                if (e.key === \"Enter\" && !e.shiftKey) {\n                  e.preventDefault();\n                  handlePickRow(menuRows[menuActiveIndex]);\n                  return;\n                }\n              }\n              if (e.key === \"Escape\") {\n                setPlusOpen(false);\n                setModelOpen(false);\n                return;\n              }\n              if (e.key === \"Enter\" && !e.shiftKey && !e.nativeEvent.isComposing) {\n                e.preventDefault();\n                handleSend();\n              }\n            }}\n            placeholder={listening ? \"Listening…\" : placeholder}\n            className=\"flex-1 min-h-[28px] max-h-[120px] py-1 px-1 bg-transparent border-none outline-none ring-0 ring-offset-0 shadow-none focus:border-none focus:outline-none focus:ring-0 focus:ring-offset-0 focus:shadow-none focus-visible:border-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none text-sm leading-relaxed text-zinc-900 dark:text-zinc-100 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 resize-none overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden\"\n          />\n\n          {/* Model Selector Button */}\n          <button type=\"button\"\n            onClick={() => {\n              setPlusOpen(false);\n              setModelOpen((prev) => !prev);\n            }}\n            className=\"flex items-center gap-1 px-2.5 py-1 h-8 rounded-lg text-xs font-medium text-zinc-600 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors shrink-0\"\n          >\n            <span>{selectedModel.name}</span>\n            <ChevronDown className=\"w-3.5 h-3.5 text-zinc-400\" />\n          </button>\n\n          {/* Dictation Button */}\n          <button type=\"button\" aria-label={listening ? \"Stop dictation\" : \"Start dictation\"}\n            onClick={() => setListening((prev) => !prev)}\n            className={cn(\"w-8 h-8 shrink-0 p-0\", isPill ? \"rounded-full\" : \"rounded-xl\")}\n          >\n            <AudioLines className=\"w-4 h-4\" />\n          </button>\n\n          {/* Send Button */}\n          <button type=\"button\"\n            disabled={(!draft.trim() && attachments.length === 0) || disabled}\n            onClick={handleSend}\n            className={cn(\"w-8 h-8 shrink-0 p-0\", isPill ? \"rounded-full\" : \"rounded-xl\")}\n          >\n            <ArrowUp className=\"w-4 h-4\" />\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n};\n\nexport default AiPromptBar;\n"
    }
  ]
}