{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transition-liquid-wipe",
  "type": "registry:component",
  "title": "Transition Liquid Wipe",
  "description": "A wavy liquid front with a bulging belly pours across the frame, led by a colored rim that moves out of step with it. Reversing drains it back the way it came.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "liquid",
    "wipe",
    "wave",
    "gooey",
    "transition"
  ],
  "docs": "https://hyperblur.dev/effects/transition-liquid-wipe",
  "files": [
    {
      "path": "registry/hyperblur/transition-liquid-wipe.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/transition-liquid-wipe.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type TransitionLiquidWipeDirection = \"right\" | \"left\" | \"up\";\n\nexport interface TransitionLiquidWipeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  children?: React.ReactNode;\n  from?: React.ReactNode;\n  to?: React.ReactNode;\n  active?: boolean;\n  defaultActive?: boolean;\n  onActiveChange?: (active: boolean) => void;\n  autoPlay?: boolean;\n  interval?: number;\n  duration?: number;\n  direction?: TransitionLiquidWipeDirection;\n  accent?: string;\n  accentEnd?: string;\n}\n\nconst css = `\n@property --hb-vj10-p {\n  syntax: \"<number>\";\n  inherits: true;\n  initial-value: 0;\n}\n.hb-vj10 {\n  position: relative;\n  display: grid;\n  grid-template: minmax(0, 1fr) / minmax(0, 1fr);\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n  --hb-vj10-p: 0;\n  transition: --hb-vj10-p var(--hb-vj10-d) cubic-bezier(0.65, 0, 0.3, 1);\n}\n.hb-vj10[data-active=\"true\"] { --hb-vj10-p: 1; }\n.hb-vj10 *, .hb-vj10 *::before, .hb-vj10 *::after { box-sizing: border-box; }\n.hb-vj10-l {\n  grid-area: 1 / 1;\n  display: grid;\n  min-width: 0;\n  min-height: 0;\n}\n.hb-vj10-rim {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  pointer-events: none;\n  background:\n    radial-gradient(120% 80% at 20% 30%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%),\n    linear-gradient(var(--hb-vj10-ang), var(--hb-vj10-a), var(--hb-vj10-b));\n}\n.hb-vj10-to { position: relative; z-index: 2; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vj10 { transition: none; }\n}\n`;\n\nfunction useSwap(\n  active: boolean | undefined,\n  defaultActive: boolean,\n  onActiveChange: ((active: boolean) => void) | undefined,\n  autoPlay: boolean,\n  interval: number,\n) {\n  const [inner, setInner] = React.useState(defaultActive);\n  const controlled = active !== undefined;\n  const value = controlled ? active : inner;\n  const set = React.useCallback(\n    (next: boolean) => {\n      if (!controlled) setInner(next);\n      onActiveChange?.(next);\n    },\n    [controlled, onActiveChange],\n  );\n  React.useEffect(() => {\n    if (!autoPlay) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const id = window.setTimeout(() => set(!value), interval);\n    return () => window.clearTimeout(id);\n  }, [autoPlay, interval, value, set]);\n  return value;\n}\n\nfunction edge(direction: TransitionLiquidWipeDirection, lead: number, speed: number, amp: number) {\n  const steps = 18;\n  const pts: string[] = [];\n  for (let i = 0; i <= steps; i++) {\n    const t = i / steps;\n    const phase = t * 540 + lead * 900;\n    const belly = Math.sin(t * Math.PI) * 9;\n    const front = `calc((var(--hb-vj10-p) * 1.5 - 0.25 + ${lead.toFixed(3)}) * 100% + ${belly.toFixed(2)}% + sin(calc(var(--hb-vj10-p) * ${speed}deg + ${phase.toFixed(1)}deg)) * ${amp}px)`;\n    const along = `${(t * 100).toFixed(2)}%`;\n    if (direction === \"right\") pts.push(`${front} ${along}`);\n    else if (direction === \"left\") pts.push(`calc(100% - (${front.slice(5, -1)})) ${along}`);\n    else pts.push(`${along} calc(100% - (${front.slice(5, -1)}))`);\n  }\n  if (direction === \"right\") return `polygon(-10% 0%, ${pts.join(\", \")}, -10% 100%)`;\n  if (direction === \"left\") return `polygon(110% 0%, ${pts.join(\", \")}, 110% 100%)`;\n  return `polygon(0% 110%, ${pts.join(\", \")}, 100% 110%)`;\n}\n\nfunction Scene({ tone, kicker, title, dark }: { tone: string; kicker: string; title: string; dark?: boolean }) {\n  const ink = dark ? \"#101010\" : \"#ededed\";\n  return (\n    <div style={{ display: \"grid\", alignContent: \"end\", gap: 4, padding: 20, minHeight: 180, background: tone, color: ink }}>\n      <span style={{ fontSize: 11, letterSpacing: \"0.14em\", textTransform: \"uppercase\", opacity: 0.65 }}>{kicker}</span>\n      <strong style={{ fontSize: 20, fontWeight: 600, letterSpacing: \"-0.01em\" }}>{title}</strong>\n    </div>\n  );\n}\n\nexport function TransitionLiquidWipe({\n  children,\n  from,\n  to,\n  active,\n  defaultActive = false,\n  onActiveChange,\n  autoPlay = false,\n  interval = 2800,\n  duration = 1250,\n  direction = \"right\",\n  accent = \"#2f7bff\",\n  accentEnd = \"#7fb3ff\",\n  className,\n  style,\n  ...rest\n}: TransitionLiquidWipeProps) {\n  const value = useSwap(active, defaultActive, onActiveChange, autoPlay, interval);\n  const kids = React.Children.toArray(children);\n  const a = from ?? kids[0] ?? <Scene tone=\"linear-gradient(150deg, #b8f2d8, #6fd6b0)\" kicker=\"Colorway\" title=\"Mint\" dark />;\n  const b = to ?? kids[1] ?? <Scene tone=\"linear-gradient(150deg, #ffb4a2, #ff7a6b)\" kicker=\"Colorway\" title=\"Coral\" dark />;\n  const clipTo = React.useMemo(() => edge(direction, 0, 620, 10), [direction]);\n  const clipRim = React.useMemo(() => edge(direction, 0.08, 760, 14), [direction]);\n\n  const vars = {\n    \"--hb-vj10-d\": `${duration}ms`,\n    \"--hb-vj10-a\": accent,\n    \"--hb-vj10-b\": accentEnd,\n    \"--hb-vj10-ang\": direction === \"up\" ? \"0deg\" : direction === \"left\" ? \"270deg\" : \"90deg\",\n  } as React.CSSProperties;\n\n  return (\n    <div className={[\"hb-vj10\", className].filter(Boolean).join(\" \")} style={{ ...vars, ...style }} data-active={value} {...rest}>\n      <style href=\"hb-transition-liquid-wipe\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vj10-l\" aria-hidden={value} inert={value}>{a}</div>\n      <div className=\"hb-vj10-rim\" style={{ clipPath: clipRim }} aria-hidden=\"true\" />\n      <div className=\"hb-vj10-l hb-vj10-to\" style={{ clipPath: clipTo }} aria-hidden={!value} inert={!value}>{b}</div>\n    </div>\n  );\n}\n"
    }
  ]
}