// axi0 Motion 0.2.0: Lightning. A crackling, branching bolt bends toward the pointer and strikes where you click.
// Generated from src/lightning/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 LightningProps extends HTMLAttributes<HTMLElement> {
  /** the bolt's color (blue white, deep blue on light pages) (default auto) */
  color?: string;
  /** how many times a second the bolt changes shape (default 12) */
  rate?: number;
  /** how fast it flickers (default 1) */
  speed?: number;
  /** 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 Lightning({ color, rate, speed, cover, ...rest }: LightningProps) {
  return createElement("axi0-lightning", { ...rest, "color": s(color), "rate": s(rate), "speed": s(speed), "cover": flag(cover, false) });
}

export default Lightning;
