@local-logic/maps 0.0.12 → 0.0.13

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 (52) hide show
  1. package/dist/index-58w3Qwxr.js +56 -0
  2. package/dist/index-BGoTpJjt.js +81 -0
  3. package/dist/index-Bp1bWq9c.js +690 -0
  4. package/dist/{index-DFdfOz0d.js → index-C36u5N_F.js} +1 -1
  5. package/dist/{index-B3NH4rqN.js → index-CBp9gCca.js} +8 -8
  6. package/dist/index-CCtDJ-mV.js +56 -0
  7. package/dist/index-CFomI3Il.js +98 -0
  8. package/dist/index-CUpaKIZP.js +105 -0
  9. package/dist/index-CXTsUiSS.js +57 -0
  10. package/dist/index-CXUQoF5Q.js +34 -0
  11. package/dist/{index-B9YXnLOH.js → index-DY5pY-zk.js} +11 -10
  12. package/dist/index-S5SfktvB.js +79 -0
  13. package/dist/index.es.js +1 -1
  14. package/dist/index.umd.js +75 -75
  15. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts +1 -1
  16. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -1
  17. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts +1 -1
  18. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -1
  19. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts +1 -1
  20. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -1
  21. package/dist/src/components/Map/Root/BaseMap/index.d.ts +1 -1
  22. package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -1
  23. package/dist/src/components/Map/Root/BaseMap/types.d.ts +10 -1
  24. package/dist/src/components/Map/Root/BaseMap/types.d.ts.map +1 -1
  25. package/dist/src/components/Map/Root/Markers/Google/index.d.ts +1 -1
  26. package/dist/src/components/Map/Root/Markers/Google/index.d.ts.map +1 -1
  27. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts +1 -1
  28. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts.map +1 -1
  29. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts +1 -1
  30. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts.map +1 -1
  31. package/dist/src/components/Map/Root/Markers/index.d.ts +1 -1
  32. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -1
  33. package/dist/src/components/Map/Root/Markers/types.d.ts +0 -11
  34. package/dist/src/components/Map/Root/Markers/types.d.ts.map +1 -1
  35. package/dist/src/components/Map/Root/Popup/Google/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/index.d.ts +1 -1
  38. package/dist/src/components/Map/Root/Popup/index.d.ts.map +1 -1
  39. package/dist/src/components/Map/Root/constants.d.ts +3 -0
  40. package/dist/src/components/Map/Root/constants.d.ts.map +1 -1
  41. package/dist/src/components/Map/Root/context.d.ts +2 -0
  42. package/dist/src/components/Map/Root/context.d.ts.map +1 -1
  43. package/dist/src/components/Map/Root/index.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/index-BcpSqK0X.js +0 -74
  46. package/dist/index-Bd7meO8V.js +0 -783
  47. package/dist/index-BhldVNew.js +0 -35
  48. package/dist/index-Bu4XEiYU.js +0 -74
  49. package/dist/index-CzBPD5Sw.js +0 -73
  50. package/dist/index-DsrEcQq0.js +0 -71
  51. package/dist/index-LKvWHhi6.js +0 -53
  52. package/dist/index-aDlW4ps0.js +0 -50
