open-plant 1.2.6 → 1.2.8
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.
- package/README.md +7 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1233 -1203
- package/dist/index.js.map +1 -1
- package/dist/types/react/draw-layer.d.ts +12 -1
- package/dist/types/react/draw-layer.d.ts.map +1 -1
- package/dist/types/react/wsi-viewer-canvas.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (e, t, n) =>
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useRef as
|
|
6
|
-
function
|
|
1
|
+
var rr = Object.defineProperty;
|
|
2
|
+
var ir = (e, t, n) => t in e ? rr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var b = (e, t, n) => ir(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as Ft, jsxs as mn, Fragment as or } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as j, useMemo as tt, useCallback as B, useEffect as X, useState as Jt } from "react";
|
|
6
|
+
function gn(e, t, n) {
|
|
7
7
|
const r = e.createShader(t);
|
|
8
8
|
if (!r)
|
|
9
9
|
throw new Error("Failed to create shader.");
|
|
@@ -13,8 +13,8 @@ function mn(e, t, n) {
|
|
|
13
13
|
}
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const r =
|
|
16
|
+
function sr(e, t, n) {
|
|
17
|
+
const r = gn(e, e.VERTEX_SHADER, t), i = gn(e, e.FRAGMENT_SHADER, n), o = e.createProgram();
|
|
18
18
|
if (!o)
|
|
19
19
|
throw e.deleteShader(r), e.deleteShader(i), new Error("Failed to create program.");
|
|
20
20
|
if (e.attachShader(o, r), e.attachShader(o, i), e.linkProgram(o), e.deleteShader(r), e.deleteShader(i), !e.getProgramParameter(o, e.LINK_STATUS)) {
|
|
@@ -29,7 +29,7 @@ function _e(e, t, n) {
|
|
|
29
29
|
throw new Error(`Failed to get uniform location: ${n}`);
|
|
30
30
|
return r;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ar(e) {
|
|
33
33
|
const t = e.getContext("webgl2", {
|
|
34
34
|
alpha: !1,
|
|
35
35
|
antialias: !1,
|
|
@@ -42,7 +42,7 @@ function sr(e) {
|
|
|
42
42
|
throw new Error("WebGL2 is not available.");
|
|
43
43
|
return t;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let ur = class {
|
|
46
46
|
constructor() {
|
|
47
47
|
b(this, "viewportWidth", 1);
|
|
48
48
|
b(this, "viewportHeight", 1);
|
|
@@ -82,7 +82,7 @@ let ar = class {
|
|
|
82
82
|
]);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
const
|
|
85
|
+
const cr = `#version 300 es
|
|
86
86
|
precision highp float;
|
|
87
87
|
|
|
88
88
|
in vec2 aUnit;
|
|
@@ -102,7 +102,7 @@ void main() {
|
|
|
102
102
|
gl_Position = vec4(clip.xy, 0.0, 1.0);
|
|
103
103
|
vUv = aUv;
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
105
|
+
`, lr = `#version 300 es
|
|
106
106
|
precision highp float;
|
|
107
107
|
|
|
108
108
|
in vec2 vUv;
|
|
@@ -114,11 +114,11 @@ void main() {
|
|
|
114
114
|
outColor = texture(uTexture, vUv);
|
|
115
115
|
}
|
|
116
116
|
`;
|
|
117
|
-
class
|
|
117
|
+
class hr {
|
|
118
118
|
constructor(t) {
|
|
119
119
|
b(this, "canvas");
|
|
120
120
|
b(this, "gl");
|
|
121
|
-
b(this, "camera", new
|
|
121
|
+
b(this, "camera", new ur());
|
|
122
122
|
b(this, "imageWidth");
|
|
123
123
|
b(this, "imageHeight");
|
|
124
124
|
b(this, "clearColor");
|
|
@@ -135,7 +135,7 @@ class lr {
|
|
|
135
135
|
b(this, "destroyed", !1);
|
|
136
136
|
b(this, "fitted", !1);
|
|
137
137
|
b(this, "controlledViewState", !1);
|
|
138
|
-
this.canvas = t.canvas, this.imageWidth = Math.max(1, t.imageWidth), this.imageHeight = Math.max(1, t.imageHeight), this.clearColor = t.clearColor ?? [0.03, 0.05, 0.08, 1], this.gl =
|
|
138
|
+
this.canvas = t.canvas, this.imageWidth = Math.max(1, t.imageWidth), this.imageHeight = Math.max(1, t.imageHeight), this.clearColor = t.clearColor ?? [0.03, 0.05, 0.08, 1], this.gl = ar(this.canvas), this.program = sr(this.gl, cr, lr);
|
|
139
139
|
const n = this.gl.createVertexArray(), r = this.gl.createBuffer();
|
|
140
140
|
if (!n || !r)
|
|
141
141
|
throw new Error("Failed to create WebGL buffers.");
|
|
@@ -310,16 +310,16 @@ class lr {
|
|
|
310
310
|
this.gl.deleteTexture(n.texture);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
const
|
|
313
|
+
const fr = 0.1, dr = 4e6, mr = 4096, gr = 64, Un = 1e-6, pr = 24;
|
|
314
314
|
function Ne(e, t, n) {
|
|
315
315
|
return Math.max(t, Math.min(n, e));
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function Wt(e) {
|
|
318
318
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
319
319
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
320
320
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function br(e) {
|
|
323
323
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
324
324
|
const t = [];
|
|
325
325
|
for (const n of e) {
|
|
@@ -331,7 +331,7 @@ function pr(e) {
|
|
|
331
331
|
}
|
|
332
332
|
return t;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function wr(e, t, n) {
|
|
335
335
|
if (t <= Un || n < 8) return [];
|
|
336
336
|
const r = [];
|
|
337
337
|
for (let i = 0; i <= n; i += 1) {
|
|
@@ -341,39 +341,39 @@ function br(e, t, n) {
|
|
|
341
341
|
e[1] + Math.sin(o) * t
|
|
342
342
|
]);
|
|
343
343
|
}
|
|
344
|
-
return
|
|
344
|
+
return Wt(r);
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Be(e, t) {
|
|
347
347
|
if (!e.length) return [];
|
|
348
348
|
let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
|
|
349
349
|
for (const [a, u] of e)
|
|
350
350
|
a < n && (n = a), a > i && (i = a), u < r && (r = u), u > o && (o = u);
|
|
351
351
|
if (!Number.isFinite(n) || !Number.isFinite(r)) return [];
|
|
352
352
|
const s = Math.max(t, 1);
|
|
353
|
-
return
|
|
353
|
+
return Wt([
|
|
354
354
|
[n - s, r - s],
|
|
355
355
|
[i + s, r - s],
|
|
356
356
|
[i + s, o + s],
|
|
357
357
|
[n - s, o + s]
|
|
358
358
|
]);
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function yr(e, t) {
|
|
361
361
|
let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
|
|
362
362
|
for (const [a, u] of e)
|
|
363
363
|
a < n && (n = a), a > i && (i = a), u < r && (r = u), u > o && (o = u);
|
|
364
364
|
const s = Math.max(t, 1);
|
|
365
365
|
return [n - s, r - s, i + s, o + s];
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function xr(e, t, n) {
|
|
368
368
|
const r = Math.max(
|
|
369
|
-
|
|
369
|
+
fr,
|
|
370
370
|
Number(n.minRasterStep) || 0
|
|
371
371
|
), i = Math.max(
|
|
372
372
|
32768,
|
|
373
|
-
Math.floor(n.maxRasterPixels ||
|
|
373
|
+
Math.floor(n.maxRasterPixels || dr)
|
|
374
374
|
), o = Math.max(
|
|
375
375
|
256,
|
|
376
|
-
Math.floor(n.maxRasterSize ||
|
|
376
|
+
Math.floor(n.maxRasterSize || mr)
|
|
377
377
|
), s = Math.max(1e-3, e[2] - e[0]), a = Math.max(1e-3, e[3] - e[1]);
|
|
378
378
|
let u = Math.max(r, Number.EPSILON), c = 3, h = Math.ceil(s / u) + c * 2 + 1, g = Math.ceil(a / u) + c * 2 + 1;
|
|
379
379
|
for (; (h > o || g > o || h * g > i) && (u *= 1.15, h = Math.ceil(s / u) + c * 2 + 1, g = Math.ceil(a / u) + c * 2 + 1, !(u > Math.max(s, a))); )
|
|
@@ -387,7 +387,7 @@ function yr(e, t, n) {
|
|
|
387
387
|
height: g
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Sr(e, t) {
|
|
391
391
|
if (typeof OffscreenCanvas < "u") {
|
|
392
392
|
const r = new OffscreenCanvas(e, t).getContext("2d", { willReadFrequently: !0 });
|
|
393
393
|
if (r) return r;
|
|
@@ -398,17 +398,17 @@ function xr(e, t) {
|
|
|
398
398
|
}
|
|
399
399
|
return null;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function Tr(e, t) {
|
|
402
402
|
return [
|
|
403
403
|
(e[0] - t.minX) / t.step + t.padding,
|
|
404
404
|
(e[1] - t.minY) / t.step + t.padding
|
|
405
405
|
];
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
const r =
|
|
407
|
+
function Mr(e, t, n) {
|
|
408
|
+
const r = Sr(n.width, n.height);
|
|
409
409
|
if (!r) return new Uint8Array(0);
|
|
410
410
|
r.clearRect(0, 0, n.width, n.height), r.fillStyle = "#ffffff", r.strokeStyle = "#ffffff", r.lineCap = "round", r.lineJoin = "round", r.lineWidth = t * 2 / n.step;
|
|
411
|
-
const i = e.map((a) =>
|
|
411
|
+
const i = e.map((a) => Tr(a, n));
|
|
412
412
|
if (i.length <= 1) {
|
|
413
413
|
const a = i[0];
|
|
414
414
|
if (!a) return new Uint8Array(0);
|
|
@@ -421,10 +421,10 @@ function Tr(e, t, n) {
|
|
|
421
421
|
}
|
|
422
422
|
const o = r.getImageData(0, 0, n.width, n.height), s = new Uint8Array(n.width * n.height);
|
|
423
423
|
for (let a = 0; a < s.length; a += 1)
|
|
424
|
-
s[a] = o.data[a * 4 + 3] >=
|
|
424
|
+
s[a] = o.data[a * 4 + 3] >= pr ? 1 : 0;
|
|
425
425
|
return s;
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function Ar(e, t, n) {
|
|
428
428
|
const r = [], i = t + 1, o = (a, u) => u * i + a, s = (a, u) => a >= 0 && u >= 0 && a < t && u < n && e[u * t + a] > 0;
|
|
429
429
|
for (let a = 0; a < n; a += 1)
|
|
430
430
|
for (let u = 0; u < t; u += 1)
|
|
@@ -447,11 +447,11 @@ function Mr(e, t, n) {
|
|
|
447
447
|
}));
|
|
448
448
|
return r;
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function Pr(e, t) {
|
|
451
451
|
const n = (t - e + 4) % 4;
|
|
452
452
|
return n === 1 ? 0 : n === 0 ? 1 : n === 3 ? 2 : 3;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function Rr(e) {
|
|
455
455
|
if (!e.length) return [];
|
|
456
456
|
const t = /* @__PURE__ */ new Map();
|
|
457
457
|
for (let i = 0; i < e.length; i += 1) {
|
|
@@ -470,22 +470,22 @@ function Pr(e) {
|
|
|
470
470
|
for (; a !== s && h < g; ) {
|
|
471
471
|
const d = t.get(a);
|
|
472
472
|
if (!d || d.length === 0) break;
|
|
473
|
-
let
|
|
474
|
-
for (const
|
|
475
|
-
if (n[
|
|
476
|
-
const
|
|
477
|
-
|
|
473
|
+
let p = -1, x = 1 / 0;
|
|
474
|
+
for (const P of d) {
|
|
475
|
+
if (n[P]) continue;
|
|
476
|
+
const k = e[P], v = Pr(u, k.dir);
|
|
477
|
+
v < x && (x = v, p = P);
|
|
478
478
|
}
|
|
479
|
-
if (
|
|
480
|
-
n[
|
|
481
|
-
const
|
|
482
|
-
a =
|
|
479
|
+
if (p < 0) break;
|
|
480
|
+
n[p] = 1;
|
|
481
|
+
const S = e[p];
|
|
482
|
+
a = S.end, u = S.dir, c.push(a), h += 1;
|
|
483
483
|
}
|
|
484
484
|
c.length >= 4 && c[0] === c[c.length - 1] && r.push(c);
|
|
485
485
|
}
|
|
486
486
|
return r;
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function Er(e, t, n) {
|
|
489
489
|
const r = t + 1, i = [];
|
|
490
490
|
for (const o of e) {
|
|
491
491
|
const s = o % r, a = Math.floor(o / r);
|
|
@@ -494,9 +494,9 @@ function vr(e, t, n) {
|
|
|
494
494
|
n.minY + (a - n.padding) * n.step
|
|
495
495
|
]);
|
|
496
496
|
}
|
|
497
|
-
return
|
|
497
|
+
return Wt(i);
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function vr(e) {
|
|
500
500
|
if (e.length < 4) return 0;
|
|
501
501
|
let t = 0;
|
|
502
502
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -505,17 +505,17 @@ function Rr(e) {
|
|
|
505
505
|
}
|
|
506
506
|
return t * 0.5;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
const n =
|
|
508
|
+
function Cr(e, t = 1e-9) {
|
|
509
|
+
const n = Wt(e);
|
|
510
510
|
if (n.length < 5) return n;
|
|
511
511
|
const r = [n[0]];
|
|
512
512
|
for (let i = 1; i < n.length - 1; i += 1) {
|
|
513
513
|
const o = r[r.length - 1], s = n[i], a = n[i + 1], u = (s[0] - o[0]) * (a[1] - s[1]) - (s[1] - o[1]) * (a[0] - s[0]);
|
|
514
514
|
Math.abs(u) <= t || r.push(s);
|
|
515
515
|
}
|
|
516
|
-
return r.push(r[0]),
|
|
516
|
+
return r.push(r[0]), Wt(r);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Ir(e, t, n) {
|
|
519
519
|
const r = n[0] - t[0], i = n[1] - t[1], o = r * r + i * i;
|
|
520
520
|
if (o <= 1e-12) {
|
|
521
521
|
const g = e[0] - t[0], d = e[1] - t[1];
|
|
@@ -528,7 +528,7 @@ function Cr(e, t, n) {
|
|
|
528
528
|
), a = t[0] + r * s, u = t[1] + i * s, c = e[0] - a, h = e[1] - u;
|
|
529
529
|
return c * c + h * h;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function _r(e, t) {
|
|
532
532
|
if (e.length <= 2 || t <= 0) return e.slice();
|
|
533
533
|
const n = new Uint8Array(e.length);
|
|
534
534
|
n[0] = 1, n[e.length - 1] = 1;
|
|
@@ -540,7 +540,7 @@ function Ir(e, t) {
|
|
|
540
540
|
if (u - a <= 1) continue;
|
|
541
541
|
let c = 0, h = -1;
|
|
542
542
|
for (let g = a + 1; g < u; g += 1) {
|
|
543
|
-
const d =
|
|
543
|
+
const d = Ir(e[g], e[a], e[u]);
|
|
544
544
|
d > c && (c = d, h = g);
|
|
545
545
|
}
|
|
546
546
|
h >= 0 && c > r && (n[h] = 1, i.push([a, h], [h, u]));
|
|
@@ -550,62 +550,62 @@ function Ir(e, t) {
|
|
|
550
550
|
n[s] && o.push(e[s]);
|
|
551
551
|
return o;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
554
|
-
const n =
|
|
553
|
+
function Br(e, t) {
|
|
554
|
+
const n = Wt(e);
|
|
555
555
|
if (n.length < 5 || t <= 0) return n;
|
|
556
|
-
const r = n.slice(0, -1), i =
|
|
557
|
-
return i.length < 3 ? n :
|
|
556
|
+
const r = n.slice(0, -1), i = _r(r, t);
|
|
557
|
+
return i.length < 3 ? n : Wt(i);
|
|
558
558
|
}
|
|
559
559
|
function ie(e, t) {
|
|
560
|
-
return t ?
|
|
560
|
+
return t ? Wt(
|
|
561
561
|
e.map(([n, r]) => [
|
|
562
562
|
Ne(n, t[0], t[2]),
|
|
563
563
|
Ne(r, t[1], t[3])
|
|
564
564
|
])
|
|
565
565
|
) : e;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
const n =
|
|
567
|
+
function Ur(e, t) {
|
|
568
|
+
const n = br(e), r = Math.max(Un, Number(t.radius) || 0);
|
|
569
569
|
if (n.length === 0 || !Number.isFinite(r)) return [];
|
|
570
|
-
const i = Math.max(12, Math.floor(t.circleSides ||
|
|
570
|
+
const i = Math.max(12, Math.floor(t.circleSides || gr));
|
|
571
571
|
if (n.length === 1)
|
|
572
572
|
return ie(
|
|
573
|
-
|
|
573
|
+
wr(n[0], r, i),
|
|
574
574
|
t.clipBounds
|
|
575
575
|
);
|
|
576
|
-
const o =
|
|
576
|
+
const o = yr(n, r), s = xr(o, r, t), a = Mr(n, r, s);
|
|
577
577
|
if (!a.length)
|
|
578
|
-
return ie(
|
|
579
|
-
const u =
|
|
578
|
+
return ie(Be(n, r), t.clipBounds);
|
|
579
|
+
const u = Ar(a, s.width, s.height), c = Rr(u);
|
|
580
580
|
if (!c.length)
|
|
581
|
-
return ie(
|
|
581
|
+
return ie(Be(n, r), t.clipBounds);
|
|
582
582
|
let h = [], g = 0;
|
|
583
|
-
for (const
|
|
584
|
-
const
|
|
585
|
-
|
|
583
|
+
for (const x of c) {
|
|
584
|
+
const S = Er(x, s.width, s), P = Math.abs(vr(S));
|
|
585
|
+
P <= g || (g = P, h = S);
|
|
586
586
|
}
|
|
587
587
|
if (!h.length)
|
|
588
|
-
return ie(
|
|
589
|
-
const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : s.step * 0.2,
|
|
590
|
-
|
|
588
|
+
return ie(Be(n, r), t.clipBounds);
|
|
589
|
+
const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : s.step * 0.2, p = Br(
|
|
590
|
+
Cr(h, s.step * 1e-3),
|
|
591
591
|
d
|
|
592
592
|
);
|
|
593
|
-
return ie(
|
|
593
|
+
return ie(p, t.clipBounds);
|
|
594
594
|
}
|
|
595
|
-
const
|
|
595
|
+
const Fn = [
|
|
596
596
|
160,
|
|
597
597
|
160,
|
|
598
598
|
160,
|
|
599
599
|
255
|
|
600
600
|
];
|
|
601
|
-
function
|
|
601
|
+
function it(e, t, n) {
|
|
602
602
|
return Math.max(t, Math.min(n, e));
|
|
603
603
|
}
|
|
604
604
|
function zn(e, t, n) {
|
|
605
605
|
const r = Number(e), i = Number(t), o = Number(n);
|
|
606
606
|
return !Number.isFinite(r) || r <= 0 ? 1 : !Number.isFinite(i) || !Number.isFinite(o) ? r : Math.pow(2, i - o) * r;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function ho(e, t, n) {
|
|
609
609
|
let i = 100 * zn(e, t, n);
|
|
610
610
|
if (Number(e)) {
|
|
611
611
|
let o = "μm";
|
|
@@ -613,10 +613,10 @@ function io(e, t, n) {
|
|
|
613
613
|
}
|
|
614
614
|
return `${Math.round(i * 1e3) / 1e3} pixels`;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function fo(e, t) {
|
|
617
617
|
return !e && !t ? !0 : !e || !t ? !1 : Math.abs((e.zoom ?? 0) - (t.zoom ?? 0)) < 1e-6 && Math.abs((e.offsetX ?? 0) - (t.offsetX ?? 0)) < 1e-6 && Math.abs((e.offsetY ?? 0) - (t.offsetY ?? 0)) < 1e-6 && Math.abs((e.rotationDeg ?? 0) - (t.rotationDeg ?? 0)) < 1e-6;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function mo(e) {
|
|
620
620
|
const t = String(e ?? "").trim();
|
|
621
621
|
if (!t) return "";
|
|
622
622
|
if (/^bearer\s+/i.test(t)) {
|
|
@@ -625,26 +625,26 @@ function so(e) {
|
|
|
625
625
|
}
|
|
626
626
|
return `Bearer ${t}`;
|
|
627
627
|
}
|
|
628
|
-
function
|
|
628
|
+
function Fr(e) {
|
|
629
629
|
const n = String(e ?? "").trim().match(/^#?([0-9a-fA-F]{6})$/);
|
|
630
|
-
if (!n) return [...
|
|
630
|
+
if (!n) return [...Fn];
|
|
631
631
|
const r = Number.parseInt(n[1], 16);
|
|
632
632
|
return [r >> 16 & 255, r >> 8 & 255, r & 255, 255];
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function go(e) {
|
|
635
635
|
const t = [
|
|
636
|
-
[...
|
|
636
|
+
[...Fn]
|
|
637
637
|
], n = /* @__PURE__ */ new Map();
|
|
638
638
|
for (const i of e ?? []) {
|
|
639
639
|
const o = String(i?.termId ?? "");
|
|
640
|
-
!o || n.has(o) || (n.set(o, t.length), t.push(
|
|
640
|
+
!o || n.has(o) || (n.set(o, t.length), t.push(Fr(i?.termColor)));
|
|
641
641
|
}
|
|
642
642
|
const r = new Uint8Array(t.length * 4);
|
|
643
643
|
for (let i = 0; i < t.length; i += 1)
|
|
644
644
|
r[i * 4] = t[i][0], r[i * 4 + 1] = t[i][1], r[i * 4 + 2] = t[i][2], r[i * 4 + 3] = t[i][3];
|
|
645
645
|
return { colors: r, termToPaletteIndex: n };
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function pn(e, t, n) {
|
|
648
648
|
const r = e.createShader(e.VERTEX_SHADER), i = e.createShader(e.FRAGMENT_SHADER);
|
|
649
649
|
if (!r || !i)
|
|
650
650
|
throw new Error("Shader allocation failed");
|
|
@@ -659,7 +659,7 @@ function gn(e, t, n) {
|
|
|
659
659
|
throw new Error(e.getProgramInfoLog(o) || "program link failed");
|
|
660
660
|
return o;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
662
|
+
const zr = "rgba(255, 77, 79, 0.16)", Lr = 3, Dr = 2, Ln = 96, Nr = 1, bn = [], Pe = [], wn = 1e3, Dn = 2, Nn = 2, kr = 4096, Xr = 0.2, Yr = 1.12, Wr = 0.89, Vr = 32, Or = "#000000", Gr = 0.1, qr = "#FFCF00", $r = "#FF0000", Hr = 1.5, yn = [2, 2], Zr = 1, Kr = 0.25, jr = 4, Jr = 0.1, Qr = 96, ti = 1.5, Xt = {
|
|
663
663
|
color: "#ff4d4f",
|
|
664
664
|
width: 2,
|
|
665
665
|
lineJoin: "round",
|
|
@@ -668,7 +668,7 @@ const Br = "rgba(255, 77, 79, 0.16)", zr = 3, Lr = 2, Ln = 96, Nr = 1, pn = [],
|
|
|
668
668
|
shadowBlur: 0,
|
|
669
669
|
shadowOffsetX: 0,
|
|
670
670
|
shadowOffsetY: 0
|
|
671
|
-
},
|
|
671
|
+
}, ei = {
|
|
672
672
|
color: "#4cc9f0",
|
|
673
673
|
width: 2,
|
|
674
674
|
lineDash: [10, 8],
|
|
@@ -678,7 +678,7 @@ const Br = "rgba(255, 77, 79, 0.16)", zr = 3, Lr = 2, Ln = 96, Nr = 1, pn = [],
|
|
|
678
678
|
shadowBlur: 0,
|
|
679
679
|
shadowOffsetX: 0,
|
|
680
680
|
shadowOffsetY: 0
|
|
681
|
-
},
|
|
681
|
+
}, Rt = {
|
|
682
682
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
683
683
|
fontSize: 12,
|
|
684
684
|
fontWeight: 500,
|
|
@@ -691,76 +691,81 @@ const Br = "rgba(255, 77, 79, 0.16)", zr = 3, Lr = 2, Ln = 96, Nr = 1, pn = [],
|
|
|
691
691
|
offsetY: 10,
|
|
692
692
|
borderRadius: 3
|
|
693
693
|
};
|
|
694
|
-
function
|
|
694
|
+
function ne(e, t, n) {
|
|
695
695
|
return Math.max(t, Math.min(n, e));
|
|
696
696
|
}
|
|
697
|
-
function
|
|
697
|
+
function we(e) {
|
|
698
698
|
return e === "stamp-rectangle" || e === "stamp-circle" || e === "stamp-rectangle-4096px" || e === "stamp-rectangle-2mm2" || e === "stamp-circle-2mm2" || e === "stamp-circle-hpf-0.2mm2";
|
|
699
699
|
}
|
|
700
700
|
function se(e, t) {
|
|
701
701
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e;
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function ni(e) {
|
|
704
704
|
return {
|
|
705
|
-
rectangleAreaMm2: se(e?.rectangleAreaMm2,
|
|
706
|
-
circleAreaMm2: se(e?.circleAreaMm2,
|
|
707
|
-
rectanglePixelSize: se(e?.rectanglePixelSize,
|
|
705
|
+
rectangleAreaMm2: se(e?.rectangleAreaMm2, Dn),
|
|
706
|
+
circleAreaMm2: se(e?.circleAreaMm2, Nn),
|
|
707
|
+
rectanglePixelSize: se(e?.rectanglePixelSize, kr)
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
return typeof e != "number" || !Number.isFinite(e) ? t :
|
|
710
|
+
function ri(e, t) {
|
|
711
|
+
return typeof e != "number" || !Number.isFinite(e) ? t : ne(e, 0, 1);
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
if (!Array.isArray(e)) return
|
|
713
|
+
function ii(e) {
|
|
714
|
+
if (!Array.isArray(e)) return yn;
|
|
715
715
|
const t = e.filter((n) => Number.isFinite(n) && n >= 0);
|
|
716
|
-
return t.length > 0 ? t :
|
|
716
|
+
return t.length > 0 ? t : yn;
|
|
717
717
|
}
|
|
718
|
-
function
|
|
719
|
-
|
|
718
|
+
function oi(e) {
|
|
719
|
+
return typeof e != "number" || !Number.isFinite(e) ? Zr : ne(e, Kr, jr);
|
|
720
|
+
}
|
|
721
|
+
function si(e) {
|
|
722
|
+
const t = se(e?.radius, Vr), n = se(e?.cursorLineWidth, Hr), r = oi(e?.edgeDetail);
|
|
720
723
|
return {
|
|
721
724
|
radius: t,
|
|
725
|
+
edgeDetail: r,
|
|
726
|
+
clickSelectRoi: e?.clickSelectRoi === !0,
|
|
722
727
|
fillColor: e?.fillColor || Or,
|
|
723
|
-
fillOpacity:
|
|
724
|
-
cursorColor: e?.cursorColor ||
|
|
725
|
-
cursorActiveColor: e?.cursorActiveColor ||
|
|
728
|
+
fillOpacity: ri(e?.fillOpacity, Gr),
|
|
729
|
+
cursorColor: e?.cursorColor || qr,
|
|
730
|
+
cursorActiveColor: e?.cursorActiveColor || $r,
|
|
726
731
|
cursorLineWidth: n,
|
|
727
|
-
cursorLineDash:
|
|
732
|
+
cursorLineDash: ii(e?.cursorLineDash)
|
|
728
733
|
};
|
|
729
734
|
}
|
|
730
|
-
function
|
|
731
|
-
return e *
|
|
735
|
+
function ai(e) {
|
|
736
|
+
return e * wn * wn;
|
|
732
737
|
}
|
|
733
|
-
function
|
|
734
|
-
return !e || !Number.isFinite(t) || t <= 0 ? [] :
|
|
738
|
+
function xn(e, t) {
|
|
739
|
+
return !e || !Number.isFinite(t) || t <= 0 ? [] : Et([
|
|
735
740
|
[e[0] - t, e[1] - t],
|
|
736
741
|
[e[0] + t, e[1] - t],
|
|
737
742
|
[e[0] + t, e[1] + t],
|
|
738
743
|
[e[0] - t, e[1] + t]
|
|
739
744
|
]);
|
|
740
745
|
}
|
|
741
|
-
function
|
|
746
|
+
function ui(e, t, n = Ln) {
|
|
742
747
|
if (!e || !Number.isFinite(t) || t <= 0) return [];
|
|
743
748
|
const r = [];
|
|
744
749
|
for (let i = 0; i <= n; i += 1) {
|
|
745
750
|
const o = i / n * Math.PI * 2;
|
|
746
751
|
r.push([e[0] + Math.cos(o) * t, e[1] + Math.sin(o) * t]);
|
|
747
752
|
}
|
|
748
|
-
return
|
|
753
|
+
return Et(r);
|
|
749
754
|
}
|
|
750
|
-
function
|
|
755
|
+
function Et(e) {
|
|
751
756
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
752
757
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
753
758
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
754
759
|
}
|
|
755
|
-
function
|
|
756
|
-
return !e || !t ? [] :
|
|
760
|
+
function Sn(e, t) {
|
|
761
|
+
return !e || !t ? [] : Et([
|
|
757
762
|
[e[0], e[1]],
|
|
758
763
|
[t[0], e[1]],
|
|
759
764
|
[t[0], t[1]],
|
|
760
765
|
[e[0], t[1]]
|
|
761
766
|
]);
|
|
762
767
|
}
|
|
763
|
-
function
|
|
768
|
+
function Tn(e, t, n = Ln) {
|
|
764
769
|
if (!e || !t) return [];
|
|
765
770
|
const r = (e[0] + t[0]) * 0.5, i = (e[1] + t[1]) * 0.5, o = Math.hypot(t[0] - e[0], t[1] - e[1]) * 0.5;
|
|
766
771
|
if (o < 1) return [];
|
|
@@ -769,9 +774,9 @@ function Sn(e, t, n = Ln) {
|
|
|
769
774
|
const u = a / n * Math.PI * 2;
|
|
770
775
|
s.push([r + Math.cos(u) * o, i + Math.sin(u) * o]);
|
|
771
776
|
}
|
|
772
|
-
return
|
|
777
|
+
return Et(s);
|
|
773
778
|
}
|
|
774
|
-
function
|
|
779
|
+
function ke(e) {
|
|
775
780
|
if (!Array.isArray(e) || e.length < 4) return 0;
|
|
776
781
|
let t = 0;
|
|
777
782
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -780,17 +785,17 @@ function De(e) {
|
|
|
780
785
|
}
|
|
781
786
|
return Math.abs(t * 0.5);
|
|
782
787
|
}
|
|
783
|
-
function
|
|
788
|
+
function Mn(e) {
|
|
784
789
|
if (!Array.isArray(e) || e.length === 0) return [0, 0, 0, 0];
|
|
785
790
|
let t = 1 / 0, n = 1 / 0, r = -1 / 0, i = -1 / 0;
|
|
786
791
|
for (const [o, s] of e)
|
|
787
792
|
o < t && (t = o), o > r && (r = o), s < n && (n = s), s > i && (i = s);
|
|
788
793
|
return [t, n, r, i];
|
|
789
794
|
}
|
|
790
|
-
function
|
|
791
|
-
return Array.isArray(e) && e.length >= 4 &&
|
|
795
|
+
function An(e) {
|
|
796
|
+
return Array.isArray(e) && e.length >= 4 && ke(e) > Nr;
|
|
792
797
|
}
|
|
793
|
-
function
|
|
798
|
+
function Xe(e, t, n = !1) {
|
|
794
799
|
if (t.length !== 0) {
|
|
795
800
|
e.moveTo(t[0][0], t[0][1]);
|
|
796
801
|
for (let r = 1; r < t.length; r += 1)
|
|
@@ -798,18 +803,18 @@ function ke(e, t, n = !1) {
|
|
|
798
803
|
n && e.closePath();
|
|
799
804
|
}
|
|
800
805
|
}
|
|
801
|
-
function
|
|
802
|
-
t.length !== 0 && (e.beginPath(),
|
|
806
|
+
function Qt(e, t, n, r = !1, i = !1) {
|
|
807
|
+
t.length !== 0 && (e.beginPath(), Xe(e, t, r), i && r && (e.fillStyle = zr, e.fill()), e.strokeStyle = n.color, e.lineWidth = n.width, e.lineJoin = n.lineJoin, e.lineCap = n.lineCap, e.shadowColor = n.shadowColor, e.shadowBlur = n.shadowBlur, e.shadowOffsetX = n.shadowOffsetX, e.shadowOffsetY = n.shadowOffsetY, e.setLineDash(n.lineDash), e.stroke(), e.setLineDash(Pe), e.shadowColor = "rgba(0, 0, 0, 0)", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0);
|
|
803
808
|
}
|
|
804
809
|
function kn(e) {
|
|
805
|
-
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) :
|
|
810
|
+
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) : Pe, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) : Xt.width, r = typeof e?.shadowBlur == "number" && Number.isFinite(e.shadowBlur) ? Math.max(0, e.shadowBlur) : Xt.shadowBlur, i = typeof e?.shadowOffsetX == "number" && Number.isFinite(e.shadowOffsetX) ? e.shadowOffsetX : Xt.shadowOffsetX, o = typeof e?.shadowOffsetY == "number" && Number.isFinite(e.shadowOffsetY) ? e.shadowOffsetY : Xt.shadowOffsetY;
|
|
806
811
|
return {
|
|
807
|
-
color: e?.color ||
|
|
812
|
+
color: e?.color || Xt.color,
|
|
808
813
|
width: n,
|
|
809
|
-
lineDash: t.length ? t :
|
|
810
|
-
lineJoin: e?.lineJoin ||
|
|
811
|
-
lineCap: e?.lineCap ||
|
|
812
|
-
shadowColor: e?.shadowColor ||
|
|
814
|
+
lineDash: t.length ? t : Pe,
|
|
815
|
+
lineJoin: e?.lineJoin || Xt.lineJoin,
|
|
816
|
+
lineCap: e?.lineCap || Xt.lineCap,
|
|
817
|
+
shadowColor: e?.shadowColor || Xt.shadowColor,
|
|
813
818
|
shadowBlur: r,
|
|
814
819
|
shadowOffsetX: i,
|
|
815
820
|
shadowOffsetY: o
|
|
@@ -828,25 +833,25 @@ function oe(e, t) {
|
|
|
828
833
|
shadowOffsetY: t.shadowOffsetY ?? e.shadowOffsetY
|
|
829
834
|
}) : e;
|
|
830
835
|
}
|
|
831
|
-
function
|
|
836
|
+
function Pn(e, t) {
|
|
832
837
|
return e == null || t === null || t === void 0 ? !1 : String(e) === String(t);
|
|
833
838
|
}
|
|
834
|
-
function
|
|
839
|
+
function ci(e) {
|
|
835
840
|
const t = e[0];
|
|
836
841
|
return Array.isArray(t) && Array.isArray(t[0]);
|
|
837
842
|
}
|
|
838
|
-
function
|
|
843
|
+
function Rn(e) {
|
|
839
844
|
return typeof e == "number" && Number.isFinite(e);
|
|
840
845
|
}
|
|
841
|
-
function
|
|
842
|
-
return Array.isArray(e) && e.length >= 2 &&
|
|
846
|
+
function li(e) {
|
|
847
|
+
return Array.isArray(e) && e.length >= 2 && Rn(e[0]) && Rn(e[1]);
|
|
843
848
|
}
|
|
844
|
-
function
|
|
845
|
-
return Array.isArray(e) && e.length >= 2 && e.every((t) =>
|
|
849
|
+
function hi(e) {
|
|
850
|
+
return Array.isArray(e) && e.length >= 2 && e.every((t) => li(t));
|
|
846
851
|
}
|
|
847
852
|
function Xn(e, t) {
|
|
848
853
|
if (!(!Array.isArray(e) || e.length === 0)) {
|
|
849
|
-
if (
|
|
854
|
+
if (hi(e)) {
|
|
850
855
|
t.push(e.map(([n, r]) => [n, r]));
|
|
851
856
|
return;
|
|
852
857
|
}
|
|
@@ -854,34 +859,34 @@ function Xn(e, t) {
|
|
|
854
859
|
Xn(n, t);
|
|
855
860
|
}
|
|
856
861
|
}
|
|
857
|
-
function
|
|
862
|
+
function En(e, t) {
|
|
858
863
|
const n = [];
|
|
859
864
|
Xn(e, n);
|
|
860
865
|
const r = [];
|
|
861
866
|
for (const i of n) {
|
|
862
867
|
if (i.length < 2) continue;
|
|
863
|
-
const o = t ?
|
|
868
|
+
const o = t ? Et(i) : i;
|
|
864
869
|
o.length >= (t ? 4 : 2) && r.push(o);
|
|
865
870
|
}
|
|
866
871
|
return r;
|
|
867
872
|
}
|
|
868
|
-
function
|
|
873
|
+
function fi(e, t, n, r) {
|
|
869
874
|
if (!(t.length < 4 || n.length === 0)) {
|
|
870
|
-
e.save(), e.beginPath(),
|
|
875
|
+
e.save(), e.beginPath(), Xe(e, t, !0);
|
|
871
876
|
for (const i of n)
|
|
872
|
-
i.length < 4 ||
|
|
877
|
+
i.length < 4 || Xe(e, i, !0);
|
|
873
878
|
e.fillStyle = r, e.fill("evenodd"), e.restore();
|
|
874
879
|
}
|
|
875
880
|
}
|
|
876
|
-
function
|
|
877
|
-
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) :
|
|
881
|
+
function di(e) {
|
|
882
|
+
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : Rt.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : Rt.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : Rt.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : Rt.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : Rt.offsetY, s = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : Rt.borderRadius;
|
|
878
883
|
return {
|
|
879
|
-
fontFamily: e?.fontFamily ||
|
|
884
|
+
fontFamily: e?.fontFamily || Rt.fontFamily,
|
|
880
885
|
fontSize: r,
|
|
881
|
-
fontWeight: e?.fontWeight ||
|
|
882
|
-
textColor: e?.textColor ||
|
|
883
|
-
backgroundColor: e?.backgroundColor ||
|
|
884
|
-
borderColor: e?.borderColor ||
|
|
886
|
+
fontWeight: e?.fontWeight || Rt.fontWeight,
|
|
887
|
+
textColor: e?.textColor || Rt.textColor,
|
|
888
|
+
backgroundColor: e?.backgroundColor || Rt.backgroundColor,
|
|
889
|
+
borderColor: e?.borderColor || Rt.borderColor,
|
|
885
890
|
borderWidth: i,
|
|
886
891
|
paddingX: t,
|
|
887
892
|
paddingY: n,
|
|
@@ -889,11 +894,11 @@ function si(e) {
|
|
|
889
894
|
borderRadius: s
|
|
890
895
|
};
|
|
891
896
|
}
|
|
892
|
-
function
|
|
897
|
+
function mi(e, t, n, r, i, o) {
|
|
893
898
|
const s = Math.max(0, Math.min(o, r * 0.5, i * 0.5));
|
|
894
899
|
e.beginPath(), e.moveTo(t + s, n), e.lineTo(t + r - s, n), e.quadraticCurveTo(t + r, n, t + r, n + s), e.lineTo(t + r, n + i - s), e.quadraticCurveTo(t + r, n + i, t + r - s, n + i), e.lineTo(t + s, n + i), e.quadraticCurveTo(t, n + i, t, n + i - s), e.lineTo(t, n + s), e.quadraticCurveTo(t, n, t + s, n), e.closePath();
|
|
895
900
|
}
|
|
896
|
-
function
|
|
901
|
+
function gi(e) {
|
|
897
902
|
if (!e.length) return null;
|
|
898
903
|
let t = 1 / 0;
|
|
899
904
|
for (const i of e)
|
|
@@ -904,22 +909,22 @@ function ui(e) {
|
|
|
904
909
|
Math.abs(i[1] - t) > 0.5 || (i[0] < n && (n = i[0]), i[0] > r && (r = i[0]));
|
|
905
910
|
return !Number.isFinite(n) || !Number.isFinite(r) ? null : [(n + r) * 0.5, t];
|
|
906
911
|
}
|
|
907
|
-
function
|
|
912
|
+
function pi(e, t, n, r, i, o) {
|
|
908
913
|
const s = t.trim();
|
|
909
914
|
if (!s) return;
|
|
910
915
|
e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
911
|
-
const u = e.measureText(s).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, h =
|
|
912
|
-
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth,
|
|
916
|
+
const u = e.measureText(s).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, h = ne(n[0], u * 0.5 + 1, r - u * 0.5 - 1), g = ne(n[1] - o.offsetY, c * 0.5 + 1, i - c * 0.5 - 1), d = h - u * 0.5, p = g - c * 0.5;
|
|
917
|
+
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, mi(e, d, p, u, c, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(s, h, g + 0.5), e.restore();
|
|
913
918
|
}
|
|
914
919
|
function Ue(e, t, n) {
|
|
915
|
-
return [
|
|
920
|
+
return [ne(e[0], 0, t), ne(e[1], 0, n)];
|
|
916
921
|
}
|
|
917
|
-
function
|
|
922
|
+
function te(e) {
|
|
918
923
|
if (!Array.isArray(e) || e.length < 2) return null;
|
|
919
924
|
const t = Number(e[0]), n = Number(e[1]);
|
|
920
925
|
return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
|
|
921
926
|
}
|
|
922
|
-
function
|
|
927
|
+
function bi({
|
|
923
928
|
tool: e,
|
|
924
929
|
imageWidth: t,
|
|
925
930
|
imageHeight: n,
|
|
@@ -928,27 +933,28 @@ function li({
|
|
|
928
933
|
stampOptions: o,
|
|
929
934
|
brushOptions: s,
|
|
930
935
|
projectorRef: a,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
936
|
+
onBrushTap: u,
|
|
937
|
+
onDrawComplete: c,
|
|
938
|
+
onPatchComplete: h,
|
|
939
|
+
enabled: g,
|
|
940
|
+
viewStateSignal: d,
|
|
941
|
+
persistedRegions: p,
|
|
942
|
+
patchRegions: x,
|
|
943
|
+
persistedPolygons: S,
|
|
944
|
+
regionStrokeStyle: P,
|
|
945
|
+
regionStrokeHoverStyle: k,
|
|
946
|
+
regionStrokeActiveStyle: v,
|
|
941
947
|
patchStrokeStyle: R,
|
|
942
|
-
resolveRegionStrokeStyle:
|
|
943
|
-
overlayShapes:
|
|
944
|
-
hoveredRegionId:
|
|
945
|
-
activeRegionId:
|
|
946
|
-
regionLabelStyle:
|
|
947
|
-
invalidateRef:
|
|
948
|
-
className:
|
|
949
|
-
style:
|
|
948
|
+
resolveRegionStrokeStyle: D,
|
|
949
|
+
overlayShapes: J,
|
|
950
|
+
hoveredRegionId: ft = null,
|
|
951
|
+
activeRegionId: at = null,
|
|
952
|
+
regionLabelStyle: $,
|
|
953
|
+
invalidateRef: ht,
|
|
954
|
+
className: vt,
|
|
955
|
+
style: Ot
|
|
950
956
|
}) {
|
|
951
|
-
const
|
|
957
|
+
const K = j(null), Ct = j(!1), zt = j(/* @__PURE__ */ new Map()), Kt = j(e), dt = j({
|
|
952
958
|
isDrawing: !1,
|
|
953
959
|
pointerId: null,
|
|
954
960
|
start: null,
|
|
@@ -956,10 +962,10 @@ function li({
|
|
|
956
962
|
cursor: null,
|
|
957
963
|
points: [],
|
|
958
964
|
stampCenter: null
|
|
959
|
-
}),
|
|
965
|
+
}), Q = g ?? e !== "cursor", M = tt(() => p && p.length > 0 ? p : !S || S.length === 0 ? bn : S.map((l, f) => ({
|
|
960
966
|
id: f,
|
|
961
967
|
coordinates: l
|
|
962
|
-
})), [
|
|
968
|
+
})), [p, S]), C = tt(() => x ?? bn, [x]), A = tt(() => kn(P), [P]), L = tt(() => oe(A, k), [A, k]), Z = tt(() => oe(A, v), [A, v]), et = tt(() => oe(ei, R), [R]), mt = tt(() => di($), [$]), yt = tt(() => ni(o), [o]), U = tt(() => si(s), [s]), At = tt(
|
|
963
969
|
() => ({
|
|
964
970
|
position: "absolute",
|
|
965
971
|
inset: 0,
|
|
@@ -968,426 +974,435 @@ function li({
|
|
|
968
974
|
height: "100%",
|
|
969
975
|
display: "block",
|
|
970
976
|
touchAction: "none",
|
|
971
|
-
pointerEvents:
|
|
972
|
-
cursor:
|
|
973
|
-
...
|
|
977
|
+
pointerEvents: Q ? "auto" : "none",
|
|
978
|
+
cursor: Q ? e === "brush" ? "none" : "crosshair" : "default",
|
|
979
|
+
...Ot
|
|
974
980
|
}),
|
|
975
|
-
[
|
|
976
|
-
),
|
|
977
|
-
const l =
|
|
981
|
+
[Q, e, Ot]
|
|
982
|
+
), gt = B(() => {
|
|
983
|
+
const l = K.current;
|
|
978
984
|
if (!l) return;
|
|
979
|
-
const f = l.getBoundingClientRect(),
|
|
980
|
-
(l.width !==
|
|
981
|
-
}, []),
|
|
985
|
+
const f = l.getBoundingClientRect(), w = Math.max(1, window.devicePixelRatio || 1), y = Math.max(1, Math.round(f.width * w)), E = Math.max(1, Math.round(f.height * w));
|
|
986
|
+
(l.width !== y || l.height !== E) && (l.width = y, l.height = E);
|
|
987
|
+
}, []), N = B(
|
|
982
988
|
(l) => {
|
|
983
989
|
const f = a.current;
|
|
984
990
|
if (!f || l.length === 0) return [];
|
|
985
|
-
const
|
|
986
|
-
for (let
|
|
987
|
-
const
|
|
988
|
-
if (!
|
|
989
|
-
|
|
991
|
+
const w = new Array(l.length);
|
|
992
|
+
for (let y = 0; y < l.length; y += 1) {
|
|
993
|
+
const E = te(f.worldToScreen(l[y][0], l[y][1]));
|
|
994
|
+
if (!E) return [];
|
|
995
|
+
w[y] = E;
|
|
990
996
|
}
|
|
991
|
-
return
|
|
997
|
+
return w;
|
|
992
998
|
},
|
|
993
999
|
[a]
|
|
994
|
-
), G =
|
|
1000
|
+
), G = B(
|
|
995
1001
|
(l, f) => {
|
|
996
1002
|
if (!Number.isFinite(f) || f <= 0) return 0;
|
|
997
|
-
const
|
|
998
|
-
if (!
|
|
999
|
-
const
|
|
1000
|
-
return !
|
|
1003
|
+
const w = a.current;
|
|
1004
|
+
if (!w) return 0;
|
|
1005
|
+
const y = te(w.worldToScreen(l[0], l[1])), E = te(w.worldToScreen(l[0] + f, l[1]));
|
|
1006
|
+
return !y || !E ? 0 : Math.hypot(E[0] - y[0], E[1] - y[1]);
|
|
1001
1007
|
},
|
|
1002
1008
|
[a]
|
|
1003
|
-
),
|
|
1009
|
+
), ut = B(
|
|
1004
1010
|
(l) => {
|
|
1005
1011
|
if (!Number.isFinite(l) || l <= 0) return 0;
|
|
1006
|
-
const f = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1,
|
|
1007
|
-
return l /
|
|
1012
|
+
const f = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, w = typeof i == "number" && Number.isFinite(i) ? i : 0, y = a.current?.getViewState?.().zoom, E = typeof y == "number" && Number.isFinite(y) && y > 0 ? y : 1, I = w + Math.log2(E), Y = Math.max(1e-9, zn(f, w, I));
|
|
1013
|
+
return l / Y / E;
|
|
1008
1014
|
},
|
|
1009
1015
|
[r, i, a]
|
|
1010
|
-
),
|
|
1016
|
+
), nt = B(
|
|
1011
1017
|
(l, f) => {
|
|
1012
1018
|
if (!f) return [];
|
|
1013
|
-
let
|
|
1019
|
+
let w = 0;
|
|
1014
1020
|
if (l === "stamp-rectangle-4096px") {
|
|
1015
|
-
const
|
|
1016
|
-
return
|
|
1021
|
+
const I = yt.rectanglePixelSize * 0.5;
|
|
1022
|
+
return xn(f, I).map((V) => Ue(V, t, n));
|
|
1017
1023
|
}
|
|
1018
|
-
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2" ?
|
|
1019
|
-
const
|
|
1020
|
-
let
|
|
1024
|
+
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2" ? w = l === "stamp-rectangle-2mm2" ? Dn : yt.rectangleAreaMm2 : (l === "stamp-circle" || l === "stamp-circle-2mm2" || l === "stamp-circle-hpf-0.2mm2") && (w = l === "stamp-circle-hpf-0.2mm2" ? Xr : l === "stamp-circle-2mm2" ? Nn : yt.circleAreaMm2), !Number.isFinite(w) || w <= 0) return [];
|
|
1025
|
+
const y = ai(w);
|
|
1026
|
+
let E = [];
|
|
1021
1027
|
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2") {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1028
|
+
const I = ut(Math.sqrt(y) * 0.5);
|
|
1029
|
+
E = xn(f, I);
|
|
1024
1030
|
} else if (l === "stamp-circle" || l === "stamp-circle-2mm2" || l === "stamp-circle-hpf-0.2mm2") {
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1031
|
+
const I = ut(Math.sqrt(y / Math.PI));
|
|
1032
|
+
E = ui(f, I);
|
|
1027
1033
|
}
|
|
1028
|
-
return
|
|
1034
|
+
return E.length ? E.map((I) => Ue(I, t, n)) : [];
|
|
1029
1035
|
},
|
|
1030
|
-
[
|
|
1031
|
-
),
|
|
1036
|
+
[ut, t, n, yt]
|
|
1037
|
+
), rt = B(() => {
|
|
1032
1038
|
const l = dt.current;
|
|
1033
|
-
return
|
|
1034
|
-
}, [e,
|
|
1039
|
+
return we(e) ? nt(e, l.stampCenter) : e === "brush" ? [] : l.isDrawing ? e === "freehand" ? l.points : e === "rectangle" ? Sn(l.start, l.current) : e === "circular" ? Tn(l.start, l.current) : [] : [];
|
|
1040
|
+
}, [e, nt]), q = B(
|
|
1035
1041
|
(l) => {
|
|
1036
1042
|
const f = dt.current;
|
|
1037
1043
|
if (!f.isDrawing || f.points.length === 0) return;
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1040
|
-
const
|
|
1041
|
-
if (!(!Number.isFinite(
|
|
1042
|
-
if (l.save(), l.globalAlpha =
|
|
1043
|
-
l.beginPath(), l.arc(
|
|
1044
|
+
const w = N(f.points);
|
|
1045
|
+
if (w.length === 0) return;
|
|
1046
|
+
const y = f.points[f.points.length - 1] ?? f.points[0], E = G(y, U.radius);
|
|
1047
|
+
if (!(!Number.isFinite(E) || E <= 0)) {
|
|
1048
|
+
if (l.save(), l.globalAlpha = U.fillOpacity, l.fillStyle = U.fillColor, l.strokeStyle = U.fillColor, l.lineCap = "round", l.lineJoin = "round", l.lineWidth = E * 2, w.length === 1)
|
|
1049
|
+
l.beginPath(), l.arc(w[0][0], w[0][1], E, 0, Math.PI * 2), l.fill();
|
|
1044
1050
|
else {
|
|
1045
|
-
l.beginPath(), l.moveTo(
|
|
1046
|
-
for (let
|
|
1047
|
-
l.lineTo(
|
|
1051
|
+
l.beginPath(), l.moveTo(w[0][0], w[0][1]);
|
|
1052
|
+
for (let I = 1; I < w.length; I += 1)
|
|
1053
|
+
l.lineTo(w[I][0], w[I][1]);
|
|
1048
1054
|
l.stroke();
|
|
1049
1055
|
}
|
|
1050
1056
|
l.restore();
|
|
1051
1057
|
}
|
|
1052
1058
|
},
|
|
1053
|
-
[
|
|
1054
|
-
),
|
|
1059
|
+
[N, G, U]
|
|
1060
|
+
), It = B(
|
|
1055
1061
|
(l) => {
|
|
1056
|
-
const f = dt.current,
|
|
1057
|
-
if (!
|
|
1058
|
-
const
|
|
1059
|
-
if (!
|
|
1060
|
-
const
|
|
1061
|
-
!Number.isFinite(
|
|
1062
|
+
const f = dt.current, w = f.cursor;
|
|
1063
|
+
if (!w) return;
|
|
1064
|
+
const y = te(a.current?.worldToScreen(w[0], w[1]) ?? []);
|
|
1065
|
+
if (!y) return;
|
|
1066
|
+
const E = G(w, U.radius);
|
|
1067
|
+
!Number.isFinite(E) || E <= 0 || (l.save(), l.beginPath(), l.arc(y[0], y[1], E, 0, Math.PI * 2), l.strokeStyle = f.isDrawing ? U.cursorActiveColor : U.cursorColor, l.lineWidth = U.cursorLineWidth, l.setLineDash(U.cursorLineDash), l.stroke(), l.setLineDash(Pe), l.restore());
|
|
1062
1068
|
},
|
|
1063
|
-
[a, G,
|
|
1064
|
-
),
|
|
1065
|
-
|
|
1066
|
-
const l =
|
|
1069
|
+
[a, G, U]
|
|
1070
|
+
), _t = B(() => {
|
|
1071
|
+
gt();
|
|
1072
|
+
const l = K.current;
|
|
1067
1073
|
if (!l) return;
|
|
1068
1074
|
const f = l.getContext("2d");
|
|
1069
1075
|
if (!f) return;
|
|
1070
|
-
const
|
|
1071
|
-
if (f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, l.width, l.height), f.setTransform(
|
|
1072
|
-
for (let
|
|
1073
|
-
const
|
|
1076
|
+
const w = Math.max(1, window.devicePixelRatio || 1), y = l.width / w, E = l.height / w;
|
|
1077
|
+
if (f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, l.width, l.height), f.setTransform(w, 0, 0, w, 0, 0), M.length > 0)
|
|
1078
|
+
for (let I = 0; I < M.length; I += 1) {
|
|
1079
|
+
const Y = M[I], V = Y?.coordinates;
|
|
1074
1080
|
if (!V || V.length < 3) continue;
|
|
1075
|
-
const
|
|
1076
|
-
if (
|
|
1077
|
-
const
|
|
1078
|
-
let
|
|
1079
|
-
if (
|
|
1080
|
-
const
|
|
1081
|
-
region:
|
|
1082
|
-
regionId:
|
|
1083
|
-
regionIndex:
|
|
1084
|
-
state:
|
|
1081
|
+
const W = Et(V), lt = N(W);
|
|
1082
|
+
if (lt.length >= 4) {
|
|
1083
|
+
const Pt = Y.id ?? I, $t = Pn(at, Pt) ? "active" : Pn(ft, Pt) ? "hover" : "default";
|
|
1084
|
+
let xt = $t === "active" ? Z : $t === "hover" ? L : A;
|
|
1085
|
+
if (D) {
|
|
1086
|
+
const H = D({
|
|
1087
|
+
region: Y,
|
|
1088
|
+
regionId: Pt,
|
|
1089
|
+
regionIndex: I,
|
|
1090
|
+
state: $t
|
|
1085
1091
|
});
|
|
1086
|
-
|
|
1092
|
+
xt = oe(xt, H || void 0);
|
|
1087
1093
|
}
|
|
1088
|
-
|
|
1094
|
+
Qt(f, lt, xt, !0, !1);
|
|
1089
1095
|
}
|
|
1090
1096
|
}
|
|
1091
|
-
if (
|
|
1092
|
-
for (let
|
|
1093
|
-
const V =
|
|
1097
|
+
if (C.length > 0)
|
|
1098
|
+
for (let I = 0; I < C.length; I += 1) {
|
|
1099
|
+
const V = C[I]?.coordinates;
|
|
1094
1100
|
if (!V || V.length < 3) continue;
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1101
|
+
const W = Et(V), lt = N(W);
|
|
1102
|
+
lt.length < 4 || Qt(f, lt, et, !0, !1);
|
|
1097
1103
|
}
|
|
1098
|
-
if (Array.isArray(
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1104
|
+
if (Array.isArray(J) && J.length > 0) {
|
|
1105
|
+
const I = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, Y = N(
|
|
1106
|
+
Et([
|
|
1101
1107
|
[0, 0],
|
|
1102
1108
|
[t, 0],
|
|
1103
1109
|
[t, n],
|
|
1104
1110
|
[0, n]
|
|
1105
1111
|
])
|
|
1106
1112
|
);
|
|
1107
|
-
for (let V = 0; V <
|
|
1108
|
-
const
|
|
1109
|
-
if (!
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1112
|
-
const
|
|
1113
|
-
for (const
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1113
|
+
for (let V = 0; V < J.length; V += 1) {
|
|
1114
|
+
const W = J[V];
|
|
1115
|
+
if (!W?.coordinates?.length || W.visible === !1) continue;
|
|
1116
|
+
const lt = W.closed ?? ci(W.coordinates), Pt = En(W.coordinates, lt);
|
|
1117
|
+
if (W.invertedFill?.fillColor) {
|
|
1118
|
+
const xt = [], H = En(W.coordinates, !0);
|
|
1119
|
+
for (const St of H) {
|
|
1120
|
+
const Tt = N(St);
|
|
1121
|
+
Tt.length >= 4 && xt.push(Tt);
|
|
1116
1122
|
}
|
|
1117
|
-
if (
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
id:
|
|
1121
|
-
outerRingPoints:
|
|
1122
|
-
sourceRingCount:
|
|
1123
|
-
holeRingCount:
|
|
1124
|
-
fillColor:
|
|
1123
|
+
if (I) {
|
|
1124
|
+
const St = String(W.id ?? V), Tt = `${Y.length}|${H.length}|${xt.length}|${W.invertedFill.fillColor}`;
|
|
1125
|
+
zt.current.get(St) !== Tt && (zt.current.set(St, Tt), console.debug("[open-plant] invertedFill", {
|
|
1126
|
+
id: W.id ?? V,
|
|
1127
|
+
outerRingPoints: Y.length,
|
|
1128
|
+
sourceRingCount: H.length,
|
|
1129
|
+
holeRingCount: xt.length,
|
|
1130
|
+
fillColor: W.invertedFill.fillColor
|
|
1125
1131
|
}));
|
|
1126
1132
|
}
|
|
1127
|
-
|
|
1133
|
+
fi(f, Y, xt, W.invertedFill.fillColor);
|
|
1128
1134
|
}
|
|
1129
|
-
if (
|
|
1130
|
-
const
|
|
1131
|
-
for (const
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1135
|
+
if (Pt.length === 0) continue;
|
|
1136
|
+
const $t = oe(A, W.stroke ?? W.strokeStyle);
|
|
1137
|
+
for (const xt of Pt) {
|
|
1138
|
+
const H = N(xt);
|
|
1139
|
+
H.length < 2 || Qt(f, H, $t, lt, W.fill ?? !1);
|
|
1134
1140
|
}
|
|
1135
1141
|
}
|
|
1136
1142
|
}
|
|
1137
|
-
if (
|
|
1143
|
+
if (Q)
|
|
1138
1144
|
if (e === "brush")
|
|
1139
|
-
|
|
1145
|
+
q(f), It(f);
|
|
1140
1146
|
else {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1147
|
+
const I = rt();
|
|
1148
|
+
if (I.length > 0)
|
|
1143
1149
|
if (e === "freehand") {
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1150
|
+
const Y = N(I);
|
|
1151
|
+
Y.length >= 2 && Qt(f, Y, A, !1, !1), Y.length >= 3 && Qt(f, N(Et(I)), A, !0, !0);
|
|
1146
1152
|
} else {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1153
|
+
const Y = N(I);
|
|
1154
|
+
Y.length >= 4 && Qt(f, Y, A, !0, !0);
|
|
1149
1155
|
}
|
|
1150
1156
|
}
|
|
1151
|
-
if (
|
|
1152
|
-
for (const
|
|
1153
|
-
if (!
|
|
1154
|
-
const
|
|
1155
|
-
if (!
|
|
1156
|
-
const V =
|
|
1157
|
-
if (!
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1157
|
+
if (M.length > 0)
|
|
1158
|
+
for (const I of M) {
|
|
1159
|
+
if (!I.label) continue;
|
|
1160
|
+
const Y = I?.coordinates;
|
|
1161
|
+
if (!Y || Y.length < 3) continue;
|
|
1162
|
+
const V = Et(Y), W = gi(V);
|
|
1163
|
+
if (!W) continue;
|
|
1164
|
+
const lt = te(a.current?.worldToScreen(W[0], W[1]) ?? []);
|
|
1165
|
+
lt && pi(f, I.label, lt, y, E, mt);
|
|
1160
1166
|
}
|
|
1161
1167
|
}, [
|
|
1162
|
-
it,
|
|
1163
|
-
e,
|
|
1164
|
-
st,
|
|
1165
1168
|
Q,
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
+
e,
|
|
1170
|
+
rt,
|
|
1171
|
+
q,
|
|
1172
|
+
It,
|
|
1173
|
+
gt,
|
|
1174
|
+
N,
|
|
1169
1175
|
t,
|
|
1170
1176
|
n,
|
|
1171
1177
|
a,
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
nt,
|
|
1178
|
+
M,
|
|
1179
|
+
J,
|
|
1175
1180
|
ft,
|
|
1176
|
-
|
|
1177
|
-
|
|
1181
|
+
at,
|
|
1182
|
+
A,
|
|
1178
1183
|
L,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1184
|
+
Z,
|
|
1185
|
+
C,
|
|
1186
|
+
et,
|
|
1187
|
+
D,
|
|
1188
|
+
mt
|
|
1189
|
+
]), F = B(() => {
|
|
1190
|
+
Ct.current || (Ct.current = !0, requestAnimationFrame(() => {
|
|
1191
|
+
Ct.current = !1, _t();
|
|
1186
1192
|
}));
|
|
1187
|
-
}, [
|
|
1188
|
-
const f = dt.current,
|
|
1189
|
-
if (
|
|
1193
|
+
}, [_t]), ct = B((l = !1) => {
|
|
1194
|
+
const f = dt.current, w = K.current;
|
|
1195
|
+
if (w && f.pointerId !== null && w.hasPointerCapture(f.pointerId))
|
|
1190
1196
|
try {
|
|
1191
|
-
|
|
1197
|
+
w.releasePointerCapture(f.pointerId);
|
|
1192
1198
|
} catch {
|
|
1193
1199
|
}
|
|
1194
1200
|
f.isDrawing = !1, f.pointerId = null, f.start = null, f.current = null, f.points = [], f.stampCenter = null, l || (f.cursor = null);
|
|
1195
|
-
}, []),
|
|
1201
|
+
}, []), ot = B(
|
|
1196
1202
|
(l) => {
|
|
1197
1203
|
const f = a.current;
|
|
1198
1204
|
if (!f || t <= 0 || n <= 0) return null;
|
|
1199
|
-
const
|
|
1200
|
-
return
|
|
1205
|
+
const w = te(f.screenToWorld(l.clientX, l.clientY));
|
|
1206
|
+
return w ? Ue(w, t, n) : null;
|
|
1201
1207
|
},
|
|
1202
1208
|
[a, t, n]
|
|
1203
|
-
),
|
|
1209
|
+
), Gt = B(() => {
|
|
1204
1210
|
const l = dt.current;
|
|
1205
1211
|
if (!l.isDrawing) {
|
|
1206
|
-
|
|
1212
|
+
ct(!0), F();
|
|
1207
1213
|
return;
|
|
1208
1214
|
}
|
|
1209
1215
|
let f = [];
|
|
1210
1216
|
if (e === "freehand")
|
|
1211
|
-
l.points.length >=
|
|
1217
|
+
l.points.length >= Lr && (f = Et(l.points));
|
|
1212
1218
|
else if (e === "rectangle")
|
|
1213
|
-
f = xn(l.start, l.current);
|
|
1214
|
-
else if (e === "circular")
|
|
1215
1219
|
f = Sn(l.start, l.current);
|
|
1220
|
+
else if (e === "circular")
|
|
1221
|
+
f = Tn(l.start, l.current);
|
|
1216
1222
|
else if (e === "brush") {
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1223
|
+
const w = l.points[l.points.length - 1] ?? l.current ?? l.start;
|
|
1224
|
+
if (U.clickSelectRoi && w && l.points.length <= 1 && u?.(w)) {
|
|
1225
|
+
ct(!0), F();
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const y = U.edgeDetail, E = Math.max(
|
|
1229
|
+
Jr,
|
|
1230
|
+
U.radius * 2 / (Qr * y)
|
|
1231
|
+
);
|
|
1232
|
+
f = Ur(l.points, {
|
|
1233
|
+
radius: U.radius,
|
|
1220
1234
|
clipBounds: [0, 0, t, n],
|
|
1221
|
-
minRasterStep:
|
|
1222
|
-
|
|
1235
|
+
minRasterStep: E,
|
|
1236
|
+
circleSides: Math.max(24, Math.round(64 * y)),
|
|
1237
|
+
simplifyTolerance: E * 0.4
|
|
1223
1238
|
});
|
|
1224
1239
|
}
|
|
1225
|
-
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") &&
|
|
1240
|
+
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && An(f) && c && c({
|
|
1226
1241
|
tool: e,
|
|
1227
1242
|
intent: e === "brush" ? "brush" : "roi",
|
|
1228
1243
|
coordinates: f,
|
|
1229
|
-
bbox:
|
|
1230
|
-
areaPx:
|
|
1231
|
-
}),
|
|
1232
|
-
}, [e,
|
|
1244
|
+
bbox: Mn(f),
|
|
1245
|
+
areaPx: ke(f)
|
|
1246
|
+
}), ct(!0), F();
|
|
1247
|
+
}, [e, c, ct, F, U.radius, U.edgeDetail, U.clickSelectRoi, t, n, u]), Bt = B(
|
|
1233
1248
|
(l, f) => {
|
|
1234
|
-
const
|
|
1235
|
-
if (!
|
|
1236
|
-
const
|
|
1249
|
+
const w = nt(l, f);
|
|
1250
|
+
if (!An(w)) return;
|
|
1251
|
+
const y = l === "stamp-rectangle-4096px" ? "patch" : "roi", E = {
|
|
1237
1252
|
tool: l,
|
|
1238
|
-
intent:
|
|
1239
|
-
coordinates:
|
|
1240
|
-
bbox:
|
|
1241
|
-
areaPx:
|
|
1253
|
+
intent: y,
|
|
1254
|
+
coordinates: w,
|
|
1255
|
+
bbox: Mn(w),
|
|
1256
|
+
areaPx: ke(w)
|
|
1242
1257
|
};
|
|
1243
|
-
|
|
1258
|
+
c?.(E), y === "patch" && h && h(E);
|
|
1244
1259
|
},
|
|
1245
|
-
[
|
|
1246
|
-
),
|
|
1260
|
+
[nt, c, h]
|
|
1261
|
+
), Ut = B(
|
|
1247
1262
|
(l, f) => {
|
|
1248
|
-
const
|
|
1249
|
-
if (!
|
|
1263
|
+
const w = a.current, y = Math.max(1e-6, w?.getViewState?.().zoom ?? 1), E = ti / y, I = E * E, Y = l.points[l.points.length - 1];
|
|
1264
|
+
if (!Y) {
|
|
1250
1265
|
l.points.push(f), l.current = f;
|
|
1251
1266
|
return;
|
|
1252
1267
|
}
|
|
1253
|
-
const V = f[0] -
|
|
1254
|
-
V * V +
|
|
1268
|
+
const V = f[0] - Y[0], W = f[1] - Y[1];
|
|
1269
|
+
V * V + W * W >= I ? l.points.push(f) : l.points[l.points.length - 1] = f, l.current = f;
|
|
1255
1270
|
},
|
|
1256
1271
|
[a]
|
|
1257
|
-
), qt =
|
|
1272
|
+
), qt = B(
|
|
1258
1273
|
(l) => {
|
|
1259
|
-
if (!
|
|
1260
|
-
const f =
|
|
1274
|
+
if (!Q || e === "cursor" || l.button !== 0) return;
|
|
1275
|
+
const f = ot(l);
|
|
1261
1276
|
if (!f) return;
|
|
1262
|
-
if (l.preventDefault(), l.stopPropagation(),
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1277
|
+
if (l.preventDefault(), l.stopPropagation(), we(e)) {
|
|
1278
|
+
const E = dt.current;
|
|
1279
|
+
E.stampCenter = f, Bt(e, f), F();
|
|
1265
1280
|
return;
|
|
1266
1281
|
}
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1282
|
+
const w = K.current;
|
|
1283
|
+
w && w.setPointerCapture(l.pointerId);
|
|
1284
|
+
const y = dt.current;
|
|
1285
|
+
y.isDrawing = !0, y.pointerId = l.pointerId, y.start = f, y.current = f, y.cursor = f, y.points = e === "freehand" || e === "brush" ? [f] : [], F();
|
|
1271
1286
|
},
|
|
1272
|
-
[
|
|
1273
|
-
),
|
|
1287
|
+
[Q, e, ot, Bt, F]
|
|
1288
|
+
), pt = B(
|
|
1274
1289
|
(l) => {
|
|
1275
|
-
if (!
|
|
1276
|
-
const f =
|
|
1290
|
+
if (!Q || e === "cursor") return;
|
|
1291
|
+
const f = ot(l);
|
|
1277
1292
|
if (!f) return;
|
|
1278
|
-
if (
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1293
|
+
if (we(e)) {
|
|
1294
|
+
const y = dt.current;
|
|
1295
|
+
y.stampCenter = f, l.preventDefault(), l.stopPropagation(), F();
|
|
1281
1296
|
return;
|
|
1282
1297
|
}
|
|
1283
|
-
const
|
|
1298
|
+
const w = dt.current;
|
|
1284
1299
|
if (e === "brush") {
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1300
|
+
if (w.cursor = f, !w.isDrawing || w.pointerId !== l.pointerId) {
|
|
1301
|
+
F();
|
|
1287
1302
|
return;
|
|
1288
1303
|
}
|
|
1289
|
-
l.preventDefault(), l.stopPropagation(),
|
|
1304
|
+
l.preventDefault(), l.stopPropagation(), Ut(w, f), F();
|
|
1290
1305
|
return;
|
|
1291
1306
|
}
|
|
1292
|
-
if (!(!
|
|
1307
|
+
if (!(!w.isDrawing || w.pointerId !== l.pointerId)) {
|
|
1293
1308
|
if (l.preventDefault(), l.stopPropagation(), e === "freehand") {
|
|
1294
|
-
const
|
|
1309
|
+
const y = a.current, E = Math.max(1e-6, y?.getViewState?.().zoom ?? 1), I = Dr / E, Y = I * I, V = w.points[w.points.length - 1];
|
|
1295
1310
|
if (!V)
|
|
1296
|
-
|
|
1311
|
+
w.points.push(f);
|
|
1297
1312
|
else {
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1313
|
+
const W = f[0] - V[0], lt = f[1] - V[1];
|
|
1314
|
+
W * W + lt * lt >= Y && w.points.push(f);
|
|
1300
1315
|
}
|
|
1301
1316
|
} else
|
|
1302
|
-
|
|
1303
|
-
|
|
1317
|
+
w.current = f;
|
|
1318
|
+
F();
|
|
1304
1319
|
}
|
|
1305
1320
|
},
|
|
1306
|
-
[
|
|
1307
|
-
),
|
|
1321
|
+
[Q, e, ot, F, a, Ut]
|
|
1322
|
+
), ue = B(
|
|
1308
1323
|
(l) => {
|
|
1309
1324
|
const f = dt.current;
|
|
1310
1325
|
if (!f.isDrawing || f.pointerId !== l.pointerId) return;
|
|
1311
1326
|
l.preventDefault(), l.stopPropagation();
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
const
|
|
1315
|
-
if (
|
|
1327
|
+
const w = ot(l);
|
|
1328
|
+
w && (f.cursor = w, e === "brush" ? Ut(f, w) : f.current = w);
|
|
1329
|
+
const y = K.current;
|
|
1330
|
+
if (y && y.hasPointerCapture(l.pointerId))
|
|
1316
1331
|
try {
|
|
1317
|
-
|
|
1332
|
+
y.releasePointerCapture(l.pointerId);
|
|
1318
1333
|
} catch {
|
|
1319
1334
|
}
|
|
1320
|
-
|
|
1335
|
+
Gt();
|
|
1321
1336
|
},
|
|
1322
|
-
[
|
|
1323
|
-
),
|
|
1337
|
+
[Gt, ot, e, Ut]
|
|
1338
|
+
), ce = B(() => {
|
|
1324
1339
|
const l = dt.current;
|
|
1325
1340
|
let f = !1;
|
|
1326
|
-
e === "brush" && !l.isDrawing && l.cursor && (l.cursor = null, f = !0),
|
|
1327
|
-
}, [e,
|
|
1341
|
+
e === "brush" && !l.isDrawing && l.cursor && (l.cursor = null, f = !0), we(e) && l.stampCenter && (l.stampCenter = null, f = !0), f && F();
|
|
1342
|
+
}, [e, F]);
|
|
1328
1343
|
return X(() => {
|
|
1329
|
-
|
|
1330
|
-
const l =
|
|
1344
|
+
gt(), F();
|
|
1345
|
+
const l = K.current;
|
|
1331
1346
|
if (!l) return;
|
|
1332
1347
|
const f = new ResizeObserver(() => {
|
|
1333
|
-
|
|
1348
|
+
gt(), F();
|
|
1334
1349
|
});
|
|
1335
1350
|
return f.observe(l), () => {
|
|
1336
1351
|
f.disconnect();
|
|
1337
1352
|
};
|
|
1338
|
-
}, [
|
|
1339
|
-
|
|
1340
|
-
}, [
|
|
1341
|
-
|
|
1342
|
-
}, [e,
|
|
1343
|
-
|
|
1344
|
-
}, [
|
|
1345
|
-
if (
|
|
1346
|
-
return
|
|
1347
|
-
|
|
1353
|
+
}, [gt, F]), X(() => {
|
|
1354
|
+
Q || ct(), F();
|
|
1355
|
+
}, [Q, F, ct]), X(() => {
|
|
1356
|
+
Kt.current !== e && (Kt.current = e, ct(), F());
|
|
1357
|
+
}, [e, ct, F]), X(() => {
|
|
1358
|
+
F();
|
|
1359
|
+
}, [d, M, J, F]), X(() => {
|
|
1360
|
+
if (ht)
|
|
1361
|
+
return ht.current = F, () => {
|
|
1362
|
+
ht.current === F && (ht.current = null);
|
|
1348
1363
|
};
|
|
1349
|
-
}, [
|
|
1350
|
-
if (!
|
|
1364
|
+
}, [ht, F]), X(() => {
|
|
1365
|
+
if (!Q) return;
|
|
1351
1366
|
const l = (f) => {
|
|
1352
|
-
f.key === "Escape" && (
|
|
1367
|
+
f.key === "Escape" && (ct(), F());
|
|
1353
1368
|
};
|
|
1354
1369
|
return window.addEventListener("keydown", l), () => {
|
|
1355
1370
|
window.removeEventListener("keydown", l);
|
|
1356
1371
|
};
|
|
1357
|
-
}, [
|
|
1372
|
+
}, [Q, ct, F]), /* @__PURE__ */ Ft(
|
|
1358
1373
|
"canvas",
|
|
1359
1374
|
{
|
|
1360
|
-
ref:
|
|
1361
|
-
className:
|
|
1362
|
-
style:
|
|
1375
|
+
ref: K,
|
|
1376
|
+
className: vt,
|
|
1377
|
+
style: At,
|
|
1363
1378
|
onPointerDown: qt,
|
|
1364
|
-
onPointerMove:
|
|
1365
|
-
onPointerUp:
|
|
1366
|
-
onPointerCancel:
|
|
1367
|
-
onPointerLeave:
|
|
1379
|
+
onPointerMove: pt,
|
|
1380
|
+
onPointerUp: ue,
|
|
1381
|
+
onPointerCancel: ue,
|
|
1382
|
+
onPointerLeave: ce,
|
|
1368
1383
|
onContextMenu: (l) => {
|
|
1369
|
-
|
|
1384
|
+
Q && l.preventDefault();
|
|
1370
1385
|
},
|
|
1371
1386
|
onWheel: (l) => {
|
|
1372
|
-
if (!
|
|
1373
|
-
const f =
|
|
1374
|
-
if (!f || typeof
|
|
1387
|
+
if (!Q) return;
|
|
1388
|
+
const f = K.current, w = a.current;
|
|
1389
|
+
if (!f || typeof w?.zoomBy != "function") return;
|
|
1375
1390
|
l.preventDefault(), l.stopPropagation();
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1391
|
+
const y = f.getBoundingClientRect(), E = l.clientX - y.left, I = l.clientY - y.top;
|
|
1392
|
+
w.zoomBy(l.deltaY < 0 ? Yr : Wr, E, I), F();
|
|
1378
1393
|
}
|
|
1379
1394
|
}
|
|
1380
1395
|
);
|
|
1381
1396
|
}
|
|
1382
|
-
function
|
|
1397
|
+
function vn(e) {
|
|
1383
1398
|
return String(e ?? "").replace(/\/+$/, "");
|
|
1384
1399
|
}
|
|
1385
1400
|
function Yn(e) {
|
|
1386
1401
|
const t = String(e ?? "");
|
|
1387
1402
|
return t.startsWith("/") ? t : `/${t}`;
|
|
1388
1403
|
}
|
|
1389
|
-
function
|
|
1390
|
-
const t =
|
|
1404
|
+
function wi(e) {
|
|
1405
|
+
const t = vn(e);
|
|
1391
1406
|
if (!t) return "";
|
|
1392
1407
|
if (/\/TileGroup\d+$/i.test(t)) return t;
|
|
1393
1408
|
let n = null;
|
|
@@ -1397,20 +1412,20 @@ function hi(e) {
|
|
|
1397
1412
|
n = null;
|
|
1398
1413
|
}
|
|
1399
1414
|
if (n) {
|
|
1400
|
-
const r = `${n.protocol}//${n.host}`, i =
|
|
1415
|
+
const r = `${n.protocol}//${n.host}`, i = vn(n.pathname || "");
|
|
1401
1416
|
return /\/ims$/i.test(i) ? `${r}${i}` : /\/tiles$/i.test(i) ? `${r}${i}` : `${r}${i}/tiles`;
|
|
1402
1417
|
}
|
|
1403
1418
|
return /\/ims$/i.test(t) ? "/ims" : /\/tiles$/i.test(t) ? `${t}` : `${t}/tiles`;
|
|
1404
1419
|
}
|
|
1405
|
-
function
|
|
1420
|
+
function po(e, t) {
|
|
1406
1421
|
const n = e?.imsInfo || {}, r = !!e?.imsInfo, i = Number(n.width ?? e?.width ?? 0), o = Number(n.height ?? e?.height ?? 0), s = Number(n.tileSize ?? e?.tileSize ?? 0), a = Number(n.zoom ?? e?.zoom ?? 0), u = String(n.path ?? e?.path ?? ""), c = Number(n.mpp ?? e?.mpp ?? 0);
|
|
1407
1422
|
if (!i || !o || !s || !u)
|
|
1408
1423
|
throw new Error("이미지 메타데이터가 불완전합니다. width/height/tileSize/path 확인 필요");
|
|
1409
|
-
const h = Array.isArray(e?.terms) ? e.terms.map((
|
|
1410
|
-
termId: String(
|
|
1411
|
-
termName: String(
|
|
1412
|
-
termColor: String(
|
|
1413
|
-
})) : [], g = Yn(u), d =
|
|
1424
|
+
const h = Array.isArray(e?.terms) ? e.terms.map((x) => ({
|
|
1425
|
+
termId: String(x?.termId ?? ""),
|
|
1426
|
+
termName: String(x?.termName ?? ""),
|
|
1427
|
+
termColor: String(x?.termColor ?? "")
|
|
1428
|
+
})) : [], g = Yn(u), d = wi(t), p = r ? (x, S, P) => `${d}${g}/${x}/${P}_${S}.webp` : void 0;
|
|
1414
1429
|
return {
|
|
1415
1430
|
id: e?._id || "unknown",
|
|
1416
1431
|
name: e?.name || "unknown",
|
|
@@ -1422,7 +1437,7 @@ function uo(e, t) {
|
|
|
1422
1437
|
tilePath: u,
|
|
1423
1438
|
tileBaseUrl: t,
|
|
1424
1439
|
terms: h,
|
|
1425
|
-
tileUrlBuilder:
|
|
1440
|
+
tileUrlBuilder: p
|
|
1426
1441
|
};
|
|
1427
1442
|
}
|
|
1428
1443
|
function Wn(e, t, n, r) {
|
|
@@ -1431,7 +1446,7 @@ function Wn(e, t, n, r) {
|
|
|
1431
1446
|
const i = Yn(e.tilePath);
|
|
1432
1447
|
return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
|
|
1433
1448
|
}
|
|
1434
|
-
const
|
|
1449
|
+
const bt = {
|
|
1435
1450
|
width: 220,
|
|
1436
1451
|
height: 140,
|
|
1437
1452
|
margin: 16,
|
|
@@ -1446,13 +1461,13 @@ const St = {
|
|
|
1446
1461
|
showThumbnail: !0,
|
|
1447
1462
|
maxThumbnailTiles: 16
|
|
1448
1463
|
};
|
|
1449
|
-
function
|
|
1464
|
+
function ee(e, t, n = 1) {
|
|
1450
1465
|
return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
|
|
1451
1466
|
}
|
|
1452
|
-
function
|
|
1467
|
+
function ye(e) {
|
|
1453
1468
|
return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
|
|
1454
1469
|
}
|
|
1455
|
-
function
|
|
1470
|
+
function yi({
|
|
1456
1471
|
source: e,
|
|
1457
1472
|
projectorRef: t,
|
|
1458
1473
|
authToken: n = "",
|
|
@@ -1461,253 +1476,253 @@ function fi({
|
|
|
1461
1476
|
className: o,
|
|
1462
1477
|
style: s
|
|
1463
1478
|
}) {
|
|
1464
|
-
const a =
|
|
1479
|
+
const a = j(null), u = j(null), c = j(null), h = j({
|
|
1465
1480
|
active: !1,
|
|
1466
1481
|
pointerId: null
|
|
1467
|
-
}), g =
|
|
1482
|
+
}), g = j(null), d = j(!1), p = ee(
|
|
1468
1483
|
r?.width,
|
|
1469
|
-
|
|
1484
|
+
bt.width,
|
|
1470
1485
|
64
|
|
1471
|
-
),
|
|
1486
|
+
), x = ee(
|
|
1472
1487
|
r?.height,
|
|
1473
|
-
|
|
1488
|
+
bt.height,
|
|
1474
1489
|
48
|
|
1475
|
-
),
|
|
1490
|
+
), S = ee(
|
|
1476
1491
|
r?.margin,
|
|
1477
|
-
|
|
1492
|
+
bt.margin,
|
|
1478
1493
|
0
|
|
1479
|
-
),
|
|
1494
|
+
), P = ee(
|
|
1480
1495
|
r?.borderRadius,
|
|
1481
|
-
|
|
1496
|
+
bt.borderRadius,
|
|
1482
1497
|
0
|
|
1483
|
-
),
|
|
1498
|
+
), k = ee(
|
|
1484
1499
|
r?.borderWidth,
|
|
1485
|
-
|
|
1500
|
+
bt.borderWidth,
|
|
1486
1501
|
0
|
|
1487
|
-
),
|
|
1502
|
+
), v = Math.max(
|
|
1488
1503
|
1,
|
|
1489
1504
|
Math.round(
|
|
1490
|
-
|
|
1505
|
+
ee(
|
|
1491
1506
|
r?.maxThumbnailTiles,
|
|
1492
|
-
|
|
1507
|
+
bt.maxThumbnailTiles,
|
|
1493
1508
|
1
|
|
1494
1509
|
)
|
|
1495
1510
|
)
|
|
1496
|
-
),
|
|
1497
|
-
const
|
|
1498
|
-
return
|
|
1511
|
+
), R = r?.backgroundColor || bt.backgroundColor, D = r?.borderColor || bt.borderColor, J = r?.viewportStrokeColor || bt.viewportStrokeColor, ft = r?.viewportFillColor || bt.viewportFillColor, at = r?.interactive ?? bt.interactive, $ = r?.showThumbnail ?? bt.showThumbnail, ht = r?.position || bt.position, vt = tt(() => {
|
|
1512
|
+
const M = {};
|
|
1513
|
+
return ht === "top-left" || ht === "bottom-left" ? M.left = S : M.right = S, ht === "top-left" || ht === "top-right" ? M.top = S : M.bottom = S, {
|
|
1499
1514
|
position: "absolute",
|
|
1500
|
-
...
|
|
1501
|
-
width:
|
|
1502
|
-
height:
|
|
1503
|
-
borderRadius:
|
|
1515
|
+
...M,
|
|
1516
|
+
width: p,
|
|
1517
|
+
height: x,
|
|
1518
|
+
borderRadius: P,
|
|
1504
1519
|
overflow: "hidden",
|
|
1505
1520
|
zIndex: 4,
|
|
1506
|
-
pointerEvents:
|
|
1521
|
+
pointerEvents: at ? "auto" : "none",
|
|
1507
1522
|
touchAction: "none",
|
|
1508
1523
|
boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
|
|
1509
1524
|
...s
|
|
1510
1525
|
};
|
|
1511
|
-
}, [
|
|
1512
|
-
const
|
|
1513
|
-
if (!
|
|
1514
|
-
const
|
|
1515
|
-
if (!
|
|
1516
|
-
const
|
|
1517
|
-
(
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
L -
|
|
1526
|
+
}, [S, ht, p, x, P, at, s]), Ot = B(() => {
|
|
1527
|
+
const M = a.current;
|
|
1528
|
+
if (!M) return;
|
|
1529
|
+
const C = M.getContext("2d");
|
|
1530
|
+
if (!C) return;
|
|
1531
|
+
const A = p, L = x, Z = Math.max(1, window.devicePixelRatio || 1), et = Math.max(1, Math.round(A * Z)), mt = Math.max(1, Math.round(L * Z));
|
|
1532
|
+
(M.width !== et || M.height !== mt) && (M.width = et, M.height = mt), C.setTransform(1, 0, 0, 1, 0, 0), C.clearRect(0, 0, M.width, M.height), C.setTransform(Z, 0, 0, Z, 0, 0), C.fillStyle = R, C.fillRect(0, 0, A, L);
|
|
1533
|
+
const yt = u.current;
|
|
1534
|
+
yt && C.drawImage(yt, 0, 0, A, L), C.strokeStyle = D, C.lineWidth = k, C.strokeRect(
|
|
1535
|
+
k * 0.5,
|
|
1536
|
+
k * 0.5,
|
|
1537
|
+
A - k,
|
|
1538
|
+
L - k
|
|
1524
1539
|
);
|
|
1525
|
-
const
|
|
1526
|
-
if (!
|
|
1527
|
-
c.current =
|
|
1528
|
-
const
|
|
1529
|
-
(
|
|
1530
|
-
) ?
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1533
|
-
for (let
|
|
1534
|
-
const Gt =
|
|
1535
|
-
|
|
1540
|
+
const U = t.current, At = U?.getViewBounds?.(), gt = U?.getViewCorners?.(), N = ye(At) ? At : ye(c.current) ? c.current : null;
|
|
1541
|
+
if (!N) return;
|
|
1542
|
+
c.current = N;
|
|
1543
|
+
const G = A / Math.max(1, e.width), ut = L / Math.max(1, e.height), nt = Array.isArray(gt) && gt.length >= 4 && gt.every(
|
|
1544
|
+
(ot) => Array.isArray(ot) && ot.length >= 2 && Number.isFinite(ot[0]) && Number.isFinite(ot[1])
|
|
1545
|
+
) ? gt : null;
|
|
1546
|
+
if (nt) {
|
|
1547
|
+
C.beginPath();
|
|
1548
|
+
for (let ot = 0; ot < nt.length; ot += 1) {
|
|
1549
|
+
const Gt = nt[ot], Bt = it(Gt[0] * G, 0, A), Ut = it(Gt[1] * ut, 0, L);
|
|
1550
|
+
ot === 0 ? C.moveTo(Bt, Ut) : C.lineTo(Bt, Ut);
|
|
1536
1551
|
}
|
|
1537
|
-
|
|
1552
|
+
C.closePath(), C.fillStyle = ft, C.fill(), C.strokeStyle = J, C.lineWidth = 1.5, C.stroke();
|
|
1538
1553
|
return;
|
|
1539
1554
|
}
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
Math.max(1,
|
|
1545
|
-
Math.max(1,
|
|
1555
|
+
const rt = it(N[0] * G, 0, A), q = it(N[1] * ut, 0, L), It = it(N[2] * G, 0, A), _t = it(N[3] * ut, 0, L), F = Math.max(1, It - rt), ct = Math.max(1, _t - q);
|
|
1556
|
+
C.fillStyle = ft, C.fillRect(rt, q, F, ct), C.strokeStyle = J, C.lineWidth = 1.5, C.strokeRect(
|
|
1557
|
+
rt + 0.5,
|
|
1558
|
+
q + 0.5,
|
|
1559
|
+
Math.max(1, F - 1),
|
|
1560
|
+
Math.max(1, ct - 1)
|
|
1546
1561
|
);
|
|
1547
1562
|
}, [
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1563
|
+
p,
|
|
1564
|
+
x,
|
|
1565
|
+
R,
|
|
1566
|
+
D,
|
|
1567
|
+
k,
|
|
1553
1568
|
t,
|
|
1554
1569
|
e.width,
|
|
1555
1570
|
e.height,
|
|
1556
1571
|
ft,
|
|
1557
|
-
|
|
1558
|
-
]),
|
|
1572
|
+
J
|
|
1573
|
+
]), K = B(() => {
|
|
1559
1574
|
d.current || (d.current = !0, g.current = requestAnimationFrame(() => {
|
|
1560
|
-
d.current = !1, g.current = null,
|
|
1575
|
+
d.current = !1, g.current = null, Ot();
|
|
1561
1576
|
}));
|
|
1562
|
-
}, [
|
|
1563
|
-
(
|
|
1564
|
-
const
|
|
1565
|
-
if (!
|
|
1566
|
-
const L =
|
|
1577
|
+
}, [Ot]), Ct = B(
|
|
1578
|
+
(M, C) => {
|
|
1579
|
+
const A = a.current;
|
|
1580
|
+
if (!A) return null;
|
|
1581
|
+
const L = A.getBoundingClientRect();
|
|
1567
1582
|
if (!L.width || !L.height) return null;
|
|
1568
|
-
const
|
|
1569
|
-
return [
|
|
1583
|
+
const Z = it((M - L.left) / L.width, 0, 1), et = it((C - L.top) / L.height, 0, 1);
|
|
1584
|
+
return [Z * e.width, et * e.height];
|
|
1570
1585
|
},
|
|
1571
1586
|
[e.width, e.height]
|
|
1572
|
-
),
|
|
1573
|
-
(
|
|
1574
|
-
const
|
|
1575
|
-
if (!
|
|
1576
|
-
if (
|
|
1577
|
-
|
|
1587
|
+
), zt = B(
|
|
1588
|
+
(M, C) => {
|
|
1589
|
+
const A = t.current;
|
|
1590
|
+
if (!A) return;
|
|
1591
|
+
if (A.setViewCenter) {
|
|
1592
|
+
A.setViewCenter(M, C), K();
|
|
1578
1593
|
return;
|
|
1579
1594
|
}
|
|
1580
|
-
const L =
|
|
1581
|
-
if (
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
offsetX:
|
|
1585
|
-
offsetY:
|
|
1586
|
-
}),
|
|
1595
|
+
const L = A.getViewBounds?.(), Z = ye(L) ? L : ye(c.current) ? c.current : null;
|
|
1596
|
+
if (!Z) return;
|
|
1597
|
+
const et = Math.max(1e-6, Z[2] - Z[0]), mt = Math.max(1e-6, Z[3] - Z[1]);
|
|
1598
|
+
A.setViewState({
|
|
1599
|
+
offsetX: M - et * 0.5,
|
|
1600
|
+
offsetY: C - mt * 0.5
|
|
1601
|
+
}), K();
|
|
1587
1602
|
},
|
|
1588
|
-
[t,
|
|
1589
|
-
),
|
|
1590
|
-
(
|
|
1591
|
-
if (!
|
|
1592
|
-
const
|
|
1593
|
-
if (!
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1603
|
+
[t, K]
|
|
1604
|
+
), Kt = B(
|
|
1605
|
+
(M) => {
|
|
1606
|
+
if (!at || M.button !== 0) return;
|
|
1607
|
+
const C = a.current;
|
|
1608
|
+
if (!C) return;
|
|
1609
|
+
const A = Ct(M.clientX, M.clientY);
|
|
1610
|
+
A && (M.preventDefault(), M.stopPropagation(), C.setPointerCapture(M.pointerId), h.current = { active: !0, pointerId: M.pointerId }, zt(A[0], A[1]));
|
|
1596
1611
|
},
|
|
1597
|
-
[
|
|
1598
|
-
),
|
|
1599
|
-
(
|
|
1600
|
-
const
|
|
1601
|
-
if (!
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1612
|
+
[at, Ct, zt]
|
|
1613
|
+
), dt = B(
|
|
1614
|
+
(M) => {
|
|
1615
|
+
const C = h.current;
|
|
1616
|
+
if (!C.active || C.pointerId !== M.pointerId) return;
|
|
1617
|
+
const A = Ct(M.clientX, M.clientY);
|
|
1618
|
+
A && (M.preventDefault(), M.stopPropagation(), zt(A[0], A[1]));
|
|
1604
1619
|
},
|
|
1605
|
-
[
|
|
1606
|
-
),
|
|
1607
|
-
(
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1620
|
+
[Ct, zt]
|
|
1621
|
+
), Q = B(
|
|
1622
|
+
(M) => {
|
|
1623
|
+
const C = h.current;
|
|
1624
|
+
if (!C.active || C.pointerId !== M.pointerId) return;
|
|
1625
|
+
const A = a.current;
|
|
1626
|
+
if (A && A.hasPointerCapture(M.pointerId))
|
|
1612
1627
|
try {
|
|
1613
|
-
|
|
1628
|
+
A.releasePointerCapture(M.pointerId);
|
|
1614
1629
|
} catch {
|
|
1615
1630
|
}
|
|
1616
|
-
h.current = { active: !1, pointerId: null },
|
|
1631
|
+
h.current = { active: !1, pointerId: null }, K();
|
|
1617
1632
|
},
|
|
1618
|
-
[
|
|
1633
|
+
[K]
|
|
1619
1634
|
);
|
|
1620
1635
|
return X(() => {
|
|
1621
|
-
let
|
|
1622
|
-
u.current = null,
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1636
|
+
let M = !1;
|
|
1637
|
+
u.current = null, K();
|
|
1638
|
+
const C = 0, A = 2 ** (e.maxTierZoom - C), L = Math.ceil(e.width / A), Z = Math.ceil(e.height / A), et = Math.max(1, Math.ceil(L / e.tileSize)), mt = Math.max(1, Math.ceil(Z / e.tileSize)), yt = et * mt;
|
|
1639
|
+
if (!$ || yt > v)
|
|
1625
1640
|
return;
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
const
|
|
1629
|
-
if (!
|
|
1641
|
+
const U = document.createElement("canvas");
|
|
1642
|
+
U.width = Math.max(1, Math.round(p)), U.height = Math.max(1, Math.round(x));
|
|
1643
|
+
const At = U.getContext("2d");
|
|
1644
|
+
if (!At)
|
|
1630
1645
|
return;
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1633
|
-
for (let
|
|
1634
|
-
for (let
|
|
1635
|
-
const
|
|
1636
|
-
|
|
1637
|
-
url: Wn(e,
|
|
1638
|
-
bounds: [
|
|
1646
|
+
At.fillStyle = R, At.fillRect(0, 0, U.width, U.height);
|
|
1647
|
+
const gt = [];
|
|
1648
|
+
for (let N = 0; N < mt; N += 1)
|
|
1649
|
+
for (let G = 0; G < et; G += 1) {
|
|
1650
|
+
const ut = G * e.tileSize * A, nt = N * e.tileSize * A, rt = Math.min((G + 1) * e.tileSize, L) * A, q = Math.min((N + 1) * e.tileSize, Z) * A;
|
|
1651
|
+
gt.push({
|
|
1652
|
+
url: Wn(e, C, G, N),
|
|
1653
|
+
bounds: [ut, nt, rt, q]
|
|
1639
1654
|
});
|
|
1640
1655
|
}
|
|
1641
1656
|
return Promise.allSettled(
|
|
1642
|
-
|
|
1643
|
-
const
|
|
1644
|
-
headers:
|
|
1657
|
+
gt.map(async (N) => {
|
|
1658
|
+
const G = !!n, ut = await fetch(N.url, {
|
|
1659
|
+
headers: G ? { Authorization: n } : void 0
|
|
1645
1660
|
});
|
|
1646
|
-
if (!
|
|
1647
|
-
throw new Error(`HTTP ${
|
|
1648
|
-
const
|
|
1649
|
-
return { tile:
|
|
1661
|
+
if (!ut.ok)
|
|
1662
|
+
throw new Error(`HTTP ${ut.status}`);
|
|
1663
|
+
const nt = await createImageBitmap(await ut.blob());
|
|
1664
|
+
return { tile: N, bitmap: nt };
|
|
1650
1665
|
})
|
|
1651
|
-
).then((
|
|
1652
|
-
if (
|
|
1653
|
-
for (const
|
|
1654
|
-
|
|
1666
|
+
).then((N) => {
|
|
1667
|
+
if (M) {
|
|
1668
|
+
for (const nt of N)
|
|
1669
|
+
nt.status === "fulfilled" && nt.value.bitmap.close();
|
|
1655
1670
|
return;
|
|
1656
1671
|
}
|
|
1657
|
-
const
|
|
1658
|
-
for (const
|
|
1659
|
-
if (
|
|
1672
|
+
const G = U.width / Math.max(1, e.width), ut = U.height / Math.max(1, e.height);
|
|
1673
|
+
for (const nt of N) {
|
|
1674
|
+
if (nt.status !== "fulfilled") continue;
|
|
1660
1675
|
const {
|
|
1661
|
-
tile: { bounds:
|
|
1662
|
-
bitmap:
|
|
1663
|
-
} =
|
|
1664
|
-
|
|
1676
|
+
tile: { bounds: rt },
|
|
1677
|
+
bitmap: q
|
|
1678
|
+
} = nt.value, It = rt[0] * G, _t = rt[1] * ut, F = Math.max(1, (rt[2] - rt[0]) * G), ct = Math.max(1, (rt[3] - rt[1]) * ut);
|
|
1679
|
+
At.drawImage(q, It, _t, F, ct), q.close();
|
|
1665
1680
|
}
|
|
1666
|
-
u.current =
|
|
1681
|
+
u.current = U, K();
|
|
1667
1682
|
}), () => {
|
|
1668
|
-
|
|
1683
|
+
M = !0;
|
|
1669
1684
|
};
|
|
1670
1685
|
}, [
|
|
1671
1686
|
e,
|
|
1672
1687
|
n,
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
M,
|
|
1676
|
-
W,
|
|
1688
|
+
p,
|
|
1689
|
+
x,
|
|
1677
1690
|
R,
|
|
1678
|
-
|
|
1691
|
+
$,
|
|
1692
|
+
v,
|
|
1693
|
+
K
|
|
1679
1694
|
]), X(() => {
|
|
1680
|
-
|
|
1681
|
-
}, [
|
|
1695
|
+
K();
|
|
1696
|
+
}, [K]), X(() => {
|
|
1682
1697
|
if (i)
|
|
1683
|
-
return i.current =
|
|
1684
|
-
i.current ===
|
|
1698
|
+
return i.current = K, () => {
|
|
1699
|
+
i.current === K && (i.current = null);
|
|
1685
1700
|
};
|
|
1686
|
-
}, [i,
|
|
1701
|
+
}, [i, K]), X(
|
|
1687
1702
|
() => () => {
|
|
1688
1703
|
h.current = { active: !1, pointerId: null }, g.current !== null && (cancelAnimationFrame(g.current), g.current = null), d.current = !1;
|
|
1689
1704
|
},
|
|
1690
1705
|
[]
|
|
1691
|
-
), /* @__PURE__ */
|
|
1706
|
+
), /* @__PURE__ */ Ft(
|
|
1692
1707
|
"canvas",
|
|
1693
1708
|
{
|
|
1694
1709
|
ref: a,
|
|
1695
1710
|
className: o,
|
|
1696
|
-
style:
|
|
1697
|
-
onPointerDown:
|
|
1698
|
-
onPointerMove:
|
|
1699
|
-
onPointerUp:
|
|
1700
|
-
onPointerCancel:
|
|
1701
|
-
onContextMenu: (
|
|
1702
|
-
|
|
1711
|
+
style: vt,
|
|
1712
|
+
onPointerDown: Kt,
|
|
1713
|
+
onPointerMove: dt,
|
|
1714
|
+
onPointerUp: Q,
|
|
1715
|
+
onPointerCancel: Q,
|
|
1716
|
+
onContextMenu: (M) => {
|
|
1717
|
+
M.preventDefault();
|
|
1703
1718
|
},
|
|
1704
|
-
onWheel: (
|
|
1705
|
-
|
|
1719
|
+
onWheel: (M) => {
|
|
1720
|
+
M.preventDefault(), M.stopPropagation();
|
|
1706
1721
|
}
|
|
1707
1722
|
}
|
|
1708
1723
|
);
|
|
1709
1724
|
}
|
|
1710
|
-
function
|
|
1725
|
+
function bo({
|
|
1711
1726
|
imageWidth: e,
|
|
1712
1727
|
imageHeight: t,
|
|
1713
1728
|
tiles: n,
|
|
@@ -1715,7 +1730,7 @@ function co({
|
|
|
1715
1730
|
className: i,
|
|
1716
1731
|
style: o
|
|
1717
1732
|
}) {
|
|
1718
|
-
const s =
|
|
1733
|
+
const s = j(null), a = j(null), u = tt(
|
|
1719
1734
|
() => ({ width: "100%", height: "100%", display: "block", ...o }),
|
|
1720
1735
|
[o]
|
|
1721
1736
|
);
|
|
@@ -1723,7 +1738,7 @@ function co({
|
|
|
1723
1738
|
const c = s.current;
|
|
1724
1739
|
if (!c)
|
|
1725
1740
|
return;
|
|
1726
|
-
const h = new
|
|
1741
|
+
const h = new hr({
|
|
1727
1742
|
canvas: c,
|
|
1728
1743
|
imageWidth: e,
|
|
1729
1744
|
imageHeight: t,
|
|
@@ -1738,9 +1753,9 @@ function co({
|
|
|
1738
1753
|
}, [n]), X(() => {
|
|
1739
1754
|
const c = a.current;
|
|
1740
1755
|
!c || !r || c.setViewState(r);
|
|
1741
|
-
}, [r]), /* @__PURE__ */
|
|
1756
|
+
}, [r]), /* @__PURE__ */ Ft("canvas", { ref: s, className: i, style: u });
|
|
1742
1757
|
}
|
|
1743
|
-
function
|
|
1758
|
+
function Vn(e) {
|
|
1744
1759
|
return Math.max(
|
|
1745
1760
|
0,
|
|
1746
1761
|
Math.min(
|
|
@@ -1750,15 +1765,15 @@ function On(e) {
|
|
|
1750
1765
|
)
|
|
1751
1766
|
);
|
|
1752
1767
|
}
|
|
1753
|
-
function
|
|
1768
|
+
function xi(e) {
|
|
1754
1769
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1755
1770
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1756
1771
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1757
1772
|
}
|
|
1758
|
-
function
|
|
1773
|
+
function On(e) {
|
|
1759
1774
|
const t = [];
|
|
1760
1775
|
for (const n of e ?? []) {
|
|
1761
|
-
const r =
|
|
1776
|
+
const r = xi(n);
|
|
1762
1777
|
if (r.length < 4) continue;
|
|
1763
1778
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
1764
1779
|
for (const [u, c] of r)
|
|
@@ -1767,7 +1782,7 @@ function Vn(e) {
|
|
|
1767
1782
|
}
|
|
1768
1783
|
return t;
|
|
1769
1784
|
}
|
|
1770
|
-
function
|
|
1785
|
+
function Si(e, t, n) {
|
|
1771
1786
|
let r = !1;
|
|
1772
1787
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
1773
1788
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -1777,25 +1792,25 @@ function mi(e, t, n) {
|
|
|
1777
1792
|
}
|
|
1778
1793
|
function Gn(e, t, n) {
|
|
1779
1794
|
for (const r of n)
|
|
1780
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
1795
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && Si(e, t, r.ring))
|
|
1781
1796
|
return !0;
|
|
1782
1797
|
return !1;
|
|
1783
1798
|
}
|
|
1784
|
-
function
|
|
1799
|
+
function Re(e, t) {
|
|
1785
1800
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1786
1801
|
return null;
|
|
1787
|
-
const n =
|
|
1802
|
+
const n = On(t ?? []);
|
|
1788
1803
|
if (n.length === 0)
|
|
1789
1804
|
return {
|
|
1790
1805
|
count: 0,
|
|
1791
1806
|
positions: new Float32Array(0),
|
|
1792
1807
|
paletteIndices: new Uint16Array(0)
|
|
1793
1808
|
};
|
|
1794
|
-
const r =
|
|
1809
|
+
const r = Vn(e), i = e.positions, o = e.paletteIndices, s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids : null, a = new Float32Array(r * 2), u = new Uint16Array(r), c = s ? new Uint32Array(r) : null;
|
|
1795
1810
|
let h = 0;
|
|
1796
1811
|
for (let d = 0; d < r; d += 1) {
|
|
1797
|
-
const
|
|
1798
|
-
Gn(
|
|
1812
|
+
const p = i[d * 2], x = i[d * 2 + 1];
|
|
1813
|
+
Gn(p, x, n) && (a[h * 2] = p, a[h * 2 + 1] = x, u[h] = o[d], c && (c[h] = s[d]), h += 1);
|
|
1799
1814
|
}
|
|
1800
1815
|
const g = {
|
|
1801
1816
|
count: h,
|
|
@@ -1804,13 +1819,13 @@ function Pe(e, t) {
|
|
|
1804
1819
|
};
|
|
1805
1820
|
return c && (g.ids = c.subarray(0, h)), g;
|
|
1806
1821
|
}
|
|
1807
|
-
function
|
|
1822
|
+
function Ti(e, t) {
|
|
1808
1823
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1809
1824
|
return new Uint32Array(0);
|
|
1810
|
-
const n =
|
|
1825
|
+
const n = On(t ?? []);
|
|
1811
1826
|
if (n.length === 0)
|
|
1812
1827
|
return new Uint32Array(0);
|
|
1813
|
-
const r =
|
|
1828
|
+
const r = Vn(e);
|
|
1814
1829
|
if (r === 0)
|
|
1815
1830
|
return new Uint32Array(0);
|
|
1816
1831
|
const i = e.positions, o = new Uint32Array(r);
|
|
@@ -1821,8 +1836,8 @@ function gi(e, t) {
|
|
|
1821
1836
|
}
|
|
1822
1837
|
return o.subarray(0, s);
|
|
1823
1838
|
}
|
|
1824
|
-
let
|
|
1825
|
-
const
|
|
1839
|
+
let xe = null;
|
|
1840
|
+
const Mi = `
|
|
1826
1841
|
struct Params {
|
|
1827
1842
|
pointCount: u32,
|
|
1828
1843
|
boundsCount: u32,
|
|
@@ -1854,20 +1869,20 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
|
1854
1869
|
outputMask[i] = inside;
|
|
1855
1870
|
}
|
|
1856
1871
|
`;
|
|
1857
|
-
function
|
|
1872
|
+
function Ai() {
|
|
1858
1873
|
if (typeof navigator > "u") return !1;
|
|
1859
1874
|
const e = navigator;
|
|
1860
1875
|
return typeof e.gpu == "object" && e.gpu !== null;
|
|
1861
1876
|
}
|
|
1862
1877
|
function qn() {
|
|
1863
|
-
if (!
|
|
1878
|
+
if (!Ai()) return null;
|
|
1864
1879
|
const t = navigator.gpu;
|
|
1865
1880
|
if (!t || typeof t != "object") return null;
|
|
1866
1881
|
const n = t;
|
|
1867
1882
|
return typeof n.requestAdapter != "function" ? null : n;
|
|
1868
1883
|
}
|
|
1869
|
-
const
|
|
1870
|
-
async function
|
|
1884
|
+
const Se = globalThis.GPUShaderStage?.COMPUTE ?? 4, Fe = globalThis.GPUBufferUsage?.STORAGE ?? 128, Te = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Pi = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Ri = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Ei = globalThis.GPUBufferUsage?.MAP_READ ?? 1, vi = globalThis.GPUMapMode?.READ ?? 1;
|
|
1885
|
+
async function wo() {
|
|
1871
1886
|
const e = qn();
|
|
1872
1887
|
if (!e)
|
|
1873
1888
|
return { supported: !1, features: [] };
|
|
@@ -1887,8 +1902,8 @@ async function lo() {
|
|
|
1887
1902
|
}
|
|
1888
1903
|
} : { supported: !1, features: [] };
|
|
1889
1904
|
}
|
|
1890
|
-
async function
|
|
1891
|
-
return
|
|
1905
|
+
async function Ci() {
|
|
1906
|
+
return xe || (xe = (async () => {
|
|
1892
1907
|
const e = qn();
|
|
1893
1908
|
if (!e) return null;
|
|
1894
1909
|
const t = await e.requestAdapter();
|
|
@@ -1897,40 +1912,40 @@ async function Ti() {
|
|
|
1897
1912
|
entries: [
|
|
1898
1913
|
{
|
|
1899
1914
|
binding: 0,
|
|
1900
|
-
visibility:
|
|
1915
|
+
visibility: Se,
|
|
1901
1916
|
buffer: { type: "read-only-storage" }
|
|
1902
1917
|
},
|
|
1903
1918
|
{
|
|
1904
1919
|
binding: 1,
|
|
1905
|
-
visibility:
|
|
1920
|
+
visibility: Se,
|
|
1906
1921
|
buffer: { type: "read-only-storage" }
|
|
1907
1922
|
},
|
|
1908
1923
|
{
|
|
1909
1924
|
binding: 2,
|
|
1910
|
-
visibility:
|
|
1925
|
+
visibility: Se,
|
|
1911
1926
|
buffer: { type: "storage" }
|
|
1912
1927
|
},
|
|
1913
1928
|
{
|
|
1914
1929
|
binding: 3,
|
|
1915
|
-
visibility:
|
|
1930
|
+
visibility: Se,
|
|
1916
1931
|
buffer: { type: "uniform" }
|
|
1917
1932
|
}
|
|
1918
1933
|
]
|
|
1919
1934
|
}), i = n.createComputePipeline({
|
|
1920
1935
|
layout: n.createPipelineLayout({ bindGroupLayouts: [r] }),
|
|
1921
1936
|
compute: {
|
|
1922
|
-
module: n.createShaderModule({ code:
|
|
1937
|
+
module: n.createShaderModule({ code: Mi }),
|
|
1923
1938
|
entryPoint: "main"
|
|
1924
1939
|
}
|
|
1925
1940
|
});
|
|
1926
1941
|
return { device: n, pipeline: i, bindGroupLayout: r };
|
|
1927
|
-
})(),
|
|
1942
|
+
})(), xe);
|
|
1928
1943
|
}
|
|
1929
|
-
function
|
|
1944
|
+
function Me(e, t) {
|
|
1930
1945
|
return Math.ceil(e / t) * t;
|
|
1931
1946
|
}
|
|
1932
|
-
async function
|
|
1933
|
-
const r = await
|
|
1947
|
+
async function Ii(e, t, n) {
|
|
1948
|
+
const r = await Ci();
|
|
1934
1949
|
if (!r) return null;
|
|
1935
1950
|
const i = Math.max(0, Math.floor(t)), o = Math.max(0, Math.floor(n.length / 4));
|
|
1936
1951
|
if (i === 0 || o === 0)
|
|
@@ -1942,20 +1957,20 @@ async function Mi(e, t, n) {
|
|
|
1942
1957
|
if (a > h || u > h || c > h)
|
|
1943
1958
|
return null;
|
|
1944
1959
|
const g = r.device.createBuffer({
|
|
1945
|
-
size:
|
|
1946
|
-
usage:
|
|
1960
|
+
size: Me(a, 4),
|
|
1961
|
+
usage: Fe | Te
|
|
1947
1962
|
}), d = r.device.createBuffer({
|
|
1948
|
-
size:
|
|
1949
|
-
usage:
|
|
1950
|
-
}),
|
|
1951
|
-
size:
|
|
1952
|
-
usage:
|
|
1953
|
-
}), y = r.device.createBuffer({
|
|
1954
|
-
size: 16,
|
|
1955
|
-
usage: yi | Se
|
|
1963
|
+
size: Me(u, 4),
|
|
1964
|
+
usage: Fe | Te
|
|
1965
|
+
}), p = r.device.createBuffer({
|
|
1966
|
+
size: Me(c, 4),
|
|
1967
|
+
usage: Fe | Pi
|
|
1956
1968
|
}), x = r.device.createBuffer({
|
|
1957
|
-
size:
|
|
1958
|
-
usage:
|
|
1969
|
+
size: 16,
|
|
1970
|
+
usage: Ri | Te
|
|
1971
|
+
}), S = r.device.createBuffer({
|
|
1972
|
+
size: Me(c, 4),
|
|
1973
|
+
usage: Te | Ei
|
|
1959
1974
|
});
|
|
1960
1975
|
r.device.queue.writeBuffer(
|
|
1961
1976
|
g,
|
|
@@ -1970,35 +1985,35 @@ async function Mi(e, t, n) {
|
|
|
1970
1985
|
n.byteOffset,
|
|
1971
1986
|
u
|
|
1972
1987
|
), r.device.queue.writeBuffer(
|
|
1973
|
-
|
|
1988
|
+
x,
|
|
1974
1989
|
0,
|
|
1975
1990
|
new Uint32Array([s, o, 0, 0])
|
|
1976
1991
|
);
|
|
1977
|
-
const
|
|
1992
|
+
const P = r.device.createBindGroup({
|
|
1978
1993
|
layout: r.bindGroupLayout,
|
|
1979
1994
|
entries: [
|
|
1980
1995
|
{ binding: 0, resource: { buffer: g } },
|
|
1981
1996
|
{ binding: 1, resource: { buffer: d } },
|
|
1982
|
-
{ binding: 2, resource: { buffer:
|
|
1983
|
-
{ binding: 3, resource: { buffer:
|
|
1997
|
+
{ binding: 2, resource: { buffer: p } },
|
|
1998
|
+
{ binding: 3, resource: { buffer: x } }
|
|
1984
1999
|
]
|
|
1985
|
-
}),
|
|
1986
|
-
|
|
1987
|
-
const
|
|
1988
|
-
return
|
|
2000
|
+
}), k = r.device.createCommandEncoder(), v = k.beginComputePass();
|
|
2001
|
+
v.setPipeline(r.pipeline), v.setBindGroup(0, P), v.dispatchWorkgroups(Math.ceil(s / 256)), v.end(), k.copyBufferToBuffer(p, 0, S, 0, c), r.device.queue.submit([k.finish()]), await S.mapAsync(vi);
|
|
2002
|
+
const R = S.getMappedRange(), D = new Uint32Array(R.slice(0));
|
|
2003
|
+
return S.unmap(), g.destroy(), d.destroy(), p.destroy(), x.destroy(), S.destroy(), D;
|
|
1989
2004
|
}
|
|
1990
|
-
function
|
|
2005
|
+
function Lt() {
|
|
1991
2006
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1992
2007
|
}
|
|
1993
|
-
function
|
|
2008
|
+
function _i(e) {
|
|
1994
2009
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1995
2010
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1996
2011
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1997
2012
|
}
|
|
1998
|
-
function
|
|
2013
|
+
function Bi(e) {
|
|
1999
2014
|
const t = [];
|
|
2000
2015
|
for (const n of e ?? []) {
|
|
2001
|
-
const r =
|
|
2016
|
+
const r = _i(n);
|
|
2002
2017
|
if (r.length < 4) continue;
|
|
2003
2018
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
2004
2019
|
for (const [u, c] of r)
|
|
@@ -2007,7 +2022,7 @@ function Pi(e) {
|
|
|
2007
2022
|
}
|
|
2008
2023
|
return t;
|
|
2009
2024
|
}
|
|
2010
|
-
function
|
|
2025
|
+
function Ui(e, t, n) {
|
|
2011
2026
|
let r = !1;
|
|
2012
2027
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
2013
2028
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -2015,26 +2030,26 @@ function vi(e, t, n) {
|
|
|
2015
2030
|
}
|
|
2016
2031
|
return r;
|
|
2017
2032
|
}
|
|
2018
|
-
function
|
|
2033
|
+
function Cn(e, t, n) {
|
|
2019
2034
|
for (const r of n)
|
|
2020
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
2035
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && Ui(e, t, r.ring))
|
|
2021
2036
|
return !0;
|
|
2022
2037
|
return !1;
|
|
2023
2038
|
}
|
|
2024
|
-
async function
|
|
2025
|
-
const r =
|
|
2039
|
+
async function Fi(e, t, n = {}) {
|
|
2040
|
+
const r = Lt(), i = n.bridgeToDraw === !0;
|
|
2026
2041
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2027
2042
|
return {
|
|
2028
2043
|
data: null,
|
|
2029
2044
|
meta: {
|
|
2030
2045
|
mode: "hybrid-webgpu",
|
|
2031
|
-
durationMs:
|
|
2046
|
+
durationMs: Lt() - r,
|
|
2032
2047
|
usedWebGpu: !1,
|
|
2033
2048
|
candidateCount: 0,
|
|
2034
2049
|
bridgedToDraw: !1
|
|
2035
2050
|
}
|
|
2036
2051
|
};
|
|
2037
|
-
const o =
|
|
2052
|
+
const o = Bi(t ?? []);
|
|
2038
2053
|
if (o.length === 0)
|
|
2039
2054
|
return {
|
|
2040
2055
|
data: {
|
|
@@ -2044,7 +2059,7 @@ async function Ri(e, t, n = {}) {
|
|
|
2044
2059
|
},
|
|
2045
2060
|
meta: {
|
|
2046
2061
|
mode: "hybrid-webgpu",
|
|
2047
|
-
durationMs:
|
|
2062
|
+
durationMs: Lt() - r,
|
|
2048
2063
|
usedWebGpu: !1,
|
|
2049
2064
|
candidateCount: 0,
|
|
2050
2065
|
bridgedToDraw: !1
|
|
@@ -2060,56 +2075,56 @@ async function Ri(e, t, n = {}) {
|
|
|
2060
2075
|
},
|
|
2061
2076
|
meta: {
|
|
2062
2077
|
mode: "hybrid-webgpu",
|
|
2063
|
-
durationMs:
|
|
2078
|
+
durationMs: Lt() - r,
|
|
2064
2079
|
usedWebGpu: !1,
|
|
2065
2080
|
candidateCount: 0,
|
|
2066
2081
|
bridgedToDraw: !1
|
|
2067
2082
|
}
|
|
2068
2083
|
};
|
|
2069
2084
|
const u = new Float32Array(o.length * 4);
|
|
2070
|
-
for (let
|
|
2071
|
-
const
|
|
2072
|
-
u[
|
|
2085
|
+
for (let v = 0; v < o.length; v += 1) {
|
|
2086
|
+
const R = v * 4, D = o[v];
|
|
2087
|
+
u[R] = D.minX, u[R + 1] = D.minY, u[R + 2] = D.maxX, u[R + 3] = D.maxY;
|
|
2073
2088
|
}
|
|
2074
2089
|
let c = null, h = !1;
|
|
2075
2090
|
try {
|
|
2076
|
-
c = await
|
|
2091
|
+
c = await Ii(e.positions, s, u), h = !!c;
|
|
2077
2092
|
} catch {
|
|
2078
2093
|
c = null, h = !1;
|
|
2079
2094
|
}
|
|
2080
2095
|
if (!c)
|
|
2081
2096
|
return {
|
|
2082
|
-
data:
|
|
2097
|
+
data: Re(e, t),
|
|
2083
2098
|
meta: {
|
|
2084
2099
|
mode: "hybrid-webgpu",
|
|
2085
|
-
durationMs:
|
|
2100
|
+
durationMs: Lt() - r,
|
|
2086
2101
|
usedWebGpu: !1,
|
|
2087
2102
|
candidateCount: s,
|
|
2088
2103
|
bridgedToDraw: !1
|
|
2089
2104
|
}
|
|
2090
2105
|
};
|
|
2091
2106
|
let g = 0;
|
|
2092
|
-
for (let
|
|
2093
|
-
c[
|
|
2107
|
+
for (let v = 0; v < s; v += 1)
|
|
2108
|
+
c[v] === 1 && (g += 1);
|
|
2094
2109
|
const d = new Uint32Array(g);
|
|
2095
2110
|
if (g > 0) {
|
|
2096
|
-
let
|
|
2097
|
-
for (let
|
|
2098
|
-
c[
|
|
2111
|
+
let v = 0;
|
|
2112
|
+
for (let R = 0; R < s; R += 1)
|
|
2113
|
+
c[R] === 1 && (d[v] = R, v += 1);
|
|
2099
2114
|
}
|
|
2100
2115
|
if (g === 0) {
|
|
2101
2116
|
if (i) {
|
|
2102
|
-
const
|
|
2117
|
+
const v = {
|
|
2103
2118
|
count: s,
|
|
2104
2119
|
positions: e.positions.subarray(0, s * 2),
|
|
2105
2120
|
paletteIndices: e.paletteIndices.subarray(0, s),
|
|
2106
2121
|
drawIndices: new Uint32Array(0)
|
|
2107
2122
|
};
|
|
2108
|
-
return a && (
|
|
2109
|
-
data:
|
|
2123
|
+
return a && (v.ids = a.subarray(0, s)), {
|
|
2124
|
+
data: v,
|
|
2110
2125
|
meta: {
|
|
2111
2126
|
mode: "hybrid-webgpu",
|
|
2112
|
-
durationMs:
|
|
2127
|
+
durationMs: Lt() - r,
|
|
2113
2128
|
usedWebGpu: !0,
|
|
2114
2129
|
candidateCount: 0,
|
|
2115
2130
|
bridgedToDraw: !0
|
|
@@ -2125,7 +2140,7 @@ async function Ri(e, t, n = {}) {
|
|
|
2125
2140
|
},
|
|
2126
2141
|
meta: {
|
|
2127
2142
|
mode: "hybrid-webgpu",
|
|
2128
|
-
durationMs:
|
|
2143
|
+
durationMs: Lt() - r,
|
|
2129
2144
|
usedWebGpu: !0,
|
|
2130
2145
|
candidateCount: 0,
|
|
2131
2146
|
bridgedToDraw: !1
|
|
@@ -2133,71 +2148,71 @@ async function Ri(e, t, n = {}) {
|
|
|
2133
2148
|
};
|
|
2134
2149
|
}
|
|
2135
2150
|
if (i) {
|
|
2136
|
-
const
|
|
2137
|
-
let
|
|
2138
|
-
for (let
|
|
2139
|
-
const ft = d[
|
|
2140
|
-
|
|
2151
|
+
const v = new Uint32Array(g);
|
|
2152
|
+
let R = 0;
|
|
2153
|
+
for (let J = 0; J < g; J += 1) {
|
|
2154
|
+
const ft = d[J] ?? 0, at = e.positions[ft * 2], $ = e.positions[ft * 2 + 1];
|
|
2155
|
+
Cn(at, $, o) && (v[R] = ft, R += 1);
|
|
2141
2156
|
}
|
|
2142
|
-
const
|
|
2157
|
+
const D = {
|
|
2143
2158
|
count: s,
|
|
2144
2159
|
positions: e.positions.subarray(0, s * 2),
|
|
2145
2160
|
paletteIndices: e.paletteIndices.subarray(0, s),
|
|
2146
|
-
drawIndices:
|
|
2161
|
+
drawIndices: v.subarray(0, R)
|
|
2147
2162
|
};
|
|
2148
|
-
return a && (
|
|
2149
|
-
data:
|
|
2163
|
+
return a && (D.ids = a.subarray(0, s)), {
|
|
2164
|
+
data: D,
|
|
2150
2165
|
meta: {
|
|
2151
2166
|
mode: "hybrid-webgpu",
|
|
2152
|
-
durationMs:
|
|
2167
|
+
durationMs: Lt() - r,
|
|
2153
2168
|
usedWebGpu: !0,
|
|
2154
2169
|
candidateCount: g,
|
|
2155
2170
|
bridgedToDraw: !0
|
|
2156
2171
|
}
|
|
2157
2172
|
};
|
|
2158
2173
|
}
|
|
2159
|
-
const
|
|
2160
|
-
let
|
|
2161
|
-
for (let
|
|
2162
|
-
const
|
|
2163
|
-
|
|
2174
|
+
const p = new Float32Array(g * 2), x = new Uint16Array(g), S = a ? new Uint32Array(g) : null;
|
|
2175
|
+
let P = 0;
|
|
2176
|
+
for (let v = 0; v < g; v += 1) {
|
|
2177
|
+
const R = d[v] ?? 0, D = e.positions[R * 2], J = e.positions[R * 2 + 1];
|
|
2178
|
+
Cn(D, J, o) && (p[P * 2] = D, p[P * 2 + 1] = J, x[P] = e.paletteIndices[R], S && (S[P] = a[R]), P += 1);
|
|
2164
2179
|
}
|
|
2165
|
-
const
|
|
2166
|
-
count:
|
|
2167
|
-
positions:
|
|
2168
|
-
paletteIndices:
|
|
2180
|
+
const k = {
|
|
2181
|
+
count: P,
|
|
2182
|
+
positions: p.subarray(0, P * 2),
|
|
2183
|
+
paletteIndices: x.subarray(0, P)
|
|
2169
2184
|
};
|
|
2170
|
-
return
|
|
2171
|
-
data:
|
|
2185
|
+
return S && (k.ids = S.subarray(0, P)), {
|
|
2186
|
+
data: k,
|
|
2172
2187
|
meta: {
|
|
2173
2188
|
mode: "hybrid-webgpu",
|
|
2174
|
-
durationMs:
|
|
2189
|
+
durationMs: Lt() - r,
|
|
2175
2190
|
usedWebGpu: !0,
|
|
2176
2191
|
candidateCount: g,
|
|
2177
2192
|
bridgedToDraw: !1
|
|
2178
2193
|
}
|
|
2179
2194
|
};
|
|
2180
2195
|
}
|
|
2181
|
-
let
|
|
2196
|
+
let wt = null, Ye = !0, $n = 1;
|
|
2182
2197
|
const Vt = /* @__PURE__ */ new Map();
|
|
2183
|
-
function
|
|
2198
|
+
function Yt() {
|
|
2184
2199
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2185
2200
|
}
|
|
2186
2201
|
function Hn() {
|
|
2187
|
-
if (!
|
|
2188
|
-
if (
|
|
2202
|
+
if (!Ye) return null;
|
|
2203
|
+
if (wt) return wt;
|
|
2189
2204
|
try {
|
|
2190
2205
|
const e = new Worker(new URL(
|
|
2191
2206
|
/* @vite-ignore */
|
|
2192
2207
|
"" + new URL("assets/roi-clip-worker-D3hALtsJ.js", import.meta.url).href,
|
|
2193
2208
|
import.meta.url
|
|
2194
2209
|
), { type: "module" });
|
|
2195
|
-
return e.addEventListener("message",
|
|
2210
|
+
return e.addEventListener("message", qe), e.addEventListener("error", $e), wt = e, e;
|
|
2196
2211
|
} catch {
|
|
2197
|
-
return
|
|
2212
|
+
return Ye = !1, null;
|
|
2198
2213
|
}
|
|
2199
2214
|
}
|
|
2200
|
-
function
|
|
2215
|
+
function qe(e) {
|
|
2201
2216
|
const t = e.data;
|
|
2202
2217
|
if (!t) return;
|
|
2203
2218
|
const n = Vt.get(t.id);
|
|
@@ -2216,7 +2231,7 @@ function Ge(e) {
|
|
|
2216
2231
|
indices: c,
|
|
2217
2232
|
meta: {
|
|
2218
2233
|
mode: "worker",
|
|
2219
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2234
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
|
|
2220
2235
|
}
|
|
2221
2236
|
});
|
|
2222
2237
|
return;
|
|
@@ -2234,25 +2249,25 @@ function Ge(e) {
|
|
|
2234
2249
|
data: a,
|
|
2235
2250
|
meta: {
|
|
2236
2251
|
mode: "worker",
|
|
2237
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2252
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
|
|
2238
2253
|
}
|
|
2239
2254
|
});
|
|
2240
2255
|
}
|
|
2241
|
-
function
|
|
2242
|
-
|
|
2256
|
+
function $e() {
|
|
2257
|
+
Ye = !1, wt && (wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null);
|
|
2243
2258
|
for (const [, e] of Vt)
|
|
2244
2259
|
e.reject(new Error("worker crashed"));
|
|
2245
2260
|
Vt.clear();
|
|
2246
2261
|
}
|
|
2247
|
-
function
|
|
2248
|
-
if (
|
|
2249
|
-
|
|
2262
|
+
function yo() {
|
|
2263
|
+
if (wt) {
|
|
2264
|
+
wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null;
|
|
2250
2265
|
for (const [, e] of Vt)
|
|
2251
2266
|
e.reject(new Error("worker terminated"));
|
|
2252
2267
|
Vt.clear();
|
|
2253
2268
|
}
|
|
2254
2269
|
}
|
|
2255
|
-
async function
|
|
2270
|
+
async function zi(e, t) {
|
|
2256
2271
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2257
2272
|
return {
|
|
2258
2273
|
data: null,
|
|
@@ -2260,13 +2275,13 @@ async function Ei(e, t) {
|
|
|
2260
2275
|
};
|
|
2261
2276
|
const n = Hn();
|
|
2262
2277
|
if (!n) {
|
|
2263
|
-
const c =
|
|
2278
|
+
const c = Yt();
|
|
2264
2279
|
return {
|
|
2265
|
-
data:
|
|
2266
|
-
meta: { mode: "sync", durationMs:
|
|
2280
|
+
data: Re(e, t),
|
|
2281
|
+
meta: { mode: "sync", durationMs: Yt() - c }
|
|
2267
2282
|
};
|
|
2268
2283
|
}
|
|
2269
|
-
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = e.paletteIndices.slice(0, r), s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids.slice(0, r) : null, a = $n++, u =
|
|
2284
|
+
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = e.paletteIndices.slice(0, r), s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids.slice(0, r) : null, a = $n++, u = Yt();
|
|
2270
2285
|
return new Promise((c, h) => {
|
|
2271
2286
|
Vt.set(a, { kind: "data", resolve: c, reject: h, startMs: u });
|
|
2272
2287
|
const g = {
|
|
@@ -2281,7 +2296,7 @@ async function Ei(e, t) {
|
|
|
2281
2296
|
s && d.push(s.buffer), n.postMessage(g, d);
|
|
2282
2297
|
});
|
|
2283
2298
|
}
|
|
2284
|
-
async function
|
|
2299
|
+
async function xo(e, t) {
|
|
2285
2300
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2286
2301
|
return {
|
|
2287
2302
|
indices: new Uint32Array(0),
|
|
@@ -2289,13 +2304,13 @@ async function fo(e, t) {
|
|
|
2289
2304
|
};
|
|
2290
2305
|
const n = Hn();
|
|
2291
2306
|
if (!n) {
|
|
2292
|
-
const a =
|
|
2307
|
+
const a = Yt();
|
|
2293
2308
|
return {
|
|
2294
|
-
indices:
|
|
2295
|
-
meta: { mode: "sync", durationMs:
|
|
2309
|
+
indices: Ti(e, t),
|
|
2310
|
+
meta: { mode: "sync", durationMs: Yt() - a }
|
|
2296
2311
|
};
|
|
2297
2312
|
}
|
|
2298
|
-
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = $n++, s =
|
|
2313
|
+
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = $n++, s = Yt();
|
|
2299
2314
|
return new Promise((a, u) => {
|
|
2300
2315
|
Vt.set(o, { kind: "index", resolve: a, reject: u, startMs: s });
|
|
2301
2316
|
const c = {
|
|
@@ -2308,14 +2323,14 @@ async function fo(e, t) {
|
|
|
2308
2323
|
n.postMessage(c, [i.buffer]);
|
|
2309
2324
|
});
|
|
2310
2325
|
}
|
|
2311
|
-
function
|
|
2326
|
+
function Li(e) {
|
|
2312
2327
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
2313
2328
|
const t = e.map(
|
|
2314
2329
|
(i) => [Number(i[0]), Number(i[1])]
|
|
2315
2330
|
), n = t[0], r = t[t.length - 1];
|
|
2316
2331
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
2317
2332
|
}
|
|
2318
|
-
function
|
|
2333
|
+
function Di(e) {
|
|
2319
2334
|
let t = 0;
|
|
2320
2335
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
2321
2336
|
const [r, i] = e[n], [o, s] = e[n + 1];
|
|
@@ -2323,12 +2338,12 @@ function Ii(e) {
|
|
|
2323
2338
|
}
|
|
2324
2339
|
return Math.abs(t * 0.5);
|
|
2325
2340
|
}
|
|
2326
|
-
function
|
|
2341
|
+
function Ni(e) {
|
|
2327
2342
|
const t = [];
|
|
2328
2343
|
for (let n = 0; n < e.length; n += 1) {
|
|
2329
2344
|
const r = e[n];
|
|
2330
2345
|
if (!r?.coordinates?.length) continue;
|
|
2331
|
-
const i =
|
|
2346
|
+
const i = Li(r.coordinates);
|
|
2332
2347
|
if (i.length < 4) continue;
|
|
2333
2348
|
let o = 1 / 0, s = 1 / 0, a = -1 / 0, u = -1 / 0;
|
|
2334
2349
|
for (const [c, h] of i)
|
|
@@ -2341,12 +2356,12 @@ function _i(e) {
|
|
|
2341
2356
|
minY: s,
|
|
2342
2357
|
maxX: a,
|
|
2343
2358
|
maxY: u,
|
|
2344
|
-
area: Math.max(1e-6,
|
|
2359
|
+
area: Math.max(1e-6, Di(i))
|
|
2345
2360
|
});
|
|
2346
2361
|
}
|
|
2347
2362
|
return t;
|
|
2348
2363
|
}
|
|
2349
|
-
function
|
|
2364
|
+
function ki(e, t, n) {
|
|
2350
2365
|
let r = !1;
|
|
2351
2366
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
2352
2367
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -2354,7 +2369,7 @@ function Fi(e, t, n) {
|
|
|
2354
2369
|
}
|
|
2355
2370
|
return r;
|
|
2356
2371
|
}
|
|
2357
|
-
function
|
|
2372
|
+
function Xi(e, t) {
|
|
2358
2373
|
if (Array.isArray(t)) {
|
|
2359
2374
|
const n = t[e];
|
|
2360
2375
|
if (typeof n == "string" && n.length > 0) return n;
|
|
@@ -2365,7 +2380,7 @@ function Ui(e, t) {
|
|
|
2365
2380
|
}
|
|
2366
2381
|
return String(e);
|
|
2367
2382
|
}
|
|
2368
|
-
function
|
|
2383
|
+
function Yi(e, t, n = {}) {
|
|
2369
2384
|
const r = Math.max(
|
|
2370
2385
|
0,
|
|
2371
2386
|
Math.min(
|
|
@@ -2377,23 +2392,23 @@ function Bi(e, t, n = {}) {
|
|
|
2377
2392
|
let i = null;
|
|
2378
2393
|
if (e?.drawIndices instanceof Uint32Array) {
|
|
2379
2394
|
const d = e.drawIndices;
|
|
2380
|
-
let
|
|
2381
|
-
for (let
|
|
2382
|
-
d[
|
|
2383
|
-
if (
|
|
2395
|
+
let p = d.length;
|
|
2396
|
+
for (let x = 0; x < d.length; x += 1)
|
|
2397
|
+
d[x] < r || (p -= 1);
|
|
2398
|
+
if (p === d.length)
|
|
2384
2399
|
i = d;
|
|
2385
|
-
else if (
|
|
2386
|
-
const
|
|
2387
|
-
let
|
|
2388
|
-
for (let
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2400
|
+
else if (p > 0) {
|
|
2401
|
+
const x = new Uint32Array(p);
|
|
2402
|
+
let S = 0;
|
|
2403
|
+
for (let P = 0; P < d.length; P += 1) {
|
|
2404
|
+
const k = d[P];
|
|
2405
|
+
k >= r || (x[S] = k, S += 1);
|
|
2391
2406
|
}
|
|
2392
|
-
i =
|
|
2407
|
+
i = x;
|
|
2393
2408
|
} else
|
|
2394
2409
|
i = new Uint32Array(0);
|
|
2395
2410
|
}
|
|
2396
|
-
const o = i ? i.length : r, s =
|
|
2411
|
+
const o = i ? i.length : r, s = Ni(t ?? []);
|
|
2397
2412
|
if (!e || o === 0 || s.length === 0)
|
|
2398
2413
|
return {
|
|
2399
2414
|
groups: [],
|
|
@@ -2404,32 +2419,32 @@ function Bi(e, t, n = {}) {
|
|
|
2404
2419
|
const a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
2405
2420
|
let c = 0;
|
|
2406
2421
|
for (let d = 0; d < o; d += 1) {
|
|
2407
|
-
const
|
|
2408
|
-
let
|
|
2409
|
-
for (const
|
|
2410
|
-
|
|
2411
|
-
if (!
|
|
2422
|
+
const p = i ? i[d] : d, x = e.positions[p * 2], S = e.positions[p * 2 + 1];
|
|
2423
|
+
let P = null;
|
|
2424
|
+
for (const R of s)
|
|
2425
|
+
x < R.minX || x > R.maxX || S < R.minY || S > R.maxY || ki(x, S, R.ring) && (!P || R.area < P.area) && (P = R);
|
|
2426
|
+
if (!P) continue;
|
|
2412
2427
|
c += 1;
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
(u.get(
|
|
2428
|
+
const k = e.paletteIndices[p] ?? 0, v = a.get(P.regionIndex) ?? /* @__PURE__ */ new Map();
|
|
2429
|
+
v.set(k, (v.get(k) ?? 0) + 1), a.set(P.regionIndex, v), u.set(
|
|
2430
|
+
P.regionIndex,
|
|
2431
|
+
(u.get(P.regionIndex) ?? 0) + 1
|
|
2417
2432
|
);
|
|
2418
2433
|
}
|
|
2419
2434
|
const h = n.includeEmptyRegions ?? !1, g = [];
|
|
2420
2435
|
for (const d of s) {
|
|
2421
|
-
const
|
|
2422
|
-
if (!h &&
|
|
2423
|
-
const
|
|
2424
|
-
termId:
|
|
2425
|
-
paletteIndex:
|
|
2426
|
-
count:
|
|
2427
|
-
})).sort((
|
|
2436
|
+
const p = u.get(d.regionIndex) ?? 0;
|
|
2437
|
+
if (!h && p <= 0) continue;
|
|
2438
|
+
const x = a.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(x.entries()).map(([P, k]) => ({
|
|
2439
|
+
termId: Xi(P, n.paletteIndexToTermId),
|
|
2440
|
+
paletteIndex: P,
|
|
2441
|
+
count: k
|
|
2442
|
+
})).sort((P, k) => k.count - P.count || P.paletteIndex - k.paletteIndex);
|
|
2428
2443
|
g.push({
|
|
2429
2444
|
regionId: d.regionId,
|
|
2430
2445
|
regionIndex: d.regionIndex,
|
|
2431
|
-
totalCount:
|
|
2432
|
-
termCounts:
|
|
2446
|
+
totalCount: p,
|
|
2447
|
+
termCounts: S
|
|
2433
2448
|
});
|
|
2434
2449
|
}
|
|
2435
2450
|
return {
|
|
@@ -2439,10 +2454,10 @@ function Bi(e, t, n = {}) {
|
|
|
2439
2454
|
unmatchedPointCount: Math.max(0, o - c)
|
|
2440
2455
|
};
|
|
2441
2456
|
}
|
|
2442
|
-
function
|
|
2457
|
+
function Ae() {
|
|
2443
2458
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2444
2459
|
}
|
|
2445
|
-
function
|
|
2460
|
+
function Wi(e, t) {
|
|
2446
2461
|
if (!t) return !1;
|
|
2447
2462
|
try {
|
|
2448
2463
|
const r = new URL(e, typeof window < "u" ? window.location.href : void 0).hostname.toLowerCase();
|
|
@@ -2451,7 +2466,7 @@ function zi(e, t) {
|
|
|
2451
2466
|
}
|
|
2452
2467
|
return !0;
|
|
2453
2468
|
}
|
|
2454
|
-
class
|
|
2469
|
+
class Vi {
|
|
2455
2470
|
constructor(t) {
|
|
2456
2471
|
b(this, "maxConcurrency");
|
|
2457
2472
|
b(this, "maxRetries");
|
|
@@ -2501,7 +2516,7 @@ class Li {
|
|
|
2501
2516
|
const o = {
|
|
2502
2517
|
tile: r,
|
|
2503
2518
|
attempt: 0,
|
|
2504
|
-
readyAt:
|
|
2519
|
+
readyAt: Ae()
|
|
2505
2520
|
};
|
|
2506
2521
|
this.queue.push(o), this.queuedByKey.set(r.key, o);
|
|
2507
2522
|
}
|
|
@@ -2557,14 +2572,14 @@ class Li {
|
|
|
2557
2572
|
if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
|
|
2558
2573
|
const t = this.queue[0]?.readyAt;
|
|
2559
2574
|
if (typeof t != "number") return;
|
|
2560
|
-
const n = Math.max(0, t -
|
|
2575
|
+
const n = Math.max(0, t - Ae());
|
|
2561
2576
|
this.timerId = window.setTimeout(() => {
|
|
2562
2577
|
this.timerId = null, this.pump();
|
|
2563
2578
|
}, n);
|
|
2564
2579
|
}
|
|
2565
2580
|
takeNextReadyQueueItem() {
|
|
2566
2581
|
if (this.queue.length === 0) return null;
|
|
2567
|
-
const t =
|
|
2582
|
+
const t = Ae(), n = this.queue[0];
|
|
2568
2583
|
return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
|
|
2569
2584
|
}
|
|
2570
2585
|
startFetch(t) {
|
|
@@ -2574,7 +2589,7 @@ class Li {
|
|
|
2574
2589
|
controller: n
|
|
2575
2590
|
};
|
|
2576
2591
|
this.inflight.set(t.tile.key, r), this.emitStateChange();
|
|
2577
|
-
const i =
|
|
2592
|
+
const i = Wi(t.tile.url, this.authToken);
|
|
2578
2593
|
fetch(t.tile.url, {
|
|
2579
2594
|
signal: n.signal,
|
|
2580
2595
|
headers: i ? { Authorization: this.authToken } : void 0
|
|
@@ -2600,7 +2615,7 @@ class Li {
|
|
|
2600
2615
|
const a = t.attempt + 1, u = this.getRetryDelay(a), c = {
|
|
2601
2616
|
tile: t.tile,
|
|
2602
2617
|
attempt: a,
|
|
2603
|
-
readyAt:
|
|
2618
|
+
readyAt: Ae() + u
|
|
2604
2619
|
}, h = this.queuedByKey.get(t.tile.key);
|
|
2605
2620
|
h ? (h.tile = c.tile, h.readyAt = Math.min(h.readyAt, c.readyAt), h.attempt = Math.max(h.attempt, c.attempt)) : (this.queue.push(c), this.queuedByKey.set(c.tile.key, c)), this.sortQueue();
|
|
2606
2621
|
return;
|
|
@@ -2624,7 +2639,7 @@ class Li {
|
|
|
2624
2639
|
this.onStateChange?.(this.getSnapshot());
|
|
2625
2640
|
}
|
|
2626
2641
|
}
|
|
2627
|
-
const
|
|
2642
|
+
const In = 0.35, We = 0.5, Oi = 256, Ve = [
|
|
2628
2643
|
{ zoom: 1, size: 2.8 },
|
|
2629
2644
|
{ zoom: 2, size: 3.4 },
|
|
2630
2645
|
{ zoom: 3, size: 4.2 },
|
|
@@ -2638,7 +2653,7 @@ const Cn = 0.35, Ye = 0.5, Ni = 256, We = [
|
|
|
2638
2653
|
{ zoom: 11, size: 22 },
|
|
2639
2654
|
{ zoom: 12, size: 28 }
|
|
2640
2655
|
];
|
|
2641
|
-
class
|
|
2656
|
+
class Gi {
|
|
2642
2657
|
constructor() {
|
|
2643
2658
|
b(this, "viewportWidth", 1);
|
|
2644
2659
|
b(this, "viewportHeight", 1);
|
|
@@ -2677,10 +2692,10 @@ class Di {
|
|
|
2677
2692
|
return [o + a * h - u * g, s + a * g + u * h];
|
|
2678
2693
|
}
|
|
2679
2694
|
worldToScreen(t, n) {
|
|
2680
|
-
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, u = n - s, c = ae(r.rotationDeg), h = Math.cos(c), g = Math.sin(c), d = a * h + u * g,
|
|
2695
|
+
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, u = n - s, c = ae(r.rotationDeg), h = Math.cos(c), g = Math.sin(c), d = a * h + u * g, p = -a * g + u * h;
|
|
2681
2696
|
return [
|
|
2682
2697
|
this.viewportWidth * 0.5 + d * i,
|
|
2683
|
-
this.viewportHeight * 0.5 +
|
|
2698
|
+
this.viewportHeight * 0.5 + p * i
|
|
2684
2699
|
];
|
|
2685
2700
|
}
|
|
2686
2701
|
getViewCorners() {
|
|
@@ -2700,7 +2715,7 @@ class Di {
|
|
|
2700
2715
|
function ae(e) {
|
|
2701
2716
|
return e * Math.PI / 180;
|
|
2702
2717
|
}
|
|
2703
|
-
function
|
|
2718
|
+
function _n() {
|
|
2704
2719
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2705
2720
|
}
|
|
2706
2721
|
function Zt(e, t, n) {
|
|
@@ -2715,16 +2730,16 @@ function ze(e, t) {
|
|
|
2715
2730
|
function Oe(e) {
|
|
2716
2731
|
return e.map((t) => ({ zoom: t.zoom, size: t.size }));
|
|
2717
2732
|
}
|
|
2718
|
-
function
|
|
2719
|
-
if (!e) return Oe(
|
|
2733
|
+
function Bn(e) {
|
|
2734
|
+
if (!e) return Oe(Ve);
|
|
2720
2735
|
const t = /* @__PURE__ */ new Map();
|
|
2721
2736
|
for (const [n, r] of Object.entries(e)) {
|
|
2722
2737
|
const i = Number(n), o = Number(r);
|
|
2723
2738
|
!Number.isFinite(i) || !Number.isFinite(o) || o <= 0 || t.set(i, o);
|
|
2724
2739
|
}
|
|
2725
|
-
return t.size === 0 ? Oe(
|
|
2740
|
+
return t.size === 0 ? Oe(Ve) : Array.from(t.entries()).sort((n, r) => n[0] - r[0]).map(([n, r]) => ({ zoom: n, size: r }));
|
|
2726
2741
|
}
|
|
2727
|
-
function
|
|
2742
|
+
function qi(e, t) {
|
|
2728
2743
|
if (e === t) return !0;
|
|
2729
2744
|
if (e.length !== t.length) return !1;
|
|
2730
2745
|
for (let n = 0; n < e.length; n += 1)
|
|
@@ -2732,25 +2747,25 @@ function ki(e, t) {
|
|
|
2732
2747
|
return !1;
|
|
2733
2748
|
return !0;
|
|
2734
2749
|
}
|
|
2735
|
-
function
|
|
2736
|
-
if (!Number.isFinite(e)) return t[0]?.size ??
|
|
2737
|
-
if (t.length === 0) return
|
|
2750
|
+
function $i(e, t) {
|
|
2751
|
+
if (!Number.isFinite(e)) return t[0]?.size ?? We;
|
|
2752
|
+
if (t.length === 0) return We;
|
|
2738
2753
|
if (t.length === 1 || e <= t[0].zoom) return t[0].size;
|
|
2739
2754
|
for (let s = 1; s < t.length; s += 1) {
|
|
2740
2755
|
const a = t[s - 1], u = t[s];
|
|
2741
2756
|
if (e > u.zoom) continue;
|
|
2742
|
-
const c = Math.max(1e-6, u.zoom - a.zoom), h =
|
|
2757
|
+
const c = Math.max(1e-6, u.zoom - a.zoom), h = it((e - a.zoom) / c, 0, 1);
|
|
2743
2758
|
return a.size + (u.size - a.size) * h;
|
|
2744
2759
|
}
|
|
2745
2760
|
const n = t[t.length - 1], r = t[t.length - 2], i = Math.max(1e-6, n.zoom - r.zoom), o = (n.size - r.size) / i;
|
|
2746
2761
|
return n.size + (e - n.zoom) * o;
|
|
2747
2762
|
}
|
|
2748
|
-
class
|
|
2763
|
+
class Hi {
|
|
2749
2764
|
constructor(t, n, r = {}) {
|
|
2750
2765
|
b(this, "canvas");
|
|
2751
2766
|
b(this, "source");
|
|
2752
2767
|
b(this, "gl");
|
|
2753
|
-
b(this, "camera", new
|
|
2768
|
+
b(this, "camera", new Gi());
|
|
2754
2769
|
b(this, "onViewStateChange");
|
|
2755
2770
|
b(this, "onStats");
|
|
2756
2771
|
b(this, "onTileError");
|
|
@@ -2783,7 +2798,7 @@ class Yi {
|
|
|
2783
2798
|
b(this, "usePointIndices", !1);
|
|
2784
2799
|
b(this, "pointBuffersDirty", !0);
|
|
2785
2800
|
b(this, "pointPaletteSize", 1);
|
|
2786
|
-
b(this, "pointSizeStops", Oe(
|
|
2801
|
+
b(this, "pointSizeStops", Oe(Ve));
|
|
2787
2802
|
b(this, "lastPointData", null);
|
|
2788
2803
|
b(this, "lastPointPalette", null);
|
|
2789
2804
|
b(this, "cache", /* @__PURE__ */ new Map());
|
|
@@ -2795,7 +2810,7 @@ class Yi {
|
|
|
2795
2810
|
b(this, "boundContextMenu");
|
|
2796
2811
|
b(this, "boundContextLost");
|
|
2797
2812
|
b(this, "boundContextRestored");
|
|
2798
|
-
this.canvas = t, this.source = n, this.onViewStateChange = r.onViewStateChange, this.onStats = r.onStats, this.onTileError = r.onTileError, this.onContextLost = r.onContextLost, this.onContextRestored = r.onContextRestored, this.authToken = r.authToken ?? "", this.maxCacheTiles = Math.max(32, Math.floor(r.maxCacheTiles ?? 320)), this.ctrlDragRotate = r.ctrlDragRotate ?? !0, this.rotationDragSensitivityDegPerPixel = typeof r.rotationDragSensitivityDegPerPixel == "number" && Number.isFinite(r.rotationDragSensitivityDegPerPixel) ? Math.max(0, r.rotationDragSensitivityDegPerPixel) :
|
|
2813
|
+
this.canvas = t, this.source = n, this.onViewStateChange = r.onViewStateChange, this.onStats = r.onStats, this.onTileError = r.onTileError, this.onContextLost = r.onContextLost, this.onContextRestored = r.onContextRestored, this.authToken = r.authToken ?? "", this.maxCacheTiles = Math.max(32, Math.floor(r.maxCacheTiles ?? 320)), this.ctrlDragRotate = r.ctrlDragRotate ?? !0, this.rotationDragSensitivityDegPerPixel = typeof r.rotationDragSensitivityDegPerPixel == "number" && Number.isFinite(r.rotationDragSensitivityDegPerPixel) ? Math.max(0, r.rotationDragSensitivityDegPerPixel) : In, this.pointSizeStops = Bn(r.pointSizeByZoom);
|
|
2799
2814
|
const i = t.getContext("webgl2", {
|
|
2800
2815
|
alpha: !1,
|
|
2801
2816
|
antialias: !1,
|
|
@@ -2805,7 +2820,7 @@ class Yi {
|
|
|
2805
2820
|
});
|
|
2806
2821
|
if (!i)
|
|
2807
2822
|
throw new Error("WebGL2 not supported");
|
|
2808
|
-
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new
|
|
2823
|
+
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new Vi({
|
|
2809
2824
|
authToken: this.authToken,
|
|
2810
2825
|
maxConcurrency: r.tileScheduler?.maxConcurrency ?? 12,
|
|
2811
2826
|
maxRetries: r.tileScheduler?.maxRetries ?? 2,
|
|
@@ -2822,7 +2837,7 @@ class Yi {
|
|
|
2822
2837
|
}
|
|
2823
2838
|
setViewState(t) {
|
|
2824
2839
|
const n = { ...t };
|
|
2825
|
-
typeof n.zoom == "number" && (n.zoom =
|
|
2840
|
+
typeof n.zoom == "number" && (n.zoom = it(n.zoom, this.minZoom, this.maxZoom)), this.camera.setViewState(n), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2826
2841
|
}
|
|
2827
2842
|
getViewState() {
|
|
2828
2843
|
return this.camera.getViewState();
|
|
@@ -2900,8 +2915,8 @@ class Yi {
|
|
|
2900
2915
|
this.interactionLocked !== n && (this.interactionLocked = n, n && this.cancelDrag());
|
|
2901
2916
|
}
|
|
2902
2917
|
setPointSizeByZoom(t) {
|
|
2903
|
-
const n =
|
|
2904
|
-
|
|
2918
|
+
const n = Bn(t);
|
|
2919
|
+
qi(this.pointSizeStops, n) || (this.pointSizeStops = n, this.requestRender());
|
|
2905
2920
|
}
|
|
2906
2921
|
cancelDrag() {
|
|
2907
2922
|
if (this.pointerId !== null && this.canvas.hasPointerCapture(this.pointerId))
|
|
@@ -2933,38 +2948,38 @@ class Yi {
|
|
|
2933
2948
|
Math.abs(t.rotationDeg) < 1e-6 || (this.camera.setViewState({ rotationDeg: 0 }), this.clampViewState(), this.emitViewState(), this.requestRender());
|
|
2934
2949
|
}
|
|
2935
2950
|
getPointSizeByZoom() {
|
|
2936
|
-
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r =
|
|
2937
|
-
return
|
|
2951
|
+
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r = $i(n, this.pointSizeStops);
|
|
2952
|
+
return it(r, We, Oi);
|
|
2938
2953
|
}
|
|
2939
2954
|
fitToImage() {
|
|
2940
2955
|
const t = this.canvas.getBoundingClientRect(), n = Math.max(1, t.width || 1), r = Math.max(1, t.height || 1), i = Math.min(n / this.source.width, r / this.source.height), o = Number.isFinite(i) && i > 0 ? i : 1;
|
|
2941
2956
|
this.fitZoom = o, this.minZoom = Math.max(this.fitZoom * 0.5, 1e-6), this.maxZoom = Math.max(1, this.fitZoom * 8), this.minZoom > this.maxZoom && (this.minZoom = this.maxZoom);
|
|
2942
2957
|
const s = n / o, a = r / o;
|
|
2943
2958
|
this.camera.setViewState({
|
|
2944
|
-
zoom:
|
|
2959
|
+
zoom: it(o, this.minZoom, this.maxZoom),
|
|
2945
2960
|
offsetX: (this.source.width - s) * 0.5,
|
|
2946
2961
|
offsetY: (this.source.height - a) * 0.5,
|
|
2947
2962
|
rotationDeg: 0
|
|
2948
2963
|
}), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2949
2964
|
}
|
|
2950
2965
|
zoomBy(t, n, r) {
|
|
2951
|
-
const i = this.camera.getViewState(), o =
|
|
2966
|
+
const i = this.camera.getViewState(), o = it(i.zoom * t, this.minZoom, this.maxZoom);
|
|
2952
2967
|
if (o === i.zoom) return;
|
|
2953
2968
|
const [s, a] = this.camera.screenToWorld(n, r);
|
|
2954
2969
|
this.camera.setViewState({ zoom: o });
|
|
2955
|
-
const u = this.camera.getViewport(), c = n - u.width * 0.5, h = r - u.height * 0.5, g = ae(this.camera.getViewState().rotationDeg), d = Math.cos(g),
|
|
2956
|
-
this.camera.setCenter(s -
|
|
2970
|
+
const u = this.camera.getViewport(), c = n - u.width * 0.5, h = r - u.height * 0.5, g = ae(this.camera.getViewState().rotationDeg), d = Math.cos(g), p = Math.sin(g), x = c / o * d - h / o * p, S = c / o * p + h / o * d;
|
|
2971
|
+
this.camera.setCenter(s - x, a - S), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2957
2972
|
}
|
|
2958
2973
|
clampViewState() {
|
|
2959
|
-
const t = this.getViewBounds(), n = Math.max(1e-6, t[2] - t[0]), r = Math.max(1e-6, t[3] - t[1]), i = n * 0.2, o = r * 0.2, [s, a] = this.camera.getCenter(), u = n * 0.5, c = r * 0.5, h = u - i, g = this.source.width - u + i, d = c - o,
|
|
2960
|
-
this.camera.setCenter(
|
|
2974
|
+
const t = this.getViewBounds(), n = Math.max(1e-6, t[2] - t[0]), r = Math.max(1e-6, t[3] - t[1]), i = n * 0.2, o = r * 0.2, [s, a] = this.camera.getCenter(), u = n * 0.5, c = r * 0.5, h = u - i, g = this.source.width - u + i, d = c - o, p = this.source.height - c + o, x = h <= g ? it(s, h, g) : this.source.width * 0.5, S = d <= p ? it(a, d, p) : this.source.height * 0.5;
|
|
2975
|
+
this.camera.setCenter(x, S);
|
|
2961
2976
|
}
|
|
2962
2977
|
emitViewState() {
|
|
2963
2978
|
this.onViewStateChange?.(this.camera.getViewState());
|
|
2964
2979
|
}
|
|
2965
2980
|
selectTier() {
|
|
2966
2981
|
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t);
|
|
2967
|
-
return
|
|
2982
|
+
return it(Math.floor(n), 0, this.source.maxTierZoom);
|
|
2968
2983
|
}
|
|
2969
2984
|
getViewBounds() {
|
|
2970
2985
|
const t = this.camera.getViewCorners();
|
|
@@ -2979,40 +2994,40 @@ class Yi {
|
|
|
2979
2994
|
getVisibleTiles() {
|
|
2980
2995
|
const t = this.selectTier();
|
|
2981
2996
|
this.currentTier = t;
|
|
2982
|
-
const n = this.getViewBounds(), r = Math.pow(2, this.source.maxTierZoom - t), i = Math.ceil(this.source.width / r), o = Math.ceil(this.source.height / r), s = Math.max(1, Math.ceil(i / this.source.tileSize)), a = Math.max(1, Math.ceil(o / this.source.tileSize)), u = n[0], c = n[1], h = n[2], g = n[3], d =
|
|
2997
|
+
const n = this.getViewBounds(), r = Math.pow(2, this.source.maxTierZoom - t), i = Math.ceil(this.source.width / r), o = Math.ceil(this.source.height / r), s = Math.max(1, Math.ceil(i / this.source.tileSize)), a = Math.max(1, Math.ceil(o / this.source.tileSize)), u = n[0], c = n[1], h = n[2], g = n[3], d = it(
|
|
2983
2998
|
Math.floor(u / r / this.source.tileSize),
|
|
2984
2999
|
0,
|
|
2985
3000
|
s - 1
|
|
2986
|
-
),
|
|
3001
|
+
), p = it(
|
|
2987
3002
|
Math.floor((h - 1) / r / this.source.tileSize),
|
|
2988
3003
|
0,
|
|
2989
3004
|
s - 1
|
|
2990
|
-
),
|
|
3005
|
+
), x = it(
|
|
2991
3006
|
Math.floor(c / r / this.source.tileSize),
|
|
2992
3007
|
0,
|
|
2993
3008
|
a - 1
|
|
2994
|
-
),
|
|
3009
|
+
), S = it(
|
|
2995
3010
|
Math.floor((g - 1) / r / this.source.tileSize),
|
|
2996
3011
|
0,
|
|
2997
3012
|
a - 1
|
|
2998
3013
|
);
|
|
2999
|
-
if (d >
|
|
3014
|
+
if (d > p || x > S)
|
|
3000
3015
|
return [];
|
|
3001
|
-
const
|
|
3002
|
-
for (let
|
|
3003
|
-
for (let
|
|
3004
|
-
const
|
|
3005
|
-
|
|
3006
|
-
key: `${t}/${
|
|
3016
|
+
const P = (u + h) * 0.5 / r / this.source.tileSize, k = (c + g) * 0.5 / r / this.source.tileSize, v = [];
|
|
3017
|
+
for (let R = x; R <= S; R += 1)
|
|
3018
|
+
for (let D = d; D <= p; D += 1) {
|
|
3019
|
+
const J = D * this.source.tileSize * r, ft = R * this.source.tileSize * r, at = Math.min((D + 1) * this.source.tileSize, i) * r, $ = Math.min((R + 1) * this.source.tileSize, o) * r, ht = D - P, vt = R - k;
|
|
3020
|
+
v.push({
|
|
3021
|
+
key: `${t}/${D}/${R}`,
|
|
3007
3022
|
tier: t,
|
|
3008
|
-
x:
|
|
3009
|
-
y:
|
|
3010
|
-
bounds: [
|
|
3011
|
-
distance2:
|
|
3012
|
-
url: Wn(this.source, t,
|
|
3023
|
+
x: D,
|
|
3024
|
+
y: R,
|
|
3025
|
+
bounds: [J, ft, at, $],
|
|
3026
|
+
distance2: ht * ht + vt * vt,
|
|
3027
|
+
url: Wn(this.source, t, D, R)
|
|
3013
3028
|
});
|
|
3014
3029
|
}
|
|
3015
|
-
return
|
|
3030
|
+
return v.sort((R, D) => R.distance2 - D.distance2), v;
|
|
3016
3031
|
}
|
|
3017
3032
|
trimCache() {
|
|
3018
3033
|
if (this.cache.size <= this.maxCacheTiles) return;
|
|
@@ -3026,7 +3041,7 @@ class Yi {
|
|
|
3026
3041
|
}
|
|
3027
3042
|
render() {
|
|
3028
3043
|
if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
|
|
3029
|
-
const t =
|
|
3044
|
+
const t = _n();
|
|
3030
3045
|
this.frameSerial += 1;
|
|
3031
3046
|
const n = this.gl, r = this.tileProgram, i = this.pointProgram;
|
|
3032
3047
|
n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
|
|
@@ -3035,7 +3050,7 @@ class Yi {
|
|
|
3035
3050
|
const u = [];
|
|
3036
3051
|
for (const [, d] of this.cache)
|
|
3037
3052
|
a.has(d.key) || this.intersectsBounds(d.bounds, s) && u.push(d);
|
|
3038
|
-
u.sort((d,
|
|
3053
|
+
u.sort((d, p) => d.tier - p.tier);
|
|
3039
3054
|
for (const d of u)
|
|
3040
3055
|
d.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, d.texture), n.uniform4f(
|
|
3041
3056
|
r.uBounds,
|
|
@@ -3047,23 +3062,23 @@ class Yi {
|
|
|
3047
3062
|
let c = 0;
|
|
3048
3063
|
const h = [];
|
|
3049
3064
|
for (const d of o) {
|
|
3050
|
-
const
|
|
3051
|
-
if (!
|
|
3065
|
+
const p = this.cache.get(d.key);
|
|
3066
|
+
if (!p) {
|
|
3052
3067
|
h.push(d);
|
|
3053
3068
|
continue;
|
|
3054
3069
|
}
|
|
3055
|
-
|
|
3070
|
+
p.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, p.texture), n.uniform4f(
|
|
3056
3071
|
r.uBounds,
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3072
|
+
p.bounds[0],
|
|
3073
|
+
p.bounds[1],
|
|
3074
|
+
p.bounds[2],
|
|
3075
|
+
p.bounds[3]
|
|
3061
3076
|
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4), c += 1;
|
|
3062
3077
|
}
|
|
3063
3078
|
this.tileScheduler.schedule(h), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
|
|
3064
3079
|
let g = 0;
|
|
3065
3080
|
if (this.pointCount > 0 && (n.enable(n.BLEND), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), n.useProgram(i.program), n.bindVertexArray(i.vao), n.uniformMatrix3fv(i.uCamera, !1, this.camera.getMatrix()), n.uniform1f(i.uPointSize, this.getPointSizeByZoom()), n.uniform1f(i.uPaletteSize, this.pointPaletteSize), n.uniform1i(i.uPalette, 1), n.activeTexture(n.TEXTURE1), n.bindTexture(n.TEXTURE_2D, i.paletteTexture), this.usePointIndices ? n.drawElements(n.POINTS, this.pointCount, n.UNSIGNED_INT, 0) : n.drawArrays(n.POINTS, 0, this.pointCount), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null), g = this.pointCount), this.onStats) {
|
|
3066
|
-
const d = this.tileScheduler.getSnapshot(),
|
|
3081
|
+
const d = this.tileScheduler.getSnapshot(), p = c, x = h.length, S = u.length + c + (g > 0 ? 1 : 0);
|
|
3067
3082
|
this.onStats({
|
|
3068
3083
|
tier: this.currentTier,
|
|
3069
3084
|
visible: o.length,
|
|
@@ -3076,10 +3091,10 @@ class Yi {
|
|
|
3076
3091
|
retries: d.retries,
|
|
3077
3092
|
failed: d.failed,
|
|
3078
3093
|
aborted: d.aborted,
|
|
3079
|
-
cacheHits:
|
|
3080
|
-
cacheMisses:
|
|
3081
|
-
drawCalls:
|
|
3082
|
-
frameMs:
|
|
3094
|
+
cacheHits: p,
|
|
3095
|
+
cacheMisses: x,
|
|
3096
|
+
drawCalls: S,
|
|
3097
|
+
frameMs: _n() - t
|
|
3083
3098
|
});
|
|
3084
3099
|
}
|
|
3085
3100
|
}
|
|
@@ -3103,7 +3118,7 @@ class Yi {
|
|
|
3103
3118
|
if (this.lastPointerX = t.clientX, this.lastPointerY = t.clientY, this.interactionMode === "rotate") {
|
|
3104
3119
|
const i = this.getPointerAngleRad(t.clientX, t.clientY), o = this.rotateLastAngleRad;
|
|
3105
3120
|
if (this.rotateLastAngleRad = i, o !== null) {
|
|
3106
|
-
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), u = this.rotationDragSensitivityDegPerPixel /
|
|
3121
|
+
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), u = this.rotationDragSensitivityDegPerPixel / In, c = this.camera.getViewState();
|
|
3107
3122
|
this.camera.setViewState({
|
|
3108
3123
|
rotationDeg: c.rotationDeg - a * 180 / Math.PI * u
|
|
3109
3124
|
});
|
|
@@ -3157,7 +3172,7 @@ class Yi {
|
|
|
3157
3172
|
}
|
|
3158
3173
|
}
|
|
3159
3174
|
initTileProgram() {
|
|
3160
|
-
const t = this.gl, i =
|
|
3175
|
+
const t = this.gl, i = pn(t, `#version 300 es
|
|
3161
3176
|
precision highp float;
|
|
3162
3177
|
in vec2 aUnit;
|
|
3163
3178
|
in vec2 aUv;
|
|
@@ -3193,7 +3208,7 @@ class Yi {
|
|
|
3193
3208
|
return t.enableVertexAttribArray(h), t.enableVertexAttribArray(g), t.vertexAttribPointer(h, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(g, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), { program: i, vao: u, vbo: c, uCamera: o, uBounds: s, uTexture: a };
|
|
3194
3209
|
}
|
|
3195
3210
|
initPointProgram() {
|
|
3196
|
-
const t = this.gl, i =
|
|
3211
|
+
const t = this.gl, i = pn(t, `#version 300 es
|
|
3197
3212
|
precision highp float;
|
|
3198
3213
|
in vec2 aPosition;
|
|
3199
3214
|
in uint aTerm;
|
|
@@ -3232,18 +3247,18 @@ class Yi {
|
|
|
3232
3247
|
if (alpha <= 0.001) discard;
|
|
3233
3248
|
|
|
3234
3249
|
outColor = vec4(color.rgb * alpha, alpha);
|
|
3235
|
-
}`), o = Zt(t, i, "uCamera"), s = Zt(t, i, "uPointSize"), a = Zt(t, i, "uPalette"), u = Zt(t, i, "uPaletteSize"), c = t.createVertexArray(), h = t.createBuffer(), g = t.createBuffer(), d = t.createBuffer(),
|
|
3236
|
-
if (!c || !h || !g || !d || !
|
|
3250
|
+
}`), o = Zt(t, i, "uCamera"), s = Zt(t, i, "uPointSize"), a = Zt(t, i, "uPalette"), u = Zt(t, i, "uPaletteSize"), c = t.createVertexArray(), h = t.createBuffer(), g = t.createBuffer(), d = t.createBuffer(), p = t.createTexture();
|
|
3251
|
+
if (!c || !h || !g || !d || !p)
|
|
3237
3252
|
throw new Error("point buffer allocation failed");
|
|
3238
3253
|
t.bindVertexArray(c), t.bindBuffer(t.ARRAY_BUFFER, h), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3239
|
-
const
|
|
3240
|
-
if (y < 0)
|
|
3241
|
-
throw new Error("point position attribute not found");
|
|
3242
|
-
t.enableVertexAttribArray(y), t.vertexAttribPointer(y, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, g), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3243
|
-
const x = t.getAttribLocation(i, "aTerm");
|
|
3254
|
+
const x = t.getAttribLocation(i, "aPosition");
|
|
3244
3255
|
if (x < 0)
|
|
3256
|
+
throw new Error("point position attribute not found");
|
|
3257
|
+
t.enableVertexAttribArray(x), t.vertexAttribPointer(x, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, g), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3258
|
+
const S = t.getAttribLocation(i, "aTerm");
|
|
3259
|
+
if (S < 0)
|
|
3245
3260
|
throw new Error("point term attribute not found");
|
|
3246
|
-
return t.enableVertexAttribArray(
|
|
3261
|
+
return t.enableVertexAttribArray(S), t.vertexAttribIPointer(S, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, d), t.bufferData(t.ELEMENT_ARRAY_BUFFER, 0, t.DYNAMIC_DRAW), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, null), t.bindTexture(t.TEXTURE_2D, p), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
|
|
3247
3262
|
t.TEXTURE_2D,
|
|
3248
3263
|
0,
|
|
3249
3264
|
t.RGBA,
|
|
@@ -3259,7 +3274,7 @@ class Yi {
|
|
|
3259
3274
|
posBuffer: h,
|
|
3260
3275
|
termBuffer: g,
|
|
3261
3276
|
indexBuffer: d,
|
|
3262
|
-
paletteTexture:
|
|
3277
|
+
paletteTexture: p,
|
|
3263
3278
|
uCamera: o,
|
|
3264
3279
|
uPointSize: s,
|
|
3265
3280
|
uPalette: a,
|
|
@@ -3290,15 +3305,15 @@ class Yi {
|
|
|
3290
3305
|
return r ? (n.bindTexture(n.TEXTURE_2D, r), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 1), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.texImage2D(n.TEXTURE_2D, 0, n.RGBA, n.RGBA, n.UNSIGNED_BYTE, t), n.bindTexture(n.TEXTURE_2D, null), r) : null;
|
|
3291
3306
|
}
|
|
3292
3307
|
}
|
|
3293
|
-
const Le = [],
|
|
3308
|
+
const Le = [], Zi = [], Ki = {
|
|
3294
3309
|
count: 0,
|
|
3295
3310
|
positions: new Float32Array(0),
|
|
3296
3311
|
paletteIndices: new Uint16Array(0)
|
|
3297
|
-
},
|
|
3298
|
-
function
|
|
3312
|
+
}, ji = 0.65, Ji = 4, Qi = 24, to = 1024, eo = 4;
|
|
3313
|
+
function no(e) {
|
|
3299
3314
|
return Math.max(0, Math.min(Math.floor(e.count ?? 0), Math.floor((e.positions?.length ?? 0) / 2), e.paletteIndices?.length ?? 0));
|
|
3300
3315
|
}
|
|
3301
|
-
function
|
|
3316
|
+
function ro(e, t) {
|
|
3302
3317
|
if (!(e instanceof Uint32Array) || t <= 0 || e.length === 0)
|
|
3303
3318
|
return null;
|
|
3304
3319
|
let n = !1;
|
|
@@ -3317,28 +3332,28 @@ function Ki(e, t) {
|
|
|
3317
3332
|
}
|
|
3318
3333
|
return r.subarray(0, i);
|
|
3319
3334
|
}
|
|
3320
|
-
function
|
|
3335
|
+
function io(e, t) {
|
|
3321
3336
|
if (!e || t <= 0) return 256;
|
|
3322
|
-
const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) *
|
|
3323
|
-
return Math.max(
|
|
3337
|
+
const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) * eo;
|
|
3338
|
+
return Math.max(Qi, Math.min(to, i));
|
|
3324
3339
|
}
|
|
3325
|
-
function
|
|
3340
|
+
function oo(e, t) {
|
|
3326
3341
|
if (!e || !e.positions || !e.paletteIndices)
|
|
3327
3342
|
return null;
|
|
3328
|
-
const n =
|
|
3343
|
+
const n = no(e);
|
|
3329
3344
|
if (n <= 0)
|
|
3330
3345
|
return null;
|
|
3331
|
-
const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o =
|
|
3346
|
+
const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o = ro(e.drawIndices, n), s = o ? o.length : n;
|
|
3332
3347
|
if (s === 0)
|
|
3333
3348
|
return null;
|
|
3334
|
-
const a =
|
|
3349
|
+
const a = io(t, s), u = /* @__PURE__ */ new Map(), c = (h) => {
|
|
3335
3350
|
const g = r[h * 2], d = r[h * 2 + 1];
|
|
3336
3351
|
if (!Number.isFinite(g) || !Number.isFinite(d)) return;
|
|
3337
|
-
const
|
|
3338
|
-
let
|
|
3339
|
-
|
|
3340
|
-
const
|
|
3341
|
-
|
|
3352
|
+
const p = Math.floor(g / a), x = Math.floor(d / a);
|
|
3353
|
+
let S = u.get(p);
|
|
3354
|
+
S || (S = /* @__PURE__ */ new Map(), u.set(p, S));
|
|
3355
|
+
const P = S.get(x);
|
|
3356
|
+
P ? P.push(h) : S.set(x, [h]);
|
|
3342
3357
|
};
|
|
3343
3358
|
if (o)
|
|
3344
3359
|
for (let h = 0; h < o.length; h += 1)
|
|
@@ -3354,10 +3369,10 @@ function Ji(e, t) {
|
|
|
3354
3369
|
buckets: u
|
|
3355
3370
|
};
|
|
3356
3371
|
}
|
|
3357
|
-
function
|
|
3372
|
+
function Ge(e, t) {
|
|
3358
3373
|
return e.id ?? t;
|
|
3359
3374
|
}
|
|
3360
|
-
function
|
|
3375
|
+
function so(e, t) {
|
|
3361
3376
|
if (!Array.isArray(t) || t.length < 3) return !1;
|
|
3362
3377
|
const [n, r] = e;
|
|
3363
3378
|
let i = !1;
|
|
@@ -3367,19 +3382,19 @@ function Qi(e, t) {
|
|
|
3367
3382
|
}
|
|
3368
3383
|
return i;
|
|
3369
3384
|
}
|
|
3370
|
-
function
|
|
3385
|
+
function De(e, t) {
|
|
3371
3386
|
for (let n = t.length - 1; n >= 0; n -= 1) {
|
|
3372
3387
|
const r = t[n];
|
|
3373
|
-
if (r?.coordinates?.length &&
|
|
3388
|
+
if (r?.coordinates?.length && so(e, r.coordinates))
|
|
3374
3389
|
return {
|
|
3375
3390
|
region: r,
|
|
3376
3391
|
regionIndex: n,
|
|
3377
|
-
regionId:
|
|
3392
|
+
regionId: Ge(r, n)
|
|
3378
3393
|
};
|
|
3379
3394
|
}
|
|
3380
3395
|
return null;
|
|
3381
3396
|
}
|
|
3382
|
-
function
|
|
3397
|
+
function So({
|
|
3383
3398
|
source: e,
|
|
3384
3399
|
viewState: t,
|
|
3385
3400
|
onViewStateChange: n,
|
|
@@ -3393,44 +3408,44 @@ function mo({
|
|
|
3393
3408
|
rotationResetNonce: h = 0,
|
|
3394
3409
|
authToken: g = "",
|
|
3395
3410
|
ctrlDragRotate: d = !0,
|
|
3396
|
-
pointData:
|
|
3397
|
-
pointPalette:
|
|
3398
|
-
pointSizeByZoom:
|
|
3399
|
-
roiRegions:
|
|
3400
|
-
roiPolygons:
|
|
3401
|
-
clipPointsToRois:
|
|
3402
|
-
clipMode:
|
|
3403
|
-
onClipStats:
|
|
3404
|
-
onRoiPointGroups:
|
|
3411
|
+
pointData: p = null,
|
|
3412
|
+
pointPalette: x = null,
|
|
3413
|
+
pointSizeByZoom: S,
|
|
3414
|
+
roiRegions: P,
|
|
3415
|
+
roiPolygons: k,
|
|
3416
|
+
clipPointsToRois: v = !1,
|
|
3417
|
+
clipMode: R = "worker",
|
|
3418
|
+
onClipStats: D,
|
|
3419
|
+
onRoiPointGroups: J,
|
|
3405
3420
|
roiPaletteIndexToTermId: ft,
|
|
3406
|
-
interactionLock:
|
|
3407
|
-
drawTool:
|
|
3408
|
-
stampOptions:
|
|
3409
|
-
brushOptions:
|
|
3410
|
-
regionStrokeStyle:
|
|
3411
|
-
regionStrokeHoverStyle:
|
|
3412
|
-
regionStrokeActiveStyle:
|
|
3413
|
-
patchStrokeStyle:
|
|
3414
|
-
resolveRegionStrokeStyle:
|
|
3415
|
-
overlayShapes:
|
|
3416
|
-
customLayers:
|
|
3417
|
-
patchRegions:
|
|
3418
|
-
regionLabelStyle:
|
|
3419
|
-
onPointerWorldMove:
|
|
3421
|
+
interactionLock: at = !1,
|
|
3422
|
+
drawTool: $ = "cursor",
|
|
3423
|
+
stampOptions: ht,
|
|
3424
|
+
brushOptions: vt,
|
|
3425
|
+
regionStrokeStyle: Ot,
|
|
3426
|
+
regionStrokeHoverStyle: K,
|
|
3427
|
+
regionStrokeActiveStyle: Ct,
|
|
3428
|
+
patchStrokeStyle: zt,
|
|
3429
|
+
resolveRegionStrokeStyle: Kt,
|
|
3430
|
+
overlayShapes: dt,
|
|
3431
|
+
customLayers: Q,
|
|
3432
|
+
patchRegions: M,
|
|
3433
|
+
regionLabelStyle: C,
|
|
3434
|
+
onPointerWorldMove: A,
|
|
3420
3435
|
onPointHover: L,
|
|
3421
|
-
onPointClick:
|
|
3422
|
-
onRegionHover:
|
|
3423
|
-
onRegionClick:
|
|
3424
|
-
onActiveRegionChange:
|
|
3425
|
-
getCellByCoordinatesRef:
|
|
3426
|
-
onDrawComplete:
|
|
3427
|
-
onPatchComplete:
|
|
3428
|
-
showOverviewMap:
|
|
3429
|
-
overviewMapOptions:
|
|
3430
|
-
className:
|
|
3431
|
-
style:
|
|
3436
|
+
onPointClick: Z,
|
|
3437
|
+
onRegionHover: et,
|
|
3438
|
+
onRegionClick: mt,
|
|
3439
|
+
onActiveRegionChange: yt,
|
|
3440
|
+
getCellByCoordinatesRef: U,
|
|
3441
|
+
onDrawComplete: At,
|
|
3442
|
+
onPatchComplete: gt,
|
|
3443
|
+
showOverviewMap: N = !1,
|
|
3444
|
+
overviewMapOptions: G,
|
|
3445
|
+
className: ut,
|
|
3446
|
+
style: nt
|
|
3432
3447
|
}) {
|
|
3433
|
-
const
|
|
3448
|
+
const rt = j(null), q = j(null), It = j(null), _t = j(null), F = j(n), ct = j(r), ot = j(a), [Gt, Bt] = Jt(!0), [Ut, qt] = Jt(null), [pt, ue] = Jt(null), [ce, l] = Jt(null), [f, w] = Jt(null), y = j(null), E = j(null), I = j(null), Y = j(0), V = P ?? Le, W = M ?? Le, lt = k ?? Zi, Pt = (Q?.length ?? 0) > 0, $t = tt(() => ({ position: "relative", width: "100%", height: "100%", ...nt }), [nt]), xt = tt(
|
|
3434
3449
|
() => ({
|
|
3435
3450
|
position: "absolute",
|
|
3436
3451
|
top: 8,
|
|
@@ -3452,56 +3467,56 @@ function mo({
|
|
|
3452
3467
|
...u
|
|
3453
3468
|
}),
|
|
3454
3469
|
[u]
|
|
3455
|
-
),
|
|
3456
|
-
id:
|
|
3457
|
-
coordinates:
|
|
3458
|
-
})), [
|
|
3470
|
+
), H = tt(() => V.length > 0 ? V : lt.length === 0 ? Le : lt.map((m, T) => ({
|
|
3471
|
+
id: T,
|
|
3472
|
+
coordinates: m
|
|
3473
|
+
})), [V, lt]), St = tt(() => H.map((m) => m.coordinates), [H]), [Tt, le] = Jt(p);
|
|
3459
3474
|
X(() => {
|
|
3460
|
-
const
|
|
3461
|
-
let
|
|
3462
|
-
if (!
|
|
3463
|
-
return
|
|
3464
|
-
|
|
3475
|
+
const m = ++Y.current;
|
|
3476
|
+
let T = !1;
|
|
3477
|
+
if (!v)
|
|
3478
|
+
return le(p), () => {
|
|
3479
|
+
T = !0;
|
|
3465
3480
|
};
|
|
3466
|
-
if (!
|
|
3467
|
-
return
|
|
3468
|
-
|
|
3481
|
+
if (!p || !p.count || !p.positions || !p.paletteIndices)
|
|
3482
|
+
return le(null), () => {
|
|
3483
|
+
T = !0;
|
|
3469
3484
|
};
|
|
3470
|
-
if (
|
|
3471
|
-
return
|
|
3472
|
-
mode:
|
|
3485
|
+
if (St.length === 0)
|
|
3486
|
+
return le(Ki), D?.({
|
|
3487
|
+
mode: R,
|
|
3473
3488
|
durationMs: 0,
|
|
3474
|
-
inputCount:
|
|
3489
|
+
inputCount: p.count,
|
|
3475
3490
|
outputCount: 0,
|
|
3476
3491
|
polygonCount: 0
|
|
3477
3492
|
}), () => {
|
|
3478
|
-
|
|
3493
|
+
T = !0;
|
|
3479
3494
|
};
|
|
3480
|
-
const _ = (z,
|
|
3481
|
-
if (
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3484
|
-
mode:
|
|
3485
|
-
durationMs:
|
|
3486
|
-
inputCount:
|
|
3487
|
-
outputCount:
|
|
3488
|
-
polygonCount:
|
|
3489
|
-
usedWebGpu:
|
|
3490
|
-
candidateCount:
|
|
3491
|
-
bridgedToDraw:
|
|
3495
|
+
const _ = (z, st) => {
|
|
3496
|
+
if (T || m !== Y.current) return;
|
|
3497
|
+
const de = z?.drawIndices ? z.drawIndices.length : z?.count ?? 0;
|
|
3498
|
+
le(z), D?.({
|
|
3499
|
+
mode: st.mode,
|
|
3500
|
+
durationMs: st.durationMs,
|
|
3501
|
+
inputCount: p.count,
|
|
3502
|
+
outputCount: de,
|
|
3503
|
+
polygonCount: St.length,
|
|
3504
|
+
usedWebGpu: st.usedWebGpu,
|
|
3505
|
+
candidateCount: st.candidateCount,
|
|
3506
|
+
bridgedToDraw: st.bridgedToDraw
|
|
3492
3507
|
});
|
|
3493
3508
|
};
|
|
3494
3509
|
return (async () => {
|
|
3495
|
-
if (
|
|
3496
|
-
const z = performance.now(),
|
|
3497
|
-
_(
|
|
3510
|
+
if (R === "sync") {
|
|
3511
|
+
const z = performance.now(), st = Re(p, St);
|
|
3512
|
+
_(st, {
|
|
3498
3513
|
mode: "sync",
|
|
3499
3514
|
durationMs: performance.now() - z
|
|
3500
3515
|
});
|
|
3501
3516
|
return;
|
|
3502
3517
|
}
|
|
3503
|
-
if (
|
|
3504
|
-
const z = await
|
|
3518
|
+
if (R === "hybrid-webgpu") {
|
|
3519
|
+
const z = await Fi(p, St, { bridgeToDraw: !0 });
|
|
3505
3520
|
_(z.data, {
|
|
3506
3521
|
mode: z.meta.mode,
|
|
3507
3522
|
durationMs: z.meta.durationMs,
|
|
@@ -3512,209 +3527,209 @@ function mo({
|
|
|
3512
3527
|
return;
|
|
3513
3528
|
}
|
|
3514
3529
|
try {
|
|
3515
|
-
const z = await
|
|
3530
|
+
const z = await zi(p, St);
|
|
3516
3531
|
_(z.data, {
|
|
3517
3532
|
mode: z.meta.mode,
|
|
3518
3533
|
durationMs: z.meta.durationMs
|
|
3519
3534
|
});
|
|
3520
3535
|
} catch {
|
|
3521
|
-
const z = performance.now(),
|
|
3522
|
-
_(
|
|
3536
|
+
const z = performance.now(), st = Re(p, St);
|
|
3537
|
+
_(st, {
|
|
3523
3538
|
mode: "sync",
|
|
3524
3539
|
durationMs: performance.now() - z
|
|
3525
3540
|
});
|
|
3526
3541
|
}
|
|
3527
3542
|
})(), () => {
|
|
3528
|
-
|
|
3543
|
+
T = !0;
|
|
3529
3544
|
};
|
|
3530
|
-
}, [
|
|
3531
|
-
const
|
|
3532
|
-
(
|
|
3533
|
-
const
|
|
3534
|
-
if (!
|
|
3535
|
-
const _ = Number(
|
|
3536
|
-
if (!Number.isFinite(_) || !Number.isFinite(
|
|
3537
|
-
const z = Math.max(1e-6,
|
|
3545
|
+
}, [v, R, p, St, D]);
|
|
3546
|
+
const He = !!(L || Z || U), Mt = tt(() => He ? oo(Tt, e) : null, [He, Tt, e]), Ht = B(
|
|
3547
|
+
(m) => {
|
|
3548
|
+
const T = q.current;
|
|
3549
|
+
if (!T || !Mt) return null;
|
|
3550
|
+
const _ = Number(m[0]), O = Number(m[1]);
|
|
3551
|
+
if (!Number.isFinite(_) || !Number.isFinite(O)) return null;
|
|
3552
|
+
const z = Math.max(1e-6, T.getViewState().zoom), st = T.getPointSizeByZoom(), re = Math.max(Ji, st * ji) / z;
|
|
3538
3553
|
if (!Number.isFinite(re) || re <= 0) return null;
|
|
3539
|
-
const
|
|
3540
|
-
let
|
|
3541
|
-
for (let
|
|
3542
|
-
const
|
|
3543
|
-
if (
|
|
3544
|
-
for (let Ce =
|
|
3545
|
-
const
|
|
3546
|
-
if (!(!
|
|
3547
|
-
for (let Ie = 0; Ie <
|
|
3548
|
-
const
|
|
3549
|
-
if (
|
|
3550
|
-
const
|
|
3551
|
-
|
|
3554
|
+
const Ee = Mt.cellSize, nn = Math.floor(_ / Ee), rn = Math.floor(O / Ee), me = Math.max(1, Math.ceil(re / Ee)), er = re * re;
|
|
3555
|
+
let ge = -1, on = er, sn = 0, an = 0;
|
|
3556
|
+
for (let ve = nn - me; ve <= nn + me; ve += 1) {
|
|
3557
|
+
const un = Mt.buckets.get(ve);
|
|
3558
|
+
if (un)
|
|
3559
|
+
for (let Ce = rn - me; Ce <= rn + me; Ce += 1) {
|
|
3560
|
+
const pe = un.get(Ce);
|
|
3561
|
+
if (!(!pe || pe.length === 0))
|
|
3562
|
+
for (let Ie = 0; Ie < pe.length; Ie += 1) {
|
|
3563
|
+
const be = pe[Ie];
|
|
3564
|
+
if (be >= Mt.safeCount) continue;
|
|
3565
|
+
const cn = Mt.positions[be * 2], ln = Mt.positions[be * 2 + 1], hn = cn - _, fn = ln - O, dn = hn * hn + fn * fn;
|
|
3566
|
+
dn > on || (on = dn, ge = be, sn = cn, an = ln);
|
|
3552
3567
|
}
|
|
3553
3568
|
}
|
|
3554
3569
|
}
|
|
3555
|
-
if (
|
|
3556
|
-
const
|
|
3570
|
+
if (ge < 0) return null;
|
|
3571
|
+
const nr = Mt.ids ? Number(Mt.ids[ge]) : null;
|
|
3557
3572
|
return {
|
|
3558
|
-
index:
|
|
3559
|
-
id:
|
|
3560
|
-
coordinate: [_,
|
|
3561
|
-
pointCoordinate: [
|
|
3573
|
+
index: ge,
|
|
3574
|
+
id: nr,
|
|
3575
|
+
coordinate: [_, O],
|
|
3576
|
+
pointCoordinate: [sn, an]
|
|
3562
3577
|
};
|
|
3563
3578
|
},
|
|
3564
|
-
[
|
|
3565
|
-
), jt =
|
|
3566
|
-
(
|
|
3579
|
+
[Mt]
|
|
3580
|
+
), jt = B(
|
|
3581
|
+
(m, T) => {
|
|
3567
3582
|
if (!L) return;
|
|
3568
|
-
const _ =
|
|
3569
|
-
E.current === _ &&
|
|
3583
|
+
const _ = m?.index ?? null, O = m?.id ?? null;
|
|
3584
|
+
E.current === _ && I.current === O || (E.current = _, I.current = O, L({
|
|
3570
3585
|
index: _,
|
|
3571
|
-
id:
|
|
3572
|
-
coordinate:
|
|
3573
|
-
pointCoordinate:
|
|
3586
|
+
id: O,
|
|
3587
|
+
coordinate: T,
|
|
3588
|
+
pointCoordinate: m?.pointCoordinate ?? null
|
|
3574
3589
|
}));
|
|
3575
3590
|
},
|
|
3576
3591
|
[L]
|
|
3577
|
-
),
|
|
3578
|
-
(
|
|
3579
|
-
if (
|
|
3580
|
-
const _ = Ht(
|
|
3581
|
-
_ &&
|
|
3592
|
+
), he = B(
|
|
3593
|
+
(m, T) => {
|
|
3594
|
+
if (!Z) return;
|
|
3595
|
+
const _ = Ht(m);
|
|
3596
|
+
_ && Z({
|
|
3582
3597
|
..._,
|
|
3583
|
-
button:
|
|
3598
|
+
button: T
|
|
3584
3599
|
});
|
|
3585
3600
|
},
|
|
3586
|
-
[
|
|
3601
|
+
[Z, Ht]
|
|
3587
3602
|
);
|
|
3588
|
-
|
|
3589
|
-
const
|
|
3590
|
-
return Number.isFinite(
|
|
3591
|
-
}, [
|
|
3592
|
-
const
|
|
3593
|
-
const
|
|
3594
|
-
return Number.isFinite(
|
|
3595
|
-
}, [
|
|
3596
|
-
const
|
|
3597
|
-
return Number.isFinite(
|
|
3598
|
-
}, [
|
|
3603
|
+
tt(() => {
|
|
3604
|
+
const m = Number(G?.width ?? 220);
|
|
3605
|
+
return Number.isFinite(m) ? Math.max(64, m) : 220;
|
|
3606
|
+
}, [G?.width]);
|
|
3607
|
+
const Ze = tt(() => {
|
|
3608
|
+
const m = Number(G?.height ?? 140);
|
|
3609
|
+
return Number.isFinite(m) ? Math.max(48, m) : 140;
|
|
3610
|
+
}, [G?.height]), Dt = tt(() => {
|
|
3611
|
+
const m = Number(G?.margin ?? 16);
|
|
3612
|
+
return Number.isFinite(m) ? Math.max(0, m) : 16;
|
|
3613
|
+
}, [G?.margin]), fe = G?.position || "bottom-right";
|
|
3599
3614
|
X(() => {
|
|
3600
|
-
if (
|
|
3601
|
-
return
|
|
3602
|
-
|
|
3615
|
+
if (U)
|
|
3616
|
+
return U.current = Ht, () => {
|
|
3617
|
+
U.current === Ht && (U.current = null);
|
|
3603
3618
|
};
|
|
3604
|
-
}, [
|
|
3605
|
-
const
|
|
3606
|
-
(
|
|
3607
|
-
|
|
3619
|
+
}, [U, Ht]);
|
|
3620
|
+
const Nt = B(
|
|
3621
|
+
(m) => {
|
|
3622
|
+
ue((T) => String(T) === String(m) ? T : (yt?.(m), m));
|
|
3608
3623
|
},
|
|
3609
|
-
[
|
|
3624
|
+
[yt]
|
|
3610
3625
|
);
|
|
3611
3626
|
X(() => {
|
|
3612
|
-
|
|
3627
|
+
F.current = n;
|
|
3613
3628
|
}, [n]), X(() => {
|
|
3614
|
-
|
|
3629
|
+
ct.current = r;
|
|
3615
3630
|
}, [r]), X(() => {
|
|
3616
|
-
|
|
3631
|
+
ot.current = a, a || w(null);
|
|
3617
3632
|
}, [a]);
|
|
3618
|
-
const
|
|
3619
|
-
|
|
3620
|
-
}, []), Zn =
|
|
3621
|
-
`tier ${
|
|
3622
|
-
`tiles visible ${
|
|
3623
|
-
`cache size ${
|
|
3624
|
-
`queue inflight ${
|
|
3625
|
-
`points ${
|
|
3633
|
+
const Ke = B((m) => {
|
|
3634
|
+
ct.current?.(m), ot.current && w(m);
|
|
3635
|
+
}, []), Zn = tt(() => f ? [
|
|
3636
|
+
`tier ${f.tier} | frame ${f.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${f.drawCalls ?? "-"}`,
|
|
3637
|
+
`tiles visible ${f.visible} | rendered ${f.rendered} | fallback ${f.fallback}`,
|
|
3638
|
+
`cache size ${f.cache} | hit ${f.cacheHits ?? "-"} | miss ${f.cacheMisses ?? "-"}`,
|
|
3639
|
+
`queue inflight ${f.inflight} | queued ${f.queued ?? "-"} | retries ${f.retries ?? "-"} | failed ${f.failed ?? "-"} | aborted ${f.aborted ?? "-"}`,
|
|
3640
|
+
`points ${f.points}`
|
|
3626
3641
|
].join(`
|
|
3627
|
-
`) : "stats: waiting for first frame...", [
|
|
3642
|
+
`) : "stats: waiting for first frame...", [f]);
|
|
3628
3643
|
X(() => {
|
|
3629
|
-
!(
|
|
3630
|
-
const
|
|
3631
|
-
!(
|
|
3644
|
+
!(pt === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(pt))) && pt !== null && Nt(null);
|
|
3645
|
+
const T = y.current;
|
|
3646
|
+
!(T === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(T))) && T !== null && (y.current = null, qt(null), et?.({
|
|
3632
3647
|
region: null,
|
|
3633
3648
|
regionId: null,
|
|
3634
3649
|
regionIndex: -1,
|
|
3635
3650
|
coordinate: null
|
|
3636
3651
|
}));
|
|
3637
|
-
}, [
|
|
3638
|
-
const
|
|
3639
|
-
|
|
3652
|
+
}, [H, pt, et, Nt]), X(() => {
|
|
3653
|
+
const m = E.current;
|
|
3654
|
+
m !== null && (Mt && m < Mt.safeCount || (E.current = null, I.current = null, L?.({
|
|
3640
3655
|
index: null,
|
|
3641
3656
|
id: null,
|
|
3642
3657
|
coordinate: null,
|
|
3643
3658
|
pointCoordinate: null
|
|
3644
3659
|
})));
|
|
3645
|
-
}, [
|
|
3646
|
-
const
|
|
3647
|
-
(
|
|
3648
|
-
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3660
|
+
}, [Mt, L]);
|
|
3661
|
+
const je = B(
|
|
3662
|
+
(m) => {
|
|
3663
|
+
Pt && l(m);
|
|
3664
|
+
const T = F.current;
|
|
3665
|
+
T && T(m), It.current?.(), _t.current?.();
|
|
3651
3666
|
},
|
|
3652
|
-
[
|
|
3667
|
+
[Pt]
|
|
3653
3668
|
);
|
|
3654
3669
|
X(() => {
|
|
3655
|
-
if (!
|
|
3656
|
-
|
|
3670
|
+
if (!N) {
|
|
3671
|
+
Bt(!1);
|
|
3657
3672
|
return;
|
|
3658
3673
|
}
|
|
3659
|
-
|
|
3660
|
-
}, [
|
|
3661
|
-
|
|
3674
|
+
Bt(!0);
|
|
3675
|
+
}, [N, e?.id]), X(() => {
|
|
3676
|
+
$ !== "cursor" && y.current !== null && (y.current = null, qt(null), et?.({
|
|
3662
3677
|
region: null,
|
|
3663
3678
|
regionId: null,
|
|
3664
3679
|
regionIndex: -1,
|
|
3665
3680
|
coordinate: null
|
|
3666
3681
|
}));
|
|
3667
|
-
}, [
|
|
3668
|
-
|
|
3682
|
+
}, [$, et]), X(() => {
|
|
3683
|
+
$ !== "cursor" && E.current !== null && (E.current = null, I.current = null, L?.({
|
|
3669
3684
|
index: null,
|
|
3670
3685
|
id: null,
|
|
3671
3686
|
coordinate: null,
|
|
3672
3687
|
pointCoordinate: null
|
|
3673
3688
|
}));
|
|
3674
|
-
}, [
|
|
3675
|
-
const
|
|
3676
|
-
const _ =
|
|
3689
|
+
}, [$, L]);
|
|
3690
|
+
const kt = B((m, T) => {
|
|
3691
|
+
const _ = q.current;
|
|
3677
3692
|
if (!_) return null;
|
|
3678
|
-
const
|
|
3679
|
-
if (!Array.isArray(
|
|
3680
|
-
const z = Number(
|
|
3681
|
-
return !Number.isFinite(z) || !Number.isFinite(
|
|
3682
|
-
}, []),
|
|
3683
|
-
const _ =
|
|
3693
|
+
const O = _.screenToWorld(m, T);
|
|
3694
|
+
if (!Array.isArray(O) || O.length < 2) return null;
|
|
3695
|
+
const z = Number(O[0]), st = Number(O[1]);
|
|
3696
|
+
return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
|
|
3697
|
+
}, []), Je = B((m, T) => {
|
|
3698
|
+
const _ = q.current;
|
|
3684
3699
|
if (!_) return null;
|
|
3685
|
-
const
|
|
3686
|
-
if (!Array.isArray(
|
|
3687
|
-
const z = Number(
|
|
3688
|
-
return !Number.isFinite(z) || !Number.isFinite(
|
|
3689
|
-
}, []),
|
|
3690
|
-
|
|
3691
|
-
}, []),
|
|
3700
|
+
const O = _.worldToScreen(m, T);
|
|
3701
|
+
if (!Array.isArray(O) || O.length < 2) return null;
|
|
3702
|
+
const z = Number(O[0]), st = Number(O[1]);
|
|
3703
|
+
return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
|
|
3704
|
+
}, []), Qe = B(() => {
|
|
3705
|
+
q.current?.requestRender(), It.current?.(), _t.current?.();
|
|
3706
|
+
}, []), tn = tt(() => ce ?? q.current?.getViewState() ?? null, [ce]), en = tt(() => {
|
|
3692
3707
|
if (!e) return null;
|
|
3693
|
-
const
|
|
3694
|
-
return
|
|
3708
|
+
const m = tn;
|
|
3709
|
+
return m ? {
|
|
3695
3710
|
source: e,
|
|
3696
|
-
viewState:
|
|
3697
|
-
drawTool:
|
|
3698
|
-
interactionLock:
|
|
3699
|
-
worldToScreen:
|
|
3700
|
-
screenToWorld:
|
|
3701
|
-
requestRedraw:
|
|
3711
|
+
viewState: m,
|
|
3712
|
+
drawTool: $,
|
|
3713
|
+
interactionLock: at,
|
|
3714
|
+
worldToScreen: Je,
|
|
3715
|
+
screenToWorld: kt,
|
|
3716
|
+
requestRedraw: Qe
|
|
3702
3717
|
} : null;
|
|
3703
|
-
}, [e,
|
|
3704
|
-
(
|
|
3705
|
-
const
|
|
3706
|
-
if (
|
|
3707
|
-
const
|
|
3708
|
-
|
|
3718
|
+
}, [e, tn, $, at, Je, kt, Qe]), Kn = B(
|
|
3719
|
+
(m) => {
|
|
3720
|
+
const T = m.target === rt.current, _ = kt(m.clientX, m.clientY);
|
|
3721
|
+
if (A) {
|
|
3722
|
+
const de = !!_ && _[0] >= 0 && _[1] >= 0 && !!e && _[0] <= e.width && _[1] <= e.height;
|
|
3723
|
+
A({
|
|
3709
3724
|
coordinate: _,
|
|
3710
|
-
clientX:
|
|
3711
|
-
clientY:
|
|
3712
|
-
insideImage:
|
|
3725
|
+
clientX: m.clientX,
|
|
3726
|
+
clientY: m.clientY,
|
|
3727
|
+
insideImage: de
|
|
3713
3728
|
});
|
|
3714
3729
|
}
|
|
3715
|
-
if (
|
|
3716
|
-
if (!
|
|
3717
|
-
jt(null, null),
|
|
3730
|
+
if ($ !== "cursor") return;
|
|
3731
|
+
if (!T) {
|
|
3732
|
+
jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
|
|
3718
3733
|
region: null,
|
|
3719
3734
|
regionId: null,
|
|
3720
3735
|
regionIndex: -1,
|
|
@@ -3726,110 +3741,124 @@ function mo({
|
|
|
3726
3741
|
jt(null, null);
|
|
3727
3742
|
return;
|
|
3728
3743
|
}
|
|
3729
|
-
if (L && jt(Ht(_), _), !
|
|
3730
|
-
const
|
|
3731
|
-
String(
|
|
3732
|
-
region:
|
|
3744
|
+
if (L && jt(Ht(_), _), !H.length) return;
|
|
3745
|
+
const O = De(_, H), z = O?.regionId ?? null, st = y.current;
|
|
3746
|
+
String(st) !== String(z) && (y.current = z, qt(z), et?.({
|
|
3747
|
+
region: O?.region ?? null,
|
|
3733
3748
|
regionId: z,
|
|
3734
|
-
regionIndex:
|
|
3749
|
+
regionIndex: O?.regionIndex ?? -1,
|
|
3735
3750
|
coordinate: _
|
|
3736
3751
|
}));
|
|
3737
3752
|
},
|
|
3738
|
-
[
|
|
3739
|
-
), jn =
|
|
3740
|
-
|
|
3753
|
+
[$, H, kt, et, A, e, jt, Ht, L]
|
|
3754
|
+
), jn = B(() => {
|
|
3755
|
+
A?.({
|
|
3741
3756
|
coordinate: null,
|
|
3742
3757
|
clientX: -1,
|
|
3743
3758
|
clientY: -1,
|
|
3744
3759
|
insideImage: !1
|
|
3745
|
-
}), jt(null, null),
|
|
3760
|
+
}), jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
|
|
3746
3761
|
region: null,
|
|
3747
3762
|
regionId: null,
|
|
3748
3763
|
regionIndex: -1,
|
|
3749
3764
|
coordinate: null
|
|
3750
3765
|
}));
|
|
3751
|
-
}, [
|
|
3752
|
-
(
|
|
3753
|
-
if (
|
|
3754
|
-
const
|
|
3755
|
-
if (!
|
|
3756
|
-
if (
|
|
3757
|
-
|
|
3766
|
+
}, [et, A, jt]), Jn = B(
|
|
3767
|
+
(m) => {
|
|
3768
|
+
if ($ !== "cursor" || m.target !== rt.current) return;
|
|
3769
|
+
const T = kt(m.clientX, m.clientY);
|
|
3770
|
+
if (!T) return;
|
|
3771
|
+
if (he(T, m.button), !H.length) {
|
|
3772
|
+
Nt(null);
|
|
3758
3773
|
return;
|
|
3759
3774
|
}
|
|
3760
|
-
const _ =
|
|
3775
|
+
const _ = De(T, H);
|
|
3761
3776
|
if (!_) {
|
|
3762
|
-
|
|
3777
|
+
Nt(null);
|
|
3763
3778
|
return;
|
|
3764
3779
|
}
|
|
3765
|
-
const
|
|
3766
|
-
|
|
3780
|
+
const O = pt !== null && String(pt) === String(_.regionId) ? null : _.regionId;
|
|
3781
|
+
Nt(O), mt?.({
|
|
3767
3782
|
region: _.region,
|
|
3768
3783
|
regionId: _.regionId,
|
|
3769
3784
|
regionIndex: _.regionIndex,
|
|
3770
|
-
coordinate:
|
|
3785
|
+
coordinate: T
|
|
3771
3786
|
});
|
|
3772
3787
|
},
|
|
3773
|
-
[
|
|
3774
|
-
), Qn =
|
|
3775
|
-
(
|
|
3776
|
-
if (
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3788
|
+
[$, H, kt, mt, pt, Nt, he]
|
|
3789
|
+
), Qn = B(
|
|
3790
|
+
(m) => {
|
|
3791
|
+
if ($ !== "brush" || vt?.clickSelectRoi !== !0 || !H.length) return !1;
|
|
3792
|
+
const T = De(m, H);
|
|
3793
|
+
if (!T) return !1;
|
|
3794
|
+
const _ = pt !== null && String(pt) === String(T.regionId) ? null : T.regionId;
|
|
3795
|
+
return Nt(_), mt?.({
|
|
3796
|
+
region: T.region,
|
|
3797
|
+
regionId: T.regionId,
|
|
3798
|
+
regionIndex: T.regionIndex,
|
|
3799
|
+
coordinate: m
|
|
3800
|
+
}), !0;
|
|
3801
|
+
},
|
|
3802
|
+
[$, vt?.clickSelectRoi, H, pt, Nt, mt]
|
|
3803
|
+
), tr = B(
|
|
3804
|
+
(m) => {
|
|
3805
|
+
if (!Z || $ !== "cursor" || m.target !== rt.current) return;
|
|
3806
|
+
m.preventDefault();
|
|
3807
|
+
const T = kt(m.clientX, m.clientY);
|
|
3808
|
+
T && he(T, m.button);
|
|
3780
3809
|
},
|
|
3781
|
-
[
|
|
3810
|
+
[$, kt, he, Z]
|
|
3782
3811
|
);
|
|
3783
3812
|
return X(() => {
|
|
3784
|
-
const
|
|
3785
|
-
if (!
|
|
3813
|
+
const m = rt.current;
|
|
3814
|
+
if (!m || !e)
|
|
3786
3815
|
return;
|
|
3787
|
-
const
|
|
3788
|
-
onViewStateChange:
|
|
3789
|
-
onStats:
|
|
3816
|
+
const T = new Hi(m, e, {
|
|
3817
|
+
onViewStateChange: je,
|
|
3818
|
+
onStats: Ke,
|
|
3790
3819
|
onTileError: i,
|
|
3791
3820
|
onContextLost: o,
|
|
3792
3821
|
onContextRestored: s,
|
|
3793
3822
|
authToken: g,
|
|
3794
3823
|
ctrlDragRotate: d,
|
|
3795
|
-
pointSizeByZoom:
|
|
3824
|
+
pointSizeByZoom: S
|
|
3796
3825
|
});
|
|
3797
|
-
return
|
|
3798
|
-
|
|
3826
|
+
return q.current = T, t && T.setViewState(t), T.setInteractionLock(at), Pt && l(T.getViewState()), () => {
|
|
3827
|
+
T.destroy(), q.current = null;
|
|
3799
3828
|
};
|
|
3800
|
-
}, [e,
|
|
3801
|
-
const
|
|
3802
|
-
!
|
|
3829
|
+
}, [e, Ke, i, o, s, g, d, S, je, Pt]), X(() => {
|
|
3830
|
+
const m = q.current;
|
|
3831
|
+
!m || !t || m.setViewState(t);
|
|
3803
3832
|
}, [t]), X(() => {
|
|
3804
|
-
const
|
|
3805
|
-
|
|
3833
|
+
const m = q.current;
|
|
3834
|
+
m && m.fitToImage();
|
|
3806
3835
|
}, [c]), X(() => {
|
|
3807
|
-
const
|
|
3808
|
-
|
|
3836
|
+
const m = q.current;
|
|
3837
|
+
m && m.resetRotation();
|
|
3809
3838
|
}, [h]), X(() => {
|
|
3810
|
-
const
|
|
3811
|
-
!
|
|
3812
|
-
}, [y]), X(() => {
|
|
3813
|
-
const p = O.current;
|
|
3814
|
-
p && p.setPointSizeByZoom(x);
|
|
3839
|
+
const m = q.current;
|
|
3840
|
+
!m || !x || m.setPointPalette(x);
|
|
3815
3841
|
}, [x]), X(() => {
|
|
3816
|
-
const
|
|
3817
|
-
|
|
3818
|
-
}, [
|
|
3819
|
-
|
|
3820
|
-
|
|
3842
|
+
const m = q.current;
|
|
3843
|
+
m && m.setPointSizeByZoom(S);
|
|
3844
|
+
}, [S]), X(() => {
|
|
3845
|
+
const m = q.current;
|
|
3846
|
+
m && m.setPointData(Tt);
|
|
3847
|
+
}, [Tt]), X(() => {
|
|
3848
|
+
if (!J) return;
|
|
3849
|
+
const T = Yi(v ? Tt : p, H, {
|
|
3821
3850
|
paletteIndexToTermId: ft,
|
|
3822
3851
|
includeEmptyRegions: !0
|
|
3823
3852
|
});
|
|
3824
|
-
|
|
3825
|
-
}, [
|
|
3826
|
-
const
|
|
3827
|
-
|
|
3828
|
-
}, [
|
|
3829
|
-
/* @__PURE__ */
|
|
3853
|
+
J(T);
|
|
3854
|
+
}, [J, v, p, Tt, H, ft]), X(() => {
|
|
3855
|
+
const m = q.current;
|
|
3856
|
+
m && m.setInteractionLock(at);
|
|
3857
|
+
}, [at]), /* @__PURE__ */ mn("div", { className: ut, style: $t, onPointerMove: Kn, onPointerLeave: jn, onClick: Jn, onContextMenu: tr, children: [
|
|
3858
|
+
/* @__PURE__ */ Ft(
|
|
3830
3859
|
"canvas",
|
|
3831
3860
|
{
|
|
3832
|
-
ref:
|
|
3861
|
+
ref: rt,
|
|
3833
3862
|
className: "wsi-render-canvas",
|
|
3834
3863
|
style: {
|
|
3835
3864
|
position: "absolute",
|
|
@@ -3839,68 +3868,69 @@ function mo({
|
|
|
3839
3868
|
height: "100%",
|
|
3840
3869
|
display: "block",
|
|
3841
3870
|
touchAction: "none",
|
|
3842
|
-
cursor:
|
|
3871
|
+
cursor: $ === "cursor" && Ut !== null ? "pointer" : at ? "crosshair" : "grab"
|
|
3843
3872
|
}
|
|
3844
3873
|
}
|
|
3845
3874
|
),
|
|
3846
|
-
e &&
|
|
3875
|
+
e && en && Array.isArray(Q) && Q.length > 0 ? Q.map((m, T) => /* @__PURE__ */ Ft(
|
|
3847
3876
|
"div",
|
|
3848
3877
|
{
|
|
3849
|
-
className:
|
|
3878
|
+
className: m.className,
|
|
3850
3879
|
style: {
|
|
3851
3880
|
position: "absolute",
|
|
3852
3881
|
inset: 0,
|
|
3853
|
-
zIndex:
|
|
3854
|
-
pointerEvents:
|
|
3855
|
-
...
|
|
3882
|
+
zIndex: m.zIndex ?? 3,
|
|
3883
|
+
pointerEvents: m.pointerEvents ?? "none",
|
|
3884
|
+
...m.style
|
|
3856
3885
|
},
|
|
3857
|
-
children:
|
|
3886
|
+
children: m.render(en)
|
|
3858
3887
|
},
|
|
3859
|
-
|
|
3888
|
+
m.id ?? T
|
|
3860
3889
|
)) : null,
|
|
3861
|
-
e ? /* @__PURE__ */
|
|
3862
|
-
|
|
3890
|
+
e ? /* @__PURE__ */ Ft(
|
|
3891
|
+
bi,
|
|
3863
3892
|
{
|
|
3864
|
-
tool:
|
|
3865
|
-
enabled:
|
|
3893
|
+
tool: $,
|
|
3894
|
+
enabled: $ !== "cursor",
|
|
3866
3895
|
imageWidth: e.width,
|
|
3867
3896
|
imageHeight: e.height,
|
|
3868
3897
|
imageMpp: e.mpp,
|
|
3869
3898
|
imageZoom: e.maxTierZoom,
|
|
3870
|
-
stampOptions:
|
|
3871
|
-
brushOptions:
|
|
3872
|
-
projectorRef:
|
|
3899
|
+
stampOptions: ht,
|
|
3900
|
+
brushOptions: vt,
|
|
3901
|
+
projectorRef: q,
|
|
3902
|
+
onBrushTap: Qn,
|
|
3873
3903
|
viewStateSignal: t,
|
|
3874
|
-
persistedRegions:
|
|
3875
|
-
patchRegions:
|
|
3876
|
-
regionStrokeStyle:
|
|
3877
|
-
regionStrokeHoverStyle:
|
|
3878
|
-
regionStrokeActiveStyle:
|
|
3879
|
-
patchStrokeStyle:
|
|
3880
|
-
resolveRegionStrokeStyle:
|
|
3881
|
-
overlayShapes:
|
|
3882
|
-
hoveredRegionId:
|
|
3883
|
-
activeRegionId:
|
|
3884
|
-
regionLabelStyle:
|
|
3904
|
+
persistedRegions: H,
|
|
3905
|
+
patchRegions: W,
|
|
3906
|
+
regionStrokeStyle: Ot,
|
|
3907
|
+
regionStrokeHoverStyle: K,
|
|
3908
|
+
regionStrokeActiveStyle: Ct,
|
|
3909
|
+
patchStrokeStyle: zt,
|
|
3910
|
+
resolveRegionStrokeStyle: Kt,
|
|
3911
|
+
overlayShapes: dt,
|
|
3912
|
+
hoveredRegionId: Ut,
|
|
3913
|
+
activeRegionId: pt,
|
|
3914
|
+
regionLabelStyle: C,
|
|
3885
3915
|
invalidateRef: It,
|
|
3886
|
-
onDrawComplete:
|
|
3887
|
-
onPatchComplete:
|
|
3916
|
+
onDrawComplete: At,
|
|
3917
|
+
onPatchComplete: gt
|
|
3888
3918
|
}
|
|
3889
3919
|
) : null,
|
|
3890
|
-
a ? /* @__PURE__ */
|
|
3891
|
-
e &&
|
|
3892
|
-
/* @__PURE__ */
|
|
3893
|
-
/* @__PURE__ */
|
|
3920
|
+
a ? /* @__PURE__ */ Ft("pre", { "data-open-plant-debug-overlay": !0, style: xt, children: Zn }) : null,
|
|
3921
|
+
e && N ? Gt ? /* @__PURE__ */ mn(or, { children: [
|
|
3922
|
+
/* @__PURE__ */ Ft(yi, { source: e, projectorRef: q, authToken: g, options: G, invalidateRef: _t }),
|
|
3923
|
+
/* @__PURE__ */ Ft(
|
|
3894
3924
|
"button",
|
|
3895
3925
|
{
|
|
3896
3926
|
type: "button",
|
|
3897
3927
|
"aria-label": "Hide overview map",
|
|
3898
|
-
onClick: () =>
|
|
3928
|
+
onClick: () => Bt(!1),
|
|
3899
3929
|
style: {
|
|
3900
3930
|
position: "absolute",
|
|
3901
3931
|
zIndex: 6,
|
|
3902
|
-
...
|
|
3903
|
-
...
|
|
3932
|
+
...fe.includes("left") ? { left: Dt } : { right: Dt },
|
|
3933
|
+
...fe.includes("top") ? { top: Dt + Ze + 8 } : { bottom: Dt + Ze + 8 },
|
|
3904
3934
|
width: 20,
|
|
3905
3935
|
height: 20,
|
|
3906
3936
|
borderRadius: 999,
|
|
@@ -3915,17 +3945,17 @@ function mo({
|
|
|
3915
3945
|
children: "×"
|
|
3916
3946
|
}
|
|
3917
3947
|
)
|
|
3918
|
-
] }) : /* @__PURE__ */
|
|
3948
|
+
] }) : /* @__PURE__ */ Ft(
|
|
3919
3949
|
"button",
|
|
3920
3950
|
{
|
|
3921
3951
|
type: "button",
|
|
3922
3952
|
"aria-label": "Show overview map",
|
|
3923
|
-
onClick: () =>
|
|
3953
|
+
onClick: () => Bt(!0),
|
|
3924
3954
|
style: {
|
|
3925
3955
|
position: "absolute",
|
|
3926
3956
|
zIndex: 6,
|
|
3927
|
-
...
|
|
3928
|
-
...
|
|
3957
|
+
...fe.includes("left") ? { left: Dt } : { right: Dt },
|
|
3958
|
+
...fe.includes("top") ? { top: Dt } : { bottom: Dt },
|
|
3929
3959
|
height: 24,
|
|
3930
3960
|
minWidth: 40,
|
|
3931
3961
|
borderRadius: 999,
|
|
@@ -3943,34 +3973,34 @@ function mo({
|
|
|
3943
3973
|
] });
|
|
3944
3974
|
}
|
|
3945
3975
|
export {
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3976
|
+
Fn as DEFAULT_POINT_COLOR,
|
|
3977
|
+
bi as DrawLayer,
|
|
3978
|
+
hr as M1TileRenderer,
|
|
3979
|
+
yi as OverviewMap,
|
|
3980
|
+
Vi as TileScheduler,
|
|
3981
|
+
bo as TileViewerCanvas,
|
|
3982
|
+
Hi as WsiTileRenderer,
|
|
3983
|
+
So as WsiViewerCanvas,
|
|
3984
|
+
go as buildTermPalette,
|
|
3985
|
+
ho as calcScaleLength,
|
|
3956
3986
|
zn as calcScaleResolution,
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3987
|
+
it as clamp,
|
|
3988
|
+
Et as closeRing,
|
|
3989
|
+
Yi as computeRoiPointGroups,
|
|
3990
|
+
Tn as createCircle,
|
|
3991
|
+
Sn as createRectangle,
|
|
3992
|
+
Re as filterPointDataByPolygons,
|
|
3993
|
+
Fi as filterPointDataByPolygonsHybrid,
|
|
3994
|
+
zi as filterPointDataByPolygonsInWorker,
|
|
3995
|
+
Ti as filterPointIndicesByPolygons,
|
|
3996
|
+
xo as filterPointIndicesByPolygonsInWorker,
|
|
3997
|
+
wo as getWebGpuCapabilities,
|
|
3998
|
+
Fr as hexToRgba,
|
|
3999
|
+
fo as isSameViewState,
|
|
4000
|
+
po as normalizeImageInfo,
|
|
4001
|
+
Ii as prefilterPointsByBoundsWebGpu,
|
|
4002
|
+
yo as terminateRoiClipWorker,
|
|
4003
|
+
mo as toBearerToken,
|
|
3974
4004
|
Wn as toTileUrl
|
|
3975
4005
|
};
|
|
3976
4006
|
//# sourceMappingURL=index.js.map
|