import { FluentIconButton } from "../../UI/inputs/buttons/FluentIconButton.mjs";
import { AmbientPopoverMenuItem } from "../../UI/inputs/buttons/AmbientPopoverMenuItem.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { Popover, Typography, makeStyles, useTheme } from "@material-ui/core";
import { ChevronDownIcon } from "@fluentui/react-icons";
import PropTypes from "prop-types";
//#region src/shell/ui/AmbientProjectSwitcher.jsx
const useStyles = makeStyles((theme) => ({
	root: {
		display: "flex",
		background: (props) => props.backgroundColor ? props.backgroundColor : theme.palette.secondary.main,
		borderRadius: 50,
		padding: 6,
		paddingLeft: 16
	},
	popoverRoot: {},
	icon: {
		color: theme.palette.primary.main,
		borderRadius: 50
	},
	label: {
		display: "block",
		width: (props) => props.width ? props.width : 100,
		overflow: "hidden",
		whiteSpace: "nowrap",
		textOverflow: "ellipsis"
	},
	listWrapper: { marginRight: theme.spacing(2) }
}));
const AmbientProjectSwitcher = (props) => {
	const $ = c(32);
	const classes = useStyles(props);
	const theme = useTheme();
	const { data, selectedItem } = props;
	const [anchorEl, setAnchorEl] = useState(null);
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = (event) => {
			setAnchorEl(event.currentTarget);
		};
		$[0] = t0;
	} else t0 = $[0];
	const handleClick = t0;
	let t1;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = () => {
			setAnchorEl(null);
		};
		$[1] = t1;
	} else t1 = $[1];
	const handleClose = t1;
	const open = Boolean(anchorEl);
	const id = open ? "open" : void 0;
	let t2;
	if ($[2] !== classes.label || $[3] !== selectedItem) {
		t2 = /* @__PURE__ */ React.createElement(Typography, { className: classes.label }, selectedItem);
		$[2] = classes.label;
		$[3] = selectedItem;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] !== classes.listWrapper || $[6] !== t2) {
		t3 = /* @__PURE__ */ React.createElement("div", { className: classes.listWrapper }, t2);
		$[5] = classes.listWrapper;
		$[6] = t2;
		$[7] = t3;
	} else t3 = $[7];
	let t4;
	if ($[8] !== theme.palette.common.white) {
		t4 = { background: theme.palette.common.white };
		$[8] = theme.palette.common.white;
		$[9] = t4;
	} else t4 = $[9];
	let t5;
	if ($[10] !== classes.icon || $[11] !== t4) {
		t5 = /* @__PURE__ */ React.createElement(FluentIconButton, {
			className: classes.icon,
			icon: ChevronDownIcon,
			onClick: handleClick,
			style: t4
		});
		$[10] = classes.icon;
		$[11] = t4;
		$[12] = t5;
	} else t5 = $[12];
	let t6;
	if ($[13] !== classes.popoverRoot) {
		t6 = { root: classes.popoverRoot };
		$[13] = classes.popoverRoot;
		$[14] = t6;
	} else t6 = $[14];
	let t7;
	let t8;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			vertical: "bottom",
			horizontal: "right"
		};
		t8 = {
			vertical: "top",
			horizontal: "right"
		};
		$[15] = t7;
		$[16] = t8;
	} else {
		t7 = $[15];
		t8 = $[16];
	}
	let t9;
	if ($[17] !== data) {
		t9 = data && data.map(_temp);
		$[17] = data;
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	if ($[19] !== t9) {
		t10 = /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, t9));
		$[19] = t9;
		$[20] = t10;
	} else t10 = $[20];
	let t11;
	if ($[21] !== anchorEl || $[22] !== id || $[23] !== open || $[24] !== t10 || $[25] !== t6) {
		t11 = /* @__PURE__ */ React.createElement(Popover, {
			classes: t6,
			square: true,
			elevation: 6,
			id,
			open,
			anchorEl,
			onClose: handleClose,
			anchorOrigin: t7,
			transformOrigin: t8
		}, t10);
		$[21] = anchorEl;
		$[22] = id;
		$[23] = open;
		$[24] = t10;
		$[25] = t6;
		$[26] = t11;
	} else t11 = $[26];
	let t12;
	if ($[27] !== classes.root || $[28] !== t11 || $[29] !== t3 || $[30] !== t5) {
		t12 = /* @__PURE__ */ React.createElement("div", { className: classes.root }, t3, t5, t11);
		$[27] = classes.root;
		$[28] = t11;
		$[29] = t3;
		$[30] = t5;
		$[31] = t12;
	} else t12 = $[31];
	return t12;
};
AmbientProjectSwitcher.propTypes = {
	data: PropTypes.array,
	selectedItem: PropTypes.string,
	backgroundColor: PropTypes.string
};
function _temp(item) {
	return /* @__PURE__ */ React.createElement(AmbientPopoverMenuItem, {
		label: item.label,
		component: ChevronDownIcon,
		click: () => item.click(item.label)
	});
}
//#endregion
export { AmbientProjectSwitcher };

//# sourceMappingURL=AmbientProjectSwitcher.mjs.map