open-plant 1.2.6 → 1.2.7

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 Ut, 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, Fn = 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,8 +331,8 @@ function pr(e) {
331
331
  }
332
332
  return t;
333
333
  }
334
- function br(e, t, n) {
335
- if (t <= Un || n < 8) return [];
334
+ function wr(e, t, n) {
335
+ if (t <= Fn || n < 8) return [];
336
336
  const r = [];
337
337
  for (let i = 0; i <= n; i += 1) {
338
338
  const o = i / n * Math.PI * 2;
@@ -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 Er(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], C = Pr(u, k.dir);
477
+ C < x && (x = C, 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 Rr(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,14 +550,14 @@ 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])
@@ -565,47 +565,47 @@ function ie(e, t) {
565
565
  ) : e;
566
566
  }
567
567
  function Fr(e, t) {
568
- const n = pr(e), r = Math.max(Un, Number(t.radius) || 0);
568
+ const n = br(e), r = Math.max(Fn, 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 = Er(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 = Rr(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 Un = [
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 co(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 lo(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 ho(e) {
620
620
  const t = String(e ?? "").trim();
621
621
  if (!t) return "";
622
622
  if (/^bearer\s+/i.test(t)) {
@@ -627,13 +627,13 @@ function so(e) {
627
627
  }
628
628
  function Ur(e) {
629
629
  const n = String(e ?? "").trim().match(/^#?([0-9a-fA-F]{6})$/);
630
- if (!n) return [...Bn];
630
+ if (!n) return [...Un];
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 fo(e) {
635
635
  const t = [
636
- [...Bn]
636
+ [...Un]
637
637
  ], n = /* @__PURE__ */ new Map();
638
638
  for (const i of e ?? []) {
639
639
  const o = String(i?.termId ?? "");
@@ -644,7 +644,7 @@ function ao(e) {
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 = 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
+ }, Qr = {
672
672
  color: "#4cc9f0",
673
673
  width: 2,
674
674
  lineDash: [10, 8],
@@ -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 ti(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 ei(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 ni(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
+ }
718
+ function ri(e) {
719
+ return typeof e != "number" || !Number.isFinite(e) ? Zr : ne(e, Kr, jr);
717
720
  }
718
- function Qr(e) {
719
- const t = se(e?.radius, Wr), n = se(e?.cursorLineWidth, $r);
721
+ function ii(e) {
722
+ const t = se(e?.radius, Vr), n = se(e?.cursorLineWidth, Hr), r = ri(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: ei(e?.fillOpacity, Gr),
729
+ cursorColor: e?.cursorColor || qr,
730
+ cursorActiveColor: e?.cursorActiveColor || $r,
726
731
  cursorLineWidth: n,
727
- cursorLineDash: Jr(e?.cursorLineDash)
732
+ cursorLineDash: ni(e?.cursorLineDash)
728
733
  };
729
734
  }
730
- function ti(e) {
731
- return e * bn * bn;
735
+ function oi(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 ? [] : Rt([
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 si(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 Rt(r);
749
754
  }
750
- function Ct(e) {
755
+ function Rt(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 ? [] : Rt([
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 Rt(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 ai(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 En(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 ui(e) {
847
+ return Array.isArray(e) && e.length >= 2 && En(e[0]) && En(e[1]);
843
848
  }
844
- function ii(e) {
845
- return Array.isArray(e) && e.length >= 2 && e.every((t) => ri(t));
849
+ function ci(e) {
850
+ return Array.isArray(e) && e.length >= 2 && e.every((t) => ui(t));
846
851
  }
847
852
  function Xn(e, t) {
848
853
  if (!(!Array.isArray(e) || e.length === 0)) {
849
- if (ii(e)) {
854
+ if (ci(e)) {
850
855
  t.push(e.map(([n, r]) => [n, r]));
851
856
  return;
852
857
  }
@@ -854,26 +859,26 @@ function Xn(e, t) {
854
859
  Xn(n, t);
855
860
  }
856
861
  }
857
- function vn(e, t) {
862
+ function Rn(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 ? Rt(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 li(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) {
881
+ function hi(e) {
877
882
  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;
878
883
  return {
879
884
  fontFamily: e?.fontFamily || Et.fontFamily,
@@ -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 fi(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 di(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 mi(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, fi(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
- function Ue(e, t, n) {
915
- return [ue(e[0], 0, t), ue(e[1], 0, n)];
919
+ function Fe(e, t, 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 gi({
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,
941
- 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
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: C,
947
+ patchStrokeStyle: E,
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]), I = tt(() => x ?? bn, [x]), A = tt(() => kn(P), [P]), L = tt(() => oe(A, k), [A, k]), Z = tt(() => oe(A, C), [A, C]), et = tt(() => oe(Qr, E), [E]), mt = tt(() => hi($), [$]), yt = tt(() => ti(o), [o]), U = tt(() => ii(s), [s]), At = tt(
963
969
  () => ({
964
970
  position: "absolute",
965
971
  inset: 0,
@@ -968,426 +974,432 @@ 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)), R = Math.max(1, Math.round(f.height * w));
986
+ (l.width !== y || l.height !== R) && (l.width = y, l.height = R);
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 R = te(f.worldToScreen(l[y][0], l[y][1]));
994
+ if (!R) return [];
995
+ w[y] = R;
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])), R = te(w.worldToScreen(l[0] + f, l[1]));
1006
+ return !y || !R ? 0 : Math.hypot(R[0] - y[0], R[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, R = typeof y == "number" && Number.isFinite(y) && y > 0 ? y : 1, v = w + Math.log2(R), Y = Math.max(1e-9, zn(f, w, v));
1013
+ return l / Y / R;
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 v = yt.rectanglePixelSize * 0.5;
1022
+ return xn(f, v).map((V) => Fe(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 = oi(w);
1026
+ let R = [];
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 v = ut(Math.sqrt(y) * 0.5);
1029
+ R = xn(f, v);
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 v = ut(Math.sqrt(y / Math.PI));
1032
+ R = si(f, v);
1027
1033
  }
1028
- return v.length ? v.map((E) => Ue(E, t, n)) : [];
1034
+ return R.length ? R.map((v) => Fe(v, 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], R = G(y, U.radius);
1047
+ if (!(!Number.isFinite(R) || R <= 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 = R * 2, w.length === 1)
1049
+ l.beginPath(), l.arc(w[0][0], w[0][1], R, 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 v = 1; v < w.length; v += 1)
1053
+ l.lineTo(w[v][0], w[v][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 R = G(w, U.radius);
1067
+ !Number.isFinite(R) || R <= 0 || (l.save(), l.beginPath(), l.arc(y[0], y[1], R, 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, R = 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 v = 0; v < M.length; v += 1) {
1079
+ const Y = M[v], 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 = Rt(V), lt = N(W);
1082
+ if (lt.length >= 4) {
1083
+ const Pt = Y.id ?? v, $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: v,
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 (I.length > 0)
1098
+ for (let v = 0; v < I.length; v += 1) {
1099
+ const V = I[v]?.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 = Rt(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 v = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, Y = N(
1106
+ Rt([
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 ?? ai(W.coordinates), Pt = Rn(W.coordinates, lt);
1117
+ if (W.invertedFill?.fillColor) {
1118
+ const xt = [], H = Rn(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 (v) {
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
+ li(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 v = rt();
1148
+ if (v.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(v);
1151
+ Y.length >= 2 && Qt(f, Y, A, !1, !1), Y.length >= 3 && Qt(f, N(Rt(v)), 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(v);
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 v of M) {
1159
+ if (!v.label) continue;
1160
+ const Y = v?.coordinates;
1161
+ if (!Y || Y.length < 3) continue;
1162
+ const V = Rt(Y), W = di(V);
1163
+ if (!W) continue;
1164
+ const lt = te(a.current?.worldToScreen(W[0], W[1]) ?? []);
1165
+ lt && mi(f, v.label, lt, y, R, 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
+ I,
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 ? Fe(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 = Rt(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);
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 = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), R = U.edgeDetail, v = 0.75 / (y * R);
1218
1229
  f = Fr(l.points, {
1219
- radius: j.radius,
1230
+ radius: U.radius,
1220
1231
  clipBounds: [0, 0, t, n],
1221
- minRasterStep: S,
1222
- simplifyTolerance: S * 0.4
1232
+ minRasterStep: v,
1233
+ circleSides: Math.max(24, Math.round(64 * R)),
1234
+ simplifyTolerance: v * 0.4
1223
1235
  });
1224
1236
  }
1225
- (e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && Mn(f) && u && u({
1237
+ (e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && An(f) && c && c({
1226
1238
  tool: e,
1227
1239
  intent: e === "brush" ? "brush" : "roi",
1228
1240
  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(
1241
+ bbox: Mn(f),
1242
+ areaPx: ke(f)
1243
+ }), ct(!0), F();
1244
+ }, [e, c, ct, F, U.radius, U.edgeDetail, U.clickSelectRoi, t, n, a, u]), Bt = B(
1233
1245
  (l, f) => {
1234
- const m = ot(l, f);
1235
- if (!Mn(m)) return;
1236
- const S = l === "stamp-rectangle-4096px" ? "patch" : "roi", v = {
1246
+ const w = nt(l, f);
1247
+ if (!An(w)) return;
1248
+ const y = l === "stamp-rectangle-4096px" ? "patch" : "roi", R = {
1237
1249
  tool: l,
1238
- intent: S,
1239
- coordinates: m,
1240
- bbox: Tn(m),
1241
- areaPx: De(m)
1250
+ intent: y,
1251
+ coordinates: w,
1252
+ bbox: Mn(w),
1253
+ areaPx: ke(w)
1242
1254
  };
1243
- u?.(v), S === "patch" && c && c(v);
1255
+ c?.(R), y === "patch" && h && h(R);
1244
1256
  },
1245
- [ot, u, c]
1246
- ), At = F(
1257
+ [nt, c, h]
1258
+ ), Ft = B(
1247
1259
  (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) {
1260
+ const w = a.current, y = Math.max(1e-6, w?.getViewState?.().zoom ?? 1), R = Jr / y, v = R * R, Y = l.points[l.points.length - 1];
1261
+ if (!Y) {
1250
1262
  l.points.push(f), l.current = f;
1251
1263
  return;
1252
1264
  }
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;
1265
+ const V = f[0] - Y[0], W = f[1] - Y[1];
1266
+ V * V + W * W >= v ? l.points.push(f) : l.points[l.points.length - 1] = f, l.current = f;
1255
1267
  },
1256
1268
  [a]
1257
- ), qt = F(
1269
+ ), qt = B(
1258
1270
  (l) => {
1259
- if (!it || e === "cursor" || l.button !== 0) return;
1260
- const f = wt(l);
1271
+ if (!Q || e === "cursor" || l.button !== 0) return;
1272
+ const f = ot(l);
1261
1273
  if (!f) return;
1262
- if (l.preventDefault(), l.stopPropagation(), be(e)) {
1263
- const v = dt.current;
1264
- v.stampCenter = f, Gt(e, f), B();
1274
+ if (l.preventDefault(), l.stopPropagation(), we(e)) {
1275
+ const R = dt.current;
1276
+ R.stampCenter = f, Bt(e, f), F();
1265
1277
  return;
1266
1278
  }
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();
1279
+ const w = K.current;
1280
+ w && w.setPointerCapture(l.pointerId);
1281
+ const y = dt.current;
1282
+ 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
1283
  },
1272
- [it, e, wt, Gt, B]
1273
- ), $t = F(
1284
+ [Q, e, ot, Bt, F]
1285
+ ), pt = B(
1274
1286
  (l) => {
1275
- if (!it || e === "cursor") return;
1276
- const f = wt(l);
1287
+ if (!Q || e === "cursor") return;
1288
+ const f = ot(l);
1277
1289
  if (!f) return;
1278
- if (be(e)) {
1279
- const S = dt.current;
1280
- S.stampCenter = f, l.preventDefault(), l.stopPropagation(), B();
1290
+ if (we(e)) {
1291
+ const y = dt.current;
1292
+ y.stampCenter = f, l.preventDefault(), l.stopPropagation(), F();
1281
1293
  return;
1282
1294
  }
1283
- const m = dt.current;
1295
+ const w = dt.current;
1284
1296
  if (e === "brush") {
1285
- if (m.cursor = f, !m.isDrawing || m.pointerId !== l.pointerId) {
1286
- B();
1297
+ if (w.cursor = f, !w.isDrawing || w.pointerId !== l.pointerId) {
1298
+ F();
1287
1299
  return;
1288
1300
  }
1289
- l.preventDefault(), l.stopPropagation(), At(m, f), B();
1301
+ l.preventDefault(), l.stopPropagation(), Ft(w, f), F();
1290
1302
  return;
1291
1303
  }
1292
- if (!(!m.isDrawing || m.pointerId !== l.pointerId)) {
1304
+ if (!(!w.isDrawing || w.pointerId !== l.pointerId)) {
1293
1305
  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];
1306
+ const y = a.current, R = Math.max(1e-6, y?.getViewState?.().zoom ?? 1), v = Dr / R, Y = v * v, V = w.points[w.points.length - 1];
1295
1307
  if (!V)
1296
- m.points.push(f);
1308
+ w.points.push(f);
1297
1309
  else {
1298
- const k = f[0] - V[0], ht = f[1] - V[1];
1299
- k * k + ht * ht >= D && m.points.push(f);
1310
+ const W = f[0] - V[0], lt = f[1] - V[1];
1311
+ W * W + lt * lt >= Y && w.points.push(f);
1300
1312
  }
1301
1313
  } else
1302
- m.current = f;
1303
- B();
1314
+ w.current = f;
1315
+ F();
1304
1316
  }
1305
1317
  },
1306
- [it, e, wt, B, a, At]
1307
- ), Rt = F(
1318
+ [Q, e, ot, F, a, Ft]
1319
+ ), ue = B(
1308
1320
  (l) => {
1309
1321
  const f = dt.current;
1310
1322
  if (!f.isDrawing || f.pointerId !== l.pointerId) return;
1311
1323
  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))
1324
+ const w = ot(l);
1325
+ w && (f.cursor = w, e === "brush" ? Ft(f, w) : f.current = w);
1326
+ const y = K.current;
1327
+ if (y && y.hasPointerCapture(l.pointerId))
1316
1328
  try {
1317
- S.releasePointerCapture(l.pointerId);
1329
+ y.releasePointerCapture(l.pointerId);
1318
1330
  } catch {
1319
1331
  }
1320
- bt();
1332
+ Gt();
1321
1333
  },
1322
- [bt, wt, e, At]
1323
- ), ve = F(() => {
1334
+ [Gt, ot, e, Ft]
1335
+ ), ce = B(() => {
1324
1336
  const l = dt.current;
1325
1337
  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]);
1338
+ e === "brush" && !l.isDrawing && l.cursor && (l.cursor = null, f = !0), we(e) && l.stampCenter && (l.stampCenter = null, f = !0), f && F();
1339
+ }, [e, F]);
1328
1340
  return X(() => {
1329
- pt(), B();
1330
- const l = yt.current;
1341
+ gt(), F();
1342
+ const l = K.current;
1331
1343
  if (!l) return;
1332
1344
  const f = new ResizeObserver(() => {
1333
- pt(), B();
1345
+ gt(), F();
1334
1346
  });
1335
1347
  return f.observe(l), () => {
1336
1348
  f.disconnect();
1337
1349
  };
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);
1350
+ }, [gt, F]), X(() => {
1351
+ Q || ct(), F();
1352
+ }, [Q, F, ct]), X(() => {
1353
+ Kt.current !== e && (Kt.current = e, ct(), F());
1354
+ }, [e, ct, F]), X(() => {
1355
+ F();
1356
+ }, [d, M, J, F]), X(() => {
1357
+ if (ht)
1358
+ return ht.current = F, () => {
1359
+ ht.current === F && (ht.current = null);
1348
1360
  };
1349
- }, [W, B]), X(() => {
1350
- if (!it) return;
1361
+ }, [ht, F]), X(() => {
1362
+ if (!Q) return;
1351
1363
  const l = (f) => {
1352
- f.key === "Escape" && (lt(), B());
1364
+ f.key === "Escape" && (ct(), F());
1353
1365
  };
1354
1366
  return window.addEventListener("keydown", l), () => {
1355
1367
  window.removeEventListener("keydown", l);
1356
1368
  };
1357
- }, [it, lt, B]), /* @__PURE__ */ Bt(
1369
+ }, [Q, ct, F]), /* @__PURE__ */ Ut(
1358
1370
  "canvas",
1359
1371
  {
1360
- ref: yt,
1361
- className: Mt,
1362
- style: tt,
1372
+ ref: K,
1373
+ className: vt,
1374
+ style: At,
1363
1375
  onPointerDown: qt,
1364
- onPointerMove: $t,
1365
- onPointerUp: Rt,
1366
- onPointerCancel: Rt,
1367
- onPointerLeave: ve,
1376
+ onPointerMove: pt,
1377
+ onPointerUp: ue,
1378
+ onPointerCancel: ue,
1379
+ onPointerLeave: ce,
1368
1380
  onContextMenu: (l) => {
1369
- it && l.preventDefault();
1381
+ Q && l.preventDefault();
1370
1382
  },
1371
1383
  onWheel: (l) => {
1372
- if (!it) return;
1373
- const f = yt.current, m = a.current;
1374
- if (!f || typeof m?.zoomBy != "function") return;
1384
+ if (!Q) return;
1385
+ const f = K.current, w = a.current;
1386
+ if (!f || typeof w?.zoomBy != "function") return;
1375
1387
  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();
1388
+ const y = f.getBoundingClientRect(), R = l.clientX - y.left, v = l.clientY - y.top;
1389
+ w.zoomBy(l.deltaY < 0 ? Yr : Wr, R, v), F();
1378
1390
  }
1379
1391
  }
1380
1392
  );
1381
1393
  }
1382
- function Rn(e) {
1394
+ function vn(e) {
1383
1395
  return String(e ?? "").replace(/\/+$/, "");
1384
1396
  }
1385
1397
  function Yn(e) {
1386
1398
  const t = String(e ?? "");
1387
1399
  return t.startsWith("/") ? t : `/${t}`;
1388
1400
  }
1389
- function hi(e) {
1390
- const t = Rn(e);
1401
+ function pi(e) {
1402
+ const t = vn(e);
1391
1403
  if (!t) return "";
1392
1404
  if (/\/TileGroup\d+$/i.test(t)) return t;
1393
1405
  let n = null;
@@ -1397,20 +1409,20 @@ function hi(e) {
1397
1409
  n = null;
1398
1410
  }
1399
1411
  if (n) {
1400
- const r = `${n.protocol}//${n.host}`, i = Rn(n.pathname || "");
1412
+ const r = `${n.protocol}//${n.host}`, i = vn(n.pathname || "");
1401
1413
  return /\/ims$/i.test(i) ? `${r}${i}` : /\/tiles$/i.test(i) ? `${r}${i}` : `${r}${i}/tiles`;
1402
1414
  }
1403
1415
  return /\/ims$/i.test(t) ? "/ims" : /\/tiles$/i.test(t) ? `${t}` : `${t}/tiles`;
1404
1416
  }
1405
- function uo(e, t) {
1417
+ function mo(e, t) {
1406
1418
  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
1419
  if (!i || !o || !s || !u)
1408
1420
  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;
1421
+ const h = Array.isArray(e?.terms) ? e.terms.map((x) => ({
1422
+ termId: String(x?.termId ?? ""),
1423
+ termName: String(x?.termName ?? ""),
1424
+ termColor: String(x?.termColor ?? "")
1425
+ })) : [], g = Yn(u), d = pi(t), p = r ? (x, S, P) => `${d}${g}/${x}/${P}_${S}.webp` : void 0;
1414
1426
  return {
1415
1427
  id: e?._id || "unknown",
1416
1428
  name: e?.name || "unknown",
@@ -1422,7 +1434,7 @@ function uo(e, t) {
1422
1434
  tilePath: u,
1423
1435
  tileBaseUrl: t,
1424
1436
  terms: h,
1425
- tileUrlBuilder: w
1437
+ tileUrlBuilder: p
1426
1438
  };
1427
1439
  }
1428
1440
  function Wn(e, t, n, r) {
@@ -1431,7 +1443,7 @@ function Wn(e, t, n, r) {
1431
1443
  const i = Yn(e.tilePath);
1432
1444
  return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
1433
1445
  }
1434
- const St = {
1446
+ const bt = {
1435
1447
  width: 220,
1436
1448
  height: 140,
1437
1449
  margin: 16,
@@ -1446,13 +1458,13 @@ const St = {
1446
1458
  showThumbnail: !0,
1447
1459
  maxThumbnailTiles: 16
1448
1460
  };
1449
- function ne(e, t, n = 1) {
1461
+ function ee(e, t, n = 1) {
1450
1462
  return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
1451
1463
  }
1452
- function we(e) {
1464
+ function ye(e) {
1453
1465
  return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
1454
1466
  }
1455
- function fi({
1467
+ function bi({
1456
1468
  source: e,
1457
1469
  projectorRef: t,
1458
1470
  authToken: n = "",
@@ -1461,253 +1473,253 @@ function fi({
1461
1473
  className: o,
1462
1474
  style: s
1463
1475
  }) {
1464
- const a = H(null), u = H(null), c = H(null), h = H({
1476
+ const a = j(null), u = j(null), c = j(null), h = j({
1465
1477
  active: !1,
1466
1478
  pointerId: null
1467
- }), g = H(null), d = H(!1), w = ne(
1479
+ }), g = j(null), d = j(!1), p = ee(
1468
1480
  r?.width,
1469
- St.width,
1481
+ bt.width,
1470
1482
  64
1471
- ), y = ne(
1483
+ ), x = ee(
1472
1484
  r?.height,
1473
- St.height,
1485
+ bt.height,
1474
1486
  48
1475
- ), x = ne(
1487
+ ), S = ee(
1476
1488
  r?.margin,
1477
- St.margin,
1489
+ bt.margin,
1478
1490
  0
1479
- ), A = ne(
1491
+ ), P = ee(
1480
1492
  r?.borderRadius,
1481
- St.borderRadius,
1493
+ bt.borderRadius,
1482
1494
  0
1483
- ), N = ne(
1495
+ ), k = ee(
1484
1496
  r?.borderWidth,
1485
- St.borderWidth,
1497
+ bt.borderWidth,
1486
1498
  0
1487
- ), R = Math.max(
1499
+ ), C = Math.max(
1488
1500
  1,
1489
1501
  Math.round(
1490
- ne(
1502
+ ee(
1491
1503
  r?.maxThumbnailTiles,
1492
- St.maxThumbnailTiles,
1504
+ bt.maxThumbnailTiles,
1493
1505
  1
1494
1506
  )
1495
1507
  )
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, {
1508
+ ), E = 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(() => {
1509
+ const M = {};
1510
+ 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
1511
  position: "absolute",
1500
- ...P,
1501
- width: w,
1502
- height: y,
1503
- borderRadius: A,
1512
+ ...M,
1513
+ width: p,
1514
+ height: x,
1515
+ borderRadius: P,
1504
1516
  overflow: "hidden",
1505
1517
  zIndex: 4,
1506
- pointerEvents: ct ? "auto" : "none",
1518
+ pointerEvents: at ? "auto" : "none",
1507
1519
  touchAction: "none",
1508
1520
  boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
1509
1521
  ...s
1510
1522
  };
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
1523
+ }, [S, ht, p, x, P, at, s]), Ot = B(() => {
1524
+ const M = a.current;
1525
+ if (!M) return;
1526
+ const I = M.getContext("2d");
1527
+ if (!I) return;
1528
+ 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));
1529
+ (M.width !== et || M.height !== mt) && (M.width = et, M.height = mt), I.setTransform(1, 0, 0, 1, 0, 0), I.clearRect(0, 0, M.width, M.height), I.setTransform(Z, 0, 0, Z, 0, 0), I.fillStyle = E, I.fillRect(0, 0, A, L);
1530
+ const yt = u.current;
1531
+ yt && I.drawImage(yt, 0, 0, A, L), I.strokeStyle = D, I.lineWidth = k, I.strokeRect(
1532
+ k * 0.5,
1533
+ k * 0.5,
1534
+ A - k,
1535
+ L - k
1524
1536
  );
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);
1537
+ const U = t.current, At = U?.getViewBounds?.(), gt = U?.getViewCorners?.(), N = ye(At) ? At : ye(c.current) ? c.current : null;
1538
+ if (!N) return;
1539
+ c.current = N;
1540
+ const G = A / Math.max(1, e.width), ut = L / Math.max(1, e.height), nt = Array.isArray(gt) && gt.length >= 4 && gt.every(
1541
+ (ot) => Array.isArray(ot) && ot.length >= 2 && Number.isFinite(ot[0]) && Number.isFinite(ot[1])
1542
+ ) ? gt : null;
1543
+ if (nt) {
1544
+ I.beginPath();
1545
+ for (let ot = 0; ot < nt.length; ot += 1) {
1546
+ const Gt = nt[ot], Bt = it(Gt[0] * G, 0, A), Ft = it(Gt[1] * ut, 0, L);
1547
+ ot === 0 ? I.moveTo(Bt, Ft) : I.lineTo(Bt, Ft);
1536
1548
  }
1537
- T.closePath(), T.fillStyle = ft, T.fill(), T.strokeStyle = nt, T.lineWidth = 1.5, T.stroke();
1549
+ I.closePath(), I.fillStyle = ft, I.fill(), I.strokeStyle = J, I.lineWidth = 1.5, I.stroke();
1538
1550
  return;
1539
1551
  }
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)
1552
+ 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);
1553
+ I.fillStyle = ft, I.fillRect(rt, q, F, ct), I.strokeStyle = J, I.lineWidth = 1.5, I.strokeRect(
1554
+ rt + 0.5,
1555
+ q + 0.5,
1556
+ Math.max(1, F - 1),
1557
+ Math.max(1, ct - 1)
1546
1558
  );
1547
1559
  }, [
1548
- w,
1549
- y,
1550
- M,
1551
- U,
1552
- N,
1560
+ p,
1561
+ x,
1562
+ E,
1563
+ D,
1564
+ k,
1553
1565
  t,
1554
1566
  e.width,
1555
1567
  e.height,
1556
1568
  ft,
1557
- nt
1558
- ]), rt = F(() => {
1569
+ J
1570
+ ]), K = B(() => {
1559
1571
  d.current || (d.current = !0, g.current = requestAnimationFrame(() => {
1560
- d.current = !1, g.current = null, yt();
1572
+ d.current = !1, g.current = null, Ot();
1561
1573
  }));
1562
- }, [yt]), Lt = F(
1563
- (P, T) => {
1564
- const I = a.current;
1565
- if (!I) return null;
1566
- const L = I.getBoundingClientRect();
1574
+ }, [Ot]), Ct = B(
1575
+ (M, I) => {
1576
+ const A = a.current;
1577
+ if (!A) return null;
1578
+ const L = A.getBoundingClientRect();
1567
1579
  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];
1580
+ const Z = it((M - L.left) / L.width, 0, 1), et = it((I - L.top) / L.height, 0, 1);
1581
+ return [Z * e.width, et * e.height];
1570
1582
  },
1571
1583
  [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();
1584
+ ), zt = B(
1585
+ (M, I) => {
1586
+ const A = t.current;
1587
+ if (!A) return;
1588
+ if (A.setViewCenter) {
1589
+ A.setViewCenter(M, I), K();
1578
1590
  return;
1579
1591
  }
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();
1592
+ const L = A.getViewBounds?.(), Z = ye(L) ? L : ye(c.current) ? c.current : null;
1593
+ if (!Z) return;
1594
+ const et = Math.max(1e-6, Z[2] - Z[0]), mt = Math.max(1e-6, Z[3] - Z[1]);
1595
+ A.setViewState({
1596
+ offsetX: M - et * 0.5,
1597
+ offsetY: I - mt * 0.5
1598
+ }), K();
1587
1599
  },
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]));
1600
+ [t, K]
1601
+ ), Kt = B(
1602
+ (M) => {
1603
+ if (!at || M.button !== 0) return;
1604
+ const I = a.current;
1605
+ if (!I) return;
1606
+ const A = Ct(M.clientX, M.clientY);
1607
+ A && (M.preventDefault(), M.stopPropagation(), I.setPointerCapture(M.pointerId), h.current = { active: !0, pointerId: M.pointerId }, zt(A[0], A[1]));
1596
1608
  },
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]));
1609
+ [at, Ct, zt]
1610
+ ), dt = B(
1611
+ (M) => {
1612
+ const I = h.current;
1613
+ if (!I.active || I.pointerId !== M.pointerId) return;
1614
+ const A = Ct(M.clientX, M.clientY);
1615
+ A && (M.preventDefault(), M.stopPropagation(), zt(A[0], A[1]));
1604
1616
  },
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))
1617
+ [Ct, zt]
1618
+ ), Q = B(
1619
+ (M) => {
1620
+ const I = h.current;
1621
+ if (!I.active || I.pointerId !== M.pointerId) return;
1622
+ const A = a.current;
1623
+ if (A && A.hasPointerCapture(M.pointerId))
1612
1624
  try {
1613
- I.releasePointerCapture(P.pointerId);
1625
+ A.releasePointerCapture(M.pointerId);
1614
1626
  } catch {
1615
1627
  }
1616
- h.current = { active: !1, pointerId: null }, rt();
1628
+ h.current = { active: !1, pointerId: null }, K();
1617
1629
  },
1618
- [rt]
1630
+ [K]
1619
1631
  );
1620
1632
  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)
1633
+ let M = !1;
1634
+ u.current = null, K();
1635
+ const I = 0, A = 2 ** (e.maxTierZoom - I), 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;
1636
+ if (!$ || yt > C)
1625
1637
  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)
1638
+ const U = document.createElement("canvas");
1639
+ U.width = Math.max(1, Math.round(p)), U.height = Math.max(1, Math.round(x));
1640
+ const At = U.getContext("2d");
1641
+ if (!At)
1630
1642
  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]
1643
+ At.fillStyle = E, At.fillRect(0, 0, U.width, U.height);
1644
+ const gt = [];
1645
+ for (let N = 0; N < mt; N += 1)
1646
+ for (let G = 0; G < et; G += 1) {
1647
+ 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;
1648
+ gt.push({
1649
+ url: Wn(e, I, G, N),
1650
+ bounds: [ut, nt, rt, q]
1639
1651
  });
1640
1652
  }
1641
1653
  return Promise.allSettled(
1642
- J.map(async (G) => {
1643
- const q = !!n, ot = await fetch(G.url, {
1644
- headers: q ? { Authorization: n } : void 0
1654
+ gt.map(async (N) => {
1655
+ const G = !!n, ut = await fetch(N.url, {
1656
+ headers: G ? { Authorization: n } : void 0
1645
1657
  });
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 };
1658
+ if (!ut.ok)
1659
+ throw new Error(`HTTP ${ut.status}`);
1660
+ const nt = await createImageBitmap(await ut.blob());
1661
+ return { tile: N, bitmap: nt };
1650
1662
  })
1651
- ).then((G) => {
1652
- if (P) {
1653
- for (const st of G)
1654
- st.status === "fulfilled" && st.value.bitmap.close();
1663
+ ).then((N) => {
1664
+ if (M) {
1665
+ for (const nt of N)
1666
+ nt.status === "fulfilled" && nt.value.bitmap.close();
1655
1667
  return;
1656
1668
  }
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;
1669
+ const G = U.width / Math.max(1, e.width), ut = U.height / Math.max(1, e.height);
1670
+ for (const nt of N) {
1671
+ if (nt.status !== "fulfilled") continue;
1660
1672
  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();
1673
+ tile: { bounds: rt },
1674
+ bitmap: q
1675
+ } = 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);
1676
+ At.drawImage(q, It, _t, F, ct), q.close();
1665
1677
  }
1666
- u.current = tt, rt();
1678
+ u.current = U, K();
1667
1679
  }), () => {
1668
- P = !0;
1680
+ M = !0;
1669
1681
  };
1670
1682
  }, [
1671
1683
  e,
1672
1684
  n,
1673
- w,
1674
- y,
1675
- M,
1676
- W,
1677
- R,
1678
- rt
1685
+ p,
1686
+ x,
1687
+ E,
1688
+ $,
1689
+ C,
1690
+ K
1679
1691
  ]), X(() => {
1680
- rt();
1681
- }, [rt]), X(() => {
1692
+ K();
1693
+ }, [K]), X(() => {
1682
1694
  if (i)
1683
- return i.current = rt, () => {
1684
- i.current === rt && (i.current = null);
1695
+ return i.current = K, () => {
1696
+ i.current === K && (i.current = null);
1685
1697
  };
1686
- }, [i, rt]), X(
1698
+ }, [i, K]), X(
1687
1699
  () => () => {
1688
1700
  h.current = { active: !1, pointerId: null }, g.current !== null && (cancelAnimationFrame(g.current), g.current = null), d.current = !1;
1689
1701
  },
1690
1702
  []
1691
- ), /* @__PURE__ */ Bt(
1703
+ ), /* @__PURE__ */ Ut(
1692
1704
  "canvas",
1693
1705
  {
1694
1706
  ref: a,
1695
1707
  className: o,
1696
- style: zt,
1697
- onPointerDown: dt,
1698
- onPointerMove: it,
1699
- onPointerUp: mt,
1700
- onPointerCancel: mt,
1701
- onContextMenu: (P) => {
1702
- P.preventDefault();
1708
+ style: vt,
1709
+ onPointerDown: Kt,
1710
+ onPointerMove: dt,
1711
+ onPointerUp: Q,
1712
+ onPointerCancel: Q,
1713
+ onContextMenu: (M) => {
1714
+ M.preventDefault();
1703
1715
  },
1704
- onWheel: (P) => {
1705
- P.preventDefault(), P.stopPropagation();
1716
+ onWheel: (M) => {
1717
+ M.preventDefault(), M.stopPropagation();
1706
1718
  }
1707
1719
  }
1708
1720
  );
1709
1721
  }
1710
- function co({
1722
+ function go({
1711
1723
  imageWidth: e,
1712
1724
  imageHeight: t,
1713
1725
  tiles: n,
@@ -1715,7 +1727,7 @@ function co({
1715
1727
  className: i,
1716
1728
  style: o
1717
1729
  }) {
1718
- const s = H(null), a = H(null), u = Z(
1730
+ const s = j(null), a = j(null), u = tt(
1719
1731
  () => ({ width: "100%", height: "100%", display: "block", ...o }),
1720
1732
  [o]
1721
1733
  );
@@ -1723,7 +1735,7 @@ function co({
1723
1735
  const c = s.current;
1724
1736
  if (!c)
1725
1737
  return;
1726
- const h = new lr({
1738
+ const h = new hr({
1727
1739
  canvas: c,
1728
1740
  imageWidth: e,
1729
1741
  imageHeight: t,
@@ -1738,9 +1750,9 @@ function co({
1738
1750
  }, [n]), X(() => {
1739
1751
  const c = a.current;
1740
1752
  !c || !r || c.setViewState(r);
1741
- }, [r]), /* @__PURE__ */ Bt("canvas", { ref: s, className: i, style: u });
1753
+ }, [r]), /* @__PURE__ */ Ut("canvas", { ref: s, className: i, style: u });
1742
1754
  }
1743
- function On(e) {
1755
+ function Vn(e) {
1744
1756
  return Math.max(
1745
1757
  0,
1746
1758
  Math.min(
@@ -1750,15 +1762,15 @@ function On(e) {
1750
1762
  )
1751
1763
  );
1752
1764
  }
1753
- function di(e) {
1765
+ function wi(e) {
1754
1766
  if (!Array.isArray(e) || e.length < 3) return [];
1755
1767
  const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
1756
1768
  return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
1757
1769
  }
1758
- function Vn(e) {
1770
+ function On(e) {
1759
1771
  const t = [];
1760
1772
  for (const n of e ?? []) {
1761
- const r = di(n);
1773
+ const r = wi(n);
1762
1774
  if (r.length < 4) continue;
1763
1775
  let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
1764
1776
  for (const [u, c] of r)
@@ -1767,7 +1779,7 @@ function Vn(e) {
1767
1779
  }
1768
1780
  return t;
1769
1781
  }
1770
- function mi(e, t, n) {
1782
+ function yi(e, t, n) {
1771
1783
  let r = !1;
1772
1784
  for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
1773
1785
  const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
@@ -1777,25 +1789,25 @@ function mi(e, t, n) {
1777
1789
  }
1778
1790
  function Gn(e, t, n) {
1779
1791
  for (const r of n)
1780
- if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && mi(e, t, r.ring))
1792
+ if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && yi(e, t, r.ring))
1781
1793
  return !0;
1782
1794
  return !1;
1783
1795
  }
1784
- function Pe(e, t) {
1796
+ function Ee(e, t) {
1785
1797
  if (!e || !e.count || !e.positions || !e.paletteIndices)
1786
1798
  return null;
1787
- const n = Vn(t ?? []);
1799
+ const n = On(t ?? []);
1788
1800
  if (n.length === 0)
1789
1801
  return {
1790
1802
  count: 0,
1791
1803
  positions: new Float32Array(0),
1792
1804
  paletteIndices: new Uint16Array(0)
1793
1805
  };
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;
1806
+ 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
1807
  let h = 0;
1796
1808
  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);
1809
+ const p = i[d * 2], x = i[d * 2 + 1];
1810
+ 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
1811
  }
1800
1812
  const g = {
1801
1813
  count: h,
@@ -1804,13 +1816,13 @@ function Pe(e, t) {
1804
1816
  };
1805
1817
  return c && (g.ids = c.subarray(0, h)), g;
1806
1818
  }
1807
- function gi(e, t) {
1819
+ function xi(e, t) {
1808
1820
  if (!e || !e.count || !e.positions || !e.paletteIndices)
1809
1821
  return new Uint32Array(0);
1810
- const n = Vn(t ?? []);
1822
+ const n = On(t ?? []);
1811
1823
  if (n.length === 0)
1812
1824
  return new Uint32Array(0);
1813
- const r = On(e);
1825
+ const r = Vn(e);
1814
1826
  if (r === 0)
1815
1827
  return new Uint32Array(0);
1816
1828
  const i = e.positions, o = new Uint32Array(r);
@@ -1821,8 +1833,8 @@ function gi(e, t) {
1821
1833
  }
1822
1834
  return o.subarray(0, s);
1823
1835
  }
1824
- let ye = null;
1825
- const pi = `
1836
+ let xe = null;
1837
+ const Si = `
1826
1838
  struct Params {
1827
1839
  pointCount: u32,
1828
1840
  boundsCount: u32,
@@ -1854,20 +1866,20 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
1854
1866
  outputMask[i] = inside;
1855
1867
  }
1856
1868
  `;
1857
- function bi() {
1869
+ function Ti() {
1858
1870
  if (typeof navigator > "u") return !1;
1859
1871
  const e = navigator;
1860
1872
  return typeof e.gpu == "object" && e.gpu !== null;
1861
1873
  }
1862
1874
  function qn() {
1863
- if (!bi()) return null;
1875
+ if (!Ti()) return null;
1864
1876
  const t = navigator.gpu;
1865
1877
  if (!t || typeof t != "object") return null;
1866
1878
  const n = t;
1867
1879
  return typeof n.requestAdapter != "function" ? null : n;
1868
1880
  }
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() {
1881
+ const Se = globalThis.GPUShaderStage?.COMPUTE ?? 4, Ue = globalThis.GPUBufferUsage?.STORAGE ?? 128, Te = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Mi = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Ai = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Pi = globalThis.GPUBufferUsage?.MAP_READ ?? 1, Ei = globalThis.GPUMapMode?.READ ?? 1;
1882
+ async function po() {
1871
1883
  const e = qn();
1872
1884
  if (!e)
1873
1885
  return { supported: !1, features: [] };
@@ -1887,8 +1899,8 @@ async function lo() {
1887
1899
  }
1888
1900
  } : { supported: !1, features: [] };
1889
1901
  }
1890
- async function Ti() {
1891
- return ye || (ye = (async () => {
1902
+ async function Ri() {
1903
+ return xe || (xe = (async () => {
1892
1904
  const e = qn();
1893
1905
  if (!e) return null;
1894
1906
  const t = await e.requestAdapter();
@@ -1897,40 +1909,40 @@ async function Ti() {
1897
1909
  entries: [
1898
1910
  {
1899
1911
  binding: 0,
1900
- visibility: xe,
1912
+ visibility: Se,
1901
1913
  buffer: { type: "read-only-storage" }
1902
1914
  },
1903
1915
  {
1904
1916
  binding: 1,
1905
- visibility: xe,
1917
+ visibility: Se,
1906
1918
  buffer: { type: "read-only-storage" }
1907
1919
  },
1908
1920
  {
1909
1921
  binding: 2,
1910
- visibility: xe,
1922
+ visibility: Se,
1911
1923
  buffer: { type: "storage" }
1912
1924
  },
1913
1925
  {
1914
1926
  binding: 3,
1915
- visibility: xe,
1927
+ visibility: Se,
1916
1928
  buffer: { type: "uniform" }
1917
1929
  }
1918
1930
  ]
1919
1931
  }), i = n.createComputePipeline({
1920
1932
  layout: n.createPipelineLayout({ bindGroupLayouts: [r] }),
1921
1933
  compute: {
1922
- module: n.createShaderModule({ code: pi }),
1934
+ module: n.createShaderModule({ code: Si }),
1923
1935
  entryPoint: "main"
1924
1936
  }
1925
1937
  });
1926
1938
  return { device: n, pipeline: i, bindGroupLayout: r };
1927
- })(), ye);
1939
+ })(), xe);
1928
1940
  }
1929
- function Te(e, t) {
1941
+ function Me(e, t) {
1930
1942
  return Math.ceil(e / t) * t;
1931
1943
  }
1932
- async function Mi(e, t, n) {
1933
- const r = await Ti();
1944
+ async function vi(e, t, n) {
1945
+ const r = await Ri();
1934
1946
  if (!r) return null;
1935
1947
  const i = Math.max(0, Math.floor(t)), o = Math.max(0, Math.floor(n.length / 4));
1936
1948
  if (i === 0 || o === 0)
@@ -1942,20 +1954,20 @@ async function Mi(e, t, n) {
1942
1954
  if (a > h || u > h || c > h)
1943
1955
  return null;
1944
1956
  const g = r.device.createBuffer({
1945
- size: Te(a, 4),
1946
- usage: Be | Se
1957
+ size: Me(a, 4),
1958
+ usage: Ue | Te
1947
1959
  }), 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
1960
+ size: Me(u, 4),
1961
+ usage: Ue | Te
1962
+ }), p = r.device.createBuffer({
1963
+ size: Me(c, 4),
1964
+ usage: Ue | Mi
1956
1965
  }), x = r.device.createBuffer({
1957
- size: Te(c, 4),
1958
- usage: Se | xi
1966
+ size: 16,
1967
+ usage: Ai | Te
1968
+ }), S = r.device.createBuffer({
1969
+ size: Me(c, 4),
1970
+ usage: Te | Pi
1959
1971
  });
1960
1972
  r.device.queue.writeBuffer(
1961
1973
  g,
@@ -1970,35 +1982,35 @@ async function Mi(e, t, n) {
1970
1982
  n.byteOffset,
1971
1983
  u
1972
1984
  ), r.device.queue.writeBuffer(
1973
- y,
1985
+ x,
1974
1986
  0,
1975
1987
  new Uint32Array([s, o, 0, 0])
1976
1988
  );
1977
- const A = r.device.createBindGroup({
1989
+ const P = r.device.createBindGroup({
1978
1990
  layout: r.bindGroupLayout,
1979
1991
  entries: [
1980
1992
  { binding: 0, resource: { buffer: g } },
1981
1993
  { binding: 1, resource: { buffer: d } },
1982
- { binding: 2, resource: { buffer: w } },
1983
- { binding: 3, resource: { buffer: y } }
1994
+ { binding: 2, resource: { buffer: p } },
1995
+ { binding: 3, resource: { buffer: x } }
1984
1996
  ]
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;
1997
+ }), k = r.device.createCommandEncoder(), C = k.beginComputePass();
1998
+ C.setPipeline(r.pipeline), C.setBindGroup(0, P), C.dispatchWorkgroups(Math.ceil(s / 256)), C.end(), k.copyBufferToBuffer(p, 0, S, 0, c), r.device.queue.submit([k.finish()]), await S.mapAsync(Ei);
1999
+ const E = S.getMappedRange(), D = new Uint32Array(E.slice(0));
2000
+ return S.unmap(), g.destroy(), d.destroy(), p.destroy(), x.destroy(), S.destroy(), D;
1989
2001
  }
1990
- function Dt() {
2002
+ function Lt() {
1991
2003
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1992
2004
  }
1993
- function Ai(e) {
2005
+ function Ci(e) {
1994
2006
  if (!Array.isArray(e) || e.length < 3) return [];
1995
2007
  const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
1996
2008
  return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
1997
2009
  }
1998
- function Pi(e) {
2010
+ function Ii(e) {
1999
2011
  const t = [];
2000
2012
  for (const n of e ?? []) {
2001
- const r = Ai(n);
2013
+ const r = Ci(n);
2002
2014
  if (r.length < 4) continue;
2003
2015
  let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
2004
2016
  for (const [u, c] of r)
@@ -2007,7 +2019,7 @@ function Pi(e) {
2007
2019
  }
2008
2020
  return t;
2009
2021
  }
2010
- function vi(e, t, n) {
2022
+ function _i(e, t, n) {
2011
2023
  let r = !1;
2012
2024
  for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
2013
2025
  const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
@@ -2015,26 +2027,26 @@ function vi(e, t, n) {
2015
2027
  }
2016
2028
  return r;
2017
2029
  }
2018
- function En(e, t, n) {
2030
+ function Cn(e, t, n) {
2019
2031
  for (const r of n)
2020
- if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && vi(e, t, r.ring))
2032
+ if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && _i(e, t, r.ring))
2021
2033
  return !0;
2022
2034
  return !1;
2023
2035
  }
2024
- async function Ri(e, t, n = {}) {
2025
- const r = Dt(), i = n.bridgeToDraw === !0;
2036
+ async function Bi(e, t, n = {}) {
2037
+ const r = Lt(), i = n.bridgeToDraw === !0;
2026
2038
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2027
2039
  return {
2028
2040
  data: null,
2029
2041
  meta: {
2030
2042
  mode: "hybrid-webgpu",
2031
- durationMs: Dt() - r,
2043
+ durationMs: Lt() - r,
2032
2044
  usedWebGpu: !1,
2033
2045
  candidateCount: 0,
2034
2046
  bridgedToDraw: !1
2035
2047
  }
2036
2048
  };
2037
- const o = Pi(t ?? []);
2049
+ const o = Ii(t ?? []);
2038
2050
  if (o.length === 0)
2039
2051
  return {
2040
2052
  data: {
@@ -2044,7 +2056,7 @@ async function Ri(e, t, n = {}) {
2044
2056
  },
2045
2057
  meta: {
2046
2058
  mode: "hybrid-webgpu",
2047
- durationMs: Dt() - r,
2059
+ durationMs: Lt() - r,
2048
2060
  usedWebGpu: !1,
2049
2061
  candidateCount: 0,
2050
2062
  bridgedToDraw: !1
@@ -2060,56 +2072,56 @@ async function Ri(e, t, n = {}) {
2060
2072
  },
2061
2073
  meta: {
2062
2074
  mode: "hybrid-webgpu",
2063
- durationMs: Dt() - r,
2075
+ durationMs: Lt() - r,
2064
2076
  usedWebGpu: !1,
2065
2077
  candidateCount: 0,
2066
2078
  bridgedToDraw: !1
2067
2079
  }
2068
2080
  };
2069
2081
  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;
2082
+ for (let C = 0; C < o.length; C += 1) {
2083
+ const E = C * 4, D = o[C];
2084
+ u[E] = D.minX, u[E + 1] = D.minY, u[E + 2] = D.maxX, u[E + 3] = D.maxY;
2073
2085
  }
2074
2086
  let c = null, h = !1;
2075
2087
  try {
2076
- c = await Mi(e.positions, s, u), h = !!c;
2088
+ c = await vi(e.positions, s, u), h = !!c;
2077
2089
  } catch {
2078
2090
  c = null, h = !1;
2079
2091
  }
2080
2092
  if (!c)
2081
2093
  return {
2082
- data: Pe(e, t),
2094
+ data: Ee(e, t),
2083
2095
  meta: {
2084
2096
  mode: "hybrid-webgpu",
2085
- durationMs: Dt() - r,
2097
+ durationMs: Lt() - r,
2086
2098
  usedWebGpu: !1,
2087
2099
  candidateCount: s,
2088
2100
  bridgedToDraw: !1
2089
2101
  }
2090
2102
  };
2091
2103
  let g = 0;
2092
- for (let R = 0; R < s; R += 1)
2093
- c[R] === 1 && (g += 1);
2104
+ for (let C = 0; C < s; C += 1)
2105
+ c[C] === 1 && (g += 1);
2094
2106
  const d = new Uint32Array(g);
2095
2107
  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);
2108
+ let C = 0;
2109
+ for (let E = 0; E < s; E += 1)
2110
+ c[E] === 1 && (d[C] = E, C += 1);
2099
2111
  }
2100
2112
  if (g === 0) {
2101
2113
  if (i) {
2102
- const R = {
2114
+ const C = {
2103
2115
  count: s,
2104
2116
  positions: e.positions.subarray(0, s * 2),
2105
2117
  paletteIndices: e.paletteIndices.subarray(0, s),
2106
2118
  drawIndices: new Uint32Array(0)
2107
2119
  };
2108
- return a && (R.ids = a.subarray(0, s)), {
2109
- data: R,
2120
+ return a && (C.ids = a.subarray(0, s)), {
2121
+ data: C,
2110
2122
  meta: {
2111
2123
  mode: "hybrid-webgpu",
2112
- durationMs: Dt() - r,
2124
+ durationMs: Lt() - r,
2113
2125
  usedWebGpu: !0,
2114
2126
  candidateCount: 0,
2115
2127
  bridgedToDraw: !0
@@ -2125,7 +2137,7 @@ async function Ri(e, t, n = {}) {
2125
2137
  },
2126
2138
  meta: {
2127
2139
  mode: "hybrid-webgpu",
2128
- durationMs: Dt() - r,
2140
+ durationMs: Lt() - r,
2129
2141
  usedWebGpu: !0,
2130
2142
  candidateCount: 0,
2131
2143
  bridgedToDraw: !1
@@ -2133,71 +2145,71 @@ async function Ri(e, t, n = {}) {
2133
2145
  };
2134
2146
  }
2135
2147
  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);
2148
+ const C = new Uint32Array(g);
2149
+ let E = 0;
2150
+ for (let J = 0; J < g; J += 1) {
2151
+ const ft = d[J] ?? 0, at = e.positions[ft * 2], $ = e.positions[ft * 2 + 1];
2152
+ Cn(at, $, o) && (C[E] = ft, E += 1);
2141
2153
  }
2142
- const U = {
2154
+ const D = {
2143
2155
  count: s,
2144
2156
  positions: e.positions.subarray(0, s * 2),
2145
2157
  paletteIndices: e.paletteIndices.subarray(0, s),
2146
- drawIndices: R.subarray(0, M)
2158
+ drawIndices: C.subarray(0, E)
2147
2159
  };
2148
- return a && (U.ids = a.subarray(0, s)), {
2149
- data: U,
2160
+ return a && (D.ids = a.subarray(0, s)), {
2161
+ data: D,
2150
2162
  meta: {
2151
2163
  mode: "hybrid-webgpu",
2152
- durationMs: Dt() - r,
2164
+ durationMs: Lt() - r,
2153
2165
  usedWebGpu: !0,
2154
2166
  candidateCount: g,
2155
2167
  bridgedToDraw: !0
2156
2168
  }
2157
2169
  };
2158
2170
  }
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);
2171
+ const p = new Float32Array(g * 2), x = new Uint16Array(g), S = a ? new Uint32Array(g) : null;
2172
+ let P = 0;
2173
+ for (let C = 0; C < g; C += 1) {
2174
+ const E = d[C] ?? 0, D = e.positions[E * 2], J = e.positions[E * 2 + 1];
2175
+ Cn(D, J, o) && (p[P * 2] = D, p[P * 2 + 1] = J, x[P] = e.paletteIndices[E], S && (S[P] = a[E]), P += 1);
2164
2176
  }
2165
- const N = {
2166
- count: A,
2167
- positions: w.subarray(0, A * 2),
2168
- paletteIndices: y.subarray(0, A)
2177
+ const k = {
2178
+ count: P,
2179
+ positions: p.subarray(0, P * 2),
2180
+ paletteIndices: x.subarray(0, P)
2169
2181
  };
2170
- return x && (N.ids = x.subarray(0, A)), {
2171
- data: N,
2182
+ return S && (k.ids = S.subarray(0, P)), {
2183
+ data: k,
2172
2184
  meta: {
2173
2185
  mode: "hybrid-webgpu",
2174
- durationMs: Dt() - r,
2186
+ durationMs: Lt() - r,
2175
2187
  usedWebGpu: !0,
2176
2188
  candidateCount: g,
2177
2189
  bridgedToDraw: !1
2178
2190
  }
2179
2191
  };
2180
2192
  }
2181
- let Tt = null, Xe = !0, $n = 1;
2193
+ let wt = null, Ye = !0, $n = 1;
2182
2194
  const Vt = /* @__PURE__ */ new Map();
2183
- function Wt() {
2195
+ function Yt() {
2184
2196
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2185
2197
  }
2186
2198
  function Hn() {
2187
- if (!Xe) return null;
2188
- if (Tt) return Tt;
2199
+ if (!Ye) return null;
2200
+ if (wt) return wt;
2189
2201
  try {
2190
2202
  const e = new Worker(new URL(
2191
2203
  /* @vite-ignore */
2192
2204
  "" + new URL("assets/roi-clip-worker-D3hALtsJ.js", import.meta.url).href,
2193
2205
  import.meta.url
2194
2206
  ), { type: "module" });
2195
- return e.addEventListener("message", Ge), e.addEventListener("error", qe), Tt = e, e;
2207
+ return e.addEventListener("message", qe), e.addEventListener("error", $e), wt = e, e;
2196
2208
  } catch {
2197
- return Xe = !1, null;
2209
+ return Ye = !1, null;
2198
2210
  }
2199
2211
  }
2200
- function Ge(e) {
2212
+ function qe(e) {
2201
2213
  const t = e.data;
2202
2214
  if (!t) return;
2203
2215
  const n = Vt.get(t.id);
@@ -2216,7 +2228,7 @@ function Ge(e) {
2216
2228
  indices: c,
2217
2229
  meta: {
2218
2230
  mode: "worker",
2219
- durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Wt() - n.startMs
2231
+ durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
2220
2232
  }
2221
2233
  });
2222
2234
  return;
@@ -2234,25 +2246,25 @@ function Ge(e) {
2234
2246
  data: a,
2235
2247
  meta: {
2236
2248
  mode: "worker",
2237
- durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Wt() - n.startMs
2249
+ durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
2238
2250
  }
2239
2251
  });
2240
2252
  }
2241
- function qe() {
2242
- Xe = !1, Tt && (Tt.removeEventListener("message", Ge), Tt.removeEventListener("error", qe), Tt.terminate(), Tt = null);
2253
+ function $e() {
2254
+ Ye = !1, wt && (wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null);
2243
2255
  for (const [, e] of Vt)
2244
2256
  e.reject(new Error("worker crashed"));
2245
2257
  Vt.clear();
2246
2258
  }
2247
- function ho() {
2248
- if (Tt) {
2249
- Tt.removeEventListener("message", Ge), Tt.removeEventListener("error", qe), Tt.terminate(), Tt = null;
2259
+ function bo() {
2260
+ if (wt) {
2261
+ wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null;
2250
2262
  for (const [, e] of Vt)
2251
2263
  e.reject(new Error("worker terminated"));
2252
2264
  Vt.clear();
2253
2265
  }
2254
2266
  }
2255
- async function Ei(e, t) {
2267
+ async function Fi(e, t) {
2256
2268
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2257
2269
  return {
2258
2270
  data: null,
@@ -2260,13 +2272,13 @@ async function Ei(e, t) {
2260
2272
  };
2261
2273
  const n = Hn();
2262
2274
  if (!n) {
2263
- const c = Wt();
2275
+ const c = Yt();
2264
2276
  return {
2265
- data: Pe(e, t),
2266
- meta: { mode: "sync", durationMs: Wt() - c }
2277
+ data: Ee(e, t),
2278
+ meta: { mode: "sync", durationMs: Yt() - c }
2267
2279
  };
2268
2280
  }
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();
2281
+ 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
2282
  return new Promise((c, h) => {
2271
2283
  Vt.set(a, { kind: "data", resolve: c, reject: h, startMs: u });
2272
2284
  const g = {
@@ -2281,7 +2293,7 @@ async function Ei(e, t) {
2281
2293
  s && d.push(s.buffer), n.postMessage(g, d);
2282
2294
  });
2283
2295
  }
2284
- async function fo(e, t) {
2296
+ async function wo(e, t) {
2285
2297
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2286
2298
  return {
2287
2299
  indices: new Uint32Array(0),
@@ -2289,13 +2301,13 @@ async function fo(e, t) {
2289
2301
  };
2290
2302
  const n = Hn();
2291
2303
  if (!n) {
2292
- const a = Wt();
2304
+ const a = Yt();
2293
2305
  return {
2294
- indices: gi(e, t),
2295
- meta: { mode: "sync", durationMs: Wt() - a }
2306
+ indices: xi(e, t),
2307
+ meta: { mode: "sync", durationMs: Yt() - a }
2296
2308
  };
2297
2309
  }
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();
2310
+ 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
2311
  return new Promise((a, u) => {
2300
2312
  Vt.set(o, { kind: "index", resolve: a, reject: u, startMs: s });
2301
2313
  const c = {
@@ -2308,14 +2320,14 @@ async function fo(e, t) {
2308
2320
  n.postMessage(c, [i.buffer]);
2309
2321
  });
2310
2322
  }
2311
- function Ci(e) {
2323
+ function Ui(e) {
2312
2324
  if (!Array.isArray(e) || e.length < 3) return [];
2313
2325
  const t = e.map(
2314
2326
  (i) => [Number(i[0]), Number(i[1])]
2315
2327
  ), n = t[0], r = t[t.length - 1];
2316
2328
  return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
2317
2329
  }
2318
- function Ii(e) {
2330
+ function zi(e) {
2319
2331
  let t = 0;
2320
2332
  for (let n = 0; n < e.length - 1; n += 1) {
2321
2333
  const [r, i] = e[n], [o, s] = e[n + 1];
@@ -2323,12 +2335,12 @@ function Ii(e) {
2323
2335
  }
2324
2336
  return Math.abs(t * 0.5);
2325
2337
  }
2326
- function _i(e) {
2338
+ function Li(e) {
2327
2339
  const t = [];
2328
2340
  for (let n = 0; n < e.length; n += 1) {
2329
2341
  const r = e[n];
2330
2342
  if (!r?.coordinates?.length) continue;
2331
- const i = Ci(r.coordinates);
2343
+ const i = Ui(r.coordinates);
2332
2344
  if (i.length < 4) continue;
2333
2345
  let o = 1 / 0, s = 1 / 0, a = -1 / 0, u = -1 / 0;
2334
2346
  for (const [c, h] of i)
@@ -2341,12 +2353,12 @@ function _i(e) {
2341
2353
  minY: s,
2342
2354
  maxX: a,
2343
2355
  maxY: u,
2344
- area: Math.max(1e-6, Ii(i))
2356
+ area: Math.max(1e-6, zi(i))
2345
2357
  });
2346
2358
  }
2347
2359
  return t;
2348
2360
  }
2349
- function Fi(e, t, n) {
2361
+ function Di(e, t, n) {
2350
2362
  let r = !1;
2351
2363
  for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
2352
2364
  const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
@@ -2354,7 +2366,7 @@ function Fi(e, t, n) {
2354
2366
  }
2355
2367
  return r;
2356
2368
  }
2357
- function Ui(e, t) {
2369
+ function Ni(e, t) {
2358
2370
  if (Array.isArray(t)) {
2359
2371
  const n = t[e];
2360
2372
  if (typeof n == "string" && n.length > 0) return n;
@@ -2365,7 +2377,7 @@ function Ui(e, t) {
2365
2377
  }
2366
2378
  return String(e);
2367
2379
  }
2368
- function Bi(e, t, n = {}) {
2380
+ function ki(e, t, n = {}) {
2369
2381
  const r = Math.max(
2370
2382
  0,
2371
2383
  Math.min(
@@ -2377,23 +2389,23 @@ function Bi(e, t, n = {}) {
2377
2389
  let i = null;
2378
2390
  if (e?.drawIndices instanceof Uint32Array) {
2379
2391
  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)
2392
+ let p = d.length;
2393
+ for (let x = 0; x < d.length; x += 1)
2394
+ d[x] < r || (p -= 1);
2395
+ if (p === d.length)
2384
2396
  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);
2397
+ else if (p > 0) {
2398
+ const x = new Uint32Array(p);
2399
+ let S = 0;
2400
+ for (let P = 0; P < d.length; P += 1) {
2401
+ const k = d[P];
2402
+ k >= r || (x[S] = k, S += 1);
2391
2403
  }
2392
- i = y;
2404
+ i = x;
2393
2405
  } else
2394
2406
  i = new Uint32Array(0);
2395
2407
  }
2396
- const o = i ? i.length : r, s = _i(t ?? []);
2408
+ const o = i ? i.length : r, s = Li(t ?? []);
2397
2409
  if (!e || o === 0 || s.length === 0)
2398
2410
  return {
2399
2411
  groups: [],
@@ -2404,32 +2416,32 @@ function Bi(e, t, n = {}) {
2404
2416
  const a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
2405
2417
  let c = 0;
2406
2418
  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;
2419
+ const p = i ? i[d] : d, x = e.positions[p * 2], S = e.positions[p * 2 + 1];
2420
+ let P = null;
2421
+ for (const E of s)
2422
+ x < E.minX || x > E.maxX || S < E.minY || S > E.maxY || Di(x, S, E.ring) && (!P || E.area < P.area) && (P = E);
2423
+ if (!P) continue;
2412
2424
  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
2425
+ const k = e.paletteIndices[p] ?? 0, C = a.get(P.regionIndex) ?? /* @__PURE__ */ new Map();
2426
+ C.set(k, (C.get(k) ?? 0) + 1), a.set(P.regionIndex, C), u.set(
2427
+ P.regionIndex,
2428
+ (u.get(P.regionIndex) ?? 0) + 1
2417
2429
  );
2418
2430
  }
2419
2431
  const h = n.includeEmptyRegions ?? !1, g = [];
2420
2432
  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);
2433
+ const p = u.get(d.regionIndex) ?? 0;
2434
+ if (!h && p <= 0) continue;
2435
+ const x = a.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(x.entries()).map(([P, k]) => ({
2436
+ termId: Ni(P, n.paletteIndexToTermId),
2437
+ paletteIndex: P,
2438
+ count: k
2439
+ })).sort((P, k) => k.count - P.count || P.paletteIndex - k.paletteIndex);
2428
2440
  g.push({
2429
2441
  regionId: d.regionId,
2430
2442
  regionIndex: d.regionIndex,
2431
- totalCount: w,
2432
- termCounts: x
2443
+ totalCount: p,
2444
+ termCounts: S
2433
2445
  });
2434
2446
  }
2435
2447
  return {
@@ -2439,10 +2451,10 @@ function Bi(e, t, n = {}) {
2439
2451
  unmatchedPointCount: Math.max(0, o - c)
2440
2452
  };
2441
2453
  }
2442
- function Me() {
2454
+ function Ae() {
2443
2455
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2444
2456
  }
2445
- function zi(e, t) {
2457
+ function Xi(e, t) {
2446
2458
  if (!t) return !1;
2447
2459
  try {
2448
2460
  const r = new URL(e, typeof window < "u" ? window.location.href : void 0).hostname.toLowerCase();
@@ -2451,7 +2463,7 @@ function zi(e, t) {
2451
2463
  }
2452
2464
  return !0;
2453
2465
  }
2454
- class Li {
2466
+ class Yi {
2455
2467
  constructor(t) {
2456
2468
  b(this, "maxConcurrency");
2457
2469
  b(this, "maxRetries");
@@ -2501,7 +2513,7 @@ class Li {
2501
2513
  const o = {
2502
2514
  tile: r,
2503
2515
  attempt: 0,
2504
- readyAt: Me()
2516
+ readyAt: Ae()
2505
2517
  };
2506
2518
  this.queue.push(o), this.queuedByKey.set(r.key, o);
2507
2519
  }
@@ -2557,14 +2569,14 @@ class Li {
2557
2569
  if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
2558
2570
  const t = this.queue[0]?.readyAt;
2559
2571
  if (typeof t != "number") return;
2560
- const n = Math.max(0, t - Me());
2572
+ const n = Math.max(0, t - Ae());
2561
2573
  this.timerId = window.setTimeout(() => {
2562
2574
  this.timerId = null, this.pump();
2563
2575
  }, n);
2564
2576
  }
2565
2577
  takeNextReadyQueueItem() {
2566
2578
  if (this.queue.length === 0) return null;
2567
- const t = Me(), n = this.queue[0];
2579
+ const t = Ae(), n = this.queue[0];
2568
2580
  return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
2569
2581
  }
2570
2582
  startFetch(t) {
@@ -2574,7 +2586,7 @@ class Li {
2574
2586
  controller: n
2575
2587
  };
2576
2588
  this.inflight.set(t.tile.key, r), this.emitStateChange();
2577
- const i = zi(t.tile.url, this.authToken);
2589
+ const i = Xi(t.tile.url, this.authToken);
2578
2590
  fetch(t.tile.url, {
2579
2591
  signal: n.signal,
2580
2592
  headers: i ? { Authorization: this.authToken } : void 0
@@ -2600,7 +2612,7 @@ class Li {
2600
2612
  const a = t.attempt + 1, u = this.getRetryDelay(a), c = {
2601
2613
  tile: t.tile,
2602
2614
  attempt: a,
2603
- readyAt: Me() + u
2615
+ readyAt: Ae() + u
2604
2616
  }, h = this.queuedByKey.get(t.tile.key);
2605
2617
  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
2618
  return;
@@ -2624,7 +2636,7 @@ class Li {
2624
2636
  this.onStateChange?.(this.getSnapshot());
2625
2637
  }
2626
2638
  }
2627
- const Cn = 0.35, Ye = 0.5, Ni = 256, We = [
2639
+ const In = 0.35, We = 0.5, Wi = 256, Ve = [
2628
2640
  { zoom: 1, size: 2.8 },
2629
2641
  { zoom: 2, size: 3.4 },
2630
2642
  { zoom: 3, size: 4.2 },
@@ -2638,7 +2650,7 @@ const Cn = 0.35, Ye = 0.5, Ni = 256, We = [
2638
2650
  { zoom: 11, size: 22 },
2639
2651
  { zoom: 12, size: 28 }
2640
2652
  ];
2641
- class Di {
2653
+ class Vi {
2642
2654
  constructor() {
2643
2655
  b(this, "viewportWidth", 1);
2644
2656
  b(this, "viewportHeight", 1);
@@ -2677,10 +2689,10 @@ class Di {
2677
2689
  return [o + a * h - u * g, s + a * g + u * h];
2678
2690
  }
2679
2691
  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;
2692
+ 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
2693
  return [
2682
2694
  this.viewportWidth * 0.5 + d * i,
2683
- this.viewportHeight * 0.5 + w * i
2695
+ this.viewportHeight * 0.5 + p * i
2684
2696
  ];
2685
2697
  }
2686
2698
  getViewCorners() {
@@ -2700,7 +2712,7 @@ class Di {
2700
2712
  function ae(e) {
2701
2713
  return e * Math.PI / 180;
2702
2714
  }
2703
- function In() {
2715
+ function _n() {
2704
2716
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2705
2717
  }
2706
2718
  function Zt(e, t, n) {
@@ -2715,16 +2727,16 @@ function ze(e, t) {
2715
2727
  function Oe(e) {
2716
2728
  return e.map((t) => ({ zoom: t.zoom, size: t.size }));
2717
2729
  }
2718
- function _n(e) {
2719
- if (!e) return Oe(We);
2730
+ function Bn(e) {
2731
+ if (!e) return Oe(Ve);
2720
2732
  const t = /* @__PURE__ */ new Map();
2721
2733
  for (const [n, r] of Object.entries(e)) {
2722
2734
  const i = Number(n), o = Number(r);
2723
2735
  !Number.isFinite(i) || !Number.isFinite(o) || o <= 0 || t.set(i, o);
2724
2736
  }
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 }));
2737
+ 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
2738
  }
2727
- function ki(e, t) {
2739
+ function Oi(e, t) {
2728
2740
  if (e === t) return !0;
2729
2741
  if (e.length !== t.length) return !1;
2730
2742
  for (let n = 0; n < e.length; n += 1)
@@ -2732,25 +2744,25 @@ function ki(e, t) {
2732
2744
  return !1;
2733
2745
  return !0;
2734
2746
  }
2735
- function Xi(e, t) {
2736
- if (!Number.isFinite(e)) return t[0]?.size ?? Ye;
2737
- if (t.length === 0) return Ye;
2747
+ function Gi(e, t) {
2748
+ if (!Number.isFinite(e)) return t[0]?.size ?? We;
2749
+ if (t.length === 0) return We;
2738
2750
  if (t.length === 1 || e <= t[0].zoom) return t[0].size;
2739
2751
  for (let s = 1; s < t.length; s += 1) {
2740
2752
  const a = t[s - 1], u = t[s];
2741
2753
  if (e > u.zoom) continue;
2742
- const c = Math.max(1e-6, u.zoom - a.zoom), h = et((e - a.zoom) / c, 0, 1);
2754
+ const c = Math.max(1e-6, u.zoom - a.zoom), h = it((e - a.zoom) / c, 0, 1);
2743
2755
  return a.size + (u.size - a.size) * h;
2744
2756
  }
2745
2757
  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
2758
  return n.size + (e - n.zoom) * o;
2747
2759
  }
2748
- class Yi {
2760
+ class qi {
2749
2761
  constructor(t, n, r = {}) {
2750
2762
  b(this, "canvas");
2751
2763
  b(this, "source");
2752
2764
  b(this, "gl");
2753
- b(this, "camera", new Di());
2765
+ b(this, "camera", new Vi());
2754
2766
  b(this, "onViewStateChange");
2755
2767
  b(this, "onStats");
2756
2768
  b(this, "onTileError");
@@ -2783,7 +2795,7 @@ class Yi {
2783
2795
  b(this, "usePointIndices", !1);
2784
2796
  b(this, "pointBuffersDirty", !0);
2785
2797
  b(this, "pointPaletteSize", 1);
2786
- b(this, "pointSizeStops", Oe(We));
2798
+ b(this, "pointSizeStops", Oe(Ve));
2787
2799
  b(this, "lastPointData", null);
2788
2800
  b(this, "lastPointPalette", null);
2789
2801
  b(this, "cache", /* @__PURE__ */ new Map());
@@ -2795,7 +2807,7 @@ class Yi {
2795
2807
  b(this, "boundContextMenu");
2796
2808
  b(this, "boundContextLost");
2797
2809
  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);
2810
+ 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
2811
  const i = t.getContext("webgl2", {
2800
2812
  alpha: !1,
2801
2813
  antialias: !1,
@@ -2805,7 +2817,7 @@ class Yi {
2805
2817
  });
2806
2818
  if (!i)
2807
2819
  throw new Error("WebGL2 not supported");
2808
- this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new Li({
2820
+ this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new Yi({
2809
2821
  authToken: this.authToken,
2810
2822
  maxConcurrency: r.tileScheduler?.maxConcurrency ?? 12,
2811
2823
  maxRetries: r.tileScheduler?.maxRetries ?? 2,
@@ -2822,7 +2834,7 @@ class Yi {
2822
2834
  }
2823
2835
  setViewState(t) {
2824
2836
  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();
2837
+ typeof n.zoom == "number" && (n.zoom = it(n.zoom, this.minZoom, this.maxZoom)), this.camera.setViewState(n), this.clampViewState(), this.emitViewState(), this.requestRender();
2826
2838
  }
2827
2839
  getViewState() {
2828
2840
  return this.camera.getViewState();
@@ -2900,8 +2912,8 @@ class Yi {
2900
2912
  this.interactionLocked !== n && (this.interactionLocked = n, n && this.cancelDrag());
2901
2913
  }
2902
2914
  setPointSizeByZoom(t) {
2903
- const n = _n(t);
2904
- ki(this.pointSizeStops, n) || (this.pointSizeStops = n, this.requestRender());
2915
+ const n = Bn(t);
2916
+ Oi(this.pointSizeStops, n) || (this.pointSizeStops = n, this.requestRender());
2905
2917
  }
2906
2918
  cancelDrag() {
2907
2919
  if (this.pointerId !== null && this.canvas.hasPointerCapture(this.pointerId))
@@ -2933,38 +2945,38 @@ class Yi {
2933
2945
  Math.abs(t.rotationDeg) < 1e-6 || (this.camera.setViewState({ rotationDeg: 0 }), this.clampViewState(), this.emitViewState(), this.requestRender());
2934
2946
  }
2935
2947
  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);
2948
+ const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r = Gi(n, this.pointSizeStops);
2949
+ return it(r, We, Wi);
2938
2950
  }
2939
2951
  fitToImage() {
2940
2952
  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
2953
  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
2954
  const s = n / o, a = r / o;
2943
2955
  this.camera.setViewState({
2944
- zoom: et(o, this.minZoom, this.maxZoom),
2956
+ zoom: it(o, this.minZoom, this.maxZoom),
2945
2957
  offsetX: (this.source.width - s) * 0.5,
2946
2958
  offsetY: (this.source.height - a) * 0.5,
2947
2959
  rotationDeg: 0
2948
2960
  }), this.clampViewState(), this.emitViewState(), this.requestRender();
2949
2961
  }
2950
2962
  zoomBy(t, n, r) {
2951
- const i = this.camera.getViewState(), o = et(i.zoom * t, this.minZoom, this.maxZoom);
2963
+ const i = this.camera.getViewState(), o = it(i.zoom * t, this.minZoom, this.maxZoom);
2952
2964
  if (o === i.zoom) return;
2953
2965
  const [s, a] = this.camera.screenToWorld(n, r);
2954
2966
  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();
2967
+ 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;
2968
+ this.camera.setCenter(s - x, a - S), this.clampViewState(), this.emitViewState(), this.requestRender();
2957
2969
  }
2958
2970
  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);
2971
+ 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;
2972
+ this.camera.setCenter(x, S);
2961
2973
  }
2962
2974
  emitViewState() {
2963
2975
  this.onViewStateChange?.(this.camera.getViewState());
2964
2976
  }
2965
2977
  selectTier() {
2966
2978
  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);
2979
+ return it(Math.floor(n), 0, this.source.maxTierZoom);
2968
2980
  }
2969
2981
  getViewBounds() {
2970
2982
  const t = this.camera.getViewCorners();
@@ -2979,40 +2991,40 @@ class Yi {
2979
2991
  getVisibleTiles() {
2980
2992
  const t = this.selectTier();
2981
2993
  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(
2994
+ 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
2995
  Math.floor(u / r / this.source.tileSize),
2984
2996
  0,
2985
2997
  s - 1
2986
- ), w = et(
2998
+ ), p = it(
2987
2999
  Math.floor((h - 1) / r / this.source.tileSize),
2988
3000
  0,
2989
3001
  s - 1
2990
- ), y = et(
3002
+ ), x = it(
2991
3003
  Math.floor(c / r / this.source.tileSize),
2992
3004
  0,
2993
3005
  a - 1
2994
- ), x = et(
3006
+ ), S = it(
2995
3007
  Math.floor((g - 1) / r / this.source.tileSize),
2996
3008
  0,
2997
3009
  a - 1
2998
3010
  );
2999
- if (d > w || y > x)
3011
+ if (d > p || x > S)
3000
3012
  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}`,
3013
+ const P = (u + h) * 0.5 / r / this.source.tileSize, k = (c + g) * 0.5 / r / this.source.tileSize, C = [];
3014
+ for (let E = x; E <= S; E += 1)
3015
+ for (let D = d; D <= p; D += 1) {
3016
+ const J = D * this.source.tileSize * r, ft = E * this.source.tileSize * r, at = Math.min((D + 1) * this.source.tileSize, i) * r, $ = Math.min((E + 1) * this.source.tileSize, o) * r, ht = D - P, vt = E - k;
3017
+ C.push({
3018
+ key: `${t}/${D}/${E}`,
3007
3019
  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)
3020
+ x: D,
3021
+ y: E,
3022
+ bounds: [J, ft, at, $],
3023
+ distance2: ht * ht + vt * vt,
3024
+ url: Wn(this.source, t, D, E)
3013
3025
  });
3014
3026
  }
3015
- return R.sort((M, U) => M.distance2 - U.distance2), R;
3027
+ return C.sort((E, D) => E.distance2 - D.distance2), C;
3016
3028
  }
3017
3029
  trimCache() {
3018
3030
  if (this.cache.size <= this.maxCacheTiles) return;
@@ -3026,7 +3038,7 @@ class Yi {
3026
3038
  }
3027
3039
  render() {
3028
3040
  if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
3029
- const t = In();
3041
+ const t = _n();
3030
3042
  this.frameSerial += 1;
3031
3043
  const n = this.gl, r = this.tileProgram, i = this.pointProgram;
3032
3044
  n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
@@ -3035,7 +3047,7 @@ class Yi {
3035
3047
  const u = [];
3036
3048
  for (const [, d] of this.cache)
3037
3049
  a.has(d.key) || this.intersectsBounds(d.bounds, s) && u.push(d);
3038
- u.sort((d, w) => d.tier - w.tier);
3050
+ u.sort((d, p) => d.tier - p.tier);
3039
3051
  for (const d of u)
3040
3052
  d.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, d.texture), n.uniform4f(
3041
3053
  r.uBounds,
@@ -3047,23 +3059,23 @@ class Yi {
3047
3059
  let c = 0;
3048
3060
  const h = [];
3049
3061
  for (const d of o) {
3050
- const w = this.cache.get(d.key);
3051
- if (!w) {
3062
+ const p = this.cache.get(d.key);
3063
+ if (!p) {
3052
3064
  h.push(d);
3053
3065
  continue;
3054
3066
  }
3055
- w.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, w.texture), n.uniform4f(
3067
+ p.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, p.texture), n.uniform4f(
3056
3068
  r.uBounds,
3057
- w.bounds[0],
3058
- w.bounds[1],
3059
- w.bounds[2],
3060
- w.bounds[3]
3069
+ p.bounds[0],
3070
+ p.bounds[1],
3071
+ p.bounds[2],
3072
+ p.bounds[3]
3061
3073
  ), n.drawArrays(n.TRIANGLE_STRIP, 0, 4), c += 1;
3062
3074
  }
3063
3075
  this.tileScheduler.schedule(h), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
3064
3076
  let g = 0;
3065
3077
  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);
3078
+ const d = this.tileScheduler.getSnapshot(), p = c, x = h.length, S = u.length + c + (g > 0 ? 1 : 0);
3067
3079
  this.onStats({
3068
3080
  tier: this.currentTier,
3069
3081
  visible: o.length,
@@ -3076,10 +3088,10 @@ class Yi {
3076
3088
  retries: d.retries,
3077
3089
  failed: d.failed,
3078
3090
  aborted: d.aborted,
3079
- cacheHits: w,
3080
- cacheMisses: y,
3081
- drawCalls: x,
3082
- frameMs: In() - t
3091
+ cacheHits: p,
3092
+ cacheMisses: x,
3093
+ drawCalls: S,
3094
+ frameMs: _n() - t
3083
3095
  });
3084
3096
  }
3085
3097
  }
@@ -3103,7 +3115,7 @@ class Yi {
3103
3115
  if (this.lastPointerX = t.clientX, this.lastPointerY = t.clientY, this.interactionMode === "rotate") {
3104
3116
  const i = this.getPointerAngleRad(t.clientX, t.clientY), o = this.rotateLastAngleRad;
3105
3117
  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();
3118
+ const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), u = this.rotationDragSensitivityDegPerPixel / In, c = this.camera.getViewState();
3107
3119
  this.camera.setViewState({
3108
3120
  rotationDeg: c.rotationDeg - a * 180 / Math.PI * u
3109
3121
  });
@@ -3157,7 +3169,7 @@ class Yi {
3157
3169
  }
3158
3170
  }
3159
3171
  initTileProgram() {
3160
- const t = this.gl, i = gn(t, `#version 300 es
3172
+ const t = this.gl, i = pn(t, `#version 300 es
3161
3173
  precision highp float;
3162
3174
  in vec2 aUnit;
3163
3175
  in vec2 aUv;
@@ -3193,7 +3205,7 @@ class Yi {
3193
3205
  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
3206
  }
3195
3207
  initPointProgram() {
3196
- const t = this.gl, i = gn(t, `#version 300 es
3208
+ const t = this.gl, i = pn(t, `#version 300 es
3197
3209
  precision highp float;
3198
3210
  in vec2 aPosition;
3199
3211
  in uint aTerm;
@@ -3232,18 +3244,18 @@ class Yi {
3232
3244
  if (alpha <= 0.001) discard;
3233
3245
 
3234
3246
  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)
3247
+ }`), 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();
3248
+ if (!c || !h || !g || !d || !p)
3237
3249
  throw new Error("point buffer allocation failed");
3238
3250
  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");
3251
+ const x = t.getAttribLocation(i, "aPosition");
3244
3252
  if (x < 0)
3253
+ throw new Error("point position attribute not found");
3254
+ 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);
3255
+ const S = t.getAttribLocation(i, "aTerm");
3256
+ if (S < 0)
3245
3257
  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(
3258
+ 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
3259
  t.TEXTURE_2D,
3248
3260
  0,
3249
3261
  t.RGBA,
@@ -3259,7 +3271,7 @@ class Yi {
3259
3271
  posBuffer: h,
3260
3272
  termBuffer: g,
3261
3273
  indexBuffer: d,
3262
- paletteTexture: w,
3274
+ paletteTexture: p,
3263
3275
  uCamera: o,
3264
3276
  uPointSize: s,
3265
3277
  uPalette: a,
@@ -3290,15 +3302,15 @@ class Yi {
3290
3302
  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
3303
  }
3292
3304
  }
3293
- const Le = [], Wi = [], Oi = {
3305
+ const Le = [], $i = [], Hi = {
3294
3306
  count: 0,
3295
3307
  positions: new Float32Array(0),
3296
3308
  paletteIndices: new Uint16Array(0)
3297
- }, Vi = 0.65, Gi = 4, qi = 24, $i = 1024, Hi = 4;
3298
- function Zi(e) {
3309
+ }, Zi = 0.65, Ki = 4, ji = 24, Ji = 1024, Qi = 4;
3310
+ function to(e) {
3299
3311
  return Math.max(0, Math.min(Math.floor(e.count ?? 0), Math.floor((e.positions?.length ?? 0) / 2), e.paletteIndices?.length ?? 0));
3300
3312
  }
3301
- function Ki(e, t) {
3313
+ function eo(e, t) {
3302
3314
  if (!(e instanceof Uint32Array) || t <= 0 || e.length === 0)
3303
3315
  return null;
3304
3316
  let n = !1;
@@ -3317,28 +3329,28 @@ function Ki(e, t) {
3317
3329
  }
3318
3330
  return r.subarray(0, i);
3319
3331
  }
3320
- function ji(e, t) {
3332
+ function no(e, t) {
3321
3333
  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));
3334
+ const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) * Qi;
3335
+ return Math.max(ji, Math.min(Ji, i));
3324
3336
  }
3325
- function Ji(e, t) {
3337
+ function ro(e, t) {
3326
3338
  if (!e || !e.positions || !e.paletteIndices)
3327
3339
  return null;
3328
- const n = Zi(e);
3340
+ const n = to(e);
3329
3341
  if (n <= 0)
3330
3342
  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;
3343
+ const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o = eo(e.drawIndices, n), s = o ? o.length : n;
3332
3344
  if (s === 0)
3333
3345
  return null;
3334
- const a = ji(t, s), u = /* @__PURE__ */ new Map(), c = (h) => {
3346
+ const a = no(t, s), u = /* @__PURE__ */ new Map(), c = (h) => {
3335
3347
  const g = r[h * 2], d = r[h * 2 + 1];
3336
3348
  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]);
3349
+ const p = Math.floor(g / a), x = Math.floor(d / a);
3350
+ let S = u.get(p);
3351
+ S || (S = /* @__PURE__ */ new Map(), u.set(p, S));
3352
+ const P = S.get(x);
3353
+ P ? P.push(h) : S.set(x, [h]);
3342
3354
  };
3343
3355
  if (o)
3344
3356
  for (let h = 0; h < o.length; h += 1)
@@ -3354,10 +3366,10 @@ function Ji(e, t) {
3354
3366
  buckets: u
3355
3367
  };
3356
3368
  }
3357
- function Ve(e, t) {
3369
+ function Ge(e, t) {
3358
3370
  return e.id ?? t;
3359
3371
  }
3360
- function Qi(e, t) {
3372
+ function io(e, t) {
3361
3373
  if (!Array.isArray(t) || t.length < 3) return !1;
3362
3374
  const [n, r] = e;
3363
3375
  let i = !1;
@@ -3367,19 +3379,19 @@ function Qi(e, t) {
3367
3379
  }
3368
3380
  return i;
3369
3381
  }
3370
- function Fn(e, t) {
3382
+ function De(e, t) {
3371
3383
  for (let n = t.length - 1; n >= 0; n -= 1) {
3372
3384
  const r = t[n];
3373
- if (r?.coordinates?.length && Qi(e, r.coordinates))
3385
+ if (r?.coordinates?.length && io(e, r.coordinates))
3374
3386
  return {
3375
3387
  region: r,
3376
3388
  regionIndex: n,
3377
- regionId: Ve(r, n)
3389
+ regionId: Ge(r, n)
3378
3390
  };
3379
3391
  }
3380
3392
  return null;
3381
3393
  }
3382
- function mo({
3394
+ function yo({
3383
3395
  source: e,
3384
3396
  viewState: t,
3385
3397
  onViewStateChange: n,
@@ -3393,44 +3405,44 @@ function mo({
3393
3405
  rotationResetNonce: h = 0,
3394
3406
  authToken: g = "",
3395
3407
  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,
3408
+ pointData: p = null,
3409
+ pointPalette: x = null,
3410
+ pointSizeByZoom: S,
3411
+ roiRegions: P,
3412
+ roiPolygons: k,
3413
+ clipPointsToRois: C = !1,
3414
+ clipMode: E = "worker",
3415
+ onClipStats: D,
3416
+ onRoiPointGroups: J,
3405
3417
  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,
3418
+ interactionLock: at = !1,
3419
+ drawTool: $ = "cursor",
3420
+ stampOptions: ht,
3421
+ brushOptions: vt,
3422
+ regionStrokeStyle: Ot,
3423
+ regionStrokeHoverStyle: K,
3424
+ regionStrokeActiveStyle: Ct,
3425
+ patchStrokeStyle: zt,
3426
+ resolveRegionStrokeStyle: Kt,
3427
+ overlayShapes: dt,
3428
+ customLayers: Q,
3429
+ patchRegions: M,
3430
+ regionLabelStyle: I,
3431
+ onPointerWorldMove: A,
3420
3432
  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
3433
+ onPointClick: Z,
3434
+ onRegionHover: et,
3435
+ onRegionClick: mt,
3436
+ onActiveRegionChange: yt,
3437
+ getCellByCoordinatesRef: U,
3438
+ onDrawComplete: At,
3439
+ onPatchComplete: gt,
3440
+ showOverviewMap: N = !1,
3441
+ overviewMapOptions: G,
3442
+ className: ut,
3443
+ style: nt
3432
3444
  }) {
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(
3445
+ 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), [Ft, qt] = Jt(null), [pt, ue] = Jt(null), [ce, l] = Jt(null), [f, w] = Jt(null), y = j(null), R = j(null), v = j(null), Y = j(0), V = P ?? Le, W = M ?? Le, lt = k ?? $i, Pt = (Q?.length ?? 0) > 0, $t = tt(() => ({ position: "relative", width: "100%", height: "100%", ...nt }), [nt]), xt = tt(
3434
3446
  () => ({
3435
3447
  position: "absolute",
3436
3448
  top: 8,
@@ -3452,56 +3464,56 @@ function mo({
3452
3464
  ...u
3453
3465
  }),
3454
3466
  [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);
3467
+ ), H = tt(() => V.length > 0 ? V : lt.length === 0 ? Le : lt.map((m, T) => ({
3468
+ id: T,
3469
+ coordinates: m
3470
+ })), [V, lt]), St = tt(() => H.map((m) => m.coordinates), [H]), [Tt, le] = Jt(p);
3459
3471
  X(() => {
3460
- const p = ++V.current;
3461
- let C = !1;
3462
- if (!R)
3463
- return ce(w), () => {
3464
- C = !0;
3472
+ const m = ++Y.current;
3473
+ let T = !1;
3474
+ if (!C)
3475
+ return le(p), () => {
3476
+ T = !0;
3465
3477
  };
3466
- if (!w || !w.count || !w.positions || !w.paletteIndices)
3467
- return ce(null), () => {
3468
- C = !0;
3478
+ if (!p || !p.count || !p.positions || !p.paletteIndices)
3479
+ return le(null), () => {
3480
+ T = !0;
3469
3481
  };
3470
- if (xt.length === 0)
3471
- return ce(Oi), U?.({
3472
- mode: M,
3482
+ if (St.length === 0)
3483
+ return le(Hi), D?.({
3484
+ mode: E,
3473
3485
  durationMs: 0,
3474
- inputCount: w.count,
3486
+ inputCount: p.count,
3475
3487
  outputCount: 0,
3476
3488
  polygonCount: 0
3477
3489
  }), () => {
3478
- C = !0;
3490
+ T = !0;
3479
3491
  };
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
3492
+ const _ = (z, st) => {
3493
+ if (T || m !== Y.current) return;
3494
+ const de = z?.drawIndices ? z.drawIndices.length : z?.count ?? 0;
3495
+ le(z), D?.({
3496
+ mode: st.mode,
3497
+ durationMs: st.durationMs,
3498
+ inputCount: p.count,
3499
+ outputCount: de,
3500
+ polygonCount: St.length,
3501
+ usedWebGpu: st.usedWebGpu,
3502
+ candidateCount: st.candidateCount,
3503
+ bridgedToDraw: st.bridgedToDraw
3492
3504
  });
3493
3505
  };
3494
3506
  return (async () => {
3495
- if (M === "sync") {
3496
- const z = performance.now(), ut = Pe(w, xt);
3497
- _(ut, {
3507
+ if (E === "sync") {
3508
+ const z = performance.now(), st = Ee(p, St);
3509
+ _(st, {
3498
3510
  mode: "sync",
3499
3511
  durationMs: performance.now() - z
3500
3512
  });
3501
3513
  return;
3502
3514
  }
3503
- if (M === "hybrid-webgpu") {
3504
- const z = await Ri(w, xt, { bridgeToDraw: !0 });
3515
+ if (E === "hybrid-webgpu") {
3516
+ const z = await Bi(p, St, { bridgeToDraw: !0 });
3505
3517
  _(z.data, {
3506
3518
  mode: z.meta.mode,
3507
3519
  durationMs: z.meta.durationMs,
@@ -3512,209 +3524,209 @@ function mo({
3512
3524
  return;
3513
3525
  }
3514
3526
  try {
3515
- const z = await Ei(w, xt);
3527
+ const z = await Fi(p, St);
3516
3528
  _(z.data, {
3517
3529
  mode: z.meta.mode,
3518
3530
  durationMs: z.meta.durationMs
3519
3531
  });
3520
3532
  } catch {
3521
- const z = performance.now(), ut = Pe(w, xt);
3522
- _(ut, {
3533
+ const z = performance.now(), st = Ee(p, St);
3534
+ _(st, {
3523
3535
  mode: "sync",
3524
3536
  durationMs: performance.now() - z
3525
3537
  });
3526
3538
  }
3527
3539
  })(), () => {
3528
- C = !0;
3540
+ T = !0;
3529
3541
  };
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;
3542
+ }, [C, E, p, St, D]);
3543
+ const He = !!(L || Z || U), Mt = tt(() => He ? ro(Tt, e) : null, [He, Tt, e]), Ht = B(
3544
+ (m) => {
3545
+ const T = q.current;
3546
+ if (!T || !Mt) return null;
3547
+ const _ = Number(m[0]), O = Number(m[1]);
3548
+ if (!Number.isFinite(_) || !Number.isFinite(O)) return null;
3549
+ const z = Math.max(1e-6, T.getViewState().zoom), st = T.getPointSizeByZoom(), re = Math.max(Ki, st * Zi) / z;
3538
3550
  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);
3551
+ const Re = Mt.cellSize, nn = Math.floor(_ / Re), rn = Math.floor(O / Re), me = Math.max(1, Math.ceil(re / Re)), er = re * re;
3552
+ let ge = -1, on = er, sn = 0, an = 0;
3553
+ for (let ve = nn - me; ve <= nn + me; ve += 1) {
3554
+ const un = Mt.buckets.get(ve);
3555
+ if (un)
3556
+ for (let Ce = rn - me; Ce <= rn + me; Ce += 1) {
3557
+ const pe = un.get(Ce);
3558
+ if (!(!pe || pe.length === 0))
3559
+ for (let Ie = 0; Ie < pe.length; Ie += 1) {
3560
+ const be = pe[Ie];
3561
+ if (be >= Mt.safeCount) continue;
3562
+ const cn = Mt.positions[be * 2], ln = Mt.positions[be * 2 + 1], hn = cn - _, fn = ln - O, dn = hn * hn + fn * fn;
3563
+ dn > on || (on = dn, ge = be, sn = cn, an = ln);
3552
3564
  }
3553
3565
  }
3554
3566
  }
3555
- if (me < 0) return null;
3556
- const er = vt.ids ? Number(vt.ids[me]) : null;
3567
+ if (ge < 0) return null;
3568
+ const nr = Mt.ids ? Number(Mt.ids[ge]) : null;
3557
3569
  return {
3558
- index: me,
3559
- id: er,
3560
- coordinate: [_, Y],
3561
- pointCoordinate: [on, sn]
3570
+ index: ge,
3571
+ id: nr,
3572
+ coordinate: [_, O],
3573
+ pointCoordinate: [sn, an]
3562
3574
  };
3563
3575
  },
3564
- [vt]
3565
- ), jt = F(
3566
- (p, C) => {
3576
+ [Mt]
3577
+ ), jt = B(
3578
+ (m, T) => {
3567
3579
  if (!L) return;
3568
- const _ = p?.index ?? null, Y = p?.id ?? null;
3569
- E.current === _ && D.current === Y || (E.current = _, D.current = Y, L({
3580
+ const _ = m?.index ?? null, O = m?.id ?? null;
3581
+ R.current === _ && v.current === O || (R.current = _, v.current = O, L({
3570
3582
  index: _,
3571
- id: Y,
3572
- coordinate: C,
3573
- pointCoordinate: p?.pointCoordinate ?? null
3583
+ id: O,
3584
+ coordinate: T,
3585
+ pointCoordinate: m?.pointCoordinate ?? null
3574
3586
  }));
3575
3587
  },
3576
3588
  [L]
3577
- ), le = F(
3578
- (p, C) => {
3579
- if (!$) return;
3580
- const _ = Ht(p);
3581
- _ && $({
3589
+ ), he = B(
3590
+ (m, T) => {
3591
+ if (!Z) return;
3592
+ const _ = Ht(m);
3593
+ _ && Z({
3582
3594
  ..._,
3583
- button: C
3595
+ button: T
3584
3596
  });
3585
3597
  },
3586
- [$, Ht]
3598
+ [Z, Ht]
3587
3599
  );
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";
3600
+ tt(() => {
3601
+ const m = Number(G?.width ?? 220);
3602
+ return Number.isFinite(m) ? Math.max(64, m) : 220;
3603
+ }, [G?.width]);
3604
+ const Ze = tt(() => {
3605
+ const m = Number(G?.height ?? 140);
3606
+ return Number.isFinite(m) ? Math.max(48, m) : 140;
3607
+ }, [G?.height]), Dt = tt(() => {
3608
+ const m = Number(G?.margin ?? 16);
3609
+ return Number.isFinite(m) ? Math.max(0, m) : 16;
3610
+ }, [G?.margin]), fe = G?.position || "bottom-right";
3599
3611
  X(() => {
3600
- if (tt)
3601
- return tt.current = Ht, () => {
3602
- tt.current === Ht && (tt.current = null);
3612
+ if (U)
3613
+ return U.current = Ht, () => {
3614
+ U.current === Ht && (U.current = null);
3603
3615
  };
3604
- }, [tt, Ht]);
3605
- const Jt = F(
3606
- (p) => {
3607
- ve((C) => String(C) === String(p) ? C : (j?.(p), p));
3616
+ }, [U, Ht]);
3617
+ const Nt = B(
3618
+ (m) => {
3619
+ ue((T) => String(T) === String(m) ? T : (yt?.(m), m));
3608
3620
  },
3609
- [j]
3621
+ [yt]
3610
3622
  );
3611
3623
  X(() => {
3612
- lt.current = n;
3624
+ F.current = n;
3613
3625
  }, [n]), X(() => {
3614
- wt.current = r;
3626
+ ct.current = r;
3615
3627
  }, [r]), X(() => {
3616
- bt.current = a, a || S(null);
3628
+ ot.current = a, a || w(null);
3617
3629
  }, [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}`
3630
+ const Ke = B((m) => {
3631
+ ct.current?.(m), ot.current && w(m);
3632
+ }, []), Zn = tt(() => f ? [
3633
+ `tier ${f.tier} | frame ${f.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${f.drawCalls ?? "-"}`,
3634
+ `tiles visible ${f.visible} | rendered ${f.rendered} | fallback ${f.fallback}`,
3635
+ `cache size ${f.cache} | hit ${f.cacheHits ?? "-"} | miss ${f.cacheMisses ?? "-"}`,
3636
+ `queue inflight ${f.inflight} | queued ${f.queued ?? "-"} | retries ${f.retries ?? "-"} | failed ${f.failed ?? "-"} | aborted ${f.aborted ?? "-"}`,
3637
+ `points ${f.points}`
3626
3638
  ].join(`
3627
- `) : "stats: waiting for first frame...", [m]);
3639
+ `) : "stats: waiting for first frame...", [f]);
3628
3640
  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?.({
3641
+ !(pt === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(pt))) && pt !== null && Nt(null);
3642
+ const T = y.current;
3643
+ !(T === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(T))) && T !== null && (y.current = null, qt(null), et?.({
3632
3644
  region: null,
3633
3645
  regionId: null,
3634
3646
  regionIndex: -1,
3635
3647
  coordinate: null
3636
3648
  }));
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?.({
3649
+ }, [H, pt, et, Nt]), X(() => {
3650
+ const m = R.current;
3651
+ m !== null && (Mt && m < Mt.safeCount || (R.current = null, v.current = null, L?.({
3640
3652
  index: null,
3641
3653
  id: null,
3642
3654
  coordinate: null,
3643
3655
  pointCoordinate: null
3644
3656
  })));
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?.();
3657
+ }, [Mt, L]);
3658
+ const je = B(
3659
+ (m) => {
3660
+ Pt && l(m);
3661
+ const T = F.current;
3662
+ T && T(m), It.current?.(), _t.current?.();
3651
3663
  },
3652
- [Ft]
3664
+ [Pt]
3653
3665
  );
3654
3666
  X(() => {
3655
- if (!G) {
3656
- At(!1);
3667
+ if (!N) {
3668
+ Bt(!1);
3657
3669
  return;
3658
3670
  }
3659
- At(!0);
3660
- }, [G, e?.id]), X(() => {
3661
- W !== "cursor" && v.current !== null && (v.current = null, $t(null), K?.({
3671
+ Bt(!0);
3672
+ }, [N, e?.id]), X(() => {
3673
+ $ !== "cursor" && y.current !== null && (y.current = null, qt(null), et?.({
3662
3674
  region: null,
3663
3675
  regionId: null,
3664
3676
  regionIndex: -1,
3665
3677
  coordinate: null
3666
3678
  }));
3667
- }, [W, K]), X(() => {
3668
- W !== "cursor" && E.current !== null && (E.current = null, D.current = null, L?.({
3679
+ }, [$, et]), X(() => {
3680
+ $ !== "cursor" && R.current !== null && (R.current = null, v.current = null, L?.({
3669
3681
  index: null,
3670
3682
  id: null,
3671
3683
  coordinate: null,
3672
3684
  pointCoordinate: null
3673
3685
  }));
3674
- }, [W, L]);
3675
- const Xt = F((p, C) => {
3676
- const _ = O.current;
3686
+ }, [$, L]);
3687
+ const kt = B((m, T) => {
3688
+ const _ = q.current;
3677
3689
  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;
3690
+ const O = _.screenToWorld(m, T);
3691
+ if (!Array.isArray(O) || O.length < 2) return null;
3692
+ const z = Number(O[0]), st = Number(O[1]);
3693
+ return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
3694
+ }, []), Je = B((m, T) => {
3695
+ const _ = q.current;
3684
3696
  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(() => {
3697
+ const O = _.worldToScreen(m, T);
3698
+ if (!Array.isArray(O) || O.length < 2) return null;
3699
+ const z = Number(O[0]), st = Number(O[1]);
3700
+ return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
3701
+ }, []), Qe = B(() => {
3702
+ q.current?.requestRender(), It.current?.(), _t.current?.();
3703
+ }, []), tn = tt(() => ce ?? q.current?.getViewState() ?? null, [ce]), en = tt(() => {
3692
3704
  if (!e) return null;
3693
- const p = Qe;
3694
- return p ? {
3705
+ const m = tn;
3706
+ return m ? {
3695
3707
  source: e,
3696
- viewState: p,
3697
- drawTool: W,
3698
- interactionLock: ct,
3699
- worldToScreen: je,
3700
- screenToWorld: Xt,
3701
- requestRedraw: Je
3708
+ viewState: m,
3709
+ drawTool: $,
3710
+ interactionLock: at,
3711
+ worldToScreen: Je,
3712
+ screenToWorld: kt,
3713
+ requestRedraw: Qe
3702
3714
  } : 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({
3715
+ }, [e, tn, $, at, Je, kt, Qe]), Kn = B(
3716
+ (m) => {
3717
+ const T = m.target === rt.current, _ = kt(m.clientX, m.clientY);
3718
+ if (A) {
3719
+ const de = !!_ && _[0] >= 0 && _[1] >= 0 && !!e && _[0] <= e.width && _[1] <= e.height;
3720
+ A({
3709
3721
  coordinate: _,
3710
- clientX: p.clientX,
3711
- clientY: p.clientY,
3712
- insideImage: fe
3722
+ clientX: m.clientX,
3723
+ clientY: m.clientY,
3724
+ insideImage: de
3713
3725
  });
3714
3726
  }
3715
- if (W !== "cursor") return;
3716
- if (!C) {
3717
- jt(null, null), v.current !== null && (v.current = null, $t(null), K?.({
3727
+ if ($ !== "cursor") return;
3728
+ if (!T) {
3729
+ jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
3718
3730
  region: null,
3719
3731
  regionId: null,
3720
3732
  regionIndex: -1,
@@ -3726,110 +3738,124 @@ function mo({
3726
3738
  jt(null, null);
3727
3739
  return;
3728
3740
  }
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,
3741
+ if (L && jt(Ht(_), _), !H.length) return;
3742
+ const O = De(_, H), z = O?.regionId ?? null, st = y.current;
3743
+ String(st) !== String(z) && (y.current = z, qt(z), et?.({
3744
+ region: O?.region ?? null,
3733
3745
  regionId: z,
3734
- regionIndex: Y?.regionIndex ?? -1,
3746
+ regionIndex: O?.regionIndex ?? -1,
3735
3747
  coordinate: _
3736
3748
  }));
3737
3749
  },
3738
- [W, at, Xt, K, I, e, jt, Ht, L]
3739
- ), jn = F(() => {
3740
- I?.({
3750
+ [$, H, kt, et, A, e, jt, Ht, L]
3751
+ ), jn = B(() => {
3752
+ A?.({
3741
3753
  coordinate: null,
3742
3754
  clientX: -1,
3743
3755
  clientY: -1,
3744
3756
  insideImage: !1
3745
- }), jt(null, null), v.current !== null && (v.current = null, $t(null), K?.({
3757
+ }), jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
3746
3758
  region: null,
3747
3759
  regionId: null,
3748
3760
  regionIndex: -1,
3749
3761
  coordinate: null
3750
3762
  }));
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);
3763
+ }, [et, A, jt]), Jn = B(
3764
+ (m) => {
3765
+ if ($ !== "cursor" || m.target !== rt.current) return;
3766
+ const T = kt(m.clientX, m.clientY);
3767
+ if (!T) return;
3768
+ if (he(T, m.button), !H.length) {
3769
+ Nt(null);
3758
3770
  return;
3759
3771
  }
3760
- const _ = Fn(C, at);
3772
+ const _ = De(T, H);
3761
3773
  if (!_) {
3762
- Jt(null);
3774
+ Nt(null);
3763
3775
  return;
3764
3776
  }
3765
- const Y = Rt !== null && String(Rt) === String(_.regionId) ? null : _.regionId;
3766
- Jt(Y), gt?.({
3777
+ const O = pt !== null && String(pt) === String(_.regionId) ? null : _.regionId;
3778
+ Nt(O), mt?.({
3767
3779
  region: _.region,
3768
3780
  regionId: _.regionId,
3769
3781
  regionIndex: _.regionIndex,
3770
- coordinate: C
3782
+ coordinate: T
3771
3783
  });
3772
3784
  },
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);
3785
+ [$, H, kt, mt, pt, Nt, he]
3786
+ ), Qn = B(
3787
+ (m) => {
3788
+ if ($ !== "brush" || vt?.clickSelectRoi !== !0 || !H.length) return !1;
3789
+ const T = De(m, H);
3790
+ if (!T) return !1;
3791
+ const _ = pt !== null && String(pt) === String(T.regionId) ? null : T.regionId;
3792
+ return Nt(_), mt?.({
3793
+ region: T.region,
3794
+ regionId: T.regionId,
3795
+ regionIndex: T.regionIndex,
3796
+ coordinate: m
3797
+ }), !0;
3798
+ },
3799
+ [$, vt?.clickSelectRoi, H, pt, Nt, mt]
3800
+ ), tr = B(
3801
+ (m) => {
3802
+ if (!Z || $ !== "cursor" || m.target !== rt.current) return;
3803
+ m.preventDefault();
3804
+ const T = kt(m.clientX, m.clientY);
3805
+ T && he(T, m.button);
3780
3806
  },
3781
- [W, Xt, le, $]
3807
+ [$, kt, he, Z]
3782
3808
  );
3783
3809
  return X(() => {
3784
- const p = Q.current;
3785
- if (!p || !e)
3810
+ const m = rt.current;
3811
+ if (!m || !e)
3786
3812
  return;
3787
- const C = new Yi(p, e, {
3788
- onViewStateChange: Ke,
3789
- onStats: Ze,
3813
+ const T = new qi(m, e, {
3814
+ onViewStateChange: je,
3815
+ onStats: Ke,
3790
3816
  onTileError: i,
3791
3817
  onContextLost: o,
3792
3818
  onContextRestored: s,
3793
3819
  authToken: g,
3794
3820
  ctrlDragRotate: d,
3795
- pointSizeByZoom: x
3821
+ pointSizeByZoom: S
3796
3822
  });
3797
- return O.current = C, t && C.setViewState(t), C.setInteractionLock(ct), Ft && f(C.getViewState()), () => {
3798
- C.destroy(), O.current = null;
3823
+ return q.current = T, t && T.setViewState(t), T.setInteractionLock(at), Pt && l(T.getViewState()), () => {
3824
+ T.destroy(), q.current = null;
3799
3825
  };
3800
- }, [e, Ze, i, o, s, g, d, x, Ke, Ft]), X(() => {
3801
- const p = O.current;
3802
- !p || !t || p.setViewState(t);
3826
+ }, [e, Ke, i, o, s, g, d, S, je, Pt]), X(() => {
3827
+ const m = q.current;
3828
+ !m || !t || m.setViewState(t);
3803
3829
  }, [t]), X(() => {
3804
- const p = O.current;
3805
- p && p.fitToImage();
3830
+ const m = q.current;
3831
+ m && m.fitToImage();
3806
3832
  }, [c]), X(() => {
3807
- const p = O.current;
3808
- p && p.resetRotation();
3833
+ const m = q.current;
3834
+ m && m.resetRotation();
3809
3835
  }, [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);
3836
+ const m = q.current;
3837
+ !m || !x || m.setPointPalette(x);
3815
3838
  }, [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, {
3839
+ const m = q.current;
3840
+ m && m.setPointSizeByZoom(S);
3841
+ }, [S]), X(() => {
3842
+ const m = q.current;
3843
+ m && m.setPointData(Tt);
3844
+ }, [Tt]), X(() => {
3845
+ if (!J) return;
3846
+ const T = ki(C ? Tt : p, H, {
3821
3847
  paletteIndexToTermId: ft,
3822
3848
  includeEmptyRegions: !0
3823
3849
  });
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(
3850
+ J(T);
3851
+ }, [J, C, p, Tt, H, ft]), X(() => {
3852
+ const m = q.current;
3853
+ m && m.setInteractionLock(at);
3854
+ }, [at]), /* @__PURE__ */ mn("div", { className: ut, style: $t, onPointerMove: Kn, onPointerLeave: jn, onClick: Jn, onContextMenu: tr, children: [
3855
+ /* @__PURE__ */ Ut(
3830
3856
  "canvas",
3831
3857
  {
3832
- ref: Q,
3858
+ ref: rt,
3833
3859
  className: "wsi-render-canvas",
3834
3860
  style: {
3835
3861
  position: "absolute",
@@ -3839,68 +3865,69 @@ function mo({
3839
3865
  height: "100%",
3840
3866
  display: "block",
3841
3867
  touchAction: "none",
3842
- cursor: W === "cursor" && qt !== null ? "pointer" : ct ? "crosshair" : "grab"
3868
+ cursor: $ === "cursor" && Ft !== null ? "pointer" : at ? "crosshair" : "grab"
3843
3869
  }
3844
3870
  }
3845
3871
  ),
3846
- e && tn && Array.isArray(mt) && mt.length > 0 ? mt.map((p, C) => /* @__PURE__ */ Bt(
3872
+ e && en && Array.isArray(Q) && Q.length > 0 ? Q.map((m, T) => /* @__PURE__ */ Ut(
3847
3873
  "div",
3848
3874
  {
3849
- className: p.className,
3875
+ className: m.className,
3850
3876
  style: {
3851
3877
  position: "absolute",
3852
3878
  inset: 0,
3853
- zIndex: p.zIndex ?? 3,
3854
- pointerEvents: p.pointerEvents ?? "none",
3855
- ...p.style
3879
+ zIndex: m.zIndex ?? 3,
3880
+ pointerEvents: m.pointerEvents ?? "none",
3881
+ ...m.style
3856
3882
  },
3857
- children: p.render(tn)
3883
+ children: m.render(en)
3858
3884
  },
3859
- p.id ?? C
3885
+ m.id ?? T
3860
3886
  )) : null,
3861
- e ? /* @__PURE__ */ Bt(
3862
- li,
3887
+ e ? /* @__PURE__ */ Ut(
3888
+ gi,
3863
3889
  {
3864
- tool: W,
3865
- enabled: W !== "cursor",
3890
+ tool: $,
3891
+ enabled: $ !== "cursor",
3866
3892
  imageWidth: e.width,
3867
3893
  imageHeight: e.height,
3868
3894
  imageMpp: e.mpp,
3869
3895
  imageZoom: e.maxTierZoom,
3870
- stampOptions: Mt,
3871
- brushOptions: zt,
3872
- projectorRef: O,
3896
+ stampOptions: ht,
3897
+ brushOptions: vt,
3898
+ projectorRef: q,
3899
+ onBrushTap: Qn,
3873
3900
  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,
3901
+ persistedRegions: H,
3902
+ patchRegions: W,
3903
+ regionStrokeStyle: Ot,
3904
+ regionStrokeHoverStyle: K,
3905
+ regionStrokeActiveStyle: Ct,
3906
+ patchStrokeStyle: zt,
3907
+ resolveRegionStrokeStyle: Kt,
3908
+ overlayShapes: dt,
3909
+ hoveredRegionId: Ft,
3910
+ activeRegionId: pt,
3911
+ regionLabelStyle: I,
3885
3912
  invalidateRef: It,
3886
- onDrawComplete: pt,
3887
- onPatchComplete: J
3913
+ onDrawComplete: At,
3914
+ onPatchComplete: gt
3888
3915
  }
3889
3916
  ) : 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(
3917
+ a ? /* @__PURE__ */ Ut("pre", { "data-open-plant-debug-overlay": !0, style: xt, children: Zn }) : null,
3918
+ e && N ? Gt ? /* @__PURE__ */ mn(or, { children: [
3919
+ /* @__PURE__ */ Ut(bi, { source: e, projectorRef: q, authToken: g, options: G, invalidateRef: _t }),
3920
+ /* @__PURE__ */ Ut(
3894
3921
  "button",
3895
3922
  {
3896
3923
  type: "button",
3897
3924
  "aria-label": "Hide overview map",
3898
- onClick: () => At(!1),
3925
+ onClick: () => Bt(!1),
3899
3926
  style: {
3900
3927
  position: "absolute",
3901
3928
  zIndex: 6,
3902
- ...he.includes("left") ? { left: kt } : { right: kt },
3903
- ...he.includes("top") ? { top: kt + He + 8 } : { bottom: kt + He + 8 },
3929
+ ...fe.includes("left") ? { left: Dt } : { right: Dt },
3930
+ ...fe.includes("top") ? { top: Dt + Ze + 8 } : { bottom: Dt + Ze + 8 },
3904
3931
  width: 20,
3905
3932
  height: 20,
3906
3933
  borderRadius: 999,
@@ -3915,17 +3942,17 @@ function mo({
3915
3942
  children: "×"
3916
3943
  }
3917
3944
  )
3918
- ] }) : /* @__PURE__ */ Bt(
3945
+ ] }) : /* @__PURE__ */ Ut(
3919
3946
  "button",
3920
3947
  {
3921
3948
  type: "button",
3922
3949
  "aria-label": "Show overview map",
3923
- onClick: () => At(!0),
3950
+ onClick: () => Bt(!0),
3924
3951
  style: {
3925
3952
  position: "absolute",
3926
3953
  zIndex: 6,
3927
- ...he.includes("left") ? { left: kt } : { right: kt },
3928
- ...he.includes("top") ? { top: kt } : { bottom: kt },
3954
+ ...fe.includes("left") ? { left: Dt } : { right: Dt },
3955
+ ...fe.includes("top") ? { top: Dt } : { bottom: Dt },
3929
3956
  height: 24,
3930
3957
  minWidth: 40,
3931
3958
  borderRadius: 999,
@@ -3943,34 +3970,34 @@ function mo({
3943
3970
  ] });
3944
3971
  }
3945
3972
  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,
3973
+ Un as DEFAULT_POINT_COLOR,
3974
+ gi as DrawLayer,
3975
+ hr as M1TileRenderer,
3976
+ bi as OverviewMap,
3977
+ Yi as TileScheduler,
3978
+ go as TileViewerCanvas,
3979
+ qi as WsiTileRenderer,
3980
+ yo as WsiViewerCanvas,
3981
+ fo as buildTermPalette,
3982
+ co as calcScaleLength,
3956
3983
  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,
3984
+ it as clamp,
3985
+ Rt as closeRing,
3986
+ ki as computeRoiPointGroups,
3987
+ Tn as createCircle,
3988
+ Sn as createRectangle,
3989
+ Ee as filterPointDataByPolygons,
3990
+ Bi as filterPointDataByPolygonsHybrid,
3991
+ Fi as filterPointDataByPolygonsInWorker,
3992
+ xi as filterPointIndicesByPolygons,
3993
+ wo as filterPointIndicesByPolygonsInWorker,
3994
+ po as getWebGpuCapabilities,
3968
3995
  Ur as hexToRgba,
3969
- oo as isSameViewState,
3970
- uo as normalizeImageInfo,
3971
- Mi as prefilterPointsByBoundsWebGpu,
3972
- ho as terminateRoiClipWorker,
3973
- so as toBearerToken,
3996
+ lo as isSameViewState,
3997
+ mo as normalizeImageInfo,
3998
+ vi as prefilterPointsByBoundsWebGpu,
3999
+ bo as terminateRoiClipWorker,
4000
+ ho as toBearerToken,
3974
4001
  Wn as toTileUrl
3975
4002
  };
3976
4003
  //# sourceMappingURL=index.js.map