import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import { createContext, forwardRef, useContext } from 'react';
import { Link } from 'react-router-dom';
import { c as cn } from './utils-BJnb9o5c.js';
import { r as renderIcon } from './renderIcon-C6twJSqH.js';
import { h as hyphenize } from './hyphenize-BU4K8zjb.js';
import { Tabs as Tabs$1, TabsList, TabsTrigger, TabsContent } from './primitives/Tabs.js';

const SIZE_CLASSES = {
  default: "",
  lg: "text-[15px] px-3 py-1.5"
};
const LIST_HEIGHT = {
  default: "",
  lg: "group-data-horizontal/tabs:h-10"
};
const TabsSizeContext = createContext("default");

const TabsRoot = forwardRef(
  ({ size = "default", children, ...props }, ref) => /* @__PURE__ */ jsx(TabsSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsx(Tabs$1, { ref, "data-testid": "tabs-container", ...props, children }) })
);
TabsRoot.displayName = "Tabs";
const TabsListComponent = forwardRef(
  ({ className, ...props }, ref) => {
    const size = useContext(TabsSizeContext);
    return /* @__PURE__ */ jsx(
      TabsList,
      {
        ref,
        className: cn(LIST_HEIGHT[size], className),
        ...props
      }
    );
  }
);
TabsListComponent.displayName = "Tabs.List";
const TabsItemComponent = forwardRef(
  ({ icon, className, children, to, dataTestid, ...otherProps }, ref) => {
    const size = useContext(TabsSizeContext);
    const testId = dataTestid ?? (otherProps.value != null ? `${hyphenize(String(otherProps.value))}-tab` : void 0);
    const content = icon ? /* @__PURE__ */ jsxs(Fragment, { children: [
      renderIcon(icon, size === "lg" ? "size-5" : "size-4"),
      children
    ] }) : children;
    if (to !== void 0) {
      return /* @__PURE__ */ jsx(
        TabsTrigger,
        {
          asChild: true,
          ref,
          className: cn(SIZE_CLASSES[size], icon && "gap-1.5", className),
          "data-testid": testId,
          ...otherProps,
          children: /* @__PURE__ */ jsx(Link, { to, children: content })
        }
      );
    }
    return /* @__PURE__ */ jsx(
      TabsTrigger,
      {
        ref,
        className: cn(SIZE_CLASSES[size], icon && "gap-1.5", className),
        "data-testid": testId,
        ...otherProps,
        children: content
      }
    );
  }
);
TabsItemComponent.displayName = "Tabs.Item";
const TabsContentComponent = forwardRef(
  (props, ref) => /* @__PURE__ */ jsx(TabsContent, { ref, ...props })
);
TabsContentComponent.displayName = "Tabs.Content";
const Tabs = Object.assign(TabsRoot, {
  List: TabsListComponent,
  Item: TabsItemComponent,
  Content: TabsContentComponent
});

export { Tabs as T };
//# sourceMappingURL=Tabs-ModAabFc.js.map
