{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slot-machine",
  "title": "Slot Machine",
  "author": "VenusUI",
  "description": "A three-reel slot machine with a lever; reels stop one after another and three of a kind lights up.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/slot-machine.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Bell, Cherry, Citrus, Clover, Gem, Grape, Star, type LucideIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface SlotMachineProps extends React.ComponentProps<\"div\"> {\n  onResult?: (symbols: string[], win: boolean) => void\n}\n\nconst SYMBOLS: { name: string; Icon: LucideIcon; color: string }[] = [\n  { name: \"Cherry\", Icon: Cherry, color: \"#dc2626\" },\n  { name: \"Lemon\", Icon: Citrus, color: \"#ca8a04\" },\n  { name: \"Grape\", Icon: Grape, color: \"#7c3aed\" },\n  { name: \"Bell\", Icon: Bell, color: \"#d97706\" },\n  { name: \"Clover\", Icon: Clover, color: \"#16a34a\" },\n  { name: \"Star\", Icon: Star, color: \"#2563eb\" },\n  { name: \"Gem\", Icon: Gem, color: \"#db2777\" },\n]\nconst ROW = 64\nconst LOOPS = 4\n\n/**\n * A three-reel slot machine. Pull the lever (or press Spin): the reels blur,\n * then stop one after another. Three of a kind lights the marquee.\n */\nfunction SlotMachine({ onResult, className, ...props }: SlotMachineProps) {\n  const [stops, setStops] = React.useState([0, 2, 4])\n  const [spin, setSpin] = React.useState(0)\n  const [spinning, setSpinning] = React.useState(false)\n  const [message, setMessage] = React.useState(\"Pull the lever\")\n  const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)\n\n  React.useEffect(() => () => clearTimeout(timer.current), [])\n\n  const pull = () => {\n    if (spinning) return\n    const next = [0, 1, 2].map(() => Math.floor(Math.random() * SYMBOLS.length))\n    setStops(next)\n    setSpin((value) => value + 1)\n    setSpinning(true)\n    setMessage(\"Spinning…\")\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n    timer.current = setTimeout(() => {\n      setSpinning(false)\n      const names = next.map((i) => SYMBOLS[i].name)\n      const win = next.every((i) => i === next[0])\n      const pair = new Set(next).size === 2\n      setMessage(win ? `Jackpot! Three ${names[0].toLowerCase()}s.` : pair ? \"So close: a pair.\" : `${names.join(\", \")}. Try again.`)\n      onResult?.(names, win)\n    }, reduced ? 0 : 2300)\n  }\n\n  const win = !spinning && stops.every((i) => i === stops[0]) && spin > 0\n  const strip = Array.from({ length: LOOPS + 1 }, () => SYMBOLS).flat()\n\n  return (\n    <div data-slot=\"slot-machine\" className={cn(\"flex w-80 max-w-full items-start\", className)} {...props}>\n      <div className=\"min-w-0 flex-1 rounded-2xl bg-linear-to-b from-red-600 to-red-800 p-3 shadow-[0_18px_30px_-14px_rgb(0_0_0/0.65),inset_0_2px_0_rgb(255_255_255/0.25)]\">\n        <div className={cn(\"mb-3 rounded-md bg-neutral-950 py-1.5 text-center font-mono text-xs font-bold tracking-[0.3em] transition-colors\", win ? \"animate-pulse text-amber-300\" : \"text-amber-500/70\")}>\n          {win ? \"JACKPOT\" : \"LUCKY 7\"}\n        </div>\n        <div className=\"grid grid-cols-3 gap-1.5 rounded-lg bg-neutral-900 p-1.5\">\n          {stops.map((stop, reel) => (\n            <div key={reel} className=\"relative h-24 overflow-hidden rounded-md bg-linear-to-b from-neutral-300 via-white to-neutral-300\" style={{ height: ROW * 1.5 }}>\n              <div\n                key={spin}\n                aria-hidden=\"true\"\n                className={cn(\"absolute inset-x-0\", spin > 0 && \"transition-transform ease-[cubic-bezier(.15,.85,.25,1)] motion-reduce:transition-none\")}\n                style={{\n                  top: ROW * 0.25,\n                  transform: `translateY(${-(spin > 0 ? LOOPS * SYMBOLS.length + stop : stop) * ROW}px)`,\n                  transitionDuration: `${1300 + reel * 450}ms`,\n                }}\n              >\n                {strip.map((symbol, i) => (\n                  <div key={i} className=\"grid place-items-center\" style={{ height: ROW }}>\n                    <symbol.Icon className=\"size-10\" style={{ color: symbol.color }} strokeWidth={2.2} />\n                  </div>\n                ))}\n              </div>\n              <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 bg-linear-to-b from-black/35 via-transparent to-black/35\" />\n            </div>\n          ))}\n        </div>\n        <button type=\"button\" onClick={pull} disabled={spinning} className=\"mt-3 w-full rounded-md bg-amber-400 py-1.5 text-sm font-bold text-red-900 shadow-[0_3px_0_#b45309] outline-none transition-transform active:translate-y-[2px] focus-visible:ring-3 focus-visible:ring-ring/60 disabled:opacity-70\">\n          Spin\n        </button>\n        <p role=\"status\" className=\"mt-2 min-h-5 text-center text-xs text-red-50\">\n          {message}\n        </p>\n      </div>\n      {/* Lever */}\n      <button\n        type=\"button\"\n        onClick={pull}\n        disabled={spinning}\n        aria-label=\"Pull the lever\"\n        className=\"group mt-6 -ml-1 flex flex-col items-center outline-none focus-visible:[&>span:first-child]:ring-3 focus-visible:[&>span:first-child]:ring-ring/60\"\n      >\n        <span className={cn(\"size-7 rounded-full bg-[radial-gradient(circle_at_35%_30%,#fecaca,#dc2626_60%,#7f1d1d)] shadow-md transition-transform duration-300\", spinning && \"translate-y-20\")} />\n        <span className={cn(\"h-24 w-1.5 origin-bottom rounded-full bg-linear-to-r from-neutral-400 to-neutral-200 transition-transform duration-300\", spinning && \"scale-y-[0.15]\")} />\n        <span className=\"h-4 w-4 rounded-sm bg-neutral-700\" />\n      </button>\n    </div>\n  )\n}\n\nexport { SlotMachine }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "animations"
  ],
  "type": "registry:ui"
}