import { jsxs as C, jsx as l } from "react/jsx-runtime";
import { classNames as T } from "./index-classNames.js";
import { ComponentContainer as B } from "./index-ComponentContainer.js";
import { Tab as I } from "./index-Tab.js";
import { TabPanel as v } from "./index-TabPanel.js";
import { TabsCustomScroll as y } from "./index-TabsCustomScroll.js";
import { useState as f } from "react";
import k from "./index-Tabs.module.scss.js";
import w from "./index-Tabs2.js";
const H = (m) => {
  const {
    tabs: s,
    value: a,
    onChange: n,
    className: p,
    keepInactiveTabsInDom: i,
    testId: u,
    tabConfig: o
  } = m, [r, c] = f(a ?? 0), h = (e, t) => {
    c(t), n && n(e, t);
  }, b = {
    ...(o == null ? void 0 : o.tabHeight) === "small" && {
      minHeight: "36px",
      height: "36px"
    },
    ...(o == null ? void 0 : o.tabNoMinWidth) === !0 && {
      minWidth: "0"
    },
    ...(o == null ? void 0 : o.padding) === "small" && {
      padding: "8px"
    },
    ...(o == null ? void 0 : o.tabGrow) === !1 && {
      flexGrow: "0"
    }
  };
  return C(B, {
    children: [l(w, {
      className: T(k.tabsContainer, p),
      scrollButtons: "auto",
      ScrollButtonComponent: y,
      variant: "scrollable",
      style: {
        ...(o == null ? void 0 : o.alignCenter) && {
          display: "flex",
          alignItems: "center"
        }
      },
      allowScrollButtonsMobile: !0,
      value: a ?? r,
      TabIndicatorProps: {
        style: {
          display: "none"
        }
      },
      children: s.map((e, t) => e.disabled ? null : l(I, {
        testId: `${u}-${t}`,
        style: b,
        label: e.label,
        value: e.value ?? t,
        onClick: (d) => h(d, e.value ?? t),
        selected: t === (a ?? r),
        tabIcons: e.tabIcons,
        hasError: e.hasError,
        tabConfig: o,
        showBackgroundColor: e.showBackgroundColor,
        hasBorderBottom: e.hasBorderBottom,
        simple: e.simple
      }, t))
    }), s.map((e, t) => l(v, {
      currentTab: a ?? r,
      value: e.value ?? t,
      keepInDom: i,
      children: e.component
    }, t))]
  });
};
export {
  H as Tabs
};
