{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"mask-wipe","type":"registry:ui","title":"Mask Wipe","description":"A big heading wiped into view by a feathered mask sweep, with a gradient or photo flowing through the letters.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/mask-wipe.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type CSSProperties } from \"react\";\n\nconst css = `\n.mh-fill{position:absolute;inset:0;color:transparent;-webkit-background-clip:text;background-clip:text;\n-webkit-mask-image:linear-gradient(100deg,#000 40%,transparent 60%);mask-image:linear-gradient(100deg,#000 40%,transparent 60%);\n-webkit-mask-size:300% 100%;mask-size:300% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:100% 0;mask-position:100% 0}\n.mh-fill[data-state=shown]{animation:mh-reveal var(--mh-r) cubic-bezier(.65,0,.35,1) forwards,var(--mh-flow)}\n.mh-fill[data-state=loop]{animation:mh-loop calc(var(--mh-r) * 2.6) cubic-bezier(.65,0,.35,1) infinite alternate,var(--mh-flow)}\n@keyframes mh-reveal{to{-webkit-mask-position:0 0;mask-position:0 0}}\n@keyframes mh-loop{0%,12%{-webkit-mask-position:100% 0;mask-position:100% 0}62%,100%{-webkit-mask-position:0 0;mask-position:0 0}}\n@keyframes mh-slide{to{background-position:200% 0}}\n@keyframes mh-pan{from{background-position:0% 50%}to{background-position:100% 50%}}\n@media (prefers-reduced-motion:reduce){.mh-fill[data-state]{animation:none;-webkit-mask-image:none;mask-image:none}}\n`;\n\nexport interface MaskWipeProps {\n  text?: string;\n  /** Gradient stops flowing through the letters. */\n  colors?: string[];\n  /** Image URL to fill the letters with instead of the gradient. */\n  image?: string;\n  /** Seconds for the reveal sweep. */\n  revealDuration?: number;\n  /** Seconds per gradient (or image pan) cycle. */\n  flowDuration?: number;\n  /** Reveal once on view, or sweep in and out forever. */\n  trigger?: \"view\" | \"loop\";\n  /** Faint ghost of the letters before they are revealed. */\n  outline?: boolean;\n  as?: \"h1\" | \"h2\" | \"h3\" | \"p\" | \"span\" | \"div\";\n  className?: string;\n}\n\nexport function MaskWipe({\n  text = \"Made to be seen\",\n  colors = [\"#bef264\", \"#22d3ee\", \"#a78bfa\", \"#f472b6\"],\n  image,\n  revealDuration = 1.8,\n  flowDuration = 6,\n  trigger = \"view\",\n  outline = true,\n  as: Tag = \"h2\",\n  className,\n}: MaskWipeProps) {\n  const ref = useRef<HTMLElement>(null);\n  const [shown, setShown] = useState(false);\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          setShown(true);\n          io.disconnect();\n        }\n      },\n      { threshold: 0.3 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  const stops = colors.length ? [...colors, colors[0]] : [\"currentColor\", \"currentColor\"];\n  const fill: CSSProperties = image\n    ? { backgroundImage: `url(\"${image}\")`, backgroundSize: \"cover\", backgroundPosition: \"0% 50%\" }\n    : { backgroundImage: `linear-gradient(90deg, ${stops.join(\", \")})`, backgroundSize: \"200% 100%\", backgroundRepeat: \"repeat\" };\n  const flow = image ? `mh-pan ${flowDuration}s ease-in-out infinite alternate` : `mh-slide ${flowDuration}s linear infinite`;\n\n  return (\n    <Tag ref={ref as never} className={className}>\n      <style href=\"mask-wipe\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"sr-only\">{text}</span>\n      <span aria-hidden style={{ position: \"relative\", display: \"inline-block\" }}>\n        <span\n          style={{\n            WebkitTextFillColor: outline ? \"color-mix(in oklab, currentColor 9%, transparent)\" : \"transparent\",\n          }}\n        >\n          {text}\n        </span>\n        <span\n          key={`${trigger}|${revealDuration}`}\n          className=\"mh-fill\"\n          data-state={shown ? (trigger === \"loop\" ? \"loop\" : \"shown\") : undefined}\n          style={{ ...fill, \"--mh-r\": `${revealDuration}s`, \"--mh-flow\": flow } as CSSProperties}\n        >\n          {text}\n        </span>\n      </span>\n    </Tag>\n  );\n}\n"}]}