@silurus/ooxml 0.88.0 → 0.89.1

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.
Files changed (127) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +8 -7
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-C5G_Nr_A.js +35 -0
  5. package/dist/assets/render-worker-DQfWdNsm.js +16 -0
  6. package/dist/assets/render-worker-Ds7LjwU-.js +15 -0
  7. package/dist/{hyperlink-Cxzhet30.js → bounded-raw-part-cache-CsnNptAy.js} +4937 -7458
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-BZ8QCrRi.js +675 -0
  10. package/dist/cfb-guard-dNeUiANF.js +528 -0
  11. package/dist/chart-ex.mjs +667 -663
  12. package/dist/comment-overlay-controller-CBvQx-En.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-BKidRH36.js} +5 -5
  15. package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-C47QoDUy.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-MzFPrxt0.js +249 -0
  18. package/dist/document-pull-client-BoJeuURD.js +35941 -0
  19. package/dist/document-pull-worker-CaP8XESP.js +104 -0
  20. package/dist/docx-BN70UhvX.js +495 -0
  21. package/dist/docx-BRRtSvk3.js +3563 -0
  22. package/dist/docx-model-source-CTO9iw_W.js +98 -0
  23. package/dist/docx-source-worker.mjs +455 -0
  24. package/dist/docx.mjs +7 -7
  25. package/dist/docx_parser_bg.wasm +0 -0
  26. package/dist/drawingml-shape-CHmq8kpM.js +310 -0
  27. package/dist/duotone-DN8P4aXe.js +126 -0
  28. package/dist/emf-CGFQIz6c.js +1790 -0
  29. package/dist/font-preload-demand-Dmy31xt-.js +2058 -0
  30. package/dist/grid-geometry-C3IG20ut.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-DsuQ2UJs.js +7 -0
  33. package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
  34. package/dist/index.mjs +4 -4
  35. package/dist/internal-companion.mjs +12 -0
  36. package/dist/line-distribute-Bu8psjGd.js +2799 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-kz_NkZqT.js +179 -0
  40. package/dist/model-source-s5hRpk4w.js +61 -0
  41. package/dist/model-source-session-6fuaqbGs.js +71 -0
  42. package/dist/model-source-session-DqrR4XHR.js +85 -0
  43. package/dist/model-source-session-cPJSF_Ak.js +58 -0
  44. package/dist/node.mjs +7 -1327
  45. package/dist/{pixel-budget-9P63Bsk5.js → pixel-budget-BpTYrepD.js} +13 -10
  46. package/dist/plot-area-frame-Bs_j4uu7.js +41811 -0
  47. package/dist/pptx-CaJ6ILnw.js +183 -0
  48. package/dist/pptx-_BOGcBym.js +2936 -0
  49. package/dist/pptx-model-source-B_9afw9R.js +37 -0
  50. package/dist/pptx-source-worker.mjs +446 -0
  51. package/dist/pptx.mjs +8 -7
  52. package/dist/pptx_parser_bg.wasm +0 -0
  53. package/dist/presentation-model-source-CGHLyX32.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +117 -153
  56. package/dist/{render-D3iqVKCo.js → render-CzbDzRKa.js} +3 -3
  57. package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-B1u6BOUd.js} +1 -1
  58. package/dist/{render-worker-host-D4123J27.js → render-worker-host-C-EECo68.js} +1 -1
  59. package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-DDqZTCVf.js} +1 -1
  60. package/dist/renderer-CD2cvVAF.js +5823 -0
  61. package/dist/renderer-DRoeb14O.js +5170 -0
  62. package/dist/resource-measurement-Dhhm7P_l.js +772 -0
  63. package/dist/session-XPmC0CUd.js +656 -0
  64. package/dist/slide-pull-client-tq7U_fYg.js +6485 -0
  65. package/dist/three-d-BKwNPAP4.js +878 -0
  66. package/dist/three-d.mjs +925 -910
  67. package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
  68. package/dist/tiff.mjs +401 -248
  69. package/dist/types/chart-ex.d.ts +149 -2
  70. package/dist/types/docx.d.ts +333 -96
  71. package/dist/types/index.d.ts +566 -301
  72. package/dist/types/internal-companion.d.ts +11 -0
  73. package/dist/types/math.d.ts +1 -1
  74. package/dist/types/node.d.ts +422 -9
  75. package/dist/types/pptx.d.ts +302 -95
  76. package/dist/types/region-map.d.ts +149 -2
  77. package/dist/types/three-d.d.ts +149 -2
  78. package/dist/types/tiff.d.ts +1 -1
  79. package/dist/types/xlsx.d.ts +343 -132
  80. package/dist/wasm-loader-rlgHmcSv.js +35 -0
  81. package/dist/wasm-runtime-generation-D6TKZdNb.js +97 -0
  82. package/dist/workbook-model-source-BIGrfZy6.js +94 -0
  83. package/dist/worker-source-DrwhR9fw.js +22 -0
  84. package/dist/worker-source-SbudzjYL.js +22 -0
  85. package/dist/worker-source-UAi3GNcM.js +22 -0
  86. package/dist/worksheet-pull-client-ClvPO_Jf.js +579 -0
  87. package/dist/xlsx-CsmREBaZ.js +5819 -0
  88. package/dist/xlsx-DmHfeNNp.js +534 -0
  89. package/dist/xlsx-model-source-D1flORqy.js +309 -0
  90. package/dist/xlsx-source-worker.mjs +525 -0
  91. package/dist/xlsx.mjs +8 -7
  92. package/dist/xlsx_parser_bg.wasm +0 -0
  93. package/package.json +42 -16
  94. package/dist/assets/render-worker-1uPAxMZr.js +0 -31
  95. package/dist/assets/render-worker-BlvJybji.js +0 -10
  96. package/dist/assets/render-worker-CzmiJfFL.js +0 -11
  97. package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
  98. package/dist/canvas-viewer-mechanics-DbLz0rYW.js +0 -1384
  99. package/dist/cjk-fallback-bLI3z70h.js +0 -46
  100. package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
  101. package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
  102. package/dist/comments-Diid5ujN.js +0 -246
  103. package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
  104. package/dist/document-pull-client-B9PTM-pL.js +0 -27280
  105. package/dist/docx-BF9WXrYH.js +0 -3103
  106. package/dist/dom-interaction-boundary-Cnm8DSBN.js +0 -223
  107. package/dist/highlight-rect-C5hkRqUr.js +0 -13
  108. package/dist/line-distribute-D1WNHKz_.js +0 -1023
  109. package/dist/line-metrics-B60C86uh.js +0 -60
  110. package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
  111. package/dist/pptx-DkyYBYoL.js +0 -3065
  112. package/dist/renderer-B4GZb5We.js +0 -6492
  113. package/dist/resource-measurement-SHQCbkh2.js +0 -150
  114. package/dist/session-BGq81gRQ.js +0 -743
  115. package/dist/slide-pull-client-DiPnm240.js +0 -6253
  116. package/dist/source-key-DIJG8BA0.js +0 -42
  117. package/dist/three-d-DJBl8g8M.js +0 -1162
  118. package/dist/transfer-p6iCC2R7.js +0 -6
  119. package/dist/units-BzZ0gAxs.js +0 -4
  120. package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
  121. package/dist/xlsx-C9NVjgaV.js +0 -8484
  122. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  123. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  124. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  125. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  126. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  127. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,2936 @@
