@arenarium/maps 1.0.186 → 1.0.188

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.
@@ -0,0 +1,413 @@
1
+ var et = Object.defineProperty;
2
+ var nt = (c, g, u) => g in c ? et(c, g, { enumerable: !0, configurable: !0, writable: !0, value: u }) : c[g] = u;
3
+ var A = (c, g, u) => nt(c, typeof g != "symbol" ? g + "" : g, u);
4
+ var U;
5
+ ((c) => {
6
+ function g(u, h, l) {
7
+ const b = u / 2, N = h / 2, d = Math.sqrt(b * b + N * N), I = Math.atan(N / b) * (180 / Math.PI), s = l * (Math.PI / 180);
8
+ return l < 180 ? l < 90 ? l < I ? {
9
+ x: 0,
10
+ y: d * Math.sin(s) - N
11
+ } : {
12
+ x: d * Math.cos(s) - b,
13
+ y: 0
14
+ } : l < 180 - I ? {
15
+ x: d * Math.cos(s) - b,
16
+ y: 0
17
+ } : {
18
+ x: -u,
19
+ y: d * Math.sin(s) - N
20
+ } : l < 270 ? l < 180 + I ? {
21
+ x: -u,
22
+ y: d * Math.sin(s) - N
23
+ } : {
24
+ x: d * Math.cos(s) - b,
25
+ y: -h
26
+ } : l < 360 - I ? {
27
+ x: d * Math.cos(s) - b,
28
+ y: -h
29
+ } : {
30
+ x: 0,
31
+ y: d * Math.sin(s) - N
32
+ };
33
+ }
34
+ c.getOffsets = g;
35
+ })(U || (U = {}));
36
+ var L;
37
+ ((c) => {
38
+ function g(d, I, s) {
39
+ return {
40
+ x: h(I) * s,
41
+ y: l(d) * s
42
+ };
43
+ }
44
+ c.project = g;
45
+ function u(d, I, s) {
46
+ return {
47
+ lat: N(I / s),
48
+ lng: b(d / s)
49
+ };
50
+ }
51
+ c.unproject = u;
52
+ function h(d) {
53
+ return (180 + d) / 360;
54
+ }
55
+ function l(d) {
56
+ return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + d * Math.PI / 360))) / 360;
57
+ }
58
+ function b(d) {
59
+ return d * 360 - 180;
60
+ }
61
+ function N(d) {
62
+ return 360 / Math.PI * Math.atan(Math.exp((180 - d * 360) * Math.PI / 180)) - 90;
63
+ }
64
+ })(L || (L = {}));
65
+ var v;
66
+ ((c) => {
67
+ c.COUNT = 12, c.DEGREES = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330], c.DEGREES_DEFAULT = 270;
68
+ })(v || (v = {}));
69
+ var Z;
70
+ ((c) => {
71
+ const g = v.DEGREES.map((s) => s * Math.PI / 180), u = g.map((s) => Math.cos(s)), h = g.map((s) => Math.sin(s));
72
+ function l(s, m) {
73
+ const p = Math.abs(m / s);
74
+ return p < 1 ? p < 0.26795 ? 0 : 1 : p < 3.73205 ? 2 : 3;
75
+ }
76
+ function b(s, m) {
77
+ const p = l(s, m);
78
+ return s > 0 ? m > 0 ? (12 - p) % 12 : 0 + p : m > 0 ? 6 + p : 6 - p;
79
+ }
80
+ function N(s, m) {
81
+ return m == 0 ? s : ((s + m) % v.COUNT + v.COUNT) % v.COUNT;
82
+ }
83
+ function d(s) {
84
+ let m = !0;
85
+ for (let p = 0; p < s.length; p++) {
86
+ const E = s[p], S = E.particle, M = E.x, n = E.y, t = S.distX, e = S.distY, o = S.index, r = N(o, -1), i = N(o, 1), a = M + t * u[r], f = n + e * h[r], x = M + t * u[o], D = n + e * h[o], F = M + t * u[i], j = n + e * h[i];
87
+ let O = 0, w = 0, z = 0;
88
+ const T = E.neighbours;
89
+ for (let G = 0; G < T.length; G++) {
90
+ const k = T[G], C = k.particle, K = k.x, V = k.y, $ = C.distX, tt = C.distY, W = C.index, X = K + $ * u[W], Y = V + tt * h[W], _ = a - X, B = f - Y;
91
+ O += 1 / (_ * _ + B * B);
92
+ const H = x - X, q = D - Y;
93
+ w += 1 / (H * H + q * q);
94
+ const Q = F - X, J = j - Y;
95
+ z += 1 / (Q * Q + J * J);
96
+ }
97
+ let R = 0;
98
+ O < w && O < z && (R = -1), z < w && z < O && (R = 1), R != 0 && (S.index = N(o, R), m = !1);
99
+ }
100
+ return m;
101
+ }
102
+ c.updateAngleIndexes = d;
103
+ function I(s) {
104
+ for (let m = 0; m < s.length; m++) {
105
+ const p = s[m], E = p.x, S = p.y;
106
+ let M = 0, n = 0;
107
+ for (let t = 0; t < s.length; t++) {
108
+ const e = s[t], o = e.x, r = e.y, i = E - o, a = S - r;
109
+ if (i == 0 && a == 0) continue;
110
+ const f = Math.sqrt(i * i + a * a), x = 1 / (f * f);
111
+ M += x * i / f, n += -(x * a) / f;
112
+ }
113
+ p.particle.index = b(M, n);
114
+ }
115
+ }
116
+ c.initializeAngleIndexes = I;
117
+ })(Z || (Z = {}));
118
+ var P;
119
+ ((c) => {
120
+ function g(h, l) {
121
+ return !(h.x - h.distances.left > l.x + l.distances.right || h.x + h.distances.right < l.x - l.distances.left || h.y - h.distances.top > l.y + l.distances.bottom || h.y + h.distances.bottom < l.y - l.distances.top);
122
+ }
123
+ c.areOverlaping = g;
124
+ function u(h, l) {
125
+ let b = Math.abs(h.x - l.x), d = (h.x < l.x ? h.distances.right + l.distances.left : h.distances.left + l.distances.right) / b, I = Math.abs(h.y - l.y), m = (h.y < l.y ? h.distances.bottom + l.distances.top : h.distances.top + l.distances.bottom) / I, p = Math.min(d, m);
126
+ return Math.log2(p);
127
+ }
128
+ c.getZoomWhenTouching = u;
129
+ })(P || (P = {}));
130
+ var y;
131
+ ((c) => {
132
+ class g {
133
+ constructor() {
134
+ A(this, "zoomAfterExpanded");
135
+ A(this, "zoomAfterAngleIndexes");
136
+ this.zoomAfterExpanded = NaN, this.zoomAfterAngleIndexes = [];
137
+ }
138
+ }
139
+ c.State = g;
140
+ class u {
141
+ constructor(t) {
142
+ A(this, "min");
143
+ A(this, "max");
144
+ A(this, "scale");
145
+ A(this, "step");
146
+ this.min = t.zoomMin, this.max = t.zoomMax, this.scale = t.zoomScale, this.step = 1 / this.scale;
147
+ }
148
+ addSteps(t, e) {
149
+ return Math.round((t + e * this.step) * this.scale) / this.scale;
150
+ }
151
+ getIndex(t) {
152
+ if (!(t < this.min))
153
+ return Math.min(Math.ceil(t * this.scale), this.max * this.scale);
154
+ }
155
+ }
156
+ c.Zoom = u;
157
+ class h {
158
+ constructor(t, e, o) {
159
+ // PROPERTIES
160
+ /** The id of the tooltip that this tooltip represents. */
161
+ A(this, "id", "");
162
+ /** The index of the tooltip in the tooltips array. */
163
+ A(this, "index", NaN);
164
+ /** The rank of the tooltip tooltip. */
165
+ A(this, "rank", NaN);
166
+ /** The x coordinate of the tooltip anchor. */
167
+ A(this, "x", NaN);
168
+ /** The y coordinate of the tooltip anchor. */
169
+ A(this, "y", NaN);
170
+ /** The base width of the tooltip tooltip. */
171
+ A(this, "width", NaN);
172
+ /** The base height of the tooltip tooltip. */
173
+ A(this, "height", NaN);
174
+ // STATE
175
+ /** State of the tooltip expanded or not. */
176
+ A(this, "expanded", !0);
177
+ /** The scale of the tooltip. */
178
+ A(this, "scale", 1);
179
+ /** The angle of the tooltip. */
180
+ A(this, "angle", v.DEGREES_DEFAULT);
181
+ /** The neighbours of the tooltip. */
182
+ A(this, "neighbours", new Array());
183
+ // BOUNDS
184
+ //* Scaled distances to edges of the tooltip bounds */
185
+ A(this, "distances", { left: NaN, right: NaN, top: NaN, bottom: NaN });
186
+ // SIMULATION
187
+ /** A tooltip has a particle whose position is used to calculate the angle */
188
+ A(this, "particle", { index: v.DEGREES.indexOf(v.DEGREES_DEFAULT), distX: NaN, distY: NaN });
189
+ const r = L.project(e.lat, e.lng, t.mapSize);
190
+ this.index = o, this.id = e.id, this.rank = e.rank, this.x = r.x, this.y = r.y, this.width = e.width + 2 * e.margin, this.height = e.height + 2 * e.margin;
191
+ }
192
+ updateScale(t) {
193
+ t != this.scale && (this.scale = t, this.updateBounds(t, this.angle), this.updateParticle(t));
194
+ }
195
+ updateAngle(t) {
196
+ t != this.angle && (this.angle = t, this.updateBounds(this.scale, t));
197
+ }
198
+ updateBounds(t, e) {
199
+ const o = U.getOffsets(this.width, this.height, e), r = -o.x, i = this.width - r, a = -o.y, f = this.height - a, x = this.distances;
200
+ x.left = r / t, x.right = i / t, x.top = a / t, x.bottom = f / t;
201
+ }
202
+ updateParticle(t) {
203
+ this.particle.distX = this.width / 2 / t, this.particle.distY = this.height / 2 / t;
204
+ }
205
+ }
206
+ c.Tooltip = h;
207
+ function l(n, t) {
208
+ let e = new Array(t.length);
209
+ for (let o = 0; o < t.length; o++)
210
+ e[o] = new h(n, t[o], o);
211
+ return e;
212
+ }
213
+ c.createTooltips = l;
214
+ function b(n, t) {
215
+ let e = new Array(), o = 0;
216
+ for (let i = 0; i < n.length; i++)
217
+ e[i] = new Array();
218
+ const r = new Array(n.length);
219
+ for (let i = 0; i < n.length; i++) {
220
+ const a = n[i];
221
+ r[i] = {
222
+ x: a.x,
223
+ y: a.y,
224
+ distances: {
225
+ left: a.width,
226
+ right: a.width,
227
+ top: a.height,
228
+ bottom: a.height
229
+ }
230
+ };
231
+ }
232
+ for (let i = 0; i < n.length; i++) {
233
+ const a = n[i], f = r[i], x = e[i];
234
+ for (let D = i + 1; D < n.length; D++) {
235
+ const F = n[D], j = r[D], O = e[D], w = P.getZoomWhenTouching(f, j);
236
+ w > o && (o = w);
237
+ const z = t.getIndex(w);
238
+ if (z == null) continue;
239
+ const T = x[z], R = O[z];
240
+ T ? T.push(F) : x[z] = [F], R ? R.push(a) : O[z] = [a];
241
+ }
242
+ }
243
+ return {
244
+ maxZwt: o,
245
+ deltas: e
246
+ };
247
+ }
248
+ c.createTooltipsNeighbours = b;
249
+ function N(n) {
250
+ const t = /* @__PURE__ */ new Set(), e = [];
251
+ for (let o = 0; o < n.length; o++) {
252
+ let r = n[o];
253
+ if (r.expanded == !1 || r.neighbours.length == 0 || t.has(r)) continue;
254
+ t.add(r);
255
+ const i = [], a = [r];
256
+ for (; a.length > 0; ) {
257
+ const f = a.pop();
258
+ i.push(f);
259
+ for (const x of f.neighbours)
260
+ t.has(x) || (t.add(x), a.push(x));
261
+ }
262
+ e.push(i);
263
+ }
264
+ return e;
265
+ }
266
+ c.getNeighbourGraphs = N;
267
+ function d(n, t, e) {
268
+ for (let o = 0; o < n.length; o++) {
269
+ let r = n[o];
270
+ if (r.expanded == !1) {
271
+ r.neighbours.length = 0;
272
+ continue;
273
+ }
274
+ const a = t[o][e];
275
+ if (a != null)
276
+ for (let f = 0; f < a.length; f++) {
277
+ const x = a[f];
278
+ x.expanded != !1 && r.neighbours.push(x);
279
+ }
280
+ }
281
+ }
282
+ c.updateNeighbours = d;
283
+ function I(n) {
284
+ n.expanded = !1;
285
+ const t = n.neighbours;
286
+ for (let e = 0; e < t.length; e++) {
287
+ const o = t[e], r = o.neighbours.indexOf(n);
288
+ o.neighbours.splice(r, 1);
289
+ }
290
+ }
291
+ c.updateCollapsed = I;
292
+ function s(n, t, e) {
293
+ for (let o = 0; o < t.length; o++) {
294
+ const r = t[o];
295
+ if (r.expanded == !1) continue;
296
+ const i = n.get(r.id);
297
+ if (!i) throw new Error("Tooltip not found");
298
+ i.zoomAfterExpanded = e;
299
+ const a = v.DEGREES.indexOf(r.angle);
300
+ i.zoomAfterAngleIndexes.length == 0 ? i.zoomAfterAngleIndexes.push([e, a]) : i.zoomAfterAngleIndexes[0][1] != a ? i.zoomAfterAngleIndexes.unshift([e, a]) : i.zoomAfterAngleIndexes[0][0] = e;
301
+ }
302
+ }
303
+ c.updateStates = s;
304
+ function m(n, t) {
305
+ for (let e = 0; e < n.length; e++)
306
+ n[e].updateScale(t);
307
+ }
308
+ c.updateScale = m;
309
+ function p(n) {
310
+ const t = /* @__PURE__ */ new Set();
311
+ for (let e = 0; e < n.length; e++) {
312
+ const o = n[e], r = n[e].neighbours;
313
+ for (let i = 0; i < r.length; i++) {
314
+ const a = r[i];
315
+ P.areOverlaping(o, a) && (t.add(o), t.add(a));
316
+ }
317
+ }
318
+ return t;
319
+ }
320
+ c.getOverlaps = p;
321
+ function E(n, t) {
322
+ let e = !1;
323
+ for (let o = 0; o < t.length; o++) {
324
+ const r = t[o], i = t[o].neighbours;
325
+ for (let a = 0; a < i.length; a++) {
326
+ const f = i[a];
327
+ P.areOverlaping(r, f) && (n.has(r) || (n.add(r), e = !0), n.has(f) || (n.add(f), e = !0));
328
+ }
329
+ }
330
+ return e;
331
+ }
332
+ c.updateOverlaps = E;
333
+ function S(n) {
334
+ let t, e = 0;
335
+ for (let o = 0; o < n.length; o++) {
336
+ const r = n[o], i = n[o].neighbours;
337
+ let a = 0;
338
+ for (let f = 0; f < i.length; f++) {
339
+ const x = i[f];
340
+ P.areOverlaping(r, x) && (a += 1 + (x.rank - r.rank));
341
+ }
342
+ a = a * i.length, a > e && (e = a, t = r);
343
+ }
344
+ return t;
345
+ }
346
+ c.getOverlapsWorstTooltip = S;
347
+ function M(n) {
348
+ for (let t = 0; t < n.length; t++) {
349
+ const e = n[t];
350
+ for (let o = t + 1; o < n.length; o++) {
351
+ const r = n[o];
352
+ if (P.areOverlaping(e, r))
353
+ return !0;
354
+ }
355
+ }
356
+ return !1;
357
+ }
358
+ c.areOverlaping = M, ((n) => {
359
+ function t(r) {
360
+ Z.initializeAngleIndexes(r), o(r);
361
+ }
362
+ n.initializeAngles = t;
363
+ function e(r) {
364
+ const i = Z.updateAngleIndexes(r);
365
+ return o(r), i;
366
+ }
367
+ n.updateAngles = e;
368
+ function o(r) {
369
+ for (let i = 0; i < r.length; i++) {
370
+ const a = r[i];
371
+ a.updateAngle(v.DEGREES[a.particle.index]);
372
+ }
373
+ }
374
+ n.updateTooltips = o;
375
+ })(c.Particles || (c.Particles = {}));
376
+ })(y || (y = {}));
377
+ function st(c, g) {
378
+ const u = new y.Zoom(c);
379
+ if (g.length == 0) return [];
380
+ if (g.length == 1) return [[u.min, [[u.min, v.DEGREES.indexOf(v.DEGREES_DEFAULT)]]]];
381
+ const h = new Map(g.map((s) => [s.id, new y.State()])), l = y.createTooltips(c, g), b = y.createTooltipsNeighbours(l, u);
382
+ y.Particles.initializeAngles(l), y.updateStates(h, l, u.addSteps(u.max, 1));
383
+ const N = u.getIndex(b.maxZwt);
384
+ if (N == null) return Array.from(h.values()).map((s) => [s.zoomAfterExpanded, s.zoomAfterAngleIndexes]);
385
+ const d = u.min, I = N / u.scale;
386
+ for (let s = I; s >= d; s = u.addSteps(s, -1)) {
387
+ const m = Math.pow(2, s), p = Math.round(s * u.scale);
388
+ y.updateNeighbours(l, b.deltas, p);
389
+ const E = y.getNeighbourGraphs(l);
390
+ for (const S of E) {
391
+ y.updateScale(S, m);
392
+ const M = y.getOverlaps(S);
393
+ for (; M.size > 1; ) {
394
+ const n = Array.from(M);
395
+ for (; !(y.Particles.updateAngles(n) == !0 || y.areOverlaping(n) == !1); )
396
+ ;
397
+ if (y.updateOverlaps(M, n)) continue;
398
+ const e = y.getOverlapsWorstTooltip(n);
399
+ if (e == null) break;
400
+ y.updateCollapsed(e), M.delete(e);
401
+ }
402
+ }
403
+ y.updateStates(h, l, Number(s.toFixed(1)));
404
+ }
405
+ return Array.from(h.values()).map((s) => [s.zoomAfterExpanded, s.zoomAfterAngleIndexes]);
406
+ }
407
+ export {
408
+ v as A,
409
+ P as B,
410
+ L as M,
411
+ U as R,
412
+ st as g
413
+ };
@@ -0,0 +1 @@
1
+ "use strict";var K=Object.defineProperty;var V=(c,f,u)=>f in c?K(c,f,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[f]=u;var A=(c,f,u)=>V(c,typeof f!="symbol"?f+"":f,u);exports.Rectangle=void 0;(c=>{function f(u,h,l){const b=u/2,N=h/2,d=Math.sqrt(b*b+N*N),I=Math.atan(N/b)*(180/Math.PI),s=l*(Math.PI/180);return l<180?l<90?l<I?{x:0,y:d*Math.sin(s)-N}:{x:d*Math.cos(s)-b,y:0}:l<180-I?{x:d*Math.cos(s)-b,y:0}:{x:-u,y:d*Math.sin(s)-N}:l<270?l<180+I?{x:-u,y:d*Math.sin(s)-N}:{x:d*Math.cos(s)-b,y:-h}:l<360-I?{x:d*Math.cos(s)-b,y:-h}:{x:0,y:d*Math.sin(s)-N}}c.getOffsets=f})(exports.Rectangle||(exports.Rectangle={}));exports.Mercator=void 0;(c=>{function f(d,I,s){return{x:h(I)*s,y:l(d)*s}}c.project=f;function u(d,I,s){return{lat:N(I/s),lng:b(d/s)}}c.unproject=u;function h(d){return(180+d)/360}function l(d){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+d*Math.PI/360)))/360}function b(d){return d*360-180}function N(d){return 360/Math.PI*Math.atan(Math.exp((180-d*360)*Math.PI/180))-90}})(exports.Mercator||(exports.Mercator={}));exports.Angles=void 0;(c=>{c.COUNT=12,c.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],c.DEGREES_DEFAULT=270})(exports.Angles||(exports.Angles={}));var T;(c=>{const f=exports.Angles.DEGREES.map(s=>s*Math.PI/180),u=f.map(s=>Math.cos(s)),h=f.map(s=>Math.sin(s));function l(s,m){const p=Math.abs(m/s);return p<1?p<.26795?0:1:p<3.73205?2:3}function b(s,m){const p=l(s,m);return s>0?m>0?(12-p)%12:0+p:m>0?6+p:6-p}function N(s,m){return m==0?s:((s+m)%exports.Angles.COUNT+exports.Angles.COUNT)%exports.Angles.COUNT}function d(s){let m=!0;for(let p=0;p<s.length;p++){const v=s[p],S=v.particle,M=v.x,n=v.y,t=S.distX,e=S.distY,o=S.index,r=N(o,-1),i=N(o,1),a=M+t*u[r],g=n+e*h[r],x=M+t*u[o],z=n+e*h[o],P=M+t*u[i],F=n+e*h[i];let D=0,O=0,E=0;const R=v.neighbours;for(let Z=0;Z<R.length;Z++){const j=R[Z],G=j.particle,H=j.x,q=j.y,Q=G.distX,J=G.distY,C=G.index,B=H+Q*u[C],k=q+J*h[C],X=a-B,Y=g-k;D+=1/(X*X+Y*Y);const U=x-B,L=z-k;O+=1/(U*U+L*L);const W=P-B,_=F-k;E+=1/(W*W+_*_)}let w=0;D<O&&D<E&&(w=-1),E<O&&E<D&&(w=1),w!=0&&(S.index=N(o,w),m=!1)}return m}c.updateAngleIndexes=d;function I(s){for(let m=0;m<s.length;m++){const p=s[m],v=p.x,S=p.y;let M=0,n=0;for(let t=0;t<s.length;t++){const e=s[t],o=e.x,r=e.y,i=v-o,a=S-r;if(i==0&&a==0)continue;const g=Math.sqrt(i*i+a*a),x=1/(g*g);M+=x*i/g,n+=-(x*a)/g}p.particle.index=b(M,n)}}c.initializeAngleIndexes=I})(T||(T={}));exports.Bounds=void 0;(c=>{function f(h,l){return!(h.x-h.distances.left>l.x+l.distances.right||h.x+h.distances.right<l.x-l.distances.left||h.y-h.distances.top>l.y+l.distances.bottom||h.y+h.distances.bottom<l.y-l.distances.top)}c.areOverlaping=f;function u(h,l){let b=Math.abs(h.x-l.x),d=(h.x<l.x?h.distances.right+l.distances.left:h.distances.left+l.distances.right)/b,I=Math.abs(h.y-l.y),m=(h.y<l.y?h.distances.bottom+l.distances.top:h.distances.top+l.distances.bottom)/I,p=Math.min(d,m);return Math.log2(p)}c.getZoomWhenTouching=u})(exports.Bounds||(exports.Bounds={}));var y;(c=>{class f{constructor(){A(this,"zoomAfterExpanded");A(this,"zoomAfterAngleIndexes");this.zoomAfterExpanded=NaN,this.zoomAfterAngleIndexes=[]}}c.State=f;class u{constructor(t){A(this,"min");A(this,"max");A(this,"scale");A(this,"step");this.min=t.zoomMin,this.max=t.zoomMax,this.scale=t.zoomScale,this.step=1/this.scale}addSteps(t,e){return Math.round((t+e*this.step)*this.scale)/this.scale}getIndex(t){if(!(t<this.min))return Math.min(Math.ceil(t*this.scale),this.max*this.scale)}}c.Zoom=u;class h{constructor(t,e,o){A(this,"id","");A(this,"index",NaN);A(this,"rank",NaN);A(this,"x",NaN);A(this,"y",NaN);A(this,"width",NaN);A(this,"height",NaN);A(this,"expanded",!0);A(this,"scale",1);A(this,"angle",exports.Angles.DEGREES_DEFAULT);A(this,"neighbours",new Array);A(this,"distances",{left:NaN,right:NaN,top:NaN,bottom:NaN});A(this,"particle",{index:exports.Angles.DEGREES.indexOf(exports.Angles.DEGREES_DEFAULT),distX:NaN,distY:NaN});const r=exports.Mercator.project(e.lat,e.lng,t.mapSize);this.index=o,this.id=e.id,this.rank=e.rank,this.x=r.x,this.y=r.y,this.width=e.width+2*e.margin,this.height=e.height+2*e.margin}updateScale(t){t!=this.scale&&(this.scale=t,this.updateBounds(t,this.angle),this.updateParticle(t))}updateAngle(t){t!=this.angle&&(this.angle=t,this.updateBounds(this.scale,t))}updateBounds(t,e){const o=exports.Rectangle.getOffsets(this.width,this.height,e),r=-o.x,i=this.width-r,a=-o.y,g=this.height-a,x=this.distances;x.left=r/t,x.right=i/t,x.top=a/t,x.bottom=g/t}updateParticle(t){this.particle.distX=this.width/2/t,this.particle.distY=this.height/2/t}}c.Tooltip=h;function l(n,t){let e=new Array(t.length);for(let o=0;o<t.length;o++)e[o]=new h(n,t[o],o);return e}c.createTooltips=l;function b(n,t){let e=new Array,o=0;for(let i=0;i<n.length;i++)e[i]=new Array;const r=new Array(n.length);for(let i=0;i<n.length;i++){const a=n[i];r[i]={x:a.x,y:a.y,distances:{left:a.width,right:a.width,top:a.height,bottom:a.height}}}for(let i=0;i<n.length;i++){const a=n[i],g=r[i],x=e[i];for(let z=i+1;z<n.length;z++){const P=n[z],F=r[z],D=e[z],O=exports.Bounds.getZoomWhenTouching(g,F);O>o&&(o=O);const E=t.getIndex(O);if(E==null)continue;const R=x[E],w=D[E];R?R.push(P):x[E]=[P],w?w.push(a):D[E]=[a]}}return{maxZwt:o,deltas:e}}c.createTooltipsNeighbours=b;function N(n){const t=new Set,e=[];for(let o=0;o<n.length;o++){let r=n[o];if(r.expanded==!1||r.neighbours.length==0||t.has(r))continue;t.add(r);const i=[],a=[r];for(;a.length>0;){const g=a.pop();i.push(g);for(const x of g.neighbours)t.has(x)||(t.add(x),a.push(x))}e.push(i)}return e}c.getNeighbourGraphs=N;function d(n,t,e){for(let o=0;o<n.length;o++){let r=n[o];if(r.expanded==!1){r.neighbours.length=0;continue}const a=t[o][e];if(a!=null)for(let g=0;g<a.length;g++){const x=a[g];x.expanded!=!1&&r.neighbours.push(x)}}}c.updateNeighbours=d;function I(n){n.expanded=!1;const t=n.neighbours;for(let e=0;e<t.length;e++){const o=t[e],r=o.neighbours.indexOf(n);o.neighbours.splice(r,1)}}c.updateCollapsed=I;function s(n,t,e){for(let o=0;o<t.length;o++){const r=t[o];if(r.expanded==!1)continue;const i=n.get(r.id);if(!i)throw new Error("Tooltip not found");i.zoomAfterExpanded=e;const a=exports.Angles.DEGREES.indexOf(r.angle);i.zoomAfterAngleIndexes.length==0?i.zoomAfterAngleIndexes.push([e,a]):i.zoomAfterAngleIndexes[0][1]!=a?i.zoomAfterAngleIndexes.unshift([e,a]):i.zoomAfterAngleIndexes[0][0]=e}}c.updateStates=s;function m(n,t){for(let e=0;e<n.length;e++)n[e].updateScale(t)}c.updateScale=m;function p(n){const t=new Set;for(let e=0;e<n.length;e++){const o=n[e],r=n[e].neighbours;for(let i=0;i<r.length;i++){const a=r[i];exports.Bounds.areOverlaping(o,a)&&(t.add(o),t.add(a))}}return t}c.getOverlaps=p;function v(n,t){let e=!1;for(let o=0;o<t.length;o++){const r=t[o],i=t[o].neighbours;for(let a=0;a<i.length;a++){const g=i[a];exports.Bounds.areOverlaping(r,g)&&(n.has(r)||(n.add(r),e=!0),n.has(g)||(n.add(g),e=!0))}}return e}c.updateOverlaps=v;function S(n){let t,e=0;for(let o=0;o<n.length;o++){const r=n[o],i=n[o].neighbours;let a=0;for(let g=0;g<i.length;g++){const x=i[g];exports.Bounds.areOverlaping(r,x)&&(a+=1+(x.rank-r.rank))}a=a*i.length,a>e&&(e=a,t=r)}return t}c.getOverlapsWorstTooltip=S;function M(n){for(let t=0;t<n.length;t++){const e=n[t];for(let o=t+1;o<n.length;o++){const r=n[o];if(exports.Bounds.areOverlaping(e,r))return!0}}return!1}c.areOverlaping=M,(n=>{function t(r){T.initializeAngleIndexes(r),o(r)}n.initializeAngles=t;function e(r){const i=T.updateAngleIndexes(r);return o(r),i}n.updateAngles=e;function o(r){for(let i=0;i<r.length;i++){const a=r[i];a.updateAngle(exports.Angles.DEGREES[a.particle.index])}}n.updateTooltips=o})(c.Particles||(c.Particles={}))})(y||(y={}));function $(c,f){const u=new y.Zoom(c);if(f.length==0)return[];if(f.length==1)return[[u.min,[[u.min,exports.Angles.DEGREES.indexOf(exports.Angles.DEGREES_DEFAULT)]]]];const h=new Map(f.map(s=>[s.id,new y.State])),l=y.createTooltips(c,f),b=y.createTooltipsNeighbours(l,u);y.Particles.initializeAngles(l),y.updateStates(h,l,u.addSteps(u.max,1));const N=u.getIndex(b.maxZwt);if(N==null)return Array.from(h.values()).map(s=>[s.zoomAfterExpanded,s.zoomAfterAngleIndexes]);const d=u.min,I=N/u.scale;for(let s=I;s>=d;s=u.addSteps(s,-1)){const m=Math.pow(2,s),p=Math.round(s*u.scale);y.updateNeighbours(l,b.deltas,p);const v=y.getNeighbourGraphs(l);for(const S of v){y.updateScale(S,m);const M=y.getOverlaps(S);for(;M.size>1;){const n=Array.from(M);for(;!(y.Particles.updateAngles(n)==!0||y.areOverlaping(n)==!1););if(y.updateOverlaps(M,n))continue;const e=y.getOverlapsWorstTooltip(n);if(e==null)break;y.updateCollapsed(e),M.delete(e)}}y.updateStates(h,l,Number(s.toFixed(1)))}return Array.from(h.values()).map(s=>[s.zoomAfterExpanded,s.zoomAfterAngleIndexes])}exports.getStates=$;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arenarium/maps",
3
- "version": "1.0.186",
3
+ "version": "1.0.188",
4
4
  "license": "MIT",
