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