@vidispine/vdt-js 24.4.0-pre.2 → 25.3.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,16 +5,16 @@ const pt = (e, t) => t ? pt(t, e % t) : e, J = (e) => {
5
5
  const { width: t, height: s } = e || {};
6
6
  if (t === void 0 || s === void 0)
7
7
  return;
8
- const i = pt(t, s);
9
- let r = t / i, n = s / i;
10
- return r > 21 && (n = 1, r = (t / s).toFixed(2)), [r, n].join(":");
11
- }, F = (e) => Object.fromEntries((e == null ? void 0 : e.map(({ key: t, value: s }) => [t, s])) || []), Gt = (e, t, s) => {
12
- let i;
8
+ const n = pt(t, s);
9
+ let r = t / n, i = s / n;
10
+ return r > 21 && (i = 1, r = (t / s).toFixed(2)), [r, i].join(":");
11
+ }, M = (e) => Object.fromEntries((e == null ? void 0 : e.map(({ key: t, value: s }) => [t, s])) || []), Gt = (e, t, s) => {
12
+ let n;
13
13
  return (r) => {
14
14
  const o = () => {
15
- i = null, s || e.apply(void 0, r);
16
- }, a = s && !i;
17
- clearTimeout(i), i = setTimeout(o, t), a && e.apply(void 0, r);
15
+ n = null, s || e.apply(void 0, r);
16
+ }, a = s && !n;
17
+ clearTimeout(n), n = setTimeout(o, t), a && e.apply(void 0, r);
18
18
  };
19
19
  };
