{
	"$schema": "https://ui.shadcn.com/schema/registry-item.json",
	"name": "Heatwave-TS-CSS",
	"title": "Heatwave",
	"description": "Arcs of heat that rise from a single point, warm up around the cursor and send a heat wave out on click.",
	"type": "registry:component",
	"files": [
		{
			"type": "registry:file",
			"path": "Heatwave.css",
			"target": "@components/Heatwave.css",
			"content": ".heatwave-container {\n  position: relative;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n}\n\n.heatwave-canvas {\n  position: absolute;\n  inset: 0;\n  display: block;\n  width: 100%;\n  height: 100%;\n}\n"
		},
		{
			"type": "registry:component",
			"path": "Heatwave.tsx",
			"content": "'use client';\n\nimport { useEffect, useRef, useState, type HTMLAttributes } from 'react';\n\nimport './Heatwave.css';\n\nconst MAX_COLORS = 8;\nconst MAX_WAVES = 3;\nconst MAX_RENDER_DIM = 2400;\nconst INTRO_SECONDS = 3.4;\nconst WAVE_SECONDS = 2.8;\nconst DEFAULT_COLORS = ['#4a3a9c', '#8eb2ea', '#6e8c3c', '#d6f2ef', '#f2d48c'];\n\nexport type HeatwaveSource = 'bottom' | 'top' | 'left' | 'right' | 'center';\n\nexport interface HeatwaveProps extends HTMLAttributes<HTMLDivElement> {\n  colors?: string[];\n  backgroundColor?: string;\n  source?: HeatwaveSource;\n  tilt?: number;\n  spacing?: number;\n  spread?: number;\n  stretch?: number;\n  sharpness?: number;\n  heat?: number;\n  fill?: number;\n  haze?: number;\n  shimmer?: number;\n  speed?: number;\n  grain?: number;\n  fade?: number;\n  opacity?: number;\n  intro?: boolean;\n  mouseInteraction?: boolean;\n  mouseStrength?: number;\n  clickWave?: boolean;\n  paused?: boolean;\n  dpr?: number;\n}\n\ntype Program = { program: WebGLProgram; uniforms: Record<string, WebGLUniformLocation | null> };\n\ntype Pulse = { start: number; strength: number };\n\nconst VERTEX = `#version 300 es\nvoid main() {\n  vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));\n  gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);\n}`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\n\nuniform vec2 uRes;\nuniform float uTime;\nuniform vec3 uColors[${MAX_COLORS}];\nuniform float uColorCount;\nuniform vec4 uBackground;\nuniform vec2 uOrigin;\nuniform float uScale;\nuniform float uAngle;\nuniform float uSpacing;\nuniform float uSpread;\nuniform float uStretch;\nuniform float uSharpness;\nuniform float uHeat;\nuniform float uFill;\nuniform float uHaze;\nuniform float uGrain;\nuniform float uSeed;\nuniform float uShimmer;\nuniform float uFlow;\nuniform vec4 uCursor;\nuniform vec2 uDrag;\nuniform vec2 uWaves[${MAX_WAVES}];\nuniform vec2 uIntro;\nuniform float uFade;\nuniform float uOpacity;\nout vec4 outColor;\n\nuint hashu(uint x) {\n  x ^= x >> 16u; x *= 0x7feb352du;\n  x ^= x >> 15u; x *= 0x846ca68bu;\n  x ^= x >> 16u; return x;\n}\nfloat hash12(vec2 p) {\n  ivec2 c = ivec2(floor(p));\n  uint h = hashu(uint(c.x) * 0x9e3779b9u ^ hashu(uint(c.y) + 0x7f4a7c15u));\n  return float(h) / 4294967295.0;\n}\nfloat speckle(vec2 p) {\n  ivec2 c = ivec2(floor(p));\n  uint h = hashu(uint(c.x) * 0x9e3779b9u ^ hashu(uint(c.y) + 0x7f4a7c15u + uint(uSeed) * 0x632be5abu));\n  return float(h) / 4294967295.0;\n}\n\nfloat noise(vec2 p) {\n  vec2 i = floor(p);\n  vec2 f = fract(p);\n  f = f * f * (3.0 - 2.0 * f);\n  float a = hash12(i);\n  float b = hash12(i + vec2(1.0, 0.0));\n  float c = hash12(i + vec2(0.0, 1.0));\n  float d = hash12(i + vec2(1.0, 1.0));\n  return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\nvec4 ramp(float v) {\n  float x = clamp(v, 0.0, 1.0) * uColorCount;\n  vec3 c = vec3(0.0);\n  float keep = 1.0;\n  for (int i = 0; i < ${MAX_COLORS}; i++) {\n    if (float(i) >= uColorCount) break;\n    float w = smoothstep(float(i), float(i) + 1.0, x);\n    c = mix(c, uColors[i], w);\n    keep *= 1.0 - w;\n  }\n  return vec4(c, 1.0 - keep);\n}\n\nfloat feather(float x, float w) {\n  if (w <= 0.0) return 1.0;\n  float t = clamp(min(x, 1.0 - x) / w, 0.0, 1.0);\n  return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nvoid main() {\n  vec2 R  = max(uRes, vec2(1.0));\n  vec2 uv = gl_FragCoord.xy / R;\n  float t = uTime;\n\n  vec2 P = (uv - uOrigin) * vec2(R.x / R.y, 1.0) * uScale;\n  vec2 toCursor = P - uCursor.xy;\n  float spot = dot(toCursor, toCursor);\n  float near = exp(-spot / 0.035);\n  P -= toCursor * uCursor.w * near + uDrag * exp(-spot / 0.07);\n  if (uShimmer > 0.0) {\n    vec2 drift = vec2(0.0, -uFlow);\n    float n1 = noise(P * vec2(6.0, 4.0) + drift) + 0.5 * noise(P * vec2(13.0, 9.0) + drift * 1.7 + 17.0);\n    float n2 = noise(P * vec2(5.0, 7.0) + drift * 1.3 + 31.0);\n    P += uShimmer * vec2(0.02 * (n1 - 0.75), 0.01 * (n2 - 0.5));\n  }\n  float ca = cos(uAngle);\n  float sa = sin(uAngle);\n  P = vec2(ca * P.x - sa * P.y, sa * P.x + ca * P.y);\n  vec2 Q = P * vec2(uStretch, 1.0);\n  float r  = length(Q);\n  float th = atan(Q.x, Q.y);\n\n  float rise = pow(max(r, 1e-4), 0.65) * 6.5;\n  float u = rise / uSpacing - t * 0.15;\n  float f = fract(u);\n\n  float sp = f < 0.6 ? 0.5 * f / 0.6 : 0.5 + 0.5 * (f - 0.6) / 0.4;\n\n  float ang  = exp(-pow(abs(th) / (0.68 * uSpread), 2.4));\n  float wave = pow(sin(3.14159265 * sp), (1.6 + 2.6 * (1.0 - ang)) * uSharpness);\n\n  float amp = 0.55 + 0.10 * smoothstep(0.14, 0.28, r)\n                   + 0.10 * smoothstep(0.28, 0.43, r)\n                   + 0.13 * smoothstep(0.43, 0.63, r)\n                   + 0.12 * smoothstep(0.63, 0.85, r);\n  float core = smoothstep(0.02, 0.12, r);\n  amp *= core;\n\n  float floorv = uFill * smoothstep(0.45, 0.85, r);\n  float v = amp * ang * mix(wave, 1.0, floorv);\n  v += uHaze * exp(-pow(th / uSpread, 2.0)) * smoothstep(0.03, 0.3, r);\n  v *= uHeat;\n\n  for (int k = 0; k < ${MAX_WAVES}; k++) {\n    vec2 pulse = uWaves[k];\n    if (pulse.y <= 0.0) continue;\n    float band = rise - pulse.x;\n    v += pulse.y * exp(-band * band / 0.2) * ang * core * mix(0.35, 1.0, wave);\n  }\n  v *= 1.0 + uCursor.z * near;\n  v += uCursor.z * near * 0.05 * ang;\n  v *= 1.0 - smoothstep(uIntro.x - 1.1, uIntro.x, rise);\n  v += uIntro.y * exp(-pow((rise - uIntro.x + 0.45) / 0.4, 2.0)) * ang * core * mix(0.3, 1.0, wave) * 0.5;\n\n  vec4 ink = ramp(v);\n  ink *= feather(uv.x, uFade * 0.34) * feather(uv.y, uFade * 0.44);\n  float speck = (speckle(gl_FragCoord.xy) - 0.5) * uGrain + (hash12(gl_FragCoord.xy) - 0.5) / 255.0;\n  if (uBackground.a > 0.5) {\n    vec3 col = ink.rgb + uBackground.rgb * (1.0 - ink.a) + speck;\n    outColor = vec4(clamp(col, 0.0, 1.0), 1.0) * uOpacity;\n    return;\n  }\n  vec3 col = ink.rgb + speck * ink.a;\n  outColor = vec4(clamp(col, 0.0, ink.a), ink.a) * uOpacity;\n}`;\n\nconst UNIFORMS = [\n  'uRes',\n  'uTime',\n  'uColors',\n  'uColorCount',\n  'uBackground',\n  'uOrigin',\n  'uScale',\n  'uAngle',\n  'uSpacing',\n  'uSpread',\n  'uStretch',\n  'uSharpness',\n  'uHeat',\n  'uFill',\n  'uHaze',\n  'uGrain',\n  'uSeed',\n  'uShimmer',\n  'uFlow',\n  'uCursor',\n  'uDrag',\n  'uWaves',\n  'uIntro',\n  'uFade',\n  'uOpacity'\n];\n\nconst SOURCES: HeatwaveSource[] = ['bottom', 'top', 'left', 'right', 'center'];\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nconst num = (value: unknown, fallback: number) => {\n  const parsed = Number(value);\n  return Number.isFinite(parsed) ? parsed : fallback;\n};\n\nconst compileShader = (gl: WebGL2RenderingContext, type: number, source: string) => {\n  const shader = gl.createShader(type);\n  if (!shader) return null;\n  gl.shaderSource(shader, source);\n  gl.compileShader(shader);\n  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\n    console.error(gl.getShaderInfoLog(shader));\n  }\n  return shader;\n};\n\nconst createProgram = (gl: WebGL2RenderingContext): Program | null => {\n  const vertex = compileShader(gl, gl.VERTEX_SHADER, VERTEX);\n  const fragment = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT);\n  const program = vertex && fragment ? gl.createProgram() : null;\n  if (!vertex || !fragment || !program) {\n    if (vertex) gl.deleteShader(vertex);\n    if (fragment) gl.deleteShader(fragment);\n    return null;\n  }\n  gl.attachShader(program, vertex);\n  gl.attachShader(program, fragment);\n  gl.linkProgram(program);\n  gl.deleteShader(vertex);\n  gl.deleteShader(fragment);\n  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n    if (!gl.isContextLost()) console.error(gl.getProgramInfoLog(program));\n    gl.deleteProgram(program);\n    return null;\n  }\n  const uniforms: Record<string, WebGLUniformLocation | null> = {};\n  for (const name of UNIFORMS) uniforms[name] = gl.getUniformLocation(program, name);\n  return { program, uniforms };\n};\n\nconst placeSource = (source: HeatwaveSource, aspect: number) => {\n  if (source === 'top') return { x: 0.5, y: 0.92, angle: Math.PI, scale: 1 };\n  if (source === 'left') return { x: 0.08, y: 0.5, angle: Math.PI / 2, scale: 1 / aspect };\n  if (source === 'right') return { x: 0.92, y: 0.5, angle: -Math.PI / 2, scale: 1 / aspect };\n  if (source === 'center') return { x: 0.5, y: 0.5, angle: 0, scale: 1.84 };\n  return { x: 0.5, y: 0.08, angle: 0, scale: 1 };\n};\n\nconst Heatwave = ({\n  colors = DEFAULT_COLORS,\n  backgroundColor = 'transparent',\n  source = 'bottom',\n  tilt = 0,\n  spacing = 1,\n  spread = 1,\n  stretch = 1,\n  sharpness = 1,\n  heat = 1,\n  fill = 0.3,\n  haze = 0.25,\n  shimmer = 0,\n  speed = 1,\n  grain = 0.25,\n  fade = 0,\n  opacity = 1,\n  intro = true,\n  mouseInteraction = true,\n  mouseStrength = 1,\n  clickWave = true,\n  paused = false,\n  dpr,\n  className = '',\n  ...rest\n}: HeatwaveProps) => {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const wakeRef = useRef<(() => void) | null>(null);\n  const [generation, setGeneration] = useState(0);\n  const palette = (Array.isArray(colors) && colors.length ? colors : DEFAULT_COLORS).slice(0, MAX_COLORS).map(String);\n  const settings = {\n    colors: palette,\n    backgroundColor: String(backgroundColor || 'transparent'),\n    source: (SOURCES.includes(source) ? source : 'bottom') as HeatwaveSource,\n    tilt: clamp(num(tilt, 0), -180, 180),\n    spacing: clamp(num(spacing, 1), 0.2, 4),\n    spread: clamp(num(spread, 1), 0.1, 6),\n    stretch: clamp(num(stretch, 1), 0.25, 4),\n    sharpness: clamp(num(sharpness, 1), 0.1, 6),\n    heat: clamp(num(heat, 1), 0, 4),\n    fill: clamp(num(fill, 0.3), 0, 1),\n    haze: clamp(num(haze, 0.25), 0, 1),\n    shimmer: clamp(num(shimmer, 0), 0, 2),\n    speed: clamp(num(speed, 1), -10, 10),\n    grain: clamp(num(grain, 0.25), 0, 1),\n    fade: clamp(num(fade, 0), 0, 1),\n    opacity: clamp(num(opacity, 1), 0, 1),\n    intro,\n    mouseInteraction,\n    mouseStrength: clamp(num(mouseStrength, 1), 0, 3),\n    clickWave,\n    paused,\n    dpr\n  };\n  const settingsRef = useRef(settings);\n  settingsRef.current = settings;\n\n  useEffect(() => {\n    wakeRef.current?.();\n  });\n\n  useEffect(() => {\n    const container = containerRef.current;\n    const canvas = canvasRef.current;\n    if (!container || !canvas) return undefined;\n    const gl = canvas.getContext('webgl2', {\n      alpha: true,\n      premultipliedAlpha: true,\n      antialias: false,\n      depth: false,\n      stencil: false,\n      powerPreference: 'default'\n    });\n    if (!gl) return undefined;\n    const scene = createProgram(gl);\n    if (!scene) return undefined;\n    const vao = gl.createVertexArray();\n    const probe = document.createElement('canvas');\n    probe.width = 1;\n    probe.height = 1;\n    const probeContext = probe.getContext('2d', { willReadFrequently: true });\n    const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;\n    const colorData = new Float32Array(MAX_COLORS * 3);\n    const waveData = new Float32Array(MAX_WAVES * 2);\n    const background = [0, 0, 0, 0];\n    const state = {\n      time: 0,\n      flow: 0,\n      clock: 0,\n      frame: 0,\n      surge: 0,\n      intro: settingsRef.current.intro && !reduce && !settingsRef.current.paused ? 0 : INTRO_SECONDS + 1,\n      width: 1,\n      height: 1,\n      paletteKey: '',\n      backgroundKey: '',\n      colorCount: 1,\n      pointer: { x: 0, y: 0, inside: false, placed: false },\n      cursor: { x: 0.5, y: 0.5, glow: 0, energy: 0 },\n      trail: { x: 0.5, y: 0.5 },\n      drag: { x: 0, y: 0 },\n      waves: [] as Pulse[]\n    };\n    let raf = 0;\n    let last = 0;\n    let visible = true;\n    let alive = true;\n    let lost = false;\n\n    const toRgba = (value: string): number[] => {\n      if (!probeContext || !value) return [0, 0, 0, 0];\n      const css = /^[0-9a-f]{3,8}$/i.test(value) ? `#${value}` : value;\n      probeContext.clearRect(0, 0, 1, 1);\n      probeContext.fillStyle = 'rgba(0, 0, 0, 0)';\n      probeContext.fillStyle = css;\n      probeContext.fillRect(0, 0, 1, 1);\n      const [r, g, b, a] = probeContext.getImageData(0, 0, 1, 1).data;\n      return [r / 255, g / 255, b / 255, a / 255];\n    };\n\n    const syncColors = (s: typeof settings) => {\n      const key = s.colors.join('|');\n      if (key !== state.paletteKey) {\n        state.paletteKey = key;\n        colorData.fill(0);\n        s.colors.forEach((color, index) => colorData.set(toRgba(color).slice(0, 3), index * 3));\n        state.colorCount = s.colors.length;\n      }\n      if (s.backgroundColor !== state.backgroundKey) {\n        state.backgroundKey = s.backgroundColor;\n        const [r, g, b, a] = toRgba(s.backgroundColor);\n        background[0] = r;\n        background[1] = g;\n        background[2] = b;\n        background[3] = a > 0.5 ? 1 : 0;\n      }\n    };\n\n    const render = () => {\n      if (lost) return;\n      const s = settingsRef.current;\n      syncColors(s);\n      const w = canvas.width;\n      const h = canvas.height;\n      const aspect = state.width / state.height;\n      const place = placeSource(s.source, aspect);\n      const u = scene.uniforms;\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.viewport(0, 0, w, h);\n      gl.disable(gl.BLEND);\n      gl.useProgram(scene.program);\n      gl.bindVertexArray(vao);\n      gl.uniform2f(u.uRes, w, h);\n      gl.uniform1f(u.uTime, state.time);\n      gl.uniform3fv(u.uColors, colorData);\n      gl.uniform1f(u.uColorCount, state.colorCount);\n      gl.uniform4f(u.uBackground, background[0], background[1], background[2], background[3]);\n      gl.uniform2f(u.uOrigin, place.x, place.y);\n      gl.uniform1f(u.uScale, place.scale);\n      gl.uniform1f(u.uAngle, place.angle + (s.tilt * Math.PI) / 180);\n      gl.uniform1f(u.uSpacing, s.spacing);\n      gl.uniform1f(u.uSpread, s.spread);\n      gl.uniform1f(u.uStretch, 0.68 / s.stretch);\n      gl.uniform1f(u.uSharpness, s.sharpness);\n      gl.uniform1f(u.uHeat, s.heat);\n      gl.uniform1f(u.uFill, s.fill);\n      gl.uniform1f(u.uHaze, s.haze * 0.1);\n      gl.uniform1f(u.uGrain, s.grain);\n      gl.uniform1f(u.uSeed, state.frame);\n      gl.uniform1f(u.uShimmer, s.shimmer);\n      gl.uniform1f(u.uFlow, state.flow);\n      const { cursor } = state;\n      const lens = cursor.glow * Math.min(0.3, 0.1 * s.mouseStrength);\n      const warmth = cursor.glow * s.mouseStrength * (0.28 + 0.5 * cursor.energy);\n      gl.uniform4f(\n        u.uCursor,\n        (cursor.x - place.x) * aspect * place.scale,\n        (cursor.y - place.y) * place.scale,\n        warmth,\n        lens\n      );\n      gl.uniform2f(u.uDrag, state.drag.x * aspect * place.scale, state.drag.y * place.scale);\n      waveData.fill(0);\n      state.waves.forEach((pulse, index) => {\n        const age = state.clock - pulse.start;\n        const life = clamp(1 - age / WAVE_SECONDS, 0, 1);\n        waveData[index * 2] = -0.4 + age * 3.8;\n        waveData[index * 2 + 1] = 0.7 * Math.pow(life, 1.6) * pulse.strength;\n      });\n      gl.uniform2fv(u.uWaves, waveData);\n      const ramp = clamp(state.intro / INTRO_SECONDS, 0, 1);\n      const eased = 1 - (1 - ramp) * (1 - ramp);\n      gl.uniform2f(u.uIntro, ramp >= 1 ? 1000 : -0.6 + eased * 10.6, ramp >= 1 ? 0 : 1 - eased);\n      gl.uniform1f(u.uFade, s.fade);\n      gl.uniform1f(u.uOpacity, s.opacity);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      gl.bindVertexArray(null);\n    };\n\n    const resize = () => {\n      const s = settingsRef.current;\n      const width = Math.max(1, container.clientWidth);\n      const height = Math.max(1, container.clientHeight);\n      const base = Math.min(s.dpr || window.devicePixelRatio || 1, 2);\n      const longest = Math.max(width, height) * base;\n      const ratio = longest > MAX_RENDER_DIM ? (base * MAX_RENDER_DIM) / longest : base;\n      const pixelWidth = Math.max(1, Math.round(width * ratio));\n      const pixelHeight = Math.max(1, Math.round(height * ratio));\n      if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {\n        canvas.width = pixelWidth;\n        canvas.height = pixelHeight;\n      }\n      state.width = width;\n      state.height = height;\n      render();\n    };\n\n    const frame = (now: number) => {\n      raf = 0;\n      if (!alive || !visible || document.hidden || lost) return;\n      const s = settingsRef.current;\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 0;\n      last = now;\n      const moving = !s.paused && !reduce;\n      const { pointer, cursor, trail, drag } = state;\n      if (moving) {\n        state.clock += dt;\n        state.frame = (state.frame + 1) % 4096;\n        state.intro += dt;\n        state.surge *= Math.exp(-dt / 0.6);\n        state.time += dt * s.speed * (1 + state.surge * 2.5);\n        state.flow += dt * (0.7 + Math.abs(s.speed) * 0.3);\n        state.waves = state.waves.filter(pulse => state.clock - pulse.start < WAVE_SECONDS);\n      } else if (state.intro < INTRO_SECONDS) {\n        state.intro = INTRO_SECONDS + 1;\n      }\n      const active = s.mouseInteraction && pointer.inside && !reduce;\n      const glowGoal = active ? 1 : 0;\n      if (dt > 0) {\n        if (active) {\n          const px = pointer.x / state.width;\n          const py = 1 - pointer.y / state.height;\n          const follow = 1 - Math.exp(-dt / 0.06);\n          const stepX = (px - cursor.x) * follow;\n          const stepY = (py - cursor.y) * follow;\n          cursor.x += stepX;\n          cursor.y += stepY;\n          const aspect = state.width / state.height;\n          const pace = Math.hypot(stepX * aspect, stepY) / dt;\n          cursor.energy += (Math.min(1, pace * 0.8) - cursor.energy) * (1 - Math.exp(-dt / 0.25));\n        } else {\n          cursor.energy *= Math.exp(-dt / 0.4);\n        }\n        const lag = 1 - Math.exp(-dt / 0.22);\n        trail.x += (cursor.x - trail.x) * lag;\n        trail.y += (cursor.y - trail.y) * lag;\n        const limit = 0.035 * Math.min(s.mouseStrength, 2) * cursor.glow;\n        const aspect = state.width / state.height;\n        const pullX = (cursor.x - trail.x) * 0.7;\n        const pullY = (cursor.y - trail.y) * 0.7;\n        const pull = Math.hypot(pullX * aspect, pullY);\n        const scale = pull > limit ? limit / pull : 1;\n        drag.x = pullX * scale;\n        drag.y = pullY * scale;\n        cursor.glow += (glowGoal - cursor.glow) * (1 - Math.exp(-dt / (active ? 0.3 : 0.55)));\n      }\n      render();\n      const settling =\n        Math.hypot(cursor.x - trail.x, cursor.y - trail.y) > 0.0005 ||\n        cursor.energy > 0.002 ||\n        Math.abs(glowGoal - cursor.glow) > 0.002;\n      if (moving || settling) raf = requestAnimationFrame(frame);\n      else last = 0;\n    };\n\n    const wake = () => {\n      if (!raf && alive && visible && !document.hidden && !lost) raf = requestAnimationFrame(frame);\n    };\n\n    const locate = (event: PointerEvent) => {\n      const rect = container.getBoundingClientRect();\n      const x = event.clientX - rect.left;\n      const y = event.clientY - rect.top;\n      return { x, y, inside: x >= 0 && y >= 0 && x <= rect.width && y <= rect.height };\n    };\n\n    const onPointerMove = (event: PointerEvent) => {\n      const spot = locate(event);\n      const { pointer, cursor, trail } = state;\n      if (spot.inside && !pointer.placed && cursor.glow < 0.05) {\n        cursor.x = spot.x / Math.max(state.width, 1);\n        cursor.y = 1 - spot.y / Math.max(state.height, 1);\n        trail.x = cursor.x;\n        trail.y = cursor.y;\n      }\n      pointer.x = spot.x;\n      pointer.y = spot.y;\n      pointer.inside = spot.inside;\n      pointer.placed = spot.inside;\n      wake();\n    };\n\n    const onPointerDown = (event: PointerEvent) => {\n      const s = settingsRef.current;\n      if (!s.mouseInteraction || !s.clickWave || event.button !== 0 || reduce || s.paused) return;\n      if (\n        event.target instanceof Element &&\n        event.target.closest('a, button, input, textarea, select, label, [role=\"button\"]')\n      )\n        return;\n      const spot = locate(event);\n      if (!spot.inside) return;\n      state.surge = Math.min(1.5, state.surge + 1);\n      state.waves.push({ start: state.clock, strength: Math.min(1.5, 0.5 + 0.5 * s.mouseStrength) });\n      while (state.waves.length > MAX_WAVES) state.waves.shift();\n      wake();\n    };\n\n    const onPointerLeave = () => {\n      state.pointer.inside = false;\n      state.pointer.placed = false;\n      wake();\n    };\n\n    const onVisibility = () => {\n      last = 0;\n      wake();\n    };\n\n    const onLost = (event: Event) => {\n      event.preventDefault();\n      lost = true;\n      cancelAnimationFrame(raf);\n      raf = 0;\n    };\n\n    const onRestored = () => setGeneration(value => value + 1);\n\n    const resizeObserver = new ResizeObserver(resize);\n    resizeObserver.observe(container);\n    const intersection = new IntersectionObserver(entries => {\n      visible = entries.some(entry => entry.isIntersecting);\n      if (visible) {\n        last = 0;\n        wake();\n      }\n    });\n    intersection.observe(container);\n    window.addEventListener('pointermove', onPointerMove, { passive: true });\n    window.addEventListener('pointerdown', onPointerDown);\n    document.documentElement.addEventListener('pointerleave', onPointerLeave);\n    document.addEventListener('visibilitychange', onVisibility);\n    canvas.addEventListener('webglcontextlost', onLost);\n    canvas.addEventListener('webglcontextrestored', onRestored);\n    resize();\n    wake();\n    wakeRef.current = () => {\n      if (!raf) render();\n      wake();\n    };\n\n    return () => {\n      alive = false;\n      cancelAnimationFrame(raf);\n      wakeRef.current = null;\n      resizeObserver.disconnect();\n      intersection.disconnect();\n      window.removeEventListener('pointermove', onPointerMove);\n      window.removeEventListener('pointerdown', onPointerDown);\n      document.documentElement.removeEventListener('pointerleave', onPointerLeave);\n      document.removeEventListener('visibilitychange', onVisibility);\n      canvas.removeEventListener('webglcontextlost', onLost);\n      canvas.removeEventListener('webglcontextrestored', onRestored);\n      if (!gl.isContextLost()) {\n        gl.deleteVertexArray(vao);\n        gl.deleteProgram(scene.program);\n      }\n    };\n  }, [generation]);\n\n  return (\n    <div ref={containerRef} className={`heatwave-container${className ? ` ${className}` : ''}`} {...rest}>\n      <canvas ref={canvasRef} className=\"heatwave-canvas\" aria-hidden=\"true\" />\n    </div>\n  );\n};\n\nexport default Heatwave;\n"
		}
	],
	"registryDependencies": [],
	"dependencies": []
}