@@ -1,783 +0,0 @@
1
- import { jsx as T } from "react/jsx-runtime";
2
- import * as D from "react";
3
- import at, { useContext as ct, useState as U, useMemo as P, lazy as A, useRef as H, useEffect as ut } from "react";
4
- const et = at.createContext({}), Z = () => ct(et), R = {
5
- zoom: 14,
6
- pitch: 0,
7
- bearing: 0,
8
- cooperativeGestures: !1
9
- }, J = {
10
- maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
11
- mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
12
- google: "a7ff20eb973126bb"
13
- }, K = 13, ht = 22, lt = 30, pt = 60, ft = "w-full h-full relative overflow-hidden", dt = A(() => import("./index-aDlW4ps0.js")), gt = A(() => import("./index-CzBPD5Sw.js")), mt = A(() => import("./index-LKvWHhi6.js")), yt = A(() => import("./index-qqbvBkdn.js")), wt = ({ children: r }) => {
14
- const {
15
- mapProvider: t,
16
- center: e,
17
- zoom: n = R.zoom,
18
- pitch: i = R.pitch,
19
- bearing: o = R.bearing,
20
- cooperativeGestures: a = R.cooperativeGestures,
21
- zoomPosition: c
22
- } = Z(), [s] = U(n), h = P(() => {
23
- switch (t == null ? void 0 : t.name) {
24
- case "maptiler":
25
- return dt;
26
- case "google":
27
- return gt;
28
- case "mapbox":
29
- return mt;
30
- default:
31
- return yt;
32
- }
33
- }, [t]);
34
- return /* @__PURE__ */ T(
35
- "div",
36
- {
37
- className: ft,
38
- "data-testid": "base-map",
39
- "data-map-provider-name": t == null ? void 0 : t.name,
40
- "data-map-provider-theme": (t == null ? void 0 : t.theme) || J[t == null ? void 0 : t.name] || J.maptiler,
41
- "data-initial-zoom": s,
42
- "data-pitch": i,
43
- "data-bearing": o,
44
- "data-cooperative-gestures": a,
45
- "data-zoom-position": c,
46
- "data-center-latitude": e.latitude,
47
- "data-center-longitude": e.longitude,
48
- children: /* @__PURE__ */ T(h, { children: r })
49
- }
50
- );
51
- }, Mt = A(() => import("./index-Do_dW76Q.js")), _t = A(() => import("./index-BCa658u4.js")), At = A(() => import("./index-CNxLnZ8O.js"));
52
- function Et(r) {
53
- const { mapProvider: t } = Z(), e = P(() => {
54
- switch (t == null ? void 0 : t.name) {
55
- case "maptiler":
56
- return Mt;
57
- case "google":
58
- return _t;
59
- case "mapbox":
60
- return At;
61
- default:
62
- return null;
63
- }
64
- }, [t]);
65
- return e ? /* @__PURE__ */ T(e, { ...r }) : null;
66
- }
67
- function nt(r, t, e = {}) {
68
- const n = { type: "Feature" };
69
- return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
70
- }
71
- function bt(r, t, e = {}) {
72
- if (!r)
73
- throw new Error("coordinates is required");
74
- if (!Array.isArray(r))
75
- throw new Error("coordinates must be an Array");
76
- if (r.length < 2)
77
- throw new Error("coordinates must be at least 2 numbers long");
78
- if (!W(r[0]) || !W(r[1]))
79
- throw new Error("coordinates must contain numbers");
80
- return nt({
81
- type: "Point",
82
- coordinates: r
83
- }, t, e);
84
- }
85
- function St(r, t, e = {}) {
86
- return nt({
87
- type: "MultiPoint",
88
- coordinates: r
89
- }, t, e);
90
- }
91
- function W(r) {
92
- return !isNaN(r) && r !== null && !Array.isArray(r);
93
- }
94
- function rt(r, t, e) {
95
- if (r !== null)
96
- for (var n, i, o, a, c, s, h, l = 0, u = 0, p, d = r.type, g = d === "FeatureCollection", M = d === "Feature", w = g ? r.features.length : 1, y = 0; y < w; y++) {
97
- h = g ? r.features[y].geometry : M ? r.geometry : r, p = h ? h.type === "GeometryCollection" : !1, c = p ? h.geometries.length : 1;
98
- for (var f = 0; f < c; f++) {
99
- var m = 0, _ = 0;
100
- if (a = p ? h.geometries[f] : h, a !== null) {
101
- s = a.coordinates;
102
- var E = a.type;
103
- switch (l = 0, E) {
104
- case null:
105
- break;
106
- case "Point":
107
- if (t(
108
- s,
109
- u,
110
- y,
111
- m,
112
- _
113
- ) === !1)
114
- return !1;
115
- u++, m++;
116
- break;
117
- case "LineString":
118
- case "MultiPoint":
119
- for (n = 0; n < s.length; n++) {
120
- if (t(
121
- s[n],
122
- u,
123
- y,
124
- m,
125
- _
126
- ) === !1)
127
- return !1;
128
- u++, E === "MultiPoint" && m++;
129
- }
130
- E === "LineString" && m++;
131
- break;
132
- case "Polygon":
133
- case "MultiLineString":
134
- for (n = 0; n < s.length; n++) {
135
- for (i = 0; i < s[n].length - l; i++) {
136
- if (t(
137
- s[n][i],
138
- u,
139
- y,
140
- m,
141
- _
142
- ) === !1)
143
- return !1;
144
- u++;
145
- }
146
- E === "MultiLineString" && m++, E === "Polygon" && _++;
147
- }
148
- E === "Polygon" && m++;
149
- break;
150
- case "MultiPolygon":
151
- for (n = 0; n < s.length; n++) {
152
- for (_ = 0, i = 0; i < s[n].length; i++) {
153
- for (o = 0; o < s[n][i].length - l; o++) {
154
- if (t(
155
- s[n][i][o],
156
- u,
157
- y,
158
- m,
159
- _
160
- ) === !1)
161
- return !1;
162
- u++;
163
- }
164
- _++;
165
- }
166
- m++;
167
- }
168
- break;
169
- case "GeometryCollection":
170
- for (n = 0; n < a.geometries.length; n++)
171
- if (rt(a.geometries[n], t) === !1)
172
- return !1;
173
- break;
174
- default:
175
- throw new Error("Unknown Geometry Type");
176
- }
177
- }
178
- }
179
- }
180
- }
181
- function Ot(r, t = {}) {
182
- if (r.bbox != null && t.recompute !== !0)
183
- return r.bbox;
184
- const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
185
- return rt(r, (n) => {
186
- e[0] > n[0] && (e[0] = n[0]), e[1] > n[1] && (e[1] = n[1]), e[2] < n[0] && (e[2] = n[0]), e[3] < n[1] && (e[3] = n[1]);
187
- }), e;
188
- }
189
- const Y = [
190
- Int8Array,
191
- Uint8Array,
192
- Uint8ClampedArray,
193
- Int16Array,
194
- Uint16Array,
195
- Int32Array,
196
- Uint32Array,
197
- Float32Array,
198
- Float64Array
199
- ], G = 1, L = 8;
200
- class I {
201
- /**
202
- * Creates an index from raw `ArrayBuffer` data.
203
- * @param {ArrayBuffer} data
204
- */
205
- static from(t) {
206
- if (!(t instanceof ArrayBuffer))
207
- throw new Error("Data must be an instance of ArrayBuffer.");
208
- const [e, n] = new Uint8Array(t, 0, 2);
209
- if (e !== 219)
210
- throw new Error("Data does not appear to be in a KDBush format.");
211
- const i = n >> 4;
212
- if (i !== G)
213
- throw new Error(`Got v${i} data when expected v${G}.`);
214
- const o = Y[n & 15];
215
- if (!o)
216
- throw new Error("Unrecognized array type.");
217
- const [a] = new Uint16Array(t, 2, 1), [c] = new Uint32Array(t, 4, 1);
218
- return new I(c, a, o, t);
219
- }
220
- /**
221
- * Creates an index that will hold a given number of items.
222
- * @param {number} numItems
223
- * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
224
- * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
225
- * @param {ArrayBuffer} [data] (For internal use only)
226
- */
227
- constructor(t, e = 64, n = Float64Array, i) {
228
- if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
229
- this.numItems = +t, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.ArrayType = n, this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array;
230
- const o = Y.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, c = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - c % 8) % 8;
231
- if (o < 0)
232
- throw new Error(`Unexpected typed array class: ${n}.`);
233
- i && i instanceof ArrayBuffer ? (this.data = i, this.ids = new this.IndexArrayType(this.data, L, t), this.coords = new this.ArrayType(this.data, L + c + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(L + a + c + s), this.ids = new this.IndexArrayType(this.data, L, t), this.coords = new this.ArrayType(this.data, L + c + s, t * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (G << 4) + o]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = t);
234
- }
235
- /**
236
- * Add a point to the index.
237
- * @param {number} x
238
- * @param {number} y
239
- * @returns {number} An incremental index associated with the added item (starting from `0`).
240
- */
241
- add(t, e) {
242
- const n = this._pos >> 1;
243
- return this.ids[n] = n, this.coords[this._pos++] = t, this.coords[this._pos++] = e, n;
244
- }
245
- /**
246
- * Perform indexing of the added points.
247
- */
248
- finish() {
249
- const t = this._pos >> 1;
250
- if (t !== this.numItems)
251
- throw new Error(`Added ${t} items when expected ${this.numItems}.`);
252
- return j(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
253
- }
254
- /**
255
- * Search the index for items within a given bounding box.
256
- * @param {number} minX
257
- * @param {number} minY
258
- * @param {number} maxX
259
- * @param {number} maxY
260
- * @returns {number[]} An array of indices correponding to the found items.
261
- */
262
- range(t, e, n, i) {
263
- if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
264
- const { ids: o, coords: a, nodeSize: c } = this, s = [0, o.length - 1, 0], h = [];
265
- for (; s.length; ) {
266
- const l = s.pop() || 0, u = s.pop() || 0, p = s.pop() || 0;
267
- if (u - p <= c) {
268
- for (let w = p; w <= u; w++) {
269
- const y = a[2 * w], f = a[2 * w + 1];
270
- y >= t && y <= n && f >= e && f <= i && h.push(o[w]);
271
- }
272
- continue;
273
- }
274
- const d = p + u >> 1, g = a[2 * d], M = a[2 * d + 1];
275
- g >= t && g <= n && M >= e && M <= i && h.push(o[d]), (l === 0 ? t <= g : e <= M) && (s.push(p), s.push(d - 1), s.push(1 - l)), (l === 0 ? n >= g : i >= M) && (s.push(d + 1), s.push(u), s.push(1 - l));
276
- }
277
- return h;
278
- }
279
- /**
280
- * Search the index for items within a given radius.
281
- * @param {number} qx
282
- * @param {number} qy
283
- * @param {number} r Query radius.
284
- * @returns {number[]} An array of indices correponding to the found items.
285
- */
286
- within(t, e, n) {
287
- if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
288
- const { ids: i, coords: o, nodeSize: a } = this, c = [0, i.length - 1, 0], s = [], h = n * n;
289
- for (; c.length; ) {
290
- const l = c.pop() || 0, u = c.pop() || 0, p = c.pop() || 0;
291
- if (u - p <= a) {
292
- for (let w = p; w <= u; w++)
293
- q(o[2 * w], o[2 * w + 1], t, e) <= h && s.push(i[w]);
294
- continue;
295
- }
296
- const d = p + u >> 1, g = o[2 * d], M = o[2 * d + 1];
297
- q(g, M, t, e) <= h && s.push(i[d]), (l === 0 ? t - n <= g : e - n <= M) && (c.push(p), c.push(d - 1), c.push(1 - l)), (l === 0 ? t + n >= g : e + n >= M) && (c.push(d + 1), c.push(u), c.push(1 - l));
298
- }
299
- return s;
300
- }
301
- }
302
- function j(r, t, e, n, i, o) {
303
- if (i - n <= e) return;
304
- const a = n + i >> 1;
305
- st(r, t, a, n, i, o), j(r, t, e, n, a - 1, 1 - o), j(r, t, e, a + 1, i, 1 - o);
306
- }
307
- function st(r, t, e, n, i, o) {
308
- for (; i > n; ) {
309
- if (i - n > 600) {
310
- const h = i - n + 1, l = e - n + 1, u = Math.log(h), p = 0.5 * Math.exp(2 * u / 3), d = 0.5 * Math.sqrt(u * p * (h - p) / h) * (l - h / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - l * p / h + d)), M = Math.min(i, Math.floor(e + (h - l) * p / h + d));
311
- st(r, t, e, g, M, o);
312
- }
313
- const a = t[2 * e + o];
314
- let c = n, s = i;
315
- for (C(r, t, n, e), t[2 * i + o] > a && C(r, t, n, i); c < s; ) {
316
- for (C(r, t, c, s), c++, s--; t[2 * c + o] < a; ) c++;
317
- for (; t[2 * s + o] > a; ) s--;
318
- }
319
- t[2 * n + o] === a ? C(r, t, n, s) : (s++, C(r, t, s, i)), s <= e && (n = s + 1), e <= s && (i = s - 1);
320
- }
321
- }
322
- function C(r, t, e, n) {
323
- N(r, e, n), N(t, 2 * e, 2 * n), N(t, 2 * e + 1, 2 * n + 1);
324
- }
325
- function N(r, t, e) {
326
- const n = r[t];
327
- r[t] = r[e], r[e] = n;
328
- }
329
- function q(r, t, e, n) {
330
- const i = r - e, o = t - n;
331
- return i * i + o * o;
332
- }
333
- const xt = {
334
- minZoom: 0,
335
- // min zoom to generate clusters on
336
- maxZoom: 16,
337
- // max zoom level to cluster the points on
338
- minPoints: 2,
339
- // minimum points to form a cluster
340
- radius: 40,
341
- // cluster radius in pixels
342
- extent: 512,
343
- // tile extent (radius is calculated relative to it)
344
- nodeSize: 64,
345
- // size of the KD-tree leaf node, affects performance
346
- log: !1,
347
- // whether to log timing info
348
- // whether to generate numeric ids for input features (in vector tiles)
349
- generateId: !1,
350
- // a reduce function for calculating custom cluster properties
351
- reduce: null,
352
- // (accumulated, props) => { accumulated.sum += props.sum; }
353
- // properties to use for individual points when running the reducer
354
- map: (r) => r
355
- // props => ({sum: props.my_value})
356
- }, Q = Math.fround || /* @__PURE__ */ ((r) => (t) => (r[0] = +t, r[0]))(new Float32Array(1)), x = 2, S = 3, $ = 4, b = 5, it = 6;
357
- class Pt {
358
- constructor(t) {
359
- this.options = Object.assign(Object.create(xt), t), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
360
- }
361
- load(t) {
362
- const { log: e, minZoom: n, maxZoom: i } = this.options;
363
- e && console.time("total time");
364
- const o = `prepare ${t.length} points`;
365
- e && console.time(o), this.points = t;
366
- const a = [];
367
- for (let s = 0; s < t.length; s++) {
368
- const h = t[s];
369
- if (!h.geometry) continue;
370
- const [l, u] = h.geometry.coordinates, p = Q(z(l)), d = Q(B(u));
371
- a.push(
372
- p,
373
- d,
374
- // projected point coordinates
375
- 1 / 0,
376
- // the last zoom the point was processed at
377
- s,
378
- // index of the source feature in the original input array
379
- -1,
380
- // parent cluster id
381
- 1
382
- // number of points in a cluster
383
- ), this.options.reduce && a.push(0);
384
- }
385
- let c = this.trees[i + 1] = this._createTree(a);
386
- e && console.timeEnd(o);
387
- for (let s = i; s >= n; s--) {
388
- const h = +Date.now();
389
- 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);
390
- }
391
- return e && console.timeEnd("total time"), this;
392
- }
393
- getClusters(t, e) {
394
- let n = ((t[0] + 180) % 360 + 360) % 360 - 180;
395
- const i = Math.max(-90, Math.min(90, t[1]));
396
- let o = t[2] === 180 ? 180 : ((t[2] + 180) % 360 + 360) % 360 - 180;
397
- const a = Math.max(-90, Math.min(90, t[3]));
398
- if (t[2] - t[0] >= 360)
399
- n = -180, o = 180;
400
- else if (n > o) {
401
- const u = this.getClusters([n, i, 180, a], e), p = this.getClusters([-180, i, o, a], e);
402
- return u.concat(p);
403
- }
404
- const c = this.trees[this._limitZoom(e)], s = c.range(z(n), B(a), z(o), B(i)), h = c.data, l = [];
405
- for (const u of s) {
406
- const p = this.stride * u;
407
- l.push(h[p + b] > 1 ? k(h, p, this.clusterProps) : this.points[h[p + S]]);
408
- }
409
- return l;
410
- }
411
- getChildren(t) {
412
- const e = this._getOriginId(t), n = this._getOriginZoom(t), i = "No cluster with the specified id.", o = this.trees[n];
413
- if (!o) throw new Error(i);
414
- const a = o.data;
415
- if (e * this.stride >= a.length) throw new Error(i);
416
- 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 = o.within(s, h, c), u = [];
417
- for (const p of l) {
418
- const d = p * this.stride;
419
- a[d + $] === t && u.push(a[d + b] > 1 ? k(a, d, this.clusterProps) : this.points[a[d + S]]);
420
- }
421
- if (u.length === 0) throw new Error(i);
422
- return u;
423
- }
424
- getLeaves(t, e, n) {
425
- e = e || 10, n = n || 0;
426
- const i = [];
427
- return this._appendLeaves(i, t, e, n, 0), i;
428
- }
429
- getTile(t, e, n) {
430
- const i = this.trees[this._limitZoom(t)], o = Math.pow(2, t), { extent: a, radius: c } = this.options, s = c / a, h = (n - s) / o, l = (n + 1 + s) / o, u = {
431
- features: []
432
- };
433
- return this._addTileFeatures(
434
- i.range((e - s) / o, h, (e + 1 + s) / o, l),
435
- i.data,
436
- e,
437
- n,
438
- o,
439
- u
440
- ), e === 0 && this._addTileFeatures(
441
- i.range(1 - s / o, h, 1, l),
442
- i.data,
443
- o,
444
- n,
445
- o,
446
- u
447
- ), e === o - 1 && this._addTileFeatures(
448
- i.range(0, h, s / o, l),
449
- i.data,
450
- -1,
451
- n,
452
- o,
453
- u
454
- ), u.features.length ? u : null;
455
- }
456
- getClusterExpansionZoom(t) {
457
- let e = this._getOriginZoom(t) - 1;
458
- for (; e <= this.options.maxZoom; ) {
459
- const n = this.getChildren(t);
460
- if (e++, n.length !== 1) break;
461
- t = n[0].properties.cluster_id;
462
- }
463
- return e;
464
- }
465
- _appendLeaves(t, e, n, i, o) {
466
- const a = this.getChildren(e);
467
- for (const c of a) {
468
- const s = c.properties;
469
- if (s && s.cluster ? o + s.point_count <= i ? o += s.point_count : o = this._appendLeaves(t, s.cluster_id, n, i, o) : o < i ? o++ : t.push(c), t.length === n) break;
470
- }
471
- return o;
472
- }
473
- _createTree(t) {
474
- const e = new I(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
475
- for (let n = 0; n < t.length; n += this.stride) e.add(t[n], t[n + 1]);
476
- return e.finish(), e.data = t, e;
477
- }
478
- _addTileFeatures(t, e, n, i, o, a) {
479
- for (const c of t) {
480
- const s = c * this.stride, h = e[s + b] > 1;
481
- let l, u, p;
482
- if (h)
483
- l = ot(e, s, this.clusterProps), u = e[s], p = e[s + 1];
484
- else {
485
- const M = this.points[e[s + S]];
486
- l = M.properties;
487
- const [w, y] = M.geometry.coordinates;
488
- u = z(w), p = B(y);
489
- }
490
- const d = {
491
- type: 1,
492
- geometry: [[
493
- Math.round(this.options.extent * (u * o - n)),
494
- Math.round(this.options.extent * (p * o - i))
495
- ]],
496
- tags: l
497
- };
498
- let g;
499
- h || this.options.generateId ? g = e[s + S] : g = this.points[e[s + S]].id, g !== void 0 && (d.id = g), a.features.push(d);
500
- }
501
- }
502
- _limitZoom(t) {
503
- return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
504
- }
505
- _cluster(t, e) {
506
- const { radius: n, extent: i, reduce: o, minPoints: a } = this.options, c = n / (i * Math.pow(2, e)), s = t.data, h = [], l = this.stride;
507
- for (let u = 0; u < s.length; u += l) {
508
- if (s[u + x] <= e) continue;
509
- s[u + x] = e;
510
- const p = s[u], d = s[u + 1], g = t.within(s[u], s[u + 1], c), M = s[u + b];
511
- let w = M;
512
- for (const y of g) {
513
- const f = y * l;
514
- s[f + x] > e && (w += s[f + b]);
515
- }
516
- if (w > M && w >= a) {
517
- let y = p * M, f = d * M, m, _ = -1;
518
- const E = ((u / l | 0) << 5) + (e + 1) + this.points.length;
519
- for (const F of g) {
520
- const O = F * l;
521
- if (s[O + x] <= e) continue;
522
- s[O + x] = e;
523
- const V = s[O + b];
524
- y += s[O] * V, f += s[O + 1] * V, s[O + $] = E, o && (m || (m = this._map(s, u, !0), _ = this.clusterProps.length, this.clusterProps.push(m)), o(m, this._map(s, O)));
525
- }
526
- s[u + $] = E, h.push(y / w, f / w, 1 / 0, E, -1, w), o && h.push(_);
527
- } else {
528
- for (let y = 0; y < l; y++) h.push(s[u + y]);
529
- if (w > 1)
530
- for (const y of g) {
531
- const f = y * l;
532
- if (!(s[f + x] <= e)) {
533
- s[f + x] = e;
534
- for (let m = 0; m < l; m++) h.push(s[f + m]);
535
- }
536
- }
537
- }
538
- }
539
- return h;
540
- }
541
- // get index of the point from which the cluster originated
542
- _getOriginId(t) {
543
- return t - this.points.length >> 5;
544
- }
545
- // get zoom of the point from which the cluster originated
546
- _getOriginZoom(t) {
547
- return (t - this.points.length) % 32;
548
- }
549
- _map(t, e, n) {
550
- if (t[e + b] > 1) {
551
- const a = this.clusterProps[t[e + it]];
552
- return n ? Object.assign({}, a) : a;
553
- }
554
- const i = this.points[t[e + S]].properties, o = this.options.map(i);
555
- return n && o === i ? Object.assign({}, o) : o;
556
- }
557
- }
558
- function k(r, t, e) {
559
- return {
560
- type: "Feature",
561
- id: r[t + S],
562
- properties: ot(r, t, e),
563
- geometry: {
564
- type: "Point",
565
- coordinates: [vt(r[t]), Tt(r[t + 1])]
566
- }
567
- };
568
- }
569
- function ot(r, t, e) {
570
- const n = r[t + b], i = n >= 1e4 ? `${Math.round(n / 1e3)}k` : n >= 1e3 ? `${Math.round(n / 100) / 10}k` : n, o = r[t + it], a = o === -1 ? {} : Object.assign({}, e[o]);
571
- return Object.assign(a, {
572
- cluster: !0,
573
- cluster_id: r[t + S],
574
- point_count: n,
575
- point_count_abbreviated: i
576
- });
577
- }
578
- function z(r) {
579
- return r / 360 + 0.5;
580
- }
581
- function B(r) {
582
- const t = Math.sin(r * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
583
- return e < 0 ? 0 : e > 1 ? 1 : e;
584
- }
585
- function vt(r) {
586
- return (r - 0.5) * 360;
587
- }
588
- function Tt(r) {
589
- const t = (180 - r * 360) * Math.PI / 180;
590
- return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
591
- }
592
- var X = Object.prototype.hasOwnProperty;
593
- function tt(r, t, e) {
594
- for (e of r.keys())
595
- if (v(e, t)) return e;
596
- }
597
- function v(r, t) {
598
- var e, n, i;
599
- if (r === t) return !0;
600
- if (r && t && (e = r.constructor) === t.constructor) {
601
- if (e === Date) return r.getTime() === t.getTime();
602
- if (e === RegExp) return r.toString() === t.toString();
603
- if (e === Array) {
604
- if ((n = r.length) === t.length)
605
- for (; n-- && v(r[n], t[n]); ) ;
606
- return n === -1;
607
- }
608
- if (e === Set) {
609
- if (r.size !== t.size)
610
- return !1;
611
- for (n of r)
612
- if (i = n, i && typeof i == "object" && (i = tt(t, i), !i) || !t.has(i)) return !1;
613
- return !0;
614
- }
615
- if (e === Map) {
616
- if (r.size !== t.size)
617
- return !1;
618
- for (n of r)
619
- if (i = n[0], i && typeof i == "object" && (i = tt(t, i), !i) || !v(n[1], t.get(i)))
620
- return !1;
621
- return !0;
622
- }
623
- if (e === ArrayBuffer)
624
- r = new Uint8Array(r), t = new Uint8Array(t);
625
- else if (e === DataView) {
626
- if ((n = r.byteLength) === t.byteLength)
627
- for (; n-- && r.getInt8(n) === t.getInt8(n); ) ;
628
- return n === -1;
629
- }
630
- if (ArrayBuffer.isView(r)) {
631
- if ((n = r.byteLength) === t.byteLength)
632
- for (; n-- && r[n] === t[n]; ) ;
633
- return n === -1;
634
- }
635
- if (!e || typeof r == "object") {
636
- n = 0;
637
- for (e in r)
638
- if (X.call(r, e) && ++n && !X.call(t, e) || !(e in t) || !v(r[e], t[e])) return !1;
639
- return Object.keys(t).length === n;
640
- }
641
- }
642
- return r !== r && t !== t;
643
- }
644
- function Lt(r) {
645
- var t = D.useRef(r), e = D.useRef(0);
646
- return v(r, t.current) || (t.current = r, e.current += 1), D.useMemo(function() {
647
- return t.current;
648
- }, [e.current]);
649
- }
650
- function Ct(r, t) {
651
- return D.useEffect(r, Lt(t));
652
- }
653
- var Rt = function(t) {
654
- var e = t.points, n = t.bounds, i = t.zoom, o = t.options, a = t.disableRefresh, c = H(), s = H(), h = U([]), l = h[0], u = h[1], p = Math.round(i);
655
- return Ct(function() {
656
- a !== !0 && ((!c.current || !v(s.current, e) || !v(c.current.options, o)) && (c.current = new Pt(o), c.current.load(e)), n && u(c.current.getClusters(n, p)), s.current = e);
657
- }, [e, n, p, o, a]), {
658
- clusters: l,
659
- supercluster: c.current
660
- };
661
- };
662
- const Ut = A(() => import("./index-Bu4XEiYU.js")), Zt = A(() => import("./index-DsrEcQq0.js")), zt = A(() => import("./index-BcpSqK0X.js"));
663
- function Bt({ markers: r, markerBoundsPadding: t = 1e-3, onClick: e, ...n }) {
664
- const { mapProvider: i, activeMarker: o, center: a, bounds: c, zoom: s } = Z(), [h, l] = U(c);
665
- ut(() => {
666
- const f = r.length > 0 ? r.map((_) => [_.latitude, _.longitude]) : [[a.latitude, a.longitude]], m = Ot(St(f));
667
- l(m);
668
- }, [r, a]);
669
- const u = P(() => typeof t == "number" ? {
670
- top: t,
671
- bottom: t,
672
- left: t,
673
- right: t
674
- } : t, [t]), p = P(
675
- () => ({
676
- points: r.map((f) => bt([f.longitude, f.latitude], f)),
677
- bounds: c,
678
- zoom: s,
679
- options: {
680
- radius: i.name === "google" && s > K ? pt : lt,
681
- minZoom: K,
682
- maxZoom: ht
683
- }
684
- }),
685
- [r, i, c, s]
686
- ), { clusters: d, supercluster: g } = Rt(p), M = (f) => {
687
- var m, _, E;
688
- if (!("properties" in f))
689
- throw new Error("Cluster does not have properties");
690
- if ((m = f.properties) != null && m.cluster && typeof ((_ = f.properties) == null ? void 0 : _.cluster_id) == "number") {
691
- e == null || e({
692
- id: `${f.properties.cluster_id}`,
693
- latitude: f.geometry.coordinates[1],
694
- longitude: f.geometry.coordinates[0],
695
- markers: ((E = g == null ? void 0 : g.getLeaves(f.properties.cluster_id)) == null ? void 0 : E.map((F) => F.properties)) ?? []
696
- });
697
- return;
698
- }
699
- e == null || e({
700
- id: f.properties.id,
701
- latitude: f.properties.latitude,
702
- longitude: f.properties.longitude,
703
- markers: [f.properties]
704
- });
705
- }, w = (f) => {
706
- var m;
707
- return !g || !o ? !1 : o.id === `${f}` ? !0 : ((m = g.getLeaves(f)) == null ? void 0 : m.find((_) => _.properties.id === o.id)) !== void 0;
708
- }, y = P(() => {
709
- switch (i == null ? void 0 : i.name) {
710
- case "maptiler":
711
- return Ut;
712
- case "google":
713
- return Zt;
714
- case "mapbox":
715
- return zt;
716
- default:
717
- return null;
718
- }
719
- }, [i]);
720
- return y ? /* @__PURE__ */ T(
721
- y,
722
- {
723
- clusters: d,
724
- markerBounds: h,
725
- markerBoundsPadding: u,
726
- onClick: M,
727
- doesSuperclusterContainActiveMarker: w,
728
- ...n
729
- }
730
- ) : null;
731
- }
732
- const Dt = A(() => import("./index-BhldVNew.js")), Ft = A(() => import("./index-B9YXnLOH.js")), Gt = A(() => import("./index-DFdfOz0d.js"));
733
- function Nt({ children: r, ...t }) {
734
- const { mapProvider: e } = Z(), n = P(() => {
735
- switch (e == null ? void 0 : e.name) {
736
- case "maptiler":
737
- return Dt;
738
- case "google":
739
- return Ft;
740
- case "mapbox":
741
- return Gt;
742
- default:
743
- return null;
744
- }
745
- }, [e]);
746
- return n ? /* @__PURE__ */ T(n, { ...t, children: r }) : null;
747
- }
748
- const $t = A(() => import("./index-CTk5bvm9.js")), jt = A(() => import("./index-UEadmVww.js")), It = A(() => import("./index-DVitM43i.js"));
749
- function Vt(r) {
750
- const { mapProvider: t } = Z(), e = P(() => {
751
- switch (t == null ? void 0 : t.name) {
752
- case "maptiler":
753
- return $t;
754
- case "google":
755
- return jt;
756
- case "mapbox":
757
- return It;
758
- default:
759
- return null;
760
- }
761
- }, [t]);
762
- return e ? /* @__PURE__ */ T(e, { ...r }) : null;
763
- }
764
- function Ht(r) {
765
- const [t, e] = U(r.zoom || R.zoom), [n, i] = U();
766
- return /* @__PURE__ */ T(et.Provider, { value: { ...r, bounds: n, setBounds: i, zoom: t, setZoom: e }, children: r.children });
767
- }
768
- const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
769
- __proto__: null,
770
- BaseMap: wt,
771
- CenterPin: Et,
772
- Layers: Vt,
773
- Markers: Bt,
774
- Popup: Nt,
775
- Root: Ht
776
- }, Symbol.toStringTag, { value: "Module" }));
777
- export {
778
- K as M,
779
- J as a,
780
- R as d,
781
- Wt as i,
782
- Z as u
783
- };