import '@das-fed/upf-ui/packages/components/tooltip/style.css';
import { defineComponent as L, useCssVars as z, useAttrs as D, computed as c, ref as v, onMounted as P, onBeforeMount as I, openBlock as s, createBlock as O, unref as b, mergeProps as W, withCtx as m, createVNode as q, createElementVNode as M, normalizeClass as $, renderSlot as R, createElementBlock as a, Fragment as h, createTextVNode as F, toDisplayString as B, createCommentVNode as g, normalizeStyle as X, nextTick as Y } from "vue";
import { setI18nRule as A, t as j } from "@das-fed/upf-web/packages/i18n/index";
import { withInstall as G } from "@das-fed/upf-utils/with-install/index";
import { DasScrollbar as J } from "@das-fed/upf-ui/packages/components/scrollbar/index";
import { ElTooltip as K } from "element-plus";
import "element-plus/es/components/tooltip/style/css";
const Q = {
  key: 0,
  class: "das-tooltip-virtual-placeholder"
}, U = ["innerHTML"], Z = { key: 1 }, _ = /* @__PURE__ */ L({
  __name: "index",
  props: {
    selfPopperClass: { default: "" },
    effect: { default: "light" },
    placement: { default: "top" },
    customClass: { default: "" },
    content: { default: "" },
    disabled: { type: Boolean, default: void 0 },
    text: { default: "" },
    row: { default: 1 },
    textWidth: { default: "100%" },
    textHtml: { type: Boolean, default: !1 },
    isMaxheight: { type: Boolean, default: !0 }
  },
  emits: ["show", "hide"],
  setup(t, { expose: f, emit: r }) {
    z((e) => ({
      v65704ba4: E.value
    }));
    const l = t, d = r, i = D(), V = c(() => {
      const e = "virtual-triggering" in i || "virtualTriggering" in i || i["virtual-triggering"] !== void 0 || i.virtualTriggering !== void 0, o = "virtual-ref" in i || "virtualRef" in i || i["virtual-ref"] !== void 0 || i.virtualRef !== void 0;
      return e || o;
    }), x = v(), w = v(!1), E = c(() => Number(l.row)), H = c(() => l.disabled ?? (l.text ? !w.value : !1)), y = c(() => l.content || l.text), S = (e) => {
      w.value = e.target.scrollHeight > e.target.clientHeight;
    }, N = (e) => {
      d("show", e), window.addEventListener("wheel", p);
    }, C = (e) => {
      d("hide", e), window.removeEventListener("wheel", p);
    }, p = (e) => {
      const o = document.querySelector('[id^="el-popper-container"]');
      if (!o) return;
      const n = o.querySelector(".das-ui-tooltip-popper");
      if (!n) return;
      const k = e.clientX, T = e.clientY, u = n == null ? void 0 : n.getBoundingClientRect();
      n && k >= u.left && k <= u.right && T >= u.top && T <= u.bottom || (n.style.display = "none", n.style.opacity = "0", Y(() => {
        C();
      }));
    };
    return P(() => {
    }), I(() => {
      window.removeEventListener("wheel", p);
    }), f({
      $tooltipRef: x
    }), (e, o) => (s(), O(b(K), W({
      ref_key: "$tooltipRef",
      ref: x,
      class: "das-ui-tooltip",
      disabled: H.value,
      effect: t.effect,
      placement: t.placement,
      "popper-class": `das-ui-tooltip-popper ${t.isMaxheight ? "max-height" : ""} ${t.selfPopperClass}`,
      "hide-after": 100,
      "show-after": 100
    }, e.$attrs, {
      onShow: N,
      onHide: C
    }), {
      content: m(() => [
        q(b(J), null, {
          default: m(() => [
            M(
              "div",
              {
                class: $({ "max-height": t.isMaxheight, "das-popper-content": !0 })
              },
              [
                R(e.$slots, "content", {}, void 0, !0),
                y.value && !e.$slots.content ? (s(), a(
                  h,
                  { key: 0 },
                  [
                    F(
                      B(y.value),
                      1
                      /* TEXT */
                    )
                  ],
                  64
                  /* STABLE_FRAGMENT */
                )) : g("v-if", !0)
              ],
              2
              /* CLASS */
            )
          ]),
          _: 3
          /* FORWARDED */
        })
      ]),
      default: m(() => [
        V.value ? (s(), a("span", Q, " ")) : (s(), a(
          h,
          { key: 1 },
          [
            g(" 默认 slot 内容 "),
            R(e.$slots, "default", {}, () => [
              t.text ? (s(), a(
                "div",
                {
                  key: 0,
                  onMouseenter: o[0] || (o[0] = (n) => S(n)),
                  class: $(`das-tooltip-text-wrap ${t.customClass}`),
                  style: X({ width: l.textWidth })
                },
                [
                  t.textHtml ? (s(), a("div", {
                    key: 0,
                    innerHTML: t.text
                  }, null, 8, U)) : (s(), a(
                    "div",
                    Z,
                    B(t.text),
                    1
                    /* TEXT */
                  ))
                ],
                38
                /* CLASS, STYLE, NEED_HYDRATION */
              )) : (s(), a(
                h,
                { key: 1 },
                [
                  g(" 当没有 text 且没有 slot 内容时，提供一个占位元素避免 ElOnlyChild 错误 "),
                  o[1] || (o[1] = M(
                    "span",
                    { class: "das-tooltip-virtual-placeholder" },
                    " ",
                    -1
                    /* CACHED */
                  ))
                ],
                2112
                /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
              ))
            ], !0)
          ],
          2112
          /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
        ))
      ]),
      _: 3
      /* FORWARDED */
    }, 16, ["disabled", "effect", "placement", "popper-class"]));
  }
}), ee = (t, f) => {
  const r = t.__vccOpts || t;
  for (const [l, d] of f)
    r[l] = d;
  return r;
}, te = /* @__PURE__ */ ee(_, [["__scopeId", "data-v-e1652f58"]]), oe = { 文字提示: { "zh-CN": "文字提示", en: "Text Prompt", "zh-MO": "文字提示", _appCode: "framework" } };
A(oe);
const de = () => v(null), ue = G(te), ce = { name: `Tooltip ${j("文字提示")}` };
export {
  ue as DasTooltip,
  de as DasTooltipRef,
  ce as default
};
