import { defineComponent, getCurrentInstance, computed, onMounted, watch, nextTick, onBeforeUnmount } from 'vue';
import classNames from '../_util/classNames.mjs';
import { findDOMNode } from '../_util/props-util/index.mjs';
import isVisible from '../vc-util/Dom/isVisible.mjs';
import '../hooks/index.mjs';
import useStyle from './style.mjs';
import useWave from './useWave.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

var Wave = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Wave",
  props: {
    disabled: Boolean
  },
  setup(props, {
    slots
  }) {
    const instance = getCurrentInstance();
    const {
      prefixCls
    } = useConfigInject("wave", props);
    const [, hashId] = useStyle(prefixCls);
    const showWave = useWave(instance, computed(() => classNames(prefixCls.value, hashId.value)));
    let onClick;
    const clear = () => {
      const node = findDOMNode(instance);
      node.removeEventListener("click", onClick, true);
    };
    onMounted(() => {
      watch(() => props.disabled, () => {
        clear();
        nextTick(() => {
          const node = findDOMNode(instance);
          if (!node || node.nodeType !== 1 || props.disabled)
            return;
          const onClick2 = (e) => {
            if (e.target.tagName === "INPUT" || !isVisible(e.target) || !node.getAttribute || node.getAttribute("disabled") || node.disabled || node.className.includes("disabled") || node.className.includes("-leave"))
              return;
            showWave();
          };
          node.addEventListener("click", onClick2, true);
        });
      }, {
        immediate: true,
        flush: "post"
      });
    });
    onBeforeUnmount(() => {
      clear();
    });
    return () => {
      var _a;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots)[0];
      return children;
    };
  }
});

export { Wave as default };
//# sourceMappingURL=index.mjs.map
