import { useShellStore } from "../../stores/shellStore.mjs";
import { useBuildEnvironment } from "./useBuildEnvironment.mjs";
import { SidebarCollapseButton } from "./SidebarCollapseButton.mjs";
import MiniCollapsibleSidebar from "./MiniCollapsibleSidebar.mjs";
import { AppMenu } from "../../UI/navigation/menus/AppMenu.mjs";
import { MenuLoader } from "../../UI/feedback/MenuLoader.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { Toolbar, lighten, makeStyles } from "@material-ui/core";
//#region src/shell/ui/NavigationSidebar.jsx
const useStyles = makeStyles((theme) => ({
	root: { marginTop: 400 },
	paper: {
		backgroundColor: theme?.getThemeData()?.mode === "dark" ? "" : lighten(theme?.palette?.primary?.main, .9),
		overflowX: "hidden"
	},
	list: {
		flex: 1,
		paddingTop: 0,
		overflowY: "auto",
		WebkitOverflowScrolling: "touch"
	},
	spacer: {
		flex: 1,
		minHeight: theme.spacing(2)
	},
	footer: {},
	toolbar: {
		padding: 0,
		minHeight: ({ appRibbonSpace }) => theme.spacing(6) + appRibbonSpace
	}
}), { name: "NavigationSidebar" });
const NavigationSidebar = (props) => {
	const $ = c(44);
	const t0 = useBuildEnvironment() ? 25 : 0;
	let t1;
	if ($[0] !== t0) {
		t1 = { appRibbonSpace: t0 };
		$[0] = t0;
		$[1] = t1;
	} else t1 = $[1];
	const classes = useStyles(t1);
	let data;
	let navMenuHoverOn;
	let other;
	let t2;
	let t3;
	let t4;
	let user;
	if ($[2] !== props) {
		const { data: t5, toggleExpandClick, navMenuHoverOn: t6, user: t7, toggle: t8, useGlobalState: t9, leftMenuLoading: t10, ...t11 } = props;
		data = t5;
		navMenuHoverOn = t6;
		user = t7;
		t2 = t8;
		t3 = t9;
		t4 = t10;
		other = t11;
		$[2] = props;
		$[3] = data;
		$[4] = navMenuHoverOn;
		$[5] = other;
		$[6] = t2;
		$[7] = t3;
		$[8] = t4;
		$[9] = user;
	} else {
		data = $[3];
		navMenuHoverOn = $[4];
		other = $[5];
		t2 = $[6];
		t3 = $[7];
		t4 = $[8];
		user = $[9];
	}
	const toggle = t2 === void 0 ? true : t2;
	const useGlobalState = t3 === void 0 ? false : t3;
	const leftMenuLoading = t4 === void 0 ? false : t4;
	const [expanded, setExpanded] = useState(true);
	const { navigationExpanded, setNavigationExpanded } = useShellStore();
	const navExpanded = useGlobalState ? navigationExpanded : expanded;
	const [hoverExpand, setHoverExpand] = useState(false);
	let t5;
	if ($[10] !== navExpanded || $[11] !== navMenuHoverOn) {
		t5 = () => {
			if (!navExpanded && navMenuHoverOn) setHoverExpand(true);
		};
		$[10] = navExpanded;
		$[11] = navMenuHoverOn;
		$[12] = t5;
	} else t5 = $[12];
	const handleHoverToggle = t5;
	let t6;
	if ($[13] !== navExpanded || $[14] !== navMenuHoverOn) {
		t6 = () => {
			if (!navExpanded && navMenuHoverOn) setHoverExpand(false);
		};
		$[13] = navExpanded;
		$[14] = navMenuHoverOn;
		$[15] = t6;
	} else t6 = $[15];
	const handleHoverLeave = t6;
	let t7;
	if ($[16] !== navigationExpanded || $[17] !== setNavigationExpanded || $[18] !== useGlobalState) {
		t7 = () => {
			if (useGlobalState) setNavigationExpanded(!navigationExpanded);
			else setExpanded(_temp);
		};
		$[16] = navigationExpanded;
		$[17] = setNavigationExpanded;
		$[18] = useGlobalState;
		$[19] = t7;
	} else t7 = $[19];
	const handleToggleClick = t7;
	let t8;
	if ($[20] !== classes.paper || $[21] !== classes.root) {
		t8 = {
			root: classes.root,
			paper: classes.paper
		};
		$[20] = classes.paper;
		$[21] = classes.root;
		$[22] = t8;
	} else t8 = $[22];
	const t9 = navExpanded || hoverExpand;
	let t10;
	if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = {
			elevation: 0,
			variant: "outlined"
		};
		$[23] = t10;
	} else t10 = $[23];
	let t11;
	if ($[24] !== classes.toolbar) {
		t11 = /* @__PURE__ */ React.createElement(Toolbar, { className: classes.toolbar });
		$[24] = classes.toolbar;
		$[25] = t11;
	} else t11 = $[25];
	let t12;
	if ($[26] !== handleToggleClick || $[27] !== navExpanded || $[28] !== toggle) {
		t12 = toggle && /* @__PURE__ */ React.createElement(SidebarCollapseButton, {
			id: "udpRecord-NavigationSidebar",
			udprecordid: "udpRecord-NavigationSidebar",
			expanded: navExpanded,
			onClick: handleToggleClick
		});
		$[26] = handleToggleClick;
		$[27] = navExpanded;
		$[28] = toggle;
		$[29] = t12;
	} else t12 = $[29];
	let t13;
	if ($[30] !== data || $[31] !== leftMenuLoading || $[32] !== navExpanded || $[33] !== user) {
		t13 = leftMenuLoading || !data ? /* @__PURE__ */ React.createElement(MenuLoader, { numOfPlaceholderNodes: 6 }) : /* @__PURE__ */ React.createElement(AppMenu, {
			menuItems: data,
			sidebarExpanded: navExpanded,
			user
		});
		$[30] = data;
		$[31] = leftMenuLoading;
		$[32] = navExpanded;
		$[33] = user;
		$[34] = t13;
	} else t13 = $[34];
	let t14;
	if ($[35] !== handleHoverLeave || $[36] !== handleHoverToggle || $[37] !== other || $[38] !== t11 || $[39] !== t12 || $[40] !== t13 || $[41] !== t8 || $[42] !== t9) {
		t14 = /* @__PURE__ */ React.createElement(MiniCollapsibleSidebar, {
			classes: t8,
			expanded: t9,
			onMouseEnter: handleHoverToggle,
			onMouseLeave: handleHoverLeave,
			PaperProps: t10,
			...other
		}, t11, t12, t13);
		$[35] = handleHoverLeave;
		$[36] = handleHoverToggle;
		$[37] = other;
		$[38] = t11;
		$[39] = t12;
		$[40] = t13;
		$[41] = t8;
		$[42] = t9;
		$[43] = t14;
	} else t14 = $[43];
	return t14;
};
function _temp(expanded_0) {
	return !expanded_0;
}
//#endregion
export { NavigationSidebar as default };

//# sourceMappingURL=NavigationSidebar.mjs.map