import { t as e } from "../component-D5sRm1fq.js";
import { t } from "../utils-BC9GT6Pr.js";
import * as n from "react";
import { jsx as r } from "react/jsx-runtime";
//#region src/react/sidebar.tsx
var i = (i) => {
	let { activeItemId: a, pathname: o, onNavigate: s, onCollapse: c, className: l, open: u, ...d } = i, f = n.useRef(null), p = n.useRef(null), m = n.useRef(s), h = n.useRef(c);
	return m.current = s, h.current = c, n.useEffect(() => {
		if (typeof document > "u" || !f.current) return;
		let t = {
			...d,
			container: f.current,
			onNavigate: (e) => {
				m.current?.(e);
			},
			onCollapse: (e) => {
				h.current?.(e);
			}
		};
		return u !== void 0 && (t.open = u), o !== void 0 && (t.pathname = o), p.current = new e(t), () => {
			p.current?.destroy(), p.current = null;
		};
	}, []), n.useEffect(() => {
		p.current && p.current.setOpen(u === !0);
	}, [u]), n.useEffect(() => {
		!p.current || a === void 0 || p.current.setActive(a);
	}, [a]), n.useEffect(() => {
		!p.current || a !== void 0 || p.current.setPathname(o);
	}, [a, o]), /* @__PURE__ */ r("div", {
		ref: f,
		"data-slot": "sidebar",
		className: t(l)
	});
};
i.displayName = "Sidebar";
var a = (e) => e ? "Expand sidebar" : "Collapse sidebar", o = (e) => e ? "m9 18 6-6-6-6" : "m15 18-6-6 6-6", s = ({ collapsed: e }) => /* @__PURE__ */ r("svg", {
	"aria-hidden": "true",
	viewBox: "0 0 24 24",
	fill: "none",
	stroke: "currentColor",
	strokeWidth: "2",
	strokeLinecap: "round",
	strokeLinejoin: "round",
	children: /* @__PURE__ */ r("path", { d: o(e) })
}), c = (e) => {
	let { collapsed: n = !1, edge: i = !1, visible: o = !1, label: c, className: l, type: u = "button", children: d, ...f } = e, p = c ?? a(n);
	return /* @__PURE__ */ r("button", {
		type: u,
		className: t("sidebar__collapse-btn", i && "sidebar__collapse-btn--edge", l),
		"aria-label": p,
		"aria-expanded": !n,
		title: p,
		"data-collapsed": n ? "true" : "false",
		"data-visible": o ? "true" : void 0,
		...f,
		children: d ?? /* @__PURE__ */ r(s, { collapsed: n })
	});
};
c.displayName = "SidebarCollapseButton";
//#endregion
export { i as Sidebar, c as SidebarCollapseButton };

//# sourceMappingURL=sidebar.js.map