@taole/giftstage 0.1.24 → 0.1.26

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.
@@ -889,7 +889,7 @@ const _ = class z {
889
889
  }
890
890
  }
891
891
  ]
892
- }), i = this.instancedTextureBindGroupLayout, o = this.device.createShaderModule({ code: I }), e = g === "test" ? {
892
+ }), o = this.instancedTextureBindGroupLayout, i = this.device.createShaderModule({ code: I }), e = g === "test" ? {
893
893
  format: "depth24plus-stencil8",
894
894
  depthWriteEnabled: !1,
895
895
  depthCompare: "always",
@@ -909,9 +909,9 @@ const _ = class z {
909
909
  },
910
910
  stencilBack: { compare: "always", passOp: "keep", failOp: "keep", depthFailOp: "keep" }
911
911
  }, a = this.device.createRenderPipeline({
912
- layout: this.device.createPipelineLayout({ bindGroupLayouts: [E, i] }),
912
+ layout: this.device.createPipelineLayout({ bindGroupLayouts: [E, o] }),
913
913
  vertex: {
914
- module: o,
914
+ module: i,
915
915
  entryPoint: "vs",
916
916
  buffers: [
917
917
  {
@@ -921,7 +921,7 @@ const _ = class z {
921
921
  ]
922
922
  },
923
923
  fragment: {
924
- module: o,
924
+ module: i,
925
925
  entryPoint: "fs",
926
926
  targets: [
927
927
  {
@@ -989,7 +989,7 @@ const _ = class z {
989
989
  depthFailOp: "keep"
990
990
  },
991
991
  stencilBack: { compare: "always", passOp: "keep", failOp: "keep", depthFailOp: "keep" }
992
- }, i = this.device.createRenderPipeline({
992
+ }, o = this.device.createRenderPipeline({
993
993
  layout: this.device.createPipelineLayout({ bindGroupLayouts: [g, Q] }),
994
994
  vertex: {
995
995
  module: C,
@@ -1022,7 +1022,7 @@ const _ = class z {
1022
1022
  multisample: { count: this.msaaSampleCount }
1023
1023
  });
1024
1024
  this.pipelines.set("vap-instanced:none", {
1025
- pipeline: i,
1025
+ pipeline: o,
1026
1026
  bindGroupLayout: g,
1027
1027
  instancedDataBindGroup: this.device.createBindGroup({
1028
1028
  layout: g,
@@ -1073,7 +1073,7 @@ const _ = class z {
1073
1073
  depthFailOp: "keep"
1074
1074
  },
1075
1075
  stencilBack: { compare: "always", passOp: "keep", failOp: "keep", depthFailOp: "keep" }
1076
- }, i = this.device.createRenderPipeline({
1076
+ }, o = this.device.createRenderPipeline({
1077
1077
  layout: this.device.createPipelineLayout({ bindGroupLayouts: [g, Q] }),
1078
1078
  vertex: {
1079
1079
  module: C,
@@ -1106,7 +1106,7 @@ const _ = class z {
1106
1106
  multisample: { count: this.msaaSampleCount }
1107
1107
  });
1108
1108
  this.pipelines.set("alpha-video-instanced:none", {
1109
- pipeline: i,
1109
+ pipeline: o,
1110
1110
  bindGroupLayout: g,
1111
1111
  instancedDataBindGroup: this.device.createBindGroup({
1112
1112
  layout: g,
@@ -1128,8 +1128,8 @@ const _ = class z {
1128
1128
  textureCount: 1
1129
1129
  });
1130
1130
  }
1131
- createTexturedPipeline(A, I, g, Q, C, E, i = 1) {
1132
- const o = this.device.createShaderModule({ code: I }), e = E === "test" ? {
1131
+ createTexturedPipeline(A, I, g, Q, C, E, o = 1) {
1132
+ const i = this.device.createShaderModule({ code: I }), e = E === "test" ? {
1133
1133
  format: "depth24plus-stencil8",
1134
1134
  depthWriteEnabled: !1,
1135
1135
  depthCompare: "always",
@@ -1151,12 +1151,12 @@ const _ = class z {
1151
1151
  }, a = this.device.createRenderPipeline({
1152
1152
  layout: this.device.createPipelineLayout({ bindGroupLayouts: [g] }),
1153
1153
  vertex: {
1154
- module: o,
1154
+ module: i,
1155
1155
  entryPoint: "vs",
1156
1156
  buffers: [{ arrayStride: C, attributes: Q }]
1157
1157
  },
1158
1158
  fragment: {
1159
- module: o,
1159
+ module: i,
1160
1160
  entryPoint: "fs",
1161
1161
  targets: [
1162
1162
  {
@@ -1172,7 +1172,7 @@ const _ = class z {
1172
1172
  depthStencil: e,
1173
1173
  multisample: { count: this.msaaSampleCount }
1174
1174
  });
1175
- this.pipelines.set(A, { pipeline: a, bindGroupLayout: g, textureCount: i });
1175
+ this.pipelines.set(A, { pipeline: a, bindGroupLayout: g, textureCount: o });
1176
1176
  }
1177
1177
  createClipMaskPipeline(A) {
1178
1178
  const I = this.device.createShaderModule({ code: tA.clipMask }), g = this.device.createRenderPipeline({
@@ -1309,9 +1309,9 @@ const _ = class z {
1309
1309
  updateBuffer(A, I, g = 0) {
1310
1310
  const Q = this.buffers.get(A.id);
1311
1311
  if (!Q) return;
1312
- const C = Math.max(0, Math.floor(g)), E = this.bufferSourceByteLength(I), i = Math.max(4, C + E);
1313
- i > Q.buffer.size && (Q.buffer.destroy(), Q.buffer = this.device.createBuffer({
1314
- size: i,
1312
+ const C = Math.max(0, Math.floor(g)), E = this.bufferSourceByteLength(I), o = Math.max(4, C + E);
1313
+ o > Q.buffer.size && (Q.buffer.destroy(), Q.buffer = this.device.createBuffer({
1314
+ size: o,
1315
1315
  usage: this.gpuBufferUsage(Q.usage)
1316
1316
  }), Q.usage === "vertex" && this.lastVertexBufferId === A.id && (this.lastVertexBufferId = -1), Q.usage === "index" && this.lastIndexBufferId === A.id && (this.lastIndexBufferId = -1)), this.writeBufferSource(Q.buffer, C, I);
1317
1317
  }
@@ -1364,14 +1364,14 @@ const _ = class z {
1364
1364
  */
1365
1365
  copyImageSourceToTexture(A, I, g, Q, C = !1) {
1366
1366
  if (typeof VideoFrame != "undefined" && Q instanceof VideoFrame) {
1367
- const E = Q, i = E.displayWidth || E.codedWidth, o = E.displayHeight || E.codedHeight;
1368
- if (!i || !o || !I || !g || this.copyVideoFrameToTextureDirect(A, I, g, E)) return;
1367
+ const E = Q, o = E.displayWidth || E.codedWidth, i = E.displayHeight || E.codedHeight;
1368
+ if (!o || !i || !I || !g || this.copyVideoFrameToTextureDirect(A, I, g, E)) return;
1369
1369
  this.drawVideoLikeSourceToTexture(A, I, g, E);
1370
1370
  return;
1371
1371
  }
1372
1372
  if (Q instanceof HTMLVideoElement) {
1373
- const E = Q, i = E.videoWidth, o = E.videoHeight;
1374
- if (E.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || !i || !o || !I || !g)
1373
+ const E = Q, o = E.videoWidth, i = E.videoHeight;
1374
+ if (E.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || !o || !i || !I || !g)
1375
1375
  return;
1376
1376
  if (E.readyState < HTMLMediaElement.HAVE_ENOUGH_DATA) {
1377
1377
  this.drawVideoLikeSourceToTexture(A, I, g, E);
@@ -1389,65 +1389,65 @@ const _ = class z {
1389
1389
  }
1390
1390
  createTexture(A, I) {
1391
1391
  var g, Q;
1392
- const C = (g = I.width) != null ? g : 1, E = (Q = I.height) != null ? Q : 1, i = this.device.createTexture({
1392
+ const C = (g = I.width) != null ? g : 1, E = (Q = I.height) != null ? Q : 1, o = this.device.createTexture({
1393
1393
  size: [C, E],
1394
1394
  format: "rgba8unorm",
1395
1395
  usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
1396
1396
  });
1397
- A instanceof ArrayBuffer ? this.device.queue.writeTexture({ texture: i }, A, { bytesPerRow: C * 4 }, [
1397
+ A instanceof ArrayBuffer ? this.device.queue.writeTexture({ texture: o }, A, { bytesPerRow: C * 4 }, [
1398
1398
  C,
1399
1399
  E
1400
- ]) : this.copyImageSourceToTexture(i, C, E, A, I.premultiplyAlpha === !0);
1401
- const o = this.nextId++;
1402
- return this.textures.set(o, { texture: i, view: i.createView(), width: C, height: E }), { id: o, width: C, height: E };
1400
+ ]) : this.copyImageSourceToTexture(o, C, E, A, I.premultiplyAlpha === !0);
1401
+ const i = this.nextId++;
1402
+ return this.textures.set(i, { texture: o, view: o.createView(), width: C, height: E }), { id: i, width: C, height: E };
1403
1403
  }
1404
1404
  createEmptyTexture(A, I, g = {}) {
1405
1405
  const Q = Math.max(1, Math.floor(A)), C = Math.max(1, Math.floor(I)), E = this.device.createTexture({
1406
1406
  size: [Q, C],
1407
1407
  format: "rgba8unorm",
1408
1408
  usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
1409
- }), i = this.nextId++;
1410
- return this.textures.set(i, { texture: E, view: E.createView(), width: Q, height: C }), { id: i, width: Q, height: C };
1409
+ }), o = this.nextId++;
1410
+ return this.textures.set(o, { texture: E, view: E.createView(), width: Q, height: C }), { id: o, width: Q, height: C };
1411
1411
  }
1412
1412
  updateTexture(A, I) {
1413
1413
  const g = this.textures.get(A.id);
1414
1414
  g && this.copyImageSourceToTexture(g.texture, g.width, g.height, I);
1415
1415
  }
1416
1416
  updateTextureRegion(A, I, g, Q, C, E) {
1417
- const i = this.textures.get(A.id);
1418
- if (!i) return;
1419
- const o = { texture: i.texture, origin: { x: Math.floor(g), y: Math.floor(Q) } };
1417
+ const o = this.textures.get(A.id);
1418
+ if (!o) return;
1419
+ const i = { texture: o.texture, origin: { x: Math.floor(g), y: Math.floor(Q) } };
1420
1420
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame) {
1421
1421
  const s = I, D = s.displayWidth || s.codedWidth, w = s.displayHeight || s.codedHeight;
1422
1422
  if (!D || !w) return;
1423
1423
  const h = C != null ? C : D, n = E != null ? E : w;
1424
1424
  if (h !== D || n !== w) {
1425
1425
  this.drawVideoLikeSourceToTextureRegion(
1426
- i.texture,
1426
+ o.texture,
1427
1427
  h,
1428
1428
  n,
1429
1429
  s,
1430
- o.origin.x,
1431
- o.origin.y
1430
+ i.origin.x,
1431
+ i.origin.y
1432
1432
  );
1433
1433
  return;
1434
1434
  }
1435
1435
  if (this.copyVideoFrameToTextureRegionDirect(
1436
- i.texture,
1436
+ o.texture,
1437
1437
  D,
1438
1438
  w,
1439
1439
  s,
1440
- o.origin.x,
1441
- o.origin.y
1440
+ i.origin.x,
1441
+ i.origin.y
1442
1442
  ))
1443
1443
  return;
1444
1444
  this.drawVideoLikeSourceToTextureRegion(
1445
- i.texture,
1445
+ o.texture,
1446
1446
  D,
1447
1447
  w,
1448
1448
  s,
1449
- o.origin.x,
1450
- o.origin.y
1449
+ i.origin.x,
1450
+ i.origin.y
1451
1451
  );
1452
1452
  return;
1453
1453
  }
@@ -1457,58 +1457,58 @@ const _ = class z {
1457
1457
  const h = C != null ? C : D, n = E != null ? E : w;
1458
1458
  if (h !== D || n !== w) {
1459
1459
  this.drawVideoLikeSourceToTextureRegion(
1460
- i.texture,
1460
+ o.texture,
1461
1461
  h,
1462
1462
  n,
1463
1463
  s,
1464
- o.origin.x,
1465
- o.origin.y
1464
+ i.origin.x,
1465
+ i.origin.y
1466
1466
  );
1467
1467
  return;
1468
1468
  }
1469
1469
  if (s.readyState < HTMLMediaElement.HAVE_ENOUGH_DATA) {
1470
1470
  this.drawVideoLikeSourceToTextureRegion(
1471
- i.texture,
1471
+ o.texture,
1472
1472
  D,
1473
1473
  w,
1474
1474
  s,
1475
- o.origin.x,
1476
- o.origin.y
1475
+ i.origin.x,
1476
+ i.origin.y
1477
1477
  );
1478
1478
  return;
1479
1479
  }
1480
1480
  if (this.copyHtmlVideoToTextureRegionDirect(
1481
- i.texture,
1481
+ o.texture,
1482
1482
  D,
1483
1483
  w,
1484
1484
  s,
1485
- o.origin.x,
1486
- o.origin.y
1485
+ i.origin.x,
1486
+ i.origin.y
1487
1487
  ))
1488
1488
  return;
1489
1489
  this.drawVideoLikeSourceToTextureRegion(
1490
- i.texture,
1490
+ o.texture,
1491
1491
  D,
1492
1492
  w,
1493
1493
  s,
1494
- o.origin.x,
1495
- o.origin.y
1494
+ i.origin.x,
1495
+ i.origin.y
1496
1496
  );
1497
1497
  return;
1498
1498
  }
1499
1499
  const e = I, a = C != null ? C : e.width, t = E != null ? E : e.height;
1500
1500
  if (a !== e.width || t !== e.height) {
1501
1501
  this.drawVideoLikeSourceToTextureRegion(
1502
- i.texture,
1502
+ o.texture,
1503
1503
  a,
1504
1504
  t,
1505
1505
  e,
1506
- o.origin.x,
1507
- o.origin.y
1506
+ i.origin.x,
1507
+ i.origin.y
1508
1508
  );
1509
1509
  return;
1510
1510
  }
1511
- this.device.queue.copyExternalImageToTexture({ source: e }, o, [e.width, e.height]);
1511
+ this.device.queue.copyExternalImageToTexture({ source: e }, i, [e.width, e.height]);
1512
1512
  }
1513
1513
  copyHtmlVideoToTextureRegionDirect(A, I, g, Q, C, E) {
1514
1514
  if (this.videoElementPreferCanvasBridge) return !1;
@@ -1518,10 +1518,10 @@ const _ = class z {
1518
1518
  { texture: A, origin: { x: C, y: E } },
1519
1519
  [I, g]
1520
1520
  ), !0;
1521
- } catch (i) {
1521
+ } catch (o) {
1522
1522
  return this.videoElementPreferCanvasBridge = !0, console.debug(
1523
1523
  "[WebGPU] copyExternalImageToTexture(<video> region) failed; using canvas bridge.",
1524
- i
1524
+ o
1525
1525
  ), !1;
1526
1526
  }
1527
1527
  }
@@ -1533,18 +1533,18 @@ const _ = class z {
1533
1533
  { texture: A, origin: { x: C, y: E } },
1534
1534
  [I, g]
1535
1535
  ), !0;
1536
- } catch (i) {
1536
+ } catch (o) {
1537
1537
  return this.videoFramePreferCanvasBridge = !0, console.debug(
1538
1538
  "[WebGPU] copyExternalImageToTexture(VideoFrame region) failed; using canvas bridge.",
1539
- i
1539
+ o
1540
1540
  ), !1;
1541
1541
  }
1542
1542
  }
1543
1543
  drawVideoLikeSourceToTextureRegion(A, I, g, Q, C, E) {
1544
1544
  this.videoUploadCanvas || (this.videoUploadCanvas = document.createElement("canvas"), this.videoUploadCtx = this.videoUploadCanvas.getContext("2d"));
1545
- const i = this.videoUploadCanvas, o = this.videoUploadCtx;
1546
- o && ((i.width !== I || i.height !== g) && (i.width = I, i.height = g), o.drawImage(Q, 0, 0, I, g), this.device.queue.copyExternalImageToTexture(
1547
- { source: i, flipY: !0 },
1545
+ const o = this.videoUploadCanvas, i = this.videoUploadCtx;
1546
+ i && ((o.width !== I || o.height !== g) && (o.width = I, o.height = g), i.drawImage(Q, 0, 0, I, g), this.device.queue.copyExternalImageToTexture(
1547
+ { source: o, flipY: !0 },
1548
1548
  { texture: A, origin: { x: C, y: E } },
1549
1549
  [I, g]
1550
1550
  ));
@@ -1559,7 +1559,7 @@ const _ = class z {
1559
1559
  }
1560
1560
  }
1561
1561
  draw(A) {
1562
- var I, g, Q, C, E, i, o;
1562
+ var I, g, Q, C, E, o, i;
1563
1563
  if (!this.passEncoder) return;
1564
1564
  if (A.shader === "svga-instanced-premul") {
1565
1565
  this.drawInstancedSvga(A);
@@ -1625,8 +1625,8 @@ const _ = class z {
1625
1625
  binding: 0,
1626
1626
  resource: { buffer: this.uniformBuffer, offset: 0, size: 160 }
1627
1627
  },
1628
- { binding: 1, resource: (i = N == null ? void 0 : N.view) != null ? i : this.dummyTextureView },
1629
- { binding: 2, resource: (o = S == null ? void 0 : S.view) != null ? o : this.dummyTextureView },
1628
+ { binding: 1, resource: (o = N == null ? void 0 : N.view) != null ? o : this.dummyTextureView },
1629
+ { binding: 2, resource: (i = S == null ? void 0 : S.view) != null ? i : this.dummyTextureView },
1630
1630
  { binding: 3, resource: this.sampler }
1631
1631
  ]
1632
1632
  }), d.set(K, l)), s.setBindGroup(0, l, [n]);
@@ -1648,8 +1648,8 @@ const _ = class z {
1648
1648
  /** One `drawIndexed` with `instanceCount` for all SVGA sprites sharing the same atlas. */
1649
1649
  drawInstancedSvga(A) {
1650
1650
  var I, g, Q;
1651
- const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, i = A.instanceData;
1652
- if (E < 1 || !i || i.length < E * 13) return;
1651
+ const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, o = A.instanceData;
1652
+ if (E < 1 || !o || o.length < E * 13) return;
1653
1653
  if (E > z.SVGA_INSTANCED_MAX) {
1654
1654
  console.warn("[WebGPU] svga-instanced-premul: instanceCount exceeds max", E);
1655
1655
  return;
@@ -1668,7 +1668,7 @@ const _ = class z {
1668
1668
  console.warn("[WebGPU] instanced SVGA storage ring full");
1669
1669
  return;
1670
1670
  }
1671
- this.instancedStorageRingOffset += OI(n, this.storageBindOffsetAlign), this.device.queue.writeBuffer(F, r, i.buffer, i.byteOffset, n);
1671
+ this.instancedStorageRingOffset += OI(n, this.storageBindOffsetAlign), this.device.queue.writeBuffer(F, r, o.buffer, o.byteOffset, n);
1672
1672
  const c = A.textures[0], G = c ? this.textures.get(c.id) : null, y = (g = G == null ? void 0 : G.view) != null ? g : this.dummyTextureView, M = (Q = c == null ? void 0 : c.id) != null ? Q : 0;
1673
1673
  let R = this.instancedTextureBindGroupCache.get(M);
1674
1674
  R || (R = this.device.createBindGroup({
@@ -1684,8 +1684,8 @@ const _ = class z {
1684
1684
  /** One `drawIndexed` with `instanceCount` for all gifts sharing the same video texture (e.g. atlas). */
1685
1685
  drawInstancedAlpha(A) {
1686
1686
  var I, g, Q;
1687
- const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, i = A.instanceData;
1688
- if (E < 1 || !i || i.length < E * 12) return;
1687
+ const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, o = A.instanceData;
1688
+ if (E < 1 || !o || o.length < E * 12) return;
1689
1689
  if (E > z.ALPHA_INSTANCED_MAX) {
1690
1690
  console.warn("[WebGPU] alpha-video-instanced: instanceCount exceeds max", E);
1691
1691
  return;
@@ -1702,7 +1702,7 @@ const _ = class z {
1702
1702
  console.warn("[WebGPU] instanced alpha storage ring full");
1703
1703
  return;
1704
1704
  }
1705
- this.instancedStorageRingOffset += OI(w, this.storageBindOffsetAlign), this.device.queue.writeBuffer(n, h, i.buffer, i.byteOffset, w);
1705
+ this.instancedStorageRingOffset += OI(w, this.storageBindOffsetAlign), this.device.queue.writeBuffer(n, h, o.buffer, o.byteOffset, w);
1706
1706
  const r = A.textures[0], F = r ? this.textures.get(r.id) : null, c = (g = F == null ? void 0 : F.view) != null ? g : this.dummyTextureView, G = (Q = r == null ? void 0 : r.id) != null ? Q : 0;
1707
1707
  let y = this.instancedTextureBindGroupCache.get(G);
1708
1708
  y || (y = this.device.createBindGroup({
@@ -1717,8 +1717,8 @@ const _ = class z {
1717
1717
  }
1718
1718
  drawInstancedVap(A) {
1719
1719
  var I, g, Q;
1720
- const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, i = A.instanceData;
1721
- if (E < 1 || !i || i.length < E * 32) return;
1720
+ const C = this.passEncoder, E = (I = A.instanceCount) != null ? I : 0, o = A.instanceData;
1721
+ if (E < 1 || !o || o.length < E * 32) return;
1722
1722
  if (E > z.VAP_INSTANCED_MAX) {
1723
1723
  console.warn("[WebGPU] vap-instanced: instanceCount exceeds max", E);
1724
1724
  return;
@@ -1735,7 +1735,7 @@ const _ = class z {
1735
1735
  console.warn("[WebGPU] instanced VAP storage ring full");
1736
1736
  return;
1737
1737
  }
1738
- this.instancedStorageRingOffset += OI(w, this.storageBindOffsetAlign), this.device.queue.writeBuffer(n, h, i.buffer, i.byteOffset, w);
1738
+ this.instancedStorageRingOffset += OI(w, this.storageBindOffsetAlign), this.device.queue.writeBuffer(n, h, o.buffer, o.byteOffset, w);
1739
1739
  const r = A.textures[0], F = r ? this.textures.get(r.id) : null, c = (g = F == null ? void 0 : F.view) != null ? g : this.dummyTextureView, G = (Q = r == null ? void 0 : r.id) != null ? Q : 0;
1740
1740
  let y = this.instancedTextureBindGroupCache.get(G);
1741
1741
  y || (y = this.device.createBindGroup({
@@ -1752,17 +1752,17 @@ const _ = class z {
1752
1752
  }
1753
1753
  setScissor(A, I, g, Q) {
1754
1754
  if (!this.passEncoder) return;
1755
- const C = this.canvas.width, E = this.canvas.height, i = Math.max(0, Math.min(C, Math.round(A))), o = Math.max(0, Math.min(E, Math.round(I))), e = Math.max(i, Math.min(C, Math.round(A + g))), a = Math.max(o, Math.min(E, Math.round(I + Q)));
1756
- this.passEncoder.setScissorRect(i, o, e - i, a - o);
1755
+ const C = this.canvas.width, E = this.canvas.height, o = Math.max(0, Math.min(C, Math.round(A))), i = Math.max(0, Math.min(E, Math.round(I))), e = Math.max(o, Math.min(C, Math.round(A + g))), a = Math.max(i, Math.min(E, Math.round(I + Q)));
1756
+ this.passEncoder.setScissorRect(o, i, e - o, a - i);
1757
1757
  }
1758
1758
  resetScissor() {
1759
1759
  this.passEncoder && this.passEncoder.setScissorRect(0, 0, this.canvas.width, this.canvas.height);
1760
1760
  }
1761
1761
  destroy() {
1762
- var A, I, g, Q, C, E, i;
1763
- for (const [, o] of this.buffers) o.buffer.destroy();
1764
- for (const [, o] of this.textures) o.texture.destroy();
1765
- (A = this.uniformBuffer) == null || A.destroy(), (I = this.instancedProjectionBuffer) == null || I.destroy(), (g = this.instancedStorageBuffer) == null || g.destroy(), (Q = this.depthStencilTexture) == null || Q.destroy(), (C = this.msaaColorTexture) == null || C.destroy(), (E = this.dummyTexture) == null || E.destroy(), (i = this.device) == null || i.destroy(), this.buffers.clear(), this.textures.clear(), this.texturedBindGroupCache.clear(), this.dualTexturedBindGroupCache.clear(), this.instancedTextureBindGroupCache.clear(), this.pipelines.clear();
1762
+ var A, I, g, Q, C, E, o;
1763
+ for (const [, i] of this.buffers) i.buffer.destroy();
1764
+ for (const [, i] of this.textures) i.texture.destroy();
1765
+ (A = this.uniformBuffer) == null || A.destroy(), (I = this.instancedProjectionBuffer) == null || I.destroy(), (g = this.instancedStorageBuffer) == null || g.destroy(), (Q = this.depthStencilTexture) == null || Q.destroy(), (C = this.msaaColorTexture) == null || C.destroy(), (E = this.dummyTexture) == null || E.destroy(), (o = this.device) == null || o.destroy(), this.buffers.clear(), this.textures.clear(), this.texturedBindGroupCache.clear(), this.dualTexturedBindGroupCache.clear(), this.instancedTextureBindGroupCache.clear(), this.pipelines.clear();
1766
1766
  }
1767
1767
  };
1768
1768
  k(_, "SVGA_INSTANCED_MAX", 2048);
@@ -1877,10 +1877,10 @@ const wA = class kA {
1877
1877
  "u_opacity"
1878
1878
  ])
1879
1879
  });
1880
- const i = hA(A, p.rgbaTextured.vert, p.rgbaTextured.frag);
1880
+ const o = hA(A, p.rgbaTextured.vert, p.rgbaTextured.frag);
1881
1881
  this.programs.set("rgba-textured", {
1882
- program: i,
1883
- uniforms: this.getUniforms(i, [
1882
+ program: o,
1883
+ uniforms: this.getUniforms(o, [
1884
1884
  "u_projection",
1885
1885
  "u_transform",
1886
1886
  "u_video",
@@ -1888,14 +1888,14 @@ const wA = class kA {
1888
1888
  "u_opacity"
1889
1889
  ])
1890
1890
  });
1891
- const o = hA(
1891
+ const i = hA(
1892
1892
  A,
1893
1893
  p.alphaVideoInstanced.vert,
1894
1894
  p.alphaVideoInstanced.frag
1895
1895
  );
1896
1896
  this.programs.set("alpha-video-instanced", {
1897
- program: o,
1898
- uniforms: this.getUniforms(o, ["u_projection", "u_video"])
1897
+ program: i,
1898
+ uniforms: this.getUniforms(i, ["u_projection", "u_video"])
1899
1899
  });
1900
1900
  const e = hA(A, p.vapInstanced.vert, p.vapInstanced.frag);
1901
1901
  this.programs.set("vap-instanced", {
@@ -1942,8 +1942,8 @@ const wA = class kA {
1942
1942
  C.bindVertexArray(null);
1943
1943
  const E = Q.usage === "index" ? C.ELEMENT_ARRAY_BUFFER : C.ARRAY_BUFFER;
1944
1944
  C.bindBuffer(E, Q.buffer);
1945
- const i = this.getBufferSourceByteLength(I);
1946
- g === 0 && i <= Q.byteLength ? C.bufferSubData(E, 0, I) : (C.bufferData(E, I, C.DYNAMIC_DRAW), Q.byteLength = i);
1945
+ const o = this.getBufferSourceByteLength(I);
1946
+ g === 0 && o <= Q.byteLength ? C.bufferSubData(E, 0, I) : (C.bufferData(E, I, C.DYNAMIC_DRAW), Q.byteLength = o);
1947
1947
  }
1948
1948
  deleteBuffer(A) {
1949
1949
  const I = this.buffers.get(A.id);
@@ -1970,12 +1970,12 @@ const wA = class kA {
1970
1970
  }
1971
1971
  }
1972
1972
  this.videoUploadCanvas || (this.videoUploadCanvas = document.createElement("canvas"), this.videoUploadCtx = this.videoUploadCanvas.getContext("2d"));
1973
- const i = this.videoUploadCanvas, o = this.videoUploadCtx;
1974
- return o ? ((i.width !== C || i.height !== E) && (i.width = C, i.height = E), o.drawImage(I, 0, 0, C, E), Q.bindTexture(Q.TEXTURE_2D, A), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 1), g ? Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, i) : Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, i), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), !0) : !1;
1973
+ const o = this.videoUploadCanvas, i = this.videoUploadCtx;
1974
+ return i ? ((o.width !== C || o.height !== E) && (o.width = C, o.height = E), i.drawImage(I, 0, 0, C, E), Q.bindTexture(Q.TEXTURE_2D, A), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 1), g ? Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, o) : Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, o), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), !0) : !1;
1975
1975
  }
1976
1976
  createTexture(A, I) {
1977
1977
  var g, Q;
1978
- const C = this.gl, E = I.filter === "nearest" ? C.NEAREST : C.LINEAR, i = Zg(C, E), o = I.premultiplyAlpha === !0;
1978
+ const C = this.gl, E = I.filter === "nearest" ? C.NEAREST : C.LINEAR, o = Zg(C, E), i = I.premultiplyAlpha === !0;
1979
1979
  let e = (g = I.width) != null ? g : 1, a = (Q = I.height) != null ? Q : 1;
1980
1980
  if (A instanceof ArrayBuffer)
1981
1981
  C.texImage2D(
@@ -1991,43 +1991,43 @@ const wA = class kA {
1991
1991
  );
1992
1992
  else if (typeof VideoFrame != "undefined" && A instanceof VideoFrame) {
1993
1993
  const s = A;
1994
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 1), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o ? 1 : 0), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, s), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), e = s.displayWidth || s.codedWidth || e, a = s.displayHeight || s.codedHeight || a;
1994
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 1), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, i ? 1 : 0), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, s), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), e = s.displayWidth || s.codedWidth || e, a = s.displayHeight || s.codedHeight || a;
1995
1995
  } else if (A instanceof HTMLVideoElement)
1996
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o ? 1 : 0), this.uploadVideoFrameToTexture(i, A, !0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), e = A.videoWidth || e, a = A.videoHeight || a;
1996
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, i ? 1 : 0), this.uploadVideoFrameToTexture(o, A, !0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), e = A.videoWidth || e, a = A.videoHeight || a;
1997
1997
  else {
1998
- const s = o, D = I.sourcePremultiplied === !0, w = s && !D ? 1 : 0;
1999
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, w), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), "width" in A && (e = A.width, a = A.height);
1998
+ const s = i, D = I.sourcePremultiplied === !0, w = s && !D ? 1 : 0;
1999
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, w), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), "width" in A && (e = A.width, a = A.height);
2000
2000
  }
2001
2001
  const t = this.nextId++;
2002
- return this.textures.set(t, { texture: i, width: e, height: a }), { id: t, width: e, height: a };
2002
+ return this.textures.set(t, { texture: o, width: e, height: a }), { id: t, width: e, height: a };
2003
2003
  }
2004
2004
  createEmptyTexture(A, I, g = {}) {
2005
- const Q = this.gl, C = g.filter === "nearest" ? Q.NEAREST : Q.LINEAR, E = Zg(Q, C), i = Math.max(1, Math.floor(A)), o = Math.max(1, Math.floor(I));
2006
- Q.bindTexture(Q.TEXTURE_2D, E), Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, i, o, 0, Q.RGBA, Q.UNSIGNED_BYTE, null);
2005
+ const Q = this.gl, C = g.filter === "nearest" ? Q.NEAREST : Q.LINEAR, E = Zg(Q, C), o = Math.max(1, Math.floor(A)), i = Math.max(1, Math.floor(I));
2006
+ Q.bindTexture(Q.TEXTURE_2D, E), Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, o, i, 0, Q.RGBA, Q.UNSIGNED_BYTE, null);
2007
2007
  const e = this.nextId++;
2008
- return this.textures.set(e, { texture: E, width: i, height: o }), { id: e, width: i, height: o };
2008
+ return this.textures.set(e, { texture: E, width: o, height: i }), { id: e, width: o, height: i };
2009
2009
  }
2010
2010
  updateTexture(A, I) {
2011
2011
  const g = this.textures.get(A.id);
2012
2012
  if (!g) return;
2013
2013
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame) {
2014
- const o = this.gl, e = tI(I), a = sI(I), t = e === g.width && a === g.height;
2015
- o.bindTexture(o.TEXTURE_2D, g.texture), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), t ? o.texSubImage2D(o.TEXTURE_2D, 0, 0, 0, o.RGBA, o.UNSIGNED_BYTE, I) : (o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, I), e > 0 && a > 0 && (g.width = e, g.height = a)), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2014
+ const i = this.gl, e = tI(I), a = sI(I), t = e === g.width && a === g.height;
2015
+ i.bindTexture(i.TEXTURE_2D, g.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), t ? i.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, i.RGBA, i.UNSIGNED_BYTE, I) : (i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, I), e > 0 && a > 0 && (g.width = e, g.height = a)), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2016
2016
  return;
2017
2017
  }
2018
2018
  if (I instanceof HTMLVideoElement) {
2019
- const o = I.videoWidth, e = I.videoHeight, a = o !== g.width || e !== g.height;
2020
- this.uploadVideoFrameToTexture(g.texture, I, a) && a && (g.width = o, g.height = e);
2019
+ const i = I.videoWidth, e = I.videoHeight, a = i !== g.width || e !== g.height;
2020
+ this.uploadVideoFrameToTexture(g.texture, I, a) && a && (g.width = i, g.height = e);
2021
2021
  return;
2022
2022
  }
2023
- const Q = this.gl, C = tI(I), E = sI(I), i = C === g.width && E === g.height;
2024
- Q.bindTexture(Q.TEXTURE_2D, g.texture), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), i ? Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, I) : (Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, I), C > 0 && E > 0 && (g.width = C, g.height = E)), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0);
2023
+ const Q = this.gl, C = tI(I), E = sI(I), o = C === g.width && E === g.height;
2024
+ Q.bindTexture(Q.TEXTURE_2D, g.texture), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), o ? Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, I) : (Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, I), C > 0 && E > 0 && (g.width = C, g.height = E)), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0);
2025
2025
  }
2026
2026
  updateTextureRegion(A, I, g, Q, C, E) {
2027
- const i = this.textures.get(A.id);
2028
- if (!i) return;
2029
- const o = this.gl;
2030
- o.bindTexture(o.TEXTURE_2D, i.texture);
2027
+ const o = this.textures.get(A.id);
2028
+ if (!o) return;
2029
+ const i = this.gl;
2030
+ i.bindTexture(i.TEXTURE_2D, o.texture);
2031
2031
  let e, a;
2032
2032
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame)
2033
2033
  e = I.displayWidth || I.codedWidth, a = I.displayHeight || I.codedHeight;
@@ -2044,18 +2044,18 @@ const wA = class kA {
2044
2044
  this.videoUploadCanvas || (this.videoUploadCanvas = document.createElement("canvas"), this.videoUploadCtx = this.videoUploadCanvas.getContext("2d"));
2045
2045
  const D = this.videoUploadCanvas, w = this.videoUploadCtx;
2046
2046
  if (!w) return;
2047
- (D.width !== t || D.height !== s) && (D.width = t, D.height = s), w.drawImage(I, 0, 0, t, s), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, D), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2047
+ (D.width !== t || D.height !== s) && (D.width = t, D.height = s), w.drawImage(I, 0, 0, t, s), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, D), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2048
2048
  return;
2049
2049
  }
2050
2050
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame) {
2051
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2051
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2052
2052
  return;
2053
2053
  }
2054
2054
  if (I instanceof HTMLVideoElement) {
2055
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2055
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2056
2056
  return;
2057
2057
  }
2058
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2058
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2059
2059
  }
2060
2060
  deleteTexture(A) {
2061
2061
  const I = this.textures.get(A.id);
@@ -2096,16 +2096,16 @@ const wA = class kA {
2096
2096
  else
2097
2097
  e === "u_opacity" ? g.uniform1f(t, a) : g.uniform1i(t, a);
2098
2098
  }
2099
- const i = this.buffers.get(A.vertexBuffer.id), o = this.buffers.get(A.indexBuffer.id);
2100
- !i || !o || (this.bindCachedVertexArray(C, A.vertexBuffer.id, A.indexBuffer.id) && (g.bindBuffer(g.ARRAY_BUFFER, i.buffer), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, o.buffer), this.setupAttributes(C)), g.drawElements(g.TRIANGLES, A.indexCount, g.UNSIGNED_INT, 0), (Q !== "none" || A.shader === "clip-mask") && (g.disable(g.STENCIL_TEST), g.colorMask(!0, !0, !0, !0)));
2099
+ const o = this.buffers.get(A.vertexBuffer.id), i = this.buffers.get(A.indexBuffer.id);
2100
+ !o || !i || (this.bindCachedVertexArray(C, A.vertexBuffer.id, A.indexBuffer.id) && (g.bindBuffer(g.ARRAY_BUFFER, o.buffer), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, i.buffer), this.setupAttributes(C)), g.drawElements(g.TRIANGLES, A.indexCount, g.UNSIGNED_INT, 0), (Q !== "none" || A.shader === "clip-mask") && (g.disable(g.STENCIL_TEST), g.colorMask(!0, !0, !0, !0)));
2101
2101
  }
2102
2102
  clearStencil() {
2103
2103
  const A = this.gl;
2104
2104
  A.stencilMask(255), A.clear(A.STENCIL_BUFFER_BIT);
2105
2105
  }
2106
2106
  setScissor(A, I, g, Q) {
2107
- const C = this.gl, E = this.canvas.width, i = this.canvas.height, o = Math.max(0, Math.min(E, Math.round(A))), e = Math.max(0, Math.min(i, Math.round(I))), a = Math.max(o, Math.min(E, Math.round(A + g))), t = Math.max(e, Math.min(i, Math.round(I + Q)));
2108
- C.enable(C.SCISSOR_TEST), C.scissor(o, i - t, a - o, t - e);
2107
+ const C = this.gl, E = this.canvas.width, o = this.canvas.height, i = Math.max(0, Math.min(E, Math.round(A))), e = Math.max(0, Math.min(o, Math.round(I))), a = Math.max(i, Math.min(E, Math.round(A + g))), t = Math.max(e, Math.min(o, Math.round(I + Q)));
2108
+ C.enable(C.SCISSOR_TEST), C.scissor(i, o - t, a - i, t - e);
2109
2109
  }
2110
2110
  resetScissor() {
2111
2111
  this.gl.disable(this.gl.SCISSOR_TEST);
@@ -2134,24 +2134,24 @@ const wA = class kA {
2134
2134
  C || (C = /* @__PURE__ */ new Map(), this.vertexArrays.set(A, C));
2135
2135
  let E = C.get(I);
2136
2136
  E || (E = /* @__PURE__ */ new Map(), C.set(I, E));
2137
- const i = E.get(g);
2138
- if (i)
2139
- return Q.bindVertexArray(i), !1;
2140
- const o = Q.createVertexArray();
2141
- if (!o) throw new Error("Failed to create vertex array");
2142
- return E.set(g, o), Q.bindVertexArray(o), !0;
2137
+ const o = E.get(g);
2138
+ if (o)
2139
+ return Q.bindVertexArray(o), !1;
2140
+ const i = Q.createVertexArray();
2141
+ if (!i) throw new Error("Failed to create vertex array");
2142
+ return E.set(g, i), Q.bindVertexArray(i), !0;
2143
2143
  }
2144
2144
  deleteVertexArraysForBuffer(A) {
2145
2145
  const I = this.gl;
2146
2146
  for (const [g, Q] of this.vertexArrays) {
2147
2147
  for (const [C, E] of Q) {
2148
2148
  if (C === A) {
2149
- for (const o of E.values()) I.deleteVertexArray(o);
2149
+ for (const i of E.values()) I.deleteVertexArray(i);
2150
2150
  Q.delete(C);
2151
2151
  continue;
2152
2152
  }
2153
- const i = E.get(A);
2154
- i && (I.deleteVertexArray(i), E.delete(A)), E.size === 0 && Q.delete(C);
2153
+ const o = E.get(A);
2154
+ o && (I.deleteVertexArray(o), E.delete(A)), E.size === 0 && Q.delete(C);
2155
2155
  }
2156
2156
  Q.size === 0 && this.vertexArrays.delete(g);
2157
2157
  }
@@ -2179,11 +2179,11 @@ const wA = class kA {
2179
2179
  console.warn("[WebGL2] svga-instanced-premul: instanceCount exceeds max", C);
2180
2180
  return;
2181
2181
  }
2182
- const i = (g = A.stencil) != null ? g : "none";
2183
- i === "test" ? (Q.enable(Q.STENCIL_TEST), Q.stencilFunc(Q.EQUAL, 1, 255), Q.stencilOp(Q.KEEP, Q.KEEP, Q.KEEP), Q.stencilMask(0), Q.colorMask(!0, !0, !0, !0)) : (Q.disable(Q.STENCIL_TEST), Q.colorMask(!0, !0, !0, !0));
2184
- const o = "svga-instanced-premul", e = this.programs.get(o);
2182
+ const o = (g = A.stencil) != null ? g : "none";
2183
+ o === "test" ? (Q.enable(Q.STENCIL_TEST), Q.stencilFunc(Q.EQUAL, 1, 255), Q.stencilOp(Q.KEEP, Q.KEEP, Q.KEEP), Q.stencilMask(0), Q.colorMask(!0, !0, !0, !0)) : (Q.disable(Q.STENCIL_TEST), Q.colorMask(!0, !0, !0, !0));
2184
+ const i = "svga-instanced-premul", e = this.programs.get(i);
2185
2185
  if (!e) return;
2186
- this.cachedDrawProgram !== o && (Q.useProgram(e.program), this.cachedDrawProgram = o);
2186
+ this.cachedDrawProgram !== i && (Q.useProgram(e.program), this.cachedDrawProgram = i);
2187
2187
  for (let D = 0; D < A.textures.length; D++) {
2188
2188
  const w = A.textures[D].id;
2189
2189
  if (D === 0 && this.cachedTex0Id === w) continue;
@@ -2195,9 +2195,9 @@ const wA = class kA {
2195
2195
  if (h)
2196
2196
  if (w instanceof Float32Array) {
2197
2197
  if (w.length === 16) {
2198
- if (D === "u_projection" && this.cachedProjectionShader === o && this.cachedProjectionRef === w)
2198
+ if (D === "u_projection" && this.cachedProjectionShader === i && this.cachedProjectionRef === w)
2199
2199
  continue;
2200
- D === "u_projection" && (this.cachedProjectionShader = o, this.cachedProjectionRef = w), Q.uniformMatrix4fv(h, !1, w);
2200
+ D === "u_projection" && (this.cachedProjectionShader = i, this.cachedProjectionRef = w), Q.uniformMatrix4fv(h, !1, w);
2201
2201
  }
2202
2202
  } else
2203
2203
  Q.uniform1i(h, w);
@@ -2205,7 +2205,7 @@ const wA = class kA {
2205
2205
  const a = this.buffers.get(A.vertexBuffer.id), t = this.buffers.get(A.indexBuffer.id);
2206
2206
  if (!a || !t) return;
2207
2207
  const s = this.ensureInstancedSvgaInstanceBuffer();
2208
- Q.bindBuffer(Q.ARRAY_BUFFER, s), Q.bufferSubData(Q.ARRAY_BUFFER, 0, E, 0, C * 13), this.bindCachedVertexArray(o, A.vertexBuffer.id, A.indexBuffer.id) && (Q.bindBuffer(Q.ARRAY_BUFFER, s), Q.enableVertexAttribArray(1), Q.vertexAttribPointer(1, 2, Q.FLOAT, !1, 52, 0), Q.vertexAttribDivisor(1, 1), Q.enableVertexAttribArray(2), Q.vertexAttribPointer(2, 4, Q.FLOAT, !1, 52, 8), Q.vertexAttribDivisor(2, 1), Q.enableVertexAttribArray(3), Q.vertexAttribPointer(3, 3, Q.FLOAT, !1, 52, 24), Q.vertexAttribDivisor(3, 1), Q.enableVertexAttribArray(4), Q.vertexAttribPointer(4, 4, Q.FLOAT, !1, 52, 36), Q.vertexAttribDivisor(4, 1), Q.bindBuffer(Q.ARRAY_BUFFER, a.buffer), Q.enableVertexAttribArray(0), Q.vertexAttribPointer(0, 2, Q.FLOAT, !1, 8, 0), Q.vertexAttribDivisor(0, 0), Q.bindBuffer(Q.ELEMENT_ARRAY_BUFFER, t.buffer)), Q.drawElementsInstanced(Q.TRIANGLES, A.indexCount, Q.UNSIGNED_INT, 0, C), i !== "none" && (Q.disable(Q.STENCIL_TEST), Q.colorMask(!0, !0, !0, !0));
2208
+ Q.bindBuffer(Q.ARRAY_BUFFER, s), Q.bufferSubData(Q.ARRAY_BUFFER, 0, E, 0, C * 13), this.bindCachedVertexArray(i, A.vertexBuffer.id, A.indexBuffer.id) && (Q.bindBuffer(Q.ARRAY_BUFFER, s), Q.enableVertexAttribArray(1), Q.vertexAttribPointer(1, 2, Q.FLOAT, !1, 52, 0), Q.vertexAttribDivisor(1, 1), Q.enableVertexAttribArray(2), Q.vertexAttribPointer(2, 4, Q.FLOAT, !1, 52, 8), Q.vertexAttribDivisor(2, 1), Q.enableVertexAttribArray(3), Q.vertexAttribPointer(3, 3, Q.FLOAT, !1, 52, 24), Q.vertexAttribDivisor(3, 1), Q.enableVertexAttribArray(4), Q.vertexAttribPointer(4, 4, Q.FLOAT, !1, 52, 36), Q.vertexAttribDivisor(4, 1), Q.bindBuffer(Q.ARRAY_BUFFER, a.buffer), Q.enableVertexAttribArray(0), Q.vertexAttribPointer(0, 2, Q.FLOAT, !1, 8, 0), Q.vertexAttribDivisor(0, 0), Q.bindBuffer(Q.ELEMENT_ARRAY_BUFFER, t.buffer)), Q.drawElementsInstanced(Q.TRIANGLES, A.indexCount, Q.UNSIGNED_INT, 0, C), o !== "none" && (Q.disable(Q.STENCIL_TEST), Q.colorMask(!0, !0, !0, !0));
2209
2209
  }
2210
2210
  ensureInstancedAlphaInstanceBuffer() {
2211
2211
  const A = this.gl;
@@ -2225,9 +2225,9 @@ const wA = class kA {
2225
2225
  return;
2226
2226
  }
2227
2227
  g.disable(g.STENCIL_TEST), g.colorMask(!0, !0, !0, !0);
2228
- const E = "alpha-video-instanced", i = this.programs.get("alpha-video-instanced");
2229
- if (!i) return;
2230
- this.cachedDrawProgram !== E && (g.useProgram(i.program), this.cachedDrawProgram = E);
2228
+ const E = "alpha-video-instanced", o = this.programs.get("alpha-video-instanced");
2229
+ if (!o) return;
2230
+ this.cachedDrawProgram !== E && (g.useProgram(o.program), this.cachedDrawProgram = E);
2231
2231
  for (let t = 0; t < A.textures.length; t++) {
2232
2232
  const s = A.textures[t].id;
2233
2233
  if (t === 0 && this.cachedTex0Id === s) continue;
@@ -2235,7 +2235,7 @@ const wA = class kA {
2235
2235
  D && (g.activeTexture(g.TEXTURE0 + t), g.bindTexture(g.TEXTURE_2D, D.texture), t === 0 && (this.cachedTex0Id = s));
2236
2236
  }
2237
2237
  for (const [t, s] of Object.entries(A.uniforms)) {
2238
- const D = i.uniforms.get(t);
2238
+ const D = o.uniforms.get(t);
2239
2239
  if (D)
2240
2240
  if (s instanceof Float32Array) {
2241
2241
  if (s.length === 16) {
@@ -2246,8 +2246,8 @@ const wA = class kA {
2246
2246
  } else
2247
2247
  t === "u_opacity" ? g.uniform1f(D, s) : g.uniform1i(D, s);
2248
2248
  }
2249
- const o = this.buffers.get(A.vertexBuffer.id), e = this.buffers.get(A.indexBuffer.id);
2250
- if (!o || !e) return;
2249
+ const i = this.buffers.get(A.vertexBuffer.id), e = this.buffers.get(A.indexBuffer.id);
2250
+ if (!i || !e) return;
2251
2251
  const a = this.ensureInstancedAlphaInstanceBuffer();
2252
2252
  if (g.bindBuffer(g.ARRAY_BUFFER, a), g.bufferSubData(g.ARRAY_BUFFER, 0, C, 0, Q * 12), this.bindCachedVertexArray(E, A.vertexBuffer.id, A.indexBuffer.id)) {
2253
2253
  g.bindBuffer(g.ARRAY_BUFFER, a);
@@ -2255,7 +2255,7 @@ const wA = class kA {
2255
2255
  const w = 2 + D;
2256
2256
  g.enableVertexAttribArray(w), g.vertexAttribPointer(w, 4, g.FLOAT, !1, 48, D * 16), g.vertexAttribDivisor(w, 1);
2257
2257
  }
2258
- g.bindBuffer(g.ARRAY_BUFFER, o.buffer);
2258
+ g.bindBuffer(g.ARRAY_BUFFER, i.buffer);
2259
2259
  const s = 16;
2260
2260
  g.enableVertexAttribArray(0), g.vertexAttribPointer(0, 2, g.FLOAT, !1, s, 0), g.vertexAttribDivisor(0, 0), g.enableVertexAttribArray(1), g.vertexAttribPointer(1, 2, g.FLOAT, !1, s, 8), g.vertexAttribDivisor(1, 0), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, e.buffer);
2261
2261
  }
@@ -2279,9 +2279,9 @@ const wA = class kA {
2279
2279
  return;
2280
2280
  }
2281
2281
  g.disable(g.STENCIL_TEST), g.colorMask(!0, !0, !0, !0);
2282
- const E = "vap-instanced", i = this.programs.get("vap-instanced");
2283
- if (!i) return;
2284
- this.cachedDrawProgram !== E && (g.useProgram(i.program), this.cachedDrawProgram = E);
2282
+ const E = "vap-instanced", o = this.programs.get("vap-instanced");
2283
+ if (!o) return;
2284
+ this.cachedDrawProgram !== E && (g.useProgram(o.program), this.cachedDrawProgram = E);
2285
2285
  for (let t = 0; t < A.textures.length; t++) {
2286
2286
  const s = A.textures[t].id;
2287
2287
  if (t === 0 && this.cachedTex0Id === s) continue;
@@ -2289,7 +2289,7 @@ const wA = class kA {
2289
2289
  D && (g.activeTexture(g.TEXTURE0 + t), g.bindTexture(g.TEXTURE_2D, D.texture), t === 0 && (this.cachedTex0Id = s));
2290
2290
  }
2291
2291
  for (const [t, s] of Object.entries(A.uniforms)) {
2292
- const D = i.uniforms.get(t);
2292
+ const D = o.uniforms.get(t);
2293
2293
  if (D)
2294
2294
  if (s instanceof Float32Array) {
2295
2295
  if (s.length === 16) {
@@ -2300,8 +2300,8 @@ const wA = class kA {
2300
2300
  } else
2301
2301
  t === "u_opacity" ? g.uniform1f(D, s) : g.uniform1i(D, s);
2302
2302
  }
2303
- const o = this.buffers.get(A.vertexBuffer.id), e = this.buffers.get(A.indexBuffer.id);
2304
- if (!o || !e) return;
2303
+ const i = this.buffers.get(A.vertexBuffer.id), e = this.buffers.get(A.indexBuffer.id);
2304
+ if (!i || !e) return;
2305
2305
  const a = this.ensureInstancedVapInstanceBuffer();
2306
2306
  if (g.bindBuffer(g.ARRAY_BUFFER, a), g.bufferSubData(g.ARRAY_BUFFER, 0, C, 0, Q * 32), this.bindCachedVertexArray(E, A.vertexBuffer.id, A.indexBuffer.id)) {
2307
2307
  g.bindBuffer(g.ARRAY_BUFFER, a);
@@ -2309,7 +2309,7 @@ const wA = class kA {
2309
2309
  const w = 2 + D;
2310
2310
  g.enableVertexAttribArray(w), g.vertexAttribPointer(w, 4, g.FLOAT, !1, 128, D * 16), g.vertexAttribDivisor(w, 1);
2311
2311
  }
2312
- g.bindBuffer(g.ARRAY_BUFFER, o.buffer);
2312
+ g.bindBuffer(g.ARRAY_BUFFER, i.buffer);
2313
2313
  const s = 16;
2314
2314
  g.enableVertexAttribArray(0), g.vertexAttribPointer(0, 2, g.FLOAT, !1, s, 0), g.vertexAttribDivisor(0, 0), g.enableVertexAttribArray(1), g.vertexAttribPointer(1, 2, g.FLOAT, !1, s, 8), g.vertexAttribDivisor(1, 0), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, e.buffer);
2315
2315
  }
@@ -2352,11 +2352,11 @@ function vA(B, A, I, g) {
2352
2352
  if (!E)
2353
2353
  throw B.deleteShader(Q), B.deleteShader(C), new Error("Failed to create program");
2354
2354
  B.attachShader(E, Q), B.attachShader(E, C);
2355
- for (const [i, o] of Object.entries(g))
2356
- B.bindAttribLocation(E, o, i);
2355
+ for (const [o, i] of Object.entries(g))
2356
+ B.bindAttribLocation(E, i, o);
2357
2357
  if (B.linkProgram(E), !B.getProgramParameter(E, B.LINK_STATUS)) {
2358
- const i = B.getProgramInfoLog(E);
2359
- throw B.deleteProgram(E), B.deleteShader(Q), B.deleteShader(C), new Error(`Program link failed: ${i}`);
2358
+ const o = B.getProgramInfoLog(E);
2359
+ throw B.deleteProgram(E), B.deleteShader(Q), B.deleteShader(C), new Error(`Program link failed: ${o}`);
2360
2360
  }
2361
2361
  return B.deleteShader(Q), B.deleteShader(C), E;
2362
2362
  }
@@ -2467,20 +2467,20 @@ class Xg {
2467
2467
  if (!Q) throw new Error("Failed to create buffer");
2468
2468
  const C = I === "index" ? this.normalizeIndexSource(A) : A, E = I === "index" ? g.ELEMENT_ARRAY_BUFFER : g.ARRAY_BUFFER;
2469
2469
  g.bindBuffer(E, Q), g.bufferData(E, C, g.DYNAMIC_DRAW);
2470
- const i = this.nextId++;
2471
- return this.buffers.set(i, {
2470
+ const o = this.nextId++;
2471
+ return this.buffers.set(o, {
2472
2472
  buffer: Q,
2473
2473
  usage: I,
2474
2474
  byteLength: this.getBufferSourceByteLength(C)
2475
- }), { id: i, usage: I };
2475
+ }), { id: o, usage: I };
2476
2476
  }
2477
2477
  updateBuffer(A, I, g = 0) {
2478
2478
  const Q = this.buffers.get(A.id);
2479
2479
  if (!Q) return;
2480
- const C = this.gl, E = Q.usage === "index" ? this.normalizeIndexSource(I) : I, i = Q.usage === "index" ? C.ELEMENT_ARRAY_BUFFER : C.ARRAY_BUFFER;
2481
- C.bindBuffer(i, Q.buffer);
2482
- const o = this.getBufferSourceByteLength(E);
2483
- g === 0 && o <= Q.byteLength ? C.bufferSubData(i, 0, E) : (C.bufferData(i, E, C.DYNAMIC_DRAW), Q.byteLength = o);
2480
+ const C = this.gl, E = Q.usage === "index" ? this.normalizeIndexSource(I) : I, o = Q.usage === "index" ? C.ELEMENT_ARRAY_BUFFER : C.ARRAY_BUFFER;
2481
+ C.bindBuffer(o, Q.buffer);
2482
+ const i = this.getBufferSourceByteLength(E);
2483
+ g === 0 && i <= Q.byteLength ? C.bufferSubData(o, 0, E) : (C.bufferData(o, E, C.DYNAMIC_DRAW), Q.byteLength = i);
2484
2484
  }
2485
2485
  deleteBuffer(A) {
2486
2486
  const I = this.buffers.get(A.id);
@@ -2493,8 +2493,8 @@ class Xg {
2493
2493
  const Q = this.gl, C = I.videoWidth, E = I.videoHeight;
2494
2494
  if (I.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || C <= 0 || E <= 0)
2495
2495
  return !1;
2496
- const i = this.ensureVideoUploadCanvas(C, E);
2497
- return !i || !this.videoUploadCanvas ? !1 : (i.drawImage(I, 0, 0, C, E), Q.bindTexture(Q.TEXTURE_2D, A), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 1), g ? Q.texImage2D(
2496
+ const o = this.ensureVideoUploadCanvas(C, E);
2497
+ return !o || !this.videoUploadCanvas ? !1 : (o.drawImage(I, 0, 0, C, E), Q.bindTexture(Q.TEXTURE_2D, A), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 1), g ? Q.texImage2D(
2498
2498
  Q.TEXTURE_2D,
2499
2499
  0,
2500
2500
  Q.RGBA,
@@ -2513,7 +2513,7 @@ class Xg {
2513
2513
  }
2514
2514
  createTexture(A, I) {
2515
2515
  var g, Q;
2516
- const C = this.gl, E = I.filter === "nearest" ? C.NEAREST : C.LINEAR, i = vg(C, E), o = I.premultiplyAlpha === !0;
2516
+ const C = this.gl, E = I.filter === "nearest" ? C.NEAREST : C.LINEAR, o = vg(C, E), i = I.premultiplyAlpha === !0;
2517
2517
  let e = (g = I.width) != null ? g : 1, a = (Q = I.height) != null ? Q : 1;
2518
2518
  if (A instanceof ArrayBuffer)
2519
2519
  C.texImage2D(
@@ -2528,43 +2528,43 @@ class Xg {
2528
2528
  new Uint8Array(A)
2529
2529
  );
2530
2530
  else if (typeof VideoFrame != "undefined" && A instanceof VideoFrame)
2531
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 1), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o ? 1 : 0), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), e = A.displayWidth || A.codedWidth || e, a = A.displayHeight || A.codedHeight || a;
2531
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 1), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, i ? 1 : 0), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), e = A.displayWidth || A.codedWidth || e, a = A.displayHeight || A.codedHeight || a;
2532
2532
  else if (A instanceof HTMLVideoElement)
2533
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o ? 1 : 0), this.uploadVideoFrameToTexture(i, A, !0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), e = A.videoWidth || e, a = A.videoHeight || a;
2533
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, i ? 1 : 0), this.uploadVideoFrameToTexture(o, A, !0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), e = A.videoWidth || e, a = A.videoHeight || a;
2534
2534
  else {
2535
- const s = o, D = I.sourcePremultiplied === !0, w = s && !D ? 1 : 0;
2536
- C.bindTexture(C.TEXTURE_2D, i), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, w), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), "width" in A && (e = A.width, a = A.height);
2535
+ const s = i, D = I.sourcePremultiplied === !0, w = s && !D ? 1 : 0;
2536
+ C.bindTexture(C.TEXTURE_2D, o), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, w), C.texImage2D(C.TEXTURE_2D, 0, C.RGBA, C.RGBA, C.UNSIGNED_BYTE, A), C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL, 0), "width" in A && (e = A.width, a = A.height);
2537
2537
  }
2538
2538
  const t = this.nextId++;
2539
- return this.textures.set(t, { texture: i, width: e, height: a }), { id: t, width: e, height: a };
2539
+ return this.textures.set(t, { texture: o, width: e, height: a }), { id: t, width: e, height: a };
2540
2540
  }
2541
2541
  createEmptyTexture(A, I, g = {}) {
2542
- const Q = this.gl, C = g.filter === "nearest" ? Q.NEAREST : Q.LINEAR, E = vg(Q, C), i = Math.max(1, Math.floor(A)), o = Math.max(1, Math.floor(I));
2543
- Q.bindTexture(Q.TEXTURE_2D, E), Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, i, o, 0, Q.RGBA, Q.UNSIGNED_BYTE, null);
2542
+ const Q = this.gl, C = g.filter === "nearest" ? Q.NEAREST : Q.LINEAR, E = vg(Q, C), o = Math.max(1, Math.floor(A)), i = Math.max(1, Math.floor(I));
2543
+ Q.bindTexture(Q.TEXTURE_2D, E), Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, o, i, 0, Q.RGBA, Q.UNSIGNED_BYTE, null);
2544
2544
  const e = this.nextId++;
2545
- return this.textures.set(e, { texture: E, width: i, height: o }), { id: e, width: i, height: o };
2545
+ return this.textures.set(e, { texture: E, width: o, height: i }), { id: e, width: o, height: i };
2546
2546
  }
2547
2547
  updateTexture(A, I) {
2548
2548
  const g = this.textures.get(A.id);
2549
2549
  if (!g) return;
2550
2550
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame) {
2551
- const o = this.gl, e = tI(I), a = sI(I), t = e === g.width && a === g.height;
2552
- o.bindTexture(o.TEXTURE_2D, g.texture), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), t ? o.texSubImage2D(o.TEXTURE_2D, 0, 0, 0, o.RGBA, o.UNSIGNED_BYTE, I) : (o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, I), e > 0 && a > 0 && (g.width = e, g.height = a)), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2551
+ const i = this.gl, e = tI(I), a = sI(I), t = e === g.width && a === g.height;
2552
+ i.bindTexture(i.TEXTURE_2D, g.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), t ? i.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, i.RGBA, i.UNSIGNED_BYTE, I) : (i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, I), e > 0 && a > 0 && (g.width = e, g.height = a)), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2553
2553
  return;
2554
2554
  }
2555
2555
  if (I instanceof HTMLVideoElement) {
2556
- const o = I.videoWidth, e = I.videoHeight, a = o !== g.width || e !== g.height;
2557
- this.uploadVideoFrameToTexture(g.texture, I, a) && a && (g.width = o, g.height = e);
2556
+ const i = I.videoWidth, e = I.videoHeight, a = i !== g.width || e !== g.height;
2557
+ this.uploadVideoFrameToTexture(g.texture, I, a) && a && (g.width = i, g.height = e);
2558
2558
  return;
2559
2559
  }
2560
- const Q = this.gl, C = tI(I), E = sI(I), i = C === g.width && E === g.height;
2561
- Q.bindTexture(Q.TEXTURE_2D, g.texture), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), i ? Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, I) : (Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, I), C > 0 && E > 0 && (g.width = C, g.height = E)), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0);
2560
+ const Q = this.gl, C = tI(I), E = sI(I), o = C === g.width && E === g.height;
2561
+ Q.bindTexture(Q.TEXTURE_2D, g.texture), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0), o ? Q.texSubImage2D(Q.TEXTURE_2D, 0, 0, 0, Q.RGBA, Q.UNSIGNED_BYTE, I) : (Q.texImage2D(Q.TEXTURE_2D, 0, Q.RGBA, Q.RGBA, Q.UNSIGNED_BYTE, I), C > 0 && E > 0 && (g.width = C, g.height = E)), Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL, 0);
2562
2562
  }
2563
2563
  updateTextureRegion(A, I, g, Q, C, E) {
2564
- const i = this.textures.get(A.id);
2565
- if (!i) return;
2566
- const o = this.gl;
2567
- o.bindTexture(o.TEXTURE_2D, i.texture);
2564
+ const o = this.textures.get(A.id);
2565
+ if (!o) return;
2566
+ const i = this.gl;
2567
+ i.bindTexture(i.TEXTURE_2D, o.texture);
2568
2568
  let e, a;
2569
2569
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame)
2570
2570
  e = I.displayWidth || I.codedWidth, a = I.displayHeight || I.codedHeight;
@@ -2580,18 +2580,18 @@ class Xg {
2580
2580
  if (t !== e || s !== a) {
2581
2581
  const D = this.ensureVideoUploadCanvas(t, s);
2582
2582
  if (!D || !this.videoUploadCanvas) return;
2583
- D.drawImage(I, 0, 0, t, s), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, this.videoUploadCanvas), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2583
+ D.drawImage(I, 0, 0, t, s), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, this.videoUploadCanvas), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2584
2584
  return;
2585
2585
  }
2586
2586
  if (typeof VideoFrame != "undefined" && I instanceof VideoFrame) {
2587
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2587
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2588
2588
  return;
2589
2589
  }
2590
2590
  if (I instanceof HTMLVideoElement) {
2591
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0);
2591
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0);
2592
2592
  return;
2593
2593
  }
2594
- o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 0), o.texSubImage2D(o.TEXTURE_2D, 0, g, Q, o.RGBA, o.UNSIGNED_BYTE, I);
2594
+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 0), i.texSubImage2D(i.TEXTURE_2D, 0, g, Q, i.RGBA, i.UNSIGNED_BYTE, I);
2595
2595
  }
2596
2596
  deleteTexture(A) {
2597
2597
  const I = this.textures.get(A.id);
@@ -2623,8 +2623,8 @@ class Xg {
2623
2623
  else
2624
2624
  e === "u_opacity" ? g.uniform1f(t, a) : g.uniform1i(t, a);
2625
2625
  }
2626
- const i = this.buffers.get(A.vertexBuffer.id), o = this.buffers.get(A.indexBuffer.id);
2627
- !i || !o || (g.bindBuffer(g.ARRAY_BUFFER, i.buffer), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, o.buffer), this.setupAttributes(C), g.drawElements(
2626
+ const o = this.buffers.get(A.vertexBuffer.id), i = this.buffers.get(A.indexBuffer.id);
2627
+ !o || !i || (g.bindBuffer(g.ARRAY_BUFFER, o.buffer), g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, i.buffer), this.setupAttributes(C), g.drawElements(
2628
2628
  g.TRIANGLES,
2629
2629
  A.indexCount,
2630
2630
  this.supportsUintIndices ? g.UNSIGNED_INT : g.UNSIGNED_SHORT,
@@ -2636,8 +2636,8 @@ class Xg {
2636
2636
  A.stencilMask(255), A.clear(A.STENCIL_BUFFER_BIT);
2637
2637
  }
2638
2638
  setScissor(A, I, g, Q) {
2639
- const C = this.gl, E = this.canvas.width, i = this.canvas.height, o = Math.max(0, Math.min(E, Math.round(A))), e = Math.max(0, Math.min(i, Math.round(I))), a = Math.max(o, Math.min(E, Math.round(A + g))), t = Math.max(e, Math.min(i, Math.round(I + Q)));
2640
- C.enable(C.SCISSOR_TEST), C.scissor(o, i - t, a - o, t - e);
2639
+ const C = this.gl, E = this.canvas.width, o = this.canvas.height, i = Math.max(0, Math.min(E, Math.round(A))), e = Math.max(0, Math.min(o, Math.round(I))), a = Math.max(i, Math.min(E, Math.round(A + g))), t = Math.max(e, Math.min(o, Math.round(I + Q)));
2640
+ C.enable(C.SCISSOR_TEST), C.scissor(i, o - t, a - i, t - e);
2641
2641
  }
2642
2642
  resetScissor() {
2643
2643
  this.gl.disable(this.gl.SCISSOR_TEST);
@@ -2687,35 +2687,35 @@ function pB() {
2687
2687
  async function tC(B, A = !0, I = !0, g = !1) {
2688
2688
  const Q = I != null ? I : !1, C = I != null ? I : !0;
2689
2689
  if (g) {
2690
- const i = new Xg(B, C);
2691
- return await i.init(), i;
2690
+ const o = new Xg(B, C);
2691
+ return await o.init(), o;
2692
2692
  }
2693
2693
  if (A && typeof navigator != "undefined" && "gpu" in navigator && qB())
2694
2694
  try {
2695
- const i = await navigator.gpu.requestAdapter({
2695
+ const o = await navigator.gpu.requestAdapter({
2696
2696
  powerPreference: "high-performance"
2697
2697
  });
2698
- if (i) {
2699
- const o = new BC(B, i, Q);
2700
- return await o.init(), o;
2698
+ if (o) {
2699
+ const i = new BC(B, o, Q);
2700
+ return await i.init(), i;
2701
2701
  } else
2702
2702
  console.warn(
2703
2703
  "[GiftStage] WebGPU unavailable: requestAdapter returned null, fallback to WebGL2/WebGL1."
2704
2704
  );
2705
- } catch (i) {
2705
+ } catch (o) {
2706
2706
  console.warn(
2707
- `[GiftStage] WebGPU init failed: ${i instanceof Error ? i.message : String(i)}, fallback to WebGL2/WebGL1.`
2707
+ `[GiftStage] WebGPU init failed: ${o instanceof Error ? o.message : String(o)}, fallback to WebGL2/WebGL1.`
2708
2708
  );
2709
2709
  }
2710
2710
  else A && typeof navigator != "undefined" && "gpu" in navigator && console.warn(
2711
2711
  "[GiftStage] WebGPU unavailable: GPUQueue.copyExternalImageToTexture is not supported, fallback to WebGL2/WebGL1."
2712
2712
  );
2713
2713
  try {
2714
- const i = new iC(B, C);
2715
- return await i.init(), i;
2716
- } catch (i) {
2714
+ const o = new iC(B, C);
2715
+ return await o.init(), o;
2716
+ } catch (o) {
2717
2717
  console.warn(
2718
- `[GiftStage] WebGL2 init failed: ${i instanceof Error ? i.message : String(i)}, fallback to WebGL1.`
2718
+ `[GiftStage] WebGL2 init failed: ${o instanceof Error ? o.message : String(o)}, fallback to WebGL1.`
2719
2719
  );
2720
2720
  }
2721
2721
  const E = new Xg(B, C);
@@ -2733,15 +2733,15 @@ function hC(B) {
2733
2733
  }
2734
2734
  function nC(B, A, I) {
2735
2735
  const g = B.clientWidth || B.getBoundingClientRect().width || 0, Q = B.clientHeight || B.getBoundingClientRect().height || 0, C = A > 0 && Number.isFinite(A) ? A : 1;
2736
- let E = Math.max(1, Math.round(g * C)), i = Math.max(1, Math.round(Q * C));
2736
+ let E = Math.max(1, Math.round(g * C)), o = Math.max(1, Math.round(Q * C));
2737
2737
  if (I !== !1) {
2738
- const o = I != null ? I : hC(), e = Math.max(o.width, o.height), a = Math.min(o.width, o.height);
2738
+ const i = I != null ? I : hC(), e = Math.max(i.width, i.height), a = Math.min(i.width, i.height);
2739
2739
  if (e > 0 && a > 0) {
2740
- const t = Math.min(1, e / Math.max(E, i), a / Math.min(E, i));
2741
- t < 1 && (E = Math.max(1, Math.round(E * t)), i = Math.max(1, Math.round(i * t)));
2740
+ const t = Math.min(1, e / Math.max(E, o), a / Math.min(E, o));
2741
+ t < 1 && (E = Math.max(1, Math.round(E * t)), o = Math.max(1, Math.round(o * t)));
2742
2742
  }
2743
2743
  }
2744
- (B.width !== E || B.height !== i) && (B.width = E, B.height = i);
2744
+ (B.width !== E || B.height !== o) && (B.width = E, B.height = o);
2745
2745
  }
2746
2746
  function yg(B) {
2747
2747
  const A = B.clientWidth || B.getBoundingClientRect().width || 1, I = B.clientHeight || B.getBoundingClientRect().height || 1;
@@ -2765,7 +2765,7 @@ function RC(B, A, I) {
2765
2765
  return C < 0 ? "" : (Q = B.clipPaths[C]) != null ? Q : "";
2766
2766
  }
2767
2767
  function xB(B, A) {
2768
- var I, g, Q, C, E, i, o;
2768
+ var I, g, Q, C, E, o, i;
2769
2769
  const e = B.length;
2770
2770
  let a = A != null ? A : 0;
2771
2771
  if (a <= 0)
@@ -2784,7 +2784,7 @@ function xB(B, A) {
2784
2784
  }
2785
2785
  const U = (g = (I = N.layout) == null ? void 0 : I.width) != null ? g : 0, K = (C = (Q = N.layout) == null ? void 0 : Q.height) != null ? C : 0, d = (E = N.transform) != null ? E : rC;
2786
2786
  s[S] = U, s[S + 1] = K, s[S + 2] = d.a, s[S + 3] = d.b, s[S + 4] = d.c, s[S + 5] = d.d, s[S + 6] = d.tx, s[S + 7] = d.ty, s[S + 8] = N.alpha;
2787
- const l = (i = N.clipPath) != null ? i : "";
2787
+ const l = (o = N.clipPath) != null ? o : "";
2788
2788
  if (l.length > 0) {
2789
2789
  let u = w.get(l);
2790
2790
  u === void 0 && (u = D.length, D.push(l), w.set(l, u)), h[c * a + R] = u;
@@ -2794,7 +2794,7 @@ function xB(B, A) {
2794
2794
  y = null, M = -1;
2795
2795
  continue;
2796
2796
  }
2797
- if (((o = J[0]) == null ? void 0 : o.kind) === "keep") {
2797
+ if (((i = J[0]) == null ? void 0 : i.kind) === "keep") {
2798
2798
  M >= 0 && (r[c * a + R] = M, F = !0);
2799
2799
  continue;
2800
2800
  }
@@ -2826,8 +2826,8 @@ function xB(B, A) {
2826
2826
  }
2827
2827
  function jI(B, A, I) {
2828
2828
  const g = Math.floor(B.length / YA), Q = Math.floor(A.length / (qA * sA)), C = Math.floor(I.length / gI), E = Math.min(g, Q, C);
2829
- for (let i = 0; i < E; i++) {
2830
- const o = i * YA, e = B[o], a = B[o + 1], t = B[o + 2], s = B[o + 3], D = B[o + 4], w = B[o + 5], h = B[o + 6], n = B[o + 7], r = B[o + 8], F = B[o + 9], c = B[o + 10], G = B[o + 11], y = B[o + 12], M = h, R = n, N = t * e + h, S = s * e + n, U = t * e + D * a + h, K = s * e + w * a + n, d = D * a + h, l = w * a + n, J = i * qA * sA;
2829
+ for (let o = 0; o < E; o++) {
2830
+ const i = o * YA, e = B[i], a = B[i + 1], t = B[i + 2], s = B[i + 3], D = B[i + 4], w = B[i + 5], h = B[i + 6], n = B[i + 7], r = B[i + 8], F = B[i + 9], c = B[i + 10], G = B[i + 11], y = B[i + 12], M = h, R = n, N = t * e + h, S = s * e + n, U = t * e + D * a + h, K = s * e + w * a + n, d = D * a + h, l = w * a + n, J = o * qA * sA;
2831
2831
  A[J] = M, A[J + 1] = R, A[J + 2] = 0, A[J + 3] = 1, A[J + 4] = 1, A[J + 5] = 1, A[J + 6] = r, A[J + 7] = F, A[J + 8] = c;
2832
2832
  const q = J + sA;
2833
2833
  A[q] = N, A[q + 1] = S, A[q + 2] = 0, A[q + 3] = 1, A[q + 4] = 1, A[q + 5] = 1, A[q + 6] = r, A[q + 7] = G, A[q + 8] = c;
@@ -2835,15 +2835,15 @@ function jI(B, A, I) {
2835
2835
  A[u] = U, A[u + 1] = K, A[u + 2] = 0, A[u + 3] = 1, A[u + 4] = 1, A[u + 5] = 1, A[u + 6] = r, A[u + 7] = G, A[u + 8] = y;
2836
2836
  const f = J + 3 * sA;
2837
2837
  A[f] = d, A[f + 1] = l, A[f + 2] = 0, A[f + 3] = 1, A[f + 4] = 1, A[f + 5] = 1, A[f + 6] = r, A[f + 7] = F, A[f + 8] = y;
2838
- const W = i * gI, iA = i * qA;
2838
+ const W = o * gI, iA = o * qA;
2839
2839
  I[W] = iA, I[W + 1] = iA + 1, I[W + 2] = iA + 2, I[W + 3] = iA, I[W + 4] = iA + 2, I[W + 5] = iA + 3;
2840
2840
  }
2841
2841
  return E;
2842
2842
  }
2843
2843
  function yC(B, A, I) {
2844
2844
  const g = jg(B, L.__wbindgen_malloc), Q = $;
2845
- var C = jg(A, L.__wbindgen_malloc), E = $, i = WB(I, L.__wbindgen_malloc), o = $;
2846
- return L.build_batch_vertices(g, Q, C, E, A, i, o, I) >>> 0;
2845
+ var C = jg(A, L.__wbindgen_malloc), E = $, o = WB(I, L.__wbindgen_malloc), i = $;
2846
+ return L.build_batch_vertices(g, Q, C, E, A, o, i, I) >>> 0;
2847
2847
  }
2848
2848
  function MC(B) {
2849
2849
  const A = vI(B, L.__wbindgen_malloc), I = $, g = L.decode_svga(A, I);
@@ -2880,8 +2880,8 @@ function UC() {
2880
2880
  }
2881
2881
  function lC(B, A) {
2882
2882
  const I = JC(B, L.__wbindgen_malloc), g = $, Q = WB(A, L.__wbindgen_malloc), C = $, E = L.triangulate_clip_polygons(I, g, Q, C);
2883
- var i = YC(E[0], E[1]).slice();
2884
- return L.__wbindgen_free(E[0], E[1] * 4, 4), i;
2883
+ var o = YC(E[0], E[1]).slice();
2884
+ return L.__wbindgen_free(E[0], E[1] * 4, 4), o;
2885
2885
  }
2886
2886
  function bB() {
2887
2887
  return {
@@ -2988,21 +2988,21 @@ function JC(B, A) {
2988
2988
  }
2989
2989
  function LC(B, A, I) {
2990
2990
  if (I === void 0) {
2991
- const i = BI.encode(B), o = A(i.length, 1) >>> 0;
2992
- return pA().subarray(o, o + i.length).set(i), $ = i.length, o;
2991
+ const o = BI.encode(B), i = A(o.length, 1) >>> 0;
2992
+ return pA().subarray(i, i + o.length).set(o), $ = o.length, i;
2993
2993
  }
2994
2994
  let g = B.length, Q = A(g, 1) >>> 0;
2995
2995
  const C = pA();
2996
2996
  let E = 0;
2997
2997
  for (; E < g; E++) {
2998
- const i = B.charCodeAt(E);
2999
- if (i > 127) break;
3000
- C[Q + E] = i;
2998
+ const o = B.charCodeAt(E);
2999
+ if (o > 127) break;
3000
+ C[Q + E] = o;
3001
3001
  }
3002
3002
  if (E !== g) {
3003
3003
  E !== 0 && (B = B.slice(E)), Q = I(Q, g, g = E + B.length * 3, 1) >>> 0;
3004
- const i = pA().subarray(Q + E, Q + g), o = BI.encodeInto(B, i);
3005
- E += o.written, Q = I(Q, g, E, 1) >>> 0;
3004
+ const o = pA().subarray(Q + E, Q + g), i = BI.encodeInto(B, o);
3005
+ E += i.written, Q = I(Q, g, E, 1) >>> 0;
3006
3006
  }
3007
3007
  return $ = E, Q;
3008
3008
  }
@@ -3155,12 +3155,12 @@ function $I(B, A, I) {
3155
3155
  }
3156
3156
  }
3157
3157
  function VC(B) {
3158
- var A, I, g, Q, C, E, i;
3159
- const o = B.params, e = o ? {
3160
- viewBoxWidth: (A = o.view_box_width) != null ? A : 0,
3161
- viewBoxHeight: (I = o.view_box_height) != null ? I : 0,
3162
- fps: (g = o.fps) != null ? g : 20,
3163
- frames: (Q = o.frames) != null ? Q : 0
3158
+ var A, I, g, Q, C, E, o;
3159
+ const i = B.params, e = i ? {
3160
+ viewBoxWidth: (A = i.view_box_width) != null ? A : 0,
3161
+ viewBoxHeight: (I = i.view_box_height) != null ? I : 0,
3162
+ fps: (g = i.fps) != null ? g : 20,
3163
+ frames: (Q = i.frames) != null ? Q : 0
3164
3164
  } : { viewBoxWidth: 0, viewBoxHeight: 0, fps: 20, frames: 0 }, a = /* @__PURE__ */ new Map(), t = B.images;
3165
3165
  if (t instanceof Map)
3166
3166
  for (const [w, h] of t)
@@ -3184,7 +3184,7 @@ function VC(B) {
3184
3184
  }
3185
3185
  );
3186
3186
  return {
3187
- version: (i = B.version) != null ? i : "",
3187
+ version: (o = B.version) != null ? o : "",
3188
3188
  params: e,
3189
3189
  images: a,
3190
3190
  spriteTable: xB(s, e.frames),
@@ -3195,13 +3195,13 @@ function vC(B) {
3195
3195
  var A, I;
3196
3196
  let g = null;
3197
3197
  const Q = ((A = B.frames) != null ? A : []).map((C) => {
3198
- var E, i, o, e, a, t, s, D, w, h, n;
3198
+ var E, o, i, e, a, t, s, D, w, h, n;
3199
3199
  const r = Array.isArray(C.shapes) ? C.shapes : [];
3200
3200
  let F;
3201
3201
  return r.length === 0 ? (g = null, F = null) : ((E = r[0]) == null ? void 0 : E.kind) === "keep" ? F = g : (F = jC(r), g = F), {
3202
- alpha: (i = C.alpha) != null ? i : 0,
3202
+ alpha: (o = C.alpha) != null ? o : 0,
3203
3203
  layout: C.layout ? {
3204
- width: (o = C.layout.width) != null ? o : 0,
3204
+ width: (i = C.layout.width) != null ? i : 0,
3205
3205
  height: (e = C.layout.height) != null ? e : 0
3206
3206
  } : null,
3207
3207
  transform: C.transform ? {
@@ -3232,7 +3232,7 @@ function zg(B) {
3232
3232
  }
3233
3233
  function XC(B) {
3234
3234
  var A, I, g, Q, C, E;
3235
- const i = (A = B == null ? void 0 : B.line_dash) != null ? A : B == null ? void 0 : B.lineDash;
3235
+ const o = (A = B == null ? void 0 : B.line_dash) != null ? A : B == null ? void 0 : B.lineDash;
3236
3236
  return {
3237
3237
  fill: zg(B == null ? void 0 : B.fill),
3238
3238
  stroke: zg(B == null ? void 0 : B.stroke),
@@ -3240,7 +3240,7 @@ function XC(B) {
3240
3240
  lineCap: (Q = B == null ? void 0 : B.line_cap) != null ? Q : B == null ? void 0 : B.lineCap,
3241
3241
  lineJoin: (C = B == null ? void 0 : B.line_join) != null ? C : B == null ? void 0 : B.lineJoin,
3242
3242
  miterLimit: (E = B == null ? void 0 : B.miter_limit) != null ? E : B == null ? void 0 : B.miterLimit,
3243
- lineDash: Array.isArray(i) && i.length > 0 ? i : void 0
3243
+ lineDash: Array.isArray(o) && o.length > 0 ? o : void 0
3244
3244
  };
3245
3245
  }
3246
3246
  function OC(B) {
@@ -3255,7 +3255,7 @@ function OC(B) {
3255
3255
  };
3256
3256
  }
3257
3257
  function jC(B) {
3258
- var A, I, g, Q, C, E, i, o, e, a, t, s, D;
3258
+ var A, I, g, Q, C, E, o, i, e, a, t, s, D;
3259
3259
  if (!Array.isArray(B) || B.length === 0) return null;
3260
3260
  const w = [];
3261
3261
  for (const h of B) {
@@ -3269,10 +3269,10 @@ function jC(B) {
3269
3269
  y: (g = h.rect.y) != null ? g : 0,
3270
3270
  width: (Q = h.rect.width) != null ? Q : 0,
3271
3271
  height: (C = h.rect.height) != null ? C : 0,
3272
- cornerRadius: (i = (E = h.rect.corner_radius) != null ? E : h.rect.cornerRadius) != null ? i : 0
3272
+ cornerRadius: (o = (E = h.rect.corner_radius) != null ? E : h.rect.cornerRadius) != null ? o : 0
3273
3273
  } : void 0,
3274
3274
  ellipse: h.ellipse ? {
3275
- x: (o = h.ellipse.x) != null ? o : 0,
3275
+ x: (i = h.ellipse.x) != null ? i : 0,
3276
3276
  y: (e = h.ellipse.y) != null ? e : 0,
3277
3277
  radiusX: (t = (a = h.ellipse.radius_x) != null ? a : h.ellipse.radiusX) != null ? t : 0,
3278
3278
  radiusY: (D = (s = h.ellipse.radius_y) != null ? s : h.ellipse.radiusY) != null ? D : 0
@@ -3318,8 +3318,8 @@ class _C {
3318
3318
  }
3319
3319
  }
3320
3320
  function HA(B, A, I, g, Q, C) {
3321
- const E = 1 / (B - A), i = 1 / (I - g), o = 1 / (Q - C), e = new Float32Array(16);
3322
- return e[0] = -2 * E, e[5] = -2 * i, e[10] = 2 * o, e[12] = (B + A) * E, e[13] = (g + I) * i, e[14] = (Q + C) * o, e[15] = 1, e;
3321
+ const E = 1 / (B - A), o = 1 / (I - g), i = 1 / (Q - C), e = new Float32Array(16);
3322
+ return e[0] = -2 * E, e[5] = -2 * o, e[10] = 2 * i, e[12] = (B + A) * E, e[13] = (g + I) * o, e[14] = (Q + C) * i, e[15] = 1, e;
3323
3323
  }
3324
3324
  function yA(B, A, I) {
3325
3325
  return B + (A - B) * I;
@@ -3335,7 +3335,7 @@ const HI = 8;
3335
3335
  function vB(B) {
3336
3336
  if (!B || B.trim().length === 0) return [];
3337
3337
  const A = [];
3338
- let I = [], g = 0, Q = 0, C = 0, E = 0, i = 0, o = 0;
3338
+ let I = [], g = 0, Q = 0, C = 0, E = 0, o = 0, i = 0;
3339
3339
  const e = IE(B);
3340
3340
  let a = 0;
3341
3341
  function t() {
@@ -3378,42 +3378,42 @@ function vB(B) {
3378
3378
  case "C": {
3379
3379
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3380
3380
  const D = t(), w = t(), h = t(), n = t(), r = t(), F = t();
3381
- SI(I, g, Q, D, w, h, n, r, F), i = h, o = n, g = r, Q = F;
3381
+ SI(I, g, Q, D, w, h, n, r, F), o = h, i = n, g = r, Q = F;
3382
3382
  }
3383
3383
  break;
3384
3384
  }
3385
3385
  case "c": {
3386
3386
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3387
3387
  const D = g + t(), w = Q + t(), h = g + t(), n = Q + t(), r = g + t(), F = Q + t();
3388
- SI(I, g, Q, D, w, h, n, r, F), i = h, o = n, g = r, Q = F;
3388
+ SI(I, g, Q, D, w, h, n, r, F), o = h, i = n, g = r, Q = F;
3389
3389
  }
3390
3390
  break;
3391
3391
  }
3392
3392
  case "S": {
3393
3393
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3394
- const D = 2 * g - i, w = 2 * Q - o, h = t(), n = t(), r = t(), F = t();
3395
- SI(I, g, Q, D, w, h, n, r, F), i = h, o = n, g = r, Q = F;
3394
+ const D = 2 * g - o, w = 2 * Q - i, h = t(), n = t(), r = t(), F = t();
3395
+ SI(I, g, Q, D, w, h, n, r, F), o = h, i = n, g = r, Q = F;
3396
3396
  }
3397
3397
  break;
3398
3398
  }
3399
3399
  case "s": {
3400
3400
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3401
- const D = 2 * g - i, w = 2 * Q - o, h = g + t(), n = Q + t(), r = g + t(), F = Q + t();
3402
- SI(I, g, Q, D, w, h, n, r, F), i = h, o = n, g = r, Q = F;
3401
+ const D = 2 * g - o, w = 2 * Q - i, h = g + t(), n = Q + t(), r = g + t(), F = Q + t();
3402
+ SI(I, g, Q, D, w, h, n, r, F), o = h, i = n, g = r, Q = F;
3403
3403
  }
3404
3404
  break;
3405
3405
  }
3406
3406
  case "Q": {
3407
3407
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3408
3408
  const D = t(), w = t(), h = t(), n = t();
3409
- _g(I, g, Q, D, w, h, n), i = D, o = w, g = h, Q = n;
3409
+ _g(I, g, Q, D, w, h, n), o = D, i = w, g = h, Q = n;
3410
3410
  }
3411
3411
  break;
3412
3412
  }
3413
3413
  case "q": {
3414
3414
  for (; a < e.length && !isNaN(parseFloat(e[a])); ) {
3415
3415
  const D = g + t(), w = Q + t(), h = g + t(), n = Q + t();
3416
- _g(I, g, Q, D, w, h, n), i = D, o = w, g = h, Q = n;
3416
+ _g(I, g, Q, D, w, h, n), o = D, i = w, g = h, Q = n;
3417
3417
  }
3418
3418
  break;
3419
3419
  }
@@ -3427,21 +3427,21 @@ function vB(B) {
3427
3427
  function IE(B) {
3428
3428
  return B.replace(/([A-Za-z])/g, " $1 ").replace(/,/g, " ").trim().split(/\s+/).filter((A) => A.length > 0);
3429
3429
  }
3430
- function SI(B, A, I, g, Q, C, E, i, o) {
3430
+ function SI(B, A, I, g, Q, C, E, o, i) {
3431
3431
  for (let e = 1; e <= HI; e++) {
3432
3432
  const a = e / HI, t = 1 - a, s = t * t, D = a * a;
3433
3433
  B.push({
3434
- x: s * t * A + 3 * s * a * g + 3 * t * D * C + D * a * i,
3435
- y: s * t * I + 3 * s * a * Q + 3 * t * D * E + D * a * o
3434
+ x: s * t * A + 3 * s * a * g + 3 * t * D * C + D * a * o,
3435
+ y: s * t * I + 3 * s * a * Q + 3 * t * D * E + D * a * i
3436
3436
  });
3437
3437
  }
3438
3438
  }
3439
3439
  function _g(B, A, I, g, Q, C, E) {
3440
- for (let i = 1; i <= HI; i++) {
3441
- const o = i / HI, e = 1 - o;
3440
+ for (let o = 1; o <= HI; o++) {
3441
+ const i = o / HI, e = 1 - i;
3442
3442
  B.push({
3443
- x: e * e * A + 2 * e * o * g + o * o * C,
3444
- y: e * e * I + 2 * e * o * Q + o * o * E
3443
+ x: e * e * A + 2 * e * i * g + i * i * C,
3444
+ y: e * e * I + 2 * e * i * Q + i * i * E
3445
3445
  });
3446
3446
  }
3447
3447
  }
@@ -3449,30 +3449,30 @@ function gE(B) {
3449
3449
  const A = B.length;
3450
3450
  if (A < 3) return [];
3451
3451
  if (A === 3) return [0, 1, 2];
3452
- const I = [], g = Array.from({ length: A }, (i, o) => o), C = BE(B) > 0;
3452
+ const I = [], g = Array.from({ length: A }, (o, i) => i), C = BE(B) > 0;
3453
3453
  let E = A * A;
3454
3454
  for (; g.length > 3 && E-- > 0; ) {
3455
- let i = !1;
3456
- const o = g.length;
3457
- for (let e = 0; e < o; e++) {
3458
- const a = g[(e - 1 + o) % o], t = g[e], s = g[(e + 1) % o], D = B[a], w = B[t], h = B[s], n = (w.x - D.x) * (h.y - D.y) - (w.y - D.y) * (h.x - D.x);
3455
+ let o = !1;
3456
+ const i = g.length;
3457
+ for (let e = 0; e < i; e++) {
3458
+ const a = g[(e - 1 + i) % i], t = g[e], s = g[(e + 1) % i], D = B[a], w = B[t], h = B[s], n = (w.x - D.x) * (h.y - D.y) - (w.y - D.y) * (h.x - D.x);
3459
3459
  if (!(C ? n > 0 : n < 0)) continue;
3460
3460
  let F = !1;
3461
- for (let c = 0; c < o; c++)
3462
- if (!(c === (e - 1 + o) % o || c === e || c === (e + 1) % o) && QE(B[g[c]], D, w, h)) {
3461
+ for (let c = 0; c < i; c++)
3462
+ if (!(c === (e - 1 + i) % i || c === e || c === (e + 1) % i) && QE(B[g[c]], D, w, h)) {
3463
3463
  F = !0;
3464
3464
  break;
3465
3465
  }
3466
3466
  if (!F) {
3467
- C ? I.push(a, t, s) : I.push(a, s, t), g.splice(e, 1), i = !0;
3467
+ C ? I.push(a, t, s) : I.push(a, s, t), g.splice(e, 1), o = !0;
3468
3468
  break;
3469
3469
  }
3470
3470
  }
3471
- if (!i) break;
3471
+ if (!o) break;
3472
3472
  }
3473
3473
  if (g.length === 3) {
3474
- const [i, o, e] = g;
3475
- C ? I.push(i, o, e) : I.push(i, e, o);
3474
+ const [o, i, e] = g;
3475
+ C ? I.push(o, i, e) : I.push(o, e, i);
3476
3476
  }
3477
3477
  return I;
3478
3478
  }
@@ -3486,8 +3486,8 @@ function BE(B) {
3486
3486
  return A * 0.5;
3487
3487
  }
3488
3488
  function QE(B, A, I, g) {
3489
- const Q = gg(B, A, I), C = gg(B, I, g), E = gg(B, g, A), i = Q < 0 || C < 0 || E < 0, o = Q > 0 || C > 0 || E > 0;
3490
- return !(i && o);
3489
+ const Q = gg(B, A, I), C = gg(B, I, g), E = gg(B, g, A), o = Q < 0 || C < 0 || E < 0, i = Q > 0 || C > 0 || E > 0;
3490
+ return !(o && i);
3491
3491
  }
3492
3492
  function gg(B, A, I) {
3493
3493
  return (B.x - I.x) * (A.y - I.y) - (A.x - I.x) * (B.y - I.y);
@@ -3504,30 +3504,30 @@ function KA(B, A, I, g) {
3504
3504
  height: 0,
3505
3505
  offsetX: 0,
3506
3506
  offsetY: 0
3507
- }, C = B.width * B.scale, E = B.height * B.scale, i = DA(B);
3507
+ }, C = B.width * B.scale, E = B.height * B.scale, o = DA(B);
3508
3508
  if (!(A > 0) || !(I > 0))
3509
3509
  return Q.scaleX = 1, Q.scaleY = 1, Q.width = C, Q.height = E, Q.offsetX = 0, Q.offsetY = 0, Q;
3510
- if (i === "fill")
3510
+ if (o === "fill")
3511
3511
  return Q.scaleX = C / A, Q.scaleY = E / I, Q.width = C, Q.height = E, Q.offsetX = 0, Q.offsetY = 0, Q;
3512
- const o = i === "cover" ? Math.max(C / A, E / I) : Math.min(C / A, E / I), e = A * o, a = I * o;
3513
- return Q.scaleX = o, Q.scaleY = o, Q.width = e, Q.height = a, Q.offsetX = i === "cover" ? (C - e) * 0.5 : 0, Q.offsetY = i === "cover" ? (E - a) * 0.5 : 0, Q;
3512
+ const i = o === "cover" ? Math.max(C / A, E / I) : Math.min(C / A, E / I), e = A * i, a = I * i;
3513
+ return Q.scaleX = i, Q.scaleY = i, Q.width = e, Q.height = a, Q.offsetX = o === "cover" ? (C - e) * 0.5 : 0, Q.offsetY = o === "cover" ? (E - a) * 0.5 : 0, Q;
3514
3514
  }
3515
3515
  function CE(B, A, I = 2) {
3516
3516
  const g = B.length;
3517
3517
  let Q = EE(B, 0, g, I, !0);
3518
3518
  const C = [];
3519
3519
  if (!Q || Q.next === Q.prev) return C;
3520
- let E, i, o;
3520
+ let E, o, i;
3521
3521
  if (B.length > 80 * I) {
3522
- E = B[0], i = B[1];
3523
- let e = E, a = i;
3522
+ E = B[0], o = B[1];
3523
+ let e = E, a = o;
3524
3524
  for (let t = I; t < g; t += I) {
3525
3525
  const s = B[t], D = B[t + 1];
3526
- s < E && (E = s), D < i && (i = D), s > e && (e = s), D > a && (a = D);
3526
+ s < E && (E = s), D < o && (o = D), s > e && (e = s), D > a && (a = D);
3527
3527
  }
3528
- o = Math.max(e - E, a - i), o = o !== 0 ? 32767 / o : 0;
3528
+ i = Math.max(e - E, a - o), i = i !== 0 ? 32767 / i : 0;
3529
3529
  }
3530
- return hI(Q, C, I, E, i, o, 0), C;
3530
+ return hI(Q, C, I, E, o, i, 0), C;
3531
3531
  }
3532
3532
  function EE(B, A, I, g, Q) {
3533
3533
  let C;
@@ -3553,14 +3553,14 @@ function wI(B, A) {
3553
3553
  function hI(B, A, I, g, Q, C, E) {
3554
3554
  if (!B) return;
3555
3555
  !E && C && tE(B, g, Q, C);
3556
- let i = B;
3556
+ let o = B;
3557
3557
  for (; B.prev !== B.next; ) {
3558
- const o = B.prev, e = B.next;
3558
+ const i = B.prev, e = B.next;
3559
3559
  if (C ? oE(B, g, Q, C) : iE(B)) {
3560
- A.push(o.i, B.i, e.i), nI(B), B = e.next, i = e.next;
3560
+ A.push(i.i, B.i, e.i), nI(B), B = e.next, o = e.next;
3561
3561
  continue;
3562
3562
  }
3563
- if (B = e, B === i) {
3563
+ if (B = e, B === o) {
3564
3564
  E ? E === 1 ? (B = eE(wI(B), A), hI(B, A, I, g, Q, C, 2)) : E === 2 && aE(B, A, I, g, Q, C) : hI(wI(B), A, I, g, Q, C, 1);
3565
3565
  break;
3566
3566
  }
@@ -3569,10 +3569,10 @@ function hI(B, A, I, g, Q, C, E) {
3569
3569
  function iE(B) {
3570
3570
  const A = B.prev, I = B, g = B.next;
3571
3571
  if (Z(A, I, g) >= 0) return !1;
3572
- const Q = A.x, C = I.x, E = g.x, i = A.y, o = I.y, e = g.y, a = Math.min(Q, C, E), t = Math.min(i, o, e), s = Math.max(Q, C, E), D = Math.max(i, o, e);
3572
+ const Q = A.x, C = I.x, E = g.x, o = A.y, i = I.y, e = g.y, a = Math.min(Q, C, E), t = Math.min(o, i, e), s = Math.max(Q, C, E), D = Math.max(o, i, e);
3573
3573
  let w = g.next;
3574
3574
  for (; w !== A; ) {
3575
- if (w.x >= a && w.x <= s && w.y >= t && w.y <= D && AI(Q, i, C, o, E, e, w.x, w.y) && Z(w.prev, w, w.next) >= 0) return !1;
3575
+ if (w.x >= a && w.x <= s && w.y >= t && w.y <= D && AI(Q, o, C, i, E, e, w.x, w.y) && Z(w.prev, w, w.next) >= 0) return !1;
3576
3576
  w = w.next;
3577
3577
  }
3578
3578
  return !0;
@@ -3580,18 +3580,18 @@ function iE(B) {
3580
3580
  function oE(B, A, I, g) {
3581
3581
  const Q = B.prev, C = B, E = B.next;
3582
3582
  if (Z(Q, C, E) >= 0) return !1;
3583
- const i = Q.x, o = C.x, e = E.x, a = Q.y, t = C.y, s = E.y, D = Math.min(i, o, e), w = Math.min(a, t, s), h = Math.max(i, o, e), n = Math.max(a, t, s), r = Mg(D, w, A, I, g), F = Mg(h, n, A, I, g);
3583
+ const o = Q.x, i = C.x, e = E.x, a = Q.y, t = C.y, s = E.y, D = Math.min(o, i, e), w = Math.min(a, t, s), h = Math.max(o, i, e), n = Math.max(a, t, s), r = Mg(D, w, A, I, g), F = Mg(h, n, A, I, g);
3584
3584
  let c = B.prevZ, G = B.nextZ;
3585
3585
  for (; c && c.z >= r && G && G.z <= F; ) {
3586
- if (c.x >= D && c.x <= h && c.y >= w && c.y <= n && c !== Q && c !== E && AI(i, a, o, t, e, s, c.x, c.y) && Z(c.prev, c, c.next) >= 0 || (c = c.prevZ, G.x >= D && G.x <= h && G.y >= w && G.y <= n && G !== Q && G !== E && AI(i, a, o, t, e, s, G.x, G.y) && Z(G.prev, G, G.next) >= 0)) return !1;
3586
+ if (c.x >= D && c.x <= h && c.y >= w && c.y <= n && c !== Q && c !== E && AI(o, a, i, t, e, s, c.x, c.y) && Z(c.prev, c, c.next) >= 0 || (c = c.prevZ, G.x >= D && G.x <= h && G.y >= w && G.y <= n && G !== Q && G !== E && AI(o, a, i, t, e, s, G.x, G.y) && Z(G.prev, G, G.next) >= 0)) return !1;
3587
3587
  G = G.nextZ;
3588
3588
  }
3589
3589
  for (; c && c.z >= r; ) {
3590
- if (c.x >= D && c.x <= h && c.y >= w && c.y <= n && c !== Q && c !== E && AI(i, a, o, t, e, s, c.x, c.y) && Z(c.prev, c, c.next) >= 0) return !1;
3590
+ if (c.x >= D && c.x <= h && c.y >= w && c.y <= n && c !== Q && c !== E && AI(o, a, i, t, e, s, c.x, c.y) && Z(c.prev, c, c.next) >= 0) return !1;
3591
3591
  c = c.prevZ;
3592
3592
  }
3593
3593
  for (; G && G.z <= F; ) {
3594
- if (G.x >= D && G.x <= h && G.y >= w && G.y <= n && G !== Q && G !== E && AI(i, a, o, t, e, s, G.x, G.y) && Z(G.prev, G, G.next) >= 0) return !1;
3594
+ if (G.x >= D && G.x <= h && G.y >= w && G.y <= n && G !== Q && G !== E && AI(o, a, i, t, e, s, G.x, G.y) && Z(G.prev, G, G.next) >= 0) return !1;
3595
3595
  G = G.nextZ;
3596
3596
  }
3597
3597
  return !0;
@@ -3607,14 +3607,14 @@ function eE(B, A) {
3607
3607
  function aE(B, A, I, g, Q, C) {
3608
3608
  let E = B;
3609
3609
  do {
3610
- let i = E.next.next;
3611
- for (; i !== E.prev; ) {
3612
- if (E.i !== i.i && wE(E, i)) {
3613
- let o = cE(E, i);
3614
- E = wI(E, E.next), o = wI(o, o.next), hI(E, A, I, g, Q, C, 0), hI(o, A, I, g, Q, C, 0);
3610
+ let o = E.next.next;
3611
+ for (; o !== E.prev; ) {
3612
+ if (E.i !== o.i && wE(E, o)) {
3613
+ let i = cE(E, o);
3614
+ E = wI(E, E.next), i = wI(i, i.next), hI(E, A, I, g, Q, C, 0), hI(i, A, I, g, Q, C, 0);
3615
3615
  return;
3616
3616
  }
3617
- i = i.next;
3617
+ o = o.next;
3618
3618
  }
3619
3619
  E = E.next;
3620
3620
  } while (E !== B);
@@ -3634,12 +3634,12 @@ function sE(B) {
3634
3634
  let C = null;
3635
3635
  for (A = 0; g; ) {
3636
3636
  A++;
3637
- let E = g, i = 0;
3638
- for (let e = 0; e < I && (i++, E = E.nextZ, !!E); e++)
3637
+ let E = g, o = 0;
3638
+ for (let e = 0; e < I && (o++, E = E.nextZ, !!E); e++)
3639
3639
  ;
3640
- let o = I;
3641
- for (; i > 0 || o > 0 && E; )
3642
- i !== 0 && (o === 0 || !E || g.z <= E.z) ? (Q = g, g = g.nextZ, i--) : (Q = E, E = E.nextZ, o--), C ? C.nextZ = Q : B = Q, Q.prevZ = C, C = Q;
3640
+ let i = I;
3641
+ for (; o > 0 || i > 0 && E; )
3642
+ o !== 0 && (i === 0 || !E || g.z <= E.z) ? (Q = g, g = g.nextZ, o--) : (Q = E, E = E.nextZ, i--), C ? C.nextZ = Q : B = Q, Q.prevZ = C, C = Q;
3643
3643
  g = E;
3644
3644
  }
3645
3645
  C.nextZ = null, I *= 2;
@@ -3649,11 +3649,11 @@ function sE(B) {
3649
3649
  function Mg(B, A, I, g, Q) {
3650
3650
  return B = (B - I) * Q | 0, A = (A - g) * Q | 0, B = (B | B << 8) & 16711935, B = (B | B << 4) & 252645135, B = (B | B << 2) & 858993459, B = (B | B << 1) & 1431655765, A = (A | A << 8) & 16711935, A = (A | A << 4) & 252645135, A = (A | A << 2) & 858993459, A = (A | A << 1) & 1431655765, B | A << 1;
3651
3651
  }
3652
- function DE(B, A, I, g, Q, C, E, i) {
3653
- return (Q - E) * (A - i) >= (B - E) * (C - i) && (B - E) * (g - i) >= (I - E) * (A - i) && (I - E) * (C - i) >= (Q - E) * (g - i);
3652
+ function DE(B, A, I, g, Q, C, E, o) {
3653
+ return (Q - E) * (A - o) >= (B - E) * (C - o) && (B - E) * (g - o) >= (I - E) * (A - o) && (I - E) * (C - o) >= (Q - E) * (g - o);
3654
3654
  }
3655
- function AI(B, A, I, g, Q, C, E, i) {
3656
- return !(B === E && A === i) && DE(B, A, I, g, Q, C, E, i);
3655
+ function AI(B, A, I, g, Q, C, E, o) {
3656
+ return !(B === E && A === o) && DE(B, A, I, g, Q, C, E, o);
3657
3657
  }
3658
3658
  function wE(B, A) {
3659
3659
  return B.next.i !== A.i && B.prev.i !== A.i && !hE(B, A) && // doesn't intersect other edges
@@ -3668,8 +3668,8 @@ function XI(B, A) {
3668
3668
  return B.x === A.x && B.y === A.y;
3669
3669
  }
3670
3670
  function XB(B, A, I, g) {
3671
- const Q = UI(Z(B, A, I)), C = UI(Z(B, A, g)), E = UI(Z(I, g, B)), i = UI(Z(I, g, A));
3672
- return !!(Q !== C && E !== i || Q === 0 && kI(B, I, A) || C === 0 && kI(B, g, A) || E === 0 && kI(I, B, g) || i === 0 && kI(I, A, g));
3671
+ const Q = UI(Z(B, A, I)), C = UI(Z(B, A, g)), E = UI(Z(I, g, B)), o = UI(Z(I, g, A));
3672
+ return !!(Q !== C && E !== o || Q === 0 && kI(B, I, A) || C === 0 && kI(B, g, A) || E === 0 && kI(I, B, g) || o === 0 && kI(I, A, g));
3673
3673
  }
3674
3674
  function kI(B, A, I) {
3675
3675
  return A.x <= Math.max(B.x, I.x) && A.x >= Math.min(B.x, I.x) && A.y <= Math.max(B.y, I.y) && A.y >= Math.min(B.y, I.y);
@@ -3736,23 +3736,23 @@ function FE(B, A) {
3736
3736
  const I = vB(B);
3737
3737
  if (I.length === 0) return null;
3738
3738
  const g = [], Q = [], C = [];
3739
- for (const o of I)
3740
- if (!(o.length < 3)) {
3741
- C.push(o);
3742
- for (const e of o)
3739
+ for (const i of I)
3740
+ if (!(i.length < 3)) {
3741
+ C.push(i);
3742
+ for (const e of i)
3743
3743
  g.push(e.x, e.y), Q.push(e.x, e.y);
3744
3744
  }
3745
3745
  if (g.length === 0) return null;
3746
3746
  const E = [];
3747
- let i = 0;
3748
- for (const o of C) {
3747
+ let o = 0;
3748
+ for (const i of C) {
3749
3749
  const e = [];
3750
- for (const t of o)
3750
+ for (const t of i)
3751
3751
  e.push(t.x, t.y);
3752
3752
  const a = CE(e, void 0, 2);
3753
3753
  for (const t of a)
3754
- E.push(t + i);
3755
- i += o.length;
3754
+ E.push(t + o);
3755
+ o += i.length;
3756
3756
  }
3757
3757
  return E.length === 0 ? null : {
3758
3758
  vertices: new Float32Array(g),
@@ -4629,24 +4629,24 @@ function UE(B, A = {}) {
4629
4629
  Y(A.signal, "SVGA clip worker task aborted");
4630
4630
  const I = kE(), g = SE++;
4631
4631
  return new Promise((Q, C) => {
4632
- var E, i;
4633
- const o = {
4632
+ var E, o;
4633
+ const i = {
4634
4634
  owner: I,
4635
4635
  signal: A.signal,
4636
4636
  resolve: Q,
4637
4637
  reject: C
4638
4638
  };
4639
- if (o.onAbort = () => {
4639
+ if (i.onAbort = () => {
4640
4640
  qI(
4641
4641
  I,
4642
4642
  IA("SVGA clip worker task aborted"),
4643
4643
  g
4644
4644
  );
4645
- }, cI.set(g, o), (E = A.signal) != null && E.aborted) {
4646
- o.onAbort();
4645
+ }, cI.set(g, i), (E = A.signal) != null && E.aborted) {
4646
+ i.onAbort();
4647
4647
  return;
4648
4648
  }
4649
- (i = A.signal) == null || i.addEventListener("abort", o.onAbort, { once: !0 });
4649
+ (o = A.signal) == null || o.addEventListener("abort", i.onAbort, { once: !0 });
4650
4650
  try {
4651
4651
  I.postMessage({
4652
4652
  type: "build-svga-clip-meshes",
@@ -4679,8 +4679,8 @@ function LE() {
4679
4679
  }
4680
4680
  function fE(B, A = {}) {
4681
4681
  var I, g, Q;
4682
- const C = Math.max(0.1, (I = A.minBudgetMs) != null ? I : KE), E = Math.max(C, (g = A.maxBudgetMs) != null ? g : dE), i = Math.max(0.05, Math.min(0.95, (Q = A.frameFraction) != null ? Q : 0.5)), o = Number.isFinite(B) && B > 0 ? B : zB;
4683
- return Math.max(C, Math.min(E, o * i));
4682
+ const C = Math.max(0.1, (I = A.minBudgetMs) != null ? I : KE), E = Math.max(C, (g = A.maxBudgetMs) != null ? g : dE), o = Math.max(0.05, Math.min(0.95, (Q = A.frameFraction) != null ? Q : 0.5)), i = Number.isFinite(B) && B > 0 ? B : zB;
4683
+ return Math.max(C, Math.min(E, i * o));
4684
4684
  }
4685
4685
  function HE(B, A) {
4686
4686
  return !Number.isFinite(A) || A < 4 || A > 100 ? B : B + (A - B) * JE;
@@ -4743,11 +4743,11 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4743
4743
  g.length > 0 && this.flushGroup(A, g), g.length = 0;
4744
4744
  }
4745
4745
  async prewarmClipMeshes(A, I = {}) {
4746
- var g, Q, C, E, i;
4747
- const o = A.spriteTable.clipPaths.filter((s) => s.length > 0);
4748
- if (o.length === 0) return 0;
4749
- const e = o.filter((s) => !this.clipMeshCache.has(s));
4750
- if (e.length === 0) return o.length;
4746
+ var g, Q, C, E, o;
4747
+ const i = A.spriteTable.clipPaths.filter((s) => s.length > 0);
4748
+ if (i.length === 0) return 0;
4749
+ const e = i.filter((s) => !this.clipMeshCache.has(s));
4750
+ if (e.length === 0) return i.length;
4751
4751
  if (I.useWorker !== !1 && PB())
4752
4752
  try {
4753
4753
  const s = await UE(e, {
@@ -4757,7 +4757,7 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4757
4757
  (g = I.checkActive) == null || g.call(I);
4758
4758
  for (const D of e)
4759
4759
  this.clipMeshCache.set(D, (Q = s.get(D)) != null ? Q : null);
4760
- return o.length;
4760
+ return i.length;
4761
4761
  } catch (s) {
4762
4762
  if (SA(s)) throw s;
4763
4763
  console.warn("[GiftStage:SVGA] clip mesh worker failed, using main thread", s);
@@ -4767,10 +4767,10 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4767
4767
  });
4768
4768
  let t = 0;
4769
4769
  for (const s of e)
4770
- Y(I.signal, "SVGA clip prewarm aborted"), (E = I.checkActive) == null || E.call(I), this.getClipMesh(s), t++, t < e.length && a.shouldYield() && (await a.yield(), Y(I.signal, "SVGA clip prewarm aborted"), (i = I.checkActive) == null || i.call(I));
4770
+ Y(I.signal, "SVGA clip prewarm aborted"), (E = I.checkActive) == null || E.call(I), this.getClipMesh(s), t++, t < e.length && a.shouldYield() && (await a.yield(), Y(I.signal, "SVGA clip prewarm aborted"), (o = I.checkActive) == null || o.call(I));
4771
4771
  return e.length > 0 && console.info(
4772
4772
  `[GiftStage:SVGA] clip mesh main prewarm paths=${e.length} built=${t}`
4773
- ), o.length;
4773
+ ), i.length;
4774
4774
  }
4775
4775
  hydrateClipMeshes(A) {
4776
4776
  if (!(!A || A.size === 0))
@@ -4797,22 +4797,22 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4797
4797
  const C = this.batchSpritesScratch;
4798
4798
  C.length = 0;
4799
4799
  let E = null;
4800
- for (const i of I) {
4801
- const o = i.videoEntity, e = o.params.viewBoxWidth, a = o.params.viewBoxHeight, t = DA(i), s = KA(i, e, a), D = s.scaleX, w = s.scaleY, h = i.width * i.scale, n = i.height * i.scale, r = t === "cover" ? h : Math.min(s.width, h), F = t === "cover" ? n : Math.min(s.height, n), c = i.x, G = i.y, y = i.x, M = i.y;
4802
- C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), A.setScissor(c, G, r, F), this.slotScissor.x = c, this.slotScissor.y = G, this.slotScissor.w = r, this.slotScissor.h = F, i.x = y + s.offsetX, i.y = M + s.offsetY;
4803
- for (let R = 0; R < o.spriteTable.spriteCount; R++) {
4804
- const N = o.spriteTable, S = i.currentFrame;
4800
+ for (const o of I) {
4801
+ const i = o.videoEntity, e = i.params.viewBoxWidth, a = i.params.viewBoxHeight, t = DA(o), s = KA(o, e, a), D = s.scaleX, w = s.scaleY, h = o.width * o.scale, n = o.height * o.scale, r = t === "cover" ? h : Math.min(s.width, h), F = t === "cover" ? n : Math.min(s.height, n), c = o.x, G = o.y, y = o.x, M = o.y;
4802
+ C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), A.setScissor(c, G, r, F), this.slotScissor.x = c, this.slotScissor.y = G, this.slotScissor.w = r, this.slotScissor.h = F, o.x = y + s.offsetX, o.y = M + s.offsetY;
4803
+ for (let R = 0; R < i.spriteTable.spriteCount; R++) {
4804
+ const N = i.spriteTable, S = o.currentFrame;
4805
4805
  if (S < 0 || S >= N.frameCount) continue;
4806
4806
  const U = (R * N.frameCount + S) * dg;
4807
- if (N.frameData[U + 8] * i.opacity < 0.05) continue;
4807
+ if (N.frameData[U + 8] * o.opacity < 0.05) continue;
4808
4808
  const K = GC(N, R, S), d = !!K && K.length > 0, l = this.acquireSpriteWork(
4809
- i,
4809
+ o,
4810
4810
  R,
4811
4811
  N.frameData,
4812
4812
  U,
4813
4813
  D,
4814
4814
  w
4815
- ), J = (g = N.imageKeys[R]) != null ? g : "", q = this.resolveSpriteTextureInto(i, J, l);
4815
+ ), J = (g = N.imageKeys[R]) != null ? g : "", q = this.resolveSpriteTextureInto(o, J, l);
4816
4816
  if (!q && !d) {
4817
4817
  this.spriteWorkCursor--;
4818
4818
  continue;
@@ -4824,13 +4824,13 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4824
4824
  }
4825
4825
  f && f.indices.length > 0 ? (C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), this.drawClippedSprite(A, l, f, Q)) : l.override ? (C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), this.drawSingleSprite(A, l, Q)) : (E && E.id !== l.handle.id && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), C.push(l), E = l.handle, C.length >= Cg && (this.drawBatch(A, C, E, Q), C.length = 0, E = null));
4826
4826
  }
4827
- C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), i.x = y, i.y = M;
4827
+ C.length > 0 && (this.drawBatch(A, C, E, Q), C.length = 0, E = null), o.x = y, o.y = M;
4828
4828
  }
4829
4829
  C.length > 0 && this.drawBatch(A, C, E, Q), C.length = 0, this.releaseSpriteWorks(), A.resetScissor();
4830
4830
  }
4831
4831
  acquireSpriteWork(A, I, g, Q, C, E) {
4832
- let i = this.spriteWorkPool[this.spriteWorkCursor];
4833
- return i || (i = {
4832
+ let o = this.spriteWorkPool[this.spriteWorkCursor];
4833
+ return o || (o = {
4834
4834
  slot: A,
4835
4835
  spriteIndex: I,
4836
4836
  layoutW: 0,
@@ -4847,7 +4847,7 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4847
4847
  override: null,
4848
4848
  sx: C,
4849
4849
  sy: E
4850
- }, this.spriteWorkPool[this.spriteWorkCursor] = i), this.spriteWorkCursor++, i.slot = A, i.spriteIndex = I, i.layoutW = g[Q], i.layoutH = g[Q + 1], i.a = g[Q + 2], i.b = g[Q + 3], i.c = g[Q + 4], i.d = g[Q + 5], i.tx = g[Q + 6], i.ty = g[Q + 7], i.alpha = g[Q + 8], i.sx = C, i.sy = E, i;
4850
+ }, this.spriteWorkPool[this.spriteWorkCursor] = o), this.spriteWorkCursor++, o.slot = A, o.spriteIndex = I, o.layoutW = g[Q], o.layoutH = g[Q + 1], o.a = g[Q + 2], o.b = g[Q + 3], o.c = g[Q + 4], o.d = g[Q + 5], o.tx = g[Q + 6], o.ty = g[Q + 7], o.alpha = g[Q + 8], o.sx = C, o.sy = E, o;
4851
4851
  }
4852
4852
  /** Drop object references so removed slots/entities are not retained by the pool. */
4853
4853
  releaseSpriteWorks() {
@@ -4870,14 +4870,14 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4870
4870
  const E = this.pool.getFloat32(C * YA);
4871
4871
  for (let r = 0; r < C; r++)
4872
4872
  this.packFrameData(E, r, I[r]);
4873
- const i = C * qA * sA, o = C * gI, e = this.pool.getFloat32B(i), a = this.pool.getUint32(o), t = new Float32Array(E.buffer, 0, C * YA), s = new Float32Array(e.buffer, 0, i), D = new Uint32Array(a.buffer, 0, o);
4873
+ const o = C * qA * sA, i = C * gI, e = this.pool.getFloat32B(o), a = this.pool.getUint32(i), t = new Float32Array(E.buffer, 0, C * YA), s = new Float32Array(e.buffer, 0, o), D = new Uint32Array(a.buffer, 0, i);
4874
4874
  (!QI() || $I(t, s, D) === null) && jI(t, s, D);
4875
4875
  const w = this.batchDrawCursor++, h = this.ensureVertexBuffer(A, w, s), n = this.ensureIndexBuffer(A, w, D);
4876
4876
  A.draw({
4877
4877
  shader: "svga-batch-premul",
4878
4878
  vertexBuffer: h,
4879
4879
  indexBuffer: n,
4880
- indexCount: o,
4880
+ indexCount: i,
4881
4881
  textures: [g],
4882
4882
  uniforms: { u_projection: Q, u_atlas: 0 }
4883
4883
  });
@@ -4885,8 +4885,8 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4885
4885
  drawBatchInstancedWebGL(A, I, g, Q, C) {
4886
4886
  this.ensureInstancedQuadBuffers(A);
4887
4887
  const E = this.instancedFrameDataScratch;
4888
- for (let i = 0; i < g; i++)
4889
- this.packFrameData(E, i, I[i]);
4888
+ for (let o = 0; o < g; o++)
4889
+ this.packFrameData(E, o, I[o]);
4890
4890
  A.draw({
4891
4891
  shader: "svga-instanced-premul",
4892
4892
  vertexBuffer: this.instancedQuadVB,
@@ -4899,7 +4899,7 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4899
4899
  });
4900
4900
  }
4901
4901
  drawClippedSprite(A, I, g, Q) {
4902
- const { slot: C, sx: E, sy: i, a: o, b: e, c: a, d: t, tx: s, ty: D } = I, w = o * E, h = e * i, n = a * E, r = t * i, F = s * E + C.x, c = D * i + C.y, G = this.getClipRect(g);
4902
+ const { slot: C, sx: E, sy: o, a: i, b: e, c: a, d: t, tx: s, ty: D } = I, w = i * E, h = e * o, n = a * E, r = t * o, F = s * E + C.x, c = D * o + C.y, G = this.getClipRect(g);
4903
4903
  if (G && gB(w, h, n, r)) {
4904
4904
  this.applyClipRectScissor(A, G, w, r, F, c) && this.drawSingleSprite(A, I, Q), this.restoreSlotScissor(A);
4905
4905
  return;
@@ -4956,7 +4956,7 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4956
4956
  }
4957
4957
  /** Rect clip in canvas space intersected with the slot scissor. Returns false when fully clipped. */
4958
4958
  applyClipRectScissor(A, I, g, Q, C, E) {
4959
- const i = g * I.x + C, o = Q * I.y + E, e = this.slotScissor, a = Math.max(i, e.x), t = Math.max(o, e.y), s = Math.min(i + g * I.w, e.x + e.w), D = Math.min(o + Q * I.h, e.y + e.h);
4959
+ const o = g * I.x + C, i = Q * I.y + E, e = this.slotScissor, a = Math.max(o, e.x), t = Math.max(i, e.y), s = Math.min(o + g * I.w, e.x + e.w), D = Math.min(i + Q * I.h, e.y + e.h);
4960
4960
  return s <= a || D <= t ? !1 : (A.setScissor(a, t, s - a, D - t), !0);
4961
4961
  }
4962
4962
  restoreSlotScissor(A) {
@@ -4970,8 +4970,8 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4970
4970
  return (!I.vertexBuf || !I.indexBuf) && (I.vertexBuf = A.createBuffer(I.vertices, "vertex"), I.indexBuf = A.createBuffer(I.indices, "index"), this.clipMeshesWithBuffers.add(I)), { vertexBuf: I.vertexBuf, indexBuf: I.indexBuf };
4971
4971
  }
4972
4972
  packClipTransform(A, I, g, Q, C, E) {
4973
- const i = this.clipTransformMat;
4974
- return i[0] = A, i[1] = I, i[4] = g, i[5] = Q, i[12] = C, i[13] = E, i;
4973
+ const o = this.clipTransformMat;
4974
+ return o[0] = A, o[1] = I, o[4] = g, o[5] = Q, o[12] = C, o[13] = E, o;
4975
4975
  }
4976
4976
  drawSingleSprite(A, I, g) {
4977
4977
  if (A.type === "webgl2" || A.type === "webgpu") {
@@ -4993,16 +4993,16 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
4993
4993
  this.packFrameData(Q, 0, I);
4994
4994
  const C = qA * sA, E = gI;
4995
4995
  (!this.clipSpriteVertsScratch || this.clipSpriteVertsScratch.length < C) && (this.clipSpriteVertsScratch = new Float32Array(C)), (!this.clipSpriteIndicesScratch || this.clipSpriteIndicesScratch.length < E) && (this.clipSpriteIndicesScratch = new Uint32Array(E));
4996
- const i = this.clipSpriteVertsScratch, o = this.clipSpriteIndicesScratch;
4997
- (!QI() || $I(Q, i, o) === null) && jI(Q, i, o);
4996
+ const o = this.clipSpriteVertsScratch, i = this.clipSpriteIndicesScratch;
4997
+ (!QI() || $I(Q, o, i) === null) && jI(Q, o, i);
4998
4998
  const e = this.clipSpriteDrawCursor++, a = this.ensureClipSpriteVertexBuffer(
4999
4999
  A,
5000
5000
  e,
5001
- i.subarray(0, C)
5001
+ o.subarray(0, C)
5002
5002
  ), t = this.ensureClipSpriteIndexBuffer(
5003
5003
  A,
5004
5004
  e,
5005
- o.subarray(0, E)
5005
+ i.subarray(0, E)
5006
5006
  );
5007
5007
  A.draw({
5008
5008
  shader: "svga-batch-premul",
@@ -5025,33 +5025,33 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
5025
5025
  });
5026
5026
  }
5027
5027
  packFrameData(A, I, g) {
5028
- const { slot: Q, layoutW: C, layoutH: E, a: i, b: o, c: e, d: a, tx: t, ty: s, alpha: D, rect: w, override: h, sx: n, sy: r } = g;
5028
+ const { slot: Q, layoutW: C, layoutH: E, a: o, b: i, c: e, d: a, tx: t, ty: s, alpha: D, rect: w, override: h, sx: n, sy: r } = g;
5029
5029
  let F = C || (h == null ? void 0 : h.logicalWidth) || 0, c = E || (h == null ? void 0 : h.logicalHeight) || 0, G = 0, y = 0;
5030
5030
  if ((h == null ? void 0 : h.mode) === "dynamic") {
5031
5031
  const l = C || h.logicalWidth, J = E || h.logicalHeight;
5032
5032
  F = h.logicalWidth, c = h.logicalHeight, G = Math.max(0, (l - F) * 0.5), y = Math.max(0, (J - c) * 0.5);
5033
5033
  }
5034
- const M = I * YA, R = i * n, N = o * r, S = e * n, U = a * r, K = t * n + R * G + S * y + Q.x, d = s * r + N * G + U * y + Q.y;
5034
+ const M = I * YA, R = o * n, N = i * r, S = e * n, U = a * r, K = t * n + R * G + S * y + Q.x, d = s * r + N * G + U * y + Q.y;
5035
5035
  A[M] = F, A[M + 1] = c, A[M + 2] = R, A[M + 3] = N, A[M + 4] = S, A[M + 5] = U, A[M + 6] = K, A[M + 7] = d, A[M + 8] = D * Q.opacity, A[M + 9] = w.x, A[M + 10] = w.y, A[M + 11] = w.x + w.w, A[M + 12] = w.y + w.h;
5036
5036
  }
5037
5037
  /** Resolve atlas/override texture into a pooled SpriteWork entry. Returns false when missing. */
5038
5038
  resolveSpriteTextureInto(A, I, g) {
5039
- var Q, C, E, i, o;
5039
+ var Q, C, E, o, i;
5040
5040
  const e = (C = (Q = A.svgaSlotTextures) == null ? void 0 : Q.get(I)) != null ? C : null;
5041
5041
  if (e)
5042
5042
  return g.handle = e.texture, g.rect = Eg, g.override = e, !0;
5043
- const a = A.videoEntity, t = a.atlasRects.get(I), s = (E = t == null ? void 0 : t.textureIndex) != null ? E : 0, D = (o = (i = a.atlasTextureHandles) == null ? void 0 : i[s]) != null ? o : a.atlasTextureHandle;
5043
+ const a = A.videoEntity, t = a.atlasRects.get(I), s = (E = t == null ? void 0 : t.textureIndex) != null ? E : 0, D = (i = (o = a.atlasTextureHandles) == null ? void 0 : o[s]) != null ? i : a.atlasTextureHandle;
5044
5044
  return !t || !D ? !1 : (g.handle = D, g.rect = t, g.override = null, !0);
5045
5045
  }
5046
5046
  drawShapeFrame(A, I, g, Q, C) {
5047
5047
  const E = this.getShapeMesh(g);
5048
5048
  if (!E || E.indices.length === 0) return;
5049
- const { slot: i, sx: o, sy: e, a, b: t, c: s, d: D, tx: w, ty: h, alpha: n } = I, r = this.getWhiteTexture(A), F = a * o, c = t * e, G = s * o, y = D * e, M = w * o + i.x, R = h * e + i.y, N = E.vertices, S = N.length / 6 * sA;
5049
+ const { slot: o, sx: i, sy: e, a, b: t, c: s, d: D, tx: w, ty: h, alpha: n } = I, r = this.getWhiteTexture(A), F = a * i, c = t * e, G = s * i, y = D * e, M = w * i + o.x, R = h * e + o.y, N = E.vertices, S = N.length / 6 * sA;
5050
5050
  (!this.shapeVertsScratch || this.shapeVertsScratch.length < S) && (this.shapeVertsScratch = new Float32Array(S));
5051
5051
  const U = this.shapeVertsScratch;
5052
5052
  for (let f = 0, W = 0; f < N.length; f += 6, W += sA) {
5053
5053
  const iA = N[f], GA = N[f + 1];
5054
- U[W] = F * iA + G * GA + M, U[W + 1] = c * iA + y * GA + R, U[W + 2] = 0, U[W + 3] = N[f + 2], U[W + 4] = N[f + 3], U[W + 5] = N[f + 4], U[W + 6] = N[f + 5] * n * i.opacity, U[W + 7] = 0.5, U[W + 8] = 0.5;
5054
+ U[W] = F * iA + G * GA + M, U[W + 1] = c * iA + y * GA + R, U[W + 2] = 0, U[W + 3] = N[f + 2], U[W + 4] = N[f + 3], U[W + 5] = N[f + 4], U[W + 6] = N[f + 5] * n * o.opacity, U[W + 7] = 0.5, U[W + 8] = 0.5;
5055
5055
  }
5056
5056
  let K = !1, d = null, l = null;
5057
5057
  if (Q && Q.indices.length > 0) {
@@ -5121,13 +5121,13 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
5121
5121
  }
5122
5122
  appendShape(A, I, g) {
5123
5123
  const Q = A.style.fill, C = A.style.stroke, E = this.buildShapeSubPaths(A);
5124
- for (const i of E) {
5125
- if (i.length < 2) continue;
5126
- const o = i.map((e) => ({
5124
+ for (const o of E) {
5125
+ if (o.length < 2) continue;
5126
+ const i = o.map((e) => ({
5127
5127
  x: A.transform.a * e.x + A.transform.c * e.y + A.transform.tx,
5128
5128
  y: A.transform.b * e.x + A.transform.d * e.y + A.transform.ty
5129
5129
  }));
5130
- Q && Q.a > 0 && o.length >= 3 && this.appendFill(o, Q, I, g), C && C.a > 0 && A.style.strokeWidth > 0.01 && this.appendStroke(o, C, A.style.strokeWidth, I, g);
5130
+ Q && Q.a > 0 && i.length >= 3 && this.appendFill(i, Q, I, g), C && C.a > 0 && A.style.strokeWidth > 0.01 && this.appendStroke(i, C, A.style.strokeWidth, I, g);
5131
5131
  }
5132
5132
  }
5133
5133
  buildShapeSubPaths(A) {
@@ -5148,8 +5148,8 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
5148
5148
  if (A.kind === "ellipse" && A.ellipse) {
5149
5149
  const g = A.ellipse, Q = [], C = 40;
5150
5150
  for (let E = 0; E < C; E++) {
5151
- const i = E / C * Math.PI * 2;
5152
- Q.push({ x: g.x + Math.cos(i) * g.radiusX, y: g.y + Math.sin(i) * g.radiusY });
5151
+ const o = E / C * Math.PI * 2;
5152
+ Q.push({ x: g.x + Math.cos(o) * g.radiusX, y: g.y + Math.sin(o) * g.radiusY });
5153
5153
  }
5154
5154
  return [Q];
5155
5155
  }
@@ -5159,29 +5159,29 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
5159
5159
  const C = this.cleanupPoints(A);
5160
5160
  if (C.length < 3) return;
5161
5161
  const E = g.length / 6;
5162
- for (const o of C)
5162
+ for (const i of C)
5163
5163
  g.push(
5164
- o.x,
5165
- o.y,
5164
+ i.x,
5165
+ i.y,
5166
5166
  this.clamp01(I.r),
5167
5167
  this.clamp01(I.g),
5168
5168
  this.clamp01(I.b),
5169
5169
  this.clamp01(I.a)
5170
5170
  );
5171
- const i = gE(C);
5172
- if (i.length >= (C.length - 2) * 3)
5173
- for (const o of i) Q.push(E + o);
5171
+ const o = gE(C);
5172
+ if (o.length >= (C.length - 2) * 3)
5173
+ for (const i of o) Q.push(E + i);
5174
5174
  else
5175
- for (let o = 1; o < C.length - 1; o++) Q.push(E, E + o, E + o + 1);
5175
+ for (let i = 1; i < C.length - 1; i++) Q.push(E, E + i, E + i + 1);
5176
5176
  }
5177
5177
  appendStroke(A, I, g, Q, C) {
5178
5178
  A = this.cleanupPoints(A);
5179
5179
  const E = g * 0.5;
5180
- for (let i = 0; i < A.length; i++) {
5181
- const o = A[i], e = A[(i + 1) % A.length], a = e.x - o.x, t = e.y - o.y, s = Math.hypot(a, t);
5180
+ for (let o = 0; o < A.length; o++) {
5181
+ const i = A[o], e = A[(o + 1) % A.length], a = e.x - i.x, t = e.y - i.y, s = Math.hypot(a, t);
5182
5182
  if (s <= 1e-4) continue;
5183
5183
  const D = -t / s * E, w = a / s * E, h = Q.length / 6, n = this.clamp01(I.r), r = this.clamp01(I.g), F = this.clamp01(I.b), c = this.clamp01(I.a);
5184
- Q.push(o.x - D, o.y - w, n, r, F, c), Q.push(o.x + D, o.y + w, n, r, F, c), Q.push(e.x + D, e.y + w, n, r, F, c), Q.push(e.x - D, e.y - w, n, r, F, c), C.push(h, h + 1, h + 2, h + 2, h + 3, h);
5184
+ Q.push(i.x - D, i.y - w, n, r, F, c), Q.push(i.x + D, i.y + w, n, r, F, c), Q.push(e.x + D, e.y + w, n, r, F, c), Q.push(e.x - D, e.y - w, n, r, F, c), C.push(h, h + 1, h + 2, h + 2, h + 3, h);
5185
5185
  }
5186
5186
  }
5187
5187
  clamp01(A) {
@@ -5193,14 +5193,14 @@ const Cg = 2048, Eg = { x: 0, y: 0, w: 1, h: 1 }, Hg = class Sg {
5193
5193
  let Q = null;
5194
5194
  for (const C of A) {
5195
5195
  if (Q) {
5196
- const E = C.x - Q.x, i = C.y - Q.y;
5197
- if (E * E + i * i <= g) continue;
5196
+ const E = C.x - Q.x, o = C.y - Q.y;
5197
+ if (E * E + o * o <= g) continue;
5198
5198
  }
5199
5199
  I.push(C), Q = C;
5200
5200
  }
5201
5201
  if (I.length > 2) {
5202
- const C = I[0], E = I[I.length - 1], i = C.x - E.x, o = C.y - E.y;
5203
- i * i + o * o <= g && I.pop();
5202
+ const C = I[0], E = I[I.length - 1], o = C.x - E.x, i = C.y - E.y;
5203
+ o * o + i * i <= g && I.pop();
5204
5204
  }
5205
5205
  return I;
5206
5206
  }
@@ -5278,16 +5278,16 @@ function mE(B, A) {
5278
5278
  const t = B[a], s = B[a + 1];
5279
5279
  t < I && (I = t), t > Q && (Q = t), s < g && (g = s), s > C && (C = s);
5280
5280
  }
5281
- const E = Q - I, i = C - g;
5282
- if (!(E > 0 && i > 0)) return null;
5283
- const o = Math.max(E, i) * 1e-4 + 1e-6;
5281
+ const E = Q - I, o = C - g;
5282
+ if (!(E > 0 && o > 0)) return null;
5283
+ const i = Math.max(E, o) * 1e-4 + 1e-6;
5284
5284
  let e = 0;
5285
5285
  for (let a = 0; a < 8; a += 2) {
5286
- const t = B[a], s = B[a + 1], D = Math.abs(t - I) <= o, w = Math.abs(t - Q) <= o, h = Math.abs(s - g) <= o, n = Math.abs(s - C) <= o;
5286
+ const t = B[a], s = B[a + 1], D = Math.abs(t - I) <= i, w = Math.abs(t - Q) <= i, h = Math.abs(s - g) <= i, n = Math.abs(s - C) <= i;
5287
5287
  if (!D && !w || !h && !n) return null;
5288
5288
  e |= 1 << ((D ? 0 : 1) | (h ? 0 : 2));
5289
5289
  }
5290
- return e !== 15 ? null : { x: I, y: g, w: E, h: i };
5290
+ return e !== 15 ? null : { x: I, y: g, w: E, h: o };
5291
5291
  }
5292
5292
  var bE = Object.defineProperty, TE = (B, A, I) => A in B ? bE(B, A, { enumerable: !0, configurable: !0, writable: !0, value: I }) : B[A] = I, oA = (B, A, I) => TE(B, typeof A != "symbol" ? A + "" : A, I);
5293
5293
  const WE = 4, ZE = 128 * 1024 * 1024, VE = 2048 * 1024 * 1024, vE = "gift-stage-resource-cache", XE = 2, BA = "resources", ig = "byUpdatedAt", OE = 3e4;
@@ -5338,7 +5338,7 @@ function zE(B) {
5338
5338
  for (const E of C.imageKeys) Q += rA(E);
5339
5339
  for (const E of C.clipPaths) Q += rA(E);
5340
5340
  for (const E of C.shapesTable)
5341
- for (const i of E) Q += rA((g = i.pathData) != null ? g : "") + 96;
5341
+ for (const o of E) Q += rA((g = o.pathData) != null ? g : "") + 96;
5342
5342
  return Q;
5343
5343
  }
5344
5344
  function og(B) {
@@ -5358,15 +5358,15 @@ class _E {
5358
5358
  const g = `ab:${A}`, Q = this.getMemory(g, "arrayBuffer");
5359
5359
  if (Q) return Q.slice(0);
5360
5360
  const C = await this.getPersistent(g, "arrayBuffer");
5361
- return C ? (this.setMemory(g, "arrayBuffer", C, C.byteLength), C.slice(0)) : this.getOrCreatePending(
5361
+ return C ? (this.setMemory(g, "arrayBuffer", C, C.byteLength), C.slice(0)) : (await this.getOrCreatePending(
5362
5362
  g,
5363
5363
  () => this.limiter.run(async () => {
5364
- const E = await fetch(A, { mode: "cors", signal: I });
5365
- if (!E.ok) throw new Error(`fetch failed ${E.status}`);
5366
- const i = await E.arrayBuffer();
5367
- return this.setMemory(g, "arrayBuffer", i, i.byteLength), this.setPersistent(g, "arrayBuffer", i.slice(0)), i.slice(0);
5364
+ const o = await fetch(A, { mode: "cors", signal: I });
5365
+ if (!o.ok) throw new Error(`fetch failed ${o.status}`);
5366
+ const i = await o.arrayBuffer();
5367
+ return this.setMemory(g, "arrayBuffer", i, i.byteLength), this.setPersistent(g, "arrayBuffer", i.slice(0)), i;
5368
5368
  })
5369
- );
5369
+ )).slice(0);
5370
5370
  }
5371
5371
  async fetchText(A, I) {
5372
5372
  const g = `text:${A}`, Q = this.getMemory(g, "text");
@@ -5377,8 +5377,8 @@ class _E {
5377
5377
  () => this.limiter.run(async () => {
5378
5378
  const E = await fetch(A, { mode: "cors", signal: I });
5379
5379
  if (!E.ok) throw new Error(`fetch failed ${E.status}`);
5380
- const i = await E.text();
5381
- return this.setMemory(g, "text", i, rA(i)), this.setPersistent(g, "text", i), i;
5380
+ const o = await E.text();
5381
+ return this.setMemory(g, "text", o, rA(o)), this.setPersistent(g, "text", o), o;
5382
5382
  })
5383
5383
  );
5384
5384
  }
@@ -5459,24 +5459,24 @@ class _E {
5459
5459
  try {
5460
5460
  const C = g.transaction(BA, "readonly");
5461
5461
  C.onerror = () => Q(null), C.onabort = () => Q(null);
5462
- const i = C.objectStore(BA).get(A);
5463
- i.onsuccess = () => {
5464
- const o = i.result;
5465
- if (!o || o.kind !== I) {
5462
+ const o = C.objectStore(BA).get(A);
5463
+ o.onsuccess = () => {
5464
+ const i = o.result;
5465
+ if (!i || i.kind !== I) {
5466
5466
  Q(null);
5467
5467
  return;
5468
5468
  }
5469
- const e = o.sizeBytes || og(o.value);
5470
- if (Date.now() - o.updatedAt >= OE && this.touchPersistent({
5471
- ...o,
5469
+ const e = i.sizeBytes || og(i.value);
5470
+ if (Date.now() - i.updatedAt >= OE && this.touchPersistent({
5471
+ ...i,
5472
5472
  sizeBytes: e,
5473
5473
  updatedAt: Date.now()
5474
5474
  }), I === "arrayBuffer") {
5475
- Q(o.value);
5475
+ Q(i.value);
5476
5476
  return;
5477
5477
  }
5478
- Q(o.value);
5479
- }, i.onerror = () => Q(null);
5478
+ Q(i.value);
5479
+ }, o.onerror = () => Q(null);
5480
5480
  } catch (C) {
5481
5481
  Q(null);
5482
5482
  }
@@ -5488,9 +5488,9 @@ class _E {
5488
5488
  const C = og(g);
5489
5489
  await new Promise((E) => {
5490
5490
  try {
5491
- const i = Q.transaction(BA, "readwrite");
5492
- i.onerror = () => E(), i.onabort = () => E();
5493
- const e = i.objectStore(BA).put({
5491
+ const o = Q.transaction(BA, "readwrite");
5492
+ o.onerror = () => E(), o.onabort = () => E();
5493
+ const e = o.objectStore(BA).put({
5494
5494
  key: A,
5495
5495
  kind: I,
5496
5496
  value: g,
@@ -5498,7 +5498,7 @@ class _E {
5498
5498
  updatedAt: Date.now()
5499
5499
  });
5500
5500
  e.onsuccess = () => E(), e.onerror = () => E();
5501
- } catch (i) {
5501
+ } catch (o) {
5502
5502
  E();
5503
5503
  }
5504
5504
  }), this.schedulePersistentTrim();
@@ -5528,22 +5528,22 @@ class _E {
5528
5528
  const g = A.transaction(BA, "readwrite");
5529
5529
  g.oncomplete = () => I(), g.onerror = () => I(), g.onabort = () => I();
5530
5530
  const Q = g.objectStore(BA), C = Q.index(ig), E = [];
5531
- let i = 0;
5532
- const o = C.openCursor();
5533
- o.onsuccess = () => {
5534
- const e = o.result;
5531
+ let o = 0;
5532
+ const i = C.openCursor();
5533
+ i.onsuccess = () => {
5534
+ const e = i.result;
5535
5535
  if (e) {
5536
5536
  const t = e.value, s = t.sizeBytes || og(t.value);
5537
- i += s, E.push({ key: t.key, sizeBytes: s }), e.continue();
5537
+ o += s, E.push({ key: t.key, sizeBytes: s }), e.continue();
5538
5538
  return;
5539
5539
  }
5540
- if (i <= this.maxPersistentBytes) return;
5541
- let a = i;
5540
+ if (o <= this.maxPersistentBytes) return;
5541
+ let a = o;
5542
5542
  for (const t of E) {
5543
5543
  if (a <= this.maxPersistentBytes) break;
5544
5544
  Q.delete(t.key), a -= t.sizeBytes;
5545
5545
  }
5546
- }, o.onerror = () => I();
5546
+ }, i.onerror = () => I();
5547
5547
  } catch (g) {
5548
5548
  I();
5549
5549
  }
@@ -5642,14 +5642,14 @@ class $B {
5642
5642
  return a;
5643
5643
  }
5644
5644
  this.ensureRvf(A, I);
5645
- const Q = performance.now(), C = this.lastCallbackAt.get(A), E = this.lastArmAt.get(A), i = C != null ? C : E, o = this.lastTimeFallback.get(A), e = o !== void 0 && Math.abs(g - o) > 1e-4;
5646
- return this.firstUploaded.has(A) && i !== void 0 && Q - i > 500 && !I.paused && !I.ended && (this.stallLogged.has(A) || (this.stallLogged.add(A), this.debugWarn(A, "rVFC stalled for slot", I, {
5647
- stallAgeMs: Math.round(Q - i),
5645
+ const Q = performance.now(), C = this.lastCallbackAt.get(A), E = this.lastArmAt.get(A), o = C != null ? C : E, i = this.lastTimeFallback.get(A), e = i !== void 0 && Math.abs(g - i) > 1e-4;
5646
+ return this.firstUploaded.has(A) && o !== void 0 && Q - o > 500 && !I.paused && !I.ended && (this.stallLogged.has(A) || (this.stallLogged.add(A), this.debugWarn(A, "rVFC stalled for slot", I, {
5647
+ stallAgeMs: Math.round(Q - o),
5648
5648
  lastCallbackAgeMs: C !== void 0 ? Math.round(Q - C) : null,
5649
5649
  lastArmAgeMs: E !== void 0 ? Math.round(Q - E) : null,
5650
5650
  timeAdvanced: e
5651
5651
  })), this.tryRecoverStalledPlayback(A, I, g, Q), this.started.delete(A), this.ensureRvf(A, I), e) ? (this.forceTimeFallback.add(A), this.lastTimeFallback.set(A, g), this.markProgress(A), this.debugWarn(A, "switching slot to time fallback", I, {
5652
- stallAgeMs: Math.round(Q - i)
5652
+ stallAgeMs: Math.round(Q - o)
5653
5653
  }), !0) : this.firstUploaded.has(A) ? this.pending.has(A) ? (this.pending.delete(A), this.lastTimeFallback.set(A, g), this.markProgress(A), (this.stallLogged.delete(A) || this.forceTimeFallback.delete(A)) && (this.stagnationLogged.delete(A), this.debugInfo(A, "rVFC progress resumed", I)), !0) : !1 : (this.firstUploaded.add(A), this.lastTimeFallback.set(A, g), this.markProgress(A), !0);
5654
5654
  }
5655
5655
  getFrameInfo(A) {
@@ -5688,9 +5688,9 @@ class $B {
5688
5688
  const C = this.lastRecoveryAt.get(A);
5689
5689
  if (C !== void 0 && Q - C < 1500) return;
5690
5690
  this.lastRecoveryAt.set(A, Q);
5691
- const E = Number.isFinite(I.duration) ? I.duration : NaN, i = Number.isFinite(E) && E > 0, o = i ? Math.min(Math.max(0, E - 1e-3), g + 1e-3) : g;
5691
+ const E = Number.isFinite(I.duration) ? I.duration : NaN, o = Number.isFinite(E) && E > 0, i = o ? Math.min(Math.max(0, E - 1e-3), g + 1e-3) : g;
5692
5692
  try {
5693
- i && o > g && (I.currentTime = o);
5693
+ o && i > g && (I.currentTime = i);
5694
5694
  } catch (e) {
5695
5695
  }
5696
5696
  try {
@@ -5701,7 +5701,7 @@ class $B {
5701
5701
  }
5702
5702
  this.debugWarn(A, "attempting stalled video recovery", I, {
5703
5703
  currentTime: g,
5704
- nudgedTime: o,
5704
+ nudgedTime: i,
5705
5705
  readyState: I.readyState
5706
5706
  });
5707
5707
  }
@@ -5828,27 +5828,27 @@ function wi(B) {
5828
5828
  return WA(g) ? g : void 0;
5829
5829
  }
5830
5830
  function EB(B, A, I, g) {
5831
- const Q = B.measureText(A), C = Q.width / I, E = (Q.actualBoundingBoxAscent || 0) + (Q.actualBoundingBoxDescent || 0), i = E > 0 ? E / I : g;
5831
+ const Q = B.measureText(A), C = Q.width / I, E = (Q.actualBoundingBoxAscent || 0) + (Q.actualBoundingBoxDescent || 0), o = E > 0 ? E / I : g;
5832
5832
  return {
5833
5833
  width: Math.max(1, C),
5834
- height: Math.max(1, i)
5834
+ height: Math.max(1, o)
5835
5835
  };
5836
5836
  }
5837
- function hi(B, A, I, g, Q, C, E, i) {
5838
- let o = Math.max(1, Math.min(E, i)), e = Math.max(o, i), a = o, t = { width: 1, height: 1 };
5837
+ function hi(B, A, I, g, Q, C, E, o) {
5838
+ let i = Math.max(1, Math.min(E, o)), e = Math.max(i, o), a = i, t = { width: 1, height: 1 };
5839
5839
  for (let s = 0; s < 16; s++) {
5840
- const D = (o + e) * 0.5;
5840
+ const D = (i + e) * 0.5;
5841
5841
  B.font = g(D);
5842
5842
  const w = EB(B, A, I, D);
5843
- w.width <= Q && w.height <= C ? (a = D, t = w, o = D) : e = D;
5843
+ w.width <= Q && w.height <= C ? (a = D, t = w, i = D) : e = D;
5844
5844
  }
5845
5845
  return B.font = g(a), t = EB(B, A, I, a), { fontSize: a, metrics: t };
5846
5846
  }
5847
5847
  function gQ(B, A, I, g) {
5848
- var Q, C, E, i, o, e;
5848
+ var Q, C, E, o, i, e;
5849
5849
  const a = Math.max(1, g.scale || 1), t = Math.max(1, Math.round(B)), s = Math.max(1, Math.round(A)), D = xA(1, 1), w = mA(D), h = (Q = g.color) != null ? Q : "#ffffff", n = Math.max(0, (C = g.padding) != null ? C : 2), r = Math.max(1, t - n * 2), F = Math.max(1, s - n * 2), c = Math.max(
5850
5850
  1,
5851
- (o = (i = (E = g.maxFontSize) != null ? E : g.fontSize) != null ? i : wi(g.fontStyle)) != null ? o : Math.max(8, F)
5851
+ (i = (o = (E = g.maxFontSize) != null ? E : g.fontSize) != null ? o : wi(g.fontStyle)) != null ? i : Math.max(8, F)
5852
5852
  ), G = Math.max(1, Math.min((e = g.minFontSize) != null ? e : 8, c)), y = h, M = `${g.style === "b" ? "bold " : ""}${c * a}px Arial`, R = si(g.fontStyle, M, y), N = (J) => Di(R.font, J * a), S = hi(
5853
5853
  w,
5854
5854
  I,
@@ -5862,7 +5862,7 @@ function gQ(B, A, I, g) {
5862
5862
  return l.clearRect(0, 0, d.width, d.height), l.textAlign = "center", l.textBaseline = "middle", l.font = N(S.fontSize), l.fillStyle = R.color, l.fillText(I, d.width / 2, d.height / 2), { canvas: d, logicalWidth: U, logicalHeight: K };
5863
5863
  }
5864
5864
  async function ni(B, A, I, g) {
5865
- var Q, C, E, i, o, e;
5865
+ var Q, C, E, o, i, e;
5866
5866
  const a = B.spriteTable, t = new Set(A), s = /* @__PURE__ */ new Map();
5867
5867
  for (let h = 0; h < a.imageKeys.length; h++) {
5868
5868
  const n = a.imageKeys[h];
@@ -5882,7 +5882,7 @@ async function ni(B, A, I, g) {
5882
5882
  }
5883
5883
  let r = 0, F = 0, c = Number.POSITIVE_INFINITY;
5884
5884
  for (let M = 0; M < w; M++) {
5885
- const R = (n * w + M) * 9, N = (Q = a.frameData[R]) != null ? Q : 0, S = (C = a.frameData[R + 1]) != null ? C : 0, U = (E = a.frameData[R + 2]) != null ? E : 1, K = (i = a.frameData[R + 3]) != null ? i : 0, d = (o = a.frameData[R + 4]) != null ? o : 0, l = (e = a.frameData[R + 5]) != null ? e : 1;
5885
+ const R = (n * w + M) * 9, N = (Q = a.frameData[R]) != null ? Q : 0, S = (C = a.frameData[R + 1]) != null ? C : 0, U = (E = a.frameData[R + 2]) != null ? E : 1, K = (o = a.frameData[R + 3]) != null ? o : 0, d = (i = a.frameData[R + 4]) != null ? i : 0, l = (e = a.frameData[R + 5]) != null ? e : 1;
5886
5886
  if (r = Math.max(r, N), F = Math.max(F, S), N > 0 && S > 0) {
5887
5887
  const J = Math.abs(U) * N + Math.abs(d) * S, q = Math.abs(K) * N + Math.abs(l) * S, u = J > 0 ? J / N : 1, f = q > 0 ? q / S : 1, W = Math.min(u || 1, f || 1);
5888
5888
  WA(W) && (c = Math.min(c, W));
@@ -5905,7 +5905,7 @@ function eg(B, A) {
5905
5905
  async function ci(B, A, I, g = 1) {
5906
5906
  var Q, C, E;
5907
5907
  if (AQ(B)) {
5908
- const o = (Q = B.mode) != null ? Q : "dynamic", e = gQ(A, I, B.text, {
5908
+ const i = (Q = B.mode) != null ? Q : "dynamic", e = gQ(A, I, B.text, {
5909
5909
  scale: (C = B.scale) != null ? C : oi,
5910
5910
  color: B.color,
5911
5911
  style: B.style,
@@ -5914,55 +5914,55 @@ async function ci(B, A, I, g = 1) {
5914
5914
  minFontSize: eg(B.minFontSize, g),
5915
5915
  maxFontSize: eg(B.maxFontSize, g),
5916
5916
  padding: B.padding,
5917
- sizing: o === "dynamic" ? "intrinsic" : "box"
5917
+ sizing: i === "dynamic" ? "intrinsic" : "box"
5918
5918
  });
5919
5919
  return {
5920
5920
  source: e.canvas,
5921
- mode: o,
5921
+ mode: i,
5922
5922
  logicalWidth: e.logicalWidth,
5923
5923
  logicalHeight: e.logicalHeight
5924
5924
  };
5925
5925
  }
5926
5926
  if (ai(B)) {
5927
- const o = typeof B.image == "string" ? await xI(B.image) : B.image, e = bA(o);
5927
+ const i = typeof B.image == "string" ? await xI(B.image) : B.image, e = bA(i);
5928
5928
  return {
5929
- source: o,
5929
+ source: i,
5930
5930
  mode: (E = B.mode) != null ? E : "replace",
5931
5931
  logicalWidth: Math.max(1, e.width || A),
5932
5932
  logicalHeight: Math.max(1, e.height || I)
5933
5933
  };
5934
5934
  }
5935
5935
  if (typeof B == "string") {
5936
- const o = await xI(B), e = bA(o);
5936
+ const i = await xI(B), e = bA(i);
5937
5937
  return {
5938
- source: o,
5938
+ source: i,
5939
5939
  mode: "replace",
5940
5940
  logicalWidth: Math.max(1, e.width || A),
5941
5941
  logicalHeight: Math.max(1, e.height || I)
5942
5942
  };
5943
5943
  }
5944
- const i = bA(B);
5944
+ const o = bA(B);
5945
5945
  return {
5946
5946
  source: B,
5947
5947
  mode: "replace",
5948
- logicalWidth: Math.max(1, i.width || A),
5949
- logicalHeight: Math.max(1, i.height || I)
5948
+ logicalWidth: Math.max(1, o.width || A),
5949
+ logicalHeight: Math.max(1, o.height || I)
5950
5950
  };
5951
5951
  }
5952
5952
  async function ri(B, A, I, g = {}) {
5953
5953
  var Q, C, E;
5954
- const i = /* @__PURE__ */ new Map();
5955
- if (!I) return i;
5956
- const o = Object.entries(I), e = gA({
5954
+ const o = /* @__PURE__ */ new Map();
5955
+ if (!I) return o;
5956
+ const i = Object.entries(I), e = gA({
5957
5957
  maxBudgetMs: g.frameBudgetMs
5958
5958
  }), a = await ni(
5959
5959
  A,
5960
- o.map(([t]) => t),
5960
+ i.map(([t]) => t),
5961
5961
  e,
5962
5962
  g.checkActive
5963
5963
  );
5964
- for (let t = 0; t < o.length; t++) {
5965
- const [s, D] = o[t];
5964
+ for (let t = 0; t < i.length; t++) {
5965
+ const [s, D] = i[t];
5966
5966
  (Q = g.checkActive) == null || Q.call(g);
5967
5967
  const w = (C = a.get(s)) != null ? C : { width: 1, height: 1, renderScale: 1 }, h = await ci(
5968
5968
  D,
@@ -5975,14 +5975,14 @@ async function ri(B, A, I, g = {}) {
5975
5975
  filter: "linear",
5976
5976
  premultiplyAlpha: !0
5977
5977
  });
5978
- i.set(s, {
5978
+ o.set(s, {
5979
5979
  texture: c,
5980
5980
  mode: h.mode,
5981
5981
  logicalWidth: h.logicalWidth,
5982
5982
  logicalHeight: h.logicalHeight
5983
- }), t + 1 < o.length && e.shouldYield() && (await e.yield(), (E = g.checkActive) == null || E.call(g));
5983
+ }), t + 1 < i.length && e.shouldYield() && (await e.yield(), (E = g.checkActive) == null || E.call(g));
5984
5984
  }
5985
- return i;
5985
+ return o;
5986
5986
  }
5987
5987
  function Fi(B, A) {
5988
5988
  var I, g;
@@ -5991,12 +5991,12 @@ function Fi(B, A) {
5991
5991
  return (g = (I = A[C]) != null ? I : A[E]) != null ? g : A[Q];
5992
5992
  }
5993
5993
  function Gi(B, A, I) {
5994
- var g, Q, C, E, i, o;
5994
+ var g, Q, C, E, o, i;
5995
5995
  const e = typeof A == "string" ? A : A.text, a = (g = I == null ? void 0 : I.width) != null ? g : B.w && B.w > 0 ? B.w : 1, t = (Q = I == null ? void 0 : I.height) != null ? Q : B.h && B.h > 0 ? B.h : 1, s = gQ(a, t, e, {
5996
5996
  scale: typeof A == "string" ? 1 : (C = A.scale) != null ? C : 1,
5997
5997
  color: typeof A == "string" ? B.color : (E = A.color) != null ? E : B.color,
5998
- style: typeof A == "string" ? B.style : (i = A.style) != null ? i : B.style,
5999
- fontStyle: typeof A == "string" ? B.fontStyle : (o = A.fontStyle) != null ? o : B.fontStyle,
5998
+ style: typeof A == "string" ? B.style : (o = A.style) != null ? o : B.style,
5999
+ fontStyle: typeof A == "string" ? B.fontStyle : (i = A.fontStyle) != null ? i : B.fontStyle,
6000
6000
  fontSize: typeof A == "string" ? void 0 : A.fontSize,
6001
6001
  minFontSize: typeof A == "string" ? void 0 : A.minFontSize,
6002
6002
  maxFontSize: typeof A == "string" ? void 0 : A.maxFontSize,
@@ -6014,10 +6014,10 @@ function Ri(B, A) {
6014
6014
  const g = String(A);
6015
6015
  let Q = 0, C = 0;
6016
6016
  for (const E of (I = B.frame) != null ? I : [])
6017
- for (const i of E.obj) {
6018
- if (String(i.srcId) !== g) continue;
6019
- const [, , o, e] = i.frame;
6020
- Q = Math.max(Q, o), C = Math.max(C, e);
6017
+ for (const o of E.obj) {
6018
+ if (String(o.srcId) !== g) continue;
6019
+ const [, , i, e] = o.frame;
6020
+ Q = Math.max(Q, i), C = Math.max(C, e);
6021
6021
  }
6022
6022
  return Q > 0 && C > 0 ? { width: Q, height: C } : void 0;
6023
6023
  }
@@ -6040,21 +6040,21 @@ async function Mi(B, A) {
6040
6040
  });
6041
6041
  continue;
6042
6042
  }
6043
- const o = Gi(
6043
+ const i = Gi(
6044
6044
  g,
6045
6045
  typeof Q == "string" || AQ(Q) ? Q : String(Q),
6046
6046
  Ri(B, g.srcId)
6047
6047
  );
6048
- I.set(String(g.srcId), o);
6048
+ I.set(String(g.srcId), i);
6049
6049
  continue;
6050
6050
  }
6051
6051
  const C = CB(Q) || typeof Q == "string" || IQ(Q) ? Q : null;
6052
6052
  if (!C) continue;
6053
- const E = await yi(C), i = bA(E);
6053
+ const E = await yi(C), o = bA(E);
6054
6054
  I.set(String(g.srcId), {
6055
6055
  source: E,
6056
- width: Math.max(1, i.width),
6057
- height: Math.max(1, i.height)
6056
+ width: Math.max(1, o.width),
6057
+ height: Math.max(1, o.height)
6058
6058
  });
6059
6059
  }
6060
6060
  return I;
@@ -6064,8 +6064,8 @@ function Ni(B) {
6064
6064
  const I = /* @__PURE__ */ new Map();
6065
6065
  for (const g of (A = B.frame) != null ? A : []) {
6066
6066
  const Q = [...g.obj].sort((C, E) => {
6067
- var i, o;
6068
- return ((i = C.z) != null ? i : 0) - ((o = E.z) != null ? o : 0);
6067
+ var o, i;
6068
+ return ((o = C.z) != null ? o : 0) - ((i = E.z) != null ? i : 0);
6069
6069
  });
6070
6070
  I.set(g.i, Q);
6071
6071
  }
@@ -6086,13 +6086,13 @@ function iB(B, A, I, g) {
6086
6086
  var Q, C;
6087
6087
  if (!B.compositeCanvas || !B.compositeCtx || !B.rawCanvas || !B.rawCtx || !B.scratchCanvas || !B.scratchCtx)
6088
6088
  throw new Error("VAP CPU compositor state is incomplete");
6089
- const { info: E } = A, i = E.videoW || B.width, o = E.videoH || B.height, [e, a, t, s] = E.rgbFrame, [D, w, h, n] = E.aFrame;
6090
- (B.rawCanvas.width !== i || B.rawCanvas.height !== o) && (B.rawCanvas.width = i, B.rawCanvas.height = o), B.rawCtx.clearRect(0, 0, i, o), B.rawCtx.drawImage(I, 0, 0, i, o);
6091
- const r = B.rawCtx.getImageData(0, 0, i, o).data, F = B.compositeCtx.createImageData(B.width, B.height), c = F.data;
6089
+ const { info: E } = A, o = E.videoW || B.width, i = E.videoH || B.height, [e, a, t, s] = E.rgbFrame, [D, w, h, n] = E.aFrame;
6090
+ (B.rawCanvas.width !== o || B.rawCanvas.height !== i) && (B.rawCanvas.width = o, B.rawCanvas.height = i), B.rawCtx.clearRect(0, 0, o, i), B.rawCtx.drawImage(I, 0, 0, o, i);
6091
+ const r = B.rawCtx.getImageData(0, 0, o, i).data, F = B.compositeCtx.createImageData(B.width, B.height), c = F.data;
6092
6092
  for (let y = 0; y < B.height; y++) {
6093
- const M = Math.min(o - 1, Math.max(0, a + Math.floor(y / B.height * s))), R = Math.min(o - 1, Math.max(0, w + Math.floor(y / B.height * n)));
6093
+ const M = Math.min(i - 1, Math.max(0, a + Math.floor(y / B.height * s))), R = Math.min(i - 1, Math.max(0, w + Math.floor(y / B.height * n)));
6094
6094
  for (let N = 0; N < B.width; N++) {
6095
- const S = Math.min(i - 1, Math.max(0, e + Math.floor(N / B.width * t))), U = Math.min(i - 1, Math.max(0, D + Math.floor(N / B.width * h))), K = (M * i + S) * 4, d = (R * i + U) * 4, l = r[d] / 255, J = (y * B.width + N) * 4;
6095
+ const S = Math.min(o - 1, Math.max(0, e + Math.floor(N / B.width * t))), U = Math.min(o - 1, Math.max(0, D + Math.floor(N / B.width * h))), K = (M * o + S) * 4, d = (R * o + U) * 4, l = r[d] / 255, J = (y * B.width + N) * 4;
6096
6096
  c[J] = Math.round(r[K] * l), c[J + 1] = Math.round(r[K + 1] * l), c[J + 2] = Math.round(r[K + 2] * l), c[J + 3] = Math.round(l * 255);
6097
6097
  }
6098
6098
  }
@@ -6108,12 +6108,12 @@ function iB(B, A, I, g) {
6108
6108
  const RQ = Math.min(
6109
6109
  B.scratchCanvas.height - 1,
6110
6110
  Math.max(0, Math.floor((GA - N) / U * B.scratchCanvas.height))
6111
- ), yQ = Math.min(o - 1, Math.max(0, d + Math.floor((GA - N) / U * J)));
6111
+ ), yQ = Math.min(i - 1, Math.max(0, d + Math.floor((GA - N) / U * J)));
6112
6112
  for (let VA = u; VA < W; VA++) {
6113
6113
  const MQ = Math.min(
6114
6114
  B.scratchCanvas.width - 1,
6115
6115
  Math.max(0, Math.floor((VA - R) / S * B.scratchCanvas.width))
6116
- ), NQ = Math.min(i - 1, Math.max(0, K + Math.floor((VA - R) / S * l))), yI = (RQ * B.scratchCanvas.width + MQ) * 4, SQ = (yQ * i + NQ) * 4, kQ = q[yI + 3] / 255, UQ = r[SQ] / 255, JA = kQ * UQ;
6116
+ ), NQ = Math.min(o - 1, Math.max(0, K + Math.floor((VA - R) / S * l))), yI = (RQ * B.scratchCanvas.width + MQ) * 4, SQ = (yQ * o + NQ) * 4, kQ = q[yI + 3] / 255, UQ = r[SQ] / 255, JA = kQ * UQ;
6117
6117
  if (JA <= 0) continue;
6118
6118
  const RA = (GA * B.width + VA) * 4, lQ = q[yI] / 255 * JA, YQ = q[yI + 1] / 255 * JA, KQ = q[yI + 2] / 255 * JA, dQ = c[RA + 3] / 255, MI = 1 - JA;
6119
6119
  c[RA] = Math.round((lQ + c[RA] / 255 * MI) * 255), c[RA + 1] = Math.round((YQ + c[RA + 1] / 255 * MI) * 255), c[RA + 2] = Math.round((KQ + c[RA + 2] / 255 * MI) * 255), c[RA + 3] = Math.round((JA + dQ * MI) * 255);
@@ -6133,13 +6133,13 @@ const ag = 1024, oB = 32, RI = class nA {
6133
6133
  */
6134
6134
  syncVideoTextures(A, I) {
6135
6135
  var g, Q, C, E;
6136
- let i = !1;
6137
- const o = this.processedHtmlGatesScratch;
6138
- o.clear();
6136
+ let o = !1;
6137
+ const i = this.processedHtmlGatesScratch;
6138
+ i.clear();
6139
6139
  for (const e of I.values()) {
6140
6140
  if (e.type !== "vap" || e.paused || e.state !== "playing" && e.state !== "fly" && e.state !== "stopped" || !e.videoTextureHandle) continue;
6141
6141
  if (((g = e.vapMixState) == null ? void 0 : g.mode) === "composited") {
6142
- i = this.syncMixedTexture(A, e) || i;
6142
+ o = this.syncMixedTexture(A, e) || o;
6143
6143
  continue;
6144
6144
  }
6145
6145
  const a = e.webcodecsPlayback;
@@ -6162,7 +6162,7 @@ const ag = 1024, oB = 32, RI = class nA {
6162
6162
  h.y,
6163
6163
  h.w,
6164
6164
  h.h
6165
- ) : A.updateTexture(e.videoTextureHandle, s), D ? D.lastUploadedFrame = s : this.lastWcFrameRef.set(e.id, s), i = !0;
6165
+ ) : A.updateTexture(e.videoTextureHandle, s), D ? D.lastUploadedFrame = s : this.lastWcFrameRef.set(e.id, s), o = !0;
6166
6166
  }
6167
6167
  } else {
6168
6168
  const D = ((C = this.wcDbgNullWarns.get(e.id)) != null ? C : 0) + 1;
@@ -6170,11 +6170,11 @@ const ag = 1024, oB = 32, RI = class nA {
6170
6170
  }
6171
6171
  } else if (e.videoElement) {
6172
6172
  const t = this.getHtmlVideoGateId(e);
6173
- if (o.has(t)) continue;
6174
- o.add(t), this.htmlGate.preUpload(t, e.videoElement) && (A.updateTexture(e.videoTextureHandle, e.videoElement), i = !0);
6173
+ if (i.has(t)) continue;
6174
+ i.add(t), this.htmlGate.preUpload(t, e.videoElement) && (A.updateTexture(e.videoTextureHandle, e.videoElement), o = !0);
6175
6175
  }
6176
6176
  }
6177
- return i;
6177
+ return o;
6178
6178
  }
6179
6179
  draw(A, I) {
6180
6180
  (A.type === "webgpu" || A.type === "webgl2") && this.drawInstancedVapBatches(A, I);
@@ -6208,25 +6208,25 @@ const ag = 1024, oB = 32, RI = class nA {
6208
6208
  const Q = A.canvas.width, C = A.canvas.height;
6209
6209
  let E;
6210
6210
  this.projCache && this.projCacheW === Q && this.projCacheH === C ? E = this.projCache : (this.projCacheW = Q, this.projCacheH = C, this.projCache = HA(0, Q, C, 0, -1, 1), E = this.projCache);
6211
- const i = /* @__PURE__ */ new Map();
6211
+ const o = /* @__PURE__ */ new Map();
6212
6212
  for (const e of g) {
6213
6213
  const a = e.videoTextureHandle.id;
6214
- let t = i.get(a);
6215
- t || (t = [], i.set(a, t)), t.push(e);
6214
+ let t = o.get(a);
6215
+ t || (t = [], o.set(a, t)), t.push(e);
6216
6216
  }
6217
- const o = this.instancePackScratch;
6218
- for (const e of i.values())
6217
+ const i = this.instancePackScratch;
6218
+ for (const e of o.values())
6219
6219
  for (let a = 0; a < e.length; a += ag) {
6220
6220
  const t = Math.min(ag, e.length - a);
6221
6221
  for (let s = 0; s < t; s++)
6222
- this.fillVapInstanceData(e[a + s], o, s * oB);
6222
+ this.fillVapInstanceData(e[a + s], i, s * oB);
6223
6223
  A.draw({
6224
6224
  shader: "vap-instanced",
6225
6225
  vertexBuffer: this.instancedQuadVB,
6226
6226
  indexBuffer: this.instancedQuadIB,
6227
6227
  indexCount: 6,
6228
6228
  instanceCount: t,
6229
- instanceData: o,
6229
+ instanceData: i,
6230
6230
  textures: [e[a].videoTextureHandle],
6231
6231
  uniforms: {
6232
6232
  u_projection: E,
@@ -6237,8 +6237,8 @@ const ag = 1024, oB = 32, RI = class nA {
6237
6237
  }
6238
6238
  /** mat4 + atlasRemap + rgb/alpha UV rects (`computeVAPUV` order). */
6239
6239
  fillVapInstanceData(A, I, g) {
6240
- var Q, C, E, i;
6241
- const o = A.vapConfig, { info: e } = o, a = e.videoW > 0 ? e.videoW : (C = (Q = A.webcodecsPlayback) == null ? void 0 : Q.videoWidth) != null ? C : 1, t = e.videoH > 0 ? e.videoH : (i = (E = A.webcodecsPlayback) == null ? void 0 : E.videoHeight) != null ? i : 1, s = this.scratchTransform, { w: D, h: w } = dA(e), h = KA(A, D, w);
6240
+ var Q, C, E, o;
6241
+ const i = A.vapConfig, { info: e } = i, a = e.videoW > 0 ? e.videoW : (C = (Q = A.webcodecsPlayback) == null ? void 0 : Q.videoWidth) != null ? C : 1, t = e.videoH > 0 ? e.videoH : (o = (E = A.webcodecsPlayback) == null ? void 0 : E.videoHeight) != null ? o : 1, s = this.scratchTransform, { w: D, h: w } = dA(e), h = KA(A, D, w);
6242
6242
  s[0] = h.width, s[5] = h.height, s[10] = 1, s[12] = A.x + h.offsetX, s[13] = A.y + h.offsetY, s[15] = 1, I.set(s, g);
6243
6243
  const n = XA(e.rgbFrame, a, t), r = XA(e.aFrame, a, t), F = A.videoTextureHandle, c = pI(F.width, F.height, A.wcAtlasRect, this.scratchAtlasRemap);
6244
6244
  I.set(c, g + 16);
@@ -6250,17 +6250,17 @@ const ag = 1024, oB = 32, RI = class nA {
6250
6250
  const Q = I.vapConfig, C = I.vapMixState;
6251
6251
  if (!Q || !C || C.mode !== "composited" || !I.videoTextureHandle)
6252
6252
  return !1;
6253
- const E = this.getMixedFrameIndex(I, Q), i = I.webcodecsPlayback;
6254
- if (i) {
6255
- const e = (g = I.wcPlaybackTime) != null ? g : 0, a = i.getFrameForTime(e);
6253
+ const E = this.getMixedFrameIndex(I, Q), o = I.webcodecsPlayback;
6254
+ if (o) {
6255
+ const e = (g = I.wcPlaybackTime) != null ? g : 0, a = o.getFrameForTime(e);
6256
6256
  if (!a || C.lastSourceRef === a && C.lastFrameIndex === E) return !1;
6257
6257
  const t = C.composer ? C.composer.render(a, E) : iB(C, Q, a, E);
6258
6258
  return A.updateTexture(I.videoTextureHandle, t), C.lastSourceRef = a, C.lastFrameIndex = E, !0;
6259
6259
  }
6260
6260
  if (!I.videoElement || !this.htmlGate.preUpload(I.id, I.videoElement) && C.lastFrameIndex === E)
6261
6261
  return !1;
6262
- const o = C.composer ? C.composer.render(I.videoElement, E) : iB(C, Q, I.videoElement, E);
6263
- return A.updateTexture(I.videoTextureHandle, o), C.lastSourceRef = I.videoElement, C.lastFrameIndex = E, !0;
6262
+ const i = C.composer ? C.composer.render(I.videoElement, E) : iB(C, Q, I.videoElement, E);
6263
+ return A.updateTexture(I.videoTextureHandle, i), C.lastSourceRef = I.videoElement, C.lastFrameIndex = E, !0;
6264
6264
  }
6265
6265
  releaseHtmlVideo(A) {
6266
6266
  var I;
@@ -6271,9 +6271,9 @@ const ag = 1024, oB = 32, RI = class nA {
6271
6271
  }
6272
6272
  drawGeometry(A, I) {
6273
6273
  var g, Q, C, E;
6274
- const i = A.canvas.width, o = A.canvas.height;
6274
+ const o = A.canvas.width, i = A.canvas.height;
6275
6275
  let e;
6276
- this.projCache && this.projCacheW === i && this.projCacheH === o ? e = this.projCache : (this.projCacheW = i, this.projCacheH = o, this.projCache = HA(0, i, o, 0, -1, 1), e = this.projCache);
6276
+ this.projCache && this.projCacheW === o && this.projCacheH === i ? e = this.projCache : (this.projCacheW = o, this.projCacheH = i, this.projCache = HA(0, o, i, 0, -1, 1), e = this.projCache);
6277
6277
  const a = I.vapConfig;
6278
6278
  if (!a) {
6279
6279
  console.warn("[GiftStage:WC] VAP vapConfig missing — draw skipped", { giftId: I.id });
@@ -6306,14 +6306,14 @@ const ag = 1024, oB = 32, RI = class nA {
6306
6306
  const E = I.vapConfig;
6307
6307
  if (!E || !I.vapMixState || I.vapMixState.mode !== "composited" || !I.videoTextureHandle)
6308
6308
  return;
6309
- const i = this.scratchTransform, o = DA(I), { w: e, h: a } = dA(E.info), t = KA(I, e, a);
6310
- i[0] = t.width, i[5] = t.height, i[10] = 1, i[12] = I.x + t.offsetX, i[13] = I.y + t.offsetY, i[15] = 1;
6309
+ const o = this.scratchTransform, i = DA(I), { w: e, h: a } = dA(E.info), t = KA(I, e, a);
6310
+ o[0] = t.width, o[5] = t.height, o[10] = 1, o[12] = I.x + t.offsetX, o[13] = I.y + t.offsetY, o[15] = 1;
6311
6311
  const s = !!I.vapMixState.composer || A.type === "webgpu";
6312
6312
  let D = s ? this.rgbaTopLeftQuadVB : this.rgbaWebGLQuadVB;
6313
6313
  D || (D = A.createBuffer(
6314
6314
  s ? nA.RGBA_QUAD_VERTS_WEBGPU : nA.RGBA_QUAD_VERTS_WEBGL,
6315
6315
  "vertex"
6316
- ), s ? this.rgbaTopLeftQuadVB = D : this.rgbaWebGLQuadVB = D), this.rgbaQuadIB || (this.rgbaQuadIB = A.createBuffer(nA.QUAD_INDICES, "index")), o === "cover" && A.setScissor(I.x, I.y, I.width * I.scale, I.height * I.scale), A.draw({
6316
+ ), s ? this.rgbaTopLeftQuadVB = D : this.rgbaWebGLQuadVB = D), this.rgbaQuadIB || (this.rgbaQuadIB = A.createBuffer(nA.QUAD_INDICES, "index")), i === "cover" && A.setScissor(I.x, I.y, I.width * I.scale, I.height * I.scale), A.draw({
6317
6317
  shader: "rgba-textured",
6318
6318
  vertexBuffer: D,
6319
6319
  indexBuffer: this.rgbaQuadIB,
@@ -6321,12 +6321,12 @@ const ag = 1024, oB = 32, RI = class nA {
6321
6321
  textures: [I.videoTextureHandle],
6322
6322
  uniforms: {
6323
6323
  u_projection: C,
6324
- u_transform: i,
6324
+ u_transform: o,
6325
6325
  u_atlasRemap: ii,
6326
6326
  u_opacity: I.opacity,
6327
6327
  u_video: 0
6328
6328
  }
6329
- }), o === "cover" && A.resetScissor();
6329
+ }), i === "cover" && A.resetScissor();
6330
6330
  }
6331
6331
  drawMixedDirectGeometry(A, I) {
6332
6332
  const g = I.vapConfig, Q = I.vapMixState, C = I.videoTextureHandle;
@@ -6335,9 +6335,9 @@ const ag = 1024, oB = 32, RI = class nA {
6335
6335
  this.drawGeometry(A, I);
6336
6336
  const E = Q.frameMap.get(this.getMixedFrameIndex(I, g));
6337
6337
  if (!E || E.length === 0) return;
6338
- const i = A.canvas.width, o = A.canvas.height;
6338
+ const o = A.canvas.width, i = A.canvas.height;
6339
6339
  let e;
6340
- this.projCache && this.projCacheW === i && this.projCacheH === o ? e = this.projCache : (this.projCacheW = i, this.projCacheH = o, this.projCache = HA(0, i, o, 0, -1, 1), e = this.projCache), this.rgbaTopLeftQuadVB || (this.rgbaTopLeftQuadVB = A.createBuffer(
6340
+ this.projCache && this.projCacheW === o && this.projCacheH === i ? e = this.projCache : (this.projCacheW = o, this.projCacheH = i, this.projCache = HA(0, o, i, 0, -1, 1), e = this.projCache), this.rgbaTopLeftQuadVB || (this.rgbaTopLeftQuadVB = A.createBuffer(
6341
6341
  nA.RGBA_QUAD_VERTS_WEBGPU,
6342
6342
  "vertex"
6343
6343
  )), this.rgbaQuadIB || (this.rgbaQuadIB = A.createBuffer(nA.QUAD_INDICES, "index"));
@@ -6384,8 +6384,8 @@ const ag = 1024, oB = 32, RI = class nA {
6384
6384
  var g, Q, C;
6385
6385
  if (A.webcodecsPlayback)
6386
6386
  return Math.max(0, Math.round(((g = A.wcPlaybackTime) != null ? g : 0) * I.info.fps));
6387
- const E = this.htmlGate.getFrameInfo(A.id), i = E == null ? void 0 : E.mediaTime;
6388
- return typeof i == "number" && Number.isFinite(i) && i >= 0 ? Math.max(0, Math.round(i * I.info.fps)) : Math.max(0, Math.round(((C = (Q = A.videoElement) == null ? void 0 : Q.currentTime) != null ? C : 0) * I.info.fps));
6387
+ const E = this.htmlGate.getFrameInfo(A.id), o = E == null ? void 0 : E.mediaTime;
6388
+ return typeof o == "number" && Number.isFinite(o) && o >= 0 ? Math.max(0, Math.round(o * I.info.fps)) : Math.max(0, Math.round(((C = (Q = A.videoElement) == null ? void 0 : Q.currentTime) != null ? C : 0) * I.info.fps));
6389
6389
  }
6390
6390
  getHtmlVideoGateId(A) {
6391
6391
  return A.releaseSharedVideoTexture && A.videoTextureHandle ? `shared:${A.videoTextureHandle.id}` : A.id;
@@ -6486,8 +6486,8 @@ const eB = 1024, aB = 12, qg = class II {
6486
6486
  }
6487
6487
  static alphaVideoContentSize(A, I) {
6488
6488
  if (A.webcodecsPlayback) {
6489
- const E = A.webcodecsPlayback.videoWidth, i = A.webcodecsPlayback.videoHeight;
6490
- return I.w = E > 0 ? E * 0.5 : 0, I.h = i, I;
6489
+ const E = A.webcodecsPlayback.videoWidth, o = A.webcodecsPlayback.videoHeight;
6490
+ return I.w = E > 0 ? E * 0.5 : 0, I.h = o, I;
6491
6491
  }
6492
6492
  const g = A.videoElement, Q = g.videoWidth, C = g.videoHeight;
6493
6493
  return I.w = Q > 0 ? Q * 0.5 : 0, I.h = C, I;
@@ -6495,44 +6495,44 @@ const eB = 1024, aB = 12, qg = class II {
6495
6495
  syncVideoTextures(A, I) {
6496
6496
  var g, Q, C;
6497
6497
  let E = !1;
6498
- const i = this.processedHtmlGatesScratch;
6499
- i.clear();
6500
- for (const o of I.values()) {
6501
- if (o.type !== "alphaVideo" || o.paused || o.state !== "playing" && o.state !== "fly" || !o.videoTextureHandle) continue;
6502
- const e = o.webcodecsPlayback;
6498
+ const o = this.processedHtmlGatesScratch;
6499
+ o.clear();
6500
+ for (const i of I.values()) {
6501
+ if (i.type !== "alphaVideo" || i.paused || i.state !== "playing" && i.state !== "fly" || !i.videoTextureHandle) continue;
6502
+ const e = i.webcodecsPlayback;
6503
6503
  if (e) {
6504
- const a = (g = o.wcPlaybackTime) != null ? g : 0, t = e.getFrameForTime(a);
6505
- if (this.wcDbgFirstDraw.has(o.id) || (this.wcDbgFirstDraw.add(o.id), console.info("[GiftStage:WC] alphaVideo first draw", {
6506
- giftId: o.id,
6507
- state: o.state,
6504
+ const a = (g = i.wcPlaybackTime) != null ? g : 0, t = e.getFrameForTime(a);
6505
+ if (this.wcDbgFirstDraw.has(i.id) || (this.wcDbgFirstDraw.add(i.id), console.info("[GiftStage:WC] alphaVideo first draw", {
6506
+ giftId: i.id,
6507
+ state: i.state,
6508
6508
  t: a,
6509
6509
  hasFrame: !!t,
6510
6510
  canvasBuf: `${A.canvas.width}x${A.canvas.height}`
6511
6511
  })), t) {
6512
- const s = o.webcodecsSurface;
6513
- if (((C = s == null ? void 0 : s.lastUploadedFrame) != null ? C : this.lastWcFrameRef.get(o.id)) !== t) {
6514
- const w = o.wcAtlasRect;
6512
+ const s = i.webcodecsSurface;
6513
+ if (((C = s == null ? void 0 : s.lastUploadedFrame) != null ? C : this.lastWcFrameRef.get(i.id)) !== t) {
6514
+ const w = i.wcAtlasRect;
6515
6515
  w ? A.updateTextureRegion(
6516
- o.videoTextureHandle,
6516
+ i.videoTextureHandle,
6517
6517
  t,
6518
6518
  w.x,
6519
6519
  w.y,
6520
6520
  w.w,
6521
6521
  w.h
6522
- ) : A.updateTexture(o.videoTextureHandle, t), s ? s.lastUploadedFrame = t : this.lastWcFrameRef.set(o.id, t), E = !0;
6522
+ ) : A.updateTexture(i.videoTextureHandle, t), s ? s.lastUploadedFrame = t : this.lastWcFrameRef.set(i.id, t), E = !0;
6523
6523
  }
6524
6524
  } else {
6525
- const s = ((Q = this.wcDbgNullWarns.get(o.id)) != null ? Q : 0) + 1;
6526
- this.wcDbgNullWarns.set(o.id, s), s <= 5 && console.warn("[GiftStage:WC] alphaVideo getFrameForTime null", {
6527
- giftId: o.id,
6525
+ const s = ((Q = this.wcDbgNullWarns.get(i.id)) != null ? Q : 0) + 1;
6526
+ this.wcDbgNullWarns.set(i.id, s), s <= 5 && console.warn("[GiftStage:WC] alphaVideo getFrameForTime null", {
6527
+ giftId: i.id,
6528
6528
  t: a,
6529
6529
  n: s
6530
6530
  });
6531
6531
  }
6532
- } else if (o.videoElement) {
6533
- const a = this.getHtmlVideoGateId(o);
6534
- if (i.has(a)) continue;
6535
- i.add(a), this.htmlGate.preUpload(a, o.videoElement) && (A.updateTexture(o.videoTextureHandle, o.videoElement), E = !0);
6532
+ } else if (i.videoElement) {
6533
+ const a = this.getHtmlVideoGateId(i);
6534
+ if (o.has(a)) continue;
6535
+ o.add(a), this.htmlGate.preUpload(a, i.videoElement) && (A.updateTexture(i.videoTextureHandle, i.videoElement), E = !0);
6536
6536
  }
6537
6537
  }
6538
6538
  return E;
@@ -6557,14 +6557,14 @@ const eB = 1024, aB = 12, qg = class II {
6557
6557
  drawInstancedAlphaBatches(A, I) {
6558
6558
  let g = null, Q = 0, C = null;
6559
6559
  const E = this.instancePackScratch;
6560
- for (const i of I.values()) {
6561
- if (i.type !== "alphaVideo" || i.state !== "playing" && i.state !== "fly" && i.state !== "stopped" || !i.videoElement && !i.webcodecsPlayback || !i.videoTextureHandle) continue;
6562
- if (DA(i) === "cover") {
6563
- g && Q > 0 && C && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0), this.drawGeometry(A, i);
6560
+ for (const o of I.values()) {
6561
+ if (o.type !== "alphaVideo" || o.state !== "playing" && o.state !== "fly" && o.state !== "stopped" || !o.videoElement && !o.webcodecsPlayback || !o.videoTextureHandle) continue;
6562
+ if (DA(o) === "cover") {
6563
+ g && Q > 0 && C && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0), this.drawGeometry(A, o);
6564
6564
  continue;
6565
6565
  }
6566
- const o = i.videoTextureHandle;
6567
- g && g.id !== o.id && Q > 0 && C && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0), g || (this.ensureQuadBuffers(A), C = this.getProjection(A), g = o), this.fillAlphaInstanceData(i, E, Q * aB), Q++, Q === eB && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0);
6566
+ const i = o.videoTextureHandle;
6567
+ g && g.id !== i.id && Q > 0 && C && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0), g || (this.ensureQuadBuffers(A), C = this.getProjection(A), g = i), this.fillAlphaInstanceData(o, E, Q * aB), Q++, Q === eB && (this.flushInstancedBatch(A, g, Q, C), g = null, Q = 0);
6568
6568
  }
6569
6569
  g && Q > 0 && C && this.flushInstancedBatch(A, g, Q, C);
6570
6570
  }
@@ -6576,8 +6576,8 @@ const eB = 1024, aB = 12, qg = class II {
6576
6576
  fillAlphaInstanceData(A, I, g) {
6577
6577
  const Q = II.alphaVideoContentSize(A, this.contentSizeScratch), C = KA(A, Q.w, Q.h, this.layoutScratch);
6578
6578
  I[g + 0] = A.x + C.offsetX, I[g + 1] = A.y + C.offsetY, I[g + 2] = C.width, I[g + 3] = C.height;
6579
- const E = A.videoTextureHandle, i = pI(E.width, E.height, A.wcAtlasRect, this.scratchAtlasRemap);
6580
- I.set(i, g + 4), I[g + 8] = A.opacity, I[g + 9] = 0, I[g + 10] = 0, I[g + 11] = 0;
6579
+ const E = A.videoTextureHandle, o = pI(E.width, E.height, A.wcAtlasRect, this.scratchAtlasRemap);
6580
+ I.set(o, g + 4), I[g + 8] = A.opacity, I[g + 9] = 0, I[g + 10] = 0, I[g + 11] = 0;
6581
6581
  }
6582
6582
  releaseHtmlVideo(A) {
6583
6583
  var I;
@@ -6590,10 +6590,10 @@ const eB = 1024, aB = 12, qg = class II {
6590
6590
  return A.releaseSharedVideoTexture && A.videoTextureHandle ? `shared:${A.videoTextureHandle.id}` : A.id;
6591
6591
  }
6592
6592
  drawGeometry(A, I) {
6593
- const g = this.getProjection(A), Q = this.scratchTransform, C = DA(I), E = II.alphaVideoContentSize(I, this.contentSizeScratch), i = KA(I, E.w, E.h, this.layoutScratch);
6594
- Q[0] = i.width, Q[5] = i.height, Q[10] = 1, Q[12] = I.x + i.offsetX, Q[13] = I.y + i.offsetY, Q[15] = 1, this.ensureQuadBuffers(A);
6595
- const o = I.videoTextureHandle, e = pI(o.width, o.height, I.wcAtlasRect, this.scratchAtlasRemap), a = this.geometryDrawCommand;
6596
- a.vertexBuffer = this.quadVB, a.indexBuffer = this.quadIB, this.geometryTexturesScratch[0] = o, this.geometryTexturesScratch.length = 1, this.geometryUniformsScratch.u_projection = g, this.geometryUniformsScratch.u_transform = Q, this.geometryUniformsScratch.u_atlasRemap = e, this.geometryUniformsScratch.u_opacity = I.opacity, C === "cover" && A.setScissor(I.x, I.y, I.width * I.scale, I.height * I.scale), A.draw(a), C === "cover" && A.resetScissor();
6593
+ const g = this.getProjection(A), Q = this.scratchTransform, C = DA(I), E = II.alphaVideoContentSize(I, this.contentSizeScratch), o = KA(I, E.w, E.h, this.layoutScratch);
6594
+ Q[0] = o.width, Q[5] = o.height, Q[10] = 1, Q[12] = I.x + o.offsetX, Q[13] = I.y + o.offsetY, Q[15] = 1, this.ensureQuadBuffers(A);
6595
+ const i = I.videoTextureHandle, e = pI(i.width, i.height, I.wcAtlasRect, this.scratchAtlasRemap), a = this.geometryDrawCommand;
6596
+ a.vertexBuffer = this.quadVB, a.indexBuffer = this.quadIB, this.geometryTexturesScratch[0] = i, this.geometryTexturesScratch.length = 1, this.geometryUniformsScratch.u_projection = g, this.geometryUniformsScratch.u_transform = Q, this.geometryUniformsScratch.u_atlasRemap = e, this.geometryUniformsScratch.u_opacity = I.opacity, C === "cover" && A.setScissor(I.x, I.y, I.width * I.scale, I.height * I.scale), A.draw(a), C === "cover" && A.resetScissor();
6597
6597
  }
6598
6598
  ensureQuadBuffers(A) {
6599
6599
  this.quadVB || (this.quadVB = A.createBuffer(II.QUAD_VERTS, "vertex"), this.quadIB = A.createBuffer(II.QUAD_INDICES, "index"));
@@ -6631,10 +6631,10 @@ class fi {
6631
6631
  constructor() {
6632
6632
  tB(this, "animations", /* @__PURE__ */ new Map()), tB(this, "completedScratch", []);
6633
6633
  }
6634
- startFly(A, I, g, Q, C, E, i, o = A.opacity) {
6635
- this.startTween(A, I, g, Q, C, E, i, void 0, o);
6634
+ startFly(A, I, g, Q, C, E, o, i = A.opacity) {
6635
+ this.startTween(A, I, g, Q, C, E, o, void 0, i);
6636
6636
  }
6637
- startTween(A, I, g, Q, C, E, i, o, e = A.opacity) {
6637
+ startTween(A, I, g, Q, C, E, o, i, e = A.opacity) {
6638
6638
  this.cancelForGift(A.id), this.animations.set(A.id, {
6639
6639
  giftId: A.id,
6640
6640
  startX: A.x,
@@ -6649,11 +6649,11 @@ class fi {
6649
6649
  // set on first update
6650
6650
  duration: C,
6651
6651
  easing: E,
6652
- onComplete: i,
6653
- onCancel: o
6652
+ onComplete: o,
6653
+ onCancel: i
6654
6654
  });
6655
6655
  }
6656
- startTweenPromise(A, I, g, Q, C, E, i, o = A.opacity) {
6656
+ startTweenPromise(A, I, g, Q, C, E, o, i = A.opacity) {
6657
6657
  return new Promise((e) => {
6658
6658
  this.startTween(
6659
6659
  A,
@@ -6663,10 +6663,10 @@ class fi {
6663
6663
  C,
6664
6664
  E,
6665
6665
  () => {
6666
- i == null || i(), e();
6666
+ o == null || o(), e();
6667
6667
  },
6668
6668
  e,
6669
- o
6669
+ i
6670
6670
  );
6671
6671
  });
6672
6672
  }
@@ -6687,8 +6687,8 @@ class fi {
6687
6687
  E.duration,
6688
6688
  E.easing,
6689
6689
  () => {
6690
- var i;
6691
- (i = E.onComplete) == null || i.call(E), C();
6690
+ var o;
6691
+ (o = E.onComplete) == null || o.call(E), C();
6692
6692
  },
6693
6693
  void 0,
6694
6694
  E.targetOpacity
@@ -6789,10 +6789,10 @@ class qi {
6789
6789
  const C = this.ensureContext(), E = C.createBufferSource();
6790
6790
  E.buffer = Q, E.connect((g = this.gainNode) != null ? g : C.destination), E.start(0, I.startTime / 1e3), E.onended = () => {
6791
6791
  E.disconnect();
6792
- const i = this.activeSources.findIndex(
6793
- (o) => o.source === E && o.giftId === A
6792
+ const o = this.activeSources.findIndex(
6793
+ (i) => i.source === E && i.giftId === A
6794
6794
  );
6795
- i >= 0 && this.activeSources.splice(i, 1);
6795
+ o >= 0 && this.activeSources.splice(o, 1);
6796
6796
  }, this.activeSources.push({ source: E, endFrame: I.endFrame, giftId: A });
6797
6797
  }
6798
6798
  stopAllForGift(A) {
@@ -6873,7 +6873,7 @@ class Zi {
6873
6873
  this.slots.set(A.id, A), this.handles.set(A.id, I), this.forceNextDraw = !0, this.running || this.start();
6874
6874
  }
6875
6875
  releaseSlotResources(A) {
6876
- var I, g, Q, C, E, i, o, e, a;
6876
+ var I, g, Q, C, E, o, i, e, a;
6877
6877
  if ((I = A.loadAbortController) == null || I.abort(), A.loadAbortController = null, this.wcDbgTickOnce.delete(A.id), A.type === "vap" && (this.vapRenderer.releaseHtmlVideo(A), this.vapRenderer.clearWebCodecsFrameRef(A.id), (Q = (g = A.vapMixState) == null ? void 0 : g.composer) == null || Q.destroy(), (C = A.vapMixState) != null && C.resourceTextures)) {
6878
6878
  for (const t of A.vapMixState.resourceTextures.values())
6879
6879
  this.backend.deleteTexture(t);
@@ -6884,7 +6884,7 @@ class Zi {
6884
6884
  this.backend.deleteTexture(t.texture);
6885
6885
  A.svgaSlotTextures.clear(), A.svgaSlotTextures = void 0;
6886
6886
  }
6887
- A.wcAtlasRect && !A.releaseWebCodecsSurface ? (this.releaseWebCodecsAtlasAllocation(A.id), A.wcAtlasRect = void 0) : A.videoTextureHandle && !A.releaseSharedVideoTexture && !A.releaseWebCodecsSurface && this.backend.deleteTexture(A.videoTextureHandle), A.videoTextureHandle = null, (E = A.releaseWebCodecsSurface) == null || E.call(A), A.releaseWebCodecsSurface = null, A.webcodecsSurface = null, A.wcAtlasRect = void 0, A.webcodecsPlayback && (A.releaseWebCodecsPlayback ? A.releaseWebCodecsPlayback() : A.webcodecsPlayback.destroy(), A.webcodecsPlayback = null), A.releaseWebCodecsPlayback = null, A.webcodecsSharedState = null, A.videoElement && !A.releaseSharedVideoPlayback && (A.videoElement.pause(), A.videoElement.removeAttribute("src"), A.videoElement.load(), A.videoElement.remove()), A.videoElement = null, (i = A.releaseSharedVideoPlayback) == null || i.call(A), A.releaseSharedVideoPlayback = null, (o = A.releaseSharedSVGAAsset) == null || o.call(A), A.releaseSharedSVGAAsset = null, (e = A.releaseSharedVideoTexture) == null || e.call(A), A.releaseSharedVideoTexture = null, (a = A.releaseMediaSource) == null || a.call(A), A.releaseMediaSource = null, A.vapMixState = null, A.videoEntity = null;
6887
+ A.wcAtlasRect && !A.releaseWebCodecsSurface ? (this.releaseWebCodecsAtlasAllocation(A.id), A.wcAtlasRect = void 0) : A.videoTextureHandle && !A.releaseSharedVideoTexture && !A.releaseWebCodecsSurface && this.backend.deleteTexture(A.videoTextureHandle), A.videoTextureHandle = null, (E = A.releaseWebCodecsSurface) == null || E.call(A), A.releaseWebCodecsSurface = null, A.webcodecsSurface = null, A.wcAtlasRect = void 0, A.webcodecsPlayback && (A.releaseWebCodecsPlayback ? A.releaseWebCodecsPlayback() : A.webcodecsPlayback.destroy(), A.webcodecsPlayback = null), A.releaseWebCodecsPlayback = null, A.webcodecsSharedState = null, A.videoElement && !A.releaseSharedVideoPlayback && (A.videoElement.pause(), A.videoElement.removeAttribute("src"), A.videoElement.load(), A.videoElement.remove()), A.videoElement = null, (o = A.releaseSharedVideoPlayback) == null || o.call(A), A.releaseSharedVideoPlayback = null, (i = A.releaseSharedSVGAAsset) == null || i.call(A), A.releaseSharedSVGAAsset = null, (e = A.releaseSharedVideoTexture) == null || e.call(A), A.releaseSharedVideoTexture = null, (a = A.releaseMediaSource) == null || a.call(A), A.releaseMediaSource = null, A.vapMixState = null, A.videoEntity = null;
6888
6888
  }
6889
6889
  removeSlot(A) {
6890
6890
  const I = this.slots.get(A);
@@ -6970,20 +6970,20 @@ class Zi {
6970
6970
  this.lastTime = A;
6971
6971
  let E = this.forceNextDraw;
6972
6972
  this.advancedSharedWebCodecsScratch.clear(), this.activeSharedWebCodecsScratch.clear();
6973
- for (const i of this.slots.values())
6974
- !i.paused && i.state === "playing" && i.webcodecsPlayback && i.webcodecsSharedState && this.activeSharedWebCodecsScratch.add(i.webcodecsSharedState.id);
6975
- for (const [i, o] of this.slots) {
6976
- if (o.paused || o.state === "loading") {
6977
- o.paused && o.state === "playing" && o.webcodecsPlayback && o.webcodecsSharedState && this.activeSharedWebCodecsScratch.has(o.webcodecsSharedState.id) && this.tickSharedWebCodecs(o, A, !1);
6973
+ for (const o of this.slots.values())
6974
+ !o.paused && o.state === "playing" && o.webcodecsPlayback && o.webcodecsSharedState && this.activeSharedWebCodecsScratch.add(o.webcodecsSharedState.id);
6975
+ for (const [o, i] of this.slots) {
6976
+ if (i.paused || i.state === "loading") {
6977
+ i.paused && i.state === "playing" && i.webcodecsPlayback && i.webcodecsSharedState && this.activeSharedWebCodecsScratch.has(i.webcodecsSharedState.id) && this.tickSharedWebCodecs(i, A, !1);
6978
6978
  continue;
6979
6979
  }
6980
- const e = this.handles.get(i);
6981
- this.postAnimator.applyAnimatedState(o, A) && (E = !0), o.type === "svga" && o.videoEntity && o.state === "playing" && (E = this.tickSVGA(o, C, e, A) || E), (o.type === "vap" || o.type === "alphaVideo") && o.webcodecsPlayback && o.state === "playing" && (o.webcodecsSharedState ? this.tickSharedWebCodecs(o, A, !0) : (this.tickWebCodecs(o, C, e), (Q = (g = o.webcodecsPlayback).ensureDecodedThrough) == null || Q.call(g, (I = o.wcPlaybackTime) != null ? I : 0)));
6980
+ const e = this.handles.get(o);
6981
+ this.postAnimator.applyAnimatedState(i, A) && (E = !0), i.type === "svga" && i.videoEntity && i.state === "playing" && (E = this.tickSVGA(i, C, e, A) || E), (i.type === "vap" || i.type === "alphaVideo") && i.webcodecsPlayback && i.state === "playing" && (i.webcodecsSharedState ? this.tickSharedWebCodecs(i, A, !0) : (this.tickWebCodecs(i, C, e), (Q = (g = i.webcodecsPlayback).ensureDecodedThrough) == null || Q.call(g, (I = i.wcPlaybackTime) != null ? I : 0)));
6982
6982
  }
6983
6983
  if (E = this.postAnimator.hasActiveAnimations() || E, this.postAnimator.update(A), E = this.removeFinished() || E, E = this.vapRenderer.syncVideoTextures(this.backend, this.slots) || E, E = this.alphaVideoRenderer.syncVideoTextures(this.backend, this.slots) || E, E) {
6984
6984
  this.forceNextDraw = !1, this.backend.beginFrame(), this.svgaBatch.beginFrame(this.backend);
6985
- for (const i of this.getRenderLayers())
6986
- this.drawLayer(i);
6985
+ for (const o of this.getRenderLayers())
6986
+ this.drawLayer(o);
6987
6987
  this.backend.endFrame();
6988
6988
  }
6989
6989
  this.rafId = requestAnimationFrame(this.onAnimationFrame);
@@ -6998,27 +6998,27 @@ class Zi {
6998
6998
  var Q, C;
6999
6999
  const E = A.webcodecsSharedState;
7000
7000
  if (!E) return;
7001
- const i = Math.max(E.playback.duration, 1e-9), o = Math.max(0, (I - E.startedAtMs) / 1e3);
7002
- A.wcPlaybackTime = o % i, g && (this.advancedSharedWebCodecsScratch.has(E.id) || (this.advancedSharedWebCodecsScratch.add(E.id), (C = (Q = E.playback).ensureDecodedThrough) == null || C.call(Q, A.wcPlaybackTime)));
7001
+ const o = Math.max(E.playback.duration, 1e-9), i = Math.max(0, (I - E.startedAtMs) / 1e3);
7002
+ A.wcPlaybackTime = i % o, g && (this.advancedSharedWebCodecsScratch.has(E.id) || (this.advancedSharedWebCodecsScratch.add(E.id), (C = (Q = E.playback).ensureDecodedThrough) == null || C.call(Q, A.wcPlaybackTime)));
7003
7003
  }
7004
7004
  tickWebCodecs(A, I, g) {
7005
7005
  var Q, C;
7006
7006
  const E = A.webcodecsPlayback;
7007
7007
  if (!E) return;
7008
- const i = Math.max(E.duration, 1e-9);
7009
- if (!Number.isFinite(i)) return;
7010
- const o = (Q = A.options.loop) != null ? Q : 1;
7008
+ const o = Math.max(E.duration, 1e-9);
7009
+ if (!Number.isFinite(o)) return;
7010
+ const i = (Q = A.options.loop) != null ? Q : 1;
7011
7011
  let e = ((C = A.wcPlaybackTime) != null ? C : 0) + I;
7012
- if (o === 0) {
7013
- A.wcPlaybackTime = (e % i + i) % i, this.wcDbgLogTickOnce(A, i, A.wcPlaybackTime, o);
7012
+ if (i === 0) {
7013
+ A.wcPlaybackTime = (e % o + o) % o, this.wcDbgLogTickOnce(A, o, A.wcPlaybackTime, i);
7014
7014
  return;
7015
7015
  }
7016
- const a = Math.floor(e / i);
7017
- if (A.loopCount + a >= o) {
7018
- A.loopCount = o, A.wcPlaybackTime = i - 1e-6, this.wcDbgLogTickOnce(A, i, A.wcPlaybackTime, o), this.onWebCodecsPlaybackComplete(A, g);
7016
+ const a = Math.floor(e / o);
7017
+ if (A.loopCount + a >= i) {
7018
+ A.loopCount = i, A.wcPlaybackTime = o - 1e-6, this.wcDbgLogTickOnce(A, o, A.wcPlaybackTime, i), this.onWebCodecsPlaybackComplete(A, g);
7019
7019
  return;
7020
7020
  }
7021
- A.loopCount += a, A.wcPlaybackTime = e - a * i, this.wcDbgLogTickOnce(A, i, A.wcPlaybackTime, o);
7021
+ A.loopCount += a, A.wcPlaybackTime = e - a * o, this.wcDbgLogTickOnce(A, o, A.wcPlaybackTime, i);
7022
7022
  }
7023
7023
  wcDbgLogTickOnce(A, I, g, Q) {
7024
7024
  var C;
@@ -7043,15 +7043,15 @@ class Zi {
7043
7043
  }
7044
7044
  tickSVGA(A, I, g, Q) {
7045
7045
  var C;
7046
- const E = A.videoEntity, i = E.params.fps, o = E.params.frames;
7047
- if (i <= 0 || o <= 0) return !1;
7048
- const e = 1 / i, a = A.currentFrame;
7046
+ const E = A.videoEntity, o = E.params.fps, i = E.params.frames;
7047
+ if (o <= 0 || i <= 0) return !1;
7048
+ const e = 1 / o, a = A.currentFrame;
7049
7049
  A.accumulatedTime += I;
7050
7050
  const t = Math.floor(A.accumulatedTime / e);
7051
7051
  if (t <= 0) return !1;
7052
7052
  A.accumulatedTime -= t * e;
7053
- const s = (C = A.options.loop) != null ? C : 1, D = A.loopCount * o + A.currentFrame + t;
7054
- return s === 0 ? (A.loopCount = Math.floor(D / o), A.currentFrame = D % o) : D >= s * o ? (A.loopCount = s, A.currentFrame = o - 1, this.onGiftPlayComplete(A, g, Q)) : (A.loopCount = Math.floor(D / o), A.currentFrame = D % o), A.currentFrame = Math.max(0, Math.min(A.currentFrame, o - 1)), A.currentFrame !== a && this.audioManager.tickFrame(A, A.currentFrame, g), A.currentFrame !== a;
7053
+ const s = (C = A.options.loop) != null ? C : 1, D = A.loopCount * i + A.currentFrame + t;
7054
+ return s === 0 ? (A.loopCount = Math.floor(D / i), A.currentFrame = D % i) : D >= s * i ? (A.loopCount = s, A.currentFrame = i - 1, this.onGiftPlayComplete(A, g, Q)) : (A.loopCount = Math.floor(D / i), A.currentFrame = D % i), A.currentFrame = Math.max(0, Math.min(A.currentFrame, i - 1)), A.currentFrame !== a && this.audioManager.tickFrame(A, A.currentFrame, g), A.currentFrame !== a;
7055
7055
  }
7056
7056
  onGiftPlayComplete(A, I, g) {
7057
7057
  var Q;
@@ -7072,9 +7072,9 @@ class Zi {
7072
7072
  for (const I of this.slots.values())
7073
7073
  I.state !== "playing" && I.state !== "fly" && I.state !== "stopped" || A.push(I);
7074
7074
  return A.sort((I, g) => {
7075
- var Q, C, E, i;
7076
- const o = (Q = I.zIndex) != null ? Q : 0, e = (C = g.zIndex) != null ? C : 0;
7077
- return o !== e ? o - e : ((E = I.renderOrder) != null ? E : 0) - ((i = g.renderOrder) != null ? i : 0);
7075
+ var Q, C, E, o;
7076
+ const i = (Q = I.zIndex) != null ? Q : 0, e = (C = g.zIndex) != null ? C : 0;
7077
+ return i !== e ? i - e : ((E = I.renderOrder) != null ? E : 0) - ((o = g.renderOrder) != null ? o : 0);
7078
7078
  }), A;
7079
7079
  }
7080
7080
  getRenderLayers() {
@@ -7083,9 +7083,9 @@ class Zi {
7083
7083
  if (g.length === 0) return [];
7084
7084
  const Q = [];
7085
7085
  let C = [], E = (A = g[0].zIndex) != null ? A : 0;
7086
- for (const i of g) {
7087
- const o = (I = i.zIndex) != null ? I : 0;
7088
- C.length > 0 && o !== E && (Q.push(this.collapseCoincidentVisualDuplicates(C)), C = [], E = o), C.push(i);
7086
+ for (const o of g) {
7087
+ const i = (I = o.zIndex) != null ? I : 0;
7088
+ C.length > 0 && i !== E && (Q.push(this.collapseCoincidentVisualDuplicates(C)), C = [], E = i), C.push(o);
7089
7089
  }
7090
7090
  return C.length > 0 && Q.push(this.collapseCoincidentVisualDuplicates(C)), Q;
7091
7091
  }
@@ -7158,7 +7158,7 @@ class Zi {
7158
7158
  }
7159
7159
  /** Batch keys are cached on the slot and only rebuilt when their inputs change. */
7160
7160
  getBatchKey(A) {
7161
- var I, g, Q, C, E, i, o;
7161
+ var I, g, Q, C, E, o, i;
7162
7162
  const e = A.batchKeyCache;
7163
7163
  switch (A.type) {
7164
7164
  case "svga": {
@@ -7175,9 +7175,9 @@ class Zi {
7175
7175
  return A.batchKeyCache = { key: D, d0: a, d1: t, d2: s }, D;
7176
7176
  }
7177
7177
  case "alphaVideo": {
7178
- const a = A.videoTextureHandle, t = (i = A.options.objectFit) != null ? i : "contain";
7178
+ const a = A.videoTextureHandle, t = (o = A.options.objectFit) != null ? o : "contain";
7179
7179
  if (e && e.d0 === a && e.d1 === t) return e.key;
7180
- const s = `alpha:${(o = a == null ? void 0 : a.id) != null ? o : -1}:${t}`;
7180
+ const s = `alpha:${(i = a == null ? void 0 : a.id) != null ? i : -1}:${t}`;
7181
7181
  return A.batchKeyCache = { key: s, d0: a, d1: t, d2: null }, s;
7182
7182
  }
7183
7183
  }
@@ -7209,19 +7209,19 @@ async function Vi(B, A, I) {
7209
7209
  inputBytes: B.byteLength,
7210
7210
  nativeAvailable: DB(),
7211
7211
  nativeAttempts: []
7212
- } : null, C = (i, o) => (Q && (Q.selectedPath = o, Q.outputBytes = i.byteLength, Q.totalMs = AA() - g, I == null || I(Q)), i), E = (i) => {
7213
- throw Q && (Q.error = QQ(i), Q.totalMs = AA() - g, I == null || I(Q)), i;
7212
+ } : null, C = (o, i) => (Q && (Q.selectedPath = i, Q.outputBytes = o.byteLength, Q.totalMs = AA() - g, I == null || I(Q)), o), E = (o) => {
7213
+ throw Q && (Q.error = QQ(o), Q.totalMs = AA() - g, I == null || I(Q)), o;
7214
7214
  };
7215
7215
  if (DB())
7216
7216
  try {
7217
7217
  return C(await wB(B, Q != null ? Q : void 0), "native");
7218
- } catch (i) {
7218
+ } catch (o) {
7219
7219
  }
7220
7220
  try {
7221
- const i = Q ? AA() : 0, o = A();
7222
- return Q && (Q.wasmMs = AA() - i), o ? C(o, "wasm") : C(await wB(B, Q != null ? Q : void 0), "native-retry");
7223
- } catch (i) {
7224
- return E(i);
7221
+ const o = Q ? AA() : 0, i = A();
7222
+ return Q && (Q.wasmMs = AA() - o), i ? C(i, "wasm") : C(await wB(B, Q != null ? Q : void 0), "native-retry");
7223
+ } catch (o) {
7224
+ return E(o);
7225
7225
  }
7226
7226
  }
7227
7227
  async function wB(B, A) {
@@ -7252,17 +7252,17 @@ async function tg(B, A, I) {
7252
7252
  status: "failed"
7253
7253
  } : null;
7254
7254
  try {
7255
- const C = new DecompressionStream(A), E = C.writable.getWriter(), i = C.readable.getReader(), o = Q ? AA() : 0, e = Promise.resolve(
7255
+ const C = new DecompressionStream(A), E = C.writable.getWriter(), o = C.readable.getReader(), i = Q ? AA() : 0, e = Promise.resolve(
7256
7256
  E.write(new Uint8Array(B.buffer, B.byteOffset, B.byteLength))
7257
7257
  ), a = Promise.resolve(E.close());
7258
7258
  e.catch(() => {
7259
7259
  }), a.catch(() => {
7260
- }), Q && (Q.writerSubmitMs = AA() - o);
7260
+ }), Q && (Q.writerSubmitMs = AA() - i);
7261
7261
  const t = [];
7262
7262
  let s = 0;
7263
7263
  const D = Q ? AA() : 0;
7264
7264
  for (; ; ) {
7265
- const { done: r, value: F } = await i.read();
7265
+ const { done: r, value: F } = await o.read();
7266
7266
  if (r) break;
7267
7267
  t.push(F), s += F.length;
7268
7268
  }
@@ -7594,39 +7594,39 @@ function Qo(B) {
7594
7594
  function Co(B) {
7595
7595
  let A = 0, I = "", g, Q, C = { fill: null, stroke: null, strokeWidth: 0 }, E = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
7596
7596
  for (; B.remaining > 0; ) {
7597
- const i = B.readTag();
7598
- if (!i) break;
7599
- switch (i.field) {
7597
+ const o = B.readTag();
7598
+ if (!o) break;
7599
+ switch (o.field) {
7600
7600
  case 1:
7601
7601
  A = B.readVarint();
7602
7602
  break;
7603
7603
  case 2: {
7604
- const o = B.readVarint();
7605
- I = go(B.sub(o));
7604
+ const i = B.readVarint();
7605
+ I = go(B.sub(i));
7606
7606
  break;
7607
7607
  }
7608
7608
  case 3: {
7609
- const o = B.readVarint();
7610
- g = Bo(B.sub(o));
7609
+ const i = B.readVarint();
7610
+ g = Bo(B.sub(i));
7611
7611
  break;
7612
7612
  }
7613
7613
  case 4: {
7614
- const o = B.readVarint();
7615
- Q = Qo(B.sub(o));
7614
+ const i = B.readVarint();
7615
+ Q = Qo(B.sub(i));
7616
7616
  break;
7617
7617
  }
7618
7618
  case 10: {
7619
- const o = B.readVarint();
7620
- C = Io(B.sub(o));
7619
+ const i = B.readVarint();
7620
+ C = Io(B.sub(i));
7621
7621
  break;
7622
7622
  }
7623
7623
  case 11: {
7624
- const o = B.readVarint();
7625
- E = EQ(B.sub(o));
7624
+ const i = B.readVarint();
7625
+ E = EQ(B.sub(i));
7626
7626
  break;
7627
7627
  }
7628
7628
  default:
7629
- B.skip(i.wire);
7629
+ B.skip(o.wire);
7630
7630
  }
7631
7631
  }
7632
7632
  return A === 3 ? { kind: "keep" } : I ? { kind: "path", pathData: I, style: C, transform: E } : g ? { kind: "rect", rect: g, style: C, transform: E } : Q ? { kind: "ellipse", ellipse: Q, style: C, transform: E } : null;
@@ -7694,7 +7694,7 @@ function io(B) {
7694
7694
  Q.shapes = g;
7695
7695
  continue;
7696
7696
  }
7697
- const E = C.filter((i) => i.kind !== "keep");
7697
+ const E = C.filter((o) => o.kind !== "keep");
7698
7698
  Q.shapes = E.length > 0 ? E : null, g = Q.shapes;
7699
7699
  }
7700
7700
  return I;
@@ -7764,8 +7764,8 @@ function cB(B) {
7764
7764
  break;
7765
7765
  }
7766
7766
  case 3: {
7767
- const C = A.readVarint(), { key: E, value: i } = eo(A.sub(C));
7768
- g.images.set(E, i);
7767
+ const C = A.readVarint(), { key: E, value: o } = eo(A.sub(C));
7768
+ g.images.set(E, o);
7769
7769
  break;
7770
7770
  }
7771
7771
  case 4: {
@@ -7803,11 +7803,11 @@ function FB(B) {
7803
7803
  }
7804
7804
  function ao(B, A) {
7805
7805
  var I, g, Q;
7806
- const C = (g = (I = A.lineDash) == null ? void 0 : I.filter((i) => i > 0)) != null ? g : [];
7806
+ const C = (g = (I = A.lineDash) == null ? void 0 : I.filter((o) => o > 0)) != null ? g : [];
7807
7807
  let E = 0;
7808
7808
  if (A.fill && (E |= 1), A.stroke && (E |= 2), A.lineCap !== void 0 && (E |= 4), A.lineJoin !== void 0 && (E |= 8), A.miterLimit !== void 0 && (E |= 16), C.length > 0 && (E |= 32), B.u8(E), A.fill && rB(B, A.fill), A.stroke && rB(B, A.stroke), B.f32((Q = A.strokeWidth) != null ? Q : 0), A.lineCap !== void 0 && B.i32(A.lineCap), A.lineJoin !== void 0 && B.i32(A.lineJoin), A.miterLimit !== void 0 && B.f32(A.miterLimit), C.length > 0) {
7809
7809
  B.u32(C.length);
7810
- for (const i of C) B.f32(i);
7810
+ for (const o of C) B.f32(o);
7811
7811
  }
7812
7812
  }
7813
7813
  function to(B) {
@@ -7818,7 +7818,7 @@ function to(B) {
7818
7818
  };
7819
7819
  if (A & 4 && (Q.lineCap = B.i32()), A & 8 && (Q.lineJoin = B.i32()), A & 16 && (Q.miterLimit = B.f32()), A & 32) {
7820
7820
  const C = B.u32(), E = [];
7821
- for (let i = 0; i < C; i++) E.push(B.f32());
7821
+ for (let o = 0; o < C; o++) E.push(B.f32());
7822
7822
  E.length > 0 && (Q.lineDash = E);
7823
7823
  }
7824
7824
  return Q;
@@ -7826,10 +7826,10 @@ function to(B) {
7826
7826
  async function so(B, A, I) {
7827
7827
  var g, Q, C, E;
7828
7828
  B.u8(A.kind === "path" ? 0 : A.kind === "rect" ? 1 : 2), await B.stringCooperative((g = A.pathData) != null ? g : "", I);
7829
- const i = (Q = A.rect) != null ? Q : { x: 0, y: 0, width: 0, height: 0, cornerRadius: 0 };
7830
- B.f32(i.x), B.f32(i.y), B.f32(i.width), B.f32(i.height), B.f32((C = i.cornerRadius) != null ? C : 0);
7831
- const o = (E = A.ellipse) != null ? E : { x: 0, y: 0, radiusX: 0, radiusY: 0 };
7832
- B.f32(o.x), B.f32(o.y), B.f32(o.radiusX), B.f32(o.radiusY), ao(B, A.style), B.f32(A.transform.a), B.f32(A.transform.b), B.f32(A.transform.c), B.f32(A.transform.d), B.f32(A.transform.tx), B.f32(A.transform.ty);
7829
+ const o = (Q = A.rect) != null ? Q : { x: 0, y: 0, width: 0, height: 0, cornerRadius: 0 };
7830
+ B.f32(o.x), B.f32(o.y), B.f32(o.width), B.f32(o.height), B.f32((C = o.cornerRadius) != null ? C : 0);
7831
+ const i = (E = A.ellipse) != null ? E : { x: 0, y: 0, radiusX: 0, radiusY: 0 };
7832
+ B.f32(i.x), B.f32(i.y), B.f32(i.radiusX), B.f32(i.radiusY), ao(B, A.style), B.f32(A.transform.a), B.f32(A.transform.b), B.f32(A.transform.c), B.f32(A.transform.d), B.f32(A.transform.tx), B.f32(A.transform.ty);
7833
7833
  }
7834
7834
  function Do(B) {
7835
7835
  const A = B.u8();
@@ -7895,10 +7895,10 @@ async function iQ(B, A) {
7895
7895
  B.pad4();
7896
7896
  const Q = B.u32(), C = I * Q * cC;
7897
7897
  B.pad4();
7898
- const E = B.position, i = new Float32Array(B.sourceBuffer(), E, C);
7898
+ const E = B.position, o = new Float32Array(B.sourceBuffer(), E, C);
7899
7899
  B.skip(C * 4), await A();
7900
- const o = B.u32(), e = [];
7901
- for (let F = 0; F < o; F++)
7900
+ const i = B.u32(), e = [];
7901
+ for (let F = 0; F < i; F++)
7902
7902
  e.push(B.string()), await A();
7903
7903
  B.pad4();
7904
7904
  const a = I * Q, t = B.position, s = new Int32Array(B.sourceBuffer(), t, a);
@@ -7916,7 +7916,7 @@ async function iQ(B, A) {
7916
7916
  spriteCount: I,
7917
7917
  frameCount: Q,
7918
7918
  imageKeys: g,
7919
- frameData: i,
7919
+ frameData: o,
7920
7920
  clipPaths: e,
7921
7921
  clipPathIndex: s,
7922
7922
  shapesTable: w,
@@ -7986,7 +7986,7 @@ async function oQ(B, A, I, g) {
7986
7986
  if (E.u32() !== co) throw new Error("Invalid SVGA worker payload magic");
7987
7987
  if (E.u16() !== ro) throw new Error("Unsupported SVGA worker payload version");
7988
7988
  E.u16();
7989
- const i = E.string(), o = {
7989
+ const o = E.string(), i = {
7990
7990
  viewBoxWidth: E.f32(),
7991
7991
  viewBoxHeight: E.f32(),
7992
7992
  fps: E.f32(),
@@ -8007,8 +8007,8 @@ async function oQ(B, A, I, g) {
8007
8007
  }
8008
8008
  const D = await iQ(E, C);
8009
8009
  return Y(g, "SVGA payload deserialization aborted"), {
8010
- version: i,
8011
- params: o,
8010
+ version: o,
8011
+ params: i,
8012
8012
  audios: e,
8013
8013
  spriteTable: D,
8014
8014
  images: {},
@@ -9534,11 +9534,11 @@ function Mo() {
9534
9534
  g.mainThreadFrameBudgetMs,
9535
9535
  g.signal
9536
9536
  ).then((E) => {
9537
- var i;
9537
+ var o;
9538
9538
  if (eA.get(I.id) !== g) return;
9539
9539
  eA.delete(I.id), fA(g);
9540
- const o = (i = E.__debug) == null ? void 0 : i.parser;
9541
- o && typeof o == "object" && !Array.isArray(o) && (o.payloadDeserializeMs = RB() - C), g.resolve(E);
9540
+ const i = (o = E.__debug) == null ? void 0 : o.parser;
9541
+ i && typeof i == "object" && !Array.isArray(i) && (i.payloadDeserializeMs = RB() - C), g.resolve(E);
9542
9542
  }, (E) => {
9543
9543
  eA.get(I.id) === g && (eA.delete(I.id), fA(g), g.reject(E instanceof Error ? E : new Error(String(E))));
9544
9544
  });
@@ -9559,25 +9559,25 @@ function No(B, A = {}) {
9559
9559
  Y(A.signal, "SVGA parser worker task aborted");
9560
9560
  const I = Mo(), g = yo++;
9561
9561
  return new Promise((Q, C) => {
9562
- var E, i;
9563
- const o = {
9562
+ var E, o;
9563
+ const i = {
9564
9564
  owner: I,
9565
9565
  mainThreadFrameBudgetMs: A.mainThreadFrameBudgetMs,
9566
9566
  signal: A.signal,
9567
9567
  resolve: Q,
9568
9568
  reject: C
9569
9569
  };
9570
- if (o.onAbort = () => {
9570
+ if (i.onAbort = () => {
9571
9571
  mI(
9572
9572
  I,
9573
9573
  IA("SVGA parser worker task aborted"),
9574
9574
  g
9575
9575
  );
9576
- }, eA.set(g, o), (E = A.signal) != null && E.aborted) {
9577
- o.onAbort();
9576
+ }, eA.set(g, i), (E = A.signal) != null && E.aborted) {
9577
+ i.onAbort();
9578
9578
  return;
9579
9579
  }
9580
- (i = A.signal) == null || i.addEventListener("abort", o.onAbort, { once: !0 });
9580
+ (o = A.signal) == null || o.addEventListener("abort", i.onAbort, { once: !0 });
9581
9581
  try {
9582
9582
  I.postMessage(
9583
9583
  {
@@ -9763,8 +9763,8 @@ async function Ko(B, A, I) {
9763
9763
  const g = gA({ maxBudgetMs: A }), Q = new Uint8Array(B.byteLength), C = 64 * 1024;
9764
9764
  Y(I, "SVGA image decode aborted");
9765
9765
  for (let E = 0; E < B.byteLength; E += C) {
9766
- const i = Math.min(E + C, B.byteLength);
9767
- Q.set(B.subarray(E, i), E), i < B.byteLength && g.shouldYield() && await g.yield(), Y(I, "SVGA image decode aborted");
9766
+ const o = Math.min(E + C, B.byteLength);
9767
+ Q.set(B.subarray(E, o), E), o < B.byteLength && g.shouldYield() && await g.yield(), Y(I, "SVGA image decode aborted");
9768
9768
  }
9769
9769
  return Q.buffer;
9770
9770
  }
@@ -9775,14 +9775,14 @@ async function Jo(B, A, I = {}) {
9775
9775
  try {
9776
9776
  for (let E = 0; E < B.length; E += C) {
9777
9777
  Y(I.signal, "SVGA image decode aborted");
9778
- const i = B.slice(E, E + C), o = [], e = [];
9779
- for (const [s, D] of i) {
9778
+ const o = B.slice(E, E + C), i = [], e = [];
9779
+ for (const [s, D] of o) {
9780
9780
  const w = await Ko(
9781
9781
  D,
9782
9782
  I.mainThreadFrameBudgetMs,
9783
9783
  I.signal
9784
9784
  );
9785
- o.push({ key: s, data: w }), e.push(w);
9785
+ i.push({ key: s, data: w }), e.push(w);
9786
9786
  }
9787
9787
  const a = Uo++, t = await new Promise((s, D) => {
9788
9788
  var w, h;
@@ -9806,7 +9806,7 @@ async function Jo(B, A, I = {}) {
9806
9806
  const r = {
9807
9807
  type: "decode-batch",
9808
9808
  id: a,
9809
- items: o,
9809
+ items: i,
9810
9810
  workerTimeSliceMs: I.workerTimeSliceMs,
9811
9811
  maxConcurrency: I.maxConcurrency
9812
9812
  };
@@ -9825,7 +9825,7 @@ async function Jo(B, A, I = {}) {
9825
9825
  }
9826
9826
  return Q;
9827
9827
  } catch (E) {
9828
- for (const i of Q.values()) i.close();
9828
+ for (const o of Q.values()) o.close();
9829
9829
  throw E;
9830
9830
  }
9831
9831
  }, I.signal);
@@ -9844,19 +9844,19 @@ async function TI(B, A, I) {
9844
9844
  const g = gA({ maxBudgetMs: A }), Q = new Uint8Array(B.byteLength), C = 64 * 1024;
9845
9845
  Y(I, "SVGA parse aborted");
9846
9846
  for (let E = 0; E < B.byteLength; E += C) {
9847
- const i = Math.min(E + C, B.byteLength);
9848
- Q.set(B.subarray(E, i), E), i < B.byteLength && g.shouldYield() && await g.yield(), Y(I, "SVGA parse aborted");
9847
+ const o = Math.min(E + C, B.byteLength);
9848
+ Q.set(B.subarray(E, o), E), o < B.byteLength && g.shouldYield() && await g.yield(), Y(I, "SVGA parse aborted");
9849
9849
  }
9850
9850
  return Q.buffer;
9851
9851
  }
9852
9852
  async function uo(B, A, I) {
9853
9853
  const g = [], Q = /* @__PURE__ */ new Map(), C = gA({ maxBudgetMs: A });
9854
- for (const [E, i] of B.images) {
9855
- if (Y(I, "SVGA image collection aborted"), Ho(E, i)) {
9856
- Q.set(E, await TI(i, A, I));
9854
+ for (const [E, o] of B.images) {
9855
+ if (Y(I, "SVGA image collection aborted"), Ho(E, o)) {
9856
+ Q.set(E, await TI(o, A, I));
9857
9857
  continue;
9858
9858
  }
9859
- i.length !== 0 && (g.push([E, i]), C.shouldYield() && await C.yield(), Y(I, "SVGA image collection aborted"));
9859
+ o.length !== 0 && (g.push([E, o]), C.shouldYield() && await C.yield(), Y(I, "SVGA image collection aborted"));
9860
9860
  }
9861
9861
  return { imageEntries: g, audioBlobs: Q };
9862
9862
  }
@@ -9865,11 +9865,11 @@ async function NB(B, A, I, g) {
9865
9865
  maxBudgetMs: Math.max(2, I)
9866
9866
  });
9867
9867
  try {
9868
- for (let i = 0; i < B.length; i += C) {
9868
+ for (let o = 0; o < B.length; o += C) {
9869
9869
  Y(g, "SVGA image decode aborted");
9870
- const o = B.slice(i, i + C);
9870
+ const i = B.slice(o, o + C);
9871
9871
  await Promise.all(
9872
- o.map(async ([e, a]) => {
9872
+ i.map(async ([e, a]) => {
9873
9873
  try {
9874
9874
  const t = await createImageBitmap(new Blob([new Uint8Array(a)]), {
9875
9875
  premultiplyAlpha: "none"
@@ -9881,25 +9881,25 @@ async function NB(B, A, I, g) {
9881
9881
  if (SA(t)) throw t;
9882
9882
  }
9883
9883
  })
9884
- ), i + C < B.length && E.shouldYield() && await E.yield();
9884
+ ), o + C < B.length && E.shouldYield() && await E.yield();
9885
9885
  }
9886
9886
  return Q;
9887
- } catch (i) {
9888
- for (const o of Q.values()) o.close();
9889
- throw i;
9887
+ } catch (o) {
9888
+ for (const i of Q.values()) i.close();
9889
+ throw o;
9890
9890
  }
9891
9891
  }
9892
9892
  async function SB(B, A, I) {
9893
9893
  const g = /* @__PURE__ */ new Map();
9894
9894
  if (B.length === 0) return g;
9895
9895
  let Q = 4;
9896
- const C = 2, E = 24, i = gA({
9896
+ const C = 2, E = 24, o = gA({
9897
9897
  maxBudgetMs: Math.max(2, A)
9898
9898
  });
9899
9899
  try {
9900
- for (let o = 0; o < B.length; ) {
9900
+ for (let i = 0; i < B.length; ) {
9901
9901
  Y(I, "SVGA image decode aborted");
9902
- const e = typeof performance != "undefined" ? performance.now() : 0, a = Math.min(o + Q, B.length), t = B.slice(o, a);
9902
+ const e = typeof performance != "undefined" ? performance.now() : 0, a = Math.min(i + Q, B.length), t = B.slice(i, a);
9903
9903
  await Promise.all(
9904
9904
  t.map(async ([w, h]) => {
9905
9905
  try {
@@ -9914,18 +9914,18 @@ async function SB(B, A, I) {
9914
9914
  }
9915
9915
  })
9916
9916
  );
9917
- const s = i.budgetMs, D = typeof performance != "undefined" ? performance.now() - e : s * 0.5;
9918
- D < s * 0.45 && Q < E ? Q = Math.min(E, Q + 2) : D > s * 1.4 && Q > C && (Q = Math.max(C, Q - 2)), o = a, o < B.length && i.shouldYield() && await i.yield();
9917
+ const s = o.budgetMs, D = typeof performance != "undefined" ? performance.now() - e : s * 0.5;
9918
+ D < s * 0.45 && Q < E ? Q = Math.min(E, Q + 2) : D > s * 1.4 && Q > C && (Q = Math.max(C, Q - 2)), i = a, i < B.length && o.shouldYield() && await o.yield();
9919
9919
  }
9920
9920
  return g;
9921
- } catch (o) {
9921
+ } catch (i) {
9922
9922
  for (const e of g.values()) e.close();
9923
- throw o;
9923
+ throw i;
9924
9924
  }
9925
9925
  }
9926
9926
  function qo(B) {
9927
- var A, I, g, Q, C, E, i;
9928
- const o = (B == null ? void 0 : B.svgaLoadFrameBudgetMs) == null ? (A = B == null ? void 0 : B.imageDecodeFrameBudgetMs) != null ? A : hg : Math.min(
9927
+ var A, I, g, Q, C, E, o;
9928
+ const i = (B == null ? void 0 : B.svgaLoadFrameBudgetMs) == null ? (A = B == null ? void 0 : B.imageDecodeFrameBudgetMs) != null ? A : hg : Math.min(
9929
9929
  B.svgaLoadFrameBudgetMs,
9930
9930
  (I = B.imageDecodeFrameBudgetMs) != null ? I : hg
9931
9931
  );
@@ -9933,11 +9933,11 @@ function qo(B) {
9933
9933
  useImageBitmapDecodeWorker: (B == null ? void 0 : B.useImageBitmapDecodeWorker) !== !1,
9934
9934
  imageDecodeWorkerChunkSize: (g = B == null ? void 0 : B.imageDecodeWorkerChunkSize) != null ? g : Lo,
9935
9935
  imageDecodeAdaptiveOnMainThread: (B == null ? void 0 : B.imageDecodeAdaptiveOnMainThread) !== !1,
9936
- imageDecodeFrameBudgetMs: o,
9936
+ imageDecodeFrameBudgetMs: i,
9937
9937
  imageDecodeFixedBatchSize: (Q = B == null ? void 0 : B.imageDecodeFixedBatchSize) != null ? Q : fo,
9938
9938
  svgaLoadFrameBudgetMs: (C = B == null ? void 0 : B.svgaLoadFrameBudgetMs) != null ? C : hg,
9939
9939
  svgaWorkerFrameBudgetMs: (E = B == null ? void 0 : B.svgaWorkerFrameBudgetMs) != null ? E : 4,
9940
- svgaWorkerImageDecodeConcurrency: (i = B == null ? void 0 : B.svgaWorkerImageDecodeConcurrency) != null ? i : 2
9940
+ svgaWorkerImageDecodeConcurrency: (o = B == null ? void 0 : B.svgaWorkerImageDecodeConcurrency) != null ? o : 2
9941
9941
  };
9942
9942
  }
9943
9943
  async function po(B, A) {
@@ -9956,9 +9956,9 @@ async function po(B, A) {
9956
9956
  mainThreadFrameBudgetMs: g.svgaLoadFrameBudgetMs,
9957
9957
  signal: A == null ? void 0 : A.signal
9958
9958
  });
9959
- } catch (o) {
9960
- if (SA(o)) throw o;
9961
- console.warn("[GiftStage:SVGA] image decode worker failed, using main thread", o), E = g.imageDecodeAdaptiveOnMainThread ? await SB(
9959
+ } catch (i) {
9960
+ if (SA(i)) throw i;
9961
+ console.warn("[GiftStage:SVGA] image decode worker failed, using main thread", i), E = g.imageDecodeAdaptiveOnMainThread ? await SB(
9962
9962
  Q,
9963
9963
  g.imageDecodeFrameBudgetMs,
9964
9964
  A == null ? void 0 : A.signal
@@ -9981,7 +9981,7 @@ async function po(B, A) {
9981
9981
  A == null ? void 0 : A.signal
9982
9982
  );
9983
9983
  if ((I = A == null ? void 0 : A.signal) != null && I.aborted) {
9984
- for (const o of E.values()) o.close();
9984
+ for (const i of E.values()) i.close();
9985
9985
  throw IA("SVGA parse aborted");
9986
9986
  }
9987
9987
  return { movie: B, imageBitmaps: E, audioBlobs: C };
@@ -10004,8 +10004,8 @@ async function UB(B, A, I) {
10004
10004
  function ng(B, A) {
10005
10005
  return B.consumers++, new Promise((I, g) => {
10006
10006
  let Q = !1;
10007
- const C = (i) => {
10008
- Q || (Q = !0, A == null || A.removeEventListener("abort", E), B.consumers = Math.max(0, B.consumers - 1), B.consumers === 0 && !B.settled && B.controller.abort(), i());
10007
+ const C = (o) => {
10008
+ Q || (Q = !0, A == null || A.removeEventListener("abort", E), B.consumers = Math.max(0, B.consumers - 1), B.consumers === 0 && !B.settled && B.controller.abort(), o());
10009
10009
  }, E = () => {
10010
10010
  C(() => g(IA("SVGA parse aborted")));
10011
10011
  };
@@ -10014,8 +10014,8 @@ function ng(B, A) {
10014
10014
  return;
10015
10015
  }
10016
10016
  A == null || A.addEventListener("abort", E, { once: !0 }), B.promise.then(
10017
- (i) => C(() => I(i)),
10018
- (i) => C(() => g(i))
10017
+ (o) => C(() => I(o)),
10018
+ (o) => C(() => g(o))
10019
10019
  );
10020
10020
  });
10021
10021
  }
@@ -10032,7 +10032,7 @@ async function sQ(B, A, I, g, Q) {
10032
10032
  const a = YI.get(A);
10033
10033
  if (a) return ng(a, Q == null ? void 0 : Q.signal);
10034
10034
  }
10035
- const C = new AbortController(), E = C.signal, i = kg(async () => {
10035
+ const C = new AbortController(), E = C.signal, o = kg(async () => {
10036
10036
  var e;
10037
10037
  if (Y(E, "SVGA parse aborted"), g)
10038
10038
  try {
@@ -10143,15 +10143,15 @@ async function sQ(B, A, I, g, Q) {
10143
10143
  payloadDeserializeMs: n
10144
10144
  }
10145
10145
  }, MB(!0, D)), Y(E, "SVGA parse aborted"), A ? BB(A, D) : fI.set(B, D), D;
10146
- }), o = {
10146
+ }), i = {
10147
10147
  controller: C,
10148
10148
  consumers: 0,
10149
10149
  settled: !1,
10150
10150
  promise: null
10151
10151
  };
10152
- return o.promise = i.finally(() => {
10153
- o.settled = !0, A ? YI.get(A) === o && YI.delete(A) : KI.get(B) === o && KI.delete(B);
10154
- }), A ? YI.set(A, o) : KI.set(B, o), ng(o, Q == null ? void 0 : Q.signal);
10152
+ return i.promise = o.finally(() => {
10153
+ i.settled = !0, A ? YI.get(A) === i && YI.delete(A) : KI.get(B) === i && KI.delete(B);
10154
+ }), A ? YI.set(A, i) : KI.set(B, i), ng(i, Q == null ? void 0 : Q.signal);
10155
10155
  }
10156
10156
  async function xo(B, A) {
10157
10157
  Y(A == null ? void 0 : A.signal, "SVGA parse aborted");
@@ -10203,14 +10203,14 @@ function lB(B) {
10203
10203
  return B--, B |= B >> 1, B |= B >> 2, B |= B >> 4, B |= B >> 8, B |= B >> 16, B + 1;
10204
10204
  }
10205
10205
  function bo(B, A, I, g, Q, C) {
10206
- const E = Math.max(1, Q - g), i = Math.min(1, C, E / Math.max(A, I));
10206
+ const E = Math.max(1, Q - g), o = Math.min(1, C, E / Math.max(A, I));
10207
10207
  return {
10208
10208
  key: B,
10209
10209
  width: A,
10210
10210
  height: I,
10211
- packedWidth: Math.max(1, Math.floor(A * i)),
10212
- packedHeight: Math.max(1, Math.floor(I * i)),
10213
- scale: i
10211
+ packedWidth: Math.max(1, Math.floor(A * o)),
10212
+ packedHeight: Math.max(1, Math.floor(I * o)),
10213
+ scale: o
10214
10214
  };
10215
10215
  }
10216
10216
  function lg(B, A, I, g, Q) {
@@ -10224,31 +10224,31 @@ function lg(B, A, I, g, Q) {
10224
10224
  w: A.packedWidth,
10225
10225
  h: A.packedHeight
10226
10226
  }), B.cursorX += C, B.shelfH = Math.max(B.shelfH, E), B.usedW = Math.max(B.usedW, B.cursorX), B.usedH = Math.max(B.usedH, B.shelfY + B.shelfH), !0;
10227
- const i = B.shelfY + B.shelfH;
10228
- return i + E > Q ? !1 : (B.shelfY = i, B.shelfH = 0, B.cursorX = 0, lg(B, A, I, g, Q));
10227
+ const o = B.shelfY + B.shelfH;
10228
+ return o + E > Q ? !1 : (B.shelfY = o, B.shelfH = 0, B.cursorX = 0, lg(B, A, I, g, Q));
10229
10229
  }
10230
10230
  async function rg(B, A, I, g, Q) {
10231
10231
  const C = [];
10232
- for (const i of B)
10232
+ for (const o of B)
10233
10233
  C.push(
10234
- bo(i.key, i.width, i.height, A, I, g)
10234
+ bo(o.key, o.width, o.height, A, I, g)
10235
10235
  ), await Q();
10236
- C.sort((i, o) => o.packedHeight - i.packedHeight || o.packedWidth - i.packedWidth), await Q();
10236
+ C.sort((o, i) => i.packedHeight - o.packedHeight || i.packedWidth - o.packedWidth), await Q();
10237
10237
  const E = [];
10238
- for (const i of C) {
10239
- let o = !1;
10238
+ for (const o of C) {
10239
+ let i = !1;
10240
10240
  for (let e = 0; e < E.length; e++) {
10241
- if (lg(E[e], i, e, A, I)) {
10242
- o = !0;
10241
+ if (lg(E[e], o, e, A, I)) {
10242
+ i = !0;
10243
10243
  break;
10244
10244
  }
10245
10245
  await Q();
10246
10246
  }
10247
- if (!o) {
10247
+ if (!i) {
10248
10248
  const e = mo(), a = E.length;
10249
- if (!lg(e, i, a, A, I))
10249
+ if (!lg(e, o, a, A, I))
10250
10250
  throw new Error(
10251
- `SVGA atlas image too large: ${i.key} ${i.width}x${i.height}, max texture size ${I}`
10251
+ `SVGA atlas image too large: ${o.key} ${o.width}x${o.height}, max texture size ${I}`
10252
10252
  );
10253
10253
  E.push(e);
10254
10254
  }
@@ -10282,27 +10282,27 @@ async function Wo(B, A, I, g, Q) {
10282
10282
  );
10283
10283
  if (E.length <= C)
10284
10284
  return YB(E, I, Q);
10285
- let i = await To(B, I, Q), o = 1, e = await rg(B, A, I, i, Q);
10285
+ let o = await To(B, I, Q), i = 1, e = await rg(B, A, I, o, Q);
10286
10286
  if (e.length > C)
10287
10287
  throw new Error(
10288
10288
  `SVGA atlas needs ${e.length} pages even at minimum scale, max pages ${C}`
10289
10289
  );
10290
10290
  for (let a = 0; a < 16; a++) {
10291
- const t = (i + o) * 0.5, s = await rg(
10291
+ const t = (o + i) * 0.5, s = await rg(
10292
10292
  B,
10293
10293
  A,
10294
10294
  I,
10295
10295
  t,
10296
10296
  Q
10297
10297
  );
10298
- s.length <= C ? (e = s, i = t) : o = t, await Q();
10298
+ s.length <= C ? (e = s, o = t) : i = t, await Q();
10299
10299
  }
10300
10300
  return YB(e, I, Q);
10301
10301
  }
10302
10302
  function Zo(B, A, I, g, Q, C) {
10303
10303
  if (I.w <= 0 || I.h <= 0 || C <= 0) return;
10304
- const E = Math.max(1, Math.floor(C * 0.5)), i = I.x, o = I.y, e = I.w, a = I.h, t = Math.min(E, i), s = Math.min(E, o), D = Math.min(E, g - (i + e)), w = Math.min(E, Q - (o + a)), h = A.imageSmoothingEnabled;
10305
- A.imageSmoothingEnabled = !1, t > 0 && A.drawImage(B, i, o, 1, a, i - t, o, t, a), D > 0 && A.drawImage(B, i + e - 1, o, 1, a, i + e, o, D, a), s > 0 && A.drawImage(B, i, o, e, 1, i, o - s, e, s), w > 0 && A.drawImage(B, i, o + a - 1, e, 1, i, o + a, e, w), t > 0 && s > 0 && A.drawImage(B, i, o, 1, 1, i - t, o - s, t, s), D > 0 && s > 0 && A.drawImage(B, i + e - 1, o, 1, 1, i + e, o - s, D, s), t > 0 && w > 0 && A.drawImage(B, i, o + a - 1, 1, 1, i - t, o + a, t, w), D > 0 && w > 0 && A.drawImage(B, i + e - 1, o + a - 1, 1, 1, i + e, o + a, D, w), A.imageSmoothingEnabled = h;
10304
+ const E = Math.max(1, Math.floor(C * 0.5)), o = I.x, i = I.y, e = I.w, a = I.h, t = Math.min(E, o), s = Math.min(E, i), D = Math.min(E, g - (o + e)), w = Math.min(E, Q - (i + a)), h = A.imageSmoothingEnabled;
10305
+ A.imageSmoothingEnabled = !1, t > 0 && A.drawImage(B, o, i, 1, a, o - t, i, t, a), D > 0 && A.drawImage(B, o + e - 1, i, 1, a, o + e, i, D, a), s > 0 && A.drawImage(B, o, i, e, 1, o, i - s, e, s), w > 0 && A.drawImage(B, o, i + a - 1, e, 1, o, i + a, e, w), t > 0 && s > 0 && A.drawImage(B, o, i, 1, 1, o - t, i - s, t, s), D > 0 && s > 0 && A.drawImage(B, o + e - 1, i, 1, 1, o + e, i - s, D, s), t > 0 && w > 0 && A.drawImage(B, o, i + a - 1, 1, 1, o - t, i + a, t, w), D > 0 && w > 0 && A.drawImage(B, o + e - 1, i + a - 1, 1, 1, o + e, i + a, D, w), A.imageSmoothingEnabled = h;
10306
10306
  }
10307
10307
  const DQ = `function x() {
10308
10308
  return {
@@ -10642,17 +10642,17 @@ function Xo() {
10642
10642
  aI(E), E.releaseGate(), E.reject(new NA(C.error));
10643
10643
  return;
10644
10644
  }
10645
- const i = (g = C.pages) != null ? g : [];
10646
- let o;
10647
- if (E.captureEncodedPng && i.length > 0) {
10645
+ const o = (g = C.pages) != null ? g : [];
10646
+ let i;
10647
+ if (E.captureEncodedPng && o.length > 0) {
10648
10648
  const e = [];
10649
- o = i.map(
10649
+ i = o.map(
10650
10650
  () => new Promise((a) => {
10651
10651
  e.push(a);
10652
10652
  })
10653
10653
  ), eI.set(C.id, {
10654
10654
  owner: B,
10655
- remaining: i.length,
10655
+ remaining: o.length,
10656
10656
  releaseGate: E.releaseGate,
10657
10657
  signal: E.signal,
10658
10658
  onAbort: E.onAbort,
@@ -10661,9 +10661,9 @@ function Xo() {
10661
10661
  } else
10662
10662
  aI(E), E.releaseGate();
10663
10663
  E.resolve({
10664
- pages: i.map((e, a) => ({
10664
+ pages: o.map((e, a) => ({
10665
10665
  ...e,
10666
- pngBytesPromise: o == null ? void 0 : o[a]
10666
+ pngBytesPromise: i == null ? void 0 : i[a]
10667
10667
  })),
10668
10668
  rects: (Q = C.rects) != null ? Q : []
10669
10669
  });
@@ -10691,24 +10691,24 @@ async function Oo(B, A) {
10691
10691
  try {
10692
10692
  Y(A.signal, "SVGA atlas worker task aborted");
10693
10693
  const g = [], Q = [];
10694
- for (const [i, o] of B)
10695
- g.push(i), Q.push(o);
10694
+ for (const [o, i] of B)
10695
+ g.push(o), Q.push(i);
10696
10696
  let C;
10697
10697
  try {
10698
10698
  C = Xo();
10699
- } catch (i) {
10700
- throw I(), new NA("SVGA atlas worker creation failed", { cause: i });
10699
+ } catch (o) {
10700
+ throw I(), new NA("SVGA atlas worker creation failed", { cause: o });
10701
10701
  }
10702
10702
  const E = vo++;
10703
- return await new Promise((i, o) => {
10703
+ return await new Promise((o, i) => {
10704
10704
  var e, a;
10705
10705
  const t = {
10706
10706
  owner: C,
10707
10707
  captureEncodedPng: A.captureEncodedPng,
10708
10708
  releaseGate: I,
10709
10709
  signal: A.signal,
10710
- resolve: i,
10711
- reject: o
10710
+ resolve: o,
10711
+ reject: i
10712
10712
  };
10713
10713
  if (t.onAbort = () => {
10714
10714
  WI(
@@ -10804,19 +10804,19 @@ async function _o(B, A, I, g, Q) {
10804
10804
  var C;
10805
10805
  const E = gA({
10806
10806
  maxBudgetMs: Q == null ? void 0 : Q.mainThreadFrameBudgetMs
10807
- }), i = async () => {
10807
+ }), o = async () => {
10808
10808
  Y(Q == null ? void 0 : Q.signal, "SVGA atlas build aborted"), E.shouldYield() && await E.yield(), Y(Q == null ? void 0 : Q.signal, "SVGA atlas build aborted");
10809
10809
  };
10810
10810
  Y(Q == null ? void 0 : Q.signal, "SVGA atlas build aborted");
10811
- const o = [];
10811
+ const i = [];
10812
10812
  for (const [s, D] of B)
10813
- o.push({ key: s, width: D.width, height: D.height }), await i();
10813
+ i.push({ key: s, width: D.width, height: D.height }), await o();
10814
10814
  const e = await Wo(
10815
- o,
10815
+ i,
10816
10816
  g,
10817
10817
  I,
10818
10818
  (C = Q == null ? void 0 : Q.maxPages) != null ? C : 4,
10819
- i
10819
+ o
10820
10820
  );
10821
10821
  if (e.length === 0)
10822
10822
  throw new Error("No atlas pages built");
@@ -10869,16 +10869,16 @@ async function $o(B, A, I, g, Q) {
10869
10869
  captureEncodedPng: (Q == null ? void 0 : Q.captureEncodedPng) === !0,
10870
10870
  workerTimeSliceMs: Q == null ? void 0 : Q.workerTimeSliceMs,
10871
10871
  signal: Q == null ? void 0 : Q.signal
10872
- }), i = /* @__PURE__ */ new Map();
10872
+ }), o = /* @__PURE__ */ new Map();
10873
10873
  for (const a of E.rects)
10874
- i.set(a.key, {
10874
+ o.set(a.key, {
10875
10875
  x: a.x,
10876
10876
  y: a.y,
10877
10877
  w: a.w,
10878
10878
  h: a.h,
10879
10879
  textureIndex: a.textureIndex
10880
10880
  });
10881
- const o = [], e = gA({
10881
+ const i = [], e = gA({
10882
10882
  maxBudgetMs: Q == null ? void 0 : Q.mainThreadFrameBudgetMs
10883
10883
  });
10884
10884
  try {
@@ -10894,7 +10894,7 @@ async function $o(B, A, I, g, Q) {
10894
10894
  t.bitmap.close();
10895
10895
  } catch (D) {
10896
10896
  }
10897
- o.push({
10897
+ i.push({
10898
10898
  textureHandle: s,
10899
10899
  atlasWidth: t.width,
10900
10900
  atlasHeight: t.height,
@@ -10907,10 +10907,10 @@ async function $o(B, A, I, g, Q) {
10907
10907
  t.bitmap.close();
10908
10908
  } catch (s) {
10909
10909
  }
10910
- for (const t of o) A.deleteTexture(t.textureHandle);
10910
+ for (const t of i) A.deleteTexture(t.textureHandle);
10911
10911
  throw a;
10912
10912
  }
10913
- return hQ(o, i);
10913
+ return hQ(i, o);
10914
10914
  }
10915
10915
  async function Ae(B, A, I = 4096, g = 2, Q) {
10916
10916
  var C;
@@ -10974,8 +10974,8 @@ async function Ee(B) {
10974
10974
  C.fileStart = 0, Q.onError = (E) => {
10975
10975
  g(new Error(`mp4box: ${E}`));
10976
10976
  }, Q.onReady = (E) => {
10977
- var i, o, e, a, t, s, D;
10978
- const w = (i = E.videoTracks) == null ? void 0 : i[0];
10977
+ var o, i, e, a, t, s, D;
10978
+ const w = (o = E.videoTracks) == null ? void 0 : o[0];
10979
10979
  if (!w) {
10980
10980
  g(new Error("mp4box: no video track"));
10981
10981
  return;
@@ -11003,7 +11003,7 @@ async function Ee(B) {
11003
11003
  codec: w.codec,
11004
11004
  timescale: w.timescale,
11005
11005
  durationSec: Number.isFinite(n) ? n : 0,
11006
- videoWidth: (a = (e = (o = w.video) == null ? void 0 : o.width) != null ? e : w.track_width) != null ? a : 0,
11006
+ videoWidth: (a = (e = (i = w.video) == null ? void 0 : i.width) != null ? e : w.track_width) != null ? a : 0,
11007
11007
  videoHeight: (D = (s = (t = w.video) == null ? void 0 : t.height) != null ? s : w.track_height) != null ? D : 0,
11008
11008
  samples: h
11009
11009
  });
@@ -11056,15 +11056,15 @@ async function ee(B, A, I, g) {
11056
11056
  var n, r, F, c;
11057
11057
  const G = ((r = (n = w.dts) != null ? n : w.cts) != null ? r : 0) - ((c = (F = h.dts) != null ? F : h.cts) != null ? c : 0);
11058
11058
  return G !== 0 ? G : 0;
11059
- }), i = [], o = new VideoDecoder({
11059
+ }), o = [], i = new VideoDecoder({
11060
11060
  output: (w) => {
11061
- i.push(w);
11061
+ o.push(w);
11062
11062
  },
11063
11063
  error: (w) => {
11064
11064
  throw w;
11065
11065
  }
11066
11066
  }), e = await te(B, A);
11067
- o.configure(e);
11067
+ i.configure(e);
11068
11068
  let a = 0;
11069
11069
  for (const w of E) {
11070
11070
  const h = w.data;
@@ -11078,28 +11078,28 @@ async function ee(B, A, I, g) {
11078
11078
  data: c
11079
11079
  });
11080
11080
  try {
11081
- o.decode(G);
11081
+ i.decode(G);
11082
11082
  } catch (y) {
11083
11083
  console.error("[GiftStage:WC] decoder.decode failed", { chunkIndex: a, err: y });
11084
11084
  try {
11085
- o.close();
11085
+ i.close();
11086
11086
  } catch (M) {
11087
11087
  }
11088
11088
  throw y;
11089
11089
  }
11090
11090
  a++, await new Promise((y) => queueMicrotask(y));
11091
11091
  }
11092
- await ie(o, "after last decode", 1e4);
11093
- const t = o.decodeQueueSize, s = i.length;
11094
- await oe(o, {
11092
+ await ie(i, "after last decode", 1e4);
11093
+ const t = i.decodeQueueSize, s = o.length;
11094
+ await oe(i, {
11095
11095
  chunksDecoded: a,
11096
11096
  outputsBeforeFlush: s,
11097
11097
  queueBeforeFlush: t
11098
- }), o.close(), i.sort((w, h) => w.timestamp - h.timestamp);
11099
- const D = Float64Array.from(i.map((w) => w.timestamp / 1e6));
11100
- if (i.length === 0)
11098
+ }), i.close(), o.sort((w, h) => w.timestamp - h.timestamp);
11099
+ const D = Float64Array.from(o.map((w) => w.timestamp / 1e6));
11100
+ if (o.length === 0)
11101
11101
  throw new Error("WebCodecs: decoder produced no frames");
11102
- return { frames: i, timesSec: D };
11102
+ return { frames: o, timesSec: D };
11103
11103
  }
11104
11104
  function Fg(B, A, I) {
11105
11105
  if (B.length === 0) return 0;
@@ -11109,8 +11109,8 @@ function Fg(B, A, I) {
11109
11109
  if (I >= A || I >= Q) return g - 1;
11110
11110
  let C = 0, E = g - 1;
11111
11111
  for (; C + 1 < E; ) {
11112
- const i = C + E >>> 1;
11113
- B[i] <= I ? C = i : E = i;
11112
+ const o = C + E >>> 1;
11113
+ B[o] <= I ? C = o : E = o;
11114
11114
  }
11115
11115
  return C;
11116
11116
  }
@@ -11119,13 +11119,13 @@ function ae(B, A, I) {
11119
11119
  const g = I.length - 1, Q = I[g], C = A.length > g ? A[g] : 0;
11120
11120
  let E = 0;
11121
11121
  Q.duration != null && Number.isFinite(Q.duration) && Q.duration > 0 ? E = Q.duration / 1e6 : A.length >= 2 ? E = A[g] - A[g - 1] : E = 1 / 30;
11122
- const i = C + E;
11123
- let o = B > 0 ? B : i;
11124
- if (!(o > 0) && A.length >= 2) {
11122
+ const o = C + E;
11123
+ let i = B > 0 ? B : o;
11124
+ if (!(i > 0) && A.length >= 2) {
11125
11125
  const e = (A[A.length - 1] - A[0]) / (A.length - 1);
11126
- o = A[A.length - 1] + (e > 0 ? e : 1 / 30);
11126
+ i = A[A.length - 1] + (e > 0 ? e : 1 / 30);
11127
11127
  }
11128
- return o > 0 || (o = Math.max(i, 1 / 30)), o;
11128
+ return i > 0 || (i = Math.max(o, 1 / 30)), i;
11129
11129
  }
11130
11130
  async function te(B, A) {
11131
11131
  var I;
@@ -11184,13 +11184,13 @@ class ce {
11184
11184
  const I = Math.max(4, Math.floor(this.maxSize * 0.35)), g = Math.max(4, this.maxSize - I - 2);
11185
11185
  for (; this.map.size > this.maxSize; ) {
11186
11186
  const Q = this.playbackHint;
11187
- let C, E, i, o = -1;
11187
+ let C, E, o, i = -1;
11188
11188
  for (const a of this.map.keys()) {
11189
11189
  a < Q - I && (C === void 0 || a < C) && (C = a), a > Q + g && (E === void 0 || a > E) && (E = a);
11190
11190
  const t = Math.abs(a - Q);
11191
- t >= o && (o = t, i = a);
11191
+ t >= i && (i = t, o = a);
11192
11192
  }
11193
- const e = (A = C != null ? C : E) != null ? A : i;
11193
+ const e = (A = C != null ? C : E) != null ? A : o;
11194
11194
  if (e === void 0) return;
11195
11195
  this.closeKey(e);
11196
11196
  }
@@ -11216,8 +11216,8 @@ class ce {
11216
11216
  frameForDisplay(A) {
11217
11217
  var I;
11218
11218
  let g = -1, Q = Number.POSITIVE_INFINITY, C = -1;
11219
- for (const i of this.map.keys())
11220
- i <= A && i > g && (g = i), i >= A && i < Q && (Q = i), i > C && (C = i);
11219
+ for (const o of this.map.keys())
11220
+ o <= A && o > g && (g = o), o >= A && o < Q && (Q = o), o > C && (C = o);
11221
11221
  const E = g >= 0 ? g : Number.isFinite(Q) ? Q : C;
11222
11222
  return E >= 0 && (I = this.map.get(E)) != null ? I : null;
11223
11223
  }
@@ -11246,8 +11246,8 @@ function JB(B, A, I) {
11246
11246
  return;
11247
11247
  }
11248
11248
  setTimeout(E, 0);
11249
- } catch (i) {
11250
- Q(i instanceof Error ? i : new Error(String(i)));
11249
+ } catch (o) {
11250
+ Q(o instanceof Error ? o : new Error(String(o)));
11251
11251
  }
11252
11252
  };
11253
11253
  setTimeout(E, 0);
@@ -11255,8 +11255,8 @@ function JB(B, A, I) {
11255
11255
  }
11256
11256
  let re = 1;
11257
11257
  class uA {
11258
- constructor(A, I, g, Q, C, E, i, o, e, a, t) {
11259
- X(this, "duration"), X(this, "videoWidth"), X(this, "videoHeight"), X(this, "timesSec"), X(this, "worker"), X(this, "workerMsgId"), X(this, "streaming"), X(this, "ring"), X(this, "frames"), X(this, "maxDecodedFrames"), X(this, "decodeAheadFrames"), X(this, "lastWrapped", -1), X(this, "lastEnsureNeedIdx", -1), X(this, "lastEnsureFreeSlots", -1), X(this, "destroyed", !1), this.duration = A, this.videoWidth = I, this.videoHeight = g, this.timesSec = Q, this.worker = C, this.workerMsgId = E, this.streaming = i, this.ring = o, this.frames = e, this.maxDecodedFrames = a, this.decodeAheadFrames = t;
11258
+ constructor(A, I, g, Q, C, E, o, i, e, a, t) {
11259
+ X(this, "duration"), X(this, "videoWidth"), X(this, "videoHeight"), X(this, "timesSec"), X(this, "worker"), X(this, "workerMsgId"), X(this, "streaming"), X(this, "ring"), X(this, "frames"), X(this, "maxDecodedFrames"), X(this, "decodeAheadFrames"), X(this, "lastWrapped", -1), X(this, "lastEnsureNeedIdx", -1), X(this, "lastEnsureFreeSlots", -1), X(this, "destroyed", !1), this.duration = A, this.videoWidth = I, this.videoHeight = g, this.timesSec = Q, this.worker = C, this.workerMsgId = E, this.streaming = o, this.ring = i, this.frames = e, this.maxDecodedFrames = a, this.decodeAheadFrames = t;
11260
11260
  }
11261
11261
  /**
11262
11262
  * Fetch MP4 (if URL) → demux + H.264 decode in Worker (default) or main thread.
@@ -11266,26 +11266,26 @@ class uA {
11266
11266
  var Q, C;
11267
11267
  if (typeof VideoDecoder == "undefined")
11268
11268
  throw new Error("WebCodecs VideoDecoder not available");
11269
- const E = (g == null ? void 0 : g.useWorker) !== !1, i = (Q = g == null ? void 0 : g.maxDecodedFrames) != null ? Q : he, o = (C = g == null ? void 0 : g.decodeAheadFrames) != null ? C : ne;
11269
+ const E = (g == null ? void 0 : g.useWorker) !== !1, o = (Q = g == null ? void 0 : g.maxDecodedFrames) != null ? Q : he, i = (C = g == null ? void 0 : g.decodeAheadFrames) != null ? C : ne;
11270
11270
  let e;
11271
11271
  if (typeof A == "string" ? e = await Fe(A, I) : e = A, E && typeof Worker != "undefined") {
11272
11272
  const a = e.slice(0);
11273
11273
  try {
11274
- return await uA.createViaWorker(a, i, o);
11274
+ return await uA.createViaWorker(a, o, i);
11275
11275
  } catch (t) {
11276
11276
  console.warn("[GiftStage:WC] Worker decode failed, falling back to main thread", t);
11277
11277
  }
11278
11278
  }
11279
- return uA.createOnMainThread(e, i, o);
11279
+ return uA.createOnMainThread(e, o, i);
11280
11280
  }
11281
11281
  static async createViaWorker(A, I, g) {
11282
11282
  const Q = new se(), C = re++, E = new ce(I);
11283
- let i = 0, o = 0, e = 0, a = new Float64Array(0), t = !1, s = null;
11283
+ let o = 0, i = 0, e = 0, a = new Float64Array(0), t = !1, s = null;
11284
11284
  const D = (F) => {
11285
11285
  const c = F.data;
11286
11286
  if (!(!c || c.id !== C)) {
11287
11287
  if (c.type === "meta") {
11288
- i = c.duration, o = c.videoWidth, e = c.videoHeight;
11288
+ o = c.duration, i = c.videoWidth, e = c.videoHeight;
11289
11289
  const G = c.timesSec;
11290
11290
  a = new Float64Array(
11291
11291
  G.buffer,
@@ -11317,17 +11317,17 @@ class uA {
11317
11317
  );
11318
11318
  try {
11319
11319
  if (await JB(() => t || s != null, 6e4, "meta"), s) throw s;
11320
- const F = i > 0 ? i : 1e-6, c = Fg(a, F, 0);
11320
+ const F = o > 0 ? o : 1e-6, c = Fg(a, F, 0);
11321
11321
  if (await JB(() => s != null || E.bestAtOrBefore(c) != null, 6e4, "first frame"), s) throw s;
11322
11322
  } catch (F) {
11323
11323
  throw Q.removeEventListener("message", D), Q.removeEventListener("error", w), Q.terminate(), E.clear(), F instanceof Error ? F : new Error(String(F));
11324
11324
  }
11325
11325
  const n = a.length > 0 ? a[0] : 0, r = a.length > 0 ? a[a.length - 1] : 0;
11326
11326
  return console.info(
11327
- `[GiftStage:WC] worker streaming ready frames=${a.length} duration=${i.toFixed(4)}s size=${o}x${e} times=[${n.toFixed(4)} … ${r.toFixed(4)}] ring=${I}`
11327
+ `[GiftStage:WC] worker streaming ready frames=${a.length} duration=${o.toFixed(4)}s size=${i}x${e} times=[${n.toFixed(4)} … ${r.toFixed(4)}] ring=${I}`
11328
11328
  ), new uA(
11329
- i,
11330
11329
  o,
11330
+ i,
11331
11331
  e,
11332
11332
  a,
11333
11333
  Q,
@@ -11344,16 +11344,16 @@ class uA {
11344
11344
  const Q = await Ee(A);
11345
11345
  if (Q.samples.length === 0)
11346
11346
  throw new Error("mp4box: no samples");
11347
- const E = Q.samples[0].description, i = E ? await Ce(E) : void 0;
11347
+ const E = Q.samples[0].description, o = E ? await Ce(E) : void 0;
11348
11348
  console.info("[GiftStage:WC] VideoDecoder decode (main thread)…");
11349
- const { frames: o, timesSec: e } = await ee(
11349
+ const { frames: i, timesSec: e } = await ee(
11350
11350
  Q.codec,
11351
- i,
11351
+ o,
11352
11352
  Q.samples,
11353
11353
  Q.timescale
11354
- ), a = o[o.length - 1], t = ae(Q.durationSec, e, o), s = Q.videoWidth || a.displayWidth || a.codedWidth || 0, D = Q.videoHeight || a.displayHeight || a.codedHeight || 0, w = e.length > 0 ? e[0] : 0, h = e.length > 0 ? e[e.length - 1] : 0;
11354
+ ), a = i[i.length - 1], t = ae(Q.durationSec, e, i), s = Q.videoWidth || a.displayWidth || a.codedWidth || 0, D = Q.videoHeight || a.displayHeight || a.codedHeight || 0, w = e.length > 0 ? e[0] : 0, h = e.length > 0 ? e[e.length - 1] : 0;
11355
11355
  return console.info(
11356
- `[GiftStage:WC] main decode ok frames=${o.length} duration=${t.toFixed(4)}s size=${s}x${D} times=[${w.toFixed(4)} … ${h.toFixed(4)}]`
11356
+ `[GiftStage:WC] main decode ok frames=${i.length} duration=${t.toFixed(4)}s size=${s}x${D} times=[${w.toFixed(4)} … ${h.toFixed(4)}]`
11357
11357
  ), new uA(
11358
11358
  t,
11359
11359
  s,
@@ -11363,7 +11363,7 @@ class uA {
11363
11363
  0,
11364
11364
  !1,
11365
11365
  null,
11366
- o,
11366
+ i,
11367
11367
  I,
11368
11368
  g
11369
11369
  );
@@ -11371,11 +11371,11 @@ class uA {
11371
11371
  ensureDecodedThrough(A) {
11372
11372
  var I, g, Q, C, E;
11373
11373
  if (this.destroyed || !this.streaming || !this.worker) return;
11374
- const i = this.duration > 0 ? this.duration : 1e-6;
11375
- if (!Number.isFinite(A) || !Number.isFinite(i)) return;
11376
- const o = (A % i + i) % i;
11377
- if (this.lastWrapped >= 0 && o < this.lastWrapped - 1e-3 && this.lastWrapped > i * 0.1 && ((I = this.ring) == null || I.clear(), this.lastEnsureNeedIdx = -1, this.lastEnsureFreeSlots = -1, this.worker.postMessage({ type: "rewind", id: this.workerMsgId })), this.lastWrapped = o, this.timesSec.length === 0) return;
11378
- const e = Fg(this.timesSec, i, o);
11374
+ const o = this.duration > 0 ? this.duration : 1e-6;
11375
+ if (!Number.isFinite(A) || !Number.isFinite(o)) return;
11376
+ const i = (A % o + o) % o;
11377
+ if (this.lastWrapped >= 0 && i < this.lastWrapped - 1e-3 && this.lastWrapped > o * 0.1 && ((I = this.ring) == null || I.clear(), this.lastEnsureNeedIdx = -1, this.lastEnsureFreeSlots = -1, this.worker.postMessage({ type: "rewind", id: this.workerMsgId })), this.lastWrapped = i, this.timesSec.length === 0) return;
11378
+ const e = Fg(this.timesSec, o, i);
11379
11379
  (g = this.ring) == null || g.setPlaybackHint(e);
11380
11380
  const a = (Q = this.ring) == null ? void 0 : Q.minKey(), t = Math.max(4, this.decodeAheadFrames);
11381
11381
  this.ring && a !== void 0 && a > e + t && (this.ring.clear(), this.lastEnsureNeedIdx = -1, this.lastEnsureFreeSlots = -1, this.worker.postMessage({ type: "rewind", id: this.workerMsgId }));
@@ -11400,14 +11400,14 @@ class uA {
11400
11400
  clip: C,
11401
11401
  frames: this.timesSec.length
11402
11402
  }), this.streaming && this.ring ? this.ring.frameForDisplay(0) : (g = (I = this.frames) == null ? void 0 : I[0]) != null ? g : null;
11403
- const E = (A % C + C) % C, i = Fg(this.timesSec, C, E);
11403
+ const E = (A % C + C) % C, o = Fg(this.timesSec, C, E);
11404
11404
  if (this.streaming && this.ring) {
11405
- this.ring.setPlaybackHint(i);
11406
- const e = this.ring.frameForDisplay(i);
11407
- return e || console.warn("[GiftStage:WC] getFrameForTime no frame in ring", { idx: i, wrapped: E, clip: C }), e;
11405
+ this.ring.setPlaybackHint(o);
11406
+ const e = this.ring.frameForDisplay(o);
11407
+ return e || console.warn("[GiftStage:WC] getFrameForTime no frame in ring", { idx: o, wrapped: E, clip: C }), e;
11408
11408
  }
11409
- const o = (Q = this.frames) == null ? void 0 : Q[i];
11410
- return o || console.warn("[GiftStage:WC] getFrameForTime missing frame at index", { idx: i, wrapped: E, clip: C }), o != null ? o : null;
11409
+ const i = (Q = this.frames) == null ? void 0 : Q[o];
11410
+ return i || console.warn("[GiftStage:WC] getFrameForTime missing frame at index", { idx: o, wrapped: E, clip: C }), i != null ? i : null;
11411
11411
  }
11412
11412
  destroy() {
11413
11413
  var A;
@@ -11437,7 +11437,7 @@ async function Fe(B, A) {
11437
11437
  return TA(B, A);
11438
11438
  }
11439
11439
  function LB(B, A, I, g, Q) {
11440
- const C = Math.max(1, Math.floor(A)), E = Math.max(1, Math.floor(I)), i = Math.max(1, B.width * B.scale), o = Math.max(1, B.height * B.scale);
11440
+ const C = Math.max(1, Math.floor(A)), E = Math.max(1, Math.floor(I)), o = Math.max(1, B.width * B.scale), i = Math.max(1, B.height * B.scale);
11441
11441
  let e;
11442
11442
  const a = DA(B);
11443
11443
  if (a === "contain" || a === "cover") {
@@ -11446,15 +11446,15 @@ function LB(B, A, I, g, Q) {
11446
11446
  t = C * 0.5, s = E;
11447
11447
  else {
11448
11448
  if (!Q)
11449
- return e = Math.min(1, i / C, o / E), Gg(C, E, e);
11449
+ return e = Math.min(1, o / C, i / E), Gg(C, E, e);
11450
11450
  ({ w: t, h: s } = dA(Q.info));
11451
11451
  }
11452
11452
  if (!(t > 0) || !(s > 0))
11453
- return e = Math.min(1, i / C, o / E), Gg(C, E, e);
11454
- const D = a === "cover" ? Math.max(i / t, o / s) : Math.min(i / t, o / s);
11453
+ return e = Math.min(1, o / C, i / E), Gg(C, E, e);
11454
+ const D = a === "cover" ? Math.max(o / t, i / s) : Math.min(o / t, i / s);
11455
11455
  e = Math.min(1, D);
11456
11456
  } else
11457
- e = Math.min(1, i / C, o / E);
11457
+ e = Math.min(1, o / C, i / E);
11458
11458
  return Gg(C, E, e);
11459
11459
  }
11460
11460
  function Gg(B, A, I) {
@@ -11497,7 +11497,7 @@ function HB(B, A, I, g = !1) {
11497
11497
  return B.activeTexture(B.TEXTURE0 + A), B.bindTexture(B.TEXTURE_2D, Q), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_MIN_FILTER, B.LINEAR), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_MAG_FILTER, B.LINEAR), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_WRAP_S, B.CLAMP_TO_EDGE), B.texParameteri(B.TEXTURE_2D, B.TEXTURE_WRAP_T, B.CLAMP_TO_EDGE), I ? (B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL, g ? 1 : 0), B.texImage2D(B.TEXTURE_2D, 0, B.RGBA, B.RGBA, B.UNSIGNED_BYTE, I), B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL, 0)) : B.texImage2D(B.TEXTURE_2D, 0, B.RGBA, 1, 1, 0, B.RGBA, B.UNSIGNED_BYTE, null), Q;
11498
11498
  }
11499
11499
  function Ne(B) {
11500
- const [A, I, g, Q] = B.rgbFrame, [C, E, i, o] = B.aFrame, e = ZI(A, I, g, Q, B.videoW, B.videoH), a = ZI(C, E, i, o, B.videoW, B.videoH);
11500
+ const [A, I, g, Q] = B.rgbFrame, [C, E, o, i] = B.aFrame, e = ZI(A, I, g, Q, B.videoW, B.videoH), a = ZI(C, E, o, i, B.videoW, B.videoH);
11501
11501
  return new Float32Array([
11502
11502
  -1,
11503
11503
  1,
@@ -11527,11 +11527,11 @@ function Ne(B) {
11527
11527
  }
11528
11528
  function Se(B, A, I) {
11529
11529
  const g = Math.max(1, A) * GI, Q = [], C = [], E = I ? "texture" : "texture2D";
11530
- for (let o = 0; o < B; o++)
11531
- Q.push(`uniform sampler2D u_image${o + 1};`), C.push(
11532
- `if (ndx == ${o + 1}) { color = ${E}(u_image${o + 1}, uv); }`
11530
+ for (let i = 0; i < B; i++)
11531
+ Q.push(`uniform sampler2D u_image${i + 1};`), C.push(
11532
+ `if (ndx == ${i + 1}) { color = ${E}(u_image${i + 1}, uv); }`
11533
11533
  );
11534
- const i = I ? "fragColor" : "gl_FragColor";
11534
+ const o = I ? "fragColor" : "gl_FragColor";
11535
11535
  return `${I ? "#version 300 es" : ""}
11536
11536
  precision lowp float;
11537
11537
  ${I ? "in" : "varying"} vec2 v_texcoord;
@@ -11590,7 +11590,7 @@ function Se(B, A, I) {
11590
11590
  }
11591
11591
  }
11592
11592
 
11593
- ${i} = bgColor;
11593
+ ${o} = bgColor;
11594
11594
  }
11595
11595
  `;
11596
11596
  }
@@ -11622,14 +11622,14 @@ function le(B, A, I, g, Q = new Float32Array(
11622
11622
  Q.fill(0);
11623
11623
  const C = A.get(g);
11624
11624
  if (!C || C.length === 0) return Q;
11625
- const [E, i] = B.info.rgbFrame;
11626
- let o = 0;
11625
+ const [E, o] = B.info.rgbFrame;
11626
+ let i = 0;
11627
11627
  for (const e of C) {
11628
11628
  const a = I.get(String(e.srcId));
11629
11629
  if (!a) continue;
11630
- if (o + GI > Q.length) break;
11631
- const [t, s, D, w] = e.frame, [h, n, r, F] = e.mFrame, c = ZI(t + E, s + i, D, w, B.info.videoW, B.info.videoH), G = ZI(h, n, r, F, B.info.videoW, B.info.videoH);
11632
- Q[o++] = a, Q[o++] = c[0], Q[o++] = c[1], Q[o++] = c[2], Q[o++] = c[3], Q[o++] = G[0], Q[o++] = G[1], Q[o++] = G[2], Q[o++] = G[3];
11630
+ if (i + GI > Q.length) break;
11631
+ const [t, s, D, w] = e.frame, [h, n, r, F] = e.mFrame, c = ZI(t + E, s + o, D, w, B.info.videoW, B.info.videoH), G = ZI(h, n, r, F, B.info.videoW, B.info.videoH);
11632
+ Q[i++] = a, Q[i++] = c[0], Q[i++] = c[1], Q[i++] = c[2], Q[i++] = c[3], Q[i++] = G[0], Q[i++] = G[1], Q[i++] = G[2], Q[i++] = G[3];
11633
11633
  }
11634
11634
  return Q;
11635
11635
  }
@@ -11639,7 +11639,7 @@ class Ye {
11639
11639
  var E;
11640
11640
  if (g.size === 0) throw new Error("VAP mix composer requires at least one slot resource");
11641
11641
  this.canvas = ye(Q, C);
11642
- const i = {
11642
+ const o = {
11643
11643
  alpha: !0,
11644
11644
  antialias: !1,
11645
11645
  depth: !1,
@@ -11647,10 +11647,10 @@ class Ye {
11647
11647
  preserveDrawingBuffer: !1,
11648
11648
  stencil: !1
11649
11649
  };
11650
- let o = !0, e = this.canvas.getContext("webgl2", i);
11651
- if (e || (o = !1, e = this.canvas.getContext("webgl", i) || this.canvas.getContext(
11650
+ let i = !0, e = this.canvas.getContext("webgl2", o);
11651
+ if (e || (i = !1, e = this.canvas.getContext("webgl", o) || this.canvas.getContext(
11652
11652
  "experimental-webgl",
11653
- i
11653
+ o
11654
11654
  )), !e) throw new Error("VAP mixed rendering requires WebGL support");
11655
11655
  this.gl = e;
11656
11656
  const a = Math.max(1, e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)), t = Math.max(0, a - 1), s = [];
@@ -11685,7 +11685,7 @@ class Ye {
11685
11685
  const h = Ue(
11686
11686
  this.resourceEntries.length,
11687
11687
  w,
11688
- o
11688
+ i
11689
11689
  ), n = Me(e, h.vertex, h.fragment);
11690
11690
  this.program = n.program, this.vertexShader = n.vertexShader, this.fragmentShader = n.fragmentShader, this.imagePosLoc = e.getUniformLocation(this.program, "image_pos"), this.videoTexture = HB(e, 0);
11691
11691
  const r = e.getUniformLocation(this.program, "u_image_video");
@@ -11746,9 +11746,9 @@ class Le {
11746
11746
  let Q = this.buffer.byteLength;
11747
11747
  for (; Q < g; ) Q *= 2;
11748
11748
  const C = new ArrayBuffer(Q), E = new Uint8Array(C);
11749
- for (let i = 0; i < this.offset; i += cA) {
11750
- const o = Math.min(i + cA, this.offset);
11751
- E.set(this.bytes.subarray(i, o), i), o < this.offset && await (I == null ? void 0 : I());
11749
+ for (let o = 0; o < this.offset; o += cA) {
11750
+ const i = Math.min(o + cA, this.offset);
11751
+ E.set(this.bytes.subarray(o, i), o), i < this.offset && await (I == null ? void 0 : I());
11752
11752
  }
11753
11753
  this.buffer = C, this.view = new DataView(this.buffer), this.bytes = E;
11754
11754
  }
@@ -11882,29 +11882,29 @@ async function EA(B) {
11882
11882
  }
11883
11883
  async function He(B, A) {
11884
11884
  var I, g, Q;
11885
- const C = B.spriteTable, E = gA({ maxBudgetMs: A }), i = () => EA(E), o = new Le(Je + GQ(B) + cA);
11886
- o.u32(cQ), o.u16(rQ), o.u16(0), o.f32(B.params.viewBoxWidth), o.f32(B.params.viewBoxHeight), o.f32(B.params.fps), o.u32(B.params.frames), o.u32(B.atlasPages.length);
11885
+ const C = B.spriteTable, E = gA({ maxBudgetMs: A }), o = () => EA(E), i = new Le(Je + GQ(B) + cA);
11886
+ i.u32(cQ), i.u16(rQ), i.u16(0), i.f32(B.params.viewBoxWidth), i.f32(B.params.viewBoxHeight), i.f32(B.params.fps), i.u32(B.params.frames), i.u32(B.atlasPages.length);
11887
11887
  for (const e of B.atlasPages)
11888
- o.u32(e.width), o.u32(e.height), await o.bytesValueCooperative(new Uint8Array(e.imageBytes), i), await EA(E);
11889
- o.u32(B.atlasRects.size);
11888
+ i.u32(e.width), i.u32(e.height), await i.bytesValueCooperative(new Uint8Array(e.imageBytes), o), await EA(E);
11889
+ i.u32(B.atlasRects.size);
11890
11890
  for (const [e, a] of B.atlasRects)
11891
- await o.stringCooperative(e, i), o.u32((I = a.textureIndex) != null ? I : 0), o.f32(a.x), o.f32(a.y), o.f32(a.w), o.f32(a.h), await EA(E);
11892
- o.u32(B.audios.length);
11891
+ await i.stringCooperative(e, o), i.u32((I = a.textureIndex) != null ? I : 0), i.f32(a.x), i.f32(a.y), i.f32(a.w), i.f32(a.h), await EA(E);
11892
+ i.u32(B.audios.length);
11893
11893
  for (const e of B.audios)
11894
- await o.stringCooperative(e.audioKey, i), o.u32(e.startFrame), o.u32(e.endFrame), o.f32(e.startTime), o.f32(e.totalTime), await EA(E);
11895
- o.u32(B.audioBlobs.size);
11894
+ await i.stringCooperative(e.audioKey, o), i.u32(e.startFrame), i.u32(e.endFrame), i.f32(e.startTime), i.f32(e.totalTime), await EA(E);
11895
+ i.u32(B.audioBlobs.size);
11896
11896
  for (const [e, a] of B.audioBlobs)
11897
- await o.stringCooperative(e, i), await o.bytesValueCooperative(new Uint8Array(a), i), await EA(E);
11898
- if (await wo(o, C, i), o.u32((Q = (g = B.clipMeshes) == null ? void 0 : g.size) != null ? Q : 0), B.clipMeshes)
11897
+ await i.stringCooperative(e, o), await i.bytesValueCooperative(new Uint8Array(a), o), await EA(E);
11898
+ if (await wo(i, C, o), i.u32((Q = (g = B.clipMeshes) == null ? void 0 : g.size) != null ? Q : 0), B.clipMeshes)
11899
11899
  for (const [e, a] of B.clipMeshes)
11900
- await o.stringCooperative(e, i), await o.bytesValueCooperative(
11900
+ await i.stringCooperative(e, o), await i.bytesValueCooperative(
11901
11901
  new Uint8Array(a.vertices.buffer, a.vertices.byteOffset, a.vertices.byteLength),
11902
- i
11903
- ), await o.bytesValueCooperative(
11902
+ o
11903
+ ), await i.bytesValueCooperative(
11904
11904
  new Uint8Array(a.indices.buffer, a.indices.byteOffset, a.indices.byteLength),
11905
- i
11905
+ o
11906
11906
  ), await EA(E);
11907
- return o.finishCooperative(E);
11907
+ return i.finishCooperative(E);
11908
11908
  }
11909
11909
  async function ue(B, A) {
11910
11910
  const I = gA({ maxBudgetMs: A }), g = new fe(B);
@@ -11921,10 +11921,10 @@ async function ue(B, A) {
11921
11921
  const r = g.u32(), F = g.u32(), c = await g.ownedBytesValueCooperative(I);
11922
11922
  E.push({ width: r, height: F, imageBytes: c }), await EA(I);
11923
11923
  }
11924
- const i = g.u32(), o = /* @__PURE__ */ new Map();
11925
- for (let n = 0; n < i; n++) {
11924
+ const o = g.u32(), i = /* @__PURE__ */ new Map();
11925
+ for (let n = 0; n < o; n++) {
11926
11926
  const r = g.string(), F = g.u32();
11927
- o.set(r, {
11927
+ i.set(r, {
11928
11928
  textureIndex: F,
11929
11929
  x: g.f32(),
11930
11930
  y: g.f32(),
@@ -11956,7 +11956,7 @@ async function ue(B, A) {
11956
11956
  spriteTable: D,
11957
11957
  audios: a,
11958
11958
  audioBlobs: s,
11959
- atlasRects: o,
11959
+ atlasRects: i,
11960
11960
  atlasPages: E,
11961
11961
  clipMeshes: h
11962
11962
  };
@@ -11991,21 +11991,21 @@ function pe(B, A) {
11991
11991
  return { width: I, height: g };
11992
11992
  }
11993
11993
  function xe(B, A, I, g) {
11994
- const Q = MA(A.width) ? A.width : void 0, C = MA(A.height) ? A.height : void 0, E = MA(B.width) ? B.width : void 0, i = MA(B.height) ? B.height : void 0, o = B.useOriginalSize === !0;
11995
- if (E && i)
11996
- return { width: E, height: i };
11994
+ const Q = MA(A.width) ? A.width : void 0, C = MA(A.height) ? A.height : void 0, E = MA(B.width) ? B.width : void 0, o = MA(B.height) ? B.height : void 0, i = B.useOriginalSize === !0;
11995
+ if (E && o)
11996
+ return { width: E, height: o };
11997
11997
  if (E)
11998
11998
  return Q && C ? {
11999
11999
  width: E,
12000
12000
  height: E * C / Q
12001
12001
  } : { width: E, height: E };
12002
- if (i)
12002
+ if (o)
12003
12003
  return Q && C ? {
12004
- width: i * Q / C,
12005
- height: i
12006
- } : { width: i, height: i };
12004
+ width: o * Q / C,
12005
+ height: o
12006
+ } : { width: o, height: o };
12007
12007
  let e = Q != null ? Q : 0, a = C != null ? C : 0;
12008
- if (e > 0 && a > 0 && MA(I) && MA(g) && (!o || e > I || a > g)) {
12008
+ if (e > 0 && a > 0 && MA(I) && MA(g) && (!i || e > I || a > g)) {
12009
12009
  const t = Math.min(I / e, g / a);
12010
12010
  e *= t, a *= t;
12011
12011
  }
@@ -12144,7 +12144,7 @@ const ZA = class lA {
12144
12144
  }
12145
12145
  resolveAnimationStepTarget(A, I) {
12146
12146
  var g, Q, C, E;
12147
- const { sx: i, sy: o } = yg(this.canvas), e = (g = I.scaleTo) != null ? g : A.scale, a = I.flyTo != null ? I.flyTo.x * i : A.x + A.width * A.scale / 2, t = I.flyTo != null ? I.flyTo.y * o : A.y + A.height * A.scale / 2;
12147
+ const { sx: o, sy: i } = yg(this.canvas), e = (g = I.scaleTo) != null ? g : A.scale, a = I.flyTo != null ? I.flyTo.x * o : A.x + A.width * A.scale / 2, t = I.flyTo != null ? I.flyTo.y * i : A.y + A.height * A.scale / 2;
12148
12148
  return {
12149
12149
  targetX: a - A.width * e / 2,
12150
12150
  targetY: t - A.height * e / 2,
@@ -12172,14 +12172,14 @@ const ZA = class lA {
12172
12172
  }
12173
12173
  createGiftAnimationChain(A, I, g) {
12174
12174
  const Q = Array.isArray(g) ? [...g] : g ? [g] : [], C = [];
12175
- let E = !1, i = !1, o = null, e = null;
12175
+ let E = !1, o = !1, i = null, e = null;
12176
12176
  const a = (s) => new Promise((D) => {
12177
- if (i) {
12177
+ if (o) {
12178
12178
  D();
12179
12179
  return;
12180
12180
  }
12181
- e = D, o = setTimeout(() => {
12182
- o = null, e = null, D();
12181
+ e = D, i = setTimeout(() => {
12182
+ i = null, e = null, D();
12183
12183
  }, Math.max(0, s));
12184
12184
  }), t = {
12185
12185
  to: (s) => {
@@ -12206,46 +12206,46 @@ const ZA = class lA {
12206
12206
  s === "afterGiftComplete" && await this.waitForGiftPlaybackComplete(A.id);
12207
12207
  let n = !1;
12208
12208
  for (const r of Q) {
12209
- if (i || !((w = this.manager) != null && w.getSlot(A.id)) || A.state === "finished") {
12209
+ if (o || !((w = this.manager) != null && w.getSlot(A.id)) || A.state === "finished") {
12210
12210
  n = !0;
12211
12211
  break;
12212
12212
  }
12213
12213
  Te(r) ? await a(r.delayMs) : await this.runGiftAnimationStep(A, I, r);
12214
12214
  }
12215
- if (!n && !i)
12215
+ if (!n && !o)
12216
12216
  for (const r of C) r(I);
12217
12217
  return I;
12218
12218
  },
12219
12219
  cancel: () => {
12220
12220
  var s;
12221
- i = !0, o != null && (clearTimeout(o), o = null), e == null || e(), e = null, (s = this.manager) == null || s.postAnimator.cancelForGift(A.id);
12221
+ o = !0, i != null && (clearTimeout(i), i = null), e == null || e(), e = null, (s = this.manager) == null || s.postAnimator.cancelForGift(A.id);
12222
12222
  }
12223
12223
  };
12224
12224
  return t;
12225
12225
  }
12226
12226
  async addGift(A) {
12227
- var I, g, Q, C, E, i;
12227
+ var I, g, Q, C, E, o;
12228
12228
  if (console.info("[GiftStage] addGift await ready…", A.type), await this.ready, console.info("[GiftStage] addGift ready, loading…", A.type), this.destroyed) throw new Error("GiftStage is destroyed");
12229
- const o = await this.normalizeAddGiftOptions(A), e = AE(), { sx: a, sy: t } = yg(this.canvas), s = BQ(
12230
- o.x,
12231
- o.y,
12232
- o.width,
12233
- o.height,
12229
+ const i = await this.normalizeAddGiftOptions(A), e = AE(), { sx: a, sy: t } = yg(this.canvas), s = BQ(
12230
+ i.x,
12231
+ i.y,
12232
+ i.width,
12233
+ i.height,
12234
12234
  this.canvas.clientWidth,
12235
12235
  this.canvas.clientHeight
12236
12236
  ), D = {
12237
12237
  id: e,
12238
- type: o.type,
12238
+ type: i.type,
12239
12239
  state: "loading",
12240
- options: o,
12241
- zIndex: (I = o.zIndex) != null ? I : 0,
12240
+ options: i,
12241
+ zIndex: (I = i.zIndex) != null ? I : 0,
12242
12242
  renderOrder: this.nextRenderOrder++,
12243
12243
  x: s.x * a,
12244
12244
  y: s.y * t,
12245
- width: o.width * a,
12246
- height: o.height * t,
12245
+ width: i.width * a,
12246
+ height: i.height * t,
12247
12247
  scale: 1,
12248
- opacity: uB((g = o.opacity) != null ? g : 1),
12248
+ opacity: uB((g = i.opacity) != null ? g : 1),
12249
12249
  paused: !1,
12250
12250
  currentFrame: 0,
12251
12251
  accumulatedTime: 0,
@@ -12272,7 +12272,7 @@ const ZA = class lA {
12272
12272
  let w;
12273
12273
  w = {
12274
12274
  id: e,
12275
- type: o.type,
12275
+ type: i.type,
12276
12276
  pause: () => {
12277
12277
  D.paused = !0;
12278
12278
  },
@@ -12284,23 +12284,23 @@ const ZA = class lA {
12284
12284
  },
12285
12285
  animate: (n) => this.createGiftAnimationChain(D, w, n)
12286
12286
  };
12287
- const h = o.onComplete;
12287
+ const h = i.onComplete;
12288
12288
  D.onComplete = (n) => {
12289
12289
  this.markGiftPlaybackComplete(D.id), h == null || h(n);
12290
12290
  }, this.manager.addSlot(D, w);
12291
12291
  try {
12292
- switch (o.type) {
12292
+ switch (i.type) {
12293
12293
  case "svga":
12294
12294
  await this.loadSVGA(D);
12295
12295
  break;
12296
12296
  case "vap":
12297
- await this.loadVAP(D, o);
12297
+ await this.loadVAP(D, i);
12298
12298
  break;
12299
12299
  case "alphaVideo":
12300
- await this.loadAlphaVideo(D, o);
12300
+ await this.loadAlphaVideo(D, i);
12301
12301
  break;
12302
12302
  }
12303
- this.assertSlotLoadActive(D), D.state = "playing", o.type === "svga" && D.videoEntity && this.manager.audioManager.tickFrame(D, D.currentFrame, w), D.webcodecsPlayback && console.info("[GiftStage:WC] gift playing", {
12303
+ this.assertSlotLoadActive(D), D.state = "playing", i.type === "svga" && D.videoEntity && this.manager.audioManager.tickFrame(D, D.currentFrame, w), D.webcodecsPlayback && console.info("[GiftStage:WC] gift playing", {
12304
12304
  giftId: D.id,
12305
12305
  type: D.type,
12306
12306
  layoutBufPx: { x: D.x, y: D.y, w: D.width, h: D.height }
@@ -12308,31 +12308,31 @@ const ZA = class lA {
12308
12308
  } catch (n) {
12309
12309
  if (this.isLoadCanceled(n))
12310
12310
  return ((Q = this.manager) == null ? void 0 : Q.getSlot(D.id)) === D ? this.manager.removeSlot(D.id) : (C = this.manager) == null || C.releaseSlotResources(D), w;
12311
- D.state = "finished", (i = (E = this.options).onError) == null || i.call(E, n instanceof Error ? n : new Error(String(n)));
12311
+ D.state = "finished", (o = (E = this.options).onError) == null || o.call(E, n instanceof Error ? n : new Error(String(n)));
12312
12312
  }
12313
12313
  return w;
12314
12314
  }
12315
12315
  async loadSVGA(A) {
12316
12316
  var I, g, Q, C;
12317
- const E = typeof A.options.source == "string" ? A.options.source : null, i = (I = A.loadAbortController) == null ? void 0 : I.signal;
12317
+ const E = typeof A.options.source == "string" ? A.options.source : null, o = (I = A.loadAbortController) == null ? void 0 : I.signal;
12318
12318
  if (E) {
12319
- const D = await this.acquireSharedSVGAEntity(E, i);
12319
+ const D = await this.acquireSharedSVGAEntity(E, o);
12320
12320
  if (!this.isSlotLoadActive(A))
12321
12321
  throw D.release(), new Error(v);
12322
12322
  A.releaseSharedSVGAAsset = D.release, await this.finishLoadSVGA(A, D.entity, D.audioBlobs), this.assertSlotLoadActive(A);
12323
12323
  return;
12324
12324
  }
12325
- const { movie: o, imageBitmaps: e, audioBlobs: a } = await cg(
12325
+ const { movie: i, imageBitmaps: e, audioBlobs: a } = await cg(
12326
12326
  A.options.source,
12327
- this.svgaParseOptions(i)
12327
+ this.svgaParseOptions(o)
12328
12328
  );
12329
12329
  let t = null, s = !1;
12330
12330
  try {
12331
- this.assertSlotLoadActive(A), t = await this.buildSVGAAtlasIfNeeded(e, !!E, !0, i), this.assertSlotLoadActive(A);
12331
+ this.assertSlotLoadActive(A), t = await this.buildSVGAAtlasIfNeeded(e, !!E, !0, o), this.assertSlotLoadActive(A);
12332
12332
  const D = {
12333
- params: o.params,
12334
- spriteTable: o.spriteTable,
12335
- audios: o.audios,
12333
+ params: i.params,
12334
+ spriteTable: i.spriteTable,
12335
+ audios: i.audios,
12336
12336
  atlasTextureHandle: (g = t == null ? void 0 : t.textureHandle) != null ? g : null,
12337
12337
  atlasTextureHandles: (Q = t == null ? void 0 : t.textureHandles) != null ? Q : [],
12338
12338
  atlasRects: (C = t == null ? void 0 : t.rects) != null ? C : /* @__PURE__ */ new Map(),
@@ -12342,9 +12342,9 @@ const ZA = class lA {
12342
12342
  w.some((h) => !h) || Rg(
12343
12343
  E,
12344
12344
  {
12345
- params: o.params,
12346
- spriteTable: o.spriteTable,
12347
- audios: o.audios,
12345
+ params: i.params,
12346
+ spriteTable: i.spriteTable,
12347
+ audios: i.audios,
12348
12348
  audioBlobs: a,
12349
12349
  atlasRects: t.rects,
12350
12350
  atlasPages: t.pages.map((h, n) => ({
@@ -12372,72 +12372,72 @@ const ZA = class lA {
12372
12372
  };
12373
12373
  let C = this.pendingSharedSVGAEntities.get(g);
12374
12374
  if (!C) {
12375
- const o = new AbortController();
12375
+ const i = new AbortController();
12376
12376
  C = {
12377
12377
  cacheKey: g,
12378
- controller: o,
12378
+ controller: i,
12379
12379
  consumers: 0,
12380
12380
  settled: !1,
12381
12381
  promise: null
12382
12382
  };
12383
12383
  const e = C;
12384
- C.promise = this.buildSharedSVGAEntity(A, o.signal).finally(() => {
12384
+ C.promise = this.buildSharedSVGAEntity(A, i.signal).finally(() => {
12385
12385
  e.settled = !0, this.pendingSharedSVGAEntities.get(g) === e && this.pendingSharedSVGAEntities.delete(g);
12386
12386
  }), this.pendingSharedSVGAEntities.set(g, C);
12387
12387
  }
12388
12388
  let E;
12389
12389
  try {
12390
12390
  E = await this.waitForPendingSharedSVGAEntity(C, I);
12391
- } catch (o) {
12392
- throw o;
12391
+ } catch (i) {
12392
+ throw i;
12393
12393
  }
12394
- let i = this.sharedSVGAEntities.get(g);
12395
- return i ? i.refs++ : (i = {
12394
+ let o = this.sharedSVGAEntities.get(g);
12395
+ return o ? o.refs++ : (o = {
12396
12396
  refs: 1,
12397
12397
  entity: E.entity,
12398
12398
  audioBlobs: E.audioBlobs
12399
- }, this.sharedSVGAEntities.set(g, i)), {
12400
- entity: i.entity,
12401
- audioBlobs: i.audioBlobs,
12399
+ }, this.sharedSVGAEntities.set(g, o)), {
12400
+ entity: o.entity,
12401
+ audioBlobs: o.audioBlobs,
12402
12402
  release: () => this.releaseSharedSVGAEntity(g)
12403
12403
  };
12404
12404
  }
12405
12405
  waitForPendingSharedSVGAEntity(A, I) {
12406
12406
  return A.consumers++, new Promise((g, Q) => {
12407
12407
  let C = !1;
12408
- const E = (o) => {
12409
- C || (C = !0, I == null || I.removeEventListener("abort", i), A.consumers = Math.max(0, A.consumers - 1), A.consumers === 0 && !A.settled && A.controller.abort(), o());
12410
- }, i = () => {
12408
+ const E = (i) => {
12409
+ C || (C = !0, I == null || I.removeEventListener("abort", o), A.consumers = Math.max(0, A.consumers - 1), A.consumers === 0 && !A.settled && A.controller.abort(), i());
12410
+ }, o = () => {
12411
12411
  E(() => Q(IA(v)));
12412
12412
  };
12413
12413
  if (I != null && I.aborted) {
12414
- i();
12414
+ o();
12415
12415
  return;
12416
12416
  }
12417
- I == null || I.addEventListener("abort", i, { once: !0 }), A.promise.then(
12418
- (o) => E(() => g(o)),
12419
- (o) => E(() => Q(o))
12417
+ I == null || I.addEventListener("abort", o, { once: !0 }), A.promise.then(
12418
+ (i) => E(() => g(i)),
12419
+ (i) => E(() => Q(i))
12420
12420
  );
12421
12421
  });
12422
12422
  }
12423
12423
  async buildSharedSVGAEntity(A, I) {
12424
- var g, Q, C, E, i;
12425
- const o = await qe(A, {
12424
+ var g, Q, C, E, o;
12425
+ const i = await qe(A, {
12426
12426
  frameBudgetMs: this.options.svgaLoadFrameBudgetMs
12427
12427
  });
12428
- if (Y(I, v), o) {
12429
- const t = await this.createCachedSVGAAtlasTextures(o.atlasPages, I);
12430
- return (g = this.manager) == null || g.hydrateSVGAClipMeshes(o.clipMeshes), {
12428
+ if (Y(I, v), i) {
12429
+ const t = await this.createCachedSVGAAtlasTextures(i.atlasPages, I);
12430
+ return (g = this.manager) == null || g.hydrateSVGAClipMeshes(i.clipMeshes), {
12431
12431
  entity: {
12432
- params: o.params,
12433
- spriteTable: o.spriteTable,
12434
- audios: o.audios,
12432
+ params: i.params,
12433
+ spriteTable: i.spriteTable,
12434
+ audios: i.audios,
12435
12435
  atlasTextureHandle: (Q = t[0]) != null ? Q : null,
12436
12436
  atlasTextureHandles: t,
12437
- atlasRects: o.atlasRects,
12437
+ atlasRects: i.atlasRects,
12438
12438
  audioBuffers: /* @__PURE__ */ new Map()
12439
12439
  },
12440
- audioBlobs: o.audioBlobs
12440
+ audioBlobs: i.audioBlobs
12441
12441
  };
12442
12442
  }
12443
12443
  let e = await cg(A, this.svgaParseOptions(I)), a = null;
@@ -12455,7 +12455,7 @@ const ZA = class lA {
12455
12455
  audios: t.audios,
12456
12456
  atlasTextureHandle: (C = a == null ? void 0 : a.textureHandle) != null ? C : null,
12457
12457
  atlasTextureHandles: (E = a == null ? void 0 : a.textureHandles) != null ? E : [],
12458
- atlasRects: (i = a == null ? void 0 : a.rects) != null ? i : /* @__PURE__ */ new Map(),
12458
+ atlasRects: (o = a == null ? void 0 : a.rects) != null ? o : /* @__PURE__ */ new Map(),
12459
12459
  audioBuffers: /* @__PURE__ */ new Map()
12460
12460
  };
12461
12461
  this.options.svgaPrewarmClipMeshes !== !1 && await this.manager.prewarmSVGAClipMeshes(D, {
@@ -12521,28 +12521,28 @@ const ZA = class lA {
12521
12521
  try {
12522
12522
  for (let E = 0; E < A.length; E++) {
12523
12523
  Y(I, v);
12524
- const i = A[E], o = await createImageBitmap(
12525
- new Blob([i.imageBytes], { type: "image/png" }),
12524
+ const o = A[E], i = await createImageBitmap(
12525
+ new Blob([o.imageBytes], { type: "image/png" }),
12526
12526
  { premultiplyAlpha: "premultiply" }
12527
12527
  );
12528
12528
  try {
12529
12529
  if (this.destroyed || !this.backend) throw new Error(v);
12530
- const e = this.backend.createTexture(o, {
12531
- width: i.width,
12532
- height: i.height,
12530
+ const e = this.backend.createTexture(i, {
12531
+ width: o.width,
12532
+ height: o.height,
12533
12533
  filter: "linear",
12534
12534
  premultiplyAlpha: !0,
12535
12535
  sourcePremultiplied: !0
12536
12536
  });
12537
12537
  Q.push(e);
12538
12538
  } finally {
12539
- o.close();
12539
+ i.close();
12540
12540
  }
12541
12541
  E + 1 < A.length && C.shouldYield() && await C.yield(), Y(I, v);
12542
12542
  }
12543
12543
  return Q;
12544
12544
  } catch (E) {
12545
- for (const i of Q) (g = this.backend) == null || g.deleteTexture(i);
12545
+ for (const o of Q) (g = this.backend) == null || g.deleteTexture(o);
12546
12546
  throw E;
12547
12547
  }
12548
12548
  }
@@ -12565,8 +12565,8 @@ const ZA = class lA {
12565
12565
  maxBudgetMs: this.options.svgaLoadFrameBudgetMs
12566
12566
  });
12567
12567
  let E = 0;
12568
- for (const [i, o] of g)
12569
- await this.manager.audioManager.decodeAudio(i, o), this.assertSlotLoadActive(A), E++, E < g.size && C.shouldYield() && (await C.yield(), this.assertSlotLoadActive(A));
12568
+ for (const [o, i] of g)
12569
+ await this.manager.audioManager.decodeAudio(o, i), this.assertSlotLoadActive(A), E++, E < g.size && C.shouldYield() && (await C.yield(), this.assertSlotLoadActive(A));
12570
12570
  this.assertSlotLoadActive(A), A.videoEntity = I, this.options.svgaPrewarmClipMeshes !== !1 && (await this.manager.prewarmSVGAClipMeshes(A.videoEntity, {
12571
12571
  frameBudgetMs: this.svgaClipFrameBudgetMs(),
12572
12572
  workerTimeSliceMs: this.options.svgaWorkerFrameBudgetMs,
@@ -12662,13 +12662,13 @@ const ZA = class lA {
12662
12662
  release: jA(() => this.releaseSharedWebCodecsPlayback(e))
12663
12663
  };
12664
12664
  }
12665
- let i = this.pendingSharedWebCodecsPlaybacks.get(A);
12666
- i || (i = this.createPendingSharedWebCodecsPlayback(A), this.pendingSharedWebCodecsPlaybacks.set(A, i));
12667
- const o = await this.waitForPendingSharedWebCodecsPlayback(i, I);
12668
- return o ? (o.refs++, {
12669
- playback: o.playback,
12670
- sharedState: o,
12671
- release: jA(() => this.releaseSharedWebCodecsPlayback(o))
12665
+ let o = this.pendingSharedWebCodecsPlaybacks.get(A);
12666
+ o || (o = this.createPendingSharedWebCodecsPlayback(A), this.pendingSharedWebCodecsPlaybacks.set(A, o));
12667
+ const i = await this.waitForPendingSharedWebCodecsPlayback(o, I);
12668
+ return i ? (i.refs++, {
12669
+ playback: i.playback,
12670
+ sharedState: i,
12671
+ release: jA(() => this.releaseSharedWebCodecsPlayback(i))
12672
12672
  }) : null;
12673
12673
  }
12674
12674
  createPendingSharedWebCodecsPlayback(A) {
@@ -12702,18 +12702,18 @@ const ZA = class lA {
12702
12702
  waitForPendingSharedWebCodecsPlayback(A, I) {
12703
12703
  return A.consumers++, new Promise((g, Q) => {
12704
12704
  let C = !1;
12705
- const E = (o) => {
12706
- C || (C = !0, I == null || I.removeEventListener("abort", i), A.consumers = Math.max(0, A.consumers - 1), A.consumers === 0 && !A.settled && A.controller.abort(), o());
12707
- }, i = () => {
12705
+ const E = (i) => {
12706
+ C || (C = !0, I == null || I.removeEventListener("abort", o), A.consumers = Math.max(0, A.consumers - 1), A.consumers === 0 && !A.settled && A.controller.abort(), i());
12707
+ }, o = () => {
12708
12708
  E(() => Q(new Error(v)));
12709
12709
  };
12710
12710
  if (I != null && I.aborted) {
12711
- i();
12711
+ o();
12712
12712
  return;
12713
12713
  }
12714
- I == null || I.addEventListener("abort", i, { once: !0 }), A.promise.then(
12715
- (o) => E(() => g(o)),
12716
- (o) => E(() => Q(o))
12714
+ I == null || I.addEventListener("abort", o, { once: !0 }), A.promise.then(
12715
+ (i) => E(() => g(i)),
12716
+ (i) => E(() => Q(i))
12717
12717
  );
12718
12718
  });
12719
12719
  }
@@ -12733,12 +12733,12 @@ const ZA = class lA {
12733
12733
  var I;
12734
12734
  A.releaseWebCodecsPlayback ? A.releaseWebCodecsPlayback() : (I = A.webcodecsPlayback) == null || I.destroy(), A.releaseWebCodecsPlayback = null, A.webcodecsSharedState = null, A.webcodecsPlayback = null;
12735
12735
  }
12736
- acquireSharedWebCodecsSurface(A, I, g, Q, C, E, i) {
12737
- const o = A.webcodecsSharedState;
12738
- if (!o) return null;
12739
- const e = i ? this.options.webCodecsVideoAtlas : void 0;
12736
+ acquireSharedWebCodecsSurface(A, I, g, Q, C, E, o) {
12737
+ const i = A.webcodecsSharedState;
12738
+ if (!i) return null;
12739
+ const e = o ? this.options.webCodecsVideoAtlas : void 0;
12740
12740
  if (e && e.width > 0 && e.height > 0) {
12741
- const w = `${o.id}:atlas:${e.width}x${e.height}:${C}x${E}`, h = this.retainSharedWebCodecsSurface(w);
12741
+ const w = `${i.id}:atlas:${e.width}x${e.height}:${C}x${E}`, h = this.retainSharedWebCodecsSurface(w);
12742
12742
  if (h) return h;
12743
12743
  const n = this.nextSharedWebCodecsSurfaceId++, r = `wc-shared-surface:${n}`, F = this.manager.tryAllocateWebCodecsAtlas(
12744
12744
  r,
@@ -12769,7 +12769,7 @@ const ZA = class lA {
12769
12769
  );
12770
12770
  }
12771
12771
  }
12772
- const a = `${o.id}:full:${g}x${Q}`, t = this.retainSharedWebCodecsSurface(a);
12772
+ const a = `${i.id}:full:${g}x${Q}`, t = this.retainSharedWebCodecsSurface(a);
12773
12773
  if (t) return t;
12774
12774
  const s = this.nextSharedWebCodecsSurfaceId++, D = this.backend.createTexture(I, {
12775
12775
  width: g,
@@ -12793,7 +12793,7 @@ const ZA = class lA {
12793
12793
  }) : null;
12794
12794
  }
12795
12795
  createSharedWebCodecsSurface(A, I, g, Q, C, E) {
12796
- const i = {
12796
+ const o = {
12797
12797
  key: A,
12798
12798
  refs: 1,
12799
12799
  atlasAllocationId: E,
@@ -12804,9 +12804,9 @@ const ZA = class lA {
12804
12804
  lastUploadedFrame: Q
12805
12805
  }
12806
12806
  };
12807
- return this.sharedWebCodecsSurfaces.set(A, i), {
12808
- surface: i.surface,
12809
- release: jA(() => this.releaseSharedWebCodecsSurface(i))
12807
+ return this.sharedWebCodecsSurfaces.set(A, o), {
12808
+ surface: o.surface,
12809
+ release: jA(() => this.releaseSharedWebCodecsSurface(o))
12810
12810
  };
12811
12811
  }
12812
12812
  releaseSharedWebCodecsSurface(A) {
@@ -12819,15 +12819,15 @@ const ZA = class lA {
12819
12819
  async loadVAP(A, I) {
12820
12820
  var g, Q, C;
12821
12821
  if (!I.config) throw new Error("VAP requires config");
12822
- const E = (g = A.loadAbortController) == null ? void 0 : g.signal, i = await QB(I.config);
12823
- this.assertSlotLoadActive(A), A.vapConfig = i;
12824
- const o = await Mi(i, I.vapSlots);
12825
- if (this.assertSlotLoadActive(A), o.size > 0) {
12826
- const D = dA(i.info), w = Ni(i);
12822
+ const E = (g = A.loadAbortController) == null ? void 0 : g.signal, o = await QB(I.config);
12823
+ this.assertSlotLoadActive(A), A.vapConfig = o;
12824
+ const i = await Mi(o, I.vapSlots);
12825
+ if (this.assertSlotLoadActive(A), i.size > 0) {
12826
+ const D = dA(o.info), w = Ni(o);
12827
12827
  let h = null;
12828
12828
  if (this.backend.type === "webgpu" || this.backend.type === "webgl2")
12829
12829
  try {
12830
- h = this.createVAPMixResourceTextures(o);
12830
+ h = this.createVAPMixResourceTextures(i);
12831
12831
  } catch (n) {
12832
12832
  console.warn(
12833
12833
  "[GiftStage] VAP main-context mixed textures failed; falling back to compositor",
@@ -12848,9 +12848,9 @@ const ZA = class lA {
12848
12848
  let n = null, r = null;
12849
12849
  try {
12850
12850
  n = new Ye(
12851
- i,
12852
- w,
12853
12851
  o,
12852
+ w,
12853
+ i,
12854
12854
  D.w,
12855
12855
  D.h
12856
12856
  );
@@ -12867,7 +12867,7 @@ const ZA = class lA {
12867
12867
  height: D.h,
12868
12868
  composer: n,
12869
12869
  frameMap: w,
12870
- resources: n ? void 0 : o,
12870
+ resources: n ? void 0 : i,
12871
12871
  lastFrameIndex: -1,
12872
12872
  lastSourceRef: null,
12873
12873
  ...r != null ? r : {}
@@ -12883,7 +12883,7 @@ const ZA = class lA {
12883
12883
  if (!D)
12884
12884
  throw this.releaseAttachedWebCodecsPlayback(A), new Error("WebCodecs: missing first frame");
12885
12885
  if (!A.vapMixState || A.vapMixState.mode === "direct") {
12886
- const h = D.displayWidth || D.codedWidth, n = D.displayHeight || D.codedHeight, r = !A.vapMixState, { w: F, h: c } = LB(A, h, n, "vap", i), G = this.acquireSharedWebCodecsSurface(
12886
+ const h = D.displayWidth || D.codedWidth, n = D.displayHeight || D.codedHeight, r = !A.vapMixState, { w: F, h: c } = LB(A, h, n, "vap", o), G = this.acquireSharedWebCodecsSurface(
12887
12887
  A,
12888
12888
  D,
12889
12889
  h,
@@ -12980,11 +12980,11 @@ const ZA = class lA {
12980
12980
  var g, Q, C;
12981
12981
  const E = (g = A.loadAbortController) == null ? void 0 : g.signal;
12982
12982
  console.info("[GiftStage:WC] loadAlphaVideo: try WebCodecs / video…");
12983
- const i = await this.acquireWebCodecsPlayback(I, E);
12983
+ const o = await this.acquireWebCodecsPlayback(I, E);
12984
12984
  if (!this.isSlotLoadActive(A))
12985
- throw i == null || i.release(), new Error(v);
12986
- if (i) {
12987
- const a = this.attachWebCodecsPlayback(A, i);
12985
+ throw o == null || o.release(), new Error(v);
12986
+ if (o) {
12987
+ const a = this.attachWebCodecsPlayback(A, o);
12988
12988
  if (!a)
12989
12989
  throw this.releaseAttachedWebCodecsPlayback(A), new Error("WebCodecs: missing first frame");
12990
12990
  const t = a.displayWidth || a.codedWidth, s = a.displayHeight || a.codedHeight, { w: D, h: w } = LB(A, t, s, "alphaVideo", void 0), h = this.acquireSharedWebCodecsSurface(
@@ -13029,11 +13029,11 @@ const ZA = class lA {
13029
13029
  }), this.logPlaybackBackend(A, "webcodecs");
13030
13030
  return;
13031
13031
  }
13032
- const o = await this.tryAcquireSharedHtmlVideo(A, I);
13032
+ const i = await this.tryAcquireSharedHtmlVideo(A, I);
13033
13033
  if (!this.isSlotLoadActive(A))
13034
- throw o == null || o.release(), new Error(v);
13035
- if (o)
13036
- A.videoElement = o.video, A.releaseSharedVideoPlayback = o.release;
13034
+ throw i == null || i.release(), new Error(v);
13035
+ if (i)
13036
+ A.videoElement = i.video, A.releaseSharedVideoPlayback = i.release;
13037
13037
  else {
13038
13038
  const a = await this.acquireVideoPlaybackSource(I.source);
13039
13039
  if (!this.isSlotLoadActive(A))
@@ -13043,9 +13043,9 @@ const ZA = class lA {
13043
13043
  A.videoElement = t;
13044
13044
  }
13045
13045
  const e = A.videoElement;
13046
- if (o) {
13047
- await o.ready, this.assertSlotLoadActive(A);
13048
- const a = this.acquireSharedVideoTexture(o.cacheKey, e);
13046
+ if (i) {
13047
+ await i.ready, this.assertSlotLoadActive(A);
13048
+ const a = this.acquireSharedVideoTexture(i.cacheKey, e);
13049
13049
  A.videoTextureHandle = a.texture, A.releaseSharedVideoTexture = a.release;
13050
13050
  } else
13051
13051
  await this.waitVideoReady(e), this.assertSlotLoadActive(A), A.videoTextureHandle = this.backend.createTexture(e, {
@@ -13082,7 +13082,7 @@ const ZA = class lA {
13082
13082
  resume: () => {
13083
13083
  },
13084
13084
  destroy: () => this.removeGift(A.id),
13085
- animate: (i) => this.createGiftAnimationChain(A, E, i)
13085
+ animate: (o) => this.createGiftAnimationChain(A, E, o)
13086
13086
  }, (Q = A.onComplete) == null || Q.call(A, E), A.state = A.options.clearsAfterStop === !1 ? "stopped" : "finished";
13087
13087
  return;
13088
13088
  }
@@ -13168,12 +13168,12 @@ const ZA = class lA {
13168
13168
  if (this.options.shareIdenticalVideoPlayback === !1 || I.loop !== 0 || typeof I.source != "string" || A.type === "vap" && A.vapMixState) return null;
13169
13169
  const C = this.normalizeSharedVideoSourceKey(I.source);
13170
13170
  if (!C) return null;
13171
- const E = (g = this.options.sharedVideoPlaybackWindowMs) != null ? g : lA.DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS, i = Math.max(0, E) / 1e3, o = this.sharedHtmlVideos.get(C);
13172
- if (o)
13173
- return o.video.currentTime > i ? null : (o.refs++, {
13171
+ const E = (g = this.options.sharedVideoPlaybackWindowMs) != null ? g : lA.DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS, o = Math.max(0, E) / 1e3, i = this.sharedHtmlVideos.get(C);
13172
+ if (i)
13173
+ return i.video.currentTime > o ? null : (i.refs++, {
13174
13174
  cacheKey: C,
13175
- video: o.video,
13176
- ready: o.ready,
13175
+ video: i.video,
13176
+ ready: i.ready,
13177
13177
  release: () => this.releaseSharedHtmlVideo(C)
13178
13178
  });
13179
13179
  let e = this.pendingSharedHtmlVideos.get(C);
@@ -13250,19 +13250,19 @@ const ZA = class lA {
13250
13250
  waitVideoReady(A) {
13251
13251
  return new Promise((I, g) => {
13252
13252
  const Q = () => {
13253
- A.removeEventListener("canplay", E), A.removeEventListener("error", i);
13253
+ A.removeEventListener("canplay", E), A.removeEventListener("error", o);
13254
13254
  }, C = async () => {
13255
13255
  try {
13256
13256
  await A.play(), await this.waitForFirstVideoFrame(A), I();
13257
- } catch (o) {
13258
- g(o);
13257
+ } catch (i) {
13258
+ g(i);
13259
13259
  }
13260
13260
  }, E = () => {
13261
13261
  Q(), C();
13262
- }, i = () => {
13262
+ }, o = () => {
13263
13263
  Q(), g(new Error("Video load failed"));
13264
13264
  };
13265
- A.addEventListener("canplay", E), A.addEventListener("error", i), A.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA && (Q(), C());
13265
+ A.addEventListener("canplay", E), A.addEventListener("error", o), A.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA && (Q(), C());
13266
13266
  });
13267
13267
  }
13268
13268
  removeGift(A) {