(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".pl-tooltip{--pl-tooltip-max-width: 300px;z-index:var(--z-tooltip);position:absolute;display:inline-block;padding:8px 12px 9px;background:var(--tooltip-bg);border-radius:6px;width:max-content;word-break:normal;transform-origin:0 50%;max-width:var(--pl-tooltip-max-width);color:#fff}.pl-tooltip__container{position:absolute;width:0;height:0}.pl-tooltip a{color:var(--tooltip-link-color)}.pl-tooltip p{margin-bottom:8px}.pl-tooltip ul,.pl-tooltip li{margin-left:6px;padding-left:6px}.pl-tooltip li{margin-bottom:4px}.pl-tooltip .beak{position:absolute;top:50%;right:100%}.pl-tooltip.top-left{bottom:0}.pl-tooltip.top-left .beak{position:absolute;top:calc(100% - 2px);transform:translate(-50%) rotate(-90deg);left:20%}.pl-tooltip.left{right:0;transform:translateY(-50%)}.pl-tooltip.left .beak{position:absolute;top:50%;transform:translateY(-50%) rotate(180deg);left:100%}.pl-tooltip.right{left:0;transform:translateY(-50%)}.pl-tooltip.right .beak{position:absolute;top:50%;transform:translateY(-50%);right:100%}.pl-tooltip.top{transform:translate(-50%);bottom:0}.pl-tooltip.top .beak{position:absolute;top:calc(100% - 2px);transform:translate(-50%) rotate(-90deg);left:50%}.pl-tooltip.southwest{transform:translateY(100%);bottom:0;right:-6px}.pl-tooltip.southwest .beak{position:absolute;top:-2px;transform:translateY(-50%) rotate(90deg);right:12px}.tooltip-transition-enter-active,.tooltip-transition-leave-active{transition:all .1s ease-in-out}.tooltip-transition-enter-from,.tooltip-transition-leave-to{opacity:0;transform:translateY(-50%) scale(0)}")),document.head.appendChild(t)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
import { defineComponent as $, reactive as b, watch as c, ref as u, toRef as N, computed as P, onUnmounted as R, createBlock as y, openBlock as a, resolveDynamicComponent as V, mergeProps as g, withCtx as v, renderSlot as k, createCommentVNode as h, Teleport as j, createVNode as w, Transition as z, createElementBlock as A, withModifiers as W, normalizeStyle as C, unref as q, createElementVNode as T, normalizeClass as x } from "vue";

import { useTooltipPosition as F } from "./useTooltipPosition.js";
import { throttle as K, delay as L, timeout as U } from "../../helpers/utils.js";
import { useClickOutside as G } from "../../composition/useClickOutside.js";
import H from "./Beak.vue.js";
import { tMap as p } from "./global.js";
const I = {
  name: "PlTooltip"
}, te = /* @__PURE__ */ $({
  ...I,
  props: {
    openDelay: { default: 100 },
    closeDelay: { default: 1e3 },
    position: { default: "top" },
    hide: { type: Boolean },
    gap: { default: 8 },
    element: { default: "div" },
    maxWidth: { default: "300px" }
  },
  emits: ["tooltip:close"],
  setup(M, { emit: _ }) {
    const B = _, i = Symbol(), t = M, o = b({
      open: !1,
      over: !1,
      tooltipOpen: !1,
      key: Symbol()
    });
    p.set(i, () => l()), c(
      () => o.open,
      (e) => {
        requestAnimationFrame(() => {
          o.tooltipOpen = e;
        });
      }
    );
    let m = () => {
    };
    const D = K(() => window.dispatchEvent(new CustomEvent("adjust")), 1e3), O = () => {
      o.open = !0;
      for (const [e, n] of p.entries())
        e !== i && n();
    }, l = () => {
      o.open = !1, B("tooltip:close");
    }, s = async () => {
      t.hide || (D(), o.over = !0, m(), await L(t.openDelay ?? 100), o.over && O());
    }, f = () => {
      o.over = !1, m = U(() => {
        o.over || l();
      }, t.closeDelay);
    };
    c(
      () => t.hide,
      (e) => {
        e && l();
      }
    );
    const r = u(), d = u(), S = F(r, N(t));
    G([r, d], () => l());
    const E = P(() => ({
      "--pl-tooltip-max-width": t.maxWidth
    }));
    return R(() => {
      p.delete(i);
    }), (e, n) => (a(), y(V(e.element), g(e.$attrs, {
      ref_key: "rootRef",
      ref: r,
      onClick: s,
      onMouseover: s,
      onMouseleave: f
    }), {
      default: v(() => [
        k(e.$slots, "default"),
        e.$slots.tooltip && o.open ? (a(), y(j, {
          key: 0,
          to: "body"
        }, [
          w(z, { name: "tooltip-transition" }, {
            default: v(() => [
              o.tooltipOpen ? (a(), A("div", {
                key: 0,
                class: "pl-tooltip__container",
                style: C(q(S)),
                onClick: n[0] || (n[0] = W(() => {
                }, ["stop"]))
              }, [
                T("div", {
                  ref_key: "tooltip",
                  ref: d,
                  class: x(["pl-tooltip", e.position]),
                  style: C(E.value),
                  onMouseover: s,
                  onMouseleave: f
                }, [
                  T("div", null, [
                    k(e.$slots, "tooltip")
                  ]),
                  w(H)
                ], 38)
              ], 4)) : h("", !0)
            ]),
            _: 3
          })
        ])) : h("", !0)
      ]),
      _: 3
    }, 16));
  }
});
export {
  te as default
};
//# sourceMappingURL=PlTooltip.vue.js.map
