{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-path-draw",
  "type": "registry:component",
  "title": "Motion Path Draw",
  "description": "A journey line that draws itself through your milestones as you scroll, with a glowing comet head and a blurred trail. Each node lights up and drops its label card the moment the line reaches it.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "motion",
    "scroll",
    "svg",
    "path",
    "timeline",
    "milestones",
    "pinned"
  ],
  "docs": "https://hyperblur.dev/effects/motion-path-draw",
  "files": [
    {
      "path": "registry/hyperblur/motion-path-draw.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/motion-path-draw.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MotionPathDrawMilestone {\n  date: string;\n  label: string;\n  x: number;\n  y: number;\n}\n\nexport interface MotionPathDrawProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  milestones?: MotionPathDrawMilestone[];\n  accent?: string;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n  length?: number;\n  height?: string;\n}\n\nconst defaultMilestones: MotionPathDrawMilestone[] = [\n  { date: \"Jan\", label: \"First commit\", x: 0.04, y: 0.78 },\n  { date: \"Mar\", label: \"Private alpha\", x: 0.27, y: 0.36 },\n  { date: \"Jun\", label: \"12 design partners\", x: 0.5, y: 0.7 },\n  { date: \"Sep\", label: \"Public beta\", x: 0.73, y: 0.3 },\n  { date: \"Nov\", label: \"1.0 launch\", x: 0.96, y: 0.52 },\n];\n\nconst css = `\n.hb-wh7 {\n  --hb-wh7-a: #2f7bff;\n  position: relative;\n  width: 100%;\n  height: var(--hb-wh7-h);\n  color: #ededed;\n  font-family: inherit;\n  background: #0a0a0a;\n}\n.hb-wh7[data-pinned=\"true\"] { height: calc(var(--hb-wh7-h) * var(--hb-wh7-len)); }\n.hb-wh7 *, .hb-wh7 *::before, .hb-wh7 *::after { box-sizing: border-box; }\n.hb-wh7-stage {\n  position: sticky;\n  top: 0;\n  height: var(--hb-wh7-h);\n  overflow: hidden;\n  container-type: size;\n  display: grid;\n  grid-template-rows: auto 1fr auto;\n  gap: 2cqh;\n  padding: 6cqh max(14px, 5cqw) 5cqh;\n  background-color: #0a0a0a;\n  background-image:\n    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.07) 1px, transparent 0);\n  background-size: clamp(14px, 3cqw, 28px) clamp(14px, 3cqw, 28px);\n}\n.hb-wh7-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; }\n.hb-wh7-eyebrow {\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(8px, 1.4cqw, 12px);\n  letter-spacing: 0.16em;\n  text-transform: uppercase;\n  color: #8f8f8f;\n}\n.hb-wh7-title {\n  margin: 0.3em 0 0;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(14px, min(4cqw, 7cqh), 52px);\n  font-weight: 600;\n  line-height: 1.05;\n  letter-spacing: -0.03em;\n  color: #f5f5f5;\n}\n.hb-wh7-pct {\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(9px, 1.6cqw, 14px);\n  font-variant-numeric: tabular-nums;\n  color: color-mix(in srgb, var(--hb-wh7-a) 55%, #fff);\n}\n.hb-wh7-area { position: relative; min-height: 0; }\n.hb-wh7-list { margin: 0; padding: 0; list-style: none; }\n.hb-wh7-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }\n.hb-wh7-node {\n  position: absolute;\n  width: clamp(8px, 1.4cqw, 14px);\n  height: clamp(8px, 1.4cqw, 14px);\n  border-radius: 50%;\n  border: 1.5px solid #3a3a3a;\n  background: #0a0a0a;\n  transform: translate(-50%, -50%);\n  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.4s ease;\n}\n.hb-wh7-node[data-on=\"true\"] {\n  border-color: var(--hb-wh7-a);\n  background: var(--hb-wh7-a);\n  box-shadow: 0 0 0 5px color-mix(in srgb, var(--hb-wh7-a) 20%, transparent), 0 0 18px var(--hb-wh7-a);\n  animation: hb-wh7-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n@keyframes hb-wh7-pop { 0% { transform: translate(-50%, -50%) scale(0.4); } 100% { transform: translate(-50%, -50%) scale(1); } }\n.hb-wh7-tag {\n  position: absolute;\n  display: flex;\n  flex-direction: column;\n  gap: 0.15em;\n  padding: 0.45em 0.7em;\n  border-radius: 0.6em;\n  border: 1px solid #262626;\n  background: linear-gradient(180deg, #161616, #111);\n  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04);\n  font-size: clamp(8px, 1.35cqw, 13px);\n  white-space: nowrap;\n  opacity: 0;\n  transform: translate(var(--tx), calc(var(--ty) + 6px));\n  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);\n  pointer-events: none;\n}\n.hb-wh7-tag[data-on=\"true\"] { opacity: 1; transform: translate(var(--tx), var(--ty)); }\n.hb-wh7-tag b { font-weight: 600; color: #f2f2f2; }\n.hb-wh7-tag span {\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: 0.82em;\n  letter-spacing: 0.1em;\n  text-transform: uppercase;\n  color: color-mix(in srgb, var(--hb-wh7-a) 55%, #fff);\n}\n.hb-wh7-head-dot {\n  position: absolute;\n  width: clamp(10px, 1.8cqw, 18px);\n  height: clamp(10px, 1.8cqw, 18px);\n  border-radius: 50%;\n  background: #fff;\n  box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-wh7-a) 45%, transparent), 0 0 24px 4px var(--hb-wh7-a);\n  transform: translate(-50%, -50%);\n  pointer-events: none;\n}\n.hb-wh7-foot {\n  display: flex;\n  justify-content: space-between;\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(7px, 1.2cqw, 11px);\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  color: #5c5c5c;\n}\n.hb-wh7-foot span[data-on=\"true\"] { color: #d6d6d6; }\n@container (max-height: 260px) {\n  .hb-wh7-foot { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wh7-node, .hb-wh7-tag { transition: none; animation: none; }\n}\n`;\n\nfunction clamp01(x: number) {\n  return Math.min(1, Math.max(0, x));\n}\n\nfunction inOut(x: number) {\n  return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\n\nfunction findScroller(el: HTMLElement): HTMLElement | null {\n  let node = el.parentElement;\n  while (node && node !== document.body && node !== document.documentElement) {\n    const oy = getComputedStyle(node).overflowY;\n    if ((oy === \"auto\" || oy === \"scroll\" || oy === \"overlay\") && node.scrollHeight > node.clientHeight + 1) return node;\n    node = node.parentElement;\n  }\n  return null;\n}\n\nfunction loopAt(ms: number, duration: number) {\n  const d = Math.max(1, duration) * 1000;\n  const back = d * 0.4;\n  const hold = 1600;\n  const t = ms % (d + hold + back + 600);\n  if (t < d) return t / d;\n  if (t < d + hold) return 1;\n  if (t < d + hold + back) return 1 - inOut((t - d - hold) / back);\n  return 0;\n}\n\nfunction useProgress(\n  ref: React.RefObject<HTMLElement | null>,\n  apply: (p: number) => void,\n  progress: number | undefined,\n  autoPlay: boolean,\n  duration: number,\n) {\n  const applyRef = React.useRef(apply);\n  React.useLayoutEffect(() => {\n    applyRef.current = apply;\n  });\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const run = (p: number) => applyRef.current(clamp01(p));\n    if (typeof progress === \"number\") {\n      run(progress);\n      return;\n    }\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      run(1);\n      return;\n    }\n    let raf = 0;\n    if (autoPlay) {\n      let visible = true;\n      let last = 0;\n      let t = 0;\n      const io = new IntersectionObserver((entries) => {\n        visible = entries[0]?.isIntersecting ?? true;\n      });\n      io.observe(el);\n      const loop = (now: number) => {\n        const dt = last ? Math.min(64, now - last) : 0;\n        last = now;\n        if (visible) {\n          t += dt;\n          run(loopAt(t, duration));\n        }\n        raf = requestAnimationFrame(loop);\n      };\n      raf = requestAnimationFrame(loop);\n      return () => {\n        cancelAnimationFrame(raf);\n        io.disconnect();\n      };\n    }\n    const sc = findScroller(el);\n    const measure = () => {\n      raf = 0;\n      const r = el.getBoundingClientRect();\n      const top = sc ? r.top - sc.getBoundingClientRect().top : r.top;\n      const vh = sc ? sc.clientHeight : window.innerHeight;\n      const span = r.height - vh;\n      run(span > 1 ? -top / span : (vh - top) / (vh + r.height));\n    };\n    const onScroll = () => {\n      if (!raf) raf = requestAnimationFrame(measure);\n    };\n    measure();\n    const target: HTMLElement | Window = sc ?? window;\n    target.addEventListener(\"scroll\", onScroll, { passive: true });\n    window.addEventListener(\"resize\", onScroll);\n    return () => {\n      cancelAnimationFrame(raf);\n      target.removeEventListener(\"scroll\", onScroll);\n      window.removeEventListener(\"resize\", onScroll);\n    };\n  }, [ref, progress, autoPlay, duration]);\n}\n\ninterface Geometry {\n  d: string;\n  samples: { x: number; y: number; l: number }[];\n  total: number;\n  marks: number[];\n}\n\nfunction build(points: [number, number][]): Geometry {\n  const samples: { x: number; y: number; l: number }[] = [];\n  const marks: number[] = [0];\n  if (points.length === 0) return { d: \"\", samples, total: 0, marks };\n  let d = `M${points[0][0].toFixed(1)} ${points[0][1].toFixed(1)}`;\n  let total = 0;\n  samples.push({ x: points[0][0], y: points[0][1], l: 0 });\n  for (let i = 0; i < points.length - 1; i++) {\n    const p0 = points[Math.max(0, i - 1)];\n    const p1 = points[i];\n    const p2 = points[i + 1];\n    const p3 = points[Math.min(points.length - 1, i + 2)];\n    const c1: [number, number] = [p1[0] + (p2[0] - p0[0]) / 5, p1[1] + (p2[1] - p0[1]) / 5];\n    const c2: [number, number] = [p2[0] - (p3[0] - p1[0]) / 5, p2[1] - (p3[1] - p1[1]) / 5];\n    d += ` C${c1[0].toFixed(1)} ${c1[1].toFixed(1)} ${c2[0].toFixed(1)} ${c2[1].toFixed(1)} ${p2[0].toFixed(1)} ${p2[1].toFixed(1)}`;\n    let px = p1[0];\n    let py = p1[1];\n    for (let s = 1; s <= 28; s++) {\n      const t = s / 28;\n      const u = 1 - t;\n      const x = u * u * u * p1[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * p2[0];\n      const y = u * u * u * p1[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * p2[1];\n      total += Math.hypot(x - px, y - py);\n      samples.push({ x, y, l: total });\n      px = x;\n      py = y;\n    }\n    marks.push(total);\n  }\n  return { d, samples, total, marks };\n}\n\nfunction pointAt(g: Geometry, len: number) {\n  const s = g.samples;\n  if (s.length === 0) return { x: 0, y: 0 };\n  if (len <= 0) return s[0];\n  let lo = 0;\n  let hi = s.length - 1;\n  while (lo < hi) {\n    const mid = (lo + hi) >> 1;\n    if (s[mid].l < len) lo = mid + 1;\n    else hi = mid;\n  }\n  const b = s[lo];\n  const a = s[Math.max(0, lo - 1)];\n  const span = b.l - a.l || 1;\n  const f = clamp01((len - a.l) / span);\n  return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };\n}\n\nexport function MotionPathDraw({\n  eyebrow = \"Our first year\",\n  title = \"From a weekend repo to a 1.0\",\n  milestones = defaultMilestones,\n  accent = \"#2f7bff\",\n  progress,\n  autoPlay = false,\n  duration = 6,\n  length = 3,\n  height = \"100vh\",\n  className,\n  style,\n  ...rest\n}: MotionPathDrawProps) {\n  const ref = React.useRef<HTMLElement>(null);\n  const areaRef = React.useRef<HTMLDivElement>(null);\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [size, setSize] = React.useState({ w: 1000, h: 480 });\n  const [p, setP] = React.useState(typeof progress === \"number\" ? clamp01(progress) : 0);\n  const pinned = progress === undefined && !autoPlay;\n\n  React.useEffect(() => {\n    const el = areaRef.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => {\n      const w = Math.max(40, el.clientWidth);\n      const h = Math.max(40, el.clientHeight);\n      setSize((old) => (old.w === w && old.h === h ? old : { w, h }));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  useProgress(\n    ref,\n    (v) => {\n      const q = Math.round(v * 1000) / 1000;\n      setP((old) => (old === q ? old : q));\n    },\n    progress,\n    autoPlay,\n    duration,\n  );\n\n  const geo = React.useMemo(\n    () => build(milestones.map((m) => [clamp01(m.x) * size.w, clamp01(m.y) * size.h] as [number, number])),\n    [milestones, size.w, size.h],\n  );\n\n  const drawn = clamp01(p / 0.94) * geo.total;\n  const head = pointAt(geo, drawn);\n  const trail = Math.min(drawn, geo.total * 0.12);\n  const passed = geo.marks.filter((m) => m <= drawn + 0.5).length;\n  const current = milestones[Math.max(0, passed - 1)];\n\n  return (\n    <section\n      ref={ref}\n      className={[\"hb-wh7\", className].filter(Boolean).join(\" \")}\n      data-pinned={pinned ? \"true\" : \"false\"}\n      style={\n        {\n          \"--hb-wh7-a\": accent,\n          \"--hb-wh7-h\": height,\n          \"--hb-wh7-len\": length,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...rest}\n    >\n      <style href=\"hb-motion-path-draw\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wh7-stage\">\n        <div className=\"hb-wh7-head\">\n          <div>\n            <div className=\"hb-wh7-eyebrow\">{eyebrow}</div>\n            <h2 className=\"hb-wh7-title\">{title}</h2>\n          </div>\n          <span className=\"hb-wh7-pct\" aria-hidden=\"true\">\n            {current ? current.date : \"\"} · {Math.round(clamp01(p / 0.94) * 100)}%\n          </span>\n        </div>\n        <div className=\"hb-wh7-area\" ref={areaRef}>\n          <svg className=\"hb-wh7-svg\" viewBox={`0 0 ${size.w} ${size.h}`} aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`${uid}-g`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\">\n                <stop offset=\"0\" stopColor={accent} stopOpacity=\"0.35\" />\n                <stop offset=\"1\" stopColor={accent} />\n              </linearGradient>\n              <filter id={`${uid}-b`} x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"140%\">\n                <feGaussianBlur stdDeviation=\"6\" />\n              </filter>\n            </defs>\n            <path d={geo.d} fill=\"none\" stroke=\"#262626\" strokeWidth=\"1.5\" strokeDasharray=\"4 6\" strokeLinecap=\"round\" />\n            <path\n              d={geo.d}\n              fill=\"none\"\n              stroke={`url(#${uid}-g)`}\n              strokeWidth=\"3\"\n              strokeLinecap=\"round\"\n              strokeDasharray={`${drawn.toFixed(1)} ${(geo.total + 10).toFixed(1)}`}\n            />\n            <path\n              d={geo.d}\n              fill=\"none\"\n              stroke={accent}\n              strokeWidth=\"10\"\n              strokeLinecap=\"round\"\n              filter={`url(#${uid}-b)`}\n              opacity=\"0.8\"\n              strokeDasharray={`0 ${(drawn - trail).toFixed(1)} ${trail.toFixed(1)} ${(geo.total + 10).toFixed(1)}`}\n            />\n          </svg>\n          <ol className=\"hb-wh7-list\">\n            {milestones.map((m, i) => {\n              const on = i < passed;\n              const below = m.y < 0.5;\n              const tx = m.x < 0.15 ? \"0%\" : m.x > 0.85 ? \"-100%\" : \"-50%\";\n              return (\n                <li key={`${m.label}-${i}`}>\n                  <span className=\"hb-wh7-node\" data-on={on ? \"true\" : \"false\"} style={{ left: `${(clamp01(m.x) * 100).toFixed(2)}%`, top: `${(clamp01(m.y) * 100).toFixed(2)}%` }} />\n                  <span\n                    className=\"hb-wh7-tag\"\n                    data-on={on ? \"true\" : \"false\"}\n                    style={\n                      {\n                        left: `${(clamp01(m.x) * 100).toFixed(2)}%`,\n                        top: `${(clamp01(m.y) * 100).toFixed(2)}%`,\n                        \"--tx\": tx,\n                        \"--ty\": below ? \"14px\" : \"calc(-100% - 14px)\",\n                      } as React.CSSProperties\n                    }\n                  >\n                    <span>{m.date}</span>\n                    <b>{m.label}</b>\n                  </span>\n                </li>\n              );\n            })}\n          </ol>\n          {geo.total > 0 && drawn > 0.5 && drawn < geo.total - 0.5 ? (\n            <span\n              className=\"hb-wh7-head-dot\"\n              aria-hidden=\"true\"\n              style={{ left: `${((head.x / size.w) * 100).toFixed(2)}%`, top: `${((head.y / size.h) * 100).toFixed(2)}%` }}\n            />\n          ) : null}\n        </div>\n        <div className=\"hb-wh7-foot\" aria-hidden=\"true\">\n          {milestones.map((m, i) => (\n            <span key={`${m.date}-${i}`} data-on={i < passed ? \"true\" : \"false\"}>\n              {m.date}\n            </span>\n          ))}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}