{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "number-ticker",
  "type": "registry:item",
  "title": "Number Ticker",
  "description": "A number that counts to `value` when it scrolls into view, and on from there when `value` changes: for stats and dashboards. Formatted for `locale` with `decimals`, `prefix` and `suffix`; screen readers get the final number, and reduced motion shows it at once.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "motion"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/number-ticker.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/number-ticker.js",
      "content": "// Generated by zubra from number-ticker.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { onMount, effect } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"number-ticker\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: 0, required: false },\n    \"from\": { attribute: \"from\", default: 0, required: false },\n    \"duration\": { attribute: \"duration\", default: 1500, required: false },\n    \"decimals\": { attribute: \"decimals\", default: 0, required: false },\n    \"prefix\": { attribute: \"prefix\", default: \"\", required: false },\n    \"suffix\": { attribute: \"suffix\", default: \"\", required: false },\n    \"locale\": { attribute: \"locale\", default: \"\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (number-ticker) to ([data-zb-slotted=\\\"number-ticker\\\"]) {\\n  :scope { display: inline-block; }\\n  .ticker-number { font-variant-numeric: tabular-nums; }\\n  .ticker-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\\n}\\n}\\n\",\n  template: \"\\n  <span class=\\\"ticker\\\">\\n    <span class=\\\"ticker-number\\\" aria-hidden=\\\"true\\\"></span>\\n    <span class=\\\"ticker-label\\\"></span>\\n  </span>\\n\",\n  setup($p, $emit) {\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                                  \n\n  const shown = __zubraState($p.from)\n  const started = __zubraState(false)\n  const box = __zubraState(null)\n  // Where the count is, and the frame it's waiting for: plain values, so counting doesn't re-run itself.\n  const at = __zubraComputed(() => ({ number: $p.from, frame: 0 }))\n  const format = (number) => `${$p.prefix}${new Intl.NumberFormat($p.locale || undefined, { minimumFractionDigits: $p.decimals, maximumFractionDigits: $p.decimals }).format(number)}${$p.suffix}`\n  const text = __zubraComputed(() => (format(shown.get())))\n  const final = __zubraComputed(() => (format($p.value)))\n\n  function show(number) {\n    at.get().number = number\n    __zubraAssign(shown, number)\n  }\n  function count(to) {\n    cancelAnimationFrame(at.get().frame)\n    const reduced = globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches\n    if (reduced || !($p.duration > 0)) return show(to)\n    const start = at.get().number\n    const length = $p.duration\n    const begun = performance.now()\n    const step = (now) => {\n      const progress = Math.min(1, (now - begun) / length)\n      show(progress < 1 ? start + (to - start) * (1 - Math.pow(1 - progress, 3)) : to)\n      if (progress < 1) at.get().frame = requestAnimationFrame(step)\n    }\n    at.get().frame = requestAnimationFrame(step)\n  }\n\n  // Once it has been seen, it counts to each new value from where it is.\n  effect(() => {\n    const to = $p.value\n    if (started.get()) count(to)\n  })\n  onMount(() => {\n    if (!(\"IntersectionObserver\" in globalThis)) { __zubraAssign(started, true); return }\n    const watcher = new IntersectionObserver((entries) => {\n      if (!entries.some((entry) => entry.isIntersecting)) return\n      watcher.disconnect()\n      __zubraAssign(started, true)\n    })\n    watcher.observe(box.get())\n    return () => { watcher.disconnect(); cancelAnimationFrame(at.get().frame) }\n  })\n    return [\n      { path: [0], ref: () => (($el) => (__zubraAssign(box, $el))) },\n      { path: [0, 0], text: () => $t($r(text)) },\n      { path: [0, 1], text: () => $t($r(final)) },\n    ];\n  },\n});\n"
    }
  ]
}
