{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tone-spark",
  "title": "ToneSpark",
  "description": "Compact daily bar sparkline filled with 45-degree SVG screentone dots.",
  "registryDependencies": [
    "https://frame12.dev/r/frame12-styles.json",
    "https://frame12.dev/r/use-on-twos.json",
    "https://frame12.dev/r/use-tempo.json"
  ],
  "files": [
    {
      "path": "ui/tone-spark.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { type MotionMode, useOnTwos, useSize } from '@/hooks/use-on-twos';\n\nexport interface ToneSparkProps {\n  values: number[];\n  label: string;\n  ariaLabel?: string;\n  rangeKey?: string | number;\n  motion?: MotionMode;\n  height?: number;\n  className?: string;\n}\n\nexport function ToneSpark({\n  values,\n  label,\n  ariaLabel,\n  rangeKey,\n  motion = 'stepped',\n  height = 40,\n  className = '',\n}: ToneSparkProps) {\n  const ref = React.useRef<HTMLDivElement | null>(null);\n  const { w } = useSize(ref);\n  const p = useOnTwos(rangeKey ?? values.length, 600, motion);\n  const rawId = React.useId();\n  const uid = React.useMemo(() => 's-' + rawId.replace(/:/g, ''), [rawId]);\n\n  const safeValues = React.useMemo(\n    () => values.map((v) => (Number.isFinite(v) ? Math.max(0, v) : 0)),\n    [values],\n  );\n  const H = height;\n  const max = Math.max(1, ...safeValues);\n  const n = safeValues.length;\n  const gap = n > 40 ? 1 : 2;\n  const isMeasured = w > 0;\n  const W = isMeasured ? w : 280;\n  const bw = n > 0 ? Math.max(1, (W - gap * (n - 1)) / n) : 0;\n  const shownCount = Math.ceil(n * p);\n  const computedAriaLabel = ariaLabel ?? `${label}, last ${n} days, one bar per day`;\n\n  return (\n    <div className={`f12-spark${className ? ` ${className}` : ''}`} ref={ref}>\n      <p className=\"f12-spark-l\">{label}</p>\n      {n > 0 && (\n        <svg\n          width={isMeasured ? W : '100%'}\n          height={H}\n          viewBox={`0 0 ${W} ${H}`}\n          preserveAspectRatio={isMeasured ? undefined : 'none'}\n          role=\"img\"\n          aria-label={computedAriaLabel}\n        >\n          <defs>\n            <pattern\n              id={`${uid}-st`}\n              width=\"4\"\n              height=\"4\"\n              patternUnits=\"userSpaceOnUse\"\n              patternTransform=\"rotate(45)\"\n            >\n              <circle cx=\"2\" cy=\"2\" r=\"1.05\" className=\"f12-tone-dot\" />\n            </pattern>\n          </defs>\n          {safeValues.map((v, i) =>\n            i < shownCount ? (\n              <rect\n                key={i}\n                className=\"f12-spark-bar\"\n                vectorEffect=\"non-scaling-stroke\"\n                fill={`url(#${uid}-st)`}\n                x={i * (bw + gap)}\n                y={H - (v / max) * H}\n                width={bw}\n                height={(v / max) * H}\n              />\n            ) : null,\n          )}\n        </svg>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/frame12/tone-spark.tsx"
    }
  ],
  "type": "registry:ui"
}