import WidgetCard from "../../WidgetCard.mjs";
import { convertISODate } from "../../utils/ConvertISODate.mjs";
import FluentStatNumber from "../../FluentComponents/molecules/FluentStatNumber.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef } from "react";
import { Box, Divider, Typography, makeStyles, useTheme } from "@material-ui/core";
import { MuiVegaLite } from "@material-vega/material-ui";
import { Sparklines, SparklinesLine } from "react-sparklines";
//#region src/UI/widgets/library/LineAndSparklinesWidget/LineAndSparklinesWidget.jsx
const layout = {
	w: {
		default: 2,
		min: 0,
		max: 4
	},
	h: {
		default: 2,
		min: 0,
		max: 4
	}
};
const useStyles = makeStyles((theme) => ({
	displayItems: {
		display: "flex",
		flexDirection: "row",
		width: "100%"
	},
	visualCaption: { marginTop: theme.spacing(-1) },
	lineGraph: {
		width: "100%",
		"& svg": { width: "100%" }
	}
}));
const LineAndSparklinesWidget = (props, ref) => {
	const $ = c(16);
	let children;
	let other;
	let params;
	if ($[0] !== props) {
		const { children: t0, params: t1, setParam, ...t2 } = props;
		children = t0;
		params = t1;
		other = t2;
		$[0] = props;
		$[1] = children;
		$[2] = other;
		$[3] = params;
	} else {
		children = $[1];
		other = $[2];
		params = $[3];
	}
	const { mockData, theme, dateRange } = params;
	const classes = useStyles();
	const mainTheme = useTheme();
	const t0 = mockData?.title;
	let t1;
	if ($[4] !== children || $[5] !== classes || $[6] !== dateRange || $[7] !== mainTheme || $[8] !== mockData) {
		t1 = mockData ? /* @__PURE__ */ React.createElement("div", null, dateRange && /* @__PURE__ */ React.createElement(Typography, {
			gutterBottom: true,
			variant: "caption",
			component: "h3"
		}, "From: ", convertISODate(dateRange.from), " to:", " ", convertISODate(dateRange.to)), /* @__PURE__ */ React.createElement("div", { className: classes.displayItems }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(FluentStatNumber, {
			number: mockData?.value,
			trend: "up"
		})), /* @__PURE__ */ React.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ React.createElement(Sparklines, {
			data: mockData?.sparklinesData,
			strokeWidth: 1,
			style: {
				width: "100%",
				height: 45,
				marginTop: 10
			}
		}, /* @__PURE__ */ React.createElement(SparklinesLine, { color: mainTheme.palette.secondary.main })), /* @__PURE__ */ React.createElement("div", { className: classes.visualCaption }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Divider, null)), /* @__PURE__ */ React.createElement(Typography, { variant: "caption" }, mockData?.label)))), /* @__PURE__ */ React.createElement(Box, {
			clone: true,
			flex: 1,
			mt: 1,
			overflow: "hidden"
		}, /* @__PURE__ */ React.createElement(MuiVegaLite, {
			variant: "areaLineChart",
			style: { width: "100%" },
			spec: {
				$schema: "https://vega.github.io/schema/vega-lite/v4.json",
				height: 150,
				data: { values: mockData?.data },
				mark: "area",
				encoding: {
					x: {
						field: "xAxis",
						type: mockData?.xAxisType
					},
					y: {
						aggregate: "sum",
						field: "yAxis",
						type: mockData?.yAxisType,
						scale: { domain: mockData?.domain || "" }
					}
				}
			},
			autoResize: "true",
			width: "container"
		})), children) : /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle2" }, "Could not retrieve widget data. Please contact support.");
		$[4] = children;
		$[5] = classes;
		$[6] = dateRange;
		$[7] = mainTheme;
		$[8] = mockData;
		$[9] = t1;
	} else t1 = $[9];
	let t2;
	if ($[10] !== other || $[11] !== ref || $[12] !== t0 || $[13] !== t1 || $[14] !== theme) {
		t2 = /* @__PURE__ */ React.createElement(WidgetCard, {
			ref,
			title: t0,
			theme,
			...other
		}, t1);
		$[10] = other;
		$[11] = ref;
		$[12] = t0;
		$[13] = t1;
		$[14] = theme;
		$[15] = t2;
	} else t2 = $[15];
	return t2;
};
var LineAndSparklinesWidget_default = forwardRef(LineAndSparklinesWidget);
//#endregion
export { LineAndSparklinesWidget_default as default, layout };

//# sourceMappingURL=LineAndSparklinesWidget.mjs.map