open-plant 1.2.1 → 1.2.2
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/CHANGELOG.md +9 -1
- package/README.md +20 -2
- package/dist/assets/roi-clip-worker-DdVYCepx.js +2 -0
- package/dist/assets/roi-clip-worker-DdVYCepx.js.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1336 -1265
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/react/draw-layer.d.ts +10 -1
- package/dist/types/react/draw-layer.d.ts.map +1 -1
- package/dist/types/react/wsi-viewer-canvas.d.ts +24 -3
- package/dist/types/react/wsi-viewer-canvas.d.ts.map +1 -1
- package/dist/types/wsi/point-clip-worker-client.d.ts +5 -0
- package/dist/types/wsi/point-clip-worker-client.d.ts.map +1 -1
- package/dist/types/wsi/point-clip-worker-protocol.d.ts +17 -2
- package/dist/types/wsi/point-clip-worker-protocol.d.ts.map +1 -1
- package/dist/types/wsi/point-clip.d.ts +1 -0
- package/dist/types/wsi/point-clip.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/roi-clip-worker-i1SE1Dpa.js +0 -2
- package/dist/assets/roi-clip-worker-i1SE1Dpa.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useRef as
|
|
6
|
-
function
|
|
1
|
+
var an = Object.defineProperty;
|
|
2
|
+
var cn = (e, t, n) => t in e ? an(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var d = (e, t, n) => cn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as Mt, jsxs as Ee, Fragment as un } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as Z, useMemo as H, useCallback as D, useEffect as z, useState as Yt } from "react";
|
|
6
|
+
function Ae(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 me(e, t, n) {
|
|
|
13
13
|
}
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const r =
|
|
16
|
+
function ln(e, t, n) {
|
|
17
|
+
const r = Ae(e, e.VERTEX_SHADER, t), i = Ae(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)) {
|
|
@@ -23,13 +23,13 @@ function Ge(e, t, n) {
|
|
|
23
23
|
}
|
|
24
24
|
return o;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function se(e, t, n) {
|
|
27
27
|
const r = e.getUniformLocation(t, n);
|
|
28
28
|
if (!r)
|
|
29
29
|
throw new Error(`Failed to get uniform location: ${n}`);
|
|
30
30
|
return r;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function hn(e) {
|
|
33
33
|
const t = e.getContext("webgl2", {
|
|
34
34
|
alpha: !1,
|
|
35
35
|
antialias: !1,
|
|
@@ -42,11 +42,11 @@ function qe(e) {
|
|
|
42
42
|
throw new Error("WebGL2 is not available.");
|
|
43
43
|
return t;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let dn = class {
|
|
46
46
|
constructor() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
d(this, "viewportWidth", 1);
|
|
48
|
+
d(this, "viewportHeight", 1);
|
|
49
|
+
d(this, "viewState", {
|
|
50
50
|
offsetX: 0,
|
|
51
51
|
offsetY: 0,
|
|
52
52
|
zoom: 1
|
|
@@ -82,7 +82,7 @@ let $e = class {
|
|
|
82
82
|
]);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
const
|
|
85
|
+
const fn = `#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
|
+
`, mn = `#version 300 es
|
|
106
106
|
precision highp float;
|
|
107
107
|
|
|
108
108
|
in vec2 vUv;
|
|
@@ -114,28 +114,28 @@ void main() {
|
|
|
114
114
|
outColor = texture(uTexture, vUv);
|
|
115
115
|
}
|
|
116
116
|
`;
|
|
117
|
-
class
|
|
117
|
+
class gn {
|
|
118
118
|
constructor(t) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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 =
|
|
119
|
+
d(this, "canvas");
|
|
120
|
+
d(this, "gl");
|
|
121
|
+
d(this, "camera", new dn());
|
|
122
|
+
d(this, "imageWidth");
|
|
123
|
+
d(this, "imageHeight");
|
|
124
|
+
d(this, "clearColor");
|
|
125
|
+
d(this, "program");
|
|
126
|
+
d(this, "vao");
|
|
127
|
+
d(this, "quadBuffer");
|
|
128
|
+
d(this, "uCameraLocation");
|
|
129
|
+
d(this, "uBoundsLocation");
|
|
130
|
+
d(this, "uTextureLocation");
|
|
131
|
+
d(this, "resizeObserver");
|
|
132
|
+
d(this, "tiles", []);
|
|
133
|
+
d(this, "frameId", null);
|
|
134
|
+
d(this, "loadVersion", 0);
|
|
135
|
+
d(this, "destroyed", !1);
|
|
136
|
+
d(this, "fitted", !1);
|
|
137
|
+
d(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 = hn(this.canvas), this.program = ln(this.gl, fn, mn);
|
|
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.");
|
|
@@ -177,15 +177,15 @@ class Ke {
|
|
|
177
177
|
!1,
|
|
178
178
|
a,
|
|
179
179
|
2 * Float32Array.BYTES_PER_ELEMENT
|
|
180
|
-
), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation =
|
|
180
|
+
), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation = se(
|
|
181
181
|
this.gl,
|
|
182
182
|
this.program,
|
|
183
183
|
"uCamera"
|
|
184
|
-
), this.uBoundsLocation =
|
|
184
|
+
), this.uBoundsLocation = se(
|
|
185
185
|
this.gl,
|
|
186
186
|
this.program,
|
|
187
187
|
"uBounds"
|
|
188
|
-
), this.uTextureLocation =
|
|
188
|
+
), this.uTextureLocation = se(
|
|
189
189
|
this.gl,
|
|
190
190
|
this.program,
|
|
191
191
|
"uTexture"
|
|
@@ -310,31 +310,31 @@ class Ke {
|
|
|
310
310
|
this.gl.deleteTexture(n.texture);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
const
|
|
313
|
+
const Xe = [
|
|
314
314
|
160,
|
|
315
315
|
160,
|
|
316
316
|
160,
|
|
317
317
|
255
|
|
318
318
|
];
|
|
319
|
-
function
|
|
319
|
+
function j(e, t, n) {
|
|
320
320
|
return Math.max(t, Math.min(n, e));
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Ve(e, t, n) {
|
|
323
323
|
const r = Number(e), i = Number(t), o = Number(n);
|
|
324
324
|
return !Number.isFinite(r) || r <= 0 ? 1 : !Number.isFinite(i) || !Number.isFinite(o) ? r : Math.pow(2, i - o) * r;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
327
|
-
let i = 100 *
|
|
326
|
+
function fr(e, t, n) {
|
|
327
|
+
let i = 100 * Ve(e, t, n);
|
|
328
328
|
if (Number(e)) {
|
|
329
329
|
let o = "μm";
|
|
330
330
|
return i > 1e3 && (i /= 1e3, o = "mm"), `${i.toPrecision(3)} ${o}`;
|
|
331
331
|
}
|
|
332
332
|
return `${Math.round(i * 1e3) / 1e3} pixels`;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function mr(e, t) {
|
|
335
335
|
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;
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function gr(e) {
|
|
338
338
|
const t = String(e ?? "").trim();
|
|
339
339
|
if (!t) return "";
|
|
340
340
|
if (/^bearer\s+/i.test(t)) {
|
|
@@ -343,26 +343,26 @@ function tr(e) {
|
|
|
343
343
|
}
|
|
344
344
|
return `Bearer ${t}`;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function pn(e) {
|
|
347
347
|
const n = String(e ?? "").trim().match(/^#?([0-9a-fA-F]{6})$/);
|
|
348
|
-
if (!n) return [...
|
|
348
|
+
if (!n) return [...Xe];
|
|
349
349
|
const r = Number.parseInt(n[1], 16);
|
|
350
350
|
return [r >> 16 & 255, r >> 8 & 255, r & 255, 255];
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function pr(e) {
|
|
353
353
|
const t = [
|
|
354
|
-
[...
|
|
354
|
+
[...Xe]
|
|
355
355
|
], n = /* @__PURE__ */ new Map();
|
|
356
356
|
for (const i of e ?? []) {
|
|
357
357
|
const o = String(i?.termId ?? "");
|
|
358
|
-
!o || n.has(o) || (n.set(o, t.length), t.push(
|
|
358
|
+
!o || n.has(o) || (n.set(o, t.length), t.push(pn(i?.termColor)));
|
|
359
359
|
}
|
|
360
360
|
const r = new Uint8Array(t.length * 4);
|
|
361
361
|
for (let i = 0; i < t.length; i += 1)
|
|
362
362
|
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];
|
|
363
363
|
return { colors: r, termToPaletteIndex: n };
|
|
364
364
|
}
|
|
365
|
-
function
|
|
365
|
+
function Re(e, t, n) {
|
|
366
366
|
const r = e.createShader(e.VERTEX_SHADER), i = e.createShader(e.FRAGMENT_SHADER);
|
|
367
367
|
if (!r || !i)
|
|
368
368
|
throw new Error("Shader allocation failed");
|
|
@@ -377,7 +377,7 @@ function ge(e, t, n) {
|
|
|
377
377
|
throw new Error(e.getProgramInfoLog(o) || "program link failed");
|
|
378
378
|
return o;
|
|
379
379
|
}
|
|
380
|
-
const
|
|
380
|
+
const wn = "rgba(255, 77, 79, 0.16)", bn = 3, yn = 2, Oe = 96, xn = 1, Ce = [], fe = [], Ie = 1e3, Ge = 2, qe = 2, Tn = 4096, vn = 0.2, Bt = {
|
|
381
381
|
color: "#ff4d4f",
|
|
382
382
|
width: 2,
|
|
383
383
|
lineJoin: "round",
|
|
@@ -386,7 +386,17 @@ const Je = "rgba(255, 77, 79, 0.16)", Qe = 3, tn = 2, _e = 96, en = 1, nn = [],
|
|
|
386
386
|
shadowBlur: 0,
|
|
387
387
|
shadowOffsetX: 0,
|
|
388
388
|
shadowOffsetY: 0
|
|
389
|
-
},
|
|
389
|
+
}, Mn = {
|
|
390
|
+
color: "#4cc9f0",
|
|
391
|
+
width: 2,
|
|
392
|
+
lineDash: [10, 8],
|
|
393
|
+
lineJoin: "round",
|
|
394
|
+
lineCap: "round",
|
|
395
|
+
shadowColor: "rgba(0, 0, 0, 0)",
|
|
396
|
+
shadowBlur: 0,
|
|
397
|
+
shadowOffsetX: 0,
|
|
398
|
+
shadowOffsetY: 0
|
|
399
|
+
}, xt = {
|
|
390
400
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
391
401
|
fontSize: 12,
|
|
392
402
|
fontWeight: 500,
|
|
@@ -399,82 +409,67 @@ const Je = "rgba(255, 77, 79, 0.16)", Qe = 3, tn = 2, _e = 96, en = 1, nn = [],
|
|
|
399
409
|
offsetY: 10,
|
|
400
410
|
borderRadius: 3
|
|
401
411
|
};
|
|
402
|
-
function
|
|
412
|
+
function ne(e, t, n) {
|
|
403
413
|
return Math.max(t, Math.min(n, e));
|
|
404
414
|
}
|
|
405
|
-
function
|
|
415
|
+
function Zt(e) {
|
|
406
416
|
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";
|
|
407
417
|
}
|
|
408
|
-
function
|
|
418
|
+
function ae(e, t) {
|
|
409
419
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e;
|
|
410
420
|
}
|
|
411
|
-
function
|
|
421
|
+
function Pn(e) {
|
|
412
422
|
return {
|
|
413
|
-
rectangleAreaMm2:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
),
|
|
417
|
-
circleAreaMm2: Qt(
|
|
418
|
-
e?.circleAreaMm2,
|
|
419
|
-
Ue
|
|
420
|
-
),
|
|
421
|
-
rectanglePixelSize: Qt(
|
|
422
|
-
e?.rectanglePixelSize,
|
|
423
|
-
rn
|
|
424
|
-
)
|
|
423
|
+
rectangleAreaMm2: ae(e?.rectangleAreaMm2, Ge),
|
|
424
|
+
circleAreaMm2: ae(e?.circleAreaMm2, qe),
|
|
425
|
+
rectanglePixelSize: ae(e?.rectanglePixelSize, Tn)
|
|
425
426
|
};
|
|
426
427
|
}
|
|
427
|
-
function
|
|
428
|
-
return e *
|
|
428
|
+
function Sn(e) {
|
|
429
|
+
return e * Ie * Ie;
|
|
429
430
|
}
|
|
430
|
-
function
|
|
431
|
-
return !e || !Number.isFinite(t) || t <= 0 ? [] :
|
|
431
|
+
function _e(e, t) {
|
|
432
|
+
return !e || !Number.isFinite(t) || t <= 0 ? [] : Pt([
|
|
432
433
|
[e[0] - t, e[1] - t],
|
|
433
434
|
[e[0] + t, e[1] - t],
|
|
434
435
|
[e[0] + t, e[1] + t],
|
|
435
436
|
[e[0] - t, e[1] + t]
|
|
436
437
|
]);
|
|
437
438
|
}
|
|
438
|
-
function
|
|
439
|
+
function En(e, t, n = Oe) {
|
|
439
440
|
if (!e || !Number.isFinite(t) || t <= 0) return [];
|
|
440
441
|
const r = [];
|
|
441
442
|
for (let i = 0; i <= n; i += 1) {
|
|
442
443
|
const o = i / n * Math.PI * 2;
|
|
443
|
-
r.push([
|
|
444
|
-
e[0] + Math.cos(o) * t,
|
|
445
|
-
e[1] + Math.sin(o) * t
|
|
446
|
-
]);
|
|
444
|
+
r.push([e[0] + Math.cos(o) * t, e[1] + Math.sin(o) * t]);
|
|
447
445
|
}
|
|
448
|
-
return
|
|
446
|
+
return Pt(r);
|
|
449
447
|
}
|
|
450
|
-
function
|
|
448
|
+
function Pt(e) {
|
|
451
449
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
452
450
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
453
451
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
454
452
|
}
|
|
455
|
-
function
|
|
456
|
-
return !e || !t ? [] :
|
|
453
|
+
function Be(e, t) {
|
|
454
|
+
return !e || !t ? [] : Pt([
|
|
457
455
|
[e[0], e[1]],
|
|
458
456
|
[t[0], e[1]],
|
|
459
457
|
[t[0], t[1]],
|
|
460
458
|
[e[0], t[1]]
|
|
461
459
|
]);
|
|
462
460
|
}
|
|
463
|
-
function
|
|
461
|
+
function Ue(e, t, n = Oe) {
|
|
464
462
|
if (!e || !t) return [];
|
|
465
463
|
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;
|
|
466
464
|
if (o < 1) return [];
|
|
467
465
|
const s = [];
|
|
468
466
|
for (let a = 0; a <= n; a += 1) {
|
|
469
|
-
const
|
|
470
|
-
s.push([
|
|
471
|
-
r + Math.cos(l) * o,
|
|
472
|
-
i + Math.sin(l) * o
|
|
473
|
-
]);
|
|
467
|
+
const c = a / n * Math.PI * 2;
|
|
468
|
+
s.push([r + Math.cos(c) * o, i + Math.sin(c) * o]);
|
|
474
469
|
}
|
|
475
|
-
return
|
|
470
|
+
return Pt(s);
|
|
476
471
|
}
|
|
477
|
-
function
|
|
472
|
+
function me(e) {
|
|
478
473
|
if (!Array.isArray(e) || e.length < 4) return 0;
|
|
479
474
|
let t = 0;
|
|
480
475
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -483,40 +478,40 @@ function oe(e) {
|
|
|
483
478
|
}
|
|
484
479
|
return Math.abs(t * 0.5);
|
|
485
480
|
}
|
|
486
|
-
function
|
|
481
|
+
function Fe(e) {
|
|
487
482
|
if (!Array.isArray(e) || e.length === 0) return [0, 0, 0, 0];
|
|
488
483
|
let t = 1 / 0, n = 1 / 0, r = -1 / 0, i = -1 / 0;
|
|
489
484
|
for (const [o, s] of e)
|
|
490
485
|
o < t && (t = o), o > r && (r = o), s < n && (n = s), s > i && (i = s);
|
|
491
486
|
return [t, n, r, i];
|
|
492
487
|
}
|
|
493
|
-
function
|
|
494
|
-
return Array.isArray(e) && e.length >= 4 &&
|
|
488
|
+
function Le(e) {
|
|
489
|
+
return Array.isArray(e) && e.length >= 4 && me(e) > xn;
|
|
495
490
|
}
|
|
496
|
-
function
|
|
491
|
+
function Wt(e, t, n, r = !1, i = !1) {
|
|
497
492
|
if (t.length !== 0) {
|
|
498
493
|
e.beginPath(), e.moveTo(t[0][0], t[0][1]);
|
|
499
494
|
for (let o = 1; o < t.length; o += 1)
|
|
500
495
|
e.lineTo(t[o][0], t[o][1]);
|
|
501
|
-
r && e.closePath(), i && r && (e.fillStyle =
|
|
496
|
+
r && e.closePath(), i && r && (e.fillStyle = wn, 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(fe), e.shadowColor = "rgba(0, 0, 0, 0)", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
|
|
502
497
|
}
|
|
503
498
|
}
|
|
504
|
-
function
|
|
505
|
-
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) :
|
|
499
|
+
function $e(e) {
|
|
500
|
+
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) : fe, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) : Bt.width, r = typeof e?.shadowBlur == "number" && Number.isFinite(e.shadowBlur) ? Math.max(0, e.shadowBlur) : Bt.shadowBlur, i = typeof e?.shadowOffsetX == "number" && Number.isFinite(e.shadowOffsetX) ? e.shadowOffsetX : Bt.shadowOffsetX, o = typeof e?.shadowOffsetY == "number" && Number.isFinite(e.shadowOffsetY) ? e.shadowOffsetY : Bt.shadowOffsetY;
|
|
506
501
|
return {
|
|
507
|
-
color: e?.color ||
|
|
502
|
+
color: e?.color || Bt.color,
|
|
508
503
|
width: n,
|
|
509
|
-
lineDash: t.length ? t :
|
|
510
|
-
lineJoin: e?.lineJoin ||
|
|
511
|
-
lineCap: e?.lineCap ||
|
|
512
|
-
shadowColor: e?.shadowColor ||
|
|
504
|
+
lineDash: t.length ? t : fe,
|
|
505
|
+
lineJoin: e?.lineJoin || Bt.lineJoin,
|
|
506
|
+
lineCap: e?.lineCap || Bt.lineCap,
|
|
507
|
+
shadowColor: e?.shadowColor || Bt.shadowColor,
|
|
513
508
|
shadowBlur: r,
|
|
514
509
|
shadowOffsetX: i,
|
|
515
510
|
shadowOffsetY: o
|
|
516
511
|
};
|
|
517
512
|
}
|
|
518
|
-
function
|
|
519
|
-
return t ?
|
|
513
|
+
function Ot(e, t) {
|
|
514
|
+
return t ? $e({
|
|
520
515
|
color: t.color ?? e.color,
|
|
521
516
|
width: t.width ?? e.width,
|
|
522
517
|
lineDash: t.lineDash ?? e.lineDash,
|
|
@@ -528,18 +523,18 @@ function Wt(e, t) {
|
|
|
528
523
|
shadowOffsetY: t.shadowOffsetY ?? e.shadowOffsetY
|
|
529
524
|
}) : e;
|
|
530
525
|
}
|
|
531
|
-
function
|
|
526
|
+
function De(e, t) {
|
|
532
527
|
return e == null || t === null || t === void 0 ? !1 : String(e) === String(t);
|
|
533
528
|
}
|
|
534
|
-
function
|
|
535
|
-
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) :
|
|
529
|
+
function An(e) {
|
|
530
|
+
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : xt.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : xt.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : xt.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : xt.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : xt.offsetY, s = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : xt.borderRadius;
|
|
536
531
|
return {
|
|
537
|
-
fontFamily: e?.fontFamily ||
|
|
532
|
+
fontFamily: e?.fontFamily || xt.fontFamily,
|
|
538
533
|
fontSize: r,
|
|
539
|
-
fontWeight: e?.fontWeight ||
|
|
540
|
-
textColor: e?.textColor ||
|
|
541
|
-
backgroundColor: e?.backgroundColor ||
|
|
542
|
-
borderColor: e?.borderColor ||
|
|
534
|
+
fontWeight: e?.fontWeight || xt.fontWeight,
|
|
535
|
+
textColor: e?.textColor || xt.textColor,
|
|
536
|
+
backgroundColor: e?.backgroundColor || xt.backgroundColor,
|
|
537
|
+
borderColor: e?.borderColor || xt.borderColor,
|
|
543
538
|
borderWidth: i,
|
|
544
539
|
paddingX: t,
|
|
545
540
|
paddingY: n,
|
|
@@ -547,11 +542,11 @@ function cn(e) {
|
|
|
547
542
|
borderRadius: s
|
|
548
543
|
};
|
|
549
544
|
}
|
|
550
|
-
function
|
|
545
|
+
function Rn(e, t, n, r, i, o) {
|
|
551
546
|
const s = Math.max(0, Math.min(o, r * 0.5, i * 0.5));
|
|
552
547
|
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();
|
|
553
548
|
}
|
|
554
|
-
function
|
|
549
|
+
function Cn(e) {
|
|
555
550
|
if (!e.length) return null;
|
|
556
551
|
let t = 1 / 0;
|
|
557
552
|
for (const i of e)
|
|
@@ -562,37 +557,22 @@ function hn(e) {
|
|
|
562
557
|
Math.abs(i[1] - t) > 0.5 || (i[0] < n && (n = i[0]), i[0] > r && (r = i[0]));
|
|
563
558
|
return !Number.isFinite(n) || !Number.isFinite(r) ? null : [(n + r) * 0.5, t];
|
|
564
559
|
}
|
|
565
|
-
function
|
|
560
|
+
function In(e, t, n, r, i, o) {
|
|
566
561
|
const s = t.trim();
|
|
567
562
|
if (!s) return;
|
|
568
563
|
e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
l * 0.5 + 1,
|
|
572
|
-
r - l * 0.5 - 1
|
|
573
|
-
), p = Zt(
|
|
574
|
-
n[1] - o.offsetY,
|
|
575
|
-
u * 0.5 + 1,
|
|
576
|
-
i - u * 0.5 - 1
|
|
577
|
-
), d = h - l * 0.5, g = p - u * 0.5;
|
|
578
|
-
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, ln(
|
|
579
|
-
e,
|
|
580
|
-
d,
|
|
581
|
-
g,
|
|
582
|
-
l,
|
|
583
|
-
u,
|
|
584
|
-
o.borderRadius
|
|
585
|
-
), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(s, h, p + 0.5), e.restore();
|
|
564
|
+
const c = e.measureText(s).width + o.paddingX * 2, l = o.fontSize + o.paddingY * 2, h = ne(n[0], c * 0.5 + 1, r - c * 0.5 - 1), w = ne(n[1] - o.offsetY, l * 0.5 + 1, i - l * 0.5 - 1), f = h - c * 0.5, m = w - l * 0.5;
|
|
565
|
+
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, Rn(e, f, m, c, l, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(s, h, w + 0.5), e.restore();
|
|
586
566
|
}
|
|
587
|
-
function
|
|
588
|
-
return [
|
|
567
|
+
function ce(e, t, n) {
|
|
568
|
+
return [ne(e[0], 0, t), ne(e[1], 0, n)];
|
|
589
569
|
}
|
|
590
|
-
function
|
|
570
|
+
function ue(e) {
|
|
591
571
|
if (!Array.isArray(e) || e.length < 2) return null;
|
|
592
572
|
const t = Number(e[0]), n = Number(e[1]);
|
|
593
573
|
return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
|
|
594
574
|
}
|
|
595
|
-
function
|
|
575
|
+
function _n({
|
|
596
576
|
tool: e,
|
|
597
577
|
imageWidth: t,
|
|
598
578
|
imageHeight: n,
|
|
@@ -601,48 +581,36 @@ function dn({
|
|
|
601
581
|
stampOptions: o,
|
|
602
582
|
projectorRef: s,
|
|
603
583
|
onDrawComplete: a,
|
|
584
|
+
onPatchComplete: c,
|
|
604
585
|
enabled: l,
|
|
605
|
-
viewStateSignal:
|
|
606
|
-
persistedRegions:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
586
|
+
viewStateSignal: h,
|
|
587
|
+
persistedRegions: w,
|
|
588
|
+
patchRegions: f,
|
|
589
|
+
persistedPolygons: m,
|
|
590
|
+
regionStrokeStyle: y,
|
|
591
|
+
regionStrokeHoverStyle: b,
|
|
592
|
+
regionStrokeActiveStyle: v,
|
|
593
|
+
patchStrokeStyle: S,
|
|
594
|
+
resolveRegionStrokeStyle: L,
|
|
595
|
+
overlayShapes: R,
|
|
596
|
+
hoveredRegionId: W = null,
|
|
597
|
+
activeRegionId: yt = null,
|
|
598
|
+
regionLabelStyle: st,
|
|
599
|
+
invalidateRef: X,
|
|
600
|
+
className: At,
|
|
601
|
+
style: mt
|
|
619
602
|
}) {
|
|
620
|
-
const
|
|
603
|
+
const lt = Z(null), Rt = Z(!1), J = Z(e), rt = Z({
|
|
621
604
|
isDrawing: !1,
|
|
622
605
|
pointerId: null,
|
|
623
606
|
start: null,
|
|
624
607
|
current: null,
|
|
625
608
|
points: [],
|
|
626
609
|
stampCenter: null
|
|
627
|
-
}),
|
|
628
|
-
id:
|
|
629
|
-
coordinates:
|
|
630
|
-
})), [
|
|
631
|
-
() => Fe(d),
|
|
632
|
-
[d]
|
|
633
|
-
), vt = et(
|
|
634
|
-
() => Wt(J, g),
|
|
635
|
-
[J, g]
|
|
636
|
-
), xt = et(
|
|
637
|
-
() => Wt(J, y),
|
|
638
|
-
[J, y]
|
|
639
|
-
), ut = et(
|
|
640
|
-
() => cn(C),
|
|
641
|
-
[C]
|
|
642
|
-
), Tt = et(
|
|
643
|
-
() => sn(o),
|
|
644
|
-
[o]
|
|
645
|
-
), P = et(
|
|
610
|
+
}), V = l ?? e !== "cursor", ht = H(() => w && w.length > 0 ? w : !m || m.length === 0 ? Ce : m.map((u, g) => ({
|
|
611
|
+
id: g,
|
|
612
|
+
coordinates: u
|
|
613
|
+
})), [w, m]), Ct = H(() => f ?? Ce, [f]), at = H(() => $e(y), [y]), x = H(() => Ot(at, b), [at, b]), T = H(() => Ot(at, v), [at, v]), E = H(() => Ot(Mn, S), [S]), k = H(() => An(st), [st]), O = H(() => Pn(o), [o]), gt = H(
|
|
646
614
|
() => ({
|
|
647
615
|
position: "absolute",
|
|
648
616
|
inset: 0,
|
|
@@ -651,324 +619,309 @@ function dn({
|
|
|
651
619
|
height: "100%",
|
|
652
620
|
display: "block",
|
|
653
621
|
touchAction: "none",
|
|
654
|
-
pointerEvents:
|
|
655
|
-
cursor:
|
|
656
|
-
...
|
|
622
|
+
pointerEvents: V ? "auto" : "none",
|
|
623
|
+
cursor: V ? "crosshair" : "default",
|
|
624
|
+
...mt
|
|
657
625
|
}),
|
|
658
|
-
[
|
|
659
|
-
),
|
|
660
|
-
const
|
|
661
|
-
if (!
|
|
662
|
-
const
|
|
663
|
-
(
|
|
664
|
-
}, []),
|
|
665
|
-
(
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
668
|
-
const
|
|
669
|
-
for (let
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (!N) return [];
|
|
674
|
-
S[v] = N;
|
|
626
|
+
[V, mt]
|
|
627
|
+
), tt = D(() => {
|
|
628
|
+
const u = lt.current;
|
|
629
|
+
if (!u) return;
|
|
630
|
+
const g = u.getBoundingClientRect(), M = Math.max(1, window.devicePixelRatio || 1), _ = Math.max(1, Math.round(g.width * M)), A = Math.max(1, Math.round(g.height * M));
|
|
631
|
+
(u.width !== _ || u.height !== A) && (u.width = _, u.height = A);
|
|
632
|
+
}, []), q = D(
|
|
633
|
+
(u) => {
|
|
634
|
+
const g = s.current;
|
|
635
|
+
if (!g || u.length === 0) return [];
|
|
636
|
+
const M = new Array(u.length);
|
|
637
|
+
for (let _ = 0; _ < u.length; _ += 1) {
|
|
638
|
+
const A = ue(g.worldToScreen(u[_][0], u[_][1]));
|
|
639
|
+
if (!A) return [];
|
|
640
|
+
M[_] = A;
|
|
675
641
|
}
|
|
676
|
-
return
|
|
642
|
+
return M;
|
|
677
643
|
},
|
|
678
644
|
[s]
|
|
679
|
-
),
|
|
680
|
-
(
|
|
681
|
-
if (!Number.isFinite(
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
Ie(m, S, T)
|
|
685
|
-
);
|
|
686
|
-
return c / _ / N;
|
|
645
|
+
), et = D(
|
|
646
|
+
(u) => {
|
|
647
|
+
if (!Number.isFinite(u) || u <= 0) return 0;
|
|
648
|
+
const g = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, M = typeof i == "number" && Number.isFinite(i) ? i : 0, _ = s.current?.getViewState?.().zoom, A = typeof _ == "number" && Number.isFinite(_) && _ > 0 ? _ : 1, C = M + Math.log2(A), I = Math.max(1e-9, Ve(g, M, C));
|
|
649
|
+
return u / I / A;
|
|
687
650
|
},
|
|
688
651
|
[r, i, s]
|
|
689
|
-
),
|
|
690
|
-
(
|
|
691
|
-
if (!
|
|
692
|
-
let
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
return
|
|
652
|
+
), ct = D(
|
|
653
|
+
(u, g) => {
|
|
654
|
+
if (!g) return [];
|
|
655
|
+
let M = 0;
|
|
656
|
+
if (u === "stamp-rectangle-4096px") {
|
|
657
|
+
const C = O.rectanglePixelSize * 0.5;
|
|
658
|
+
return _e(g, C).map((G) => ce(G, t, n));
|
|
696
659
|
}
|
|
697
|
-
if (
|
|
698
|
-
const
|
|
699
|
-
let
|
|
700
|
-
if (
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
} else if (
|
|
704
|
-
const
|
|
705
|
-
|
|
660
|
+
if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2" ? M = u === "stamp-rectangle-2mm2" ? Ge : O.rectangleAreaMm2 : (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") && (M = u === "stamp-circle-hpf-0.2mm2" ? vn : u === "stamp-circle-2mm2" ? qe : O.circleAreaMm2), !Number.isFinite(M) || M <= 0) return [];
|
|
661
|
+
const _ = Sn(M);
|
|
662
|
+
let A = [];
|
|
663
|
+
if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2") {
|
|
664
|
+
const C = et(Math.sqrt(_) * 0.5);
|
|
665
|
+
A = _e(g, C);
|
|
666
|
+
} else if (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") {
|
|
667
|
+
const C = et(Math.sqrt(_ / Math.PI));
|
|
668
|
+
A = En(g, C);
|
|
706
669
|
}
|
|
707
|
-
return
|
|
670
|
+
return A.length ? A.map((C) => ce(C, t, n)) : [];
|
|
708
671
|
},
|
|
709
|
-
[
|
|
710
|
-
),
|
|
711
|
-
const
|
|
712
|
-
return
|
|
713
|
-
}, [e,
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
if (!
|
|
717
|
-
const
|
|
718
|
-
if (!
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
for (let
|
|
722
|
-
const
|
|
672
|
+
[et, t, n, O]
|
|
673
|
+
), ut = D(() => {
|
|
674
|
+
const u = rt.current;
|
|
675
|
+
return Zt(e) ? ct(e, u.stampCenter) : u.isDrawing ? e === "freehand" ? u.points : e === "rectangle" ? Be(u.start, u.current) : e === "circular" ? Ue(u.start, u.current) : [] : [];
|
|
676
|
+
}, [e, ct]), U = D(() => {
|
|
677
|
+
tt();
|
|
678
|
+
const u = lt.current;
|
|
679
|
+
if (!u) return;
|
|
680
|
+
const g = u.getContext("2d");
|
|
681
|
+
if (!g) return;
|
|
682
|
+
const M = Math.max(1, window.devicePixelRatio || 1), _ = u.width / M, A = u.height / M;
|
|
683
|
+
if (g.setTransform(1, 0, 0, 1, 0, 0), g.clearRect(0, 0, u.width, u.height), g.setTransform(M, 0, 0, M, 0, 0), ht.length > 0)
|
|
684
|
+
for (let C = 0; C < ht.length; C += 1) {
|
|
685
|
+
const I = ht[C], G = I?.coordinates;
|
|
723
686
|
if (!G || G.length < 3) continue;
|
|
724
|
-
const
|
|
725
|
-
if (
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
regionId: Rt,
|
|
735
|
-
regionIndex: T,
|
|
736
|
-
state: j
|
|
687
|
+
const it = Pt(G), ot = q(it);
|
|
688
|
+
if (ot.length >= 4) {
|
|
689
|
+
const St = I.id ?? C, It = De(yt, St) ? "active" : De(W, St) ? "hover" : "default";
|
|
690
|
+
let Vt = It === "active" ? T : It === "hover" ? x : at;
|
|
691
|
+
if (L) {
|
|
692
|
+
const ie = L({
|
|
693
|
+
region: I,
|
|
694
|
+
regionId: St,
|
|
695
|
+
regionIndex: C,
|
|
696
|
+
state: It
|
|
737
697
|
});
|
|
738
|
-
|
|
698
|
+
Vt = Ot(Vt, ie || void 0);
|
|
739
699
|
}
|
|
740
|
-
|
|
700
|
+
Wt(g, ot, Vt, !0, !1);
|
|
741
701
|
}
|
|
742
702
|
}
|
|
743
|
-
if (
|
|
744
|
-
for (let
|
|
745
|
-
const
|
|
746
|
-
if (!
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
const Rt = Wt(
|
|
750
|
-
J,
|
|
751
|
-
_.strokeStyle
|
|
752
|
-
);
|
|
753
|
-
Dt(m, dt, Rt, G, _.fill ?? !1);
|
|
703
|
+
if (Ct.length > 0)
|
|
704
|
+
for (let C = 0; C < Ct.length; C += 1) {
|
|
705
|
+
const G = Ct[C]?.coordinates;
|
|
706
|
+
if (!G || G.length < 3) continue;
|
|
707
|
+
const it = Pt(G), ot = q(it);
|
|
708
|
+
ot.length < 4 || Wt(g, ot, E, !0, !1);
|
|
754
709
|
}
|
|
755
|
-
if (
|
|
756
|
-
|
|
757
|
-
|
|
710
|
+
if (Array.isArray(R) && R.length > 0)
|
|
711
|
+
for (let C = 0; C < R.length; C += 1) {
|
|
712
|
+
const I = R[C];
|
|
713
|
+
if (!I?.coordinates?.length) continue;
|
|
714
|
+
const G = I.closed ?? !1, it = G ? Pt(I.coordinates) : I.coordinates, ot = q(it);
|
|
715
|
+
if (ot.length < 2) continue;
|
|
716
|
+
const St = Ot(at, I.strokeStyle);
|
|
717
|
+
Wt(g, ot, St, G, I.fill ?? !1);
|
|
718
|
+
}
|
|
719
|
+
if (V) {
|
|
720
|
+
const C = ut();
|
|
721
|
+
if (C.length > 0)
|
|
758
722
|
if (e === "freehand") {
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
m,
|
|
762
|
-
M(St(T)),
|
|
763
|
-
J,
|
|
764
|
-
!0,
|
|
765
|
-
!0
|
|
766
|
-
);
|
|
723
|
+
const I = q(C);
|
|
724
|
+
I.length >= 2 && Wt(g, I, at, !1, !1), I.length >= 3 && Wt(g, q(Pt(C)), at, !0, !0);
|
|
767
725
|
} else {
|
|
768
|
-
const
|
|
769
|
-
|
|
726
|
+
const I = q(C);
|
|
727
|
+
I.length >= 4 && Wt(g, I, at, !0, !0);
|
|
770
728
|
}
|
|
771
729
|
}
|
|
772
|
-
if (
|
|
773
|
-
for (const
|
|
774
|
-
if (!
|
|
775
|
-
const
|
|
776
|
-
if (!
|
|
777
|
-
const G =
|
|
778
|
-
if (!
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
);
|
|
782
|
-
dt && fn(
|
|
783
|
-
m,
|
|
784
|
-
T.label,
|
|
785
|
-
dt,
|
|
786
|
-
v,
|
|
787
|
-
N,
|
|
788
|
-
ut
|
|
789
|
-
);
|
|
730
|
+
if (ht.length > 0)
|
|
731
|
+
for (const C of ht) {
|
|
732
|
+
if (!C.label) continue;
|
|
733
|
+
const I = C?.coordinates;
|
|
734
|
+
if (!I || I.length < 3) continue;
|
|
735
|
+
const G = Pt(I), it = Cn(G);
|
|
736
|
+
if (!it) continue;
|
|
737
|
+
const ot = ue(s.current?.worldToScreen(it[0], it[1]) ?? []);
|
|
738
|
+
ot && In(g, C.label, ot, _, A, k);
|
|
790
739
|
}
|
|
791
740
|
}, [
|
|
792
|
-
|
|
741
|
+
V,
|
|
793
742
|
e,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
743
|
+
ut,
|
|
744
|
+
tt,
|
|
745
|
+
q,
|
|
797
746
|
s,
|
|
798
|
-
|
|
747
|
+
ht,
|
|
748
|
+
R,
|
|
749
|
+
W,
|
|
750
|
+
yt,
|
|
751
|
+
at,
|
|
799
752
|
x,
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
yt.current || (yt.current = !0, requestAnimationFrame(() => {
|
|
809
|
-
yt.current = !1, ot();
|
|
753
|
+
T,
|
|
754
|
+
Ct,
|
|
755
|
+
E,
|
|
756
|
+
L,
|
|
757
|
+
k
|
|
758
|
+
]), P = D(() => {
|
|
759
|
+
Rt.current || (Rt.current = !0, requestAnimationFrame(() => {
|
|
760
|
+
Rt.current = !1, U();
|
|
810
761
|
}));
|
|
811
|
-
}, [
|
|
812
|
-
const
|
|
813
|
-
if (
|
|
762
|
+
}, [U]), Y = D(() => {
|
|
763
|
+
const u = rt.current, g = lt.current;
|
|
764
|
+
if (g && u.pointerId !== null && g.hasPointerCapture(u.pointerId))
|
|
814
765
|
try {
|
|
815
|
-
|
|
766
|
+
g.releasePointerCapture(u.pointerId);
|
|
816
767
|
} catch {
|
|
817
768
|
}
|
|
818
|
-
|
|
819
|
-
}, []),
|
|
820
|
-
(
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
);
|
|
826
|
-
return S ? te(S, t, n) : null;
|
|
769
|
+
u.isDrawing = !1, u.pointerId = null, u.start = null, u.current = null, u.points = [], u.stampCenter = null;
|
|
770
|
+
}, []), $ = D(
|
|
771
|
+
(u) => {
|
|
772
|
+
const g = s.current;
|
|
773
|
+
if (!g || t <= 0 || n <= 0) return null;
|
|
774
|
+
const M = ue(g.screenToWorld(u.clientX, u.clientY));
|
|
775
|
+
return M ? ce(M, t, n) : null;
|
|
827
776
|
},
|
|
828
777
|
[s, t, n]
|
|
829
|
-
),
|
|
830
|
-
const
|
|
831
|
-
if (!
|
|
832
|
-
|
|
778
|
+
), Q = D(() => {
|
|
779
|
+
const u = rt.current;
|
|
780
|
+
if (!u.isDrawing) {
|
|
781
|
+
Y(), P();
|
|
833
782
|
return;
|
|
834
783
|
}
|
|
835
|
-
let
|
|
836
|
-
e === "freehand" ?
|
|
784
|
+
let g = [];
|
|
785
|
+
e === "freehand" ? u.points.length >= bn && (g = Pt(u.points)) : e === "rectangle" ? g = Be(u.start, u.current) : e === "circular" && (g = Ue(u.start, u.current)), (e === "freehand" || e === "rectangle" || e === "circular") && Le(g) && a && a({
|
|
837
786
|
tool: e,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
787
|
+
intent: "roi",
|
|
788
|
+
coordinates: g,
|
|
789
|
+
bbox: Fe(g),
|
|
790
|
+
areaPx: me(g)
|
|
791
|
+
}), Y(), P();
|
|
792
|
+
}, [e, a, Y, P]), dt = D(
|
|
793
|
+
(u, g) => {
|
|
794
|
+
const M = ct(u, g);
|
|
795
|
+
if (!Le(M)) return;
|
|
796
|
+
const _ = u === "stamp-rectangle-4096px" ? "patch" : "roi", A = {
|
|
797
|
+
tool: u,
|
|
798
|
+
intent: _,
|
|
799
|
+
coordinates: M,
|
|
800
|
+
bbox: Fe(M),
|
|
801
|
+
areaPx: me(M)
|
|
802
|
+
};
|
|
803
|
+
a?.(A), _ === "patch" && c && c(A);
|
|
851
804
|
},
|
|
852
|
-
[
|
|
853
|
-
),
|
|
854
|
-
(
|
|
855
|
-
if (!
|
|
856
|
-
const
|
|
857
|
-
if (!
|
|
858
|
-
if (
|
|
859
|
-
const
|
|
860
|
-
|
|
805
|
+
[ct, a, c]
|
|
806
|
+
), Lt = D(
|
|
807
|
+
(u) => {
|
|
808
|
+
if (!V || e === "cursor" || u.button !== 0) return;
|
|
809
|
+
const g = $(u);
|
|
810
|
+
if (!g) return;
|
|
811
|
+
if (u.preventDefault(), u.stopPropagation(), Zt(e)) {
|
|
812
|
+
const A = rt.current;
|
|
813
|
+
A.stampCenter = g, dt(e, g), P();
|
|
861
814
|
return;
|
|
862
815
|
}
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
|
|
816
|
+
const M = lt.current;
|
|
817
|
+
M && M.setPointerCapture(u.pointerId);
|
|
818
|
+
const _ = rt.current;
|
|
819
|
+
_.isDrawing = !0, _.pointerId = u.pointerId, _.start = g, _.current = g, _.points = e === "freehand" ? [g] : [], P();
|
|
867
820
|
},
|
|
868
|
-
[
|
|
869
|
-
),
|
|
870
|
-
(
|
|
871
|
-
if (!
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
874
|
-
if (
|
|
875
|
-
const
|
|
876
|
-
|
|
821
|
+
[V, e, $, dt, P]
|
|
822
|
+
), Tt = D(
|
|
823
|
+
(u) => {
|
|
824
|
+
if (!V || e === "cursor") return;
|
|
825
|
+
const g = $(u);
|
|
826
|
+
if (!g) return;
|
|
827
|
+
if (Zt(e)) {
|
|
828
|
+
const _ = rt.current;
|
|
829
|
+
_.stampCenter = g, u.preventDefault(), u.stopPropagation(), P();
|
|
877
830
|
return;
|
|
878
831
|
}
|
|
879
|
-
const
|
|
880
|
-
if (!(!
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
832
|
+
const M = rt.current;
|
|
833
|
+
if (!(!M.isDrawing || M.pointerId !== u.pointerId)) {
|
|
834
|
+
if (u.preventDefault(), u.stopPropagation(), e === "freehand") {
|
|
835
|
+
const _ = s.current, A = Math.max(1e-6, _?.getViewState?.().zoom ?? 1), C = yn / A, I = C * C, G = M.points[M.points.length - 1];
|
|
883
836
|
if (!G)
|
|
884
|
-
|
|
837
|
+
M.points.push(g);
|
|
885
838
|
else {
|
|
886
|
-
const
|
|
887
|
-
|
|
839
|
+
const it = g[0] - G[0], ot = g[1] - G[1];
|
|
840
|
+
it * it + ot * ot >= I && M.points.push(g);
|
|
888
841
|
}
|
|
889
842
|
} else
|
|
890
|
-
|
|
891
|
-
|
|
843
|
+
M.current = g;
|
|
844
|
+
P();
|
|
892
845
|
}
|
|
893
846
|
},
|
|
894
|
-
[
|
|
895
|
-
),
|
|
896
|
-
(
|
|
897
|
-
const
|
|
898
|
-
if (!
|
|
899
|
-
|
|
900
|
-
const
|
|
901
|
-
if (
|
|
847
|
+
[V, e, $, P, s]
|
|
848
|
+
), vt = D(
|
|
849
|
+
(u) => {
|
|
850
|
+
const g = rt.current;
|
|
851
|
+
if (!g.isDrawing || g.pointerId !== u.pointerId) return;
|
|
852
|
+
u.preventDefault(), u.stopPropagation();
|
|
853
|
+
const M = lt.current;
|
|
854
|
+
if (M && M.hasPointerCapture(u.pointerId))
|
|
902
855
|
try {
|
|
903
|
-
|
|
856
|
+
M.releasePointerCapture(u.pointerId);
|
|
904
857
|
} catch {
|
|
905
858
|
}
|
|
906
|
-
|
|
859
|
+
Q();
|
|
907
860
|
},
|
|
908
|
-
[
|
|
909
|
-
),
|
|
910
|
-
if (!
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
}, [e,
|
|
914
|
-
return
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
if (!
|
|
918
|
-
const
|
|
919
|
-
|
|
861
|
+
[Q]
|
|
862
|
+
), bt = D(() => {
|
|
863
|
+
if (!Zt(e)) return;
|
|
864
|
+
const u = rt.current;
|
|
865
|
+
u.stampCenter && (u.stampCenter = null, P());
|
|
866
|
+
}, [e, P]);
|
|
867
|
+
return z(() => {
|
|
868
|
+
tt(), P();
|
|
869
|
+
const u = lt.current;
|
|
870
|
+
if (!u) return;
|
|
871
|
+
const g = new ResizeObserver(() => {
|
|
872
|
+
tt(), P();
|
|
920
873
|
});
|
|
921
|
-
return
|
|
922
|
-
|
|
874
|
+
return g.observe(u), () => {
|
|
875
|
+
g.disconnect();
|
|
923
876
|
};
|
|
924
|
-
}, [
|
|
925
|
-
|
|
926
|
-
}, [
|
|
927
|
-
|
|
928
|
-
}, [e,
|
|
929
|
-
|
|
930
|
-
}, [
|
|
931
|
-
if (
|
|
932
|
-
return
|
|
933
|
-
|
|
877
|
+
}, [tt, P]), z(() => {
|
|
878
|
+
V || Y(), P();
|
|
879
|
+
}, [V, P, Y]), z(() => {
|
|
880
|
+
J.current !== e && (J.current = e, Y(), P());
|
|
881
|
+
}, [e, Y, P]), z(() => {
|
|
882
|
+
P();
|
|
883
|
+
}, [h, ht, R, P]), z(() => {
|
|
884
|
+
if (X)
|
|
885
|
+
return X.current = P, () => {
|
|
886
|
+
X.current === P && (X.current = null);
|
|
934
887
|
};
|
|
935
|
-
}, [
|
|
936
|
-
if (!
|
|
937
|
-
const
|
|
938
|
-
|
|
888
|
+
}, [X, P]), z(() => {
|
|
889
|
+
if (!V) return;
|
|
890
|
+
const u = (g) => {
|
|
891
|
+
g.key === "Escape" && (Y(), P());
|
|
939
892
|
};
|
|
940
|
-
return window.addEventListener("keydown",
|
|
941
|
-
window.removeEventListener("keydown",
|
|
893
|
+
return window.addEventListener("keydown", u), () => {
|
|
894
|
+
window.removeEventListener("keydown", u);
|
|
942
895
|
};
|
|
943
|
-
}, [
|
|
896
|
+
}, [V, Y, P]), /* @__PURE__ */ Mt(
|
|
944
897
|
"canvas",
|
|
945
898
|
{
|
|
946
|
-
ref:
|
|
947
|
-
className:
|
|
948
|
-
style:
|
|
949
|
-
onPointerDown:
|
|
950
|
-
onPointerMove:
|
|
951
|
-
onPointerUp:
|
|
952
|
-
onPointerCancel:
|
|
953
|
-
onPointerLeave:
|
|
954
|
-
onContextMenu: (
|
|
955
|
-
|
|
899
|
+
ref: lt,
|
|
900
|
+
className: At,
|
|
901
|
+
style: gt,
|
|
902
|
+
onPointerDown: Lt,
|
|
903
|
+
onPointerMove: Tt,
|
|
904
|
+
onPointerUp: vt,
|
|
905
|
+
onPointerCancel: vt,
|
|
906
|
+
onPointerLeave: bt,
|
|
907
|
+
onContextMenu: (u) => {
|
|
908
|
+
V && u.preventDefault();
|
|
956
909
|
},
|
|
957
|
-
onWheel: (
|
|
958
|
-
|
|
910
|
+
onWheel: (u) => {
|
|
911
|
+
V && u.preventDefault();
|
|
959
912
|
}
|
|
960
913
|
}
|
|
961
914
|
);
|
|
962
915
|
}
|
|
963
|
-
function
|
|
916
|
+
function Ne(e) {
|
|
964
917
|
return String(e ?? "").replace(/\/+$/, "");
|
|
965
918
|
}
|
|
966
|
-
function
|
|
919
|
+
function He(e) {
|
|
967
920
|
const t = String(e ?? "");
|
|
968
921
|
return t.startsWith("/") ? t : `/${t}`;
|
|
969
922
|
}
|
|
970
|
-
function
|
|
971
|
-
const t =
|
|
923
|
+
function Bn(e) {
|
|
924
|
+
const t = Ne(e);
|
|
972
925
|
if (!t) return "";
|
|
973
926
|
if (/\/TileGroup\d+$/i.test(t)) return t;
|
|
974
927
|
let n = null;
|
|
@@ -978,41 +931,41 @@ function mn(e) {
|
|
|
978
931
|
n = null;
|
|
979
932
|
}
|
|
980
933
|
if (n) {
|
|
981
|
-
const r = `${n.protocol}//${n.host}`, i =
|
|
934
|
+
const r = `${n.protocol}//${n.host}`, i = Ne(n.pathname || "");
|
|
982
935
|
return /\/ims$/i.test(i) ? `${r}${i}` : /\/tiles$/i.test(i) ? `${r}${i}` : `${r}${i}/tiles`;
|
|
983
936
|
}
|
|
984
937
|
return /\/ims$/i.test(t) ? "/ims" : /\/tiles$/i.test(t) ? `${t}` : `${t}/tiles`;
|
|
985
938
|
}
|
|
986
|
-
function
|
|
987
|
-
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),
|
|
988
|
-
if (!i || !o || !s || !
|
|
939
|
+
function wr(e, t) {
|
|
940
|
+
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), c = String(n.path ?? e?.path ?? ""), l = Number(n.mpp ?? e?.mpp ?? 0);
|
|
941
|
+
if (!i || !o || !s || !c)
|
|
989
942
|
throw new Error("이미지 메타데이터가 불완전합니다. width/height/tileSize/path 확인 필요");
|
|
990
943
|
const h = Array.isArray(e?.terms) ? e.terms.map((y) => ({
|
|
991
944
|
termId: String(y?.termId ?? ""),
|
|
992
945
|
termName: String(y?.termName ?? ""),
|
|
993
946
|
termColor: String(y?.termColor ?? "")
|
|
994
|
-
})) : [],
|
|
947
|
+
})) : [], w = He(c), f = Bn(t), m = r ? (y, b, v) => `${f}${w}/${y}/${v}_${b}.webp` : void 0;
|
|
995
948
|
return {
|
|
996
949
|
id: e?._id || "unknown",
|
|
997
950
|
name: e?.name || "unknown",
|
|
998
951
|
width: i,
|
|
999
952
|
height: o,
|
|
1000
|
-
mpp: Number.isFinite(
|
|
953
|
+
mpp: Number.isFinite(l) && l > 0 ? l : void 0,
|
|
1001
954
|
tileSize: s,
|
|
1002
955
|
maxTierZoom: Number.isFinite(a) ? Math.max(0, Math.floor(a)) : 0,
|
|
1003
|
-
tilePath:
|
|
956
|
+
tilePath: c,
|
|
1004
957
|
tileBaseUrl: t,
|
|
1005
958
|
terms: h,
|
|
1006
|
-
tileUrlBuilder:
|
|
959
|
+
tileUrlBuilder: m
|
|
1007
960
|
};
|
|
1008
961
|
}
|
|
1009
|
-
function
|
|
962
|
+
function Ze(e, t, n, r) {
|
|
1010
963
|
if (e.tileUrlBuilder)
|
|
1011
964
|
return e.tileUrlBuilder(t, n, r);
|
|
1012
|
-
const i =
|
|
965
|
+
const i = He(e.tilePath);
|
|
1013
966
|
return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
|
|
1014
967
|
}
|
|
1015
|
-
const
|
|
968
|
+
const pt = {
|
|
1016
969
|
width: 220,
|
|
1017
970
|
height: 140,
|
|
1018
971
|
margin: 16,
|
|
@@ -1027,13 +980,13 @@ const mt = {
|
|
|
1027
980
|
showThumbnail: !0,
|
|
1028
981
|
maxThumbnailTiles: 16
|
|
1029
982
|
};
|
|
1030
|
-
function
|
|
983
|
+
function Xt(e, t, n = 1) {
|
|
1031
984
|
return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
|
|
1032
985
|
}
|
|
1033
|
-
function
|
|
986
|
+
function Kt(e) {
|
|
1034
987
|
return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
|
|
1035
988
|
}
|
|
1036
|
-
function
|
|
989
|
+
function Un({
|
|
1037
990
|
source: e,
|
|
1038
991
|
projectorRef: t,
|
|
1039
992
|
authToken: n = "",
|
|
@@ -1042,253 +995,253 @@ function gn({
|
|
|
1042
995
|
className: o,
|
|
1043
996
|
style: s
|
|
1044
997
|
}) {
|
|
1045
|
-
const a =
|
|
998
|
+
const a = Z(null), c = Z(null), l = Z(null), h = Z({
|
|
1046
999
|
active: !1,
|
|
1047
1000
|
pointerId: null
|
|
1048
|
-
}),
|
|
1001
|
+
}), w = Z(null), f = Z(!1), m = Xt(
|
|
1049
1002
|
r?.width,
|
|
1050
|
-
|
|
1003
|
+
pt.width,
|
|
1051
1004
|
64
|
|
1052
|
-
), y =
|
|
1005
|
+
), y = Xt(
|
|
1053
1006
|
r?.height,
|
|
1054
|
-
|
|
1007
|
+
pt.height,
|
|
1055
1008
|
48
|
|
1056
|
-
), b =
|
|
1009
|
+
), b = Xt(
|
|
1057
1010
|
r?.margin,
|
|
1058
|
-
|
|
1011
|
+
pt.margin,
|
|
1059
1012
|
0
|
|
1060
|
-
),
|
|
1013
|
+
), v = Xt(
|
|
1061
1014
|
r?.borderRadius,
|
|
1062
|
-
|
|
1015
|
+
pt.borderRadius,
|
|
1063
1016
|
0
|
|
1064
|
-
),
|
|
1017
|
+
), S = Xt(
|
|
1065
1018
|
r?.borderWidth,
|
|
1066
|
-
|
|
1019
|
+
pt.borderWidth,
|
|
1067
1020
|
0
|
|
1068
|
-
),
|
|
1021
|
+
), L = Math.max(
|
|
1069
1022
|
1,
|
|
1070
1023
|
Math.round(
|
|
1071
|
-
|
|
1024
|
+
Xt(
|
|
1072
1025
|
r?.maxThumbnailTiles,
|
|
1073
|
-
|
|
1026
|
+
pt.maxThumbnailTiles,
|
|
1074
1027
|
1
|
|
1075
1028
|
)
|
|
1076
1029
|
)
|
|
1077
|
-
),
|
|
1078
|
-
const
|
|
1079
|
-
return
|
|
1030
|
+
), R = r?.backgroundColor || pt.backgroundColor, W = r?.borderColor || pt.borderColor, yt = r?.viewportStrokeColor || pt.viewportStrokeColor, st = r?.viewportFillColor || pt.viewportFillColor, X = r?.interactive ?? pt.interactive, At = r?.showThumbnail ?? pt.showThumbnail, mt = r?.position || pt.position, lt = H(() => {
|
|
1031
|
+
const x = {};
|
|
1032
|
+
return mt === "top-left" || mt === "bottom-left" ? x.left = b : x.right = b, mt === "top-left" || mt === "top-right" ? x.top = b : x.bottom = b, {
|
|
1080
1033
|
position: "absolute",
|
|
1081
|
-
...
|
|
1082
|
-
width:
|
|
1034
|
+
...x,
|
|
1035
|
+
width: m,
|
|
1083
1036
|
height: y,
|
|
1084
|
-
borderRadius:
|
|
1037
|
+
borderRadius: v,
|
|
1085
1038
|
overflow: "hidden",
|
|
1086
1039
|
zIndex: 4,
|
|
1087
|
-
pointerEvents:
|
|
1040
|
+
pointerEvents: X ? "auto" : "none",
|
|
1088
1041
|
touchAction: "none",
|
|
1089
1042
|
boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
|
|
1090
1043
|
...s
|
|
1091
1044
|
};
|
|
1092
|
-
}, [b,
|
|
1093
|
-
const
|
|
1094
|
-
if (!
|
|
1095
|
-
const
|
|
1096
|
-
if (!
|
|
1097
|
-
const
|
|
1098
|
-
(
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1045
|
+
}, [b, mt, m, y, v, X, s]), Rt = D(() => {
|
|
1046
|
+
const x = a.current;
|
|
1047
|
+
if (!x) return;
|
|
1048
|
+
const T = x.getContext("2d");
|
|
1049
|
+
if (!T) return;
|
|
1050
|
+
const E = m, k = y, O = Math.max(1, window.devicePixelRatio || 1), gt = Math.max(1, Math.round(E * O)), tt = Math.max(1, Math.round(k * O));
|
|
1051
|
+
(x.width !== gt || x.height !== tt) && (x.width = gt, x.height = tt), T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, x.width, x.height), T.setTransform(O, 0, 0, O, 0, 0), T.fillStyle = R, T.fillRect(0, 0, E, k);
|
|
1052
|
+
const q = c.current;
|
|
1053
|
+
q && T.drawImage(q, 0, 0, E, k), T.strokeStyle = W, T.lineWidth = S, T.strokeRect(
|
|
1054
|
+
S * 0.5,
|
|
1055
|
+
S * 0.5,
|
|
1056
|
+
E - S,
|
|
1057
|
+
k - S
|
|
1105
1058
|
);
|
|
1106
|
-
const
|
|
1107
|
-
if (!
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1110
|
-
(
|
|
1111
|
-
) ?
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1114
|
-
for (let
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1059
|
+
const et = t.current, ct = et?.getViewBounds?.(), ut = et?.getViewCorners?.(), U = Kt(ct) ? ct : Kt(l.current) ? l.current : null;
|
|
1060
|
+
if (!U) return;
|
|
1061
|
+
l.current = U;
|
|
1062
|
+
const P = E / Math.max(1, e.width), Y = k / Math.max(1, e.height), $ = Array.isArray(ut) && ut.length >= 4 && ut.every(
|
|
1063
|
+
(u) => Array.isArray(u) && u.length >= 2 && Number.isFinite(u[0]) && Number.isFinite(u[1])
|
|
1064
|
+
) ? ut : null;
|
|
1065
|
+
if ($) {
|
|
1066
|
+
T.beginPath();
|
|
1067
|
+
for (let u = 0; u < $.length; u += 1) {
|
|
1068
|
+
const g = $[u], M = j(g[0] * P, 0, E), _ = j(g[1] * Y, 0, k);
|
|
1069
|
+
u === 0 ? T.moveTo(M, _) : T.lineTo(M, _);
|
|
1117
1070
|
}
|
|
1118
|
-
|
|
1071
|
+
T.closePath(), T.fillStyle = st, T.fill(), T.strokeStyle = yt, T.lineWidth = 1.5, T.stroke();
|
|
1119
1072
|
return;
|
|
1120
1073
|
}
|
|
1121
|
-
const Q =
|
|
1122
|
-
|
|
1074
|
+
const Q = j(U[0] * P, 0, E), dt = j(U[1] * Y, 0, k), Lt = j(U[2] * P, 0, E), Tt = j(U[3] * Y, 0, k), vt = Math.max(1, Lt - Q), bt = Math.max(1, Tt - dt);
|
|
1075
|
+
T.fillStyle = st, T.fillRect(Q, dt, vt, bt), T.strokeStyle = yt, T.lineWidth = 1.5, T.strokeRect(
|
|
1123
1076
|
Q + 0.5,
|
|
1124
|
-
|
|
1125
|
-
Math.max(1,
|
|
1126
|
-
Math.max(1,
|
|
1077
|
+
dt + 0.5,
|
|
1078
|
+
Math.max(1, vt - 1),
|
|
1079
|
+
Math.max(1, bt - 1)
|
|
1127
1080
|
);
|
|
1128
1081
|
}, [
|
|
1129
|
-
|
|
1082
|
+
m,
|
|
1130
1083
|
y,
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1084
|
+
R,
|
|
1085
|
+
W,
|
|
1086
|
+
S,
|
|
1134
1087
|
t,
|
|
1135
1088
|
e.width,
|
|
1136
1089
|
e.height,
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
]),
|
|
1140
|
-
|
|
1141
|
-
|
|
1090
|
+
st,
|
|
1091
|
+
yt
|
|
1092
|
+
]), J = D(() => {
|
|
1093
|
+
f.current || (f.current = !0, w.current = requestAnimationFrame(() => {
|
|
1094
|
+
f.current = !1, w.current = null, Rt();
|
|
1142
1095
|
}));
|
|
1143
|
-
}, [
|
|
1144
|
-
(
|
|
1145
|
-
const
|
|
1146
|
-
if (!
|
|
1147
|
-
const
|
|
1148
|
-
if (!
|
|
1149
|
-
const O =
|
|
1150
|
-
return [O * e.width,
|
|
1096
|
+
}, [Rt]), rt = D(
|
|
1097
|
+
(x, T) => {
|
|
1098
|
+
const E = a.current;
|
|
1099
|
+
if (!E) return null;
|
|
1100
|
+
const k = E.getBoundingClientRect();
|
|
1101
|
+
if (!k.width || !k.height) return null;
|
|
1102
|
+
const O = j((x - k.left) / k.width, 0, 1), gt = j((T - k.top) / k.height, 0, 1);
|
|
1103
|
+
return [O * e.width, gt * e.height];
|
|
1151
1104
|
},
|
|
1152
1105
|
[e.width, e.height]
|
|
1153
|
-
),
|
|
1154
|
-
(
|
|
1155
|
-
const
|
|
1156
|
-
if (!
|
|
1157
|
-
if (
|
|
1158
|
-
|
|
1106
|
+
), V = D(
|
|
1107
|
+
(x, T) => {
|
|
1108
|
+
const E = t.current;
|
|
1109
|
+
if (!E) return;
|
|
1110
|
+
if (E.setViewCenter) {
|
|
1111
|
+
E.setViewCenter(x, T), J();
|
|
1159
1112
|
return;
|
|
1160
1113
|
}
|
|
1161
|
-
const
|
|
1114
|
+
const k = E.getViewBounds?.(), O = Kt(k) ? k : Kt(l.current) ? l.current : null;
|
|
1162
1115
|
if (!O) return;
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
offsetX:
|
|
1166
|
-
offsetY:
|
|
1167
|
-
}),
|
|
1116
|
+
const gt = Math.max(1e-6, O[2] - O[0]), tt = Math.max(1e-6, O[3] - O[1]);
|
|
1117
|
+
E.setViewState({
|
|
1118
|
+
offsetX: x - gt * 0.5,
|
|
1119
|
+
offsetY: T - tt * 0.5
|
|
1120
|
+
}), J();
|
|
1168
1121
|
},
|
|
1169
|
-
[t,
|
|
1170
|
-
),
|
|
1171
|
-
(
|
|
1172
|
-
if (!
|
|
1173
|
-
const
|
|
1174
|
-
if (!
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1122
|
+
[t, J]
|
|
1123
|
+
), ht = D(
|
|
1124
|
+
(x) => {
|
|
1125
|
+
if (!X || x.button !== 0) return;
|
|
1126
|
+
const T = a.current;
|
|
1127
|
+
if (!T) return;
|
|
1128
|
+
const E = rt(x.clientX, x.clientY);
|
|
1129
|
+
E && (x.preventDefault(), x.stopPropagation(), T.setPointerCapture(x.pointerId), h.current = { active: !0, pointerId: x.pointerId }, V(E[0], E[1]));
|
|
1177
1130
|
},
|
|
1178
|
-
[
|
|
1179
|
-
),
|
|
1180
|
-
(
|
|
1181
|
-
const
|
|
1182
|
-
if (!
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1131
|
+
[X, rt, V]
|
|
1132
|
+
), Ct = D(
|
|
1133
|
+
(x) => {
|
|
1134
|
+
const T = h.current;
|
|
1135
|
+
if (!T.active || T.pointerId !== x.pointerId) return;
|
|
1136
|
+
const E = rt(x.clientX, x.clientY);
|
|
1137
|
+
E && (x.preventDefault(), x.stopPropagation(), V(E[0], E[1]));
|
|
1185
1138
|
},
|
|
1186
|
-
[
|
|
1187
|
-
),
|
|
1188
|
-
(
|
|
1189
|
-
const
|
|
1190
|
-
if (!
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1139
|
+
[rt, V]
|
|
1140
|
+
), at = D(
|
|
1141
|
+
(x) => {
|
|
1142
|
+
const T = h.current;
|
|
1143
|
+
if (!T.active || T.pointerId !== x.pointerId) return;
|
|
1144
|
+
const E = a.current;
|
|
1145
|
+
if (E && E.hasPointerCapture(x.pointerId))
|
|
1193
1146
|
try {
|
|
1194
|
-
|
|
1147
|
+
E.releasePointerCapture(x.pointerId);
|
|
1195
1148
|
} catch {
|
|
1196
1149
|
}
|
|
1197
|
-
h.current = { active: !1, pointerId: null },
|
|
1150
|
+
h.current = { active: !1, pointerId: null }, J();
|
|
1198
1151
|
},
|
|
1199
|
-
[
|
|
1152
|
+
[J]
|
|
1200
1153
|
);
|
|
1201
|
-
return
|
|
1202
|
-
let
|
|
1203
|
-
|
|
1204
|
-
const
|
|
1205
|
-
if (!
|
|
1154
|
+
return z(() => {
|
|
1155
|
+
let x = !1;
|
|
1156
|
+
c.current = null, J();
|
|
1157
|
+
const T = 0, E = 2 ** (e.maxTierZoom - T), k = Math.ceil(e.width / E), O = Math.ceil(e.height / E), gt = Math.max(1, Math.ceil(k / e.tileSize)), tt = Math.max(1, Math.ceil(O / e.tileSize)), q = gt * tt;
|
|
1158
|
+
if (!At || q > L)
|
|
1206
1159
|
return;
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
1160
|
+
const et = document.createElement("canvas");
|
|
1161
|
+
et.width = Math.max(1, Math.round(m)), et.height = Math.max(1, Math.round(y));
|
|
1162
|
+
const ct = et.getContext("2d");
|
|
1163
|
+
if (!ct)
|
|
1211
1164
|
return;
|
|
1212
|
-
|
|
1213
|
-
const
|
|
1214
|
-
for (let
|
|
1215
|
-
for (let
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
url:
|
|
1219
|
-
bounds: [
|
|
1165
|
+
ct.fillStyle = R, ct.fillRect(0, 0, et.width, et.height);
|
|
1166
|
+
const ut = [];
|
|
1167
|
+
for (let U = 0; U < tt; U += 1)
|
|
1168
|
+
for (let P = 0; P < gt; P += 1) {
|
|
1169
|
+
const Y = P * e.tileSize * E, $ = U * e.tileSize * E, Q = Math.min((P + 1) * e.tileSize, k) * E, dt = Math.min((U + 1) * e.tileSize, O) * E;
|
|
1170
|
+
ut.push({
|
|
1171
|
+
url: Ze(e, T, P, U),
|
|
1172
|
+
bounds: [Y, $, Q, dt]
|
|
1220
1173
|
});
|
|
1221
1174
|
}
|
|
1222
1175
|
return Promise.allSettled(
|
|
1223
|
-
|
|
1224
|
-
const
|
|
1225
|
-
headers:
|
|
1176
|
+
ut.map(async (U) => {
|
|
1177
|
+
const P = !!n, Y = await fetch(U.url, {
|
|
1178
|
+
headers: P ? { Authorization: n } : void 0
|
|
1226
1179
|
});
|
|
1227
|
-
if (!
|
|
1228
|
-
throw new Error(`HTTP ${
|
|
1229
|
-
const
|
|
1230
|
-
return { tile:
|
|
1180
|
+
if (!Y.ok)
|
|
1181
|
+
throw new Error(`HTTP ${Y.status}`);
|
|
1182
|
+
const $ = await createImageBitmap(await Y.blob());
|
|
1183
|
+
return { tile: U, bitmap: $ };
|
|
1231
1184
|
})
|
|
1232
|
-
).then((
|
|
1233
|
-
if (
|
|
1234
|
-
for (const
|
|
1235
|
-
|
|
1185
|
+
).then((U) => {
|
|
1186
|
+
if (x) {
|
|
1187
|
+
for (const $ of U)
|
|
1188
|
+
$.status === "fulfilled" && $.value.bitmap.close();
|
|
1236
1189
|
return;
|
|
1237
1190
|
}
|
|
1238
|
-
const
|
|
1239
|
-
for (const
|
|
1240
|
-
if (
|
|
1191
|
+
const P = et.width / Math.max(1, e.width), Y = et.height / Math.max(1, e.height);
|
|
1192
|
+
for (const $ of U) {
|
|
1193
|
+
if ($.status !== "fulfilled") continue;
|
|
1241
1194
|
const {
|
|
1242
1195
|
tile: { bounds: Q },
|
|
1243
|
-
bitmap:
|
|
1244
|
-
} =
|
|
1245
|
-
|
|
1196
|
+
bitmap: dt
|
|
1197
|
+
} = $.value, Lt = Q[0] * P, Tt = Q[1] * Y, vt = Math.max(1, (Q[2] - Q[0]) * P), bt = Math.max(1, (Q[3] - Q[1]) * Y);
|
|
1198
|
+
ct.drawImage(dt, Lt, Tt, vt, bt), dt.close();
|
|
1246
1199
|
}
|
|
1247
|
-
|
|
1200
|
+
c.current = et, J();
|
|
1248
1201
|
}), () => {
|
|
1249
|
-
|
|
1202
|
+
x = !0;
|
|
1250
1203
|
};
|
|
1251
1204
|
}, [
|
|
1252
1205
|
e,
|
|
1253
1206
|
n,
|
|
1254
|
-
|
|
1207
|
+
m,
|
|
1255
1208
|
y,
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
]),
|
|
1261
|
-
|
|
1262
|
-
}, [
|
|
1209
|
+
R,
|
|
1210
|
+
At,
|
|
1211
|
+
L,
|
|
1212
|
+
J
|
|
1213
|
+
]), z(() => {
|
|
1214
|
+
J();
|
|
1215
|
+
}, [J]), z(() => {
|
|
1263
1216
|
if (i)
|
|
1264
|
-
return i.current =
|
|
1265
|
-
i.current ===
|
|
1217
|
+
return i.current = J, () => {
|
|
1218
|
+
i.current === J && (i.current = null);
|
|
1266
1219
|
};
|
|
1267
|
-
}, [i,
|
|
1220
|
+
}, [i, J]), z(
|
|
1268
1221
|
() => () => {
|
|
1269
|
-
h.current = { active: !1, pointerId: null },
|
|
1222
|
+
h.current = { active: !1, pointerId: null }, w.current !== null && (cancelAnimationFrame(w.current), w.current = null), f.current = !1;
|
|
1270
1223
|
},
|
|
1271
1224
|
[]
|
|
1272
|
-
), /* @__PURE__ */
|
|
1225
|
+
), /* @__PURE__ */ Mt(
|
|
1273
1226
|
"canvas",
|
|
1274
1227
|
{
|
|
1275
1228
|
ref: a,
|
|
1276
1229
|
className: o,
|
|
1277
|
-
style:
|
|
1278
|
-
onPointerDown:
|
|
1279
|
-
onPointerMove:
|
|
1280
|
-
onPointerUp:
|
|
1281
|
-
onPointerCancel:
|
|
1282
|
-
onContextMenu: (
|
|
1283
|
-
|
|
1230
|
+
style: lt,
|
|
1231
|
+
onPointerDown: ht,
|
|
1232
|
+
onPointerMove: Ct,
|
|
1233
|
+
onPointerUp: at,
|
|
1234
|
+
onPointerCancel: at,
|
|
1235
|
+
onContextMenu: (x) => {
|
|
1236
|
+
x.preventDefault();
|
|
1284
1237
|
},
|
|
1285
|
-
onWheel: (
|
|
1286
|
-
|
|
1238
|
+
onWheel: (x) => {
|
|
1239
|
+
x.preventDefault(), x.stopPropagation();
|
|
1287
1240
|
}
|
|
1288
1241
|
}
|
|
1289
1242
|
);
|
|
1290
1243
|
}
|
|
1291
|
-
function
|
|
1244
|
+
function br({
|
|
1292
1245
|
imageWidth: e,
|
|
1293
1246
|
imageHeight: t,
|
|
1294
1247
|
tiles: n,
|
|
@@ -1296,16 +1249,16 @@ function rr({
|
|
|
1296
1249
|
className: i,
|
|
1297
1250
|
style: o
|
|
1298
1251
|
}) {
|
|
1299
|
-
const s =
|
|
1252
|
+
const s = Z(null), a = Z(null), c = H(
|
|
1300
1253
|
() => ({ width: "100%", height: "100%", display: "block", ...o }),
|
|
1301
1254
|
[o]
|
|
1302
1255
|
);
|
|
1303
|
-
return
|
|
1304
|
-
const
|
|
1305
|
-
if (!
|
|
1256
|
+
return z(() => {
|
|
1257
|
+
const l = s.current;
|
|
1258
|
+
if (!l)
|
|
1306
1259
|
return;
|
|
1307
|
-
const h = new
|
|
1308
|
-
canvas:
|
|
1260
|
+
const h = new gn({
|
|
1261
|
+
canvas: l,
|
|
1309
1262
|
imageWidth: e,
|
|
1310
1263
|
imageHeight: t,
|
|
1311
1264
|
initialViewState: r
|
|
@@ -1313,69 +1266,96 @@ function rr({
|
|
|
1313
1266
|
return a.current = h, h.setTiles(n), () => {
|
|
1314
1267
|
h.destroy(), a.current = null;
|
|
1315
1268
|
};
|
|
1316
|
-
}, [e, t]),
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
}, [n]),
|
|
1320
|
-
const
|
|
1321
|
-
!
|
|
1322
|
-
}, [r]), /* @__PURE__ */
|
|
1269
|
+
}, [e, t]), z(() => {
|
|
1270
|
+
const l = a.current;
|
|
1271
|
+
l && l.setTiles(n);
|
|
1272
|
+
}, [n]), z(() => {
|
|
1273
|
+
const l = a.current;
|
|
1274
|
+
!l || !r || l.setViewState(r);
|
|
1275
|
+
}, [r]), /* @__PURE__ */ Mt("canvas", { ref: s, className: i, style: c });
|
|
1276
|
+
}
|
|
1277
|
+
function Ke(e) {
|
|
1278
|
+
return Math.max(
|
|
1279
|
+
0,
|
|
1280
|
+
Math.min(
|
|
1281
|
+
Math.floor(e.count ?? 0),
|
|
1282
|
+
Math.floor((e.positions?.length ?? 0) / 2),
|
|
1283
|
+
e.paletteIndices?.length ?? 0
|
|
1284
|
+
)
|
|
1285
|
+
);
|
|
1323
1286
|
}
|
|
1324
|
-
function
|
|
1287
|
+
function Fn(e) {
|
|
1325
1288
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1326
1289
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1327
1290
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1328
1291
|
}
|
|
1329
|
-
function
|
|
1292
|
+
function je(e) {
|
|
1330
1293
|
const t = [];
|
|
1331
1294
|
for (const n of e ?? []) {
|
|
1332
|
-
const r =
|
|
1295
|
+
const r = Fn(n);
|
|
1333
1296
|
if (r.length < 4) continue;
|
|
1334
1297
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
1335
|
-
for (const [
|
|
1336
|
-
|
|
1298
|
+
for (const [c, l] of r)
|
|
1299
|
+
c < i && (i = c), c > s && (s = c), l < o && (o = l), l > a && (a = l);
|
|
1337
1300
|
!Number.isFinite(i) || !Number.isFinite(o) || t.push({ ring: r, minX: i, minY: o, maxX: s, maxY: a });
|
|
1338
1301
|
}
|
|
1339
1302
|
return t;
|
|
1340
1303
|
}
|
|
1341
|
-
function
|
|
1304
|
+
function Ln(e, t, n) {
|
|
1342
1305
|
let r = !1;
|
|
1343
1306
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
1344
|
-
const s = n[i][0], a = n[i][1],
|
|
1345
|
-
a > t !=
|
|
1307
|
+
const s = n[i][0], a = n[i][1], c = n[o][0], l = n[o][1];
|
|
1308
|
+
a > t != l > t && e < (c - s) * (t - a) / (l - a || Number.EPSILON) + s && (r = !r);
|
|
1346
1309
|
}
|
|
1347
1310
|
return r;
|
|
1348
1311
|
}
|
|
1349
|
-
function
|
|
1312
|
+
function Je(e, t, n) {
|
|
1350
1313
|
for (const r of n)
|
|
1351
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
1314
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && Ln(e, t, r.ring))
|
|
1352
1315
|
return !0;
|
|
1353
1316
|
return !1;
|
|
1354
1317
|
}
|
|
1355
|
-
function
|
|
1318
|
+
function re(e, t) {
|
|
1356
1319
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1357
1320
|
return null;
|
|
1358
|
-
const n =
|
|
1321
|
+
const n = je(t ?? []);
|
|
1359
1322
|
if (n.length === 0)
|
|
1360
1323
|
return {
|
|
1361
1324
|
count: 0,
|
|
1362
1325
|
positions: new Float32Array(0),
|
|
1363
1326
|
paletteIndices: new Uint16Array(0)
|
|
1364
1327
|
};
|
|
1365
|
-
const r = e
|
|
1366
|
-
let
|
|
1367
|
-
for (let
|
|
1368
|
-
const h = i[
|
|
1369
|
-
|
|
1328
|
+
const r = Ke(e), i = e.positions, o = e.paletteIndices, s = new Float32Array(r * 2), a = new Uint16Array(r);
|
|
1329
|
+
let c = 0;
|
|
1330
|
+
for (let l = 0; l < r; l += 1) {
|
|
1331
|
+
const h = i[l * 2], w = i[l * 2 + 1];
|
|
1332
|
+
Je(h, w, n) && (s[c * 2] = h, s[c * 2 + 1] = w, a[c] = o[l], c += 1);
|
|
1370
1333
|
}
|
|
1371
1334
|
return {
|
|
1372
|
-
count:
|
|
1373
|
-
positions: s.subarray(0,
|
|
1374
|
-
paletteIndices: a.subarray(0,
|
|
1335
|
+
count: c,
|
|
1336
|
+
positions: s.subarray(0, c * 2),
|
|
1337
|
+
paletteIndices: a.subarray(0, c)
|
|
1375
1338
|
};
|
|
1376
1339
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1340
|
+
function Dn(e, t) {
|
|
1341
|
+
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1342
|
+
return new Uint32Array(0);
|
|
1343
|
+
const n = je(t ?? []);
|
|
1344
|
+
if (n.length === 0)
|
|
1345
|
+
return new Uint32Array(0);
|
|
1346
|
+
const r = Ke(e);
|
|
1347
|
+
if (r === 0)
|
|
1348
|
+
return new Uint32Array(0);
|
|
1349
|
+
const i = e.positions, o = new Uint32Array(r);
|
|
1350
|
+
let s = 0;
|
|
1351
|
+
for (let a = 0; a < r; a += 1) {
|
|
1352
|
+
const c = i[a * 2], l = i[a * 2 + 1];
|
|
1353
|
+
Je(c, l, n) && (o[s] = a, s += 1);
|
|
1354
|
+
}
|
|
1355
|
+
return o.subarray(0, s);
|
|
1356
|
+
}
|
|
1357
|
+
let jt = null;
|
|
1358
|
+
const Nn = `
|
|
1379
1359
|
struct Params {
|
|
1380
1360
|
pointCount: u32,
|
|
1381
1361
|
boundsCount: u32,
|
|
@@ -1407,21 +1387,21 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
|
1407
1387
|
outputMask[i] = inside;
|
|
1408
1388
|
}
|
|
1409
1389
|
`;
|
|
1410
|
-
function
|
|
1390
|
+
function zn() {
|
|
1411
1391
|
if (typeof navigator > "u") return !1;
|
|
1412
1392
|
const e = navigator;
|
|
1413
1393
|
return typeof e.gpu == "object" && e.gpu !== null;
|
|
1414
1394
|
}
|
|
1415
|
-
function
|
|
1416
|
-
if (!
|
|
1395
|
+
function Qe() {
|
|
1396
|
+
if (!zn()) return null;
|
|
1417
1397
|
const t = navigator.gpu;
|
|
1418
1398
|
if (!t || typeof t != "object") return null;
|
|
1419
1399
|
const n = t;
|
|
1420
1400
|
return typeof n.requestAdapter != "function" ? null : n;
|
|
1421
1401
|
}
|
|
1422
|
-
const
|
|
1423
|
-
async function
|
|
1424
|
-
const e =
|
|
1402
|
+
const Jt = globalThis.GPUShaderStage?.COMPUTE ?? 4, le = globalThis.GPUBufferUsage?.STORAGE ?? 128, Qt = globalThis.GPUBufferUsage?.COPY_DST ?? 8, kn = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Yn = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Wn = globalThis.GPUBufferUsage?.MAP_READ ?? 1, Xn = globalThis.GPUMapMode?.READ ?? 1;
|
|
1403
|
+
async function yr() {
|
|
1404
|
+
const e = Qe();
|
|
1425
1405
|
if (!e)
|
|
1426
1406
|
return { supported: !1, features: [] };
|
|
1427
1407
|
const t = await e.requestAdapter();
|
|
@@ -1440,9 +1420,9 @@ async function ir() {
|
|
|
1440
1420
|
}
|
|
1441
1421
|
} : { supported: !1, features: [] };
|
|
1442
1422
|
}
|
|
1443
|
-
async function
|
|
1444
|
-
return
|
|
1445
|
-
const e =
|
|
1423
|
+
async function Vn() {
|
|
1424
|
+
return jt || (jt = (async () => {
|
|
1425
|
+
const e = Qe();
|
|
1446
1426
|
if (!e) return null;
|
|
1447
1427
|
const t = await e.requestAdapter();
|
|
1448
1428
|
if (!t) return null;
|
|
@@ -1450,40 +1430,40 @@ async function Mn() {
|
|
|
1450
1430
|
entries: [
|
|
1451
1431
|
{
|
|
1452
1432
|
binding: 0,
|
|
1453
|
-
visibility:
|
|
1433
|
+
visibility: Jt,
|
|
1454
1434
|
buffer: { type: "read-only-storage" }
|
|
1455
1435
|
},
|
|
1456
1436
|
{
|
|
1457
1437
|
binding: 1,
|
|
1458
|
-
visibility:
|
|
1438
|
+
visibility: Jt,
|
|
1459
1439
|
buffer: { type: "read-only-storage" }
|
|
1460
1440
|
},
|
|
1461
1441
|
{
|
|
1462
1442
|
binding: 2,
|
|
1463
|
-
visibility:
|
|
1443
|
+
visibility: Jt,
|
|
1464
1444
|
buffer: { type: "storage" }
|
|
1465
1445
|
},
|
|
1466
1446
|
{
|
|
1467
1447
|
binding: 3,
|
|
1468
|
-
visibility:
|
|
1448
|
+
visibility: Jt,
|
|
1469
1449
|
buffer: { type: "uniform" }
|
|
1470
1450
|
}
|
|
1471
1451
|
]
|
|
1472
1452
|
}), i = n.createComputePipeline({
|
|
1473
1453
|
layout: n.createPipelineLayout({ bindGroupLayouts: [r] }),
|
|
1474
1454
|
compute: {
|
|
1475
|
-
module: n.createShaderModule({ code:
|
|
1455
|
+
module: n.createShaderModule({ code: Nn }),
|
|
1476
1456
|
entryPoint: "main"
|
|
1477
1457
|
}
|
|
1478
1458
|
});
|
|
1479
1459
|
return { device: n, pipeline: i, bindGroupLayout: r };
|
|
1480
|
-
})(),
|
|
1460
|
+
})(), jt);
|
|
1481
1461
|
}
|
|
1482
|
-
function
|
|
1462
|
+
function te(e, t) {
|
|
1483
1463
|
return Math.ceil(e / t) * t;
|
|
1484
1464
|
}
|
|
1485
|
-
async function
|
|
1486
|
-
const r = await
|
|
1465
|
+
async function On(e, t, n) {
|
|
1466
|
+
const r = await Vn();
|
|
1487
1467
|
if (!r) return null;
|
|
1488
1468
|
const i = Math.max(0, Math.floor(t)), o = Math.max(0, Math.floor(n.length / 4));
|
|
1489
1469
|
if (i === 0 || o === 0)
|
|
@@ -1491,103 +1471,103 @@ async function An(e, t, n) {
|
|
|
1491
1471
|
const s = Math.min(i, Math.floor(e.length / 2));
|
|
1492
1472
|
if (s === 0)
|
|
1493
1473
|
return new Uint32Array(0);
|
|
1494
|
-
const a = s * 2 * Float32Array.BYTES_PER_ELEMENT,
|
|
1495
|
-
if (a > h ||
|
|
1474
|
+
const a = s * 2 * Float32Array.BYTES_PER_ELEMENT, c = o * 4 * Float32Array.BYTES_PER_ELEMENT, l = s * Uint32Array.BYTES_PER_ELEMENT, h = Number(r.device.limits.maxStorageBufferBindingSize);
|
|
1475
|
+
if (a > h || c > h || l > h)
|
|
1496
1476
|
return null;
|
|
1497
|
-
const
|
|
1498
|
-
size:
|
|
1499
|
-
usage:
|
|
1500
|
-
}),
|
|
1501
|
-
size:
|
|
1502
|
-
usage:
|
|
1503
|
-
}),
|
|
1504
|
-
size:
|
|
1505
|
-
usage:
|
|
1477
|
+
const w = r.device.createBuffer({
|
|
1478
|
+
size: te(a, 4),
|
|
1479
|
+
usage: le | Qt
|
|
1480
|
+
}), f = r.device.createBuffer({
|
|
1481
|
+
size: te(c, 4),
|
|
1482
|
+
usage: le | Qt
|
|
1483
|
+
}), m = r.device.createBuffer({
|
|
1484
|
+
size: te(l, 4),
|
|
1485
|
+
usage: le | kn
|
|
1506
1486
|
}), y = r.device.createBuffer({
|
|
1507
1487
|
size: 16,
|
|
1508
|
-
usage:
|
|
1488
|
+
usage: Yn | Qt
|
|
1509
1489
|
}), b = r.device.createBuffer({
|
|
1510
|
-
size:
|
|
1511
|
-
usage:
|
|
1490
|
+
size: te(l, 4),
|
|
1491
|
+
usage: Qt | Wn
|
|
1512
1492
|
});
|
|
1513
1493
|
r.device.queue.writeBuffer(
|
|
1514
|
-
|
|
1494
|
+
w,
|
|
1515
1495
|
0,
|
|
1516
1496
|
e.buffer,
|
|
1517
1497
|
e.byteOffset,
|
|
1518
1498
|
a
|
|
1519
1499
|
), r.device.queue.writeBuffer(
|
|
1520
|
-
|
|
1500
|
+
f,
|
|
1521
1501
|
0,
|
|
1522
1502
|
n.buffer,
|
|
1523
1503
|
n.byteOffset,
|
|
1524
|
-
|
|
1504
|
+
c
|
|
1525
1505
|
), r.device.queue.writeBuffer(
|
|
1526
1506
|
y,
|
|
1527
1507
|
0,
|
|
1528
1508
|
new Uint32Array([s, o, 0, 0])
|
|
1529
1509
|
);
|
|
1530
|
-
const
|
|
1510
|
+
const v = r.device.createBindGroup({
|
|
1531
1511
|
layout: r.bindGroupLayout,
|
|
1532
1512
|
entries: [
|
|
1533
|
-
{ binding: 0, resource: { buffer:
|
|
1534
|
-
{ binding: 1, resource: { buffer:
|
|
1535
|
-
{ binding: 2, resource: { buffer:
|
|
1513
|
+
{ binding: 0, resource: { buffer: w } },
|
|
1514
|
+
{ binding: 1, resource: { buffer: f } },
|
|
1515
|
+
{ binding: 2, resource: { buffer: m } },
|
|
1536
1516
|
{ binding: 3, resource: { buffer: y } }
|
|
1537
1517
|
]
|
|
1538
|
-
}),
|
|
1539
|
-
|
|
1540
|
-
const
|
|
1541
|
-
return b.unmap(),
|
|
1518
|
+
}), S = r.device.createCommandEncoder(), L = S.beginComputePass();
|
|
1519
|
+
L.setPipeline(r.pipeline), L.setBindGroup(0, v), L.dispatchWorkgroups(Math.ceil(s / 256)), L.end(), S.copyBufferToBuffer(m, 0, b, 0, l), r.device.queue.submit([S.finish()]), await b.mapAsync(Xn);
|
|
1520
|
+
const R = b.getMappedRange(), W = new Uint32Array(R.slice(0));
|
|
1521
|
+
return b.unmap(), w.destroy(), f.destroy(), m.destroy(), y.destroy(), b.destroy(), W;
|
|
1542
1522
|
}
|
|
1543
|
-
function
|
|
1523
|
+
function Et() {
|
|
1544
1524
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1545
1525
|
}
|
|
1546
|
-
function
|
|
1526
|
+
function Gn(e) {
|
|
1547
1527
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1548
1528
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1549
1529
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1550
1530
|
}
|
|
1551
|
-
function
|
|
1531
|
+
function qn(e) {
|
|
1552
1532
|
const t = [];
|
|
1553
1533
|
for (const n of e ?? []) {
|
|
1554
|
-
const r =
|
|
1534
|
+
const r = Gn(n);
|
|
1555
1535
|
if (r.length < 4) continue;
|
|
1556
1536
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
1557
|
-
for (const [
|
|
1558
|
-
|
|
1537
|
+
for (const [c, l] of r)
|
|
1538
|
+
c < i && (i = c), c > s && (s = c), l < o && (o = l), l > a && (a = l);
|
|
1559
1539
|
!Number.isFinite(i) || !Number.isFinite(o) || t.push({ ring: r, minX: i, minY: o, maxX: s, maxY: a });
|
|
1560
1540
|
}
|
|
1561
1541
|
return t;
|
|
1562
1542
|
}
|
|
1563
|
-
function
|
|
1543
|
+
function $n(e, t, n) {
|
|
1564
1544
|
let r = !1;
|
|
1565
1545
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
1566
|
-
const s = n[i][0], a = n[i][1],
|
|
1567
|
-
a > t !=
|
|
1546
|
+
const s = n[i][0], a = n[i][1], c = n[o][0], l = n[o][1];
|
|
1547
|
+
a > t != l > t && e < (c - s) * (t - a) / (l - a || Number.EPSILON) + s && (r = !r);
|
|
1568
1548
|
}
|
|
1569
1549
|
return r;
|
|
1570
1550
|
}
|
|
1571
|
-
function
|
|
1551
|
+
function ze(e, t, n) {
|
|
1572
1552
|
for (const r of n)
|
|
1573
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
1553
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && $n(e, t, r.ring))
|
|
1574
1554
|
return !0;
|
|
1575
1555
|
return !1;
|
|
1576
1556
|
}
|
|
1577
|
-
async function
|
|
1578
|
-
const r =
|
|
1557
|
+
async function Hn(e, t, n = {}) {
|
|
1558
|
+
const r = Et(), i = n.bridgeToDraw === !0;
|
|
1579
1559
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1580
1560
|
return {
|
|
1581
1561
|
data: null,
|
|
1582
1562
|
meta: {
|
|
1583
1563
|
mode: "hybrid-webgpu",
|
|
1584
|
-
durationMs:
|
|
1564
|
+
durationMs: Et() - r,
|
|
1585
1565
|
usedWebGpu: !1,
|
|
1586
1566
|
candidateCount: 0,
|
|
1587
1567
|
bridgedToDraw: !1
|
|
1588
1568
|
}
|
|
1589
1569
|
};
|
|
1590
|
-
const o =
|
|
1570
|
+
const o = qn(t ?? []);
|
|
1591
1571
|
if (o.length === 0)
|
|
1592
1572
|
return {
|
|
1593
1573
|
data: {
|
|
@@ -1597,7 +1577,7 @@ async function _n(e, t, n = {}) {
|
|
|
1597
1577
|
},
|
|
1598
1578
|
meta: {
|
|
1599
1579
|
mode: "hybrid-webgpu",
|
|
1600
|
-
durationMs:
|
|
1580
|
+
durationMs: Et() - r,
|
|
1601
1581
|
usedWebGpu: !1,
|
|
1602
1582
|
candidateCount: 0,
|
|
1603
1583
|
bridgedToDraw: !1
|
|
@@ -1613,7 +1593,7 @@ async function _n(e, t, n = {}) {
|
|
|
1613
1593
|
},
|
|
1614
1594
|
meta: {
|
|
1615
1595
|
mode: "hybrid-webgpu",
|
|
1616
|
-
durationMs:
|
|
1596
|
+
durationMs: Et() - r,
|
|
1617
1597
|
usedWebGpu: !1,
|
|
1618
1598
|
candidateCount: 0,
|
|
1619
1599
|
bridgedToDraw: !1
|
|
@@ -1621,21 +1601,21 @@ async function _n(e, t, n = {}) {
|
|
|
1621
1601
|
};
|
|
1622
1602
|
const a = new Float32Array(o.length * 4);
|
|
1623
1603
|
for (let b = 0; b < o.length; b += 1) {
|
|
1624
|
-
const
|
|
1625
|
-
a[
|
|
1604
|
+
const v = b * 4, S = o[b];
|
|
1605
|
+
a[v] = S.minX, a[v + 1] = S.minY, a[v + 2] = S.maxX, a[v + 3] = S.maxY;
|
|
1626
1606
|
}
|
|
1627
|
-
let
|
|
1607
|
+
let c = null, l = !1;
|
|
1628
1608
|
try {
|
|
1629
|
-
|
|
1609
|
+
c = await On(e.positions, s, a), l = !!c;
|
|
1630
1610
|
} catch {
|
|
1631
|
-
|
|
1611
|
+
c = null, l = !1;
|
|
1632
1612
|
}
|
|
1633
|
-
if (!
|
|
1613
|
+
if (!c)
|
|
1634
1614
|
return {
|
|
1635
|
-
data:
|
|
1615
|
+
data: re(e, t),
|
|
1636
1616
|
meta: {
|
|
1637
1617
|
mode: "hybrid-webgpu",
|
|
1638
|
-
durationMs:
|
|
1618
|
+
durationMs: Et() - r,
|
|
1639
1619
|
usedWebGpu: !1,
|
|
1640
1620
|
candidateCount: s,
|
|
1641
1621
|
bridgedToDraw: !1
|
|
@@ -1643,12 +1623,12 @@ async function _n(e, t, n = {}) {
|
|
|
1643
1623
|
};
|
|
1644
1624
|
let h = 0;
|
|
1645
1625
|
for (let b = 0; b < s; b += 1)
|
|
1646
|
-
|
|
1647
|
-
const
|
|
1626
|
+
c[b] === 1 && (h += 1);
|
|
1627
|
+
const w = new Uint32Array(h);
|
|
1648
1628
|
if (h > 0) {
|
|
1649
1629
|
let b = 0;
|
|
1650
|
-
for (let
|
|
1651
|
-
|
|
1630
|
+
for (let v = 0; v < s; v += 1)
|
|
1631
|
+
c[v] === 1 && (w[b] = v, b += 1);
|
|
1652
1632
|
}
|
|
1653
1633
|
if (h === 0)
|
|
1654
1634
|
return i ? {
|
|
@@ -1660,7 +1640,7 @@ async function _n(e, t, n = {}) {
|
|
|
1660
1640
|
},
|
|
1661
1641
|
meta: {
|
|
1662
1642
|
mode: "hybrid-webgpu",
|
|
1663
|
-
durationMs:
|
|
1643
|
+
durationMs: Et() - r,
|
|
1664
1644
|
usedWebGpu: !0,
|
|
1665
1645
|
candidateCount: 0,
|
|
1666
1646
|
bridgedToDraw: !0
|
|
@@ -1673,7 +1653,7 @@ async function _n(e, t, n = {}) {
|
|
|
1673
1653
|
},
|
|
1674
1654
|
meta: {
|
|
1675
1655
|
mode: "hybrid-webgpu",
|
|
1676
|
-
durationMs:
|
|
1656
|
+
durationMs: Et() - r,
|
|
1677
1657
|
usedWebGpu: !0,
|
|
1678
1658
|
candidateCount: 0,
|
|
1679
1659
|
bridgedToDraw: !1
|
|
@@ -1681,76 +1661,95 @@ async function _n(e, t, n = {}) {
|
|
|
1681
1661
|
};
|
|
1682
1662
|
if (i) {
|
|
1683
1663
|
const b = new Uint32Array(h);
|
|
1684
|
-
let
|
|
1685
|
-
for (let
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1664
|
+
let v = 0;
|
|
1665
|
+
for (let S = 0; S < h; S += 1) {
|
|
1666
|
+
const L = w[S] ?? 0, R = e.positions[L * 2], W = e.positions[L * 2 + 1];
|
|
1667
|
+
ze(R, W, o) && (b[v] = L, v += 1);
|
|
1688
1668
|
}
|
|
1689
1669
|
return {
|
|
1690
1670
|
data: {
|
|
1691
1671
|
count: s,
|
|
1692
1672
|
positions: e.positions.subarray(0, s * 2),
|
|
1693
1673
|
paletteIndices: e.paletteIndices.subarray(0, s),
|
|
1694
|
-
drawIndices: b.subarray(0,
|
|
1674
|
+
drawIndices: b.subarray(0, v)
|
|
1695
1675
|
},
|
|
1696
1676
|
meta: {
|
|
1697
1677
|
mode: "hybrid-webgpu",
|
|
1698
|
-
durationMs:
|
|
1678
|
+
durationMs: Et() - r,
|
|
1699
1679
|
usedWebGpu: !0,
|
|
1700
1680
|
candidateCount: h,
|
|
1701
1681
|
bridgedToDraw: !0
|
|
1702
1682
|
}
|
|
1703
1683
|
};
|
|
1704
1684
|
}
|
|
1705
|
-
const
|
|
1685
|
+
const f = new Float32Array(h * 2), m = new Uint16Array(h);
|
|
1706
1686
|
let y = 0;
|
|
1707
1687
|
for (let b = 0; b < h; b += 1) {
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1688
|
+
const v = w[b] ?? 0, S = e.positions[v * 2], L = e.positions[v * 2 + 1];
|
|
1689
|
+
ze(S, L, o) && (f[y * 2] = S, f[y * 2 + 1] = L, m[y] = e.paletteIndices[v], y += 1);
|
|
1710
1690
|
}
|
|
1711
1691
|
return {
|
|
1712
1692
|
data: {
|
|
1713
1693
|
count: y,
|
|
1714
|
-
positions:
|
|
1715
|
-
paletteIndices:
|
|
1694
|
+
positions: f.subarray(0, y * 2),
|
|
1695
|
+
paletteIndices: m.subarray(0, y)
|
|
1716
1696
|
},
|
|
1717
1697
|
meta: {
|
|
1718
1698
|
mode: "hybrid-webgpu",
|
|
1719
|
-
durationMs:
|
|
1699
|
+
durationMs: Et() - r,
|
|
1720
1700
|
usedWebGpu: !0,
|
|
1721
1701
|
candidateCount: h,
|
|
1722
1702
|
bridgedToDraw: !1
|
|
1723
1703
|
}
|
|
1724
1704
|
};
|
|
1725
1705
|
}
|
|
1726
|
-
let
|
|
1727
|
-
const
|
|
1728
|
-
function
|
|
1706
|
+
let wt = null, ge = !0, tn = 1;
|
|
1707
|
+
const Ft = /* @__PURE__ */ new Map();
|
|
1708
|
+
function Ut() {
|
|
1729
1709
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1730
1710
|
}
|
|
1731
|
-
function
|
|
1732
|
-
if (!
|
|
1733
|
-
if (
|
|
1711
|
+
function en() {
|
|
1712
|
+
if (!ge) return null;
|
|
1713
|
+
if (wt) return wt;
|
|
1734
1714
|
try {
|
|
1735
1715
|
const e = new Worker(new URL(
|
|
1736
1716
|
/* @vite-ignore */
|
|
1737
|
-
"" + new URL("assets/roi-clip-worker-
|
|
1717
|
+
"" + new URL("assets/roi-clip-worker-DdVYCepx.js", import.meta.url).href,
|
|
1738
1718
|
import.meta.url
|
|
1739
1719
|
), { type: "module" });
|
|
1740
|
-
return e.addEventListener("message",
|
|
1720
|
+
return e.addEventListener("message", we), e.addEventListener("error", be), wt = e, e;
|
|
1741
1721
|
} catch {
|
|
1742
|
-
return
|
|
1722
|
+
return ge = !1, null;
|
|
1743
1723
|
}
|
|
1744
1724
|
}
|
|
1745
|
-
function
|
|
1725
|
+
function we(e) {
|
|
1746
1726
|
const t = e.data;
|
|
1747
1727
|
if (!t) return;
|
|
1748
|
-
const n =
|
|
1728
|
+
const n = Ft.get(t.id);
|
|
1749
1729
|
if (!n) return;
|
|
1750
|
-
if (
|
|
1730
|
+
if (Ft.delete(t.id), t.type === "roi-clip-failure") {
|
|
1751
1731
|
n.reject(new Error(t.error || "worker clip failed"));
|
|
1752
1732
|
return;
|
|
1753
1733
|
}
|
|
1734
|
+
if (t.type === "roi-clip-index-success") {
|
|
1735
|
+
if (n.kind !== "index") {
|
|
1736
|
+
n.reject(new Error("worker response mismatch: expected point data result"));
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
const a = Math.max(0, Math.floor(t.count)), c = new Uint32Array(t.indices).subarray(0, a);
|
|
1740
|
+
n.resolve({
|
|
1741
|
+
indices: c,
|
|
1742
|
+
meta: {
|
|
1743
|
+
mode: "worker",
|
|
1744
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Ut() - n.startMs
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
if (n.kind !== "data") {
|
|
1750
|
+
n.reject(new Error("worker response mismatch: expected index result"));
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1754
1753
|
const r = Math.max(0, Math.floor(t.count)), i = new Float32Array(t.positions), o = new Uint16Array(t.paletteIndices), s = {
|
|
1755
1754
|
count: r,
|
|
1756
1755
|
positions: i.subarray(0, r * 2),
|
|
@@ -1760,41 +1759,41 @@ function ue(e) {
|
|
|
1760
1759
|
data: s,
|
|
1761
1760
|
meta: {
|
|
1762
1761
|
mode: "worker",
|
|
1763
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
1762
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Ut() - n.startMs
|
|
1764
1763
|
}
|
|
1765
1764
|
});
|
|
1766
1765
|
}
|
|
1767
|
-
function
|
|
1768
|
-
|
|
1769
|
-
for (const [, e] of
|
|
1766
|
+
function be() {
|
|
1767
|
+
ge = !1, wt && (wt.removeEventListener("message", we), wt.removeEventListener("error", be), wt.terminate(), wt = null);
|
|
1768
|
+
for (const [, e] of Ft)
|
|
1770
1769
|
e.reject(new Error("worker crashed"));
|
|
1771
|
-
|
|
1770
|
+
Ft.clear();
|
|
1772
1771
|
}
|
|
1773
|
-
function
|
|
1774
|
-
if (
|
|
1775
|
-
|
|
1776
|
-
for (const [, e] of
|
|
1772
|
+
function xr() {
|
|
1773
|
+
if (wt) {
|
|
1774
|
+
wt.removeEventListener("message", we), wt.removeEventListener("error", be), wt.terminate(), wt = null;
|
|
1775
|
+
for (const [, e] of Ft)
|
|
1777
1776
|
e.reject(new Error("worker terminated"));
|
|
1778
|
-
|
|
1777
|
+
Ft.clear();
|
|
1779
1778
|
}
|
|
1780
1779
|
}
|
|
1781
|
-
async function
|
|
1780
|
+
async function Zn(e, t) {
|
|
1782
1781
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1783
1782
|
return {
|
|
1784
1783
|
data: null,
|
|
1785
1784
|
meta: { mode: "worker", durationMs: 0 }
|
|
1786
1785
|
};
|
|
1787
|
-
const n =
|
|
1786
|
+
const n = en();
|
|
1788
1787
|
if (!n) {
|
|
1789
|
-
const
|
|
1788
|
+
const c = Ut();
|
|
1790
1789
|
return {
|
|
1791
|
-
data:
|
|
1792
|
-
meta: { mode: "sync", durationMs:
|
|
1790
|
+
data: re(e, t),
|
|
1791
|
+
meta: { mode: "sync", durationMs: Ut() - c }
|
|
1793
1792
|
};
|
|
1794
1793
|
}
|
|
1795
|
-
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 =
|
|
1796
|
-
return new Promise((
|
|
1797
|
-
|
|
1794
|
+
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 = tn++, a = Ut();
|
|
1795
|
+
return new Promise((c, l) => {
|
|
1796
|
+
Ft.set(s, { kind: "data", resolve: c, reject: l, startMs: a });
|
|
1798
1797
|
const h = {
|
|
1799
1798
|
type: "roi-clip-request",
|
|
1800
1799
|
id: s,
|
|
@@ -1806,14 +1805,41 @@ async function Fn(e, t) {
|
|
|
1806
1805
|
n.postMessage(h, [i.buffer, o.buffer]);
|
|
1807
1806
|
});
|
|
1808
1807
|
}
|
|
1809
|
-
function
|
|
1808
|
+
async function Tr(e, t) {
|
|
1809
|
+
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1810
|
+
return {
|
|
1811
|
+
indices: new Uint32Array(0),
|
|
1812
|
+
meta: { mode: "worker", durationMs: 0 }
|
|
1813
|
+
};
|
|
1814
|
+
const n = en();
|
|
1815
|
+
if (!n) {
|
|
1816
|
+
const a = Ut();
|
|
1817
|
+
return {
|
|
1818
|
+
indices: Dn(e, t),
|
|
1819
|
+
meta: { mode: "sync", durationMs: Ut() - a }
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
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 = tn++, s = Ut();
|
|
1823
|
+
return new Promise((a, c) => {
|
|
1824
|
+
Ft.set(o, { kind: "index", resolve: a, reject: c, startMs: s });
|
|
1825
|
+
const l = {
|
|
1826
|
+
type: "roi-clip-index-request",
|
|
1827
|
+
id: o,
|
|
1828
|
+
count: r,
|
|
1829
|
+
positions: i.buffer,
|
|
1830
|
+
polygons: t ?? []
|
|
1831
|
+
};
|
|
1832
|
+
n.postMessage(l, [i.buffer]);
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
function Kn(e) {
|
|
1810
1836
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1811
1837
|
const t = e.map(
|
|
1812
1838
|
(i) => [Number(i[0]), Number(i[1])]
|
|
1813
1839
|
), n = t[0], r = t[t.length - 1];
|
|
1814
1840
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1815
1841
|
}
|
|
1816
|
-
function
|
|
1842
|
+
function jn(e) {
|
|
1817
1843
|
let t = 0;
|
|
1818
1844
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
1819
1845
|
const [r, i] = e[n], [o, s] = e[n + 1];
|
|
@@ -1821,38 +1847,38 @@ function Ln(e) {
|
|
|
1821
1847
|
}
|
|
1822
1848
|
return Math.abs(t * 0.5);
|
|
1823
1849
|
}
|
|
1824
|
-
function
|
|
1850
|
+
function Jn(e) {
|
|
1825
1851
|
const t = [];
|
|
1826
1852
|
for (let n = 0; n < e.length; n += 1) {
|
|
1827
1853
|
const r = e[n];
|
|
1828
1854
|
if (!r?.coordinates?.length) continue;
|
|
1829
|
-
const i =
|
|
1855
|
+
const i = Kn(r.coordinates);
|
|
1830
1856
|
if (i.length < 4) continue;
|
|
1831
|
-
let o = 1 / 0, s = 1 / 0, a = -1 / 0,
|
|
1832
|
-
for (const [
|
|
1833
|
-
|
|
1834
|
-
!Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(a) || !Number.isFinite(
|
|
1857
|
+
let o = 1 / 0, s = 1 / 0, a = -1 / 0, c = -1 / 0;
|
|
1858
|
+
for (const [l, h] of i)
|
|
1859
|
+
l < o && (o = l), l > a && (a = l), h < s && (s = h), h > c && (c = h);
|
|
1860
|
+
!Number.isFinite(o) || !Number.isFinite(s) || !Number.isFinite(a) || !Number.isFinite(c) || t.push({
|
|
1835
1861
|
regionId: r.id ?? n,
|
|
1836
1862
|
regionIndex: n,
|
|
1837
1863
|
ring: i,
|
|
1838
1864
|
minX: o,
|
|
1839
1865
|
minY: s,
|
|
1840
1866
|
maxX: a,
|
|
1841
|
-
maxY:
|
|
1842
|
-
area: Math.max(1e-6,
|
|
1867
|
+
maxY: c,
|
|
1868
|
+
area: Math.max(1e-6, jn(i))
|
|
1843
1869
|
});
|
|
1844
1870
|
}
|
|
1845
1871
|
return t;
|
|
1846
1872
|
}
|
|
1847
|
-
function
|
|
1873
|
+
function Qn(e, t, n) {
|
|
1848
1874
|
let r = !1;
|
|
1849
1875
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
1850
|
-
const s = n[i][0], a = n[i][1],
|
|
1851
|
-
a > t !=
|
|
1876
|
+
const s = n[i][0], a = n[i][1], c = n[o][0], l = n[o][1];
|
|
1877
|
+
a > t != l > t && e < (c - s) * (t - a) / (l - a || Number.EPSILON) + s && (r = !r);
|
|
1852
1878
|
}
|
|
1853
1879
|
return r;
|
|
1854
1880
|
}
|
|
1855
|
-
function
|
|
1881
|
+
function tr(e, t) {
|
|
1856
1882
|
if (Array.isArray(t)) {
|
|
1857
1883
|
const n = t[e];
|
|
1858
1884
|
if (typeof n == "string" && n.length > 0) return n;
|
|
@@ -1863,7 +1889,7 @@ function kn(e, t) {
|
|
|
1863
1889
|
}
|
|
1864
1890
|
return String(e);
|
|
1865
1891
|
}
|
|
1866
|
-
function
|
|
1892
|
+
function er(e, t, n = {}) {
|
|
1867
1893
|
const r = Math.max(
|
|
1868
1894
|
0,
|
|
1869
1895
|
Math.min(
|
|
@@ -1874,24 +1900,24 @@ function Yn(e, t, n = {}) {
|
|
|
1874
1900
|
);
|
|
1875
1901
|
let i = null;
|
|
1876
1902
|
if (e?.drawIndices instanceof Uint32Array) {
|
|
1877
|
-
const
|
|
1878
|
-
let
|
|
1879
|
-
for (let y = 0; y <
|
|
1880
|
-
|
|
1881
|
-
if (
|
|
1882
|
-
i =
|
|
1883
|
-
else if (
|
|
1884
|
-
const y = new Uint32Array(
|
|
1903
|
+
const f = e.drawIndices;
|
|
1904
|
+
let m = f.length;
|
|
1905
|
+
for (let y = 0; y < f.length; y += 1)
|
|
1906
|
+
f[y] < r || (m -= 1);
|
|
1907
|
+
if (m === f.length)
|
|
1908
|
+
i = f;
|
|
1909
|
+
else if (m > 0) {
|
|
1910
|
+
const y = new Uint32Array(m);
|
|
1885
1911
|
let b = 0;
|
|
1886
|
-
for (let
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1912
|
+
for (let v = 0; v < f.length; v += 1) {
|
|
1913
|
+
const S = f[v];
|
|
1914
|
+
S >= r || (y[b] = S, b += 1);
|
|
1889
1915
|
}
|
|
1890
1916
|
i = y;
|
|
1891
1917
|
} else
|
|
1892
1918
|
i = new Uint32Array(0);
|
|
1893
1919
|
}
|
|
1894
|
-
const o = i ? i.length : r, s =
|
|
1920
|
+
const o = i ? i.length : r, s = Jn(t ?? []);
|
|
1895
1921
|
if (!e || o === 0 || s.length === 0)
|
|
1896
1922
|
return {
|
|
1897
1923
|
groups: [],
|
|
@@ -1899,48 +1925,48 @@ function Yn(e, t, n = {}) {
|
|
|
1899
1925
|
pointsInsideAnyRegion: 0,
|
|
1900
1926
|
unmatchedPointCount: o
|
|
1901
1927
|
};
|
|
1902
|
-
const a = /* @__PURE__ */ new Map(),
|
|
1903
|
-
let
|
|
1904
|
-
for (let
|
|
1905
|
-
const
|
|
1906
|
-
let
|
|
1907
|
-
for (const
|
|
1908
|
-
y <
|
|
1909
|
-
if (!
|
|
1910
|
-
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
(
|
|
1928
|
+
const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
1929
|
+
let l = 0;
|
|
1930
|
+
for (let f = 0; f < o; f += 1) {
|
|
1931
|
+
const m = i ? i[f] : f, y = e.positions[m * 2], b = e.positions[m * 2 + 1];
|
|
1932
|
+
let v = null;
|
|
1933
|
+
for (const R of s)
|
|
1934
|
+
y < R.minX || y > R.maxX || b < R.minY || b > R.maxY || Qn(y, b, R.ring) && (!v || R.area < v.area) && (v = R);
|
|
1935
|
+
if (!v) continue;
|
|
1936
|
+
l += 1;
|
|
1937
|
+
const S = e.paletteIndices[m] ?? 0, L = a.get(v.regionIndex) ?? /* @__PURE__ */ new Map();
|
|
1938
|
+
L.set(S, (L.get(S) ?? 0) + 1), a.set(v.regionIndex, L), c.set(
|
|
1939
|
+
v.regionIndex,
|
|
1940
|
+
(c.get(v.regionIndex) ?? 0) + 1
|
|
1915
1941
|
);
|
|
1916
1942
|
}
|
|
1917
|
-
const h = n.includeEmptyRegions ?? !1,
|
|
1918
|
-
for (const
|
|
1919
|
-
const
|
|
1920
|
-
if (!h &&
|
|
1921
|
-
const y = a.get(
|
|
1922
|
-
termId:
|
|
1923
|
-
paletteIndex:
|
|
1924
|
-
count:
|
|
1925
|
-
})).sort((
|
|
1926
|
-
|
|
1927
|
-
regionId:
|
|
1928
|
-
regionIndex:
|
|
1929
|
-
totalCount:
|
|
1943
|
+
const h = n.includeEmptyRegions ?? !1, w = [];
|
|
1944
|
+
for (const f of s) {
|
|
1945
|
+
const m = c.get(f.regionIndex) ?? 0;
|
|
1946
|
+
if (!h && m <= 0) continue;
|
|
1947
|
+
const y = a.get(f.regionIndex) ?? /* @__PURE__ */ new Map(), b = Array.from(y.entries()).map(([v, S]) => ({
|
|
1948
|
+
termId: tr(v, n.paletteIndexToTermId),
|
|
1949
|
+
paletteIndex: v,
|
|
1950
|
+
count: S
|
|
1951
|
+
})).sort((v, S) => S.count - v.count || v.paletteIndex - S.paletteIndex);
|
|
1952
|
+
w.push({
|
|
1953
|
+
regionId: f.regionId,
|
|
1954
|
+
regionIndex: f.regionIndex,
|
|
1955
|
+
totalCount: m,
|
|
1930
1956
|
termCounts: b
|
|
1931
1957
|
});
|
|
1932
1958
|
}
|
|
1933
1959
|
return {
|
|
1934
|
-
groups:
|
|
1960
|
+
groups: w,
|
|
1935
1961
|
inputPointCount: o,
|
|
1936
|
-
pointsInsideAnyRegion:
|
|
1937
|
-
unmatchedPointCount: Math.max(0, o -
|
|
1962
|
+
pointsInsideAnyRegion: l,
|
|
1963
|
+
unmatchedPointCount: Math.max(0, o - l)
|
|
1938
1964
|
};
|
|
1939
1965
|
}
|
|
1940
|
-
function
|
|
1966
|
+
function ee() {
|
|
1941
1967
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1942
1968
|
}
|
|
1943
|
-
function
|
|
1969
|
+
function nr(e, t) {
|
|
1944
1970
|
if (!t) return !1;
|
|
1945
1971
|
try {
|
|
1946
1972
|
const r = new URL(e, typeof window < "u" ? window.location.href : void 0).hostname.toLowerCase();
|
|
@@ -1949,25 +1975,25 @@ function Wn(e, t) {
|
|
|
1949
1975
|
}
|
|
1950
1976
|
return !0;
|
|
1951
1977
|
}
|
|
1952
|
-
class
|
|
1978
|
+
class rr {
|
|
1953
1979
|
constructor(t) {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1980
|
+
d(this, "maxConcurrency");
|
|
1981
|
+
d(this, "maxRetries");
|
|
1982
|
+
d(this, "retryBaseDelayMs");
|
|
1983
|
+
d(this, "retryMaxDelayMs");
|
|
1984
|
+
d(this, "onTileLoad");
|
|
1985
|
+
d(this, "onTileError");
|
|
1986
|
+
d(this, "onStateChange");
|
|
1987
|
+
d(this, "authToken");
|
|
1988
|
+
d(this, "destroyed", !1);
|
|
1989
|
+
d(this, "queue", []);
|
|
1990
|
+
d(this, "queuedByKey", /* @__PURE__ */ new Map());
|
|
1991
|
+
d(this, "inflight", /* @__PURE__ */ new Map());
|
|
1992
|
+
d(this, "visibleKeys", /* @__PURE__ */ new Set());
|
|
1993
|
+
d(this, "timerId", null);
|
|
1994
|
+
d(this, "abortedCount", 0);
|
|
1995
|
+
d(this, "retryCount", 0);
|
|
1996
|
+
d(this, "failedCount", 0);
|
|
1971
1997
|
this.maxConcurrency = Math.max(1, Math.floor(t.maxConcurrency ?? 12)), this.maxRetries = Math.max(0, Math.floor(t.maxRetries ?? 2)), this.retryBaseDelayMs = Math.max(
|
|
1972
1998
|
10,
|
|
1973
1999
|
Math.floor(t.retryBaseDelayMs ?? 120)
|
|
@@ -1999,7 +2025,7 @@ class Xn {
|
|
|
1999
2025
|
const o = {
|
|
2000
2026
|
tile: r,
|
|
2001
2027
|
attempt: 0,
|
|
2002
|
-
readyAt:
|
|
2028
|
+
readyAt: ee()
|
|
2003
2029
|
};
|
|
2004
2030
|
this.queue.push(o), this.queuedByKey.set(r.key, o);
|
|
2005
2031
|
}
|
|
@@ -2055,14 +2081,14 @@ class Xn {
|
|
|
2055
2081
|
if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
|
|
2056
2082
|
const t = this.queue[0]?.readyAt;
|
|
2057
2083
|
if (typeof t != "number") return;
|
|
2058
|
-
const n = Math.max(0, t -
|
|
2084
|
+
const n = Math.max(0, t - ee());
|
|
2059
2085
|
this.timerId = window.setTimeout(() => {
|
|
2060
2086
|
this.timerId = null, this.pump();
|
|
2061
2087
|
}, n);
|
|
2062
2088
|
}
|
|
2063
2089
|
takeNextReadyQueueItem() {
|
|
2064
2090
|
if (this.queue.length === 0) return null;
|
|
2065
|
-
const t =
|
|
2091
|
+
const t = ee(), n = this.queue[0];
|
|
2066
2092
|
return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
|
|
2067
2093
|
}
|
|
2068
2094
|
startFetch(t) {
|
|
@@ -2072,7 +2098,7 @@ class Xn {
|
|
|
2072
2098
|
controller: n
|
|
2073
2099
|
};
|
|
2074
2100
|
this.inflight.set(t.tile.key, r), this.emitStateChange();
|
|
2075
|
-
const i =
|
|
2101
|
+
const i = nr(t.tile.url, this.authToken);
|
|
2076
2102
|
fetch(t.tile.url, {
|
|
2077
2103
|
signal: n.signal,
|
|
2078
2104
|
headers: i ? { Authorization: this.authToken } : void 0
|
|
@@ -2095,12 +2121,12 @@ class Xn {
|
|
|
2095
2121
|
return;
|
|
2096
2122
|
if (t.attempt < this.maxRetries && this.visibleKeys.has(t.tile.key)) {
|
|
2097
2123
|
this.retryCount += 1;
|
|
2098
|
-
const a = t.attempt + 1,
|
|
2124
|
+
const a = t.attempt + 1, c = this.getRetryDelay(a), l = {
|
|
2099
2125
|
tile: t.tile,
|
|
2100
2126
|
attempt: a,
|
|
2101
|
-
readyAt:
|
|
2127
|
+
readyAt: ee() + c
|
|
2102
2128
|
}, h = this.queuedByKey.get(t.tile.key);
|
|
2103
|
-
h ? (h.tile =
|
|
2129
|
+
h ? (h.tile = l.tile, h.readyAt = Math.min(h.readyAt, l.readyAt), h.attempt = Math.max(h.attempt, l.attempt)) : (this.queue.push(l), this.queuedByKey.set(l.tile.key, l)), this.sortQueue();
|
|
2104
2130
|
return;
|
|
2105
2131
|
}
|
|
2106
2132
|
this.failedCount += 1, this.onTileError?.(t.tile, o, t.attempt + 1);
|
|
@@ -2122,12 +2148,12 @@ class Xn {
|
|
|
2122
2148
|
this.onStateChange?.(this.getSnapshot());
|
|
2123
2149
|
}
|
|
2124
2150
|
}
|
|
2125
|
-
const
|
|
2126
|
-
class
|
|
2151
|
+
const ke = 0.35;
|
|
2152
|
+
class ir {
|
|
2127
2153
|
constructor() {
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2154
|
+
d(this, "viewportWidth", 1);
|
|
2155
|
+
d(this, "viewportHeight", 1);
|
|
2156
|
+
d(this, "viewState", {
|
|
2131
2157
|
zoom: 1,
|
|
2132
2158
|
offsetX: 0,
|
|
2133
2159
|
offsetY: 0,
|
|
@@ -2158,14 +2184,14 @@ class Vn {
|
|
|
2158
2184
|
this.viewState.offsetX = t - this.viewportWidth / (2 * r), this.viewState.offsetY = n - this.viewportHeight / (2 * r);
|
|
2159
2185
|
}
|
|
2160
2186
|
screenToWorld(t, n) {
|
|
2161
|
-
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = (t - this.viewportWidth * 0.5) / i,
|
|
2162
|
-
return [o + a * h -
|
|
2187
|
+
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = (t - this.viewportWidth * 0.5) / i, c = (n - this.viewportHeight * 0.5) / i, l = Gt(r.rotationDeg), h = Math.cos(l), w = Math.sin(l);
|
|
2188
|
+
return [o + a * h - c * w, s + a * w + c * h];
|
|
2163
2189
|
}
|
|
2164
2190
|
worldToScreen(t, n) {
|
|
2165
|
-
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o,
|
|
2191
|
+
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, c = n - s, l = Gt(r.rotationDeg), h = Math.cos(l), w = Math.sin(l), f = a * h + c * w, m = -a * w + c * h;
|
|
2166
2192
|
return [
|
|
2167
|
-
this.viewportWidth * 0.5 +
|
|
2168
|
-
this.viewportHeight * 0.5 +
|
|
2193
|
+
this.viewportWidth * 0.5 + f * i,
|
|
2194
|
+
this.viewportHeight * 0.5 + m * i
|
|
2169
2195
|
];
|
|
2170
2196
|
}
|
|
2171
2197
|
getViewCorners() {
|
|
@@ -2178,75 +2204,75 @@ class Vn {
|
|
|
2178
2204
|
];
|
|
2179
2205
|
}
|
|
2180
2206
|
getMatrix() {
|
|
2181
|
-
const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i =
|
|
2182
|
-
return new Float32Array([a,
|
|
2207
|
+
const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i = Gt(this.viewState.rotationDeg), o = Math.cos(i), s = Math.sin(i), a = 2 * t * o / this.viewportWidth, c = 2 * t * s / this.viewportWidth, l = 2 * t * s / this.viewportHeight, h = -2 * t * o / this.viewportHeight, w = -(a * n + c * r), f = -(l * n + h * r);
|
|
2208
|
+
return new Float32Array([a, l, 0, c, h, 0, w, f, 1]);
|
|
2183
2209
|
}
|
|
2184
2210
|
}
|
|
2185
|
-
function
|
|
2211
|
+
function Gt(e) {
|
|
2186
2212
|
return e * Math.PI / 180;
|
|
2187
2213
|
}
|
|
2188
|
-
function
|
|
2214
|
+
function Ye() {
|
|
2189
2215
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2190
2216
|
}
|
|
2191
|
-
function
|
|
2217
|
+
function Nt(e, t, n) {
|
|
2192
2218
|
const r = e.getUniformLocation(t, n);
|
|
2193
2219
|
if (!r)
|
|
2194
2220
|
throw new Error(`uniform location lookup failed: ${n}`);
|
|
2195
2221
|
return r;
|
|
2196
2222
|
}
|
|
2197
|
-
function
|
|
2223
|
+
function he(e, t) {
|
|
2198
2224
|
return !e || !t ? e === t : e.buffer === t.buffer && e.byteOffset === t.byteOffset && e.byteLength === t.byteLength;
|
|
2199
2225
|
}
|
|
2200
|
-
class
|
|
2226
|
+
class or {
|
|
2201
2227
|
constructor(t, n, r = {}) {
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
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) :
|
|
2228
|
+
d(this, "canvas");
|
|
2229
|
+
d(this, "source");
|
|
2230
|
+
d(this, "gl");
|
|
2231
|
+
d(this, "camera", new ir());
|
|
2232
|
+
d(this, "onViewStateChange");
|
|
2233
|
+
d(this, "onStats");
|
|
2234
|
+
d(this, "onTileError");
|
|
2235
|
+
d(this, "onContextLost");
|
|
2236
|
+
d(this, "onContextRestored");
|
|
2237
|
+
d(this, "resizeObserver");
|
|
2238
|
+
d(this, "tileProgram");
|
|
2239
|
+
d(this, "pointProgram");
|
|
2240
|
+
d(this, "tileScheduler");
|
|
2241
|
+
d(this, "authToken");
|
|
2242
|
+
d(this, "destroyed", !1);
|
|
2243
|
+
d(this, "contextLost", !1);
|
|
2244
|
+
d(this, "frame", null);
|
|
2245
|
+
d(this, "frameSerial", 0);
|
|
2246
|
+
d(this, "dragging", !1);
|
|
2247
|
+
d(this, "interactionMode", "none");
|
|
2248
|
+
d(this, "rotateLastAngleRad", null);
|
|
2249
|
+
d(this, "pointerId", null);
|
|
2250
|
+
d(this, "lastPointerX", 0);
|
|
2251
|
+
d(this, "lastPointerY", 0);
|
|
2252
|
+
d(this, "interactionLocked", !1);
|
|
2253
|
+
d(this, "ctrlDragRotate", !0);
|
|
2254
|
+
d(this, "rotationDragSensitivityDegPerPixel", 0.35);
|
|
2255
|
+
d(this, "maxCacheTiles");
|
|
2256
|
+
d(this, "fitZoom", 1);
|
|
2257
|
+
d(this, "minZoom", 1e-6);
|
|
2258
|
+
d(this, "maxZoom", 1);
|
|
2259
|
+
d(this, "currentTier", 0);
|
|
2260
|
+
d(this, "pointCount", 0);
|
|
2261
|
+
d(this, "usePointIndices", !1);
|
|
2262
|
+
d(this, "pointBuffersDirty", !0);
|
|
2263
|
+
d(this, "pointPaletteSize", 1);
|
|
2264
|
+
d(this, "lastPointData", null);
|
|
2265
|
+
d(this, "lastPointPalette", null);
|
|
2266
|
+
d(this, "cache", /* @__PURE__ */ new Map());
|
|
2267
|
+
d(this, "boundPointerDown");
|
|
2268
|
+
d(this, "boundPointerMove");
|
|
2269
|
+
d(this, "boundPointerUp");
|
|
2270
|
+
d(this, "boundWheel");
|
|
2271
|
+
d(this, "boundDoubleClick");
|
|
2272
|
+
d(this, "boundContextMenu");
|
|
2273
|
+
d(this, "boundContextLost");
|
|
2274
|
+
d(this, "boundContextRestored");
|
|
2275
|
+
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) : ke;
|
|
2250
2276
|
const i = t.getContext("webgl2", {
|
|
2251
2277
|
alpha: !1,
|
|
2252
2278
|
antialias: !1,
|
|
@@ -2256,7 +2282,7 @@ class On {
|
|
|
2256
2282
|
});
|
|
2257
2283
|
if (!i)
|
|
2258
2284
|
throw new Error("WebGL2 not supported");
|
|
2259
|
-
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new
|
|
2285
|
+
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new rr({
|
|
2260
2286
|
authToken: this.authToken,
|
|
2261
2287
|
maxConcurrency: r.tileScheduler?.maxConcurrency ?? 12,
|
|
2262
2288
|
maxRetries: r.tileScheduler?.maxRetries ?? 2,
|
|
@@ -2273,7 +2299,7 @@ class On {
|
|
|
2273
2299
|
}
|
|
2274
2300
|
setViewState(t) {
|
|
2275
2301
|
const n = { ...t };
|
|
2276
|
-
typeof n.zoom == "number" && (n.zoom =
|
|
2302
|
+
typeof n.zoom == "number" && (n.zoom = j(n.zoom, this.minZoom, this.maxZoom)), this.camera.setViewState(n), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2277
2303
|
}
|
|
2278
2304
|
getViewState() {
|
|
2279
2305
|
return this.camera.getViewState();
|
|
@@ -2310,7 +2336,7 @@ class On {
|
|
|
2310
2336
|
t.paletteIndices.length
|
|
2311
2337
|
)
|
|
2312
2338
|
), r = t.positions.subarray(0, n * 2), i = t.paletteIndices.subarray(0, n), o = t.drawIndices instanceof Uint32Array, s = o ? this.sanitizeDrawIndices(t.drawIndices, n) : null, a = this.lastPointData;
|
|
2313
|
-
let
|
|
2339
|
+
let c = this.pointBuffersDirty || !a || a.count !== n || !he(a.positions, r) || !he(a.paletteIndices, i), l = this.pointBuffersDirty || o && (!a?.drawIndices || !he(a.drawIndices, s)) || !o && !!a?.drawIndices;
|
|
2314
2340
|
if (this.lastPointData = {
|
|
2315
2341
|
count: n,
|
|
2316
2342
|
positions: r,
|
|
@@ -2318,15 +2344,15 @@ class On {
|
|
|
2318
2344
|
drawIndices: o ? s ?? void 0 : void 0
|
|
2319
2345
|
}, this.contextLost || this.gl.isContextLost()) return;
|
|
2320
2346
|
const h = this.gl;
|
|
2321
|
-
|
|
2347
|
+
c && (h.bindBuffer(h.ARRAY_BUFFER, this.pointProgram.posBuffer), h.bufferData(h.ARRAY_BUFFER, this.lastPointData.positions, h.STATIC_DRAW), h.bindBuffer(h.ARRAY_BUFFER, this.pointProgram.termBuffer), h.bufferData(
|
|
2322
2348
|
h.ARRAY_BUFFER,
|
|
2323
2349
|
this.lastPointData.paletteIndices,
|
|
2324
2350
|
h.STATIC_DRAW
|
|
2325
|
-
), h.bindBuffer(h.ARRAY_BUFFER, null)), o &&
|
|
2351
|
+
), h.bindBuffer(h.ARRAY_BUFFER, null)), o && l && (h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, this.pointProgram.indexBuffer), h.bufferData(
|
|
2326
2352
|
h.ELEMENT_ARRAY_BUFFER,
|
|
2327
2353
|
s ?? new Uint32Array(0),
|
|
2328
2354
|
h.DYNAMIC_DRAW
|
|
2329
|
-
), h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, null)), this.usePointIndices = o, this.pointCount = o ? s?.length ?? 0 : this.lastPointData.count, (
|
|
2355
|
+
), h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, null)), this.usePointIndices = o, this.pointCount = o ? s?.length ?? 0 : this.lastPointData.count, (c || l) && (this.pointBuffersDirty = !1), this.requestRender();
|
|
2330
2356
|
}
|
|
2331
2357
|
sanitizeDrawIndices(t, n) {
|
|
2332
2358
|
if (n <= 0 || t.length === 0)
|
|
@@ -2396,35 +2422,35 @@ class On {
|
|
|
2396
2422
|
];
|
|
2397
2423
|
let i = r[0][1];
|
|
2398
2424
|
for (let s = 1; s < r.length; s += 1) {
|
|
2399
|
-
const [a,
|
|
2425
|
+
const [a, c] = r[s - 1], [l, h] = r[s];
|
|
2400
2426
|
if (n <= a) break;
|
|
2401
|
-
const
|
|
2402
|
-
i =
|
|
2427
|
+
const w = j((n - a) / Math.max(1e-6, l - a), 0, 1);
|
|
2428
|
+
i = c + (h - c) * w;
|
|
2403
2429
|
}
|
|
2404
2430
|
const o = r[r.length - 1];
|
|
2405
|
-
return n > o[0] && (i += (n - o[0]) * 4),
|
|
2431
|
+
return n > o[0] && (i += (n - o[0]) * 4), j(i, 2.2, 36);
|
|
2406
2432
|
}
|
|
2407
2433
|
fitToImage() {
|
|
2408
2434
|
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;
|
|
2409
2435
|
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);
|
|
2410
2436
|
const s = n / o, a = r / o;
|
|
2411
2437
|
this.camera.setViewState({
|
|
2412
|
-
zoom:
|
|
2438
|
+
zoom: j(o, this.minZoom, this.maxZoom),
|
|
2413
2439
|
offsetX: (this.source.width - s) * 0.5,
|
|
2414
2440
|
offsetY: (this.source.height - a) * 0.5,
|
|
2415
2441
|
rotationDeg: 0
|
|
2416
2442
|
}), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2417
2443
|
}
|
|
2418
2444
|
zoomBy(t, n, r) {
|
|
2419
|
-
const i = this.camera.getViewState(), o =
|
|
2445
|
+
const i = this.camera.getViewState(), o = j(i.zoom * t, this.minZoom, this.maxZoom);
|
|
2420
2446
|
if (o === i.zoom) return;
|
|
2421
2447
|
const [s, a] = this.camera.screenToWorld(n, r);
|
|
2422
2448
|
this.camera.setViewState({ zoom: o });
|
|
2423
|
-
const
|
|
2449
|
+
const c = this.camera.getViewport(), l = n - c.width * 0.5, h = r - c.height * 0.5, w = Gt(this.camera.getViewState().rotationDeg), f = Math.cos(w), m = Math.sin(w), y = l / o * f - h / o * m, b = l / o * m + h / o * f;
|
|
2424
2450
|
this.camera.setCenter(s - y, a - b), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2425
2451
|
}
|
|
2426
2452
|
clampViewState() {
|
|
2427
|
-
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(),
|
|
2453
|
+
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(), c = n * 0.5, l = r * 0.5, h = c - i, w = this.source.width - c + i, f = l - o, m = this.source.height - l + o, y = h <= w ? j(s, h, w) : this.source.width * 0.5, b = f <= m ? j(a, f, m) : this.source.height * 0.5;
|
|
2428
2454
|
this.camera.setCenter(y, b);
|
|
2429
2455
|
}
|
|
2430
2456
|
emitViewState() {
|
|
@@ -2432,7 +2458,7 @@ class On {
|
|
|
2432
2458
|
}
|
|
2433
2459
|
selectTier() {
|
|
2434
2460
|
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t);
|
|
2435
|
-
return
|
|
2461
|
+
return j(Math.floor(n), 0, this.source.maxTierZoom);
|
|
2436
2462
|
}
|
|
2437
2463
|
getViewBounds() {
|
|
2438
2464
|
const t = this.camera.getViewCorners();
|
|
@@ -2447,40 +2473,40 @@ class On {
|
|
|
2447
2473
|
getVisibleTiles() {
|
|
2448
2474
|
const t = this.selectTier();
|
|
2449
2475
|
this.currentTier = t;
|
|
2450
|
-
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)),
|
|
2451
|
-
Math.floor(
|
|
2476
|
+
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)), c = n[0], l = n[1], h = n[2], w = n[3], f = j(
|
|
2477
|
+
Math.floor(c / r / this.source.tileSize),
|
|
2452
2478
|
0,
|
|
2453
2479
|
s - 1
|
|
2454
|
-
),
|
|
2480
|
+
), m = j(
|
|
2455
2481
|
Math.floor((h - 1) / r / this.source.tileSize),
|
|
2456
2482
|
0,
|
|
2457
2483
|
s - 1
|
|
2458
|
-
), y =
|
|
2459
|
-
Math.floor(
|
|
2484
|
+
), y = j(
|
|
2485
|
+
Math.floor(l / r / this.source.tileSize),
|
|
2460
2486
|
0,
|
|
2461
2487
|
a - 1
|
|
2462
|
-
), b =
|
|
2463
|
-
Math.floor((
|
|
2488
|
+
), b = j(
|
|
2489
|
+
Math.floor((w - 1) / r / this.source.tileSize),
|
|
2464
2490
|
0,
|
|
2465
2491
|
a - 1
|
|
2466
2492
|
);
|
|
2467
|
-
if (
|
|
2493
|
+
if (f > m || y > b)
|
|
2468
2494
|
return [];
|
|
2469
|
-
const
|
|
2470
|
-
for (let
|
|
2471
|
-
for (let
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2474
|
-
key: `${t}/${
|
|
2495
|
+
const v = (c + h) * 0.5 / r / this.source.tileSize, S = (l + w) * 0.5 / r / this.source.tileSize, L = [];
|
|
2496
|
+
for (let R = y; R <= b; R += 1)
|
|
2497
|
+
for (let W = f; W <= m; W += 1) {
|
|
2498
|
+
const yt = W * this.source.tileSize * r, st = R * this.source.tileSize * r, X = Math.min((W + 1) * this.source.tileSize, i) * r, At = Math.min((R + 1) * this.source.tileSize, o) * r, mt = W - v, lt = R - S;
|
|
2499
|
+
L.push({
|
|
2500
|
+
key: `${t}/${W}/${R}`,
|
|
2475
2501
|
tier: t,
|
|
2476
|
-
x:
|
|
2477
|
-
y:
|
|
2478
|
-
bounds: [
|
|
2479
|
-
distance2:
|
|
2480
|
-
url:
|
|
2502
|
+
x: W,
|
|
2503
|
+
y: R,
|
|
2504
|
+
bounds: [yt, st, X, At],
|
|
2505
|
+
distance2: mt * mt + lt * lt,
|
|
2506
|
+
url: Ze(this.source, t, W, R)
|
|
2481
2507
|
});
|
|
2482
2508
|
}
|
|
2483
|
-
return
|
|
2509
|
+
return L.sort((R, W) => R.distance2 - W.distance2), L;
|
|
2484
2510
|
}
|
|
2485
2511
|
trimCache() {
|
|
2486
2512
|
if (this.cache.size <= this.maxCacheTiles) return;
|
|
@@ -2494,60 +2520,60 @@ class On {
|
|
|
2494
2520
|
}
|
|
2495
2521
|
render() {
|
|
2496
2522
|
if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
|
|
2497
|
-
const t =
|
|
2523
|
+
const t = Ye();
|
|
2498
2524
|
this.frameSerial += 1;
|
|
2499
2525
|
const n = this.gl, r = this.tileProgram, i = this.pointProgram;
|
|
2500
2526
|
n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
|
|
2501
|
-
const o = this.getVisibleTiles(), s = this.getViewBounds(), a = new Set(o.map((
|
|
2527
|
+
const o = this.getVisibleTiles(), s = this.getViewBounds(), a = new Set(o.map((f) => f.key));
|
|
2502
2528
|
n.useProgram(r.program), n.bindVertexArray(r.vao), n.uniformMatrix3fv(r.uCamera, !1, this.camera.getMatrix()), n.uniform1i(r.uTexture, 0);
|
|
2503
|
-
const
|
|
2504
|
-
for (const [,
|
|
2505
|
-
a.has(
|
|
2506
|
-
|
|
2507
|
-
for (const
|
|
2508
|
-
|
|
2529
|
+
const c = [];
|
|
2530
|
+
for (const [, f] of this.cache)
|
|
2531
|
+
a.has(f.key) || this.intersectsBounds(f.bounds, s) && c.push(f);
|
|
2532
|
+
c.sort((f, m) => f.tier - m.tier);
|
|
2533
|
+
for (const f of c)
|
|
2534
|
+
f.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, f.texture), n.uniform4f(
|
|
2509
2535
|
r.uBounds,
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2536
|
+
f.bounds[0],
|
|
2537
|
+
f.bounds[1],
|
|
2538
|
+
f.bounds[2],
|
|
2539
|
+
f.bounds[3]
|
|
2514
2540
|
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4);
|
|
2515
|
-
let
|
|
2541
|
+
let l = 0;
|
|
2516
2542
|
const h = [];
|
|
2517
|
-
for (const
|
|
2518
|
-
const
|
|
2519
|
-
if (!
|
|
2520
|
-
h.push(
|
|
2543
|
+
for (const f of o) {
|
|
2544
|
+
const m = this.cache.get(f.key);
|
|
2545
|
+
if (!m) {
|
|
2546
|
+
h.push(f);
|
|
2521
2547
|
continue;
|
|
2522
2548
|
}
|
|
2523
|
-
|
|
2549
|
+
m.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, m.texture), n.uniform4f(
|
|
2524
2550
|
r.uBounds,
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4),
|
|
2551
|
+
m.bounds[0],
|
|
2552
|
+
m.bounds[1],
|
|
2553
|
+
m.bounds[2],
|
|
2554
|
+
m.bounds[3]
|
|
2555
|
+
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4), l += 1;
|
|
2530
2556
|
}
|
|
2531
2557
|
this.tileScheduler.schedule(h), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
|
|
2532
|
-
let
|
|
2533
|
-
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),
|
|
2534
|
-
const
|
|
2558
|
+
let w = 0;
|
|
2559
|
+
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), w = this.pointCount), this.onStats) {
|
|
2560
|
+
const f = this.tileScheduler.getSnapshot(), m = l, y = h.length, b = c.length + l + (w > 0 ? 1 : 0);
|
|
2535
2561
|
this.onStats({
|
|
2536
2562
|
tier: this.currentTier,
|
|
2537
2563
|
visible: o.length,
|
|
2538
|
-
rendered:
|
|
2539
|
-
points:
|
|
2540
|
-
fallback:
|
|
2564
|
+
rendered: l,
|
|
2565
|
+
points: w,
|
|
2566
|
+
fallback: c.length,
|
|
2541
2567
|
cache: this.cache.size,
|
|
2542
|
-
inflight:
|
|
2543
|
-
queued:
|
|
2544
|
-
retries:
|
|
2545
|
-
failed:
|
|
2546
|
-
aborted:
|
|
2547
|
-
cacheHits:
|
|
2568
|
+
inflight: f.inflight,
|
|
2569
|
+
queued: f.queued,
|
|
2570
|
+
retries: f.retries,
|
|
2571
|
+
failed: f.failed,
|
|
2572
|
+
aborted: f.aborted,
|
|
2573
|
+
cacheHits: m,
|
|
2548
2574
|
cacheMisses: y,
|
|
2549
2575
|
drawCalls: b,
|
|
2550
|
-
frameMs:
|
|
2576
|
+
frameMs: Ye() - t
|
|
2551
2577
|
});
|
|
2552
2578
|
}
|
|
2553
2579
|
}
|
|
@@ -2571,15 +2597,15 @@ class On {
|
|
|
2571
2597
|
if (this.lastPointerX = t.clientX, this.lastPointerY = t.clientY, this.interactionMode === "rotate") {
|
|
2572
2598
|
const i = this.getPointerAngleRad(t.clientX, t.clientY), o = this.rotateLastAngleRad;
|
|
2573
2599
|
if (this.rotateLastAngleRad = i, o !== null) {
|
|
2574
|
-
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)),
|
|
2600
|
+
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), c = this.rotationDragSensitivityDegPerPixel / ke, l = this.camera.getViewState();
|
|
2575
2601
|
this.camera.setViewState({
|
|
2576
|
-
rotationDeg:
|
|
2602
|
+
rotationDeg: l.rotationDeg - a * 180 / Math.PI * c
|
|
2577
2603
|
});
|
|
2578
2604
|
}
|
|
2579
2605
|
} else {
|
|
2580
|
-
const i = this.camera.getViewState(), o = Math.max(1e-6, i.zoom), s =
|
|
2606
|
+
const i = this.camera.getViewState(), o = Math.max(1e-6, i.zoom), s = Gt(i.rotationDeg), a = Math.cos(s), c = Math.sin(s), l = (n * a - r * c) / o, h = (n * c + r * a) / o;
|
|
2581
2607
|
this.camera.setViewState({
|
|
2582
|
-
offsetX: i.offsetX -
|
|
2608
|
+
offsetX: i.offsetX - l,
|
|
2583
2609
|
offsetY: i.offsetY - h
|
|
2584
2610
|
});
|
|
2585
2611
|
}
|
|
@@ -2625,7 +2651,7 @@ class On {
|
|
|
2625
2651
|
}
|
|
2626
2652
|
}
|
|
2627
2653
|
initTileProgram() {
|
|
2628
|
-
const t = this.gl, i =
|
|
2654
|
+
const t = this.gl, i = Re(t, `#version 300 es
|
|
2629
2655
|
precision highp float;
|
|
2630
2656
|
in vec2 aUnit;
|
|
2631
2657
|
in vec2 aUv;
|
|
@@ -2647,21 +2673,21 @@ class On {
|
|
|
2647
2673
|
out vec4 outColor;
|
|
2648
2674
|
void main() {
|
|
2649
2675
|
outColor = texture(uTexture, vUv);
|
|
2650
|
-
}`), o =
|
|
2651
|
-
if (!
|
|
2676
|
+
}`), o = Nt(t, i, "uCamera"), s = Nt(t, i, "uBounds"), a = Nt(t, i, "uTexture"), c = t.createVertexArray(), l = t.createBuffer();
|
|
2677
|
+
if (!c || !l)
|
|
2652
2678
|
throw new Error("buffer allocation failed");
|
|
2653
|
-
t.bindVertexArray(
|
|
2679
|
+
t.bindVertexArray(c), t.bindBuffer(t.ARRAY_BUFFER, l), t.bufferData(
|
|
2654
2680
|
t.ARRAY_BUFFER,
|
|
2655
2681
|
new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]),
|
|
2656
2682
|
t.STATIC_DRAW
|
|
2657
2683
|
);
|
|
2658
|
-
const h = t.getAttribLocation(i, "aUnit"),
|
|
2659
|
-
if (h < 0 ||
|
|
2684
|
+
const h = t.getAttribLocation(i, "aUnit"), w = t.getAttribLocation(i, "aUv");
|
|
2685
|
+
if (h < 0 || w < 0)
|
|
2660
2686
|
throw new Error("tile attribute lookup failed");
|
|
2661
|
-
return t.enableVertexAttribArray(h), t.enableVertexAttribArray(
|
|
2687
|
+
return t.enableVertexAttribArray(h), t.enableVertexAttribArray(w), t.vertexAttribPointer(h, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(w, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), { program: i, vao: c, vbo: l, uCamera: o, uBounds: s, uTexture: a };
|
|
2662
2688
|
}
|
|
2663
2689
|
initPointProgram() {
|
|
2664
|
-
const t = this.gl, i =
|
|
2690
|
+
const t = this.gl, i = Re(t, `#version 300 es
|
|
2665
2691
|
precision highp float;
|
|
2666
2692
|
in vec2 aPosition;
|
|
2667
2693
|
in uint aTerm;
|
|
@@ -2700,18 +2726,18 @@ class On {
|
|
|
2700
2726
|
if (alpha <= 0.001) discard;
|
|
2701
2727
|
|
|
2702
2728
|
outColor = vec4(color.rgb * alpha, alpha);
|
|
2703
|
-
}`), o =
|
|
2704
|
-
if (!
|
|
2729
|
+
}`), o = Nt(t, i, "uCamera"), s = Nt(t, i, "uPointSize"), a = Nt(t, i, "uPalette"), c = Nt(t, i, "uPaletteSize"), l = t.createVertexArray(), h = t.createBuffer(), w = t.createBuffer(), f = t.createBuffer(), m = t.createTexture();
|
|
2730
|
+
if (!l || !h || !w || !f || !m)
|
|
2705
2731
|
throw new Error("point buffer allocation failed");
|
|
2706
|
-
t.bindVertexArray(
|
|
2732
|
+
t.bindVertexArray(l), t.bindBuffer(t.ARRAY_BUFFER, h), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
2707
2733
|
const y = t.getAttribLocation(i, "aPosition");
|
|
2708
2734
|
if (y < 0)
|
|
2709
2735
|
throw new Error("point position attribute not found");
|
|
2710
|
-
t.enableVertexAttribArray(y), t.vertexAttribPointer(y, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER,
|
|
2736
|
+
t.enableVertexAttribArray(y), t.vertexAttribPointer(y, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, w), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
2711
2737
|
const b = t.getAttribLocation(i, "aTerm");
|
|
2712
2738
|
if (b < 0)
|
|
2713
2739
|
throw new Error("point term attribute not found");
|
|
2714
|
-
return t.enableVertexAttribArray(b), t.vertexAttribIPointer(b, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,
|
|
2740
|
+
return t.enableVertexAttribArray(b), t.vertexAttribIPointer(b, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, f), 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, m), 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(
|
|
2715
2741
|
t.TEXTURE_2D,
|
|
2716
2742
|
0,
|
|
2717
2743
|
t.RGBA,
|
|
@@ -2723,15 +2749,15 @@ class On {
|
|
|
2723
2749
|
new Uint8Array([160, 160, 160, 255])
|
|
2724
2750
|
), t.bindTexture(t.TEXTURE_2D, null), {
|
|
2725
2751
|
program: i,
|
|
2726
|
-
vao:
|
|
2752
|
+
vao: l,
|
|
2727
2753
|
posBuffer: h,
|
|
2728
|
-
termBuffer:
|
|
2729
|
-
indexBuffer:
|
|
2730
|
-
paletteTexture:
|
|
2754
|
+
termBuffer: w,
|
|
2755
|
+
indexBuffer: f,
|
|
2756
|
+
paletteTexture: m,
|
|
2731
2757
|
uCamera: o,
|
|
2732
2758
|
uPointSize: s,
|
|
2733
2759
|
uPalette: a,
|
|
2734
|
-
uPaletteSize:
|
|
2760
|
+
uPaletteSize: c
|
|
2735
2761
|
};
|
|
2736
2762
|
}
|
|
2737
2763
|
handleTileLoaded(t, n) {
|
|
@@ -2758,37 +2784,37 @@ class On {
|
|
|
2758
2784
|
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;
|
|
2759
2785
|
}
|
|
2760
2786
|
}
|
|
2761
|
-
const
|
|
2787
|
+
const de = [], sr = [], ar = {
|
|
2762
2788
|
count: 0,
|
|
2763
2789
|
positions: new Float32Array(0),
|
|
2764
2790
|
paletteIndices: new Uint16Array(0)
|
|
2765
2791
|
};
|
|
2766
|
-
function
|
|
2792
|
+
function pe(e, t) {
|
|
2767
2793
|
return e.id ?? t;
|
|
2768
2794
|
}
|
|
2769
|
-
function
|
|
2795
|
+
function cr(e, t) {
|
|
2770
2796
|
if (!Array.isArray(t) || t.length < 3) return !1;
|
|
2771
2797
|
const [n, r] = e;
|
|
2772
2798
|
let i = !1;
|
|
2773
2799
|
for (let o = 0, s = t.length - 1; o < t.length; s = o++) {
|
|
2774
|
-
const [a,
|
|
2775
|
-
|
|
2800
|
+
const [a, c] = t[o], [l, h] = t[s];
|
|
2801
|
+
c > r != h > r && n < (l - a) * (r - c) / Math.max(1e-12, h - c) + a && (i = !i);
|
|
2776
2802
|
}
|
|
2777
2803
|
return i;
|
|
2778
2804
|
}
|
|
2779
|
-
function
|
|
2805
|
+
function We(e, t) {
|
|
2780
2806
|
for (let n = t.length - 1; n >= 0; n -= 1) {
|
|
2781
2807
|
const r = t[n];
|
|
2782
|
-
if (r?.coordinates?.length &&
|
|
2808
|
+
if (r?.coordinates?.length && cr(e, r.coordinates))
|
|
2783
2809
|
return {
|
|
2784
2810
|
region: r,
|
|
2785
2811
|
regionIndex: n,
|
|
2786
|
-
regionId:
|
|
2812
|
+
regionId: pe(r, n)
|
|
2787
2813
|
};
|
|
2788
2814
|
}
|
|
2789
2815
|
return null;
|
|
2790
2816
|
}
|
|
2791
|
-
function
|
|
2817
|
+
function vr({
|
|
2792
2818
|
source: e,
|
|
2793
2819
|
viewState: t,
|
|
2794
2820
|
onViewStateChange: n,
|
|
@@ -2797,40 +2823,44 @@ function sr({
|
|
|
2797
2823
|
onContextLost: o,
|
|
2798
2824
|
onContextRestored: s,
|
|
2799
2825
|
debugOverlay: a = !1,
|
|
2800
|
-
debugOverlayStyle:
|
|
2801
|
-
fitNonce:
|
|
2826
|
+
debugOverlayStyle: c,
|
|
2827
|
+
fitNonce: l = 0,
|
|
2802
2828
|
rotationResetNonce: h = 0,
|
|
2803
|
-
authToken:
|
|
2804
|
-
ctrlDragRotate:
|
|
2805
|
-
pointData:
|
|
2829
|
+
authToken: w = "",
|
|
2830
|
+
ctrlDragRotate: f = !0,
|
|
2831
|
+
pointData: m = null,
|
|
2806
2832
|
pointPalette: y = null,
|
|
2807
2833
|
roiRegions: b,
|
|
2808
|
-
roiPolygons:
|
|
2809
|
-
clipPointsToRois:
|
|
2810
|
-
clipMode:
|
|
2811
|
-
onClipStats:
|
|
2812
|
-
onRoiPointGroups:
|
|
2813
|
-
roiPaletteIndexToTermId:
|
|
2814
|
-
interactionLock:
|
|
2815
|
-
drawTool:
|
|
2816
|
-
stampOptions:
|
|
2817
|
-
regionStrokeStyle:
|
|
2818
|
-
regionStrokeHoverStyle:
|
|
2819
|
-
regionStrokeActiveStyle:
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2834
|
+
roiPolygons: v,
|
|
2835
|
+
clipPointsToRois: S = !1,
|
|
2836
|
+
clipMode: L = "worker",
|
|
2837
|
+
onClipStats: R,
|
|
2838
|
+
onRoiPointGroups: W,
|
|
2839
|
+
roiPaletteIndexToTermId: yt,
|
|
2840
|
+
interactionLock: st = !1,
|
|
2841
|
+
drawTool: X = "cursor",
|
|
2842
|
+
stampOptions: At,
|
|
2843
|
+
regionStrokeStyle: mt,
|
|
2844
|
+
regionStrokeHoverStyle: lt,
|
|
2845
|
+
regionStrokeActiveStyle: Rt,
|
|
2846
|
+
patchStrokeStyle: J,
|
|
2847
|
+
resolveRegionStrokeStyle: rt,
|
|
2848
|
+
overlayShapes: V,
|
|
2849
|
+
customLayers: ht,
|
|
2850
|
+
patchRegions: Ct,
|
|
2851
|
+
regionLabelStyle: at,
|
|
2852
|
+
onPointerWorldMove: x,
|
|
2853
|
+
onRegionHover: T,
|
|
2854
|
+
onRegionClick: E,
|
|
2855
|
+
onActiveRegionChange: k,
|
|
2856
|
+
onDrawComplete: O,
|
|
2857
|
+
onPatchComplete: gt,
|
|
2858
|
+
showOverviewMap: tt = !1,
|
|
2859
|
+
overviewMapOptions: q,
|
|
2860
|
+
className: et,
|
|
2861
|
+
style: ct
|
|
2832
2862
|
}) {
|
|
2833
|
-
const
|
|
2863
|
+
const ut = Z(null), U = Z(null), P = Z(null), Y = Z(null), $ = Z(n), Q = Z(r), dt = Z(a), [Lt, Tt] = Yt(!0), [vt, bt] = Yt(null), [u, g] = Yt(null), [M, _] = Yt(null), [A, C] = Yt(null), I = Z(null), G = Z(0), it = b ?? de, ot = Ct ?? de, St = v ?? sr, It = (ht?.length ?? 0) > 0, Vt = H(() => ({ position: "relative", width: "100%", height: "100%", ...ct }), [ct]), ie = H(
|
|
2834
2864
|
() => ({
|
|
2835
2865
|
position: "absolute",
|
|
2836
2866
|
top: 8,
|
|
@@ -2849,171 +2879,192 @@ function sr({
|
|
|
2849
2879
|
border: "1px solid rgba(173, 216, 255, 0.28)",
|
|
2850
2880
|
borderRadius: 8,
|
|
2851
2881
|
boxShadow: "0 8px 22px rgba(0,0,0,0.35)",
|
|
2852
|
-
...
|
|
2882
|
+
...c
|
|
2853
2883
|
}),
|
|
2854
|
-
[
|
|
2855
|
-
),
|
|
2884
|
+
[c]
|
|
2885
|
+
), ft = H(() => it.length > 0 ? it : St.length === 0 ? de : St.map((p, B) => ({
|
|
2856
2886
|
id: B,
|
|
2857
|
-
coordinates:
|
|
2858
|
-
})), [
|
|
2859
|
-
|
|
2860
|
-
const
|
|
2887
|
+
coordinates: p
|
|
2888
|
+
})), [it, St]), Dt = H(() => ft.map((p) => p.coordinates), [ft]), [qt, $t] = Yt(m);
|
|
2889
|
+
z(() => {
|
|
2890
|
+
const p = ++G.current;
|
|
2861
2891
|
let B = !1;
|
|
2862
|
-
if (!
|
|
2863
|
-
return
|
|
2892
|
+
if (!S)
|
|
2893
|
+
return $t(m), () => {
|
|
2864
2894
|
B = !0;
|
|
2865
2895
|
};
|
|
2866
|
-
if (!
|
|
2867
|
-
return
|
|
2896
|
+
if (!m || !m.count || !m.positions || !m.paletteIndices)
|
|
2897
|
+
return $t(null), () => {
|
|
2868
2898
|
B = !0;
|
|
2869
2899
|
};
|
|
2870
|
-
if (
|
|
2871
|
-
return
|
|
2872
|
-
mode:
|
|
2900
|
+
if (Dt.length === 0)
|
|
2901
|
+
return $t(ar), R?.({
|
|
2902
|
+
mode: L,
|
|
2873
2903
|
durationMs: 0,
|
|
2874
|
-
inputCount:
|
|
2904
|
+
inputCount: m.count,
|
|
2875
2905
|
outputCount: 0,
|
|
2876
2906
|
polygonCount: 0
|
|
2877
2907
|
}), () => {
|
|
2878
2908
|
B = !0;
|
|
2879
2909
|
};
|
|
2880
|
-
const
|
|
2881
|
-
if (B ||
|
|
2882
|
-
const
|
|
2883
|
-
|
|
2884
|
-
mode:
|
|
2885
|
-
durationMs:
|
|
2886
|
-
inputCount:
|
|
2887
|
-
outputCount:
|
|
2888
|
-
polygonCount:
|
|
2889
|
-
usedWebGpu:
|
|
2890
|
-
candidateCount:
|
|
2891
|
-
bridgedToDraw:
|
|
2910
|
+
const N = (F, nt) => {
|
|
2911
|
+
if (B || p !== G.current) return;
|
|
2912
|
+
const oe = F?.drawIndices ? F.drawIndices.length : F?.count ?? 0;
|
|
2913
|
+
$t(F), R?.({
|
|
2914
|
+
mode: nt.mode,
|
|
2915
|
+
durationMs: nt.durationMs,
|
|
2916
|
+
inputCount: m.count,
|
|
2917
|
+
outputCount: oe,
|
|
2918
|
+
polygonCount: Dt.length,
|
|
2919
|
+
usedWebGpu: nt.usedWebGpu,
|
|
2920
|
+
candidateCount: nt.candidateCount,
|
|
2921
|
+
bridgedToDraw: nt.bridgedToDraw
|
|
2892
2922
|
});
|
|
2893
2923
|
};
|
|
2894
2924
|
return (async () => {
|
|
2895
|
-
if (
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2925
|
+
if (L === "sync") {
|
|
2926
|
+
const F = performance.now(), nt = re(m, Dt);
|
|
2927
|
+
N(nt, {
|
|
2898
2928
|
mode: "sync",
|
|
2899
|
-
durationMs: performance.now() -
|
|
2929
|
+
durationMs: performance.now() - F
|
|
2900
2930
|
});
|
|
2901
2931
|
return;
|
|
2902
2932
|
}
|
|
2903
|
-
if (
|
|
2904
|
-
const
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
durationMs: U.meta.durationMs,
|
|
2912
|
-
usedWebGpu: U.meta.usedWebGpu,
|
|
2913
|
-
candidateCount: U.meta.candidateCount,
|
|
2914
|
-
bridgedToDraw: U.meta.bridgedToDraw
|
|
2933
|
+
if (L === "hybrid-webgpu") {
|
|
2934
|
+
const F = await Hn(m, Dt, { bridgeToDraw: !0 });
|
|
2935
|
+
N(F.data, {
|
|
2936
|
+
mode: F.meta.mode,
|
|
2937
|
+
durationMs: F.meta.durationMs,
|
|
2938
|
+
usedWebGpu: F.meta.usedWebGpu,
|
|
2939
|
+
candidateCount: F.meta.candidateCount,
|
|
2940
|
+
bridgedToDraw: F.meta.bridgedToDraw
|
|
2915
2941
|
});
|
|
2916
2942
|
return;
|
|
2917
2943
|
}
|
|
2918
2944
|
try {
|
|
2919
|
-
const
|
|
2920
|
-
|
|
2921
|
-
mode:
|
|
2922
|
-
durationMs:
|
|
2945
|
+
const F = await Zn(m, Dt);
|
|
2946
|
+
N(F.data, {
|
|
2947
|
+
mode: F.meta.mode,
|
|
2948
|
+
durationMs: F.meta.durationMs
|
|
2923
2949
|
});
|
|
2924
2950
|
} catch {
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2951
|
+
const F = performance.now(), nt = re(m, Dt);
|
|
2952
|
+
N(nt, {
|
|
2927
2953
|
mode: "sync",
|
|
2928
|
-
durationMs: performance.now() -
|
|
2954
|
+
durationMs: performance.now() - F
|
|
2929
2955
|
});
|
|
2930
2956
|
}
|
|
2931
2957
|
})(), () => {
|
|
2932
2958
|
B = !0;
|
|
2933
2959
|
};
|
|
2934
|
-
}, [
|
|
2935
|
-
const
|
|
2936
|
-
return Number.isFinite(
|
|
2937
|
-
}, [
|
|
2938
|
-
const
|
|
2939
|
-
const
|
|
2940
|
-
return Number.isFinite(
|
|
2941
|
-
}, [
|
|
2942
|
-
const
|
|
2943
|
-
return Number.isFinite(
|
|
2944
|
-
}, [
|
|
2945
|
-
(
|
|
2946
|
-
|
|
2960
|
+
}, [S, L, m, Dt, R]), H(() => {
|
|
2961
|
+
const p = Number(q?.width ?? 220);
|
|
2962
|
+
return Number.isFinite(p) ? Math.max(64, p) : 220;
|
|
2963
|
+
}, [q?.width]);
|
|
2964
|
+
const ye = H(() => {
|
|
2965
|
+
const p = Number(q?.height ?? 140);
|
|
2966
|
+
return Number.isFinite(p) ? Math.max(48, p) : 140;
|
|
2967
|
+
}, [q?.height]), _t = H(() => {
|
|
2968
|
+
const p = Number(q?.margin ?? 16);
|
|
2969
|
+
return Number.isFinite(p) ? Math.max(0, p) : 16;
|
|
2970
|
+
}, [q?.margin]), Ht = q?.position || "bottom-right", zt = D(
|
|
2971
|
+
(p) => {
|
|
2972
|
+
g((B) => String(B) === String(p) ? B : (k?.(p), p));
|
|
2947
2973
|
},
|
|
2948
|
-
[
|
|
2974
|
+
[k]
|
|
2949
2975
|
);
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
}, [n]),
|
|
2953
|
-
|
|
2954
|
-
}, [r]),
|
|
2955
|
-
|
|
2976
|
+
z(() => {
|
|
2977
|
+
$.current = n;
|
|
2978
|
+
}, [n]), z(() => {
|
|
2979
|
+
Q.current = r;
|
|
2980
|
+
}, [r]), z(() => {
|
|
2981
|
+
dt.current = a, a || C(null);
|
|
2956
2982
|
}, [a]);
|
|
2957
|
-
const
|
|
2958
|
-
|
|
2959
|
-
}, []),
|
|
2960
|
-
`tier ${
|
|
2961
|
-
`tiles visible ${
|
|
2962
|
-
`cache size ${
|
|
2963
|
-
`queue inflight ${
|
|
2964
|
-
`points ${
|
|
2983
|
+
const xe = D((p) => {
|
|
2984
|
+
Q.current?.(p), dt.current && C(p);
|
|
2985
|
+
}, []), nn = H(() => A ? [
|
|
2986
|
+
`tier ${A.tier} | frame ${A.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${A.drawCalls ?? "-"}`,
|
|
2987
|
+
`tiles visible ${A.visible} | rendered ${A.rendered} | fallback ${A.fallback}`,
|
|
2988
|
+
`cache size ${A.cache} | hit ${A.cacheHits ?? "-"} | miss ${A.cacheMisses ?? "-"}`,
|
|
2989
|
+
`queue inflight ${A.inflight} | queued ${A.queued ?? "-"} | retries ${A.retries ?? "-"} | failed ${A.failed ?? "-"} | aborted ${A.aborted ?? "-"}`,
|
|
2990
|
+
`points ${A.points}`
|
|
2965
2991
|
].join(`
|
|
2966
|
-
`) : "stats: waiting for first frame...", [
|
|
2967
|
-
|
|
2968
|
-
!(
|
|
2969
|
-
const B =
|
|
2970
|
-
!(B === null ? !0 :
|
|
2992
|
+
`) : "stats: waiting for first frame...", [A]);
|
|
2993
|
+
z(() => {
|
|
2994
|
+
!(u === null ? !0 : ft.some((K, F) => String(pe(K, F)) === String(u))) && u !== null && zt(null);
|
|
2995
|
+
const B = I.current;
|
|
2996
|
+
!(B === null ? !0 : ft.some((K, F) => String(pe(K, F)) === String(B))) && B !== null && (I.current = null, bt(null), T?.({
|
|
2971
2997
|
region: null,
|
|
2972
2998
|
regionId: null,
|
|
2973
2999
|
regionIndex: -1,
|
|
2974
3000
|
coordinate: null
|
|
2975
3001
|
}));
|
|
2976
|
-
}, [
|
|
2977
|
-
const
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3002
|
+
}, [ft, u, T, zt]);
|
|
3003
|
+
const Te = D(
|
|
3004
|
+
(p) => {
|
|
3005
|
+
It && _(p);
|
|
3006
|
+
const B = $.current;
|
|
3007
|
+
B && B(p), P.current?.(), Y.current?.();
|
|
3008
|
+
},
|
|
3009
|
+
[It]
|
|
3010
|
+
);
|
|
3011
|
+
z(() => {
|
|
3012
|
+
if (!tt) {
|
|
3013
|
+
Tt(!1);
|
|
2984
3014
|
return;
|
|
2985
3015
|
}
|
|
2986
|
-
|
|
2987
|
-
}, [
|
|
2988
|
-
|
|
3016
|
+
Tt(!0);
|
|
3017
|
+
}, [tt, e?.id]), z(() => {
|
|
3018
|
+
X !== "cursor" && I.current !== null && (I.current = null, bt(null), T?.({
|
|
2989
3019
|
region: null,
|
|
2990
3020
|
regionId: null,
|
|
2991
3021
|
regionIndex: -1,
|
|
2992
3022
|
coordinate: null
|
|
2993
3023
|
}));
|
|
2994
|
-
}, [
|
|
2995
|
-
const kt = D((
|
|
2996
|
-
const
|
|
2997
|
-
if (!
|
|
2998
|
-
const
|
|
2999
|
-
if (!Array.isArray(
|
|
3000
|
-
const
|
|
3001
|
-
return !Number.isFinite(
|
|
3002
|
-
}, []),
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3024
|
+
}, [X, T]);
|
|
3025
|
+
const kt = D((p, B) => {
|
|
3026
|
+
const N = U.current;
|
|
3027
|
+
if (!N) return null;
|
|
3028
|
+
const K = N.screenToWorld(p, B);
|
|
3029
|
+
if (!Array.isArray(K) || K.length < 2) return null;
|
|
3030
|
+
const F = Number(K[0]), nt = Number(K[1]);
|
|
3031
|
+
return !Number.isFinite(F) || !Number.isFinite(nt) ? null : [F, nt];
|
|
3032
|
+
}, []), ve = D((p, B) => {
|
|
3033
|
+
const N = U.current;
|
|
3034
|
+
if (!N) return null;
|
|
3035
|
+
const K = N.worldToScreen(p, B);
|
|
3036
|
+
if (!Array.isArray(K) || K.length < 2) return null;
|
|
3037
|
+
const F = Number(K[0]), nt = Number(K[1]);
|
|
3038
|
+
return !Number.isFinite(F) || !Number.isFinite(nt) ? null : [F, nt];
|
|
3039
|
+
}, []), Me = D(() => {
|
|
3040
|
+
U.current?.requestRender(), P.current?.(), Y.current?.();
|
|
3041
|
+
}, []), Pe = H(() => M ?? U.current?.getViewState() ?? null, [M]), Se = H(() => {
|
|
3042
|
+
if (!e) return null;
|
|
3043
|
+
const p = Pe;
|
|
3044
|
+
return p ? {
|
|
3045
|
+
source: e,
|
|
3046
|
+
viewState: p,
|
|
3047
|
+
drawTool: X,
|
|
3048
|
+
interactionLock: st,
|
|
3049
|
+
worldToScreen: ve,
|
|
3050
|
+
screenToWorld: kt,
|
|
3051
|
+
requestRedraw: Me
|
|
3052
|
+
} : null;
|
|
3053
|
+
}, [e, Pe, X, st, ve, kt, Me]), rn = D(
|
|
3054
|
+
(p) => {
|
|
3055
|
+
const B = p.target === ut.current, N = kt(p.clientX, p.clientY);
|
|
3056
|
+
if (x) {
|
|
3057
|
+
const oe = !!N && N[0] >= 0 && N[1] >= 0 && !!e && N[0] <= e.width && N[1] <= e.height;
|
|
3058
|
+
x({
|
|
3059
|
+
coordinate: N,
|
|
3060
|
+
clientX: p.clientX,
|
|
3061
|
+
clientY: p.clientY,
|
|
3062
|
+
insideImage: oe
|
|
3012
3063
|
});
|
|
3013
3064
|
}
|
|
3014
|
-
if (
|
|
3065
|
+
if (X !== "cursor") return;
|
|
3015
3066
|
if (!B) {
|
|
3016
|
-
|
|
3067
|
+
I.current !== null && (I.current = null, bt(null), T?.({
|
|
3017
3068
|
region: null,
|
|
3018
3069
|
regionId: null,
|
|
3019
3070
|
regionIndex: -1,
|
|
@@ -3021,98 +3072,98 @@ function sr({
|
|
|
3021
3072
|
}));
|
|
3022
3073
|
return;
|
|
3023
3074
|
}
|
|
3024
|
-
if (!
|
|
3025
|
-
const
|
|
3026
|
-
String(
|
|
3027
|
-
region:
|
|
3028
|
-
regionId:
|
|
3029
|
-
regionIndex:
|
|
3030
|
-
coordinate:
|
|
3075
|
+
if (!N || !ft.length) return;
|
|
3076
|
+
const K = We(N, ft), F = K?.regionId ?? null, nt = I.current;
|
|
3077
|
+
String(nt) !== String(F) && (I.current = F, bt(F), T?.({
|
|
3078
|
+
region: K?.region ?? null,
|
|
3079
|
+
regionId: F,
|
|
3080
|
+
regionIndex: K?.regionIndex ?? -1,
|
|
3081
|
+
coordinate: N
|
|
3031
3082
|
}));
|
|
3032
3083
|
},
|
|
3033
|
-
[
|
|
3034
|
-
),
|
|
3035
|
-
|
|
3084
|
+
[X, ft, kt, T, x, e]
|
|
3085
|
+
), on = D(() => {
|
|
3086
|
+
x?.({
|
|
3036
3087
|
coordinate: null,
|
|
3037
3088
|
clientX: -1,
|
|
3038
3089
|
clientY: -1,
|
|
3039
3090
|
insideImage: !1
|
|
3040
|
-
}),
|
|
3091
|
+
}), I.current !== null && (I.current = null, bt(null), T?.({
|
|
3041
3092
|
region: null,
|
|
3042
3093
|
regionId: null,
|
|
3043
3094
|
regionIndex: -1,
|
|
3044
3095
|
coordinate: null
|
|
3045
3096
|
}));
|
|
3046
|
-
}, [
|
|
3047
|
-
(
|
|
3048
|
-
if (
|
|
3049
|
-
if (!
|
|
3050
|
-
|
|
3097
|
+
}, [T, x]), sn = D(
|
|
3098
|
+
(p) => {
|
|
3099
|
+
if (X !== "cursor" || p.target !== ut.current) return;
|
|
3100
|
+
if (!ft.length) {
|
|
3101
|
+
zt(null);
|
|
3051
3102
|
return;
|
|
3052
3103
|
}
|
|
3053
|
-
const B = kt(
|
|
3104
|
+
const B = kt(p.clientX, p.clientY);
|
|
3054
3105
|
if (!B) return;
|
|
3055
|
-
const
|
|
3056
|
-
if (!
|
|
3057
|
-
|
|
3106
|
+
const N = We(B, ft);
|
|
3107
|
+
if (!N) {
|
|
3108
|
+
zt(null);
|
|
3058
3109
|
return;
|
|
3059
3110
|
}
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
region:
|
|
3063
|
-
regionId:
|
|
3064
|
-
regionIndex:
|
|
3111
|
+
const K = u !== null && String(u) === String(N.regionId) ? null : N.regionId;
|
|
3112
|
+
zt(K), E?.({
|
|
3113
|
+
region: N.region,
|
|
3114
|
+
regionId: N.regionId,
|
|
3115
|
+
regionIndex: N.regionIndex,
|
|
3065
3116
|
coordinate: B
|
|
3066
3117
|
});
|
|
3067
3118
|
},
|
|
3068
|
-
[
|
|
3119
|
+
[X, ft, kt, E, u, zt]
|
|
3069
3120
|
);
|
|
3070
|
-
return
|
|
3071
|
-
const
|
|
3072
|
-
if (!
|
|
3121
|
+
return z(() => {
|
|
3122
|
+
const p = ut.current;
|
|
3123
|
+
if (!p || !e)
|
|
3073
3124
|
return;
|
|
3074
|
-
const B = new
|
|
3075
|
-
onViewStateChange:
|
|
3076
|
-
onStats:
|
|
3125
|
+
const B = new or(p, e, {
|
|
3126
|
+
onViewStateChange: Te,
|
|
3127
|
+
onStats: xe,
|
|
3077
3128
|
onTileError: i,
|
|
3078
3129
|
onContextLost: o,
|
|
3079
3130
|
onContextRestored: s,
|
|
3080
|
-
authToken:
|
|
3081
|
-
ctrlDragRotate:
|
|
3131
|
+
authToken: w,
|
|
3132
|
+
ctrlDragRotate: f
|
|
3082
3133
|
});
|
|
3083
|
-
return
|
|
3084
|
-
B.destroy(),
|
|
3134
|
+
return U.current = B, t && B.setViewState(t), B.setInteractionLock(st), It && _(B.getViewState()), () => {
|
|
3135
|
+
B.destroy(), U.current = null;
|
|
3085
3136
|
};
|
|
3086
|
-
}, [e,
|
|
3087
|
-
const
|
|
3088
|
-
!
|
|
3089
|
-
}, [t]),
|
|
3090
|
-
const
|
|
3091
|
-
|
|
3092
|
-
}, [
|
|
3093
|
-
const
|
|
3094
|
-
|
|
3095
|
-
}, [h]),
|
|
3096
|
-
const
|
|
3097
|
-
!
|
|
3098
|
-
}, [y]),
|
|
3099
|
-
const
|
|
3100
|
-
|
|
3101
|
-
}, [
|
|
3102
|
-
if (!
|
|
3103
|
-
const B =
|
|
3104
|
-
paletteIndexToTermId:
|
|
3137
|
+
}, [e, xe, i, o, s, w, f, Te, It]), z(() => {
|
|
3138
|
+
const p = U.current;
|
|
3139
|
+
!p || !t || p.setViewState(t);
|
|
3140
|
+
}, [t]), z(() => {
|
|
3141
|
+
const p = U.current;
|
|
3142
|
+
p && p.fitToImage();
|
|
3143
|
+
}, [l]), z(() => {
|
|
3144
|
+
const p = U.current;
|
|
3145
|
+
p && p.resetRotation();
|
|
3146
|
+
}, [h]), z(() => {
|
|
3147
|
+
const p = U.current;
|
|
3148
|
+
!p || !y || p.setPointPalette(y);
|
|
3149
|
+
}, [y]), z(() => {
|
|
3150
|
+
const p = U.current;
|
|
3151
|
+
p && p.setPointData(qt);
|
|
3152
|
+
}, [qt]), z(() => {
|
|
3153
|
+
if (!W) return;
|
|
3154
|
+
const B = er(S ? qt : m, ft, {
|
|
3155
|
+
paletteIndexToTermId: yt,
|
|
3105
3156
|
includeEmptyRegions: !0
|
|
3106
3157
|
});
|
|
3107
|
-
|
|
3108
|
-
}, [
|
|
3109
|
-
const
|
|
3110
|
-
|
|
3111
|
-
}, [
|
|
3112
|
-
/* @__PURE__ */
|
|
3158
|
+
W(B);
|
|
3159
|
+
}, [W, S, m, qt, ft, yt]), z(() => {
|
|
3160
|
+
const p = U.current;
|
|
3161
|
+
p && p.setInteractionLock(st);
|
|
3162
|
+
}, [st]), /* @__PURE__ */ Ee("div", { className: et, style: Vt, onPointerMove: rn, onPointerLeave: on, onClick: sn, children: [
|
|
3163
|
+
/* @__PURE__ */ Mt(
|
|
3113
3164
|
"canvas",
|
|
3114
3165
|
{
|
|
3115
|
-
ref:
|
|
3166
|
+
ref: ut,
|
|
3116
3167
|
className: "wsi-render-canvas",
|
|
3117
3168
|
style: {
|
|
3118
3169
|
position: "absolute",
|
|
@@ -3122,49 +3173,67 @@ function sr({
|
|
|
3122
3173
|
height: "100%",
|
|
3123
3174
|
display: "block",
|
|
3124
3175
|
touchAction: "none",
|
|
3125
|
-
cursor:
|
|
3176
|
+
cursor: X === "cursor" && vt !== null ? "pointer" : st ? "crosshair" : "grab"
|
|
3126
3177
|
}
|
|
3127
3178
|
}
|
|
3128
3179
|
),
|
|
3129
|
-
e ? /* @__PURE__ */
|
|
3130
|
-
|
|
3180
|
+
e && Se && Array.isArray(ht) && ht.length > 0 ? ht.map((p, B) => /* @__PURE__ */ Mt(
|
|
3181
|
+
"div",
|
|
3182
|
+
{
|
|
3183
|
+
className: p.className,
|
|
3184
|
+
style: {
|
|
3185
|
+
position: "absolute",
|
|
3186
|
+
inset: 0,
|
|
3187
|
+
zIndex: p.zIndex ?? 3,
|
|
3188
|
+
pointerEvents: p.pointerEvents ?? "none",
|
|
3189
|
+
...p.style
|
|
3190
|
+
},
|
|
3191
|
+
children: p.render(Se)
|
|
3192
|
+
},
|
|
3193
|
+
p.id ?? B
|
|
3194
|
+
)) : null,
|
|
3195
|
+
e ? /* @__PURE__ */ Mt(
|
|
3196
|
+
_n,
|
|
3131
3197
|
{
|
|
3132
|
-
tool:
|
|
3133
|
-
enabled:
|
|
3198
|
+
tool: X,
|
|
3199
|
+
enabled: X !== "cursor",
|
|
3134
3200
|
imageWidth: e.width,
|
|
3135
3201
|
imageHeight: e.height,
|
|
3136
3202
|
imageMpp: e.mpp,
|
|
3137
3203
|
imageZoom: e.maxTierZoom,
|
|
3138
|
-
stampOptions:
|
|
3139
|
-
projectorRef:
|
|
3204
|
+
stampOptions: At,
|
|
3205
|
+
projectorRef: U,
|
|
3140
3206
|
viewStateSignal: t,
|
|
3141
|
-
persistedRegions:
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3207
|
+
persistedRegions: ft,
|
|
3208
|
+
patchRegions: ot,
|
|
3209
|
+
regionStrokeStyle: mt,
|
|
3210
|
+
regionStrokeHoverStyle: lt,
|
|
3211
|
+
regionStrokeActiveStyle: Rt,
|
|
3212
|
+
patchStrokeStyle: J,
|
|
3213
|
+
resolveRegionStrokeStyle: rt,
|
|
3214
|
+
overlayShapes: V,
|
|
3215
|
+
hoveredRegionId: vt,
|
|
3216
|
+
activeRegionId: u,
|
|
3217
|
+
regionLabelStyle: at,
|
|
3218
|
+
invalidateRef: P,
|
|
3219
|
+
onDrawComplete: O,
|
|
3220
|
+
onPatchComplete: gt
|
|
3152
3221
|
}
|
|
3153
3222
|
) : null,
|
|
3154
|
-
a ? /* @__PURE__ */
|
|
3155
|
-
e &&
|
|
3156
|
-
/* @__PURE__ */
|
|
3157
|
-
/* @__PURE__ */
|
|
3223
|
+
a ? /* @__PURE__ */ Mt("pre", { "data-open-plant-debug-overlay": !0, style: ie, children: nn }) : null,
|
|
3224
|
+
e && tt ? Lt ? /* @__PURE__ */ Ee(un, { children: [
|
|
3225
|
+
/* @__PURE__ */ Mt(Un, { source: e, projectorRef: U, authToken: w, options: q, invalidateRef: Y }),
|
|
3226
|
+
/* @__PURE__ */ Mt(
|
|
3158
3227
|
"button",
|
|
3159
3228
|
{
|
|
3160
3229
|
type: "button",
|
|
3161
3230
|
"aria-label": "Hide overview map",
|
|
3162
|
-
onClick: () =>
|
|
3231
|
+
onClick: () => Tt(!1),
|
|
3163
3232
|
style: {
|
|
3164
3233
|
position: "absolute",
|
|
3165
3234
|
zIndex: 6,
|
|
3166
|
-
...
|
|
3167
|
-
...
|
|
3235
|
+
...Ht.includes("left") ? { left: _t } : { right: _t },
|
|
3236
|
+
...Ht.includes("top") ? { top: _t + ye + 8 } : { bottom: _t + ye + 8 },
|
|
3168
3237
|
width: 20,
|
|
3169
3238
|
height: 20,
|
|
3170
3239
|
borderRadius: 999,
|
|
@@ -3179,17 +3248,17 @@ function sr({
|
|
|
3179
3248
|
children: "×"
|
|
3180
3249
|
}
|
|
3181
3250
|
)
|
|
3182
|
-
] }) : /* @__PURE__ */
|
|
3251
|
+
] }) : /* @__PURE__ */ Mt(
|
|
3183
3252
|
"button",
|
|
3184
3253
|
{
|
|
3185
3254
|
type: "button",
|
|
3186
3255
|
"aria-label": "Show overview map",
|
|
3187
|
-
onClick: () =>
|
|
3256
|
+
onClick: () => Tt(!0),
|
|
3188
3257
|
style: {
|
|
3189
3258
|
position: "absolute",
|
|
3190
3259
|
zIndex: 6,
|
|
3191
|
-
...
|
|
3192
|
-
...
|
|
3260
|
+
...Ht.includes("left") ? { left: _t } : { right: _t },
|
|
3261
|
+
...Ht.includes("top") ? { top: _t } : { bottom: _t },
|
|
3193
3262
|
height: 24,
|
|
3194
3263
|
minWidth: 40,
|
|
3195
3264
|
borderRadius: 999,
|
|
@@ -3207,32 +3276,34 @@ function sr({
|
|
|
3207
3276
|
] });
|
|
3208
3277
|
}
|
|
3209
3278
|
export {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3279
|
+
Xe as DEFAULT_POINT_COLOR,
|
|
3280
|
+
_n as DrawLayer,
|
|
3281
|
+
gn as M1TileRenderer,
|
|
3282
|
+
Un as OverviewMap,
|
|
3283
|
+
rr as TileScheduler,
|
|
3284
|
+
br as TileViewerCanvas,
|
|
3285
|
+
or as WsiTileRenderer,
|
|
3286
|
+
vr as WsiViewerCanvas,
|
|
3287
|
+
pr as buildTermPalette,
|
|
3288
|
+
fr as calcScaleLength,
|
|
3289
|
+
Ve as calcScaleResolution,
|
|
3290
|
+
j as clamp,
|
|
3291
|
+
Pt as closeRing,
|
|
3292
|
+
er as computeRoiPointGroups,
|
|
3293
|
+
Ue as createCircle,
|
|
3294
|
+
Be as createRectangle,
|
|
3295
|
+
re as filterPointDataByPolygons,
|
|
3296
|
+
Hn as filterPointDataByPolygonsHybrid,
|
|
3297
|
+
Zn as filterPointDataByPolygonsInWorker,
|
|
3298
|
+
Dn as filterPointIndicesByPolygons,
|
|
3299
|
+
Tr as filterPointIndicesByPolygonsInWorker,
|
|
3300
|
+
yr as getWebGpuCapabilities,
|
|
3301
|
+
pn as hexToRgba,
|
|
3302
|
+
mr as isSameViewState,
|
|
3303
|
+
wr as normalizeImageInfo,
|
|
3304
|
+
On as prefilterPointsByBoundsWebGpu,
|
|
3305
|
+
xr as terminateRoiClipWorker,
|
|
3306
|
+
gr as toBearerToken,
|
|
3307
|
+
Ze as toTileUrl
|
|
3237
3308
|
};
|
|
3238
3309
|
//# sourceMappingURL=index.js.map
|