@local-logic/maps 0.1.2 → 0.1.3

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.
@@ -1,21 +1,21 @@
1
- import { jsx as O } from "react/jsx-runtime";
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 = {
1
+ import { jsx as _ } from "react/jsx-runtime";
2
+ import * as Z from "react";
3
+ import ct, { useContext as ut, useState as L, useMemo as O, lazy as w, Suspense as R, useRef as j, useEffect as V } from "react";
4
+ const nt = ct.createContext({}), I = () => ut(nt), C = {
5
5
  zoom: 14,
6
6
  pitch: 0,
7
7
  bearing: 0,
8
8
  cooperativeGestures: !1
9
- }, V = {
9
+ }, J = {
10
10
  maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
11
11
  mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
12
12
  google: "a7ff20eb973126bb"
13
- }, ut = {
13
+ }, lt = {
14
14
  top: 10,
15
15
  bottom: 10,
16
16
  left: 10,
17
17
  right: 10
18
- }, J = 10, pt = 22, Jt = 10, 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-CTWLtI5f.js")), gt = w(() => import("./index-BabQioiH.js")), yt = w(() => import("./index-xDS1OfMB.js")), wt = w(() => import("./index-qqbvBkdn.js")), Mt = ({ children: r }) => {
18
+ }, W = 10, pt = 22, Wt = 10, ht = 30, ft = 60, Yt = 15, dt = [-180, -85.0511, 180, 85.0511], mt = "w-full h-full relative overflow-hidden", gt = w(() => import("./index-NMqp09ek.js")), yt = w(() => import("./index-B1dI6iqp.js")), wt = w(() => import("./index-Bm2KdhhT.js")), Mt = w(() => import("./index-qqbvBkdn.js")), _t = ({ children: r }) => {
19
19
  const {
20
20
  mapProvider: t,
21
21
  center: e,
@@ -24,25 +24,25 @@ const et = at.createContext({}), R = () => ct(et), C = {
24
24
  bearing: i = C.bearing,
25
25
  cooperativeGestures: a = C.cooperativeGestures,
26
26
  zoomPosition: c
27
- } = R(), [s] = L(n), p = S(() => {
27
+ } = I(), [s] = L(n), l = O(() => {
28
28
  switch (t?.name) {
29
29
  case "maptiler":
30
- return mt;
31
- case "google":
32
30
  return gt;
33
- case "mapbox":
31
+ case "google":
34
32
  return yt;
35
- default:
33
+ case "mapbox":
36
34
  return wt;
35
+ default:
36
+ return Mt;
37
37
  }
38
38
  }, [t]);
39
- return /* @__PURE__ */ O(
39
+ return /* @__PURE__ */ _(
40
40
  "div",
41
41
  {
42
- className: dt,
42
+ className: mt,
43
43
  "data-testid": "base-map",
44
44
  "data-map-provider-name": t?.name,
45
- "data-map-provider-theme": t?.theme || V[t?.name] || V.maptiler,
45
+ "data-map-provider-theme": t?.theme || J[t?.name] || J.maptiler,
46
46
  "data-initial-zoom": s,
47
47
  "data-pitch": o,
48
48
  "data-bearing": i,
@@ -50,53 +50,53 @@ const et = at.createContext({}), R = () => ct(et), C = {
50
50
  "data-zoom-position": c,
51
51
  "data-center-latitude": e.latitude,
52
52
  "data-center-longitude": e.longitude,
53
- children: /* @__PURE__ */ O(p, { children: r })
53
+ children: /* @__PURE__ */ _(R, { fallback: null, children: /* @__PURE__ */ _(l, { children: r }) })
54
54
  }
55
55
  );
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(() => {
56
+ }, Pt = w(() => import("./index-C3Tj3r2u.js")), At = w(() => import("./index-CUUravWc.js")), Et = w(() => import("./index-eWv3le07.js"));
57
+ function xt(r) {
58
+ const { mapProvider: t } = I(), e = O(() => {
59
59
  switch (t?.name) {
60
60
  case "maptiler":
61
- return _t;
62
- case "google":
63
61
  return Pt;
64
- case "mapbox":
62
+ case "google":
65
63
  return At;
64
+ case "mapbox":
65
+ return Et;
66
66
  default:
67
67
  return null;
68
68
  }
69
69
  }, [t]);
70
- return e ? /* @__PURE__ */ O(e, { ...r }) : null;
70
+ return e ? /* @__PURE__ */ _(R, { fallback: null, children: /* @__PURE__ */ _(e, { ...r }) }) : null;
71
71
  }
72
- function nt(r, t, e = {}) {
72
+ function rt(r, t, e = {}) {
73
73
  const n = { type: "Feature" };
74
74
  return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
75
75
  }
76
- function xt(r, t, e = {}) {
76
+ function bt(r, t, e = {}) {
77
77
  if (!r)
78
78
  throw new Error("coordinates is required");
79
79
  if (!Array.isArray(r))
80
80
  throw new Error("coordinates must be an Array");
81
81
  if (r.length < 2)
82
82
  throw new Error("coordinates must be at least 2 numbers long");
83
- if (!W(r[0]) || !W(r[1]))
83
+ if (!Y(r[0]) || !Y(r[1]))
84
84
  throw new Error("coordinates must contain numbers");
85
- return nt({
85
+ return rt({
86
86
  type: "Point",
87
87
  coordinates: r
88
88
  }, t, e);
89
89
  }
90
- function Yt(r, t, e = {}) {
91
- return nt({
90
+ function Kt(r, t, e = {}) {
91
+ return rt({
92
92
  type: "MultiPoint",
93
93
  coordinates: r
94
94
  }, t, e);
95
95
  }
96
- function W(r) {
96
+ function Y(r) {
97
97
  return !isNaN(r) && r !== null && !Array.isArray(r);
98
98
  }
99
- const Y = [
99
+ const K = [
100
100
  Int8Array,
101
101
  Uint8Array,
102
102
  Uint8ClampedArray,
@@ -106,7 +106,7 @@ const Y = [
106
106
  Uint32Array,
107
107
  Float32Array,
108
108
  Float64Array
109
- ], B = 1, T = 8;
109
+ ], F = 1, S = 8;
110
110
  class G {
111
111
  /**
112
112
  * Creates an index from raw `ArrayBuffer` data.
@@ -119,9 +119,9 @@ class G {
119
119
  if (e !== 219)
120
120
  throw new Error("Data does not appear to be in a KDBush format.");
121
121
  const o = n >> 4;
122
- if (o !== B)
123
- throw new Error(`Got v${o} data when expected v${B}.`);
124
- const i = Y[n & 15];
122
+ if (o !== F)
123
+ throw new Error(`Got v${o} data when expected v${F}.`);
124
+ const i = K[n & 15];
125
125
  if (!i)
126
126
  throw new Error("Unrecognized array type.");
127
127
  const [a] = new Uint16Array(t, 2, 1), [c] = new Uint32Array(t, 4, 1);
@@ -137,10 +137,10 @@ class G {
137
137
  constructor(t, e = 64, n = Float64Array, o) {
138
138
  if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
139
139
  this.numItems = +t, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.ArrayType = n, this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array;
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;
140
+ const i = K.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, c = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - c % 8) % 8;
141
141
  if (i < 0)
142
142
  throw new Error(`Unexpected typed array class: ${n}.`);
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, (B << 4) + i]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = t);
143
+ o && o instanceof ArrayBuffer ? (this.data = o, this.ids = new this.IndexArrayType(this.data, S, t), this.coords = new this.ArrayType(this.data, S + c + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(S + a + c + s), this.ids = new this.IndexArrayType(this.data, S, t), this.coords = new this.ArrayType(this.data, S + 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);
144
144
  }
145
145
  /**
146
146
  * Add a point to the index.
@@ -159,7 +159,7 @@ class G {
159
159
  const t = this._pos >> 1;
160
160
  if (t !== this.numItems)
161
161
  throw new Error(`Added ${t} items when expected ${this.numItems}.`);
162
- return j(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
162
+ return k(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
163
163
  }
164
164
  /**
165
165
  * Search the index for items within a given bounding box.
@@ -171,20 +171,20 @@ class G {
171
171
  */
172
172
  range(t, e, n, o) {
173
173
  if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
174
- 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], l = [];
175
175
  for (; s.length; ) {
176
- const l = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
176
+ const h = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
177
177
  if (u - f <= c) {
178
- for (let h = f; h <= u; h++) {
179
- const m = a[2 * h], M = a[2 * h + 1];
180
- m >= t && m <= n && M >= e && M <= o && p.push(i[h]);
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 && l.push(i[p]);
181
181
  }
182
182
  continue;
183
183
  }
184
184
  const d = f + u >> 1, g = a[2 * d], y = a[2 * d + 1];
185
- g >= t && g <= n && y >= e && y <= o && p.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));
185
+ g >= t && g <= n && y >= e && y <= o && l.push(i[d]), (h === 0 ? t <= g : e <= y) && (s.push(f), s.push(d - 1), s.push(1 - h)), (h === 0 ? n >= g : o >= y) && (s.push(d + 1), s.push(u), s.push(1 - h));
186
186
  }
187
- return p;
187
+ return l;
188
188
  }
189
189
  /**
190
190
  * Search the index for items within a given radius.
@@ -195,48 +195,48 @@ class G {
195
195
  */
196
196
  within(t, e, n) {
197
197
  if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
198
- 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 = [], l = n * n;
199
199
  for (; c.length; ) {
200
- const l = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
200
+ const h = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
201
201
  if (u - f <= a) {
202
- for (let h = f; h <= u; h++)
203
- K(i[2 * h], i[2 * h + 1], t, e) <= p && s.push(o[h]);
202
+ for (let p = f; p <= u; p++)
203
+ q(i[2 * p], i[2 * p + 1], t, e) <= l && s.push(o[p]);
204
204
  continue;
205
205
  }
206
206
  const d = f + u >> 1, g = i[2 * d], y = i[2 * d + 1];
207
- K(g, y, t, e) <= p && 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));
207
+ q(g, y, t, e) <= l && s.push(o[d]), (h === 0 ? t - n <= g : e - n <= y) && (c.push(f), c.push(d - 1), c.push(1 - h)), (h === 0 ? t + n >= g : e + n >= y) && (c.push(d + 1), c.push(u), c.push(1 - h));
208
208
  }
209
209
  return s;
210
210
  }
211
211
  }
212
- function j(r, t, e, n, o, i) {
212
+ function k(r, t, e, n, o, i) {
213
213
  if (o - n <= e) return;
214
214
  const a = n + o >> 1;
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);
215
+ st(r, t, a, n, o, i), k(r, t, e, n, a - 1, 1 - i), k(r, t, e, a + 1, o, 1 - i);
216
216
  }
217
- function rt(r, t, e, n, o, i) {
217
+ function st(r, t, e, n, o, i) {
218
218
  for (; o > n; ) {
219
219
  if (o - n > 600) {
220
- const p = o - n + 1, l = 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) * (l - p / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - l * f / p + d)), y = Math.min(o, Math.floor(e + (p - l) * f / p + d));
221
- rt(r, t, e, g, y, i);
220
+ const l = o - n + 1, h = e - n + 1, u = Math.log(l), f = 0.5 * Math.exp(2 * u / 3), d = 0.5 * Math.sqrt(u * f * (l - f) / l) * (h - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - h * f / l + d)), y = Math.min(o, Math.floor(e + (l - h) * f / l + d));
221
+ st(r, t, e, g, y, i);
222
222
  }
223
223
  const a = t[2 * e + i];
224
224
  let c = n, s = o;
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++;
225
+ for (T(r, t, n, e), t[2 * o + i] > a && T(r, t, n, o); c < s; ) {
226
+ for (T(r, t, c, s), c++, s--; t[2 * c + i] < a; ) c++;
227
227
  for (; t[2 * s + i] > a; ) s--;
228
228
  }
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);
229
+ t[2 * n + i] === a ? T(r, t, n, s) : (s++, T(r, t, s, o)), s <= e && (n = s + 1), e <= s && (o = s - 1);
230
230
  }
231
231
  }
232
- function b(r, t, e, n) {
233
- F(r, e, n), F(t, 2 * e, 2 * n), F(t, 2 * e + 1, 2 * n + 1);
232
+ function T(r, t, e, n) {
233
+ N(r, e, n), N(t, 2 * e, 2 * n), N(t, 2 * e + 1, 2 * n + 1);
234
234
  }
235
- function F(r, t, e) {
235
+ function N(r, t, e) {
236
236
  const n = r[t];
237
237
  r[t] = r[e], r[e] = n;
238
238
  }
239
- function K(r, t, e, n) {
239
+ function q(r, t, e, n) {
240
240
  const o = r - e, i = t - n;
241
241
  return o * o + i * i;
242
242
  }
@@ -263,7 +263,7 @@ const vt = {
263
263
  // properties to use for individual points when running the reducer
264
264
  map: (r) => r
265
265
  // props => ({sum: props.my_value})
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;
266
+ }, Q = Math.fround || /* @__PURE__ */ ((r) => ((t) => (r[0] = +t, r[0])))(new Float32Array(1)), b = 2, E = 3, z = 4, A = 5, ot = 6;
267
267
  class Ot {
268
268
  constructor(t) {
269
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 = [];
@@ -275,9 +275,9 @@ class Ot {
275
275
  e && console.time(i), this.points = t;
276
276
  const a = [];
277
277
  for (let s = 0; s < t.length; s++) {
278
- const p = t[s];
279
- if (!p.geometry) continue;
280
- const [l, u] = p.geometry.coordinates, f = q(I(l)), d = q(U(u));
278
+ const l = t[s];
279
+ if (!l.geometry) continue;
280
+ const [h, u] = l.geometry.coordinates, f = Q(U(h)), d = Q(D(u));
281
281
  a.push(
282
282
  f,
283
283
  d,
@@ -295,8 +295,8 @@ class Ot {
295
295
  let c = this.trees[o + 1] = this._createTree(a);
296
296
  e && console.timeEnd(i);
297
297
  for (let s = o; s >= n; s--) {
298
- const p = +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() - p);
298
+ const l = +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() - l);
300
300
  }
301
301
  return e && console.timeEnd("total time"), this;
302
302
  }
@@ -311,22 +311,22 @@ class Ot {
311
311
  const u = this.getClusters([n, o, 180, a], e), f = this.getClusters([-180, o, i, a], e);
312
312
  return u.concat(f);
313
313
  }
314
- const c = this.trees[this._limitZoom(e)], s = c.range(I(n), U(a), I(i), U(o)), p = c.data, l = [];
314
+ const c = this.trees[this._limitZoom(e)], s = c.range(U(n), D(a), U(i), D(o)), l = c.data, h = [];
315
315
  for (const u of s) {
316
316
  const f = this.stride * u;
317
- l.push(p[f + P] > 1 ? Q(p, f, this.clusterProps) : this.points[p[f + A]]);
317
+ h.push(l[f + A] > 1 ? X(l, f, this.clusterProps) : this.points[l[f + E]]);
318
318
  }
319
- return l;
319
+ return h;
320
320
  }
321
321
  getChildren(t) {
322
322
  const e = this._getOriginId(t), n = this._getOriginZoom(t), o = "No cluster with the specified id.", i = this.trees[n];
323
323
  if (!i) throw new Error(o);
324
324
  const a = i.data;
325
325
  if (e * this.stride >= a.length) throw new Error(o);
326
- const c = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), s = a[e * this.stride], p = a[e * this.stride + 1], l = i.within(s, p, c), u = [];
327
- for (const f of l) {
326
+ const c = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), s = a[e * this.stride], l = a[e * this.stride + 1], h = i.within(s, l, c), u = [];
327
+ for (const f of h) {
328
328
  const d = f * this.stride;
329
- a[d + N] === t && u.push(a[d + P] > 1 ? Q(a, d, this.clusterProps) : this.points[a[d + A]]);
329
+ a[d + z] === t && u.push(a[d + A] > 1 ? X(a, d, this.clusterProps) : this.points[a[d + E]]);
330
330
  }
331
331
  if (u.length === 0) throw new Error(o);
332
332
  return u;
@@ -337,25 +337,25 @@ class Ot {
337
337
  return this._appendLeaves(o, t, e, n, 0), o;
338
338
  }
339
339
  getTile(t, e, n) {
340
- 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, l = (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, l = (n - s) / i, h = (n + 1 + s) / i, u = {
341
341
  features: []
342
342
  };
343
343
  return this._addTileFeatures(
344
- o.range((e - s) / i, p, (e + 1 + s) / i, l),
344
+ o.range((e - s) / i, l, (e + 1 + s) / i, h),
345
345
  o.data,
346
346
  e,
347
347
  n,
348
348
  i,
349
349
  u
350
350
  ), e === 0 && this._addTileFeatures(
351
- o.range(1 - s / i, p, 1, l),
351
+ o.range(1 - s / i, l, 1, h),
352
352
  o.data,
353
353
  i,
354
354
  n,
355
355
  i,
356
356
  u
357
357
  ), e === i - 1 && this._addTileFeatures(
358
- o.range(0, p, s / i, l),
358
+ o.range(0, l, s / i, h),
359
359
  o.data,
360
360
  -1,
361
361
  n,
@@ -387,15 +387,15 @@ class Ot {
387
387
  }
388
388
  _addTileFeatures(t, e, n, o, i, a) {
389
389
  for (const c of t) {
390
- const s = c * this.stride, p = e[s + P] > 1;
391
- let l, u, f;
392
- if (p)
393
- l = ot(e, s, this.clusterProps), u = e[s], f = e[s + 1];
390
+ const s = c * this.stride, l = e[s + A] > 1;
391
+ let h, u, f;
392
+ if (l)
393
+ h = it(e, s, this.clusterProps), u = e[s], f = e[s + 1];
394
394
  else {
395
- const y = this.points[e[s + A]];
396
- l = y.properties;
397
- const [h, m] = y.geometry.coordinates;
398
- u = I(h), f = U(m);
395
+ const y = this.points[e[s + E]];
396
+ h = y.properties;
397
+ const [p, m] = y.geometry.coordinates;
398
+ u = U(p), f = D(m);
399
399
  }
400
400
  const d = {
401
401
  type: 1,
@@ -403,50 +403,50 @@ class Ot {
403
403
  Math.round(this.options.extent * (u * i - n)),
404
404
  Math.round(this.options.extent * (f * i - o))
405
405
  ]],
406
- tags: l
406
+ tags: h
407
407
  };
408
408
  let g;
409
- p || this.options.generateId ? g = e[s + A] : g = this.points[e[s + A]].id, g !== void 0 && (d.id = g), a.features.push(d);
409
+ l || this.options.generateId ? g = e[s + E] : g = this.points[e[s + E]].id, g !== void 0 && (d.id = g), a.features.push(d);
410
410
  }
411
411
  }
412
412
  _limitZoom(t) {
413
413
  return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
414
414
  }
415
415
  _cluster(t, e) {
416
- const { radius: n, extent: o, reduce: i, minPoints: a } = this.options, c = n / (o * Math.pow(2, e)), s = t.data, p = [], 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 h = y;
416
+ const { radius: n, extent: o, reduce: i, minPoints: a } = this.options, c = n / (o * Math.pow(2, e)), s = t.data, l = [], h = this.stride;
417
+ for (let u = 0; u < s.length; u += h) {
418
+ if (s[u + b] <= e) continue;
419
+ s[u + b] = e;
420
+ const f = s[u], d = s[u + 1], g = t.within(s[u], s[u + 1], c), y = s[u + A];
421
+ let p = y;
422
422
  for (const m of g) {
423
- const M = m * l;
424
- s[M + x] > e && (h += s[M + P]);
423
+ const M = m * h;
424
+ s[M + b] > e && (p += s[M + A]);
425
425
  }
426
- if (h > y && h >= 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)));
426
+ if (p > y && p >= a) {
427
+ let m = f * y, M = d * y, P, $ = -1;
428
+ const B = ((u / h | 0) << 5) + (e + 1) + this.points.length;
429
+ for (const at of g) {
430
+ const x = at * h;
431
+ if (s[x + b] <= e) continue;
432
+ s[x + b] = e;
433
+ const H = s[x + A];
434
+ m += s[x] * H, M += s[x + 1] * H, s[x + z] = B, i && (P || (P = this._map(s, u, !0), $ = this.clusterProps.length, this.clusterProps.push(P)), i(P, this._map(s, x)));
435
435
  }
436
- s[u + N] = Z, p.push(m / h, M / h, 1 / 0, Z, -1, h), i && p.push($);
436
+ s[u + z] = B, l.push(m / p, M / p, 1 / 0, B, -1, p), i && l.push($);
437
437
  } else {
438
- for (let m = 0; m < l; m++) p.push(s[u + m]);
439
- if (h > 1)
438
+ for (let m = 0; m < h; m++) l.push(s[u + m]);
439
+ if (p > 1)
440
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; _++) p.push(s[M + _]);
441
+ const M = m * h;
442
+ if (!(s[M + b] <= e)) {
443
+ s[M + b] = e;
444
+ for (let P = 0; P < h; P++) l.push(s[M + P]);
445
445
  }
446
446
  }
447
447
  }
448
448
  }
449
- return p;
449
+ return l;
450
450
  }
451
451
  // get index of the point from which the cluster originated
452
452
  _getOriginId(t) {
@@ -457,38 +457,38 @@ class Ot {
457
457
  return (t - this.points.length) % 32;
458
458
  }
459
459
  _map(t, e, n) {
460
- if (t[e + P] > 1) {
461
- const a = this.clusterProps[t[e + st]];
460
+ if (t[e + A] > 1) {
461
+ const a = this.clusterProps[t[e + ot]];
462
462
  return n ? Object.assign({}, a) : a;
463
463
  }
464
- const o = this.points[t[e + A]].properties, i = this.options.map(o);
464
+ const o = this.points[t[e + E]].properties, i = this.options.map(o);
465
465
  return n && i === o ? Object.assign({}, i) : i;
466
466
  }
467
467
  }
468
- function Q(r, t, e) {
468
+ function X(r, t, e) {
469
469
  return {
470
470
  type: "Feature",
471
- id: r[t + A],
472
- properties: ot(r, t, e),
471
+ id: r[t + E],
472
+ properties: it(r, t, e),
473
473
  geometry: {
474
474
  type: "Point",
475
475
  coordinates: [St(r[t]), Tt(r[t + 1])]
476
476
  }
477
477
  };
478
478
  }
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]);
479
+ function it(r, t, e) {
480
+ 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 + ot], a = i === -1 ? {} : Object.assign({}, e[i]);
481
481
  return Object.assign(a, {
482
482
  cluster: !0,
483
- cluster_id: r[t + A],
483
+ cluster_id: r[t + E],
484
484
  point_count: n,
485
485
  point_count_abbreviated: o
486
486
  });
487
487
  }
488
- function I(r) {
488
+ function U(r) {
489
489
  return r / 360 + 0.5;
490
490
  }
491
- function U(r) {
491
+ function D(r) {
492
492
  const t = Math.sin(r * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
493
493
  return e < 0 ? 0 : e > 1 ? 1 : e;
494
494
  }
@@ -499,8 +499,8 @@ function Tt(r) {
499
499
  const t = (180 - r * 360) * Math.PI / 180;
500
500
  return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
501
501
  }
502
- var X = Object.prototype.hasOwnProperty;
503
- function tt(r, t, e) {
502
+ var tt = Object.prototype.hasOwnProperty;
503
+ function et(r, t, e) {
504
504
  for (e of r.keys())
505
505
  if (v(e, t)) return e;
506
506
  }
@@ -519,14 +519,14 @@ function v(r, t) {
519
519
  if (r.size !== t.size)
520
520
  return !1;
521
521
  for (n of r)
522
- if (o = n, o && typeof o == "object" && (o = tt(t, o), !o) || !t.has(o)) return !1;
522
+ if (o = n, o && typeof o == "object" && (o = et(t, o), !o) || !t.has(o)) return !1;
523
523
  return !0;
524
524
  }
525
525
  if (e === Map) {
526
526
  if (r.size !== t.size)
527
527
  return !1;
528
528
  for (n of r)
529
- if (o = n[0], o && typeof o == "object" && (o = tt(t, o), !o) || !v(n[1], t.get(o)))
529
+ if (o = n[0], o && typeof o == "object" && (o = et(t, o), !o) || !v(n[1], t.get(o)))
530
530
  return !1;
531
531
  return !0;
532
532
  }
@@ -545,152 +545,152 @@ function v(r, t) {
545
545
  if (!e || typeof r == "object") {
546
546
  n = 0;
547
547
  for (e in r)
548
- if (X.call(r, e) && ++n && !X.call(t, e) || !(e in t) || !v(r[e], t[e])) return !1;
548
+ if (tt.call(r, e) && ++n && !tt.call(t, e) || !(e in t) || !v(r[e], t[e])) return !1;
549
549
  return Object.keys(t).length === n;
550
550
  }
551
551
  }
552
552
  return r !== r && t !== t;
553
553
  }
554
- function bt(r) {
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() {
554
+ function Ct(r) {
555
+ var t = Z.useRef(r), e = Z.useRef(0);
556
+ return v(r, t.current) || (t.current = r, e.current += 1), Z.useMemo(function() {
557
557
  return t.current;
558
558
  }, [e.current]);
559
559
  }
560
- function Ct(r, t) {
561
- return D.useEffect(r, bt(t));
560
+ function Lt(r, t) {
561
+ return Z.useEffect(r, Ct(t));
562
562
  }
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(), p = L([]), l = p[0], u = p[1], f = Math.round(o);
565
- return Ct(function() {
563
+ var Rt = function(t) {
564
+ var e = t.points, n = t.bounds, o = t.zoom, i = t.options, a = t.disableRefresh, c = j(), s = j(), l = L([]), h = l[0], u = l[1], f = Math.round(o);
565
+ return Lt(function() {
566
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);
567
567
  }, [e, n, f, i, a]), {
568
- clusters: l,
568
+ clusters: h,
569
569
  supercluster: c.current
570
570
  };
571
571
  };
572
- const Rt = w(() => import("./index-Dy0j33aN.js")), It = w(() => import("./index-BOJCRr60.js")), Ut = w(() => import("./index-vIYPnHrB.js"));
573
- function Dt({ isLoading: r, markers: t, onClick: e, ...n }) {
574
- const { mapProvider: o, activeMarker: i, zoom: a, setMarkerPoints: c, setClusterPoints: s } = R();
575
- H(() => {
572
+ const It = w(() => import("./index-Deqck8KU.js")), Ut = w(() => import("./index-CFioISlP.js")), Dt = w(() => import("./index-CyFpPXRS.js"));
573
+ function Zt({ isLoading: r, markers: t, onClick: e, ...n }) {
574
+ const { mapProvider: o, activeMarker: i, zoom: a, setMarkerPoints: c, setClusterPoints: s } = I();
575
+ V(() => {
576
576
  if (r)
577
577
  return;
578
- const h = (t || []).map((m) => [m.longitude, m.latitude]);
579
- c(h);
578
+ const p = (t || []).map((m) => [m.longitude, m.latitude]);
579
+ c(p);
580
580
  }, [t, c]);
581
- const p = S(
581
+ const l = O(
582
582
  () => ({
583
- points: t.map((h) => xt([h.longitude, h.latitude], h)),
583
+ points: t.map((p) => bt([p.longitude, p.latitude], p)),
584
584
  // Using world bounds to avoid issues with markers near the edges of the map
585
- bounds: ft,
585
+ bounds: dt,
586
586
  zoom: a,
587
587
  options: {
588
- radius: o.name === "google" && a > J ? lt : ht,
589
- minZoom: J,
588
+ radius: o.name === "google" && a > W ? ft : ht,
589
+ minZoom: W,
590
590
  maxZoom: pt
591
591
  }
592
592
  }),
593
593
  [t, o, a]
594
- ), { clusters: l, supercluster: u } = Lt(p), f = z("");
595
- H(() => {
596
- const h = JSON.stringify(
597
- l.map((m) => ({
594
+ ), { clusters: h, supercluster: u } = Rt(l), f = j("");
595
+ V(() => {
596
+ const p = JSON.stringify(
597
+ h.map((m) => ({
598
598
  coords: m.geometry.coordinates,
599
599
  props: m.properties
600
600
  }))
601
601
  );
602
- h !== f.current && (s(l), f.current = h);
603
- }, [l, s]);
604
- const d = (h) => {
605
- if (!("properties" in h))
602
+ p !== f.current && (s(h), f.current = p);
603
+ }, [h, s]);
604
+ const d = (p) => {
605
+ if (!("properties" in p))
606
606
  throw new Error("Cluster does not have properties");
607
- if (h.properties?.cluster && typeof h.properties?.cluster_id == "number") {
607
+ if (p.properties?.cluster && typeof p.properties?.cluster_id == "number") {
608
608
  e?.({
609
- id: `${h.properties.cluster_id}`,
610
- latitude: h.geometry.coordinates[1],
611
- longitude: h.geometry.coordinates[0],
612
- markers: u?.getLeaves(h.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) ?? []
613
613
  });
614
614
  return;
615
615
  }
616
616
  e?.({
617
- id: h.properties.id,
618
- latitude: h.properties.latitude,
619
- longitude: h.properties.longitude,
620
- markers: [h.properties]
617
+ id: p.properties.id,
618
+ latitude: p.properties.latitude,
619
+ longitude: p.properties.longitude,
620
+ markers: [p.properties]
621
621
  });
622
- }, g = (h) => {
622
+ }, g = (p) => {
623
623
  if (!u || !i) return !1;
624
- if (i.id === `${h}`)
624
+ if (i.id === `${p}`)
625
625
  return !0;
626
626
  try {
627
- return u.getLeaves(h)?.find((m) => m.properties.id === i.id) !== void 0;
627
+ return u.getLeaves(p)?.find((m) => m.properties.id === i.id) !== void 0;
628
628
  } catch {
629
629
  return !1;
630
630
  }
631
- }, y = S(() => {
631
+ }, y = O(() => {
632
632
  switch (o?.name) {
633
633
  case "maptiler":
634
- return Rt;
635
- case "google":
636
634
  return It;
637
- case "mapbox":
635
+ case "google":
638
636
  return Ut;
637
+ case "mapbox":
638
+ return Dt;
639
639
  default:
640
640
  return null;
641
641
  }
642
642
  }, [o]);
643
- return y ? /* @__PURE__ */ O(
643
+ return y ? /* @__PURE__ */ _(R, { fallback: null, children: /* @__PURE__ */ _(
644
644
  y,
645
645
  {
646
- clusters: l,
646
+ clusters: h,
647
647
  onClick: d,
648
648
  doesSuperclusterContainActiveMarker: g,
649
649
  ...n
650
650
  }
651
- ) : null;
651
+ ) }) : null;
652
652
  }
653
- const Zt = w(() => import("./index-Ci9PQ3VM.js")), Bt = w(() => import("./index-DHOxmHER.js")), Ft = w(() => import("./index-CWXZA3V3.js"));
654
- function Nt({ children: r, anchor: t = "bottom", ...e }) {
655
- const { mapProvider: n } = R(), o = S(() => {
653
+ const Bt = w(() => import("./index-zqYpD_YN.js")), Ft = w(() => import("./index-CzqD82Cl.js")), Nt = w(() => import("./index-VFglx6lb.js"));
654
+ function zt({ children: r, anchor: t = "bottom", ...e }) {
655
+ const { mapProvider: n } = I(), o = O(() => {
656
656
  switch (n?.name) {
657
657
  case "maptiler":
658
- return Zt;
659
- case "google":
660
658
  return Bt;
661
- case "mapbox":
659
+ case "google":
662
660
  return Ft;
661
+ case "mapbox":
662
+ return Nt;
663
663
  default:
664
664
  return null;
665
665
  }
666
666
  }, [n]);
667
- return o ? /* @__PURE__ */ O(o, { ...e, anchor: t, children: r }) : null;
667
+ return o ? /* @__PURE__ */ _(R, { fallback: null, children: /* @__PURE__ */ _(o, { ...e, anchor: t, children: r }) }) : null;
668
668
  }
669
- const zt = w(() => import("./index-DKy2opdk.js")), jt = w(() => import("./index-k9UFzKZZ.js")), Gt = w(() => import("./index-D8-yY6UK.js"));
669
+ const jt = w(() => import("./index-DKy2opdk.js")), kt = w(() => import("./index-k9UFzKZZ.js")), Gt = w(() => import("./index-D8-yY6UK.js"));
670
670
  function $t(r) {
671
- const { mapProvider: t } = R(), e = S(() => {
671
+ const { mapProvider: t } = I(), e = O(() => {
672
672
  switch (t?.name) {
673
673
  case "maptiler":
674
- return zt;
675
- case "google":
676
674
  return jt;
675
+ case "google":
676
+ return kt;
677
677
  case "mapbox":
678
678
  return Gt;
679
679
  default:
680
680
  return null;
681
681
  }
682
682
  }, [t]);
683
- return e ? /* @__PURE__ */ O(e, { ...r }) : null;
683
+ return e ? /* @__PURE__ */ _(R, { fallback: null, children: /* @__PURE__ */ _(e, { ...r }) }) : null;
684
684
  }
685
- function kt(r) {
685
+ function Ht(r) {
686
686
  const [t, e] = L([]), [n, o] = L([]), [i, a] = L(r.zoom || C.zoom);
687
- return /* @__PURE__ */ O(
688
- et.Provider,
687
+ return /* @__PURE__ */ _(
688
+ nt.Provider,
689
689
  {
690
690
  value: {
691
691
  ...r,
692
692
  locale: r.locale || "en",
693
- mapPadding: r.mapPadding || ut,
693
+ mapPadding: r.mapPadding || lt,
694
694
  locationBoundary: r.locationBoundary ? r.locationBoundary : [[r.center.longitude, r.center.latitude]],
695
695
  markerPoints: t,
696
696
  setMarkerPoints: e,
@@ -703,23 +703,23 @@ function kt(r) {
703
703
  }
704
704
  );
705
705
  }
706
- const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
706
+ const qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
707
707
  __proto__: null,
708
- BaseMap: Mt,
709
- CenterPin: Et,
708
+ BaseMap: _t,
709
+ CenterPin: xt,
710
710
  Layers: $t,
711
- Markers: Dt,
712
- Popup: Nt,
713
- Root: kt
711
+ Markers: Zt,
712
+ Popup: zt,
713
+ Root: Ht
714
714
  }, Symbol.toStringTag, { value: "Module" }));
715
715
  export {
716
716
  C as D,
717
- Jt as M,
718
- Wt as P,
719
- ft as W,
720
- V as a,
721
- ut as b,
722
- Kt as i,
723
- Yt as m,
724
- R as u
717
+ Wt as M,
718
+ Yt as P,
719
+ dt as W,
720
+ J as a,
721
+ lt as b,
722
+ qt as i,
723
+ Kt as m,
724
+ I as u
725
725
  };