{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bg-wave-lines",
  "type": "registry:component",
  "title": "Wave Lines",
  "description": "Rows of thin lines in perspective that ripple like a sheet of fabric, with near rows hiding the far ones. A swell travels across and lights the crests in the accent color.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "overlay",
    "background",
    "waves",
    "lines",
    "terrain",
    "canvas",
    "perspective"
  ],
  "docs": "https://hyperblur.dev/effects/bg-wave-lines",
  "files": [
    {
      "path": "registry/hyperblur/bg-wave-lines.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/bg-wave-lines.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BgWaveLinesProps extends React.HTMLAttributes<HTMLDivElement> {\n  color?: string;\n  accent?: string;\n  background?: string;\n  lines?: number;\n  amplitude?: number;\n  horizon?: number;\n  speed?: number;\n  children?: React.ReactNode;\n}\n\nconst css = `\n.hb-vd9 { position: absolute; inset: 0; overflow: hidden; pointer-events: none; box-sizing: border-box; }\n.hb-vd9-c { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }\n.hb-vd9-in { position: relative; z-index: 1; width: 100%; height: 100%; pointer-events: auto; font-family: inherit; }\n`;\n\nexport function BgWaveLines({\n  color = \"#ededed\",\n  accent = \"#2f7bff\",\n  background = \"#060608\",\n  lines = 40,\n  amplitude = 1,\n  horizon = 0.3,\n  speed = 1,\n  children,\n  className = \"\",\n  style,\n  ...rest\n}: BgWaveLinesProps) {\n  const wrapRef = React.useRef<HTMLDivElement>(null);\n  const canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n  React.useEffect(() => {\n    const wrap = wrapRef.current;\n    const canvas = canvasRef.current;\n    const context = canvas?.getContext(\"2d\");\n    if (!wrap || !canvas || !context) return;\n    const el: HTMLDivElement = wrap;\n    const cv: HTMLCanvasElement = canvas;\n    const g: CanvasRenderingContext2D = context;\n    const motion = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const L = Math.max(8, Math.min(90, Math.round(lines)));\n    let w = 0;\n    let h = 0;\n    let t = 0;\n    let raf = 0;\n    let prev = 0;\n    let visible = true;\n    let ysBuf = new Float32Array(0);\n    let hsBuf = new Float32Array(0);\n\n    function height(u: number, z: number) {\n      const bx = 0.5 + 0.38 * Math.sin(t * 0.21);\n      const bz = 0.55 + 0.3 * Math.sin(t * 0.17 + 1.3);\n      const dx = (u - bx) * 1.6;\n      const dz = z - bz;\n      const bump = Math.exp(-(dx * dx + dz * dz * 1.8) / 0.045);\n      return (\n        0.42 * Math.sin(u * 4.2 + t * 0.55 + z * 5.1) +\n        0.24 * Math.sin(u * 9.3 - t * 0.8 + z * 2.4) +\n        0.14 * Math.sin(u * 17 + t * 1.1 - z * 6) +\n        bump * 1.15\n      );\n    }\n\n    function draw() {\n      if (!w || !h) return;\n      g.globalAlpha = 1;\n      g.fillStyle = background;\n      g.fillRect(0, 0, w, h);\n      const top = h * Math.max(0, Math.min(0.8, horizon));\n      const step = Math.max(4, Math.round(w / 140));\n      const count = Math.ceil(w / step) + 2;\n      if (ysBuf.length !== count) {\n        ysBuf = new Float32Array(count);\n        hsBuf = new Float32Array(count);\n      }\n      g.lineJoin = \"round\";\n      for (let j = 0; j < L; j++) {\n        const z = j / (L - 1);\n        const persp = Math.pow(z, 1.75);\n        const yb = top + (h * 1.04 - top) * persp;\n        const spread = 1.5 - z * 0.55;\n        const amp = h * 0.075 * amplitude * (0.25 + z * 0.95);\n        g.beginPath();\n        for (let i = 0; i < count; i++) {\n          const x = (i - 1) * step;\n          const u = 0.5 + (x / w - 0.5) * spread;\n          const hv = height(u, z);\n          const y = yb - hv * amp;\n          ysBuf[i] = y;\n          hsBuf[i] = hv;\n          if (i === 0) g.moveTo(x, y);\n          else g.lineTo(x, y);\n        }\n        g.lineTo(w + step, h + 2);\n        g.lineTo(-step, h + 2);\n        g.closePath();\n        g.globalAlpha = 1;\n        g.fillStyle = background;\n        g.fill();\n        g.beginPath();\n        for (let i = 0; i < count; i++) {\n          const x = (i - 1) * step;\n          if (i === 0) g.moveTo(x, ysBuf[i]);\n          else g.lineTo(x, ysBuf[i]);\n        }\n        g.globalAlpha = 0.1 + 0.55 * z;\n        g.strokeStyle = color;\n        g.lineWidth = 0.6 + z * 0.8;\n        g.stroke();\n        g.beginPath();\n        let pen = false;\n        for (let i = 0; i < count; i++) {\n          const x = (i - 1) * step;\n          if (hsBuf[i] > 0.62) {\n            if (pen) g.lineTo(x, ysBuf[i]);\n            else g.moveTo(x, ysBuf[i]);\n            pen = true;\n          } else pen = false;\n        }\n        g.globalAlpha = Math.min(1, 0.35 + 0.65 * z);\n        g.strokeStyle = accent;\n        g.lineWidth = 1 + z * 1.2;\n        g.stroke();\n      }\n      const fog = g.createLinearGradient(0, top - 10, 0, top + (h - top) * 0.35);\n      fog.addColorStop(0, background);\n      fog.addColorStop(1, \"rgba(0,0,0,0)\");\n      g.globalAlpha = 1;\n      g.fillStyle = fog;\n      g.fillRect(0, 0, w, top + (h - top) * 0.35);\n    }\n\n    function resize() {\n      const nw = el.clientWidth;\n      const nh = el.clientHeight;\n      if (!nw || !nh) return;\n      const dpr = Math.min(2, window.devicePixelRatio || 1);\n      w = nw;\n      h = nh;\n      cv.width = Math.max(1, Math.round(w * dpr));\n      cv.height = Math.max(1, Math.round(h * dpr));\n      g.setTransform(dpr, 0, 0, dpr, 0, 0);\n      if (motion.matches) t = 4;\n      draw();\n    }\n\n    function frame(now: number) {\n      const dt = Math.min(0.05, (now - prev) / 1000);\n      prev = now;\n      t += dt * speed;\n      draw();\n      raf = requestAnimationFrame(frame);\n    }\n\n    function sync() {\n      const run = visible && !document.hidden && !motion.matches;\n      if (run && !raf) {\n        prev = performance.now();\n        raf = requestAnimationFrame(frame);\n      } else if (!run && raf) {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n      if (motion.matches) {\n        t = 4;\n        draw();\n      }\n    }\n\n    const ro = new ResizeObserver(resize);\n    const io = new IntersectionObserver((entries) => {\n      visible = entries[entries.length - 1].isIntersecting;\n      sync();\n    });\n    ro.observe(el);\n    io.observe(el);\n    document.addEventListener(\"visibilitychange\", sync);\n    motion.addEventListener(\"change\", sync);\n    resize();\n    sync();\n\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", sync);\n      motion.removeEventListener(\"change\", sync);\n    };\n  }, [color, accent, background, lines, amplitude, horizon, speed]);\n\n  return (\n    <div ref={wrapRef} className={`hb-vd9 ${className}`} style={style} {...rest}>\n      <style href=\"hb-bg-wave-lines\" precedence=\"default\">{css}</style>\n      <canvas ref={canvasRef} className=\"hb-vd9-c\" aria-hidden=\"true\" />\n      {children ? <div className=\"hb-vd9-in\">{children}</div> : null}\n    </div>\n  );\n}\n"
    }
  ]
}