@xyo-network/react-map 7.5.8 → 7.5.11

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.
Files changed (69) hide show
  1. package/dist/browser/Components/MapBox.d.ts.map +1 -1
  2. package/dist/browser/Components/MapBoxPoints.d.ts.map +1 -1
  3. package/dist/browser/MapBoxClasses/MapHeat.d.ts.map +1 -1
  4. package/dist/browser/MapBoxClasses/MapSettings.d.ts.map +1 -1
  5. package/dist/browser/hooks/useDynamicMapResize.d.ts.map +1 -1
  6. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.d.ts.map +1 -1
  7. package/dist/browser/index.mjs +481 -714
  8. package/dist/browser/index.mjs.map +1 -1
  9. package/package.json +159 -36
  10. package/src/Components/AnimatedHeatMap.tsx +0 -61
  11. package/src/Components/AnimatedHeatMapLoaded.tsx +0 -61
  12. package/src/Components/FeaturesToLayersMap.ts +0 -8
  13. package/src/Components/HeatMapSettings.ts +0 -11
  14. package/src/Components/LayerAnimator.tsx +0 -119
  15. package/src/Components/Legend.tsx +0 -36
  16. package/src/Components/Legends/ColorGradient.tsx +0 -35
  17. package/src/Components/Legends/index.ts +0 -1
  18. package/src/Components/MapBox.stories.tsx +0 -92
  19. package/src/Components/MapBox.tsx +0 -79
  20. package/src/Components/MapBoxHeat.tsx +0 -19
  21. package/src/Components/MapBoxPoints.tsx +0 -99
  22. package/src/Components/MapSettingsComponents/Setting.tsx +0 -36
  23. package/src/Components/MapSettingsComponents/SettingsBox.tsx +0 -34
  24. package/src/Components/MapSettingsComponents/index.ts +0 -2
  25. package/src/Components/index.ts +0 -11
  26. package/src/Contexts/HeatMapInitializer/Context.ts +0 -7
  27. package/src/Contexts/HeatMapInitializer/Provider.tsx +0 -93
  28. package/src/Contexts/HeatMapInitializer/State.ts +0 -8
  29. package/src/Contexts/HeatMapInitializer/index.ts +0 -3
  30. package/src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx +0 -13
  31. package/src/Contexts/MapBoxInstance/Context.ts +0 -7
  32. package/src/Contexts/MapBoxInstance/Provider.tsx +0 -26
  33. package/src/Contexts/MapBoxInstance/State.ts +0 -8
  34. package/src/Contexts/MapBoxInstance/index.ts +0 -3
  35. package/src/Contexts/MapBoxInstance/useMapBoxInstance.tsx +0 -13
  36. package/src/Contexts/MapSettings/Context.ts +0 -7
  37. package/src/Contexts/MapSettings/Provider.tsx +0 -43
  38. package/src/Contexts/MapSettings/State.ts +0 -7
  39. package/src/Contexts/MapSettings/index.ts +0 -3
  40. package/src/Contexts/MapSettings/useMapSettings.tsx +0 -11
  41. package/src/Contexts/index.ts +0 -3
  42. package/src/Layers/Builders/LocationHeatMapLayerBuilder.ts +0 -36
  43. package/src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts +0 -21
  44. package/src/Layers/Builders/LocationPointsMapLayerBuilder.ts +0 -17
  45. package/src/Layers/Builders/index.ts +0 -3
  46. package/src/Layers/CircleLayer.ts +0 -31
  47. package/src/Layers/Configs/HeatMapFillLayerConfig.ts +0 -13
  48. package/src/Layers/Configs/HeatMapLineLayerConfig.ts +0 -13
  49. package/src/Layers/Configs/HeatMapSymbolLayerConfig.ts +0 -18
  50. package/src/Layers/Configs/LocationPointLayerConfig.ts +0 -15
  51. package/src/Layers/Configs/index.ts +0 -4
  52. package/src/Layers/FillLayer.ts +0 -23
  53. package/src/Layers/LineLayer.ts +0 -24
  54. package/src/Layers/MapLayer.ts +0 -6
  55. package/src/Layers/SymbolLayer.ts +0 -23
  56. package/src/Layers/index.ts +0 -7
  57. package/src/MapBoxClasses/MapBase.ts +0 -45
  58. package/src/MapBoxClasses/MapHeat.ts +0 -184
  59. package/src/MapBoxClasses/MapPoints.ts +0 -39
  60. package/src/MapBoxClasses/MapSettings.ts +0 -132
  61. package/src/MapBoxClasses/index.ts +0 -4
  62. package/src/global.d.ts +0 -1
  63. package/src/hooks/index.ts +0 -3
  64. package/src/hooks/useDynamicMapResize.tsx +0 -43
  65. package/src/hooks/useDynamicPositioning.tsx +0 -68
  66. package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +0 -54
  67. package/src/index.ts +0 -5
  68. package/src/lib/MapBoxBaseProps.ts +0 -20
  69. package/src/lib/index.ts +0 -1
@@ -1,74 +1,47 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/Components/AnimatedHeatMap.tsx
5
2
  import { useTheme } from "@mui/material";
6
3
  import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
7
4
  import { darkenCss } from "@xylabs/react-theme";
8
- import React8, { useState as useState5 } from "react";
5
+ import { useState as useState3 } from "react";
9
6
 
10
7
  // src/Contexts/HeatMapInitializer/Provider.tsx
11
8
  import { forget as forget2 } from "@xylabs/sdk-js";
12
- import React3, { useEffect as useEffect5, useMemo as useMemo5 } from "react";
9
+ import { useEffect as useEffect4, useMemo as useMemo5 } from "react";
13
10
 
14
11
  // src/hooks/useDynamicMapResize.tsx
15
- import { useEffect, useMemo } from "react";
16
- var useDynamicMapResize = /* @__PURE__ */ __name((mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
17
- const resizer = useMemo(() => new ResizeObserver(() => {
18
- const width = mapContainerRef.current?.getBoundingClientRect().width;
19
- if (width && mapCanvasRef.current) {
20
- mapCanvasRef.current.style.width = `${width}px`;
21
- setTimeout(() => mapInstance?.resize());
22
- }
23
- }), [
24
- mapCanvasRef,
25
- mapContainerRef,
26
- mapInstance
27
- ]);
28
- const dependenciesReady = useMemo(() => {
29
- return !!(active && mapInstance && mapContainerRef?.current && mapCanvasRef.current);
30
- }, [
31
- active,
32
- mapCanvasRef,
33
- mapContainerRef,
34
- mapInstance
35
- ]);
12
+ import { useEffect } from "react";
13
+ var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
36
14
  useEffect(() => {
37
- if (dependenciesReady) {
38
- if (mapContainerRef.current) {
39
- resizer.observe(mapContainerRef.current);
15
+ if (active && mapInstance) {
16
+ const container = mapContainerRef.current;
17
+ if (container) {
18
+ let timerId;
19
+ const resizer = new ResizeObserver(() => {
20
+ const width = container.getBoundingClientRect().width;
21
+ const canvas = mapCanvasRef.current;
22
+ if (width && canvas) {
23
+ canvas.style.width = `${width}px`;
24
+ timerId = setTimeout(() => mapInstance.resize());
25
+ }
26
+ });
27
+ resizer.observe(container);
28
+ return () => {
29
+ clearTimeout(timerId);
30
+ resizer.disconnect();
31
+ };
40
32
  }
41
- return () => {
42
- resizer.disconnect();
43
- };
44
33
  }
45
- }, [
46
- active,
47
- dependenciesReady,
48
- mapCanvasRef,
49
- mapContainerRef,
50
- mapInstance,
51
- resizer
52
- ]);
53
- }, "useDynamicMapResize");
34
+ }, [active, mapCanvasRef, mapContainerRef, mapInstance]);
35
+ };
54
36
 
55
37
  // src/hooks/useDynamicPositioning.tsx
56
38
  import { useWindowSize } from "@xylabs/react-shared";
57
- import { useMemo as useMemo2 } from "react";
39
+ import { useMemo } from "react";
58
40
  var defaultZoom = 1.6;
