{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "curtain-wipe",
  "type": "registry:component",
  "title": "Curtain Wipe",
  "description": "One soft curtain that glides away with a glowing gradient edge, feathering wider as it travels across.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "curtain",
    "wipe",
    "gradient",
    "feather",
    "reveal",
    "transition"
  ],
  "docs": "https://hyperblur.dev/effects/curtain-wipe",
  "files": [
    {
      "path": "registry/hyperblur/curtain-wipe.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/curtain-wipe.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type CurtainWipeTrigger = \"mount\" | \"view\" | \"manual\";\n\nexport interface CurtainWipeProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"color\"> {\n  children?: React.ReactNode;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  trigger?: CurtainWipeTrigger;\n  duration?: number;\n  color?: string;\n  accent?: string;\n  direction?: \"left\" | \"right\" | \"up\" | \"down\";\n  feather?: number;\n  replay?: string | number;\n  closeAfter?: number;\n  loop?: boolean;\n}\n\nconst css = `\n@property --hb-zy7-p {\n  syntax: \"<number>\";\n  inherits: true;\n  initial-value: 0;\n}\n.hb-zy7 {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n  --hb-zy7-p: 0;\n  transition: --hb-zy7-p var(--hb-zy7-d) cubic-bezier(0.6, 0, 0.3, 1);\n}\n.hb-zy7[data-open=\"true\"] { --hb-zy7-p: 1; }\n.hb-zy7 *, .hb-zy7 *::before, .hb-zy7 *::after { box-sizing: border-box; }\n.hb-zy7-c { position: relative; z-index: 0; height: 100%; }\n.hb-zy7-k, .hb-zy7-g {\n  --hb-zy7-e: calc(var(--hb-zy7-p) * (100% + var(--hb-zy7-fm)));\n  --hb-zy7-w: calc(6% + var(--hb-zy7-p) * (var(--hb-zy7-fm) - 6%));\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n}\n.hb-zy7-k {\n  z-index: 1;\n  background:\n    linear-gradient(var(--hb-zy7-a), color-mix(in srgb, var(--hb-zy7-acc) 30%, var(--hb-zy7-col)) 0%, var(--hb-zy7-col) 45%, color-mix(in srgb, var(--hb-zy7-col) 80%, #000000) 100%);\n  -webkit-mask-image: linear-gradient(var(--hb-zy7-a), transparent calc(var(--hb-zy7-e) - var(--hb-zy7-w)), #000000 var(--hb-zy7-e));\n  mask-image: linear-gradient(var(--hb-zy7-a), transparent calc(var(--hb-zy7-e) - var(--hb-zy7-w)), #000000 var(--hb-zy7-e));\n}\n.hb-zy7[data-open=\"false\"] .hb-zy7-k { pointer-events: auto; }\n.hb-zy7-g {\n  z-index: 2;\n  background: linear-gradient(var(--hb-zy7-a), var(--hb-zy7-acc), #ffffff);\n  mix-blend-mode: screen;\n  opacity: 0.55;\n  -webkit-mask-image: linear-gradient(var(--hb-zy7-a), transparent calc(var(--hb-zy7-e) - var(--hb-zy7-w)), #000000 calc(var(--hb-zy7-e) - var(--hb-zy7-w) * 0.25), transparent calc(var(--hb-zy7-e) + var(--hb-zy7-p) * 2%));\n  mask-image: linear-gradient(var(--hb-zy7-a), transparent calc(var(--hb-zy7-e) - var(--hb-zy7-w)), #000000 calc(var(--hb-zy7-e) - var(--hb-zy7-w) * 0.25), transparent calc(var(--hb-zy7-e) + var(--hb-zy7-p) * 2%));\n}\n.hb-zy7[data-instant=\"true\"] { transition: none !important; }\n.hb-zy7-s {\n  display: flex;\n  min-height: 220px;\n  flex-direction: column;\n  justify-content: flex-end;\n  gap: 4px;\n  padding: 22px;\n  color: #ededed;\n  background:\n    radial-gradient(circle at 25% 25%, rgba(255, 140, 90, 0.5), transparent 40%),\n    linear-gradient(200deg, #1a1420 0%, #0a0a0f 100%);\n}\n.hb-zy7-s small {\n  font-size: 11px;\n  letter-spacing: 0.16em;\n  text-transform: uppercase;\n  color: rgba(237, 237, 237, 0.6);\n}\n.hb-zy7-s strong { font-size: 26px; line-height: 1.1; font-weight: 600; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-zy7 { transition: none !important; }\n}\n`;\n\nfunction useCurtain(\n  open: boolean | undefined,\n  defaultOpen: boolean,\n  onOpenChange: ((open: boolean) => void) | undefined,\n  trigger: CurtainWipeTrigger,\n  replay: string | number | undefined,\n  closeAfter: number | undefined,\n  loop: boolean,\n  total: number,\n) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const controlled = open !== undefined;\n  const [inner, setInner] = React.useState(defaultOpen);\n  const [instant, setInstant] = React.useState(false);\n  const isOpen = controlled ? open : inner;\n  const live = React.useRef({ controlled, onOpenChange, isOpen });\n  const opened = React.useRef(defaultOpen);\n  const prevReplay = React.useRef(replay);\n\n  React.useEffect(() => {\n    live.current = { controlled, onOpenChange, isOpen };\n    if (isOpen) opened.current = true;\n  });\n\n  const setOpen = React.useCallback((next: boolean) => {\n    if (live.current.isOpen === next) return;\n    live.current.isOpen = next;\n    if (!live.current.controlled) setInner(next);\n    live.current.onOpenChange?.(next);\n  }, []);\n\n  React.useEffect(() => {\n    if (trigger !== \"mount\") return;\n    let b = 0;\n    const a = requestAnimationFrame(() => {\n      b = requestAnimationFrame(() => setOpen(true));\n    });\n    return () => {\n      cancelAnimationFrame(a);\n      cancelAnimationFrame(b);\n    };\n  }, [trigger, setOpen]);\n\n  React.useEffect(() => {\n    if (trigger !== \"view\") return;\n    const el = ref.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(\n      (entries) => {\n        if (!entries.some((e) => e.isIntersecting)) return;\n        setOpen(true);\n        io.disconnect();\n      },\n      { threshold: 0.3 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [trigger, setOpen]);\n\n  React.useEffect(() => {\n    if (prevReplay.current === replay) return;\n    prevReplay.current = replay;\n    let b = 0;\n    let c = 0;\n    const a = requestAnimationFrame(() => {\n      setInstant(true);\n      setOpen(false);\n      b = requestAnimationFrame(() => {\n        c = requestAnimationFrame(() => {\n          setInstant(false);\n          setOpen(true);\n        });\n      });\n    });\n    return () => {\n      cancelAnimationFrame(a);\n      cancelAnimationFrame(b);\n      cancelAnimationFrame(c);\n    };\n  }, [replay, setOpen]);\n\n  React.useEffect(() => {\n    if (instant) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let t = 0;\n    if (isOpen && closeAfter !== undefined) {\n      t = window.setTimeout(() => setOpen(false), total + closeAfter);\n    } else if (!isOpen && loop && opened.current) {\n      t = window.setTimeout(() => setOpen(true), total + 800);\n    }\n    return () => window.clearTimeout(t);\n  }, [isOpen, instant, closeAfter, loop, total, setOpen]);\n\n  return { ref, isOpen, instant };\n}\n\nconst angles = { right: \"90deg\", left: \"270deg\", down: \"180deg\", up: \"0deg\" } as const;\n\nexport function CurtainWipe({\n  children,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  trigger = \"mount\",\n  duration = 1200,\n  color = \"#111111\",\n  accent = \"#2f7bff\",\n  direction = \"right\",\n  feather = 0.4,\n  replay,\n  closeAfter,\n  loop = false,\n  className = \"\",\n  style,\n  ...rest\n}: CurtainWipeProps) {\n  const { ref, isOpen, instant } = useCurtain(\n    open,\n    defaultOpen,\n    onOpenChange,\n    trigger,\n    replay,\n    closeAfter,\n    loop,\n    duration,\n  );\n  const soft = Math.max(0.08, Math.min(0.9, feather));\n\n  const vars = {\n    \"--hb-zy7-col\": color,\n    \"--hb-zy7-acc\": accent,\n    \"--hb-zy7-d\": `${duration}ms`,\n    \"--hb-zy7-a\": angles[direction],\n    \"--hb-zy7-fm\": `${(soft * 100).toFixed(1)}%`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-curtain-wipe\" precedence=\"default\">{css}</style>\n      <div\n        ref={ref}\n        className={`hb-zy7 ${className}`}\n        style={vars}\n        data-open={isOpen}\n        data-instant={instant}\n        {...rest}\n      >\n        <div className=\"hb-zy7-c\">\n          {children ?? (\n            <div className=\"hb-zy7-s\">\n              <small>Tonight</small>\n              <strong>Low tide at Harbor Point</strong>\n            </div>\n          )}\n        </div>\n        <div className=\"hb-zy7-k\" aria-hidden=\"true\" />\n        <div className=\"hb-zy7-g\" aria-hidden=\"true\" />\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}