@idetik/core 0.35.5 → 0.36.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.
Files changed (31) hide show
  1. package/README.md +63 -119
  2. package/dist/index.d.ts +87 -99
  3. package/dist/index.js +782 -765
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +36 -36
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/dist/types/src/core/layer.d.ts +3 -5
  8. package/dist/types/src/core/layer.d.ts.map +1 -1
  9. package/dist/types/src/core/renderer.d.ts +2 -1
  10. package/dist/types/src/core/renderer.d.ts.map +1 -1
  11. package/dist/types/src/idetik.d.ts +2 -3
  12. package/dist/types/src/idetik.d.ts.map +1 -1
  13. package/dist/types/src/layers/image_layer.d.ts +3 -2
  14. package/dist/types/src/layers/image_layer.d.ts.map +1 -1
  15. package/dist/types/src/layers/label_layer.d.ts +1 -2
  16. package/dist/types/src/layers/label_layer.d.ts.map +1 -1
  17. package/dist/types/src/layers/volume_layer.d.ts +2 -1
  18. package/dist/types/src/layers/volume_layer.d.ts.map +1 -1
  19. package/dist/types/src/objects/cameras/orthographic_camera.d.ts +12 -9
  20. package/dist/types/src/objects/cameras/orthographic_camera.d.ts.map +1 -1
  21. package/dist/types/src/objects/cameras/perspective_camera.d.ts +1 -1
  22. package/dist/types/src/objects/cameras/perspective_camera.d.ts.map +1 -1
  23. package/dist/types/src/objects/renderable/image_renderable.d.ts +7 -1
  24. package/dist/types/src/objects/renderable/image_renderable.d.ts.map +1 -1
  25. package/dist/types/src/objects/renderable/volume_renderable.d.ts +5 -1
  26. package/dist/types/src/objects/renderable/volume_renderable.d.ts.map +1 -1
  27. package/dist/types/src/renderers/webgl_renderer.d.ts +4 -1
  28. package/dist/types/src/renderers/webgl_renderer.d.ts.map +1 -1
  29. package/dist/types/src/renderers/webgl_state.d.ts +4 -0
  30. package/dist/types/src/renderers/webgl_state.d.ts.map +1 -1
  31. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class RC {
1
+ class NC {
2
2
  canvas_;
3
3
  width_ = 0;
4
4
  height_ = 0;
@@ -27,7 +27,7 @@ class RC {
27
27
  return this.renderedObjects_;
28
28
  }
29
29
  }
30
- var NC = `#version 300 es
30
+ var cC = `#version 300 es
31
31
 
32
32
  layout (location = 0) in vec3 a_position;
33
33
  layout (location = 3) in vec3 a_prevPosition;
@@ -87,7 +87,7 @@ void main() {
87
87
 
88
88
 
89
89
  gl_PointSize = 5.0;
90
- }`, cC = `#version 300 es
90
+ }`, UC = `#version 300 es
91
91
 
92
92
  precision mediump float;
93
93
 
@@ -139,7 +139,7 @@ void main() {
139
139
  float texel = float(texture(u_imageSampler, v_texCoords).r);
140
140
  float value = (texel + u_valueOffset) * u_valueScale;
141
141
  fragColor = vec4(value * u_color, u_opacity);
142
- }`, UC = `#version 300 es
142
+ }`, kC = `#version 300 es
143
143
 
144
144
  precision mediump float;
145
145
 
@@ -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
- }`, kC = `#version 300 es
162
+ }`, LC = `#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
- }`, LC = `#version 300 es
182
+ }`, JC = `#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
- }`, JC = `#version 300 es
192
+ }`, YC = `#version 300 es
193
193
 
194
194
  precision mediump float;
195
195
 
@@ -355,7 +355,7 @@ void main() {
355
355
  }
356
356
 
357
357
  fragColor = accumulatedColor;
358
- }`, bg = `#version 300 es
358
+ }`, Zg = `#version 300 es
359
359
  #pragma inject_defines
360
360
 
361
361
  precision highp float;
@@ -454,18 +454,18 @@ void main() {
454
454
 
455
455
  fragColor = vec4(color.rgb, alpha);
456
456
  }`;
457
- const YC = {
457
+ const MC = {
458
458
  projectedLine: {
459
- vertex: NC,
460
- fragment: cC
459
+ vertex: cC,
460
+ fragment: UC
461
461
  },
462
462
  points: {
463
- vertex: UC,
464
- fragment: kC
463
+ vertex: kC,
464
+ fragment: LC
465
465
  },
466
466
  wireframe: {
467
- vertex: LC,
468
- fragment: JC
467
+ vertex: JC,
468
+ fragment: YC
469
469
  },
470
470
  floatScalarImage: {
471
471
  vertex: WA,
@@ -483,11 +483,11 @@ const YC = {
483
483
  },
484
484
  labelImage: {
485
485
  vertex: WA,
486
- fragment: bg
486
+ fragment: Zg
487
487
  },
488
488
  intLabelImage: {
489
489
  vertex: WA,
490
- fragment: bg,
490
+ fragment: Zg,
491
491
  fragmentDefines: /* @__PURE__ */ new Map([["TEXTURE_DATA_TYPE_INT", "1"]])
492
492
  },
493
493
  floatVolume: {
@@ -504,12 +504,12 @@ const YC = {
504
504
  fragment: lI,
505
505
  fragmentDefines: /* @__PURE__ */ new Map([["TEXTURE_DATA_TYPE_UINT", "1"]])
506
506
  }
507
- }, Zg = {
507
+ }, Pg = {
508
508
  debug: 10,
509
509
  info: 20,
510
510
  warn: 30,
511
511
  error: 40
512
- }, MC = {
512
+ }, dC = {
513
513
  debug: "\x1B[90m",
514
514
  // gray
515
515
  info: "\x1B[36m",
@@ -519,7 +519,7 @@ const YC = {
519
519
  error: "\x1B[31m"
520
520
  // red
521
521
  };
522
- function dC() {
522
+ function KC() {
523
523
  const g = typeof process < "u" && typeof process.env?.NODE_ENV == "string" ? process.env.NODE_ENV : void 0;
524
524
  if (g === "production" || g === "development" || g === "test")
525
525
  return g;
@@ -531,7 +531,7 @@ function dC() {
531
531
  return "development";
532
532
  }
533
533
  class k {
534
- static logLevel_ = dC() === "production" ? "warn" : "debug";
534
+ static logLevel_ = KC() === "production" ? "warn" : "debug";
535
535
  static setLogLevel(A) {
536
536
  k.logLevel_ = A;
537
537
  }
@@ -548,8 +548,8 @@ class k {
548
548
  k.log("error", A, I, ...B);
549
549
  }
550
550
  static log(A, I, B, ...C) {
551
- if (Zg[A] < Zg[k.logLevel_]) return;
552
- const Q = (/* @__PURE__ */ new Date()).toISOString(), E = MC[A], i = `[${Q}][${A.toUpperCase()}][${I}]`, o = [`${E}${i}`, B, ...C];
551
+ if (Pg[A] < Pg[k.logLevel_]) return;
552
+ const Q = (/* @__PURE__ */ new Date()).toISOString(), E = dC[A], i = `[${Q}][${A.toUpperCase()}][${I}]`, o = [`${E}${i}`, B, ...C];
553
553
  switch (A) {
554
554
  case "debug":
555
555
  console.debug(...o);
@@ -566,7 +566,7 @@ class k {
566
566
  }
567
567
  }
568
568
  }
569
- class KC {
569
+ class HC {
570
570
  gl_;
571
571
  program_;
572
572
  uniformInfo_ = /* @__PURE__ */ new Map();
@@ -648,7 +648,7 @@ class KC {
648
648
  for (let I = 0; I < A; I++) {
649
649
  const B = this.gl_.getActiveUniform(this.program_, I);
650
650
  if (B) {
651
- if (!qC.has(B.type))
651
+ if (!lC.has(B.type))
652
652
  throw new Error(
653
653
  `Unsupported uniform type "${B.type}" (GLenum) found in shader program for uniform "${B.name}"`
654
654
  );
@@ -689,7 +689,7 @@ class KC {
689
689
  return Array.from(this.uniformInfo_.keys());
690
690
  }
691
691
  }
692
- const HC = typeof window < "u" ? [
692
+ const qC = typeof window < "u" ? [
693
693
  WebGL2RenderingContext.BOOL,
694
694
  WebGL2RenderingContext.FLOAT,
695
695
  WebGL2RenderingContext.INT,
@@ -714,10 +714,10 @@ const HC = typeof window < "u" ? [
714
714
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_3D,
715
715
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_CUBE,
716
716
  WebGL2RenderingContext.UNSIGNED_INT_SAMPLER_2D_ARRAY
717
- ] : [], qC = new Set(
718
- HC
717
+ ] : [], lC = new Set(
718
+ qC
719
719
  ), fI = "#pragma inject_defines";
720
- class lC {
720
+ class fC {
721
721
  gl_;
722
722
  programs_ = /* @__PURE__ */ new Map();
723
723
  constructor(A) {
@@ -726,14 +726,14 @@ class lC {
726
726
  use(A) {
727
727
  let I = this.programs_.get(A);
728
728
  if (I === void 0) {
729
- const B = YC[A], C = Pg(
729
+ const B = MC[A], C = Og(
730
730
  B.vertex,
731
731
  B.vertexDefines
732
- ), Q = Pg(
732
+ ), Q = Og(
733
733
  B.fragment,
734
734
  B.fragmentDefines
735
735
  );
736
- I = new KC(
736
+ I = new HC(
737
737
  this.gl_,
738
738
  C,
739
739
  Q
@@ -747,7 +747,7 @@ class lC {
747
747
  return I;
748
748
  }
749
749
  }
750
- function Pg(g, A) {
750
+ function Og(g, A) {
751
751
  if (A === void 0 || A.size == 0) return g;
752
752
  if (!g.includes(fI))
753
753
  throw new Error(
@@ -759,25 +759,25 @@ ${C}`;
759
759
  return g.replace(fI, Q);
760
760
  }
761
761
  const CI = {};
