@fxi/zartigl 0.10.4 → 0.10.5

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.
@@ -1,15 +1,16 @@
1
- const te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, ie = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, re = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ne = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, se = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, ae = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, oe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ce = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, de = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, le = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, he = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, ue = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, fe = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Ee = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, pe = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Te = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, be = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, Re = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, ge = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, we = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, _e = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, K = {
1
+ import "./backdrop-Dceb4d8E.js";
2
+ const te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, ie = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, re = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ne = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, ae = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, se = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, oe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ce = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, le = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, de = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, he = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, ue = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, fe = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Ee = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, pe = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Te = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, ge = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, be = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, Re = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, _e = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, xe = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, z = {
2
3
  thermal: te,
3
4
  "thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
4
5
  haline: ie,
5
6
  solar: re,
6
7
  ice: ne,
7
- deep: se,
8
- rdylbu: ae,
8
+ deep: ae,
9
+ rdylbu: se,
9
10
  dense: oe,
10
11
  algae: ce,
11
- oxygen: de,
12
- matter: le,
12
+ oxygen: le,
13
+ matter: de,
13
14
  viridis: he,
14
15
  plasma: ue,
15
16
  cyclic: fe,
@@ -17,28 +18,28 @@ const te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#0
17
18
  turbid: Ee,
18
19
  speed: pe,
19
20
  amp: Te,
20
- heat: be,
21
+ heat: ge,
21
22
  "heat-alert": { label: "Heat Alert", tags: ["sequential", "alpha", "deprecated"], colors: ["#fde72500", "#fde725cc", "#f8961e", "#e63946", "#9d0208", "#3a0007"] },
22
- balance: Re,
23
- delta: ge,
24
- curl: we,
23
+ balance: be,
24
+ delta: Re,
25
+ curl: _e,
25
26
  "mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
26
27
  "mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
27
28
  "mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
28
- gray: _e
29
- }, B = 64, ye = {
29
+ gray: xe
30
+ }, O = 64, we = {
30
31
  linear: (t) => t,
31
32
  // Rises fast: values just inside the zone already show.
32
33
  log: (t) => Math.log10(1 + 9 * t),
33
34
  // Stays faint longer: codec noise at the end of the range stays hidden.
34
35
  exp: (t) => (10 ** t - 1) / 9
35
36
  };
36
- function xe(t, e) {
37
- const i = ye[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
38
- let s = 1;
39
- return r > 0 && t < r && (s = Math.min(s, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (s = Math.min(s, i(Math.max(1 - t, 0) / n))), s;
37
+ function ye(t, e) {
38
+ const i = we[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
39
+ let a = 1;
40
+ return r > 0 && t < r && (a = Math.min(a, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (a = Math.min(a, i(Math.max(1 - t, 0) / n))), a;
40
41
  }
41
- function Ae(t) {
42
+ function ve(t) {
42
43
  let e = t.replace("#", "");
43
44
  (e.length === 3 || e.length === 4) && (e = [...e].map((r) => r + r).join(""));
44
45
  const i = (r) => parseInt(e.slice(r, r + 2), 16);
@@ -49,46 +50,46 @@ function Ae(t) {
49
50
  e.length === 8 ? i(6) : 255
50
51
  ];
51
52
  }
52
- function ke([t, e, i, r]) {
53
+ function Ae([t, e, i, r]) {
53
54
  return `#${[t, e, i, r].map(
54
55
  (n) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, "0")
55
56
  ).join("")}`;
56
57
  }
57
- function Fe(t, e) {
58
+ function ke(t, e) {
58
59
  if (e <= t[0][0])
59
60
  return t[0][1];
60
61
  for (let i = 1; i < t.length; i++) {
61
62
  const [r, n] = t[i];
62
63
  if (e <= r) {
63
- const [s, o] = t[i - 1], a = r === s ? 1 : (e - s) / (r - s);
64
- return o.map((d, c) => d + (n[c] - d) * a);
64
+ const [a, o] = t[i - 1], s = r === a ? 1 : (e - a) / (r - a);
65
+ return o.map((l, c) => l + (n[c] - l) * s);
65
66
  }
66
67
  }
67
68
  return t[t.length - 1][1];
68
69
  }
69
- function ve(t, e) {
70
+ function Fe(t, e) {
70
71
  const i = Object.entries(t).map(
71
- ([n, s]) => [Number(n), Ae(s)]
72
- ).sort((n, s) => n[0] - s[0]), r = {};
73
- for (let n = 0; n <= B; n++) {
74
- const s = n / B, [o, a, d, c] = Fe(i, s);
75
- r[s] = ke([o, a, d, c * xe(s, e)]);
72
+ ([n, a]) => [Number(n), ve(a)]
73
+ ).sort((n, a) => n[0] - a[0]), r = {};
74
+ for (let n = 0; n <= O; n++) {
75
+ const a = n / O, [o, s, l, c] = ke(i, a);
76
+ r[a] = Ae([o, s, l, c * ye(a, e)]);
76
77
  }
77
78
  return r;
78
79
  }
79
80
  const Se = (t) => !!t && ((t.low ?? 0) > 0 || (t.high ?? 0) > 0);
80
- function X(t) {
81
+ function B(t) {
81
82
  const e = {}, i = t.length - 1;
82
83
  return t.forEach((r, n) => {
83
84
  e[i === 0 ? 0 : n / i] = r;
84
85
  }), e;
85
86
  }
86
- function Ue(t, e) {
87
- const i = Pe(t, e?.reverse ?? !1);
88
- return Se(e?.alphaFade) ? ve(i, e.alphaFade) : i;
87
+ function De(t, e) {
88
+ const i = Ue(t, e?.reverse ?? !1);
89
+ return Se(e?.alphaFade) ? Fe(i, e.alphaFade) : i;
89
90
  }
90
- function Pe(t, e) {
91
- const i = K;
91
+ function Ue(t, e) {
92
+ const i = z;
92
93
  if (typeof t == "string") {
93
94
  const r = i[t];
94
95
  if (!r)
@@ -98,22 +99,22 @@ function Pe(t, e) {
98
99
  ).join(", ")}`
99
100
  );
100
101
  const n = e ? [...r.colors].reverse() : r.colors;
101
- return X(n);
102
+ return B(n);
102
103
  }
103
104
  if (Array.isArray(t)) {
104
105
  const r = e ? [...t].reverse() : t;
105
- return X(r);
106
+ return B(r);
106
107
  }
107
108
  return e ? Object.fromEntries(
108
109
  Object.entries(t).map(([r, n]) => [1 - Number(r), n])
109
110
  ) : t;
110
111
  }
111
- function wt(t = {}) {
112
- return Object.entries(K).map(([i, r]) => ({ id: i, ...r })).filter(
112
+ function Ft(t = {}) {
113
+ return Object.entries(z).map(([i, r]) => ({ id: i, ...r })).filter(
113
114
  (i) => t.includeDeprecated || !i.tags.includes("deprecated")
114
115
  );
115
116
  }
116
- function O(t, e, i) {
117
+ function X(t, e, i) {
117
118
  const r = t.createShader(e);
118
119
  if (!r)
119
120
  throw new Error("Failed to create shader");
@@ -123,22 +124,22 @@ function O(t, e, i) {
123
124
  }
124
125
  return r;
125
126
  }
126
- function _t(t, e, i) {
127
+ function St(t, e, i) {
127
128
  const r = t.createProgram();
128
129
  if (!r)
129
130
  throw new Error("Failed to create program");
130
- const n = O(t, t.VERTEX_SHADER, e), s = O(t, t.FRAGMENT_SHADER, i);
131
- if (t.attachShader(r, n), t.attachShader(r, s), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
131
+ const n = X(t, t.VERTEX_SHADER, e), a = X(t, t.FRAGMENT_SHADER, i);
132
+ if (t.attachShader(r, n), t.attachShader(r, a), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
132
133
  const o = t.getProgramInfoLog(r);
133
134
  throw t.deleteProgram(r), new Error(`Program link error: ${o}`);
134
135
  }
135
- return t.deleteShader(n), t.deleteShader(s), r;
136
+ return t.deleteShader(n), t.deleteShader(a), r;
136
137
  }
137
- function yt(t, e, i, r, n) {
138
- const s = t.createTexture();
139
- if (!s)
138
+ function Dt(t, e, i, r, n) {
139
+ const a = t.createTexture();
140
+ if (!a)
140
141
  throw new Error("Failed to create texture");
141
- return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
142
+ return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
142
143
  t.TEXTURE_2D,
143
144
  0,
144
145
  t.RGBA,
@@ -148,19 +149,19 @@ function yt(t, e, i, r, n) {
148
149
  t.RGBA,
149
150
  t.UNSIGNED_BYTE,
150
151
  i
151
- ), t.bindTexture(t.TEXTURE_2D, null), s;
152
+ ), t.bindTexture(t.TEXTURE_2D, null), a;
152
153
  }
153
- function De(t, e, i) {
154
+ function Pe(t, e, i) {
154
155
  const r = t.getParameter(
155
156
  t.TEXTURE_BINDING_2D
156
157
  ), n = t.getParameter(
157
158
  t.FRAMEBUFFER_BINDING
158
- ), s = t.createTexture(), o = t.createFramebuffer();
159
- if (!s || !o)
160
- return s && t.deleteTexture(s), o && t.deleteFramebuffer(o), t.bindTexture(t.TEXTURE_2D, r), t.bindFramebuffer(t.FRAMEBUFFER, n), !1;
161
- let a = !1;
159
+ ), a = t.createTexture(), o = t.createFramebuffer();
160
+ if (!a || !o)
161
+ return a && t.deleteTexture(a), o && t.deleteFramebuffer(o), t.bindTexture(t.TEXTURE_2D, r), t.bindFramebuffer(t.FRAMEBUFFER, n), !1;
162
+ let s = !1;
162
163
  try {
163
- t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
164
+ t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
164
165
  t.TEXTURE_2D,
165
166
  0,
166
167
  e,
@@ -174,13 +175,13 @@ function De(t, e, i) {
174
175
  t.FRAMEBUFFER,
175
176
  t.COLOR_ATTACHMENT0,
176
177
  t.TEXTURE_2D,
177
- s,
178
+ a,
178
179
  0
179
- ), a = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
180
+ ), s = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
180
181
  } finally {
181
- t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(s);
182
+ t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(a);
182
183
  }
183
- return a;
184
+ return s;
184
185
  }
185
186
  function Me(t) {
186
187
  return {
@@ -189,12 +190,12 @@ function Me(t) {
189
190
  type: t.UNSIGNED_BYTE
190
191
  };
191
192
  }
192
- function xt(t) {
193
+ function Ut(t) {
193
194
  if (typeof WebGL2RenderingContext > "u" || !(t instanceof WebGL2RenderingContext))
194
195
  throw new Error("zartigl requires WebGL2");
195
196
  return t;
196
197
  }
197
- function At(t) {
198
+ function Pt(t) {
198
199
  const e = [];
199
200
  t.getExtension("EXT_color_buffer_float") ? e.push(
200
201
  { kind: "float32", internalFormat: t.RGBA32F, type: t.FLOAT },
@@ -205,7 +206,7 @@ function At(t) {
205
206
  type: t.HALF_FLOAT
206
207
  });
207
208
  for (const i of e)
208
- if (De(
209
+ if (Pe(
209
210
  t,
210
211
  i.internalFormat,
211
212
  i.type
@@ -213,26 +214,26 @@ function At(t) {
213
214
  return i;
214
215
  return Me(t);
215
216
  }
216
- function kt(t, e, i, r, n, s, o) {
217
- const a = t.createTexture();
218
- if (!a)
217
+ function Mt(t, e, i, r, n, a, o) {
218
+ const s = t.createTexture();
219
+ if (!s)
219
220
  throw new Error("Failed to create texture");
220
- return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
221
+ return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
221
222
  t.TEXTURE_2D,
222
223
  0,
223
- s,
224
+ a,
224
225
  r,
225
226
  n,
226
227
  0,
227
228
  t.RGBA,
228
229
  o,
229
230
  i
230
- ), t.bindTexture(t.TEXTURE_2D, null), a;
231
+ ), t.bindTexture(t.TEXTURE_2D, null), s;
231
232
  }
232
- function Ft(t, e, i) {
233
+ function Gt(t, e, i) {
233
234
  t.activeTexture(t.TEXTURE0 + i), t.bindTexture(t.TEXTURE_2D, e);
234
235
  }
235
- function vt(t, e) {
236
+ function Nt(t, e) {
236
237
  const i = t.createFramebuffer();
237
238
  if (!i)
238
239
  throw new Error("Failed to create framebuffer");
@@ -244,7 +245,7 @@ function vt(t, e) {
244
245
  0
245
246
  ), t.bindFramebuffer(t.FRAMEBUFFER, null), i;
246
247
  }
247
- function St(t) {
248
+ function It(t) {
248
249
  const e = t.createBuffer();
249
250
  if (!e)
250
251
  throw new Error("Failed to create buffer");
@@ -254,7 +255,7 @@ function St(t) {
254
255
  t.STATIC_DRAW
255
256
  ), e;
256
257
  }
257
- const Ne = {
258
+ const Ge = {
258
259
  0: "#3288bd",
259
260
  0.1: "#66c2a5",
260
261
  0.2: "#abdda4",
@@ -264,19 +265,19 @@ const Ne = {
264
265
  0.6: "#f46d43",
265
266
  1: "#d53e4f"
266
267
  };
267
- function Ut(t, e, i) {
268
- const r = Ue(e ?? Ne, i), n = document.createElement("canvas");
268
+ function Lt(t, e, i) {
269
+ const r = De(e ?? Ge, i), n = document.createElement("canvas");
269
270
  n.width = 256, n.height = 1;
270
- const s = n.getContext("2d"), o = s.createLinearGradient(0, 0, 256, 0);
271
- for (const [d, c] of Object.entries(r))
272
- o.addColorStop(Number(d), c);
273
- s.fillStyle = o, s.fillRect(0, 0, 256, 1);
274
- const a = t.createTexture();
275
- if (!a)
271
+ const a = n.getContext("2d"), o = a.createLinearGradient(0, 0, 256, 0);
272
+ for (const [l, c] of Object.entries(r))
273
+ o.addColorStop(Number(l), c);
274
+ a.fillStyle = o, a.fillRect(0, 0, 256, 1);
275
+ const s = t.createTexture();
276
+ if (!s)
276
277
  throw new Error("Failed to create color ramp texture");
277
- return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), a;
278
+ return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), s;
278
279
  }
279
- function Pt(t) {
280
+ function Ct(t) {
280
281
  const e = t.getExtension("WEBGL_debug_renderer_info");
281
282
  return {
282
283
  vendor: String(t.getParameter(t.VENDOR) ?? ""),
@@ -286,7 +287,7 @@ function Pt(t) {
286
287
  version: String(t.getParameter(t.VERSION) ?? "")
287
288
  };
288
289
  }
289
- function Dt(t) {
290
+ function Vt(t) {
290
291
  return {
291
292
  program: t.getParameter(t.CURRENT_PROGRAM),
292
293
  activeTexture: t.getParameter(t.ACTIVE_TEXTURE),
@@ -303,10 +304,10 @@ function Dt(t) {
303
304
  ]
304
305
  };
305
306
  }
306
- function Mt(t, e) {
307
+ function Ot(t, e) {
307
308
  t.useProgram(e.program), t.activeTexture(e.activeTexture), t.bindBuffer(t.ARRAY_BUFFER, e.arrayBuffer), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.elementBuffer), t.bindFramebuffer(t.FRAMEBUFFER, e.framebuffer), e.blend ? t.enable(t.BLEND) : t.disable(t.BLEND), e.depthTest ? t.enable(t.DEPTH_TEST) : t.disable(t.DEPTH_TEST), e.stencilTest ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), t.viewport(e.viewport[0], e.viewport[1], e.viewport[2], e.viewport[3]), t.blendFunc(e.blendFunc[0], e.blendFunc[1]);
308
309
  }
309
- const Ie = {
310
+ const Ne = {
310
311
  degrees_c: "°C",
311
312
  degc: "°C",
312
313
  degrees_celsius: "°C",
@@ -322,7 +323,7 @@ const Ie = {
322
323
  "0.001": "PSU",
323
324
  psu: "PSU",
324
325
  stress_level: ""
325
- }, Ge = {
326
+ }, Ie = {
326
327
  meter: "m",
327
328
  meters: "m",
328
329
  metre: "m",
@@ -349,32 +350,32 @@ const Ie = {
349
350
  function q(t) {
350
351
  return t === 1 ? "" : [...String(t)].map((e) => Le[Number(e)]).join("");
351
352
  }
352
- function Nt(t) {
353
- const e = t?.trim() ?? "", i = Ie[e.toLowerCase()];
353
+ function Bt(t) {
354
+ const e = t?.trim() ?? "", i = Ne[e.toLowerCase()];
354
355
  if (i != null)
355
356
  return i;
356
357
  if (e.includes("/"))
357
358
  return e;
358
359
  const r = [], n = [];
359
- for (const s of e.split(/\s+/)) {
360
- const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(s);
360
+ for (const a of e.split(/\s+/)) {
361
+ const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(a);
361
362
  if (!o)
362
363
  return e.replace(/_/g, " ");
363
- const a = Ge[o[1]] ?? o[1], d = Number(o[2] ?? 1);
364
- d < 0 ? n.push(a + q(-d)) : r.push(a + q(d));
364
+ const s = Ie[o[1]] ?? o[1], l = Number(o[2] ?? 1);
365
+ l < 0 ? n.push(s + q(-l)) : r.push(s + q(l));
365
366
  }
366
367
  return [r.join(" ") || "1", ...n].join("/");
367
368
  }
368
- const $ = 20, Ce = 600;
369
+ const W = 20, Ce = 600;
369
370
  function Ve(t) {
370
371
  const e = Math.max(0, Math.min(1, t));
371
- return $ * Math.pow(Ce / $, e);
372
+ return W * Math.pow(Ce / W, e);
372
373
  }
373
- function It(t) {
374
+ function Xt(t) {
374
375
  return Math.exp(-1 / Ve(t));
375
376
  }
376
- const Be = 0.8, Xe = 120, Oe = 300;
377
- class Gt {
377
+ const Oe = 0.8, Be = 120, Xe = 300;
378
+ class qt {
378
379
  constructor(e) {
379
380
  this.base = e, this.moving = !1, this.start = 0, this.duration = 0, this.from = e, this.to = e;
380
381
  }
@@ -383,7 +384,7 @@ class Gt {
383
384
  this.base = e, this.moving || (this.from = e, this.to = e, this.duration = 0);
384
385
  }
385
386
  setMoving(e, i) {
386
- e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? Be : this.base, this.start = i, this.duration = e ? Xe : Oe);
387
+ e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? Oe : this.base, this.start = i, this.duration = e ? Be : Xe);
387
388
  }
388
389
  value(e) {
389
390
  if (this.duration === 0)
@@ -392,7 +393,91 @@ class Gt {
392
393
  return i === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * i * i * (3 - 2 * i);
393
394
  }
394
395
  }
395
- function Lt(t) {
396
+ var qe = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physical) {
397
+ if (physical > 0.5) return texel.xyz;
398
+ return vec3(mix(minimum, maximum, texel.rg), texel.a);
399
+ }
400
+
401
+ vec3 blendVelocity(vec3 a, vec3 b, float fraction) {
402
+ if (fraction <= 0.0) return a;
403
+ return mix(a, b, fraction);
404
+ }`, We = `vec3 applyVibrance(vec3 c, float v) {
405
+ float mx = max(c.r, max(c.g, c.b));
406
+ float mn = min(c.r, min(c.g, c.b));
407
+ float boost = v * (1.0 - (mx - mn));
408
+ float luma = dot(c, vec3(0.299, 0.587, 0.114));
409
+ return mix(vec3(luma), c, 1.0 + boost);
410
+ }
411
+
412
+ vec3 gradeColor(vec3 c, vec4 g) {
413
+ float m = max(c.r, max(c.g, c.b));
414
+ if (m > 0.0) {
415
+
416
+
417
+ float e = g.x > 1e-3 ? (1.0 - exp(-g.x * m)) / (1.0 - exp(-g.x)) : m;
418
+
419
+ e += g.w * smoothstep(0.5, 1.0, e) * (1.0 - e);
420
+ c *= e / m;
421
+ }
422
+
423
+ c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
424
+ return clamp(applyVibrance(c, g.z), 0.0, 1.0);
425
+ }`, $e = `uniform vec2 u_code_range;
426
+ uniform vec2 u_value_range;
427
+ uniform float u_scalar_transfer;
428
+
429
+ float geoVideoScalarCode(float r) {
430
+ return clamp((r - u_code_range.x) / (u_code_range.y - u_code_range.x), 0.0, 1.0);
431
+ }
432
+
433
+ float geoVideoScalarValue(float r) {
434
+ float code = geoVideoScalarCode(r);
435
+ float t = mix(code, (pow(10.0, code) - 1.0) / 9.0, u_scalar_transfer);
436
+ return mix(u_value_range.x, u_value_range.y, t);
437
+ }`, He = `uint pcg(uint v) {
438
+ uint state = v * 747796405u + 2891336453u;
439
+ uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
440
+ return (word >> 22u) ^ word;
441
+ }
442
+
443
+ float random(uvec3 v) {
444
+ return float(pcg(v.x ^ pcg(v.y ^ pcg(v.z))) >> 8u) * (1.0 / 16777216.0);
445
+ }`, Ye = `vec3 applyVibrance(vec3 c, float v) {
446
+ float mx = max(c.r, max(c.g, c.b));
447
+ float mn = min(c.r, min(c.g, c.b));
448
+ float boost = v * (1.0 - (mx - mn));
449
+ float luma = dot(c, vec3(0.299, 0.587, 0.114));
450
+ return mix(vec3(luma), c, 1.0 + boost);
451
+ }`, je = `#define GLOW_SCALE 4
452
+
453
+ vec4 glowGather(sampler2D trails, ivec2 texel) {
454
+ ivec2 last = textureSize(trails, 0) - 1;
455
+ ivec2 origin = texel * GLOW_SCALE;
456
+ vec4 sum = vec4(0.0);
457
+ for (int y = 0; y < GLOW_SCALE; y++) {
458
+ for (int x = 0; x < GLOW_SCALE; x++) {
459
+ vec4 c = texelFetch(trails, min(origin + ivec2(x, y), last), 0);
460
+ sum += vec4(c.rgb * c.a, c.a);
461
+ }
462
+ }
463
+ return sum / float(GLOW_SCALE * GLOW_SCALE);
464
+ }
465
+
466
+ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
467
+ vec2 d = 1.0 / vec2(textureSize(glowTex, 0));
468
+ vec4 glow = 0.25 * (
469
+ texture(glowTex, uv + vec2(-d.x, -d.y)) +
470
+ texture(glowTex, uv + vec2(d.x, -d.y)) +
471
+ texture(glowTex, uv + vec2(-d.x, d.y)) +
472
+ texture(glowTex, uv + vec2(d.x, d.y)));
473
+ glow = min(glow * gain, vec4(1.0));
474
+ float under = 1.0 - trail.a;
475
+ float alpha = trail.a + glow.a * under;
476
+ vec3 rgb = (trail.rgb * trail.a + glow.rgb * under) / max(alpha, 1e-4);
477
+ return vec4(rgb, alpha);
478
+ }`;
479
+ const Wt = Ye, $t = We, Ht = He, Yt = $e, jt = qe, zt = je, Kt = 4, Zt = 1.2;
480
+ function Jt(t) {
396
481
  if (t == null)
397
482
  return null;
398
483
  if (!Number.isFinite(t[0]) || !Number.isFinite(t[1]) || t[0] >= t[1])
@@ -406,7 +491,7 @@ function p(t, e) {
406
491
  throw new Error(`Invalid GeoVideo manifest ${e}`);
407
492
  return t;
408
493
  }
409
- function A(t, e) {
494
+ function v(t, e) {
410
495
  if (typeof t != "string")
411
496
  throw new Error(`Invalid GeoVideo manifest ${e}`);
412
497
  const i = new Date(t).getTime();
@@ -414,12 +499,12 @@ function A(t, e) {
414
499
  throw new Error(`Invalid GeoVideo manifest ${e}`);
415
500
  return i;
416
501
  }
417
- function D(t) {
502
+ function P(t) {
418
503
  return typeof t == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
419
504
  t
420
505
  );
421
506
  }
422
- function W(t) {
507
+ function $(t) {
423
508
  if (!t || typeof t != "object")
424
509
  throw new Error("Invalid GeoVideo manifest");
425
510
  const e = t;
@@ -431,10 +516,10 @@ function W(t) {
431
516
  );
432
517
  if (!Array.isArray(e.bounds) || e.bounds.length !== 4)
433
518
  throw new Error("Invalid GeoVideo manifest bounds");
434
- const [i, r, n, s] = e.bounds.map(
519
+ const [i, r, n, a] = e.bounds.map(
435
520
  (u, m) => p(u, `bounds[${m}]`)
436
521
  );
437
- if (r < -90 || s > 90 || r >= s || i === n)
522
+ if (r < -90 || a > 90 || r >= a || i === n)
438
523
  throw new Error("Invalid GeoVideo geographic bounds");
439
524
  const o = e.media;
440
525
  if (!o || typeof o.url != "string" || !o.url)
@@ -442,38 +527,38 @@ function W(t) {
442
527
  for (const u of ["width", "height", "fps", "durationSeconds"])
443
528
  if (p(o[u], `media.${u}`) <= 0)
444
529
  throw new Error(`Invalid GeoVideo media.${u}`);
445
- const a = e.encoding;
446
- if (!a || a.bits !== 8 || a.colorSpace !== "bt709" || a.colorRange !== "limited" && a.colorRange !== "full")
530
+ const s = e.encoding;
531
+ if (!s || s.bits !== 8 || s.colorSpace !== "bt709" || s.colorRange !== "limited" && s.colorRange !== "full")
447
532
  throw new Error("Invalid GeoVideo encoding");
448
- const d = p(a.codeMin, "encoding.codeMin"), c = p(a.codeMax, "encoding.codeMax");
449
- if (d < 0 || c > 255 || d >= c)
533
+ const l = p(s.codeMin, "encoding.codeMin"), c = p(s.codeMax, "encoding.codeMax");
534
+ if (l < 0 || c > 255 || l >= c)
450
535
  throw new Error("Invalid GeoVideo code range");
451
- let l = o.height;
452
- if (a.kind === "scalar-luma") {
453
- if (a.transfer !== "linear" && a.transfer !== "log10-1p9" || p(a.valueMin, "encoding.valueMin") >= p(a.valueMax, "encoding.valueMax"))
536
+ let d = o.height;
537
+ if (s.kind === "scalar-luma") {
538
+ if (s.transfer !== "linear" && s.transfer !== "log10-1p9" || p(s.valueMin, "encoding.valueMin") >= p(s.valueMax, "encoding.valueMax"))
454
539
  throw new Error("Invalid GeoVideo scalar-luma encoding");
455
- } else if (a.kind === "vector-luma") {
456
- if (a.transfer !== "linear" && a.transfer !== "sqrt" || a.layout !== "stacked-uv" || p(a.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
540
+ } else if (s.kind === "vector-luma") {
541
+ if (s.transfer !== "linear" && s.transfer !== "sqrt" || s.layout !== "stacked-uv" || p(s.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
457
542
  throw new Error("Invalid GeoVideo vector-luma encoding");
458
- l = o.height / 2;
543
+ d = o.height / 2;
459
544
  } else
460
545
  throw new Error("Unsupported GeoVideo encoding");
461
546
  const h = e.mask;
462
- if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || p(h.width, "mask.width") !== o.width || p(h.height, "mask.height") !== l || p(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
547
+ if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || p(h.width, "mask.width") !== o.width || p(h.height, "mask.height") !== d || p(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
463
548
  throw new Error("Invalid GeoVideo static mask");
464
549
  if (e.timeline?.kind === "range") {
465
- const u = A(e.timeline.dateStart, "timeline.dateStart");
466
- if (A(e.timeline.dateEnd, "timeline.dateEnd") <= u)
550
+ const u = v(e.timeline.dateStart, "timeline.dateStart");
551
+ if (v(e.timeline.dateEnd, "timeline.dateEnd") <= u)
467
552
  throw new Error("GeoVideo timeline end must follow start");
468
553
  if (e.timeline.interpolation !== "linear" && e.timeline.interpolation !== "nearest")
469
554
  throw new Error("Invalid GeoVideo interpolation");
470
555
  } else if (e.timeline?.kind === "snapshot-loop")
471
- A(e.timeline.date, "timeline.date");
556
+ v(e.timeline.date, "timeline.date");
472
557
  else if (e.timeline?.kind === "sample-sequence") {
473
558
  if (!Array.isArray(e.timeline.values) || e.timeline.values.length === 0)
474
559
  throw new Error("GeoVideo sample sequence must contain values");
475
560
  const u = e.timeline.values.map(
476
- (m, T) => A(m, `timeline.values[${T}]`)
561
+ (m, T) => v(m, `timeline.values[${T}]`)
477
562
  );
478
563
  if (u.some((m, T) => T > 0 && m <= u[T - 1]))
479
564
  throw new Error(
@@ -484,26 +569,26 @@ function W(t) {
484
569
  const f = e.style?.colorDomain;
485
570
  if (!Array.isArray(f) || f.length !== 2 || !f.every(Number.isFinite) || f[0] >= f[1])
486
571
  throw new Error("Invalid GeoVideo color domain");
487
- if (!D(e.id) || !e.provenance || !D(e.provenance.catalogEntryId) || !D(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
572
+ if (!P(e.id) || !e.provenance || !P(e.provenance.catalogEntryId) || !P(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
488
573
  throw new Error("Invalid GeoVideo provenance");
489
- return { ...e, bounds: [i, r, n, s] };
574
+ return { ...e, bounds: [i, r, n, a] };
490
575
  }
491
- async function qe(t, e) {
576
+ async function ze(t, e) {
492
577
  if (typeof t != "string")
493
- return W(t);
578
+ return $(t);
494
579
  const i = await fetch(t, { signal: e });
495
580
  if (!i.ok)
496
581
  throw new Error(
497
582
  `GeoVideo manifest request failed (${i.status}): ${t}`
498
583
  );
499
- const r = await i.json(), n = W(r), s = typeof document < "u" ? new URL(t, document.baseURI).href : t;
584
+ const r = await i.json(), n = $(r), a = typeof document < "u" ? new URL(t, document.baseURI).href : t;
500
585
  return {
501
586
  ...n,
502
- media: { ...n.media, url: new URL(n.media.url, s).href },
503
- mask: { ...n.mask, url: new URL(n.mask.url, s).href }
587
+ media: { ...n.media, url: new URL(n.media.url, a).href },
588
+ mask: { ...n.mask, url: new URL(n.mask.url, a).href }
504
589
  };
505
590
  }
506
- function w(t) {
591
+ function _(t) {
507
592
  if (t.timeline.kind === "snapshot-loop")
508
593
  return [new Date(t.timeline.date).getTime()];
509
594
  if (t.timeline.kind === "sample-sequence")
@@ -514,43 +599,43 @@ function w(t) {
514
599
  );
515
600
  return Array.from(
516
601
  { length: r },
517
- (n, s) => e + (i - e) * s / (r - 1)
602
+ (n, a) => e + (i - e) * a / (r - 1)
518
603
  );
519
604
  }
520
- function z(t) {
605
+ function K(t) {
521
606
  return t.timeline.kind === "sample-sequence" ? t.timeline.values.length / t.media.durationSeconds : t.media.fps;
522
607
  }
523
- function Ct(t, e) {
524
- return e / z(t);
608
+ function Qt(t, e) {
609
+ return e / K(t);
525
610
  }
526
- function $e(t, e) {
611
+ function Ke(t, e) {
527
612
  if (t.timeline.kind === "snapshot-loop")
528
613
  return 0;
529
614
  if (t.timeline.kind === "sample-sequence") {
530
- const s = w(t);
615
+ const a = _(t);
531
616
  let o = 0;
532
- for (let d = 1; d < s.length; d += 1)
533
- Math.abs(s[d] - e) < Math.abs(s[o] - e) && (o = d);
534
- const a = t.media.durationSeconds / s.length;
535
- return o * a + Math.min(a / 2, 0.5 / t.media.fps);
617
+ for (let l = 1; l < a.length; l += 1)
618
+ Math.abs(a[l] - e) < Math.abs(a[o] - e) && (o = l);
619
+ const s = t.media.durationSeconds / a.length;
620
+ return o * s + Math.min(s / 2, 0.5 / t.media.fps);
536
621
  }
537
622
  const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime();
538
623
  return Math.max(0, Math.min(1, (e - i) / (r - i))) * Z(t);
539
624
  }
540
- function Vt(t, e) {
625
+ function ei(t, e) {
541
626
  if (t.timeline.kind === "snapshot-loop")
542
627
  return new Date(t.timeline.date).getTime();
543
628
  if (t.timeline.kind === "sample-sequence") {
544
- const o = w(t), a = t.media.durationSeconds / o.length, d = Math.floor((e + 0.25 / t.media.fps) / a);
545
- return o[Math.max(0, Math.min(o.length - 1, d))];
629
+ const o = _(t), s = t.media.durationSeconds / o.length, l = Math.floor((e + 0.25 / t.media.fps) / s);
630
+ return o[Math.max(0, Math.min(o.length - 1, l))];
546
631
  }
547
- const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = Z(t), s = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
548
- return i + (r - i) * s;
632
+ const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = Z(t), a = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
633
+ return i + (r - i) * a;
549
634
  }
550
635
  function Z(t) {
551
636
  return Math.max(0, t.media.durationSeconds - 1 / t.media.fps);
552
637
  }
553
- function We(t, e) {
638
+ function Ze(t, e) {
554
639
  const i = new Uint8Array(t.length / 4);
555
640
  for (let r = 0; r < i.length; r++) {
556
641
  const n = t[r * 4];
@@ -558,7 +643,7 @@ function We(t, e) {
558
643
  }
559
644
  return i;
560
645
  }
561
- class He {
646
+ class Je {
562
647
  constructor() {
563
648
  this.gl = null, this.texture = null, this.framebuffer = null;
564
649
  }
@@ -571,8 +656,8 @@ class He {
571
656
  this.texture,
572
657
  0
573
658
  );
574
- const s = new Uint8Array(i * r * 4);
575
- return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE, s), n.bindFramebuffer(n.FRAMEBUFFER, null), s;
659
+ const a = new Uint8Array(i * r * 4);
660
+ return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE, a), n.bindFramebuffer(n.FRAMEBUFFER, null), a;
576
661
  }
577
662
  release() {
578
663
  this.gl?.getExtension("WEBGL_lose_context")?.loseContext(), this.gl = null, this.texture = null, this.framebuffer = null;
@@ -599,14 +684,14 @@ function H(t) {
599
684
  function E() {
600
685
  return new DOMException("GeoVideo frame request was cancelled", "AbortError");
601
686
  }
602
- function _(t, e, i) {
687
+ function x(t, e, i) {
603
688
  return e ? e.aborted ? (t.catch(() => {
604
689
  }), i?.(), Promise.reject(E())) : new Promise((r, n) => {
605
- const s = () => {
690
+ const a = () => {
606
691
  i?.(), n(E());
607
692
  };
608
- e.addEventListener("abort", s, { once: !0 }), t.then(r, n).finally(() => {
609
- e.removeEventListener("abort", s);
693
+ e.addEventListener("abort", a, { once: !0 }), t.then(r, n).finally(() => {
694
+ e.removeEventListener("abort", a);
610
695
  });
611
696
  }) : t;
612
697
  }
@@ -615,18 +700,18 @@ function M(t, e) {
615
700
  (i) => t.addEventListener(e, () => i(), { once: !0 })
616
701
  );
617
702
  }
618
- const Ye = 250;
619
- function je(t) {
703
+ const Qe = 250;
704
+ function et(t) {
620
705
  return "requestVideoFrameCallback" in t ? Promise.race([
621
706
  new Promise(
622
707
  (e) => t.requestVideoFrameCallback(() => e())
623
708
  ),
624
- new Promise((e) => setTimeout(e, Ye))
709
+ new Promise((e) => setTimeout(e, Qe))
625
710
  ]) : Promise.resolve();
626
711
  }
627
712
  class J {
628
713
  constructor(e, i, r = {}) {
629
- this.reader = new He(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(w(e));
714
+ this.reader = new Je(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(_(e));
630
715
  }
631
716
  /** Static validity, one 8-bit value per grid cell; null before init(). */
632
717
  get mask() {
@@ -635,7 +720,7 @@ class J {
635
720
  /** Luma codes of the presented frame, or null when it is blank. */
636
721
  readCodes(e, i) {
637
722
  const r = this.reader.read(e, this.width, i);
638
- return H(r) ? null : We(r, this.manifest.encoding.colorRange);
723
+ return H(r) ? null : Ze(r, this.manifest.encoding.colorRange);
639
724
  }
640
725
  /** True when the decoder exposed no pixels; reads back one row only. */
641
726
  isBlank(e) {
@@ -667,8 +752,8 @@ class J {
667
752
  let n = this.frames.get(e);
668
753
  if (n ? (this.frames.delete(e), this.frames.set(e, n)) : n = this.enqueue(e), n.settled)
669
754
  return n.promise;
670
- const s = n;
671
- return s.waiters++, _(s.promise, r, () => this.leave(s));
755
+ const a = n;
756
+ return a.waiters++, x(a.promise, r, () => this.leave(a));
672
757
  }
673
758
  enqueue(e) {
674
759
  const i = new AbortController(), r = this.queue.then(
@@ -679,7 +764,7 @@ class J {
679
764
  const n = {
680
765
  index: e,
681
766
  controller: i,
682
- promise: _(r, i.signal),
767
+ promise: x(r, i.signal),
683
768
  waiters: 0,
684
769
  settled: !1
685
770
  };
@@ -717,9 +802,9 @@ class J {
717
802
  throw new Error(
718
803
  `GeoVideo mask dimensions ${n.naturalWidth}x${n.naturalHeight} do not match manifest ${i}x${r}`
719
804
  );
720
- const s = this.reader.read(n, i, r), o = new Uint8Array(i * r);
721
- for (let a = 0; a < o.length; a++)
722
- o[a] = s[a * 4];
805
+ const a = this.reader.read(n, i, r), o = new Uint8Array(i * r);
806
+ for (let s = 0; s < o.length; s++)
807
+ o[s] = a[s * 4];
723
808
  return o;
724
809
  }
725
810
  async loadVideo() {
@@ -745,7 +830,7 @@ class J {
745
830
  async presentFrame(e, i) {
746
831
  if (this.presented && Math.abs(e.currentTime - i) <= 1e-3 && !e.seeking)
747
832
  return;
748
- const r = je(e), n = M(e, "seeked");
833
+ const r = et(e), n = M(e, "seeked");
749
834
  e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([M(e, "loadeddata"), M(e, "canplay")]), await r, this.presented = !0;
750
835
  }
751
836
  /**
@@ -772,29 +857,29 @@ class J {
772
857
  const r = this.video, n = this.maskCodes;
773
858
  if (i.aborted || !r || !n)
774
859
  throw E();
775
- const s = this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : $e(this.manifest, this.times[e]);
776
- if (await this.presentFrame(r, s), i.aborted || r !== this.video)
860
+ const a = this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : Ke(this.manifest, this.times[e]);
861
+ if (await this.presentFrame(r, a), i.aborted || r !== this.video)
777
862
  throw E();
778
863
  const o = this.height * this.planes;
779
- let a = await this.capture(r, o, n);
780
- if (a === null && !this.primed) {
781
- if (await this.primeDecoder(r), await this.presentFrame(r, s), i.aborted || r !== this.video)
864
+ let s = await this.capture(r, o, n);
865
+ if (s === null && !this.primed) {
866
+ if (await this.primeDecoder(r), await this.presentFrame(r, a), i.aborted || r !== this.video)
782
867
  throw E();
783
- a = await this.capture(r, o, n);
868
+ s = await this.capture(r, o, n);
784
869
  }
785
- if (a === null)
870
+ if (s === null)
786
871
  throw new Error("GeoVideo frame could not be read back from the decoder");
787
- return a;
872
+ return s;
788
873
  }
789
874
  }
790
- function Ke(t) {
875
+ function tt(t) {
791
876
  return {
792
877
  codeRange: [t.codeMin / 255, t.codeMax / 255],
793
878
  valueRange: [t.valueMin, t.valueMax],
794
879
  transfer: t.transfer === "log10-1p9" ? 1 : 0
795
880
  };
796
881
  }
797
- class ze extends J {
882
+ class it extends J {
798
883
  constructor(e, i = {}) {
799
884
  if (e.encoding.kind !== "scalar-luma")
800
885
  throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
@@ -807,7 +892,7 @@ class ze extends J {
807
892
  });
808
893
  }
809
894
  }
810
- function R(t, e) {
895
+ function b(t, e) {
811
896
  if (e <= t[0])
812
897
  return { index: 0, fraction: 0 };
813
898
  const i = t.length - 1;
@@ -815,55 +900,55 @@ function R(t, e) {
815
900
  return { index: i, fraction: 0 };
816
901
  let r = 0, n = i;
817
902
  for (; n - r > 1; ) {
818
- const s = r + n >> 1;
819
- t[s] <= e ? r = s : n = s;
903
+ const a = r + n >> 1;
904
+ t[a] <= e ? r = a : n = a;
820
905
  }
821
906
  return { index: r, fraction: (e - t[r]) / (t[n] - t[r]) };
822
907
  }
823
- function N(t, e) {
824
- const { index: i, fraction: r } = R(t, e);
908
+ function G(t, e) {
909
+ const { index: i, fraction: r } = b(t, e);
825
910
  return i + r;
826
911
  }
827
- function Ze(t, e) {
912
+ function rt(t, e) {
828
913
  const i = Math.max(0, Math.min(t.length - 1, Math.floor(e))), r = Math.min(i + 1, t.length - 1);
829
914
  return t[i] + (t[r] - t[i]) * Math.max(0, e - i);
830
915
  }
831
- function Je(t, e) {
916
+ function nt(t, e) {
832
917
  let i = (t - e.codeMin) / (e.codeMax - e.codeMin) * 2 - 1;
833
918
  return i = Math.max(-1, Math.min(1, i)), e.transfer === "sqrt" && (i = Math.sign(i) * i * i), i * e.valueDomain;
834
919
  }
835
- function Qe(t, e, i, r) {
920
+ function at(t, e, i, r) {
836
921
  const n = e.length;
837
922
  if (t.length !== 2 * n)
838
923
  throw new Error(
839
924
  `GeoVideo vector frame has ${t.length} codes, expected ${2 * n}`
840
925
  );
841
- const s = new Float32Array(256);
926
+ const a = new Float32Array(256);
842
927
  for (let c = 0; c < 256; c++)
843
- s[c] = Je(c, r);
844
- const o = i * 255, a = new Float32Array(n), d = new Float32Array(n);
928
+ a[c] = nt(c, r);
929
+ const o = i * 255, s = new Float32Array(n), l = new Float32Array(n);
845
930
  for (let c = 0; c < n; c++) {
846
- const l = e[c] >= o;
847
- a[c] = l ? s[t[c]] : NaN, d[c] = l ? s[t[n + c]] : NaN;
931
+ const d = e[c] >= o;
932
+ s[c] = d ? a[t[c]] : NaN, l[c] = d ? a[t[n + c]] : NaN;
848
933
  }
849
- return { u: a, v: d };
934
+ return { u: s, v: l };
850
935
  }
851
- class et extends J {
936
+ class st extends J {
852
937
  constructor(e, i = {}) {
853
938
  if (e.encoding.kind !== "vector-luma")
854
939
  throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
855
940
  super(e, 2, i), this.encoding = e.encoding;
856
- const [r, n, s, o] = e.bounds, a = (s - r) / this.width, d = (o - n) / this.height;
941
+ const [r, n, a, o] = e.bounds, s = (a - r) / this.width, l = (o - n) / this.height;
857
942
  this.coords = {
858
943
  time: this.times,
859
944
  vertical: new Float32Array([0]),
860
945
  latitude: Float32Array.from(
861
946
  { length: this.height },
862
- (c, l) => o - (l + 0.5) * d
947
+ (c, d) => o - (d + 0.5) * l
863
948
  ),
864
949
  longitude: Float32Array.from(
865
950
  { length: this.width },
866
- (c, l) => r + (l + 0.5) * a
951
+ (c, d) => r + (d + 0.5) * s
867
952
  )
868
953
  };
869
954
  }
@@ -885,12 +970,12 @@ class et extends J {
885
970
  findTimeIndex(e) {
886
971
  const i = typeof e == "number" ? e : new Date(e).getTime(), r = this.coords.time;
887
972
  let n = 0;
888
- for (let s = 1; s < r.length; s++)
889
- Math.abs(r[s] - i) < Math.abs(r[n] - i) && (n = s);
973
+ for (let a = 1; a < r.length; a++)
974
+ Math.abs(r[a] - i) < Math.abs(r[n] - i) && (n = a);
890
975
  return n;
891
976
  }
892
977
  getChunksForBounds(e, i, r) {
893
- const { latitude: n, longitude: s } = this.coords;
978
+ const { latitude: n, longitude: a } = this.coords;
894
979
  return [
895
980
  {
896
981
  timeIdx: i,
@@ -898,7 +983,7 @@ class et extends J {
898
983
  latIdx: 0,
899
984
  lonIdx: 0,
900
985
  latRange: [n[0], n[this.height - 1]],
901
- lonRange: [s[0], s[this.width - 1]],
986
+ lonRange: [a[0], a[this.width - 1]],
902
987
  latSize: this.height,
903
988
  lonSize: this.width
904
989
  }
@@ -915,7 +1000,7 @@ class et extends J {
915
1000
  /** u/v codes are written into luma: read back, then decoded on the CPU. */
916
1001
  async capture(e, i, r) {
917
1002
  const n = this.readCodes(e, i);
918
- return n ? Qe(
1003
+ return n ? at(
919
1004
  n,
920
1005
  r,
921
1006
  this.manifest.mask.threshold,
@@ -923,23 +1008,23 @@ class et extends J {
923
1008
  ) : null;
924
1009
  }
925
1010
  }
926
- function tt(t, e, i = {}) {
927
- const [r, n] = i.range ?? [-1 / 0, 1 / 0], s = [...t].sort((a, d) => a.start - d.start), o = s.find(
928
- (a) => a.start > e && a.start <= n
929
- ) ?? (i.loop ? s.find(
930
- (a) => a.end >= r && a.start <= n
1011
+ function ot(t, e, i = {}) {
1012
+ const [r, n] = i.range ?? [-1 / 0, 1 / 0], a = [...t].sort((s, l) => s.start - l.start), o = a.find(
1013
+ (s) => s.start > e && s.start <= n
1014
+ ) ?? (i.loop ? a.find(
1015
+ (s) => s.end >= r && s.start <= n
931
1016
  ) : void 0);
932
1017
  return o ? { chunk: o, time: Math.max(o.start, r) } : null;
933
1018
  }
934
- function it(t, e) {
1019
+ function ct(t, e) {
935
1020
  let i = null, r = -1 / 0;
936
1021
  for (const n of e) {
937
- const s = Math.min(t.end, n.end) - Math.max(t.start, n.start);
938
- Number.isFinite(s) && s >= 0 && s > r && (i = n, r = s);
1022
+ const a = Math.min(t.end, n.end) - Math.max(t.start, n.start);
1023
+ Number.isFinite(a) && a >= 0 && a > r && (i = n, r = a);
939
1024
  }
940
1025
  return i;
941
1026
  }
942
- function rt(t) {
1027
+ function lt(t) {
943
1028
  return {
944
1029
  width: t.mask.width,
945
1030
  height: t.mask.height,
@@ -948,10 +1033,10 @@ function rt(t) {
948
1033
  };
949
1034
  }
950
1035
  function Q(t, e = {}) {
951
- return t.encoding.kind === "vector-luma" ? new et(t, e) : new ze(t, e);
1036
+ return t.encoding.kind === "vector-luma" ? new st(t, e) : new it(t, e);
952
1037
  }
953
- const nt = 3, st = 3, at = 0.6, ot = 1.5;
954
- function ct(t) {
1038
+ const dt = 3, ht = 3, ut = 0.6, ft = 1.5;
1039
+ function mt(t) {
955
1040
  const e = new AbortController();
956
1041
  if (!t)
957
1042
  return { controller: e, unlink: () => {
@@ -962,14 +1047,14 @@ function ct(t) {
962
1047
  unlink: () => t.removeEventListener("abort", i)
963
1048
  };
964
1049
  }
965
- class Bt {
1050
+ class ti {
966
1051
  constructor(e) {
967
1052
  this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = e.id, this.chunks = e.chunks.filter(
968
1053
  (i) => Number.isFinite(i.start) && Number.isFinite(i.end) && i.end >= i.start
969
- ).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? nt), this.frameCacheSize = Math.max(
1054
+ ).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? dt), this.frameCacheSize = Math.max(
970
1055
  1,
971
- e.frameCacheSize ?? st
972
- ), this.prefetchAt = e.prefetchAt ?? at, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? qe, this.createFrameSource = e.createFrameSource ?? ((i, r) => Q(
1056
+ e.frameCacheSize ?? ht
1057
+ ), this.prefetchAt = e.prefetchAt ?? ut, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? ze, this.createFrameSource = e.createFrameSource ?? ((i, r) => Q(
973
1058
  i,
974
1059
  r
975
1060
  ));
@@ -988,11 +1073,11 @@ class Bt {
988
1073
  async steps(e = {}) {
989
1074
  if (e.signal?.aborted)
990
1075
  throw E();
991
- const i = await _(
1076
+ const i = await x(
992
1077
  Promise.all(this.chunks.map((r) => this.manifest(r))),
993
1078
  e.signal
994
1079
  );
995
- return Float64Array.from(i.flatMap(w));
1080
+ return Float64Array.from(i.flatMap(_));
996
1081
  }
997
1082
  /**
998
1083
  * The frames bracketing `time`, decoded; null out of coverage (before the
@@ -1002,41 +1087,41 @@ class Bt {
1002
1087
  const { signal: r } = i, n = i.mode ?? "interpolate";
1003
1088
  if (r?.aborted)
1004
1089
  throw E();
1005
- const s = this.chunkIndexAt(e);
1006
- if (s < 0)
1090
+ const a = this.chunkIndexAt(e);
1091
+ if (a < 0)
1007
1092
  return null;
1008
- const o = [], { controller: a, unlink: d } = ct(r);
1093
+ const o = [], { controller: s, unlink: l } = mt(r);
1009
1094
  try {
1010
- const c = this.acquire(this.chunks[s], o), l = await _(c.ready, a.signal), { times: h } = l;
1095
+ const c = this.acquire(this.chunks[a], o), d = await x(c.ready, s.signal), { times: h } = d;
1011
1096
  let f;
1012
1097
  if (e <= h[h.length - 1]) {
1013
- const { index: b, fraction: g } = R(h, e);
1014
- f = n === "discrete" || g === 0 ? [c, b, c, b, 0] : [c, b, c, b + 1, g];
1098
+ const { index: g, fraction: R } = b(h, e);
1099
+ f = n === "discrete" || R === 0 ? [c, g, c, g, 0] : [c, g, c, g + 1, R];
1015
1100
  } else {
1016
- const b = this.chunks[s + 1];
1017
- if (!b)
1101
+ const g = this.chunks[a + 1];
1102
+ if (!g)
1018
1103
  return null;
1019
- const g = this.acquire(b, o), V = await _(g.ready, a.signal), x = h.length - 1, U = h[x], P = V.times[0];
1020
- if (P - U > this.gapLimit(h, V.times))
1104
+ const R = this.acquire(g, o), V = await x(R.ready, s.signal), y = h.length - 1, D = h[y], U = V.times[0];
1105
+ if (U - D > this.gapLimit(h, V.times))
1021
1106
  return null;
1022
- f = n === "discrete" ? [c, x, c, x, 0] : e >= P ? [g, 0, g, 0, 0] : [c, x, g, 0, (e - U) / (P - U)];
1107
+ f = n === "discrete" ? [c, y, c, y, 0] : e >= U ? [R, 0, R, 0, 0] : [c, y, R, 0, (e - D) / (U - D)];
1023
1108
  }
1024
- const [u, m, T, v, y] = f, L = u === T && m === v, C = [this.frame(u, m, a.signal)];
1025
- L || C.push(this.frame(T, v, a.signal));
1109
+ const [u, m, T, F, w] = f, L = u === T && m === F, C = [this.frame(u, m, s.signal)];
1110
+ L || C.push(this.frame(T, F, s.signal));
1026
1111
  let S;
1027
1112
  try {
1028
1113
  S = await Promise.all(C);
1029
- } catch (b) {
1030
- throw a.abort(), b;
1114
+ } catch (g) {
1115
+ throw s.abort(), g;
1031
1116
  }
1032
- return this.prefetchAfter(s, e), {
1117
+ return this.prefetchAfter(a, e), {
1033
1118
  time: e,
1034
1119
  a: S[0],
1035
1120
  b: S[L ? 0 : 1],
1036
- mix: y
1121
+ mix: w
1037
1122
  };
1038
1123
  } finally {
1039
- d();
1124
+ l();
1040
1125
  for (const c of o)
1041
1126
  c.users--;
1042
1127
  this.trim();
@@ -1060,8 +1145,8 @@ class Bt {
1060
1145
  chunkIndexAt(e) {
1061
1146
  let i = 0, r = this.chunks.length - 1, n = -1;
1062
1147
  for (; i <= r; ) {
1063
- const s = i + r >> 1;
1064
- this.chunks[s].start <= e ? (n = s, i = s + 1) : r = s - 1;
1148
+ const a = i + r >> 1;
1149
+ this.chunks[a].start <= e ? (n = a, i = a + 1) : r = a - 1;
1065
1150
  }
1066
1151
  return n;
1067
1152
  }
@@ -1072,10 +1157,10 @@ class Bt {
1072
1157
  e.length > 1 ? e[e.length - 1] - e[e.length - 2] : 0,
1073
1158
  i.length > 1 ? i[1] - i[0] : 0
1074
1159
  ], n = Math.max(...r);
1075
- return n > 0 ? n * ot : -1 / 0;
1160
+ return n > 0 ? n * ft : -1 / 0;
1076
1161
  }
1077
1162
  prefetchAfter(e, i) {
1078
- const r = this.chunks[e], n = this.chunks[e + 1], s = r.end - r.start, o = s > 0 ? (i - r.start) / s : 1;
1163
+ const r = this.chunks[e], n = this.chunks[e + 1], a = r.end - r.start, o = a > 0 ? (i - r.start) / a : 1;
1079
1164
  n && o > this.prefetchAt && this.prefetch(n);
1080
1165
  }
1081
1166
  manifest(e) {
@@ -1108,8 +1193,8 @@ class Bt {
1108
1193
  throw E();
1109
1194
  return r.opened = {
1110
1195
  manifest: n,
1111
- times: Float64Array.from(w(n)),
1112
- grid: rt(n),
1196
+ times: Float64Array.from(_(n)),
1197
+ grid: lt(n),
1113
1198
  source: this.createFrameSource(n, {
1114
1199
  cacheSize: this.frameCacheSize
1115
1200
  })
@@ -1121,19 +1206,19 @@ class Bt {
1121
1206
  return this.open.set(e.key, i), i;
1122
1207
  }
1123
1208
  async frame(e, i, r) {
1124
- const { manifest: n, times: s, grid: o, source: a } = await _(
1209
+ const { manifest: n, times: a, grid: o, source: s } = await x(
1125
1210
  e.ready,
1126
1211
  r
1127
1212
  );
1128
1213
  if (e.released)
1129
1214
  throw E();
1130
- const d = await a.frame(i, { signal: r });
1215
+ const l = await s.frame(i, { signal: r });
1131
1216
  return {
1132
1217
  key: `${this.id}/${e.chunk.key}/${i}`,
1133
1218
  chunk: e.chunk,
1134
1219
  step: i,
1135
- time: s[i],
1136
- data: d,
1220
+ time: a[i],
1221
+ data: l,
1137
1222
  grid: o,
1138
1223
  manifest: n
1139
1224
  };
@@ -1151,18 +1236,18 @@ class Bt {
1151
1236
  e.released = !0, e.prefetch?.abort(), e.prefetch = null, e.opened?.source.release(), e.opened = null, this.open.get(e.chunk.key) === e && this.open.delete(e.chunk.key);
1152
1237
  }
1153
1238
  }
1154
- const dt = {
1239
+ const Et = {
1155
1240
  a: "u_vel0",
1156
1241
  b: "u_vel1",
1157
1242
  mix: "u_vel_mix",
1158
1243
  bounds: "u_bounds"
1159
- }, lt = {
1244
+ }, pt = {
1160
1245
  a: "u_tint0",
1161
1246
  b: "u_tint1",
1162
1247
  mix: "u_tint_mix",
1163
1248
  bounds: "u_tint_bounds"
1164
1249
  };
1165
- function ht(t) {
1250
+ function Tt(t) {
1166
1251
  const e = new Float32Array(t.u.length * 4);
1167
1252
  for (let i = 0; i < t.u.length; i++) {
1168
1253
  const r = t.u[i], n = t.v[i];
@@ -1170,10 +1255,10 @@ function ht(t) {
1170
1255
  }
1171
1256
  return e;
1172
1257
  }
1173
- class ut {
1258
+ class gt {
1174
1259
  constructor(e, i, r = {}) {
1175
- this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = Q(i, { cacheSize: 2 }), this.uniforms = this.vector ? dt : lt;
1176
- const n = w(i);
1260
+ this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = Q(i, { cacheSize: 2 }), this.uniforms = this.vector ? Et : pt;
1261
+ const n = _(i);
1177
1262
  this.times = r.animateSnapshot && i.timeline.kind === "snapshot-loop" ? Array.from(
1178
1263
  {
1179
1264
  length: Math.max(
@@ -1181,7 +1266,7 @@ class ut {
1181
1266
  Math.round(i.media.durationSeconds * i.media.fps)
1182
1267
  )
1183
1268
  },
1184
- (s, o) => n[0] + o * 1e3 / i.media.fps
1269
+ (a, o) => n[0] + o * 1e3 / i.media.fps
1185
1270
  ) : n, this.bounds = i.bounds;
1186
1271
  }
1187
1272
  get currentPair() {
@@ -1198,12 +1283,12 @@ class ut {
1198
1283
  }
1199
1284
  /** Resolves once the step at `ms` is uploaded. */
1200
1285
  async prime(e) {
1201
- const { index: i } = R(this.times, e);
1286
+ const { index: i } = b(this.times, e);
1202
1287
  await this.request(i);
1203
1288
  }
1204
1289
  /** True once the frames interpolated at `ms` are uploaded. */
1205
1290
  ready(e) {
1206
- const { index: i, fraction: r } = R(this.times, e);
1291
+ const { index: i, fraction: r } = b(this.times, e);
1207
1292
  return this.textures.has(i) && (r === 0 || this.textures.has(i + 1));
1208
1293
  }
1209
1294
  /**
@@ -1211,12 +1296,12 @@ class ut {
1211
1296
  * `ms`, then request those first.
1212
1297
  */
1213
1298
  focus(e) {
1214
- const { index: i } = R(this.times, e), r = Math.min(i + 1, this.times.length - 1);
1299
+ const { index: i } = b(this.times, e), r = Math.min(i + 1, this.times.length - 1);
1215
1300
  [...this.pending.keys()].some(
1216
- (s) => s !== i && s !== r
1301
+ (a) => a !== i && a !== r
1217
1302
  ) && (this.source.cancelAll(), this.pending.clear());
1218
- for (const s of [i, r])
1219
- this.request(s).catch(() => {
1303
+ for (const a of [i, r])
1304
+ this.request(a).catch(() => {
1220
1305
  });
1221
1306
  }
1222
1307
  /**
@@ -1224,13 +1309,13 @@ class ut {
1224
1309
  * while a requested frame decodes.
1225
1310
  */
1226
1311
  sample(e, i = !0) {
1227
- const { index: r, fraction: n } = R(this.times, e), s = Math.min(r + 1, this.times.length - 1);
1228
- [...this.pending.keys()].some((c) => c < r || c > s + 1) && (this.source.cancelAll(), this.pending.clear());
1229
- for (const c of [r, s, s + 1])
1312
+ const { index: r, fraction: n } = b(this.times, e), a = Math.min(r + 1, this.times.length - 1);
1313
+ [...this.pending.keys()].some((c) => c < r || c > a + 1) && (this.source.cancelAll(), this.pending.clear());
1314
+ for (const c of [r, a, a + 1])
1230
1315
  c < this.times.length && this.request(c).catch(() => {
1231
1316
  });
1232
- const o = this.textures.get(r), a = this.textures.get(s), d = i ? n : 0;
1233
- return o && (d === 0 || a) && (this.pair = [o, d === 0 ? o : a, d]), this.evict(r), this.pair;
1317
+ const o = this.textures.get(r), s = this.textures.get(a), l = i ? n : 0;
1318
+ return o && (l === 0 || s) && (this.pair = [o, l === 0 ? o : s, l]), this.evict(r), this.pair;
1234
1319
  }
1235
1320
  /** Switch spatial filtering without changing the decoded-step cache. */
1236
1321
  setFilter(e) {
@@ -1263,10 +1348,10 @@ class ut {
1263
1348
  return !1;
1264
1349
  const n = this.uniforms;
1265
1350
  if (e.texture(n.a, r, this.pair[0]), e.texture(n.b, r + 1, this.pair[1]), e.float(n.mix, this.pair[2]), e.vec4(n.bounds, this.bounds), this.mask && this.manifest.encoding.kind === "scalar-luma") {
1266
- const { codeRange: s, valueRange: o, transfer: a } = Ke(
1351
+ const { codeRange: a, valueRange: o, transfer: s } = tt(
1267
1352
  this.manifest.encoding
1268
1353
  );
1269
- e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...s), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", a);
1354
+ e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...a), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", s);
1270
1355
  }
1271
1356
  return !0;
1272
1357
  }
@@ -1284,8 +1369,8 @@ class ut {
1284
1369
  return i;
1285
1370
  const r = this.source.frame(e).then((n) => {
1286
1371
  if (!this.destroyed && this.pending.get(e) === r && !this.textures.has(e)) {
1287
- const s = performance.now();
1288
- this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() - s, this.options.onReady?.();
1372
+ const a = performance.now();
1373
+ this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() - a, this.options.onReady?.();
1289
1374
  }
1290
1375
  }).catch((n) => {
1291
1376
  throw !this.destroyed && this.pending.get(e) === r && !(n instanceof Error && n.name === "AbortError") && this.options.onError?.(n), n;
@@ -1302,15 +1387,15 @@ class ut {
1302
1387
  i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
1303
1388
  i.UNPACK_COLORSPACE_CONVERSION_WEBGL,
1304
1389
  i.UNPACK_ALIGNMENT
1305
- ], s = n.map((o) => i.getParameter(o));
1390
+ ], a = n.map((o) => i.getParameter(o));
1306
1391
  try {
1307
1392
  return this.upload(e);
1308
1393
  } finally {
1309
- i.bindTexture(i.TEXTURE_2D, r), n.forEach((o, a) => i.pixelStorei(o, s[a]));
1394
+ i.bindTexture(i.TEXTURE_2D, r), n.forEach((o, s) => i.pixelStorei(o, a[s]));
1310
1395
  }
1311
1396
  }
1312
1397
  upload(e) {
1313
- const i = this.gl, { width: r, height: n } = this.source, s = this.gridTexture();
1398
+ const i = this.gl, { width: r, height: n } = this.source, a = this.gridTexture();
1314
1399
  return this.vector ? i.texImage2D(
1315
1400
  i.TEXTURE_2D,
1316
1401
  0,
@@ -1320,7 +1405,7 @@ class ut {
1320
1405
  0,
1321
1406
  i.RGBA,
1322
1407
  i.FLOAT,
1323
- ht(e)
1408
+ Tt(e)
1324
1409
  ) : (i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, i.NONE), i.texImage2D(
1325
1410
  i.TEXTURE_2D,
1326
1411
  0,
@@ -1328,7 +1413,7 @@ class ut {
1328
1413
  i.RGBA,
1329
1414
  i.UNSIGNED_BYTE,
1330
1415
  e
1331
- ), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null), s;
1416
+ ), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null), a;
1332
1417
  }
1333
1418
  /** The source's mask, loaded with its first frame, as an R8 texture. */
1334
1419
  uploadMask() {
@@ -1373,7 +1458,7 @@ class ut {
1373
1458
  }
1374
1459
  }
1375
1460
  }
1376
- class ft {
1461
+ class bt {
1377
1462
  constructor(e, i) {
1378
1463
  this.onPlaying = i, this.time = 0, this.endFraction = 0, this.held = !1, this.playingValue = e;
1379
1464
  }
@@ -1398,37 +1483,37 @@ class ft {
1398
1483
  * Advance in step units, including irregular timelines. Returns true at a
1399
1484
  * non-looping end. holdLastStep gives the final sample a full step's duration.
1400
1485
  */
1401
- advance(e, i, r, n = [i[0], i[i.length - 1]], s = !1, o = !1) {
1486
+ advance(e, i, r, n = [i[0], i[i.length - 1]], a = !1, o = !1) {
1402
1487
  if (!this.advancing || !i.length)
1403
1488
  return !1;
1404
- const a = N(i, n[0]), d = N(i, n[1]), c = d + (o ? 1 : 0);
1405
- let l = Math.max(a, N(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
1406
- const h = o ? l >= c : l > c;
1407
- return h && s && c > a ? l = a + (l - a) % (c - a) : l = Math.min(c, l), this.time = Ze(i, Math.min(d, l)), this.endFraction = Math.max(0, l - d), h && !s;
1489
+ const s = G(i, n[0]), l = G(i, n[1]), c = l + (o ? 1 : 0);
1490
+ let d = Math.max(s, G(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
1491
+ const h = o ? d >= c : d > c;
1492
+ return h && a && c > s ? d = s + (d - s) % (c - s) : d = Math.min(c, d), this.time = rt(i, Math.min(l, d)), this.endFraction = Math.max(0, d - l), h && !a;
1408
1493
  }
1409
1494
  }
1410
- function k(t) {
1411
- const e = w(t);
1495
+ function A(t) {
1496
+ const e = _(t);
1412
1497
  return [e[0], e[e.length - 1]];
1413
1498
  }
1414
- function I(t, e) {
1499
+ function N(t, e) {
1415
1500
  return e ? [Math.max(t[0], e[0]), Math.min(t[1], e[1])] : t;
1416
1501
  }
1417
- function F([t, e], i) {
1502
+ function k([t, e], i) {
1418
1503
  return Math.max(t, Math.min(e, i));
1419
1504
  }
1420
- class Xt {
1505
+ class ii {
1421
1506
  constructor(e, i, r) {
1422
1507
  this.repaint = i, this.emit = r, this.field = null, this.manifest = null, this.gl = null, this.pendingField = null, this.standby = null, this.awaitingNext = !1, this.timeRange = null, this.lastTick = null, this.lastStepTime = null, this.seekId = 0, this.seeking = !1, this.failed = !1, this.exactTime = 0, this.endEmitted = !1, this.destroyed = !1, this.resumePlayback = !1, this.playOnReady = e.autoplay ?? !0, this.loop = e.loop ?? !0, this.playbackRate = e.playbackRate ?? 1, this.stepsPerSecond = e.stepsPerSecond;
1423
1508
  const n = typeof e.time == "string" ? Date.parse(e.time) : e.time;
1424
- this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new ft(
1509
+ this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new bt(
1425
1510
  !1,
1426
- (s) => this.emit("playbackChange", s)
1511
+ (a) => this.emit("playbackChange", a)
1427
1512
  );
1428
1513
  }
1429
1514
  async load(e, i) {
1430
- if (this.gl = e, this.manifest = i, this.timeRange = I(
1431
- k(i),
1515
+ if (this.gl = e, this.manifest = i, this.timeRange = N(
1516
+ A(i),
1432
1517
  this.requestedTimeRange
1433
1518
  ), this.timeRange[0] > this.timeRange[1])
1434
1519
  throw new Error(
@@ -1472,12 +1557,12 @@ class Xt {
1472
1557
  const r = this.clock.advance(
1473
1558
  i,
1474
1559
  this.field.times,
1475
- this.stepsPerSecond ?? this.playbackRate * z(this.field.manifest),
1560
+ this.stepsPerSecond ?? this.playbackRate * K(this.field.manifest),
1476
1561
  this.playbackRange(this.field),
1477
1562
  this.loop,
1478
1563
  !0
1479
- ), { index: n } = R(this.field.times, this.clock.ms), s = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : F(this.timeRange, this.field.times[n]);
1480
- s !== this.lastStepTime && (this.lastStepTime = s, this.emit("timeChange", s)), r ? this.reachEnd() : this.repaint();
1564
+ ), { index: n } = b(this.field.times, this.clock.ms), a = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : k(this.timeRange, this.field.times[n]);
1565
+ a !== this.lastStepTime && (this.lastStepTime = a, this.emit("timeChange", a)), r ? this.reachEnd() : this.repaint();
1481
1566
  }
1482
1567
  setTime(e) {
1483
1568
  const i = typeof e == "number" ? e : Date.parse(e);
@@ -1490,27 +1575,27 @@ class Xt {
1490
1575
  /** Load the requested step first; stale seeks and swaps cannot replace it. */
1491
1576
  async prepare(e, i) {
1492
1577
  this.failed = !1;
1493
- const r = ++this.seekId, n = this.timeRange ?? k(e.manifest), s = i ?? F(n, this.requestedTime ?? n[0]), o = R(e.times, s), a = Math.min(
1578
+ const r = ++this.seekId, n = this.timeRange ?? A(e.manifest), a = i ?? k(n, this.requestedTime ?? n[0]), o = b(e.times, a), s = Math.min(
1494
1579
  e.times.length - 1,
1495
1580
  o.index + (o.fraction > 0.5 ? 1 : 0)
1496
- ), d = e.times[a];
1497
- this.seeking = !0, this.lastTick = null, e.focus(d);
1581
+ ), l = e.times[s];
1582
+ this.seeking = !0, this.lastTick = null, e.focus(l);
1498
1583
  try {
1499
- await e.prime(d);
1500
- } catch (l) {
1584
+ await e.prime(l);
1585
+ } catch (d) {
1501
1586
  if (r !== this.seekId)
1502
1587
  return;
1503
- throw l;
1588
+ throw d;
1504
1589
  }
1505
1590
  if (r !== this.seekId || this.destroyed)
1506
1591
  return;
1507
1592
  const c = this.pendingField === e;
1508
- if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = d, this.clock.ms = F(this.playbackRange(e), d), e.sample(d, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
1509
- const l = e.manifest;
1593
+ if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = l, this.clock.ms = k(this.playbackRange(e), l), e.sample(l, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
1594
+ const d = e.manifest;
1510
1595
  if (this.emit("loaded", {
1511
- min: l.style.colorDomain[0],
1512
- max: l.style.colorDomain[1],
1513
- unit: l.style.unit ?? "",
1596
+ min: d.style.colorDomain[0],
1597
+ max: d.style.colorDomain[1],
1598
+ unit: d.style.unit ?? "",
1514
1599
  time: new Date(this.clock.ms).toISOString()
1515
1600
  }), this.emit("status", { phase: "ready", time: this.clock.ms }), this.playOnReady) {
1516
1601
  this.playOnReady = !1;
@@ -1527,7 +1612,7 @@ class Xt {
1527
1612
  this.playOnReady ||= this.isPlaying(), this.pendingField?.destroy();
1528
1613
  const n = this.standby;
1529
1614
  return this.standby = null, n && n.field.manifest.media.url !== e.media.url && n.field.destroy(), this.pendingField = n?.field.manifest.media.url === e.media.url ? n.field : this.createField(e), this.awaitingNext = !1, this.manifest = e, this.requestedTimeRange = i.timeRange, this.timeRange = r, this.requestedTime = i.time ?? r[0], this.loop = i.loop ?? this.loop, this.playbackRate = i.playbackRate ?? this.playbackRate, this.stepsPerSecond = i.stepsPerSecond ?? this.stepsPerSecond, this.lastTick = null, this.prepare(this.pendingField).catch(
1530
- (s) => this.reportError(s)
1615
+ (a) => this.reportError(a)
1531
1616
  ), !0;
1532
1617
  }
1533
1618
  /** Decode the next chunk ahead of its swap, including its static mask. */
@@ -1535,11 +1620,11 @@ class Xt {
1535
1620
  const r = this.replacementTimeRange(e, i);
1536
1621
  if (!r || !this.gl || e.media.url === this.manifest?.media.url)
1537
1622
  return !1;
1538
- const n = F(r, i.time ?? r[0]);
1623
+ const n = k(r, i.time ?? r[0]);
1539
1624
  this.standby?.field.manifest.media.url !== e.media.url && (this.discardStandby(), this.standby = { field: this.createField(e), time: n });
1540
- const s = this.standby;
1541
- return s.time = n, s.field.prime(n).catch(() => {
1542
- this.standby === s && this.discardStandby();
1625
+ const a = this.standby;
1626
+ return a.time = n, a.field.prime(n).catch(() => {
1627
+ this.standby === a && this.discardStandby();
1543
1628
  }), !0;
1544
1629
  }
1545
1630
  discardStandby() {
@@ -1550,8 +1635,8 @@ class Xt {
1550
1635
  const r = this.manifest;
1551
1636
  if (!r || e.encoding.kind !== r.encoding.kind || e.media.width !== r.media.width || e.media.height !== r.media.height || e.mask.width !== r.mask.width || e.mask.height !== r.mask.height)
1552
1637
  return null;
1553
- const n = I(
1554
- k(e),
1638
+ const n = N(
1639
+ A(e),
1555
1640
  i.timeRange
1556
1641
  );
1557
1642
  return n[0] <= n[1] ? n : null;
@@ -1572,7 +1657,7 @@ class Xt {
1572
1657
  pause() {
1573
1658
  const e = this.playOnReady && !this.clock.playing;
1574
1659
  if (this.playOnReady = !1, this.awaitingNext = !1, this.clock.setPlaying(!1), this.field && !this.pendingField && !this.seeking && !this.endEmitted) {
1575
- const { index: i } = R(this.field.times, this.clock.ms);
1660
+ const { index: i } = b(this.field.times, this.clock.ms);
1576
1661
  this.prepare(this.field, this.field.times[i]).catch(
1577
1662
  (r) => this.reportError(r)
1578
1663
  );
@@ -1596,8 +1681,8 @@ class Xt {
1596
1681
  setTimeRange(e) {
1597
1682
  if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] > e[1])
1598
1683
  throw new Error("Invalid GeoVideo time range");
1599
- const i = I(
1600
- this.manifest ? k(this.manifest) : e,
1684
+ const i = N(
1685
+ this.manifest ? A(this.manifest) : e,
1601
1686
  e
1602
1687
  );
1603
1688
  if (i[0] > i[1])
@@ -1615,7 +1700,7 @@ class Xt {
1615
1700
  ];
1616
1701
  }
1617
1702
  createField(e) {
1618
- const i = new ut(this.gl, e, {
1703
+ const i = new gt(this.gl, e, {
1619
1704
  repeatLongitude: !1,
1620
1705
  animateSnapshot: !0,
1621
1706
  onError: (r) => {
@@ -1630,7 +1715,7 @@ class Xt {
1630
1715
  i.name === "AbortError" || this.destroyed || (this.playOnReady = !1, this.awaitingNext = !1, this.failed = !0, this.seeking = !0, this.clock.setPlaying(!1), this.emit("status", { phase: "error", error: i }), this.emit("error", i));
1631
1716
  }
1632
1717
  }
1633
- function G(t) {
1718
+ function I(t) {
1634
1719
  const { start: e, end: i } = t.temporal ?? {};
1635
1720
  return {
1636
1721
  source: t,
@@ -1638,35 +1723,35 @@ function G(t) {
1638
1723
  end: Date.parse(i ?? e ?? "")
1639
1724
  };
1640
1725
  }
1641
- function Ot(t, e, i = {}) {
1642
- const r = t.filter((s) => s.id === e.id && s.temporal?.start != null).map(G), n = tt(
1726
+ function ri(t, e, i = {}) {
1727
+ const r = t.filter((a) => a.id === e.id && a.temporal?.start != null).map(I), n = ot(
1643
1728
  r,
1644
1729
  Date.parse(e.temporal?.end ?? ""),
1645
1730
  i
1646
1731
  );
1647
1732
  return n ? { source: n.chunk.source, time: n.time } : null;
1648
1733
  }
1649
- function qt(t, e) {
1650
- return it(G(t), e.map(G))?.source ?? null;
1734
+ function ni(t, e) {
1735
+ return ct(I(t), e.map(I))?.source ?? null;
1651
1736
  }
1652
- const mt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
1653
- function Et(t) {
1737
+ const Rt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
1738
+ function _t(t) {
1654
1739
  return t instanceof Date ? t.getTime() : typeof t == "number" ? t : new Date(t).getTime();
1655
1740
  }
1656
1741
  function Y(t, e) {
1657
- const i = Et(t);
1742
+ const i = _t(t);
1658
1743
  if (!Number.isFinite(i))
1659
1744
  throw new Error(`Invalid ${e}`);
1660
1745
  return i;
1661
1746
  }
1662
1747
  function ee(t, e) {
1663
- const i = e.match(mt);
1748
+ const i = e.match(Rt);
1664
1749
  if (!i)
1665
1750
  throw new Error(`Invalid trailing time duration: ${e}`);
1666
- const r = i.slice(1).map((y) => Number(y ?? 0));
1667
- if (!r.some((y) => y > 0))
1751
+ const r = i.slice(1).map((w) => Number(w ?? 0));
1752
+ if (!r.some((w) => w > 0))
1668
1753
  throw new Error("Trailing time duration must be positive");
1669
- const [n, s, o, a, d, c, l] = r, h = new Date(t), f = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - s, u = Math.floor(f / 12), m = (f % 12 + 12) % 12, T = new Date(Date.UTC(u, m + 1, 0)).getUTCDate();
1754
+ const [n, a, o, s, l, c, d] = r, h = new Date(t), f = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - a, u = Math.floor(f / 12), m = (f % 12 + 12) % 12, T = new Date(Date.UTC(u, m + 1, 0)).getUTCDate();
1670
1755
  return Date.UTC(
1671
1756
  u,
1672
1757
  m,
@@ -1675,21 +1760,21 @@ function ee(t, e) {
1675
1760
  h.getUTCMinutes(),
1676
1761
  h.getUTCSeconds(),
1677
1762
  h.getUTCMilliseconds()
1678
- ) - (((o * 7 + a) * 24 + d) * 60 + c) * 6e4 - l * 1e3;
1763
+ ) - (((o * 7 + s) * 24 + l) * 60 + c) * 6e4 - d * 1e3;
1679
1764
  }
1680
- function $t(t, [e, i]) {
1765
+ function ai(t, [e, i]) {
1681
1766
  let r = e, n = i;
1682
1767
  if (typeof t.trailing == "string" ? r = ee(i, t.trailing) : (t.start != null && (r = Y(t.start, "time range start")), t.end != null && (n = Y(t.end, "time range end"))), r > n)
1683
1768
  throw new Error("Time range start must not follow its end");
1684
1769
  return [Math.max(e, r), Math.min(i, n)];
1685
1770
  }
1686
- const pt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
1687
- function Wt(t, e) {
1688
- if (!pt(t))
1771
+ const xt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
1772
+ function si(t, e) {
1773
+ if (!xt(t))
1689
1774
  throw new Error(`${e} must be an object`);
1690
- for (const s of Object.keys(t))
1691
- if (s !== "start" && s !== "end" && s !== "trailing")
1692
- throw new Error(`${e}.${s} is not a time range key`);
1775
+ for (const a of Object.keys(t))
1776
+ if (a !== "start" && a !== "end" && a !== "trailing")
1777
+ throw new Error(`${e}.${a} is not a time range key`);
1693
1778
  if (t.trailing !== void 0) {
1694
1779
  if (t.start !== void 0 || t.end !== void 0)
1695
1780
  throw new Error(`${e}.trailing excludes start and end`);
@@ -1697,11 +1782,11 @@ function Wt(t, e) {
1697
1782
  throw new Error(`${e}.trailing must be an ISO 8601 duration`);
1698
1783
  return ee(0, t.trailing), { trailing: t.trailing };
1699
1784
  }
1700
- const i = (s) => {
1701
- const o = t[s];
1785
+ const i = (a) => {
1786
+ const o = t[a];
1702
1787
  if (o !== void 0) {
1703
1788
  if (typeof o != "string" || !Number.isFinite(Date.parse(o)))
1704
- throw new Error(`${e}.${s} is not a date`);
1789
+ throw new Error(`${e}.${a} is not a date`);
1705
1790
  return o;
1706
1791
  }
1707
1792
  }, r = i("start"), n = i("end");
@@ -1712,16 +1797,16 @@ function Wt(t, e) {
1712
1797
  ...n !== void 0 && { end: n }
1713
1798
  };
1714
1799
  }
1715
- function Ht(t) {
1800
+ function oi(t) {
1716
1801
  return t.type === "geovideo" && typeof t.indexUrl == "string";
1717
1802
  }
1718
- function Yt(t, e) {
1803
+ function ci(t, e) {
1719
1804
  return t.id === e.id && (t.type !== "geovideo" || e.type !== "geovideo" || t.manifestUrl === e.manifestUrl);
1720
1805
  }
1721
1806
  function j(t) {
1722
1807
  return typeof t == "string" && Number.isFinite(Date.parse(t));
1723
1808
  }
1724
- function Tt(t) {
1809
+ function wt(t) {
1725
1810
  const e = t;
1726
1811
  if (!e || e.schemaVersion !== 1 || e.type !== "geovideo-index" || !Array.isArray(e.chunks))
1727
1812
  throw new Error("Unsupported GeoVideo index");
@@ -1730,19 +1815,19 @@ function Tt(t) {
1730
1815
  throw new Error("Invalid GeoVideo index chunk");
1731
1816
  return e;
1732
1817
  }
1733
- async function jt(t, e) {
1818
+ async function li(t, e) {
1734
1819
  const i = await fetch(t, { signal: e });
1735
1820
  if (!i.ok)
1736
1821
  throw new Error(
1737
1822
  `GeoVideo index request failed (${i.status}): ${t}`
1738
1823
  );
1739
- return Tt(await i.json());
1824
+ return wt(await i.json());
1740
1825
  }
1741
- function bt(t) {
1826
+ function yt(t) {
1742
1827
  return typeof document < "u" ? new URL(t, document.baseURI).href : t;
1743
1828
  }
1744
- function Rt(t, e) {
1745
- const i = bt(e);
1829
+ function vt(t, e) {
1830
+ const i = yt(e);
1746
1831
  return t.chunks.map((r) => ({
1747
1832
  key: r.key,
1748
1833
  manifestUrl: new URL(r.manifestUrl, i).href,
@@ -1752,17 +1837,17 @@ function Rt(t, e) {
1752
1837
  ...r.provisional ? { provisional: !0 } : {}
1753
1838
  }));
1754
1839
  }
1755
- function gt(t, e, i) {
1840
+ function At(t, e, i) {
1756
1841
  if (e.sourceId !== t.id || e.catalogEntryId !== i.id)
1757
1842
  throw new Error(
1758
1843
  `GeoVideo index identity does not match catalog entry/source: ${t.id}`
1759
1844
  );
1760
1845
  }
1761
- function Kt(t, e, i) {
1762
- gt(t, e, i);
1763
- const r = Rt(e, t.indexUrl);
1846
+ function di(t, e, i) {
1847
+ At(t, e, i);
1848
+ const r = vt(e, t.indexUrl);
1764
1849
  return e.chunks.map(
1765
- (n, s) => ({
1850
+ (n, a) => ({
1766
1851
  id: t.id,
1767
1852
  type: "geovideo",
1768
1853
  title: t.title,
@@ -1773,67 +1858,75 @@ function Kt(t, e, i) {
1773
1858
  start: n.start,
1774
1859
  end: n.end
1775
1860
  },
1776
- manifestUrl: r[s].manifestUrl
1861
+ manifestUrl: r[a].manifestUrl
1777
1862
  })
1778
1863
  );
1779
1864
  }
1780
1865
  export {
1781
- ee as $,
1782
- Ht as A,
1783
- Ot as B,
1784
- jt as C,
1785
- Kt as D,
1786
- $t as E,
1787
- Vt as F,
1788
- Xt as G,
1789
- W as H,
1790
- Bt as I,
1791
- ft as J,
1792
- ut as K,
1793
- J as L,
1794
- ze as M,
1795
- et as N,
1796
- xe as O,
1866
+ Ve as $,
1867
+ K as A,
1868
+ Bt as B,
1869
+ oi as C,
1870
+ ri as D,
1871
+ li as E,
1872
+ di as F,
1873
+ Zt as G,
1874
+ ai as H,
1875
+ ei as I,
1876
+ $ as J,
1877
+ $t as K,
1878
+ Yt as L,
1879
+ zt as M,
1880
+ ti as N,
1881
+ bt as O,
1797
1882
  gt as P,
1798
- Q,
1799
- O as R,
1800
- Ve as S,
1801
- Gt as T,
1802
- rt as U,
1803
- Rt as V,
1804
- tt as W,
1805
- qt as X,
1806
- it as Y,
1807
- Wt as Z,
1808
- Ze as _,
1809
- St as a,
1810
- R as a0,
1811
- N as a1,
1812
- Tt as a2,
1813
- ht as a3,
1814
- Ut as b,
1815
- _t as c,
1816
- At as d,
1817
- kt as e,
1818
- vt as f,
1819
- Pt as g,
1820
- yt as h,
1821
- Ft as i,
1822
- xt as j,
1823
- Mt as k,
1824
- It as l,
1825
- qe as m,
1826
- Ke as n,
1827
- Ue as o,
1828
- $e as p,
1829
- wt as q,
1883
+ J as Q,
1884
+ it as R,
1885
+ st as S,
1886
+ qt as T,
1887
+ Ht as U,
1888
+ jt as V,
1889
+ Wt as W,
1890
+ ye as X,
1891
+ At as Y,
1892
+ Q as Z,
1893
+ X as _,
1894
+ It as a,
1895
+ lt as a0,
1896
+ vt as a1,
1897
+ ot as a2,
1898
+ ni as a3,
1899
+ ct as a4,
1900
+ si as a5,
1901
+ rt as a6,
1902
+ ee as a7,
1903
+ b as a8,
1904
+ G as a9,
1905
+ wt as aa,
1906
+ Tt as ab,
1907
+ Lt as b,
1908
+ St as c,
1909
+ Pt as d,
1910
+ Mt as e,
1911
+ Nt as f,
1912
+ Ct as g,
1913
+ Dt as h,
1914
+ Gt as i,
1915
+ Kt as j,
1916
+ Ut as k,
1917
+ Ot as l,
1918
+ ii as m,
1919
+ Xt as n,
1920
+ ze as o,
1921
+ tt as p,
1922
+ De as q,
1830
1923
  Me as r,
1831
- Dt as s,
1832
- Y as t,
1833
- w as u,
1834
- Lt as v,
1835
- Yt as w,
1836
- Ct as x,
1837
- z as y,
1838
- Nt as z
1924
+ Vt as s,
1925
+ Ke as t,
1926
+ Ft as u,
1927
+ Jt as v,
1928
+ Y as w,
1929
+ _ as x,
1930
+ ci as y,
1931
+ Qt as z
1839
1932
  };