@local-logic/maps 0.0.23 → 0.0.24

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 (68) hide show
  1. package/dist/index-BOZt1-DO.js +69 -0
  2. package/dist/{index-BrxP9NHZ.js → index-Buv9_Jj9.js} +3 -3
  3. package/dist/index-C3Tj3r2u.js +24 -0
  4. package/dist/index-C6a0FCIX.js +92 -0
  5. package/dist/index-CCS3Ef2w.js +92 -0
  6. package/dist/{index-CSVsF1EQ.js → index-CEDpofgZ.js} +1 -1
  7. package/dist/{index-BRD3rjLE.js → index-CIE9YlvM.js} +12 -12
  8. package/dist/index-CUUravWc.js +25 -0
  9. package/dist/index-CUvZ7gVt.js +98 -0
  10. package/dist/{index-CN_dNOir.js → index-Ct-3yYUx.js} +245 -217
  11. package/dist/index-DJx0avMT.js +75 -0
  12. package/dist/{index-B85VZGVP.js → index-DOkeQ2e4.js} +3 -3
  13. package/dist/{index-ufLC1PLO.js → index-DbyYOXrb.js} +16 -16
  14. package/dist/index-DntG4mBo.js +75 -0
  15. package/dist/{index-CFomI3Il.js → index-DscDx7HE.js} +14 -13
  16. package/dist/{index-DfhwDiOS.js → index-GGtrKiJn.js} +22 -22
  17. package/dist/index-Y5T20C1G.js +92 -0
  18. package/dist/{index-CiWKwaC4.js → index-eWv3le07.js} +7 -6
  19. package/dist/index.es.js +1 -1
  20. package/dist/index.umd.js +8 -3615
  21. package/dist/{logo-control-VgN6MEKI.js → logo-control-CHapR1Dt.js} +11 -11
  22. package/dist/{scale-control-jBKptTbw.js → scale-control-Dsir9fWY.js} +21 -21
  23. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts +1 -1
  24. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -1
  25. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts +1 -1
  26. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -1
  27. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts +1 -1
  28. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -1
  29. package/dist/src/components/Map/Root/BaseMap/index.d.ts +1 -1
  30. package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -1
  31. package/dist/src/components/Map/Root/BaseMap/types.d.ts +1 -10
  32. package/dist/src/components/Map/Root/BaseMap/types.d.ts.map +1 -1
  33. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -1
  34. package/dist/src/components/Map/Root/Popup/Google/index.d.ts.map +1 -1
  35. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts.map +1 -1
  36. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts.map +1 -1
  37. package/dist/src/components/Map/Root/Popup/utils/index.d.ts +2 -0
  38. package/dist/src/components/Map/Root/Popup/utils/index.d.ts.map +1 -0
  39. package/dist/src/components/Map/Root/Popup/utils/moveIntoView/index.d.ts +21 -0
  40. package/dist/src/components/Map/Root/Popup/utils/moveIntoView/index.d.ts.map +1 -0
  41. package/dist/src/components/Map/Root/constants.d.ts +11 -2
  42. package/dist/src/components/Map/Root/constants.d.ts.map +1 -1
  43. package/dist/src/components/Map/Root/context.d.ts +6 -6
  44. package/dist/src/components/Map/Root/context.d.ts.map +1 -1
  45. package/dist/src/components/Map/Root/index.d.ts.map +1 -1
  46. package/dist/src/components/Map/Root/types.d.ts +9 -0
  47. package/dist/src/components/Map/Root/types.d.ts.map +1 -1
  48. package/dist/src/components/Map/index.stories.d.ts +9 -3
  49. package/dist/src/components/Map/index.stories.d.ts.map +1 -1
  50. package/dist/style.css +1 -1
  51. package/dist/styles-BNaT0cTi.js +36 -0
  52. package/dist/{styles-BR85tnqI.js → styles-BhmqUA5C.js} +231 -266
  53. package/package.json +30 -10
  54. package/dist/IconBase.es-rM5tt24D.js +0 -48
  55. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  56. package/dist/index-BpFpg_5A.js +0 -78
  57. package/dist/index-CRdDPWou.js +0 -34
  58. package/dist/index-CceEGv05.js +0 -104
  59. package/dist/index-CmajMf1d.js +0 -109
  60. package/dist/index-D5kHxP9H.js +0 -43
  61. package/dist/index-DNNz78Rc.js +0 -24
  62. package/dist/index-Db33Ugg9.js +0 -34
  63. package/dist/index-arkRlpaR.js +0 -80
  64. package/dist/index-vHMPqmOL.js +0 -23
  65. package/dist/index.modern-B-ChKejQ.js +0 -914
  66. package/dist/mapbox-gl-C6frO4Gl.js +0 -34625
  67. package/dist/maplibre-gl-DkDrZ6rP.js +0 -21669
  68. package/dist/styles-ChFj97uV.js +0 -7
@@ -1,7 +1,7 @@
1
1
  import { jsx as O } from "react/jsx-runtime";
