import { defineComponent, ref, inject, computed, onBeforeUnmount, unref, createBlock, watch, openBlock, Teleport, createVNode, Transition, withCtx, withDirectives, createCommentVNode, mergeProps, renderSlot, vShow } from "vue";
import { onClickOutside as q$1 } from "../../../../../@vueuse/core/index.mjs";
import { TOOLTIP_INJECTION_KEY as o } from "./constants.mjs";
import { useTooltipContentProps as a } from "./content.mjs";
import c from "../../../_virtual/plugin-vue_export-helper.mjs";
import { usePopperContainerId as a$1 } from "../../../hooks/use-popper-container/index.mjs";
import { useNamespace as q } from "../../../hooks/use-namespace/index.mjs";
import { composeEventHandlers as u } from "../../../utils/dom/event.mjs";
import Ae from "../../popper/src/content.mjs";
const se = defineComponent({
  name: "ElTooltipContent",
  inheritAttrs: false
}), ie = /* @__PURE__ */ defineComponent({
  ...se,
  props: a,
  setup(P, { expose: w }) {
    const n = P, { selector: B } = a$1(), S = q("tooltip"), l = ref(null), u$1 = ref(false), {
      controlled: f,
      id: N,
      open: a2,
      trigger: i,
      onClose: s,
      onOpen: O,
      onShow: L,
      onHide: A,
      onBeforeShow: d,
      onBeforeHide: c2
    } = inject(o, void 0), H = computed(() => n.transition || `${S.namespace.value}-fade-in-linear`), I = computed(() => n.persistent);
    onBeforeUnmount(() => {
      u$1.value = true;
    });
    const R = computed(() => unref(I) ? true : unref(a2)), v = computed(() => n.disabled ? false : unref(a2)), _ = computed(() => n.appendTo || B.value), $ = computed(() => {
      var e;
      return (e = n.style) != null ? e : {};
    }), M = computed(() => !unref(a2)), z = () => {
      A();
    }, m = () => {
      if (unref(f))
        return true;
    }, V = u(m, () => {
      n.enterable && unref(i) === "hover" && O();
    }), D = u(m, () => {
      unref(i) === "hover" && s();
    }), j = () => {
      var e, r;
      (r = (e = l.value) == null ? void 0 : e.updatePopper) == null || r.call(e), d == null || d();
    }, J = () => {
      c2 == null || c2();
    }, K = () => {
      L(), p = q$1(computed(() => {
        var e;
        return (e = l.value) == null ? void 0 : e.popperContentRef;
      }), () => {
        if (unref(f))
          return;
        unref(i) !== "hover" && s();
      });
    }, U = () => {
      n.virtualTriggering || s();
    };
    let p;
    return watch(() => unref(a2), (e) => {
      e || p == null || p();
    }, {
      flush: "post"
    }), watch(() => n.content, () => {
      var e, r;
      (r = (e = l.value) == null ? void 0 : e.updatePopper) == null || r.call(e);
    }), w({
      contentRef: l
    }), (e, r) => (openBlock(), createBlock(Teleport, {
      disabled: !e.teleported,
      to: unref(_)
    }, [
      createVNode(Transition, {
        name: unref(H),
        onAfterLeave: z,
        onBeforeEnter: j,
        onAfterEnter: K,
        onBeforeLeave: J
      }, {
        default: withCtx(() => [
          unref(R) ? withDirectives((openBlock(), createBlock(unref(Ae), mergeProps({
            key: 0,
            id: unref(N),
            ref_key: "contentRef",
            ref: l
          }, e.$attrs, {
            "aria-label": e.ariaLabel,
            "aria-hidden": unref(M),
            "boundaries-padding": e.boundariesPadding,
            "fallback-placements": e.fallbackPlacements,
            "gpu-acceleration": e.gpuAcceleration,
            offset: e.offset,
            placement: e.placement,
            "popper-options": e.popperOptions,
            strategy: e.strategy,
            effect: e.effect,
            enterable: e.enterable,
            pure: e.pure,
            "popper-class": e.popperClass,
            "popper-style": [e.popperStyle, unref($)],
            "reference-el": e.referenceEl,
            "trigger-target-el": e.triggerTargetEl,
            visible: unref(v),
            "z-index": e.zIndex,
            onMouseenter: unref(V),
            onMouseleave: unref(D),
            onBlur: U,
            onClose: unref(s)
          }), {
            default: withCtx(() => [
              u$1.value ? createCommentVNode("v-if", true) : renderSlot(e.$slots, "default", { key: 0 })
            ]),
            _: 3
          }, 16, ["id", "aria-label", "aria-hidden", "boundaries-padding", "fallback-placements", "gpu-acceleration", "offset", "placement", "popper-options", "strategy", "effect", "enterable", "pure", "popper-class", "popper-style", "reference-el", "trigger-target-el", "visible", "z-index", "onMouseenter", "onMouseleave", "onClose"])), [
            [vShow, unref(v)]
          ]) : createCommentVNode("v-if", true)
        ]),
        _: 3
      }, 8, ["name"])
    ], 8, ["disabled", "to"]));
  }
});
var he = /* @__PURE__ */ c(ie, [["__file", "content.vue"]]);
export {
  he as default
};
