{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dice-tray",
  "title": "Dice tray",
  "description": "Pick a die, roll a handful, and keep the last four scores.",
  "dependencies": [
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/recipe-layout.json",
    "https://www.cyberspec.dev/r/button.json",
    "https://www.cyberspec.dev/r/readout.json",
    "https://www.cyberspec.dev/r/segmented-control.json"
  ],
  "files": [
    {
      "path": "registry/cyber/recipes/dice-tray.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Dice5 } from \"lucide-react\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { SegmentedControl } from \"@/registry/cyber/ui/segmented-control\"\nimport { Readout } from \"@/registry/cyber/ui/readout\"\nimport \"./recipe-layout.css\"\n\nconst dice = [\"D4\", \"D6\", \"D12\", \"D20\"]\ntype Roll = { faces: string; values: number[] }\n\nexport default function DiceTray() {\n  const [faces, setFaces] = useState(\"D6\")\n  const [rolls, setRolls] = useState<Roll[]>([])\n  const latest = rolls[0]\n  function roll() {\n    const sides = Number(faces.slice(1))\n    const values = Array.from({length: 3}, () => 1 + Math.floor(Math.random() * sides))\n    setRolls([{faces, values}, ...rolls].slice(0, 4))\n  }\n  return (\n    <div className=\"sink-stack\">\n      <div className=\"sink-between\">\n        <Readout label=\"Last total\" value={latest?.values.reduce((a, b) => a + b, 0) ?? 0} size=\"lg\" />\n        <Dice5 size={52} color=\"var(--cy-ink)\" aria-hidden />\n      </div>\n      <SegmentedControl label=\"Die type\" fill value={faces} onValueChange={value => { if (value) setFaces(value) }} options={dice} />\n      <Button tone=\"signal\" onClick={roll}>Roll 3{faces.toLowerCase()}</Button>\n      <div role=\"status\" className=\"sink-note\">{latest ? `3${latest.faces.toLowerCase()} rolled ${latest.values.join(\" + \")}` : \"Roll three dice to start a score sheet.\"}</div>\n      {rolls.length > 1 && <p className=\"sink-note\">Previous totals · {rolls.slice(1).map(r => r.values.reduce((a, b) => a + b, 0)).join(\" / \")}</p>}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/recipes/dice-tray.tsx"
    }
  ],
  "categories": [
    "recipe",
    "arcade"
  ],
  "type": "registry:component"
}
