import { cx as e } from "../../../theme/tools.js";
import { ChevronDownSvg as t } from "../../../icons/ChevronDownSvg.js";
import { SidebarNavItem as n } from "../sidebar_nav_item/SidebarNavItem.js";
import { header as r, headerButton as i, headerButtonSidebarCollapsed as a, headerSidebarCollapsed as o, items as s, itemsNested as c, section as l, title as u, titleContent as d, titleIcon as f, titleSidebarCollapsed as p, toggleIcon as m, toggleIconCollapsed as h } from "./sidebarNavSection.css.js";
import { useCallback as g, useId as _, useState as v } from "react";
import { jsx as y, jsxs as b } from "react/jsx-runtime";
//#region src/backoffice/molecules/sidebar_nav_section/SidebarNavSection.tsx
var x = ({ title: x, icon: S, items: C, collapsible: w = !1, isCollapsed: T, defaultCollapsed: E = !1, onCollapsedChange: D, collapsed: O = !1, className: k }) => {
	let [A, j] = v(E), M = _(), N = _(), P = T ?? A, F = w, I = g(() => {
		if (!F) return;
		let e = !P;
		T ?? j(e), D?.(e);
	}, [
		F,
		P,
		T,
		D
	]), L;
	typeof x == "string" && (L = x);
	let R = e(u, { [p]: O }), z = e(m, { [h]: P }), B;
	O && (B = L);
	let V = null;
	S != null && (V = /* @__PURE__ */ y("span", {
		className: f,
		"aria-hidden": "true",
		children: S
	}));
	let H = null;
	x != null && (H = F ? /* @__PURE__ */ b("button", {
		id: N,
		type: "button",
		className: e(i, { [a]: O }),
		onClick: I,
		"aria-expanded": !P,
		"aria-controls": M,
		"aria-label": B,
		title: B,
		children: [/* @__PURE__ */ b("span", {
			className: d,
			children: [V, /* @__PURE__ */ y("span", {
				className: R,
				children: x
			})]
		}), !O && /* @__PURE__ */ y("span", {
			className: z,
			"aria-hidden": "true",
			children: /* @__PURE__ */ y(t, {
				width: 18,
				height: 18
			})
		})]
	}) : /* @__PURE__ */ y("div", {
		className: e(r, { [o]: O }),
		title: B,
		children: /* @__PURE__ */ b("div", {
			className: d,
			id: N,
			children: [V, /* @__PURE__ */ y("span", {
				className: R,
				children: x
			})]
		})
	}));
	let U = null;
	if (!P) {
		let t = x != null && !O;
		U = /* @__PURE__ */ y("div", {
			className: e(s, { [c]: t }),
			id: M,
			role: "list",
			children: C.map((e) => {
				let { id: r, data: i, ...a } = e;
				return /* @__PURE__ */ y(n, {
					...a,
					collapsed: O,
					nested: t
				}, r);
			})
		});
	}
	let W;
	return x != null && (W = N), /* @__PURE__ */ b("section", {
		className: e(l, k),
		"aria-labelledby": W,
		children: [H, U]
	});
};
//#endregion
export { x as SidebarNavSection, x as default };

//# sourceMappingURL=SidebarNavSection.js.map