@silurus/ooxml 0.74.3 → 0.74.4

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.
@@ -3358,7 +3358,7 @@ function bn(e, t, n) {
3358
3358
  }
3359
3359
  //#endregion
3360
3360
  //#region packages/pptx/src/text-layer.ts
3361
- function xn(e, t, n, r, i) {
3361
+ function Y(e, t, n, r, i) {
3362
3362
  e.innerHTML = "";
3363
3363
  let a = /* @__PURE__ */ new Map();
3364
3364
  for (let o of t) {
@@ -3382,7 +3382,7 @@ function xn(e, t, n, r, i) {
3382
3382
  })), c.div.appendChild(l);
3383
3383
  }
3384
3384
  }
3385
- function Sn(e, t, n, r, i, a, o = {}) {
3385
+ function xn(e, t, n, r, i, a, o = {}) {
3386
3386
  e.innerHTML = "";
3387
3387
  let s = o.match ?? "rgba(255, 214, 0, 0.42)", c = o.active ?? "rgba(255, 140, 0, 0.55)", l = /* @__PURE__ */ new Map(), u = (t) => {
3388
3388
  let n = t.rotation + (t.textBodyRotation ?? 0), a = `${t.shapeX},${t.shapeY},${t.shapeW},${t.shapeH},${n}`, o = l.get(a);
@@ -3410,21 +3410,23 @@ function Sn(e, t, n, r, i, a, o = {}) {
3410
3410
  }
3411
3411
  //#endregion
3412
3412
  //#region packages/pptx/src/find.ts
3413
- var Cn = class {
3413
+ var Sn = class {
3414
3414
  _slideRuns = /* @__PURE__ */ new Map();
3415
3415
  _matches = [];
3416
3416
  _active = -1;
3417
+ _generation = 0;
3418
+ _runsRevision = 0;
3417
3419
  constructor(e, t) {
3418
3420
  this._slideCount = e, this._collectSlideRuns = t;
3419
3421
  }
3420
3422
  invalidate() {
3421
- this._slideRuns.clear(), this._matches = [], this._active = -1;
3423
+ this._generation++, this._runsRevision++, this._slideRuns.clear(), this._matches = [], this._active = -1;
3422
3424
  }
3423
3425
  slideRuns(e) {
3424
3426
  return this._slideRuns.get(e);
3425
3427
  }
3426
3428
  setSlideRuns(e, t) {
3427
- this._slideRuns.set(e, t);
3429
+ this._runsRevision++, this._slideRuns.set(e, t);
3428
3430
  }
3429
3431
  slideHighlights(e) {
3430
3432
  let t = [];
@@ -3449,20 +3451,30 @@ var Cn = class {
3449
3451
  }));
3450
3452
  }
3451
3453
  async find(e, t = {}) {
3452
- if (this._matches = [], this._active = -1, e.length === 0) return [];
3453
- let n = this._slideCount();
3454
- for (let r = 0; r < n; r++) {
3455
- let n = await this._ensureSlideRuns(r), i = ve(n);
3454
+ let n = ++this._generation;
3455
+ if (e.length === 0) return this._runsRevision++, this._slideRuns.clear(), this._matches = [], this._active = -1, [];
3456
+ let r = this._runsRevision, i = new Map(this._slideRuns), a = this._slideCount();
3457
+ for (let e = 0; e < a; e++) {
3458
+ let t = i.get(e);
3459
+ if (!t) {
3460
+ if (t = await this._collectSlideRuns(e), n !== this._generation) return [];
3461
+ i.set(e, t);
3462
+ }
3463
+ }
3464
+ if (n !== this._generation) return [];
3465
+ let o = r === this._runsRevision ? i : new Map([...i, ...this._slideRuns]), s = [];
3466
+ for (let n = 0; n < a; n++) {
3467
+ let r = o.get(n) ?? [], i = ve(r);
3456
3468
  for (let a of ie(i, e, t)) {
3457
- let e = a.slices.map((e) => n[e.runIndex].text.slice(e.start, e.end)).join("");
3458
- this._matches.push({
3459
- slide: r,
3469
+ let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
3470
+ s.push({
3471
+ slide: n,
3460
3472
  text: e,
3461
3473
  slices: a.slices
3462
3474
  });
3463
3475
  }
3464
3476
  }
3465
- return this.matches();
3477
+ return this._runsRevision++, this._slideRuns = o, this._matches = s, this._active = -1, this.matches();
3466
3478
  }
3467
3479
  next() {
3468
3480
  return this._active = Se(this._active, this._matches.length), this._activePublic();
@@ -3478,21 +3490,15 @@ var Cn = class {
3478
3490
  location: { slide: e.slide }
3479
3491
  } : null;
3480
3492
  }
3481
- async _ensureSlideRuns(e) {
3482
- let t = this._slideRuns.get(e);
3483
- if (t) return t;
3484
- let n = await this._collectSlideRuns(e);
3485
- return this._slideRuns.set(e, n), n;
3486
- }
3487
3493
  };
3488
3494
  //#endregion
3489
3495
  //#region packages/pptx/src/types.ts
3490
- function wn(e) {
3496
+ function Cn(e) {
3491
3497
  return e;
3492
3498
  }
3493
3499
  //#endregion
3494
3500
  //#region packages/pptx/src/hyperlink.ts
3495
- function Tn(e, t) {
3501
+ function wn(e, t) {
3496
3502
  let n = e !== void 0 && e !== "" ? e : void 0, r = t !== void 0 && t !== "" ? t : void 0;
3497
3503
  if (n === void 0 && r === void 0) return;
3498
3504
  if (r !== void 0) return {
@@ -3510,7 +3516,7 @@ function Tn(e, t) {
3510
3516
  }
3511
3517
  //#endregion
3512
3518
  //#region packages/pptx/src/media-chrome.ts
3513
- function En(e, t, n, r, i, a) {
3519
+ function Tn(e, t, n, r, i, a) {
3514
3520
  let o = Math.max(18, Math.min(32, Math.min(r, i) * .25));
3515
3521
  if (e.save(), e.shadowColor = "rgba(0, 0, 0, 0.3)", e.shadowBlur = o * .35, e.fillStyle = "rgba(20, 20, 20, 0.7)", e.beginPath(), e.arc(t, n, o, 0, Math.PI * 2), e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.fillStyle = "#fff", a === "paused") {
3516
3522
  e.beginPath();
@@ -3524,18 +3530,18 @@ function En(e, t, n, r, i, a) {
3524
3530
  }
3525
3531
  //#endregion
3526
3532
  //#region packages/pptx/src/bidi-line.ts
3527
- var Dn = (e) => {
3533
+ var En = (e) => {
3528
3534
  let t = e.text;
3529
3535
  return typeof t == "string" ? t : void 0;
3530
- }, On = (e) => "isTab" in e;
3531
- function kn(e) {
3536
+ }, Dn = (e) => "isTab" in e;
3537
+ function On(e) {
3532
3538
  for (let t of e) {
3533
- let e = Dn(t);
3539
+ let e = En(t);
3534
3540
  if (e !== void 0 && M(e)) return !0;
3535
3541
  }
3536
3542
  return !1;
3537
3543
  }
3538
- function An(e, t) {
3544
+ function kn(e, t) {
3539
3545
  let n = e.length;
3540
3546
  if (n === 0) return {
3541
3547
  order: [],
@@ -3544,8 +3550,8 @@ function An(e, t) {
3544
3550
  let i = "", a = Array(n), o;
3545
3551
  for (let t = 0; t < n; t++) {
3546
3552
  a[t] = i.length;
3547
- let n = Dn(e[t]) ?? "";
3548
- if (i += n.length > 0 ? n : "", On(e[t])) {
3553
+ let n = En(e[t]) ?? "";
3554
+ if (i += n.length > 0 ? n : "", Dn(e[t])) {
3549
3555
  for (o ??= []; o.length < i.length;) o.push(null);
3550
3556
  o[a[t]] = "S";
3551
3557
  }
@@ -3560,7 +3566,7 @@ function An(e, t) {
3560
3566
  }
3561
3567
  //#endregion
3562
3568
  //#region packages/pptx/src/cjk-wrap.ts
3563
- function jn(e, t, n, r) {
3569
+ function An(e, t, n, r) {
3564
3570
  if (e.length === 0) return 0;
3565
3571
  let i = t === 0, a = 0, o = t;
3566
3572
  for (let t of e) {
@@ -3575,8 +3581,8 @@ function jn(e, t, n, r) {
3575
3581
  }
3576
3582
  //#endregion
3577
3583
  //#region packages/pptx/src/text-justify.ts
3578
- var Mn = (e) => /\s/.test(String.fromCodePoint(e));
3579
- function Nn(e, t, n, r, i) {
3584
+ var jn = (e) => /\s/.test(String.fromCodePoint(e));
3585
+ function Mn(e, t, n, r, i) {
3580
3586
  if (r === "just" && i) return null;
3581
3587
  let a = t - n;
3582
3588
  if (a <= .5) return null;
@@ -3584,7 +3590,7 @@ function Nn(e, t, n, r, i) {
3584
3590
  firstContentSi: 0,
3585
3591
  lastDrawnSi: e.length,
3586
3592
  isGapChar: S,
3587
- isWhitespace: Mn,
3593
+ isWhitespace: jn,
3588
3594
  seaClusterGaps: r === "thaiDist"
3589
3595
  });
3590
3596
  if (!o) return null;
@@ -3605,7 +3611,7 @@ function Nn(e, t, n, r, i) {
3605
3611
  }
3606
3612
  //#endregion
3607
3613
  //#region packages/pptx/src/table-border-conflict.ts
3608
- function Pn(e) {
3614
+ function Nn(e) {
3609
3615
  if (!e) return {
3610
3616
  r: 0,
3611
3617
  g: 0,
@@ -3622,21 +3628,21 @@ function Pn(e) {
3622
3628
  b: parseInt(t.slice(4, 6), 16)
3623
3629
  };
3624
3630
  }
3625
- function Fn(e) {
3626
- let t = Pn(e);
3631
+ function Pn(e) {
3632
+ let t = Nn(e);
3627
3633
  return .299 * t.r + .587 * t.g + .114 * t.b;
3628
3634
  }
3629
- function In(e, t) {
3635
+ function Fn(e, t) {
3630
3636
  if (!e && !t) return null;
3631
3637
  if (!e) return t;
3632
3638
  if (!t) return e;
3633
3639
  if (e.width !== t.width) return e.width > t.width ? e : t;
3634
- let n = Fn(e.color), r = Fn(t.color);
3640
+ let n = Pn(e.color), r = Pn(t.color);
3635
3641
  return n === r || n < r ? e : t;
3636
3642
  }
3637
3643
  //#endregion
3638
3644
  //#region packages/pptx/src/smartart-fallback-contrast.ts
3639
- function Ln(e) {
3645
+ function In(e) {
3640
3646
  let t = I(e.length === 8 ? e.slice(0, 6) : e);
3641
3647
  if (!t) return null;
3642
3648
  let n = w(t[0], t[1], t[2]);
@@ -3646,13 +3652,13 @@ function Ln(e) {
3646
3652
  let i = r / 255;
3647
3653
  return i * n + (1 - i);
3648
3654
  }
3649
- function Rn(e) {
3655
+ function Ln(e) {
3650
3656
  if (!e) return null;
3651
- if (e.fillType === "solid") return Ln(e.color);
3657
+ if (e.fillType === "solid") return In(e.color);
3652
3658
  if (e.fillType === "gradient") {
3653
3659
  let t = e.stops.map((e) => ({
3654
3660
  p: Math.min(1, Math.max(0, e.position)),
3655
- l: Ln(e.color)
3661
+ l: In(e.color)
3656
3662
  })).filter((e) => e.l !== null).sort((e, t) => e.p - t.p);
3657
3663
  if (t.length === 0) return null;
3658
3664
  let n = t[0], r = t[t.length - 1], i = n.l * n.p + r.l * (1 - r.p);
@@ -3661,18 +3667,18 @@ function Rn(e) {
3661
3667
  }
3662
3668
  return null;
3663
3669
  }
3664
- function zn(e) {
3670
+ function Rn(e) {
3665
3671
  return e.name === "SmartArt" && e.id === void 0;
3666
3672
  }
3667
- function Bn(e, t) {
3668
- let n = Rn(e);
3673
+ function zn(e, t) {
3674
+ let n = Ln(e);
3669
3675
  if (n === null || n >= .5) return null;
3670
- let r = Ln(t.replace(/^#/, ""));
3676
+ let r = In(t.replace(/^#/, ""));
3671
3677
  return r !== null && r >= .5 ? null : "#FFFFFF";
3672
3678
  }
3673
3679
  //#endregion
3674
3680
  //#region packages/pptx/src/tab-layout.ts
3675
- function Vn(e, t, n, r, i, a = 0) {
3681
+ function Bn(e, t, n, r, i, a = 0) {
3676
3682
  let o = e.map((e) => e.width), s = (t) => {
3677
3683
  let n = 0;
3678
3684
  for (let r = t; r < e.length && !e[r].isTab; r++) n += o[r];
@@ -3700,8 +3706,8 @@ function Vn(e, t, n, r, i, a = 0) {
3700
3706
  }
3701
3707
  //#endregion
3702
3708
  //#region packages/pptx/src/vertical-text.ts
3703
- var Hn = () => !1;
3704
- function Un(e, t, n) {
3709
+ var Vn = () => !1;
3710
+ function Hn(e, t, n) {
3705
3711
  let r = e.textBaseline;
3706
3712
  e.textBaseline = "alphabetic";
3707
3713
  let i = e.measureText(t);
@@ -3709,7 +3715,7 @@ function Un(e, t, n) {
3709
3715
  let a = i.fontBoundingBoxAscent, o = i.fontBoundingBoxDescent;
3710
3716
  return typeof a == "number" && typeof o == "number" && (a !== 0 || o !== 0) ? (a - o) / 2 : .38 * n;
3711
3717
  }
3712
- function Wn(e, t) {
3718
+ function Un(e, t) {
3713
3719
  let n = e.textAlign, r = e.textBaseline;
3714
3720
  e.textAlign = "center", e.textBaseline = "middle";
3715
3721
  let i = e.measureText(t);
@@ -3717,15 +3723,15 @@ function Wn(e, t) {
3717
3723
  let a = i.actualBoundingBoxAscent, o = i.actualBoundingBoxDescent;
3718
3724
  return typeof a == "number" && typeof o == "number" ? (a - o) / 2 : 0;
3719
3725
  }
3720
- function Gn(e, t, n, r, i, o, s = "fill", c = Hn) {
3721
- let l = e.textAlign, u = e.textBaseline, d = s === "stroke" ? e.strokeText.bind(e) : e.fillText.bind(e), f = r - Un(e, t, i), p = 0;
3726
+ function Wn(e, t, n, r, i, o, s = "fill", c = Vn) {
3727
+ let l = e.textAlign, u = e.textBaseline, d = s === "stroke" ? e.strokeText.bind(e) : e.fillText.bind(e), f = r - Hn(e, t, i), p = 0;
3722
3728
  for (let s of t) {
3723
3729
  let t = s.codePointAt(0) ?? 0, u = D(t), m = e.measureText(s).width + o, h = u === "Tr" ? B(t) : null, g = u === "Tr" && h === null && De(t), _ = u === "U" || u === "Tu" || h !== null || g;
3724
3730
  if (a(t) && c(t)) {
3725
3731
  let t = n + p + m / 2;
3726
3732
  e.save(), e.translate(t, f), e.rotate(-Math.PI / 2), e.textAlign = "center", e.textBaseline = "middle", Te(e, () => d(s, 0, 0)), e.restore();
3727
3733
  } else if (_) {
3728
- let r = h === null && u === "Tu" ? ke(t) : null, a = h === null ? r : h, o = a === null ? s : String.fromCodePoint(a), c = n + p + m / 2, l = r === null ? Wn(e, o) / i : 0;
3734
+ let r = h === null && u === "Tu" ? ke(t) : null, a = h === null ? r : h, o = a === null ? s : String.fromCodePoint(a), c = n + p + m / 2, l = r === null ? Un(e, o) / i : 0;
3729
3735
  e.save(), e.translate(c, f), e.rotate(-Math.PI / 2), e.textAlign = "center", e.textBaseline = "middle", d(o, 0, l * i), e.restore();
3730
3736
  } else if (u === "Tr") {
3731
3737
  let t = n + p + m / 2;
@@ -3735,27 +3741,27 @@ function Gn(e, t, n, r, i, o, s = "fill", c = Hn) {
3735
3741
  }
3736
3742
  e.textAlign = l, e.textBaseline = u;
3737
3743
  }
3738
- function Kn(e, t, n, r, i, a, o = "fill") {
3739
- Gn(e, t, n, r, i, a, o, (t) => L(e, t));
3744
+ function Gn(e, t, n, r, i, a, o = "fill") {
3745
+ Wn(e, t, n, r, i, a, o, (t) => L(e, t));
3740
3746
  }
3741
3747
  //#endregion
3742
3748
  //#region packages/pptx/src/renderer.ts
3743
- function Y(e, t) {
3749
+ function X(e, t) {
3744
3750
  return e * t;
3745
3751
  }
3746
- var X = Ae;
3747
- function qn(e, t, n, r, i, a, o) {
3752
+ var Z = Ae;
3753
+ function Kn(e, t, n, r, i, a, o) {
3748
3754
  let { top: s, height: c } = gn(n, i);
3749
3755
  e.fillStyle = a, e.fillRect(t, s, r, c), e.fillStyle = o;
3750
3756
  }
3751
- function Jn(e) {
3752
- return !e || e.fillType === "none" ? null : e.fillType === "solid" ? X(e.color) : e.fillType === "gradient" ? e.stops.length > 0 ? X(e.stops[0].color) : null : e.fillType === "pattern" ? X(e.fg) : null;
3757
+ function qn(e) {
3758
+ return !e || e.fillType === "none" ? null : e.fillType === "solid" ? Z(e.color) : e.fillType === "gradient" ? e.stops.length > 0 ? Z(e.stops[0].color) : null : e.fillType === "pattern" ? Z(e.fg) : null;
3753
3759
  }
3754
- function Yn(e, t, n, r, i, a) {
3760
+ function Jn(e, t, n, r, i, a) {
3755
3761
  return O(e, t, n, r, i, a);
3756
3762
  }
3757
- var Xn = /* @__PURE__ */ new WeakMap();
3758
- function Zn(e, t) {
3763
+ var Yn = /* @__PURE__ */ new WeakMap();
3764
+ function Xn(e, t) {
3759
3765
  let n = e.tinted.get(t);
3760
3766
  if (n) return n;
3761
3767
  let r = e.img.naturalWidth || 1, i = e.img.naturalHeight || 1, a = document.createElement("canvas");
@@ -3763,18 +3769,18 @@ function Zn(e, t) {
3763
3769
  let o = a.getContext("2d");
3764
3770
  return o ? (o.drawImage(e.img, 0, 0, r, i), o.globalCompositeOperation = "source-in", o.fillStyle = t, o.fillRect(0, 0, r, i), e.tinted.set(t, a), a) : e.img;
3765
3771
  }
3766
- function Qn(e) {
3772
+ function Zn(e) {
3767
3773
  let t = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`, n = new Image();
3768
3774
  return new Promise((e, r) => {
3769
3775
  n.onload = () => e(n), n.onerror = r, n.src = t;
3770
3776
  });
3771
3777
  }
3772
- var $n = 256;
3773
- function er(e, t, n) {
3774
- let r = Math.max(1, Math.round(t * $n)), i = Math.max(1, Math.round(n * $n));
3778
+ var Qn = 256;
3779
+ function $n(e, t, n) {
3780
+ let r = Math.max(1, Math.round(t * Qn)), i = Math.max(1, Math.round(n * Qn));
3775
3781
  return e.replace(/<svg([^>]*?)>/, (e, t) => `<svg${t.replace(/\s(?:width|height)="[^"]*"/g, "")} width="${r}" height="${i}">`);
3776
3782
  }
3777
- function tr(e) {
3783
+ function er(e) {
3778
3784
  let t = [], n = (e) => {
3779
3785
  if (e) for (let n of e.paragraphs) for (let e of n.runs) e.type === "math" && t.push({
3780
3786
  nodes: e.nodes,
@@ -3785,13 +3791,13 @@ function tr(e) {
3785
3791
  else if (t.type === "table") for (let e of t.rows) for (let t of e.cells) n(t.textBody);
3786
3792
  return t;
3787
3793
  }
3788
- async function nr(e, t) {
3789
- let n = tr(e);
3794
+ async function tr(e, t) {
3795
+ let n = er(e);
3790
3796
  if (n.length !== 0) {
3791
3797
  await t.loadMathJax();
3792
- for (let e of n) if (!Xn.has(e.nodes)) try {
3793
- let n = await t.mathMLToSvg(m(e.nodes, e.display)), r = await Qn(er(Ye(n.svg, "#000000"), n.widthEm, n.ascentEm + n.descentEm));
3794
- Xn.set(e.nodes, {
3798
+ for (let e of n) if (!Yn.has(e.nodes)) try {
3799
+ let n = await t.mathMLToSvg(m(e.nodes, e.display)), r = await Zn($n(Ye(n.svg, "#000000"), n.widthEm, n.ascentEm + n.descentEm));
3800
+ Yn.set(e.nodes, {
3795
3801
  img: r,
3796
3802
  widthEm: n.widthEm,
3797
3803
  ascentEm: n.ascentEm,
@@ -3801,10 +3807,10 @@ async function nr(e, t) {
3801
3807
  } catch {}
3802
3808
  }
3803
3809
  }
3804
- function rr(e, t) {
3810
+ function nr(e, t) {
3805
3811
  return e ? e.startsWith("+") ? e === "+mj-lt" || e === "+mj-ea" || e === "+mj-cs" ? t.themeMajorFont ?? "sans-serif" : t.themeMinorFont ?? "sans-serif" : e.split(",")[0].trim() || (t.themeMinorFont ?? "sans-serif") : t.themeMinorFont ?? "sans-serif";
3806
3812
  }
3807
- var ir = new Set([
3813
+ var rr = new Set([
3808
3814
  "serif",
3809
3815
  "sans-serif",
3810
3816
  "monospace",
@@ -3812,11 +3818,11 @@ var ir = new Set([
3812
3818
  "fantasy",
3813
3819
  "system-ui"
3814
3820
  ]);
3815
- function ar(e) {
3821
+ function ir(e) {
3816
3822
  let t = E(e);
3817
3823
  return t === "mono" ? "monospace" : t === "serif" ? "serif" : "sans-serif";
3818
3824
  }
3819
- var or = {
3825
+ var ar = {
3820
3826
  calibri: "Carlito",
3821
3827
  "calibri light": "Carlito",
3822
3828
  cambria: "Caladea",
@@ -3826,65 +3832,65 @@ var or = {
3826
3832
  "simplified arabic": "Noto Naskh Arabic",
3827
3833
  "arabic typesetting": "Noto Naskh Arabic",
3828
3834
  "univers next arabic": "Noto Sans Arabic"
3829
- }, sr = "\"Noto Naskh Arabic\", \"Noto Sans Arabic\"";
3830
- function cr(e) {
3831
- if (or[e.toLowerCase()]?.includes("Arabic")) return !0;
3835
+ }, or = "\"Noto Naskh Arabic\", \"Noto Sans Arabic\"";
3836
+ function sr(e) {
3837
+ if (ar[e.toLowerCase()]?.includes("Arabic")) return !0;
3832
3838
  let t = e.toLowerCase();
3833
3839
  return /arabic|naskh|kufi|nastaliq|amiri|scheherazade|lateef|aldhabi|urdu|farsi|العرب|[؀-ۿ]/.test(t);
3834
3840
  }
3835
- function lr(e) {
3841
+ function cr(e) {
3836
3842
  return e.map((e) => `"${e}"`).join(", ");
3837
3843
  }
3838
- function ur(e) {
3839
- let t = ar(e), n = or[e.toLowerCase()], r = n ? `"${n}", ` : "";
3840
- if (cr(e)) return `"${e}", ${r}${sr}, ${t}`;
3844
+ function lr(e) {
3845
+ let t = ir(e), n = ar[e.toLowerCase()], r = n ? `"${n}", ` : "";
3846
+ if (sr(e)) return `"${e}", ${r}${or}, ${t}`;
3841
3847
  let i = t === "serif" ? "serif" : "sans", a = v(e);
3842
- return `"${e}", ${r}${a ? `${lr(p(a, i))}, ` : ""}${`${lr(i === "serif" ? C : x)}, `}${t}`;
3848
+ return `"${e}", ${r}${a ? `${cr(p(a, i))}, ` : ""}${`${cr(i === "serif" ? C : x)}, `}${t}`;
3843
3849
  }
3844
- function dr(e) {
3850
+ function ur(e) {
3845
3851
  return e ? e.kind === "external" ? `e:${e.url}` : `i:${e.ref}` : "";
3846
3852
  }
3847
- function Z(e, t, n, r, i) {
3848
- let a = t ? "italic " : "", o = e ? "bold " : "", s = rr(r, i);
3849
- return ir.has(s) ? `${a}${o}${n}px ${s}` : `${a}${o}${n}px ${ur(s)}`;
3853
+ function Q(e, t, n, r, i) {
3854
+ let a = t ? "italic " : "", o = e ? "bold " : "", s = nr(r, i);
3855
+ return rr.has(s) ? `${a}${o}${n}px ${s}` : `${a}${o}${n}px ${lr(s)}`;
3850
3856
  }
3851
- function fr(e) {
3852
- return e.bullet.type === "char" || e.bullet.type === "autoNum" || wn(e.bullet).type === "blip";
3857
+ function dr(e) {
3858
+ return e.bullet.type === "char" || e.bullet.type === "autoNum" || Cn(e.bullet).type === "blip";
3853
3859
  }
3854
- function pr(e, t) {
3860
+ function fr(e, t) {
3855
3861
  return e ? 0 : Math.max(0, t);
3856
3862
  }
3857
- function mr(e, t, r, i, a, o, s) {
3863
+ function pr(e, t, r, i, a, o, s) {
3858
3864
  let c = (t.defaultFontSize ?? 18) * n * o;
3859
3865
  for (let l of t.paragraphs) {
3860
- let u = Y(l.marL, o), d = Y(l.marR, o), f = Y(l.indent, o), p = pr(fr(l), f), m = r - i - a - u - d - p, h = 0;
3866
+ let u = X(l.marL, o), d = X(l.marR, o), f = X(l.indent, o), p = fr(dr(l), f), m = r - i - a - u - d - p, h = 0;
3861
3867
  for (let r of l.runs) {
3862
3868
  if (r.type !== "text") continue;
3863
- let i = r.fontSize == null ? l.defFontSize == null ? c : l.defFontSize * n * o : r.fontSize * n * o, a = rr(r.fontFamily ?? l.defFontFamily ?? null, s);
3864
- if (e.font = Z(r.bold ?? l.defBold ?? t.defaultBold ?? !1, r.italic ?? l.defItalic ?? t.defaultItalic ?? !1, i, a, s), h += e.measureText(r.text).width, h > m) return !0;
3869
+ let i = r.fontSize == null ? l.defFontSize == null ? c : l.defFontSize * n * o : r.fontSize * n * o, a = nr(r.fontFamily ?? l.defFontFamily ?? null, s);
3870
+ if (e.font = Q(r.bold ?? l.defBold ?? t.defaultBold ?? !1, r.italic ?? l.defItalic ?? t.defaultItalic ?? !1, i, a, s), h += e.measureText(r.text).width, h > m) return !0;
3865
3871
  }
3866
3872
  }
3867
3873
  return !1;
3868
3874
  }
3869
- function hr(e) {
3875
+ function mr(e) {
3870
3876
  for (let t of e) if (S(t.codePointAt(0) ?? 0)) return !0;
3871
3877
  return !1;
3872
3878
  }
3873
- function Q(e) {
3879
+ function $(e) {
3874
3880
  let t = 0;
3875
3881
  for (let n of e) t++;
3876
3882
  return t;
3877
3883
  }
3878
- function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3884
+ function hr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3879
3885
  themeMajorFont: null,
3880
3886
  themeMinorFont: null,
3881
3887
  dpr: 1
3882
3888
  }, h = 0) {
3883
- let g = [], _ = () => r - (g.length === 0 ? h : 0), v = { segments: [] }, x = 0, C = !1, w = t.rtl === !0, E = Y(t.marR, c), D = (t.tabStops ?? []).map((e) => ({
3884
- pos: Y(e.pos, c),
3889
+ let g = [], _ = () => r - (g.length === 0 ? h : 0), v = { segments: [] }, x = 0, C = !1, w = t.rtl === !0, E = X(t.marR, c), D = (t.tabStops ?? []).map((e) => ({
3890
+ pos: X(e.pos, c),
3885
3891
  algn: e.algn
3886
- })), O = Y(t.defTabSz ?? 914400, c), A = !1, j = [], M = 0, N = () => w ? E : l + (g.length === 0 ? h : 0), P = (e = 0) => {
3887
- let t = Vn(e > 0 ? [...j, {
3892
+ })), O = X(t.defTabSz ?? 914400, c), A = !1, j = [], M = 0, N = () => w ? E : l + (g.length === 0 ? h : 0), P = (e = 0) => {
3893
+ let t = Bn(e > 0 ? [...j, {
3888
3894
  isTab: !1,
3889
3895
  width: e
3890
3896
  }] : j, D, N(), Infinity, M, O), n = 0;
@@ -3909,7 +3915,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3909
3915
  }, R = (t, n, r, i, a, o, s, c) => {
3910
3916
  if (!t) return;
3911
3917
  e.font = n;
3912
- let l = c?.letterSpacingPx ?? 0, u = e.measureText(t).width + l * Q(t), d = c?.strikeDouble, f = c?.underlineStyle, p = c?.underlineColor, m = c?.shadow, h = c?.outline, g = c?.highlight, _ = c?.fontFamily, y = c?.hyperlink, b = (e) => !e.math && !e.isTab && e.font === n && e.color === i && e.underline === a && (e.underlineStyle ?? "") === (f ?? "") && (e.underlineColor ?? "") === (p ?? "") && e.strikethrough === o && (e.strikeDouble ?? !1) === (d ?? !1) && (e.letterSpacingPx ?? 0) === l && e.baseline === s && e.shadow === m && e.outline === h && (e.highlight ?? "") === (g ?? "") && (e.fontFamily ?? "") === (_ ?? "") && dr(e.hyperlink) === dr(y);
3918
+ let l = c?.letterSpacingPx ?? 0, u = e.measureText(t).width + l * $(t), d = c?.strikeDouble, f = c?.underlineStyle, p = c?.underlineColor, m = c?.shadow, h = c?.outline, g = c?.highlight, _ = c?.fontFamily, y = c?.hyperlink, b = (e) => !e.math && !e.isTab && e.font === n && e.color === i && e.underline === a && (e.underlineStyle ?? "") === (f ?? "") && (e.underlineColor ?? "") === (p ?? "") && e.strikethrough === o && (e.strikeDouble ?? !1) === (d ?? !1) && (e.letterSpacingPx ?? 0) === l && e.baseline === s && e.shadow === m && e.outline === h && (e.highlight ?? "") === (g ?? "") && (e.fontFamily ?? "") === (_ ?? "") && ur(e.hyperlink) === ur(y);
3913
3919
  x += u, j.push({
3914
3920
  isTab: !1,
3915
3921
  width: u
@@ -3957,7 +3963,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3957
3963
  continue;
3958
3964
  }
3959
3965
  if (r.type === "math") {
3960
- let e = Xn.get(r.nodes), t = r.fontSize == null ? i : r.fontSize * n * c * f, o = e ? e.widthEm * t : 0, s = e ? e.ascentEm * t : 0, l = e ? e.descentEm * t : 0;
3966
+ let e = Yn.get(r.nodes), t = r.fontSize == null ? i : r.fontSize * n * c * f, o = e ? e.widthEm * t : 0, s = e ? e.ascentEm * t : 0, l = e ? e.descentEm * t : 0;
3961
3967
  (r.display && x > 0 || !F(o) && x > 0) && L(), j.push({
3962
3968
  isTab: !1,
3963
3969
  width: o
@@ -3965,7 +3971,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3965
3971
  text: "",
3966
3972
  font: `${t}px sans-serif`,
3967
3973
  sizePx: t,
3968
- color: r.color ? X(r.color) : a,
3974
+ color: r.color ? Z(r.color) : a,
3969
3975
  underline: !1,
3970
3976
  strikethrough: !1,
3971
3977
  math: {
@@ -3978,9 +3984,9 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3978
3984
  }), x += o, r.display && L();
3979
3985
  continue;
3980
3986
  }
3981
- let l = r.fontSize == null ? i : r.fontSize * n * c * f, h = rr(r.fontFamily ?? t.defFontFamily ?? null, m), g = r.fontFamilyEa ? rr(r.fontFamilyEa, m) : null, w = r.fontFamilySym ? rr(r.fontFamilySym, m) : null, E;
3982
- E = r.color ? X(r.color) : r.hyperlink && m.themeHlinkColor ? X(m.themeHlinkColor) : a;
3983
- let D = r.bold ?? t.defBold ?? u, O = r.italic ?? t.defItalic ?? d, N = Z(D, O, l, h, m), P = g ? Z(D, O, l, g, m) : N;
3987
+ let l = r.fontSize == null ? i : r.fontSize * n * c * f, h = nr(r.fontFamily ?? t.defFontFamily ?? null, m), g = r.fontFamilyEa ? nr(r.fontFamilyEa, m) : null, w = r.fontFamilySym ? nr(r.fontFamilySym, m) : null, E;
3988
+ E = r.color ? Z(r.color) : r.hyperlink && m.themeHlinkColor ? Z(m.themeHlinkColor) : a;
3989
+ let D = r.bold ?? t.defBold ?? u, O = r.italic ?? t.defItalic ?? d, N = Q(D, O, l, h, m), P = g ? Q(D, O, l, g, m) : N;
3984
3990
  e.font = N;
3985
3991
  let B = r.caps, V = r.text;
3986
3992
  (B === "all" || B === "small") && (V = V.toUpperCase());
@@ -3988,12 +3994,12 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
3988
3994
  strikeDouble: ee,
3989
3995
  letterSpacingPx: W,
3990
3996
  underlineStyle: r.underlineStyle,
3991
- underlineColor: r.underlineColor ? X(r.underlineColor) : void 0,
3997
+ underlineColor: r.underlineColor ? Z(r.underlineColor) : void 0,
3992
3998
  shadow: r.shadow,
3993
3999
  outline: r.outline,
3994
4000
  fontFamily: h,
3995
- highlight: r.highlight ? X(r.highlight) : void 0,
3996
- hyperlink: Tn(r.hyperlink)
4001
+ highlight: r.highlight ? Z(r.highlight) : void 0,
4002
+ hyperlink: wn(r.hyperlink)
3997
4003
  }, te = H.split(/(\s+)/);
3998
4004
  for (let n of te) {
3999
4005
  if (!n) continue;
@@ -4023,7 +4029,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
4023
4029
  let n = i, a = N;
4024
4030
  if (c.test(i)) {
4025
4031
  let e = Ie(i, t);
4026
- e === i ? a = Z(D, O, l, t, m) : (n = e, a = Z(D, O, l, "sans-serif", m));
4032
+ e === i ? a = Q(D, O, l, t, m) : (n = e, a = Q(D, O, l, "sans-serif", m));
4027
4033
  }
4028
4034
  e.font = a;
4029
4035
  let o = e.measureText(n).width;
@@ -4031,7 +4037,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
4031
4037
  }
4032
4038
  continue;
4033
4039
  }
4034
- if (hr(n) && (!k(n) || t.eaLnBrk === !1)) {
4040
+ if (mr(n) && (!k(n) || t.eaLnBrk === !1)) {
4035
4041
  let i = [];
4036
4042
  for (let t of n) {
4037
4043
  let n = S(t.codePointAt(0) ?? 0) && g != null, r = n ? P : N, a = n ? g : h;
@@ -4053,7 +4059,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
4053
4059
  }
4054
4060
  let a = i;
4055
4061
  for (; a.length > 0;) {
4056
- let e = Number.isFinite(_()) ? _() - I() : x, t = jn(a, e, _(), T);
4062
+ let e = Number.isFinite(_()) ? _() - I() : x, t = An(a, e, _(), T);
4057
4063
  if (t === 0) {
4058
4064
  if (x > 0) {
4059
4065
  L();
@@ -4077,7 +4083,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
4077
4083
  cjk: !0,
4078
4084
  kinsoku: T
4079
4085
  }), i = g != null && P !== N, a = (e) => i && S(e.codePointAt(0) ?? 0), c = (t) => {
4080
- let n = W * Q(t), r = "", i = null, o = () => {
4086
+ let n = W * $(t), r = "", i = null, o = () => {
4081
4087
  r !== "" && (e.font = i ? P : N, n += e.measureText(r).width, r = "");
4082
4088
  };
4083
4089
  for (let e of t) {
@@ -4132,7 +4138,7 @@ function gr(e, t, r, i, a, c, l, u = !1, d = !1, f = 1, p, m = {
4132
4138
  }
4133
4139
  return g.push(v), g;
4134
4140
  }
4135
- async function _r(e, t, r, i, a, o) {
4141
+ async function gr(e, t, r, i, a, o) {
4136
4142
  if (t && t.fillType === "image") {
4137
4143
  if (e.fillStyle = "#FFFFFF", e.fillRect(0, 0, r, i), !t.imagePath || !t.mimeType || !o) return;
4138
4144
  try {
@@ -4141,7 +4147,7 @@ async function _r(e, t, r, i, a, o) {
4141
4147
  heightPt: i / a / n
4142
4148
  });
4143
4149
  if (!s) return;
4144
- if (e.save(), e.beginPath(), e.rect(0, 0, r, i), e.clip(), t.alpha != null && (e.globalAlpha = t.alpha), t.tile) br(e, s, t.tile, r, i, a);
4150
+ if (e.save(), e.beginPath(), e.rect(0, 0, r, i), e.clip(), t.alpha != null && (e.globalAlpha = t.alpha), t.tile) yr(e, s, t.tile, r, i, a);
4145
4151
  else {
4146
4152
  let n = t.fillRect ?? {}, a = n.l ?? 0, o = n.t ?? 0, c = n.r ?? 0, l = n.b ?? 0, u = a * r, d = o * i, f = r * (1 - a - c), p = i * (1 - o - l);
4147
4153
  e.drawImage(s, u, d, f, p);
@@ -4150,10 +4156,10 @@ async function _r(e, t, r, i, a, o) {
4150
4156
  } catch {}
4151
4157
  return;
4152
4158
  }
4153
- e.fillStyle = Yn(t, e, 0, 0, r, i) ?? "#FFFFFF", e.fillRect(0, 0, r, i);
4159
+ e.fillStyle = Jn(t, e, 0, 0, r, i) ?? "#FFFFFF", e.fillRect(0, 0, r, i);
4154
4160
  }
4155
- var vr = 9525;
4156
- function yr(e, t, n, r, i) {
4161
+ var _r = 9525;
4162
+ function vr(e, t, n, r, i) {
4157
4163
  let a;
4158
4164
  a = e === "t" || e === "ctr" || e === "b" ? (t - r) / 2 : e === "tr" || e === "r" || e === "br" ? t - r : 0;
4159
4165
  let o;
@@ -4162,8 +4168,8 @@ function yr(e, t, n, r, i) {
4162
4168
  ay: o
4163
4169
  };
4164
4170
  }
4165
- function br(e, t, n, r, i, a) {
4166
- let o = t.width * vr * n.sx * a, s = t.height * vr * n.sy * a;
4171
+ function yr(e, t, n, r, i, a) {
4172
+ let o = t.width * _r * n.sx * a, s = t.height * _r * n.sy * a;
4167
4173
  if (!(o > 0) || !(s > 0)) return;
4168
4174
  let l = n.flip === "x" || n.flip === "xy", u = n.flip === "y" || n.flip === "xy", d = c(o * (l ? 2 : 1), s * (u ? 2 : 1));
4169
4175
  if (!d) return;
@@ -4175,33 +4181,33 @@ function br(e, t, n, r, i, a) {
4175
4181
  p(0, 0, !1, !1), l && p(o, 0, !0, !1), u && p(0, s, !1, !0), l && u && p(o, s, !0, !0);
4176
4182
  let m = e.createPattern(d, "repeat");
4177
4183
  if (!m) return;
4178
- let { ax: h, ay: g } = yr(n.algn, r, i, o, s), _ = h + Y(n.tx, a), v = g + Y(n.ty, a);
4184
+ let { ax: h, ay: g } = vr(n.algn, r, i, o, s), _ = h + X(n.tx, a), v = g + X(n.ty, a);
4179
4185
  typeof m.setTransform == "function" && typeof DOMMatrix < "u" ? (m.setTransform(new DOMMatrix().translateSelf(_, v)), e.fillStyle = m, e.fillRect(0, 0, r, i)) : (e.save(), e.translate(_, v), e.fillStyle = m, e.fillRect(-_, -v, r, i), e.restore());
4180
4186
  }
4181
- function xr(e, t, n) {
4187
+ function br(e, t, n) {
4182
4188
  if (!t) return;
4183
- let r = t.dir * Math.PI / 180, i = Y(t.dist, n);
4184
- e.shadowColor = X(t.color, t.alpha), e.shadowBlur = Y(t.blur, n), e.shadowOffsetX = Math.cos(r) * i, e.shadowOffsetY = Math.sin(r) * i;
4189
+ let r = t.dir * Math.PI / 180, i = X(t.dist, n);
4190
+ e.shadowColor = Z(t.color, t.alpha), e.shadowBlur = X(t.blur, n), e.shadowOffsetX = Math.cos(r) * i, e.shadowOffsetY = Math.sin(r) * i;
4185
4191
  }
4186
- function Sr(e, t, n) {
4187
- t && (e.shadowColor = X(t.color, t.alpha), e.shadowBlur = Y(t.radius, n), e.shadowOffsetX = 0, e.shadowOffsetY = 0);
4192
+ function xr(e, t, n) {
4193
+ t && (e.shadowColor = Z(t.color, t.alpha), e.shadowBlur = X(t.radius, n), e.shadowOffsetX = 0, e.shadowOffsetY = 0);
4188
4194
  }
4189
- function Cr(e) {
4195
+ function Sr(e) {
4190
4196
  e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
4191
4197
  }
4192
- var wr = 8, Tr = 1, Er = 1, Dr = 256;
4193
- function Or(e, t, n, r, i, a, o, s, l, u, d, f, p, m, h) {
4198
+ var Cr = 8, wr = 1, Tr = 1, Er = 256;
4199
+ function Dr(e, t, n, r, i, a, o, s, l, u, d, f, p, m, h) {
4194
4200
  if (r <= 0) return;
4195
- let g = e.measureText(t), _ = g.actualBoundingBoxAscent > 0 ? g.actualBoundingBoxAscent : r, v = g.actualBoundingBoxDescent > 0 ? g.actualBoundingBoxDescent : r * .25, y = g.actualBoundingBoxLeft > 0 ? g.actualBoundingBoxLeft : 0, b = g.actualBoundingBoxRight > 0 ? g.actualBoundingBoxRight : r, x = r * u * i, S = Math.min(Dr, Math.max(1, Math.round(x / wr))), C = (e) => jr(e, a, r, o, s, l, d, f), w = C(S), T = Nr(w, a, o, s, l, d, f, u, i, -_, v);
4196
- for (; T > Er && S < Dr;) {
4197
- let e = Math.min(Dr, S * 2), t = C(e), n = Nr(t, a, o, s, l, d, f, u, i, -_, v);
4201
+ let g = e.measureText(t), _ = g.actualBoundingBoxAscent > 0 ? g.actualBoundingBoxAscent : r, v = g.actualBoundingBoxDescent > 0 ? g.actualBoundingBoxDescent : r * .25, y = g.actualBoundingBoxLeft > 0 ? g.actualBoundingBoxLeft : 0, b = g.actualBoundingBoxRight > 0 ? g.actualBoundingBoxRight : r, x = r * u * i, S = Math.min(Er, Math.max(1, Math.round(x / Cr))), C = (e) => Ar(e, a, r, o, s, l, d, f), w = C(S), T = Mr(w, a, o, s, l, d, f, u, i, -_, v);
4202
+ for (; T > Tr && S < Er;) {
4203
+ let e = Math.min(Er, S * 2), t = C(e), n = Mr(t, a, o, s, l, d, f, u, i, -_, v);
4198
4204
  if (n >= T * .75) {
4199
4205
  w = t;
4200
4206
  break;
4201
4207
  }
4202
4208
  S = e, w = t, T = n;
4203
4209
  }
4204
- let E = 1e4, D = Tr / (u * i), O = w.length - 1, k = (e, t, n) => e === 0 ? -E : t - n - D, A = (e, t, n) => e === O ? E : t - n + D, j = (e, r) => {
4210
+ let E = 1e4, D = wr / (u * i), O = w.length - 1, k = (e, t, n) => e === 0 ? -E : t - n - D, A = (e, t, n) => e === O ? E : t - n + D, j = (e, r) => {
4205
4211
  e.fillStyle = r;
4206
4212
  for (let r = 0; r <= O; r++) {
4207
4213
  let { s0: i, s1: a, g: o } = w[r], s = (i + a) / 2;
@@ -4209,7 +4215,7 @@ function Or(e, t, n, r, i, a, o, s, l, u, d, f, p, m, h) {
4209
4215
  let c = k(r, i, s), l = A(r, a, s);
4210
4216
  e.rect(c, -E, l - c, 2 * E), e.clip(), e.fillText(t, -s + n / 2, 0), e.restore();
4211
4217
  }
4212
- }, M = kr(h), N = typeof e.globalAlpha == "number" ? e.globalAlpha : 1;
4218
+ }, M = Or(h), N = typeof e.globalAlpha == "number" ? e.globalAlpha : 1;
4213
4219
  if (M >= 1 && N >= 1) {
4214
4220
  j(e, h);
4215
4221
  return;
@@ -4229,7 +4235,7 @@ function Or(e, t, n, r, i, a, o, s, l, u, d, f, p, m, h) {
4229
4235
  [s, v],
4230
4236
  [c, v]
4231
4237
  ]) {
4232
- let n = Mr(i, u, e, t), r = p + n.x, a = m + n.y, o = P.a * r + P.c * a + P.e, s = P.b * r + P.d * a + P.f;
4238
+ let n = jr(i, u, e, t), r = p + n.x, a = m + n.y, o = P.a * r + P.c * a + P.e, s = P.b * r + P.d * a + P.f;
4233
4239
  o < F && (F = o), o > L && (L = o), s < I && (I = s), s > R && (R = s);
4234
4240
  }
4235
4241
  }
@@ -4239,19 +4245,19 @@ function Or(e, t, n, r, i, a, o, s, l, u, d, f, p, m, h) {
4239
4245
  j(e, h);
4240
4246
  return;
4241
4247
  }
4242
- H.font = e.font, H.textAlign = "left", H.textBaseline = "alphabetic", H.setTransform(P.a, P.b, P.c, P.d, P.e - z, P.f - B), j(H, Ar(h)), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = N * M, e.drawImage(V, z, B), e.restore();
4248
+ H.font = e.font, H.textAlign = "left", H.textBaseline = "alphabetic", H.setTransform(P.a, P.b, P.c, P.d, P.e - z, P.f - B), j(H, kr(h)), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = N * M, e.drawImage(V, z, B), e.restore();
4243
4249
  }
4244
- function kr(e) {
4250
+ function Or(e) {
4245
4251
  let t = /^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*([\d.]+)\s*\)$/i.exec(e);
4246
4252
  if (!t) return 1;
4247
4253
  let n = parseFloat(t[1]);
4248
4254
  return Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 1;
4249
4255
  }
4250
- function Ar(e) {
4256
+ function kr(e) {
4251
4257
  let t = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(e);
4252
4258
  return t ? `rgb(${t[1]}, ${t[2]}, ${t[3]})` : e;
4253
4259
  }
4254
- function jr(e, t, n, r, i, a, o, s) {
4260
+ function Ar(e, t, n, r, i, a, o, s) {
4255
4261
  let c = Array(e);
4256
4262
  for (let l = 0; l < e; l++) {
4257
4263
  let u = l / e * n, d = (l + 1) / e * n;
@@ -4263,33 +4269,33 @@ function jr(e, t, n, r, i, a, o, s) {
4263
4269
  }
4264
4270
  return c;
4265
4271
  }
4266
- function Mr(e, t, n, r) {
4272
+ function jr(e, t, n, r) {
4267
4273
  let i = n * t, a = r * e.vScale, o = i + e.shear * a, s = Math.cos(e.angle), c = Math.sin(e.angle);
4268
4274
  return {
4269
4275
  x: e.x + s * o - c * a,
4270
4276
  y: e.y + c * o + s * a
4271
4277
  };
4272
4278
  }
4273
- function Nr(e, t, n, r, i, a, o, s, c, l, u) {
4279
+ function Mr(e, t, n, r, i, a, o, s, c, l, u) {
4274
4280
  let d = 0;
4275
4281
  for (let f of e) {
4276
4282
  let e = (f.s0 + f.s1) / 2;
4277
4283
  for (let p of [f.s0, f.s1]) {
4278
4284
  let m = lt(t, (n + p) / r * i, a, o);
4279
4285
  for (let t of [l, u]) {
4280
- let n = Mr(m, s, 0, t), r = Mr(f.g, s, p - e, t), i = Math.hypot(r.x - n.x, r.y - n.y) * c;
4286
+ let n = jr(m, s, 0, t), r = jr(f.g, s, p - e, t), i = Math.hypot(r.x - n.x, r.y - n.y) * c;
4281
4287
  i > d && (d = i);
4282
4288
  }
4283
4289
  }
4284
4290
  }
4285
4291
  return d;
4286
4292
  }
4287
- function Pr(e, t, r, i, a, o, s, c, l, u, d) {
4293
+ function Nr(e, t, r, i, a, o, s, c, l, u, d) {
4288
4294
  let f = a, p = o, m = Math.max(1, s), h = Math.max(1, c), g = at(r, i, m, h);
4289
4295
  if (!g) return;
4290
4296
  let _ = t.defaultBold ?? !1, v = t.defaultItalic ?? !1, y = (t.defaultFontSize ?? 18) * n * l, b = [];
4291
4297
  for (let r of t.paragraphs) {
4292
- let t = gr(e, r, Infinity, r.defFontSize == null ? y : r.defFontSize * n * l, r.defColor ? X(r.defColor) : u, l, 0, _, v, 1, void 0, d, 0);
4298
+ let t = hr(e, r, Infinity, r.defFontSize == null ? y : r.defFontSize * n * l, r.defColor ? Z(r.defColor) : u, l, 0, _, v, 1, void 0, d, 0);
4293
4299
  for (let e of t) b.push(e);
4294
4300
  }
4295
4301
  if (b.length === 0) return;
@@ -4308,7 +4314,7 @@ function Pr(e, t, r, i, a, o, s, c, l, u, d) {
4308
4314
  }
4309
4315
  e.font = t.font;
4310
4316
  let n = t.letterSpacingPx ?? 0, r = e.measureText(t.text);
4311
- a += r.width + n * Q(t.text), o = Math.max(o, t.sizePx), r.actualBoundingBoxAscent > 0 && (s = Math.max(s, r.actualBoundingBoxAscent)), r.actualBoundingBoxDescent > 0 && (c = Math.max(c, r.actualBoundingBoxDescent));
4317
+ a += r.width + n * $(t.text), o = Math.max(o, t.sizePx), r.actualBoundingBoxAscent > 0 && (s = Math.max(s, r.actualBoundingBoxAscent)), r.actualBoundingBoxDescent > 0 && (c = Math.max(c, r.actualBoundingBoxDescent));
4312
4318
  }
4313
4319
  if (a <= 0) continue;
4314
4320
  let l = s + c > 0 ? s + c : o, u = g.singleEdge ? .8 : l > 0 ? s / l : .8, d = g.singleEdge ? 1 : m / a, _ = g.singleEdge ? h : l / (i - r), v = ct(g, a), y = 0;
@@ -4322,7 +4328,7 @@ function Pr(e, t, r, i, a, o, s, c, l, u, d) {
4322
4328
  for (let s of o) {
4323
4329
  let o = e.measureText(s).width + n, c = r + u * (i - r);
4324
4330
  if (!g.singleEdge && o > 0) {
4325
- Or(e, s, n, o, S(), g, y, a, v, d, _, c, f, p, t.color), y += o;
4331
+ Dr(e, s, n, o, S(), g, y, a, v, d, _, c, f, p, t.color), y += o;
4326
4332
  continue;
4327
4333
  }
4328
4334
  let l = lt(g, (y + o / 2) / a * v, _, c);
@@ -4332,7 +4338,7 @@ function Pr(e, t, r, i, a, o, s, c, l, u, d) {
4332
4338
  }
4333
4339
  e.restore();
4334
4340
  }
4335
- function Fr(e, t, n, r, i, a, o) {
4341
+ function Pr(e, t, n, r, i, a, o) {
4336
4342
  let s = Math.min(r, i);
4337
4343
  switch (e) {
4338
4344
  case "rightarrow":
@@ -4362,35 +4368,35 @@ function Fr(e, t, n, r, i, a, o) {
4362
4368
  default: return null;
4363
4369
  }
4364
4370
  }
4365
- function Ir(e, t) {
4366
- return e.defaultTextColor ? X(e.defaultTextColor) : t.smartArtFallbackTextColor != null && zn(e) ? t.smartArtFallbackTextColor : null;
4371
+ function Fr(e, t) {
4372
+ return e.defaultTextColor ? Z(e.defaultTextColor) : t.smartArtFallbackTextColor != null && Rn(e) ? t.smartArtFallbackTextColor : null;
4367
4373
  }
4368
- function Lr(e, t, n) {
4374
+ function Ir(e, t, n) {
4369
4375
  return {
4370
4376
  outerRotation: e,
4371
4377
  localFlipH: t,
4372
4378
  localFlipV: n
4373
4379
  };
4374
4380
  }
4375
- function Rr(e, t, n, r = "#000000", i, a = {
4381
+ function Lr(e, t, n, r = "#000000", i, a = {
4376
4382
  themeMajorFont: null,
4377
4383
  themeMinorFont: null,
4378
4384
  dpr: 1
4379
4385
  }, o, s) {
4380
- let c = Y(t.x, n), l = Y(t.y, n), u = Y(t.width, n), d = Y(t.height, n), f = o && t.id !== void 0 ? (e) => o({
4386
+ let c = X(t.x, n), l = X(t.y, n), u = X(t.width, n), d = X(t.height, n), f = o && t.id !== void 0 ? (e) => o({
4381
4387
  ...e,
4382
4388
  shapeId: t.id
4383
4389
  }) : o;
4384
4390
  if (d === 0 && t.textBody?.verticalAnchor === "b") {
4385
- if (t.stroke && (e.save(), $(e, t.stroke, n), e.beginPath(), e.moveTo(c, l), e.lineTo(c + u, l), e.stroke(), e.restore()), t.textBody) {
4386
- let o = Ir(t, a);
4387
- Wr(e, t.textBody, c, l, u, d, n, o, t.rotation, t.flipH, t.flipV, r, i, a, f, !1, s);
4391
+ if (t.stroke && (e.save(), $r(e, t.stroke, n), e.beginPath(), e.moveTo(c, l), e.lineTo(c + u, l), e.stroke(), e.restore()), t.textBody) {
4392
+ let o = Fr(t, a);
4393
+ Ur(e, t.textBody, c, l, u, d, n, o, t.rotation, t.flipH, t.flipV, r, i, a, f, !1, s);
4388
4394
  }
4389
4395
  return;
4390
4396
  }
4391
4397
  let p = t.scene3d && Dt(t.scene3d.camera) ? t.scene3d : null;
4392
4398
  if (p && u > 0 && d > 0) {
4393
- let o = e.getTransform(), s = Math.abs(o.a * o.d - o.b * o.c), f = s > 0 ? Math.sqrt(s) : 1, m = Gr(t.sp3d, t.scene3d?.lightRig, t.sp3d?.prstMaterial, n, f), h = Kr(t.sp3d, p.camera, u, d, n, f), g = Lr(t.rotation, t.flipH, t.flipV);
4399
+ let o = e.getTransform(), s = Math.abs(o.a * o.d - o.b * o.c), f = s > 0 ? Math.sqrt(s) : 1, m = Wr(t.sp3d, t.scene3d?.lightRig, t.sp3d?.prstMaterial, n, f), h = Gr(t.sp3d, p.camera, u, d, n, f), g = Ir(t.rotation, t.flipH, t.flipV);
4394
4400
  e.save(), g.outerRotation !== 0 && (e.translate(c + u / 2, l + d / 2), e.rotate(g.outerRotation * Math.PI / 180), e.translate(-(c + u / 2), -(l + d / 2)));
4395
4401
  let _ = {
4396
4402
  ...t,
@@ -4401,8 +4407,8 @@ function Rr(e, t, n, r = "#000000", i, a = {
4401
4407
  flipV: g.localFlipV,
4402
4408
  scene3d: void 0
4403
4409
  };
4404
- if (qr(e, p.camera, c, l, u, d, (e) => {
4405
- Rr(e, _, n, r, i, a, void 0);
4410
+ if (Kr(e, p.camera, c, l, u, d, (e) => {
4411
+ Lr(e, _, n, r, i, a, void 0);
4406
4412
  }, {
4407
4413
  bevels: m,
4408
4414
  extrusion: h ?? void 0,
@@ -4414,8 +4420,8 @@ function Rr(e, t, n, r = "#000000", i, a = {
4414
4420
  e.restore();
4415
4421
  }
4416
4422
  e.save(), (t.rotation !== 0 || t.flipH || t.flipV) && (e.translate(c + u / 2, l + d / 2), e.rotate(t.rotation * Math.PI / 180), t.flipH && e.scale(-1, 1), t.flipV && e.scale(1, -1), e.translate(-(c + u / 2), -(l + d / 2)));
4417
- let m = t.geometry.toLowerCase(), h = Yn(t.fill, e, c, l, u, d);
4418
- xr(e, t.shadow ?? null, n), t.shadow || Sr(e, t.glow ?? null, n);
4423
+ let m = t.geometry.toLowerCase(), h = Jn(t.fill, e, c, l, u, d);
4424
+ br(e, t.shadow ?? null, n), t.shadow || xr(e, t.glow ?? null, n);
4419
4425
  let g = new Set([
4420
4426
  "line",
4421
4427
  "straightconnector1",
@@ -4442,8 +4448,8 @@ function Rr(e, t, n, r = "#000000", i, a = {
4442
4448
  "accentbordercallout3"
4443
4449
  ]), v = (e) => _.has(e) || e === "line" || e === "straightconnector1" || e.startsWith("bentconnector"), y = !t.custGeom && he(m), b = (e, r) => {
4444
4450
  let i = r ?? h, a = r ? null : t.stroke ? () => {
4445
- $(e, t.stroke, n), e.stroke();
4446
- } : null, o = () => Cr(e);
4451
+ $r(e, t.stroke, n), e.stroke();
4452
+ } : null, o = () => Sr(e);
4447
4453
  if (y && !r) {
4448
4454
  le(e, m, c, l, u, d, [
4449
4455
  t.adj,
@@ -4457,7 +4463,7 @@ function Rr(e, t, n, r = "#000000", i, a = {
4457
4463
  ], i, a, o, v(m) ? { skipTrailingStroke: !0 } : void 0);
4458
4464
  return;
4459
4465
  }
4460
- e.beginPath(), t.custGeom && t.custGeom.length > 0 ? zr(e, t.custGeom, c, l, u, d) : Pe(e, m, c, l, u, d, t.adj, t.adj2, t.adj3, t.adj4), i && m !== "arc" && (e.fillStyle = i, m === "donut" || m === "smileyface" || m === "frame" ? e.fill("evenodd") : e.fill(), r || o()), a && a();
4466
+ e.beginPath(), t.custGeom && t.custGeom.length > 0 ? Rr(e, t.custGeom, c, l, u, d) : Pe(e, m, c, l, u, d, t.adj, t.adj2, t.adj3, t.adj4), i && m !== "arc" && (e.fillStyle = i, m === "donut" || m === "smileyface" || m === "frame" ? e.fill("evenodd") : e.fill(), r || o()), a && a();
4461
4467
  }, x = e.canvas.width || 0, S = e.canvas.height || 0, C = e.getTransform(), w = Math.abs(C.a * C.d - C.b * C.c), T = w > 0 ? Math.sqrt(w) : 1, E = {
4462
4468
  x: c * T,
4463
4469
  y: l * T,
@@ -4500,38 +4506,38 @@ function Rr(e, t, n, r = "#000000", i, a = {
4500
4506
  let e = Be(t.stroke.headEnd, t.stroke, n);
4501
4507
  i[0] = He(i[0], i[1], e);
4502
4508
  }
4503
- $(e, t.stroke, n), e.beginPath(), e.moveTo(i[0].x, i[0].y);
4509
+ $r(e, t.stroke, n), e.beginPath(), e.moveTo(i[0].x, i[0].y);
4504
4510
  for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
4505
4511
  e.stroke();
4506
4512
  }
4507
- i && a && $r(e, r.start, r.end, t.stroke, i, n), t.stroke.tailEnd && Ne(e, r.end.x, r.end.y, r.end.angle, t.stroke.tailEnd, t.stroke, n), t.stroke.headEnd && Ne(e, r.start.x, r.start.y, r.start.angle, t.stroke.headEnd, t.stroke, n);
4513
+ i && a && Qr(e, r.start, r.end, t.stroke, i, n), t.stroke.tailEnd && Ne(e, r.end.x, r.end.y, r.end.angle, t.stroke.tailEnd, t.stroke, n), t.stroke.headEnd && Ne(e, r.start.x, r.start.y, r.start.angle, t.stroke.headEnd, t.stroke, n);
4508
4514
  }
4509
4515
  } else if (t.stroke && t.custGeom && t.custGeom.length > 0 && (t.stroke.headEnd && t.stroke.headEnd.type !== "none" || t.stroke.tailEnd && t.stroke.tailEnd.type !== "none")) {
4510
4516
  let { start: r, end: i } = Re(t.custGeom);
4511
4517
  r && t.stroke.headEnd && t.stroke.headEnd.type !== "none" && Ne(e, c + r.x * u, l + r.y * d, Math.atan2(r.dy * d, r.dx * u), t.stroke.headEnd, t.stroke, n), i && t.stroke.tailEnd && t.stroke.tailEnd.type !== "none" && Ne(e, c + i.x * u, l + i.y * d, Math.atan2(i.dy * d, i.dx * u), t.stroke.tailEnd, t.stroke, n);
4512
4518
  }
4513
4519
  if (t.textBody) {
4514
- let o = Ir(t, a);
4520
+ let o = Fr(t, a);
4515
4521
  if (e.save(), t.flipH || t.flipV) {
4516
4522
  let n = c + u / 2, r = l + d / 2;
4517
4523
  e.translate(n, r), t.flipH && e.scale(-1, 1), t.flipV && e.scale(1, -1), e.translate(-n, -r);
4518
4524
  }
4519
4525
  let p = c, h = l, g = u, _ = d;
4520
- if (t.textRect) p = Y(t.textRect.x, n), h = Y(t.textRect.y, n), g = Y(t.textRect.width, n), _ = Y(t.textRect.height, n);
4526
+ if (t.textRect) p = X(t.textRect.x, n), h = X(t.textRect.y, n), g = X(t.textRect.width, n), _ = X(t.textRect.height, n);
4521
4527
  else if (m === "ellipse") {
4522
4528
  let e = u * (1 - 1 / Math.SQRT2) / 2, t = d * (1 - 1 / Math.SQRT2) / 2;
4523
4529
  p = c + e, h = l + t, g = u / Math.SQRT2, _ = d / Math.SQRT2;
4524
4530
  } else {
4525
- let e = Fr(m, c, l, u, d, t.adj, t.adj2);
4531
+ let e = Pr(m, c, l, u, d, t.adj, t.adj2);
4526
4532
  e && (p = e.tx, h = e.ty, g = e.tw, _ = e.th);
4527
4533
  }
4528
- Wr(e, t.textBody, p, h, g, _, n, o, t.rotation, !1, !1, r, i, a, f, !1, s), e.restore();
4534
+ Ur(e, t.textBody, p, h, g, _, n, o, t.rotation, !1, !1, r, i, a, f, !1, s), e.restore();
4529
4535
  }
4530
4536
  e.restore();
4531
4537
  }
4532
- var zr = Ue;
4533
- function Br(e, t) {
4534
- let n = `${e}`, r = e >= 1 && e <= 26 ? String.fromCharCode(96 + e) : n, i = e >= 1 && e <= 26 ? String.fromCharCode(64 + e) : n, a = Vr(e).toLowerCase(), o = Vr(e), s = n.replace(/[0-9]/g, (e) => String.fromCharCode(65296 + (e.charCodeAt(0) - 48)));
4538
+ var Rr = Ue;
4539
+ function zr(e, t) {
4540
+ let n = `${e}`, r = e >= 1 && e <= 26 ? String.fromCharCode(96 + e) : n, i = e >= 1 && e <= 26 ? String.fromCharCode(64 + e) : n, a = Br(e).toLowerCase(), o = Br(e), s = n.replace(/[0-9]/g, (e) => String.fromCharCode(65296 + (e.charCodeAt(0) - 48)));
4535
4541
  switch (t) {
4536
4542
  case "arabicPlain": return n;
4537
4543
  case "arabicPeriod": return `${n}.`;
@@ -4558,7 +4564,7 @@ function Br(e, t) {
4558
4564
  default: return `${n}.`;
4559
4565
  }
4560
4566
  }
4561
- function Vr(e) {
4567
+ function Br(e) {
4562
4568
  let t = [
4563
4569
  1e3,
4564
4570
  900,
@@ -4591,21 +4597,21 @@ function Vr(e) {
4591
4597
  for (let i = 0; i < t.length; i++) for (; e >= t[i];) r += n[i], e -= t[i];
4592
4598
  return r;
4593
4599
  }
4594
- function Hr(e) {
4600
+ function Vr(e) {
4595
4601
  for (let t of e.runs) if (t.type === "text" && t.text !== "" || t.type === "math") return !0;
4596
4602
  return !1;
4597
4603
  }
4598
- function Ur(e, t) {
4599
- let n = Hr(e);
4604
+ function Hr(e, t) {
4605
+ let n = Vr(e);
4600
4606
  if (e.bullet.type === "char") return t.clear(), n ? Ie(e.bullet.char, e.bullet.fontFamily ?? null) : "";
4601
4607
  if (e.bullet.type === "autoNum") {
4602
4608
  if (!n) return "";
4603
4609
  let r = e.lvl;
4604
- return t.has(r) ? t.set(r, t.get(r) + 1) : t.set(r, e.bullet.startAt ?? 1), Br(t.get(r), e.bullet.numType);
4610
+ return t.has(r) ? t.set(r, t.get(r) + 1) : t.set(r, e.bullet.startAt ?? 1), zr(t.get(r), e.bullet.numType);
4605
4611
  }
4606
4612
  return t.clear(), "";
4607
4613
  }
4608
- function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000", m, h = {
4614
+ function Ur(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000", m, h = {
4609
4615
  themeMajorFont: null,
4610
4616
  themeMinorFont: null,
4611
4617
  dpr: 1
@@ -4624,7 +4630,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4624
4630
  textBodyRotation: d
4625
4631
  }) : void 0;
4626
4632
  if (_) return a;
4627
- e.save(), e.translate(n, u), e.rotate(x ? -Math.PI / 2 : Math.PI / 2), Wr(e, {
4633
+ e.save(), e.translate(n, u), e.rotate(x ? -Math.PI / 2 : Math.PI / 2), Ur(e, {
4628
4634
  ...t,
4629
4635
  vert: "horz"
4630
4636
  }, -o / 2, -a / 2, o, a, s, c, 0, !1, !1, p, m, h, f, !1, v, t.vert === "eaVert"), e.restore();
@@ -4632,25 +4638,25 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4632
4638
  }
4633
4639
  let S = t.textWarp;
4634
4640
  if (!_ && S && et(S.preset)) {
4635
- Pr(e, t, S.preset, S.adj ?? [], r, i, a, o, s, c ?? p, h);
4641
+ Nr(e, t, S.preset, S.adj ?? [], r, i, a, o, s, c ?? p, h);
4636
4642
  return;
4637
4643
  }
4638
- let C = Y(t.lIns, s), w = Y(t.rIns, s), T = Y(t.tIns, s), E = Y(t.bIns, s), D = t.wrap !== "none", O = t.autoFit === "sp" ? D && mr(e, t, a, C, w, s, h) : D, k = Math.max(1, t.numCol ?? 1), A = Y(t.spcCol ?? 0, s), j = t.defaultBold ?? !1, M = t.defaultItalic ?? !1, N = c ?? p, P = (i) => {
4644
+ let C = X(t.lIns, s), w = X(t.rIns, s), T = X(t.tIns, s), E = X(t.bIns, s), D = t.wrap !== "none", O = t.autoFit === "sp" ? D && pr(e, t, a, C, w, s, h) : D, k = Math.max(1, t.numCol ?? 1), A = X(t.spcCol ?? 0, s), j = t.defaultBold ?? !1, M = t.defaultItalic ?? !1, N = c ?? p, P = (i) => {
4639
4645
  let o = (t.defaultFontSize ?? 18) * n * s * i, c = [], l = 0, u = /* @__PURE__ */ new Map();
4640
4646
  for (let d = 0; d < t.paragraphs.length; d++) {
4641
- let f = t.paragraphs[d], p = Y(f.marL, s), g = Y(f.marR, s), _ = Y(f.indent, s), v = f.defFontSize == null ? o : f.defFontSize * n * s * i, y = f.defColor ? X(f.defColor) : N, b = fr(f), x = (() => {
4647
+ let f = t.paragraphs[d], p = X(f.marL, s), g = X(f.marR, s), _ = X(f.indent, s), v = f.defFontSize == null ? o : f.defFontSize * n * s * i, y = f.defColor ? Z(f.defColor) : N, b = dr(f), x = (() => {
4642
4648
  for (let e of f.runs) if (e.type === "text" && e.fontSize != null) return e.fontSize;
4643
4649
  return null;
4644
4650
  })(), S = x == null ? v : x * n * s * i, T = (() => {
4645
4651
  for (let e of f.runs) if (e.type === "text" && e.color) return e.color;
4646
4652
  return null;
4647
- })(), E = T ? X(T) : y, D = "", P = Z(!1, !1, S, "sans-serif", h), F = E, I = null;
4648
- D = Ur(f, u);
4649
- let L = wn(f.bullet);
4653
+ })(), E = T ? Z(T) : y, D = "", P = Q(!1, !1, S, "sans-serif", h), F = E, I = null;
4654
+ D = Hr(f, u);
4655
+ let L = Cn(f.bullet);
4650
4656
  if (L.type === "char") {
4651
4657
  let e = L;
4652
- P = Z(!1, !1, e.sizePts == null ? e.sizePct == null ? S : S * (e.sizePct / 100) : e.sizePts * n * s * i, D === e.char ? rr(e.fontFamily ?? null, h) : "sans-serif", h), F = e.color ? X(e.color) : E;
4653
- } else if (L.type === "autoNum") P = Z(!1, !1, S, "sans-serif", h), F = L.color ? X(L.color) : E;
4658
+ P = Q(!1, !1, e.sizePts == null ? e.sizePct == null ? S : S * (e.sizePct / 100) : e.sizePts * n * s * i, D === e.char ? nr(e.fontFamily ?? null, h) : "sans-serif", h), F = e.color ? Z(e.color) : E;
4659
+ } else if (L.type === "autoNum") P = Q(!1, !1, S, "sans-serif", h), F = L.color ? Z(L.color) : E;
4654
4660
  else if (L.type === "blip") {
4655
4661
  let e = L, t = e.sizePts == null ? e.sizePct == null ? S : S * (e.sizePct / 100) : e.sizePts * n * s * i;
4656
4662
  I = {
@@ -4659,7 +4665,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4659
4665
  sizePx: t
4660
4666
  };
4661
4667
  }
4662
- let R = k > 1 ? (a - C - w - (k - 1) * A) / k : a - C - w, z = r + C + p, B = r + C + p + _, V = R - p - g, H = gr(e, f, O ? V : Infinity, v, y, s, p, j, M, i, m, h, pr(b, _)), U = f.spaceBefore == null ? 0 : f.spaceBefore / 100 * n * s * i, ee = f.spaceAfter == null ? 0 : f.spaceAfter / 100 * n * s * i;
4668
+ let R = k > 1 ? (a - C - w - (k - 1) * A) / k : a - C - w, z = r + C + p, B = r + C + p + _, V = R - p - g, H = hr(e, f, O ? V : Infinity, v, y, s, p, j, M, i, m, h, fr(b, _)), U = f.spaceBefore == null ? 0 : f.spaceBefore / 100 * n * s * i, ee = f.spaceAfter == null ? 0 : f.spaceAfter / 100 * n * s * i;
4663
4669
  for (let r = 0; r < H.length; r++) {
4664
4670
  let i = H[r], a = r === 0, o = r === H.length - 1, u = 0, p = 0;
4665
4671
  for (let e of i.segments) {
@@ -4677,7 +4683,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4677
4683
  a && I && I.sizePx > u && (u = I.sizePx);
4678
4684
  let m = Math.max(u * 1.2, p), h;
4679
4685
  h = f.spaceLine ? f.spaceLine.type === "pct" ? m * (f.spaceLine.val / 1e5) : f.spaceLine.val * n * s : m, t.autoFit === "norm" && t.lnSpcReduction != null && f.spaceLine?.type !== "pts" && (h *= 1 - t.lnSpcReduction);
4680
- let g = h + (o ? ee : 0), y = a && d > 0 ? U : 0, x = a ? pr(b, _) : 0, S = i.segments.some((e) => e.text && e.text.length > 0 || e.math != null), C = a && S ? I : null;
4686
+ let g = h + (o ? ee : 0), y = a && d > 0 ? U : 0, x = a ? fr(b, _) : 0, S = i.segments.some((e) => e.text && e.text.length > 0 || e.math != null), C = a && S ? I : null;
4681
4687
  c.push({
4682
4688
  line: i,
4683
4689
  linePx: g,
@@ -4723,11 +4729,11 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4723
4729
  for (let n of F) {
4724
4730
  let { line: c, linePx: d, lineHeight: f, topGapPx: p, textXOffset: m, bulletLabel: _, bulletFont: b, bulletColor: x, bulletImage: S, alignment: C, isLastLine: w } = n;
4725
4731
  k > 1 && te < k - 1 && ne >= G && (te++, ne = 0, B = H), B += p, ne++;
4726
- let T = (t.rtlCol ? k - 1 - te : te) * U, E = n.textX + T, D = n.bulletX + T, O = n.textMaxW, A = n.para.rtl === !0, j = A || kn(c.segments), M = c.segments.some((e) => e.isTab);
4732
+ let T = (t.rtlCol ? k - 1 - te : te) * U, E = n.textX + T, D = n.bulletX + T, O = n.textMaxW, A = n.para.rtl === !0, j = A || On(c.segments), M = c.segments.some((e) => e.isTab);
4727
4733
  if (M) {
4728
- let t = Y(n.para.marL, s), r = Y(n.para.marR, s), i = A ? r : t + m, a = O + t + r;
4734
+ let t = X(n.para.marL, s), r = X(n.para.marR, s), i = A ? r : t + m, a = O + t + r;
4729
4735
  e.font = c.segments.find((e) => e.isTab).font;
4730
- let o = e.measureText(" ").width, l = Vn(c.segments.map((t) => {
4736
+ let o = e.measureText(" ").width, l = Bn(c.segments.map((t) => {
4731
4737
  if (t.isTab) return {
4732
4738
  isTab: !0,
4733
4739
  width: 0
@@ -4740,12 +4746,12 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4740
4746
  let n = t.letterSpacingPx ?? 0;
4741
4747
  return {
4742
4748
  isTab: !1,
4743
- width: t.text ? e.measureText(t.text).width + n * Q(t.text) : 0
4749
+ width: t.text ? e.measureText(t.text).width + n * $(t.text) : 0
4744
4750
  };
4745
4751
  }), (n.para.tabStops ?? []).map((e) => ({
4746
- pos: Y(e.pos, s),
4752
+ pos: X(e.pos, s),
4747
4753
  algn: e.algn
4748
- })), i, a, o, Y(n.para.defTabSz ?? 914400, s));
4754
+ })), i, a, o, X(n.para.defTabSz ?? 914400, s));
4749
4755
  for (let e = 0; e < c.segments.length; e++) c.segments[e].isTab && (c.segments[e].tabWidthPx = l[e]);
4750
4756
  }
4751
4757
  let N = 0, P = f * .8;
@@ -4760,7 +4766,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4760
4766
  }
4761
4767
  e.font = t.font;
4762
4768
  let n = e.measureText(t.text || "M"), r = t.letterSpacingPx ?? 0;
4763
- N += t.text ? n.width + r * Q(t.text) : 0, n.actualBoundingBoxAscent > 0 && (P = Math.max(P, n.actualBoundingBoxAscent));
4769
+ N += t.text ? n.width + r * $(t.text) : 0, n.actualBoundingBoxAscent > 0 && (P = Math.max(P, n.actualBoundingBoxAscent));
4764
4770
  }
4765
4771
  let F = B + P, I = E + O, L = 0, R = null;
4766
4772
  if (j && A) {
@@ -4783,7 +4789,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4783
4789
  }
4784
4790
  let z = E + m, V;
4785
4791
  V = M ? A ? E + O - L - N : z : C === "ctr" ? z + (O - m - N) / 2 : C === "r" ? E + O - L - N : z;
4786
- let ee = C === "just" || C === "justLow" ? "just" : C === "thaiDist" ? "thaiDist" : C === "dist" ? "dist" : null, W = w || (c.endsWithBreak ?? !1), re = (ee && !j && !M ? Nn(c.segments, O - m, N, ee, W) : null) ?? c.segments, ie = j ? An(c.segments, A) : null, K = re.length;
4792
+ let ee = C === "just" || C === "justLow" ? "just" : C === "thaiDist" ? "thaiDist" : C === "dist" ? "dist" : null, W = w || (c.endsWithBreak ?? !1), re = (ee && !j && !M ? Mn(c.segments, O - m, N, ee, W) : null) ?? c.segments, ie = j ? kn(c.segments, A) : null, K = re.length;
4787
4793
  for (let t = 0; t < K; t++) {
4788
4794
  let n = ie ? ie.order[t] : t, c = re[n], d = ie ? ie.rtl[n] : !1;
4789
4795
  if (j && (e.direction = d ? "rtl" : "ltr"), c.isTab) {
@@ -4792,9 +4798,9 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4792
4798
  }
4793
4799
  let p = c.jext ?? 0, m = c.splitBefore, _ = c.perGap ?? 0, v = m && m.length > 0 ? m.length * _ : 0;
4794
4800
  if (c.math) {
4795
- let t = Xn.get(c.math.nodes), n = c.math.width, r = c.math.ascent + c.math.descent;
4801
+ let t = Yn.get(c.math.nodes), n = c.math.width, r = c.math.ascent + c.math.descent;
4796
4802
  if (t && n > 0 && r > 0) {
4797
- let i = F - c.math.ascent, a = Zn(t, c.color);
4803
+ let i = F - c.math.ascent, a = Xn(t, c.color);
4798
4804
  e.drawImage(a, V, i, n, r);
4799
4805
  }
4800
4806
  V += n, V += p;
@@ -4803,13 +4809,13 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4803
4809
  e.font = c.font, e.fillStyle = c.color;
4804
4810
  let b = F + (c.baseline ? -(c.baseline / 1e5) * c.sizePx : 0), x = c.letterSpacingPx ?? 0;
4805
4811
  if (c.highlight && c.text) {
4806
- let t = e.measureText(c.text).width + (x > 0 ? x * Q(c.text) : 0) + v + p;
4807
- qn(e, V, b, t, c.sizePx, c.highlight, c.color);
4812
+ let t = e.measureText(c.text).width + (x > 0 ? x * $(c.text) : 0) + v + p;
4813
+ Kn(e, V, b, t, c.sizePx, c.highlight, c.color);
4808
4814
  }
4809
4815
  let S = c.shadow;
4810
4816
  if (S) {
4811
- let t = S.dir * Math.PI / 180, n = Y(S.dist, s);
4812
- e.save(), e.shadowColor = X(S.color, S.alpha), e.shadowBlur = Y(S.blur, s), e.shadowOffsetX = Math.cos(t) * n, e.shadowOffsetY = Math.sin(t) * n;
4817
+ let t = S.dir * Math.PI / 180, n = X(S.dist, s);
4818
+ e.save(), e.shadowColor = Z(S.color, S.alpha), e.shadowBlur = X(S.blur, s), e.shadowOffsetX = Math.cos(t) * n, e.shadowOffsetY = Math.sin(t) * n;
4813
4819
  }
4814
4820
  let C = (t, n, r) => {
4815
4821
  let i = r === "fill" ? e.fillText.bind(e) : e.strokeText.bind(e);
@@ -4826,7 +4832,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4826
4832
  }, w = (t) => e.measureText(t).width, T = m && m.length > 0 ? _n([...c.text], m, _, w, x) : null, E = [...c.text], D = !!m && m.length === E.length - 1 && E.length > 1, O = (t) => {
4827
4833
  if (y) {
4828
4834
  let n = D ? x + _ : x;
4829
- Kn(e, c.text, V, b, c.sizePx, n, t);
4835
+ Gn(e, c.text, V, b, c.sizePx, n, t);
4830
4836
  return;
4831
4837
  }
4832
4838
  if (D) {
@@ -4843,8 +4849,8 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4843
4849
  };
4844
4850
  O("fill"), S && e.restore();
4845
4851
  let k = c.outline;
4846
- k && k.width > 0 && (e.save(), e.lineWidth = Math.max(.5, Y(k.width, s)), e.strokeStyle = k.color ? `#${k.color}` : c.color, e.lineJoin = "round", O("stroke"), e.restore()), e.font = c.font;
4847
- let A = e.measureText(c.text).width + (x > 0 ? x * Q(c.text) : 0) + v;
4852
+ k && k.width > 0 && (e.save(), e.lineWidth = Math.max(.5, X(k.width, s)), e.strokeStyle = k.color ? `#${k.color}` : c.color, e.lineJoin = "round", O("stroke"), e.restore()), e.font = c.font;
4853
+ let A = e.measureText(c.text).width + (x > 0 ? x * $(c.text) : 0) + v;
4848
4854
  if (g && c.text && g({
4849
4855
  text: c.text,
4850
4856
  inShapeX: V - r,
@@ -4877,7 +4883,7 @@ function Wr(e, t, r, i, a, o, s, c = null, l = 0, d = !1, f = !1, p = "#000000",
4877
4883
  }
4878
4884
  e.restore();
4879
4885
  }
4880
- function Gr(e, t, n, r, i) {
4886
+ function Wr(e, t, n, r, i) {
4881
4887
  if (!e) return [];
4882
4888
  let a = nn(t?.rig ?? "threePt", t?.dir ?? "t", t?.rot), o = ln(n), s = r * i, c = [];
4883
4889
  return e.bevelT && e.bevelT.w > 0 && e.bevelT.h > 0 && c.push({
@@ -4895,7 +4901,7 @@ function Gr(e, t, n, r, i) {
4895
4901
  bottom: !0
4896
4902
  }), c;
4897
4903
  }
4898
- function Kr(e, t, n, r, i, a) {
4904
+ function Gr(e, t, n, r, i, a) {
4899
4905
  if (!e || !e.extrusionH || e.extrusionH <= 0) return null;
4900
4906
  let o = e.extrusionH * i * a, s = Ot(t, n * a, r * a, o);
4901
4907
  if (Math.hypot(s.x, s.y) < .75) return null;
@@ -4918,7 +4924,7 @@ function Kr(e, t, n, r, i, a) {
4918
4924
  rgb: c
4919
4925
  };
4920
4926
  }
4921
- function qr(e, t, n, r, i, a, o, s = {}) {
4927
+ function Kr(e, t, n, r, i, a, o, s = {}) {
4922
4928
  if (i <= 0 || a <= 0) return !1;
4923
4929
  let l = e.getTransform(), u = Math.abs(l.a * l.d - l.b * l.c), d = u > 0 ? Math.sqrt(u) : 1, f = Math.max(0, Math.ceil((s.edgePadCss ?? 0) * d)), p = Et(t, i, a), m = p.corners;
4924
4930
  if (f > 0) {
@@ -4946,7 +4952,7 @@ function qr(e, t, n, r, i, a, o, s = {}) {
4946
4952
  y: r + e.y
4947
4953
  }))), !0;
4948
4954
  }
4949
- function Jr(e, t, n, r, i, a, o, s, l = 0) {
4955
+ function qr(e, t, n, r, i, a, o, s, l = 0) {
4950
4956
  if (r <= 0 || i <= 0 || a.length === 0) return !1;
4951
4957
  let u = e.getTransform(), d = Math.abs(u.a * u.d - u.b * u.c), f = d > 0 ? Math.sqrt(d) : 1, p = Math.max(0, Math.ceil(l * f)), m = p / f, h = Math.max(1, Math.ceil(r * f) + 2 * p), g = Math.max(1, Math.ceil(i * f) + 2 * p), _ = c(h, g);
4952
4958
  if (!_) return !1;
@@ -4965,18 +4971,18 @@ function Jr(e, t, n, r, i, a, o, s, l = 0) {
4965
4971
  }
4966
4972
  return s && (v.save(), v.scale(f, f), v.translate(m, m), s(v, 0, 0, r, i), v.restore()), e.drawImage(_, t - m, n - m, h / f, g / f), !0;
4967
4973
  }
4968
- var Yr = /* @__PURE__ */ new WeakMap();
4969
- function Xr(e, t) {
4970
- let n = Yr.get(e);
4974
+ var Jr = /* @__PURE__ */ new WeakMap();
4975
+ function Yr(e, t) {
4976
+ let n = Jr.get(e);
4971
4977
  if (n) return n;
4972
4978
  let r = (async () => {
4973
4979
  let n = await t(e.posterPath), r = e.posterMimeType ? new Blob([n], { type: e.posterMimeType }) : n;
4974
4980
  if (H(new Uint8Array(await r.slice(0, 64 * 1024).arrayBuffer()))) throw Error("poster raster exceeds the pixel budget");
4975
4981
  return createImageBitmap(r);
4976
4982
  })();
4977
- return Yr.set(e, r), r;
4983
+ return Jr.set(e, r), r;
4978
4984
  }
4979
- async function Zr(e, r, i, a) {
4985
+ async function Xr(e, r, i, a) {
4980
4986
  if (a) try {
4981
4987
  let o = r.mimeType === "image/svg+xml", { widthPt: s, heightPt: c } = de(r.mimeType, r.srcRect, r.width / n, r.height / n), l;
4982
4988
  if (P(r)) try {
@@ -4993,23 +4999,23 @@ async function Zr(e, r, i, a) {
4993
4999
  });
4994
5000
  if (!l) return;
4995
5001
  e.save(), r.alpha != null && (e.globalAlpha *= r.alpha);
4996
- let u = Y(r.x, i), d = Y(r.y, i), f = Y(r.width, i), p = Y(r.height, i);
5002
+ let u = X(r.x, i), d = X(r.y, i), f = X(r.width, i), p = X(r.height, i);
4997
5003
  (r.rotation !== 0 || r.flipH || r.flipV) && (e.translate(u + f / 2, d + p / 2), e.rotate(r.rotation * Math.PI / 180), r.flipH && e.scale(-1, 1), r.flipV && e.scale(1, -1), e.translate(-(u + f / 2), -(d + p / 2)));
4998
5004
  let m = t(l, r.srcRect), h = (e, t, n, i, a) => {
4999
- r.custGeom && r.custGeom.length > 0 ? zr(e, r.custGeom, t, n, i, a) : r.prstGeom && ee(e, r.prstGeom, t, n, i, a, r.prstAdjust ?? []) || e.rect(t, n, i, a);
5005
+ r.custGeom && r.custGeom.length > 0 ? Rr(e, r.custGeom, t, n, i, a) : r.prstGeom && ee(e, r.prstGeom, t, n, i, a, r.prstAdjust ?? []) || e.rect(t, n, i, a);
5000
5006
  }, g = (e, t, n, r, i) => {
5001
5007
  e.beginPath(), h(e, t, n, r, i);
5002
5008
  }, _ = (e, t, n, i, a) => {
5003
5009
  (r.prstGeom || r.custGeom && r.custGeom.length > 0) && (g(e, t, n, i, a), e.clip());
5004
5010
  }, v = (e, t, n, a, o) => {
5005
- r.stroke && (e.save(), $(e, r.stroke, i), g(e, t, n, a, o), e.stroke(), e.restore());
5011
+ r.stroke && (e.save(), $r(e, r.stroke, i), g(e, t, n, a, o), e.stroke(), e.restore());
5006
5012
  }, y = (e, t, n, a, o) => {
5007
5013
  let s = r.sp3d;
5008
5014
  if (s && (s.contourW ?? 0) > 0 && s.contourClr) {
5009
5015
  let r = Math.max(.5, s.contourW * i);
5010
5016
  e.save(), e.beginPath();
5011
5017
  let c = r * 2 + Math.max(a, o);
5012
- e.rect(t - c, n - c, a + 2 * c, o + 2 * c), h(e, t, n, a, o), e.clip("evenodd"), e.beginPath(), g(e, t, n, a, o), e.strokeStyle = X(s.contourClr), e.lineWidth = r * 2, e.setLineDash([]), e.stroke(), e.restore();
5018
+ e.rect(t - c, n - c, a + 2 * c, o + 2 * c), h(e, t, n, a, o), e.clip("evenodd"), e.beginPath(), g(e, t, n, a, o), e.strokeStyle = Z(s.contourClr), e.lineWidth = r * 2, e.setLineDash([]), e.stroke(), e.restore();
5013
5019
  }
5014
5020
  }, b = r.scene3d && Dt(r.scene3d.camera) ? r.scene3d : null, x = (e, t, n, r, i) => {
5015
5021
  e.save(), _(e, t, n, r, i), m ? e.drawImage(l, m.sx, m.sy, m.sw, m.sh, t, n, r, i) : e.drawImage(l, t, n, r, i), e.restore();
@@ -5017,20 +5023,20 @@ async function Zr(e, r, i, a) {
5017
5023
  x(e, t, n, r, i), v(e, t, n, r, i), y(e, t, n, r, i);
5018
5024
  }, C = (e, t, n, r, i) => {
5019
5025
  x(e, t, n, r, i), v(e, t, n, r, i);
5020
- }, w = e.getTransform(), T = Math.abs(w.a * w.d - w.b * w.c), E = T > 0 ? Math.sqrt(T) : 1, D = Gr(r.sp3d, r.scene3d?.lightRig, r.sp3d ? r.sp3d.prstMaterial : void 0, i, E), O = b ? Kr(r.sp3d, b.camera, f, p, i, E) : null, k = r.stroke ? r.stroke.width * i / 2 : 0, A = r.sp3d?.contourW ? r.sp3d.contourW * i : 0, j = O ? Math.hypot(O.offsetX, O.offsetY) / E : 0, M = k + A + j + 2, N = (e) => {
5026
+ }, w = e.getTransform(), T = Math.abs(w.a * w.d - w.b * w.c), E = T > 0 ? Math.sqrt(T) : 1, D = Wr(r.sp3d, r.scene3d?.lightRig, r.sp3d ? r.sp3d.prstMaterial : void 0, i, E), O = b ? Gr(r.sp3d, b.camera, f, p, i, E) : null, k = r.stroke ? r.stroke.width * i / 2 : 0, A = r.sp3d?.contourW ? r.sp3d.contourW * i : 0, j = O ? Math.hypot(O.offsetX, O.offsetY) / E : 0, M = k + A + j + 2, N = (e) => {
5021
5027
  if (b) {
5022
- if (qr(e, b.camera, u, d, f, p, C, {
5028
+ if (Kr(e, b.camera, u, d, f, p, C, {
5023
5029
  bevels: D,
5024
5030
  extrusion: O ?? void 0,
5025
5031
  paintEdges: y,
5026
5032
  edgePadCss: M
5027
5033
  })) return;
5028
- } else if (D.length > 0 && Jr(e, u, d, f, p, D, C, y, M)) return;
5034
+ } else if (D.length > 0 && qr(e, u, d, f, p, D, C, y, M)) return;
5029
5035
  S(e, u, d, f, p);
5030
5036
  }, F = (e, t, n, r, i, a) => {
5031
5037
  e.save(), _(e, n, r, i, a), e.fillStyle = t, e.fillRect(n, r, i, a), e.restore();
5032
5038
  }, I = (e, t) => {
5033
- b && qr(e, b.camera, u, d, f, p, (e, n, r, i, a) => F(e, t, n, r, i, a)) || F(e, t, u, d, f, p);
5039
+ b && Kr(e, b.camera, u, d, f, p, (e, n, r, i, a) => F(e, t, n, r, i, a)) || F(e, t, u, d, f, p);
5034
5040
  }, L = e.canvas.width || 0, R = e.canvas.height || 0, z = e.getTransform(), B = Math.abs(z.a * z.d - z.b * z.c), V = B > 0 ? Math.sqrt(B) : 1, H = {
5035
5041
  x: u * V,
5036
5042
  y: d * V,
@@ -5039,24 +5045,24 @@ async function Zr(e, r, i, a) {
5039
5045
  }, U = i * V, W = (e) => e.setTransform(z), G = L > 0 && R > 0;
5040
5046
  r.reflection && G && (e.save(), e.setTransform(new DOMMatrix()), gt(e, (e) => {
5041
5047
  W(e), N(e);
5042
- }, H, r.reflection, U, L, R), e.restore()), r.shadow ? xr(e, r.shadow, i) : r.glow && Sr(e, r.glow, i), r.softEdge && G ? (e.save(), e.setTransform(new DOMMatrix()), ht(e, (e) => {
5048
+ }, H, r.reflection, U, L, R), e.restore()), r.shadow ? br(e, r.shadow, i) : r.glow && xr(e, r.glow, i), r.softEdge && G ? (e.save(), e.setTransform(new DOMMatrix()), ht(e, (e) => {
5043
5049
  W(e), N(e);
5044
5050
  }, H, r.softEdge, U, L, R, (e) => {
5045
5051
  W(e), I(e, "#000");
5046
- }), e.restore()) : N(e), (r.shadow || r.glow) && Cr(e), r.innerShadow && G && (e.save(), e.setTransform(new DOMMatrix()), mt(e, (e) => {
5052
+ }), e.restore()) : N(e), (r.shadow || r.glow) && Sr(e), r.innerShadow && G && (e.save(), e.setTransform(new DOMMatrix()), mt(e, (e) => {
5047
5053
  W(e), I(e, "#000");
5048
5054
  }, H, r.innerShadow, U, L, R), e.restore()), e.restore();
5049
5055
  } catch {}
5050
5056
  }
5051
- async function Qr(e, t, n, r, i) {
5052
- let a = Y(t.x, n), o = Y(t.y, n), s = Y(t.width, n), c = Y(t.height, n), l;
5057
+ async function Zr(e, t, n, r, i) {
5058
+ let a = X(t.x, n), o = X(t.y, n), s = X(t.width, n), c = X(t.height, n), l;
5053
5059
  if (t.posterPath && r) try {
5054
- l = await Xr(t, r);
5060
+ l = await Yr(t, r);
5055
5061
  } catch {}
5056
- e.save(), ei(e, t, n), l ? e.drawImage(l, a, o, s, c) : (e.fillStyle = t.mediaKind === "video" ? "#111" : "#f0f0f0", e.fillRect(a, o, s, c)), i || En(e, a + s / 2, o + c / 2, s, c, "paused"), e.restore();
5062
+ e.save(), ei(e, t, n), l ? e.drawImage(l, a, o, s, c) : (e.fillStyle = t.mediaKind === "video" ? "#111" : "#f0f0f0", e.fillRect(a, o, s, c)), i || Tn(e, a + s / 2, o + c / 2, s, c, "paused"), e.restore();
5057
5063
  }
5058
- function $r(e, t, n, r, i, a) {
5059
- let o = Math.max(.5, Y(r.width, a)), s = n.x - t.x, c = n.y - t.y, l = Math.hypot(s, c);
5064
+ function Qr(e, t, n, r, i, a) {
5065
+ let o = Math.max(.5, X(r.width, a)), s = n.x - t.x, c = n.y - t.y, l = Math.hypot(s, c);
5060
5066
  if (l === 0) return;
5061
5067
  let u = -c / l, d = s / l, f;
5062
5068
  switch (i) {
@@ -5105,19 +5111,19 @@ function $r(e, t, n, r, i, a) {
5105
5111
  break;
5106
5112
  default: return;
5107
5113
  }
5108
- e.save(), e.globalCompositeOperation = "destination-out", e.strokeStyle = "#000", e.lineWidth = o + .5, e.setLineDash([]), e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(n.x, n.y), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle = X(r.color);
5114
+ e.save(), e.globalCompositeOperation = "destination-out", e.strokeStyle = "#000", e.lineWidth = o + .5, e.setLineDash([]), e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(n.x, n.y), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle = Z(r.color);
5109
5115
  for (let r of f) {
5110
5116
  let i = u * (o * r.offset), a = d * (o * r.offset);
5111
5117
  e.lineWidth = Math.max(.5, o * r.widthFrac), e.beginPath(), e.moveTo(t.x + i, t.y + a), e.lineTo(n.x + i, n.y + a), e.stroke();
5112
5118
  }
5113
5119
  e.restore();
5114
5120
  }
5115
- function $(e, t, n) {
5121
+ function $r(e, t, n) {
5116
5122
  je(e, t, n);
5117
5123
  }
5118
5124
  function ei(e, t, n) {
5119
5125
  if (t.rotation === 0 && !t.flipH && !t.flipV) return;
5120
- let r = Y(t.x, n), i = Y(t.y, n), a = Y(t.width, n), o = Y(t.height, n);
5126
+ let r = X(t.x, n), i = X(t.y, n), a = X(t.width, n), o = X(t.height, n);
5121
5127
  e.translate(r + a / 2, i + o / 2), e.rotate(t.rotation * Math.PI / 180), t.flipH && e.scale(-1, 1), t.flipV && e.scale(1, -1), e.translate(-(r + a / 2), -(i + o / 2));
5122
5128
  }
5123
5129
  function ti(e, t, n, r, i = {
@@ -5126,17 +5132,17 @@ function ti(e, t, n, r, i = {
5126
5132
  dpr: 1
5127
5133
  }) {
5128
5134
  e.save(), ei(e, t, n);
5129
- let a = Y(t.x, n), o = Y(t.y, n), s = t.cols.map((e) => Y(e, n)), c = s.length, l = (e, t) => {
5135
+ let a = X(t.x, n), o = X(t.y, n), s = t.cols.map((e) => X(e, n)), c = s.length, l = (e, t) => {
5130
5136
  let n = 0;
5131
5137
  for (let r = 0; r < t; r++) n += s[e + r] ?? 0;
5132
5138
  return n;
5133
- }, d = t.rows.map((e) => Y(e.height, n));
5139
+ }, d = t.rows.map((e) => X(e.height, n));
5134
5140
  for (let a = 0; a < t.rows.length; a++) {
5135
5141
  let o = t.rows[a];
5136
5142
  for (let t = 0; t < o.cells.length; t++) {
5137
5143
  let s = o.cells[t];
5138
5144
  if (s.hMerge || s.vMerge || (s.rowSpan || 1) > 1 || !s.textBody) continue;
5139
- let c = l(t, s.gridSpan || 1), u = Wr(e, s.textBody, 0, 0, c, 0, n, null, 0, !1, !1, "#000000", r, i, void 0, !0) || 0;
5145
+ let c = l(t, s.gridSpan || 1), u = Ur(e, s.textBody, 0, 0, c, 0, n, null, 0, !1, !1, "#000000", r, i, void 0, !0) || 0;
5140
5146
  u > d[a] && (d[a] = u);
5141
5147
  }
5142
5148
  }
@@ -5147,7 +5153,7 @@ function ti(e, t, n, r, i = {
5147
5153
  if (s.hMerge || s.vMerge) continue;
5148
5154
  let c = s.rowSpan || 1;
5149
5155
  if (c <= 1 || !s.textBody) continue;
5150
- let u = l(t, s.gridSpan || 1), f = Wr(e, s.textBody, 0, 0, u, 0, n, null, 0, !1, !1, "#000000", r, i, void 0, !0) || 0, p = 0;
5156
+ let u = l(t, s.gridSpan || 1), f = Ur(e, s.textBody, 0, 0, u, 0, n, null, 0, !1, !1, "#000000", r, i, void 0, !0) || 0, p = 0;
5151
5157
  for (let e = 0; e < c && a + e < d.length; e++) p += d[a + e];
5152
5158
  if (f > p) {
5153
5159
  let e = (f - p) / c;
@@ -5192,10 +5198,10 @@ function ti(e, t, n, r, i = {
5192
5198
  }
5193
5199
  }
5194
5200
  for (let { cell: t, colX: a, rowY: o, cellW: s, cellH: c } of g) {
5195
- let l = Jn(t.fill);
5201
+ let l = qn(t.fill);
5196
5202
  if (l && (e.fillStyle = l, e.fillRect(a, o, s, c)), t.textBody) {
5197
- let l = t.textColor ? X(t.textColor) : null;
5198
- Wr(e, t.textBody, a, o, s, c, n, l, 0, !1, !1, "#000000", r, i);
5203
+ let l = t.textColor ? Z(t.textColor) : null;
5204
+ Ur(e, t.textBody, a, o, s, c, n, l, 0, !1, !1, "#000000", r, i);
5199
5205
  }
5200
5206
  }
5201
5207
  let v = i.dpr, y = (e, t) => {
@@ -5203,7 +5209,7 @@ function ti(e, t, n, r, i = {
5203
5209
  let n = _[e][t];
5204
5210
  return n < 0 ? null : g[n];
5205
5211
  }, b = (t, r, i, a, o) => {
5206
- $(e, t, n);
5212
+ $r(e, t, n);
5207
5213
  let s = r === a ? u(r, e.lineWidth, v) : 0, c = i === o ? u(i, e.lineWidth, v) : 0;
5208
5214
  e.beginPath(), e.moveTo(r + s, i + c), e.lineTo(a + s, o + c), e.stroke();
5209
5215
  };
@@ -5219,7 +5225,7 @@ function ti(e, t, n, r, i = {
5219
5225
  for (; a < n;) {
5220
5226
  let r = _[e][a], o = a + 1;
5221
5227
  for (; o < n && _[e][o] === r;) o++;
5222
- let s = y(e, a), c = In(i.borderB, s ? s.cell.borderT : null);
5228
+ let s = y(e, a), c = Fn(i.borderB, s ? s.cell.borderT : null);
5223
5229
  if (c) {
5224
5230
  let e = m(a, o - a);
5225
5231
  b(c, e, t, e + l(a, o - a), t);
@@ -5235,11 +5241,11 @@ function ti(e, t, n, r, i = {
5235
5241
  for (; t <= r.lastRi;) {
5236
5242
  let n = _[t][x], i = t;
5237
5243
  for (; i + 1 <= r.lastRi && _[i + 1][x] === n;) i++;
5238
- let a = y(t, x), o = In(p, a ? S(a.cell) : null);
5244
+ let a = y(t, x), o = Fn(p, a ? S(a.cell) : null);
5239
5245
  o && b(o, e, h[t], e, h[i] + d[i]), t = i + 1;
5240
5246
  }
5241
5247
  }
5242
- i.diagonalTL && ($(e, i.diagonalTL, n), e.beginPath(), e.moveTo(a, o), e.lineTo(a + s, o + u), e.stroke()), i.diagonalTR && ($(e, i.diagonalTR, n), e.beginPath(), e.moveTo(a + s, o), e.lineTo(a, o + u), e.stroke()), e.restore();
5248
+ i.diagonalTL && ($r(e, i.diagonalTL, n), e.beginPath(), e.moveTo(a, o), e.lineTo(a + s, o + u), e.stroke()), i.diagonalTR && ($r(e, i.diagonalTR, n), e.beginPath(), e.moveTo(a + s, o), e.lineTo(a, o + u), e.stroke()), e.restore();
5243
5249
  }
5244
5250
  e.restore();
5245
5251
  }
@@ -5288,9 +5294,9 @@ async function oi(e, t, r, i, a = {}, o) {
5288
5294
  themeMinorFont: a.minorFont ?? null,
5289
5295
  themeHlinkColor: a.hlinkColor ?? null,
5290
5296
  dpr: h,
5291
- smartArtFallbackTextColor: Bn(t.background, v)
5297
+ smartArtFallbackTextColor: zn(t.background, v)
5292
5298
  };
5293
- if (await _r(_, t.background, d, f, u, a.fetchImage), c() || (a.math && await nr(t, a.math), c())) return e;
5299
+ if (await gr(_, t.background, d, f, u, a.fetchImage), c() || (a.math && await tr(t, a.math), c())) return e;
5294
5300
  let b = t.slideNumber;
5295
5301
  for (let e of t.elements) if (e.type === "picture" && a.fetchImage) {
5296
5302
  let t = e, r = t.mimeType === "image/svg+xml";
@@ -5305,12 +5311,12 @@ async function oi(e, t, r, i, a = {}, o) {
5305
5311
  }
5306
5312
  } else if (e.type === "media") {
5307
5313
  let t = e;
5308
- t.posterPath && a.fetchMedia && Xr(t, a.fetchMedia).catch(() => void 0);
5314
+ t.posterPath && a.fetchMedia && Yr(t, a.fetchMedia).catch(() => void 0);
5309
5315
  }
5310
5316
  if (a.fetchImage) {
5311
5317
  let n = a.fetchImage, r = /* @__PURE__ */ new Set();
5312
5318
  for (let e of t.elements) if (!(e.type !== "shape" || !e.textBody)) for (let t of e.textBody.paragraphs) {
5313
- let e = wn(t.bullet);
5319
+ let e = Cn(t.bullet);
5314
5320
  e.type === "blip" && r.add(`${e.imagePath} ${e.mimeType}`);
5315
5321
  }
5316
5322
  if (r.size > 0 && (await Promise.all([...r].map((e) => {
@@ -5320,17 +5326,17 @@ async function oi(e, t, r, i, a = {}, o) {
5320
5326
  }
5321
5327
  for (let r of t.elements) {
5322
5328
  if (c()) return e;
5323
- if (r.type === "shape") Rr(_, r, u, v, b, y, o, a.fetchImage);
5324
- else if (r.type === "picture") await Zr(_, r, u, a.fetchImage);
5329
+ if (r.type === "shape") Lr(_, r, u, v, b, y, o, a.fetchImage);
5330
+ else if (r.type === "picture") await Xr(_, r, u, a.fetchImage);
5325
5331
  else if (r.type === "table") ti(_, r, u, b, y);
5326
- else if (r.type === "media") await Qr(_, r, u, a.fetchMedia, a.skipMediaControls);
5332
+ else if (r.type === "media") await Zr(_, r, u, a.fetchMedia, a.skipMediaControls);
5327
5333
  else if (r.type === "chart") {
5328
5334
  let e = n * u;
5329
5335
  _.save(), ei(_, r, u), Ee(_, r.chart, {
5330
- x: Y(r.x, u),
5331
- y: Y(r.y, u),
5332
- w: Y(r.width, u),
5333
- h: Y(r.height, u)
5336
+ x: X(r.x, u),
5337
+ y: X(r.y, u),
5338
+ w: X(r.width, u),
5339
+ h: X(r.height, u)
5334
5340
  }, e), _.restore();
5335
5341
  }
5336
5342
  }
@@ -5414,7 +5420,7 @@ async function fi(e, t, n) {
5414
5420
  if (e === u || h?.state === e) vi(r, e, t);
5415
5421
  else if (t.paused) {
5416
5422
  let { x: t, y: n, w: i, h: a } = e.posterRect;
5417
- En(r, t + i / 2, n + a / 2, i, a, "paused");
5423
+ Tn(r, t + i / 2, n + a / 2, i, a, "paused");
5418
5424
  }
5419
5425
  }
5420
5426
  }, f = () => {
@@ -5488,7 +5494,7 @@ async function fi(e, t, n) {
5488
5494
  var pi = 28, mi = 14, hi = 72, gi = 10, _i = 3;
5489
5495
  function vi(e, t, n) {
5490
5496
  let r = Number.isFinite(n.duration) ? n.duration : 0, i = r > 0 ? Math.min(1, n.currentTime / r) : 0, a = t.posterRect;
5491
- En(e, a.x + a.w / 2, a.y + a.h / 2, a.w, a.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ? bi(e, t, n, r, i) : yi(e, t, n, r, i);
5497
+ Tn(e, a.x + a.w / 2, a.y + a.h / 2, a.w, a.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ? bi(e, t, n, r, i) : yi(e, t, n, r, i);
5492
5498
  }
5493
5499
  function yi(e, t, n, r, i) {
5494
5500
  let { x: a, y: o, w: s, h: c } = t.rect, l = Math.max(28, Math.min(56, c * .22)), u = o + c - l;
@@ -5882,7 +5888,7 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
5882
5888
  constructor(e, t = {}) {
5883
5889
  this.opts = t, this.canvas = e, this._mode = t.mode ?? "main", this._hiddenMode = t.hiddenSlideMode ?? "show";
5884
5890
  let n = e.parentElement;
5885
- this._originalParent = n, this._originalNextSibling = e.nextSibling, this._originalDisplay = e.style.display, this.wrapper = document.createElement("div"), this.wrapper.style.cssText = "position:relative;display:inline-block;vertical-align:top;", e.style.display || (e.style.display = "block"), n && n.insertBefore(this.wrapper, e), this.wrapper.appendChild(e), this._mode === "worker" && !t.enableMediaPlayback && (this._bitmapCtx = e.getContext("bitmaprenderer")), t.enableTextSelection && (this.textLayer = document.createElement("div"), this.textLayer.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", this.wrapper.appendChild(this.textLayer)), this.highlightLayer = document.createElement("div"), this.highlightLayer.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", this.wrapper.appendChild(this.highlightLayer), this._find = new Cn(() => this.slideCount, (e) => this._collectSlideRuns(e));
5891
+ this._originalParent = n, this._originalNextSibling = e.nextSibling, this._originalDisplay = e.style.display, this.wrapper = document.createElement("div"), this.wrapper.style.cssText = "position:relative;display:inline-block;vertical-align:top;", e.style.display || (e.style.display = "block"), n && n.insertBefore(this.wrapper, e), this.wrapper.appendChild(e), this._mode === "worker" && !t.enableMediaPlayback && (this._bitmapCtx = e.getContext("bitmaprenderer")), t.enableTextSelection && (this.textLayer = document.createElement("div"), this.textLayer.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", this.wrapper.appendChild(this.textLayer)), this.highlightLayer = document.createElement("div"), this.highlightLayer.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", this.wrapper.appendChild(this.highlightLayer), this._find = new Sn(() => this.slideCount, (e) => this._collectSlideRuns(e));
5886
5892
  }
5887
5893
  async load(e) {
5888
5894
  let t = ++this._loadGen, n = this.engine;
@@ -6036,7 +6042,7 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6036
6042
  }
6037
6043
  _buildHighlightLayer(e, t, n) {
6038
6044
  let r = this.highlightLayer;
6039
- r && Sn(r, e, this._find.slideHighlights(this.currentSlide), t, n, (e) => this._measureForFont(e));
6045
+ r && xn(r, e, this._find.slideHighlights(this.currentSlide), t, n, (e) => this._measureForFont(e));
6040
6046
  }
6041
6047
  _measureForFont(e) {
6042
6048
  this._measureCtx ||= document.createElement("canvas").getContext("2d");
@@ -6068,7 +6074,7 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6068
6074
  this._buildHighlightLayer(e, t, n);
6069
6075
  }
6070
6076
  _buildTextLayer(e, t, n, r) {
6071
- xn(e, t, n, r, this._hyperlinkHandler());
6077
+ Y(e, t, n, r, this._hyperlinkHandler());
6072
6078
  }
6073
6079
  _hyperlinkHandler() {
6074
6080
  if (this.opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
@@ -6134,6 +6140,9 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6134
6140
  _prevBase = 0;
6135
6141
  _lastFitWidth = 0;
6136
6142
  _pageShadow;
6143
+ _find = new Sn(() => this.slideCount, (e) => this._collectSlideRuns(e));
6144
+ _findActive = !1;
6145
+ _findMeasureCtx;
6137
6146
  constructor(e, t = {}) {
6138
6147
  if (e.tagName === "CANVAS") throw Error("PptxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-slide canvas API use PptxViewer.");
6139
6148
  if (this._container = e, this._opts = t, this._pageShadow = t.pageShadow ?? Gi, this._injected = !!t.presentation, this._injected) {
@@ -6166,7 +6175,7 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6166
6175
  r.destroy();
6167
6176
  return;
6168
6177
  }
6169
- if (this._pres = r, n?.destroy(), n) {
6178
+ if (this._pres = r, n?.destroy(), this._find.invalidate(), this._findActive = !1, n) {
6170
6179
  for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
6171
6180
  this._lastTopIndex = -1;
6172
6181
  }
@@ -6226,6 +6235,9 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6226
6235
  _overscan() {
6227
6236
  return this._opts.overscan ?? 1;
6228
6237
  }
6238
+ _mediaOverscan() {
6239
+ return this._opts.mediaOverscan ?? 1;
6240
+ }
6229
6241
  _pad() {
6230
6242
  let e = this._gap();
6231
6243
  return {
@@ -6251,6 +6263,12 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6251
6263
  _range() {
6252
6264
  return Ve(this._heights, this._gap(), this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan(), this._pad());
6253
6265
  }
6266
+ _mediaRange() {
6267
+ return Ve(this._heights, this._gap(), this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._mediaOverscan(), this._pad());
6268
+ }
6269
+ _rangeContains(e, t) {
6270
+ return t >= e.start && t <= e.end;
6271
+ }
6254
6272
  _syncSpacer() {
6255
6273
  let e = this._range();
6256
6274
  this._lastRange = e, this._spacer.style.height = `${e.totalHeight}px`, this._syncSpacerWidth();
@@ -6264,15 +6282,15 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6264
6282
  }
6265
6283
  _mountVisible() {
6266
6284
  if (!this._pres || this._pres.slideCount === 0) return;
6267
- let e = this._range();
6285
+ let e = this._range(), t = this._opts.enableMediaPlayback ? this._mediaRange() : null;
6268
6286
  this._lastRange = e;
6269
6287
  for (let [t, n] of [...this._slots]) (t < e.start || t > e.end) && this._recycleSlot(t, n);
6270
- for (let t = e.start; t <= e.end; t++) if (this._slots.has(t)) this._positionSlot(this._slots.get(t), t, e);
6288
+ for (let n = e.start; n <= e.end; n++) if (this._slots.has(n)) this._positionSlot(this._slots.get(n), n, e);
6271
6289
  else {
6272
- let n = this._acquireSlot();
6273
- this._positionSlot(n, t, e), this._slots.set(t, n), this._renderSlot(t, n);
6290
+ let r = this._acquireSlot();
6291
+ this._positionSlot(r, n, e), this._slots.set(n, r), this._renderSlot(n, r, !!t && this._rangeContains(t, n));
6274
6292
  }
6275
- e.topIndex !== this._lastTopIndex && (this._lastTopIndex = e.topIndex, this._opts.onVisibleSlideChange?.(e.topIndex, this._pres.slideCount));
6293
+ t && this._syncMediaPlayback(t), e.topIndex !== this._lastTopIndex && (this._lastTopIndex = e.topIndex, this._opts.onVisibleSlideChange?.(e.topIndex, this._pres.slideCount));
6276
6294
  }
6277
6295
  _applyPageShadow(e) {
6278
6296
  this._pageShadow !== !1 && (e.style.boxShadow = this._pageShadow);
@@ -6285,18 +6303,25 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6285
6303
  let n = document.createElement("canvas");
6286
6304
  n.style.cssText = "display:block;background:#fff;", this._applyPageShadow(n), t.appendChild(n);
6287
6305
  let r = null;
6288
- return this._opts.enableTextSelection && (r = document.createElement("div"), r.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", t.appendChild(r)), this._scrollHost.appendChild(t), {
6306
+ this._opts.enableTextSelection && (r = document.createElement("div"), r.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", t.appendChild(r));
6307
+ let i = document.createElement("div");
6308
+ return i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i), this._scrollHost.appendChild(t), {
6289
6309
  wrapper: t,
6290
6310
  canvas: n,
6291
6311
  textLayer: r,
6312
+ highlightLayer: i,
6292
6313
  renderedSlide: -1,
6293
6314
  renderedScale: -1,
6294
6315
  bitmap: null,
6295
- bitmapCtx: null
6316
+ bitmapCtx: null,
6317
+ presentationHandle: null,
6318
+ mediaInteractive: !1,
6319
+ renderGeneration: 0,
6320
+ presentationGeneration: 0
6296
6321
  };
6297
6322
  }
6298
6323
  _recycleSlot(e, t) {
6299
- this._slots.delete(e), t.bitmap &&= (t.bitmap.close(), null), t.textLayer && (t.textLayer.innerHTML = "", t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = ""), t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
6324
+ this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.bitmap &&= (t.bitmap.close(), null), t.textLayer && (t.textLayer.innerHTML = "", t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = ""), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
6300
6325
  }
6301
6326
  _positionSlot(e, t, n) {
6302
6327
  e.wrapper.style.top = `${n.offsets[t]}px`;
@@ -6308,54 +6333,84 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6308
6333
  _dpr() {
6309
6334
  return this._opts.dpr ?? (typeof window < "u" && window.devicePixelRatio || 1);
6310
6335
  }
6311
- _renderSlot(e, t) {
6336
+ _renderSlot(e, t, n = !1) {
6312
6337
  if (!this._pres || t.renderedSlide === e) return;
6313
6338
  t.renderedSlide = e;
6314
- let n = this._dpr(), r = this._slideWidthPx(), i = this._renderEpoch, a = this._scale;
6315
- if (this._mode === "worker") {
6316
- this._renderSlotBitmap(e, t, r, n, a);
6339
+ let r = ++t.renderGeneration, i = this._dpr(), a = this._slideWidthPx(), o = this._renderEpoch, s = this._scale;
6340
+ if (this._opts.enableMediaPlayback && n) {
6341
+ t.mediaInteractive = !0, this._renderInteractiveSlot(e, t, a, i, s, o);
6317
6342
  return;
6318
6343
  }
6319
- let o = [], s = !!this._opts.enableTextSelection && !!t.textLayer, c = s ? (e) => o.push(e) : void 0;
6320
- this._pres.renderSlide(t.canvas, e, {
6321
- width: r,
6322
- dpr: n,
6323
- onTextRun: c
6344
+ if (t.mediaInteractive = !1, this._mode === "worker") {
6345
+ this._renderSlotBitmap(e, t, a, i, s, r);
6346
+ return;
6347
+ }
6348
+ let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0, f = t.canvas;
6349
+ this._pres.renderSlide(f, e, {
6350
+ width: a,
6351
+ dpr: i,
6352
+ onTextRun: d
6324
6353
  }).then(() => {
6325
- i !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e || (t.renderedScale = a, s && t.textLayer && xn(t.textLayer, o, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler()));
6354
+ r !== t.renderGeneration || f !== t.canvas || o !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e || (t.renderedScale = s, l && t.textLayer && Y(t.textLayer, c, Math.round(a), Math.round(this._slideHeightPx()), this._hyperlinkHandler()), u && this._refreshFindRuns(e, c), this._redrawSlotHighlights(e, t));
6326
6355
  }).catch((e) => {
6327
6356
  this._reportRenderError(e);
6328
6357
  });
6329
6358
  }
6359
+ _renderInteractiveSlot(e, t, n, r, i, a) {
6360
+ if (!this._pres) return;
6361
+ let o = ++t.presentationGeneration;
6362
+ t.presentationHandle?.destroy(), t.presentationHandle = null;
6363
+ let s = [], c = !!this._opts.enableTextSelection && !!t.textLayer, l = c || this._findActive, u = l ? (e) => s.push(e) : void 0;
6364
+ this._pres.presentSlide(t.canvas, e, {
6365
+ width: n,
6366
+ dpr: r,
6367
+ onTextRun: u
6368
+ }).then((r) => {
6369
+ if (o !== t.presentationGeneration || !t.mediaInteractive || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
6370
+ r.destroy();
6371
+ return;
6372
+ }
6373
+ t.presentationHandle = r, t.renderedScale = i, c && t.textLayer && Y(t.textLayer, s, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler()), l && this._refreshFindRuns(e, s), this._redrawSlotHighlights(e, t);
6374
+ }).catch((e) => {
6375
+ o === t.presentationGeneration && this._reportRenderError(e);
6376
+ });
6377
+ }
6378
+ _syncMediaPlayback(e = this._mediaRange()) {
6379
+ if (this._opts.enableMediaPlayback) for (let [t, n] of this._slots) {
6380
+ let r = this._rangeContains(e, t);
6381
+ r !== n.mediaInteractive && (r ? (n.mediaInteractive = !0, this._settleInteractiveSlot(t, n, this._slideWidthPx(), this._dpr(), this._scale, this._renderEpoch)) : (n.mediaInteractive = !1, n.presentationGeneration++, n.presentationHandle?.destroy(), n.presentationHandle = null));
6382
+ }
6383
+ }
6330
6384
  _reportRenderError(e) {
6331
6385
  if (this._destroyed) return;
6332
6386
  let t = e instanceof Error ? e : Error(String(e));
6333
6387
  this._opts.onError ? this._opts.onError(t) : console.error("[ooxml] PptxScrollViewer render failed:", t);
6334
6388
  }
6335
- async _renderSlotBitmap(e, t, n, r, i) {
6389
+ async _renderSlotBitmap(e, t, n, r, i, a = ++t.renderGeneration) {
6336
6390
  if (this._slideInFlight.has(e) || this._slots.get(e) !== t) return;
6337
- let a = this._renderEpoch;
6391
+ let o = this._renderEpoch;
6338
6392
  this._slideInFlight.add(e);
6339
- let o = !1;
6340
- t.bitmapCtx ||= t.canvas.getContext("bitmaprenderer");
6341
- let s = !!this._opts.enableTextSelection && !!t.textLayer, c = [];
6393
+ let s = t.canvas, c = !1;
6394
+ t.bitmapCtx ||= s.getContext("bitmaprenderer");
6395
+ let l = t.bitmapCtx, u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive, f = [];
6342
6396
  try {
6343
- let l = await this._pres.renderSlideToBitmap(e, {
6397
+ let p = await this._pres.renderSlideToBitmap(e, {
6344
6398
  width: n,
6345
6399
  dpr: r,
6346
- onTextRun: s ? (e) => c.push(e) : void 0
6400
+ onTextRun: d ? (e) => f.push(e) : void 0
6347
6401
  });
6348
- if (a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
6349
- l.close();
6402
+ if (a !== t.renderGeneration || s !== t.canvas || o !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
6403
+ p.close();
6350
6404
  return;
6351
6405
  }
6352
- t.bitmap && t.bitmap.close(), t.bitmap = l, t.canvas.width = l.width, t.canvas.height = l.height, t.canvas.style.width = `${Math.round(l.width / r)}px`, t.canvas.style.height = `${Math.round(l.height / r)}px`, t.bitmapCtx?.transferFromImageBitmap(l), t.bitmap = null, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", s && xn(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler())), o = !0;
6406
+ if (!l) throw p.close(), Error("bitmaprenderer context not available");
6407
+ t.bitmap && t.bitmap.close(), t.bitmap = p, s.width = p.width, s.height = p.height, s.style.width = `${Math.round(p.width / r)}px`, s.style.height = `${Math.round(p.height / r)}px`, l.transferFromImageBitmap(p), t.bitmap = null, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", u && Y(t.textLayer, f, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler())), d && this._refreshFindRuns(e, f), this._redrawSlotHighlights(e, t), c = !0;
6353
6408
  } catch (e) {
6354
6409
  this._reportRenderError(e);
6355
6410
  } finally {
6356
6411
  this._slideInFlight.delete(e);
6357
6412
  let n = this._slots.get(e);
6358
- !o && n && (n !== t || a !== this._renderEpoch) && !this._slideInFlight.has(e) && !this._destroyed && this._renderSlotBitmap(e, n, this._slideWidthPx(), this._dpr(), this._scale);
6413
+ !c && n && (n !== t || o !== this._renderEpoch || a !== n.renderGeneration) && !this._slideInFlight.has(e) && !this._destroyed && !(this._opts.enableMediaPlayback && n.mediaInteractive) && this._renderSlotBitmap(e, n, this._slideWidthPx(), this._dpr(), this._scale);
6359
6414
  }
6360
6415
  }
6361
6416
  setScale(e) {
@@ -6405,18 +6460,18 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6405
6460
  }
6406
6461
  _previewVisible() {
6407
6462
  if (!this._pres || this._pres.slideCount === 0) return;
6408
- let e = this._range();
6463
+ let e = this._range(), t = this._opts.enableMediaPlayback ? this._mediaRange() : null;
6409
6464
  this._lastRange = e;
6410
6465
  for (let [t, n] of [...this._slots]) (t < e.start || t > e.end) && this._recycleSlot(t, n);
6411
- for (let t = e.start; t <= e.end; t++) {
6412
- let n = this._slots.get(t);
6413
- if (n) this._previewSlot(n, t, e);
6466
+ for (let n = e.start; n <= e.end; n++) {
6467
+ let r = this._slots.get(n);
6468
+ if (r) this._previewSlot(r, n, e);
6414
6469
  else {
6415
- let n = this._acquireSlot();
6416
- this._positionSlot(n, t, e), this._slots.set(t, n), this._renderSlot(t, n);
6470
+ let r = this._acquireSlot();
6471
+ this._positionSlot(r, n, e), this._slots.set(n, r), this._renderSlot(n, r, !!t && this._rangeContains(t, n));
6417
6472
  }
6418
6473
  }
6419
- e.topIndex !== this._lastTopIndex && (this._lastTopIndex = e.topIndex, this._opts.onVisibleSlideChange?.(e.topIndex, this._pres.slideCount));
6474
+ t && this._syncMediaPlayback(t), e.topIndex !== this._lastTopIndex && (this._lastTopIndex = e.topIndex, this._opts.onVisibleSlideChange?.(e.topIndex, this._pres.slideCount));
6420
6475
  }
6421
6476
  _previewSlot(e, t, n) {
6422
6477
  if (this._positionSlot(e, t, n), e.canvas.style.width = `${this._slideWidthPx()}px`, e.canvas.style.height = `${this._slideHeightPx()}px`, e.textLayer && e.renderedScale > 0) {
@@ -6430,30 +6485,57 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6430
6485
  }, Wi);
6431
6486
  }
6432
6487
  _settleRender() {
6433
- if (!(this._destroyed || !this._pres || this._pres.slideCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._settleSlot(e, t);
6488
+ if (this._destroyed || !this._pres || this._pres.slideCount === 0) return;
6489
+ let e = this._opts.enableMediaPlayback ? this._mediaRange() : null;
6490
+ for (let [t, n] of [...this._slots]) e && !this._rangeContains(e, t) || n.renderedScale !== this._scale && this._settleSlot(t, n);
6434
6491
  }
6435
6492
  _settleSlot(e, t) {
6436
6493
  if (!this._pres) return;
6437
6494
  let n = this._dpr(), r = this._slideWidthPx(), i = this._scale, a = this._renderEpoch;
6495
+ if (this._opts.enableMediaPlayback && t.mediaInteractive) {
6496
+ this._settleInteractiveSlot(e, t, r, n, i, a);
6497
+ return;
6498
+ }
6499
+ if (this._opts.enableMediaPlayback) return;
6438
6500
  if (this._mode === "worker") {
6439
6501
  this._renderSlotBitmap(e, t, r, n, i);
6440
6502
  return;
6441
6503
  }
6442
- let o = document.createElement("canvas");
6504
+ let o = document.createElement("canvas"), s = ++t.renderGeneration;
6443
6505
  o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
6444
- let s = [], c = !!this._opts.enableTextSelection && !!t.textLayer, l = c ? (e) => s.push(e) : void 0;
6506
+ let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0;
6445
6507
  this._pres.renderSlide(o, e, {
6446
6508
  width: r,
6447
6509
  dpr: n,
6448
- onTextRun: l
6510
+ onTextRun: d
6449
6511
  }).then(() => {
6450
- if (a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) return;
6512
+ if (s !== t.renderGeneration || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) return;
6451
6513
  let n = t.canvas;
6452
- t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.bitmapCtx = null, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", c && xn(t.textLayer, s, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler()));
6514
+ t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.bitmapCtx = null, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", l && Y(t.textLayer, c, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler())), u && this._refreshFindRuns(e, c), this._redrawSlotHighlights(e, t);
6453
6515
  }).catch((e) => {
6454
6516
  this._reportRenderError(e);
6455
6517
  });
6456
6518
  }
6519
+ _settleInteractiveSlot(e, t, n, r, i, a) {
6520
+ if (!this._pres) return;
6521
+ let o = ++t.presentationGeneration, s = document.createElement("canvas");
6522
+ s.style.cssText = "display:block;background:#fff;", this._applyPageShadow(s);
6523
+ let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0;
6524
+ this._pres.presentSlide(s, e, {
6525
+ width: n,
6526
+ dpr: r,
6527
+ onTextRun: d
6528
+ }).then((r) => {
6529
+ if (o !== t.presentationGeneration || !t.mediaInteractive || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
6530
+ r.destroy();
6531
+ return;
6532
+ }
6533
+ let d = t.canvas, f = t.presentationHandle;
6534
+ t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.bitmapCtx = null, t.presentationHandle = r, t.renderedScale = i, f?.destroy(), t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", l && Y(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler())), u && this._refreshFindRuns(e, c), this._redrawSlotHighlights(e, t);
6535
+ }).catch((e) => {
6536
+ o === t.presentationGeneration && this._reportRenderError(e);
6537
+ });
6538
+ }
6457
6539
  scrollToSlide(e, t) {
6458
6540
  if (!this._pres || this._pres.slideCount === 0 || !this._scaleEstablished) return;
6459
6541
  let n = Math.max(0, Math.min(e, this._pres.slideCount - 1)), r = Ve(this._heights, this._gap(), 0, this._scrollHost.clientHeight, this._overscan(), this._pad()), i = r.offsets[n] ?? 0, a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
@@ -6462,6 +6544,50 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6462
6544
  behavior: t?.behavior ?? "auto"
6463
6545
  }) : this._scrollHost.scrollTop = o, this._mountVisible();
6464
6546
  }
6547
+ async findText(e, t = {}) {
6548
+ if (!this._pres) return [];
6549
+ this._findActive = e.length > 0;
6550
+ let n = await this._find.find(e, t);
6551
+ return this._redrawHighlights(), n;
6552
+ }
6553
+ async findNext() {
6554
+ return this._activateMatch(this._find.next());
6555
+ }
6556
+ async findPrev() {
6557
+ return this._activateMatch(this._find.prev());
6558
+ }
6559
+ clearFind() {
6560
+ this._findActive = !1, this._find.invalidate(), this._redrawHighlights();
6561
+ }
6562
+ async _activateMatch(e) {
6563
+ return e && this.scrollToSlide(e.location.slide), this._redrawHighlights(), e;
6564
+ }
6565
+ async _collectSlideRuns(e) {
6566
+ return this._pres ? this._pres.collectSlideRuns(e, this._slideWidthPx()) : [];
6567
+ }
6568
+ _redrawHighlights() {
6569
+ for (let [e, t] of this._slots) this._redrawSlotHighlights(e, t);
6570
+ }
6571
+ _refreshFindRuns(e, t) {
6572
+ this._findActive && this._find.setSlideRuns(e, t);
6573
+ }
6574
+ _redrawSlotHighlights(e, t) {
6575
+ if (!this._findActive) {
6576
+ t.highlightLayer.innerHTML = "";
6577
+ return;
6578
+ }
6579
+ let n = this._find.slideRuns(e);
6580
+ if (!n) {
6581
+ t.highlightLayer.innerHTML = "";
6582
+ return;
6583
+ }
6584
+ xn(t.highlightLayer, n, this._find.slideHighlights(e), this._slideWidthPx(), this._slideHeightPx(), (e) => this._measureForFind(e));
6585
+ }
6586
+ _measureForFind(e) {
6587
+ this._findMeasureCtx === void 0 && (this._findMeasureCtx = document.createElement("canvas").getContext("2d"));
6588
+ let t = this._findMeasureCtx;
6589
+ return !t || typeof t.measureText != "function" ? (e) => e.length : (t.font = e, (e) => t.measureText(e).width);
6590
+ }
6465
6591
  _hyperlinkHandler() {
6466
6592
  if (this._opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
6467
6593
  }
@@ -6491,6 +6617,10 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6491
6617
  this.relayout();
6492
6618
  return;
6493
6619
  }
6620
+ if (this._opts.refitOnResize === !1) {
6621
+ this._lastFitWidth = this._fitWidthPx(), this._mountVisible();
6622
+ return;
6623
+ }
6494
6624
  let e = this._baseScale();
6495
6625
  if (e <= 0) return;
6496
6626
  let t = this._fitWidthPx();
@@ -6508,6 +6638,9 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6508
6638
  mountedSlideIndicesForTest() {
6509
6639
  return [...this._slots.keys()];
6510
6640
  }
6641
+ interactiveSlideIndicesForTest() {
6642
+ return [...this._slots].filter(([, e]) => e.mediaInteractive).map(([e]) => e);
6643
+ }
6511
6644
  scaleForTest() {
6512
6645
  return this._scale;
6513
6646
  }
@@ -6531,7 +6664,7 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6531
6664
  return (this._range().offsets[e] ?? 0) + t * (this._heights[e] || 0) - this._scrollHost.scrollTop;
6532
6665
  }
6533
6666
  destroy() {
6534
- this._destroyed = !0, this._loadGen++, this._scrollListener &&= (this._scrollHost.removeEventListener("scroll", this._scrollListener), null), this._wheelListener &&= (this._scrollHost.removeEventListener("wheel", this._wheelListener), null), this._resizeObserver?.disconnect(), this._resizeObserver = null, this._settleTimer !== null && (clearTimeout(this._settleTimer), this._settleTimer = null);
6667
+ this._destroyed = !0, this._loadGen++, this._find.invalidate(), this._findActive = !1, this._scrollListener &&= (this._scrollHost.removeEventListener("scroll", this._scrollListener), null), this._wheelListener &&= (this._scrollHost.removeEventListener("wheel", this._wheelListener), null), this._resizeObserver?.disconnect(), this._resizeObserver = null, this._settleTimer !== null && (clearTimeout(this._settleTimer), this._settleTimer = null);
6535
6668
  for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
6536
6669
  this._free.length = 0, this._injected || this._pres?.destroy(), this._pres = null, this._wrapper.remove();
6537
6670
  }
@@ -6541,10 +6674,10 @@ var Bi = new URL("pptx_parser_bg.wasm", import.meta.url).href, Vi = class e {
6541
6674
  PptxScrollViewer: () => Ki,
6542
6675
  PptxViewer: () => Ui,
6543
6676
  autoResize: () => R,
6544
- buildPptxHighlightLayer: () => Sn,
6545
- buildPptxTextLayer: () => xn,
6677
+ buildPptxHighlightLayer: () => xn,
6678
+ buildPptxTextLayer: () => Y,
6546
6679
  openExternalHyperlink: () => oe,
6547
6680
  renderSlide: () => ai
6548
6681
  });
6549
6682
  //#endregion
6550
- export { ai as a, Vi as i, Ki as n, Sn as o, Ui as r, xn as s, qi as t };
6683
+ export { ai as a, Vi as i, Ki as n, xn as o, Ui as r, Y as s, qi as t };