import { cx as e } from "../../../theme/tools.js";
import { panel as t, panels as n, tabRecipe as r, tabsBar as i, tabsInner as a, tabsRecipe as o, wrapper as s } from "./tabs.css.js";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
import u from "@plumile/router/routing/Link.js";
import d from "@plumile/router/routing/useLocation.js";
//#region src/atomic/molecules/tabs/Tabs.tsx
var f = u, p = (e, t, n, r = !1) => t == null ? typeof e.isActive == "boolean" ? e.isActive : r ? !1 : e.to != null && n != null ? n === e.to : !1 : e.id === t, m = (u) => {
	let { activeId: m, ariaLabel: h, children: g, className: _, items: v, layout: y = "nav", onChange: b, panelClassName: x, variant: S = "line" } = u, { pathname: C } = d();
	if (v.length === 0) return null;
	let w = v.some((e) => e.to != null), T = b != null && !w, E = v.some((e) => typeof e.isActive == "boolean"), D = o({ variant: S });
	y === "nav" && (D = e(D, _));
	let O = v.map((e) => {
		let { disabled: t, id: n, label: i, to: a } = e, o = p(e, m, C, E), s = "default";
		t ? s = "disabled" : o && (s = "active");
		let l = r({
			state: s,
			variant: S
		}), u;
		t && (u = !0);
		let d;
		if (o && a != null && (d = "page"), a != null) {
			let e;
			return t && (e = -1), /* @__PURE__ */ c(f, {
				exact: !0,
				"aria-current": d,
				"aria-disabled": u,
				className: l,
				to: a,
				tabIndex: e,
				onClick: (e) => {
					t && e.preventDefault();
				},
				children: i
			}, n);
		}
		if (b != null) return /* @__PURE__ */ c("button", {
			type: "button",
			role: "tab",
			"aria-selected": o,
			"aria-disabled": u,
			className: l,
			disabled: t,
			onClick: () => {
				t || b(n);
			},
			children: i
		}, n);
		let h;
		return o && (h = "page"), /* @__PURE__ */ c("span", {
			"aria-current": h,
			"aria-disabled": u,
			className: l,
			children: i
		}, n);
	}), k = T ? /* @__PURE__ */ c("div", {
		className: D,
		role: "tablist",
		"aria-label": h,
		children: O
	}) : w ? /* @__PURE__ */ c("nav", {
		"aria-label": h,
		className: D,
		children: O
	}) : /* @__PURE__ */ c("div", {
		className: D,
		children: O
	});
	return y === "content" ? /* @__PURE__ */ l("div", {
		className: e(s, _),
		children: [/* @__PURE__ */ c("div", {
			className: i,
			children: /* @__PURE__ */ c("div", {
				className: a,
				children: k
			})
		}), /* @__PURE__ */ c("div", {
			className: n,
			children: /* @__PURE__ */ c("section", {
				role: "tabpanel",
				className: e(t, x),
				children: g
			})
		})]
	}) : k;
}, h = { resolveItemIsActive: p };
//#endregion
export { m as Tabs, h as __test };

//# sourceMappingURL=Tabs.js.map