20
20
  function zt() {
@@ -321,7 +321,7 @@ const os = {
321
321
  const t = (s) => Kt(s) && s.value === void 0 && !!Object.entries(e);
322
322
  return Array.isArray(e) ? e.every(It) : t(e);
323
323
  }, Jt = (e, t) => e + (t.length > 1 ? "s" : ""), Ot = (e, t) => {
324
- const s = e.filter((i) => !t.includes(i));
324
+ const s = e.filter((n) => !t.includes(n));
325
325
  if (s.length)
326
326
  throw Error(
327
327
  `Unsupported ${Jt("key", s)} (${s.join(", ")})`
@@ -344,8 +344,8 @@ const os = {
344
344
  Ot(Object.keys(e), Ht);
345
345
  const t = X(e == null ? void 0 : e.value);
346
346
  if (t === void 0) {
347
- const { value: s, ...i } = e;
348
- return i;
347
+ const { value: s, ...n } = e;
348
+ return n;
349
349
  }
350
350
  return {
351
351
  ...e,
@@ -359,43 +359,43 @@ const os = {
359
359
  return { value: [...Array.isArray(t) ? t : [t]] };
360
360
  }, Rt = (e) => {
361
361
  const t = [], s = [];
362
- let i = {};
363
- return Object.entries(e || {}).forEach(([r, n]) => {
362
+ let n = {};
363
+ return Object.entries(e || {}).forEach(([r, i]) => {
364
364
  if (Yt.includes(r))
365
- i = { ...i, [r]: n };
366
- else if (At(n))
365
+ n = { ...n, [r]: i };
366
+ else if (At(i))
367
367
  try {
368
- s.push({ name: r, ...Qt(n) });
368
+ s.push({ name: r, ...Qt(i) });
369
369
  } catch (o) {
370
370
  throw Error(o.message + (r ? ` for field "${r}"` : ""));
371
371
  }
372
- else if (It(n))
373
- (Array.isArray(n) ? n : [n]).forEach((o) => {
372
+ else if (It(i))
373
+ (Array.isArray(i) ? i : [i]).forEach((o) => {
374
374
  t.push({ name: r, ...Rt(o) });
375
375
  });
376
376
  else
377
377
  throw Error(`Unhandled value for "${r}"`);
378
378
  }), {
379
- ...i,
379
+ ...n,
380
380
  ...t.length > 0 ? { group: t } : {},
381
381
  ...s.length > 0 ? { field: s } : {}
382
382
  };
383
383
  }, Zt = (e) => {
384
- const { start: t = "-INF", end: s = "+INF", base: i = void 0, ...r } = e, { group: n, field: o } = Rt(r);
384
+ const { start: t = "-INF", end: s = "+INF", base: n = void 0, ...r } = e, { group: i, field: o } = Rt(r);
385
385
  return {
386
- ...n ? { group: n } : {},
386
+ ...i ? { group: i } : {},
387
387
  ...o ? { field: o } : {},
388
388
  start: t.toString(),
389
389
  end: s.toString(),
390
- ...i ? { base: i } : {}
390
+ ...n ? { base: n } : {}
391
391
  };
392
392
  }, ds = (e) => ({
393
393
  timespan: (Array.isArray(e) ? e : [e || {}]).map((t) => Zt(t))
394
394
  }), te = (e, t) => {
395
- var r, n;
396
- const [s] = ((r = e == null ? void 0 : e.start) == null ? void 0 : r.split("@")) || [], [i] = ((n = t == null ? void 0 : t.start) == null ? void 0 : n.split("@")) || [];
397
- return Number(s) < Number(i) ? -1 : Number(s) > Number(i) ? 1 : 0;
398
- }, D = (e) => Array.isArray(e) ? e : e && [e] || [], at = (e) => Array.isArray(e) ? e.pop() : e, ee = (e) => (e == null ? void 0 : e.every((t) => typeof t == "string")) || !1, yt = {
395
+ var r, i;
396
+ const [s] = ((r = e == null ? void 0 : e.start) == null ? void 0 : r.split("@")) || [], [n] = ((i = t == null ? void 0 : t.start) == null ? void 0 : i.split("@")) || [];
397
+ return Number(s) < Number(n) ? -1 : Number(s) > Number(n) ? 1 : 0;
398
+ }, F = (e) => Array.isArray(e) ? e : e && [e] || [], at = (e) => Array.isArray(e) ? e.pop() : e, ee = (e) => (e == null ? void 0 : e.every((t) => typeof t == "string")) || !1, yt = {
399
399
  includeValueAttributes: !1
400
400
  };
401
401
  function se(e, t) {
@@ -405,12 +405,12 @@ function se(e, t) {
405
405
  };
406
406
  if (s === !1)
407
407
  return e == null ? void 0 : e.value;
408
- const { value: i, ...r } = e;
408
+ const { value: n, ...r } = e;
409
409
  return { ...s === !0 && r || Array.isArray(s) && Object.fromEntries(
410
410
  Object.entries(r).filter(
411
411
  ([o]) => s.includes(o)
412
412
  )
413
- ) || {}, value: i };
413
+ ) || {}, value: n };
414
414
  }
415
415
  const St = {
416
416
  ...yt,
@@ -418,21 +418,21 @@ const St = {
418
418
  arrayOnSingleValue: !0
419
419
  };
420
420
  function re(e, t) {
421
- const { joinValue: s, arrayOnSingleValue: i, ...r } = {
421
+ const { joinValue: s, arrayOnSingleValue: n, ...r } = {
422
422
  ...St,
423
423
  ...t || {}
424
- }, n = e == null ? void 0 : e.map((o) => se(o, r));
425
- return ee(n) && s ? n == null ? void 0 : n.join(s) : i !== !0 && (n == null ? void 0 : n.length) <= 1 ? n == null ? void 0 : n[0] : n;
424
+ }, i = e == null ? void 0 : e.map((o) => se(o, r));
425
+ return ee(i) && s ? i == null ? void 0 : i.join(s) : n !== !0 && (i == null ? void 0 : i.length) <= 1 ? i == null ? void 0 : i[0] : i;
426
426
  }
427
427
  const vt = {
428
428
  includeFieldAttributes: !1,
429
429
  ...St
430
- }, ie = (e, t) => {
431
- const { includeFieldAttributes: s, ...i } = {
430
+ }, ne = (e, t) => {
431
+ const { includeFieldAttributes: s, ...n } = {
432
432
  ...vt,
433
433
  ...t || {}
434
- }, { value: r, ...n } = e, o = re(r, i), a = s === !0 && n || Array.isArray(s) && Object.fromEntries(
435
- Object.entries(n).filter(
434
+ }, { value: r, ...i } = e, o = re(r, n), a = s === !0 && i || Array.isArray(s) && Object.fromEntries(
435
+ Object.entries(i).filter(
436
436
  ([c]) => s.includes(c)
437
437
  )
438
438
  ) || {};
@@ -442,48 +442,48 @@ const vt = {
442
442
  fieldAsList: !1,
443
443
  arrayOnSingleField: !1,
444
444
  overrideField: void 0
445
- }, Mt = (e, t) => {
445
+ }, Dt = (e, t) => {
446
446
  const s = {
447
447
  ...G,
448
448
  ...t || {}
449
- }, { fieldAsList: i, arrayOnSingleField: r, overrideField: n } = s, o = n === !0 && i === !1, a = {};
449
+ }, { fieldAsList: n, arrayOnSingleField: r, overrideField: i } = s, o = i === !0 && n === !1, a = {};
450
450
  return e == null || e.forEach((c) => {
451
- const { name: l } = c, u = ie(c, s), f = r === !0 ? D(u) : u, m = a[l];
452
- m ? o ? a[l] = u : a[l] = [D(m), D(u)].flat() : a[l] = f;
453
- }), i === !0 ? Object.values(a).flat() : a;
454
- }, Dt = {
451
+ const { name: l } = c, u = ne(c, s), f = r === !0 ? F(u) : u, m = a[l];
452
+ m ? o ? a[l] = u : a[l] = [F(m), F(u)].flat() : a[l] = f;
453
+ }), n === !0 ? Object.values(a).flat() : a;
454
+ }, Ft = {
455
455
  ...G,
456
456
  includeGroupAttributes: !1,
457
457
  groupAsList: !1,
458
458
  arrayOnSingleGroup: !1,
459
459
  overrideGroup: void 0
460
- }, ne = (e, t) => {
460
+ }, ie = (e, t) => {
461
461
  const s = {
462
- ...Dt,
462
+ ...Ft,
463
463
  ...t || {}
464
- }, { includeGroupAttributes: i } = s, r = Object.fromEntries(
464
+ }, { includeGroupAttributes: n } = s, r = Object.fromEntries(
465
465
  Object.entries(s).filter(
466
466
  ([f]) => Object.keys(G).includes(f)
467
467
  )
468
- ), { field: n, group: o, ...a } = e, c = n && Mt(n, r), l = o && Ft(o, s);
468
+ ), { field: i, group: o, ...a } = e, c = i && Dt(i, r), l = o && Mt(o, s);
469
469
  return {
470
- ...i === !0 && a || Array.isArray(i) && Object.fromEntries(
470
+ ...n === !0 && a || Array.isArray(n) && Object.fromEntries(
471
471
  Object.entries(a).filter(
472
- ([f]) => i.includes(f)
472
+ ([f]) => n.includes(f)
473
473
  )
474
474
  ) || {},
475
475
  ...r != null && r.fieldAsList ? c && { field: c } || {} : c,
476
476
  ...s != null && s.groupAsList ? l && { group: l } || {} : l
477
477
  };
478
- }, Q = Dt, Ft = (e, t) => {
479
- const s = { ...Q, ...t || {} }, { groupAsList: i, arrayOnSingleGroup: r, overrideGroup: n } = s, o = n === !0 && i === !1, a = {};
478
+ }, Q = Ft, Mt = (e, t) => {
479
+ const s = { ...Q, ...t || {} }, { groupAsList: n, arrayOnSingleGroup: r, overrideGroup: i } = s, o = i === !0 && n === !1, a = {};
480
480
  return e == null || e.forEach((c) => {
481
- const { name: l } = c, u = ne(c, s), f = r === !0 ? D(u) : u, m = a[l];
481
+ const { name: l } = c, u = ie(c, s), f = r === !0 ? F(u) : u, m = a[l];
482
482
  m ? o ? a[l] = u : a[l] = [
483
- D(m),
484
- D(u)
483
+ F(m),
484
+ F(u)
485
485
  ].flat() : a[l] = f;
486
- }), i ? Object.values(a).flat() : a;
486
+ }), n ? Object.values(a).flat() : a;
487
487
  }, Nt = {
488
488
  ...Q,
489
489
  includeTimespanAttributes: !1,
@@ -496,21 +496,21 @@ const vt = {
496
496
  const s = {
497
497
  ...Nt,
498
498
  ...t || {}
499
- }, { includeTimespanAttributes: i, arrayOnSingle: r, flat: n } = s, o = Object.fromEntries(
499
+ }, { includeTimespanAttributes: n, arrayOnSingle: r, flat: i } = s, o = Object.fromEntries(
500
500
  Object.entries(t).map(([d, h]) => {
501
501
  if (Object.keys(Q).includes(d))
502
- return ["arrayOnSingleGroup", "arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideGroup", "overrideField"].includes(d) && (h !== void 0 ? h : n === !0) ? [d, !0] : [d, h];
502
+ return ["arrayOnSingleGroup", "arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideGroup", "overrideField"].includes(d) && (h !== void 0 ? h : i === !0) ? [d, !0] : [d, h];
503
503
  }).filter((d) => !!d)
504
504
  ), a = Object.fromEntries(
505
505
  Object.entries(t).map(([d, h]) => {
506
506
  if (Object.keys(G).includes(d))
507
- return ["arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideField"].includes(d) && (h !== void 0 ? h : n === !0) ? [d, !0] : [d, h];
507
+ return ["arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideField"].includes(d) && (h !== void 0 ? h : i === !0) ? [d, !0] : [d, h];
508
508
  }).filter((d) => !!d)
509
- ), { field: c, group: l, ...u } = e || {}, f = c && Mt(c, a), m = l && Ft(l, o);
509
+ ), { field: c, group: l, ...u } = e || {}, f = c && Dt(c, a), m = l && Mt(l, o);
510
510
  return {
511
- ...i === !0 && u || Array.isArray(i) && Object.fromEntries(
511
+ ...n === !0 && u || Array.isArray(n) && Object.fromEntries(
512
512
  Object.entries(u).filter(
513
- ([d]) => i.includes(d)
513
+ ([d]) => n.includes(d)
514
514
  )
515
515
  ) || {},
516
516
  ...a != null && a.fieldAsList ? { field: f } : f,
@@ -527,13 +527,13 @@ const vt = {
527
527
  const s = {
528
528
  ...Z,
529
529
  ...t || {}
530
- }, { timespanAsList: i, joinTimespan: r, sortTimespan: n, flat: o, flatTimespan: a, ...c } = s, l = { flat: o, ...c };
531
- n && e.sort(te);
532
- const u = (a !== void 0 ? a === !0 : o === !0) && i === !1, f = {};
530
+ }, { timespanAsList: n, joinTimespan: r, sortTimespan: i, flat: o, flatTimespan: a, ...c } = s, l = { flat: o, ...c };
531
+ i && e.sort(te);
532
+ const u = (a !== void 0 ? a === !0 : o === !0) && n === !1, f = {};
533
533
  return e == null || e.forEach((m) => {
534
534
  const { start: p, end: d } = m, h = u ? "flat" : [p, d].join(r), g = ae(m, l), E = f[h];
535
- E ? u ? p === "-INF" && d === "+INF" ? f[h] = { ...at(E), ...g } : f[h] = { ...g, ...at(E) } : f[h] = [...D(E), g] : f[h] = g;
536
- }), i === !0 ? Object.values(f) : u ? Object.values(f).pop() : f;
535
+ E ? u ? p === "-INF" && d === "+INF" ? f[h] = { ...at(E), ...g } : f[h] = { ...g, ...at(E) } : f[h] = [...F(E), g] : f[h] = g;
536
+ }), n === !0 ? Object.values(f) : u ? Object.values(f).pop() : f;
537
537
  }, oe = {
538
538
  ...Z,
539
539
  includeMetadataAttributes: !1,
@@ -543,22 +543,22 @@ function ce(e, t) {
543
543
  const s = {
544
544
  ...oe,
545
545
  ...t || {}
546
- }, { includeMetadataAttributes: i, flat: r } = s, { timespan: n = [], ...o } = e || {}, a = Object.fromEntries(
546
+ }, { includeMetadataAttributes: n, flat: r } = s, { timespan: i = [], ...o } = e || {}, a = Object.fromEntries(
547
547
  Object.entries(s).map(([u, f]) => {
548
548
  if (Object.keys(Z).includes(u))
549
549
  return ["onlyGeneric", "overrideGroup", "overrideField"].includes(u) && (f !== void 0 ? f : r === !0) ? [u, !0] : [u, f];
550
550
  }).filter((u) => !!u)
551
551
  ), c = Ct(
552
- n,
552
+ i,
553
553
  a
554
554
  );
555
555
  return {
556
- ...i === !0 && {
556
+ ...n === !0 && {
557
557
  ...o,
558
558
  ...o.revision ? { revision: o.revision.split(",") } : {}
559
- } || Array.isArray(i) && Object.fromEntries(
559
+ } || Array.isArray(n) && Object.fromEntries(
560
560
  Object.entries(o).map(([u, f]) => {
561
- if (i.includes(u))
561
+ if (n.includes(u))
562
562
  return [
563
563
  u,
564
564
  u === "revision" && typeof f == "string" ? f.split(",") : f
@@ -570,7 +570,7 @@ function ce(e, t) {
570
570
  }
571
571
  const ls = (e) => {
572
572
  const { field: t = [] } = e || {};
573
- return F(t);
573
+ return M(t);
574
574
  }, tt = {
575
575
  PAL: { denominator: 25, numerator: 1 },
576
576
  NTSC: { denominator: 3e4, numerator: 1001 },
@@ -597,8 +597,8 @@ class R {
597
597
  */
598
598
  constructor(t) {
599
599
  this.numerator = 1, this.denominator = 1;
600
- const { numerator: s = 1, denominator: i = 1 } = t || {};
601
- this.numerator = Number(s), this.denominator = Number(i);
600
+ const { numerator: s = 1, denominator: n = 1 } = t || {};
601
+ this.numerator = Number(s), this.denominator = Number(n);
602
602
  }
603
603
  /**
604
604
  * Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
@@ -607,8 +607,8 @@ class R {
607
607
  toConstant() {
608
608
  let t;
609
609
  return Object.entries(tt).find((s) => {
610
- const [i, r] = s, { numerator: n, denominator: o } = r;
611
- return n === this.numerator && o === this.denominator ? (t = i, !0) : !1;
610
+ const [n, r] = s, { numerator: i, denominator: o } = r;
611
+ return i === this.numerator && o === this.denominator ? (t = n, !0) : !1;
612
612
  }), t;
613
613
  }
614
614
  /**
@@ -623,13 +623,13 @@ class R {
623
623
  * @returns Text representation of the TimeBase
624
624
  */
625
625
  toText(t) {
626
- const { constant: s, fraction: i } = { ...ct.toText, ...t };
626
+ const { constant: s, fraction: n } = { ...ct.toText, ...t };
627
627
  if (s) {
628
- const n = this.toConstant();
629
- if (n)
630
- return n;
628
+ const i = this.toConstant();
629
+ if (i)
630
+ return i;
631
631
  }
632
- return i || this.numerator > 1 ? [this.denominator, this.numerator].join(":") : String(this.denominator);
632
+ return n || this.numerator > 1 ? [this.denominator, this.numerator].join(":") : String(this.denominator);
633
633
  }
634
634
  /**
635
635
  * Output TimeBase as frame rate (by default max 16 decimal places)
@@ -647,8 +647,8 @@ class R {
647
647
  const s = this.denominator / this.numerator;
648
648
  if (Number.isInteger(s))
649
649
  return s;
650
- const { rounded: i, fixed: r } = { ...ct.toRate, ...t || {} };
651
- return i ? Math.round(s) : r === !0 || typeof r == "number" ? Number(s.toFixed(typeof r == "boolean" ? 2 : r)) : s;
650
+ const { rounded: n, fixed: r } = { ...ct.toRate, ...t || {} };
651
+ return n ? Math.round(s) : r === !0 || typeof r == "number" ? Number(s.toFixed(typeof r == "boolean" ? 2 : r)) : s;
652
652
  }
653
653
  /**
654
654
  * Get TimeBase in a object representation
@@ -679,8 +679,8 @@ const et = (e) => {
679
679
  if (typeof e == "number")
680
680
  return new R({ denominator: e });
681
681
  if (typeof e == "string" && e.includes(":")) {
682
- const [s, i] = e.split(":");
683
- return new R({ denominator: s, numerator: i });
682
+ const [s, n] = e.split(":");
683
+ return new R({ denominator: s, numerator: n });
684
684
  }
685
685
  if (!["string", "number"].includes(typeof e) || Number.isNaN(Number(e)))
686
686
  throw new Error(
@@ -693,16 +693,16 @@ const et = (e) => {
693
693
  const t = e.toConstant();
694
694
  return t === "59.94" && 4 || ["NTSC", "29.97"].includes(t) && 2 || void 0;
695
695
  }, wt = (e) => st(e) > 0, ut = (e) => {
696
- const { samples: t, timeBase: s } = e, i = st(s);
697
- if (!i)
696
+ const { samples: t, timeBase: s } = e, n = st(s);
697
+ if (!n)
698
698
  return 0;
699
- const r = s.toRate({ rounded: !0 }), n = 60 * r, o = 60 * r - i, a = 10 * (n - i) + i, c = Math.floor((t + 1) / a), l = Math.max(
699
+ const r = s.toRate({ rounded: !0 }), i = 60 * r, o = 60 * r - n, a = 10 * (i - n) + n, c = Math.floor((t + 1) / a), l = Math.max(
700
700
  0,
701
- (t + 1) % a - n
701
+ (t + 1) % a - i
702
702
  ), u = Math.floor(
703
703
  l / o
704
- ), m = l % o > 0 ? i : 0;
705
- return c * 9 * i + u * i + m;
704
+ ), m = l % o > 0 ? n : 0;
705
+ return c * 9 * n + u * n + m;
706
706
  }, V = {
707
707
  conformTimeBase: {
708
708
  dropFrame: void 0,
@@ -726,14 +726,14 @@ class S {
726
726
  */
727
727
  constructor(t, s) {
728
728
  this.samples = 0, this.timeBase = new R();
729
- const { samples: i, timeBase: r } = t || {};
730
- if (i !== void 0)
731
- if (typeof i == "number")
732
- this.samples = i;
733
- else if (typeof i == "string")
734
- i === "-INF" ? this.samples = -1 / 0 : i === "+INF" ? this.samples = 1 / 0 : this.samples = Number(i);
729
+ const { samples: n, timeBase: r } = t || {};
730
+ if (n !== void 0)
731
+ if (typeof n == "number")
732
+ this.samples = n;
733
+ else if (typeof n == "string")
734
+ n === "-INF" ? this.samples = -1 / 0 : n === "+INF" ? this.samples = 1 / 0 : this.samples = Number(n);
735
735
  else
736
- throw new Error(`samples is not number/string/-Inf/+Inf is: ${i}`);
736
+ throw new Error(`samples is not number/string/-Inf/+Inf is: ${n}`);
737
737
  r !== void 0 && (r instanceof R ? this.timeBase = r : this.timeBase = $(r)), this.dropFrame = (s == null ? void 0 : s.dropFrame) ?? wt(this.timeBase), this.frameSeparator = (s == null ? void 0 : s.frameSeparator) ?? (this.dropFrame ? ";" : ":");
738
738
  }
739
739
  /**
@@ -754,11 +754,11 @@ class S {
754
754
  add(t) {
755
755
  if (!(t != null && t.timeBase) || (t == null ? void 0 : t.samples) === void 0)
756
756
  throw Error("Invalid timeCodeType, cannot be added");
757
- const { numerator: s, denominator: i } = (t == null ? void 0 : t.timeBase) || {};
757
+ const { numerator: s, denominator: n } = (t == null ? void 0 : t.timeBase) || {};
758
758
  let r = t;
759
- (s !== this.timeBase.numerator || i !== this.timeBase.denominator) && (r = t.conformTimeBase(this.timeBase));
760
- const { samples: n } = r;
761
- return new S({ samples: this.samples + n, timeBase: this.timeBase });
759
+ (s !== this.timeBase.numerator || n !== this.timeBase.denominator) && (r = t.conformTimeBase(this.timeBase));
760
+ const { samples: i } = r;
761
+ return new S({ samples: this.samples + i, timeBase: this.timeBase });
762
762
  }
763
763
  /**
764
764
  * Return this TimeCode subtracted with the supplied timeCodeType
@@ -778,11 +778,11 @@ class S {
778
778
  subtract(t) {
779
779
  if (!(t != null && t.timeBase) || (t == null ? void 0 : t.samples) === void 0)
780
780
  throw Error("Invalid timeCodeType, cannot be subtracted");
781
- const { timeBase: { numerator: s, denominator: i } = {} } = t;
781
+ const { timeBase: { numerator: s, denominator: n } = {} } = t;
782
782
  let r = t;
783
- (s !== this.timeBase.numerator || i !== this.timeBase.denominator) && (r = t.conformTimeBase(this.timeBase));
784
- const { samples: n } = r;
785
- return new S({ samples: this.samples - n, timeBase: this.timeBase });
783
+ (s !== this.timeBase.numerator || n !== this.timeBase.denominator) && (r = t.conformTimeBase(this.timeBase));
784
+ const { samples: i } = r;
785
+ return new S({ samples: this.samples - i, timeBase: this.timeBase });
786
786
  }
787
787
  /**
788
788
  * Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
@@ -797,7 +797,7 @@ class S {
797
797
  * @returns A new TimeCode instance with the conformTo timeBase applied
798
798
  */
799
799
  conformTimeBase(t, s) {
800
- const i = t instanceof R ? t : $(t), r = (s == null ? void 0 : s.roundingMode) ?? "floor";
800
+ const n = t instanceof R ? t : $(t), r = (s == null ? void 0 : s.roundingMode) ?? "floor";
801
801
  if (!["floor", "ceil", "round"].includes(r))
802
802
  throw Error(
803
803
  `Invalid mode selection "${r}". Has to be one of "${[
@@ -806,13 +806,13 @@ class S {
806
806
  "round"
807
807
  ].join(", ")}"`
808
808
  );
809
- const n = Math[r](
810
- this.samples / (this.timeBase.toRate({ fixed: !1 }) / i.toRate({ fixed: !1 }))
809
+ const i = Math[r](
810
+ this.samples / (this.timeBase.toRate({ fixed: !1 }) / n.toRate({ fixed: !1 }))
811
811
  ), o = { ...V.conformTimeBase, ...s || {} };
812
812
  return new S(
813
813
  {
814
- samples: n,
815
- timeBase: i
814
+ samples: i,
815
+ timeBase: n
816
816
  },
817
817
  o
818
818
  );
@@ -830,7 +830,7 @@ class S {
830
830
  */
831
831
  toText(t) {
832
832
  let s = `${this.samples}`;
833
- const i = { ...V.toText, ...t || {} }, r = this.timeBase.toText(i);
833
+ const n = { ...V.toText, ...t || {} }, r = this.timeBase.toText(n);
834
834
  return (t != null && t.includeTimeBaseForSeconds || !["1", "1:1"].includes(r)) && (s = [this.samples, r].join("@")), s;
835
835
  }
836
836
  /**
@@ -852,11 +852,11 @@ class S {
852
852
  const t = this.samples + (this.dropFrame ? ut(this) : 0);
853
853
  let s = this.timeBase.toRate({ rounded: !0 });
854
854
  ["23.976", "23.98"].includes(this.timeBase.toConstant()) && (s = this.timeBase.toRate({ fixed: !0 }));
855
- const i = Math.floor(t / (3600 * s)), r = Math.floor(t / (60 * s)) % 60, n = Math.floor(t / s) % 60, o = Math.floor(t % s);
855
+ const n = Math.floor(t / (3600 * s)), r = Math.floor(t / (60 * s)) % 60, i = Math.floor(t / s) % 60, o = Math.floor(t % s);
856
856
  return {
857
- hours: i,
857
+ hours: n,
858
858
  minutes: r,
859
- seconds: n,
859
+ seconds: i,
860
860
  frames: o
861
861
  };
862
862
  }
@@ -868,10 +868,10 @@ class S {
868
868
  * @returns Time for the time code
869
869
  */
870
870
  toTime() {
871
- const t = this.samples + ut(this), { hours: s, minutes: i, seconds: r } = this.toUnits(), n = this.timeBase.toRate({ rounded: !0 }), o = t % n, a = Math.floor(1e3 * o / n), c = o / n;
871
+ const t = this.samples + ut(this), { hours: s, minutes: n, seconds: r } = this.toUnits(), i = this.timeBase.toRate({ rounded: !0 }), o = t % i, a = Math.floor(1e3 * o / i), c = o / i;
872
872
  return {
873
873
  hours: s,
874
- minutes: i,
874
+ minutes: n,
875
875
  seconds: r,
876
876
  milliseconds: a,
877
877
  partialSeconds: c
@@ -883,7 +883,7 @@ class S {
883
883
  * @returns Total seconds for the time code
884
884
  */
885
885
  toSeconds(t) {
886
- const { numerator: s, denominator: i } = this.timeBase, r = +(this.samples * s / i);
886
+ const { numerator: s, denominator: n } = this.timeBase, r = +(this.samples * s / n);
887
887
  return t != null && t.round ? Math.round(1e3 * r) / 1e3 : r;
888
888
  }
889
889
  /**
@@ -906,15 +906,15 @@ class S {
906
906
  * @returns Duration representation of the TimeCode
907
907
  */
908
908
  toDuration(t) {
909
- const { format: s } = { ...V.toDuration, ...t || {} }, { hours: i, ...r } = this.toTime();
910
- let { minutes: n, seconds: o, milliseconds: a } = r;
909
+ const { format: s } = { ...V.toDuration, ...t || {} }, { hours: n, ...r } = this.toTime();
910
+ let { minutes: i, seconds: o, milliseconds: a } = r;
911
911
  if (s && typeof s != "string")
912
912
  throw Error("format has to be a string");
913
913
  const c = (m, p) => !s.includes(m) || !p.some((d) => s.includes(d) && s.lastIndexOf(m) > s.indexOf(d));
914
914
  if (s && !(c("h", ["m", "s", "S"]) && c("m", ["s", "S"]) && c("s", ["S"])))
915
915
  throw Error("format order is unsupported (has to be h, m, s then S)");
916
916
  if (!s)
917
- return `${i > 0 ? `${i}:${`${n}`.padStart(2, "0")}` : n}:${`${o}`.padStart(2, "0")}`;
917
+ return `${n > 0 ? `${n}:${`${i}`.padStart(2, "0")}` : i}:${`${o}`.padStart(2, "0")}`;
918
918
  const l = (m, p) => {
919
919
  let d = m;
920
920
  for (; p[d] === p[d + 1]; )
@@ -927,21 +927,21 @@ class S {
927
927
  if (d[p - 1] === "h")
928
928
  break;
929
929
  const h = l(p, d);
930
- f.push(`${i}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
930
+ f.push(`${n}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
931
931
  break;
932
932
  }
933
933
  case "m": {
934
934
  if (d[p - 1] === "m")
935
935
  break;
936
936
  const h = l(p, d);
937
- s.includes("h") || (n += i * 60), f.push(`${n}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
937
+ s.includes("h") || (i += n * 60), f.push(`${i}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
938
938
  break;
939
939
  }
940
940
  case "s": {
941
941
  if (d[p - 1] === "s")
942
942
  break;
943
943
  const h = l(p, d);
944
- s.includes("m") || (o += n * 60), f.push(`${o}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(".");
944
+ s.includes("m") || (o += i * 60), f.push(`${o}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(".");
945
945
  break;
946
946
  }
947
947
  case "S": {
@@ -970,10 +970,10 @@ class S {
970
970
  };
971
971
  if (this.samples === -1 / 0)
972
972
  return "00:00:00:00";
973
- const { hours: i, minutes: r, seconds: n, frames: o } = this.toUnits(), a = s ? this.frameSeparator : ":", c = [
974
- i.toFixed().padStart(2, "0"),
973
+ const { hours: n, minutes: r, seconds: i, frames: o } = this.toUnits(), a = s ? this.frameSeparator : ":", c = [
974
+ n.toFixed().padStart(2, "0"),
975
975
  r.toFixed().padStart(2, "0"),
976
- n.toFixed().padStart(2, "0")
976
+ i.toFixed().padStart(2, "0")
977
977
  ].join(a), l = Math.max(2, `${this.timeBase.toRate({ rounded: !0 }) - 1}`.length);
978
978
  return [c, `${o}`.padStart(l, "0")].join(this.frameSeparator);
979
979
  }
@@ -998,12 +998,12 @@ class S {
998
998
  }
999
999
  }
1000
1000
  const ue = (e, t) => {
1001
- let s = Math.abs(e), i = Math.abs(t);
1002
- for (; s && i && s !== i; )
1003
- s > i ? [s, i] = [s - i, i] : [s, i] = [s, i - s];
1004
- return s || i;
1001
+ let s = Math.abs(e), n = Math.abs(t);
1002
+ for (; s && n && s !== n; )
1003
+ s > n ? [s, n] = [s - n, n] : [s, n] = [s, n - s];
1004
+ return s || n;
1005
1005
  }, de = (e, t) => {
1006
- const { timeBase: s, useGCD: i = !1, roundingMode: r, ...n } = t || {}, o = `${e}`.replace(/,/g, ".");
1006
+ const { timeBase: s, useGCD: n = !1, roundingMode: r, ...i } = t || {}, o = `${e}`.replace(/,/g, ".");
1007
1007
  if (Number.isNaN(+o))
1008
1008
  throw new Error(`seconds must be digits, is ${e}`);
1009
1009
  let a = 1, c;
@@ -1013,45 +1013,45 @@ const ue = (e, t) => {
1013
1013
  const [, u] = o.split("."), f = Math.min((u == null ? void 0 : u.length) ?? 0, 16);
1014
1014
  a *= 10 ** f, c = Math.round(Number(o) * a);
1015
1015
  }
1016
- if (s === void 0 && i) {
1016
+ if (s === void 0 && n) {
1017
1017
  const u = ue(a, c);
1018
1018
  c /= u, a /= u;
1019
1019
  }
1020
1020
  const l = new S(
1021
1021
  { samples: c, timeBase: { denominator: a, numerator: 1 } },
1022
- n
1022
+ i
1023
1023
  );
1024
- return s !== void 0 ? l.conformTimeBase(s, { ...n, roundingMode: r }) : l;
1025
- }, le = ([e, t, s, i], r, n) => {
1026
- const o = n.toRate({ rounded: !0 }), a = st(n);
1024
+ return s !== void 0 ? l.conformTimeBase(s, { ...i, roundingMode: r }) : l;
1025
+ }, le = ([e, t, s, n], r, i) => {
1026
+ const o = i.toRate({ rounded: !0 }), a = st(i);
1027
1027
  if (r === 0 || !a)
1028
1028
  return 0;
1029
1029
  const c = t % 10 !== 0, l = c && s === 0, u = e * (3600 * o - 54 * a), f = t * 60 * o - (t - Math.ceil(t / 10)) * a, m = s * o - (c && s > 1 ? a : 0);
1030
- if (l && i < a)
1030
+ if (l && n < a)
1031
1031
  throw new Error(
1032
- `Frame does not exist for ${n.toConstant() || n.toRate()} drop-frame`
1032
+ `Frame does not exist for ${i.toConstant() || i.toRate()} drop-frame`
1033
1033
  );
1034
- const p = l ? i - a : i, d = u + f + m + p;
1034
+ const p = l ? n - a : n, d = u + f + m + p;
1035
1035
  return r - d;
1036
1036
  }, H = (e, t, s) => {
1037
- const [i, r, n, o] = e, a = t.toRate({ rounded: !0 }), c = i * 3600 * a + r * 60 * a + n * a + o;
1037
+ const [n, r, i, o] = e, a = t.toRate({ rounded: !0 }), c = n * 3600 * a + r * 60 * a + i * a + o;
1038
1038
  return c - (s ? le(e, c, t) : 0);
1039
1039
  }, fe = (e) => {
1040
1040
  const [t] = (e == null ? void 0 : e.match(/[^0-9:\-_]/)) || [];
1041
1041
  let s = [];
1042
1042
  if (t) {
1043
- const [r, n] = e.split(t);
1044
- s = [...r.split(":"), n];
1043
+ const [r, i] = e.split(t);
1044
+ s = [...r.split(":"), i];
1045
1045
  } else
1046
1046
  s = e.split(":");
1047
1047
  if (s.length !== 4)
1048
1048
  throw new Error('Invalid format, must be "##:##:##:##');
1049
1049
  if (s.some((r) => Number.isNaN(r)))
1050
1050
  throw new Error("Invalid format, values must be numbers");
1051
- const i = t || ":";
1051
+ const n = t || ":";
1052
1052
  return {
1053
1053
  smpteValues: s.map(Number),
1054
- smpteFrameSeparator: i
1054
+ smpteFrameSeparator: n
1055
1055
  };
1056
1056
  }, me = ["error", "add", "ignore"], he = {
1057
1057
  exceedingMode: "error",
@@ -1059,35 +1059,35 @@ const ue = (e, t) => {
1059
1059
  dropFrame: void 0,
1060
1060
  frameSeparator: void 0
1061
1061
  }, pe = (e, t) => {
1062
- const { exceedingMode: s, timeBase: i, ...r } = { ...he, ...t };
1062
+ const { exceedingMode: s, timeBase: n, ...r } = { ...he, ...t };
1063
1063
  if ([null, void 0].includes(e))
1064
1064
  throw new Error("smpte cannot be undefined or null");
1065
1065
  if (typeof e != "string")
1066
1066
  throw new Error(`smpte must be a string, is ${JSON.stringify(e)}`);
1067
- const { smpteValues: n, smpteFrameSeparator: o } = fe(e), a = $(i), c = {
1067
+ const { smpteValues: i, smpteFrameSeparator: o } = fe(e), a = $(n), c = {
1068
1068
  ...r,
1069
1069
  frameSeparator: (r == null ? void 0 : r.frameSeparator) || o,
1070
1070
  ...(r == null ? void 0 : r.dropFrame) === void 0 ? {
1071
- dropFrame: i !== void 0 ? wt(a) : [";", ","].includes(o)
1071
+ dropFrame: n !== void 0 ? wt(a) : [";", ","].includes(o)
1072
1072
  } : {}
1073
1073
  }, l = a.toRate({ rounded: !0 }), u = Math.max(0, l - 1);
1074
- if (n.some((m) => m < 0))
1074
+ if (i.some((m) => m < 0))
1075
1075
  throw new Error("Negative values are not supported");
1076
1076
  let f;
1077
1077
  switch (s) {
1078
1078
  case "error": {
1079
- const [m, p, d, h] = n;
1079
+ const [m, p, d, h] = i;
1080
1080
  if (m >= 100 || p >= 60)
1081
1081
  throw Error("Minutes has to be less than 60");
1082
1082
  if (d >= 60)
1083
1083
  throw Error("Seconds has to be less than 60");
1084
1084
  if (h > u)
1085
1085
  throw Error(`Frames has to be less or equal to ${u}`);
1086
- f = H(n, a, c == null ? void 0 : c.dropFrame);
1086
+ f = H(i, a, c == null ? void 0 : c.dropFrame);
1087
1087
  break;
1088
1088
  }
1089
1089
  case "ignore": {
1090
- const [m, p, d, h] = n, g = [
1090
+ const [m, p, d, h] = i, g = [
1091
1091
  Math.min(100, m),
1092
1092
  Math.min(59, p),
1093
1093
  Math.min(59, d),
@@ -1101,7 +1101,7 @@ const ue = (e, t) => {
1101
1101
  break;
1102
1102
  }
1103
1103
  case "add": {
1104
- f = H(n, a, c == null ? void 0 : c.dropFrame);
1104
+ f = H(i, a, c == null ? void 0 : c.dropFrame);
1105
1105
  break;
1106
1106
  }
1107
1107
  default:
@@ -1113,7 +1113,7 @@ const ue = (e, t) => {
1113
1113
  dropFrame: void 0,
1114
1114
  frameSeparator: void 0
1115
1115
  }, U = (e, t) => {
1116
- const { timeBase: s, ...i } = { ..._e, ...t };
1116
+ const { timeBase: s, ...n } = { ..._e, ...t };
1117
1117
  let r;
1118
1118
  if (e === void 0)
1119
1119
  r = { samples: 0 };
@@ -1126,8 +1126,8 @@ const ue = (e, t) => {
1126
1126
  e === "-INF" ? r = { samples: -1 / 0 } : e === "+INF" ? r = { samples: 1 / 0 } : r = { samples: Number(e) };
1127
1127
  if (Number.isNaN(r == null ? void 0 : r.samples) || r.timeBase && !(r.timeBase instanceof R))
1128
1128
  throw new Error(`timeCodeText must be a number or sample@timeBase - is ${e}`);
1129
- const n = new S(r, i);
1130
- return s ? n.conformTimeBase($(s), i) : n;
1129
+ const i = new S(r, n);
1130
+ return s ? i.conformTimeBase($(s), n) : i;
1131
1131
  }, Te = {
1132
1132
  dropFrame: void 0,
1133
1133
  frameSeparator: void 0
@@ -1143,15 +1143,15 @@ const ue = (e, t) => {
1143
1143
  if (typeof e == "string")
1144
1144
  return U(e, t);
1145
1145
  };
1146
- function dt({ hours: e = 0, minutes: t = 0, seconds: s = 0, partialSeconds: i = 0 }) {
1147
- const r = e.toFixed().padStart(2, "0"), n = t.toFixed().padStart(2, "0"), o = s.toFixed().padStart(2, "0"), a = (i * 10).toFixed().padStart(3, "0");
1148
- return `${r}:${n}:${o}.${a}`;
1146
+ function dt({ hours: e = 0, minutes: t = 0, seconds: s = 0, partialSeconds: n = 0 }) {
1147
+ const r = e.toFixed().padStart(2, "0"), i = t.toFixed().padStart(2, "0"), o = s.toFixed().padStart(2, "0"), a = (n * 10).toFixed().padStart(3, "0");
1148
+ return `${r}:${i}:${o}.${a}`;
1149
1149
  }
1150
1150
  const Ae = {
1151
1151
  subtitleGroup: "stl_subtitle",
1152
1152
  subtitleField: "stl_text"
1153
1153
  }, fs = (e, t) => {
1154
- const { subtitleGroup: s, subtitleField: i } = { ...Ae, ...t || {} }, { timespan: r = [] } = e || {};
1154
+ const { subtitleGroup: s, subtitleField: n } = { ...Ae, ...t || {} }, { timespan: r = [] } = e || {};
1155
1155
  if (r.length === 0)
1156
1156
  return "";
1157
1157
  const o = Ct(r, {
@@ -1164,7 +1164,7 @@ const Ae = {
1164
1164
  const {
1165
1165
  start: c,
1166
1166
  end: l,
1167
- [s]: { [i]: u } = {}
1167
+ [s]: { [n]: u } = {}
1168
1168
  } = (Array.isArray(a) ? a[0] : a) || {};
1169
1169
  if (!u)
1170
1170
  return "";
@@ -1178,29 +1178,29 @@ const Ae = {
1178
1178
  ${o.join(`
1179
1179
  `)}`;
1180
1180
  }, Ie = { count: !0, exclude: !0 }, ms = (e = [], t = {}) => {
1181
- const s = { ...Ie, ...t }, { count: i, exclude: r } = s;
1182
- return e.map((n) => typeof n == "string" ? {
1183
- field: n,
1184
- name: n,
1185
- count: i,
1186
- ...r === !0 ? { exclude: [n] } : {}
1187
- } : n);
1188
- }, hs = (e = []) => e == null ? void 0 : e.map(({ name: t, field: s, count: i, range: r }) => ({
1181
+ const s = { ...Ie, ...t }, { count: n, exclude: r } = s;
1182
+ return e.map((i) => typeof i == "string" ? {
1183
+ field: i,
1184
+ name: i,
1185
+ count: n,
1186
+ ...r === !0 ? { exclude: [i] } : {}
1187
+ } : i);
1188
+ }, hs = (e = []) => e == null ? void 0 : e.map(({ name: t, field: s, count: n, range: r }) => ({
1189
1189
  facetName: t,
1190
1190
  fieldName: s,
1191
- count: i == null ? void 0 : i.reduce((n, { fieldValue: o, value: a }) => ({ ...n, [o]: a }), {}),
1191
+ count: n == null ? void 0 : n.reduce((i, { fieldValue: o, value: a }) => ({ ...i, [o]: a }), {}),
1192
1192
  ...r ? {
1193
- range: r.map(({ value: n, start: o, end: a }) => ({
1193
+ range: r.map(({ value: i, start: o, end: a }) => ({
1194
1194
  start: Number.isNaN(+o) ? o : Number(o),
1195
1195
  end: Number.isNaN(+a) ? a : Number(a),
1196
- count: Number(n) || 0
1196
+ count: Number(i) || 0
1197
1197
  }))
1198
1198
  } : {}
1199
1199
  })), ps = (e = []) => {
1200
1200
  const t = {};
1201
- return e.forEach(({ name: s, field: i, count: r }) => {
1202
- t[s || i] = r.reduce(
1203
- (n, { fieldValue: o, value: a }) => ({ ...n, [o]: a }),
1201
+ return e.forEach(({ name: s, field: n, count: r }) => {
1202
+ t[s || n] = r.reduce(
1203
+ (i, { fieldValue: o, value: a }) => ({ ...i, [o]: a }),
1204
1204
  {}
1205
1205
  );
1206
1206
  }), t;
@@ -1211,15 +1211,15 @@ ${o.join(`
1211
1211
  }, Y = (e, t) => {
1212
1212
  const {
1213
1213
  arrayOnSingle: s = !0,
1214
- joinValue: i = void 0,
1214
+ joinValue: n = void 0,
1215
1215
  timespanAsList: r = !1
1216
- } = { ...Bt, ...t || {} }, { field: n = [], start: o, end: a } = e || {}, c = r ? { start: o, end: a } : {};
1217
- return n.reduce((u, f) => {
1216
+ } = { ...Bt, ...t || {} }, { field: i = [], start: o, end: a } = e || {}, c = r ? { start: o, end: a } : {};
1217
+ return i.reduce((u, f) => {
1218
1218
  const { name: m, value: p = [] } = f;
1219
1219
  if (p.length === 0)
1220
1220
  return u;
1221
1221
  let d;
1222
- return s === !1 && p.length === 1 ? [d] = p : i ? d = p.join(i) : d = p, { ...u, [m]: d };
1222
+ return s === !1 && p.length === 1 ? [d] = p : n ? d = p.join(n) : d = p, { ...u, [m]: d };
1223
1223
  }, c);
1224
1224
  }, Oe = {
1225
1225
  ...Bt,
@@ -1230,20 +1230,20 @@ ${o.join(`
1230
1230
  }, _s = (e = [], t) => {
1231
1231
  const {
1232
1232
  timespanAsList: s,
1233
- joinTimespan: i = "_",
1233
+ joinTimespan: n = "_",
1234
1234
  flat: r,
1235
- flatTimespan: n,
1235
+ flatTimespan: i,
1236
1236
  ...o
1237
1237
  } = { ...Oe, ...t || {} };
1238
1238
  return s === !0 ? e.map(
1239
1239
  (a) => Y(a, { ...o, timespanAsList: s })
1240
- ) : r === !0 || n === !0 ? e.reduce(
1240
+ ) : r === !0 || i === !0 ? e.reduce(
1241
1241
  (a, c) => ({ ...a, ...Y(c, t) }),
1242
1242
  {}
1243
1243
  ) : e.reduce(
1244
1244
  (a, c) => ({
1245
1245
  ...a,
1246
- [[c.start, c.end].join(i)]: Y(
1246
+ [[c.start, c.end].join(n)]: Y(
1247
1247
  c,
1248
1248
  t
1249
1249
  )
@@ -1251,11 +1251,11 @@ ${o.join(`
1251
1251
  {}
1252
1252
  );
1253
1253
  }, be = (e, t) => {
1254
- const s = j(t).toSeconds(), { thumbnails: i = {} } = e || {}, { uri: r = [] } = i, n = r.map((a) => {
1254
+ const s = j(t).toSeconds(), { thumbnails: n = {} } = e || {}, { uri: r = [] } = n, i = r.map((a) => {
1255
1255
  const c = a.split("/").pop().split("?").shift();
1256
1256
  return U(c).toSeconds();
1257
- }), o = n.reduce(
1258
- (a, c, l) => Math.abs(c - s) < Math.abs(n[a] - s) ? l : a,
1257
+ }), o = i.reduce(
1258
+ (a, c, l) => Math.abs(c - s) < Math.abs(i[a] - s) ? l : a,
1259
1259
  0
1260
1260
  );
1261
1261
  return r[o];
@@ -1269,13 +1269,13 @@ ${o.join(`
1269
1269
  end: t,
1270
1270
  group: s = [{ id: "unknown", name: "unknown" }]
1271
1271
  }) => {
1272
- const [{ id: i, name: r }] = s, n = j(e).toSeconds(), o = j(t).toSeconds();
1273
- return { start: e, end: t, startSeconds: n, endSeconds: o, group: { uuid: i, name: r } };
1272
+ const [{ id: n, name: r }] = s, i = j(e).toSeconds(), o = j(t).toSeconds();
1273
+ return { start: e, end: t, startSeconds: i, endSeconds: o, group: { uuid: n, name: r } };
1274
1274
  }, Ts = (e = {}, t) => {
1275
- const { entry: s = [] } = e, i = {
1275
+ const { entry: s = [] } = e, n = {
1276
1276
  ...Re,
1277
1277
  ...t || {}
1278
- }, { includeGroupMetadata: r, flatEvents: n, includeEntityType: o, includeNearestThumbnail: a } = i, c = s.map((l) => {
1278
+ }, { includeGroupMetadata: r, flatEvents: i, includeEntityType: o, includeNearestThumbnail: a } = n, c = s.map((l) => {
1279
1279
  const { type: u, item: { metadata: f = {}, id: m, thumbnails: p = {} } = {}, timespan: d, item: h } = l;
1280
1280
  let g = d.map(
1281
1281
  (E) => ye(E)
@@ -1291,8 +1291,8 @@ ${o.join(`
1291
1291
  const O = g.map((I) => {
1292
1292
  const {
1293
1293
  group: { uuid: b }
1294
- } = I, [M] = b.split("/"), { field: N = [], group: C = [] } = A.find(
1295
- ({ uuid: v }) => v === M
1294
+ } = I, [D] = b.split("/"), { field: N = [], group: C = [] } = A.find(
1295
+ ({ uuid: v }) => v === D
1296
1296
  );
1297
1297
  return {
1298
1298
  ...I,
@@ -1319,7 +1319,7 @@ ${o.join(`
1319
1319
  ...o && u === "Collection" ? { collectionType: h } : {}
1320
1320
  };
1321
1321
  });
1322
- return n ? c.flatMap(
1322
+ return i ? c.flatMap(
1323
1323
  ({ events: l, entityType: u, entityId: f, itemType: m, collectionType: p }) => l.map(
1324
1324
  (d) => ({
1325
1325
  ...d,
@@ -1334,8 +1334,8 @@ ${o.join(`
1334
1334
  if (e.startsWith("NOW")) {
1335
1335
  if (e === "NOW")
1336
1336
  return /* @__PURE__ */ new Date();
1337
- const t = e[3], s = Number(e.match(/(\d+)/)[0]), i = e.match(/(\d.*)/)[0].replace(/\d/g, ""), r = /* @__PURE__ */ new Date();
1338
- switch (i) {
1337
+ const t = e[3], s = Number(e.match(/(\d+)/)[0]), n = e.match(/(\d.*)/)[0].replace(/\d/g, ""), r = /* @__PURE__ */ new Date();
1338
+ switch (n) {
1339
1339
  case "HOUR":
1340
1340
  case "HOURS":
1341
1341
  t === "+" && r.setHours(r.getHours() + s), t === "-" && r.setHours(r.getHours() - s);
@@ -1358,31 +1358,31 @@ ${o.join(`
1358
1358
  return new Date(e);
1359
1359
  }, z = (e) => {
1360
1360
  const { property: t = [], ...s } = e || {};
1361
- return { ...F(t), ...s };
1362
- }, Se = (e) => z(e), ve = (e) => z(e), Me = { kB: "kHz", B: "Hz", mB: "mHz" }, lt = { kB: "kbps", B: "bps", MB: "mbps" }, De = (e) => {
1361
+ return { ...M(t), ...s };
1362
+ }, Se = (e) => z(e), ve = (e) => z(e), De = { kB: "kHz", B: "Hz", mB: "mHz" }, lt = { kB: "kbps", B: "bps", MB: "mbps" }, Fe = (e) => {
1363
1363
  var g;
1364
1364
  const {
1365
1365
  timeBase: t,
1366
1366
  channelCount: s,
1367
- codec: i,
1367
+ codec: n,
1368
1368
  mediaInfo: r,
1369
- bitrate: n,
1369
+ bitrate: i,
1370
1370
  metadata: o
1371
1371
  } = e, a = Se(r), {
1372
1372
  Format: c,
1373
1373
  Resolution: l,
1374
1374
  Bit_rate_mode: u
1375
- } = a, f = F(o || []), m = t != null && t.denominator ? ((t == null ? void 0 : t.denominator) || 1) / ((t == null ? void 0 : t.numerator) || 1) : void 0, p = m !== void 0 ? w(m, {
1375
+ } = a, f = M(o || []), m = t != null && t.denominator ? ((t == null ? void 0 : t.denominator) || 1) / ((t == null ? void 0 : t.numerator) || 1) : void 0, p = m !== void 0 ? w(m, {
1376
1376
  base: 10,
1377
1377
  round: 1,
1378
- symbols: Me
1378
+ symbols: De
1379
1379
  }) : void 0;
1380
1380
  let d, h;
1381
- return n !== void 0 && (d = w(n, { round: 2, symbols: lt }), h = Number(
1382
- (g = w(n, { exponent: 1, symbols: lt }).split(" kbps")) == null ? void 0 : g[0]
1381
+ return i !== void 0 && (d = w(i, { round: 2, symbols: lt }), h = Number(
1382
+ (g = w(i, { exponent: 1, symbols: lt }).split(" kbps")) == null ? void 0 : g[0]
1383
1383
  )), {
1384
1384
  audioFormat: c,
1385
- audioCodec: i,
1385
+ audioCodec: n,
1386
1386
  audioSamplerate: p,
1387
1387
  audioSamplerateSamples: m,
1388
1388
  audioBitDepth: l,
@@ -1420,25 +1420,25 @@ ${o.join(`
1420
1420
  const {
1421
1421
  uri: t = [],
1422
1422
  size: s,
1423
- hash: i,
1423
+ hash: n,
1424
1424
  path: r,
1425
- id: n,
1425
+ id: i,
1426
1426
  storage: o
1427
1427
  } = e, [a] = t, c = s !== void 0 ? w(s, { base: 2, standard: "jedec" }) : "", l = (r == null ? void 0 : r.split("/")) || [], u = l.pop() || "", f = l.map((m) => `${m}/`).join("") || void 0;
1428
1428
  return {
1429
1429
  uri: a,
1430
- hash: i,
1430
+ hash: n,
1431
1431
  fileSize: c,
1432
1432
  fileSizeBytes: s,
1433
1433
  path: r,
1434
1434
  fileName: u,
1435
- fileId: n,
1435
+ fileId: i,
1436
1436
  storageId: o,
1437
1437
  folderPath: f
1438
1438
  };
1439
- }, Fe = (e = {}) => {
1440
- const { file: t, mediaInfo: s, metadata: i = [] } = e, r = F(i), n = z(s);
1441
- let o = { binaryMetadata: r, binaryMediaInfo: n };
1439
+ }, Me = (e = {}) => {
1440
+ const { file: t, mediaInfo: s, metadata: n = [] } = e, r = M(n), i = z(s);
1441
+ let o = { binaryMetadata: r, binaryMediaInfo: i };
1442
1442
  if (t) {
1443
1443
  const [a] = t, c = Pt(a);
1444
1444
  o = {
@@ -1451,12 +1451,12 @@ ${o.join(`
1451
1451
  const {
1452
1452
  mediaInfo: t,
1453
1453
  metadata: s,
1454
- file: i,
1454
+ file: n,
1455
1455
  duration: r,
1456
- startTimestamp: n,
1456
+ startTimestamp: i,
1457
1457
  startTimecode: o,
1458
1458
  timeCodeTimeBase: a
1459
- } = e, c = F(s || []), l = z(t);
1459
+ } = e, c = M(s || []), l = z(t);
1460
1460
  let { Format: u } = l;
1461
1461
  const {
1462
1462
  Video_Format_List: f,
@@ -1479,11 +1479,11 @@ ${o.join(`
1479
1479
  const h = L(r);
1480
1480
  d.durationTimeCode = h.toObject(), d.duration = h.toDuration();
1481
1481
  }
1482
- if (n && (d.startTimestamp = L(n).toObject()), o !== void 0 && a && (d.startTimecode = L({
1482
+ if (i && (d.startTimestamp = L(i).toObject()), o !== void 0 && a && (d.startTimecode = L({
1483
1483
  samples: o,
1484
1484
  timeBase: a
1485
- })), i) {
1486
- const [h] = i, g = Pt(h);
1485
+ })), n) {
1486
+ const [h] = n, g = Pt(h);
1487
1487
  d = {
1488
1488
  ...d,
1489
1489
  ...g
@@ -1495,11 +1495,11 @@ ${o.join(`
1495
1495
  const {
1496
1496
  codec: t,
1497
1497
  bitrate: s,
1498
- fieldOrder: i,
1498
+ fieldOrder: n,
1499
1499
  resolution: r,
1500
- mediaInfo: n,
1500
+ mediaInfo: i,
1501
1501
  metadata: o = []
1502
- } = e, a = ve(n), c = F(o), {
1502
+ } = e, a = ve(i), c = M(o), {
1503
1503
  Format: l,
1504
1504
  "Frame rate": u,
1505
1505
  "Color space": f,
@@ -1517,12 +1517,12 @@ ${o.join(`
1517
1517
  }));
1518
1518
  let { "Frame count": E } = a;
1519
1519
  if (E === void 0) {
1520
- const { numberOfPackets: nt } = e;
1521
- nt !== void 0 && (E = nt.toString());
1520
+ const { numberOfPackets: it } = e;
1521
+ it !== void 0 && (E = it.toString());
1522
1522
  }
1523
1523
  let A, O, I;
1524
1524
  E && d && (A = L({ samples: E, timeBase: d }), O = A.timeBase.toConstant() || A.timeBase.toRate(), I = A.toSmpte());
1525
- const { height: b, width: M } = r || {}, N = J(r), C = `${M}x${b}`;
1525
+ const { height: b, width: D } = r || {}, N = J(r), C = `${D}x${b}`;
1526
1526
  let v, B;
1527
1527
  return s !== void 0 && (v = w(s, { round: 2, symbols: ft }), B = Number(
1528
1528
  (k = w(s, { exponent: 2, symbols: ft }).split(" mbps")) == null ? void 0 : k[0]
@@ -1531,14 +1531,14 @@ ${o.join(`
1531
1531
  dimension: C,
1532
1532
  frameRate: O,
1533
1533
  height: b,
1534
- width: M,
1534
+ width: D,
1535
1535
  timeBase: d,
1536
1536
  timeCode: A,
1537
1537
  videoCodec: t,
1538
1538
  smpte: I,
1539
1539
  videoBitrate: v,
1540
1540
  videoBitrateMbps: B,
1541
- fieldOrder: i,
1541
+ fieldOrder: n,
1542
1542
  colorSpace: f,
1543
1543
  chromaSubsampling: p,
1544
1544
  aspectRatio: N,
@@ -1548,9 +1548,9 @@ ${o.join(`
1548
1548
  };
1549
1549
  }, rt = (e = {}, t = {}) => {
1550
1550
  let s = {};
1551
- const { priority: i = ["container", "video", "audio", "binary"] } = t, {
1551
+ const { priority: n = ["container", "video", "audio", "binary"] } = t, {
1552
1552
  containerComponent: r,
1553
- videoComponent: n,
1553
+ videoComponent: i,
1554
1554
  audioComponent: o,
1555
1555
  binaryComponent: a,
1556
1556
  mimeType: c = [],
@@ -1563,7 +1563,7 @@ ${o.join(`
1563
1563
  m[p] ?? f[p]
1564
1564
  ])
1565
1565
  );
1566
- return i.reverse().forEach((f) => {
1566
+ return n.reverse().forEach((f) => {
1567
1567
  switch (f) {
1568
1568
  case "container":
1569
1569
  r && (s = u(
@@ -1572,8 +1572,8 @@ ${o.join(`
1572
1572
  ));
1573
1573
  break;
1574
1574
  case "video":
1575
- if (n) {
1576
- const [m] = n;
1575
+ if (i) {
1576
+ const [m] = i;
1577
1577
  s = u(
1578
1578
  s,
1579
1579
  Ce(m)
@@ -1585,7 +1585,7 @@ ${o.join(`
1585
1585
  const [m] = o;
1586
1586
  s = u(
1587
1587
  s,
1588
- De(m)
1588
+ Fe(m)
1589
1589
  );
1590
1590
  }
1591
1591
  break;
@@ -1594,7 +1594,7 @@ ${o.join(`
1594
1594
  const [m] = a;
1595
1595
  s = u(
1596
1596
  s,
1597
- Fe(m)
1597
+ Me(m)
1598
1598
  );
1599
1599
  }
1600
1600
  break;
@@ -1655,9 +1655,9 @@ ${o.join(`
1655
1655
  ].reverse(), mt = ({ parsedShape: { tag: e } }, { parsedShape: { tag: t } }) => W.includes(e) || W.includes(t) ? W.indexOf(t) - W.indexOf(e) : e.toLowerCase().localeCompare(t.toLowerCase()), Is = (e, t) => {
1656
1656
  const {
1657
1657
  allowedMimeTypes: s = Le,
1658
- allowedMethods: i = xe,
1658
+ allowedMethods: n = xe,
1659
1659
  sortPriority: r = mt,
1660
- sourceKey: n = "src",
1660
+ sourceKey: i = "src",
1661
1661
  mimeTypeKey: o = "type",
1662
1662
  shapeKey: a = "shape",
1663
1663
  parsedShapeKey: c = "parsedShape"
@@ -1665,13 +1665,13 @@ ${o.join(`
1665
1665
  let p, d;
1666
1666
  const h = rt(m), { uri: g, mimeType: E, containerFormat: A, videoCodec: O } = h;
1667
1667
  if (E && (p = E, (E === ke || E === We) && (A === $e || A === Ue) && O === Ge && (p = je)), g)
1668
- if (i) {
1668
+ if (n) {
1669
1669
  const [I] = g.split("://");
1670
- i.includes(I) && (d = g);
1670
+ n.includes(I) && (d = g);
1671
1671
  } else
1672
1672
  d = g;
1673
1673
  return d && s.includes(p) && f.push({
1674
- [n]: d,
1674
+ [i]: d,
1675
1675
  [o]: p,
1676
1676
  [a]: m,
1677
1677
  [c]: h
@@ -1679,12 +1679,12 @@ ${o.join(`
1679
1679
  }, []);
1680
1680
  return typeof r == "function" && u.sort(mt), u;
1681
1681
  }, Os = (e) => {
1682
- const t = rt(e), { mimeType: s, videoCodec: i, audioCodec: r } = t;
1682
+ const t = rt(e), { mimeType: s, videoCodec: n, audioCodec: r } = t;
1683
1683
  if (s) {
1684
1684
  if (s.startsWith("audio/") && r !== void 0)
1685
1685
  return y.AUDIO;
1686
1686
  if (s.startsWith("video/")) {
1687
- if (i !== void 0)
1687
+ if (n !== void 0)
1688
1688
  return y.VIDEO;
1689
1689
  if (r !== void 0)
1690
1690
  return y.AUDIO;
@@ -1722,17 +1722,17 @@ ${o.join(`
1722
1722
  }) => $t(e[0], window.btoa(t), `.${s}`), bs = (e, t) => {
1723
1723
  const {
1724
1724
  allowedMimeTypes: s = qe,
1725
- allowedMethods: i = Xe,
1725
+ allowedMethods: n = Xe,
1726
1726
  streamingServers: r = []
1727
- } = t || {}, { shape: n = [] } = e || {}, { startTimeCode: o } = ce(e == null ? void 0 : e.metadata, {
1727
+ } = t || {}, { shape: i = [] } = e || {}, { startTimeCode: o } = ce(e == null ? void 0 : e.metadata, {
1728
1728
  flat: !0,
1729
1729
  arrayOnSingleValue: !1
1730
1730
  });
1731
- return n.reduce((c, l) => {
1732
- var M, N, C;
1731
+ return i.reduce((c, l) => {
1732
+ var D, N, C;
1733
1733
  let u, f, m;
1734
1734
  const p = rt(l), { uri: d, mimeType: h, containerFormat: g, videoCodec: E } = p;
1735
- if (!(s != null && s.includes(h)) || !(i != null && i.includes((M = d == null ? void 0 : d.split("://")) == null ? void 0 : M[0])))
1735
+ if (!(s != null && s.includes(h)) || !(n != null && n.includes((D = d == null ? void 0 : d.split("://")) == null ? void 0 : D[0])))
1736
1736
  return c;
1737
1737
  if (m = p.tag, !m) {
1738
1738
  const v = (C = (N = h == null ? void 0 : h.split) == null ? void 0 : N.call(h, "/")) == null ? void 0 : C.pop(), B = c.filter((k) => k.label === v).length;
@@ -1755,11 +1755,11 @@ ${o.join(`
1755
1755
  const t = {}, { outputSetting: s = [] } = e || {};
1756
1756
  if (s.length === 0)
1757
1757
  return t;
1758
- const i = JSON.parse(s[0]), { Settings: { ContainerSettings: r, VideoDescription: n, AudioDescriptions: o } = {} } = i;
1759
- if (r && (t.containerFormat = r.Container), n) {
1760
- const { CodecSettings: a = {} } = n, { Codec: c, ...l } = a;
1758
+ const n = JSON.parse(s[0]), { Settings: { ContainerSettings: r, VideoDescription: i, AudioDescriptions: o } = {} } = n;
1759
+ if (r && (t.containerFormat = r.Container), i) {
1760
+ const { CodecSettings: a = {} } = i, { Codec: c, ...l } = a;
1761
1761
  t.videoFormat = c;
1762
- const { Height: u, Width: f } = n;
1762
+ const { Height: u, Width: f } = i;
1763
1763
  t.height = u, t.width = f, u && f && (t.dimension = `${f}x${u}`, t.aspectRatio = J({ height: u, width: f }));
1764
1764
  const [m] = Object.values(l);
1765
1765
  if (m) {
@@ -1776,16 +1776,16 @@ ${o.join(`
1776
1776
  }
1777
1777
  return t;
1778
1778
  }, Rs = (e) => {
1779
- const t = {}, { description: s, format: i, audio: r, video: n, mediaconvert: o } = e || {};
1779
+ const t = {}, { description: s, format: n, audio: r, video: i, mediaconvert: o } = e || {};
1780
1780
  if (o)
1781
1781
  return { description: s, ...Ze(o) };
1782
- if (t.description = s, t.containerFormat = i, n) {
1783
- if (t.videoFormat = n.codec, t.videoBitrate = n.bitrate, n.framerate) {
1784
- const a = x(n.framerate);
1782
+ if (t.description = s, t.containerFormat = n, i) {
1783
+ if (t.videoFormat = i.codec, t.videoBitrate = i.bitrate, i.framerate) {
1784
+ const a = x(i.framerate);
1785
1785
  t.timeBase = a, t.frameRate = a.toConstant() || a.toRate();
1786
1786
  }
1787
- if (n.scaling) {
1788
- const { height: a, width: c } = n.scaling;
1787
+ if (i.scaling) {
1788
+ const { height: a, width: c } = i.scaling;
1789
1789
  t.height = a, t.width = c, a && c && (t.dimension = `${c}x${a}`, t.aspectRatio = J({ height: a, width: c }));
1790
1790
  }
1791
1791
  }
@@ -1800,15 +1800,15 @@ ${o.join(`
1800
1800
  const {
1801
1801
  name: t,
1802
1802
  type: s,
1803
- defaultValue: i,
1803
+ defaultValue: n,
1804
1804
  stringRestriction: r,
1805
- floatRestriction: n,
1805
+ floatRestriction: i,
1806
1806
  integerRestriction: o,
1807
1807
  longRestriction: a,
1808
1808
  data: c,
1809
1809
  values: l,
1810
1810
  system: u
1811
- } = e, { minLength: f, maxLength: m, pattern: p } = r || {}, { minInclusive: d, maxInclusive: h } = n || o || a || {}, g = ((l == null ? void 0 : l.field) || []).map(({ key: I, value: b }) => ({
1811
+ } = e, { minLength: f, maxLength: m, pattern: p } = r || {}, { minInclusive: d, maxInclusive: h } = i || o || a || {}, g = ((l == null ? void 0 : l.field) || []).map(({ key: I, value: b }) => ({
1812
1812
  label: b ?? I,
1813
1813
  value: I
1814
1814
  })), A = ((I) => Object.fromEntries(Object.entries(I).filter(([, b]) => b !== void 0)))({
@@ -1817,11 +1817,11 @@ ${o.join(`
1817
1817
  minLength: f,
1818
1818
  maxLength: m,
1819
1819
  pattern: p ? new RegExp(p) : void 0
1820
- }), O = F(c);
1820
+ }), O = M(c);
1821
1821
  return {
1822
1822
  name: t,
1823
1823
  type: s,
1824
- defaultValue: i,
1824
+ defaultValue: n,
1825
1825
  required: d !== void 0 || f !== void 0 && f > 0,
1826
1826
  restrictions: A,
1827
1827
  data: O,
@@ -1838,7 +1838,7 @@ ${o.join(`
1838
1838
  "boolean",
1839
1839
  "timeCode"
1840
1840
  ];
1841
- class it {
1841
+ class nt {
1842
1842
  // custom events model
1843
1843
  constructor() {
1844
1844
  this.events = {};
@@ -1850,8 +1850,8 @@ class it {
1850
1850
  * @param callback function receiving state of chunk, transfer manager or chunked upload instance
1851
1851
  */
1852
1852
  on(t, s) {
1853
- const i = this.events[t] || [];
1854
- i.push(s), this.events[t] = i;
1853
+ const n = this.events[t] || [];
1854
+ n.push(s), this.events[t] = n;
1855
1855
  }
1856
1856
  /**
1857
1857
  * Remove all callbacks for a specific event type
@@ -1868,10 +1868,10 @@ class it {
1868
1868
  * @param data
1869
1869
  * @returns
1870
1870
  */
1871
- trigger(t, s, i) {
1871
+ trigger(t, s, n) {
1872
1872
  const r = this.events[t];
1873
- !r || r.length < 1 || r.forEach((n) => {
1874
- n(s, i);
1873
+ !r || r.length < 1 || r.forEach((i) => {
1874
+ i(s, n);
1875
1875
  });
1876
1876
  }
1877
1877
  }
@@ -1885,7 +1885,7 @@ class es {
1885
1885
  completeTime: null,
1886
1886
  response: null,
1887
1887
  bytesTransferred: null
1888
- }, this.eventBus = new it();
1888
+ }, this.eventBus = new nt();
1889
1889
  }
1890
1890
  /**
1891
1891
  * Attempt to transfer chunk with some fault resilience.
@@ -1897,16 +1897,16 @@ class es {
1897
1897
  */
1898
1898
  tryTransfer() {
1899
1899
  return this.state.status = _.transferring, this.state.startTime = performance.now(), new Promise((t, s) => {
1900
- const i = () => {
1900
+ const n = () => {
1901
1901
  this.transfer().then((r) => {
1902
1902
  this.state.response = r, this.onComplete(), t(this);
1903
1903
  }).catch(() => {
1904
1904
  this.state.retries > 3 ? (this.state.status = _.failed, s(new Error(`Chunk ${this.start}-${this.end} failed`))) : this.state.status !== _.paused ? (this.state.retries += 1, this.tryTimeout = setTimeout(() => {
1905
- i();
1905
+ n();
1906
1906
  }, 1e3)) : clearTimeout(this.tryTimeout);
1907
1907
  });
1908
1908
  };
1909
- i(), window.addEventListener(T.online, () => {
1909
+ n(), window.addEventListener(T.online, () => {
1910
1910
  this.resume();
1911
1911
  }), window.addEventListener(T.offline, () => {
1912
1912
  this.pause();
@@ -1928,10 +1928,11 @@ class es {
1928
1928
  [_.complete, _.offline].includes(this.state.status) || (this.state.bytesTransferred = s == null ? void 0 : s.loaded, this.eventBus.trigger(T.progress, this.state));
1929
1929
  }
1930
1930
  };
1931
- return this.end - this.start !== this.fileSize && (t.headers = {
1931
+ return t = { ...t, ...this.api.props || {} }, this.end - this.start !== this.fileSize && (t.headers = {
1932
1932
  index: this.start,
1933
- size: this.fileSize
1934
- }), t = { ...t, ...this.api.props || {} }, this.transferPromise = this.api.method(t), this.state.status = _.transferring, this.transferPromise;
1933
+ size: this.fileSize,
1934
+ ...t.headers || {}
1935
+ }), this.transferPromise = this.api.method(t), this.state.status = _.transferring, this.transferPromise;
1935
1936
  }
1936
1937
  pause() {
1937
1938
  this.state.status !== _.complete && (this.state.status = _.paused);
@@ -1955,7 +1956,7 @@ class es {
1955
1956
  }
1956
1957
  class ht {
1957
1958
  constructor(t, s) {
1958
- var i, r, n, o, a, c;
1959
+ var n, r, i, o, a, c;
1959
1960
  if (this.DEFAULT_OPTIONS = Object.freeze({
1960
1961
  targetRate: 4e6,
1961
1962
  // 4mb sec,
@@ -1971,7 +1972,7 @@ class ht {
1971
1972
  autoResume: !0,
1972
1973
  // ChunkedTransferManager -> automatically resume transfers on network
1973
1974
  api: void 0
1974
- }), this.eventBus = new it(), !s.api.method)
1975
+ }), this.eventBus = new nt(), !s.api.method)
1975
1976
  throw new Error("No api method specified");
1976
1977
  this.options = {
1977
1978
  ...this.DEFAULT_OPTIONS,
@@ -1979,10 +1980,10 @@ class ht {
1979
1980
  api: {
1980
1981
  ...s.api ?? {},
1981
1982
  props: {
1982
- ...((i = s.api) == null ? void 0 : i.props) ?? {},
1983
+ ...((n = s.api) == null ? void 0 : n.props) ?? {},
1983
1984
  queryParams: {
1984
1985
  transferId: zt(),
1985
- ...((n = (r = s.api) == null ? void 0 : r.props) == null ? void 0 : n.queryParams) ?? {}
1986
+ ...((i = (r = s.api) == null ? void 0 : r.props) == null ? void 0 : i.queryParams) ?? {}
1986
1987
  }
1987
1988
  }
1988
1989
  }
@@ -2006,30 +2007,37 @@ class ht {
2006
2007
  const { status: t } = this.state;
2007
2008
  if (t !== _.complete)
2008
2009
  if (t === _.idle || t === _.transferring) {
2009
- this.state.transferPromises = [];
2010
- const s = () => {
2011
- const i = this.state.chunks[0].state.status;
2012
- return this.state.transferPromises.length < this.state.maxConcurrentTransfers && i !== _.transferring;
2010
+ const s = this.state.chunks.length;
2011
+ let n = 0;
2012
+ const r = () => {
2013
+ for (; this.state.transferPromises.length < this.state.maxConcurrentTransfers && n < s; ) {
2014
+ const i = this.state.chunks[n];
2015
+ if (n += 1, i.state.status !== _.complete && i.state.status !== _.transferring) {
2016
+ this.state.status = _.transferring;
2017
+ const o = i.tryTransfer();
2018
+ this.state.transferPromises.push(o), o.then(() => {
2019
+ const a = this.state.transferPromises.indexOf(o);
2020
+ a !== -1 && this.state.transferPromises.splice(a, 1), this.state.status !== _.canceled && r();
2021
+ }).catch((a) => {
2022
+ const c = this.state.transferPromises.indexOf(o);
2023
+ c !== -1 && this.state.transferPromises.splice(c, 1), console.error(
2024
+ "Failed on this upload(), check connectivity and try to resume",
2025
+ a
2026
+ ), this.state.status !== _.offline ? (this.state.status = _.failed, this.eventBus.trigger(T.failed, this.state, a), this.options.onFail && this.options.onFail(a)) : setTimeout(() => this.retry(), 5e3);
2027
+ });
2028
+ }
2029
+ }
2013
2030
  };
2014
- s() && (this.state.chunks.forEach((i) => {
2015
- i.state.status !== _.complete && i.state.status !== _.transferring && s() && (this.state.status = _.transferring, this.state.transferPromises.push(i.tryTransfer()));
2016
- }), this.state.transferPromises.length > 0 && Promise.all(this.state.transferPromises).then(() => {
2017
- this.upload();
2018
- }).catch((i) => {
2019
- console.error(
2020
- "Failed on this upload() cycle, check connectivity and try to resume",
2021
- i
2022
- ), this.state.status !== _.offline ? (this.state.status = _.failed, this.eventBus.trigger(T.failed, this.state, i), this.options.onFail && this.options.onFail(i)) : setTimeout(() => this.retry(), 5e3);
2023
- }));
2031
+ r();
2024
2032
  } else
2025
2033
  this.retry();
2026
2034
  }
2027
2035
  // get all byte ranges for splitting in chunks
2028
2036
  getByteRangesForChunks(t, s = this.options.chunkSize) {
2029
- const i = [], { minChunkSize: r } = this.options;
2037
+ const n = [], { minChunkSize: r } = this.options;
2030
2038
  let o = s >= r ? s : r, a = Math.floor(t.size / o);
2031
2039
  if (t.size - (t.size - t.size / a) >= r || (a -= 1, o = Math.floor(t.size / a)), a < 2 || t.size < this.options.minFileSize)
2032
- i.push({ start: 0, end: t.size });
2040
+ n.push({ start: 0, end: t.size });
2033
2041
  else
2034
2042
  for (let c = 0; c <= a; c += 1) {
2035
2043
  const l = o * c;
@@ -2039,17 +2047,17 @@ class ht {
2039
2047
  start: l,
2040
2048
  end: u
2041
2049
  };
2042
- if (i.push(m), u === t.size)
2050
+ if (n.push(m), u === t.size)
2043
2051
  break;
2044
2052
  }
2045
- return i;
2053
+ return n;
2046
2054
  }
2047
2055
  addChunksFromBlob(t) {
2048
- this.getByteRangesForChunks(t).forEach((i) => {
2056
+ this.getByteRangesForChunks(t).forEach((n) => {
2049
2057
  const r = new es({
2050
- start: i.start,
2051
- end: i.end,
2052
- blobSlice: t.slice(i.start, i.end),
2058
+ start: n.start,
2059
+ end: n.end,
2060
+ blobSlice: t.slice(n.start, n.end),
2053
2061
  fileSize: t.size,
2054
2062
  api: this.options.api
2055
2063
  });
@@ -2080,8 +2088,7 @@ class ht {
2080
2088
  cancel() {
2081
2089
  this.state.status = _.canceled, this.state.chunks.length > 0 && this.state.chunks.forEach((s) => {
2082
2090
  s.cancel();
2083
- }), this.upload = () => {
2084
- };
2091
+ });
2085
2092
  const t = Promise.all(this.state.transferPromises);
2086
2093
  return t.then(() => {
2087
2094
  this.eventBus.trigger(T.removed, this.state);
@@ -2096,10 +2103,10 @@ class ht {
2096
2103
  else if (s < 0.3)
2097
2104
  this.state.maxConcurrentTransfers = 1;
2098
2105
  else {
2099
- const i = this.options.maxConcurrentTransfers - 1;
2106
+ const n = this.options.maxConcurrentTransfers - 1;
2100
2107
  this.state.maxConcurrentTransfers = Math.max(
2101
2108
  this.options.maxConcurrentTransfers,
2102
- Math.min(i, this.options.maxConcurrentTransfers)
2109
+ Math.min(n, this.options.maxConcurrentTransfers)
2103
2110
  );
2104
2111
  }
2105
2112
  }
@@ -2125,16 +2132,16 @@ class ht {
2125
2132
  getStats() {
2126
2133
  const t = this.state.chunks.length, s = this.state.chunks.filter(
2127
2134
  (l) => l.state.status === _.complete
2128
- ), i = this.state.chunks.filter(
2135
+ ), n = this.state.chunks.filter(
2129
2136
  (l) => l.state.status === _.transferring
2130
2137
  ), r = s.length;
2131
- let n = 0, o = 0;
2138
+ let i = 0, o = 0;
2132
2139
  s.forEach((l) => {
2133
- n += l.transferRate, o += l.blobSlice.size;
2134
- }), i.forEach((l) => {
2140
+ i += l.transferRate, o += l.blobSlice.size;
2141
+ }), n.forEach((l) => {
2135
2142
  o += l.state.bytesTransferred;
2136
2143
  });
2137
- const a = n / r, c = {
2144
+ const a = i / r, c = {
2138
2145
  totalChunks: t,
2139
2146
  completedChunks: r,
2140
2147
  totalBytes: this.state.blob.size,
@@ -2156,8 +2163,8 @@ class ht {
2156
2163
  }
2157
2164
  get finalResponse() {
2158
2165
  const t = this.state.chunks.length - 1, s = !1;
2159
- for (let i = t; i >= 0; i -= 1) {
2160
- const r = this.state.chunks[i];
2166
+ for (let n = t; n >= 0; n -= 1) {
2167
+ const r = this.state.chunks[n];
2161
2168
  if (typeof r.state.response.data == "object")
2162
2169
  return r.state.response;
2163
2170
  }
@@ -2189,7 +2196,7 @@ class vs {
2189
2196
  }), this.state = { ...this.initialState }, this.options = {
2190
2197
  ...rs,
2191
2198
  ...t
2192
- }, this.events = new it(), this.bindNetworkEvents();
2199
+ }, this.events = new nt(), this.bindNetworkEvents();
2193
2200
  }
2194
2201
  get transfers() {
2195
2202
  return Object.values(this.state.transfers) || [];
@@ -2235,8 +2242,8 @@ class vs {
2235
2242
  this.onProgress();
2236
2243
  }), t.eventBus.on(T.complete, () => {
2237
2244
  this.upload(), this.onProgress();
2238
- }), t.eventBus.on(T.failed, (s, i) => {
2239
- this.onFail(i, s);
2245
+ }), t.eventBus.on(T.failed, (s, n) => {
2246
+ this.onFail(n, s);
2240
2247
  }), t.eventBus.on(T.retry, () => {
2241
2248
  this.events.trigger(T.retry, this.state);
2242
2249
  }), t.eventBus.on(T.paused, () => {
@@ -2245,12 +2252,12 @@ class vs {
2245
2252
  }
2246
2253
  // param can be file or a reference to transfer, or a transferId
2247
2254
  removeChunkedUpload(t, s = !1) {
2248
- const i = (r) => r ? r.state.status === _.complete && !s ? (console.error(
2255
+ const n = (r) => r ? r.state.status === _.complete && !s ? (console.error(
2249
2256
  "Can't cancel complete transfers, pass true as a second argument in .removeChunkedUpload() to force removal."
2250
- ), !1) : (Object.keys(this.state.transfers).forEach((n) => {
2251
- r === this.state.transfers[n] && delete this.state.transfers[n];
2257
+ ), !1) : (Object.keys(this.state.transfers).forEach((i) => {
2258
+ r === this.state.transfers[i] && delete this.state.transfers[i];
2252
2259
  }), this.events.trigger(T.removed, this.state), r.cancel(), !0) : (console.error("Could not find a matching transfer to cancel."), !1);
2253
- t instanceof ht ? i(t) : t instanceof File ? i(this.exists(t)) : typeof t == "string" ? i(this.transfers.find((r) => r.transferId === t)) : console.error(
2260
+ t instanceof ht ? n(t) : t instanceof File ? n(this.exists(t)) : typeof t == "string" ? n(this.transfers.find((r) => r.transferId === t)) : console.error(
2254
2261
  "Invalid object to remove - has to be either ChunkedUpload, File or transferId"
2255
2262
  );
2256
2263
  }
@@ -2262,8 +2269,8 @@ class vs {
2262
2269
  }
2263
2270
  exists(t) {
2264
2271
  let s;
2265
- for (let i = 0; i < this.transfers.length; i += 1) {
2266
- const r = this.transfers[i];
2272
+ for (let n = 0; n < this.transfers.length; n += 1) {
2273
+ const r = this.transfers[n];
2267
2274
  if (r.state.blob.name === t.name && r.state.blob.lastModified === t.lastModified && r.state.blob.size && t.size)
2268
2275
  return s = r, s;
2269
2276
  }
@@ -2278,8 +2285,8 @@ class vs {
2278
2285
  if (!this.paused) {
2279
2286
  this.events.trigger(T.pausing, this.state);
2280
2287
  const s = [];
2281
- this.transfers.forEach((i) => {
2282
- s.push(i.pause());
2288
+ this.transfers.forEach((n) => {
2289
+ s.push(n.pause());
2283
2290
  }), t = Promise.all(s), t.then(() => {
2284
2291
  this.events.trigger(T.paused, this.state);
2285
2292
  });
@@ -2327,12 +2334,12 @@ class vs {
2327
2334
  get fileList() {
2328
2335
  const t = [];
2329
2336
  return this.transfers.forEach((s) => {
2330
- const i = s.getStats(), { totalChunks: r, completedChunks: n } = i, o = {
2337
+ const n = s.getStats(), { totalChunks: r, completedChunks: i } = n, o = {
2331
2338
  name: s.state.blob.name,
2332
- bytesDone: i.transferredBytes,
2339
+ bytesDone: n.transferredBytes,
2333
2340
  bytesTotal: s.state.blob.size,
2334
2341
  totalChunks: r,
2335
- completedChunks: n,
2342
+ completedChunks: i,
2336
2343
  transfer: s
2337
2344
  };
2338
2345
  t.push(o);
@@ -2340,16 +2347,16 @@ class vs {
2340
2347
  }
2341
2348
  }
2342
2349
  const Wt = (e, t, s = "") => {
2343
- const i = (a) => {
2350
+ const n = (a) => {
2344
2351
  const c = a.startsWith("/") ? a.slice(1) : a, l = (c == null ? void 0 : c.search("/")) ?? -1;
2345
2352
  return l === -1 ? [c] : [c.slice(0, l), c.slice(l + 1)];
2346
- }, [r, n] = i(t), o = [s, r].filter(Boolean).join("/");
2347
- return n ? {
2353
+ }, [r, i] = n(t), o = [s, r].filter(Boolean).join("/");
2354
+ return i ? {
2348
2355
  [r]: {
2349
2356
  file: new File([e], r, { ...e, type: "folder" }),
2350
2357
  path: o,
2351
2358
  progress: { totalBytes: e.size ?? 0, transferredBytes: 0 },
2352
- files: Wt(e, n, o)
2359
+ files: Wt(e, i, o)
2353
2360
  }
2354
2361
  } : {
2355
2362
  [r]: {
@@ -2358,12 +2365,12 @@ const Wt = (e, t, s = "") => {
2358
2365
  progress: { totalBytes: e.size ?? 0, transferredBytes: 0 }
2359
2366
  }
2360
2367
  };
2361
- }, Ms = (e) => e.map((t) => Wt(t, t.path ?? t.webkitRelativePath)).reduce((t, s) => Ut(t, s), {});
2368
+ }, Ds = (e) => e.map((t) => Wt(t, t.path ?? t.webkitRelativePath)).reduce((t, s) => Ut(t, s), {});
2362
2369
  export {
2363
2370
  es as Chunk,
2364
2371
  vs as ChunkedTransferManager,
2365
2372
  ht as ChunkedUpload,
2366
- it as ChunkedUploadEventBus,
2373
+ nt as ChunkedUploadEventBus,
2367
2374
  P as DOCUMENT_TYPES,
2368
2375
  T as EVENTS,
2369
2376
  Ht as FIELD_ATTRIBUTE_KEYS,
@@ -2382,7 +2389,7 @@ export {
2382
2389
  ms as createSearchFacetList,
2383
2390
  $ as createTimeBase,
2384
2391
  j as createTimeCode,
2385
- Ms as fileListToFileTree,
2392
+ Ds as fileListToFileTree,
2386
2393
  Is as filterShapeSource,
2387
2394
  be as findNearestThumbnail,
2388
2395
  et as formatTimeBaseText,
@@ -2395,18 +2402,18 @@ export {
2395
2402
  As as getShapeDocumentType,
2396
2403
  Os as getShapeMediaType,
2397
2404
  fs as metadataTypeToWebVtt,
2398
- De as parseAudioComponent,
2399
- Fe as parseBinaryComponent,
2405
+ Fe as parseAudioComponent,
2406
+ Me as parseBinaryComponent,
2400
2407
  Ne as parseContainerComponent,
2401
2408
  hs as parseFacetList,
2402
2409
  ps as parseFacetType,
2403
2410
  ys as parseFieldDefinitionList,
2404
- Mt as parseFieldList,
2411
+ Dt as parseFieldList,
2405
2412
  Pt as parseFileType,
2406
- Ft as parseGroupList,
2413
+ Mt as parseGroupList,
2407
2414
  Y as parseHighlightTimespan,
2408
2415
  _s as parseHighlightTimespanList,
2409
- F as parseKeyValuePairType,
2416
+ M as parseKeyValuePairType,
2410
2417
  Ze as parseMediaConvertPreset,
2411
2418
  ce as parseMetadataType,
2412
2419
  gs as parseNowDate,