{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-odometer",
  "type": "registry:component",
  "title": "Text Odometer",
  "description": "Each digit rolls vertically to its new value like a mechanical counter, with separators and symbols left in place.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "text",
    "text",
    "odometer",
    "counter",
    "number",
    "rolling",
    "stats"
  ],
  "docs": "https://hyperblur.dev/effects/text-odometer",
  "files": [
    {
      "path": "registry/hyperblur/text-odometer.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/text-odometer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TextOdometerProps extends React.HTMLAttributes<HTMLSpanElement> {\n  value: string | number;\n  cycle?: (string | number)[];\n  interval?: number;\n  duration?: number;\n  stagger?: number;\n  animateOnMount?: boolean;\n  fade?: boolean;\n}\n\nconst digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nconst css = `\n.hb-qd8 {\n  position: relative;\n  display: inline-flex;\n  align-items: flex-start;\n  line-height: 1.2;\n  white-space: pre;\n  font-variant-numeric: tabular-nums;\n  font-family: inherit;\n  box-sizing: border-box;\n}\n.hb-qd8 *, .hb-qd8 *::before, .hb-qd8 *::after { box-sizing: border-box; }\n.hb-qd8-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  padding: 0;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  white-space: nowrap;\n  border: 0;\n}\n.hb-qd8-c {\n  display: inline-block;\n  height: 1.2em;\n  overflow: hidden;\n}\n.hb-qd8[data-fade] .hb-qd8-c {\n  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 0.2em, #000 calc(100% - 0.2em), transparent 100%);\n  mask-image: linear-gradient(to bottom, transparent 0, #000 0.2em, #000 calc(100% - 0.2em), transparent 100%);\n}\n.hb-qd8-s {\n  display: flex;\n  flex-direction: column;\n  transform: translate3d(0, calc(var(--hb-qd8-d) * -10%), 0);\n  transition: transform var(--hb-qd8-dur) cubic-bezier(.2, .9, .22, 1);\n  transition-delay: calc(var(--hb-qd8-n) * var(--hb-qd8-stagger));\n  will-change: transform;\n}\n.hb-qd8-s > span { display: block; height: 1.2em; text-align: center; }\n.hb-qd8-x { display: inline-block; height: 1.2em; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qd8-s { transition: none; will-change: auto; }\n}\n`;\n\nexport function TextOdometer({\n  value,\n  cycle,\n  interval = 2.6,\n  duration = 1.1,\n  stagger = 0.07,\n  animateOnMount = true,\n  fade = true,\n  className = \"\",\n  style,\n  ...rest\n}: TextOdometerProps) {\n  const [armed, setArmed] = React.useState(!animateOnMount);\n  const [index, setIndex] = React.useState(0);\n  const count = cycle ? cycle.length : 0;\n\n  React.useEffect(() => {\n    if (armed) return;\n    const id = requestAnimationFrame(() => requestAnimationFrame(() => setArmed(true)));\n    return () => cancelAnimationFrame(id);\n  }, [armed]);\n\n  React.useEffect(() => {\n    if (count < 2) return;\n    const id = setInterval(() => setIndex((i) => (i + 1) % count), Math.max(0.6, interval) * 1000);\n    return () => clearInterval(id);\n  }, [count, interval]);\n\n  const current = String(cycle && count > 0 ? cycle[index % count] : value);\n  const shown = armed ? current : current.replace(/[0-9]/g, \"0\");\n  const chars = Array.from(shown);\n  const len = chars.length;\n\n  const vars = {\n    \"--hb-qd8-dur\": `${duration}s`,\n    \"--hb-qd8-stagger\": `${stagger}s`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <span className={`hb-qd8 ${className}`} style={vars} data-fade={fade ? \"\" : undefined} {...rest}>\n      <style href=\"hb-text-odometer\" precedence=\"default\">{css}</style>\n      <span className=\"hb-qd8-sr\">{current}</span>\n      {chars.map((ch, i) => {\n        const fromRight = len - 1 - i;\n        if (!/[0-9]/.test(ch)) {\n          return (\n            <span key={`x${fromRight}`} className=\"hb-qd8-x\" aria-hidden=\"true\">\n              {ch}\n            </span>\n          );\n        }\n        const cell = { \"--hb-qd8-d\": Number(ch), \"--hb-qd8-n\": fromRight } as React.CSSProperties;\n        return (\n          <span key={`d${fromRight}`} className=\"hb-qd8-c\" aria-hidden=\"true\">\n            <span className=\"hb-qd8-s\" style={cell}>\n              {digits.map((d) => (\n                <span key={d}>{d}</span>\n              ))}\n            </span>\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n"
    }
  ]
}