import { ThreatMap as e } from "../../visualization/map/index.js";
import { t } from "../../utils-B7XIe3qq.js";
import { useEffect as n, useRef as r } from "react";
import { jsx as i } from "react/jsx-runtime";
//#region src/react/primitives/map.tsx
function a({ center: a, zoom: o, markers: s, regions: c, tileUrl: l, minZoom: u, maxZoom: d, onMarkerClick: f, onRegionClick: p, className: m }) {
	let h = r(null), g = r(null), _ = r(f);
	_.current = f;
	let v = r(p);
	return v.current = p, n(() => {
		let t = h.current;
		if (!t) return;
		let n = {
			container: t,
			onMarkerClick: (e) => _.current?.(e),
			onRegionClick: (e) => v.current?.(e)
		};
		return a !== void 0 && (n.center = a), o !== void 0 && (n.zoom = o), s !== void 0 && (n.markers = s), c !== void 0 && (n.regions = c), l !== void 0 && (n.tileUrl = l), u !== void 0 && (n.minZoom = u), d !== void 0 && (n.maxZoom = d), g.current = new e(n), () => {
			g.current?.destroy(), g.current = null;
		};
	}, [
		l,
		u,
		d
	]), n(() => {
		g.current && a && g.current.setCenter(a.lat, a.lng);
	}, [a]), n(() => {
		g.current && o !== void 0 && g.current.setZoom(o);
	}, [o]), /* @__PURE__ */ i("div", {
		ref: h,
		"data-slot": "map",
		className: t("relative h-full w-full overflow-hidden", m)
	});
}
a.displayName = "Map";
//#endregion
export { a as Map };

//# sourceMappingURL=map.js.map