@munusshih/p5.export 0.1.0-beta.1 → 0.1.0-beta.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/p5.export.js CHANGED
@@ -1183,8 +1183,8 @@ function rs(t = 256) {
1183
1183
  i = new Uint8Array(s), e > 0 && i.set(l.subarray(0, e), 0);
1184
1184
  }
1185
1185
  }
1186
- var Pi = 12, Or = 5003, Mn = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
1187
- function Pn(t, e, i, r, s = rs(512), n = new Uint8Array(256), a = new Int32Array(Or), l = new Int32Array(Or)) {
1186
+ var Ii = 12, Or = 5003, Mn = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
1187
+ function In(t, e, i, r, s = rs(512), n = new Uint8Array(256), a = new Int32Array(Or), l = new Int32Array(Or)) {
1188
1188
  let u = a.length, g = Math.max(2, r);
1189
1189
  n.fill(0), l.fill(0), a.fill(-1);
1190
1190
  let v = 0, p = 0, h = g + 1, d = h, f = !1, m = d, w = (1 << m) - 1, y = 1 << h - 1, C = y + 1, x = y + 2, _ = 0, M = i[0], $ = 0;
@@ -1193,7 +1193,7 @@ function Pn(t, e, i, r, s = rs(512), n = new Uint8Array(256), a = new Int32Array
1193
1193
  let B = i.length;
1194
1194
  for (let G = 1; G < B; G++)
1195
1195
  t: {
1196
- let Z = i[G], X = (Z << Pi) + M, q = Z << $ ^ M;
1196
+ let Z = i[G], X = (Z << Ii) + M, q = Z << $ ^ M;
1197
1197
  if (a[q] === X) {
1198
1198
  M = l[q];
1199
1199
  break t;
@@ -1203,18 +1203,18 @@ function Pn(t, e, i, r, s = rs(512), n = new Uint8Array(256), a = new Int32Array
1203
1203
  M = l[q];
1204
1204
  break t;
1205
1205
  }
1206
- O(M), M = Z, x < 1 << Pi ? (l[q] = x++, a[q] = X) : (a.fill(-1), x = y + 2, f = !0, O(y));
1206
+ O(M), M = Z, x < 1 << Ii ? (l[q] = x++, a[q] = X) : (a.fill(-1), x = y + 2, f = !0, O(y));
1207
1207
  }
1208
1208
  return O(M), O(C), s.writeByte(0), s.bytesView();
1209
1209
  function O(G) {
1210
1210
  for (v &= Mn[p], p > 0 ? v |= G << p : v = G, p += m; p >= 8; ) n[_++] = v & 255, _ >= 254 && (s.writeByte(_), s.writeBytesView(n, 0, _), _ = 0), v >>= 8, p -= 8;
1211
- if ((x > w || f) && (f ? (m = d, w = (1 << m) - 1, f = !1) : (++m, w = m === Pi ? 1 << m : (1 << m) - 1)), G == C) {
1211
+ if ((x > w || f) && (f ? (m = d, w = (1 << m) - 1, f = !1) : (++m, w = m === Ii ? 1 << m : (1 << m) - 1)), G == C) {
1212
1212
  for (; p > 0; ) n[_++] = v & 255, _ >= 254 && (s.writeByte(_), s.writeBytesView(n, 0, _), _ = 0), v >>= 8, p -= 8;
1213
1213
  _ > 0 && (s.writeByte(_), s.writeBytesView(n, 0, _), _ = 0);
1214
1214
  }
1215
1215
  }
1216
1216
  }
1217
- var In = Pn;
1217
+ var Pn = In;
1218
1218
  function ss(t, e, i) {
1219
1219
  return t << 8 & 63488 | e << 2 & 992 | i >> 3;
1220
1220
  }
@@ -1244,21 +1244,21 @@ function Gr(t, e, i) {
1244
1244
  }
1245
1245
  n.err = s, n.nn = r;
1246
1246
  }
1247
- function Ii() {
1247
+ function Pi() {
1248
1248
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
1249
1249
  }
1250
1250
  function Rn(t, e) {
1251
1251
  let i = e === "rgb444" ? 4096 : 65536, r = new Array(i), s = t.length;
1252
1252
  if (e === "rgba4444") for (let n = 0; n < s; ++n) {
1253
- let a = t[n], l = a >> 24 & 255, u = a >> 16 & 255, g = a >> 8 & 255, v = a & 255, p = ns(v, g, u, l), h = p in r ? r[p] : r[p] = Ii();
1253
+ let a = t[n], l = a >> 24 & 255, u = a >> 16 & 255, g = a >> 8 & 255, v = a & 255, p = ns(v, g, u, l), h = p in r ? r[p] : r[p] = Pi();
1254
1254
  h.rc += v, h.gc += g, h.bc += u, h.ac += l, h.cnt++;
1255
1255
  }
1256
1256
  else if (e === "rgb444") for (let n = 0; n < s; ++n) {
1257
- let a = t[n], l = a >> 16 & 255, u = a >> 8 & 255, g = a & 255, v = as(g, u, l), p = v in r ? r[v] : r[v] = Ii();
1257
+ let a = t[n], l = a >> 16 & 255, u = a >> 8 & 255, g = a & 255, v = as(g, u, l), p = v in r ? r[v] : r[v] = Pi();
1258
1258
  p.rc += g, p.gc += u, p.bc += l, p.cnt++;
1259
1259
  }
1260
1260
  else for (let n = 0; n < s; ++n) {
1261
- let a = t[n], l = a >> 16 & 255, u = a >> 8 & 255, g = a & 255, v = ss(g, u, l), p = v in r ? r[v] : r[v] = Ii();
1261
+ let a = t[n], l = a >> 16 & 255, u = a >> 8 & 255, g = a & 255, v = ss(g, u, l), p = v in r ? r[v] : r[v] = Pi();
1262
1262
  p.rc += g, p.gc += u, p.bc += l, p.cnt++;
1263
1263
  }
1264
1264
  return r;
@@ -1417,7 +1417,7 @@ function Vn(t, e, i, r) {
1417
1417
  } else t.writeByte(0);
1418
1418
  }
1419
1419
  function Ln(t, e, i, r, s = 8, n, a, l) {
1420
- In(i, r, e, s, t, n, a, l);
1420
+ Pn(i, r, e, s, t, n, a, l);
1421
1421
  }
1422
1422
  function Rt(t, e) {
1423
1423
  t.writeByte(e & 255), t.writeByte(e >> 8 & 255);
@@ -2043,18 +2043,18 @@ var ar = (t, e, i) => {
2043
2043
  // Default sample flags
2044
2044
  ]), $r = (t, e) => J("moof", null, [
2045
2045
  Ma(t),
2046
- ...e.map(Pa)
2046
+ ...e.map(Ia)
2047
2047
  ]), Ma = (t) => H("mfhd", 0, 0, [
2048
2048
  E(t)
2049
2049
  // Sequence number
2050
2050
  ]), ms = (t) => {
2051
2051
  let e = 0, i = 0, r = 0, s = 0, n = t.type === "delta";
2052
2052
  return i |= +n, n ? e |= 1 : e |= 2, e << 24 | i << 16 | r << 8 | s;
2053
- }, Pa = (t) => J("traf", null, [
2054
- Ia(t),
2053
+ }, Ia = (t) => J("traf", null, [
2054
+ Pa(t),
2055
2055
  Ra(t),
2056
2056
  Ba(t)
2057
- ]), Ia = (t) => {
2057
+ ]), Pa = (t) => {
2058
2058
  let e = 0;
2059
2059
  e |= 8, e |= 16, e |= 32, e |= 131072;
2060
2060
  let i = t.currentChunk.samples[1] ?? t.currentChunk.samples[0], r = {
@@ -2358,9 +2358,9 @@ var ja = class extends cr {
2358
2358
  chunkSize: (i = e.options) == null ? void 0 : i.chunkSize
2359
2359
  }));
2360
2360
  }
2361
- }, Li = 1e3, qa = ["avc", "hevc", "vp9", "av1"], Ha = ["aac", "opus"], Xa = 2082844800, Ya = ["strict", "offset", "cross-track-offset"], P, R, pi, rt, it, tt, Qt, re, fr, zt, Vt, Ae, Oi, _s, Gi, xs, ur, Ss, Ni, Cs, pr, Es, ri, $i, lt, vt, mr, Ts, Me, mi, wi, wr, fe, je, si, ji, Ja = class {
2361
+ }, Li = 1e3, qa = ["avc", "hevc", "vp9", "av1"], Ha = ["aac", "opus"], Xa = 2082844800, Ya = ["strict", "offset", "cross-track-offset"], I, R, pi, rt, it, tt, Qt, re, fr, zt, Vt, Ae, Oi, _s, Gi, xs, ur, Ss, Ni, Cs, pr, Es, ri, $i, lt, vt, mr, Ts, Me, mi, wi, wr, fe, je, si, ji, Ja = class {
2362
2362
  constructor(e) {
2363
- if (D(this, Oi), D(this, Gi), D(this, ur), D(this, Ni), D(this, pr), D(this, ri), D(this, lt), D(this, mr), D(this, Me), D(this, wi), D(this, fe), D(this, si), D(this, P, void 0), D(this, R, void 0), D(this, pi, void 0), D(this, rt, void 0), D(this, it, null), D(this, tt, null), D(this, Qt, Math.floor(Date.now() / 1e3) + Xa), D(this, re, []), D(this, fr, 1), D(this, zt, []), D(this, Vt, []), D(this, Ae, !1), z(this, Oi, _s).call(this, e), e.video = Ee(e.video), e.audio = Ee(e.audio), e.fastStart = Ee(e.fastStart), this.target = e.target, et(this, P, {
2363
+ if (D(this, Oi), D(this, Gi), D(this, ur), D(this, Ni), D(this, pr), D(this, ri), D(this, lt), D(this, mr), D(this, Me), D(this, wi), D(this, fe), D(this, si), D(this, I, void 0), D(this, R, void 0), D(this, pi, void 0), D(this, rt, void 0), D(this, it, null), D(this, tt, null), D(this, Qt, Math.floor(Date.now() / 1e3) + Xa), D(this, re, []), D(this, fr, 1), D(this, zt, []), D(this, Vt, []), D(this, Ae, !1), z(this, Oi, _s).call(this, e), e.video = Ee(e.video), e.audio = Ee(e.audio), e.fastStart = Ee(e.fastStart), this.target = e.target, et(this, I, {
2364
2364
  firstTimestampBehavior: "strict",
2365
2365
  ...e
2366
2366
  }), e.target instanceof ws)
@@ -2411,12 +2411,12 @@ var ja = class extends cr {
2411
2411
  throw new TypeError(
2412
2412
  "addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number."
2413
2413
  );
2414
- if (z(this, si, ji).call(this), !c(this, P).video)
2414
+ if (z(this, si, ji).call(this), !c(this, I).video)
2415
2415
  throw new Error("No video track declared.");
2416
- if (typeof c(this, P).fastStart == "object" && c(this, it).samples.length === c(this, P).fastStart.expectedVideoChunks)
2417
- throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${c(this, P).fastStart.expectedVideoChunks}).`);
2416
+ if (typeof c(this, I).fastStart == "object" && c(this, it).samples.length === c(this, I).fastStart.expectedVideoChunks)
2417
+ throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${c(this, I).fastStart.expectedVideoChunks}).`);
2418
2418
  let l = z(this, ri, $i).call(this, c(this, it), e, i, r, s, n, a);
2419
- if (c(this, P).fastStart === "fragmented" && c(this, tt)) {
2419
+ if (c(this, I).fastStart === "fragmented" && c(this, tt)) {
2420
2420
  for (; c(this, Vt).length > 0 && c(this, Vt)[0].decodeTimestamp <= l.decodeTimestamp; ) {
2421
2421
  let u = c(this, Vt).shift();
2422
2422
  z(this, lt, vt).call(this, c(this, tt), u);
@@ -2448,12 +2448,12 @@ var ja = class extends cr {
2448
2448
  throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");
2449
2449
  if (n && typeof n != "object")
2450
2450
  throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");
2451
- if (z(this, si, ji).call(this), !c(this, P).audio)
2451
+ if (z(this, si, ji).call(this), !c(this, I).audio)
2452
2452
  throw new Error("No audio track declared.");
2453
- if (typeof c(this, P).fastStart == "object" && c(this, tt).samples.length === c(this, P).fastStart.expectedAudioChunks)
2454
- throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${c(this, P).fastStart.expectedAudioChunks}).`);
2453
+ if (typeof c(this, I).fastStart == "object" && c(this, tt).samples.length === c(this, I).fastStart.expectedAudioChunks)
2454
+ throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${c(this, I).fastStart.expectedAudioChunks}).`);
2455
2455
  let a = z(this, ri, $i).call(this, c(this, tt), e, i, r, s, n);
2456
- if (c(this, P).fastStart === "fragmented" && c(this, it)) {
2456
+ if (c(this, I).fastStart === "fragmented" && c(this, it)) {
2457
2457
  for (; c(this, zt).length > 0 && c(this, zt)[0].decodeTimestamp <= a.decodeTimestamp; ) {
2458
2458
  let l = c(this, zt).shift();
2459
2459
  z(this, lt, vt).call(this, c(this, it), l);
@@ -2466,7 +2466,7 @@ var ja = class extends cr {
2466
2466
  finalize() {
2467
2467
  if (c(this, Ae))
2468
2468
  throw new Error("Cannot finalize a muxer more than once.");
2469
- if (c(this, P).fastStart === "fragmented") {
2469
+ if (c(this, I).fastStart === "fragmented") {
2470
2470
  for (let i of c(this, zt))
2471
2471
  z(this, lt, vt).call(this, c(this, it), i);
2472
2472
  for (let i of c(this, Vt))
@@ -2475,7 +2475,7 @@ var ja = class extends cr {
2475
2475
  } else
2476
2476
  c(this, it) && z(this, Me, mi).call(this, c(this, it)), c(this, tt) && z(this, Me, mi).call(this, c(this, tt));
2477
2477
  let e = [c(this, it), c(this, tt)].filter(Boolean);
2478
- if (c(this, P).fastStart === "in-memory") {
2478
+ if (c(this, I).fastStart === "in-memory") {
2479
2479
  let i;
2480
2480
  for (let s = 0; s < 2; s++) {
2481
2481
  let n = ti(e, c(this, Qt)), a = c(this, R).measureBox(n);
@@ -2495,7 +2495,7 @@ var ja = class extends cr {
2495
2495
  for (let s of c(this, re))
2496
2496
  for (let n of s.samples)
2497
2497
  c(this, R).write(n.data), n.data = null;
2498
- } else if (c(this, P).fastStart === "fragmented") {
2498
+ } else if (c(this, I).fastStart === "fragmented") {
2499
2499
  let i = c(this, R).pos, r = Fa(e);
2500
2500
  c(this, R).writeBox(r);
2501
2501
  let s = c(this, R).pos - i;
@@ -2504,7 +2504,7 @@ var ja = class extends cr {
2504
2504
  let i = c(this, R).offsets.get(c(this, rt)), r = c(this, R).pos - i;
2505
2505
  c(this, rt).size = r, c(this, rt).largeSize = r >= 2 ** 32, c(this, R).patchBox(c(this, rt));
2506
2506
  let s = ti(e, c(this, Qt));
2507
- if (typeof c(this, P).fastStart == "object") {
2507
+ if (typeof c(this, I).fastStart == "object") {
2508
2508
  c(this, R).seek(c(this, pi)), c(this, R).writeBox(s);
2509
2509
  let n = i - c(this, R).pos;
2510
2510
  c(this, R).writeBox(Xn(n));
@@ -2514,7 +2514,7 @@ var ja = class extends cr {
2514
2514
  z(this, fe, je).call(this), c(this, R).finalize(), et(this, Ae, !0);
2515
2515
  }
2516
2516
  };
2517
- P = /* @__PURE__ */ new WeakMap();
2517
+ I = /* @__PURE__ */ new WeakMap();
2518
2518
  R = /* @__PURE__ */ new WeakMap();
2519
2519
  pi = /* @__PURE__ */ new WeakMap();
2520
2520
  rt = /* @__PURE__ */ new WeakMap();
@@ -2585,12 +2585,12 @@ Gi = /* @__PURE__ */ new WeakSet();
2585
2585
  xs = function() {
2586
2586
  var t;
2587
2587
  if (c(this, R).writeBox(Hn({
2588
- holdsAvc: ((t = c(this, P).video) == null ? void 0 : t.codec) === "avc",
2589
- fragmented: c(this, P).fastStart === "fragmented"
2590
- })), et(this, pi, c(this, R).pos), c(this, P).fastStart === "in-memory")
2588
+ holdsAvc: ((t = c(this, I).video) == null ? void 0 : t.codec) === "avc",
2589
+ fragmented: c(this, I).fastStart === "fragmented"
2590
+ })), et(this, pi, c(this, R).pos), c(this, I).fastStart === "in-memory")
2591
2591
  et(this, rt, Wi(!1));
2592
- else if (c(this, P).fastStart !== "fragmented") {
2593
- if (typeof c(this, P).fastStart == "object") {
2592
+ else if (c(this, I).fastStart !== "fragmented") {
2593
+ if (typeof c(this, I).fastStart == "object") {
2594
2594
  let e = z(this, ur, Ss).call(this);
2595
2595
  c(this, R).seek(c(this, R).pos + e);
2596
2596
  }
@@ -2600,11 +2600,11 @@ xs = function() {
2600
2600
  };
2601
2601
  ur = /* @__PURE__ */ new WeakSet();
2602
2602
  Ss = function() {
2603
- if (typeof c(this, P).fastStart != "object")
2603
+ if (typeof c(this, I).fastStart != "object")
2604
2604
  return;
2605
2605
  let t = 0, e = [
2606
- c(this, P).fastStart.expectedVideoChunks,
2607
- c(this, P).fastStart.expectedAudioChunks
2606
+ c(this, I).fastStart.expectedVideoChunks,
2607
+ c(this, I).fastStart.expectedAudioChunks
2608
2608
  ];
2609
2609
  for (let i of e)
2610
2610
  i && (t += 8 * Math.ceil(2 / 3 * i), t += 4 * i, t += 12 * Math.ceil(2 / 3 * i), t += 4 * i, t += 8 * i);
@@ -2612,18 +2612,18 @@ Ss = function() {
2612
2612
  };
2613
2613
  Ni = /* @__PURE__ */ new WeakSet();
2614
2614
  Cs = function() {
2615
- if (c(this, P).video && et(this, it, {
2615
+ if (c(this, I).video && et(this, it, {
2616
2616
  id: 1,
2617
2617
  info: {
2618
2618
  type: "video",
2619
- codec: c(this, P).video.codec,
2620
- width: c(this, P).video.width,
2621
- height: c(this, P).video.height,
2622
- rotation: c(this, P).video.rotation ?? 0,
2619
+ codec: c(this, I).video.codec,
2620
+ width: c(this, I).video.width,
2621
+ height: c(this, I).video.height,
2622
+ rotation: c(this, I).video.rotation ?? 0,
2623
2623
  decoderConfig: null
2624
2624
  },
2625
2625
  // The fallback contains many common frame rates as factors
2626
- timescale: c(this, P).video.frameRate ?? 57600,
2626
+ timescale: c(this, I).video.frameRate ?? 57600,
2627
2627
  samples: [],
2628
2628
  finalizedChunks: [],
2629
2629
  currentChunk: null,
@@ -2634,16 +2634,16 @@ Cs = function() {
2634
2634
  lastTimescaleUnits: null,
2635
2635
  lastSample: null,
2636
2636
  compactlyCodedChunkTable: []
2637
- }), c(this, P).audio && (et(this, tt, {
2638
- id: c(this, P).video ? 2 : 1,
2637
+ }), c(this, I).audio && (et(this, tt, {
2638
+ id: c(this, I).video ? 2 : 1,
2639
2639
  info: {
2640
2640
  type: "audio",
2641
- codec: c(this, P).audio.codec,
2642
- numberOfChannels: c(this, P).audio.numberOfChannels,
2643
- sampleRate: c(this, P).audio.sampleRate,
2641
+ codec: c(this, I).audio.codec,
2642
+ numberOfChannels: c(this, I).audio.numberOfChannels,
2643
+ sampleRate: c(this, I).audio.sampleRate,
2644
2644
  decoderConfig: null
2645
2645
  },
2646
- timescale: c(this, P).audio.sampleRate,
2646
+ timescale: c(this, I).audio.sampleRate,
2647
2647
  samples: [],
2648
2648
  finalizedChunks: [],
2649
2649
  currentChunk: null,
@@ -2654,19 +2654,19 @@ Cs = function() {
2654
2654
  lastTimescaleUnits: null,
2655
2655
  lastSample: null,
2656
2656
  compactlyCodedChunkTable: []
2657
- }), c(this, P).audio.codec === "aac")) {
2657
+ }), c(this, I).audio.codec === "aac")) {
2658
2658
  let t = z(this, pr, Es).call(
2659
2659
  this,
2660
2660
  2,
2661
2661
  // Object type for AAC-LC, since it's the most common
2662
- c(this, P).audio.sampleRate,
2663
- c(this, P).audio.numberOfChannels
2662
+ c(this, I).audio.sampleRate,
2663
+ c(this, I).audio.numberOfChannels
2664
2664
  );
2665
2665
  c(this, tt).info.decoderConfig = {
2666
- codec: c(this, P).audio.codec,
2666
+ codec: c(this, I).audio.codec,
2667
2667
  description: t,
2668
- numberOfChannels: c(this, P).audio.numberOfChannels,
2669
- sampleRate: c(this, P).audio.sampleRate
2668
+ numberOfChannels: c(this, I).audio.numberOfChannels,
2669
+ sampleRate: c(this, I).audio.sampleRate
2670
2670
  };
2671
2671
  }
2672
2672
  };
@@ -2697,11 +2697,11 @@ $i = function(t, e, i, r, s, n, a) {
2697
2697
  };
2698
2698
  lt = /* @__PURE__ */ new WeakSet();
2699
2699
  vt = function(t, e) {
2700
- c(this, P).fastStart !== "fragmented" && t.samples.push(e);
2700
+ c(this, I).fastStart !== "fragmented" && t.samples.push(e);
2701
2701
  const i = mt(e.presentationTimestamp - e.decodeTimestamp, t.timescale);
2702
2702
  if (t.lastTimescaleUnits !== null) {
2703
2703
  let s = mt(e.decodeTimestamp, t.timescale, !1), n = Math.round(s - t.lastTimescaleUnits);
2704
- if (t.lastTimescaleUnits += n, t.lastSample.timescaleUnitsToNextSample = n, c(this, P).fastStart !== "fragmented") {
2704
+ if (t.lastTimescaleUnits += n, t.lastSample.timescaleUnitsToNextSample = n, c(this, I).fastStart !== "fragmented") {
2705
2705
  let a = ci(t.timeToSampleTable);
2706
2706
  a.sampleCount === 1 ? (a.sampleDelta = n, a.sampleCount++) : a.sampleDelta === n ? a.sampleCount++ : (a.sampleCount--, t.timeToSampleTable.push({
2707
2707
  sampleCount: 2,
@@ -2714,7 +2714,7 @@ vt = function(t, e) {
2714
2714
  });
2715
2715
  }
2716
2716
  } else
2717
- t.lastTimescaleUnits = 0, c(this, P).fastStart !== "fragmented" && (t.timeToSampleTable.push({
2717
+ t.lastTimescaleUnits = 0, c(this, I).fastStart !== "fragmented" && (t.timeToSampleTable.push({
2718
2718
  sampleCount: 1,
2719
2719
  sampleDelta: mt(e.duration, t.timescale)
2720
2720
  }), t.compositionTimeOffsetTable.push({
@@ -2727,9 +2727,9 @@ vt = function(t, e) {
2727
2727
  r = !0;
2728
2728
  else {
2729
2729
  let s = e.presentationTimestamp - t.currentChunk.startTimestamp;
2730
- if (c(this, P).fastStart === "fragmented") {
2730
+ if (c(this, I).fastStart === "fragmented") {
2731
2731
  let n = c(this, it) ?? c(this, tt);
2732
- const a = c(this, P).minFragmentDuration ?? 1;
2732
+ const a = c(this, I).minFragmentDuration ?? 1;
2733
2733
  t === n && e.type === "key" && s >= a && (r = !0, z(this, wi, wr).call(this));
2734
2734
  } else
2735
2735
  r = s >= 0.5;
@@ -2742,7 +2742,7 @@ vt = function(t, e) {
2742
2742
  mr = /* @__PURE__ */ new WeakSet();
2743
2743
  Ts = function(t, e, i) {
2744
2744
  var a, l;
2745
- const r = c(this, P).firstTimestampBehavior === "strict", s = i.lastDecodeTimestamp === -1;
2745
+ const r = c(this, I).firstTimestampBehavior === "strict", s = i.lastDecodeTimestamp === -1;
2746
2746
  if (r && s && e !== 0)
2747
2747
  throw new Error(
2748
2748
  `The first chunk for your media track must have a timestamp of 0 (received DTS=${e}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
@@ -2750,10 +2750,10 @@ Ts = function(t, e, i) {
2750
2750
  If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
2751
2751
  `
2752
2752
  );
2753
- if (c(this, P).firstTimestampBehavior === "offset" || c(this, P).firstTimestampBehavior === "cross-track-offset") {
2753
+ if (c(this, I).firstTimestampBehavior === "offset" || c(this, I).firstTimestampBehavior === "cross-track-offset") {
2754
2754
  i.firstDecodeTimestamp === void 0 && (i.firstDecodeTimestamp = e);
2755
2755
  let u;
2756
- c(this, P).firstTimestampBehavior === "offset" ? u = i.firstDecodeTimestamp : u = Math.min(
2756
+ c(this, I).firstTimestampBehavior === "offset" ? u = i.firstDecodeTimestamp : u = Math.min(
2757
2757
  ((a = c(this, it)) == null ? void 0 : a.firstDecodeTimestamp) ?? 1 / 0,
2758
2758
  ((l = c(this, tt)) == null ? void 0 : l.firstDecodeTimestamp) ?? 1 / 0
2759
2759
  ), e -= u, t -= u;
@@ -2766,14 +2766,14 @@ If you want to offset all timestamps of a track such that the first one is zero,
2766
2766
  };
2767
2767
  Me = /* @__PURE__ */ new WeakSet();
2768
2768
  mi = function(t) {
2769
- if (c(this, P).fastStart === "fragmented")
2769
+ if (c(this, I).fastStart === "fragmented")
2770
2770
  throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");
2771
2771
  if (t.currentChunk) {
2772
2772
  if (t.finalizedChunks.push(t.currentChunk), c(this, re).push(t.currentChunk), (t.compactlyCodedChunkTable.length === 0 || ci(t.compactlyCodedChunkTable).samplesPerChunk !== t.currentChunk.samples.length) && t.compactlyCodedChunkTable.push({
2773
2773
  firstChunk: t.finalizedChunks.length,
2774
2774
  // 1-indexed
2775
2775
  samplesPerChunk: t.currentChunk.samples.length
2776
- }), c(this, P).fastStart === "in-memory") {
2776
+ }), c(this, I).fastStart === "in-memory") {
2777
2777
  t.currentChunk.offset = 0;
2778
2778
  return;
2779
2779
  }
@@ -2785,7 +2785,7 @@ mi = function(t) {
2785
2785
  };
2786
2786
  wi = /* @__PURE__ */ new WeakSet();
2787
2787
  wr = function(t = !0) {
2788
- if (c(this, P).fastStart !== "fragmented")
2788
+ if (c(this, I).fastStart !== "fragmented")
2789
2789
  throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");
2790
2790
  let e = [c(this, it), c(this, tt)].filter((l) => l && l.currentChunk);
2791
2791
  if (e.length === 0)
@@ -2873,7 +2873,7 @@ var gr = (t, e, i) => {
2873
2873
  constructor() {
2874
2874
  super(...arguments), this.buffer = null;
2875
2875
  }
2876
- }, Ps = class extends Ci {
2876
+ }, Is = class extends Ci {
2877
2877
  constructor(t) {
2878
2878
  if (super(), this.options = t, typeof t != "object")
2879
2879
  throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");
@@ -2903,7 +2903,7 @@ var gr = (t, e, i) => {
2903
2903
  if (e && e.chunkSize !== void 0 && (!Number.isInteger(e.chunkSize) || e.chunkSize <= 0))
2904
2904
  throw new TypeError("options.chunkSize, when provided, must be a positive integer");
2905
2905
  }
2906
- }, Bt, N, qi, Is, Hi, Rs, Xi, Bs, ni, Yi, Ji, Fs, Us = class {
2906
+ }, Bt, N, qi, Ps, Hi, Rs, Xi, Bs, ni, Yi, Ji, Fs, Us = class {
2907
2907
  constructor() {
2908
2908
  S(this, qi), S(this, Hi), S(this, Xi), S(this, ni), S(this, Ji), this.pos = 0, S(this, Bt, new Uint8Array(8)), S(this, N, new DataView(o(this, Bt).buffer)), this.offsets = /* @__PURE__ */ new WeakMap(), this.dataOffsets = /* @__PURE__ */ new WeakMap();
2909
2909
  }
@@ -2945,7 +2945,7 @@ var gr = (t, e, i) => {
2945
2945
  this.writeEBML(e);
2946
2946
  else if (this.offsets.set(t, this.pos), T(this, ni, Yi).call(this, t.id), Array.isArray(t.data)) {
2947
2947
  let e = this.pos, i = t.size === -1 ? 1 : t.size ?? 4;
2948
- t.size === -1 ? T(this, qi, Is).call(this, 255) : this.seek(this.pos + i);
2948
+ t.size === -1 ? T(this, qi, Ps).call(this, 255) : this.seek(this.pos + i);
2949
2949
  let r = this.pos;
2950
2950
  if (this.dataOffsets.set(t, r), this.writeEBML(t.data), t.size !== -1) {
2951
2951
  let s = this.pos - r, n = this.pos;
@@ -2960,7 +2960,7 @@ var gr = (t, e, i) => {
2960
2960
  Bt = /* @__PURE__ */ new WeakMap();
2961
2961
  N = /* @__PURE__ */ new WeakMap();
2962
2962
  qi = /* @__PURE__ */ new WeakSet();
2963
- Is = function(t) {
2963
+ Ps = function(t) {
2964
2964
  o(this, N).setUint8(0, t), this.write(o(this, Bt).subarray(0, 1));
2965
2965
  };
2966
2966
  Hi = /* @__PURE__ */ new WeakSet();
@@ -3061,10 +3061,10 @@ Zt = /* @__PURE__ */ new WeakMap();
3061
3061
  dt = /* @__PURE__ */ new WeakMap();
3062
3062
  ct = /* @__PURE__ */ new WeakMap();
3063
3063
  Lt = /* @__PURE__ */ new WeakMap();
3064
- var eo = 2 ** 24, io = 2, Ot, se, Pe, _e, Et, nt, gi, Zi, yr, Ds, br, Ws, Ie, vi, _r = class extends qe {
3064
+ var eo = 2 ** 24, io = 2, Ot, se, Ie, _e, Et, nt, gi, Zi, yr, Ds, br, Ws, Pe, vi, _r = class extends qe {
3065
3065
  constructor(t, e) {
3066
3066
  var i, r;
3067
- super(t), S(this, gi), S(this, yr), S(this, br), S(this, Ie), S(this, Ot, []), S(this, se, 0), S(this, Pe, void 0), S(this, _e, void 0), S(this, Et, void 0), S(this, nt, []), U(this, Pe, e), U(this, _e, ((i = t.options) == null ? void 0 : i.chunked) ?? !1), U(this, Et, ((r = t.options) == null ? void 0 : r.chunkSize) ?? eo);
3067
+ super(t), S(this, gi), S(this, yr), S(this, br), S(this, Pe), S(this, Ot, []), S(this, se, 0), S(this, Ie, void 0), S(this, _e, void 0), S(this, Et, void 0), S(this, nt, []), U(this, Ie, e), U(this, _e, ((i = t.options) == null ? void 0 : i.chunked) ?? !1), U(this, Et, ((r = t.options) == null ? void 0 : r.chunkSize) ?? eo);
3068
3068
  }
3069
3069
  write(t) {
3070
3070
  super.write(t), o(this, Ot).push({
@@ -3093,9 +3093,9 @@ var eo = 2 ** 24, io = 2, Ot, se, Pe, _e, Et, nt, gi, Zi, yr, Ds, br, Ws, Ie, vi
3093
3093
  for (let n of o(this, Ot))
3094
3094
  s.start <= n.start && n.start < s.start + s.size && s.data.set(n.data, n.start - s.start);
3095
3095
  if (o(this, _e))
3096
- T(this, gi, Zi).call(this, s.data, s.start), T(this, Ie, vi).call(this);
3096
+ T(this, gi, Zi).call(this, s.data, s.start), T(this, Pe, vi).call(this);
3097
3097
  else {
3098
- if (o(this, Pe) && s.start < o(this, se))
3098
+ if (o(this, Ie) && s.start < o(this, se))
3099
3099
  throw new Error("Internal error: Monotonicity violation.");
3100
3100
  (r = (i = this.target.options).onData) == null || r.call(i, s.data, s.start), U(this, se, s.start + s.data.byteLength);
3101
3101
  }
@@ -3103,12 +3103,12 @@ var eo = 2 ** 24, io = 2, Ot, se, Pe, _e, Et, nt, gi, Zi, yr, Ds, br, Ws, Ie, vi
3103
3103
  o(this, Ot).length = 0;
3104
3104
  }
3105
3105
  finalize() {
3106
- o(this, _e) && T(this, Ie, vi).call(this, !0);
3106
+ o(this, _e) && T(this, Pe, vi).call(this, !0);
3107
3107
  }
3108
3108
  };
3109
3109
  Ot = /* @__PURE__ */ new WeakMap();
3110
3110
  se = /* @__PURE__ */ new WeakMap();
3111
- Pe = /* @__PURE__ */ new WeakMap();
3111
+ Ie = /* @__PURE__ */ new WeakMap();
3112
3112
  _e = /* @__PURE__ */ new WeakMap();
3113
3113
  Et = /* @__PURE__ */ new WeakMap();
3114
3114
  nt = /* @__PURE__ */ new WeakMap();
@@ -3125,7 +3125,7 @@ Zi = function(t, e) {
3125
3125
  if (T(this, yr, Ds).call(this, r, a), r.written[0].start === 0 && r.written[0].end === o(this, Et) && (r.shouldFlush = !0), o(this, nt).length > io) {
3126
3126
  for (let l = 0; l < o(this, nt).length - 1; l++)
3127
3127
  o(this, nt)[l].shouldFlush = !0;
3128
- T(this, Ie, vi).call(this);
3128
+ T(this, Pe, vi).call(this);
3129
3129
  }
3130
3130
  n.byteLength < t.byteLength && T(this, gi, Zi).call(this, t.subarray(n.byteLength), e + n.byteLength);
3131
3131
  };
@@ -3149,14 +3149,14 @@ Ws = function(t) {
3149
3149
  };
3150
3150
  return o(this, nt).push(i), o(this, nt).sort((r, s) => r.start - s.start), o(this, nt).indexOf(i);
3151
3151
  };
3152
- Ie = /* @__PURE__ */ new WeakSet();
3152
+ Pe = /* @__PURE__ */ new WeakSet();
3153
3153
  vi = function(t = !1) {
3154
3154
  var e, i;
3155
3155
  for (let r = 0; r < o(this, nt).length; r++) {
3156
3156
  let s = o(this, nt)[r];
3157
3157
  if (!(!s.shouldFlush && !t)) {
3158
3158
  for (let n of s.written) {
3159
- if (o(this, Pe) && s.start + n.start < o(this, se))
3159
+ if (o(this, Ie) && s.start + n.start < o(this, se))
3160
3160
  throw new Error("Internal error: Monotonicity violation.");
3161
3161
  (i = (e = this.target.options).onData) == null || i.call(
3162
3162
  e,
@@ -3171,7 +3171,7 @@ vi = function(t = !1) {
3171
3171
  var ro = class extends _r {
3172
3172
  constructor(t, e) {
3173
3173
  var i;
3174
- super(new Ps({
3174
+ super(new Is({
3175
3175
  onData: (r, s) => t.stream.write({
3176
3176
  type: "write",
3177
3177
  data: r,
@@ -3181,17 +3181,17 @@ var ro = class extends _r {
3181
3181
  chunkSize: (i = t.options) == null ? void 0 : i.chunkSize
3182
3182
  }), e);
3183
3183
  }
3184
- }, ue = 1, Le = 2, yi = 3, so = 1, no = 2, ao = 17, oo = 2 ** 15, Re = 2 ** 13, jr = "https://github.com/Vanilagy/webm-muxer", zs = 6, Vs = 5, ho = ["strict", "offset", "permissive"], I, k, Oe, Ge, bt, pe, te, Xt, me, Ft, ne, ae, pt, He, oe, Pt, It, Gt, Be, Fe, he, le, bi, Ne, Ue, Qi, Ls, tr, Os, xr, Gs, Sr, Ns, Cr, $s, Er, js, Tr, qs, Ei, kr, Ti, Ar, Mr, Hs, Nt, ee, $t, ie, er, Xs, ir, Ys, xe, hi, Se, li, Pr, Js, ft, yt, de, $e, De, _i, Ir, Ks, xi, Rr, Ce, di, lo = class {
3184
+ }, ue = 1, Le = 2, yi = 3, so = 1, no = 2, ao = 17, oo = 2 ** 15, Re = 2 ** 13, jr = "https://github.com/Vanilagy/webm-muxer", zs = 6, Vs = 5, ho = ["strict", "offset", "permissive"], P, k, Oe, Ge, bt, pe, te, Xt, me, Ft, ne, ae, pt, He, oe, It, Pt, Gt, Be, Fe, he, le, bi, Ne, Ue, Qi, Ls, tr, Os, xr, Gs, Sr, Ns, Cr, $s, Er, js, Tr, qs, Ei, kr, Ti, Ar, Mr, Hs, Nt, ee, $t, ie, er, Xs, ir, Ys, xe, hi, Se, li, Ir, Js, ft, yt, de, $e, De, _i, Pr, Ks, xi, Rr, Ce, di, lo = class {
3185
3185
  constructor(t) {
3186
- S(this, Qi), S(this, tr), S(this, xr), S(this, Sr), S(this, Cr), S(this, Er), S(this, Tr), S(this, Ei), S(this, Ti), S(this, Mr), S(this, Nt), S(this, $t), S(this, er), S(this, ir), S(this, xe), S(this, Se), S(this, Pr), S(this, ft), S(this, de), S(this, De), S(this, Ir), S(this, xi), S(this, Ce), S(this, I, void 0), S(this, k, void 0), S(this, Oe, void 0), S(this, Ge, void 0), S(this, bt, void 0), S(this, pe, void 0), S(this, te, void 0), S(this, Xt, void 0), S(this, me, void 0), S(this, Ft, void 0), S(this, ne, void 0), S(this, ae, void 0), S(this, pt, void 0), S(this, He, void 0), S(this, oe, 0), S(this, Pt, []), S(this, It, []), S(this, Gt, []), S(this, Be, void 0), S(this, Fe, void 0), S(this, he, -1), S(this, le, -1), S(this, bi, -1), S(this, Ne, void 0), S(this, Ue, !1), T(this, Qi, Ls).call(this, t), U(this, I, {
3186
+ S(this, Qi), S(this, tr), S(this, xr), S(this, Sr), S(this, Cr), S(this, Er), S(this, Tr), S(this, Ei), S(this, Ti), S(this, Mr), S(this, Nt), S(this, $t), S(this, er), S(this, ir), S(this, xe), S(this, Se), S(this, Ir), S(this, ft), S(this, de), S(this, De), S(this, Pr), S(this, xi), S(this, Ce), S(this, P, void 0), S(this, k, void 0), S(this, Oe, void 0), S(this, Ge, void 0), S(this, bt, void 0), S(this, pe, void 0), S(this, te, void 0), S(this, Xt, void 0), S(this, me, void 0), S(this, Ft, void 0), S(this, ne, void 0), S(this, ae, void 0), S(this, pt, void 0), S(this, He, void 0), S(this, oe, 0), S(this, It, []), S(this, Pt, []), S(this, Gt, []), S(this, Be, void 0), S(this, Fe, void 0), S(this, he, -1), S(this, le, -1), S(this, bi, -1), S(this, Ne, void 0), S(this, Ue, !1), T(this, Qi, Ls).call(this, t), U(this, P, {
3187
3187
  type: "webm",
3188
3188
  firstTimestampBehavior: "strict",
3189
3189
  ...t
3190
3190
  }), this.target = t.target;
3191
- let e = !!o(this, I).streaming;
3191
+ let e = !!o(this, P).streaming;
3192
3192
  if (t.target instanceof Ms)
3193
3193
  U(this, k, new to(t.target));
3194
- else if (t.target instanceof Ps)
3194
+ else if (t.target instanceof Is)
3195
3195
  U(this, k, new _r(t.target, e));
3196
3196
  else if (t.target instanceof Qa)
3197
3197
  U(this, k, new ro(t.target, e));
@@ -3220,15 +3220,15 @@ var ro = class extends _r {
3220
3220
  throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");
3221
3221
  if (r && typeof r != "object")
3222
3222
  throw new TypeError("addVideoChunkRaw's fourth argument (meta), when provided, must be an object.");
3223
- if (T(this, Ce, di).call(this), !o(this, I).video)
3223
+ if (T(this, Ce, di).call(this), !o(this, P).video)
3224
3224
  throw new Error("No video track declared.");
3225
3225
  o(this, Be) === void 0 && U(this, Be, i), r && T(this, er, Xs).call(this, r);
3226
3226
  let s = T(this, Se, li).call(this, t, e, i, ue);
3227
- for (o(this, I).video.codec === "V_VP9" && T(this, ir, Ys).call(this, s), U(this, he, s.timestamp); o(this, It).length > 0 && o(this, It)[0].timestamp <= s.timestamp; ) {
3228
- let n = o(this, It).shift();
3227
+ for (o(this, P).video.codec === "V_VP9" && T(this, ir, Ys).call(this, s), U(this, he, s.timestamp); o(this, Pt).length > 0 && o(this, Pt)[0].timestamp <= s.timestamp; ) {
3228
+ let n = o(this, Pt).shift();
3229
3229
  T(this, ft, yt).call(this, n, !1);
3230
3230
  }
3231
- !o(this, I).audio || s.timestamp <= o(this, le) ? T(this, ft, yt).call(this, s, !0) : o(this, Pt).push(s), T(this, xe, hi).call(this), T(this, Nt, ee).call(this);
3231
+ !o(this, P).audio || s.timestamp <= o(this, le) ? T(this, ft, yt).call(this, s, !0) : o(this, It).push(s), T(this, xe, hi).call(this), T(this, Nt, ee).call(this);
3232
3232
  }
3233
3233
  addAudioChunk(t, e, i) {
3234
3234
  if (!(t instanceof EncodedAudioChunk))
@@ -3251,15 +3251,15 @@ var ro = class extends _r {
3251
3251
  throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");
3252
3252
  if (r && typeof r != "object")
3253
3253
  throw new TypeError("addAudioChunkRaw's fourth argument (meta), when provided, must be an object.");
3254
- if (T(this, Ce, di).call(this), !o(this, I).audio)
3254
+ if (T(this, Ce, di).call(this), !o(this, P).audio)
3255
3255
  throw new Error("No audio track declared.");
3256
- o(this, Fe) === void 0 && U(this, Fe, i), r != null && r.decoderConfig && (o(this, I).streaming ? U(this, Ft, T(this, de, $e).call(this, r.decoderConfig.description)) : T(this, De, _i).call(this, o(this, Ft), r.decoderConfig.description));
3256
+ o(this, Fe) === void 0 && U(this, Fe, i), r != null && r.decoderConfig && (o(this, P).streaming ? U(this, Ft, T(this, de, $e).call(this, r.decoderConfig.description)) : T(this, De, _i).call(this, o(this, Ft), r.decoderConfig.description));
3257
3257
  let s = T(this, Se, li).call(this, t, e, i, Le);
3258
- for (U(this, le, s.timestamp); o(this, Pt).length > 0 && o(this, Pt)[0].timestamp <= s.timestamp; ) {
3259
- let n = o(this, Pt).shift();
3258
+ for (U(this, le, s.timestamp); o(this, It).length > 0 && o(this, It)[0].timestamp <= s.timestamp; ) {
3259
+ let n = o(this, It).shift();
3260
3260
  T(this, ft, yt).call(this, n, !0);
3261
3261
  }
3262
- !o(this, I).video || s.timestamp <= o(this, he) ? T(this, ft, yt).call(this, s, !o(this, I).video) : o(this, It).push(s), T(this, xe, hi).call(this), T(this, Nt, ee).call(this);
3262
+ !o(this, P).video || s.timestamp <= o(this, he) ? T(this, ft, yt).call(this, s, !o(this, P).video) : o(this, Pt).push(s), T(this, xe, hi).call(this), T(this, Nt, ee).call(this);
3263
3263
  }
3264
3264
  addSubtitleChunk(t, e, i) {
3265
3265
  if (typeof t != "object" || !t)
@@ -3274,29 +3274,29 @@ var ro = class extends _r {
3274
3274
  throw new TypeError("additions, when present, must be an instance of Uint8Array.");
3275
3275
  if (typeof e != "object")
3276
3276
  throw new TypeError("addSubtitleChunk's second argument (meta) must be an object.");
3277
- if (T(this, Ce, di).call(this), !o(this, I).subtitles)
3277
+ if (T(this, Ce, di).call(this), !o(this, P).subtitles)
3278
3278
  throw new Error("No subtitle track declared.");
3279
- e != null && e.decoderConfig && (o(this, I).streaming ? U(this, ne, T(this, de, $e).call(this, e.decoderConfig.description)) : T(this, De, _i).call(this, o(this, ne), e.decoderConfig.description));
3279
+ e != null && e.decoderConfig && (o(this, P).streaming ? U(this, ne, T(this, de, $e).call(this, e.decoderConfig.description)) : T(this, De, _i).call(this, o(this, ne), e.decoderConfig.description));
3280
3280
  let r = T(this, Se, li).call(this, t.body, "key", i ?? t.timestamp, yi, t.duration, t.additions);
3281
3281
  U(this, bi, r.timestamp), o(this, Gt).push(r), T(this, xe, hi).call(this), T(this, Nt, ee).call(this);
3282
3282
  }
3283
3283
  finalize() {
3284
3284
  if (o(this, Ue))
3285
3285
  throw new Error("Cannot finalize a muxer more than once.");
3286
- for (; o(this, Pt).length > 0; )
3287
- T(this, ft, yt).call(this, o(this, Pt).shift(), !0);
3288
3286
  for (; o(this, It).length > 0; )
3289
3287
  T(this, ft, yt).call(this, o(this, It).shift(), !0);
3288
+ for (; o(this, Pt).length > 0; )
3289
+ T(this, ft, yt).call(this, o(this, Pt).shift(), !0);
3290
3290
  for (; o(this, Gt).length > 0 && o(this, Gt)[0].timestamp <= o(this, oe); )
3291
3291
  T(this, ft, yt).call(this, o(this, Gt).shift(), !1);
3292
- if (o(this, pt) && T(this, xi, Rr).call(this), o(this, k).writeEBML(o(this, ae)), !o(this, I).streaming) {
3292
+ if (o(this, pt) && T(this, xi, Rr).call(this), o(this, k).writeEBML(o(this, ae)), !o(this, P).streaming) {
3293
3293
  let t = o(this, k).pos, e = o(this, k).pos - o(this, $t, ie);
3294
3294
  o(this, k).seek(o(this, k).offsets.get(o(this, Oe)) + 4), o(this, k).writeEBMLVarInt(e, zs), o(this, te).data = new vr(o(this, oe)), o(this, k).seek(o(this, k).offsets.get(o(this, te))), o(this, k).writeEBML(o(this, te)), o(this, bt).data[0].data[1].data = o(this, k).offsets.get(o(this, ae)) - o(this, $t, ie), o(this, bt).data[1].data[1].data = o(this, k).offsets.get(o(this, Ge)) - o(this, $t, ie), o(this, bt).data[2].data[1].data = o(this, k).offsets.get(o(this, pe)) - o(this, $t, ie), o(this, k).seek(o(this, k).offsets.get(o(this, bt))), o(this, k).writeEBML(o(this, bt)), o(this, k).seek(t);
3295
3295
  }
3296
3296
  T(this, Nt, ee).call(this), o(this, k).finalize(), U(this, Ue, !0);
3297
3297
  }
3298
3298
  };
3299
- I = /* @__PURE__ */ new WeakMap();
3299
+ P = /* @__PURE__ */ new WeakMap();
3300
3300
  k = /* @__PURE__ */ new WeakMap();
3301
3301
  Oe = /* @__PURE__ */ new WeakMap();
3302
3302
  Ge = /* @__PURE__ */ new WeakMap();
@@ -3311,8 +3311,8 @@ ae = /* @__PURE__ */ new WeakMap();
3311
3311
  pt = /* @__PURE__ */ new WeakMap();
3312
3312
  He = /* @__PURE__ */ new WeakMap();
3313
3313
  oe = /* @__PURE__ */ new WeakMap();
3314
- Pt = /* @__PURE__ */ new WeakMap();
3315
3314
  It = /* @__PURE__ */ new WeakMap();
3315
+ Pt = /* @__PURE__ */ new WeakMap();
3316
3316
  Gt = /* @__PURE__ */ new WeakMap();
3317
3317
  Be = /* @__PURE__ */ new WeakMap();
3318
3318
  Fe = /* @__PURE__ */ new WeakMap();
@@ -3368,7 +3368,7 @@ Ls = function(t) {
3368
3368
  };
3369
3369
  tr = /* @__PURE__ */ new WeakSet();
3370
3370
  Os = function() {
3371
- o(this, k) instanceof qe && o(this, k).target.options.onHeader && o(this, k).startTrackingWrites(), T(this, xr, Gs).call(this), o(this, I).streaming || T(this, Er, js).call(this), T(this, Tr, qs).call(this), T(this, Sr, Ns).call(this), T(this, Cr, $s).call(this), o(this, I).streaming || (T(this, Ei, kr).call(this), T(this, Ti, Ar).call(this)), T(this, Mr, Hs).call(this), T(this, Nt, ee).call(this);
3371
+ o(this, k) instanceof qe && o(this, k).target.options.onHeader && o(this, k).startTrackingWrites(), T(this, xr, Gs).call(this), o(this, P).streaming || T(this, Er, js).call(this), T(this, Tr, qs).call(this), T(this, Sr, Ns).call(this), T(this, Cr, $s).call(this), o(this, P).streaming || (T(this, Ei, kr).call(this), T(this, Ti, Ar).call(this)), T(this, Mr, Hs).call(this), T(this, Nt, ee).call(this);
3372
3372
  };
3373
3373
  xr = /* @__PURE__ */ new WeakSet();
3374
3374
  Gs = function() {
@@ -3377,7 +3377,7 @@ Gs = function() {
3377
3377
  { id: 17143, data: 1 },
3378
3378
  { id: 17138, data: 4 },
3379
3379
  { id: 17139, data: 8 },
3380
- { id: 17026, data: o(this, I).type ?? "webm" },
3380
+ { id: 17026, data: o(this, P).type ?? "webm" },
3381
3381
  { id: 17031, data: 2 },
3382
3382
  { id: 17029, data: 2 }
3383
3383
  ] };
@@ -3422,42 +3422,42 @@ qs = function() {
3422
3422
  { id: 2807729, data: 1e6 },
3423
3423
  { id: 19840, data: jr },
3424
3424
  { id: 22337, data: jr },
3425
- o(this, I).streaming ? null : t
3425
+ o(this, P).streaming ? null : t
3426
3426
  ] };
3427
3427
  U(this, Ge, e);
3428
3428
  };
3429
3429
  Ei = /* @__PURE__ */ new WeakSet();
3430
3430
  kr = function() {
3431
3431
  let t = { id: 374648427, data: [] };
3432
- U(this, pe, t), o(this, I).video && t.data.push({ id: 174, data: [
3432
+ U(this, pe, t), o(this, P).video && t.data.push({ id: 174, data: [
3433
3433
  { id: 215, data: ue },
3434
3434
  { id: 29637, data: ue },
3435
3435
  { id: 131, data: so },
3436
- { id: 134, data: o(this, I).video.codec },
3436
+ { id: 134, data: o(this, P).video.codec },
3437
3437
  o(this, me),
3438
- o(this, I).video.frameRate ? { id: 2352003, data: 1e9 / o(this, I).video.frameRate } : null,
3438
+ o(this, P).video.frameRate ? { id: 2352003, data: 1e9 / o(this, P).video.frameRate } : null,
3439
3439
  { id: 224, data: [
3440
- { id: 176, data: o(this, I).video.width },
3441
- { id: 186, data: o(this, I).video.height },
3442
- o(this, I).video.alpha ? { id: 21440, data: 1 } : null,
3440
+ { id: 176, data: o(this, P).video.width },
3441
+ { id: 186, data: o(this, P).video.height },
3442
+ o(this, P).video.alpha ? { id: 21440, data: 1 } : null,
3443
3443
  o(this, Xt)
3444
3444
  ] }
3445
- ] }), o(this, I).audio && (U(this, Ft, o(this, I).streaming ? o(this, Ft) || null : { id: 236, size: 4, data: new Uint8Array(Re) }), t.data.push({ id: 174, data: [
3445
+ ] }), o(this, P).audio && (U(this, Ft, o(this, P).streaming ? o(this, Ft) || null : { id: 236, size: 4, data: new Uint8Array(Re) }), t.data.push({ id: 174, data: [
3446
3446
  { id: 215, data: Le },
3447
3447
  { id: 29637, data: Le },
3448
3448
  { id: 131, data: no },
3449
- { id: 134, data: o(this, I).audio.codec },
3449
+ { id: 134, data: o(this, P).audio.codec },
3450
3450
  o(this, Ft),
3451
3451
  { id: 225, data: [
3452
- { id: 181, data: new ks(o(this, I).audio.sampleRate) },
3453
- { id: 159, data: o(this, I).audio.numberOfChannels },
3454
- o(this, I).audio.bitDepth ? { id: 25188, data: o(this, I).audio.bitDepth } : null
3452
+ { id: 181, data: new ks(o(this, P).audio.sampleRate) },
3453
+ { id: 159, data: o(this, P).audio.numberOfChannels },
3454
+ o(this, P).audio.bitDepth ? { id: 25188, data: o(this, P).audio.bitDepth } : null
3455
3455
  ] }
3456
- ] })), o(this, I).subtitles && t.data.push({ id: 174, data: [
3456
+ ] })), o(this, P).subtitles && t.data.push({ id: 174, data: [
3457
3457
  { id: 215, data: yi },
3458
3458
  { id: 29637, data: yi },
3459
3459
  { id: 131, data: ao },
3460
- { id: 134, data: o(this, I).subtitles.codec },
3460
+ { id: 134, data: o(this, P).subtitles.codec },
3461
3461
  o(this, ne)
3462
3462
  ] });
3463
3463
  };
@@ -3465,9 +3465,9 @@ Ti = /* @__PURE__ */ new WeakSet();
3465
3465
  Ar = function() {
3466
3466
  let t = {
3467
3467
  id: 408125543,
3468
- size: o(this, I).streaming ? -1 : zs,
3468
+ size: o(this, P).streaming ? -1 : zs,
3469
3469
  data: [
3470
- o(this, I).streaming ? null : o(this, bt),
3470
+ o(this, P).streaming ? null : o(this, bt),
3471
3471
  o(this, Ge),
3472
3472
  o(this, pe)
3473
3473
  ]
@@ -3512,12 +3512,12 @@ Xs = function(t) {
3512
3512
  smpte170m: 6
3513
3513
  }[e.primaries] },
3514
3514
  { id: 21945, data: [1, 2][Number(e.fullRange)] }
3515
- ], !o(this, I).streaming) {
3515
+ ], !o(this, P).streaming) {
3516
3516
  let i = o(this, k).pos;
3517
3517
  o(this, k).seek(o(this, k).offsets.get(o(this, Xt))), o(this, k).writeEBML(o(this, Xt)), o(this, k).seek(i);
3518
3518
  }
3519
3519
  }
3520
- t.decoderConfig.description && (o(this, I).streaming ? U(this, me, T(this, de, $e).call(this, t.decoderConfig.description)) : T(this, De, _i).call(this, o(this, me), t.decoderConfig.description));
3520
+ t.decoderConfig.description && (o(this, P).streaming ? U(this, me, T(this, de, $e).call(this, t.decoderConfig.description)) : T(this, De, _i).call(this, o(this, me), t.decoderConfig.description));
3521
3521
  }
3522
3522
  };
3523
3523
  ir = /* @__PURE__ */ new WeakSet();
@@ -3552,15 +3552,15 @@ Ys = function(t) {
3552
3552
  xe = /* @__PURE__ */ new WeakSet();
3553
3553
  hi = function() {
3554
3554
  let t = Math.min(
3555
- o(this, I).video ? o(this, he) : 1 / 0,
3556
- o(this, I).audio ? o(this, le) : 1 / 0
3555
+ o(this, P).video ? o(this, he) : 1 / 0,
3556
+ o(this, P).audio ? o(this, le) : 1 / 0
3557
3557
  ), e = o(this, Gt);
3558
3558
  for (; e.length > 0 && e[0].timestamp <= t; )
3559
- T(this, ft, yt).call(this, e.shift(), !o(this, I).video && !o(this, I).audio);
3559
+ T(this, ft, yt).call(this, e.shift(), !o(this, P).video && !o(this, P).audio);
3560
3560
  };
3561
3561
  Se = /* @__PURE__ */ new WeakSet();
3562
3562
  li = function(t, e, i, r, s, n) {
3563
- let a = T(this, Pr, Js).call(this, i, r);
3563
+ let a = T(this, Ir, Js).call(this, i, r);
3564
3564
  return {
3565
3565
  data: t,
3566
3566
  additions: n,
@@ -3570,12 +3570,12 @@ li = function(t, e, i, r, s, n) {
3570
3570
  trackNumber: r
3571
3571
  };
3572
3572
  };
3573
- Pr = /* @__PURE__ */ new WeakSet();
3573
+ Ir = /* @__PURE__ */ new WeakSet();
3574
3574
  Js = function(t, e) {
3575
3575
  let i = e === ue ? o(this, he) : e === Le ? o(this, le) : o(this, bi);
3576
3576
  if (e !== yi) {
3577
3577
  let r = e === ue ? o(this, Be) : o(this, Fe);
3578
- if (o(this, I).firstTimestampBehavior === "strict" && i === -1 && t !== 0)
3578
+ if (o(this, P).firstTimestampBehavior === "strict" && i === -1 && t !== 0)
3579
3579
  throw new Error(
3580
3580
  `The first chunk for your media track must have a timestamp of 0 (received ${t}). Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of the document, which is probably what you want.
3581
3581
 
@@ -3583,7 +3583,7 @@ If you want to offset all timestamps of a track such that the first one is zero,
3583
3583
  If you want to allow non-zero first timestamps, set firstTimestampBehavior: 'permissive'.
3584
3584
  `
3585
3585
  );
3586
- o(this, I).firstTimestampBehavior === "offset" && (t -= r);
3586
+ o(this, P).firstTimestampBehavior === "offset" && (t -= r);
3587
3587
  }
3588
3588
  if (t < i)
3589
3589
  throw new Error(
@@ -3595,9 +3595,9 @@ If you want to allow non-zero first timestamps, set firstTimestampBehavior: 'per
3595
3595
  };
3596
3596
  ft = /* @__PURE__ */ new WeakSet();
3597
3597
  yt = function(t, e) {
3598
- o(this, I).streaming && !o(this, pe) && (T(this, Ei, kr).call(this), T(this, Ti, Ar).call(this));
3598
+ o(this, P).streaming && !o(this, pe) && (T(this, Ei, kr).call(this), T(this, Ti, Ar).call(this));
3599
3599
  let i = Math.floor(t.timestamp / 1e3), r = i - o(this, He), s = e && t.type === "key" && r >= 1e3, n = r >= oo;
3600
- if ((!o(this, pt) || s || n) && (T(this, Ir, Ks).call(this, i), r = 0), r < 0)
3600
+ if ((!o(this, pt) || s || n) && (T(this, Pr, Ks).call(this, i), r = 0), r < 0)
3601
3601
  return;
3602
3602
  let a = new Uint8Array(4), l = new DataView(a.buffer);
3603
3603
  if (l.setUint8(0, 128 | t.trackNumber), l.setInt16(1, r, !1), t.duration === void 0 && !t.additions) {
@@ -3638,11 +3638,11 @@ _i = function(t, e) {
3638
3638
  { id: 236, size: 4, data: new Uint8Array(s) }
3639
3639
  ], o(this, k).writeEBML(t), o(this, k).seek(i);
3640
3640
  };
3641
- Ir = /* @__PURE__ */ new WeakSet();
3641
+ Pr = /* @__PURE__ */ new WeakSet();
3642
3642
  Ks = function(t) {
3643
3643
  o(this, pt) && T(this, xi, Rr).call(this), o(this, k) instanceof qe && o(this, k).target.options.onCluster && o(this, k).startTrackingWrites(), U(this, pt, {
3644
3644
  id: 524531317,
3645
- size: o(this, I).streaming ? -1 : Vs,
3645
+ size: o(this, P).streaming ? -1 : Vs,
3646
3646
  data: [
3647
3647
  { id: 231, data: t }
3648
3648
  ]
@@ -3650,11 +3650,11 @@ Ks = function(t) {
3650
3650
  let e = o(this, k).offsets.get(o(this, pt)) - o(this, $t, ie);
3651
3651
  o(this, ae).data.push({ id: 187, data: [
3652
3652
  { id: 179, data: t },
3653
- o(this, I).video ? { id: 183, data: [
3653
+ o(this, P).video ? { id: 183, data: [
3654
3654
  { id: 247, data: ue },
3655
3655
  { id: 241, data: e }
3656
3656
  ] } : null,
3657
- o(this, I).audio ? { id: 183, data: [
3657
+ o(this, P).audio ? { id: 183, data: [
3658
3658
  { id: 247, data: Le },
3659
3659
  { id: 241, data: e }
3660
3660
  ] } : null
@@ -3662,7 +3662,7 @@ Ks = function(t) {
3662
3662
  };
3663
3663
  xi = /* @__PURE__ */ new WeakSet();
3664
3664
  Rr = function() {
3665
- if (!o(this, I).streaming) {
3665
+ if (!o(this, P).streaming) {
3666
3666
  let t = o(this, k).pos - o(this, k).dataOffsets.get(o(this, pt)), e = o(this, k).pos;
3667
3667
  o(this, k).seek(o(this, k).offsets.get(o(this, pt)) + 4), o(this, k).writeEBMLVarInt(t, Vs), o(this, k).seek(e);
3668
3668
  }
@@ -3843,7 +3843,7 @@ async function _o(t, e = {}) {
3843
3843
  async function xo(t, e = {}) {
3844
3844
  if (!t || !t.frames.length)
3845
3845
  throw new Error("[p5.export] encodeAnimatedWebP: buffer has no frames");
3846
- const { width: i, height: r, fps: s, frames: n } = t, a = Io(e.quality ?? 0.85), l = Math.max(0, e.loop ?? 0), u = Math.max(1, Math.round(1e3 / (s || 30)));
3846
+ const { width: i, height: r, fps: s, frames: n } = t, a = Po(e.quality ?? 0.85), l = Math.max(0, e.loop ?? 0), u = Math.max(1, Math.round(1e3 / (s || 30)));
3847
3847
  await So(i, r);
3848
3848
  const g = document.createElement("canvas");
3849
3849
  g.width = i, g.height = r;
@@ -3881,7 +3881,7 @@ function Zs(t, e) {
3881
3881
  function Co(t) {
3882
3882
  let e = 12;
3883
3883
  for (; e + 8 <= t.length; ) {
3884
- const i = String.fromCharCode(t[e], t[e + 1], t[e + 2], t[e + 3]), r = Po(t, e + 4), s = r + (r & 1);
3884
+ const i = String.fromCharCode(t[e], t[e + 1], t[e + 2], t[e + 3]), r = Io(t, e + 4), s = r + (r & 1);
3885
3885
  if (i === "VP8 " || i === "VP8L")
3886
3886
  return t.slice(e, e + 8 + s);
3887
3887
  e += 8 + s;
@@ -3927,10 +3927,10 @@ function We(t, e, i) {
3927
3927
  function Qs(t, e, i) {
3928
3928
  t[e] = i & 255, t[e + 1] = i >> 8 & 255, t[e + 2] = i >> 16 & 255, t[e + 3] = i >> 24 & 255;
3929
3929
  }
3930
- function Po(t, e) {
3930
+ function Io(t, e) {
3931
3931
  return t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24 >>> 0;
3932
3932
  }
3933
- function Io(t) {
3933
+ function Po(t) {
3934
3934
  return Math.max(0, Math.min(1, t));
3935
3935
  }
3936
3936
  const Ze = {
@@ -4378,9 +4378,28 @@ function tn(t) {
4378
4378
  const e = {};
4379
4379
  Br(t, t.prototype, e);
4380
4380
  const i = (r, s) => typeof s == "function" && typeof t.prototype.registerMethod == "function" && t.prototype.registerMethod(r, s);
4381
- return i("beforeSetup", e.presetup), i("afterSetup", e.postsetup), i("pre", e.predraw), i("post", e.postdraw), console.info("[p5.export] Registered against p5 1.x — vector SVG, image, GIF, video, PDF exports available. Use p5 2.0 for full feature parity."), !0;
4381
+ return i("beforeSetup", e.presetup), i("afterSetup", e.postsetup), i("pre", e.predraw), i("post", e.postdraw), qo(t), console.info("[p5.export] Registered against p5 1.x — vector SVG, image, GIF, video, PDF exports available. Use p5 2.0 for full feature parity."), !0;
4382
4382
  }
4383
- function eh(t) {
4383
+ function qo(t) {
4384
+ if (typeof window > "u") return;
4385
+ const e = Date.now(), i = setInterval(() => {
4386
+ if ((window.p5ExportConfig || {}).autoGUI === !1) {
4387
+ clearInterval(i);
4388
+ return;
4389
+ }
4390
+ const s = t && t.instance;
4391
+ if (s && s._p5ExportPanel) {
4392
+ clearInterval(i);
4393
+ return;
4394
+ }
4395
+ if (s && s._setupDone && typeof s.createExportGUI == "function") {
4396
+ s.createExportGUI(), clearInterval(i);
4397
+ return;
4398
+ }
4399
+ Date.now() - e > 3e4 && clearInterval(i);
4400
+ }, 150);
4401
+ }
4402
+ function Ho(t) {
4384
4403
  if (!t) throw new Error("[p5.export] register() called with no p5 constructor");
4385
4404
  if (typeof t.registerAddon == "function") {
4386
4405
  t.registerAddon(Br);
@@ -4392,15 +4411,25 @@ function eh(t) {
4392
4411
  function Ui() {
4393
4412
  return typeof window > "u" || !window.p5 ? !1 : window.p5.prototype && window.p5.prototype.__p5ExportInstalled || window.p5.__p5ExportAutoRegistered ? !0 : typeof window.p5.registerAddon == "function" ? (window.p5.registerAddon(Br), window.p5.__p5ExportAutoRegistered = !0, !0) : tn(window.p5);
4394
4413
  }
4414
+ function Xo() {
4415
+ typeof window > "u" || window.__p5ExportModuleTried || (window.__p5ExportModuleTried = !0, import(
4416
+ /* @vite-ignore */
4417
+ "p5"
4418
+ ).then((t) => {
4419
+ const e = t && (t.default || t.p5) || t;
4420
+ !e || typeof e != "function" && !e.prototype || e.__p5ExportAutoRegistered || e.prototype && e.prototype.__p5ExportInstalled || (Ho(e), e.__p5ExportAutoRegistered = !0);
4421
+ }).catch(() => {
4422
+ }));
4423
+ }
4395
4424
  if (typeof window < "u" && !Ui()) {
4396
4425
  const t = setInterval(() => {
4397
4426
  Ui() && clearInterval(t);
4398
4427
  }, 10);
4399
- setTimeout(() => clearInterval(t), 5e3), window.addEventListener("p5Ready", Ui, { once: !0 });
4428
+ setTimeout(() => clearInterval(t), 5e3), window.addEventListener("p5Ready", Ui, { once: !0 }), Xo();
4400
4429
  }
4401
4430
  export {
4402
4431
  Br as default,
4403
4432
  Br as p5ExportAddon,
4404
- eh as register
4433
+ Ho as register
4405
4434
  };
4406
4435
  //# sourceMappingURL=p5.export.js.map