'use strict';

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

var vue = require('vue');
var index = require('../../_util/vue-types/index.js');
require('../../vc-trigger/index.js');
var index$1 = require('../../_util/props-util/index.js');
var Content = require('./Content.js');
var placements = require('./placements.js');
var Trigger = require('../../vc-trigger/Trigger.js');

function noop() {
}
var Tooltip = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Tooltip",
  inheritAttrs: false,
  props: {
    trigger: index.default.any.def(["hover"]),
    defaultVisible: {
      type: Boolean,
      default: void 0
    },
    visible: {
      type: Boolean,
      default: void 0
    },
    placement: index.default.string.def("right"),
    transitionName: String,
    animation: index.default.any,
    afterVisibleChange: index.default.func.def(() => {
    }),
    overlayStyle: {
      type: Object,
      default: void 0
    },
    overlayClassName: String,
    prefixCls: index.default.string.def("rc-tooltip"),
    mouseEnterDelay: index.default.number.def(0.1),
    mouseLeaveDelay: index.default.number.def(0.1),
    getPopupContainer: Function,
    destroyTooltipOnHide: {
      type: Boolean,
      default: false
    },
    align: index.default.object.def(() => ({})),
    arrowContent: index.default.any.def(null),
    tipId: String,
    builtinPlacements: index.default.object,
    overlayInnerStyle: {
      type: Object,
      default: void 0
    },
    popupVisible: {
      type: Boolean,
      default: void 0
    },
    onVisibleChange: Function,
    onPopupAlign: Function
  },
  setup(props, {
    slots,
    attrs,
    expose
  }) {
    const triggerDOM = vue.shallowRef();
    const getPopupElement = () => {
      const {
        prefixCls,
        tipId,
        overlayInnerStyle
      } = props;
      return [vue.createVNode("div", {
        "class": `${prefixCls}-arrow`,
        "key": "arrow"
      }, [index$1.getPropsSlot(slots, props, "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;
      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;
      const extraProps = {
        ...restProps
      };
      if (props.visible !== void 0)
        extraProps.popupVisible = props.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.onVisibleChange || noop,
        onPopupAlign: props.onPopupAlign || noop,
        ref: triggerDOM,
        popup: getPopupElement()
      };
      return vue.createVNode(Trigger.default, triggerProps, {
        default: slots.default
      });
    };
  }
});

exports.default = Tooltip;
//# sourceMappingURL=Tooltip.js.map
