@fxi/zartigl 0.8.0 → 0.9.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.
@@ -51,7 +51,7 @@ function fe(e, t) {
51
51
  }
52
52
  return e;
53
53
  }
54
- function Je() {
54
+ function je() {
55
55
  return Object.entries(X).map(([t, r]) => ({ id: t, ...r }));
56
56
  }
57
57
  function g(e, t, r) {
@@ -64,7 +64,7 @@ function g(e, t, r) {
64
64
  }
65
65
  return n;
66
66
  }
67
- function Qe(e, t, r) {
67
+ function Ke(e, t, r) {
68
68
  const n = e.createProgram();
69
69
  if (!n)
70
70
  throw new Error("Failed to create program");
@@ -75,7 +75,7 @@ function Qe(e, t, r) {
75
75
  }
76
76
  return e.deleteShader(a), e.deleteShader(i), n;
77
77
  }
78
- function Ze(e, t, r, n, a) {
78
+ function Je(e, t, r, n, a) {
79
79
  const i = e.createTexture();
80
80
  if (!i)
81
81
  throw new Error("Failed to create texture");
@@ -130,12 +130,12 @@ function me(e) {
130
130
  type: e.UNSIGNED_BYTE
131
131
  };
132
132
  }
133
- function et(e) {
133
+ function Qe(e) {
134
134
  if (typeof WebGL2RenderingContext > "u" || !(e instanceof WebGL2RenderingContext))
135
135
  throw new Error("zartigl requires WebGL2");
136
136
  return e;
137
137
  }
138
- function tt(e) {
138
+ function Ze(e) {
139
139
  const t = [];
140
140
  e.getExtension("EXT_color_buffer_float") ? t.push(
141
141
  { kind: "float32", internalFormat: e.RGBA32F, type: e.FLOAT },
@@ -154,7 +154,7 @@ function tt(e) {
154
154
  return r;
155
155
  return me(e);
156
156
  }
157
- function rt(e, t, r, n, a, i, s) {
157
+ function et(e, t, r, n, a, i, s) {
158
158
  const o = e.createTexture();
159
159
  if (!o)
160
160
  throw new Error("Failed to create texture");
@@ -170,10 +170,10 @@ function rt(e, t, r, n, a, i, s) {
170
170
  r
171
171
  ), e.bindTexture(e.TEXTURE_2D, null), o;
172
172
  }
173
- function nt(e, t, r) {
173
+ function tt(e, t, r) {
174
174
  e.activeTexture(e.TEXTURE0 + r), e.bindTexture(e.TEXTURE_2D, t);
175
175
  }
176
- function at(e, t) {
176
+ function rt(e, t) {
177
177
  const r = e.createFramebuffer();
178
178
  if (!r)
179
179
  throw new Error("Failed to create framebuffer");
@@ -185,7 +185,7 @@ function at(e, t) {
185
185
  0
186
186
  ), e.bindFramebuffer(e.FRAMEBUFFER, null), r;
187
187
  }
188
- function it(e) {
188
+ function nt(e) {
189
189
  const t = e.createBuffer();
190
190
  if (!t)
191
191
  throw new Error("Failed to create buffer");
@@ -205,19 +205,19 @@ const Ee = {
205
205
  0.6: "#f46d43",
206
206
  1: "#d53e4f"
207
207
  };
208
- function ot(e, t) {
208
+ function at(e, t) {
209
209
  const r = t != null ? fe(t) : Ee, n = document.createElement("canvas");
210
210
  n.width = 256, n.height = 1;
211
211
  const a = n.getContext("2d"), i = a.createLinearGradient(0, 0, 256, 0);
212
- for (const [o, c] of Object.entries(r))
213
- i.addColorStop(Number(o), c);
212
+ for (const [o, d] of Object.entries(r))
213
+ i.addColorStop(Number(o), d);
214
214
  a.fillStyle = i, a.fillRect(0, 0, 256, 1);
215
215
  const s = e.createTexture();
216
216
  if (!s)
217
217
  throw new Error("Failed to create color ramp texture");
218
218
  return e.bindTexture(e.TEXTURE_2D, s), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, n), e.bindTexture(e.TEXTURE_2D, null), s;
219
219
  }
220
- function st(e) {
220
+ function it(e) {
221
221
  const t = e.getExtension("WEBGL_debug_renderer_info");
222
222
  return {
223
223
  vendor: String(e.getParameter(e.VENDOR) ?? ""),
@@ -227,7 +227,7 @@ function st(e) {
227
227
  version: String(e.getParameter(e.VERSION) ?? "")
228
228
  };
229
229
  }
230
- function ct(e) {
230
+ function ot(e) {
231
231
  return {
232
232
  program: e.getParameter(e.CURRENT_PROGRAM),
233
233
  activeTexture: e.getParameter(e.ACTIVE_TEXTURE),
@@ -244,7 +244,7 @@ function ct(e) {
244
244
  ]
245
245
  };
246
246
  }
247
- function dt(e, t) {
247
+ function st(e, t) {
248
248
  e.useProgram(t.program), e.activeTexture(t.activeTexture), e.bindBuffer(e.ARRAY_BUFFER, t.arrayBuffer), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, t.elementBuffer), e.bindFramebuffer(e.FRAMEBUFFER, t.framebuffer), t.blend ? e.enable(e.BLEND) : e.disable(e.BLEND), t.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST), t.stencilTest ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST), e.viewport(t.viewport[0], t.viewport[1], t.viewport[2], t.viewport[3]), e.blendFunc(t.blendFunc[0], t.blendFunc[1]);
249
249
  }
250
250
  const Te = {
@@ -287,10 +287,10 @@ const Te = {
287
287
  pascal: "Pa",
288
288
  kelvin: "K"
289
289
  }, be = "⁰¹²³⁴⁵⁶⁷⁸⁹";
290
- function N(e) {
290
+ function C(e) {
291
291
  return e === 1 ? "" : [...String(e)].map((t) => be[Number(t)]).join("");
292
292
  }
293
- function ut(e) {
293
+ function ct(e) {
294
294
  const t = e?.trim() ?? "", r = Te[t.toLowerCase()];
295
295
  if (r != null)
296
296
  return r;
@@ -301,21 +301,21 @@ function ut(e) {
301
301
  const s = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(i);
302
302
  if (!s)
303
303
  return t.replace(/_/g, " ");
304
- const o = pe[s[1]] ?? s[1], c = Number(s[2] ?? 1);
305
- c < 0 ? a.push(o + N(-c)) : n.push(o + N(c));
304
+ const o = pe[s[1]] ?? s[1], d = Number(s[2] ?? 1);
305
+ d < 0 ? a.push(o + C(-d)) : n.push(o + C(d));
306
306
  }
307
307
  return [n.join(" ") || "1", ...a].join("/");
308
308
  }
309
- const L = 20, we = 600;
309
+ const N = 20, we = 600;
310
310
  function Re(e) {
311
311
  const t = Math.max(0, Math.min(1, e));
312
- return L * Math.pow(we / L, t);
312
+ return N * Math.pow(we / N, t);
313
313
  }
314
- function lt(e) {
314
+ function dt(e) {
315
315
  return Math.exp(-1 / Re(e));
316
316
  }
317
317
  const _e = 0.8, Ae = 120, Fe = 300;
318
- class ft {
318
+ class ut {
319
319
  constructor(t) {
320
320
  this.base = t, this.moving = !1, this.start = 0, this.duration = 0, this.from = t, this.to = t;
321
321
  }
@@ -333,7 +333,7 @@ class ft {
333
333
  return r === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * r * r * (3 - 2 * r);
334
334
  }
335
335
  }
336
- function ht(e) {
336
+ function lt(e) {
337
337
  if (e == null)
338
338
  return null;
339
339
  if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] >= e[1])
@@ -360,7 +360,7 @@ function S(e) {
360
360
  e
361
361
  );
362
362
  }
363
- function C(e) {
363
+ function L(e) {
364
364
  if (!e || typeof e != "object")
365
365
  throw new Error("Invalid GeoVideo manifest");
366
366
  const t = e;
@@ -386,8 +386,8 @@ function C(e) {
386
386
  const o = t.encoding;
387
387
  if (!o || o.bits !== 8 || o.colorSpace !== "bt709" || o.colorRange !== "limited" && o.colorRange !== "full")
388
388
  throw new Error("Invalid GeoVideo encoding");
389
- const c = m(o.codeMin, "encoding.codeMin"), d = m(o.codeMax, "encoding.codeMax");
390
- if (c < 0 || d > 255 || c >= d)
389
+ const d = m(o.codeMin, "encoding.codeMin"), c = m(o.codeMax, "encoding.codeMax");
390
+ if (d < 0 || c > 255 || d >= c)
391
391
  throw new Error("Invalid GeoVideo code range");
392
392
  let h = s.height;
393
393
  if (o.kind === "scalar-luma") {
@@ -431,13 +431,13 @@ function C(e) {
431
431
  }
432
432
  async function xe(e, t) {
433
433
  if (typeof e != "string")
434
- return C(e);
434
+ return L(e);
435
435
  const r = await fetch(e, { signal: t });
436
436
  if (!r.ok)
437
437
  throw new Error(
438
438
  `GeoVideo manifest request failed (${r.status}): ${e}`
439
439
  );
440
- const n = await r.json(), a = C(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
440
+ const n = await r.json(), a = L(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
441
441
  return {
442
442
  ...a,
443
443
  media: { ...a.media, url: new URL(a.media.url, i).href },
@@ -461,7 +461,7 @@ function _(e) {
461
461
  function ve(e) {
462
462
  return e.timeline.kind === "sample-sequence" ? e.timeline.values.length / e.media.durationSeconds : e.media.fps;
463
463
  }
464
- function mt(e, t) {
464
+ function ft(e, t) {
465
465
  return t / ve(e);
466
466
  }
467
467
  function ye(e, t) {
@@ -470,20 +470,20 @@ function ye(e, t) {
470
470
  if (e.timeline.kind === "sample-sequence") {
471
471
  const i = _(e);
472
472
  let s = 0;
473
- for (let c = 1; c < i.length; c += 1)
474
- Math.abs(i[c] - t) < Math.abs(i[s] - t) && (s = c);
473
+ for (let d = 1; d < i.length; d += 1)
474
+ Math.abs(i[d] - t) < Math.abs(i[s] - t) && (s = d);
475
475
  const o = e.media.durationSeconds / i.length;
476
476
  return s * o + Math.min(o / 2, 0.5 / e.media.fps);
477
477
  }
478
478
  const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime();
479
479
  return Math.max(0, Math.min(1, (t - r) / (n - r))) * O(e);
480
480
  }
481
- function Et(e, t) {
481
+ function ht(e, t) {
482
482
  if (e.timeline.kind === "snapshot-loop")
483
483
  return new Date(e.timeline.date).getTime();
484
484
  if (e.timeline.kind === "sample-sequence") {
485
- const s = _(e), o = e.media.durationSeconds / s.length, c = Math.floor((t + 0.25 / e.media.fps) / o);
486
- return s[Math.max(0, Math.min(s.length - 1, c))];
485
+ const s = _(e), o = e.media.durationSeconds / s.length, d = Math.floor((t + 0.25 / e.media.fps) / o);
486
+ return s[Math.max(0, Math.min(s.length - 1, d))];
487
487
  }
488
488
  const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime(), a = O(e), i = a > 0 ? Math.max(0, Math.min(1, t / a)) : 0;
489
489
  return r + (n - r) * i;
@@ -556,18 +556,31 @@ function U(e, t) {
556
556
  (r) => e.addEventListener(t, () => r(), { once: !0 })
557
557
  );
558
558
  }
559
- const Me = 250;
560
- function De(e) {
559
+ const De = 250;
560
+ function Me(e) {
561
561
  return "requestVideoFrameCallback" in e ? Promise.race([
562
562
  new Promise(
563
563
  (t) => e.requestVideoFrameCallback(() => t())
564
564
  ),
565
- new Promise((t) => setTimeout(t, Me))
565
+ new Promise((t) => setTimeout(t, De))
566
566
  ]) : Promise.resolve();
567
567
  }
568
568
  class q {
569
569
  constructor(t, r, n = {}) {
570
- this.reader = new Ue(), this.video = null, this.mask = 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 = t, this.planes = r, this.cacheSize = Math.max(1, n.cacheSize ?? 3), this.width = t.media.width, this.height = t.media.height / r, this.times = Float64Array.from(_(t));
570
+ this.reader = new Ue(), 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 = t, this.planes = r, this.cacheSize = Math.max(1, n.cacheSize ?? 3), this.width = t.media.width, this.height = t.media.height / r, this.times = Float64Array.from(_(t));
571
+ }
572
+ /** Static validity, one 8-bit value per grid cell; null before init(). */
573
+ get mask() {
574
+ return this.maskCodes;
575
+ }
576
+ /** Luma codes of the presented frame, or null when it is blank. */
577
+ readCodes(t, r) {
578
+ const n = this.reader.read(t, this.width, r);
579
+ return V(n) ? null : Se(n, this.manifest.encoding.colorRange);
580
+ }
581
+ /** True when the decoder exposed no pixels; reads back one row only. */
582
+ isBlank(t) {
583
+ return V(this.reader.read(t, this.width, 1));
571
584
  }
572
585
  init() {
573
586
  return this.initPromise ??= this.load().catch((t) => {
@@ -581,7 +594,7 @@ class q {
581
594
  }
582
595
  /** Release the video element and GL context; a later init() reloads them. */
583
596
  release() {
584
- this.cancelAll(), this.frames.clear(), this.video && (this.video.removeAttribute("src"), this.video.load()), this.video = null, this.mask = null, this.presented = !1, this.primed = !1, this.initPromise = null, this.reader.release();
597
+ this.cancelAll(), this.frames.clear(), this.video && (this.video.removeAttribute("src"), this.video.load()), this.video = null, this.maskCodes = null, this.presented = !1, this.primed = !1, this.initPromise = null, this.reader.release();
585
598
  }
586
599
  /**
587
600
  * One decode per time step, cached and shared by concurrent requests.
@@ -631,7 +644,7 @@ class q {
631
644
  }
632
645
  async load() {
633
646
  const [t] = await Promise.all([this.loadMask(), this.loadVideo()]);
634
- this.mask = t;
647
+ this.maskCodes = t;
635
648
  }
636
649
  async loadMask() {
637
650
  const { url: t, width: r, height: n } = this.manifest.mask, a = new Image();
@@ -670,7 +683,7 @@ class q {
670
683
  async presentFrame(t, r) {
671
684
  if (this.presented && Math.abs(t.currentTime - r) <= 1e-3 && !t.seeking)
672
685
  return;
673
- const n = De(t), a = U(t, "seeked");
686
+ const n = Me(t), a = U(t, "seeked");
674
687
  t.currentTime = r, await a, t.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([U(t, "loadeddata"), U(t, "canplay")]), await n, this.presented = !0;
675
688
  }
676
689
  /**
@@ -687,68 +700,86 @@ class q {
687
700
  t.pause(), this.presented = !1;
688
701
  }
689
702
  /**
690
- * Seek, read back and decode one step. `signal` aborts it between steps;
691
- * a seek already started completes first, keeping the queue serial.
703
+ * Seek and capture one step. `signal` aborts it between steps; a seek
704
+ * already started completes first, keeping the queue serial.
692
705
  */
693
706
  async decode(t, r) {
694
707
  if (r.aborted)
695
708
  throw f();
696
709
  await this.init();
697
- const n = this.video, a = this.mask;
710
+ const n = this.video, a = this.maskCodes;
698
711
  if (r.aborted || !n || !a)
699
712
  throw f();
700
713
  const i = ye(this.manifest, this.times[t]);
701
714
  if (await this.presentFrame(n, i), r.aborted || n !== this.video)
702
715
  throw f();
703
716
  const s = this.height * this.planes;
704
- let o = this.reader.read(n, this.width, s);
705
- if (V(o) && !this.primed) {
717
+ let o = await this.capture(n, s, a);
718
+ if (o === null && !this.primed) {
706
719
  if (await this.primeDecoder(n), await this.presentFrame(n, i), r.aborted || n !== this.video)
707
720
  throw f();
708
- o = this.reader.read(n, this.width, s);
721
+ o = await this.capture(n, s, a);
709
722
  }
710
- if (V(o))
723
+ if (o === null)
711
724
  throw new Error("GeoVideo frame could not be read back from the decoder");
712
- const c = Se(o, this.manifest.encoding.colorRange);
713
- return this.decodeCodes(c, a, this.manifest.mask.threshold);
725
+ return o;
726
+ }
727
+ }
728
+ function mt(e) {
729
+ return {
730
+ codeRange: [e.codeMin / 255, e.codeMax / 255],
731
+ valueRange: [e.valueMin, e.valueMax]
732
+ };
733
+ }
734
+ class ke extends q {
735
+ constructor(t, r = {}) {
736
+ if (t.encoding.kind !== "scalar-luma")
737
+ throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
738
+ super(t, 1, r);
739
+ }
740
+ async capture(t) {
741
+ return this.isBlank(t) ? null : createImageBitmap(t, {
742
+ premultiplyAlpha: "none",
743
+ colorSpaceConversion: "none"
744
+ });
714
745
  }
715
746
  }
716
747
  function Pe(e, t) {
717
748
  let r = (e - t.codeMin) / (t.codeMax - t.codeMin) * 2 - 1;
718
749
  return r = Math.max(-1, Math.min(1, r)), t.transfer === "sqrt" && (r = Math.sign(r) * r * r), r * t.valueDomain;
719
750
  }
720
- function ke(e, t, r, n) {
751
+ function Ge(e, t, r, n) {
721
752
  const a = t.length;
722
753
  if (e.length !== 2 * a)
723
754
  throw new Error(
724
755
  `GeoVideo vector frame has ${e.length} codes, expected ${2 * a}`
725
756
  );
726
757
  const i = new Float32Array(256);
727
- for (let d = 0; d < 256; d++)
728
- i[d] = Pe(d, n);
729
- const s = r * 255, o = new Float32Array(a), c = new Float32Array(a);
730
- for (let d = 0; d < a; d++) {
731
- const h = t[d] >= s;
732
- o[d] = h ? i[e[d]] : NaN, c[d] = h ? i[e[a + d]] : NaN;
758
+ for (let c = 0; c < 256; c++)
759
+ i[c] = Pe(c, n);
760
+ const s = r * 255, o = new Float32Array(a), d = new Float32Array(a);
761
+ for (let c = 0; c < a; c++) {
762
+ const h = t[c] >= s;
763
+ o[c] = h ? i[e[c]] : NaN, d[c] = h ? i[e[a + c]] : NaN;
733
764
  }
734
- return { u: o, v: c };
765
+ return { u: o, v: d };
735
766
  }
736
- class Ge extends q {
767
+ class Ie extends q {
737
768
  constructor(t, r = {}) {
738
769
  if (t.encoding.kind !== "vector-luma")
739
770
  throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
740
771
  super(t, 2, r), this.encoding = t.encoding;
741
- const [n, a, i, s] = t.bounds, o = (i - n) / this.width, c = (s - a) / this.height;
772
+ const [n, a, i, s] = t.bounds, o = (i - n) / this.width, d = (s - a) / this.height;
742
773
  this.coords = {
743
774
  time: this.times,
744
775
  vertical: new Float32Array([0]),
745
776
  latitude: Float32Array.from(
746
777
  { length: this.height },
747
- (d, h) => s - (h + 0.5) * c
778
+ (c, h) => s - (h + 0.5) * d
748
779
  ),
749
780
  longitude: Float32Array.from(
750
781
  { length: this.width },
751
- (d, h) => n + (h + 0.5) * o
782
+ (c, h) => n + (h + 0.5) * o
752
783
  )
753
784
  };
754
785
  }
@@ -797,46 +828,19 @@ class Ge extends q {
797
828
  url: this.manifest.media.url
798
829
  };
799
830
  }
800
- decodeCodes(t, r, n) {
801
- return ke(t, r, n, this.encoding);
802
- }
803
- }
804
- function Ie(e, t) {
805
- const r = Math.max(
806
- 0,
807
- Math.min(
808
- 1,
809
- (e - t.codeMin) / (t.codeMax - t.codeMin)
810
- )
811
- );
812
- return t.valueMin + r * (t.valueMax - t.valueMin);
813
- }
814
- function ge(e, t, r, n) {
815
- const a = t.length;
816
- if (e.length !== a)
817
- throw new Error(
818
- `GeoVideo scalar frame has ${e.length} codes, expected ${a}`
819
- );
820
- const i = new Float32Array(256);
821
- for (let c = 0; c < 256; c++)
822
- i[c] = Ie(c, n);
823
- const s = r * 255, o = new Float32Array(a);
824
- for (let c = 0; c < a; c++)
825
- o[c] = t[c] >= s ? i[e[c]] : NaN;
826
- return o;
827
- }
828
- class Ne extends q {
829
- constructor(t, r = {}) {
830
- if (t.encoding.kind !== "scalar-luma")
831
- throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
832
- super(t, 1, r), this.encoding = t.encoding;
833
- }
834
- decodeCodes(t, r, n) {
835
- return ge(t, r, n, this.encoding);
831
+ /** u/v codes are written into luma: read back, then decoded on the CPU. */
832
+ async capture(t, r, n) {
833
+ const a = this.readCodes(t, r);
834
+ return a ? Ge(
835
+ a,
836
+ n,
837
+ this.manifest.mask.threshold,
838
+ this.encoding
839
+ ) : null;
836
840
  }
837
841
  }
838
- function Le(e, t, r = {}) {
839
- const [n, a] = r.range ?? [-1 / 0, 1 / 0], i = [...e].sort((o, c) => o.start - c.start), s = i.find(
842
+ function ge(e, t, r = {}) {
843
+ const [n, a] = r.range ?? [-1 / 0, 1 / 0], i = [...e].sort((o, d) => o.start - d.start), s = i.find(
840
844
  (o) => o.start > t && o.start <= a
841
845
  ) ?? (r.loop ? i.find(
842
846
  (o) => o.end >= n && o.start <= a
@@ -851,7 +855,7 @@ function Ce(e, t) {
851
855
  }
852
856
  return r;
853
857
  }
854
- function Ve(e) {
858
+ function Ne(e) {
855
859
  return {
856
860
  width: e.mask.width,
857
861
  height: e.mask.height,
@@ -859,11 +863,11 @@ function Ve(e) {
859
863
  rowOrder: "north-to-south"
860
864
  };
861
865
  }
862
- function Be(e, t = {}) {
863
- return e.encoding.kind === "vector-luma" ? new Ge(e, t) : new Ne(e, t);
866
+ function Le(e, t = {}) {
867
+ return e.encoding.kind === "vector-luma" ? new Ie(e, t) : new ke(e, t);
864
868
  }
865
- const Xe = 3, Oe = 3, qe = 0.6, $e = 1.5;
866
- function We(e, t) {
869
+ const Ve = 3, Be = 3, Xe = 0.6, Oe = 1.5;
870
+ function qe(e, t) {
867
871
  const r = e.length - 1;
868
872
  if (t <= e[0])
869
873
  return { step: 0, fraction: 0 };
@@ -876,7 +880,7 @@ function We(e, t) {
876
880
  }
877
881
  return { step: n, fraction: (t - e[n]) / (e[a] - e[n]) };
878
882
  }
879
- function He(e) {
883
+ function $e(e) {
880
884
  const t = new AbortController();
881
885
  if (!e)
882
886
  return { controller: t, unlink: () => {
@@ -887,14 +891,14 @@ function He(e) {
887
891
  unlink: () => e.removeEventListener("abort", r)
888
892
  };
889
893
  }
890
- class Tt {
894
+ class Et {
891
895
  constructor(t) {
892
896
  this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = t.id, this.chunks = t.chunks.filter(
893
897
  (r) => Number.isFinite(r.start) && Number.isFinite(r.end) && r.end >= r.start
894
- ).sort((r, n) => r.start - n.start), this.maxOpenChunks = Math.max(2, t.maxOpenChunks ?? Xe), this.frameCacheSize = Math.max(
898
+ ).sort((r, n) => r.start - n.start), this.maxOpenChunks = Math.max(2, t.maxOpenChunks ?? Ve), this.frameCacheSize = Math.max(
895
899
  1,
896
- t.frameCacheSize ?? Oe
897
- ), this.prefetchAt = t.prefetchAt ?? qe, this.maxGap = t.maxGap, this.loadManifest = t.loadManifest ?? xe, this.createFrameSource = t.createFrameSource ?? ((r, n) => Be(
900
+ t.frameCacheSize ?? Be
901
+ ), this.prefetchAt = t.prefetchAt ?? Xe, this.maxGap = t.maxGap, this.loadManifest = t.loadManifest ?? xe, this.createFrameSource = t.createFrameSource ?? ((r, n) => Le(
898
902
  r,
899
903
  n
900
904
  ));
@@ -930,13 +934,13 @@ class Tt {
930
934
  const i = this.chunkIndexAt(t);
931
935
  if (i < 0)
932
936
  return null;
933
- const s = [], { controller: o, unlink: c } = He(n);
937
+ const s = [], { controller: o, unlink: d } = $e(n);
934
938
  try {
935
- const d = this.acquire(this.chunks[i], s), h = await R(d.ready, o.signal), { times: u } = h;
939
+ const c = this.acquire(this.chunks[i], s), h = await R(c.ready, o.signal), { times: u } = h;
936
940
  let E;
937
941
  if (t <= u[u.length - 1]) {
938
- const { step: p, fraction: w } = We(u, t);
939
- E = a === "discrete" || w === 0 ? [d, p, d, p, 0] : [d, p, d, p + 1, w];
942
+ const { step: p, fraction: w } = qe(u, t);
943
+ E = a === "discrete" || w === 0 ? [c, p, c, p, 0] : [c, p, c, p + 1, w];
940
944
  } else {
941
945
  const p = this.chunks[i + 1];
942
946
  if (!p)
@@ -944,26 +948,26 @@ class Tt {
944
948
  const w = this.acquire(p, s), G = await R(w.ready, o.signal), A = u.length - 1, v = u[A], y = G.times[0];
945
949
  if (y - v > this.gapLimit(u, G.times))
946
950
  return null;
947
- E = a === "discrete" ? [d, A, d, A, 0] : t >= y ? [w, 0, w, 0, 0] : [d, A, w, 0, (t - v) / (y - v)];
951
+ E = a === "discrete" ? [c, A, c, A, 0] : t >= y ? [w, 0, w, 0, 0] : [c, A, w, 0, (t - v) / (y - v)];
948
952
  }
949
- const [l, T, b, D, $] = E, P = l === b && T === D, k = [this.frame(l, T, o.signal)];
950
- P || k.push(this.frame(b, D, o.signal));
953
+ const [l, T, b, M, $] = E, k = l === b && T === M, P = [this.frame(l, T, o.signal)];
954
+ k || P.push(this.frame(b, M, o.signal));
951
955
  let x;
952
956
  try {
953
- x = await Promise.all(k);
957
+ x = await Promise.all(P);
954
958
  } catch (p) {
955
959
  throw o.abort(), p;
956
960
  }
957
961
  return this.prefetchAfter(i, t), {
958
962
  time: t,
959
963
  a: x[0],
960
- b: x[P ? 0 : 1],
964
+ b: x[k ? 0 : 1],
961
965
  mix: $
962
966
  };
963
967
  } finally {
964
- c();
965
- for (const d of s)
966
- d.users--;
968
+ d();
969
+ for (const c of s)
970
+ c.users--;
967
971
  this.trim();
968
972
  }
969
973
  }
@@ -997,7 +1001,7 @@ class Tt {
997
1001
  t.length > 1 ? t[t.length - 1] - t[t.length - 2] : 0,
998
1002
  r.length > 1 ? r[1] - r[0] : 0
999
1003
  ], a = Math.max(...n);
1000
- return a > 0 ? a * $e : -1 / 0;
1004
+ return a > 0 ? a * Oe : -1 / 0;
1001
1005
  }
1002
1006
  prefetchAfter(t, r) {
1003
1007
  const n = this.chunks[t], a = this.chunks[t + 1], i = n.end - n.start, s = i > 0 ? (r - n.start) / i : 1;
@@ -1034,7 +1038,7 @@ class Tt {
1034
1038
  return n.opened = {
1035
1039
  manifest: a,
1036
1040
  times: Float64Array.from(_(a)),
1037
- grid: Ve(a),
1041
+ grid: Ne(a),
1038
1042
  source: this.createFrameSource(a, {
1039
1043
  cacheSize: this.frameCacheSize
1040
1044
  })
@@ -1052,13 +1056,13 @@ class Tt {
1052
1056
  );
1053
1057
  if (t.released)
1054
1058
  throw f();
1055
- const c = await o.frame(r, { signal: n });
1059
+ const d = await o.frame(r, { signal: n });
1056
1060
  return {
1057
1061
  key: `${this.id}/${t.chunk.key}/${r}`,
1058
1062
  chunk: t.chunk,
1059
1063
  step: r,
1060
1064
  time: i[r],
1061
- data: c,
1065
+ data: d,
1062
1066
  grid: s,
1063
1067
  manifest: a
1064
1068
  };
@@ -1076,7 +1080,7 @@ class Tt {
1076
1080
  t.released = !0, t.prefetch?.abort(), t.prefetch = null, t.opened?.source.release(), t.opened = null, this.open.get(t.chunk.key) === t && this.open.delete(t.chunk.key);
1077
1081
  }
1078
1082
  }
1079
- function M(e) {
1083
+ function D(e) {
1080
1084
  const { start: t, end: r } = e.temporal ?? {};
1081
1085
  return {
1082
1086
  source: e,
@@ -1084,27 +1088,27 @@ function M(e) {
1084
1088
  end: Date.parse(r ?? t ?? "")
1085
1089
  };
1086
1090
  }
1087
- function pt(e, t, r = {}) {
1088
- const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(M), a = Le(
1091
+ function Tt(e, t, r = {}) {
1092
+ const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(D), a = ge(
1089
1093
  n,
1090
1094
  Date.parse(t.temporal?.end ?? ""),
1091
1095
  r
1092
1096
  );
1093
1097
  return a ? { source: a.chunk.source, time: a.time } : null;
1094
1098
  }
1095
- function bt(e, t) {
1096
- return Ce(M(e), t.map(M))?.source ?? null;
1099
+ function pt(e, t) {
1100
+ return Ce(D(e), t.map(D))?.source ?? null;
1097
1101
  }
1098
- function wt(e) {
1102
+ function bt(e) {
1099
1103
  return e.type === "geovideo" && typeof e.indexUrl == "string";
1100
1104
  }
1101
- function Rt(e, t) {
1105
+ function wt(e, t) {
1102
1106
  return e.id === t.id && (e.type !== "geovideo" || t.type !== "geovideo" || e.manifestUrl === t.manifestUrl);
1103
1107
  }
1104
1108
  function B(e) {
1105
1109
  return typeof e == "string" && Number.isFinite(Date.parse(e));
1106
1110
  }
1107
- function Ye(e) {
1111
+ function We(e) {
1108
1112
  const t = e;
1109
1113
  if (!t || t.schemaVersion !== 1 || t.type !== "geovideo-index" || !Array.isArray(t.chunks))
1110
1114
  throw new Error("Unsupported GeoVideo index");
@@ -1113,19 +1117,19 @@ function Ye(e) {
1113
1117
  throw new Error("Invalid GeoVideo index chunk");
1114
1118
  return t;
1115
1119
  }
1116
- async function _t(e, t) {
1120
+ async function Rt(e, t) {
1117
1121
  const r = await fetch(e, { signal: t });
1118
1122
  if (!r.ok)
1119
1123
  throw new Error(
1120
1124
  `GeoVideo index request failed (${r.status}): ${e}`
1121
1125
  );
1122
- return Ye(await r.json());
1126
+ return We(await r.json());
1123
1127
  }
1124
- function ze(e) {
1128
+ function He(e) {
1125
1129
  return typeof document < "u" ? new URL(e, document.baseURI).href : e;
1126
1130
  }
1127
- function je(e, t) {
1128
- const r = ze(t);
1131
+ function Ye(e, t) {
1132
+ const r = He(t);
1129
1133
  return e.chunks.map((n) => ({
1130
1134
  key: n.key,
1131
1135
  manifestUrl: new URL(n.manifestUrl, r).href,
@@ -1135,15 +1139,15 @@ function je(e, t) {
1135
1139
  ...n.provisional ? { provisional: !0 } : {}
1136
1140
  }));
1137
1141
  }
1138
- function Ke(e, t, r) {
1142
+ function ze(e, t, r) {
1139
1143
  if (t.sourceId !== e.id || t.catalogEntryId !== r.id)
1140
1144
  throw new Error(
1141
1145
  `GeoVideo index identity does not match catalog entry/source: ${e.id}`
1142
1146
  );
1143
1147
  }
1144
- function At(e, t, r) {
1145
- Ke(e, t, r);
1146
- const n = je(t, e.indexUrl);
1148
+ function _t(e, t, r) {
1149
+ ze(e, t, r);
1150
+ const n = Ye(t, e.indexUrl);
1147
1151
  return t.chunks.map(
1148
1152
  (a, i) => ({
1149
1153
  id: e.id,
@@ -1161,49 +1165,50 @@ function At(e, t, r) {
1161
1165
  );
1162
1166
  }
1163
1167
  export {
1164
- pt as A,
1165
- _t as B,
1166
- At as C,
1167
- C as D,
1168
- Tt as E,
1169
- q as F,
1170
- Ge as G,
1171
- Ne as H,
1172
- Ke as I,
1173
- Be as J,
1174
- g as K,
1175
- Re as L,
1176
- Ve as M,
1177
- je as N,
1178
- Le as O,
1179
- bt as P,
1180
- Ce as Q,
1181
- Ye as R,
1182
- ft as T,
1183
- it as a,
1184
- ot as b,
1185
- Qe as c,
1186
- tt as d,
1187
- rt as e,
1188
- at as f,
1189
- st as g,
1190
- Ze as h,
1191
- nt as i,
1192
- et as j,
1193
- dt as k,
1194
- lt as l,
1168
+ bt as A,
1169
+ Tt as B,
1170
+ Rt as C,
1171
+ _t as D,
1172
+ L as E,
1173
+ Et as F,
1174
+ Ie as G,
1175
+ q as H,
1176
+ ke as I,
1177
+ ze as J,
1178
+ Le as K,
1179
+ g as L,
1180
+ Re as M,
1181
+ Ne as N,
1182
+ Ye as O,
1183
+ ge as P,
1184
+ pt as Q,
1185
+ Ce as R,
1186
+ We as S,
1187
+ ut as T,
1188
+ nt as a,
1189
+ at as b,
1190
+ Ke as c,
1191
+ Ze as d,
1192
+ et as e,
1193
+ rt as f,
1194
+ it as g,
1195
+ Je as h,
1196
+ tt as i,
1197
+ Qe as j,
1198
+ st as k,
1199
+ dt as l,
1195
1200
  xe as m,
1196
- ye as n,
1197
- fe as o,
1198
- Et as p,
1199
- _ as q,
1201
+ mt as n,
1202
+ ye as o,
1203
+ fe as p,
1204
+ ht as q,
1200
1205
  me as r,
1201
- ct as s,
1202
- Rt as t,
1203
- mt as u,
1204
- ht as v,
1205
- ve as w,
1206
- ut as x,
1207
- Je as y,
1208
- wt as z
1206
+ ot as s,
1207
+ _ as t,
1208
+ wt as u,
1209
+ lt as v,
1210
+ ft as w,
1211
+ ve as x,
1212
+ ct as y,
1213
+ je as z
1209
1214
  };