@idetik/core 0.45.5 → 0.46.1

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,4 +1,4 @@
1
- class MC {
1
+ class dC {
2
2
  canvas_;
3
3
  width_ = 0;
4
4
  height_ = 0;
@@ -87,7 +87,7 @@ void main() {
87
87
 
88
88
 
89
89
  gl_PointSize = 5.0;
90
- }`, KC = `#version 300 es
90
+ }`, MC = `#version 300 es
91
91
 
92
92
  precision mediump float;
93
93
 
@@ -159,7 +159,7 @@ void main() {
159
159
  gl_PointSize = a_size;
160
160
  v_color = a_color;
161
161
  v_marker = uint(a_marker);
162
- }`, HC = `#version 300 es
162
+ }`, KC = `#version 300 es
163
163
 
164
164
  precision mediump float;
165
165
 
@@ -179,7 +179,7 @@ void main() {
179
179
  discard;
180
180
  }
181
181
  fragColor = vec4(v_color.rgb, u_opacity * alpha * v_color.a);
182
- }`, qC = `#version 300 es
182
+ }`, HC = `#version 300 es
183
183
 
184
184
  layout (location = 0) in vec3 a_position;
185
185
  layout (location = 1) in vec3 a_normal;
@@ -189,7 +189,7 @@ uniform mat4 u_modelView;
189
189
 
190
190
  void main() {
191
191
  gl_Position = u_projection * u_modelView * vec4(a_position, 1.0);
192
- }`, lC = `#version 300 es
192
+ }`, qC = `#version 300 es
193
193
 
194
194
  precision mediump float;
195
195
 
@@ -477,7 +477,7 @@ void main() {
477
477
  fragColor = vec4(color.rgb, alpha);
478
478
  }`, _g = `#version 300 es
479
479
 
480
- void main() {}`, fC = `#version 300 es
480
+ void main() {}`, lC = `#version 300 es
481
481
 
482
482
  precision mediump float;
483
483
 
@@ -490,18 +490,18 @@ void main() {
490
490
  discard;
491
491
  }
