import FUICard_default, { FUICardHeaderMenu } from "../UI/surfaces/cards/fluentCards/FUICard.mjs";
import FUIMenuItem_default from "../UI/widgets/FluentComponents/FUIMenuItem.mjs";
import React from "react";
import { CircularProgress, makeStyles } from "@material-ui/core";
import clsx from "clsx";
import { DeleteIcon } from "@fluentui/react-icons";
//#region src/dashboard/WidgetCard.jsx
/**
* Core component for dashboard widget cards
*/
const WidgetCard = (props) => {
	const { children, headerActions, className, widgetType, id, layout, params, setParam, onDelete, loading, errors, theme, hideWidgetName, innerPadding, contentHeight, contentMaxHeight, ...other } = props;
	const classes = makeStyles((theme_0) => ({
		root: { "&.react-resizable-hide .react-resizable-handle": { display: "none" } },
		darkRoot: {
			"&.react-resizable-hide .react-resizable-handle": { display: "none" },
			background: "#424242",
			color: "white"
		},
		anyRoot: { "& .MuiCardContent-root": {
			justifyContent: "space-between",
			overflow: "auto",
			padding: 0
		} },
		handle: {
			cursor: "move",
			"&:hover": { backgroundColor: theme_0.palette.action.hover },
			display: hideWidgetName && "none"
		},
		loadingContent: {
			flex: 1,
			display: "flex",
			flexDirection: "column",
			alignItems: "center",
			justifyContent: "center"
		},
		innerWidgetContentContainer: {
			height: widgetType === "TransformerLoadWidget" ? "auto" : contentHeight ? contentHeight : "100%",
			maxHeight: contentMaxHeight ? contentMaxHeight : "",
			minWidth: widgetType === "ProgressBarWidget" ? 0 : 270,
			display: "flex",
			flexDirection: "column",
			justifyContent: "space-between",
			padding: innerPadding || (widgetType === "VEERegisterRead" ? 0 : theme_0.spacing(2))
		}
	}))();
	const raised = /(^|\s)react-draggable-dragging(\s|$)/.test(className ?? "");
	let body = children;
	if (loading && !body) body = /* @__PURE__ */ React.createElement("div", { className: classes.loadingContent }, /* @__PURE__ */ React.createElement(CircularProgress, { size: 64 }));
	if (errors && !body) body = /* @__PURE__ */ React.createElement("div", null, "Unexpected error");
	return /* @__PURE__ */ React.createElement(FUICard_default, {
		...other,
		className: clsx(className, theme === "dark" ? classes.darkRoot : classes.root, classes.anyRoot),
		raised,
		CardHeaderProps: {
			className: classes.handle,
			"data-handle": true
		},
		headerActions: /* @__PURE__ */ React.createElement(React.Fragment, null, headerActions, /* @__PURE__ */ React.createElement(FUICardHeaderMenu, null, /* @__PURE__ */ React.createElement(FUIMenuItem_default, {
			onClick: onDelete,
			fluentIcon: DeleteIcon,
			primary: "Delete"
		})))
	}, /* @__PURE__ */ React.createElement("div", { className: classes.innerWidgetContentContainer }, body));
};
//#endregion
export { WidgetCard };

//# sourceMappingURL=WidgetCard.mjs.map