open-plant 1.2.6 → 1.2.8

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