{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elements-approval-card",
  "type": "registry:component",
  "title": "Approval card",
  "description": "Human in the loop: the agent asks before it runs anything with side effects.",
  "registryDependencies": [
    "https://r.assistant-ui.com/elements-surfaces.json",
    "https://r.assistant-ui.com/elements-receipt-focus.json"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "type": "registry:component",
      "path": "components/assistant-ui/elements/approval-card.tsx",
      "sourcePath": "packages/ui/src/components/react/assistant-ui/elements/approval-card.tsx",
      "content": "\"use client\";\n\nimport { useId, type ComponentProps, type ReactNode } from \"react\";\nimport { CheckIcon, Loader2Icon, TerminalIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { field, ghostButton, inkButton, mono, paper } from \"./surfaces\";\nimport { useReceiptFocus } from \"./receipt-focus\";\n\nexport type ApprovalState = \"request\" | \"running\" | \"done\" | \"denied\";\n\nconst receiptText: Record<Exclude<ApprovalState, \"request\">, string> = {\n  running: \"Approved, running\",\n  done: \"Finished\",\n  denied: \"Denied\",\n};\n\nexport function ApprovalCard({\n  state,\n  command,\n  title,\n  subtitle,\n  description,\n  details,\n  variant = \"default\",\n  icon,\n  onAllowOnce,\n  onAlwaysAllow,\n  onDeny,\n  allowOnceLabel = \"Allow once\",\n  alwaysAllowLabel = \"Always allow\",\n  denyLabel = \"Deny\",\n  statusLabel,\n  className,\n  ...props\n}: Omit<\n  ComponentProps<\"div\">,\n  | \"children\"\n  | \"state\"\n  | \"command\"\n  | \"title\"\n  | \"subtitle\"\n  | \"description\"\n  | \"details\"\n  | \"variant\"\n  | \"icon\"\n  | \"onAllowOnce\"\n  | \"onAlwaysAllow\"\n  | \"onDeny\"\n  | \"allowOnceLabel\"\n  | \"alwaysAllowLabel\"\n  | \"denyLabel\"\n  | \"statusLabel\"\n> & {\n  state: ApprovalState;\n  command?: string | undefined;\n  title: string;\n  subtitle: string;\n  description?: string | undefined;\n  details?: readonly { label: string; value: string }[] | undefined;\n  variant?: \"default\" | \"destructive\" | undefined;\n  icon?: ReactNode | undefined;\n  onAllowOnce?: (() => void) | undefined;\n  onAlwaysAllow?: (() => void) | undefined;\n  onDeny?: (() => void) | undefined;\n  allowOnceLabel?: string | undefined;\n  alwaysAllowLabel?: string | undefined;\n  denyLabel?: string | undefined;\n  statusLabel?: string | undefined;\n}) {\n  const titleId = useId();\n  const descriptionId = useId();\n  const { receiptRef, focusHandlers } = useReceiptFocus<HTMLDivElement>(props);\n\n  return (\n    <div\n      {...props}\n      {...focusHandlers}\n      role=\"group\"\n      data-variant={variant}\n      data-slot=\"approval-card\"\n      aria-labelledby={titleId}\n      aria-describedby={description ? descriptionId : undefined}\n      className={cn(\n        paper,\n        \"flex w-full max-w-sm flex-col gap-3.5 rounded-[20px] p-4\",\n        className,\n      )}\n    >\n      <div className=\"flex items-center gap-3\">\n        <span\n          aria-hidden\n          className={cn(\n            \"flex size-9 shrink-0 items-center justify-center rounded-xl\",\n            variant === \"destructive\"\n              ? \"bg-red-600/10 text-red-600 dark:bg-red-400/10 dark:text-red-400\"\n              : \"bg-foreground/[0.05] text-muted-foreground\",\n          )}\n        >\n          {icon ?? <TerminalIcon className=\"size-4\" />}\n        </span>\n        <div className=\"flex flex-col\">\n          <p id={titleId} className=\"text-[13.5px] font-medium\">\n            {title}\n          </p>\n          <p className=\"text-muted-foreground text-xs\">{subtitle}</p>\n        </div>\n      </div>\n\n      {description ? (\n        <p id={descriptionId} className=\"text-foreground/60 text-[13px]\">\n          {description}\n        </p>\n      ) : null}\n\n      {command ? (\n        <div\n          className={cn(\n            field,\n            \"text-foreground/70 rounded-xl px-3.5 py-2.5 font-mono text-xs\",\n          )}\n        >\n          {command}\n        </div>\n      ) : null}\n\n      {details?.length ? (\n        <dl\n          className={cn(field, \"flex flex-col gap-2 rounded-xl px-3.5 py-2.5\")}\n        >\n          {details.map((detail, index) => (\n            <div\n              key={`${detail.label}-${index}`}\n              className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] gap-4 text-xs\"\n            >\n              <dt className={cn(mono, \"text-muted-foreground\")}>\n                {detail.label}\n              </dt>\n              <dd className=\"text-foreground/80 break-words\">{detail.value}</dd>\n            </div>\n          ))}\n        </dl>\n      ) : null}\n\n      <div className=\"flex min-h-8 flex-wrap items-center justify-end gap-2\">\n        {state === \"request\" ? (\n          <>\n            {onDeny && (\n              <button\n                type=\"button\"\n                data-slot=\"approval-card-deny\"\n                onClick={onDeny}\n                className={cn(\n                  ghostButton,\n                  \"h-8 px-3.5 text-xs font-medium whitespace-nowrap\",\n                )}\n              >\n                {denyLabel}\n              </button>\n            )}\n            {onAlwaysAllow && (\n              <button\n                type=\"button\"\n                data-slot=\"approval-card-always-allow\"\n                onClick={onAlwaysAllow}\n                className={cn(\n                  ghostButton,\n                  \"h-8 px-3.5 text-xs font-medium whitespace-nowrap\",\n                )}\n              >\n                {alwaysAllowLabel}\n              </button>\n            )}\n            {onAllowOnce && (\n              <button\n                type=\"button\"\n                data-slot=\"approval-card-allow-once\"\n                onClick={onAllowOnce}\n                className={cn(\n                  variant === \"destructive\"\n                    ? \"text-background bg-red-600 transition-[background-color,scale] duration-150 hover:bg-red-600/90 active:scale-[0.96] motion-reduce:transition-none dark:bg-red-400 dark:text-red-950 dark:hover:bg-red-400/90\"\n                    : inkButton,\n                  \"flex h-8 items-center rounded-full px-3.5 text-xs font-medium whitespace-nowrap\",\n                )}\n              >\n                {allowOnceLabel}\n              </button>\n            )}\n          </>\n        ) : (\n          <div\n            key={state}\n            ref={receiptRef}\n            tabIndex={-1}\n            role=\"status\"\n            className=\"fade-in animate-in text-muted-foreground flex items-center gap-2 text-xs duration-300 motion-reduce:animate-none\"\n          >\n            {state === \"running\" ? (\n              <>\n                <Loader2Icon className=\"text-muted-foreground size-3.5 animate-spin motion-reduce:animate-none\" />\n                {statusLabel ?? receiptText.running}\n              </>\n            ) : state === \"denied\" ? (\n              <>\n                <XIcon className=\"text-muted-foreground size-3.5\" />\n                {statusLabel ?? receiptText.denied}\n              </>\n            ) : (\n              <>\n                <CheckIcon className=\"size-3.5 text-emerald-500\" />\n                {statusLabel ?? receiptText.done}\n              </>\n            )}\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}