"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const index$3 = require("../../popper/index.js");
const constants = require("./constants.js");
const tooltip = require("./tooltip.js");
const trigger2 = require("./trigger2.js");
const content2 = require("./content2.js");
const pluginVue_exportHelper = require("../../../_virtual/plugin-vue_export-helper.js");
const index = require("../../../hooks/use-popper-container/index.js");
const index$1 = require("../../../hooks/use-id/index.js");
const index$2 = require("../../../hooks/use-delayed-toggle/index.js");
const types = require("../../../utils/types.js");
const arrow2 = require("../../popper/src/arrow2.js");
const _ = ["innerHTML"], x = { key: 1 }, ee = Vue.defineComponent({
  name: "ElTooltip"
}), oe = /* @__PURE__ */ Vue.defineComponent({
  ...ee,
  props: tooltip.useTooltipProps,
  emits: tooltip.tooltipEmits,
  setup(R, { expose: A, emit: a }) {
    const o = R;
    index.usePopperContainer();
    const P = index$1.useId(), f = Vue.ref(), d = Vue.ref(), v = () => {
      var e;
      const t = Vue.unref(f);
      t && ((e = t.popperInstanceRef) == null || e.update());
    }, r = Vue.ref(false), n = Vue.ref(), { show: I, hide: g, hasUpdateHandler: O } = tooltip.useTooltipModelToggle({
      indicator: r,
      toggleReason: n
    }), { onOpen: u, onClose: m } = index$2.useDelayedToggle({
      showAfter: Vue.toRef(o, "showAfter"),
      hideAfter: Vue.toRef(o, "hideAfter"),
      autoClose: Vue.toRef(o, "autoClose"),
      open: I,
      close: g
    }), B = Vue.computed(() => types.isBoolean(o.visible) && !O.value);
    Vue.provide(constants.TOOLTIP_INJECTION_KEY, {
      controlled: B,
      id: P,
      open: Vue.readonly(r),
      trigger: Vue.toRef(o, "trigger"),
      onOpen: (e) => {
        u(e);
      },
      onClose: (e) => {
        m(e);
      },
      onToggle: (e) => {
        Vue.unref(r) ? m(e) : u(e);
      },
      onShow: () => {
        a("show", n.value);
      },
      onHide: () => {
        a("hide", n.value);
      },
      onBeforeShow: () => {
        a("before-show", n.value);
      },
      onBeforeHide: () => {
        a("before-hide", n.value);
      },
      updatePopper: v
    }), Vue.watch(() => o.disabled, (e) => {
      e && r.value && (r.value = false);
    });
    const H = (e) => {
      var t, h;
      const b = (h = (t = d.value) == null ? void 0 : t.contentRef) == null ? void 0 : h.popperContentRef, S = (e == null ? void 0 : e.relatedTarget) || document.activeElement;
      return b && b.contains(S);
    };
    return Vue.onDeactivated(() => r.value && g()), A({
      popperRef: f,
      contentRef: d,
      isFocusInsideContent: H,
      updatePopper: v,
      onOpen: u,
      onClose: m,
      hide: g
    }), (e, t) => (Vue.openBlock(), Vue.createBlock(Vue.unref(index$3.ElPopper), {
      ref_key: "popperRef",
      ref: f,
      role: e.role
    }, {
      default: Vue.withCtx(() => [
        Vue.createVNode(trigger2.default, {
          disabled: e.disabled,
          trigger: e.trigger,
          "trigger-keys": e.triggerKeys,
          "virtual-ref": e.virtualRef,
          "virtual-triggering": e.virtualTriggering
        }, {
          default: Vue.withCtx(() => [
            e.$slots.default ? Vue.renderSlot(e.$slots, "default", { key: 0 }) : Vue.createCommentVNode("v-if", true)
          ]),
          _: 3
        }, 8, ["disabled", "trigger", "trigger-keys", "virtual-ref", "virtual-triggering"]),
        Vue.createVNode(content2.default, {
          ref_key: "contentRef",
          ref: d,
          "aria-label": e.ariaLabel,
          "boundaries-padding": e.boundariesPadding,
          content: e.content,
          disabled: e.disabled,
          effect: e.effect,
          enterable: e.enterable,
          "fallback-placements": e.fallbackPlacements,
          "hide-after": e.hideAfter,
          "gpu-acceleration": e.gpuAcceleration,
          offset: e.offset,
          persistent: e.persistent,
          "popper-class": e.popperClass,
          "popper-style": e.popperStyle,
          placement: e.placement,
          "popper-options": e.popperOptions,
          pure: e.pure,
          "raw-content": e.rawContent,
          "reference-el": e.referenceEl,
          "trigger-target-el": e.triggerTargetEl,
          "show-after": e.showAfter,
          strategy: e.strategy,
          teleported: e.teleported,
          transition: e.transition,
          "virtual-triggering": e.virtualTriggering,
          "z-index": e.zIndex,
          "append-to": e.appendTo
        }, {
          default: Vue.withCtx(() => [
            Vue.renderSlot(e.$slots, "content", {}, () => [
              e.rawContent ? (Vue.openBlock(), Vue.createElementBlock("span", {
                key: 0,
                innerHTML: e.content
              }, null, 8, _)) : (Vue.openBlock(), Vue.createElementBlock("span", x, Vue.toDisplayString(e.content), 1))
            ]),
            e.showArrow ? (Vue.openBlock(), Vue.createBlock(Vue.unref(arrow2.default), {
              key: 0,
              "arrow-offset": e.arrowOffset
            }, null, 8, ["arrow-offset"])) : Vue.createCommentVNode("v-if", true)
          ]),
          _: 3
        }, 8, ["aria-label", "boundaries-padding", "content", "disabled", "effect", "enterable", "fallback-placements", "hide-after", "gpu-acceleration", "offset", "persistent", "popper-class", "popper-style", "placement", "popper-options", "pure", "raw-content", "reference-el", "trigger-target-el", "show-after", "strategy", "teleported", "transition", "virtual-triggering", "z-index", "append-to"])
      ]),
      _: 3
    }, 8, ["role"]));
  }
});
var me = /* @__PURE__ */ pluginVue_exportHelper.default(oe, [["__file", "tooltip.vue"]]);
exports.default = me;
