import { cx as e } from "../../../theme/tools.js";
import { SidebarCollapseToggle as t } from "../../../backoffice/molecules/sidebar_collapse_toggle/SidebarCollapseToggle.js";
import { SidebarNavSection as n } from "../../../backoffice/molecules/sidebar_nav_section/SidebarNavSection.js";
import { container as r, containerRecipe as i, footer as a, header as o, inner as s, sections as c } from "./sidebarNavigation.css.js";
import { useCallback as l, useState as u } from "react";
import { jsx as d, jsxs as f } from "react/jsx-runtime";
import p from "@plumile/router/routing/useLocation.js";
//#region src/components/navigation/sidebar/SidebarNavigation.tsx
var m = (e, t, n) => t == null ? !1 : n === !0 ? e === t : e === t || e.startsWith(`${t}/`), h = (e, t) => e.children?.some((e) => e.isActive === !0 || m(t, e.href, e.exact) || h(e, t)) ?? !1, g = (e, t, n) => {
	let r = [];
	return e.forEach((e) => {
		let i = h(e, t), a = e.isActive ?? m(t, e.href, e.exact), { id: o, children: s, data: c, label: l, href: u, icon: d, badge: f, disabled: p, onClick: _, actionSlot: v, dragHandleSlot: y, dragHandleLabel: b, actionsVisibility: x, ariaLabel: S } = e;
		r.push({
			id: o,
			data: c,
			label: l,
			href: u,
			icon: d,
			badge: f,
			disabled: p,
			onClick: _,
			actionSlot: v,
			dragHandleSlot: y,
			dragHandleLabel: b,
			actionsVisibility: x,
			ariaLabel: S,
			isActive: a || i
		}), !n && i && s != null && r.push(...g(s, t, n));
	}), r;
}, _ = ({ header: m, search: h, footer: _, sections: v, isCollapsed: y, defaultCollapsed: b = !1, onCollapsedChange: x, collapseToggleLabel: S, expandToggleLabel: C, collapseShortcut: w, navigationAriaLabel: T = "Navigation", hideCollapseToggle: E = !1, size: D = "standard", className: O }) => {
	let [k, A] = u(b), j = y ?? k, { pathname: M } = p(), N = l(() => {
		let e = !j;
		y ?? A(e), x?.(e);
	}, [
		j,
		y,
		x
	]), P = "expanded";
	j && (P = "collapsed");
	let F = null;
	return _ != null && (F = /* @__PURE__ */ d("div", {
		className: a,
		children: _
	})), /* @__PURE__ */ d("aside", {
		className: e(r, i({
			size: D,
			state: P
		}), O),
		children: /* @__PURE__ */ f("div", {
			className: s,
			children: [
				/* @__PURE__ */ f("div", {
					className: o,
					children: [!j && m, !E && /* @__PURE__ */ d(t, {
						isCollapsed: j,
						onToggle: N,
						label: S,
						expandLabel: C,
						shortcut: w
					})]
				}),
				h != null && !j && /* @__PURE__ */ d("div", {
					className: "_6jdbjof txvbqb10m7 txvbqb11js txvbqbfpn txvbqbh4x txvbqbhdl",
					children: h
				}),
				/* @__PURE__ */ d("nav", {
					className: c,
					"aria-label": T,
					children: v.map((e) => /* @__PURE__ */ d(n, {
						title: e.title,
						icon: e.icon,
						items: g(e.items, M, j),
						collapsible: e.collapsible,
						defaultCollapsed: e.defaultCollapsed,
						isCollapsed: e.isCollapsed,
						onCollapsedChange: e.onCollapsedChange,
						collapsed: j,
						reorder: e.reorder
					}, e.id))
				}),
				F
			]
		})
	});
};
//#endregion
export { _ as SidebarNavigation, _ as default, t as SidebarNavigationCollapseToggle };

//# sourceMappingURL=SidebarNavigation.js.map