492
492
  }`;
493
- const pC = {
493
+ const fC = {
494
494
  projectedLine: {
495
495
  vertex: Xg,
496
- fragment: KC
496
+ fragment: MC
497
497
  },
498
498
  points: {
499
499
  vertex: jg,
500
- fragment: HC
500
+ fragment: KC
501
501
  },
502
502
  wireframe: {
503
- vertex: qC,
504
- fragment: lC
503
+ vertex: HC,
504
+ fragment: qC
505
505
  },
506
506
  floatScalarImage: {
507
507
  vertex: UA,
@@ -546,7 +546,7 @@ const pC = {
546
546
  },
547
547
  pointsDepth: {
548
548
  vertex: jg,
549
- fragment: fC
549
+ fragment: lC
550
550
  },
551
551
  projectedLineDepth: {
552
552
  vertex: Xg,
@@ -557,7 +557,7 @@ const pC = {
557
557
  info: 20,
558
558
  warn: 30,
559
559
  error: 40
560
- }, uC = {
560
+ }, pC = {
561
561
  debug: "\x1B[90m",
562
562
  // gray
563
563
  info: "\x1B[36m",
@@ -567,7 +567,7 @@ const pC = {
567
567
  error: "\x1B[31m"
568
568
  // red
569
569
  };
570
- function mC() {
570
+ function uC() {
571
571
  const g = typeof process < "u" && typeof process.env?.NODE_ENV == "string" ? process.env.NODE_ENV : void 0;
572
572
  if (g === "production" || g === "development" || g === "test")
573
573
  return g;
@@ -579,7 +579,7 @@ function mC() {
579
579
  return "development";
580
580
  }
581
581
  class k {
582
- static logLevel_ = mC() === "production" ? "warn" : "debug";
582
+ static logLevel_ = uC() === "production" ? "warn" : "debug";
583
583
  static setLogLevel(A) {
584
584
  k.logLevel_ = A;
585
585
  }
@@ -597,7 +597,7 @@ class k {
597
597
  }
598
598
  static log(A, I, B, ...C) {
599
599
  if ($g[A] < $g[k.logLevel_]) return;
600
- const Q = (/* @__PURE__ */ new Date()).toISOString(), E = uC[A], i = `[${Q}][${A.toUpperCase()}][${I}]`, o = [`${E}${i}`, B, ...C];
600
+ const Q = (/* @__PURE__ */ new Date()).toISOString(), E = pC[A], i = `[${Q}][${A.toUpperCase()}][${I}]`, o = [`${E}${i}`, B, ...C];
601
601
  switch (A) {
602
602
  case "debug":
603
603
  console.debug(...o);
@@ -614,7 +614,7 @@ class k {
614
614
  }
615
615
  }
616
616
  }
617
- class TC {
617
+ class mC {
618
618
  gl_;
619
619
  program_;
620
620
  uniformInfo_ = /* @__PURE__ */ new Map();
@@ -696,7 +696,7 @@ class TC {
696
696
  for (let I = 0; I < A; I++) {
697
697
  const B = this.gl_.getActiveUniform(this.program_, I);
698
698
  if (B) {
699
- if (!WC.has(B.type))
699
+ if (!xC.has(B.type))
700
700
  throw new Error(
701
701
  `Unsupported uniform type "${B.type}" (GLenum) found in shader program for uniform "${B.name}"`
702
702
  );
@@ -737,7 +737,7 @@ class TC {
737
737
  return Array.from(this.uniformInfo_.keys());
738
738
  }
739
739
  }
740
- const xC = typeof window < "u" ? [
740
+ const TC = typeof window < "u" ? [
741
741
  WebGL2RenderingContext.BOOL,
742
742
  WebGL2RenderingContext.FLOAT,
743
743
  WebGL2RenderingContext.INT,
@@ -762,10 +762,10 @@ const xC = typeof window < "u" ? [
762
762
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_3D,
763
763
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_CUBE,
764
764
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_2D_ARRAY
765
- ] : [], WC = new Set(
766
- xC
765
+ ] : [], xC = new Set(
766
+ TC
767
767
  ), uI = "#pragma inject_defines";
768
- class bC {
768
+ class WC {
769
769
  gl_;
770
770
  programs_ = /* @__PURE__ */ new Map();
771
771
  constructor(A) {
@@ -774,14 +774,14 @@ class bC {
774
774
  use(A) {
775
775
  let I = this.programs_.get(A);
776
776
  if (I === void 0) {
777
- const B = pC[A], C = AB(
777
+ const B = fC[A], C = AB(
778
778
  B.vertex,
779
779
  B.vertexDefines
780
780
  ), Q = AB(
781
781
  B.fragment,
782
782
  B.fragmentDefines
783
783
  );
784
- I = new TC(
784
+ I = new mC(
785
785
  this.gl_,
786
786
  C,
787
787
  Q
@@ -814,18 +814,18 @@ function _B(g) {
814
814
  class YI {
815
815
  id = _B();
816
816
  }
817
- var m = 1e-6, j = typeof Float32Array < "u" ? Float32Array : Array, ZC = Math.PI / 180;
818
- function PC(g) {
819
- return g * ZC;
817
+ var m = 1e-6, j = typeof Float32Array < "u" ? Float32Array : Array, bC = Math.PI / 180;
818
+ function ZC(g) {
819
+ return g * bC;
820
820
  }
821
821
  function $B() {
822
822
  var g = new j(9);
823
823
  return j != Float32Array && (g[1] = 0, g[2] = 0, g[3] = 0, g[5] = 0, g[6] = 0, g[7] = 0), g[0] = 1, g[4] = 1, g[8] = 1, g;
824
824
  }
825
- function OC(g, A) {
825
+ function PC(g, A) {
826
826
  return g[0] = A[0], g[1] = A[1], g[2] = A[2], g[3] = A[4], g[4] = A[5], g[5] = A[6], g[6] = A[8], g[7] = A[9], g[8] = A[10], g;
827
827
  }
828
- function VC(g, A, I, B, C, Q, E, i, o) {
828
+ function OC(g, A, I, B, C, Q, E, i, o) {
829
829
  var a = new j(9);
830
830
  return a[0] = g, a[1] = A, a[2] = I, a[3] = B, a[4] = C, a[5] = Q, a[6] = E, a[7] = i, a[8] = o, a;
831
831
  }
@@ -841,18 +841,18 @@ function QI(g, A, I) {
841
841
  var B = A[0], C = A[1], Q = A[2], E = A[3], i = A[4], o = A[5], a = A[6], s = A[7], D = A[8], h = A[9], t = A[10], e = A[11], n = A[12], F = A[13], G = A[14], L = A[15], N = I[0], S = I[1], r = I[2], U = I[3];
842
842
  return g[0] = N * B + S * i + r * D + U * n, g[1] = N * C + S * o + r * h + U * F, g[2] = N * Q + S * a + r * t + U * G, g[3] = N * E + S * s + r * e + U * L, N = I[4], S = I[5], r = I[6], U = I[7], g[4] = N * B + S * i + r * D + U * n, g[5] = N * C + S * o + r * h + U * F, g[6] = N * Q + S * a + r * t + U * G, g[7] = N * E + S * s + r * e + U * L, N = I[8], S = I[9], r = I[10], U = I[11], g[8] = N * B + S * i + r * D + U * n, g[9] = N * C + S * o + r * h + U * F, g[10] = N * Q + S * a + r * t + U * G, g[11] = N * E + S * s + r * e + U * L, N = I[12], S = I[13], r = I[14], U = I[15], g[12] = N * B + S * i + r * D + U * n, g[13] = N * C + S * o + r * h + U * F, g[14] = N * Q + S * a + r * t + U * G, g[15] = N * E + S * s + r * e + U * L, g;
843
843
  }
844
- function vC(g, A, I) {
844
+ function VC(g, A, I) {
845
845
  var B = I[0], C = I[1], Q = I[2], E, i, o, a, s, D, h, t, e, n, F, G;
846
846
  return A === g ? (g[12] = A[0] * B + A[4] * C + A[8] * Q + A[12], g[13] = A[1] * B + A[5] * C + A[9] * Q + A[13], g[14] = A[2] * B + A[6] * C + A[10] * Q + A[14], g[15] = A[3] * B + A[7] * C + A[11] * Q + A[15]) : (E = A[0], i = A[1], o = A[2], a = A[3], s = A[4], D = A[5], h = A[6], t = A[7], e = A[8], n = A[9], F = A[10], G = A[11], g[0] = E, g[1] = i, g[2] = o, g[3] = a, g[4] = s, g[5] = D, g[6] = h, g[7] = t, g[8] = e, g[9] = n, g[10] = F, g[11] = G, g[12] = E * B + s * C + e * Q + A[12], g[13] = i * B + D * C + n * Q + A[13], g[14] = o * B + h * C + F * Q + A[14], g[15] = a * B + t * C + G * Q + A[15]), g;
847
847
  }
848
848
  function AC(g, A) {
849
849
  return g[0] = A[0], g[1] = 0, g[2] = 0, g[3] = 0, g[4] = 0, g[5] = A[1], g[6] = 0, g[7] = 0, g[8] = 0, g[9] = 0, g[10] = A[2], g[11] = 0, g[12] = 0, g[13] = 0, g[14] = 0, g[15] = 1, g;
850
850
  }
851
- function XC(g, A, I, B) {
851
+ function vC(g, A, I, B) {
852
852
  var C = A[0], Q = A[1], E = A[2], i = A[3], o = C + C, a = Q + Q, s = E + E, D = C * o, h = C * a, t = C * s, e = Q * a, n = Q * s, F = E * s, G = i * o, L = i * a, N = i * s, S = B[0], r = B[1], U = B[2];
853
853
  return g[0] = (1 - (e + F)) * S, g[1] = (h + N) * S, g[2] = (t - L) * S, g[3] = 0, g[4] = (h - N) * r, g[5] = (1 - (D + F)) * r, g[6] = (n + G) * r, g[7] = 0, g[8] = (t + L) * U, g[9] = (n - G) * U, g[10] = (1 - (D + e)) * U, g[11] = 0, g[12] = I[0], g[13] = I[1], g[14] = I[2], g[15] = 1, g;
854
854
  }
855
- function jC(g, A, I, B, C) {
855
+ function XC(g, A, I, B, C) {
856
856
  var Q = 1 / Math.tan(A / 2);
857
857
  if (g[0] = Q / I, g[1] = 0, g[2] = 0, g[3] = 0, g[4] = 0, g[5] = Q, g[6] = 0, g[7] = 0, g[8] = 0, g[9] = 0, g[11] = -1, g[12] = 0, g[13] = 0, g[15] = 0, C != null && C !== 1 / 0) {
858
858
  var E = 1 / (B - C);
@@ -861,19 +861,19 @@ function jC(g, A, I, B, C) {
861
861
  g[10] = -1, g[14] = -2 * B;
862
862
  return g;
863
863
  }
864
- var zC = jC;
865
- function _C(g, A, I, B, C, Q, E) {
864
+ var jC = XC;
865
+ function zC(g, A, I, B, C, Q, E) {
866
866
  var i = 1 / (A - I), o = 1 / (B - C), a = 1 / (Q - E);
867
867
  return g[0] = -2 * i, g[1] = 0, g[2] = 0, g[3] = 0, g[4] = 0, g[5] = -2 * o, g[6] = 0, g[7] = 0, g[8] = 0, g[9] = 0, g[10] = 2 * a, g[11] = 0, g[12] = (A + I) * i, g[13] = (C + B) * o, g[14] = (E + Q) * a, g[15] = 1, g;
868
868
  }
869
- var $C = _C;
870
- function AQ(g, A, I, B) {
869
+ var _C = zC;
870
+ function $C(g, A, I, B) {
871
871
  var C = A[0], Q = A[1], E = A[2], i = B[0], o = B[1], a = B[2], s = C - I[0], D = Q - I[1], h = E - I[2], t = s * s + D * D + h * h;
872
872
  t > 0 && (t = 1 / Math.sqrt(t), s *= t, D *= t, h *= t);
873
873
  var e = o * h - a * D, n = a * s - i * h, F = i * D - o * s;
874
874
  return t = e * e + n * n + F * F, t > 0 && (t = 1 / Math.sqrt(t), e *= t, n *= t, F *= t), g[0] = e, g[1] = n, g[2] = F, g[3] = 0, g[4] = D * F - h * n, g[5] = h * e - s * F, g[6] = s * n - D * e, g[7] = 0, g[8] = s, g[9] = D, g[10] = h, g[11] = 0, g[12] = C, g[13] = Q, g[14] = E, g[15] = 1, g;
875
875
  }
876
- function IQ(g, A) {
876
+ function AQ(g, A) {
877
877
  var I = g[0], B = g[1], C = g[2], Q = g[3], E = g[4], i = g[5], o = g[6], a = g[7], s = g[8], D = g[9], h = g[10], t = g[11], e = g[12], n = g[13], F = g[14], G = g[15], L = A[0], N = A[1], S = A[2], r = A[3], U = A[4], l = A[5], Z = A[6], O = A[7], b = A[8], z = A[9], oA = A[10], aA = A[11], P = A[12], Og = A[13], Vg = A[14], vg = A[15];
878
878
  return Math.abs(I - L) <= m * Math.max(1, Math.abs(I), Math.abs(L)) && Math.abs(B - N) <= m * Math.max(1, Math.abs(B), Math.abs(N)) && Math.abs(C - S) <= m * Math.max(1, Math.abs(C), Math.abs(S)) && Math.abs(Q - r) <= m * Math.max(1, Math.abs(Q), Math.abs(r)) && Math.abs(E - U) <= m * Math.max(1, Math.abs(E), Math.abs(U)) && Math.abs(i - l) <= m * Math.max(1, Math.abs(i), Math.abs(l)) && Math.abs(o - Z) <= m * Math.max(1, Math.abs(o), Math.abs(Z)) && Math.abs(a - O) <= m * Math.max(1, Math.abs(a), Math.abs(O)) && Math.abs(s - b) <= m * Math.max(1, Math.abs(s), Math.abs(b)) && Math.abs(D - z) <= m * Math.max(1, Math.abs(D), Math.abs(z)) && Math.abs(h - oA) <= m * Math.max(1, Math.abs(h), Math.abs(oA)) && Math.abs(t - aA) <= m * Math.max(1, Math.abs(t), Math.abs(aA)) && Math.abs(e - P) <= m * Math.max(1, Math.abs(e), Math.abs(P)) && Math.abs(n - Og) <= m * Math.max(1, Math.abs(n), Math.abs(Og)) && Math.abs(F - Vg) <= m * Math.max(1, Math.abs(F), Math.abs(Vg)) && Math.abs(G - vg) <= m * Math.max(1, Math.abs(G), Math.abs(vg));
879
879
  }
@@ -905,7 +905,7 @@ function aI(g, A, I) {
905
905
  function Gg(g, A, I) {
906
906
  return g[0] = A[0] - I[0], g[1] = A[1] - I[1], g[2] = A[2] - I[2], g;
907
907
  }
908
- function gQ(g, A, I) {
908
+ function IQ(g, A, I) {
909
909
  return g[0] = A[0] * I[0], g[1] = A[1] * I[1], g[2] = A[2] * I[2], g;
910
910
  }
911
911
  function $I(g, A, I) {
@@ -914,7 +914,7 @@ function $I(g, A, I) {
914
914
  function Ag(g, A, I, B) {
915
915
  return g[0] = A[0] + I[0] * B, g[1] = A[1] + I[1] * B, g[2] = A[2] + I[2] * B, g;
916
916
  }
917
- function BQ(g, A) {
917
+ function gQ(g, A) {
918
918
  var I = A[0] - g[0], B = A[1] - g[1], C = A[2] - g[2];
919
919
  return I * I + B * B + C * C;
920
920
  }
@@ -937,14 +937,14 @@ function gC(g, A, I) {
937
937
  var B = I[0], C = I[1], Q = I[2], E = I[3], i = A[0], o = A[1], a = A[2], s = C * a - Q * o, D = Q * i - B * a, h = B * o - C * i;
938
938
  return s = s + s, D = D + D, h = h + h, g[0] = i + E * s + C * h - Q * D, g[1] = o + E * D + Q * s - B * h, g[2] = a + E * h + B * D - C * s, g;
939
939
  }
940
- function CQ(g) {
940
+ function BQ(g) {
941
941
  return g[0] = 0, g[1] = 0, g[2] = 0, g;
942
942
  }
943
943
  function Fg(g, A) {
944
944
  var I = g[0], B = g[1], C = g[2], Q = A[0], E = A[1], i = A[2];
945
945
  return Math.abs(I - Q) <= m * Math.max(1, Math.abs(I), Math.abs(Q)) && Math.abs(B - E) <= m * Math.max(1, Math.abs(B), Math.abs(E)) && Math.abs(C - i) <= m * Math.max(1, Math.abs(C), Math.abs(i));
946
946
  }
947
- var Ig = Gg, QQ = ng;
947
+ var Ig = Gg, CQ = ng;
948
948
  (function() {
949
949
  var g = M();
950
950
  return function(A, I, B, C, Q, E) {
@@ -958,7 +958,7 @@ function JA() {
958
958
  var g = new j(4);
959
959
  return j != Float32Array && (g[0] = 0, g[1] = 0, g[2] = 0, g[3] = 0), g;
960
960
  }
961
- function EQ(g) {
961
+ function QQ(g) {
962
962
  var A = new j(4);
963
963
  return A[0] = g[0], A[1] = g[1], A[2] = g[2], A[3] = g[3], A;
964
964
  }
@@ -966,13 +966,13 @@ function DI(g, A, I, B) {
966
966
  var C = new j(4);
967
967
  return C[0] = g, C[1] = A, C[2] = I, C[3] = B, C;
968
968
  }
969
- function iQ(g, A) {
969
+ function EQ(g, A) {
970
970
  return g[0] = A[0], g[1] = A[1], g[2] = A[2], g[3] = A[3], g;
971
971
  }
972
- function oQ(g, A, I) {
972
+ function iQ(g, A, I) {
973
973
  return g[0] = A[0] * I, g[1] = A[1] * I, g[2] = A[2] * I, g[3] = A[3] * I, g;
974
974
  }
975
- function aQ(g, A) {
975
+ function oQ(g, A) {
976
976
  var I = A[0], B = A[1], C = A[2], Q = A[3], E = I * I + B * B + C * C + Q * Q;
977
977
  return E > 0 && (E = 1 / Math.sqrt(E)), g[0] = I * E, g[1] = B * E, g[2] = C * E, g[3] = Q * E, g;
978
978
  }
@@ -993,12 +993,12 @@ function hI() {
993
993
  var g = new j(4);
994
994
  return j != Float32Array && (g[0] = 0, g[1] = 0, g[2] = 0), g[3] = 1, g;
995
995
  }
996
- function sQ(g, A, I) {
996
+ function aQ(g, A, I) {
997
997
  I = I * 0.5;
998
998
  var B = Math.sin(I);
999
999
  return g[0] = B * A[0], g[1] = B * A[1], g[2] = B * A[2], g[3] = Math.cos(I), g;
1000
1000
  }
1001
- function DQ(g, A, I) {
1001
+ function sQ(g, A, I) {
1002
1002
  var B = A[0], C = A[1], Q = A[2], E = A[3], i = I[0], o = I[1], a = I[2], s = I[3];
1003
1003
  return g[0] = B * s + E * i + C * a - Q * o, g[1] = C * s + E * o + Q * i - B * a, g[2] = Q * s + E * a + B * o - C * i, g[3] = E * s - B * i - C * o - Q * a, g;
1004
1004
  }
@@ -1018,12 +1018,12 @@ function rg(g, A) {
1018
1018
  }
1019
1019
  return g;
1020
1020
  }
1021
- var hQ = EQ, tQ = iQ, dI = aQ;
1021
+ var DQ = QQ, hQ = EQ, dI = oQ;
1022
1022
  (function() {
1023
1023
  var g = M(), A = x(1, 0, 0), I = x(0, 1, 0);
1024
1024
  return function(B, C, Q) {
1025
1025
  var E = sI(C, Q);
1026
- return E < -0.999999 ? (EI(g, A, C), QQ(g) < 1e-6 && EI(g, I, C), IC(g, g), sQ(B, g, Math.PI), B) : E > 0.999999 ? (B[0] = 0, B[1] = 0, B[2] = 0, B[3] = 1, B) : (EI(g, C, Q), B[0] = g[0], B[1] = g[1], B[2] = g[2], B[3] = 1 + E, dI(B, B));
1026
+ return E < -0.999999 ? (EI(g, A, C), CQ(g) < 1e-6 && EI(g, I, C), IC(g, g), aQ(B, g, Math.PI), B) : E > 0.999999 ? (B[0] = 0, B[1] = 0, B[2] = 0, B[3] = 1, B) : (EI(g, C, Q), B[0] = g[0], B[1] = g[1], B[2] = g[2], B[3] = 1 + E, dI(B, B));
1027
1027
  };
1028
1028
  })();
1029
1029
  (function() {
@@ -1050,15 +1050,15 @@ function v(g, A) {
1050
1050
  var I = new j(2);
1051
1051
  return I[0] = g, I[1] = A, I;
1052
1052
  }
1053
- function yQ(g, A) {
1053
+ function tQ(g, A) {
1054
1054
  var I = A[0] - g[0], B = A[1] - g[1];
1055
1055
  return Math.sqrt(I * I + B * B);
1056
1056
  }
1057
- function eQ(g) {
1057
+ function yQ(g) {
1058
1058
  var A = g[0], I = g[1];
1059
1059
  return A * A + I * I;
1060
1060
  }
1061
- function nQ(g, A, I, B) {
1061
+ function eQ(g, A, I, B) {
1062
1062
  var C = A[0], Q = A[1];
1063
1063
  return g[0] = C + B * (I[0] - C), g[1] = Q + B * (I[1] - Q), g;
1064
1064
  }
@@ -1143,7 +1143,7 @@ class VA {
1143
1143
  wg(Q, E, A), this.expandWithPoint(Q);
1144
1144
  }
1145
1145
  }
1146
- const GQ = {
1146
+ const nQ = {
1147
1147
  position: 0,
1148
1148
  normal: 1,
1149
1149
  uv: 2,
@@ -1207,7 +1207,7 @@ class pA extends YI {
1207
1207
  return this.attributes_.find((I) => I.type === A);
1208
1208
  }
1209
1209
  }
1210
- class wQ {
1210
+ class GQ {
1211
1211
  gl_;
1212
1212
  buffers_ = /* @__PURE__ */ new Map();
1213
1213
  currentGeometry_ = null;
@@ -1243,7 +1243,7 @@ class wQ {
1243
1243
  this.gl_.bindBuffer(C, Q), this.gl_.bufferData(C, B, this.gl_.STATIC_DRAW);
1244
1244
  const { attributes: E, strideBytes: i } = A;
1245
1245
  E.forEach((s) => {
1246
- const D = GQ[s.type];
1246
+ const D = nQ[s.type];
1247
1247
  this.gl_.vertexAttribPointer(
1248
1248
  D,
1249
1249
  s.itemSize,
@@ -1262,7 +1262,7 @@ class wQ {
1262
1262
  this.buffers_.set(A, o), this.gl_.bindVertexArray(null);
1263
1263
  }
1264
1264
  }
1265
- function FQ(g) {
1265
+ function wQ(g) {
1266
1266
  return g === 1 || g === 2 || g === 4 || g === 8;
1267
1267
  }
1268
1268
  function Sg(g) {
@@ -1282,7 +1282,7 @@ function Sg(g) {
1282
1282
  return "float";
1283
1283
  throw new Error("Unsupported buffer type.");
1284
1284
  }
1285
- function rQ(g) {
1285
+ function FQ(g) {
1286
1286
  switch (g.dataFormat) {
1287
1287
  case "scalar":
1288
1288
  return 1;
@@ -1292,7 +1292,7 @@ function rQ(g) {
1292
1292
  return 4;
1293
1293
  }
1294
1294
  }
1295
- function SQ(g) {
1295
+ function rQ(g) {
1296
1296
  switch (g.dataType) {
1297
1297
  case "byte":
1298
1298
  case "unsigned_byte":
@@ -1307,13 +1307,13 @@ function SQ(g) {
1307
1307
  }
1308
1308
  }
1309
1309
  function gg(g) {
1310
- const A = rQ(g) * SQ(g), I = Math.max(1, g.mipmapLevels);
1310
+ const A = FQ(g) * rQ(g), I = Math.max(1, g.mipmapLevels);
1311
1311
  let B = Math.max(1, g.width), C = Math.max(1, g.height), Q = Math.max(1, g.depth), E = 0;
1312
1312
  for (let i = 0; i < I; ++i)
1313
1313
  E += A * Q * B * C, B = Math.max(1, B >> 1), C = Math.max(1, C >> 1), g.type === "Texture3D" && (Q = Math.max(1, Q >> 1));
1314
1314
  return E;
1315
1315
  }
1316
- function RQ(g) {
1316
+ function SQ(g) {
1317
1317
  if (g.dataFormat === "rgb" || g.dataFormat === "rgba")
1318
1318
  return [0, 1];
1319
1319
  switch (g.dataType) {
@@ -1364,7 +1364,7 @@ class Rg extends YI {
1364
1364
  return "Texture";
1365
1365
  }
1366
1366
  }
1367
- class cQ {
1367
+ class RQ {
1368
1368
  gl_;
1369
1369
  textures_ = /* @__PURE__ */ new Map();
1370
1370
  currentTexture_ = null;
@@ -1695,7 +1695,7 @@ class AA {
1695
1695
  return { x: A, y: I, width: B, height: C };
1696
1696
  }
1697
1697
  }
1698
- class NQ {
1698
+ class cQ {
1699
1699
  gl_;
1700
1700
  enabledCapabilities_ = /* @__PURE__ */ new Map();
1701
1701
  depthMaskEnabled_ = null;
@@ -1823,7 +1823,7 @@ class NQ {
1823
1823
  (this.stencilFunc_ !== A || this.stencilRef_ !== I || this.stencilFuncMask_ !== B) && (this.gl_.stencilFunc(A, I, B), this.stencilFunc_ = A, this.stencilRef_ = I, this.stencilFuncMask_ = B);
1824
1824
  }
1825
1825
  }
1826
- class UQ {
1826
+ class NQ {
1827
1827
  textureUnit;
1828
1828
  gl_;
1829
1829
  framebuffer_ = null;
@@ -1874,8 +1874,8 @@ class UQ {
1874
1874
  ), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_MIN_FILTER, B.NEAREST), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_MAG_FILTER, B.NEAREST), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_WRAP_S, B.CLAMP_TO_EDGE), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_WRAP_T, B.CLAMP_TO_EDGE), C;
1875
1875
  }
1876
1876
  }
1877
- const kQ = AC($(), [1, -1, 1]);
1878
- class LQ extends MC {
1877
+ const UQ = AC($(), [1, -1, 1]);
1878
+ class kQ extends dC {
1879
1879
  gl_;
1880
1880
  bindings_;
1881
1881
  depthTarget_;
@@ -1898,7 +1898,7 @@ class LQ extends MC {
1898
1898
  this.gl_ = I, k.info(
1899
1899
  "WebGLRenderer",
1900
1900
  `WebGL version ${I.getParameter(I.VERSION)}`
1901
- ), I.getExtension("EXT_color_buffer_float"), this.programs_ = new bC(I), this.bindings_ = new wQ(I), this.textures_ = new cQ(I), this.state_ = new NQ(I), this.depthTarget_ = new UQ(
1901
+ ), I.getExtension("EXT_color_buffer_float"), this.programs_ = new WC(I), this.bindings_ = new GQ(I), this.textures_ = new RQ(I), this.state_ = new cQ(I), this.depthTarget_ = new NQ(
1902
1902
  I,
1903
1903
  this.textures_.reservePersistentUnit()
1904
1904
  ), this.resize(this.canvas.width, this.canvas.height);
@@ -1913,7 +1913,7 @@ class LQ extends MC {
1913
1913
  this.renderedObjects_ = 0, this.renderedObjectsPerFrame_ = 0, this.stencilRef_ = 0;
1914
1914
  for (const s of A.layers)
1915
1915
  s.update(A);
1916
- if (getComputedStyle(A.element).visibility === "hidden") return;
1916
+ if (getComputedStyle(A.domElement).visibility === "hidden") return;
1917
1917
  const I = A.getBoxRelativeTo(this.canvas), B = new AA(
1918
1918
  v(0, 0),
1919
1919
  v(this.width, this.height)
@@ -2003,7 +2003,7 @@ class LQ extends MC {
2003
2003
  I.transform.matrix
2004
2004
  ), i = QI(
2005
2005
  $(),
2006
- kQ,
2006
+ UQ,
2007
2007
  Q.projectionMatrix
2008
2008
  ), o = this.currentViewportSize_, a = I.getUniforms(), D = {
2009
2009
  ...B.getUniforms(),
@@ -2118,7 +2118,7 @@ function xA(g, A) {
2118
2118
  const I = g.priority ?? Number.MAX_SAFE_INTEGER, B = A.priority ?? Number.MAX_SAFE_INTEGER;
2119
2119
  return I === B ? (g.orderKey ?? Number.MAX_SAFE_INTEGER) - (A.orderKey ?? Number.MAX_SAFE_INTEGER) : I - B;
2120
2120
  }
2121
- class JQ {
2121
+ class LQ {
2122
2122
  maxConcurrent_;
2123
2123
  pending_ = [];
2124
2124
  running_ = /* @__PURE__ */ new Map();
@@ -2168,13 +2168,13 @@ class JQ {
2168
2168
  }
2169
2169
  }
2170
2170
  let tI = 0, yI = 0;
2171
- function YQ(g, A) {
2171
+ function JQ(g, A) {
2172
2172
  g.data && (tI -= g.data.byteLength, yI -= 1), g.data = A, tI += A.byteLength, yI += 1;
2173
2173
  }
2174
2174
  function CB(g) {
2175
2175
  g.data && (tI -= g.data.byteLength, yI -= 1), g.data = void 0, g.texture?.releaseCpuData();
2176
2176
  }
2177
- function dQ() {
2177
+ function YQ() {
2178
2178
  return { cpuChunkBytes: tI, cpuChunkCount: yI };
2179
2179
  }
2180
2180
  function QB(g, A, I = 1e-6) {
@@ -2198,7 +2198,7 @@ function YA(g) {
2198
2198
  function dA(g) {
2199
2199
  const A = M(), I = M();
2200
2200
  A[W[g.u]] = 1, I[W[g.v]] = 1;
2201
- const B = EI(M(), A, I), C = VC(
2201
+ const B = EI(M(), A, I), C = OC(
2202
2202
  A[0],
2203
2203
  A[1],
2204
2204
  A[2],
@@ -2220,7 +2220,7 @@ const EB = [
2220
2220
  Uint32Array,
2221
2221
  Float32Array
2222
2222
  ];
2223
- function MQ(g) {
2223
+ function dQ(g) {
2224
2224
  if (EB.some((I) => g instanceof I))
2225
2225
  return !0;
2226
2226
  const A = EB.map((I) => I.name);
@@ -2229,7 +2229,7 @@ function MQ(g) {
2229
2229
  `Unsupported chunk data type: ${g}. Supported data types: ${A}`
2230
2230
  ), !1;
2231
2231
  }
2232
- function KQ(g, A) {
2232
+ function MQ(g, A) {
2233
2233
  return Math.round((A - g.translation) / g.scale);
2234
2234
  }
2235
2235
  function CC(g, A) {
@@ -2239,13 +2239,13 @@ function CC(g, A) {
2239
2239
  I[i] = 1 / (g.scale[Q] * g.shape[Q]), B[i] = E - g.offset[Q];
2240
2240
  }
2241
2241
  const C = AC($(), I);
2242
- return vC(C, C, B);
2242
+ return VC(C, C, B);
2243
2243
  }
2244
2244
  function hA(g, A, I) {
2245
2245
  return Math.max(A, Math.min(I, g));
2246
2246
  }
2247
2247
  const MI = Symbol("INTERNAL_POLICY_KEY"), QC = 1e-6;
2248
- class HQ {
2248
+ class KQ {
2249
2249
  store_;
2250
2250
  policy_;
2251
2251
  policyChanged_ = !1;
@@ -2273,7 +2273,7 @@ class HQ {
2273
2273
  `Source is missing dimensions for slice plane axes "${this.axes_.u}" and "${this.axes_.v}"`
2274
2274
  );
2275
2275
  const i = Q.lods[0], o = E.lods[0];
2276
- this.scale0_ = i.scale, this.sourceMaxSquareDistance2D_ = eQ(
2276
+ this.scale0_ = i.scale, this.sourceMaxSquareDistance2D_ = yQ(
2277
2277
  v(i.size * i.scale, o.size * o.scale)
2278
2278
  );
2279
2279
  }
@@ -2334,7 +2334,7 @@ class HQ {
2334
2334
  return;
2335
2335
  }
2336
2336
  const D = BC();
2337
- nQ(D, B.min, B.max, 0.5);
2337
+ eQ(D, B.min, B.max, 0.5);
2338
2338
  const h = this.makeViewBounds3D(B, o);
2339
2339
  this.chunkViewStates_.forEach(TA);
2340
2340
  const t = this.channelsOfInterest(A.c), e = this.lodRange().max, n = this.getPaddedBounds(h), F = new iB(
@@ -2537,7 +2537,7 @@ class HQ {
2537
2537
  }
2538
2538
  timeIndex(A) {
2539
2539
  const I = this.store_.dimensions.t;
2540
- return A === void 0 || I === void 0 ? 0 : KQ(I.lods[0], A);
2540
+ return A === void 0 || I === void 0 ? 0 : MQ(I.lods[0], A);
2541
2541
  }
2542
2542
  getSliceAxisBounds(A) {
2543
2543
  const I = this.store_.dimensions[this.axes_.w];
@@ -2565,7 +2565,7 @@ class HQ {
2565
2565
  return this.lastViewBounds2D_ === null || !BB(this.lastViewBounds2D_.min, A.min) || !BB(this.lastViewBounds2D_.max, A.max);
2566
2566
  }
2567
2567
  hasViewProjectionChanged(A) {
2568
- return this.lastViewProjection_ === null || !IQ(this.lastViewProjection_, A);
2568
+ return this.lastViewProjection_ === null || !AQ(this.lastViewProjection_, A);
2569
2569
  }
2570
2570
  cCoordsChanged(A) {
2571
2571
  return !this.lastCCoords_ && !A ? !1 : !this.lastCCoords_ || !A || this.lastCCoords_.length !== A.length ? !0 : !this.lastCCoords_.every((I, B) => I === A[B]);
@@ -2616,7 +2616,7 @@ function WI(g, A) {
2616
2616
  function TA(g) {
2617
2617
  g.visible = !1, g.prefetch = !1, g.priority = null, g.orderKey = null;
2618
2618
  }
2619
- class qQ {
2619
+ class HQ {
2620
2620
  // Chunks indexed as chunks_[lod][t][c][z][y][x].
2621
2621
  chunks_;
2622
2622
  lowestResLOD_;
@@ -2697,7 +2697,7 @@ class qQ {
2697
2697
  return this.lowestResLOD_;
2698
2698
  }
2699
2699
  addView(A, I) {
2700
- const B = new HQ(this, A, I);
2700
+ const B = new KQ(this, A, I);
2701
2701
  return this.views_.push(B), this.hasHadViews_ = !0, B;
2702
2702
  }
2703
2703
  get views() {
@@ -2787,7 +2787,7 @@ class qQ {
2787
2787
  };
2788
2788
  }
2789
2789
  }
2790
- function lQ(g, A) {
2790
+ function qQ(g, A) {
2791
2791
  const I = A.dimensions.t?.lods[0].size ?? 1, B = {
2792
2792
  requested: new Uint32Array(I),
2793
2793
  resident: new Uint32Array(I)
@@ -2796,20 +2796,20 @@ function lQ(g, A) {
2796
2796
  const E = A.views;
2797
2797
  for (let i = 0; i < E.length; i++)
2798
2798
  for (const [o, a] of E[i].chunkViewStates) {
2799
- if (a.priority === null || fQ(o, E, i)) continue;
2799
+ if (a.priority === null || lQ(o, E, i)) continue;
2800
2800
  const s = o.chunkIndex.t;
2801
2801
  C += 1, B.requested[s] += 1, o.texture !== void 0 && (Q += 1, B.resident[s] += 1);
2802
2802
  }
2803
2803
  return { source: g, requested: C, resident: Q, timepoints: B };
2804
2804
  }
2805
- function fQ(g, A, I) {
2805
+ function lQ(g, A, I) {
2806
2806
  for (let B = 0; B < I; B++) {
2807
2807
  const C = A[B].chunkViewStates.get(g);
2808
2808
  if (C !== void 0 && C.priority !== null) return !0;
2809
2809
  }
2810
2810
  return !1;
2811
2811
  }
2812
- function pQ(g, A) {
2812
+ function fQ(g, A) {
2813
2813
  let I = 0, B = 0;
2814
2814
  const C = { requested: 0, resident: 0 };
2815
2815
  for (const Q of A) {
@@ -2856,8 +2856,8 @@ class cg extends Rg {
2856
2856
  return B.unpackAlignment = A.rowAlignmentBytes, B;
2857
2857
  }
2858
2858
  }
2859
- const uQ = 8, mQ = 4;
2860
- class TQ {
2859
+ const pQ = 8, uQ = 4;
2860
+ class mQ {
2861
2861
  stores_ = [];
2862
2862
  queue_;
2863
2863
  uploadTexture_;
@@ -2865,8 +2865,8 @@ class TQ {
2865
2865
  getGpuResidentBytes_;
2866
2866
  memoryLimitBytes_;
2867
2867
  maxGpuUploadsPerUpdate_;
2868
- constructor(A, I, B = () => 0, C = 1 / 0, Q = uQ, E = mQ) {
2869
- this.uploadTexture_ = A, this.disposeTexture_ = I, this.getGpuResidentBytes_ = B, this.memoryLimitBytes_ = C, this.maxGpuUploadsPerUpdate_ = Math.max(1, E), this.queue_ = new JQ(Q);
2868
+ constructor(A, I, B = () => 0, C = 1 / 0, Q = pQ, E = uQ) {
2869
+ this.uploadTexture_ = A, this.disposeTexture_ = I, this.getGpuResidentBytes_ = B, this.memoryLimitBytes_ = C, this.maxGpuUploadsPerUpdate_ = Math.max(1, E), this.queue_ = new LQ(Q);
2870
2870
  }
2871
2871
  get memoryLimitBytes() {
2872
2872
  return this.memoryLimitBytes_;
@@ -2881,16 +2881,16 @@ class TQ {
2881
2881
  };
2882
2882
  }
2883
2883
  get memoryStats() {
2884
- return dQ();
2884
+ return YQ();
2885
2885
  }
2886
2886
  get sourceChunkStats() {
2887
2887
  return this.stores_.map(
2888
- ({ source: A, store: I }) => lQ(A, I)
2888
+ ({ source: A, store: I }) => qQ(A, I)
2889
2889
  );
2890
2890
  }
2891
2891
  addView(A, I, B) {
2892
2892
  let C = this.stores_.find((Q) => Q.source === A)?.store;
2893
- return C || (C = new qQ(A.loader.getSourceDimensionMap()), this.stores_.push({ source: A, store: C })), C.addView(I, B);
2893
+ return C || (C = new HQ(A.loader.getSourceDimensionMap()), this.stores_.push({ source: A, store: C })), C.addView(I, B);
2894
2894
  }
2895
2895
  update() {
2896
2896
  const A = [];
@@ -3042,6 +3042,10 @@ class KI {
3042
3042
  */
3043
3043
  onEvent(A) {
3044
3044
  }
3045
+ /** Whether the layer is attached to a viewport. */
3046
+ get attached() {
3047
+ return this.attached_;
3048
+ }
3045
3049
  /**
3046
3050
  * Lifecycle hook that is called automatically when a layer is
3047
3051
  * is attached to a viewport. A layer can only be attached to one viewport
@@ -3156,7 +3160,7 @@ function Ng(g = {}) {
3156
3160
  ]
3157
3161
  }, g));
3158
3162
  }
3159
- function ko(g = {}) {
3163
+ function co(g = {}) {
3160
3164
  return Ug(kg({
3161
3165
  profile: "playback",
3162
3166
  prefetch: { x: 0, y: 0, z: 0, t: 20 },
@@ -3169,7 +3173,7 @@ function ko(g = {}) {
3169
3173
  ]
3170
3174
  }, g));
3171
3175
  }
3172
- function Lo(g = {}) {
3176
+ function No(g = {}) {
3173
3177
  return Ug(kg({
3174
3178
  profile: "no-prefetch",
3175
3179
  prefetch: { x: 0, y: 0, z: 0, t: 0 },
@@ -3183,7 +3187,7 @@ function Lo(g = {}) {
3183
3187
  }, g));
3184
3188
  }
3185
3189
  function Ug(g) {
3186
- xQ(g);
3190
+ TQ(g);
3187
3191
  const A = {
3188
3192
  x: g.prefetch.x,
3189
3193
  y: g.prefetch.y,
@@ -3210,7 +3214,7 @@ function Ug(g) {
3210
3214
  };
3211
3215
  return Object.freeze(C);
3212
3216
  }
3213
- function xQ(g) {
3217
+ function TQ(g) {
3214
3218
  for (const [B, C] of Object.entries(g.prefetch))
3215
3219
  if (C !== void 0 && C < 0)
3216
3220
  throw new Error(`prefetch.${B} must be a non-negative number`);
@@ -3334,7 +3338,7 @@ class T {
3334
3338
  }
3335
3339
  const oB = 32;
3336
3340
  function vA(g, { visible: A, color: I, contrastLimits: B, opacity: C }) {
3337
- return A ??= !0, I = I === void 0 ? T.WHITE : T.from(I), C = C === void 0 ? 1 : hA(C, 0, 1), g !== null ? B = WQ(B, g) : B === void 0 && (k.debug(
3341
+ return A ??= !0, I = I === void 0 ? T.WHITE : T.from(I), C = C === void 0 ? 1 : hA(C, 0, 1), g !== null ? B = xQ(B, g) : B === void 0 && (k.debug(
3338
3342
  "Channel",
3339
3343
  "No texture provided, defaulting channel contrast limits to [0, 1]."
3340
3344
  ), B = [0, 1]), {
@@ -3355,16 +3359,16 @@ function iC(g, A) {
3355
3359
  `channelProps length (${g.length}) must match source channel count (${A}).`
3356
3360
  );
3357
3361
  }
3358
- function WQ(g, A) {
3362
+ function xQ(g, A) {
3359
3363
  if (g === void 0)
3360
- return RQ(A);
3364
+ return SQ(A);
3361
3365
  if (g[1] <= g[0])
3362
3366
  throw new Error(
3363
3367
  `Contrast limits must be strictly increasing: ${g}.`
3364
3368
  );
3365
3369
  return g;
3366
3370
  }
3367
- class bQ extends pA {
3371
+ class WQ extends pA {
3368
3372
  constructor(A) {
3369
3373
  if (super(), A.primitive != "triangles") {
3370
3374
  k.warn("WireframeGeometry", "Only indexed geometries are supported");
@@ -3389,7 +3393,7 @@ class bQ extends pA {
3389
3393
  this.indexData_ = new Uint32Array(B);
3390
3394
  }
3391
3395
  }
3392
- const ZQ = x(0, 1, 0);
3396
+ const bQ = x(0, 1, 0);
3393
3397
  class oC {
3394
3398
  dirty_ = !0;
3395
3399
  matrix_ = $();
@@ -3402,7 +3406,7 @@ class oC {
3402
3406
  * @param q - The rotation to apply.
3403
3407
  */
3404
3408
  addRotation(A) {
3405
- DQ(this.rotation_, this.rotation_, A), this.dirty_ = !0;
3409
+ sQ(this.rotation_, this.rotation_, A), this.dirty_ = !0;
3406
3410
  }
3407
3411
  /**
3408
3412
  * Replaces the rotation with the given quaternion.
@@ -3410,11 +3414,11 @@ class oC {
3410
3414
  * @param q - The new rotation.
3411
3415
  */
3412
3416
  setRotation(A) {
3413
- tQ(this.rotation_, A), this.dirty_ = !0;
3417
+ hQ(this.rotation_, A), this.dirty_ = !0;
3414
3418
  }
3415
3419
  /** A copy of the rotation quaternion. */
3416
3420
  get rotation() {
3417
- return hQ(this.rotation_);
3421
+ return DQ(this.rotation_);
3418
3422
  }
3419
3423
  /**
3420
3424
  * Adds the given offset to the translation.
@@ -3442,7 +3446,7 @@ class oC {
3442
3446
  * @param vec - The scale factors to apply.
3443
3447
  */
3444
3448
  addScale(A) {
3445
- gQ(this.scale_, this.scale_, A), this.dirty_ = !0;
3449
+ IQ(this.scale_, this.scale_, A), this.dirty_ = !0;
3446
3450
  }
3447
3451
  /**
3448
3452
  * Replaces the scale with the given vector.
@@ -3460,7 +3464,7 @@ class oC {
3460
3464
  */
3461
3465
  targetTo(A) {
3462
3466
  Fg(this.translation_, A) && (A = EA(A), A[2] += m);
3463
- const I = AQ($(), this.translation_, A, ZQ), B = OC($B(), I);
3467
+ const I = $C($(), this.translation_, A, bQ), B = PC($B(), I);
3464
3468
  rg(this.rotation_, B), dI(this.rotation_, this.rotation_), this.dirty_ = !0;
3465
3469
  }
3466
3470
  /** A copy of the scale vector. */
@@ -3476,7 +3480,7 @@ class oC {
3476
3480
  return PA($(), this.matrix);
3477
3481
  }
3478
3482
  computeMatrix() {
3479
- XC(
3483
+ vC(
3480
3484
  this.matrix_,
3481
3485
  this.rotation_,
3482
3486
  this.translation_,
@@ -3555,7 +3559,7 @@ class zA extends YI {
3555
3559
  * changes.
3556
3560
  */
3557
3561
  get wireframeGeometry() {
3558
- return this.wireframeGeometry_ ??= new bQ(this.geometry), this.wireframeGeometry_;
3562
+ return this.wireframeGeometry_ ??= new WQ(this.geometry), this.wireframeGeometry_;
3559
3563
  }
3560
3564
  /** The assigned textures indexed by texture unit. */
3561
3565
  get textures() {
@@ -3659,7 +3663,7 @@ class aC extends pA {
3659
3663
  });
3660
3664
  }
3661
3665
  }
3662
- class PQ extends zA {
3666
+ class ZQ extends zA {
3663
3667
  /**
3664
3668
  * A matrix mapping world space to the texture's normalized coordinate
3665
3669
  * space. Layers derive it from the chunk's offset, scale, and shape.
@@ -3678,7 +3682,7 @@ class PQ extends zA {
3678
3682
  texture: B,
3679
3683
  channelProps: C = []
3680
3684
  }) {
3681
- super(), this.geometry = new aC(A, I, 1, 1), this.setTexture(0, B), this.channels_ = Bg(B, C), this.programName = OQ(B), this.depthProgramName = "meshDepth";
3685
+ super(), this.geometry = new aC(A, I, 1, 1), this.setTexture(0, B), this.channels_ = Bg(B, C), this.programName = PQ(B), this.depthProgramName = "meshDepth";
3682
3686
  }
3683
3687
  /** Identifies the renderable type as `ImageRenderable`. */
3684
3688
  get type() {
@@ -3727,7 +3731,7 @@ class PQ extends zA {
3727
3731
  };
3728
3732
  }
3729
3733
  }
3730
- function OQ(g) {
3734
+ function PQ(g) {
3731
3735
  switch (g.dataType) {
3732
3736
  case "byte":
3733
3737
  case "int":
@@ -3773,7 +3777,7 @@ function sC(g, A, I, B, C = 3) {
3773
3777
  case "pointerup": {
3774
3778
  if (!A) return A;
3775
3779
  const Q = g.event, E = v(Q.clientX, Q.clientY);
3776
- if (yQ(A, E) < C) {
3780
+ if (tQ(A, E) < C) {
3777
3781
  if (!B) return null;
3778
3782
  const o = g.worldRay;
3779
3783
  return o && I(o).then((a) => {
@@ -4000,7 +4004,7 @@ class Jg extends KI {
4000
4004
  return this.channelProps_ ? [this.channelProps_[A.chunkIndex.c] ?? {}] : [{}];
4001
4005
  }
4002
4006
  createImage(A, I) {
4003
- const B = new PQ({
4007
+ const B = new ZQ({
4004
4008
  width: A.shape[this.axes_.u],
4005
4009
  height: A.shape[this.axes_.v],
4006
4010
  texture: I,
@@ -4134,7 +4138,7 @@ class aB extends Rg {
4134
4138
  return this.height_;
4135
4139
  }
4136
4140
  }
4137
- const VQ = [
4141
+ const OQ = [
4138
4142
  [1, 0.5, 0.5],
4139
4143
  [0.5, 1, 0.5],
4140
4144
  [0.5, 0.5, 1],
@@ -4142,7 +4146,7 @@ const VQ = [
4142
4146
  [1, 0.5, 1],
4143
4147
  [1, 1, 0.5]
4144
4148
  ];
4145
- function vQ(g) {
4149
+ function VQ(g) {
4146
4150
  return g = g ?? /* @__PURE__ */ new Map(), new Map(
4147
4151
  Array.from(g.entries()).map(([A, I]) => [
4148
4152
  A,
@@ -4150,35 +4154,35 @@ function vQ(g) {
4150
4154
  ])
4151
4155
  );
4152
4156
  }
4153
- function XQ(g) {
4154
- return g = g ?? VQ, g.map(T.from);
4157
+ function vQ(g) {
4158
+ return g = g ?? OQ, g.map(T.from);
4155
4159
  }
4156
4160
  function nI(g = {}) {
4157
4161
  return {
4158
- lookupTable: vQ(g.lookupTable),
4159
- cycle: XQ(g.cycle)
4162
+ lookupTable: VQ(g.lookupTable),
4163
+ cycle: vQ(g.cycle)
4160
4164
  };
4161
4165
  }
4162
- const DC = /* @__PURE__ */ new Set(["byte", "short", "int"]), jQ = /* @__PURE__ */ new Set([
4166
+ const DC = /* @__PURE__ */ new Set(["byte", "short", "int"]), XQ = /* @__PURE__ */ new Set([
4163
4167
  "unsigned_byte",
4164
4168
  "unsigned_short",
4165
4169
  "unsigned_int"
4166
4170
  ]);
4167
- function zQ(g) {
4171
+ function jQ(g) {
4168
4172
  if (g.dataFormat !== "scalar")
4169
4173
  throw new Error(
4170
4174
  `Image data format must be scalar, instead found: ${g.dataFormat}`
4171
4175
  );
4172
- if (!DC.has(g.dataType) && !jQ.has(g.dataType))
4176
+ if (!DC.has(g.dataType) && !XQ.has(g.dataType))
4173
4177
  throw new Error(
4174
4178
  `Image data type must be an integer, instead found: ${g.dataType}`
4175
4179
  );
4176
4180
  return g;
4177
4181
  }
4178
- function _Q(g) {
4182
+ function zQ(g) {
4179
4183
  return DC.has(g.dataType) ? "intLabelImage" : "labelImage";
4180
4184
  }
4181
- class $Q extends zA {
4185
+ class _Q extends zA {
4182
4186
  /**
4183
4187
  * A matrix mapping world space to the texture's normalized coordinate
4184
4188
  * space. Layers derive it from the chunk's offset, scale, and shape.
@@ -4193,9 +4197,9 @@ class $Q extends zA {
4193
4197
  * @param props - Initialization properties.
4194
4198
  */
4195
4199
  constructor(A) {
4196
- super(), this.geometry = new aC(A.width, A.height, 1, 1), this.setTexture(0, zQ(A.imageData));
4200
+ super(), this.geometry = new aC(A.width, A.height, 1, 1), this.setTexture(0, jQ(A.imageData));
4197
4201
  const I = nI(A.colorMap);
4198
- this.setTexture(1, this.makeColorCycleTexture(I.cycle)), this.setTexture(2, this.makeColorLookupTableTexture(I.lookupTable)), this.outlineSelected_ = A.outlineSelected ?? !1, this.selectedValue_ = A.selectedValue ?? null, this.programName = _Q(A.imageData), this.depthProgramName = "meshDepth";
4202
+ this.setTexture(1, this.makeColorCycleTexture(I.cycle)), this.setTexture(2, this.makeColorLookupTableTexture(I.lookupTable)), this.outlineSelected_ = A.outlineSelected ?? !1, this.selectedValue_ = A.selectedValue ?? null, this.programName = zQ(A.imageData), this.depthProgramName = "meshDepth";
4199
4203
  }
4200
4204
  /** Identifies the renderable type as `LabelImageRenderable`. */
4201
4205
  get type() {
@@ -4481,7 +4485,7 @@ class Yg extends KI {
4481
4485
  return C ? (C.setTexture(0, I), C.setColorMap(this.colorMap_), C.setSelectedValue(this.selectedValue_), this.updateLabelChunk(C, A), C) : this.createLabel(A, I);
4482
4486
  }
4483
4487
  createLabel(A, I) {
4484
- const B = new $Q({
4488
+ const B = new _Q({
4485
4489
  width: A.shape[this.axes_.u],
4486
4490
  height: A.shape[this.axes_.v],
4487
4491
  imageData: I,
@@ -4513,7 +4517,7 @@ class Yg extends KI {
4513
4517
  }
4514
4518
  }
4515
4519
  }
4516
- class AE extends pA {
4520
+ class $Q extends pA {
4517
4521
  constructor(A, I, B, C, Q, E) {
4518
4522
  super();
4519
4523
  const i = [], o = [], a = Math.floor(C), s = Math.floor(Q), D = Math.floor(E);
@@ -4560,7 +4564,7 @@ class AE extends pA {
4560
4564
  }
4561
4565
  }
4562
4566
  }
4563
- class IE extends zA {
4567
+ class AE extends zA {
4564
4568
  /**
4565
4569
  * World size of a voxel along each axis. Layers set it from the chunk
4566
4570
  * scale so ray march steps account for anisotropic voxels. Defaults to
@@ -4576,7 +4580,7 @@ class IE extends zA {
4576
4580
  * @param props - Initialization properties.
4577
4581
  */
4578
4582
  constructor({ channelProps: A = [] } = {}) {
4579
- super(), this.geometry = new AE(1, 1, 1, 1, 1, 1), this.cullFaceMode = "front", this.depthTest = !1, this.channels_ = [], this.setChannelProps(A);
4583
+ super(), this.geometry = new $Q(1, 1, 1, 1, 1, 1), this.cullFaceMode = "front", this.depthTest = !1, this.channels_ = [], this.setChannelProps(A);
4580
4584
  }
4581
4585
  /** Identifies the renderable type as `VolumeRenderable`. */
4582
4586
  get type() {
@@ -4598,7 +4602,7 @@ class IE extends zA {
4598
4602
  addChannelTexture(A, I) {
4599
4603
  const B = this.textures.length;
4600
4604
  this.setTexture(B, I), this.channelToTextureIndex_.set(A, B);
4601
- const C = gE(I.dataType);
4605
+ const C = IE(I.dataType);
4602
4606
  if (this.programName && this.programName !== C)
4603
4607
  throw new Error(
4604
4608
  `Volume renderable does not support multiple channels with different data types. Existing program: ${this.programName}, new channel data type: ${I.dataType} and program: ${C}`
@@ -4710,7 +4714,7 @@ class IE extends zA {
4710
4714
  this.channels_[A] = C;
4711
4715
  }
4712
4716
  }
4713
- function gE(g) {
4717
+ function IE(g) {
4714
4718
  switch (g) {
4715
4719
  case "byte":
4716
4720
  case "int":
@@ -4724,8 +4728,8 @@ function gE(g) {
4724
4728
  return "floatVolume";
4725
4729
  }
4726
4730
  }
4727
- const BE = 2;
4728
- class CE extends KI {
4731
+ const gE = 2;
4732
+ class BE extends KI {
4729
4733
  /** Identifies the layer type as `VolumeLayer`. */
4730
4734
  type = "VolumeLayer";
4731
4735
  /** Highlights rays of zero length for debugging. Defaults to `false`. */
@@ -4832,7 +4836,7 @@ class CE extends KI {
4832
4836
  for (const E of I) B.updateVolumeWithChunk(E);
4833
4837
  return B;
4834
4838
  }
4835
- const C = iE(I[0]), Q = this.pool_.acquire(C) ?? new IE();
4839
+ const C = EE(I[0]), Q = this.pool_.acquire(C) ?? new AE();
4836
4840
  Q.setChannelProps(this.channelProps_ ?? []), this.volumeToPoolKey_.set(Q, C);
4837
4841
  for (const E of I) Q.updateVolumeWithChunk(E);
4838
4842
  return this.updateVolumeTransform(Q, I[0]), Q;
@@ -4856,7 +4860,7 @@ class CE extends KI {
4856
4860
  updateChunks() {
4857
4861
  if (!this.chunkStoreView_) return;
4858
4862
  this.state !== "ready" && this.setState("ready");
4859
- const A = this.chunkStoreView_.getChunksToRender(), I = this.sliceCoords_.t ?? -1, B = EE(A);
4863
+ const A = this.chunkStoreView_.getChunksToRender(), I = this.sliceCoords_.t ?? -1, B = QE(A);
4860
4864
  if (this.lastLoadedTime_ !== I || B.size !== this.currentVolumes_.size || this.lastNumRenderedChannelChunks_ !== A.length) {
4861
4865
  for (const [Q, E] of this.currentVolumes_)
4862
4866
  B.has(Q) || (this.releaseAndRemoveVolume(E), this.currentVolumes_.delete(Q));
@@ -4901,11 +4905,11 @@ class CE extends KI {
4901
4905
  A.camera.getViewProjection()
4902
4906
  );
4903
4907
  const I = A.cameraControls?.isMoving ?? !1;
4904
- this.interactiveStepSizeScale_ = I ? BE : 1, this.updateChunks(), this.rebuildObjects(A.camera);
4908
+ this.interactiveStepSizeScale_ = I ? gE : 1, this.updateChunks(), this.rebuildObjects(A.camera);
4905
4909
  }
4906
4910
  rebuildObjects(A) {
4907
4911
  const I = Array.from(this.currentVolumes_.values());
4908
- oE(I, A), this.clearObjects();
4912
+ iE(I, A), this.clearObjects();
4909
4913
  for (const B of I)
4910
4914
  this.addObject(B);
4911
4915
  }
@@ -4923,35 +4927,35 @@ class CE extends KI {
4923
4927
  };
4924
4928
  }
4925
4929
  }
4926
- function QE(g) {
4930
+ function CE(g) {
4927
4931
  const { x: A, y: I, z: B, t: C } = g.chunkIndex;
4928
4932
  return `${A}:${I}:${B}:${C}`;
4929
4933
  }
4930
- function EE(g) {
4934
+ function QE(g) {
4931
4935
  const A = /* @__PURE__ */ new Map();
4932
4936
  for (const I of g) {
4933
- const B = QE(I);
4937
+ const B = CE(I);
4934
4938
  let C = A.get(B);
4935
4939
  C || (C = [], A.set(B, C)), C.push(I);
4936
4940
  }
4937
4941
  return A;
4938
4942
  }
4939
- function iE(g) {
4943
+ function EE(g) {
4940
4944
  return [
4941
4945
  `lod${g.lod}`,
4942
4946
  `shape${g.shape.x}x${g.shape.y}x${g.shape.z}`,
4943
4947
  `align${g.rowAlignmentBytes}`
4944
4948
  ].join(":");
4945
4949
  }
4946
- function oE(g, A) {
4950
+ function iE(g, A) {
4947
4951
  const I = A.position, B = /* @__PURE__ */ new Map();
4948
4952
  for (const C of g) {
4949
4953
  const Q = C.transform.translation;
4950
- B.set(C, BQ(I, Q));
4954
+ B.set(C, gQ(I, Q));
4951
4955
  }
4952
4956
  g.sort((C, Q) => B.get(Q) - B.get(C));
4953
4957
  }
4954
- let aE = class {
4958
+ let oE = class {
4955
4959
  renderer_;
4956
4960
  chunkManager_;
4957
4961
  viewports_;
@@ -4988,8 +4992,8 @@ let aE = class {
4988
4992
  for (const I of this.viewports_) {
4989
4993
  const B = [];
4990
4994
  for (const C of I.layers)
4991
- !(C instanceof Jg) && !(C instanceof Yg) && !(C instanceof CE) || C.chunkStoreView && B.push(C.chunkStoreView);
4992
- B.length !== 0 && A.push(pQ(I.id, B));
4995
+ !(C instanceof Jg) && !(C instanceof Yg) && !(C instanceof BE) || C.chunkStoreView && B.push(C.chunkStoreView);
4996
+ B.length !== 0 && A.push(fQ(I.id, B));
4993
4997
  }
4994
4998
  return { sources: this.chunkManager_.sourceChunkStats, viewports: A };
4995
4999
  }
@@ -5050,13 +5054,277 @@ ZA.Panel = function(g, A, I, B) {
5050
5054
  }
5051
5055
  };
5052
5056
  };
5053
- function sE({ scale: g } = { scale: 1.5 }) {
5057
+ function aE({ scale: g } = { scale: 1.5 }) {
5054
5058
  const A = new ZA(g);
5055
5059
  return A.showPanel(
5056
5060
  0
5057
5061
  /* 0 = fps, 1 = ms, 2 = mb */
5058
5062
  ), document.body.appendChild(A.dom), A;
5059
5063
  }
5064
+ class sE {
5065
+ elements_;
5066
+ resizeObserver_;
5067
+ mediaQuery_;
5068
+ onMediaQueryChange_;
5069
+ onChange_;
5070
+ constructor(A = [], I) {
5071
+ this.elements_ = [...A], this.onChange_ = I;
5072
+ }
5073
+ connect() {
5074
+ if (this.resizeObserver_) {
5075
+ k.warn(
5076
+ "PixelSizeObserver",
5077
+ "Attempted to connect already connected observer"
5078
+ );
5079
+ return;
5080
+ }
5081
+ this.resizeObserver_ = new ResizeObserver(() => {
5082
+ this.onChange_();
5083
+ });
5084
+ for (const A of this.elements_)
5085
+ this.resizeObserver_.observe(A);
5086
+ this.startDevicePixelRatioObserver();
5087
+ }
5088
+ startDevicePixelRatioObserver() {
5089
+ this.mediaQuery_ = matchMedia(
5090
+ `(resolution: ${window.devicePixelRatio}dppx)`
5091
+ ), this.onMediaQueryChange_ = () => {
5092
+ this.onChange_(), this.startDevicePixelRatioObserver();
5093
+ }, this.mediaQuery_.addEventListener("change", this.onMediaQueryChange_, {
5094
+ once: !0
5095
+ });
5096
+ }
5097
+ disconnect() {
5098
+ if (!this.resizeObserver_) {
5099
+ k.warn(
5100
+ "PixelSizeObserver",
5101
+ "Attempted to disconnect already disconnected observer"
5102
+ );
5103
+ return;
5104
+ }
5105
+ this.resizeObserver_?.disconnect(), this.mediaQuery_ && this.onMediaQueryChange_ && this.mediaQuery_.removeEventListener("change", this.onMediaQueryChange_);
5106
+ }
5107
+ observe(A) {
5108
+ if (this.elements_.includes(A)) {
5109
+ k.warn("PixelSizeObserver", "Element already being observed");
5110
+ return;
5111
+ }
5112
+ this.elements_.push(A), this.resizeObserver_ && this.resizeObserver_.observe(A);
5113
+ }
5114
+ unobserve(A) {
5115
+ const I = this.elements_.indexOf(A);
5116
+ if (I === -1) {
5117
+ k.warn("PixelSizeObserver", "Element not being observed");
5118
+ return;
5119
+ }
5120
+ this.elements_.splice(I, 1), this.resizeObserver_ && this.resizeObserver_.unobserve(A);
5121
+ }
5122
+ }
5123
+ const DE = 2048;
5124
+ function sB(g, A) {
5125
+ for (const B of A) {
5126
+ if (B.id === g.id)
5127
+ throw new Error(
5128
+ `Duplicate viewport ID "${g.id}". Each viewport must have a unique ID.`
5129
+ );
5130
+ if (B.domElement === g.domElement) {
5131
+ const C = g.domElement.tagName.toLowerCase() + (g.domElement.id ? `#${g.domElement.id}` : "[element has no id]");
5132
+ throw new Error(
5133
+ `Multiple viewports cannot share the same HTML element: viewports "${B.id}" and "${g.id}" both use ${C}`
5134
+ );
5135
+ }
5136
+ }
5137
+ const I = new Set(
5138
+ A.flatMap((B) => B.layers)
5139
+ );
5140
+ for (const B of g.layers)
5141
+ if (I.has(B))
5142
+ throw new Error(
5143
+ `${B.type} cannot be shared by multiple viewports simultaneously.`
5144
+ );
5145
+ }
5146
+ class ko {
5147
+ /** The canvas element the renderer draws into. */
5148
+ canvas;
5149
+ /** The registered overlays that update once per frame in order. */
5150
+ overlays;
5151
+ /** Memory, queue, chunk, and rendered-object statistics. */
5152
+ stats;
5153
+ chunkManager_;
5154
+ context_;
5155
+ renderer_;
5156
+ viewports_;
5157
+ attachments_ = /* @__PURE__ */ new Map();
5158
+ stats_;
5159
+ sizeObserver_;
5160
+ lastAnimationId_;
5161
+ lastTimestamp_ = 0;
5162
+ /**
5163
+ * Creates an Idetik runtime for the given canvas.
5164
+ *
5165
+ * @param params - Initialization properties.
5166
+ */
5167
+ constructor(A) {
5168
+ this.canvas = A.canvas, this.renderer_ = new kQ(this.canvas);
5169
+ const B = (A.memoryLimitMB ?? DE) * 1024 * 1024;
5170
+ this.chunkManager_ = new mQ(
5171
+ (Q) => this.renderer_.uploadTexture(Q),
5172
+ (Q) => this.renderer_.disposeTexture(Q),
5173
+ () => this.renderer_.gpuTextureBytes,
5174
+ B,
5175
+ A.maxConcurrentRequests,
5176
+ A.maxGpuUploadsPerUpdate
5177
+ ), this.context_ = {
5178
+ chunkManager: this.chunkManager_
5179
+ }, this.viewports_ = [];
5180
+ for (const Q of A.viewports ?? [])
5181
+ sB(Q, this.viewports_), this.viewports_.push(Q);
5182
+ this.overlays = [...A.overlays ?? []], this.stats = new oE(this.renderer_, this.chunkManager_, this.viewports_), A.showStats && (this.stats_ = aE());
5183
+ const C = [this.canvas];
5184
+ for (const Q of this.viewports_)
5185
+ Q.domElement !== this.canvas && C.push(Q.domElement);
5186
+ this.sizeObserver_ = new sE(C, () => {
5187
+ this.renderer_.updateSize(), this.detachRemovedLayers(), this.renderer_.beginFrame();
5188
+ for (const Q of this.viewports_)
5189
+ Q.updateSize(), this.renderViewport(Q);
5190
+ });
5191
+ }
5192
+ /** The width of the rendering surface in pixels. */
5193
+ get width() {
5194
+ return this.renderer_.width;
5195
+ }
5196
+ /** The height of the rendering surface in pixels. */
5197
+ get height() {
5198
+ return this.renderer_.height;
5199
+ }
5200
+ /** The viewports in render order. */
5201
+ get viewports() {
5202
+ return this.viewports_;
5203
+ }
5204
+ /** Whether the render loop is running. */
5205
+ get running() {
5206
+ return this.lastAnimationId_ !== void 0;
5207
+ }
5208
+ /**
5209
+ * Finds a viewport by its id.
5210
+ *
5211
+ * @param id - The id given in the viewport's definition.
5212
+ * @returns The matching viewport or `undefined` if none matches.
5213
+ */
5214
+ getViewport(A) {
5215
+ return this.viewports_.find((I) => I.id === A);
5216
+ }
5217
+ /**
5218
+ * Adds a viewport at runtime.
5219
+ *
5220
+ * @param viewport - The viewport to add.
5221
+ * @returns The added viewport.
5222
+ */
5223
+ addViewport(A) {
5224
+ return sB(A, this.viewports_), A.updateSize(), this.viewports_.push(A), this.running && (A.events.connect(), A.domElement !== this.canvas && this.sizeObserver_.observe(A.domElement)), k.info("Idetik", `Added viewport "${A.id}"`), A;
5225
+ }
5226
+ /**
5227
+ * Removes a previously added viewport.
5228
+ *
5229
+ * @param viewport - The viewport to remove.
5230
+ * @returns `true` if the viewport was found and removed.
5231
+ */
5232
+ removeViewport(A) {
5233
+ const I = this.viewports_.indexOf(A);
5234
+ if (I === -1)
5235
+ return k.warn(
5236
+ "Idetik",
5237
+ `Viewport "${A.id}" not found, nothing to remove`
5238
+ ), !1;
5239
+ this.running && (A.events.disconnect(), A.domElement !== this.canvas && this.sizeObserver_.unobserve(A.domElement)), this.viewports_.splice(I, 1);
5240
+ for (const [B, C] of this.attachments_)
5241
+ C === A && (B.onDetached(this.context_), this.attachments_.delete(B));
5242
+ return k.info("Idetik", `Removed viewport "${A.id}"`), !0;
5243
+ }
5244
+ /**
5245
+ * Registers an overlay that updates once per frame.
5246
+ *
5247
+ * @param overlay - The overlay to add.
5248
+ */
5249
+ addOverlay(A) {
5250
+ this.overlays.push(A);
5251
+ }
5252
+ /**
5253
+ * Removes a previously added overlay.
5254
+ *
5255
+ * @param overlay - The overlay to remove.
5256
+ * @returns `true` if the overlay was found and removed.
5257
+ */
5258
+ removeOverlay(A) {
5259
+ const I = this.overlays.indexOf(A);
5260
+ return I === -1 ? (k.warn("Idetik", "Overlay not found, nothing to remove"), !1) : (this.overlays.splice(I, 1), !0);
5261
+ }
5262
+ /**
5263
+ * Sets the memory budget for chunk data at runtime.
5264
+ *
5265
+ * @param memoryLimitMB - The new budget in megabytes.
5266
+ */
5267
+ setMemoryLimitMB(A) {
5268
+ this.chunkManager_.memoryLimitBytes = A * 1024 * 1024;
5269
+ }
5270
+ /**
5271
+ * Starts the render loop and connects input handlers.
5272
+ *
5273
+ * @returns The instance, for chaining.
5274
+ */
5275
+ start() {
5276
+ if (k.info("Idetik", "Idetik runtime starting"), this.running)
5277
+ k.warn("Idetik", "Idetik runtime already started");
5278
+ else {
5279
+ for (const A of this.viewports_)
5280
+ A.events.connect();
5281
+ this.sizeObserver_.connect(), this.lastAnimationId_ = requestAnimationFrame((A) => {
5282
+ this.lastTimestamp_ = A, this.animate(A);
5283
+ });
5284
+ }
5285
+ return this;
5286
+ }
5287
+ detachRemovedLayers() {
5288
+ for (const [A, I] of this.attachments_)
5289
+ (!this.viewports_.includes(I) || !I.layers.includes(A)) && (A.onDetached(this.context_), this.attachments_.delete(A));
5290
+ }
5291
+ renderViewport(A) {
5292
+ for (const I of A.layers)
5293
+ if (I.attached && this.attachments_.get(I) !== A)
5294
+ throw new Error(
5295
+ `${I.type} is already attached to another viewport or Idetik runtime.`
5296
+ );
5297
+ for (const I of A.layers)
5298
+ I.attached || (I.onAttached(this.context_), this.attachments_.set(I, A));
5299
+ this.renderer_.render(A);
5300
+ }
5301
+ animate(A) {
5302
+ this.stats_ && this.stats_.begin();
5303
+ const I = Math.min(A - this.lastTimestamp_, 100) / 1e3;
5304
+ this.lastTimestamp_ = A, this.detachRemovedLayers(), this.renderer_.beginFrame();
5305
+ for (const B of this.viewports_)
5306
+ B.cameraControls?.onUpdate(I), this.renderViewport(B);
5307
+ this.chunkManager_.update();
5308
+ for (const B of this.overlays)
5309
+ B.update(this);
5310
+ this.stats_ && this.stats_.end(), this.lastAnimationId_ = requestAnimationFrame(
5311
+ (B) => this.animate(B)
5312
+ );
5313
+ }
5314
+ /**
5315
+ * Stops the render loop and disconnects input handlers.
5316
+ */
5317
+ stop() {
5318
+ if (k.info("Idetik", "Idetik runtime stopping"), !this.running)
5319
+ k.warn("Idetik", "Idetik runtime not started");
5320
+ else {
5321
+ this.sizeObserver_.disconnect();
5322
+ for (const A of this.viewports_)
5323
+ A.events.disconnect();
5324
+ cancelAnimationFrame(this.lastAnimationId_), this.lastAnimationId_ = void 0;
5325
+ }
5326
+ }
5327
+ }
5060
5328
  const Cg = [
5061
5329
  "pointerdown",
5062
5330
  "pointermove",
@@ -5064,10 +5332,10 @@ const Cg = [
5064
5332
  "pointercancel",
5065
5333
  "wheel"
5066
5334
  ];
5067
- function DE(g) {
5335
+ function hE(g) {
5068
5336
  return Cg.includes(g);
5069
5337
  }
5070
- class hE {
5338
+ class tE {
5071
5339
  propagationStopped_ = !1;
5072
5340
  type;
5073
5341
  event;
@@ -5084,7 +5352,7 @@ class hE {
5084
5352
  this.propagationStopped_ = !0;
5085
5353
  }
5086
5354
  }
5087
- class tE {
5355
+ class yE {
5088
5356
  listeners_ = [];
5089
5357
  element_;
5090
5358
  isConnected_ = !1;
@@ -5129,17 +5397,17 @@ class tE {
5129
5397
  });
5130
5398
  }
5131
5399
  handleEvent = (A) => {
5132
- if (!DE(A.type)) {
5400
+ if (!hE(A.type)) {
5133
5401
  k.error("EventDispatcher", `Unsupported event type ${A.type}`);
5134
5402
  return;
5135
5403
  }
5136
- const I = new hE(A.type, A);
5404
+ const I = new tE(A.type, A);
5137
5405
  for (const B of this.listeners_)
5138
5406
  if (B(I), I.propagationStopped) break;
5139
5407
  };
5140
5408
  }
5141
- const yE = 1e-12;
5142
- class eE {
5409
+ const eE = 1e-12;
5410
+ class nE {
5143
5411
  origin;
5144
5412
  direction;
5145
5413
  constructor(A, I) {
@@ -5147,43 +5415,37 @@ class eE {
5147
5415
  }
5148
5416
  intersectWithPlane(A) {
5149
5417
  const I = sI(this.direction, A.normal);
5150
- if (Math.abs(I) < yE)
5418
+ if (Math.abs(I) < eE)
5151
5419
  return null;
5152
5420
  const B = -A.signedDistanceToPoint(this.origin) / I;
5153
5421
  return Ag(M(), this.origin, this.direction, B);
5154
5422
  }
5155
5423
  }
5156
- class nE {
5424
+ class Lo {
5157
5425
  /** The viewport's unique identifier. */
5158
5426
  id;
5159
5427
  /** The host element defining the viewport's area. */
5160
- element;
5428
+ domElement;
5161
5429
  /** The camera the viewport renders with. */
5162
5430
  camera;
5163
5431
  /** The pointer and wheel event dispatcher for the host element. */
5164
5432
  events;
5165
5433
  /** Input controls driving the camera. */
5166
5434
  cameraControls;
5167
- // Carried only to relay to `layer.onAttached` / `layer.onDetached`.
5168
- // To be removed when the chunk-infrastructure refactor folds chunk management
5169
- // into the source and the attach lifecycle goes away.
5170
- context_;
5171
5435
  layers_ = [];
5172
- /** @hidden */
5173
5436
  constructor(A) {
5174
- this.id = A.id, this.element = A.element, this.camera = A.camera, this.context_ = A.context, this.cameraControls = A.cameraControls, this.updateAspectRatio(), this.events = new tE(this.element), this.events.addEventListener((I) => {
5437
+ this.id = A.id || A.domElement.id || _B("viewport"), this.domElement = A.domElement, this.camera = A.camera, this.cameraControls = A.cameraControls, this.updateAspectRatio(), this.events = new yE(this.domElement), this.events.addEventListener((I) => {
5175
5438
  if (I.event instanceof PointerEvent || I.event instanceof WheelEvent) {
5176
5439
  const { clientX: B, clientY: C } = I.event, Q = v(B, C);
5177
5440
  I.clipPos = this.clientToClip(Q, 0), I.worldPos = this.camera.clipToWorld(I.clipPos);
5178
5441
  const E = this.camera.clipToWorld(this.clientToClip(Q, -1)), i = this.camera.clipToWorld(this.clientToClip(Q, 1));
5179
- I.worldRay = new eE(E, Gg(M(), i, E));
5442
+ I.worldRay = new nE(E, Gg(M(), i, E));
5180
5443
  }
5181
5444
  for (const B of this.layers_)
5182
5445
  if (B.onEvent(I), I.propagationStopped) return;
5183
5446
  this.cameraControls?.onEvent(I);
5184
5447
  });
5185
- for (const I of A.layers ?? [])
5186
- this.addLayer(I);
5448
+ for (const I of A.layers ?? []) this.addLayer(I);
5187
5449
  }
5188
5450
  /**
5189
5451
  * The layers rendered by this viewport in order. Layers with `occludes`
@@ -5193,12 +5455,15 @@ class nE {
5193
5455
  return this.layers_;
5194
5456
  }
5195
5457
  /**
5196
- * Adds a layer to the top of the stack.
5458
+ * Adds a layer to the top of the stack. Throws if the viewport already
5459
+ * contains the layer.
5197
5460
  *
5198
5461
  * @param layer - The layer to add.
5199
5462
  */
5200
5463
  addLayer(A) {
5201
- A.onAttached(this.context_), this.layers_.push(A);
5464
+ if (this.layers_.includes(A))
5465
+ throw new Error(`${A.type} is already in viewport "${this.id}".`);
5466
+ this.layers_.push(A);
5202
5467
  }
5203
5468
  /**
5204
5469
  * Removes a previously added layer.
@@ -5209,12 +5474,10 @@ class nE {
5209
5474
  const I = this.layers_.indexOf(A);
5210
5475
  if (I === -1)
5211
5476
  throw new Error(`Layer to remove not found: ${A}`);
5212
- this.layers_.splice(I, 1), A.onDetached(this.context_);
5477
+ this.layers_.splice(I, 1);
5213
5478
  }
5214
5479
  /** Removes all layers from the viewport. */
5215
5480
  removeAllLayers() {
5216
- for (const A of this.layers_)
5217
- A.onDetached(this.context_);
5218
5481
  this.layers_ = [];
5219
5482
  }
5220
5483
  /**
@@ -5225,10 +5488,12 @@ class nE {
5225
5488
  this.updateAspectRatio();
5226
5489
  }
5227
5490
  /**
5228
- * Computes the viewport's box relative to the given canvas in device pixels.
5491
+ * Computes the viewport's box relative to the given element in device
5492
+ * pixels, with `y` flipped to match WebGL's bottom-left origin.
5229
5493
  *
5230
- * @param canvas - The canvas to compute the box against.
5231
- * @returns The viewport's box in the canvas's coordinate space.
5494
+ * @param element - The element to compute the box against, typically the
5495
+ * canvas.
5496
+ * @returns The viewport's box in the element's coordinate space.
5232
5497
  */
5233
5498
  getBoxRelativeTo(A) {
5234
5499
  const I = this.getBox().toRect(), B = A.getBoundingClientRect(), C = window.devicePixelRatio || 1, Q = B.left * C, E = B.top * C, i = B.height * C, o = I.x - Q, a = I.y - E, s = Math.floor(o), D = Math.floor(i - a - I.height), h = Math.floor(I.width), t = Math.floor(I.height);
@@ -5238,10 +5503,11 @@ class nE {
5238
5503
  );
5239
5504
  }
5240
5505
  /**
5241
- * The viewport's rectangle in the drawing buffer in device pixels.
5506
+ * The viewport's size in device pixels. Measured relative to its own host
5507
+ * element, so `x` and `y` are always `0`.
5242
5508
  */
5243
5509
  getBufferRect() {
5244
- return this.getBoxRelativeTo(this.element).toRect();
5510
+ return this.getBoxRelativeTo(this.domElement).toRect();
5245
5511
  }
5246
5512
  /**
5247
5513
  * Converts a client-space position to clip space. The `y` axis points
@@ -5251,7 +5517,7 @@ class nE {
5251
5517
  * @param depth - The clip-space z value.
5252
5518
  */
5253
5519
  clientToClip(A, I = 0) {
5254
- const [B, C] = A, Q = this.element.getBoundingClientRect();
5520
+ const [B, C] = A, Q = this.domElement.getBoundingClientRect();
5255
5521
  return x(
5256
5522
  2 * (B - Q.x) / Q.width - 1,
5257
5523
  2 * (C - Q.y) / Q.height - 1,
@@ -5270,7 +5536,7 @@ class nE {
5270
5536
  return this.camera.clipToWorld(B);
5271
5537
  }
5272
5538
  getBox() {
5273
- const A = this.element.getBoundingClientRect(), I = window.devicePixelRatio || 1, B = A.left * I, C = A.top * I, Q = A.width * I, E = A.height * I;
5539
+ const A = this.domElement.getBoundingClientRect(), I = window.devicePixelRatio || 1, B = A.left * I, C = A.top * I, Q = A.width * I, E = A.height * I;
5274
5540
  return new AA(
5275
5541
  v(B, C),
5276
5542
  v(B + Q, C + E)
@@ -5289,262 +5555,7 @@ class nE {
5289
5555
  this.camera.setAspectRatio(B);
5290
5556
  }
5291
5557
  }
5292
- function hC(g, A) {
5293
- for (const I of A) {
5294
- if (I.id === g.id)
5295
- throw new Error(
5296
- `Duplicate viewport ID "${g.id}". Each viewport must have a unique ID.`
5297
- );
5298
- if (I.element === g.element) {
5299
- const B = g.element.tagName.toLowerCase() + (g.element.id ? `#${g.element.id}` : "[element has no id]");
5300
- throw new Error(
5301
- `Multiple viewports cannot share the same HTML element: viewports "${I.id}" and "${g.id}" both use ${B}`
5302
- );
5303
- }
5304
- }
5305
- }
5306
- function GE(g) {
5307
- for (let A = 0; A < g.length; A++)
5308
- hC(g[A], g.slice(0, A));
5309
- }
5310
- function sB(g, A, I) {
5311
- const B = g.map((C) => {
5312
- const Q = C.element ?? A;
5313
- return {
5314
- ...C,
5315
- element: Q,
5316
- id: C.id ?? Q.id ?? _B("viewport"),
5317
- context: I
5318
- };
5319
- });
5320
- return GE(B), B.map((C) => new nE(C));
5321
- }
5322
- class wE {
5323
- elements_;
5324
- resizeObserver_;
5325
- mediaQuery_;
5326
- onMediaQueryChange_;
5327
- onChange_;
5328
- constructor(A = [], I) {
5329
- this.elements_ = [...A], this.onChange_ = I;
5330
- }
5331
- connect() {
5332
- if (this.resizeObserver_) {
5333
- k.warn(
5334
- "PixelSizeObserver",
5335
- "Attempted to connect already connected observer"
5336
- );
5337
- return;
5338
- }
5339
- this.resizeObserver_ = new ResizeObserver(() => {
5340
- this.onChange_();
5341
- });
5342
- for (const A of this.elements_)
5343
- this.resizeObserver_.observe(A);
5344
- this.startDevicePixelRatioObserver();
5345
- }
5346
- startDevicePixelRatioObserver() {
5347
- this.mediaQuery_ = matchMedia(
5348
- `(resolution: ${window.devicePixelRatio}dppx)`
5349
- ), this.onMediaQueryChange_ = () => {
5350
- this.onChange_(), this.startDevicePixelRatioObserver();
5351
- }, this.mediaQuery_.addEventListener("change", this.onMediaQueryChange_, {
5352
- once: !0
5353
- });
5354
- }
5355
- disconnect() {
5356
- if (!this.resizeObserver_) {
5357
- k.warn(
5358
- "PixelSizeObserver",
5359
- "Attempted to disconnect already disconnected observer"
5360
- );
5361
- return;
5362
- }
5363
- this.resizeObserver_?.disconnect(), this.mediaQuery_ && this.onMediaQueryChange_ && this.mediaQuery_.removeEventListener("change", this.onMediaQueryChange_);
5364
- }
5365
- observe(A) {
5366
- if (this.elements_.includes(A)) {
5367
- k.warn("PixelSizeObserver", "Element already being observed");
5368
- return;
5369
- }
5370
- this.elements_.push(A), this.resizeObserver_ && this.resizeObserver_.observe(A);
5371
- }
5372
- unobserve(A) {
5373
- const I = this.elements_.indexOf(A);
5374
- if (I === -1) {
5375
- k.warn("PixelSizeObserver", "Element not being observed");
5376
- return;
5377
- }
5378
- this.elements_.splice(I, 1), this.resizeObserver_ && this.resizeObserver_.unobserve(A);
5379
- }
5380
- }
5381
- const FE = 2048;
5382
- class Yo {
5383
- /** The canvas element the renderer draws into. */
5384
- canvas;
5385
- /** The registered overlays that update once per frame in order. */
5386
- overlays;
5387
- /** Memory, queue, chunk, and rendered-object statistics. */
5388
- stats;
5389
- chunkManager_;
5390
- context_;
5391
- renderer_;
5392
- viewports_;
5393
- stats_;
5394
- sizeObserver_;
5395
- lastAnimationId_;
5396
- lastTimestamp_ = 0;
5397
- /**
5398
- * Creates an Idetik runtime for the given canvas.
5399
- *
5400
- * @param params - Initialization properties.
5401
- */
5402
- constructor(A) {
5403
- this.canvas = A.canvas, this.renderer_ = new LQ(this.canvas);
5404
- const B = (A.memoryLimitMB ?? FE) * 1024 * 1024;
5405
- this.chunkManager_ = new TQ(
5406
- (Q) => this.renderer_.uploadTexture(Q),
5407
- (Q) => this.renderer_.disposeTexture(Q),
5408
- () => this.renderer_.gpuTextureBytes,
5409
- B,
5410
- A.maxConcurrentRequests,
5411
- A.maxGpuUploadsPerUpdate
5412
- ), this.context_ = {
5413
- chunkManager: this.chunkManager_
5414
- }, this.viewports_ = sB(
5415
- A.viewports ?? [],
5416
- this.canvas,
5417
- this.context_
5418
- ), this.overlays = [...A.overlays ?? []], this.stats = new aE(this.renderer_, this.chunkManager_, this.viewports_), A.showStats && (this.stats_ = sE());
5419
- const C = [this.canvas];
5420
- for (const Q of this.viewports_)
5421
- Q.element !== this.canvas && C.push(Q.element);
5422
- this.sizeObserver_ = new wE(C, () => {
5423
- this.renderer_.updateSize(), this.renderer_.beginFrame();
5424
- for (const Q of this.viewports_)
5425
- Q.updateSize(), this.renderer_.render(Q);
5426
- });
5427
- }
5428
- /** The width of the rendering surface in pixels. */
5429
- get width() {
5430
- return this.renderer_.width;
5431
- }
5432
- /** The height of the rendering surface in pixels. */
5433
- get height() {
5434
- return this.renderer_.height;
5435
- }
5436
- /** The viewports in render order. */
5437
- get viewports() {
5438
- return this.viewports_;
5439
- }
5440
- /** Whether the render loop is running. */
5441
- get running() {
5442
- return this.lastAnimationId_ !== void 0;
5443
- }
5444
- /**
5445
- * Finds a viewport by its id.
5446
- *
5447
- * @param id - The id given in the viewport's definition.
5448
- * @returns The matching viewport or `undefined` if none matches.
5449
- */
5450
- getViewport(A) {
5451
- return this.viewports_.find((I) => I.id === A);
5452
- }
5453
- /**
5454
- * Adds a viewport at runtime.
5455
- *
5456
- * @param props - The viewport definition. The `element` defaults to the
5457
- * canvas and must be unique across viewports.
5458
- * @returns The created viewport.
5459
- */
5460
- addViewport(A) {
5461
- const [I] = sB([A], this.canvas, this.context_);
5462
- return hC(I, this.viewports_), this.viewports_.push(I), this.running && (I.events.connect(), I.element !== this.canvas && this.sizeObserver_.observe(I.element)), k.info("Idetik", `Added viewport "${I.id}"`), I;
5463
- }
5464
- /**
5465
- * Removes a previously added viewport.
5466
- *
5467
- * @param viewport - The viewport to remove.
5468
- * @returns `true` if the viewport was found and removed.
5469
- */
5470
- removeViewport(A) {
5471
- const I = this.viewports_.indexOf(A);
5472
- return I === -1 ? (k.warn(
5473
- "Idetik",
5474
- `Viewport "${A.id}" not found, nothing to remove`
5475
- ), !1) : (this.running && (A.events.disconnect(), A.element !== this.canvas && this.sizeObserver_.unobserve(A.element)), this.viewports_.splice(I, 1), k.info("Idetik", `Removed viewport "${A.id}"`), !0);
5476
- }
5477
- /**
5478
- * Registers an overlay that updates once per frame.
5479
- *
5480
- * @param overlay - The overlay to add.
5481
- */
5482
- addOverlay(A) {
5483
- this.overlays.push(A);
5484
- }
5485
- /**
5486
- * Removes a previously added overlay.
5487
- *
5488
- * @param overlay - The overlay to remove.
5489
- * @returns `true` if the overlay was found and removed.
5490
- */
5491
- removeOverlay(A) {
5492
- const I = this.overlays.indexOf(A);
5493
- return I === -1 ? (k.warn("Idetik", "Overlay not found, nothing to remove"), !1) : (this.overlays.splice(I, 1), !0);
5494
- }
5495
- /**
5496
- * Sets the memory budget for chunk data at runtime.
5497
- *
5498
- * @param memoryLimitMB - The new budget in megabytes.
5499
- */
5500
- setMemoryLimitMB(A) {
5501
- this.chunkManager_.memoryLimitBytes = A * 1024 * 1024;
5502
- }
5503
- /**
5504
- * Starts the render loop and connects input handlers.
5505
- *
5506
- * @returns The instance, for chaining.
5507
- */
5508
- start() {
5509
- if (k.info("Idetik", "Idetik runtime starting"), this.running)
5510
- k.warn("Idetik", "Idetik runtime already started");
5511
- else {
5512
- for (const A of this.viewports_)
5513
- A.events.connect();
5514
- this.sizeObserver_.connect(), this.lastAnimationId_ = requestAnimationFrame((A) => {
5515
- this.lastTimestamp_ = A, this.animate(A);
5516
- });
5517
- }
5518
- return this;
5519
- }
5520
- animate(A) {
5521
- this.stats_ && this.stats_.begin();
5522
- const I = Math.min(A - this.lastTimestamp_, 100) / 1e3;
5523
- this.lastTimestamp_ = A, this.renderer_.beginFrame();
5524
- for (const B of this.viewports_)
5525
- B.cameraControls?.onUpdate(I), this.renderer_.render(B);
5526
- this.chunkManager_.update();
5527
- for (const B of this.overlays)
5528
- B.update(this);
5529
- this.stats_ && this.stats_.end(), this.lastAnimationId_ = requestAnimationFrame(
5530
- (B) => this.animate(B)
5531
- );
5532
- }
5533
- /**
5534
- * Stops the render loop and disconnects input handlers.
5535
- */
5536
- stop() {
5537
- if (k.info("Idetik", "Idetik runtime stopping"), !this.running)
5538
- k.warn("Idetik", "Idetik runtime not started");
5539
- else {
5540
- this.sizeObserver_.disconnect();
5541
- for (const A of this.viewports_)
5542
- A.events.disconnect();
5543
- cancelAnimationFrame(this.lastAnimationId_), this.lastAnimationId_ = void 0;
5544
- }
5545
- }
5546
- }
5547
- function rE(g, A) {
5558
+ function GE(g, A) {
5548
5559
  return {
5549
5560
  ...g,
5550
5561
  ...A,
@@ -5576,7 +5587,7 @@ class _A {
5576
5587
  this.url = A, this.#A = I.fetch ?? ((B) => fetch(B)), this.#I = I.overrides ?? {}, this.#g = I.useSuffixRequest ?? !1;
5577
5588
  }
5578
5589
  #B(A, I) {
5579
- return new Request(A, rE(this.#I, I));
5590
+ return new Request(A, GE(this.#I, I));
5580
5591
  }
5581
5592
  async get(A, I = {}) {
5582
5593
  let B = DB(this.url, A).href, C = this.#B(B, I), Q = await this.#A(C);
@@ -5641,7 +5652,7 @@ class X extends $A {
5641
5652
  super(A, { cause: I.cause }), this.path = I.path;
5642
5653
  }
5643
5654
  }
5644
- class SE extends $A {
5655
+ class wE extends $A {
5645
5656
  _tag = "UnknownCodecError";
5646
5657
  name = "UnknownCodecError";
5647
5658
  codec;
@@ -5649,7 +5660,7 @@ class SE extends $A {
5649
5660
  super(`Unknown codec: ${A}`), this.codec = A;
5650
5661
  }
5651
5662
  }
5652
- class RE extends $A {
5663
+ class FE extends $A {
5653
5664
  _tag = "CodecPipelineError";
5654
5665
  name = "CodecPipelineError";
5655
5666
  direction;
@@ -5699,7 +5710,7 @@ class GI {
5699
5710
  function Mg(g) {
5700
5711
  return g instanceof ArrayBuffer || g instanceof SharedArrayBuffer;
5701
5712
  }
5702
- class tC {
5713
+ class hC {
5703
5714
  #A;
5704
5715
  constructor(A, I, B) {
5705
5716
  typeof A == "number" ? this.#A = new Uint8Array(A) : Mg(A) ? this.#A = new Uint8Array(A, I, B) : this.#A = new Uint8Array(Array.from(A, (C) => C ? 1 : 0));
@@ -5838,11 +5849,11 @@ class AI {
5838
5849
  yield this.get(A);
5839
5850
  }
5840
5851
  }
5841
- function cE() {
5852
+ function rE() {
5842
5853
  if (typeof SharedArrayBuffer > "u")
5843
5854
  throw new Error("SharedArrayBuffer is not available. In browsers, this requires Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers to be set.");
5844
5855
  }
5845
- function NE(g, A) {
5856
+ function SE(g, A) {
5846
5857
  return new SharedArrayBuffer(g);
5847
5858
  }
5848
5859
  function II(g) {
@@ -5882,7 +5893,7 @@ function mA(g) {
5882
5893
  float16: globalThis.Float16Array,
5883
5894
  float32: Float32Array,
5884
5895
  float64: Float64Array,
5885
- bool: tC
5896
+ bool: hC
5886
5897
  }[g];
5887
5898
  if (!I)
5888
5899
  throw new X(`Unknown or unsupported dataType: ${g}`);
@@ -5896,7 +5907,7 @@ function SA(g, A) {
5896
5907
  C[A[Q]] = B, B *= g[A[Q]];
5897
5908
  return C;
5898
5909
  }
5899
- function UE({ name: g, configuration: A }) {
5910
+ function RE({ name: g, configuration: A }) {
5900
5911
  if (g === "default") {
5901
5912
  const I = A?.separator ?? "/";
5902
5913
  return (B) => ["c", ...B].join(I);
@@ -5931,15 +5942,15 @@ function yB(g) {
5931
5942
  throw new X(`Unsupported or unknown dtype: ${g}`);
5932
5943
  return I === "|" ? { dataType: C } : { dataType: C, endian: I === "<" ? "little" : "big" };
5933
5944
  }
5934
- function kE(g) {
5945
+ function cE(g) {
5935
5946
  return (g.id === "fixedscaleoffset" || g.id === "numcodecs.fixedscaleoffset") && typeof g.scale == "number" && typeof g.offset == "number" && (g.astype === void 0 || typeof g.astype == "string") && (g.dtype === void 0 || typeof g.dtype == "string");
5936
5947
  }
5937
- function LE(g, A = {}) {
5948
+ function NE(g, A = {}) {
5938
5949
  let I = [], B = yB(g.dtype);
5939
5950
  g.order === "F" && I.push({ name: "transpose", configuration: { order: "F" } });
5940
5951
  for (let Q of g.filters ?? []) {
5941
5952
  if (Q.id === "fixedscaleoffset" || Q.id === "numcodecs.fixedscaleoffset") {
5942
- if (!kE(Q))
5953
+ if (!cE(Q))
5943
5954
  throw new X(`Invalid fixedscaleoffset filter: ${JSON.stringify(Q)}`);
5944
5955
  I.push({
5945
5956
  name: "scale_offset",
@@ -5997,7 +6008,7 @@ function LE(g, A = {}) {
5997
6008
  attributes: A
5998
6009
  };
5999
6010
  }
6000
- function JE(g, A = {}) {
6011
+ function UE(g, A = {}) {
6001
6012
  return {
6002
6013
  zarr_format: 3,
6003
6014
  node_type: "group",
@@ -6019,10 +6030,10 @@ function Qg(g, A) {
6019
6030
  let Q = g === "v2:object";
6020
6031
  return A === "object" ? Q : !B && !C && !I && !Q;
6021
6032
  }
6022
- function YE(g) {
6033
+ function kE(g) {
6023
6034
  return g?.name === "sharding_indexed";
6024
6035
  }
6025
- function yC(g) {
6036
+ function tC(g) {
6026
6037
  if ((g.data_type === "uint64" || g.data_type === "int64") && g.fill_value != null)
6027
6038
  return BigInt(g.fill_value);
6028
6039
  let A = g.data_type === "float16" || g.data_type === "float32" || g.data_type === "float64";
@@ -6037,7 +6048,7 @@ function yC(g) {
6037
6048
  }
6038
6049
  return g.fill_value;
6039
6050
  }
6040
- function eC(g, ...A) {
6051
+ function yC(g, ...A) {
6041
6052
  if (!A.some((I) => g instanceof I))
6042
6053
  throw g;
6043
6054
  }
@@ -6045,7 +6056,7 @@ function IA(g, A = "") {
6045
6056
  if (!g)
6046
6057
  throw new Error(A);
6047
6058
  }
6048
- async function nC(g, { format: A, signal: I }) {
6059
+ async function eC(g, { format: A, signal: I }) {
6049
6060
  let B;
6050
6061
  if (g instanceof ArrayBuffer)
6051
6062
  B = new Response(g);
@@ -6060,8 +6071,8 @@ async function nC(g, { format: A, signal: I }) {
6060
6071
  throw I?.throwIfAborted(), new Error(`Failed to decode ${A}`);
6061
6072
  }
6062
6073
  }
6063
- const eB = dE();
6064
- function dE() {
6074
+ const eB = LE();
6075
+ function LE() {
6065
6076
  const g = new Uint32Array([305419896]);
6066
6077
  return new Uint8Array(g.buffer, g.byteOffset, g.byteLength)[0] !== 18;
6067
6078
  }
@@ -6102,18 +6113,18 @@ const GB = {
6102
6113
  NaN: NaN,
6103
6114
  Infinity: 1 / 0,
6104
6115
  "-Infinity": -1 / 0
6105
- }, GC = {
6116
+ }, nC = {
6106
6117
  float16: 2,
6107
6118
  float32: 4,
6108
6119
  float64: 8
6109
6120
  };
6110
6121
  function wI(g) {
6111
- return g in GC;
6122
+ return g in nC;
6112
6123
  }
6113
6124
  function Eg(g) {
6114
6125
  return g === "int64" || g === "uint64";
6115
6126
  }
6116
- function ME(g, A) {
6127
+ function JE(g, A) {
6117
6128
  const I = BigInt(g), B = new ArrayBuffer(A), C = new DataView(B);
6118
6129
  if (A === 2) {
6119
6130
  if (typeof C.getFloat16 != "function")
@@ -6135,7 +6146,7 @@ function FI(g, A) {
6135
6146
  }
6136
6147
  if (!wI(g))
6137
6148
  throw new X(`String-encoded scalar "${A}" is not valid for non-float data type "${g}"`);
6138
- return A in GB ? GB[A] : ME(A, GC[g]);
6149
+ return A in GB ? GB[A] : JE(A, nC[g]);
6139
6150
  }
6140
6151
  const wB = /* @__PURE__ */ new Set([
6141
6152
  "int8",
@@ -6166,7 +6177,7 @@ function FB(g, A, I) {
6166
6177
  tgt: FI(I, C)
6167
6178
  }));
6168
6179
  }
6169
- function KE(g, A) {
6180
+ function YE(g, A) {
6170
6181
  for (const I of A)
6171
6182
  if (typeof I.src == "number" && Number.isNaN(I.src)) {
6172
6183
  if (typeof g == "number" && Number.isNaN(g))
@@ -6174,7 +6185,7 @@ function KE(g, A) {
6174
6185
  } else if (g === I.src)
6175
6186
  return I.tgt;
6176
6187
  }
6177
- function HE(g) {
6188
+ function dE(g) {
6178
6189
  if (!Number.isFinite(g))
6179
6190
  return g;
6180
6191
  if (Math.abs(g - Math.trunc(g)) === 0.5) {
@@ -6183,13 +6194,13 @@ function HE(g) {
6183
6194
  }
6184
6195
  return Math.round(g);
6185
6196
  }
6186
- function qE(g) {
6197
+ function ME(g) {
6187
6198
  return Math.sign(g) * Math.floor(Math.abs(g) + 0.5);
6188
6199
  }
6189
6200
  function rB(g) {
6190
6201
  switch (g) {
6191
6202
  case "nearest-even":
6192
- return HE;
6203
+ return dE;
6193
6204
  case "towards-zero":
6194
6205
  return Math.trunc;
6195
6206
  case "towards-positive":
@@ -6197,7 +6208,7 @@ function rB(g) {
6197
6208
  case "towards-negative":
6198
6209
  return Math.floor;
6199
6210
  case "nearest-away":
6200
- return qE;
6211
+ return ME;
6201
6212
  }
6202
6213
  }
6203
6214
  function PI(g, A, I) {
@@ -6299,7 +6310,7 @@ function SB(g, A, I, B, C) {
6299
6310
  else
6300
6311
  throw new Error(`Unhandled type combination: ${g} -> ${A}`);
6301
6312
  return C.length === 0 ? a : (D) => {
6302
- const h = KE(D, C);
6313
+ const h = YE(D, C);
6303
6314
  return h !== void 0 ? h : a(D);
6304
6315
  };
6305
6316
  }
@@ -6316,7 +6327,7 @@ class qg {
6316
6327
  return A + 4;
6317
6328
  }
6318
6329
  }
6319
- const lE = /* @__PURE__ */ new Set([
6330
+ const KE = /* @__PURE__ */ new Set([
6320
6331
  "int8",
6321
6332
  "uint8",
6322
6333
  "int16",
@@ -6349,7 +6360,7 @@ class lg {
6349
6360
  this.#A = A;
6350
6361
  }
6351
6362
  static fromConfig(A, I) {
6352
- if (!lE.has(I.dataType))
6363
+ if (!KE.has(I.dataType))
6353
6364
  throw new X(`Delta codec does not support data type: ${I.dataType}`);
6354
6365
  return new lg(mA(I.dataType));
6355
6366
  }
@@ -6377,14 +6388,14 @@ class fg {
6377
6388
  }
6378
6389
  encode = NA("gzip");
6379
6390
  async decode(A) {
6380
- const I = await nC(A, { format: "gzip" });
6391
+ const I = await eC(A, { format: "gzip" });
6381
6392
  return new Uint8Array(I);
6382
6393
  }
6383
6394
  }
6384
- function fE(g, A) {
6395
+ function HE(g, A) {
6385
6396
  return IA(!Number.isNaN(A), "JsonCodec allow_nan is false but NaN was encountered during encoding."), IA(A !== Number.POSITIVE_INFINITY, "JsonCodec allow_nan is false but Infinity was encountered during encoding."), IA(A !== Number.NEGATIVE_INFINITY, "JsonCodec allow_nan is false but -Infinity was encountered during encoding."), A;
6386
6397
  }
6387
- function pE(g, A) {
6398
+ function qE(g, A) {
6388
6399
  return A instanceof Object && !Array.isArray(A) ? Object.keys(A).sort().reduce((I, B) => (I[B] = A[B], I), {}) : A;
6389
6400
  }
6390
6401
  class rI {
@@ -6414,7 +6425,7 @@ class rI {
6414
6425
  const { indent: I, encoding: B, ensure_ascii: C, check_circular: Q, allow_nan: E, sort_keys: i } = this.#A;
6415
6426
  IA(B === "utf-8", "JsonCodec does not yet support non-utf-8 encoding.");
6416
6427
  const o = [];
6417
- IA(Q, "JsonCodec does not yet support skipping the check for circular references during encoding."), E || o.push(fE), i && o.push(pE);
6428
+ IA(Q, "JsonCodec does not yet support skipping the check for circular references during encoding."), E || o.push(HE), i && o.push(qE);
6418
6429
  const a = Array.from(A.data);
6419
6430
  a.push("|O"), a.push(A.shape);
6420
6431
  let s;
@@ -6439,7 +6450,7 @@ class rI {
6439
6450
  return { data: B, shape: C, stride: Q };
6440
6451
  }
6441
6452
  }
6442
- const uE = /* @__PURE__ */ new Set([
6453
+ const lE = /* @__PURE__ */ new Set([
6443
6454
  "int8",
6444
6455
  "uint8",
6445
6456
  "int16",
@@ -6461,7 +6472,7 @@ class pg {
6461
6472
  this.#I = A, this.#g = I, this.#A = B;
6462
6473
  }
6463
6474
  static fromConfig(A, I) {
6464
- if (!uE.has(I.dataType))
6475
+ if (!lE.has(I.dataType))
6465
6476
  throw new X(`scale_offset codec does not support data type: ${I.dataType}`);
6466
6477
  return new pg(FI(I.dataType, A.scale ?? 1), FI(I.dataType, A.offset ?? 0), mA(I.dataType));
6467
6478
  }
@@ -6487,20 +6498,20 @@ class ug {
6487
6498
  return new ug(A, I);
6488
6499
  }
6489
6500
  encode(A) {
6490
- return mE(A, this.#A);
6501
+ return fE(A, this.#A);
6491
6502
  }
6492
6503
  decode(A) {
6493
- return TE(A, this.#A);
6504
+ return pE(A, this.#A);
6494
6505
  }
6495
6506
  }
6496
- function mE(g, A) {
6507
+ function fE(g, A) {
6497
6508
  let I = g.length, B = Math.floor(I / A), C = new Uint8Array(I);
6498
6509
  for (let Q = 0; Q < A; Q++)
6499
6510
  for (let E = 0; E < B; E++)
6500
6511
  C[Q * B + E] = g[E * A + Q];
6501
6512
  return C;
6502
6513
  }
6503
- function TE(g, A) {
6514
+ function pE(g, A) {
6504
6515
  let I = g.length, B = Math.floor(I / A), C = new Uint8Array(I);
6505
6516
  for (let Q = 0; Q < A; Q++)
6506
6517
  for (let E = 0; E < B; E++)
@@ -6508,7 +6519,7 @@ function TE(g, A) {
6508
6519
  return C;
6509
6520
  }
6510
6521
  function cB(g) {
6511
- return g instanceof tC || g instanceof Kg || g instanceof AI ? new Proxy(g, {
6522
+ return g instanceof hC || g instanceof Kg || g instanceof AI ? new Proxy(g, {
6512
6523
  get(I, B) {
6513
6524
  return I.get(Number(B));
6514
6525
  },
@@ -6517,7 +6528,7 @@ function cB(g) {
6517
6528
  }
6518
6529
  }) : g;
6519
6530
  }
6520
- function xE(g, A) {
6531
+ function uE(g, A) {
6521
6532
  let I;
6522
6533
  return g.data instanceof Kg || g.data instanceof AI ? I = new g.constructor(
6523
6534
  // @ts-expect-error
@@ -6529,8 +6540,8 @@ function xE(g, A) {
6529
6540
  stride: SA(g.shape, A)
6530
6541
  };
6531
6542
  }
6532
- function WE(g, A) {
6533
- let I = xE(g, A), B = g.shape.length, C = g.data.length, Q = Array(B).fill(0), E = cB(g.data), i = cB(I.data);
6543
+ function mE(g, A) {
6544
+ let I = uE(g, A), B = g.shape.length, C = g.data.length, Q = Array(B).fill(0), E = cB(g.data), i = cB(I.data);
6534
6545
  for (let o = 0; o < C; o++) {
6535
6546
  let a = 0;
6536
6547
  for (let s = 0; s < B; s++)
@@ -6545,12 +6556,12 @@ function WE(g, A) {
6545
6556
  }
6546
6557
  return I;
6547
6558
  }
6548
- function bE(g) {
6559
+ function TE(g) {
6549
6560
  let A = g.shape.length;
6550
6561
  return IA(A === g.stride.length, "Shape and stride must have the same length."), g.stride.map((I, B) => ({ stride: I, index: B })).sort((I, B) => B.stride - I.stride).map((I) => I.index);
6551
6562
  }
6552
- function ZE(g, A) {
6553
- let I = bE(g);
6563
+ function xE(g, A) {
6564
+ let I = TE(g);
6554
6565
  return IA(I.length === A.length, "Orders must match"), I.every((B, C) => B === A[C]);
6555
6566
  }
6556
6567
  class mg {
@@ -6575,7 +6586,7 @@ class mg {
6575
6586
  return new mg(A, I);
6576
6587
  }
6577
6588
  encode(A) {
6578
- return ZE(A, this.#I) ? A : WE(A, this.#I);
6589
+ return xE(A, this.#I) ? A : mE(A, this.#I);
6579
6590
  }
6580
6591
  decode(A) {
6581
6592
  return {
@@ -6612,25 +6623,25 @@ class Tg {
6612
6623
  }
6613
6624
  encode = NA("zlib");
6614
6625
  async decode(A) {
6615
- const I = await nC(A, { format: "deflate" });
6626
+ const I = await eC(A, { format: "deflate" });
6616
6627
  return new Uint8Array(I);
6617
6628
  }
6618
6629
  }
6619
- function PE() {
6630
+ function WE() {
6620
6631
  let g = () => import("./blosc-D1xNXZJs.js").then((Q) => Q.default), A = () => import("./lz4-1Ws5oVWR.js").then((Q) => Q.default), I = () => import("./zstd-C4EcZnjq.js").then((Q) => Q.default), B = () => fg, C = () => Tg;
6621
6632
  return (/* @__PURE__ */ new Map()).set("blosc", g).set("lz4", A).set("zstd", I).set("gzip", B).set("zlib", C).set("transpose", () => mg).set("bytes", () => HI).set("crc32c", () => qg).set("vlen-utf8", () => SI).set("json2", () => rI).set("bitround", () => GI).set("cast_value", () => Hg).set("scale_offset", () => pg).set("numcodecs.blosc", g).set("numcodecs.lz4", A).set("numcodecs.zstd", I).set("numcodecs.gzip", B).set("numcodecs.zlib", C).set("numcodecs.vlen-utf8", () => SI).set("numcodecs.shuffle", () => ug).set("numcodecs.delta", () => lg).set("numcodecs.bitround", () => GI).set("numcodecs.json2", () => rI);
6622
6633
  }
6623
- const OE = PE();
6634
+ const bE = WE();
6624
6635
  function ig(g) {
6625
6636
  let A;
6626
6637
  function I() {
6627
- return A || (A = VE(g)), A;
6638
+ return A || (A = ZE(g)), A;
6628
6639
  }
6629
6640
  async function B(C, Q, E) {
6630
6641
  try {
6631
6642
  return await E();
6632
6643
  } catch (i) {
6633
- throw new RE({ direction: C, codec: Q, cause: i });
6644
+ throw new FE({ direction: C, codec: Q, cause: i });
6634
6645
  }
6635
6646
  }
6636
6647
  return {
@@ -6669,11 +6680,11 @@ function NB(g, A, I) {
6669
6680
  throw new X(`Codec "${g}" cannot compute its encoded size; it is not a fixed-size codec and cannot be used in a sharding index pipeline`);
6670
6681
  return A.computeEncodedSize(I);
6671
6682
  }
6672
- async function VE(g) {
6683
+ async function ZE(g) {
6673
6684
  let A = g.codecs.map(async (E) => {
6674
- let i = await OE.get(E.name)?.();
6685
+ let i = await bE.get(E.name)?.();
6675
6686
  if (!i)
6676
- throw new SE(E.name);
6687
+ throw new wE(E.name);
6677
6688
  return { Codec: i, meta: E };
6678
6689
  }), I = [], B, C = [], Q = { ...g };
6679
6690
  for await (let { Codec: E, meta: i } of A) {
@@ -6699,7 +6710,7 @@ async function VE(g) {
6699
6710
  }
6700
6711
  }
6701
6712
  if (!B) {
6702
- if (!vE(Q))
6713
+ if (!PE(Q))
6703
6714
  throw new X(`Cannot encode ${Q.dataType} to bytes without a codec`);
6704
6715
  B = {
6705
6716
  name: "bytes",
@@ -6712,11 +6723,11 @@ async function VE(g) {
6712
6723
  bytesToBytes: C
6713
6724
  };
6714
6725
  }
6715
- function vE(g) {
6726
+ function PE(g) {
6716
6727
  return g.dataType !== "v2:object" && g.dataType !== "string";
6717
6728
  }
6718
6729
  const UB = 18446744073709551615n;
6719
- function XE(g, A, I, B) {
6730
+ function OE(g, A, I, B) {
6720
6731
  if (!g.store.getRange)
6721
6732
  throw new dg("sharding requires a store with getRange");
6722
6733
  let C = g.store.getRange.bind(g.store), Q = A.map((a, s) => a / B.chunk_shape[s]), E = ig({
@@ -6769,9 +6780,9 @@ function kB(g) {
6769
6780
  return g.find((I) => I.name === "transpose")?.configuration?.order ?? "C";
6770
6781
  }
6771
6782
  const CI = Symbol("zarrita.context");
6772
- function jE(g, A) {
6773
- let { configuration: I } = A.codecs.find(YE) ?? {}, B = {
6774
- encodeChunkKey: UE(A.chunk_key_encoding),
6783
+ function VE(g, A) {
6784
+ let { configuration: I } = A.codecs.find(kE) ?? {}, B = {
6785
+ encodeChunkKey: RE(A.chunk_key_encoding),
6775
6786
  TypedArray: mA(A.data_type),
6776
6787
  fillValue: A.fill_value
6777
6788
  };
@@ -6790,7 +6801,7 @@ function jE(g, A) {
6790
6801
  getStrides(E) {
6791
6802
  return SA(E, Q);
6792
6803
  },
6793
- getChunkBytes: XE(g, A.chunk_grid.configuration.chunk_shape, B.encodeChunkKey, I)
6804
+ getChunkBytes: OE(g, A.chunk_grid.configuration.chunk_shape, B.encodeChunkKey, I)
6794
6805
  };
6795
6806
  }
6796
6807
  let C = kB(A.codecs);
@@ -6820,8 +6831,8 @@ let RI = class extends CA {
6820
6831
  constructor(A, I, B) {
6821
6832
  super(A, I), this.#A = {
6822
6833
  ...B,
6823
- fill_value: yC(B)
6824
- }, this[CI] = jE(this, this.#A);
6834
+ fill_value: tC(B)
6835
+ }, this[CI] = VE(this, this.#A);
6825
6836
  }
6826
6837
  get attrs() {
6827
6838
  return this.#A.attributes;
@@ -6842,7 +6853,7 @@ let RI = class extends CA {
6842
6853
  return this.#A.data_type;
6843
6854
  }
6844
6855
  async getChunk(A, I, B) {
6845
- B?.useSharedArrayBuffer && cE();
6856
+ B?.useSharedArrayBuffer && rE();
6846
6857
  let C = this[CI], Q = await C.getChunkBytes(A, I);
6847
6858
  if (!Q) {
6848
6859
  let E = C.chunkShape.reduce((o, a) => o * a, 1), i;
@@ -6851,7 +6862,7 @@ let RI = class extends CA {
6851
6862
  if (!("BYTES_PER_ELEMENT" in o))
6852
6863
  console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."), i = new C.TypedArray(E);
6853
6864
  else {
6854
- let a = NE(E * o.BYTES_PER_ELEMENT);
6865
+ let a = SE(E * o.BYTES_PER_ELEMENT);
6855
6866
  i = new C.TypedArray(a, 0, E);
6856
6867
  }
6857
6868
  } else
@@ -6885,21 +6896,21 @@ let RI = class extends CA {
6885
6896
  return Qg(this.dtype, A);
6886
6897
  }
6887
6898
  };
6888
- function zE(g, A) {
6899
+ function vE(g, A) {
6889
6900
  let I = g;
6890
6901
  for (let B of A)
6891
6902
  I instanceof Promise ? I = I.then((C) => B(C)) : I = B(I);
6892
6903
  return I;
6893
6904
  }
6894
- function _E(g, ...A) {
6895
- return zE(g, A);
6905
+ function XE(g, ...A) {
6906
+ return vE(g, A);
6896
6907
  }
6897
- async function wC(g) {
6908
+ async function GC(g) {
6898
6909
  let A = g.store.arrayExtensions;
6899
- return A?.length ? await _E(g, ...A) : g;
6910
+ return A?.length ? await XE(g, ...A) : g;
6900
6911
  }
6901
- let qI = $E();
6902
- function $E() {
6912
+ let qI = jE();
6913
+ function jE() {
6903
6914
  let g = /* @__PURE__ */ new WeakMap();
6904
6915
  function A(I) {
6905
6916
  let B = g.get(I) ?? { v2: 0, v3: 0 };
@@ -6915,37 +6926,37 @@ function $E() {
6915
6926
  }
6916
6927
  };
6917
6928
  }
6918
- async function Ai(g, A) {
6929
+ async function zE(g, A) {
6919
6930
  let I = await g.store.get(g.resolve(".zattrs").path, {
6920
6931
  signal: A
6921
6932
  });
6922
6933
  return I ? II(I) : {};
6923
6934
  }
6924
- async function Ii(g, A = {}) {
6935
+ async function _E(g, A = {}) {
6925
6936
  let I = "store" in g ? g : new CA(g), { signal: B } = A, C = {};
6926
- return (A.attrs ?? !0) && (C = await Ai(I, B)), B?.throwIfAborted(), A.kind === "array" ? LB(I, C, B) : A.kind === "group" ? JB(I, C, B) : LB(I, C, B).catch((Q) => (eC(Q, uA, X), JB(I, C, B)));
6937
+ return (A.attrs ?? !0) && (C = await zE(I, B)), B?.throwIfAborted(), A.kind === "array" ? LB(I, C, B) : A.kind === "group" ? JB(I, C, B) : LB(I, C, B).catch((Q) => (yC(Q, uA, X), JB(I, C, B)));
6927
6938
  }
6928
6939
  async function LB(g, A, I) {
6929
6940
  let { path: B } = g.resolve(".zarray"), C = await g.store.get(B, { signal: I });
6930
6941
  if (!C)
6931
6942
  throw new uA("v2 array", { path: B });
6932
- return qI.increment(g.store, "v2"), wC(new RI(g.store, g.path, LE(II(C), A)));
6943
+ return qI.increment(g.store, "v2"), GC(new RI(g.store, g.path, NE(II(C), A)));
6933
6944
  }
6934
6945
  async function JB(g, A, I) {
6935
6946
  let { path: B } = g.resolve(".zgroup"), C = await g.store.get(B, { signal: I });
6936
6947
  if (!C)
6937
6948
  throw new uA("v2 group", { path: B });
6938
- return qI.increment(g.store, "v2"), new xg(g.store, g.path, JE(II(C), A));
6949
+ return qI.increment(g.store, "v2"), new xg(g.store, g.path, UE(II(C), A));
6939
6950
  }
6940
- async function gi(g, A) {
6951
+ async function $E(g, A) {
6941
6952
  let { store: I, path: B } = g.resolve("zarr.json"), C = await g.store.get(B, { signal: A });
6942
6953
  if (!C)
6943
6954
  throw new uA("v3 array or group", { path: B });
6944
6955
  let Q = II(C);
6945
- return Q.node_type === "array" && (Q.fill_value = yC(Q)), Q.node_type === "array" ? wC(new RI(I, g.path, Q)) : new xg(I, g.path, Q);
6956
+ return Q.node_type === "array" && (Q.fill_value = tC(Q)), Q.node_type === "array" ? GC(new RI(I, g.path, Q)) : new xg(I, g.path, Q);
6946
6957
  }
6947
- async function Bi(g, A = {}) {
6948
- let I = "store" in g ? g : new CA(g), B = await gi(I, A.signal);
6958
+ async function Ai(g, A = {}) {
6959
+ let I = "store" in g ? g : new CA(g), B = await $E(I, A.signal);
6949
6960
  if (qI.increment(I.store, "v3"), A.kind === void 0 || A.kind === "array" && B instanceof RI || A.kind === "group" && B instanceof xg)
6950
6961
  return B;
6951
6962
  let C = B instanceof RI ? "array" : "group";
@@ -6956,11 +6967,11 @@ async function Bi(g, A = {}) {
6956
6967
  }
6957
6968
  async function BA(g, A = {}) {
6958
6969
  let I = "store" in g ? g.store : g, B = qI.versionMax(I), C = B === "v2" ? BA.v2 : BA.v3, Q = B === "v2" ? BA.v3 : BA.v2;
6959
- return C(g, A).catch((E) => (eC(E, uA, X), Q(g, A)));
6970
+ return C(g, A).catch((E) => (yC(E, uA, X), Q(g, A)));
6960
6971
  }
6961
- BA.v2 = Ii;
6962
- BA.v3 = Bi;
6963
- async function Ci(g, A) {
6972
+ BA.v2 = _E;
6973
+ BA.v3 = Ai;
6974
+ async function Ii(g, A) {
6964
6975
  const I = A.split("/"), B = I.pop();
6965
6976
  if (!B)
6966
6977
  throw new Error("Invalid path");
@@ -6977,7 +6988,7 @@ class Wg {
6977
6988
  return this.#A;
6978
6989
  }
6979
6990
  async get(A) {
6980
- const I = await Ci(this.#A, A.slice(1)).catch(
6991
+ const I = await Ii(this.#A, A.slice(1)).catch(
6981
6992
  () => {
6982
6993
  }
6983
6994
  );
@@ -7006,7 +7017,7 @@ async function gI(g, A) {
7006
7017
  throw new Error(`Failed to open Zarr group at ${g}`);
7007
7018
  }
7008
7019
  }
7009
- async function Qi(g, A) {
7020
+ async function gi(g, A) {
7010
7021
  if (A === "v2")
7011
7022
  try {
7012
7023
  return BA.v2(g, { kind: "array", attrs: !1 });
@@ -7025,7 +7036,7 @@ async function Qi(g, A) {
7025
7036
  throw new Error(`Failed to open Zarr array at ${g}`);
7026
7037
  }
7027
7038
  }
7028
- async function Ei(g) {
7039
+ async function Bi(g) {
7029
7040
  let A;
7030
7041
  switch (g.type) {
7031
7042
  case "fetch": {
@@ -7046,9 +7057,9 @@ async function Ei(g) {
7046
7057
  }
7047
7058
  }
7048
7059
  const I = g.arrayPath ? A.resolve(g.arrayPath) : A;
7049
- return Qi(I, g.zarrVersion);
7060
+ return gi(I, g.zarrVersion);
7050
7061
  }
7051
- function ii(g, A, I) {
7062
+ function Ci(g, A, I) {
7052
7063
  if (g.store instanceof _A)
7053
7064
  return {
7054
7065
  type: "fetch",
@@ -7068,10 +7079,10 @@ function ii(g, A, I) {
7068
7079
  `Unsupported store type: ${g.store.constructor.name}`
7069
7080
  );
7070
7081
  }
7071
- function oi(g, A, I, B) {
7072
- return ai(g, A, I, B);
7082
+ function Qi(g, A, I, B) {
7083
+ return Ei(g, A, I, B);
7073
7084
  }
7074
- function ai(g, A, I, B) {
7085
+ function Ei(g, A, I, B) {
7075
7086
  const { targetShape: C, chunkIndex: Q, dimIndices: E } = B;
7076
7087
  let i = 1;
7077
7088
  for (let r = A.length - 1; r >= 0; r--) {
@@ -7106,7 +7117,7 @@ function ai(g, A, I, B) {
7106
7117
  }
7107
7118
  return G;
7108
7119
  }
7109
- const FC = `function xg(B, A) {
7120
+ const wC = `function xg(B, A) {
7110
7121
  return {
7111
7122
  ...B,
7112
7123
  ...A,
@@ -10760,8 +10771,8 @@ return ret;
10760
10771
  default: IQ
10761
10772
  });
10762
10773
  //# sourceMappingURL=worker_kernel-CBlE4MBI.js.map
10763
- `, YB = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", FC], { type: "text/javascript;charset=utf-8" });
10764
- function si(g) {
10774
+ `, YB = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", wC], { type: "text/javascript;charset=utf-8" });
10775
+ function ii(g) {
10765
10776
  let A;
10766
10777
  try {
10767
10778
  if (A = YB && (self.URL || self.webkitURL).createObjectURL(YB), !A) throw "";
@@ -10774,7 +10785,7 @@ function si(g) {
10774
10785
  }), I;
10775
10786
  } catch {
10776
10787
  return new Worker(
10777
- "data:text/javascript;charset=utf-8," + encodeURIComponent(FC),
10788
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(wC),
10778
10789
  {
10779
10790
  type: "module",
10780
10791
  name: g?.name
@@ -10782,17 +10793,17 @@ function si(g) {
10782
10793
  );
10783
10794
  }
10784
10795
  }
10785
- const Di = Math.max(1, navigator.hardwareConcurrency - 2);
10786
- let iA = [], hi = 0, rC = 0;
10796
+ const oi = Math.max(1, navigator.hardwareConcurrency - 2);
10797
+ let iA = [], ai = 0, FC = 0;
10787
10798
  const RA = /* @__PURE__ */ new Map(), cI = /* @__PURE__ */ new Set();
10788
- function SC(g) {
10799
+ function rC(g) {
10789
10800
  const A = iA.find((I) => I.worker === g);
10790
10801
  return A || k.error(
10791
10802
  "ZarrWorker",
10792
10803
  "Worker not found in pool - this should not happen"
10793
10804
  ), A;
10794
10805
  }
10795
- function ti(g, A) {
10806
+ function si(g, A) {
10796
10807
  const { id: I, success: B } = g.data, C = RA.get(I);
10797
10808
  if (!C) {
10798
10809
  cI.has(I) ? cI.delete(I) : k.warn(
@@ -10803,7 +10814,7 @@ function ti(g, A) {
10803
10814
  return;
10804
10815
  }
10805
10816
  RA.delete(I), C.abortListener && C.abortSignal && C.abortSignal.removeEventListener("abort", C.abortListener);
10806
- const Q = SC(A);
10817
+ const Q = rC(A);
10807
10818
  Q && Q.pendingCount > 0 ? Q.pendingCount-- : Q && k.error(
10808
10819
  "ZarrWorker",
10809
10820
  "Received message but no pending tasks - this should not happen"
@@ -10822,7 +10833,7 @@ function dB(g, A) {
10822
10833
  "Worker failed - replacing worker and canceling its in-flight messages",
10823
10834
  g.message
10824
10835
  );
10825
- const I = SC(A);
10836
+ const I = rC(A);
10826
10837
  if (I) {
10827
10838
  const C = iA.indexOf(I);
10828
10839
  iA.splice(C, 1);
@@ -10832,31 +10843,31 @@ function dB(g, A) {
10832
10843
  for (const [C, Q] of RA.entries())
10833
10844
  Q.workerId === B && (Q.reject(new Error(`Worker error: ${g.message}`)), RA.delete(C));
10834
10845
  try {
10835
- const C = RC();
10846
+ const C = SC();
10836
10847
  iA.push({
10837
10848
  worker: C,
10838
10849
  pendingCount: 0,
10839
- workerId: rC++
10850
+ workerId: FC++
10840
10851
  }), k.debug("ZarrWorker", "Replacement worker created successfully");
10841
10852
  } catch (C) {
10842
10853
  k.error("ZarrWorker", "Failed to create replacement worker", C);
10843
10854
  }
10844
10855
  }
10845
- function RC() {
10846
- const g = new si();
10847
- return g.addEventListener("message", (A) => ti(A, g)), g.addEventListener("error", (A) => dB(A, g)), g.addEventListener(
10856
+ function SC() {
10857
+ const g = new ii();
10858
+ return g.addEventListener("message", (A) => si(A, g)), g.addEventListener("error", (A) => dB(A, g)), g.addEventListener(
10848
10859
  "messageerror",
10849
10860
  (A) => dB(A, g)
10850
10861
  ), g;
10851
10862
  }
10852
- function yi() {
10863
+ function Di() {
10853
10864
  if (iA.length === 0)
10854
10865
  throw new Error("Worker pool is not initialized");
10855
10866
  return iA.sort((g, A) => g.pendingCount - A.pendingCount)[0];
10856
10867
  }
10857
- async function ei(g, A, I, B) {
10868
+ async function hi(g, A, I, B) {
10858
10869
  return new Promise((C, Q) => {
10859
- const E = yi(), i = hi++, o = {
10870
+ const E = Di(), i = ai++, o = {
10860
10871
  resolve: C,
10861
10872
  reject: Q,
10862
10873
  workerId: E.workerId
@@ -10883,15 +10894,15 @@ async function ei(g, A, I, B) {
10883
10894
  });
10884
10895
  });
10885
10896
  }
10886
- function ni() {
10897
+ function ti() {
10887
10898
  if (!(iA.length > 0))
10888
10899
  try {
10889
- for (let g = 0; g < Di; g++) {
10890
- const A = RC();
10900
+ for (let g = 0; g < oi; g++) {
10901
+ const A = SC();
10891
10902
  iA.push({
10892
10903
  worker: A,
10893
10904
  pendingCount: 0,
10894
- workerId: rC++
10905
+ workerId: FC++
10895
10906
  });
10896
10907
  }
10897
10908
  k.debug(
@@ -10899,14 +10910,14 @@ function ni() {
10899
10910
  `Initialized worker pool with ${iA.length} workers`
10900
10911
  );
10901
10912
  } catch {
10902
- k.warn("ZarrWorker", "Failed to create workers - clearing pool"), wi();
10913
+ k.warn("ZarrWorker", "Failed to create workers - clearing pool"), ei();
10903
10914
  return;
10904
10915
  }
10905
10916
  }
10906
- async function Gi(g, A, I, B, C) {
10907
- ni();
10917
+ async function yi(g, A, I, B, C) {
10918
+ ti();
10908
10919
  try {
10909
- return await ei(
10920
+ return await hi(
10910
10921
  A,
10911
10922
  I,
10912
10923
  B,
@@ -10917,11 +10928,11 @@ async function Gi(g, A, I, B, C) {
10917
10928
  throw Q;
10918
10929
  k.warn("ZarrWorker", "Falling back to main thread", Q);
10919
10930
  const E = await g.getChunk(I, C);
10920
- if (!MQ(E.data))
10931
+ if (!dQ(E.data))
10921
10932
  throw new Error(
10922
10933
  `Unsupported chunk data type: ${E.data.constructor.name}`
10923
10934
  );
10924
- return oi(
10935
+ return Qi(
10925
10936
  E.data,
10926
10937
  E.shape,
10927
10938
  E.stride,
@@ -10929,19 +10940,19 @@ async function Gi(g, A, I, B, C) {
10929
10940
  );
10930
10941
  }
10931
10942
  }
10932
- function wi() {
10943
+ function ei() {
10933
10944
  for (const g of iA)
10934
10945
  g.worker.terminate();
10935
10946
  iA = [], RA.clear();
10936
10947
  }
10937
- class Fi {
10948
+ class ni {
10938
10949
  metadata_;
10939
10950
  arrays_;
10940
10951
  arrayParams_;
10941
10952
  dimensions_;
10942
10953
  bytesPerElement_;
10943
10954
  constructor(A) {
10944
- this.metadata_ = A.metadata, this.arrays_ = A.arrays, this.arrayParams_ = A.arrayParams, this.dimensions_ = Si(this.metadata_, this.arrays_), this.bytesPerElement_ = ri(this.arrays_[0].dtype);
10955
+ this.metadata_ = A.metadata, this.arrays_ = A.arrays, this.arrayParams_ = A.arrayParams, this.dimensions_ = wi(this.metadata_, this.arrays_), this.bytesPerElement_ = Gi(this.arrays_[0].dtype);
10945
10956
  }
10946
10957
  getSourceDimensionMap() {
10947
10958
  return this.dimensions_;
@@ -10975,18 +10986,18 @@ class Fi {
10975
10986
  },
10976
10987
  cChunkSize: E?.chunkSize,
10977
10988
  tChunkSize: i?.chunkSize
10978
- }, a = await Gi(
10989
+ }, a = await yi(
10979
10990
  C,
10980
10991
  Q,
10981
10992
  B,
10982
10993
  o,
10983
10994
  { signal: I }
10984
10995
  ), s = a.BYTES_PER_ELEMENT;
10985
- if (!FQ(s))
10996
+ if (!wQ(s))
10986
10997
  throw new Error(
10987
10998
  "Invalid row alignment value. Possible values are 1, 2, 4, or 8"
10988
10999
  );
10989
- A.rowAlignmentBytes = s, YQ(A, a);
11000
+ A.rowAlignmentBytes = s, JQ(A, a);
10990
11001
  }
10991
11002
  }
10992
11003
  const MB = {
@@ -10998,7 +11009,7 @@ const MB = {
10998
11009
  uint32: 4,
10999
11010
  float32: 4
11000
11011
  };
11001
- function ri(g) {
11012
+ function Gi(g) {
11002
11013
  const A = MB[g];
11003
11014
  if (A === void 0)
11004
11015
  throw new Error(
@@ -11006,7 +11017,7 @@ function ri(g) {
11006
11017
  );
11007
11018
  return A;
11008
11019
  }
11009
- function Si(g, A) {
11020
+ function wi(g, A) {
11010
11021
  const I = g.axes.map((D) => D.name), B = g.axes.length, C = KB(I, "x"), Q = KB(I, "y"), E = (D, h) => {
11011
11022
  const t = [];
11012
11023
  for (let e = 0; e < g.datasets.length; e++) {
@@ -11018,7 +11029,7 @@ function Si(g, A) {
11018
11029
  translation: L[h]
11019
11030
  });
11020
11031
  }
11021
- if (g.axes[h].type === "space" && ci(t))
11032
+ if (g.axes[h].type === "space" && ri(t))
11022
11033
  for (const e of t) e.translation -= 0.5 * e.scale;
11023
11034
  return {
11024
11035
  name: D,
@@ -11037,7 +11048,7 @@ function Si(g, A) {
11037
11048
  const s = iI(I, "t");
11038
11049
  return s !== -1 && (i.t = E(I[s], s)), i;
11039
11050
  }
11040
- function Ri(g, A) {
11051
+ function Fi(g, A) {
11041
11052
  return g.toLowerCase() === A.toLowerCase();
11042
11053
  }
11043
11054
  function KB(g, A) {
@@ -11049,9 +11060,9 @@ function KB(g, A) {
11049
11060
  return I;
11050
11061
  }
11051
11062
  function iI(g, A) {
11052
- return g.findIndex((I) => Ri(I, A));
11063
+ return g.findIndex((I) => Fi(I, A));
11053
11064
  }
11054
- function ci(g) {
11065
+ function ri(g) {
11055
11066
  if (g.length <= 1) return !1;
11056
11067
  for (let A = 1; A < g.length; A++) {
11057
11068
  const I = 0.5 * (g[A].scale - g[A - 1].scale), B = g[A].translation - g[A - 1].translation;
@@ -11284,11 +11295,11 @@ const og = (g, A) => {
11284
11295
  }
11285
11296
  return { message: I };
11286
11297
  };
11287
- let Ni = og;
11288
- function Ui() {
11289
- return Ni;
11298
+ let Si = og;
11299
+ function Ri() {
11300
+ return Si;
11290
11301
  }
11291
- const ki = (g) => {
11302
+ const ci = (g) => {
11292
11303
  const { data: A, path: I, errorMaps: B, issueData: C } = g, Q = [...I, ...C.path || []], E = {
11293
11304
  ...C,
11294
11305
  path: Q
@@ -11310,7 +11321,7 @@ const ki = (g) => {
11310
11321
  };
11311
11322
  };
11312
11323
  function w(g, A) {
11313
- const I = Ui(), B = ki({
11324
+ const I = Ri(), B = ci({
11314
11325
  issueData: A,
11315
11326
  data: g.data,
11316
11327
  path: g.path,
@@ -11592,7 +11603,7 @@ class q {
11592
11603
  });
11593
11604
  }
11594
11605
  brand() {
11595
- return new Xi({
11606
+ return new Oi({
11596
11607
  typeName: d.ZodBranded,
11597
11608
  type: this,
11598
11609
  ...K(this._def)
@@ -11627,28 +11638,28 @@ class q {
11627
11638
  return this.safeParse(null).success;
11628
11639
  }
11629
11640
  }
11630
- const Li = /^c[^\s-]{8,}$/i, Ji = /^[0-9a-z]+$/, Yi = /^[0-9A-HJKMNP-TV-Z]{26}$/i, di = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Mi = /^[a-z0-9_-]{21}$/i, Ki = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Hi = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, qi = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, li = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
11641
+ const Ni = /^c[^\s-]{8,}$/i, Ui = /^[0-9a-z]+$/, ki = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Li = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Ji = /^[a-z0-9_-]{21}$/i, Yi = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, di = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Mi = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ki = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
11631
11642
  let VI;
11632
- const fi = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, pi = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, ui = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, mi = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Ti = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, xi = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, cC = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Wi = new RegExp(`^${cC}$`);
11633
- function NC(g) {
11643
+ const Hi = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, qi = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, li = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, fi = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, pi = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ui = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, RC = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", mi = new RegExp(`^${RC}$`);
11644
+ function cC(g) {
11634
11645
  let A = "[0-5]\\d";
11635
11646
  g.precision ? A = `${A}\\.\\d{${g.precision}}` : g.precision == null && (A = `${A}(\\.\\d+)?`);
11636
11647
  const I = g.precision ? "+" : "?";
11637
11648
  return `([01]\\d|2[0-3]):[0-5]\\d(:${A})${I}`;
11638
11649
  }
11639
- function bi(g) {
11640
- return new RegExp(`^${NC(g)}$`);
11650
+ function Ti(g) {
11651
+ return new RegExp(`^${cC(g)}$`);
11641
11652
  }
11642
- function Zi(g) {
11643
- let A = `${cC}T${NC(g)}`;
11653
+ function xi(g) {
11654
+ let A = `${RC}T${cC(g)}`;
11644
11655
  const I = [];
11645
11656
  return I.push(g.local ? "Z?" : "Z"), g.offset && I.push("([+-]\\d{2}:?\\d{2})"), A = `${A}(${I.join("|")})`, new RegExp(`^${A}$`);
11646
11657
  }
11647
- function Pi(g, A) {
11648
- return !!((A === "v4" || !A) && fi.test(g) || (A === "v6" || !A) && ui.test(g));
11658
+ function Wi(g, A) {
11659
+ return !!((A === "v4" || !A) && Hi.test(g) || (A === "v6" || !A) && li.test(g));
11649
11660
  }
11650
- function Oi(g, A) {
11651
- if (!Ki.test(g))
11661
+ function bi(g, A) {
11662
+ if (!Yi.test(g))
11652
11663
  return !1;
11653
11664
  try {
11654
11665
  const [I] = g.split(".");
@@ -11660,8 +11671,8 @@ function Oi(g, A) {
11660
11671
  return !1;
11661
11672
  }
11662
11673
  }
11663
- function Vi(g, A) {
11664
- return !!((A === "v4" || !A) && pi.test(g) || (A === "v6" || !A) && mi.test(g));
11674
+ function Zi(g, A) {
11675
+ return !!((A === "v4" || !A) && qi.test(g) || (A === "v6" || !A) && fi.test(g));
11665
11676
  }
11666
11677
  class eA extends q {
11667
11678
  _parse(A) {
@@ -11712,43 +11723,43 @@ class eA extends q {
11712
11723
  message: Q.message
11713
11724
  }), B.dirty());
11714
11725
  } else if (Q.kind === "email")
11715
- qi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11726
+ Mi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11716
11727
  validation: "email",
11717
11728
  code: y.invalid_string,
11718
11729
  message: Q.message
11719
11730
  }), B.dirty());
11720
11731
  else if (Q.kind === "emoji")
11721
- VI || (VI = new RegExp(li, "u")), VI.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11732
+ VI || (VI = new RegExp(Ki, "u")), VI.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11722
11733
  validation: "emoji",
11723
11734
  code: y.invalid_string,
11724
11735
  message: Q.message
11725
11736
  }), B.dirty());
11726
11737
  else if (Q.kind === "uuid")
11727
- di.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11738
+ Li.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11728
11739
  validation: "uuid",
11729
11740
  code: y.invalid_string,
11730
11741
  message: Q.message
11731
11742
  }), B.dirty());
11732
11743
  else if (Q.kind === "nanoid")
11733
- Mi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11744
+ Ji.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11734
11745
  validation: "nanoid",
11735
11746
  code: y.invalid_string,
11736
11747
  message: Q.message
11737
11748
  }), B.dirty());
11738
11749
  else if (Q.kind === "cuid")
11739
- Li.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11750
+ Ni.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11740
11751
  validation: "cuid",
11741
11752
  code: y.invalid_string,
11742
11753
  message: Q.message
11743
11754
  }), B.dirty());
11744
11755
  else if (Q.kind === "cuid2")
11745
- Ji.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11756
+ Ui.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11746
11757
  validation: "cuid2",
11747
11758
  code: y.invalid_string,
11748
11759
  message: Q.message
11749
11760
  }), B.dirty());
11750
11761
  else if (Q.kind === "ulid")
11751
- Yi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11762
+ ki.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11752
11763
  validation: "ulid",
11753
11764
  code: y.invalid_string,
11754
11765
  message: Q.message
@@ -11779,39 +11790,39 @@ class eA extends q {
11779
11790
  code: y.invalid_string,
11780
11791
  validation: { endsWith: Q.value },
11781
11792
  message: Q.message
11782
- }), B.dirty()) : Q.kind === "datetime" ? Zi(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11793
+ }), B.dirty()) : Q.kind === "datetime" ? xi(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11783
11794
  code: y.invalid_string,
11784
11795
  validation: "datetime",
11785
11796
  message: Q.message
11786
- }), B.dirty()) : Q.kind === "date" ? Wi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11797
+ }), B.dirty()) : Q.kind === "date" ? mi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11787
11798
  code: y.invalid_string,
11788
11799
  validation: "date",
11789
11800
  message: Q.message
11790
- }), B.dirty()) : Q.kind === "time" ? bi(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11801
+ }), B.dirty()) : Q.kind === "time" ? Ti(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11791
11802
  code: y.invalid_string,
11792
11803
  validation: "time",
11793
11804
  message: Q.message
11794
- }), B.dirty()) : Q.kind === "duration" ? Hi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11805
+ }), B.dirty()) : Q.kind === "duration" ? di.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11795
11806
  validation: "duration",
11796
11807
  code: y.invalid_string,
11797
11808
  message: Q.message
11798
- }), B.dirty()) : Q.kind === "ip" ? Pi(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
11809
+ }), B.dirty()) : Q.kind === "ip" ? Wi(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
11799
11810
  validation: "ip",
11800
11811
  code: y.invalid_string,
11801
11812
  message: Q.message
11802
- }), B.dirty()) : Q.kind === "jwt" ? Oi(A.data, Q.alg) || (C = this._getOrReturnCtx(A, C), w(C, {
11813
+ }), B.dirty()) : Q.kind === "jwt" ? bi(A.data, Q.alg) || (C = this._getOrReturnCtx(A, C), w(C, {
11803
11814
  validation: "jwt",
11804
11815
  code: y.invalid_string,
11805
11816
  message: Q.message
11806
- }), B.dirty()) : Q.kind === "cidr" ? Vi(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
11817
+ }), B.dirty()) : Q.kind === "cidr" ? Zi(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
11807
11818
  validation: "cidr",
11808
11819
  code: y.invalid_string,
11809
11820
  message: Q.message
11810
- }), B.dirty()) : Q.kind === "base64" ? Ti.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11821
+ }), B.dirty()) : Q.kind === "base64" ? pi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11811
11822
  validation: "base64",
11812
11823
  code: y.invalid_string,
11813
11824
  message: Q.message
11814
- }), B.dirty()) : Q.kind === "base64url" ? xi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11825
+ }), B.dirty()) : Q.kind === "base64url" ? ui.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
11815
11826
  validation: "base64url",
11816
11827
  code: y.invalid_string,
11817
11828
  message: Q.message
@@ -12046,7 +12057,7 @@ eA.create = (g) => new eA({
12046
12057
  coerce: g?.coerce ?? !1,
12047
12058
  ...K(g)
12048
12059
  });
12049
- function vi(g, A) {
12060
+ function Pi(g, A) {
12050
12061
  const I = (g.toString().split(".")[1] || "").length, B = (A.toString().split(".")[1] || "").length, C = I > B ? I : B, Q = Number.parseInt(g.toFixed(C).replace(".", "")), E = Number.parseInt(A.toFixed(C).replace(".", ""));
12051
12062
  return Q % E / 10 ** C;
12052
12063
  }
@@ -12085,7 +12096,7 @@ class KA extends q {
12085
12096
  inclusive: Q.inclusive,
12086
12097
  exact: !1,
12087
12098
  message: Q.message
12088
- }), C.dirty()) : Q.kind === "multipleOf" ? vi(A.data, Q.value) !== 0 && (B = this._getOrReturnCtx(A, B), w(B, {
12099
+ }), C.dirty()) : Q.kind === "multipleOf" ? Pi(A.data, Q.value) !== 0 && (B = this._getOrReturnCtx(A, B), w(B, {
12089
12100
  code: y.not_multiple_of,
12090
12101
  multipleOf: Q.value,
12091
12102
  message: Q.message
@@ -12909,7 +12920,7 @@ class V extends q {
12909
12920
  });
12910
12921
  }
12911
12922
  keyof() {
12912
- return UC(f.objectKeys(this.shape));
12923
+ return NC(f.objectKeys(this.shape));
12913
12924
  }
12914
12925
  }
12915
12926
  V.create = (g, A) => new V({
@@ -13267,7 +13278,7 @@ hg.create = (g, A) => new hg({
13267
13278
  typeName: d.ZodLiteral,
13268
13279
  ...K(A)
13269
13280
  });
13270
- function UC(g, A) {
13281
+ function NC(g, A) {
13271
13282
  return new HA({
13272
13283
  values: g,
13273
13284
  typeName: d.ZodEnum,
@@ -13328,7 +13339,7 @@ class HA extends q {
13328
13339
  });
13329
13340
  }
13330
13341
  }
13331
- HA.create = UC;
13342
+ HA.create = NC;
13332
13343
  class ZB extends q {
13333
13344
  _parse(A) {
13334
13345
  const I = f.getValidEnumValues(this._def.values), B = this._getOrReturnCtx(A);
@@ -13581,7 +13592,7 @@ PB.create = (g) => new PB({
13581
13592
  typeName: d.ZodNaN,
13582
13593
  ...K(g)
13583
13594
  });
13584
- class Xi extends q {
13595
+ class Oi extends q {
13585
13596
  _parse(A) {
13586
13597
  const { ctx: I } = this._processInputParams(A), B = I.data;
13587
13598
  return this._def.type._parse({
@@ -13652,7 +13663,7 @@ var d;
13652
13663
  (function(g) {
13653
13664
  g.ZodString = "ZodString", g.ZodNumber = "ZodNumber", g.ZodNaN = "ZodNaN", g.ZodBigInt = "ZodBigInt", g.ZodBoolean = "ZodBoolean", g.ZodDate = "ZodDate", g.ZodSymbol = "ZodSymbol", g.ZodUndefined = "ZodUndefined", g.ZodNull = "ZodNull", g.ZodAny = "ZodAny", g.ZodUnknown = "ZodUnknown", g.ZodNever = "ZodNever", g.ZodVoid = "ZodVoid", g.ZodArray = "ZodArray", g.ZodObject = "ZodObject", g.ZodUnion = "ZodUnion", g.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", g.ZodIntersection = "ZodIntersection", g.ZodTuple = "ZodTuple", g.ZodRecord = "ZodRecord", g.ZodMap = "ZodMap", g.ZodSet = "ZodSet", g.ZodFunction = "ZodFunction", g.ZodLazy = "ZodLazy", g.ZodLiteral = "ZodLiteral", g.ZodEnum = "ZodEnum", g.ZodEffects = "ZodEffects", g.ZodNativeEnum = "ZodNativeEnum", g.ZodOptional = "ZodOptional", g.ZodNullable = "ZodNullable", g.ZodDefault = "ZodDefault", g.ZodCatch = "ZodCatch", g.ZodPromise = "ZodPromise", g.ZodBranded = "ZodBranded", g.ZodPipeline = "ZodPipeline", g.ZodReadonly = "ZodReadonly";
13654
13665
  })(d || (d = {}));
13655
- const u = eA.create, H = KA.create, kC = ag.create, nA = sg.create;
13666
+ const u = eA.create, H = KA.create, UC = ag.create, nA = sg.create;
13656
13667
  FA.create;
13657
13668
  const p = DA.create, J = V.create;
13658
13669
  kI.create;
@@ -13662,7 +13673,7 @@ const _ = hg.create, LA = HA.create;
13662
13673
  JI.create;
13663
13674
  GA.create;
13664
13675
  lA.create;
13665
- const ji = J({
13676
+ const Vi = J({
13666
13677
  /**The multiscale datasets for this image*/
13667
13678
  multiscales: p(
13668
13679
  J({
@@ -13775,7 +13786,7 @@ const ji = J({
13775
13786
  label: u().optional(),
13776
13787
  family: u().optional(),
13777
13788
  color: u(),
13778
- active: kC().optional()
13789
+ active: UC().optional()
13779
13790
  })
13780
13791
  ),
13781
13792
  // The rdefs are not in the JSON schema and are not particularly well
@@ -13790,7 +13801,7 @@ const ji = J({
13790
13801
  projection: u().optional()
13791
13802
  }).optional()
13792
13803
  }).optional()
13793
- }).describe("JSON from OME-NGFF .zattrs"), zi = J({
13804
+ }).describe("JSON from OME-NGFF .zattrs"), vi = J({
13794
13805
  plate: J({
13795
13806
  /**The acquisitions for this plate*/
13796
13807
  acquisitions: p(
@@ -13849,7 +13860,7 @@ const ji = J({
13849
13860
  })
13850
13861
  ).min(1).describe("The wells of the plate")
13851
13862
  }).optional()
13852
- }).describe("JSON from OME-NGFF .zattrs"), _i = J({
13863
+ }).describe("JSON from OME-NGFF .zattrs"), Xi = J({
13853
13864
  well: J({
13854
13865
  /**The fields of view for this well*/
13855
13866
  images: p(
@@ -13863,7 +13874,7 @@ const ji = J({
13863
13874
  /**The version of the specification*/
13864
13875
  version: _("0.4").describe("The version of the specification").optional()
13865
13876
  }).optional()
13866
- }).describe("JSON from OME-NGFF .zattrs"), $i = J({
13877
+ }).describe("JSON from OME-NGFF .zattrs"), ji = J({
13867
13878
  /**The versioned OME-Zarr Metadata namespace*/
13868
13879
  ome: J({
13869
13880
  /**The multiscale datasets for this image*/
@@ -13975,7 +13986,7 @@ const ji = J({
13975
13986
  label: u().optional(),
13976
13987
  family: u().optional(),
13977
13988
  color: u().optional(),
13978
- active: kC().optional()
13989
+ active: UC().optional()
13979
13990
  })
13980
13991
  ),
13981
13992
  // The rdefs are not in the JSON schema and are not particularly well
@@ -13993,7 +14004,7 @@ const ji = J({
13993
14004
  /**The version of the OME-Zarr Metadata*/
13994
14005
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
13995
14006
  }).describe("The versioned OME-Zarr Metadata namespace")
13996
- }).describe("The zarr.json attributes key"), Ao = J({
14007
+ }).describe("The zarr.json attributes key"), zi = J({
13997
14008
  /**The versioned OME-Zarr Metadata namespace*/
13998
14009
  ome: J({
13999
14010
  plate: J({
@@ -14055,7 +14066,7 @@ const ji = J({
14055
14066
  /**The version of the OME-Zarr Metadata*/
14056
14067
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
14057
14068
  }).describe("The versioned OME-Zarr Metadata namespace")
14058
- }).describe("The zarr.json attributes key"), Io = J({
14069
+ }).describe("The zarr.json attributes key"), _i = J({
14059
14070
  /**The versioned OME-Zarr Metadata namespace*/
14060
14071
  ome: J({
14061
14072
  well: J({
@@ -14074,15 +14085,15 @@ const ji = J({
14074
14085
  /**The version of the OME-Zarr Metadata*/
14075
14086
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
14076
14087
  }).describe("The versioned OME-Zarr Metadata namespace")
14077
- }).describe("JSON from OME-Zarr zarr.json"), go = ["0.4", "0.5"], Bo = new Set(go);
14078
- function Co(g) {
14088
+ }).describe("JSON from OME-Zarr zarr.json"), $i = ["0.4", "0.5"], Ao = new Set($i);
14089
+ function Io(g) {
14079
14090
  if (!("ome" in g) || !(g.ome instanceof Object)) return;
14080
14091
  const A = g.ome;
14081
- if ("version" in A && typeof A.version == "string" && Bo.has(A.version))
14092
+ if ("version" in A && typeof A.version == "string" && Ao.has(A.version))
14082
14093
  return A.version;
14083
14094
  }
14084
14095
  function Zg(g) {
14085
- const A = Co(g);
14096
+ const A = Io(g);
14086
14097
  return A === void 0 ? "0.4" : A;
14087
14098
  }
14088
14099
  function fA(g) {
@@ -14094,14 +14105,14 @@ function fA(g) {
14094
14105
  return "v3";
14095
14106
  }
14096
14107
  }
14097
- function LC(g, A) {
14108
+ function kC(g, A) {
14098
14109
  const I = { ...g };
14099
14110
  return delete I[A], I;
14100
14111
  }
14101
- async function Ko(g, A) {
14112
+ async function Yo(g, A) {
14102
14113
  const I = new _A(g), B = new CA(I), C = fA(A), Q = await gI(B, C);
14103
14114
  try {
14104
- return Qo(Q.attrs);
14115
+ return go(Q.attrs);
14105
14116
  } catch {
14106
14117
  throw Error(
14107
14118
  `Failed to parse OME-Zarr plate:
@@ -14109,58 +14120,58 @@ ${JSON.stringify(Q.attrs)}`
14109
14120
  );
14110
14121
  }
14111
14122
  }
14112
- function Qo(g) {
14123
+ function go(g) {
14113
14124
  switch (Zg(g)) {
14114
14125
  case "0.5":
14115
14126
  return {
14116
- ...Ao.parse(g).ome,
14127
+ ...zi.parse(g).ome,
14117
14128
  originalVersion: "0.5"
14118
14129
  };
14119
14130
  case "0.4":
14120
14131
  return {
14121
- ...Eo(zi.parse(g)).ome,
14132
+ ...Bo(vi.parse(g)).ome,
14122
14133
  originalVersion: "0.4"
14123
14134
  };
14124
14135
  }
14125
14136
  }
14126
- function Eo(g) {
14137
+ function Bo(g) {
14127
14138
  if (g.plate === void 0)
14128
14139
  throw new Error("Plate metadata is missing in OME-Zarr v0.4 plate");
14129
14140
  return {
14130
14141
  ome: {
14131
- plate: LC(g.plate, "version"),
14142
+ plate: kC(g.plate, "version"),
14132
14143
  version: "0.5"
14133
14144
  }
14134
14145
  };
14135
14146
  }
14136
- function io(g) {
14147
+ function Co(g) {
14137
14148
  if (g.well === void 0)
14138
14149
  throw new Error("Well metadata is missing in OME-Zarr v0.4 well");
14139
14150
  return {
14140
14151
  ome: {
14141
- well: LC(g.well, "version"),
14152
+ well: kC(g.well, "version"),
14142
14153
  version: "0.5"
14143
14154
  }
14144
14155
  };
14145
14156
  }
14146
- function oo(g) {
14157
+ function Qo(g) {
14147
14158
  switch (Zg(g)) {
14148
14159
  case "0.5":
14149
14160
  return {
14150
- ...Io.parse(g).ome,
14161
+ ..._i.parse(g).ome,
14151
14162
  originalVersion: "0.5"
14152
14163
  };
14153
14164
  case "0.4":
14154
14165
  return {
14155
- ...io(_i.parse(g)).ome,
14166
+ ...Co(Xi.parse(g)).ome,
14156
14167
  originalVersion: "0.4"
14157
14168
  };
14158
14169
  }
14159
14170
  }
14160
- async function Ho(g, A, I) {
14171
+ async function Mo(g, A, I) {
14161
14172
  const B = g + "/" + A, C = new _A(B), Q = new CA(C), E = fA(I), i = await gI(Q, E);
14162
14173
  try {
14163
- return oo(i.attrs);
14174
+ return Qo(i.attrs);
14164
14175
  } catch {
14165
14176
  throw Error(
14166
14177
  `Failed to parse OME-Zarr well:
@@ -14168,15 +14179,15 @@ ${JSON.stringify(i.attrs)}`
14168
14179
  );
14169
14180
  }
14170
14181
  }
14171
- async function qo(g) {
14182
+ async function Ko(g) {
14172
14183
  const A = fA(g.version), I = await gI(g.location, A);
14173
14184
  return Pg(I.attrs).omero?.channels ?? [];
14174
14185
  }
14175
- async function lo(g) {
14186
+ async function Ho(g) {
14176
14187
  const A = fA(g.version), I = await gI(g.location, A);
14177
14188
  return Pg(I.attrs).omero?.rdefs;
14178
14189
  }
14179
- function ao(g) {
14190
+ function Eo(g) {
14180
14191
  return {
14181
14192
  ome: {
14182
14193
  multiscales: g.multiscales,
@@ -14185,23 +14196,23 @@ function ao(g) {
14185
14196
  }
14186
14197
  };
14187
14198
  }
14188
- function so(g) {
14199
+ function io(g) {
14189
14200
  switch (Zg(g)) {
14190
14201
  case "0.5":
14191
14202
  return {
14192
- ...$i.parse(g).ome,
14203
+ ...ji.parse(g).ome,
14193
14204
  originalVersion: "0.5"
14194
14205
  };
14195
14206
  case "0.4":
14196
14207
  return {
14197
- ...ao(ji.parse(g)).ome,
14208
+ ...Eo(Vi.parse(g)).ome,
14198
14209
  originalVersion: "0.4"
14199
14210
  };
14200
14211
  }
14201
14212
  }
14202
14213
  function Pg(g) {
14203
14214
  try {
14204
- return so(g);
14215
+ return io(g);
14205
14216
  } catch {
14206
14217
  throw Error(`Failed to parse OME-Zarr image:
14207
14218
  ${JSON.stringify(g)}`);
@@ -14228,15 +14239,15 @@ class bA {
14228
14239
  throw new Error("No datasets found in the multiscale image.");
14229
14240
  B || (B = fA(Q.originalVersion));
14230
14241
  const o = i.datasets.map(
14231
- (h) => ii(A, h.path, B)
14242
+ (h) => Ci(A, h.path, B)
14232
14243
  ), a = await Promise.all(
14233
- o.map((h) => Ei(h))
14244
+ o.map((h) => Bi(h))
14234
14245
  ), s = a[0].shape, D = i.axes;
14235
14246
  if (D.length !== s.length)
14236
14247
  throw new Error(
14237
14248
  `Mismatch between number of axes (${D.length}) and array shape (${s.length})`
14238
14249
  );
14239
- return new Fi({ metadata: i, arrays: a, arrayParams: o });
14250
+ return new ni({ metadata: i, arrays: a, arrayParams: o });
14240
14251
  }
14241
14252
  /**
14242
14253
  * Returns per-axis dimension metadata for the image.
@@ -14286,7 +14297,7 @@ class bA {
14286
14297
  return new bA({ location: I, version: A.version, loader: B });
14287
14298
  }
14288
14299
  }
14289
- class Do extends pA {
14300
+ class oo extends pA {
14290
14301
  // this creates the geometry for a screen-space projected line
14291
14302
  // each point on the input path is split into two vertices
14292
14303
  // these are pushed in opposite directions in screen-space to create width
@@ -14335,7 +14346,7 @@ class Do extends pA {
14335
14346
  return I;
14336
14347
  }
14337
14348
  }
14338
- class ho extends zA {
14349
+ class ao extends zA {
14339
14350
  color_;
14340
14351
  width_;
14341
14352
  /**
@@ -14374,7 +14385,7 @@ class ho extends zA {
14374
14385
  };
14375
14386
  }
14376
14387
  }
14377
- class fo extends KI {
14388
+ class qo extends KI {
14378
14389
  /** Identifies the layer type as `AxesLayer`. */
14379
14390
  type = "AxesLayer";
14380
14391
  /**
@@ -14410,14 +14421,14 @@ class fo extends KI {
14410
14421
  }
14411
14422
  }
14412
14423
  function vI(g) {
14413
- const { end: A, width: I, color: B } = g, C = new Do([[0, 0, 0], A]);
14414
- return new ho({
14424
+ const { end: A, width: I, color: B } = g, C = new oo([[0, 0, 0], A]);
14425
+ return new ao({
14415
14426
  geometry: C,
14416
14427
  color: B,
14417
14428
  width: I
14418
14429
  });
14419
14430
  }
14420
- class to extends Rg {
14431
+ class so extends Rg {
14421
14432
  width_;
14422
14433
  height_;
14423
14434
  depth_;
@@ -14437,12 +14448,12 @@ class to extends Rg {
14437
14448
  return this.depth_;
14438
14449
  }
14439
14450
  }
14440
- const JC = {
14451
+ const LC = {
14441
14452
  circle: 0,
14442
14453
  square: 1,
14443
14454
  triangle: 2
14444
14455
  };
14445
- class po extends zA {
14456
+ class lo extends zA {
14446
14457
  /**
14447
14458
  * Creates a renderable drawing one marker per entry.
14448
14459
  *
@@ -14461,7 +14472,7 @@ class po extends zA {
14461
14472
  Q.b,
14462
14473
  Q.a,
14463
14474
  C.size,
14464
- JC[C.marker]
14475
+ LC[C.marker]
14465
14476
  ];
14466
14477
  }), B = new pA(I, [], "points");
14467
14478
  B.addAttribute({
@@ -14480,7 +14491,7 @@ class po extends zA {
14480
14491
  type: "marker",
14481
14492
  itemSize: 1,
14482
14493
  offset: B.strideBytes
14483
- }), this.geometry = B, this.setTexture(0, yo());
14494
+ }), this.geometry = B, this.setTexture(0, Do());
14484
14495
  }
14485
14496
  /** Identifies the renderable type as `PointsRenderable`. */
14486
14497
  get type() {
@@ -14488,10 +14499,10 @@ class po extends zA {
14488
14499
  }
14489
14500
  }
14490
14501
  let XI;
14491
- function yo() {
14492
- return XI || (XI = eo()), XI;
14502
+ function Do() {
14503
+ return XI || (XI = ho()), XI;
14493
14504
  }
14494
- function eo() {
14505
+ function ho() {
14495
14506
  const g = (a) => {
14496
14507
  const s = new Float32Array(a * a);
14497
14508
  return s.fill(1), s;
@@ -14513,11 +14524,11 @@ function eo() {
14513
14524
  triangle: I(256)
14514
14525
  }, E = Object.keys(Q).length, i = new Float32Array(E * 65536);
14515
14526
  for (const [a, s] of Object.entries(Q))
14516
- i.set(s, JC[a] * 65536);
14517
- const o = new to(i, 256, 256);
14527
+ i.set(s, LC[a] * 65536);
14528
+ const o = new so(i, 256, 256);
14518
14529
  return o.wrapR = "clamp_to_edge", o.wrapS = "clamp_to_edge", o.wrapT = "clamp_to_edge", o;
14519
14530
  }
14520
- class no {
14531
+ class to {
14521
14532
  planes_;
14522
14533
  /**
14523
14534
  * Creates a frustum from a view-projection matrix.
@@ -14581,7 +14592,7 @@ class no {
14581
14592
  return !0;
14582
14593
  }
14583
14594
  }
14584
- class YC extends YI {
14595
+ class JC extends YI {
14585
14596
  transform_ = new oC();
14586
14597
  /** @hidden */
14587
14598
  projectionMatrix_ = $();
@@ -14625,7 +14636,7 @@ class YC extends YI {
14625
14636
  }
14626
14637
  /** The view frustum derived from the current view-projection. */
14627
14638
  get frustum() {
14628
- return new no(this.getViewProjection());
14639
+ return new to(this.getViewProjection());
14629
14640
  }
14630
14641
  /**
14631
14642
  * Moves the camera by the given world-space offset.
@@ -14654,7 +14665,7 @@ class YC extends YI {
14654
14665
  I,
14655
14666
  B
14656
14667
  );
14657
- oQ(C, C, 1 / C[3]);
14668
+ iQ(C, C, 1 / C[3]);
14658
14669
  const Q = OA(
14659
14670
  JA(),
14660
14671
  C,
@@ -14679,8 +14690,8 @@ class OB {
14679
14690
  );
14680
14691
  }
14681
14692
  }
14682
- const jI = -1, VB = 0, Go = 1, vB = 9e-3, wo = 1e-3, Fo = 9e-4, ro = 0.5, So = 60;
14683
- class uo {
14693
+ const jI = -1, VB = 0, yo = 1, vB = 9e-3, eo = 1e-3, no = 9e-4, Go = 0.5, wo = 60;
14694
+ class fo {
14684
14695
  camera_;
14685
14696
  orbitVelocity_ = new OB(0, 0, 0);
14686
14697
  panVelocity_ = M();
@@ -14701,7 +14712,7 @@ class uo {
14701
14712
  I?.yaw ?? 0,
14702
14713
  I?.pitch ?? 0
14703
14714
  ), I?.target && _I(this.currCenter_, I.target), this.dampingFactor_ = hA(
14704
- I?.dampingFactor ?? ro,
14715
+ I?.dampingFactor ?? Go,
14705
14716
  0,
14706
14717
  1
14707
14718
  ), this.scrollZoom_ = I?.scrollZoom ?? "always", this.updateCamera();
@@ -14761,7 +14772,7 @@ class uo {
14761
14772
  this.currPos_.phi += this.orbitVelocity_.phi, this.currPos_.theta += this.orbitVelocity_.theta, this.currPos_.radius += this.orbitVelocity_.radius * this.currPos_.radius, aI(this.currCenter_, this.currCenter_, this.panVelocity_);
14762
14773
  const I = Math.PI / 2 - m;
14763
14774
  this.currPos_.theta = hA(this.currPos_.theta, -I, I), this.currPos_.radius = Math.max(0.01, this.currPos_.radius), this.updateCamera();
14764
- const B = Math.pow(1 - this.dampingFactor_, A * So);
14775
+ const B = Math.pow(1 - this.dampingFactor_, A * wo);
14765
14776
  this.orbitVelocity_.phi *= B, this.orbitVelocity_.theta *= B, this.orbitVelocity_.radius *= B, $I(this.panVelocity_, this.panVelocity_, B), this.cutoffLowVelocity();
14766
14777
  }
14767
14778
  onPointerDown(A) {
@@ -14770,7 +14781,7 @@ class uo {
14770
14781
  }
14771
14782
  onPointerMove(A) {
14772
14783
  if (this.currMouseButton_ == jI) return;
14773
- const I = A.event, B = I.movementX ?? 0, C = I.movementY ?? 0, Q = this.currMouseButton_ === VB && !I.shiftKey, E = this.currMouseButton_ === VB && I.shiftKey || this.currMouseButton_ === Go;
14784
+ const I = A.event, B = I.movementX ?? 0, C = I.movementY ?? 0, Q = this.currMouseButton_ === VB && !I.shiftKey, E = this.currMouseButton_ === VB && I.shiftKey || this.currMouseButton_ === yo;
14774
14785
  Q && this.orbit(B, C), E && this.pan(B, C);
14775
14786
  }
14776
14787
  onWheel(A) {
@@ -14789,26 +14800,26 @@ class uo {
14789
14800
  this.orbitVelocity_.phi -= A * vB, this.orbitVelocity_.theta += I * vB;
14790
14801
  }
14791
14802
  pan(A, I) {
14792
- const B = this.currPos_.radius * wo, C = M();
14803
+ const B = this.currPos_.radius * eo, C = M();
14793
14804
  Ag(C, C, this.camera_.right, A), Ag(C, C, this.camera_.up, I), $I(C, C, B), Ig(this.panVelocity_, this.panVelocity_, C);
14794
14805
  }
14795
14806
  zoom(A) {
14796
- this.orbitVelocity_.radius += A * Fo;
14807
+ this.orbitVelocity_.radius += A * no;
14797
14808
  }
14798
14809
  updateCamera() {
14799
14810
  const A = aI(M(), this.currCenter_, this.currPos_.toVec3());
14800
14811
  this.camera_.transform.setTranslation(A), this.camera_.transform.targetTo(this.currCenter_);
14801
14812
  }
14802
14813
  cutoffLowVelocity() {
14803
- Math.abs(this.orbitVelocity_.phi) < m && (this.orbitVelocity_.phi = 0), Math.abs(this.orbitVelocity_.theta) < m && (this.orbitVelocity_.theta = 0), Math.abs(this.orbitVelocity_.radius) < m && (this.orbitVelocity_.radius = 0), ng(this.panVelocity_) < m && CQ(this.panVelocity_);
14814
+ Math.abs(this.orbitVelocity_.phi) < m && (this.orbitVelocity_.phi = 0), Math.abs(this.orbitVelocity_.theta) < m && (this.orbitVelocity_.theta = 0), Math.abs(this.orbitVelocity_.radius) < m && (this.orbitVelocity_.radius = 0), ng(this.panVelocity_) < m && BQ(this.panVelocity_);
14804
14815
  }
14805
14816
  }
14806
- const dC = 1.77, XB = 128, jB = 128 / dC, Ro = -1e6, co = 1e6;
14807
- class mo extends YC {
14817
+ const YC = 1.77, XB = 128, jB = 128 / YC, Fo = -1e6, ro = 1e6;
14818
+ class po extends JC {
14808
14819
  // width_ and height_ should always be defined by constructor (see setFrame)
14809
14820
  width_ = XB;
14810
14821
  height_ = jB;
14811
- viewportAspectRatio_ = dC;
14822
+ viewportAspectRatio_ = YC;
14812
14823
  viewportSize_ = [XB, jB];
14813
14824
  axes_;
14814
14825
  rotation_;
@@ -14819,7 +14830,7 @@ class mo extends YC {
14819
14830
  * @param props - Initialization properties.
14820
14831
  */
14821
14832
  constructor(A) {
14822
- super(), this.near_ = A.near ?? Ro, this.far_ = A.far ?? co, this.orientation_ = A.orientation ?? "XY", this.axes_ = YA(this.orientation_), this.rotation_ = dA(this.axes_), this.setFrame(A), this.updateProjectionMatrix();
14833
+ super(), this.near_ = A.near ?? Fo, this.far_ = A.far ?? ro, this.orientation_ = A.orientation ?? "XY", this.axes_ = YA(this.orientation_), this.rotation_ = dA(this.axes_), this.setFrame(A), this.updateProjectionMatrix();
14823
14834
  }
14824
14835
  /**
14825
14836
  * The world-space size of the rendered view as `[width, height]`.
@@ -14909,7 +14920,7 @@ class mo extends YC {
14909
14920
  updateProjectionMatrix() {
14910
14921
  const A = this.width_, I = this.height_, B = A / I;
14911
14922
  let C = 0.5 * A, Q = 0.5 * I;
14912
- this.viewportAspectRatio_ > B ? C *= this.viewportAspectRatio_ / B : Q *= B / this.viewportAspectRatio_, this.viewportSize_ = [2 * C, 2 * Q], $C(
14923
+ this.viewportAspectRatio_ > B ? C *= this.viewportAspectRatio_ / B : Q *= B / this.viewportAspectRatio_, this.viewportSize_ = [2 * C, 2 * Q], _C(
14913
14924
  this.projectionMatrix_,
14914
14925
  -C,
14915
14926
  C,
@@ -14921,7 +14932,7 @@ class mo extends YC {
14921
14932
  }
14922
14933
  }
14923
14934
  const zB = 0;
14924
- class To {
14935
+ class uo {
14925
14936
  camera_;
14926
14937
  scrollZoom_;
14927
14938
  dragActive_ = !1;
@@ -14993,8 +15004,8 @@ class To {
14993
15004
  !this.dragActive_ || I.button !== zB || (this.dragActive_ = !1, I.target?.releasePointerCapture?.(I.pointerId));
14994
15005
  }
14995
15006
  }
14996
- const No = 60, Uo = 1.77, oI = 0.1, zI = 180 - oI;
14997
- class xo extends YC {
15007
+ const So = 60, Ro = 1.77, oI = 0.1, zI = 180 - oI;
15008
+ class mo extends JC {
14998
15009
  fov_;
14999
15010
  aspectRatio_;
15000
15011
  /**
@@ -15004,8 +15015,8 @@ class xo extends YC {
15004
15015
  */
15005
15016
  constructor(A = {}) {
15006
15017
  const {
15007
- fov: I = No,
15008
- aspectRatio: B = Uo,
15018
+ fov: I = So,
15019
+ aspectRatio: B = Ro,
15009
15020
  near: C = 0.1,
15010
15021
  far: Q = 1e4,
15011
15022
  position: E = x(0, 0, 0)
@@ -15051,9 +15062,9 @@ class xo extends YC {
15051
15062
  }
15052
15063
  /** @hidden */
15053
15064
  updateProjectionMatrix() {
15054
- zC(
15065
+ jC(
15055
15066
  this.projectionMatrix_,
15056
- PC(this.fov),
15067
+ ZC(this.fov),
15057
15068
  this.aspectRatio_,
15058
15069
  this.near_,
15059
15070
  this.far_
@@ -15061,38 +15072,38 @@ class xo extends YC {
15061
15072
  }
15062
15073
  }
15063
15074
  export {
15064
- fo as AxesLayer,
15075
+ qo as AxesLayer,
15065
15076
  AA as Box2,
15066
15077
  VA as Box3,
15067
- YC as Camera,
15078
+ JC as Camera,
15068
15079
  T as Color,
15069
- no as Frustum,
15070
- Yo as Idetik,
15080
+ to as Frustum,
15081
+ ko as Idetik,
15071
15082
  Jg as ImageLayer,
15072
- PQ as ImageRenderable,
15073
- $Q as LabelImageRenderable,
15083
+ ZQ as ImageRenderable,
15084
+ _Q as LabelImageRenderable,
15074
15085
  Yg as LabelLayer,
15075
15086
  KI as Layer,
15076
15087
  bA as OmeZarrImageSource,
15077
- uo as OrbitControls,
15078
- mo as OrthographicCamera,
15079
- To as PanZoomControls,
15080
- xo as PerspectiveCamera,
15081
- po as PointsRenderable,
15082
- ho as ProjectedLineRenderable,
15088
+ fo as OrbitControls,
15089
+ po as OrthographicCamera,
15090
+ uo as PanZoomControls,
15091
+ mo as PerspectiveCamera,
15092
+ lo as PointsRenderable,
15093
+ ao as ProjectedLineRenderable,
15083
15094
  zA as RenderableObject,
15084
- aE as Stats,
15095
+ oE as Stats,
15085
15096
  oC as TrsTransform,
15086
- nE as Viewport,
15087
- CE as VolumeLayer,
15088
- IE as VolumeRenderable,
15097
+ Lo as Viewport,
15098
+ BE as VolumeLayer,
15099
+ AE as VolumeRenderable,
15089
15100
  Ng as createExplorationPolicy,
15090
15101
  Ug as createImageSourcePolicy,
15091
- Lo as createNoPrefetchPolicy,
15092
- ko as createPlaybackPolicy,
15093
- Ko as loadOmeZarrPlate,
15094
- Ho as loadOmeZarrWell,
15095
- qo as loadOmeroChannels,
15096
- lo as loadOmeroDefaults
15102
+ No as createNoPrefetchPolicy,
15103
+ co as createPlaybackPolicy,
15104
+ Yo as loadOmeZarrPlate,
15105
+ Mo as loadOmeZarrWell,
15106
+ Ko as loadOmeroChannels,
15107
+ Ho as loadOmeroDefaults
15097
15108
  };
15098
15109
  //# sourceMappingURL=index.js.map