@local-logic/maps 0.0.9 → 0.0.10

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 (79) hide show
  1. package/dist/IconBase.es-rM5tt24D.js +48 -0
  2. package/dist/{index-BZ2605rA.js → index-9RZYMoMG.js} +1 -1
  3. package/dist/index-BCa658u4.js +24 -0
  4. package/dist/index-BOuko7CL.js +32 -0
  5. package/dist/index-BYlamtEc.js +96 -0
  6. package/dist/{index-CPq7k7F4.js → index-BsnsAUt5.js} +1 -1
  7. package/dist/index-BtwgeEEU.js +53 -0
  8. package/dist/index-CNxLnZ8O.js +23 -0
  9. package/dist/index-CR8t37Oz.js +73 -0
  10. package/dist/index-CRQ5kxRL.js +65 -0
  11. package/dist/{index-B43MtiHH.js → index-D5uhfwEH.js} +10 -9
  12. package/dist/index-DNKXUpkv.js +65 -0
  13. package/dist/index-DgHrPgsK.js +772 -0
  14. package/dist/index-DnsF5I7I.js +62 -0
  15. package/dist/index-Do_dW76Q.js +23 -0
  16. package/dist/index-JQfyhSrg.js +50 -0
  17. package/dist/index.es.js +1 -1
  18. package/dist/{index.modern-EsUgbhzI.js → index.modern-CLRs8JwI.js} +7 -7
  19. package/dist/index.umd.js +134 -146
  20. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -1
  21. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -1
  22. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -1
  23. package/dist/src/components/Map/Root/CenterPin/Google/index.d.ts +4 -0
  24. package/dist/src/components/Map/Root/CenterPin/Google/index.d.ts.map +1 -0
  25. package/dist/src/components/Map/Root/CenterPin/Mapbox/index.d.ts +4 -0
  26. package/dist/src/components/Map/Root/CenterPin/Mapbox/index.d.ts.map +1 -0
  27. package/dist/src/components/Map/Root/CenterPin/Maptiler/index.d.ts +4 -0
  28. package/dist/src/components/Map/Root/CenterPin/Maptiler/index.d.ts.map +1 -0
  29. package/dist/src/components/Map/Root/CenterPin/index.d.ts +4 -0
  30. package/dist/src/components/Map/Root/CenterPin/index.d.ts.map +1 -0
  31. package/dist/src/components/Map/Root/CenterPin/styles.d.ts +4 -0
  32. package/dist/src/components/Map/Root/CenterPin/styles.d.ts.map +1 -0
  33. package/dist/src/components/Map/Root/CenterPin/types.d.ts +6 -0
  34. package/dist/src/components/Map/Root/CenterPin/types.d.ts.map +1 -0
  35. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts +4 -3
  36. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts.map +1 -1
  37. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts +2 -1
  38. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts.map +1 -1
  39. package/dist/src/components/Map/Root/Markers/Google/index.d.ts +1 -1
  40. package/dist/src/components/Map/Root/Markers/Google/index.d.ts.map +1 -1
  41. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts +1 -1
  42. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts.map +1 -1
  43. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts +1 -1
  44. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts.map +1 -1
  45. package/dist/src/components/Map/Root/Markers/MarkerIcon/index.d.ts +6 -0
  46. package/dist/src/components/Map/Root/Markers/MarkerIcon/index.d.ts.map +1 -0
  47. package/dist/src/components/Map/Root/Markers/index.d.ts +1 -1
  48. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -1
  49. package/dist/src/components/Map/Root/Markers/styles.d.ts +2 -4
  50. package/dist/src/components/Map/Root/Markers/styles.d.ts.map +1 -1
  51. package/dist/src/components/Map/Root/Markers/types.d.ts +18 -9
  52. package/dist/src/components/Map/Root/Markers/types.d.ts.map +1 -1
  53. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts.map +1 -1
  54. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts.map +1 -1
  55. package/dist/src/components/Map/Root/constants.d.ts +3 -0
  56. package/dist/src/components/Map/Root/constants.d.ts.map +1 -1
  57. package/dist/src/components/Map/Root/context.d.ts +2 -0
  58. package/dist/src/components/Map/Root/context.d.ts.map +1 -1
  59. package/dist/src/components/Map/Root/index.d.ts +1 -0
  60. package/dist/src/components/Map/Root/index.d.ts.map +1 -1
  61. package/dist/src/components/Map/Root/types.d.ts +10 -0
  62. package/dist/src/components/Map/Root/types.d.ts.map +1 -1
  63. package/dist/src/components/Map/index.d.ts +2 -2
  64. package/dist/src/components/Map/index.d.ts.map +1 -1
  65. package/dist/src/components/Map/index.stories.d.ts.map +1 -1
  66. package/dist/src/components/Map/storybook-data.d.ts.map +1 -1
  67. package/dist/src/index.d.ts.map +1 -1
  68. package/dist/style.css +24 -1
  69. package/dist/styles-D2MYaLhP.js +47 -0
  70. package/package.json +5 -3
  71. package/dist/index-92HhWupr.js +0 -29
  72. package/dist/index-BF2kb4Y-.js +0 -42
  73. package/dist/index-C5-_i-6M.js +0 -64
  74. package/dist/index-CXjxZmYt.js +0 -144
  75. package/dist/index-CY0to_1B.js +0 -676
  76. package/dist/index-ChwN5abO.js +0 -29
  77. package/dist/index-CrIFr9oc.js +0 -47
  78. package/dist/index-D5-2anzJ.js +0 -29
  79. package/dist/index-J1MKzGEM.js +0 -31
