import '@das-fed/upf-ui/packages/components/tabs/style.css';
import { withInstall as H } from "@das-fed/upf-utils/with-install/index";
import { t as $, setI18nRule as J } from "@das-fed/upf-web/packages/i18n/index";
import { TabPane as Q } from "ant-design-vue/es";
import "ant-design-vue/es/tabs/style/css";
import { ElPopover as Y } from "element-plus/es";
import "element-plus/es/components/base/style/css";
import "element-plus/es/components/popover/style/css";
import { ref as E, computed as d, onMounted as Z, defineComponent as ee, openBlock as s, createBlock as I, unref as i, mergeProps as K, createSlots as U, withCtx as v, renderSlot as p, createCommentVNode as u, createElementBlock as f, Fragment as x, renderList as _, normalizeStyle as te, withDirectives as R, createTextVNode as W, toDisplayString as O, createVNode as ne, createElementVNode as ae, normalizeClass as oe } from "vue";
import { Tabs as re } from "ant-design-vue";
import { DasIcon as le } from "@das-fed/upf-ui/packages/components/icon/index";
import { vDasTooltip as V } from "@das-fed/upf-ui/packages/components/text-tooltip/index";
const se = (t) => /^[+-]?\d+(\.\d+)?(px|em|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|%)$/.test(t), L = (t) => {
  if (t)
    return typeof t == "string" && se(t) ? t : t + "px";
}, ie = (t, h) => {
  const e = E({}), m = E([
    {
      key: "all",
      name: $("关闭全部页签"),
      disabled: !1,
      hidden: !1
    },
    {
      key: "other",
      name: $("关闭其他页签"),
      disabled: !1,
      hidden: (a, r) => a.length === 1
    },
    {
      key: "right",
      name: $("关闭右侧页签"),
      disabled: !1,
      hidden: (a, r) => {
        var S;
        const c = (S = t.defualtProps) == null ? void 0 : S.key;
        return (c ? a.findIndex((B) => B[c] === r[c]) : -1) === a.length - 1;
      }
    }
  ]), C = d(() => t.constomMenuList && t.constomMenuList.length ? t.constomMenuList : m.value), g = d(() => {
    let a;
    return t.width && (a = L(t.width)), a;
  }), T = d(() => {
    let a = t.type === "lattice" ? "65px" : void 0;
    return t.tabWidth && (a = L(t.tabWidth)), a;
  }), M = d(() => {
    let a;
    return t.tabMaxWidth && (a = L(t.tabMaxWidth)), a;
  }), w = E(!1), y = E(), z = (a) => {
    Object.keys(e.value).forEach((r) => {
      (w.value || r != a) && (e.value[r] = !1);
    });
  }, k = (a) => {
    const r = a.target.parentElement;
    w.value = !r.classList.contains("ant-tabs-tab-btn");
  }, A = (a, r) => {
    var c;
    h("menuClick", a, r), (c = y.value) != null && c.length && y.value.forEach((P) => {
      P.hide();
    });
  };
  return Z(() => {
    t.contextmenu && t.options.forEach((a) => {
      var r;
      (r = t.defualtProps) != null && r.key && (e.value[a[t.defualtProps.key]] = !1);
    });
  }), {
    realWidth: g,
    realMenuList: C,
    realTabWidth: T,
    realTabMaxWidth: M,
    tabsMenuPoppver: y,
    poppverVisible: e,
    menuClick: A,
    beforeEnter: z,
    onContextmenu: k
  };
}, de = {
  key: 1,
  class: "das-tab-label"
}, ue = { class: "das-tabs-contextmenu-list" }, fe = ["onClick"], ce = {
  key: 1,
  style: { position: "relative", top: "-5px", "font-size": "18px" }
}, be = "var(--upf-tab-text)", ve = "var(--upf-tab-bg)", ye = "var(--upf-border-color)", pe = /* @__PURE__ */ ee({
  inheritAttrs: !1,
  __name: "Tabs",
  props: {
    activeKey: {},
    type: { default: "line" },
    isStrict: { type: Boolean, default: !1 },
    hideAdd: { type: Boolean, default: !0 },
    tabsStyle: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
    size: {},
    contextmenu: { type: Boolean, default: !1 },
    width: {},
    options: { default: () => [] },
    constomMenuList: { default: () => [] },
    tabWidth: {},
    tabMaxWidth: {},
    tabPadding: {},
    defualtProps: { default: () => ({
      key: "key",
      tab: "tab"
    }) },
    menuPoppverAttrs: {},
    fontColor: {},
    backgroudColor: {},
    borderColor: {},
    moreIconType: {},
    hideOverflow: { type: Boolean }
  },
  emits: ["update:activeKey", "tabClick", "menuClick"],
  setup(t, { emit: h }) {
    const e = t, m = E(), C = (n) => {
      var b;
      y("tabClick", n), (b = m.value) == null || b.$el.click();
    }, g = d({
      get: () => e.activeKey ?? "",
      set: (n) => y("update:activeKey", n)
    }), T = d(() => e.options.filter((b) => !b.hidden)), M = (n) => e.isStrict ? !!(n.contentSlot && n[e.defualtProps.key] === g.value) : !!n.contentSlot, w = d(() => e.moreIconType ? e.moreIconType : e.type === "lattice" ? "default" : "arrow"), y = h, z = d(() => e.type === "lattice" ? "line" : e.type), k = d(() => {
      if (e.type === "card")
        return e.size ? e.size : "large";
      if (e.type === "line")
        return e.size ? e.size : "medium";
      if (e.type === "editable-card")
        return e.size ? e.size : "small";
    }), A = d(() => {
      if (e.tabPadding) return e.tabPadding;
      if (c.value || P.value) return "0";
      if (e.type === "line") return "0 20px";
      if (e.type === "card") {
        if (k.value === "large") return "0 40px";
        if (k.value === "medium" || k.value === "small") return "0 24px";
      }
      if (e.type === "lattice") return "0 20px";
    }), a = d(() => {
      let n = {};
      return e != null && e.fontColor && (n["--upf-tabs-text-override"] = e.fontColor), e != null && e.backgroudColor && (n["--upf-tabs-bg-override"] = e.backgroudColor), e != null && e.borderColor && (n["--upf-tabs-border-override"] = e.borderColor), n;
    }), r = d(() => ({
      "--upf-tabs-text-override": be,
      "--upf-tabs-bg-override": ve,
      "--upf-tabs-border-override": ye,
      "---upf-tabs-tab-width": c.value,
      "---upf-tabs-tab-max-width": P.value,
      "---upf-tabs-tab-padding": A.value,
      ...e.tabsStyle,
      ...a.value
    })), {
      realTabWidth: c,
      realTabMaxWidth: P,
      realWidth: S,
      menuClick: B,
      tabsMenuPoppver: j,
      realMenuList: F,
      poppverVisible: N,
      beforeEnter: G,
      onContextmenu: D
    } = ie(e, y);
    return (n, b) => {
      const X = Y, q = Q;
      return T.value && T.value.length ? (s(), I(i(re), K({
        key: 0,
        ref_key: "tabsContainerRef",
        ref: m,
        class: ["das-tabs", t.type, k.value, t.hideOverflow ? "hide-overflow" : ""],
        style: r.value,
        type: z.value,
        hideAdd: t.hideAdd,
        activeKey: g.value,
        "onUpdate:activeKey": b[1] || (b[1] = (o) => g.value = o)
      }, n.$attrs, { onTabClick: C }), U({
        moreIcon: v(() => [
          p(n.$slots, "moreIcon", {}, () => [
            w.value === "arrow" ? (s(), I(i(le), {
              key: 0,
              icon: "fold",
              size: "small",
              "icon-color": "var(--upf-tabs-text-override, var(--upf-tab-text))"
            })) : u("v-if", !0),
            w.value === "default" ? (s(), f("div", ce, "...")) : u("v-if", !0)
          ], !0)
        ]),
        default: v(() => [
          (s(!0), f(
            x,
            null,
            _(T.value, (o) => (s(), I(q, {
              style: te({ width: i(S) }),
              key: o[t.defualtProps.key],
              tab: void 0,
              disabled: o.disabled,
              forceRender: o.forceRender
            }, U({
              tab: v(() => [
                u(" 无右键菜单 "),
                t.contextmenu ? (s(), f(
                  x,
                  { key: 1 },
                  [
                    u(" 有右键菜单 "),
                    ne(X, K({
                      ref_for: !0,
                      ref_key: "tabsMenuPoppver",
                      ref: j,
                      visible: i(N)[o[t.defualtProps.key]],
                      "onUpdate:visible": (l) => i(N)[o[t.defualtProps.key]] = l,
                      "popper-class": "das-tabs-contextmenu",
                      "show-arrow": !1,
                      placement: "bottom-start",
                      trigger: "contextmenu",
                      width: 106
                    }, { ref_for: !0 }, t.menuPoppverAttrs, {
                      onBeforeEnter: (l) => i(G)(o[t.defualtProps.key])
                    }), {
                      reference: v(() => [
                        u(" @slot  自定义选项卡头显示文字"),
                        o.tabSlot ? p(n.$slots, o.tabSlot, { key: 0 }, void 0, !0) : R((s(), f(
                          "div",
                          {
                            key: 1,
                            class: "das-tab-label",
                            onContextmenu: b[0] || (b[0] = //@ts-ignore
                            (...l) => i(D) && i(D)(...l))
                          },
                          [
                            W(
                              O(o[t.defualtProps.tab]),
                              1
                              /* TEXT */
                            )
                          ],
                          32
                          /* NEED_HYDRATION */
                        )), [
                          [i(V)]
                        ])
                      ]),
                      default: v(() => [
                        ae("ul", ue, [
                          (s(!0), f(
                            x,
                            null,
                            _(i(F), (l) => (s(), f(
                              x,
                              null,
                              [
                                (typeof l.hidden == "function" ? !l.hidden(t.options, o) : !l.hidden) ? R((s(), f("li", {
                                  key: l.key,
                                  class: oe([
                                    "das-tabs-contextmenu-item",
                                    (typeof l.disabled == "function" ? l.disabled(t.options, o) : l.disabled) ? "is-disabled" : ""
                                  ]),
                                  onClick: (xe) => i(B)(l, o)
                                }, [
                                  W(
                                    O(l.name),
                                    1
                                    /* TEXT */
                                  )
                                ], 10, fe)), [
                                  [i(V)]
                                ]) : u("v-if", !0)
                              ],
                              64
                              /* STABLE_FRAGMENT */
                            ))),
                            256
                            /* UNKEYED_FRAGMENT */
                          ))
                        ])
                      ]),
                      _: 2
                      /* DYNAMIC */
                    }, 1040, ["visible", "onUpdate:visible", "onBeforeEnter"])
                  ],
                  2112
                  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
                )) : (s(), f(
                  x,
                  { key: 0 },
                  [
                    u(" @slot  自定义选项卡头显示文字"),
                    o.tabSlot ? p(n.$slots, o.tabSlot, { key: 0 }, void 0, !0) : R((s(), f("div", de, [
                      W(
                        O(o[t.defualtProps.tab]),
                        1
                        /* TEXT */
                      )
                    ])), [
                      [i(V)]
                    ])
                  ],
                  64
                  /* STABLE_FRAGMENT */
                ))
              ]),
              default: v(() => [
                M(o) ? (s(), f(
                  x,
                  { key: 0 },
                  [
                    u(" @slot  自定义显示内容"),
                    p(n.$slots, o.contentSlot, {}, void 0, !0)
                  ],
                  64
                  /* STABLE_FRAGMENT */
                )) : u("v-if", !0)
              ]),
              _: 2
              /* DYNAMIC */
            }, [
              o.closeIconSlot ? {
                name: "closeIcon",
                fn: v(() => [
                  p(n.$slots, o.closeIconSlot, {}, void 0, !0)
                ]),
                key: "0"
              } : void 0
            ]), 1032, ["style", "disabled", "forceRender"]))),
            128
            /* KEYED_FRAGMENT */
          ))
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        n.$slots.leftExtra ? {
          name: "leftExtra",
          fn: v(() => [
            u(" @slot tabbar 上左侧额外的元素 "),
            p(n.$slots, "leftExtra", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        n.$slots.rightExtra ? {
          name: "rightExtra",
          fn: v(() => [
            p(n.$slots, "rightExtra", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0
      ]), 1040, ["class", "style", "type", "hideAdd", "activeKey"])) : u("v-if", !0);
    };
  }
}), he = (t, h) => {
  const e = t.__vccOpts || t;
  for (const [m, C] of h)
    e[m] = C;
  return e;
}, me = /* @__PURE__ */ he(pe, [["__scopeId", "data-v-bc4dda14"]]), ke = {
  关闭全部页签: { "zh-CN": "关闭全部页签", en: "Close All Tabs", "zh-MO": "關閉全部頁籤", _appCode: "framework" },
  关闭其他页签: { "zh-CN": "关闭其他页签", en: "Close Other Tabs", "zh-MO": "關閉其他頁籤", _appCode: "framework" },
  关闭右侧页签: { "zh-CN": "关闭右侧页签", en: "Close Right Tabs", "zh-MO": "關閉右側頁籤", _appCode: "framework" }
};
J(ke);
const $e = H(me), Ie = { name: "Tabs 页签" };
export {
  $e as DasTabs,
  Ie as default
};
