import Map from "./openLayerMaps/Map/Map.mjs";
import { Layers } from "./openLayerMaps/Layers/Layers.mjs";
import { TileLayer } from "./openLayerMaps/Layers/TileLayer.mjs";
import osm from "./openLayerMaps/Source/osm.mjs";
import Controls from "./openLayerMaps/Controls/Controls.mjs";
import FullScreenControl from "./openLayerMaps/Controls/FullScreenControl.mjs";
import MapControlsStandard from "./openLayerMaps/ui/MapControlsStandard.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { Toolbar, makeStyles } from "@material-ui/core";
import { fromLonLat } from "ol/proj";
import BingMaps from "ol/source/BingMaps";
import "ol/ol.css";
//#region src/maps/GeoMap.jsx
const useStyles = makeStyles((theme) => ({ toolbar: {
	padding: 0,
	minHeight: theme.spacing(6)
} }));
const GeoMap = (props) => {
	const $ = c(49);
	const { locations, start, mapType, tooltip, bingKey, toolbar, width, height, defaultZoom } = props;
	const classes = useStyles();
	const [center, setCenter] = useState(start);
	const [zoom, setZoom] = useState(defaultZoom);
	const [showLayer1, setShowLayer1] = useState(true);
	const [showLayer2, setShowLayer2] = useState(true);
	const [lat, setLat] = useState();
	const [long, setLong] = useState();
	const [displayType, setDisplayType] = useState(mapType);
	let t0;
	if ($[0] !== start) {
		t0 = () => {
			setCenter(start);
			setZoom(9);
		};
		$[0] = start;
		$[1] = t0;
	} else t0 = $[1];
	const resetPosition = t0;
	let t1;
	if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = (position) => {
			setCenter(position);
			console.log("POSITION", position);
		};
		$[2] = t1;
	} else t1 = $[2];
	const sendPosition = t1;
	let t2;
	if ($[3] !== zoom) {
		t2 = (input) => {
			setZoom(zoom + (input === "in" ? 1 : -1));
		};
		$[3] = zoom;
		$[4] = t2;
	} else t2 = $[4];
	const controlZoom = t2;
	let t3;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = (event, newValue) => {
			setZoom(newValue);
		};
		$[5] = t3;
	} else t3 = $[5];
	const handleSliderChange = t3;
	let t4;
	if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = (event_0) => {
			setZoom(event_0.target.value === "" ? "" : Number(event_0.target.value));
		};
		$[6] = t4;
	} else t4 = $[6];
	const handleInputChange = t4;
	let t5;
	if ($[7] !== zoom) {
		t5 = () => {
			if (zoom < 0) setZoom(0);
			else if (zoom > 100) setZoom(100);
		};
		$[7] = zoom;
		$[8] = t5;
	} else t5 = $[8];
	const handleBlur = t5;
	let t6;
	if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = (event_1) => {
			setLat(event_1.target.value);
		};
		$[9] = t6;
	} else t6 = $[9];
	const handleInputPositionLat = t6;
	let t7;
	if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = (event_2) => {
			setLong(event_2.target.value);
		};
		$[10] = t7;
	} else t7 = $[10];
	const handleInputPositionLong = t7;
	let t8;
	if ($[11] !== lat || $[12] !== long) {
		t8 = () => {
			setCenter([lat, long]);
		};
		$[11] = lat;
		$[12] = long;
		$[13] = t8;
	} else t8 = $[13];
	const setNewPosition = t8;
	let t9;
	if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
		t9 = (event_3, newType) => {
			setDisplayType(newType);
		};
		$[14] = t9;
	} else t9 = $[14];
	const handleViewType = t9;
	let t10;
	if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = (value) => {
			setCenter(value.location);
		};
		$[15] = t10;
	} else t10 = $[15];
	const getLocationValue = t10;
	let t11;
	if ($[16] !== height || $[17] !== width) {
		t11 = {
			width,
			height,
			overflow: "hidden"
		};
		$[16] = height;
		$[17] = width;
		$[18] = t11;
	} else t11 = $[18];
	let t12;
	if ($[19] !== classes || $[20] !== controlZoom || $[21] !== displayType || $[22] !== handleBlur || $[23] !== locations || $[24] !== resetPosition || $[25] !== setNewPosition || $[26] !== showLayer1 || $[27] !== showLayer2 || $[28] !== toolbar || $[29] !== tooltip || $[30] !== zoom) {
		t12 = toolbar && /* @__PURE__ */ React.createElement(Toolbar, { className: classes.toolbar }, /* @__PURE__ */ React.createElement(MapControlsStandard, {
			showLayer1,
			showLayer2,
			setShowLayer1,
			setShowLayer2,
			zoomIn: () => controlZoom("in"),
			zoomOut: () => controlZoom("out"),
			value: zoom,
			setValue: setZoom,
			handleSliderChange,
			handleInputChange,
			handleBlur,
			reset: resetPosition,
			changeLat: handleInputPositionLat,
			changeLong: handleInputPositionLong,
			setPosition: setNewPosition,
			handleChange: handleViewType,
			displayType,
			getLocation: sendPosition,
			locations,
			tooltip,
			getLocationValue
		}));
		$[19] = classes;
		$[20] = controlZoom;
		$[21] = displayType;
		$[22] = handleBlur;
		$[23] = locations;
		$[24] = resetPosition;
		$[25] = setNewPosition;
		$[26] = showLayer1;
		$[27] = showLayer2;
		$[28] = toolbar;
		$[29] = tooltip;
		$[30] = zoom;
		$[31] = t12;
	} else t12 = $[31];
	let t13;
	if ($[32] !== center) {
		t13 = fromLonLat(center);
		$[32] = center;
		$[33] = t13;
	} else t13 = $[33];
	let t14;
	if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = /* @__PURE__ */ React.createElement(TileLayer, {
			source: osm(),
			zIndex: 0
		});
		$[34] = t14;
	} else t14 = $[34];
	let t15;
	if ($[35] !== bingKey || $[36] !== displayType) {
		t15 = new BingMaps({
			preload: Infinity,
			visible: true,
			imagerySet: displayType,
			key: bingKey
		});
		$[35] = bingKey;
		$[36] = displayType;
		$[37] = t15;
	} else t15 = $[37];
	let t16;
	if ($[38] !== t15) {
		t16 = /* @__PURE__ */ React.createElement(Layers, null, t14, /* @__PURE__ */ React.createElement(TileLayer, {
			source: t15,
			zIndex: 0
		}));
		$[38] = t15;
		$[39] = t16;
	} else t16 = $[39];
	let t17;
	if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
		t17 = /* @__PURE__ */ React.createElement(Controls, null, /* @__PURE__ */ React.createElement(FullScreenControl, null));
		$[40] = t17;
	} else t17 = $[40];
	let t18;
	if ($[41] !== t13 || $[42] !== t16 || $[43] !== zoom) {
		t18 = /* @__PURE__ */ React.createElement(Map, {
			center: t13,
			zoom
		}, t16, t17);
		$[41] = t13;
		$[42] = t16;
		$[43] = zoom;
		$[44] = t18;
	} else t18 = $[44];
	let t19;
	if ($[45] !== t11 || $[46] !== t12 || $[47] !== t18) {
		t19 = /* @__PURE__ */ React.createElement("div", { style: t11 }, t12, t18);
		$[45] = t11;
		$[46] = t12;
		$[47] = t18;
		$[48] = t19;
	} else t19 = $[48];
	return t19;
};
//#endregion
export { GeoMap };

//# sourceMappingURL=GeoMap.mjs.map