import { cx as e } from "../../../theme/tools.js";
import { actionSlot as t, actions as ee, actionsVisible as n, badge as r, badgeCollapsed as i, dragHandle as a, icon as o, iconNested as s, item as te, itemActive as ne, itemActiveTheme as re, itemCollapsed as ie, itemDisabled as ae, itemDragging as oe, itemNested as se, label as ce, labelCollapsed as le, link as c } from "./sidebarNavItem.css.js";
import { useCallback as ue, useEffect as de, useRef as l, useState as u } from "react";
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
import m from "@plumile/router/routing/Link.js";
//#region src/backoffice/molecules/sidebar_nav_item/SidebarNavItem.tsx
var h = m, g = ({ label: m, href: g, icon: _, badge: v, isActive: y = !1, disabled: b = !1, onClick: fe, collapsed: x = !1, nested: S = !1, ariaLabel: pe, className: C, actionSlot: w, dragHandleSlot: T, dragHandleLabel: E, dragHandleProps: D, isDragging: O = !1, actionsVisibility: k = "auto" }) => {
	let A = l(null), j = l(null), [M, N] = u(!1), [P, F] = u(!1), I = [te];
	x && I.push(ie), S && !x && I.push(se), y && (I.push(ne), I.push(re)), b && I.push(ae), O && I.push(oe), C != null && I.push(C);
	let L = e(...I), R = pe;
	R == null && typeof m == "string" && (R = m);
	let z, B;
	x && (z = R, B = R);
	let V;
	y && (V = "page");
	let H = null;
	_ != null && (H = /* @__PURE__ */ f("span", {
		className: e(o, { [s]: S && !x }),
		children: _
	}));
	let U = null;
	x && (U = le);
	let me = e(ce, U), W = null;
	if (v != null) {
		let t = null;
		x && (t = i), W = /* @__PURE__ */ f("span", {
			className: e(r, t),
			children: v
		});
	}
	let G = /* @__PURE__ */ p(d, { children: [
		H,
		/* @__PURE__ */ f("span", {
			className: me,
			children: m
		}),
		W
	] }), K = () => {
		fe?.();
	}, q = !x && !b && !O && (w != null || T != null), J = ue(() => {
		j.current != null && (clearTimeout(j.current), j.current = null);
	}, []);
	de(() => (q || (N(!1), F(!1), J()), () => {
		J();
	}), [J, q]);
	let he = () => {
		q && (J(), j.current = setTimeout(() => {
			N(!0);
		}, 150));
	}, ge = () => {
		J(), N(!1);
	}, _e = () => {
		q && F(!0);
	}, ve = (e) => {
		if (!q) {
			F(!1);
			return;
		}
		let t = e.relatedTarget;
		t != null && A.current?.contains(t) || F(!1);
	}, Y;
	Y = b ? /* @__PURE__ */ f("span", {
		className: c,
		"aria-disabled": "true",
		"aria-label": z,
		title: B,
		children: G
	}) : g == null ? /* @__PURE__ */ f("button", {
		type: "button",
		className: c,
		onClick: K,
		"aria-current": V,
		"aria-label": z,
		title: B,
		children: G
	}) : /* @__PURE__ */ f(h, {
		to: g,
		className: c,
		"aria-current": V,
		"aria-label": z,
		title: B,
		onClick: K,
		children: G
	});
	let ye = q && (k === "always" || M || P), X;
	ye && (X = n);
	let be = e(ee, X), Z = null;
	T != null && !x && (Z = /* @__PURE__ */ f("button", {
		...D,
		type: "button",
		className: e(a, D?.className),
		"aria-label": E,
		title: E,
		children: T
	}));
	let Q = null;
	w != null && !x && (Q = /* @__PURE__ */ f("span", {
		className: t,
		children: w
	}));
	let $ = null;
	return q && ($ = /* @__PURE__ */ p("span", {
		className: be,
		children: [Z, Q]
	})), /* @__PURE__ */ p("div", {
		className: L,
		onMouseEnter: he,
		onMouseLeave: ge,
		onFocusCapture: _e,
		onBlurCapture: ve,
		ref: A,
		role: "listitem",
		children: [Y, $]
	});
};
//#endregion
export { g as SidebarNavItem, g as default };

//# sourceMappingURL=SidebarNavItem.js.map