'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
var Trigger = require('../../vc-trigger/src/Trigger.cjs');
var placements = require('./placements.cjs');
var Content = require('./Content.cjs');
var vueTypes = require('../../../utils/vue/vueTypes.cjs');
var props = require('../../../utils/vue/props.cjs');

function noop() {
}
var VcTooltip = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Tooltip",
  inheritAttrs: false,
  props: {
    trigger: vueTypes.default.any.def(["hover"]),
    defaultVisible: {
      type: Boolean,
      default: void 0
    },
    visible: {
      type: Boolean,
      default: void 0
    },
    placement: vueTypes.default.string.def("right"),
    transitionName: String,
    animation: vueTypes.default.any,
    afterVisibleChange: vueTypes.default.func.def(() => {
    }),
    overlayStyle: {
      type: Object,
      default: void 0
    },
    overlayClassName: String,
    prefixCls: vueTypes.default.string.def("rc-tooltip"),
    mouseEnterDelay: vueTypes.default.number.def(0.1),
    mouseLeaveDelay: vueTypes.default.number.def(0.1),
    getPopupContainer: Function,
    destroyTooltipOnHide: {
      type: Boolean,
      default: false
    },
    align: vueTypes.default.object.def(() => ({})),
    arrowContent: vueTypes.default.any.def(null),
    tipId: String,
    builtinPlacements: vueTypes.default.object,
    overlayInnerStyle: {
      type: Object,
      default: void 0
    },
    popupVisible: {
      type: Boolean,
      default: void 0
    },
    onVisibleChange: Function,
    onPopupAlign: Function
  },
  setup(props$1, {
    slots,
    attrs,
    expose
  }) {
    const triggerDOM = vue.shallowRef();
    const getPopupElement = () => {
      const {
        prefixCls,
        tipId,
        overlayInnerStyle
      } = props$1;
      return [vue.createVNode("div", {
        "class": `${prefixCls}-arrow`,
        "key": "arrow"
      }, [props.getPropsSlot(slots, props$1, "arrowContent")]), vue.createVNode(Content.default, {
        "key": "content",
        "prefixCls": prefixCls,
        "id": tipId,
        "overlayInnerStyle": overlayInnerStyle
      }, {
        overlay: slots.overlay
      })];
    };
    const getPopupDomNode = () => {
      return triggerDOM.value.getPopupDomNode();
    };
    expose({
      getPopupDomNode,
      triggerDOM,
      forcePopupAlign: () => {
        var _a;
        return (_a = triggerDOM.value) == null ? void 0 : _a.forcePopupAlign();
      }
    });
    const destroyTooltip = vue.shallowRef(false);
    const autoDestroy = vue.shallowRef(false);
    vue.watchEffect(() => {
      const {
        destroyTooltipOnHide
      } = props$1;
      if (typeof destroyTooltipOnHide === "boolean") {
        destroyTooltip.value = destroyTooltipOnHide;
      } else if (destroyTooltipOnHide && typeof destroyTooltipOnHide === "object") {
        const {
          keepParent
        } = destroyTooltipOnHide;
        destroyTooltip.value = keepParent === true;
        autoDestroy.value = keepParent === false;
      }
    });
    return () => {
      const {
        overlayClassName,
        trigger,
        mouseEnterDelay,
        mouseLeaveDelay,
        overlayStyle,
        prefixCls,
        afterVisibleChange,
        transitionName,
        animation,
        placement,
        align,
        destroyTooltipOnHide,
        defaultVisible,
        ...restProps
      } = props$1;
      const extraProps = {
        ...restProps
      };
      if (props$1.visible !== void 0)
        extraProps.popupVisible = props$1.visible;
      const triggerProps = {
        popupClassName: overlayClassName,
        prefixCls,
        action: trigger,
        builtinPlacements: placements.placements,
        popupPlacement: placement,
        popupAlign: align,
        afterPopupVisibleChange: afterVisibleChange,
        popupTransitionName: transitionName,
        popupAnimation: animation,
        defaultPopupVisible: defaultVisible,
        destroyPopupOnHide: destroyTooltip.value,
        autoDestroy: autoDestroy.value,
        mouseLeaveDelay,
        popupStyle: overlayStyle,
        mouseEnterDelay,
        ...extraProps,
        ...attrs,
        onPopupVisibleChange: props$1.onVisibleChange || noop,
        onPopupAlign: props$1.onPopupAlign || noop,
        ref: triggerDOM,
        popup: getPopupElement()
      };
      return vue.createVNode(Trigger.default, triggerProps, {
        default: slots.default
      });
    };
  }
});

exports.default = VcTooltip;
//# sourceMappingURL=Tooltip.cjs.map
