{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slide-show",
  "type": "registry:component",
  "title": "Slide Show",
  "description": "A full-bleed slideshow with a slow Ken Burns zoom, animated captions, arrows, dots, an autoplay progress bar, swipe and keyboard control.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "slideshow",
    "gallery",
    "hero",
    "ken-burns",
    "fullscreen"
  ],
  "docs": "https://hyperblur.dev/effects/slide-show",
  "files": [
    {
      "path": "registry/hyperblur/slide-show.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/slide-show.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SlideShowSlide {\n  background: React.ReactNode;\n  title?: string;\n  text?: string;\n}\n\nexport interface SlideShowProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  slides?: SlideShowSlide[];\n  children?: React.ReactNode;\n  transition?: \"fade\" | \"zoom\" | \"slide\";\n  autoplay?: number;\n  loop?: boolean;\n  arrows?: boolean;\n  dots?: boolean;\n  fullscreenButton?: boolean;\n}\n\nconst css = `\n@keyframes hb-ss-kb {\n  from { transform: scale(1); }\n  to { transform: scale(1.14); }\n}\n@keyframes hb-ss-up {\n  from { opacity: 0; transform: translateY(16px); }\n  to { opacity: 1; transform: translateY(0); }\n}\n@keyframes hb-ss-out {\n  from { opacity: 1; }\n  to { opacity: 0; }\n}\n@keyframes hb-ss-prog {\n  from { transform: scaleX(0); }\n  to { transform: scaleX(1); }\n}\n.hb-ss {\n  position: relative;\n  width: 100%;\n  height: 100%;\n  aspect-ratio: 16 / 9;\n  overflow: hidden;\n  border-radius: inherit;\n  background: #000;\n  color: #fff;\n  touch-action: pan-y;\n  user-select: none;\n  outline: none;\n  container-type: inline-size;\n}\n.hb-ss:focus-visible { box-shadow: inset 0 0 0 2px #2f7bff; }\n.hb-ss:fullscreen { aspect-ratio: auto; border-radius: 0; }\n.hb-ss-slide {\n  position: absolute;\n  inset: 0;\n  z-index: 0;\n  overflow: hidden;\n  opacity: 0;\n}\n.hb-ss-slide.hb-ss-prev { z-index: 1; opacity: 1; }\n.hb-ss-slide.hb-ss-active {\n  z-index: 2;\n  opacity: 1;\n  transition: opacity 0.9s ease;\n}\n.hb-ss-bg { position: absolute; inset: 0; }\n.hb-ss-bg > * { width: 100%; height: 100%; object-fit: cover; }\n.hb-ss-t-zoom .hb-ss-active .hb-ss-bg,\n.hb-ss-t-zoom .hb-ss-prev .hb-ss-bg {\n  animation: hb-ss-kb var(--hb-ss-kb) ease-out forwards;\n}\n.hb-ss-t-slide .hb-ss-slide { opacity: 1; transition: none; }\n.hb-ss-t-slide .hb-ss-before { transform: translateX(-100%); }\n.hb-ss-t-slide .hb-ss-after { transform: translateX(100%); }\n.hb-ss-t-slide .hb-ss-slide.hb-ss-active,\n.hb-ss-t-slide .hb-ss-slide.hb-ss-prev {\n  transition: transform 0.8s cubic-bezier(.65, 0, .35, 1);\n}\n.hb-ss-t-slide .hb-ss-slide.hb-ss-active { transform: none; }\n.hb-ss-scrim {\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.65) 100%);\n  pointer-events: none;\n}\n.hb-ss-copy {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  padding: 0 clamp(14px, 6%, 48px) clamp(30px, 9%, 56px);\n  max-width: 36em;\n  opacity: 0;\n}\n.hb-ss-active .hb-ss-copy { animation: hb-ss-up 0.8s cubic-bezier(.22, 1, .36, 1) 0.3s both; }\n.hb-ss-prev .hb-ss-copy { animation: hb-ss-out 0.35s ease forwards; }\n.hb-ss-title {\n  margin: 0;\n  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n    font-weight: 400;\n  font-size: clamp(20px, 5.4cqw, 44px);\n  line-height: 1.05;\n  letter-spacing: -0.01em;\n}\n.hb-ss-text {\n  margin: 0.5em 0 0;\n  font-size: clamp(12px, 1.6cqw, 16px);\n  line-height: 1.5;\n  color: rgba(255, 255, 255, 0.78);\n}\n.hb-ss-btn {\n  position: absolute;\n  top: 50%;\n  z-index: 5;\n  display: grid;\n  place-items: center;\n  width: 32px;\n  height: 32px;\n  margin: -16px 0 0;\n  padding: 0;\n  border: 1px solid rgba(255, 255, 255, 0.2);\n  border-radius: 50%;\n  background: rgba(10, 10, 10, 0.55);\n  color: #fff;\n  cursor: pointer;\n  backdrop-filter: blur(6px);\n  transition: background 0.2s ease, opacity 0.2s ease;\n}\n.hb-ss-btn:hover:not(:disabled) { background: rgba(47, 123, 255, 0.85); }\n.hb-ss-btn:focus-visible { outline: 2px solid #2f7bff; outline-offset: 2px; }\n.hb-ss-btn:disabled { opacity: 0.35; cursor: default; }\n.hb-ss-prevbtn { left: 8px; }\n.hb-ss-nextbtn { right: 8px; }\n.hb-ss-fs { top: 8px; right: 8px; margin: 0; }\n.hb-ss-dots {\n  position: absolute;\n  left: 50%;\n  bottom: 10px;\n  z-index: 5;\n  display: flex;\n  gap: 6px;\n  padding: 5px 8px;\n  border-radius: 999px;\n  background: rgba(10, 10, 10, 0.45);\n  transform: translateX(-50%);\n}\n.hb-ss-dot {\n  width: 8px;\n  height: 8px;\n  padding: 0;\n  border: 0;\n  border-radius: 999px;\n  background: rgba(255, 255, 255, 0.4);\n  cursor: pointer;\n  transition: background 0.2s ease, width 0.25s ease;\n}\n.hb-ss-dot:hover { background: rgba(255, 255, 255, 0.7); }\n.hb-ss-dot:focus-visible { outline: 2px solid #2f7bff; outline-offset: 2px; }\n.hb-ss-dot[aria-current=\"true\"] { width: 18px; background: #fff; }\n.hb-ss-bar {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  z-index: 5;\n  height: 3px;\n  background: rgba(255, 255, 255, 0.14);\n}\n.hb-ss-bar > i {\n  display: block;\n  height: 100%;\n  background: #fff;\n  transform-origin: 0 50%;\n  animation: hb-ss-prog var(--hb-ss-ap) linear forwards;\n}\n.hb-ss-paused .hb-ss-bar > i { animation-play-state: paused; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-ss-t-zoom .hb-ss-active .hb-ss-bg,\n  .hb-ss-t-zoom .hb-ss-prev .hb-ss-bg { animation: none; }\n  .hb-ss-active .hb-ss-copy { animation: hb-ss-out 0.4s ease reverse both; }\n  .hb-ss-t-slide .hb-ss-slide,\n  .hb-ss-t-slide .hb-ss-slide.hb-ss-active,\n  .hb-ss-t-slide .hb-ss-slide.hb-ss-prev {\n    transform: none;\n    opacity: 0;\n    transition: opacity 0.4s ease;\n  }\n  .hb-ss-t-slide .hb-ss-slide.hb-ss-active { opacity: 1; }\n  .hb-ss-t-slide .hb-ss-slide.hb-ss-prev { opacity: 1; transition: none; }\n  .hb-ss-btn, .hb-ss-dot { transition: none; }\n}\n`;\n\ninterface State {\n  index: number;\n  prev: number;\n  dir: number;\n}\n\nfunction subscribeMotion(onChange: () => void) {\n  const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n}\n\nfunction getMotion() {\n  return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\nfunction getServerMotion() {\n  return false;\n}\n\nfunction place(i: number, state: State, n: number) {\n  if (i === state.index) return \"\";\n  if (i === state.prev) return state.dir > 0 ? \"before\" : \"after\";\n  return (i - state.index + n) % n <= n / 2 ? \"after\" : \"before\";\n}\n\nexport function SlideShow({\n  slides,\n  children,\n  transition = \"zoom\",\n  autoplay = 5000,\n  loop = true,\n  arrows = true,\n  dots = true,\n  fullscreenButton = false,\n  className = \"\",\n  style,\n  onKeyDown,\n  onMouseEnter,\n  onMouseLeave,\n  onFocus,\n  onBlur,\n  onPointerDown,\n  onPointerUp,\n  onPointerCancel,\n  ...rest\n}: SlideShowProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const startX = React.useRef<number | null>(null);\n  const [state, setState] = React.useState<State>({ index: 0, prev: -1, dir: 1 });\n  const [paused, setPaused] = React.useState(false);\n  const [full, setFull] = React.useState(false);\n  const reduced = React.useSyncExternalStore(subscribeMotion, getMotion, getServerMotion);\n\n  const items: SlideShowSlide[] = slides ?? React.Children.toArray(children).map((child) => ({ background: child }));\n  const count = items.length;\n  const index = Math.min(state.index, Math.max(0, count - 1));\n  const playing = autoplay > 0 && count > 1 && !reduced;\n\n  const go = React.useCallback(\n    (to: number, dir: number) => {\n      setState((s) => {\n        if (to === s.index) return s;\n        return { index: to, prev: s.index, dir };\n      });\n    },\n    [],\n  );\n\n  const next = React.useCallback(() => {\n    if (count < 2) return;\n    if (index < count - 1) go(index + 1, 1);\n    else if (loop) go(0, 1);\n  }, [count, index, loop, go]);\n\n  const prev = React.useCallback(() => {\n    if (count < 2) return;\n    if (index > 0) go(index - 1, -1);\n    else if (loop) go(count - 1, -1);\n  }, [count, index, loop, go]);\n\n  React.useEffect(() => {\n    const onChange = () => setFull(document.fullscreenElement === rootRef.current);\n    document.addEventListener(\"fullscreenchange\", onChange);\n    return () => document.removeEventListener(\"fullscreenchange\", onChange);\n  }, []);\n\n  function toggleFullscreen() {\n    const el = rootRef.current;\n    if (!el) return;\n    if (document.fullscreenElement) void document.exitFullscreen();\n    else void el.requestFullscreen?.();\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {\n    onKeyDown?.(e);\n    if (e.defaultPrevented) return;\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      next();\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      prev();\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      go(0, -1);\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      go(count - 1, 1);\n    }\n  }\n\n  function handlePointerDown(e: React.PointerEvent<HTMLDivElement>) {\n    onPointerDown?.(e);\n    if ((e.target as HTMLElement).closest(\"button\")) {\n      startX.current = null;\n      return;\n    }\n    startX.current = e.clientX;\n  }\n\n  function handlePointerUp(e: React.PointerEvent<HTMLDivElement>) {\n    onPointerUp?.(e);\n    const from = startX.current;\n    startX.current = null;\n    if (from === null) return;\n    const dx = e.clientX - from;\n    if (Math.abs(dx) < 40) return;\n    if (dx < 0) next();\n    else prev();\n  }\n\n  function handlePointerCancel(e: React.PointerEvent<HTMLDivElement>) {\n    onPointerCancel?.(e);\n    startX.current = null;\n  }\n\n  function handleEnter(e: React.MouseEvent<HTMLDivElement>) {\n    onMouseEnter?.(e);\n    setPaused(true);\n  }\n\n  function handleLeave(e: React.MouseEvent<HTMLDivElement>) {\n    onMouseLeave?.(e);\n    setPaused(false);\n  }\n\n  function handleFocus(e: React.FocusEvent<HTMLDivElement>) {\n    onFocus?.(e);\n    setPaused(true);\n  }\n\n  function handleBlur(e: React.FocusEvent<HTMLDivElement>) {\n    onBlur?.(e);\n    setPaused(false);\n  }\n\n  const vars = {\n    \"--hb-ss-ap\": `${Math.max(500, autoplay)}ms`,\n    \"--hb-ss-kb\": `${Math.max(9000, autoplay * 1.8)}ms`,\n    ...style,\n  } as React.CSSProperties;\n\n  const atEnd = !loop && index === count - 1;\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-ss hb-ss-t-${transition}${paused ? \" hb-ss-paused\" : \"\"} ${className}`}\n      style={vars}\n      role=\"region\"\n      aria-roledescription=\"carousel\"\n      aria-label=\"Slideshow\"\n      tabIndex={0}\n      onKeyDown={handleKeyDown}\n      onMouseEnter={handleEnter}\n      onMouseLeave={handleLeave}\n      onFocus={handleFocus}\n      onBlur={handleBlur}\n      onPointerDown={handlePointerDown}\n      onPointerUp={handlePointerUp}\n      onPointerCancel={handlePointerCancel}\n      {...rest}\n    >\n      <style href=\"hb-slide-show\" precedence=\"default\">{css}</style>\n      {items.map((item, i) => {\n        const active = i === index;\n        const old = !active && i === state.prev;\n        const where = place(i, { ...state, index }, count);\n        const cls = [\"hb-ss-slide\", active ? \"hb-ss-active\" : \"\", old ? \"hb-ss-prev\" : \"\", where ? `hb-ss-${where}` : \"\"]\n          .filter(Boolean)\n          .join(\" \");\n        return (\n          <div\n            key={i}\n            className={cls}\n            role=\"group\"\n            aria-roledescription=\"slide\"\n            aria-label={`${i + 1} of ${count}`}\n            aria-hidden={active ? undefined : true}\n          >\n            <div className=\"hb-ss-bg\">{item.background}</div>\n            {(item.title || item.text) && (\n              <>\n                <div className=\"hb-ss-scrim\" />\n                <div className=\"hb-ss-copy\">\n                  {item.title && <h3 className=\"hb-ss-title\">{item.title}</h3>}\n                  {item.text && <p className=\"hb-ss-text\">{item.text}</p>}\n                </div>\n              </>\n            )}\n          </div>\n        );\n      })}\n      {count > 1 && arrows && (\n        <>\n          <button\n            type=\"button\"\n            className=\"hb-ss-btn hb-ss-prevbtn\"\n            aria-label=\"Previous slide\"\n            disabled={!loop && index === 0}\n            onClick={prev}\n          >\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M15 5l-7 7 7 7\" />\n            </svg>\n          </button>\n          <button\n            type=\"button\"\n            className=\"hb-ss-btn hb-ss-nextbtn\"\n            aria-label=\"Next slide\"\n            disabled={atEnd}\n            onClick={next}\n          >\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M9 5l7 7-7 7\" />\n            </svg>\n          </button>\n        </>\n      )}\n      {count > 1 && dots && (\n        <div className=\"hb-ss-dots\">\n          {items.map((_, i) => (\n            <button\n              type=\"button\"\n              key={i}\n              className=\"hb-ss-dot\"\n              aria-label={`Go to slide ${i + 1}`}\n              aria-current={i === index ? \"true\" : undefined}\n              onClick={() => go(i, i > index ? 1 : -1)}\n            />\n          ))}\n        </div>\n      )}\n      {fullscreenButton && (\n        <button\n          type=\"button\"\n          className=\"hb-ss-btn hb-ss-fs\"\n          aria-label={full ? \"Exit fullscreen\" : \"Enter fullscreen\"}\n          onClick={toggleFullscreen}\n        >\n          <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.25\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            {full ? (\n              <path d=\"M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5\" />\n            ) : (\n              <path d=\"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5\" />\n            )}\n          </svg>\n        </button>\n      )}\n      {playing && !atEnd && (\n        <div className=\"hb-ss-bar\" aria-hidden=\"true\">\n          <i key={`${index}-${autoplay}`} onAnimationEnd={next} />\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}