{
	"$schema": "https://ui.shadcn.com/schema/registry-item.json",
	"name": "HoloMosaic-TS-TW",
	"title": "HoloMosaic",
	"description": "Holographic tiles that split light into sweeping color as it moves, with glitter, a flip-in intro and click waves.",
	"type": "registry:component",
	"files": [
		{
			"type": "registry:component",
			"path": "HoloMosaic/HoloMosaic.tsx",
			"content": "'use client';\n\nimport { useEffect, useRef, useState, type HTMLAttributes } from 'react';\n\nconst MAX_WAVES = 6;\nconst MAX_RENDER_DIM = 2400;\nconst TILE_PX = 52;\nconst EYE = 1.15;\nconst INTRO_SECONDS = 2.4;\nconst WAVE_SECONDS = 4;\nexport type HoloMosaicSpectrum = 'full' | 'warm' | 'cool' | 'pearl';\n\nexport type HoloMosaicFilter = 'none' | 'ascii' | 'dither';\n\nexport interface HoloMosaicProps extends HTMLAttributes<HTMLDivElement> {\n  color?: string;\n  metalColor?: string;\n  spectrum?: HoloMosaicSpectrum;\n  tileSize?: number;\n  gap?: number;\n  roundness?: number;\n  bevel?: number;\n  rotation?: number;\n  scatter?: number;\n  tilt?: number;\n  swirl?: number;\n  ripple?: number;\n  bands?: number;\n  softness?: number;\n  intensity?: number;\n  saturation?: number;\n  glitter?: number;\n  sheen?: number;\n  grain?: number;\n  speed?: number;\n  variation?: number;\n  filter?: HoloMosaicFilter;\n  filterSize?: number;\n  fade?: number;\n  opacity?: number;\n  intro?: boolean;\n  mouseInteraction?: boolean;\n  mouseStrength?: number;\n  mouseRadius?: number;\n  flipOnClick?: boolean;\n  lightMode?: boolean;\n  paused?: boolean;\n  dpr?: number;\n}\n\ntype Job = { program: WebGLProgram; vertex: WebGLShader; fragment: WebGLShader };\n\ntype Surface = { program: WebGLProgram; uniforms: Record<string, WebGLUniformLocation | null> };\n\ntype Point = { x: number; y: number };\n\ntype Body = { x: number; y: number; vx: number; vy: number };\n\ntype Wave = { x: number; y: number; start: number };\n\nconst FILTERS: Record<HoloMosaicFilter, number> = { none: 0, dither: 1, ascii: 2 };\n\nconst SPECTRUMS: Record<HoloMosaicSpectrum, [number, number, number]> = {\n  full: [400, 700, 0],\n  warm: [565, 700, 0],\n  cool: [405, 565, 0],\n  pearl: [420, 690, 0.55]\n};\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;\nuniform vec2 uRes;\nuniform float uPixel;\nuniform float uTime;\nuniform float uClock;\nuniform float uTile;\nuniform vec2 uRot;\nuniform float uGap;\nuniform float uRound;\nuniform float uBevel;\nuniform float uScatter;\nuniform float uTilt;\nuniform float uSwirl;\nuniform float uRipple;\nuniform float uBands;\nuniform float uSoft;\nuniform float uIntensity;\nuniform float uSaturation;\nuniform vec3 uSpectrum;\nuniform float uGlitter;\nuniform float uSheen;\nuniform float uGrain;\nuniform vec3 uColor;\nuniform vec3 uMetal;\nuniform vec2 uLight;\nuniform vec4 uHover;\nuniform vec4 uWaves[${MAX_WAVES}];\nuniform vec4 uIntro;\nuniform float uFade;\nuniform float uOpacity;\nuniform float uLightMode;\nuniform float uSeed;\nuniform float uFrame;\nuniform float uFilter;\nuniform float uFilterSize;\nout vec4 outColor;\n\nfloat h21(vec2 p) {\n  vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n  q += dot(q, q.yzx + 33.33);\n  return fract((q.x + q.y) * q.z);\n}\n\nfloat h31(vec3 p) {\n  p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n  p += dot(p, p.yxz + 33.33);\n  return fract((p.x + p.y) * p.z);\n}\n\nfloat vn3(vec3 p) {\n  vec3 i = floor(p);\n  vec3 f = fract(p);\n  f = f * f * (3.0 - 2.0 * f);\n  return mix(\n    mix(mix(h31(i), h31(i + vec3(1, 0, 0)), f.x), mix(h31(i + vec3(0, 1, 0)), h31(i + vec3(1, 1, 0)), f.x), f.y),\n    mix(mix(h31(i + vec3(0, 0, 1)), h31(i + vec3(1, 0, 1)), f.x), mix(h31(i + vec3(0, 1, 1)), h31(i + vec3(1, 1, 1)), f.x), f.y),\n    f.z\n  );\n}\n\nvec3 bump3y(vec3 x, vec3 yo) {\n  return clamp(1.0 - x * x - yo, 0.0, 1.0);\n}\n\nvec3 spectral(float w) {\n  float x = clamp((w - 400.0) / 300.0, 0.0, 1.0);\n  vec3 c1 = vec3(3.54585104, 2.93225262, 2.41593945);\n  vec3 x1 = vec3(0.69549072, 0.49228336, 0.27699880);\n  vec3 y1 = vec3(0.02312639, 0.15225084, 0.52607955);\n  vec3 c2 = vec3(3.90307140, 3.21182957, 3.96587128);\n  vec3 x2 = vec3(0.11748627, 0.86755042, 0.66077860);\n  vec3 y2 = vec3(0.84897130, 0.88445281, 0.73949448);\n  return bump3y(c1 * (x - x1), y1) + bump3y(c2 * (x - x2), y2);\n}\n\nvec3 band(float lam) {\n  float window = smoothstep(380.0, 425.0, lam) * (1.0 - smoothstep(680.0, 780.0, lam));\n  if (window <= 0.0) return vec3(0.0);\n  return spectral(mix(uSpectrum.x, uSpectrum.y, clamp((lam - 380.0) / 400.0, 0.0, 1.0))) * window;\n}\n\nfloat boxDist(vec2 p, float b, float r, out vec2 grad) {\n  vec2 q = abs(p) - b + r;\n  vec2 m = max(q, 0.0);\n  float outside = length(m);\n  vec2 sg = vec2(p.x < 0.0 ? -1.0 : 1.0, p.y < 0.0 ? -1.0 : 1.0);\n  grad = outside > 0.0 ? sg * m / outside : sg * (q.x > q.y ? vec2(1.0, 0.0) : vec2(0.0, 1.0));\n  return outside + min(max(q.x, q.y), 0.0) - r;\n}\n\nvec4 shade(vec2 frag, float solid) {\n  vec2 c = frag - 0.5 * uRes;\n  vec2 s = c / uRes.y;\n  vec2 g = vec2(uRot.x * c.x + uRot.y * c.y, uRot.x * c.y - uRot.y * c.x) / uTile;\n  vec2 id = floor(g);\n  vec2 f = g - id - 0.5;\n  vec2 gc = (id + 0.5) * uTile;\n  vec2 cell = vec2(uRot.x * gc.x - uRot.y * gc.y, uRot.y * gc.x + uRot.x * gc.y) / uRes.y;\n  vec2 seed = vec2(uSeed * 17.13, uSeed * 31.71);\n  float h1 = h21(id + seed);\n  float h2 = h21(id + seed + 19.7);\n  float h3 = h21(id + seed + 41.3);\n\n  float flip = 0.0;\n  float presence = 1.0;\n  if (uIntro.w > 0.0) {\n    float k = clamp((uIntro.z - length(cell - uIntro.xy) * 0.85 - h1 * 0.22) / 0.75, 0.0, 1.0);\n    float e = k * k * k * (k * (k * 6.0 - 15.0) + 10.0);\n    flip = (1.0 - e) * 1.5707963;\n    presence = e;\n  }\n  for (int i = 0; i < ${MAX_WAVES}; i++) {\n    vec4 w = uWaves[i];\n    if (w.w <= 0.0) continue;\n    float k = clamp(((uClock - w.z) * 0.95 - length(cell - w.xy)) / 0.2, 0.0, 1.0);\n    flip += k * k * (3.0 - 2.0 * k) * 3.1415927;\n  }\n\n  float ca = cos(flip);\n  float sa = sin(flip);\n  float squash = max(abs(ca), 0.02);\n  float half_ = 0.5 - 0.5 * uGap;\n  vec2 grad;\n  float d = boxDist(vec2(f.x / squash, f.y), half_, uRound * half_, grad);\n  float aa = 1.2 / uTile;\n  float aaD = mix(aa, aa / squash, abs(grad.x));\n  float cover = mix((1.0 - smoothstep(-aaD, aaD, d)) * smoothstep(0.02, 0.08, abs(ca)), 1.0, solid);\n  float alpha = cover * uOpacity;\n  if (uFade > 0.0) {\n    vec2 uv = frag / uRes;\n    vec2 m = clamp(min(uv, 1.0 - uv) / max(uFade * 0.5, 1e-4), 0.0, 1.0);\n    m = m * m * m * (m * (m * 6.0 - 15.0) + 10.0);\n    alpha *= m.x * m.y;\n  }\n  if (alpha <= 0.002) return vec4(0.0);\n\n  float edge = smoothstep(-0.02 - 0.07 * uBevel, 0.0, d) * uBevel;\n  float inner = smoothstep(0.0, -0.09, d);\n  vec3 n = normalize(vec3((vec2(h2, h3) - 0.5) * (0.5 * uTilt) + grad * edge * 0.55, 1.0));\n  n = vec3(n.x * ca + n.z * sa, n.y, abs(n.z * ca - n.x * sa));\n  vec3 N = vec3(uRot.x * n.x - uRot.y * n.y, uRot.y * n.x + uRot.x * n.y, n.z);\n  vec2 hv = cell - uHover.xy;\n  float hw = exp(-dot(hv, hv) / (uHover.z * uHover.z)) * uHover.w;\n  N = normalize(N + vec3(-hv / uHover.z * hw * 1.3, 0.0));\n  float turn = abs(sin(flip));\n\n  float t = uTime;\n  float flow = vn3(vec3(s * (1.4 * uSwirl) + seed * 0.013, t * 0.05));\n  vec2 rc = vec2(0.15 + 0.22 * sin(t * 0.07), -0.05 + 0.16 * cos(t * 0.053));\n  float rip = sin(length(s - rc) * 26.0 - t * 1.2) * 0.5 + 0.5;\n  float phi = 6.2831853 * mix(flow, h1, uScatter) + uRipple * 0.9 * rip;\n  vec3 T = vec3(cos(phi), sin(phi), 0.0);\n  T = normalize(T - dot(T, N) * N);\n  vec3 V = normalize(vec3(-s, ${EYE.toFixed(1)}));\n  vec3 L = normalize(vec3(uLight, 1.0));\n  float D = 1450.0 * uBands;\n  vec3 sh = vec3(0.0);\n  for (int k = 0; k < 3; k++) {\n    float a = float(k) * 2.39996 + 0.7;\n    vec3 Lk = normalize(vec3(uLight + vec2(cos(a), sin(a)) * sqrt((float(k) + 0.5) / 3.0) * uSoft, 1.0));\n    float x = abs(dot(Lk + V, T)) * D;\n    sh += band(x) + 0.6 * band(x * 0.5);\n  }\n  sh *= presence * (0.62 + 0.38 * inner) / 3.0;\n  float lum = dot(sh, vec3(0.2126, 0.7152, 0.0722));\n  sh = mix(vec3(lum), sh, uSaturation);\n  sh = mix(sh, vec3(lum * 1.15 + 0.08 * presence), uSpectrum.z * 0.6);\n\n  vec3 H = normalize(L + V);\n  float ndh = max(dot(N, H), 0.0);\n  float wide = pow(ndh, 34.0);\n  float tight = pow(ndh, 700.0);\n  vec2 spot = uLight * ${EYE.toFixed(1)};\n  float pool = pow(max(1.0 - length(s - spot) * 2.1, 0.0), 2.5) * uSheen;\n\n  float spark = 0.0;\n  vec3 sparkColor = vec3(1.0);\n  if (uGlitter > 0.0) {\n    vec2 gq = frag / (uPixel * 6.0);\n    vec2 gid = floor(gq) + seed;\n    float gh = h21(gid + 3.7);\n    if (gh < 0.05 + 0.25 * uGlitter) {\n      vec2 off = vec2(h21(gid + 1.3), h21(gid + 5.9)) - 0.5;\n      float r = length(fract(gq) - 0.5 - off * 0.45);\n      vec3 gn = normalize(vec3((vec2(h21(gid + 9.1), h21(gid + 2.2)) - 0.5) * 0.7 + N.xy, 1.0));\n      float twinkle = 0.55 + 0.45 * sin(t * (2.0 + 5.0 * gh) + gh * 70.0);\n      spark = smoothstep(0.991, 0.9995, dot(gn, H)) * (1.0 - smoothstep(0.07, 0.24, r)) * twinkle * presence * uGlitter;\n      sparkColor = spectral(420.0 + 260.0 * h21(gid + 7.7));\n    }\n  }\n\n  float grainNoise = h31(vec3(floor(frag / uPixel), uFrame)) - 0.5;\n  vec3 col;\n  if (uLightMode > 0.5) {\n    float ink = max(max(sh.r, sh.g), sh.b) * uIntensity;\n    float top = max(max(sh.r, sh.g), sh.b);\n    vec3 hue = sh / max(top, 1e-3);\n    float chroma = (top - min(min(sh.r, sh.g), sh.b)) / max(top, 1e-3);\n    hue = clamp(mix(vec3(dot(hue, vec3(0.2126, 0.7152, 0.0722))), hue, 1.35) * 0.92, 0.0, 1.0);\n    hue = mix(uMetal * 0.85, hue, smoothstep(0.08, 0.45, chroma));\n    float density = 0.86 * smoothstep(0.0, 0.85, ink);\n    vec3 paper = uColor * (1.0 - 0.035 * (1.0 - wide) - 0.05 * edge) + uMetal * (0.08 * tight);\n    col = mix(paper, hue * mix(vec3(1.0), uColor, 0.15), density);\n    col = mix(col, sparkColor * 0.9, min(spark * 1.4, 0.9));\n    col -= abs(grainNoise) * uGrain * 0.35 * clamp(density * 1.6 + spark, 0.0, 1.0);\n    col = mix(col, uColor, 0.12 * (1.0 - wide) * (1.0 - density) * pool);\n  } else {\n    vec3 base = uColor + vec3(0.018, 0.018, 0.024);\n    col = base + uMetal * (0.025 + 0.07 * wide + 1.1 * tight + 0.2 * pool + 0.55 * turn * turn) * (0.75 + 0.25 * inner);\n    col += sh * (1.65 * uIntensity);\n    col += mix(sparkColor, vec3(1.0), 0.45) * spark * 2.4;\n    col = col * (1.0 + col / 5.0) / (1.0 + col * 0.55);\n    col += grainNoise * uGrain * 0.24;\n  }\n  col = clamp(col, 0.0, 1.0);\n  return vec4(col * alpha, alpha);\n}\n\nfloat bayer(vec2 p) {\n  int i = int(mod(p.x, 4.0)) + int(mod(p.y, 4.0)) * 4;\n  int m[16] = int[16](0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5);\n  return (float(m[i]) + 0.5) / 16.0;\n}\n\nfloat glyph(float level, vec2 uv) {\n  int codes[8] = int[8](0, 4194304, 131200, 14336, 459200, 145536, 703136, 11512810);\n  vec2 g = floor(uv * 7.0) - 1.0;\n  if (g.x < 0.0 || g.y < 0.0 || g.x > 4.0 || g.y > 4.0) return 0.0;\n  int code = codes[int(clamp(level * 8.0, 0.0, 7.0))];\n  return float((code >> (int(g.x) + 5 * int(4.0 - g.y))) & 1);\n}\n\nvoid main() {\n  vec2 frag = gl_FragCoord.xy;\n  if (uFilter > 1.5) {\n    float size = max(4.0, floor(uPixel * 10.0 * uFilterSize + 0.5));\n    vec2 cellId = floor(frag / size);\n    vec4 sampled = shade((cellId + 0.5) * size, 1.0);\n    if (sampled.a <= 0.002) {\n      outColor = vec4(0.0);\n      return;\n    }\n    vec3 col = sampled.rgb / sampled.a;\n    float ink = pow(clamp(length(col - uColor) * 1.25, 0.0, 1.0), 0.85);\n    float on = glyph(ink, (frag - cellId * size) / size);\n    float top = max(max(col.r, col.g), col.b);\n    vec3 tone = uLightMode > 0.5 ? col * 0.82 : mix(col, col / max(top, 0.25), 0.4);\n    float alpha = on * sampled.a;\n    outColor = vec4(clamp(tone, 0.0, 1.0) * alpha, alpha);\n  } else if (uFilter > 0.5) {\n    float size = max(1.0, floor(uPixel * 2.0 * uFilterSize + 0.5));\n    vec2 cellId = floor(frag / size);\n    vec4 sampled = shade((cellId + 0.5) * size, 0.0);\n    float threshold = bayer(cellId);\n    float alpha = sampled.a >= 0.999 ? 1.0 : step(threshold, sampled.a);\n    if (alpha <= 0.0) {\n      outColor = vec4(0.0);\n      return;\n    }\n    vec3 col = sampled.rgb / max(sampled.a, 1e-3);\n    vec3 levels = clamp(uColor + floor((col - uColor) * 4.0 + threshold) / 4.0, 0.0, 1.0);\n    outColor = vec4(levels * alpha, alpha);\n  } else {\n    outColor = shade(frag, 0.0);\n  }\n}`;\n\nconst UNIFORMS = [\n  'uRes',\n  'uPixel',\n  'uTime',\n  'uClock',\n  'uTile',\n  'uRot',\n  'uGap',\n  'uRound',\n  'uBevel',\n  'uScatter',\n  'uTilt',\n  'uSwirl',\n  'uRipple',\n  'uBands',\n  'uSoft',\n  'uIntensity',\n  'uSaturation',\n  'uSpectrum',\n  'uGlitter',\n  'uSheen',\n  'uGrain',\n  'uColor',\n  'uMetal',\n  'uLight',\n  'uHover',\n  'uWaves',\n  'uIntro',\n  'uFade',\n  'uOpacity',\n  'uLightMode',\n  'uSeed',\n  'uFrame',\n  'uFilter',\n  'uFilterSize'\n];\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  return shader;\n};\n\nconst startProgram = (gl: WebGL2RenderingContext): Job | 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  return { program, vertex, fragment };\n};\n\nconst finishProgram = (gl: WebGL2RenderingContext, job: Job): Surface | null => {\n  const { program, vertex, fragment } = job;\n  const linked = gl.getProgramParameter(program, gl.LINK_STATUS);\n  if (!linked && !gl.isContextLost()) {\n    const broken = [vertex, fragment].filter(shader => !gl.getShaderParameter(shader, gl.COMPILE_STATUS));\n    if (broken.length) broken.forEach(shader => console.error(gl.getShaderInfoLog(shader)));\n    else console.error(gl.getProgramInfoLog(program));\n  }\n  gl.deleteShader(vertex);\n  gl.deleteShader(fragment);\n  if (!linked) {\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 HoloMosaic = ({\n  color = '#120f17',\n  metalColor = '#e8ebf1',\n  spectrum = 'full',\n  tileSize = 1,\n  gap = 0.08,\n  roundness = 0.15,\n  bevel = 0.35,\n  rotation = 0,\n  scatter = 0.3,\n  tilt = 0.35,\n  swirl = 1,\n  ripple = 0.6,\n  bands = 1.3,\n  softness = 0.5,\n  intensity = 1.25,\n  saturation = 0.1,\n  glitter = 0.85,\n  sheen = 0.8,\n  grain = 0.08,\n  speed = 0.5,\n  variation = 0,\n  filter = 'none',\n  filterSize = 1,\n  fade = 0,\n  opacity = 1,\n  intro = true,\n  mouseInteraction = true,\n  mouseStrength = 1,\n  mouseRadius = 0.25,\n  flipOnClick = true,\n  lightMode = false,\n  paused = false,\n  dpr,\n  className = '',\n  ...rest\n}: HoloMosaicProps) => {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const wakeRef = useRef<(() => void) | null>(null);\n  const releaseRef = useRef(0);\n  const [generation, setGeneration] = useState(0);\n  const settings = {\n    color: String(color),\n    metalColor: String(metalColor),\n    spectrum: SPECTRUMS[spectrum] || SPECTRUMS.full,\n    tileSize: clamp(num(tileSize, 1), 0.2, 6),\n    gap: clamp(num(gap, 0), 0, 0.6),\n    roundness: clamp(num(roundness, 0), 0, 1),\n    bevel: clamp(num(bevel, 0), 0, 1),\n    rotation: (num(rotation, 0) * Math.PI) / 180,\n    scatter: clamp(num(scatter, 0), 0, 1),\n    tilt: clamp(num(tilt, 0), 0, 2),\n    swirl: clamp(num(swirl, 0), 0, 5),\n    ripple: clamp(num(ripple, 0), 0, 3),\n    bands: clamp(num(bands, 1), 0.3, 3),\n    softness: clamp(num(softness, 0), 0, 1),\n    intensity: Math.max(0, num(intensity, 0)),\n    saturation: clamp(num(saturation, 0), 0, 1.5),\n    glitter: clamp(num(glitter, 0), 0, 1),\n    sheen: clamp(num(sheen, 0), 0, 2),\n    grain: clamp(num(grain, 0), 0, 1),\n    speed: Math.max(0, num(speed, 0)),\n    variation: num(variation, 0),\n    filter: FILTERS[filter] ?? 0,\n    filterSize: clamp(num(filterSize, 1), 0.5, 4),\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, 0), 0, 3),\n    mouseRadius: clamp(num(mouseRadius, 0.25), 0.05, 1),\n    flipOnClick,\n    lightMode,\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    cancelAnimationFrame(releaseRef.current);\n    releaseRef.current = 0;\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 parallel = gl.getExtension('KHR_parallel_shader_compile');\n    let job = startProgram(gl);\n    if (!job) return undefined;\n    let surface: Surface | null = null;\n    if (!parallel) {\n      surface = finishProgram(gl, job);\n      job = null;\n      if (!surface) return undefined;\n    }\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 waveData = new Float32Array(MAX_WAVES * 4);\n    const state = {\n      time: 17 + (settingsRef.current.variation % 97) * 3.1,\n      clock: 0,\n      frame: 0,\n      intro: settingsRef.current.intro && !reduce && !settingsRef.current.paused ? 0 : INTRO_SECONDS,\n      started: false,\n      width: 1,\n      height: 1,\n      ratio: 1,\n      colorKey: '',\n      color: [0.07, 0.06, 0.09],\n      metal: [0.78, 0.8, 0.85],\n      pointer: { x: 0, y: 0, inside: false },\n      light: { x: 0, y: 0, vx: 0, vy: 0, placed: false },\n      hover: { x: 0, y: 0, vx: 0, vy: 0, presence: 0, placed: false },\n      follow: 0,\n      waves: [] as Wave[]\n    };\n    let raf = 0;\n    let last = 0;\n    let visible = true;\n    let alive = true;\n    let lost = false;\n\n    const toRgb = (value: string, fallback: number[]): number[] => {\n      if (!probeContext || !value) return fallback;\n      const css = /^[0-9a-f]{3,8}$/i.test(value) ? `#${value}` : value;\n      probeContext.clearRect(0, 0, 1, 1);\n      probeContext.fillStyle = '#000000';\n      probeContext.fillStyle = css;\n      probeContext.fillRect(0, 0, 1, 1);\n      const [r, g, b] = probeContext.getImageData(0, 0, 1, 1).data;\n      return [r / 255, g / 255, b / 255];\n    };\n\n    const resolveColors = (s: typeof settings) => {\n      const key = `${s.color}|${s.metalColor}`;\n      if (key === state.colorKey) return;\n      state.colorKey = key;\n      state.color = toRgb(s.color, [0.07, 0.06, 0.09]);\n      state.metal = toRgb(s.metalColor, [0.78, 0.8, 0.85]);\n    };\n\n    const aspect = () => state.width / Math.max(state.height, 1);\n\n    const wander = () => {\n      const t = state.time;\n      return {\n        x: 0.46 * aspect() * Math.cos(t * 0.29 + 0.4),\n        y: 0.36 * Math.sin(t * 0.41 + 1.1)\n      };\n    };\n\n    const toSurface = (px: number, py: number): Point => ({\n      x: (px - state.width / 2) / state.height,\n      y: (state.height / 2 - py) / state.height\n    });\n\n    const render = () => {\n      if (!surface || lost) return;\n      const s = settingsRef.current;\n      resolveColors(s);\n      const u = surface.uniforms;\n      gl.viewport(0, 0, canvas.width, canvas.height);\n      gl.disable(gl.BLEND);\n      gl.useProgram(surface.program);\n      gl.bindVertexArray(vao);\n      waveData.fill(0);\n      state.waves.forEach((wave, index) => {\n        waveData[index * 4] = wave.x;\n        waveData[index * 4 + 1] = wave.y;\n        waveData[index * 4 + 2] = wave.start;\n        waveData[index * 4 + 3] = 1;\n      });\n      const introLive = state.intro < INTRO_SECONDS;\n      gl.uniform2f(u.uRes, canvas.width, canvas.height);\n      gl.uniform1f(u.uPixel, state.ratio);\n      gl.uniform1f(u.uTime, state.time);\n      gl.uniform1f(u.uClock, state.clock);\n      gl.uniform1f(u.uTile, TILE_PX * s.tileSize * state.ratio);\n      gl.uniform2f(u.uRot, Math.cos(s.rotation), Math.sin(s.rotation));\n      gl.uniform1f(u.uGap, s.gap);\n      gl.uniform1f(u.uRound, s.roundness);\n      gl.uniform1f(u.uBevel, s.bevel);\n      gl.uniform1f(u.uScatter, s.scatter);\n      gl.uniform1f(u.uTilt, s.tilt);\n      gl.uniform1f(u.uSwirl, s.swirl);\n      gl.uniform1f(u.uRipple, s.ripple);\n      gl.uniform1f(u.uBands, s.bands);\n      gl.uniform1f(u.uSoft, 0.02 + 0.2 * s.softness);\n      gl.uniform1f(u.uIntensity, s.intensity);\n      gl.uniform1f(u.uSaturation, s.saturation);\n      gl.uniform3f(u.uSpectrum, s.spectrum[0], s.spectrum[1], s.spectrum[2]);\n      gl.uniform1f(u.uGlitter, s.glitter);\n      gl.uniform1f(u.uSheen, s.sheen);\n      gl.uniform1f(u.uGrain, s.grain);\n      gl.uniform3f(u.uColor, state.color[0], state.color[1], state.color[2]);\n      gl.uniform3f(u.uMetal, state.metal[0], state.metal[1], state.metal[2]);\n      gl.uniform2f(u.uLight, state.light.x / EYE, state.light.y / EYE);\n      gl.uniform4f(u.uHover, state.hover.x, state.hover.y, s.mouseRadius, 0.8 * state.hover.presence * s.mouseStrength);\n      gl.uniform4fv(u.uWaves, waveData);\n      gl.uniform4f(u.uIntro, 0, 0, state.intro, introLive ? 1 : 0);\n      gl.uniform1f(u.uFade, s.fade);\n      gl.uniform1f(u.uOpacity, s.opacity);\n      gl.uniform1f(u.uLightMode, s.lightMode ? 1 : 0);\n      gl.uniform1f(u.uSeed, (s.variation % 1000) * 0.618);\n      gl.uniform1f(u.uFrame, state.frame % 613);\n      gl.uniform1f(u.uFilter, s.filter);\n      gl.uniform1f(u.uFilterSize, s.filterSize);\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      state.ratio = pixelHeight / height;\n      if (!state.light.placed) {\n        const home = wander();\n        state.light.x = home.x;\n        state.light.y = home.y;\n        state.light.placed = true;\n      }\n      render();\n    };\n\n    const spring = (body: Body, target: Point, stiffness: number, damping: number, dt: number) => {\n      body.vx += (stiffness * (target.x - body.x) - damping * body.vx) * dt;\n      body.vy += (stiffness * (target.y - body.y) - damping * body.vy) * dt;\n      body.x += body.vx * dt;\n      body.y += body.vy * dt;\n    };\n\n    const ready = () => {\n      if (surface) return true;\n      if (!job || !parallel || !gl.getProgramParameter(job.program, parallel.COMPLETION_STATUS_KHR)) return false;\n      surface = finishProgram(gl, job);\n      job = null;\n      return Boolean(surface);\n    };\n\n    const frame = (now: number) => {\n      raf = 0;\n      if (!alive || !visible || document.hidden || lost) return;\n      if (!ready()) {\n        if (job) raf = requestAnimationFrame(frame);\n        return;\n      }\n      const s = settingsRef.current;\n      const dt = last && state.started ? Math.min(0.05, (now - last) / 1000) : 0;\n      last = now;\n      state.started = true;\n      const moving = !s.paused && !reduce;\n      if (moving) {\n        state.frame += 1;\n        state.clock += dt;\n        state.intro += dt;\n        state.time += dt * s.speed;\n        state.waves = state.waves.filter(wave => state.clock - wave.start < WAVE_SECONDS);\n      } else if (state.intro < INTRO_SECONDS) {\n        state.intro = INTRO_SECONDS;\n      }\n      const { pointer, light, hover } = state;\n      const active = s.mouseInteraction && pointer.inside && !reduce;\n      const target = active ? toSurface(pointer.x, pointer.y) : null;\n      state.follow += ((active ? 1 : 0) - state.follow) * (1 - Math.exp(-dt / (active ? 0.45 : 1.2)));\n      const home = wander();\n      const goal = target\n        ? { x: home.x + (target.x - home.x) * state.follow, y: home.y + (target.y - home.y) * state.follow }\n        : home;\n      if (dt > 0) spring(light, goal, 38, 11, dt);\n      if (target) {\n        if (!hover.placed) {\n          hover.x = target.x;\n          hover.y = target.y;\n          hover.vx = 0;\n          hover.vy = 0;\n          hover.placed = true;\n        }\n        if (dt > 0) spring(hover, target, 90, 18, dt);\n      }\n      const hoverGoal = target ? 1 : 0;\n      hover.presence += (hoverGoal - hover.presence) * (1 - Math.exp(-dt / (hoverGoal > hover.presence ? 0.3 : 0.6)));\n      if (!target && hover.presence < 0.001) hover.placed = false;\n      render();\n      const settling =\n        Math.abs(hoverGoal - hover.presence) > 0.002 ||\n        Math.hypot(light.vx, light.vy) > 0.0005 ||\n        Math.hypot(goal.x - light.x, goal.y - light.y) > 0.0005 ||\n        Math.hypot(hover.vx, hover.vy) > 0.0005;\n      const animating = moving && (s.speed > 0 || state.intro < INTRO_SECONDS || state.waves.length > 0);\n      if (animating || 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      state.pointer.x = spot.x;\n      state.pointer.y = spot.y;\n      state.pointer.inside = spot.inside;\n      wake();\n    };\n\n    const onPointerDown = (event: PointerEvent) => {\n      const s = settingsRef.current;\n      if (!s.mouseInteraction || !s.flipOnClick || 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      const point = toSurface(spot.x, spot.y);\n      state.waves.push({ x: point.x, y: point.y, start: state.clock });\n      while (state.waves.length > MAX_WAVES) state.waves.shift();\n      wake();\n    };\n\n    const onPointerLeave = () => {\n      state.pointer.inside = 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        if (surface) gl.deleteProgram(surface.program);\n        const release = () => {\n          if (!job || gl.isContextLost()) return;\n          if (parallel && !gl.getProgramParameter(job.program, parallel.COMPLETION_STATUS_KHR)) {\n            requestAnimationFrame(release);\n            return;\n          }\n          gl.deleteShader(job.vertex);\n          gl.deleteShader(job.fragment);\n          gl.deleteProgram(job.program);\n          job = null;\n        };\n        release();\n      }\n      const free = () => {\n        releaseRef.current = 0;\n        if (!canvas.isConnected && !gl.isContextLost()) gl.getExtension('WEBGL_lose_context')?.loseContext();\n      };\n      if (canvas.isConnected) releaseRef.current = requestAnimationFrame(free);\n      else free();\n    };\n  }, [generation]);\n\n  return (\n    <div\n      ref={containerRef}\n      className={['relative h-full w-full overflow-hidden', className].filter(Boolean).join(' ')}\n      {...rest}\n    >\n      <canvas ref={canvasRef} className=\"absolute inset-0 block h-full w-full\" aria-hidden=\"true\" />\n    </div>\n  );\n};\n\nexport default HoloMosaic;\n"
		}
	],
	"registryDependencies": [],
	"dependencies": []
}