{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hover-reveal-lens",
  "type": "registry:component",
  "title": "Reveal Lens",
  "description": "A round lens that floats after the pointer on a spring and shows a second layer through it, such as live data over a blueprint. Press to widen the lens; arrow keys and plus or minus drive it from the keyboard.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hover",
    "lens",
    "reveal",
    "map",
    "clip-path",
    "inspect",
    "pointer"
  ],
  "docs": "https://hyperblur.dev/effects/hover-reveal-lens",
  "files": [
    {
      "path": "registry/hyperblur/hover-reveal-lens.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hover-reveal-lens.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HoverRevealLensProps extends React.HTMLAttributes<HTMLDivElement> {\n  base?: React.ReactNode;\n  reveal?: React.ReactNode;\n  radius?: number;\n  accent?: string;\n  autoPlay?: boolean;\n  label?: string;\n  ratio?: number;\n}\n\nfunction hash(n: number) {\n  let x = Math.imul((n | 0) ^ 0x9e3779b9, 0x85ebca6b) >>> 0;\n  x ^= x >>> 13;\n  x = Math.imul(x, 0xc2b2ae35) >>> 0;\n  x ^= x >>> 16;\n  return (x >>> 0) / 4294967296;\n}\n\nconst W = 400;\nconst H = 250;\nconst cols = [0, 46, 98, 140, 196, 238, 292, 338, 400];\nconst rows = [0, 40, 84, 122, 170, 208, 250];\nconst blocks: { x: number; y: number; w: number; h: number; v: number; park: boolean }[] = [];\nfor (let r = 0; r < rows.length - 1; r++) {\n  for (let c = 0; c < cols.length - 1; c++) {\n    const i = r * 10 + c;\n    const x = cols[c] + 5;\n    const y = rows[r] + 5;\n    const w = cols[c + 1] - cols[c] - 10;\n    const h = rows[r + 1] - rows[r] - 10;\n    blocks.push({ x, y, w, h, v: hash(i + 7), park: hash(i + 91) > 0.86 });\n  }\n}\nconst river = \"M-10 150 C 60 128, 110 190, 180 168 S 300 112, 410 138\";\nconst heat = (v: number) => (v > 0.78 ? \"#ff5a5f\" : v > 0.55 ? \"#ff9f43\" : v > 0.32 ? \"#f6d365\" : \"#3ddc97\");\nconst pins = [\n  { x: 120, y: 60, t: \"Depot 4\" },\n  { x: 262, y: 96, t: \"Hub\" },\n  { x: 70, y: 196, t: \"Dock B\" },\n  { x: 318, y: 186, t: \"Yard 2\" },\n];\n\nfunction Blueprint() {\n  return (\n    <svg viewBox={`0 0 ${W} ${H}`} preserveAspectRatio=\"xMidYMid slice\" width=\"100%\" height=\"100%\">\n      <rect width={W} height={H} fill=\"#0b1020\" />\n      <g stroke=\"#1b2847\" strokeWidth=\".6\">\n        {Array.from({ length: 21 }, (_, i) => (\n          <line key={`v${i}`} x1={i * 20} y1=\"0\" x2={i * 20} y2={H} />\n        ))}\n        {Array.from({ length: 13 }, (_, i) => (\n          <line key={`h${i}`} x1=\"0\" y1={i * 20} x2={W} y2={i * 20} />\n        ))}\n      </g>\n      <g fill=\"none\" stroke=\"#3a5288\" strokeWidth=\".9\">\n        {blocks.map((b, i) => (\n          <rect key={i} x={b.x} y={b.y} width={b.w} height={b.h} rx=\"2\" strokeDasharray={b.park ? \"3 3\" : undefined} />\n        ))}\n      </g>\n      <path d={river} fill=\"none\" stroke=\"#4e6aa8\" strokeWidth=\"10\" strokeOpacity=\".25\" />\n      <path d={river} fill=\"none\" stroke=\"#5f7cc0\" strokeWidth=\".9\" />\n      {pins.map((p) => (\n        <circle key={p.t} cx={p.x} cy={p.y} r=\"2.5\" fill=\"none\" stroke=\"#5f7cc0\" />\n      ))}\n    </svg>\n  );\n}\n\nfunction Live({ accent }: { accent: string }) {\n  return (\n    <svg viewBox={`0 0 ${W} ${H}`} preserveAspectRatio=\"xMidYMid slice\" width=\"100%\" height=\"100%\">\n      <rect width={W} height={H} fill=\"#121212\" />\n      {blocks.map((b, i) =>\n        b.park ? (\n          <rect key={i} x={b.x} y={b.y} width={b.w} height={b.h} rx=\"3\" fill=\"#1f3d2a\" />\n        ) : (\n          <g key={i}>\n            <rect x={b.x} y={b.y} width={b.w} height={b.h} rx=\"3\" fill=\"#1d1d1d\" />\n            <rect x={b.x} y={b.y} width={b.w} height={b.h} rx=\"3\" fill={heat(b.v)} opacity={(0.18 + b.v * 0.5).toFixed(3)} />\n          </g>\n        ),\n      )}\n      <path d={river} fill=\"none\" stroke=\"#1d4f8a\" strokeWidth=\"11\" />\n      <path d={river} fill=\"none\" stroke=\"#3d86d8\" strokeWidth=\"1.2\" strokeOpacity=\".7\" />\n      <g stroke={accent} strokeWidth=\"2\" strokeLinecap=\"round\" fill=\"none\" opacity=\".9\">\n        <path d=\"M120 60 L120 84 L262 84 L262 96\" />\n        <path d=\"M262 96 L292 96 L292 186 L318 186\" />\n        <path d=\"M70 196 L98 196 L98 122 L120 122 L120 60\" />\n      </g>\n      {pins.map((p) => (\n        <g key={p.t}>\n          <circle cx={p.x} cy={p.y} r=\"6\" fill={accent} opacity=\".25\" />\n          <circle cx={p.x} cy={p.y} r=\"3\" fill=\"#fff\" stroke={accent} strokeWidth=\"1.5\" />\n          <rect x={p.x + 6} y={p.y - 15} width={p.t.length * 5.2 + 8} height=\"12\" rx=\"3\" fill=\"#0a0a0a\" opacity=\".85\" />\n          <text x={p.x + 10} y={p.y - 6} fontSize=\"8\" fill=\"#ededed\" fontFamily=\"var(--font-mono, ui-monospace, monospace)\">{p.t}</text>\n        </g>\n      ))}\n    </svg>\n  );\n}\n\nconst css = `\n.hb-wg8 { --hb-wg8-accent: #2f7bff; --hb-wg8-x: 50%; --hb-wg8-y: 50%; --hb-wg8-r: 52px; position: relative; box-sizing: border-box; width: 100%; overflow: hidden; border-radius: 14px; font-family: inherit; color: #ededed; background: #0b1020; box-shadow: 0 0 0 1px #262626, 0 20px 40px -24px rgba(0,0,0,.9); touch-action: pan-y; cursor: none; outline: none; }\n.hb-wg8 *, .hb-wg8 *::before, .hb-wg8 *::after { box-sizing: border-box; }\n.hb-wg8:focus-visible { box-shadow: 0 0 0 2px #0a0a0a, 0 0 0 4px var(--hb-wg8-accent); }\n.hb-wg8-layer { position: absolute; inset: 0; }\n.hb-wg8-layer > svg { display: block; }\n.hb-wg8-reveal { clip-path: circle(var(--hb-wg8-r) at var(--hb-wg8-x) var(--hb-wg8-y)); }\n.hb-wg8-ring { position: absolute; left: var(--hb-wg8-x); top: var(--hb-wg8-y); width: calc(var(--hb-wg8-r) * 2); height: calc(var(--hb-wg8-r) * 2); margin: calc(var(--hb-wg8-r) * -1) 0 0 calc(var(--hb-wg8-r) * -1); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 1.5px rgba(255,255,255,.85), 0 0 0 5px rgba(10,10,10,.35), 0 10px 30px rgba(0,0,0,.55), inset 0 0 24px rgba(0,0,0,.35); }\n.hb-wg8-ring::before, .hb-wg8-ring::after { content: \"\"; position: absolute; left: 50%; top: 50%; background: rgba(255,255,255,.7); }\n.hb-wg8-ring::before { width: 10px; height: 1px; margin: 0 0 0 -5px; }\n.hb-wg8-ring::after { width: 1px; height: 10px; margin: -5px 0 0 0; }\n.hb-wg8-tick { position: absolute; inset: -7px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.55) 0 1.2deg, transparent 1.2deg 15deg); -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 4px)); mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 4px)); animation: hb-wg8-spin 18s linear infinite; }\n.hb-wg8-read { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); padding: 2px 6px; border-radius: 5px; background: rgba(10,10,10,.82); box-shadow: 0 0 0 1px #262626; font-family: var(--font-mono, ui-monospace, monospace); font-size: 8.5px; letter-spacing: .04em; white-space: nowrap; color: #ededed; }\n.hb-wg8-tag { position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; background: rgba(10,10,10,.75); box-shadow: 0 0 0 1px #262626; font-size: 10px; color: #a1a1a1; pointer-events: none; }\n.hb-wg8-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hb-wg8-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-wg8-accent) 25%, transparent); }\n@keyframes hb-wg8-spin { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wg8-tick { animation: none; }\n}\n`;\n\nexport function HoverRevealLens({\n  base,\n  reveal,\n  radius = 52,\n  accent = \"#2f7bff\",\n  autoPlay = true,\n  label = \"Live load\",\n  ratio = 0.625,\n  className = \"\",\n  style,\n  ...rest\n}: HoverRevealLensProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const readRef = React.useRef<HTMLSpanElement>(null);\n\n  React.useEffect(() => {\n    const root = rootRef.current;\n    const read = readRef.current;\n    if (!root || !read) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let w = root.offsetWidth;\n    let h = root.offsetHeight;\n    let x = w * 0.5;\n    let y = h * 0.5;\n    let vx = 0;\n    let vy = 0;\n    let px = x;\n    let py = y;\n    let r = radius;\n    let goalR = radius;\n    let inside = false;\n    let keyMode = false;\n    let t = 0;\n    let raf = 0;\n    let last = performance.now();\n    let visible = true;\n\n    const paint = () => {\n      root.style.setProperty(\"--hb-wg8-x\", `${x.toFixed(1)}px`);\n      root.style.setProperty(\"--hb-wg8-y\", `${y.toFixed(1)}px`);\n      root.style.setProperty(\"--hb-wg8-r\", `${r.toFixed(1)}px`);\n      const gx = w ? (x / w) * 100 : 0;\n      const gy = h ? (y / h) * 100 : 0;\n      read.textContent = `${gx.toFixed(1).padStart(4, \"0\")} · ${gy.toFixed(1).padStart(4, \"0\")}`;\n    };\n    const frame = (now: number) => {\n      const dt = Math.min(0.032, (now - last) / 1000);\n      last = now;\n      t += dt;\n      w = root.offsetWidth;\n      h = root.offsetHeight;\n      let tx = px;\n      let ty = py;\n      if (!inside && !keyMode && autoPlay) {\n        tx = w * (0.5 + 0.34 * Math.sin(t * 0.45) + 0.06 * Math.sin(t * 1.7));\n        ty = h * (0.5 + 0.26 * Math.sin(t * 0.7 + 1.2));\n      }\n      const k = 170;\n      const d = 22;\n      vx += ((tx - x) * k - vx * d) * dt;\n      vy += ((ty - y) * k - vy * d) * dt;\n      x += vx * dt;\n      y += vy * dt;\n      r += (goalR - r) * (1 - Math.exp(-dt * 12));\n      paint();\n      raf = requestAnimationFrame(frame);\n    };\n    const start = () => {\n      if (raf || !visible) return;\n      last = performance.now();\n      raf = requestAnimationFrame(frame);\n    };\n    const stop = () => {\n      if (raf) cancelAnimationFrame(raf);\n      raf = 0;\n    };\n    const locate = (e: PointerEvent) => {\n      const b = root.getBoundingClientRect();\n      const s = b.width ? root.offsetWidth / b.width : 1;\n      px = (e.clientX - b.left) * s;\n      py = (e.clientY - b.top) * s;\n      inside = true;\n      keyMode = false;\n      if (reduce) {\n        x = px;\n        y = py;\n        paint();\n      }\n    };\n    const onDown = (e: PointerEvent) => {\n      locate(e);\n      goalR = radius * 1.45;\n      if (reduce) {\n        r = goalR;\n        paint();\n      }\n    };\n    const onUp = (e: PointerEvent) => {\n      goalR = radius;\n      if (reduce) {\n        r = goalR;\n        paint();\n      }\n      if (e.pointerType !== \"mouse\") window.setTimeout(() => {\n          inside = false;\n        }, 1600);\n    };\n    const onLeave = () => {\n      inside = false;\n      goalR = radius;\n    };\n    const onKey = (e: KeyboardEvent) => {\n      const step = e.shiftKey ? 30 : 12;\n      let used = true;\n      if (e.key === \"ArrowLeft\") px -= step;\n      else if (e.key === \"ArrowRight\") px += step;\n      else if (e.key === \"ArrowUp\") py -= step;\n      else if (e.key === \"ArrowDown\") py += step;\n      else if (e.key === \"+\" || e.key === \"=\") goalR = Math.min(radius * 2, goalR + 8);\n      else if (e.key === \"-\") goalR = Math.max(radius * 0.6, goalR - 8);\n      else used = false;\n      if (!used) return;\n      e.preventDefault();\n      if (!keyMode) {\n        keyMode = true;\n        px = Math.min(Math.max(px, 0), w);\n        py = Math.min(Math.max(py, 0), h);\n      }\n      px = Math.min(Math.max(px, 0), w);\n      py = Math.min(Math.max(py, 0), h);\n      if (reduce) {\n        x = px;\n        y = py;\n        r = goalR;\n        paint();\n      }\n    };\n    const onBlur = () => {\n      keyMode = false;\n    };\n    root.addEventListener(\"pointermove\", locate);\n    root.addEventListener(\"pointerdown\", onDown);\n    root.addEventListener(\"pointerup\", onUp);\n    root.addEventListener(\"pointerleave\", onLeave);\n    root.addEventListener(\"pointercancel\", onLeave);\n    root.addEventListener(\"keydown\", onKey);\n    root.addEventListener(\"blur\", onBlur);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible && !reduce) start();\n      else stop();\n    });\n    io.observe(root);\n    paint();\n    if (!reduce) start();\n    return () => {\n      stop();\n      io.disconnect();\n      root.removeEventListener(\"pointermove\", locate);\n      root.removeEventListener(\"pointerdown\", onDown);\n      root.removeEventListener(\"pointerup\", onUp);\n      root.removeEventListener(\"pointerleave\", onLeave);\n      root.removeEventListener(\"pointercancel\", onLeave);\n      root.removeEventListener(\"keydown\", onKey);\n      root.removeEventListener(\"blur\", onBlur);\n    };\n  }, [radius, autoPlay]);\n\n  const vars = { \"--hb-wg8-accent\": accent, \"--hb-wg8-r\": `${radius}px`, aspectRatio: `1 / ${ratio}` } as React.CSSProperties;\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-wg8 ${className}`}\n      style={{ ...vars, ...style }}\n      tabIndex={0}\n      role=\"img\"\n      aria-label={`${label}. Move the pointer or use the arrow keys to inspect, plus and minus to resize the lens.`}\n      {...rest}\n    >\n      <style href=\"hb-hover-reveal-lens\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wg8-layer\">{base ?? <Blueprint />}</div>\n      <div className=\"hb-wg8-layer hb-wg8-reveal\">{reveal ?? <Live accent={accent} />}</div>\n      <span className=\"hb-wg8-ring\" aria-hidden=\"true\">\n        <span className=\"hb-wg8-tick\" />\n        <span ref={readRef} className=\"hb-wg8-read\" />\n      </span>\n      <span className=\"hb-wg8-tag\" aria-hidden=\"true\">\n        <span className=\"hb-wg8-dot\" />\n        {label}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}