{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "abacus",
  "title": "Abacus",
  "author": "VenusUI",
  "description": "A soroban abacus: slide beads to the bar and read the number.",
  "files": [
    {
      "path": "registry/default/ui/abacus.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface AbacusProps extends Omit<React.ComponentProps<\"div\">, \"onChange\"> {\n  /** Number of rods (digits). */\n  rods?: number\n  defaultValue?: number\n  onValueChange?: (value: number) => void\n}\n\nconst BEAD_COLORS = [\"#b45309\", \"#be123c\", \"#047857\", \"#1d4ed8\", \"#6d28d9\", \"#c2410c\", \"#0f766e\", \"#a21caf\"]\n\n/**\n * A soroban abacus. Each rod is one digit: the top bead counts five, the\n * four below count one each. Click a bead to slide it to the bar, or focus a\n * rod and use the arrow keys (each rod is a slider from 0 to 9).\n */\nfunction Abacus({ rods = 6, defaultValue = 2026, onValueChange, className, ...props }: AbacusProps) {\n  const [digits, setDigits] = React.useState(() => String(defaultValue).padStart(rods, \"0\").slice(-rods).split(\"\").map(Number))\n  const value = Number(digits.join(\"\"))\n\n  const setDigit = (rod: number, digit: number) => {\n    const next = digits.map((d, i) => (i === rod ? Math.min(9, Math.max(0, digit)) : d))\n    setDigits(next)\n    onValueChange?.(Number(next.join(\"\")))\n  }\n\n  return (\n    <div data-slot=\"abacus\" className={cn(\"w-full max-w-md\", className)} {...props}>\n      <div className=\"rounded-xl bg-[linear-gradient(180deg,#78350f,#92400e)] p-2.5 shadow-[0_16px_26px_-14px_rgb(0_0_0/0.6)]\">\n        <div className=\"relative flex justify-around rounded-md bg-[#fbf3e4] px-2 py-3 dark:bg-[#2a2118]\">\n          <span aria-hidden=\"true\" className=\"absolute inset-x-0 top-[31%] h-2 bg-[#78350f]\" />\n          {digits.map((digit, rod) => {\n            const five = digit >= 5\n            const ones = digit % 5\n            const color = BEAD_COLORS[rod % BEAD_COLORS.length]\n            return (\n              <div\n                key={rod}\n                role=\"slider\"\n                tabIndex={0}\n                aria-label={`Rod ${rod + 1}`}\n                aria-valuemin={0}\n                aria-valuemax={9}\n                aria-valuenow={digit}\n                onKeyDown={(event) => {\n                  const step = event.key === \"ArrowUp\" || event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowDown\" || event.key === \"ArrowLeft\" ? -1 : 0\n                  if (!step) return\n                  event.preventDefault()\n                  setDigit(rod, digit + step)\n                }}\n                className=\"relative flex h-52 w-9 flex-col items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50\"\n              >\n                <span aria-hidden=\"true\" className=\"absolute inset-y-0 left-1/2 w-1 -translate-x-1/2 rounded-full bg-neutral-400\" />\n                {/* Heaven bead (5) */}\n                <span\n                  aria-hidden=\"true\"\n                  data-bead=\"five\"\n                  onClick={() => setDigit(rod, five ? digit - 5 : digit + 5)}\n                  className=\"relative mt-1 h-6 w-9 cursor-pointer rounded-[50%] shadow-[inset_0_-3px_4px_rgb(0_0_0/0.3),inset_0_2px_2px_rgb(255_255_255/0.4)] transition-transform duration-200 motion-reduce:transition-none\"\n                  style={{ background: color, transform: `translateY(${five ? 30 : 0}px)` }}\n                />\n                {/* Earth beads (1 each) */}\n                <div className=\"relative mt-auto flex flex-col gap-0.5 pb-1\">\n                  {[0, 1, 2, 3].map((bead) => {\n                    const up = bead < ones\n                    return (\n                      <span\n                        key={bead}\n                        aria-hidden=\"true\"\n                        data-bead=\"one\"\n                        onClick={() => setDigit(rod, (five ? 5 : 0) + (up ? bead : bead + 1))}\n                        className=\"relative h-6 w-9 cursor-pointer rounded-[50%] shadow-[inset_0_-3px_4px_rgb(0_0_0/0.3),inset_0_2px_2px_rgb(255_255_255/0.4)] transition-transform duration-200 motion-reduce:transition-none\"\n                        style={{ background: color, transform: `translateY(${up ? -22 : 0}px)` }}\n                      />\n                    )\n                  })}\n                </div>\n              </div>\n            )\n          })}\n        </div>\n      </div>\n      <p aria-live=\"polite\" className=\"mt-3 text-center font-mono text-2xl tabular-nums\">\n        {value.toLocaleString(\"en-US\")}\n      </p>\n    </div>\n  )\n}\n\nexport { Abacus }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "inputs",
    "data-display"
  ],
  "type": "registry:ui"
}