open-plant 1.4.2 → 1.4.3

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
@@ -585,7 +585,7 @@ class xn {
585
585
  if (r && cn(e, n, 0, i - 1, o), this._root === null)
586
586
  this._root = an(e, n, 0, i), this._size = i;
587
587
  else {
588
- const s = Ti(
588
+ const s = Ii(
589
589
  this.toList(),
590
590
  Mi(e, n),
591
591
  o
@@ -656,7 +656,7 @@ function ln(t, e, n) {
656
656
  }
657
657
  return null;
658
658
  }
659
- function Ti(t, e, n) {
659
+ function Ii(t, e, n) {
660
660
  const r = new ee(null, null);
661
661
  let i = r, o = t, s = e;
662
662
  for (; o !== null && s !== null; )
@@ -680,7 +680,7 @@ function cn(t, e, n, r, i) {
680
680
  }
681
681
  cn(t, e, n, a, i), cn(t, e, a + 1, r, i);
682
682
  }
683
- const Zt = 11102230246251565e-32, _t = 134217729, Ii = (3 + 8 * Zt) * Zt;
683
+ const Zt = 11102230246251565e-32, _t = 134217729, Ti = (3 + 8 * Zt) * Zt;
684
684
  function Qe(t, e, n, r, i) {
685
685
  let o, s, a, c, u = e[0], h = r[0], l = 0, f = 0;
686
686
  h > u == h > -u ? (o = u, u = e[++l]) : (o = h, h = r[++f]);
@@ -707,8 +707,8 @@ function Li(t, e, n, r, i, o, s) {
707
707
  let a, c, u, h, l, f, d, m, g, p, y, b, R, x, E, P, O, k;
708
708
  const q = t - i, z = n - i, H = e - o, ot = r - o;
709
709
  x = q * ot, f = _t * q, d = f - (f - q), m = q - d, f = _t * ot, g = f - (f - ot), p = ot - g, E = m * p - (x - d * g - m * g - d * p), P = H * z, f = _t * H, d = f - (f - H), m = H - d, f = _t * z, g = f - (f - z), p = z - g, O = m * p - (P - d * g - m * g - d * p), y = E - O, l = E - y, oe[0] = E - (y + l) + (l - O), b = x + y, l = b - x, R = x - (b - l) + (y - l), y = R - P, l = R - y, oe[1] = R - (y + l) + (l - P), k = b + y, l = k - b, oe[2] = b - (k - l) + (y - l), oe[3] = k;
710
- let T = Pi(4, oe), Z = _i * s;
711
- if (T >= Z || -T >= Z || (l = t - q, a = t - (q + l) + (l - i), l = n - z, u = n - (z + l) + (l - i), l = e - H, c = e - (H + l) + (l - o), l = r - ot, h = r - (ot + l) + (l - o), a === 0 && c === 0 && u === 0 && h === 0) || (Z = Fi * s + Ii * Math.abs(T), T += q * h + ot * a - (H * u + z * c), T >= Z || -T >= Z)) return T;
710
+ let I = Pi(4, oe), Z = _i * s;
711
+ if (I >= Z || -I >= Z || (l = t - q, a = t - (q + l) + (l - i), l = n - z, u = n - (z + l) + (l - i), l = e - H, c = e - (H + l) + (l - o), l = r - ot, h = r - (ot + l) + (l - o), a === 0 && c === 0 && u === 0 && h === 0) || (Z = Fi * s + Ti * Math.abs(I), I += q * h + ot * a - (H * u + z * c), I >= Z || -I >= Z)) return I;
712
712
  x = a * ot, f = _t * a, d = f - (f - a), m = a - d, f = _t * ot, g = f - (f - ot), p = ot - g, E = m * p - (x - d * g - m * g - d * p), P = c * z, f = _t * c, d = f - (f - c), m = c - d, f = _t * z, g = f - (f - z), p = z - g, O = m * p - (P - d * g - m * g - d * p), y = E - O, l = E - y, Lt[0] = E - (y + l) + (l - O), b = x + y, l = b - x, R = x - (b - l) + (y - l), y = R - P, l = R - y, Lt[1] = R - (y + l) + (l - P), k = b + y, l = k - b, Lt[2] = b - (k - l) + (y - l), Lt[3] = k;
713
713
  const N = Qe(4, oe, 4, Lt, Fn);
714
714
  x = q * h, f = _t * q, d = f - (f - q), m = q - d, f = _t * h, g = f - (f - h), p = h - g, E = m * p - (x - d * g - m * g - d * p), P = H * u, f = _t * H, d = f - (f - H), m = H - d, f = _t * u, g = f - (f - u), p = u - g, O = m * p - (P - d * g - m * g - d * p), y = E - O, l = E - y, Lt[0] = E - (y + l) + (l - O), b = x + y, l = b - x, R = x - (b - l) + (y - l), y = R - P, l = R - y, Lt[1] = R - (y + l) + (l - P), k = b + y, l = k - b, Lt[2] = b - (k - l) + (y - l), Lt[3] = k;
@@ -1698,7 +1698,7 @@ function Vr(t, e, n) {
1698
1698
  const r = Number(t), i = Number(e), o = Number(n);
1699
1699
  return !Number.isFinite(r) || r <= 0 ? 1 : !Number.isFinite(i) || !Number.isFinite(o) ? r : Math.pow(2, i - o) * r;
1700
1700
  }
1701
- function bl(t, e, n) {
1701
+ function wl(t, e, n) {
1702
1702
  let i = 100 * Vr(t, e, n);
1703
1703
  if (Number(t)) {
1704
1704
  let o = "μm";
@@ -1724,7 +1724,7 @@ function ie(t) {
1724
1724
  function qn(t, e) {
1725
1725
  return !t && !e ? !0 : !t || !e ? !1 : Math.abs((t.zoom ?? 0) - (e.zoom ?? 0)) < 1e-6 && Math.abs((t.offsetX ?? 0) - (e.offsetX ?? 0)) < 1e-6 && Math.abs((t.offsetY ?? 0) - (e.offsetY ?? 0)) < 1e-6 && Math.abs((t.rotationDeg ?? 0) - (e.rotationDeg ?? 0)) < 1e-6;
1726
1726
  }
1727
- function xl(t) {
1727
+ function bl(t) {
1728
1728
  const e = String(t ?? "").trim();
1729
1729
  if (!e) return "";
1730
1730
  if (/^bearer\s+/i.test(e)) {
@@ -1739,7 +1739,7 @@ function Qi(t) {
1739
1739
  const r = Number.parseInt(n[1], 16);
1740
1740
  return [r >> 16 & 255, r >> 8 & 255, r & 255, 255];
1741
1741
  }
1742
- function Sl(t) {
1742
+ function xl(t) {
1743
1743
  const e = [
1744
1744
  [...Wr]
1745
1745
  ], n = /* @__PURE__ */ new Map();
@@ -2012,7 +2012,7 @@ const re = [], Kn = [], Gt = {
2012
2012
  }, jn = {
2013
2013
  x: 16,
2014
2014
  y: -24
2015
- }, xo = 20, Qn = 1e-6, Jn = "transparent", So = 3, Ao = 2, Zr = 96, vo = 1, tr = 1e3, $r = 2, Kr = 2, Eo = 4096, Mo = 0.2, Ro = 1.12, To = 0.89, Io = 32, Po = "#000000", Co = 0.1, _o = "#FFCF00", Fo = "#FF0000", Lo = 1.5, er = [2, 2], No = 1, Bo = 0.25, ko = 4, zo = 1, Do = 0, Uo = 4, Oo = 1.5;
2015
+ }, xo = 20, Qn = 1e-6, Jn = "transparent", So = 3, Ao = 2, Zr = 96, vo = 1, tr = 1e3, $r = 2, Kr = 2, Eo = 4096, Mo = 0.2, Ro = 1.12, Io = 0.89, To = 32, Po = "#000000", Co = 0.1, _o = "#FFCF00", Fo = "#FF0000", Lo = 1.5, er = [2, 2], No = 1, Bo = 0.25, ko = 4, zo = 1, Do = 0, Uo = 4, Oo = 1.5;
2016
2016
  function Oe(t, e, n) {
2017
2017
  return [X(t[0], 0, e), X(t[1], 0, n)];
2018
2018
  }
@@ -2188,7 +2188,7 @@ function Ho(t) {
2188
2188
  return typeof t != "number" || !Number.isFinite(t) ? zo : Math.round(X(t, Do, Uo));
2189
2189
  }
2190
2190
  function Zo(t) {
2191
- const e = he(t?.radius, Io), n = he(t?.cursorLineWidth, Lo), r = qo(t?.edgeDetail), i = Ho(t?.edgeSmoothing);
2191
+ const e = he(t?.radius, To), n = he(t?.cursorLineWidth, Lo), r = qo(t?.edgeDetail), i = Ho(t?.edgeSmoothing);
2192
2192
  return {
2193
2193
  radius: e,
2194
2194
  edgeDetail: r,
@@ -2298,7 +2298,7 @@ function Rn(t, e) {
2298
2298
  borderRadius: e.borderRadius ?? t.borderRadius
2299
2299
  }) : t;
2300
2300
  }
2301
- function Tn(t, e, n) {
2301
+ function In(t, e, n) {
2302
2302
  if (!t || !n) return 0;
2303
2303
  const r = Number(n.minZoom), i = Number(n.maxZoom);
2304
2304
  return !Number.isFinite(r) || !Number.isFinite(i) || i - r <= Qn || !Number.isFinite(e) ? 0 : e >= i - Qn ? xo : 0;
@@ -2503,7 +2503,7 @@ function ms({
2503
2503
  regionLabelStyle: z,
2504
2504
  drawAreaTooltip: H,
2505
2505
  autoLiftRegionLabelAtMaxZoom: ot = !1,
2506
- regionLabelAnchor: T = "top-center",
2506
+ regionLabelAnchor: I = "top-center",
2507
2507
  clampRegionLabelToViewport: Z = !0,
2508
2508
  regionLabelAutoLiftOffsetPx: N,
2509
2509
  invalidateRef: L,
@@ -2526,11 +2526,11 @@ function ms({
2526
2526
  })), [d, g]), ft = lt(() => m ?? Kn, [m]), tt = lt(() => {
2527
2527
  const w = [];
2528
2528
  for (let S = 0; S < W.length; S += 1) {
2529
- const I = W[S], _ = Xe(I.coordinates);
2529
+ const T = W[S], _ = Xe(T.coordinates);
2530
2530
  _.length !== 0 && w.push({
2531
- region: I,
2531
+ region: T,
2532
2532
  regionIndex: S,
2533
- regionKey: I.id ?? S,
2533
+ regionKey: T.id ?? S,
2534
2534
  polygons: _
2535
2535
  });
2536
2536
  }
@@ -2538,11 +2538,11 @@ function ms({
2538
2538
  }, [W]), st = lt(() => {
2539
2539
  const w = [];
2540
2540
  for (let S = 0; S < ft.length; S += 1) {
2541
- const I = ft[S], _ = Xe(I.coordinates);
2541
+ const T = ft[S], _ = Xe(T.coordinates);
2542
2542
  _.length !== 0 && w.push({
2543
- region: I,
2543
+ region: T,
2544
2544
  regionIndex: S,
2545
- regionKey: I.id ?? S,
2545
+ regionKey: T.id ?? S,
2546
2546
  polygons: _
2547
2547
  });
2548
2548
  }
@@ -2564,26 +2564,26 @@ function ms({
2564
2564
  ), pt = V(() => {
2565
2565
  const w = ct.current;
2566
2566
  if (!w) return;
2567
- const S = w.getBoundingClientRect(), I = Math.max(1, window.devicePixelRatio || 1), _ = Math.max(1, Math.round(S.width * I)), Q = Math.max(1, Math.round(S.height * I));
2567
+ const S = w.getBoundingClientRect(), T = Math.max(1, window.devicePixelRatio || 1), _ = Math.max(1, Math.round(S.width * T)), Q = Math.max(1, Math.round(S.height * T));
2568
2568
  (w.width !== _ || w.height !== Q) && (w.width = _, w.height = Q);
2569
2569
  }, []), ut = V(
2570
2570
  (w) => {
2571
2571
  const S = a.current;
2572
2572
  if (!S || w.length === 0) return [];
2573
- const I = new Array(w.length);
2573
+ const T = new Array(w.length);
2574
2574
  for (let _ = 0; _ < w.length; _ += 1) {
2575
2575
  const Q = Wt(S.worldToScreen(w[_][0], w[_][1]));
2576
2576
  if (!Q) return [];
2577
- I[_] = Q;
2577
+ T[_] = Q;
2578
2578
  }
2579
- return I;
2579
+ return T;
2580
2580
  },
2581
2581
  [a]
2582
- ), Tt = V(
2582
+ ), It = V(
2583
2583
  (w) => {
2584
- const S = a.current, I = ct.current;
2585
- if (!S || !I) return null;
2586
- const _ = I.getBoundingClientRect(), Q = Wt(S.screenToWorld(_.left + w[0], _.top + w[1]));
2584
+ const S = a.current, T = ct.current;
2585
+ if (!S || !T) return null;
2586
+ const _ = T.getBoundingClientRect(), Q = Wt(S.screenToWorld(_.left + w[0], _.top + w[1]));
2587
2587
  return Q ? Oe(Q, e, n) : null;
2588
2588
  },
2589
2589
  [a, e, n]
@@ -2591,13 +2591,13 @@ function ms({
2591
2591
  const w = a.current, S = w?.getViewState?.().rotationDeg ?? 0;
2592
2592
  if (!(Math.abs(S % 360) < 0.01 || !w))
2593
2593
  return {
2594
- worldToScreen: (I, _) => Wt(w.worldToScreen(I, _)),
2595
- screenToWorld: Tt
2594
+ worldToScreen: (T, _) => Wt(w.worldToScreen(T, _)),
2595
+ screenToWorld: It
2596
2596
  };
2597
- }, [a, Tt]), C = V(
2597
+ }, [a, It]), C = V(
2598
2598
  (w) => {
2599
2599
  if (!Number.isFinite(w) || w <= 0) return 0;
2600
- const S = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, I = typeof i == "number" && Number.isFinite(i) ? i : 0, _ = a.current?.getViewState?.().zoom, Q = typeof _ == "number" && Number.isFinite(_) && _ > 0 ? _ : 1, It = I + Math.log2(Q), mt = Math.max(1e-9, Vr(S, I, It));
2600
+ const S = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, T = typeof i == "number" && Number.isFinite(i) ? i : 0, _ = a.current?.getViewState?.().zoom, Q = typeof _ == "number" && Number.isFinite(_) && _ > 0 ? _ : 1, Tt = T + Math.log2(Q), mt = Math.max(1e-9, Vr(S, T, Tt));
2601
2601
  return w / mt / Q;
2602
2602
  },
2603
2603
  [r, i, a]
@@ -2621,8 +2621,8 @@ function ms({
2621
2621
  if (!w) return;
2622
2622
  const S = w.getContext("2d");
2623
2623
  if (!S) return;
2624
- const I = Math.max(1, window.devicePixelRatio || 1), _ = w.width / I, Q = w.height / I;
2625
- if (S.setTransform(1, 0, 0, 1, 0, 0), S.clearRect(0, 0, w.width, w.height), S.setTransform(I, 0, 0, I, 0, 0), tt.length > 0)
2624
+ const T = Math.max(1, window.devicePixelRatio || 1), _ = w.width / T, Q = w.height / T;
2625
+ if (S.setTransform(1, 0, 0, 1, 0, 0), S.clearRect(0, 0, w.width, w.height), S.setTransform(T, 0, 0, T, 0, 0), tt.length > 0)
2626
2626
  for (const mt of tt) {
2627
2627
  const { region: wt, polygons: Mt, regionIndex: Pt, regionKey: Bt } = mt, Yt = Ye(q, Bt) ? "active" : Ye(k, Bt) ? "hover" : "default";
2628
2628
  let Kt = Yt === "active" ? K : Yt === "hover" ? yt : gt;
@@ -2676,24 +2676,24 @@ function ms({
2676
2676
  } : void 0
2677
2677
  });
2678
2678
  }
2679
- const It = et();
2679
+ const Tt = et();
2680
2680
  if (M) {
2681
2681
  if (t === "brush")
2682
2682
  $o(S, v.current, B), Ko(S, v.current, a.current, B);
2683
- else if (It.length > 0)
2683
+ else if (Tt.length > 0)
2684
2684
  if (t === "freehand") {
2685
- const mt = ut(It);
2686
- mt.length >= 2 && Ft(S, mt, gt, !1, !1), mt.length >= 3 && Ft(S, ut(zt(It)), gt, !0, !0, xt);
2685
+ const mt = ut(Tt);
2686
+ mt.length >= 2 && Ft(S, mt, gt, !1, !1), mt.length >= 3 && Ft(S, ut(zt(Tt)), gt, !0, !0, xt);
2687
2687
  } else {
2688
- const mt = ut(It);
2688
+ const mt = ut(Tt);
2689
2689
  mt.length >= 4 && Ft(S, mt, gt, !0, !0, xt);
2690
2690
  }
2691
2691
  }
2692
2692
  if (tt.length > 0) {
2693
- const mt = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), wt = typeof N == "number" && Number.isFinite(N) ? Math.max(0, N) : Tn(ot, mt, a.current?.getZoomRange?.());
2693
+ const mt = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), wt = typeof N == "number" && Number.isFinite(N) ? Math.max(0, N) : In(ot, mt, a.current?.getZoomRange?.());
2694
2694
  for (const Mt of tt) {
2695
2695
  if (!Mt.region.label) continue;
2696
- const Pt = En(Mt.polygons, T);
2696
+ const Pt = En(Mt.polygons, I);
2697
2697
  if (!Pt) continue;
2698
2698
  const Bt = Wt(a.current?.worldToScreen(Pt[0], Pt[1]) ?? []);
2699
2699
  if (!Bt) continue;
@@ -2715,7 +2715,7 @@ function ms({
2715
2715
  if (G.enabled && M && (t === "freehand" || t === "rectangle" || t === "circular")) {
2716
2716
  const mt = v.current;
2717
2717
  if (mt.isDrawing) {
2718
- const wt = t === "freehand" ? zt(It) : It;
2718
+ const wt = t === "freehand" ? zt(Tt) : Tt;
2719
2719
  if (wt.length >= 4) {
2720
2720
  const Mt = Le(wt), Pt = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 0, Bt = Pt > 0 ? Mt * Pt * Pt / (tr * tr) : 0, Yt = G.format(Bt), Kt = mt.cursorScreen ?? (mt.current ? Wt(a.current?.worldToScreen(mt.current[0], mt.current[1]) ?? []) : null);
2721
2721
  Kt && ss(
@@ -2755,7 +2755,7 @@ function ms({
2755
2755
  U,
2756
2756
  G,
2757
2757
  ot,
2758
- T,
2758
+ I,
2759
2759
  Z,
2760
2760
  N,
2761
2761
  r,
@@ -2765,20 +2765,20 @@ function ms({
2765
2765
  Rt.current = !1, at();
2766
2766
  }));
2767
2767
  }, [at]), j = V((w = !1) => {
2768
- const S = v.current, I = ct.current;
2769
- I && S.pointerId !== null && I.hasPointerCapture(S.pointerId) && I.releasePointerCapture(S.pointerId), S.isDrawing = !1, S.pointerId = null, S.start = null, S.current = null, S.points = [], S.screenPoints = [], S.stampCenter = null, w || (S.cursor = null, S.cursorScreen = null);
2768
+ const S = v.current, T = ct.current;
2769
+ T && S.pointerId !== null && T.hasPointerCapture(S.pointerId) && T.releasePointerCapture(S.pointerId), S.isDrawing = !1, S.pointerId = null, S.start = null, S.current = null, S.points = [], S.screenPoints = [], S.stampCenter = null, w || (S.cursor = null, S.cursorScreen = null);
2770
2770
  }, []), ht = V(
2771
2771
  (w) => {
2772
2772
  const S = a.current;
2773
2773
  if (!S || e <= 0 || n <= 0) return null;
2774
- const I = Wt(S.screenToWorld(w.clientX, w.clientY));
2775
- return I ? Oe(I, e, n) : null;
2774
+ const T = Wt(S.screenToWorld(w.clientX, w.clientY));
2775
+ return T ? Oe(T, e, n) : null;
2776
2776
  },
2777
2777
  [a, e, n]
2778
2778
  ), it = V((w) => {
2779
2779
  const S = ct.current;
2780
2780
  if (!S) return null;
2781
- const I = S.getBoundingClientRect(), _ = X(w.clientX - I.left, 0, I.width), Q = X(w.clientY - I.top, 0, I.height);
2781
+ const T = S.getBoundingClientRect(), _ = X(w.clientX - T.left, 0, T.width), Q = X(w.clientY - T.top, 0, T.height);
2782
2782
  return !Number.isFinite(_) || !Number.isFinite(Q) ? null : [_, Q];
2783
2783
  }, []), dt = V(() => {
2784
2784
  const w = v.current;
@@ -2794,19 +2794,19 @@ function ms({
2794
2794
  else if (t === "circular")
2795
2795
  S = or(w.start, w.current);
2796
2796
  else if (t === "brush") {
2797
- const I = w.points[w.points.length - 1] ?? w.current ?? w.start;
2798
- if (B.clickSelectRoi && I && w.points.length <= 1 && c?.(I)) {
2797
+ const T = w.points[w.points.length - 1] ?? w.current ?? w.start;
2798
+ if (B.clickSelectRoi && T && w.points.length <= 1 && c?.(T)) {
2799
2799
  j(!0), F();
2800
2800
  return;
2801
2801
  }
2802
- const _ = Math.max(0.25, B.edgeDetail), Q = w.screenPoints.length > 0 ? w.screenPoints : ut(w.points), It = Math.max(0.5, B.radius * 0.04 / _), mt = bo(Q, {
2802
+ const _ = Math.max(0.25, B.edgeDetail), Q = w.screenPoints.length > 0 ? w.screenPoints : ut(w.points), Tt = Math.max(0.5, B.radius * 0.04 / _), mt = bo(Q, {
2803
2803
  radius: B.radius,
2804
2804
  circleSides: Math.max(16, Math.round(32 * _)),
2805
- simplifyTolerance: It,
2805
+ simplifyTolerance: Tt,
2806
2806
  smoothingPasses: B.edgeSmoothing
2807
2807
  }), wt = [];
2808
2808
  for (const Mt of mt) {
2809
- const Pt = Tt(Mt);
2809
+ const Pt = It(Mt);
2810
2810
  Pt && wt.push(Pt);
2811
2811
  }
2812
2812
  S = zt(wt);
@@ -2824,7 +2824,7 @@ function ms({
2824
2824
  j,
2825
2825
  F,
2826
2826
  ut,
2827
- Tt,
2827
+ It,
2828
2828
  Et,
2829
2829
  B.radius,
2830
2830
  B.edgeDetail,
@@ -2833,27 +2833,27 @@ function ms({
2833
2833
  c
2834
2834
  ]), Ot = V(
2835
2835
  (w, S) => {
2836
- const I = Y(w, S);
2837
- if (!lr(I)) return;
2836
+ const T = Y(w, S);
2837
+ if (!lr(T)) return;
2838
2838
  const _ = w === "stamp-rectangle-4096px" ? "patch" : "roi", Q = {
2839
2839
  tool: w,
2840
2840
  intent: _,
2841
- coordinates: I,
2842
- bbox: nr(I),
2843
- areaPx: Le(I)
2841
+ coordinates: T,
2842
+ bbox: nr(T),
2843
+ areaPx: Le(T)
2844
2844
  };
2845
2845
  u?.(Q), _ === "patch" && h && h(Q);
2846
2846
  },
2847
2847
  [Y, u, h]
2848
2848
  ), $t = V(
2849
- (w, S, I) => {
2850
- const _ = Math.max(Oo, B.radius * 0.1), Q = _ * _, It = w.screenPoints[w.screenPoints.length - 1];
2851
- if (!It) {
2852
- w.points.push(S), w.screenPoints.push(I), w.current = S;
2849
+ (w, S, T) => {
2850
+ const _ = Math.max(Oo, B.radius * 0.1), Q = _ * _, Tt = w.screenPoints[w.screenPoints.length - 1];
2851
+ if (!Tt) {
2852
+ w.points.push(S), w.screenPoints.push(T), w.current = S;
2853
2853
  return;
2854
2854
  }
2855
- const mt = I[0] - It[0], wt = I[1] - It[1];
2856
- mt * mt + wt * wt >= Q ? (w.points.push(S), w.screenPoints.push(I)) : (w.points[w.points.length - 1] = S, w.screenPoints[w.screenPoints.length - 1] = I), w.current = S;
2855
+ const mt = T[0] - Tt[0], wt = T[1] - Tt[1];
2856
+ mt * mt + wt * wt >= Q ? (w.points.push(S), w.screenPoints.push(T)) : (w.points[w.points.length - 1] = S, w.screenPoints[w.screenPoints.length - 1] = T), w.current = S;
2857
2857
  },
2858
2858
  [B.radius]
2859
2859
  ), He = V(
@@ -2861,17 +2861,17 @@ function ms({
2861
2861
  if (!M || t === "cursor" || w.button !== 0) return;
2862
2862
  const S = ht(w);
2863
2863
  if (!S) return;
2864
- const I = it(w);
2865
- if (!I) return;
2864
+ const T = it(w);
2865
+ if (!T) return;
2866
2866
  if (w.preventDefault(), w.stopPropagation(), Ee(t)) {
2867
- const It = v.current;
2868
- It.stampCenter = S, Ot(t, S), F();
2867
+ const Tt = v.current;
2868
+ Tt.stampCenter = S, Ot(t, S), F();
2869
2869
  return;
2870
2870
  }
2871
2871
  const _ = ct.current;
2872
2872
  _ && _.setPointerCapture(w.pointerId);
2873
2873
  const Q = v.current;
2874
- Q.isDrawing = !0, Q.pointerId = w.pointerId, Q.start = S, Q.current = S, Q.cursor = S, Q.cursorScreen = I, Q.points = t === "freehand" || t === "brush" ? [S] : [], Q.screenPoints = t === "brush" ? [I] : [], F();
2874
+ Q.isDrawing = !0, Q.pointerId = w.pointerId, Q.start = S, Q.current = S, Q.cursor = S, Q.cursorScreen = T, Q.points = t === "freehand" || t === "brush" ? [S] : [], Q.screenPoints = t === "brush" ? [T] : [], F();
2875
2875
  },
2876
2876
  [M, t, ht, it, Ot, F]
2877
2877
  ), le = V(
@@ -2879,10 +2879,10 @@ function ms({
2879
2879
  if (!M || t === "cursor") return;
2880
2880
  const S = ht(w);
2881
2881
  if (!S) return;
2882
- const I = it(w);
2883
- if (!I) return;
2882
+ const T = it(w);
2883
+ if (!T) return;
2884
2884
  const _ = v.current;
2885
- if (_.cursor = S, _.cursorScreen = I, Ee(t)) {
2885
+ if (_.cursor = S, _.cursorScreen = T, Ee(t)) {
2886
2886
  _.stampCenter = S, w.preventDefault(), w.stopPropagation(), F();
2887
2887
  return;
2888
2888
  }
@@ -2891,12 +2891,12 @@ function ms({
2891
2891
  F();
2892
2892
  return;
2893
2893
  }
2894
- w.preventDefault(), w.stopPropagation(), $t(_, S, I), F();
2894
+ w.preventDefault(), w.stopPropagation(), $t(_, S, T), F();
2895
2895
  return;
2896
2896
  }
2897
2897
  if (!(!_.isDrawing || _.pointerId !== w.pointerId)) {
2898
2898
  if (w.preventDefault(), w.stopPropagation(), t === "freehand") {
2899
- const Q = a.current, It = Math.max(1e-6, Q?.getViewState?.().zoom ?? 1), mt = Ao / It, wt = mt * mt, Mt = _.points[_.points.length - 1];
2899
+ const Q = a.current, Tt = Math.max(1e-6, Q?.getViewState?.().zoom ?? 1), mt = Ao / Tt, wt = mt * mt, Mt = _.points[_.points.length - 1];
2900
2900
  if (!Mt)
2901
2901
  _.points.push(S);
2902
2902
  else {
@@ -2914,8 +2914,8 @@ function ms({
2914
2914
  const S = v.current;
2915
2915
  if (!S.isDrawing || S.pointerId !== w.pointerId) return;
2916
2916
  w.preventDefault(), w.stopPropagation();
2917
- const I = ht(w), _ = it(w);
2918
- I && (S.cursor = I, _ && (S.cursorScreen = _), t === "brush" ? _ && $t(S, I, _) : S.current = I);
2917
+ const T = ht(w), _ = it(w);
2918
+ T && (S.cursor = T, _ && (S.cursorScreen = _), t === "brush" ? _ && $t(S, T, _) : S.current = T);
2919
2919
  const Q = ct.current;
2920
2920
  Q && Q.hasPointerCapture(w.pointerId) && Q.releasePointerCapture(w.pointerId), dt();
2921
2921
  },
@@ -2970,11 +2970,11 @@ function ms({
2970
2970
  },
2971
2971
  onWheel: (w) => {
2972
2972
  if (!M) return;
2973
- const S = ct.current, I = a.current;
2974
- if (!S || typeof I?.zoomBy != "function") return;
2973
+ const S = ct.current, T = a.current;
2974
+ if (!S || typeof T?.zoomBy != "function") return;
2975
2975
  w.preventDefault(), w.stopPropagation();
2976
- const _ = S.getBoundingClientRect(), Q = w.clientX - _.left, It = w.clientY - _.top;
2977
- I.zoomBy(w.deltaY < 0 ? Ro : To, Q, It), F();
2976
+ const _ = S.getBoundingClientRect(), Q = w.clientX - _.left, Tt = w.clientY - _.top;
2977
+ T.zoomBy(w.deltaY < 0 ? Ro : Io, Q, Tt), F();
2978
2978
  }
2979
2979
  }
2980
2980
  );
@@ -2986,7 +2986,7 @@ function we() {
2986
2986
  throw new Error("useViewerContext must be used within a <WsiViewer>");
2987
2987
  return t;
2988
2988
  }
2989
- function Al({ tool: t = "cursor", stampOptions: e, brushOptions: n, fillColor: r, areaTooltip: i, onComplete: o, onPatchComplete: s, onBrushTap: a }) {
2989
+ function Sl({ tool: t = "cursor", stampOptions: e, brushOptions: n, fillColor: r, areaTooltip: i, onComplete: o, onPatchComplete: s, onBrushTap: a }) {
2990
2990
  const { source: c, rendererRef: u, rendererSerial: h, setInteractionLock: l } = we(), f = t !== "cursor";
2991
2991
  D(() => (l("drawing-layer", f), () => l("drawing-layer", !1)), [f, l]);
2992
2992
  const d = lt(() => u.current?.getViewState(), [h]);
@@ -3012,7 +3012,7 @@ function Al({ tool: t = "cursor", stampOptions: e, brushOptions: n, fillColor: r
3012
3012
  ) : null;
3013
3013
  }
3014
3014
  const cr = "__overlay_layer__";
3015
- function vl({ shapes: t }) {
3015
+ function Al({ shapes: t }) {
3016
3016
  const { rendererRef: e, source: n, registerDrawCallback: r, unregisterDrawCallback: i, requestOverlayRedraw: o } = we(), s = V(
3017
3017
  (c) => {
3018
3018
  const u = e.current;
@@ -3072,7 +3072,7 @@ function ps(t) {
3072
3072
  }
3073
3073
  return /\/ims$/i.test(e) ? "/ims" : /\/tiles$/i.test(e) ? `${e}` : `${e}/tiles`;
3074
3074
  }
3075
- function El(t, e) {
3075
+ function vl(t, e) {
3076
3076
  const n = t?.imsInfo ?? {}, r = !!t?.imsInfo, i = Number(n.width ?? t?.width ?? 0), o = Number(n.height ?? t?.height ?? 0), s = Number(n.tileSize ?? t?.tileSize ?? 0), a = Number(n.zoom ?? t?.zoom ?? 0), c = String(n.path ?? t?.path ?? ""), u = Number(n.mpp ?? t?.mpp ?? 0);
3077
3077
  if (!i || !o || !s || !c)
3078
3078
  throw new Error("Incomplete image metadata: width/height/tileSize/path required");
@@ -3216,7 +3216,7 @@ const bs = {
3216
3216
  alignItems: "center",
3217
3217
  justifyContent: "center"
3218
3218
  };
3219
- function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalidateRef: i, className: o, style: s }) {
3219
+ function El({ source: t, projectorRef: e, authToken: n = "", options: r, invalidateRef: i, className: o, style: s }) {
3220
3220
  const a = J(null), c = J(null), u = J(null), h = J({
3221
3221
  active: !1,
3222
3222
  pointerId: null
@@ -3229,7 +3229,7 @@ function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalid
3229
3229
  w: tt,
3230
3230
  h: st
3231
3231
  };
3232
- }, [t.width, t.height, d, m]), p = se(r?.margin, kt.margin, 0), y = se(r?.borderRadius, kt.borderRadius, 0), b = se(r?.borderWidth, kt.borderWidth, 0), R = Math.max(1, Math.round(se(r?.maxThumbnailTiles, kt.maxThumbnailTiles, 1))), x = r?.backgroundColor || kt.backgroundColor, E = r?.borderColor || kt.borderColor, P = r?.viewportBorderColor || kt.viewportBorderColor, O = r?.viewportBorderStyle === "stroke" || r?.viewportBorderStyle === "dash" ? r.viewportBorderStyle : kt.viewportBorderStyle, k = r?.viewportFillColor ?? kt.viewportFillColor, q = r?.interactive ?? kt.interactive, z = r?.showThumbnail ?? kt.showThumbnail, H = r?.position || kt.position, ot = r?.onClose, T = r?.closeIcon, Z = r?.closeButtonStyle, N = lt(() => {
3232
+ }, [t.width, t.height, d, m]), p = se(r?.margin, kt.margin, 0), y = se(r?.borderRadius, kt.borderRadius, 0), b = se(r?.borderWidth, kt.borderWidth, 0), R = Math.max(1, Math.round(se(r?.maxThumbnailTiles, kt.maxThumbnailTiles, 1))), x = r?.backgroundColor || kt.backgroundColor, E = r?.borderColor || kt.borderColor, P = r?.viewportBorderColor || kt.viewportBorderColor, O = r?.viewportBorderStyle === "stroke" || r?.viewportBorderStyle === "dash" ? r.viewportBorderStyle : kt.viewportBorderStyle, k = r?.viewportFillColor ?? kt.viewportFillColor, q = r?.interactive ?? kt.interactive, z = r?.showThumbnail ?? kt.showThumbnail, H = r?.position || kt.position, ot = r?.onClose, I = r?.closeIcon, Z = r?.closeButtonStyle, N = lt(() => {
3233
3233
  const v = {};
3234
3234
  return H === "top-left" || H === "bottom-left" ? v.left = p : v.right = p, H === "top-left" || H === "top-right" ? v.top = p : v.bottom = p, {
3235
3235
  position: "absolute",
@@ -3255,9 +3255,9 @@ function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalid
3255
3255
  U && M.drawImage(U, yt, K, bt, xt), M.strokeStyle = E, M.lineWidth = b, M.strokeRect(b * 0.5, b * 0.5, W - b, ft - b);
3256
3256
  const G = e.current, nt = G?.getViewBounds?.(), B = G?.getViewCorners?.(), rt = Array.isArray(B) && B.length >= 4 && B.every((ht) => Array.isArray(ht) && ht.length >= 2 && Number.isFinite(ht[0]) && Number.isFinite(ht[1])) ? B : null, pt = ue(nt) ? nt : ue(u.current) ? u.current : null;
3257
3257
  ue(nt) && (u.current = nt);
3258
- const ut = bt / Math.max(1, t.width), Tt = xt / Math.max(1, t.height), Et = O === "dash";
3258
+ const ut = bt / Math.max(1, t.width), It = xt / Math.max(1, t.height), Et = O === "dash";
3259
3259
  if (rt) {
3260
- const ht = rt.map((dt) => [yt + dt[0] * ut, K + dt[1] * Tt]), it = ws(ht, yt, K, yt + bt, K + xt);
3260
+ const ht = rt.map((dt) => [yt + dt[0] * ut, K + dt[1] * It]), it = ws(ht, yt, K, yt + bt, K + xt);
3261
3261
  if (it.length >= 3) {
3262
3262
  M.beginPath();
3263
3263
  for (let dt = 0; dt < it.length; dt += 1)
@@ -3268,7 +3268,7 @@ function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalid
3268
3268
  }
3269
3269
  if (!pt)
3270
3270
  return;
3271
- const C = X(yt + pt[0] * ut, yt, yt + bt), Y = X(K + pt[1] * Tt, K, K + xt), et = X(yt + pt[2] * ut, yt, yt + bt), at = X(K + pt[3] * Tt, K, K + xt), F = Math.max(1, et - C), j = Math.max(1, at - Y);
3271
+ const C = X(yt + pt[0] * ut, yt, yt + bt), Y = X(K + pt[1] * It, K, K + xt), et = X(yt + pt[2] * ut, yt, yt + bt), at = X(K + pt[3] * It, K, K + xt), F = Math.max(1, et - C), j = Math.max(1, at - Y);
3272
3272
  if (M.fillStyle = k, M.fillRect(C, Y, F, j), M.strokeStyle = P, M.lineWidth = 2.25, Et) {
3273
3273
  const ht = [
3274
3274
  [C + 0.5, Y + 0.5],
@@ -3384,8 +3384,8 @@ function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalid
3384
3384
  const {
3385
3385
  tile: { bounds: rt },
3386
3386
  bitmap: pt
3387
- } = B.value, ut = rt[0] * G, Tt = rt[1] * nt, Et = Math.max(1, (rt[2] - rt[0]) * G), C = Math.max(1, (rt[3] - rt[1]) * nt);
3388
- bt.drawImage(pt, ut, Tt, Et, C), pt.close();
3387
+ } = B.value, ut = rt[0] * G, It = rt[1] * nt, Et = Math.max(1, (rt[2] - rt[0]) * G), C = Math.max(1, (rt[3] - rt[1]) * nt);
3388
+ bt.drawImage(pt, ut, It, Et, C), pt.close();
3389
3389
  }
3390
3390
  c.current = K, $();
3391
3391
  }), () => {
@@ -3435,13 +3435,13 @@ function Ml({ source: t, projectorRef: e, authToken: n = "", options: r, invalid
3435
3435
  v.stopPropagation(), ot();
3436
3436
  },
3437
3437
  style: Z ? { ...Z } : { ...bs },
3438
- children: T ?? "×"
3438
+ children: I ?? "×"
3439
3439
  }
3440
3440
  )
3441
3441
  ] });
3442
3442
  }
3443
3443
  const pr = "__patch_layer__", xs = [];
3444
- function Rl({ regions: t, strokeStyle: e }) {
3444
+ function Ml({ regions: t, strokeStyle: e }) {
3445
3445
  const { rendererRef: n, registerDrawCallback: r, unregisterDrawCallback: i, requestOverlayRedraw: o } = we(), s = t ?? xs, a = lt(() => Ht(Gr, e), [e]), c = lt(() => {
3446
3446
  const l = [];
3447
3447
  for (let f = 0; f < s.length; f += 1) {
@@ -3565,8 +3565,8 @@ function ii() {
3565
3565
  const n = e;
3566
3566
  return typeof n.requestAdapter != "function" ? null : n;
3567
3567
  }
3568
- const Re = globalThis.GPUShaderStage?.COMPUTE ?? 4, tn = globalThis.GPUBufferUsage?.STORAGE ?? 128, Te = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Es = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Ms = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Rs = globalThis.GPUBufferUsage?.MAP_READ ?? 1, Ts = globalThis.GPUMapMode?.READ ?? 1;
3569
- async function Tl() {
3568
+ const Re = globalThis.GPUShaderStage?.COMPUTE ?? 4, tn = globalThis.GPUBufferUsage?.STORAGE ?? 128, Ie = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Es = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Ms = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Rs = globalThis.GPUBufferUsage?.MAP_READ ?? 1, Is = globalThis.GPUMapMode?.READ ?? 1;
3569
+ async function Rl() {
3570
3570
  const t = ii();
3571
3571
  if (!t)
3572
3572
  return { supported: !1, features: [] };
@@ -3586,7 +3586,7 @@ async function Tl() {
3586
3586
  }
3587
3587
  } : { supported: !1, features: [] };
3588
3588
  }
3589
- async function Is() {
3589
+ async function Ts() {
3590
3590
  return Me || (Me = (async () => {
3591
3591
  const t = ii();
3592
3592
  if (!t) return null;
@@ -3625,11 +3625,11 @@ async function Is() {
3625
3625
  return { device: n, pipeline: i, bindGroupLayout: r };
3626
3626
  })(), Me);
3627
3627
  }
3628
- function Ie(t, e) {
3628
+ function Te(t, e) {
3629
3629
  return Math.ceil(t / e) * e;
3630
3630
  }
3631
3631
  async function Ps(t, e, n) {
3632
- const r = await Is();
3632
+ const r = await Ts();
3633
3633
  if (!r) return null;
3634
3634
  const i = Math.max(0, Math.floor(e)), o = Math.max(0, Math.floor(n.length / 4));
3635
3635
  if (i === 0 || o === 0)
@@ -3641,20 +3641,20 @@ async function Ps(t, e, n) {
3641
3641
  if (a > h || c > h || u > h)
3642
3642
  return null;
3643
3643
  const l = r.device.createBuffer({
3644
- size: Ie(a, 4),
3645
- usage: tn | Te
3644
+ size: Te(a, 4),
3645
+ usage: tn | Ie
3646
3646
  }), f = r.device.createBuffer({
3647
- size: Ie(c, 4),
3648
- usage: tn | Te
3647
+ size: Te(c, 4),
3648
+ usage: tn | Ie
3649
3649
  }), d = r.device.createBuffer({
3650
- size: Ie(u, 4),
3650
+ size: Te(u, 4),
3651
3651
  usage: tn | Es
3652
3652
  }), m = r.device.createBuffer({
3653
3653
  size: 16,
3654
- usage: Ms | Te
3654
+ usage: Ms | Ie
3655
3655
  }), g = r.device.createBuffer({
3656
- size: Ie(u, 4),
3657
- usage: Te | Rs
3656
+ size: Te(u, 4),
3657
+ usage: Ie | Rs
3658
3658
  });
3659
3659
  let p = !1;
3660
3660
  try {
@@ -3684,7 +3684,7 @@ async function Ps(t, e, n) {
3684
3684
  { binding: 3, resource: { buffer: m } }
3685
3685
  ]
3686
3686
  }), b = r.device.createCommandEncoder(), R = b.beginComputePass();
3687
- R.setPipeline(r.pipeline), R.setBindGroup(0, y), R.dispatchWorkgroups(Math.ceil(s / 256)), R.end(), b.copyBufferToBuffer(d, 0, g, 0, u), r.device.queue.submit([b.finish()]), await g.mapAsync(Ts), p = !0;
3687
+ R.setPipeline(r.pipeline), R.setBindGroup(0, y), R.dispatchWorkgroups(Math.ceil(s / 256)), R.end(), b.copyBufferToBuffer(d, 0, g, 0, u), r.device.queue.submit([b.finish()]), await g.mapAsync(Is), p = !0;
3688
3688
  const x = g.getMappedRange();
3689
3689
  return new Uint32Array(x.slice(0));
3690
3690
  } finally {
@@ -3998,7 +3998,7 @@ async function _s(t, e) {
3998
3998
  }
3999
3999
  });
4000
4000
  }
4001
- async function Pl(t, e) {
4001
+ async function Tl(t, e) {
4002
4002
  if (!t || !t.count || !t.positions || !t.paletteIndices)
4003
4003
  return {
4004
4004
  indices: new Uint32Array(0),
@@ -4153,13 +4153,13 @@ function Us(t) {
4153
4153
  const s = zs(t.sourceWidth, t.sourceHeight, o), a = 1 / s, c = new Int32Array(o), u = new Int32Array(o);
4154
4154
  let h = 0;
4155
4155
  if (i)
4156
- for (let T = 0; T < o; T += 1) {
4157
- const Z = i[T], N = t.positions[Z * 2], L = t.positions[Z * 2 + 1];
4156
+ for (let I = 0; I < o; I += 1) {
4157
+ const Z = i[I], N = t.positions[Z * 2], L = t.positions[Z * 2 + 1];
4158
4158
  !Number.isFinite(N) || !Number.isFinite(L) || (c[h] = Math.floor(N * a), u[h] = Math.floor(L * a), h += 1);
4159
4159
  }
4160
4160
  else
4161
- for (let T = 0; T < r; T += 1) {
4162
- const Z = t.positions[T * 2], N = t.positions[T * 2 + 1];
4161
+ for (let I = 0; I < r; I += 1) {
4162
+ const Z = t.positions[I * 2], N = t.positions[I * 2 + 1];
4163
4163
  !Number.isFinite(Z) || !Number.isFinite(N) || (c[h] = Math.floor(Z * a), u[h] = Math.floor(N * a), h += 1);
4164
4164
  }
4165
4165
  if (h === 0)
@@ -4172,13 +4172,13 @@ function Us(t) {
4172
4172
  m.fill(2147483647);
4173
4173
  let p = 0;
4174
4174
  const y = new Int32Array(h);
4175
- for (let T = 0; T < h; T += 1) {
4176
- const Z = c[T], N = u[T];
4175
+ for (let I = 0; I < h; I += 1) {
4176
+ const Z = c[I], N = u[I];
4177
4177
  let L = fe(Z, N, d);
4178
4178
  for (; ; ) {
4179
4179
  const $ = m[L * 2];
4180
4180
  if ($ === 2147483647) {
4181
- if (m[L * 2] = Z, m[L * 2 + 1] = N, g[L] = 1, y[T] = L, p += 1, p * 4 > f * 3) {
4181
+ if (m[L * 2] = Z, m[L * 2 + 1] = N, g[L] = 1, y[I] = L, p += 1, p * 4 > f * 3) {
4182
4182
  const At = f;
4183
4183
  f <<= 1, d = f - 1;
4184
4184
  const ct = new Int32Array(f * 2), Rt = new Int32Array(f);
@@ -4192,12 +4192,12 @@ function Us(t) {
4192
4192
  }
4193
4193
  for (m = ct, g = Rt, L = fe(Z, N, d); m[L * 2] !== Z || m[L * 2 + 1] !== N; )
4194
4194
  L = L + 1 & d;
4195
- y[T] = L;
4195
+ y[I] = L;
4196
4196
  }
4197
4197
  break;
4198
4198
  }
4199
4199
  if ($ === Z && m[L * 2 + 1] === N) {
4200
- g[L] += 1, y[T] = L;
4200
+ g[L] += 1, y[I] = L;
4201
4201
  break;
4202
4202
  }
4203
4203
  L = L + 1 & d;
@@ -4206,32 +4206,32 @@ function Us(t) {
4206
4206
  const b = new Int32Array(p * 2), R = new Uint32Array(p), x = new Uint32Array(p), E = new Int32Array(f);
4207
4207
  E.fill(Ne);
4208
4208
  let P = 0, O = 0;
4209
- for (let T = 0; T < f; T += 1)
4210
- m[T * 2] !== 2147483647 && (b[P * 2] = m[T * 2], b[P * 2 + 1] = m[T * 2 + 1], R[P] = O, x[P] = g[T], E[T] = P, O += g[T], P += 1);
4209
+ for (let I = 0; I < f; I += 1)
4210
+ m[I * 2] !== 2147483647 && (b[P * 2] = m[I * 2], b[P * 2 + 1] = m[I * 2 + 1], R[P] = O, x[P] = g[I], E[I] = P, O += g[I], P += 1);
4211
4211
  const k = new Uint32Array(h), q = new Uint32Array(p);
4212
4212
  if (q.set(R), i)
4213
- for (let T = 0; T < h; T += 1) {
4214
- const Z = E[y[T]];
4215
- k[q[Z]] = i[T], q[Z] += 1;
4213
+ for (let I = 0; I < h; I += 1) {
4214
+ const Z = E[y[I]];
4215
+ k[q[Z]] = i[I], q[Z] += 1;
4216
4216
  }
4217
4217
  else {
4218
- let T = 0;
4218
+ let I = 0;
4219
4219
  for (let Z = 0; Z < r; Z += 1) {
4220
4220
  const N = t.positions[Z * 2], L = t.positions[Z * 2 + 1];
4221
4221
  if (!Number.isFinite(N) || !Number.isFinite(L)) continue;
4222
- const $ = E[y[T]];
4223
- k[q[$]] = Z, q[$] += 1, T += 1;
4222
+ const $ = E[y[I]];
4223
+ k[q[$]] = Z, q[$] += 1, I += 1;
4224
4224
  }
4225
4225
  }
4226
4226
  let z = 1;
4227
4227
  for (; z < p * 2; ) z <<= 1;
4228
4228
  const H = z - 1, ot = new Int32Array(z);
4229
4229
  ot.fill(Ne);
4230
- for (let T = 0; T < p; T += 1) {
4231
- const Z = b[T * 2], N = b[T * 2 + 1];
4230
+ for (let I = 0; I < p; I += 1) {
4231
+ const Z = b[I * 2], N = b[I * 2 + 1];
4232
4232
  let L = fe(Z, N, H);
4233
4233
  for (; ot[L] !== Ne; ) L = L + 1 & H;
4234
- ot[L] = T;
4234
+ ot[L] = I;
4235
4235
  }
4236
4236
  return {
4237
4237
  cellSize: s,
@@ -4293,7 +4293,7 @@ const dn = new oi(
4293
4293
  }
4294
4294
  }
4295
4295
  );
4296
- function Cl() {
4296
+ function Pl() {
4297
4297
  dn.terminate("worker terminated");
4298
4298
  }
4299
4299
  function Xs(t, e) {
@@ -4375,9 +4375,9 @@ function qs(t, e, n, r, i, o, s) {
4375
4375
  if (!Number.isFinite(y) || !Number.isFinite(b)) return null;
4376
4376
  const R = Math.max(1e-6, p.getViewState().zoom), x = p.getPointSizeByZoom(), P = Math.max(Gs, x * Vs) / R;
4377
4377
  if (!Number.isFinite(P) || P <= 0) return null;
4378
- const { cellSize: O, cellOffsets: k, cellLengths: q, pointIndices: z, positions: H, safeCount: ot } = c, T = Math.floor(y / O), Z = Math.floor(b / O), N = Math.max(1, Math.ceil(P / O)), L = P * P;
4378
+ const { cellSize: O, cellOffsets: k, cellLengths: q, pointIndices: z, positions: H, safeCount: ot } = c, I = Math.floor(y / O), Z = Math.floor(b / O), N = Math.max(1, Math.ceil(P / O)), L = P * P;
4379
4379
  let $ = -1, At = L, ct = 0, Rt = 0;
4380
- for (let vt = T - N; vt <= T + N; vt += 1)
4380
+ for (let vt = I - N; vt <= I + N; vt += 1)
4381
4381
  for (let v = Z - N; v <= Z + N; v += 1) {
4382
4382
  const M = Os(c, vt, v);
4383
4383
  if (M < 0) continue;
@@ -4438,7 +4438,7 @@ function qs(t, e, n, r, i, o, s) {
4438
4438
  }, [c, n]), D(() => {
4439
4439
  }, [o, n]), { getCellByCoordinates: f, emitPointHover: d, emitPointClick: m };
4440
4440
  }
4441
- const _l = yi(function({
4441
+ const Cl = yi(function({
4442
4442
  data: e = null,
4443
4443
  palette: n = null,
4444
4444
  sizeByZoom: r,
@@ -4519,7 +4519,7 @@ function Ks(t, e, n) {
4519
4519
  u(0);
4520
4520
  return;
4521
4521
  }
4522
- const d = Tn(t, l, f.getZoomRange());
4522
+ const d = In(t, l, f.getZoomRange());
4523
4523
  u(d);
4524
4524
  },
4525
4525
  [t, u]
@@ -4633,7 +4633,7 @@ function ra(t) {
4633
4633
  shadowOffsetY: 0
4634
4634
  };
4635
4635
  }
4636
- function Fl({
4636
+ function _l({
4637
4637
  regions: t,
4638
4638
  polygons: e,
4639
4639
  strokeStyle: n,
@@ -4649,7 +4649,7 @@ function Fl({
4649
4649
  onHover: f,
4650
4650
  onClick: d
4651
4651
  }) {
4652
- const { rendererRef: m, rendererSerial: g, canvasRef: p, containerRef: y, registerDrawCallback: b, unregisterDrawCallback: R, requestOverlayRedraw: x, drawInvalidateRef: E, screenToWorld: P, worldToScreen: O, isInteractionLocked: k } = we(), q = t ?? xr, z = e ?? na, H = lt(() => q.length > 0 ? q : z.length === 0 ? xr : z.map((U, G) => ({ id: G, coordinates: U })), [q, z]), [ot, T] = ne(null), [Z, N] = ne(() => h ?? null), L = h !== void 0, $ = L ? h ?? null : Z, At = J(null);
4652
+ const { rendererRef: m, rendererSerial: g, canvasRef: p, containerRef: y, registerDrawCallback: b, unregisterDrawCallback: R, requestOverlayRedraw: x, drawInvalidateRef: E, screenToWorld: P, worldToScreen: O, isInteractionLocked: k } = we(), q = t ?? xr, z = e ?? na, H = lt(() => q.length > 0 ? q : z.length === 0 ? xr : z.map((U, G) => ({ id: G, coordinates: U })), [q, z]), [ot, I] = ne(null), [Z, N] = ne(() => h ?? null), L = h !== void 0, $ = L ? h ?? null : Z, At = J(null);
4653
4653
  D(() => {
4654
4654
  L && N(h ?? null);
4655
4655
  }, [L, h]);
@@ -4672,7 +4672,7 @@ function Fl({
4672
4672
  }, [g, Ct]), D(() => {
4673
4673
  !($ === null ? !0 : H.some((B, rt) => String(mn(B, rt)) === String($))) && $ !== null && ct(null);
4674
4674
  const G = At.current;
4675
- !(G === null ? !0 : H.some((B, rt) => String(mn(B, rt)) === String(G))) && G !== null && (At.current = null, T(null), f?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }));
4675
+ !(G === null ? !0 : H.some((B, rt) => String(mn(B, rt)) === String(G))) && G !== null && (At.current = null, I(null), f?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }));
4676
4676
  }, [H, $, f, ct]);
4677
4677
  const yt = V(
4678
4678
  (U) => {
@@ -4713,13 +4713,13 @@ function Fl({
4713
4713
  activeRegionId: rt,
4714
4714
  resolvedStrokeStyle: pt,
4715
4715
  resolvedHoverStrokeStyle: ut,
4716
- resolvedActiveStrokeStyle: Tt,
4716
+ resolvedActiveStrokeStyle: It,
4717
4717
  resolveStrokeStyleProp: Et,
4718
4718
  worldToScreenPoints: C
4719
4719
  } = K.current;
4720
4720
  for (const Y of nt) {
4721
4721
  const { region: et, polygons: at, regionIndex: F, regionKey: j } = Y, ht = Ye(rt, j) ? "active" : Ye(B, j) ? "hover" : "default";
4722
- let it = ht === "active" ? Tt : ht === "hover" ? ut : pt;
4722
+ let it = ht === "active" ? It : ht === "hover" ? ut : pt;
4723
4723
  if (Et) {
4724
4724
  const Ot = Et({ region: et, regionId: j, regionIndex: F, state: ht });
4725
4725
  it = Ht(it, Ot || void 0);
@@ -4759,17 +4759,17 @@ function Fl({
4759
4759
  preparedRegions: rt,
4760
4760
  resolvedLabelStyle: pt,
4761
4761
  labelStyleResolver: ut,
4762
- labelAnchor: Tt,
4762
+ labelAnchor: It,
4763
4763
  autoLiftLabelAtMaxZoom: Et,
4764
4764
  clampLabelToViewport: C,
4765
4765
  regionLabelAutoLiftOffsetPx: Y,
4766
4766
  rendererRef: et
4767
4767
  } = bt.current;
4768
4768
  if (rt.length === 0) return;
4769
- const at = Math.max(1e-6, et.current?.getViewState?.().zoom ?? 1), F = typeof Y == "number" && Number.isFinite(Y) ? Math.max(0, Y) : Tn(Et, at, et.current?.getZoomRange?.());
4769
+ const at = Math.max(1e-6, et.current?.getViewState?.().zoom ?? 1), F = typeof Y == "number" && Number.isFinite(Y) ? Math.max(0, Y) : In(Et, at, et.current?.getZoomRange?.());
4770
4770
  for (const j of rt) {
4771
4771
  if (!j.region.label) continue;
4772
- const ht = En(j.polygons, Tt);
4772
+ const ht = En(j.polygons, It);
4773
4773
  if (!ht) continue;
4774
4774
  const it = Wt(et.current?.worldToScreen(ht[0], ht[1]) ?? []);
4775
4775
  if (!it) continue;
@@ -4807,7 +4807,7 @@ function Fl({
4807
4807
  if (!pt) return;
4808
4808
  const {
4809
4809
  preparedRegionHits: ut,
4810
- resolvedLabelStyle: Tt,
4810
+ resolvedLabelStyle: It,
4811
4811
  labelStyleResolver: Et,
4812
4812
  regionLabelAutoLiftOffsetPx: C,
4813
4813
  clampLabelToViewport: Y,
@@ -4824,7 +4824,7 @@ function Fl({
4824
4824
  it,
4825
4825
  ut,
4826
4826
  pt,
4827
- Tt,
4827
+ It,
4828
4828
  Et,
4829
4829
  typeof C == "number" ? C : 0,
4830
4830
  dt?.width ?? 0,
@@ -4834,7 +4834,7 @@ function Fl({
4834
4834
  }
4835
4835
  }
4836
4836
  const ht = At.current;
4837
- String(ht) !== String(F) && (At.current = F, T(F), et?.({
4837
+ String(ht) !== String(F) && (At.current = F, I(F), et?.({
4838
4838
  region: j?.region ?? null,
4839
4839
  regionId: F,
4840
4840
  regionIndex: j?.regionIndex ?? -1,
@@ -4846,7 +4846,7 @@ function Fl({
4846
4846
  if (!pt) return;
4847
4847
  const {
4848
4848
  preparedRegionHits: ut,
4849
- resolvedLabelStyle: Tt,
4849
+ resolvedLabelStyle: It,
4850
4850
  labelStyleResolver: Et,
4851
4851
  regionLabelAutoLiftOffsetPx: C,
4852
4852
  clampLabelToViewport: Y,
@@ -4863,7 +4863,7 @@ function Fl({
4863
4863
  j,
4864
4864
  ut,
4865
4865
  pt,
4866
- Tt,
4866
+ It,
4867
4867
  Et,
4868
4868
  typeof C == "number" ? C : 0,
4869
4869
  ht?.width ?? 0,
@@ -4877,14 +4877,14 @@ function Fl({
4877
4877
  coordinate: F
4878
4878
  });
4879
4879
  }, B = () => {
4880
- At.current !== null && (At.current = null, T(null), xt.current.onHover?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }), x());
4880
+ At.current !== null && (At.current = null, I(null), xt.current.onHover?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }), x());
4881
4881
  };
4882
4882
  return U.addEventListener("pointermove", G), U.addEventListener("click", nt), U.addEventListener("pointerleave", B), () => {
4883
4883
  U.removeEventListener("pointermove", G), U.removeEventListener("click", nt), U.removeEventListener("pointerleave", B);
4884
4884
  };
4885
4885
  }, [y, m, p, P, O, k, x]), null;
4886
4886
  }
4887
- function Ll({
4887
+ function Fl({
4888
4888
  imageWidth: t,
4889
4889
  imageHeight: e,
4890
4890
  tiles: n,
@@ -5179,7 +5179,7 @@ function Rr(t) {
5179
5179
  saturation: r / 100
5180
5180
  };
5181
5181
  }
5182
- function In(t) {
5182
+ function Tn(t) {
5183
5183
  return t;
5184
5184
  }
5185
5185
  function nn(t) {
@@ -5189,7 +5189,7 @@ function Ce(t) {
5189
5189
  return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? null : Math.max(1e-6, t);
5190
5190
  }
5191
5191
  function rn(t) {
5192
- return typeof t == "function" ? t : In;
5192
+ return typeof t == "function" ? t : Tn;
5193
5193
  }
5194
5194
  function si(t, e, n) {
5195
5195
  const r = t.getBoundingClientRect(), i = e - r.left - r.width * 0.5, o = n - r.top - r.height * 0.5;
@@ -5237,24 +5237,18 @@ function Aa(t) {
5237
5237
  const i = n.getBoundingClientRect(), o = e.clientX - i.left, s = e.clientY - i.top, a = e.deltaY < 0 ? 1.12 : 0.89;
5238
5238
  r(a, o, s);
5239
5239
  }
5240
- const va = 4, Ea = 300;
5241
- function Ma(t) {
5240
+ const va = 4;
5241
+ function Ea(t) {
5242
5242
  const { event: e, canvas: n, snapState: r, onSnapZoom: i } = t;
5243
- e.preventDefault();
5244
- const o = performance.now();
5245
- if (o - r.lastSnapTimeMs < Ea) {
5246
- r.accumulatedDelta = 0;
5247
- return;
5248
- }
5249
- if (r.accumulatedDelta !== 0 && e.deltaY !== 0 && Math.sign(r.accumulatedDelta) !== Math.sign(e.deltaY) && (r.accumulatedDelta = 0), r.accumulatedDelta += e.deltaY, Math.abs(r.accumulatedDelta) < va) return;
5250
- const s = n.getBoundingClientRect(), a = e.clientX - s.left, c = e.clientY - s.top, u = r.accumulatedDelta > 0 ? "out" : "in";
5251
- r.accumulatedDelta = 0, r.lastSnapTimeMs = o, i(u, a, c);
5243
+ if (e.preventDefault(), r.accumulatedDelta !== 0 && e.deltaY !== 0 && Math.sign(r.accumulatedDelta) !== Math.sign(e.deltaY) && (r.accumulatedDelta = 0), r.accumulatedDelta += e.deltaY, Math.abs(r.accumulatedDelta) < va) return;
5244
+ const o = n.getBoundingClientRect(), s = e.clientX - o.left, a = e.clientY - o.top, c = r.accumulatedDelta > 0 ? "out" : "in";
5245
+ r.accumulatedDelta = 0, i(c, s, a);
5252
5246
  }
5253
- function Ra(t) {
5247
+ function Ma(t) {
5254
5248
  const { event: e, canvas: n, onZoomBy: r } = t, i = n.getBoundingClientRect(), o = e.clientX - i.left, s = e.clientY - i.top;
5255
5249
  r(e.shiftKey ? 0.8 : 1.25, o, s);
5256
5250
  }
5257
- function Ta(t, e) {
5251
+ function Ra(t, e) {
5258
5252
  (e || t.ctrlKey || t.metaKey) && t.preventDefault();
5259
5253
  }
5260
5254
  function Ve(t) {
@@ -5272,7 +5266,7 @@ function Ia(t, e) {
5272
5266
  const n = Math.max(1e-6, t.getViewState().zoom), r = e.maxTierZoom + Math.log2(n);
5273
5267
  return X(Math.floor(r), 0, e.maxTierZoom);
5274
5268
  }
5275
- function Pa(t, e) {
5269
+ function Ta(t, e) {
5276
5270
  return !(t[2] <= e[0] || t[0] >= e[2] || t[3] <= e[1] || t[1] >= e[3]);
5277
5271
  }
5278
5272
  function li(t, e, n) {
@@ -5295,14 +5289,14 @@ function li(t, e, n) {
5295
5289
  }
5296
5290
  return R.sort((x, E) => x.distance2 - E.distance2), R;
5297
5291
  }
5298
- function Ca(t, e) {
5292
+ function Pa(t, e) {
5299
5293
  const n = Ia(t, e);
5300
5294
  return {
5301
5295
  tier: n,
5302
5296
  visible: li(t, e, n)
5303
5297
  };
5304
5298
  }
5305
- function _a(t) {
5299
+ function Ca(t) {
5306
5300
  t.interactionLocked || ba({
5307
5301
  event: t.event,
5308
5302
  canvas: t.canvas,
@@ -5314,7 +5308,7 @@ function _a(t) {
5314
5308
  cancelViewAnimation: t.cancelViewAnimation
5315
5309
  });
5316
5310
  }
5317
- function Fa(t) {
5311
+ function _a(t) {
5318
5312
  t.interactionLocked || xa({
5319
5313
  event: t.event,
5320
5314
  canvas: t.canvas,
@@ -5329,25 +5323,25 @@ function Fa(t) {
5329
5323
  requestRender: t.requestRender
5330
5324
  });
5331
5325
  }
5332
- function La(t) {
5326
+ function Fa(t) {
5333
5327
  t.interactionLocked || Sa(t.event, t.canvas, t.state);
5334
5328
  }
5335
- function Na(t) {
5336
- t.interactionLocked || Ra({
5329
+ function La(t) {
5330
+ t.interactionLocked || Ma({
5337
5331
  event: t.event,
5338
5332
  canvas: t.canvas,
5339
5333
  onZoomBy: t.onZoomBy
5340
5334
  });
5341
5335
  }
5342
- function Ba(t) {
5343
- Ta(t.event, t.state.dragging);
5336
+ function Na(t) {
5337
+ Ra(t.event, t.state.dragging);
5344
5338
  }
5345
- function ka(t, e) {
5339
+ function Ba(t, e) {
5346
5340
  ai(t, e);
5347
5341
  }
5348
- function za(t) {
5342
+ function ka(t) {
5349
5343
  return {
5350
- pointerDown: (e) => _a({
5344
+ pointerDown: (e) => Ca({
5351
5345
  event: e,
5352
5346
  interactionLocked: t.getInteractionLocked(),
5353
5347
  canvas: t.canvas,
@@ -5356,7 +5350,7 @@ function za(t) {
5356
5350
  rotationDragSensitivityDegPerPixel: t.getRotationDragSensitivityDegPerPixel(),
5357
5351
  cancelViewAnimation: t.cancelViewAnimation
5358
5352
  }),
5359
- pointerMove: (e) => Fa({
5353
+ pointerMove: (e) => _a({
5360
5354
  event: e,
5361
5355
  interactionLocked: t.getInteractionLocked(),
5362
5356
  canvas: t.canvas,
@@ -5368,7 +5362,7 @@ function za(t) {
5368
5362
  emitViewState: t.emitViewState,
5369
5363
  requestRender: t.requestRender
5370
5364
  }),
5371
- pointerUp: (e) => La({
5365
+ pointerUp: (e) => Fa({
5372
5366
  event: e,
5373
5367
  interactionLocked: t.getInteractionLocked(),
5374
5368
  canvas: t.canvas,
@@ -5380,7 +5374,7 @@ function za(t) {
5380
5374
  return;
5381
5375
  }
5382
5376
  if (t.getUseZoomSnaps?.() && t.onSnapZoom && t.zoomSnapState) {
5383
- Ma({
5377
+ Ea({
5384
5378
  event: e,
5385
5379
  canvas: t.canvas,
5386
5380
  snapState: t.zoomSnapState,
@@ -5394,20 +5388,20 @@ function za(t) {
5394
5388
  onZoomBy: t.zoomBy
5395
5389
  });
5396
5390
  },
5397
- doubleClick: (e) => Na({
5391
+ doubleClick: (e) => La({
5398
5392
  event: e,
5399
5393
  interactionLocked: t.getInteractionLocked(),
5400
5394
  canvas: t.canvas,
5401
5395
  onZoomBy: t.zoomBy
5402
5396
  }),
5403
- contextMenu: (e) => Ba({
5397
+ contextMenu: (e) => Na({
5404
5398
  event: e,
5405
5399
  canvas: t.canvas,
5406
5400
  state: t.state
5407
5401
  })
5408
5402
  };
5409
5403
  }
5410
- function Da(t) {
5404
+ function za(t) {
5411
5405
  const { gl: e, cache: n, maxCacheTiles: r } = t;
5412
5406
  if (n.size <= r) return;
5413
5407
  const i = Math.max(0, Math.floor(r));
@@ -5419,12 +5413,12 @@ function Da(t) {
5419
5413
  e.deleteTexture(s.texture), n.delete(o);
5420
5414
  }
5421
5415
  }
5422
- function Ua(t, e) {
5416
+ function Da(t, e) {
5423
5417
  if (t.isContextLost()) return null;
5424
5418
  const n = t.createTexture();
5425
5419
  return n ? (t.bindTexture(t.TEXTURE_2D, n), t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, 1), 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.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, e), t.bindTexture(t.TEXTURE_2D, null), n) : null;
5426
5420
  }
5427
- function Oa(t) {
5421
+ function Ua(t) {
5428
5422
  const { gl: e, cache: n, tile: r, bitmap: i, frameSerial: o, maxCacheTiles: s, destroyed: a, contextLost: c, requestRender: u } = t;
5429
5423
  if (a || c || e.isContextLost()) {
5430
5424
  i.close();
@@ -5434,20 +5428,20 @@ function Oa(t) {
5434
5428
  i.close();
5435
5429
  return;
5436
5430
  }
5437
- const h = Ua(e, i);
5431
+ const h = Da(e, i);
5438
5432
  i.close(), h && (n.set(r.key, {
5439
5433
  key: r.key,
5440
5434
  texture: h,
5441
5435
  bounds: r.bounds,
5442
5436
  tier: r.tier,
5443
5437
  lastUsed: o
5444
- }), Da({ gl: e, cache: n, maxCacheTiles: s }), u());
5438
+ }), za({ gl: e, cache: n, maxCacheTiles: s }), u());
5445
5439
  }
5446
- function Ya(t, e) {
5440
+ function Oa(t, e) {
5447
5441
  for (const [, n] of e)
5448
5442
  t.deleteTexture(n.texture);
5449
5443
  }
5450
- function Xa(t) {
5444
+ function Ya(t) {
5451
5445
  const { event: e, destroyed: n, contextLost: r, cancelViewAnimation: i, cancelDrag: o, tileScheduler: s, cache: a, onContextLost: c } = t;
5452
5446
  if (e.preventDefault(), n || r)
5453
5447
  return {
@@ -5460,19 +5454,19 @@ function Xa(t) {
5460
5454
  frame: u
5461
5455
  };
5462
5456
  }
5463
- function Wa(t) {
5457
+ function Xa(t) {
5464
5458
  if (t.destroyed)
5465
5459
  return {
5466
5460
  didDestroy: !1,
5467
5461
  frame: t.frame
5468
5462
  };
5469
5463
  let e = t.frame;
5470
- return e !== null && (cancelAnimationFrame(e), e = null), t.cancelViewAnimation(), t.resizeObserver.disconnect(), t.removeCanvasEventListeners(), t.cancelDrag(), t.tileScheduler.destroy(), !t.contextLost && !t.gl.isContextLost() && (Ya(t.gl, t.cache), t.gl.deleteBuffer(t.tileProgram.vbo), t.gl.deleteVertexArray(t.tileProgram.vao), t.gl.deleteProgram(t.tileProgram.program), t.gl.deleteBuffer(t.pointProgram.posBuffer), t.gl.deleteBuffer(t.pointProgram.termBuffer), t.gl.deleteBuffer(t.pointProgram.fillModeBuffer), t.gl.deleteBuffer(t.pointProgram.indexBuffer), t.gl.deleteTexture(t.pointProgram.paletteTexture), t.gl.deleteVertexArray(t.pointProgram.vao), t.gl.deleteProgram(t.pointProgram.program)), t.cache.clear(), {
5464
+ return e !== null && (cancelAnimationFrame(e), e = null), t.cancelViewAnimation(), t.resizeObserver.disconnect(), t.removeCanvasEventListeners(), t.cancelDrag(), t.tileScheduler.destroy(), !t.contextLost && !t.gl.isContextLost() && (Oa(t.gl, t.cache), t.gl.deleteBuffer(t.tileProgram.vbo), t.gl.deleteVertexArray(t.tileProgram.vao), t.gl.deleteProgram(t.tileProgram.program), t.gl.deleteBuffer(t.pointProgram.posBuffer), t.gl.deleteBuffer(t.pointProgram.termBuffer), t.gl.deleteBuffer(t.pointProgram.fillModeBuffer), t.gl.deleteBuffer(t.pointProgram.indexBuffer), t.gl.deleteTexture(t.pointProgram.paletteTexture), t.gl.deleteVertexArray(t.pointProgram.vao), t.gl.deleteProgram(t.pointProgram.program)), t.cache.clear(), {
5471
5465
  didDestroy: !0,
5472
5466
  frame: e
5473
5467
  };
5474
5468
  }
5475
- function Va(t, e) {
5469
+ function Wa(t, e) {
5476
5470
  if (e <= 0 || t.length === 0)
5477
5471
  return new Uint32Array(0);
5478
5472
  let n = t.length;
@@ -5490,10 +5484,10 @@ function Va(t, e) {
5490
5484
  }
5491
5485
  return r;
5492
5486
  }
5493
- function Ga(t, e) {
5487
+ function Va(t, e) {
5494
5488
  return e <= 0 ? new Uint8Array(0) : t.length < e ? new Uint8Array(e) : t.subarray(0, e);
5495
5489
  }
5496
- function qa(t, e, n, r, i) {
5490
+ function Ga(t, e, n, r, i) {
5497
5491
  if (!i || i.length === 0)
5498
5492
  return {
5499
5493
  ...t,
@@ -5512,7 +5506,7 @@ function qa(t, e, n, r, i) {
5512
5506
  pointPaletteSize: s
5513
5507
  };
5514
5508
  }
5515
- function Ha(t, e, n, r, i) {
5509
+ function qa(t, e, n, r, i) {
5516
5510
  if (!i || !i.count || !i.positions || !i.paletteIndices)
5517
5511
  return {
5518
5512
  ...t,
@@ -5520,7 +5514,7 @@ function Ha(t, e, n, r, i) {
5520
5514
  pointCount: 0,
5521
5515
  usePointIndices: !1
5522
5516
  };
5523
- const o = i.fillModes instanceof Uint8Array ? i.fillModes : null, s = o !== null, a = Math.max(0, Math.min(i.count, Math.floor(i.positions.length / 2), i.paletteIndices.length, s ? o.length : Number.MAX_SAFE_INTEGER)), c = i.positions.subarray(0, a * 2), u = i.paletteIndices.subarray(0, a), h = s ? o.subarray(0, a) : void 0, l = i.drawIndices instanceof Uint32Array, f = l ? Va(i.drawIndices, a) : null, d = t.lastPointData, m = d?.fillModes instanceof Uint8Array, g = t.pointBuffersDirty || !d || d.count !== a || !Pe(d.positions, c) || !Pe(d.paletteIndices, u) || m !== s || s && (!d?.fillModes || !Pe(d.fillModes, h)), p = t.pointBuffersDirty || l && (!d?.drawIndices || !Pe(d.drawIndices, f)) || !l && !!d?.drawIndices, y = {
5517
+ const o = i.fillModes instanceof Uint8Array ? i.fillModes : null, s = o !== null, a = Math.max(0, Math.min(i.count, Math.floor(i.positions.length / 2), i.paletteIndices.length, s ? o.length : Number.MAX_SAFE_INTEGER)), c = i.positions.subarray(0, a * 2), u = i.paletteIndices.subarray(0, a), h = s ? o.subarray(0, a) : void 0, l = i.drawIndices instanceof Uint32Array, f = l ? Wa(i.drawIndices, a) : null, d = t.lastPointData, m = d?.fillModes instanceof Uint8Array, g = t.pointBuffersDirty || !d || d.count !== a || !Pe(d.positions, c) || !Pe(d.paletteIndices, u) || m !== s || s && (!d?.fillModes || !Pe(d.fillModes, h)), p = t.pointBuffersDirty || l && (!d?.drawIndices || !Pe(d.drawIndices, f)) || !l && !!d?.drawIndices, y = {
5524
5518
  ...t,
5525
5519
  lastPointData: {
5526
5520
  count: a,
@@ -5537,12 +5531,12 @@ function Ha(t, e, n, r, i) {
5537
5531
  return y;
5538
5532
  if (g) {
5539
5533
  e.bindBuffer(e.ARRAY_BUFFER, n.posBuffer), e.bufferData(e.ARRAY_BUFFER, b.positions, e.STATIC_DRAW), e.bindBuffer(e.ARRAY_BUFFER, n.termBuffer), e.bufferData(e.ARRAY_BUFFER, b.paletteIndices, e.STATIC_DRAW);
5540
- const R = Ga(y.zeroFillModes, a);
5534
+ const R = Va(y.zeroFillModes, a);
5541
5535
  e.bindBuffer(e.ARRAY_BUFFER, n.fillModeBuffer), e.bufferData(e.ARRAY_BUFFER, b.fillModes ?? R, e.STATIC_DRAW), e.bindBuffer(e.ARRAY_BUFFER, null), y.zeroFillModes = R;
5542
5536
  }
5543
5537
  return l && p && (e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, f ?? new Uint32Array(0), e.DYNAMIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null)), y.usePointIndices = l, y.pointCount = l ? f?.length ?? 0 : b.count, (g || p) && (y.pointBuffersDirty = !1), y;
5544
5538
  }
5545
- function Za(t) {
5539
+ function Ha(t) {
5546
5540
  const {
5547
5541
  gl: e,
5548
5542
  camera: n,
@@ -5583,9 +5577,9 @@ function Za(t) {
5583
5577
  }
5584
5578
  L.lastUsed = o, e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, L.texture), e.uniform4f(s.uBounds, L.bounds[0], L.bounds[1], L.bounds[2], L.bounds[3]), e.drawArrays(e.TRIANGLE_STRIP, 0, 4), q += 1;
5585
5579
  }
5586
- const H = z.slice(), ot = 1e6, T = [];
5587
- x > 0 && T.push(x - 1), x < r.maxTierZoom && T.push(x + 1);
5588
- for (const N of T) {
5580
+ const H = z.slice(), ot = 1e6, I = [];
5581
+ x > 0 && I.push(x - 1), x < r.maxTierZoom && I.push(x + 1);
5582
+ for (const N of I) {
5589
5583
  const L = y(N);
5590
5584
  for (const $ of L)
5591
5585
  i.has($.key) || ($.distance2 += ot, H.push($));
@@ -5603,7 +5597,7 @@ function Za(t) {
5603
5597
  drawCalls: k.length + q + (Z > 0 ? 1 : 0)
5604
5598
  };
5605
5599
  }
5606
- function Tr(t) {
5600
+ function Ir(t) {
5607
5601
  const r = bn(t, `#version 300 es
5608
5602
  precision highp float;
5609
5603
  in vec2 aUnit;
@@ -5668,7 +5662,7 @@ function Tr(t) {
5668
5662
  uSaturation: u
5669
5663
  };
5670
5664
  }
5671
- function Ir(t) {
5665
+ function Tr(t) {
5672
5666
  const r = bn(t, `#version 300 es
5673
5667
  precision highp float;
5674
5668
  in vec2 aPosition;
@@ -5756,7 +5750,7 @@ function Ir(t) {
5756
5750
  function ci(t) {
5757
5751
  t.animation = null, t.frame !== null && (cancelAnimationFrame(t.frame), t.frame = null);
5758
5752
  }
5759
- function $a(t) {
5753
+ function Za(t) {
5760
5754
  const { state: e, camera: n, target: r, durationMs: i, easing: o, onUpdate: s } = t, a = n.getViewState();
5761
5755
  ci(e), e.animation = {
5762
5756
  startMs: St(),
@@ -5788,19 +5782,19 @@ function $a(t) {
5788
5782
  };
5789
5783
  e.frame = requestAnimationFrame(c);
5790
5784
  }
5791
- function Ka(t) {
5785
+ function $a(t) {
5792
5786
  const e = Math.max(t * 0.5, 1e-6), n = Math.max(1, t * 8);
5793
5787
  return {
5794
5788
  minZoom: e,
5795
5789
  maxZoom: Math.max(e, n)
5796
5790
  };
5797
5791
  }
5798
- function ja(t, e, n) {
5799
- const r = Ka(t);
5792
+ function Ka(t, e, n) {
5793
+ const r = $a(t);
5800
5794
  let i = e ?? r.minZoom, o = n ?? r.maxZoom;
5801
5795
  return i = Math.max(1e-6, i), o = Math.max(1e-6, o), i > o && (i = o), { minZoom: i, maxZoom: o };
5802
5796
  }
5803
- function Qa(t, e, n, r, i) {
5797
+ function ja(t, e, n, r, i) {
5804
5798
  const o = t.getViewState(), s = {
5805
5799
  zoom: typeof r.zoom == "number" && Number.isFinite(r.zoom) ? X(r.zoom, e, n) : o.zoom,
5806
5800
  offsetX: typeof r.offsetX == "number" && Number.isFinite(r.offsetX) ? r.offsetX : o.offsetX,
@@ -5823,7 +5817,7 @@ function Pr(t, e, n, r, i) {
5823
5817
  }
5824
5818
  };
5825
5819
  }
5826
- function Ja(t, e, n, r, i, o) {
5820
+ function Qa(t, e, n, r, i, o) {
5827
5821
  const s = t.getViewState(), a = X(s.zoom * r, e, n);
5828
5822
  if (a === s.zoom) return null;
5829
5823
  const [c, u] = t.screenToWorld(i, o), h = t.getViewportSize(), l = i - h.width * 0.5, f = o - h.height * 0.5, d = qe(s.rotationDeg), m = Math.cos(d), g = Math.sin(d), p = l / a * m - f / a * g, y = l / a * g + f / a * m, b = c - p, R = u - y;
@@ -5833,7 +5827,7 @@ function Ja(t, e, n, r, i, o) {
5833
5827
  offsetY: R - h.height / (2 * a)
5834
5828
  };
5835
5829
  }
5836
- function tl(t, e, n, r, i, o) {
5830
+ function Ja(t, e, n, r, i, o) {
5837
5831
  const s = t.getViewState(), a = X(r, e, n);
5838
5832
  if (a === s.zoom) return null;
5839
5833
  const [c, u] = t.screenToWorld(i, o), h = t.getViewportSize(), l = i - h.width * 0.5, f = o - h.height * 0.5, d = qe(s.rotationDeg), m = Math.cos(d), g = Math.sin(d), p = l / a * m - f / a * g, y = l / a * g + f / a * m, b = c - p, R = u - y;
@@ -5850,7 +5844,7 @@ function _r(t, e) {
5850
5844
  const n = 10 / e;
5851
5845
  return t.map((r) => r / n).filter((r) => Number.isFinite(r) && r > 0).sort((r, i) => r - i);
5852
5846
  }
5853
- function el(t, e, n, r) {
5847
+ function tl(t, e, n, r) {
5854
5848
  if (t.length === 0) return null;
5855
5849
  const i = Math.max(e * 5e-3, 1e-8);
5856
5850
  if (n === "in") {
@@ -5881,7 +5875,7 @@ function Fr(t, e, n, r, i) {
5881
5875
  durationMs: Math.max(0, i),
5882
5876
  from: o,
5883
5877
  to: { zoom: u, offsetX: p.offsetX, offsetY: p.offsetY, rotationDeg: o.rotationDeg },
5884
- easing: In
5878
+ easing: Tn
5885
5879
  };
5886
5880
  const y = () => {
5887
5881
  const b = t.viewAnimationState.animation;
@@ -5893,7 +5887,7 @@ function Fr(t, e, n, r, i) {
5893
5887
  };
5894
5888
  t.viewAnimationState.frame = requestAnimationFrame(y);
5895
5889
  }
5896
- class nl {
5890
+ class el {
5897
5891
  constructor(e, n, r = {}) {
5898
5892
  A(this, "canvas");
5899
5893
  A(this, "source");
@@ -5908,6 +5902,10 @@ class nl {
5908
5902
  A(this, "tileProgram");
5909
5903
  A(this, "pointProgram");
5910
5904
  A(this, "tileScheduler");
5905
+ A(this, "zoomStack", {
5906
+ cnt: 0,
5907
+ direction: null
5908
+ });
5911
5909
  A(this, "authToken");
5912
5910
  A(this, "destroyed", !1);
5913
5911
  A(this, "contextLost", !1);
@@ -5931,7 +5929,7 @@ class nl {
5931
5929
  A(this, "minZoomOverride", null);
5932
5930
  A(this, "maxZoomOverride", null);
5933
5931
  A(this, "viewTransitionDurationMs", 0);
5934
- A(this, "viewTransitionEasing", In);
5932
+ A(this, "viewTransitionEasing", Tn);
5935
5933
  A(this, "viewAnimationState", {
5936
5934
  animation: null,
5937
5935
  frame: null
@@ -5973,13 +5971,13 @@ class nl {
5973
5971
  });
5974
5972
  if (!i)
5975
5973
  throw new Error("WebGL2 not supported");
5976
- this.gl = i, this.tileProgram = Tr(this.gl), this.pointProgram = Ir(this.gl), this.tileScheduler = new oa({
5974
+ this.gl = i, this.tileProgram = Ir(this.gl), this.pointProgram = Tr(this.gl), this.tileScheduler = new oa({
5977
5975
  authToken: this.authToken,
5978
5976
  maxConcurrency: r.tileScheduler?.maxConcurrency ?? 12,
5979
5977
  maxRetries: r.tileScheduler?.maxRetries ?? 2,
5980
5978
  retryBaseDelayMs: r.tileScheduler?.retryBaseDelayMs ?? 120,
5981
5979
  retryMaxDelayMs: r.tileScheduler?.retryMaxDelayMs ?? 1200,
5982
- onTileLoad: (s, a) => Oa({
5980
+ onTileLoad: (s, a) => Ua({
5983
5981
  gl: this.gl,
5984
5982
  cache: this.cache,
5985
5983
  tile: s,
@@ -5994,7 +5992,7 @@ class nl {
5994
5992
  this.onTileError?.({ tile: s, error: a, attemptCount: c }), console.warn("tile load failed", s.url, a);
5995
5993
  }
5996
5994
  }), this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(e);
5997
- const o = za({
5995
+ const o = ka({
5998
5996
  canvas: this.canvas,
5999
5997
  state: this.interactionState,
6000
5998
  getInteractionLocked: () => this.interactionLocked,
@@ -6025,17 +6023,17 @@ class nl {
6025
6023
  };
6026
6024
  }
6027
6025
  applyZoomBounds() {
6028
- const e = ja(this.fitZoom, this.minZoomOverride, this.maxZoomOverride);
6026
+ const e = Ka(this.fitZoom, this.minZoomOverride, this.maxZoomOverride);
6029
6027
  this.minZoom = e.minZoom, this.maxZoom = e.maxZoom;
6030
6028
  }
6031
6029
  resolveTargetViewState(e) {
6032
- return Qa(this.camera, this.minZoom, this.maxZoom, e, () => Be(this.camera, this.source));
6030
+ return ja(this.camera, this.minZoom, this.maxZoom, e, () => Be(this.camera, this.source));
6033
6031
  }
6034
6032
  cancelViewAnimation() {
6035
6033
  ci(this.viewAnimationState);
6036
6034
  }
6037
6035
  startViewAnimation(e, n, r) {
6038
- $a({
6036
+ Za({
6039
6037
  state: this.viewAnimationState,
6040
6038
  camera: this.camera,
6041
6039
  target: e,
@@ -6097,11 +6095,11 @@ class nl {
6097
6095
  return this.viewAnimationState.animation !== null;
6098
6096
  }
6099
6097
  setPointPalette(e) {
6100
- const n = qa(this.getPointBufferRuntime(), this.gl, this.pointProgram, this.contextLost, e);
6098
+ const n = Ga(this.getPointBufferRuntime(), this.gl, this.pointProgram, this.contextLost, e);
6101
6099
  this.applyPointBufferRuntime(n), !(!e || e.length === 0) && this.requestRender();
6102
6100
  }
6103
6101
  setPointData(e) {
6104
- const n = Ha(this.getPointBufferRuntime(), this.gl, this.pointProgram, this.contextLost, e);
6102
+ const n = qa(this.getPointBufferRuntime(), this.gl, this.pointProgram, this.contextLost, e);
6105
6103
  this.applyPointBufferRuntime(n), this.requestRender();
6106
6104
  }
6107
6105
  setInteractionLock(e) {
@@ -6125,7 +6123,7 @@ class nl {
6125
6123
  r.brightness === n.brightness && r.contrast === n.contrast && r.saturation === n.saturation || (this.imageColorSettings = n, this.requestRender());
6126
6124
  }
6127
6125
  cancelDrag() {
6128
- ka(this.canvas, this.interactionState);
6126
+ Ba(this.canvas, this.interactionState);
6129
6127
  }
6130
6128
  screenToWorld(e, n) {
6131
6129
  const r = this.canvas.getBoundingClientRect(), i = e - r.left, o = n - r.top;
@@ -6164,11 +6162,11 @@ class nl {
6164
6162
  this.fitZoom = o.fitZoom, this.applyZoomBounds(), this.setViewState(o.target, e);
6165
6163
  }
6166
6164
  zoomBy(e, n, r, i) {
6167
- const o = Ja(this.camera, this.minZoom, this.maxZoom, e, n, r);
6165
+ const o = Qa(this.camera, this.minZoom, this.maxZoom, e, n, r);
6168
6166
  o && this.setViewState(o, i);
6169
6167
  }
6170
6168
  zoomTo(e, n, r, i) {
6171
- const o = tl(this.camera, this.minZoom, this.maxZoom, e, n, r);
6169
+ const o = Ja(this.camera, this.minZoom, this.maxZoom, e, n, r);
6172
6170
  o && this.setViewState(o, i);
6173
6171
  }
6174
6172
  setZoomSnaps(e, n) {
@@ -6187,21 +6185,25 @@ class nl {
6187
6185
  };
6188
6186
  }
6189
6187
  handleSnapZoom(e, n, r) {
6190
- const i = this.zoomSnaps.filter((s) => s >= this.minZoom && s <= this.maxZoom), o = el(i, this.camera.getViewState().zoom, e, this.zoomSnapFitAsMin);
6191
- if (o) {
6192
- if (o.type === "fit") {
6193
- const s = this.canvas.getBoundingClientRect(), a = Math.max(1, s.width || 1), c = Math.max(1, s.height || 1), u = Pr(this.source, a, c, this.minZoom, this.maxZoom);
6194
- this.fitZoom = u.fitZoom, this.applyZoomBounds(), Fr(this.getZoomPivotAnimationContext(), u.target.zoom, n, r, Cr);
6188
+ const i = this.viewAnimationState.animation, o = i ? i.to.zoom : this.camera.getViewState().zoom, s = this.zoomSnaps.filter((u) => u >= this.minZoom && u <= this.maxZoom), a = this.zoomStack;
6189
+ if (a.cnt > 0 && s.length - 1 === a.cnt && a.direction === e)
6190
+ return;
6191
+ a.direction !== e && (a.cnt = 0, a.direction = e), a.cnt += 1;
6192
+ const c = tl(s, o, e, this.zoomSnapFitAsMin);
6193
+ if (c) {
6194
+ if (c.type === "fit") {
6195
+ const u = this.canvas.getBoundingClientRect(), h = Math.max(1, u.width || 1), l = Math.max(1, u.height || 1), f = Pr(this.source, h, l, this.minZoom, this.maxZoom);
6196
+ this.fitZoom = f.fitZoom, this.applyZoomBounds(), Fr(this.getZoomPivotAnimationContext(), f.target.zoom, n, r, Cr);
6195
6197
  return;
6196
6198
  }
6197
- Fr(this.getZoomPivotAnimationContext(), o.zoom, n, r, Cr);
6199
+ Fr(this.getZoomPivotAnimationContext(), c.zoom, n, r, Cr);
6198
6200
  }
6199
6201
  }
6200
6202
  render() {
6201
6203
  if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
6202
6204
  const e = this.onStats ? St() : 0;
6203
6205
  this.frameSerial += 1;
6204
- const n = Za({
6206
+ const n = Ha({
6205
6207
  gl: this.gl,
6206
6208
  camera: this.camera,
6207
6209
  source: this.source,
@@ -6217,10 +6219,10 @@ class nl {
6217
6219
  pointInnerFillOpacity: this.pointInnerFillOpacity,
6218
6220
  pointSizePx: this.getPointSizeByZoom() * Math.max(1, window.devicePixelRatio || 1),
6219
6221
  tileScheduler: this.tileScheduler,
6220
- getVisibleTiles: () => Ca(this.camera, this.source),
6222
+ getVisibleTiles: () => Pa(this.camera, this.source),
6221
6223
  getVisibleTilesForTier: (r) => li(this.camera, this.source, r),
6222
6224
  getViewBounds: () => Ve(this.camera),
6223
- intersectsBounds: Pa
6225
+ intersectsBounds: Ta
6224
6226
  });
6225
6227
  if (this.onStats) {
6226
6228
  const r = this.tileScheduler.getSnapshot();
@@ -6252,7 +6254,7 @@ class nl {
6252
6254
  la(this.canvas, this.gl, this.camera), this.requestRender();
6253
6255
  }
6254
6256
  onWebGlContextLost(e) {
6255
- const n = Xa({
6257
+ const n = Ya({
6256
6258
  event: e,
6257
6259
  destroyed: this.destroyed,
6258
6260
  contextLost: this.contextLost,
@@ -6266,10 +6268,10 @@ class nl {
6266
6268
  n.handled && (this.frame = n.frame, this.contextLost = !0, this.pointBuffersDirty = !0);
6267
6269
  }
6268
6270
  onWebGlContextRestored(e) {
6269
- this.destroyed || (this.contextLost = !1, this.cache.clear(), this.tileProgram = Tr(this.gl), this.pointProgram = Ir(this.gl), this.pointBuffersDirty = !0, this.lastPointPalette && this.lastPointPalette.length > 0 && this.setPointPalette(this.lastPointPalette), this.lastPointData ? this.setPointData(this.lastPointData) : this.pointCount = 0, this.resize(), this.onContextRestored?.());
6271
+ this.destroyed || (this.contextLost = !1, this.cache.clear(), this.tileProgram = Ir(this.gl), this.pointProgram = Tr(this.gl), this.pointBuffersDirty = !0, this.lastPointPalette && this.lastPointPalette.length > 0 && this.setPointPalette(this.lastPointPalette), this.lastPointData ? this.setPointData(this.lastPointData) : this.pointCount = 0, this.resize(), this.onContextRestored?.());
6270
6272
  }
6271
6273
  destroy() {
6272
- const e = Wa({
6274
+ const e = Xa({
6273
6275
  destroyed: this.destroyed,
6274
6276
  frame: this.frame,
6275
6277
  cancelViewAnimation: () => this.cancelViewAnimation(),
@@ -6286,8 +6288,8 @@ class nl {
6286
6288
  e.didDestroy && (this.destroyed = !0, this.frame = e.frame);
6287
6289
  }
6288
6290
  }
6289
- const rl = [];
6290
- function Nl({
6291
+ const nl = [];
6292
+ function Ll({
6291
6293
  source: t,
6292
6294
  viewState: e,
6293
6295
  onViewStateChange: n,
@@ -6312,7 +6314,7 @@ function Nl({
6312
6314
  style: E,
6313
6315
  children: P
6314
6316
  }) {
6315
- const O = J(null), k = J(null), q = J(null), z = J(null), H = J(null), ot = J(null), T = J(rl), Z = J(!1), N = J(/* @__PURE__ */ new Set()), L = J(n), $ = J(r), At = J(i), ct = J(o), Rt = J(s), [Ct, vt] = ne(0), [v, M] = ne(null), W = J(b);
6317
+ const O = J(null), k = J(null), q = J(null), z = J(null), H = J(null), ot = J(null), I = J(nl), Z = J(!1), N = J(/* @__PURE__ */ new Set()), L = J(n), $ = J(r), At = J(i), ct = J(o), Rt = J(s), [Ct, vt] = ne(0), [v, M] = ne(null), W = J(b);
6316
6318
  D(() => {
6317
6319
  L.current = n;
6318
6320
  }, [n]), D(() => {
@@ -6366,7 +6368,7 @@ function Nl({
6366
6368
  (C.width !== F || C.height !== j) && (C.width = F, C.height = j);
6367
6369
  const ht = at.width, it = at.height;
6368
6370
  Y.setTransform(1, 0, 0, 1, 0, 0), Y.clearRect(0, 0, C.width, C.height), Y.setTransform(et, 0, 0, et, 0, 0);
6369
- const dt = T.current;
6371
+ const dt = I.current;
6370
6372
  for (let Ot = 0; Ot < dt.length; Ot += 1)
6371
6373
  Y.save(), dt[Ot].draw(Y, ht, it), Y.restore();
6372
6374
  }, []), K = V(() => {
@@ -6375,13 +6377,13 @@ function Nl({
6375
6377
  }));
6376
6378
  }, [yt]), bt = V(
6377
6379
  (C, Y, et) => {
6378
- const at = T.current.filter((F) => F.id !== C);
6379
- at.push({ id: C, priority: Y, draw: et }), at.sort((F, j) => F.priority - j.priority), T.current = at, K();
6380
+ const at = I.current.filter((F) => F.id !== C);
6381
+ at.push({ id: C, priority: Y, draw: et }), at.sort((F, j) => F.priority - j.priority), I.current = at, K();
6380
6382
  },
6381
6383
  [K]
6382
6384
  ), xt = V(
6383
6385
  (C) => {
6384
- T.current = T.current.filter((Y) => Y.id !== C), K();
6386
+ I.current = I.current.filter((Y) => Y.id !== C), K();
6385
6387
  },
6386
6388
  [K]
6387
6389
  ), U = V((C, Y) => {
@@ -6405,7 +6407,7 @@ function Nl({
6405
6407
  D(() => {
6406
6408
  const C = k.current;
6407
6409
  if (!C || !t) return;
6408
- const Y = new nl(C, t, {
6410
+ const Y = new el(C, t, {
6409
6411
  onViewStateChange: rt,
6410
6412
  onStats: st,
6411
6413
  onTileError: (et) => {
@@ -6477,7 +6479,7 @@ function Nl({
6477
6479
  D(() => {
6478
6480
  ut.current = y;
6479
6481
  }, [y]);
6480
- const Tt = V(
6482
+ const It = V(
6481
6483
  (C) => {
6482
6484
  const Y = ut.current;
6483
6485
  if (!Y) return;
@@ -6494,7 +6496,7 @@ function Nl({
6494
6496
  ref: O,
6495
6497
  className: x,
6496
6498
  style: ft,
6497
- onPointerMove: y ? Tt : void 0,
6499
+ onPointerMove: y ? It : void 0,
6498
6500
  onPointerLeave: y ? Et : void 0,
6499
6501
  children: [
6500
6502
  /* @__PURE__ */ qt(
@@ -6536,7 +6538,7 @@ function Nl({
6536
6538
  }
6537
6539
  ) });
6538
6540
  }
6539
- function il(t) {
6541
+ function rl(t) {
6540
6542
  const e = [];
6541
6543
  for (let n = 0; n < t.length; n += 1) {
6542
6544
  const r = t[n], i = ye([Ge(r?.coordinates)]);
@@ -6557,20 +6559,20 @@ function il(t) {
6557
6559
  }
6558
6560
  return e;
6559
6561
  }
6560
- const ol = 128, on = [];
6562
+ const il = 128, on = [];
6561
6563
  function ae(t, e, n, r, i) {
6562
6564
  if (i <= 1 || n <= e) return 0;
6563
6565
  const o = (t - e) / r;
6564
6566
  return !Number.isFinite(o) || o <= 0 ? 0 : o >= i - 1 ? i - 1 : Math.floor(o);
6565
6567
  }
6566
- function sl(t) {
6568
+ function ol(t) {
6567
6569
  if (t.length === 0) return null;
6568
6570
  let e = 1 / 0, n = 1 / 0, r = -1 / 0, i = -1 / 0;
6569
6571
  for (const h of t)
6570
6572
  h.minX < e && (e = h.minX), h.minY < n && (n = h.minY), h.maxX > r && (r = h.maxX), h.maxY > i && (i = h.maxY);
6571
6573
  if (!Number.isFinite(e) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i))
6572
6574
  return null;
6573
- const o = Math.ceil(Math.sqrt(t.length * 2)), s = Math.max(1, Math.min(ol, o)), a = r > e ? (r - e) / s : 1, c = i > n ? (i - n) / s : 1, u = Array.from({ length: s * s }, () => []);
6575
+ const o = Math.ceil(Math.sqrt(t.length * 2)), s = Math.max(1, Math.min(il, o)), a = r > e ? (r - e) / s : 1, c = i > n ? (i - n) / s : 1, u = Array.from({ length: s * s }, () => []);
6574
6576
  for (let h = 0; h < t.length; h += 1) {
6575
6577
  const l = t[h], f = ae(l.minX, e, r, a, s), d = ae(l.maxX, e, r, a, s), m = ae(l.minY, n, i, c, s), g = ae(l.maxY, n, i, c, s);
6576
6578
  for (let p = m; p <= g; p += 1)
@@ -6588,13 +6590,13 @@ function sl(t) {
6588
6590
  buckets: u
6589
6591
  };
6590
6592
  }
6591
- function al(t, e, n) {
6593
+ function sl(t, e, n) {
6592
6594
  if (!t || e < t.minX || e > t.maxX || n < t.minY || n > t.maxY)
6593
6595
  return on;
6594
6596
  const r = ae(e, t.minX, t.maxX, t.cellWidth, t.gridSize), i = ae(n, t.minY, t.maxY, t.cellHeight, t.gridSize);
6595
6597
  return t.buckets[i * t.gridSize + r] ?? on;
6596
6598
  }
6597
- function ll(t, e) {
6599
+ function al(t, e) {
6598
6600
  if (Array.isArray(e)) {
6599
6601
  const n = e[t];
6600
6602
  if (typeof n == "string" && n.length > 0) return n;
@@ -6605,7 +6607,7 @@ function ll(t, e) {
6605
6607
  }
6606
6608
  return String(t);
6607
6609
  }
6608
- function Bl(t, e, n = {}) {
6610
+ function Nl(t, e, n = {}) {
6609
6611
  const r = Math.max(
6610
6612
  0,
6611
6613
  Math.min(
@@ -6634,7 +6636,7 @@ function Bl(t, e, n = {}) {
6634
6636
  } else
6635
6637
  i = new Uint32Array(0);
6636
6638
  }
6637
- const o = i ? i.length : r, s = il(e ?? []);
6639
+ const o = i ? i.length : r, s = rl(e ?? []);
6638
6640
  if (!t || o === 0 || s.length === 0)
6639
6641
  return {
6640
6642
  groups: [],
@@ -6642,13 +6644,13 @@ function Bl(t, e, n = {}) {
6642
6644
  pointsInsideAnyRegion: 0,
6643
6645
  unmatchedPointCount: o
6644
6646
  };
6645
- const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = sl(s);
6647
+ const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = ol(s);
6646
6648
  let h = 0;
6647
6649
  for (let d = 0; d < o; d += 1) {
6648
6650
  const m = i ? i[d] : d, g = t.positions[m * 2], p = t.positions[m * 2 + 1];
6649
6651
  if (!Number.isFinite(g) || !Number.isFinite(p)) continue;
6650
6652
  let y = null;
6651
- const b = al(u, g, p);
6653
+ const b = sl(u, g, p);
6652
6654
  if (b.length === 0) continue;
6653
6655
  for (const E of b) {
6654
6656
  const P = s[E];
@@ -6670,7 +6672,7 @@ function Bl(t, e, n = {}) {
6670
6672
  const m = c.get(d.regionIndex) ?? 0;
6671
6673
  if (!l && m <= 0) continue;
6672
6674
  const g = a.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), p = Array.from(g.entries()).map(([y, b]) => ({
6673
- termId: ll(y, n.paletteIndexToTermId),
6675
+ termId: al(y, n.paletteIndexToTermId),
6674
6676
  paletteIndex: y,
6675
6677
  count: b
6676
6678
  })).sort((y, b) => b.count - y.count || y.paletteIndex - b.paletteIndex);
@@ -6694,7 +6696,7 @@ function Lr(t, e, n, r) {
6694
6696
  function Nr(t, e) {
6695
6697
  return !(t[2] < e[0] || t[0] > e[2] || t[3] < e[1] || t[1] > e[3]);
6696
6698
  }
6697
- class cl {
6699
+ class ll {
6698
6700
  constructor(e = 16) {
6699
6701
  A(this, "targetNodeSize");
6700
6702
  A(this, "items", []);
@@ -6778,26 +6780,26 @@ class cl {
6778
6780
  return !Number.isFinite(i) || i <= 0 ? 0 : i >= this.gridSize - 1 ? this.gridSize - 1 : Math.max(0, Math.min(this.gridSize - 1, Math.floor(i)));
6779
6781
  }
6780
6782
  }
6781
- function kl(t) {
6782
- return new cl(t);
6783
+ function Bl(t) {
6784
+ return new ll(t);
6783
6785
  }
6784
- function ul(t) {
6786
+ function cl(t) {
6785
6787
  return t.replace(/^\s*SRID\s*=\s*\d+\s*;\s*/i, "");
6786
6788
  }
6787
- function fl(t) {
6789
+ function ul(t) {
6788
6790
  return t >= "A" && t <= "Z" || t >= "a" && t <= "z";
6789
6791
  }
6790
- function hl(t) {
6792
+ function fl(t) {
6791
6793
  return t >= "0" && t <= "9";
6792
6794
  }
6793
6795
  function Br(t) {
6794
- return t === "+" || t === "-" || t === "." || hl(t);
6796
+ return t === "+" || t === "-" || t === "." || fl(t);
6795
6797
  }
6796
- class dl {
6798
+ class hl {
6797
6799
  constructor(e) {
6798
6800
  A(this, "text");
6799
6801
  A(this, "index", 0);
6800
- this.text = ul(e.trim());
6802
+ this.text = cl(e.trim());
6801
6803
  }
6802
6804
  parse() {
6803
6805
  if (!this.text) return null;
@@ -6828,7 +6830,7 @@ class dl {
6828
6830
  coordinates: s
6829
6831
  } : null;
6830
6832
  }
6831
- const o = gl(i);
6833
+ const o = ml(i);
6832
6834
  return o ? {
6833
6835
  type: "MultiPolygon",
6834
6836
  coordinates: o
@@ -6847,7 +6849,7 @@ class dl {
6847
6849
  readWord() {
6848
6850
  if (this.skipWhitespace(), this.isEof()) return null;
6849
6851
  const e = this.index;
6850
- for (; !this.isEof() && fl(this.currentChar()); )
6852
+ for (; !this.isEof() && ul(this.currentChar()); )
6851
6853
  this.index += 1;
6852
6854
  return this.index === e ? null : this.text.slice(e, this.index);
6853
6855
  }
@@ -6906,7 +6908,7 @@ class dl {
6906
6908
  return Number.isFinite(r) ? (this.index += n[0].length, r) : null;
6907
6909
  }
6908
6910
  }
6909
- function ml(t) {
6911
+ function dl(t) {
6910
6912
  return Array.isArray(t) && t.length >= 2 && typeof t[0] == "number" && Number.isFinite(t[0]) && typeof t[1] == "number" && Number.isFinite(t[1]);
6911
6913
  }
6912
6914
  function ui(t) {
@@ -6916,14 +6918,14 @@ function ui(t) {
6916
6918
  if (!Array.isArray(n)) return null;
6917
6919
  const r = [];
6918
6920
  for (const i of n) {
6919
- if (!ml(i)) return null;
6921
+ if (!dl(i)) return null;
6920
6922
  r.push([i[0], i[1]]);
6921
6923
  }
6922
6924
  e.push(r);
6923
6925
  }
6924
6926
  return e;
6925
6927
  }
6926
- function gl(t) {
6928
+ function ml(t) {
6927
6929
  if (!Array.isArray(t)) return null;
6928
6930
  const e = [];
6929
6931
  for (const n of t) {
@@ -6933,48 +6935,48 @@ function gl(t) {
6933
6935
  }
6934
6936
  return e;
6935
6937
  }
6936
- function zl(t) {
6937
- return typeof t != "string" ? null : new dl(t).parse();
6938
+ function kl(t) {
6939
+ return typeof t != "string" ? null : new hl(t).parse();
6938
6940
  }
6939
6941
  export {
6940
6942
  Wr as DEFAULT_POINT_COLOR,
6941
6943
  ms as DrawLayer,
6942
- Al as DrawingLayer,
6944
+ Sl as DrawingLayer,
6943
6945
  Ai as M1TileRenderer,
6944
- vl as OverlayLayer,
6945
- Ml as OverviewMap,
6946
- Rl as PatchLayer,
6947
- _l as PointLayer,
6948
- Fl as RegionLayer,
6946
+ Al as OverlayLayer,
6947
+ El as OverviewMap,
6948
+ Ml as PatchLayer,
6949
+ Cl as PointLayer,
6950
+ _l as RegionLayer,
6949
6951
  oa as TileScheduler,
6950
- Ll as TileViewerCanvas,
6951
- nl as WsiTileRenderer,
6952
- Nl as WsiViewer,
6952
+ Fl as TileViewerCanvas,
6953
+ el as WsiTileRenderer,
6954
+ Ll as WsiViewer,
6953
6955
  Ws as buildPointSpatialIndexAsync,
6954
- Sl as buildTermPalette,
6955
- bl as calcScaleLength,
6956
+ xl as buildTermPalette,
6957
+ wl as calcScaleLength,
6956
6958
  Vr as calcScaleResolution,
6957
6959
  X as clamp,
6958
6960
  zt as closeRing,
6959
- Bl as computeRoiPointGroups,
6961
+ Nl as computeRoiPointGroups,
6960
6962
  or as createCircle,
6961
6963
  hn as createRectangle,
6962
- kl as createSpatialIndex,
6964
+ Bl as createSpatialIndex,
6963
6965
  We as filterPointDataByPolygons,
6964
6966
  Cs as filterPointDataByPolygonsHybrid,
6965
6967
  _s as filterPointDataByPolygonsInWorker,
6966
6968
  Ss as filterPointIndicesByPolygons,
6967
- Pl as filterPointIndicesByPolygonsInWorker,
6968
- Tl as getWebGpuCapabilities,
6969
+ Tl as filterPointIndicesByPolygonsInWorker,
6970
+ Rl as getWebGpuCapabilities,
6969
6971
  Qi as hexToRgba,
6970
6972
  qn as isSameViewState,
6971
6973
  Os as lookupCellIndex,
6972
- El as normalizeImageInfo,
6973
- zl as parseWkt,
6974
+ vl as normalizeImageInfo,
6975
+ kl as parseWkt,
6974
6976
  Ps as prefilterPointsByBoundsWebGpu,
6975
- Cl as terminatePointHitIndexWorker,
6977
+ Pl as terminatePointHitIndexWorker,
6976
6978
  Il as terminateRoiClipWorker,
6977
- xl as toBearerToken,
6979
+ bl as toBearerToken,
6978
6980
  Ge as toRoiGeometry,
6979
6981
  ri as toTileUrl,
6980
6982
  we as useViewerContext