{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "wave-text",
  "title": "Wave Text",
  "description": "Bands of colour washing through text like a swell, on one CSS animation.",
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/use-entrance"
  ],
  "files": [
    {
      "path": "registry/default/ui/wave-text.tsx",
      "content": "\"use client\";\n\nimport { useMemo, type ComponentProps, type CSSProperties, type Ref } from \"react\";\n\nimport { useEntrance, type EntranceTrigger } from \"@/registry/default/hooks/use-entrance\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\nfunction mergeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n  return (node: T | null) => {\n    for (const ref of refs) {\n      if (typeof ref === \"function\") ref(node);\n      else if (ref) ref.current = node;\n    }\n  };\n}\n\n// Registering the offset as a number lets CSS animate it smoothly; an\n// unregistered custom property would jump from start to end instead.\nif (typeof CSS !== \"undefined\" && \"registerProperty\" in CSS) {\n  try {\n    CSS.registerProperty({\n      name: \"--wave-text-offset\",\n      syntax: \"<number>\",\n      inherits: false,\n      initialValue: \"-25\",\n    });\n  } catch {\n    // Already registered by another copy of the component.\n  }\n}\n\nconst COLORS = [\"#d9b06a\", \"#6fb3c2\", \"#e07a5f\", \"#81b29a\", \"#f2cc8f\", \"#8d7fc9\"];\n\ntype WaveTextTag = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"p\" | \"span\" | \"div\";\n\ninterface WaveTextProps extends Omit<ComponentProps<\"p\">, \"color\"> {\n  as?: WaveTextTag;\n  /** Colours of the bands, in order. */\n  colors?: string[];\n  /** The colour of the text between waves. Defaults to the text colour. */\n  base?: string;\n  /** Bands ripple out from below the text (radial) or rise straight up (linear). */\n  shape?: \"radial\" | \"linear\";\n  /** How many bands one wave carries. */\n  bands?: number;\n  /** Width of each band, in percent of the text box. */\n  bandWidth?: number;\n  /**\n   * Room below the text where the ripples start, in percent of the\n   * container's width (padding percentages follow the width). Radial only.\n   */\n  depth?: number;\n  /** Seconds for one wave to pass. */\n  duration?: number;\n  /** Keep sending waves, instead of one. */\n  repeat?: boolean;\n  /** Wait before the first wave, in ms. */\n  delay?: number;\n  /** \"load\" plays on first paint with CSS alone; \"in-view\" when the text scrolls into view. */\n  trigger?: EntranceTrigger;\n  /** In-view: play the first time only. */\n  once?: boolean;\n  /** Takes over from `trigger`: `false` holds the wave back, `true` sends it. */\n  play?: boolean;\n}\n\n/**\n * Bands of colour that wash through text like a swell, rippling out from\n * below it or rising straight up. It is a gradient clipped to the text,\n * moved by one CSS animation of a registered custom property: no canvas,\n * no per-frame JavaScript. The text rests in its own colour, repeating\n * waves pause off screen, and with `prefers-reduced-motion` it stays still.\n *\n * @example\n * <WaveText as=\"h2\" className=\"text-6xl font-semibold\" repeat>\n *   High tide\n * </WaveText>\n */\nfunction WaveText({\n  as: Tag = \"span\",\n  colors = COLORS,\n  base = \"currentColor\",\n  shape = \"radial\",\n  bands = 8,\n  bandWidth = 4,\n  depth = 20,\n  duration = 3.75,\n  repeat = false,\n  delay = 0,\n  trigger = \"load\",\n  once = true,\n  play,\n  className,\n  style,\n  ref,\n  children,\n  ...props\n}: WaveTextProps) {\n  const [observe, phase, inView] = useEntrance<HTMLElement>({ trigger, once, play });\n  const mergedRef = useMemo(() => mergeRefs(ref, observe), [ref, observe]);\n\n  const gradient = useMemo(() => {\n    const palette = colors.length > 0 ? colors : COLORS;\n    const at = (offset: number) => `calc((var(--wave-text-offset) + ${offset}) * 1%)`;\n    const stops = [`${base} ${at(0)}`];\n    for (let band = 0; band < bands; band++) {\n      stops.push(`${palette[band % palette.length]} ${at((band + 2) * bandWidth)}`);\n    }\n    stops.push(`${base} ${at((bands + 2) * bandWidth)}`);\n    return shape === \"radial\"\n      ? `radial-gradient(circle at 50% 100%, ${stops.join(\", \")})`\n      : `linear-gradient(0deg, ${stops.join(\", \")})`;\n  }, [colors, base, bands, bandWidth, shape]);\n\n  const moving = phase !== \"static\";\n  const lift = shape === \"radial\" ? depth : 0;\n\n  return (\n    <Tag\n      ref={mergedRef as Ref<never>}\n      data-slot=\"wave-text\"\n      data-state={phase}\n      className={cn(\n        \"inline-block bg-clip-text [-webkit-text-fill-color:transparent]\",\n        moving && \"motion-safe:animate-wave-text\",\n        className\n      )}\n      style={\n        {\n          // A resting value for the moment before the property is registered,\n          // so the gradient is valid and the text visible from the first paint.\n          // The animation overrides it while it runs.\n          \"--wave-text-offset\": -25,\n          backgroundImage: gradient,\n          // Extra room below the text puts the ripples' centre under the baseline.\n          paddingBottom: lift ? `${lift}%` : undefined,\n          marginBottom: lift ? `-${lift}%` : undefined,\n          ...(moving\n            ? {\n                animationDuration: `${duration}s`,\n                animationDelay: `${delay}ms`,\n                animationIterationCount: repeat ? \"infinite\" : 1,\n                animationPlayState: phase === \"armed\" || (repeat && !inView) ? \"paused\" : undefined,\n              }\n            : null),\n          ...style,\n        } as CSSProperties\n      }\n      {...props}\n    >\n      {children}\n    </Tag>\n  );\n}\n\nexport { WaveText, type WaveTextProps };\n",
      "type": "registry:ui"
    }
  ],
  "tailwind": {
    "config": {
      "theme": {
        "extend": {
          "keyframes": {
            "wave-text": {
              "from": {
                "--wave-text-offset": "-25"
              },
              "to": {
                "--wave-text-offset": "200"
              }
            }
          },
          "animation": {
            "wave-text": "wave-text 3.75s linear both"
          }
        }
      }
    }
  },
  "cssVars": {
    "theme": {
      "animate-wave-text": "wave-text 3.75s linear both"
    }
  },
  "css": {
    "@keyframes wave-text": {
      "from": {
        "--wave-text-offset": "-25"
      },
      "to": {
        "--wave-text-offset": "200"
      }
    }
  },
  "categories": [
    "text"
  ],
  "type": "registry:ui"
}