1
+ import { t as e } from "./chunk-Dy4uBu1J.js";
2
+ import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./slide-pull-client-tq7U_fYg.js";
3
+ import { Aa as m, vo as h, yo as g } from "./plot-area-frame-Bs_j4uu7.js";
4
+ import { n as _, t as ee } from "./cfb-guard-dNeUiANF.js";
5
+ import { H as v, M as y, N as b, Tn as x, V as S, X as C, Xt as w, Y as T, Yt as te, Zt as E, fn as ne, hn as re, ht as ie, j as ae, n as oe, qt as se, st as ce, t as le, u as D, ut as ue } from "./bounded-raw-part-cache-CsnNptAy.js";
6
+ import { C as de, D as fe, E as O, N as pe, O as me, P as k, S as he, T as A, _ as ge, a as _e, b as ve, c as ye, d as be, f as xe, g as Se, h as Ce, i as we, l as Te, m as Ee, n as De, o as Oe, p as ke, r as Ae, t as je, u as Me, v as Ne, w as j, x as Pe, y as Fe } from "./comment-overlay-controller-CBvQx-En.js";
7
+ import { f as M, u as Ie } from "./pixel-budget-BpTYrepD.js";
8
+ import { i as Le, t as Re } from "./tiff-contract-C6M3QcPp.js";
9
+ import { D as ze, E as Be, T as Ve, a as N, b as He, c as Ue, f as We, i as Ge, l as Ke, n as qe, o as P, p as Je, r as Ye, s as Xe, t as Ze, u as F, v as Qe, w as $e, x as et, y as tt } from "./canvas-viewer-mechanics-BZ8QCrRi.js";
10
+ import { n as nt } from "./renderer-module-contract-CWM7jv6d.js";
11
+ import { t as rt } from "./visible-index-FeVA0mGE.js";
12
+ import { n as it } from "./resource-measurement-Dhhm7P_l.js";
13
+ //#region packages/core/src/nav/internal-target.ts
14
+ function at(e, t) {
15
+ let n = t.startsWith("/") ? [] : e.split("/").filter((e) => e !== "");
16
+ for (let e of t.split("/")) if (e === "..") n.pop();
17
+ else if (e === "." || e === "") continue;
18
+ else n.push(e);
19
+ return n.join("/");
20
+ }
21
+ function ot(e) {
22
+ let t = /[?&]jump=([a-zA-Z]+)/.exec(e);
23
+ if (!t) return null;
24
+ let n = t[1].toLowerCase();
25
+ return n === "firstslide" || n === "lastslide" || n === "nextslide" || n === "previousslide" ? n : null;
26
+ }
27
+ function st(e, t, n) {
28
+ if (!(n <= 0)) switch (e) {
29
+ case "firstslide": return 0;
30
+ case "lastslide": return n - 1;
31
+ case "nextslide": return Math.min(t + 1, n - 1);
32
+ case "previousslide": return Math.max(t - 1, 0);
33
+ }
34
+ }
35
+ //#endregion
36
+ //#region packages/pptx/src/run-frame-transform.ts
37
+ function I(e) {
38
+ let t = e.textBodyRotation ?? 0, n = e.shapeFlipH === !0, r = e.shapeFlipV === !0;
39
+ if (n || r) return `rotate(${e.rotation}deg) scale(${n ? -1 : 1}, ${r ? -1 : 1})` + (t === 0 ? "" : ` rotate(${t}deg)`);
40
+ let i = e.rotation + t;
41
+ return i === 0 ? "" : `rotate(${i}deg)`;
42
+ }
43
+ function ct(e, t) {
44
+ return `${e.shapeX},${e.shapeY},${e.shapeW},${e.shapeH},${e.cellHorzOverflow ?? "shape"},${t}`;
45
+ }
46
+ //#endregion
47
+ //#region packages/pptx/src/run-frame-dom.ts
48
+ function lt(e, t, n, r, i, a) {
49
+ let o = e.createElement("div"), s = t.cellHorzOverflow !== void 0;
50
+ o.style.cssText = `position:absolute;left:${O(t.shapeX, n)};top:${O(t.shapeY, r)};width:${O(t.shapeW, n)};height:${O(t.shapeH, r)};pointer-events:${i};overflow:${s ? "visible" : a};`, t.cellHorzOverflow === "clip" && (o.style.overflowX = "clip", o.style.overflowY = "visible");
51
+ let c = I(t);
52
+ return c && (o.style.transformOrigin = "center center", o.style.transform = c), {
53
+ div: o,
54
+ w: t.shapeW,
55
+ h: t.shapeH
56
+ };
57
+ }
58
+ //#endregion
59
+ //#region packages/pptx/src/text-layer.ts
60
+ function L(e, t, n, r, i, a) {
61
+ e.innerHTML = "", A(e, "ooxmlSelectionSurface", "pptx"), A(e, "slideIndex", a === void 0 ? void 0 : String(a));
62
+ let o = /* @__PURE__ */ new Map(), s = e.ownerDocument ?? document;
63
+ for (let [a, c] of t.entries()) {
64
+ let t = ct(c, I(c)), l = o.get(t);
65
+ if (!l) {
66
+ let i = lt(s, c, n, r, "all", "visible");
67
+ l = i, o.set(t, l), e.appendChild(i.div);
68
+ }
69
+ let u = s.createElement("span");
70
+ A(u, "ooxmlSelectionRun", "pptx"), A(u, "runIndex", String(a)), c.shapeId !== void 0 && A(u, "shapeId", c.shapeId), c.elementIndex !== void 0 && A(u, "elementIndex", String(c.elementIndex)), c.origin !== void 0 && A(u, "elementOrigin", c.origin), u.textContent = c.text;
71
+ let d = i ? c.hyperlink : void 0;
72
+ u.style.cssText = `position:absolute;left:${O(c.inShapeX, l.w)};top:${O(c.inShapeY, l.h)};font:${c.font};line-height:${c.h}px;letter-spacing:0;white-space:pre;color:transparent;cursor:${d ? "pointer" : "text"};`, d && i && (u.title = d.kind === "external" ? d.url : d.ref, u.addEventListener("click", (e) => {
73
+ e.preventDefault(), i(d);
74
+ })), l.div.appendChild(u);
75
+ }
76
+ }
77
+ function R(e, t, n, r, i, a, o = {}) {
78
+ e.innerHTML = "";
79
+ let s = o.match ?? "rgba(255, 214, 0, 0.42)", c = o.active ?? "rgba(255, 140, 0, 0.55)", l = e.ownerDocument ?? document, u = /* @__PURE__ */ new Map(), d = (t) => {
80
+ let n = ct(t, I(t)), a = u.get(n);
81
+ if (!a) {
82
+ let o = lt(l, t, r, i, "none", "hidden");
83
+ a = o, u.set(n, a), e.appendChild(o.div);
84
+ }
85
+ return a;
86
+ };
87
+ for (let e of n) {
88
+ let n = e.active ? c : s;
89
+ for (let r of e.slices) {
90
+ let e = t[r.runIndex];
91
+ if (!e) continue;
92
+ let i = a(e.font), { x: o, width: s } = fe(e.text, r.start, r.end, i);
93
+ if (s <= 0) continue;
94
+ let c = d(e), u = l.createElement("div");
95
+ u.style.cssText = `position:absolute;left:${O(e.inShapeX + o, c.w)};top:${O(e.inShapeY, c.h)};width:${O(s, c.w)};height:${O(e.h, c.h)};background:${n};pointer-events:none;`, c.div.appendChild(u);
96
+ }
97
+ }
98
+ }
99
+ //#endregion
100
+ //#region packages/pptx/src/find.ts
101
+ function ut(e, t) {
102
+ let n = e.tableCell, r = t.tableCell;
103
+ return !n && !r ? !0 : !n || !r ? !1 : (e.renderElementIndex ?? e.elementIndex) === (t.renderElementIndex ?? t.elementIndex) && e.origin === t.origin && e.shapeId === t.shapeId && n.row === r.row && n.column === r.column;
104
+ }
105
+ function dt(e, t) {
106
+ for (let n = 1; n < t.length; n++) {
107
+ let r = e[t[n - 1].runIndex], i = e[t[n].runIndex];
108
+ if (!r || !i || !ut(r, i)) return !1;
109
+ }
110
+ return !0;
111
+ }
112
+ var ft = class extends de {
113
+ constructor(e, t) {
114
+ super(e, t, (e) => ({ slide: e }), dt);
115
+ }
116
+ slideRuns(e) {
117
+ return this.unitRuns(e);
118
+ }
119
+ setSlideRuns(e, t) {
120
+ this.setUnitRuns(e, t);
121
+ }
122
+ slideHighlights(e) {
123
+ return this.unitHighlights(e);
124
+ }
125
+ activeSlide() {
126
+ return this.activeUnit();
127
+ }
128
+ };
129
+ //#endregion
130
+ //#region packages/pptx/src/font-demand-collector.ts
131
+ async function pt(e) {
132
+ return e ? (await import("./font-preload-demand-Dmy31xt-.js")).collectSlideFontDemand : void 0;
133
+ }
134
+ //#endregion
135
+ //#region packages/pptx/src/tabular-text.ts
136
+ var mt = (e) => e >= "0" && e <= "9";
137
+ function ht(e) {
138
+ let t = 0;
139
+ for (let n = 0; n < 10; n++) t = Math.max(t, e.measureText(String(n)).width);
140
+ return t;
141
+ }
142
+ function gt(e, t, n) {
143
+ let r = 0;
144
+ for (let i of t) r += mt(i) ? n : e.measureText(i).width;
145
+ return r;
146
+ }
147
+ function _t(e, t, n, r, i) {
148
+ let a = e.textAlign;
149
+ e.textAlign = "left";
150
+ let o = n;
151
+ for (let n of t) if (mt(n)) {
152
+ let t = e.measureText(n).width;
153
+ e.fillText(n, o + (i - t) / 2, r), o += i;
154
+ } else e.fillText(n, o, r), o += e.measureText(n).width;
155
+ e.textAlign = a;
156
+ }
157
+ //#endregion
158
+ //#region packages/pptx/src/presentation-handle.ts
159
+ var z = (e, t) => e / m * t;
160
+ async function vt(e, t, n) {
161
+ let i = e.getContext("2d");
162
+ if (!i) throw Error("2D context not available");
163
+ let a = n.width / (n.slideWidthEmu / m);
164
+ await n.drawBase();
165
+ let o = document.createElement("canvas");
166
+ o.width = e.width, o.height = e.height;
167
+ let s = o.getContext("2d");
168
+ if (!s) throw Error("base 2D context not available");
169
+ s.drawImage(e, 0, 0);
170
+ let c = [], l = !1, u = () => {
171
+ for (let e of c) {
172
+ e.detachListeners(), e.media.pause(), e.media.removeAttribute("src");
173
+ try {
174
+ e.media.load();
175
+ } catch {}
176
+ URL.revokeObjectURL(e.objectUrl);
177
+ }
178
+ c.length = 0;
179
+ }, d = (e) => {
180
+ l || (n.onError ? n.onError(e) : console.error("[ooxml] PPTX embedded media failed:", e));
181
+ };
182
+ for (let e of t) {
183
+ let t;
184
+ try {
185
+ t = await n.fetchMedia(e.mediaPath);
186
+ } catch (t) {
187
+ throw u(), t instanceof g || M(t) ? t : xt(e, t);
188
+ }
189
+ let r = e.mimeType || t.type, i = t.type === r ? t : new Blob([t], { type: r }), o = URL.createObjectURL(i), s = e.mediaKind === "video" ? document.createElement("video") : document.createElement("audio");
190
+ s.src = o, s.preload = "metadata", e.mediaKind === "video" && (s.playsInline = !0);
191
+ let f = yt(e, a), p = {
192
+ el: e,
193
+ rect: e.mediaKind === "audio" ? {
194
+ x: f.x + f.w / 2 - Math.max(f.w, 260) / 2,
195
+ y: f.y,
196
+ w: Math.max(f.w, 260),
197
+ h: f.h + 36
198
+ } : f,
199
+ posterRect: f,
200
+ media: s,
201
+ objectUrl: o,
202
+ loadState: "loading",
203
+ detachListeners: () => {}
204
+ }, m = () => {
205
+ l || (p.loadState = "metadata");
206
+ }, h = () => {
207
+ l || (p.loadState = "ready");
208
+ }, _ = () => {
209
+ l || (p.loadState = "error", d(B(e, s, "decode")));
210
+ };
211
+ s.addEventListener("loadedmetadata", m), s.addEventListener("canplay", h), s.addEventListener("error", _), p.detachListeners = () => {
212
+ s.removeEventListener("loadedmetadata", m), s.removeEventListener("canplay", h), s.removeEventListener("error", _);
213
+ }, c.push(p);
214
+ try {
215
+ s.load();
216
+ } catch (t) {
217
+ let n = B(e, s, "load", t);
218
+ throw u(), n;
219
+ }
220
+ }
221
+ let f = null, p = null, h = () => {
222
+ i.setTransform(e.width / n.width, 0, 0, e.height / n.height, 0, 0), i.drawImage(o, 0, 0, e.width, e.height, 0, 0, n.width, n.height);
223
+ for (let e of c) {
224
+ let t = e.media;
225
+ if (e.loadState !== "loading") {
226
+ if (e.loadState === "error") {
227
+ bt(i, e.posterRect, "Media unavailable");
228
+ continue;
229
+ }
230
+ if (e.el.mediaKind === "video" && t.readyState >= 2) {
231
+ let { x: n, y: r, w: a, h: o } = e.posterRect;
232
+ i.drawImage(t, n, r, a, o);
233
+ }
234
+ if (e === p || y?.state === e) Et(i, e, t);
235
+ else if (t.paused) {
236
+ let { x: t, y: n, w: a, h: o } = e.posterRect;
237
+ r(i, t + a / 2, n + o / 2, a, o, "paused");
238
+ }
239
+ }
240
+ }
241
+ }, _ = () => {
242
+ l || (h(), f = requestAnimationFrame(_));
243
+ }, ee = (t, r) => {
244
+ let i = e.getBoundingClientRect();
245
+ return {
246
+ x: (t - i.left) / i.width * n.width,
247
+ y: (r - i.top) / i.height * n.height
248
+ };
249
+ }, v = (e, t) => {
250
+ for (let n of c) {
251
+ let { x: r, y: i, w: a, h: o } = n.rect;
252
+ if (e < r || e > r + a || t < i || t > i + o) continue;
253
+ let s = U(n), c = s.y - 12, l = s.y + s.h + 8;
254
+ return (Number.isFinite(n.media.duration) ? n.media.duration : 0) > 0 && e >= s.x && e <= s.x + s.w && t >= c && t <= l ? {
255
+ kind: "seek",
256
+ state: n,
257
+ fraction: Math.max(0, Math.min(1, (e - s.x) / s.w))
258
+ } : {
259
+ kind: "toggle",
260
+ state: n
261
+ };
262
+ }
263
+ return null;
264
+ }, y = null, b = (e, t) => {
265
+ let n = Number.isFinite(e.media.duration) ? e.media.duration : 0;
266
+ n <= 0 || (e.media.currentTime = n * t);
267
+ }, x = (e) => {
268
+ try {
269
+ e.media.play().catch((t) => {
270
+ d(B(e.el, e.media, "play", t));
271
+ });
272
+ } catch (t) {
273
+ d(B(e.el, e.media, "play", t));
274
+ }
275
+ }, S = (t) => {
276
+ let { x: n, y: r } = ee(t.clientX, t.clientY), i = v(n, r);
277
+ i && (i.kind === "seek" ? (y = {
278
+ state: i.state,
279
+ wasPlaying: !i.state.media.paused
280
+ }, i.state.media.pause(), b(i.state, i.fraction), e.setPointerCapture(t.pointerId), t.preventDefault()) : i.state.media.paused ? x(i.state) : i.state.media.pause());
281
+ }, C = (e) => {
282
+ let { x: t, y: n } = ee(e.clientX, e.clientY);
283
+ p = null;
284
+ for (let e of c) {
285
+ let { x: r, y: i, w: a, h: o } = e.rect;
286
+ if (t >= r && t <= r + a && n >= i && n <= i + o) {
287
+ p = e;
288
+ break;
289
+ }
290
+ }
291
+ if (y) {
292
+ let e = U(y.state), n = Math.max(0, Math.min(1, (t - e.x) / e.w));
293
+ b(y.state, n);
294
+ }
295
+ }, w = () => {
296
+ p = null;
297
+ }, T = (t) => {
298
+ if (!y) return;
299
+ let { wasPlaying: n, state: r } = y;
300
+ y = null, e.releasePointerCapture(t.pointerId), n && x(r);
301
+ };
302
+ return c.length > 0 && (e.addEventListener("pointerdown", S), e.addEventListener("pointermove", C), e.addEventListener("pointerleave", w), e.addEventListener("pointerup", T), e.addEventListener("pointercancel", T), e.style.cursor = "pointer", _()), {
303
+ play(e) {
304
+ for (let t of c) (!e || t.el.mediaPath === e) && x(t);
305
+ },
306
+ pause(e) {
307
+ for (let t of c) (!e || t.el.mediaPath === e) && t.media.pause();
308
+ },
309
+ destroy() {
310
+ l || (l = !0, f !== null && cancelAnimationFrame(f), e.removeEventListener("pointerdown", S), e.removeEventListener("pointermove", C), e.removeEventListener("pointerleave", w), e.removeEventListener("pointerup", T), e.removeEventListener("pointercancel", T), e.style.cursor = "", u());
311
+ }
312
+ };
313
+ }
314
+ function yt(e, t) {
315
+ return {
316
+ x: z(e.x, t),
317
+ y: z(e.y, t),
318
+ w: z(e.width, t),
319
+ h: z(e.height, t)
320
+ };
321
+ }
322
+ function bt(e, t, n) {
323
+ let r = Math.max(10, Math.min(14, t.h * .12));
324
+ e.save(), e.font = `500 ${r}px system-ui, -apple-system, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
325
+ let i = r + 12, a = Math.min(t.w, Math.max(100, e.measureText(n).width + 24));
326
+ W(e, t.x + (t.w - a) / 2, t.y + (t.h - i) / 2, a, i, i / 2), e.fillStyle = "rgba(20, 20, 20, 0.72)", e.fill(), e.fillStyle = "rgba(255, 255, 255, 0.95)", e.fillText(n, t.x + t.w / 2, t.y + t.h / 2), e.restore();
327
+ }
328
+ function xt(e, t) {
329
+ return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} fetch failed for "${e.mediaPath}" (mime=${e.mimeType || "unknown"}): ${St(t)}`);
330
+ }
331
+ function B(e, t, n, r) {
332
+ let i = "";
333
+ try {
334
+ i = e.mimeType ? t.canPlayType(e.mimeType) : "";
335
+ } catch {}
336
+ let a = t.error, o = [
337
+ `mime=${e.mimeType || "unknown"}`,
338
+ `canPlayType=${i || "no"}`,
339
+ `readyState=${t.readyState}`,
340
+ `networkState=${t.networkState}`
341
+ ];
342
+ a && o.push(`mediaError=${a.code}${a.message ? ` ${a.message}` : ""}`);
343
+ let s = r === void 0 ? "" : `: ${St(r)}`;
344
+ return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} ${n} failed for "${e.mediaPath}" (${o.join("; ")})${s}`);
345
+ }
346
+ function St(e) {
347
+ return e instanceof Error ? `${e.name || "Error"}${e.message ? `: ${e.message}` : ""}` : String(e);
348
+ }
349
+ var Ct = 28, V = 14, wt = 72, Tt = 10, H = 3;
350
+ function Et(e, t, n) {
351
+ let i = Number.isFinite(n.duration) ? n.duration : 0, a = i > 0 ? Math.min(1, n.currentTime / i) : 0, o = t.posterRect;
352
+ r(e, o.x + o.w / 2, o.y + o.h / 2, o.w, o.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ? Ot(e, t, n, i, a) : Dt(e, t, n, i, a);
353
+ }
354
+ function Dt(e, t, n, r, i) {
355
+ let { x: a, y: o, w: s, h: c } = t.rect, l = Math.max(28, Math.min(56, c * .22)), u = o + c - l;
356
+ e.save();
357
+ let d = e.createLinearGradient(0, u, 0, o + c);
358
+ d.addColorStop(0, "rgba(0, 0, 0, 0)"), d.addColorStop(1, "rgba(0, 0, 0, 0.55)"), e.fillStyle = d, e.fillRect(a, u, s, l), e.restore();
359
+ let f = U(t);
360
+ At(e, f, i, r > 0), e.save(), e.font = "500 11px system-ui, -apple-system, sans-serif", e.textBaseline = "middle", e.shadowColor = "rgba(0, 0, 0, 0.75)", e.shadowBlur = 3, e.fillStyle = "rgba(255, 255, 255, 0.95)", kt(e, n.currentTime, r, f.x, f.y - 10, "bottom"), e.restore();
361
+ }
362
+ function Ot(e, t, n, r, i) {
363
+ let a = jt(t.rect);
364
+ e.save(), W(e, a.x, a.y, a.w, a.h, a.h / 2), e.fillStyle = "rgba(20, 20, 20, 0.72)", e.fill(), e.font = "500 11px system-ui, -apple-system, sans-serif", e.textBaseline = "middle", e.fillStyle = "rgba(255, 255, 255, 0.95)", kt(e, n.currentTime, r, a.x + V, a.y + a.h / 2, "middle"), e.restore(), At(e, U(t), i, r > 0);
365
+ }
366
+ function kt(e, t, n, r, i, a) {
367
+ let o = Mt(t), s = Mt(n), c = ht(e), l = gt(e, o, c), u = gt(e, s, c), d = e.measureText(" / ").width, f = Math.max(l, u);
368
+ _t(e, o, r + f - l, i, c);
369
+ let p = e.textAlign;
370
+ e.textAlign = "left", e.fillText(" / ", r + f, i), e.textAlign = p, _t(e, s, r + f + d, i, c);
371
+ }
372
+ function At(e, t, n, r) {
373
+ let i = t.h / 2;
374
+ if (e.save(), W(e, t.x, t.y, t.w, t.h, i), e.fillStyle = "rgba(255, 255, 255, 0.35)", e.fill(), n > 0 && (W(e, t.x, t.y, t.w * n, t.h, i), e.fillStyle = "#fff", e.fill()), r) {
375
+ let r = Math.max(t.x + 5, Math.min(t.x + t.w - 5, t.x + t.w * n));
376
+ e.shadowColor = "rgba(0, 0, 0, 0.3)", e.shadowBlur = 3, e.fillStyle = "#fff", e.beginPath(), e.arc(r, t.y + t.h / 2, 5, 0, Math.PI * 2), e.fill();
377
+ }
378
+ e.restore();
379
+ }
380
+ function jt(e) {
381
+ let t = Math.max(220, e.w - 24);
382
+ return {
383
+ x: e.x + e.w / 2 - t / 2,
384
+ y: e.y + e.h - Ct - 4,
385
+ w: t,
386
+ h: Ct
387
+ };
388
+ }
389
+ function U(e) {
390
+ if (e.el.mediaKind === "audio") {
391
+ let t = jt(e.rect), n = t.x + V + wt + Tt, r = Math.max(40, t.x + t.w - V - n);
392
+ return {
393
+ x: n,
394
+ y: t.y + (t.h - H) / 2,
395
+ w: r,
396
+ h: H
397
+ };
398
+ }
399
+ let t = e.rect, n = Math.max(12, t.w * .025), r = Math.max(12, Math.min(18, t.h * .05));
400
+ return {
401
+ x: t.x + n,
402
+ y: t.y + t.h - H - r,
403
+ w: t.w - n * 2,
404
+ h: H
405
+ };
406
+ }
407
+ function W(e, t, n, r, i, a) {
408
+ let o = Math.min(a, i / 2, r / 2);
409
+ e.beginPath(), e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
410
+ }
411
+ function Mt(e) {
412
+ if (!Number.isFinite(e) || e < 0) return "0:00";
413
+ let t = Math.floor(e);
414
+ return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
415
+ }
416
+ //#endregion
417
+ //#region packages/pptx/src/slide-nav.ts
418
+ function Nt(e) {
419
+ let t = /* @__PURE__ */ new Map();
420
+ for (let n = 0; n < e.length; n++) {
421
+ let r = e[n];
422
+ r !== void 0 && r !== "" && !t.has(r) && t.set(r, n);
423
+ }
424
+ return t;
425
+ }
426
+ function Pt(e, t) {
427
+ if (e === "") return;
428
+ if (e.startsWith("ppt/")) return t.get(e);
429
+ let n = at("ppt/slides", e);
430
+ return t.get(n);
431
+ }
432
+ function Ft(e, t, n) {
433
+ let r = ot(e);
434
+ return r === null ? Pt(e, t) : st(r, n, t.size);
435
+ }
436
+ //#endregion
437
+ //#region packages/pptx/src/office-route-acquisition.ts
438
+ function It(e) {
439
+ let t = E(e.family);
440
+ return e.presenceOnly ? `presence:${t}` : `${t}:${e.weight ?? 400}:${e.style ?? "normal"}`;
441
+ }
442
+ async function Lt(e, t, n, r = null) {
443
+ let i = /* @__PURE__ */ new Map();
444
+ for (let n of t) {
445
+ let t = It(n);
446
+ !e.has(t) && !i.has(t) && i.set(t, n);
447
+ }
448
+ if (i.size > 0) {
449
+ let t = n([...i.values()]);
450
+ for (let n of i.keys()) e.set(n, t);
451
+ }
452
+ let a = new Set(t.map((t) => e.get(It(t)))), o = await Promise.all(a), s = Object.assign({}, ...o.map((e) => e.routes)), c = new Set(o.flatMap((e) => e.installed ?? [])), l = {}, u = /* @__PURE__ */ new Set();
453
+ for (let e of t) {
454
+ let t = E(e.family);
455
+ if (e.presenceOnly) {
456
+ c.has(t) && u.add(t);
457
+ continue;
458
+ }
459
+ let n = zt(e);
460
+ s[n] && (l[n] = s[n], u.add(t));
461
+ }
462
+ for (let e of Rt(r)) u.delete(e);
463
+ return {
464
+ routes: l,
465
+ installed: [...u].sort()
466
+ };
467
+ }
468
+ function Rt(e) {
469
+ return !e || typeof e[Symbol.iterator] != "function" ? /* @__PURE__ */ new Set() : new Set([...e].map((e) => E(e.family.replace(/^(['"])(.*)\1$/u, "$2"))));
470
+ }
471
+ function zt(e) {
472
+ let t = E(e.family), n = e.weight ?? 400, r = e.style ?? "normal";
473
+ return n === 400 && r === "normal" ? t : `${t}:${n}:${r}`;
474
+ }
475
+ function Bt(e) {
476
+ return [...new Set(e.values())];
477
+ }
478
+ //#endregion
479
+ //#region packages/pptx/src/slide-repository.ts
480
+ var Vt = class {
481
+ #e;
482
+ #t;
483
+ #n;
484
+ #r = 0;
485
+ #i = Promise.resolve();
486
+ #a;
487
+ #o;
488
+ constructor(e) {
489
+ if (!Number.isSafeInteger(e.slideCount) || e.slideCount < 0) throw TypeError("slideCount must be a non-negative safe integer");
490
+ this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new oe({
491
+ maxEntries: e.maxCachedSlides,
492
+ maxWeight: e.maxCachedStructuralBytes,
493
+ measure: (e) => it(e).jsonBytes
494
+ });
495
+ }
496
+ get slideCount() {
497
+ return this.#e;
498
+ }
499
+ get usage() {
500
+ return this.#n.usage;
501
+ }
502
+ withSlide(e, t) {
503
+ this.#c(e);
504
+ let n = this.#r, r = this.#i.then(async () => {
505
+ if (n !== this.#r) throw this.#a ? this.#a : Error("PPTX slide repository generation is stale");
506
+ if (this.#a) throw this.#a;
507
+ let r = await this.#s(e, n);
508
+ try {
509
+ return await t(r);
510
+ } catch (e) {
511
+ let t = Ht(e);
512
+ throw t ? (this.#l(t, n), this.#o === n ? this.#a ?? t : t) : e;
513
+ }
514
+ });
515
+ return this.#i = r.then(() => void 0, () => void 0), r;
516
+ }
517
+ async #s(e, t) {
518
+ return this.#n.getOrLoad(e, async () => {
519
+ let n;
520
+ try {
521
+ n = await this.#t(e);
522
+ } catch (e) {
523
+ let n = Ht(e);
524
+ throw n ? (this.#l(n, t), this.#o === t ? this.#a ?? n : n) : e;
525
+ }
526
+ if (this.#o === t && this.#a) throw this.#a;
527
+ return n;
528
+ });
529
+ }
530
+ clear() {
531
+ this.#r += 1, this.#a = void 0, this.#o = void 0, this.#n.clear();
532
+ }
533
+ #c(e) {
534
+ if (!Number.isSafeInteger(e) || e < 0 || e >= this.#e) throw RangeError(`Slide index ${e} out of range (count: ${this.#e})`);
535
+ }
536
+ #l(e, t) {
537
+ t !== this.#r || this.#a || (this.#a = e, this.#o = t, this.#r += 1, this.#n.clear());
538
+ }
539
+ };
540
+ function Ht(e) {
541
+ return e instanceof g ? e : v(e);
542
+ }
543
+ //#endregion
544
+ //#region packages/pptx/src/embedded-fonts.ts
545
+ function Ut(e, t) {
546
+ return e.filter((e) => !t.has(`${e.family.toLowerCase()}:${e.weight}:${e.style}`));
547
+ }
548
+ var Wt = 1;
549
+ function G(e) {
550
+ return e.trim().toLowerCase();
551
+ }
552
+ async function Gt(e, t) {
553
+ if (e.length === 0) return {
554
+ faces: [],
555
+ aliases: /* @__PURE__ */ new Map(),
556
+ authoredFamilies: /* @__PURE__ */ new Map(),
557
+ tuples: /* @__PURE__ */ new Set()
558
+ };
559
+ let n = Wt++, r = /* @__PURE__ */ new Map();
560
+ for (let t of e) {
561
+ let e = G(t.fontName);
562
+ r.has(e) || r.set(e, `__ooxml_pptx_${n}_${r.size + 1}`);
563
+ }
564
+ let i = [], a = /* @__PURE__ */ new Set();
565
+ try {
566
+ for (let n = 0; n < e.length; n += 2) {
567
+ let o = (await Promise.all(e.slice(n, n + 2).map(async (e) => {
568
+ try {
569
+ return {
570
+ family: r.get(G(e.fontName)),
571
+ bytes: await t(e.partPath),
572
+ odttf: !1,
573
+ weight: e.style === "bold" || e.style === "boldItalic" ? "bold" : "normal",
574
+ style: e.style === "italic" || e.style === "boldItalic" ? "italic" : "normal"
575
+ };
576
+ } catch (e) {
577
+ if (e instanceof g || M(e)) throw e;
578
+ let t = v(e);
579
+ if (t) throw t;
580
+ return null;
581
+ }
582
+ }))).filter((e) => e !== null);
583
+ if (o.length !== 0) for (let e of await pe(o)) a.has(e) ? k([e]) : (a.add(e), i.push(e));
584
+ }
585
+ } catch (e) {
586
+ throw k(i), e;
587
+ }
588
+ let o = new Set(i.map((e) => G(e.family))), s = new Map([...r].filter(([, e]) => o.has(G(e)))), c = new Map([...s].map(([e, t]) => [t, e]));
589
+ return {
590
+ faces: i,
591
+ aliases: s,
592
+ authoredFamilies: c,
593
+ tuples: new Set(i.map((e) => `${c.get(e.family)}:${e.weight === "bold" || e.weight === "700" ? 700 : 400}:${e.style === "italic" ? "italic" : "normal"}`))
594
+ };
595
+ }
596
+ function K(e, t) {
597
+ return e.filter((e) => e === null || !t.has(e.trim().toLowerCase()));
598
+ }
599
+ //#endregion
600
+ //#region packages/pptx/src/worker.ts?worker&inline
601
+ var Kt = "var e=Object.defineProperty,t=(e,t)=>()=>(e&&(t=e(e=0)),t),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r,i,a=t((()=>{r=class e extends Error{code;details;constructor(t,n,r){super(n),this.name=`OoxmlError`,this.code=t,t===`unsupported-content`&&r&&(this.details=Object.freeze({format:r.format,reason:r.reason})),Object.setPrototypeOf(this,e.prototype)}},i=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}}}));function o(e,t){return t!=null&&Object.hasOwn(e,t)?e[t]:void 0}var s=t((()=>{})),c,l,u,d,f,p=t((()=>{c=134217728,l=268435456,u=4096,d=67108864,f=67108864})),m,h,g,_,v=t((()=>{m=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,h=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,g=`https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap`,_={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},cambria:{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"franklin gothic book\":{url:g,loadFamily:`Libre Franklin`},\"franklin gothic medium\":{url:g,loadFamily:`Libre Franklin`},\"nunito sans\":{url:`https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},nunito:{url:`https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"open sans\":{url:`https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},roboto:{url:`https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap`},lato:{url:`https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap`},montserrat:{url:`https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;1,400;1,700&display=swap`},poppins:{url:`https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap`},raleway:{url:`https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"playfair display\":{url:`https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap`},ubuntu:{url:`https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"sakkal majalla\":{url:m,loadFamily:`Noto Naskh Arabic`,script:`arabic`},\"traditional arabic\":{url:m,loadFamily:`Noto Naskh Arabic`,script:`arabic`},\"simplified arabic\":{url:m,loadFamily:`Noto Naskh Arabic`,script:`arabic`},\"arabic typesetting\":{url:m,loadFamily:`Noto Naskh Arabic`,script:`arabic`},\"univers next arabic\":{url:h,loadFamily:`Noto Sans Arabic`,script:`arabic`},\"noto naskh arabic\":{url:m,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:h,loadFamily:`Noto Sans Arabic`}}}));function ee(e){return e?o(re,e.trim().toLowerCase())??null:null}function y(e){if(!e)return null;let t=ee(e)??e.trim(),n=t.toLowerCase(),r=n.match(/^noto\\s+(?:sans|serif)\\s+(?:cjk\\s+)?(sc|tc|hk|jp|kr)$/);return r?r[1]:/[ᄀ-ᇿ㄰-㆏가-힯]/.test(t)?`kr`:/[぀-ヿ]/.test(t)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(n)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(t)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(n)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(t)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(n)?`kr`:/\\bmeiryo\\b|\\byu\\s*(gothic|mincho)\\b|yugothic|yumincho|hiragino|\\bms\\s*(gothic|mincho|pgothic|pmincho|ui\\s*gothic)\\b|\\bms[pg]?(gothic|mincho)\\b|ipa(ex)?(gothic|mincho)|noto\\s+(sans|serif)\\s+jp|游ゴシック|游明朝|MS|メイリオ|ヒラギノ/.test(n)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(t)?`jp`:null}function te(e){return/\\p{Script=Han}/u.test(e)}function ne(e,t,n=!1){let r=new se(t);return r.addText(e),r.names(n)}var re,b,ie,ae,oe,se,ce=t((()=>{s(),re={\"noto sans cjk sc\":`Noto Sans SC`,\"noto serif cjk sc\":`Noto Serif SC`,\"noto sans cjk tc\":`Noto Sans TC`,\"noto serif cjk tc\":`Noto Serif TC`,\"noto sans cjk jp\":`Noto Sans JP`,\"noto serif cjk jp\":`Noto Serif JP`,\"noto sans cjk kr\":`Noto Sans KR`,\"noto serif cjk kr\":`Noto Serif KR`,\"noto sans cjk hk\":`Noto Sans HK`},b=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,ie={\"noto sans kr\":{url:b(`Noto+Sans+KR`)},\"noto sans sc\":{url:b(`Noto+Sans+SC`)},\"noto sans tc\":{url:b(`Noto+Sans+TC`)},\"noto sans hk\":{url:b(`Noto+Sans+HK`)},\"noto sans jp\":{url:b(`Noto+Sans+JP`)},\"noto serif kr\":{url:b(`Noto+Serif+KR`)},\"noto serif sc\":{url:b(`Noto+Serif+SC`)},\"noto serif tc\":{url:b(`Noto+Serif+TC`)},\"noto serif jp\":{url:b(`Noto+Serif+JP`)}},ae=Object.fromEntries(Object.entries(re).map(([e,t])=>[e,{...ie[t.toLowerCase()],loadFamily:t}])),oe={...ie,...ae,\"noto sans\":{url:b(`Noto+Sans`)},\"noto serif\":{url:b(`Noto+Serif`)},\"noto sans devanagari\":{url:b(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:b(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:b(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:b(`Noto+Serif+Hebrew`)}},se=class e{cjkLang;hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}scriptCjkLanguage(){return this.hasHangul?`kr`:this.hasKana?`jp`:null}preferredCjkLanguage(){return this.scriptCjkLanguage()??this.cjkLang??`jp`}clone(){let t=new e(this.cjkLang);return t.hasHan=this.hasHan,t.hasHangul=this.hasHangul,t.hasKana=this.hasKana,t.hasArabic=this.hasArabic,t.hasThai=this.hasThai,t.hasHebrew=this.hasHebrew,t.hasDevanagari=this.hasDevanagari,t.hasCyrGreek=this.hasCyrGreek,t}addText(e){let t=()=>this.hasHan&&this.hasHangul&&this.hasKana&&this.hasArabic&&this.hasThai&&this.hasHebrew&&this.hasDevanagari&&this.hasCyrGreek;outer:for(let n of e)if(n)for(let e of n){let n=e.codePointAt(0);if(n!==void 0&&!(n<=591)&&(n>=4352&&n<=4607||n>=12592&&n<=12687||n>=44032&&n<=55215?this.hasHangul=!0:n>=12352&&n<=12543?this.hasKana=!0:te(e)?this.hasHan=!0:n>=1536&&n<=1791||n>=1872&&n<=1919||n>=2208&&n<=2303||n>=64336&&n<=65023||n>=65136&&n<=65279?this.hasArabic=!0:n>=3584&&n<=3711?this.hasThai=!0:n>=1424&&n<=1535||n>=64285&&n<=64335?this.hasHebrew=!0:n>=2304&&n<=2431?this.hasDevanagari=!0:(n>=1024&&n<=1279||n>=880&&n<=1023)&&(this.hasCyrGreek=!0),t()))break outer}}names(e=!1){let t=[],n=new Set;this.hasHangul&&n.add(`kr`),this.hasKana&&n.add(`jp`),this.hasHan&&(n.size===0||e)&&n.add(this.cjkLang??`jp`);for(let e of[`kr`,`sc`,`tc`,`hk`,`jp`])if(n.has(e)){let n={kr:`KR`,sc:`SC`,tc:`TC`,hk:`HK`,jp:`JP`}[e];t.push(`Noto Sans ${n}`),e!==`hk`&&t.push(`Noto Serif ${n}`)}return this.hasCyrGreek&&t.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&t.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&t.push(`Noto Sans Thai`),this.hasHebrew&&t.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&t.push(`Noto Sans Devanagari`),t}}}));function le(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`||e===`image-effect-count`||e===`image-effect-work`||e===`tiff-lzw-work`||e===`metafile-path-commands`||e===`metafile-record-points`||e===`metafile-record-polygons`||e===`metafile-record-rectangles`||e===`metafile-record-text-units`}function ue(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function de(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!le(r)||!ue(i)||!ue(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var fe,pe,me,he,ge,_e=t((()=>{fe=1<<25,pe=1<<27,fe*4,pe*4,me=Math.floor(fe/4),he=pe,he/me,ge=class e extends RangeError{metric;limit;observed;code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function ve(e){return ye.test(e)}var ye,be=t((()=>{ye=/[\\u0590-\\u08FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFF\\u200F\\u202B\\u202E\\u2067]|[\\u{10800}-\\u{10FFF}\\u{1E800}-\\u{1EFFF}]/u}));function xe(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var Se,Ce=t((()=>{Se=class e extends Error{code=`ooxml-tiff-decode`;constructor(t,n){super(t,n),this.name=`TiffDecodeError`,Object.setPrototypeOf(this,e.prototype)}}}));function we(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var Te=t((()=>{}));function Ee(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function De(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Ee(t.requiredBytes)&&Ee(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}function Oe(e){if(e instanceof x)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(je))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!De(r)))return new x(r)}function ke(e,t,n){let r=Oe(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}var Ae,je,x,Me=t((()=>{Ae=`ooxml-insufficient-credit`,je=`OOXML_INSUFFICIENT_CREDIT:`,x=class e extends RangeError{code=Ae;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}}}));function S(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Ne(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return S(t.archiveEntryCount)&&S(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||S(t.largestInflatedEntryBytes))&&S(t.distinctInflatedBytes)&&S(t.operationInflatedBytes)}function Pe(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!Ne(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function Fe(e){return e===`docx`||e===`xlsx`||e===`pptx`}function Ie(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function C(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function w(e){return C(e,D)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function Le(e){return!C(e,rt)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}function Re(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!Fe(t.format)||!C(t.operation,nt)||!w(t.resource)||!w(t.metric)||!S(t.limit)||!S(t.observed)||typeof t.configurable!=`boolean`||!Ne(t.usage)?!1:!(`part`in t)||Le(t.part)}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!Ie(t.stage)||!Re(t.violation))return!1;let n=t.violation,r=it.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(at.has(n.resource)&&ot.has(n.metric))}function ze(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function Be(e){if(!T(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ze(t.usage)}};return T(n)?n:void 0}function Ve(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``} (${t.resource}, ${e.stage}): ${t.metric} ${t.observed} > ${t.limit}`}function He(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(et))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!T(r.details)))return new i(Ve(r.details),r.details)}function Ue(e){try{return e()}catch(e){throw e instanceof i||typeof e!=`string`&&!(e instanceof Error)?e:He(e)??e}}function We(e){let t=e instanceof Error?e.message:String(e);if(t.startsWith(tt))return new r(`not-ooxml`,`This file is not an Office Open XML document: ${t.slice(16)}`)}function Ge(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t.format,r=t.reason;if(!(!w(n)||r!==`source-subset`))return{format:n,reason:r}}function Ke(e){return new r(`unsupported-content`,`Input is outside the source’s supported subset.`,e)}function qe(e){let t=typeof e==`string`?e:e instanceof Error?e.message:``;if(!(!t.startsWith(`MODEL_SOURCE_UNSUPPORTED:`)||t.length>1024))try{let e=Ge(JSON.parse(t.slice(25)));return e?Ke(e):void 0}catch{return}}function Je(e){return e===`OOXML_SOURCE_UNSUPPORTED_ENCRYPTION`||e instanceof Error&&e.message===`OOXML_SOURCE_UNSUPPORTED_ENCRYPTION`?new r(`unsupported-encryption`,`The configured source cannot decrypt this input.`):qe(e)??He(e)??We(e)}function Ye(e){let t=de(e);if(t){let e=new ge(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=xe(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let a=Oe(e);if(a)return{message:a.message,errorName:a.name,code:a.code,insufficientCredit:{requiredBytes:a.requiredBytes,offeredBytes:a.offeredBytes}};let o=e instanceof r||e instanceof i?e:Je(e),s=o??e;if(o instanceof i||s&&typeof s==`object`&&s.code===`ooxml-resource-limit`){let e=s,t=Be(e.details);return t?{message:typeof e.message==`string`?e.message:Ve(t),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:t}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(s&&typeof s==`object`&&s.code===`unsupported-content`){let e=Ge(s.details);return e?{message:Ke(e).message,code:`unsupported-content`,unsupportedContent:e}:{message:`Invalid unsupported-content error payload`,errorName:`Error`}}if(o instanceof r)return{message:typeof o.message==`string`?o.message:String(o.message),errorName:C(o.name,D)?o.name:`OoxmlError`,...w(o.code)?{code:o.code}:{}};let c=e instanceof Error?e.message:String(e);if(typeof c==`string`&&c.startsWith(et))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let l=e instanceof Error?e:Error(c),u=l;return{message:typeof l.message==`string`?l.message:String(l.message),errorName:C(l.name,D)?l.name:`Error`,...typeof u.code==`string`?{code:u.code}:{}}}function E(e){try{return Ye(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Xe(e){return typeof e==`string`&&Object.prototype.hasOwnProperty.call(ct,e)}function Ze(e,t){if(e!==`ooxml-decoded-image-limit`||!t||typeof t!=`object`)return;let n=t,r=n.metric,i=n.limit,a=n.observed;if(!(!Xe(r)||!S(i)||!S(a)||a<=i))return{metric:r,limit:i,observed:a}}function Qe(e){let t=e.message,n=e.errorName,a=e.code,o=e.decodedImage,s=e.insufficientCredit,c=e.resourceLimit,l=e.unsupportedContent,u=typeof t==`string`?t:`Worker operation failed with an invalid error payload`,d=C(n,D)?n:void 0,f=typeof a==`string`?a:void 0;if(f===`unsupported-content`){let e=Ge(l);return e?Ke(e):Error(`Invalid unsupported-content error payload`)}let p=Ze(f,o);if(p)return new ge(p.metric,p.limit,p.observed);if(f===`ooxml-tiff-decode`)return new Se(u);if(f===`ooxml-insufficient-credit`&&De(s))return new x(s);if(f===`ooxml-resource-limit`&&T(c))return new i(u,c);if(f&&st.has(f))return new r(f,u);let m=d===`TypeError`?TypeError(u):d===`RangeError`?RangeError(u):Error(u);return d&&(m.name=d),f!==void 0&&Object.assign(m,{code:f}),m}function $e(e){try{return Qe(e)}catch{return Error(`Worker operation failed with an unreadable error payload`)}}var et,tt,D,nt,rt,it,at,ot,st,ct,lt=t((()=>{a(),_e(),Ce(),Me(),et=`OOXML_RESOURCE_LIMIT:`,tt=`OOXML_NOT_OOXML:`,D=128,nt=256,rt=4096,it=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`image-effect:work`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`chartex-allocation:elements`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`chartex-allocation:bytes`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`chart-cache:points`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`numbering-marker:bytes`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`chart-style-formats:entries`,{stage:`parsing`,part:`required`,configurable:!1}],[`chart-custom-number-formats:entries`,{stage:`parsing`,part:`required`,configurable:!1}],[`chart-number-format-bytes:bytes`,{stage:`parsing`,part:`required`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`theme-style-reparse:bytes`,{stage:`parsing`,part:`forbidden`,configurable:!1}],[`style-inheritance:depth`,{stage:`parsing`,part:`required`,configurable:!1}],[`complex-field:depth`,{stage:`parsing`,part:`forbidden`,configurable:!1}]]),at=new Set([...it.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),ot=new Set([...it.keys()].map(e=>e.slice(e.indexOf(`:`)+1))),st=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`,`invalid-numbering`,`unsupported-image-effect`]),ct={\"image-dimension\":!0,\"image-pixels\":!0,\"active-decoded-bytes\":!0,\"image-effect-count\":!0,\"image-effect-work\":!0,\"tiff-lzw-work\":!0,\"metafile-path-commands\":!0,\"metafile-record-points\":!0,\"metafile-record-polygons\":!0,\"metafile-record-rectangles\":!0,\"metafile-record-text-units\":!0}})),ut,dt=t((()=>{ut=class{initialize;reinitialize;normalizeFailure;state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}}}));function ft(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function pt(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function mt(e,t){return e({module_or_path:t})}function ht(e){return ft(e)?new gt(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}var gt,_t,vt=t((()=>{lt(),dt(),gt=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}},_t=class{init;options;runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new ut(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),ht),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return Ue(()=>this.runtime.run(e))}poison(){this.runtime.poison(new gt(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):mt(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,pt(e)}}}));function yt(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}var bt=t((()=>{}));function xt(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}var St=t((()=>{p(),Object.freeze({maxArchiveEntryBytes:c,maxTotalInflatedBytes:l,maxArchiveEntries:u})}));function O(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Ct(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var k,wt,Tt,Et=t((()=>{lt(),Me(),k=`ooxml-pull-v1`,wt=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,O(this.maxRetainedBytes,`max retained lease bytes`),O(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Tt=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Ct(e.sessionId),O(e.operationId,`operation id`),O(e.generation,`generation`),O(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&O(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=E(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(O(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:k,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){O(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(O(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:k,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:k,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}}})),A=t((()=>{Te(),a(),vt(),lt(),Me(),bt(),_e(),Ce(),s(),v(),ce(),be(),St(),p(),Et()})),Dt=t((()=>{be()})),j=t((()=>{a(),s(),p(),v(),ce(),_e(),be(),Ce(),A(),Dt()})),Ot=t((()=>{}));function kt(){return At??=[0,191,198,198,208,208,215,216,222,223,230,230,240,240,247,248,254,254,272,273,294,295,305,307,312,312,319,322,329,331,338,339,358,359,383,415,418,430,433,460,477,477,484,485,497,499,502,503,540,541,544,549,564,767,847,847,880,883,885,887,890,893,895,895,900,900,913,929,931,937,945,969,975,978,981,1023,1026,1026,1028,1030,1032,1035,1039,1048,1050,1080,1082,1103,1106,1106,1108,1110,1112,1115,1119,1141,1144,1154,1160,1216,1219,1231,1236,1237,1240,1241,1248,1249,1256,1257,1270,1271,1274,1327,1329,1366,1369,1418,1421,1423,1470,1470,1472,1472,1475,1475,1478,1478,1488,1514,1519,1524,1536,1551,1563,1569,1575,1610,1632,1647,1649,1727,1729,1729,1731,1746,1748,1749,1757,1758,1765,1766,1769,1769,1774,1805,1807,1808,1810,1839,1869,1969,1984,2026,2036,2042,2046,2069,2074,2074,2084,2084,2088,2088,2096,2110,2112,2136,2142,2142,2144,2154,2160,2193,2208,2249,2274,2274,2304,2344,2346,2352,2354,2355,2357,2363,2365,2380,2382,2384,2389,2391,2400,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2495,2500,2503,2504,2510,2510,2528,2531,2534,2557,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2610,2613,2613,2616,2617,2622,2626,2631,2632,2635,2636,2641,2641,2652,2652,2662,2678,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2757,2759,2761,2763,2764,2768,2768,2784,2787,2790,2801,2809,2815,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2879,2884,2887,2887,2901,2901,2911,2915,2918,2935,2946,2947,2949,2954,2958,2960,2962,2963,2965,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3007,3010,3014,3016,3024,3024,3046,3066,3072,3084,3086,3088,3090,3112,3114,3129,3133,3140,3142,3143,3146,3148,3160,3162,3164,3165,3168,3171,3174,3183,3191,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3263,3265,3265,3267,3268,3270,3270,3276,3276,3292,3294,3296,3299,3302,3311,3313,3315,3328,3340,3342,3344,3346,3386,3389,3389,3391,3396,3398,3400,3406,3407,3412,3414,3416,3427,3430,3455,3457,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3536,3540,3542,3542,3544,3545,3547,3547,3558,3567,3570,3572,3585,3639,3647,3655,3660,3675,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3767,3771,3773,3776,3780,3782,3782,3788,3790,3792,3801,3804,3807,3840,3863,3866,3892,3894,3894,3896,3896,3898,3906,3908,3911,3913,3916,3918,3921,3923,3926,3928,3931,3933,3944,3946,3948,3959,3959,3961,3961,3966,3967,3973,3973,3976,3986,3988,3991,3993,3996,3998,4001,4003,4006,4008,4011,4013,4020,4022,4022,4024,4024,4026,4028,4030,4037,4039,4044,4046,4058,4096,4133,4135,4141,4143,4150,4152,4152,4155,4236,4238,4293,4295,4295,4301,4301,4304,4351,4371,4448,4470,4519,4547,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4960,4988,4992,5017,5024,5109,5112,5117,5120,5788,5792,5880,5888,5907,5919,5939,5941,5942,5952,5971,5984,5996,5998,6e3,6002,6003,6016,6097,6099,6108,6112,6121,6128,6137,6144,6169,6176,6264,6272,6312,6314,6314,6320,6389,6400,6430,6432,6443,6448,6456,6464,6464,6468,6509,6512,6516,6528,6571,6576,6601,6608,6618,6622,6678,6681,6683,6686,6750,6753,6772,6784,6793,6800,6809,6816,6829,6846,6846,6912,6917,6919,6919,6921,6921,6923,6923,6925,6925,6927,6929,6931,6963,6966,6970,6972,6972,6974,6975,6978,6978,6981,6988,6990,7018,7028,7081,7084,7141,7143,7153,7164,7222,7227,7241,7245,7306,7312,7354,7357,7367,7379,7379,7393,7393,7401,7404,7406,7411,7413,7415,7418,7418,7424,7615,7834,7834,7836,7839,7930,7935,8125,8125,8127,8128,8190,8190,8194,8292,8294,8305,8308,8334,8336,8348,8352,8385,8413,8416,8418,8420,8448,8485,8487,8489,8492,8587,8592,8601,8604,8621,8623,8652,8656,8707,8709,8712,8714,8715,8717,8739,8741,8741,8743,8768,8770,8771,8773,8774,8776,8776,8778,8799,8801,8801,8803,8812,8818,8819,8822,8823,8826,8831,8834,8835,8838,8839,8842,8875,8880,8927,8932,8937,8942,9e3,9003,9257,9280,9290,9312,10971,10973,11123,11126,11502,11506,11507,11513,11557,11559,11559,11565,11565,11568,11623,11631,11632,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11776,11869,11904,11929,11931,12019,12032,12245,12272,12329,12336,12351,12353,12363,12365,12365,12367,12367,12369,12369,12371,12371,12373,12373,12375,12375,12377,12377,12379,12379,12381,12381,12383,12383,12385,12385,12387,12388,12390,12390,12392,12392,12394,12399,12402,12402,12405,12405,12408,12408,12411,12411,12414,12435,12437,12438,12443,12445,12447,12459,12461,12461,12463,12463,12465,12465,12467,12467,12469,12469,12471,12471,12473,12473,12475,12475,12477,12477,12479,12479,12481,12481,12483,12484,12486,12486,12488,12488,12490,12495,12498,12498,12501,12501,12504,12504,12507,12507,12510,12531,12533,12534,12539,12541,12543,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,42124,42128,42182,42192,42539,42560,42606,42608,42611,42622,42653,42656,42735,42738,42743,42752,42972,42993,43013,43015,43051,43056,43065,43072,43127,43136,43203,43205,43205,43214,43225,43250,43306,43310,43346,43359,43388,43392,43442,43444,43455,43457,43469,43471,43481,43486,43518,43520,43574,43584,43597,43600,43609,43612,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43765,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43883,43888,44012,44016,44025,55216,55238,55243,55291,57344,63743,64014,64015,64017,64017,64019,64020,64031,64031,64033,64033,64035,64036,64039,64041,64256,64262,64275,64279,64288,64297,64335,64975,65008,65049,65072,65106,65108,65126,65128,65131,65136,65140,65142,65276,65279,65279,65281,65470,65474,65479,65482,65487,65490,65495,65498,65500,65504,65510,65512,65518,65529,65533,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65792,65794,65799,65843,65847,65934,65936,65948,65952,65952,66e3,66044,66176,66204,66208,66256,66273,66299,66304,66339,66349,66378,66384,66421,66432,66461,66463,66499,66504,66517,66560,66717,66720,66729,66736,66771,66776,66811,66816,66855,66864,66915,66927,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67008,67016,67018,67043,67045,67059,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67671,67742,67751,67759,67808,67826,67828,67829,67835,67867,67871,67897,67903,67929,67968,68023,68028,68047,68050,68099,68101,68102,68108,68108,68110,68110,68112,68115,68117,68119,68121,68149,68160,68168,68176,68184,68192,68255,68288,68324,68331,68342,68352,68405,68409,68437,68440,68466,68472,68497,68505,68508,68521,68527,68608,68680,68736,68786,68800,68850,68858,68899,68912,68921,68928,68965,68974,68997,69006,69007,69216,69246,69248,69289,69293,69293,69296,69297,69314,69319,69328,69336,69372,69372,69376,69415,69424,69445,69457,69465,69488,69505,69510,69513,69552,69579,69600,69622,69632,69701,69703,69709,69714,69743,69745,69749,69760,69785,69787,69787,69789,69802,69804,69816,69819,69826,69837,69837,69840,69864,69872,69881,69891,69926,69928,69933,69936,69938,69942,69959,69968,70002,70004,70006,70016,70079,70081,70089,70091,70111,70113,70132,70144,70161,70163,70196,70199,70209,70272,70278,70280,70280,70282,70285,70287,70301,70303,70313,70320,70376,70384,70393,70400,70403,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70461,70461,70463,70468,70471,70472,70480,70480,70493,70499,70528,70530,70532,70532,70534,70537,70539,70539,70544,70544,70546,70581,70583,70583,70585,70586,70588,70592,70602,70602,70604,70605,70609,70613,70615,70616,70625,70626,70656,70721,70723,70725,70727,70747,70749,70749,70751,70753,70784,70831,70833,70841,70847,70849,70852,70855,70864,70873,71040,71086,71088,71093,71096,71097,71100,71102,71105,71133,71168,71230,71232,71236,71248,71257,71264,71276,71296,71349,71352,71353,71360,71369,71376,71395,71424,71450,71453,71466,71472,71494,71680,71736,71739,71739,71840,71922,71935,71942,71945,71945,71948,71955,71957,71958,71960,71983,71985,71989,71991,71991,71995,71996,71999,72002,72004,72006,72016,72025,72096,72103,72106,72151,72154,72159,72161,72164,72192,72243,72245,72262,72272,72344,72346,72354,72368,72440,72448,72457,72544,72551,72640,72673,72688,72697,72704,72712,72714,72758,72760,72766,72768,72773,72784,72812,72816,72847,72850,72871,72873,72886,72960,72966,72968,72969,72971,73014,73018,73018,73020,73021,73023,73025,73027,73027,73030,73031,73040,73049,73056,73061,73063,73064,73066,73102,73104,73105,73107,73110,73112,73112,73120,73129,73136,73179,73184,73193,73440,73464,73472,73488,73490,73530,73534,73536,73539,73562,73648,73648,73664,73713,73727,74649,74752,74862,74864,74868,74880,75075,77712,77810,77824,78933,78944,82938,82944,83526,90368,90397,90410,90414,90416,90425,92160,92728,92736,92766,92768,92777,92782,92862,92864,92873,92880,92909,92917,92917,92928,92975,92983,92997,93008,93017,93019,93025,93027,93047,93053,93071,93504,93542,93547,93561,93760,93850,93856,93880,93883,93907,93952,94026,94031,94087,94095,94111,94176,94180,94194,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,113820,113821,113823,113827,117760,118012,118016,118451,118458,118480,118496,118512,118528,118573,118576,118598,118608,118723,118784,119029,119040,119078,119081,119133,119146,119148,119155,119162,119171,119172,119180,119209,119214,119226,119233,119274,119296,119361,119365,119365,119488,119507,119520,119539,119552,119638,119648,119672,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120779,120782,121483,121499,121503,121505,121519,122624,122654,122661,122666,122928,122989,123136,123180,123191,123197,123200,123209,123214,123215,123536,123565,123584,123627,123632,123641,123647,123647,124112,124139,124144,124153,124368,124397,124400,124410,124415,124415,124608,124638,124640,124642,124644,124645,124647,124653,124656,124660,124670,124671,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125127,125135,125184,125251,125259,125259,125264,125273,125278,125279,126065,126132,126209,126269,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,126704,126705,126976,127019,127024,127123,127136,127150,127153,127167,127169,127183,127185,127221,127232,127405,127462,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,128728,128732,128748,128752,128764,128768,128985,128992,129003,129008,129008,129024,129035,129040,129095,129104,129113,129120,129159,129168,129197,129200,129211,129216,129217,129232,129240,129280,129623,129632,129645,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,129792,129938,129940,130042,131072,173791,173824,178205,178208,183981,183984,191456,191472,192093,196608,201546,201552,210041,917505,917505,917536,917631,917760,917999,983040,1048573,1048576,1114109]}var At,jt=t((()=>{}));function Mt(e){if(!Number.isInteger(e))return!1;let t=kt(),n=0,r=t.length/2-1;for(;n<=r;){let i=n+r>>>1;if(e<t[i*2])r=i-1;else if(e>t[i*2+1])n=i+1;else return!0}return!1}var Nt=t((()=>{jt()}));function Pt(e,t){let n=e.fieldType===`slidenum`&&t!==void 0?String(t):e.text;return e.caps===`all`||e.caps===`small`?n.toUpperCase():n}var Ft=t((()=>{})),It=n({collectSlideFontDemand:()=>Lt});function Lt(e,t,n){let r=new Set,i=2;if(i>n)return`all`;let a=e=>{if(ve(e))return!1;for(let a of e){let e=a.codePointAt(0);if(!Mt(e)||e>=61472&&e<=61695)return!1;if(!t.has(e)&&!r.has(e)){if(i+=String(e).length+1,i>n)return!1;r.add(e)}}return!0},o=t=>{if(!t)return!0;if(t.vert&&t.vert!==`horz`||`textWarp`in t)return!1;for(let n of t.paragraphs){if(n.rtl||n.bullet?.type!==`none`&&n.bullet?.type!==`inherit`)return!1;for(let t of n.runs)if(t.type!==`break`&&(t.type!==`text`||t.fontFamilySym||t.fieldType&&t.fieldType!==`slidenum`||!a(t.text)||!a(Pt(t,e.slideNumber))))return!1}return!0};if(e.parseError||!a(`Mii `))return`all`;for(let t of e.elements)if(t.type===`shape`){if(!o(t.textBody))return`all`}else if(t.type===`table`){for(let e of t.rows)for(let t of e.cells)if(!o(t.textBody))return`all`}else return`all`;return[...r]}var Rt=t((()=>{j(),Ot(),Nt(),Ft()}));async function zt(e){return e?(await Promise.resolve().then(()=>(Rt(),It))).collectSlideFontDemand:void 0}function M(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function N(e,t,n){return M(e,`resource measurement`),M(t,`resource measurement`),M(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Bt(e,t=2**53-1){M(t,`resource measurement limit`);let n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=3}else a=3;if(n=N(n,a,t),n>t)return n}return n}function Vt(e,t=2**53-1){M(t,`resource measurement limit`);let n=N(0,2,t);if(n>t)return n;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i===34||i===92||i===8||i===9||i===10||i===12||i===13)a=2;else if(i<=31)a=6;else if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=6}else a=i>=55296&&i<=57343?6:3;if(n=N(n,a,t),n>t)return n}return n}function P(e,t){return N(0,e,t)}function F(e,t=2**53-1,n=!1){if(M(t,`resource measurement limit`),e===null)return{jsonBytes:P(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:Vt(e,t),stringValueUtf8Bytes:Bt(e,t)};if(typeof e==`boolean`)return{jsonBytes:P(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:P((Number.isFinite(e)?String(Object.is(e,-0)?0:e):`null`).length,t),stringValueUtf8Bytes:0};if(typeof e==`bigint`)throw TypeError(`BigInt values cannot be serialized to JSON`);if(Array.isArray(e)){let n=P(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=N(n,1,t));let a=F(e[i],t,!0);n=N(n,a.jsonBytes,t),r=N(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=P(2,t),r=0,i=0;for(let[a,o]of Object.entries(e)){if(o===void 0||typeof o==`function`||typeof o==`symbol`)continue;i++!==0&&(n=N(n,1,t)),n=N(n,Vt(a,t),t),n=N(n,1,t);let e=F(o,t);n=N(n,e.jsonBytes,t),r=N(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?P(4,t):0,stringValueUtf8Bytes:0}}j(),ce(),{..._,...oe};function*Ht(e){let t=[e[Symbol.iterator]()];for(;t.length;){let e=t[t.length-1].next();if(e.done){t.pop();continue}let n=e.value;yield n,(n.type===`shape`||n.type===`table`)&&n.mathFallback&&t.push(n.mathFallback.elements[Symbol.iterator]())}}function*Ut(e){for(let t of e?.paragraphs??[]){for(let e of t.mathFallbacks??[])yield e.text;for(let e of t.runs)e.type===`text`&&(yield e.text),e.type===`math`&&e.fallbackText&&(yield e.fallbackText)}}function*Wt(e){for(let t of e?.paragraphs??[]){t.defFontFamily&&(yield t.defFontFamily);for(let e of t.runs)e.type===`text`&&(e.fontFamily&&(yield e.fontFamily),e.fontFamilyEa&&(yield e.fontFamilyEa),e.fontFamilyCs&&(yield e.fontFamilyCs),e.fontFamilySym&&(yield e.fontFamilySym))}}function*Gt(e){for(let t of Ht(e.elements))if(t.type===`shape`)yield*Ut(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*Ut(t.textBody);else if(t.type===`chart`){t.chart.title&&(yield t.chart.title);for(let e of t.chart.categories)yield e;for(let e of t.chart.series)e.name&&(yield e.name)}}var Kt=class e{majorFont;minorFont;fallback;scriptNames;scripts;families;constructor(e,t,n,r,i,a=new Set){this.majorFont=e,this.minorFont=t,this.fallback=i,this.scriptNames=a;let o=y(e)??y(t)??i??null;this.scripts=n??new se(o),this.families=r??new Set,e&&this.families.add(e),t&&this.families.add(t)}addSlide(e){e.theme?.majorFont&&this.families.add(e.theme.majorFont),e.theme?.minorFont&&this.families.add(e.theme.minorFont),this.scripts.addText(Gt(e));for(let t of ne(Gt(e),y(e.theme?e.theme.majorFont:this.majorFont)??y(e.theme?e.theme.minorFont:this.minorFont)??this.fallback??null))this.scriptNames.add(t);for(let t of Ht(e.elements))if(t.type===`shape`)for(let e of Wt(t.textBody))this.families.add(e);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)for(let e of Wt(t.textBody))this.families.add(e)}names(){return[...new Set([...this.families,...this.scripts.names(),...this.scriptNames])]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone(),new Set(this.families),this.fallback,new Set(this.scriptNames));return n.addSlide(t),n}};j(),A();const qt=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),Jt=f;function I(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function Yt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap slide at ${t}`);let n=e;if(n.index!==t)throw Error(`invalid PPTX presentation bootstrap slide index ${n.index}`);if(n.partName!==void 0&&typeof n.partName!=`string`)throw Error(`invalid PPTX presentation bootstrap slide partName at ${t}`);return Object.freeze({index:n.index,...n.partName===void 0?{}:{partName:n.partName}})}function Xt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap embedded font at ${t}`);let n=e;if(typeof n.fontName!=`string`||n.fontName.length===0||![`regular`,`bold`,`italic`,`boldItalic`].includes(n.style??``)||typeof n.partPath!=`string`||n.partPath.length===0||n.partPath.startsWith(`/`)||n.partPath.split(`/`).includes(`..`)||![`application/x-font-ttf`,`application/x-fontdata`].includes(n.contentType??``))throw Error(`invalid PPTX presentation bootstrap embedded font fields at ${t}`);return Object.freeze({fontName:n.fontName,style:n.style,partPath:n.partPath,contentType:n.contentType})}function Zt(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap payload`);let t=e;if(!Number.isSafeInteger(t.slideCount)||(t.slideCount??-1)<0||!Number.isSafeInteger(t.slideWidth)||(t.slideWidth??0)<=0||!Number.isSafeInteger(t.slideHeight)||(t.slideHeight??0)<=0||!Array.isArray(t.embeddedFonts)||!Array.isArray(t.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return I(t.defaultTextColor,`defaultTextColor`),I(t.majorFont,`majorFont`),I(t.minorFont,`minorFont`),I(t.hlinkColor,`hlinkColor`),I(t.folHlinkColor,`folHlinkColor`),Object.freeze({slideCount:t.slideCount,slideWidth:t.slideWidth,slideHeight:t.slideHeight,defaultTextColor:t.defaultTextColor,majorFont:t.majorFont,minorFont:t.minorFont,hlinkColor:t.hlinkColor,folHlinkColor:t.folHlinkColor,embeddedFonts:Object.freeze(t.embeddedFonts.map(Xt)),slides:Object.freeze(t.slides.map(Yt))})}function Qt(e){return Object.freeze({type:`media`,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,flipH:e.flipH,flipV:e.flipV,mediaKind:e.mediaKind,posterPath:e.posterPath,posterMimeType:e.posterMimeType,mediaPath:e.mediaPath,mimeType:e.mimeType})}function $t(e){return Object.freeze({...e.id===void 0?{}:{id:e.id},...e.authorId===void 0?{}:{authorId:e.authorId},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.status===void 0?{}:{status:e.status},text:e.text})}function en(e){return Object.freeze({...e})}function tn(e){return Object.freeze({...e.authorId===void 0?{}:{authorId:e.authorId},...e.modernAuthorId===void 0?{}:{modernAuthorId:e.modernAuthorId},...e.id===void 0?{}:{id:e.id},...e.index===void 0?{}:{index:e.index},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.x===void 0?{}:{x:e.x},...e.y===void 0?{}:{y:e.y},...e.anchors?.length?{anchors:Object.freeze(e.anchors.map(en))}:{},...e.status===void 0?{}:{status:e.status},text:e.text,...e.replies?.length?{replies:Object.freeze(e.replies.map($t))}:{}})}function nn(e,t){if(e.index!==t.index||e.partName!==t.partName)throw Error(`PPTX pulled slide identity does not match bootstrap index ${t.index}`);return Object.freeze({index:t.index,...t.partName===void 0?{}:{partName:t.partName},notes:e.notes??null,hidden:e.hidden??!1,mediaElements:Object.freeze(e.elements.filter(e=>e.type===`media`).map(Qt)),...e.comments?.length?{comments:Object.freeze(e.comments.map(tn))}:{}})}function rn(e,t,n){if(!(e<=t))throw new i(`PPTX presentation preflight exceeded its hard limit of ${t} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:t,observed:Math.min(e,t+1),configurable:!1,usage:n}})}var an=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;embeddedFontsValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;demandPoints;demandAll=!1;demandBytes=0;demandMembershipBytes=0;demandDeltaBytes=0;collectFontDemand;demandDelta;constructor(e,t={}){let n=Zt(e),r=t.maxProjectionBytes??Jt;if(!Number.isSafeInteger(r)||r<=0||r>Jt)throw Error(`invalid PPTX presentation preflight limit`);this.limit=r,this.collectFontDemand=t.collectFontDemand,this.demandPoints=this.collectFontDemand?new Set:void 0,this.demandBytes=this.collectFontDemand?F({fontPreloadDemand:[]},this.limit).jsonBytes-1:0,this.demandMembershipBytes=this.demandBytes,this.slideCountValue=n.slideCount,this.slideWidthValue=n.slideWidth,this.slideHeightValue=n.slideHeight,this.defaultTextColorValue=n.defaultTextColor,this.majorFontValue=n.majorFont,this.minorFontValue=n.minorFont,this.hlinkColorValue=n.hlinkColor,this.folHlinkColorValue=n.folHlinkColor,this.embeddedFontsValue=n.embeddedFonts,this.descriptors=[...n.slides],this.fonts=new Kt(this.majorFontValue,this.minorFontValue,void 0,void 0,t.cjkFallback),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=F(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=F({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,this.projectionBytesValue+this.demandBytes>this.limit&&(this.demandAll=!0,this.demandBytes=0,this.demandMembershipBytes=0),this.projectionBytesValue=N(this.projectionBytesValue,this.demandBytes,this.limit),rn(this.projectionBytesValue,this.limit,qt)}get acceptedSlideCount(){return this.finished?.slideCount??this.slides.length}get projectedBytes(){return this.projectionBytesValue}get remainingDescriptorCount(){return this.descriptors.reduce((e,t)=>e+Number(t!==void 0),0)}get latestSlide(){return this.slides[this.slides.length-1]}get currentFontPreloadNames(){return this.fontPreloadNames}get currentFontPreloadDemandDelta(){return this.demandDelta}snapshot(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);return Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames})}addSlide(e,t=qt){this.prepareSlide(e,t).commit()}prepareSlide(e,t=qt){if(this.finished)throw Error(`PPTX presentation preflight is already finished`);if(this.pending)throw Error(`PPTX presentation preflight already has a prepared slide`);let n=this.slides.length,r=this.descriptors[n];if(!r)throw Error(`PPTX presentation preflight received an extra slide`);let i=nn(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=F(o,this.limit).jsonBytes,c=F(i,this.limit).jsonBytes,l=this.projectionBytesValue-this.demandBytes-this.fontProjectionBytes-F(r,this.limit).jsonBytes+4;l=N(l,s,this.limit),l=N(l,c,this.limit),this.slides.length!==0&&(l=N(l,1,this.limit));let u=F({slide:i,fontPreloadNames:o},this.limit).jsonBytes,d=N(this.projectionBytesValue-this.demandBytes,u,this.limit),f=l;rn(Math.max(d,f),this.limit,t);let p=d+this.demandBytes;l+=this.demandBytes,Math.max(p,l)>this.limit&&this.demandBytes&&(this.projectionBytesValue-=this.demandBytes,this.demandBytes=0,this.demandMembershipBytes=0,this.demandDeltaBytes=0,this.demandPoints?.clear(),this.demandAll=!0,this.demandDelta=`all`,p=d,l=f);let m,h=this.demandBytes,g=this.demandMembershipBytes,_=this.demandDeltaBytes;if(this.collectFontDemand){let t=F([],this.limit).jsonBytes,n=this.limit-p,r=this.limit-f-this.demandMembershipBytes,i=Math.min(n,Math.floor((r+t-Number((this.demandPoints?.size??0)>0))/2));if(m=this.demandAll?`all`:this.collectFontDemand(e,this.demandPoints,Math.max(0,i)),m===`all`)h=0,g=0,_=0;else{_=F(m,this.limit).jsonBytes;let e=m.length===0?0:_-t+Number((this.demandPoints?.size??0)>0);g+=e,h=g+_,p+=_}l=f+h}rn(Math.max(p,l),this.limit,t);let v={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:l,demandDelta:m,demandBytes:h,demandMembershipBytes:g,demandDeltaBytes:_};return this.pending=v,{projectedBytes:p,commit:()=>{if(v.state!==`committed`){if(v.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==v)throw Error(`PPTX presentation preflight prepared slide is stale`);if(this.descriptors[n]=void 0,this.slides.push(v.fact),this.fonts=v.fonts,this.fontPreloadNames=v.fontNames,this.fontProjectionBytes=v.fontBytes,this.projectionBytesValue=v.committedBytes,this.demandDelta=v.demandDelta,v.demandDelta===`all`)this.demandAll=!0,this.demandPoints?.clear();else for(let e of v.demandDelta??[])this.demandPoints?.add(e);this.demandBytes=v.demandBytes,this.demandMembershipBytes=v.demandMembershipBytes,this.demandDeltaBytes=v.demandDeltaBytes,v.state=`committed`,this.pending=null}},rollback:()=>{if(v.state!==`rolled-back`){if(v.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==v)throw Error(`PPTX presentation preflight prepared slide is stale`);v.state=`rolled-back`,this.pending=null}}}}finish(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);if(this.slides.length!==this.slideCountValue)throw Error(`PPTX presentation preflight is incomplete: ${this.slides.length}/${this.slideCountValue} slides`);return this.finished=Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames,...this.collectFontDemand&&!this.demandAll&&this.demandBytes?{fontPreloadDemand:Object.freeze([...this.demandPoints??[]])}:{}}),this.demandPoints?.clear(),this.demandDelta=void 0,this.descriptors=[],this.slides=[],this.projectionBytesValue=F(this.finished,this.limit).jsonBytes,this.finished}};A();function on(e){try{return Pe(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function sn(e,t,n,r,i){let a,o;try{if(i){if(!r)throw Error(`slide payload is missing before acknowledgement`);let t=i(n,r,on(e));typeof t==`function`?a=t:t&&({rollback:a,commit:o}=t)}e(e=>e.acknowledge_slide(t.operationId,t.generation)),o?.()}catch(e){try{a?.()}catch{}throw e}}j(),A();var cn=class{archive;acceptSlide;executeArchive;coordinatorGeneration=new wt;sessions=new Map;pendingOpens=new Map;operationTail=Promise.resolve();resourceFailure;lifecycleState=`ready`;resetBarrier;resetIdentities=new Map;constructor(e,t,n=e=>e(this.requireArchive())){this.archive=e,this.acceptSlide=t,this.executeArchive=n}get coordinator(){return this.coordinatorGeneration}reserveOpen(e){if(this.assertReady(),un(e),this.pendingOpens.has(e.sessionId)||this.sessions.has(e.sessionId))throw Error(`slide pull session id is already reserved`);this.pendingOpens.set(e.sessionId,{identity:e,canceled:!1})}abandonOpen(e){this.pendingOpens.delete(e)}get pendingOpenCount(){return this.pendingOpens.size}async open(e,t){if(this.assertReady(),this.resourceFailure)throw this.resourceFailure;if(!Number.isSafeInteger(e)||e<0)throw RangeError(`slide index must be a non-negative safe integer`);let n=this.pendingOpens.get(t.sessionId);if(!n||!L(n.identity,t))throw Error(`slide pull session open reservation is stale or missing`);let r,i=new Promise(e=>{r=e}),a=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(n.canceled)throw Error(`slide pull session open was canceled`);let i,a=!1,o=new Tt({...t,maxByteCredit:d,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_slide(e,t.operationId,t.generation,n))}catch(e){throw ke(e,n,d)||(this.latchResourceFailure(e),e)}let o=yt(r);return this.acceptSlide&&(i=JSON.parse(new TextDecoder().decode(new Uint8Array(o)))),a=!0,{payload:o,byteLength:o.byteLength,done:!0,transfer:[o]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:()=>{if(!a)throw Error(`slide unit is not awaiting acknowledgement`);try{sn(this.executeArchive,t,e,i,this.acceptSlide)}catch(e){throw this.latchResourceFailure(e),e}a=!1,i=void 0,this.sessions.delete(t.sessionId),r()},cancel:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{i=void 0,a=!1,this.sessions.delete(t.sessionId),r()}},close:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{i=void 0,a=!1,this.sessions.delete(t.sessionId),r()}},resourceUsage:()=>{try{return this.readResourceUsage()}catch(e){throw this.latchResourceFailure(e),e}}}});this.sessions.set(t.sessionId,{host:o,identity:t}),this.pendingOpens.delete(t.sessionId)}));this.operationTail=a.then(()=>i,()=>void 0);try{await a}catch(e){throw this.pendingOpens.delete(t.sessionId),r(),e}}async postOpenedSafely(e,t,n){if(this.lifecycleState!==`ready`){try{n(this.lifecycleError())}catch{}return}try{t()}catch(t){await this.closeIdentity(e);try{n(t)}catch{}}}dispatch(e,t){if(this.lifecycleState!==`ready`)return t(this.responseDuringReset(e)),Promise.resolve();let n=this.sessions.get(e.sessionId);if(n)return n.host.dispatch(e,t);let r=this.pendingOpens.get(e.sessionId);if(r&&(e.kind===`cancel`||e.kind===`close`)){let n=L(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:k,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}:this.staleLifecycleResponse(e)),Promise.resolve()}return e.kind===`cancel`||e.kind===`close`?(t({protocol:k,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:k,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:E(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:k,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:E(n)})}catch{}}}run(e){if(this.lifecycleState!==`ready`)return Promise.reject(this.lifecycleError());let t=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(this.resourceFailure)throw this.resourceFailure;return e()})).catch(e=>{throw this.latchResourceFailure(e),e});return this.operationTail=t.then(()=>void 0,()=>void 0),t}reset(){if(this.resetBarrier)return this.resetBarrier;this.lifecycleState=`resetting`,this.captureResetIdentities();let e=this.performReset().then(()=>{this.resetIdentities.clear(),this.lifecycleState=`ready`},e=>{throw this.lifecycleState=`reset-failed`,e}).finally(()=>{this.resetBarrier===e&&(this.resetBarrier=void 0)});return this.resetBarrier=e,e}async performReset(){for(let e of this.pendingOpens.values())e.canceled=!0;let e=1;for(let{host:t,identity:n}of[...this.sessions.values()]){let r;if(await t.dispatch({protocol:k,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=$e(e.error))}),r)throw r}this.sessions.clear(),await this.operationTail,this.pendingOpens.clear(),this.archive()&&await this.executeArchive(e=>e.close_presentation_session()),this.coordinatorGeneration=new wt,this.resourceFailure=void 0}assertReady(){if(this.lifecycleState!==`ready`)throw this.lifecycleError()}lifecycleError(){let e=this.lifecycleState===`reset-failed`,t=Error(e?`slide pull worker reset failed; retry reset before new work`:`slide pull worker reset is in progress`);return t.name=`PullSessionLifecycleError`,Object.assign(t,{code:e?`ooxml-pull-reset-failed`:`ooxml-pull-resetting`})}captureResetIdentities(){for(let{identity:e}of this.sessions.values())this.resetIdentities.set(e.sessionId,e);for(let{identity:e}of this.pendingOpens.values())this.resetIdentities.set(e.sessionId,e)}responseDuringReset(e){if(e.kind===`cancel`||e.kind===`close`){let t=this.resetIdentities.get(e.sessionId);return t&&!L(t,e)?this.staleLifecycleResponse(e):{protocol:k,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:k,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:E(this.lifecycleError())}}requireArchive(){let e=this.archive();if(!e)throw Error(`Presentation not loaded`);return e}async closeIdentity(e){if(this.lifecycleState!==`ready`)return;let t=this.sessions.get(e.sessionId);if(t){await t.host.dispatch({protocol:k,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&L(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return on(this.executeArchive)}latchResourceFailure(e){let t=e instanceof i?e:He(e);t&&(this.resourceFailure??=t)}staleLifecycleResponse(e){return{protocol:k,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:{message:`stale lifecycle targets another slide operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`}}}};function ln(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function un(e){if(!Number.isSafeInteger(e.sessionId)||e.sessionId<=0)throw RangeError(`session id must be a positive safe integer`);if(!Number.isSafeInteger(e.operationId)||e.operationId<=0)throw RangeError(`operation id must be a positive safe integer`);if(!Number.isSafeInteger(e.generation)||e.generation<=0)throw RangeError(`generation must be a positive safe integer`)}function L(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var dn=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,pn.unregister(this),e}free(){let e=this.__destroy_into_raw();Y.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=Y.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw G(n[0])}assert_healthy(){let e=Y.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw G(e[0])}cancel_slide(){Y.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){Y.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_font(e){let t=W(e,Y.__wbindgen_malloc,Y.__wbindgen_realloc),n=J,r=Y.pptxarchive_extract_font(this.__wbg_ptr,t,n);if(r[3])throw G(r[2]);var i=R(r[0],r[1]).slice();return Y.__wbindgen_free(r[0],r[1]*1,1),i}extract_image(e){let t=W(e,Y.__wbindgen_malloc,Y.__wbindgen_realloc),n=J,r=Y.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw G(r[2]);var i=R(r[0],r[1]).slice();return Y.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=W(e,Y.__wbindgen_malloc,Y.__wbindgen_realloc),n=J,r=Y.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw G(r[2]);var i=R(r[0],r[1]).slice();return Y.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=hn(e,Y.__wbindgen_malloc),a=J,o=Y.pptxarchive_new(i,a,!U(t),U(t)?BigInt(0):t,!U(n),U(n)?BigInt(0):n,!U(r),U(r)?BigInt(0):r);if(o[2])throw G(o[1]);return this.__wbg_ptr=o[0]>>>0,pn.register(this,this.__wbg_ptr,this),this}parse(){let e=Y.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw G(e[2]);var t=R(e[0],e[1]).slice();return Y.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=Y.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw G(e[2]);var t=R(e[0],e[1]).slice();return Y.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=Y.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw G(i[2]);var a=R(i[0],i[1]).slice();return Y.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=Y.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw G(e[2]);var t=R(e[0],e[1]).slice();return Y.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=Y.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw G(e[2]);var t=R(e[0],e[1]).slice();return Y.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=Y.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,G(i[2]);return e=n,t=r,B(n,r)}finally{Y.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(dn.prototype[Symbol.dispose]=dn.prototype.free);function fn(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(B(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(B(e,t))}finally{Y.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=W(n,Y.__wbindgen_malloc,Y.__wbindgen_realloc),i=J;mn().setInt32(e+4,i,!0),mn().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return B(e,t)},__wbindgen_init_externref_table:function(){let e=Y.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const pn=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Y.__wbg_pptxarchive_free(e>>>0,1));function R(e,t){return e>>>=0,H().subarray(e/1,e/1+t)}let z=null;function mn(){return(z===null||z.buffer.detached===!0||z.buffer.detached===void 0&&z.buffer!==Y.memory.buffer)&&(z=new DataView(Y.memory.buffer)),z}function B(e,t){return e>>>=0,_n(e,t)}let V=null;function H(){return(V===null||V.byteLength===0)&&(V=new Uint8Array(Y.memory.buffer)),V}function U(e){return e==null}function hn(e,t){let n=t(e.length*1,1)>>>0;return H().set(e,n/1),J=e.length,n}function W(e,t,n){if(n===void 0){let n=q.encode(e),r=t(n.length,1)>>>0;return H().subarray(r,r+n.length).set(n),J=n.length,r}let r=e.length,i=t(r,1)>>>0,a=H(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=H().subarray(i+o,i+r),a=q.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return J=o,i}function G(e){let t=Y.__wbindgen_externrefs.get(e);return Y.__externref_table_dealloc(e),t}let K=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});K.decode();let gn=0;function _n(e,t){return gn+=t,gn>=2146435072&&(K=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),K.decode(),gn=t),K.decode(H().subarray(e,e+t))}const q=new TextEncoder;`encodeInto`in q||(q.encodeInto=function(e,t){let n=q.encode(e);return t.set(n),{read:e.length,written:n.length}});let J=0,Y;function vn(e,t){return Y=e.exports,z=null,V=null,Y.__wbindgen_start(),Y}async function yn(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function bn(e){if(Y!==void 0)return Y;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=fn();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await yn(await e,t);return vn(n,r)}async function xn(e){return Y=void 0,z=null,V=null,bn(e)}j(),A();const X=new _t(bn,{freeArchive:e=>e.free(),reinit:xn});let Z=null,Sn=`empty`;function Cn(){if(Sn!==`empty`){let e=Error(`this PPTX worker already owns a presentation parse`);throw e.name=`PptxWorkerStateError`,Object.assign(e,{code:`ooxml-pptx-parse-already-started`})}Sn=`opening`}const Q=new cn(()=>X.archive,(e,t,n)=>{if(Z){if(e!==Z.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${Z.acceptedSlideCount}, received ${e}`);return Z.prepareSlide(t,n)}},e=>{let t=X.archive;if(!t)throw Error(`Presentation not loaded`);return X.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(ln(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){X.setWasmInput(we(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(Cn(),r=!0),t.kind===`openSlideSession`){await X.ensureReady(),await Q.open(t.slideIndex,t),await Q.postOpenedSafely(t,()=>$({kind:`slideSessionOpened`,id:n,sessionId:t.sessionId,operationId:t.operationId,generation:t.generation}),e=>$({kind:`error`,id:n,...E(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await X.ensureReady(),t.kind!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(t.kind===`parse`){Z=null;let[e,r,i]=xt(t.resourcePolicy),a=X.run(()=>{let n=new dn(new Uint8Array(t.buffer),e,r,i);return X.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});Z=t.progressiveLayout?null:new an(a,{cjkFallback:t.cjkFallback,collectFontDemand:t.collectFontDemand===!0?await zt(!0):void 0}),$({kind:`presentationOpened`,id:n,bootstrap:a}),Sn=`ready`;return}let e=X.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!Z)throw Error(`PPTX presentation preflight is not active`);let e=Z.finish();Z=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=X.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=X.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractFont`){let r=X.run(()=>e.extract_font(t.path).buffer);$({kind:`fontExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:Pe(X.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:X.run(()=>e.to_markdown())})})}catch(e){r&&(Sn=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...E(e)})}catch{}}};", qt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Kt], { type: "text/javascript;charset=utf-8" });
602
+ function Jt(e) {
603
+ let t;
604
+ try {
605
+ if (t = qt && (self.URL || self.webkitURL).createObjectURL(qt), !t) throw "";
606
+ let n = new Worker(t, {
607
+ type: "module",
608
+ name: e?.name
609
+ });
610
+ return n.addEventListener("error", () => {
611
+ (self.URL || self.webkitURL).revokeObjectURL(t);
612
+ }), n;
613
+ } catch {
614
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Kt), {
615
+ type: "module",
616
+ name: e?.name
617
+ });
618
+ }
619
+ }
620
+ //#endregion
621
+ //#region packages/pptx/src/wasm/pptx_parser_bg.wasm?url
622
+ var Yt = new URL("pptx_parser_bg.wasm", import.meta.url).href, q = 65536, Xt = 16384, Zt = new Set(["line", "straightconnector1"]);
623
+ function Qt(e, t) {
624
+ let n = e.x + e.width / 2, r = e.y + e.height / 2, i = -e.rotation * Math.PI / 180, a = Math.cos(i), o = Math.sin(i), s = t.x - n, c = t.y - r, l = n + a * s - o * c, u = r + o * s + a * c;
625
+ return e.flipH && (l = 2 * n - l), e.flipV && (u = 2 * r - u), {
626
+ x: l,
627
+ y: u
628
+ };
629
+ }
630
+ function $t(e, t, n) {
631
+ let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
632
+ if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
633
+ let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a));
634
+ return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
635
+ }
636
+ function en(e, t, n = 0) {
637
+ if (!Number.isFinite(t.x) || !Number.isFinite(t.y)) return !1;
638
+ let r = Qt(e, t), i = Number.isFinite(n) && n > 0 ? n : 0;
639
+ if (e.type === "shape" && (Zt.has(e.geometry.toLowerCase()) || e.width === 0 || e.height === 0)) return $t(r, {
640
+ x: e.x,
641
+ y: e.y
642
+ }, {
643
+ x: e.x + e.width,
644
+ y: e.y + e.height
645
+ }) <= i;
646
+ let a = Math.min(e.x, e.x + e.width), o = Math.max(e.x, e.x + e.width), s = Math.min(e.y, e.y + e.height), c = Math.max(e.y, e.y + e.height);
647
+ return r.x >= a && r.x <= o && r.y >= s && r.y <= c;
648
+ }
649
+ function* tn(e) {
650
+ if (e) for (let t of e.paragraphs) {
651
+ let e = !0;
652
+ for (let n of t.runs) {
653
+ let t = n.type === "text" ? n.text : n.type === "break" ? "\n" : "[equation]";
654
+ t && (yield {
655
+ text: t,
656
+ beginsPart: e
657
+ }, e = !1);
658
+ }
659
+ }
660
+ }
661
+ function* nn(e) {
662
+ if (e.type === "shape") {
663
+ yield* tn(e.textBody);
664
+ return;
665
+ }
666
+ if (e.type === "table") {
667
+ for (let t of e.rows) for (let e of t.cells) yield* tn(e.textBody);
668
+ return;
669
+ }
670
+ }
671
+ function rn(e, t = Xt) {
672
+ if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
673
+ let n = Math.min(q, Math.floor(t)), r = e.text, i = r === void 0 ? void 0 : Je(r, n), a = r !== void 0 && i.length < r.length;
674
+ return {
675
+ ...structuredClone(e),
676
+ ...i === void 0 ? {} : { text: i },
677
+ truncated: e.truncated || a,
678
+ truncationReasons: e.truncated || a ? ["text"] : [],
679
+ textCharacters: i?.length ?? 0,
680
+ maxTextCharacters: n
681
+ };
682
+ }
683
+ function an(e, t) {
684
+ let n = [], r = 0, i = !1, a = !1;
685
+ for (let o of e) {
686
+ if (a = !0, o.beginsPart && n.length > 0) {
687
+ if (r >= t) {
688
+ i = !0;
689
+ break;
690
+ }
691
+ n.push("\n"), r++;
692
+ }
693
+ let e = Math.max(0, t - r), s = Je(o.text, e);
694
+ if (n.push(s), r += s.length, s.length < o.text.length) {
695
+ i = !0;
696
+ break;
697
+ }
698
+ }
699
+ return a ? {
700
+ text: n.join(""),
701
+ truncated: i,
702
+ textCharacters: r
703
+ } : {
704
+ truncated: !1,
705
+ textCharacters: 0
706
+ };
707
+ }
708
+ function on(e, t, n, r = {}) {
709
+ if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) throw RangeError("PPTX hit-test point must contain finite coordinates.");
710
+ let i = r.maxTextCharacters ?? Xt;
711
+ if (!Number.isFinite(i) || i < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
712
+ let a = Math.min(q, Math.floor(i)), o = r.tolerance ?? 0;
713
+ if (!Number.isFinite(o) || o < 0) throw RangeError("tolerance must be a finite non-negative number.");
714
+ for (let r = t.elements.length - 1; r >= 0; r--) {
715
+ let i = t.elements[r];
716
+ if (!en(i, n, o)) continue;
717
+ let s = i.type === "chart" ? We(i.chart, a) : an(nn(i), a);
718
+ return {
719
+ format: "pptx",
720
+ kind: "element",
721
+ slideIndex: e,
722
+ elementIndex: r,
723
+ origin: t.elementSources?.[r]?.origin ?? "unknown",
724
+ elementType: i.type,
725
+ point: { ...n },
726
+ bounds: {
727
+ x: i.x,
728
+ y: i.y,
729
+ width: i.width,
730
+ height: i.height,
731
+ rotation: i.rotation,
732
+ flipH: i.flipH,
733
+ flipV: i.flipV
734
+ },
735
+ ...i.type === "shape" ? {
736
+ ...i.id === void 0 ? {} : { shapeId: i.id },
737
+ ...i.name === void 0 ? {} : { name: i.name },
738
+ geometry: i.geometry
739
+ } : {},
740
+ ...s.text === void 0 ? {} : { text: s.text },
741
+ ...i.type === "picture" ? { mimeType: i.mimeType } : {},
742
+ ...i.type === "media" ? {
743
+ mimeType: i.mimeType,
744
+ mediaKind: i.mediaKind
745
+ } : {},
746
+ ...i.type === "table" ? {
747
+ rowCount: i.rows.length,
748
+ columnCount: i.cols.length
749
+ } : {},
750
+ ...i.type === "chart" ? { seriesCount: i.chart.series.length } : {},
751
+ truncated: s.truncated,
752
+ truncationReasons: s.truncated ? ["text"] : [],
753
+ textCharacters: s.textCharacters,
754
+ maxTextCharacters: a
755
+ };
756
+ }
757
+ return null;
758
+ }
759
+ function sn(e, t) {
760
+ let n = new Set(t.filter((e) => e.length > 0));
761
+ if (n.size === 0) return Object.freeze([]);
762
+ let r = /* @__PURE__ */ new Map();
763
+ for (let [t, i] of e.elements.entries()) {
764
+ let a = i.id;
765
+ if (!a || !n.has(a)) continue;
766
+ let o = e.elementSources?.[t]?.origin ?? "unknown", s = o === "slide" ? 3 : o === "layout" ? 2 : +(o === "master"), c = r.get(a), l = c?.origin === "slide" ? 3 : c?.origin === "layout" ? 2 : +(c?.origin === "master");
767
+ c && l > s || r.set(a, Object.freeze({
768
+ elementId: a,
769
+ elementIndex: t,
770
+ origin: o,
771
+ elementType: i.type,
772
+ bounds: Object.freeze({
773
+ x: i.x,
774
+ y: i.y,
775
+ width: i.width,
776
+ height: i.height,
777
+ rotation: i.rotation,
778
+ flipH: i.flipH,
779
+ flipV: i.flipV
780
+ })
781
+ }));
782
+ }
783
+ return Object.freeze(t.flatMap((e) => {
784
+ let t = r.get(e);
785
+ return t ? [t] : [];
786
+ }));
787
+ }
788
+ //#endregion
789
+ //#region packages/pptx/src/presentation-layout-events.ts
790
+ var J = /* @__PURE__ */ new WeakMap();
791
+ function Y(e, t) {
792
+ let n = Object.freeze({ ...t });
793
+ for (let t of [...J.get(e) ?? []]) try {
794
+ t.notify(n);
795
+ } catch (e) {
796
+ try {
797
+ t.report(e);
798
+ } catch {}
799
+ }
800
+ }
801
+ function cn(e, t, n, r) {
802
+ let i = J.get(e);
803
+ i || (i = /* @__PURE__ */ new Set(), J.set(e, i));
804
+ let a = Object.freeze({
805
+ notify: n,
806
+ report: r
807
+ });
808
+ i.add(a);
809
+ try {
810
+ n(Object.freeze({ ...t() }));
811
+ } catch (e) {
812
+ try {
813
+ r(e);
814
+ } catch {}
815
+ }
816
+ return () => {
817
+ i?.delete(a), i?.size === 0 && J.delete(e);
818
+ };
819
+ }
820
+ //#endregion
821
+ //#region packages/pptx/src/worker-task-scheduler.ts
822
+ function ln() {
823
+ return new Promise((e) => {
824
+ let t = new MessageChannel();
825
+ t.port1.onmessage = () => {
826
+ t.port1.close(), t.port2.close(), e();
827
+ }, t.port2.postMessage(void 0);
828
+ });
829
+ }
830
+ //#endregion
831
+ //#region packages/pptx/src/presentation.ts
832
+ var X = class e {
833
+ _cjkFallback = "jp";
834
+ _googleSubstitutes = !1;
835
+ _metrics = null;
836
+ _worker;
837
+ _bridge;
838
+ _mode = "main";
839
+ _bootstrap = null;
840
+ _preflight = null;
841
+ _availableSlideCount = 0;
842
+ _layoutLifecycle = new he();
843
+ _layoutObservers = new Pe();
844
+ _layoutCompletion = null;
845
+ _parseRequestId = null;
846
+ _progressive = null;
847
+ _progressiveWatchdog;
848
+ _progressiveWatchdogMs;
849
+ _layoutWaiters = /* @__PURE__ */ new Set();
850
+ _slides = null;
851
+ _slidePullClient = null;
852
+ _resourceFailure = null;
853
+ _slidePartIndex = null;
854
+ _rawParts = new le({
855
+ maxEntries: 64,
856
+ maxBytes: re
857
+ });
858
+ _googleFonts = null;
859
+ _officeFontLoads = /* @__PURE__ */ new Map();
860
+ _embeddedFontFaces = [];
861
+ _embeddedFontAliases = /* @__PURE__ */ new Map();
862
+ _embeddedFontAuthoredFamilies = /* @__PURE__ */ new Map();
863
+ _embeddedFontTuples = /* @__PURE__ */ new Set();
864
+ _destroyed = !1;
865
+ _fetchImage = (e, t) => this.getImage(e, t);
866
+ _fetchMedia = (e) => this.getMedia(e);
867
+ _math;
868
+ _threeD;
869
+ _regionMap;
870
+ _chartEx;
871
+ _tiff;
872
+ constructor(e, t, n) {
873
+ this._worker = e, this._mode = t, this._bridge = new Be(this._worker, {
874
+ correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
875
+ toError: (e) => !("protocol" in e) && e.kind === "error" ? S(e) : void 0,
876
+ onUnsolicited: (e) => this._onWorkerLayoutPush(e)
877
+ });
878
+ let r = new URL(n ?? Yt, location.href).href;
879
+ this._bridge.post({
880
+ kind: "init",
881
+ wasmUrl: r
882
+ });
883
+ }
884
+ _assertResourceHealthy() {
885
+ if (this._resourceFailure) throw this._resourceFailure;
886
+ }
887
+ _rethrowWithResourceFailure(e) {
888
+ let t = e instanceof g ? e : v(e);
889
+ throw t ? (this._resourceFailure ??= t, this._resourceFailure) : e;
890
+ }
891
+ static async load(t, n = {}) {
892
+ if (n.legacyPpt !== void 0) {
893
+ let { loadPptxModelSource: e } = await import("./presentation-model-source-CGHLyX32.js");
894
+ return e(t, n);
895
+ }
896
+ let r = se(n.cjkFallback), i = b(n), a = n.mode ?? "main", o = new ae({
897
+ enabled: !0,
898
+ format: "pptx",
899
+ mode: a,
900
+ policy: i.policy,
901
+ onMetrics: i.onResourceMetrics,
902
+ emitToConsole: i.debug
903
+ });
904
+ try {
905
+ if (a === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
906
+ let s;
907
+ if (typeof t == "string") {
908
+ let e = await fetch(t);
909
+ if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
910
+ s = await e.arrayBuffer();
911
+ } else s = t;
912
+ s = _(await ee(s, n.password)), o.setSourceBytes(s.byteLength), o.checkpoint("container ready");
913
+ let c = a === "worker" ? (await import("./render-worker-host-C-EECo68.js")).createRenderWorker() : new Jt(), l = a === "worker" ? nt(n) : void 0, u;
914
+ try {
915
+ u = new e(c, a, n.wasmUrl), u._metrics = o, n.math && a === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), n.threeD && a === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), u._cjkFallback = r, u._math = a === "worker" ? void 0 : n.math, u._threeD = a === "worker" ? void 0 : n.threeD, n.regionMap && a === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), u._regionMap = a === "worker" ? void 0 : n.regionMap, n.chartEx && a === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), u._chartEx = a === "worker" ? void 0 : n.chartEx, n.tiff && a === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), u._tiff = a === "worker" ? void 0 : n.tiff;
916
+ let t = n.progressiveLayout ? {
917
+ onProgress: n.onLayoutProgress,
918
+ onPartial: n.onLayoutPartial,
919
+ onComplete: n.onLayoutComplete,
920
+ firstPublication: ve(),
921
+ published: !1,
922
+ deferred: !1,
923
+ settled: !1
924
+ } : void 0;
925
+ return u._googleSubstitutes = !!n.useGoogleFonts, await u._parse(s, i.policy, !!n.useGoogleFonts, n.workerTimeoutMs, (e) => o.observeUsage(e), l, t), o.checkpoint("presentation preflight ready"), a === "main" && n.useGoogleFonts && u._preflight && !t && await u._ensureGoogleFonts(K(u._preflight.fontPreloadNames, u._embeddedFontAliases), u._preflight.fontPreloadDemand), o.succeed({ slides: u.slideCount }), u;
926
+ } catch (e) {
927
+ let t = u;
928
+ throw Ve(c, t ? () => t.destroy() : void 0), e;
929
+ }
930
+ } catch (e) {
931
+ throw o.fail(e), e;
932
+ }
933
+ }
934
+ async _ensureGoogleFonts(e, t) {
935
+ this._destroyed || (this._googleFonts ??= new x(i), await this._googleFonts.ensure(e, t));
936
+ }
937
+ async _parse(e, n, r = !1, i, a, o, l) {
938
+ if (l) {
939
+ this._progressive = l, this._mode === "worker" ? await this._parseWorkerProgressively(e, n, r, i, a, o, l) : await this._parseMainProgressively(e, n, r, i, a, l, r && !o);
940
+ return;
941
+ }
942
+ let u = await this._bridge.request((t) => this._mode === "worker" ? {
943
+ kind: "parse",
944
+ id: t,
945
+ buffer: e,
946
+ resourcePolicy: n,
947
+ useGoogleFonts: r,
948
+ cjkFallback: this._cjkFallback,
949
+ renderers: o
950
+ } : {
951
+ kind: "parse",
952
+ id: t,
953
+ buffer: e,
954
+ resourcePolicy: n,
955
+ cjkFallback: this._cjkFallback,
956
+ ...r && !o ? { collectFontDemand: !0 } : {}
957
+ }, [e], { timeoutMs: i });
958
+ if (this._mode === "worker") {
959
+ let e = u;
960
+ e.usage && a?.(e.usage), this._preflight = c(u.preflight), this._bootstrap = this._preflight, this._availableSlideCount = this._preflight.slideCount;
961
+ return;
962
+ }
963
+ let d = t(u.bootstrap);
964
+ this._bootstrap = d;
965
+ let p = Gt(d.embeddedFonts, (e) => this.getFontBytes(e)).then((e) => {
966
+ this._destroyed ? k(e.faces) : (this._embeddedFontFaces = e.faces, this._embeddedFontAliases = e.aliases, this._embeddedFontAuthoredFamilies = e.authoredFamilies, this._embeddedFontTuples = e.tuples);
967
+ });
968
+ p.catch(() => void 0), this._slidePullClient = new f({
969
+ slideCount: d.slideCount,
970
+ transport: this._bridge.transport(s),
971
+ open: async (e, t, n) => {
972
+ await this._bridge.request((n) => ({
973
+ kind: "openSlideSession",
974
+ id: n,
975
+ slideIndex: e,
976
+ ...t
977
+ }), void 0, { timeoutMs: n });
978
+ },
979
+ onUsage: a
980
+ });
981
+ let m;
982
+ try {
983
+ for (let e = 0; e < d.slideCount; e += 1) await this._slidePullClient.load(e, !1, i);
984
+ m = await this._bridge.request((e) => ({
985
+ kind: "finishPresentationPreflight",
986
+ id: e
987
+ }), void 0, { timeoutMs: i }), await p;
988
+ } catch (e) {
989
+ throw p.catch(() => void 0), e;
990
+ }
991
+ this._preflight = c(m.preflight), this._availableSlideCount = this._preflight.slideCount, this._slides = new Vt({
992
+ slideCount: this._preflight.slideCount,
993
+ maxCachedSlides: 8,
994
+ maxCachedStructuralBytes: ne,
995
+ loadSlide: async (e) => {
996
+ let t = await this._slidePullClient?.load(e, !0, i);
997
+ if (!t) throw Error("PPTX slide pull client is unavailable");
998
+ return t;
999
+ }
1000
+ });
1001
+ }
1002
+ async _parseMainProgressively(e, n, r, i, a, o, s = r) {
1003
+ let c = t((await this._bridge.request((t) => ({
1004
+ kind: "parse",
1005
+ id: t,
1006
+ buffer: e,
1007
+ resourcePolicy: n,
1008
+ cjkFallback: this._cjkFallback,
1009
+ progressiveLayout: !0
1010
+ }), [e], { timeoutMs: i })).bootstrap);
1011
+ this._bootstrap = c;
1012
+ let l = Gt(c.embeddedFonts, (e) => this.getFontBytes(e)).then((e) => {
1013
+ this._destroyed ? k(e.faces) : (this._embeddedFontFaces = e.faces, this._embeddedFontAliases = e.aliases, this._embeddedFontAuthoredFamilies = e.authoredFamilies, this._embeddedFontTuples = e.tuples);
1014
+ });
1015
+ l.catch(() => void 0), this._slidePullClient = this._createSlidePullClient(c.slideCount, i, a), this._slides = new Vt({
1016
+ slideCount: c.slideCount,
1017
+ maxCachedSlides: 8,
1018
+ maxCachedStructuralBytes: ne,
1019
+ loadSlide: async (e) => {
1020
+ let t = await this._slidePullClient?.load(e, !0, i);
1021
+ if (!t) throw Error("PPTX slide pull client is unavailable");
1022
+ return t;
1023
+ }
1024
+ });
1025
+ let d = new u(c, {
1026
+ cjkFallback: this._cjkFallback,
1027
+ collectFontDemand: s ? await pt(!0) : void 0
1028
+ }), f = async () => {
1029
+ await l, r && await this._ensureGoogleFonts(K(d.currentFontPreloadNames, this._embeddedFontAliases), d.currentFontPreloadDemandDelta);
1030
+ }, p = (async () => {
1031
+ for (let e = 0; e < c.slideCount; e += 1) await this._slides.withSlide(e, (e) => {
1032
+ d.addSlide(e);
1033
+ }), await f(), this._applyProgressivePrefix(d.snapshot(), o), e === 0 && o.deferred && await ln();
1034
+ await l, this._finishProgressiveLayout(d.finish(), o);
1035
+ })();
1036
+ this._layoutCompletion = p.then(() => void 0, (e) => this._failProgressiveLayout(e, o)), await o.firstPublication.promise;
1037
+ }
1038
+ async _parseWorkerProgressively(e, t, n, r, i, a, o) {
1039
+ this._progressiveWatchdogMs = r;
1040
+ let s = this._bridge.request((r) => (this._parseRequestId = r, {
1041
+ kind: "parse",
1042
+ id: r,
1043
+ buffer: e,
1044
+ resourcePolicy: t,
1045
+ useGoogleFonts: n,
1046
+ cjkFallback: this._cjkFallback,
1047
+ renderers: a,
1048
+ progressiveLayout: !0
1049
+ }), [e], { timeoutMs: !1 });
1050
+ this._rearmProgressiveWatchdog(), this._layoutCompletion = s.then((e) => {
1051
+ this._parseRequestId = null;
1052
+ let t = e;
1053
+ t.usage && i?.(t.usage), this._finishProgressiveLayout(c(t.preflight), o);
1054
+ }, (e) => {
1055
+ this._parseRequestId = null, this._failProgressiveLayout(e, o);
1056
+ }), await o.firstPublication.promise;
1057
+ }
1058
+ _createSlidePullClient(e, t, n) {
1059
+ return new f({
1060
+ slideCount: e,
1061
+ transport: this._bridge.transport(s),
1062
+ open: async (e, n, r) => {
1063
+ await this._bridge.request((t) => ({
1064
+ kind: "openSlideSession",
1065
+ id: t,
1066
+ slideIndex: e,
1067
+ ...n
1068
+ }), void 0, { timeoutMs: r ?? t });
1069
+ },
1070
+ onUsage: n
1071
+ });
1072
+ }
1073
+ _onWorkerLayoutPush(e) {
1074
+ if (!$e((e, t) => this._worker.postMessage(e, t), e) && !(!("kind" in e) || e.kind !== "presentationLayoutPartial" || e.forId !== this._parseRequestId || !this._progressive)) try {
1075
+ this._rearmProgressiveWatchdog(), e.usage && this._metrics?.observeUsage(e.usage), e.bootstrap && (this._bootstrap = t(e.bootstrap));
1076
+ let n = this._bootstrap;
1077
+ if (!n) throw Error("PPTX progressive worker published before bootstrap");
1078
+ let r = this._preflight?.slides ?? [];
1079
+ if (e.availableSlides !== r.length + 1 || e.slide.index !== r.length) throw Error("PPTX progressive worker published a non-sequential slide");
1080
+ this._applyProgressivePrefix(d({
1081
+ ...n,
1082
+ slides: [...r, e.slide],
1083
+ fontPreloadNames: e.fontPreloadNames
1084
+ }), this._progressive), ln().then(() => {
1085
+ this._destroyed || this._parseRequestId !== e.forId || this._bridge.post({
1086
+ kind: "continuePresentationPreflight",
1087
+ forId: e.forId,
1088
+ availableSlides: e.availableSlides
1089
+ });
1090
+ }).catch((t) => {
1091
+ this._destroyed || this._parseRequestId !== e.forId || !this._progressive || (this._failProgressiveLayout(t, this._progressive), this._bridge.terminate());
1092
+ });
1093
+ } catch (e) {
1094
+ this._failProgressiveLayout(e, this._progressive), this._bridge.terminate();
1095
+ }
1096
+ }
1097
+ _applyProgressivePrefix(e, t) {
1098
+ if (!(t.settled || this._destroyed)) {
1099
+ if (this._preflight = e, this._availableSlideCount = e.slides.length, !t.published && e.slides.length === e.slideCount) {
1100
+ t.published = !0, t.deferred = !1;
1101
+ return;
1102
+ }
1103
+ if (this._layoutLifecycle.begin(), this._wakeLayoutWaiters(), this._layoutObservers.notify("onLayoutProgress", t.onProgress, { committedUnits: this._availableSlideCount }), Y(this, {
1104
+ availableSlides: this._availableSlideCount,
1105
+ slideCount: this.slideCount,
1106
+ exact: !1,
1107
+ complete: !1
1108
+ }), !t.published) {
1109
+ t.published = !0, t.deferred = e.slides.length < e.slideCount, t.firstPublication.resolve();
1110
+ return;
1111
+ }
1112
+ this._layoutObservers.notify("onLayoutPartial", t.onPartial, {
1113
+ availableUnits: this._availableSlideCount,
1114
+ totalUnits: this.slideCount,
1115
+ exact: !1
1116
+ });
1117
+ }
1118
+ }
1119
+ _finishProgressiveLayout(e, t) {
1120
+ t.settled || this._destroyed || (t.settled = !0, this._clearProgressiveWatchdog(), this._preflight = e, this._bootstrap ??= e, this._availableSlideCount = e.slideCount, this._layoutLifecycle.succeed(), this._wakeLayoutWaiters(), t.firstPublication.resolve(), Y(this, {
1121
+ availableSlides: this._availableSlideCount,
1122
+ slideCount: this.slideCount,
1123
+ exact: !0,
1124
+ complete: !0
1125
+ }), this._layoutObservers.notify("onLayoutComplete", t.onComplete));
1126
+ }
1127
+ _failProgressiveLayout(e, t) {
1128
+ if (t.settled || (t.settled = !0, this._clearProgressiveWatchdog(), this._destroyed)) return;
1129
+ if (!t.deferred) {
1130
+ t.firstPublication.reject(e);
1131
+ return;
1132
+ }
1133
+ let n = this._layoutLifecycle.fail(e);
1134
+ this._wakeLayoutWaiters(), Y(this, {
1135
+ availableSlides: this._availableSlideCount,
1136
+ slideCount: this.slideCount,
1137
+ exact: !1,
1138
+ complete: !1,
1139
+ error: n
1140
+ }), this._layoutObservers.notify("onLayoutComplete", t.onComplete, n);
1141
+ }
1142
+ _wakeLayoutWaiters() {
1143
+ for (let e of this._layoutWaiters) e();
1144
+ this._layoutWaiters.clear();
1145
+ }
1146
+ _rearmProgressiveWatchdog() {
1147
+ this._progressiveWatchdogMs !== void 0 && (clearTimeout(this._progressiveWatchdog), this._progressiveWatchdog = setTimeout(() => {
1148
+ let e = this._progressive, t = this._progressiveWatchdogMs;
1149
+ if (!e || e.settled || t === void 0 || this._destroyed) return;
1150
+ let n = /* @__PURE__ */ Error(`worker layout produced no progress for ${t}ms`);
1151
+ this._failProgressiveLayout(n, e), this._bridge.terminate();
1152
+ }, this._progressiveWatchdogMs));
1153
+ }
1154
+ _clearProgressiveWatchdog() {
1155
+ clearTimeout(this._progressiveWatchdog), this._progressiveWatchdog = void 0, this._progressiveWatchdogMs = void 0;
1156
+ }
1157
+ async _waitForSlide(e) {
1158
+ for (; !this._destroyed && e >= this._availableSlideCount && !this._layoutLifecycle.settled;) await new Promise((e) => this._layoutWaiters.add(e));
1159
+ e >= this._availableSlideCount && await this.waitUntilLayoutComplete();
1160
+ }
1161
+ _assertSlideIndex(e) {
1162
+ if (!Number.isInteger(e) || e < 0 || e >= this.slideCount) throw Error(`Slide index ${e} out of range (count: ${this.slideCount})`);
1163
+ }
1164
+ get slideCount() {
1165
+ return this._bootstrap?.slideCount ?? this._preflight?.slideCount ?? 0;
1166
+ }
1167
+ get availableSlideCount() {
1168
+ return this._availableSlideCount;
1169
+ }
1170
+ get layoutComplete() {
1171
+ return this._layoutLifecycle.complete;
1172
+ }
1173
+ async waitUntilLayoutComplete() {
1174
+ this._layoutCompletion && await this._layoutCompletion, this._layoutLifecycle.throwIfFailed();
1175
+ }
1176
+ get slideWidth() {
1177
+ return this._bootstrap?.slideWidth ?? this._preflight?.slideWidth ?? 0;
1178
+ }
1179
+ get slideHeight() {
1180
+ return this._bootstrap?.slideHeight ?? this._preflight?.slideHeight ?? 0;
1181
+ }
1182
+ get mode() {
1183
+ return this._mode;
1184
+ }
1185
+ getNotes(e) {
1186
+ return Number.isInteger(e) ? this._preflight?.slides[e]?.notes ?? null : null;
1187
+ }
1188
+ getComments(e) {
1189
+ return Number.isInteger(e) ? this._preflight?.slides[e]?.comments ?? [] : [];
1190
+ }
1191
+ isHidden(e) {
1192
+ return Number.isInteger(e) ? this._preflight?.slides[e]?.hidden ?? !1 : !1;
1193
+ }
1194
+ _partNames() {
1195
+ return (this._bootstrap?.slides ?? this._preflight?.slides ?? []).map((e) => e.partName);
1196
+ }
1197
+ _partIndex() {
1198
+ return this._slidePartIndex ||= Nt(this._partNames()), this._slidePartIndex;
1199
+ }
1200
+ getSlideIndexByPartName(e) {
1201
+ return this._partIndex().get(e);
1202
+ }
1203
+ resolveInternalTarget(e, t = 0) {
1204
+ return Ft(e, this._partIndex(), t);
1205
+ }
1206
+ async _officeRoutesForRequests(e, t) {
1207
+ if (this._destroyed) throw Error("Presentation destroyed");
1208
+ if (!t) return {
1209
+ routes: {},
1210
+ installed: []
1211
+ };
1212
+ let n = Ut(e, this._embeddedFontTuples), r = this._officeFontLoads.get(t);
1213
+ r || (r = /* @__PURE__ */ new Map(), this._officeFontLoads.set(t, r));
1214
+ let i = await Lt(r, n, (e) => te(e, t), t);
1215
+ if (this._destroyed) throw Error("Presentation destroyed");
1216
+ return i;
1217
+ }
1218
+ async renderSlide(e, t, n = {}) {
1219
+ this._assertResourceHealthy();
1220
+ try {
1221
+ if (this._mode === "worker") throw Error("renderSlide(canvas) is unavailable in mode: 'worker'; use renderSlideToBitmap() and paint it via an ImageBitmapRenderingContext");
1222
+ if (this._assertSlideIndex(t), await this._waitForSlide(t), this._destroyed) throw Error("Presentation destroyed");
1223
+ let r = this._preflight, i = this._slides;
1224
+ if (!r || !i) throw Error("Presentation not loaded");
1225
+ let a = n.dpr ?? T(), o = n.width ?? ((C(e) ? e.offsetWidth : 0) || 960), s = await i.withSlide(t, (e) => l(e, r.majorFont, r.minorFont));
1226
+ if (this._destroyed) throw Error("Presentation destroyed");
1227
+ let c = C(e) ? e.ownerDocument.fonts : typeof document < "u" ? document.fonts : null, { routes: u, installed: d } = await this._officeRoutesForRequests(s, c);
1228
+ await i.withSlide(t, (t) => {
1229
+ if (this._destroyed) throw Error("Presentation destroyed");
1230
+ return this._assertResourceHealthy(), p(e, t, r.slideWidth, r.slideHeight, {
1231
+ width: o,
1232
+ dpr: a,
1233
+ defaultTextColor: r.defaultTextColor,
1234
+ cjkFallback: this._cjkFallback,
1235
+ majorFont: r.majorFont,
1236
+ minorFont: r.minorFont,
1237
+ hlinkColor: r.hlinkColor,
1238
+ embeddedFontAliases: this._embeddedFontAliases,
1239
+ embeddedFontAuthoredFamilies: this._embeddedFontAuthoredFamilies,
1240
+ embeddedFontTuples: this._embeddedFontTuples,
1241
+ officeFontRoutes: u,
1242
+ officeInstalledFamilies: d,
1243
+ googleSubstitutes: this._googleSubstitutes,
1244
+ fetchMedia: this._fetchMedia,
1245
+ fetchImage: this._fetchImage,
1246
+ skipMediaControls: n.skipMediaControls,
1247
+ dim: n.dim,
1248
+ math: this._math,
1249
+ threeD: this._threeD,
1250
+ regionMap: this._regionMap,
1251
+ chartEx: this._chartEx,
1252
+ tiff: this._tiff,
1253
+ imageResources: n.imageResources
1254
+ }, n.onTextRun);
1255
+ });
1256
+ } catch (e) {
1257
+ this._rethrowWithResourceFailure(e);
1258
+ }
1259
+ }
1260
+ async renderSlideToBitmap(e, t = {}) {
1261
+ this._assertResourceHealthy();
1262
+ try {
1263
+ this._assertSlideIndex(e), await this._waitForSlide(e);
1264
+ let n = t.width ?? 960, r = t.dpr ?? T();
1265
+ if (this._mode === "worker") {
1266
+ let i = new OffscreenCanvas(1, 1), a = await this._bridge.request((a) => ({
1267
+ kind: "renderSlide",
1268
+ id: a,
1269
+ slideIndex: e,
1270
+ width: n,
1271
+ dpr: r,
1272
+ imageResources: t.imageResources,
1273
+ skipMediaControls: t.skipMediaControls,
1274
+ dim: t.dim,
1275
+ canvas: i
1276
+ }), [i]);
1277
+ try {
1278
+ if (t.onTextRun) for (let e of a.runs) t.onTextRun(e);
1279
+ } catch (e) {
1280
+ throw ie(a.bitmap), e;
1281
+ }
1282
+ return a.bitmap;
1283
+ }
1284
+ let i = new OffscreenCanvas(1, 1);
1285
+ return await this.renderSlide(i, e, {
1286
+ width: n,
1287
+ dpr: r,
1288
+ imageResources: t.imageResources,
1289
+ skipMediaControls: t.skipMediaControls,
1290
+ dim: t.dim,
1291
+ onTextRun: t.onTextRun
1292
+ }), i.transferToImageBitmap();
1293
+ } catch (e) {
1294
+ this._rethrowWithResourceFailure(e);
1295
+ }
1296
+ }
1297
+ async collectSlideRuns(e, t = 960) {
1298
+ this._assertResourceHealthy();
1299
+ try {
1300
+ if (this._assertSlideIndex(e), await this._waitForSlide(e), this._mode === "worker") {
1301
+ let n = new OffscreenCanvas(1, 1);
1302
+ return (await this._bridge.request((r) => ({
1303
+ kind: "collectRuns",
1304
+ id: r,
1305
+ slideIndex: e,
1306
+ width: t,
1307
+ canvas: n
1308
+ }), [n])).runs;
1309
+ }
1310
+ let n = [], r = new OffscreenCanvas(1, 1);
1311
+ return await this.renderSlide(r, e, {
1312
+ width: t,
1313
+ onTextRun: (e) => n.push(e)
1314
+ }), n;
1315
+ } catch (e) {
1316
+ this._rethrowWithResourceFailure(e);
1317
+ }
1318
+ }
1319
+ async getElementContextAt(e, t, n = {}) {
1320
+ this._assertResourceHealthy(), this._assertSlideIndex(e);
1321
+ try {
1322
+ if (await this._waitForSlide(e), this._mode === "worker") return (await this._bridge.request((r) => ({
1323
+ kind: "hitTestElement",
1324
+ id: r,
1325
+ slideIndex: e,
1326
+ point: t,
1327
+ options: n
1328
+ }))).context;
1329
+ if (!this._slides) throw Error("Presentation not loaded");
1330
+ return await this._slides.withSlide(e, (r) => on(e, r, t, n));
1331
+ } catch (e) {
1332
+ this._rethrowWithResourceFailure(e);
1333
+ }
1334
+ }
1335
+ async getElementBoundsByIds(e, t) {
1336
+ this._assertResourceHealthy(), this._assertSlideIndex(e);
1337
+ let n = Object.freeze(t.filter((e) => typeof e == "string" && e.length > 0));
1338
+ if (n.length === 0) return Object.freeze([]);
1339
+ try {
1340
+ if (await this._waitForSlide(e), this._mode === "worker") return (await this._bridge.request((t) => ({
1341
+ kind: "resolveElementBounds",
1342
+ id: t,
1343
+ slideIndex: e,
1344
+ elementIds: n
1345
+ }))).bounds;
1346
+ if (!this._slides) throw Error("Presentation not loaded");
1347
+ return await this._slides.withSlide(e, (e) => sn(e, n));
1348
+ } catch (e) {
1349
+ this._rethrowWithResourceFailure(e);
1350
+ }
1351
+ }
1352
+ async getMedia(e) {
1353
+ this._assertResourceHealthy();
1354
+ try {
1355
+ let t = this._findMimeTypeForPath(e);
1356
+ return await this._rawParts.get(e, t, async () => {
1357
+ let n = (await this._bridge.request((t) => ({
1358
+ kind: "extractMedia",
1359
+ id: t,
1360
+ path: e
1361
+ }))).bytes;
1362
+ return new Blob([n], { type: t });
1363
+ });
1364
+ } catch (e) {
1365
+ this._rethrowWithResourceFailure(e);
1366
+ }
1367
+ }
1368
+ _findMimeTypeForPath(e) {
1369
+ return this._preflight ? a(this._preflight, e) : "";
1370
+ }
1371
+ async getImage(e, t) {
1372
+ this._assertResourceHealthy();
1373
+ try {
1374
+ return await this._rawParts.get(e, t, async () => {
1375
+ let n = (await this._bridge.request((t) => ({
1376
+ kind: "extractImage",
1377
+ id: t,
1378
+ path: e
1379
+ }))).bytes;
1380
+ return new Blob([n], { type: t });
1381
+ });
1382
+ } catch (e) {
1383
+ this._rethrowWithResourceFailure(e);
1384
+ }
1385
+ }
1386
+ async getFontBytes(e) {
1387
+ this._assertResourceHealthy();
1388
+ try {
1389
+ let t = await this._bridge.request((t) => ({
1390
+ kind: "extractFont",
1391
+ id: t,
1392
+ path: e
1393
+ }));
1394
+ return new Uint8Array(t.bytes);
1395
+ } catch (e) {
1396
+ this._rethrowWithResourceFailure(e);
1397
+ }
1398
+ }
1399
+ async getResourceMetrics() {
1400
+ let e = this._metrics;
1401
+ if (!e) throw Error("Presentation not loaded");
1402
+ return y(e, async (e) => (await this._bridge.request((e) => ({
1403
+ kind: "resourceUsage",
1404
+ id: e
1405
+ }), void 0, { timeoutMs: e })).usage);
1406
+ }
1407
+ async toMarkdown() {
1408
+ this._assertResourceHealthy();
1409
+ try {
1410
+ return (await this._bridge.request((e) => ({
1411
+ kind: "toMarkdown",
1412
+ id: e
1413
+ }))).markdown;
1414
+ } catch (e) {
1415
+ this._rethrowWithResourceFailure(e);
1416
+ }
1417
+ }
1418
+ async presentSlide(e, t, n = {}) {
1419
+ this._assertResourceHealthy();
1420
+ try {
1421
+ if (this._assertSlideIndex(t), await this._waitForSlide(t), !this._preflight) throw Error("Presentation not loaded");
1422
+ let r = n.dpr ?? T(), i = n.width ?? (e.offsetWidth || 960), a = this.slideWidth > 0 ? i * this.slideHeight / this.slideWidth : 0;
1423
+ e.style.width = `${Math.round(i)}px`, e.style.height = `${Math.round(a)}px`, e.style.display || (e.style.display = "block");
1424
+ let o = this._mode === "worker" ? async () => {
1425
+ let a = await this.renderSlideToBitmap(t, {
1426
+ width: i,
1427
+ dpr: r,
1428
+ imageResources: n.imageResources,
1429
+ skipMediaControls: !0,
1430
+ dim: n.dim,
1431
+ onTextRun: n.onTextRun
1432
+ });
1433
+ try {
1434
+ e.width = a.width, e.height = a.height;
1435
+ let t = e.getContext("2d");
1436
+ if (!t) throw Error("2D context not available");
1437
+ t.drawImage(a, 0, 0);
1438
+ } finally {
1439
+ ie(a);
1440
+ }
1441
+ } : () => this.renderSlide(e, t, {
1442
+ width: i,
1443
+ dpr: r,
1444
+ imageResources: n.imageResources,
1445
+ skipMediaControls: !0,
1446
+ dim: n.dim,
1447
+ onTextRun: n.onTextRun
1448
+ });
1449
+ return await vt(e, this._preflight.slides[t]?.mediaElements ?? [], {
1450
+ width: i,
1451
+ height: a,
1452
+ slideWidthEmu: this.slideWidth,
1453
+ fetchMedia: this._fetchMedia,
1454
+ fetchImage: this._fetchImage,
1455
+ drawBase: o,
1456
+ onError: n.onError
1457
+ });
1458
+ } catch (e) {
1459
+ this._rethrowWithResourceFailure(e);
1460
+ }
1461
+ }
1462
+ destroy() {
1463
+ this._destroyed = !0, this._clearProgressiveWatchdog(), this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._bootstrap = null, this._preflight = null, this._availableSlideCount = 0, this._layoutLifecycle.succeed(), this._layoutCompletion = null, this._progressive = null, this._parseRequestId = null, this._wakeLayoutWaiters(), this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFonts?.release(), this._googleFonts = null;
1464
+ for (let e of this._officeFontLoads.values()) for (let t of Bt(e)) t.then((e) => w(e.faces));
1465
+ this._officeFontLoads.clear(), this._embeddedFontFaces.length > 0 && (k(this._embeddedFontFaces), this._embeddedFontFaces = []), this._embeddedFontAliases = /* @__PURE__ */ new Map(), this._embeddedFontAuthoredFamilies = /* @__PURE__ */ new Map(), this._embeddedFontTuples = /* @__PURE__ */ new Set(), ue(this._fetchImage), ce(this._fetchImage);
1466
+ }
1467
+ };
1468
+ //#endregion
1469
+ //#region packages/pptx/src/selection-context.ts
1470
+ function un(e, t, n, r, i = {}) {
1471
+ let a = Fe({
1472
+ id: e.id,
1473
+ author: e.author,
1474
+ date: e.date,
1475
+ text: e.text,
1476
+ status: e.status ?? "active"
1477
+ }, (e.replies ?? []).map((e) => ({
1478
+ id: e.id,
1479
+ author: e.author,
1480
+ date: e.date,
1481
+ text: e.text,
1482
+ status: e.status ?? "active"
1483
+ })), i.maxTextCharacters);
1484
+ return Object.freeze({
1485
+ format: "pptx",
1486
+ kind: "comment",
1487
+ slideIndex: t,
1488
+ commentIndex: n,
1489
+ occurrenceId: r,
1490
+ ...e.id ? { commentId: e.id } : {},
1491
+ ...Number.isFinite(e.x) && Number.isFinite(e.y) ? { point: Object.freeze({
1492
+ x: e.x,
1493
+ y: e.y
1494
+ }) } : {},
1495
+ thread: a.thread,
1496
+ truncated: a.truncated,
1497
+ truncationReasons: a.truncated ? ["text"] : [],
1498
+ textCharacters: a.textCharacters,
1499
+ maxTextCharacters: a.maxTextCharacters
1500
+ });
1501
+ }
1502
+ function dn(e) {
1503
+ for (let t = e; t; t = t.parentElement) {
1504
+ let e = j(t.dataset.slideIndex);
1505
+ if (e !== null) return e;
1506
+ }
1507
+ return null;
1508
+ }
1509
+ function Z(e, t, n = {}) {
1510
+ let r = Ue(e, t, (e) => {
1511
+ let t = dn(e), n = j(e.dataset.runIndex);
1512
+ if (t === null || n === null) return null;
1513
+ let r = j(e.dataset.elementIndex), i = e.dataset.elementOrigin, a = r !== null && (i === "master" || i === "layout" || i === "slide");
1514
+ return {
1515
+ slideIndex: t,
1516
+ runIndex: n,
1517
+ ...e.dataset.shapeId === void 0 ? {} : { shapeId: e.dataset.shapeId },
1518
+ ...a ? {
1519
+ elementIndex: r,
1520
+ origin: i
1521
+ } : {}
1522
+ };
1523
+ }, {
1524
+ maxChars: n.maxTextCharacters,
1525
+ maxLocators: n.maxRunLocators
1526
+ });
1527
+ if (!r) return null;
1528
+ let i = [...r.locators].sort((e, t) => e.slideIndex - t.slideIndex || e.runIndex - t.runIndex);
1529
+ return {
1530
+ format: "pptx",
1531
+ kind: "text",
1532
+ text: r.text,
1533
+ slideIndexes: [...new Set(i.map((e) => e.slideIndex))],
1534
+ shapeIds: [...new Set(i.flatMap((e) => e.shapeId ? [e.shapeId] : []))],
1535
+ runs: i,
1536
+ truncated: r.truncated,
1537
+ truncationReasons: r.truncationReasons,
1538
+ textCharacters: r.textCharacters,
1539
+ maxTextCharacters: r.maxTextCharacters,
1540
+ maxRunLocators: r.maxLocators
1541
+ };
1542
+ }
1543
+ //#endregion
1544
+ //#region packages/pptx/src/focused-view-runtime.ts
1545
+ function Q(e, t, n, r, i) {
1546
+ return r === "worker" ? e.renderSlideToBitmap(n, i) : e.renderSlide(t, n, i);
1547
+ }
1548
+ //#endregion
1549
+ //#region packages/pptx/src/loading-indicator.ts
1550
+ function fn(e) {
1551
+ let t = e.ownerDocument ?? document, n = new qe(e, "Loading slide"), r = n.layer;
1552
+ r.style.backdropFilter = "blur(2px)";
1553
+ let i = t.createElement("span");
1554
+ return i.className = "ooxml-pptx-progress-circle", i.style.cssText = [
1555
+ "width:34px",
1556
+ "height:34px",
1557
+ "box-sizing:border-box",
1558
+ "border-radius:50%",
1559
+ "border:3px solid var(--border-bright, rgba(100,116,139,0.28))",
1560
+ "border-top-color:var(--signal, #12bfd8)",
1561
+ "box-shadow:0 2px 10px rgba(15,23,42,0.08)"
1562
+ ].join(";"), i.setAttribute("aria-hidden", "true"), r.appendChild(i), !(t.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1) && typeof i.animate == "function" && i.animate([{ transform: "rotate(0deg)" }, { transform: "rotate(360deg)" }], {
1563
+ duration: 800,
1564
+ iterations: Infinity,
1565
+ easing: "linear"
1566
+ }), n;
1567
+ }
1568
+ //#endregion
1569
+ //#region packages/pptx/src/viewer.ts
1570
+ var pn = Symbol("PptxViewer.borrowedPresentation"), mn = {
1571
+ color: "#ffffff",
1572
+ opacity: .6
1573
+ }, hn = class e {
1574
+ canvas;
1575
+ wrapper;
1576
+ canvasMount;
1577
+ _scale = null;
1578
+ textLayer = null;
1579
+ highlightLayer = null;
1580
+ elementLayer = null;
1581
+ _find;
1582
+ _findGeneration = 0;
1583
+ _measureCtx = null;
1584
+ presentationOwner;
1585
+ get engine() {
1586
+ return this.presentationOwner.current;
1587
+ }
1588
+ borrowed;
1589
+ hostWindow;
1590
+ opts;
1591
+ currentSlide = 0;
1592
+ _renderedSlide = -1;
1593
+ _hiddenMode;
1594
+ handle = null;
1595
+ _mode;
1596
+ renderDispatcher;
1597
+ errorRouter;
1598
+ destroyed = !1;
1599
+ selectionChangeListener = null;
1600
+ selectionContextKey = "null";
1601
+ elementClickListener = null;
1602
+ contextMenuListener = null;
1603
+ elementContext = null;
1604
+ elementHitGeneration = 0;
1605
+ elementHitTolerance;
1606
+ _loadingIndicator;
1607
+ _layoutUnsubscribe = null;
1608
+ _layoutWaiters = /* @__PURE__ */ new Set();
1609
+ _layoutFailed = !1;
1610
+ _navigationGeneration = 0;
1611
+ _renderProgressGeneration = 0;
1612
+ _lastReportedSlide = -1;
1613
+ _lastReportedTotal = -1;
1614
+ _lastReportedAvailable = -1;
1615
+ _lastReportedLayoutComplete = null;
1616
+ static fromPresentation(t, n, r = {}) {
1617
+ return new e(t, {
1618
+ ...r,
1619
+ [pn]: n
1620
+ });
1621
+ }
1622
+ constructor(e, t = {}) {
1623
+ this.opts = t, this.canvas = e;
1624
+ let n = t[pn];
1625
+ this.borrowed = n !== void 0, this._mode = F("PptxViewer", t.mode, n), this.presentationOwner = new P("PptxViewer", n ?? null, !1);
1626
+ let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
1627
+ if (!r) throw Error("PptxViewer requires a canvas with an active Window");
1628
+ this.hostWindow = r;
1629
+ let i = t.elementHitTolerance ?? 6;
1630
+ if (!Number.isFinite(i) || i < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
1631
+ this.elementHitTolerance = i, this._hiddenMode = t.hiddenSlideMode ?? "show", this.canvasMount = new Ze(e, {
1632
+ wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
1633
+ forceDisplayBlock: !0
1634
+ }), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new N(e, this._mode === "worker" && !t.enableMediaPlayback), this.errorRouter = new Ge("PptxViewer", t.onError);
1635
+ let a = new Ye(this.wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
1636
+ this.textLayer = a.textLayer, this.highlightLayer = a.highlightLayer, this.elementLayer = a.elementLayer, this._loadingIndicator = fn(this.wrapper), this.wrapper.insertBefore(this._loadingIndicator.layer, this.elementLayer), this.textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this.selectionChangeListener = () => this._emitSelectionContextChange(), this.wrapper.ownerDocument.addEventListener("selectionchange", this.selectionChangeListener)), t.enableElementSelection && (this.elementClickListener = (e) => {
1637
+ this._onElementClick(e).catch((e) => this._reportRenderError(e));
1638
+ }, this.wrapper.addEventListener("click", this.elementClickListener)), t.onContextMenu && (this.contextMenuListener = (e) => this._onContextMenu(e), this.wrapper.addEventListener("contextmenu", this.contextMenuListener)), this._find = new ft(() => this.slideCount, (e) => this._collectSlideRuns(e)), n && this._bindLayoutPresentation(n);
1639
+ }
1640
+ async load(e) {
1641
+ if (this.destroyed) throw Error("PptxViewer is destroyed");
1642
+ if (this.borrowed) throw Error("PptxViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.");
1643
+ let t = !1;
1644
+ try {
1645
+ let n = await this.presentationOwner.replace(() => X.load(e, {
1646
+ password: this.opts.password,
1647
+ useGoogleFonts: this.opts.useGoogleFonts,
1648
+ cjkFallback: this.opts.cjkFallback,
1649
+ maxZipEntryBytes: this.opts.maxZipEntryBytes,
1650
+ resourceLimits: this.opts.resourceLimits,
1651
+ debug: this.opts.debug,
1652
+ onResourceMetrics: this.opts.onResourceMetrics,
1653
+ workerTimeoutMs: this.opts.workerTimeoutMs,
1654
+ wasmUrl: this.opts.wasmUrl,
1655
+ math: this.opts.math,
1656
+ threeD: this.opts.threeD,
1657
+ regionMap: this.opts.regionMap,
1658
+ chartEx: this.opts.chartEx,
1659
+ tiff: this.opts.tiff,
1660
+ mode: this._mode,
1661
+ ...this.opts.legacyPpt === void 0 ? void 0 : { legacyPpt: this.opts.legacyPpt },
1662
+ progressiveLayout: this.opts.progressiveLayout,
1663
+ onLayoutProgress: this.opts.onLayoutProgress,
1664
+ onLayoutPartial: this.opts.onLayoutPartial,
1665
+ onLayoutComplete: this.opts.onLayoutComplete
1666
+ }), () => {
1667
+ this._invalidateElementSelection(!1), t = !0, this.renderDispatcher.begin(), this._invalidateFind(), this.handle?.destroy(), this.handle = null, this._unbindLayoutPresentation();
1668
+ });
1669
+ if (!n) return;
1670
+ if (this.destroyed) throw Error("PptxViewer is destroyed");
1671
+ this._bindLayoutPresentation(n);
1672
+ let r = this._beginNavigation();
1673
+ if (this.currentSlide = await this._initialSlide(r), r !== this._navigationGeneration || n !== this.engine) return;
1674
+ this._renderedSlide = -1, this._invalidateFind(), await this.renderCurrentSlide();
1675
+ } catch (e) {
1676
+ throw this.destroyed ? Error("PptxViewer is destroyed") : e instanceof Error ? e : Error(String(e));
1677
+ }
1678
+ t && !this.destroyed && this._emitSelectionContextChange();
1679
+ }
1680
+ async goToSlide(e) {
1681
+ let t = this._beginNavigation();
1682
+ await this._goToSlide(e, t);
1683
+ }
1684
+ async _goToSlide(e, t) {
1685
+ if (t !== this._navigationGeneration || !this.engine || this.slideCount === 0) return;
1686
+ let n = Math.max(0, Math.min(e, this.slideCount - 1)), r = n !== this.currentSlide;
1687
+ r && this._invalidateElementSelection(!1), this.currentSlide = n, await this.renderCurrentSlide(), r && !this.destroyed && this._emitSelectionContextChange();
1688
+ }
1689
+ async nextSlide() {
1690
+ let e = this._beginNavigation(), t = await this._step(1, e);
1691
+ await this._goToSlide(t, e);
1692
+ }
1693
+ async prevSlide() {
1694
+ let e = this._beginNavigation(), t = await this._step(-1, e);
1695
+ await this._goToSlide(t, e);
1696
+ }
1697
+ async _step(e, t) {
1698
+ let n = this.engine, r = this.currentSlide;
1699
+ if (this._hiddenMode !== "skip" || !n) return r + e;
1700
+ for (let i = r + e; i >= 0 && i < this.slideCount; i += e) {
1701
+ if (i >= n.availableSlideCount && (n.layoutComplete || this._setLoading(!0), !await this._waitForSlide(n, i, () => t === this._navigationGeneration))) return r;
1702
+ if (!n.isHidden(i)) return i;
1703
+ }
1704
+ return r;
1705
+ }
1706
+ async _initialSlide(e) {
1707
+ let t = this.engine;
1708
+ if (this._hiddenMode !== "skip" || !t || this.slideCount === 0 || t.availableSlideCount === 0 && !await this._waitForSlide(t, 0, () => e === this._navigationGeneration) || !t.isHidden(0)) return 0;
1709
+ let n = await this._step(1, e);
1710
+ return n === 0 ? 0 : n;
1711
+ }
1712
+ _dim() {
1713
+ return {
1714
+ color: this.opts.hiddenSlideDim?.color ?? mn.color,
1715
+ opacity: this.opts.hiddenSlideDim?.opacity ?? mn.opacity
1716
+ };
1717
+ }
1718
+ async setHiddenSlideMode(e) {
1719
+ let t = this._beginNavigation();
1720
+ this._hiddenMode = e;
1721
+ let n = this.currentSlide;
1722
+ if (e === "skip" && this.engine) {
1723
+ let e = this.engine;
1724
+ if (this.currentSlide >= e.availableSlideCount && !await this._waitForSlide(e, this.currentSlide, () => t === this._navigationGeneration)) return;
1725
+ e.isHidden(this.currentSlide) && (n = await this._step(1, t), n === this.currentSlide && (n = await this._step(-1, t)));
1726
+ }
1727
+ if (t !== this._navigationGeneration) return;
1728
+ let r = n !== this.currentSlide;
1729
+ r && this._invalidateElementSelection(!1), this.currentSlide = n, await this.renderCurrentSlide(), r && !this.destroyed && this._emitSelectionContextChange();
1730
+ }
1731
+ get hiddenSlideMode() {
1732
+ return this._hiddenMode;
1733
+ }
1734
+ get visibleSlideCount() {
1735
+ if (!this.engine) return 0;
1736
+ let e = this.engine;
1737
+ return rt((t) => e.isHidden(t), this.slideCount);
1738
+ }
1739
+ get slideIndex() {
1740
+ return this.currentSlide;
1741
+ }
1742
+ get slideCount() {
1743
+ return this.engine?.slideCount ?? 0;
1744
+ }
1745
+ get availableSlideCount() {
1746
+ return this.engine?.availableSlideCount ?? this.slideCount;
1747
+ }
1748
+ get layoutComplete() {
1749
+ return this.engine?.layoutComplete ?? !0;
1750
+ }
1751
+ async waitUntilLayoutComplete() {
1752
+ await this.errorRouter.ownBackgroundLifecycle(async () => {
1753
+ await this.engine?.waitUntilLayoutComplete?.();
1754
+ });
1755
+ }
1756
+ getNotes(e) {
1757
+ return this.engine?.getNotes(e) ?? null;
1758
+ }
1759
+ get canvasElement() {
1760
+ return this.canvas;
1761
+ }
1762
+ _naturalWidthPx() {
1763
+ let e = this.engine?.slideWidth ?? 0;
1764
+ return e > 0 ? e / m : 0;
1765
+ }
1766
+ _targetWidth() {
1767
+ if (this._scale === null) return this.opts.width ?? (this.canvas.offsetWidth || 960);
1768
+ let e = this._naturalWidthPx();
1769
+ return e <= 0 ? this.opts.width ?? (this.canvas.offsetWidth || 960) : Math.round(e * this._scale);
1770
+ }
1771
+ getScale() {
1772
+ if (this._scale !== null) return this._scale;
1773
+ let e = this._naturalWidthPx();
1774
+ return e <= 0 ? 1 : this._targetWidth() / e;
1775
+ }
1776
+ _zoomMin() {
1777
+ return this.opts.zoomMin ?? .1;
1778
+ }
1779
+ _zoomMax() {
1780
+ return this.opts.zoomMax ?? 4;
1781
+ }
1782
+ async setScale(e) {
1783
+ let t = Qe(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
1784
+ this._scale = t, await this.renderCurrentSlide(), n && this.opts.onScaleChange?.(t);
1785
+ }
1786
+ async zoomIn() {
1787
+ await this.setScale(He(this.getScale()));
1788
+ }
1789
+ async zoomOut() {
1790
+ await this.setScale(et(this.getScale()));
1791
+ }
1792
+ async fitWidth() {
1793
+ await this._fit("width");
1794
+ }
1795
+ async fitPage() {
1796
+ await this._fit("page");
1797
+ }
1798
+ async _fit(e) {
1799
+ if (!this.engine) return;
1800
+ let t = this.wrapper.parentElement;
1801
+ if (!t) return;
1802
+ let n = tt({
1803
+ contentWidth: this.engine.slideWidth / m,
1804
+ contentHeight: this.engine.slideHeight / m,
1805
+ containerWidth: t.clientWidth,
1806
+ containerHeight: t.clientHeight
1807
+ }, e);
1808
+ n <= 0 || await this.setScale(n);
1809
+ }
1810
+ async renderCurrentSlide() {
1811
+ let e = this.engine;
1812
+ if (!e) return;
1813
+ let t = this.currentSlide, n = ++this._renderProgressGeneration;
1814
+ this._setLoading(t >= this.availableSlideCount && !this.layoutComplete);
1815
+ let r = this.renderDispatcher.begin();
1816
+ try {
1817
+ if (t >= e.availableSlideCount && !await this._waitForSlide(e, t, () => n === this._renderProgressGeneration && this.renderDispatcher.isCurrent(r) && e === this.engine && t === this.currentSlide)) return;
1818
+ let i = this._hiddenMode === "dim" && e.isHidden(t) ? this._dim() : void 0, a = this._targetWidth(), o = this.opts.dpr ?? T(), s = a / e.slideWidth, c = Math.round(e.slideHeight * s);
1819
+ this.canvas.style.width = `${a}px`, this.canvas.style.height = `${c}px`, this.handle?.destroy(), this.handle = null;
1820
+ let l = this._mode === "worker", u = [], d = (e) => u.push(e);
1821
+ if (this.opts.enableMediaPlayback) {
1822
+ let n = await e.presentSlide(this.canvas, t, {
1823
+ width: a,
1824
+ dpr: o,
1825
+ imageResources: this.opts.imageResources,
1826
+ dim: i,
1827
+ onTextRun: d,
1828
+ onError: (e) => {
1829
+ this.renderDispatcher.isCurrent(r) && this._reportRenderError(e);
1830
+ }
1831
+ });
1832
+ if (!this.renderDispatcher.isCurrent(r)) {
1833
+ n.destroy();
1834
+ return;
1835
+ }
1836
+ this.handle = n;
1837
+ } else if (l) {
1838
+ let e = await Q(this.engine, this.canvas, t, "worker", {
1839
+ width: a,
1840
+ dpr: o,
1841
+ imageResources: this.opts.imageResources,
1842
+ dim: i,
1843
+ onTextRun: d
1844
+ });
1845
+ if (!this.renderDispatcher.commitBitmap(r, e)) return;
1846
+ } else if (await Q(this.engine, this.canvas, t, "main", {
1847
+ width: a,
1848
+ dpr: o,
1849
+ imageResources: this.opts.imageResources,
1850
+ onTextRun: d,
1851
+ dim: i
1852
+ }), !this.renderDispatcher.isCurrent(r)) return;
1853
+ this._renderedSlide = t, this._emitSlideChange(!0), this.textLayer && this._buildTextLayer(this.textLayer, u, a, c), this._find.setSlideRuns(t, u), this._buildHighlightLayer(u, a, c);
1854
+ } catch (t) {
1855
+ if (!this.renderDispatcher.isCurrent(r) && !(e === this.engine && this._layoutFailed)) return;
1856
+ throw t;
1857
+ } finally {
1858
+ n === this._renderProgressGeneration && this._setLoading(!1);
1859
+ }
1860
+ }
1861
+ _bindLayoutPresentation(e) {
1862
+ this._unbindLayoutPresentation(), this._layoutFailed = !1;
1863
+ let t = !0;
1864
+ this._layoutUnsubscribe = cn(e, () => ({
1865
+ availableSlides: e.availableSlideCount,
1866
+ slideCount: e.slideCount,
1867
+ exact: e.layoutComplete,
1868
+ complete: e.layoutComplete
1869
+ }), (n) => {
1870
+ if (t) {
1871
+ t = !1;
1872
+ return;
1873
+ }
1874
+ this._onLayoutPublication(e, n);
1875
+ }, (e) => this._reportRenderError(e));
1876
+ }
1877
+ _unbindLayoutPresentation() {
1878
+ this._layoutUnsubscribe?.(), this._layoutUnsubscribe = null, this._layoutFailed = !1, this._navigationGeneration++, this._renderProgressGeneration++, this._wakeLayoutWaiters(), this._setLoading(!1);
1879
+ }
1880
+ _beginNavigation() {
1881
+ let e = ++this._navigationGeneration;
1882
+ return this._wakeLayoutWaiters(), e;
1883
+ }
1884
+ _onLayoutPublication(e, t) {
1885
+ if (!(this.destroyed || e !== this.engine)) {
1886
+ if (this._wakeLayoutWaiters(), t.error !== void 0) {
1887
+ this._layoutFailed = !0, this.errorRouter.reportBackground(t.error, this.opts.onLayoutComplete !== void 0);
1888
+ return;
1889
+ }
1890
+ this._renderedSlide === this.currentSlide && this._emitSlideChange();
1891
+ }
1892
+ }
1893
+ async _waitForSlide(e, t, n) {
1894
+ return await this.errorRouter.ownBackgroundLifecycle(async () => {
1895
+ for (; !this.destroyed && n() && e === this.engine && t >= e.availableSlideCount && !e.layoutComplete && !this._layoutFailed;) await new Promise((e) => this._layoutWaiters.add(e));
1896
+ return this.destroyed || e !== this.engine || ((e.layoutComplete || this._layoutFailed) && await e.waitUntilLayoutComplete?.(), !n()) ? !1 : t < e.availableSlideCount;
1897
+ });
1898
+ }
1899
+ _wakeLayoutWaiters() {
1900
+ for (let e of this._layoutWaiters) e();
1901
+ this._layoutWaiters.clear();
1902
+ }
1903
+ _emitSlideChange(e = !1) {
1904
+ let t = this.slideCount, n = this.availableSlideCount, r = this.layoutComplete;
1905
+ !e && this.currentSlide === this._lastReportedSlide && t === this._lastReportedTotal && n === this._lastReportedAvailable && r === this._lastReportedLayoutComplete || (this._lastReportedSlide = this.currentSlide, this._lastReportedTotal = t, this._lastReportedAvailable = n, this._lastReportedLayoutComplete = r, this.opts.onSlideChange?.(this.currentSlide, t, r));
1906
+ }
1907
+ _setLoading(e) {
1908
+ this._loadingIndicator.setLoading(e);
1909
+ }
1910
+ _buildHighlightLayer(e, t, n) {
1911
+ let r = this.highlightLayer;
1912
+ r && R(r, e, this._find.slideHighlights(this.currentSlide), t, n, (e) => this._measureForFont(e), this.opts.findHighlightColors);
1913
+ }
1914
+ _measureForFont(e) {
1915
+ if (!this._measureCtx) {
1916
+ let e = document.createElement("canvas");
1917
+ this._measureCtx = e.getContext("2d");
1918
+ }
1919
+ let t = this._measureCtx;
1920
+ return t ? (t.font = e, (e) => t.measureText(e).width) : (e) => e.length;
1921
+ }
1922
+ async _collectSlideRuns(e) {
1923
+ return this.engine ? this.engine.collectSlideRuns(e, this._targetWidth()) : [];
1924
+ }
1925
+ async findText(e, t = {}) {
1926
+ let n = this.engine;
1927
+ if (!n) return [];
1928
+ let r = ++this._findGeneration;
1929
+ if (e.length === 0) return this._find.invalidate(), this._redrawHighlights(), [];
1930
+ if (n.layoutComplete || await this.errorRouter.ownBackgroundLifecycle(() => n.waitUntilLayoutComplete()), this.destroyed || r !== this._findGeneration || n !== this.engine) return [];
1931
+ let i = await this.errorRouter.ownAwaitable(() => this._find.find(e, t));
1932
+ return this.destroyed || r !== this._findGeneration || n !== this.engine ? [] : (this._redrawHighlights(), i);
1933
+ }
1934
+ async findNext() {
1935
+ return this._activateMatch(this._find.next());
1936
+ }
1937
+ async findPrev() {
1938
+ return this._activateMatch(this._find.prev());
1939
+ }
1940
+ clearFind() {
1941
+ this._invalidateFind(), this._redrawHighlights();
1942
+ }
1943
+ _invalidateFind() {
1944
+ this._findGeneration++, this._find.invalidate();
1945
+ }
1946
+ async _activateMatch(e) {
1947
+ return e ? (e.location.slide === this.currentSlide ? this._redrawHighlights() : await this.goToSlide(e.location.slide), e) : (this._redrawHighlights(), null);
1948
+ }
1949
+ _redrawHighlights() {
1950
+ let e = this._find.slideRuns(this.currentSlide) ?? [], t = this._targetWidth(), n = this.engine ? Math.round(this.engine.slideHeight * (t / this.engine.slideWidth)) : 0;
1951
+ this._buildHighlightLayer(e, t, n);
1952
+ }
1953
+ _buildTextLayer(e, t, n, r) {
1954
+ L(e, t, n, r, this._hyperlinkHandler(), this.currentSlide);
1955
+ }
1956
+ _hyperlinkHandler() {
1957
+ if (this.opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
1958
+ }
1959
+ _onHyperlinkClick(e) {
1960
+ let t = this._resolveInternalSlideIndex(e);
1961
+ if (this.opts.onHyperlinkClick) {
1962
+ this.opts.onHyperlinkClick(t);
1963
+ return;
1964
+ }
1965
+ if (t.kind === "external") {
1966
+ D(t.url, void 0, this.hostWindow);
1967
+ return;
1968
+ }
1969
+ t.slideIndex !== void 0 && this.goToSlide(t.slideIndex).catch((e) => this._reportRenderError(e));
1970
+ }
1971
+ _resolveInternalSlideIndex(e) {
1972
+ if (e.kind !== "internal" || e.slideIndex !== void 0) return e;
1973
+ let t = this.engine?.resolveInternalTarget(e.ref, this.currentSlide);
1974
+ return t === void 0 ? e : {
1975
+ ...e,
1976
+ slideIndex: t
1977
+ };
1978
+ }
1979
+ _reportRenderError(e) {
1980
+ this.errorRouter.report(e);
1981
+ }
1982
+ async getResourceMetrics() {
1983
+ if (!this.engine) throw Error("Presentation not loaded");
1984
+ return await this.engine.getResourceMetrics();
1985
+ }
1986
+ getSelectionContext(e = {}) {
1987
+ if (this.destroyed) throw Error("PptxViewer is destroyed");
1988
+ return (this.textLayer ? Z(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this.elementContext ? rn(this.elementContext, e.maxTextCharacters) : null);
1989
+ }
1990
+ _emitSelectionContextChange() {
1991
+ let e = this.getSelectionContext();
1992
+ e?.kind === "text" && (this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline());
1993
+ let t = JSON.stringify(e);
1994
+ t !== this.selectionContextKey && (this.selectionContextKey = t, this.opts.onSelectionContextChange?.(e ? structuredClone(e) : null));
1995
+ }
1996
+ _setElementContext(e) {
1997
+ this.elementContext = e ? structuredClone(e) : null, this._redrawElementOutline(), this._emitSelectionContextChange();
1998
+ }
1999
+ _invalidateElementSelection(e = !0) {
2000
+ this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline(), e && this._emitSelectionContextChange();
2001
+ }
2002
+ _redrawElementOutline() {
2003
+ let e = this.elementContext, t = this.engine;
2004
+ if (!e || !t || e.slideIndex !== this.currentSlide) {
2005
+ Ke(this.elementLayer, null);
2006
+ return;
2007
+ }
2008
+ Ke(this.elementLayer, {
2009
+ x: e.bounds.x / t.slideWidth,
2010
+ y: e.bounds.y / t.slideHeight,
2011
+ width: e.bounds.width / t.slideWidth,
2012
+ height: e.bounds.height / t.slideHeight,
2013
+ rotation: e.bounds.rotation
2014
+ });
2015
+ }
2016
+ async _onElementClick(e) {
2017
+ this.destroyed || e.defaultPrevented || e.button !== 0 || await this._resolveContextAt(e);
2018
+ }
2019
+ _onContextMenu(e) {
2020
+ let t;
2021
+ this.opts.onContextMenu?.({
2022
+ originalEvent: e,
2023
+ getContext: () => t ??= this._resolveContextAt(e)
2024
+ });
2025
+ }
2026
+ async _resolveContextAt(e) {
2027
+ let t = this.engine;
2028
+ if (this.destroyed || !t) return null;
2029
+ if (this.textLayer && Z(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null)) return this._emitSelectionContextChange(), this.destroyed ? null : this.getSelectionContext();
2030
+ if (!this.opts.enableElementSelection) return this.getSelectionContext();
2031
+ let n = this.canvas.getBoundingClientRect();
2032
+ if (n.width <= 0 || n.height <= 0) return this._invalidateElementSelection(), null;
2033
+ let r = e.clientX - n.left, i = e.clientY - n.top;
2034
+ if (r < 0 || i < 0 || r > n.width || i > n.height) return this._invalidateElementSelection(), null;
2035
+ let a = ++this.elementHitGeneration, o = this.currentSlide, s = {
2036
+ x: r / n.width * t.slideWidth,
2037
+ y: i / n.height * t.slideHeight
2038
+ }, c;
2039
+ try {
2040
+ c = await t.getElementContextAt(o, s, {
2041
+ tolerance: this.elementHitTolerance / n.width * t.slideWidth,
2042
+ maxTextCharacters: q
2043
+ });
2044
+ } catch (e) {
2045
+ if (this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine) return null;
2046
+ throw e;
2047
+ }
2048
+ return this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine ? null : (this._setElementContext(c), this.destroyed ? null : this.getSelectionContext());
2049
+ }
2050
+ destroy() {
2051
+ this.destroyed || (this.destroyed = !0, this.errorRouter.close(), this.renderDispatcher.destroy(), n(this.canvas), this.handle?.destroy(), this.handle = null, this._unbindLayoutPresentation(), this.presentationOwner.close(), this._invalidateFind(), this.selectionChangeListener &&= (this.wrapper.ownerDocument.removeEventListener("selectionchange", this.selectionChangeListener), null), this.elementHitGeneration++, this.elementClickListener &&= (this.wrapper.removeEventListener("click", this.elementClickListener), null), this.contextMenuListener &&= (this.wrapper.removeEventListener("contextmenu", this.contextMenuListener), null), this.elementContext = null, this.canvasMount.restore());
2052
+ }
2053
+ };
2054
+ //#endregion
2055
+ //#region packages/pptx/src/comment-occurrence.ts
2056
+ function $(e, t, n) {
2057
+ return `slide:${n}:${e.id ?? `classic:${e.authorId ?? "unknown"}:${e.index ?? t}`}`;
2058
+ }
2059
+ //#endregion
2060
+ //#region packages/pptx/src/scroll-layout-controller.ts
2061
+ var gn = class {
2062
+ hooks;
2063
+ unsubscribe = null;
2064
+ constructor(e) {
2065
+ this.hooks = e;
2066
+ }
2067
+ bind(e) {
2068
+ this.unbind();
2069
+ let t = !0;
2070
+ this.unsubscribe = cn(e, () => ({
2071
+ availableSlides: e.availableSlideCount,
2072
+ slideCount: e.slideCount,
2073
+ exact: e.layoutComplete,
2074
+ complete: e.layoutComplete
2075
+ }), (n) => {
2076
+ if (t) {
2077
+ t = !1;
2078
+ return;
2079
+ }
2080
+ this.onPublication(e, n);
2081
+ }, this.hooks.report);
2082
+ }
2083
+ unbind() {
2084
+ this.unsubscribe?.(), this.unsubscribe = null, this.hooks.resetComments(), this.hooks.wakeComments();
2085
+ }
2086
+ onPublication(e, t) {
2087
+ if (!(this.hooks.destroyed() || e !== this.hooks.current())) {
2088
+ if (this.hooks.wakeComments(), t.error !== void 0) {
2089
+ this.hooks.failComments(), this.hooks.reportBackground(t.error);
2090
+ return;
2091
+ }
2092
+ this.hooks.scanComments(e), this.hooks.renderAvailable(e), this.hooks.emitVisible();
2093
+ }
2094
+ }
2095
+ destroy() {
2096
+ this.unbind();
2097
+ }
2098
+ }, _n = class {
2099
+ hooks;
2100
+ constructor(e) {
2101
+ this.hooks = e;
2102
+ }
2103
+ renderInteractive(e, t, n, r, i, a, o = !0) {
2104
+ let s = this.hooks.presentation();
2105
+ if (!s) return Promise.resolve();
2106
+ let c = ++t.presentationGeneration;
2107
+ t.presentationHandle?.destroy(), t.presentationHandle = null;
2108
+ let l = [], u = this.hooks.textSelection() && !!t.textLayer, d = u || this.hooks.findActive();
2109
+ return s.presentSlide(t.canvas, e, {
2110
+ width: n,
2111
+ dpr: r,
2112
+ imageResources: this.hooks.imageResources(),
2113
+ onTextRun: d ? (e) => l.push(e) : void 0,
2114
+ onError: (e) => {
2115
+ c === t.presentationGeneration && this.hooks.reportError(e);
2116
+ }
2117
+ }).then((r) => {
2118
+ if (!this.isCurrent(e, t, c, a)) {
2119
+ r.destroy();
2120
+ return;
2121
+ }
2122
+ t.presentationHandle = r, t.renderedScale = i, u && t.textLayer && L(t.textLayer, l, Math.round(n), Math.round(this.hooks.height()), this.hooks.hyperlinkHandler(), e), d && this.hooks.refreshFindRuns(e, l), this.hooks.commitComments(e, t), this.hooks.redrawHighlights(e, t);
2123
+ }).catch((e) => {
2124
+ if (c === t.presentationGeneration) if (o) this.hooks.reportError(e);
2125
+ else throw e;
2126
+ });
2127
+ }
2128
+ sync(e = this.hooks.mediaRange()) {
2129
+ if (this.hooks.mediaEnabled()) for (let [t, n] of this.hooks.slots()) {
2130
+ let r = this.hooks.rangeContains(e, t);
2131
+ r !== n.mediaInteractive && (r ? (n.mediaInteractive = !0, this.settleInteractive(t, n, this.hooks.width(), this.hooks.dpr(), this.hooks.scale(), this.hooks.epoch())) : (n.mediaInteractive = !1, n.presentationGeneration++, n.presentationHandle?.destroy(), n.presentationHandle = null));
2132
+ }
2133
+ }
2134
+ settleInteractive(e, t, n, r, i, a) {
2135
+ let o = this.hooks.presentation();
2136
+ if (!o) return;
2137
+ let s = ++t.presentationGeneration, c = document.createElement("canvas");
2138
+ c.style.cssText = "display:block;background:#fff;";
2139
+ let l = this.hooks.shadow();
2140
+ l !== !1 && (c.style.boxShadow = l);
2141
+ let u = [], d = this.hooks.textSelection() && !!t.textLayer, f = d || this.hooks.findActive();
2142
+ o.presentSlide(c, e, {
2143
+ width: n,
2144
+ dpr: r,
2145
+ onTextRun: f ? (e) => u.push(e) : void 0,
2146
+ onError: (e) => {
2147
+ s === t.presentationGeneration && this.hooks.reportError(e);
2148
+ }
2149
+ }).then((r) => {
2150
+ if (!this.isCurrent(e, t, s, a)) {
2151
+ r.destroy();
2152
+ return;
2153
+ }
2154
+ let o = t.canvas, l = t.presentationHandle;
2155
+ t.dispatcher.destroy(), t.wrapper.insertBefore(c, o), o.remove(), t.canvas = c, t.dispatcher = new N(c, !1), t.presentationHandle = r, t.renderedScale = i, l?.destroy(), t.textLayer && (this.hooks.clearTextPreview(t.textLayer), d && L(t.textLayer, u, Math.round(n), Math.round(this.hooks.height()), this.hooks.hyperlinkHandler(), e)), f && this.hooks.refreshFindRuns(e, u), this.hooks.commitComments(e, t), this.hooks.redrawHighlights(e, t);
2156
+ }).catch((e) => {
2157
+ s === t.presentationGeneration && this.hooks.reportError(e);
2158
+ });
2159
+ }
2160
+ isCurrent(e, t, n, r) {
2161
+ return n === t.presentationGeneration && t.mediaInteractive && r === this.hooks.epoch() && this.hooks.slots().get(e) === t && t.renderedSlide === e;
2162
+ }
2163
+ destroy() {
2164
+ for (let e of this.hooks.slots().values()) e.presentationGeneration++, e.presentationHandle?.destroy(), e.presentationHandle = null, e.mediaInteractive = !1;
2165
+ }
2166
+ }, vn = class {
2167
+ hooks;
2168
+ generation = 0;
2169
+ layoutWaiters = /* @__PURE__ */ new Set();
2170
+ layoutFailed = !1;
2171
+ constructor(e) {
2172
+ this.hooks = e;
2173
+ }
2174
+ resetLayout() {
2175
+ this.layoutFailed = !1, this.wake();
2176
+ }
2177
+ failLayout() {
2178
+ this.layoutFailed = !0, this.wake();
2179
+ }
2180
+ wake() {
2181
+ for (let e of this.layoutWaiters) e();
2182
+ this.layoutWaiters.clear();
2183
+ }
2184
+ begin() {
2185
+ let e = ++this.generation;
2186
+ return this.wake(), e;
2187
+ }
2188
+ async waitForSlideMetadata(e, t, n) {
2189
+ return await this.hooks.ownBackground(async () => {
2190
+ for (; !this.hooks.destroyed() && n === this.generation && e === this.hooks.presentation() && t >= e.availableSlideCount && !e.layoutComplete && !this.layoutFailed;) await new Promise((e) => this.layoutWaiters.add(e));
2191
+ return this.hooks.destroyed() || e !== this.hooks.presentation() || ((e.layoutComplete || this.layoutFailed) && await e.waitUntilLayoutComplete?.(), n !== this.generation) ? !1 : t < e.availableSlideCount;
2192
+ });
2193
+ }
2194
+ async resolveBounds(e, t) {
2195
+ let n = this.hooks.presentation();
2196
+ if (!n) return;
2197
+ let r = (t.anchors ?? []).flatMap((e) => (e.type === "drawingElement" || e.type === "textRange") && e.elementId ? [e.elementId] : []);
2198
+ if (r.length === 0) return;
2199
+ let i = new Map((this.hooks.slots().get(e)?.commentElementBounds ?? []).map((e) => [e.elementId, e.bounds])), a = r.flatMap((e) => {
2200
+ let t = i.get(e);
2201
+ return t ? [t] : [];
2202
+ })[0];
2203
+ if (a) return a;
2204
+ let o = await n.getElementBoundsByIds(e, r);
2205
+ return r.flatMap((e) => {
2206
+ let t = o.find((t) => t.elementId === e);
2207
+ return t ? [t.bounds] : [];
2208
+ })[0];
2209
+ }
2210
+ scrollToTarget(e, t, n, r) {
2211
+ if (!this.hooks.presentation()) return !1;
2212
+ let i = this.hooks.slots().get(e), a = new Map((i?.commentElementBounds ?? []).map((e) => [e.elementId, e.bounds])), o = r ?? (t.anchors ?? []).flatMap((e) => {
2213
+ if (e.type !== "drawingElement" && e.type !== "textRange" || !e.elementId) return [];
2214
+ let t = a.get(e.elementId);
2215
+ return t ? [t] : [];
2216
+ })[0], s = t.anchors ?? [], c = Number.isFinite(t.x) && Number.isFinite(t.y) && (s.length === 0 || s.some((e) => e.type === "slide"));
2217
+ if (!o && !c) return !1;
2218
+ let l = o ? o.x + (c ? t.x : o.width) : t.x, u = o ? o.y + (c ? t.y : 0) : t.y, d = l / m * this.hooks.scale(), f = u / m * this.hooks.scale();
2219
+ return this.hooks.scrollPoint(e, d, f, n), !0;
2220
+ }
2221
+ async goToComment(e, t, n) {
2222
+ if (this.hooks.destroyed()) throw Error("PptxScrollViewer is destroyed");
2223
+ let r = this.hooks.presentation();
2224
+ if (!r || !Number.isInteger(e) || !Number.isInteger(t) || e < 0 || e >= r.slideCount || t < 0) return !1;
2225
+ let i = this.begin();
2226
+ if (e >= r.availableSlideCount && !r.layoutComplete && !await this.waitForSlideMetadata(r, e, i)) return !1;
2227
+ if (this.hooks.destroyed()) throw Error("PptxScrollViewer is destroyed");
2228
+ if (i !== this.generation || r !== this.hooks.presentation()) return !1;
2229
+ let a = r.getComments(e)[t];
2230
+ if (!a) return !1;
2231
+ let o = await this.resolveBounds(e, a);
2232
+ if (this.hooks.destroyed()) throw Error("PptxScrollViewer is destroyed");
2233
+ if (i !== this.generation || r !== this.hooks.presentation()) return !1;
2234
+ let s = a.anchors ?? [], c = Number.isFinite(a.x) && Number.isFinite(a.y) && (s.length === 0 || s.some((e) => e.type === "slide"));
2235
+ return !o && !c || (this.hooks.scrollToSlide(e, n), !this.scrollToTarget(e, a, n, o)) ? !1 : (this.hooks.select($(a, t, e), e), !0);
2236
+ }
2237
+ destroy() {
2238
+ this.begin();
2239
+ }
2240
+ }, yn = 12, bn;
2241
+ function xn() {
2242
+ return bn ??= import("./comment-ui-runtime-C47QoDUy.js");
2243
+ }
2244
+ var Sn = 440, Cn = 20, wn = Symbol("PptxScrollViewer.borrowedPresentation"), Tn = class e {
2245
+ _presentationOwner;
2246
+ get _pres() {
2247
+ return this._presentationOwner.current;
2248
+ }
2249
+ _borrowed;
2250
+ _opts;
2251
+ _errorRouter;
2252
+ _container;
2253
+ _shell;
2254
+ get _wrapper() {
2255
+ return this._shell.wrapper;
2256
+ }
2257
+ get _scrollHost() {
2258
+ return this._shell.scrollHost;
2259
+ }
2260
+ get _spacer() {
2261
+ return this._shell.spacer;
2262
+ }
2263
+ _mode;
2264
+ _viewport = new ye({
2265
+ options: () => this._opts,
2266
+ container: () => this._container,
2267
+ scrollHost: () => this._scrollHost
2268
+ });
2269
+ _zoom = new Ae({
2270
+ scrollHost: () => this._scrollHost,
2271
+ spacer: () => this._spacer,
2272
+ count: () => this._pres?.slideCount ?? 0,
2273
+ zoomMin: () => this._opts.zoomMin ?? .1,
2274
+ zoomMax: () => this._opts.zoomMax ?? 4,
2275
+ baseScale: () => this._baseScale(),
2276
+ fitWidthPx: () => this._viewport.fitWidth(),
2277
+ fitContentSize: () => this._pres ? {
2278
+ width: this._pres.slideWidth / m,
2279
+ height: this._pres.slideHeight / m
2280
+ } : null,
2281
+ indexAt: (e) => this._slideIndexAtOffset(e),
2282
+ offset: (e) => this._slideOffset(e),
2283
+ height: () => this._uniformSlideHeight,
2284
+ totalHeight: () => this._rangeAt(0, this._viewport.overscan()).totalHeight,
2285
+ recomputeHeights: () => this._recomputeHeights(),
2286
+ syncSpacerWidth: () => this._syncSpacerWidth(),
2287
+ padLeft: () => this._viewport.horizontalPadding().left,
2288
+ invalidateRender: () => {
2289
+ this._renderEpoch++;
2290
+ },
2291
+ preview: () => this._previewVisible(),
2292
+ scheduleSettle: () => this._scheduleSettle(),
2293
+ onScaleChange: (e) => this._opts.onScaleChange?.(e),
2294
+ relayout: () => this.relayout(),
2295
+ mountVisible: () => this._mountVisible(),
2296
+ refitOnResize: () => this._opts.refitOnResize !== !1
2297
+ });
2298
+ get _scale() {
2299
+ return this._zoom.scale;
2300
+ }
2301
+ get _scaleEstablished() {
2302
+ return this._zoom.established;
2303
+ }
2304
+ _scroller = new be({
2305
+ spacer: () => this._spacer,
2306
+ count: () => this._pres?.slideCount ?? 0,
2307
+ range: () => this._range(),
2308
+ createSlot: () => this._createSlot(),
2309
+ attachSlot: (e) => this._scrollHost.appendChild(e.wrapper),
2310
+ resetSlot: (e, t) => this._resetSlot(e, t),
2311
+ positionSlot: (e, t, n) => this._positionSlot(t, e, n),
2312
+ renderSlot: (e, t, n) => this._renderSlot(e, t, this._opts.enableMediaPlayback === !0 && this._rangeContains(this._mediaRange(), e), n),
2313
+ previewSlot: (e, t, n) => this._previewSlot(t, e, n),
2314
+ settleSlot: (e, t) => this._settleSlot(e, t),
2315
+ renderedScale: (e) => e.renderedScale,
2316
+ scale: () => this._scale,
2317
+ syncSpacerWidth: () => this._syncSpacerWidth(),
2318
+ onRange: (e) => this._emitVisibleSlideChange(e),
2319
+ onNewSlot: (e, t) => this._redrawSlotComments(e, t),
2320
+ afterMount: () => {
2321
+ this._opts.enableMediaPlayback && this._media.sync();
2322
+ },
2323
+ awaitInitialRender: (e) => e < this.availableSlideCount,
2324
+ shouldSettle: (e) => !this._opts.enableMediaPlayback || this._rangeContains(this._mediaRange(), e)
2325
+ });
2326
+ _slots = this._scroller.slots;
2327
+ _layout = new gn({
2328
+ current: () => this._pres,
2329
+ destroyed: () => this._destroyed,
2330
+ report: (e) => this._reportRenderError(e),
2331
+ reportBackground: (e) => this._errorRouter.reportBackground(e, this._opts.onLayoutComplete !== void 0),
2332
+ wakeComments: () => this._commentNavigation.wake(),
2333
+ resetComments: () => this._commentNavigation.resetLayout(),
2334
+ failComments: () => this._commentNavigation.failLayout(),
2335
+ scanComments: (e) => this._scanAvailableComments(e, !0),
2336
+ renderAvailable: (e) => {
2337
+ let t = this._opts.enableMediaPlayback ? this._mediaRange() : null;
2338
+ for (let [n, r] of this._slots) n >= e.availableSlideCount || r.renderedSlide === n || this._renderSlot(n, r, !!t && this._rangeContains(t, n));
2339
+ },
2340
+ emitVisible: () => {
2341
+ this._scroller.lastRange && this._emitVisibleSlideChange(this._scroller.lastRange);
2342
+ }
2343
+ });
2344
+ _renderHooks = {
2345
+ slots: () => this._slots,
2346
+ epoch: () => this._renderEpoch,
2347
+ scale: () => this._scale,
2348
+ slotIndex: (e) => e.renderedSlide,
2349
+ token: (e) => e.renderGeneration,
2350
+ nextToken: (e) => ++e.renderGeneration,
2351
+ wantRuns: (e) => !!(this._opts.enableTextSelection && e.textLayer) || this._findActive,
2352
+ reportError: (e) => this._reportRenderError(e)
2353
+ };
2354
+ _bitmap = new Se({
2355
+ ...this._renderHooks,
2356
+ inFlight: () => this._scroller.inFlight,
2357
+ destroyed: () => this._destroyed,
2358
+ width: () => this._slideWidthPx(),
2359
+ dpr: () => this._viewport.dpr(),
2360
+ canRetry: (e) => !(this._opts.enableMediaPlayback && e.mediaInteractive),
2361
+ render: (e, t, n, r, i) => Q(this._pres, t, e, "worker", {
2362
+ width: n,
2363
+ dpr: r,
2364
+ imageResources: this._opts.imageResources,
2365
+ onTextRun: i
2366
+ }),
2367
+ commitBitmap: (e, t, n, r, i, a) => {
2368
+ let o = {
2369
+ cssWidth: Math.round(a),
2370
+ cssHeight: Math.round(this._slideHeightPx())
2371
+ };
2372
+ return this._opts.enableMediaPlayback ? n.commitBitmapTo2d(r, i, o) : n.commitBitmap(r, i, o);
2373
+ },
2374
+ commitRuns: (e, t, n, r, i) => this._commitRenderedRuns(e, t, n, r, i, !0)
2375
+ });
2376
+ _main = new Ce({
2377
+ ...this._renderHooks,
2378
+ render: (e, t, n, r, i, a) => Q(this._pres, t, e, "main", {
2379
+ width: n,
2380
+ dpr: r,
2381
+ ...a ? {} : { imageResources: this._opts.imageResources },
2382
+ onTextRun: i
2383
+ }),
2384
+ commitRuns: (e, t, n, r, i, a, o) => this._commitRenderedRuns(e, t, n, i, a, o),
2385
+ shadow: () => this._pageShadow
2386
+ });
2387
+ _media = new _n({
2388
+ presentation: () => this._pres,
2389
+ slots: () => this._slots,
2390
+ epoch: () => this._renderEpoch,
2391
+ scale: () => this._scale,
2392
+ dpr: () => this._viewport.dpr(),
2393
+ width: () => this._slideWidthPx(),
2394
+ height: () => this._slideHeightPx(),
2395
+ imageResources: () => this._opts.imageResources,
2396
+ textSelection: () => this._opts.enableTextSelection === !0,
2397
+ findActive: () => this._findActive,
2398
+ mediaEnabled: () => this._opts.enableMediaPlayback === !0,
2399
+ mediaRange: () => this._mediaRange(),
2400
+ rangeContains: (e, t) => this._rangeContains(e, t),
2401
+ shadow: () => this._pageShadow,
2402
+ hyperlinkHandler: () => this._hyperlinkHandler(),
2403
+ refreshFindRuns: (e, t) => this._highlights.refreshRuns(e, t),
2404
+ redrawHighlights: (e, t) => this._highlights.redrawSlot(e, t),
2405
+ commitComments: (e, t) => this._commitSlotComments(e, t),
2406
+ clearTextPreview: (e) => this._clearTextLayerPreview(e),
2407
+ reportError: (e) => this._reportRenderError(e)
2408
+ });
2409
+ _commentNavigation = new vn({
2410
+ presentation: () => this._pres,
2411
+ destroyed: () => this._destroyed,
2412
+ slots: () => this._slots,
2413
+ scale: () => this._scale,
2414
+ scrollPoint: (e, t, n, r) => this._navigation.scrollToPoint(e, t, n, r),
2415
+ scrollToSlide: (e, t) => this.scrollToSlide(e, t),
2416
+ select: (e, t) => {
2417
+ this._activeCommentId = e, this._activeCommentSlide = t, this._selection.clearElementContext();
2418
+ for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2419
+ this._selection.emitChange();
2420
+ },
2421
+ ownBackground: (e) => this._errorRouter.ownBackgroundLifecycle(e)
2422
+ });
2423
+ _navigation = new Te({
2424
+ host: () => this._scrollHost,
2425
+ spacer: () => this._spacer,
2426
+ count: () => this.slideCount,
2427
+ established: () => this._scaleEstablished,
2428
+ offset: (e) => this._slideOffset(e),
2429
+ height: () => this._uniformSlideHeight,
2430
+ indexAt: (e) => this._slideIndexAtOffset(e),
2431
+ totalHeight: () => this._rangeAt(0, this._viewport.overscan()).totalHeight,
2432
+ width: () => this._slideWidthPx(),
2433
+ padLeft: () => this._viewport.horizontalPadding().left,
2434
+ marginOrigin: () => this._commentMargin.originPx,
2435
+ mount: () => this._mountVisible()
2436
+ });
2437
+ _selection = new De({
2438
+ wrapper: () => this._wrapper,
2439
+ scrollHost: () => this._scrollHost,
2440
+ slots: () => this._slots,
2441
+ resource: () => this._pres,
2442
+ destroyed: () => this._destroyed,
2443
+ textSelectionEnabled: () => this._opts.enableTextSelection === !0,
2444
+ elementSelectionEnabled: () => this._opts.enableElementSelection === !0,
2445
+ textSelected: () => Z(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null) !== null,
2446
+ getContext: () => this.getSelectionContext(),
2447
+ hitTest: (e, t, n, r, i) => e.getElementContextAt(t, {
2448
+ x: n * e.slideWidth,
2449
+ y: r * e.slideHeight
2450
+ }, {
2451
+ tolerance: this._elementHitTolerance / i * e.slideWidth,
2452
+ maxTextCharacters: q
2453
+ }),
2454
+ outline: (e, t, n) => n.slideIndex === t ? {
2455
+ x: n.bounds.x / e.slideWidth,
2456
+ y: n.bounds.y / e.slideHeight,
2457
+ width: n.bounds.width / e.slideWidth,
2458
+ height: n.bounds.height / e.slideHeight,
2459
+ rotation: n.bounds.rotation
2460
+ } : null,
2461
+ onChange: (e) => this._opts.onSelectionContextChange?.(e),
2462
+ onContextMenu: (e, t) => this._opts.onContextMenu?.({
2463
+ originalEvent: e,
2464
+ getContext: t
2465
+ }),
2466
+ reportError: (e) => this._reportRenderError(e)
2467
+ });
2468
+ _uniformSlideHeight = 0;
2469
+ _visibleEvents = new Oe((e, t, n) => this._opts.onVisibleSlideChange?.(e, t, n));
2470
+ _loader = new _e({
2471
+ name: () => "PptxScrollViewer",
2472
+ borrowed: () => this._borrowed,
2473
+ borrowedMessage: () => "PptxScrollViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.",
2474
+ destroyed: () => this._destroyed,
2475
+ owner: () => this._presentationOwner,
2476
+ acquire: (e) => X.load(e, {
2477
+ password: this._opts.password,
2478
+ useGoogleFonts: this._opts.useGoogleFonts,
2479
+ cjkFallback: this._opts.cjkFallback,
2480
+ maxZipEntryBytes: this._opts.maxZipEntryBytes,
2481
+ resourceLimits: this._opts.resourceLimits,
2482
+ debug: this._opts.debug,
2483
+ onResourceMetrics: this._opts.onResourceMetrics,
2484
+ workerTimeoutMs: this._opts.workerTimeoutMs,
2485
+ wasmUrl: this._opts.wasmUrl,
2486
+ math: this._opts.math,
2487
+ threeD: this._opts.threeD,
2488
+ regionMap: this._opts.regionMap,
2489
+ chartEx: this._opts.chartEx,
2490
+ tiff: this._opts.tiff,
2491
+ mode: this._mode,
2492
+ ...this._opts.legacyPpt === void 0 ? void 0 : { legacyPpt: this._opts.legacyPpt },
2493
+ progressiveLayout: this._opts.progressiveLayout,
2494
+ onLayoutProgress: this._opts.onLayoutProgress,
2495
+ onLayoutPartial: this._opts.onLayoutPartial,
2496
+ onLayoutComplete: this._opts.onLayoutComplete
2497
+ }),
2498
+ beforeReplace: (e) => {
2499
+ if (this._selection.invalidateElementContext(!1), this._invalidateFind(), this._findActive = !1, this._activeCommentId = null, this._activeCommentSlide = null, this._hasComments = !1, this._commentScanFrontier = 0, this._commentNavigation.begin(), this._layout.unbind(), e) {
2500
+ for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
2501
+ this._visibleEvents.resetIndex();
2502
+ }
2503
+ },
2504
+ afterReplace: (e) => {
2505
+ this._invalidateFind(), this._findActive = !1, this._activeCommentId = null, this._activeCommentSlide = null, this._hasComments = !1, this._commentScanFrontier = 0, this._scanAvailableComments(e, !1), this._layout.bind(e);
2506
+ },
2507
+ mountOpeningWindow: async () => {
2508
+ let e = [];
2509
+ this._relayout(e), await Promise.all(e);
2510
+ },
2511
+ selectionChanged: () => this._selection.emitChange()
2512
+ });
2513
+ _activeCommentId = null;
2514
+ _activeCommentSlide = null;
2515
+ _commentUi = null;
2516
+ _hasComments = !1;
2517
+ _commentMargin = new we({
2518
+ container: () => this._container,
2519
+ scrollHost: () => this._scrollHost,
2520
+ spacer: () => this._spacer,
2521
+ enabled: () => this._commentsEnabled(),
2522
+ cards: () => this._commentsOptions()?.cards !== !1,
2523
+ hasDisplayableComments: () => this._hasComments,
2524
+ requestedSide: () => this._commentsOptions()?.side,
2525
+ zoom: () => this._scaleEstablished ? this._scale : 1,
2526
+ gapPx: yn,
2527
+ widthPx: Sn,
2528
+ fontSizePx: Cn
2529
+ });
2530
+ _layers = new Me({
2531
+ markerLayer: (e) => e.commentMarkerLayer,
2532
+ syncMargin: (e) => this._commentMargin.syncMargin(e),
2533
+ marginSide: () => this._commentMargin.side(),
2534
+ marginExtent: () => this._commentMargin.extent(),
2535
+ commentsEnabled: () => this._commentsEnabled(),
2536
+ previewMargin: (e, t) => this._commentUi?.previewReadOnlyCommentMargin(e, t),
2537
+ disposeMargin: (e) => {
2538
+ this._commentUi?.disposeReadOnlyCommentMargin(e), this._commentUi || e.replaceChildren();
2539
+ },
2540
+ disposeDecoration: (e) => {
2541
+ this._commentUi?.disposeReadOnlyCommentDecoration(e), this._commentUi || e.replaceChildren();
2542
+ },
2543
+ redrawOutline: (e, t) => this._selection.redrawOutlineForSlot(e, t),
2544
+ markerRatio: (e) => Math.round(e * 1e6) / 1e6,
2545
+ resetMarkerTransform: () => !1,
2546
+ resetDecorationVisibility: () => !0
2547
+ });
2548
+ _commentOverlay = new je({
2549
+ slots: () => this._slots,
2550
+ scale: () => this._scale,
2551
+ destroyed: () => this._destroyed,
2552
+ ownerWindow: () => this._wrapper.ownerDocument.defaultView,
2553
+ width: () => this._slideWidthPx(),
2554
+ height: () => this._slideHeightPx(),
2555
+ side: () => this._commentMargin.side(),
2556
+ marginExtent: () => this._commentMargin.extent(),
2557
+ connectorOptions: () => this._commentsOptions()?.connectors,
2558
+ runtime: () => this._commentUi,
2559
+ redrawComments: (e, t) => this._redrawSlotComments(e, t)
2560
+ });
2561
+ _commentScanFrontier = 0;
2562
+ _elementHitTolerance;
2563
+ _destroyed = !1;
2564
+ get _renderEpoch() {
2565
+ return this._scroller.renderEpoch;
2566
+ }
2567
+ set _renderEpoch(e) {
2568
+ this._scroller.renderEpoch = e;
2569
+ }
2570
+ _pageShadow;
2571
+ _find = new ft(() => this.slideCount, (e) => this._collectSlideRuns(e));
2572
+ _findGeneration = 0;
2573
+ _findActive = !1;
2574
+ _highlights = new ge({
2575
+ slots: () => this._slots,
2576
+ active: () => this._findActive,
2577
+ runs: (e) => this._find.slideRuns(e),
2578
+ setRuns: (e, t) => this._find.setSlideRuns(e, t),
2579
+ paint: (e, t, n, r) => R(t.highlightLayer, n, this._find.slideHighlights(e), this._slideWidthPx(), this._slideHeightPx(), r, this._opts.findHighlightColors),
2580
+ reveal: (e) => this.scrollToSlide(e),
2581
+ unitOf: (e) => e.slide
2582
+ });
2583
+ static fromPresentation(t, n, r = {}) {
2584
+ return new e(t, {
2585
+ ...r,
2586
+ [wn]: n
2587
+ });
2588
+ }
2589
+ constructor(e, t = {}) {
2590
+ 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.");
2591
+ this._container = e, this._opts = t, this._errorRouter = new Ge("PptxScrollViewer", t.onError);
2592
+ let n = t.elementHitTolerance ?? 6;
2593
+ if (!Number.isFinite(n) || n < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
2594
+ this._elementHitTolerance = n, this._pageShadow = t.pageShadow ?? "0 1px 3px rgba(0,0,0,0.2)";
2595
+ let r = t[wn];
2596
+ this._borrowed = r !== void 0, r ? (this._presentationOwner = new P("PptxScrollViewer", r, !1), this._mode = F("PptxScrollViewer", t.mode, r), this._scanAvailableComments(r, !1)) : (this._presentationOwner = new P("PptxScrollViewer"), this._mode = F("PptxScrollViewer", t.mode, void 0)), this._shell = new Ne(e, {
2597
+ background: t.background,
2598
+ comments: !!t.comments,
2599
+ onScroll: () => this._onScroll(),
2600
+ onOutsideComment: () => {
2601
+ if (this._activeCommentId !== null) {
2602
+ this._activeCommentId = null, this._activeCommentSlide = null;
2603
+ for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2604
+ this._selection.emitChange();
2605
+ }
2606
+ }
2607
+ }), this._commentsEnabled() && xn().then((e) => {
2608
+ if (!this._destroyed) {
2609
+ this._commentUi = e;
2610
+ for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2611
+ }
2612
+ }).catch((e) => this._reportRenderError(e)), this._selection.bind(!!t.onSelectionContextChange, !!t.onContextMenu), this._zoom.bind(this._container, this._scrollHost, this._opts.enableZoom !== !1), this._borrowed && (this._layout.bind(r), this.relayout());
2613
+ }
2614
+ async load(e) {
2615
+ await this._loader.load(e);
2616
+ }
2617
+ get slideCount() {
2618
+ return this._pres?.slideCount ?? 0;
2619
+ }
2620
+ get availableSlideCount() {
2621
+ return this._pres?.availableSlideCount ?? this.slideCount;
2622
+ }
2623
+ get layoutComplete() {
2624
+ return this._pres?.layoutComplete ?? !0;
2625
+ }
2626
+ async waitUntilLayoutComplete() {
2627
+ await this._errorRouter.ownBackgroundLifecycle(async () => {
2628
+ await this._pres?.waitUntilLayoutComplete?.();
2629
+ });
2630
+ }
2631
+ _slideWidthPx() {
2632
+ return this._pres.slideWidth / m * this._scale;
2633
+ }
2634
+ _slideHeightPx() {
2635
+ return this._pres.slideHeight / m * this._scale;
2636
+ }
2637
+ _commentsEnabled() {
2638
+ return this._opts.comments === !0 || typeof this._opts.comments == "object";
2639
+ }
2640
+ _commentsOptions() {
2641
+ return typeof this._opts.comments == "object" ? this._opts.comments : void 0;
2642
+ }
2643
+ _scanAvailableComments(e, t) {
2644
+ if (!this._commentsEnabled() || this._hasComments) return;
2645
+ let n = this._commentsOptions()?.includeResolved === !0, r = Math.min(e.availableSlideCount, e.slideCount);
2646
+ for (let i = this._commentScanFrontier; i < r; i++) if (e.getComments(i).some((e) => n || e.status !== "resolved" && e.status !== "closed")) {
2647
+ this._commentScanFrontier = r, this._hasComments = !0, t && this._refreshDiscoveredComments();
2648
+ return;
2649
+ }
2650
+ this._commentScanFrontier = Math.max(this._commentScanFrontier, r);
2651
+ }
2652
+ _refreshDiscoveredComments() {
2653
+ this._syncSpacerWidth();
2654
+ for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2655
+ }
2656
+ _baseScale() {
2657
+ if (!this._pres || this._pres.slideCount === 0) return 0;
2658
+ let e = this._viewport.fitWidth(), t = this._pres.slideWidth / m;
2659
+ return e <= 0 || t <= 0 ? 0 : e / t;
2660
+ }
2661
+ relayout() {
2662
+ this._relayout();
2663
+ }
2664
+ _relayout(e) {
2665
+ this._pres && (!this._scaleEstablished && !this._zoom.establishBase() || (this._recomputeHeights(), this._syncSpacer(), this._mountVisible(e)));
2666
+ }
2667
+ _recomputeHeights() {
2668
+ this._uniformSlideHeight = this._slideHeightPx();
2669
+ }
2670
+ _mediaOverscan() {
2671
+ return this._opts.mediaOverscan ?? 1;
2672
+ }
2673
+ _slideOffset(e) {
2674
+ return this._viewport.verticalPadding().leading + e * (this._uniformSlideHeight + this._viewport.gap());
2675
+ }
2676
+ _slideIndexAtOffset(e) {
2677
+ return me(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._viewport.gap(), e, 0, 0, this._viewport.verticalPadding()).topIndex;
2678
+ }
2679
+ _rangeAt(e, t) {
2680
+ return me(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._viewport.gap(), e, this._scrollHost.clientHeight, t, this._viewport.verticalPadding());
2681
+ }
2682
+ _range() {
2683
+ return this._rangeAt(this._scrollHost.scrollTop, this._viewport.overscan());
2684
+ }
2685
+ _mediaRange() {
2686
+ return this._rangeAt(this._scrollHost.scrollTop, this._mediaOverscan());
2687
+ }
2688
+ _rangeContains(e, t) {
2689
+ return t >= e.start && t <= e.end;
2690
+ }
2691
+ _syncSpacer() {
2692
+ this._scroller.syncSpacer();
2693
+ }
2694
+ _syncSpacerWidth() {
2695
+ let { left: e, right: t } = this._viewport.horizontalPadding();
2696
+ this._commentMargin.syncSpacerWidth(this._slideWidthPx(), e, t);
2697
+ }
2698
+ _onScroll() {
2699
+ !this._pres || !this._scaleEstablished || this._mountVisible(void 0, !1);
2700
+ }
2701
+ _mountVisible(e, t = !0) {
2702
+ this._scroller.mount(e, t);
2703
+ }
2704
+ _createSlot() {
2705
+ let { wrapper: e, canvas: t, textLayer: n, highlightLayer: r } = Ee(this._scrollHost, this._opts.enableTextSelection === !0, this._pageShadow), i = fn(e), { markerLayer: a, margin: o, decorationLayer: s } = ke(e, this._commentsEnabled(), this._commentsOptions()?.cards !== !1, this._commentsOptions()?.connectors !== void 0, (e) => this._commentMargin.syncMargin(e)), c = Xe(e, this._opts.enableElementSelection === !0);
2706
+ return this._scrollHost.appendChild(e), {
2707
+ wrapper: e,
2708
+ canvas: t,
2709
+ textLayer: n,
2710
+ highlightLayer: r,
2711
+ elementLayer: c,
2712
+ loadingIndicator: i,
2713
+ commentMarkerLayer: a,
2714
+ commentMargin: o,
2715
+ commentDecorationLayer: s,
2716
+ commentElementBounds: Object.freeze([]),
2717
+ commentGeometry: null,
2718
+ commentAnchorSlide: -1,
2719
+ commentAnchorGeneration: 0,
2720
+ renderedSlide: -1,
2721
+ renderedScale: -1,
2722
+ dispatcher: new N(t, this._mode === "worker" && !this._opts.enableMediaPlayback),
2723
+ presentationHandle: null,
2724
+ mediaInteractive: !1,
2725
+ renderGeneration: 0,
2726
+ presentationGeneration: 0
2727
+ };
2728
+ }
2729
+ _recycleSlot(e, t) {
2730
+ this._scroller.recycleSlot(e, t);
2731
+ }
2732
+ _resetSlot(e, t) {
2733
+ t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new N(t.canvas, this._mode === "worker" && !this._opts.enableMediaPlayback)), this._layers.reset(t), t.loadingIndicator.setLoading(!1), t.commentElementBounds = Object.freeze([]), t.commentGeometry = null, t.commentAnchorSlide = -1, t.commentAnchorGeneration++, t.canvas.style.height = "", t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove();
2734
+ }
2735
+ _positionSlot(e, t, n) {
2736
+ e.wrapper.dataset.slideIndex = String(t), this._layers.position(t, e, this._slideOffset(t), this._slideWidthPx(), this._slideHeightPx(), this._scrollHost.clientWidth, this._viewport.horizontalPadding().left);
2737
+ }
2738
+ _renderSlot(e, t, n = !1, r = !0) {
2739
+ if (!this._pres || t.renderedSlide === e) return null;
2740
+ if (e >= this.availableSlideCount && !this.layoutComplete) return t.renderedSlide = -1, t.mediaInteractive = !1, t.loadingIndicator.setLoading(!0), null;
2741
+ t.renderedSlide = e;
2742
+ let i = ++t.renderGeneration;
2743
+ t.loadingIndicator.setLoading(e >= this.availableSlideCount && !this.layoutComplete);
2744
+ let a = this._viewport.dpr(), o = this._slideWidthPx(), s = this._renderEpoch, c = this._scale, l = t.dispatcher, u = l.begin();
2745
+ return this._opts.enableMediaPlayback && n ? (t.mediaInteractive = !0, this._trackSlotLoading(e, t, i, this._media.renderInteractive(e, t, o, a, c, s, r))) : (t.mediaInteractive = !1, this._mode === "worker" ? this._trackSlotLoading(e, t, i, this._renderSlotBitmap(e, t, o, a, c, i, l, u, r)) : this._trackSlotLoading(e, t, i, this._main.render(e, t, o, a, i, l, u, r)));
2746
+ }
2747
+ async _trackSlotLoading(e, t, n, r) {
2748
+ try {
2749
+ await r;
2750
+ } finally {
2751
+ n === t.renderGeneration && this._slots.get(e) === t && t.renderedSlide === e && t.loadingIndicator.setLoading(!1);
2752
+ }
2753
+ }
2754
+ _emitVisibleSlideChange(e) {
2755
+ this._pres && this._visibleEvents.publish(e, this._pres.slideCount, this.layoutComplete);
2756
+ }
2757
+ _reportRenderError(e) {
2758
+ this._errorRouter.report(e);
2759
+ }
2760
+ _commitRenderedRuns(e, t, n, r, i, a) {
2761
+ t.textLayer && (a && this._clearTextLayerPreview(t.textLayer), this._opts.enableTextSelection && L(t.textLayer, n, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), i && this._highlights.refreshRuns(e, n), this._commitSlotComments(e, t), this._highlights.redrawSlot(e, t);
2762
+ }
2763
+ _renderSlotBitmap(e, t, n, r, i, a = ++t.renderGeneration, o = t.dispatcher, s = o.begin(), c = !0) {
2764
+ return this._bitmap.render(e, t, n, r, i, a, o, s, c);
2765
+ }
2766
+ setScale(e) {
2767
+ this._zoom.setScale(e);
2768
+ }
2769
+ getScale() {
2770
+ return this._zoom.getScale();
2771
+ }
2772
+ zoomIn() {
2773
+ this._zoom.zoomIn();
2774
+ }
2775
+ zoomOut() {
2776
+ this._zoom.zoomOut();
2777
+ }
2778
+ fitWidth() {
2779
+ this._zoom.fit("width");
2780
+ }
2781
+ fitPage() {
2782
+ this._zoom.fit("page");
2783
+ }
2784
+ _previewVisible() {
2785
+ this._scroller.preview();
2786
+ }
2787
+ _previewSlot(e, t, n) {
2788
+ this._positionSlot(e, t, n), this._layers.preview(e, this._slideWidthPx(), this._slideHeightPx(), this._scale);
2789
+ }
2790
+ _clearTextLayerPreview(e) {
2791
+ xe(e);
2792
+ }
2793
+ _scheduleSettle() {
2794
+ this._scroller.scheduleSettle(150);
2795
+ }
2796
+ _settleSlot(e, t) {
2797
+ if (!this._pres) return;
2798
+ let n = this._viewport.dpr(), r = this._slideWidthPx(), i = this._scale, a = this._renderEpoch;
2799
+ if (this._opts.enableMediaPlayback && t.mediaInteractive) {
2800
+ this._media.settleInteractive(e, t, r, n, i, a);
2801
+ return;
2802
+ }
2803
+ if (!this._opts.enableMediaPlayback) {
2804
+ if (this._mode === "worker") {
2805
+ this._renderSlotBitmap(e, t, r, n, i);
2806
+ return;
2807
+ }
2808
+ this._main.settle(e, t, r, n);
2809
+ }
2810
+ }
2811
+ scrollToSlide(e, t) {
2812
+ this._navigation.scrollToUnit(e, t);
2813
+ }
2814
+ async goToComment(e, t, n) {
2815
+ return this._commentNavigation.goToComment(e, t, n);
2816
+ }
2817
+ async findText(e, t = {}) {
2818
+ let n = this._pres;
2819
+ if (!n) return [];
2820
+ let r = ++this._findGeneration;
2821
+ if (this._findActive = e.length > 0, e.length === 0) return this._find.invalidate(), this._highlights.redrawAll(), [];
2822
+ if (n.layoutComplete || await this._errorRouter.ownBackgroundLifecycle(() => n.waitUntilLayoutComplete()), this._destroyed || r !== this._findGeneration || n !== this._pres) return [];
2823
+ let i = await this._errorRouter.ownAwaitable(() => this._find.find(e, t));
2824
+ return this._destroyed || r !== this._findGeneration || n !== this._pres ? [] : (this._highlights.redrawAll(), i);
2825
+ }
2826
+ async findNext() {
2827
+ return this._highlights.activate(this._find.next());
2828
+ }
2829
+ async findPrev() {
2830
+ return this._highlights.activate(this._find.prev());
2831
+ }
2832
+ clearFind() {
2833
+ this._findActive = !1, this._invalidateFind(), this._highlights.redrawAll();
2834
+ }
2835
+ _invalidateFind() {
2836
+ this._findGeneration++, this._find.invalidate();
2837
+ }
2838
+ async _collectSlideRuns(e) {
2839
+ return this._pres ? this._pres.collectSlideRuns(e, this._slideWidthPx()) : [];
2840
+ }
2841
+ _redrawSlotComments(e, t) {
2842
+ if (!this._pres || !t.commentMarkerLayer) return;
2843
+ this._commentMargin.syncMargin(t.commentMargin);
2844
+ let n = this._commentUi;
2845
+ if (!n) {
2846
+ t.commentMarkerLayer.replaceChildren(), t.commentMargin?.replaceChildren(), t.commentDecorationLayer?.replaceChildren(), t.commentGeometry = null;
2847
+ return;
2848
+ }
2849
+ t.commentGeometry = n.buildPptxCommentMargin(t.commentMarkerLayer, t.commentMargin, this._pres.getComments(e), t.commentElementBounds, e, this._pres.slideWidth, this._pres.slideHeight, this._activeCommentId, (t, n) => {
2850
+ let r = n ? t : this._activeCommentId === t ? null : this._activeCommentId;
2851
+ if (r !== this._activeCommentId) {
2852
+ this._activeCommentId = r, this._activeCommentSlide = r ? e : null, this._selection.clearElementContext();
2853
+ for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2854
+ this._selection.emitChange();
2855
+ }
2856
+ }, this._commentMargin.zoom(), Sn, this._commentsOptions()?.markers !== !1, this._commentsOptions()?.includeResolved === !0, t.commentDecorationLayer ? () => this._commentOverlay.schedule(e, t, !1) : void 0, t.commentDecorationLayer ? () => this._commentOverlay.schedule(e, t, !0) : void 0), this._commentOverlay.drawConnectors(e, t);
2857
+ }
2858
+ _commitSlotComments(e, t) {
2859
+ this._ensureSlotCommentAnchors(e, t), this._redrawSlotComments(e, t), t.commentMarkerLayer && (t.commentMarkerLayer.style.visibility = ""), t.commentMargin && (t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (t.commentDecorationLayer.style.visibility = "");
2860
+ }
2861
+ _ensureSlotCommentAnchors(e, t) {
2862
+ let n = this._pres;
2863
+ if (!n || t.commentAnchorSlide === e) return;
2864
+ t.commentAnchorSlide = e, t.commentElementBounds = Object.freeze([]);
2865
+ let r = [...new Set(n.getComments(e).flatMap((e) => (e.anchors ?? []).flatMap((e) => (e.type === "drawingElement" || e.type === "textRange") && e.elementId ? [e.elementId] : [])))];
2866
+ if (r.length === 0) return;
2867
+ let i = ++t.commentAnchorGeneration;
2868
+ n.getElementBoundsByIds(e, r).then((r) => {
2869
+ if (this._destroyed || i !== t.commentAnchorGeneration || n !== this._pres || this._slots.get(e) !== t || t.commentAnchorSlide !== e) return;
2870
+ t.commentElementBounds = r, this._redrawSlotComments(e, t);
2871
+ let a = n.getComments(e).find((t, n) => $(t, n, e) === this._activeCommentId);
2872
+ a && this._commentNavigation.scrollToTarget(e, a);
2873
+ }).catch((e) => {
2874
+ !this._destroyed && i === t.commentAnchorGeneration && this._reportRenderError(e);
2875
+ });
2876
+ }
2877
+ _hyperlinkHandler() {
2878
+ if (this._opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
2879
+ }
2880
+ _onHyperlinkClick(e) {
2881
+ let t = this._resolveInternalSlideIndex(e);
2882
+ if (this._opts.onHyperlinkClick) {
2883
+ this._opts.onHyperlinkClick(t);
2884
+ return;
2885
+ }
2886
+ if (t.kind === "external") {
2887
+ D(t.url);
2888
+ return;
2889
+ }
2890
+ t.slideIndex !== void 0 && this.scrollToSlide(t.slideIndex);
2891
+ }
2892
+ _resolveInternalSlideIndex(e) {
2893
+ if (e.kind !== "internal" || e.slideIndex !== void 0) return e;
2894
+ let t = this._pres?.resolveInternalTarget(e.ref, this._range().topIndex);
2895
+ return t === void 0 ? e : {
2896
+ ...e,
2897
+ slideIndex: t
2898
+ };
2899
+ }
2900
+ get topVisibleSlide() {
2901
+ return this._scroller.lastRange?.topIndex ?? 0;
2902
+ }
2903
+ async getResourceMetrics() {
2904
+ if (!this._pres) throw Error("Presentation not loaded");
2905
+ return await this._pres.getResourceMetrics();
2906
+ }
2907
+ getSelectionContext(e = {}) {
2908
+ if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
2909
+ if (this._pres && this._activeCommentId !== null && this._activeCommentSlide !== null) {
2910
+ let t = this._pres.getComments(this._activeCommentSlide), n = t.findIndex((e, t) => $(e, t, this._activeCommentSlide) === this._activeCommentId), r = t[n];
2911
+ if (r && n >= 0) return un(r, this._activeCommentSlide, n, this._activeCommentId, e);
2912
+ }
2913
+ return (this._opts.enableTextSelection ? Z(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._selection.elementContext ? rn(this._selection.elementContext, e.maxTextCharacters) : null);
2914
+ }
2915
+ destroy() {
2916
+ this._destroyed || (this._destroyed = !0, this._commentNavigation.begin(), this._errorRouter.close(), this._invalidateFind(), this._findActive = !1, this._layout.unbind(), this._selection.destroy(), this._media.destroy(), this._commentNavigation.destroy(), this._highlights.destroy(), this._commentOverlay.destroy(), this._selection.clearElementContext(), this._scroller.destroy(), this._zoom.destroy(), this._commentMargin.destroy(), this._presentationOwner.close(), this._shell.destroy());
2917
+ }
2918
+ }, En = /* @__PURE__ */ e({
2919
+ OoxmlDecodedImageLimitError: () => Ie,
2920
+ OoxmlError: () => h,
2921
+ OoxmlResourceLimitError: () => g,
2922
+ PptxPresentation: () => X,
2923
+ PptxScrollViewer: () => Tn,
2924
+ PptxViewer: () => hn,
2925
+ TiffDecodeError: () => Re,
2926
+ autoResize: () => ze,
2927
+ buildPptxHighlightLayer: () => R,
2928
+ buildPptxTextLayer: () => L,
2929
+ isOoxmlDecodedImageLimitError: () => M,
2930
+ isTiffDecodeError: () => Le,
2931
+ openExternalHyperlink: () => D,
2932
+ readPptxTextSelectionContext: () => Z,
2933
+ renderSlide: () => o
2934
+ });
2935
+ //#endregion
2936
+ export { Z as a, R as c, hn as i, L as l, Tn as n, X as o, $ as r, K as s, En as t };