@@ -0,0 +1,772 @@
1
+ import { jsx as T } from "react/jsx-runtime";
2
+ import * as B from "react";
3
+ import ot, { useContext as at, useMemo as v, lazy as _, useRef as V, useState as D, useEffect as ct } from "react";
4
+ const X = ot.createContext({}), Z = () => at(X), R = {
5
+ zoom: 14,
6
+ pitch: 0,
7
+ bearing: 0,
8
+ cooperativeGestures: !1
9
+ }, H = {
10
+ maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
11
+ mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
12
+ google: "a7ff20eb973126bb"
13
+ }, ut = 13, ht = 22, lt = 30, pt = "w-full h-full relative overflow-hidden", ft = _(() => import("./index-JQfyhSrg.js")), dt = _(() => import("./index-CR8t37Oz.js")), gt = _(() => import("./index-BtwgeEEU.js")), mt = _(() => import("./index-qqbvBkdn.js")), yt = ({ 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: u
22
+ } = Z(), s = v(() => {
23
+ switch (t == null ? void 0 : t.name) {
24
+ case "maptiler":
25
+ return ft;
26
+ case "google":
27
+ return dt;
28
+ case "mapbox":
29
+ return gt;
30
+ default:
31
+ return mt;
32
+ }
33
+ }, [t]);
34
+ return /* @__PURE__ */ T(
35
+ "div",
36
+ {
37
+ className: pt,
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) || H[t == null ? void 0 : t.name] || H.maptiler,
41
+ "data-zoom": n,
42
+ "data-pitch": i,
43
+ "data-bearing": o,
44
+ "data-cooperative-gestures": a,
45
+ "data-zoom-position": u,
46
+ "data-center-latitude": e.latitude,
47
+ "data-center-longitude": e.longitude,
48
+ children: /* @__PURE__ */ T(s, { children: r })
49
+ }
50
+ );
51
+ }, wt = _(() => import("./index-Do_dW76Q.js")), Mt = _(() => import("./index-BCa658u4.js")), _t = _(() => import("./index-CNxLnZ8O.js"));
52
+ function At(r) {
53
+ const { mapProvider: t } = Z(), e = v(() => {
54
+ switch (t == null ? void 0 : t.name) {
55
+ case "maptiler":
56
+ return wt;
57
+ case "google":
58
+ return Mt;
59
+ case "mapbox":
60
+ return _t;
61
+ default:
62
+ return null;
63
+ }
64
+ }, [t]);
65
+ return e ? /* @__PURE__ */ T(e, { ...r }) : null;
66
+ }
67
+ function tt(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 Et(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 (!J(r[0]) || !J(r[1]))
79
+ throw new Error("coordinates must contain numbers");
80
+ return tt({
81
+ type: "Point",
82
+ coordinates: r
83
+ }, t, e);
84
+ }
85
+ function bt(r, t, e = {}) {
86
+ return tt({
87
+ type: "MultiPoint",
88
+ coordinates: r
89
+ }, t, e);
90
+ }
91
+ function J(r) {
92
+ return !isNaN(r) && r !== null && !Array.isArray(r);
93
+ }
94
+ function et(r, t, e) {
95
+ if (r !== null)
96
+ for (var n, i, o, a, u, s, h, l = 0, c = 0, p, d = r.type, y = d === "FeatureCollection", f = d === "Feature", m = y ? r.features.length : 1, g = 0; g < m; g++) {
97
+ h = y ? r.features[g].geometry : f ? r.geometry : r, p = h ? h.type === "GeometryCollection" : !1, u = p ? h.geometries.length : 1;
98
+ for (var M = 0; M < u; M++) {
99
+ var w = 0, A = 0;
100
+ if (a = p ? h.geometries[M] : 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
+ c,
110
+ g,
111
+ w,
112
+ A
113
+ ) === !1)
114
+ return !1;
115
+ c++, w++;
116
+ break;
117
+ case "LineString":
118
+ case "MultiPoint":
119
+ for (n = 0; n < s.length; n++) {
120
+ if (t(
121
+ s[n],
122
+ c,
123
+ g,
124
+ w,
125
+ A
126
+ ) === !1)
127
+ return !1;
128
+ c++, E === "MultiPoint" && w++;
129
+ }
130
+ E === "LineString" && w++;
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
+ c,
139
+ g,
140
+ w,
141
+ A
142
+ ) === !1)
143
+ return !1;
144
+ c++;
145
+ }
146
+ E === "MultiLineString" && w++, E === "Polygon" && A++;
147
+ }
148
+ E === "Polygon" && w++;
149
+ break;
150
+ case "MultiPolygon":
151
+ for (n = 0; n < s.length; n++) {
152
+ for (A = 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
+ c,
157
+ g,
158
+ w,
159
+ A
160
+ ) === !1)
161
+ return !1;
162
+ c++;
163
+ }
164
+ A++;
165
+ }
166
+ w++;
167
+ }
168
+ break;
169
+ case "GeometryCollection":
170
+ for (n = 0; n < a.geometries.length; n++)
171
+ if (et(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 St(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 et(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 K = [
190
+ Int8Array,
191
+ Uint8Array,
192
+ Uint8ClampedArray,
193
+ Int16Array,
194
+ Uint16Array,
195
+ Int32Array,
196
+ Uint32Array,
197
+ Float32Array,
198
+ Float64Array
199
+ ], F = 1, L = 8;
200
+ class j {
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 !== F)
213
+ throw new Error(`Got v${i} data when expected v${F}.`);
214
+ const o = K[n & 15];
215
+ if (!o)
216
+ throw new Error("Unrecognized array type.");
217
+ const [a] = new Uint16Array(t, 2, 1), [u] = new Uint32Array(t, 4, 1);
218
+ return new j(u, 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 = K.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, u = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - u % 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 + u + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(L + a + u + s), this.ids = new this.IndexArrayType(this.data, L, t), this.coords = new this.ArrayType(this.data, L + u + s, t * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (F << 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 $(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: u } = this, s = [0, o.length - 1, 0], h = [];
265
+ for (; s.length; ) {
266
+ const l = s.pop() || 0, c = s.pop() || 0, p = s.pop() || 0;
267
+ if (c - p <= u) {
268
+ for (let m = p; m <= c; m++) {
269
+ const g = a[2 * m], M = a[2 * m + 1];
270
+ g >= t && g <= n && M >= e && M <= i && h.push(o[m]);
271
+ }
272
+ continue;
273
+ }
274
+ const d = p + c >> 1, y = a[2 * d], f = a[2 * d + 1];
275
+ y >= t && y <= n && f >= e && f <= i && h.push(o[d]), (l === 0 ? t <= y : e <= f) && (s.push(p), s.push(d - 1), s.push(1 - l)), (l === 0 ? n >= y : i >= f) && (s.push(d + 1), s.push(c), 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, u = [0, i.length - 1, 0], s = [], h = n * n;
289
+ for (; u.length; ) {
290
+ const l = u.pop() || 0, c = u.pop() || 0, p = u.pop() || 0;
291
+ if (c - p <= a) {
292
+ for (let m = p; m <= c; m++)
293
+ W(o[2 * m], o[2 * m + 1], t, e) <= h && s.push(i[m]);
294
+ continue;
295
+ }
296
+ const d = p + c >> 1, y = o[2 * d], f = o[2 * d + 1];
297
+ W(y, f, t, e) <= h && s.push(i[d]), (l === 0 ? t - n <= y : e - n <= f) && (u.push(p), u.push(d - 1), u.push(1 - l)), (l === 0 ? t + n >= y : e + n >= f) && (u.push(d + 1), u.push(c), u.push(1 - l));
298
+ }
299
+ return s;
300
+ }
301
+ }
302
+ function $(r, t, e, n, i, o) {
303
+ if (i - n <= e) return;
304
+ const a = n + i >> 1;
305
+ nt(r, t, a, n, i, o), $(r, t, e, n, a - 1, 1 - o), $(r, t, e, a + 1, i, 1 - o);
306
+ }
307
+ function nt(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, c = Math.log(h), p = 0.5 * Math.exp(2 * c / 3), d = 0.5 * Math.sqrt(c * p * (h - p) / h) * (l - h / 2 < 0 ? -1 : 1), y = Math.max(n, Math.floor(e - l * p / h + d)), f = Math.min(i, Math.floor(e + (h - l) * p / h + d));
311
+ nt(r, t, e, y, f, o);
312
+ }
313
+ const a = t[2 * e + o];
314
+ let u = n, s = i;
315
+ for (C(r, t, n, e), t[2 * i + o] > a && C(r, t, n, i); u < s; ) {
316
+ for (C(r, t, u, s), u++, s--; t[2 * u + o] < a; ) u++;
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 W(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
+ }, Y = Math.fround || /* @__PURE__ */ ((r) => (t) => (r[0] = +t, r[0]))(new Float32Array(1)), P = 2, S = 3, G = 4, b = 5, rt = 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, c] = h.geometry.coordinates, p = Y(U(l)), d = Y(z(c));
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 u = 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
+ u = this.trees[s] = this._createTree(this._cluster(u, s)), e && console.log("z%d: %d clusters in %dms", s, u.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 c = this.getClusters([n, i, 180, a], e), p = this.getClusters([-180, i, o, a], e);
402
+ return c.concat(p);
403
+ }
404
+ const u = this.trees[this._limitZoom(e)], s = u.range(U(n), z(a), U(o), z(i)), h = u.data, l = [];
405
+ for (const c of s) {
406
+ const p = this.stride * c;
407
+ l.push(h[p + b] > 1 ? q(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 u = 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, u), c = [];
417
+ for (const p of l) {
418
+ const d = p * this.stride;
419
+ a[d + G] === t && c.push(a[d + b] > 1 ? q(a, d, this.clusterProps) : this.points[a[d + S]]);
420
+ }
421
+ if (c.length === 0) throw new Error(i);
422
+ return c;
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: u } = this.options, s = u / a, h = (n - s) / o, l = (n + 1 + s) / o, c = {
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
+ c
440
+ ), e === 0 && this._addTileFeatures(
441
+ i.range(1 - s / o, h, 1, l),
442
+ i.data,
443
+ o,
444
+ n,
445
+ o,
446
+ c
447
+ ), e === o - 1 && this._addTileFeatures(
448
+ i.range(0, h, s / o, l),
449
+ i.data,
450
+ -1,
451
+ n,
452
+ o,
453
+ c
454
+ ), c.features.length ? c : 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 u of a) {
468
+ const s = u.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(u), t.length === n) break;
470
+ }
471
+ return o;
472
+ }
473
+ _createTree(t) {
474
+ const e = new j(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 u of t) {
480
+ const s = u * this.stride, h = e[s + b] > 1;
481
+ let l, c, p;
482
+ if (h)
483
+ l = st(e, s, this.clusterProps), c = e[s], p = e[s + 1];
484
+ else {
485
+ const f = this.points[e[s + S]];
486
+ l = f.properties;
487
+ const [m, g] = f.geometry.coordinates;
488
+ c = U(m), p = z(g);
489
+ }
490
+ const d = {
491
+ type: 1,
492
+ geometry: [[
493
+ Math.round(this.options.extent * (c * o - n)),
494
+ Math.round(this.options.extent * (p * o - i))
495
+ ]],
496
+ tags: l
497
+ };
498
+ let y;
499
+ h || this.options.generateId ? y = e[s + S] : y = this.points[e[s + S]].id, y !== void 0 && (d.id = y), 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, u = n / (i * Math.pow(2, e)), s = t.data, h = [], l = this.stride;
507
+ for (let c = 0; c < s.length; c += l) {
508
+ if (s[c + P] <= e) continue;
509
+ s[c + P] = e;
510
+ const p = s[c], d = s[c + 1], y = t.within(s[c], s[c + 1], u), f = s[c + b];
511
+ let m = f;
512
+ for (const g of y) {
513
+ const M = g * l;
514
+ s[M + P] > e && (m += s[M + b]);
515
+ }
516
+ if (m > f && m >= a) {
517
+ let g = p * f, M = d * f, w, A = -1;
518
+ const E = ((c / l | 0) << 5) + (e + 1) + this.points.length;
519
+ for (const it of y) {
520
+ const x = it * l;
521
+ if (s[x + P] <= e) continue;
522
+ s[x + P] = e;
523
+ const I = s[x + b];
524
+ g += s[x] * I, M += s[x + 1] * I, s[x + G] = E, o && (w || (w = this._map(s, c, !0), A = this.clusterProps.length, this.clusterProps.push(w)), o(w, this._map(s, x)));
525
+ }
526
+ s[c + G] = E, h.push(g / m, M / m, 1 / 0, E, -1, m), o && h.push(A);
527
+ } else {
528
+ for (let g = 0; g < l; g++) h.push(s[c + g]);
529
+ if (m > 1)
530
+ for (const g of y) {
531
+ const M = g * l;
532
+ if (!(s[M + P] <= e)) {
533
+ s[M + P] = e;
534
+ for (let w = 0; w < l; w++) h.push(s[M + w]);
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 + rt]];
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 q(r, t, e) {
559
+ return {
560
+ type: "Feature",
561
+ id: r[t + S],
562
+ properties: st(r, t, e),
563
+ geometry: {
564
+ type: "Point",
565
+ coordinates: [Ot(r[t]), Tt(r[t + 1])]
566
+ }
567
+ };
568
+ }
569
+ function st(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 + rt], 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 U(r) {
579
+ return r / 360 + 0.5;
580
+ }
581
+ function z(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 Ot(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 Q = Object.prototype.hasOwnProperty;
593
+ function k(r, t, e) {
594
+ for (e of r.keys())
595
+ if (O(e, t)) return e;
596
+ }
597
+ function O(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-- && O(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 = k(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 = k(t, i), !i) || !O(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 (Q.call(r, e) && ++n && !Q.call(t, e) || !(e in t) || !O(r[e], t[e])) return !1;
639
+ return Object.keys(t).length === n;
640
+ }
641
+ }
642
+ return r !== r && t !== t;
643
+ }
644
+ function vt(r) {
645
+ var t = B.useRef(r), e = B.useRef(0);
646
+ return O(r, t.current) || (t.current = r, e.current += 1), B.useMemo(function() {
647
+ return t.current;
648
+ }, [e.current]);
649
+ }
650
+ function Lt(r, t) {
651
+ return B.useEffect(r, vt(t));
652
+ }
653
+ var Ct = function(t) {
654
+ var e = t.points, n = t.bounds, i = t.zoom, o = t.options, a = t.disableRefresh, u = V(), s = V(), h = D([]), l = h[0], c = h[1], p = Math.round(i);
655
+ return Lt(function() {
656
+ a !== !0 && ((!u.current || !O(s.current, e) || !O(u.current.options, o)) && (u.current = new Pt(o), u.current.load(e)), n && c(u.current.getClusters(n, p)), s.current = e);
657
+ }, [e, n, p, o, a]), {
658
+ clusters: l,
659
+ supercluster: u.current
660
+ };
661
+ };
662
+ const Rt = _(() => import("./index-CRQ5kxRL.js")), Zt = _(() => import("./index-DnsF5I7I.js")), Ut = _(() => import("./index-DNKXUpkv.js"));
663
+ function zt({ markers: r, markerBoundsPadding: t = 1e-3, onClick: e, ...n }) {
664
+ const { mapProvider: i, center: o, bounds: a, zoom: u } = Z(), [s, h] = D(a);
665
+ ct(() => {
666
+ const f = r.length > 0 ? r.map((g) => [g.latitude, g.longitude]) : [[o.latitude, o.longitude]], m = St(bt(f));
667
+ h(m);
668
+ }, [r, o]);
669
+ const l = v(() => typeof t == "number" ? {
670
+ top: t,
671
+ bottom: t,
672
+ left: t,
673
+ right: t
674
+ } : t, [t]), { clusters: c, supercluster: p } = Ct({
675
+ points: r.map((f) => Et([f.longitude, f.latitude], f)),
676
+ bounds: a,
677
+ zoom: u,
678
+ options: { radius: lt, minZoom: ut, maxZoom: ht }
679
+ }), d = (f) => {
680
+ var m, g, M;
681
+ if (!("properties" in f))
682
+ throw new Error("Cluster does not have properties");
683
+ if ((m = f.properties) != null && m.cluster && typeof ((g = f.properties) == null ? void 0 : g.cluster_id) == "number") {
684
+ e == null || e({
685
+ id: `${f.properties.cluster_id}`,
686
+ latitude: f.geometry.coordinates[1],
687
+ longitude: f.geometry.coordinates[0],
688
+ markers: ((M = p == null ? void 0 : p.getLeaves(f.properties.cluster_id)) == null ? void 0 : M.map((w) => w.properties)) ?? []
689
+ });
690
+ return;
691
+ }
692
+ e == null || e({
693
+ id: f.properties.id,
694
+ latitude: f.properties.latitude,
695
+ longitude: f.properties.longitude,
696
+ markers: [f.properties]
697
+ });
698
+ }, y = v(() => {
699
+ switch (i == null ? void 0 : i.name) {
700
+ case "maptiler":
701
+ return Rt;
702
+ case "google":
703
+ return Zt;
704
+ case "mapbox":
705
+ return Ut;
706
+ default:
707
+ return null;
708
+ }
709
+ }, [i]);
710
+ return y ? /* @__PURE__ */ T(
711
+ y,
712
+ {
713
+ clusters: c,
714
+ markerBounds: s,
715
+ markerBoundsPadding: l,
716
+ onClick: d,
717
+ ...n
718
+ }
719
+ ) : null;
720
+ }
721
+ const Bt = _(() => import("./index-BOuko7CL.js")), Dt = _(() => import("./index-9RZYMoMG.js")), Ft = _(() => import("./index-D5uhfwEH.js"));
722
+ function Nt({ children: r, ...t }) {
723
+ const { mapProvider: e } = Z(), n = v(() => {
724
+ switch (e == null ? void 0 : e.name) {
725
+ case "maptiler":
726
+ return Bt;
727
+ case "google":
728
+ return Dt;
729
+ case "mapbox":
730
+ return Ft;
731
+ default:
732
+ return null;
733
+ }
734
+ }, [e]);
735
+ return n ? /* @__PURE__ */ T(n, { ...t, children: r }) : null;
736
+ }
737
+ const Gt = _(() => import("./index-CTk5bvm9.js")), $t = _(() => import("./index-BsnsAUt5.js")), jt = _(() => import("./index-DVitM43i.js"));
738
+ function It(r) {
739
+ const { mapProvider: t } = Z(), e = v(() => {
740
+ switch (t == null ? void 0 : t.name) {
741
+ case "maptiler":
742
+ return Gt;
743
+ case "google":
744
+ return $t;
745
+ case "mapbox":
746
+ return jt;
747
+ default:
748
+ return null;
749
+ }
750
+ }, [t]);
751
+ return e ? /* @__PURE__ */ T(e, { ...r }) : null;
752
+ }
753
+ function Vt(r) {
754
+ const [t, e] = D(r.zoom || R.zoom), [n, i] = D();
755
+ return /* @__PURE__ */ T(X.Provider, { value: { ...r, bounds: n, setBounds: i, zoom: t, setZoom: e }, children: r.children });
756
+ }
757
+ const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
758
+ __proto__: null,
759
+ BaseMap: yt,
760
+ CenterPin: At,
761
+ Layers: It,
762
+ Markers: zt,
763
+ Popup: Nt,
764
+ Root: Vt
765
+ }, Symbol.toStringTag, { value: "Module" }));
766
+ export {
767
+ ut as M,
768
+ H as a,
769
+ R as d,
770
+ Kt as i,
771
+ Z as u
772
+ };