@classic-homes/maps-react 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as React6 from 'react';
1
+ import * as React25 from 'react';
2
2
  import { useState, useEffect, useCallback } from 'react';
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
@@ -7,16 +7,19 @@ import maplibregl from 'maplibre-gl';
7
7
  import 'maplibre-gl/dist/maplibre-gl.css';
8
8
  import '@classic-homes/maps-core/styles/controls.css';
9
9
  import '@classic-homes/maps-core/styles/marker.css';
10
- import { generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, darkBasicStyle, lightBasicStyle, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, computeVerticalOffsetStyle, computePositionClasses, formatCoordinates } from '@classic-homes/maps-core';
11
- export { THEME_DARK, THEME_LIGHT, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getSelectionStyle, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, validateGeoJSON } from '@classic-homes/maps-core';
10
+ import { generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, darkBasicStyle, lightBasicStyle, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, computeVerticalOffsetStyle, computePositionClasses, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
11
+ export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
12
12
  import * as ReactDOM from 'react-dom';
13
13
  import { cva } from 'class-variance-authority';
14
+ import '@classic-homes/maps-core/styles/basemap-switcher.css';
15
+ import '@classic-homes/maps-core/styles/layer-manager.css';
16
+ import { Switch } from '@classic-homes/theme-react';
14
17
 
15
18
  // src/components/base/MapContainer.tsx
16
19
  function cn(...inputs) {
17
20
  return twMerge(clsx(inputs));
18
21
  }
19
- var MapSkeleton = React6.forwardRef(
22
+ var MapSkeleton = React25.forwardRef(
20
23
  ({ height = 400, className, ...props }, ref) => {
21
24
  const heightStyle = typeof height === "number" ? `${height}px` : height;
22
25
  return /* @__PURE__ */ jsxs(
@@ -70,7 +73,7 @@ var MapSkeleton = React6.forwardRef(
70
73
  }
71
74
  );
72
75
  MapSkeleton.displayName = "MapSkeleton";
73
- var MapError = React6.forwardRef(
76
+ var MapError = React25.forwardRef(
74
77
  ({ message = "Failed to load map", height = 400, onRetry, className, ...props }, ref) => {
75
78
  const heightStyle = typeof height === "number" ? `${height}px` : height;
76
79
  return /* @__PURE__ */ jsx(
@@ -124,7 +127,7 @@ var MapError = React6.forwardRef(
124
127
  }
125
128
  );
126
129
  MapError.displayName = "MapError";
127
- var MapEmpty = React6.forwardRef(
130
+ var MapEmpty = React25.forwardRef(
128
131
  ({ message = "No map data to display", height = 400, className, ...props }, ref) => {
129
132
  const heightStyle = typeof height === "number" ? `${height}px` : height;
130
133
  return /* @__PURE__ */ jsx(
@@ -167,7 +170,7 @@ var MapEmpty = React6.forwardRef(
167
170
  }
168
171
  );
169
172
  MapEmpty.displayName = "MapEmpty";
170
- var MapContainer = React6.forwardRef(
173
+ var MapContainer = React25.forwardRef(
171
174
  ({
172
175
  title,
173
176
  description,
@@ -272,9 +275,9 @@ function useReducedMotion() {
272
275
  }, []);
273
276
  return prefersReducedMotion2;
274
277
  }
275
- var MapContext = React6.createContext(null);
278
+ var MapContext = React25.createContext(null);
276
279
  function useMap() {
277
- const context = React6.useContext(MapContext);
280
+ const context = React25.useContext(MapContext);
278
281
  if (!context) {
279
282
  throw new Error("useMap must be used within a Map component");
280
283
  }
@@ -284,7 +287,7 @@ function useMapInstance() {
284
287
  const { map, loaded } = useMap();
285
288
  return loaded ? map : null;
286
289
  }
287
- var Map = React6.forwardRef(
290
+ var Map2 = React25.forwardRef(
288
291
  ({
289
292
  // Base props
290
293
  title,
@@ -338,25 +341,33 @@ var Map = React6.forwardRef(
338
341
  onZoom,
339
342
  onError
340
343
  }, ref) => {
341
- const containerRef = React6.useRef(null);
342
- const mapRef = React6.useRef(null);
343
- const [mapLoaded, setMapLoaded] = React6.useState(false);
344
- const [mapError, setMapError] = React6.useState(null);
345
- const customControlRegistryRef = React6.useRef({
344
+ const containerRef = React25.useRef(null);
345
+ const mapRef = React25.useRef(null);
346
+ const [mapLoaded, setMapLoaded] = React25.useState(false);
347
+ const [mapError, setMapError] = React25.useState(null);
348
+ const [styleVersion, setStyleVersion] = React25.useState(0);
349
+ const activeStyleOverrideRef = React25.useRef(
350
+ null
351
+ );
352
+ const setMapStyle = React25.useCallback((style) => {
353
+ activeStyleOverrideRef.current = style;
354
+ mapRef.current?.setStyle(style);
355
+ }, []);
356
+ const customControlRegistryRef = React25.useRef({
346
357
  "top-left": [],
347
358
  "top-right": [],
348
359
  "bottom-left": [],
349
360
  "bottom-right": []
350
361
  });
351
- const [, forceUpdate] = React6.useReducer((x) => x + 1, 0);
362
+ const [, forceUpdate] = React25.useReducer((x) => x + 1, 0);
352
363
  const prefersReducedMotion2 = useReducedMotion();
353
364
  const { style: themeStyle } = useMapTheme(themePref);
354
- const onLoadRef = React6.useRef(onLoad);
365
+ const onLoadRef = React25.useRef(onLoad);
355
366
  onLoadRef.current = onLoad;
356
- const onErrorRef = React6.useRef(onError);
367
+ const onErrorRef = React25.useRef(onError);
357
368
  onErrorRef.current = onError;
358
369
  const mapStyle = customStyle || themeStyle;
359
- const controlOffsets = React6.useMemo(() => {
370
+ const controlOffsets = React25.useMemo(() => {
360
371
  const offsets = {
361
372
  "top-left": 0,
362
373
  "top-right": 0,
@@ -386,7 +397,7 @@ var Map = React6.forwardRef(
386
397
  geolocateControl,
387
398
  geolocateControlPosition
388
399
  ]);
389
- const registerControl = React6.useCallback(
400
+ const registerControl = React25.useCallback(
390
401
  (id, position, height2) => {
391
402
  const registry = customControlRegistryRef.current;
392
403
  const positionControls = registry[position] || [];
@@ -407,13 +418,13 @@ var Map = React6.forwardRef(
407
418
  },
408
419
  []
409
420
  );
410
- const unregisterControl = React6.useCallback((id, position) => {
421
+ const unregisterControl = React25.useCallback((id, position) => {
411
422
  const registry = customControlRegistryRef.current;
412
423
  const positionControls = registry[position] || [];
413
424
  registry[position] = positionControls.filter((c) => c.id !== id);
414
425
  forceUpdate();
415
426
  }, []);
416
- const getCustomControlOffset = React6.useCallback((id, position) => {
427
+ const getCustomControlOffset = React25.useCallback((id, position) => {
417
428
  const registry = customControlRegistryRef.current;
418
429
  const positionControls = registry[position] || [];
419
430
  let offset = 0;
@@ -427,7 +438,7 @@ var Map = React6.forwardRef(
427
438
  center,
428
439
  zoom
429
440
  });
430
- React6.useEffect(() => {
441
+ React25.useEffect(() => {
431
442
  if (!containerRef.current || mapRef.current) return;
432
443
  try {
433
444
  const map = new maplibregl.Map({
@@ -450,6 +461,9 @@ var Map = React6.forwardRef(
450
461
  attributionControl: attributionControl ? { customAttribution } : false
451
462
  });
452
463
  mapRef.current = map;
464
+ map.on("style.load", () => {
465
+ setStyleVersion((v) => v + 1);
466
+ });
453
467
  if (navigationControl) {
454
468
  map.addControl(
455
469
  new maplibregl.NavigationControl({
@@ -504,16 +518,22 @@ var Map = React6.forwardRef(
504
518
  onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
505
519
  }
506
520
  }, []);
507
- const styleInitialized = React6.useRef(false);
508
- React6.useEffect(() => {
521
+ const styleInitialized = React25.useRef(false);
522
+ React25.useEffect(() => {
509
523
  if (!mapRef.current || !mapLoaded) return;
510
524
  if (!styleInitialized.current) {
511
525
  styleInitialized.current = true;
512
526
  return;
513
527
  }
528
+ if (activeStyleOverrideRef.current) return;
514
529
  mapRef.current.setStyle(mapStyle);
515
530
  }, [mapStyle, mapLoaded]);
516
- React6.useEffect(() => {
531
+ React25.useEffect(() => {
532
+ if (customStyle) {
533
+ activeStyleOverrideRef.current = null;
534
+ }
535
+ }, [customStyle]);
536
+ React25.useEffect(() => {
517
537
  const map = mapRef.current;
518
538
  if (!map || !mapLoaded) return;
519
539
  const createEventParams = (e) => ({
@@ -633,7 +653,9 @@ var Map = React6.forwardRef(
633
653
  controlOffsets,
634
654
  registerControl,
635
655
  unregisterControl,
636
- getCustomControlOffset
656
+ getCustomControlOffset,
657
+ styleVersion,
658
+ setMapStyle
637
659
  },
638
660
  children: [
639
661
  /* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
@@ -645,7 +667,7 @@ var Map = React6.forwardRef(
645
667
  );
646
668
  }
647
669
  );
648
- Map.displayName = "Map";
670
+ Map2.displayName = "Map";
649
671
  var Source = ({
650
672
  id,
651
673
  type,
@@ -665,10 +687,10 @@ var Source = ({
665
687
  fitBoundsAnimate = true,
666
688
  children
667
689
  }) => {
668
- const { map, loaded } = useMap();
669
- const sourceAdded = React6.useRef(false);
670
- const initialFitDone = React6.useRef(false);
671
- const fitBoundsParamsRef = React6.useRef({
690
+ const { map, loaded, styleVersion } = useMap();
691
+ const sourceAdded = React25.useRef(false);
692
+ const initialFitDone = React25.useRef(false);
693
+ const fitBoundsParamsRef = React25.useRef({
672
694
  shouldFitBounds,
673
695
  data,
674
696
  fitBoundsPadding,
@@ -684,7 +706,7 @@ var Source = ({
684
706
  fitBoundsAnimate,
685
707
  type
686
708
  };
687
- const performFitBounds = React6.useCallback(
709
+ const performFitBounds = React25.useCallback(
688
710
  (cancelledRef) => {
689
711
  const params = fitBoundsParamsRef.current;
690
712
  if (cancelledRef.current || !params.shouldFitBounds || initialFitDone.current) return;
@@ -728,7 +750,7 @@ var Source = ({
728
750
  },
729
751
  [map]
730
752
  );
731
- React6.useEffect(() => {
753
+ React25.useEffect(() => {
732
754
  if (!map || !loaded || sourceAdded.current) return;
733
755
  if (map.getSource(id)) {
734
756
  sourceAdded.current = true;
@@ -854,7 +876,6 @@ var Source = ({
854
876
  } catch {
855
877
  }
856
878
  sourceAdded.current = false;
857
- initialFitDone.current = false;
858
879
  }
859
880
  };
860
881
  } catch (err) {
@@ -874,27 +895,44 @@ var Source = ({
874
895
  clusterMaxZoom,
875
896
  generateId,
876
897
  promoteId,
877
- performFitBounds
898
+ performFitBounds,
878
899
  // stable due to using ref for params
900
+ styleVersion
901
+ // re-add source after basemap style changes
879
902
  ]);
880
- React6.useEffect(() => {
903
+ React25.useEffect(() => {
881
904
  if (!map || !loaded || !sourceAdded.current || type !== "geojson") return;
882
905
  const source = map.getSource(id);
883
906
  if (!source) return;
907
+ let cancelled = false;
884
908
  try {
885
- if (typeof data === "string") {
886
- source.setData(data);
887
- } else if (data && typeof data === "object") {
888
- source.setData(data);
909
+ const newData = typeof data === "string" ? data : data && typeof data === "object" ? data : null;
910
+ if (!newData) return;
911
+ const handleSourceData = (e) => {
912
+ if (cancelled) return;
913
+ if (e.sourceId === id && e.isSourceLoaded) {
914
+ map.off("sourcedata", handleSourceData);
915
+ map.triggerRepaint();
916
+ }
917
+ };
918
+ if (cluster) {
919
+ map.on("sourcedata", handleSourceData);
889
920
  }
921
+ source.setData(newData);
922
+ return () => {
923
+ cancelled = true;
924
+ if (cluster) {
925
+ map.off("sourcedata", handleSourceData);
926
+ }
927
+ };
890
928
  } catch (err) {
891
929
  console.error(`[maps-react] Failed to update source "${id}" data:`, err);
892
930
  }
893
- }, [map, loaded, id, type, data]);
931
+ }, [map, loaded, id, type, data, cluster]);
894
932
  return /* @__PURE__ */ jsx(Fragment, { children });
895
933
  };
896
934
  Source.displayName = "Source";
897
- var Marker = React6.forwardRef(
935
+ var Marker = React25.forwardRef(
898
936
  ({
899
937
  id,
900
938
  coordinates,
@@ -910,27 +948,27 @@ var Marker = React6.forwardRef(
910
948
  children
911
949
  }, ref) => {
912
950
  const { map, loaded } = useMap();
913
- const markerRef = React6.useRef(null);
914
- const elementRef = React6.useRef(null);
915
- const originalLngLatRef = React6.useRef();
916
- const clickHandlerRef = React6.useRef(null);
917
- const [mounted, setMounted] = React6.useState(false);
918
- const onClickRef = React6.useRef(onClick);
951
+ const markerRef = React25.useRef(null);
952
+ const elementRef = React25.useRef(null);
953
+ const originalLngLatRef = React25.useRef();
954
+ const clickHandlerRef = React25.useRef(null);
955
+ const [mounted, setMounted] = React25.useState(false);
956
+ const onClickRef = React25.useRef(onClick);
919
957
  onClickRef.current = onClick;
920
- const onDragRef = React6.useRef(onDrag);
958
+ const onDragRef = React25.useRef(onDrag);
921
959
  onDragRef.current = onDrag;
922
- const onDragEndRef = React6.useRef(onDragEnd);
960
+ const onDragEndRef = React25.useRef(onDragEnd);
923
961
  onDragEndRef.current = onDragEnd;
924
- React6.useEffect(() => {
962
+ React25.useEffect(() => {
925
963
  setMounted(true);
926
964
  return () => setMounted(false);
927
965
  }, []);
928
- React6.useEffect(() => {
966
+ React25.useEffect(() => {
929
967
  if (children && !elementRef.current) {
930
968
  elementRef.current = document.createElement("div");
931
969
  }
932
970
  }, [children]);
933
- React6.useEffect(() => {
971
+ React25.useEffect(() => {
934
972
  if (!map || !loaded || !mounted) return;
935
973
  if (markerRef.current) return;
936
974
  const markerOptions = {
@@ -1014,17 +1052,17 @@ var Marker = React6.forwardRef(
1014
1052
  }
1015
1053
  };
1016
1054
  }, [map, loaded, mounted]);
1017
- React6.useEffect(() => {
1055
+ React25.useEffect(() => {
1018
1056
  if (markerRef.current) {
1019
1057
  markerRef.current.setLngLat(coordinates);
1020
1058
  }
1021
1059
  }, [coordinates]);
1022
- React6.useEffect(() => {
1060
+ React25.useEffect(() => {
1023
1061
  if (markerRef.current) {
1024
1062
  markerRef.current.setDraggable(draggable);
1025
1063
  }
1026
1064
  }, [draggable]);
1027
- React6.useEffect(() => {
1065
+ React25.useEffect(() => {
1028
1066
  if (markerRef.current && rotation !== void 0) {
1029
1067
  markerRef.current.setRotation(rotation);
1030
1068
  }
@@ -1070,7 +1108,7 @@ function panToFitPopup(map, popup, padding) {
1070
1108
  });
1071
1109
  }
1072
1110
  }
1073
- var Popup = React6.forwardRef(
1111
+ var Popup = React25.forwardRef(
1074
1112
  ({
1075
1113
  coordinates,
1076
1114
  closeButton = true,
@@ -1088,25 +1126,25 @@ var Popup = React6.forwardRef(
1088
1126
  children
1089
1127
  }, ref) => {
1090
1128
  const { map, loaded } = useMap();
1091
- const popupRef = React6.useRef(null);
1092
- const onOpenRef = React6.useRef(onOpen);
1129
+ const popupRef = React25.useRef(null);
1130
+ const onOpenRef = React25.useRef(onOpen);
1093
1131
  onOpenRef.current = onOpen;
1094
- const onCloseRef = React6.useRef(onClose);
1132
+ const onCloseRef = React25.useRef(onClose);
1095
1133
  onCloseRef.current = onClose;
1096
- const coordinatesRef = React6.useRef(coordinates);
1134
+ const coordinatesRef = React25.useRef(coordinates);
1097
1135
  coordinatesRef.current = coordinates;
1098
- const containerRef = React6.useRef(null);
1136
+ const containerRef = React25.useRef(null);
1099
1137
  if (!containerRef.current && typeof document !== "undefined") {
1100
1138
  containerRef.current = document.createElement("div");
1101
1139
  containerRef.current.className = "maplibregl-popup-content-wrapper";
1102
1140
  }
1103
- const [contentReady, setContentReady] = React6.useState(false);
1104
- const contentCallbackRef = React6.useCallback((node) => {
1141
+ const [contentReady, setContentReady] = React25.useState(false);
1142
+ const contentCallbackRef = React25.useCallback((node) => {
1105
1143
  if (node && containerRef.current) {
1106
1144
  setContentReady(true);
1107
1145
  }
1108
1146
  }, []);
1109
- React6.useEffect(() => {
1147
+ React25.useEffect(() => {
1110
1148
  if (!map || !loaded || !containerRef.current) return;
1111
1149
  const popup = new maplibregl.Popup({
1112
1150
  closeButton,
@@ -1146,7 +1184,7 @@ var Popup = React6.forwardRef(
1146
1184
  maxWidth,
1147
1185
  focusAfterOpen
1148
1186
  ]);
1149
- React6.useEffect(() => {
1187
+ React25.useEffect(() => {
1150
1188
  if (!popupRef.current || !ref) return;
1151
1189
  if (typeof ref === "function") {
1152
1190
  ref(popupRef.current);
@@ -1154,12 +1192,12 @@ var Popup = React6.forwardRef(
1154
1192
  ref.current = popupRef.current;
1155
1193
  }
1156
1194
  }, [ref]);
1157
- React6.useEffect(() => {
1195
+ React25.useEffect(() => {
1158
1196
  if (popupRef.current) {
1159
1197
  popupRef.current.setLngLat(coordinates);
1160
1198
  }
1161
1199
  }, [coordinates]);
1162
- React6.useEffect(() => {
1200
+ React25.useEffect(() => {
1163
1201
  if (!map || !popupRef.current || !contentReady) return;
1164
1202
  let rafHandle;
1165
1203
  if (open) {
@@ -1188,7 +1226,7 @@ var Popup = React6.forwardRef(
1188
1226
  }
1189
1227
  );
1190
1228
  Popup.displayName = "Popup";
1191
- var PopupCard = React6.forwardRef(
1229
+ var PopupCard = React25.forwardRef(
1192
1230
  ({ className, children, ...props }, ref) => {
1193
1231
  return /* @__PURE__ */ jsx("div", { ref, className: cn("bg-popover text-popover-foreground", className), ...props, children });
1194
1232
  }
@@ -1208,7 +1246,7 @@ var badgeVariants = cva("text-xs px-1.5 py-0.5 rounded font-medium flex-shrink-0
1208
1246
  badgeVariant: "secondary"
1209
1247
  }
1210
1248
  });
1211
- var PopupHeader = React6.forwardRef(
1249
+ var PopupHeader = React25.forwardRef(
1212
1250
  ({ className, title, badge, badgeVariant, ...props }, ref) => {
1213
1251
  return /* @__PURE__ */ jsxs(
1214
1252
  "div",
@@ -1228,13 +1266,13 @@ var PopupHeader = React6.forwardRef(
1228
1266
  }
1229
1267
  );
1230
1268
  PopupHeader.displayName = "PopupHeader";
1231
- var PopupContent = React6.forwardRef(
1269
+ var PopupContent = React25.forwardRef(
1232
1270
  ({ className, children, ...props }, ref) => {
1233
1271
  return /* @__PURE__ */ jsx("div", { ref, className: cn("px-4 py-3 text-sm", className), ...props, children });
1234
1272
  }
1235
1273
  );
1236
1274
  PopupContent.displayName = "PopupContent";
1237
- var PopupFooter = React6.forwardRef(
1275
+ var PopupFooter = React25.forwardRef(
1238
1276
  ({ className, children, ...props }, ref) => {
1239
1277
  return /* @__PURE__ */ jsx(
1240
1278
  "div",
@@ -1268,12 +1306,15 @@ function useLayer({
1268
1306
  onHover,
1269
1307
  hoverThrottleMs = 0
1270
1308
  }) {
1271
- const { map, loaded } = useMap();
1272
- const [layerAdded, setLayerAdded] = React6.useState(false);
1273
- const hoveredFeatureId = React6.useRef(null);
1274
- const lastHoverCallTime = React6.useRef(0);
1275
- const lastMousePosition = React6.useRef(null);
1276
- React6.useEffect(() => {
1309
+ const { map, loaded, styleVersion } = useMap();
1310
+ const [layerAdded, setLayerAdded] = React25.useState(false);
1311
+ const hoveredFeatureId = React25.useRef(null);
1312
+ const lastHoverCallTime = React25.useRef(0);
1313
+ const lastMousePosition = React25.useRef(null);
1314
+ React25.useEffect(() => {
1315
+ hoveredFeatureId.current = null;
1316
+ }, [styleVersion]);
1317
+ React25.useEffect(() => {
1277
1318
  if (!map || !loaded) return;
1278
1319
  if (!map.getSource(source)) {
1279
1320
  let timeoutId = null;
@@ -1343,25 +1384,25 @@ function useLayer({
1343
1384
  setLayerAdded(false);
1344
1385
  }
1345
1386
  };
1346
- }, [map, loaded, id, source, sourceLayer, type, beforeId]);
1347
- React6.useEffect(() => {
1387
+ }, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion]);
1388
+ React25.useEffect(() => {
1348
1389
  if (!map || !layerAdded) return;
1349
1390
  if (!map.getLayer(id)) return;
1350
1391
  map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
1351
1392
  }, [map, id, visible, layerAdded]);
1352
- React6.useEffect(() => {
1393
+ React25.useEffect(() => {
1353
1394
  if (!map || !layerAdded) return;
1354
1395
  if (!map.getLayer(id)) return;
1355
1396
  Object.entries(paint).forEach(([key, value]) => {
1356
1397
  map.setPaintProperty(id, key, value);
1357
1398
  });
1358
1399
  }, [map, id, paint, layerAdded]);
1359
- React6.useEffect(() => {
1400
+ React25.useEffect(() => {
1360
1401
  if (!map || !layerAdded || !filter) return;
1361
1402
  if (!map.getLayer(id)) return;
1362
1403
  map.setFilter(id, filter);
1363
1404
  }, [map, id, filter, layerAdded]);
1364
- React6.useEffect(() => {
1405
+ React25.useEffect(() => {
1365
1406
  if (!map || !layerAdded) return;
1366
1407
  const createFeatureParams = (e) => {
1367
1408
  const feature = e.features?.[0];
@@ -1497,7 +1538,7 @@ var FillLayer = ({
1497
1538
  fillTranslate,
1498
1539
  fillAntialias
1499
1540
  }) => {
1500
- const paint = React6.useMemo(() => {
1541
+ const paint = React25.useMemo(() => {
1501
1542
  const p = {};
1502
1543
  if (fillColor !== void 0) p["fill-color"] = fillColor;
1503
1544
  if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
@@ -1518,7 +1559,7 @@ var FillLayer = ({
1518
1559
  fillAntialias,
1519
1560
  opacity
1520
1561
  ]);
1521
- const layout = React6.useMemo(() => ({}), []);
1562
+ const layout = React25.useMemo(() => ({}), []);
1522
1563
  useLayer({
1523
1564
  id,
1524
1565
  source,
@@ -1562,7 +1603,7 @@ var LineLayer = ({
1562
1603
  lineOffset,
1563
1604
  lineGradient
1564
1605
  }) => {
1565
- const paint = React6.useMemo(() => {
1606
+ const paint = React25.useMemo(() => {
1566
1607
  const p = {};
1567
1608
  if (lineColor !== void 0) p["line-color"] = lineColor;
1568
1609
  if (lineWidth !== void 0) p["line-width"] = lineWidth;
@@ -1587,7 +1628,7 @@ var LineLayer = ({
1587
1628
  lineGradient,
1588
1629
  opacity
1589
1630
  ]);
1590
- const layout = React6.useMemo(() => {
1631
+ const layout = React25.useMemo(() => {
1591
1632
  const l = {};
1592
1633
  if (lineCap !== void 0) l["line-cap"] = lineCap;
1593
1634
  if (lineJoin !== void 0) l["line-join"] = lineJoin;
@@ -1636,7 +1677,7 @@ var CircleLayer = ({
1636
1677
  circlePitchScale,
1637
1678
  circleTranslate
1638
1679
  }) => {
1639
- const paint = React6.useMemo(() => {
1680
+ const paint = React25.useMemo(() => {
1640
1681
  const p = {};
1641
1682
  if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
1642
1683
  if (circleColor !== void 0) p["circle-color"] = circleColor;
@@ -1665,7 +1706,7 @@ var CircleLayer = ({
1665
1706
  circleTranslate,
1666
1707
  opacity
1667
1708
  ]);
1668
- const layout = React6.useMemo(() => ({}), []);
1709
+ const layout = React25.useMemo(() => ({}), []);
1669
1710
  useLayer({
1670
1711
  id,
1671
1712
  source,
@@ -1725,7 +1766,7 @@ var SymbolLayer = ({
1725
1766
  symbolSpacing,
1726
1767
  symbolSortKey
1727
1768
  }) => {
1728
- const paint = React6.useMemo(() => {
1769
+ const paint = React25.useMemo(() => {
1729
1770
  const p = {};
1730
1771
  if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
1731
1772
  if (iconColor !== void 0) p["icon-color"] = iconColor;
@@ -1746,7 +1787,7 @@ var SymbolLayer = ({
1746
1787
  textHaloColor,
1747
1788
  textHaloWidth
1748
1789
  ]);
1749
- const layout = React6.useMemo(() => {
1790
+ const layout = React25.useMemo(() => {
1750
1791
  const l = {};
1751
1792
  if (iconImage !== void 0) l["icon-image"] = iconImage;
1752
1793
  if (iconSize !== void 0) l["icon-size"] = iconSize;
@@ -1827,7 +1868,7 @@ var FillExtrusionLayer = ({
1827
1868
  fillExtrusionTranslate,
1828
1869
  fillExtrusionVerticalGradient
1829
1870
  }) => {
1830
- const paint = React6.useMemo(() => {
1871
+ const paint = React25.useMemo(() => {
1831
1872
  const p = {};
1832
1873
  if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
1833
1874
  if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
@@ -1853,7 +1894,7 @@ var FillExtrusionLayer = ({
1853
1894
  fillExtrusionVerticalGradient,
1854
1895
  opacity
1855
1896
  ]);
1856
- const layout = React6.useMemo(() => ({}), []);
1897
+ const layout = React25.useMemo(() => ({}), []);
1857
1898
  useLayer({
1858
1899
  id,
1859
1900
  source,
@@ -1892,7 +1933,7 @@ var HeatmapLayer = ({
1892
1933
  heatmapRadius,
1893
1934
  heatmapOpacity
1894
1935
  }) => {
1895
- const paint = React6.useMemo(() => {
1936
+ const paint = React25.useMemo(() => {
1896
1937
  const p = {};
1897
1938
  if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
1898
1939
  if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
@@ -1904,7 +1945,7 @@ var HeatmapLayer = ({
1904
1945
  }
1905
1946
  return p;
1906
1947
  }, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
1907
- const layout = React6.useMemo(() => ({}), []);
1948
+ const layout = React25.useMemo(() => ({}), []);
1908
1949
  useLayer({
1909
1950
  id,
1910
1951
  source,
@@ -1939,11 +1980,11 @@ var Legend = ({
1939
1980
  onItemClick
1940
1981
  }) => {
1941
1982
  const { controlOffsets, registerControl, unregisterControl } = useMap();
1942
- const [isCollapsed, setIsCollapsed] = React6.useState(initialCollapsed);
1943
- const [customControlOffset, setCustomControlOffset] = React6.useState(0);
1944
- const legendRef = React6.useRef(null);
1945
- const legendIdRef = React6.useRef(`legend-${++legendIdCounter}`);
1946
- React6.useEffect(() => {
1983
+ const [isCollapsed, setIsCollapsed] = React25.useState(initialCollapsed);
1984
+ const [customControlOffset, setCustomControlOffset] = React25.useState(0);
1985
+ const legendRef = React25.useRef(null);
1986
+ const legendIdRef = React25.useRef(`legend-${++legendIdCounter}`);
1987
+ React25.useEffect(() => {
1947
1988
  if (!legendRef.current || !registerControl) return;
1948
1989
  const updatePosition = () => {
1949
1990
  if (!legendRef.current) return;
@@ -1959,7 +2000,7 @@ var Legend = ({
1959
2000
  unregisterControl?.(legendIdRef.current, position);
1960
2001
  };
1961
2002
  }, [position, registerControl, unregisterControl]);
1962
- const verticalOffsetStyle = React6.useMemo(() => {
2003
+ const verticalOffsetStyle = React25.useMemo(() => {
1963
2004
  return computeVerticalOffsetStyle(position, customControlOffset);
1964
2005
  }, [customControlOffset, position]);
1965
2006
  const handleItemClick = (item, index) => {
@@ -1972,13 +2013,13 @@ var Legend = ({
1972
2013
  setIsCollapsed(!isCollapsed);
1973
2014
  }
1974
2015
  };
1975
- const gradientStyle = React6.useMemo(() => {
2016
+ const gradientStyle = React25.useMemo(() => {
1976
2017
  if (type !== "gradient" || gradient.length === 0) return "";
1977
2018
  const stops = gradient.map((stop) => `${stop.color} ${stop.position * 100}%`).join(", ");
1978
2019
  return `linear-gradient(to right, ${stops})`;
1979
2020
  }, [type, gradient]);
1980
2021
  const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
1981
- const computedPositionClasses = React6.useMemo(() => {
2022
+ const computedPositionClasses = React25.useMemo(() => {
1982
2023
  return computePositionClasses(position, hasControlsAtPosition);
1983
2024
  }, [position, hasControlsAtPosition]);
1984
2025
  return /* @__PURE__ */ jsxs(
@@ -2077,15 +2118,15 @@ var LegendGroup = ({
2077
2118
  class: className
2078
2119
  }) => {
2079
2120
  const { controlOffsets, registerControl, unregisterControl } = useMap();
2080
- const containerRef = React6.useRef(null);
2081
- const groupIdRef = React6.useRef(`legend-group-${++legendGroupIdCounter}`);
2082
- const [customControlOffset, setCustomControlOffset] = React6.useState(0);
2121
+ const containerRef = React25.useRef(null);
2122
+ const groupIdRef = React25.useRef(`legend-group-${++legendGroupIdCounter}`);
2123
+ const [customControlOffset, setCustomControlOffset] = React25.useState(0);
2083
2124
  const getInitialExpanded = () => {
2084
2125
  if (controlledExpanded !== void 0) return controlledExpanded;
2085
2126
  if (defaultExpanded) return defaultExpanded;
2086
2127
  return legends[0]?.id || null;
2087
2128
  };
2088
- const [internalExpanded, setInternalExpanded] = React6.useState(getInitialExpanded);
2129
+ const [internalExpanded, setInternalExpanded] = React25.useState(getInitialExpanded);
2089
2130
  const expandedId = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
2090
2131
  const handleToggle = (id) => {
2091
2132
  const newExpanded = expandedId === id ? allowCollapseAll ? null : id : id;
@@ -2094,7 +2135,7 @@ var LegendGroup = ({
2094
2135
  }
2095
2136
  onExpandedChange?.(newExpanded);
2096
2137
  };
2097
- React6.useEffect(() => {
2138
+ React25.useEffect(() => {
2098
2139
  if (!containerRef.current || !registerControl) return;
2099
2140
  const timeoutId = setTimeout(() => {
2100
2141
  if (containerRef.current) {
@@ -2108,11 +2149,11 @@ var LegendGroup = ({
2108
2149
  unregisterControl?.(groupIdRef.current, position);
2109
2150
  };
2110
2151
  }, [position, expandedId, registerControl, unregisterControl]);
2111
- const verticalOffsetStyle = React6.useMemo(() => {
2152
+ const verticalOffsetStyle = React25.useMemo(() => {
2112
2153
  return computeVerticalOffsetStyle(position, customControlOffset);
2113
2154
  }, [customControlOffset, position]);
2114
2155
  const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
2115
- const computedPositionClasses = React6.useMemo(() => {
2156
+ const computedPositionClasses = React25.useMemo(() => {
2116
2157
  return computePositionClasses(position, hasControlsAtPosition);
2117
2158
  }, [position, hasControlsAtPosition]);
2118
2159
  const getGradientStyle = (legend) => {
@@ -2243,13 +2284,13 @@ var CoordinateDisplay = ({
2243
2284
  class: className
2244
2285
  }) => {
2245
2286
  const { map, loaded, controlOffsets, registerControl, unregisterControl } = useMap();
2246
- const [cursorLngLat, setCursorLngLat] = React6.useState(null);
2247
- const [currentZoom, setCurrentZoom] = React6.useState(0);
2248
- const [currentBearing, setCurrentBearing] = React6.useState(0);
2249
- const [customControlOffset, setCustomControlOffset] = React6.useState(0);
2250
- const controlRef = React6.useRef(null);
2251
- const controlIdRef = React6.useRef(`coord-display-${++coordDisplayIdCounter}`);
2252
- React6.useEffect(() => {
2287
+ const [cursorLngLat, setCursorLngLat] = React25.useState(null);
2288
+ const [currentZoom, setCurrentZoom] = React25.useState(0);
2289
+ const [currentBearing, setCurrentBearing] = React25.useState(0);
2290
+ const [customControlOffset, setCustomControlOffset] = React25.useState(0);
2291
+ const controlRef = React25.useRef(null);
2292
+ const controlIdRef = React25.useRef(`coord-display-${++coordDisplayIdCounter}`);
2293
+ React25.useEffect(() => {
2253
2294
  if (!controlRef.current || !registerControl) return;
2254
2295
  const updatePosition = () => {
2255
2296
  if (!controlRef.current) return;
@@ -2265,10 +2306,10 @@ var CoordinateDisplay = ({
2265
2306
  unregisterControl?.(controlIdRef.current, position);
2266
2307
  };
2267
2308
  }, [position, registerControl, unregisterControl]);
2268
- const verticalOffsetStyle = React6.useMemo(() => {
2309
+ const verticalOffsetStyle = React25.useMemo(() => {
2269
2310
  return computeVerticalOffsetStyle(position, customControlOffset);
2270
2311
  }, [customControlOffset, position]);
2271
- const formatCoord = React6.useCallback(
2312
+ const formatCoord = React25.useCallback(
2272
2313
  (lngLat) => {
2273
2314
  return formatCoordinates(lngLat, precision, format);
2274
2315
  },
@@ -2282,10 +2323,10 @@ var CoordinateDisplay = ({
2282
2323
  return `${normalized.toFixed(0)}\xB0`;
2283
2324
  };
2284
2325
  const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
2285
- const computedPositionClasses = React6.useMemo(() => {
2326
+ const computedPositionClasses = React25.useMemo(() => {
2286
2327
  return computePositionClasses(position, hasControlsAtPosition);
2287
2328
  }, [position, hasControlsAtPosition]);
2288
- React6.useEffect(() => {
2329
+ React25.useEffect(() => {
2289
2330
  if (!map || !loaded) return;
2290
2331
  setCurrentZoom(map.getZoom());
2291
2332
  setCurrentBearing(map.getBearing());
@@ -2338,6 +2379,766 @@ var CoordinateDisplay = ({
2338
2379
  );
2339
2380
  };
2340
2381
  CoordinateDisplay.displayName = "CoordinateDisplay";
2382
+ var switcherIdCounter = 0;
2383
+ var BasemapSwitcher = ({
2384
+ basemaps,
2385
+ extraBasemaps,
2386
+ apiKeys,
2387
+ defaultBasemapId,
2388
+ activeBasemapId,
2389
+ onBasemapChange,
2390
+ columns = 3,
2391
+ thumbnailSize = 64,
2392
+ position = "bottom-right",
2393
+ class: className
2394
+ }) => {
2395
+ const { controlOffsets, registerControl, unregisterControl, setMapStyle } = useMap();
2396
+ const [isOpen, setIsOpen] = React25.useState(false);
2397
+ const [internalActiveId, setInternalActiveId] = React25.useState(
2398
+ defaultBasemapId
2399
+ );
2400
+ const [customControlOffset, setCustomControlOffset] = React25.useState(0);
2401
+ const containerRef = React25.useRef(null);
2402
+ const panelRef = React25.useRef(null);
2403
+ const switcherIdRef = React25.useRef(`basemap-switcher-${++switcherIdCounter}`);
2404
+ const sourceBasemaps = basemaps ?? FREE_BASEMAPS;
2405
+ const availableBasemaps = React25.useMemo(() => {
2406
+ const available = getAvailableBasemaps(sourceBasemaps, apiKeys);
2407
+ if (extraBasemaps?.length) {
2408
+ return [...available, ...getAvailableBasemaps(extraBasemaps, apiKeys)];
2409
+ }
2410
+ return available;
2411
+ }, [sourceBasemaps, extraBasemaps, apiKeys]);
2412
+ const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
2413
+ React25.useEffect(() => {
2414
+ if (!containerRef.current || !registerControl) return;
2415
+ const updatePosition = () => {
2416
+ if (!containerRef.current) return;
2417
+ const height = containerRef.current.offsetHeight;
2418
+ const offset = registerControl(switcherIdRef.current, position, height);
2419
+ setCustomControlOffset(offset);
2420
+ };
2421
+ updatePosition();
2422
+ const observer = new ResizeObserver(updatePosition);
2423
+ observer.observe(containerRef.current);
2424
+ return () => {
2425
+ observer.disconnect();
2426
+ unregisterControl?.(switcherIdRef.current, position);
2427
+ };
2428
+ }, [position, registerControl, unregisterControl]);
2429
+ React25.useEffect(() => {
2430
+ if (!isOpen) return;
2431
+ const handleMouseDown = (e) => {
2432
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
2433
+ setIsOpen(false);
2434
+ }
2435
+ };
2436
+ document.addEventListener("mousedown", handleMouseDown);
2437
+ return () => document.removeEventListener("mousedown", handleMouseDown);
2438
+ }, [isOpen]);
2439
+ React25.useEffect(() => {
2440
+ if (!isOpen) return;
2441
+ const handleKeyDown = (e) => {
2442
+ if (e.key === "Escape") {
2443
+ setIsOpen(false);
2444
+ }
2445
+ };
2446
+ document.addEventListener("keydown", handleKeyDown);
2447
+ return () => document.removeEventListener("keydown", handleKeyDown);
2448
+ }, [isOpen]);
2449
+ const handleSelect = (basemap) => {
2450
+ const style = resolveBasemapStyle(basemap, apiKeys);
2451
+ if (!style) return;
2452
+ if (!activeBasemapId) {
2453
+ setInternalActiveId(basemap.id);
2454
+ }
2455
+ setMapStyle?.(style);
2456
+ onBasemapChange?.(basemap);
2457
+ setIsOpen(false);
2458
+ };
2459
+ const verticalOffsetStyle = React25.useMemo(() => {
2460
+ return computeVerticalOffsetStyle(position, customControlOffset);
2461
+ }, [customControlOffset, position]);
2462
+ const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
2463
+ const computedPositionClasses = React25.useMemo(() => {
2464
+ return computePositionClasses(position, hasControlsAtPosition);
2465
+ }, [position, hasControlsAtPosition]);
2466
+ const isTop = position.startsWith("top");
2467
+ return /* @__PURE__ */ jsxs(
2468
+ "div",
2469
+ {
2470
+ ref: containerRef,
2471
+ className: cn("absolute z-10", computedPositionClasses, className),
2472
+ style: verticalOffsetStyle,
2473
+ children: [
2474
+ isOpen && /* @__PURE__ */ jsx(
2475
+ "div",
2476
+ {
2477
+ ref: panelRef,
2478
+ className: cn(
2479
+ "absolute classic-basemap-panel-enter",
2480
+ "bg-card rounded-lg shadow-lg border border-black dark:border-gray-400",
2481
+ "p-2",
2482
+ isTop ? "top-full mt-1" : "bottom-full mb-1",
2483
+ position.includes("right") ? "right-0" : "left-0"
2484
+ ),
2485
+ style: {
2486
+ width: columns * (thumbnailSize + 12) + 16
2487
+ },
2488
+ children: /* @__PURE__ */ jsx(
2489
+ "div",
2490
+ {
2491
+ role: "listbox",
2492
+ "aria-label": "Select basemap",
2493
+ className: "grid gap-1.5",
2494
+ style: {
2495
+ gridTemplateColumns: `repeat(${columns}, 1fr)`
2496
+ },
2497
+ children: availableBasemaps.map((basemap) => {
2498
+ const isActive = basemap.id === currentActiveId;
2499
+ const thumbUrl = resolveBasemapThumbnail(basemap, apiKeys);
2500
+ return /* @__PURE__ */ jsxs(
2501
+ "button",
2502
+ {
2503
+ type: "button",
2504
+ role: "option",
2505
+ "aria-selected": isActive,
2506
+ className: cn(
2507
+ "flex flex-col items-center gap-1 p-1 rounded cursor-pointer",
2508
+ "hover:bg-muted transition-colors",
2509
+ isActive && "ring-2 ring-primary"
2510
+ ),
2511
+ onClick: () => handleSelect(basemap),
2512
+ title: basemap.name,
2513
+ children: [
2514
+ /* @__PURE__ */ jsx(
2515
+ "img",
2516
+ {
2517
+ src: thumbUrl,
2518
+ alt: basemap.name,
2519
+ loading: "lazy",
2520
+ className: "rounded object-cover",
2521
+ style: {
2522
+ width: thumbnailSize,
2523
+ height: thumbnailSize
2524
+ }
2525
+ }
2526
+ ),
2527
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-foreground truncate w-full text-center leading-tight", children: basemap.label ?? basemap.name })
2528
+ ]
2529
+ },
2530
+ basemap.id
2531
+ );
2532
+ })
2533
+ }
2534
+ )
2535
+ }
2536
+ ),
2537
+ /* @__PURE__ */ jsx(
2538
+ "button",
2539
+ {
2540
+ type: "button",
2541
+ className: cn(
2542
+ "w-[40px] h-[40px] flex items-center justify-center",
2543
+ "bg-card rounded shadow-lg border border-black dark:border-gray-400",
2544
+ "hover:bg-muted transition-colors cursor-pointer",
2545
+ "text-foreground"
2546
+ ),
2547
+ onClick: () => setIsOpen(!isOpen),
2548
+ "aria-label": "Switch basemap",
2549
+ "aria-expanded": isOpen,
2550
+ "aria-haspopup": "true",
2551
+ children: /* @__PURE__ */ jsxs(
2552
+ "svg",
2553
+ {
2554
+ width: "20",
2555
+ height: "20",
2556
+ viewBox: "0 0 24 24",
2557
+ fill: "none",
2558
+ stroke: "currentColor",
2559
+ strokeWidth: "2",
2560
+ strokeLinecap: "round",
2561
+ strokeLinejoin: "round",
2562
+ children: [
2563
+ /* @__PURE__ */ jsx("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }),
2564
+ /* @__PURE__ */ jsx("path", { d: "M2 17l10 5 10-5" }),
2565
+ /* @__PURE__ */ jsx("path", { d: "M2 12l10 5 10-5" })
2566
+ ]
2567
+ }
2568
+ )
2569
+ }
2570
+ )
2571
+ ]
2572
+ }
2573
+ );
2574
+ };
2575
+ BasemapSwitcher.displayName = "BasemapSwitcher";
2576
+ var managerIdCounter = 0;
2577
+ var LayerManager = ({
2578
+ layers,
2579
+ apiKeys,
2580
+ initialActiveLayers,
2581
+ position = "top-right",
2582
+ showSearch = false,
2583
+ showCategories = false,
2584
+ allowReorder = false,
2585
+ showOpacity = false,
2586
+ collapsible = true,
2587
+ onLayerChange,
2588
+ class: className
2589
+ }) => {
2590
+ const { controlOffsets, registerControl, unregisterControl } = useMap();
2591
+ const { isDark } = useMapTheme();
2592
+ const [isOpen, setIsOpen] = React25.useState(false);
2593
+ const [layerStates, setLayerStates] = React25.useState(
2594
+ () => createInitialLayerStates(layers, initialActiveLayers)
2595
+ );
2596
+ const [searchQuery, setSearchQuery] = React25.useState("");
2597
+ const [activeCategory, setActiveCategory] = React25.useState("all");
2598
+ const [customControlOffset, setCustomControlOffset] = React25.useState(0);
2599
+ const [expandedOpacity, setExpandedOpacity] = React25.useState(null);
2600
+ const [draggedId, setDraggedId] = React25.useState(null);
2601
+ const [dragOver, setDragOver] = React25.useState(null);
2602
+ const containerRef = React25.useRef(null);
2603
+ const managerIdRef = React25.useRef(`layer-manager-${++managerIdCounter}`);
2604
+ const lastLayerIdsRef = React25.useRef(new Set(layers.map((l) => l.id)));
2605
+ React25.useEffect(() => {
2606
+ const currentLayerIds = new Set(layers.map((l) => l.id));
2607
+ const hasNewLayers = layers.some((l) => !lastLayerIdsRef.current.has(l.id));
2608
+ const hasRemovedLayers = Array.from(lastLayerIdsRef.current).some(
2609
+ (id) => !currentLayerIds.has(id)
2610
+ );
2611
+ if (hasNewLayers || hasRemovedLayers) {
2612
+ setLayerStates((prev) => {
2613
+ const newStates = new Map(prev);
2614
+ for (const layer of layers) {
2615
+ if (!newStates.has(layer.id)) {
2616
+ newStates.set(layer.id, {
2617
+ id: layer.id,
2618
+ visible: initialActiveLayers?.includes(layer.id) ?? false,
2619
+ opacity: 1,
2620
+ loading: false,
2621
+ error: null,
2622
+ order: newStates.size
2623
+ });
2624
+ }
2625
+ }
2626
+ for (const id of lastLayerIdsRef.current) {
2627
+ if (!currentLayerIds.has(id)) {
2628
+ newStates.delete(id);
2629
+ }
2630
+ }
2631
+ return newStates;
2632
+ });
2633
+ lastLayerIdsRef.current = currentLayerIds;
2634
+ }
2635
+ }, [layers, initialActiveLayers]);
2636
+ const categories = React25.useMemo(() => getLayerCategories(layers), [layers]);
2637
+ const filteredLayers = React25.useMemo(() => {
2638
+ let result = layers;
2639
+ if (searchQuery) {
2640
+ result = searchLayers(result, searchQuery);
2641
+ }
2642
+ if (activeCategory !== "all") {
2643
+ result = result.filter((l) => l.category === activeCategory);
2644
+ }
2645
+ return [...result].sort((a, b) => {
2646
+ const orderA = layerStates.get(a.id)?.order ?? 0;
2647
+ const orderB = layerStates.get(b.id)?.order ?? 0;
2648
+ return orderA - orderB;
2649
+ });
2650
+ }, [layers, searchQuery, activeCategory, layerStates]);
2651
+ const layerGroups = React25.useMemo(
2652
+ () => showCategories ? groupLayersByCategory(filteredLayers) : null,
2653
+ [filteredLayers, showCategories]
2654
+ );
2655
+ React25.useEffect(() => {
2656
+ if (!containerRef.current || !registerControl) return;
2657
+ const updatePosition = () => {
2658
+ if (!containerRef.current) return;
2659
+ const height = containerRef.current.offsetHeight;
2660
+ const offset = registerControl(managerIdRef.current, position, height);
2661
+ setCustomControlOffset(offset);
2662
+ };
2663
+ updatePosition();
2664
+ const observer = new ResizeObserver(updatePosition);
2665
+ observer.observe(containerRef.current);
2666
+ return () => {
2667
+ observer.disconnect();
2668
+ unregisterControl?.(managerIdRef.current, position);
2669
+ };
2670
+ }, [position, registerControl, unregisterControl]);
2671
+ React25.useEffect(() => {
2672
+ if (!isOpen) return;
2673
+ const handleMouseDown = (e) => {
2674
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
2675
+ setIsOpen(false);
2676
+ }
2677
+ };
2678
+ document.addEventListener("mousedown", handleMouseDown);
2679
+ return () => document.removeEventListener("mousedown", handleMouseDown);
2680
+ }, [isOpen]);
2681
+ React25.useEffect(() => {
2682
+ if (!isOpen) return;
2683
+ const handleKeyDown = (e) => {
2684
+ if (e.key === "Escape") {
2685
+ setIsOpen(false);
2686
+ }
2687
+ };
2688
+ document.addEventListener("keydown", handleKeyDown);
2689
+ return () => document.removeEventListener("keydown", handleKeyDown);
2690
+ }, [isOpen]);
2691
+ const handleToggleLayer = React25.useCallback(
2692
+ (layerId) => {
2693
+ setLayerStates((prev) => {
2694
+ const newStates = toggleLayerVisibility(prev, layerId);
2695
+ const state = newStates.get(layerId);
2696
+ if (state && onLayerChange) {
2697
+ onLayerChange(layerId, state);
2698
+ }
2699
+ return newStates;
2700
+ });
2701
+ },
2702
+ [onLayerChange]
2703
+ );
2704
+ const handleOpacityChange = React25.useCallback(
2705
+ (layerId, opacity) => {
2706
+ setLayerStates((prev) => {
2707
+ const newStates = setLayerOpacity(prev, layerId, opacity);
2708
+ const state = newStates.get(layerId);
2709
+ if (state && onLayerChange) {
2710
+ onLayerChange(layerId, state);
2711
+ }
2712
+ return newStates;
2713
+ });
2714
+ },
2715
+ [onLayerChange]
2716
+ );
2717
+ const handleDragStart = React25.useCallback((e, layerId) => {
2718
+ setDraggedId(layerId);
2719
+ e.dataTransfer.effectAllowed = "move";
2720
+ e.dataTransfer.setData("text/plain", layerId);
2721
+ }, []);
2722
+ const handleDragOver = React25.useCallback(
2723
+ (e, layerId) => {
2724
+ e.preventDefault();
2725
+ e.dataTransfer.dropEffect = "move";
2726
+ if (layerId !== draggedId) {
2727
+ const rect = e.currentTarget.getBoundingClientRect();
2728
+ const relativeY = (e.clientY - rect.top) / rect.height;
2729
+ let position2;
2730
+ if (relativeY < 0.3) {
2731
+ position2 = "above";
2732
+ } else if (relativeY > 0.7) {
2733
+ position2 = "below";
2734
+ } else {
2735
+ position2 = dragOver?.id === layerId ? dragOver.position : "below";
2736
+ }
2737
+ setDragOver({ id: layerId, position: position2 });
2738
+ }
2739
+ },
2740
+ [draggedId, dragOver]
2741
+ );
2742
+ const handleDragLeave = React25.useCallback(() => {
2743
+ setDragOver(null);
2744
+ }, []);
2745
+ const handleDragEnd = React25.useCallback(() => {
2746
+ setDraggedId(null);
2747
+ setDragOver(null);
2748
+ }, []);
2749
+ const handleDrop = React25.useCallback(
2750
+ (e, targetLayerId) => {
2751
+ e.preventDefault();
2752
+ const sourceLayerId = e.dataTransfer.getData("text/plain");
2753
+ if (sourceLayerId && sourceLayerId !== targetLayerId) {
2754
+ const sortedStates = getLayerStatesArray(layerStates);
2755
+ const sourceIndex = sortedStates.findIndex((s) => s.id === sourceLayerId);
2756
+ let targetIndex = sortedStates.findIndex((s) => s.id === targetLayerId);
2757
+ if (targetIndex !== -1) {
2758
+ if (dragOver?.position === "below") {
2759
+ targetIndex += 1;
2760
+ }
2761
+ if (sourceIndex < targetIndex) {
2762
+ targetIndex -= 1;
2763
+ }
2764
+ setLayerStates((prev) => {
2765
+ const newStates = reorderLayers(prev, sourceLayerId, targetIndex);
2766
+ const state = newStates.get(sourceLayerId);
2767
+ if (state && onLayerChange) {
2768
+ onLayerChange(sourceLayerId, state);
2769
+ }
2770
+ return newStates;
2771
+ });
2772
+ }
2773
+ }
2774
+ setDraggedId(null);
2775
+ setDragOver(null);
2776
+ },
2777
+ [layerStates, onLayerChange, dragOver]
2778
+ );
2779
+ const verticalOffsetStyle = React25.useMemo(() => {
2780
+ return computeVerticalOffsetStyle(position, customControlOffset);
2781
+ }, [customControlOffset, position]);
2782
+ const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
2783
+ const computedPositionClasses = React25.useMemo(() => {
2784
+ return computePositionClasses(position, hasControlsAtPosition);
2785
+ }, [position, hasControlsAtPosition]);
2786
+ const isTop = position.startsWith("top");
2787
+ const renderLayer = (layer, state) => {
2788
+ if (!state.visible) return null;
2789
+ const theme = isDark ? "dark" : "light";
2790
+ const paint = getLayerStyleForTheme(layer, theme);
2791
+ const sourceUrl = resolveLayerSourceUrl(layer, apiKeys);
2792
+ const sourceId = `lm-source-${layer.id}`;
2793
+ const sourceData = layer.source.type === "geojson-inline" ? layer.source.data : layer.source.type === "geojson-url" && sourceUrl ? sourceUrl : void 0;
2794
+ if (!sourceData && layer.source.type !== "vector-tiles") {
2795
+ return null;
2796
+ }
2797
+ const layerProps = {
2798
+ id: `lm-layer-${layer.id}`,
2799
+ source: sourceId,
2800
+ sourceLayer: layer.source.sourceLayer,
2801
+ visible: state.visible,
2802
+ opacity: state.opacity,
2803
+ minZoom: layer.style.minZoom,
2804
+ maxZoom: layer.style.maxZoom
2805
+ };
2806
+ let layerComponent = null;
2807
+ const baseOpacity = {
2808
+ fill: paint["fill-opacity"] ?? 1,
2809
+ line: paint["line-opacity"] ?? 1,
2810
+ circle: paint["circle-opacity"] ?? 1,
2811
+ icon: paint["icon-opacity"] ?? 1
2812
+ };
2813
+ switch (layer.style.renderType) {
2814
+ case "fill":
2815
+ layerComponent = /* @__PURE__ */ jsx(
2816
+ FillLayer,
2817
+ {
2818
+ ...layerProps,
2819
+ fillColor: paint["fill-color"],
2820
+ fillOpacity: baseOpacity.fill * state.opacity,
2821
+ fillOutlineColor: paint["fill-outline-color"]
2822
+ }
2823
+ );
2824
+ break;
2825
+ case "line":
2826
+ layerComponent = /* @__PURE__ */ jsx(
2827
+ LineLayer,
2828
+ {
2829
+ ...layerProps,
2830
+ lineColor: paint["line-color"],
2831
+ lineWidth: paint["line-width"],
2832
+ lineOpacity: baseOpacity.line * state.opacity,
2833
+ lineDasharray: paint["line-dasharray"]
2834
+ }
2835
+ );
2836
+ break;
2837
+ case "circle":
2838
+ layerComponent = /* @__PURE__ */ jsx(
2839
+ CircleLayer,
2840
+ {
2841
+ ...layerProps,
2842
+ circleColor: paint["circle-color"],
2843
+ circleRadius: paint["circle-radius"],
2844
+ circleOpacity: baseOpacity.circle * state.opacity,
2845
+ circleStrokeWidth: paint["circle-stroke-width"],
2846
+ circleStrokeColor: paint["circle-stroke-color"]
2847
+ }
2848
+ );
2849
+ break;
2850
+ case "symbol":
2851
+ layerComponent = /* @__PURE__ */ jsx(
2852
+ SymbolLayer,
2853
+ {
2854
+ ...layerProps,
2855
+ iconImage: paint["icon-image"],
2856
+ iconSize: paint["icon-size"],
2857
+ iconOpacity: baseOpacity.icon * state.opacity,
2858
+ textField: paint["text-field"],
2859
+ textSize: paint["text-size"],
2860
+ textColor: paint["text-color"]
2861
+ }
2862
+ );
2863
+ break;
2864
+ }
2865
+ return /* @__PURE__ */ jsx(
2866
+ Source,
2867
+ {
2868
+ id: sourceId,
2869
+ type: layer.source.type === "vector-tiles" ? "vector" : "geojson",
2870
+ data: layer.source.type !== "vector-tiles" ? sourceData : void 0,
2871
+ url: layer.source.type === "vector-tiles" ? sourceUrl ?? void 0 : void 0,
2872
+ tiles: layer.source.type === "vector-tiles" ? [sourceUrl ?? ""] : void 0,
2873
+ attribution: layer.source.attribution,
2874
+ children: layerComponent
2875
+ },
2876
+ layer.id
2877
+ );
2878
+ };
2879
+ const renderLayerItem = (layer) => {
2880
+ const state = layerStates.get(layer.id);
2881
+ if (!state) return null;
2882
+ const isDragging = draggedId === layer.id;
2883
+ const isDragOver = dragOver?.id === layer.id;
2884
+ const dragOverPosition = isDragOver ? dragOver.position : void 0;
2885
+ return /* @__PURE__ */ jsxs(
2886
+ "div",
2887
+ {
2888
+ className: "classic-layer-item",
2889
+ draggable: allowReorder,
2890
+ onDragStart: allowReorder ? (e) => handleDragStart(e, layer.id) : void 0,
2891
+ onDragOver: allowReorder ? (e) => handleDragOver(e, layer.id) : void 0,
2892
+ onDragLeave: allowReorder ? handleDragLeave : void 0,
2893
+ onDragEnd: allowReorder ? handleDragEnd : void 0,
2894
+ onDrop: allowReorder ? (e) => handleDrop(e, layer.id) : void 0,
2895
+ "data-dragging": isDragging || void 0,
2896
+ "data-drag-over": dragOverPosition,
2897
+ children: [
2898
+ allowReorder && /* @__PURE__ */ jsx("span", { className: "classic-layer-drag-handle text-muted-foreground", children: /* @__PURE__ */ jsxs(
2899
+ "svg",
2900
+ {
2901
+ width: "12",
2902
+ height: "12",
2903
+ viewBox: "0 0 24 24",
2904
+ fill: "none",
2905
+ stroke: "currentColor",
2906
+ strokeWidth: "2",
2907
+ children: [
2908
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "6", r: "1", fill: "currentColor" }),
2909
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "6", r: "1", fill: "currentColor" }),
2910
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "12", r: "1", fill: "currentColor" }),
2911
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "12", r: "1", fill: "currentColor" }),
2912
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "18", r: "1", fill: "currentColor" }),
2913
+ /* @__PURE__ */ jsx("circle", { cx: "15", cy: "18", r: "1", fill: "currentColor" })
2914
+ ]
2915
+ }
2916
+ ) }),
2917
+ /* @__PURE__ */ jsx(
2918
+ Switch,
2919
+ {
2920
+ size: "sm",
2921
+ checked: state.visible,
2922
+ onCheckedChange: () => handleToggleLayer(layer.id),
2923
+ "aria-label": `Toggle ${layer.name}`
2924
+ }
2925
+ ),
2926
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
2927
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2928
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground truncate", children: layer.name }),
2929
+ state.loading && /* @__PURE__ */ jsx(
2930
+ "svg",
2931
+ {
2932
+ className: "classic-layer-loading w-3 h-3 text-muted-foreground",
2933
+ viewBox: "0 0 24 24",
2934
+ fill: "none",
2935
+ stroke: "currentColor",
2936
+ strokeWidth: "2",
2937
+ children: /* @__PURE__ */ jsx("path", { d: "M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83" })
2938
+ }
2939
+ )
2940
+ ] }),
2941
+ state.error && /* @__PURE__ */ jsx("span", { className: "classic-layer-error", children: state.error })
2942
+ ] }),
2943
+ showOpacity && state.visible && /* @__PURE__ */ jsx(
2944
+ "button",
2945
+ {
2946
+ type: "button",
2947
+ className: "text-muted-foreground hover:text-foreground p-1",
2948
+ onClick: () => setExpandedOpacity(expandedOpacity === layer.id ? null : layer.id),
2949
+ "aria-label": "Adjust opacity",
2950
+ children: /* @__PURE__ */ jsxs(
2951
+ "svg",
2952
+ {
2953
+ width: "14",
2954
+ height: "14",
2955
+ viewBox: "0 0 24 24",
2956
+ fill: "none",
2957
+ stroke: "currentColor",
2958
+ strokeWidth: "2",
2959
+ children: [
2960
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
2961
+ /* @__PURE__ */ jsx("path", { d: "M12 2a10 10 0 0 1 0 20", fill: "currentColor", opacity: "0.3" })
2962
+ ]
2963
+ }
2964
+ )
2965
+ }
2966
+ )
2967
+ ]
2968
+ },
2969
+ layer.id
2970
+ );
2971
+ };
2972
+ const renderOpacitySlider = (layerId) => {
2973
+ if (expandedOpacity !== layerId) return null;
2974
+ const state = layerStates.get(layerId);
2975
+ if (!state) return null;
2976
+ return /* @__PURE__ */ jsx("div", { className: "px-3 pb-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2977
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-12", children: "Opacity" }),
2978
+ /* @__PURE__ */ jsx(
2979
+ "input",
2980
+ {
2981
+ type: "range",
2982
+ min: "0",
2983
+ max: "100",
2984
+ value: state.opacity * 100,
2985
+ onChange: (e) => handleOpacityChange(layerId, Number(e.target.value) / 100),
2986
+ className: "classic-layer-opacity-slider flex-1"
2987
+ }
2988
+ ),
2989
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground w-8 text-right", children: [
2990
+ Math.round(state.opacity * 100),
2991
+ "%"
2992
+ ] })
2993
+ ] }) });
2994
+ };
2995
+ const visibleLayerStates = getLayerStatesArray(layerStates).filter((s) => s.visible);
2996
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2997
+ visibleLayerStates.map((state) => {
2998
+ const layer = layers.find((l) => l.id === state.id);
2999
+ return layer ? renderLayer(layer, state) : null;
3000
+ }),
3001
+ /* @__PURE__ */ jsxs(
3002
+ "div",
3003
+ {
3004
+ ref: containerRef,
3005
+ className: cn("absolute z-10", computedPositionClasses, className),
3006
+ style: verticalOffsetStyle,
3007
+ children: [
3008
+ isOpen && /* @__PURE__ */ jsxs(
3009
+ "div",
3010
+ {
3011
+ className: cn(
3012
+ "absolute classic-layer-panel-enter",
3013
+ "bg-card rounded-lg shadow-lg border border-black dark:border-gray-400",
3014
+ "w-64",
3015
+ isTop ? "top-full mt-1" : "bottom-full mb-1",
3016
+ position.includes("right") ? "right-0" : "left-0"
3017
+ ),
3018
+ children: [
3019
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-3 border-b border-border", children: [
3020
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: "Layers" }),
3021
+ collapsible && /* @__PURE__ */ jsx(
3022
+ "button",
3023
+ {
3024
+ type: "button",
3025
+ className: "text-muted-foreground hover:text-foreground",
3026
+ onClick: () => setIsOpen(false),
3027
+ "aria-label": "Close layer manager",
3028
+ children: /* @__PURE__ */ jsx(
3029
+ "svg",
3030
+ {
3031
+ width: "16",
3032
+ height: "16",
3033
+ viewBox: "0 0 24 24",
3034
+ fill: "none",
3035
+ stroke: "currentColor",
3036
+ strokeWidth: "2",
3037
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
3038
+ }
3039
+ )
3040
+ }
3041
+ )
3042
+ ] }),
3043
+ showSearch && /* @__PURE__ */ jsx("div", { className: "p-2 border-b border-border", children: /* @__PURE__ */ jsx(
3044
+ "input",
3045
+ {
3046
+ type: "text",
3047
+ placeholder: "Search layers...",
3048
+ value: searchQuery,
3049
+ onChange: (e) => setSearchQuery(e.target.value),
3050
+ className: "classic-layer-search"
3051
+ }
3052
+ ) }),
3053
+ showCategories && categories.length > 1 && /* @__PURE__ */ jsx("div", { className: "p-2 border-b border-border", children: /* @__PURE__ */ jsxs("div", { className: "classic-layer-tabs", children: [
3054
+ /* @__PURE__ */ jsx(
3055
+ "button",
3056
+ {
3057
+ type: "button",
3058
+ className: "classic-layer-tab",
3059
+ "data-active": activeCategory === "all",
3060
+ onClick: () => setActiveCategory("all"),
3061
+ children: "All"
3062
+ }
3063
+ ),
3064
+ categories.map((cat) => /* @__PURE__ */ jsx(
3065
+ "button",
3066
+ {
3067
+ type: "button",
3068
+ className: "classic-layer-tab",
3069
+ "data-active": activeCategory === cat,
3070
+ onClick: () => setActiveCategory(cat),
3071
+ children: CATEGORY_META[cat].label
3072
+ },
3073
+ cat
3074
+ ))
3075
+ ] }) }),
3076
+ /* @__PURE__ */ jsxs("div", { className: "max-h-64 overflow-y-auto", children: [
3077
+ showCategories && layerGroups && activeCategory === "all" ? (
3078
+ // Grouped by category
3079
+ categories.map((cat) => {
3080
+ const catLayers = layerGroups[cat];
3081
+ if (catLayers.length === 0) return null;
3082
+ return /* @__PURE__ */ jsxs("div", { children: [
3083
+ /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider", children: CATEGORY_META[cat].label }),
3084
+ catLayers.map((layer) => /* @__PURE__ */ jsxs(React25.Fragment, { children: [
3085
+ renderLayerItem(layer),
3086
+ renderOpacitySlider(layer.id)
3087
+ ] }, layer.id))
3088
+ ] }, cat);
3089
+ })
3090
+ ) : (
3091
+ // Flat list
3092
+ filteredLayers.map((layer) => /* @__PURE__ */ jsxs(React25.Fragment, { children: [
3093
+ renderLayerItem(layer),
3094
+ renderOpacitySlider(layer.id)
3095
+ ] }, layer.id))
3096
+ ),
3097
+ filteredLayers.length === 0 && /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No layers found" })
3098
+ ] })
3099
+ ]
3100
+ }
3101
+ ),
3102
+ /* @__PURE__ */ jsx(
3103
+ "button",
3104
+ {
3105
+ type: "button",
3106
+ className: cn(
3107
+ "w-[40px] h-[40px] flex items-center justify-center",
3108
+ "bg-card rounded shadow-lg border border-black dark:border-gray-400",
3109
+ "hover:bg-muted transition-colors cursor-pointer",
3110
+ "text-foreground"
3111
+ ),
3112
+ onClick: () => setIsOpen(!isOpen),
3113
+ "aria-label": "Toggle layer manager",
3114
+ "aria-expanded": isOpen,
3115
+ "aria-haspopup": "true",
3116
+ children: /* @__PURE__ */ jsxs(
3117
+ "svg",
3118
+ {
3119
+ width: "20",
3120
+ height: "20",
3121
+ viewBox: "0 0 24 24",
3122
+ fill: "none",
3123
+ stroke: "currentColor",
3124
+ strokeWidth: "2",
3125
+ strokeLinecap: "round",
3126
+ strokeLinejoin: "round",
3127
+ children: [
3128
+ /* @__PURE__ */ jsx("path", { d: "M12.89 1.45l8 4A2 2 0 0 1 22 7.24v9.53a2 2 0 0 1-1.11 1.79l-8 4a2 2 0 0 1-1.78 0l-8-4a2 2 0 0 1-1.11-1.8V7.24a2 2 0 0 1 1.11-1.79l8-4a2 2 0 0 1 1.78 0z" }),
3129
+ /* @__PURE__ */ jsx("polyline", { points: "2.32 6.16 12 11 21.68 6.16" }),
3130
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "22.76", x2: "12", y2: "11" })
3131
+ ]
3132
+ }
3133
+ )
3134
+ }
3135
+ )
3136
+ ]
3137
+ }
3138
+ )
3139
+ ] });
3140
+ };
3141
+ LayerManager.displayName = "LayerManager";
2341
3142
  var DeckOverlay = ({
2342
3143
  layers = [],
2343
3144
  onHover,
@@ -2348,9 +3149,9 @@ var DeckOverlay = ({
2348
3149
  deckProps = {}
2349
3150
  }) => {
2350
3151
  const { map, loaded } = useMap();
2351
- const overlayRef = React6.useRef(null);
2352
- const MapboxOverlayRef = React6.useRef(null);
2353
- React6.useEffect(() => {
3152
+ const overlayRef = React25.useRef(null);
3153
+ const MapboxOverlayRef = React25.useRef(null);
3154
+ React25.useEffect(() => {
2354
3155
  if (!map || !loaded) return;
2355
3156
  let cancelled = false;
2356
3157
  const initOverlay = async () => {
@@ -2390,12 +3191,12 @@ var DeckOverlay = ({
2390
3191
  }
2391
3192
  };
2392
3193
  }, [map, loaded, interleaved]);
2393
- React6.useEffect(() => {
3194
+ React25.useEffect(() => {
2394
3195
  if (overlayRef.current && "setProps" in overlayRef.current) {
2395
3196
  overlayRef.current.setProps({ layers });
2396
3197
  }
2397
3198
  }, [layers]);
2398
- React6.useEffect(() => {
3199
+ React25.useEffect(() => {
2399
3200
  if (overlayRef.current && "setProps" in overlayRef.current) {
2400
3201
  overlayRef.current.setProps({
2401
3202
  onHover,
@@ -2403,7 +3204,7 @@ var DeckOverlay = ({
2403
3204
  });
2404
3205
  }
2405
3206
  }, [onHover, onClick]);
2406
- React6.useEffect(() => {
3207
+ React25.useEffect(() => {
2407
3208
  if (overlayRef.current && effects && "setProps" in overlayRef.current) {
2408
3209
  overlayRef.current.setProps({ effects });
2409
3210
  }
@@ -2412,4 +3213,4 @@ var DeckOverlay = ({
2412
3213
  };
2413
3214
  DeckOverlay.displayName = "DeckOverlay";
2414
3215
 
2415
- export { CircleLayer, CoordinateDisplay, DeckOverlay, FillExtrusionLayer, FillLayer, HeatmapLayer, Legend, LegendGroup, LineLayer, Map, MapContainer, MapContext, MapEmpty, MapError, MapSkeleton, Marker, Popup, PopupCard, PopupContent, PopupFooter, PopupHeader, Source, SymbolLayer, cn, useLayer, useMap, useMapInstance, useMapTheme, useReducedMotion };
3216
+ export { BasemapSwitcher, CircleLayer, CoordinateDisplay, DeckOverlay, FillExtrusionLayer, FillLayer, HeatmapLayer, LayerManager, Legend, LegendGroup, LineLayer, Map2 as Map, MapContainer, MapContext, MapEmpty, MapError, MapSkeleton, Marker, Popup, PopupCard, PopupContent, PopupFooter, PopupHeader, Source, SymbolLayer, cn, useLayer, useMap, useMapInstance, useMapTheme, useReducedMotion };