import { useReadMetaData } from "../hooks/useReadMetaData.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { Box, Grid } from "@material-ui/core";
import { MuiVegaLite } from "@material-vega/material-ui";
//#region src/componentSystems/pageRenderer/wrappers/HistogramWrapper.jsx
const HistogramWrapper = (props) => {
	const $ = c(21);
	const { propsComponent } = props;
	const { id, columnSize } = useReadMetaData(propsComponent);
	const t0 = columnSize?.xs;
	const t1 = columnSize?.sm;
	const t2 = columnSize?.md;
	let t3;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = {
			width: "100%",
			minWidth: "100%"
		};
		$[0] = t3;
	} else t3 = $[0];
	let t4;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = {
			name: "binOffset",
			value: 0,
			bind: {
				input: "range",
				min: -.1,
				max: .1
			}
		};
		$[1] = t4;
	} else t4 = $[1];
	let t5;
	let t6;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = [t4, {
			name: "binStep",
			value: .1,
			bind: {
				input: "range",
				min: .001,
				max: .4,
				step: .001
			}
		}];
		t6 = {
			name: "points",
			url: "data/normal-2d.json"
		};
		$[2] = t5;
		$[3] = t6;
	} else {
		t5 = $[2];
		t6 = $[3];
	}
	let t7;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			type: "bin",
			field: "u",
			extent: [-1, 1],
			anchor: { signal: "binOffset" },
			step: { signal: "binStep" },
			nice: false
		};
		$[4] = t7;
	} else t7 = $[4];
	let t8;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t8 = [t6, {
			name: "binned",
			source: "points",
			transform: [t7, {
				type: "aggregate",
				key: "bin0",
				groupby: ["bin0", "bin1"],
				fields: ["bin0"],
				ops: ["count"],
				as: ["count"]
			}]
		}];
		$[5] = t8;
	} else t8 = $[5];
	let t9;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = {
			name: "xscale",
			type: "linear",
			range: "width",
			domain: [-1, 1]
		};
		$[6] = t9;
	} else t9 = $[6];
	let t10;
	let t11;
	if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = [t9, {
			name: "yscale",
			type: "linear",
			range: "height",
			round: true,
			domain: {
				data: "binned",
				field: "count"
			},
			zero: true,
			nice: true
		}];
		t11 = [{
			orient: "bottom",
			scale: "xscale",
			zindex: 1
		}, {
			orient: "left",
			scale: "yscale",
			tickCount: 5,
			zindex: 1
		}];
		$[7] = t10;
		$[8] = t11;
	} else {
		t10 = $[7];
		t11 = $[8];
	}
	let t12;
	let t13;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = { data: "binned" };
		t13 = {
			scale: "xscale",
			field: "bin0"
		};
		$[9] = t12;
		$[10] = t13;
	} else {
		t12 = $[9];
		t13 = $[10];
	}
	let t14;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = {
			type: "rect",
			from: t12,
			encode: {
				update: {
					x: t13,
					x2: {
						scale: "xscale",
						field: "bin1",
						offset: { signal: "binStep > 0.02 ? -0.5 : 0" }
					},
					y: {
						scale: "yscale",
						field: "count"
					},
					y2: {
						scale: "yscale",
						value: 0
					},
					fill: { value: "steelblue" }
				},
				hover: { fill: { value: "firebrick" } }
			}
		};
		$[11] = t14;
	} else t14 = $[11];
	let t15;
	let t16;
	let t17;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t15 = { data: "points" };
		t16 = {
			scale: "xscale",
			field: "u"
		};
		t17 = { value: 1 };
		$[12] = t15;
		$[13] = t16;
		$[14] = t17;
	} else {
		t15 = $[12];
		t16 = $[13];
		t17 = $[14];
	}
	let t18;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = /* @__PURE__ */ React.createElement(Box, {
			mt: 2,
			clone: true,
			overflow: "hidden",
			sx: t3
		}, /* @__PURE__ */ React.createElement(MuiVegaLite, {
			variant: "histogram",
			color: "secondary",
			background: "paper",
			autoResize: true,
			actions: false,
			spec: {
				$schema: "https://vega.github.io/schema/vega/v5.json",
				description: "An interactive histogram for visualizing a univariate distribution.",
				width: 500,
				height: 100,
				padding: 5,
				signals: t5,
				data: t8,
				scales: t10,
				axes: t11,
				marks: [t14, {
					type: "rect",
					from: t15,
					encode: { enter: {
						x: t16,
						width: t17,
						y: {
							value: 25,
							offset: { signal: "height" }
						},
						height: { value: 5 },
						fill: { value: "steelblue" },
						fillOpacity: { value: .4 }
					} }
				}]
			}
		}));
		$[15] = t18;
	} else t18 = $[15];
	let t19;
	if ($[16] !== id || $[17] !== t0 || $[18] !== t1 || $[19] !== t2) {
		t19 = /* @__PURE__ */ React.createElement(Grid, {
			item: true,
			xs: t0,
			sm: t1,
			md: t2,
			key: id
		}, t18);
		$[16] = id;
		$[17] = t0;
		$[18] = t1;
		$[19] = t2;
		$[20] = t19;
	} else t19 = $[20];
	return t19;
};
//#endregion
export { HistogramWrapper };

//# sourceMappingURL=HistogramWrapper.mjs.map