{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"video-player","type":"registry:component","title":"Video player","description":"A hairline video player whose 3px scrubber springs open into a live filmstrip of extracted frames, with chapter micro-gaps, a return-to-spot bookmark and a Bayer buffering veil.","author":"Hairline UI","dependencies":["lucide-react"],"files":[{"path":"registry/video-player.tsx","type":"registry:component","content":"// Hairline UI · video-player · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\nimport {\n  Captions,\n  Maximize,\n  Minimize,\n  Pause,\n  PictureInPicture2,\n  Play,\n  RotateCcw,\n  Undo2,\n  Volume2,\n  VolumeX,\n} from \"lucide-react\";\nimport {\n  EASE_OUT,\n  INTERACTION_FOCUS,\n  INTERACTION_PRESS,\n  createSpring,\n  interactionIcon,\n  useInteractionActivity,\n  useInteractionReducedMotion,\n  type Spring,\n} from \"./ui-interaction-motion\";\nimport { playSound } from \"./ui-sounds\";\n\n/* ─────────────────────────────────────────────────────────\n * VIDEO PLAYER: hairline-to-filmstrip optical video player\n *\n *   scrubber   at rest, a razor-clean 3px hairline segmented by\n *              chapter micro-gaps. Hover or scrub and it springs\n *              open into a live optical filmstrip of the video's\n *              real frames (extracted client-side from a hidden\n *              copy and cached per src, with CORS-safe fallback to\n *              `thumbnails` or an architectural Bayer rail), plus\n *              a magnified preview loupe with chapter & timestamp.\n *\n *   bookmark   jumping more than 2.5s leaves a subtle hairline\n *              notch where you came from and a one-tap return pill\n *              (\"Back to 0:04\") so exploring never loses your spot.\n *\n *   buffering  while loading or buffering, a fine 1.5px 8×8 Bayer\n *              optical veil breathes softly over the stage and\n *              sleeps completely at 0% CPU once frames arrive.\n * ───────────────────────────────────────────────────────── */\n\nexport interface VideoChapter {\n  /** Start timestamp in seconds. */\n  time: number;\n  /** Short chapter name shown on the filmstrip loupe and control bar. */\n  title: string;\n}\n\nexport interface VideoCaption {\n  /** Start timestamp in seconds. */\n  start: number;\n  /** End timestamp in seconds. */\n  end: number;\n  /** Caption text line(s). */\n  text: string;\n}\n\nexport interface VideoPlayerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onTimeUpdate\" | \"onError\"> {\n  /** Video URL (MP4 / WebM). */\n  src: string;\n  /** Optional poster image URL shown before first playback. */\n  poster?: string;\n  /** Chapter markers rendered as hairline gaps along the timeline and named in the scrub loupe. */\n  chapters?: VideoChapter[];\n  /** Inline timed captions rendered above the controls bar. */\n  captions?: VideoCaption[];\n  /** Standard WebVTT (.vtt) captions URL (parsed client-side if CORS permits, plus native <track>). */\n  captionSrc?: string;\n  /** Pre-generated thumbnail image URLs distributed across the timeline (fallback for non-CORS videos). */\n  thumbnails?: string[];\n  /** Number of frames to extract into the client-side filmstrip cache (default 10). */\n  filmstripFrames?: number;\n  /** CSS aspect-ratio for the frame before metadata arrives (default \"16 / 10\"). */\n  aspectRatio?: string;\n  /** Start muted (default false; required by browsers when autoPlay is true). */\n  muted?: boolean;\n  /** Attempt automatic playback on mount (default false). */\n  autoPlay?: boolean;\n  /** Loop playback at end (default false). */\n  loop?: boolean;\n  /** Initial captions visibility when captions are provided (default false). */\n  defaultCaptions?: boolean;\n  /** Accessible title describing the video. */\n  label?: string;\n  /** Opt-in quiet Web Audio ticks on seek, bookmark return and speed change (from ui-sounds.ts). */\n  sound?: boolean;\n  onPlayChange?: (playing: boolean) => void;\n  onTimeChange?: (currentTime: number, duration: number) => void;\n}\n\nconst subscribeNoop = () => () => {};\nconst getPipEnabled = () => typeof document !== \"undefined\" && Boolean(document.pictureInPictureEnabled);\n\nconst SPEEDS = [0.75, 1, 1.25, 1.5, 2] as const;\nconst THUMB_W = 160;\nconst THUMB_H = 100;\n\ntype FrameSource = HTMLCanvasElement | HTMLImageElement;\nconst filmstripCache = new Map<string, FrameSource[]>();\n\nfunction formatClock(seconds: number): string {\n  if (!Number.isFinite(seconds) || seconds < 0) return \"0:00\";\n  const whole = Math.floor(seconds);\n  const h = Math.floor(whole / 3600);\n  const m = Math.floor((whole % 3600) / 60);\n  const s = whole % 60;\n  if (h > 0) return `${h}:${String(m).padStart(2, \"0\")}:${String(s).padStart(2, \"0\")}`;\n  return `${m}:${String(s).padStart(2, \"0\")}`;\n}\n\nfunction parseVttTime(raw: string): number {\n  const parts = raw.trim().replace(\",\", \".\").split(\":\").map(Number);\n  if (parts.some((n) => !Number.isFinite(n))) return 0;\n  if (parts.length === 3) return parts[0] * 3600 + parts[1] * 60 + parts[2];\n  if (parts.length === 2) return parts[0] * 60 + parts[1];\n  return parts[0] ?? 0;\n}\n\nfunction parseVtt(vtt: string): VideoCaption[] {\n  const blocks = vtt.replace(/\\r\\n/g, \"\\n\").split(/\\n{2,}/);\n  const cues: VideoCaption[] = [];\n  for (const block of blocks) {\n    const lines = block.trim().split(\"\\n\");\n    const timeIdx = lines.findIndex((l) => l.includes(\"-->\"));\n    if (timeIdx === -1) continue;\n    const [startRaw, endRaw] = lines[timeIdx].split(\"-->\");\n    const start = parseVttTime(startRaw);\n    const end = parseVttTime((endRaw || \"\").split(/\\s+/)[0] || \"0\");\n    const text = lines\n      .slice(timeIdx + 1)\n      .join(\" \")\n      .replace(/<[^>]+>/g, \"\")\n      .trim();\n    if (text && end > start) cues.push({ start, end, text });\n  }\n  return cues;\n}\n\nfunction isSameOriginUrl(src: string): boolean {\n  if (typeof window === \"undefined\") return true;\n  try {\n    return new URL(src, window.location.href).origin === window.location.origin;\n  } catch {\n    return true;\n  }\n}\n\n/* ── 8×8 Bayer optical buffering veil utilities ── */\n\nconst BAYER8: Float32Array = (() => {\n  const m = [\n    [0, 32, 8, 40, 2, 34, 10, 42],\n    [48, 16, 56, 24, 50, 18, 58, 26],\n    [12, 44, 4, 36, 14, 46, 6, 38],\n    [60, 28, 52, 20, 62, 30, 54, 22],\n    [3, 35, 11, 43, 1, 33, 9, 41],\n    [51, 19, 59, 27, 49, 17, 57, 25],\n    [15, 47, 7, 39, 13, 45, 5, 37],\n    [63, 31, 55, 23, 61, 29, 53, 21],\n  ];\n  const out = new Float32Array(64);\n  for (let y = 0; y < 8; y++) {\n    for (let x = 0; x < 8; x++) {\n      out[(y << 3) | x] = (m[y][x] + 0.5) / 64;\n    }\n  }\n  return out;\n})();\n\nconst IS_LE = (() => {\n  const b = new ArrayBuffer(4);\n  new Uint32Array(b)[0] = 0x0a0b0c0d;\n  return new Uint8Array(b)[0] === 0x0d;\n})();\n\nfunction packRgba(r: number, g: number, b: number, a: number): number {\n  const ri = r < 0 ? 0 : r > 255 ? 255 : r | 0;\n  const gi = g < 0 ? 0 : g > 255 ? 255 : g | 0;\n  const bi = b < 0 ? 0 : b > 255 ? 255 : b | 0;\n  const ai = a < 0 ? 0 : a > 255 ? 255 : a | 0;\n  return IS_LE ? ((ai << 24) | (bi << 16) | (gi << 8) | ri) >>> 0 : ((ri << 24) | (gi << 16) | (bi << 8) | ai) >>> 0;\n}\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\nconst clamp01 = (v: number) => (Number.isFinite(v) ? clamp(v, 0, 1) : 0);\n\nfunction drawCover(ctx: CanvasRenderingContext2D, src: FrameSource, dx: number, dy: number, dw: number, dh: number) {\n  const sw = src instanceof HTMLCanvasElement ? src.width : src.naturalWidth;\n  const sh = src instanceof HTMLCanvasElement ? src.height : src.naturalHeight;\n  if (sw <= 0 || sh <= 0) return;\n  const scale = Math.max(dw / sw, dh / sh);\n  const cw = dw / scale;\n  const ch = dh / scale;\n  const sx = (sw - cw) * 0.5;\n  const sy = (sh - ch) * 0.5;\n  ctx.drawImage(src, sx, sy, cw, ch, dx, dy, dw, dh);\n}\n\nexport function VideoPlayer({\n  src,\n  poster,\n  chapters = [],\n  captions,\n  captionSrc,\n  thumbnails,\n  filmstripFrames = 10,\n  aspectRatio = \"16 / 10\",\n  muted: initialMuted = false,\n  autoPlay = false,\n  loop = false,\n  defaultCaptions = false,\n  label = \"Video player\",\n  sound = false,\n  onPlayChange,\n  onTimeChange,\n  className = \"\",\n  ...props\n}: VideoPlayerProps) {\n  const reduced = useInteractionReducedMotion();\n  const { ref: rootRef, active: onScreen } = useInteractionActivity<HTMLDivElement>();\n\n  const videoRef = React.useRef<HTMLVideoElement>(null);\n  const bufferCanvasRef = React.useRef<HTMLCanvasElement>(null);\n  const railHitRef = React.useRef<HTMLDivElement>(null);\n  const railBoxRef = React.useRef<HTMLDivElement>(null);\n  const filmstripCanvasRef = React.useRef<HTMLCanvasElement>(null);\n  const playedBarRef = React.useRef<HTMLDivElement>(null);\n  const bottomLineRef = React.useRef<HTMLDivElement>(null);\n  const needleRef = React.useRef<HTMLDivElement>(null);\n  const loupeWrapRef = React.useRef<HTMLDivElement>(null);\n  const loupeCanvasRef = React.useRef<HTMLCanvasElement>(null);\n\n  const [playing, setPlaying] = React.useState(false);\n  const [ended, setEnded] = React.useState(false);\n  const [buffering, setBuffering] = React.useState(false);\n  const [ready, setReady] = React.useState(false);\n  const [duration, setDuration] = React.useState(0);\n  const [currentTime, setCurrentTime] = React.useState(0);\n  const [muted, setMuted] = React.useState(initialMuted || autoPlay);\n  const [volume, setVolume] = React.useState(initialMuted || autoPlay ? 0 : 0.85);\n  const [speedIdx, setSpeedIdx] = React.useState(1); // 1x\n  const [captionsOn, setCaptionsOn] = React.useState(defaultCaptions);\n  const [vttCaptions, setVttCaptions] = React.useState<VideoCaption[]>([]);\n  const [fullscreen, setFullscreen] = React.useState(false);\n  const pipSupported = React.useSyncExternalStore(subscribeNoop, getPipEnabled, () => false);\n  const [hudHidden, setHudHidden] = React.useState(false);\n  const hudVisible = !playing || !hudHidden;\n  const [railActive, setRailActive] = React.useState(false);\n  const [scrubTime, setScrubTime] = React.useState<number | null>(null);\n  const [returnBookmark, setReturnBookmark] = React.useState<number | null>(null);\n  const [centerCue, setCenterCue] = React.useState<{ kind: \"play\" | \"pause\" | \"back\" | \"fwd\"; key: number } | null>(null);\n  const [liveStatus, setLiveStatus] = React.useState(\"\");\n\n  const framesRef = React.useRef<FrameSource[]>([]);\n  const scrubbingRef = React.useRef(false);\n  const railHoverRef = React.useRef(false);\n  const controlsHoverRef = React.useRef(false);\n  const hudTimerRef = React.useRef(0);\n  const cueTimerRef = React.useRef(0);\n  const tapHistoryRef = React.useRef<{ time: number; side: \"left\" | \"right\" } | null>(null);\n  const hoverRatioRef = React.useRef(0);\n  const openSpringRef = React.useRef<Spring | null>(null);\n  const durationRef = React.useRef(0);\n  const currentTimeRef = React.useRef(0);\n  const prevSeekStartRef = React.useRef<number | null>(null);\n\n  const sortedChapters = React.useMemo(() => [...chapters].sort((a, b) => a.time - b.time), [chapters]);\n  const allCaptions = React.useMemo(() => (captions?.length ? captions : vttCaptions), [captions, vttCaptions]);\n  const hasCaptions = allCaptions.length > 0;\n\n  // Optional WebVTT fetch for captionSrc\n  React.useEffect(() => {\n    if (!captionSrc || captions?.length) return;\n    let alive = true;\n    fetch(captionSrc)\n      .then((r) => (r.ok ? r.text() : \"\"))\n      .then((txt) => {\n        if (alive && txt) setVttCaptions(parseVtt(txt));\n      })\n      .catch(() => {});\n    return () => {\n      alive = false;\n    };\n  }, [captionSrc, captions]);\n\n  // If the browser finished loading metadata from cache before React hydrated, sync duration via event\n  React.useEffect(() => {\n    const v = videoRef.current;\n    if (v && v.readyState >= 1 && Number.isFinite(v.duration) && v.duration > 0) {\n      v.dispatchEvent(new Event(\"durationchange\"));\n    }\n  }, [src]);\n\n  // Synchronise video playback speed & volume\n  React.useEffect(() => {\n    const v = videoRef.current;\n    if (!v) return;\n    v.playbackRate = SPEEDS[speedIdx];\n  }, [speedIdx]);\n\n  React.useEffect(() => {\n    const v = videoRef.current;\n    if (!v) return;\n    v.muted = muted;\n    v.volume = clamp01(volume);\n  }, [muted, volume]);\n\n  // Helper: active chapter for any timestamp\n  const chapterAt = React.useCallback(\n    (t: number): VideoChapter | null => {\n      if (sortedChapters.length === 0) return null;\n      let active: VideoChapter | null = null;\n      for (const ch of sortedChapters) {\n        if (t >= ch.time - 0.15) active = ch;\n        else break;\n      }\n      return active ?? sortedChapters[0];\n    },\n    [sortedChapters],\n  );\n\n  // Paint the full horizontal optical filmstrip canvas (cached frames + chapter micro-gaps)\n  const paintFilmstrip = React.useCallback(() => {\n    const canvas = filmstripCanvasRef.current;\n    if (!canvas) return;\n    const rect = canvas.getBoundingClientRect();\n    const w = Math.round(rect.width);\n    const h = 38;\n    if (w <= 0) return;\n    const dpr = Math.min(2, window.devicePixelRatio || 1);\n    if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)) {\n      canvas.width = Math.round(w * dpr);\n      canvas.height = Math.round(h * dpr);\n    }\n    const ctx = canvas.getContext(\"2d\");\n    if (!ctx) return;\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.clearRect(0, 0, w, h);\n\n    const frames = framesRef.current;\n    if (frames.length > 0) {\n      const tileW = w / frames.length;\n      for (let i = 0; i < frames.length; i++) {\n        drawCover(ctx, frames[i], i * tileW, 0, tileW + 0.6, h);\n      }\n      // Subtle top/bottom cinematic frame vignette\n      const grad = ctx.createLinearGradient(0, 0, 0, h);\n      grad.addColorStop(0, \"rgba(0,0,0,0.22)\");\n      grad.addColorStop(0.5, \"rgba(0,0,0,0.04)\");\n      grad.addColorStop(1, \"rgba(0,0,0,0.28)\");\n      ctx.fillStyle = grad;\n      ctx.fillRect(0, 0, w, h);\n    } else {\n      // Crisp architectural Bayer fallback strip (while frames extract or on non-CORS CDNs)\n      ctx.fillStyle = \"rgba(24, 24, 27, 0.9)\";\n      ctx.fillRect(0, 0, w, h);\n      ctx.fillStyle = \"rgba(255, 255, 255, 0.14)\";\n      for (let y = 3; y < h - 2; y += 4) {\n        for (let x = 2; x < w - 2; x += 4) {\n          const b = BAYER8[(((y >> 2) & 7) << 3) | ((x >> 2) & 7)];\n          if (b < 0.35 + 0.25 * Math.sin(x * 0.03)) ctx.fillRect(x, y, 1.5, 1.5);\n        }\n      }\n    }\n\n    // Dim the unplayed portion slightly so current progress reads immediately inside the filmstrip\n    const dur = durationRef.current;\n    const ratio = dur > 0 ? clamp01(currentTimeRef.current / dur) : 0;\n    const playedX = ratio * w;\n    if (playedX < w) {\n      ctx.fillStyle = \"rgba(9, 9, 11, 0.44)\";\n      ctx.fillRect(playedX, 0, w - playedX, h);\n    }\n\n    // Crisp hairline white played indicator line\n    ctx.fillStyle = \"rgba(255, 255, 255, 0.92)\";\n    ctx.fillRect(Math.max(0, playedX - 1), 0, 2, h);\n\n    // Chapter boundary micro-gaps\n    if (dur > 0 && sortedChapters.length > 1) {\n      ctx.fillStyle = \"rgba(9, 9, 11, 0.92)\";\n      for (let i = 1; i < sortedChapters.length; i++) {\n        const cx = clamp01(sortedChapters[i].time / dur) * w;\n        ctx.fillRect(Math.round(cx) - 1, 0, 2, h);\n      }\n    }\n  }, [sortedChapters]);\n\n  // Paint the magnified preview still inside the floating scrub loupe\n  const paintLoupe = React.useCallback((ratio: number) => {\n    const canvas = loupeCanvasRef.current;\n    if (!canvas) return;\n    const dpr = Math.min(2, window.devicePixelRatio || 1);\n    if (canvas.width !== Math.round(THUMB_W * dpr) || canvas.height !== Math.round(THUMB_H * dpr)) {\n      canvas.width = Math.round(THUMB_W * dpr);\n      canvas.height = Math.round(THUMB_H * dpr);\n    }\n    const ctx = canvas.getContext(\"2d\");\n    if (!ctx) return;\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.fillStyle = \"#09090b\";\n    ctx.fillRect(0, 0, THUMB_W, THUMB_H);\n\n    const frames = framesRef.current;\n    if (frames.length > 0) {\n      const idx = clamp(Math.round(ratio * (frames.length - 1)), 0, frames.length - 1);\n      drawCover(ctx, frames[idx], 0, 0, THUMB_W, THUMB_H);\n    } else if (videoRef.current && videoRef.current.readyState >= 2) {\n      try {\n        ctx.drawImage(videoRef.current, 0, 0, THUMB_W, THUMB_H);\n      } catch {\n        // Non-CORS video: keep sleek dark still frame\n      }\n    }\n  }, []);\n\n  // Client-side filmstrip frame extraction (runs on a hidden copy, cached per src; CORS-safe fallback to `thumbnails`)\n  React.useEffect(() => {\n    let cancelled = false;\n\n    const cacheKey = thumbnails?.length ? `thumbs:${thumbnails.join(\"|\")}` : `video:${src}:${filmstripFrames}`;\n    const cached = filmstripCache.get(cacheKey);\n    if (cached && cached.length > 0) {\n      framesRef.current = cached;\n      paintFilmstrip();\n      return;\n    }\n\n    framesRef.current = [];\n    paintFilmstrip();\n\n    // Path A: Caller supplied thumbnail URLs (ideal for non-CORS CDNs)\n    if (thumbnails && thumbnails.length > 0) {\n      const loaded: FrameSource[] = [];\n      let done = 0;\n      thumbnails.forEach((url, idx) => {\n        const img = new Image();\n        img.decoding = \"async\";\n        img.onload = () => {\n          if (cancelled) return;\n          loaded[idx] = img;\n          done++;\n          if (done === thumbnails.length) {\n            const clean = loaded.filter(Boolean);\n            framesRef.current = clean;\n            filmstripCache.set(cacheKey, clean);\n            paintFilmstrip();\n          }\n        };\n        img.onerror = () => {\n          done++;\n        };\n        img.src = url;\n      });\n      return () => {\n        cancelled = true;\n      };\n    }\n\n    // Path B: Extract real frames sequentially from a detached hidden <video>\n    const count = clamp(filmstripFrames, 6, 16);\n    const probe = document.createElement(\"video\");\n    probe.muted = true;\n    probe.playsInline = true;\n    probe.preload = \"auto\";\n    if (!isSameOriginUrl(src)) probe.crossOrigin = \"anonymous\";\n\n    const cleanupProbe = () => {\n      probe.pause();\n      probe.removeAttribute(\"src\");\n      probe.load();\n    };\n\n    const extract = async () => {\n      try {\n        await new Promise<void>((resolve, reject) => {\n          probe.onloadeddata = () => resolve();\n          probe.onerror = () => reject(new Error(\"probe load failed\"));\n          probe.src = src;\n        });\n        if (cancelled) return;\n        const dur = probe.duration;\n        if (!Number.isFinite(dur) || dur <= 0) return;\n\n        const collected: FrameSource[] = [];\n        for (let i = 0; i < count; i++) {\n          if (cancelled) return;\n          const targetT = count === 1 ? dur * 0.5 : (i / (count - 1)) * Math.max(0.05, dur - 0.14) + 0.06;\n          await new Promise<void>((resolve) => {\n            const done = () => {\n              window.clearTimeout(timer);\n              probe.removeEventListener(\"seeked\", done);\n              resolve();\n            };\n            const timer = window.setTimeout(done, 1500);\n            probe.addEventListener(\"seeked\", done, { once: true });\n            try {\n              probe.currentTime = clamp(targetT, 0, Math.max(0, dur - 0.05));\n            } catch {\n              done();\n            }\n          });\n          if (cancelled) return;\n\n          const tile = document.createElement(\"canvas\");\n          tile.width = THUMB_W;\n          tile.height = THUMB_H;\n          const tctx = tile.getContext(\"2d\");\n          if (!tctx) continue;\n\n          // Verify pixel readability (throws SecurityError on tainted cross-origin stream -> clean fallback)\n          const vw = probe.videoWidth || THUMB_W;\n          const vh = probe.videoHeight || THUMB_H;\n          const scale = Math.max(THUMB_W / vw, THUMB_H / vh);\n          const cw = THUMB_W / scale;\n          const ch = THUMB_H / scale;\n          tctx.drawImage(probe, (vw - cw) * 0.5, (vh - ch) * 0.5, cw, ch, 0, 0, THUMB_W, THUMB_H);\n          if (i === 0) tctx.getImageData(0, 0, 1, 1);\n\n          collected.push(tile);\n          framesRef.current = [...collected];\n          if (i === 0 || i === count - 1) paintFilmstrip();\n        }\n        if (!cancelled && collected.length > 0) {\n          filmstripCache.set(cacheKey, collected);\n          paintFilmstrip();\n        }\n      } catch {\n        // Cross-origin without CORS: stay cleanly on architectural Bayer rail with zero console noise\n      } finally {\n        cleanupProbe();\n      }\n    };\n\n    void extract();\n    return () => {\n      cancelled = true;\n      cleanupProbe();\n    };\n  }, [src, thumbnails, filmstripFrames, paintFilmstrip]);\n\n  React.useEffect(() => {\n    const el = railHitRef.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => paintFilmstrip());\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [paintFilmstrip]);\n\n  // Spring driving the signature Hairline (3px) <-> Optical Filmstrip (38px) expansion + Loupe reveal\n  React.useEffect(() => {\n    const applyOpen = (v: number) => {\n      const open = clamp01(v);\n      const box = railBoxRef.current;\n      const strip = filmstripCanvasRef.current;\n      const bar = playedBarRef.current;\n      const loupe = loupeWrapRef.current;\n      if (box) {\n        const h = 3 + open * 35;\n        box.style.height = `${h.toFixed(2)}px`;\n        box.style.borderRadius = `${(999 * (1 - Math.min(1, open * 4)) + 8 * Math.min(1, open * 4)).toFixed(1)}px`;\n        box.style.borderColor = `rgba(255, 255, 255, ${(open * 0.18).toFixed(3)})`;\n      }\n      if (strip) strip.style.opacity = open.toFixed(3);\n      if (bar) bar.style.opacity = clamp01(1 - open * 2.2).toFixed(3);\n      if (loupe) {\n        loupe.style.opacity = open.toFixed(3);\n        loupe.style.transform = `translate3d(-50%, ${((1 - open) * 6).toFixed(2)}px, 0) scale(${(0.95 + open * 0.05).toFixed(3)})`;\n      }\n    };\n\n    const spring = createSpring(0, { stiffness: 270, damping: 24 }, () => applyOpen(spring.get()), 0.002);\n    openSpringRef.current = spring;\n    applyOpen(0);\n    return () => {\n      spring.stop();\n      openSpringRef.current = null;\n    };\n  }, []);\n\n  React.useEffect(() => {\n    const sp = openSpringRef.current;\n    if (!sp) return;\n    if (railActive) paintFilmstrip();\n    if (reduced) sp.jump(railActive ? 1 : 0);\n    else sp.set(railActive ? 1 : 0);\n  }, [railActive, reduced, paintFilmstrip]);\n\n  // Optical 8×8 Bayer buffering veil (sleeps completely at 0% CPU when not buffering!)\n  React.useEffect(() => {\n    const canvas = bufferCanvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!canvas || !ctx || !onScreen || reduced || !buffering) {\n      if (canvas && ctx) ctx.clearRect(0, 0, canvas.width, canvas.height);\n      return;\n    }\n\n    const gridCanvas = document.createElement(\"canvas\");\n    const gridCtx = gridCanvas.getContext(\"2d\");\n    if (!gridCtx) return;\n\n    let raf = 0;\n    let time = 0;\n    let last = 0;\n    let gCols = 0;\n    let gRows = 0;\n    let gridImg: ImageData | null = null;\n    let gridU32: Uint32Array | null = null;\n\n    const tick = (now: number) => {\n      const dt = last ? Math.min(1 / 24, (now - last) / 1000) : 1 / 60;\n      last = now;\n      time += dt;\n\n      const rect = canvas.getBoundingClientRect();\n      const w = Math.round(rect.width);\n      const h = Math.round(rect.height);\n      if (w > 0 && h > 0) {\n        const dpr = Math.min(2, window.devicePixelRatio || 1);\n        if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)) {\n          canvas.width = Math.round(w * dpr);\n          canvas.height = Math.round(h * dpr);\n        }\n        const pitch = 3;\n        const cols = Math.max(1, Math.ceil(w / pitch));\n        const rows = Math.max(1, Math.ceil(h / pitch));\n        if (cols !== gCols || rows !== gRows || !gridImg || !gridU32) {\n          gCols = cols;\n          gRows = rows;\n          gridCanvas.width = cols;\n          gridCanvas.height = rows;\n          gridImg = gridCtx.createImageData(cols, rows);\n          gridU32 = new Uint32Array(gridImg.data.buffer);\n        }\n        const u32 = gridU32;\n        u32.fill(0);\n        const scanU = ((time * 0.72) % 1.4) - 0.2;\n        for (let r = 0; r < rows; r++) {\n          const v = (r + 0.5) / rows;\n          const bRow = (r & 7) << 3;\n          const rowOff = r * cols;\n          for (let c = 0; c < cols; c++) {\n            const u = (c + 0.5) / cols;\n            const d = u - scanU;\n            const band = Math.exp(-(d * d) / 0.032);\n            const sheen = 0.14 + 0.12 * Math.sin(u * 5 + v * 3 + time * 1.4) + band * 0.42;\n            const bayer = BAYER8[bRow | (c & 7)];\n            const hit = clamp01((sheen - bayer + 0.05) / 0.14);\n            if (hit > 0.02) {\n              const alpha = hit * (0.28 + band * 0.46) * 255;\n              u32[rowOff + c] = packRgba(220, 228, 244, alpha);\n            }\n          }\n        }\n        gridCtx.putImageData(gridImg, 0, 0);\n        ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n        ctx.clearRect(0, 0, w, h);\n        ctx.imageSmoothingEnabled = false;\n        ctx.drawImage(gridCanvas, 0, 0, cols * pitch, rows * pitch);\n      }\n      raf = requestAnimationFrame(tick);\n    };\n\n    raf = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(raf);\n      ctx.clearRect(0, 0, canvas.width, canvas.height);\n    };\n  }, [buffering, onScreen, reduced]);\n\n  // Smooth 60fps direct-DOM playhead sync while playing (zero React state churn per frame!)\n  const syncProgressDom = React.useCallback(\n    (t: number, dur: number) => {\n      currentTimeRef.current = t;\n      durationRef.current = dur;\n      const pct = dur > 0 ? clamp01(t / dur) * 100 : 0;\n      if (playedBarRef.current) playedBarRef.current.style.width = `${pct.toFixed(3)}%`;\n      if (bottomLineRef.current) bottomLineRef.current.style.width = `${pct.toFixed(3)}%`;\n      if (railHoverRef.current || scrubbingRef.current) paintFilmstrip();\n    },\n    [paintFilmstrip],\n  );\n\n  React.useEffect(() => {\n    if (!playing || !onScreen) return;\n    let raf = 0;\n    const step = () => {\n      const v = videoRef.current;\n      if (v) syncProgressDom(v.currentTime, v.duration || durationRef.current);\n      raf = requestAnimationFrame(step);\n    };\n    raf = requestAnimationFrame(step);\n    return () => cancelAnimationFrame(raf);\n  }, [playing, onScreen, syncProgressDom]);\n\n  // HUD auto-hide timer while playing (derived: always visible when paused, fades after 2.4s idle during playback)\n  const bumpHud = React.useCallback(\n    (keepOpen = false) => {\n      setHudHidden(false);\n      window.clearTimeout(hudTimerRef.current);\n      if (keepOpen || !playing || controlsHoverRef.current || scrubbingRef.current) return;\n      hudTimerRef.current = window.setTimeout(() => {\n        if (!controlsHoverRef.current && !scrubbingRef.current) setHudHidden(true);\n      }, 2400);\n    },\n    [playing],\n  );\n\n  React.useEffect(() => {\n    window.clearTimeout(hudTimerRef.current);\n    if (!playing) return;\n    hudTimerRef.current = window.setTimeout(() => {\n      if (!controlsHoverRef.current && !scrubbingRef.current) setHudHidden(true);\n    }, 2400);\n    return () => window.clearTimeout(hudTimerRef.current);\n  }, [playing]);\n\n  // Fullscreen listener\n  React.useEffect(() => {\n    const onFs = () => setFullscreen(document.fullscreenElement === rootRef.current);\n    document.addEventListener(\"fullscreenchange\", onFs);\n    return () => document.removeEventListener(\"fullscreenchange\", onFs);\n  }, [rootRef]);\n\n  const flashCenterCue = React.useCallback((kind: \"play\" | \"pause\" | \"back\" | \"fwd\") => {\n    setCenterCue({ kind, key: Date.now() });\n    window.clearTimeout(cueTimerRef.current);\n    cueTimerRef.current = window.setTimeout(() => setCenterCue(null), 540);\n  }, []);\n\n  React.useEffect(() => () => window.clearTimeout(cueTimerRef.current), []);\n\n  const togglePlay = React.useCallback(\n    (showCue = false) => {\n      const v = videoRef.current;\n      if (!v) return;\n      if (v.paused || v.ended) {\n        if (v.ended) v.currentTime = 0;\n        void v.play().catch(() => {});\n        if (showCue) flashCenterCue(\"play\");\n      } else {\n        v.pause();\n        if (showCue) flashCenterCue(\"pause\");\n      }\n      bumpHud();\n    },\n    [flashCenterCue, bumpHud],\n  );\n\n  const seekTo = React.useCallback(\n    (targetTime: number, recordBookmark = true) => {\n      const v = videoRef.current;\n      const dur = v?.duration || durationRef.current;\n      if (!v || !Number.isFinite(dur) || dur <= 0) return;\n      const clamped = clamp(targetTime, 0, dur);\n      if (recordBookmark && Math.abs(clamped - v.currentTime) >= 2.5) {\n        setReturnBookmark(v.currentTime);\n      }\n      v.currentTime = clamped;\n      setCurrentTime(clamped);\n      syncProgressDom(clamped, dur);\n      if (ended && clamped < dur - 0.1) setEnded(false);\n    },\n    [ended, syncProgressDom],\n  );\n\n  const jumpBackToBookmark = React.useCallback(() => {\n    if (returnBookmark === null) return;\n    const target = returnBookmark;\n    setReturnBookmark(null);\n    seekTo(target, false);\n    if (sound) playSound(\"pop\", 0.32);\n    setLiveStatus(`Returned to ${formatClock(target)}`);\n  }, [returnBookmark, seekTo, sound]);\n\n  const cycleSpeed = React.useCallback(() => {\n    setSpeedIdx((i) => {\n      const next = (i + 1) % SPEEDS.length;\n      if (sound) playSound(\"tick\", 0.3);\n      setLiveStatus(`Playback speed ${SPEEDS[next]}x`);\n      return next;\n    });\n  }, [sound]);\n\n  const toggleFullscreen = React.useCallback(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    if (document.fullscreenElement === el) {\n      void document.exitFullscreen?.().catch(() => {});\n    } else {\n      void el.requestFullscreen?.().catch(() => {});\n    }\n  }, [rootRef]);\n\n  const togglePiP = React.useCallback(() => {\n    const v = videoRef.current;\n    if (!v || !document.pictureInPictureEnabled) return;\n    if (document.pictureInPictureElement === v) {\n      void document.exitPictureInPicture?.().catch(() => {});\n    } else {\n      void v.requestPictureInPicture?.().catch(() => {});\n    }\n  }, []);\n\n  // Scrubber pointer position -> loupe position & frame preview\n  const updateHoverFromClientX = React.useCallback(\n    (clientX: number) => {\n      const el = railHitRef.current;\n      const dur = durationRef.current || videoRef.current?.duration || 0;\n      if (!el || dur <= 0) return 0;\n      const rect = el.getBoundingClientRect();\n      const ratio = clamp01((clientX - rect.left) / Math.max(1, rect.width));\n      hoverRatioRef.current = ratio;\n      const t = ratio * dur;\n      setScrubTime(t);\n\n      // Position hover needle & clamped loupe directly via DOM for zero-lag 60fps tracking\n      if (needleRef.current) {\n        needleRef.current.style.left = `${(ratio * 100).toFixed(3)}%`;\n        needleRef.current.style.opacity = \"1\";\n      }\n      if (loupeWrapRef.current) {\n        const half = THUMB_W * 0.5 + 4;\n        const clampedX = clamp(ratio * rect.width, half, Math.max(half, rect.width - half));\n        loupeWrapRef.current.style.left = `${clampedX.toFixed(1)}px`;\n      }\n      paintLoupe(ratio);\n      return t;\n    },\n    [paintLoupe],\n  );\n\n  const handleRailPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {\n    railHoverRef.current = true;\n    setRailActive(true);\n    const t = updateHoverFromClientX(e.clientX);\n    if (scrubbingRef.current) {\n      seekTo(t, false);\n    }\n  };\n\n  const handleRailPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (e.button !== 0) return;\n    e.currentTarget.setPointerCapture(e.pointerId);\n    scrubbingRef.current = true;\n    prevSeekStartRef.current = videoRef.current?.currentTime ?? currentTimeRef.current;\n    setRailActive(true);\n    const t = updateHoverFromClientX(e.clientX);\n    seekTo(t, false);\n    if (sound) playSound(\"tick\", 0.28);\n  };\n\n  const handleRailPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (!scrubbingRef.current) return;\n    scrubbingRef.current = false;\n    if (e.currentTarget.hasPointerCapture(e.pointerId)) {\n      e.currentTarget.releasePointerCapture(e.pointerId);\n    }\n    const startT = prevSeekStartRef.current;\n    const endT = videoRef.current?.currentTime ?? currentTimeRef.current;\n    if (startT !== null && Math.abs(endT - startT) >= 2.5) {\n      setReturnBookmark(startT);\n    }\n    prevSeekStartRef.current = null;\n    if (!railHoverRef.current) {\n      setRailActive(false);\n      setScrubTime(null);\n      if (needleRef.current) needleRef.current.style.opacity = \"0\";\n    }\n    bumpHud();\n  };\n\n  const handleRailPointerLeave = () => {\n    railHoverRef.current = false;\n    if (!scrubbingRef.current) {\n      setRailActive(false);\n      setScrubTime(null);\n      if (needleRef.current) needleRef.current.style.opacity = \"0\";\n    }\n  };\n\n  // Stage tap / double-tap skip on touch\n  const handleStageClick = (e: React.MouseEvent<HTMLDivElement>) => {\n    if ((e.target as HTMLElement).closest(\"[data-vp-controls]\")) return;\n    const now = Date.now();\n    const rect = e.currentTarget.getBoundingClientRect();\n    const relX = (e.clientX - rect.left) / Math.max(1, rect.width);\n    const side: \"left\" | \"right\" | null = relX < 0.28 ? \"left\" : relX > 0.72 ? \"right\" : null;\n\n    if (side && tapHistoryRef.current && tapHistoryRef.current.side === side && now - tapHistoryRef.current.time < 320) {\n      tapHistoryRef.current = null;\n      const delta = side === \"left\" ? -10 : 10;\n      seekTo(currentTimeRef.current + delta, true);\n      flashCenterCue(side === \"left\" ? \"back\" : \"fwd\");\n      if (sound) playSound(\"tick\", 0.3);\n      return;\n    }\n    if (side) tapHistoryRef.current = { time: now, side };\n    togglePlay(true);\n  };\n\n  // Full keyboard navigation (J/K/L, Space, arrows, M, C, F, B, 0-9)\n  const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    const tag = (e.target as HTMLElement).tagName;\n    if (tag === \"INPUT\" || tag === \"TEXTAREA\") return;\n    const key = e.key.toLowerCase();\n\n    if (key === \" \" || key === \"k\") {\n      e.preventDefault();\n      togglePlay(true);\n    } else if (key === \"j\") {\n      e.preventDefault();\n      seekTo(currentTimeRef.current - 10, true);\n      flashCenterCue(\"back\");\n    } else if (key === \"l\") {\n      e.preventDefault();\n      seekTo(currentTimeRef.current + 10, true);\n      flashCenterCue(\"fwd\");\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      seekTo(currentTimeRef.current - 5, true);\n      flashCenterCue(\"back\");\n    } else if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      seekTo(currentTimeRef.current + 5, true);\n      flashCenterCue(\"fwd\");\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault();\n      setMuted(false);\n      setVolume((v) => clamp01(v + 0.1));\n      bumpHud();\n    } else if (e.key === \"ArrowDown\") {\n      e.preventDefault();\n      setVolume((v) => {\n        const next = clamp01(v - 0.1);\n        if (next === 0) setMuted(true);\n        return next;\n      });\n      bumpHud();\n    } else if (key === \"m\") {\n      e.preventDefault();\n      setMuted((m) => !m);\n      bumpHud();\n    } else if (key === \"c\" && hasCaptions) {\n      e.preventDefault();\n      setCaptionsOn((c) => !c);\n      bumpHud();\n    } else if (key === \"f\") {\n      e.preventDefault();\n      toggleFullscreen();\n    } else if (key === \"b\" && returnBookmark !== null) {\n      e.preventDefault();\n      jumpBackToBookmark();\n    } else if (e.key >= \"0\" && e.key <= \"9\" && durationRef.current > 0) {\n      e.preventDefault();\n      seekTo((Number(e.key) / 10) * durationRef.current, true);\n      bumpHud();\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      seekTo(0, true);\n      bumpHud();\n    } else if (e.key === \"End\" && durationRef.current > 0) {\n      e.preventDefault();\n      seekTo(durationRef.current, true);\n      bumpHud();\n    } else if (e.key === \">\") {\n      e.preventDefault();\n      setSpeedIdx((i) => Math.min(SPEEDS.length - 1, i + 1));\n      bumpHud();\n    } else if (e.key === \"<\") {\n      e.preventDefault();\n      setSpeedIdx((i) => Math.max(0, i - 1));\n      bumpHud();\n    }\n  };\n\n  const activeChapter = chapterAt(currentTime);\n  const loupeChapter = scrubTime !== null ? chapterAt(scrubTime) : activeChapter;\n  const activeCaption = React.useMemo(() => {\n    if (!captionsOn || !hasCaptions) return null;\n    return allCaptions.find((c) => currentTime >= c.start && currentTime <= c.end)?.text ?? null;\n  }, [captionsOn, hasCaptions, allCaptions, currentTime]);\n\n  const bookmarkPct = returnBookmark !== null && duration > 0 ? clamp01(returnBookmark / duration) * 100 : null;\n\n  return (\n    <div\n      ref={rootRef}\n      role=\"region\"\n      aria-label={label}\n      tabIndex={0}\n      onKeyDown={handleKeyDown}\n      onPointerMove={() => bumpHud()}\n      onPointerLeave={() => {\n        if (playing && !scrubbingRef.current) setHudHidden(true);\n      }}\n      onClick={handleStageClick}\n      className={`group relative w-full overflow-hidden rounded-[16px] border border-border bg-zinc-950 text-white shadow-[inset_0_0.5px_0_rgb(255_255_255/0.12)] select-none ${INTERACTION_FOCUS} ${className}`}\n      style={{ aspectRatio }}\n      {...props}\n    >\n      {/* Native HTML5 video surface */}\n      <video\n        ref={videoRef}\n        src={src}\n        poster={poster}\n        muted={muted}\n        autoPlay={autoPlay}\n        loop={loop}\n        playsInline\n        preload=\"metadata\"\n        onLoadedMetadata={(e) => {\n          const v = e.currentTarget;\n          const dur = Number.isFinite(v.duration) ? v.duration : 0;\n          setDuration(dur);\n          durationRef.current = dur;\n          setReady(true);\n          syncProgressDom(v.currentTime, dur);\n          paintFilmstrip();\n        }}\n        onDurationChange={(e) => {\n          const v = e.currentTarget;\n          const dur = Number.isFinite(v.duration) ? v.duration : 0;\n          if (dur > 0) {\n            setDuration(dur);\n            durationRef.current = dur;\n            setReady(true);\n            syncProgressDom(v.currentTime, dur);\n            paintFilmstrip();\n          }\n        }}\n        onCanPlay={() => {\n          setReady(true);\n          setBuffering(false);\n        }}\n        onWaiting={() => setBuffering(true)}\n        onPlaying={() => {\n          setBuffering(false);\n          setPlaying(true);\n          setEnded(false);\n          onPlayChange?.(true);\n        }}\n        onPause={() => {\n          setPlaying(false);\n          onPlayChange?.(false);\n        }}\n        onEnded={() => {\n          setPlaying(false);\n          setEnded(true);\n          onPlayChange?.(false);\n        }}\n        onTimeUpdate={(e) => {\n          const v = e.currentTarget;\n          setCurrentTime(v.currentTime);\n          syncProgressDom(v.currentTime, v.duration || durationRef.current);\n          onTimeChange?.(v.currentTime, v.duration || durationRef.current);\n        }}\n        className=\"h-full w-full cursor-pointer object-cover\"\n      >\n        {captionSrc ? <track kind=\"captions\" src={captionSrc} label=\"Captions\" /> : null}\n      </video>\n\n      {/* Optical 8×8 Bayer buffering veil (0% CPU when not buffering) */}\n      <canvas\n        ref={bufferCanvasRef}\n        aria-hidden=\"true\"\n        className={`pointer-events-none absolute inset-0 z-10 h-full w-full transition-opacity duration-300 ${\n          buffering ? \"opacity-100\" : \"opacity-0\"\n        }`}\n      />\n\n      {/* Initial resting Play pill (only when paused at 0:00 before playback or ended; yields cleanly when scrub loupe opens) */}\n      {!playing && (currentTime < 0.05 || ended) && (\n        <div\n          className={`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/15 transition-opacity duration-200 ${\n            railActive ? \"opacity-0\" : \"opacity-100\"\n          }`}\n        >\n          <span\n            aria-hidden=\"true\"\n            className=\"flex size-13 items-center justify-center rounded-full border border-white/20 bg-zinc-950/75 text-white shadow-[0_8px_28px_rgb(0_0_0/0.45),inset_0_0.5px_0_rgb(255_255_255/0.25)] backdrop-blur-md transition-transform duration-200 group-hover:scale-105\"\n          >\n            {ended ? <RotateCcw className=\"size-5\" strokeWidth={2} /> : <Play className=\"ml-0.5 size-5 fill-current\" strokeWidth={1.8} />}\n          </span>\n        </div>\n      )}\n\n      {/* Brief center optical feedback cue on click / J / L skip */}\n      {centerCue && !reduced && (\n        <div\n          key={centerCue.key}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0 z-20 flex items-center justify-center\"\n        >\n          <span className=\"flex h-11 min-w-11 items-center justify-center rounded-full border border-white/15 bg-zinc-950/70 px-3 text-[12px] font-medium tracking-tight text-white/95 backdrop-blur-md\">\n            {centerCue.kind === \"play\" ? (\n              <Play className=\"ml-0.5 size-4 fill-current\" />\n            ) : centerCue.kind === \"pause\" ? (\n              <Pause className=\"size-4 fill-current\" />\n            ) : centerCue.kind === \"back\" ? (\n              \"-10s\"\n            ) : (\n              \"+10s\"\n            )}\n          </span>\n        </div>\n      )}\n\n      {/* Live captions pill (fades cleanly out of the way while the magnified scrub loupe is active) */}\n      {activeCaption && (\n        <div\n          className=\"pointer-events-none absolute inset-x-4 z-20 flex justify-center\"\n          style={{\n            bottom: hudVisible ? \"68px\" : \"24px\",\n            opacity: railActive ? 0 : 1,\n            transition: reduced ? \"none\" : `bottom 220ms ${EASE_OUT}, opacity 180ms ${EASE_OUT}`,\n          }}\n        >\n          <p className=\"max-w-[82%] rounded-[9px] border border-white/12 bg-zinc-950/82 px-3 py-1.5 text-center text-[13px] leading-snug text-white/95 backdrop-blur-md\">\n            {activeCaption}\n          </p>\n        </div>\n      )}\n\n      {/* Ultra-minimal 2px bottom progress whisper when HUD hides during playback */}\n      <div\n        aria-hidden=\"true\"\n        className={`pointer-events-none absolute inset-x-0 bottom-0 z-10 h-[2px] bg-white/12 transition-opacity duration-300 ${\n          hudVisible ? \"opacity-0\" : \"opacity-100\"\n        }`}\n      >\n        <div ref={bottomLineRef} className=\"h-full bg-white/85\" style={{ width: \"0%\" }} />\n      </div>\n\n      {/* Hairline optical HUD */}\n      <div\n        data-vp-controls=\"true\"\n        onPointerEnter={() => {\n          controlsHoverRef.current = true;\n          bumpHud(true);\n        }}\n        onPointerLeave={() => {\n          controlsHoverRef.current = false;\n          bumpHud();\n        }}\n        className={`absolute inset-x-0 bottom-0 z-20 bg-gradient-to-t from-black/82 via-black/48 to-transparent px-3.5 pb-3 pt-10 ${\n          hudVisible ? \"opacity-100 translate-y-0\" : \"pointer-events-none opacity-0 translate-y-1.5\"\n        }`}\n        style={{ transition: reduced ? \"none\" : `opacity 220ms ${EASE_OUT}, transform 240ms ${EASE_OUT}` }}\n      >\n        {/* Signature Hairline-to-Filmstrip Scrubber */}\n        <div\n          ref={railHitRef}\n          role=\"slider\"\n          tabIndex={0}\n          aria-label=\"Seek timeline\"\n          aria-valuemin={0}\n          aria-valuemax={Math.round(duration)}\n          aria-valuenow={Math.round(currentTime)}\n          aria-valuetext={`${formatClock(currentTime)} of ${formatClock(duration)}${activeChapter ? `, ${activeChapter.title}` : \"\"}`}\n          data-filmstrip-open={railActive ? \"true\" : \"false\"}\n          onPointerMove={handleRailPointerMove}\n          onPointerDown={handleRailPointerDown}\n          onPointerUp={handleRailPointerUp}\n          onPointerCancel={handleRailPointerUp}\n          onPointerLeave={handleRailPointerLeave}\n          className=\"relative mb-2.5 flex cursor-pointer items-end pt-4 pb-1 touch-none\"\n        >\n          {/* Floating Magnified Scrub Loupe (real frame + chapter title + timestamp) */}\n          <div\n            ref={loupeWrapRef}\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute bottom-[48px] z-30 overflow-hidden rounded-[10px] border border-white/18 bg-zinc-950 shadow-[0_10px_28px_rgb(0_0_0/0.6)]\"\n            style={{ width: `${THUMB_W}px`, left: `${THUMB_W * 0.5 + 4}px`, opacity: 0 }}\n          >\n            <canvas ref={loupeCanvasRef} className=\"block h-[94px] w-full bg-zinc-900\" />\n            <div className=\"flex items-center justify-between gap-2 border-t border-white/10 bg-zinc-950/95 px-2.5 py-1.5\">\n              <span className=\"min-w-0 truncate text-[11px] font-medium text-white/85\">\n                {loupeChapter?.title ?? \"Preview\"}\n              </span>\n              <span className=\"shrink-0 font-mono text-[11px] tabular-nums text-white/65\">\n                {formatClock(scrubTime ?? currentTime)}\n              </span>\n            </div>\n          </div>\n\n          {/* Hairline rail -> springs vertically into 38px optical filmstrip */}\n          <div\n            ref={railBoxRef}\n            className=\"relative w-full overflow-hidden border border-transparent bg-white/22\"\n            style={{ height: \"3px\", borderRadius: \"999px\" }}\n          >\n            {/* Extracted frames horizontal strip (fades in as rail springs open) */}\n            <canvas\n              ref={filmstripCanvasRef}\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute inset-0 h-[38px] w-full\"\n              style={{ opacity: 0 }}\n            />\n\n            {/* Hairline played progress bar (visible at rest; fades cleanly into filmstrip playhead) */}\n            <div ref={playedBarRef} className=\"pointer-events-none absolute inset-y-0 left-0 bg-white\" style={{ width: \"0%\" }} />\n\n            {/* Chapter micro-gaps on the resting 3px hairline */}\n            {duration > 0 &&\n              sortedChapters.slice(1).map((ch) => (\n                <span\n                  key={ch.time}\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute inset-y-0 w-[2px] -translate-x-1/2 bg-zinc-950\"\n                  style={{ left: `${clamp01(ch.time / duration) * 100}%` }}\n                />\n              ))}\n\n            {/* Return-to-previous-spot bookmark notch */}\n            {bookmarkPct !== null && (\n              <span\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute inset-y-0 z-10 w-[2px] -translate-x-1/2 bg-amber-300 shadow-[0_0_6px_rgb(252_211_77/0.7)]\"\n                style={{ left: `${bookmarkPct}%` }}\n              />\n            )}\n\n            {/* Hover scrub needle */}\n            <div\n              ref={needleRef}\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute inset-y-0 z-20 w-[2px] -translate-x-1/2 bg-white shadow-[0_0_8px_rgb(255_255_255/0.8)]\"\n              style={{ opacity: 0, left: \"0%\" }}\n            />\n          </div>\n        </div>\n\n        {/* Hairline Control Row */}\n        <div className=\"flex items-center justify-between gap-2\">\n          {/* Left: Play/Pause, Volume, Clock, Chapter, Return Bookmark */}\n          <div className=\"flex min-w-0 items-center gap-1.5\">\n            <button\n              type=\"button\"\n              aria-label={playing ? \"Pause\" : ended ? \"Replay\" : \"Play\"}\n              onClick={() => togglePlay(false)}\n              className={`relative flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-[9px] text-white/95 hover:bg-white/12 ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n            >\n              <span aria-hidden=\"true\" className=\"absolute inset-0 flex items-center justify-center\" style={interactionIcon(!playing, reduced)}>\n                {ended ? <RotateCcw className=\"size-[15px]\" strokeWidth={2} /> : <Play className=\"ml-0.5 size-[15px] fill-current\" strokeWidth={1.8} />}\n              </span>\n              <span aria-hidden=\"true\" className=\"absolute inset-0 flex items-center justify-center\" style={interactionIcon(playing, reduced)}>\n                <Pause className=\"size-[15px] fill-current\" strokeWidth={1.8} />\n              </span>\n            </button>\n\n            {/* Mute + hover-expanding hairline volume track */}\n            <div className=\"group/vol flex items-center\">\n              <button\n                type=\"button\"\n                aria-label={muted || volume === 0 ? \"Unmute\" : \"Mute\"}\n                onClick={() => {\n                  if (muted || volume === 0) {\n                    setMuted(false);\n                    if (volume === 0) setVolume(0.75);\n                  } else {\n                    setMuted(true);\n                  }\n                }}\n                className={`flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-[9px] text-white/85 hover:bg-white/12 hover:text-white ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n              >\n                {muted || volume === 0 ? <VolumeX className=\"size-[15px]\" strokeWidth={1.9} /> : <Volume2 className=\"size-[15px]\" strokeWidth={1.9} />}\n              </button>\n              <div className=\"w-0 overflow-hidden opacity-0 transition-[width,opacity,margin] duration-200 group-hover/vol:ml-1 group-hover/vol:w-14 group-hover/vol:opacity-100 group-focus-within/vol:ml-1 group-focus-within/vol:w-14 group-focus-within/vol:opacity-100\">\n                <input\n                  type=\"range\"\n                  aria-label=\"Volume\"\n                  min={0}\n                  max={1}\n                  step={0.05}\n                  value={muted ? 0 : volume}\n                  onChange={(e) => {\n                    const next = Number(e.target.value);\n                    setVolume(next);\n                    setMuted(next === 0);\n                  }}\n                  className=\"h-1 w-14 cursor-pointer accent-white\"\n                />\n              </div>\n            </div>\n\n            {/* Tabular clock */}\n            <span className=\"shrink-0 pl-1 font-mono text-[12px] tabular-nums text-white/85\">\n              {formatClock(currentTime)}\n              <span className=\"mx-1 text-white/40\">/</span>\n              <span className=\"text-white/55\">{ready ? formatClock(duration) : \"0:00\"}</span>\n            </span>\n\n            {/* Current chapter name (hidden on tiny widths) */}\n            {activeChapter && (\n              <span className=\"hidden min-w-0 truncate border-l border-white/15 pl-2.5 text-[12px] text-white/70 sm:inline\">\n                {activeChapter.title}\n              </span>\n            )}\n\n            {/* One-tap Return-to-previous-spot pill */}\n            {returnBookmark !== null && (\n              <button\n                type=\"button\"\n                aria-label={`Return to ${formatClock(returnBookmark)}`}\n                onClick={jumpBackToBookmark}\n                className={`ml-1 inline-flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-full border border-amber-300/35 bg-amber-300/12 px-2 text-[11px] font-medium tabular-nums text-amber-200 hover:bg-amber-300/20 ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n              >\n                <Undo2 className=\"size-3\" strokeWidth={2.2} aria-hidden=\"true\" />\n                {formatClock(returnBookmark)}\n              </button>\n            )}\n          </div>\n\n          {/* Right: Speed, Captions, PiP, Fullscreen */}\n          <div className=\"flex shrink-0 items-center gap-1\">\n            <button\n              type=\"button\"\n              aria-label={`Playback speed ${SPEEDS[speedIdx]}x`}\n              onClick={cycleSpeed}\n              className={`inline-flex h-7 min-w-[38px] cursor-pointer items-center justify-center rounded-[8px] px-1.5 font-mono text-[11.5px] font-medium tabular-nums text-white/80 hover:bg-white/12 hover:text-white ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n            >\n              {SPEEDS[speedIdx]}×\n            </button>\n\n            {hasCaptions && (\n              <button\n                type=\"button\"\n                aria-label={captionsOn ? \"Hide captions\" : \"Show captions\"}\n                aria-pressed={captionsOn}\n                onClick={() => setCaptionsOn((c) => !c)}\n                className={`flex size-8 cursor-pointer items-center justify-center rounded-[9px] hover:bg-white/12 ${\n                  captionsOn ? \"bg-white/14 text-white\" : \"text-white/75 hover:text-white\"\n                } ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n              >\n                <Captions className=\"size-[15px]\" strokeWidth={1.9} />\n              </button>\n            )}\n\n            {pipSupported && (\n              <button\n                type=\"button\"\n                aria-label=\"Picture in picture\"\n                onClick={togglePiP}\n                className={`hidden size-8 cursor-pointer items-center justify-center rounded-[9px] text-white/75 hover:bg-white/12 hover:text-white sm:flex ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n              >\n                <PictureInPicture2 className=\"size-[15px]\" strokeWidth={1.9} />\n              </button>\n            )}\n\n            <button\n              type=\"button\"\n              aria-label={fullscreen ? \"Exit fullscreen\" : \"Enter fullscreen\"}\n              onClick={toggleFullscreen}\n              className={`flex size-8 cursor-pointer items-center justify-center rounded-[9px] text-white/80 hover:bg-white/12 hover:text-white ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n            >\n              {fullscreen ? <Minimize className=\"size-[15px]\" strokeWidth={1.9} /> : <Maximize className=\"size-[15px]\" strokeWidth={1.9} />}\n            </button>\n          </div>\n        </div>\n      </div>\n\n      <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n        {liveStatus}\n      </span>\n    </div>\n  );\n}\n\nexport default VideoPlayer;\n"},{"path":"registry/ui-interaction-motion.ts","type":"registry:component","content":"// Hairline UI · video-player · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n'use client';\n\nimport * as React from 'react';\n\nexport const EASE_OUT = 'cubic-bezier(0.16, 1, 0.3, 1)';\nexport const EASE_SETTLE = 'cubic-bezier(0.22, 1.18, 0.36, 1)';\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = 'cubic-bezier(0.34, 1.36, 0.64, 1)';\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  'transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100';\nexport const INTERACTION_FOCUS ='focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\nconst query = '(prefers-reduced-motion: reduce)';\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener('change', notify);\n  return () => media.removeEventListener('change', notify);\n};\nexport const useInteractionReducedMotion = () => React.useSyncExternalStore(subscribe, () => window.matchMedia(query).matches, () => false);\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility(); document.addEventListener('visibilitychange', visibility);\n    return () => { observer.disconnect(); document.removeEventListener('visibilitychange', visibility); };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(on: boolean, reduced: boolean): React.CSSProperties {\n  return { opacity: on ? 1 : 0, transform: on ? 'none' : 'scale(0.6)', filter: on ? 'blur(0px)' : 'blur(3px)', transition: reduced ? 'none' : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}` };\n}\n\n/** A raised object: one tight contact shadow, one short ambient, a hairline of light on its top edge. */\nexport const MATERIAL_LIFT =\n  'shadow-[0_1px_1.5px_rgb(0_0_0/0.07),0_3px_8px_-2px_rgb(0_0_0/0.1),inset_0_0.5px_0_rgb(255_255_255/0.8)] dark:shadow-[0_1px_2px_rgb(0_0_0/0.5),0_4px_10px_-2px_rgb(0_0_0/0.35),inset_0_0.5px_0_rgb(255_255_255/0.1)]';\n/** A trough something sits in, shaded from above, lit along its bottom edge. */\nexport const MATERIAL_RECESS =\n  'shadow-[inset_0_1px_2.5px_rgb(0_0_0/0.09),inset_0_-0.5px_0_rgb(255_255_255/0.7)] dark:shadow-[inset_0_1px_3px_rgb(0_0_0/0.45),inset_0_-0.5px_0_rgb(255_255_255/0.07)]';\n\nexport type SpringConfig = { stiffness: number; damping: number; mass?: number };\nexport interface Spring {\n  get(): number;\n  getVelocity(): number;\n  getTarget(): number;\n  /** Aim somewhere new from wherever it is now, keeping its speed. */\n  set(target: number): void;\n  /** Add speed (units per second), on top of what it already has. */\n  push(velocity: number): void;\n  /** Be there now, at rest. */\n  jump(value: number): void;\n  configure(config: SpringConfig): void;\n  stop(): void;\n}\n\n// Every moving spring on the page shares one frame loop, which sleeps when the last one rests. Each spring's onFrame runs\n// once per frame after all of them have stepped, so several springs that draw one shape paint it once.\nconst SPRING_STEP = 1 / 240;\ntype Running = { step: () => void };\nconst runningSprings = new Set<Running>();\nconst springPainters = new Set<() => void>();\nlet springFrame = 0;\nlet springLast = 0;\nlet springSpare = 0;\n\nfunction springTick(now: number) {\n  // A hidden tab stops the frames, so the first one back must not count the whole gap as time passed.\n  springSpare += Math.min((now - springLast) / 1000, 0.05);\n  springLast = now;\n  while (springSpare >= SPRING_STEP) {\n    runningSprings.forEach((spring) => spring.step());\n    springSpare -= SPRING_STEP;\n  }\n  const painters = [...springPainters];\n  springPainters.clear();\n  painters.forEach((paint) => paint());\n  springFrame = runningSprings.size ? requestAnimationFrame(springTick) : 0;\n}\n\nfunction wakeSprings(spring: Running) {\n  runningSprings.add(spring);\n  if (springFrame) return;\n  springSpare = 0;\n  springFrame = requestAnimationFrame((now) => {\n    springLast = now - 1000 / 60;\n    springTick(now);\n  });\n}\n\n/**\n * A spring that carries its speed: re-aim it mid-flight and it curves on from where it is, push it while it swings and the\n * push adds to the swing. Use it for anything that can be interrupted; a curve restarts from a standstill every time.\n * `onFrame` should write straight to the DOM. `precision` is how close counts as there, in the value's own units.\n */\nexport function createSpring(initial: number, config: SpringConfig, onFrame: () => void, precision = 0.01): Spring {\n  let value = initial;\n  let velocity = 0;\n  let target = initial;\n  let { stiffness, damping, mass = 1 } = config;\n  const running: Running = {\n    step() {\n      velocity += ((-stiffness * (value - target) - damping * velocity) / mass) * SPRING_STEP;\n      value += velocity * SPRING_STEP;\n      if (Math.abs(value - target) < precision && Math.abs(velocity) < precision * 10) {\n        value = target;\n        velocity = 0;\n        runningSprings.delete(running);\n      }\n      springPainters.add(onFrame);\n    },\n  };\n  return {\n    get: () => value,\n    getVelocity: () => velocity,\n    getTarget: () => target,\n    set(next) {\n      if (next === target && !runningSprings.has(running)) return;\n      target = next;\n      wakeSprings(running);\n    },\n    push(speed) {\n      velocity += speed;\n      wakeSprings(running);\n    },\n    jump(next) {\n      value = next;\n      target = next;\n      velocity = 0;\n      runningSprings.delete(running);\n      onFrame();\n    },\n    configure(next) {\n      ({ stiffness, damping, mass = 1 } = next);\n    },\n    stop() {\n      runningSprings.delete(running);\n    },\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(samples: PointerSample[], x: number, time: number) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100) return 0;\n  const first = samples[0], last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(overshoot: number, dimension = 320, constant = 0.55): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(distance: number, velocity: number, time = 0.12): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(velocity: number, distanceToTarget: number, factor = 10): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient = (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value = to + Math.exp(-damping * omega * t) * (displacement * Math.cos(damped * t) + coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n\n"},{"path":"registry/ui-sounds.ts","type":"registry:component","content":"// Hairline UI · video-player · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n/* ─────────────────────────────────────────────────────────\n * UI SOUNDS: small interface sounds, made in code\n *\n * No files and nothing to license: every sound is built from a\n * tone or a burst of noise with the Web Audio API the moment it\n * plays. They're short and quiet, made to sit under an interface,\n * and components only play them when you pass `sound`.\n *\n *   fold     paper creasing: two short crisp bursts\n *   unfold   paper opening: a soft rising sweep\n *   drop     something small landing: a low, soft knock\n *   tick     a light click\n *   pop      a quick bright blip\n *   success  two soft rising notes\n *   error    two low falling notes\n *\n * Browsers only start audio after the visitor has pressed\n * something on the page, so a sound before that stays silent.\n * ───────────────────────────────────────────────────────── */\n\nexport type UiSound = \"fold\" | \"unfold\" | \"drop\" | \"tick\" | \"pop\" | \"success\" | \"error\";\n\nlet context: AudioContext | null = null;\nlet noise: AudioBuffer | null = null;\n\nfunction audio() {\n  if (typeof window === \"undefined\") return null;\n  if (!context) {\n    const Ctx = window.AudioContext ?? (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;\n    if (!Ctx) return null;\n    context = new Ctx();\n  }\n  if (context.state === \"suspended\") void context.resume().catch(() => {});\n  return context;\n}\n\nfunction noiseBuffer(ctx: AudioContext) {\n  if (noise && noise.sampleRate === ctx.sampleRate) return noise;\n  noise = ctx.createBuffer(1, Math.floor(ctx.sampleRate * 0.5), ctx.sampleRate);\n  const data = noise.getChannelData(0);\n  for (let i = 0; i < data.length; i++) data[i] = Math.random() * 2 - 1;\n  return noise;\n}\n\n/** A burst of filtered noise. */\nfunction burst(ctx: AudioContext, out: AudioNode, at: number, length: number, { type = \"bandpass\", from = 2000, to = from, q = 0.9, level = 0.5 }: { type?: BiquadFilterType; from?: number; to?: number; q?: number; level?: number }) {\n  const src = ctx.createBufferSource();\n  src.buffer = noiseBuffer(ctx);\n  const filter = ctx.createBiquadFilter();\n  filter.type = type;\n  filter.Q.value = q;\n  filter.frequency.setValueAtTime(from, at);\n  filter.frequency.exponentialRampToValueAtTime(Math.max(40, to), at + length);\n  const gain = ctx.createGain();\n  gain.gain.setValueAtTime(0.0001, at);\n  gain.gain.exponentialRampToValueAtTime(level, at + Math.min(0.012, length / 3));\n  gain.gain.exponentialRampToValueAtTime(0.0001, at + length);\n  src.connect(filter).connect(gain).connect(out);\n  src.start(at, Math.random() * 0.3, length + 0.02);\n}\n\n/** A tone that glides from one pitch to another. */\nfunction tone(ctx: AudioContext, out: AudioNode, at: number, length: number, { type = \"sine\", from, to = from, level = 0.4 }: { type?: OscillatorType; from: number; to?: number; level?: number }) {\n  const osc = ctx.createOscillator();\n  osc.type = type;\n  osc.frequency.setValueAtTime(from, at);\n  osc.frequency.exponentialRampToValueAtTime(Math.max(20, to), at + length);\n  const gain = ctx.createGain();\n  gain.gain.setValueAtTime(0.0001, at);\n  gain.gain.exponentialRampToValueAtTime(level, at + 0.006);\n  gain.gain.exponentialRampToValueAtTime(0.0001, at + length);\n  osc.connect(gain).connect(out);\n  osc.start(at);\n  osc.stop(at + length + 0.02);\n}\n\n/** Plays one sound. `volume` is 0 to 1; the default sits quietly under an interface. */\nexport function playSound(name: UiSound, volume = 0.5) {\n  const ctx = audio();\n  if (!ctx) return;\n  const out = ctx.createGain();\n  out.gain.value = Math.max(0, Math.min(1, volume)) * 0.5;\n  out.connect(ctx.destination);\n  const t = ctx.currentTime + 0.005;\n  switch (name) {\n    case \"fold\":\n      burst(ctx, out, t, 0.05, { type: \"highpass\", from: 2600, q: 0.7, level: 0.45 });\n      burst(ctx, out, t + 0.07, 0.07, { type: \"bandpass\", from: 3200, to: 1800, q: 1.2, level: 0.35 });\n      break;\n    case \"unfold\":\n      burst(ctx, out, t, 0.16, { type: \"bandpass\", from: 900, to: 2800, q: 0.8, level: 0.3 });\n      break;\n    case \"drop\":\n      tone(ctx, out, t, 0.12, { from: 180, to: 70, level: 0.55 });\n      burst(ctx, out, t, 0.03, { type: \"lowpass\", from: 1200, q: 0.5, level: 0.2 });\n      break;\n    case \"tick\":\n      tone(ctx, out, t, 0.025, { type: \"triangle\", from: 1900, to: 1500, level: 0.25 });\n      break;\n    case \"pop\":\n      tone(ctx, out, t, 0.06, { from: 620, to: 980, level: 0.3 });\n      break;\n    case \"success\":\n      tone(ctx, out, t, 0.11, { from: 660, level: 0.22 });\n      tone(ctx, out, t + 0.09, 0.16, { from: 990, level: 0.22 });\n      break;\n    case \"error\":\n      tone(ctx, out, t, 0.12, { type: \"triangle\", from: 330, level: 0.25 });\n      tone(ctx, out, t + 0.1, 0.18, { type: \"triangle\", from: 247, level: 0.25 });\n      break;\n  }\n  window.setTimeout(() => out.disconnect(), 600);\n}\n"}],"css":{},"docs":"Docs and live preview: https://hairlineui.com/ui/video-player. MIT licensed: https://hairlineui.com/license#components","meta":{"license":"MIT"}}