@local-logic/maps 0.1.2 → 0.1.4

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 (58) hide show
  1. package/dist/{index-Ci9PQ3VM.js → index--PIAfLjo.js} +2 -2
  2. package/dist/{index-Dy0j33aN.js → index-0EkdzCyN.js} +12 -11
  3. package/dist/index-BO34uKgS.js +16 -0
  4. package/dist/{index-vIYPnHrB.js → index-BY_xYg2p.js} +12 -11
  5. package/dist/{index-DHOxmHER.js → index-BnTZMzoy.js} +2 -2
  6. package/dist/index-C0inY_TA.js +41 -0
  7. package/dist/index-CHdAT424.js +44 -0
  8. package/dist/index-CNP-c5ZB.js +736 -0
  9. package/dist/index-COB6j_V1.js +25 -0
  10. package/dist/{index-BOJCRr60.js → index-CZPGxjSJ.js} +11 -10
  11. package/dist/index-D4t3jFAj.js +35 -0
  12. package/dist/index-DEFuc-6u.js +78 -0
  13. package/dist/index-DXT59VJA.js +29 -0
  14. package/dist/{index-CWXZA3V3.js → index-GoHd1Tri.js} +2 -2
  15. package/dist/{index-CTWLtI5f.js → index-MZUXTR07.js} +1 -1
  16. package/dist/{index-xDS1OfMB.js → index-QxKYqddl.js} +1 -1
  17. package/dist/{index-BabQioiH.js → index-zzok3ruU.js} +1 -1
  18. package/dist/index.es.js +1 -1
  19. package/dist/index.umd.js +62 -7
  20. package/dist/src/components/Map/Root/BaseMap/Testing/index.d.ts +4 -0
  21. package/dist/src/components/Map/Root/BaseMap/Testing/index.d.ts.map +1 -0
  22. package/dist/src/components/Map/Root/BaseMap/Testing/styles.d.ts +4 -0
  23. package/dist/src/components/Map/Root/BaseMap/Testing/styles.d.ts.map +1 -0
  24. package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -1
  25. package/dist/src/components/Map/Root/CenterPin/Testing/index.d.ts +4 -0
  26. package/dist/src/components/Map/Root/CenterPin/Testing/index.d.ts.map +1 -0
  27. package/dist/src/components/Map/Root/CenterPin/Testing/styles.d.ts +2 -0
  28. package/dist/src/components/Map/Root/CenterPin/Testing/styles.d.ts.map +1 -0
  29. package/dist/src/components/Map/Root/CenterPin/index.d.ts.map +1 -1
  30. package/dist/src/components/Map/Root/Layers/Testing/index.d.ts +4 -0
  31. package/dist/src/components/Map/Root/Layers/Testing/index.d.ts.map +1 -0
  32. package/dist/src/components/Map/Root/Layers/Testing/styles.d.ts +9 -0
  33. package/dist/src/components/Map/Root/Layers/Testing/styles.d.ts.map +1 -0
  34. package/dist/src/components/Map/Root/Layers/index.d.ts.map +1 -1
  35. package/dist/src/components/Map/Root/Markers/Testing/index.d.ts +4 -0
  36. package/dist/src/components/Map/Root/Markers/Testing/index.d.ts.map +1 -0
  37. package/dist/src/components/Map/Root/Markers/Testing/styles.d.ts +7 -0
  38. package/dist/src/components/Map/Root/Markers/Testing/styles.d.ts.map +1 -0
  39. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -1
  40. package/dist/src/components/Map/Root/Popup/Testing/index.d.ts +4 -0
  41. package/dist/src/components/Map/Root/Popup/Testing/index.d.ts.map +1 -0
  42. package/dist/src/components/Map/Root/Popup/Testing/styles.d.ts +5 -0
  43. package/dist/src/components/Map/Root/Popup/Testing/styles.d.ts.map +1 -0
  44. package/dist/src/components/Map/Root/Popup/index.d.ts.map +1 -1
  45. package/dist/src/components/Map/Root/constants.d.ts +1 -0
  46. package/dist/src/components/Map/Root/constants.d.ts.map +1 -1
  47. package/dist/src/components/Map/Root/types.d.ts +1 -1
  48. package/dist/src/components/Map/Root/types.d.ts.map +1 -1
  49. package/dist/src/components/Map/index.stories.d.ts +3 -0
  50. package/dist/src/components/Map/index.stories.d.ts.map +1 -1
  51. package/dist/style.css +1 -1
  52. package/dist/{styles-B3ZaR0wz.js → styles-DvWVFFVb.js} +1 -1
  53. package/package.json +2 -1
  54. package/dist/index-BUZonjTY.js +0 -75
  55. package/dist/index-D37STE_k.js +0 -725
  56. package/dist/index-qqbvBkdn.js +0 -7
  57. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts +0 -3
  58. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts.map +0 -1
