import { evaluateRule, mapRule } from "../utilities/rules/RuleUtilities.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect, useState } from "react";
import { Chip, makeStyles, useTheme } from "@material-ui/core";
//#region src/UI/AlertContainer.jsx
const useStyles = makeStyles((theme) => ({
	root: {
		display: "grid",
		gridTemplateColumns: "auto auto"
	},
	alertContainer: { margin: "0.3em" },
	chipStyle: {
		maxWidth: "150px",
		textOverflow: "ellipsis"
	}
}));
const AlertContainer = (props) => {
	const $ = c(26);
	const { data } = props;
	const theme = useTheme();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = [];
		$[0] = t0;
	} else t0 = $[0];
	const [alertData, setAlertData] = useState(t0);
	const classes = useStyles(props);
	let t1;
	let t2;
	if ($[1] !== data) {
		t1 = () => {
			if (data?.properties?.alerts) {
				const tempData = [];
				data.properties.alerts.forEach((alert) => {
					if (evaluateRule(mapRule(alert.propertyMapping, alert.jsonLogic), data.nodeObj, data.properties?.joiningEntityCatalogObjectKey, data.wasLazyLoaded)) tempData.push(alert);
				});
				setAlertData(tempData);
			}
		};
		t2 = [data];
		$[1] = data;
		$[2] = t1;
		$[3] = t2;
	} else {
		t1 = $[2];
		t2 = $[3];
	}
	useEffect(t1, t2);
	if (alertData.length > 0) {
		const t3 = classes.root;
		let t4;
		if ($[4] !== alertData || $[5] !== classes.alertContainer || $[6] !== classes.chipStyle || $[7] !== theme) {
			let t5;
			if ($[9] !== classes.alertContainer || $[10] !== classes.chipStyle || $[11] !== theme) {
				t5 = (alert_0) => /* @__PURE__ */ React.createElement("div", { className: classes.alertContainer }, /* @__PURE__ */ React.createElement(Chip, {
					label: alert_0.label,
					style: { backgroundColor: alert_0 ? alert_0.alertColor.hex : theme.palette.secondary.main },
					className: classes.chipStyle
				}));
				$[9] = classes.alertContainer;
				$[10] = classes.chipStyle;
				$[11] = theme;
				$[12] = t5;
			} else t5 = $[12];
			t4 = alertData.filter(_temp).map(t5);
			$[4] = alertData;
			$[5] = classes.alertContainer;
			$[6] = classes.chipStyle;
			$[7] = theme;
			$[8] = t4;
		} else t4 = $[8];
		let t5;
		if ($[13] !== alertData || $[14] !== classes.alertContainer || $[15] !== classes.chipStyle || $[16] !== theme) {
			let t6;
			if ($[18] !== classes.alertContainer || $[19] !== classes.chipStyle || $[20] !== theme) {
				t6 = (alert_1) => /* @__PURE__ */ React.createElement("div", { className: classes.alertContainer }, /* @__PURE__ */ React.createElement(Chip, {
					label: alert_1.label,
					style: { backgroundColor: alert_1 ? alert_1.alertColor.hex : theme.palette.secondary.main },
					className: classes.chipStyle
				}));
				$[18] = classes.alertContainer;
				$[19] = classes.chipStyle;
				$[20] = theme;
				$[21] = t6;
			} else t6 = $[21];
			t5 = alertData.filter(_temp2).map(t6);
			$[13] = alertData;
			$[14] = classes.alertContainer;
			$[15] = classes.chipStyle;
			$[16] = theme;
			$[17] = t5;
		} else t5 = $[17];
		let t6;
		if ($[22] !== classes.root || $[23] !== t4 || $[24] !== t5) {
			t6 = /* @__PURE__ */ React.createElement("div", { className: t3 }, t4, t5);
			$[22] = classes.root;
			$[23] = t4;
			$[24] = t5;
			$[25] = t6;
		} else t6 = $[25];
		return t6;
	} else return null;
};
function _temp(item, i) {
	return i % 2 === 0;
}
function _temp2(item_0, i_0) {
	return i_0 % 2 !== 0 && i_0 !== 0;
}
//#endregion
export { AlertContainer };

//# sourceMappingURL=AlertContainer.mjs.map