import { FluentButton } from "../inputs/buttons/FluentButton.mjs";
import { FluentIcon } from "../../utilities/iconLibrary/FluentIcon.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { Badge, MenuItem, Popover, Tooltip, Typography } from "@material-ui/core";
import { AppIconDefaultIcon, ChevronDownIcon, ErrorIcon } from "@fluentui/react-icons";
//#region src/UI/utilityDisplay/BulkActionsGridButton.jsx
const BulkActionsGridButton = (props) => {
	const $ = c(23);
	const { numSelectedRows, bulkActions, triggerAction, domain } = props;
	const [actionsAnchorEl, setActionsAnchorEl] = useState(null);
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = (event) => {
			setActionsAnchorEl(event.currentTarget);
		};
		$[0] = t0;
	} else t0 = $[0];
	const handleBulkActionsClick = t0;
	let t1;
	if ($[1] !== triggerAction) {
		t1 = (actionId) => {
			triggerAction(actionId);
		};
		$[1] = triggerAction;
		$[2] = t1;
	} else t1 = $[2];
	const triggerBulkAction = t1;
	let t2;
	if ($[3] !== domain) {
		t2 = (action) => !!domain ? JSON.parse(action?.parameters)?.entityName === domain : true;
		$[3] = domain;
		$[4] = t2;
	} else t2 = $[4];
	const filterAction = t2;
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			marginTop: 5,
			marginLeft: 20
		};
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ React.createElement(FluentButton, {
			type: "button",
			onClick: handleBulkActionsClick,
			variant: "outlined",
			color: "primary",
			endIcon: /* @__PURE__ */ React.createElement(FluentIcon, {
				component: ChevronDownIcon,
				size: "small"
			})
		}, "With Selected");
		$[6] = t4;
	} else t4 = $[6];
	let t5;
	if ($[7] !== numSelectedRows) {
		t5 = /* @__PURE__ */ React.createElement(Badge, {
			badgeContent: numSelectedRows,
			color: "secondary"
		}, t4);
		$[7] = numSelectedRows;
		$[8] = t5;
	} else t5 = $[8];
	const t6 = Boolean(actionsAnchorEl);
	let t7;
	let t8;
	let t9;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = () => setActionsAnchorEl(null);
		t8 = {
			vertical: "bottom",
			horizontal: "right"
		};
		t9 = {
			vertical: "top",
			horizontal: "right"
		};
		$[9] = t7;
		$[10] = t8;
		$[11] = t9;
	} else {
		t7 = $[9];
		t8 = $[10];
		t9 = $[11];
	}
	let t10;
	if ($[12] !== bulkActions || $[13] !== filterAction || $[14] !== triggerBulkAction) {
		t10 = bulkActions && bulkActions.map((action_0) => {
			const valid = filterAction(action_0);
			return /* @__PURE__ */ React.createElement(Tooltip, {
				placement: "right",
				title: !valid ? "Action entity does not match data grid entity" : ""
			}, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(MenuItem, {
				onClick: () => triggerBulkAction(action_0.actionId),
				style: {
					display: "flex",
					justifyContent: "space-between"
				},
				disabled: !valid
			}, /* @__PURE__ */ React.createElement(Typography, null, action_0.name), /* @__PURE__ */ React.createElement(FluentIcon, {
				component: valid ? action_0.icon ?? AppIconDefaultIcon : ErrorIcon,
				style: { marginLeft: 7 },
				color: !valid && "red"
			}))));
		});
		$[12] = bulkActions;
		$[13] = filterAction;
		$[14] = triggerBulkAction;
		$[15] = t10;
	} else t10 = $[15];
	let t11;
	if ($[16] !== actionsAnchorEl || $[17] !== t10 || $[18] !== t6) {
		t11 = /* @__PURE__ */ React.createElement(Popover, {
			id: "actions",
			open: t6,
			anchorEl: actionsAnchorEl,
			onClose: t7,
			anchorOrigin: t8,
			transformOrigin: t9
		}, t10);
		$[16] = actionsAnchorEl;
		$[17] = t10;
		$[18] = t6;
		$[19] = t11;
	} else t11 = $[19];
	let t12;
	if ($[20] !== t11 || $[21] !== t5) {
		t12 = /* @__PURE__ */ React.createElement("div", { style: t3 }, t5, t11);
		$[20] = t11;
		$[21] = t5;
		$[22] = t12;
	} else t12 = $[22];
	return t12;
};
//#endregion
export { BulkActionsGridButton };

//# sourceMappingURL=BulkActionsGridButton.mjs.map