@fxi/zartigl 0.14.2 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/zartigl.js CHANGED
@@ -1,88 +1,86 @@
1
- import { m as ae, p as pt, s as gt, a as qe, b as Bt, r as ze, c as $t, d as he, e as qt, f as vt, g as Wt } from "./index-B1lj-XR_.js";
2
- import { T as Xt, g as Ht, r as Yt, d as Zt, c as W, a as jt, b as ge, e as Qt, f as J, h as Se, i as O, G as Kt, j as We, F as Jt, s as yt, v as Q, k as K, l as Ge, m as Oe, n as _t, o as Xe, p as Ce, q as ei, t as ke, u as ti, w as xt, x as z, y as He, z as we, A as ii, B as ai, C as si, D as Ye, E as ri, H as Fe, I as ni, J as bt, K as oi, L as li, M as ci, N as hi } from "./engine-C8ZNzILO.js";
3
- import { O as Na, P as za } from "./engine-C8ZNzILO.js";
4
- import { B as ui, a as di, b as mi, c as fi, d as St, r as wt, e as pi, g as gi } from "./backdrop-Dceb4d8E.js";
5
- import { f as Oa, i as Ba } from "./backdrop-Dceb4d8E.js";
6
- import { inflate as vi } from "pako";
7
- import yi from "numcodecs/blosc";
8
- const Ie = 85, _i = 89.9;
9
- function Ue(s) {
10
- return Math.max(-Ie, Math.min(Ie, s));
11
- }
12
- function Ze(s) {
13
- const e = Ue(s), t = Math.sin(e * Math.PI / 180);
1
+ import { m as ae, p as dt, s as mt, a as $e, b as Gt, r as ze, c as Ot, d as ue, e as Nt, f as ft, g as Bt } from "./index-DxMsDfgL.js";
2
+ import { T as $t, $ as qt, a0 as Wt, a1 as Xt, s as q, a2 as Ht, q as ge, a3 as Yt, a4 as J, a5 as Se, a6 as O, a as Zt, c as qe, a7 as jt, a8 as pt, Y as Q, Z as ve, a9 as K, aa as Ge, ab as Oe, i as gt, v as We, H as Ae, A as Qt, N as Ce, ac as Kt, D as vt, ad as z, ae as Xe, B as we, af as Jt, ag as ei, ah as ti, w as He, ai as ii, E as ke, I as ai, S as yt, aj as si, F as ri, x as ni, z as oi } from "./geovideo-index-D-BHqpO6.js";
3
+ import { ak as Ma, X as Pa } from "./geovideo-index-D-BHqpO6.js";
4
+ import { B as li, C as ci, b as ui, d as hi, e as _t, r as xt, c as di, g as mi } from "./backdrop-BMwRyFI5.js";
5
+ import { a as La, i as Da } from "./backdrop-BMwRyFI5.js";
6
+ const Fe = 85, fi = 89.9;
7
+ function Ve(a) {
8
+ return Math.max(-Fe, Math.min(Fe, a));
9
+ }
10
+ function Ye(a) {
11
+ const e = Ve(a), t = Math.sin(e * Math.PI / 180);
14
12
  return 0.5 - Math.log((1 + t) / (1 - t)) / (4 * Math.PI);
15
13
  }
16
- function ve(s) {
17
- return (s + 180) / 360;
14
+ function ye(a) {
15
+ return (a + 180) / 360;
18
16
  }
19
- function xi(s) {
20
- return ((s + 180) % 360 + 360) % 360 - 180;
17
+ function pi(a) {
18
+ return ((a + 180) % 360 + 360) % 360 - 180;
21
19
  }
22
- function Tt(s, e, t, i) {
23
- const a = (o, l, d) => d > l ? Math.abs(o[d] - o[l]) / (d - l) / 2 : o.length > 1 ? Math.abs(o[1] - o[0]) / 2 : 0, r = a(s, t[0], t[1]), n = a(e, i[0], i[1]);
20
+ function bt(a, e, t, i) {
21
+ const s = (o, c, d) => d > c ? Math.abs(o[d] - o[c]) / (d - c) / 2 : o.length > 1 ? Math.abs(o[1] - o[0]) / 2 : 0, r = s(a, t[0], t[1]), n = s(e, i[0], i[1]);
24
22
  return {
25
- west: s[t[0]] - r,
26
- east: s[t[1]] + r,
23
+ west: a[t[0]] - r,
24
+ east: a[t[1]] + r,
27
25
  south: Math.min(e[i[0]], e[i[1]]) - n,
28
26
  north: Math.max(e[i[0]], e[i[1]]) + n
29
27
  };
30
28
  }
31
- function ye(s, e) {
32
- if (s.getProjection?.()?.type !== "globe")
29
+ function _e(a, e) {
30
+ if (a.getProjection?.()?.type !== "globe")
33
31
  return !1;
34
32
  const t = e?.projectionTransition;
35
33
  return typeof t == "number" ? t > 0 : !0;
36
34
  }
37
- function bi(s, e) {
38
- const t = xi(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
35
+ function gi(a, e) {
36
+ const t = pi(a) * Math.PI / 180, i = e * Math.PI / 180, s = Math.cos(i);
39
37
  return [
40
- Math.sin(t) * a,
38
+ Math.sin(t) * s,
41
39
  Math.sin(i),
42
- Math.cos(t) * a
40
+ Math.cos(t) * s
43
41
  ];
44
42
  }
45
- function Si(s) {
43
+ function vi(a) {
46
44
  return {
47
45
  west: -180,
48
46
  east: 180,
49
- south: Ue(s.getSouth()),
50
- north: Ue(s.getNorth())
47
+ south: Ve(a.getSouth()),
48
+ north: Ve(a.getNorth())
51
49
  };
52
50
  }
53
- function wi(s, e = 1, t = !1) {
54
- const i = t ? _i : Ie, a = (d) => Math.max(-i, Math.min(i, d)), r = a(s.getSouth()), n = a(s.getNorth()), l = Math.max(0, n - r) * Math.max(0, e);
51
+ function yi(a, e = 1, t = !1) {
52
+ const i = t ? fi : Fe, s = (d) => Math.max(-i, Math.min(i, d)), r = s(a.getSouth()), n = s(a.getNorth()), c = Math.max(0, n - r) * Math.max(0, e);
55
53
  return {
56
54
  west: -180,
57
55
  east: 180,
58
- south: a(r - l),
59
- north: a(n + l)
56
+ south: s(r - c),
57
+ north: s(n + c)
60
58
  };
61
59
  }
62
- function Ti(s, e, t = 1e-6) {
63
- return s.south <= e.south + t && s.north >= e.north - t;
60
+ function _i(a, e, t = 1e-6) {
61
+ return a.south <= e.south + t && a.north >= e.north - t;
64
62
  }
65
- function Mi(s, e = !1) {
66
- const t = s.getWest(), i = s.getEast(), a = ve(t), r = ve(i), n = a - Math.floor(a), o = r - a >= 1 ? { minX: 0, maxX: 1 } : { minX: n, maxX: n + r - a };
63
+ function xi(a, e = !1) {
64
+ const t = a.getWest(), i = a.getEast(), s = ye(t), r = ye(i), n = s - Math.floor(s), o = r - s >= 1 ? { minX: 0, maxX: 1 } : { minX: n, maxX: n + r - s };
67
65
  return e ? {
68
66
  ...o,
69
- minY: (Math.max(s.getSouth(), -90) + 90) / 180,
70
- maxY: (Math.min(s.getNorth(), 90) + 90) / 180
67
+ minY: (Math.max(a.getSouth(), -90) + 90) / 180,
68
+ maxY: (Math.min(a.getNorth(), 90) + 90) / 180
71
69
  } : {
72
70
  ...o,
73
- minY: Ze(s.getNorth()),
74
- maxY: Ze(s.getSouth())
71
+ minY: Ye(a.getNorth()),
72
+ maxY: Ye(a.getSouth())
75
73
  };
76
74
  }
77
- function Be(s, e) {
75
+ function Ne(a, e) {
78
76
  if (e)
79
77
  return [0];
80
- const t = ve(s.getWest()), i = ve(s.getEast()), a = [];
78
+ const t = ye(a.getWest()), i = ye(a.getEast()), s = [];
81
79
  for (let r = Math.floor(t); r <= Math.floor(i); r++)
82
- a.push(r);
83
- return a;
80
+ s.push(r);
81
+ return s;
84
82
  }
85
- const ue = [
83
+ const he = [
86
84
  "u_velocity_next",
87
85
  "u_velocity_next_min",
88
86
  "u_velocity_next_max",
@@ -92,8 +90,8 @@ const ue = [
92
90
  "u_velocity_flip_y",
93
91
  "u_velocity_next_flip_y"
94
92
  ];
95
- function Te(s, e, t) {
96
- s.uniform1i(e.u_velocity_next, t.b.unit), s.uniform2f(e.u_velocity_next_min, ...t.b.min), s.uniform2f(e.u_velocity_next_max, ...t.b.max), s.uniform1f(e.u_velocity_mix, t.mix), s.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), s.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), s.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), s.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
93
+ function Te(a, e, t) {
94
+ a.uniform1i(e.u_velocity_next, t.b.unit), a.uniform2f(e.u_velocity_next_min, ...t.b.min), a.uniform2f(e.u_velocity_next_max, ...t.b.max), a.uniform1f(e.u_velocity_mix, t.mix), a.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), a.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), a.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), a.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
97
95
  }
98
96
  var de = `#version 300 es
99
97
  precision highp float;
@@ -104,7 +102,7 @@ out vec2 v_tex_coord;
104
102
  void main() {
105
103
  v_tex_coord = a_position * 0.5 + 0.5;
106
104
  gl_Position = vec4(a_position, 0.0, 1.0);
107
- }`, Ri = `#version 300 es
105
+ }`, bi = `#version 300 es
108
106
  precision highp float;
109
107
 
110
108
  uint pcg(uint v) {
@@ -374,7 +372,7 @@ void main() {
374
372
  fract(newPos.y * 255.0)
375
373
  );
376
374
  #endif
377
- }`, Pi = `precision highp float;
375
+ }`, Si = `precision highp float;
378
376
 
379
377
  attribute float a_index;
380
378
  attribute float a_is_curr;
@@ -606,7 +604,7 @@ void main() {
606
604
  vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
607
605
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
608
606
  }
609
- }`, Ei = `precision mediump float;
607
+ }`, wi = `precision mediump float;
610
608
 
611
609
  uniform sampler2D u_color_ramp;
612
610
  uniform float u_particle_contrast;
@@ -645,7 +643,7 @@ void main() {
645
643
  }
646
644
 
647
645
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
648
- }`, Li = `#version 300 es
646
+ }`, Ti = `#version 300 es
649
647
  precision mediump float;
650
648
 
651
649
  uniform sampler2D u_screen;
@@ -662,7 +660,7 @@ void main() {
662
660
  float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
663
661
 
664
662
  o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
665
- }`, Di = `#version 300 es
663
+ }`, Ri = `#version 300 es
666
664
  precision mediump float;
667
665
 
668
666
  uniform sampler2D u_screen;
@@ -733,7 +731,7 @@ void main() {
733
731
  }
734
732
  vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
735
733
  o_color = vec4(rgb, color.a);
736
- }`, Ai = `#version 300 es
734
+ }`, Mi = `#version 300 es
737
735
  precision mediump float;
738
736
 
739
737
  uniform sampler2D u_screen;
@@ -770,7 +768,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
770
768
 
771
769
  void main() {
772
770
  o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
773
- }`, Mt = `precision highp float;
771
+ }`, St = `precision highp float;
774
772
 
775
773
  attribute vec2 a_grid_uv;
776
774
 
@@ -804,7 +802,7 @@ void main() {
804
802
 
805
803
  v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
806
804
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
807
- }`, Ci = `precision mediump float;
805
+ }`, Pi = `precision mediump float;
808
806
 
809
807
  uniform sampler2D u_field;
810
808
  uniform sampler2D u_color_ramp;
@@ -904,7 +902,7 @@ void main() {
904
902
  vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
905
903
  color.rgb = applyVibrance(color.rgb, u_vibrance);
906
904
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
907
- }`, Rt = `precision highp float;
905
+ }`, wt = `precision highp float;
908
906
 
909
907
  attribute vec2 a_grid_uv;
910
908
 
@@ -954,7 +952,7 @@ void main() {
954
952
  position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
955
953
  }
956
954
  gl_Position = position;
957
- }`, ki = `precision mediump float;
955
+ }`, Ei = `precision mediump float;
958
956
 
959
957
  uniform sampler2D u_field;
960
958
  uniform sampler2D u_color_ramp;
@@ -1044,25 +1042,25 @@ void main() {
1044
1042
  color.rgb = applyVibrance(color.rgb, u_vibrance);
1045
1043
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
1046
1044
  }`;
1047
- const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, Fi = 1, Ii = 0.92, Ui = 0.1, je = 0.98;
1048
- function Vi(s) {
1049
- if (Number.isNaN(s))
1045
+ const Re = [0, 0, 0, 0], N = 512, H = N * N, Y = 128, ee = 64, Li = 1, Di = 0.92, Ai = 0.1, Ze = 0.98;
1046
+ function Ci(a) {
1047
+ if (Number.isNaN(a))
1050
1048
  return 32256;
1051
- if (s === 1 / 0)
1049
+ if (a === 1 / 0)
1052
1050
  return 31744;
1053
- if (s === -1 / 0)
1051
+ if (a === -1 / 0)
1054
1052
  return 64512;
1055
- const e = s < 0 ? 32768 : 0, t = Math.abs(s);
1053
+ const e = a < 0 ? 32768 : 0, t = Math.abs(a);
1056
1054
  if (t === 0)
1057
1055
  return e;
1058
1056
  if (t >= 65504)
1059
1057
  return e | 31743;
1060
1058
  if (t < 6103515625e-14)
1061
1059
  return e | Math.round(t / 5960464477539063e-23);
1062
- const i = Math.floor(Math.log2(t)), a = t / 2 ** i - 1;
1063
- return e | i + 15 << 10 | Math.round(a * 1024);
1060
+ const i = Math.floor(Math.log2(t)), s = t / 2 ** i - 1;
1061
+ return e | i + 15 << 10 | Math.round(s * 1024);
1064
1062
  }
1065
- const Ni = {
1063
+ const ki = {
1066
1064
  particleDensity: 0.05,
1067
1065
  speed: 1,
1068
1066
  fadeOpacity: 0.996,
@@ -1071,28 +1069,28 @@ const Ni = {
1071
1069
  opacity: 1,
1072
1070
  logScale: !1,
1073
1071
  vibrance: 0,
1074
- colorGrade: di,
1075
- backdrop: ui,
1072
+ colorGrade: ci,
1073
+ backdrop: li,
1076
1074
  glow: 0,
1077
1075
  scalarMode: !1,
1078
1076
  particleState: "auto",
1079
1077
  rgba8MaxParticleZoom: 4
1080
1078
  };
1081
- class Pt {
1079
+ class Tt {
1082
1080
  constructor(e) {
1083
- this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...Ni, ...e }, this.trailFade = new Xt(this.params.fadeOpacity);
1081
+ this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...ki, ...e }, this.trailFade = new $t(this.params.fadeOpacity);
1084
1082
  }
1085
1083
  init(e) {
1086
- this.gl = e, this.webglInfo = Ht(e), this.stateFormat = this.params.particleState === "rgba8" ? Yt(e) : Zt(e);
1084
+ this.gl = e, this.webglInfo = qt(e), this.stateFormat = this.params.particleState === "rgba8" ? Wt(e) : Xt(e);
1087
1085
  const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
1088
1086
  ` : "";
1089
- this.updateProgram = W(
1087
+ this.updateProgram = q(
1090
1088
  e,
1091
1089
  de,
1092
- Ri.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1093
- ), this.drawProgram = W(e, t + Pi, Ei), this.fadeProgram = W(e, de, Li), this.compositeProgram = W(e, de, Di), this.glowProgram = W(e, de, Ai), this.gridProgram = W(e, Mt, Ci), this.gridGlobeProgram = W(e, Rt, ki), this.updateLocs = this.getUniforms(this.updateProgram, [
1090
+ bi.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1091
+ ), this.drawProgram = q(e, t + Si, wi), this.fadeProgram = q(e, de, Ti), this.compositeProgram = q(e, de, Ri), this.glowProgram = q(e, de, Mi), this.gridProgram = q(e, St, Pi), this.gridGlobeProgram = q(e, wt, Ei), this.updateLocs = this.getUniforms(this.updateProgram, [
1094
1092
  "u_particles",
1095
- ...ue,
1093
+ ...he,
1096
1094
  "u_velocity",
1097
1095
  "u_velocity_min",
1098
1096
  "u_velocity_max",
@@ -1108,7 +1106,7 @@ class Pt {
1108
1106
  ]), this.drawLocs = this.getUniforms(this.drawProgram, [
1109
1107
  "u_particles",
1110
1108
  "u_prev_particles",
1111
- ...ue,
1109
+ ...he,
1112
1110
  "u_velocity",
1113
1111
  "u_velocity_min",
1114
1112
  "u_velocity_max",
@@ -1136,7 +1134,7 @@ class Pt {
1136
1134
  "u_grade_on",
1137
1135
  "u_grade"
1138
1136
  ]), this.glowLocs = this.getUniforms(this.glowProgram, ["u_screen"]), this.gridLocs = this.getUniforms(this.gridProgram, [
1139
- ...ue,
1137
+ ...he,
1140
1138
  "u_field",
1141
1139
  "u_color_ramp",
1142
1140
  "u_matrix",
@@ -1155,7 +1153,7 @@ class Pt {
1155
1153
  "u_scalar_mode",
1156
1154
  "u_solid"
1157
1155
  ]), this.gridGlobeLocs = this.getUniforms(this.gridGlobeProgram, [
1158
- ...ue,
1156
+ ...he,
1159
1157
  "u_field",
1160
1158
  "u_color_ramp",
1161
1159
  "u_matrix",
@@ -1174,52 +1172,52 @@ class Pt {
1174
1172
  "u_vibrance",
1175
1173
  "u_scalar_mode",
1176
1174
  "u_solid"
1177
- ]), this.quadBuffer = jt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1175
+ ]), this.quadBuffer = Ht(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1178
1176
  }
1179
1177
  getUniforms(e, t) {
1180
1178
  const i = {};
1181
- for (const a of t)
1182
- i[a] = this.gl.getUniformLocation(e, a);
1179
+ for (const s of t)
1180
+ i[s] = this.gl.getUniformLocation(e, s);
1183
1181
  return i;
1184
1182
  }
1185
1183
  /** Random initial particle positions, matching the active state format. */
1186
1184
  makeStateData() {
1187
- const e = B, t = e * e * 4;
1185
+ const e = N, t = e * e * 4;
1188
1186
  if (this.stateFormat?.kind === "float32") {
1189
- const a = new Float32Array(t);
1187
+ const s = new Float32Array(t);
1190
1188
  for (let r = 0; r < t; r++)
1191
- a[r] = Math.random();
1192
- return a;
1189
+ s[r] = Math.random();
1190
+ return s;
1193
1191
  }
1194
1192
  if (this.stateFormat?.kind === "float16") {
1195
- const a = new Uint16Array(t);
1193
+ const s = new Uint16Array(t);
1196
1194
  for (let r = 0; r < t; r++)
1197
- a[r] = Vi(Math.random());
1198
- return a;
1195
+ s[r] = Ci(Math.random());
1196
+ return s;
1199
1197
  }
1200
1198
  const i = new Uint8Array(t);
1201
- for (let a = 0; a < t; a++)
1202
- i[a] = Math.floor(Math.random() * 256);
1199
+ for (let s = 0; s < t; s++)
1200
+ i[s] = Math.floor(Math.random() * 256);
1203
1201
  return i;
1204
1202
  }
1205
1203
  createStateTexture(e) {
1206
- return Qt(
1204
+ return Yt(
1207
1205
  this.gl,
1208
1206
  this.gl.NEAREST,
1209
1207
  e,
1210
- B,
1211
- B,
1208
+ N,
1209
+ N,
1212
1210
  this.stateFormat.internalFormat,
1213
1211
  this.stateFormat.type
1214
1212
  );
1215
1213
  }
1216
1214
  initParticleState() {
1217
- const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
1218
- this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
1219
- const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
1215
+ const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), s = this.createStateTexture(t), r = J(e, i), n = J(e, s);
1216
+ this.particleStateTextures = [i, s], this.particleFramebuffers = [r, n];
1217
+ const o = new Float32Array(H * 2), c = new Float32Array(H * 2);
1220
1218
  for (let d = 0; d < H; d++)
1221
- o[d * 2] = d, o[d * 2 + 1] = d, l[d * 2] = 0, l[d * 2 + 1] = 1;
1222
- this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
1219
+ o[d * 2] = d, o[d * 2 + 1] = d, c[d * 2] = 0, c[d * 2 + 1] = 1;
1220
+ this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, c, e.STATIC_DRAW);
1223
1221
  }
1224
1222
  initRasterGrid() {
1225
1223
  const e = this.gl, t = new Float32Array(
@@ -1227,19 +1225,19 @@ class Pt {
1227
1225
  );
1228
1226
  let i = 0;
1229
1227
  for (let o = 0; o <= ee; o++)
1230
- for (let l = 0; l <= Y; l++)
1231
- t[i++] = l / Y, t[i++] = o / ee;
1232
- const a = new Uint16Array(
1228
+ for (let c = 0; c <= Y; c++)
1229
+ t[i++] = c / Y, t[i++] = o / ee;
1230
+ const s = new Uint16Array(
1233
1231
  Y * ee * 6
1234
1232
  );
1235
1233
  let r = 0;
1236
1234
  const n = Y + 1;
1237
1235
  for (let o = 0; o < ee; o++)
1238
- for (let l = 0; l < Y; l++) {
1239
- const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
1240
- a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
1236
+ for (let c = 0; c < Y; c++) {
1237
+ const d = o * n + c, u = d + 1, h = d + n, v = h + 1;
1238
+ s[r++] = d, s[r++] = h, s[r++] = u, s[r++] = u, s[r++] = h, s[r++] = v;
1241
1239
  }
1242
- this.rasterGridBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.rasterGridBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), this.rasterGridIndexBuffer = e.createBuffer(), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.rasterGridIndexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, a, e.STATIC_DRAW), this.rasterGridIndexCount = a.length;
1240
+ this.rasterGridBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.rasterGridBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), this.rasterGridIndexBuffer = e.createBuffer(), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.rasterGridIndexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, s, e.STATIC_DRAW), this.rasterGridIndexCount = s.length;
1243
1241
  }
1244
1242
  /**
1245
1243
  * Ensure screen textures match the current canvas size and recompute
@@ -1256,31 +1254,31 @@ class Pt {
1256
1254
  return;
1257
1255
  const i = this.gl;
1258
1256
  this.screenWidth = e, this.screenHeight = t, this.screenTextures && (i.deleteTexture(this.screenTextures[0]), i.deleteTexture(this.screenTextures[1]), i.deleteFramebuffer(this.screenFramebuffers[0]), i.deleteFramebuffer(this.screenFramebuffers[1])), this.deleteGlowTarget();
1259
- const a = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, a, e, t), n = Se(i, i.NEAREST, a, e, t), o = J(i, r), l = J(i, n);
1260
- this.screenTextures = [r, n], this.screenFramebuffers = [o, l];
1257
+ const s = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, s, e, t), n = Se(i, i.NEAREST, s, e, t), o = J(i, r), c = J(i, n);
1258
+ this.screenTextures = [r, n], this.screenFramebuffers = [o, c];
1261
1259
  }
1262
1260
  /**
1263
1261
  * Run one simulation step: update positions, fade trails, draw particles.
1264
1262
  * Must be called within the MapLibre render callback.
1265
1263
  */
1266
- render(e, t, i, a, r, n, o, l, d = !1, c = [0, 0, 1], u, f) {
1267
- const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
1264
+ render(e, t, i, s, r, n, o, c, d = !1, u = [0, 0, 1], h, v) {
1265
+ const m = { unit: e, min: t, max: i }, f = v ?? { a: m, b: m, mix: 0 }, l = this.gl;
1268
1266
  if (this.screenWidth === 0 || this.screenHeight === 0)
1269
1267
  return;
1270
- const g = h.getParameter(
1271
- h.FRAMEBUFFER_BINDING
1268
+ const p = l.getParameter(
1269
+ l.FRAMEBUFFER_BINDING
1272
1270
  ), x = this.shouldSuppressRgba8Particles(n);
1273
1271
  x && !this.lastRgba8ParticlesSuppressed && this.clearState(), this.lastRgba8ParticlesSuppressed = x;
1274
- const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), M = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
1272
+ const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), R = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
1275
1273
  let y = !1;
1276
1274
  if (T) {
1277
- h.disable(h.BLEND), h.useProgram(this.updateProgram), h.viewport(0, 0, B, B), O(h, this.particleStateTextures[0], 0), h.uniform1i(this.updateLocs.u_particles, 0), Te(h, this.updateLocs, p), h.uniform1i(this.updateLocs.u_velocity, p.a.unit), h.uniform2f(this.updateLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.updateLocs.u_velocity_max, ...p.a.max), h.uniform1f(this.updateLocs.u_speed, this.params.speed), h.uniform1f(this.updateLocs.u_world_size, n), h.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
1278
- const R = r.maxX - r.minX;
1275
+ l.disable(l.BLEND), l.useProgram(this.updateProgram), l.viewport(0, 0, N, N), O(l, this.particleStateTextures[0], 0), l.uniform1i(this.updateLocs.u_particles, 0), Te(l, this.updateLocs, f), l.uniform1i(this.updateLocs.u_velocity, f.a.unit), l.uniform2f(this.updateLocs.u_velocity_min, ...f.a.min), l.uniform2f(this.updateLocs.u_velocity_max, ...f.a.max), l.uniform1f(this.updateLocs.u_speed, this.params.speed), l.uniform1f(this.updateLocs.u_world_size, n), l.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
1276
+ const P = r.maxX - r.minX;
1279
1277
  if (this.prevBounds) {
1280
- const F = this.prevBounds.maxX - this.prevBounds.minX, L = this.prevBounds.maxY - this.prevBounds.minY, D = 1e-6, b = (r.minX + r.maxX) * 0.5, A = (r.minY + r.maxY) * 0.5, N = (this.prevBounds.minX + this.prevBounds.maxX) * 0.5, C = (this.prevBounds.minY + this.prevBounds.maxY) * 0.5, I = Math.abs(R - F) / Math.max(F, D), w = Math.abs(b - N) / Math.max(F, D) + Math.abs(A - C) / Math.max(L, D), U = Math.min(1, I + w);
1278
+ const U = this.prevBounds.maxX - this.prevBounds.minX, L = this.prevBounds.maxY - this.prevBounds.minY, D = 1e-6, b = (r.minX + r.maxX) * 0.5, V = (r.minY + r.maxY) * 0.5, X = (this.prevBounds.minX + this.prevBounds.maxX) * 0.5, C = (this.prevBounds.minY + this.prevBounds.maxY) * 0.5, I = Math.abs(P - U) / Math.max(U, D), w = Math.abs(b - X) / Math.max(U, D) + Math.abs(V - C) / Math.max(L, D), k = Math.min(1, I + w);
1281
1279
  this.redistributionBoost = Math.max(
1282
- this.redistributionBoost * Ii,
1283
- U * Fi
1280
+ this.redistributionBoost * Di,
1281
+ k * Li
1284
1282
  );
1285
1283
  }
1286
1284
  this.prevBounds = {
@@ -1289,187 +1287,187 @@ class Pt {
1289
1287
  maxX: r.maxX,
1290
1288
  maxY: r.maxY
1291
1289
  };
1292
- const k = Math.min(
1290
+ const A = Math.min(
1293
1291
  this.params.dropRate + this.redistributionBoost,
1294
- Ui
1292
+ Ai
1295
1293
  );
1296
- h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
1294
+ l.uniform1f(this.updateLocs.u_drop_rate, A), l.uniform1f(
1297
1295
  this.updateLocs.u_drop_rate_bump,
1298
1296
  this.params.dropRateBump
1299
- ), h.uniform4f(
1297
+ ), l.uniform4f(
1300
1298
  this.updateLocs.u_bounds,
1301
1299
  r.minX,
1302
1300
  r.minY,
1303
1301
  r.maxX,
1304
1302
  r.maxY
1305
- ), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
1303
+ ), l.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), c && l.uniform4f(
1306
1304
  this.updateLocs.u_geo_bounds,
1307
- l.west,
1308
- l.south,
1309
- l.east,
1310
- l.north
1311
- ), h.uniform1f(
1305
+ c.west,
1306
+ c.south,
1307
+ c.east,
1308
+ c.north
1309
+ ), l.uniform1f(
1312
1310
  this.updateLocs.u_valid_threshold,
1313
- je
1314
- ), h.bindFramebuffer(h.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
1311
+ Ze
1312
+ ), l.bindFramebuffer(l.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
1315
1313
  }
1316
- h.viewport(0, 0, this.screenWidth, this.screenHeight), h.bindFramebuffer(h.FRAMEBUFFER, this.screenFramebuffers[1]), h.useProgram(this.fadeProgram), h.disable(h.BLEND), O(h, this.screenTextures[0], 0), h.uniform1i(this.fadeLocs.u_screen, 0), h.uniform1f(
1314
+ l.viewport(0, 0, this.screenWidth, this.screenHeight), l.bindFramebuffer(l.FRAMEBUFFER, this.screenFramebuffers[1]), l.useProgram(this.fadeProgram), l.disable(l.BLEND), O(l, this.screenTextures[0], 0), l.uniform1i(this.fadeLocs.u_screen, 0), l.uniform1f(
1317
1315
  this.fadeLocs.u_opacity,
1318
1316
  this.updateTrailFadeOpacity(performance.now())
1319
1317
  ), this.drawQuad();
1320
- const v = (R) => {
1321
- l && (d && u ? this.renderGridGlobe(
1318
+ const g = (P) => {
1319
+ c && (d && h ? this.renderGridGlobe(
1322
1320
  e,
1323
1321
  t,
1324
1322
  i,
1325
- a,
1326
- l,
1327
- u,
1323
+ s,
1324
+ c,
1325
+ h,
1328
1326
  1,
1329
- R,
1330
- p
1327
+ P,
1328
+ f
1331
1329
  ) : d || this.renderGrid(
1332
1330
  e,
1333
1331
  t,
1334
1332
  i,
1335
- a,
1333
+ s,
1336
1334
  n,
1337
1335
  o,
1338
- l,
1336
+ c,
1339
1337
  1,
1340
- R,
1341
- p
1338
+ P,
1339
+ f
1342
1340
  ));
1343
1341
  };
1344
- if (M && v(Me), T) {
1345
- h.useProgram(this.drawProgram), h.enable(h.BLEND), h.blendFuncSeparate(
1346
- h.SRC_ALPHA,
1347
- h.ONE_MINUS_SRC_ALPHA,
1348
- h.ONE,
1349
- h.ONE_MINUS_SRC_ALPHA
1350
- ), O(h, this.particleStateTextures[1], 0), h.uniform1i(this.drawLocs.u_particles, 0), O(h, this.particleStateTextures[0], 3), h.uniform1i(this.drawLocs.u_prev_particles, 3), Te(h, this.drawLocs, p), h.uniform1i(this.drawLocs.u_velocity, p.a.unit), h.uniform2f(this.drawLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.drawLocs.u_velocity_max, ...p.a.max), l && h.uniform4f(
1342
+ if (R && g(Re), T) {
1343
+ l.useProgram(this.drawProgram), l.enable(l.BLEND), l.blendFuncSeparate(
1344
+ l.SRC_ALPHA,
1345
+ l.ONE_MINUS_SRC_ALPHA,
1346
+ l.ONE,
1347
+ l.ONE_MINUS_SRC_ALPHA
1348
+ ), O(l, this.particleStateTextures[1], 0), l.uniform1i(this.drawLocs.u_particles, 0), O(l, this.particleStateTextures[0], 3), l.uniform1i(this.drawLocs.u_prev_particles, 3), Te(l, this.drawLocs, f), l.uniform1i(this.drawLocs.u_velocity, f.a.unit), l.uniform2f(this.drawLocs.u_velocity_min, ...f.a.min), l.uniform2f(this.drawLocs.u_velocity_max, ...f.a.max), c && l.uniform4f(
1351
1349
  this.drawLocs.u_geo_bounds,
1352
- l.west,
1353
- l.south,
1354
- l.east,
1355
- l.north
1356
- ), h.uniform1f(this.drawLocs.u_particles_res, B), h.uniform1f(this.drawLocs.u_world_size, n), h.uniform1f(this.drawLocs.u_speed, this.params.speed), O(h, this.colorRampTexture, 2), h.uniform1i(this.drawLocs.u_color_ramp, 2), h.uniform1f(
1350
+ c.west,
1351
+ c.south,
1352
+ c.east,
1353
+ c.north
1354
+ ), l.uniform1f(this.drawLocs.u_particles_res, N), l.uniform1f(this.drawLocs.u_world_size, n), l.uniform1f(this.drawLocs.u_speed, this.params.speed), O(l, this.colorRampTexture, 2), l.uniform1i(this.drawLocs.u_color_ramp, 2), l.uniform1f(
1357
1355
  this.drawLocs.u_particle_contrast,
1358
1356
  this.renderMode === "raster+particles" ? 1 : 0
1359
- ), h.uniform1f(this.drawLocs.u_opacity, this.params.opacity), h.uniform1f(
1357
+ ), l.uniform1f(this.drawLocs.u_opacity, this.params.opacity), l.uniform1f(
1360
1358
  this.drawLocs.u_log_scale,
1361
1359
  this.params.logScale ? 1 : 0
1362
- ), h.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), h.uniform1f(
1360
+ ), l.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), l.uniform1f(
1363
1361
  this.drawLocs.u_valid_threshold,
1364
- je
1365
- ), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
1362
+ Ze
1363
+ ), l.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), l.uniform3f(
1366
1364
  this.drawLocs.u_globe_center,
1367
- c[0],
1368
- c[1],
1369
- c[2]
1370
- ), h.uniformMatrix4fv(
1365
+ u[0],
1366
+ u[1],
1367
+ u[2]
1368
+ ), l.uniformMatrix4fv(
1371
1369
  this.drawLocs.u_matrix,
1372
1370
  !1,
1373
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1371
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1374
1372
  );
1375
- const R = h.getAttribLocation(this.drawProgram, "a_index");
1376
- h.bindBuffer(h.ARRAY_BUFFER, this.particleIndexBuffer), h.enableVertexAttribArray(R), h.vertexAttribPointer(R, 1, h.FLOAT, !1, 0, 0);
1377
- const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
1378
- h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
1379
- for (const F of o)
1380
- h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
1381
- h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1373
+ const P = l.getAttribLocation(this.drawProgram, "a_index");
1374
+ l.bindBuffer(l.ARRAY_BUFFER, this.particleIndexBuffer), l.enableVertexAttribArray(P), l.vertexAttribPointer(P, 1, l.FLOAT, !1, 0, 0);
1375
+ const A = l.getAttribLocation(this.drawProgram, "a_is_curr");
1376
+ l.bindBuffer(l.ARRAY_BUFFER, this.particleIsCurrBuffer), l.enableVertexAttribArray(A), l.vertexAttribPointer(A, 1, l.FLOAT, !1, 0, 0);
1377
+ for (const U of o)
1378
+ l.uniform1f(this.drawLocs.u_world_offset, U), l.drawArrays(l.LINES, 0, this.numParticles * 2);
1379
+ l.disableVertexAttribArray(P), l.disableVertexAttribArray(A), l.disable(l.BLEND);
1382
1380
  }
1383
- h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
1384
- const _ = mi(this.params.backdrop);
1385
- _[3] > 0 && v(_);
1386
- const S = this.params.glow > 0 ? this.renderGlow(g) : null, E = this.params.colorGrade;
1387
- h.useProgram(this.compositeProgram), O(h, this.screenTextures[1], 0), h.uniform1i(this.compositeLocs.u_screen, 0), O(h, S ?? this.screenTextures[1], 1), h.uniform1i(this.compositeLocs.u_glow_tex, 1), h.uniform1f(
1381
+ l.bindFramebuffer(l.FRAMEBUFFER, p), l.viewport(0, 0, this.screenWidth, this.screenHeight);
1382
+ const _ = ui(this.params.backdrop);
1383
+ _[3] > 0 && g(_);
1384
+ const S = this.params.glow > 0 ? this.renderGlow(p) : null, E = this.params.colorGrade;
1385
+ l.useProgram(this.compositeProgram), O(l, this.screenTextures[1], 0), l.uniform1i(this.compositeLocs.u_screen, 0), O(l, S ?? this.screenTextures[1], 1), l.uniform1i(this.compositeLocs.u_glow_tex, 1), l.uniform1f(
1388
1386
  this.compositeLocs.u_glow,
1389
- S ? Kt * this.params.glow : 0
1390
- ), h.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...fi(E)), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.drawQuad(), h.disable(h.BLEND), y && (this.particleStateTextures.reverse(), this.particleFramebuffers.reverse()), this.screenTextures.reverse(), this.screenFramebuffers.reverse();
1387
+ S ? Zt * this.params.glow : 0
1388
+ ), l.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), l.uniform4f(this.compositeLocs.u_grade, ...hi(E)), l.enable(l.BLEND), l.blendFunc(l.SRC_ALPHA, l.ONE_MINUS_SRC_ALPHA), this.drawQuad(), l.disable(l.BLEND), y && (this.particleStateTextures.reverse(), this.particleFramebuffers.reverse()), this.screenTextures.reverse(), this.screenFramebuffers.reverse();
1391
1389
  }
1392
1390
  /**
1393
1391
  * Reduce the latest trails into the glow texture (glow.glsl), then rebind
1394
1392
  * `framebuffer` with the full viewport.
1395
1393
  */
1396
1394
  renderGlow(e) {
1397
- const t = this.gl, i = Math.ceil(this.screenWidth / We), a = Math.ceil(this.screenHeight / We);
1398
- return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, a), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, a), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1395
+ const t = this.gl, i = Math.ceil(this.screenWidth / qe), s = Math.ceil(this.screenHeight / qe);
1396
+ return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, s), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, s), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1399
1397
  }
1400
1398
  deleteGlowTarget() {
1401
1399
  this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
1402
1400
  }
1403
- renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
1404
- const u = this.gl;
1405
- u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1401
+ renderGrid(e, t, i, s, r, n, o, c = 1, d = Re, u) {
1402
+ const h = this.gl;
1403
+ h.useProgram(this.gridProgram), h.disable(h.DEPTH_TEST), h.disable(h.STENCIL_TEST), h.disable(h.BLEND), this.setGridFieldUniforms(
1406
1404
  this.gridLocs,
1407
1405
  e,
1408
1406
  t,
1409
1407
  i,
1410
- l,
1408
+ c,
1411
1409
  d,
1412
- c
1413
- ), u.uniformMatrix4fv(
1410
+ u
1411
+ ), h.uniformMatrix4fv(
1414
1412
  this.gridLocs.u_matrix,
1415
1413
  !1,
1416
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1417
- ), u.uniform4f(
1414
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1415
+ ), h.uniform4f(
1418
1416
  this.gridLocs.u_geo_bounds,
1419
1417
  o.west,
1420
1418
  o.south,
1421
1419
  o.east,
1422
1420
  o.north
1423
- ), u.uniform1f(this.gridLocs.u_world_size, r), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1424
- for (const f of n)
1425
- u.uniform1f(this.gridLocs.u_world_offset, f), u.drawElements(
1426
- u.TRIANGLES,
1421
+ ), h.uniform1f(this.gridLocs.u_world_size, r), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1422
+ for (const v of n)
1423
+ h.uniform1f(this.gridLocs.u_world_offset, v), h.drawElements(
1424
+ h.TRIANGLES,
1427
1425
  this.rasterGridIndexCount,
1428
- u.UNSIGNED_SHORT,
1426
+ h.UNSIGNED_SHORT,
1429
1427
  0
1430
1428
  );
1431
- this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
1429
+ this.unbindRasterGrid(this.gridProgram), h.disable(h.BLEND);
1432
1430
  }
1433
- renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Jt) {
1434
- const u = this.gl;
1435
- u.useProgram(this.gridGlobeProgram), yt(u, this.gridGlobeLocs, c), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1431
+ renderGridGlobe(e, t, i, s, r, n, o = 1, c = Re, d, u = jt) {
1432
+ const h = this.gl;
1433
+ h.useProgram(this.gridGlobeProgram), pt(h, this.gridGlobeLocs, u), h.disable(h.DEPTH_TEST), h.disable(h.STENCIL_TEST), h.disable(h.BLEND), this.setGridFieldUniforms(
1436
1434
  this.gridGlobeLocs,
1437
1435
  e,
1438
1436
  t,
1439
1437
  i,
1440
1438
  o,
1441
- l,
1439
+ c,
1442
1440
  d
1443
- ), u.uniformMatrix4fv(
1441
+ ), h.uniformMatrix4fv(
1444
1442
  this.gridGlobeLocs.u_matrix,
1445
1443
  !1,
1446
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1447
- ), u.uniform4f(
1444
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1445
+ ), h.uniform4f(
1448
1446
  this.gridGlobeLocs.u_geo_bounds,
1449
1447
  r.west,
1450
1448
  r.south,
1451
1449
  r.east,
1452
1450
  r.north
1453
- ), u.uniform4f(
1451
+ ), h.uniform4f(
1454
1452
  this.gridGlobeLocs.u_clipping_plane,
1455
1453
  n[0],
1456
1454
  n[1],
1457
1455
  n[2],
1458
1456
  n[3]
1459
- ), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), u.drawElements(
1460
- u.TRIANGLES,
1457
+ ), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), h.drawElements(
1458
+ h.TRIANGLES,
1461
1459
  this.rasterGridIndexCount,
1462
- u.UNSIGNED_SHORT,
1460
+ h.UNSIGNED_SHORT,
1463
1461
  0
1464
- ), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
1462
+ ), this.unbindRasterGrid(this.gridGlobeProgram), h.disable(h.BLEND);
1465
1463
  }
1466
- setGridFieldUniforms(e, t, i, a, r, n, o) {
1467
- const l = this.gl, d = { unit: t, min: i, max: a }, c = o ?? { a: d, b: d, mix: 0 };
1468
- Te(l, e, c), l.uniform1i(e.u_field, c.a.unit), l.uniform4f(e.u_solid, ...n), O(l, this.colorRampTexture, 2), l.uniform1i(e.u_color_ramp, 2);
1469
- const u = Math.sqrt(
1470
- Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
1464
+ setGridFieldUniforms(e, t, i, s, r, n, o) {
1465
+ const c = this.gl, d = { unit: t, min: i, max: s }, u = o ?? { a: d, b: d, mix: 0 };
1466
+ Te(c, e, u), c.uniform1i(e.u_field, u.a.unit), c.uniform4f(e.u_solid, ...n), O(c, this.colorRampTexture, 2), c.uniform1i(e.u_color_ramp, 2);
1467
+ const h = Math.sqrt(
1468
+ Math.max(Math.abs(i[0]), Math.abs(s[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(s[1])) ** 2
1471
1469
  );
1472
- l.uniform1f(e.u_field_min, 0), l.uniform1f(e.u_field_max, u > 0 ? u : 1), l.uniform1f(e.u_u_min, c.a.min[0]), l.uniform1f(e.u_u_max, c.a.max[0]), l.uniform1f(e.u_v_min, c.a.min[1]), l.uniform1f(e.u_v_max, c.a.max[1]), l.uniform1f(e.u_opacity, this.params.opacity * r), l.uniform1f(e.u_log_scale, this.params.logScale ? 1 : 0), l.uniform1f(e.u_vibrance, this.params.vibrance), l.uniform1f(e.u_scalar_mode, this.params.scalarMode ? 1 : 0);
1470
+ c.uniform1f(e.u_field_min, 0), c.uniform1f(e.u_field_max, h > 0 ? h : 1), c.uniform1f(e.u_u_min, u.a.min[0]), c.uniform1f(e.u_u_max, u.a.max[0]), c.uniform1f(e.u_v_min, u.a.min[1]), c.uniform1f(e.u_v_max, u.a.max[1]), c.uniform1f(e.u_opacity, this.params.opacity * r), c.uniform1f(e.u_log_scale, this.params.logScale ? 1 : 0), c.uniform1f(e.u_vibrance, this.params.vibrance), c.uniform1f(e.u_scalar_mode, this.params.scalarMode ? 1 : 0);
1473
1471
  }
1474
1472
  bindRasterGrid(e) {
1475
1473
  const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
@@ -1535,11 +1533,11 @@ class Pt {
1535
1533
  }
1536
1534
  /** Partial values take the vibrant preset; see resolveColorGrade. */
1537
1535
  setColorGrade(e) {
1538
- this.params.colorGrade = St(e);
1536
+ this.params.colorGrade = _t(e);
1539
1537
  }
1540
1538
  /** Missing values take the defaults; see resolveBackdrop. */
1541
1539
  setBackdrop(e) {
1542
- this.params.backdrop = wt(e);
1540
+ this.params.backdrop = xt(e);
1543
1541
  }
1544
1542
  /** Halo strength, clamped to [0, 1]; 0 frees the glow texture. */
1545
1543
  setGlow(e) {
@@ -1556,9 +1554,9 @@ class Pt {
1556
1554
  * or map move. Randomises the full state texture and clears trail FBOs.
1557
1555
  */
1558
1556
  resetParticles() {
1559
- const e = this.gl, t = B, i = this.makeStateData();
1560
- for (const a of this.particleStateTextures)
1561
- e.bindTexture(e.TEXTURE_2D, a), e.texImage2D(
1557
+ const e = this.gl, t = N, i = this.makeStateData();
1558
+ for (const s of this.particleStateTextures)
1559
+ e.bindTexture(e.TEXTURE_2D, s), e.texImage2D(
1562
1560
  e.TEXTURE_2D,
1563
1561
  0,
1564
1562
  this.stateFormat.internalFormat,
@@ -1587,7 +1585,7 @@ class Pt {
1587
1585
  return {
1588
1586
  particleState: this.stateFormat?.kind ?? "rgba8-packed",
1589
1587
  particleStateMode: this.params.particleState,
1590
- particleStateResolution: B,
1588
+ particleStateResolution: N,
1591
1589
  maxParticles: H,
1592
1590
  activeParticles: this.numParticles,
1593
1591
  rgba8MaxParticleZoom: this.params.rgba8MaxParticleZoom,
@@ -1624,7 +1622,7 @@ class Pt {
1624
1622
  e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
1625
1623
  }
1626
1624
  }
1627
- class Et {
1625
+ class Rt {
1628
1626
  constructor() {
1629
1627
  this.gl = null, this.texture = null, this.width = 0, this.height = 0, this.uMin = 0, this.uMax = 0, this.vMin = 0, this.vMax = 0, this.geoBounds = { west: -180, south: -90, east: 180, north: 90 }, this.scalarMode = !1, this.linearFilter = !0;
1630
1628
  }
@@ -1638,34 +1636,34 @@ class Et {
1638
1636
  * fields may use a fixed color domain so fragments never decode physical values.
1639
1637
  */
1640
1638
  update(e, t = null) {
1641
- const i = this.gl, { u: a, v: r, width: n, height: o, uMin: l, uMax: d, vMin: c, vMax: u } = e;
1642
- this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = l, this.uMax = d, this.vMin = c, this.vMax = u, this.geoBounds = e.bounds;
1643
- const f = this.scalarMode && t ? t[0] : l, p = (this.scalarMode && t ? t[1] : d) - f || 1, h = u - c || 1, g = new Uint8Array(n * o * 4);
1639
+ const i = this.gl, { u: s, v: r, width: n, height: o, uMin: c, uMax: d, vMin: u, vMax: h } = e;
1640
+ this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = c, this.uMax = d, this.vMin = u, this.vMax = h, this.geoBounds = e.bounds;
1641
+ const v = this.scalarMode && t ? t[0] : c, f = (this.scalarMode && t ? t[1] : d) - v || 1, l = h - u || 1, p = new Uint8Array(n * o * 4);
1644
1642
  for (let y = 0; y < n * o; y++) {
1645
- const v = a[y], _ = r[y];
1646
- this.scalarMode ? isNaN(v) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
1647
- Math.max(0, Math.min(1, (v - f) / p)) * 255
1648
- ), g[y * 4 + 1] = 128, g[y * 4 + 2] = 0, g[y * 4 + 3] = 255) : isNaN(v) || isNaN(_) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
1649
- Math.max(0, Math.min(1, (v - l) / p)) * 255
1650
- ), g[y * 4 + 1] = Math.round(
1651
- Math.max(0, Math.min(1, (_ - c) / h)) * 255
1652
- ), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
1643
+ const g = s[y], _ = r[y];
1644
+ this.scalarMode ? isNaN(g) ? (p[y * 4] = 0, p[y * 4 + 1] = 0, p[y * 4 + 2] = 0, p[y * 4 + 3] = 0) : (p[y * 4] = Math.round(
1645
+ Math.max(0, Math.min(1, (g - v) / f)) * 255
1646
+ ), p[y * 4 + 1] = 128, p[y * 4 + 2] = 0, p[y * 4 + 3] = 255) : isNaN(g) || isNaN(_) ? (p[y * 4] = 0, p[y * 4 + 1] = 0, p[y * 4 + 2] = 0, p[y * 4 + 3] = 0) : (p[y * 4] = Math.round(
1647
+ Math.max(0, Math.min(1, (g - c) / f)) * 255
1648
+ ), p[y * 4 + 1] = Math.round(
1649
+ Math.max(0, Math.min(1, (_ - u) / l)) * 255
1650
+ ), p[y * 4 + 2] = 0, p[y * 4 + 3] = 255);
1653
1651
  }
1654
1652
  if (e.latDescending) {
1655
- const y = n * 4, v = new Uint8Array(y);
1653
+ const y = n * 4, g = new Uint8Array(y);
1656
1654
  for (let _ = 0, S = o - 1; _ < S; _++, S--)
1657
- v.set(g.subarray(_ * y, (_ + 1) * y)), g.copyWithin(_ * y, S * y, (S + 1) * y), g.set(v, S * y);
1655
+ g.set(p.subarray(_ * y, (_ + 1) * y)), p.copyWithin(_ * y, S * y, (S + 1) * y), p.set(g, S * y);
1658
1656
  }
1659
1657
  let x = 0, T = 0;
1660
1658
  for (let y = 0; y < n * o; y++)
1661
- g[y * 4 + 3] === 255 ? x++ : T++;
1659
+ p[y * 4 + 3] === 255 ? x++ : T++;
1662
1660
  console.log(
1663
1661
  `[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
1664
1662
  1
1665
- )}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
1663
+ )}%), nodata=${T}, uRange=[${c.toFixed(4)}, ${d.toFixed(4)}], vRange=[${u.toFixed(4)}, ${h.toFixed(4)}]`
1666
1664
  ), this.texture || (this.texture = i.createTexture());
1667
- const M = this.linearFilter ? i.LINEAR : i.NEAREST;
1668
- i.bindTexture(i.TEXTURE_2D, this.texture), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, M), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, M), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(
1665
+ const R = this.linearFilter ? i.LINEAR : i.NEAREST;
1666
+ i.bindTexture(i.TEXTURE_2D, this.texture), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, R), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, R), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(
1669
1667
  i.TEXTURE_2D,
1670
1668
  0,
1671
1669
  i.RGBA,
@@ -1674,7 +1672,7 @@ class Et {
1674
1672
  0,
1675
1673
  i.RGBA,
1676
1674
  i.UNSIGNED_BYTE,
1677
- g
1675
+ p
1678
1676
  ), i.bindTexture(i.TEXTURE_2D, null);
1679
1677
  }
1680
1678
  /** Switch between bilinear (particles) and nearest-neighbour (raster) sampling. */
@@ -1702,669 +1700,67 @@ class Et {
1702
1700
  this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
1703
1701
  }
1704
1702
  }
1705
- function Lt(s, e, t, i, a, r, n) {
1706
- const o = new Float32Array(t * i).fill(NaN), l = new Float32Array(t * i).fill(NaN);
1707
- for (const m of s)
1708
- for (let p = 0; p < m.latSize; p++)
1709
- for (let h = 0; h < m.lonSize; h++) {
1710
- const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1711
- o[x] = m.data[g];
1703
+ function Mt(a, e, t, i, s, r, n) {
1704
+ const o = new Float32Array(t * i).fill(NaN), c = new Float32Array(t * i).fill(NaN);
1705
+ for (const m of a)
1706
+ for (let f = 0; f < m.latSize; f++)
1707
+ for (let l = 0; l < m.lonSize; l++) {
1708
+ const p = f * m.lonChunkSize + l, x = (m.latStart + f) * i + (m.lonStart + l);
1709
+ o[x] = m.data[p];
1712
1710
  }
1713
1711
  for (const m of e)
1714
- for (let p = 0; p < m.latSize; p++)
1715
- for (let h = 0; h < m.lonSize; h++) {
1716
- const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1717
- l[x] = m.data[g];
1712
+ for (let f = 0; f < m.latSize; f++)
1713
+ for (let l = 0; l < m.lonSize; l++) {
1714
+ const p = f * m.lonChunkSize + l, x = (m.latStart + f) * i + (m.lonStart + l);
1715
+ c[x] = m.data[p];
1718
1716
  }
1719
- let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
1717
+ let d = 1 / 0, u = -1 / 0, h = 1 / 0, v = -1 / 0;
1720
1718
  for (let m = 0; m < o.length; m++)
1721
- isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > c && (c = o[m])), isNaN(l[m]) || (l[m] < u && (u = l[m]), l[m] > f && (f = l[m]));
1722
- return isFinite(d) || (d = -1), isFinite(c) || (c = 1), isFinite(u) || (u = -1), isFinite(f) || (f = 1), {
1719
+ isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > u && (u = o[m])), isNaN(c[m]) || (c[m] < h && (h = c[m]), c[m] > v && (v = c[m]));
1720
+ return isFinite(d) || (d = -1), isFinite(u) || (u = 1), isFinite(h) || (h = -1), isFinite(v) || (v = 1), {
1723
1721
  u: o,
1724
- v: l,
1722
+ v: c,
1725
1723
  width: i,
1726
1724
  height: t,
1727
1725
  uMin: d,
1728
- uMax: c,
1729
- vMin: u,
1730
- vMax: f,
1731
- bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
1726
+ uMax: u,
1727
+ vMin: h,
1728
+ vMax: v,
1729
+ bounds: s ?? { west: -180, south: -90, east: 180, north: 90 },
1732
1730
  latDescending: r,
1733
1731
  scalarMode: n
1734
1732
  };
1735
1733
  }
1736
- function zi(s, e, t, i) {
1737
- const a = s.indexOf("time");
1738
- if (a < 0 || !e[a] || !t[a])
1739
- return "";
1740
- const r = Math.floor((e[a] - 1) / t[a]);
1741
- return i[a] === r ? `t=${e[a]}` : "";
1742
- }
1743
- const Re = [
1744
- "depth",
1745
- "elevation",
1746
- "level",
1747
- "altitude",
1748
- "pressure_level"
1749
- ];
1750
- class Qe extends Error {
1751
- constructor(e, t) {
1752
- super(`Chunk fetch failed: ${e} ${t}`), this.name = "ZarrChunkFetchError", this.status = e, this.url = t;
1753
- }
1754
- }
1755
- class _e {
1756
- /**
1757
- * `options.chunkStore` keeps the compressed chunks across sessions (see
1758
- * chunkStore.ts); without it, chunks are only kept in memory.
1759
- */
1760
- constructor(e, t = 200, i = {}) {
1761
- this.meta = null, this.coords = null, this.initPromise = null, this.verticalName = "depth", this.timeUnits = "", this.timeCalendar = "standard", this.cache = /* @__PURE__ */ new Map(), this.abortControllers = /* @__PURE__ */ new Map(), this.bloscCodecCache = /* @__PURE__ */ new Map(), this.root = e.replace(/\/$/, ""), this.maxCacheSize = t, this.chunkStore = i.chunkStore;
1762
- }
1763
- /** The URL of a chunk, as fetched and as stored. */
1764
- chunkUrl(e, t) {
1765
- return `${this.root}/${e}/${t.join(this.getDimensionSeparator(e))}`;
1766
- }
1767
- /** The revision a stored chunk must carry to be current (see chunkRevision). */
1768
- chunkRevision(e, t) {
1769
- return zi(
1770
- this.getDimensions(e),
1771
- this.getShape(e),
1772
- this.getChunkShape(e),
1773
- t
1774
- );
1775
- }
1776
- async init() {
1777
- if (!this.coords) {
1778
- if (this.initPromise)
1779
- return this.initPromise;
1780
- this.initPromise = (async () => {
1781
- const e = await fetch(`${this.root}/.zmetadata`);
1782
- if (!e.ok)
1783
- throw new Error(`Failed to fetch .zmetadata: ${e.status}`);
1784
- this.meta = await e.json(), await this.loadCoordinates();
1785
- })();
1786
- try {
1787
- await this.initPromise;
1788
- } catch (e) {
1789
- throw this.meta = null, this.coords = null, e;
1790
- } finally {
1791
- this.initPromise = null;
1792
- }
1793
- }
1794
- }
1795
- getArrayMeta(e) {
1796
- const t = `${e}/.zarray`, i = this.meta.metadata[t];
1797
- if (!i || !("dtype" in i))
1798
- throw new Error(`No .zarray for ${e}`);
1799
- return i;
1800
- }
1801
- getAttrs(e) {
1802
- const t = `${e}/.zattrs`;
1803
- return this.meta.metadata[t] ?? {};
1804
- }
1805
- getDimensionSeparator(e) {
1806
- return this.getArrayMeta(e).dimension_separator ?? ".";
1807
- }
1808
- getShape(e) {
1809
- return this.getArrayMeta(e).shape;
1810
- }
1811
- getChunkShape(e) {
1812
- return this.getArrayMeta(e).chunks;
1813
- }
1814
- getCoords() {
1815
- if (!this.coords)
1816
- throw new Error("Call init() first");
1817
- return this.coords;
1818
- }
1819
- getTimeDimension() {
1820
- const e = this.getCoords().time, t = e.length, i = Array.from(e, (o) => this.zarrTimeToMs(o));
1821
- let a = t ? i[0] : NaN, r = a;
1822
- for (let o = 1; o < i.length; o++)
1823
- a = Math.min(a, i[o]), r = Math.max(r, i[o]);
1824
- const n = $i(i);
1825
- return {
1826
- min: a,
1827
- max: r,
1828
- step: n,
1829
- size: t,
1830
- units: this.timeUnits,
1831
- values: i
1832
- };
1833
- }
1834
- getVerticalDimension(e) {
1835
- if (!this.verticalName || e && !this.getDimensions(e).includes(this.verticalName))
1836
- return;
1837
- const t = this.getAttrs(this.verticalName), i = typeof t.units == "string" ? t.units : void 0, a = typeof t.standard_name == "string" ? t.standard_name : "", r = i?.toLowerCase() ?? "", n = a.includes("pressure") || this.verticalName.includes("pressure") || /(^|\s)(pa|hpa|bar|dbar)($|\s)/i.test(r) ? "pressure" : a.includes("elevation") || this.verticalName === "elevation" || t.positive === "up" ? "elevation" : "depth";
1838
- return {
1839
- name: this.verticalName,
1840
- label: n,
1841
- units: i,
1842
- values: Array.from(this.getCoords().vertical)
1843
- };
1844
- }
1845
- hasVariable(e) {
1846
- const t = this.meta?.metadata[`${e}/.zarray`];
1847
- return !!(t && "dtype" in t);
1848
- }
1849
- getVariableAttrs(e) {
1850
- if (!this.meta)
1851
- throw new Error("Call init() first");
1852
- if (!this.hasVariable(e))
1853
- throw new Error(`No .zarray for ${e}`);
1854
- return { ...this.getAttrs(e) };
1855
- }
1856
- getDimensions(e) {
1857
- return this.getAttrs(e)._ARRAY_DIMENSIONS ?? ["time", "latitude", "longitude"];
1858
- }
1859
- findNearestIndex(e, t) {
1860
- let i = 0, a = Math.abs(e[0] - t);
1861
- for (let r = 1; r < e.length; r++) {
1862
- const n = Math.abs(e[r] - t);
1863
- n < a && (a = n, i = r);
1864
- }
1865
- return i;
1866
- }
1867
- findTimeIndex(e) {
1868
- const t = this.getCoords();
1869
- let i;
1870
- return typeof e == "string" ? i = new Date(e).getTime() : i = e, this.findNearestIndex(t.time, this.msToZarrTime(i));
1871
- }
1872
- /**
1873
- * Convert a Unix-ms timestamp to the native time units used by this zarr
1874
- * (read from the time variable's .zattrs "units" field).
1875
- * Unsupported units are rejected during initialization rather than guessed.
1876
- */
1877
- msToZarrTime(e) {
1878
- const { refMs: t, multiplier: i } = this.parseTimeEncoding();
1879
- return (e - t) / i;
1880
- }
1881
- zarrTimeToMs(e) {
1882
- const { refMs: t, multiplier: i } = this.parseTimeEncoding();
1883
- return t + e * i;
1884
- }
1885
- parseTimeEncoding() {
1886
- const e = this.timeCalendar.toLowerCase();
1887
- if (!["standard", "gregorian", "proleptic_gregorian"].includes(e))
1888
- throw new Error(`Unsupported Zarr time calendar: ${this.timeCalendar}`);
1889
- const t = this.timeUnits.match(
1890
- /^(milliseconds?|seconds?|minutes?|hours?|days?)\s+since\s+(.+)$/i
1891
- );
1892
- if (!t)
1893
- throw new Error(
1894
- `Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
1895
- );
1896
- const i = Oi(t[2]);
1897
- if (!Number.isFinite(i))
1898
- throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
1899
- const a = t[1].toLowerCase(), r = a.startsWith("ms") || a.startsWith("milli") ? 1 : a.startsWith("s") ? 1e3 : a.startsWith("min") ? 6e4 : a.startsWith("h") ? 36e5 : 864e5;
1900
- return { refMs: i, multiplier: r };
1901
- }
1902
- findNearestLongitudeIndex(e) {
1903
- const t = this.getCoords().longitude, i = t[0], a = t[t.length - 1];
1904
- let r = e;
1905
- return i >= 0 && a > 180 ? r = (e % 360 + 360) % 360 : r = ((e + 180) % 360 + 360) % 360 - 180, this.findNearestIndex(t, r);
1906
- }
1907
- async sampleVariableAt(e, t) {
1908
- const i = this.getDimensions(e), a = this.getChunkShape(e), r = this.getShape(e), n = new Array(i.length).fill(0), o = new Array(i.length).fill(0);
1909
- for (let c = 0; c < i.length; c++) {
1910
- const u = i[c];
1911
- let f = 0;
1912
- u === "time" ? f = t.timeIdx : u === "latitude" ? f = t.latIdx : u === "longitude" ? f = t.lonIdx : (u === this.verticalName || Re.includes(u)) && (f = t.depthIdx), f = Math.max(0, Math.min(r[c] - 1, f)), n[c] = Math.floor(f / a[c]), o[c] = f - n[c] * a[c];
1913
- }
1914
- let l;
1915
- try {
1916
- l = await this.fetchChunk(e, n);
1917
- } catch (c) {
1918
- if (c instanceof Qe && (c.status === 403 || c.status === 404))
1919
- return NaN;
1920
- throw c;
1921
- }
1922
- const d = this.getFlatOffset(e, o);
1923
- return d < l.length ? l[d] : NaN;
1924
- }
1925
- getFlatOffset(e, t) {
1926
- const i = this.getArrayMeta(e), a = i.chunks;
1927
- if (i.order === "F") {
1928
- let n = 0, o = 1;
1929
- for (let l = 0; l < t.length; l++)
1930
- n += t[l] * o, o *= a[l];
1931
- return n;
1932
- }
1933
- let r = 0;
1934
- for (let n = 0; n < t.length; n++)
1935
- r = r * a[n] + t[n];
1936
- return r;
1937
- }
1938
- findDepthIndex(e) {
1939
- return this.findNearestIndex(this.getCoords().vertical, e);
1940
- }
1941
- async sampleTimeSeries(e) {
1942
- await this.init();
1943
- const t = this.getCoords(), i = this.findNearestLongitudeIndex(e.longitude), a = this.findNearestIndex(t.latitude, e.latitude), r = this.findDepthIndex(e.depth ?? 0), n = Math.max(0, e.timeStartIndex ?? 0), o = Math.min(
1944
- t.time.length - 1,
1945
- e.timeEndIndex ?? t.time.length - 1
1946
- ), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
1947
- 0,
1948
- Math.floor(e.stopAfterMissingSamples ?? 0)
1949
- );
1950
- let c = 0;
1951
- const u = [];
1952
- for (let f = n; f <= o; f += l) {
1953
- const m = {};
1954
- for (const g of e.variables)
1955
- m[g] = await this.sampleVariableAt(g, {
1956
- timeIdx: f,
1957
- depthIdx: r,
1958
- latIdx: a,
1959
- lonIdx: i
1960
- });
1961
- const p = this.zarrTimeToMs(t.time[f]);
1962
- if (u.push({
1963
- axisValue: p,
1964
- time: p,
1965
- depth: t.vertical[r],
1966
- values: m
1967
- }), c = e.variables.every(
1968
- (g) => !Number.isFinite(m[g])
1969
- ) ? c + 1 : 0, d > 0 && c >= d)
1970
- break;
1971
- }
1972
- return {
1973
- longitude: t.longitude[i],
1974
- latitude: t.latitude[a],
1975
- depth: t.vertical[r],
1976
- points: u
1977
- };
1978
- }
1979
- async sampleVerticalProfile(e) {
1980
- await this.init();
1981
- const t = this.getCoords(), i = this.findNearestLongitudeIndex(e.longitude), a = this.findNearestIndex(t.latitude, e.latitude), r = this.findTimeIndex(e.time), n = Math.max(
1982
- 0,
1983
- Math.floor(e.stopAfterMissingSamples ?? 0)
1984
- );
1985
- let o = 0;
1986
- const l = [];
1987
- let d = Array.from(
1988
- { length: t.vertical.length },
1989
- (f, m) => m
1990
- ).sort(
1991
- (f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
1992
- );
1993
- const c = Math.max(
1994
- 1,
1995
- Math.floor(e.maxDepths ?? d.length)
1996
- ), u = Math.max(
1997
- 1,
1998
- Math.floor(e.stride ?? Math.ceil(d.length / c))
1999
- );
2000
- d = d.filter((f, m) => m % u === 0).slice(0, c);
2001
- for (const f of d) {
2002
- const m = {};
2003
- for (const g of e.variables)
2004
- m[g] = await this.sampleVariableAt(g, {
2005
- timeIdx: r,
2006
- depthIdx: f,
2007
- latIdx: a,
2008
- lonIdx: i
2009
- });
2010
- const p = t.vertical[f];
2011
- if (l.push({
2012
- axisValue: p,
2013
- time: this.zarrTimeToMs(t.time[r]),
2014
- depth: p,
2015
- values: m
2016
- }), o = e.variables.every(
2017
- (g) => !Number.isFinite(m[g])
2018
- ) ? o + 1 : 0, n > 0 && o >= n)
2019
- break;
2020
- }
2021
- return {
2022
- longitude: t.longitude[i],
2023
- latitude: t.latitude[a],
2024
- time: this.zarrTimeToMs(t.time[r]),
2025
- points: l
2026
- };
2027
- }
2028
- /** Return the actual name of the vertical dimension ("depth" or "elevation"). */
2029
- getVerticalDimName() {
2030
- return this.verticalName;
2031
- }
2032
- /**
2033
- * Get chunk indices that intersect a geographic bounding box.
2034
- */
2035
- getChunksForBounds(e, t, i, a) {
2036
- const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e), l = o.indexOf("latitude"), d = o.indexOf("longitude"), c = n[l], u = n[d], f = r.latitude, m = r.longitude, p = this.findNearestIndex(f, a.north), h = this.findNearestIndex(f, a.south), g = this.findNearestIndex(m, a.west), x = this.findNearestIndex(m, a.east), T = Math.min(p, h), M = Math.max(p, h), y = Math.min(g, x), v = Math.max(g, x), _ = Math.floor(T / c), S = Math.floor(M / c), E = Math.floor(y / u), R = Math.floor(v / u), k = this.getShape(e), F = k[l], L = k[d], D = [];
2037
- for (let b = _; b <= S; b++)
2038
- for (let A = E; A <= R; A++) {
2039
- const N = b * c, C = A * u, I = Math.min(c, F - N), w = Math.min(u, L - C);
2040
- D.push({
2041
- timeIdx: t,
2042
- depthIdx: i,
2043
- latIdx: b,
2044
- lonIdx: A,
2045
- latRange: [f[N], f[N + I - 1]],
2046
- lonRange: [m[C], m[C + w - 1]],
2047
- latSize: I,
2048
- lonSize: w
2049
- });
2050
- }
2051
- return D;
2052
- }
2053
- async fetchChunk(e, t) {
2054
- return (await this.fetchChunkResult(e, t)).data;
2055
- }
2056
- /**
2057
- * Fetch one latitude/longitude chunk and extract the requested time/vertical
2058
- * plane from it. Logical coordinate indices are converted to physical Zarr
2059
- * chunk indices before fetching.
2060
- */
2061
- async fetchSpatialChunkResult(e, t) {
2062
- const i = this.getDimensions(e), a = this.getChunkShape(e), r = i.indexOf("latitude"), n = i.indexOf("longitude");
2063
- if (r < 0 || n < 0)
2064
- throw new Error(
2065
- `Variable ${e} must have latitude and longitude dimensions`
2066
- );
2067
- const o = new Array(i.length).fill(0), l = new Array(i.length).fill(0);
2068
- for (let m = 0; m < i.length; m++) {
2069
- const p = i[m];
2070
- let h = 0;
2071
- if (p === "time")
2072
- h = t.timeIndex;
2073
- else if (p === this.verticalName || Re.includes(p))
2074
- h = t.verticalIndex;
2075
- else if (p === "latitude") {
2076
- o[m] = t.latitudeChunkIndex;
2077
- continue;
2078
- } else if (p === "longitude") {
2079
- o[m] = t.longitudeChunkIndex;
2080
- continue;
2081
- }
2082
- o[m] = Math.floor(h / a[m]), l[m] = h % a[m];
2083
- }
2084
- const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
2085
- f.fill(NaN);
2086
- for (let m = 0; m < c; m++) {
2087
- l[r] = m;
2088
- for (let p = 0; p < u; p++) {
2089
- l[n] = p;
2090
- const h = this.getFlatOffset(e, l);
2091
- h < d.data.length && (f[m * u + p] = d.data[h]);
2092
- }
2093
- }
2094
- return { ...d, data: f };
2095
- }
2096
- async fetchChunkResult(e, t) {
2097
- const i = this.getDimensionSeparator(e), a = t.join(i), r = `${e}/${a}`, n = `${this.root}/${e}/${a}`;
2098
- if (this.cache.has(r))
2099
- return { data: this.cache.get(r), missing: !1, url: n };
2100
- this.abortControllers.get(r)?.abort();
2101
- const o = new AbortController();
2102
- this.abortControllers.set(r, o);
2103
- const l = this.getArrayMeta(e), d = this.chunkStore ? this.chunkRevision(e, t) : "";
2104
- try {
2105
- const c = await this.chunkStore?.get(n, d);
2106
- if (c) {
2107
- const p = Ke(
2108
- await this.decompress(c, l, e)
2109
- );
2110
- return this.cacheChunk(r, p), { data: p, missing: !1, url: n };
2111
- }
2112
- const u = await fetch(n, { signal: o.signal });
2113
- if (!u.ok) {
2114
- if (u.status === 403 || u.status === 404)
2115
- return {
2116
- data: Gi(l),
2117
- missing: !0,
2118
- status: u.status,
2119
- url: n
2120
- };
2121
- throw new Qe(u.status, n);
2122
- }
2123
- const f = new Uint8Array(await u.arrayBuffer());
2124
- this.chunkStore?.put(n, f, d);
2125
- const m = Ke(
2126
- await this.decompress(f, l, e)
2127
- );
2128
- return this.cacheChunk(r, m), { data: m, missing: !1, url: n };
2129
- } finally {
2130
- this.abortControllers.get(r) === o && this.abortControllers.delete(r);
2131
- }
2132
- }
2133
- cancelAll() {
2134
- for (const e of this.abortControllers.values())
2135
- e.abort();
2136
- this.abortControllers.clear();
2137
- }
2138
- cacheChunk(e, t) {
2139
- if (this.cache.size >= this.maxCacheSize) {
2140
- const i = this.cache.keys().next().value;
2141
- i !== void 0 && this.cache.delete(i);
2142
- }
2143
- this.cache.set(e, t);
2144
- }
2145
- getBloscCodec(e) {
2146
- const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
2147
- let a = this.bloscCodecCache.get(i);
2148
- return a || (a = yi.fromConfig({
2149
- id: "blosc",
2150
- cname: t.cname ?? "lz4",
2151
- clevel: t.clevel ?? 5,
2152
- shuffle: t.shuffle ?? 1,
2153
- blocksize: t.blocksize ?? 0
2154
- }), this.bloscCodecCache.set(i, a)), a;
2155
- }
2156
- async decompress(e, t, i) {
2157
- let a;
2158
- if (t.compressor)
2159
- switch (t.compressor.id) {
2160
- case "zlib":
2161
- case "gzip":
2162
- a = vi(e);
2163
- break;
2164
- case "blosc": {
2165
- a = await this.getBloscCodec(t).decode(e);
2166
- break;
2167
- }
2168
- default:
2169
- throw new Error(`Unsupported compressor: ${t.compressor.id}`);
2170
- }
2171
- else
2172
- a = e;
2173
- let r;
2174
- const n = t.dtype;
2175
- if (n === "<f4" || n === "|f4")
2176
- r = new Float32Array(
2177
- a.buffer,
2178
- a.byteOffset,
2179
- a.byteLength / 4
2180
- );
2181
- else if (n === "<f8" || n === "|f8")
2182
- r = new Float64Array(
2183
- a.buffer,
2184
- a.byteOffset,
2185
- a.byteLength / 8
2186
- );
2187
- else if (n === "<i2" || n === "|i2") {
2188
- const l = new Int16Array(
2189
- a.buffer,
2190
- a.byteOffset,
2191
- a.byteLength / 2
2192
- );
2193
- r = Float32Array.from(l);
2194
- } else if (n === "<i4" || n === "|i4") {
2195
- const l = new Int32Array(
2196
- a.buffer,
2197
- a.byteOffset,
2198
- a.byteLength / 4
2199
- );
2200
- r = Float32Array.from(l);
2201
- } else if (n === "<i8" || n === "|i8") {
2202
- const l = new DataView(
2203
- a.buffer,
2204
- a.byteOffset,
2205
- a.byteLength
2206
- ), d = a.byteLength / 8;
2207
- r = new Float64Array(d);
2208
- for (let c = 0; c < d; c++)
2209
- r[c] = Number(l.getBigInt64(c * 8, !0));
2210
- } else
2211
- throw new Error(`Unsupported dtype: ${n}`);
2212
- const o = t.fill_value;
2213
- if (o != null && typeof o == "number" && !isNaN(o))
2214
- for (let l = 0; l < r.length; l++)
2215
- r[l] === o && (r[l] = NaN);
2216
- if (i) {
2217
- const l = this.getAttrs(i), d = l.scale_factor, c = l.add_offset;
2218
- if (d != null || c != null) {
2219
- const u = d ?? 1, f = c ?? 0;
2220
- for (let m = 0; m < r.length; m++)
2221
- isNaN(r[m]) || (r[m] = r[m] * u + f);
2222
- }
2223
- }
2224
- return r;
2225
- }
2226
- async loadCoordinates() {
2227
- const e = async (l) => {
2228
- const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
2229
- for (let g = 0; g < u; g++) {
2230
- const x = `${this.root}/${l}/${g}`, T = await fetch(x);
2231
- if (!T.ok)
2232
- throw new Error(`Failed to fetch coord ${l}/${g}`);
2233
- const M = new Uint8Array(await T.arrayBuffer());
2234
- f.push(await this.decompress(M, d));
2235
- }
2236
- if (f.length === 1)
2237
- return f[0].length > c ? f[0].subarray(0, c) : f[0];
2238
- const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(c);
2239
- let h = 0;
2240
- for (const g of f) {
2241
- const x = Math.min(g.length, c - h);
2242
- if (p.set(g.subarray(0, x), h), h += x, h >= c)
2243
- break;
2244
- }
2245
- return p;
2246
- };
2247
- let t = null;
2248
- for (const l of Re) {
2249
- const d = `${l}/.zarray`;
2250
- if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
2251
- t = l;
2252
- break;
2253
- }
2254
- }
2255
- this.verticalName = t ?? "";
2256
- const i = this.getAttrs("time");
2257
- this.timeUnits = i.units ?? "", this.timeCalendar = i.calendar ?? "standard", this.parseTimeEncoding();
2258
- const [a, r, n] = await Promise.all([
2259
- e("time"),
2260
- e("latitude"),
2261
- e("longitude")
2262
- ]);
2263
- let o;
2264
- t ? o = await e(t) : o = new Float32Array([0]), this.coords = {
2265
- time: a,
2266
- vertical: o,
2267
- latitude: r,
2268
- longitude: n
2269
- };
2270
- }
2271
- }
2272
- function Ke(s) {
2273
- return s instanceof Float32Array ? s : Float32Array.from(s);
2274
- }
2275
- function Gi(s) {
2276
- const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
2277
- return t.fill(NaN), t;
2278
- }
2279
- function Oi(s) {
2280
- const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
2281
- /^(\d{4})-(\d{2})-(\d{2})(?:(?:T|\s+)(\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/i
2282
- );
2283
- if (!t)
2284
- return NaN;
2285
- const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0), l = Number(t[6] ?? 0), d = Number((t[7] ?? "").padEnd(3, "0").slice(0, 3)), c = t[8] ?? "Z";
2286
- if (a < 1 || a > 12 || n > 23 || o > 59 || l > 59)
2287
- return NaN;
2288
- const u = /* @__PURE__ */ new Date(0);
2289
- u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
2290
- const f = u.getTime();
2291
- if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
2292
- return NaN;
2293
- if (/^z$/i.test(c))
2294
- return f;
2295
- const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
2296
- if (!m)
2297
- return NaN;
2298
- const p = Number(m[2]), h = Number(m[3]);
2299
- if (p > 23 || h > 59)
2300
- return NaN;
2301
- const g = (p * 60 + h) * 6e4;
2302
- return f - (m[1] === "+" ? g : -g);
2303
- }
2304
- function Bi(s) {
2305
- if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
2306
- return s;
2307
- const e = [
2308
- 60 * 1e3,
2309
- 180 * 1e3,
2310
- 300 * 1e3,
2311
- 600 * 1e3,
2312
- 900 * 1e3,
2313
- 1800 * 1e3,
2314
- 3600 * 1e3,
2315
- 10800 * 1e3,
2316
- 360 * 60 * 1e3,
2317
- 720 * 60 * 1e3,
2318
- 1440 * 60 * 1e3,
2319
- 10080 * 60 * 1e3
2320
- ];
2321
- for (const t of e)
2322
- if (Math.abs(s - t) <= Math.max(1e3, t * 0.02))
2323
- return t;
2324
- return Math.round(s);
2325
- }
2326
- function $i(s) {
2327
- if (s.length < 2)
2328
- return;
2329
- const e = s[1] - s[0];
2330
- if (!Number.isFinite(e) || e <= 0)
2331
- return;
2332
- const t = Math.max(1, Math.abs(e) * 1e-9);
2333
- for (let i = 2; i < s.length; i++)
2334
- if (Math.abs(s[i] - s[i - 1] - e) > t)
2335
- return;
2336
- return Bi(e);
2337
- }
2338
1734
  class xe extends Error {
2339
1735
  constructor(e, t, i) {
2340
1736
  super(
2341
1737
  t.length > 0 ? "Remote data is not available yet; the selected frame may still be publishing." : "The selected frame contains no renderable data."
2342
- ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
1738
+ ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((s, r) => s - r), this.urls = [...new Set(i)];
2343
1739
  }
2344
1740
  }
2345
- function qi(s) {
2346
- for (const e of s)
1741
+ function Fi(a) {
1742
+ for (const e of a)
2347
1743
  if (Number.isFinite(e))
2348
1744
  return !0;
2349
1745
  return !1;
2350
1746
  }
2351
- function Wi(s, e) {
2352
- for (let t = 0; t < Math.min(s.length, e.length); t++)
2353
- if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
1747
+ function Vi(a, e) {
1748
+ for (let t = 0; t < Math.min(a.length, e.length); t++)
1749
+ if (Number.isFinite(a[t]) && Number.isFinite(e[t]))
2354
1750
  return !0;
2355
1751
  return !1;
2356
1752
  }
2357
- function Dt(s) {
1753
+ function Pt(a) {
2358
1754
  return {
2359
1755
  phase: "blocked",
2360
- time: s.time,
2361
- statuses: s.statuses,
2362
- message: s.message
1756
+ time: a.time,
1757
+ statuses: a.statuses,
1758
+ message: a.message
2363
1759
  };
2364
1760
  }
2365
1761
  class me {
2366
1762
  constructor(e) {
2367
- this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new _e(e.source), this.activeField = new Et(), this.simulation = new Pt({
1763
+ this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new ve(e.source), this.activeField = new Rt(), this.simulation = new Tt({
2368
1764
  colorRamp: e.colorRamp,
2369
1765
  opacity: e.opacity ?? 1,
2370
1766
  logScale: e.logScale ?? !1,
@@ -2396,12 +1792,12 @@ class me {
2396
1792
  const i = K(e);
2397
1793
  if (this.suspended || !this.map || !this.activeData || !this.activeField.hasData())
2398
1794
  return;
2399
- const a = Ge(i);
1795
+ const s = Ge(i);
2400
1796
  try {
2401
1797
  const r = i.canvas;
2402
- this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
2403
- const n = this.map.getBounds(), o = t.defaultProjectionData, l = ye(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
2404
- this.activeField.bind(this.textureUnit), l ? this.simulation.renderGridGlobe(
1798
+ this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, s.framebuffer), i.viewport(0, 0, r.width, r.height);
1799
+ const n = this.map.getBounds(), o = t.defaultProjectionData, c = _e(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
1800
+ this.activeField.bind(this.textureUnit), c ? this.simulation.renderGridGlobe(
2405
1801
  this.textureUnit,
2406
1802
  [this.activeData.uMin, this.activeData.vMin],
2407
1803
  [this.activeData.uMax, this.activeData.vMax],
@@ -2418,12 +1814,12 @@ class me {
2418
1814
  [this.activeData.uMax, this.activeData.vMax],
2419
1815
  t.modelViewProjectionMatrix,
2420
1816
  d,
2421
- Be(n, !1),
1817
+ Ne(n, !1),
2422
1818
  this.activeField.geoBounds,
2423
1819
  1
2424
1820
  );
2425
1821
  } finally {
2426
- Oe(i, a);
1822
+ Oe(i, s);
2427
1823
  }
2428
1824
  if (this.pendingReadyTime != null) {
2429
1825
  const r = this.pendingReadyTime;
@@ -2535,28 +1931,28 @@ class me {
2535
1931
  return;
2536
1932
  }
2537
1933
  this.loading = !0, this.emit("loading");
2538
- const e = this.generation, t = this.requestId, i = this.time, a = this.timeToMs(i);
1934
+ const e = this.generation, t = this.requestId, i = this.time, s = this.timeToMs(i);
2539
1935
  try {
2540
1936
  if (await this.zarrSource.init(), e !== this.generation || t !== this.requestId)
2541
1937
  return;
2542
1938
  this.initialized = !0;
2543
- const r = this.frameCache.get(a) ?? await this.fetchScalarData(i, (n, o) => {
1939
+ const r = this.frameCache.get(s) ?? await this.fetchScalarData(i, (n, o) => {
2544
1940
  e === this.generation && t === this.requestId && this.emit("status", {
2545
1941
  phase: "fetching",
2546
- time: a,
1942
+ time: s,
2547
1943
  completed: n,
2548
1944
  total: o
2549
1945
  });
2550
1946
  });
2551
1947
  if (e !== this.generation || t !== this.requestId)
2552
1948
  return;
2553
- this.frameCache.set(a, r), this.setActive(r, i);
1949
+ this.frameCache.set(s, r), this.setActive(r, i);
2554
1950
  } catch (r) {
2555
1951
  if (r.name !== "AbortError") {
2556
1952
  const n = r instanceof Error ? r : new Error(String(r));
2557
1953
  e === this.generation && t === this.requestId && (this.emit(
2558
1954
  "status",
2559
- n instanceof xe ? Dt(n) : { phase: "error", time: a, error: n }
1955
+ n instanceof xe ? Pt(n) : { phase: "error", time: s, error: n }
2560
1956
  ), this.emit("error", n));
2561
1957
  }
2562
1958
  } finally {
@@ -2564,7 +1960,7 @@ class me {
2564
1960
  }
2565
1961
  }
2566
1962
  async fetchScalarData(e, t) {
2567
- const i = this.map.getBounds(), a = {
1963
+ const i = this.map.getBounds(), s = {
2568
1964
  west: -180,
2569
1965
  east: 180,
2570
1966
  south: Math.max(i.getSouth(), -85),
@@ -2573,14 +1969,14 @@ class me {
2573
1969
  this.variable,
2574
1970
  r,
2575
1971
  n,
2576
- a
2577
- ), l = this.zarrSource.getDimensions(this.variable), d = l.indexOf("latitude"), c = l.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
2578
- let f = 0;
2579
- const m = o.length, p = [], h = [];
2580
- t?.(f, m);
2581
- const g = await Promise.all(
1972
+ s
1973
+ ), c = this.zarrSource.getDimensions(this.variable), d = c.indexOf("latitude"), u = c.indexOf("longitude"), h = this.zarrSource.getChunkShape(this.variable);
1974
+ let v = 0;
1975
+ const m = o.length, f = [], l = [];
1976
+ t?.(v, m);
1977
+ const p = await Promise.all(
2582
1978
  o.map(async (b) => {
2583
- const A = await this.zarrSource.fetchSpatialChunkResult(
1979
+ const V = await this.zarrSource.fetchSpatialChunkResult(
2584
1980
  this.variable,
2585
1981
  {
2586
1982
  timeIndex: b.timeIdx,
@@ -2589,38 +1985,38 @@ class me {
2589
1985
  longitudeChunkIndex: b.lonIdx
2590
1986
  }
2591
1987
  );
2592
- return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
2593
- data: A.data,
2594
- latStart: b.latIdx * u[d],
2595
- lonStart: b.lonIdx * u[c],
1988
+ return V.missing && (V.status != null && f.push(V.status), l.push(V.url)), v++, t?.(v, m), {
1989
+ data: V.data,
1990
+ latStart: b.latIdx * h[d],
1991
+ lonStart: b.lonIdx * h[u],
2596
1992
  latSize: b.latSize,
2597
1993
  lonSize: b.lonSize,
2598
- lonChunkSize: u[c]
1994
+ lonChunkSize: h[u]
2599
1995
  };
2600
1996
  })
2601
- ), x = Math.min(...g.map((b) => b.latStart)), T = Math.max(...g.map((b) => b.latStart + b.latSize)), M = Math.min(...g.map((b) => b.lonStart)), y = Math.max(...g.map((b) => b.lonStart + b.lonSize)), v = T - x, _ = y - M, S = g.map((b) => ({
1997
+ ), x = Math.min(...p.map((b) => b.latStart)), T = Math.max(...p.map((b) => b.latStart + b.latSize)), R = Math.min(...p.map((b) => b.lonStart)), y = Math.max(...p.map((b) => b.lonStart + b.lonSize)), g = T - x, _ = y - R, S = p.map((b) => ({
2602
1998
  ...b,
2603
1999
  latStart: b.latStart - x,
2604
- lonStart: b.lonStart - M
2605
- })), E = this.zarrSource.getCoords(), R = Math.min(T - 1, E.latitude.length - 1), k = Math.min(y - 1, E.longitude.length - 1), F = Tt(
2000
+ lonStart: b.lonStart - R
2001
+ })), E = this.zarrSource.getCoords(), P = Math.min(T - 1, E.latitude.length - 1), A = Math.min(y - 1, E.longitude.length - 1), U = bt(
2606
2002
  E.longitude,
2607
2003
  E.latitude,
2608
- [M, k],
2609
- [x, R]
2610
- ), L = E.latitude[x] > E.latitude[R], D = Lt(
2004
+ [R, A],
2005
+ [x, P]
2006
+ ), L = E.latitude[x] > E.latitude[P], D = Mt(
2611
2007
  S,
2612
2008
  [],
2613
- v,
2009
+ g,
2614
2010
  _,
2615
- F,
2011
+ U,
2616
2012
  L,
2617
2013
  !0
2618
2014
  );
2619
- if (!qi(D.u))
2015
+ if (!Fi(D.u))
2620
2016
  throw new xe(
2621
2017
  this.timeToMs(e),
2622
- p,
2623
- h
2018
+ f,
2019
+ l
2624
2020
  );
2625
2021
  return D;
2626
2022
  }
@@ -2629,8 +2025,8 @@ class me {
2629
2025
  this.emit("status", { phase: "rendering", time: i }), this.activeData = e, this.activeField.update(e, this.colorDomain), this.activeField.setFilter(!1), this.emit("loaded", this.computeFieldMeta(e, t)), this.pendingReadyTime = i, this.map?.triggerRepaint();
2630
2026
  }
2631
2027
  sampleActiveData(e, t, i) {
2632
- const { west: a, east: r, south: n, north: o } = e.bounds, l = r - a, d = o - n;
2633
- if (e.width <= 0 || e.height <= 0 || l <= 0 || d <= 0)
2028
+ const { west: s, east: r, south: n, north: o } = e.bounds, c = r - s, d = o - n;
2029
+ if (e.width <= 0 || e.height <= 0 || c <= 0 || d <= 0)
2634
2030
  return {
2635
2031
  longitude: t,
2636
2032
  latitude: i,
@@ -2639,8 +2035,8 @@ class me {
2639
2035
  time: this.timeToMs(this.time),
2640
2036
  depth: this.depth
2641
2037
  };
2642
- const c = a + ((t - a) % 360 + 360) % 360;
2643
- if (c > r && l < 359 || i < n || i > o)
2038
+ const u = s + ((t - s) % 360 + 360) % 360;
2039
+ if (u > r && c < 359 || i < n || i > o)
2644
2040
  return {
2645
2041
  longitude: t,
2646
2042
  latitude: i,
@@ -2649,17 +2045,17 @@ class me {
2649
2045
  time: this.timeToMs(this.time),
2650
2046
  depth: this.depth
2651
2047
  };
2652
- const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2048
+ const h = (u - s) / c, v = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2653
2049
  0,
2654
- Math.min(e.width - 1, Math.floor(u * e.width))
2655
- ), p = Math.max(
2050
+ Math.min(e.width - 1, Math.floor(h * e.width))
2051
+ ), f = Math.max(
2656
2052
  0,
2657
- Math.min(e.height - 1, Math.floor(f * e.height))
2658
- ), h = e.u[p * e.width + m] ?? NaN, g = a + (m + 0.5) / e.width * l, x = e.latDescending ? o - (p + 0.5) / e.height * d : n + (p + 0.5) / e.height * d;
2053
+ Math.min(e.height - 1, Math.floor(v * e.height))
2054
+ ), l = e.u[f * e.width + m] ?? NaN, p = s + (m + 0.5) / e.width * c, x = e.latDescending ? o - (f + 0.5) / e.height * d : n + (f + 0.5) / e.height * d;
2659
2055
  return {
2660
- longitude: g,
2056
+ longitude: p,
2661
2057
  latitude: x,
2662
- value: h,
2058
+ value: l,
2663
2059
  unit: this.unit,
2664
2060
  time: this.timeToMs(this.time),
2665
2061
  depth: this.depth
@@ -2681,38 +2077,38 @@ class me {
2681
2077
  emit(e, ...t) {
2682
2078
  const i = this.listeners.get(e);
2683
2079
  if (i)
2684
- for (const a of i)
2685
- a(...t);
2080
+ for (const s of i)
2081
+ s(...t);
2686
2082
  }
2687
2083
  }
2688
- function Xi(s, e, t) {
2689
- if (!Number.isFinite(s) || !Number.isFinite(e))
2084
+ function Ui(a, e, t) {
2085
+ if (!Number.isFinite(a) || !Number.isFinite(e))
2690
2086
  return { u: NaN, v: NaN };
2691
- const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
2087
+ const i = t.direction_convention !== t.output_direction ? 180 : 0, s = (a + i) * Math.PI / 180;
2692
2088
  return {
2693
- u: e * Math.sin(a),
2694
- v: e * Math.cos(a)
2089
+ u: e * Math.sin(s),
2090
+ v: e * Math.cos(s)
2695
2091
  };
2696
2092
  }
2697
- function Aa(s) {
2698
- return [s.direction_variable, s.magnitude_variable];
2093
+ function _a(a) {
2094
+ return [a.direction_variable, a.magnitude_variable];
2699
2095
  }
2700
- const Hi = 0.7;
2701
- class P {
2096
+ const Ii = 0.7;
2097
+ class M {
2702
2098
  constructor(e) {
2703
2099
  if (this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.reloadQueuedResetParticles = !1, this.globeRendering = null, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.velocityTexUnit = 1, this.moveStartHandler = null, this.moveHandler = null, this.moveEndHandler = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.geoVideoManifest = e.geoVideo?.manifest, this.geoVideoManifest && this.geoVideoManifest.encoding.kind !== "vector-luma")
2704
2100
  throw new Error("Vector GeoVideo requires a vector-luma manifest");
2705
- this.playback = e.geoVideo ? new _t(
2101
+ this.playback = e.geoVideo ? new gt(
2706
2102
  { ...e.geoVideo, time: e.time },
2707
2103
  () => this.map?.triggerRepaint(),
2708
2104
  (t, ...i) => {
2709
2105
  if (t === "loaded") {
2710
2106
  this.initialized = !0;
2711
- const a = i[0], r = this.playback?.field?.manifest.encoding;
2107
+ const s = i[0], r = this.playback?.field?.manifest.encoding;
2712
2108
  this.emit("loaded", {
2713
- ...a,
2109
+ ...s,
2714
2110
  min: 0,
2715
- max: r?.kind === "vector-luma" ? Math.SQRT2 * r.valueDomain : a.max,
2111
+ max: r?.kind === "vector-luma" ? Math.SQRT2 * r.valueDomain : s.max,
2716
2112
  unit: this.unit,
2717
2113
  depth: this.depth
2718
2114
  });
@@ -2720,16 +2116,16 @@ class P {
2720
2116
  }
2721
2117
  t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
2722
2118
  }
2723
- ) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new _e(e.source), this.velocityField = new Et(), this.simulation = new Pt({
2119
+ ) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new ve(e.source), this.velocityField = new Rt(), this.simulation = new Tt({
2724
2120
  particleDensity: e.particleDensity ?? 0.05,
2725
2121
  speed: e.speed ?? 1,
2726
- fadeOpacity: Xe(e.fade ?? Hi),
2122
+ fadeOpacity: We(e.fade ?? Ii),
2727
2123
  colorRamp: e.colorRamp,
2728
2124
  opacity: e.opacity ?? 1,
2729
2125
  logScale: e.logScale ?? !1,
2730
2126
  vibrance: e.vibrance ?? 0,
2731
- colorGrade: St(e.colorGrade),
2732
- backdrop: wt(e.backdrop),
2127
+ colorGrade: _t(e.colorGrade),
2128
+ backdrop: xt(e.backdrop),
2733
2129
  glow: e.glow ?? 0,
2734
2130
  particleState: e.particleState ?? "auto",
2735
2131
  rgba8MaxParticleZoom: e.rgba8MaxParticleZoom ?? 4
@@ -2742,8 +2138,8 @@ class P {
2742
2138
  }
2743
2139
  async onAdd(e, t) {
2744
2140
  const i = K(t);
2745
- this.map = e, this.gl = i, this.simulation.init(i), this.velocityField.init(i), this.playback && this.geoVideoManifest ? (this.emit("loading"), this.emit("status", { phase: "metadata" }), this.playback.load(i, this.geoVideoManifest).catch((a) => {
2746
- const r = a instanceof Error ? a : new Error(String(a));
2141
+ this.map = e, this.gl = i, this.simulation.init(i), this.velocityField.init(i), this.playback && this.geoVideoManifest ? (this.emit("loading"), this.emit("status", { phase: "metadata" }), this.playback.load(i, this.geoVideoManifest).catch((s) => {
2142
+ const r = s instanceof Error ? s : new Error(String(s));
2747
2143
  r.name !== "AbortError" && this.map && (this.playback?.pause(), this.emit("status", { phase: "error", error: r }), this.emit("error", r));
2748
2144
  })) : this.initAsync(), this.moveStartHandler = () => {
2749
2145
  this.suspended || (this.simulation.setCameraMoving(!0), this.map?.triggerRepaint());
@@ -2777,9 +2173,9 @@ class P {
2777
2173
  };
2778
2174
  }
2779
2175
  isViewportCovered() {
2780
- return !this.map || !this.velocityField.hasData() ? !1 : Ti(
2176
+ return !this.map || !this.velocityField.hasData() ? !1 : _i(
2781
2177
  this.velocityField.geoBounds,
2782
- Si(this.map.getBounds())
2178
+ vi(this.map.getBounds())
2783
2179
  );
2784
2180
  }
2785
2181
  reloadIfViewportUncovered() {
@@ -2796,37 +2192,37 @@ class P {
2796
2192
  * The map's current viewport is used to determine the lat bounds of the request.
2797
2193
  */
2798
2194
  async fetchVelocityData(e, t) {
2799
- const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r = wi(i, 1, a), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
2195
+ const i = this.map.getBounds(), s = this.globeRendering ?? _e(this.map), r = yi(i, 1, s), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
2800
2196
  console.log(
2801
2197
  `[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
2802
2198
  );
2803
- const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2804
- l,
2199
+ const c = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2200
+ c,
2805
2201
  n,
2806
2202
  o,
2807
2203
  r
2808
- ), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
2204
+ ), u = this.zarrSource.getDimensions(c), h = u.indexOf("latitude"), v = u.indexOf("longitude");
2809
2205
  let m = 0;
2810
- const p = d.length * 2, h = [], g = [];
2811
- t?.(m, p);
2812
- const x = (w) => d.map(async (U) => {
2813
- const X = await this.zarrSource.fetchSpatialChunkResult(w, {
2814
- timeIndex: U.timeIdx,
2815
- verticalIndex: U.depthIdx,
2816
- latitudeChunkIndex: U.latIdx,
2817
- longitudeChunkIndex: U.lonIdx
2206
+ const f = d.length * 2, l = [], p = [];
2207
+ t?.(m, f);
2208
+ const x = (w) => d.map(async (k) => {
2209
+ const W = await this.zarrSource.fetchSpatialChunkResult(w, {
2210
+ timeIndex: k.timeIdx,
2211
+ verticalIndex: k.depthIdx,
2212
+ latitudeChunkIndex: k.latIdx,
2213
+ longitudeChunkIndex: k.lonIdx
2818
2214
  });
2819
- X.missing && (X.status != null && h.push(X.status), g.push(X.url)), m++, t?.(m, p);
2820
- const oe = this.zarrSource.getChunkShape(w), le = oe[f];
2215
+ W.missing && (W.status != null && l.push(W.status), p.push(W.url)), m++, t?.(m, f);
2216
+ const oe = this.zarrSource.getChunkShape(w), le = oe[v];
2821
2217
  return {
2822
- data: X.data,
2823
- latStart: U.latIdx * oe[u],
2824
- lonStart: U.lonIdx * le,
2825
- latSize: U.latSize,
2826
- lonSize: U.lonSize,
2218
+ data: W.data,
2219
+ latStart: k.latIdx * oe[h],
2220
+ lonStart: k.lonIdx * le,
2221
+ latSize: k.latSize,
2222
+ lonSize: k.lonSize,
2827
2223
  lonChunkSize: le
2828
2224
  };
2829
- }), [T, M] = this.vectorDerivation ? Yi(
2225
+ }), [T, R] = this.vectorDerivation ? zi(
2830
2226
  await Promise.all(
2831
2227
  x(this.vectorDerivation.direction_variable)
2832
2228
  ),
@@ -2837,32 +2233,32 @@ class P {
2837
2233
  ) : await Promise.all([
2838
2234
  Promise.all(x(this.variableU)),
2839
2235
  Promise.all(x(this.variableV))
2840
- ]), y = Math.min(...T.map((w) => w.latStart)), v = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)), E = v - y, R = S - _, k = T.map((w) => ({
2236
+ ]), y = Math.min(...T.map((w) => w.latStart)), g = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)), E = g - y, P = S - _, A = T.map((w) => ({
2841
2237
  ...w,
2842
2238
  latStart: w.latStart - y,
2843
2239
  lonStart: w.lonStart - _
2844
- })), F = M.map((w) => ({
2240
+ })), U = R.map((w) => ({
2845
2241
  ...w,
2846
2242
  latStart: w.latStart - y,
2847
2243
  lonStart: w.lonStart - _
2848
- })), L = this.zarrSource.getCoords(), D = Math.min(v - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), A = Tt(
2244
+ })), L = this.zarrSource.getCoords(), D = Math.min(g - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), V = bt(
2849
2245
  L.longitude,
2850
2246
  L.latitude,
2851
2247
  [_, b],
2852
2248
  [y, D]
2853
- ), N = L.latitude[y] > L.latitude[D], C = Lt(
2854
- k,
2855
- F,
2856
- E,
2857
- R,
2249
+ ), X = L.latitude[y] > L.latitude[D], C = Mt(
2858
2250
  A,
2859
- N
2251
+ U,
2252
+ E,
2253
+ P,
2254
+ V,
2255
+ X
2860
2256
  ), I = this.zarrSource.getValueDomain?.();
2861
- if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !Wi(C.u, C.v))
2257
+ if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !Vi(C.u, C.v))
2862
2258
  throw new xe(
2863
2259
  this.timeToMs(e),
2864
- h,
2865
- g
2260
+ l,
2261
+ p
2866
2262
  );
2867
2263
  return C;
2868
2264
  }
@@ -2874,7 +2270,7 @@ class P {
2874
2270
  return;
2875
2271
  }
2876
2272
  this.loading = !0, this.emit("loading");
2877
- const t = this.generation, i = this.requestId, a = this.time, r = this.timeToMs(a);
2273
+ const t = this.generation, i = this.requestId, s = this.time, r = this.timeToMs(s);
2878
2274
  try {
2879
2275
  if (await this.zarrSource.init(), t !== this.generation || i !== this.requestId)
2880
2276
  return;
@@ -2884,12 +2280,12 @@ class P {
2884
2280
  n = this.frameCache.get(r);
2885
2281
  else {
2886
2282
  const o = await this.fetchVelocityData(
2887
- a,
2888
- (l, d) => {
2283
+ s,
2284
+ (c, d) => {
2889
2285
  t === this.generation && i === this.requestId && this.emit("status", {
2890
2286
  phase: "fetching",
2891
2287
  time: r,
2892
- completed: l,
2288
+ completed: c,
2893
2289
  total: d
2894
2290
  });
2895
2291
  }
@@ -2900,13 +2296,13 @@ class P {
2900
2296
  }
2901
2297
  if (t !== this.generation || i !== this.requestId)
2902
2298
  return;
2903
- this.emit("status", { phase: "rendering", time: r }), this.velocityField.update(n), e.resetParticles && this.simulation.resetParticles(), this.emit("loaded", this.computeFieldMeta(n, a)), this.pendingReadyTime = r, this.map?.triggerRepaint();
2299
+ this.emit("status", { phase: "rendering", time: r }), this.velocityField.update(n), e.resetParticles && this.simulation.resetParticles(), this.emit("loaded", this.computeFieldMeta(n, s)), this.pendingReadyTime = r, this.map?.triggerRepaint();
2904
2300
  } catch (n) {
2905
2301
  if (n.name !== "AbortError") {
2906
2302
  const o = n instanceof Error ? n : new Error(String(n));
2907
2303
  console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
2908
2304
  "status",
2909
- o instanceof xe ? Dt(o) : { phase: "error", time: r, error: o }
2305
+ o instanceof xe ? Pt(o) : { phase: "error", time: r, error: o }
2910
2306
  ), this.emit("error", o));
2911
2307
  }
2912
2308
  } finally {
@@ -2917,72 +2313,72 @@ class P {
2917
2313
  }
2918
2314
  }
2919
2315
  render(e, t) {
2920
- const i = K(e), a = t.modelViewProjectionMatrix;
2316
+ const i = K(e), s = t.modelViewProjectionMatrix;
2921
2317
  if (this.suspended || !this.map)
2922
2318
  return;
2923
2319
  const r = this.playback?.sample(performance.now()), n = this.playback?.field;
2924
2320
  if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
2925
2321
  return;
2926
2322
  n?.setFilter(this.simulation.renderMode !== "raster");
2927
- const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, l = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], d = n ? [o, o] : [this.velocityField.uMax, this.velocityField.vMax], c = n ? {
2323
+ const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, c = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], d = n ? [o, o] : [this.velocityField.uMax, this.velocityField.vMax], u = n ? {
2928
2324
  west: n.bounds[0],
2929
2325
  south: n.bounds[1],
2930
2326
  east: n.bounds[2],
2931
2327
  north: n.bounds[3]
2932
- } : this.velocityField.geoBounds, u = r ? {
2328
+ } : this.velocityField.geoBounds, h = r ? {
2933
2329
  a: {
2934
2330
  unit: 1,
2935
- min: l,
2331
+ min: c,
2936
2332
  max: d,
2937
2333
  physical: !0,
2938
2334
  northToSouth: !0
2939
2335
  },
2940
2336
  b: {
2941
2337
  unit: 4,
2942
- min: l,
2338
+ min: c,
2943
2339
  max: d,
2944
2340
  physical: !0,
2945
2341
  northToSouth: !0
2946
2342
  },
2947
2343
  mix: r[2]
2948
- } : void 0, f = Ge(i), m = r ? [1, 4].map((p) => (i.activeTexture(i.TEXTURE0 + p), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2344
+ } : void 0, v = Ge(i), m = r ? [1, 4].map((f) => (i.activeTexture(i.TEXTURE0 + f), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2949
2345
  try {
2950
- const p = i.canvas;
2951
- this.simulation.resize(p.width, p.height), i.bindFramebuffer(i.FRAMEBUFFER, f.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
2952
- const h = ye(this.map, t.defaultProjectionData);
2953
- if (this.globeRendering !== null && this.globeRendering !== h) {
2954
- if (this.globeRendering = h, !this.playback) {
2346
+ const f = i.canvas;
2347
+ this.simulation.resize(f.width, f.height), i.bindFramebuffer(i.FRAMEBUFFER, v.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
2348
+ const l = _e(this.map, t.defaultProjectionData);
2349
+ if (this.globeRendering !== null && this.globeRendering !== l) {
2350
+ if (this.globeRendering = l, !this.playback) {
2955
2351
  this.loadViewportVelocity({ resetParticles: !0 });
2956
2352
  return;
2957
2353
  }
2958
2354
  this.simulation.resetParticles();
2959
2355
  }
2960
- this.globeRendering = h;
2961
- const g = this.map.getBounds(), x = Mi(g, h), T = Be(g, h);
2356
+ this.globeRendering = l;
2357
+ const p = this.map.getBounds(), x = xi(p, l), T = Ne(p, l);
2962
2358
  i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
2963
- const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2359
+ const R = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2964
2360
  this.simulation.render(
2965
2361
  this.velocityTexUnit,
2966
- l,
2362
+ c,
2967
2363
  d,
2968
- a,
2364
+ s,
2969
2365
  x,
2970
- M,
2366
+ R,
2971
2367
  T,
2972
- c,
2973
- h,
2974
- bi(y.lng, y.lat),
2368
+ u,
2369
+ l,
2370
+ gi(y.lng, y.lat),
2975
2371
  t.defaultProjectionData.clippingPlane,
2976
- ...u ? [u] : []
2372
+ ...h ? [h] : []
2977
2373
  );
2978
2374
  } finally {
2979
- m.forEach((p, h) => {
2980
- i.activeTexture(i.TEXTURE0 + (h === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, p);
2981
- }), Oe(i, f);
2375
+ m.forEach((f, l) => {
2376
+ i.activeTexture(i.TEXTURE0 + (l === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, f);
2377
+ }), Oe(i, v);
2982
2378
  }
2983
2379
  if (this.pendingReadyTime != null) {
2984
- const p = this.pendingReadyTime;
2985
- this.pendingReadyTime = null, this.emit("status", { phase: "ready", time: p });
2380
+ const f = this.pendingReadyTime;
2381
+ this.pendingReadyTime = null, this.emit("status", { phase: "ready", time: f });
2986
2382
  }
2987
2383
  this.map.triggerRepaint();
2988
2384
  }
@@ -3013,10 +2409,10 @@ class P {
3013
2409
  const i = this.depth !== t;
3014
2410
  if (this.time = e, this.depth = t, i && (this.generation++, this.zarrSource.cancelAll(), this.frameCache.clear(), this.inflight.clear()), this.suspended)
3015
2411
  return;
3016
- const a = this.timeToMs(e);
3017
- if (!i && this.frameCache.has(a)) {
3018
- const r = this.frameCache.get(a);
3019
- this.emit("status", { phase: "rendering", time: a }), this.velocityField.update(r), this.emit("loaded", this.computeFieldMeta(r, e)), this.pendingReadyTime = a, this.map?.triggerRepaint();
2412
+ const s = this.timeToMs(e);
2413
+ if (!i && this.frameCache.has(s)) {
2414
+ const r = this.frameCache.get(s);
2415
+ this.emit("status", { phase: "rendering", time: s }), this.velocityField.update(r), this.emit("loaded", this.computeFieldMeta(r, e)), this.pendingReadyTime = s, this.map?.triggerRepaint();
3020
2416
  return;
3021
2417
  }
3022
2418
  this.loadViewportVelocity();
@@ -3100,7 +2496,7 @@ class P {
3100
2496
  this.simulation.setSpeed(e);
3101
2497
  }
3102
2498
  setFade(e) {
3103
- this.simulation.setFadeOpacity(Xe(e));
2499
+ this.simulation.setFadeOpacity(We(e));
3104
2500
  }
3105
2501
  setParticleDensity(e) {
3106
2502
  this.simulation.setParticleDensity(e);
@@ -3155,27 +2551,27 @@ class P {
3155
2551
  emit(e, ...t) {
3156
2552
  const i = this.listeners.get(e);
3157
2553
  if (i)
3158
- for (const a of i)
3159
- a(...t);
3160
- }
3161
- }
3162
- function Yi(s, e, t) {
3163
- const i = [], a = [];
3164
- for (let r = 0; r < s.length; r++) {
3165
- const n = s[r], o = e[r], l = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
3166
- for (let c = 0; c < n.data.length; c++) {
3167
- const u = Xi(
3168
- n.data[c],
3169
- o.data[c],
2554
+ for (const s of i)
2555
+ s(...t);
2556
+ }
2557
+ }
2558
+ function zi(a, e, t) {
2559
+ const i = [], s = [];
2560
+ for (let r = 0; r < a.length; r++) {
2561
+ const n = a[r], o = e[r], c = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
2562
+ for (let u = 0; u < n.data.length; u++) {
2563
+ const h = Ui(
2564
+ n.data[u],
2565
+ o.data[u],
3170
2566
  t
3171
2567
  );
3172
- l[c] = u.u, d[c] = u.v;
2568
+ c[u] = h.u, d[u] = h.v;
3173
2569
  }
3174
- i.push({ ...n, data: l }), a.push({ ...n, data: d });
2570
+ i.push({ ...n, data: c }), s.push({ ...n, data: d });
3175
2571
  }
3176
- return [i, a];
2572
+ return [i, s];
3177
2573
  }
3178
- var Je = `precision mediump float;
2574
+ var je = `precision mediump float;
3179
2575
 
3180
2576
  uniform sampler2D u_color;
3181
2577
  uniform sampler2D u_color_next;
@@ -3235,7 +2631,7 @@ void main() {
3235
2631
  const Z = 128, te = 64;
3236
2632
  class G {
3237
2633
  constructor(e) {
3238
- this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new _t(
2634
+ this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new gt(
3239
2635
  e,
3240
2636
  () => this.map?.triggerRepaint(),
3241
2637
  (t, ...i) => this.emit(t, ...i)
@@ -3245,7 +2641,7 @@ class G {
3245
2641
  const i = K(t);
3246
2642
  this.map = e, this.gl = i, this.abortController = new AbortController(), this.emit("loading"), this.emit("status", { phase: "metadata" });
3247
2643
  try {
3248
- if (this.manifest = await Ce(
2644
+ if (this.manifest = await Ae(
3249
2645
  this.source,
3250
2646
  this.abortController.signal
3251
2647
  ), this.abortController?.signal.aborted || !this.map)
@@ -3255,84 +2651,84 @@ class G {
3255
2651
  `GeoVideoLayer renders scalar-luma manifests, received ${this.manifest.encoding.kind}`
3256
2652
  );
3257
2653
  this.colorDomain == null && (this.colorDomain = this.manifest.style.colorDomain);
3258
- const a = i.getParameter(i.MAX_TEXTURE_SIZE);
3259
- if (this.manifest.media.width > a || this.manifest.media.height > a)
2654
+ const s = i.getParameter(i.MAX_TEXTURE_SIZE);
2655
+ if (this.manifest.media.width > s || this.manifest.media.height > s)
3260
2656
  throw new Error(
3261
- `GeoVideo ${this.manifest.media.width}x${this.manifest.media.height} exceeds GPU texture limit ${a}`
2657
+ `GeoVideo ${this.manifest.media.width}x${this.manifest.media.height} exceeds GPU texture limit ${s}`
3262
2658
  );
3263
2659
  if (this.initGl(i), this.abortController.signal.aborted)
3264
2660
  return;
3265
2661
  await this.playback.load(i, this.manifest);
3266
- } catch (a) {
3267
- const r = a instanceof Error ? a : new Error(String(a));
2662
+ } catch (s) {
2663
+ const r = s instanceof Error ? s : new Error(String(s));
3268
2664
  if (r.name === "AbortError")
3269
2665
  return;
3270
2666
  throw this.emit("status", { phase: "error", error: r }), this.emit("error", r), r;
3271
2667
  }
3272
2668
  }
3273
2669
  render(e, t) {
3274
- const i = K(e), a = this.playback.sample(performance.now()), r = this.playback.field;
2670
+ const i = K(e), s = this.playback.sample(performance.now()), r = this.playback.field;
3275
2671
  if (!r)
3276
2672
  return;
3277
2673
  const n = r.manifest;
3278
- if (!a || !r.maskTexture)
2674
+ if (!s || !r.maskTexture)
3279
2675
  return;
3280
- const o = Ge(i), l = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
2676
+ const o = Ge(i), c = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
3281
2677
  try {
3282
- const d = !!this.map && ye(this.map, t.defaultProjectionData), c = d ? this.globeProgram : this.mercatorProgram;
3283
- if (!c || !this.map)
2678
+ const d = !!this.map && _e(this.map, t.defaultProjectionData), u = d ? this.globeProgram : this.mercatorProgram;
2679
+ if (!u || !this.map)
3284
2680
  return;
3285
- i.useProgram(c), i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, a[0]), i.uniform1i(i.getUniformLocation(c, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, a[1]), i.uniform1i(i.getUniformLocation(c, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(c, "u_mix"), a[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(c, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(c, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(c, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(c, "u_scalar_luma"), 1), i.uniform1f(
3286
- i.getUniformLocation(c, "u_log_scale"),
2681
+ i.useProgram(u), i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, s[0]), i.uniform1i(i.getUniformLocation(u, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, s[1]), i.uniform1i(i.getUniformLocation(u, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(u, "u_mix"), s[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(u, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(u, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(u, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(u, "u_scalar_luma"), 1), i.uniform1f(
2682
+ i.getUniformLocation(u, "u_log_scale"),
3287
2683
  this.logScale ? 1 : 0
3288
- ), i.uniform1f(i.getUniformLocation(c, "u_vibrance"), this.vibrance), i.uniform1f(
3289
- i.getUniformLocation(c, "u_mask_threshold"),
2684
+ ), i.uniform1f(i.getUniformLocation(u, "u_vibrance"), this.vibrance), i.uniform1f(
2685
+ i.getUniformLocation(u, "u_mask_threshold"),
3290
2686
  n.mask.threshold
3291
2687
  );
3292
- const { codeRange: u, valueRange: f, transfer: m } = ei(
2688
+ const { codeRange: h, valueRange: v, transfer: m } = Qt(
3293
2689
  n.encoding
3294
2690
  );
3295
2691
  i.uniform1f(
3296
- i.getUniformLocation(c, "u_scalar_transfer"),
2692
+ i.getUniformLocation(u, "u_scalar_transfer"),
3297
2693
  m
3298
2694
  );
3299
- const p = this.colorDomain ?? f;
2695
+ const f = this.colorDomain ?? v;
3300
2696
  i.uniform2f(
3301
- i.getUniformLocation(c, "u_code_range"),
3302
- ...u
2697
+ i.getUniformLocation(u, "u_code_range"),
2698
+ ...h
3303
2699
  ), i.uniform2f(
3304
- i.getUniformLocation(c, "u_value_range"),
3305
- ...f
2700
+ i.getUniformLocation(u, "u_value_range"),
2701
+ ...v
3306
2702
  ), i.uniform2f(
3307
- i.getUniformLocation(c, "u_color_domain"),
3308
- p[0],
3309
- p[1]
2703
+ i.getUniformLocation(u, "u_color_domain"),
2704
+ f[0],
2705
+ f[1]
3310
2706
  ), i.uniformMatrix4fv(
3311
- i.getUniformLocation(c, "u_matrix"),
2707
+ i.getUniformLocation(u, "u_matrix"),
3312
2708
  !1,
3313
2709
  t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
3314
2710
  );
3315
- const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
2711
+ const [l, p, x, T] = n.bounds, R = x < l ? x + 360 : x;
3316
2712
  if (i.uniform4f(
3317
- i.getUniformLocation(c, "u_geo_bounds"),
3318
- h,
3319
- g,
3320
- M,
2713
+ i.getUniformLocation(u, "u_geo_bounds"),
2714
+ l,
2715
+ p,
2716
+ R,
3321
2717
  T
3322
- ), this.bindGrid(i, c), d) {
2718
+ ), this.bindGrid(i, u), d) {
3323
2719
  const y = t.defaultProjectionData.clippingPlane;
3324
2720
  i.uniform4f(
3325
- i.getUniformLocation(c, "u_clipping_plane"),
2721
+ i.getUniformLocation(u, "u_clipping_plane"),
3326
2722
  ...y
3327
- ), yt(
2723
+ ), pt(
3328
2724
  i,
3329
2725
  {
3330
2726
  u_projection_transition: i.getUniformLocation(
3331
- c,
2727
+ u,
3332
2728
  "u_projection_transition"
3333
2729
  ),
3334
2730
  u_fallback_matrix: i.getUniformLocation(
3335
- c,
2731
+ u,
3336
2732
  "u_fallback_matrix"
3337
2733
  )
3338
2734
  },
@@ -3340,20 +2736,20 @@ class G {
3340
2736
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3341
2737
  } else {
3342
2738
  const y = 512 * Math.pow(2, this.map.getZoom());
3343
- i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
3344
- for (const v of Be(
2739
+ i.uniform1f(i.getUniformLocation(u, "u_world_size"), y);
2740
+ for (const g of Ne(
3345
2741
  this.map.getBounds(),
3346
2742
  !1
3347
2743
  ))
3348
2744
  i.uniform1f(
3349
- i.getUniformLocation(c, "u_world_offset"),
3350
- v
2745
+ i.getUniformLocation(u, "u_world_offset"),
2746
+ g
3351
2747
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3352
2748
  }
3353
- this.unbindGrid(i, c);
2749
+ this.unbindGrid(i, u);
3354
2750
  } finally {
3355
- l.forEach((d, c) => {
3356
- i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
2751
+ c.forEach((d, u) => {
2752
+ i.activeTexture(i.TEXTURE0 + u), i.bindTexture(i.TEXTURE_2D, d);
3357
2753
  }), Oe(i, o);
3358
2754
  }
3359
2755
  }
@@ -3393,7 +2789,7 @@ class G {
3393
2789
  setColorRamp(e) {
3394
2790
  this.colorRamp = e, this.gl && (this.colorRampTexture && this.gl.deleteTexture(this.colorRampTexture), this.colorRampTexture = ge(
3395
2791
  this.gl,
3396
- ke(e)
2792
+ Ce(e)
3397
2793
  )), this.map?.triggerRepaint();
3398
2794
  }
3399
2795
  setLogScale(e) {
@@ -3433,7 +2829,7 @@ class G {
3433
2829
  id: this.id,
3434
2830
  initialized: !!e?.currentPair,
3435
2831
  playing: this.playback.isPlaying(),
3436
- currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : ti(e.manifest, this.playback.time) : 0,
2832
+ currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : Kt(e.manifest, this.playback.time) : 0,
3437
2833
  manifestId: this.manifest?.id,
3438
2834
  mediaUrl: this.manifest?.media.url,
3439
2835
  preloadedMediaUrl: this.playback.preloadedMediaUrl,
@@ -3457,28 +2853,28 @@ class G {
3457
2853
  return this.listeners.get(e)?.delete(t), this;
3458
2854
  }
3459
2855
  initGl(e) {
3460
- this.mercatorProgram = W(e, Mt, Je), this.globeProgram = W(e, Rt, Je), this.colorRampTexture = ge(
2856
+ this.mercatorProgram = q(e, St, je), this.globeProgram = q(e, wt, je), this.colorRampTexture = ge(
3461
2857
  e,
3462
- ke(this.colorRamp)
2858
+ Ce(this.colorRamp)
3463
2859
  );
3464
2860
  const t = new Float32Array(
3465
2861
  (Z + 1) * (te + 1) * 2
3466
2862
  );
3467
2863
  let i = 0;
3468
2864
  for (let o = 0; o <= te; o++)
3469
- for (let l = 0; l <= Z; l++)
3470
- t[i++] = l / Z, t[i++] = o / te;
3471
- const a = new Uint16Array(Z * te * 6);
2865
+ for (let c = 0; c <= Z; c++)
2866
+ t[i++] = c / Z, t[i++] = o / te;
2867
+ const s = new Uint16Array(Z * te * 6);
3472
2868
  let r = 0;
3473
2869
  const n = Z + 1;
3474
2870
  for (let o = 0; o < te; o++)
3475
- for (let l = 0; l < Z; l++) {
3476
- const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
3477
- a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
2871
+ for (let c = 0; c < Z; c++) {
2872
+ const d = o * n + c, u = d + 1, h = d + n, v = h + 1;
2873
+ s[r++] = d, s[r++] = h, s[r++] = u, s[r++] = u, s[r++] = h, s[r++] = v;
3478
2874
  }
3479
2875
  if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
3480
2876
  throw new Error("Failed to create GeoVideo grid");
3481
- e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, a, e.STATIC_DRAW), this.indexCount = a.length;
2877
+ e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, s, e.STATIC_DRAW), this.indexCount = s.length;
3482
2878
  }
3483
2879
  bindGrid(e, t) {
3484
2880
  const i = e.getAttribLocation(t, "a_grid_uv");
@@ -3492,89 +2888,89 @@ class G {
3492
2888
  i(...t);
3493
2889
  }
3494
2890
  }
3495
- function $e(s) {
3496
- return typeof s == "string" ? s : new Date(s).toISOString();
2891
+ function Be(a) {
2892
+ return typeof a == "string" ? a : new Date(a).toISOString();
3497
2893
  }
3498
- function j(s) {
3499
- return encodeURIComponent(String(s));
2894
+ function j(a) {
2895
+ return encodeURIComponent(String(a));
3500
2896
  }
3501
- function At(s, e) {
3502
- return e === "depth" ? -Math.abs(s) : s;
2897
+ function Et(a, e) {
2898
+ return e === "depth" ? -Math.abs(a) : a;
3503
2899
  }
3504
- function Zi(s) {
3505
- let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
3506
- return s.tileMatrixSet != null && (e = e.replace(
2900
+ function Gi(a) {
2901
+ let e = a.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
2902
+ return a.tileMatrixSet != null && (e = e.replace(
3507
2903
  /\{TileMatrixSet\}/gi,
3508
- j(s.tileMatrixSet)
3509
- )), s.style != null && (e = e.replace(/\{Style\}/gi, j(s.style))), s.time != null && (e = e.replace(/\{time\}/gi, j($e(s.time)))), s.depth != null && (e = e.replace(
2904
+ j(a.tileMatrixSet)
2905
+ )), a.style != null && (e = e.replace(/\{Style\}/gi, j(a.style))), a.time != null && (e = e.replace(/\{time\}/gi, j(Be(a.time)))), a.depth != null && (e = e.replace(
3510
2906
  /\{elevation\}/gi,
3511
- j(At(s.depth, s.verticalLabel))
2907
+ j(Et(a.depth, a.verticalLabel))
3512
2908
  )), [...e.matchAll(/\{([^{}]+)\}/g)].some(
3513
2909
  (t) => !/^(?:z|y|x)$/i.test(t[1])
3514
2910
  ) ? void 0 : e;
3515
2911
  }
3516
- function et(s) {
2912
+ function Qe(a) {
3517
2913
  const e = [
3518
2914
  ["SERVICE", "WMTS"],
3519
2915
  ["VERSION", "1.0.0"],
3520
2916
  ["REQUEST", "GetTile"],
3521
- ["LAYER", s.layer],
3522
- ["FORMAT", s.format],
3523
- ["TILEMATRIXSET", s.tileMatrixSet],
2917
+ ["LAYER", a.layer],
2918
+ ["FORMAT", a.format],
2919
+ ["TILEMATRIXSET", a.tileMatrixSet],
3524
2920
  ["TILEMATRIX", "{z}"],
3525
2921
  ["TILEROW", "{y}"],
3526
2922
  ["TILECOL", "{x}"]
3527
2923
  ];
3528
- s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
2924
+ a.style && e.push(["STYLE", a.style]), a.time != null && e.push(["time", Be(a.time)]), a.depth != null && e.push([
3529
2925
  "elevation",
3530
- String(At(s.depth, s.verticalLabel))
2926
+ String(Et(a.depth, a.verticalLabel))
3531
2927
  ]);
3532
2928
  const t = e.map(
3533
- ([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
2929
+ ([i, s]) => `${i}=${s.startsWith("{") ? s : j(s)}`
3534
2930
  ).join("&");
3535
- return `${s.baseUrl}?${t}`;
2931
+ return `${a.baseUrl}?${t}`;
3536
2932
  }
3537
- function ji(s) {
2933
+ function Oi(a) {
3538
2934
  const e = [
3539
2935
  ["SERVICE", "WMTS"],
3540
2936
  ["REQUEST", "GetLegend"],
3541
- ["LAYER", s.layer],
3542
- ["FORMAT", s.format ?? "image/svg+xml"]
2937
+ ["LAYER", a.layer],
2938
+ ["FORMAT", a.format ?? "image/svg+xml"]
3543
2939
  ];
3544
- return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
2940
+ return a.style && e.push(["STYLE", a.style]), `${a.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
3545
2941
  }
3546
- function Qi(s) {
3547
- return s.sourceConfig.type === "wmts" ? "scalar-wmts" : s.sourceConfig.type === "geovideo" ? s.entry.kind === "vector" ? "vector-geovideo" : "scalar-geovideo" : s.entry.kind === "vector" ? "vector-zarr" : "scalar-zarr";
2942
+ function Ni(a) {
2943
+ return a.sourceConfig.type === "wmts" ? "scalar-wmts" : a.sourceConfig.type === "geovideo" ? a.entry.kind === "vector" ? "vector-geovideo" : "scalar-geovideo" : a.entry.kind === "vector" ? "vector-zarr" : "scalar-zarr";
3548
2944
  }
3549
- function Ki(s) {
3550
- return s.variables.kind === "scalar" ? s.variables.value : "scalar";
2945
+ function Bi(a) {
2946
+ return a.variables.kind === "scalar" ? a.variables.value : "scalar";
3551
2947
  }
3552
- function Ji(s) {
3553
- return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
2948
+ function $i(a) {
2949
+ return a.variables.kind === "vector" ? a.variables.u ?? "uo" : "uo";
3554
2950
  }
3555
- function ea(s) {
3556
- return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
2951
+ function qi(a) {
2952
+ return a.variables.kind === "vector" ? a.variables.v ?? "vo" : "vo";
3557
2953
  }
3558
- function ta(s) {
3559
- return s.variables.kind === "vector" ? s.variables.derivation : void 0;
2954
+ function Wi(a) {
2955
+ return a.variables.kind === "vector" ? a.variables.derivation : void 0;
3560
2956
  }
3561
- class ia {
2957
+ class Xi {
3562
2958
  constructor(e) {
3563
- if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend = Qi(e), this.rasterSourceId = `${e.id}-wmts-source`, this.rasterLayerId = `${e.id}-wmts`, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.opacity = e.opacity ?? 1, this.backend === "vector-zarr") {
2959
+ if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend = Ni(e), this.rasterSourceId = `${e.id}-wmts-source`, this.rasterLayerId = `${e.id}-wmts`, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.opacity = e.opacity ?? 1, this.backend === "vector-zarr") {
3564
2960
  const t = e.sourceConfig;
3565
- this.delegate = new P({
2961
+ this.delegate = new M({
3566
2962
  ...e,
3567
2963
  source: t.endpoints.field,
3568
2964
  zarrSource: e.zarrSource,
3569
- variableU: Ji(t),
3570
- variableV: ea(t),
3571
- vectorDerivation: ta(t),
2965
+ variableU: $i(t),
2966
+ variableV: qi(t),
2967
+ vectorDerivation: Wi(t),
3572
2968
  unit: e.unit ?? ""
3573
2969
  });
3574
2970
  } else if (this.backend === "vector-geovideo") {
3575
2971
  if (!e.geoVideoManifest)
3576
2972
  throw new Error("Vector GeoVideo requires a loaded manifest");
3577
- this.delegate = new P({
2973
+ this.delegate = new M({
3578
2974
  ...e,
3579
2975
  source: e.geoVideoManifest.media.url,
3580
2976
  geoVideo: {
@@ -3595,7 +2991,7 @@ class ia {
3595
2991
  id: e.id,
3596
2992
  source: t.endpoints.field,
3597
2993
  zarrSource: e.zarrSource,
3598
- variable: Ki(t),
2994
+ variable: Bi(t),
3599
2995
  time: e.time,
3600
2996
  depth: e.depth,
3601
2997
  colorRamp: e.colorRamp,
@@ -3626,7 +3022,7 @@ class ia {
3626
3022
  vibrance: e.vibrance
3627
3023
  });
3628
3024
  }
3629
- this.delegate instanceof P && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3025
+ this.delegate instanceof M && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3630
3026
  this.time = t;
3631
3027
  });
3632
3028
  }
@@ -3714,16 +3110,16 @@ class ia {
3714
3110
  }
3715
3111
  }
3716
3112
  setSpeed(e) {
3717
- this.delegate instanceof P && this.delegate.setSpeed(e);
3113
+ this.delegate instanceof M && this.delegate.setSpeed(e);
3718
3114
  }
3719
3115
  setFade(e) {
3720
- this.delegate instanceof P && this.delegate.setFade(e);
3116
+ this.delegate instanceof M && this.delegate.setFade(e);
3721
3117
  }
3722
3118
  setParticleDensity(e) {
3723
- this.delegate instanceof P && this.delegate.setParticleDensity(e);
3119
+ this.delegate instanceof M && this.delegate.setParticleDensity(e);
3724
3120
  }
3725
3121
  setRenderMode(e) {
3726
- this.delegate instanceof P && this.delegate.setRenderMode(e);
3122
+ this.delegate instanceof M && this.delegate.setRenderMode(e);
3727
3123
  }
3728
3124
  setRgba8MaxParticleZoom(e) {
3729
3125
  this.delegate?.setRgba8MaxParticleZoom(e);
@@ -3739,34 +3135,34 @@ class ia {
3739
3135
  this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
3740
3136
  }
3741
3137
  setLogScale(e) {
3742
- this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof P && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
3138
+ this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof M && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
3743
3139
  }
3744
3140
  setVibrance(e) {
3745
3141
  this.delegate?.setVibrance(e);
3746
3142
  }
3747
3143
  /** Particle trails only; rasters ignore it. */
3748
3144
  setColorGrade(e) {
3749
- this.delegate instanceof P && this.delegate.setColorGrade(e);
3145
+ this.delegate instanceof M && this.delegate.setColorGrade(e);
3750
3146
  }
3751
3147
  /** Under particle trails only; rasters ignore it. */
3752
3148
  setBackdrop(e) {
3753
- this.delegate instanceof P && this.delegate.setBackdrop(e);
3149
+ this.delegate instanceof M && this.delegate.setBackdrop(e);
3754
3150
  }
3755
3151
  /** Particle trails only; rasters ignore it. */
3756
3152
  setGlow(e) {
3757
- this.delegate instanceof P && this.delegate.setGlow(e);
3153
+ this.delegate instanceof M && this.delegate.setGlow(e);
3758
3154
  }
3759
3155
  setColorDomain(e) {
3760
3156
  this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
3761
3157
  }
3762
3158
  async play() {
3763
- (this.delegate instanceof G || this.delegate instanceof P) && await this.delegate.play();
3159
+ (this.delegate instanceof G || this.delegate instanceof M) && await this.delegate.play();
3764
3160
  }
3765
3161
  pause() {
3766
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
3162
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.pause();
3767
3163
  }
3768
3164
  setLoop(e) {
3769
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setLoop(e);
3165
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.setLoop(e);
3770
3166
  }
3771
3167
  /** Media rate multiplier of a scalar GeoVideo. */
3772
3168
  setPlaybackRate(e) {
@@ -3774,21 +3170,21 @@ class ia {
3774
3170
  }
3775
3171
  /** Cadence of the continuous vector GeoVideo clock. */
3776
3172
  setStepsPerSecond(e) {
3777
- this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
3173
+ this.delegate instanceof M && this.delegate.setStepsPerSecond(e);
3778
3174
  }
3779
3175
  setTimeRange(e) {
3780
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setTimeRange(e);
3176
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.setTimeRange(e);
3781
3177
  }
3782
3178
  /**
3783
3179
  * Move a GeoVideo to another artifact, such as the next archive
3784
3180
  * chunk, without rebuilding the map layer. False when a new layer is needed.
3785
3181
  */
3786
3182
  replaceGeoVideoManifest(e, t) {
3787
- return this.suspended || !(this.delegate instanceof G || this.delegate instanceof P) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
3183
+ return this.suspended || !(this.delegate instanceof G || this.delegate instanceof M) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
3788
3184
  }
3789
3185
  /** Load the GeoVideo artifact expected next, such as the next archive chunk. */
3790
3186
  preloadGeoVideoManifest(e, t) {
3791
- return !this.suspended && (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.preloadManifest(e, t);
3187
+ return !this.suspended && (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.preloadManifest(e, t);
3792
3188
  }
3793
3189
  async samplePoint(e) {
3794
3190
  if (this.delegate instanceof me)
@@ -3805,14 +3201,14 @@ class ia {
3805
3201
  return;
3806
3202
  this.removeWmts();
3807
3203
  const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
3808
- Zi({
3204
+ Gi({
3809
3205
  template: e.tileUrlTemplate,
3810
3206
  tileMatrixSet: e.tileMatrixSet,
3811
3207
  style: e.style,
3812
3208
  time: this.time,
3813
3209
  depth: this.depth,
3814
3210
  verticalLabel: this.options.verticalLabel
3815
- }) ?? et({
3211
+ }) ?? Qe({
3816
3212
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3817
3213
  layer: e.layer,
3818
3214
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3823,7 +3219,7 @@ class ia {
3823
3219
  verticalLabel: this.options.verticalLabel
3824
3220
  })
3825
3221
  ] : [
3826
- et({
3222
+ Qe({
3827
3223
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3828
3224
  layer: e.layer,
3829
3225
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3857,15 +3253,15 @@ class ia {
3857
3253
  min: 0,
3858
3254
  max: 0,
3859
3255
  unit: this.options.unit ?? "",
3860
- time: $e(this.time),
3256
+ time: Be(this.time),
3861
3257
  depth: this.depth
3862
3258
  }), this.emit("status", { phase: "ready", time: e });
3863
3259
  }
3864
3260
  emit(e, ...t) {
3865
3261
  const i = this.listeners.get(e);
3866
3262
  if (i)
3867
- for (const a of i)
3868
- a(...t);
3263
+ for (const s of i)
3264
+ s(...t);
3869
3265
  }
3870
3266
  /** The WMTS raster takes the place of this custom layer, right above it. */
3871
3267
  getBeforeLayerId() {
@@ -3876,113 +3272,113 @@ class ia {
3876
3272
  return i && this.map?.getLayer(i) ? i : void 0;
3877
3273
  }
3878
3274
  }
3879
- function Pe(s, e) {
3880
- return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3275
+ function Me(a, e) {
3276
+ return a.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3881
3277
  }
3882
- function aa(s, e, t) {
3883
- const i = s.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}").replace(/\{TileMatrixSet\}/gi, e), a = t == null ? i : i.replace(/\{Style\}/gi, t);
3884
- return [...a.matchAll(/\{([^{}]+)\}/g)].some(
3278
+ function Hi(a, e, t) {
3279
+ const i = a.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}").replace(/\{TileMatrixSet\}/gi, e), s = t == null ? i : i.replace(/\{Style\}/gi, t);
3280
+ return [...s.matchAll(/\{([^{}]+)\}/g)].some(
3885
3281
  (n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
3886
- ) ? void 0 : a;
3282
+ ) ? void 0 : s;
3887
3283
  }
3888
- function Ct(s) {
3889
- return s.replace(/<[^>]+>/g, "").trim();
3284
+ function Lt(a) {
3285
+ return a.replace(/<[^>]+>/g, "").trim();
3890
3286
  }
3891
- function be(s, e) {
3287
+ function be(a, e) {
3892
3288
  const t = new RegExp(
3893
3289
  `<(?:(?:\\w+):)?${e}\\b[^>]*>([\\s\\S]*?)<\\/(?:(?:\\w+):)?${e}>`,
3894
3290
  "gi"
3895
3291
  );
3896
- return [...s.matchAll(t)].map((i) => i[1]);
3292
+ return [...a.matchAll(t)].map((i) => i[1]);
3897
3293
  }
3898
- function se(s, e) {
3899
- return be(s, e).map(Ct).find(Boolean);
3294
+ function se(a, e) {
3295
+ return be(a, e).map(Lt).find(Boolean);
3900
3296
  }
3901
- function tt(s, e) {
3297
+ function Ke(a, e) {
3902
3298
  const t = e.match(
3903
3299
  /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
3904
3300
  );
3905
3301
  if (!t || !t.slice(1).some((m) => Number(m) > 0))
3906
3302
  return;
3907
- const i = new Date(s), a = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(), l = i.getUTCMinutes(), d = i.getUTCSeconds(), c = i.getUTCMilliseconds(), u = new Date(
3908
- Date.UTC(a, r, 1, o, l, d, c)
3909
- ), f = new Date(
3910
- Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
3303
+ const i = new Date(a), s = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(), c = i.getUTCMinutes(), d = i.getUTCSeconds(), u = i.getUTCMilliseconds(), h = new Date(
3304
+ Date.UTC(s, r, 1, o, c, d, u)
3305
+ ), v = new Date(
3306
+ Date.UTC(h.getUTCFullYear(), h.getUTCMonth() + 1, 0)
3911
3307
  ).getUTCDate();
3912
- return u.setUTCDate(Math.min(n, f)), u.setUTCDate(u.getUTCDate() + Number(t[3] ?? 0)), u.setUTCHours(u.getUTCHours() + Number(t[4] ?? 0)), u.setUTCMinutes(u.getUTCMinutes() + Number(t[5] ?? 0)), u.setUTCSeconds(u.getUTCSeconds() + Number(t[6] ?? 0)), u.getTime();
3308
+ return h.setUTCDate(Math.min(n, v)), h.setUTCDate(h.getUTCDate() + Number(t[3] ?? 0)), h.setUTCHours(h.getUTCHours() + Number(t[4] ?? 0)), h.setUTCMinutes(h.getUTCMinutes() + Number(t[5] ?? 0)), h.setUTCSeconds(h.getUTCSeconds() + Number(t[6] ?? 0)), h.getTime();
3913
3309
  }
3914
- function sa(s) {
3310
+ function Yi(a) {
3915
3311
  const e = [];
3916
- for (const t of s.flatMap((i) => i.split(","))) {
3312
+ for (const t of a.flatMap((i) => i.split(","))) {
3917
3313
  const i = t.trim().split("/");
3918
3314
  if (i.length === 3) {
3919
- const r = Date.parse(i[0]), n = Date.parse(i[1]), o = tt(r, i[2]);
3315
+ const r = Date.parse(i[0]), n = Date.parse(i[1]), o = Ke(r, i[2]);
3920
3316
  if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
3921
- for (let l = r, d = 0; l <= n && d < 1e5; d += 1)
3922
- e.push(l), l = tt(l, i[2]);
3317
+ for (let c = r, d = 0; c <= n && d < 1e5; d += 1)
3318
+ e.push(c), c = Ke(c, i[2]);
3923
3319
  continue;
3924
3320
  }
3925
- const a = Date.parse(t.trim());
3926
- Number.isFinite(a) && e.push(a);
3321
+ const s = Date.parse(t.trim());
3322
+ Number.isFinite(s) && e.push(s);
3927
3323
  }
3928
3324
  return [...new Set(e)].sort((t, i) => t - i);
3929
3325
  }
3930
- function it(s, e) {
3931
- for (const t of be(s, "Dimension"))
3326
+ function Je(a, e) {
3327
+ for (const t of be(a, "Dimension"))
3932
3328
  if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
3933
- return be(t, "Value").map(Ct);
3329
+ return be(t, "Value").map(Lt);
3934
3330
  return [];
3935
3331
  }
3936
- function ra(s, e) {
3937
- const t = be(s, "Layer").find(
3938
- (h) => se(h, "Identifier") === e.layer
3332
+ function Zi(a, e) {
3333
+ const t = be(a, "Layer").find(
3334
+ (l) => se(l, "Identifier") === e.layer
3939
3335
  );
3940
3336
  if (!t)
3941
3337
  throw new Error(`WMTS capabilities do not contain layer: ${e.layer}`);
3942
3338
  const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
3943
3339
  if (!/3857|GoogleMapsCompatible/i.test(i))
3944
3340
  throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
3945
- const a = sa(it(t, "time")), r = a.length ? {
3946
- min: a[0],
3947
- max: a[a.length - 1],
3948
- size: a.length,
3949
- values: a,
3341
+ const s = Yi(Je(t, "time")), r = s.length ? {
3342
+ min: s[0],
3343
+ max: s[s.length - 1],
3344
+ size: s.length,
3345
+ values: s,
3950
3346
  units: "milliseconds since 1970-01-01T00:00:00Z",
3951
- step: a.length > 1 && a.every(
3952
- (h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
3953
- ) ? a[1] - a[0] : void 0
3954
- } : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = it(t, "elevation").flatMap((h) => h.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, l = s.match(
3347
+ step: s.length > 1 && s.every(
3348
+ (l, p) => p === 0 || l - s[p - 1] === s[1] - s[0]
3349
+ ) ? s[1] - s[0] : void 0
3350
+ } : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = Je(t, "elevation").flatMap((l) => l.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, c = a.match(
3955
3351
  /GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
3956
- )?.[1], c = [
3352
+ )?.[1], u = [
3957
3353
  ...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
3958
3354
  ].find(
3959
- (h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
3960
- ), u = c ? Pe(c[1], "template") : void 0, f = [
3355
+ (l) => Me(l[1], "resourceType")?.toLowerCase() === "tile"
3356
+ ), h = u ? Me(u[1], "template") : void 0, v = [
3961
3357
  ...t.matchAll(
3962
3358
  /<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
3963
3359
  )
3964
- ], m = f.find(
3965
- (h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
3966
- ), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
3360
+ ], m = v.find(
3361
+ (l) => Me(l[1], "isDefault")?.toLowerCase() === "true"
3362
+ ), f = e.style ?? se(m?.[2] ?? v[0]?.[2] ?? "", "Identifier");
3967
3363
  return {
3968
- baseUrl: e.baseUrl ?? l ?? new URL(e.capabilitiesUrl).origin,
3969
- tileUrlTemplate: e.tileUrlTemplate ?? (u ? aa(u, i, p) : void 0),
3364
+ baseUrl: e.baseUrl ?? c ?? new URL(e.capabilitiesUrl).origin,
3365
+ tileUrlTemplate: e.tileUrlTemplate ?? (h ? Hi(h, i, f) : void 0),
3970
3366
  tileMatrixSet: i,
3971
3367
  format: e.format ?? se(t, "Format") ?? "image/png",
3972
- style: p,
3368
+ style: f,
3973
3369
  time: r,
3974
3370
  vertical: o
3975
3371
  };
3976
3372
  }
3977
- async function na(s, e) {
3978
- const t = await fetch(s.capabilitiesUrl, { signal: e });
3373
+ async function ji(a, e) {
3374
+ const t = await fetch(a.capabilitiesUrl, { signal: e });
3979
3375
  if (!t.ok)
3980
3376
  throw new Error(
3981
- `WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
3377
+ `WMTS capabilities request failed (${t.status}): ${a.capabilitiesUrl}`
3982
3378
  );
3983
- return ra(await t.text(), s);
3379
+ return Zi(await t.text(), a);
3984
3380
  }
3985
- const oa = [
3381
+ const Qi = [
3986
3382
  0.25,
3987
3383
  0.5,
3988
3384
  1,
@@ -3991,17 +3387,17 @@ const oa = [
3991
3387
  8,
3992
3388
  16,
3993
3389
  32
3994
- ], at = [0.25, 0.5, 1, 2];
3995
- function st(s, e) {
3996
- if (s.length === 0)
3390
+ ], et = [0.25, 0.5, 1, 2];
3391
+ function tt(a, e) {
3392
+ if (a.length === 0)
3997
3393
  return e;
3998
- let t = s[0], i;
3999
- for (const a of s)
4000
- a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
3394
+ let t = a[0], i;
3395
+ for (const s of a)
3396
+ s < t && (t = s), s <= e && (i === void 0 || s > i) && (i = s);
4001
3397
  return i ?? t;
4002
3398
  }
4003
- function la(s) {
4004
- const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((l) => o(l) === o(e[0]))), i = [
3399
+ function Ki(a) {
3400
+ const e = a.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((c) => o(c) === o(e[0]))), i = [
4005
3401
  (n) => n.getUTCHours(),
4006
3402
  (n) => n.getUTCMinutes(),
4007
3403
  (n) => n.getUTCSeconds(),
@@ -4012,135 +3408,135 @@ function la(s) {
4012
3408
  return "year";
4013
3409
  if (t([(o) => o.getUTCDate(), ...i]))
4014
3410
  return "month";
4015
- const n = s.slice(1).map((o, l) => o - s[l]);
3411
+ const n = a.slice(1).map((o, c) => o - a[c]);
4016
3412
  return t(i) && n.every((o) => o % 864e5 === 0) ? "day" : t(i.slice(1)) && n.every((o) => o % 36e5 === 0) ? "hour" : t(i.slice(2)) && n.every((o) => o % 6e4 === 0) ? "minute" : "second";
4017
3413
  }
4018
- const a = e[0];
4019
- if (!a)
3414
+ const s = e[0];
3415
+ if (!s)
4020
3416
  return "second";
4021
- const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
4022
- return r && a.getUTCMonth() === 0 && a.getUTCDate() === 1 ? "year" : r && a.getUTCDate() === 1 ? "month" : r ? "day" : a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "hour" : a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "minute" : "second";
3417
+ const r = s.getUTCHours() === 0 && s.getUTCMinutes() === 0 && s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0;
3418
+ return r && s.getUTCMonth() === 0 && s.getUTCDate() === 1 ? "year" : r && s.getUTCDate() === 1 ? "month" : r ? "day" : s.getUTCMinutes() === 0 && s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0 ? "hour" : s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0 ? "minute" : "second";
4023
3419
  }
4024
- function kt(s) {
4025
- if (s.length < 2)
3420
+ function Dt(a) {
3421
+ if (a.length < 2)
4026
3422
  return;
4027
- const e = s[1] - s[0];
4028
- return s.every(
4029
- (t, i) => i === 0 || t - s[i - 1] === e
3423
+ const e = a[1] - a[0];
3424
+ return a.every(
3425
+ (t, i) => i === 0 || t - a[i - 1] === e
4030
3426
  ) ? e : void 0;
4031
3427
  }
4032
- function re(s, e) {
4033
- return e ? bt(e, [
4034
- s.values[0],
4035
- s.values[s.values.length - 1]
3428
+ function re(a, e) {
3429
+ return e ? yt(e, [
3430
+ a.values[0],
3431
+ a.values[a.values.length - 1]
4036
3432
  ]) : null;
4037
3433
  }
4038
- function ne(s, e) {
4039
- const t = re(s, e);
3434
+ function ne(a, e) {
3435
+ const t = re(a, e);
4040
3436
  if (!t)
4041
- return s;
4042
- const [i, a] = t, r = s.values.filter((n) => n >= i && n <= a);
3437
+ return a;
3438
+ const [i, s] = t, r = a.values.filter((n) => n >= i && n <= s);
4043
3439
  if (r.length === 0)
4044
3440
  throw new RangeError(
4045
3441
  "Time range does not contain any available timestamps"
4046
3442
  );
4047
3443
  return {
4048
- ...s,
3444
+ ...a,
4049
3445
  min: r[0],
4050
3446
  max: r[r.length - 1],
4051
3447
  size: r.length,
4052
- step: kt(r),
3448
+ step: Dt(r),
4053
3449
  values: r
4054
3450
  };
4055
3451
  }
4056
- function rt(s, e) {
4057
- const { start: t, end: i } = s.temporal ?? {};
3452
+ function it(a, e) {
3453
+ const { start: t, end: i } = a.temporal ?? {};
4058
3454
  return t || i ? ne(e, { start: t, end: i }) : e;
4059
3455
  }
4060
- function fe(s) {
4061
- return s.variables.kind === "scalar" ? [s.variables.value] : s.variables.derivation ? [
4062
- s.variables.derivation.direction_variable,
4063
- s.variables.derivation.magnitude_variable
4064
- ] : [s.variables.u ?? "uo", s.variables.v ?? "vo"];
3456
+ function fe(a) {
3457
+ return a.variables.kind === "scalar" ? [a.variables.value] : a.variables.derivation ? [
3458
+ a.variables.derivation.direction_variable,
3459
+ a.variables.derivation.magnitude_variable
3460
+ ] : [a.variables.u ?? "uo", a.variables.v ?? "vo"];
4065
3461
  }
4066
- function Ee(s, e) {
4067
- const t = s.sources.filter(Fe);
3462
+ function Pe(a, e) {
3463
+ const t = a.sources.filter(ke);
4068
3464
  return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
4069
3465
  }
4070
- function Ft(s) {
4071
- return [...s].sort((e, t) => {
4072
- const i = Math.abs(e), a = Math.abs(t);
4073
- return i !== a ? i - a : t - e;
3466
+ function At(a) {
3467
+ return [...a].sort((e, t) => {
3468
+ const i = Math.abs(e), s = Math.abs(t);
3469
+ return i !== s ? i - s : t - e;
4074
3470
  });
4075
3471
  }
4076
- function Le(s, e) {
4077
- return s?.values.length ? e == null ? Ft(s.values)[0] : V(s.values, e) : e ?? 0;
3472
+ function Ee(a, e) {
3473
+ return a?.values.length ? e == null ? At(a.values)[0] : F(a.values, e) : e ?? 0;
4078
3474
  }
4079
- function V(s, e) {
4080
- if (s.length === 0)
3475
+ function F(a, e) {
3476
+ if (a.length === 0)
4081
3477
  return e;
4082
- let t = s[0], i = Math.abs(t - e);
4083
- for (let a = 1; a < s.length; a++) {
4084
- const r = Math.abs(s[a] - e);
4085
- r < i && (t = s[a], i = r);
3478
+ let t = a[0], i = Math.abs(t - e);
3479
+ for (let s = 1; s < a.length; s++) {
3480
+ const r = Math.abs(a[s] - e);
3481
+ r < i && (t = a[s], i = r);
4086
3482
  }
4087
3483
  return t;
4088
3484
  }
4089
- function nt(s) {
3485
+ function at(a) {
4090
3486
  for (const [e, t] of [
4091
- [s?.playbackRate, "Playback rate"],
4092
- [s?.stepsPerSecond, "Steps per second"]
3487
+ [a?.playbackRate, "Playback rate"],
3488
+ [a?.stepsPerSecond, "Steps per second"]
4093
3489
  ])
4094
3490
  if (e != null && (!Number.isFinite(e) || e <= 0))
4095
3491
  throw new Error(`${t} must be positive`);
4096
3492
  }
4097
- function ot(s, e) {
4098
- const t = s.surface?.value ?? 0, i = V(
4099
- [t, ...s.depths.map((a) => a.value)],
3493
+ function st(a, e) {
3494
+ const t = a.surface?.value ?? 0, i = F(
3495
+ [t, ...a.depths.map((s) => s.value)],
4100
3496
  e
4101
3497
  );
4102
3498
  return i === t ? null : i;
4103
3499
  }
4104
- function ca(s) {
4105
- const e = s.surface ?? s.depths[0];
3500
+ function Ji(a) {
3501
+ const e = a.surface ?? a.depths[0];
4106
3502
  return {
4107
3503
  name: e.name,
4108
3504
  label: e.positive === "up" || e.name === "elevation" ? "elevation" : "depth",
4109
3505
  units: e.units || void 0,
4110
3506
  values: [
4111
- s.surface?.value ?? 0,
4112
- ...s.depths.map((t) => t.value)
3507
+ a.surface?.value ?? 0,
3508
+ ...a.depths.map((t) => t.value)
4113
3509
  ]
4114
3510
  };
4115
3511
  }
4116
- function lt(s, e) {
3512
+ function rt(a, e) {
4117
3513
  return JSON.stringify([
4118
- s?.values ?? null,
3514
+ a?.values ?? null,
4119
3515
  e ? [e.name, e.units, e.values] : null
4120
3516
  ]);
4121
3517
  }
4122
- function ha(s) {
4123
- const e = [...new Set(s)].sort((t, i) => t - i);
3518
+ function ea(a) {
3519
+ const e = [...new Set(a)].sort((t, i) => t - i);
4124
3520
  return {
4125
3521
  min: e[0],
4126
3522
  max: e[e.length - 1],
4127
- step: kt(e),
3523
+ step: Dt(e),
4128
3524
  size: e.length,
4129
3525
  units: "milliseconds since 1970-01-01T00:00:00Z",
4130
3526
  values: e
4131
3527
  };
4132
3528
  }
4133
- const ua = 5 * 6e4, da = 6e4, ct = 6;
4134
- function pe(s) {
4135
- const { particles: e = {}, raster: t = {} } = s, i = {
4136
- palette: s.palette,
4137
- reversePalette: s.reversePalette,
4138
- renderMode: s.renderMode,
3529
+ const ta = 5 * 6e4, ia = 6e4, nt = 6;
3530
+ function pe(a) {
3531
+ const { particles: e = {}, raster: t = {} } = a, i = {
3532
+ palette: a.palette,
3533
+ reversePalette: a.reversePalette,
3534
+ renderMode: a.renderMode,
4139
3535
  particleDensity: e.density,
4140
3536
  speed: e.speed,
4141
3537
  fade: e.fade,
4142
3538
  glow: e.glow,
4143
- colorGrade: e.grade === void 0 ? void 0 : gi(e.grade),
3539
+ colorGrade: e.grade === void 0 ? void 0 : mi(e.grade),
4144
3540
  opacity: t.opacity,
4145
3541
  logScale: t.logScale,
4146
3542
  vibrance: t.vibrance,
@@ -4151,32 +3547,32 @@ function pe(s) {
4151
3547
  backdrop: e.backdrop && { ...e.backdrop }
4152
3548
  };
4153
3549
  return Object.fromEntries(
4154
- Object.entries(i).filter(([, a]) => a !== void 0)
3550
+ Object.entries(i).filter(([, s]) => s !== void 0)
4155
3551
  );
4156
3552
  }
4157
- function Ve(s) {
4158
- const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
4159
- return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
3553
+ function Ue(a) {
3554
+ const e = a.alphaFadeLow ?? 0, t = a.alphaFadeHigh ?? 0;
3555
+ return e > 0 || t > 0 ? { low: e, high: t, curve: a.alphaFadeCurve ?? "linear" } : void 0;
4160
3556
  }
4161
- const ht = "rdylbu", ma = new Set(
4162
- xt({ includeDeprecated: !0 }).map((s) => s.id)
4163
- ), ut = /* @__PURE__ */ new Set();
4164
- function Ne(s) {
4165
- return typeof s != "string" || ma.has(s) ? s : (ut.has(s) || (ut.add(s), console.warn(
4166
- `[zartigl] palette "${s}" is not in this version: drawn with "${ht}"`
4167
- )), ht);
3557
+ const ot = "rdylbu", aa = new Set(
3558
+ vt({ includeDeprecated: !0 }).map((a) => a.id)
3559
+ ), lt = /* @__PURE__ */ new Set();
3560
+ function Ie(a) {
3561
+ return typeof a != "string" || aa.has(a) ? a : (lt.has(a) || (lt.add(a), console.warn(
3562
+ `[zartigl] palette "${a}" is not in this version: drawn with "${ot}"`
3563
+ )), ot);
4168
3564
  }
4169
- function De(s) {
4170
- const { reversePalette: e } = s, t = Ne(s.palette), i = Ve(s);
4171
- return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
3565
+ function Le(a) {
3566
+ const { reversePalette: e } = a, t = Ie(a.palette), i = Ue(a);
3567
+ return t != null && (e || i) ? Ce(t, { reverse: e, alphaFade: i }) : t;
4172
3568
  }
4173
- const fa = [
3569
+ const sa = [
4174
3570
  "palette",
4175
3571
  "reversePalette",
4176
3572
  "alphaFadeLow",
4177
3573
  "alphaFadeHigh",
4178
3574
  "alphaFadeCurve"
4179
- ], It = Object.freeze({
3575
+ ], Ct = Object.freeze({
4180
3576
  palette: "style.palette",
4181
3577
  renderMode: "style.renderMode",
4182
3578
  particleDensity: "style.particles.density",
@@ -4189,22 +3585,22 @@ const fa = [
4189
3585
  colorDomain: "style.raster.colorDomain",
4190
3586
  backdrop: "style.particles.backdrop"
4191
3587
  });
4192
- function Ae(s) {
3588
+ function De(a) {
4193
3589
  const {
4194
3590
  palette: e,
4195
3591
  renderMode: t,
4196
3592
  particleDensity: i,
4197
- speed: a,
3593
+ speed: s,
4198
3594
  fade: r,
4199
3595
  colorGrade: n,
4200
3596
  opacity: o,
4201
- logScale: l,
3597
+ logScale: c,
4202
3598
  vibrance: d,
4203
- colorDomain: c,
4204
- backdrop: u,
4205
- ...f
4206
- } = s ?? {}, m = Object.keys(s ?? {}).filter(
4207
- (h) => h in It && s[h] !== void 0
3599
+ colorDomain: u,
3600
+ backdrop: h,
3601
+ ...v
3602
+ } = a ?? {}, m = Object.keys(a ?? {}).filter(
3603
+ (l) => l in Ct && a[l] !== void 0
4208
3604
  );
4209
3605
  return {
4210
3606
  style: ae({
@@ -4212,49 +3608,49 @@ function Ae(s) {
4212
3608
  renderMode: t,
4213
3609
  particles: {
4214
3610
  density: i,
4215
- speed: a,
3611
+ speed: s,
4216
3612
  fade: r,
4217
- grade: n && pi(n),
4218
- backdrop: u
3613
+ grade: n && di(n),
3614
+ backdrop: h
4219
3615
  },
4220
- raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
3616
+ raster: { opacity: o, logScale: c, vibrance: d, colorDomain: u }
4221
3617
  }),
4222
- settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
3618
+ settings: e === void 0 || typeof e == "string" ? v : { ...v, palette: e },
4223
3619
  legacyKeys: m
4224
3620
  };
4225
3621
  }
4226
- const dt = /* @__PURE__ */ new Set();
4227
- function mt(s) {
4228
- for (const e of s)
4229
- dt.has(e) || (dt.add(e), console.warn(
4230
- `[zartigl] settings.${e} is deprecated: use ${It[e]}`
3622
+ const ct = /* @__PURE__ */ new Set();
3623
+ function ut(a) {
3624
+ for (const e of a)
3625
+ ct.has(e) || (ct.add(e), console.warn(
3626
+ `[zartigl] settings.${e} is deprecated: use ${Ct[e]}`
4231
3627
  ));
4232
3628
  }
4233
- function Ut(s, e) {
4234
- const t = ze(s, e);
3629
+ function kt(a, e) {
3630
+ const t = ze(a, e);
4235
3631
  return {
4236
3632
  ...pe(t),
4237
3633
  palette: t.palette ?? "rdylbu",
4238
3634
  colorDomain: Q(t.raster.colorDomain)
4239
3635
  };
4240
3636
  }
4241
- function pa(s) {
3637
+ function ra(a) {
4242
3638
  return {
4243
- ...Ut(s),
3639
+ ...kt(a),
4244
3640
  particleState: "auto",
4245
3641
  rgba8MaxParticleZoom: 4
4246
3642
  };
4247
3643
  }
4248
- function ga(s) {
4249
- const { palette: e, ...t } = s;
3644
+ function na(a) {
3645
+ const { palette: e, ...t } = a;
4250
3646
  return t;
4251
3647
  }
4252
- function ft(s, e, t) {
4253
- s !== void 0 && pt(s, "style", {
3648
+ function ht(a, e, t) {
3649
+ a !== void 0 && dt(a, "style", {
4254
3650
  kind: e.layers.find((i) => i.id === t)?.kind
4255
3651
  });
4256
3652
  }
4257
- class Ca {
3653
+ class xa {
4258
3654
  constructor(e) {
4259
3655
  if (this.fullTimeMeta = null, this.autoplayPending = !0, this.playing = !1, this.catalogLayer = null, this.catalogSource = null, this.layer = null, this.time = 0, this.pendingTime = null, this.requestedTime = null, this.playbackIntent = 0, this.requestSeq = 0, this.playSeq = 0, this.depth = 0, this.depthRequest = null, this.failedGeoVideo = /* @__PURE__ */ new Set(), this.lastMeta = null, this.timeMeta = null, this.resolvedTimeRange = null, this.verticalMeta = null, this.variableUnit = "", this.geoVideoManifest = null, this.wmtsMetadata = null, this.fieldSources = /* @__PURE__ */ new Map(), this.archiveChunks = /* @__PURE__ */ new Map(), this.chunkTimes = /* @__PURE__ */ new Map(), this.archiveRoots = /* @__PURE__ */ new Map(), this.archiveLevel = null, this.depthLocked = !1, this.chunkLevels = /* @__PURE__ */ new Map(), this.nextChunkManifest = null, this.activeFieldSource = null, this.switchGeneration = 0, this.destroyed = !1, this.initialized = !1, this.initStarted = !1, this.updateQueue = Promise.resolve(), this.suspended = !1, this.attachQueued = !1, this.anchor = null, this.querySources = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map(), this.onMapReady = () => {
4260
3656
  this.attachQueued && this.attachWhenReady();
@@ -4262,9 +3658,9 @@ class Ca {
4262
3658
  throw new Error("Zartigl requires a layer UUID");
4263
3659
  if (e.time != null && z(e.time, "time"), e.depth != null && !Number.isFinite(e.depth))
4264
3660
  throw new Error("Depth must be finite");
4265
- nt(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
4266
- const t = Ae(e.settings);
4267
- mt(t.legacyKeys), this.style = ae(t.style, e.style), ft(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
3661
+ at(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
3662
+ const t = De(e.settings);
3663
+ ut(t.legacyKeys), this.style = ae(t.style, e.style), ht(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
4268
3664
  this.settings.colorDomain
4269
3665
  )), this.colorDomainOverridden = this.settings.colorDomain !== void 0, this.paletteOverridden = this.settings.palette !== void 0, this.map.on("load", this.onMapReady), this.map.on("styledata", this.onMapReady), this.map.on("idle", this.onMapReady);
4270
3666
  }
@@ -4281,16 +3677,16 @@ class Ca {
4281
3677
  }
4282
3678
  async update(e) {
4283
3679
  this.assertAlive();
4284
- const t = Ae(e.settings);
4285
- mt(t.legacyKeys);
3680
+ const t = De(e.settings);
3681
+ ut(t.legacyKeys);
4286
3682
  const i = t.legacyKeys.length ? { ...e, settings: t.settings, stylePatch: t.style } : e;
4287
3683
  if (!this.initialized)
4288
3684
  throw new Error("Call init() before update()");
4289
3685
  if (i.depth != null && !Number.isFinite(i.depth))
4290
3686
  throw new Error("Depth must be finite");
4291
- i.time != null && z(i.time, "time"), nt(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
4292
- for (const a of [i.style, i.stylePatch])
4293
- a !== void 0 && pt(a, "style");
3687
+ i.time != null && z(i.time, "time"), at(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
3688
+ for (const s of [i.style, i.stylePatch])
3689
+ s !== void 0 && dt(s, "style");
4294
3690
  return i.time != null && this.pause(), this.enqueue(i, ++this.requestSeq);
4295
3691
  }
4296
3692
  /**
@@ -4300,7 +3696,7 @@ class Ca {
4300
3696
  enqueue(e, t) {
4301
3697
  const i = e.layer != null && e.layer !== this.catalogLayer?.id;
4302
3698
  e.time != null ? (this.playbackIntent += 1, this.requestedTime = z(e.time, "time")) : i && (this.requestedTime = null), e.depth != null ? (this.depthRequest = e.depth, this.playbackIntent += 1) : i && (this.depthRequest = null);
4303
- const a = e.layer != null ? ++this.switchGeneration : void 0, r = e.layer != null ? this.applyUpdate(e, a, t) : this.updateQueue.then(() => this.applyUpdate(e, void 0, t));
3699
+ const s = e.layer != null ? ++this.switchGeneration : void 0, r = e.layer != null ? this.applyUpdate(e, s, t) : this.updateQueue.then(() => this.applyUpdate(e, void 0, t));
4304
3700
  if (this.updateQueue = r.catch(() => {
4305
3701
  }), e.depth != null) {
4306
3702
  const n = e.depth;
@@ -4312,14 +3708,14 @@ class Ca {
4312
3708
  }
4313
3709
  async applyUpdate(e, t, i) {
4314
3710
  this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
4315
- const a = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (a || e.source !== this.sourcePreference), n = !a && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, l = a ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), c = e.settings?.palette, u = d !== void 0 && c !== void 0 && typeof c != "string" && e.style?.palette === void 0 ? ga(d) : d;
4316
- ft(u, this.catalog, l);
4317
- const f = u ?? (a ? gt(
3711
+ const s = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (s || e.source !== this.sourcePreference), n = !s && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, c = s ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), u = e.settings?.palette, h = d !== void 0 && u !== void 0 && typeof u != "string" && e.style?.palette === void 0 ? na(d) : d;
3712
+ ht(h, this.catalog, c);
3713
+ const v = h ?? (s ? mt(
4318
3714
  this.style,
4319
- this.catalog.layers.find((m) => m.id === l)?.kind
3715
+ this.catalog.layers.find((m) => m.id === c)?.kind
4320
3716
  ) : void 0);
4321
- if (a) {
4322
- const m = { ...e.settings, ...pe(f) };
3717
+ if (s) {
3718
+ const m = { ...e.settings, ...pe(v) };
4323
3719
  await this.loadLayer(
4324
3720
  e.layer,
4325
3721
  e.source ?? "auto",
@@ -4331,163 +3727,163 @@ class Ca {
4331
3727
  target: o
4332
3728
  },
4333
3729
  t
4334
- ), this.style = f;
3730
+ ), this.style = v;
4335
3731
  } else {
4336
3732
  const m = Object.prototype.hasOwnProperty.call(
4337
3733
  e,
4338
3734
  "timeRange"
4339
- ), p = m ? e.timeRange ?? void 0 : this.timeRange;
3735
+ ), f = m ? e.timeRange ?? void 0 : this.timeRange;
4340
3736
  if (r || n)
4341
- await this.changeSource(e.source, p, o);
4342
- else if (await this.needsSourceSwitch(p, o, m)) {
4343
- const h = this.playing && e.time == null && e.depth != null, g = this.playbackIntent;
4344
- await this.changeSource(this.sourcePreference, p, o), h && g === this.playbackIntent && !this.destroyed && await this.play();
3737
+ await this.changeSource(e.source, f, o);
3738
+ else if (await this.needsSourceSwitch(f, o, m)) {
3739
+ const l = this.playing && e.time == null && e.depth != null, p = this.playbackIntent;
3740
+ await this.changeSource(this.sourcePreference, f, o), l && p === this.playbackIntent && !this.destroyed && await this.play();
4345
3741
  } else m && this.applyTimeRange(e.timeRange ?? null);
4346
3742
  }
4347
- if (!a && f !== void 0) {
4348
- this.style = f;
4349
- const m = { ...e.settings, ...pe(this.style) }, p = this.settings.palette;
4350
- m.palette === void 0 && p && typeof p != "string" && (m.palette = p);
4351
- const h = {
3743
+ if (!s && v !== void 0) {
3744
+ this.style = v;
3745
+ const m = { ...e.settings, ...pe(this.style) }, f = this.settings.palette;
3746
+ m.palette === void 0 && f && typeof f != "string" && (m.palette = f);
3747
+ const l = {
4352
3748
  ...this.styledSettings(),
4353
3749
  ...m
4354
3750
  };
4355
3751
  this.applySettings(
4356
3752
  Object.fromEntries(
4357
- Object.entries(h).filter(
4358
- ([g, x]) => JSON.stringify(x) !== JSON.stringify(this.settings[g])
3753
+ Object.entries(l).filter(
3754
+ ([p, x]) => JSON.stringify(x) !== JSON.stringify(this.settings[p])
4359
3755
  )
4360
3756
  )
4361
3757
  ), this.colorDomainOverridden = m.colorDomain !== void 0, this.paletteOverridden = m.palette !== void 0;
4362
- } else !a && e.settings && this.applySettings(e.settings);
3758
+ } else !s && e.settings && this.applySettings(e.settings);
4363
3759
  e.geoVideo && (e.geoVideo.autoplay != null && (this.autoplay = e.geoVideo.autoplay, this.catalogSource?.type === "geovideo" && (this.autoplay ? await this.startPlayback(i ?? ++this.requestSeq) : this.pause())), e.geoVideo.loop != null && this.applyLoop(e.geoVideo.loop), e.geoVideo.stepsPerSecond != null ? (this.stepsPerSecond = e.geoVideo.stepsPerSecond, this.applyPlaybackSpeed()) : e.geoVideo.playbackRate != null && this.applyPlaybackRate(e.geoVideo.playbackRate)), e.time != null && e.depth != null ? this.applyTimeAndDepth(e.time, e.depth) : (e.time != null && this.applyTime(e.time), e.depth != null && this.applyDepth(e.depth)), e.time != null && this.requestedTime === z(e.time, "time") && (this.requestedTime = null), e.visible != null && this.applyVisible(e.visible);
4364
3760
  }
4365
- async loadLayer(e, t = this.sourcePreference, i, a) {
4366
- const r = this.getSource(), n = lt(this.timeMeta, this.verticalMeta);
4367
- await this.loadSource(e, t, i, a);
3761
+ async loadLayer(e, t = this.sourcePreference, i, s) {
3762
+ const r = this.getSource(), n = rt(this.timeMeta, this.verticalMeta);
3763
+ await this.loadSource(e, t, i, s);
4368
3764
  const o = this.getSource();
4369
- o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : lt(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
3765
+ o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : rt(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
4370
3766
  }
4371
- async loadSource(e, t, i, a) {
3767
+ async loadSource(e, t, i, s) {
4372
3768
  this.assertAlive();
4373
3769
  const r = this.catalog.layers.find(
4374
- (v) => v.id === e
3770
+ (g) => g.id === e
4375
3771
  );
4376
3772
  if (!r)
4377
3773
  throw new Error(`Unknown zartigl catalog entry: ${e}`);
4378
- const n = pa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
3774
+ const n = ra(r), o = i ? i.timeRange : this.timeRange, c = s ?? ++this.switchGeneration, d = {
4379
3775
  ...i?.target,
4380
3776
  depth: i?.target?.depth ?? this.depthRequest ?? void 0
4381
- }, c = await this.selectSource(
3777
+ }, u = await this.selectSource(
4382
3778
  r,
4383
3779
  t,
4384
3780
  o,
4385
3781
  d
4386
- ), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
4387
- if (c.type === "geovideo") {
3782
+ ), h = i?.settings ?? this.settings, v = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
3783
+ if (u.type === "geovideo") {
4388
3784
  this.emit("status", { phase: "metadata" });
4389
3785
  try {
4390
- if (!c.manifestUrl)
3786
+ if (!u.manifestUrl)
4391
3787
  throw new Error(
4392
- `GeoVideo archive source was not resolved to a chunk: ${c.id}`
3788
+ `GeoVideo archive source was not resolved to a chunk: ${u.id}`
4393
3789
  );
4394
- const v = await this.loadChunkManifest(
4395
- c.manifestUrl
3790
+ const g = await this.loadChunkManifest(
3791
+ u.manifestUrl
4396
3792
  ), _ = r.sources.find(
4397
- (ce) => ce.id === v.provenance.inputSourceId
3793
+ (ce) => ce.id === g.provenance.inputSourceId
4398
3794
  );
4399
- if (v.id !== c.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
3795
+ if (g.id !== u.id || g.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
4400
3796
  throw new Error(
4401
- `GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
3797
+ `GeoVideo manifest identity does not match catalog entry/source: ${u.id}`
4402
3798
  );
4403
- const S = Ee(r, c.id), E = S ? this.chunkLevels.get(c.manifestUrl) ?? null : null, R = v.vertical;
4404
- if (S && (E ? !He(R, E) : R !== void 0))
3799
+ const S = Pe(r, u.id), E = S ? this.chunkLevels.get(u.manifestUrl) ?? null : null, P = g.vertical;
3800
+ if (S && (E ? !Xe(P, E) : P !== void 0))
4405
3801
  throw new Error(
4406
- `GeoVideo manifest level does not match its index: ${c.manifestUrl}`
3802
+ `GeoVideo manifest level does not match its index: ${u.manifestUrl}`
4407
3803
  );
4408
- const k = E?.value ?? null, F = S ? await this.archiveTimes(r, c.id, k) : null, L = S ? await this.archiveLevels(r, S) : null, D = !!L?.depths.length, b = !D && !!L?.surface, A = D || b ? ca(L) : null;
4409
- if (l !== this.switchGeneration)
3804
+ const A = E?.value ?? null, U = S ? await this.archiveTimes(r, u.id, A) : null, L = S ? await this.archiveLevels(r, S) : null, D = !!L?.depths.length, b = !D && !!L?.surface, V = D || b ? Ji(L) : null;
3805
+ if (c !== this.switchGeneration)
4410
3806
  throw new DOMException(
4411
3807
  "Layer selection was superseded",
4412
3808
  "AbortError"
4413
3809
  );
4414
- const N = we(v), C = ha(F ?? N), I = re(
3810
+ const X = we(g), C = ea(U ?? X), I = re(
4415
3811
  C,
4416
3812
  o
4417
3813
  ), w = ne(
4418
3814
  C,
4419
3815
  o
4420
- ), U = N.filter(
3816
+ ), k = X.filter(
4421
3817
  (ce) => ce >= w.min && ce <= w.max
4422
- ), X = U.length ? U : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
4423
- this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = v, this.wmtsMetadata = null, this.fullTimeMeta = C, this.resolvedTimeRange = I, this.timeMeta = w, this.verticalMeta = A, this.variableUnit = v.style.unit ?? "", this.variableStandardName = v.provenance.variables[0], this.time = this.pendingTime == null ? X[0] : V(X, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = k, this.depth = D ? k ?? L.surface?.value ?? 0 : Le(A, d.depth), D && (this.depthRequest = this.depth);
4424
- const Ot = u.colorDomain;
4425
- if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? Ot ?? null : v.style.colorDomain, this.settings.palette = m ? this.settings.palette : qe(r.defaults).palette ?? v.style.palette, this.lastMeta = null, oe && this.replaceGeoVideoInPlace(le))
3818
+ ), W = k.length ? k : X, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
3819
+ this.catalogLayer = r, this.catalogSource = u, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = g, this.wmtsMetadata = null, this.fullTimeMeta = C, this.resolvedTimeRange = I, this.timeMeta = w, this.verticalMeta = V, this.variableUnit = g.style.unit ?? "", this.variableStandardName = g.provenance.variables[0], this.time = this.pendingTime == null ? W[0] : F(W, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = A, this.depth = D ? A ?? L.surface?.value ?? 0 : Ee(V, d.depth), D && (this.depthRequest = this.depth);
3820
+ const zt = h.colorDomain;
3821
+ if (this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.settings.colorDomain = v ? zt ?? null : g.style.colorDomain, this.settings.palette = m ? this.settings.palette : $e(r.defaults).palette ?? g.style.palette, this.lastMeta = null, oe && this.replaceGeoVideoInPlace(le))
4426
3822
  return;
4427
3823
  this.detach(), this.attachWhenReady();
4428
3824
  return;
4429
- } catch (v) {
4430
- const _ = v instanceof Error ? v : new Error(String(v)), S = c.manifestUrl;
4431
- if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== c.id)
4432
- return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, l);
3825
+ } catch (g) {
3826
+ const _ = g instanceof Error ? g : new Error(String(g)), S = u.manifestUrl;
3827
+ if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== u.id)
3828
+ return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, c);
4433
3829
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4434
3830
  }
4435
3831
  }
4436
- if (c.type === "wmts") {
3832
+ if (u.type === "wmts") {
4437
3833
  this.emit("status", { phase: "metadata" });
4438
3834
  try {
4439
- const v = await na(c);
4440
- if (l !== this.switchGeneration)
3835
+ const g = await ji(u);
3836
+ if (c !== this.switchGeneration)
4441
3837
  throw new DOMException(
4442
3838
  "Layer selection was superseded",
4443
3839
  "AbortError"
4444
3840
  );
4445
- const _ = v.time, S = ne(_, o);
3841
+ const _ = g.time, S = ne(_, o);
4446
3842
  this.detach(), this.catalogLayer = r, this.catalogSource = {
4447
- ...c,
4448
- baseUrl: v.baseUrl,
4449
- tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
4450
- tileMatrixSet: v.tileMatrixSet,
4451
- format: v.format,
4452
- style: c.style ?? v.style
4453
- }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
3843
+ ...u,
3844
+ baseUrl: g.baseUrl,
3845
+ tileUrlTemplate: u.tileUrlTemplate ?? g.tileUrlTemplate,
3846
+ tileMatrixSet: g.tileMatrixSet,
3847
+ format: g.format,
3848
+ style: u.style ?? g.style
3849
+ }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = g, this.fullTimeMeta = _, this.resolvedTimeRange = re(
4454
3850
  _,
4455
3851
  o
4456
- ), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = c.layer, this.time = this.pendingTime == null ? st(S.values, Date.now()) : V(S.values, this.pendingTime), this.pendingTime = null, this.depth = Le(v.vertical, d.depth), this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.lastMeta = null, this.attachWhenReady();
3852
+ ), this.timeMeta = S, this.verticalMeta = g.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = u.layer, this.time = this.pendingTime == null ? tt(S.values, Date.now()) : F(S.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(g.vertical, d.depth), this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.lastMeta = null, this.attachWhenReady();
4457
3853
  return;
4458
- } catch (v) {
4459
- const _ = v instanceof Error ? v : new Error(String(v));
3854
+ } catch (g) {
3855
+ const _ = g instanceof Error ? g : new Error(String(g));
4460
3856
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4461
3857
  }
4462
3858
  }
4463
- const p = this.getFieldSource(c.endpoints.field);
4464
- let h, g, x, T, M;
3859
+ const f = this.getFieldSource(u.endpoints.field);
3860
+ let l, p, x, T, R;
4465
3861
  this.emit("status", { phase: "metadata" });
4466
3862
  try {
4467
- await p.init();
4468
- const v = fe(c);
4469
- for (const _ of v)
4470
- if (!p.hasVariable(_))
3863
+ await f.init();
3864
+ const g = fe(u);
3865
+ for (const _ of g)
3866
+ if (!f.hasVariable(_))
4471
3867
  throw new Error(
4472
3868
  `Configured variable not found in Zarr store: ${_}`
4473
3869
  );
4474
- if (g = rt(
4475
- c,
4476
- p.getTimeDimension()
4477
- ), g.values.length === 0)
3870
+ if (p = it(
3871
+ u,
3872
+ f.getTimeDimension()
3873
+ ), p.values.length === 0)
4478
3874
  throw new Error("Zarr time coordinate is empty");
4479
- x = re(g, o), h = ne(g, o), T = p.getVerticalDimension(v[0]) ?? null, M = p.getVariableAttrs(
4480
- v[v.length - 1]
3875
+ x = re(p, o), l = ne(p, o), T = f.getVerticalDimension(g[0]) ?? null, R = f.getVariableAttrs(
3876
+ g[g.length - 1]
4481
3877
  );
4482
- } catch (v) {
4483
- const _ = v instanceof Error ? v : new Error(String(v));
3878
+ } catch (g) {
3879
+ const _ = g instanceof Error ? g : new Error(String(g));
4484
3880
  throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
4485
3881
  }
4486
- if (l !== this.switchGeneration)
3882
+ if (c !== this.switchGeneration)
4487
3883
  throw new DOMException("Layer selection was superseded", "AbortError");
4488
- this.detach(), this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = p, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = g, this.resolvedTimeRange = x, this.timeMeta = h, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof M.units == "string" ? M.units : "", this.variableStandardName = typeof M.standard_name == "string" ? M.standard_name : void 0, this.time = this.pendingTime == null ? st(this.timeMeta.values, Date.now()) : V(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
4489
- const y = u.colorDomain;
4490
- this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
3884
+ this.detach(), this.catalogLayer = r, this.catalogSource = u, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = f, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = p, this.resolvedTimeRange = x, this.timeMeta = l, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof R.units == "string" ? R.units : "", this.variableStandardName = typeof R.standard_name == "string" ? R.standard_name : void 0, this.time = this.pendingTime == null ? tt(this.timeMeta.values, Date.now()) : F(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(T, d.depth);
3885
+ const y = h.colorDomain;
3886
+ this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.settings.colorDomain = v ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
4491
3887
  }
4492
3888
  async changeSource(e, t = this.timeRange, i = {}) {
4493
3889
  if (this.assertAlive(), !this.catalogLayer) {
@@ -4508,19 +3904,19 @@ class Ca {
4508
3904
  * depth ever switches to another source.
4509
3905
  */
4510
3906
  async needsSourceSwitch(e, t, i) {
4511
- const a = this.catalogLayer, r = this.catalogSource;
4512
- if (!a || !r || !this.isArchiveChunk(r))
3907
+ const s = this.catalogLayer, r = this.catalogSource;
3908
+ if (!s || !r || !this.isArchiveChunk(r))
4513
3909
  return !1;
4514
- const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null && ot(o, t.depth) !== this.archiveLevel;
4515
- if ((t.time == null && !i || Bt(r, this.sourceTimeRequest(e, t.time))) && !d)
3910
+ const n = Pe(s, this.sourcePreference), o = n ? await this.archiveLevels(s, n) : null, d = !!o?.depths.length && t.depth != null && st(o, t.depth) !== this.archiveLevel;
3911
+ if ((t.time == null && !i || Gt(r, this.sourceTimeRequest(e, t.time))) && !d)
4516
3912
  return !1;
4517
- const u = await this.selectSource(
4518
- a,
3913
+ const h = await this.selectSource(
3914
+ s,
4519
3915
  this.sourcePreference,
4520
3916
  e,
4521
3917
  t
4522
3918
  );
4523
- return !ii(u, r);
3919
+ return !Jt(h, r);
4524
3920
  }
4525
3921
  applyVisible(e) {
4526
3922
  this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
@@ -4545,7 +3941,7 @@ class Ca {
4545
3941
  applyTime(e) {
4546
3942
  this.assertAlive();
4547
3943
  const t = z(e, "time");
4548
- this.layer || (this.pendingTime = t), this.time = V(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
3944
+ this.layer || (this.pendingTime = t), this.time = F(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
4549
3945
  }
4550
3946
  /** Start GeoVideo playback; does nothing where playback is unavailable. */
4551
3947
  async play() {
@@ -4572,7 +3968,7 @@ class Ca {
4572
3968
  const t = this.timeMeta?.values ?? [];
4573
3969
  if (!t.length)
4574
3970
  return;
4575
- const i = V(t, this.requestedTime ?? this.time);
3971
+ const i = F(t, this.requestedTime ?? this.time);
4576
3972
  return t[t.indexOf(i) + e];
4577
3973
  }
4578
3974
  pause() {
@@ -4593,10 +3989,10 @@ class Ca {
4593
3989
  }
4594
3990
  /** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
4595
3991
  effectivePlaybackRate() {
4596
- return this.stepsPerSecond != null && this.geoVideoManifest ? ai(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
3992
+ return this.stepsPerSecond != null && this.geoVideoManifest ? ei(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4597
3993
  }
4598
3994
  playbackSpeeds() {
4599
- return this.catalogLayer?.kind === "vector" ? at : oa;
3995
+ return this.catalogLayer?.kind === "vector" ? et : Qi;
4600
3996
  }
4601
3997
  /**
4602
3998
  * Steps per second the active source shows. Vector GeoVideo stays inside
@@ -4604,29 +4000,29 @@ class Ca {
4604
4000
  */
4605
4001
  appliedStepsPerSecond() {
4606
4002
  if (this.catalogLayer?.kind === "vector") {
4607
- const e = at;
4003
+ const e = et;
4608
4004
  return Math.min(
4609
4005
  e[e.length - 1],
4610
4006
  Math.max(e[0], this.stepsPerSecond ?? 1)
4611
4007
  );
4612
4008
  }
4613
- return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * si(this.geoVideoManifest) : this.playbackRate;
4009
+ return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ti(this.geoVideoManifest) : this.playbackRate;
4614
4010
  }
4615
4011
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
4616
4012
  applyTimeRange(e) {
4617
4013
  if (this.assertAlive(), !this.fullTimeMeta)
4618
4014
  throw new Error("Set a layer before changing its time range");
4619
- const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r = V(a.values, this.time);
4620
- return this.timeRange = t, this.resolvedTimeRange = i, this.timeMeta = a, this.time = r, this.layer?.setTimeRange([a.min, a.max]), this.layer?.setTime(r), this.getTimeMeta();
4015
+ const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), s = ne(this.fullTimeMeta, t), r = F(s.values, this.time);
4016
+ return this.timeRange = t, this.resolvedTimeRange = i, this.timeMeta = s, this.time = r, this.layer?.setTimeRange([s.min, s.max]), this.layer?.setTime(r), this.getTimeMeta();
4621
4017
  }
4622
4018
  applyDepth(e) {
4623
- this.assertAlive(), this.depth = V(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4019
+ this.assertAlive(), this.depth = F(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4624
4020
  }
4625
4021
  applyTimeAndDepth(e, t) {
4626
- this.assertAlive(), this.time = V(
4022
+ this.assertAlive(), this.time = F(
4627
4023
  this.timeMeta?.values ?? [],
4628
4024
  z(e, "time")
4629
- ), this.depth = V(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4025
+ ), this.depth = F(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4630
4026
  }
4631
4027
  on(e, t) {
4632
4028
  return this.assertAlive(), this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), this;
@@ -4644,7 +4040,7 @@ class Ca {
4644
4040
  values: t.values,
4645
4041
  units: t.units,
4646
4042
  current: this.time,
4647
- granularity: la(t.values),
4043
+ granularity: Ki(t.values),
4648
4044
  timelineKind: this.geoVideoManifest?.timeline.kind
4649
4045
  } : {
4650
4046
  min: NaN,
@@ -4660,7 +4056,7 @@ class Ca {
4660
4056
  return { values: [], label: "depth", current: void 0 };
4661
4057
  const e = this.verticalMeta;
4662
4058
  return {
4663
- values: Ft(e.values),
4059
+ values: At(e.values),
4664
4060
  name: e.name,
4665
4061
  label: e.label,
4666
4062
  units: e.units,
@@ -4681,7 +4077,7 @@ class Ca {
4681
4077
  const i = this.catalogSource;
4682
4078
  return {
4683
4079
  type: "image",
4684
- url: ji({
4080
+ url: Oi({
4685
4081
  baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
4686
4082
  layer: i.layer,
4687
4083
  style: i.style
@@ -4690,30 +4086,30 @@ class Ca {
4690
4086
  };
4691
4087
  }
4692
4088
  if (this.catalogSource.type === "geovideo" && this.geoVideoManifest) {
4693
- const i = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", a = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4089
+ const i = typeof this.settings.palette == "string" ? Ie(this.settings.palette) : "custom", s = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4694
4090
  return {
4695
4091
  type: "gradient",
4696
4092
  palette: i,
4697
4093
  reverse: this.settings.reversePalette ?? !1,
4698
- alphaFade: Ve(this.settings),
4699
- min: a[0],
4700
- max: a[1],
4701
- unit: Ye(this.geoVideoManifest.style.unit)
4094
+ alphaFade: Ue(this.settings),
4095
+ min: s[0],
4096
+ max: s[1],
4097
+ unit: He(this.geoVideoManifest.style.unit)
4702
4098
  };
4703
4099
  }
4704
- const e = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4100
+ const e = typeof this.settings.palette == "string" ? Ie(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4705
4101
  return {
4706
4102
  type: "gradient",
4707
4103
  palette: e,
4708
4104
  reverse: this.settings.reversePalette ?? !1,
4709
- alphaFade: this.catalogLayer.kind === "scalar" ? Ve(this.settings) : void 0,
4105
+ alphaFade: this.catalogLayer.kind === "scalar" ? Ue(this.settings) : void 0,
4710
4106
  min: t?.[0] ?? this.lastMeta?.min,
4711
4107
  max: t?.[1] ?? this.lastMeta?.max,
4712
- unit: Ye(this.lastMeta?.unit ?? this.variableUnit)
4108
+ unit: He(this.lastMeta?.unit ?? this.variableUnit)
4713
4109
  };
4714
4110
  }
4715
4111
  getPalettes() {
4716
- return xt();
4112
+ return vt();
4717
4113
  }
4718
4114
  getSource() {
4719
4115
  return this.catalogSource ? { id: this.catalogSource.id, type: this.catalogSource.type } : void 0;
@@ -4747,7 +4143,7 @@ class Ca {
4747
4143
  return this.catalogLayer?.kind !== "vector";
4748
4144
  const t = this.timeMeta;
4749
4145
  return we(e).filter(
4750
- (a) => !t || a >= t.min && a <= t.max
4146
+ (s) => !t || s >= t.min && s <= t.max
4751
4147
  ).length > 1;
4752
4148
  }
4753
4149
  /** Whether palette/domain styling is applied to values in the active renderer. */
@@ -4761,7 +4157,7 @@ class Ca {
4761
4157
  getStyle() {
4762
4158
  return ze(
4763
4159
  this.catalogLayer ?? void 0,
4764
- Ae(this.settings).style
4160
+ De(this.settings).style
4765
4161
  );
4766
4162
  }
4767
4163
  /** The style override over the layer's own. */
@@ -4785,7 +4181,7 @@ class Ca {
4785
4181
  devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
4786
4182
  catalogEntry: this.catalogLayer ? {
4787
4183
  id: this.catalogLayer.id,
4788
- title: $t(
4184
+ title: Ot(
4789
4185
  this.catalogLayer.title,
4790
4186
  this.catalog.defaultLocale,
4791
4187
  this.catalog.defaultLocale
@@ -4810,26 +4206,26 @@ class Ca {
4810
4206
  * color domain of a GeoVideo archive included, as a load sets them.
4811
4207
  */
4812
4208
  styledSettings() {
4813
- const e = Ut(
4209
+ const e = kt(
4814
4210
  this.catalogLayer ?? void 0,
4815
4211
  this.style
4816
4212
  ), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
4817
- return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = qe(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4213
+ return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = $e(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4818
4214
  }
4819
4215
  applySettings(e) {
4820
4216
  this.assertAlive();
4821
4217
  const t = e.colorDomain === void 0 ? e : {
4822
4218
  ...e,
4823
4219
  colorDomain: Q(e.colorDomain)
4824
- }, i = fa.some(
4220
+ }, i = sa.some(
4825
4221
  (r) => t[r] != null && t[r] !== this.settings[r]
4826
- ), a = t.particleState != null && t.particleState !== this.settings.particleState;
4222
+ ), s = t.particleState != null && t.particleState !== this.settings.particleState;
4827
4223
  if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
4828
4224
  if (i && this.catalogSource?.type === "geovideo") {
4829
- this.layer.setColorRamp(De(this.settings)), this.applyMutableSettings(this.layer, t);
4225
+ this.layer.setColorRamp(Le(this.settings)), this.applyMutableSettings(this.layer, t);
4830
4226
  return;
4831
4227
  }
4832
- if (i || a) {
4228
+ if (i || s) {
4833
4229
  this.detach(), this.attachWhenReady();
4834
4230
  return;
4835
4231
  }
@@ -4843,14 +4239,14 @@ class Ca {
4843
4239
  throw new Error(
4844
4240
  `Catalog entry does not provide point-query capability: ${t.id}`
4845
4241
  );
4846
- const a = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
4242
+ const s = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
4847
4243
  await r.init();
4848
- const n = r.getTimeDimension().values, o = rt(
4244
+ const n = r.getTimeDimension().values, o = it(
4849
4245
  i,
4850
4246
  r.getTimeDimension()
4851
4247
  );
4852
4248
  if (!this.timeRange && o.size === n.length) {
4853
- const m = Math.max(1, Math.ceil(n.length / a));
4249
+ const m = Math.max(1, Math.ceil(n.length / s));
4854
4250
  return r.sampleTimeSeries({
4855
4251
  variables: fe(i),
4856
4252
  longitude: e.longitude,
@@ -4860,30 +4256,30 @@ class Ca {
4860
4256
  stopAfterMissingSamples: 12
4861
4257
  });
4862
4258
  }
4863
- const l = this.timeRange ? Math.max(
4259
+ const c = this.timeRange ? Math.max(
4864
4260
  o.min,
4865
4261
  this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
4866
4262
  ) : o.min, d = this.timeRange ? Math.min(
4867
4263
  o.max,
4868
4264
  this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
4869
- ) : o.max, c = n.findIndex((m) => m >= l);
4870
- let u = n.length - 1;
4871
- for (; u >= 0 && n[u] > d; )
4872
- u--;
4873
- if (c < 0 || u < c)
4265
+ ) : o.max, u = n.findIndex((m) => m >= c);
4266
+ let h = n.length - 1;
4267
+ for (; h >= 0 && n[h] > d; )
4268
+ h--;
4269
+ if (u < 0 || h < u)
4874
4270
  throw new Error("Time range does not overlap the point-series store");
4875
- const f = Math.max(
4271
+ const v = Math.max(
4876
4272
  1,
4877
- Math.ceil((u - c + 1) / a)
4273
+ Math.ceil((h - u + 1) / s)
4878
4274
  );
4879
4275
  return r.sampleTimeSeries({
4880
4276
  variables: fe(i),
4881
4277
  longitude: e.longitude,
4882
4278
  latitude: e.latitude,
4883
4279
  depth: e.depth ?? this.depth,
4884
- timeStartIndex: c,
4885
- timeEndIndex: u,
4886
- stride: f,
4280
+ timeStartIndex: u,
4281
+ timeEndIndex: h,
4282
+ stride: v,
4887
4283
  stopAfterMissingSamples: 12
4888
4284
  });
4889
4285
  }
@@ -4919,7 +4315,7 @@ class Ca {
4919
4315
  );
4920
4316
  return;
4921
4317
  }
4922
- const e = new ia({
4318
+ const e = new Xi({
4923
4319
  id: this.id,
4924
4320
  entry: this.catalogLayer,
4925
4321
  sourceConfig: this.catalogSource,
@@ -4945,14 +4341,14 @@ class Ca {
4945
4341
  zarrSource: this.activeFieldSource ?? void 0,
4946
4342
  unit: this.variableUnit,
4947
4343
  verticalLabel: this.verticalMeta?.label,
4948
- colorRamp: De(this.settings),
4344
+ colorRamp: Le(this.settings),
4949
4345
  metadata: this.metadata ? { ...this.metadata } : void 0,
4950
4346
  before: this.before
4951
4347
  });
4952
4348
  this.pendingTime = null, this.autoplayPending = !1, e.on("loading", () => this.emit("loading")), e.on("loaded", (t) => {
4953
4349
  this.lastMeta = t, this.emit("loaded", t);
4954
4350
  }), e.on("error", (t) => this.emit("error", t)), e.on("status", (t) => this.emit("status", t)), e.on("frameBuffered", (t) => this.emit("frameBuffered", t)), e.on("cacheInvalidated", () => this.emit("cacheInvalidated")), e.on("timeChange", (t) => {
4955
- e === this.layer && (this.time = V(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4351
+ e === this.layer && (this.time = F(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4956
4352
  }), e.on("playbackChange", (t) => {
4957
4353
  e === this.layer && (t && this.preloadNextArchiveChunk(e), t !== this.playing && (this.playing = t, this.emit("playbackChange", t)));
4958
4354
  }), e.on("playbackEnd", () => {
@@ -4984,7 +4380,7 @@ class Ca {
4984
4380
  loop: i.geoVideoLoop,
4985
4381
  playbackRate: i.geoVideoPlaybackRate,
4986
4382
  stepsPerSecond: this.catalogLayer?.kind === "vector" ? this.appliedStepsPerSecond() : void 0
4987
- }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(De(this.settings)), !0) : !1;
4383
+ }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(Le(this.settings)), !0) : !1;
4988
4384
  }
4989
4385
  detach() {
4990
4386
  const e = this.layer;
@@ -4999,19 +4395,19 @@ class Ca {
4999
4395
  }
5000
4396
  getQuerySource(e) {
5001
4397
  let t = this.querySources.get(e);
5002
- return t || (t = new _e(e, 80), this.querySources.set(e, t)), t;
4398
+ return t || (t = new ve(e, 80), this.querySources.set(e, t)), t;
5003
4399
  }
5004
4400
  getFieldSource(e) {
5005
4401
  let t = this.fieldSources.get(e);
5006
- return t || (t = new _e(e), this.fieldSources.set(e, t)), t;
4402
+ return t || (t = new ve(e), this.fieldSources.set(e, t)), t;
5007
4403
  }
5008
4404
  /**
5009
4405
  * Time the caller asked for, so selection skips fixed-period sources (such
5010
4406
  * as a GeoVideo artifact) that cannot show it. A trailing window targets now.
5011
4407
  */
5012
4408
  sourceTimeRequest(e, t) {
5013
- const i = t ?? this.pendingTime, a = {};
5014
- return i != null && (a.time = z(i, "time")), e?.trailing ? a.start = a.end = Date.now() : e && (e.start != null && (a.start = z(e.start, "timeRange.start")), e.end != null && (a.end = z(e.end, "timeRange.end"))), a;
4409
+ const i = t ?? this.pendingTime, s = {};
4410
+ return i != null && (s.time = z(i, "time")), e?.trailing ? s.start = s.end = Date.now() : e && (e.start != null && (s.start = z(e.start, "timeRange.start")), e.end != null && (s.end = z(e.end, "timeRange.end"))), s;
5015
4411
  }
5016
4412
  /**
5017
4413
  * Source for a preference and target. An archive (pinned, or the
@@ -5020,25 +4416,25 @@ class Ca {
5020
4416
  * "auto" moves on to Zarr. Regional artifacts show only when pinned. In
5021
4417
  * "auto", a level deeper than the surface GeoVideo renders shows Zarr.
5022
4418
  */
5023
- async selectSource(e, t, i, a = {}) {
5024
- const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
4419
+ async selectSource(e, t, i, s = {}) {
4420
+ const r = this.sourceTimeRequest(i, s.time), n = Pe(e, t);
5025
4421
  if (n) {
5026
- const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && a.depth != null ? ot(o, a.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, c = await this.resolveArchives(e, d), u = c.sources.filter(
4422
+ const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && s.depth != null ? st(o, s.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, u = await this.resolveArchives(e, d), h = u.sources.filter(
5027
4423
  (m) => m.id === n.id
5028
4424
  );
5029
- if (u.length) {
4425
+ if (h.length) {
5030
4426
  const m = await this.archiveSample(
5031
4427
  e,
5032
4428
  n.id,
5033
4429
  i,
5034
- a.time,
4430
+ s.time,
5035
4431
  d
5036
- ), p = ri(u, { time: m });
5037
- if (p && !this.isFailedGeoVideo(p))
5038
- return p;
4432
+ ), f = ii(h, { time: m });
4433
+ if (f && !this.isFailedGeoVideo(f))
4434
+ return f;
5039
4435
  if (t !== "auto" || this.catalogSource?.id === n.id)
5040
4436
  throw new Error(
5041
- `GeoVideo chunk unavailable: ${p?.type === "geovideo" ? p.manifestUrl : n.id}`
4437
+ `GeoVideo chunk unavailable: ${f?.type === "geovideo" ? f.manifestUrl : n.id}`
5042
4438
  );
5043
4439
  } else {
5044
4440
  if (d != null)
@@ -5046,17 +4442,17 @@ class Ca {
5046
4442
  if (t !== "auto")
5047
4443
  throw new Error(`GeoVideo archive unavailable: ${n.id}`);
5048
4444
  }
5049
- const f = he(c, ["zarr"], r);
5050
- if (f)
5051
- return f;
4445
+ const v = ue(u, ["zarr"], r);
4446
+ if (v)
4447
+ return v;
5052
4448
  e = {
5053
- ...c,
5054
- sources: c.sources.filter(
4449
+ ...u,
4450
+ sources: u.sources.filter(
5055
4451
  (m) => m.type !== "geovideo"
5056
4452
  )
5057
4453
  };
5058
4454
  }
5059
- return t === "auto" && this.isFailedGeoVideo(this.resolveSource(e, t, r)) ? he(e, ["zarr"], r) ?? this.resolveSource(
4455
+ return t === "auto" && this.isFailedGeoVideo(this.resolveSource(e, t, r)) ? ue(e, ["zarr"], r) ?? this.resolveSource(
5060
4456
  this.withoutFailedGeoVideo(e),
5061
4457
  t,
5062
4458
  r
@@ -5074,7 +4470,7 @@ class Ca {
5074
4470
  }
5075
4471
  isArchiveChunk(e) {
5076
4472
  return e.type === "geovideo" && !!this.catalogLayer?.sources.some(
5077
- (t) => t.id === e.id && Fe(t)
4473
+ (t) => t.id === e.id && ke(t)
5078
4474
  );
5079
4475
  }
5080
4476
  /**
@@ -5086,7 +4482,7 @@ class Ca {
5086
4482
  if (!e || !t || !this.isArchiveChunk(t))
5087
4483
  return null;
5088
4484
  const i = this.archiveLevel;
5089
- return ni(
4485
+ return ai(
5090
4486
  (await this.resolveArchives(e, i)).sources,
5091
4487
  t,
5092
4488
  {
@@ -5097,7 +4493,7 @@ class Ca {
5097
4493
  }
5098
4494
  /** A chunk manifest, reusing the one requested ahead for the next chunk. */
5099
4495
  loadChunkManifest(e) {
5100
- return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ce(e);
4496
+ return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ae(e);
5101
4497
  }
5102
4498
  /**
5103
4499
  * While a scalar archive chunk plays, load the next chunk into the layer so
@@ -5107,10 +4503,10 @@ class Ca {
5107
4503
  const t = this.catalogSource;
5108
4504
  if (t)
5109
4505
  try {
5110
- const i = await this.nextArchiveChunk(), a = i?.source.type === "geovideo" && i.source.manifestUrl;
5111
- if (!i || !a)
4506
+ const i = await this.nextArchiveChunk(), s = i?.source.type === "geovideo" && i.source.manifestUrl;
4507
+ if (!i || !s)
5112
4508
  return;
5113
- this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest: Ce(a) });
4509
+ this.nextChunkManifest?.url !== s && (this.nextChunkManifest = { url: s, manifest: Ae(s) });
5114
4510
  const r = this.nextChunkManifest, n = await r.manifest.catch((o) => {
5115
4511
  throw this.nextChunkManifest === r && (this.nextChunkManifest = null), o;
5116
4512
  });
@@ -5148,7 +4544,7 @@ class Ca {
5148
4544
  }
5149
4545
  /** The entry's initialised field Zarr, or null when it has none. */
5150
4546
  async entryFieldZarr(e) {
5151
- const t = he(e, ["zarr"]);
4547
+ const t = ue(e, ["zarr"]);
5152
4548
  if (t?.type !== "zarr")
5153
4549
  return null;
5154
4550
  const i = this.getFieldSource(t.endpoints.field);
@@ -5160,22 +4556,22 @@ class Ca {
5160
4556
  * a time; one that cannot be read only leaves its samples out.
5161
4557
  */
5162
4558
  async archiveTimes(e, t, i = null) {
5163
- const a = (await this.resolveArchives(e, i)).sources.flatMap(
4559
+ const s = (await this.resolveArchives(e, i)).sources.flatMap(
5164
4560
  (n) => n.id === t && n.type === "geovideo" && n.manifestUrl ? [n.manifestUrl] : []
5165
- ), r = a.filter((n) => !this.chunkTimes.has(n));
5166
- for (let n = 0; n < r.length; n += ct) {
5167
- const o = r.slice(n, n + ct);
4561
+ ), r = s.filter((n) => !this.chunkTimes.has(n));
4562
+ for (let n = 0; n < r.length; n += nt) {
4563
+ const o = r.slice(n, n + nt);
5168
4564
  (await Promise.allSettled(
5169
4565
  o.map((d) => this.loadChunkManifest(d))
5170
- )).forEach((d, c) => {
5171
- d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
4566
+ )).forEach((d, u) => {
4567
+ d.status === "fulfilled" ? this.chunkTimes.set(o[u], we(d.value)) : console.warn(
5172
4568
  "[zartigl] GeoVideo chunk samples unavailable:",
5173
4569
  d.reason
5174
4570
  );
5175
4571
  });
5176
4572
  }
5177
4573
  return [
5178
- ...new Set(a.flatMap((n) => this.chunkTimes.get(n) ?? []))
4574
+ ...new Set(s.flatMap((n) => this.chunkTimes.get(n) ?? []))
5179
4575
  ].sort((n, o) => n - o);
5180
4576
  }
5181
4577
  /**
@@ -5184,14 +4580,14 @@ class Ca {
5184
4580
  * the latest without a time. Snapping once, here, keeps the chunk loaded
5185
4581
  * and the time shown in agreement.
5186
4582
  */
5187
- async archiveSample(e, t, i, a, r = null) {
5188
- const n = await this.archiveTimes(e, t, r), [o, l] = i && n.length ? bt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((u) => u >= o && u <= l);
4583
+ async archiveSample(e, t, i, s, r = null) {
4584
+ const n = await this.archiveTimes(e, t, r), [o, c] = i && n.length ? yt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((h) => h >= o && h <= c);
5189
4585
  if (d.length === 0)
5190
4586
  throw new RangeError(
5191
4587
  "Time range does not contain any available timestamps"
5192
4588
  );
5193
- const c = this.sourceTimeRequest(void 0, a).time;
5194
- return c == null ? d[d.length - 1] : V(d, c);
4589
+ const u = this.sourceTimeRequest(void 0, s).time;
4590
+ return u == null ? d[d.length - 1] : F(d, u);
5195
4591
  }
5196
4592
  /**
5197
4593
  * Entry whose archive sources are replaced by one fixed-period source per
@@ -5201,22 +4597,22 @@ class Ca {
5201
4597
  */
5202
4598
  async resolveArchives(e, t = null) {
5203
4599
  const i = await Promise.all(
5204
- e.sources.map(async (a) => {
5205
- if (!Fe(a))
5206
- return [a];
4600
+ e.sources.map(async (s) => {
4601
+ if (!ke(s))
4602
+ return [s];
5207
4603
  const r = await this.archiveChunksAt(
5208
4604
  e,
5209
- a,
5210
- a.indexUrl,
4605
+ s,
4606
+ s.indexUrl,
5211
4607
  null
5212
4608
  );
5213
4609
  if (t == null)
5214
4610
  return r;
5215
- const n = this.archiveRoots.get(a.indexUrl)?.depths.find((o) => o.value === t);
4611
+ const n = this.archiveRoots.get(s.indexUrl)?.depths.find((o) => o.value === t);
5216
4612
  return n ? this.archiveChunksAt(
5217
4613
  e,
5218
- a,
5219
- oi(n, a.indexUrl),
4614
+ s,
4615
+ si(n, s.indexUrl),
5220
4616
  n
5221
4617
  ) : [];
5222
4618
  })
@@ -5232,46 +4628,46 @@ class Ca {
5232
4628
  * which also lists the levels below, or a depth's, which must record that
5233
4629
  * level. Revalidated like any archive index.
5234
4630
  */
5235
- archiveChunksAt(e, t, i, a) {
4631
+ archiveChunksAt(e, t, i, s) {
5236
4632
  const r = this.archiveChunks.get(i);
5237
4633
  if (r && r.expires > Date.now())
5238
4634
  return r.chunks;
5239
4635
  const n = {
5240
- expires: Date.now() + ua,
5241
- chunks: li(i).then((o) => {
5242
- if (a ? !He(o.vertical, a) : o.vertical !== void 0)
4636
+ expires: Date.now() + ta,
4637
+ chunks: ri(i).then((o) => {
4638
+ if (s ? !Xe(o.vertical, s) : o.vertical !== void 0)
5243
4639
  throw new Error(`GeoVideo index level does not match: ${i}`);
5244
- !a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
4640
+ !s && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
5245
4641
  surface: o.surface,
5246
4642
  depths: o.depths ?? []
5247
4643
  });
5248
- const l = ci(
4644
+ const c = ni(
5249
4645
  { ...t, indexUrl: i },
5250
4646
  o,
5251
4647
  e
5252
4648
  );
5253
- for (const d of hi(o, i))
5254
- this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
5255
- return l;
5256
- }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + da, []))
4649
+ for (const d of oi(o, i))
4650
+ this.chunkLevels.set(d.manifestUrl, s), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
4651
+ return c;
4652
+ }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ia, []))
5257
4653
  };
5258
4654
  return this.archiveChunks.set(i, n), n.chunks;
5259
4655
  }
5260
4656
  resolveSource(e, t, i) {
5261
- const a = t === "auto" ? qt(e, i) : e.sources.find((r) => r.id === t) ?? he(
4657
+ const s = t === "auto" ? Nt(e, i) : e.sources.find((r) => r.id === t) ?? ue(
5262
4658
  e,
5263
4659
  [t],
5264
4660
  i
5265
4661
  );
5266
- if (!a)
4662
+ if (!s)
5267
4663
  throw new Error(
5268
4664
  `Catalog entry ${e.id} does not provide source: ${t}`
5269
4665
  );
5270
- if (e.kind === "vector" && a.type !== "zarr" && a.type !== "geovideo")
4666
+ if (e.kind === "vector" && s.type !== "zarr" && s.type !== "geovideo")
5271
4667
  throw new Error(
5272
4668
  `Vector catalog entry ${e.id} requires a Zarr or GeoVideo source`
5273
4669
  );
5274
- return a;
4670
+ return s;
5275
4671
  }
5276
4672
  querySource(e) {
5277
4673
  const t = e.defaults.querySourceId ? e.sources.find(
@@ -5300,7 +4696,7 @@ class Ca {
5300
4696
  /** First layer above the render layer that is not its own WMTS raster. */
5301
4697
  layerAbove(e) {
5302
4698
  const t = this.map.getLayersOrder?.() ?? [], i = t.indexOf(e);
5303
- return i < 0 ? void 0 : t.slice(i + 1).find((a) => a !== `${e}-wmts`);
4699
+ return i < 0 ? void 0 : t.slice(i + 1).find((s) => s !== `${e}-wmts`);
5304
4700
  }
5305
4701
  requireLayer() {
5306
4702
  if (!this.catalogLayer)
@@ -5315,37 +4711,37 @@ class Ca {
5315
4711
  emit(e, ...t) {
5316
4712
  const i = this.listeners.get(e);
5317
4713
  if (i)
5318
- for (const a of i)
5319
- a(...t);
4714
+ for (const s of i)
4715
+ s(...t);
5320
4716
  }
5321
4717
  }
5322
- function va(s, e) {
5323
- const t = new Date(s).toISOString();
4718
+ function oa(a, e) {
4719
+ const t = new Date(a).toISOString();
5324
4720
  return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
5325
4721
  }
5326
- function ya(s, e) {
5327
- return e === "year" ? Date.UTC(Number(s), 0, 1) : e === "month" ? (/* @__PURE__ */ new Date(`${s}-01T00:00:00Z`)).getTime() : e === "day" ? (/* @__PURE__ */ new Date(`${s}T00:00:00Z`)).getTime() : (/* @__PURE__ */ new Date(`${s}Z`)).getTime();
4722
+ function la(a, e) {
4723
+ return e === "year" ? Date.UTC(Number(a), 0, 1) : e === "month" ? (/* @__PURE__ */ new Date(`${a}-01T00:00:00Z`)).getTime() : e === "day" ? (/* @__PURE__ */ new Date(`${a}T00:00:00Z`)).getTime() : (/* @__PURE__ */ new Date(`${a}Z`)).getTime();
5328
4724
  }
5329
- function ka(s, e, t) {
5330
- if (!e || s.length === 0)
4725
+ function ba(a, e, t) {
4726
+ if (!e || a.length === 0)
5331
4727
  return;
5332
4728
  if (["year", "month", "day"].includes(t)) {
5333
- const a = s.find(
5334
- (r) => va(r, t) === e
4729
+ const s = a.find(
4730
+ (r) => oa(r, t) === e
5335
4731
  );
5336
- if (a !== void 0)
5337
- return a;
4732
+ if (s !== void 0)
4733
+ return s;
5338
4734
  }
5339
- const i = ya(e, t);
4735
+ const i = la(e, t);
5340
4736
  if (Number.isFinite(i))
5341
- return s.reduce(
5342
- (a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
4737
+ return a.reduce(
4738
+ (s, r) => Math.abs(r - i) < Math.abs(s - i) ? r : s
5343
4739
  );
5344
4740
  }
5345
- const Vt = vt.devDependencies["maplibre-gl"].replace(
4741
+ const Ft = ft.devDependencies["maplibre-gl"].replace(
5346
4742
  /^[^\d]*/,
5347
4743
  ""
5348
- ), _a = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/+esm`, xa = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/dist/maplibre-gl.css`, ba = `{
4744
+ ), ca = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Ft}/+esm`, ua = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Ft}/dist/maplibre-gl.css`, ha = `{
5349
4745
  version: 8,
5350
4746
  sources: {
5351
4747
  "eox-cloudless": {
@@ -5366,60 +4762,60 @@ const Vt = vt.devDependencies["maplibre-gl"].replace(
5366
4762
  }
5367
4763
  ]
5368
4764
  }`;
5369
- function q(s) {
5370
- return JSON.stringify(s);
4765
+ function $(a) {
4766
+ return JSON.stringify(a);
5371
4767
  }
5372
- function Sa(s) {
5373
- return JSON.stringify(s, null, 2);
4768
+ function da(a) {
4769
+ return JSON.stringify(a, null, 2);
5374
4770
  }
5375
- function Nt(s) {
5376
- return s instanceof Date ? `new Date(${q(s.toISOString())})` : typeof s == "string" ? `new Date(${q(s)})` : String(s);
4771
+ function Vt(a) {
4772
+ return a instanceof Date ? `new Date(${$(a.toISOString())})` : typeof a == "string" ? `new Date(${$(a)})` : String(a);
5377
4773
  }
5378
- function ie(s, e = 6) {
5379
- return String(Number(s.toFixed(e)));
4774
+ function ie(a, e = 6) {
4775
+ return String(Number(a.toFixed(e)));
5380
4776
  }
5381
- function $(s, e) {
4777
+ function B(a, e) {
5382
4778
  const t = " ".repeat(e);
5383
- return Sa(s).split(`
4779
+ return da(a).split(`
5384
4780
  `).map((i) => `${t}${i}`).join(`
5385
4781
  `).trimStart();
5386
4782
  }
5387
- function wa(s, e) {
4783
+ function ma(a, e) {
5388
4784
  const t = " ".repeat(e);
5389
- return s.split(`
4785
+ return a.split(`
5390
4786
  `).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
5391
4787
  `);
5392
4788
  }
5393
- const Ta = (s) => {
5394
- const e = s.source ?? "auto";
5395
- return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
4789
+ const fa = (a) => {
4790
+ const e = a.source ?? "auto";
4791
+ return a.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
5396
4792
  };
5397
- function zt(s) {
5398
- const { layerKind: e, layerDefaults: t } = s, i = gt(s.style ?? {}, e), a = t === void 0 ? i : Wt(i, ze({ kind: e, defaults: t })), r = a.raster?.opacity, n = Ta(s) !== "wmts" ? a : r === void 0 ? {} : { raster: { opacity: r } };
4793
+ function Ut(a) {
4794
+ const { layerKind: e, layerDefaults: t } = a, i = mt(a.style ?? {}, e), s = t === void 0 ? i : Bt(i, ze({ kind: e, defaults: t })), r = s.raster?.opacity, n = fa(a) !== "wmts" ? s : r === void 0 ? {} : { raster: { opacity: r } };
5399
4795
  return Object.keys(n).length ? n : void 0;
5400
4796
  }
5401
- function Gt(s) {
5402
- const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
4797
+ function It(a) {
4798
+ const { particleState: e, rgba8MaxParticleZoom: t } = a.settings ?? {}, i = Object.fromEntries(
5403
4799
  Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
5404
- ([, a]) => a !== void 0
4800
+ ([, s]) => s !== void 0
5405
4801
  )
5406
4802
  );
5407
- return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
4803
+ return a.layerKind === "vector" && Object.keys(i).length ? i : void 0;
5408
4804
  }
5409
- function Fa(s) {
5410
- const e = s.source ?? "auto", t = zt(s), i = Gt(s), a = [
4805
+ function Sa(a) {
4806
+ const e = a.source ?? "auto", t = Ut(a), i = It(a), s = [
5411
4807
  " idView: widget.opt.view.id,",
5412
4808
  " map: widget.opt.map,",
5413
- ` layer: ${q(s.layerId)},`,
5414
- ` source: ${q(e)},`
4809
+ ` layer: ${$(a.layerId)},`,
4810
+ ` source: ${$(e)},`
5415
4811
  ];
5416
4812
  for (const r of ["title", "subtitle", "description"])
5417
- s[r] != null && a.push(` ${r}: ${$(s[r], 10)},`);
5418
- return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${Nt(s.time)},`), s.timeRange != null && a.push(
5419
- ` timeRange: ${$(s.timeRange, 10)},`
5420
- ), s.geoVideo != null && a.push(
5421
- ` geoVideo: ${$(s.geoVideo, 10)},`
5422
- ), s.depth != null && a.push(` depth: ${s.depth},`), a.push(
4813
+ a[r] != null && s.push(` ${r}: ${B(a[r], 10)},`);
4814
+ return a.entry && s.push(` entry: ${B(a.entry, 10)},`), t && s.push(` style: ${B(t, 10)},`), i && s.push(` settings: ${B(i, 10)},`), a.time != null && s.push(` time: ${Vt(a.time)},`), a.timeRange != null && s.push(
4815
+ ` timeRange: ${B(a.timeRange, 10)},`
4816
+ ), a.geoVideo != null && s.push(
4817
+ ` geoVideo: ${B(a.geoVideo, 10)},`
4818
+ ), a.depth != null && s.push(` depth: ${a.depth},`), s.push(
5423
4819
  " elLegend: elLegend,",
5424
4820
  " elInputs: widget.elContent,"
5425
4821
  ), `function handler() {
@@ -5438,7 +4834,7 @@ function Fa(s) {
5438
4834
  const elLegend = getViewLegend(widget.opt.view, { clone: false });
5439
4835
 
5440
4836
  local.arco = new ArcoMapLegend({
5441
- ${a.join(`
4837
+ ${s.join(`
5442
4838
  `)}
5443
4839
  });
5444
4840
 
@@ -5454,19 +4850,19 @@ ${a.join(`
5454
4850
  };
5455
4851
  }`;
5456
4852
  }
5457
- function Ma(s) {
5458
- const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${vt.version}/dist`, t = s.source ?? "auto", i = zt(s), a = Gt(s), r = s.timeRange == null ? "" : ` timeRange: ${$(s.timeRange, 2)},
5459
- `, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
5460
- `, o = i == null ? "" : ` style: ${$(i, 2)},
5461
- `, l = a == null ? "" : ` settings: ${$(a, 2)},
5462
- `, d = s.time == null ? "" : ` time: ${Nt(s.time)},
5463
- `, c = s.depth == null ? "" : ` depth: ${s.depth},
5464
- `, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? ba : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
4853
+ function pa(a) {
4854
+ const e = a.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${ft.version}/dist`, t = a.source ?? "auto", i = Ut(a), s = It(a), r = a.timeRange == null ? "" : ` timeRange: ${B(a.timeRange, 2)},
4855
+ `, n = a.geoVideo == null ? "" : ` geoVideo: ${B(a.geoVideo, 2)},
4856
+ `, o = i == null ? "" : ` style: ${B(i, 2)},
4857
+ `, c = s == null ? "" : ` settings: ${B(s, 2)},
4858
+ `, d = a.time == null ? "" : ` time: ${Vt(a.time)},
4859
+ `, u = a.depth == null ? "" : ` depth: ${a.depth},
4860
+ `, h = a.center ?? [0, 20], v = a.projection ?? "mercator", m = a.mapStyle == null ? ha : $(a.mapStyle), f = `map.setProjection({ type: ${$(v)} });
5465
4861
  map.jumpTo({
5466
- center: [${ie(u[0])}, ${ie(u[1])}],
5467
- zoom: ${ie(s.zoom ?? 2, 3)},
5468
- bearing: ${ie(s.bearing ?? 0, 3)},
5469
- pitch: ${ie(s.pitch ?? 0, 3)},
4862
+ center: [${ie(h[0])}, ${ie(h[1])}],
4863
+ zoom: ${ie(a.zoom ?? 2, 3)},
4864
+ bearing: ${ie(a.bearing ?? 0, 3)},
4865
+ pitch: ${ie(a.pitch ?? 0, 3)},
5470
4866
  });
5471
4867
  map.setSky({
5472
4868
  "sky-color": "#05070f",
@@ -5488,12 +4884,12 @@ const z = new Zartigl({
5488
4884
  id: "zartigl-demo",
5489
4885
  map,
5490
4886
  catalog,
5491
- layer: ${q(s.layerId)},
5492
- source: ${q(t)},
5493
- ${r}${n}${o}${l}${d}${c}});
4887
+ layer: ${$(a.layerId)},
4888
+ source: ${$(t)},
4889
+ ${r}${n}${o}${c}${d}${u}});
5494
4890
 
5495
4891
  await z.init();`;
5496
- return `import maplibregl from ${q(_a)};
4892
+ return `import maplibregl from ${$(ca)};
5497
4893
  import { Zartigl } from "${e}/zartigl.js";
5498
4894
  import { catalog } from "${e}/catalog.js";
5499
4895
 
@@ -5505,18 +4901,18 @@ const map = new maplibregl.Map({
5505
4901
  });
5506
4902
 
5507
4903
  map.once("style.load", async () => {
5508
- ${wa(p, 2)}
4904
+ ${ma(f, 2)}
5509
4905
  });`;
5510
4906
  }
5511
- function Ia(s) {
5512
- const e = Ma(s);
4907
+ function wa(a) {
4908
+ const e = pa(a);
5513
4909
  return `<!doctype html>
5514
4910
  <html lang="en">
5515
4911
  <head>
5516
4912
  <meta charset="UTF-8" />
5517
4913
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5518
4914
  <title>Zartigl demo</title>
5519
- <link rel="stylesheet" href=${q(xa)} />
4915
+ <link rel="stylesheet" href=${$(ua)} />
5520
4916
  <style>
5521
4917
  html, body, #map {
5522
4918
  width: 100%;
@@ -5538,41 +4934,41 @@ ${e}
5538
4934
  </html>`;
5539
4935
  }
5540
4936
  export {
5541
- ui as BACKDROP_OFF,
5542
- di as COLOR_GRADE_OFF,
5543
- Oa as COLOR_GRADE_VIBRANT,
5544
- oa as GEOVIDEO_SPEEDS,
4937
+ li as BACKDROP_OFF,
4938
+ ci as COLOR_GRADE_OFF,
4939
+ La as COLOR_GRADE_VIBRANT,
4940
+ Qi as GEOVIDEO_SPEEDS,
5545
4941
  G as GeoVideoLayer,
5546
- It as LEGACY_STYLE_SETTINGS,
5547
- Pt as ParticleSimulation,
4942
+ Ct as LEGACY_STYLE_SETTINGS,
4943
+ Tt as ParticleSimulation,
5548
4944
  me as ScalarLayer,
5549
- at as VECTOR_GEOVIDEO_SPEEDS,
5550
- P as VectorLayer,
5551
- Et as VelocityField,
5552
- _e as ZarrSource,
5553
- Ca as Zartigl,
4945
+ et as VECTOR_GEOVIDEO_SPEEDS,
4946
+ M as VectorLayer,
4947
+ Rt as VelocityField,
4948
+ ve as ZarrSource,
4949
+ xa as Zartigl,
5554
4950
  xe as ZartiglFrameUnavailableError,
5555
- Fa as buildMapxWidgetSnippet,
5556
- Ia as buildStandaloneDemoHtml,
5557
- Ma as buildStandaloneDemoSnippet,
5558
- ji as buildWmtsLegendUrl,
5559
- et as buildWmtsTileUrl,
5560
- pi as colorGradeToGrade,
5561
- Xi as deriveDirectionMagnitudeComponents,
5562
- Ye as formatUnit,
5563
- ti as geoVideoSecondsForTime,
5564
- Na as geoVideoTimeForSeconds,
4951
+ Sa as buildMapxWidgetSnippet,
4952
+ wa as buildStandaloneDemoHtml,
4953
+ pa as buildStandaloneDemoSnippet,
4954
+ Oi as buildWmtsLegendUrl,
4955
+ Qe as buildWmtsTileUrl,
4956
+ di as colorGradeToGrade,
4957
+ Ui as deriveDirectionMagnitudeComponents,
4958
+ He as formatUnit,
4959
+ Kt as geoVideoSecondsForTime,
4960
+ Ma as geoVideoTimeForSeconds,
5565
4961
  we as geoVideoTimelineValues,
5566
- xt as getPalettes,
5567
- Aa as getVectorDerivationVariables,
5568
- gi as gradeToColorGrade,
5569
- Ba as isHexColor,
5570
- Ce as loadGeoVideoManifest,
5571
- wt as resolveBackdrop,
5572
- St as resolveColorGrade,
5573
- ke as resolveColorRamp,
5574
- ka as resolveTimeInputSelection,
5575
- Ae as splitLegacySettings,
5576
- Lt as stitchVelocityChunks,
5577
- za as validateGeoVideoManifest
4962
+ vt as getPalettes,
4963
+ _a as getVectorDerivationVariables,
4964
+ mi as gradeToColorGrade,
4965
+ Da as isHexColor,
4966
+ Ae as loadGeoVideoManifest,
4967
+ xt as resolveBackdrop,
4968
+ _t as resolveColorGrade,
4969
+ Ce as resolveColorRamp,
4970
+ ba as resolveTimeInputSelection,
4971
+ De as splitLegacySettings,
4972
+ Mt as stitchVelocityChunks,
4973
+ Pa as validateGeoVideoManifest
5578
4974
  };