import { defineComponent, ref, computed, createVNode, Fragment, mergeProps } from 'vue';
import Tooltip from '../tooltip/index.mjs';
import abstractTooltipProps from '../tooltip/abstractTooltipProps.mjs';
import { filterEmpty } from '../_util/props-util/index.mjs';
import { anyType, withInstall } from '../_util/type.mjs';
import '../hooks/index.mjs';
import omit from '../_util/omit.mjs';
import { getTransitionName } from '../_util/components/transition.mjs';
import { tooltipDefaultProps } from '../tooltip/Tooltip.mjs';
import classNames from '../_util/classNames.mjs';
import warning from '../_util/warning.mjs';
import useStyle from './style/index.mjs';
import initDefaultProps from '../_util/props-util/initDefaultProps.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

const popoverProps = () => ({
  ...abstractTooltipProps(),
  content: anyType(),
  title: anyType()
});
const Popover = /* @__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();
    warning(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, mergeProps(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
      }));
    };
  }
});
var Popover$1 = withInstall(Popover);

export { Popover$1 as default, popoverProps };
//# sourceMappingURL=index.mjs.map