2
- import * as U from "react";
3
- import it, { useContext as at, useState as L, useMemo as b, lazy as y, useRef as k, useEffect as ct } from "react";
4
- const tt = it.createContext({}), I = () => at(tt), C = {
2
+ import * as D from "react";
3
+ import at, { useContext as ct, useState as L, useMemo as S, lazy as w, useRef as z, useEffect as H } from "react";
4
+ const et = at.createContext({}), R = () => ct(et), C = {
5
5
  zoom: 14,
6
6
  pitch: 0,
7
7
  bearing: 0,
@@ -10,61 +10,66 @@ const tt = it.createContext({}), I = () => at(tt), C = {
10
10
  maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
11
11
  mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
12
12
  google: "a7ff20eb973126bb"
13
- }, H = 13, ut = 22, Vt = 12.5, pt = 30, ht = 60, lt = "w-full h-full relative overflow-hidden", ft = y(() => import("./index-BpFpg_5A.js")), dt = y(() => import("./index-CceEGv05.js")), mt = y(() => import("./index-arkRlpaR.js")), gt = y(() => import("./index-qqbvBkdn.js")), yt = ({ padding: r = 1e-3, children: t }) => {
13
+ }, ut = {
14
+ top: 10,
15
+ bottom: 10,
16
+ left: 10,
17
+ right: 10
18
+ }, J = 13, pt = 22, Jt = 12.5, ht = 30, lt = 60, Wt = 15, ft = [-180, -85.0511, 180, 85.0511], dt = "w-full h-full relative overflow-hidden", mt = w(() => import("./index-BOZt1-DO.js")), gt = w(() => import("./index-CUvZ7gVt.js")), yt = w(() => import("./index-DJx0avMT.js")), wt = w(() => import("./index-qqbvBkdn.js")), Mt = ({ children: r }) => {
14
19
  const {
15
- mapProvider: e,
16
- center: n,
17
- zoom: o = C.zoom,
18
- pitch: i = C.pitch,
19
- bearing: a = C.bearing,
20
- cooperativeGestures: c = C.cooperativeGestures,
21
- zoomPosition: s
22
- } = I(), [p] = L(o), h = b(() => {
23
- switch (e?.name) {
20
+ mapProvider: t,
21
+ center: e,
22
+ zoom: n = C.zoom,
23
+ pitch: o = C.pitch,
24
+ bearing: i = C.bearing,
25
+ cooperativeGestures: a = C.cooperativeGestures,
26
+ zoomPosition: c
27
+ } = R(), [s] = L(n), h = S(() => {
28
+ switch (t?.name) {
24
29
  case "maptiler":
25
- return ft;
30
+ return mt;
26
31
  case "google":
27
- return dt;
32
+ return gt;
28
33
  case "mapbox":
29
- return mt;
34
+ return yt;
30
35
  default:
31
- return gt;
36
+ return wt;
32
37
  }
33
- }, [e]);
38
+ }, [t]);
34
39
  return /* @__PURE__ */ O(
35
40
  "div",
36
41
  {
37
- className: lt,
42
+ className: dt,
38
43
  "data-testid": "base-map",
39
- "data-map-provider-name": e?.name,
40
- "data-map-provider-theme": e?.theme || V[e?.name] || V.maptiler,
41
- "data-initial-zoom": p,
42
- "data-pitch": i,
43
- "data-bearing": a,
44
- "data-cooperative-gestures": c,
45
- "data-zoom-position": s,
46
- "data-center-latitude": n.latitude,
47
- "data-center-longitude": n.longitude,
48
- children: /* @__PURE__ */ O(h, { padding: r, children: t })
44
+ "data-map-provider-name": t?.name,
45
+ "data-map-provider-theme": t?.theme || V[t?.name] || V.maptiler,
46
+ "data-initial-zoom": s,
47
+ "data-pitch": o,
48
+ "data-bearing": i,
49
+ "data-cooperative-gestures": a,
50
+ "data-zoom-position": c,
51
+ "data-center-latitude": e.latitude,
52
+ "data-center-longitude": e.longitude,
53
+ children: /* @__PURE__ */ O(h, { children: r })
49
54
  }
50
55
  );
51
- }, wt = y(() => import("./index-vHMPqmOL.js")), Mt = y(() => import("./index-DNNz78Rc.js")), _t = y(() => import("./index-CiWKwaC4.js"));
52
- function At(r) {
53
- const { mapProvider: t } = I(), e = b(() => {
56
+ }, _t = w(() => import("./index-C3Tj3r2u.js")), Pt = w(() => import("./index-CUUravWc.js")), At = w(() => import("./index-eWv3le07.js"));
57
+ function Et(r) {
58
+ const { mapProvider: t } = R(), e = S(() => {
54
59
  switch (t?.name) {
55
60
  case "maptiler":
56
- return wt;
61
+ return _t;
57
62
  case "google":
58
- return Mt;
63
+ return Pt;
59
64
  case "mapbox":
60
- return _t;
65
+ return At;
61
66
  default:
62
67
  return null;
63
68
  }
64
69
  }, [t]);
65
70
  return e ? /* @__PURE__ */ O(e, { ...r }) : null;
66
71
  }
67
- function et(r, t, e = {}) {
72
+ function nt(r, t, e = {}) {
68
73
  const n = { type: "Feature" };
69
74
  return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
70
75
  }
@@ -75,23 +80,23 @@ function xt(r, t, e = {}) {
75
80
  throw new Error("coordinates must be an Array");
76
81
  if (r.length < 2)
77
82
  throw new Error("coordinates must be at least 2 numbers long");
78
- if (!Y(r[0]) || !Y(r[1]))
83
+ if (!W(r[0]) || !W(r[1]))
79
84
  throw new Error("coordinates must contain numbers");
80
- return et({
85
+ return nt({
81
86
  type: "Point",
82
87
  coordinates: r
83
88
  }, t, e);
84
89
  }
85
- function Ht(r, t, e = {}) {
86
- return et({
90
+ function Yt(r, t, e = {}) {
91
+ return nt({
87
92
  type: "MultiPoint",
88
93
  coordinates: r
89
94
  }, t, e);
90
95
  }
91
- function Y(r) {
96
+ function W(r) {
92
97
  return !isNaN(r) && r !== null && !Array.isArray(r);
93
98
  }
94
- const J = [
99
+ const Y = [
95
100
  Int8Array,
96
101
  Uint8Array,
97
102
  Uint8ClampedArray,
@@ -102,7 +107,7 @@ const J = [
102
107
  Float32Array,
103
108
  Float64Array
104
109
  ], F = 1, T = 8;
105
- class j {
110
+ class G {
106
111
  /**
107
112
  * Creates an index from raw `ArrayBuffer` data.
108
113
  * @param {ArrayBuffer} data
@@ -116,11 +121,11 @@ class j {
116
121
  const o = n >> 4;
117
122
  if (o !== F)
118
123
  throw new Error(`Got v${o} data when expected v${F}.`);
119
- const i = J[n & 15];
124
+ const i = Y[n & 15];
120
125
  if (!i)
121
126
  throw new Error("Unrecognized array type.");
122
127
  const [a] = new Uint16Array(t, 2, 1), [c] = new Uint32Array(t, 4, 1);
123
- return new j(c, a, i, t);
128
+ return new G(c, a, i, t);
124
129
  }
125
130
  /**
126
131
  * Creates an index that will hold a given number of items.
@@ -132,7 +137,7 @@ class j {
132
137
  constructor(t, e = 64, n = Float64Array, o) {
133
138
  if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
134
139
  this.numItems = +t, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.ArrayType = n, this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array;
135
- const i = J.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, c = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - c % 8) % 8;
140
+ const i = Y.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, c = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - c % 8) % 8;
136
141
  if (i < 0)
137
142
  throw new Error(`Unexpected typed array class: ${n}.`);
138
143
  o && o instanceof ArrayBuffer ? (this.data = o, this.ids = new this.IndexArrayType(this.data, T, t), this.coords = new this.ArrayType(this.data, T + c + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(T + a + c + s), this.ids = new this.IndexArrayType(this.data, T, t), this.coords = new this.ArrayType(this.data, T + c + s, t * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (F << 4) + i]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = t);
@@ -154,7 +159,7 @@ class j {
154
159
  const t = this._pos >> 1;
155
160
  if (t !== this.numItems)
156
161
  throw new Error(`Added ${t} items when expected ${this.numItems}.`);
157
- return N(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
162
+ return j(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
158
163
  }
159
164
  /**
160
165
  * Search the index for items within a given bounding box.
@@ -166,20 +171,20 @@ class j {
166
171
  */
167
172
  range(t, e, n, o) {
168
173
  if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
169
- const { ids: i, coords: a, nodeSize: c } = this, s = [0, i.length - 1, 0], p = [];
174
+ const { ids: i, coords: a, nodeSize: c } = this, s = [0, i.length - 1, 0], h = [];
170
175
  for (; s.length; ) {
171
- const h = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
176
+ const l = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
172
177
  if (u - f <= c) {
173
- for (let m = f; m <= u; m++) {
174
- const w = a[2 * m], M = a[2 * m + 1];
175
- w >= t && w <= n && M >= e && M <= o && p.push(i[m]);
178
+ for (let p = f; p <= u; p++) {
179
+ const m = a[2 * p], M = a[2 * p + 1];
180
+ m >= t && m <= n && M >= e && M <= o && h.push(i[p]);
176
181
  }
177
182
  continue;
178
183
  }
179
- const d = f + u >> 1, g = a[2 * d], l = a[2 * d + 1];
180
- g >= t && g <= n && l >= e && l <= o && p.push(i[d]), (h === 0 ? t <= g : e <= l) && (s.push(f), s.push(d - 1), s.push(1 - h)), (h === 0 ? n >= g : o >= l) && (s.push(d + 1), s.push(u), s.push(1 - h));
184
+ const d = f + u >> 1, g = a[2 * d], y = a[2 * d + 1];
185
+ g >= t && g <= n && y >= e && y <= o && h.push(i[d]), (l === 0 ? t <= g : e <= y) && (s.push(f), s.push(d - 1), s.push(1 - l)), (l === 0 ? n >= g : o >= y) && (s.push(d + 1), s.push(u), s.push(1 - l));
181
186
  }
182
- return p;
187
+ return h;
183
188
  }
184
189
  /**
185
190
  * Search the index for items within a given radius.
@@ -190,44 +195,44 @@ class j {
190
195
  */
191
196
  within(t, e, n) {
192
197
  if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
193
- const { ids: o, coords: i, nodeSize: a } = this, c = [0, o.length - 1, 0], s = [], p = n * n;
198
+ const { ids: o, coords: i, nodeSize: a } = this, c = [0, o.length - 1, 0], s = [], h = n * n;
194
199
  for (; c.length; ) {
195
- const h = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
200
+ const l = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
196
201
  if (u - f <= a) {
197
- for (let m = f; m <= u; m++)
198
- K(i[2 * m], i[2 * m + 1], t, e) <= p && s.push(o[m]);
202
+ for (let p = f; p <= u; p++)
203
+ K(i[2 * p], i[2 * p + 1], t, e) <= h && s.push(o[p]);
199
204
  continue;
200
205
  }
201
- const d = f + u >> 1, g = i[2 * d], l = i[2 * d + 1];
202
- K(g, l, t, e) <= p && s.push(o[d]), (h === 0 ? t - n <= g : e - n <= l) && (c.push(f), c.push(d - 1), c.push(1 - h)), (h === 0 ? t + n >= g : e + n >= l) && (c.push(d + 1), c.push(u), c.push(1 - h));
206
+ const d = f + u >> 1, g = i[2 * d], y = i[2 * d + 1];
207
+ K(g, y, t, e) <= h && s.push(o[d]), (l === 0 ? t - n <= g : e - n <= y) && (c.push(f), c.push(d - 1), c.push(1 - l)), (l === 0 ? t + n >= g : e + n >= y) && (c.push(d + 1), c.push(u), c.push(1 - l));
203
208
  }
204
209
  return s;
205
210
  }
206
211
  }
207
- function N(r, t, e, n, o, i) {
212
+ function j(r, t, e, n, o, i) {
208
213
  if (o - n <= e) return;
209
214
  const a = n + o >> 1;
210
- nt(r, t, a, n, o, i), N(r, t, e, n, a - 1, 1 - i), N(r, t, e, a + 1, o, 1 - i);
215
+ rt(r, t, a, n, o, i), j(r, t, e, n, a - 1, 1 - i), j(r, t, e, a + 1, o, 1 - i);
211
216
  }
212
- function nt(r, t, e, n, o, i) {
217
+ function rt(r, t, e, n, o, i) {
213
218
  for (; o > n; ) {
214
219
  if (o - n > 600) {
215
- const p = o - n + 1, h = e - n + 1, u = Math.log(p), f = 0.5 * Math.exp(2 * u / 3), d = 0.5 * Math.sqrt(u * f * (p - f) / p) * (h - p / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - h * f / p + d)), l = Math.min(o, Math.floor(e + (p - h) * f / p + d));
216
- nt(r, t, e, g, l, i);
220
+ const h = o - n + 1, l = e - n + 1, u = Math.log(h), f = 0.5 * Math.exp(2 * u / 3), d = 0.5 * Math.sqrt(u * f * (h - f) / h) * (l - h / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - l * f / h + d)), y = Math.min(o, Math.floor(e + (h - l) * f / h + d));
221
+ rt(r, t, e, g, y, i);
217
222
  }
218
223
  const a = t[2 * e + i];
219
224
  let c = n, s = o;
220
- for (S(r, t, n, e), t[2 * o + i] > a && S(r, t, n, o); c < s; ) {
221
- for (S(r, t, c, s), c++, s--; t[2 * c + i] < a; ) c++;
225
+ for (b(r, t, n, e), t[2 * o + i] > a && b(r, t, n, o); c < s; ) {
226
+ for (b(r, t, c, s), c++, s--; t[2 * c + i] < a; ) c++;
222
227
  for (; t[2 * s + i] > a; ) s--;
223
228
  }
224
- t[2 * n + i] === a ? S(r, t, n, s) : (s++, S(r, t, s, o)), s <= e && (n = s + 1), e <= s && (o = s - 1);
229
+ t[2 * n + i] === a ? b(r, t, n, s) : (s++, b(r, t, s, o)), s <= e && (n = s + 1), e <= s && (o = s - 1);
225
230
  }
226
231
  }
227
- function S(r, t, e, n) {
228
- z(r, e, n), z(t, 2 * e, 2 * n), z(t, 2 * e + 1, 2 * n + 1);
232
+ function b(r, t, e, n) {
233
+ B(r, e, n), B(t, 2 * e, 2 * n), B(t, 2 * e + 1, 2 * n + 1);
229
234
  }
230
- function z(r, t, e) {
235
+ function B(r, t, e) {
231
236
  const n = r[t];
232
237
  r[t] = r[e], r[e] = n;
233
238
  }
@@ -235,7 +240,7 @@ function K(r, t, e, n) {
235
240
  const o = r - e, i = t - n;
236
241
  return o * o + i * i;
237
242
  }
238
- const Et = {
243
+ const vt = {
239
244
  minZoom: 0,
240
245
  // min zoom to generate clusters on
241
246
  maxZoom: 16,
@@ -258,10 +263,10 @@ const Et = {
258
263
  // properties to use for individual points when running the reducer
259
264
  map: (r) => r
260
265
  // props => ({sum: props.my_value})
261
- }, q = Math.fround || /* @__PURE__ */ ((r) => (t) => (r[0] = +t, r[0]))(new Float32Array(1)), P = 2, x = 3, D = 4, A = 5, rt = 6;
262
- class Pt {
266
+ }, q = Math.fround || /* @__PURE__ */ ((r) => (t) => (r[0] = +t, r[0]))(new Float32Array(1)), x = 2, A = 3, N = 4, P = 5, st = 6;
267
+ class Ot {
263
268
  constructor(t) {
264
- this.options = Object.assign(Object.create(Et), t), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
269
+ this.options = Object.assign(Object.create(vt), t), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
265
270
  }
266
271
  load(t) {
267
272
  const { log: e, minZoom: n, maxZoom: o } = this.options;
@@ -270,9 +275,9 @@ class Pt {
270
275
  e && console.time(i), this.points = t;
271
276
  const a = [];
272
277
  for (let s = 0; s < t.length; s++) {
273
- const p = t[s];
274
- if (!p.geometry) continue;
275
- const [h, u] = p.geometry.coordinates, f = q(R(h)), d = q(Z(u));
278
+ const h = t[s];
279
+ if (!h.geometry) continue;
280
+ const [l, u] = h.geometry.coordinates, f = q(I(l)), d = q(U(u));
276
281
  a.push(
277
282
  f,
278
283
  d,
@@ -290,8 +295,8 @@ class Pt {
290
295
  let c = this.trees[o + 1] = this._createTree(a);
291
296
  e && console.timeEnd(i);
292
297
  for (let s = o; s >= n; s--) {
293
- const p = +Date.now();
294
- c = this.trees[s] = this._createTree(this._cluster(c, s)), e && console.log("z%d: %d clusters in %dms", s, c.numItems, +Date.now() - p);
298
+ const h = +Date.now();
299
+ c = this.trees[s] = this._createTree(this._cluster(c, s)), e && console.log("z%d: %d clusters in %dms", s, c.numItems, +Date.now() - h);
295
300
  }
296
301
  return e && console.timeEnd("total time"), this;
297
302
  }
@@ -306,22 +311,22 @@ class Pt {
306
311
  const u = this.getClusters([n, o, 180, a], e), f = this.getClusters([-180, o, i, a], e);
307
312
  return u.concat(f);
308
313
  }
309
- const c = this.trees[this._limitZoom(e)], s = c.range(R(n), Z(a), R(i), Z(o)), p = c.data, h = [];
314
+ const c = this.trees[this._limitZoom(e)], s = c.range(I(n), U(a), I(i), U(o)), h = c.data, l = [];
310
315
  for (const u of s) {
311
316
  const f = this.stride * u;
312
- h.push(p[f + A] > 1 ? Q(p, f, this.clusterProps) : this.points[p[f + x]]);
317
+ l.push(h[f + P] > 1 ? Q(h, f, this.clusterProps) : this.points[h[f + A]]);
313
318
  }
314
- return h;
319
+ return l;
315
320
  }
316
321
  getChildren(t) {
317
322
  const e = this._getOriginId(t), n = this._getOriginZoom(t), o = "No cluster with the specified id.", i = this.trees[n];
318
323
  if (!i) throw new Error(o);
319
324
  const a = i.data;
320
325
  if (e * this.stride >= a.length) throw new Error(o);
321
- const c = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), s = a[e * this.stride], p = a[e * this.stride + 1], h = i.within(s, p, c), u = [];
322
- for (const f of h) {
326
+ const c = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), s = a[e * this.stride], h = a[e * this.stride + 1], l = i.within(s, h, c), u = [];
327
+ for (const f of l) {
323
328
  const d = f * this.stride;
324
- a[d + D] === t && u.push(a[d + A] > 1 ? Q(a, d, this.clusterProps) : this.points[a[d + x]]);
329
+ a[d + N] === t && u.push(a[d + P] > 1 ? Q(a, d, this.clusterProps) : this.points[a[d + A]]);
325
330
  }
326
331
  if (u.length === 0) throw new Error(o);
327
332
  return u;
@@ -332,25 +337,25 @@ class Pt {
332
337
  return this._appendLeaves(o, t, e, n, 0), o;
333
338
  }
334
339
  getTile(t, e, n) {
335
- const o = this.trees[this._limitZoom(t)], i = Math.pow(2, t), { extent: a, radius: c } = this.options, s = c / a, p = (n - s) / i, h = (n + 1 + s) / i, u = {
340
+ const o = this.trees[this._limitZoom(t)], i = Math.pow(2, t), { extent: a, radius: c } = this.options, s = c / a, h = (n - s) / i, l = (n + 1 + s) / i, u = {
336
341
  features: []
337
342
  };
338
343
  return this._addTileFeatures(
339
- o.range((e - s) / i, p, (e + 1 + s) / i, h),
344
+ o.range((e - s) / i, h, (e + 1 + s) / i, l),
340
345
  o.data,
341
346
  e,
342
347
  n,
343
348
  i,
344
349
  u
345
350
  ), e === 0 && this._addTileFeatures(
346
- o.range(1 - s / i, p, 1, h),
351
+ o.range(1 - s / i, h, 1, l),
347
352
  o.data,
348
353
  i,
349
354
  n,
350
355
  i,
351
356
  u
352
357
  ), e === i - 1 && this._addTileFeatures(
353
- o.range(0, p, s / i, h),
358
+ o.range(0, h, s / i, l),
354
359
  o.data,
355
360
  -1,
356
361
  n,
@@ -376,21 +381,21 @@ class Pt {
376
381
  return i;
377
382
  }
378
383
  _createTree(t) {
379
- const e = new j(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
384
+ const e = new G(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
380
385
  for (let n = 0; n < t.length; n += this.stride) e.add(t[n], t[n + 1]);
381
386
  return e.finish(), e.data = t, e;
382
387
  }
383
388
  _addTileFeatures(t, e, n, o, i, a) {
384
389
  for (const c of t) {
385
- const s = c * this.stride, p = e[s + A] > 1;
386
- let h, u, f;
387
- if (p)
388
- h = st(e, s, this.clusterProps), u = e[s], f = e[s + 1];
390
+ const s = c * this.stride, h = e[s + P] > 1;
391
+ let l, u, f;
392
+ if (h)
393
+ l = ot(e, s, this.clusterProps), u = e[s], f = e[s + 1];
389
394
  else {
390
- const l = this.points[e[s + x]];
391
- h = l.properties;
392
- const [m, w] = l.geometry.coordinates;
393
- u = R(m), f = Z(w);
395
+ const y = this.points[e[s + A]];
396
+ l = y.properties;
397
+ const [p, m] = y.geometry.coordinates;
398
+ u = I(p), f = U(m);
394
399
  }
395
400
  const d = {
396
401
  type: 1,
@@ -398,50 +403,50 @@ class Pt {
398
403
  Math.round(this.options.extent * (u * i - n)),
399
404
  Math.round(this.options.extent * (f * i - o))
400
405
  ]],
401
- tags: h
406
+ tags: l
402
407
  };
403
408
  let g;
404
- p || this.options.generateId ? g = e[s + x] : g = this.points[e[s + x]].id, g !== void 0 && (d.id = g), a.features.push(d);
409
+ h || this.options.generateId ? g = e[s + A] : g = this.points[e[s + A]].id, g !== void 0 && (d.id = g), a.features.push(d);
405
410
  }
406
411
  }
407
412
  _limitZoom(t) {
408
413
  return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
409
414
  }
410
415
  _cluster(t, e) {
411
- const { radius: n, extent: o, reduce: i, minPoints: a } = this.options, c = n / (o * Math.pow(2, e)), s = t.data, p = [], h = this.stride;
412
- for (let u = 0; u < s.length; u += h) {
413
- if (s[u + P] <= e) continue;
414
- s[u + P] = e;
415
- const f = s[u], d = s[u + 1], g = t.within(s[u], s[u + 1], c), l = s[u + A];
416
- let m = l;
417
- for (const w of g) {
418
- const M = w * h;
419
- s[M + P] > e && (m += s[M + A]);
416
+ const { radius: n, extent: o, reduce: i, minPoints: a } = this.options, c = n / (o * Math.pow(2, e)), s = t.data, h = [], l = this.stride;
417
+ for (let u = 0; u < s.length; u += l) {
418
+ if (s[u + x] <= e) continue;
419
+ s[u + x] = e;
420
+ const f = s[u], d = s[u + 1], g = t.within(s[u], s[u + 1], c), y = s[u + P];
421
+ let p = y;
422
+ for (const m of g) {
423
+ const M = m * l;
424
+ s[M + x] > e && (p += s[M + P]);
420
425
  }
421
- if (m > l && m >= a) {
422
- let w = f * l, M = d * l, _, G = -1;
423
- const B = ((u / h | 0) << 5) + (e + 1) + this.points.length;
424
- for (const ot of g) {
425
- const E = ot * h;
426
- if (s[E + P] <= e) continue;
427
- s[E + P] = e;
428
- const $ = s[E + A];
429
- w += s[E] * $, M += s[E + 1] * $, s[E + D] = B, i && (_ || (_ = this._map(s, u, !0), G = this.clusterProps.length, this.clusterProps.push(_)), i(_, this._map(s, E)));
426
+ if (p > y && p >= a) {
427
+ let m = f * y, M = d * y, _, $ = -1;
428
+ const Z = ((u / l | 0) << 5) + (e + 1) + this.points.length;
429
+ for (const it of g) {
430
+ const E = it * l;
431
+ if (s[E + x] <= e) continue;
432
+ s[E + x] = e;
433
+ const k = s[E + P];
434
+ m += s[E] * k, M += s[E + 1] * k, s[E + N] = Z, i && (_ || (_ = this._map(s, u, !0), $ = this.clusterProps.length, this.clusterProps.push(_)), i(_, this._map(s, E)));
430
435
  }
431
- s[u + D] = B, p.push(w / m, M / m, 1 / 0, B, -1, m), i && p.push(G);
436
+ s[u + N] = Z, h.push(m / p, M / p, 1 / 0, Z, -1, p), i && h.push($);
432
437
  } else {
433
- for (let w = 0; w < h; w++) p.push(s[u + w]);
434
- if (m > 1)
435
- for (const w of g) {
436
- const M = w * h;
437
- if (!(s[M + P] <= e)) {
438
- s[M + P] = e;
439
- for (let _ = 0; _ < h; _++) p.push(s[M + _]);
438
+ for (let m = 0; m < l; m++) h.push(s[u + m]);
439
+ if (p > 1)
440
+ for (const m of g) {
441
+ const M = m * l;
442
+ if (!(s[M + x] <= e)) {
443
+ s[M + x] = e;
444
+ for (let _ = 0; _ < l; _++) h.push(s[M + _]);
440
445
  }
441
446
  }
442
447
  }
443
448
  }
444
- return p;
449
+ return h;
445
450
  }
446
451
  // get index of the point from which the cluster originated
447
452
  _getOriginId(t) {
@@ -452,50 +457,50 @@ class Pt {
452
457
  return (t - this.points.length) % 32;
453
458
  }
454
459
  _map(t, e, n) {
455
- if (t[e + A] > 1) {
456
- const a = this.clusterProps[t[e + rt]];
460
+ if (t[e + P] > 1) {
461
+ const a = this.clusterProps[t[e + st]];
457
462
  return n ? Object.assign({}, a) : a;
458
463
  }
459
- const o = this.points[t[e + x]].properties, i = this.options.map(o);
464
+ const o = this.points[t[e + A]].properties, i = this.options.map(o);
460
465
  return n && i === o ? Object.assign({}, i) : i;
461
466
  }
462
467
  }
463
468
  function Q(r, t, e) {
464
469
  return {
465
470
  type: "Feature",
466
- id: r[t + x],
467
- properties: st(r, t, e),
471
+ id: r[t + A],
472
+ properties: ot(r, t, e),
468
473
  geometry: {
469
474
  type: "Point",
470
- coordinates: [vt(r[t]), Ot(r[t + 1])]
475
+ coordinates: [St(r[t]), Tt(r[t + 1])]
471
476
  }
472
477
  };
473
478
  }
474
- function st(r, t, e) {
475
- const n = r[t + A], o = n >= 1e4 ? `${Math.round(n / 1e3)}k` : n >= 1e3 ? `${Math.round(n / 100) / 10}k` : n, i = r[t + rt], a = i === -1 ? {} : Object.assign({}, e[i]);
479
+ function ot(r, t, e) {
480
+ const n = r[t + P], o = n >= 1e4 ? `${Math.round(n / 1e3)}k` : n >= 1e3 ? `${Math.round(n / 100) / 10}k` : n, i = r[t + st], a = i === -1 ? {} : Object.assign({}, e[i]);
476
481
  return Object.assign(a, {
477
482
  cluster: !0,
478
- cluster_id: r[t + x],
483
+ cluster_id: r[t + A],
479
484
  point_count: n,
480
485
  point_count_abbreviated: o
481
486
  });
482
487
  }
483
- function R(r) {
488
+ function I(r) {
484
489
  return r / 360 + 0.5;
485
490
  }
486
- function Z(r) {
491
+ function U(r) {
487
492
  const t = Math.sin(r * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
488
493
  return e < 0 ? 0 : e > 1 ? 1 : e;
489
494
  }
490
- function vt(r) {
495
+ function St(r) {
491
496
  return (r - 0.5) * 360;
492
497
  }
493
- function Ot(r) {
498
+ function Tt(r) {
494
499
  const t = (180 - r * 360) * Math.PI / 180;
495
500
  return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
496
501
  }
497
- var W = Object.prototype.hasOwnProperty;
498
- function X(r, t, e) {
502
+ var X = Object.prototype.hasOwnProperty;
503
+ function tt(r, t, e) {
499
504
  for (e of r.keys())
500
505
  if (v(e, t)) return e;
501
506
  }
@@ -514,14 +519,14 @@ function v(r, t) {
514
519
  if (r.size !== t.size)
515
520
  return !1;
516
521
  for (n of r)
517
- if (o = n, o && typeof o == "object" && (o = X(t, o), !o) || !t.has(o)) return !1;
522
+ if (o = n, o && typeof o == "object" && (o = tt(t, o), !o) || !t.has(o)) return !1;
518
523
  return !0;
519
524
  }
520
525
  if (e === Map) {
521
526
  if (r.size !== t.size)
522
527
  return !1;
523
528
  for (n of r)
524
- if (o = n[0], o && typeof o == "object" && (o = X(t, o), !o) || !v(n[1], t.get(o)))
529
+ if (o = n[0], o && typeof o == "object" && (o = tt(t, o), !o) || !v(n[1], t.get(o)))
525
530
  return !1;
526
531
  return !0;
527
532
  }
@@ -540,99 +545,110 @@ function v(r, t) {
540
545
  if (!e || typeof r == "object") {
541
546
  n = 0;
542
547
  for (e in r)
543
- if (W.call(r, e) && ++n && !W.call(t, e) || !(e in t) || !v(r[e], t[e])) return !1;
548
+ if (X.call(r, e) && ++n && !X.call(t, e) || !(e in t) || !v(r[e], t[e])) return !1;
544
549
  return Object.keys(t).length === n;
545
550
  }
546
551
  }
547
552
  return r !== r && t !== t;
548
553
  }
549
554
  function bt(r) {
550
- var t = U.useRef(r), e = U.useRef(0);
551
- return v(r, t.current) || (t.current = r, e.current += 1), U.useMemo(function() {
555
+ var t = D.useRef(r), e = D.useRef(0);
556
+ return v(r, t.current) || (t.current = r, e.current += 1), D.useMemo(function() {
552
557
  return t.current;
553
558
  }, [e.current]);
554
559
  }
555
- function Tt(r, t) {
556
- return U.useEffect(r, bt(t));
560
+ function Ct(r, t) {
561
+ return D.useEffect(r, bt(t));
557
562
  }
558
- var St = function(t) {
559
- var e = t.points, n = t.bounds, o = t.zoom, i = t.options, a = t.disableRefresh, c = k(), s = k(), p = L([]), h = p[0], u = p[1], f = Math.round(o);
560
- return Tt(function() {
561
- a !== !0 && ((!c.current || !v(s.current, e) || !v(c.current.options, i)) && (c.current = new Pt(i), c.current.load(e)), n && u(c.current.getClusters(n, f)), s.current = e);
563
+ var Lt = function(t) {
564
+ var e = t.points, n = t.bounds, o = t.zoom, i = t.options, a = t.disableRefresh, c = z(), s = z(), h = L([]), l = h[0], u = h[1], f = Math.round(o);
565
+ return Ct(function() {
566
+ a !== !0 && ((!c.current || !v(s.current, e) || !v(c.current.options, i)) && (c.current = new Ot(i), c.current.load(e)), n && u(c.current.getClusters(n, f)), s.current = e);
562
567
  }, [e, n, f, i, a]), {
563
- clusters: h,
568
+ clusters: l,
564
569
  supercluster: c.current
565
570
  };
566
571
  };
567
- const Ct = y(() => import("./index-BrxP9NHZ.js")), Lt = y(() => import("./index-ufLC1PLO.js")), It = y(() => import("./index-B85VZGVP.js"));
568
- function Rt({ markers: r, onClick: t, ...e }) {
569
- const { mapProvider: n, activeMarker: o, center: i, bounds: a, zoom: c, setMarkerPoints: s } = I();
570
- ct(() => {
571
- let l = [[i.latitude, i.longitude]];
572
- r.length > 0 && (l = l.concat(
573
- r.map((m) => [m.latitude, m.longitude])
574
- )), s(l);
572
+ const Rt = w(() => import("./index-Buv9_Jj9.js")), It = w(() => import("./index-DbyYOXrb.js")), Ut = w(() => import("./index-DOkeQ2e4.js"));
573
+ function Dt({ markers: r, onClick: t, ...e }) {
574
+ const { mapProvider: n, activeMarker: o, center: i, zoom: a, setMarkerPoints: c, setClusterPoints: s } = R();
575
+ H(() => {
576
+ let p = [[i.longitude, i.latitude]];
577
+ r.length > 0 && (p = p.concat(
578
+ r.map((m) => [m.longitude, m.latitude])
579
+ )), c(p);
575
580
  }, [r, i]);
576
- const p = b(
581
+ const h = S(
577
582
  () => ({
578
- points: r.map((l) => xt([l.longitude, l.latitude], l)),
579
- bounds: a,
580
- zoom: c,
583
+ points: r.map((p) => xt([p.longitude, p.latitude], p)),
584
+ // Using world bounds to avoid issues with markers near the edges of the map
585
+ bounds: ft,
586
+ zoom: a,
581
587
  options: {
582
- radius: n.name === "google" && c > H ? ht : pt,
583
- minZoom: H,
584
- maxZoom: ut
588
+ radius: n.name === "google" && a > J ? lt : ht,
589
+ minZoom: J,
590
+ maxZoom: pt
585
591
  }
586
592
  }),
587
- [r, n, a, c]
588
- ), { clusters: h, supercluster: u } = St(p), f = (l) => {
589
- if (!("properties" in l))
593
+ [r, n, a]
594
+ ), { clusters: l, supercluster: u } = Lt(h), f = z("");
595
+ H(() => {
596
+ const p = JSON.stringify(
597
+ l.map((m) => ({
598
+ coords: m.geometry.coordinates,
599
+ props: m.properties
600
+ }))
601
+ );
602
+ p !== f.current && (s(l), f.current = p);
603
+ }, [l, s]);
604
+ const d = (p) => {
605
+ if (!("properties" in p))
590
606
  throw new Error("Cluster does not have properties");
591
- if (l.properties?.cluster && typeof l.properties?.cluster_id == "number") {
607
+ if (p.properties?.cluster && typeof p.properties?.cluster_id == "number") {
592
608
  t?.({
593
- id: `${l.properties.cluster_id}`,
594
- latitude: l.geometry.coordinates[1],
595
- longitude: l.geometry.coordinates[0],
596
- markers: u?.getLeaves(l.properties.cluster_id)?.map((m) => m.properties) ?? []
609
+ id: `${p.properties.cluster_id}`,
610
+ latitude: p.geometry.coordinates[1],
611
+ longitude: p.geometry.coordinates[0],
612
+ markers: u?.getLeaves(p.properties.cluster_id)?.map((m) => m.properties) ?? []
597
613
  });
598
614
  return;
599
615
  }
600
616
  t?.({
601
- id: l.properties.id,
602
- latitude: l.properties.latitude,
603
- longitude: l.properties.longitude,
604
- markers: [l.properties]
617
+ id: p.properties.id,
618
+ latitude: p.properties.latitude,
619
+ longitude: p.properties.longitude,
620
+ markers: [p.properties]
605
621
  });
606
- }, d = (l) => !u || !o ? !1 : o.id === `${l}` ? !0 : u.getLeaves(l)?.find((m) => m.properties.id === o.id) !== void 0, g = b(() => {
622
+ }, g = (p) => !u || !o ? !1 : o.id === `${p}` ? !0 : u.getLeaves(p)?.find((m) => m.properties.id === o.id) !== void 0, y = S(() => {
607
623
  switch (n?.name) {
608
624
  case "maptiler":
609
- return Ct;
625
+ return Rt;
610
626
  case "google":
611
- return Lt;
612
- case "mapbox":
613
627
  return It;
628
+ case "mapbox":
629
+ return Ut;
614
630
  default:
615
631
  return null;
616
632
  }
617
633
  }, [n]);
618
- return g ? /* @__PURE__ */ O(
619
- g,
634
+ return y ? /* @__PURE__ */ O(
635
+ y,
620
636
  {
621
- clusters: h,
622
- onClick: f,
623
- doesSuperclusterContainActiveMarker: d,
637
+ clusters: l,
638
+ onClick: d,
639
+ doesSuperclusterContainActiveMarker: g,
624
640
  ...e
625
641
  }
626
642
  ) : null;
627
643
  }
628
- const Zt = y(() => import("./index-CRdDPWou.js")), Ut = y(() => import("./index-D5kHxP9H.js")), Bt = y(() => import("./index-Db33Ugg9.js"));
629
- function Ft({ children: r, anchor: t = "bottom", ...e }) {
630
- const { mapProvider: n } = I(), o = b(() => {
644
+ const Zt = w(() => import("./index-CCS3Ef2w.js")), Ft = w(() => import("./index-C6a0FCIX.js")), Bt = w(() => import("./index-Y5T20C1G.js"));
645
+ function Nt({ children: r, anchor: t = "bottom", ...e }) {
646
+ const { mapProvider: n } = R(), o = S(() => {
631
647
  switch (n?.name) {
632
648
  case "maptiler":
633
649
  return Zt;
634
650
  case "google":
635
- return Ut;
651
+ return Ft;
636
652
  case "mapbox":
637
653
  return Bt;
638
654
  default:
@@ -641,46 +657,58 @@ function Ft({ children: r, anchor: t = "bottom", ...e }) {
641
657
  }, [n]);
642
658
  return o ? /* @__PURE__ */ O(o, { ...e, anchor: t, children: r }) : null;
643
659
  }
644
- const zt = y(() => import("./index-DfhwDiOS.js")), Dt = y(() => import("./index-CSVsF1EQ.js")), Nt = y(() => import("./index-BRD3rjLE.js"));
645
- function jt(r) {
646
- const { mapProvider: t } = I(), e = b(() => {
660
+ const zt = w(() => import("./index-GGtrKiJn.js")), jt = w(() => import("./index-CEDpofgZ.js")), Gt = w(() => import("./index-CIE9YlvM.js"));
661
+ function $t(r) {
662
+ const { mapProvider: t } = R(), e = S(() => {
647
663
  switch (t?.name) {
648
664
  case "maptiler":
649
665
  return zt;
650
666
  case "google":
651
- return Dt;
667
+ return jt;
652
668
  case "mapbox":
653
- return Nt;
669
+ return Gt;
654
670
  default:
655
671
  return null;
656
672
  }
657
673
  }, [t]);
658
674
  return e ? /* @__PURE__ */ O(e, { ...r }) : null;
659
675
  }
660
- function Gt(r) {
661
- const [t, e] = L([]), [n, o] = L(r.zoom || C.zoom), [i, a] = L();
676
+ function kt(r) {
677
+ const [t, e] = L([]), [n, o] = L([]), [i, a] = L(r.zoom || C.zoom);
662
678
  return /* @__PURE__ */ O(
663
- tt.Provider,
679
+ et.Provider,
664
680
  {
665
- value: { ...r, markerPoints: t, setMarkerPoints: e, bounds: i, setBounds: a, zoom: n, setZoom: o },
681
+ value: {
682
+ ...r,
683
+ mapPadding: r.mapPadding || ut,
684
+ markerPoints: t,
685
+ setMarkerPoints: e,
686
+ clusterPoints: n,
687
+ setClusterPoints: o,
688
+ zoom: i,
689
+ setZoom: a
690
+ },
666
691
  children: r.children
667
692
  }
668
693
  );
669
694
  }
670
- const Yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
695
+ const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
671
696
  __proto__: null,
672
- BaseMap: yt,
673
- CenterPin: At,
674
- Layers: jt,
675
- Markers: Rt,
676
- Popup: Ft,
677
- Root: Gt
697
+ BaseMap: Mt,
698
+ CenterPin: Et,
699
+ Layers: $t,
700
+ Markers: Dt,
701
+ Popup: Nt,
702
+ Root: kt
678
703
  }, Symbol.toStringTag, { value: "Module" }));
679
704
  export {
680
- Vt as M,
705
+ C as D,
706
+ Jt as M,
707
+ Wt as P,
708
+ ft as W,
681
709
  V as a,
682
- C as d,
683
- Yt as i,
684
- Ht as m,
685
- I as u
710
+ ut as b,
711
+ Kt as i,
712
+ Yt as m,
713
+ R as u
686
714
  };