762
- function bB(g) {
762
+ function ZB(g) {
763
763
  const A = g ?? "";
764
764
  return CI[A] = (CI[A] ?? 0) + 1, g ? `${g}-${CI[A]}` : String(CI[A]);
765
765
  }
766
766
  class hg {
767
- id = bB();
767
+ id = ZB();
768
768
  }
769
- var T = 1e-6, X = typeof Float32Array < "u" ? Float32Array : Array, fC = Math.PI / 180;
770
- function pC(g) {
771
- return g * fC;
769
+ var T = 1e-6, X = typeof Float32Array < "u" ? Float32Array : Array, pC = Math.PI / 180;
770
+ function mC(g) {
771
+ return g * pC;
772
772
  }
773
- function ZB() {
773
+ function PB() {
774
774
  var g = new X(9);
775
775
  return X != 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;
776
776
  }
777
- function mC(g, A) {
777
+ function uC(g, A) {
778
778
  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;
779
779
  }
780
- function uC(g, A, I, B, C, Q, E, i, o) {
780
+ function TC(g, A, I, B, C, Q, E, i, o) {
781
781
  var a = new X(9);
782
782
  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;
783
783
  }
@@ -793,18 +793,18 @@ function vI(g, A, I) {
793
793
  var B = A[0], C = A[1], Q = A[2], E = A[3], i = A[4], o = A[5], a = A[6], D = A[7], s = A[8], h = A[9], t = A[10], y = A[11], n = A[12], F = A[13], G = A[14], J = A[15], U = I[0], S = I[1], r = I[2], c = I[3];
794
794
  return g[0] = U * B + S * i + r * s + c * n, g[1] = U * C + S * o + r * h + c * F, g[2] = U * Q + S * a + r * t + c * G, g[3] = U * E + S * D + r * y + c * J, U = I[4], S = I[5], r = I[6], c = I[7], g[4] = U * B + S * i + r * s + c * n, g[5] = U * C + S * o + r * h + c * F, g[6] = U * Q + S * a + r * t + c * G, g[7] = U * E + S * D + r * y + c * J, U = I[8], S = I[9], r = I[10], c = I[11], g[8] = U * B + S * i + r * s + c * n, g[9] = U * C + S * o + r * h + c * F, g[10] = U * Q + S * a + r * t + c * G, g[11] = U * E + S * D + r * y + c * J, U = I[12], S = I[13], r = I[14], c = I[15], g[12] = U * B + S * i + r * s + c * n, g[13] = U * C + S * o + r * h + c * F, g[14] = U * Q + S * a + r * t + c * G, g[15] = U * E + S * D + r * y + c * J, g;
795
795
  }
796
- function TC(g, A, I) {
796
+ function xC(g, A, I) {
797
797
  var B = I[0], C = I[1], Q = I[2], E, i, o, a, D, s, h, t, y, n, F, G;
798
798
  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], D = A[4], s = A[5], h = A[6], t = A[7], y = 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] = D, g[5] = s, g[6] = h, g[7] = t, g[8] = y, g[9] = n, g[10] = F, g[11] = G, g[12] = E * B + D * C + y * Q + A[12], g[13] = i * B + s * 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;
799
799
  }
800
- function PB(g, A) {
800
+ function OB(g, A) {
801
801
  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;
802
802
  }
803
- function xC(g, A, I, B) {
803
+ function WC(g, A, I, B) {
804
804
  var C = A[0], Q = A[1], E = A[2], i = A[3], o = C + C, a = Q + Q, D = E + E, s = C * o, h = C * a, t = C * D, y = Q * a, n = Q * D, F = E * D, G = i * o, J = i * a, U = i * D, S = B[0], r = B[1], c = B[2];
805
805
  return g[0] = (1 - (y + F)) * S, g[1] = (h + U) * S, g[2] = (t - J) * S, g[3] = 0, g[4] = (h - U) * r, g[5] = (1 - (s + F)) * r, g[6] = (n + G) * r, g[7] = 0, g[8] = (t + J) * c, g[9] = (n - G) * c, g[10] = (1 - (s + y)) * c, g[11] = 0, g[12] = I[0], g[13] = I[1], g[14] = I[2], g[15] = 1, g;
806
806
  }
807
- function WC(g, A, I, B, C) {
807
+ function bC(g, A, I, B, C) {
808
808
  var Q = 1 / Math.tan(A / 2);
809
809
  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) {
810
810
  var E = 1 / (B - C);
@@ -813,21 +813,21 @@ function WC(g, A, I, B, C) {
813
813
  g[10] = -1, g[14] = -2 * B;
814
814
  return g;
815
815
  }
816
- var bC = WC;
817
- function ZC(g, A, I, B, C, Q, E) {
816
+ var ZC = bC;
817
+ function PC(g, A, I, B, C, Q, E) {
818
818
  var i = 1 / (A - I), o = 1 / (B - C), a = 1 / (Q - E);
819
819
  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;
820
820
  }
821
- var PC = ZC;
822
- function OC(g, A, I, B) {
821
+ var OC = PC;
822
+ function VC(g, A, I, B) {
823
823
  var C = A[0], Q = A[1], E = A[2], i = B[0], o = B[1], a = B[2], D = C - I[0], s = Q - I[1], h = E - I[2], t = D * D + s * s + h * h;
824
824
  t > 0 && (t = 1 / Math.sqrt(t), D *= t, s *= t, h *= t);
825
825
  var y = o * h - a * s, n = a * D - i * h, F = i * s - o * D;
826
826
  return t = y * y + n * n + F * F, t > 0 && (t = 1 / Math.sqrt(t), y *= t, n *= t, F *= t), g[0] = y, g[1] = n, g[2] = F, g[3] = 0, g[4] = s * F - h * n, g[5] = h * y - D * F, g[6] = D * n - s * y, g[7] = 0, g[8] = D, g[9] = s, g[10] = h, g[11] = 0, g[12] = C, g[13] = Q, g[14] = E, g[15] = 1, g;
827
827
  }
828
- function VC(g, A) {
829
- 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], D = g[8], s = g[9], h = g[10], t = g[11], y = g[12], n = g[13], F = g[14], G = g[15], J = A[0], U = A[1], S = A[2], r = A[3], c = A[4], f = A[5], Z = A[6], j = A[7], b = A[8], z = A[9], iA = A[10], oA = A[11], P = A[12], Tg = A[13], xg = A[14], Wg = A[15];
830
- return Math.abs(I - J) <= T * Math.max(1, Math.abs(I), Math.abs(J)) && Math.abs(B - U) <= T * Math.max(1, Math.abs(B), Math.abs(U)) && Math.abs(C - S) <= T * Math.max(1, Math.abs(C), Math.abs(S)) && Math.abs(Q - r) <= T * Math.max(1, Math.abs(Q), Math.abs(r)) && Math.abs(E - c) <= T * Math.max(1, Math.abs(E), Math.abs(c)) && Math.abs(i - f) <= T * Math.max(1, Math.abs(i), Math.abs(f)) && Math.abs(o - Z) <= T * Math.max(1, Math.abs(o), Math.abs(Z)) && Math.abs(a - j) <= T * Math.max(1, Math.abs(a), Math.abs(j)) && Math.abs(D - b) <= T * Math.max(1, Math.abs(D), Math.abs(b)) && Math.abs(s - z) <= T * Math.max(1, Math.abs(s), Math.abs(z)) && Math.abs(h - iA) <= T * Math.max(1, Math.abs(h), Math.abs(iA)) && Math.abs(t - oA) <= T * Math.max(1, Math.abs(t), Math.abs(oA)) && Math.abs(y - P) <= T * Math.max(1, Math.abs(y), Math.abs(P)) && Math.abs(n - Tg) <= T * Math.max(1, Math.abs(n), Math.abs(Tg)) && Math.abs(F - xg) <= T * Math.max(1, Math.abs(F), Math.abs(xg)) && Math.abs(G - Wg) <= T * Math.max(1, Math.abs(G), Math.abs(Wg));
828
+ function vC(g, A) {
829
+ 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], D = g[8], s = g[9], h = g[10], t = g[11], y = g[12], n = g[13], F = g[14], G = g[15], J = A[0], U = A[1], S = A[2], r = A[3], c = A[4], f = A[5], Z = A[6], j = A[7], b = A[8], z = A[9], iA = A[10], oA = A[11], P = A[12], xg = A[13], Wg = A[14], bg = A[15];
830
+ return Math.abs(I - J) <= T * Math.max(1, Math.abs(I), Math.abs(J)) && Math.abs(B - U) <= T * Math.max(1, Math.abs(B), Math.abs(U)) && Math.abs(C - S) <= T * Math.max(1, Math.abs(C), Math.abs(S)) && Math.abs(Q - r) <= T * Math.max(1, Math.abs(Q), Math.abs(r)) && Math.abs(E - c) <= T * Math.max(1, Math.abs(E), Math.abs(c)) && Math.abs(i - f) <= T * Math.max(1, Math.abs(i), Math.abs(f)) && Math.abs(o - Z) <= T * Math.max(1, Math.abs(o), Math.abs(Z)) && Math.abs(a - j) <= T * Math.max(1, Math.abs(a), Math.abs(j)) && Math.abs(D - b) <= T * Math.max(1, Math.abs(D), Math.abs(b)) && Math.abs(s - z) <= T * Math.max(1, Math.abs(s), Math.abs(z)) && Math.abs(h - iA) <= T * Math.max(1, Math.abs(h), Math.abs(iA)) && Math.abs(t - oA) <= T * Math.max(1, Math.abs(t), Math.abs(oA)) && Math.abs(y - P) <= T * Math.max(1, Math.abs(y), Math.abs(P)) && Math.abs(n - xg) <= T * Math.max(1, Math.abs(n), Math.abs(xg)) && Math.abs(F - Wg) <= T * Math.max(1, Math.abs(F), Math.abs(Wg)) && Math.abs(G - bg) <= T * Math.max(1, Math.abs(G), Math.abs(bg));
831
831
  }
832
832
  function d() {
833
833
  var g = new X(3);
@@ -857,7 +857,7 @@ function JA(g, A, I) {
857
857
  function yg(g, A, I) {
858
858
  return g[0] = A[0] - I[0], g[1] = A[1] - I[1], g[2] = A[2] - I[2], g;
859
859
  }
860
- function vC(g, A, I) {
860
+ function XC(g, A, I) {
861
861
  return g[0] = A[0] * I[0], g[1] = A[1] * I[1], g[2] = A[2] * I[2], g;
862
862
  }
863
863
  function vA(g, A, I) {
@@ -866,11 +866,11 @@ function vA(g, A, I) {
866
866
  function jI(g, A, I, B) {
867
867
  return g[0] = A[0] + I[0] * B, g[1] = A[1] + I[1] * B, g[2] = A[2] + I[2] * B, g;
868
868
  }
869
- function Og(g, A) {
869
+ function Vg(g, A) {
870
870
  var I = A[0] - g[0], B = A[1] - g[1], C = A[2] - g[2];
871
871
  return I * I + B * B + C * C;
872
872
  }
873
- function OB(g, A) {
873
+ function VB(g, A) {
874
874
  var I = A[0], B = A[1], C = A[2], Q = I * I + B * B + C * C;
875
875
  return Q > 0 && (Q = 1 / Math.sqrt(Q)), g[0] = A[0] * Q, g[1] = A[1] * Q, g[2] = A[2] * Q, g;
876
876
  }
@@ -885,18 +885,18 @@ function eg(g, A, I) {
885
885
  var B = A[0], C = A[1], Q = A[2], E = I[3] * B + I[7] * C + I[11] * Q + I[15];
886
886
  return E = E || 1, g[0] = (I[0] * B + I[4] * C + I[8] * Q + I[12]) / E, g[1] = (I[1] * B + I[5] * C + I[9] * Q + I[13]) / E, g[2] = (I[2] * B + I[6] * C + I[10] * Q + I[14]) / E, g;
887
887
  }
888
- function VB(g, A, I) {
888
+ function vB(g, A, I) {
889
889
  var B = I[0], C = I[1], Q = I[2], E = I[3], i = A[0], o = A[1], a = A[2], D = C * a - Q * o, s = Q * i - B * a, h = B * o - C * i;
890
890
  return D = D + D, s = s + s, h = h + h, g[0] = i + E * D + C * h - Q * s, g[1] = o + E * s + Q * D - B * h, g[2] = a + E * h + B * s - C * D, g;
891
891
  }
892
- function XC(g) {
892
+ function jC(g) {
893
893
  return g[0] = 0, g[1] = 0, g[2] = 0, g;
894
894
  }
895
895
  function ng(g, A) {
896
896
  var I = g[0], B = g[1], C = g[2], Q = A[0], E = A[1], i = A[2];
897
897
  return Math.abs(I - Q) <= T * Math.max(1, Math.abs(I), Math.abs(Q)) && Math.abs(B - E) <= T * Math.max(1, Math.abs(B), Math.abs(E)) && Math.abs(C - i) <= T * Math.max(1, Math.abs(C), Math.abs(i));
898
898
  }
899
- var zI = yg, jC = tg;
899
+ var zI = yg, zC = tg;
900
900
  (function() {
901
901
  var g = d();
902
902
  return function(A, I, B, C, Q, E) {
@@ -910,7 +910,7 @@ function YA() {
910
910
  var g = new X(4);
911
911
  return X != Float32Array && (g[0] = 0, g[1] = 0, g[2] = 0, g[3] = 0), g;
912
912
  }
913
- function zC(g) {
913
+ function _C(g) {
914
914
  var A = new X(4);
915
915
  return A[0] = g[0], A[1] = g[1], A[2] = g[2], A[3] = g[3], A;
916
916
  }
@@ -918,13 +918,13 @@ function DI(g, A, I, B) {
918
918
  var C = new X(4);
919
919
  return C[0] = g, C[1] = A, C[2] = I, C[3] = B, C;
920
920
  }
921
- function _C(g, A) {
921
+ function $C(g, A) {
922
922
  return g[0] = A[0], g[1] = A[1], g[2] = A[2], g[3] = A[3], g;
923
923
  }
924
- function $C(g, A, I) {
924
+ function AQ(g, A, I) {
925
925
  return g[0] = A[0] * I, g[1] = A[1] * I, g[2] = A[2] * I, g[3] = A[3] * I, g;
926
926
  }
927
- function AQ(g, A) {
927
+ function IQ(g, A) {
928
928
  var I = A[0], B = A[1], C = A[2], Q = A[3], E = I * I + B * B + C * C + Q * Q;
929
929
  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;
930
930
  }
@@ -945,12 +945,12 @@ function sI() {
945
945
  var g = new X(4);
946
946
  return X != Float32Array && (g[0] = 0, g[1] = 0, g[2] = 0), g[3] = 1, g;
947
947
  }
948
- function IQ(g, A, I) {
948
+ function gQ(g, A, I) {
949
949
  I = I * 0.5;
950
950
  var B = Math.sin(I);
951
951
  return g[0] = B * A[0], g[1] = B * A[1], g[2] = B * A[2], g[3] = Math.cos(I), g;
952
952
  }
953
- function gQ(g, A, I) {
953
+ function BQ(g, A, I) {
954
954
  var B = A[0], C = A[1], Q = A[2], E = A[3], i = I[0], o = I[1], a = I[2], D = I[3];
955
955
  return g[0] = B * D + E * i + C * a - Q * o, g[1] = C * D + E * o + Q * i - B * a, g[2] = Q * D + E * a + B * o - C * i, g[3] = E * D - B * i - C * o - Q * a, g;
956
956
  }
@@ -970,12 +970,12 @@ function Gg(g, A) {
970
970
  }
971
971
  return g;
972
972
  }
973
- var BQ = zC, CQ = _C, JI = AQ;
973
+ var CQ = _C, QQ = $C, JI = IQ;
974
974
  (function() {
975
975
  var g = d(), A = p(1, 0, 0), I = p(0, 1, 0);
976
976
  return function(B, C, Q) {
977
977
  var E = aI(C, Q);
978
- return E < -0.999999 ? (EI(g, A, C), jC(g) < 1e-6 && EI(g, I, C), OB(g, g), IQ(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, JI(B, B));
978
+ return E < -0.999999 ? (EI(g, A, C), zC(g) < 1e-6 && EI(g, I, C), VB(g, g), gQ(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, JI(B, B));
979
979
  };
980
980
  })();
981
981
  (function() {
@@ -985,16 +985,16 @@ var BQ = zC, CQ = _C, JI = AQ;
985
985
  };
986
986
  })();
987
987
  (function() {
988
- var g = ZB();
988
+ var g = PB();
989
989
  return function(A, I, B, C) {
990
990
  return g[0] = B[0], g[3] = B[1], g[6] = B[2], g[1] = C[0], g[4] = C[1], g[7] = C[2], g[2] = -I[0], g[5] = -I[1], g[8] = -I[2], JI(A, Gg(A, g));
991
991
  };
992
992
  })();
993
- function vB() {
993
+ function XB() {
994
994
  var g = new X(2);
995
995
  return X != Float32Array && (g[0] = 0, g[1] = 0), g;
996
996
  }
997
- function Vg(g) {
997
+ function vg(g) {
998
998
  var A = new X(2);
999
999
  return A[0] = g[0], A[1] = g[1], A;
1000
1000
  }
@@ -1002,19 +1002,19 @@ function V(g, A) {
1002
1002
  var I = new X(2);
1003
1003
  return I[0] = g, I[1] = A, I;
1004
1004
  }
1005
- function QQ(g, A) {
1005
+ function EQ(g, A) {
1006
1006
  var I = A[0] - g[0], B = A[1] - g[1];
1007
1007
  return Math.sqrt(I * I + B * B);
1008
1008
  }
1009
- function EQ(g) {
1009
+ function iQ(g) {
1010
1010
  var A = g[0], I = g[1];
1011
1011
  return A * A + I * I;
1012
1012
  }
1013
- function iQ(g, A, I, B) {
1013
+ function oQ(g, A, I, B) {
1014
1014
  var C = A[0], Q = A[1];
1015
1015
  return g[0] = C + B * (I[0] - C), g[1] = Q + B * (I[1] - Q), g;
1016
1016
  }
1017
- function vg(g, A) {
1017
+ function Xg(g, A) {
1018
1018
  return g[0] === A[0] && g[1] === A[1];
1019
1019
  }
1020
1020
  function mI(g, A) {
@@ -1022,7 +1022,7 @@ function mI(g, A) {
1022
1022
  return Math.abs(I - C) <= T * Math.max(1, Math.abs(I), Math.abs(C)) && Math.abs(B - Q) <= T * Math.max(1, Math.abs(B), Math.abs(Q));
1023
1023
  }
1024
1024
  (function() {
1025
- var g = vB();
1025
+ var g = XB();
1026
1026
  return function(A, I, B, C, Q, E) {
1027
1027
  var i, o;
1028
1028
  for (I || (I = 2), B || (B = 0), C ? o = Math.min(C * I + B, A.length) : o = A.length, i = B; i < o; i += I)
@@ -1072,7 +1072,7 @@ class SA {
1072
1072
  eg(Q, E, A), this.expandWithPoint(Q);
1073
1073
  }
1074
1074
  }
1075
- const oQ = {
1075
+ const aQ = {
1076
1076
  position: 0,
1077
1077
  normal: 1,
1078
1078
  uv: 2,
@@ -1135,7 +1135,7 @@ class mA extends hg {
1135
1135
  return this.attributes_.find((I) => I.type === A);
1136
1136
  }
1137
1137
  }
1138
- class aQ {
1138
+ class DQ {
1139
1139
  gl_;
1140
1140
  buffers_ = /* @__PURE__ */ new Map();
1141
1141
  currentGeometry_ = null;
@@ -1171,7 +1171,7 @@ class aQ {
1171
1171
  this.gl_.bindBuffer(C, Q), this.gl_.bufferData(C, B, this.gl_.STATIC_DRAW);
1172
1172
  const { attributes: E, strideBytes: i } = A;
1173
1173
  E.forEach((D) => {
1174
- const s = oQ[D.type];
1174
+ const s = aQ[D.type];
1175
1175
  this.gl_.vertexAttribPointer(
1176
1176
  s,
1177
1177
  D.itemSize,
@@ -1190,7 +1190,7 @@ class aQ {
1190
1190
  this.buffers_.set(A, o), this.gl_.bindVertexArray(null);
1191
1191
  }
1192
1192
  }
1193
- function DQ(g) {
1193
+ function sQ(g) {
1194
1194
  return g === 1 || g === 2 || g === 4 || g === 8;
1195
1195
  }
1196
1196
  function wg(g) {
@@ -1210,7 +1210,7 @@ function wg(g) {
1210
1210
  return "float";
1211
1211
  throw new Error("Unsupported buffer type.");
1212
1212
  }
1213
- function sQ(g) {
1213
+ function hQ(g) {
1214
1214
  switch (g.dataFormat) {
1215
1215
  case "scalar":
1216
1216
  return 1;
@@ -1220,7 +1220,7 @@ function sQ(g) {
1220
1220
  return 4;
1221
1221
  }
1222
1222
  }
1223
- function hQ(g) {
1223
+ function tQ(g) {
1224
1224
  switch (g.dataType) {
1225
1225
  case "byte":
1226
1226
  case "unsigned_byte":
@@ -1235,13 +1235,13 @@ function hQ(g) {
1235
1235
  }
1236
1236
  }
1237
1237
  function _I(g) {
1238
- const A = sQ(g) * hQ(g), I = Math.max(1, g.mipmapLevels);
1238
+ const A = hQ(g) * tQ(g), I = Math.max(1, g.mipmapLevels);
1239
1239
  let B = Math.max(1, g.width), C = Math.max(1, g.height), Q = Math.max(1, g.depth), E = 0;
1240
1240
  for (let i = 0; i < I; ++i)
1241
1241
  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));
1242
1242
  return E;
1243
1243
  }
1244
- function tQ(g) {
1244
+ function yQ(g) {
1245
1245
  if (g.dataFormat === "rgb" || g.dataFormat === "rgba")
1246
1246
  return [0, 1];
1247
1247
  switch (g.dataType) {
@@ -1292,7 +1292,7 @@ class Fg extends hg {
1292
1292
  return "Texture";
1293
1293
  }
1294
1294
  }
1295
- class yQ {
1295
+ class eQ {
1296
1296
  gl_;
1297
1297
  textures_ = /* @__PURE__ */ new Map();
1298
1298
  currentTexture_ = null;
@@ -1564,7 +1564,7 @@ class AA {
1564
1564
  * the first element, and avoids biasing toward (0,0).
1565
1565
  */
1566
1566
  constructor(A, I) {
1567
- this.min = A ? Vg(A) : V(1 / 0, 1 / 0), this.max = I ? Vg(I) : V(-1 / 0, -1 / 0);
1567
+ this.min = A ? vg(A) : V(1 / 0, 1 / 0), this.max = I ? vg(I) : V(-1 / 0, -1 / 0);
1568
1568
  }
1569
1569
  clone() {
1570
1570
  return new AA(this.min, this.max);
@@ -1577,7 +1577,7 @@ class AA {
1577
1577
  return !(A.max[0] <= I.min[0] || A.min[0] >= I.max[0] || A.max[1] <= I.min[1] || A.min[1] >= I.max[1]);
1578
1578
  }
1579
1579
  static equals(A, I) {
1580
- return vg(A.min, I.min) && vg(A.max, I.max);
1580
+ return Xg(A.min, I.min) && Xg(A.max, I.max);
1581
1581
  }
1582
1582
  floor() {
1583
1583
  return new AA(
@@ -1590,7 +1590,7 @@ class AA {
1590
1590
  return { x: A, y: I, width: B, height: C };
1591
1591
  }
1592
1592
  }
1593
- class eQ {
1593
+ class nQ {
1594
1594
  gl_;
1595
1595
  enabledCapabilities_ = /* @__PURE__ */ new Map();
1596
1596
  depthMaskEnabled_ = null;
@@ -1600,6 +1600,9 @@ class eQ {
1600
1600
  currentViewport_ = null;
1601
1601
  currentScissor_ = null;
1602
1602
  currentCullingMode_ = null;
1603
+ stencilFunc_ = null;
1604
+ stencilRef_ = null;
1605
+ stencilFuncMask_ = null;
1603
1606
  constructor(A) {
1604
1607
  this.gl_ = A, this.gl_.frontFace(this.gl_.CW);
1605
1608
  }
@@ -1689,15 +1692,19 @@ class eQ {
1689
1692
  setStencilTest(A) {
1690
1693
  A ? this.enable(this.gl_.STENCIL_TEST) : this.disable(this.gl_.STENCIL_TEST);
1691
1694
  }
1695
+ setStencilFunc(A, I, B) {
1696
+ (this.stencilFunc_ !== A || this.stencilRef_ !== I || this.stencilFuncMask_ !== B) && (this.gl_.stencilFunc(A, I, B), this.stencilFunc_ = A, this.stencilRef_ = I, this.stencilFuncMask_ = B);
1697
+ }
1692
1698
  }
1693
- const nQ = PB($(), [1, -1, 1]);
1694
- class GQ extends RC {
1699
+ const GQ = OB($(), [1, -1, 1]);
1700
+ class wQ extends NC {
1695
1701
  gl_;
1696
1702
  programs_;
1697
1703
  bindings_;
1698
1704
  textures_;
1699
1705
  state_;
1700
1706
  renderedObjectsPerFrame_ = 0;
1707
+ stencilRef_ = 0;
1701
1708
  currentViewportSize_ = [0, 0];
1702
1709
  constructor(A) {
1703
1710
  super(A);
@@ -1711,7 +1718,7 @@ class GQ extends RC {
1711
1718
  this.gl_ = I, k.info(
1712
1719
  "WebGLRenderer",
1713
1720
  `WebGL version ${I.getParameter(I.VERSION)}`
1714
- ), I.getExtension("EXT_color_buffer_float"), this.programs_ = new lC(I), this.bindings_ = new aQ(I), this.textures_ = new yQ(I), this.state_ = new eQ(I), this.initStencil(), this.resize(this.canvas.width, this.canvas.height);
1721
+ ), I.getExtension("EXT_color_buffer_float"), this.programs_ = new fC(I), this.bindings_ = new DQ(I), this.textures_ = new eQ(I), this.state_ = new nQ(I), this.initStencil(), this.resize(this.canvas.width, this.canvas.height);
1715
1722
  }
1716
1723
  get gpuTextureBytes() {
1717
1724
  return this.textures_.gpuTextureBytes;
@@ -1720,7 +1727,7 @@ class GQ extends RC {
1720
1727
  return this.textures_.textureCount;
1721
1728
  }
1722
1729
  render(A) {
1723
- this.renderedObjects_ = 0, this.renderedObjectsPerFrame_ = 0;
1730
+ this.renderedObjects_ = 0, this.renderedObjectsPerFrame_ = 0, this.stencilRef_ = 0;
1724
1731
  const I = [], B = [];
1725
1732
  for (const D of A.layers)
1726
1733
  (D.blendMode === "none" ? I : B).push(D);
@@ -1755,33 +1762,38 @@ class GQ extends RC {
1755
1762
  this.renderedObjects_ = this.renderedObjectsPerFrame_;
1756
1763
  }
1757
1764
  initStencil() {
1758
- this.gl_.clearStencil(0), this.gl_.stencilMask(255), this.gl_.stencilFunc(this.gl_.EQUAL, 0, 255), this.gl_.stencilOp(this.gl_.KEEP, this.gl_.KEEP, this.gl_.INCR);
1765
+ this.gl_.clearStencil(0), this.gl_.stencilMask(255), this.gl_.stencilOp(this.gl_.KEEP, this.gl_.KEEP, this.gl_.REPLACE);
1766
+ }
1767
+ setCoverageStencil(A) {
1768
+ this.state_.setStencilTest(A !== null), A !== null && (this.stencilRef_ += 1, this.stencilRef_ > 255 && k.warn(
1769
+ "WebGLRenderer",
1770
+ "Exceeded 255 stencil coverage groups in one frame; dedup may be incorrect"
1771
+ ), this.state_.setStencilFunc(this.gl_.NOTEQUAL, this.stencilRef_, 255));
1759
1772
  }
1760
1773
  renderLayer(A, I, B) {
1761
- if (A.objects.length === 0) return;
1762
1774
  this.state_.setBlendingMode(A.blendMode);
1763
- const C = A.hasMultipleLODs();
1764
- this.state_.setStencilTest(C), C && this.gl_.clear(this.gl_.STENCIL_BUFFER_BIT), A.objects.forEach((Q, E) => {
1765
- B.intersectsWithBox3(Q.boundingBox) && (this.renderObject(A, E, I), this.renderedObjectsPerFrame_ += 1);
1766
- });
1775
+ for (const [C, Q] of A.coverageGroups) {
1776
+ this.setCoverageStencil(C);
1777
+ for (const E of Q)
1778
+ B.intersectsWithBox3(E.boundingBox) && (this.renderObject(A, E, I), this.renderedObjectsPerFrame_ += 1);
1779
+ }
1767
1780
  }
1768
1781
  renderObject(A, I, B) {
1769
- const C = A.objects[I];
1770
- if (C.popStaleTextures().forEach((E) => {
1771
- this.textures_.dispose(E);
1772
- }), !C.programName) return;
1773
- this.state_.setCullFaceMode(C.cullFaceMode), this.state_.setDepthTesting(C.depthTest), this.state_.setDepthMask(C.depthTest), this.bindings_.bindGeometry(C.geometry), C.textures.forEach((E, i) => {
1774
- this.textures_.bindTexture(E, i);
1782
+ if (I.popStaleTextures().forEach((Q) => {
1783
+ this.textures_.dispose(Q);
1784
+ }), !I.programName) return;
1785
+ this.state_.setCullFaceMode(I.cullFaceMode), this.state_.setDepthTesting(I.depthTest), this.bindings_.bindGeometry(I.geometry), I.textures.forEach((Q, E) => {
1786
+ this.textures_.bindTexture(Q, E);
1775
1787
  });
1776
- const Q = this.programs_.use(C.programName);
1777
- if (this.drawGeometry(C.geometry, C, A, Q, B), C.wireframeEnabled) {
1778
- this.bindings_.bindGeometry(C.wireframeGeometry);
1779
- const E = this.programs_.use("wireframe");
1780
- E.setUniform("u_color", C.wireframeColor.rgb), this.drawGeometry(
1781
- C.wireframeGeometry,
1782
- C,
1788
+ const C = this.programs_.use(I.programName);
1789
+ if (this.drawGeometry(I.geometry, I, A, C, B), I.wireframeEnabled) {
1790
+ this.bindings_.bindGeometry(I.wireframeGeometry);
1791
+ const Q = this.programs_.use("wireframe");
1792
+ Q.setUniform("u_color", I.wireframeColor.rgb), this.drawGeometry(
1793
+ I.wireframeGeometry,
1794
+ I,
1783
1795
  A,
1784
- E,
1796
+ Q,
1785
1797
  B
1786
1798
  );
1787
1799
  }
@@ -1793,7 +1805,7 @@ class GQ extends RC {
1793
1805
  I.transform.matrix
1794
1806
  ), i = vI(
1795
1807
  $(),
1796
- nQ,
1808
+ GQ,
1797
1809
  Q.projectionMatrix
1798
1810
  ), o = this.currentViewportSize_, a = I.getUniforms(), s = {
1799
1811
  ...B.getUniforms(),
@@ -1869,14 +1881,16 @@ class GQ extends RC {
1869
1881
  this.state_.setViewport(B);
1870
1882
  }
1871
1883
  clear() {
1872
- this.gl_.clearColor(0, 0, 0, 0), this.gl_.clear(this.gl_.COLOR_BUFFER_BIT | this.gl_.DEPTH_BUFFER_BIT), this.state_.setDepthTesting(!0), this.gl_.depthFunc(this.gl_.LEQUAL);
1884
+ this.gl_.clearColor(0, 0, 0, 0), this.gl_.clear(
1885
+ this.gl_.COLOR_BUFFER_BIT | this.gl_.DEPTH_BUFFER_BIT | this.gl_.STENCIL_BUFFER_BIT
1886
+ ), this.state_.setDepthTesting(!0), this.gl_.depthFunc(this.gl_.LEQUAL);
1873
1887
  }
1874
1888
  }
1875
1889
  function ZA(g, A) {
1876
1890
  const I = g.priority ?? Number.MAX_SAFE_INTEGER, B = A.priority ?? Number.MAX_SAFE_INTEGER;
1877
1891
  return I === B ? (g.orderKey ?? Number.MAX_SAFE_INTEGER) - (A.orderKey ?? Number.MAX_SAFE_INTEGER) : I - B;
1878
1892
  }
1879
- class wQ {
1893
+ class FQ {
1880
1894
  maxConcurrent_;
1881
1895
  pending_ = [];
1882
1896
  running_ = /* @__PURE__ */ new Map();
@@ -1926,16 +1940,16 @@ class wQ {
1926
1940
  }
1927
1941
  }
1928
1942
  let hI = 0, tI = 0;
1929
- function FQ(g, A) {
1943
+ function rQ(g, A) {
1930
1944
  g.data && (hI -= g.data.byteLength, tI -= 1), g.data = A, hI += A.byteLength, tI += 1;
1931
1945
  }
1932
- function Xg(g) {
1946
+ function jg(g) {
1933
1947
  g.data && (hI -= g.data.byteLength, tI -= 1), g.data = void 0, g.texture?.releaseCpuData();
1934
1948
  }
1935
- function rQ() {
1949
+ function SQ() {
1936
1950
  return { cpuChunkBytes: hI, cpuChunkCount: tI };
1937
1951
  }
1938
- function jg(g, A, I = 1e-6) {
1952
+ function zg(g, A, I = 1e-6) {
1939
1953
  return Math.abs(g - A) <= I;
1940
1954
  }
1941
1955
  const W = {
@@ -1956,7 +1970,7 @@ function MA(g) {
1956
1970
  function dA(g) {
1957
1971
  const A = d(), I = d();
1958
1972
  A[W[g.u]] = 1, I[W[g.v]] = 1;
1959
- const B = EI(d(), A, I), C = uC(
1973
+ const B = EI(d(), A, I), C = TC(
1960
1974
  A[0],
1961
1975
  A[1],
1962
1976
  A[2],
@@ -1969,7 +1983,7 @@ function dA(g) {
1969
1983
  ), Q = Gg(sI(), C);
1970
1984
  return JI(Q, Q);
1971
1985
  }
1972
- const zg = [
1986
+ const _g = [
1973
1987
  Int8Array,
1974
1988
  Int16Array,
1975
1989
  Int32Array,
@@ -1978,32 +1992,32 @@ const zg = [
1978
1992
  Uint32Array,
1979
1993
  Float32Array
1980
1994
  ];
1981
- function SQ(g) {
1982
- if (zg.some((I) => g instanceof I))
1995
+ function RQ(g) {
1996
+ if (_g.some((I) => g instanceof I))
1983
1997
  return !0;
1984
- const A = zg.map((I) => I.name);
1998
+ const A = _g.map((I) => I.name);
1985
1999
  return k.debug(
1986
2000
  "Chunk",
1987
2001
  `Unsupported chunk data type: ${g}. Supported data types: ${A}`
1988
2002
  ), !1;
1989
2003
  }
1990
- function RQ(g, A) {
2004
+ function NQ(g, A) {
1991
2005
  return Math.round((A - g.translation) / g.scale);
1992
2006
  }
1993
- function XB(g, A) {
2007
+ function jB(g, A) {
1994
2008
  const I = d(), B = d();
1995
2009
  for (const Q of ["x", "y", "z"]) {
1996
2010
  const E = Q === A.w ? 0.5 * g.scale[Q] : 0, i = W[Q];
1997
2011
  I[i] = 1 / (g.scale[Q] * g.shape[Q]), B[i] = E - g.offset[Q];
1998
2012
  }
1999
- const C = PB($(), I);
2000
- return TC(C, C, B);
2013
+ const C = OB($(), I);
2014
+ return xC(C, C, B);
2001
2015
  }
2002
2016
  function hA(g, A, I) {
2003
2017
  return Math.max(A, Math.min(I, g));
2004
2018
  }
2005
2019
  const YI = Symbol("INTERNAL_POLICY_KEY");
2006
- class NQ {
2020
+ class cQ {
2007
2021
  store_;
2008
2022
  policy_;
2009
2023
  policyChanged_ = !1;
@@ -2030,7 +2044,7 @@ class NQ {
2030
2044
  `Source is missing dimensions for slice plane axes "${this.axes_.u}" and "${this.axes_.v}"`
2031
2045
  );
2032
2046
  const i = Q.lods[0], o = E.lods[0];
2033
- this.scale0_ = i.scale, this.sourceMaxSquareDistance2D_ = EQ(
2047
+ this.scale0_ = i.scale, this.sourceMaxSquareDistance2D_ = iQ(
2034
2048
  V(i.size * i.scale, o.size * o.scale)
2035
2049
  );
2036
2050
  }
@@ -2073,8 +2087,8 @@ class NQ {
2073
2087
  ), this.chunkViewStates_.forEach(bA);
2074
2088
  return;
2075
2089
  }
2076
- const s = vB();
2077
- iQ(s, B.min, B.max, 0.5);
2090
+ const s = XB();
2091
+ oQ(s, B.min, B.max, 0.5);
2078
2092
  const h = this.makeViewBounds3D(B, o);
2079
2093
  this.chunkViewStates_.forEach(bA);
2080
2094
  const t = this.channelsOfInterest(A), y = this.fallbackLOD(), n = this.getPaddedBounds(h), F = this.currentLOD_ === y ? [this.currentLOD_] : [this.currentLOD_, y];
@@ -2284,7 +2298,7 @@ class NQ {
2284
2298
  }
2285
2299
  timeIndex(A) {
2286
2300
  const I = this.store_.dimensions.t;
2287
- return A.t === void 0 || I === void 0 ? 0 : RQ(I.lods[0], A.t);
2301
+ return A.t === void 0 || I === void 0 ? 0 : NQ(I.lods[0], A.t);
2288
2302
  }
2289
2303
  getSliceAxisBounds(A) {
2290
2304
  const I = this.store_.dimensions[this.axes_.w];
@@ -2312,7 +2326,7 @@ class NQ {
2312
2326
  return this.lastViewBounds2D_ === null || !mI(this.lastViewBounds2D_.min, A.min) || !mI(this.lastViewBounds2D_.max, A.max);
2313
2327
  }
2314
2328
  hasViewProjectionChanged(A) {
2315
- return this.lastViewProjection_ === null || !VC(this.lastViewProjection_, A);
2329
+ return this.lastViewProjection_ === null || !vC(this.lastViewProjection_, A);
2316
2330
  }
2317
2331
  sliceBoundsChanged(A) {
2318
2332
  return !this.lastSliceBounds_ || !mI(this.lastSliceBounds_, A);
@@ -2338,7 +2352,7 @@ class NQ {
2338
2352
  function bA(g) {
2339
2353
  g.visible = !1, g.prefetch = !1, g.priority = null, g.orderKey = null;
2340
2354
  }
2341
- class cQ {
2355
+ class UQ {
2342
2356
  // Chunks indexed as chunks_[lod][t][c][z][y][x].
2343
2357
  chunks_;
2344
2358
  lowestResLOD_;
@@ -2418,7 +2432,7 @@ class cQ {
2418
2432
  return this.lowestResLOD_;
2419
2433
  }
2420
2434
  addView(A, I) {
2421
- const B = new NQ(this, A, I);
2435
+ const B = new cQ(this, A, I);
2422
2436
  return this.views_.push(B), this.hasHadViews_ = !0, B;
2423
2437
  }
2424
2438
  get views() {
@@ -2456,7 +2470,7 @@ class cQ {
2456
2470
  const A = this.dimensions_.x, I = this.dimensions_.y;
2457
2471
  for (let B = 1; B < this.dimensions_.numLods; B++) {
2458
2472
  const C = A.lods[B].scale / A.lods[B - 1].scale, Q = I.lods[B].scale / I.lods[B - 1].scale;
2459
- if (!jg(C, 2, 0.02) || !jg(Q, 2, 0.02))
2473
+ if (!zg(C, 2, 0.02) || !zg(Q, 2, 0.02))
2460
2474
  throw new Error(
2461
2475
  `Invalid downsampling factor between levels ${B - 1} → ${B}: expected (2× in X and Y), but got (${C.toFixed(2)}×, ${Q.toFixed(2)}×) from scale [${A.lods[B - 1].scale}, ${I.lods[B - 1].scale}] → [${A.lods[B].scale}, ${I.lods[B].scale}]`
2462
2476
  );
@@ -2532,8 +2546,8 @@ class rg extends Fg {
2532
2546
  return B.unpackAlignment = A.rowAlignmentBytes, B;
2533
2547
  }
2534
2548
  }
2535
- const UQ = 8, kQ = 4;
2536
- class LQ {
2549
+ const kQ = 8, LQ = 4;
2550
+ class JQ {
2537
2551
  stores_ = [];
2538
2552
  queue_;
2539
2553
  uploadTexture_;
@@ -2542,8 +2556,8 @@ class LQ {
2542
2556
  memoryLimitBytes_;
2543
2557
  maxGpuUploadsPerUpdate_;
2544
2558
  resident_ = /* @__PURE__ */ new Set();
2545
- constructor(A, I, B = () => 0, C = 1 / 0, Q = UQ, E = kQ) {
2546
- this.uploadTexture_ = A, this.disposeTexture_ = I, this.getGpuResidentBytes_ = B, this.memoryLimitBytes_ = C, this.maxGpuUploadsPerUpdate_ = Math.max(1, E), this.queue_ = new wQ(Q);
2559
+ constructor(A, I, B = () => 0, C = 1 / 0, Q = kQ, E = LQ) {
2560
+ this.uploadTexture_ = A, this.disposeTexture_ = I, this.getGpuResidentBytes_ = B, this.memoryLimitBytes_ = C, this.maxGpuUploadsPerUpdate_ = Math.max(1, E), this.queue_ = new FQ(Q);
2547
2561
  }
2548
2562
  get memoryLimitBytes() {
2549
2563
  return this.memoryLimitBytes_;
@@ -2558,11 +2572,11 @@ class LQ {
2558
2572
  };
2559
2573
  }
2560
2574
  get memoryStats() {
2561
- return rQ();
2575
+ return SQ();
2562
2576
  }
2563
2577
  addView(A, I, B) {
2564
2578
  let C = this.stores_.find((Q) => Q.source === A)?.store;
2565
- return C || (C = new cQ(A.loader.getSourceDimensionMap()), this.stores_.push({ source: A, store: C })), C.addView(I, B);
2579
+ return C || (C = new UQ(A.loader.getSourceDimensionMap()), this.stores_.push({ source: A, store: C })), C.addView(I, B);
2566
2580
  }
2567
2581
  update() {
2568
2582
  const A = [];
@@ -2581,7 +2595,7 @@ class LQ {
2581
2595
  A.releasedAt ??= performance.now();
2582
2596
  return;
2583
2597
  }
2584
- Xg(A), A.state === "loaded" && (A.state = "unloaded");
2598
+ jg(A), A.state === "loaded" && (A.state = "unloaded");
2585
2599
  }
2586
2600
  enqueueWithinBudget(A) {
2587
2601
  if (A.length === 0) return;
@@ -2630,7 +2644,7 @@ class LQ {
2630
2644
  const B = Math.min(I.length, this.maxGpuUploadsPerUpdate_);
2631
2645
  for (let C = 0; C < B; C++) {
2632
2646
  const Q = I[C], E = rg.createWithChunk(Q);
2633
- this.uploadTexture_(E), Q.texture = E, this.resident_.add(Q), Xg(Q);
2647
+ this.uploadTexture_(E), Q.texture = E, this.resident_.add(Q), jg(Q);
2634
2648
  }
2635
2649
  }
2636
2650
  disposeChunkTexture(A) {
@@ -2689,7 +2703,7 @@ VA.Panel = function(g, A, I, B) {
2689
2703
  }
2690
2704
  };
2691
2705
  };
2692
- function JQ({ scale: g } = { scale: 1.5 }) {
2706
+ function YQ({ scale: g } = { scale: 1.5 }) {
2693
2707
  const A = new VA(g);
2694
2708
  return A.showPanel(
2695
2709
  0
@@ -2703,10 +2717,10 @@ const $I = [
2703
2717
  "pointercancel",
2704
2718
  "wheel"
2705
2719
  ];
2706
- function YQ(g) {
2720
+ function MQ(g) {
2707
2721
  return $I.includes(g);
2708
2722
  }
2709
- class MQ {
2723
+ class dQ {
2710
2724
  propagationStopped_ = !1;
2711
2725
  type;
2712
2726
  event;
@@ -2723,7 +2737,7 @@ class MQ {
2723
2737
  this.propagationStopped_ = !0;
2724
2738
  }
2725
2739
  }
2726
- class dQ {
2740
+ class KQ {
2727
2741
  listeners_ = [];
2728
2742
  element_;
2729
2743
  isConnected_ = !1;
@@ -2768,31 +2782,31 @@ class dQ {
2768
2782
  });
2769
2783
  }
2770
2784
  handleEvent = (A) => {
2771
- if (!YQ(A.type)) {
2785
+ if (!MQ(A.type)) {
2772
2786
  k.error("EventDispatcher", `Unsupported event type ${A.type}`);
2773
2787
  return;
2774
2788
  }
2775
- const I = new MQ(A.type, A);
2789
+ const I = new dQ(A.type, A);
2776
2790
  for (const B of this.listeners_)
2777
2791
  if (B(I), I.propagationStopped) break;
2778
2792
  };
2779
2793
  }
2780
- const KQ = 1e-12;
2781
- class HQ {
2794
+ const HQ = 1e-12;
2795
+ class qQ {
2782
2796
  origin;
2783
2797
  direction;
2784
2798
  constructor(A, I) {
2785
- this.origin = DA(A), this.direction = OB(d(), I);
2799
+ this.origin = DA(A), this.direction = VB(d(), I);
2786
2800
  }
2787
2801
  intersectWithPlane(A) {
2788
2802
  const I = aI(this.direction, A.normal);
2789
- if (Math.abs(I) < KQ)
2803
+ if (Math.abs(I) < HQ)
2790
2804
  return null;
2791
2805
  const B = -A.signedDistanceToPoint(this.origin) / I;
2792
2806
  return jI(d(), this.origin, this.direction, B);
2793
2807
  }
2794
2808
  }
2795
- class qQ {
2809
+ class lQ {
2796
2810
  id;
2797
2811
  element;
2798
2812
  camera;
@@ -2804,12 +2818,12 @@ class qQ {
2804
2818
  context_;
2805
2819
  layers_ = [];
2806
2820
  constructor(A) {
2807
- 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 dQ(this.element), this.events.addEventListener((I) => {
2821
+ 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 KQ(this.element), this.events.addEventListener((I) => {
2808
2822
  if (I.event instanceof PointerEvent || I.event instanceof WheelEvent) {
2809
2823
  const { clientX: B, clientY: C } = I.event, Q = V(B, C);
2810
2824
  I.clipPos = this.clientToClip(Q, 0), I.worldPos = this.camera.clipToWorld(I.clipPos);
2811
2825
  const E = this.camera.clipToWorld(this.clientToClip(Q, -1)), i = this.camera.clipToWorld(this.clientToClip(Q, 1));
2812
- I.worldRay = new HQ(E, yg(d(), i, E));
2826
+ I.worldRay = new qQ(E, yg(d(), i, E));
2813
2827
  }
2814
2828
  for (const B of this.layers_)
2815
2829
  if (B.onEvent(I), I.propagationStopped) return;
@@ -2880,7 +2894,7 @@ class qQ {
2880
2894
  this.camera.setAspectRatio(B);
2881
2895
  }
2882
2896
  }
2883
- function jB(g, A) {
2897
+ function zB(g, A) {
2884
2898
  for (const I of A) {
2885
2899
  if (I.id === g.id)
2886
2900
  throw new Error(
@@ -2894,23 +2908,23 @@ function jB(g, A) {
2894
2908
  }
2895
2909
  }
2896
2910
  }
2897
- function lQ(g) {
2911
+ function fQ(g) {
2898
2912
  for (let A = 0; A < g.length; A++)
2899
- jB(g[A], g.slice(0, A));
2913
+ zB(g[A], g.slice(0, A));
2900
2914
  }
2901
- function _g(g, A, I) {
2915
+ function $g(g, A, I) {
2902
2916
  const B = g.map((C) => {
2903
2917
  const Q = C.element ?? A;
2904
2918
  return {
2905
2919
  ...C,
2906
2920
  element: Q,
2907
- id: C.id ?? Q.id ?? bB("viewport"),
2921
+ id: C.id ?? Q.id ?? ZB("viewport"),
2908
2922
  context: I
2909
2923
  };
2910
2924
  });
2911
- return lQ(B), B.map((C) => new qQ(C));
2925
+ return fQ(B), B.map((C) => new lQ(C));
2912
2926
  }
2913
- class fQ {
2927
+ class pQ {
2914
2928
  elements_;
2915
2929
  resizeObserver_;
2916
2930
  mediaQuery_;
@@ -2969,8 +2983,8 @@ class fQ {
2969
2983
  this.elements_.splice(I, 1), this.resizeObserver_ && this.resizeObserver_.unobserve(A);
2970
2984
  }
2971
2985
  }
2972
- const pQ = 2048;
2973
- class ho {
2986
+ const mQ = 2048;
2987
+ class to {
2974
2988
  chunkManager_;
2975
2989
  context_;
2976
2990
  renderer_;
@@ -2997,7 +3011,7 @@ class ho {
2997
3011
  *
2998
3012
  * @example
2999
3013
  * // Single viewport (element defaults to canvas)
3000
- * const camera = new OrthographicCamera(0, 1024, 0, 1024);
3014
+ * const camera = new OrthographicCamera({ left: 0, right: 1024, top: 0, bottom: 1024 });
3001
3015
  * const idetik = new Idetik({
3002
3016
  * canvas: document.querySelector('canvas')!,
3003
3017
  * viewports: [{
@@ -3029,30 +3043,30 @@ class ho {
3029
3043
  *
3030
3044
  * @throws {Error} If viewports have duplicate IDs or shared elements
3031
3045
  */
3032
- constructor(A, I) {
3033
- this.canvas = A.canvas, this.renderer_ = I ?? new GQ(this.canvas);
3034
- const C = (A.memoryLimitMB ?? pQ) * 1024 * 1024;
3035
- this.chunkManager_ = new LQ(
3036
- (E) => this.renderer_.uploadTexture(E),
3037
- (E) => this.renderer_.disposeTexture(E),
3046
+ constructor(A) {
3047
+ this.canvas = A.canvas, this.renderer_ = new wQ(this.canvas);
3048
+ const B = (A.memoryLimitMB ?? mQ) * 1024 * 1024;
3049
+ this.chunkManager_ = new JQ(
3050
+ (Q) => this.renderer_.uploadTexture(Q),
3051
+ (Q) => this.renderer_.disposeTexture(Q),
3038
3052
  () => this.renderer_.gpuTextureBytes,
3039
- C,
3053
+ B,
3040
3054
  A.maxConcurrentRequests,
3041
3055
  A.maxGpuUploadsPerUpdate
3042
3056
  ), this.context_ = {
3043
3057
  chunkManager: this.chunkManager_
3044
- }, this.viewports_ = _g(
3058
+ }, this.viewports_ = $g(
3045
3059
  A.viewports ?? [],
3046
3060
  this.canvas,
3047
3061
  this.context_
3048
- ), this.overlays = [...A.overlays ?? []], A.showStats && (this.stats_ = JQ());
3049
- const Q = [this.canvas];
3050
- for (const E of this.viewports_)
3051
- E.element !== this.canvas && Q.push(E.element);
3052
- this.sizeObserver_ = new fQ(Q, () => {
3062
+ ), this.overlays = [...A.overlays ?? []], A.showStats && (this.stats_ = YQ());
3063
+ const C = [this.canvas];
3064
+ for (const Q of this.viewports_)
3065
+ Q.element !== this.canvas && C.push(Q.element);
3066
+ this.sizeObserver_ = new pQ(C, () => {
3053
3067
  this.renderer_.updateSize(), this.renderer_.beginFrame();
3054
- for (const E of this.viewports_)
3055
- E.updateSize(), this.renderer_.render(E);
3068
+ for (const Q of this.viewports_)
3069
+ Q.updateSize(), this.renderer_.render(Q);
3056
3070
  });
3057
3071
  }
3058
3072
  get chunkQueueStats() {
@@ -3087,8 +3101,8 @@ class ho {
3087
3101
  return this.viewports_.find((I) => I.id === A);
3088
3102
  }
3089
3103
  addViewport(A) {
3090
- const [I] = _g([A], this.canvas, this.context_);
3091
- return jB(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;
3104
+ const [I] = $g([A], this.canvas, this.context_);
3105
+ return zB(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;
3092
3106
  }
3093
3107
  removeViewport(A) {
3094
3108
  const I = this.viewports_.indexOf(A);
@@ -3143,7 +3157,7 @@ class ho {
3143
3157
  }
3144
3158
  }
3145
3159
  }
3146
- function mQ(g, A) {
3160
+ function uQ(g, A) {
3147
3161
  return {
3148
3162
  ...g,
3149
3163
  ...A,
@@ -3153,13 +3167,13 @@ function mQ(g, A) {
3153
3167
  }
3154
3168
  };
3155
3169
  }
3156
- function $g(g, A) {
3170
+ function AB(g, A) {
3157
3171
  const I = typeof g == "string" ? new URL(g) : g;
3158
3172
  I.pathname.endsWith("/") || (I.pathname += "/");
3159
3173
  const B = new URL(A.slice(1), I);
3160
3174
  return B.search = I.search, B;
3161
3175
  }
3162
- async function AB(g) {
3176
+ async function IB(g) {
3163
3177
  if (g.status !== 404) {
3164
3178
  if (g.status === 200 || g.status === 206)
3165
3179
  return new Uint8Array(await g.arrayBuffer());
@@ -3175,14 +3189,14 @@ class $A {
3175
3189
  this.url = A, this.#A = I.fetch ?? ((B) => fetch(B)), this.#I = I.overrides ?? {}, this.#g = I.useSuffixRequest ?? !1;
3176
3190
  }
3177
3191
  #B(A, I) {
3178
- return new Request(A, mQ(this.#I, I));
3192
+ return new Request(A, uQ(this.#I, I));
3179
3193
  }
3180
3194
  async get(A, I = {}) {
3181
- let B = $g(this.url, A).href, C = this.#B(B, I), Q = await this.#A(C);
3182
- return AB(Q);
3195
+ let B = AB(this.url, A).href, C = this.#B(B, I), Q = await this.#A(C);
3196
+ return IB(Q);
3183
3197
  }
3184
3198
  async getRange(A, I, B = {}) {
3185
- let C = $g(this.url, A), Q;
3199
+ let C = AB(this.url, A), Q;
3186
3200
  if ("suffixLength" in I)
3187
3201
  Q = await this.#C(C, I.suffixLength, B);
3188
3202
  else {
@@ -3195,7 +3209,7 @@ class $A {
3195
3209
  }, i = this.#B(C, E);
3196
3210
  Q = await this.#A(i);
3197
3211
  }
3198
- return AB(Q);
3212
+ return IB(Q);
3199
3213
  }
3200
3214
  async #C(A, I, B) {
3201
3215
  if (this.#g) {
@@ -3240,7 +3254,7 @@ class v extends AI {
3240
3254
  super(A, { cause: I.cause }), this.path = I.path;
3241
3255
  }
3242
3256
  }
3243
- class uQ extends AI {
3257
+ class TQ extends AI {
3244
3258
  _tag = "UnknownCodecError";
3245
3259
  name = "UnknownCodecError";
3246
3260
  codec;
@@ -3248,7 +3262,7 @@ class uQ extends AI {
3248
3262
  super(`Unknown codec: ${A}`), this.codec = A;
3249
3263
  }
3250
3264
  }
3251
- class TQ extends AI {
3265
+ class xQ extends AI {
3252
3266
  _tag = "CodecPipelineError";
3253
3267
  name = "CodecPipelineError";
3254
3268
  direction;
@@ -3298,7 +3312,7 @@ class yI {
3298
3312
  function Rg(g) {
3299
3313
  return g instanceof ArrayBuffer || g instanceof SharedArrayBuffer;
3300
3314
  }
3301
- class zB {
3315
+ class _B {
3302
3316
  #A;
3303
3317
  constructor(A, I, B) {
3304
3318
  typeof A == "number" ? this.#A = new Uint8Array(A) : Rg(A) ? this.#A = new Uint8Array(A, I, B) : this.#A = new Uint8Array(Array.from(A, (C) => C ? 1 : 0));
@@ -3437,11 +3451,11 @@ class II {
3437
3451
  yield this.get(A);
3438
3452
  }
3439
3453
  }
3440
- function xQ() {
3454
+ function WQ() {
3441
3455
  if (typeof SharedArrayBuffer > "u")
3442
3456
  throw new Error("SharedArrayBuffer is not available. In browsers, this requires Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers to be set.");
3443
3457
  }
3444
- function WQ(g, A) {
3458
+ function bQ(g, A) {
3445
3459
  return new SharedArrayBuffer(g);
3446
3460
  }
3447
3461
  function gI(g) {
@@ -3452,7 +3466,7 @@ function gI(g) {
3452
3466
  throw new v("Failed to decode JSON", { cause: I });
3453
3467
  }
3454
3468
  }
3455
- function IB(g, A) {
3469
+ function gB(g, A) {
3456
3470
  const I = A / 2, B = A - 1;
3457
3471
  let C = 0;
3458
3472
  for (let Q = 0; Q < g.length; Q += A)
@@ -3481,7 +3495,7 @@ function TA(g) {
3481
3495
  float16: globalThis.Float16Array,
3482
3496
  float32: Float32Array,
3483
3497
  float64: Float64Array,
3484
- bool: zB
3498
+ bool: _B
3485
3499
  }[g];
3486
3500
  if (!I)
3487
3501
  throw new v(`Unknown or unsupported dataType: ${g}`);
@@ -3495,7 +3509,7 @@ function RA(g, A) {
3495
3509
  C[A[Q]] = B, B *= g[A[Q]];
3496
3510
  return C;
3497
3511
  }
3498
- function bQ({ name: g, configuration: A }) {
3512
+ function ZQ({ name: g, configuration: A }) {
3499
3513
  if (g === "default") {
3500
3514
  const I = A?.separator ?? "/";
3501
3515
  return (B) => ["c", ...B].join(I);
@@ -3506,7 +3520,7 @@ function bQ({ name: g, configuration: A }) {
3506
3520
  }
3507
3521
  throw new v(`Unknown chunk key encoding: ${g}`);
3508
3522
  }
3509
- function gB(g) {
3523
+ function BB(g) {
3510
3524
  if (g === "|O")
3511
3525
  return { dataType: "v2:object" };
3512
3526
  let A = g.match(/^([<|>])(.*)$/);
@@ -3530,15 +3544,15 @@ function gB(g) {
3530
3544
  throw new v(`Unsupported or unknown dtype: ${g}`);
3531
3545
  return I === "|" ? { dataType: C } : { dataType: C, endian: I === "<" ? "little" : "big" };
3532
3546
  }
3533
- function ZQ(g) {
3547
+ function PQ(g) {
3534
3548
  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");
3535
3549
  }
3536
- function PQ(g, A = {}) {
3537
- let I = [], B = gB(g.dtype);
3550
+ function OQ(g, A = {}) {
3551
+ let I = [], B = BB(g.dtype);
3538
3552
  g.order === "F" && I.push({ name: "transpose", configuration: { order: "F" } });
3539
3553
  for (let Q of g.filters ?? []) {
3540
3554
  if (Q.id === "fixedscaleoffset" || Q.id === "numcodecs.fixedscaleoffset") {
3541
- if (!ZQ(Q))
3555
+ if (!PQ(Q))
3542
3556
  throw new v(`Invalid fixedscaleoffset filter: ${JSON.stringify(Q)}`);
3543
3557
  I.push({
3544
3558
  name: "scale_offset",
@@ -3549,7 +3563,7 @@ function PQ(g, A = {}) {
3549
3563
  });
3550
3564
  let o = Q.astype ?? Q.dtype;
3551
3565
  if (o !== void 0 && o !== g.dtype) {
3552
- let a = gB(o).dataType;
3566
+ let a = BB(o).dataType;
3553
3567
  if (!Ag(a, "number") && !Ag(a, "bigint"))
3554
3568
  throw new v(`fixedscaleoffset astype must be a numeric data type, got ${o}`);
3555
3569
  I.push({
@@ -3596,7 +3610,7 @@ function PQ(g, A = {}) {
3596
3610
  attributes: A
3597
3611
  };
3598
3612
  }
3599
- function OQ(g, A = {}) {
3613
+ function VQ(g, A = {}) {
3600
3614
  return {
3601
3615
  zarr_format: 3,
3602
3616
  node_type: "group",
@@ -3618,10 +3632,10 @@ function Ag(g, A) {
3618
3632
  let Q = g === "v2:object";
3619
3633
  return A === "object" ? Q : !B && !C && !I && !Q;
3620
3634
  }
3621
- function VQ(g) {
3635
+ function vQ(g) {
3622
3636
  return g?.name === "sharding_indexed";
3623
3637
  }
3624
- function _B(g) {
3638
+ function $B(g) {
3625
3639
  if ((g.data_type === "uint64" || g.data_type === "int64") && g.fill_value != null)
3626
3640
  return BigInt(g.fill_value);
3627
3641
  let A = g.data_type === "float16" || g.data_type === "float32" || g.data_type === "float64";
@@ -3636,7 +3650,7 @@ function _B(g) {
3636
3650
  }
3637
3651
  return g.fill_value;
3638
3652
  }
3639
- function $B(g, ...A) {
3653
+ function AC(g, ...A) {
3640
3654
  if (!A.some((I) => g instanceof I))
3641
3655
  throw g;
3642
3656
  }
@@ -3644,7 +3658,7 @@ function IA(g, A = "") {
3644
3658
  if (!g)
3645
3659
  throw new Error(A);
3646
3660
  }
3647
- async function AC(g, { format: A, signal: I }) {
3661
+ async function IC(g, { format: A, signal: I }) {
3648
3662
  let B;
3649
3663
  if (g instanceof ArrayBuffer)
3650
3664
  B = new Response(g);
@@ -3659,12 +3673,12 @@ async function AC(g, { format: A, signal: I }) {
3659
3673
  throw I?.throwIfAborted(), new Error(`Failed to decode ${A}`);
3660
3674
  }
3661
3675
  }
3662
- const BB = vQ();
3663
- function vQ() {
3676
+ const CB = XQ();
3677
+ function XQ() {
3664
3678
  const g = new Uint32Array([305419896]);
3665
3679
  return new Uint8Array(g.buffer, g.byteOffset, g.byteLength)[0] !== 18;
3666
3680
  }
3667
- function CB(g) {
3681
+ function QB(g) {
3668
3682
  return "BYTES_PER_ELEMENT" in g ? g.BYTES_PER_ELEMENT : 4;
3669
3683
  }
3670
3684
  class MI {
@@ -3684,35 +3698,35 @@ class MI {
3684
3698
  }
3685
3699
  encode(A) {
3686
3700
  let I = new Uint8Array(A.data.buffer);
3687
- return BB && this.#C === "big" && IB(I, CB(this.#I)), I;
3701
+ return CB && this.#C === "big" && gB(I, QB(this.#I)), I;
3688
3702
  }
3689
3703
  computeEncodedSize(A) {
3690
3704
  return A;
3691
3705
  }
3692
3706
  decode(A) {
3693
- return BB && this.#C === "big" && IB(A, CB(this.#I)), {
3707
+ return CB && this.#C === "big" && gB(A, QB(this.#I)), {
3694
3708
  data: new this.#I(A.buffer, A.byteOffset, A.byteLength / this.#g),
3695
3709
  shape: this.#B,
3696
3710
  stride: this.#A
3697
3711
  };
3698
3712
  }
3699
3713
  }
3700
- const QB = {
3714
+ const EB = {
3701
3715
  NaN: NaN,
3702
3716
  Infinity: 1 / 0,
3703
3717
  "-Infinity": -1 / 0
3704
- }, IC = {
3718
+ }, gC = {
3705
3719
  float16: 2,
3706
3720
  float32: 4,
3707
3721
  float64: 8
3708
3722
  };
3709
3723
  function eI(g) {
3710
- return g in IC;
3724
+ return g in gC;
3711
3725
  }
3712
3726
  function Ig(g) {
3713
3727
  return g === "int64" || g === "uint64";
3714
3728
  }
3715
- function XQ(g, A) {
3729
+ function jQ(g, A) {
3716
3730
  const I = BigInt(g), B = new ArrayBuffer(A), C = new DataView(B);
3717
3731
  if (A === 2) {
3718
3732
  if (typeof C.getFloat16 != "function")
@@ -3734,9 +3748,9 @@ function nI(g, A) {
3734
3748
  }
3735
3749
  if (!eI(g))
3736
3750
  throw new v(`String-encoded scalar "${A}" is not valid for non-float data type "${g}"`);
3737
- return A in QB ? QB[A] : XQ(A, IC[g]);
3751
+ return A in EB ? EB[A] : jQ(A, gC[g]);
3738
3752
  }
3739
- const EB = /* @__PURE__ */ new Set([
3753
+ const iB = /* @__PURE__ */ new Set([
3740
3754
  "int8",
3741
3755
  "uint8",
3742
3756
  "int16",
@@ -3759,13 +3773,13 @@ const EB = /* @__PURE__ */ new Set([
3759
3773
  int64: [-(2n ** 63n), 2n ** 63n - 1n],
3760
3774
  uint64: [0n, 2n ** 64n - 1n]
3761
3775
  };
3762
- function iB(g, A, I) {
3776
+ function oB(g, A, I) {
3763
3777
  return g.map(([B, C]) => ({
3764
3778
  src: nI(A, B),
3765
3779
  tgt: nI(I, C)
3766
3780
  }));
3767
3781
  }
3768
- function jQ(g, A) {
3782
+ function zQ(g, A) {
3769
3783
  for (const I of A)
3770
3784
  if (typeof I.src == "number" && Number.isNaN(I.src)) {
3771
3785
  if (typeof g == "number" && Number.isNaN(g))
@@ -3773,7 +3787,7 @@ function jQ(g, A) {
3773
3787
  } else if (g === I.src)
3774
3788
  return I.tgt;
3775
3789
  }
3776
- function zQ(g) {
3790
+ function _Q(g) {
3777
3791
  if (!Number.isFinite(g))
3778
3792
  return g;
3779
3793
  if (Math.abs(g - Math.trunc(g)) === 0.5) {
@@ -3782,13 +3796,13 @@ function zQ(g) {
3782
3796
  }
3783
3797
  return Math.round(g);
3784
3798
  }
3785
- function _Q(g) {
3799
+ function $Q(g) {
3786
3800
  return Math.sign(g) * Math.floor(Math.abs(g) + 0.5);
3787
3801
  }
3788
- function oB(g) {
3802
+ function aB(g) {
3789
3803
  switch (g) {
3790
3804
  case "nearest-even":
3791
- return zQ;
3805
+ return _Q;
3792
3806
  case "towards-zero":
3793
3807
  return Math.trunc;
3794
3808
  case "towards-positive":
@@ -3796,7 +3810,7 @@ function oB(g) {
3796
3810
  case "towards-negative":
3797
3811
  return Math.floor;
3798
3812
  case "nearest-away":
3799
- return _Q;
3813
+ return $Q;
3800
3814
  }
3801
3815
  }
3802
3816
  function xI(g, A, I) {
@@ -3836,7 +3850,7 @@ class cg {
3836
3850
  #g;
3837
3851
  #B;
3838
3852
  constructor(A, I, B, C, Q, E) {
3839
- this.#A = I, this.#I = TA(A), this.#g = aB(I, A, B, C, Q), this.#B = aB(A, I, B, C, E);
3853
+ this.#A = I, this.#I = TA(A), this.#g = DB(I, A, B, C, Q), this.#B = DB(A, I, B, C, E);
3840
3854
  }
3841
3855
  /** Return updated metadata reflecting the type and fill value after encoding. */
3842
3856
  getEncodedMeta(A) {
@@ -3845,11 +3859,11 @@ class cg {
3845
3859
  }
3846
3860
  static fromConfig(A, I) {
3847
3861
  const B = I.dataType, C = A.data_type;
3848
- if (!EB.has(B))
3862
+ if (!iB.has(B))
3849
3863
  throw new v(`cast_value codec does not support array data type: ${B}`);
3850
- if (!EB.has(C))
3864
+ if (!iB.has(C))
3851
3865
  throw new v(`cast_value codec does not support encoded data type: ${C}`);
3852
- const Q = A.rounding ?? "nearest-even", E = A.scalar_map?.decode ? iB(A.scalar_map.decode, C, B) : [], i = A.scalar_map?.encode ? iB(A.scalar_map.encode, B, C) : [];
3866
+ const Q = A.rounding ?? "nearest-even", E = A.scalar_map?.decode ? oB(A.scalar_map.decode, C, B) : [], i = A.scalar_map?.encode ? oB(A.scalar_map.encode, B, C) : [];
3853
3867
  return new cg(B, C, Q, A.out_of_range, E, i);
3854
3868
  }
3855
3869
  encode = UA("cast_value");
@@ -3860,7 +3874,7 @@ class cg {
3860
3874
  return { data: B, shape: A.shape, stride: A.stride };
3861
3875
  }
3862
3876
  }
3863
- function aB(g, A, I, B, C) {
3877
+ function DB(g, A, I, B, C) {
3864
3878
  const Q = eI(g), E = Ig(g), i = eI(A), o = Ig(A);
3865
3879
  let a;
3866
3880
  if (Q && i) {
@@ -3868,14 +3882,14 @@ function aB(g, A, I, B, C) {
3868
3882
  throw new v(`cast_value float -> float only supports "nearest-even" rounding, got "${I}"`);
3869
3883
  a = (s) => s;
3870
3884
  } else if (Q && !i && !o) {
3871
- const s = oB(I), h = xI(...uI[A], B);
3885
+ const s = aB(I), h = xI(...uI[A], B);
3872
3886
  a = (t) => {
3873
3887
  if (!Number.isFinite(t))
3874
3888
  throw new Error(`Cannot cast ${t} to integer type without scalar_map`);
3875
3889
  return h(s(t));
3876
3890
  };
3877
3891
  } else if (Q && o) {
3878
- const s = oB(I), h = WI(...TI[A], B);
3892
+ const s = aB(I), h = WI(...TI[A], B);
3879
3893
  a = (t) => {
3880
3894
  if (!Number.isFinite(t))
3881
3895
  throw new Error(`Cannot cast ${t} to integer type without scalar_map`);
@@ -3898,7 +3912,7 @@ function aB(g, A, I, B, C) {
3898
3912
  else
3899
3913
  throw new Error(`Unhandled type combination: ${g} -> ${A}`);
3900
3914
  return C.length === 0 ? a : (s) => {
3901
- const h = jQ(s, C);
3915
+ const h = zQ(s, C);
3902
3916
  return h !== void 0 ? h : a(s);
3903
3917
  };
3904
3918
  }
@@ -3915,7 +3929,7 @@ class Ug {
3915
3929
  return A + 4;
3916
3930
  }
3917
3931
  }
3918
- const $Q = /* @__PURE__ */ new Set([
3932
+ const AE = /* @__PURE__ */ new Set([
3919
3933
  "int8",
3920
3934
  "uint8",
3921
3935
  "int16",
@@ -3928,7 +3942,7 @@ const $Q = /* @__PURE__ */ new Set([
3928
3942
  "float32",
3929
3943
  "float64"
3930
3944
  ]);
3931
- function DB(g, A) {
3945
+ function sB(g, A) {
3932
3946
  const I = g.length;
3933
3947
  let B = I === 0 || A[I - 1] === 1;
3934
3948
  for (let Q = I - 2; Q >= 0 && B; Q--)
@@ -3948,12 +3962,12 @@ class kg {
3948
3962
  this.#A = A;
3949
3963
  }
3950
3964
  static fromConfig(A, I) {
3951
- if (!$Q.has(I.dataType))
3965
+ if (!AE.has(I.dataType))
3952
3966
  throw new v(`Delta codec does not support data type: ${I.dataType}`);
3953
3967
  return new kg(TA(I.dataType));
3954
3968
  }
3955
3969
  encode(A) {
3956
- DB(A.shape, A.stride);
3970
+ sB(A.shape, A.stride);
3957
3971
  const I = A.data, B = new this.#A(I.length);
3958
3972
  B[0] = I[0];
3959
3973
  for (let C = 1; C < I.length; C++)
@@ -3961,7 +3975,7 @@ class kg {
3961
3975
  return { data: B, shape: A.shape, stride: A.stride };
3962
3976
  }
3963
3977
  decode(A) {
3964
- DB(A.shape, A.stride);
3978
+ sB(A.shape, A.stride);
3965
3979
  const I = A.data, B = new this.#A(I.length);
3966
3980
  B[0] = I[0];
3967
3981
  for (let C = 1; C < I.length; C++)
@@ -3976,14 +3990,14 @@ class Lg {
3976
3990
  }
3977
3991
  encode = UA("gzip");
3978
3992
  async decode(A) {
3979
- const I = await AC(A, { format: "gzip" });
3993
+ const I = await IC(A, { format: "gzip" });
3980
3994
  return new Uint8Array(I);
3981
3995
  }
3982
3996
  }
3983
- function AE(g, A) {
3997
+ function IE(g, A) {
3984
3998
  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;
3985
3999
  }
3986
- function IE(g, A) {
4000
+ function gE(g, A) {
3987
4001
  return A instanceof Object && !Array.isArray(A) ? Object.keys(A).sort().reduce((I, B) => (I[B] = A[B], I), {}) : A;
3988
4002
  }
3989
4003
  class GI {
@@ -4013,7 +4027,7 @@ class GI {
4013
4027
  const { indent: I, encoding: B, ensure_ascii: C, check_circular: Q, allow_nan: E, sort_keys: i } = this.#A;
4014
4028
  IA(B === "utf-8", "JsonCodec does not yet support non-utf-8 encoding.");
4015
4029
  const o = [];
4016
- IA(Q, "JsonCodec does not yet support skipping the check for circular references during encoding."), E || o.push(AE), i && o.push(IE);
4030
+ IA(Q, "JsonCodec does not yet support skipping the check for circular references during encoding."), E || o.push(IE), i && o.push(gE);
4017
4031
  const a = Array.from(A.data);
4018
4032
  a.push("|O"), a.push(A.shape);
4019
4033
  let D;
@@ -4038,7 +4052,7 @@ class GI {
4038
4052
  return { data: B, shape: C, stride: Q };
4039
4053
  }
4040
4054
  }
4041
- const gE = /* @__PURE__ */ new Set([
4055
+ const BE = /* @__PURE__ */ new Set([
4042
4056
  "int8",
4043
4057
  "uint8",
4044
4058
  "int16",
@@ -4060,7 +4074,7 @@ class Jg {
4060
4074
  this.#I = A, this.#g = I, this.#A = B;
4061
4075
  }
4062
4076
  static fromConfig(A, I) {
4063
- if (!gE.has(I.dataType))
4077
+ if (!BE.has(I.dataType))
4064
4078
  throw new v(`scale_offset codec does not support data type: ${I.dataType}`);
4065
4079
  return new Jg(nI(I.dataType, A.scale ?? 1), nI(I.dataType, A.offset ?? 0), TA(I.dataType));
4066
4080
  }
@@ -4086,28 +4100,28 @@ class Yg {
4086
4100
  return new Yg(A, I);
4087
4101
  }
4088
4102
  encode(A) {
4089
- return BE(A, this.#A);
4103
+ return CE(A, this.#A);
4090
4104
  }
4091
4105
  decode(A) {
4092
- return CE(A, this.#A);
4106
+ return QE(A, this.#A);
4093
4107
  }
4094
4108
  }
4095
- function BE(g, A) {
4109
+ function CE(g, A) {
4096
4110
  let I = g.length, B = Math.floor(I / A), C = new Uint8Array(I);
4097
4111
  for (let Q = 0; Q < A; Q++)
4098
4112
  for (let E = 0; E < B; E++)
4099
4113
  C[Q * B + E] = g[E * A + Q];
4100
4114
  return C;
4101
4115
  }
4102
- function CE(g, A) {
4116
+ function QE(g, A) {
4103
4117
  let I = g.length, B = Math.floor(I / A), C = new Uint8Array(I);
4104
4118
  for (let Q = 0; Q < A; Q++)
4105
4119
  for (let E = 0; E < B; E++)
4106
4120
  C[E * A + Q] = g[Q * B + E];
4107
4121
  return C;
4108
4122
  }
4109
- function sB(g) {
4110
- return g instanceof zB || g instanceof Ng || g instanceof II ? new Proxy(g, {
4123
+ function hB(g) {
4124
+ return g instanceof _B || g instanceof Ng || g instanceof II ? new Proxy(g, {
4111
4125
  get(I, B) {
4112
4126
  return I.get(Number(B));
4113
4127
  },
@@ -4116,7 +4130,7 @@ function sB(g) {
4116
4130
  }
4117
4131
  }) : g;
4118
4132
  }
4119
- function QE(g, A) {
4133
+ function EE(g, A) {
4120
4134
  let I;
4121
4135
  return g.data instanceof Ng || g.data instanceof II ? I = new g.constructor(
4122
4136
  // @ts-expect-error
@@ -4128,8 +4142,8 @@ function QE(g, A) {
4128
4142
  stride: RA(g.shape, A)
4129
4143
  };
4130
4144
  }
4131
- function EE(g, A) {
4132
- let I = QE(g, A), B = g.shape.length, C = g.data.length, Q = Array(B).fill(0), E = sB(g.data), i = sB(I.data);
4145
+ function iE(g, A) {
4146
+ let I = EE(g, A), B = g.shape.length, C = g.data.length, Q = Array(B).fill(0), E = hB(g.data), i = hB(I.data);
4133
4147
  for (let o = 0; o < C; o++) {
4134
4148
  let a = 0;
4135
4149
  for (let D = 0; D < B; D++)
@@ -4144,12 +4158,12 @@ function EE(g, A) {
4144
4158
  }
4145
4159
  return I;
4146
4160
  }
4147
- function iE(g) {
4161
+ function oE(g) {
4148
4162
  let A = g.shape.length;
4149
4163
  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);
4150
4164
  }
4151
- function oE(g, A) {
4152
- let I = iE(g);
4165
+ function aE(g, A) {
4166
+ let I = oE(g);
4153
4167
  return IA(I.length === A.length, "Orders must match"), I.every((B, C) => B === A[C]);
4154
4168
  }
4155
4169
  class Mg {
@@ -4174,7 +4188,7 @@ class Mg {
4174
4188
  return new Mg(A, I);
4175
4189
  }
4176
4190
  encode(A) {
4177
- return oE(A, this.#I) ? A : EE(A, this.#I);
4191
+ return aE(A, this.#I) ? A : iE(A, this.#I);
4178
4192
  }
4179
4193
  decode(A) {
4180
4194
  return {
@@ -4211,25 +4225,25 @@ class dg {
4211
4225
  }
4212
4226
  encode = UA("zlib");
4213
4227
  async decode(A) {
4214
- const I = await AC(A, { format: "deflate" });
4228
+ const I = await IC(A, { format: "deflate" });
4215
4229
  return new Uint8Array(I);
4216
4230
  }
4217
4231
  }
4218
- function aE() {
4232
+ function DE() {
4219
4233
  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 = () => Lg, C = () => dg;
4220
4234
  return (/* @__PURE__ */ new Map()).set("blosc", g).set("lz4", A).set("zstd", I).set("gzip", B).set("zlib", C).set("transpose", () => Mg).set("bytes", () => MI).set("crc32c", () => Ug).set("vlen-utf8", () => wI).set("json2", () => GI).set("bitround", () => yI).set("cast_value", () => cg).set("scale_offset", () => Jg).set("numcodecs.blosc", g).set("numcodecs.lz4", A).set("numcodecs.zstd", I).set("numcodecs.gzip", B).set("numcodecs.zlib", C).set("numcodecs.vlen-utf8", () => wI).set("numcodecs.shuffle", () => Yg).set("numcodecs.delta", () => kg).set("numcodecs.bitround", () => yI).set("numcodecs.json2", () => GI);
4221
4235
  }
4222
- const DE = aE();
4236
+ const sE = DE();
4223
4237
  function gg(g) {
4224
4238
  let A;
4225
4239
  function I() {
4226
- return A || (A = sE(g)), A;
4240
+ return A || (A = hE(g)), A;
4227
4241
  }
4228
4242
  async function B(C, Q, E) {
4229
4243
  try {
4230
4244
  return await E();
4231
4245
  } catch (i) {
4232
- throw new TQ({ direction: C, codec: Q, cause: i });
4246
+ throw new xQ({ direction: C, codec: Q, cause: i });
4233
4247
  }
4234
4248
  }
4235
4249
  return {
@@ -4256,23 +4270,23 @@ function gg(g) {
4256
4270
  return E;
4257
4271
  },
4258
4272
  async computeEncodedSize(C) {
4259
- let Q = await I(), E = hB(Q.arrayToBytes.name, Q.arrayToBytes.codec, C);
4273
+ let Q = await I(), E = tB(Q.arrayToBytes.name, Q.arrayToBytes.codec, C);
4260
4274
  for (const { name: i, codec: o } of Q.bytesToBytes)
4261
- E = hB(i, o, E);
4275
+ E = tB(i, o, E);
4262
4276
  return E;
4263
4277
  }
4264
4278
  };
4265
4279
  }
4266
- function hB(g, A, I) {
4280
+ function tB(g, A, I) {
4267
4281
  if (!A.computeEncodedSize)
4268
4282
  throw new v(`Codec "${g}" cannot compute its encoded size; it is not a fixed-size codec and cannot be used in a sharding index pipeline`);
4269
4283
  return A.computeEncodedSize(I);
4270
4284
  }
4271
- async function sE(g) {
4285
+ async function hE(g) {
4272
4286
  let A = g.codecs.map(async (E) => {
4273
- let i = await DE.get(E.name)?.();
4287
+ let i = await sE.get(E.name)?.();
4274
4288
  if (!i)
4275
- throw new uQ(E.name);
4289
+ throw new TQ(E.name);
4276
4290
  return { Codec: i, meta: E };
4277
4291
  }), I = [], B, C = [], Q = { ...g };
4278
4292
  for await (let { Codec: E, meta: i } of A) {
@@ -4298,7 +4312,7 @@ async function sE(g) {
4298
4312
  }
4299
4313
  }
4300
4314
  if (!B) {
4301
- if (!hE(Q))
4315
+ if (!tE(Q))
4302
4316
  throw new v(`Cannot encode ${Q.dataType} to bytes without a codec`);
4303
4317
  B = {
4304
4318
  name: "bytes",
@@ -4311,11 +4325,11 @@ async function sE(g) {
4311
4325
  bytesToBytes: C
4312
4326
  };
4313
4327
  }
4314
- function hE(g) {
4328
+ function tE(g) {
4315
4329
  return g.dataType !== "v2:object" && g.dataType !== "string";
4316
4330
  }
4317
- const tB = 18446744073709551615n;
4318
- function tE(g, A, I, B) {
4331
+ const yB = 18446744073709551615n;
4332
+ function yE(g, A, I, B) {
4319
4333
  if (!g.store.getRange)
4320
4334
  throw new Sg("sharding requires a store with getRange");
4321
4335
  let C = g.store.getRange.bind(g.store), Q = A.map((a, D) => a / B.chunk_shape[D]), E = gg({
@@ -4336,7 +4350,7 @@ function tE(g, A, I, B) {
4336
4350
  if (t === null)
4337
4351
  return;
4338
4352
  let { data: y, shape: n, stride: F } = t, G = a.map((S, r) => S % n[r]).reduce((S, r, c) => S + r * F[c], 0), J = y[G], U = y[G + 1];
4339
- if (!(J === tB && U === tB))
4353
+ if (!(J === yB && U === yB))
4340
4354
  return C(h, {
4341
4355
  offset: Number(J),
4342
4356
  length: Number(U)
@@ -4364,18 +4378,18 @@ class Kg extends CA {
4364
4378
  return this.#A.attributes;
4365
4379
  }
4366
4380
  }
4367
- function yB(g) {
4381
+ function eB(g) {
4368
4382
  return g.find((I) => I.name === "transpose")?.configuration?.order ?? "C";
4369
4383
  }
4370
4384
  const QI = Symbol("zarrita.context");
4371
- function yE(g, A) {
4372
- let { configuration: I } = A.codecs.find(VQ) ?? {}, B = {
4373
- encodeChunkKey: bQ(A.chunk_key_encoding),
4385
+ function eE(g, A) {
4386
+ let { configuration: I } = A.codecs.find(vQ) ?? {}, B = {
4387
+ encodeChunkKey: ZQ(A.chunk_key_encoding),
4374
4388
  TypedArray: TA(A.data_type),
4375
4389
  fillValue: A.fill_value
4376
4390
  };
4377
4391
  if (I) {
4378
- let Q = yB(I.codecs);
4392
+ let Q = eB(I.codecs);
4379
4393
  return {
4380
4394
  ...B,
4381
4395
  kind: "sharded",
@@ -4389,10 +4403,10 @@ function yE(g, A) {
4389
4403
  getStrides(E) {
4390
4404
  return RA(E, Q);
4391
4405
  },
4392
- getChunkBytes: tE(g, A.chunk_grid.configuration.chunk_shape, B.encodeChunkKey, I)
4406
+ getChunkBytes: yE(g, A.chunk_grid.configuration.chunk_shape, B.encodeChunkKey, I)
4393
4407
  };
4394
4408
  }
4395
- let C = yB(A.codecs);
4409
+ let C = eB(A.codecs);
4396
4410
  return {
4397
4411
  ...B,
4398
4412
  kind: "regular",
@@ -4419,8 +4433,8 @@ let FI = class extends CA {
4419
4433
  constructor(A, I, B) {
4420
4434
  super(A, I), this.#A = {
4421
4435
  ...B,
4422
- fill_value: _B(B)
4423
- }, this[QI] = yE(this, this.#A);
4436
+ fill_value: $B(B)
4437
+ }, this[QI] = eE(this, this.#A);
4424
4438
  }
4425
4439
  get attrs() {
4426
4440
  return this.#A.attributes;
@@ -4441,7 +4455,7 @@ let FI = class extends CA {
4441
4455
  return this.#A.data_type;
4442
4456
  }
4443
4457
  async getChunk(A, I, B) {
4444
- B?.useSharedArrayBuffer && xQ();
4458
+ B?.useSharedArrayBuffer && WQ();
4445
4459
  let C = this[QI], Q = await C.getChunkBytes(A, I);
4446
4460
  if (!Q) {
4447
4461
  let E = C.chunkShape.reduce((o, a) => o * a, 1), i;
@@ -4450,7 +4464,7 @@ let FI = class extends CA {
4450
4464
  if (!("BYTES_PER_ELEMENT" in o))
4451
4465
  console.warn("zarrita: useSharedArrayBuffer is not supported for non-buffer-backed data types."), i = new C.TypedArray(E);
4452
4466
  else {
4453
- let a = WQ(E * o.BYTES_PER_ELEMENT);
4467
+ let a = bQ(E * o.BYTES_PER_ELEMENT);
4454
4468
  i = new C.TypedArray(a, 0, E);
4455
4469
  }
4456
4470
  } else
@@ -4484,21 +4498,21 @@ let FI = class extends CA {
4484
4498
  return Ag(this.dtype, A);
4485
4499
  }
4486
4500
  };
4487
- function eE(g, A) {
4501
+ function nE(g, A) {
4488
4502
  let I = g;
4489
4503
  for (let B of A)
4490
4504
  I instanceof Promise ? I = I.then((C) => B(C)) : I = B(I);
4491
4505
  return I;
4492
4506
  }
4493
- function nE(g, ...A) {
4494
- return eE(g, A);
4507
+ function GE(g, ...A) {
4508
+ return nE(g, A);
4495
4509
  }
4496
- async function gC(g) {
4510
+ async function BC(g) {
4497
4511
  let A = g.store.arrayExtensions;
4498
- return A?.length ? await nE(g, ...A) : g;
4512
+ return A?.length ? await GE(g, ...A) : g;
4499
4513
  }
4500
- let dI = GE();
4501
- function GE() {
4514
+ let dI = wE();
4515
+ function wE() {
4502
4516
  let g = /* @__PURE__ */ new WeakMap();
4503
4517
  function A(I) {
4504
4518
  let B = g.get(I) ?? { v2: 0, v3: 0 };
@@ -4514,37 +4528,37 @@ function GE() {
4514
4528
  }
4515
4529
  };
4516
4530
  }
4517
- async function wE(g, A) {
4531
+ async function FE(g, A) {
4518
4532
  let I = await g.store.get(g.resolve(".zattrs").path, {
4519
4533
  signal: A
4520
4534
  });
4521
4535
  return I ? gI(I) : {};
4522
4536
  }
4523
- async function FE(g, A = {}) {
4537
+ async function rE(g, A = {}) {
4524
4538
  let I = "store" in g ? g : new CA(g), { signal: B } = A, C = {};
4525
- return (A.attrs ?? !0) && (C = await wE(I, B)), B?.throwIfAborted(), A.kind === "array" ? eB(I, C, B) : A.kind === "group" ? nB(I, C, B) : eB(I, C, B).catch((Q) => ($B(Q, uA, v), nB(I, C, B)));
4539
+ return (A.attrs ?? !0) && (C = await FE(I, B)), B?.throwIfAborted(), A.kind === "array" ? nB(I, C, B) : A.kind === "group" ? GB(I, C, B) : nB(I, C, B).catch((Q) => (AC(Q, uA, v), GB(I, C, B)));
4526
4540
  }
4527
- async function eB(g, A, I) {
4541
+ async function nB(g, A, I) {
4528
4542
  let { path: B } = g.resolve(".zarray"), C = await g.store.get(B, { signal: I });
4529
4543
  if (!C)
4530
4544
  throw new uA("v2 array", { path: B });
4531
- return dI.increment(g.store, "v2"), gC(new FI(g.store, g.path, PQ(gI(C), A)));
4545
+ return dI.increment(g.store, "v2"), BC(new FI(g.store, g.path, OQ(gI(C), A)));
4532
4546
  }
4533
- async function nB(g, A, I) {
4547
+ async function GB(g, A, I) {
4534
4548
  let { path: B } = g.resolve(".zgroup"), C = await g.store.get(B, { signal: I });
4535
4549
  if (!C)
4536
4550
  throw new uA("v2 group", { path: B });
4537
- return dI.increment(g.store, "v2"), new Kg(g.store, g.path, OQ(gI(C), A));
4551
+ return dI.increment(g.store, "v2"), new Kg(g.store, g.path, VQ(gI(C), A));
4538
4552
  }
4539
- async function rE(g, A) {
4553
+ async function SE(g, A) {
4540
4554
  let { store: I, path: B } = g.resolve("zarr.json"), C = await g.store.get(B, { signal: A });
4541
4555
  if (!C)
4542
4556
  throw new uA("v3 array or group", { path: B });
4543
4557
  let Q = gI(C);
4544
- return Q.node_type === "array" && (Q.fill_value = _B(Q)), Q.node_type === "array" ? gC(new FI(I, g.path, Q)) : new Kg(I, g.path, Q);
4558
+ return Q.node_type === "array" && (Q.fill_value = $B(Q)), Q.node_type === "array" ? BC(new FI(I, g.path, Q)) : new Kg(I, g.path, Q);
4545
4559
  }
4546
- async function SE(g, A = {}) {
4547
- let I = "store" in g ? g : new CA(g), B = await rE(I, A.signal);
4560
+ async function RE(g, A = {}) {
4561
+ let I = "store" in g ? g : new CA(g), B = await SE(I, A.signal);
4548
4562
  if (dI.increment(I.store, "v3"), A.kind === void 0 || A.kind === "array" && B instanceof FI || A.kind === "group" && B instanceof Kg)
4549
4563
  return B;
4550
4564
  let C = B instanceof FI ? "array" : "group";
@@ -4555,11 +4569,11 @@ async function SE(g, A = {}) {
4555
4569
  }
4556
4570
  async function BA(g, A = {}) {
4557
4571
  let I = "store" in g ? g.store : g, B = dI.versionMax(I), C = B === "v2" ? BA.v2 : BA.v3, Q = B === "v2" ? BA.v3 : BA.v2;
4558
- return C(g, A).catch((E) => ($B(E, uA, v), Q(g, A)));
4572
+ return C(g, A).catch((E) => (AC(E, uA, v), Q(g, A)));
4559
4573
  }
4560
- BA.v2 = FE;
4561
- BA.v3 = SE;
4562
- async function RE(g, A) {
4574
+ BA.v2 = rE;
4575
+ BA.v3 = RE;
4576
+ async function NE(g, A) {
4563
4577
  const I = A.split("/"), B = I.pop();
4564
4578
  if (!B)
4565
4579
  throw new Error("Invalid path");
@@ -4576,7 +4590,7 @@ class Hg {
4576
4590
  return this.#A;
4577
4591
  }
4578
4592
  async get(A) {
4579
- const I = await RE(this.#A, A.slice(1)).catch(
4593
+ const I = await NE(this.#A, A.slice(1)).catch(
4580
4594
  () => {
4581
4595
  }
4582
4596
  );
@@ -4605,7 +4619,7 @@ async function BI(g, A) {
4605
4619
  throw new Error(`Failed to open Zarr group at ${g}`);
4606
4620
  }
4607
4621
  }
4608
- async function NE(g, A) {
4622
+ async function cE(g, A) {
4609
4623
  if (A === "v2")
4610
4624
  try {
4611
4625
  return BA.v2(g, { kind: "array", attrs: !1 });
@@ -4624,7 +4638,7 @@ async function NE(g, A) {
4624
4638
  throw new Error(`Failed to open Zarr array at ${g}`);
4625
4639
  }
4626
4640
  }
4627
- async function cE(g) {
4641
+ async function UE(g) {
4628
4642
  let A;
4629
4643
  switch (g.type) {
4630
4644
  case "fetch": {
@@ -4645,9 +4659,9 @@ async function cE(g) {
4645
4659
  }
4646
4660
  }
4647
4661
  const I = g.arrayPath ? A.resolve(g.arrayPath) : A;
4648
- return NE(I, g.zarrVersion);
4662
+ return cE(I, g.zarrVersion);
4649
4663
  }
4650
- function UE(g, A, I) {
4664
+ function kE(g, A, I) {
4651
4665
  if (g.store instanceof $A)
4652
4666
  return {
4653
4667
  type: "fetch",
@@ -4667,10 +4681,10 @@ function UE(g, A, I) {
4667
4681
  `Unsupported store type: ${g.store.constructor.name}`
4668
4682
  );
4669
4683
  }
4670
- function kE(g, A, I, B) {
4671
- return LE(g, A, I, B);
4672
- }
4673
4684
  function LE(g, A, I, B) {
4685
+ return JE(g, A, I, B);
4686
+ }
4687
+ function JE(g, A, I, B) {
4674
4688
  const { targetShape: C, chunkIndex: Q, dimIndices: E } = B;
4675
4689
  let i = 1;
4676
4690
  for (let r = A.length - 1; r >= 0; r--) {
@@ -4705,7 +4719,7 @@ function LE(g, A, I, B) {
4705
4719
  }
4706
4720
  return G;
4707
4721
  }
4708
- const BC = `function xg(B, A) {
4722
+ const CC = `function xg(B, A) {
4709
4723
  return {
4710
4724
  ...B,
4711
4725
  ...A,
@@ -8359,11 +8373,11 @@ return ret;
8359
8373
  default: IQ
8360
8374
  });
8361
8375
  //# sourceMappingURL=worker_kernel-CBlE4MBI.js.map
8362
- `, GB = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", BC], { type: "text/javascript;charset=utf-8" });
8363
- function JE(g) {
8376
+ `, wB = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", CC], { type: "text/javascript;charset=utf-8" });
8377
+ function YE(g) {
8364
8378
  let A;
8365
8379
  try {
8366
- if (A = GB && (self.URL || self.webkitURL).createObjectURL(GB), !A) throw "";
8380
+ if (A = wB && (self.URL || self.webkitURL).createObjectURL(wB), !A) throw "";
8367
8381
  const I = new Worker(A, {
8368
8382
  type: "module",
8369
8383
  name: g?.name
@@ -8373,7 +8387,7 @@ function JE(g) {
8373
8387
  }), I;
8374
8388
  } catch {
8375
8389
  return new Worker(
8376
- "data:text/javascript;charset=utf-8," + encodeURIComponent(BC),
8390
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(CC),
8377
8391
  {
8378
8392
  type: "module",
8379
8393
  name: g?.name
@@ -8381,17 +8395,17 @@ function JE(g) {
8381
8395
  );
8382
8396
  }
8383
8397
  }
8384
- const YE = Math.max(1, navigator.hardwareConcurrency - 2);
8385
- let EA = [], ME = 0, CC = 0;
8398
+ const ME = Math.max(1, navigator.hardwareConcurrency - 2);
8399
+ let EA = [], dE = 0, QC = 0;
8386
8400
  const NA = /* @__PURE__ */ new Map(), rI = /* @__PURE__ */ new Set();
8387
- function QC(g) {
8401
+ function EC(g) {
8388
8402
  const A = EA.find((I) => I.worker === g);
8389
8403
  return A || k.error(
8390
8404
  "ZarrWorker",
8391
8405
  "Worker not found in pool - this should not happen"
8392
8406
  ), A;
8393
8407
  }
8394
- function dE(g, A) {
8408
+ function KE(g, A) {
8395
8409
  const { id: I, success: B } = g.data, C = NA.get(I);
8396
8410
  if (!C) {
8397
8411
  rI.has(I) ? rI.delete(I) : k.warn(
@@ -8402,13 +8416,13 @@ function dE(g, A) {
8402
8416
  return;
8403
8417
  }
8404
8418
  NA.delete(I), C.abortListener && C.abortSignal && C.abortSignal.removeEventListener("abort", C.abortListener);
8405
- const Q = QC(A);
8419
+ const Q = EC(A);
8406
8420
  Q && Q.pendingCount > 0 ? Q.pendingCount-- : Q && k.error(
8407
8421
  "ZarrWorker",
8408
8422
  "Received message but no pending tasks - this should not happen"
8409
8423
  ), B && g.data.type === "getChunk" ? C.resolve(g.data.data) : B || C.reject(new Error(g.data.error || "Unknown worker error"));
8410
8424
  }
8411
- function wB(g, A) {
8425
+ function FB(g, A) {
8412
8426
  if (g instanceof MessageEvent) {
8413
8427
  k.error(
8414
8428
  "ZarrWorker",
@@ -8421,7 +8435,7 @@ function wB(g, A) {
8421
8435
  "Worker failed - replacing worker and canceling its in-flight messages",
8422
8436
  g.message
8423
8437
  );
8424
- const I = QC(A);
8438
+ const I = EC(A);
8425
8439
  if (I) {
8426
8440
  const C = EA.indexOf(I);
8427
8441
  EA.splice(C, 1);
@@ -8431,31 +8445,31 @@ function wB(g, A) {
8431
8445
  for (const [C, Q] of NA.entries())
8432
8446
  Q.workerId === B && (Q.reject(new Error(`Worker error: ${g.message}`)), NA.delete(C));
8433
8447
  try {
8434
- const C = EC();
8448
+ const C = iC();
8435
8449
  EA.push({
8436
8450
  worker: C,
8437
8451
  pendingCount: 0,
8438
- workerId: CC++
8452
+ workerId: QC++
8439
8453
  }), k.debug("ZarrWorker", "Replacement worker created successfully");
8440
8454
  } catch (C) {
8441
8455
  k.error("ZarrWorker", "Failed to create replacement worker", C);
8442
8456
  }
8443
8457
  }
8444
- function EC() {
8445
- const g = new JE();
8446
- return g.addEventListener("message", (A) => dE(A, g)), g.addEventListener("error", (A) => wB(A, g)), g.addEventListener(
8458
+ function iC() {
8459
+ const g = new YE();
8460
+ return g.addEventListener("message", (A) => KE(A, g)), g.addEventListener("error", (A) => FB(A, g)), g.addEventListener(
8447
8461
  "messageerror",
8448
- (A) => wB(A, g)
8462
+ (A) => FB(A, g)
8449
8463
  ), g;
8450
8464
  }
8451
- function KE() {
8465
+ function HE() {
8452
8466
  if (EA.length === 0)
8453
8467
  throw new Error("Worker pool is not initialized");
8454
8468
  return EA.sort((g, A) => g.pendingCount - A.pendingCount)[0];
8455
8469
  }
8456
- async function HE(g, A, I, B) {
8470
+ async function qE(g, A, I, B) {
8457
8471
  return new Promise((C, Q) => {
8458
- const E = KE(), i = ME++, o = {
8472
+ const E = HE(), i = dE++, o = {
8459
8473
  resolve: C,
8460
8474
  reject: Q,
8461
8475
  workerId: E.workerId
@@ -8482,15 +8496,15 @@ async function HE(g, A, I, B) {
8482
8496
  });
8483
8497
  });
8484
8498
  }
8485
- function qE() {
8499
+ function lE() {
8486
8500
  if (!(EA.length > 0))
8487
8501
  try {
8488
- for (let g = 0; g < YE; g++) {
8489
- const A = EC();
8502
+ for (let g = 0; g < ME; g++) {
8503
+ const A = iC();
8490
8504
  EA.push({
8491
8505
  worker: A,
8492
8506
  pendingCount: 0,
8493
- workerId: CC++
8507
+ workerId: QC++
8494
8508
  });
8495
8509
  }
8496
8510
  k.debug(
@@ -8498,14 +8512,14 @@ function qE() {
8498
8512
  `Initialized worker pool with ${EA.length} workers`
8499
8513
  );
8500
8514
  } catch {
8501
- k.warn("ZarrWorker", "Failed to create workers - clearing pool"), fE();
8515
+ k.warn("ZarrWorker", "Failed to create workers - clearing pool"), pE();
8502
8516
  return;
8503
8517
  }
8504
8518
  }
8505
- async function lE(g, A, I, B, C) {
8506
- qE();
8519
+ async function fE(g, A, I, B, C) {
8520
+ lE();
8507
8521
  try {
8508
- return await HE(
8522
+ return await qE(
8509
8523
  A,
8510
8524
  I,
8511
8525
  B,
@@ -8516,11 +8530,11 @@ async function lE(g, A, I, B, C) {
8516
8530
  throw Q;
8517
8531
  k.warn("ZarrWorker", "Falling back to main thread", Q);
8518
8532
  const E = await g.getChunk(I, C);
8519
- if (!SQ(E.data))
8533
+ if (!RQ(E.data))
8520
8534
  throw new Error(
8521
8535
  `Unsupported chunk data type: ${E.data.constructor.name}`
8522
8536
  );
8523
- return kE(
8537
+ return LE(
8524
8538
  E.data,
8525
8539
  E.shape,
8526
8540
  E.stride,
@@ -8528,19 +8542,19 @@ async function lE(g, A, I, B, C) {
8528
8542
  );
8529
8543
  }
8530
8544
  }
8531
- function fE() {
8545
+ function pE() {
8532
8546
  for (const g of EA)
8533
8547
  g.worker.terminate();
8534
8548
  EA = [], NA.clear();
8535
8549
  }
8536
- class pE {
8550
+ class mE {
8537
8551
  metadata_;
8538
8552
  arrays_;
8539
8553
  arrayParams_;
8540
8554
  dimensions_;
8541
8555
  bytesPerElement_;
8542
8556
  constructor(A) {
8543
- this.metadata_ = A.metadata, this.arrays_ = A.arrays, this.arrayParams_ = A.arrayParams, this.dimensions_ = uE(this.metadata_, this.arrays_), this.bytesPerElement_ = mE(this.arrays_[0].dtype);
8557
+ this.metadata_ = A.metadata, this.arrays_ = A.arrays, this.arrayParams_ = A.arrayParams, this.dimensions_ = TE(this.metadata_, this.arrays_), this.bytesPerElement_ = uE(this.arrays_[0].dtype);
8544
8558
  }
8545
8559
  getSourceDimensionMap() {
8546
8560
  return this.dimensions_;
@@ -8574,21 +8588,21 @@ class pE {
8574
8588
  },
8575
8589
  cChunkSize: E?.chunkSize,
8576
8590
  tChunkSize: i?.chunkSize
8577
- }, a = await lE(
8591
+ }, a = await fE(
8578
8592
  C,
8579
8593
  Q,
8580
8594
  B,
8581
8595
  o,
8582
8596
  { signal: I }
8583
8597
  ), D = a.BYTES_PER_ELEMENT;
8584
- if (!DQ(D))
8598
+ if (!sQ(D))
8585
8599
  throw new Error(
8586
8600
  "Invalid row alignment value. Possible values are 1, 2, 4, or 8"
8587
8601
  );
8588
- A.rowAlignmentBytes = D, FQ(A, a);
8602
+ A.rowAlignmentBytes = D, rQ(A, a);
8589
8603
  }
8590
8604
  }
8591
- const FB = {
8605
+ const rB = {
8592
8606
  int8: 1,
8593
8607
  uint8: 1,
8594
8608
  int16: 2,
@@ -8597,16 +8611,16 @@ const FB = {
8597
8611
  uint32: 4,
8598
8612
  float32: 4
8599
8613
  };
8600
- function mE(g) {
8601
- const A = FB[g];
8614
+ function uE(g) {
8615
+ const A = rB[g];
8602
8616
  if (A === void 0)
8603
8617
  throw new Error(
8604
- `Unsupported zarr dtype "${g}". Supported dtypes: ${Object.keys(FB).join(", ")}`
8618
+ `Unsupported zarr dtype "${g}". Supported dtypes: ${Object.keys(rB).join(", ")}`
8605
8619
  );
8606
8620
  return A;
8607
8621
  }
8608
- function uE(g, A) {
8609
- const I = g.axes.map((s) => s.name), B = g.axes.length, C = rB(I, "x"), Q = rB(I, "y"), E = (s, h) => {
8622
+ function TE(g, A) {
8623
+ const I = g.axes.map((s) => s.name), B = g.axes.length, C = SB(I, "x"), Q = SB(I, "y"), E = (s, h) => {
8610
8624
  const t = [];
8611
8625
  for (let y = 0; y < g.datasets.length; y++) {
8612
8626
  const n = g.datasets[y], F = A[y], G = n.coordinateTransformations[0].scale, J = n.coordinateTransformations.length === 2 ? n.coordinateTransformations[1].translation : new Array(B).fill(0);
@@ -8617,7 +8631,7 @@ function uE(g, A) {
8617
8631
  translation: J[h]
8618
8632
  });
8619
8633
  }
8620
- if (g.axes[h].type === "space" && xE(t))
8634
+ if (g.axes[h].type === "space" && WE(t))
8621
8635
  for (const y of t) y.translation -= 0.5 * y.scale;
8622
8636
  return {
8623
8637
  name: s,
@@ -8636,10 +8650,10 @@ function uE(g, A) {
8636
8650
  const D = iI(I, "t");
8637
8651
  return D !== -1 && (i.t = E(I[D], D)), i;
8638
8652
  }
8639
- function TE(g, A) {
8653
+ function xE(g, A) {
8640
8654
  return g.toLowerCase() === A.toLowerCase();
8641
8655
  }
8642
- function rB(g, A) {
8656
+ function SB(g, A) {
8643
8657
  const I = iI(g, A);
8644
8658
  if (I === -1)
8645
8659
  throw new Error(
@@ -8648,9 +8662,9 @@ function rB(g, A) {
8648
8662
  return I;
8649
8663
  }
8650
8664
  function iI(g, A) {
8651
- return g.findIndex((I) => TE(I, A));
8665
+ return g.findIndex((I) => xE(I, A));
8652
8666
  }
8653
- function xE(g) {
8667
+ function WE(g) {
8654
8668
  if (g.length <= 1) return !1;
8655
8669
  for (let A = 1; A < g.length; A++) {
8656
8670
  const I = 0.5 * (g[A].scale - g[A - 1].scale), B = g[A].translation - g[A - 1].translation;
@@ -8695,14 +8709,14 @@ var l;
8695
8709
  }
8696
8710
  g.joinValues = B, g.jsonStringifyReplacer = (C, Q) => typeof Q == "bigint" ? Q.toString() : Q;
8697
8711
  })(l || (l = {}));
8698
- var SB;
8712
+ var RB;
8699
8713
  (function(g) {
8700
8714
  g.mergeShapes = (A, I) => ({
8701
8715
  ...A,
8702
8716
  ...I
8703
8717
  // second overwrites first
8704
8718
  });
8705
- })(SB || (SB = {}));
8719
+ })(RB || (RB = {}));
8706
8720
  const R = l.arrayToEnum([
8707
8721
  "string",
8708
8722
  "nan",
@@ -8883,11 +8897,11 @@ const Bg = (g, A) => {
8883
8897
  }
8884
8898
  return { message: I };
8885
8899
  };
8886
- let WE = Bg;
8887
- function bE() {
8888
- return WE;
8900
+ let bE = Bg;
8901
+ function ZE() {
8902
+ return bE;
8889
8903
  }
8890
- const ZE = (g) => {
8904
+ const PE = (g) => {
8891
8905
  const { data: A, path: I, errorMaps: B, issueData: C } = g, Q = [...I, ...C.path || []], E = {
8892
8906
  ...C,
8893
8907
  path: Q
@@ -8909,7 +8923,7 @@ const ZE = (g) => {
8909
8923
  };
8910
8924
  };
8911
8925
  function w(g, A) {
8912
- const I = bE(), B = ZE({
8926
+ const I = ZE(), B = PE({
8913
8927
  issueData: A,
8914
8928
  data: g.data,
8915
8929
  path: g.path,
@@ -8969,7 +8983,7 @@ class gA {
8969
8983
  }
8970
8984
  const Y = Object.freeze({
8971
8985
  status: "aborted"
8972
- }), PA = (g) => ({ status: "dirty", value: g }), QA = (g) => ({ status: "valid", value: g }), RB = (g) => g.status === "aborted", NB = (g) => g.status === "dirty", KA = (g) => g.status === "valid", SI = (g) => typeof Promise < "u" && g instanceof Promise;
8986
+ }), PA = (g) => ({ status: "dirty", value: g }), QA = (g) => ({ status: "valid", value: g }), NB = (g) => g.status === "aborted", cB = (g) => g.status === "dirty", KA = (g) => g.status === "valid", SI = (g) => typeof Promise < "u" && g instanceof Promise;
8973
8987
  var N;
8974
8988
  (function(g) {
8975
8989
  g.errToObj = (A) => typeof A == "string" ? { message: A } : A || {}, g.toString = (A) => typeof A == "string" ? A : A?.message;
@@ -8982,7 +8996,7 @@ class wA {
8982
8996
  return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
8983
8997
  }
8984
8998
  }
8985
- const cB = (g, A) => {
8999
+ const UB = (g, A) => {
8986
9000
  if (KA(A))
8987
9001
  return { success: !0, data: A.value };
8988
9002
  if (!g.common.issues.length)
@@ -9067,7 +9081,7 @@ class q {
9067
9081
  data: A,
9068
9082
  parsedType: yA(A)
9069
9083
  }, C = this._parseSync({ data: A, path: B.path, parent: B });
9070
- return cB(B, C);
9084
+ return UB(B, C);
9071
9085
  }
9072
9086
  "~validate"(A) {
9073
9087
  const I = {
@@ -9120,7 +9134,7 @@ class q {
9120
9134
  data: A,
9121
9135
  parsedType: yA(A)
9122
9136
  }, C = this._parse({ data: A, path: B.path, parent: B }), Q = await (SI(C) ? C : Promise.resolve(C));
9123
- return cB(B, Q);
9137
+ return UB(B, Q);
9124
9138
  }
9125
9139
  refine(A, I) {
9126
9140
  const B = (C) => typeof I == "string" || typeof I > "u" ? { message: I } : typeof I == "function" ? I(C) : I;
@@ -9191,7 +9205,7 @@ class q {
9191
9205
  });
9192
9206
  }
9193
9207
  brand() {
9194
- return new ti({
9208
+ return new yi({
9195
9209
  typeName: M.ZodBranded,
9196
9210
  type: this,
9197
9211
  ...K(this._def)
@@ -9226,28 +9240,28 @@ class q {
9226
9240
  return this.safeParse(null).success;
9227
9241
  }
9228
9242
  }
9229
- const PE = /^c[^\s-]{8,}$/i, OE = /^[0-9a-z]+$/, VE = /^[0-9A-HJKMNP-TV-Z]{26}$/i, vE = /^[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, XE = /^[a-z0-9_-]{21}$/i, jE = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, zE = /^[-+]?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)?)??$/, _E = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, $E = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
9243
+ const OE = /^c[^\s-]{8,}$/i, VE = /^[0-9a-z]+$/, vE = /^[0-9A-HJKMNP-TV-Z]{26}$/i, XE = /^[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, jE = /^[a-z0-9_-]{21}$/i, zE = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, _E = /^[-+]?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)?)??$/, $E = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ai = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
9230
9244
  let bI;
9231
- const Ai = /^(?:(?: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])$/, Ii = /^(?:(?: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])$/, gi = /^(([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]))$/, Bi = /^(([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])$/, Ci = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Qi = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, iC = "((\\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])))", Ei = new RegExp(`^${iC}$`);
9232
- function oC(g) {
9245
+ const Ii = /^(?:(?: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])$/, gi = /^(?:(?: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])$/, Bi = /^(([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]))$/, Ci = /^(([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])$/, Qi = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ei = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, oC = "((\\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])))", ii = new RegExp(`^${oC}$`);
9246
+ function aC(g) {
9233
9247
  let A = "[0-5]\\d";
9234
9248
  g.precision ? A = `${A}\\.\\d{${g.precision}}` : g.precision == null && (A = `${A}(\\.\\d+)?`);
9235
9249
  const I = g.precision ? "+" : "?";
9236
9250
  return `([01]\\d|2[0-3]):[0-5]\\d(:${A})${I}`;
9237
9251
  }
9238
- function ii(g) {
9239
- return new RegExp(`^${oC(g)}$`);
9240
- }
9241
9252
  function oi(g) {
9242
- let A = `${iC}T${oC(g)}`;
9253
+ return new RegExp(`^${aC(g)}$`);
9254
+ }
9255
+ function ai(g) {
9256
+ let A = `${oC}T${aC(g)}`;
9243
9257
  const I = [];
9244
9258
  return I.push(g.local ? "Z?" : "Z"), g.offset && I.push("([+-]\\d{2}:?\\d{2})"), A = `${A}(${I.join("|")})`, new RegExp(`^${A}$`);
9245
9259
  }
9246
- function ai(g, A) {
9247
- return !!((A === "v4" || !A) && Ai.test(g) || (A === "v6" || !A) && gi.test(g));
9248
- }
9249
9260
  function Di(g, A) {
9250
- if (!jE.test(g))
9261
+ return !!((A === "v4" || !A) && Ii.test(g) || (A === "v6" || !A) && Bi.test(g));
9262
+ }
9263
+ function si(g, A) {
9264
+ if (!zE.test(g))
9251
9265
  return !1;
9252
9266
  try {
9253
9267
  const [I] = g.split(".");
@@ -9259,8 +9273,8 @@ function Di(g, A) {
9259
9273
  return !1;
9260
9274
  }
9261
9275
  }
9262
- function si(g, A) {
9263
- return !!((A === "v4" || !A) && Ii.test(g) || (A === "v6" || !A) && Bi.test(g));
9276
+ function hi(g, A) {
9277
+ return !!((A === "v4" || !A) && gi.test(g) || (A === "v6" || !A) && Ci.test(g));
9264
9278
  }
9265
9279
  class eA extends q {
9266
9280
  _parse(A) {
@@ -9311,43 +9325,43 @@ class eA extends q {
9311
9325
  message: Q.message
9312
9326
  }), B.dirty());
9313
9327
  } else if (Q.kind === "email")
9314
- _E.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9328
+ $E.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9315
9329
  validation: "email",
9316
9330
  code: e.invalid_string,
9317
9331
  message: Q.message
9318
9332
  }), B.dirty());
9319
9333
  else if (Q.kind === "emoji")
9320
- bI || (bI = new RegExp($E, "u")), bI.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9334
+ bI || (bI = new RegExp(Ai, "u")), bI.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9321
9335
  validation: "emoji",
9322
9336
  code: e.invalid_string,
9323
9337
  message: Q.message
9324
9338
  }), B.dirty());
9325
9339
  else if (Q.kind === "uuid")
9326
- vE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9340
+ XE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9327
9341
  validation: "uuid",
9328
9342
  code: e.invalid_string,
9329
9343
  message: Q.message
9330
9344
  }), B.dirty());
9331
9345
  else if (Q.kind === "nanoid")
9332
- XE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9346
+ jE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9333
9347
  validation: "nanoid",
9334
9348
  code: e.invalid_string,
9335
9349
  message: Q.message
9336
9350
  }), B.dirty());
9337
9351
  else if (Q.kind === "cuid")
9338
- PE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9352
+ OE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9339
9353
  validation: "cuid",
9340
9354
  code: e.invalid_string,
9341
9355
  message: Q.message
9342
9356
  }), B.dirty());
9343
9357
  else if (Q.kind === "cuid2")
9344
- OE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9358
+ VE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9345
9359
  validation: "cuid2",
9346
9360
  code: e.invalid_string,
9347
9361
  message: Q.message
9348
9362
  }), B.dirty());
9349
9363
  else if (Q.kind === "ulid")
9350
- VE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9364
+ vE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9351
9365
  validation: "ulid",
9352
9366
  code: e.invalid_string,
9353
9367
  message: Q.message
@@ -9378,39 +9392,39 @@ class eA extends q {
9378
9392
  code: e.invalid_string,
9379
9393
  validation: { endsWith: Q.value },
9380
9394
  message: Q.message
9381
- }), B.dirty()) : Q.kind === "datetime" ? oi(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9395
+ }), B.dirty()) : Q.kind === "datetime" ? ai(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9382
9396
  code: e.invalid_string,
9383
9397
  validation: "datetime",
9384
9398
  message: Q.message
9385
- }), B.dirty()) : Q.kind === "date" ? Ei.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9399
+ }), B.dirty()) : Q.kind === "date" ? ii.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9386
9400
  code: e.invalid_string,
9387
9401
  validation: "date",
9388
9402
  message: Q.message
9389
- }), B.dirty()) : Q.kind === "time" ? ii(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9403
+ }), B.dirty()) : Q.kind === "time" ? oi(Q).test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9390
9404
  code: e.invalid_string,
9391
9405
  validation: "time",
9392
9406
  message: Q.message
9393
- }), B.dirty()) : Q.kind === "duration" ? zE.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9407
+ }), B.dirty()) : Q.kind === "duration" ? _E.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9394
9408
  validation: "duration",
9395
9409
  code: e.invalid_string,
9396
9410
  message: Q.message
9397
- }), B.dirty()) : Q.kind === "ip" ? ai(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
9411
+ }), B.dirty()) : Q.kind === "ip" ? Di(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
9398
9412
  validation: "ip",
9399
9413
  code: e.invalid_string,
9400
9414
  message: Q.message
9401
- }), B.dirty()) : Q.kind === "jwt" ? Di(A.data, Q.alg) || (C = this._getOrReturnCtx(A, C), w(C, {
9415
+ }), B.dirty()) : Q.kind === "jwt" ? si(A.data, Q.alg) || (C = this._getOrReturnCtx(A, C), w(C, {
9402
9416
  validation: "jwt",
9403
9417
  code: e.invalid_string,
9404
9418
  message: Q.message
9405
- }), B.dirty()) : Q.kind === "cidr" ? si(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
9419
+ }), B.dirty()) : Q.kind === "cidr" ? hi(A.data, Q.version) || (C = this._getOrReturnCtx(A, C), w(C, {
9406
9420
  validation: "cidr",
9407
9421
  code: e.invalid_string,
9408
9422
  message: Q.message
9409
- }), B.dirty()) : Q.kind === "base64" ? Ci.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9423
+ }), B.dirty()) : Q.kind === "base64" ? Qi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9410
9424
  validation: "base64",
9411
9425
  code: e.invalid_string,
9412
9426
  message: Q.message
9413
- }), B.dirty()) : Q.kind === "base64url" ? Qi.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9427
+ }), B.dirty()) : Q.kind === "base64url" ? Ei.test(A.data) || (C = this._getOrReturnCtx(A, C), w(C, {
9414
9428
  validation: "base64url",
9415
9429
  code: e.invalid_string,
9416
9430
  message: Q.message
@@ -9645,7 +9659,7 @@ eA.create = (g) => new eA({
9645
9659
  coerce: g?.coerce ?? !1,
9646
9660
  ...K(g)
9647
9661
  });
9648
- function hi(g, A) {
9662
+ function ti(g, A) {
9649
9663
  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(".", ""));
9650
9664
  return Q % E / 10 ** C;
9651
9665
  }
@@ -9684,7 +9698,7 @@ class HA extends q {
9684
9698
  inclusive: Q.inclusive,
9685
9699
  exact: !1,
9686
9700
  message: Q.message
9687
- }), C.dirty()) : Q.kind === "multipleOf" ? hi(A.data, Q.value) !== 0 && (B = this._getOrReturnCtx(A, B), w(B, {
9701
+ }), C.dirty()) : Q.kind === "multipleOf" ? ti(A.data, Q.value) !== 0 && (B = this._getOrReturnCtx(A, B), w(B, {
9688
9702
  code: e.not_multiple_of,
9689
9703
  multipleOf: Q.value,
9690
9704
  message: Q.message
@@ -10050,7 +10064,7 @@ RI.create = (g) => new RI({
10050
10064
  typeName: M.ZodDate,
10051
10065
  ...K(g)
10052
10066
  });
10053
- class UB extends q {
10067
+ class kB extends q {
10054
10068
  _parse(A) {
10055
10069
  if (this._getType(A) !== R.symbol) {
10056
10070
  const B = this._getOrReturnCtx(A);
@@ -10063,11 +10077,11 @@ class UB extends q {
10063
10077
  return QA(A.data);
10064
10078
  }
10065
10079
  }
10066
- UB.create = (g) => new UB({
10080
+ kB.create = (g) => new kB({
10067
10081
  typeName: M.ZodSymbol,
10068
10082
  ...K(g)
10069
10083
  });
10070
- class kB extends q {
10084
+ class LB extends q {
10071
10085
  _parse(A) {
10072
10086
  if (this._getType(A) !== R.undefined) {
10073
10087
  const B = this._getOrReturnCtx(A);
@@ -10080,11 +10094,11 @@ class kB extends q {
10080
10094
  return QA(A.data);
10081
10095
  }
10082
10096
  }
10083
- kB.create = (g) => new kB({
10097
+ LB.create = (g) => new LB({
10084
10098
  typeName: M.ZodUndefined,
10085
10099
  ...K(g)
10086
10100
  });
10087
- class LB extends q {
10101
+ class JB extends q {
10088
10102
  _parse(A) {
10089
10103
  if (this._getType(A) !== R.null) {
10090
10104
  const B = this._getOrReturnCtx(A);
@@ -10097,7 +10111,7 @@ class LB extends q {
10097
10111
  return QA(A.data);
10098
10112
  }
10099
10113
  }
10100
- LB.create = (g) => new LB({
10114
+ JB.create = (g) => new JB({
10101
10115
  typeName: M.ZodNull,
10102
10116
  ...K(g)
10103
10117
  });
@@ -10113,7 +10127,7 @@ Qg.create = (g) => new Qg({
10113
10127
  typeName: M.ZodAny,
10114
10128
  ...K(g)
10115
10129
  });
10116
- class JB extends q {
10130
+ class YB extends q {
10117
10131
  constructor() {
10118
10132
  super(...arguments), this._unknown = !0;
10119
10133
  }
@@ -10121,7 +10135,7 @@ class JB extends q {
10121
10135
  return QA(A.data);
10122
10136
  }
10123
10137
  }
10124
- JB.create = (g) => new JB({
10138
+ YB.create = (g) => new YB({
10125
10139
  typeName: M.ZodUnknown,
10126
10140
  ...K(g)
10127
10141
  });
@@ -10139,7 +10153,7 @@ FA.create = (g) => new FA({
10139
10153
  typeName: M.ZodNever,
10140
10154
  ...K(g)
10141
10155
  });
10142
- class YB extends q {
10156
+ class MB extends q {
10143
10157
  _parse(A) {
10144
10158
  if (this._getType(A) !== R.undefined) {
10145
10159
  const B = this._getOrReturnCtx(A);
@@ -10152,7 +10166,7 @@ class YB extends q {
10152
10166
  return QA(A.data);
10153
10167
  }
10154
10168
  }
10155
- YB.create = (g) => new YB({
10169
+ MB.create = (g) => new MB({
10156
10170
  typeName: M.ZodVoid,
10157
10171
  ...K(g)
10158
10172
  });
@@ -10508,7 +10522,7 @@ class O extends q {
10508
10522
  });
10509
10523
  }
10510
10524
  keyof() {
10511
- return aC(l.objectKeys(this.shape));
10525
+ return DC(l.objectKeys(this.shape));
10512
10526
  }
10513
10527
  }
10514
10528
  O.create = (g, A) => new O({
@@ -10634,10 +10648,10 @@ function Eg(g, A) {
10634
10648
  class cI extends q {
10635
10649
  _parse(A) {
10636
10650
  const { status: I, ctx: B } = this._processInputParams(A), C = (Q, E) => {
10637
- if (RB(Q) || RB(E))
10651
+ if (NB(Q) || NB(E))
10638
10652
  return Y;
10639
10653
  const i = Eg(Q.value, E.value);
10640
- return i.valid ? ((NB(Q) || NB(E)) && I.dirty(), { status: I.value, value: i.data }) : (w(B, {
10654
+ return i.valid ? ((cB(Q) || cB(E)) && I.dirty(), { status: I.value, value: i.data }) : (w(B, {
10641
10655
  code: e.invalid_intersection_types
10642
10656
  }), Y);
10643
10657
  };
@@ -10719,7 +10733,7 @@ cA.create = (g, A) => {
10719
10733
  ...K(A)
10720
10734
  });
10721
10735
  };
10722
- class MB extends q {
10736
+ class dB extends q {
10723
10737
  get keySchema() {
10724
10738
  return this._def.keyType;
10725
10739
  }
@@ -10761,7 +10775,7 @@ class MB extends q {
10761
10775
  }
10762
10776
  }
10763
10777
  }
10764
- MB.create = (g, A, I) => new MB({
10778
+ dB.create = (g, A, I) => new dB({
10765
10779
  valueType: A,
10766
10780
  keyType: g,
10767
10781
  typeName: M.ZodMap,
@@ -10831,7 +10845,7 @@ zA.create = (g, A) => new zA({
10831
10845
  typeName: M.ZodSet,
10832
10846
  ...K(A)
10833
10847
  });
10834
- class dB extends q {
10848
+ class KB extends q {
10835
10849
  get schema() {
10836
10850
  return this._def.getter();
10837
10851
  }
@@ -10840,7 +10854,7 @@ class dB extends q {
10840
10854
  return this._def.getter()._parse({ data: I.data, path: I.path, parent: I });
10841
10855
  }
10842
10856
  }
10843
- dB.create = (g, A) => new dB({
10857
+ KB.create = (g, A) => new KB({
10844
10858
  getter: g,
10845
10859
  typeName: M.ZodLazy,
10846
10860
  ...K(A)
@@ -10866,7 +10880,7 @@ ig.create = (g, A) => new ig({
10866
10880
  typeName: M.ZodLiteral,
10867
10881
  ...K(A)
10868
10882
  });
10869
- function aC(g, A) {
10883
+ function DC(g, A) {
10870
10884
  return new qA({
10871
10885
  values: g,
10872
10886
  typeName: M.ZodEnum,
@@ -10927,8 +10941,8 @@ class qA extends q {
10927
10941
  });
10928
10942
  }
10929
10943
  }
10930
- qA.create = aC;
10931
- class KB extends q {
10944
+ qA.create = DC;
10945
+ class HB extends q {
10932
10946
  _parse(A) {
10933
10947
  const I = l.getValidEnumValues(this._def.values), B = this._getOrReturnCtx(A);
10934
10948
  if (B.parsedType !== R.string && B.parsedType !== R.number) {
@@ -10953,7 +10967,7 @@ class KB extends q {
10953
10967
  return this._def.values;
10954
10968
  }
10955
10969
  }
10956
- KB.create = (g, A) => new KB({
10970
+ HB.create = (g, A) => new HB({
10957
10971
  values: g,
10958
10972
  typeName: M.ZodNativeEnum,
10959
10973
  ...K(A)
@@ -11163,7 +11177,7 @@ ag.create = (g, A) => new ag({
11163
11177
  catchValue: typeof A.catch == "function" ? A.catch : () => A.catch,
11164
11178
  ...K(A)
11165
11179
  });
11166
- class HB extends q {
11180
+ class qB extends q {
11167
11181
  _parse(A) {
11168
11182
  if (this._getType(A) !== R.nan) {
11169
11183
  const B = this._getOrReturnCtx(A);
@@ -11176,11 +11190,11 @@ class HB extends q {
11176
11190
  return { status: "valid", value: A.data };
11177
11191
  }
11178
11192
  }
11179
- HB.create = (g) => new HB({
11193
+ qB.create = (g) => new qB({
11180
11194
  typeName: M.ZodNaN,
11181
11195
  ...K(g)
11182
11196
  });
11183
- class ti extends q {
11197
+ class yi extends q {
11184
11198
  _parse(A) {
11185
11199
  const { ctx: I } = this._processInputParams(A), B = I.data;
11186
11200
  return this._def.type._parse({
@@ -11251,7 +11265,7 @@ var M;
11251
11265
  (function(g) {
11252
11266
  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";
11253
11267
  })(M || (M = {}));
11254
- const u = eA.create, H = HA.create, DC = Cg.create, nA = Qg.create;
11268
+ const u = eA.create, H = HA.create, sC = Cg.create, nA = Qg.create;
11255
11269
  FA.create;
11256
11270
  const m = sA.create, L = O.create;
11257
11271
  NI.create;
@@ -11261,7 +11275,7 @@ const _ = ig.create, LA = qA.create;
11261
11275
  UI.create;
11262
11276
  GA.create;
11263
11277
  fA.create;
11264
- const yi = L({
11278
+ const ei = L({
11265
11279
  /**The multiscale datasets for this image*/
11266
11280
  multiscales: m(
11267
11281
  L({
@@ -11374,7 +11388,7 @@ const yi = L({
11374
11388
  label: u().optional(),
11375
11389
  family: u().optional(),
11376
11390
  color: u(),
11377
- active: DC().optional()
11391
+ active: sC().optional()
11378
11392
  })
11379
11393
  ),
11380
11394
  // The rdefs are not in the JSON schema and are not particularly well
@@ -11389,7 +11403,7 @@ const yi = L({
11389
11403
  projection: u().optional()
11390
11404
  }).optional()
11391
11405
  }).optional()
11392
- }).describe("JSON from OME-NGFF .zattrs"), ei = L({
11406
+ }).describe("JSON from OME-NGFF .zattrs"), ni = L({
11393
11407
  plate: L({
11394
11408
  /**The acquisitions for this plate*/
11395
11409
  acquisitions: m(
@@ -11448,7 +11462,7 @@ const yi = L({
11448
11462
  })
11449
11463
  ).min(1).describe("The wells of the plate")
11450
11464
  }).optional()
11451
- }).describe("JSON from OME-NGFF .zattrs"), ni = L({
11465
+ }).describe("JSON from OME-NGFF .zattrs"), Gi = L({
11452
11466
  well: L({
11453
11467
  /**The fields of view for this well*/
11454
11468
  images: m(
@@ -11462,7 +11476,7 @@ const yi = L({
11462
11476
  /**The version of the specification*/
11463
11477
  version: _("0.4").describe("The version of the specification").optional()
11464
11478
  }).optional()
11465
- }).describe("JSON from OME-NGFF .zattrs"), Gi = L({
11479
+ }).describe("JSON from OME-NGFF .zattrs"), wi = L({
11466
11480
  /**The versioned OME-Zarr Metadata namespace*/
11467
11481
  ome: L({
11468
11482
  /**The multiscale datasets for this image*/
@@ -11574,7 +11588,7 @@ const yi = L({
11574
11588
  label: u().optional(),
11575
11589
  family: u().optional(),
11576
11590
  color: u().optional(),
11577
- active: DC().optional()
11591
+ active: sC().optional()
11578
11592
  })
11579
11593
  ),
11580
11594
  // The rdefs are not in the JSON schema and are not particularly well
@@ -11592,7 +11606,7 @@ const yi = L({
11592
11606
  /**The version of the OME-Zarr Metadata*/
11593
11607
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
11594
11608
  }).describe("The versioned OME-Zarr Metadata namespace")
11595
- }).describe("The zarr.json attributes key"), wi = L({
11609
+ }).describe("The zarr.json attributes key"), Fi = L({
11596
11610
  /**The versioned OME-Zarr Metadata namespace*/
11597
11611
  ome: L({
11598
11612
  plate: L({
@@ -11654,7 +11668,7 @@ const yi = L({
11654
11668
  /**The version of the OME-Zarr Metadata*/
11655
11669
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
11656
11670
  }).describe("The versioned OME-Zarr Metadata namespace")
11657
- }).describe("The zarr.json attributes key"), Fi = L({
11671
+ }).describe("The zarr.json attributes key"), ri = L({
11658
11672
  /**The versioned OME-Zarr Metadata namespace*/
11659
11673
  ome: L({
11660
11674
  well: L({
@@ -11673,15 +11687,15 @@ const yi = L({
11673
11687
  /**The version of the OME-Zarr Metadata*/
11674
11688
  version: _("0.5").describe("The version of the OME-Zarr Metadata")
11675
11689
  }).describe("The versioned OME-Zarr Metadata namespace")
11676
- }).describe("JSON from OME-Zarr zarr.json"), ri = ["0.4", "0.5"], Si = new Set(ri);
11677
- function Ri(g) {
11690
+ }).describe("JSON from OME-Zarr zarr.json"), Si = ["0.4", "0.5"], Ri = new Set(Si);
11691
+ function Ni(g) {
11678
11692
  if (!("ome" in g) || !(g.ome instanceof Object)) return;
11679
11693
  const A = g.ome;
11680
- if ("version" in A && typeof A.version == "string" && Si.has(A.version))
11694
+ if ("version" in A && typeof A.version == "string" && Ri.has(A.version))
11681
11695
  return A.version;
11682
11696
  }
11683
11697
  function lg(g) {
11684
- const A = Ri(g);
11698
+ const A = Ni(g);
11685
11699
  return A === void 0 ? "0.4" : A;
11686
11700
  }
11687
11701
  function pA(g) {
@@ -11693,14 +11707,14 @@ function pA(g) {
11693
11707
  return "v3";
11694
11708
  }
11695
11709
  }
11696
- function sC(g, A) {
11710
+ function hC(g, A) {
11697
11711
  const I = { ...g };
11698
11712
  return delete I[A], I;
11699
11713
  }
11700
- async function yo(g, A) {
11714
+ async function eo(g, A) {
11701
11715
  const I = new $A(g), B = new CA(I), C = pA(A), Q = await BI(B, C);
11702
11716
  try {
11703
- return Ni(Q.attrs);
11717
+ return ci(Q.attrs);
11704
11718
  } catch {
11705
11719
  throw Error(
11706
11720
  `Failed to parse OME-Zarr plate:
@@ -11708,58 +11722,58 @@ ${JSON.stringify(Q.attrs)}`
11708
11722
  );
11709
11723
  }
11710
11724
  }
11711
- function Ni(g) {
11725
+ function ci(g) {
11712
11726
  switch (lg(g)) {
11713
11727
  case "0.5":
11714
11728
  return {
11715
- ...wi.parse(g).ome,
11729
+ ...Fi.parse(g).ome,
11716
11730
  originalVersion: "0.5"
11717
11731
  };
11718
11732
  case "0.4":
11719
11733
  return {
11720
- ...ci(ei.parse(g)).ome,
11734
+ ...Ui(ni.parse(g)).ome,
11721
11735
  originalVersion: "0.4"
11722
11736
  };
11723
11737
  }
11724
11738
  }
11725
- function ci(g) {
11739
+ function Ui(g) {
11726
11740
  if (g.plate === void 0)
11727
11741
  throw new Error("Plate metadata is missing in OME-Zarr v0.4 plate");
11728
11742
  return {
11729
11743
  ome: {
11730
- plate: sC(g.plate, "version"),
11744
+ plate: hC(g.plate, "version"),
11731
11745
  version: "0.5"
11732
11746
  }
11733
11747
  };
11734
11748
  }
11735
- function Ui(g) {
11749
+ function ki(g) {
11736
11750
  if (g.well === void 0)
11737
11751
  throw new Error("Well metadata is missing in OME-Zarr v0.4 well");
11738
11752
  return {
11739
11753
  ome: {
11740
- well: sC(g.well, "version"),
11754
+ well: hC(g.well, "version"),
11741
11755
  version: "0.5"
11742
11756
  }
11743
11757
  };
11744
11758
  }
11745
- function ki(g) {
11759
+ function Li(g) {
11746
11760
  switch (lg(g)) {
11747
11761
  case "0.5":
11748
11762
  return {
11749
- ...Fi.parse(g).ome,
11763
+ ...ri.parse(g).ome,
11750
11764
  originalVersion: "0.5"
11751
11765
  };
11752
11766
  case "0.4":
11753
11767
  return {
11754
- ...Ui(ni.parse(g)).ome,
11768
+ ...ki(Gi.parse(g)).ome,
11755
11769
  originalVersion: "0.4"
11756
11770
  };
11757
11771
  }
11758
11772
  }
11759
- async function eo(g, A, I) {
11773
+ async function no(g, A, I) {
11760
11774
  const B = g + "/" + A, C = new $A(B), Q = new CA(C), E = pA(I), i = await BI(Q, E);
11761
11775
  try {
11762
- return ki(i.attrs);
11776
+ return Li(i.attrs);
11763
11777
  } catch {
11764
11778
  throw Error(
11765
11779
  `Failed to parse OME-Zarr well:
@@ -11767,15 +11781,15 @@ ${JSON.stringify(i.attrs)}`
11767
11781
  );
11768
11782
  }
11769
11783
  }
11770
- async function no(g) {
11784
+ async function Go(g) {
11771
11785
  const A = pA(g.version), I = await BI(g.location, A);
11772
11786
  return fg(I.attrs).omero?.channels ?? [];
11773
11787
  }
11774
- async function Go(g) {
11788
+ async function wo(g) {
11775
11789
  const A = pA(g.version), I = await BI(g.location, A);
11776
11790
  return fg(I.attrs).omero?.rdefs;
11777
11791
  }
11778
- function Li(g) {
11792
+ function Ji(g) {
11779
11793
  return {
11780
11794
  ome: {
11781
11795
  multiscales: g.multiscales,
@@ -11784,23 +11798,23 @@ function Li(g) {
11784
11798
  }
11785
11799
  };
11786
11800
  }
11787
- function Ji(g) {
11801
+ function Yi(g) {
11788
11802
  switch (lg(g)) {
11789
11803
  case "0.5":
11790
11804
  return {
11791
- ...Gi.parse(g).ome,
11805
+ ...wi.parse(g).ome,
11792
11806
  originalVersion: "0.5"
11793
11807
  };
11794
11808
  case "0.4":
11795
11809
  return {
11796
- ...Li(yi.parse(g)).ome,
11810
+ ...Ji(ei.parse(g)).ome,
11797
11811
  originalVersion: "0.4"
11798
11812
  };
11799
11813
  }
11800
11814
  }
11801
11815
  function fg(g) {
11802
11816
  try {
11803
- return Ji(g);
11817
+ return Yi(g);
11804
11818
  } catch {
11805
11819
  throw Error(`Failed to parse OME-Zarr image:
11806
11820
  ${JSON.stringify(g)}`);
@@ -11825,15 +11839,15 @@ class OA {
11825
11839
  throw new Error("No datasets found in the multiscale image.");
11826
11840
  B || (B = pA(Q.originalVersion));
11827
11841
  const o = i.datasets.map(
11828
- (h) => UE(A, h.path, B)
11842
+ (h) => kE(A, h.path, B)
11829
11843
  ), a = await Promise.all(
11830
- o.map((h) => cE(h))
11844
+ o.map((h) => UE(h))
11831
11845
  ), D = a[0].shape, s = i.axes;
11832
11846
  if (s.length !== D.length)
11833
11847
  throw new Error(
11834
11848
  `Mismatch between number of axes (${s.length}) and array shape (${D.length})`
11835
11849
  );
11836
- return new pE({ metadata: i, arrays: a, arrayParams: o });
11850
+ return new mE({ metadata: i, arrays: a, arrayParams: o });
11837
11851
  }
11838
11852
  getDimensions() {
11839
11853
  return this.loader_.getSourceDimensionMap();
@@ -11872,7 +11886,7 @@ class OA {
11872
11886
  }
11873
11887
  }
11874
11888
  class KI {
11875
- objects_ = [];
11889
+ coverageGroups_ = /* @__PURE__ */ new Map();
11876
11890
  state_ = "initialized";
11877
11891
  attached_ = !1;
11878
11892
  callbacks_ = [];
@@ -11906,8 +11920,8 @@ class KI {
11906
11920
  }
11907
11921
  detach(A) {
11908
11922
  }
11909
- get objects() {
11910
- return this.objects_;
11923
+ get coverageGroups() {
11924
+ return this.coverageGroups_;
11911
11925
  }
11912
11926
  get state() {
11913
11927
  return this.state_;
@@ -11921,22 +11935,16 @@ class KI {
11921
11935
  throw new Error(`Callback to remove could not be found: ${A}`);
11922
11936
  this.callbacks_.splice(I, 1);
11923
11937
  }
11924
- hasMultipleLODs() {
11925
- return !1;
11926
- }
11927
11938
  setState(A) {
11928
11939
  const I = this.state_;
11929
11940
  this.state_ = A, this.callbacks_.forEach((B) => B(A, I));
11930
11941
  }
11931
- addObject(A) {
11932
- this.objects_.push(A);
11933
- }
11934
- removeObject(A) {
11935
- const I = this.objects_.indexOf(A);
11936
- I !== -1 && this.objects_.splice(I, 1);
11942
+ addObject(A, I = null) {
11943
+ const B = this.coverageGroups_.get(I);
11944
+ B ? B.push(A) : this.coverageGroups_.set(I, [A]);
11937
11945
  }
11938
11946
  clearObjects() {
11939
- this.objects_ = [];
11947
+ this.coverageGroups_.clear();
11940
11948
  }
11941
11949
  /**
11942
11950
  * Get uniforms for shader program. Override in derived classes that need custom uniforms.
@@ -11946,7 +11954,7 @@ class KI {
11946
11954
  return {};
11947
11955
  }
11948
11956
  }
11949
- class Yi extends mA {
11957
+ class Mi extends mA {
11950
11958
  // this creates the geometry for a screen-space projected line
11951
11959
  // each point on the input path is split into two vertices
11952
11960
  // these are pushed in opposite directions in screen-space to create width
@@ -11995,7 +12003,7 @@ class Yi extends mA {
11995
12003
  return I;
11996
12004
  }
11997
12005
  }
11998
- class Mi extends mA {
12006
+ class di extends mA {
11999
12007
  constructor(A) {
12000
12008
  if (super(), A.primitive != "triangles") {
12001
12009
  k.warn("WireframeGeometry", "Only indexed geometries are supported");
@@ -12020,21 +12028,21 @@ class Mi extends mA {
12020
12028
  this.indexData_ = new Uint32Array(B);
12021
12029
  }
12022
12030
  }
12023
- const di = p(0, 1, 0);
12024
- class Ki {
12031
+ const Ki = p(0, 1, 0);
12032
+ class Hi {
12025
12033
  dirty_ = !0;
12026
12034
  matrix_ = $();
12027
12035
  rotation_ = sI();
12028
12036
  translation_ = d();
12029
12037
  scale_ = p(1, 1, 1);
12030
12038
  addRotation(A) {
12031
- gQ(this.rotation_, this.rotation_, A), this.dirty_ = !0;
12039
+ BQ(this.rotation_, this.rotation_, A), this.dirty_ = !0;
12032
12040
  }
12033
12041
  setRotation(A) {
12034
- CQ(this.rotation_, A), this.dirty_ = !0;
12042
+ QQ(this.rotation_, A), this.dirty_ = !0;
12035
12043
  }
12036
12044
  get rotation() {
12037
- return BQ(this.rotation_);
12045
+ return CQ(this.rotation_);
12038
12046
  }
12039
12047
  addTranslation(A) {
12040
12048
  JA(this.translation_, this.translation_, A), this.dirty_ = !0;
@@ -12046,14 +12054,14 @@ class Ki {
12046
12054
  return DA(this.translation_);
12047
12055
  }
12048
12056
  addScale(A) {
12049
- vC(this.scale_, this.scale_, A), this.dirty_ = !0;
12057
+ XC(this.scale_, this.scale_, A), this.dirty_ = !0;
12050
12058
  }
12051
12059
  setScale(A) {
12052
12060
  XI(this.scale_, A), this.dirty_ = !0;
12053
12061
  }
12054
12062
  targetTo(A) {
12055
12063
  ng(this.translation_, A) && (A = DA(A), A[2] += T);
12056
- const I = OC($(), this.translation_, A, di), B = mC(ZB(), I);
12064
+ const I = VC($(), this.translation_, A, Ki), B = uC(PB(), I);
12057
12065
  Gg(this.rotation_, B), JI(this.rotation_, this.rotation_), this.dirty_ = !0;
12058
12066
  }
12059
12067
  get scale() {
@@ -12066,7 +12074,7 @@ class Ki {
12066
12074
  return LI($(), this.matrix);
12067
12075
  }
12068
12076
  computeMatrix() {
12069
- xC(
12077
+ WC(
12070
12078
  this.matrix_,
12071
12079
  this.rotation_,
12072
12080
  this.translation_,
@@ -12148,7 +12156,7 @@ class xA extends hg {
12148
12156
  depthTest = !0;
12149
12157
  textures_ = [];
12150
12158
  staleTextures_ = [];
12151
- transform_ = new Ki();
12159
+ transform_ = new Hi();
12152
12160
  geometry_ = new mA();
12153
12161
  wireframeGeometry_ = null;
12154
12162
  programName_ = null;
@@ -12170,7 +12178,7 @@ class xA extends hg {
12170
12178
  return this.geometry_;
12171
12179
  }
12172
12180
  get wireframeGeometry() {
12173
- return this.wireframeGeometry_ ??= new Mi(this.geometry), this.wireframeGeometry_;
12181
+ return this.wireframeGeometry_ ??= new di(this.geometry), this.wireframeGeometry_;
12174
12182
  }
12175
12183
  get textures() {
12176
12184
  return this.textures_;
@@ -12205,7 +12213,7 @@ class xA extends hg {
12205
12213
  return {};
12206
12214
  }
12207
12215
  }
12208
- class Hi extends xA {
12216
+ class qi extends xA {
12209
12217
  color_;
12210
12218
  width_;
12211
12219
  constructor({ geometry: A, color: I, width: B }) {
@@ -12233,7 +12241,7 @@ class Hi extends xA {
12233
12241
  };
12234
12242
  }
12235
12243
  }
12236
- class wo extends KI {
12244
+ class Fo extends KI {
12237
12245
  type = "AxesLayer";
12238
12246
  constructor(A) {
12239
12247
  super();
@@ -12262,16 +12270,109 @@ class wo extends KI {
12262
12270
  }
12263
12271
  }
12264
12272
  function ZI(g) {
12265
- const { end: A, width: I, color: B } = g, C = new Yi([[0, 0, 0], A]);
12266
- return new Hi({
12273
+ const { end: A, width: I, color: B } = g, C = new Mi([[0, 0, 0], A]);
12274
+ return new qi({
12267
12275
  geometry: C,
12268
12276
  color: B,
12269
12277
  width: I
12270
12278
  });
12271
12279
  }
12272
- const qB = 32;
12280
+ const tC = [
12281
+ "fallbackVisible",
12282
+ "prefetchTime",
12283
+ "visibleCurrent",
12284
+ "fallbackBackground",
12285
+ "prefetchSpace"
12286
+ ];
12287
+ function pg(g) {
12288
+ li(g);
12289
+ const A = {
12290
+ x: g.prefetch.x,
12291
+ y: g.prefetch.y,
12292
+ z: g.prefetch.z ?? 0,
12293
+ t: g.prefetch.t ?? 0
12294
+ }, I = Object.freeze(
12295
+ tC.reduce(
12296
+ (Q, E) => {
12297
+ const i = g.priorityOrder.indexOf(E);
12298
+ return Q[E] = i, Q;
12299
+ },
12300
+ {}
12301
+ )
12302
+ ), B = {
12303
+ min: g.lod?.min ?? 0,
12304
+ max: g.lod?.max ?? Number.MAX_SAFE_INTEGER,
12305
+ bias: g.lod?.bias ?? 0.5
12306
+ }, C = {
12307
+ profile: g.profile ?? "custom",
12308
+ prefetch: A,
12309
+ priorityOrder: Object.freeze([...g.priorityOrder]),
12310
+ priorityMap: I,
12311
+ lod: B
12312
+ };
12313
+ return Object.freeze(C);
12314
+ }
12315
+ function mg(g = {}) {
12316
+ return pg(ug({
12317
+ profile: "exploration",
12318
+ prefetch: { x: 1, y: 1, z: 1, t: 0 },
12319
+ priorityOrder: [
12320
+ "fallbackVisible",
12321
+ "visibleCurrent",
12322
+ "prefetchSpace",
12323
+ "prefetchTime",
12324
+ "fallbackBackground"
12325
+ ]
12326
+ }, g));
12327
+ }
12328
+ function ro(g = {}) {
12329
+ return pg(ug({
12330
+ profile: "playback",
12331
+ prefetch: { x: 0, y: 0, z: 0, t: 20 },
12332
+ priorityOrder: [
12333
+ "fallbackVisible",
12334
+ "prefetchTime",
12335
+ "visibleCurrent",
12336
+ "fallbackBackground",
12337
+ "prefetchSpace"
12338
+ ]
12339
+ }, g));
12340
+ }
12341
+ function So(g = {}) {
12342
+ return pg(ug({
12343
+ profile: "no-prefetch",
12344
+ prefetch: { x: 0, y: 0, z: 0, t: 0 },
12345
+ priorityOrder: [
12346
+ "fallbackVisible",
12347
+ "visibleCurrent",
12348
+ "fallbackBackground",
12349
+ "prefetchSpace",
12350
+ "prefetchTime"
12351
+ ]
12352
+ }, g));
12353
+ }
12354
+ function li(g) {
12355
+ for (const [B, C] of Object.entries(g.prefetch))
12356
+ if (C !== void 0 && C < 0)
12357
+ throw new Error(`prefetch.${B} must be a non-negative number`);
12358
+ const A = g.lod;
12359
+ if (A?.min !== void 0 && A?.max !== void 0 && A.min > A.max)
12360
+ throw new Error("lod.min must be <= lod.max");
12361
+ const I = g.priorityOrder;
12362
+ if (I.length !== tC.length || new Set(I).size !== I.length)
12363
+ throw new Error("priorityOrder must include all categories exactly once");
12364
+ }
12365
+ function ug(g, A = {}) {
12366
+ return {
12367
+ profile: A.profile ?? g.profile,
12368
+ prefetch: { ...g.prefetch, ...A.prefetch ?? {} },
12369
+ lod: { ...g.lod, ...A.lod ?? {} },
12370
+ priorityOrder: A.priorityOrder ?? g.priorityOrder
12371
+ };
12372
+ }
12373
+ const lB = 32;
12273
12374
  function _A(g, { visible: A, color: I, contrastLimits: B, opacity: C }) {
12274
- return A ??= !0, I = I === void 0 ? x.WHITE : x.from(I), C = C === void 0 ? 1 : hA(C, 0, 1), g !== null ? B = qi(B, g) : B === void 0 && (k.debug(
12375
+ return A ??= !0, I = I === void 0 ? x.WHITE : x.from(I), C = C === void 0 ? 1 : hA(C, 0, 1), g !== null ? B = fi(B, g) : B === void 0 && (k.debug(
12275
12376
  "Channel",
12276
12377
  "No texture provided, defaulting channel contrast limits to [0, 1]."
12277
12378
  ), B = [0, 1]), {
@@ -12282,26 +12383,26 @@ function _A(g, { visible: A, color: I, contrastLimits: B, opacity: C }) {
12282
12383
  };
12283
12384
  }
12284
12385
  function sg(g, A) {
12285
- if (A.length > qB)
12286
- throw new Error(`Maximum number of channels is ${qB}`);
12386
+ if (A.length > lB)
12387
+ throw new Error(`Maximum number of channels is ${lB}`);
12287
12388
  return A.map((I) => _A(g, I));
12288
12389
  }
12289
- function hC(g, A) {
12390
+ function yC(g, A) {
12290
12391
  if (g && g.length !== A)
12291
12392
  throw new Error(
12292
12393
  `channelProps length (${g.length}) must match source channel count (${A}).`
12293
12394
  );
12294
12395
  }
12295
- function qi(g, A) {
12396
+ function fi(g, A) {
12296
12397
  if (g === void 0)
12297
- return tQ(A);
12398
+ return yQ(A);
12298
12399
  if (g[1] <= g[0])
12299
12400
  throw new Error(
12300
12401
  `Contrast limits must be strictly increasing: ${g}.`
12301
12402
  );
12302
12403
  return g;
12303
12404
  }
12304
- class tC extends mA {
12405
+ class eC extends mA {
12305
12406
  constructor(A, I, B, C) {
12306
12407
  super();
12307
12408
  const Q = [], E = [], i = B, o = C, a = i + 1, D = o + 1, s = A / i, h = I / o;
@@ -12332,11 +12433,16 @@ class tC extends mA {
12332
12433
  });
12333
12434
  }
12334
12435
  }
12335
- class li extends xA {
12436
+ class pi extends xA {
12336
12437
  channels_;
12337
12438
  worldToTexCoord = $();
12338
- constructor(A, I, B, C = []) {
12339
- super(), this.geometry = new tC(A, I, 1, 1), this.setTexture(0, B), this.channels_ = sg(B, C), this.programName = fi(B);
12439
+ constructor({
12440
+ width: A,
12441
+ height: I,
12442
+ texture: B,
12443
+ channelProps: C = []
12444
+ }) {
12445
+ super(), this.geometry = new eC(A, I, 1, 1), this.setTexture(0, B), this.channels_ = sg(B, C), this.programName = mi(B);
12340
12446
  }
12341
12447
  get type() {
12342
12448
  return "ImageRenderable";
@@ -12366,7 +12472,7 @@ class li extends xA {
12366
12472
  };
12367
12473
  }
12368
12474
  }
12369
- function fi(g) {
12475
+ function mi(g) {
12370
12476
  switch (g.dataType) {
12371
12477
  case "byte":
12372
12478
  case "int":
@@ -12403,7 +12509,7 @@ class aA {
12403
12509
  }
12404
12510
  }
12405
12511
  }
12406
- function yC(g, A, I, B, C = 3) {
12512
+ function nC(g, A, I, B, C = 3) {
12407
12513
  switch (g.type) {
12408
12514
  case "pointerdown": {
12409
12515
  const Q = g.event;
@@ -12412,7 +12518,7 @@ function yC(g, A, I, B, C = 3) {
12412
12518
  case "pointerup": {
12413
12519
  if (!A) return A;
12414
12520
  const Q = g.event, E = V(Q.clientX, Q.clientY);
12415
- if (QQ(A, E) < C) {
12521
+ if (EQ(A, E) < C) {
12416
12522
  if (!B) return null;
12417
12523
  const o = g.worldRay;
12418
12524
  return o && I(o).then((a) => {
@@ -12429,7 +12535,7 @@ function yC(g, A, I, B, C = 3) {
12429
12535
  return A;
12430
12536
  }
12431
12537
  }
12432
- class pg {
12538
+ class Tg {
12433
12539
  bins_ = /* @__PURE__ */ new Map();
12434
12540
  acquire(A) {
12435
12541
  const B = this.bins_.get(A)?.pop();
@@ -12444,7 +12550,7 @@ class pg {
12444
12550
  this.bins_.clear();
12445
12551
  }
12446
12552
  }
12447
- class eC extends KI {
12553
+ class GC extends KI {
12448
12554
  type = "ImageLayer";
12449
12555
  source_;
12450
12556
  sliceCoords_;
@@ -12453,7 +12559,8 @@ class eC extends KI {
12453
12559
  orientation_;
12454
12560
  onPickValue_;
12455
12561
  visibleChunks_ = /* @__PURE__ */ new Map();
12456
- pool_ = new pg();
12562
+ orderedChunks_ = [];
12563
+ pool_ = new Tg();
12457
12564
  initialChannelProps_;
12458
12565
  channelChangeCallbacks_ = [];
12459
12566
  policy_;
@@ -12480,22 +12587,20 @@ class eC extends KI {
12480
12587
  onPickValue: E,
12481
12588
  ...i
12482
12589
  }) {
12483
- super(i), this.setState("initialized"), this.source_ = A, this.policy_ = B, this.sliceCoords_ = I, this.orientation_ = C ?? "XY", this.axes_ = MA(this.orientation_), this.planeRotation_ = dA(this.axes_), this.channelProps_ = Q, this.initialChannelProps_ = Q, this.onPickValue_ = E;
12590
+ super({ blendMode: "additive", ...i }), this.setState("initialized"), this.source_ = A, this.policy_ = B ?? mg(), this.sliceCoords_ = I, this.orientation_ = C ?? "XY", this.axes_ = MA(this.orientation_), this.planeRotation_ = dA(this.axes_), this.channelProps_ = Q, this.initialChannelProps_ = Q, this.onPickValue_ = E;
12484
12591
  }
12485
12592
  attach(A) {
12486
12593
  this.context_ = A, this.chunkStoreView_ = A.chunkManager.addView(
12487
12594
  this.source_,
12488
12595
  this.policy_,
12489
12596
  this.axes_
12597
+ ), yC(
12598
+ this.channelProps_,
12599
+ this.chunkStoreView_.channelCount
12490
12600
  );
12491
- const I = this.chunkStoreView_.channelCount;
12492
- if (hC(this.channelProps_, I), I > 1 && this.sliceCoords_.c !== void 0 && this.sliceCoords_.c.length > 1)
12493
- throw new Error(
12494
- `ImageLayer requires exactly one channel in sliceCoords.c for multi-channel sources (found ${I} channels). Use one layer per channel.`
12495
- );
12496
12601
  }
12497
12602
  detach(A) {
12498
- this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0, this.context_ = void 0;
12603
+ this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.orderedChunks_ = [], this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0, this.context_ = void 0;
12499
12604
  }
12500
12605
  update(A) {
12501
12606
  if (!A || !this.chunkStoreView_) return;
@@ -12515,7 +12620,7 @@ class eC extends KI {
12515
12620
  * for the new plane, chunks already resident in the shared cache are reused.
12516
12621
  */
12517
12622
  setOrientation(A) {
12518
- A !== this.orientation_ && (this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_?.dispose(), this.lastPresentationTimeStamp_ = void 0, this.lastPresentationTimeCoord_ = void 0, this.orientation_ = A, this.axes_ = MA(A), this.planeRotation_ = dA(this.axes_), this.context_ && (this.chunkStoreView_ = this.context_.chunkManager.addView(
12623
+ A !== this.orientation_ && (this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.orderedChunks_ = [], this.clearObjects(), this.chunkStoreView_?.dispose(), this.lastPresentationTimeStamp_ = void 0, this.lastPresentationTimeCoord_ = void 0, this.orientation_ = A, this.axes_ = MA(A), this.planeRotation_ = dA(this.axes_), this.context_ && (this.chunkStoreView_ = this.context_.chunkManager.addView(
12519
12624
  this.source_,
12520
12625
  this.policy_,
12521
12626
  this.axes_
@@ -12533,23 +12638,29 @@ class eC extends KI {
12533
12638
  const I = this.chunkStoreView_.getChunksToRender(), B = new Set(I), C = Array.from(this.visibleChunks_.keys()).filter(
12534
12639
  (Q) => !B.has(Q)
12535
12640
  );
12536
- this.releaseAndRemoveChunks(C), this.clearObjects();
12537
- for (const Q of I) {
12538
- const E = this.getImageForChunk(Q, Q.texture);
12539
- this.visibleChunks_.set(Q, E), this.addObject(E);
12540
- }
12641
+ this.releaseAndRemoveChunks(C);
12642
+ for (const Q of I)
12643
+ this.visibleChunks_.set(
12644
+ Q,
12645
+ this.getImageForChunk(Q, Q.texture)
12646
+ );
12647
+ this.orderedChunks_ = I, this.rebuildRenderGroups();
12541
12648
  }
12542
- hasMultipleLODs() {
12543
- return this.chunkStoreView_ ? this.chunkStoreView_.lodCount > 1 : !1;
12649
+ rebuildRenderGroups() {
12650
+ this.clearObjects();
12651
+ for (const A of this.orderedChunks_) {
12652
+ const I = this.visibleChunks_.get(A), B = A.chunkIndex.c;
12653
+ I === void 0 || this.channelProps_?.[B]?.visible === !1 || this.addObject(I, B);
12654
+ }
12544
12655
  }
12545
12656
  get lastPresentationTimeCoord() {
12546
12657
  return this.lastPresentationTimeCoord_;
12547
12658
  }
12548
12659
  isPresentationStale() {
12549
- return this.lastPresentationTimeStamp_ === void 0 ? !1 : performance.now() - this.lastPresentationTimeStamp_ > eC.STALE_PRESENTATION_MS_;
12660
+ return this.lastPresentationTimeStamp_ === void 0 ? !1 : performance.now() - this.lastPresentationTimeStamp_ > GC.STALE_PRESENTATION_MS_;
12550
12661
  }
12551
12662
  onEvent(A) {
12552
- this.pointerDownPos_ = yC(
12663
+ this.pointerDownPos_ = nC(
12553
12664
  A,
12554
12665
  this.pointerDownPos_,
12555
12666
  (I) => this.pickAtRay(I),
@@ -12559,7 +12670,7 @@ class eC extends KI {
12559
12670
  async pickAtRay(A) {
12560
12671
  const I = this.visibleChunks_.values().next();
12561
12672
  if (I.done) return null;
12562
- const B = I.value.transform, C = VB(
12673
+ const B = I.value.transform, C = vB(
12563
12674
  d(),
12564
12675
  p(0, 0, 1),
12565
12676
  B.rotation
@@ -12599,12 +12710,12 @@ class eC extends KI {
12599
12710
  return this.channelProps_ ? [this.channelProps_[A.chunkIndex.c] ?? {}] : [{}];
12600
12711
  }
12601
12712
  createImage(A, I) {
12602
- const B = new li(
12603
- A.shape[this.axes_.u],
12604
- A.shape[this.axes_.v],
12605
- I,
12606
- this.getChannelPropsForChunk(A)
12607
- );
12713
+ const B = new pi({
12714
+ width: A.shape[this.axes_.u],
12715
+ height: A.shape[this.axes_.v],
12716
+ texture: I,
12717
+ channelProps: this.getChannelPropsForChunk(A)
12718
+ });
12608
12719
  return this.updateImageChunk(B, A), B;
12609
12720
  }
12610
12721
  updateSlicePosition(A, I) {
@@ -12621,7 +12732,7 @@ class eC extends KI {
12621
12732
  updateImageChunk(A, I) {
12622
12733
  this.debugMode_ ? (A.wireframeEnabled = !0, A.wireframeColor = this.wireframeColors_[I.lod % this.wireframeColors_.length]) : A.wireframeEnabled = !1;
12623
12734
  const { u: B, v: C } = this.axes_;
12624
- A.transform.setScale([I.scale[B], I.scale[C], 1]), A.transform.setRotation(this.planeRotation_), this.updateSlicePosition(A, I), A.worldToTexCoord = XB(I, this.axes_);
12735
+ A.transform.setScale([I.scale[B], I.scale[C], 1]), A.transform.setRotation(this.planeRotation_), this.updateSlicePosition(A, I), A.worldToTexCoord = jB(I, this.axes_);
12625
12736
  }
12626
12737
  async getValueAtWorld(A) {
12627
12738
  const I = this.chunkStoreView_?.currentLOD ?? 0;
@@ -12658,7 +12769,7 @@ class eC extends KI {
12658
12769
  setChannelProps(A) {
12659
12770
  this.channelProps_ = A, this.visibleChunks_.forEach((I, B) => {
12660
12771
  I.setChannelProps(this.getChannelPropsForChunk(B));
12661
- }), this.channelChangeCallbacks_.forEach((I) => {
12772
+ }), this.rebuildRenderGroups(), this.channelChangeCallbacks_.forEach((I) => {
12662
12773
  I();
12663
12774
  });
12664
12775
  }
@@ -12689,7 +12800,7 @@ function kI(g, A) {
12689
12800
  `align${g.rowAlignmentBytes}`
12690
12801
  ].join(":");
12691
12802
  }
12692
- class pi extends mA {
12803
+ class ui extends mA {
12693
12804
  constructor(A, I, B, C, Q, E) {
12694
12805
  super();
12695
12806
  const i = [], o = [], a = Math.floor(C), D = Math.floor(Q), s = Math.floor(E);
@@ -12736,13 +12847,13 @@ class pi extends mA {
12736
12847
  }
12737
12848
  }
12738
12849
  }
12739
- class mi extends xA {
12850
+ class Ti extends xA {
12740
12851
  voxelScale = p(1, 1, 1);
12741
12852
  channels_;
12742
12853
  loadedChannels_ = /* @__PURE__ */ new Set();
12743
12854
  channelToTextureIndex_ = /* @__PURE__ */ new Map();
12744
- constructor() {
12745
- super(), this.geometry = new pi(1, 1, 1, 1, 1, 1), this.cullFaceMode = "front", this.depthTest = !1, this.channels_ = [];
12855
+ constructor({ channelProps: A = [] } = {}) {
12856
+ super(), this.geometry = new ui(1, 1, 1, 1, 1, 1), this.cullFaceMode = "front", this.depthTest = !1, this.channels_ = [], this.setChannelProps(A);
12746
12857
  }
12747
12858
  get type() {
12748
12859
  return "VolumeRenderable";
@@ -12755,7 +12866,7 @@ class mi extends xA {
12755
12866
  addChannelTexture(A, I) {
12756
12867
  const B = this.textures.length;
12757
12868
  this.setTexture(B, I), this.channelToTextureIndex_.set(A, B);
12758
- const C = ui(I.dataType);
12869
+ const C = xi(I.dataType);
12759
12870
  if (this.programName && this.programName !== C)
12760
12871
  throw new Error(
12761
12872
  `Volume renderable does not support multiple channels with different data types. Existing program: ${this.programName}, new channel data type: ${I.dataType} and program: ${C}`
@@ -12841,7 +12952,7 @@ class mi extends xA {
12841
12952
  this.channels_[A] = C;
12842
12953
  }
12843
12954
  }
12844
- function ui(g) {
12955
+ function xi(g) {
12845
12956
  switch (g) {
12846
12957
  case "byte":
12847
12958
  case "int":
@@ -12855,22 +12966,22 @@ function ui(g) {
12855
12966
  return "floatVolume";
12856
12967
  }
12857
12968
  }
12858
- function Ti(g, A) {
12969
+ function Wi(g, A) {
12859
12970
  const I = A.position, B = d(), C = d();
12860
12971
  return g.sort((Q, E) => {
12861
12972
  JA(B, Q.boundingBox.max, Q.boundingBox.min), vA(B, B, 0.5), JA(C, E.boundingBox.max, E.boundingBox.min), vA(C, C, 0.5);
12862
- const i = Og(I, B), o = Og(I, C);
12973
+ const i = Vg(I, B), o = Vg(I, C);
12863
12974
  return i - o;
12864
12975
  }), g;
12865
12976
  }
12866
- const xi = 2;
12867
- class Fo extends KI {
12977
+ const bi = 2;
12978
+ class Ro extends KI {
12868
12979
  type = "VolumeLayer";
12869
12980
  source_;
12870
12981
  sliceCoords_;
12871
12982
  currentVolumes_ = /* @__PURE__ */ new Map();
12872
12983
  volumeToPoolKey_ = /* @__PURE__ */ new Map();
12873
- pool_ = new pg();
12984
+ pool_ = new Tg();
12874
12985
  initialChannelProps_;
12875
12986
  channelChangeCallbacks_ = [];
12876
12987
  policy_;
@@ -12925,7 +13036,7 @@ class Fo extends KI {
12925
13036
  this.channelChangeCallbacks_.splice(I, 1);
12926
13037
  }
12927
13038
  constructor({ source: A, sliceCoords: I, policy: B, channelProps: C }) {
12928
- super({ blendMode: "premultiplied" }), this.source_ = A, this.sliceCoords_ = I, this.policy_ = B, this.initialChannelProps_ = C, this.channelProps_ = C, this.setState("initialized");
13039
+ super({ blendMode: "premultiplied" }), this.source_ = A, this.sliceCoords_ = I, this.policy_ = B ?? mg(), this.initialChannelProps_ = C, this.channelProps_ = C, this.setState("initialized");
12929
13040
  }
12930
13041
  getOrCreateVolume(A, I) {
12931
13042
  const B = this.currentVolumes_.get(A);
@@ -12933,7 +13044,7 @@ class Fo extends KI {
12933
13044
  for (const E of I) B.updateVolumeWithChunk(E);
12934
13045
  return B;
12935
13046
  }
12936
- const C = Zi(I[0]), Q = this.pool_.acquire(C) ?? new mi();
13047
+ const C = Oi(I[0]), Q = this.pool_.acquire(C) ?? new Ti();
12937
13048
  Q.setChannelProps(this.channelProps_ ?? []), this.volumeToPoolKey_.set(Q, C);
12938
13049
  for (const E of I) Q.updateVolumeWithChunk(E);
12939
13050
  return this.updateVolumeTransform(Q, I[0]), Q;
@@ -12942,7 +13053,7 @@ class Fo extends KI {
12942
13053
  this.chunkStoreView_ = A.chunkManager.addView(
12943
13054
  this.source_,
12944
13055
  this.policy_
12945
- ), hC(
13056
+ ), yC(
12946
13057
  this.channelProps_,
12947
13058
  this.chunkStoreView_.channelCount
12948
13059
  );
@@ -12950,19 +13061,18 @@ class Fo extends KI {
12950
13061
  detach(A) {
12951
13062
  for (const I of this.currentVolumes_.values())
12952
13063
  this.releaseAndRemoveVolume(I);
12953
- this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0;
13064
+ this.currentVolumes_.clear(), this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0;
12954
13065
  }
12955
13066
  updateChunks() {
12956
13067
  if (!this.chunkStoreView_) return;
12957
13068
  this.state !== "ready" && this.setState("ready");
12958
- const A = this.chunkStoreView_.getChunksToRender(), I = this.sliceCoords_.t ?? -1, B = bi(A);
13069
+ const A = this.chunkStoreView_.getChunksToRender(), I = this.sliceCoords_.t ?? -1, B = Pi(A);
12959
13070
  if (this.lastLoadedTime_ !== I || B.size !== this.currentVolumes_.size || this.lastNumRenderedChannelChunks_ !== A.length) {
12960
13071
  for (const [Q, E] of this.currentVolumes_)
12961
13072
  B.has(Q) || (this.releaseAndRemoveVolume(E), this.currentVolumes_.delete(Q));
12962
- this.clearObjects();
12963
13073
  for (const [Q, E] of B) {
12964
13074
  const i = this.getOrCreateVolume(Q, E);
12965
- i.wireframeEnabled = this.debugShowWireframes, this.currentVolumes_.set(Q, i), this.addObject(i);
13075
+ i.wireframeEnabled = this.debugShowWireframes, this.currentVolumes_.set(Q, i);
12966
13076
  }
12967
13077
  this.lastLoadedTime_ = I, this.lastNumRenderedChannelChunks_ = A.length;
12968
13078
  }
@@ -12995,7 +13105,13 @@ class Fo extends KI {
12995
13105
  A.camera.getViewProjection()
12996
13106
  );
12997
13107
  const I = A.cameraControls?.isMoving ?? !1;
12998
- this.interactiveStepSizeScale_ = I ? xi : 1, this.updateChunks(), Ti(this.objects, A.camera);
13108
+ this.interactiveStepSizeScale_ = I ? bi : 1, this.updateChunks(), this.rebuildObjects(A.camera);
13109
+ }
13110
+ rebuildObjects(A) {
13111
+ const I = Array.from(this.currentVolumes_.values());
13112
+ Wi(I, A), this.clearObjects();
13113
+ for (const B of I)
13114
+ this.addObject(B);
12999
13115
  }
13000
13116
  getUniforms() {
13001
13117
  return {
@@ -13006,27 +13122,27 @@ class Fo extends KI {
13006
13122
  };
13007
13123
  }
13008
13124
  }
13009
- function Wi(g) {
13125
+ function Zi(g) {
13010
13126
  const { x: A, y: I, z: B, t: C } = g.chunkIndex;
13011
13127
  return `${A}:${I}:${B}:${C}`;
13012
13128
  }
13013
- function bi(g) {
13129
+ function Pi(g) {
13014
13130
  const A = /* @__PURE__ */ new Map();
13015
13131
  for (const I of g) {
13016
- const B = Wi(I);
13132
+ const B = Zi(I);
13017
13133
  let C = A.get(B);
13018
13134
  C || (C = [], A.set(B, C)), C.push(I);
13019
13135
  }
13020
13136
  return A;
13021
13137
  }
13022
- function Zi(g) {
13138
+ function Oi(g) {
13023
13139
  return [
13024
13140
  `lod${g.lod}`,
13025
13141
  `shape${g.shape.x}x${g.shape.y}x${g.shape.z}`,
13026
13142
  `align${g.rowAlignmentBytes}`
13027
13143
  ].join(":");
13028
13144
  }
13029
- class lB extends Fg {
13145
+ class fB extends Fg {
13030
13146
  width_;
13031
13147
  height_;
13032
13148
  constructor(A, I, B) {
@@ -13042,7 +13158,7 @@ class lB extends Fg {
13042
13158
  return this.height_;
13043
13159
  }
13044
13160
  }
13045
- const Pi = [
13161
+ const Vi = [
13046
13162
  [1, 0.5, 0.5],
13047
13163
  [0.5, 1, 0.5],
13048
13164
  [0.5, 0.5, 1],
@@ -13050,7 +13166,7 @@ const Pi = [
13050
13166
  [1, 0.5, 1],
13051
13167
  [1, 1, 0.5]
13052
13168
  ];
13053
- function Oi(g) {
13169
+ function vi(g) {
13054
13170
  return g = g ?? /* @__PURE__ */ new Map(), new Map(
13055
13171
  Array.from(g.entries()).map(([A, I]) => [
13056
13172
  A,
@@ -13058,47 +13174,47 @@ function Oi(g) {
13058
13174
  ])
13059
13175
  );
13060
13176
  }
13061
- function Vi(g) {
13062
- return g = g ?? Pi, g.map(x.from);
13177
+ function Xi(g) {
13178
+ return g = g ?? Vi, g.map(x.from);
13063
13179
  }
13064
- class fB {
13180
+ class pB {
13065
13181
  lookupTable;
13066
13182
  cycle;
13067
13183
  constructor(A = {}) {
13068
- this.lookupTable = Oi(A.lookupTable), this.cycle = Vi(A.cycle);
13184
+ this.lookupTable = vi(A.lookupTable), this.cycle = Xi(A.cycle);
13069
13185
  }
13070
13186
  }
13071
- const nC = /* @__PURE__ */ new Set(["byte", "short", "int"]), vi = /* @__PURE__ */ new Set([
13187
+ const wC = /* @__PURE__ */ new Set(["byte", "short", "int"]), ji = /* @__PURE__ */ new Set([
13072
13188
  "unsigned_byte",
13073
13189
  "unsigned_short",
13074
13190
  "unsigned_int"
13075
13191
  ]);
13076
- function Xi(g) {
13192
+ function zi(g) {
13077
13193
  if (g.dataFormat !== "scalar")
13078
13194
  throw new Error(
13079
13195
  `Image data format must be scalar, instead found: ${g.dataFormat}`
13080
13196
  );
13081
- if (!nC.has(g.dataType) && !vi.has(g.dataType))
13197
+ if (!wC.has(g.dataType) && !ji.has(g.dataType))
13082
13198
  throw new Error(
13083
13199
  `Image data type must be an integer, instead found: ${g.dataType}`
13084
13200
  );
13085
13201
  return g;
13086
13202
  }
13087
- function ji(g) {
13088
- return nC.has(g.dataType) ? "intLabelImage" : "labelImage";
13203
+ function _i(g) {
13204
+ return wC.has(g.dataType) ? "intLabelImage" : "labelImage";
13089
13205
  }
13090
- class zi extends xA {
13206
+ class $i extends xA {
13091
13207
  outlineSelected_;
13092
13208
  selectedValue_;
13093
13209
  worldToTexCoord = $();
13094
13210
  constructor(A) {
13095
- super(), this.geometry = new tC(A.width, A.height, 1, 1), this.setTexture(0, Xi(A.imageData));
13211
+ super(), this.geometry = new eC(A.width, A.height, 1, 1), this.setTexture(0, zi(A.imageData));
13096
13212
  const I = this.makeColorCycleTexture(A.colorMap.cycle);
13097
13213
  this.setTexture(1, I);
13098
13214
  const B = this.makeColorLookupTableTexture(
13099
13215
  A.colorMap.lookupTable
13100
13216
  );
13101
- this.setTexture(2, B), this.outlineSelected_ = A.outlineSelected ?? !1, this.selectedValue_ = A.selectedValue ?? null, this.programName = ji(A.imageData);
13217
+ this.setTexture(2, B), this.outlineSelected_ = A.outlineSelected ?? !1, this.selectedValue_ = A.selectedValue ?? null, this.programName = _i(A.imageData);
13102
13218
  }
13103
13219
  get type() {
13104
13220
  return "LabelImageRenderable";
@@ -13122,16 +13238,16 @@ class zi extends xA {
13122
13238
  makeColorCycleTexture(A) {
13123
13239
  const I = new Uint8Array(
13124
13240
  A.flatMap((C) => C.rgba).map((C) => Math.round(C * 255))
13125
- ), B = new lB(I, A.length, 1);
13241
+ ), B = new fB(I, A.length, 1);
13126
13242
  return B.dataFormat = "rgba", B;
13127
13243
  }
13128
13244
  makeColorLookupTableTexture(A) {
13129
13245
  A === void 0 ? A = /* @__PURE__ */ new Map([[0, x.TRANSPARENT]]) : A.has(0) || (A = new Map([[0, x.TRANSPARENT], ...A]));
13130
13246
  const I = Array.from(A.keys()), B = Array.from(A.values()).map((E) => E.packed), C = A.size, Q = new Uint32Array(C * 2);
13131
- return Q.set(I, 0), Q.set(B, C), new lB(Q, C, 2);
13247
+ return Q.set(I, 0), Q.set(B, C), new fB(Q, C, 2);
13132
13248
  }
13133
13249
  }
13134
- class GC extends KI {
13250
+ class FC extends KI {
13135
13251
  type = "LabelLayer";
13136
13252
  source_;
13137
13253
  sliceCoords_;
@@ -13141,7 +13257,7 @@ class GC extends KI {
13141
13257
  onPickValue_;
13142
13258
  outlineSelected_;
13143
13259
  visibleChunks_ = /* @__PURE__ */ new Map();
13144
- pool_ = new pg();
13260
+ pool_ = new Tg();
13145
13261
  colorMap_;
13146
13262
  selectedValue_ = null;
13147
13263
  policy_;
@@ -13161,7 +13277,7 @@ class GC extends KI {
13161
13277
  outlineSelected: i = !1,
13162
13278
  ...o
13163
13279
  }) {
13164
- super(o), this.setState("initialized"), this.source_ = A, this.policy_ = B, this.sliceCoords_ = I, this.orientation_ = C ?? "XY", this.axes_ = MA(this.orientation_), this.planeRotation_ = dA(this.axes_), this.colorMap_ = new fB(Q), this.onPickValue_ = E, this.outlineSelected_ = i;
13280
+ super(o), this.setState("initialized"), this.source_ = A, this.policy_ = B ?? mg(), this.sliceCoords_ = I, this.orientation_ = C ?? "XY", this.axes_ = MA(this.orientation_), this.planeRotation_ = dA(this.axes_), this.colorMap_ = new pB(Q), this.onPickValue_ = E, this.outlineSelected_ = i;
13165
13281
  }
13166
13282
  attach(A) {
13167
13283
  if (this.context_ = A, this.chunkStoreView_ = A.chunkManager.addView(
@@ -13215,17 +13331,14 @@ class GC extends KI {
13215
13331
  this.releaseAndRemoveChunks(C), this.clearObjects();
13216
13332
  for (const Q of I) {
13217
13333
  const E = this.getLabelForChunk(Q, Q.texture);
13218
- this.visibleChunks_.set(Q, E), this.addObject(E);
13334
+ this.visibleChunks_.set(Q, E), this.addObject(E, 0);
13219
13335
  }
13220
13336
  }
13221
- hasMultipleLODs() {
13222
- return this.chunkStoreView_ ? this.chunkStoreView_.lodCount > 1 : !1;
13223
- }
13224
13337
  isPresentationStale() {
13225
- return this.lastPresentationTimeStamp_ === void 0 ? !1 : performance.now() - this.lastPresentationTimeStamp_ > GC.STALE_PRESENTATION_MS_;
13338
+ return this.lastPresentationTimeStamp_ === void 0 ? !1 : performance.now() - this.lastPresentationTimeStamp_ > FC.STALE_PRESENTATION_MS_;
13226
13339
  }
13227
13340
  onEvent(A) {
13228
- this.pointerDownPos_ = yC(
13341
+ this.pointerDownPos_ = nC(
13229
13342
  A,
13230
13343
  this.pointerDownPos_,
13231
13344
  (I) => this.pickAtRay(I),
@@ -13237,7 +13350,7 @@ class GC extends KI {
13237
13350
  async pickAtRay(A) {
13238
13351
  const I = this.visibleChunks_.values().next();
13239
13352
  if (I.done) return null;
13240
- const B = I.value.transform, C = VB(
13353
+ const B = I.value.transform, C = vB(
13241
13354
  d(),
13242
13355
  p(0, 0, 1),
13243
13356
  B.rotation
@@ -13250,7 +13363,7 @@ class GC extends KI {
13250
13363
  return this.colorMap_;
13251
13364
  }
13252
13365
  setColorMap(A) {
13253
- this.colorMap_ = new fB(A), this.visibleChunks_.forEach((I) => {
13366
+ this.colorMap_ = new pB(A), this.visibleChunks_.forEach((I) => {
13254
13367
  I.setColorMap(this.colorMap_);
13255
13368
  });
13256
13369
  }
@@ -13311,7 +13424,7 @@ class GC extends KI {
13311
13424
  return C ? (C.setTexture(0, I), C.setColorMap(this.colorMap_), C.setSelectedValue(this.selectedValue_), this.updateLabelChunk(C, A), C) : this.createLabel(A, I);
13312
13425
  }
13313
13426
  createLabel(A, I) {
13314
- const B = new zi({
13427
+ const B = new $i({
13315
13428
  width: A.shape[this.axes_.u],
13316
13429
  height: A.shape[this.axes_.v],
13317
13430
  imageData: I,
@@ -13334,7 +13447,7 @@ class GC extends KI {
13334
13447
  }
13335
13448
  updateLabelChunk(A, I) {
13336
13449
  const { u: B, v: C } = this.axes_;
13337
- A.transform.setScale([I.scale[B], I.scale[C], 1]), A.transform.setRotation(this.planeRotation_), this.updateSlicePosition(A, I), A.worldToTexCoord = XB(I, this.axes_);
13450
+ A.transform.setScale([I.scale[B], I.scale[C], 1]), A.transform.setRotation(this.planeRotation_), this.updateSlicePosition(A, I), A.worldToTexCoord = jB(I, this.axes_);
13338
13451
  }
13339
13452
  releaseAndRemoveChunks(A) {
13340
13453
  for (const I of A) {
@@ -13343,7 +13456,7 @@ class GC extends KI {
13343
13456
  }
13344
13457
  }
13345
13458
  }
13346
- class _i extends Fg {
13459
+ class Ao extends Fg {
13347
13460
  width_;
13348
13461
  height_;
13349
13462
  depth_;
@@ -13363,12 +13476,12 @@ class _i extends Fg {
13363
13476
  return this.depth_;
13364
13477
  }
13365
13478
  }
13366
- const wC = {
13479
+ const rC = {
13367
13480
  circle: 0,
13368
13481
  square: 1,
13369
13482
  triangle: 2
13370
13483
  };
13371
- class ro extends xA {
13484
+ class No extends xA {
13372
13485
  constructor(A) {
13373
13486
  super(), this.programName = "points";
13374
13487
  const I = A.flatMap((C) => {
@@ -13382,7 +13495,7 @@ class ro extends xA {
13382
13495
  Q.b,
13383
13496
  Q.a,
13384
13497
  C.size,
13385
- wC[C.marker]
13498
+ rC[C.marker]
13386
13499
  ];
13387
13500
  }), B = new mA(I, [], "points");
13388
13501
  B.addAttribute({
@@ -13401,17 +13514,17 @@ class ro extends xA {
13401
13514
  type: "marker",
13402
13515
  itemSize: 1,
13403
13516
  offset: B.strideBytes
13404
- }), this.geometry = B, this.setTexture(0, $i());
13517
+ }), this.geometry = B, this.setTexture(0, Io());
13405
13518
  }
13406
13519
  get type() {
13407
13520
  return "PointsRenderable";
13408
13521
  }
13409
13522
  }
13410
13523
  let PI;
13411
- function $i() {
13412
- return PI || (PI = Ao()), PI;
13524
+ function Io() {
13525
+ return PI || (PI = go()), PI;
13413
13526
  }
13414
- function Ao() {
13527
+ function go() {
13415
13528
  const g = (a) => {
13416
13529
  const D = new Float32Array(a * a);
13417
13530
  return D.fill(1), D;
@@ -13433,11 +13546,11 @@ function Ao() {
13433
13546
  triangle: I(256)
13434
13547
  }, E = Object.keys(Q).length, i = new Float32Array(E * 65536);
13435
13548
  for (const [a, D] of Object.entries(Q))
13436
- i.set(D, wC[a] * 65536);
13437
- const o = new _i(i, 256, 256);
13549
+ i.set(D, rC[a] * 65536);
13550
+ const o = new Ao(i, 256, 256);
13438
13551
  return o.wrapR = "clamp_to_edge", o.wrapS = "clamp_to_edge", o.wrapT = "clamp_to_edge", o;
13439
13552
  }
13440
- class pB {
13553
+ class mB {
13441
13554
  radius;
13442
13555
  phi;
13443
13556
  theta;
@@ -13453,22 +13566,22 @@ class pB {
13453
13566
  );
13454
13567
  }
13455
13568
  }
13456
- const OI = -1, mB = 0, Io = 1, uB = 9e-3, go = 1e-3, Bo = 9e-4, Co = 0.5, Qo = 60;
13457
- class So {
13569
+ const OI = -1, uB = 0, Bo = 1, TB = 9e-3, Co = 1e-3, Qo = 9e-4, Eo = 0.5, io = 60;
13570
+ class co {
13458
13571
  camera_;
13459
- orbitVelocity_ = new pB(0, 0, 0);
13572
+ orbitVelocity_ = new mB(0, 0, 0);
13460
13573
  panVelocity_ = d();
13461
13574
  currPos_;
13462
13575
  currCenter_ = d();
13463
13576
  dampingFactor_;
13464
13577
  currMouseButton_ = OI;
13465
13578
  constructor(A, I) {
13466
- this.camera_ = A, this.currPos_ = new pB(
13579
+ this.camera_ = A, this.currPos_ = new mB(
13467
13580
  I?.radius ?? 1,
13468
13581
  I?.yaw ?? 0,
13469
13582
  I?.pitch ?? 0
13470
13583
  ), I?.target && XI(this.currCenter_, I.target), this.dampingFactor_ = hA(
13471
- I?.dampingFactor ?? Co,
13584
+ I?.dampingFactor ?? Eo,
13472
13585
  0,
13473
13586
  1
13474
13587
  ), this.updateCamera();
@@ -13499,7 +13612,7 @@ class So {
13499
13612
  this.currPos_.phi += this.orbitVelocity_.phi, this.currPos_.theta += this.orbitVelocity_.theta, this.currPos_.radius += this.orbitVelocity_.radius * this.currPos_.radius, JA(this.currCenter_, this.currCenter_, this.panVelocity_);
13500
13613
  const I = Math.PI / 2 - T;
13501
13614
  this.currPos_.theta = hA(this.currPos_.theta, -I, I), this.currPos_.radius = Math.max(0.01, this.currPos_.radius), this.updateCamera();
13502
- const B = Math.pow(1 - this.dampingFactor_, A * Qo);
13615
+ const B = Math.pow(1 - this.dampingFactor_, A * io);
13503
13616
  this.orbitVelocity_.phi *= B, this.orbitVelocity_.theta *= B, this.orbitVelocity_.radius *= B, vA(this.panVelocity_, this.panVelocity_, B), this.cutoffLowVelocity();
13504
13617
  }
13505
13618
  onPointerDown(A) {
@@ -13508,7 +13621,7 @@ class So {
13508
13621
  }
13509
13622
  onPointerMove(A) {
13510
13623
  if (this.currMouseButton_ == OI) return;
13511
- const I = A.event, B = I.movementX ?? 0, C = I.movementY ?? 0, Q = this.currMouseButton_ === mB && !I.shiftKey, E = this.currMouseButton_ === mB && I.shiftKey || this.currMouseButton_ === Io;
13624
+ const I = A.event, B = I.movementX ?? 0, C = I.movementY ?? 0, Q = this.currMouseButton_ === uB && !I.shiftKey, E = this.currMouseButton_ === uB && I.shiftKey || this.currMouseButton_ === Bo;
13512
13625
  Q && this.orbit(B, C), E && this.pan(B, C);
13513
13626
  }
13514
13627
  onWheel(A) {
@@ -13523,24 +13636,24 @@ class So {
13523
13636
  I.target?.releasePointerCapture?.(I.pointerId);
13524
13637
  }
13525
13638
  orbit(A, I) {
13526
- this.orbitVelocity_.phi -= A * uB, this.orbitVelocity_.theta += I * uB;
13639
+ this.orbitVelocity_.phi -= A * TB, this.orbitVelocity_.theta += I * TB;
13527
13640
  }
13528
13641
  pan(A, I) {
13529
- const B = this.currPos_.radius * go, C = d();
13642
+ const B = this.currPos_.radius * Co, C = d();
13530
13643
  jI(C, C, this.camera_.right, A), jI(C, C, this.camera_.up, I), vA(C, C, B), zI(this.panVelocity_, this.panVelocity_, C);
13531
13644
  }
13532
13645
  zoom(A) {
13533
- this.orbitVelocity_.radius += A * Bo;
13646
+ this.orbitVelocity_.radius += A * Qo;
13534
13647
  }
13535
13648
  updateCamera() {
13536
13649
  const A = JA(d(), this.currCenter_, this.currPos_.toVec3());
13537
13650
  this.camera_.transform.setTranslation(A), this.camera_.transform.targetTo(this.currCenter_);
13538
13651
  }
13539
13652
  cutoffLowVelocity() {
13540
- Math.abs(this.orbitVelocity_.phi) < T && (this.orbitVelocity_.phi = 0), Math.abs(this.orbitVelocity_.theta) < T && (this.orbitVelocity_.theta = 0), Math.abs(this.orbitVelocity_.radius) < T && (this.orbitVelocity_.radius = 0), tg(this.panVelocity_) < T && XC(this.panVelocity_);
13653
+ Math.abs(this.orbitVelocity_.phi) < T && (this.orbitVelocity_.phi = 0), Math.abs(this.orbitVelocity_.theta) < T && (this.orbitVelocity_.theta = 0), Math.abs(this.orbitVelocity_.radius) < T && (this.orbitVelocity_.radius = 0), tg(this.panVelocity_) < T && jC(this.panVelocity_);
13541
13654
  }
13542
13655
  }
13543
- class Eo {
13656
+ class oo {
13544
13657
  planes_;
13545
13658
  constructor(A) {
13546
13659
  this.planes_ = [
@@ -13586,7 +13699,7 @@ class Eo {
13586
13699
  return !0;
13587
13700
  }
13588
13701
  }
13589
- class FC extends xA {
13702
+ class SC extends xA {
13590
13703
  projectionMatrix_ = $();
13591
13704
  near_ = 0;
13592
13705
  far_ = 0;
@@ -13611,7 +13724,7 @@ class FC extends xA {
13611
13724
  return vI($(), this.projectionMatrix, this.viewMatrix);
13612
13725
  }
13613
13726
  get frustum() {
13614
- return new Eo(this.getViewProjection());
13727
+ return new oo(this.getViewProjection());
13615
13728
  }
13616
13729
  pan(A) {
13617
13730
  this.transform.addTranslation(A);
@@ -13628,7 +13741,7 @@ class FC extends xA {
13628
13741
  I,
13629
13742
  B
13630
13743
  );
13631
- $C(C, C, 1 / C[3]);
13744
+ AQ(C, C, 1 / C[3]);
13632
13745
  const Q = XA(
13633
13746
  YA(),
13634
13747
  C,
@@ -13637,28 +13750,25 @@ class FC extends xA {
13637
13750
  return p(Q[0], Q[1], Q[2]);
13638
13751
  }
13639
13752
  }
13640
- const rC = 1.77, TB = 128, xB = 128 / rC, io = -1e6, oo = 1e6;
13641
- class Ro extends FC {
13753
+ const RC = 1.77, xB = 128, WB = 128 / RC, ao = -1e6, Do = 1e6;
13754
+ class Uo extends SC {
13642
13755
  // width_ and height_ should always be defined by constructor (see setFrame)
13643
- width_ = TB;
13644
- height_ = xB;
13645
- viewportAspectRatio_ = rC;
13646
- viewportSize_ = [TB, xB];
13756
+ width_ = xB;
13757
+ height_ = WB;
13758
+ viewportAspectRatio_ = RC;
13759
+ viewportSize_ = [xB, WB];
13647
13760
  axes_;
13648
13761
  rotation_;
13649
13762
  orientation_;
13650
13763
  /**
13651
13764
  * Creates an orthographic camera framing the given world-space rectangle.
13652
13765
  *
13653
- * @param left - Left edge of the view frame, in world units.
13654
- * @param right - Right edge of the view frame, in world units.
13655
- * @param top - Top edge of the view frame, in world units.
13656
- * @param bottom - Bottom edge of the view frame, in world units.
13657
- * @param options - Near/far clipping plane distances (default `-1e6` and
13658
- * `1e6`) and the slice orientation the camera faces (default `"XY"`).
13766
+ * @param props - The view frame edges in world units, near/far clipping
13767
+ * plane distances (default `-1e6` and `1e6`), and the slice orientation
13768
+ * the camera faces (default `"XY"`).
13659
13769
  */
13660
- constructor(A, I, B, C, Q = {}) {
13661
- super(), this.near_ = Q.near ?? io, this.far_ = Q.far ?? oo, this.orientation_ = Q.orientation ?? "XY", this.axes_ = MA(this.orientation_), this.rotation_ = dA(this.axes_), this.setFrame(A, I, C, B), this.updateProjectionMatrix();
13770
+ constructor(A) {
13771
+ super(), this.near_ = A.near ?? ao, this.far_ = A.far ?? Do, this.orientation_ = A.orientation ?? "XY", this.axes_ = MA(this.orientation_), this.rotation_ = dA(this.axes_), this.setFrame(A), this.updateProjectionMatrix();
13662
13772
  }
13663
13773
  get viewportSize() {
13664
13774
  return this.viewportSize_;
@@ -13666,10 +13776,10 @@ class Ro extends FC {
13666
13776
  setAspectRatio(A) {
13667
13777
  this.viewportAspectRatio_ = A, this.updateProjectionMatrix();
13668
13778
  }
13669
- setFrame(A, I, B, C) {
13670
- this.width_ = Math.abs(I - A), this.height_ = Math.abs(C - B), this.updateProjectionMatrix();
13779
+ setFrame({ left: A, right: I, top: B, bottom: C }) {
13780
+ this.width_ = Math.abs(I - A), this.height_ = Math.abs(B - C), this.updateProjectionMatrix();
13671
13781
  const Q = d();
13672
- Q[W[this.axes_.u]] = 0.5 * (A + I), Q[W[this.axes_.v]] = 0.5 * (B + C), this.transform.setTranslation(Q), this.transform.setScale([1, 1, 1]), this.transform.setRotation(this.rotation_);
13782
+ Q[W[this.axes_.u]] = 0.5 * (A + I), Q[W[this.axes_.v]] = 0.5 * (C + B), this.transform.setTranslation(Q), this.transform.setScale([1, 1, 1]), this.transform.setRotation(this.rotation_);
13673
13783
  }
13674
13784
  get type() {
13675
13785
  return "OrthographicCamera";
@@ -13709,7 +13819,7 @@ class Ro extends FC {
13709
13819
  updateProjectionMatrix() {
13710
13820
  const A = this.width_, I = this.height_, B = A / I;
13711
13821
  let C = 0.5 * A, Q = 0.5 * I;
13712
- this.viewportAspectRatio_ > B ? C *= this.viewportAspectRatio_ / B : Q *= B / this.viewportAspectRatio_, this.viewportSize_ = [2 * C, 2 * Q], PC(
13822
+ this.viewportAspectRatio_ > B ? C *= this.viewportAspectRatio_ / B : Q *= B / this.viewportAspectRatio_, this.viewportSize_ = [2 * C, 2 * Q], OC(
13713
13823
  this.projectionMatrix_,
13714
13824
  -C,
13715
13825
  C,
@@ -13720,8 +13830,8 @@ class Ro extends FC {
13720
13830
  );
13721
13831
  }
13722
13832
  }
13723
- const WB = 0;
13724
- class No {
13833
+ const bB = 0;
13834
+ class ko {
13725
13835
  camera_;
13726
13836
  dragActive_ = !1;
13727
13837
  dragStart_ = d();
@@ -13761,7 +13871,7 @@ class No {
13761
13871
  }
13762
13872
  onPointerDown(A) {
13763
13873
  const I = A.event;
13764
- !A.worldPos || I.button !== WB || (this.dragStart_ = DA(A.worldPos), this.dragActive_ = !0, I.target?.setPointerCapture?.(I.pointerId));
13874
+ !A.worldPos || I.button !== bB || (this.dragStart_ = DA(A.worldPos), this.dragActive_ = !0, I.target?.setPointerCapture?.(I.pointerId));
13765
13875
  }
13766
13876
  onPointerMove(A) {
13767
13877
  if (!this.dragActive_ || !A.worldPos) return;
@@ -13770,17 +13880,17 @@ class No {
13770
13880
  }
13771
13881
  onPointerEnd(A) {
13772
13882
  const I = A.event;
13773
- !this.dragActive_ || I.button !== WB || (this.dragActive_ = !1, I.target?.releasePointerCapture?.(I.pointerId));
13883
+ !this.dragActive_ || I.button !== bB || (this.dragActive_ = !1, I.target?.releasePointerCapture?.(I.pointerId));
13774
13884
  }
13775
13885
  }
13776
- const ao = 60, Do = 1.77, oI = 0.1, VI = 180 - oI;
13777
- class co extends FC {
13886
+ const so = 60, ho = 1.77, oI = 0.1, VI = 180 - oI;
13887
+ class Lo extends SC {
13778
13888
  fov_;
13779
13889
  aspectRatio_;
13780
13890
  constructor(A = {}) {
13781
13891
  const {
13782
- fov: I = ao,
13783
- aspectRatio: B = Do,
13892
+ fov: I = so,
13893
+ aspectRatio: B = ho,
13784
13894
  near: C = 0.1,
13785
13895
  far: Q = 1e4,
13786
13896
  position: E = p(0, 0, 0)
@@ -13806,134 +13916,41 @@ class co extends FC {
13806
13916
  this.fov_ = Math.max(oI, Math.min(VI, this.fov_ / A)), this.updateProjectionMatrix();
13807
13917
  }
13808
13918
  updateProjectionMatrix() {
13809
- bC(
13919
+ ZC(
13810
13920
  this.projectionMatrix_,
13811
- pC(this.fov),
13921
+ mC(this.fov),
13812
13922
  this.aspectRatio_,
13813
13923
  this.near_,
13814
13924
  this.far_
13815
13925
  );
13816
13926
  }
13817
13927
  }
13818
- const SC = [
13819
- "fallbackVisible",
13820
- "prefetchTime",
13821
- "visibleCurrent",
13822
- "fallbackBackground",
13823
- "prefetchSpace"
13824
- ];
13825
- function mg(g) {
13826
- so(g);
13827
- const A = {
13828
- x: g.prefetch.x,
13829
- y: g.prefetch.y,
13830
- z: g.prefetch.z ?? 0,
13831
- t: g.prefetch.t ?? 0
13832
- }, I = Object.freeze(
13833
- SC.reduce(
13834
- (Q, E) => {
13835
- const i = g.priorityOrder.indexOf(E);
13836
- return Q[E] = i, Q;
13837
- },
13838
- {}
13839
- )
13840
- ), B = {
13841
- min: g.lod?.min ?? 0,
13842
- max: g.lod?.max ?? Number.MAX_SAFE_INTEGER,
13843
- bias: g.lod?.bias ?? 0.5
13844
- }, C = {
13845
- profile: g.profile ?? "custom",
13846
- prefetch: A,
13847
- priorityOrder: Object.freeze([...g.priorityOrder]),
13848
- priorityMap: I,
13849
- lod: B
13850
- };
13851
- return Object.freeze(C);
13852
- }
13853
- function Uo(g = {}) {
13854
- return mg(ug({
13855
- profile: "exploration",
13856
- prefetch: { x: 1, y: 1, z: 1, t: 0 },
13857
- priorityOrder: [
13858
- "fallbackVisible",
13859
- "visibleCurrent",
13860
- "prefetchSpace",
13861
- "prefetchTime",
13862
- "fallbackBackground"
13863
- ]
13864
- }, g));
13865
- }
13866
- function ko(g = {}) {
13867
- return mg(ug({
13868
- profile: "playback",
13869
- prefetch: { x: 0, y: 0, z: 0, t: 20 },
13870
- priorityOrder: [
13871
- "fallbackVisible",
13872
- "prefetchTime",
13873
- "visibleCurrent",
13874
- "fallbackBackground",
13875
- "prefetchSpace"
13876
- ]
13877
- }, g));
13878
- }
13879
- function Lo(g = {}) {
13880
- return mg(ug({
13881
- profile: "no-prefetch",
13882
- prefetch: { x: 0, y: 0, z: 0, t: 0 },
13883
- priorityOrder: [
13884
- "fallbackVisible",
13885
- "visibleCurrent",
13886
- "fallbackBackground",
13887
- "prefetchSpace",
13888
- "prefetchTime"
13889
- ]
13890
- }, g));
13891
- }
13892
- function so(g) {
13893
- for (const [B, C] of Object.entries(g.prefetch))
13894
- if (C !== void 0 && C < 0)
13895
- throw new Error(`prefetch.${B} must be a non-negative number`);
13896
- const A = g.lod;
13897
- if (A?.min !== void 0 && A?.max !== void 0 && A.min > A.max)
13898
- throw new Error("lod.min must be <= lod.max");
13899
- const I = g.priorityOrder;
13900
- if (I.length !== SC.length || new Set(I).size !== I.length)
13901
- throw new Error("priorityOrder must include all categories exactly once");
13902
- }
13903
- function ug(g, A = {}) {
13904
- return {
13905
- profile: A.profile ?? g.profile,
13906
- prefetch: { ...g.prefetch, ...A.prefetch ?? {} },
13907
- lod: { ...g.lod, ...A.lod ?? {} },
13908
- priorityOrder: A.priorityOrder ?? g.priorityOrder
13909
- };
13910
- }
13911
13928
  export {
13912
- wo as AxesLayer,
13929
+ Fo as AxesLayer,
13913
13930
  x as Color,
13914
- ho as Idetik,
13915
- eC as ImageLayer,
13916
- li as ImageRenderable,
13917
- fB as LabelColorMap,
13918
- zi as LabelImageRenderable,
13919
- GC as LabelLayer,
13931
+ to as Idetik,
13932
+ GC as ImageLayer,
13933
+ pi as ImageRenderable,
13934
+ pB as LabelColorMap,
13935
+ $i as LabelImageRenderable,
13936
+ FC as LabelLayer,
13920
13937
  KI as Layer,
13921
13938
  OA as OmeZarrImageSource,
13922
- So as OrbitControls,
13923
- Ro as OrthographicCamera,
13924
- No as PanZoomControls,
13925
- co as PerspectiveCamera,
13926
- ro as PointsRenderable,
13927
- Hi as ProjectedLineRenderable,
13928
- Fo as VolumeLayer,
13929
- mi as VolumeRenderable,
13930
- Uo as createExplorationPolicy,
13931
- mg as createImageSourcePolicy,
13932
- Lo as createNoPrefetchPolicy,
13933
- ko as createPlaybackPolicy,
13934
- yo as loadOmeZarrPlate,
13935
- eo as loadOmeZarrWell,
13936
- no as loadOmeroChannels,
13937
- Go as loadOmeroDefaults
13939
+ co as OrbitControls,
13940
+ Uo as OrthographicCamera,
13941
+ ko as PanZoomControls,
13942
+ Lo as PerspectiveCamera,
13943
+ No as PointsRenderable,
13944
+ qi as ProjectedLineRenderable,
13945
+ Ro as VolumeLayer,
13946
+ Ti as VolumeRenderable,
13947
+ mg as createExplorationPolicy,
13948
+ pg as createImageSourcePolicy,
13949
+ So as createNoPrefetchPolicy,
13950
+ ro as createPlaybackPolicy,
13951
+ eo as loadOmeZarrPlate,
13952
+ no as loadOmeZarrWell,
13953
+ Go as loadOmeroChannels,
13954
+ wo as loadOmeroDefaults
13938
13955
  };
13939
13956
  //# sourceMappingURL=index.js.map