{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fine-tune-card",
  "title": "Fine-tune card",
  "description": "Controlled or uncontrolled design inspector for layout, dimensions, radius, opacity, and type.",
  "registryDependencies": [
    "https://beadkit.dev/r/ai-core.json"
  ],
  "files": [
    {
      "path": "components/ai/FineTuneCard.tsx",
      "content": "\"use client\";\n\nimport { useId, useState, type ChangeEvent, type ReactNode } from \"react\";\nimport styles from \"./ai-state.module.css\";\n\nexport type FineTuneLayout = \"row\" | \"column\" | \"grid\";\nexport interface FineTuneValues { layout: FineTuneLayout; width: number; height: number; radius: number; opacity: number; type: string }\nexport interface FineTuneCardProps { title?: string; value?: Partial<FineTuneValues>; defaultValue?: Partial<FineTuneValues>; typeOptions?: readonly string[]; onChange?: (value: FineTuneValues) => void; className?: string }\n\nconst defaults: FineTuneValues = { layout: \"row\", width: 320, height: 96, radius: 16, opacity: 100, type: \"\" };\nfunction clamp(value: number, min: number, max: number) { return Math.max(min, Math.min(max, value)); }\nfunction LayoutIcon({ layout }: { layout: FineTuneLayout }) { return <span aria-hidden=\"true\" className={layout === \"column\" ? \"flex flex-col gap-0.5\" : layout === \"grid\" ? \"grid grid-cols-2 gap-0.5\" : \"flex gap-0.5\"}>{Array.from({ length: layout === \"grid\" ? 4 : 3 }, (_, i) => <i key={i} className=\"border-current size-1.5 rounded-[2px] border\" />)}</span>; }\n\n/** A presentational shell for compact inspector controls. */\nexport function FineTuneCardFrame({ title = \"Fine tune\", action, children, footer, className = \"\" }: { title?: string; action?: ReactNode; children: ReactNode; footer?: ReactNode; className?: string }) {\n  return <section data-ai-state=\"fine-tune-card\" className={`bg-card w-full max-w-sm rounded-xl border shadow-sm ${className}`}><header className=\"border-border flex items-center justify-between border-b px-3 py-2.5\"><h2 className=\"text-foreground text-sm font-medium\">{title}</h2><div className=\"flex min-h-8 min-w-12 items-center justify-end\">{action ?? <span className=\"text-muted-foreground text-xs\">Adjust</span>}</div></header><div className=\"border-b p-3\">{children}</div>{footer ? <footer className=\"p-3\">{footer}</footer> : null}</section>;\n}\n\nexport function FineTuneCard({ title = \"Fine tune\", value, defaultValue, typeOptions = [], onChange, className = \"\" }: FineTuneCardProps) {\n  const typeId = useId();\n  const [baseline] = useState<FineTuneValues>(() => ({ ...defaults, ...defaultValue, ...value }));\n  const [internal, setInternal] = useState<FineTuneValues>(baseline);\n  const current = { ...internal, ...value } as FineTuneValues;\n  function update(next: Partial<FineTuneValues>) { const merged = { ...current, ...next }; setInternal(merged); onChange?.(merged); }\n  function numberChange(key: keyof Pick<FineTuneValues, \"width\" | \"height\" | \"radius\" | \"opacity\">, min: number, max: number) { return (event: ChangeEvent<HTMLInputElement>) => { const parsed = Number(event.target.value); if (Number.isFinite(parsed)) update({ [key]: clamp(parsed, min, max) }); }; }\n  const edited = JSON.stringify(current) !== JSON.stringify(baseline);\n  const reset = () => { setInternal(baseline); onChange?.(baseline); };\n  const previewLayout = current.layout === \"column\" ? \"flex-col\" : current.layout === \"grid\" ? \"grid grid-cols-2\" : \"flex-row\";\n  return <FineTuneCardFrame title={title} className={className} action={edited ? <button type=\"button\" onClick={reset} className={`${styles.fadeIn} text-success hover:bg-muted min-h-8 rounded-md px-2 text-xs font-medium`}>Reset</button> : undefined} footer={<div className=\"flex items-center justify-between gap-3\"><label className=\"text-muted-foreground text-xs\" htmlFor={typeId}>Type</label><select id={typeId} value={current.type} onChange={(event) => update({ type: event.target.value })} className=\"bg-muted text-foreground min-h-8 min-w-0 flex-1 rounded-md border px-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring\"><option value=\"\">Select type</option>{typeOptions.map((option) => <option key={option} value={option}>{option}</option>)}</select></div>}><div className=\"flex flex-col gap-3\"><span className=\"text-foreground text-xs font-medium\">Layout</span><div className=\"bg-muted grid grid-cols-3 gap-1 rounded-lg p-1\" role=\"group\" aria-label=\"Layout\"><span className=\"sr-only\">Choose layout</span>{([\"row\", \"column\", \"grid\"] as FineTuneLayout[]).map((layout) => <button key={layout} type=\"button\" aria-label={`${layout} layout`} aria-pressed={current.layout === layout} onClick={() => update({ layout })} className={`flex min-h-8 items-center justify-center rounded-md transition-colors duration-150 motion-reduce:transition-none ${current.layout === layout ? \"bg-card text-foreground shadow-sm\" : \"text-muted-foreground hover:text-foreground\"}`}><LayoutIcon layout={layout} /></button>)}</div><div className=\"grid grid-cols-2 gap-2\">{([ [\"width\", 40, 999], [\"height\", 24, 999], [\"radius\", 0, 64], [\"opacity\", 0, 100] ] as const).map(([key, min, max]) => <label key={key} className=\"bg-muted text-muted-foreground flex min-h-9 items-center gap-1 rounded-md px-2 text-xs\">{key}<input type=\"number\" min={min} max={max} value={current[key]} onChange={numberChange(key, min, max)} aria-label={`${key} value`} className=\"text-foreground min-w-0 flex-1 bg-transparent text-right tabular-nums outline-none\" />{key === \"opacity\" ? \"%\" : null}</label>)}</div><div className=\"bg-muted overflow-hidden rounded-lg p-3\"><div className={`bg-accent/15 border-accent/40 flex gap-1 border p-2 ${previewLayout}`} style={{ width: `${clamp(current.width / 4, 20, 100)}%`, minHeight: `${clamp(current.height, 24, 100)}px`, borderRadius: `${current.radius}px`, opacity: current.opacity / 100 }}>{Array.from({ length: 4 }, (_, index) => <span key={index} aria-hidden=\"true\" className=\"bg-accent/40 min-h-3 min-w-3 flex-1 rounded-sm\" />)}<span className=\"sr-only\">Preview</span></div></div></div></FineTuneCardFrame>;\n}\n",
      "type": "registry:component",
      "target": "@components/ai/FineTuneCard.tsx"
    }
  ],
  "type": "registry:component"
}