59
- var defaultAspectRatioRange = [
60
- 0.5,
61
- 2
62
- ];
63
- var latRange = [
64
- 0.9121644205263664,
65
- 1.71785031559439
66
- ];
67
- var lngRange = [
68
- -81.4742014851959,
69
- 12.788958675506933
70
- ];
71
- var linearInterpolate = /* @__PURE__ */ __name((aspectRatio, degreeRange, aspectRatioRange) => {
41
+ var defaultAspectRatioRange = [0.5, 2];
42
+ var latRange = [0.9121644205263664, 1.71785031559439];
43
+ var lngRange = [-81.4742014851959, 12.788958675506933];
44
+ var linearInterpolate = (aspectRatio, degreeRange, aspectRatioRange) => {
72
45
  const [degreeMin, degreeMax] = degreeRange;
73
46
  const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange;
74
47
  const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin;
@@ -76,84 +49,78 @@ var linearInterpolate = /* @__PURE__ */ __name((aspectRatio, degreeRange, aspect
76
49
  const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan;
77
50
  const scaledDegree = percent * degreeRangeSpan + degreeMin;
78
51
  return scaledDegree;
79
- }, "linearInterpolate");
80
- var useDynamicPositioning = /* @__PURE__ */ __name(() => {
52
+ };
53
+ var useDynamicPositioning = () => {
81
54
  const { width, height } = useWindowSize();
82
- const options = useMemo2(() => {
55
+ const options = useMemo(() => {
83
56
  if (width && height) {
84
57
  const aspectRatio = width / height;
85
58
  return {
86
- center: [
87
- linearInterpolate(aspectRatio, lngRange),
88
- linearInterpolate(aspectRatio, latRange)
89
- ],
59
+ center: [linearInterpolate(aspectRatio, lngRange), linearInterpolate(aspectRatio, latRange)],
90
60
  zoom: defaultZoom
91
61
  };
92
62
  }
93
- }, [
94
- height,
95
- width
96
- ]);
97
- return {
98
- options
99
- };
100
- }, "useDynamicPositioning");
63
+ }, [height, width]);
64
+ return { options };
65
+ };
101
66
 
102
67
  // src/hooks/useQuadKeyPayloadsToFeatures.tsx
103
68
  import { GeoJson } from "@xylabs/geo";
104
69
  import { exists } from "@xylabs/sdk-js";
105
- import { useEffect as useEffect2, useState } from "react";
106
- var quadKeyToFeature = /* @__PURE__ */ __name(({ density, quadkey }) => {
70
+ import { useMemo as useMemo2 } from "react";
71
+ var quadKeyToFeature = ({ density, quadkey }) => {
107
72
  const polygonFeature = new GeoJson(quadkey).polygonFeature();
108
73
  polygonFeature.properties = {
109
74
  count: density,
110
75
  density
111
76
  };
112
77
  return polygonFeature;
113
- }, "quadKeyToFeature");
114
- var setDensity = /* @__PURE__ */ __name((feature) => {
78
+ };
79
+ var setDensity = (feature) => {
115
80
  if (feature.properties) {
116
81
  feature.properties.value = feature.properties.density / 5;
117
82
  }
118
83
  return feature;
119
- }, "setDensity");
120
- var useQuadKeyPayloadsToFeatures = /* @__PURE__ */ __name((payloads) => {
121
- const [multipleFeatureSets, setMultipleFeatureSets] = useState([
122
- []
123
- ]);
124
- const [features, setFeatures] = useState([]);
125
- const [error, setError] = useState();
126
- useEffect2(() => {
84
+ };
85
+ var useQuadKeyPayloadsToFeatures = (payloads) => {
86
+ const {
87
+ multipleFeatureSets,
88
+ features,
89
+ error
90
+ } = useMemo2(() => {
91
+ let multipleFeatureSets2 = [[]];
92
+ let features2 = [];
93
+ let error2;
127
94
  if (Array.isArray(payloads)) {
128
95
  if (payloads?.filter(exists).length > 0) {
129
96
  const mappedFeatures = payloads?.map((payload) => payload?.result.map(quadKeyToFeature));
130
- setMultipleFeatureSets(mappedFeatures.map((features2) => features2?.map(setDensity) ?? []));
97
+ multipleFeatureSets2 = mappedFeatures.map((f) => f?.map(setDensity) ?? []);
131
98
  } else {
132
- setError(new Error("Cannot find payloads for provided hashes"));
99
+ error2 = new Error("Cannot find payloads for provided hashes");
133
100
  }
134
101
  }
135
102
  if (payloads && payloads.result) {
136
103
  const singlePayload = payloads;
137
104
  const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
138
- setFeatures(mappedFeatures.map(setDensity));
105
+ features2 = mappedFeatures.map(setDensity);
139
106
  }
140
- }, [
141
- payloads
142
- ]);
107
+ return {
108
+ multipleFeatureSets: multipleFeatureSets2,
109
+ features: features2,
110
+ error: error2
111
+ };
112
+ }, [payloads]);
143
113
  return {
144
114
  error,
145
115
  features,
146
116
  multipleFeatureSets
147
117
  };
148
- }, "useQuadKeyPayloadsToFeatures");
118
+ };
149
119
 
150
120
  // src/MapBoxClasses/MapBase.ts
151
121
  import { GeoJson as GeoJson2 } from "@xylabs/geo";
152
122
  import { assertEx } from "@xylabs/sdk-js";
153
123
  var MapBase = class {
154
- static {
155
- __name(this, "MapBase");
156
- }
157
124
  _config;
158
125
  constructor(config) {
159
126
  this._config = {
@@ -166,10 +133,10 @@ var MapBase = class {
166
133
  return !!this._config.map;
167
134
  }
168
135
  initializeMapSource(layer) {
169
- const getSource = /* @__PURE__ */ __name(() => {
136
+ const getSource = () => {
170
137
  const featuresCollection = GeoJson2.featureCollection(this._config.features);
171
138
  return GeoJson2.featuresSource(featuresCollection);
172
- }, "getSource");
139
+ };
173
140
  const existingSource = this._config.map.getSource(layer.source);
174
141
  const source = getSource();
175
142
  if (existingSource) {
@@ -184,13 +151,13 @@ var MapBase = class {
184
151
 
185
152
  // src/MapBoxClasses/MapHeat.ts
186
153
  import { GeoJson as GeoJson3 } from "@xylabs/geo";
187
- import { assertEx as assertEx2, delay, forget } from "@xylabs/sdk-js";
154
+ import {
155
+ assertEx as assertEx2,
156
+ delay,
157
+ forget
158
+ } from "@xylabs/sdk-js";
188
159
  import { LngLatBounds } from "mapbox-gl";
189
160
  var MapHeat = class extends MapBase {
190
- static {
191
- __name(this, "MapHeat");
192
- }
193
- // eslint-disable-next-line sonarjs/public-static-readonly
194
161
  static animationStarted = false;
195
162
  config;
196
163
  constructor(config) {
@@ -238,7 +205,7 @@ var MapHeat = class extends MapBase {
238
205
  const stepLength = frameLength / steps;
239
206
  const lowUsageColor = startColor ?? "#FFB3B3";
240
207
  const highUsageColor = endColor ?? "#FF0000";
241
- const dynamicFillColor = /* @__PURE__ */ __name((factor2, initialPad2, i) => {
208
+ const dynamicFillColor = (factor2, initialPad2, i) => {
242
209
  const sinFade = Math.sin(i / steps * Math.PI / 2);
243
210
  const cosFade = Math.cos(i / steps * Math.PI / 2);
244
211
  const divisor = factor2 + factor2 * sinFade;
@@ -246,54 +213,27 @@ var MapHeat = class extends MapBase {
246
213
  return [
247
214
  "let",
248
215
  "density",
249
- [
250
- "+",
251
- [
252
- "/",
253
- [
254
- "number",
255
- [
256
- "get",
257
- "value"
258
- ]
259
- ],
260
- divisor
261
- ],
262
- offset
263
- ],
264
- [
265
- "interpolate",
266
- [
267
- "linear"
268
- ],
269
- [
270
- "var",
271
- "density"
272
- ],
273
- 0,
274
- lowUsageColor,
275
- 0.5,
276
- highUsageColor
277
- ]
216
+ ["+", ["/", ["number", ["get", "value"]], divisor], offset],
217
+ ["interpolate", ["linear"], ["var", "density"], 0, lowUsageColor, 0.5, highUsageColor]
278
218
  ];
279
- }, "dynamicFillColor");
219
+ };
280
220
  const fadedIn = layers.map((_) => false);
281
- const fadeIn = /* @__PURE__ */ __name(async (id, index) => {
221
+ const fadeIn = async (id, index) => {
282
222
  for (let i = steps; i >= 1; i--) {
283
223
  map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
284
224
  await delay(stepLength);
285
225
  }
286
226
  fadedIn[index] = true;
287
- }, "fadeIn");
288
- const fadeOut = /* @__PURE__ */ __name(async (id, index) => {
227
+ };
228
+ const fadeOut = async (id, index) => {
289
229
  for (let i = 1; i <= steps; i++) {
290
230
  map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
291
231
  await delay(stepLength);
292
232
  }
293
233
  fadedIn[index] = false;
294
- }, "fadeOut");
234
+ };
295
235
  let started = false;
296
- const startAnimation = /* @__PURE__ */ __name(async () => {
236
+ const startAnimation = async () => {
297
237
  assertEx2(!started, () => "Animation Already Started");
298
238
  started = true;
299
239
  while (this.animationStarted) {
@@ -315,7 +255,7 @@ var MapHeat = class extends MapBase {
315
255
  layerTick++;
316
256
  sourceTick++;
317
257
  }
318
- }, "startAnimation");
258
+ };
319
259
  await startAnimation();
320
260
  }
321
261
  static updateLayer(map, layer, source) {
@@ -329,10 +269,10 @@ var MapHeat = class extends MapBase {
329
269
  }
330
270
  // Build layers each with the same features
331
271
  initializeHeatMapSource(layers) {
332
- const getSource = /* @__PURE__ */ __name((_) => {
272
+ const getSource = (_) => {
333
273
  const featuresCollection = GeoJson3.featureCollection(this.config.features);
334
274
  return GeoJson3.featuresSource(featuresCollection);
335
- }, "getSource");
275
+ };
336
276
  for (const [index, layer] of layers.entries()) {
337
277
  const existingSource = this.config.map.getSource(layer.source);
338
278
  const source = getSource(index);
@@ -350,9 +290,6 @@ var MapHeat = class extends MapBase {
350
290
  // src/MapBoxClasses/MapPoints.ts
351
291
  import { LngLatBounds as LngLatBounds2 } from "mapbox-gl";
352
292
  var MapPoints = class extends MapBase {
353
- static {
354
- __name(this, "MapPoints");
355
- }
356
293
  config;
357
294
  constructor(config) {
358
295
  super(config);
@@ -377,24 +314,17 @@ var MapPoints = class extends MapBase {
377
314
  // src/MapBoxClasses/MapSettings.ts
378
315
  import { GeolocateControl, NavigationControl } from "mapbox-gl";
379
316
  var MapSettings = class _MapSettings {
380
- static {
381
- __name(this, "MapSettings");
382
- }
383
- // eslint-disable-next-line sonarjs/public-static-readonly
384
317
  static geoLocateControl;
385
- // eslint-disable-next-line sonarjs/public-static-readonly
386
318
  static mapListeners = {
387
- logData: /* @__PURE__ */ __name((ev, map) => {
319
+ logData: (ev, map) => {
388
320
  const target = map || ev?.target;
389
321
  if (target) {
390
322
  console.log("zoom", target.getZoom());
391
323
  console.log("center", target.getCenter());
392
324
  }
393
- }, "logData")
325
+ }
394
326
  };
395
- // eslint-disable-next-line sonarjs/public-static-readonly
396
327
  static navControl;
397
- // eslint-disable-next-line sonarjs/public-static-readonly
398
328
  static requestLocation;
399
329
  static toggleControls(value, map, zoom, requestLocation) {
400
330
  if (value) {
@@ -416,11 +346,7 @@ var MapSettings = class _MapSettings {
416
346
  return this;
417
347
  }
418
348
  static toggleDebugLogging(value, map) {
419
- const debugEvents = [
420
- "resize",
421
- "zoomend",
422
- "dragend"
423
- ];
349
+ const debugEvents = ["resize", "zoomend", "dragend"];
424
350
  if (value) {
425
351
  this.mapListeners.logData(void 0, map);
426
352
  for (const event of debugEvents) map.on(event, this.mapListeners.logData);
@@ -437,24 +363,29 @@ var MapSettings = class _MapSettings {
437
363
  return this;
438
364
  }
439
365
  static updateSettings(config) {
440
- const { settings, map, zoom, requestLocation, debugLayerName = "" } = config;
441
- const { scrollToZoom: scrollToZoom2, enableControls, debugLayer: debugLayer2, debugLogging } = settings;
366
+ const {
367
+ settings,
368
+ map,
369
+ zoom,
370
+ requestLocation,
371
+ debugLayerName = ""
372
+ } = config;
373
+ const {
374
+ scrollToZoom: scrollToZoom2,
375
+ enableControls,
376
+ debugLayer: debugLayer2,
377
+ debugLogging
378
+ } = settings;
442
379
  _MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation).toggleScrollToZoom(scrollToZoom2?.value, map).toggleDebugLayer(debugLayer2?.value, map, debugLayerName).toggleDebugLogging(debugLogging.value, map);
443
380
  }
444
381
  // Needs to be static so we ensure controls are only instantiated once
445
382
  static addControls(map, zoom, requestLocation) {
446
383
  const geolocateControl = new GeolocateControl({
447
- fitBoundsOptions: {
448
- zoom: zoom || 2
449
- },
450
- positionOptions: {
451
- enableHighAccuracy: true
452
- },
384
+ fitBoundsOptions: { zoom: zoom || 2 },
385
+ positionOptions: { enableHighAccuracy: true },
453
386
  trackUserLocation: true
454
387
  });
455
- const navControl = new NavigationControl({
456
- showCompass: false
457
- });
388
+ const navControl = new NavigationControl({ showCompass: false });
458
389
  this.geoLocateControl = this.geoLocateControl || geolocateControl;
459
390
  this.navControl = this.navControl || navControl;
460
391
  if (!map.hasControl(this.geoLocateControl) && requestLocation) {
@@ -477,69 +408,72 @@ var MapSettings = class _MapSettings {
477
408
  };
478
409
 
479
410
  // src/Contexts/MapBoxInstance/Provider.tsx
480
- import React, { useEffect as useEffect3, useMemo as useMemo3, useState as useState2 } from "react";
411
+ import {
412
+ useEffect as useEffect2,
413
+ useMemo as useMemo3,
414
+ useState
415
+ } from "react";
481
416
 
482
417
  // src/Contexts/MapBoxInstance/Context.ts
483
418
  import { createContext } from "react";
484
419
  var MapBoxInstanceContext = createContext({});
485
420
 
486
421
  // src/Contexts/MapBoxInstance/Provider.tsx
487
- var MapBoxInstanceProvider = /* @__PURE__ */ __name(({ children }) => {
488
- const [map, setMapBoxInstance] = useState2();
489
- const [mapInitialized, setMapInitialized] = useState2(false);
422
+ import { jsx } from "react/jsx-runtime";
423
+ var MapBoxInstanceProvider = ({ children }) => {
424
+ const [map, setMap] = useState();
425
+ const [mapInitialized, setMapInitialized] = useState(false);
490
426
  const value = useMemo3(() => ({
491
427
  map,
492
428
  mapInitialized,
493
- setMapBoxInstance
494
- }), [
495
- map,
496
- mapInitialized,
497
- setMapBoxInstance
498
- ]);
499
- useEffect3(() => {
429
+ setMapBoxInstance: setMap
430
+ }), [map, mapInitialized]);
431
+ useEffect2(() => {
500
432
  if (!mapInitialized && map) {
501
433
  map?.on("load", () => {
502
434
  setMapInitialized(true);
503
435
  });
504
436
  }
505
- }, [
506
- map,
507
- mapInitialized,
508
- setMapInitialized
509
- ]);
510
- return /* @__PURE__ */ React.createElement(MapBoxInstanceContext, {
511
- value
512
- }, children);
513
- }, "MapBoxInstanceProvider");
437
+ }, [map, mapInitialized, setMapInitialized]);
438
+ return /* @__PURE__ */ jsx(MapBoxInstanceContext, { value, children });
439
+ };
514
440
 
515
441
  // src/Contexts/MapBoxInstance/useMapBoxInstance.tsx
516
442
  import { assertEx as assertEx3 } from "@xylabs/sdk-js";
517
443
  import { use } from "react";
518
- var useMapBoxInstance = /* @__PURE__ */ __name(() => {
444
+ var useMapBoxInstance = () => {
519
445
  const context = use(MapBoxInstanceContext);
520
446
  assertEx3("map" in context, () => "useMapBoxInstance must be used within a MapBoxInstanceContext");
521
447
  return context;
522
- }, "useMapBoxInstance");
448
+ };
523
449
 
524
450
  // src/Contexts/MapSettings/Provider.tsx
525
- import React2, { useEffect as useEffect4, useMemo as useMemo4, useState as useState3 } from "react";
451
+ import {
452
+ useEffect as useEffect3,
453
+ useMemo as useMemo4,
454
+ useState as useState2
455
+ } from "react";
526
456
 
527
457
  // src/Contexts/MapSettings/Context.ts
528
458
  import { createContext as createContext2 } from "react";
529
459
  var MapSettingsContext = createContext2({});
530
460
 
531
461
  // src/Contexts/MapSettings/Provider.tsx
532
- var MapSettingsProvider = /* @__PURE__ */ __name(({ children, debugLayerName, defaultMapSettings, requestLocation, zoom = 1 }) => {
533
- const [mapSettings, setMapSettings] = useState3(defaultMapSettings || {});
462
+ import { jsx as jsx2 } from "react/jsx-runtime";
463
+ var MapSettingsProvider = ({
464
+ children,
465
+ debugLayerName,
466
+ defaultMapSettings,
467
+ requestLocation,
468
+ zoom = 1
469
+ }) => {
470
+ const [mapSettings, setMapSettings] = useState2(defaultMapSettings || {});
534
471
  const { map, mapInitialized } = useMapBoxInstance();
535
472
  const value = useMemo4(() => ({
536
473
  mapSettings,
537
474
  setMapSettings
538
- }), [
539
- mapSettings,
540
- setMapSettings
541
- ]);
542
- useEffect4(() => {
475
+ }), [mapSettings, setMapSettings]);
476
+ useEffect3(() => {
543
477
  if (mapSettings && map && mapInitialized) {
544
478
  MapSettings.updateSettings({
545
479
  debugLayerName,
@@ -549,32 +483,33 @@ var MapSettingsProvider = /* @__PURE__ */ __name(({ children, debugLayerName, de
549
483
  zoom
550
484
  });
551
485
  }
552
- }, [
553
- debugLayerName,
554
- map,
555
- mapInitialized,
556
- mapSettings,
557
- requestLocation,
558
- zoom
559
- ]);
560
- return /* @__PURE__ */ React2.createElement(MapSettingsContext, {
561
- value
562
- }, children);
563
- }, "MapSettingsProvider");
486
+ }, [debugLayerName, map, mapInitialized, mapSettings, requestLocation, zoom]);
487
+ return /* @__PURE__ */ jsx2(MapSettingsContext, { value, children });
488
+ };
564
489
 
565
490
  // src/Contexts/MapSettings/useMapSettings.tsx
566
491
  import { use as use2 } from "react";
567
- var useMapSettings = /* @__PURE__ */ __name(() => {
492
+ var useMapSettings = () => {
568
493
  const context = use2(MapSettingsContext);
569
494
  return context;
570
- }, "useMapSettings");
495
+ };
571
496
 
572
497
  // src/Contexts/HeatMapInitializer/Context.ts
573
498
  import { createContext as createContext3 } from "react";
574
499
  var HeatMapInitializerContext = createContext3({});
575
500
 
576
501
  // src/Contexts/HeatMapInitializer/Provider.tsx
577
- var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets, featureSetsLayers, features, fitToPadding, heatMapColorProps, layers, zoom }) => {
502
+ import { jsx as jsx3 } from "react/jsx-runtime";
503
+ var HeatMapInitializerProvider = ({
504
+ children,
505
+ featureSets,
506
+ featureSetsLayers,
507
+ features,
508
+ fitToPadding,
509
+ heatMapColorProps,
510
+ layers,
511
+ zoom
512
+ }) => {
578
513
  const { options } = useDynamicPositioning();
579
514
  const { mapSettings } = useMapSettings();
580
515
  const { map, mapInitialized } = useMapBoxInstance();
@@ -584,19 +519,12 @@ var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets
584
519
  map,
585
520
  zoom
586
521
  }) : void 0;
587
- }, [
588
- map,
589
- features,
590
- zoom
591
- ]);
522
+ }, [map, features, zoom]);
592
523
  const value = useMemo5(() => ({
593
524
  MapHeat: mapHeat,
594
525
  heatMapColorProps
595
- }), [
596
- mapHeat,
597
- heatMapColorProps
598
- ]);
599
- useEffect5(() => {
526
+ }), [mapHeat, heatMapColorProps]);
527
+ useEffect4(() => {
600
528
  if (mapInitialized && featureSets?.length && featureSets[0].length > 0 && map && featureSetsLayers?.length) {
601
529
  const { lowUsageColor, highUsageColor } = heatMapColorProps;
602
530
  forget2(MapHeat.initializeAnimatedHeatMapSource(featureSetsLayers, featureSets, map, lowUsageColor, highUsageColor));
@@ -604,187 +532,94 @@ var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets
604
532
  return () => {
605
533
  MapHeat.animationStarted = false;
606
534
  };
607
- }, [
608
- featureSets,
609
- featureSetsLayers,
610
- mapInitialized,
611
- map,
612
- heatMapColorProps
613
- ]);
614
- useEffect5(() => {
535
+ }, [featureSets, featureSetsLayers, mapInitialized, map, heatMapColorProps]);
536
+ useEffect4(() => {
615
537
  if (mapHeat && mapInitialized && features?.length && layers?.length) {
616
538
  mapHeat.initializeHeatMapSource(layers);
617
539
  }
618
- }, [
619
- mapHeat,
620
- features?.length,
621
- layers,
622
- mapInitialized
623
- ]);
624
- useEffect5(() => {
540
+ }, [mapHeat, features?.length, layers, mapInitialized]);
541
+ useEffect4(() => {
625
542
  if (mapInitialized) {
626
543
  const { fitToPoints: fitToPoints2 } = mapSettings || {};
627
544
  if (map) {
628
545
  if (fitToPoints2?.value === true) {
629
- MapHeat.initialMapPositioning({
630
- padding: {
631
- bottom: fitToPadding,
632
- left: fitToPadding,
633
- right: fitToPadding,
634
- top: fitToPadding
635
- }
636
- }, map, features);
546
+ MapHeat.initialMapPositioning(
547
+ {
548
+ padding: {
549
+ bottom: fitToPadding,
550
+ left: fitToPadding,
551
+ right: fitToPadding,
552
+ top: fitToPadding
553
+ }
554
+ },
555
+ map,
556
+ features
557
+ );
637
558
  } else if (options?.zoom && options.center) {
638
559
  map.setZoom(options.zoom);
639
560
  map.setCenter(options.center);
640
561
  }
641
562
  }
642
563
  }
643
- }, [
644
- mapHeat,
645
- map,
646
- mapSettings,
647
- fitToPadding,
648
- options,
649
- mapInitialized,
650
- features
651
- ]);
652
- return /* @__PURE__ */ React3.createElement(HeatMapInitializerContext, {
653
- value
654
- }, children);
655
- }, "HeatMapInitializerProvider");
564
+ }, [mapHeat, map, mapSettings, fitToPadding, options, mapInitialized, features]);
565
+ return /* @__PURE__ */ jsx3(HeatMapInitializerContext, { value, children });
566
+ };
656
567
 
657
568
  // src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx
658
569
  import { assertEx as assertEx4 } from "@xylabs/sdk-js";
659
570
  import { use as use3 } from "react";
660
- var useHeatMapInitializer = /* @__PURE__ */ __name(() => {
571
+ var useHeatMapInitializer = () => {
661
572
  const context = use3(HeatMapInitializerContext);
662
573
  assertEx4("heatMapInitialized" in context, () => "useHeatMapInitializer must be used within a HeatMapInitializerContext");
663
574
  return context;
664
- }, "useHeatMapInitializer");
575
+ };
665
576
 
666
577
  // src/Layers/Configs/HeatMapFillLayerConfig.ts
667
- var HeatMapFillLayerConfig = /* @__PURE__ */ __name((color) => ({
578
+ var HeatMapFillLayerConfig = (color) => ({
668
579
  paint: {
669
580
  "fill-color": color,
670
581
  "fill-opacity": [
671
582
  "let",
672
583
  "density",
673
- [
674
- "+",
675
- [
676
- "/",
677
- [
678
- "number",
679
- [
680
- "get",
681
- "value"
682
- ]
683
- ],
684
- 4
685
- ],
686
- 0.125
687
- ],
688
- [
689
- "interpolate",
690
- [
691
- "linear"
692
- ],
693
- [
694
- "var",
695
- "density"
696
- ],
697
- 0.8,
698
- [
699
- "var",
700
- "density"
701
- ],
702
- 1,
703
- 0.85
704
- ]
584
+ ["+", ["/", ["number", ["get", "value"]], 4], 0.125],
585
+ ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]
705
586
  ]
706
587
  }
707
- }), "HeatMapFillLayerConfig");
588
+ });
708
589
 
709
590
  // src/Layers/Configs/HeatMapLineLayerConfig.ts
710
- var HeatMapLineLayerConfig = /* @__PURE__ */ __name((color) => ({
591
+ var HeatMapLineLayerConfig = (color) => ({
711
592
  layout: {
712
593
  // Enable for debugging
713
594
  visibility: "none"
714
595
  },
715
596
  paint: {
716
597
  "line-color": color,
717
- "line-opacity": [
718
- "let",
719
- "density",
720
- 0,
721
- [
722
- "interpolate",
723
- [
724
- "linear"
725
- ],
726
- [
727
- "var",
728
- "density"
729
- ],
730
- 0.8,
731
- [
732
- "var",
733
- "density"
734
- ],
735
- 1,
736
- 0.85
737
- ]
738
- ],
598
+ "line-opacity": ["let", "density", 0, ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]],
739
599
  "line-width": 0.5
740
600
  }
741
- }), "HeatMapLineLayerConfig");
601
+ });
742
602
 
743
603
  // src/Layers/Configs/HeatMapSymbolLayerConfig.ts
744
- var HeatMapSymbolLayerConfig = /* @__PURE__ */ __name((color) => ({
604
+ var HeatMapSymbolLayerConfig = (color) => ({
745
605
  layout: {
746
606
  "text-anchor": "center",
747
607
  "text-field": [
748
608
  "concat",
749
609
  "value: ",
750
- [
751
- "to-string",
752
- [
753
- "+",
754
- [
755
- "/",
756
- [
757
- "number",
758
- [
759
- "get",
760
- "value"
761
- ]
762
- ],
763
- 2
764
- ],
765
- 0.25
766
- ]
767
- ],
610
+ ["to-string", ["+", ["/", ["number", ["get", "value"]], 2], 0.25]],
768
611
  "\n",
769
612
  "count: ",
770
- [
771
- "to-string",
772
- [
773
- "get",
774
- "count"
775
- ]
776
- ]
613
+ ["to-string", ["get", "count"]]
777
614
  ],
778
615
  "text-size": 10,
779
616
  "visibility": "none"
780
617
  },
781
- paint: {
782
- "text-color": color
783
- }
784
- }), "HeatMapSymbolLayerConfig");
618
+ paint: { "text-color": color }
619
+ });
785
620
 
786
621
  // src/Layers/Configs/LocationPointLayerConfig.ts
787
- var LocationPointLayerConfig = /* @__PURE__ */ __name((color, circleRadius, circleOpacity) => {
622
+ var LocationPointLayerConfig = (color, circleRadius, circleOpacity) => {
788
623
  return {
789
624
  paint: {
790
625
  "circle-color": color,
@@ -792,23 +627,17 @@ var LocationPointLayerConfig = /* @__PURE__ */ __name((color, circleRadius, circ
792
627
  "circle-radius": circleRadius
793
628
  }
794
629
  };
795
- }, "LocationPointLayerConfig");
630
+ };
796
631
 
797
632
  // src/Layers/FillLayer.ts
798
633
  import { LayerBase } from "@xylabs/geo";
799
634
  var FillLayerBuilder = class extends LayerBase {
800
- static {
801
- __name(this, "FillLayerBuilder");
802
- }
803
635
  FillLayerOptions;
804
636
  // ensures this class passes for `AnyLayer` type in MapBox
805
637
  type = "fill";
806
638
  constructor(id, source, FillLayerOptions) {
807
639
  super(id, source);
808
- this.FillLayerOptions = FillLayerOptions || {
809
- id: this.id,
810
- source: this.source
811
- };
640
+ this.FillLayerOptions = FillLayerOptions || { id: this.id, source: this.source };
812
641
  }
813
642
  buildLayer() {
814
643
  return {
@@ -823,18 +652,12 @@ var FillLayerBuilder = class extends LayerBase {
823
652
  // src/Layers/LineLayer.ts
824
653
  import { LayerBase as LayerBase2 } from "@xylabs/geo";
825
654
  var LineLayerBuilder = class extends LayerBase2 {
826
- static {
827
- __name(this, "LineLayerBuilder");
828
- }
829
655
  LineLayerOptions;
830
656
  // ensures this class passes for `AnyLayer` type in MapBox
831
657
  type = "line";
832
658
  constructor(id, source, LineLayerOptions) {
833
659
  super(id, source);
834
- this.LineLayerOptions = LineLayerOptions || {
835
- id: this.id,
836
- source: this.source
837
- };
660
+ this.LineLayerOptions = LineLayerOptions || { id: this.id, source: this.source };
838
661
  }
839
662
  buildLayer() {
840
663
  return {
@@ -850,18 +673,12 @@ var LineLayerBuilder = class extends LayerBase2 {
850
673
  // src/Layers/SymbolLayer.ts
851
674
  import { LayerBase as LayerBase3 } from "@xylabs/geo";
852
675
  var SymbolLayerBuilder = class extends LayerBase3 {
853
- static {
854
- __name(this, "SymbolLayerBuilder");
855
- }
856
676
  SymbolLayerOptions;
857
677
  // ensures this class passes for `AnyLayer` type in MapBox
858
678
  type = "symbol";
859
679
  constructor(id, source, SymbolLayerOptions) {
860
680
  super(id, source);
861
- this.SymbolLayerOptions = SymbolLayerOptions || {
862
- id: this.id,
863
- source: this.source
864
- };
681
+ this.SymbolLayerOptions = SymbolLayerOptions || { id: this.id, source: this.source };
865
682
  }
866
683
  buildLayer() {
867
684
  return {
@@ -882,43 +699,43 @@ var MapHeatConstants = {
882
699
  LocationLineLayerId: "location-line-id",
883
700
  LocationLineLayerSource: "location-line-source"
884
701
  };
885
- var LocationHeatMapLayerBuilder = /* @__PURE__ */ __name((color, alternateColor = "#000") => {
886
- const { LocationFillLayerId, LocationFillLayerSource, LocationLineLayerId, LocationLineLayerSource, LocationDebugLayerId, LocationDebugLayerSource } = MapHeatConstants;
702
+ var LocationHeatMapLayerBuilder = (color, alternateColor = "#000") => {
703
+ const {
704
+ LocationFillLayerId,
705
+ LocationFillLayerSource,
706
+ LocationLineLayerId,
707
+ LocationLineLayerSource,
708
+ LocationDebugLayerId,
709
+ LocationDebugLayerSource
710
+ } = MapHeatConstants;
887
711
  const fillLayerConfig = HeatMapFillLayerConfig(color);
888
712
  const lineLayerConfig = HeatMapLineLayerConfig(color);
889
713
  const debugLayerConfig = HeatMapSymbolLayerConfig(alternateColor);
890
714
  const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
891
715
  const lineLayer = new LineLayerBuilder(LocationLineLayerId, LocationLineLayerSource, lineLayerConfig);
892
716
  const debugLayer2 = new SymbolLayerBuilder(LocationDebugLayerId, LocationDebugLayerSource, debugLayerConfig);
893
- return [
894
- fillLayer,
895
- lineLayer,
896
- debugLayer2
897
- ];
898
- }, "LocationHeatMapLayerBuilder");
717
+ return [fillLayer, lineLayer, debugLayer2];
718
+ };
899
719
 
900
720
  // src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts
901
- var MapHeatConstants2 = /* @__PURE__ */ __name((index, type) => ({
721
+ var MapHeatConstants2 = (index, type) => ({
902
722
  LocationDebugLayerId: `location-${type}-debug-id-${index}`,
903
723
  LocationDebugLayerSource: `location-${type}-debug-source-${index}`,
904
724
  LocationFillLayerId: `location-${type}-fill-id-${index}`,
905
725
  LocationFillLayerSource: `location-${type}-fill-source-${index}`,
906
726
  LocationLineLayerId: `location-${type}-line-id-${index}`,
907
727
  LocationLineLayerSource: `location-${type}-line-source-${index}`
908
- }), "MapHeatConstants");
909
- var LocationHeatMapLayerBuilderAnimated = /* @__PURE__ */ __name((color, index, type = "") => {
728
+ });
729
+ var LocationHeatMapLayerBuilderAnimated = (color, index, type = "") => {
910
730
  const { LocationFillLayerId, LocationFillLayerSource } = MapHeatConstants2(index, type);
911
731
  const fillLayerConfig = HeatMapFillLayerConfig(color);
912
732
  const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
913
733
  return fillLayer;
914
- }, "LocationHeatMapLayerBuilderAnimated");
734
+ };
915
735
 
916
736
  // src/Layers/CircleLayer.ts
917
737
  import { LayerBase as LayerBase4 } from "@xylabs/geo";
918
738
  var CircleLayerBuilder = class extends LayerBase4 {
919
- static {
920
- __name(this, "CircleLayerBuilder");
921
- }
922
739
  CircleLayerOptions;
923
740
  // ensures this class passes for `AnyLayer` type in MapBox
924
741
  type = "circle";
@@ -932,11 +749,7 @@ var CircleLayerBuilder = class extends LayerBase4 {
932
749
  }
933
750
  buildLayer() {
934
751
  return {
935
- filter: [
936
- "==",
937
- "$type",
938
- "Point"
939
- ],
752
+ filter: ["==", "$type", "Point"],
940
753
  layout: {},
941
754
  paint: {
942
755
  "circle-color": "#ff0000",
@@ -955,258 +768,256 @@ var MapPointsConstants = {
955
768
  LocationDotsLayerId: "location-dots",
956
769
  LocationDotsLayerSource: "location-dots-source"
957
770
  };
958
- var LocationPointsMapLayerBuilder = /* @__PURE__ */ __name((color, circleRadius = 6, circleOpacity = 0.8) => {
771
+ var LocationPointsMapLayerBuilder = (color, circleRadius = 6, circleOpacity = 0.8) => {
959
772
  const { LocationDotsLayerId, LocationDotsLayerSource } = MapPointsConstants;
960
773
  const dotLayerConfig = LocationPointLayerConfig(color, circleRadius, circleOpacity);
961
774
  const dotLayer = new CircleLayerBuilder(LocationDotsLayerId, LocationDotsLayerSource, dotLayerConfig);
962
- return [
963
- dotLayer
964
- ];
965
- }, "LocationPointsMapLayerBuilder");
775
+ return [dotLayer];
776
+ };
966
777
 
967
778
  // src/Components/MapBoxHeat.tsx
968
779
  import { FlexCol } from "@xylabs/react-flexbox";
969
- import React7 from "react";
970
780
 
971
781
  // src/Components/MapBox.tsx
972
782
  import "mapbox-gl/dist/mapbox-gl.css";
973
783
  import { MapStyle } from "@xyo-network/react-map-model";
974
784
  import { Map } from "mapbox-gl";
975
- import React4, { useEffect as useEffect6, useRef, useState as useState4 } from "react";
976
- var MapBox = /* @__PURE__ */ __name(({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
977
- const [map, setMap] = useState4();
785
+ import { useEffect as useEffect5, useRef } from "react";
786
+ import { jsx as jsx4 } from "react/jsx-runtime";
787
+ var MapBox = ({
788
+ accessToken,
789
+ darkMode = false,
790
+ options,
791
+ zoom = 2,
792
+ ...props
793
+ }) => {
794
+ const mapRef = useRef(void 0);
978
795
  const mapContainerRef = useRef(null);
979
796
  const mapCanvasRef = useRef(null);
980
797
  const { setMapBoxInstance, map: mapInstance } = useMapBoxInstance();
981
798
  const { mapSettings } = useMapSettings();
982
799
  const activeResize = mapSettings?.dynamicMapResize.value;
983
800
  useDynamicMapResize(mapContainerRef, mapCanvasRef, mapInstance, activeResize);
984
- useEffect6(() => {
801
+ useEffect5(() => {
985
802
  if (mapSettings?.preferDark?.value === true) {
986
- map?.setStyle(`mapbox://styles/${MapStyle.Dark}`);
803
+ mapRef.current?.setStyle(`mapbox://styles/${MapStyle.Dark}`);
987
804
  } else {
988
- map?.setStyle(`mapbox://styles/${darkMode ? MapStyle.Dark : MapStyle.Light}`);
805
+ mapRef.current?.setStyle(`mapbox://styles/${darkMode ? MapStyle.Dark : MapStyle.Light}`);
989
806
  }
990
- }, [
991
- map,
992
- darkMode,
993
- mapSettings
994
- ]);
995
- useEffect6(() => {
996
- const map2 = new Map({
807
+ }, [darkMode, mapSettings]);
808
+ useEffect5(() => {
809
+ const map = new Map({
997
810
  accessToken,
998
- center: [
999
- 0,
1000
- 0
1001
- ],
811
+ center: [0, 0],
1002
812
  container: mapContainerRef.current ?? "",
1003
813
  style: `mapbox://styles/${MapStyle.Light}`,
1004
814
  zoom,
1005
815
  ...options
1006
816
  });
1007
- setMapBoxInstance?.(map2);
1008
- setMap(map2);
817
+ mapRef.current = map;
818
+ setMapBoxInstance?.(map);
1009
819
  mapCanvasRef.current = document.querySelector(".mapboxgl-canvas");
1010
820
  console.log("Created Map");
1011
821
  return () => {
1012
822
  console.log("Removing Map");
1013
- map2.remove();
823
+ map.remove();
1014
824
  };
1015
- }, [
1016
- mapContainerRef,
1017
- setMap,
1018
- options,
1019
- zoom,
1020
- setMapBoxInstance,
1021
- accessToken
1022
- ]);
1023
- return /* @__PURE__ */ React4.createElement("div", {
1024
- ref: /* @__PURE__ */ __name((el) => {
1025
- mapContainerRef.current = el;
1026
- }, "ref"),
1027
- style: {
1028
- bottom: 0,
1029
- left: 0,
1030
- position: "absolute",
1031
- right: 0,
1032
- top: 0,
1033
- ...props
825
+ }, [mapContainerRef, options, zoom, setMapBoxInstance, accessToken]);
826
+ return /* @__PURE__ */ jsx4(
827
+ "div",
828
+ {
829
+ ref: (el) => {
830
+ mapContainerRef.current = el;
831
+ },
832
+ style: {
833
+ bottom: 0,
834
+ left: 0,
835
+ position: "absolute",
836
+ right: 0,
837
+ top: 0,
838
+ ...props
839
+ }
1034
840
  }
1035
- });
1036
- }, "MapBox");
841
+ );
842
+ };
1037
843
 
1038
844
  // src/Components/MapSettingsComponents/Setting.tsx
1039
845
  import { FormControlLabel, Switch } from "@mui/material";
1040
- import React5 from "react";
1041
- var MapSettingSwitch = /* @__PURE__ */ __name(({ developerMode, field, ...props }) => {
846
+ import { jsx as jsx5 } from "react/jsx-runtime";
847
+ var MapSettingSwitch = ({
848
+ developerMode,
849
+ field,
850
+ ...props
851
+ }) => {
1042
852
  const { mapSettings, setMapSettings } = useMapSettings();
1043
853
  const setting = mapSettings?.[field];
1044
- const onLocalChange = /* @__PURE__ */ __name((event) => {
854
+ const onLocalChange = (event) => {
1045
855
  if (setting) {
1046
856
  setMapSettings?.((previous) => {
1047
857
  previous[setting.field].value = event.target.checked;
1048
- return {
1049
- ...previous
1050
- };
858
+ return { ...previous };
1051
859
  });
1052
860
  }
1053
- }, "onLocalChange");
861
+ };
1054
862
  if (setting?.devMode && developerMode === false) {
1055
863
  return null;
1056
864
  }
1057
- return setting?.hidden ? null : /* @__PURE__ */ React5.createElement(FormControlLabel, {
1058
- label: setting?.label,
1059
- control: /* @__PURE__ */ React5.createElement(Switch, {
1060
- checked: setting?.value,
1061
- onChange: onLocalChange,
1062
- ...props
1063
- })
1064
- });
1065
- }, "MapSettingSwitch");
865
+ return setting?.hidden ? null : /* @__PURE__ */ jsx5(FormControlLabel, { label: setting?.label, control: /* @__PURE__ */ jsx5(Switch, { checked: setting?.value, onChange: onLocalChange, ...props }) });
866
+ };
1066
867
 
1067
868
  // src/Components/MapSettingsComponents/SettingsBox.tsx
1068
869
  import { Paper, Stack } from "@mui/material";
1069
870
  import { useAppSettings } from "@xylabs/react-app-settings";
1070
871
  import { FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
1071
- import React6 from "react";
1072
- var MapSettingsBox = /* @__PURE__ */ __name(({ developerMode, ...props }) => {
872
+ import { jsx as jsx6 } from "react/jsx-runtime";
873
+ var MapSettingsBox = ({ developerMode, ...props }) => {
1073
874
  const { mapSettings } = useMapSettings();
1074
875
  const { developerMode: devModeFromContext } = useAppSettings();
1075
876
  const resolveDeveloperMode = developerMode ?? devModeFromContext;
1076
- return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ React6.createElement(FlexGrowRow, {
1077
- bottom: 36,
1078
- left: 10,
1079
- position: "absolute",
1080
- ...props
1081
- }, /* @__PURE__ */ React6.createElement(FlexRow, {
1082
- paddingX: 2
1083
- }, /* @__PURE__ */ React6.createElement(Paper, null, /* @__PURE__ */ React6.createElement(Stack, {
1084
- direction: "row",
1085
- spacing: 1,
1086
- marginX: 1
1087
- }, Object.keys(mapSettings).map((key, index) => {
1088
- return /* @__PURE__ */ React6.createElement(MapSettingSwitch, {
1089
- key: index,
1090
- field: mapSettings[key].field,
1091
- developerMode
1092
- });
1093
- }))))) : null;
1094
- }, "MapSettingsBox");
877
+ return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ jsx6(FlexGrowRow, { bottom: 36, left: 10, position: "absolute", ...props, children: /* @__PURE__ */ jsx6(FlexRow, { paddingX: 2, children: /* @__PURE__ */ jsx6(Paper, { children: /* @__PURE__ */ jsx6(Stack, { direction: "row", spacing: 1, marginX: 1, children: Object.keys(mapSettings).map((key) => {
878
+ return /* @__PURE__ */ jsx6(MapSettingSwitch, { field: mapSettings[key].field, developerMode }, key);
879
+ }) }) }) }) }) : null;
880
+ };
1095
881
 
1096
882
  // src/Components/MapBoxHeat.tsx
1097
- var MapboxHeatFlexBox = /* @__PURE__ */ __name(({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
1098
- return /* @__PURE__ */ React7.createElement(FlexCol, props, /* @__PURE__ */ React7.createElement(MapBox, {
1099
- accessToken,
1100
- options: mapBoxOptions,
1101
- zoom
1102
- }), /* @__PURE__ */ React7.createElement(MapSettingsBox, {
1103
- developerMode
1104
- }), legend, children);
1105
- }, "MapboxHeatFlexBox");
883
+ import { jsx as jsx7, jsxs } from "react/jsx-runtime";
884
+ var MapboxHeatFlexBox = ({
885
+ accessToken,
886
+ children,
887
+ mapBoxOptions,
888
+ zoom,
889
+ legend,
890
+ developerMode,
891
+ ...props
892
+ }) => {
893
+ return /* @__PURE__ */ jsxs(FlexCol, { ...props, children: [
894
+ /* @__PURE__ */ jsx7(MapBox, { accessToken, options: mapBoxOptions, zoom }),
895
+ /* @__PURE__ */ jsx7(MapSettingsBox, { developerMode }),
896
+ legend,
897
+ children
898
+ ] });
899
+ };
1106
900
 
1107
901
  // src/Components/AnimatedHeatMap.tsx
1108
- var AnimatedHeatMap = /* @__PURE__ */ __name(({ accessToken, animatedFeatureSets, defaultMapSettings, heatMapColorProps, staticFeatureSet, ...props }) => {
902
+ import { jsx as jsx8 } from "react/jsx-runtime";
903
+ var AnimatedHeatMap = ({
904
+ accessToken,
905
+ animatedFeatureSets,
906
+ defaultMapSettings,
907
+ heatMapColorProps,
908
+ staticFeatureSet,
909
+ ...props
910
+ }) => {
1109
911
  const theme = useTheme();
1110
- const { staticMapColor, lowUsageColor, highUsageColor } = heatMapColorProps || {};
912
+ const {
913
+ staticMapColor,
914
+ lowUsageColor,
915
+ highUsageColor
916
+ } = heatMapColorProps || {};
1111
917
  const localStaticMapColor = staticMapColor ?? theme.vars.palette.primary.light;
1112
- const [layers] = useState5(() => [
918
+ const [layers] = useState3(() => [
1113
919
  LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, "static"),
1114
920
  LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, "animated"),
1115
921
  LocationHeatMapLayerBuilderAnimated(highUsageColor || darkenCss(localStaticMapColor, 0.9), 1, "animated")
1116
922
  ]);
1117
- return animatedFeatureSets?.length ? /* @__PURE__ */ React8.createElement(MapBoxInstanceProvider, null, /* @__PURE__ */ React8.createElement(MapSettingsProvider, {
1118
- defaultMapSettings,
1119
- debugLayerName: MapHeatConstants.LocationDebugLayerId
1120
- }, /* @__PURE__ */ React8.createElement(HeatMapInitializerProvider, {
1121
- features: staticFeatureSet,
1122
- layers: [
1123
- layers[0]
1124
- ],
1125
- featureSets: animatedFeatureSets,
1126
- featureSetsLayers: layers.slice(1, 3),
1127
- heatMapColorProps
1128
- }, /* @__PURE__ */ React8.createElement(MapboxHeatFlexBox, {
1129
- accessToken,
1130
- ...props
1131
- })))) : /* @__PURE__ */ React8.createElement(FlexCol2, {
1132
- minHeight: 160,
1133
- minWidth: 160,
1134
- busy: true
1135
- });
1136
- }, "AnimatedHeatMap");
923
+ return animatedFeatureSets?.length ? /* @__PURE__ */ jsx8(MapBoxInstanceProvider, { children: /* @__PURE__ */ jsx8(MapSettingsProvider, { defaultMapSettings, debugLayerName: MapHeatConstants.LocationDebugLayerId, children: /* @__PURE__ */ jsx8(
924
+ HeatMapInitializerProvider,
925
+ {
926
+ features: staticFeatureSet,
927
+ layers: [layers[0]],
928
+ featureSets: animatedFeatureSets,
929
+ featureSetsLayers: layers.slice(1, 3),
930
+ heatMapColorProps,
931
+ children: /* @__PURE__ */ jsx8(MapboxHeatFlexBox, { accessToken, ...props })
932
+ }
933
+ ) }) }) : /* @__PURE__ */ jsx8(FlexCol2, { minHeight: 160, minWidth: 160, busy: true });
934
+ };
1137
935
 
1138
936
  // src/Components/AnimatedHeatMapLoaded.tsx
1139
937
  import { Alert, AlertTitle } from "@mui/material";
1140
938
  import { FlexCol as FlexCol5 } from "@xylabs/react-flexbox";
1141
939
  import { useWeakArchivistFromNode, useWeakArchivistGet } from "@xyo-network/react-archivist";
1142
- import { AnimatedHeatMapSettings, useFindHashes, useHeatMapColors } from "@xyo-network/react-map-model";
1143
- import React11 from "react";
940
+ import {
941
+ AnimatedHeatMapSettings,
942
+ useFindHashes,
943
+ useHeatMapColors
944
+ } from "@xyo-network/react-map-model";
1144
945
 
1145
946
  // src/Components/Legend.tsx
1146
947
  import { useMediaQuery, useTheme as useTheme3 } from "@mui/material";
1147
948
  import { FlexCol as FlexCol4 } from "@xylabs/react-flexbox";
1148
- import React10 from "react";
1149
949
 
1150
950
  // src/Components/Legends/ColorGradient.tsx
1151
951
  import { Typography, useTheme as useTheme2 } from "@mui/material";
1152
952
  import { FlexCol as FlexCol3, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
1153
- import React9 from "react";
1154
- var ColorGradientLegend = /* @__PURE__ */ __name(({ startColor, endColor, startLabel, endLabel, heading, textColor, ...props }) => {
953
+ import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
954
+ var ColorGradientLegend = ({
955
+ startColor,
956
+ endColor,
957
+ startLabel,
958
+ endLabel,
959
+ heading,
960
+ textColor,
961
+ ...props
962
+ }) => {
1155
963
  const theme = useTheme2();
1156
- return /* @__PURE__ */ React9.createElement(FlexCol3, props, /* @__PURE__ */ React9.createElement(Typography, {
1157
- mb: theme.spacing(0.25),
1158
- color: textColor,
1159
- variant: "caption",
1160
- textAlign: "center"
1161
- }, heading), /* @__PURE__ */ React9.createElement(FlexCol3, {
1162
- flexGrow: 1,
1163
- alignItems: "stretch",
1164
- paddingX: theme.spacing(1),
1165
- mb: theme.spacing(0.25)
1166
- }, /* @__PURE__ */ React9.createElement(FlexCol3, {
1167
- height: theme.spacing(0.75),
1168
- border: `1px solid ${textColor}`,
1169
- sx: {
1170
- backgroundImage: `linear-gradient(to right, ${startColor},${endColor})`
1171
- }
1172
- })), /* @__PURE__ */ React9.createElement(FlexRow2, {
1173
- flexGrow: 1,
1174
- justifyContent: "space-between"
1175
- }, /* @__PURE__ */ React9.createElement(Typography, {
1176
- color: textColor,
1177
- variant: "caption"
1178
- }, startLabel), /* @__PURE__ */ React9.createElement(Typography, {
1179
- color: textColor,
1180
- variant: "caption"
1181
- }, endLabel)));
1182
- }, "ColorGradientLegend");
964
+ return /* @__PURE__ */ jsxs2(FlexCol3, { ...props, children: [
965
+ /* @__PURE__ */ jsx9(Typography, { mb: theme.spacing(0.25), color: textColor, variant: "caption", textAlign: "center", children: heading }),
966
+ /* @__PURE__ */ jsx9(FlexCol3, { flexGrow: 1, alignItems: "stretch", paddingX: theme.spacing(1), mb: theme.spacing(0.25), children: /* @__PURE__ */ jsx9(
967
+ FlexCol3,
968
+ {
969
+ height: theme.spacing(0.75),
970
+ border: `1px solid ${textColor}`,
971
+ sx: { backgroundImage: `linear-gradient(to right, ${startColor},${endColor})` }
972
+ }
973
+ ) }),
974
+ /* @__PURE__ */ jsxs2(FlexRow2, { flexGrow: 1, justifyContent: "space-between", children: [
975
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: startLabel }),
976
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: endLabel })
977
+ ] })
978
+ ] });
979
+ };
1183
980
 
1184
981
  // src/Components/Legend.tsx
1185
- var AnimatedHeatMapLegend = /* @__PURE__ */ __name(({ ...legendProps }) => {
1186
- const { startColor, endColor, startLabel, endLabel, heading, textColor } = legendProps;
1187
- const theme = useTheme3();
1188
- const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
1189
- return /* @__PURE__ */ React10.createElement(FlexCol4, {
1190
- position: "absolute",
1191
- bottom: 0,
1192
- right: 0
1193
- }, /* @__PURE__ */ React10.createElement(ColorGradientLegend, {
982
+ import { jsx as jsx10 } from "react/jsx-runtime";
983
+ var AnimatedHeatMapLegend = ({ ...legendProps }) => {
984
+ const {
1194
985
  startColor,
1195
986
  endColor,
1196
987
  startLabel,
1197
988
  endLabel,
1198
989
  heading,
1199
- textColor,
1200
- alignItems: "stretch",
1201
- marginBottom: theme.spacing(4),
1202
- marginLeft: isSmall ? theme.spacing(3) : 0,
1203
- marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
1204
- width: isSmall ? "40vw" : theme.spacing(18)
1205
- }));
1206
- }, "AnimatedHeatMapLegend");
990
+ textColor
991
+ } = legendProps;
992
+ const theme = useTheme3();
993
+ const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
994
+ return /* @__PURE__ */ jsx10(FlexCol4, { position: "absolute", bottom: 0, right: 0, children: /* @__PURE__ */ jsx10(
995
+ ColorGradientLegend,
996
+ {
997
+ startColor,
998
+ endColor,
999
+ startLabel,
1000
+ endLabel,
1001
+ heading,
1002
+ textColor,
1003
+ ...{
1004
+ alignItems: "stretch",
1005
+ marginBottom: theme.spacing(4),
1006
+ marginLeft: isSmall ? theme.spacing(3) : 0,
1007
+ marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
1008
+ width: isSmall ? "40vw" : theme.spacing(18)
1009
+ }
1010
+ }
1011
+ ) });
1012
+ };
1207
1013
 
1208
1014
  // src/Components/AnimatedHeatMapLoaded.tsx
1209
- var AnimatedHeatMapLoaded = /* @__PURE__ */ __name(({ accessToken, archivistNameOrAddress, ...props }) => {
1015
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
1016
+ var AnimatedHeatMapLoaded = ({
1017
+ accessToken,
1018
+ archivistNameOrAddress,
1019
+ ...props
1020
+ }) => {
1210
1021
  const hashes = useFindHashes();
1211
1022
  const [archivist] = useWeakArchivistFromNode(archivistNameOrAddress);
1212
1023
  const [payloads, xyoError] = useWeakArchivistGet(archivist, hashes);
@@ -1214,106 +1025,113 @@ var AnimatedHeatMapLoaded = /* @__PURE__ */ __name(({ accessToken, archivistName
1214
1025
  const { heatMapColorProps, legendProps } = useHeatMapColors();
1215
1026
  const MapBoxHeatProps = {
1216
1027
  flexGrow: 1,
1217
- legend: legendProps ? /* @__PURE__ */ React11.createElement(AnimatedHeatMapLegend, legendProps) : null
1028
+ legend: legendProps ? /* @__PURE__ */ jsx11(AnimatedHeatMapLegend, { ...legendProps }) : null
1218
1029
  };
1219
- return /* @__PURE__ */ React11.createElement(FlexCol5, {
1220
- alignItems: "stretch",
1221
- ...props
1222
- }, xyoError ? /* @__PURE__ */ React11.createElement(Alert, {
1223
- sx: {
1224
- mt: 2
1225
- }
1226
- }, /* @__PURE__ */ React11.createElement(AlertTitle, null, "Error Loading Map"), xyoError.message ? `Error: ${xyoError.message}` : null, "You might try authenticating again.") : null, hashes === void 0 ? /* @__PURE__ */ React11.createElement(Alert, null, "Missing answer hash for heat map query") : /* @__PURE__ */ React11.createElement(AnimatedHeatMap, {
1227
- accessToken,
1228
- defaultMapSettings: AnimatedHeatMapSettings,
1229
- animatedFeatureSets: multipleFeatureSets.slice(1),
1230
- staticFeatureSet: multipleFeatureSets[0],
1231
- heatMapColorProps,
1232
- ...MapBoxHeatProps
1233
- }));
1234
- }, "AnimatedHeatMapLoaded");
1030
+ return /* @__PURE__ */ jsxs3(FlexCol5, { alignItems: "stretch", ...props, children: [
1031
+ xyoError ? /* @__PURE__ */ jsxs3(Alert, { sx: { mt: 2 }, children: [
1032
+ /* @__PURE__ */ jsx11(AlertTitle, { children: "Error Loading Map" }),
1033
+ xyoError.message ? `Error: ${xyoError.message}` : null,
1034
+ "You might try authenticating again."
1035
+ ] }) : null,
1036
+ hashes === void 0 ? /* @__PURE__ */ jsx11(Alert, { children: "Missing answer hash for heat map query" }) : /* @__PURE__ */ jsx11(
1037
+ AnimatedHeatMap,
1038
+ {
1039
+ accessToken,
1040
+ defaultMapSettings: AnimatedHeatMapSettings,
1041
+ animatedFeatureSets: multipleFeatureSets.slice(1),
1042
+ staticFeatureSet: multipleFeatureSets[0],
1043
+ heatMapColorProps,
1044
+ ...MapBoxHeatProps
1045
+ }
1046
+ )
1047
+ ] });
1048
+ };
1235
1049
 
1236
1050
  // src/Components/HeatMapSettings.ts
1237
1051
  import { DefaultMapSettings } from "@xyo-network/react-map-model";
1238
1052
  var HeatMapSettings = DefaultMapSettings();
1239
- var { debugLayer, scrollToZoom, fitToPoints } = HeatMapSettings;
1053
+ var {
1054
+ debugLayer,
1055
+ scrollToZoom,
1056
+ fitToPoints
1057
+ } = HeatMapSettings;
1240
1058
  debugLayer.hidden = false;
1241
1059
  scrollToZoom.value = true;
1242
1060
  fitToPoints.value = true;
1243
1061
 
1244
1062
  // src/Components/LayerAnimator.tsx
1245
1063
  import { useInterval } from "@xylabs/react-shared";
1246
- import React12, { useCallback, useEffect as useEffect7, useMemo as useMemo6, useRef as useRef2 } from "react";
1064
+ import {
1065
+ useCallback,
1066
+ useEffect as useEffect6,
1067
+ useMemo as useMemo6,
1068
+ useRef as useRef2
1069
+ } from "react";
1070
+ import { Fragment, jsx as jsx12 } from "react/jsx-runtime";
1247
1071
  var timeIncrement = 2e3;
1248
1072
  var animatedLayerCount = 3;
1249
- var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, layersInitialized, map }) => {
1250
- const layerIndexQueue = useRef2([]);
1073
+ var LayerAnimator = ({
1074
+ animateLayers,
1075
+ children,
1076
+ layers,
1077
+ layersInitialized,
1078
+ map
1079
+ }) => {
1080
+ const layerIndexQueueRef = useRef2([]);
1251
1081
  const fillLayers = useMemo6(() => {
1252
1082
  if (layers?.length && map && layersInitialized) {
1253
1083
  return layers.filter((layer) => {
1254
1084
  const fillLayer = layer.id.startsWith("location-fill");
1255
1085
  if (fillLayer) {
1256
- map.setPaintProperty(layer.id, "fill-opacity-transition", {
1257
- delay: 0,
1258
- duration: 4e3
1259
- });
1086
+ map.setPaintProperty(layer.id, "fill-opacity-transition", { delay: 0, duration: 4e3 });
1260
1087
  }
1261
1088
  return fillLayer;
1262
1089
  });
1263
1090
  }
1264
1091
  return [];
1265
- }, [
1266
- layers,
1267
- layersInitialized,
1268
- map
1269
- ]);
1270
- const incrementQueue = useCallback((index) => {
1271
- if (fillLayers[index]) {
1272
- layerIndexQueue.current.push(index);
1273
- } else {
1274
- layerIndexQueue.current.push(0);
1275
- }
1276
- return layerIndexQueue.current.at(-1);
1277
- }, [
1278
- fillLayers
1279
- ]);
1092
+ }, [layers, layersInitialized, map]);
1093
+ const incrementQueue = useCallback(
1094
+ (index) => {
1095
+ if (fillLayers[index]) {
1096
+ layerIndexQueueRef.current.push(index);
1097
+ } else {
1098
+ layerIndexQueueRef.current.push(0);
1099
+ }
1100
+ return layerIndexQueueRef.current.at(-1);
1101
+ },
1102
+ [fillLayers]
1103
+ );
1280
1104
  const lastQueuedIndex = useCallback(() => {
1281
- const last = layerIndexQueue.current.at(-1);
1105
+ const last = layerIndexQueueRef.current.at(-1);
1282
1106
  if (last === void 0) {
1283
1107
  incrementQueue(0);
1284
1108
  return 0;
1285
1109
  } else {
1286
1110
  return last;
1287
1111
  }
1288
- }, [
1289
- incrementQueue
1290
- ]);
1112
+ }, [incrementQueue]);
1291
1113
  const unshiftQueue = useCallback(() => {
1292
- layerIndexQueue.current.shift();
1114
+ layerIndexQueueRef.current.shift();
1293
1115
  }, []);
1294
1116
  const getNextLayer = useCallback(() => {
1295
1117
  const nextLayer = fillLayers[lastQueuedIndex()];
1296
1118
  incrementQueue(lastQueuedIndex() + 1);
1297
1119
  return nextLayer;
1298
- }, [
1299
- fillLayers,
1300
- incrementQueue,
1301
- lastQueuedIndex
1302
- ]);
1303
- const layerAnimateWorker = useCallback((layer) => {
1304
- if (layer) {
1305
- map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
1306
- setTimeout(() => {
1307
- map?.setPaintProperty(layer.id, "fill-opacity", 0);
1308
- unshiftQueue();
1309
- }, timeIncrement * 2);
1310
- } else {
1311
- console.warn("tried to queue an empty layer");
1312
- }
1313
- }, [
1314
- map,
1315
- unshiftQueue
1316
- ]);
1120
+ }, [fillLayers, incrementQueue, lastQueuedIndex]);
1121
+ const layerAnimateWorker = useCallback(
1122
+ (layer) => {
1123
+ if (layer) {
1124
+ map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
1125
+ setTimeout(() => {
1126
+ map?.setPaintProperty(layer.id, "fill-opacity", 0);
1127
+ unshiftQueue();
1128
+ }, timeIncrement * 2);
1129
+ } else {
1130
+ console.warn("tried to queue an empty layer");
1131
+ }
1132
+ },
1133
+ [map, unshiftQueue]
1134
+ );
1317
1135
  const queueLayerAnimation = useCallback(() => {
1318
1136
  const animatedLayers = [];
1319
1137
  for (let i = 0; i < animatedLayerCount; i++) {
@@ -1328,122 +1146,71 @@ var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, l
1328
1146
  }, timeIncrement * index);
1329
1147
  }
1330
1148
  }
1331
- }, [
1332
- getNextLayer,
1333
- layerAnimateWorker
1334
- ]);
1335
- useEffect7(() => {
1149
+ }, [getNextLayer, layerAnimateWorker]);
1150
+ useEffect6(() => {
1336
1151
  if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1337
1152
  queueLayerAnimation();
1338
1153
  }
1339
- }, [
1340
- animateLayers,
1341
- fillLayers.length,
1342
- layersInitialized,
1343
- map,
1344
- queueLayerAnimation
1345
- ]);
1154
+ }, [animateLayers, fillLayers.length, layersInitialized, map, queueLayerAnimation]);
1346
1155
  useInterval(() => {
1347
1156
  if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1348
1157
  queueLayerAnimation();
1349
1158
  }
1350
1159
  }, timeIncrement * animatedLayerCount);
1351
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, children);
1352
- }, "LayerAnimator");
1160
+ return /* @__PURE__ */ jsx12(Fragment, { children });
1161
+ };
1353
1162
 
1354
1163
  // src/Components/MapBoxPoints.tsx
1355
1164
  import { Alert as Alert2 } from "@mui/material";
1356
1165
  import { FlexCol as FlexCol6 } from "@xylabs/react-flexbox";
1357
- import React13, { useCallback as useCallback2, useEffect as useEffect8, useMemo as useMemo7 } from "react";
1358
- var MapboxPointsFlexBox = /* @__PURE__ */ __name(({ accessToken, features, fitToPointsPadding = 20, layers, zoom, ...props }) => {
1166
+ import { useEffect as useEffect7 } from "react";
1167
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
1168
+ var MapboxPointsFlexBox = ({
1169
+ accessToken,
1170
+ features,
1171
+ fitToPointsPadding = 20,
1172
+ layers,
1173
+ zoom,
1174
+ ...props
1175
+ }) => {
1359
1176
  const { mapSettings } = useMapSettings();
1360
1177
  const { map, mapInitialized } = useMapBoxInstance();
1361
- const customFitToBoundsOptions = /* @__PURE__ */ __name((zoom2) => {
1178
+ const customFitToBoundsOptions = (zoom2) => {
1362
1179
  if (zoom2 !== void 0) {
1363
- return {
1364
- maxZoom: zoom2
1365
- };
1180
+ return { maxZoom: zoom2 };
1366
1181
  }
1367
1182
  return {};
1368
- }, "customFitToBoundsOptions");
1369
- const mapPoints = useMemo7(() => {
1370
- return map && features?.length ? new MapPoints({
1371
- features,
1372
- map,
1373
- zoom
1374
- }) : void 0;
1375
- }, [
1376
- map,
1377
- features,
1378
- zoom
1379
- ]);
1380
- const updateFeatures = useCallback2(() => {
1381
- if (mapPoints?.isMapReady && features?.length && layers) for (const layer of layers) {
1382
- mapPoints.initializeMapSource(layer);
1383
- }
1384
- }, [
1385
- mapPoints,
1386
- features,
1387
- layers
1388
- ]);
1389
- const updateMapSetup = useCallback2(() => {
1390
- const { fitToPoints: fitToPoints2 } = mapSettings || {};
1391
- if (mapPoints && map && fitToPoints2?.value === true) {
1392
- mapPoints.initialMapPositioning({
1393
- padding: {
1394
- bottom: fitToPointsPadding,
1395
- left: fitToPointsPadding,
1396
- right: fitToPointsPadding,
1397
- top: fitToPointsPadding
1398
- },
1399
- ...customFitToBoundsOptions(zoom)
1400
- });
1401
- }
1402
- }, [
1403
- mapSettings,
1404
- mapPoints,
1405
- map,
1406
- fitToPointsPadding,
1407
- zoom
1408
- ]);
1409
- const reInitializeMap = useCallback2(() => {
1410
- mapPoints?.initialMapPositioning({
1411
- padding: {
1183
+ };
1184
+ useEffect7(() => {
1185
+ if (mapInitialized) {
1186
+ const mapPoints = map && features?.length ? new MapPoints({
1187
+ features,
1188
+ map,
1189
+ zoom
1190
+ }) : void 0;
1191
+ const { fitToPoints: fitToPoints2 } = mapSettings || {};
1192
+ const padding = {
1412
1193
  bottom: fitToPointsPadding,
1413
1194
  left: fitToPointsPadding,
1414
1195
  right: fitToPointsPadding,
1415
1196
  top: fitToPointsPadding
1416
- },
1417
- ...customFitToBoundsOptions(zoom)
1418
- });
1419
- updateFeatures();
1420
- }, [
1421
- mapPoints,
1422
- fitToPointsPadding,
1423
- updateFeatures,
1424
- zoom
1425
- ]);
1426
- useEffect8(() => {
1427
- if (mapInitialized) {
1428
- updateMapSetup();
1429
- reInitializeMap();
1197
+ };
1198
+ if (mapPoints && map && fitToPoints2?.value === true) {
1199
+ mapPoints.initialMapPositioning({ padding, ...customFitToBoundsOptions(zoom) });
1200
+ }
1201
+ mapPoints?.initialMapPositioning({ padding, ...customFitToBoundsOptions(zoom) });
1202
+ if (mapPoints?.isMapReady && features?.length && layers) {
1203
+ for (const layer of layers) {
1204
+ mapPoints.initializeMapSource(layer);
1205
+ }
1206
+ }
1430
1207
  }
1431
- }, [
1432
- mapInitialized,
1433
- reInitializeMap,
1434
- updateMapSetup
1435
- ]);
1436
- return /* @__PURE__ */ React13.createElement(FlexCol6, {
1437
- alignItems: "stretch",
1438
- id: "xyo-mapbox-wrap",
1439
- ...props
1440
- }, features ? /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(MapBox, {
1441
- accessToken,
1442
- zoom
1443
- }), /* @__PURE__ */ React13.createElement(MapSettingsBox, null)) : /* @__PURE__ */ React13.createElement(Alert2, {
1444
- severity: "error"
1445
- }, "No data to show"));
1446
- }, "MapboxPointsFlexBox");
1208
+ }, [mapInitialized, mapSettings, map, fitToPointsPadding, zoom, features, layers]);
1209
+ return /* @__PURE__ */ jsx13(FlexCol6, { alignItems: "stretch", id: "xyo-mapbox-wrap", ...props, children: features ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
1210
+ /* @__PURE__ */ jsx13(MapBox, { accessToken, zoom }),
1211
+ /* @__PURE__ */ jsx13(MapSettingsBox, {})
1212
+ ] }) : /* @__PURE__ */ jsx13(Alert2, { severity: "error", children: "No data to show" }) });
1213
+ };
1447
1214
  export {
1448
1215
  AnimatedHeatMap,
1449
1216
  AnimatedHeatMapLegend,