@moq/watch 0.2.5 → 0.2.6

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.
@@ -2,37 +2,37 @@ import * as _ from "@moq/lite";
2
2
  import { Time as p, Path as zn } from "@moq/lite";
3
3
  import { Signal as h, Effect as T } from "@moq/signals";
4
4
  function v(n, e, t) {
5
- function s(c, o) {
6
- if (c._zod || Object.defineProperty(c, "_zod", {
5
+ function s(o, c) {
6
+ if (o._zod || Object.defineProperty(o, "_zod", {
7
7
  value: {
8
- def: o,
8
+ def: c,
9
9
  constr: a,
10
10
  traits: /* @__PURE__ */ new Set()
11
11
  },
12
12
  enumerable: !1
13
- }), c._zod.traits.has(n))
13
+ }), o._zod.traits.has(n))
14
14
  return;
15
- c._zod.traits.add(n), e(c, o);
15
+ o._zod.traits.add(n), e(o, c);
16
16
  const u = a.prototype, d = Object.keys(u);
17
17
  for (let l = 0; l < d.length; l++) {
18
18
  const f = d[l];
19
- f in c || (c[f] = u[f].bind(c));
19
+ f in o || (o[f] = u[f].bind(o));
20
20
  }
21
21
  }
22
22
  const r = t?.Parent ?? Object;
23
23
  class i extends r {
24
24
  }
25
25
  Object.defineProperty(i, "name", { value: n });
26
- function a(c) {
27
- var o;
26
+ function a(o) {
27
+ var c;
28
28
  const u = t?.Parent ? new i() : this;
29
- s(u, c), (o = u._zod).deferred ?? (o.deferred = []);
29
+ s(u, o), (c = u._zod).deferred ?? (c.deferred = []);
30
30
  for (const d of u._zod.deferred)
31
31
  d();
32
32
  return u;
33
33
  }
34
34
  return Object.defineProperty(a, "init", { value: s }), Object.defineProperty(a, Symbol.hasInstance, {
35
- value: (c) => t?.Parent && c instanceof t.Parent ? !0 : c?._zod?.traits?.has(n)
35
+ value: (o) => t?.Parent && o instanceof t.Parent ? !0 : o?._zod?.traits?.has(n)
36
36
  }), Object.defineProperty(a, "name", { value: n }), a;
37
37
  }
38
38
  class H extends Error {
@@ -161,16 +161,16 @@ const He = (n, e) => {
161
161
  if (a instanceof Promise)
162
162
  throw new H();
163
163
  if (a.issues.length) {
164
- const c = new (r?.Err ?? n)(a.issues.map((o) => Y(o, i, K())));
165
- throw Ze(c, r?.callee), c;
164
+ const o = new (r?.Err ?? n)(a.issues.map((c) => Y(c, i, K())));
165
+ throw Ze(o, r?.callee), o;
166
166
  }
167
167
  return a.value;
168
168
  }, $n = /* @__PURE__ */ Ln(fe), jn = (n) => async (e, t, s, r) => {
169
169
  const i = s ? Object.assign(s, { async: !0 }) : { async: !0 };
170
170
  let a = e._zod.run({ value: t, issues: [] }, i);
171
171
  if (a instanceof Promise && (a = await a), a.issues.length) {
172
- const c = new (r?.Err ?? n)(a.issues.map((o) => Y(o, i, K())));
173
- throw Ze(c, r?.callee), c;
172
+ const o = new (r?.Err ?? n)(a.issues.map((c) => Y(c, i, K())));
173
+ throw Ze(o, r?.callee), o;
174
174
  }
175
175
  return a.value;
176
176
  }, Gn = /* @__PURE__ */ jn(fe), Zn = (n) => (e, t, s) => {
@@ -236,25 +236,25 @@ const He = (n, e) => {
236
236
  be.init(n, e), e.format = e.format || "float64";
237
237
  const t = e.format?.includes("int"), s = t ? "int" : "number", [r, i] = Vn[e.format];
238
238
  n._zod.onattach.push((a) => {
239
- const c = a._zod.bag;
240
- c.format = e.format, c.minimum = r, c.maximum = i, t && (c.pattern = Wn);
239
+ const o = a._zod.bag;
240
+ o.format = e.format, o.minimum = r, o.maximum = i, t && (o.pattern = Wn);
241
241
  }), n._zod.check = (a) => {
242
- const c = a.value;
242
+ const o = a.value;
243
243
  if (t) {
244
- if (!Number.isInteger(c)) {
244
+ if (!Number.isInteger(o)) {
245
245
  a.issues.push({
246
246
  expected: s,
247
247
  format: e.format,
248
248
  code: "invalid_type",
249
249
  continue: !1,
250
- input: c,
250
+ input: o,
251
251
  inst: n
252
252
  });
253
253
  return;
254
254
  }
255
- if (!Number.isSafeInteger(c)) {
256
- c > 0 ? a.issues.push({
257
- input: c,
255
+ if (!Number.isSafeInteger(o)) {
256
+ o > 0 ? a.issues.push({
257
+ input: o,
258
258
  code: "too_big",
259
259
  maximum: Number.MAX_SAFE_INTEGER,
260
260
  note: "Integers must be within the safe integer range.",
@@ -263,7 +263,7 @@ const He = (n, e) => {
263
263
  inclusive: !0,
264
264
  continue: !e.abort
265
265
  }) : a.issues.push({
266
- input: c,
266
+ input: o,
267
267
  code: "too_small",
268
268
  minimum: Number.MIN_SAFE_INTEGER,
269
269
  note: "Integers must be within the safe integer range.",
@@ -275,17 +275,17 @@ const He = (n, e) => {
275
275
  return;
276
276
  }
277
277
  }
278
- c < r && a.issues.push({
278
+ o < r && a.issues.push({
279
279
  origin: "number",
280
- input: c,
280
+ input: o,
281
281
  code: "too_small",
282
282
  minimum: r,
283
283
  inclusive: !0,
284
284
  inst: n,
285
285
  continue: !e.abort
286
- }), c > i && a.issues.push({
286
+ }), o > i && a.issues.push({
287
287
  origin: "number",
288
- input: c,
288
+ input: o,
289
289
  code: "too_big",
290
290
  maximum: i,
291
291
  inclusive: !0,
@@ -310,16 +310,16 @@ const He = (n, e) => {
310
310
  n._zod.run = n._zod.parse;
311
311
  });
312
312
  else {
313
- const r = (a, c, o) => {
313
+ const r = (a, o, c) => {
314
314
  let u = ee(a), d;
315
- for (const l of c) {
315
+ for (const l of o) {
316
316
  if (l._zod.def.when) {
317
317
  if (!l._zod.def.when(a))
318
318
  continue;
319
319
  } else if (u)
320
320
  continue;
321
321
  const f = a.issues.length, w = l._zod.check(a);
322
- if (w instanceof Promise && o?.async === !1)
322
+ if (w instanceof Promise && c?.async === !1)
323
323
  throw new H();
324
324
  if (d || w instanceof Promise)
325
325
  d = (d ?? Promise.resolve()).then(async () => {
@@ -332,31 +332,31 @@ const He = (n, e) => {
332
332
  }
333
333
  }
334
334
  return d ? d.then(() => a) : a;
335
- }, i = (a, c, o) => {
335
+ }, i = (a, o, c) => {
336
336
  if (ee(a))
337
337
  return a.aborted = !0, a;
338
- const u = r(c, s, o);
338
+ const u = r(o, s, c);
339
339
  if (u instanceof Promise) {
340
- if (o.async === !1)
340
+ if (c.async === !1)
341
341
  throw new H();
342
- return u.then((d) => n._zod.parse(d, o));
342
+ return u.then((d) => n._zod.parse(d, c));
343
343
  }
344
- return n._zod.parse(u, o);
344
+ return n._zod.parse(u, c);
345
345
  };
346
- n._zod.run = (a, c) => {
347
- if (c.skipChecks)
348
- return n._zod.parse(a, c);
349
- if (c.direction === "backward") {
350
- const u = n._zod.parse({ value: a.value, issues: [] }, { ...c, skipChecks: !0 });
351
- return u instanceof Promise ? u.then((d) => i(d, a, c)) : i(u, a, c);
352
- }
353
- const o = n._zod.parse(a, c);
354
- if (o instanceof Promise) {
355
- if (c.async === !1)
346
+ n._zod.run = (a, o) => {
347
+ if (o.skipChecks)
348
+ return n._zod.parse(a, o);
349
+ if (o.direction === "backward") {
350
+ const u = n._zod.parse({ value: a.value, issues: [] }, { ...o, skipChecks: !0 });
351
+ return u instanceof Promise ? u.then((d) => i(d, a, o)) : i(u, a, o);
352
+ }
353
+ const c = n._zod.parse(a, o);
354
+ if (c instanceof Promise) {
355
+ if (o.async === !1)
356
356
  throw new H();
357
- return o.then((u) => r(u, s, c));
357
+ return c.then((u) => r(u, s, o));
358
358
  }
359
- return r(o, s, c);
359
+ return r(c, s, o);
360
360
  };
361
361
  }
362
362
  I(n, "~standard", () => ({
@@ -438,11 +438,11 @@ const rt = /* @__PURE__ */ v("$ZodArray", (n, e) => {
438
438
  t.value = Array(r.length);
439
439
  const i = [];
440
440
  for (let a = 0; a < r.length; a++) {
441
- const c = r[a], o = e.element._zod.run({
442
- value: c,
441
+ const o = r[a], c = e.element._zod.run({
442
+ value: o,
443
443
  issues: []
444
444
  }, s);
445
- o instanceof Promise ? i.push(o.then((u) => Ie(u, t, a))) : Ie(o, t, a);
445
+ c instanceof Promise ? i.push(c.then((u) => Ie(u, t, a))) : Ie(c, t, a);
446
446
  }
447
447
  return i.length ? Promise.all(i).then(() => t) : t;
448
448
  };
@@ -470,15 +470,15 @@ function it(n) {
470
470
  };
471
471
  }
472
472
  function at(n, e, t, s, r, i) {
473
- const a = [], c = r.keySet, o = r.catchall._zod, u = o.def.type, d = o.optout === "optional";
473
+ const a = [], o = r.keySet, c = r.catchall._zod, u = c.def.type, d = c.optout === "optional";
474
474
  for (const l in e) {
475
- if (c.has(l))
475
+ if (o.has(l))
476
476
  continue;
477
477
  if (u === "never") {
478
478
  a.push(l);
479
479
  continue;
480
480
  }
481
- const f = o.run({ value: e[l], issues: [] }, s);
481
+ const f = c.run({ value: e[l], issues: [] }, s);
482
482
  f instanceof Promise ? n.push(f.then((w) => le(w, t, l, e, d))) : le(f, t, l, e, d);
483
483
  }
484
484
  return a.length && t.issues.push({
@@ -490,48 +490,48 @@ function at(n, e, t, s, r, i) {
490
490
  }
491
491
  const ot = /* @__PURE__ */ v("$ZodObject", (n, e) => {
492
492
  if (U.init(n, e), !Object.getOwnPropertyDescriptor(e, "shape")?.get) {
493
- const c = e.shape;
493
+ const o = e.shape;
494
494
  Object.defineProperty(e, "shape", {
495
495
  get: () => {
496
- const o = { ...c };
496
+ const c = { ...o };
497
497
  return Object.defineProperty(e, "shape", {
498
- value: o
499
- }), o;
498
+ value: c
499
+ }), c;
500
500
  }
501
501
  });
502
502
  }
503
503
  const s = je(() => it(e));
504
504
  I(n._zod, "propValues", () => {
505
- const c = e.shape, o = {};
506
- for (const u in c) {
507
- const d = c[u]._zod;
505
+ const o = e.shape, c = {};
506
+ for (const u in o) {
507
+ const d = o[u]._zod;
508
508
  if (d.values) {
509
- o[u] ?? (o[u] = /* @__PURE__ */ new Set());
509
+ c[u] ?? (c[u] = /* @__PURE__ */ new Set());
510
510
  for (const l of d.values)
511
- o[u].add(l);
511
+ c[u].add(l);
512
512
  }
513
513
  }
514
- return o;
514
+ return c;
515
515
  });
516
516
  const r = de, i = e.catchall;
517
517
  let a;
518
- n._zod.parse = (c, o) => {
518
+ n._zod.parse = (o, c) => {
519
519
  a ?? (a = s.value);
520
- const u = c.value;
520
+ const u = o.value;
521
521
  if (!r(u))
522
- return c.issues.push({
522
+ return o.issues.push({
523
523
  expected: "object",
524
524
  code: "invalid_type",
525
525
  input: u,
526
526
  inst: n
527
- }), c;
528
- c.value = {};
527
+ }), o;
528
+ o.value = {};
529
529
  const d = [], l = a.shape;
530
530
  for (const f of a.keys) {
531
- const w = l[f], b = w._zod.optout === "optional", g = w._zod.run({ value: u[f], issues: [] }, o);
532
- g instanceof Promise ? d.push(g.then((R) => le(R, c, f, u, b))) : le(g, c, f, u, b);
531
+ const w = l[f], b = w._zod.optout === "optional", g = w._zod.run({ value: u[f], issues: [] }, c);
532
+ g instanceof Promise ? d.push(g.then((R) => le(R, o, f, u, b))) : le(g, o, f, u, b);
533
533
  }
534
- return i ? at(d, u, c, o, s.value, n) : d.length ? Promise.all(d).then(() => c) : c;
534
+ return i ? at(d, u, o, c, s.value, n) : d.length ? Promise.all(d).then(() => o) : o;
535
535
  };
536
536
  });
537
537
  function Re(n, e, t, s) {
@@ -561,21 +561,21 @@ const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
561
561
  if (t)
562
562
  return s(r, i);
563
563
  let a = !1;
564
- const c = [];
565
- for (const o of e.options) {
566
- const u = o._zod.run({
564
+ const o = [];
565
+ for (const c of e.options) {
566
+ const u = c._zod.run({
567
567
  value: r.value,
568
568
  issues: []
569
569
  }, i);
570
570
  if (u instanceof Promise)
571
- c.push(u), a = !0;
571
+ o.push(u), a = !0;
572
572
  else {
573
573
  if (u.issues.length === 0)
574
574
  return u;
575
- c.push(u);
575
+ o.push(u);
576
576
  }
577
577
  }
578
- return a ? Promise.all(c).then((o) => Re(o, r, n, i)) : Re(c, r, n, i);
578
+ return a ? Promise.all(o).then((c) => Re(c, r, n, i)) : Re(o, r, n, i);
579
579
  };
580
580
  }), ct = /* @__PURE__ */ v("$ZodDiscriminatedUnion", (n, e) => {
581
581
  e.inclusive = !1, en.init(n, e);
@@ -586,10 +586,10 @@ const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
586
586
  const a = i._zod.propValues;
587
587
  if (!a || Object.keys(a).length === 0)
588
588
  throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);
589
- for (const [c, o] of Object.entries(a)) {
590
- r[c] || (r[c] = /* @__PURE__ */ new Set());
591
- for (const u of o)
592
- r[c].add(u);
589
+ for (const [o, c] of Object.entries(a)) {
590
+ r[o] || (r[o] = /* @__PURE__ */ new Set());
591
+ for (const u of c)
592
+ r[o].add(u);
593
593
  }
594
594
  }
595
595
  return r;
@@ -597,13 +597,13 @@ const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
597
597
  const s = je(() => {
598
598
  const r = e.options, i = /* @__PURE__ */ new Map();
599
599
  for (const a of r) {
600
- const c = a._zod.propValues?.[e.discriminator];
601
- if (!c || c.size === 0)
600
+ const o = a._zod.propValues?.[e.discriminator];
601
+ if (!o || o.size === 0)
602
602
  throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);
603
- for (const o of c) {
604
- if (i.has(o))
605
- throw new Error(`Duplicate discriminator value "${String(o)}"`);
606
- i.set(o, a);
603
+ for (const c of o) {
604
+ if (i.has(c))
605
+ throw new Error(`Duplicate discriminator value "${String(c)}"`);
606
+ i.set(c, a);
607
607
  }
608
608
  }
609
609
  return i;
@@ -617,8 +617,8 @@ const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
617
617
  input: a,
618
618
  inst: n
619
619
  }), r;
620
- const c = s.value.get(a?.[e.discriminator]);
621
- return c ? c._zod.run(r, i) : e.unionFallback ? t(r, i) : (r.issues.push({
620
+ const o = s.value.get(a?.[e.discriminator]);
621
+ return o ? o._zod.run(r, i) : e.unionFallback ? t(r, i) : (r.issues.push({
622
622
  code: "invalid_union",
623
623
  errors: [],
624
624
  note: "No matching discriminator",
@@ -641,53 +641,53 @@ const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
641
641
  const i = [], a = e.keyType._zod.values;
642
642
  if (a) {
643
643
  t.value = {};
644
- const c = /* @__PURE__ */ new Set();
644
+ const o = /* @__PURE__ */ new Set();
645
645
  for (const u of a)
646
646
  if (typeof u == "string" || typeof u == "number" || typeof u == "symbol") {
647
- c.add(typeof u == "number" ? u.toString() : u);
647
+ o.add(typeof u == "number" ? u.toString() : u);
648
648
  const d = e.valueType._zod.run({ value: r[u], issues: [] }, s);
649
649
  d instanceof Promise ? i.push(d.then((l) => {
650
650
  l.issues.length && t.issues.push(...Z(u, l.issues)), t.value[u] = l.value;
651
651
  })) : (d.issues.length && t.issues.push(...Z(u, d.issues)), t.value[u] = d.value);
652
652
  }
653
- let o;
653
+ let c;
654
654
  for (const u in r)
655
- c.has(u) || (o = o ?? [], o.push(u));
656
- o && o.length > 0 && t.issues.push({
655
+ o.has(u) || (c = c ?? [], c.push(u));
656
+ c && c.length > 0 && t.issues.push({
657
657
  code: "unrecognized_keys",
658
658
  input: r,
659
659
  inst: n,
660
- keys: o
660
+ keys: c
661
661
  });
662
662
  } else {
663
663
  t.value = {};
664
- for (const c of Reflect.ownKeys(r)) {
665
- if (c === "__proto__")
664
+ for (const o of Reflect.ownKeys(r)) {
665
+ if (o === "__proto__")
666
666
  continue;
667
- let o = e.keyType._zod.run({ value: c, issues: [] }, s);
668
- if (o instanceof Promise)
667
+ let c = e.keyType._zod.run({ value: o, issues: [] }, s);
668
+ if (c instanceof Promise)
669
669
  throw new Error("Async schemas not supported in object keys currently");
670
- if (typeof c == "string" && Ye.test(c) && o.issues.length) {
671
- const l = e.keyType._zod.run({ value: Number(c), issues: [] }, s);
670
+ if (typeof o == "string" && Ye.test(o) && c.issues.length) {
671
+ const l = e.keyType._zod.run({ value: Number(o), issues: [] }, s);
672
672
  if (l instanceof Promise)
673
673
  throw new Error("Async schemas not supported in object keys currently");
674
- l.issues.length === 0 && (o = l);
674
+ l.issues.length === 0 && (c = l);
675
675
  }
676
- if (o.issues.length) {
677
- e.mode === "loose" ? t.value[c] = r[c] : t.issues.push({
676
+ if (c.issues.length) {
677
+ e.mode === "loose" ? t.value[o] = r[o] : t.issues.push({
678
678
  code: "invalid_key",
679
679
  origin: "record",
680
- issues: o.issues.map((l) => Y(l, s, K())),
681
- input: c,
682
- path: [c],
680
+ issues: c.issues.map((l) => Y(l, s, K())),
681
+ input: o,
682
+ path: [o],
683
683
  inst: n
684
684
  });
685
685
  continue;
686
686
  }
687
- const d = e.valueType._zod.run({ value: r[c], issues: [] }, s);
687
+ const d = e.valueType._zod.run({ value: r[o], issues: [] }, s);
688
688
  d instanceof Promise ? i.push(d.then((l) => {
689
- l.issues.length && t.issues.push(...Z(c, l.issues)), t.value[o.value] = l.value;
690
- })) : (d.issues.length && t.issues.push(...Z(c, d.issues)), t.value[o.value] = d.value);
689
+ l.issues.length && t.issues.push(...Z(o, l.issues)), t.value[c.value] = l.value;
690
+ })) : (d.issues.length && t.issues.push(...Z(o, d.issues)), t.value[c.value] = d.value);
691
691
  }
692
692
  }
693
693
  return i.length ? Promise.all(i).then(() => t) : t;
@@ -1223,34 +1223,34 @@ function fn(n, e = {}) {
1223
1223
  }
1224
1224
  if (typeof TextDecoder < "u") return new TextDecoder(r).decode(t);
1225
1225
  const { byteLength: i } = t, a = r !== pe;
1226
- let c = "", o;
1226
+ let o = "", c;
1227
1227
  for (; s < i; ) {
1228
1228
  switch (r) {
1229
1229
  case te:
1230
- if (o = t.getUint8(s), o < 128) s++;
1231
- else if (o >= 194 && o <= 223) if (s + 1 < i) {
1230
+ if (c = t.getUint8(s), c < 128) s++;
1231
+ else if (c >= 194 && c <= 223) if (s + 1 < i) {
1232
1232
  const u = t.getUint8(s + 1);
1233
- u >= 128 && u <= 191 ? (o = (o & 31) << 6 | u & 63, s += 2) : s++;
1233
+ u >= 128 && u <= 191 ? (c = (c & 31) << 6 | u & 63, s += 2) : s++;
1234
1234
  } else s++;
1235
- else if (o >= 224 && o <= 239) if (s + 2 <= i - 1) {
1235
+ else if (c >= 224 && c <= 239) if (s + 2 <= i - 1) {
1236
1236
  const u = t.getUint8(s + 1), d = t.getUint8(s + 2);
1237
- u >= 128 && u <= 191 && d >= 128 && d <= 191 ? (o = (o & 15) << 12 | (u & 63) << 6 | d & 63, s += 3) : s++;
1237
+ u >= 128 && u <= 191 && d >= 128 && d <= 191 ? (c = (c & 15) << 12 | (u & 63) << 6 | d & 63, s += 3) : s++;
1238
1238
  } else s++;
1239
- else if (o >= 240 && o <= 244) if (s + 3 <= i - 1) {
1239
+ else if (c >= 240 && c <= 244) if (s + 3 <= i - 1) {
1240
1240
  const u = t.getUint8(s + 1), d = t.getUint8(s + 2), l = t.getUint8(s + 3);
1241
- u >= 128 && u <= 191 && d >= 128 && d <= 191 && l >= 128 && l <= 191 ? (o = (o & 7) << 18 | (u & 63) << 12 | (d & 63) << 6 | l & 63, s += 4) : s++;
1241
+ u >= 128 && u <= 191 && d >= 128 && d <= 191 && l >= 128 && l <= 191 ? (c = (c & 7) << 18 | (u & 63) << 12 | (d & 63) << 6 | l & 63, s += 4) : s++;
1242
1242
  } else s++;
1243
1243
  else s++;
1244
1244
  break;
1245
1245
  case pe:
1246
1246
  case Kt:
1247
1247
  case ze:
1248
- o = t.getUint16(s, a), s += 2;
1248
+ c = t.getUint16(s, a), s += 2;
1249
1249
  break;
1250
1250
  }
1251
- c += String.fromCodePoint(o);
1251
+ o += String.fromCodePoint(c);
1252
1252
  }
1253
- return c;
1253
+ return o;
1254
1254
  }
1255
1255
  function Yt(n) {
1256
1256
  return new TextEncoder().encode(n);
@@ -1300,16 +1300,16 @@ var A = class {
1300
1300
  r.setUint16(i, t);
1301
1301
  break;
1302
1302
  case 3: {
1303
- const a = (t & 16776960) >> 8, c = t & 255;
1304
- r.setUint16(i, a), r.setUint8(i + 2, c);
1303
+ const a = (t & 16776960) >> 8, o = t & 255;
1304
+ r.setUint16(i, a), r.setUint8(i + 2, o);
1305
1305
  break;
1306
1306
  }
1307
1307
  case 4:
1308
1308
  r.setUint32(i, t);
1309
1309
  break;
1310
1310
  case 8: {
1311
- const a = Math.floor(t / Math.pow(2, 32)), c = t - a * Math.pow(2, 32);
1312
- r.setUint32(i, a), r.setUint32(i + 4, c);
1311
+ const a = Math.floor(t / Math.pow(2, 32)), o = t - a * Math.pow(2, 32);
1312
+ r.setUint32(i, a), r.setUint32(i + 4, o);
1313
1313
  break;
1314
1314
  }
1315
1315
  }
@@ -1327,8 +1327,8 @@ var A = class {
1327
1327
  r.setInt32(i, t);
1328
1328
  break;
1329
1329
  case 8:
1330
- const a = Math.floor(t / Math.pow(2, 32)), c = t - a * Math.pow(2, 32);
1331
- r.setUint32(i, a), r.setUint32(i + 4, c);
1330
+ const a = Math.floor(t / Math.pow(2, 32)), o = t - a * Math.pow(2, 32);
1331
+ r.setUint32(i, a), r.setUint32(i + 4, o);
1332
1332
  break;
1333
1333
  }
1334
1334
  this.cursor += s;
@@ -1348,7 +1348,7 @@ var A = class {
1348
1348
  new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length;
1349
1349
  }, this.writeArray = (t, s, r, i) => {
1350
1350
  const a = s === L ? this.writeUint : s === ie ? this.writeTemplate : this.writeInt;
1351
- for (let c = 0; c < i; c++) a(t[c] ?? 0, r);
1351
+ for (let o = 0; o < i; o++) a(t[o] ?? 0, r);
1352
1352
  }, this.writeTemplate = (t, s) => {
1353
1353
  const i = Math.round(t * Math.pow(2, s === 4 ? 16 : 8));
1354
1354
  this.writeUint(i, s);
@@ -1506,55 +1506,55 @@ var cs = class wn {
1506
1506
  */
1507
1507
  constructor(e, t) {
1508
1508
  this.truncated = !1, this.slice = (s, r) => {
1509
- const i = new wn(new DataView(this.dataView.buffer, s, r), this.config), a = this.offset - s, c = r - a;
1510
- return this.offset += c, i.jump(a), i;
1509
+ const i = new wn(new DataView(this.dataView.buffer, s, r), this.config), a = this.offset - s, o = r - a;
1510
+ return this.offset += o, i.jump(a), i;
1511
1511
  }, this.read = (s, r = 0) => {
1512
1512
  const { dataView: i, offset: a } = this;
1513
- let c, o = r;
1513
+ let o, c = r;
1514
1514
  switch (s) {
1515
1515
  case L:
1516
- c = G(i, a, r);
1516
+ o = G(i, a, r);
1517
1517
  break;
1518
1518
  case De:
1519
- c = ss(i, a, r);
1519
+ o = ss(i, a, r);
1520
1520
  break;
1521
1521
  case ie:
1522
- c = rs(i, a, r);
1522
+ o = rs(i, a, r);
1523
1523
  break;
1524
1524
  case qe:
1525
- r === -1 ? (c = is(i, a), o = c.length + 1) : c = Ce(i, a, r);
1525
+ r === -1 ? (o = is(i, a), c = o.length + 1) : o = Ce(i, a, r);
1526
1526
  break;
1527
1527
  case xe:
1528
- c = ts(i, a, r), o = c.length;
1528
+ o = ts(i, a, r), c = o.length;
1529
1529
  break;
1530
1530
  case Ne:
1531
- r === -1 ? (c = os(i, a), o = c.length + 1) : c = as(i, a);
1531
+ r === -1 ? (o = os(i, a), c = o.length + 1) : o = as(i, a);
1532
1532
  break;
1533
1533
  default:
1534
- c = -1;
1534
+ o = -1;
1535
1535
  }
1536
- return this.offset += o, c;
1536
+ return this.offset += c, o;
1537
1537
  }, this.readUint = (s) => this.read(L, s), this.readInt = (s) => this.read(De, s), this.readString = (s) => this.read(qe, s), this.readTemplate = (s) => this.read(ie, s), this.readData = (s) => this.read(xe, s), this.readUtf8 = (s) => this.read(Ne, s), this.readFullBox = () => ({
1538
1538
  version: this.readUint(1),
1539
1539
  flags: this.readUint(3)
1540
1540
  }), this.readArray = (s, r, i) => {
1541
1541
  const a = [];
1542
- for (let c = 0; c < i; c++) a.push(this.read(s, r));
1542
+ for (let o = 0; o < i; o++) a.push(this.read(s, r));
1543
1543
  return a;
1544
1544
  }, this.jump = (s) => {
1545
1545
  this.offset += s;
1546
1546
  }, this.readBox = () => {
1547
1547
  const { dataView: s, offset: r } = this;
1548
1548
  let i = 0;
1549
- const a = G(s, r, 4), c = Ce(s, r + 4, 4), o = {
1549
+ const a = G(s, r, 4), o = Ce(s, r + 4, 4), c = {
1550
1550
  size: a,
1551
- type: c
1551
+ type: o
1552
1552
  };
1553
- i += 8, o.size === 1 && (o.largesize = G(s, r + i, 8), i += 8);
1554
- const u = o.size === 0 ? this.bytesRemaining : o.largesize ?? o.size;
1553
+ i += 8, c.size === 1 && (c.largesize = G(s, r + i, 8), i += 8);
1554
+ const u = c.size === 0 ? this.bytesRemaining : c.largesize ?? c.size;
1555
1555
  if (this.cursor + u > s.byteLength)
1556
1556
  throw this.truncated = !0, new Error("Truncated box");
1557
- return this.jump(i), c === "uuid" && (o.usertype = this.readArray("uint", 1, 16)), o.view = this.slice(r, u), o;
1557
+ return this.jump(i), o === "uuid" && (c.usertype = this.readArray("uint", 1, 16)), c.view = this.slice(r, u), c;
1558
1558
  }, this.readBoxes = (s = -1) => {
1559
1559
  const r = [];
1560
1560
  for (const i of this)
@@ -1613,7 +1613,7 @@ var cs = class wn {
1613
1613
  const t = this.readBox(), { type: s, view: r } = t, i = e[s] || e[s.trim()];
1614
1614
  if (i && Object.assign(t, i(r, s)), mn(t) && !t.boxes) {
1615
1615
  const a = [];
1616
- for (const c of r) a.push(c);
1616
+ for (const o of r) a.push(o);
1617
1617
  t.boxes = a;
1618
1618
  }
1619
1619
  yield t;
@@ -1672,8 +1672,8 @@ function ms(n) {
1672
1672
  let r, i;
1673
1673
  t & 1 && (r = n.readInt(4)), t & 4 && (i = n.readUint(4));
1674
1674
  const a = n.readEntries(s, () => {
1675
- const c = {};
1676
- return t & 256 && (c.sampleDuration = n.readUint(4)), t & 512 && (c.sampleSize = n.readUint(4)), t & 1024 && (c.sampleFlags = n.readUint(4)), t & 2048 && (c.sampleCompositionTimeOffset = e === 1 ? n.readInt(4) : n.readUint(4)), c;
1675
+ const o = {};
1676
+ return t & 256 && (o.sampleDuration = n.readUint(4)), t & 512 && (o.sampleSize = n.readUint(4)), t & 1024 && (o.sampleFlags = n.readUint(4)), t & 2048 && (o.sampleCompositionTimeOffset = e === 1 ? n.readInt(4) : n.readUint(4)), o;
1677
1677
  });
1678
1678
  return {
1679
1679
  type: "trun",
@@ -1686,8 +1686,8 @@ function ms(n) {
1686
1686
  };
1687
1687
  }
1688
1688
  function ps(n, e) {
1689
- const i = n.entries.length, { bytes: a, size: c } = ye(n.entries, e), o = new A("dref", 16 + c);
1690
- return o.writeFullBox(n.version, n.flags), o.writeUint(i, 4), o.writeBytes(a), o;
1689
+ const i = n.entries.length, { bytes: a, size: o } = ye(n.entries, e), c = new A("dref", 16 + o);
1690
+ return c.writeFullBox(n.version, n.flags), c.writeUint(i, 4), c.writeBytes(a), c;
1691
1691
  }
1692
1692
  function ws(n) {
1693
1693
  const r = n.compatibleBrands.length * 4, i = new A("ftyp", 16 + r);
@@ -1696,8 +1696,8 @@ function ws(n) {
1696
1696
  return i;
1697
1697
  }
1698
1698
  function vs(n) {
1699
- const a = n.name.length + 1, c = new A("hdlr", 32 + a);
1700
- return c.writeFullBox(n.version, n.flags), c.writeUint(n.preDefined, 4), c.writeString(n.handlerType), c.writeArray(n.reserved, L, 4, 3), c.writeTerminatedString(n.name), c;
1699
+ const a = n.name.length + 1, o = new A("hdlr", 32 + a);
1700
+ return o.writeFullBox(n.version, n.flags), o.writeUint(n.preDefined, 4), o.writeString(n.handlerType), o.writeArray(n.reserved, L, 4, 3), o.writeTerminatedString(n.name), o;
1701
1701
  }
1702
1702
  function bs(n) {
1703
1703
  const e = new A("mdat", 8 + n.data.length);
@@ -1722,8 +1722,8 @@ function Ss(n) {
1722
1722
  return e.writeFullBox(n.version, n.flags), e.writeUint(n.balance, 2), e.writeUint(n.reserved, 2), e;
1723
1723
  }
1724
1724
  function ks(n, e) {
1725
- const i = n.entries.length, { bytes: a, size: c } = ye(n.entries, e), o = new A("stsd", 16 + c);
1726
- return o.writeFullBox(n.version, n.flags), o.writeUint(i, 4), o.writeBytes(a), o;
1725
+ const i = n.entries.length, { bytes: a, size: o } = ye(n.entries, e), c = new A("stsd", 16 + o);
1726
+ return c.writeFullBox(n.version, n.flags), c.writeUint(i, 4), c.writeBytes(a), c;
1727
1727
  }
1728
1728
  function As(n) {
1729
1729
  const r = n.entryCount * 8, i = new A("stts", 16 + r);
@@ -1737,7 +1737,7 @@ function Is(n) {
1737
1737
  return i.writeFullBox(n.version, n.flags), i.writeUint(n.baseMediaDecodeTime, e), i;
1738
1738
  }
1739
1739
  function Rs(n) {
1740
- const r = n.flags & 1 ? 8 : 0, i = n.flags & 2 ? 4 : 0, a = n.flags & 8 ? 4 : 0, c = n.flags & 16 ? 4 : 0, o = n.flags & 32 ? 4 : 0, u = new A("tfhd", 16 + r + i + a + c + o);
1740
+ const r = n.flags & 1 ? 8 : 0, i = n.flags & 2 ? 4 : 0, a = n.flags & 8 ? 4 : 0, o = n.flags & 16 ? 4 : 0, c = n.flags & 32 ? 4 : 0, u = new A("tfhd", 16 + r + i + a + o + c);
1741
1741
  return u.writeFullBox(n.version, n.flags), u.writeUint(n.trackId, 4), n.flags & 1 && u.writeUint(n.baseDataOffset ?? 0, 8), n.flags & 2 && u.writeUint(n.sampleDescriptionIndex ?? 0, 4), n.flags & 8 && u.writeUint(n.defaultSampleDuration ?? 0, 4), n.flags & 16 && u.writeUint(n.defaultSampleSize ?? 0, 4), n.flags & 32 && u.writeUint(n.defaultSampleFlags ?? 0, 4), u;
1742
1742
  }
1743
1743
  function Es(n) {
@@ -1752,11 +1752,11 @@ function Us(n) {
1752
1752
  const r = n.flags & 1 ? 4 : 0, i = n.flags & 4 ? 4 : 0;
1753
1753
  let a = 0;
1754
1754
  n.flags & 256 && (a += 4), n.flags & 512 && (a += 4), n.flags & 1024 && (a += 4), n.flags & 2048 && (a += 4);
1755
- const c = a * n.sampleCount, o = new A("trun", 16 + r + i + c);
1756
- o.writeFullBox(n.version, n.flags), o.writeUint(n.sampleCount, 4), n.flags & 1 && o.writeUint(n.dataOffset ?? 0, 4), n.flags & 4 && o.writeUint(n.firstSampleFlags ?? 0, 4);
1755
+ const o = a * n.sampleCount, c = new A("trun", 16 + r + i + o);
1756
+ c.writeFullBox(n.version, n.flags), c.writeUint(n.sampleCount, 4), n.flags & 1 && c.writeUint(n.dataOffset ?? 0, 4), n.flags & 4 && c.writeUint(n.firstSampleFlags ?? 0, 4);
1757
1757
  for (const u of n.samples)
1758
- n.flags & 256 && o.writeUint(u.sampleDuration ?? 0, 4), n.flags & 512 && o.writeUint(u.sampleSize ?? 0, 4), n.flags & 1024 && o.writeUint(u.sampleFlags ?? 0, 4), n.flags & 2048 && o.writeUint(u.sampleCompositionTimeOffset ?? 0, 4);
1759
- return o;
1758
+ n.flags & 256 && c.writeUint(u.sampleDuration ?? 0, 4), n.flags & 512 && c.writeUint(u.sampleSize ?? 0, 4), n.flags & 1024 && c.writeUint(u.sampleFlags ?? 0, 4), n.flags & 2048 && c.writeUint(u.sampleCompositionTimeOffset ?? 0, 4);
1759
+ return c;
1760
1760
  }
1761
1761
  function Ms(n) {
1762
1762
  const s = n.location.length + 1, r = new A("url ", 12 + s);
@@ -1796,7 +1796,7 @@ function yn(n, e) {
1796
1796
  return (X(t, ne("tfdt"))?.baseMediaDecodeTime ?? 0) * 1e6 / e;
1797
1797
  }
1798
1798
  function _n(n, e) {
1799
- const t = vn(gn(n), { readers: bn }), r = X(t, ne("tfdt"))?.baseMediaDecodeTime ?? 0, i = X(t, ne("tfhd")), a = i?.defaultSampleDuration ?? 0, c = i?.defaultSampleSize ?? 0, o = i?.defaultSampleFlags ?? 0, u = X(t, ne("trun"));
1799
+ const t = vn(gn(n), { readers: bn }), r = X(t, ne("tfdt"))?.baseMediaDecodeTime ?? 0, i = X(t, ne("tfhd")), a = i?.defaultSampleDuration ?? 0, o = i?.defaultSampleSize ?? 0, c = i?.defaultSampleFlags ?? 0, u = X(t, ne("trun"));
1800
1800
  if (!u)
1801
1801
  throw new Error("No trun box found in data segment");
1802
1802
  const d = X(t, ne("mdat"));
@@ -1808,7 +1808,7 @@ function _n(n, e) {
1808
1808
  const f = [];
1809
1809
  let w = 0, b = r;
1810
1810
  for (let g = 0; g < u.sampleCount; g++) {
1811
- const R = u.samples[g] ?? {}, O = R.sampleSize ?? c, z = R.sampleDuration ?? a;
1811
+ const R = u.samples[g] ?? {}, O = R.sampleSize ?? o, z = R.sampleDuration ?? a;
1812
1812
  if (O <= 0)
1813
1813
  throw new Error(`Invalid sample size ${O} for sample ${g} in trun`);
1814
1814
  if (z <= 0)
@@ -1817,7 +1817,7 @@ function _n(n, e) {
1817
1817
  throw new Error(
1818
1818
  `Sample ${g} would overflow mdat: offset=${w}, size=${O}, mdatLength=${l.length}`
1819
1819
  );
1820
- const $ = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : R.sampleFlags ?? o, D = R.sampleCompositionTimeOffset ?? 0, x = new Uint8Array(l.slice(w, w + O));
1820
+ const $ = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : R.sampleFlags ?? c, D = R.sampleCompositionTimeOffset ?? 0, x = new Uint8Array(l.slice(w, w + O));
1821
1821
  w += O;
1822
1822
  const C = b + D, F = Math.round(C * 1e6 / e), k = $ === 0 || ($ & 65536) === 0;
1823
1823
  f.push({
@@ -1878,20 +1878,20 @@ function An() {
1878
1878
  return _e("stco", 0, 0, n);
1879
1879
  }
1880
1880
  function zs(n, e, t) {
1881
- const s = 8 + t.length, i = 8 + (78 + s), a = new Uint8Array(i), c = new DataView(a.buffer);
1882
- let o = 0;
1883
- return c.setUint32(o, i, !1), o += 4, a[o++] = 97, a[o++] = 118, a[o++] = 99, a[o++] = 49, o += 6, c.setUint16(o, 1, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, o += 12, c.setUint16(o, n, !1), o += 2, c.setUint16(o, e, !1), o += 2, c.setUint32(o, 4718592, !1), o += 4, c.setUint32(o, 4718592, !1), o += 4, c.setUint32(o, 0, !1), o += 4, c.setUint16(o, 1, !1), o += 2, o += 32, c.setUint16(o, 24, !1), o += 2, c.setUint16(o, 65535, !1), o += 2, c.setUint32(o, s, !1), o += 4, a[o++] = 97, a[o++] = 118, a[o++] = 99, a[o++] = 67, a.set(t, o), a;
1881
+ const s = 8 + t.length, i = 8 + (78 + s), a = new Uint8Array(i), o = new DataView(a.buffer);
1882
+ let c = 0;
1883
+ return o.setUint32(c, i, !1), c += 4, a[c++] = 97, a[c++] = 118, a[c++] = 99, a[c++] = 49, c += 6, o.setUint16(c, 1, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint16(c, 0, !1), c += 2, c += 12, o.setUint16(c, n, !1), c += 2, o.setUint16(c, e, !1), c += 2, o.setUint32(c, 4718592, !1), c += 4, o.setUint32(c, 4718592, !1), c += 4, o.setUint32(c, 0, !1), c += 4, o.setUint16(c, 1, !1), c += 2, c += 32, o.setUint16(c, 24, !1), c += 2, o.setUint16(c, 65535, !1), c += 2, o.setUint32(c, s, !1), c += 4, a[c++] = 97, a[c++] = 118, a[c++] = 99, a[c++] = 67, a.set(t, c), a;
1884
1884
  }
1885
1885
  function Fe(n) {
1886
1886
  const { codedWidth: e, codedHeight: t, description: s, container: r } = n;
1887
1887
  if (!e || !t || !s)
1888
1888
  throw new Error("Missing required fields to create video init segment");
1889
- const i = r.kind === "cmaf" ? r.timescale : 1e6, a = r.kind === "cmaf" ? r.trackId : 1, c = {
1889
+ const i = r.kind === "cmaf" ? r.timescale : 1e6, a = r.kind === "cmaf" ? r.trackId : 1, o = {
1890
1890
  type: "ftyp",
1891
1891
  majorBrand: "isom",
1892
1892
  minorVersion: 512,
1893
1893
  compatibleBrands: ["isom", "iso6", "mp41"]
1894
- }, o = {
1894
+ }, c = {
1895
1895
  type: "mvhd",
1896
1896
  version: 0,
1897
1897
  flags: 0,
@@ -1982,9 +1982,9 @@ function Fe(n) {
1982
1982
  flags: 0,
1983
1983
  entryCount: 0,
1984
1984
  entries: []
1985
- }, $ = Sn(), D = kn(), x = An(), me = se([c, {
1985
+ }, $ = Sn(), D = kn(), x = An(), me = se([o, {
1986
1986
  type: "moov",
1987
- boxes: [o, {
1987
+ boxes: [c, {
1988
1988
  type: "trak",
1989
1989
  boxes: [u, {
1990
1990
  type: "mdia",
@@ -2017,7 +2017,7 @@ function Fe(n) {
2017
2017
  return oe;
2018
2018
  }
2019
2019
  function Ve(n) {
2020
- const { sampleRate: e, numberOfChannels: t, description: s, codec: r, container: i } = n, a = i.kind === "cmaf" ? i.timescale : 1e6, c = i.kind === "cmaf" ? i.trackId : 1, o = {
2020
+ const { sampleRate: e, numberOfChannels: t, description: s, codec: r, container: i } = n, a = i.kind === "cmaf" ? i.timescale : 1e6, o = i.kind === "cmaf" ? i.trackId : 1, c = {
2021
2021
  type: "ftyp",
2022
2022
  majorBrand: "isom",
2023
2023
  minorVersion: 512,
@@ -2036,14 +2036,14 @@ function Ve(n) {
2036
2036
  reserved2: [0, 0],
2037
2037
  matrix: he,
2038
2038
  preDefined: [0, 0, 0, 0, 0, 0],
2039
- nextTrackId: c + 1
2039
+ nextTrackId: o + 1
2040
2040
  }, d = {
2041
2041
  type: "tkhd",
2042
2042
  version: 0,
2043
2043
  flags: 3,
2044
2044
  creationTime: 0,
2045
2045
  modificationTime: 0,
2046
- trackId: c,
2046
+ trackId: o,
2047
2047
  reserved1: 0,
2048
2048
  duration: 0,
2049
2049
  reserved2: [0, 0],
@@ -2106,7 +2106,7 @@ function Ve(n) {
2106
2106
  flags: 0,
2107
2107
  entryCount: 0,
2108
2108
  entries: []
2109
- }, D = Sn(), x = kn(), C = An(), ae = se([o, {
2109
+ }, D = Sn(), x = kn(), C = An(), ae = se([c, {
2110
2110
  type: "moov",
2111
2111
  boxes: [u, {
2112
2112
  type: "trak",
@@ -2127,7 +2127,7 @@ function Ve(n) {
2127
2127
  type: "trex",
2128
2128
  version: 0,
2129
2129
  flags: 0,
2130
- trackId: c,
2130
+ trackId: o,
2131
2131
  defaultSampleDescriptionIndex: 1,
2132
2132
  defaultSampleDuration: 0,
2133
2133
  defaultSampleSize: 0,
@@ -2148,14 +2148,14 @@ function Ns(n, e, t, s) {
2148
2148
  throw new Error(`Unsupported audio codec: ${n}`);
2149
2149
  }
2150
2150
  function qs(n, e, t) {
2151
- const s = Cs(n, e, t), i = 8 + (28 + s.length), a = new Uint8Array(i), c = new DataView(a.buffer);
2152
- let o = 0;
2153
- return c.setUint32(o, i, !1), o += 4, a[o++] = 109, a[o++] = 112, a[o++] = 52, a[o++] = 97, o += 6, c.setUint16(o, 1, !1), o += 2, o += 8, c.setUint16(o, e, !1), o += 2, c.setUint16(o, 16, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint32(o, n * 65536, !1), o += 4, a.set(s, o), a;
2151
+ const s = Cs(n, e, t), i = 8 + (28 + s.length), a = new Uint8Array(i), o = new DataView(a.buffer);
2152
+ let c = 0;
2153
+ return o.setUint32(c, i, !1), c += 4, a[c++] = 109, a[c++] = 112, a[c++] = 52, a[c++] = 97, c += 6, o.setUint16(c, 1, !1), c += 2, c += 8, o.setUint16(c, e, !1), c += 2, o.setUint16(c, 16, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint32(c, n * 65536, !1), c += 4, a.set(s, c), a;
2154
2154
  }
2155
2155
  function Ds(n, e, t) {
2156
- const s = Fs(e, n, t), i = 8 + (28 + s.length), a = new Uint8Array(i), c = new DataView(a.buffer);
2157
- let o = 0;
2158
- return c.setUint32(o, i, !1), o += 4, a[o++] = 79, a[o++] = 112, a[o++] = 117, a[o++] = 115, o += 6, c.setUint16(o, 1, !1), o += 2, o += 8, c.setUint16(o, e, !1), o += 2, c.setUint16(o, 16, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint32(o, n * 65536, !1), o += 4, a.set(s, o), a;
2156
+ const s = Fs(e, n, t), i = 8 + (28 + s.length), a = new Uint8Array(i), o = new DataView(a.buffer);
2157
+ let c = 0;
2158
+ return o.setUint32(c, i, !1), c += 4, a[c++] = 79, a[c++] = 112, a[c++] = 117, a[c++] = 115, c += 6, o.setUint16(c, 1, !1), c += 2, c += 8, o.setUint16(c, e, !1), c += 2, o.setUint16(c, 16, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint32(c, n * 65536, !1), c += 4, a.set(s, c), a;
2159
2159
  }
2160
2160
  function xs(n, e) {
2161
2161
  const s = {
@@ -2176,21 +2176,21 @@ function xs(n, e) {
2176
2176
  return new Uint8Array([i, a]);
2177
2177
  }
2178
2178
  function Cs(n, e, t) {
2179
- const s = t ? q(t) : xs(n, e), r = s.length, i = 15 + r, a = 5 + i + 3, c = 14 + a, o = new Uint8Array(c), u = new DataView(o.buffer);
2179
+ const s = t ? q(t) : xs(n, e), r = s.length, i = 15 + r, a = 5 + i + 3, o = 14 + a, c = new Uint8Array(o), u = new DataView(c.buffer);
2180
2180
  let d = 0;
2181
- return u.setUint32(d, c, !1), d += 4, o[d++] = 101, o[d++] = 115, o[d++] = 100, o[d++] = 115, u.setUint32(d, 0, !1), d += 4, o[d++] = 3, o[d++] = a, u.setUint16(d, 0, !1), d += 2, o[d++] = 0, o[d++] = 4, o[d++] = i, o[d++] = 64, o[d++] = 21, o[d++] = 0, o[d++] = 0, o[d++] = 0, u.setUint32(d, 0, !1), d += 4, u.setUint32(d, 0, !1), d += 4, o[d++] = 5, o[d++] = r, o.set(s, d), d += r, o[d++] = 6, o[d++] = 1, o[d++] = 2, o;
2181
+ return u.setUint32(d, o, !1), d += 4, c[d++] = 101, c[d++] = 115, c[d++] = 100, c[d++] = 115, u.setUint32(d, 0, !1), d += 4, c[d++] = 3, c[d++] = a, u.setUint16(d, 0, !1), d += 2, c[d++] = 0, c[d++] = 4, c[d++] = i, c[d++] = 64, c[d++] = 21, c[d++] = 0, c[d++] = 0, c[d++] = 0, u.setUint32(d, 0, !1), d += 4, u.setUint32(d, 0, !1), d += 4, c[d++] = 5, c[d++] = r, c.set(s, d), d += r, c[d++] = 6, c[d++] = 1, c[d++] = 2, c;
2182
2182
  }
2183
2183
  function Fs(n, e, t) {
2184
2184
  if (t) {
2185
- const c = q(t), o = 8 + c.length, u = new Uint8Array(o);
2186
- return new DataView(u.buffer).setUint32(0, o, !1), u[4] = 100, u[5] = 79, u[6] = 112, u[7] = 115, u.set(c, 8), u;
2185
+ const o = q(t), c = 8 + o.length, u = new Uint8Array(c);
2186
+ return new DataView(u.buffer).setUint32(0, c, !1), u[4] = 100, u[5] = 79, u[6] = 112, u[7] = 115, u.set(o, 8), u;
2187
2187
  }
2188
2188
  const s = 19, r = new Uint8Array(s), i = new DataView(r.buffer);
2189
2189
  let a = 0;
2190
2190
  return i.setUint32(a, s, !1), a += 4, r[a++] = 100, r[a++] = 79, r[a++] = 112, r[a++] = 115, r[a++] = 0, r[a++] = n, i.setUint16(a, 312, !1), a += 2, i.setUint32(a, e, !1), a += 4, i.setInt16(a, 0, !1), a += 2, r[a++] = 0, r;
2191
2191
  }
2192
2192
  function In(n) {
2193
- const { data: e, timestamp: t, duration: s, keyframe: r, sequence: i, trackId: a = 1 } = n, c = r ? 33554432 : 16842752, o = {
2193
+ const { data: e, timestamp: t, duration: s, keyframe: r, sequence: i, trackId: a = 1 } = n, o = r ? 33554432 : 16842752, c = {
2194
2194
  type: "mfhd",
2195
2195
  version: 0,
2196
2196
  flags: 0,
@@ -2217,12 +2217,12 @@ function In(n) {
2217
2217
  {
2218
2218
  sampleDuration: s,
2219
2219
  sampleSize: e.byteLength,
2220
- sampleFlags: c
2220
+ sampleFlags: o
2221
2221
  }
2222
2222
  ]
2223
2223
  }, w = {
2224
2224
  type: "moof",
2225
- boxes: [o, {
2225
+ boxes: [c, {
2226
2226
  type: "traf",
2227
2227
  boxes: [u, d, l]
2228
2228
  }]
@@ -2310,10 +2310,10 @@ class J {
2310
2310
  for (; this.#e.length >= 2; ) {
2311
2311
  const t = _.Time.Micro.fromMilli(this.#t.peek());
2312
2312
  let s, r;
2313
- for (const c of this.#e) {
2314
- if (c.latest === void 0) continue;
2315
- const o = c.frames.at(0)?.timestamp ?? c.latest;
2316
- (s === void 0 || o < s) && (s = o), (r === void 0 || c.latest > r) && (r = c.latest);
2313
+ for (const o of this.#e) {
2314
+ if (o.latest === void 0) continue;
2315
+ const c = o.frames.at(0)?.timestamp ?? o.latest;
2316
+ (s === void 0 || c < s) && (s = c), (r === void 0 || o.latest > r) && (r = o.latest);
2317
2317
  }
2318
2318
  if (s === void 0 || r === void 0 || r - s <= t) break;
2319
2319
  const a = this.#e.shift();
@@ -2359,8 +2359,8 @@ class J {
2359
2359
  for (const s of this.#e) {
2360
2360
  const r = s.frames.at(0);
2361
2361
  if (!r || s.latest === void 0) continue;
2362
- const i = _.Time.Milli.fromMicro(r.timestamp), a = _.Time.Milli.fromMicro(s.latest), c = e.at(-1), o = t?.done && t.consumer.sequence + 1 === s.consumer.sequence;
2363
- c && (c.end >= i || o) ? c.end = _.Time.Milli.max(c.end, a) : e.push({ start: i, end: a }), t = s;
2362
+ const i = _.Time.Milli.fromMicro(r.timestamp), a = _.Time.Milli.fromMicro(s.latest), o = e.at(-1), c = t?.done && t.consumer.sequence + 1 === s.consumer.sequence;
2363
+ o && (o.end >= i || c) ? o.end = _.Time.Milli.max(o.end, a) : e.push({ start: i, end: a }), t = s;
2364
2364
  }
2365
2365
  this.#i.set(e);
2366
2366
  }
@@ -5557,17 +5557,17 @@ let $s = class {
5557
5557
  channelCountMode: "explicit"
5558
5558
  });
5559
5559
  e.cleanup(() => a.disconnect());
5560
- const c = {
5560
+ const o = {
5561
5561
  type: "init",
5562
5562
  rate: s,
5563
5563
  channels: r,
5564
5564
  latency: this.source.sync.buffer.peek()
5565
5565
  // Updated reactively via #runLatency
5566
5566
  };
5567
- a.port.postMessage(c), a.port.onmessage = (o) => {
5568
- if (o.data.type === "state") {
5569
- const u = p.Milli.fromMicro(o.data.timestamp);
5570
- this.#s.set(u), this.#i.set(o.data.stalled), this.#v(u);
5567
+ a.port.postMessage(o), a.port.onmessage = (c) => {
5568
+ if (c.data.type === "state") {
5569
+ const u = p.Milli.fromMicro(c.data.timestamp);
5570
+ this.#s.set(u), this.#i.set(c.data.stalled), this.#v(u);
5571
5571
  }
5572
5572
  }, e.set(this.#t, a);
5573
5573
  });
@@ -5597,20 +5597,20 @@ let $s = class {
5597
5597
  if (!i) return;
5598
5598
  const a = e.get(s.active);
5599
5599
  if (!a) return;
5600
- const c = a.subscribe(r, W.audio);
5601
- e.cleanup(() => c.close()), i.container.kind === "cmaf" ? this.#p(e, c, i) : this.#m(e, c, i);
5600
+ const o = a.subscribe(r, W.audio);
5601
+ e.cleanup(() => o.close()), i.container.kind === "cmaf" ? this.#p(e, o, i) : this.#m(e, o, i);
5602
5602
  }
5603
5603
  #m(e, t, s) {
5604
5604
  const r = new J(t, {
5605
5605
  latency: this.source.sync.buffer
5606
5606
  });
5607
5607
  e.cleanup(() => r.close()), e.run((i) => {
5608
- const a = i.get(r.buffered), c = i.get(this.#a);
5609
- this.#o.update(() => Gs(a, c));
5608
+ const a = i.get(r.buffered), o = i.get(this.#a);
5609
+ this.#o.update(() => Gs(a, o));
5610
5610
  }), e.spawn(async () => {
5611
5611
  if (!await Be()) return;
5612
5612
  let a = 0;
5613
- const c = new AudioDecoder({
5613
+ const o = new AudioDecoder({
5614
5614
  output: (u) => {
5615
5615
  if (a++, a <= 3) {
5616
5616
  u.close();
@@ -5621,12 +5621,12 @@ let $s = class {
5621
5621
  error: (u) => console.error(u)
5622
5622
  });
5623
5623
  e.cleanup(() => {
5624
- c.state !== "closed" && c.close();
5624
+ o.state !== "closed" && o.close();
5625
5625
  });
5626
- const o = s.description ? q(s.description) : void 0;
5627
- for (c.configure({
5626
+ const c = s.description ? q(s.description) : void 0;
5627
+ for (o.configure({
5628
5628
  ...s,
5629
- description: o
5629
+ description: c
5630
5630
  }); ; ) {
5631
5631
  const u = await r.next();
5632
5632
  if (!u) break;
@@ -5641,7 +5641,7 @@ let $s = class {
5641
5641
  data: d.data,
5642
5642
  timestamp: d.timestamp
5643
5643
  });
5644
- c.decode(f);
5644
+ o.decode(f);
5645
5645
  }
5646
5646
  });
5647
5647
  }
@@ -5649,28 +5649,28 @@ let $s = class {
5649
5649
  if (s.container.kind !== "cmaf") return;
5650
5650
  const { timescale: r } = s.container, i = s.description ? q(s.description) : void 0;
5651
5651
  e.run((a) => {
5652
- const c = a.get(this.#a);
5653
- this.#o.update(() => c);
5652
+ const o = a.get(this.#a);
5653
+ this.#o.update(() => o);
5654
5654
  }), e.spawn(async () => {
5655
5655
  if (!await Be()) return;
5656
- const c = new AudioDecoder({
5657
- output: (o) => this.#h(o),
5658
- error: (o) => console.error(o)
5656
+ const o = new AudioDecoder({
5657
+ output: (c) => this.#h(c),
5658
+ error: (c) => console.error(c)
5659
5659
  });
5660
5660
  for (e.cleanup(() => {
5661
- c.state !== "closed" && c.close();
5662
- }), c.configure({
5661
+ o.state !== "closed" && o.close();
5662
+ }), o.configure({
5663
5663
  codec: s.codec,
5664
5664
  sampleRate: s.sampleRate,
5665
5665
  numberOfChannels: s.numberOfChannels,
5666
5666
  description: i
5667
5667
  }); ; ) {
5668
- const o = await t.nextGroup();
5669
- if (!o) break;
5668
+ const c = await t.nextGroup();
5669
+ if (!c) break;
5670
5670
  e.spawn(async () => {
5671
5671
  try {
5672
5672
  for (; ; ) {
5673
- const u = await o.readFrame();
5673
+ const u = await c.readFrame();
5674
5674
  if (!u) break;
5675
5675
  const d = _n(u, r);
5676
5676
  for (const l of d) {
@@ -5683,11 +5683,11 @@ let $s = class {
5683
5683
  data: l.data,
5684
5684
  timestamp: l.timestamp
5685
5685
  });
5686
- c.decode(w);
5686
+ o.decode(w);
5687
5687
  }
5688
5688
  }
5689
5689
  } finally {
5690
- o.close();
5690
+ c.close();
5691
5691
  }
5692
5692
  });
5693
5693
  }
@@ -5699,16 +5699,16 @@ let $s = class {
5699
5699
  e.close();
5700
5700
  return;
5701
5701
  }
5702
- const i = e.numberOfFrames / e.sampleRate * 1e6, a = p.Milli.fromMicro(i), c = p.Milli.add(s, a);
5703
- this.#w(s, c);
5704
- const o = [];
5702
+ const i = e.numberOfFrames / e.sampleRate * 1e6, a = p.Milli.fromMicro(i), o = p.Milli.add(s, a);
5703
+ this.#w(s, o);
5704
+ const c = [];
5705
5705
  for (let d = 0; d < e.numberOfChannels; d++) {
5706
5706
  const l = new Float32Array(e.numberOfFrames);
5707
- e.copyTo(l, { format: "f32-planar", planeIndex: d }), o.push(l);
5707
+ e.copyTo(l, { format: "f32-planar", planeIndex: d }), c.push(l);
5708
5708
  }
5709
5709
  const u = {
5710
5710
  type: "data",
5711
- data: o,
5711
+ data: c,
5712
5712
  timestamp: t
5713
5713
  };
5714
5714
  r.port.postMessage(
@@ -5831,8 +5831,8 @@ class Rn {
5831
5831
  e.interval(() => {
5832
5832
  const i = t.buffered;
5833
5833
  if (i.length === 0) return;
5834
- const c = i.end(i.length - 1) - r, o = c - t.currentTime;
5835
- (o > 0.1 || o < -0.1) && (console.warn("seeking", o > 0 ? "forward" : "backward", Math.abs(o).toFixed(3), "seconds"), t.currentTime = c);
5834
+ const o = i.end(i.length - 1) - r, c = o - t.currentTime;
5835
+ (c > 0.1 || c < -0.1) && (console.warn("seeking", c > 0 ? "forward" : "backward", Math.abs(c).toFixed(3), "seconds"), t.currentTime = o);
5836
5836
  }, 100);
5837
5837
  }
5838
5838
  #i(e) {
@@ -5894,9 +5894,7 @@ class Se {
5894
5894
  #e;
5895
5895
  // The media timestamp of the most recently received frame.
5896
5896
  timestamp = new h(void 0);
5897
- // Per-label tracking: minimum reference and late-frame stats.
5898
- // The effective #reference is the max across all labels,
5899
- // ensuring the slowest track sets the pace (late audio stalls early video).
5897
+ // Per-label late-frame tracking: accumulate count and max lateness, flush on recovery.
5900
5898
  #r = /* @__PURE__ */ new Map();
5901
5899
  // RTT signal from the connection (PROBE or getStats).
5902
5900
  rtt;
@@ -5928,27 +5926,26 @@ class Se {
5928
5926
  const t = e.get(this.jitter), s = e.get(this.video) ?? p.Milli.zero, r = e.get(this.audio) ?? p.Milli.zero, i = p.Milli.add(p.Milli.max(s, r), t);
5929
5927
  this.#t.set(i), this.#e.resolve(), this.#e = Promise.withResolvers();
5930
5928
  }
5931
- // Update the reference if this is the earliest frame we've seen for this label, relative to its timestamp.
5932
- // The effective reference is the max across all labels so the slowest track sets the pace.
5929
+ // Update the reference if this is the earliest frame we've seen, relative to its timestamp.
5933
5930
  received(e, t = "") {
5934
- this.timestamp.update((o) => o === void 0 || e > o ? e : o);
5931
+ this.timestamp.update((a) => a === void 0 || e > a ? e : a);
5935
5932
  const s = p.Milli.now(), r = p.Milli.sub(s, e), i = this.#n.peek();
5936
- let a = this.#r.get(t);
5937
- if (a || (a = { ref: r, lateCount: 0, lateMaxMs: 0 }, this.#r.set(t, a)), i !== void 0) {
5938
- const o = p.Milli.add(p.Milli.sub(i, r), this.#t.peek());
5939
- if (o < 0)
5940
- a.lateCount++, a.lateMaxMs = Math.max(a.lateMaxMs, -o);
5941
- else if (a.lateCount > 0) {
5942
- const u = t ? `sync[${t}]` : "sync", d = Se.#o(a.lateMaxMs);
5943
- console.debug(`${u}: ${a.lateCount} late frame(s), max ${d} behind`), a.lateCount = 0, a.lateMaxMs = 0;
5933
+ if (i !== void 0) {
5934
+ const a = p.Milli.add(p.Milli.sub(i, r), this.#t.peek());
5935
+ if (a < 0) {
5936
+ const o = this.#r.get(t);
5937
+ o ? (o.count++, o.maxMs = Math.max(o.maxMs, -a)) : this.#r.set(t, { count: 1, maxMs: -a });
5938
+ } else {
5939
+ const o = this.#r.get(t);
5940
+ if (o) {
5941
+ const c = t ? `sync[${t}]` : "sync", u = Se.#o(o.maxMs);
5942
+ console.debug(`${c}: ${o.count} late frame(s), max ${u} behind`), this.#r.delete(t);
5943
+ }
5944
5944
  }
5945
+ if (r >= i)
5946
+ return;
5945
5947
  }
5946
- if (r >= a.ref) return;
5947
- a.ref = r;
5948
- let c = r;
5949
- for (const { ref: o } of this.#r.values())
5950
- o > c && (c = o);
5951
- i !== c && (this.#n.set(c), this.#e.resolve(), this.#e = Promise.withResolvers());
5948
+ this.#n.set(r), this.#e.resolve(), this.#e = Promise.withResolvers();
5952
5949
  }
5953
5950
  // Sleep until it's time to render this frame.
5954
5951
  async wait(e) {
@@ -5959,8 +5956,8 @@ class Se {
5959
5956
  if (i === void 0) return;
5960
5957
  const a = p.Milli.add(p.Milli.sub(i, r), this.#t.peek());
5961
5958
  if (a <= 0 || a < 5) return;
5962
- const c = new Promise((u) => setTimeout(u, a)).then(() => !0);
5963
- if (await Promise.race([this.#e.promise, c])) return;
5959
+ const o = new Promise((u) => setTimeout(u, a)).then(() => !0);
5960
+ if (await Promise.race([this.#e.promise, o])) return;
5964
5961
  }
5965
5962
  }
5966
5963
  static #o(e) {
@@ -6007,23 +6004,23 @@ class Ks {
6007
6004
  this.#n.set(void 0);
6008
6005
  return;
6009
6006
  }
6010
- const [s, r, i, a] = t, c = e.get(r.active);
6011
- if (!c) return;
6012
- let o = new Ys({
6007
+ const [s, r, i, a] = t, o = e.get(r.active);
6008
+ if (!o) return;
6009
+ let c = new Ys({
6013
6010
  source: this.source,
6014
- broadcast: c,
6011
+ broadcast: o,
6015
6012
  track: i,
6016
6013
  config: a,
6017
6014
  stats: this.#i
6018
6015
  });
6019
- e.cleanup(() => o?.close()), e.run((u) => {
6020
- if (!o) return;
6016
+ e.cleanup(() => c?.close()), e.run((u) => {
6017
+ if (!c) return;
6021
6018
  const d = u.get(this.#n);
6022
6019
  if (d) {
6023
- const l = u.get(o.timestamp), f = u.get(d.timestamp);
6020
+ const l = u.get(c.timestamp), f = u.get(d.timestamp);
6024
6021
  if (!l || f && f > l + Ws) return;
6025
6022
  }
6026
- this.#n.set(o), o = void 0, u.close();
6023
+ this.#n.set(c), c = void 0, u.close();
6027
6024
  });
6028
6025
  }
6029
6026
  #d(e) {
@@ -6100,7 +6097,7 @@ class Ys {
6100
6097
  const a = this.source.sync.wait(i).then(() => !0);
6101
6098
  if (!await Promise.race([a, e.cancel]) || i < (this.timestamp.peek() ?? 0))
6102
6099
  return;
6103
- this.timestamp.set(i), this.#i(i), this.frame.update((o) => (o?.close(), r.clone()));
6100
+ this.timestamp.set(i), this.#i(i), this.frame.update((c) => (c?.close(), r.clone()));
6104
6101
  } finally {
6105
6102
  r.close();
6106
6103
  }
@@ -6119,8 +6116,8 @@ class Ys {
6119
6116
  latency: this.source.sync.buffer
6120
6117
  });
6121
6118
  e.cleanup(() => r.close()), e.run((a) => {
6122
- const c = a.get(r.buffered), o = a.get(this.#n);
6123
- this.buffered.update(() => Js(c, o));
6119
+ const o = a.get(r.buffered), c = a.get(this.#n);
6120
+ this.buffered.update(() => Js(o, c));
6124
6121
  }), s.configure({
6125
6122
  ...this.config,
6126
6123
  description: this.config.description ? q(this.config.description) : void 0,
@@ -6133,28 +6130,28 @@ class Ys {
6133
6130
  for (; ; ) {
6134
6131
  const a = await Promise.race([r.next(), e.cancel]);
6135
6132
  if (!a) break;
6136
- const { frame: c, group: o } = a;
6137
- if (!c) {
6133
+ const { frame: o, group: c } = a;
6134
+ if (!o) {
6138
6135
  i && (i.final = !0);
6139
6136
  continue;
6140
6137
  }
6141
- const u = p.Milli.fromMicro(c.timestamp);
6138
+ const u = p.Milli.fromMicro(o.timestamp);
6142
6139
  this.source.sync.received(u, "video");
6143
6140
  const d = new EncodedVideoChunk({
6144
- type: c.keyframe ? "key" : "delta",
6145
- data: c.data,
6146
- timestamp: c.timestamp
6141
+ type: o.keyframe ? "key" : "delta",
6142
+ data: o.data,
6143
+ timestamp: o.timestamp
6147
6144
  });
6148
6145
  if (this.stats.update((l) => ({
6149
6146
  frameCount: (l?.frameCount ?? 0) + 1,
6150
- bytesReceived: (l?.bytesReceived ?? 0) + c.data.byteLength
6151
- })), i?.group === o || i?.final && i.group + 1 === o) {
6152
- const l = p.Milli.fromMicro(i.timestamp), f = p.Milli.fromMicro(c.timestamp);
6147
+ bytesReceived: (l?.bytesReceived ?? 0) + o.data.byteLength
6148
+ })), i?.group === c || i?.final && i.group + 1 === c) {
6149
+ const l = p.Milli.fromMicro(i.timestamp), f = p.Milli.fromMicro(o.timestamp);
6153
6150
  this.#s(l, f);
6154
6151
  }
6155
6152
  i = {
6156
- timestamp: c.timestamp,
6157
- group: o,
6153
+ timestamp: o.timestamp,
6154
+ group: c,
6158
6155
  final: !1
6159
6156
  }, s.decode(d);
6160
6157
  }
@@ -6170,19 +6167,19 @@ class Ys {
6170
6167
  // @ts-expect-error Only supported by Chrome, so the renderer has to flip manually.
6171
6168
  flip: !1
6172
6169
  }), e.run((a) => {
6173
- const c = a.get(this.#n);
6174
- this.buffered.update(() => c);
6170
+ const o = a.get(this.#n);
6171
+ this.buffered.update(() => o);
6175
6172
  }), e.spawn(async () => {
6176
6173
  for (; ; ) {
6177
6174
  const a = await Promise.race([t.nextGroup(), e.cancel]);
6178
6175
  if (!a) break;
6179
6176
  e.spawn(async () => {
6180
- let c;
6177
+ let o;
6181
6178
  try {
6182
6179
  for (; ; ) {
6183
- const o = await Promise.race([a.readFrame(), e.cancel]);
6184
- if (!o) break;
6185
- const u = _n(o, r);
6180
+ const c = await Promise.race([a.readFrame(), e.cancel]);
6181
+ if (!c) break;
6182
+ const u = _n(c, r);
6186
6183
  for (const d of u) {
6187
6184
  const l = new EncodedVideoChunk({
6188
6185
  type: d.keyframe ? "key" : "delta",
@@ -6192,11 +6189,11 @@ class Ys {
6192
6189
  if (this.source.sync.received(f, "video"), this.stats.update((w) => ({
6193
6190
  frameCount: (w?.frameCount ?? 0) + 1,
6194
6191
  bytesReceived: (w?.bytesReceived ?? 0) + d.data.byteLength
6195
- })), c !== void 0) {
6196
- const w = p.Milli.fromMicro(c), b = p.Milli.fromMicro(d.timestamp);
6192
+ })), o !== void 0) {
6193
+ const w = p.Milli.fromMicro(o), b = p.Milli.fromMicro(d.timestamp);
6197
6194
  this.#s(w, b);
6198
6195
  }
6199
- c = d.timestamp, s.decode(l);
6196
+ o = d.timestamp, s.decode(l);
6200
6197
  }
6201
6198
  }
6202
6199
  } finally {
@@ -6280,16 +6277,16 @@ let er = class {
6280
6277
  if (!i) return;
6281
6278
  const a = e.get(this.source.track);
6282
6279
  if (!a) return;
6283
- const c = e.get(this.source.config);
6284
- if (!c) return;
6285
- const o = `video/mp4; codecs="${c.codec}"`, u = s.addSourceBuffer(o);
6280
+ const o = e.get(this.source.config);
6281
+ if (!o) return;
6282
+ const c = `video/mp4; codecs="${o.codec}"`, u = s.addSourceBuffer(c);
6286
6283
  e.cleanup(() => {
6287
6284
  s.removeSourceBuffer(u), u.abort();
6288
6285
  }), e.event(u, "error", (d) => {
6289
6286
  console.error("[MSE] SourceBuffer error:", d);
6290
6287
  }), e.event(u, "updateend", () => {
6291
6288
  this.#t.set(En(u.buffered));
6292
- }), c.container.kind === "cmaf" ? this.#a(e, i, a, c, u, t) : this.#o(e, i, a, c, u, t);
6289
+ }), o.container.kind === "cmaf" ? this.#a(e, i, a, o, u, t) : this.#o(e, i, a, o, u, t);
6293
6290
  }
6294
6291
  async #i(e, t) {
6295
6292
  for (; e.updating; )
@@ -6299,31 +6296,31 @@ let er = class {
6299
6296
  }
6300
6297
  #a(e, t, s, r, i, a) {
6301
6298
  if (r.container.kind !== "cmaf") throw new Error("unreachable");
6302
- const c = t.subscribe(s, W.video);
6303
- e.cleanup(() => c.close());
6304
- const o = r.container.timescale;
6299
+ const o = t.subscribe(s, W.video);
6300
+ e.cleanup(() => o.close());
6301
+ const c = r.container.timescale;
6305
6302
  e.spawn(async () => {
6306
6303
  const u = Fe(r);
6307
6304
  for (await this.#i(i, u); ; ) {
6308
- const d = await c.readFrame();
6305
+ const d = await o.readFrame();
6309
6306
  if (!d) return;
6310
- const l = yn(d, o);
6307
+ const l = yn(d, c);
6311
6308
  this.source.sync.received(_.Time.Milli.fromMicro(l), "video"), await this.#i(i, d), a.buffered.length > 0 && a.currentTime < a.buffered.start(0) && (a.currentTime = a.buffered.start(0));
6312
6309
  }
6313
6310
  });
6314
6311
  }
6315
6312
  #o(e, t, s, r, i, a) {
6316
- const c = t.subscribe(s, W.video);
6317
- e.cleanup(() => c.close());
6318
- const o = new J(c, {
6313
+ const o = t.subscribe(s, W.video);
6314
+ e.cleanup(() => o.close());
6315
+ const c = new J(o, {
6319
6316
  latency: this.source.sync.buffer
6320
6317
  });
6321
- e.cleanup(() => o.close()), e.spawn(async () => {
6318
+ e.cleanup(() => c.close()), e.spawn(async () => {
6322
6319
  const u = Fe(r);
6323
6320
  await this.#i(i, u);
6324
6321
  let d = 1, l, f;
6325
6322
  for (; ; ) {
6326
- const w = await o.next();
6323
+ const w = await c.next();
6327
6324
  if (!w) return;
6328
6325
  if (!w.frame) continue;
6329
6326
  f = w.frame;
@@ -6332,7 +6329,7 @@ let er = class {
6332
6329
  break;
6333
6330
  }
6334
6331
  for (; ; ) {
6335
- const w = await o.next();
6332
+ const w = await c.next();
6336
6333
  if (w && !w.frame) continue;
6337
6334
  const b = w?.frame;
6338
6335
  if (b) {
@@ -6422,8 +6419,8 @@ class tr {
6422
6419
  this.#t.set(s && !document.hidden);
6423
6420
  }, i = new IntersectionObserver(
6424
6421
  (a) => {
6425
- for (const c of a)
6426
- s = c.isIntersecting, r();
6422
+ for (const o of a)
6423
+ s = o.isIntersecting, r();
6427
6424
  },
6428
6425
  { threshold: 0.01 }
6429
6426
  );
@@ -6447,7 +6444,7 @@ class tr {
6447
6444
  s || (r = e.get(this.decoder.frame));
6448
6445
  let i = requestAnimationFrame(() => {
6449
6446
  const a = r ?? this.frame.peek();
6450
- this.#o(t, a), r && (this.frame.update((c) => (c?.close(), r.clone())), this.timestamp.set(p.Milli.fromMicro(r.timestamp))), i = void 0;
6447
+ this.#o(t, a), r && (this.frame.update((o) => (o?.close(), r.clone())), this.timestamp.set(p.Milli.fromMicro(r.timestamp))), i = void 0;
6451
6448
  });
6452
6449
  e.cleanup(() => {
6453
6450
  r?.close(), i && cancelAnimationFrame(i);
@@ -6538,13 +6535,13 @@ let ar = class {
6538
6535
  if (Object.keys(t).length === 0) return;
6539
6536
  const s = e.get(this.target);
6540
6537
  if (s?.name && s.name in t) {
6541
- const o = t[s.name];
6542
- e.set(this.#e, s.name), e.set(this.#r, o), e.set(this.sync.video, o.jitter);
6538
+ const c = t[s.name];
6539
+ e.set(this.#e, s.name), e.set(this.#r, c), e.set(this.sync.video, c.jitter);
6543
6540
  return;
6544
6541
  }
6545
6542
  let r = s;
6546
6543
  if (!s?.bitrate) {
6547
- const o = e.get(this.broadcast), d = (o ? e.get(o.connection) : void 0)?.recvBandwidth;
6544
+ const c = e.get(this.broadcast), d = (c ? e.get(c.connection) : void 0)?.recvBandwidth;
6548
6545
  if (d) {
6549
6546
  const l = e.get(d);
6550
6547
  if (l != null) {
@@ -6557,8 +6554,8 @@ let ar = class {
6557
6554
  if (!i) return;
6558
6555
  const a = t[i];
6559
6556
  e.set(this.#e, i), e.set(this.#r, a);
6560
- const c = a.jitter ?? (a.framerate ? Math.ceil(1e3 / a.framerate) : void 0);
6561
- e.set(this.sync.video, c);
6557
+ const o = a.jitter ?? (a.framerate ? Math.ceil(1e3 / a.framerate) : void 0);
6558
+ e.set(this.sync.video, o);
6562
6559
  }
6563
6560
  /**
6564
6561
  * Select the best rendition using a generic filter system.
@@ -6574,10 +6571,10 @@ let ar = class {
6574
6571
  const r = [];
6575
6572
  if (t?.pixels != null && r.push(sr(t.pixels)), t?.bitrate != null && r.push(rr(t.bitrate)), r.length === 0)
6576
6573
  return ir(s);
6577
- const i = r.map((c) => c(s)), a = i.map((c) => new Set(c));
6578
- for (const c of i[0])
6579
- if (a.every((o) => o.has(c)))
6580
- return c;
6574
+ const i = r.map((o) => o(s)), a = i.map((o) => new Set(o));
6575
+ for (const o of i[0])
6576
+ if (a.every((c) => c.has(o)))
6577
+ return o;
6581
6578
  console.warn("conflicting rendition filters, no rendition satisfies all criteria");
6582
6579
  }
6583
6580
  close() {
@@ -6695,9 +6692,9 @@ class ur {
6695
6692
  if (!i) return;
6696
6693
  const a = e.get(this.source.track);
6697
6694
  if (!a) return;
6698
- const c = e.get(this.source.config);
6699
- if (!c) return;
6700
- const o = `audio/mp4; codecs="${c.codec}"`, u = s.addSourceBuffer(o);
6695
+ const o = e.get(this.source.config);
6696
+ if (!o) return;
6697
+ const c = `audio/mp4; codecs="${o.codec}"`, u = s.addSourceBuffer(c);
6701
6698
  e.cleanup(() => {
6702
6699
  s.removeSourceBuffer(u), u.abort();
6703
6700
  }), e.event(u, "error", (l) => {
@@ -6706,7 +6703,7 @@ class ur {
6706
6703
  this.#t.set(En(u.buffered));
6707
6704
  });
6708
6705
  const d = i.subscribe(a, W.audio);
6709
- e.cleanup(() => d.close()), c.container.kind === "cmaf" ? this.#i(e, d, c, u, t) : this.#a(e, d, c, u, t);
6706
+ e.cleanup(() => d.close()), o.container.kind === "cmaf" ? this.#i(e, d, o, u, t) : this.#a(e, d, o, u, t);
6710
6707
  }
6711
6708
  async #s(e, t) {
6712
6709
  for (; e.updating; )
@@ -6718,12 +6715,12 @@ class ur {
6718
6715
  if (s.container.kind !== "cmaf") throw new Error("unreachable");
6719
6716
  const a = s.container.timescale;
6720
6717
  e.spawn(async () => {
6721
- const c = Ve(s);
6722
- for (await this.#s(r, c); ; ) {
6723
- const o = await t.readFrame();
6724
- if (!o) return;
6725
- const u = yn(o, a);
6726
- this.source.sync.received(_.Time.Milli.fromMicro(u), "audio"), await this.#s(r, o), i.buffered.length > 0 && i.currentTime < i.buffered.start(0) && (i.currentTime = i.buffered.start(0));
6718
+ const o = Ve(s);
6719
+ for (await this.#s(r, o); ; ) {
6720
+ const c = await t.readFrame();
6721
+ if (!c) return;
6722
+ const u = yn(c, a);
6723
+ this.source.sync.received(_.Time.Milli.fromMicro(u), "audio"), await this.#s(r, c), i.buffered.length > 0 && i.currentTime < i.buffered.start(0) && (i.currentTime = i.buffered.start(0));
6727
6724
  }
6728
6725
  });
6729
6726
  }
@@ -6732,9 +6729,9 @@ class ur {
6732
6729
  latency: this.source.sync.buffer
6733
6730
  });
6734
6731
  e.cleanup(() => a.close()), e.spawn(async () => {
6735
- const c = Ve(s);
6736
- await this.#s(r, c);
6737
- let o = 1, u, d;
6732
+ const o = Ve(s);
6733
+ await this.#s(r, o);
6734
+ let c = 1, u, d;
6738
6735
  for (; ; ) {
6739
6736
  const l = await a.next();
6740
6737
  if (!l) return;
@@ -6759,7 +6756,7 @@ class ur {
6759
6756
  duration: u ?? 0,
6760
6757
  // Default to 0 duration if there's literally one frame then stream FIN.
6761
6758
  keyframe: d.keyframe,
6762
- sequence: o++
6759
+ sequence: c++
6763
6760
  });
6764
6761
  if (await this.#s(r, w), i.buffered.length > 0 && i.currentTime < i.buffered.start(0) && (i.currentTime = i.buffered.start(0)), !f) return;
6765
6762
  d = f;
@@ -6781,7 +6778,7 @@ class ur {
6781
6778
  async function dr(n) {
6782
6779
  return MediaSource.isTypeSupported(`audio/mp4; codecs="${n.codec}"`);
6783
6780
  }
6784
- const lr = 128, hr = 5;
6781
+ const lr = 128, hr = 10;
6785
6782
  class fr {
6786
6783
  broadcast;
6787
6784
  target;
@@ -6824,8 +6821,8 @@ class fr {
6824
6821
  r = { track: s.name, config: t[s.name] };
6825
6822
  else if (r = this.#c(t), !r) return;
6826
6823
  e.set(this.#e, r.track), e.set(this.#r, r.config);
6827
- const i = r.config.jitter ?? mr(r.config) ?? 0, a = Math.ceil(lr / r.config.sampleRate * 1e3) + hr, c = i + a;
6828
- e.set(this.sync.audio, c);
6824
+ const i = r.config.jitter ?? mr(r.config) ?? 0, a = Math.ceil(lr / r.config.sampleRate * 1e3) + hr, o = i + a;
6825
+ e.set(this.sync.audio, o);
6829
6826
  }
6830
6827
  /**
6831
6828
  * Select rendition based on the configured strategy.
@@ -6925,4 +6922,4 @@ export {
6925
6922
  y as s,
6926
6923
  En as t
6927
6924
  };
6928
- //# sourceMappingURL=broadcast-CZkbruBC.js.map
6925
+ //# sourceMappingURL=broadcast-BdsV4u8m.js.map