import MapContext from "../Map/MapContext.mjs";
import { c } from "react-compiler-runtime";
import { useContext, useEffect } from "react";
import OLTileLayer from "ol/layer/Tile";
//#region src/map-library/Layers/TileLayer.js
const TileLayer = (t0) => {
	const $ = c(7);
	const { source, zIndex: t1 } = t0;
	const zIndex = t1 === void 0 ? 0 : t1;
	const { map } = useContext(MapContext);
	let t2;
	if ($[0] !== map || $[1] !== source || $[2] !== zIndex) {
		t2 = () => {
			if (!map) return;
			const tileLayer = new OLTileLayer({
				source,
				zIndex
			});
			map.addLayer(tileLayer);
			tileLayer.setZIndex(zIndex);
			return () => {
				if (map) map.removeLayer(tileLayer);
			};
		};
		$[0] = map;
		$[1] = source;
		$[2] = zIndex;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== map || $[5] !== source) {
		t3 = [map, source];
		$[4] = map;
		$[5] = source;
		$[6] = t3;
	} else t3 = $[6];
	useEffect(t2, t3);
	return null;
};
//#endregion
export { TileLayer };

//# sourceMappingURL=TileLayer.mjs.map