// axi0 Motion 0.2.0: Water ripple. Water ripples spread from the pointer, warp the picture under them and leave a wake that fades.
// Generated from src/water-ripple/meta.json by motion-pack: a thin wrapper. The loader (motion.js) must be on the page once;
// it starts the effect on the element this renders. Options left out keep the effect's own defaults.
import { createElement } from "react";
import type { HTMLAttributes, ReactNode } from "react";

export interface WaterRippleProps extends HTMLAttributes<HTMLElement> {
  /** An image under the water (same origin); empty draws a pool floor (default auto) */
  src?: string;
  /** How hard the pointer pushes the water (default 1) */
  strength?: number;
  /** How long waves last (default 0.985) */
  damping?: number;
  /** Raindrops per second while idle (default 1) */
  rain?: number;
  /** Colors, comma separated (empty: the palette for the page's theme) (default auto) */
  colors?: string;
  /** Background color (empty: the theme's) (default auto) */
  background?: string;
  /** How fast it moves (default 1) */
  speed?: number;
  /** Light or dark palette (auto: from the page behind it) (default "auto") */
  theme?: "auto" | "light" | "dark";
  /** Fill the nearest positioned parent, behind its content (default false) */
  cover?: boolean;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));
// a present attribute is on; "false" turns off an option that is on by default
const flag = (v: boolean | undefined, d: boolean) => (v === undefined || v === d ? undefined : v ? "" : "false");

export function WaterRipple({ src, strength, damping, rain, colors, background, speed, theme, cover, ...rest }: WaterRippleProps) {
  return createElement("axi0-water-ripple", { ...rest, "src": s(src), "strength": s(strength), "damping": s(damping), "rain": s(rain), "colors": s(colors), "background": s(background), "speed": s(speed), "theme": s(theme), "cover": flag(cover, false) });
}

export default WaterRipple;
