import v from "../../../../classnames/index.mjs";
import { supportRef as b, composeRef as E } from "../../../../rc-util/es/ref.mjs";
import C from "../../../../rc-util/es/Dom/isVisible.mjs";
import c, { useContext as N, useRef as g } from "react";
import "../../config-provider/index.mjs";
import { cloneElement as x } from "../reactNode.mjs";
import R from "./style.mjs";
import W from "./useWave.mjs";
import { ConfigContext as h } from "../../config-provider/context.mjs";
const l = (a) => {
  const {
    children: t,
    disabled: r,
    component: m
  } = a, {
    getPrefixCls: f
  } = N(h), o = g(null), s = f("wave"), [, u] = R(s), d = W(o, v(s, u), m);
  if (c.useEffect(() => {
    const e = o.current;
    if (!e || e.nodeType !== 1 || r)
      return;
    const n = (i) => {
      !C(i.target) || // No need wave
      !e.getAttribute || e.getAttribute("disabled") || e.disabled || e.className.includes("disabled") || e.className.includes("-leave") || d(i);
    };
    return e.addEventListener("click", n, !0), () => {
      e.removeEventListener("click", n, !0);
    };
  }, [r]), !/* @__PURE__ */ c.isValidElement(t))
    return t ?? null;
  const p = b(t) ? E(t.ref, o) : o;
  return x(t, {
    ref: p
  });
};
process.env.NODE_ENV !== "production" && (l.displayName = "Wave");
const O = l;
export {
  O as default
};
