{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "plan-approval-card",
  "title": "Plan Approval Card",
  "description": "A proposed plan with clear steps and controls to edit, cancel, or start the work.",
  "dependencies": [
    "cn@^0.3.0"
  ],
  "registryDependencies": [
    "button",
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/plan-approval-card.tsx",
      "content": "import * as React from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\ninterface PlanApprovalStep {\n  id: string\n  label: string\n}\n\ninterface PlanApprovalCardProps extends React.ComponentProps<'section'> {\n  title: string\n  steps: PlanApprovalStep[]\n  onEdit?: () => void\n  onStepsChange?: (steps: PlanApprovalStep[]) => void\n  onCancel?: () => void\n  onStart?: () => void\n  disabled?: boolean\n  /** Controlled display only; the card never starts a plan automatically. */\n  countdownSeconds?: number\n  countdownDuration?: number\n}\n\nfunction PlanApprovalCard({\n  className,\n  title,\n  steps,\n  onEdit,\n  onStepsChange,\n  onCancel,\n  onStart,\n  disabled = false,\n  countdownSeconds,\n  countdownDuration = 60,\n  ...props\n}: PlanApprovalCardProps) {\n  const titleId = React.useId()\n  const [editing, setEditing] = React.useState(false)\n  const inputs = React.useRef(new Map<string, HTMLInputElement>())\n  const pendingFocus = React.useRef<string | undefined>(undefined)\n  const nextStepId = React.useRef(0)\n\n  React.useEffect(() => {\n    const id = pendingFocus.current\n    const input = id ? inputs.current.get(id) : undefined\n    if (!input) return\n    input.focus()\n    pendingFocus.current = undefined\n  })\n\n  function update(id: string, label: string) {\n    onStepsChange?.(steps.map((step) => (step.id === id ? { ...step, label } : step)))\n  }\n\n  function addStep() {\n    nextStepId.current += 1\n    const id = `${titleId}-step-${nextStepId.current}`\n    onStepsChange?.([...steps, { id, label: '' }])\n    pendingFocus.current = id\n  }\n\n  function finishEditing() {\n    onStepsChange?.(steps.filter((step) => step.label.trim()))\n    setEditing(false)\n  }\n  const seconds =\n    countdownSeconds === undefined || !Number.isFinite(countdownSeconds)\n      ? undefined\n      : Math.max(0, Math.ceil(countdownSeconds))\n  const progress =\n    seconds === undefined || !Number.isFinite(countdownDuration) || countdownDuration <= 0\n      ? 0\n      : Math.min(1, seconds / countdownDuration)\n\n  return (\n    <section\n      aria-labelledby={titleId}\n      data-slot=\"plan-approval-card\"\n      className={cn(\n        'w-fit max-w-full rounded-[16px] bg-card p-5 font-sans text-sm leading-5 font-[450] tracking-[-0.05px] text-muted-foreground shadow-card transition-[opacity,translate] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] sm:p-6 starting:translate-y-1 starting:opacity-0 motion-reduce:starting:translate-y-0',\n        className,\n      )}\n      {...props}\n    >\n      <h3 id={titleId} className=\"card-heading leading-[19.25px]\">\n        {title}\n      </h3>\n      <ol className=\"mt-6 space-y-5\">\n        {steps.map((step, index) => (\n          <li\n            key={step.id}\n            className=\"group/step flex items-start gap-4 transition-[opacity,translate] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] starting:-translate-y-1 starting:opacity-0 motion-reduce:starting:translate-y-0\"\n          >\n            <span\n              aria-hidden=\"true\"\n              className=\"mt-0.5 size-4 shrink-0 rounded-full border-2 border-dashed border-muted-foreground/50\"\n            />\n            {editing ? (\n              <>\n                <label className=\"sr-only\" htmlFor={`${titleId}-${step.id}`}>\n                  Step {index + 1}\n                </label>\n                <input\n                  className=\"min-w-0 flex-1 bg-transparent text-sm leading-5 text-muted-foreground outline-none placeholder:text-muted-foreground/50\"\n                  id={`${titleId}-${step.id}`}\n                  onChange={(event) => update(step.id, event.target.value)}\n                  onKeyDown={(event) => {\n                    if (event.key === 'Enter') {\n                      event.preventDefault()\n                      if (index === steps.length - 1) addStep()\n                      else inputs.current.get(steps[index + 1].id)?.focus()\n                    }\n                    if (event.key === 'Escape') finishEditing()\n                    if (event.key === 'Backspace' && !step.label && steps.length > 1) {\n                      event.preventDefault()\n                      onStepsChange?.(steps.filter((item) => item.id !== step.id))\n                      pendingFocus.current = steps[Math.max(0, index - 1)].id\n                    }\n                  }}\n                  placeholder=\"Describe this step\"\n                  ref={(element) => {\n                    if (element) inputs.current.set(step.id, element)\n                    else inputs.current.delete(step.id)\n                  }}\n                  value={step.label}\n                />\n                <button\n                  aria-label={`Remove step ${index + 1}`}\n                  className=\"-my-0.5 flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity duration-150 outline-none group-focus-within/step:opacity-100 group-hover/step:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/40 pointer-coarse:opacity-100\"\n                  onClick={() => onStepsChange?.(steps.filter((item) => item.id !== step.id))}\n                  type=\"button\"\n                >\n                  <svg\n                    aria-hidden=\"true\"\n                    className=\"size-3.5\"\n                    fill=\"none\"\n                    stroke=\"currentColor\"\n                    strokeLinecap=\"round\"\n                    strokeWidth=\"1.5\"\n                    viewBox=\"0 0 16 16\"\n                  >\n                    <path d=\"m4.5 4.5 7 7m0-7-7 7\" />\n                  </svg>\n                </button>\n              </>\n            ) : (\n              <span className=\"min-w-0 break-words\">{step.label}</span>\n            )}\n          </li>\n        ))}\n        {editing && (\n          <li>\n            <button\n              className=\"-ml-1 flex items-center gap-4 rounded-full px-1 text-sm leading-5 text-muted-foreground transition-opacity outline-none hover:opacity-80 focus-visible:ring-2 focus-visible:ring-ring/40\"\n              onClick={addStep}\n              type=\"button\"\n            >\n              <svg\n                aria-hidden=\"true\"\n                className=\"size-4\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                strokeLinecap=\"round\"\n                strokeWidth=\"1.5\"\n                viewBox=\"0 0 16 16\"\n              >\n                <path d=\"M8 3.5v9M3.5 8h9\" />\n              </svg>\n              Add step\n            </button>\n          </li>\n        )}\n      </ol>\n      <div className=\"mt-8 flex flex-wrap items-center justify-between gap-3\">\n        <Button\n          type=\"button\"\n          variant=\"ghost\"\n          className=\"h-7 rounded-full px-3 text-sm font-[450] text-muted-foreground hover:text-muted-foreground\"\n          aria-pressed={editing}\n          disabled={disabled}\n          onClick={() => {\n            if (editing) finishEditing()\n            else {\n              setEditing(true)\n              onEdit?.()\n            }\n          }}\n        >\n          {editing ? 'Done' : 'Edit'}\n        </Button>\n        <div className=\"ml-auto flex items-center gap-1.5\">\n          <Button\n            type=\"button\"\n            variant=\"ghost\"\n            className=\"h-7 rounded-full px-3 text-sm font-[450] text-muted-foreground hover:text-muted-foreground\"\n            disabled={disabled}\n            onClick={onCancel}\n          >\n            Cancel\n          </Button>\n          <Button\n            type=\"button\"\n            variant=\"default\"\n            className=\"h-7 gap-2 rounded-full border-0 bg-primary bg-linear-to-b from-[color-mix(in_oklch,var(--primary),var(--primary-foreground)_30%)] to-primary px-3 text-sm font-[450] text-primary-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.14),0_1px_2px_rgba(0,0,0,0.18)] shadow-none hover:brightness-110 dark:bg-none\"\n            disabled={disabled || editing || steps.length === 0}\n            onClick={onStart}\n          >\n            Start\n            {seconds !== undefined && (\n              <span\n                className=\"relative flex size-5 items-center justify-center text-[10px] tabular-nums\"\n                aria-label={`${seconds} seconds remaining`}\n              >\n                <svg\n                  aria-hidden=\"true\"\n                  viewBox=\"0 0 32 32\"\n                  className=\"absolute inset-0 size-5 -rotate-90 fill-none stroke-current\"\n                >\n                  <circle cx=\"16\" cy=\"16\" r=\"14\" strokeWidth=\"1.5\" className=\"opacity-15\" />\n                  <circle\n                    cx=\"16\"\n                    cy=\"16\"\n                    r=\"14\"\n                    strokeWidth=\"1.5\"\n                    strokeLinecap=\"round\"\n                    pathLength=\"1\"\n                    strokeDasharray={`${progress} 1`}\n                    className=\"transition-[stroke-dasharray] duration-1000 ease-linear motion-reduce:transition-none\"\n                  />\n                </svg>\n                {seconds}\n              </span>\n            )}\n          </Button>\n        </div>\n      </div>\n    </section>\n  )\n}\n\nexport { PlanApprovalCard }\nexport type { PlanApprovalCardProps, PlanApprovalStep }\n",
      "type": "registry:component",
      "target": "@components/ai/plan-approval-card.tsx"
    },
    {
      "path": "src/components/ai/plan-research-card.tsx",
      "content": "import * as React from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\ninterface PlanResearchStep {\n  id: string\n  label: string\n  status: 'pending' | 'running' | 'complete'\n}\n\ninterface PlanResearchCardProps extends React.ComponentProps<'section'> {\n  title: string\n  steps: PlanResearchStep[]\n  progress: number\n  searchCount: number\n  statusText: string\n  onUpdate?: () => void\n  onStop?: () => void\n  disabled?: boolean\n}\n\nfunction PlanResearchCard({\n  title,\n  steps,\n  progress,\n  searchCount,\n  statusText,\n  onUpdate,\n  onStop,\n  disabled = false,\n  className,\n  ...props\n}: PlanResearchCardProps) {\n  const titleId = React.useId()\n  const percentage = Math.min(100, Math.max(0, progress))\n\n  return (\n    <section\n      aria-labelledby={titleId}\n      data-slot=\"plan-research-card\"\n      className={cn(\n        'w-fit max-w-full rounded-[16px] bg-card p-5 font-sans text-sm leading-5 font-[450] tracking-[-0.05px] text-muted-foreground shadow-card sm:p-6',\n        className,\n      )}\n      {...props}\n    >\n      <div className=\"flex items-center justify-between gap-4\">\n        <h3 id={titleId} className=\"card-heading leading-[19.25px]\">\n          {title}\n        </h3>\n        <Button\n          type=\"button\"\n          variant=\"ghost\"\n          className=\"h-7 shrink-0 rounded-full px-3 text-sm font-[450] text-muted-foreground hover:text-muted-foreground\"\n          onClick={onUpdate}\n          disabled={disabled || !onUpdate}\n        >\n          Update\n        </Button>\n      </div>\n      <ol className=\"mt-6 space-y-5\">\n        {steps.map((step) => (\n          <li key={step.id} className=\"flex items-start gap-4\">\n            {step.status === 'complete' ? (\n              <svg\n                aria-hidden=\"true\"\n                viewBox=\"0 0 16 16\"\n                className=\"mt-0.5 size-4 shrink-0 text-muted-foreground transition-[opacity,scale] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] starting:scale-90 starting:opacity-0 motion-reduce:starting:scale-100\"\n              >\n                <circle cx=\"8\" cy=\"8\" r=\"8\" fill=\"currentColor\" />\n                <path\n                  d=\"m4.5 8 2.2 2.2 4.8-5\"\n                  fill=\"none\"\n                  className=\"stroke-background\"\n                  strokeWidth=\"1.5\"\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                />\n              </svg>\n            ) : (\n              <span\n                aria-hidden=\"true\"\n                className={cn(\n                  'mt-0.5 size-4 shrink-0 rounded-full border-[1.5px]',\n                  step.status === 'running'\n                    ? 'border-muted-foreground'\n                    : 'border-dashed border-muted-foreground/50',\n                )}\n              />\n            )}\n            <span className=\"min-w-0 break-words\">\n              <span className=\"sr-only\">{step.status}: </span>\n              {step.label}\n            </span>\n          </li>\n        ))}\n      </ol>\n      <div className=\"mt-8\">\n        <div className=\"flex flex-wrap items-center justify-between gap-3\">\n          <output className=\"min-w-0 flex-1\">{statusText}</output>\n          <span className=\"shrink-0 tabular-nums\">\n            {searchCount.toLocaleString('en-US')} searches\n          </span>\n        </div>\n        <div className=\"mt-3 flex items-center gap-3\">\n          <progress\n            aria-label=\"Research progress\"\n            max={100}\n            value={percentage}\n            className=\"h-1 min-w-0 flex-1 appearance-none overflow-hidden rounded-full border-0 bg-muted [&::-moz-progress-bar]:rounded-full [&::-moz-progress-bar]:bg-muted-foreground [&::-webkit-progress-bar]:rounded-full [&::-webkit-progress-bar]:bg-muted [&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:bg-muted-foreground\"\n          />\n          <Button\n            type=\"button\"\n            aria-label=\"Stop research\"\n            variant=\"default\"\n            className=\"size-7 rounded-full border-0 bg-primary bg-linear-to-b from-[color-mix(in_oklch,var(--primary),var(--primary-foreground)_30%)] to-primary p-0 text-primary-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.14),0_1px_2px_rgba(0,0,0,0.18)] shadow-none hover:brightness-110 dark:bg-none\"\n            disabled={disabled || !onStop}\n            onClick={onStop}\n          >\n            <span aria-hidden=\"true\" className=\"size-2.5 rounded-[2px] bg-current\" />\n          </Button>\n        </div>\n      </div>\n    </section>\n  )\n}\n\nexport { PlanResearchCard }\nexport type { PlanResearchCardProps, PlanResearchStep }\n",
      "type": "registry:component",
      "target": "@components/ai/plan-research-card.tsx"
    }
  ],
  "type": "registry:component"
}