5
5
  "author": "arenarium.dev",
6
6
  "description": "Visualize complex map markers clearly.",
@@ -68,12 +68,12 @@
68
68
  "devDependencies": {
69
69
  "@rollup/plugin-typescript": "^12.1.4",
70
70
  "@sveltejs/adapter-auto": "^6.0.1",
71
- "@sveltejs/kit": "^2.25.1",
71
+ "@sveltejs/kit": "^2.26.1",
72
72
  "@sveltejs/package": "^2.4.0",
73
73
  "@sveltejs/vite-plugin-svelte": "^5.1.1",
74
- "@types/node": "^24.0.15",
74
+ "@types/node": "^24.1.0",
75
75
  "dts-bundle-generator": "^9.5.1",
76
- "eslint": "^9.31.0",
76
+ "eslint": "^9.32.0",
77
77
  "eslint-config-prettier": "^10.1.8",
78
78
  "eslint-plugin-svelte": "^3.11.0",
79
79
  "globals": "^16.3.0",
@@ -81,10 +81,10 @@
81
81
  "prettier": "^3.6.2",
82
82
  "prettier-plugin-svelte": "^3.4.0",
83
83
  "publint": "^0.3.12",
84
- "svelte": "^5.36.8",
84
+ "svelte": "^5.36.17",
85
85
  "svelte-check": "^4.3.0",
86
86
  "typescript": "^5.8.3",
87
- "typescript-eslint": "^8.37.0",
87
+ "typescript-eslint": "^8.38.0",
88
88
  "vite": "^6.3.5",
89
89
  "vite-plugin-dts": "^4.5.4"
90
90
  },