{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hud-shelf-slider",
  "type": "registry:component",
  "title": "HUD Shelf Slider",
  "description": "A stepped horizontal slider with tick marks, a diamond thumb, a 03 / 09 counter and the name of the current step.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hud",
    "slider",
    "range",
    "steps",
    "hud",
    "ticks",
    "input"
  ],
  "docs": "https://hyperblur.dev/effects/hud-shelf-slider",
  "files": [
    {
      "path": "registry/hyperblur/hud-shelf-slider.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hud-shelf-slider.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HudShelfSliderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  count?: number;\n  value?: number;\n  defaultValue?: number;\n  onChange?: (index: number) => void;\n  label?: string;\n  labels?: string[];\n  accent?: string;\n}\n\nconst css = `\n.hb-ua4 {\n  --hb-ua4-accent: #ff4d4d;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  gap: 10px;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n}\n.hb-ua4 *, .hb-ua4 *::before, .hb-ua4 *::after { box-sizing: border-box; }\n.hb-ua4-top {\n  display: flex;\n  align-items: baseline;\n  justify-content: space-between;\n  gap: 12px;\n  min-width: 0;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 10px;\n  letter-spacing: .14em;\n  text-transform: uppercase;\n}\n.hb-ua4-name { display: flex; gap: 10px; min-width: 0; color: #8f8f8f; }\n.hb-ua4-name b { font-weight: 400; color: #ededed; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-ua4-count { flex: 0 0 auto; color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-ua4-count b { font-weight: 400; color: var(--hb-ua4-accent); }\n.hb-ua4-track {\n  position: relative;\n  height: 30px;\n  margin: 0 7px;\n  cursor: pointer;\n  touch-action: none;\n}\n.hb-ua4-line {\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 50%;\n  height: 1px;\n  background: rgba(255,255,255,.16);\n}\n.hb-ua4-fill {\n  position: absolute;\n  left: 0;\n  top: 50%;\n  height: 1px;\n  width: var(--hb-ua4-p);\n  background: var(--hb-ua4-accent);\n  box-shadow: 0 0 8px var(--hb-ua4-accent);\n  transition: width .22s cubic-bezier(.2, .8, .2, 1);\n}\n.hb-ua4-tick {\n  position: absolute;\n  top: 50%;\n  width: 1px;\n  height: 5px;\n  margin-top: 3px;\n  background: rgba(255,255,255,.18);\n  transform: translateX(-.5px);\n}\n.hb-ua4-tick[data-major=\"true\"] { height: 9px; margin-top: -4.5px; background: rgba(255,255,255,.4); }\n.hb-ua4-tick[data-lit=\"true\"] { background: color-mix(in srgb, var(--hb-ua4-accent) 75%, transparent); }\n.hb-ua4-thumb {\n  position: absolute;\n  top: 50%;\n  left: var(--hb-ua4-p);\n  width: 30px;\n  height: 30px;\n  margin: -15px 0 0 -15px;\n  padding: 0;\n  border: 0;\n  background: none;\n  outline: none;\n  cursor: grab;\n  transition: left .22s cubic-bezier(.2, .8, .2, 1);\n}\n.hb-ua4-thumb::before {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: 11px;\n  height: 11px;\n  margin: -5.5px 0 0 -5.5px;\n  border: 1px solid var(--hb-ua4-accent);\n  background: #0a0a0a;\n  transform: rotate(45deg);\n  box-shadow: 0 0 0 3px #0a0a0a, 0 0 14px color-mix(in srgb, var(--hb-ua4-accent) 70%, transparent);\n  transition: transform .18s ease, background-color .18s ease;\n}\n.hb-ua4-thumb::after {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: 3px;\n  height: 3px;\n  margin: -1.5px 0 0 -1.5px;\n  background: var(--hb-ua4-accent);\n  transform: rotate(45deg);\n}\n.hb-ua4-thumb:hover::before, .hb-ua4[data-drag=\"true\"] .hb-ua4-thumb::before { transform: rotate(45deg) scale(1.2); }\n.hb-ua4-thumb:focus-visible::before { outline: 1px solid #ededed; outline-offset: 4px; }\n.hb-ua4[data-drag=\"true\"] .hb-ua4-thumb { cursor: grabbing; transition-duration: .08s; }\n.hb-ua4[data-drag=\"true\"] .hb-ua4-fill { transition-duration: .08s; }\n.hb-ua4-scale {\n  display: flex;\n  justify-content: space-between;\n  margin: -4px 7px 0;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 9px;\n  letter-spacing: .14em;\n  color: #5f5f5f;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ua4-fill, .hb-ua4-thumb, .hb-ua4-thumb::before { transition: none; }\n}\n`;\n\nexport function HudShelfSlider({\n  count = 9,\n  value,\n  defaultValue = 2,\n  onChange,\n  label = \"Shelf\",\n  labels,\n  accent = \"#ff4d4d\",\n  className,\n  style,\n  ...rest\n}: HudShelfSliderProps) {\n  const steps = Math.max(2, Math.round(count));\n  const [inner, setInner] = React.useState(() => Math.min(steps - 1, Math.max(0, defaultValue)));\n  const [drag, setDrag] = React.useState(false);\n  const trackRef = React.useRef<HTMLDivElement>(null);\n  const thumbRef = React.useRef<HTMLButtonElement>(null);\n  const current = Math.min(steps - 1, Math.max(0, value ?? inner));\n\n  const commit = (next: number) => {\n    const v = Math.min(steps - 1, Math.max(0, next));\n    if (v === current) return;\n    if (value === undefined) setInner(v);\n    onChange?.(v);\n  };\n\n  const fromPointer = (clientX: number) => {\n    const el = trackRef.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const t = r.width ? (clientX - r.left) / r.width : 0;\n    commit(Math.round(Math.min(1, Math.max(0, t)) * (steps - 1)));\n  };\n\n  const onKey = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n    const map: Record<string, number> = {\n      ArrowRight: current + 1,\n      ArrowUp: current + 1,\n      ArrowLeft: current - 1,\n      ArrowDown: current - 1,\n      PageUp: current + 3,\n      PageDown: current - 3,\n      Home: 0,\n      End: steps - 1,\n    };\n    if (e.key in map) {\n      e.preventDefault();\n      commit(map[e.key]);\n    }\n  };\n\n  const pad = (v: number) => String(v).padStart(2, \"0\");\n  const pct = `${((current / (steps - 1)) * 100).toFixed(3)}%`;\n  const name = labels?.[current];\n  const ticks: React.ReactNode[] = [];\n  const sub = 3;\n  for (let i = 0; i <= (steps - 1) * sub; i++) {\n    const pos = i / ((steps - 1) * sub);\n    ticks.push(\n      <span\n        key={i}\n        className=\"hb-ua4-tick\"\n        data-major={i % sub === 0 ? \"true\" : \"false\"}\n        data-lit={pos <= current / (steps - 1) + 0.0001 ? \"true\" : \"false\"}\n        style={{ left: `${(pos * 100).toFixed(3)}%` }}\n      />,\n    );\n  }\n\n  return (\n    <div\n      className={[\"hb-ua4\", className].filter(Boolean).join(\" \")}\n      data-drag={drag ? \"true\" : \"false\"}\n      style={{ [\"--hb-ua4-accent\" as string]: accent, [\"--hb-ua4-p\" as string]: pct, ...style }}\n      {...rest}\n    >\n      <style href=\"hb-hud-shelf-slider\" precedence=\"default\">{css}</style>\n      <div className=\"hb-ua4-top\">\n        <span className=\"hb-ua4-name\">\n          <span>{label}</span>\n          {name ? <b>{name}</b> : null}\n        </span>\n        <span className=\"hb-ua4-count\" aria-hidden=\"true\">\n          <b>{pad(current + 1)}</b> / {pad(steps)}\n        </span>\n      </div>\n      <div\n        ref={trackRef}\n        className=\"hb-ua4-track\"\n        onPointerDown={(e) => {\n          if (e.button !== 0 && e.pointerType === \"mouse\") return;\n          e.preventDefault();\n          e.currentTarget.setPointerCapture(e.pointerId);\n          setDrag(true);\n          thumbRef.current?.focus();\n          fromPointer(e.clientX);\n        }}\n        onPointerMove={(e) => {\n          if (drag) fromPointer(e.clientX);\n        }}\n        onPointerUp={() => setDrag(false)}\n        onPointerCancel={() => setDrag(false)}\n      >\n        <span className=\"hb-ua4-line\" />\n        {ticks}\n        <span className=\"hb-ua4-fill\" />\n        <button\n          ref={thumbRef}\n          type=\"button\"\n          className=\"hb-ua4-thumb\"\n          role=\"slider\"\n          aria-label={label}\n          aria-valuemin={1}\n          aria-valuemax={steps}\n          aria-valuenow={current + 1}\n          aria-valuetext={name ? `${current + 1} of ${steps}, ${name}` : `${current + 1} of ${steps}`}\n          onKeyDown={onKey}\n        />\n      </div>\n      <div className=\"hb-ua4-scale\" aria-hidden=\"true\">\n        <span>01</span>\n        <span>{pad(steps)}</span>\n      </div>\n    </div>\n  );\n}\n\nexport default HudShelfSlider;\n"
    }
  ]
}