import '@das-fed/upf-ui/packages/components/tag/style.css';
import { withInstall as C } from "@das-fed/upf-utils/with-install/index";
import { defineComponent as E, computed as t, ref as d, watch as L, nextTick as D, openBlock as f, createElementBlock as T, createVNode as I, unref as g, mergeProps as R, withCtx as _, renderSlot as V, createBlock as z, createElementVNode as A, normalizeStyle as y, toDisplayString as w, createCommentVNode as k } from "vue";
import { DasTooltip as O } from "@das-fed/upf-ui/packages/components/tooltip/index";
import { ElTag as P } from "element-plus";
import "element-plus/es/components/tag/style/css";
const j = { class: "das-ui-tag" }, q = {
  inheritAttrs: !1
}, F = /* @__PURE__ */ E({
  ...q,
  __name: "Index",
  props: {
    round: { type: Boolean, default: !0 },
    effect: { default: "dark" },
    type: { default: "" },
    toolTip: { type: Boolean, default: !1 },
    toolTipLabel: { default: "" },
    width: { default: "" },
    maxWidth: { default: "" }
  },
  setup(o, { expose: u }) {
    const e = o, l = t(() => e.type || ""), n = ["success", "info", "warning", "danger", ""], b = t(() => n.includes(l.value) ? null : `el-tag--${l.value}`), W = t(() => n.includes(l.value) ? l.value : ""), a = t(() => e.effect || "dark"), p = ["dark", "light", "plain"], $ = t(() => p.includes(a.value) ? null : `el-tag--${a.value}`), S = t(() => p.includes(a.value) ? a.value : "dark"), v = t(() => e.round), N = t(() => a.value === "list" ? !v.value : v.value), r = d(), i = t(() => e.maxWidth ? e.maxWidth : e.width), B = t(() => {
      if (e.maxWidth)
        return `max-width:${e.width}`;
      if (e.width)
        return `width:${e.width}`;
    }), m = t(() => {
      if (e.maxWidth)
        return `max-width:${Number(String(i.value).split("px")[0]) - 36}px`;
      if (e.width)
        return `width:${Number(String(i.value).split("px")[0]) - 36}px`;
    }), c = d(!0);
    L(
      () => r.value,
      (s) => {
        if (e.toolTip && s) {
          const x = Number(String(i.value).split("px")[0]) - 36;
          D(() => {
            r.value.scrollWidth <= x && (c.value = !1);
          });
        }
      }
    );
    const h = d(null);
    return u({
      /** das-tag */
      $refTag: h
    }), (s, x) => (f(), T("div", j, [
      I(g(P), R({
        ref_key: "$refTag",
        ref: h
      }, s.$attrs, {
        effect: S.value,
        style: B.value,
        round: N.value,
        type: W.value,
        class: [b.value, $.value]
      }), {
        default: _(() => [
          V(s.$slots, "default", {}, void 0, !0),
          e.toolTip && e.toolTipLabel && c.value ? (f(), z(g(O), {
            key: 0,
            content: e.toolTipLabel,
            placement: "top"
          }, {
            default: _(() => [
              A(
                "div",
                {
                  class: "text-nowrap",
                  ref_key: "textRef",
                  ref: r,
                  style: y(m.value)
                },
                w(e.toolTipLabel),
                5
                /* TEXT, STYLE */
              )
            ]),
            _: 1
            /* STABLE */
          }, 8, ["content"])) : k("v-if", !0),
          c.value ? k("v-if", !0) : (f(), T(
            "div",
            {
              key: 1,
              style: y(m.value)
            },
            w(e.toolTipLabel),
            5
            /* TEXT, STYLE */
          ))
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["effect", "style", "round", "type", "class"])
    ]));
  }
}), G = (o, u) => {
  const e = o.__vccOpts || o;
  for (const [l, n] of u)
    e[l] = n;
  return e;
}, H = /* @__PURE__ */ G(F, [["__scopeId", "data-v-6cb29150"]]), X = C(H);
export {
  X as DasTag,
  X as default
};
