import { defineComponent, ref, computed, createVNode, Fragment } from 'vue';
import '../../../utils/index.mjs';
import '../../../vue-components/index.mjs';
import { Tooltip } from '../../tooltip/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import { popoverProps } from './props.mjs';
import { initDefaultProps } from '../../../utils/vue/initDefaultProps.mjs';
import { tooltipDefaultProps } from '../../tooltip/src/props.mjs';
import { devWarning } from '../../../utils/log.mjs';
import { filterEmpty } from '../../../utils/vue/props.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { omit } from '../../../utils/lang/omit.mjs';
import { getTransitionName } from '../../../vue-components/transition/src/transition.mjs';

var APopover = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "APopover",
  inheritAttrs: false,
  props: initDefaultProps(popoverProps(), {
    ...tooltipDefaultProps(),
    trigger: "hover",
    placement: "top",
    mouseEnterDelay: 0.1,
    mouseLeaveDelay: 0.1
  }),
  setup(props, {
    expose,
    slots,
    attrs
  }) {
    const tooltipRef = ref();
    devWarning(props.visible === void 0, "popover", "`visible` will be removed in next major version, please use `open` instead.");
    expose({
      getPopupDomNode: () => {
        var _a, _b;
        return (_b = (_a = tooltipRef.value) == null ? void 0 : _a.getPopupDomNode) == null ? void 0 : _b.call(_a);
      }
    });
    const {
      prefixCls,
      configProvider
    } = useConfigInject("popover", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const rootPrefixCls = computed(() => configProvider.getPrefixCls());
    const getOverlay = () => {
      var _a, _b;
      const {
        title = filterEmpty((_a = slots.title) == null ? void 0 : _a.call(slots)),
        content = filterEmpty((_b = slots.content) == null ? void 0 : _b.call(slots))
      } = props;
      const hasTitle = !!(Array.isArray(title) ? title.length : title);
      const hasContent = !!(Array.isArray(content) ? content.length : title);
      if (!hasTitle && !hasContent)
        return null;
      return createVNode(Fragment, null, [hasTitle && createVNode("div", {
        "class": `${prefixCls.value}-title`
      }, [title]), createVNode("div", {
        "class": `${prefixCls.value}-inner-content`
      }, [content])]);
    };
    return () => {
      const overlayCls = classNames(props.overlayClassName, hashId.value);
      return wrapSSR(createVNode(Tooltip, {
        ...omit(props, ["title", "content"]),
        ...attrs,
        "prefixCls": prefixCls.value,
        "ref": tooltipRef,
        "overlayClassName": overlayCls,
        "transitionName": getTransitionName(rootPrefixCls.value, "zoom-big", props.transitionName),
        "data-popover-inject": true
      }, {
        title: getOverlay,
        default: slots.default
      }));
    };
  }
});

export { APopover as default };
//# sourceMappingURL=Popover.mjs.map
