'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.js');
var tabs = require('./tabs.js');
var createNamespace = require('../../../utils/create-namespace.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlTabs" },
  __name: "tabs",
  props: tabs.tabsProps,
  setup(__props) {
    const props = __props;
    const bem = createNamespace.createNamespace("tabs");
    const tabsRef = vue.ref();
    const attrs = vue.useAttrs();
    const slots = vue.useSlots();
    const filterSlots = vue.computed(() => {
      const allSlotNames = Object.keys(slots || {});
      return allSlotNames.filter(
        (name) => name !== "leftExtra" && name !== "rightExtra" && name !== "default"
      );
    });
    const getStyle = vue.computed(() => {
      const computedStyle = {};
      computedStyle["--tab-ink-bar-width"] = props.inkBarWidth;
      computedStyle["--tab-ink-bar-color"] = props.inkBarColor ? props.inkBarColor : props.type === "button" ? "#005ce5" : "#2e73ff";
      if (props.tabWidthMode === "fixed") {
        computedStyle["--tab-fixed-width"] = props.tabFixedWidth;
      }
      computedStyle["--tab-border-radius"] = props.tabBorderRadius;
      if (props.tabPadding && Object.keys(props.tabPadding).length > 0) {
        for (const key in props.tabPadding) {
          computedStyle[`--tab-${key}`] = props.tabPadding[key];
        }
      } else {
        if (props.type === "line") {
          if (props.tabPosition === "top" || props.tabPosition === "bottom") {
            for (const key in tabs.tabsLinePaddingEnum.horizontal[props.size]) {
              computedStyle[`--tab-${key}`] = tabs.tabsLinePaddingEnum.horizontal[props.size][key];
            }
          } else {
            for (const key in tabs.tabsLinePaddingEnum.vertical[props.size]) {
              computedStyle[`--tab-${key}`] = tabs.tabsLinePaddingEnum.vertical[props.size][key];
            }
          }
        } else {
          for (const key in tabs.tabsCardPaddingEnum[props.size]) {
            computedStyle[`--tab-${key}`] = tabs.tabsCardPaddingEnum[props.size][key];
          }
        }
      }
      return {
        width: props.width,
        height: props.height,
        ...computedStyle
      };
    });
    const getTabBarStyle = vue.computed(() => {
      if (props.tabBarStyle) {
        return props.tabBarStyle;
      } else {
        switch (props.tabPosition) {
          case "top":
            return {
              marginBottom: "8px"
            };
          case "bottom":
            return {
              marginTop: "8px"
            };
          case "left":
            return {
              marginBottom: "8px"
            };
          case "right":
            return {
              marginTop: "8px"
            };
          default:
            return null;
        }
      }
    });
    const getLeftExtraStyle = vue.computed(() => {
      return props.tabPosition === "top" || props.tabPosition === "bottom" ? { marginLeft: props.startIndent + "px" } : { marginTop: props.startIndent + "px" };
    });
    const getRightExtraStyle = vue.computed(() => {
      return props.tabPosition === "top" || props.tabPosition === "bottom" ? { marginRight: props.endIndent + "px" } : { marginBottom: props.endIndent + "px" };
    });
    return (_ctx, _cache) => {
      const _component_a_tab_pane = vue.resolveComponent("a-tab-pane");
      const _component_a_tabs = vue.resolveComponent("a-tabs");
      return vue.openBlock(), vue.createBlock(_component_a_tabs, vue.mergeProps({
        ref_key: "tabsRef",
        ref: tabsRef
      }, vue.unref(attrs), {
        style: getStyle.value,
        class: [
          vue.unref(bem).b(),
          vue.unref(bem).is(_ctx.type === "button" ? "button" : ""),
          vue.unref(bem).is(_ctx.tabWidthMode),
          vue.unref(bem).is(_ctx.tabBorderRadius ? "set-border-radius" : "")
        ],
        size: _ctx.size,
        "hide-add": _ctx.hideAdd,
        "tab-position": _ctx.tabPosition,
        "tab-bar-style": getTabBarStyle.value,
        type: _ctx.type === "button" ? "card" : _ctx.type
      }), vue.createSlots({
        leftExtra: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass(vue.unref(bem).e("leftExtra")),
              style: vue.normalizeStyle(getLeftExtraStyle.value)
            },
            [
              vue.renderSlot(_ctx.$slots, "leftExtra")
            ],
            6
            /* CLASS, STYLE */
          )
        ]),
        rightExtra: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass(vue.unref(bem).e("rightExtra")),
              style: vue.normalizeStyle(getRightExtraStyle.value)
            },
            [
              vue.renderSlot(_ctx.$slots, "rightExtra")
            ],
            6
            /* CLASS, STYLE */
          )
        ]),
        default: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "default", {}, () => [
            (vue.openBlock(true), vue.createElementBlock(
              vue.Fragment,
              null,
              vue.renderList(props.tabs, (tab, index) => {
                return vue.openBlock(), vue.createBlock(_component_a_tab_pane, {
                  key: tab.key,
                  disabled: tab.disabled,
                  closable: tab.closable
                }, {
                  tab: vue.withCtx(() => [
                    vue.renderSlot(_ctx.$slots, "tab", { tab }, () => [
                      vue.createElementVNode(
                        "span",
                        null,
                        vue.toDisplayString(tab.name),
                        1
                        /* TEXT */
                      )
                    ])
                  ]),
                  default: vue.withCtx(() => [
                    vue.renderSlot(_ctx.$slots, "tabPane", {
                      tab,
                      index
                    })
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["disabled", "closable"]);
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ])
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        vue.renderList(filterSlots.value, (item) => {
          return {
            name: item,
            fn: vue.withCtx((data) => [
              vue.renderSlot(_ctx.$slots, item, vue.normalizeProps(vue.guardReactiveProps(data || {})))
            ])
          };
        })
      ]), 1040, ["style", "class", "size", "hide-add", "tab-position", "tab-bar-style", "type"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=tabs.vue2.js.map