@@ -1,725 +0,0 @@
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 = {
5
- zoom: 14,
6
- pitch: 0,
7
- bearing: 0,
8
- cooperativeGestures: !1
9
- }, V = {
10
- maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
11
- mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
12
- google: "a7ff20eb973126bb"
13
- }, ut = {
14
- top: 10,
15
- bottom: 10,
16
- left: 10,
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 }) => {
19
- const {
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), p = S(() => {
28
- switch (t?.name) {
29
- case "maptiler":
30
- return mt;
31
- case "google":
32
- return gt;
33
- case "mapbox":
34
- return yt;
35
- default:
36
- return wt;
37
- }
38
- }, [t]);
39
- return /* @__PURE__ */ O(
40
- "div",
41
- {
42
- className: dt,
43
- "data-testid": "base-map",
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(p, { children: r })
54
- }
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(() => {
59
- switch (t?.name) {
60
- case "maptiler":
61
- return _t;
62
- case "google":
63
- return Pt;
64
- case "mapbox":
65
- return At;
66
- default:
67
- return null;
68
- }
69
- }, [t]);
70
- return e ? /* @__PURE__ */ O(e, { ...r }) : null;
71
- }
72
- function nt(r, t, e = {}) {
73
- const n = { type: "Feature" };
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
- }
76
- function xt(r, t, e = {}) {
77
- if (!r)
78
- throw new Error("coordinates is required");
79
- if (!Array.isArray(r))
80
- throw new Error("coordinates must be an Array");
81
- if (r.length < 2)
82
- throw new Error("coordinates must be at least 2 numbers long");
83
- if (!W(r[0]) || !W(r[1]))
84
- throw new Error("coordinates must contain numbers");
85
- return nt({
86
- type: "Point",
87
- coordinates: r
88
- }, t, e);
89
- }
90
- function Yt(r, t, e = {}) {
91
- return nt({
92
- type: "MultiPoint",
93
- coordinates: r
94
- }, t, e);
95
- }
96
- function W(r) {
97
- return !isNaN(r) && r !== null && !Array.isArray(r);
98
- }
99
- const Y = [
100
- Int8Array,
101
- Uint8Array,
102
- Uint8ClampedArray,
103
- Int16Array,
104
- Uint16Array,
105
- Int32Array,
106
- Uint32Array,
107
- Float32Array,
108
- Float64Array
109
- ], B = 1, T = 8;
110
- class G {
111
- /**
112
- * Creates an index from raw `ArrayBuffer` data.
113
- * @param {ArrayBuffer} data
114
- */
115
- static from(t) {
116
- if (!(t instanceof ArrayBuffer))
117
- throw new Error("Data must be an instance of ArrayBuffer.");
118
- const [e, n] = new Uint8Array(t, 0, 2);
119
- if (e !== 219)
120
- throw new Error("Data does not appear to be in a KDBush format.");
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];
125
- if (!i)
126
- throw new Error("Unrecognized array type.");
127
- const [a] = new Uint16Array(t, 2, 1), [c] = new Uint32Array(t, 4, 1);
128
- return new G(c, a, i, t);
129
- }
130
- /**
131
- * Creates an index that will hold a given number of items.
132
- * @param {number} numItems
133
- * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
134
- * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
135
- * @param {ArrayBuffer} [data] (For internal use only)
136
- */
137
- constructor(t, e = 64, n = Float64Array, o) {
138
- if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
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;
141
- if (i < 0)
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);
144
- }
145
- /**
146
- * Add a point to the index.
147
- * @param {number} x
148
- * @param {number} y
149
- * @returns {number} An incremental index associated with the added item (starting from `0`).
150
- */
151
- add(t, e) {
152
- const n = this._pos >> 1;
153
- return this.ids[n] = n, this.coords[this._pos++] = t, this.coords[this._pos++] = e, n;
154
- }
155
- /**
156
- * Perform indexing of the added points.
157
- */
158
- finish() {
159
- const t = this._pos >> 1;
160
- if (t !== this.numItems)
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;
163
- }
164
- /**
165
- * Search the index for items within a given bounding box.
166
- * @param {number} minX
167
- * @param {number} minY
168
- * @param {number} maxX
169
- * @param {number} maxY
170
- * @returns {number[]} An array of indices correponding to the found items.
171
- */
172
- range(t, e, n, o) {
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 = [];
175
- for (; s.length; ) {
176
- const l = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
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]);
181
- }
182
- continue;
183
- }
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));
186
- }
187
- return p;
188
- }
189
- /**
190
- * Search the index for items within a given radius.
191
- * @param {number} qx
192
- * @param {number} qy
193
- * @param {number} r Query radius.
194
- * @returns {number[]} An array of indices correponding to the found items.
195
- */
196
- within(t, e, n) {
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;
199
- for (; c.length; ) {
200
- const l = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
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]);
204
- continue;
205
- }
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));
208
- }
209
- return s;
210
- }
211
- }
212
- function j(r, t, e, n, o, i) {
213
- if (o - n <= e) return;
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);
216
- }
217
- function rt(r, t, e, n, o, i) {
218
- for (; o > n; ) {
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);
222
- }
223
- const a = t[2 * e + i];
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++;
227
- for (; t[2 * s + i] > a; ) s--;
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);
230
- }
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);
234
- }
235
- function F(r, t, e) {
236
- const n = r[t];
237
- r[t] = r[e], r[e] = n;
238
- }
239
- function K(r, t, e, n) {
240
- const o = r - e, i = t - n;
241
- return o * o + i * i;
242
- }
243
- const vt = {
244
- minZoom: 0,
245
- // min zoom to generate clusters on
246
- maxZoom: 16,
247
- // max zoom level to cluster the points on
248
- minPoints: 2,
249
- // minimum points to form a cluster
250
- radius: 40,
251
- // cluster radius in pixels
252
- extent: 512,
253
- // tile extent (radius is calculated relative to it)
254
- nodeSize: 64,
255
- // size of the KD-tree leaf node, affects performance
256
- log: !1,
257
- // whether to log timing info
258
- // whether to generate numeric ids for input features (in vector tiles)
259
- generateId: !1,
260
- // a reduce function for calculating custom cluster properties
261
- reduce: null,
262
- // (accumulated, props) => { accumulated.sum += props.sum; }
263
- // properties to use for individual points when running the reducer
264
- map: (r) => r
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;
267
- class Ot {
268
- constructor(t) {
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 = [];
270
- }
271
- load(t) {
272
- const { log: e, minZoom: n, maxZoom: o } = this.options;
273
- e && console.time("total time");
274
- const i = `prepare ${t.length} points`;
275
- e && console.time(i), this.points = t;
276
- const a = [];
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));
281
- a.push(
282
- f,
283
- d,
284
- // projected point coordinates
285
- 1 / 0,
286
- // the last zoom the point was processed at
287
- s,
288
- // index of the source feature in the original input array
289
- -1,
290
- // parent cluster id
291
- 1
292
- // number of points in a cluster
293
- ), this.options.reduce && a.push(0);
294
- }
295
- let c = this.trees[o + 1] = this._createTree(a);
296
- e && console.timeEnd(i);
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);
300
- }
301
- return e && console.timeEnd("total time"), this;
302
- }
303
- getClusters(t, e) {
304
- let n = ((t[0] + 180) % 360 + 360) % 360 - 180;
305
- const o = Math.max(-90, Math.min(90, t[1]));
306
- let i = t[2] === 180 ? 180 : ((t[2] + 180) % 360 + 360) % 360 - 180;
307
- const a = Math.max(-90, Math.min(90, t[3]));
308
- if (t[2] - t[0] >= 360)
309
- n = -180, i = 180;
310
- else if (n > i) {
311
- const u = this.getClusters([n, o, 180, a], e), f = this.getClusters([-180, o, i, a], e);
312
- return u.concat(f);
313
- }
314
- const c = this.trees[this._limitZoom(e)], s = c.range(I(n), U(a), I(i), U(o)), p = c.data, l = [];
315
- for (const u of s) {
316
- const f = this.stride * u;
317
- l.push(p[f + P] > 1 ? Q(p, f, this.clusterProps) : this.points[p[f + A]]);
318
- }
319
- return l;
320
- }
321
- getChildren(t) {
322
- const e = this._getOriginId(t), n = this._getOriginZoom(t), o = "No cluster with the specified id.", i = this.trees[n];
323
- if (!i) throw new Error(o);
324
- const a = i.data;
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) {
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]]);
330
- }
331
- if (u.length === 0) throw new Error(o);
332
- return u;
333
- }
334
- getLeaves(t, e, n) {
335
- e = e || 10, n = n || 0;
336
- const o = [];
337
- return this._appendLeaves(o, t, e, n, 0), o;
338
- }
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 = {
341
- features: []
342
- };
343
- return this._addTileFeatures(
344
- o.range((e - s) / i, p, (e + 1 + s) / i, l),
345
- o.data,
346
- e,
347
- n,
348
- i,
349
- u
350
- ), e === 0 && this._addTileFeatures(
351
- o.range(1 - s / i, p, 1, l),
352
- o.data,
353
- i,
354
- n,
355
- i,
356
- u
357
- ), e === i - 1 && this._addTileFeatures(
358
- o.range(0, p, s / i, l),
359
- o.data,
360
- -1,
361
- n,
362
- i,
363
- u
364
- ), u.features.length ? u : null;
365
- }
366
- getClusterExpansionZoom(t) {
367
- let e = this._getOriginZoom(t) - 1;
368
- for (; e <= this.options.maxZoom; ) {
369
- const n = this.getChildren(t);
370
- if (e++, n.length !== 1) break;
371
- t = n[0].properties.cluster_id;
372
- }
373
- return e;
374
- }
375
- _appendLeaves(t, e, n, o, i) {
376
- const a = this.getChildren(e);
377
- for (const c of a) {
378
- const s = c.properties;
379
- if (s && s.cluster ? i + s.point_count <= o ? i += s.point_count : i = this._appendLeaves(t, s.cluster_id, n, o, i) : i < o ? i++ : t.push(c), t.length === n) break;
380
- }
381
- return i;
382
- }
383
- _createTree(t) {
384
- const e = new G(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
385
- for (let n = 0; n < t.length; n += this.stride) e.add(t[n], t[n + 1]);
386
- return e.finish(), e.data = t, e;
387
- }
388
- _addTileFeatures(t, e, n, o, i, a) {
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];
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);
399
- }
400
- const d = {
401
- type: 1,
402
- geometry: [[
403
- Math.round(this.options.extent * (u * i - n)),
404
- Math.round(this.options.extent * (f * i - o))
405
- ]],
406
- tags: l
407
- };
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);
410
- }
411
- }
412
- _limitZoom(t) {
413
- return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
414
- }
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;
422
- for (const m of g) {
423
- const M = m * l;
424
- s[M + x] > e && (h += s[M + P]);
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)));
435
- }
436
- s[u + N] = Z, p.push(m / h, M / h, 1 / 0, Z, -1, h), i && p.push($);
437
- } else {
438
- for (let m = 0; m < l; m++) p.push(s[u + m]);
439
- if (h > 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; _++) p.push(s[M + _]);
445
- }
446
- }
447
- }
448
- }
449
- return p;
450
- }
451
- // get index of the point from which the cluster originated
452
- _getOriginId(t) {
453
- return t - this.points.length >> 5;
454
- }
455
- // get zoom of the point from which the cluster originated
456
- _getOriginZoom(t) {
457
- return (t - this.points.length) % 32;
458
- }
459
- _map(t, e, n) {
460
- if (t[e + P] > 1) {
461
- const a = this.clusterProps[t[e + st]];
462
- return n ? Object.assign({}, a) : a;
463
- }
464
- const o = this.points[t[e + A]].properties, i = this.options.map(o);
465
- return n && i === o ? Object.assign({}, i) : i;
466
- }
467
- }
468
- function Q(r, t, e) {
469
- return {
470
- type: "Feature",
471
- id: r[t + A],
472
- properties: ot(r, t, e),
473
- geometry: {
474
- type: "Point",
475
- coordinates: [St(r[t]), Tt(r[t + 1])]
476
- }
477
- };
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]);
481
- return Object.assign(a, {
482
- cluster: !0,
483
- cluster_id: r[t + A],
484
- point_count: n,
485
- point_count_abbreviated: o
486
- });
487
- }
488
- function I(r) {
489
- return r / 360 + 0.5;
490
- }
491
- function U(r) {
492
- const t = Math.sin(r * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
493
- return e < 0 ? 0 : e > 1 ? 1 : e;
494
- }
495
- function St(r) {
496
- return (r - 0.5) * 360;
497
- }
498
- function Tt(r) {
499
- const t = (180 - r * 360) * Math.PI / 180;
500
- return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
501
- }
502
- var X = Object.prototype.hasOwnProperty;
503
- function tt(r, t, e) {
504
- for (e of r.keys())
505
- if (v(e, t)) return e;
506
- }
507
- function v(r, t) {
508
- var e, n, o;
509
- if (r === t) return !0;
510
- if (r && t && (e = r.constructor) === t.constructor) {
511
- if (e === Date) return r.getTime() === t.getTime();
512
- if (e === RegExp) return r.toString() === t.toString();
513
- if (e === Array) {
514
- if ((n = r.length) === t.length)
515
- for (; n-- && v(r[n], t[n]); ) ;
516
- return n === -1;
517
- }
518
- if (e === Set) {
519
- if (r.size !== t.size)
520
- return !1;
521
- for (n of r)
522
- if (o = n, o && typeof o == "object" && (o = tt(t, o), !o) || !t.has(o)) return !1;
523
- return !0;
524
- }
525
- if (e === Map) {
526
- if (r.size !== t.size)
527
- return !1;
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)))
530
- return !1;
531
- return !0;
532
- }
533
- if (e === ArrayBuffer)
534
- r = new Uint8Array(r), t = new Uint8Array(t);
535
- else if (e === DataView) {
536
- if ((n = r.byteLength) === t.byteLength)
537
- for (; n-- && r.getInt8(n) === t.getInt8(n); ) ;
538
- return n === -1;
539
- }
540
- if (ArrayBuffer.isView(r)) {
541
- if ((n = r.byteLength) === t.byteLength)
542
- for (; n-- && r[n] === t[n]; ) ;
543
- return n === -1;
544
- }
545
- if (!e || typeof r == "object") {
546
- n = 0;
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;
549
- return Object.keys(t).length === n;
550
- }
551
- }
552
- return r !== r && t !== t;
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() {
557
- return t.current;
558
- }, [e.current]);
559
- }
560
- function Ct(r, t) {
561
- return D.useEffect(r, bt(t));
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() {
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
- }, [e, n, f, i, a]), {
568
- clusters: l,
569
- supercluster: c.current
570
- };
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(() => {
576
- if (r)
577
- return;
578
- const h = (t || []).map((m) => [m.longitude, m.latitude]);
579
- c(h);
580
- }, [t, c]);
581
- const p = S(
582
- () => ({
583
- points: t.map((h) => xt([h.longitude, h.latitude], h)),
584
- // Using world bounds to avoid issues with markers near the edges of the map
585
- bounds: ft,
586
- zoom: a,
587
- options: {
588
- radius: o.name === "google" && a > J ? lt : ht,
589
- minZoom: J,
590
- maxZoom: pt
591
- }
592
- }),
593
- [t, o, a]
594
- ), { clusters: l, supercluster: u } = Lt(p), f = z("");
595
- H(() => {
596
- const h = JSON.stringify(
597
- l.map((m) => ({
598
- coords: m.geometry.coordinates,
599
- props: m.properties
600
- }))
601
- );
602
- h !== f.current && (s(l), f.current = h);
603
- }, [l, s]);
604
- const d = (h) => {
605
- if (!("properties" in h))
606
- throw new Error("Cluster does not have properties");
607
- if (h.properties?.cluster && typeof h.properties?.cluster_id == "number") {
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) ?? []
613
- });
614
- return;
615
- }
616
- e?.({
617
- id: h.properties.id,
618
- latitude: h.properties.latitude,
619
- longitude: h.properties.longitude,
620
- markers: [h.properties]
621
- });
622
- }, g = (h) => {
623
- if (!u || !i) return !1;
624
- if (i.id === `${h}`)
625
- return !0;
626
- try {
627
- return u.getLeaves(h)?.find((m) => m.properties.id === i.id) !== void 0;
628
- } catch {
629
- return !1;
630
- }
631
- }, y = S(() => {
632
- switch (o?.name) {
633
- case "maptiler":
634
- return Rt;
635
- case "google":
636
- return It;
637
- case "mapbox":
638
- return Ut;
639
- default:
640
- return null;
641
- }
642
- }, [o]);
643
- return y ? /* @__PURE__ */ O(
644
- y,
645
- {
646
- clusters: l,
647
- onClick: d,
648
- doesSuperclusterContainActiveMarker: g,
649
- ...n
650
- }
651
- ) : null;
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(() => {
656
- switch (n?.name) {
657
- case "maptiler":
658
- return Zt;
659
- case "google":
660
- return Bt;
661
- case "mapbox":
662
- return Ft;
663
- default:
664
- return null;
665
- }
666
- }, [n]);
667
- return o ? /* @__PURE__ */ O(o, { ...e, anchor: t, children: r }) : null;
668
- }
669
- const zt = w(() => import("./index-DKy2opdk.js")), jt = w(() => import("./index-k9UFzKZZ.js")), Gt = w(() => import("./index-D8-yY6UK.js"));
670
- function $t(r) {
671
- const { mapProvider: t } = R(), e = S(() => {
672
- switch (t?.name) {
673
- case "maptiler":
674
- return zt;
675
- case "google":
676
- return jt;
677
- case "mapbox":
678
- return Gt;
679
- default:
680
- return null;
681
- }
682
- }, [t]);
683
- return e ? /* @__PURE__ */ O(e, { ...r }) : null;
684
- }
685
- function kt(r) {
686
- const [t, e] = L([]), [n, o] = L([]), [i, a] = L(r.zoom || C.zoom);
687
- return /* @__PURE__ */ O(
688
- et.Provider,
689
- {
690
- value: {
691
- ...r,
692
- locale: r.locale || "en",
693
- mapPadding: r.mapPadding || ut,
694
- locationBoundary: r.locationBoundary ? r.locationBoundary : [[r.center.longitude, r.center.latitude]],
695
- markerPoints: t,
696
- setMarkerPoints: e,
697
- clusterPoints: n,
698
- setClusterPoints: o,
699
- zoom: i,
700
- setZoom: a
701
- },
702
- children: r.children
703
- }
704
- );
705
- }
706
- const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
707
- __proto__: null,
708
- BaseMap: Mt,
709
- CenterPin: Et,
710
- Layers: $t,
711
- Markers: Dt,
712
- Popup: Nt,
713
- Root: kt
714
- }, Symbol.toStringTag, { value: "Module" }));
715
- export {
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
725
- };