{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gallery-backstage",
  "type": "registry:component",
  "title": "Gallery Backstage",
  "description": "A dark stage with the images standing in a row. A soft spotlight cone picks out the active one while the rest wait dimmed behind; drag across the stage, click or use the arrows to move the light.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "components",
    "gallery",
    "spotlight",
    "stage",
    "drag",
    "dark",
    "images"
  ],
  "docs": "https://hyperblur.dev/effects/gallery-backstage",
  "files": [
    {
      "path": "registry/hyperblur/gallery-backstage.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/gallery-backstage.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type GalleryBackstageImage = { src?: string; title: string; caption?: string };\n\nexport interface GalleryBackstageProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  images?: GalleryBackstageImage[];\n  value?: number;\n  defaultValue?: number;\n  onChange?: (index: number) => void;\n  idle?: boolean;\n  interval?: number;\n  height?: number;\n  light?: string;\n  accent?: string;\n  label?: string;\n}\n\nconst sampleImages: GalleryBackstageImage[] = [\n  { title: \"Dune Hour\", caption: \"Erg Chebbi, 2024\" },\n  { title: \"Harbor Lights\", caption: \"Lisbon, 2023\" },\n  { title: \"Glacier Line\", caption: \"Jokulsarlon, 2022\" },\n  { title: \"Pine Ridge\", caption: \"Cascades, 2021\" },\n  { title: \"Polar Night\", caption: \"Tromso, 2020\" },\n  { title: \"Sun Room\", caption: \"Brooklyn, 2019\" },\n];\n\nfunction mix(n: number) {\n  let x = Math.imul((n + 7) | 0, 0x9e3779b1) >>> 0;\n  x = Math.imul(x ^ (x >>> 16), 0x85ebca6b) >>> 0;\n  x = Math.imul(x ^ (x >>> 13), 0xc2b2ae35) >>> 0;\n  return (x ^ (x >>> 16)) >>> 0;\n}\n\nfunction sky(a: string, b: string, c: string) {\n  return `<defs><linearGradient id=\"s\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"${a}\"/><stop offset=\"0.62\" stop-color=\"${b}\"/><stop offset=\"1\" stop-color=\"${c}\"/></linearGradient></defs><rect width=\"320\" height=\"240\" fill=\"url(#s)\"/>`;\n}\n\nfunction sceneSvg(k: number) {\n  let b = \"\";\n  if (k === 0) {\n    b =\n      sky(\"#ffd28f\", \"#f2866b\", \"#8a4a7c\") +\n      '<circle cx=\"214\" cy=\"98\" r=\"54\" fill=\"#fff3cf\" opacity=\"0.18\"/><circle cx=\"214\" cy=\"98\" r=\"30\" fill=\"#fff3cf\"/><path d=\"M0 168 Q90 122 172 160 T320 150 V240 H0Z\" fill=\"#dc8752\"/><path d=\"M0 198 Q110 160 204 194 T320 186 V240 H0Z\" fill=\"#ab5840\"/><path d=\"M0 224 Q120 200 236 222 T320 216 V240 H0Z\" fill=\"#6f3437\"/>';\n  } else if (k === 1) {\n    b = sky(\"#0c1230\", \"#28205e\", \"#5c2c6c\") + '<circle cx=\"258\" cy=\"48\" r=\"13\" fill=\"#fff1d6\"/>';\n    for (let i = 0; i < 18; i += 1) {\n      const v = mix(i + 40);\n      b += `<circle cx=\"${v % 320}\" cy=\"${mix(i + 90) % 90}\" r=\"${(0.6 + (v % 4) / 5).toFixed(2)}\" fill=\"#ffffff\" opacity=\"0.7\"/>`;\n    }\n    for (let i = 0; i < 10; i += 1) {\n      const x = i * 34 - 6;\n      const w = 30 + (mix(i) % 10);\n      const h = 70 + (mix(i + 20) % 96);\n      b += `<rect x=\"${x}\" y=\"${222 - h}\" width=\"${w}\" height=\"${h}\" fill=\"#161333\"/>`;\n      for (let r = 0; r < Math.floor((h - 12) / 14); r += 1) {\n        for (let c = 0; c < Math.floor((w - 8) / 9); c += 1) {\n          const q = mix(i * 97 + r * 13 + c);\n          if (q % 3 === 0) b += `<rect x=\"${x + 5 + c * 9}\" y=\"${230 - h + r * 14}\" width=\"4\" height=\"6\" fill=\"${q % 2 ? \"#ffcf7a\" : \"#ff9f86\"}\"/>`;\n        }\n      }\n    }\n    b += '<rect y=\"222\" width=\"320\" height=\"18\" fill=\"#0b0a1f\"/><rect x=\"40\" y=\"228\" width=\"60\" height=\"2\" fill=\"#ffcf7a\" opacity=\"0.35\"/><rect x=\"190\" y=\"232\" width=\"80\" height=\"2\" fill=\"#ff9f86\" opacity=\"0.3\"/>';\n  } else if (k === 2) {\n    b =\n      sky(\"#d9efff\", \"#86bde8\", \"#2f6fa8\") +\n      '<polygon points=\"0,150 46,96 82,128 124,78 170,134 214,92 262,140 320,104 320,170 0,170\" fill=\"#f4fbff\"/><polygon points=\"46,96 60,150 30,150\" fill=\"#c4def2\"/><polygon points=\"124,78 142,150 104,150\" fill=\"#c4def2\"/><polygon points=\"214,92 230,150 196,150\" fill=\"#c4def2\"/><rect y=\"164\" width=\"320\" height=\"76\" fill=\"#17508a\"/><path d=\"M0 182 Q40 176 80 182 T160 182 T240 182 T320 182\" stroke=\"#8ec6f0\" stroke-width=\"2\" fill=\"none\" opacity=\"0.5\"/><path d=\"M0 204 Q40 198 80 204 T160 204 T240 204 T320 204\" stroke=\"#8ec6f0\" stroke-width=\"2\" fill=\"none\" opacity=\"0.35\"/><polygon points=\"88,176 126,176 116,190 96,190\" fill=\"#e8f6ff\"/><polygon points=\"220,196 268,196 256,212 230,212\" fill=\"#d2ecff\"/>';\n  } else if (k === 3) {\n    b = sky(\"#e4ece4\", \"#a9c2b2\", \"#6f8f7e\");\n    const rows: [number, number, string][] = [\n      [120, 50, \"#86a596\"],\n      [150, 62, \"#4b6d5d\"],\n      [186, 78, \"#22392f\"],\n    ];\n    rows.forEach(([base, tall, fill], r) => {\n      for (let i = 0; i < 12; i += 1) {\n        const x = i * 30 + (mix(r * 31 + i) % 18) - 10;\n        const h = tall - 14 + (mix(r * 57 + i) % 28);\n        b += `<polygon points=\"${x},${base - h} ${x - 15},${base + 6} ${x + 15},${base + 6}\" fill=\"${fill}\"/>`;\n      }\n      b += `<rect y=\"${base + 4}\" width=\"320\" height=\"${240 - base}\" fill=\"${fill}\"/>`;\n      if (r === 0) b += '<rect y=\"118\" width=\"320\" height=\"30\" fill=\"#e4ece4\" opacity=\"0.55\"/>';\n    });\n  } else if (k === 4) {\n    b =\n      sky(\"#040a18\", \"#0b1d38\", \"#12304a\") +\n      '<path d=\"M0 96 C70 40 160 126 320 56 L320 104 C170 168 92 84 0 146Z\" fill=\"#3ef0a8\" opacity=\"0.32\"/><path d=\"M0 70 C90 30 170 96 320 30 L320 60 C180 120 96 60 0 110Z\" fill=\"#8f6bff\" opacity=\"0.22\"/><path d=\"M40 110 C120 76 200 140 300 90\" stroke=\"#9fffd6\" stroke-width=\"3\" fill=\"none\" opacity=\"0.4\"/>';\n    for (let i = 0; i < 26; i += 1) {\n      const v = mix(i + 300);\n      b += `<circle cx=\"${v % 320}\" cy=\"${mix(i + 500) % 120}\" r=\"${(0.5 + (v % 3) / 4).toFixed(2)}\" fill=\"#ffffff\" opacity=\"0.75\"/>`;\n    }\n    b +=\n      '<polygon points=\"0,200 60,140 104,176 160,120 220,180 266,150 320,190 320,240 0,240\" fill=\"#0a1626\"/><polygon points=\"160,120 176,136 168,134 160,142 152,134 146,134\" fill=\"#dfeaf5\"/><polygon points=\"60,140 72,152 60,150 50,152\" fill=\"#dfeaf5\"/><rect y=\"214\" width=\"320\" height=\"26\" fill=\"#06101d\"/>';\n  } else {\n    b =\n      '<defs><radialGradient id=\"s\" cx=\"0.32\" cy=\"0.3\" r=\"0.9\"><stop offset=\"0\" stop-color=\"#ffe2c8\"/><stop offset=\"0.55\" stop-color=\"#e09a7c\"/><stop offset=\"1\" stop-color=\"#7c4648\"/></radialGradient><radialGradient id=\"o\" cx=\"0.35\" cy=\"0.3\" r=\"0.75\"><stop offset=\"0\" stop-color=\"#fff6ea\"/><stop offset=\"1\" stop-color=\"#c46f58\"/></radialGradient></defs><rect width=\"320\" height=\"240\" fill=\"url(#s)\"/><path d=\"M188 240 V112 A52 52 0 0 1 292 112 V240Z\" fill=\"#f6c9a8\" opacity=\"0.55\"/><rect x=\"40\" y=\"176\" width=\"140\" height=\"64\" fill=\"#5d3236\"/><rect x=\"40\" y=\"170\" width=\"140\" height=\"8\" fill=\"#7a4447\"/><circle cx=\"110\" cy=\"138\" r=\"32\" fill=\"url(#o)\"/><rect x=\"150\" y=\"128\" width=\"16\" height=\"42\" rx=\"3\" fill=\"#2f2a44\"/><ellipse cx=\"158\" cy=\"128\" rx=\"8\" ry=\"3\" fill=\"#4a4366\"/>';\n  }\n  return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 240\" preserveAspectRatio=\"xMidYMid slice\">${b}</svg>`;\n}\n\nconst sceneCache = new Map<number, string>();\n\nfunction sceneUrl(index: number) {\n  const k = ((index % 6) + 6) % 6;\n  let url = sceneCache.get(k);\n  if (!url) {\n    url = `url(\"data:image/svg+xml,${encodeURIComponent(sceneSvg(k))}\")`;\n    sceneCache.set(k, url);\n  }\n  return url;\n}\n\nfunction imageUrl(src: string | undefined, index: number) {\n  return src ? `url(${JSON.stringify(src)})` : sceneUrl(index);\n}\n\nconst motes = Array.from({ length: 9 }, (_, i) => {\n  const v = mix(i + 900);\n  return {\n    left: (18 + (v % 64)).toFixed(0),\n    top: (16 + (mix(i + 940) % 64)).toFixed(0),\n    size: (1.5 + (v % 3) * 0.6).toFixed(1),\n    delay: ((mix(i + 980) % 40) / 10).toFixed(1),\n    dur: (4 + (v % 4)).toFixed(1),\n  };\n});\n\nconst css = `\n.hb-zw3 {\n  --hb-zw3-accent: #2f7bff;\n  --hb-zw3-light: #fff2d6;\n  box-sizing: border-box;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  container-type: inline-size;\n}\n.hb-zw3 *, .hb-zw3 *::before, .hb-zw3 *::after { box-sizing: border-box; }\n.hb-zw3-stage {\n  --hb-zw3-iw: min(calc(88cqw / var(--hb-zw3-n) * 1.4), calc(var(--hb-zw3-h) * 0.42));\n  position: relative;\n  width: 100%;\n  height: var(--hb-zw3-h);\n  overflow: hidden;\n  isolation: isolate;\n  border: 1px solid #1f1f1f;\n  border-radius: 16px;\n  background:\n    radial-gradient(120% 70% at 50% 0%, #17171b 0%, #0b0b0d 60%, #070708 100%);\n  cursor: grab;\n  touch-action: pan-y;\n  user-select: none;\n  -webkit-user-select: none;\n}\n.hb-zw3-stage[data-drag=\"true\"] { cursor: grabbing; }\n.hb-zw3-wall {\n  position: absolute;\n  inset: 0 0 30% 0;\n  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 18px);\n  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 100%);\n  mask-image: linear-gradient(180deg, #000 0%, transparent 100%);\n}\n.hb-zw3-floor {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  height: 30%;\n  background: linear-gradient(180deg, #0f0f12 0%, #060607 100%);\n  border-top: 1px solid rgba(255, 255, 255, 0.04);\n}\n.hb-zw3-beam, .hb-zw3-pool {\n  position: absolute;\n  left: var(--hb-zw3-x);\n  transition: left 0.65s cubic-bezier(0.22, 0.8, 0.2, 1);\n  pointer-events: none;\n}\n.hb-zw3-stage[data-drag=\"true\"] .hb-zw3-beam, .hb-zw3-stage[data-drag=\"true\"] .hb-zw3-pool { transition: none; }\n.hb-zw3-beam {\n  top: 0;\n  bottom: 16%;\n  z-index: 2;\n  width: calc(var(--hb-zw3-iw) * 1.9);\n  transform: translateX(-50%);\n}\n.hb-zw3-cone {\n  position: absolute;\n  inset: 0;\n  clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);\n  background: linear-gradient(180deg,\n    color-mix(in srgb, var(--hb-zw3-light) 70%, transparent) 0%,\n    color-mix(in srgb, var(--hb-zw3-light) 16%, transparent) 70%,\n    transparent 100%);\n  filter: blur(5px);\n  mix-blend-mode: screen;\n  transform-origin: 50% 0;\n  animation: hb-zw3-sway 6s ease-in-out infinite alternate;\n}\n.hb-zw3-mote {\n  position: absolute;\n  border-radius: 999px;\n  background: var(--hb-zw3-light);\n  opacity: 0;\n  animation: hb-zw3-drift var(--hb-zw3-md) ease-in-out var(--hb-zw3-mdl) infinite;\n}\n.hb-zw3-lamp {\n  position: absolute;\n  top: -6px;\n  left: 50%;\n  width: 34px;\n  height: 14px;\n  margin-left: -17px;\n  border-radius: 0 0 10px 10px;\n  background: linear-gradient(180deg, #2a2a2e, #141416);\n  box-shadow: 0 6px 18px 2px color-mix(in srgb, var(--hb-zw3-light) 45%, transparent);\n}\n.hb-zw3-pool {\n  bottom: 9%;\n  z-index: 1;\n  width: calc(var(--hb-zw3-iw) * 2.2);\n  height: 18%;\n  transform: translateX(-50%);\n  border-radius: 50%;\n  background: radial-gradient(closest-side, color-mix(in srgb, var(--hb-zw3-light) 30%, transparent), transparent);\n}\n.hb-zw3-item {\n  position: absolute;\n  bottom: 22%;\n  left: calc(6% + (var(--hb-zw3-i) + 0.5) * 88% / var(--hb-zw3-n));\n  z-index: 1;\n  width: var(--hb-zw3-iw);\n  aspect-ratio: 3 / 4;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 8px;\n  overflow: hidden;\n  background: #171717;\n  background-size: cover;\n  background-position: center;\n  cursor: pointer;\n  outline: none;\n  transform: translateX(-50%) scale(0.84);\n  transform-origin: 50% 100%;\n  filter: brightness(0.3) saturate(0.45);\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);\n  transition: transform 0.65s cubic-bezier(0.22, 0.8, 0.2, 1), filter 0.65s ease, box-shadow 0.4s ease;\n}\n.hb-zw3-item[data-on=\"true\"] {\n  z-index: 3;\n  transform: translateX(-50%) translateY(-3%) scale(1.12);\n  filter: brightness(1.04) saturate(1.05);\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 20px 34px -14px rgba(0, 0, 0, 0.9);\n}\n.hb-zw3-item:focus-visible { box-shadow: 0 0 0 2px var(--hb-zw3-accent); }\n.hb-zw3-cap {\n  position: absolute;\n  left: 50%;\n  bottom: 5%;\n  z-index: 4;\n  width: 64%;\n  transform: translateX(-50%);\n  text-align: center;\n  pointer-events: none;\n}\n.hb-zw3-title {\n  margin: 0;\n  font-size: 0.95em;\n  font-weight: 600;\n  line-height: 1.25;\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  animation: hb-zw3-in 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;\n}\n.hb-zw3-sub {\n  margin: 1px 0 0;\n  font-size: 0.72em;\n  letter-spacing: 0.06em;\n  color: #8f8f8f;\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  animation: hb-zw3-in 0.55s 0.06s cubic-bezier(0.2, 0.7, 0.2, 1) both;\n}\n.hb-zw3-arrow {\n  position: absolute;\n  bottom: 5%;\n  z-index: 4;\n  display: grid;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  margin: 0;\n  padding: 0;\n  border: 1px solid #2a2a2a;\n  border-radius: 999px;\n  background: rgba(17, 17, 17, 0.8);\n  color: #ededed;\n  cursor: pointer;\n  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;\n}\n.hb-zw3-arrow:hover { background: #1c1c1c; border-color: #3a3a3a; }\n.hb-zw3-arrow:focus-visible { outline: 2px solid var(--hb-zw3-accent); outline-offset: 2px; }\n.hb-zw3-arrow:disabled { opacity: 0.35; cursor: default; }\n.hb-zw3-arrow svg { width: 13px; height: 13px; }\n.hb-zw3-left { left: 12px; }\n.hb-zw3-right { right: 12px; }\n@keyframes hb-zw3-sway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }\n@keyframes hb-zw3-drift {\n  0% { opacity: 0; transform: translate(0, 6px); }\n  40% { opacity: 0.8; }\n  100% { opacity: 0; transform: translate(6px, -14px); }\n}\n@keyframes hb-zw3-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-zw3-beam, .hb-zw3-pool, .hb-zw3-item, .hb-zw3-arrow { transition: none; }\n  .hb-zw3-cone, .hb-zw3-mote, .hb-zw3-title, .hb-zw3-sub { animation: none; }\n}\n`;\n\nfunction Chevron({ dir }: { dir: 1 | -1 }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n      <path\n        d={dir === 1 ? \"M6 3.5 10.5 8 6 12.5\" : \"M10 3.5 5.5 8 10 12.5\"}\n        stroke=\"currentColor\"\n        strokeWidth=\"1.6\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function GalleryBackstage({\n  images,\n  value,\n  defaultValue = 0,\n  onChange,\n  idle = true,\n  interval = 2600,\n  height = 320,\n  light = \"#fff2d6\",\n  accent = \"#2f7bff\",\n  label = \"Gallery\",\n  className,\n  style,\n  ...rest\n}: GalleryBackstageProps) {\n  const list = images && images.length ? images : sampleImages;\n  const n = list.length;\n  const [inner, setInner] = React.useState(Math.min(Math.max(defaultValue, 0), n - 1));\n  const current = Math.min(Math.max(value ?? inner, 0), n - 1);\n  const [dragX, setDragX] = React.useState<number | null>(null);\n  const [inside, setInside] = React.useState(false);\n  const [focused, setFocused] = React.useState(false);\n  const [visible, setVisible] = React.useState(true);\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const stageRef = React.useRef<HTMLDivElement>(null);\n  const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const drag = React.useRef<{ id: number; x: number; moved: boolean } | null>(null);\n  const dirRef = React.useRef(1);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  const go = React.useCallback(\n    (next: number, fromUser: boolean) => {\n      const k = Math.min(Math.max(next, 0), n - 1);\n      if (value === undefined) setInner(k);\n      if (fromUser && k !== current) onChange?.(k);\n    },\n    [n, value, current, onChange],\n  );\n\n  React.useEffect(() => {\n    if (!idle || inside || focused || !visible || value !== undefined || n < 2) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const t = window.setInterval(() => {\n      setInner((c) => {\n        let d = dirRef.current;\n        if (c + d > n - 1 || c + d < 0) d = -d;\n        dirRef.current = d;\n        return c + d;\n      });\n    }, interval);\n    return () => window.clearInterval(t);\n  }, [idle, inside, focused, visible, value, n, interval]);\n\n  const fraction = (clientX: number) => {\n    const r = stageRef.current?.getBoundingClientRect();\n    if (!r || r.width === 0) return 0.5;\n    return Math.min(Math.max((clientX - r.left) / r.width, 0), 0.9999);\n  };\n\n  const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (e.button !== 0) return;\n    if ((e.target as HTMLElement).closest(\".hb-zw3-arrow\")) return;\n    drag.current = { id: e.pointerId, x: e.clientX, moved: false };\n  };\n\n  const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    if (!d || d.id !== e.pointerId) return;\n    if (!d.moved) {\n      if (Math.abs(e.clientX - d.x) < 5) return;\n      d.moved = true;\n      e.currentTarget.setPointerCapture(e.pointerId);\n    }\n    const f = fraction(e.clientX);\n    setDragX(f);\n    go(Math.floor(Math.min(Math.max((f - 0.06) / 0.88, 0), 0.9999) * n), true);\n  };\n\n  const endDrag = (e: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    if (!d || d.id !== e.pointerId) return;\n    drag.current = null;\n    if (d.moved) {\n      if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n      setDragX(null);\n    }\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    let next: number | null = null;\n    if (e.key === \"ArrowRight\") next = current + 1;\n    else if (e.key === \"ArrowLeft\") next = current - 1;\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = n - 1;\n    if (next === null) return;\n    e.preventDefault();\n    const k = Math.min(Math.max(next, 0), n - 1);\n    go(k, true);\n    if ((e.target as HTMLElement).classList.contains(\"hb-zw3-item\")) itemRefs.current[k]?.focus();\n  };\n\n  const x = dragX !== null ? dragX * 100 : 6 + ((current + 0.5) / n) * 88;\n  const item = list[current];\n\n  return (\n    <div\n      ref={rootRef}\n      role=\"region\"\n      aria-roledescription=\"gallery\"\n      aria-label={label}\n      className={className ? `hb-zw3 ${className}` : \"hb-zw3\"}\n      style={\n        {\n          \"--hb-zw3-accent\": accent,\n          \"--hb-zw3-light\": light,\n          \"--hb-zw3-h\": `${height}px`,\n          \"--hb-zw3-n\": n,\n          ...style,\n        } as React.CSSProperties\n      }\n      onPointerEnter={() => setInside(true)}\n      onPointerLeave={() => setInside(false)}\n      onFocus={() => setFocused(true)}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n      }}\n      onKeyDown={onKeyDown}\n      {...rest}\n    >\n      <style href=\"hb-gallery-backstage\" precedence=\"default\">\n        {css}\n      </style>\n      <div\n        ref={stageRef}\n        className=\"hb-zw3-stage\"\n        data-drag={dragX !== null ? \"true\" : \"false\"}\n        style={{ \"--hb-zw3-x\": `${x.toFixed(2)}%` } as React.CSSProperties}\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n      >\n        <div className=\"hb-zw3-wall\" />\n        <div className=\"hb-zw3-floor\" />\n        <div className=\"hb-zw3-pool\" />\n        {list.map((img, i) => (\n          <button\n            key={i}\n            ref={(el) => {\n              itemRefs.current[i] = el;\n            }}\n            type=\"button\"\n            className=\"hb-zw3-item\"\n            data-on={i === current ? \"true\" : \"false\"}\n            aria-label={img.title}\n            aria-current={i === current ? \"true\" : undefined}\n            tabIndex={i === current ? 0 : -1}\n            style={{ \"--hb-zw3-i\": i, backgroundImage: imageUrl(img.src, i) } as React.CSSProperties}\n            onClick={() => go(i, true)}\n          />\n        ))}\n        <div className=\"hb-zw3-beam\" aria-hidden=\"true\">\n          <div className=\"hb-zw3-cone\" />\n          {motes.map((m, i) => (\n            <span\n              key={i}\n              className=\"hb-zw3-mote\"\n              style={\n                {\n                  left: `${m.left}%`,\n                  top: `${m.top}%`,\n                  width: `${m.size}px`,\n                  height: `${m.size}px`,\n                  \"--hb-zw3-md\": `${m.dur}s`,\n                  \"--hb-zw3-mdl\": `${m.delay}s`,\n                } as React.CSSProperties\n              }\n            />\n          ))}\n          <div className=\"hb-zw3-lamp\" />\n        </div>\n        <div className=\"hb-zw3-cap\" key={current} aria-live=\"polite\">\n          <p className=\"hb-zw3-title\">{item.title}</p>\n          {item.caption ? <p className=\"hb-zw3-sub\">{item.caption}</p> : null}\n        </div>\n        <button\n          type=\"button\"\n          className=\"hb-zw3-arrow hb-zw3-left\"\n          aria-label=\"Previous image\"\n          disabled={current === 0}\n          onClick={() => go(current - 1, true)}\n        >\n          <Chevron dir={-1} />\n        </button>\n        <button\n          type=\"button\"\n          className=\"hb-zw3-arrow hb-zw3-right\"\n          aria-label=\"Next image\"\n          disabled={current === n - 1}\n          onClick={() => go(current + 1, true)}\n        >\n          <Chevron dir={1} />\n        </button>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}