@silurus/ooxml 0.76.2 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -32
- package/dist/{canvas-viewer-mechanics-CwVSOYke.js → canvas-viewer-mechanics-DTkBvITv.js} +318 -152
- package/dist/{document-pull-client-B-3_7_YS.js → document-pull-client-iWr8-S7P.js} +2106 -2028
- package/dist/{docx-C6B98B4-.js → docx-B1gYS6eU.js} +612 -191
- package/dist/docx.mjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/node.mjs +5 -5
- package/dist/{pptx-CKAk5e-J.js → pptx-CQjtK_o7.js} +646 -258
- package/dist/pptx.mjs +4 -4
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/{render-CLcpSi0m.js → render-Ca80nlG5.js} +1 -1
- package/dist/{render-worker-host-Bkf1jUcW.js → render-worker-host-BozYMmxO.js} +1 -1
- package/dist/render-worker-host-C96AiK8e.js +27 -0
- package/dist/{render-worker-host-CKOmXdyr.js → render-worker-host-EHG5j8FK.js} +1 -1
- package/dist/{session-B4Y54cbT.js → session-KvKxQAeL.js} +1 -1
- package/dist/{slide-pull-client-WCuYCjio.js → slide-pull-client-BXb67StB.js} +15 -11
- package/dist/types/docx.d.ts +129 -28
- package/dist/types/index.d.ts +400 -86
- package/dist/types/node.d.ts +35 -20
- package/dist/types/pptx.d.ts +136 -10
- package/dist/types/xlsx.d.ts +163 -54
- package/dist/{xlsx-EykJ9tPV.js → xlsx-RLCmd1Bm.js} +1943 -1108
- package/dist/xlsx.mjs +4 -4
- package/package.json +1 -1
- package/dist/render-worker-host-Dpv-nKHY.js +0 -27
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } from "./slide-pull-client-
|
|
2
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } from "./slide-pull-client-BXb67StB.js";
|
|
3
3
|
import { B as u, Et as d, G as f, It as p, Lt as m, R as h, a as g, at as _, gt as v, hn as y, ht as b, in as x, it as S, kt as C, mn as w, q as T, z as ee } from "./line-metrics-BdCACYlq.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
4
|
+
import { C as te, E as ne, S as re, T as ie, _ as E, a as D, b as ae, c as O, d as oe, f as se, g as ce, h as le, i as k, l as A, m as ue, n as de, o as fe, p as pe, r as me, s as he, t as ge, v as j, w as _e, x as ve, y as M } from "./canvas-viewer-mechanics-DTkBvITv.js";
|
|
5
|
+
import { a as ye, i as be, n as xe, t as Se } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
6
|
+
import { n as Ce } from "./resource-measurement-E_S_iau4.js";
|
|
7
|
+
import { n as we, r as N, t as Te } from "./visible-index-CgyJLAS_.js";
|
|
8
|
+
import { n as Ee, r as P, t as F } from "./highlight-rect-CAkCWJ37.js";
|
|
9
9
|
//#region packages/core/src/nav/internal-target.ts
|
|
10
|
-
function
|
|
10
|
+
function De(e, t) {
|
|
11
11
|
let n = t.startsWith("/") ? [] : e.split("/").filter((e) => e !== "");
|
|
12
12
|
for (let e of t.split("/")) if (e === "..") n.pop();
|
|
13
13
|
else if (e === "." || e === "") continue;
|
|
14
14
|
else n.push(e);
|
|
15
15
|
return n.join("/");
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function Oe(e) {
|
|
18
18
|
let t = /[?&]jump=([a-zA-Z]+)/.exec(e);
|
|
19
19
|
if (!t) return null;
|
|
20
20
|
let n = t[1].toLowerCase();
|
|
21
21
|
return n === "firstslide" || n === "lastslide" || n === "nextslide" || n === "previousslide" ? n : null;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function ke(e, t, n) {
|
|
24
24
|
if (!(n <= 0)) switch (e) {
|
|
25
25
|
case "firstslide": return 0;
|
|
26
26
|
case "lastslide": return n - 1;
|
|
@@ -30,37 +30,40 @@ function De(e, t, n) {
|
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region packages/pptx/src/text-layer.ts
|
|
33
|
-
function
|
|
34
|
-
e.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
function I(e, t, n) {
|
|
34
|
+
e.dataset ? n === void 0 ? delete e.dataset[t] : e.dataset[t] = n : n !== void 0 && e.setAttribute?.(`data-${t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}`, n);
|
|
35
|
+
}
|
|
36
|
+
function L(e, t, n, r, i, a) {
|
|
37
|
+
e.innerHTML = "", I(e, "ooxmlSelectionSurface", "pptx"), I(e, "slideIndex", a === void 0 ? void 0 : String(a));
|
|
38
|
+
let o = /* @__PURE__ */ new Map(), s = e.ownerDocument ?? document;
|
|
39
|
+
for (let [a, c] of t.entries()) {
|
|
40
|
+
let t = c.rotation + (c.textBodyRotation ?? 0), l = `${c.shapeX},${c.shapeY},${c.shapeW},${c.shapeH},${t}`;
|
|
41
|
+
if (!o.has(l)) {
|
|
42
|
+
let i = s.createElement("div");
|
|
43
|
+
i.style.cssText = `position:absolute;left:${F(c.shapeX, n)};top:${F(c.shapeY, r)};width:${F(c.shapeW, n)};height:${F(c.shapeH, r)};pointer-events:all;overflow:hidden;`, t !== 0 && (i.style.transformOrigin = "center center", i.style.transform = `rotate(${t}deg)`), o.set(l, {
|
|
41
44
|
div: i,
|
|
42
|
-
x:
|
|
43
|
-
y:
|
|
44
|
-
w:
|
|
45
|
-
h:
|
|
45
|
+
x: c.shapeX,
|
|
46
|
+
y: c.shapeY,
|
|
47
|
+
w: c.shapeW,
|
|
48
|
+
h: c.shapeH,
|
|
46
49
|
rot: t
|
|
47
50
|
}), e.appendChild(i);
|
|
48
51
|
}
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
e.preventDefault(), i(
|
|
54
|
-
})),
|
|
52
|
+
let u = o.get(l), d = s.createElement("span");
|
|
53
|
+
I(d, "ooxmlSelectionRun", "pptx"), I(d, "runIndex", String(a)), c.shapeId !== void 0 && I(d, "shapeId", c.shapeId), c.elementIndex !== void 0 && I(d, "elementIndex", String(c.elementIndex)), c.origin !== void 0 && I(d, "elementOrigin", c.origin), d.textContent = c.text;
|
|
54
|
+
let f = i ? c.hyperlink : void 0;
|
|
55
|
+
d.style.cssText = `position:absolute;left:${F(c.inShapeX, u.w)};top:${F(c.inShapeY, u.h)};font:${c.font};line-height:${c.h}px;letter-spacing:0;white-space:pre;color:transparent;cursor:${f ? "pointer" : "text"};`, f && i && (d.title = f.kind === "external" ? f.url : f.ref, d.addEventListener("click", (e) => {
|
|
56
|
+
e.preventDefault(), i(f);
|
|
57
|
+
})), u.div.appendChild(d);
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
function
|
|
60
|
+
function R(e, t, n, r, i, a, o = {}) {
|
|
58
61
|
e.innerHTML = "";
|
|
59
62
|
let s = o.match ?? "rgba(255, 214, 0, 0.42)", c = o.active ?? "rgba(255, 140, 0, 0.55)", l = /* @__PURE__ */ new Map(), u = (t) => {
|
|
60
63
|
let n = t.rotation + (t.textBodyRotation ?? 0), a = `${t.shapeX},${t.shapeY},${t.shapeW},${t.shapeH},${n}`, o = l.get(a);
|
|
61
64
|
if (!o) {
|
|
62
65
|
let s = document.createElement("div");
|
|
63
|
-
s.style.cssText = `position:absolute;left:${
|
|
66
|
+
s.style.cssText = `position:absolute;left:${F(t.shapeX, r)};top:${F(t.shapeY, i)};width:${F(t.shapeW, r)};height:${F(t.shapeH, i)};pointer-events:none;overflow:hidden;`, n !== 0 && (s.style.transformOrigin = "center center", s.style.transform = `rotate(${n}deg)`), o = {
|
|
64
67
|
div: s,
|
|
65
68
|
w: t.shapeW,
|
|
66
69
|
h: t.shapeH
|
|
@@ -73,16 +76,16 @@ function F(e, t, n, r, i, a, o = {}) {
|
|
|
73
76
|
for (let r of e.slices) {
|
|
74
77
|
let e = t[r.runIndex];
|
|
75
78
|
if (!e) continue;
|
|
76
|
-
let i = a(e.font), { x: o, width: s } =
|
|
79
|
+
let i = a(e.font), { x: o, width: s } = Ee(e.text, r.start, r.end, i);
|
|
77
80
|
if (s <= 0) continue;
|
|
78
81
|
let c = u(e), l = document.createElement("div");
|
|
79
|
-
l.style.cssText = `position:absolute;left:${
|
|
82
|
+
l.style.cssText = `position:absolute;left:${F(e.inShapeX + o, c.w)};top:${F(e.inShapeY, c.h)};width:${F(s, c.w)};height:${F(e.h, c.h)};background:${n};pointer-events:none;`, c.div.appendChild(l);
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
//#endregion
|
|
84
87
|
//#region packages/pptx/src/find.ts
|
|
85
|
-
var
|
|
88
|
+
var z = class {
|
|
86
89
|
_slideRuns = /* @__PURE__ */ new Map();
|
|
87
90
|
_matches = [];
|
|
88
91
|
_active = -1;
|
|
@@ -142,8 +145,8 @@ var I = class {
|
|
|
142
145
|
if (n !== this._generation) return [];
|
|
143
146
|
let o = r === this._runsRevision ? i : new Map([...i, ...this._slideRuns]), s = [];
|
|
144
147
|
for (let n = 0; n < a; n++) {
|
|
145
|
-
let r = o.get(n) ?? [], i =
|
|
146
|
-
for (let a of
|
|
148
|
+
let r = o.get(n) ?? [], i = ue(r);
|
|
149
|
+
for (let a of le(i, e, t)) {
|
|
147
150
|
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
148
151
|
s.push({
|
|
149
152
|
slide: n,
|
|
@@ -155,10 +158,10 @@ var I = class {
|
|
|
155
158
|
return this._runsRevision++, this._slideRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
156
159
|
}
|
|
157
160
|
next() {
|
|
158
|
-
return this._active =
|
|
161
|
+
return this._active = se(this._active, this._matches.length), this._activePublic();
|
|
159
162
|
}
|
|
160
163
|
prev() {
|
|
161
|
-
return this._active =
|
|
164
|
+
return this._active = pe(this._active, this._matches.length), this._activePublic();
|
|
162
165
|
}
|
|
163
166
|
_activePublic() {
|
|
164
167
|
let e = this._matches[this._active];
|
|
@@ -168,22 +171,22 @@ var I = class {
|
|
|
168
171
|
location: { slide: e.slide }
|
|
169
172
|
} : null;
|
|
170
173
|
}
|
|
171
|
-
},
|
|
172
|
-
function
|
|
174
|
+
}, B = (e) => e >= "0" && e <= "9";
|
|
175
|
+
function Ae(e) {
|
|
173
176
|
let t = 0;
|
|
174
177
|
for (let n = 0; n < 10; n++) t = Math.max(t, e.measureText(String(n)).width);
|
|
175
178
|
return t;
|
|
176
179
|
}
|
|
177
|
-
function
|
|
180
|
+
function V(e, t, n) {
|
|
178
181
|
let r = 0;
|
|
179
|
-
for (let i of t) r +=
|
|
182
|
+
for (let i of t) r += B(i) ? n : e.measureText(i).width;
|
|
180
183
|
return r;
|
|
181
184
|
}
|
|
182
|
-
function
|
|
185
|
+
function je(e, t, n, r, i) {
|
|
183
186
|
let a = e.textAlign;
|
|
184
187
|
e.textAlign = "left";
|
|
185
188
|
let o = n;
|
|
186
|
-
for (let n of t) if (
|
|
189
|
+
for (let n of t) if (B(n)) {
|
|
187
190
|
let t = e.measureText(n).width;
|
|
188
191
|
e.fillText(n, o + (i - t) / 2, r), o += i;
|
|
189
192
|
} else e.fillText(n, o, r), o += e.measureText(n).width;
|
|
@@ -191,8 +194,8 @@ function Ae(e, t, n, r, i) {
|
|
|
191
194
|
}
|
|
192
195
|
//#endregion
|
|
193
196
|
//#region packages/pptx/src/presentation-handle.ts
|
|
194
|
-
var
|
|
195
|
-
async function
|
|
197
|
+
var H = (e, t) => e / x * t;
|
|
198
|
+
async function Me(e, t, n) {
|
|
196
199
|
let r = e.getContext("2d");
|
|
197
200
|
if (!r) throw Error("2D context not available");
|
|
198
201
|
let a = n.width / (n.slideWidthEmu / x);
|
|
@@ -202,20 +205,28 @@ async function je(e, t, n) {
|
|
|
202
205
|
let s = o.getContext("2d");
|
|
203
206
|
if (!s) throw Error("base 2D context not available");
|
|
204
207
|
s.drawImage(e, 0, 0);
|
|
205
|
-
let c = [], l =
|
|
206
|
-
|
|
208
|
+
let c = [], l = !1, u = () => {
|
|
209
|
+
for (let e of c) {
|
|
210
|
+
e.detachListeners(), e.media.pause(), e.media.removeAttribute("src");
|
|
211
|
+
try {
|
|
212
|
+
e.media.load();
|
|
213
|
+
} catch {}
|
|
214
|
+
URL.revokeObjectURL(e.objectUrl);
|
|
215
|
+
}
|
|
216
|
+
c.length = 0;
|
|
217
|
+
}, d = (e) => {
|
|
218
|
+
l || (n.onError ? n.onError(e) : console.error("[ooxml] PPTX embedded media failed:", e));
|
|
207
219
|
};
|
|
208
220
|
for (let e of t) {
|
|
209
221
|
let t;
|
|
210
222
|
try {
|
|
211
223
|
t = await n.fetchMedia(e.mediaPath);
|
|
212
224
|
} catch (t) {
|
|
213
|
-
|
|
214
|
-
continue;
|
|
225
|
+
throw u(), Fe(e, t);
|
|
215
226
|
}
|
|
216
227
|
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");
|
|
217
228
|
s.src = o, s.preload = "metadata", e.mediaKind === "video" && (s.playsInline = !0);
|
|
218
|
-
let f =
|
|
229
|
+
let f = Ne(e, a), p = {
|
|
219
230
|
el: e,
|
|
220
231
|
rect: e.mediaKind === "audio" ? {
|
|
221
232
|
x: f.x + f.w / 2 - Math.max(f.w, 260) / 2,
|
|
@@ -229,11 +240,11 @@ async function je(e, t, n) {
|
|
|
229
240
|
loadState: "loading",
|
|
230
241
|
detachListeners: () => {}
|
|
231
242
|
}, m = () => {
|
|
232
|
-
|
|
243
|
+
l || (p.loadState = "metadata");
|
|
233
244
|
}, h = () => {
|
|
234
|
-
|
|
245
|
+
l || (p.loadState = "ready");
|
|
235
246
|
}, g = () => {
|
|
236
|
-
|
|
247
|
+
l || (p.loadState = "error", d(U(e, s, "decode")));
|
|
237
248
|
};
|
|
238
249
|
s.addEventListener("loadedmetadata", m), s.addEventListener("canplay", h), s.addEventListener("error", g), p.detachListeners = () => {
|
|
239
250
|
s.removeEventListener("loadedmetadata", m), s.removeEventListener("canplay", h), s.removeEventListener("error", g);
|
|
@@ -241,26 +252,26 @@ async function je(e, t, n) {
|
|
|
241
252
|
try {
|
|
242
253
|
s.load();
|
|
243
254
|
} catch (t) {
|
|
244
|
-
|
|
255
|
+
let n = U(e, s, "load", t);
|
|
256
|
+
throw u(), n;
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
let f = null, p = null, m = () => {
|
|
248
260
|
r.setTransform(n.dpr, 0, 0, n.dpr, 0, 0);
|
|
249
261
|
let t = e.width / n.dpr, a = e.height / n.dpr;
|
|
250
262
|
r.drawImage(o, 0, 0, e.width, e.height, 0, 0, t, a);
|
|
251
|
-
for (let e of l) B(r, e, "Media unavailable");
|
|
252
263
|
for (let e of c) {
|
|
253
264
|
let t = e.media;
|
|
254
265
|
if (e.loadState !== "loading") {
|
|
255
266
|
if (e.loadState === "error") {
|
|
256
|
-
|
|
267
|
+
Pe(r, e.posterRect, "Media unavailable");
|
|
257
268
|
continue;
|
|
258
269
|
}
|
|
259
270
|
if (e.el.mediaKind === "video" && t.readyState >= 2) {
|
|
260
271
|
let { x: n, y: i, w: a, h: o } = e.posterRect;
|
|
261
272
|
r.drawImage(t, n, i, a, o);
|
|
262
273
|
}
|
|
263
|
-
if (e === p || v?.state === e)
|
|
274
|
+
if (e === p || v?.state === e) Be(r, e, t);
|
|
264
275
|
else if (t.paused) {
|
|
265
276
|
let { x: t, y: n, w: a, h: o } = e.posterRect;
|
|
266
277
|
i(r, t + a / 2, n + o / 2, a, o, "paused");
|
|
@@ -268,7 +279,7 @@ async function je(e, t, n) {
|
|
|
268
279
|
}
|
|
269
280
|
}
|
|
270
281
|
}, h = () => {
|
|
271
|
-
|
|
282
|
+
l || (m(), f = requestAnimationFrame(h));
|
|
272
283
|
}, g = (t, r) => {
|
|
273
284
|
let i = e.getBoundingClientRect(), a = e.width / n.dpr, o = e.height / n.dpr;
|
|
274
285
|
return {
|
|
@@ -279,7 +290,7 @@ async function je(e, t, n) {
|
|
|
279
290
|
for (let n of c) {
|
|
280
291
|
let { x: r, y: i, w: a, h: o } = n.rect;
|
|
281
292
|
if (e < r || e > r + a || t < i || t > i + o) continue;
|
|
282
|
-
let s =
|
|
293
|
+
let s = K(n), c = s.y - 12, l = s.y + s.h + 8;
|
|
283
294
|
return (Number.isFinite(n.media.duration) ? n.media.duration : 0) > 0 && e >= s.x && e <= s.x + s.w && t >= c && t <= l ? {
|
|
284
295
|
kind: "seek",
|
|
285
296
|
state: n,
|
|
@@ -296,10 +307,10 @@ async function je(e, t, n) {
|
|
|
296
307
|
}, b = (e) => {
|
|
297
308
|
try {
|
|
298
309
|
e.media.play().catch((t) => {
|
|
299
|
-
d(
|
|
310
|
+
d(U(e.el, e.media, "play", t));
|
|
300
311
|
});
|
|
301
312
|
} catch (t) {
|
|
302
|
-
d(
|
|
313
|
+
d(U(e.el, e.media, "play", t));
|
|
303
314
|
}
|
|
304
315
|
}, S = (t) => {
|
|
305
316
|
let { x: n, y: r } = g(t.clientX, t.clientY), i = _(n, r);
|
|
@@ -318,7 +329,7 @@ async function je(e, t, n) {
|
|
|
318
329
|
}
|
|
319
330
|
}
|
|
320
331
|
if (v) {
|
|
321
|
-
let e =
|
|
332
|
+
let e = K(v.state), n = Math.max(0, Math.min(1, (t - e.x) / e.w));
|
|
322
333
|
y(v.state, n);
|
|
323
334
|
}
|
|
324
335
|
}, w = () => {
|
|
@@ -328,7 +339,7 @@ async function je(e, t, n) {
|
|
|
328
339
|
let { wasPlaying: n, state: r } = v;
|
|
329
340
|
v = null, e.releasePointerCapture(t.pointerId), n && b(r);
|
|
330
341
|
};
|
|
331
|
-
return c.length > 0
|
|
342
|
+
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", h()), {
|
|
332
343
|
play(e) {
|
|
333
344
|
for (let t of c) (!e || t.el.mediaPath === e) && b(t);
|
|
334
345
|
},
|
|
@@ -336,31 +347,28 @@ async function je(e, t, n) {
|
|
|
336
347
|
for (let t of c) (!e || t.el.mediaPath === e) && t.media.pause();
|
|
337
348
|
},
|
|
338
349
|
destroy() {
|
|
339
|
-
|
|
340
|
-
u = !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 = "";
|
|
341
|
-
for (let e of c) e.detachListeners(), e.media.pause(), e.media.removeAttribute("src"), e.media.load(), URL.revokeObjectURL(e.objectUrl);
|
|
342
|
-
}
|
|
350
|
+
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());
|
|
343
351
|
}
|
|
344
352
|
};
|
|
345
353
|
}
|
|
346
|
-
function
|
|
354
|
+
function Ne(e, t) {
|
|
347
355
|
return {
|
|
348
|
-
x:
|
|
349
|
-
y:
|
|
350
|
-
w:
|
|
351
|
-
h:
|
|
356
|
+
x: H(e.x, t),
|
|
357
|
+
y: H(e.y, t),
|
|
358
|
+
w: H(e.width, t),
|
|
359
|
+
h: H(e.height, t)
|
|
352
360
|
};
|
|
353
361
|
}
|
|
354
|
-
function
|
|
362
|
+
function Pe(e, t, n) {
|
|
355
363
|
let r = Math.max(10, Math.min(14, t.h * .12));
|
|
356
364
|
e.save(), e.font = `500 ${r}px system-ui, -apple-system, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
|
|
357
365
|
let i = r + 12, a = Math.min(t.w, Math.max(100, e.measureText(n).width + 24));
|
|
358
|
-
|
|
366
|
+
q(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();
|
|
359
367
|
}
|
|
360
|
-
function
|
|
361
|
-
return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} fetch failed for "${e.mediaPath}" (mime=${e.mimeType || "unknown"}): ${
|
|
368
|
+
function Fe(e, t) {
|
|
369
|
+
return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} fetch failed for "${e.mediaPath}" (mime=${e.mimeType || "unknown"}): ${Ie(t)}`);
|
|
362
370
|
}
|
|
363
|
-
function
|
|
371
|
+
function U(e, t, n, r) {
|
|
364
372
|
let i = "";
|
|
365
373
|
try {
|
|
366
374
|
i = e.mimeType ? t.canPlayType(e.mimeType) : "";
|
|
@@ -372,55 +380,55 @@ function V(e, t, n, r) {
|
|
|
372
380
|
`networkState=${t.networkState}`
|
|
373
381
|
];
|
|
374
382
|
a && o.push(`mediaError=${a.code}${a.message ? ` ${a.message}` : ""}`);
|
|
375
|
-
let s = r === void 0 ? "" : `: ${
|
|
383
|
+
let s = r === void 0 ? "" : `: ${Ie(r)}`;
|
|
376
384
|
return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} ${n} failed for "${e.mediaPath}" (${o.join("; ")})${s}`);
|
|
377
385
|
}
|
|
378
|
-
function
|
|
386
|
+
function Ie(e) {
|
|
379
387
|
return e instanceof Error ? `${e.name || "Error"}${e.message ? `: ${e.message}` : ""}` : String(e);
|
|
380
388
|
}
|
|
381
|
-
var
|
|
382
|
-
function
|
|
389
|
+
var Le = 28, W = 14, Re = 72, ze = 10, G = 3;
|
|
390
|
+
function Be(e, t, n) {
|
|
383
391
|
let r = Number.isFinite(n.duration) ? n.duration : 0, a = r > 0 ? Math.min(1, n.currentTime / r) : 0, o = t.posterRect;
|
|
384
|
-
i(e, o.x + o.w / 2, o.y + o.h / 2, o.w, o.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ?
|
|
392
|
+
i(e, o.x + o.w / 2, o.y + o.h / 2, o.w, o.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ? He(e, t, n, r, a) : Ve(e, t, n, r, a);
|
|
385
393
|
}
|
|
386
|
-
function
|
|
394
|
+
function Ve(e, t, n, r, i) {
|
|
387
395
|
let { x: a, y: o, w: s, h: c } = t.rect, l = Math.max(28, Math.min(56, c * .22)), u = o + c - l;
|
|
388
396
|
e.save();
|
|
389
397
|
let d = e.createLinearGradient(0, u, 0, o + c);
|
|
390
398
|
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();
|
|
391
|
-
let f =
|
|
392
|
-
|
|
399
|
+
let f = K(t);
|
|
400
|
+
We(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)", Ue(e, n.currentTime, r, f.x, f.y - 10, "bottom"), e.restore();
|
|
393
401
|
}
|
|
394
|
-
function
|
|
395
|
-
let a =
|
|
396
|
-
e.save(),
|
|
402
|
+
function He(e, t, n, r, i) {
|
|
403
|
+
let a = Ge(t.rect);
|
|
404
|
+
e.save(), q(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)", Ue(e, n.currentTime, r, a.x + W, a.y + a.h / 2, "middle"), e.restore(), We(e, K(t), i, r > 0);
|
|
397
405
|
}
|
|
398
|
-
function
|
|
399
|
-
let o =
|
|
400
|
-
|
|
406
|
+
function Ue(e, t, n, r, i, a) {
|
|
407
|
+
let o = Ke(t), s = Ke(n), c = Ae(e), l = V(e, o, c), u = V(e, s, c), d = e.measureText(" / ").width, f = Math.max(l, u);
|
|
408
|
+
je(e, o, r + f - l, i, c);
|
|
401
409
|
let p = e.textAlign;
|
|
402
|
-
e.textAlign = "left", e.fillText(" / ", r + f, i), e.textAlign = p,
|
|
410
|
+
e.textAlign = "left", e.fillText(" / ", r + f, i), e.textAlign = p, je(e, s, r + f + d, i, c);
|
|
403
411
|
}
|
|
404
|
-
function
|
|
412
|
+
function We(e, t, n, r) {
|
|
405
413
|
let i = t.h / 2;
|
|
406
|
-
if (e.save(),
|
|
414
|
+
if (e.save(), q(e, t.x, t.y, t.w, t.h, i), e.fillStyle = "rgba(255, 255, 255, 0.35)", e.fill(), n > 0 && (q(e, t.x, t.y, t.w * n, t.h, i), e.fillStyle = "#fff", e.fill()), r) {
|
|
407
415
|
let r = Math.max(t.x + 5, Math.min(t.x + t.w - 5, t.x + t.w * n));
|
|
408
416
|
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();
|
|
409
417
|
}
|
|
410
418
|
e.restore();
|
|
411
419
|
}
|
|
412
|
-
function
|
|
420
|
+
function Ge(e) {
|
|
413
421
|
let t = Math.max(220, e.w - 24);
|
|
414
422
|
return {
|
|
415
423
|
x: e.x + e.w / 2 - t / 2,
|
|
416
|
-
y: e.y + e.h -
|
|
424
|
+
y: e.y + e.h - Le - 4,
|
|
417
425
|
w: t,
|
|
418
|
-
h:
|
|
426
|
+
h: Le
|
|
419
427
|
};
|
|
420
428
|
}
|
|
421
|
-
function
|
|
429
|
+
function K(e) {
|
|
422
430
|
if (e.el.mediaKind === "audio") {
|
|
423
|
-
let t =
|
|
431
|
+
let t = Ge(e.rect), n = t.x + W + Re + ze, r = Math.max(40, t.x + t.w - W - n);
|
|
424
432
|
return {
|
|
425
433
|
x: n,
|
|
426
434
|
y: t.y + (t.h - G) / 2,
|
|
@@ -436,18 +444,18 @@ function Y(e) {
|
|
|
436
444
|
h: G
|
|
437
445
|
};
|
|
438
446
|
}
|
|
439
|
-
function
|
|
447
|
+
function q(e, t, n, r, i, a) {
|
|
440
448
|
let o = Math.min(a, i / 2, r / 2);
|
|
441
449
|
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();
|
|
442
450
|
}
|
|
443
|
-
function
|
|
451
|
+
function Ke(e) {
|
|
444
452
|
if (!Number.isFinite(e) || e < 0) return "0:00";
|
|
445
453
|
let t = Math.floor(e);
|
|
446
454
|
return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
|
|
447
455
|
}
|
|
448
456
|
//#endregion
|
|
449
457
|
//#region packages/pptx/src/slide-nav.ts
|
|
450
|
-
function
|
|
458
|
+
function qe(e) {
|
|
451
459
|
let t = /* @__PURE__ */ new Map();
|
|
452
460
|
for (let n = 0; n < e.length; n++) {
|
|
453
461
|
let r = e[n];
|
|
@@ -455,18 +463,18 @@ function Re(e) {
|
|
|
455
463
|
}
|
|
456
464
|
return t;
|
|
457
465
|
}
|
|
458
|
-
function
|
|
466
|
+
function Je(e, t) {
|
|
459
467
|
if (e === "") return;
|
|
460
|
-
let n =
|
|
468
|
+
let n = De("ppt/slides", e);
|
|
461
469
|
return t.get(n);
|
|
462
470
|
}
|
|
463
|
-
function
|
|
464
|
-
let r =
|
|
465
|
-
return r === null ?
|
|
471
|
+
function Ye(e, t, n) {
|
|
472
|
+
let r = Oe(e);
|
|
473
|
+
return r === null ? Je(e, t) : ke(r, n, t.size);
|
|
466
474
|
}
|
|
467
475
|
//#endregion
|
|
468
476
|
//#region packages/pptx/src/slide-repository.ts
|
|
469
|
-
var
|
|
477
|
+
var Xe = class {
|
|
470
478
|
#e;
|
|
471
479
|
#t;
|
|
472
480
|
#n;
|
|
@@ -476,10 +484,10 @@ var Ve = class {
|
|
|
476
484
|
#o;
|
|
477
485
|
constructor(e) {
|
|
478
486
|
if (!Number.isSafeInteger(e.slideCount) || e.slideCount < 0) throw TypeError("slideCount must be a non-negative safe integer");
|
|
479
|
-
this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new
|
|
487
|
+
this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new xe({
|
|
480
488
|
maxEntries: e.maxCachedSlides,
|
|
481
489
|
maxWeight: e.maxCachedStructuralBytes,
|
|
482
|
-
measure: (e) =>
|
|
490
|
+
measure: (e) => Ce(e).jsonBytes
|
|
483
491
|
});
|
|
484
492
|
}
|
|
485
493
|
get slideCount() {
|
|
@@ -497,7 +505,7 @@ var Ve = class {
|
|
|
497
505
|
try {
|
|
498
506
|
return await t(r);
|
|
499
507
|
} catch (e) {
|
|
500
|
-
let t =
|
|
508
|
+
let t = Ze(e);
|
|
501
509
|
throw t ? (this.#l(t, n), this.#o === n ? this.#a ?? t : t) : e;
|
|
502
510
|
}
|
|
503
511
|
});
|
|
@@ -509,7 +517,7 @@ var Ve = class {
|
|
|
509
517
|
try {
|
|
510
518
|
n = await this.#t(e);
|
|
511
519
|
} catch (e) {
|
|
512
|
-
let n =
|
|
520
|
+
let n = Ze(e);
|
|
513
521
|
throw n ? (this.#l(n, t), this.#o === t ? this.#a ?? n : n) : e;
|
|
514
522
|
}
|
|
515
523
|
if (this.#o === t && this.#a) throw this.#a;
|
|
@@ -526,16 +534,16 @@ var Ve = class {
|
|
|
526
534
|
t !== this.#r || this.#a || (this.#a = e, this.#o = t, this.#r += 1, this.#n.clear());
|
|
527
535
|
}
|
|
528
536
|
};
|
|
529
|
-
function
|
|
537
|
+
function Ze(e) {
|
|
530
538
|
return e instanceof y ? e : _(e);
|
|
531
539
|
}
|
|
532
540
|
//#endregion
|
|
533
541
|
//#region packages/pptx/src/worker.ts?worker&inline
|
|
534
|
-
var Ue = "var e=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},t=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)}};const n=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,r=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,i={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},\"calibri light\":{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`},\"cambria math\":{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"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:n,loadFamily:`Noto Naskh Arabic`},\"traditional arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"simplified arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"arabic typesetting\":{url:n,loadFamily:`Noto Naskh Arabic`},\"univers next arabic\":{url:r,loadFamily:`Noto Sans Arabic`},\"noto naskh arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:r,loadFamily:`Noto Sans Arabic`}};function a(e){if(!e)return null;let t=e.toLowerCase();return/[ᄀ-ᇿ-가-]/.test(e)?`kr`:/[-ヿ]/.test(e)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(t)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(e)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(t)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(e)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(t)?`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(t)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(e)?`jp`:null}const o=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,s={\"noto sans kr\":{url:o(`Noto+Sans+KR`)},\"noto sans sc\":{url:o(`Noto+Sans+SC`)},\"noto sans tc\":{url:o(`Noto+Sans+TC`)},\"noto sans jp\":{url:o(`Noto+Sans+JP`)},\"noto serif kr\":{url:o(`Noto+Serif+KR`)},\"noto serif sc\":{url:o(`Noto+Serif+SC`)},\"noto serif tc\":{url:o(`Noto+Serif+TC`)},\"noto serif jp\":{url:o(`Noto+Serif+JP`)},\"noto sans\":{url:o(`Noto+Sans`)},\"noto serif\":{url:o(`Noto+Serif`)},\"noto sans devanagari\":{url:o(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:o(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:o(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:o(`Noto+Serif+Hebrew`)}};var ee=class e{hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}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:n>=13312&&n<=19903||n>=19968&&n<=40959||n>=63744&&n<=64255||n>=131072&&n<=195103?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(){let e=[],t=new Set;this.hasHangul&&t.add(`kr`),this.hasKana&&t.add(`jp`),this.hasHan&&t.size===0&&t.add(this.cjkLang??`jp`);for(let n of[`kr`,`sc`,`tc`,`jp`])if(t.has(n)){let t={kr:`KR`,sc:`SC`,tc:`TC`,jp:`JP`}[n];e.push(`Noto Sans ${t}`,`Noto Serif ${t}`)}return this.hasCyrGreek&&e.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&e.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&e.push(`Noto Sans Thai`),this.hasHebrew&&e.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&e.push(`Noto Sans Devanagari`),e}},c=class e extends RangeError{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 te(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 l=class{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`)}},u=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ne(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 re(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 ie(e,t){return e({module_or_path:t})}var ae=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new l(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),oe),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 this.runtime.run(e)}poison(){this.runtime.poison(new u(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ie(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,re(e)}};function oe(e){return ne(e)?new u(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function d(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function f(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return d(t.requiredBytes)&&d(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var p=class e extends RangeError{code=`ooxml-insufficient-credit`;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 se(e){if(e instanceof p)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))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`||!f(r)))return new p(r)}function ce(e,t,n){let r=se(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}const le=`OOXML_RESOURCE_LIMIT:`;function m(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return m(t.archiveEntryCount)&&m(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||m(t.largestInflatedEntryBytes))&&m(t.distinctInflatedBytes)&&m(t.operationInflatedBytes)}function de(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!ue(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function fe(e){return e===`docx`||e===`xlsx`||e===`pptx`}function pe(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function h(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function g(e){return h(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function me(e){return!h(e,4096)||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!==`..`)}const _=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}],[`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}]]),he=new Set([..._.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),ge=new Set([..._.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function _e(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!fe(t.format)||!h(t.operation,256)||!g(t.resource)||!g(t.metric)||!m(t.limit)||!m(t.observed)||typeof t.configurable!=`boolean`||!ue(t.usage)?!1:!(`part`in t)||me(t.part)}function v(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!pe(t.stage)||!_e(t.violation))return!1;let n=t.violation,r=_.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:!(he.has(n.resource)&&ge.has(n.metric))}function ve(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function ye(e){if(!v(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:ve(t.usage)}};return v(n)?n:void 0}function be(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function y(e){let n=e instanceof Error?e.message:String(e);if(!n.startsWith(le))return;let r;try{r=JSON.parse(n.slice(21))}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(!(i.code!==`ooxml-resource-limit`||!v(i.details)))return new t(be(i.details),i.details)}function xe(n){if(n instanceof c)return{message:n.message,errorName:n.name,code:n.code,decodedImage:{metric:n.metric,limit:n.limit,observed:n.observed}};let r=se(n);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=n instanceof e||n instanceof t?n:y(n);if(i instanceof t){let e=ye(i.details);return e?{message:typeof i.message==`string`?i.message:be(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof e)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:h(i.name,128)?i.name:`OoxmlError`,...g(i.code)?{code:i.code}:{}};let a=n instanceof Error?n.message:String(n);if(typeof a==`string`&&a.startsWith(le))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=n instanceof Error?n:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:h(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function b(e){try{return xe(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}const Se=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`]);function Ce(n){if(n.code===`ooxml-decoded-image-limit`&&n.decodedImage&&(n.decodedImage.metric===`image-pixels`||n.decodedImage.metric===`active-decoded-bytes`)&&m(n.decodedImage.limit)&&m(n.decodedImage.observed)&&n.decodedImage.observed>n.decodedImage.limit)return new c(n.decodedImage.metric,n.decodedImage.limit,n.decodedImage.observed);if(n.code===`ooxml-insufficient-credit`&&f(n.insufficientCredit))return new p(n.insufficientCredit);if(n.code===`ooxml-resource-limit`&&v(n.resourceLimit))return new t(n.message,n.resourceLimit);if(n.code&&Se.has(n.code))return new e(n.code,n.message);let r=n.errorName===`TypeError`?TypeError(n.message):n.errorName===`RangeError`?RangeError(n.message):Error(n.message);return n.errorName&&(r.name=n.errorName),n.code!==void 0&&Object.assign(r,{code:n.code}),r}function we(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}const x=67108864;Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function Te(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const S=`ooxml-pull-v1`;function C(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Ee(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 w=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,C(this.maxRetainedBytes,`max retained lease bytes`),C(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}},De=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){Ee(e.sessionId),C(e.operationId,`operation id`),C(e.generation,`generation`),C(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&C(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=b(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(C(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:S,...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){C(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(C(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:S,...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:S,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}}};function T(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function E(e,t,n){return T(e,`resource measurement`),T(t,`resource measurement`),T(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Oe(e,t=2**53-1){T(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=E(n,a,t),n>t)return n}return n}function D(e,t=2**53-1){T(t,`resource measurement limit`);let n=E(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=E(n,a,t),n>t)return n}return n}function O(e,t){return E(0,e,t)}function k(e,t=2**53-1,n=!1){if(T(t,`resource measurement limit`),e===null)return{jsonBytes:O(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:D(e,t),stringValueUtf8Bytes:Oe(e,t)};if(typeof e==`boolean`)return{jsonBytes:O(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:O((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=O(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=E(n,1,t));let a=k(e[i],t,!0);n=E(n,a.jsonBytes,t),r=E(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=O(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=E(n,1,t)),n=E(n,D(a,t),t),n=E(n,1,t);let e=k(o,t);n=E(n,e.jsonBytes,t),r=E(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?O(4,t):0,stringValueUtf8Bytes:0}}({...i,...s});function*A(e){for(let t of e?.paragraphs??[])for(let e of t.runs)e.type===`text`&&(yield e.text)}function*ke(e){for(let t of e.elements)if(t.type===`shape`)yield*A(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*A(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 Ae=class e{scripts;constructor(e,t,n){this.majorFont=e,this.minorFont=t;let r=a(e)??a(t)??null;this.scripts=n??new ee(r)}addSlide(e){this.scripts.addText(ke(e))}names(){return[this.majorFont,this.minorFont,...this.scripts.names()]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone());return n.addSlide(t),n}};const j=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),M=67108864;function N(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function je(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 Me(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.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return N(t.defaultTextColor,`defaultTextColor`),N(t.majorFont,`majorFont`),N(t.minorFont,`minorFont`),N(t.hlinkColor,`hlinkColor`),N(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,slides:Object.freeze(t.slides.map(je))})}function Ne(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 Pe(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(Ne))})}function Fe(e,n,r){if(!(e<=n))throw new t(`PPTX presentation preflight exceeded its hard limit of ${n} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:n,observed:Math.min(e,n+1),configurable:!1,usage:r}})}var Ie=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;constructor(e,t={}){let n=Me(e),r=t.hardLimitForTesting??M;if(!Number.isSafeInteger(r)||r<=0||r>M)throw Error(`invalid PPTX presentation preflight test limit`);this.limit=r,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.descriptors=[...n.slides],this.fonts=new Ae(this.majorFontValue,this.minorFontValue),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=k(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=k({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,Fe(this.projectionBytesValue,this.limit,j)}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)}addSlide(e,t=j){this.prepareSlide(e,t).commit()}prepareSlide(e,t=j){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=Pe(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=k(o,this.limit).jsonBytes,ee=k(i,this.limit).jsonBytes,c=this.projectionBytesValue-this.fontProjectionBytes-k(r,this.limit).jsonBytes+4;c=E(c,s,this.limit),c=E(c,ee,this.limit),this.slides.length!==0&&(c=E(c,1,this.limit));let te=k({slide:i,fontPreloadNames:o},this.limit).jsonBytes,l=E(this.projectionBytesValue,te,this.limit);Fe(Math.max(l,c),this.limit,t);let u={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:c};return this.pending=u,{projectedBytes:l,commit:()=>{if(u.state!==`committed`){if(u.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==u)throw Error(`PPTX presentation preflight prepared slide is stale`);this.descriptors[n]=void 0,this.slides.push(u.fact),this.fonts=u.fonts,this.fontPreloadNames=u.fontNames,this.fontProjectionBytes=u.fontBytes,this.projectionBytesValue=u.committedBytes,u.state=`committed`,this.pending=null}},rollback:()=>{if(u.state!==`rolled-back`){if(u.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==u)throw Error(`PPTX presentation preflight prepared slide is stale`);u.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,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames}),this.descriptors=[],this.slides=[],this.projectionBytesValue=k(this.finished,this.limit).jsonBytes,this.finished}};function Le(e){try{return de(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function Re(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,Le(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}}var ze=class{coordinatorGeneration=new w;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(),Ve(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||!P(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 De({...t,maxByteCredit:x,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 ce(e,n,x)||(this.latchResourceFailure(e),e)}let o=we(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{Re(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=P(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:S,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:S,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(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:S,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=Ce(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 w,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&&!P(t,e)?this.staleLifecycleResponse(e):{protocol:S,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(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:S,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&P(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return Le(this.executeArchive)}latchResourceFailure(e){let n=e instanceof t?e:y(e);n&&(this.resourceFailure??=n)}staleLifecycleResponse(e){return{protocol:S,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 Be(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function Ve(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 P(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var F=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ue.unregister(this),e}free(){let e=this.__destroy_into_raw();J.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=J.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw U(n[0])}assert_healthy(){let e=J.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw U(e[0])}cancel_slide(){J.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){J.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_image(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=Ge(e,J.__wbindgen_malloc),a=q,o=J.pptxarchive_new(i,a,!V(t),V(t)?BigInt(0):t,!V(n),V(n)?BigInt(0):n,!V(r),V(r)?BigInt(0):r);if(o[2])throw U(o[1]);return this.__wbg_ptr=o[0]>>>0,Ue.register(this,this.__wbg_ptr,this),this}parse(){let e=J.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=J.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=J.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw U(i[2]);var a=I(i[0],i[1]).slice();return J.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=J.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=J.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=J.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,U(i[2]);return e=n,t=r,R(n,r)}finally{J.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function He(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(R(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(R(e,t))}finally{J.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=H(n,J.__wbindgen_malloc,J.__wbindgen_realloc),i=q;We().setInt32(e+4,i,!0),We().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return R(e,t)},__wbindgen_init_externref_table:function(){let e=J.__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 Ue=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>J.__wbg_pptxarchive_free(e>>>0,1));function I(e,t){return e>>>=0,B().subarray(e/1,e/1+t)}let L=null;function We(){return(L===null||L.buffer.detached===!0||L.buffer.detached===void 0&&L.buffer!==J.memory.buffer)&&(L=new DataView(J.memory.buffer)),L}function R(e,t){return e>>>=0,Ke(e,t)}let z=null;function B(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(J.memory.buffer)),z}function V(e){return e==null}function Ge(e,t){let n=t(e.length*1,1)>>>0;return B().set(e,n/1),q=e.length,n}function H(e,t,n){if(n===void 0){let n=K.encode(e),r=t(n.length,1)>>>0;return B().subarray(r,r+n.length).set(n),q=n.length,r}let r=e.length,i=t(r,1)>>>0,a=B(),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=B().subarray(i+o,i+r),a=K.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return q=o,i}function U(e){let t=J.__wbindgen_externrefs.get(e);return J.__externref_table_dealloc(e),t}let W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});W.decode();let G=0;function Ke(e,t){return G+=t,G>=2146435072&&(W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),W.decode(),G=t),W.decode(B().subarray(e,e+t))}const K=new TextEncoder;`encodeInto`in K||(K.encodeInto=function(e,t){let n=K.encode(e);return t.set(n),{read:e.length,written:n.length}});let q=0,J;function qe(e,t){return J=e.exports,L=null,z=null,J.__wbindgen_start(),J}async function Je(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 Ye(e){if(J!==void 0)return J;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=He();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Je(await e,t);return qe(n,r)}async function Xe(e){return J=void 0,L=null,z=null,Ye(e)}const Y=new ae(Ye,{freeArchive:e=>e.free(),reinit:Xe});let X=null,Z=`empty`;function Ze(){if(Z!==`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`})}Z=`opening`}const Q=new ze(()=>Y.archive,(e,t,n)=>{if(X){if(e!==X.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${X.acceptedSlideCount}, received ${e}`);return X.prepareSlide(t,n)}},e=>{let t=Y.archive;if(!t)throw Error(`Presentation not loaded`);return Y.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(Be(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){Y.setWasmInput(te(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(Ze(),r=!0),t.kind===`openSlideSession`){await Y.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,...b(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await Y.ensureReady(),t.kind!==`parse`&&Y.archive){let e=Y.archive;Y.run(()=>e.assert_healthy())}if(t.kind===`parse`){X=null;let[e,r,i]=Te(t.resourcePolicy),a=Y.run(()=>{let n=new F(new Uint8Array(t.buffer),e,r,i);return Y.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});X=new Ie(a),$({kind:`presentationOpened`,id:n,bootstrap:a}),Z=`ready`;return}let e=Y.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!X)throw Error(`PPTX presentation preflight is not active`);let e=X.finish();X=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=Y.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=Y.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:de(Y.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:Y.run(()=>e.to_markdown())})})}catch(e){r&&(Z=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...b(e)})}catch{}}};", We = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Ue], { type: "text/javascript;charset=utf-8" });
|
|
535
|
-
function
|
|
542
|
+
var Qe = "var e=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},t=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)}};const n=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,r=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,i={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},\"calibri light\":{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`},\"cambria math\":{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"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:n,loadFamily:`Noto Naskh Arabic`},\"traditional arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"simplified arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"arabic typesetting\":{url:n,loadFamily:`Noto Naskh Arabic`},\"univers next arabic\":{url:r,loadFamily:`Noto Sans Arabic`},\"noto naskh arabic\":{url:n,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:r,loadFamily:`Noto Sans Arabic`}};function a(e){if(!e)return null;let t=e.toLowerCase();return/[ᄀ-ᇿ-가-]/.test(e)?`kr`:/[-ヿ]/.test(e)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(t)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(e)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(t)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(e)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(t)?`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(t)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(e)?`jp`:null}const o=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,s={\"noto sans kr\":{url:o(`Noto+Sans+KR`)},\"noto sans sc\":{url:o(`Noto+Sans+SC`)},\"noto sans tc\":{url:o(`Noto+Sans+TC`)},\"noto sans jp\":{url:o(`Noto+Sans+JP`)},\"noto serif kr\":{url:o(`Noto+Serif+KR`)},\"noto serif sc\":{url:o(`Noto+Serif+SC`)},\"noto serif tc\":{url:o(`Noto+Serif+TC`)},\"noto serif jp\":{url:o(`Noto+Serif+JP`)},\"noto sans\":{url:o(`Noto+Sans`)},\"noto serif\":{url:o(`Noto+Serif`)},\"noto sans devanagari\":{url:o(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:o(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:o(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:o(`Noto+Serif+Hebrew`)}};var ee=class e{hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}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:n>=13312&&n<=19903||n>=19968&&n<=40959||n>=63744&&n<=64255||n>=131072&&n<=195103?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(){let e=[],t=new Set;this.hasHangul&&t.add(`kr`),this.hasKana&&t.add(`jp`),this.hasHan&&t.size===0&&t.add(this.cjkLang??`jp`);for(let n of[`kr`,`sc`,`tc`,`jp`])if(t.has(n)){let t={kr:`KR`,sc:`SC`,tc:`TC`,jp:`JP`}[n];e.push(`Noto Sans ${t}`,`Noto Serif ${t}`)}return this.hasCyrGreek&&e.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&e.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&e.push(`Noto Sans Thai`),this.hasHebrew&&e.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&e.push(`Noto Sans Devanagari`),e}},c=class e extends RangeError{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 te(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 l=class{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`)}},u=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ne(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 re(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 ie(e,t){return e({module_or_path:t})}var ae=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new l(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),oe),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 this.runtime.run(e)}poison(){this.runtime.poison(new u(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ie(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,re(e)}};function oe(e){return ne(e)?new u(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function d(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function f(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return d(t.requiredBytes)&&d(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var p=class e extends RangeError{code=`ooxml-insufficient-credit`;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 se(e){if(e instanceof p)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))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`||!f(r)))return new p(r)}function ce(e,t,n){let r=se(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}const le=`OOXML_RESOURCE_LIMIT:`;function m(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return m(t.archiveEntryCount)&&m(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||m(t.largestInflatedEntryBytes))&&m(t.distinctInflatedBytes)&&m(t.operationInflatedBytes)}function de(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!ue(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function fe(e){return e===`docx`||e===`xlsx`||e===`pptx`}function pe(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function h(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function g(e){return h(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function me(e){return!h(e,4096)||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!==`..`)}const _=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}],[`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}]]),he=new Set([..._.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),ge=new Set([..._.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function _e(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!fe(t.format)||!h(t.operation,256)||!g(t.resource)||!g(t.metric)||!m(t.limit)||!m(t.observed)||typeof t.configurable!=`boolean`||!ue(t.usage)?!1:!(`part`in t)||me(t.part)}function v(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!pe(t.stage)||!_e(t.violation))return!1;let n=t.violation,r=_.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:!(he.has(n.resource)&&ge.has(n.metric))}function ve(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function ye(e){if(!v(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:ve(t.usage)}};return v(n)?n:void 0}function be(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function y(e){let n=e instanceof Error?e.message:String(e);if(!n.startsWith(le))return;let r;try{r=JSON.parse(n.slice(21))}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(!(i.code!==`ooxml-resource-limit`||!v(i.details)))return new t(be(i.details),i.details)}function xe(n){if(n instanceof c)return{message:n.message,errorName:n.name,code:n.code,decodedImage:{metric:n.metric,limit:n.limit,observed:n.observed}};let r=se(n);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=n instanceof e||n instanceof t?n:y(n);if(i instanceof t){let e=ye(i.details);return e?{message:typeof i.message==`string`?i.message:be(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof e)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:h(i.name,128)?i.name:`OoxmlError`,...g(i.code)?{code:i.code}:{}};let a=n instanceof Error?n.message:String(n);if(typeof a==`string`&&a.startsWith(le))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=n instanceof Error?n:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:h(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function b(e){try{return xe(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}const Se=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`]);function Ce(n){if(n.code===`ooxml-decoded-image-limit`&&n.decodedImage&&(n.decodedImage.metric===`image-pixels`||n.decodedImage.metric===`active-decoded-bytes`)&&m(n.decodedImage.limit)&&m(n.decodedImage.observed)&&n.decodedImage.observed>n.decodedImage.limit)return new c(n.decodedImage.metric,n.decodedImage.limit,n.decodedImage.observed);if(n.code===`ooxml-insufficient-credit`&&f(n.insufficientCredit))return new p(n.insufficientCredit);if(n.code===`ooxml-resource-limit`&&v(n.resourceLimit))return new t(n.message,n.resourceLimit);if(n.code&&Se.has(n.code))return new e(n.code,n.message);let r=n.errorName===`TypeError`?TypeError(n.message):n.errorName===`RangeError`?RangeError(n.message):Error(n.message);return n.errorName&&(r.name=n.errorName),n.code!==void 0&&Object.assign(r,{code:n.code}),r}function we(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}const x=67108864;Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function Te(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const S=`ooxml-pull-v1`;function C(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Ee(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 w=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,C(this.maxRetainedBytes,`max retained lease bytes`),C(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}},De=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){Ee(e.sessionId),C(e.operationId,`operation id`),C(e.generation,`generation`),C(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&C(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=b(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(C(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:S,...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){C(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(C(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:S,...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:S,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}}};function T(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function E(e,t,n){return T(e,`resource measurement`),T(t,`resource measurement`),T(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Oe(e,t=2**53-1){T(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=E(n,a,t),n>t)return n}return n}function D(e,t=2**53-1){T(t,`resource measurement limit`);let n=E(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=E(n,a,t),n>t)return n}return n}function O(e,t){return E(0,e,t)}function k(e,t=2**53-1,n=!1){if(T(t,`resource measurement limit`),e===null)return{jsonBytes:O(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:D(e,t),stringValueUtf8Bytes:Oe(e,t)};if(typeof e==`boolean`)return{jsonBytes:O(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:O((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=O(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=E(n,1,t));let a=k(e[i],t,!0);n=E(n,a.jsonBytes,t),r=E(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=O(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=E(n,1,t)),n=E(n,D(a,t),t),n=E(n,1,t);let e=k(o,t);n=E(n,e.jsonBytes,t),r=E(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?O(4,t):0,stringValueUtf8Bytes:0}}({...i,...s});function*A(e){for(let t of e?.paragraphs??[])for(let e of t.runs)e.type===`text`&&(yield e.text)}function*ke(e){for(let t of e.elements)if(t.type===`shape`)yield*A(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*A(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 Ae=class e{scripts;constructor(e,t,n){this.majorFont=e,this.minorFont=t;let r=a(e)??a(t)??null;this.scripts=n??new ee(r)}addSlide(e){this.scripts.addText(ke(e))}names(){return[this.majorFont,this.minorFont,...this.scripts.names()]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone());return n.addSlide(t),n}};const j=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),M=67108864;function N(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function je(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 Me(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.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return N(t.defaultTextColor,`defaultTextColor`),N(t.majorFont,`majorFont`),N(t.minorFont,`minorFont`),N(t.hlinkColor,`hlinkColor`),N(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,slides:Object.freeze(t.slides.map(je))})}function Ne(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 Pe(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(Ne))})}function Fe(e,n,r){if(!(e<=n))throw new t(`PPTX presentation preflight exceeded its hard limit of ${n} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:n,observed:Math.min(e,n+1),configurable:!1,usage:r}})}var Ie=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;constructor(e,t={}){let n=Me(e),r=t.hardLimitForTesting??M;if(!Number.isSafeInteger(r)||r<=0||r>M)throw Error(`invalid PPTX presentation preflight test limit`);this.limit=r,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.descriptors=[...n.slides],this.fonts=new Ae(this.majorFontValue,this.minorFontValue),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=k(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=k({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,Fe(this.projectionBytesValue,this.limit,j)}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)}addSlide(e,t=j){this.prepareSlide(e,t).commit()}prepareSlide(e,t=j){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=Pe(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=k(o,this.limit).jsonBytes,ee=k(i,this.limit).jsonBytes,c=this.projectionBytesValue-this.fontProjectionBytes-k(r,this.limit).jsonBytes+4;c=E(c,s,this.limit),c=E(c,ee,this.limit),this.slides.length!==0&&(c=E(c,1,this.limit));let te=k({slide:i,fontPreloadNames:o},this.limit).jsonBytes,l=E(this.projectionBytesValue,te,this.limit);Fe(Math.max(l,c),this.limit,t);let u={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:c};return this.pending=u,{projectedBytes:l,commit:()=>{if(u.state!==`committed`){if(u.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==u)throw Error(`PPTX presentation preflight prepared slide is stale`);this.descriptors[n]=void 0,this.slides.push(u.fact),this.fonts=u.fonts,this.fontPreloadNames=u.fontNames,this.fontProjectionBytes=u.fontBytes,this.projectionBytesValue=u.committedBytes,u.state=`committed`,this.pending=null}},rollback:()=>{if(u.state!==`rolled-back`){if(u.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==u)throw Error(`PPTX presentation preflight prepared slide is stale`);u.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,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames}),this.descriptors=[],this.slides=[],this.projectionBytesValue=k(this.finished,this.limit).jsonBytes,this.finished}};function Le(e){try{return de(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function Re(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,Le(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}}var ze=class{coordinatorGeneration=new w;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(),Ve(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||!P(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 De({...t,maxByteCredit:x,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 ce(e,n,x)||(this.latchResourceFailure(e),e)}let o=we(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{Re(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=P(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:S,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:S,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(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:S,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=Ce(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 w,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&&!P(t,e)?this.staleLifecycleResponse(e):{protocol:S,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:S,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:b(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:S,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&P(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return Le(this.executeArchive)}latchResourceFailure(e){let n=e instanceof t?e:y(e);n&&(this.resourceFailure??=n)}staleLifecycleResponse(e){return{protocol:S,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 Be(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function Ve(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 P(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var F=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ue.unregister(this),e}free(){let e=this.__destroy_into_raw();J.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=J.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw U(n[0])}assert_healthy(){let e=J.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw U(e[0])}cancel_slide(){J.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){J.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_image(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=Ge(e,J.__wbindgen_malloc),a=q,o=J.pptxarchive_new(i,a,!V(t),V(t)?BigInt(0):t,!V(n),V(n)?BigInt(0):n,!V(r),V(r)?BigInt(0):r);if(o[2])throw U(o[1]);return this.__wbg_ptr=o[0]>>>0,Ue.register(this,this.__wbg_ptr,this),this}parse(){let e=J.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=J.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=J.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw U(i[2]);var a=I(i[0],i[1]).slice();return J.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=J.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=J.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=J.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,U(i[2]);return e=n,t=r,R(n,r)}finally{J.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function He(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(R(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(R(e,t))}finally{J.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=H(n,J.__wbindgen_malloc,J.__wbindgen_realloc),i=q;We().setInt32(e+4,i,!0),We().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return R(e,t)},__wbindgen_init_externref_table:function(){let e=J.__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 Ue=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>J.__wbg_pptxarchive_free(e>>>0,1));function I(e,t){return e>>>=0,B().subarray(e/1,e/1+t)}let L=null;function We(){return(L===null||L.buffer.detached===!0||L.buffer.detached===void 0&&L.buffer!==J.memory.buffer)&&(L=new DataView(J.memory.buffer)),L}function R(e,t){return e>>>=0,Ke(e,t)}let z=null;function B(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(J.memory.buffer)),z}function V(e){return e==null}function Ge(e,t){let n=t(e.length*1,1)>>>0;return B().set(e,n/1),q=e.length,n}function H(e,t,n){if(n===void 0){let n=K.encode(e),r=t(n.length,1)>>>0;return B().subarray(r,r+n.length).set(n),q=n.length,r}let r=e.length,i=t(r,1)>>>0,a=B(),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=B().subarray(i+o,i+r),a=K.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return q=o,i}function U(e){let t=J.__wbindgen_externrefs.get(e);return J.__externref_table_dealloc(e),t}let W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});W.decode();let G=0;function Ke(e,t){return G+=t,G>=2146435072&&(W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),W.decode(),G=t),W.decode(B().subarray(e,e+t))}const K=new TextEncoder;`encodeInto`in K||(K.encodeInto=function(e,t){let n=K.encode(e);return t.set(n),{read:e.length,written:n.length}});let q=0,J;function qe(e,t){return J=e.exports,L=null,z=null,J.__wbindgen_start(),J}async function Je(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 Ye(e){if(J!==void 0)return J;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=He();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Je(await e,t);return qe(n,r)}async function Xe(e){return J=void 0,L=null,z=null,Ye(e)}const Y=new ae(Ye,{freeArchive:e=>e.free(),reinit:Xe});let X=null,Z=`empty`;function Ze(){if(Z!==`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`})}Z=`opening`}const Q=new ze(()=>Y.archive,(e,t,n)=>{if(X){if(e!==X.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${X.acceptedSlideCount}, received ${e}`);return X.prepareSlide(t,n)}},e=>{let t=Y.archive;if(!t)throw Error(`Presentation not loaded`);return Y.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(Be(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){Y.setWasmInput(te(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(Ze(),r=!0),t.kind===`openSlideSession`){await Y.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,...b(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await Y.ensureReady(),t.kind!==`parse`&&Y.archive){let e=Y.archive;Y.run(()=>e.assert_healthy())}if(t.kind===`parse`){X=null;let[e,r,i]=Te(t.resourcePolicy),a=Y.run(()=>{let n=new F(new Uint8Array(t.buffer),e,r,i);return Y.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});X=new Ie(a),$({kind:`presentationOpened`,id:n,bootstrap:a}),Z=`ready`;return}let e=Y.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!X)throw Error(`PPTX presentation preflight is not active`);let e=X.finish();X=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=Y.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=Y.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:de(Y.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:Y.run(()=>e.to_markdown())})})}catch(e){r&&(Z=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...b(e)})}catch{}}};", $e = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Qe], { type: "text/javascript;charset=utf-8" });
|
|
543
|
+
function et(e) {
|
|
536
544
|
let t;
|
|
537
545
|
try {
|
|
538
|
-
if (t =
|
|
546
|
+
if (t = $e && (self.URL || self.webkitURL).createObjectURL($e), !t) throw "";
|
|
539
547
|
let n = new Worker(t, {
|
|
540
548
|
type: "module",
|
|
541
549
|
name: e?.name
|
|
@@ -544,7 +552,7 @@ function Ge(e) {
|
|
|
544
552
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
545
553
|
}), n;
|
|
546
554
|
} catch {
|
|
547
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
555
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Qe), {
|
|
548
556
|
type: "module",
|
|
549
557
|
name: e?.name
|
|
550
558
|
});
|
|
@@ -552,7 +560,154 @@ function Ge(e) {
|
|
|
552
560
|
}
|
|
553
561
|
//#endregion
|
|
554
562
|
//#region packages/pptx/src/wasm/pptx_parser_bg.wasm?url
|
|
555
|
-
var
|
|
563
|
+
var tt = new URL("pptx_parser_bg.wasm", import.meta.url).href, J = 65536, nt = 16384, rt = new Set(["line", "straightconnector1"]);
|
|
564
|
+
function it(e, t) {
|
|
565
|
+
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;
|
|
566
|
+
return e.flipH && (l = 2 * n - l), e.flipV && (u = 2 * r - u), {
|
|
567
|
+
x: l,
|
|
568
|
+
y: u
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function at(e, t, n) {
|
|
572
|
+
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
573
|
+
if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
|
|
574
|
+
let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a));
|
|
575
|
+
return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
576
|
+
}
|
|
577
|
+
function ot(e, t, n = 0) {
|
|
578
|
+
if (!Number.isFinite(t.x) || !Number.isFinite(t.y)) return !1;
|
|
579
|
+
let r = it(e, t), i = Number.isFinite(n) && n > 0 ? n : 0;
|
|
580
|
+
if (e.type === "shape" && (rt.has(e.geometry.toLowerCase()) || e.width === 0 || e.height === 0)) return at(r, {
|
|
581
|
+
x: e.x,
|
|
582
|
+
y: e.y
|
|
583
|
+
}, {
|
|
584
|
+
x: e.x + e.width,
|
|
585
|
+
y: e.y + e.height
|
|
586
|
+
}) <= i;
|
|
587
|
+
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);
|
|
588
|
+
return r.x >= a && r.x <= o && r.y >= s && r.y <= c;
|
|
589
|
+
}
|
|
590
|
+
function* st(e) {
|
|
591
|
+
if (e) for (let t of e.paragraphs) {
|
|
592
|
+
let e = !0;
|
|
593
|
+
for (let n of t.runs) {
|
|
594
|
+
let t = n.type === "text" ? n.text : n.type === "break" ? "\n" : "[equation]";
|
|
595
|
+
t && (yield {
|
|
596
|
+
text: t,
|
|
597
|
+
beginsPart: e
|
|
598
|
+
}, e = !1);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function* ct(e) {
|
|
603
|
+
if (e.type === "shape") {
|
|
604
|
+
yield* st(e.textBody);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (e.type === "table") {
|
|
608
|
+
for (let t of e.rows) for (let e of t.cells) yield* st(e.textBody);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function lt(e, t) {
|
|
613
|
+
let n = Math.min(e.length, t);
|
|
614
|
+
if (n > 0 && n < e.length) {
|
|
615
|
+
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
616
|
+
t >= 55296 && t <= 56319 && r >= 56320 && r <= 57343 && n--;
|
|
617
|
+
}
|
|
618
|
+
return e.slice(0, n);
|
|
619
|
+
}
|
|
620
|
+
function ut(e, t = nt) {
|
|
621
|
+
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
622
|
+
let n = Math.min(J, Math.floor(t)), r = e.text, i = r === void 0 ? void 0 : lt(r, n), a = r !== void 0 && i.length < r.length;
|
|
623
|
+
return {
|
|
624
|
+
...structuredClone(e),
|
|
625
|
+
...i === void 0 ? {} : { text: i },
|
|
626
|
+
truncated: e.truncated || a,
|
|
627
|
+
truncationReasons: e.truncated || a ? ["text"] : [],
|
|
628
|
+
textCharacters: i?.length ?? 0,
|
|
629
|
+
maxTextCharacters: n
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function dt(e, t) {
|
|
633
|
+
let n = [], r = 0, i = !1, a = !1;
|
|
634
|
+
for (let o of e) {
|
|
635
|
+
if (a = !0, o.beginsPart && n.length > 0) {
|
|
636
|
+
if (r >= t) {
|
|
637
|
+
i = !0;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
n.push("\n"), r++;
|
|
641
|
+
}
|
|
642
|
+
let e = Math.max(0, t - r), s = lt(o.text, e);
|
|
643
|
+
if (n.push(s), r += s.length, s.length < o.text.length) {
|
|
644
|
+
i = !0;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return a ? {
|
|
649
|
+
text: n.join(""),
|
|
650
|
+
truncated: i,
|
|
651
|
+
textCharacters: r
|
|
652
|
+
} : {
|
|
653
|
+
truncated: !1,
|
|
654
|
+
textCharacters: 0
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function ft(e, t, n, r = {}) {
|
|
658
|
+
if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) throw RangeError("PPTX hit-test point must contain finite coordinates.");
|
|
659
|
+
let i = r.maxTextCharacters ?? nt;
|
|
660
|
+
if (!Number.isFinite(i) || i < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
661
|
+
let a = Math.min(J, Math.floor(i)), o = r.tolerance ?? 0;
|
|
662
|
+
if (!Number.isFinite(o) || o < 0) throw RangeError("tolerance must be a finite non-negative number.");
|
|
663
|
+
for (let r = t.elements.length - 1; r >= 0; r--) {
|
|
664
|
+
let i = t.elements[r];
|
|
665
|
+
if (!ot(i, n, o)) continue;
|
|
666
|
+
let s = i.type === "chart" ? oe(i.chart, a) : dt(ct(i), a);
|
|
667
|
+
return {
|
|
668
|
+
format: "pptx",
|
|
669
|
+
kind: "element",
|
|
670
|
+
slideIndex: e,
|
|
671
|
+
elementIndex: r,
|
|
672
|
+
origin: t.elementSources?.[r]?.origin ?? "unknown",
|
|
673
|
+
elementType: i.type,
|
|
674
|
+
point: { ...n },
|
|
675
|
+
bounds: {
|
|
676
|
+
x: i.x,
|
|
677
|
+
y: i.y,
|
|
678
|
+
width: i.width,
|
|
679
|
+
height: i.height,
|
|
680
|
+
rotation: i.rotation,
|
|
681
|
+
flipH: i.flipH,
|
|
682
|
+
flipV: i.flipV
|
|
683
|
+
},
|
|
684
|
+
...i.type === "shape" ? {
|
|
685
|
+
...i.id === void 0 ? {} : { shapeId: i.id },
|
|
686
|
+
...i.name === void 0 ? {} : { name: i.name },
|
|
687
|
+
geometry: i.geometry
|
|
688
|
+
} : {},
|
|
689
|
+
...s.text === void 0 ? {} : { text: s.text },
|
|
690
|
+
...i.type === "picture" ? { mimeType: i.mimeType } : {},
|
|
691
|
+
...i.type === "media" ? {
|
|
692
|
+
mimeType: i.mimeType,
|
|
693
|
+
mediaKind: i.mediaKind
|
|
694
|
+
} : {},
|
|
695
|
+
...i.type === "table" ? {
|
|
696
|
+
rowCount: i.rows.length,
|
|
697
|
+
columnCount: i.cols.length
|
|
698
|
+
} : {},
|
|
699
|
+
...i.type === "chart" ? { seriesCount: i.chart.series.length } : {},
|
|
700
|
+
truncated: s.truncated,
|
|
701
|
+
truncationReasons: s.truncated ? ["text"] : [],
|
|
702
|
+
textCharacters: s.textCharacters,
|
|
703
|
+
maxTextCharacters: a
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region packages/pptx/src/presentation.ts
|
|
710
|
+
var Y = class e {
|
|
556
711
|
_metrics = null;
|
|
557
712
|
_worker;
|
|
558
713
|
_bridge;
|
|
@@ -562,7 +717,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
562
717
|
_slidePullClient = null;
|
|
563
718
|
_resourceFailure = null;
|
|
564
719
|
_slidePartIndex = null;
|
|
565
|
-
_rawParts = new
|
|
720
|
+
_rawParts = new Se({
|
|
566
721
|
maxEntries: 64,
|
|
567
722
|
maxBytes: T
|
|
568
723
|
});
|
|
@@ -571,11 +726,11 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
571
726
|
_fetchMedia = (e) => this.getMedia(e);
|
|
572
727
|
_math;
|
|
573
728
|
constructor(e, t, n) {
|
|
574
|
-
this._worker = e, this._mode = t, this._bridge = new
|
|
729
|
+
this._worker = e, this._mode = t, this._bridge = new te(this._worker, {
|
|
575
730
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
576
731
|
toError: (e) => !("protocol" in e) && e.kind === "error" ? S(e) : void 0
|
|
577
732
|
});
|
|
578
|
-
let r = new URL(n ??
|
|
733
|
+
let r = new URL(n ?? tt, location.href).href;
|
|
579
734
|
this._bridge.post({
|
|
580
735
|
kind: "init",
|
|
581
736
|
wasmUrl: r
|
|
@@ -605,13 +760,13 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
605
760
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
606
761
|
s = await e.arrayBuffer();
|
|
607
762
|
} else s = t;
|
|
608
|
-
s =
|
|
609
|
-
let c = i === "worker" ? (await import("./render-worker-host-
|
|
763
|
+
s = ne(await ie(s, n.password)), a.setSourceBytes(s.byteLength), a.checkpoint("container ready");
|
|
764
|
+
let c = i === "worker" ? (await import("./render-worker-host-EHG5j8FK.js")).createRenderWorker() : new et(), l;
|
|
610
765
|
try {
|
|
611
|
-
return l = new e(c, i, n.wasmUrl), l._metrics = a, n.math && i === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), l._math = i === "worker" ? void 0 : n.math, await l._parse(s, r.policy, i === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => a.observeUsage(e)), a.checkpoint("presentation preflight ready"), i === "main" && n.useGoogleFonts && l._preflight && (l._googleFontFaces = await
|
|
766
|
+
return l = new e(c, i, n.wasmUrl), l._metrics = a, n.math && i === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), l._math = i === "worker" ? void 0 : n.math, await l._parse(s, r.policy, i === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => a.observeUsage(e)), a.checkpoint("presentation preflight ready"), i === "main" && n.useGoogleFonts && l._preflight && (l._googleFontFaces = await be(l._preflight.fontPreloadNames, o)), a.succeed({ slides: l.slideCount }), l;
|
|
612
767
|
} catch (e) {
|
|
613
768
|
let t = l;
|
|
614
|
-
throw
|
|
769
|
+
throw re(c, t ? () => t.destroy() : void 0), e;
|
|
615
770
|
}
|
|
616
771
|
} catch (e) {
|
|
617
772
|
throw a.fail(e), e;
|
|
@@ -653,7 +808,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
653
808
|
this._preflight = t((await this._bridge.request((e) => ({
|
|
654
809
|
kind: "finishPresentationPreflight",
|
|
655
810
|
id: e
|
|
656
|
-
}), void 0, { timeoutMs: o })).preflight), this._slides = new
|
|
811
|
+
}), void 0, { timeoutMs: o })).preflight), this._slides = new Xe({
|
|
657
812
|
slideCount: this._preflight.slideCount,
|
|
658
813
|
maxCachedSlides: 8,
|
|
659
814
|
maxCachedStructuralBytes: f,
|
|
@@ -686,13 +841,13 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
686
841
|
return (this._preflight?.slides ?? []).map((e) => e.partName);
|
|
687
842
|
}
|
|
688
843
|
_partIndex() {
|
|
689
|
-
return this._slidePartIndex ||=
|
|
844
|
+
return this._slidePartIndex ||= qe(this._partNames()), this._slidePartIndex;
|
|
690
845
|
}
|
|
691
846
|
getSlideIndexByPartName(e) {
|
|
692
847
|
return this._partIndex().get(e);
|
|
693
848
|
}
|
|
694
849
|
resolveInternalTarget(e, t = 0) {
|
|
695
|
-
return
|
|
850
|
+
return Ye(e, this._partIndex(), t);
|
|
696
851
|
}
|
|
697
852
|
async renderSlide(e, t, r = {}) {
|
|
698
853
|
this._assertResourceHealthy();
|
|
@@ -769,6 +924,22 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
769
924
|
this._rethrowWithResourceFailure(e);
|
|
770
925
|
}
|
|
771
926
|
}
|
|
927
|
+
async getElementContextAt(e, t, n = {}) {
|
|
928
|
+
if (this._assertResourceHealthy(), !Number.isInteger(e) || e < 0 || e >= this.slideCount) throw Error(`Slide index ${e} out of range (count: ${this.slideCount})`);
|
|
929
|
+
try {
|
|
930
|
+
if (this._mode === "worker") return (await this._bridge.request((r) => ({
|
|
931
|
+
kind: "hitTestElement",
|
|
932
|
+
id: r,
|
|
933
|
+
slideIndex: e,
|
|
934
|
+
point: t,
|
|
935
|
+
options: n
|
|
936
|
+
}))).context;
|
|
937
|
+
if (!this._slides) throw Error("Presentation not loaded");
|
|
938
|
+
return await this._slides.withSlide(e, (r) => ft(e, r, t, n));
|
|
939
|
+
} catch (e) {
|
|
940
|
+
this._rethrowWithResourceFailure(e);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
772
943
|
async getMedia(e) {
|
|
773
944
|
this._assertResourceHealthy();
|
|
774
945
|
try {
|
|
@@ -846,7 +1017,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
846
1017
|
dim: n.dim,
|
|
847
1018
|
onTextRun: n.onTextRun
|
|
848
1019
|
});
|
|
849
|
-
return await
|
|
1020
|
+
return await Me(e, this._preflight.slides[t]?.mediaElements ?? [], {
|
|
850
1021
|
width: i,
|
|
851
1022
|
dpr: r,
|
|
852
1023
|
slideWidthEmu: this.slideWidth,
|
|
@@ -860,18 +1031,70 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
860
1031
|
}
|
|
861
1032
|
}
|
|
862
1033
|
destroy() {
|
|
863
|
-
this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._preflight = null, this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFontFaces.length > 0 && (
|
|
1034
|
+
this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._preflight = null, this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFontFaces.length > 0 && (ye(this._googleFontFaces), this._googleFontFaces = []), C(this._fetchImage), d(this._fetchImage);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region packages/pptx/src/selection-context.ts
|
|
1039
|
+
function X(e) {
|
|
1040
|
+
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1041
|
+
let t = Number(e);
|
|
1042
|
+
return Number.isSafeInteger(t) ? t : null;
|
|
1043
|
+
}
|
|
1044
|
+
function pt(e) {
|
|
1045
|
+
for (let t = e; t; t = t.parentElement) {
|
|
1046
|
+
let e = X(t.dataset.slideIndex);
|
|
1047
|
+
if (e !== null) return e;
|
|
864
1048
|
}
|
|
865
|
-
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
1051
|
+
function Z(e, t, n = {}) {
|
|
1052
|
+
let r = he(e, t, (e) => {
|
|
1053
|
+
let t = pt(e), n = X(e.dataset.runIndex);
|
|
1054
|
+
if (t === null || n === null) return null;
|
|
1055
|
+
let r = X(e.dataset.elementIndex), i = e.dataset.elementOrigin, a = r !== null && (i === "master" || i === "layout" || i === "slide");
|
|
1056
|
+
return {
|
|
1057
|
+
slideIndex: t,
|
|
1058
|
+
runIndex: n,
|
|
1059
|
+
...e.dataset.shapeId === void 0 ? {} : { shapeId: e.dataset.shapeId },
|
|
1060
|
+
...a ? {
|
|
1061
|
+
elementIndex: r,
|
|
1062
|
+
origin: i
|
|
1063
|
+
} : {}
|
|
1064
|
+
};
|
|
1065
|
+
}, {
|
|
1066
|
+
maxChars: n.maxTextCharacters,
|
|
1067
|
+
maxLocators: n.maxRunLocators
|
|
1068
|
+
});
|
|
1069
|
+
if (!r) return null;
|
|
1070
|
+
let i = [...r.locators].sort((e, t) => e.slideIndex - t.slideIndex || e.runIndex - t.runIndex);
|
|
1071
|
+
return {
|
|
1072
|
+
format: "pptx",
|
|
1073
|
+
kind: "text",
|
|
1074
|
+
text: r.text,
|
|
1075
|
+
slideIndexes: [...new Set(i.map((e) => e.slideIndex))],
|
|
1076
|
+
shapeIds: [...new Set(i.flatMap((e) => e.shapeId ? [e.shapeId] : []))],
|
|
1077
|
+
runs: i,
|
|
1078
|
+
truncated: r.truncated,
|
|
1079
|
+
truncationReasons: r.truncationReasons,
|
|
1080
|
+
textCharacters: r.textCharacters,
|
|
1081
|
+
maxTextCharacters: r.maxTextCharacters,
|
|
1082
|
+
maxRunLocators: r.maxLocators
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region packages/pptx/src/viewer.ts
|
|
1087
|
+
var Q = Symbol("PptxViewer.borrowedPresentation"), mt = {
|
|
866
1088
|
color: "#ffffff",
|
|
867
1089
|
opacity: .6
|
|
868
|
-
},
|
|
1090
|
+
}, ht = class e {
|
|
869
1091
|
canvas;
|
|
870
1092
|
wrapper;
|
|
871
1093
|
canvasMount;
|
|
872
1094
|
_scale = null;
|
|
873
1095
|
textLayer = null;
|
|
874
1096
|
highlightLayer = null;
|
|
1097
|
+
elementLayer = null;
|
|
875
1098
|
_find;
|
|
876
1099
|
_measureCtx = null;
|
|
877
1100
|
presentationOwner;
|
|
@@ -888,30 +1111,44 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
888
1111
|
renderDispatcher;
|
|
889
1112
|
errorRouter;
|
|
890
1113
|
destroyed = !1;
|
|
1114
|
+
selectionChangeListener = null;
|
|
1115
|
+
selectionContextKey = "null";
|
|
1116
|
+
elementClickListener = null;
|
|
1117
|
+
contextMenuListener = null;
|
|
1118
|
+
elementContext = null;
|
|
1119
|
+
elementHitGeneration = 0;
|
|
1120
|
+
elementHitTolerance;
|
|
891
1121
|
static fromPresentation(t, n, r = {}) {
|
|
892
1122
|
return new e(t, {
|
|
893
1123
|
...r,
|
|
894
|
-
[
|
|
1124
|
+
[Q]: n
|
|
895
1125
|
});
|
|
896
1126
|
}
|
|
897
1127
|
constructor(e, t = {}) {
|
|
898
1128
|
this.opts = t, this.canvas = e;
|
|
899
|
-
let n = t[
|
|
900
|
-
this.borrowed = n !== void 0, this._mode =
|
|
1129
|
+
let n = t[Q];
|
|
1130
|
+
this.borrowed = n !== void 0, this._mode = A("PptxViewer", t.mode, n), this.presentationOwner = new D("PptxViewer", n ?? null, !1);
|
|
901
1131
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
902
1132
|
if (!r) throw Error("PptxViewer requires a canvas with an active Window");
|
|
903
|
-
this.hostWindow = r
|
|
1133
|
+
this.hostWindow = r;
|
|
1134
|
+
let i = t.elementHitTolerance ?? 6;
|
|
1135
|
+
if (!Number.isFinite(i) || i < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
1136
|
+
this.elementHitTolerance = i, this._hiddenMode = t.hiddenSlideMode ?? "show", this.canvasMount = new ge(e, {
|
|
904
1137
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
905
1138
|
forceDisplayBlock: !0
|
|
906
|
-
}), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new
|
|
907
|
-
let
|
|
908
|
-
this.textLayer =
|
|
1139
|
+
}), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new k(e, this._mode === "worker" && !t.enableMediaPlayback), this.errorRouter = new me("PptxViewer", t.onError);
|
|
1140
|
+
let a = new de(this.wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1141
|
+
this.textLayer = a.textLayer, this.highlightLayer = a.highlightLayer, this.elementLayer = a.elementLayer, this.textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this.selectionChangeListener = () => this._emitSelectionContextChange(), this.wrapper.ownerDocument.addEventListener("selectionchange", this.selectionChangeListener)), t.enableElementSelection && (this.elementClickListener = (e) => {
|
|
1142
|
+
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1143
|
+
}, this.wrapper.addEventListener("click", this.elementClickListener)), t.onContextMenu && (this.contextMenuListener = (e) => this._onContextMenu(e), this.wrapper.addEventListener("contextmenu", this.contextMenuListener)), this._find = new z(() => this.slideCount, (e) => this._collectSlideRuns(e));
|
|
909
1144
|
}
|
|
910
1145
|
async load(e) {
|
|
911
1146
|
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
912
1147
|
if (this.borrowed) throw Error("PptxViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.");
|
|
1148
|
+
let t = !1;
|
|
913
1149
|
try {
|
|
914
|
-
if (!await this.presentationOwner.replace(() =>
|
|
1150
|
+
if (!await this.presentationOwner.replace(() => Y.load(e, {
|
|
1151
|
+
password: this.opts.password,
|
|
915
1152
|
useGoogleFonts: this.opts.useGoogleFonts,
|
|
916
1153
|
maxZipEntryBytes: this.opts.maxZipEntryBytes,
|
|
917
1154
|
resourceLimits: this.opts.resourceLimits,
|
|
@@ -922,22 +1159,19 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
922
1159
|
math: this.opts.math,
|
|
923
1160
|
mode: this._mode
|
|
924
1161
|
}), () => {
|
|
925
|
-
this.renderDispatcher.begin(), this._find.invalidate(), this.handle?.destroy(), this.handle = null;
|
|
1162
|
+
this._invalidateElementSelection(!1), t = !0, this.renderDispatcher.begin(), this._find.invalidate(), this.handle?.destroy(), this.handle = null;
|
|
926
1163
|
})) return;
|
|
927
1164
|
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
928
1165
|
this.currentSlide = this._initialSlide(), this._find.invalidate(), await this.renderCurrentSlide();
|
|
929
1166
|
} catch (e) {
|
|
930
|
-
|
|
931
|
-
let t = e instanceof Error ? e : Error(String(e));
|
|
932
|
-
if (this.opts.onError) {
|
|
933
|
-
this.opts.onError(t);
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
throw t;
|
|
1167
|
+
throw this.destroyed ? Error("PptxViewer is destroyed") : e instanceof Error ? e : Error(String(e));
|
|
937
1168
|
}
|
|
1169
|
+
t && !this.destroyed && this._emitSelectionContextChange();
|
|
938
1170
|
}
|
|
939
1171
|
async goToSlide(e) {
|
|
940
|
-
!this.engine || this.slideCount === 0
|
|
1172
|
+
if (!this.engine || this.slideCount === 0) return;
|
|
1173
|
+
let t = Math.max(0, Math.min(e, this.slideCount - 1)), n = t !== this.currentSlide;
|
|
1174
|
+
n && this._invalidateElementSelection(!1), this.currentSlide = t, await this.renderCurrentSlide(), n && !this.destroyed && this._emitSelectionContextChange();
|
|
941
1175
|
}
|
|
942
1176
|
async nextSlide() {
|
|
943
1177
|
await this.goToSlide(this._step(1));
|
|
@@ -946,19 +1180,23 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
946
1180
|
await this.goToSlide(this._step(-1));
|
|
947
1181
|
}
|
|
948
1182
|
_step(e) {
|
|
949
|
-
return this._hiddenMode === "skip" && this.engine ?
|
|
1183
|
+
return this._hiddenMode === "skip" && this.engine ? we(this.currentSlide, e, (e) => this.engine.isHidden(e), this.slideCount) : this.currentSlide + e;
|
|
950
1184
|
}
|
|
951
1185
|
_initialSlide() {
|
|
952
|
-
return this._hiddenMode === "skip" && this.engine ?
|
|
1186
|
+
return this._hiddenMode === "skip" && this.engine ? N(0, (e) => this.engine.isHidden(e), this.slideCount) : 0;
|
|
953
1187
|
}
|
|
954
1188
|
_dim() {
|
|
955
1189
|
return {
|
|
956
|
-
color: this.opts.hiddenSlideDim?.color ??
|
|
957
|
-
opacity: this.opts.hiddenSlideDim?.opacity ??
|
|
1190
|
+
color: this.opts.hiddenSlideDim?.color ?? mt.color,
|
|
1191
|
+
opacity: this.opts.hiddenSlideDim?.opacity ?? mt.opacity
|
|
958
1192
|
};
|
|
959
1193
|
}
|
|
960
1194
|
async setHiddenSlideMode(e) {
|
|
961
|
-
this._hiddenMode = e
|
|
1195
|
+
this._hiddenMode = e;
|
|
1196
|
+
let t = this.currentSlide;
|
|
1197
|
+
e === "skip" && this.engine && (t = N(this.currentSlide, (e) => this.engine.isHidden(e), this.slideCount));
|
|
1198
|
+
let n = t !== this.currentSlide;
|
|
1199
|
+
n && this._invalidateElementSelection(!1), this.currentSlide = t, await this.renderCurrentSlide(), n && !this.destroyed && this._emitSelectionContextChange();
|
|
962
1200
|
}
|
|
963
1201
|
get hiddenSlideMode() {
|
|
964
1202
|
return this._hiddenMode;
|
|
@@ -966,7 +1204,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
966
1204
|
get visibleSlideCount() {
|
|
967
1205
|
if (!this.engine) return 0;
|
|
968
1206
|
let e = this.engine;
|
|
969
|
-
return
|
|
1207
|
+
return Te((t) => e.isHidden(t), this.slideCount);
|
|
970
1208
|
}
|
|
971
1209
|
get slideIndex() {
|
|
972
1210
|
return this.currentSlide;
|
|
@@ -1001,14 +1239,14 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1001
1239
|
return this.opts.zoomMax ?? 4;
|
|
1002
1240
|
}
|
|
1003
1241
|
async setScale(e) {
|
|
1004
|
-
let t =
|
|
1242
|
+
let t = ce(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1005
1243
|
this._scale = t, await this.renderCurrentSlide(), n && this.opts.onScaleChange?.(t);
|
|
1006
1244
|
}
|
|
1007
1245
|
async zoomIn() {
|
|
1008
|
-
await this.setScale(
|
|
1246
|
+
await this.setScale(j(this.getScale()));
|
|
1009
1247
|
}
|
|
1010
1248
|
async zoomOut() {
|
|
1011
|
-
await this.setScale(
|
|
1249
|
+
await this.setScale(M(this.getScale()));
|
|
1012
1250
|
}
|
|
1013
1251
|
async fitWidth() {
|
|
1014
1252
|
await this._fit("width");
|
|
@@ -1020,7 +1258,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1020
1258
|
if (!this.engine) return;
|
|
1021
1259
|
let t = this.wrapper.parentElement;
|
|
1022
1260
|
if (!t) return;
|
|
1023
|
-
let n =
|
|
1261
|
+
let n = E({
|
|
1024
1262
|
contentWidth: this.engine.slideWidth / x,
|
|
1025
1263
|
contentHeight: this.engine.slideHeight / x,
|
|
1026
1264
|
containerWidth: t.clientWidth,
|
|
@@ -1065,14 +1303,14 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1065
1303
|
}), !this.renderDispatcher.isCurrent(e)) return;
|
|
1066
1304
|
this.opts.onSlideChange?.(this.currentSlide, this.slideCount);
|
|
1067
1305
|
} catch (t) {
|
|
1068
|
-
this.renderDispatcher.isCurrent(e)
|
|
1069
|
-
|
|
1306
|
+
if (!this.renderDispatcher.isCurrent(e)) return;
|
|
1307
|
+
throw t;
|
|
1070
1308
|
}
|
|
1071
1309
|
this.textLayer && this._buildTextLayer(this.textLayer, s, n, a), this._find.setSlideRuns(this.currentSlide, s), this._buildHighlightLayer(s, n, a);
|
|
1072
1310
|
}
|
|
1073
1311
|
_buildHighlightLayer(e, t, n) {
|
|
1074
1312
|
let r = this.highlightLayer;
|
|
1075
|
-
r &&
|
|
1313
|
+
r && R(r, e, this._find.slideHighlights(this.currentSlide), t, n, (e) => this._measureForFont(e), this.opts.findHighlightColors);
|
|
1076
1314
|
}
|
|
1077
1315
|
_measureForFont(e) {
|
|
1078
1316
|
this._measureCtx ||= document.createElement("canvas").getContext("2d");
|
|
@@ -1104,7 +1342,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1104
1342
|
this._buildHighlightLayer(e, t, n);
|
|
1105
1343
|
}
|
|
1106
1344
|
_buildTextLayer(e, t, n, r) {
|
|
1107
|
-
|
|
1345
|
+
L(e, t, n, r, this._hyperlinkHandler(), this.currentSlide);
|
|
1108
1346
|
}
|
|
1109
1347
|
_hyperlinkHandler() {
|
|
1110
1348
|
if (this.opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
|
|
@@ -1119,7 +1357,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1119
1357
|
g(t.url, void 0, this.hostWindow);
|
|
1120
1358
|
return;
|
|
1121
1359
|
}
|
|
1122
|
-
t.slideIndex !== void 0 && this.goToSlide(t.slideIndex);
|
|
1360
|
+
t.slideIndex !== void 0 && this.goToSlide(t.slideIndex).catch((e) => this._reportRenderError(e));
|
|
1123
1361
|
}
|
|
1124
1362
|
_resolveInternalSlideIndex(e) {
|
|
1125
1363
|
if (e.kind !== "internal" || e.slideIndex !== void 0) return e;
|
|
@@ -1136,10 +1374,74 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1136
1374
|
if (!this.engine) throw Error("Presentation not loaded");
|
|
1137
1375
|
return await this.engine.getResourceMetrics();
|
|
1138
1376
|
}
|
|
1377
|
+
getSelectionContext(e = {}) {
|
|
1378
|
+
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
1379
|
+
return (this.textLayer ? Z(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this.elementContext ? ut(this.elementContext, e.maxTextCharacters) : null);
|
|
1380
|
+
}
|
|
1381
|
+
_emitSelectionContextChange() {
|
|
1382
|
+
let e = this.getSelectionContext();
|
|
1383
|
+
e?.kind === "text" && (this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline());
|
|
1384
|
+
let t = JSON.stringify(e);
|
|
1385
|
+
t !== this.selectionContextKey && (this.selectionContextKey = t, this.opts.onSelectionContextChange?.(e ? structuredClone(e) : null));
|
|
1386
|
+
}
|
|
1387
|
+
_setElementContext(e) {
|
|
1388
|
+
this.elementContext = e ? structuredClone(e) : null, this._redrawElementOutline(), this._emitSelectionContextChange();
|
|
1389
|
+
}
|
|
1390
|
+
_invalidateElementSelection(e = !0) {
|
|
1391
|
+
this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline(), e && this._emitSelectionContextChange();
|
|
1392
|
+
}
|
|
1393
|
+
_redrawElementOutline() {
|
|
1394
|
+
let e = this.elementContext, t = this.engine;
|
|
1395
|
+
if (!e || !t || e.slideIndex !== this.currentSlide) {
|
|
1396
|
+
O(this.elementLayer, null);
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
O(this.elementLayer, {
|
|
1400
|
+
x: e.bounds.x / t.slideWidth,
|
|
1401
|
+
y: e.bounds.y / t.slideHeight,
|
|
1402
|
+
width: e.bounds.width / t.slideWidth,
|
|
1403
|
+
height: e.bounds.height / t.slideHeight,
|
|
1404
|
+
rotation: e.bounds.rotation
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
async _onElementClick(e) {
|
|
1408
|
+
this.destroyed || e.defaultPrevented || e.button !== 0 || await this._resolveContextAt(e);
|
|
1409
|
+
}
|
|
1410
|
+
_onContextMenu(e) {
|
|
1411
|
+
let t;
|
|
1412
|
+
this.opts.onContextMenu?.({
|
|
1413
|
+
originalEvent: e,
|
|
1414
|
+
getContext: () => t ??= this._resolveContextAt(e)
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
async _resolveContextAt(e) {
|
|
1418
|
+
let t = this.engine;
|
|
1419
|
+
if (this.destroyed || !t) return null;
|
|
1420
|
+
if (this.textLayer && Z(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null)) return this._emitSelectionContextChange(), this.destroyed ? null : this.getSelectionContext();
|
|
1421
|
+
if (!this.opts.enableElementSelection) return this.getSelectionContext();
|
|
1422
|
+
let n = this.canvas.getBoundingClientRect();
|
|
1423
|
+
if (n.width <= 0 || n.height <= 0) return this._invalidateElementSelection(), null;
|
|
1424
|
+
let r = e.clientX - n.left, i = e.clientY - n.top;
|
|
1425
|
+
if (r < 0 || i < 0 || r > n.width || i > n.height) return this._invalidateElementSelection(), null;
|
|
1426
|
+
let a = ++this.elementHitGeneration, o = this.currentSlide, s = {
|
|
1427
|
+
x: r / n.width * t.slideWidth,
|
|
1428
|
+
y: i / n.height * t.slideHeight
|
|
1429
|
+
}, c;
|
|
1430
|
+
try {
|
|
1431
|
+
c = await t.getElementContextAt(o, s, {
|
|
1432
|
+
tolerance: this.elementHitTolerance / n.width * t.slideWidth,
|
|
1433
|
+
maxTextCharacters: J
|
|
1434
|
+
});
|
|
1435
|
+
} catch (e) {
|
|
1436
|
+
if (this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine) return null;
|
|
1437
|
+
throw e;
|
|
1438
|
+
}
|
|
1439
|
+
return this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine ? null : (this._setElementContext(c), this.destroyed ? null : this.getSelectionContext());
|
|
1440
|
+
}
|
|
1139
1441
|
destroy() {
|
|
1140
|
-
this.destroyed || (this.destroyed = !0, this.errorRouter.close(), this.renderDispatcher.destroy(), c(this.canvas), this.handle?.destroy(), this.handle = null, this.presentationOwner.close(), this._find.invalidate(), this.canvasMount.restore());
|
|
1442
|
+
this.destroyed || (this.destroyed = !0, this.errorRouter.close(), this.renderDispatcher.destroy(), c(this.canvas), this.handle?.destroy(), this.handle = null, this.presentationOwner.close(), this._find.invalidate(), 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());
|
|
1141
1443
|
}
|
|
1142
|
-
},
|
|
1444
|
+
}, gt = 150, _t = "0 1px 3px rgba(0,0,0,0.2)", vt = Symbol("PptxScrollViewer.borrowedPresentation"), $ = class e {
|
|
1143
1445
|
_presentationOwner;
|
|
1144
1446
|
get _pres() {
|
|
1145
1447
|
return this._presentationOwner.current;
|
|
@@ -1160,6 +1462,13 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1160
1462
|
_lastRange = null;
|
|
1161
1463
|
_lastTopIndex = -1;
|
|
1162
1464
|
_scrollListener = null;
|
|
1465
|
+
_selectionChangeListener = null;
|
|
1466
|
+
_selectionContextKey = "null";
|
|
1467
|
+
_elementClickListener = null;
|
|
1468
|
+
_contextMenuListener = null;
|
|
1469
|
+
_elementContext = null;
|
|
1470
|
+
_elementHitGeneration = 0;
|
|
1471
|
+
_elementHitTolerance;
|
|
1163
1472
|
_destroyed = !1;
|
|
1164
1473
|
_slideInFlight = /* @__PURE__ */ new Set();
|
|
1165
1474
|
_renderEpoch = 0;
|
|
@@ -1170,33 +1479,40 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1170
1479
|
_prevBase = 0;
|
|
1171
1480
|
_lastFitWidth = 0;
|
|
1172
1481
|
_pageShadow;
|
|
1173
|
-
_find = new
|
|
1482
|
+
_find = new z(() => this.slideCount, (e) => this._collectSlideRuns(e));
|
|
1174
1483
|
_findActive = !1;
|
|
1175
1484
|
_findMeasureCtx;
|
|
1176
1485
|
static fromPresentation(t, n, r = {}) {
|
|
1177
1486
|
return new e(t, {
|
|
1178
1487
|
...r,
|
|
1179
|
-
[
|
|
1488
|
+
[vt]: n
|
|
1180
1489
|
});
|
|
1181
1490
|
}
|
|
1182
1491
|
constructor(e, t = {}) {
|
|
1183
1492
|
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.");
|
|
1184
|
-
this._container = e, this._opts = t
|
|
1185
|
-
let n = t
|
|
1186
|
-
|
|
1493
|
+
this._container = e, this._opts = t;
|
|
1494
|
+
let n = t.elementHitTolerance ?? 6;
|
|
1495
|
+
if (!Number.isFinite(n) || n < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
1496
|
+
this._elementHitTolerance = n, this._pageShadow = t.pageShadow ?? _t;
|
|
1497
|
+
let r = t[vt];
|
|
1498
|
+
this._borrowed = r !== void 0, r ? (this._presentationOwner = new D("PptxScrollViewer", r, !1), this._mode = A("PptxScrollViewer", t.mode, r)) : (this._presentationOwner = new D("PptxScrollViewer"), this._mode = A("PptxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1499
|
+
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1500
|
+
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), this._opts.enableZoom !== !1 && (this._wheelListener = (e) => {
|
|
1187
1501
|
if (!(e.ctrlKey || e.metaKey) || (e.preventDefault(), e.deltaY === 0)) return;
|
|
1188
1502
|
let t = this._scrollHost.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
1189
1503
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
1190
1504
|
x: n,
|
|
1191
1505
|
y: r
|
|
1192
|
-
} : null, this.setScale(
|
|
1506
|
+
} : null, this.setScale(ve(this._scale, e.deltaY));
|
|
1193
1507
|
}, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && this.relayout();
|
|
1194
1508
|
}
|
|
1195
1509
|
async load(e) {
|
|
1196
1510
|
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
1197
1511
|
if (this._borrowed) throw Error("PptxScrollViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.");
|
|
1512
|
+
let t = !1;
|
|
1198
1513
|
try {
|
|
1199
|
-
if (!await this._presentationOwner.replace(() =>
|
|
1514
|
+
if (!await this._presentationOwner.replace(() => Y.load(e, {
|
|
1515
|
+
password: this._opts.password,
|
|
1200
1516
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1201
1517
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1202
1518
|
resourceLimits: this._opts.resourceLimits,
|
|
@@ -1207,22 +1523,19 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1207
1523
|
math: this._opts.math,
|
|
1208
1524
|
mode: this._mode
|
|
1209
1525
|
}), (e) => {
|
|
1210
|
-
if (this._find.invalidate(), this._findActive = !1, e) {
|
|
1526
|
+
if (this._invalidateElementSelection(!1), t = !0, this._find.invalidate(), this._findActive = !1, e) {
|
|
1211
1527
|
for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
|
|
1212
1528
|
this._lastTopIndex = -1;
|
|
1213
1529
|
}
|
|
1214
1530
|
})) return;
|
|
1215
1531
|
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
1216
|
-
this._find.invalidate(), this._findActive = !1
|
|
1532
|
+
this._find.invalidate(), this._findActive = !1;
|
|
1533
|
+
let n = [];
|
|
1534
|
+
this._relayout(n), await Promise.all(n);
|
|
1217
1535
|
} catch (e) {
|
|
1218
|
-
|
|
1219
|
-
let t = e instanceof Error ? e : Error(String(e));
|
|
1220
|
-
if (this._opts.onError) {
|
|
1221
|
-
this._opts.onError(t);
|
|
1222
|
-
return;
|
|
1223
|
-
}
|
|
1224
|
-
throw t;
|
|
1536
|
+
throw this._destroyed ? Error("PptxScrollViewer is destroyed") : e instanceof Error ? e : Error(String(e));
|
|
1225
1537
|
}
|
|
1538
|
+
t && !this._destroyed && this._emitSelectionContextChange();
|
|
1226
1539
|
}
|
|
1227
1540
|
get slideCount() {
|
|
1228
1541
|
return this._pres?.slideCount ?? 0;
|
|
@@ -1246,6 +1559,9 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1246
1559
|
return e <= 0 || t <= 0 ? 0 : e / t;
|
|
1247
1560
|
}
|
|
1248
1561
|
relayout() {
|
|
1562
|
+
this._relayout();
|
|
1563
|
+
}
|
|
1564
|
+
_relayout(e) {
|
|
1249
1565
|
if (this._pres) {
|
|
1250
1566
|
if (!this._scaleEstablished) {
|
|
1251
1567
|
let e = this._baseScale();
|
|
@@ -1256,7 +1572,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1256
1572
|
}
|
|
1257
1573
|
} else return;
|
|
1258
1574
|
}
|
|
1259
|
-
this._recomputeHeights(), this._syncSpacer(), this._mountVisible();
|
|
1575
|
+
this._recomputeHeights(), this._syncSpacer(), this._mountVisible(e);
|
|
1260
1576
|
}
|
|
1261
1577
|
}
|
|
1262
1578
|
_recomputeHeights() {
|
|
@@ -1295,10 +1611,10 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1295
1611
|
return a;
|
|
1296
1612
|
}
|
|
1297
1613
|
_range() {
|
|
1298
|
-
return
|
|
1614
|
+
return P(this._heights, this._gap(), this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan(), this._pad());
|
|
1299
1615
|
}
|
|
1300
1616
|
_mediaRange() {
|
|
1301
|
-
return
|
|
1617
|
+
return P(this._heights, this._gap(), this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._mediaOverscan(), this._pad());
|
|
1302
1618
|
}
|
|
1303
1619
|
_rangeContains(e, t) {
|
|
1304
1620
|
return t >= e.start && t <= e.end;
|
|
@@ -1314,17 +1630,19 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1314
1630
|
_onScroll() {
|
|
1315
1631
|
!this._pres || !this._scaleEstablished || this._mountVisible();
|
|
1316
1632
|
}
|
|
1317
|
-
_mountVisible() {
|
|
1633
|
+
_mountVisible(e) {
|
|
1318
1634
|
if (!this._pres || this._pres.slideCount === 0) return;
|
|
1319
|
-
let
|
|
1320
|
-
this._lastRange =
|
|
1321
|
-
for (let [
|
|
1322
|
-
for (let
|
|
1635
|
+
let t = this._range(), n = this._opts.enableMediaPlayback ? this._mediaRange() : null;
|
|
1636
|
+
this._lastRange = t;
|
|
1637
|
+
for (let [e, n] of [...this._slots]) (e < t.start || e > t.end) && this._recycleSlot(e, n);
|
|
1638
|
+
for (let r = t.start; r <= t.end; r++) if (this._slots.has(r)) this._positionSlot(this._slots.get(r), r, t);
|
|
1323
1639
|
else {
|
|
1324
|
-
let
|
|
1325
|
-
this._positionSlot(
|
|
1640
|
+
let i = this._acquireSlot();
|
|
1641
|
+
this._positionSlot(i, r, t), this._slots.set(r, i);
|
|
1642
|
+
let a = this._renderSlot(r, i, !!n && this._rangeContains(n, r), e === void 0);
|
|
1643
|
+
e && a && e.push(a);
|
|
1326
1644
|
}
|
|
1327
|
-
|
|
1645
|
+
n && this._syncMediaPlayback(n), t.topIndex !== this._lastTopIndex && (this._lastTopIndex = t.topIndex, this._opts.onVisibleSlideChange?.(t.topIndex, this._pres.slideCount));
|
|
1328
1646
|
}
|
|
1329
1647
|
_applyPageShadow(e) {
|
|
1330
1648
|
this._pageShadow !== !1 && (e.style.boxShadow = this._pageShadow);
|
|
@@ -1339,14 +1657,17 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1339
1657
|
let r = null;
|
|
1340
1658
|
this._opts.enableTextSelection && (r = document.createElement("div"), r.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", t.appendChild(r));
|
|
1341
1659
|
let i = document.createElement("div");
|
|
1342
|
-
|
|
1660
|
+
i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
|
|
1661
|
+
let a = fe(t, this._opts.enableElementSelection === !0);
|
|
1662
|
+
return this._scrollHost.appendChild(t), {
|
|
1343
1663
|
wrapper: t,
|
|
1344
1664
|
canvas: n,
|
|
1345
1665
|
textLayer: r,
|
|
1346
1666
|
highlightLayer: i,
|
|
1667
|
+
elementLayer: a,
|
|
1347
1668
|
renderedSlide: -1,
|
|
1348
1669
|
renderedScale: -1,
|
|
1349
|
-
dispatcher: new
|
|
1670
|
+
dispatcher: new k(n, this._mode === "worker"),
|
|
1350
1671
|
presentationHandle: null,
|
|
1351
1672
|
mediaInteractive: !1,
|
|
1352
1673
|
renderGeneration: 0,
|
|
@@ -1354,61 +1675,57 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1354
1675
|
};
|
|
1355
1676
|
}
|
|
1356
1677
|
_recycleSlot(e, t) {
|
|
1357
|
-
this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
1678
|
+
this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new k(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = ""), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", O(t.elementLayer, null), t.canvas.style.height = "", t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
1358
1679
|
}
|
|
1359
1680
|
_positionSlot(e, t, n) {
|
|
1360
|
-
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
1681
|
+
e.wrapper.dataset.slideIndex = String(t), e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
1361
1682
|
let r = this._slideWidthPx();
|
|
1362
|
-
e.wrapper.style.width = `${r}px`, e.wrapper.style.height = `${this._slideHeightPx()}px
|
|
1683
|
+
e.wrapper.style.width = `${r}px`, e.wrapper.style.height = `${this._slideHeightPx()}px`, this._redrawElementOutlineForSlot(t, e);
|
|
1363
1684
|
let { left: i } = this._padH(), a = this._scrollHost.clientWidth;
|
|
1364
1685
|
e.wrapper.style.left = `${Math.max(i, (a - r) / 2)}px`;
|
|
1365
1686
|
}
|
|
1366
1687
|
_dpr() {
|
|
1367
1688
|
return this._opts.dpr ?? (typeof window < "u" && window.devicePixelRatio || 1);
|
|
1368
1689
|
}
|
|
1369
|
-
_renderSlot(e, t, n = !1) {
|
|
1370
|
-
if (!this._pres || t.renderedSlide === e) return;
|
|
1690
|
+
_renderSlot(e, t, n = !1, r = !0) {
|
|
1691
|
+
if (!this._pres || t.renderedSlide === e) return null;
|
|
1371
1692
|
t.renderedSlide = e;
|
|
1372
|
-
let
|
|
1373
|
-
if (this._opts.enableMediaPlayback && n)
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
}
|
|
1381
|
-
let u = [], d = !!this._opts.enableTextSelection && !!t.textLayer, f = d || this._findActive, p = f ? (e) => u.push(e) : void 0, m = t.canvas;
|
|
1382
|
-
this._pres.renderSlide(m, e, {
|
|
1383
|
-
width: a,
|
|
1384
|
-
dpr: i,
|
|
1385
|
-
onTextRun: p
|
|
1693
|
+
let i = ++t.renderGeneration, a = this._dpr(), o = this._slideWidthPx(), s = this._renderEpoch, c = this._scale, l = t.dispatcher, u = l.begin();
|
|
1694
|
+
if (this._opts.enableMediaPlayback && n) return t.mediaInteractive = !0, this._renderInteractiveSlot(e, t, o, a, c, s, r);
|
|
1695
|
+
if (t.mediaInteractive = !1, this._mode === "worker") return this._renderSlotBitmap(e, t, o, a, c, i, l, u, r);
|
|
1696
|
+
let d = [], f = !!this._opts.enableTextSelection && !!t.textLayer, p = f || this._findActive, m = p ? (e) => d.push(e) : void 0, h = t.canvas;
|
|
1697
|
+
return this._pres.renderSlide(h, e, {
|
|
1698
|
+
width: o,
|
|
1699
|
+
dpr: a,
|
|
1700
|
+
onTextRun: m
|
|
1386
1701
|
}).then(() => {
|
|
1387
|
-
|
|
1702
|
+
i !== t.renderGeneration || !l.isCurrent(u) || h !== t.canvas || s !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e || (t.renderedScale = c, f && t.textLayer && L(t.textLayer, d, Math.round(o), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e), p && this._refreshFindRuns(e, d), this._redrawSlotHighlights(e, t));
|
|
1388
1703
|
}).catch((n) => {
|
|
1389
|
-
|
|
1704
|
+
if (i === t.renderGeneration && l.isCurrent(u) && h === t.canvas && s === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e) if (r) this._reportRenderError(n);
|
|
1705
|
+
else throw n;
|
|
1390
1706
|
});
|
|
1391
1707
|
}
|
|
1392
|
-
_renderInteractiveSlot(e, t, n, r, i, a) {
|
|
1393
|
-
if (!this._pres) return;
|
|
1394
|
-
let
|
|
1708
|
+
_renderInteractiveSlot(e, t, n, r, i, a, o = !0) {
|
|
1709
|
+
if (!this._pres) return Promise.resolve();
|
|
1710
|
+
let s = ++t.presentationGeneration;
|
|
1395
1711
|
t.presentationHandle?.destroy(), t.presentationHandle = null;
|
|
1396
|
-
let
|
|
1397
|
-
this._pres.presentSlide(t.canvas, e, {
|
|
1712
|
+
let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0;
|
|
1713
|
+
return this._pres.presentSlide(t.canvas, e, {
|
|
1398
1714
|
width: n,
|
|
1399
1715
|
dpr: r,
|
|
1400
|
-
onTextRun:
|
|
1716
|
+
onTextRun: d,
|
|
1401
1717
|
onError: (e) => {
|
|
1402
|
-
|
|
1718
|
+
s === t.presentationGeneration && this._reportRenderError(e);
|
|
1403
1719
|
}
|
|
1404
1720
|
}).then((r) => {
|
|
1405
|
-
if (
|
|
1721
|
+
if (s !== t.presentationGeneration || !t.mediaInteractive || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
1406
1722
|
r.destroy();
|
|
1407
1723
|
return;
|
|
1408
1724
|
}
|
|
1409
|
-
t.presentationHandle = r, t.renderedScale = i,
|
|
1725
|
+
t.presentationHandle = r, t.renderedScale = i, l && t.textLayer && L(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e), u && this._refreshFindRuns(e, c), this._redrawSlotHighlights(e, t);
|
|
1410
1726
|
}).catch((e) => {
|
|
1411
|
-
|
|
1727
|
+
if (s === t.presentationGeneration) if (o) this._reportRenderError(e);
|
|
1728
|
+
else throw e;
|
|
1412
1729
|
});
|
|
1413
1730
|
}
|
|
1414
1731
|
_syncMediaPlayback(e = this._mediaRange()) {
|
|
@@ -1422,32 +1739,33 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1422
1739
|
let t = e instanceof Error ? e : Error(String(e));
|
|
1423
1740
|
this._opts.onError ? this._opts.onError(t) : console.error("[ooxml] PptxScrollViewer render failed:", t);
|
|
1424
1741
|
}
|
|
1425
|
-
async _renderSlotBitmap(e, t, n, r, i, a = ++t.renderGeneration, o = t.dispatcher, s = o.begin()) {
|
|
1742
|
+
async _renderSlotBitmap(e, t, n, r, i, a = ++t.renderGeneration, o = t.dispatcher, s = o.begin(), c = !0) {
|
|
1426
1743
|
if (this._slideInFlight.has(e) || this._slots.get(e) !== t) return;
|
|
1427
|
-
let
|
|
1744
|
+
let l = this._renderEpoch;
|
|
1428
1745
|
this._slideInFlight.add(e);
|
|
1429
|
-
let
|
|
1746
|
+
let u = t.canvas, d = !1, f = !!this._opts.enableTextSelection && !!t.textLayer, p = f || this._findActive, m = [];
|
|
1430
1747
|
try {
|
|
1431
|
-
let
|
|
1748
|
+
let c = await this._pres.renderSlideToBitmap(e, {
|
|
1432
1749
|
width: n,
|
|
1433
1750
|
dpr: r,
|
|
1434
|
-
onTextRun:
|
|
1751
|
+
onTextRun: p ? (e) => m.push(e) : void 0
|
|
1435
1752
|
});
|
|
1436
|
-
if (a !== t.renderGeneration || !o.isCurrent(s) ||
|
|
1437
|
-
|
|
1753
|
+
if (a !== t.renderGeneration || !o.isCurrent(s) || u !== t.canvas || l !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
1754
|
+
c.close();
|
|
1438
1755
|
return;
|
|
1439
1756
|
}
|
|
1440
|
-
if (!o.commitBitmap(s,
|
|
1441
|
-
cssWidth: Math.round(
|
|
1442
|
-
cssHeight: Math.round(
|
|
1757
|
+
if (!o.commitBitmap(s, c, {
|
|
1758
|
+
cssWidth: Math.round(c.width / r),
|
|
1759
|
+
cssHeight: Math.round(c.height / r)
|
|
1443
1760
|
})) return;
|
|
1444
|
-
t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "",
|
|
1761
|
+
t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", f && L(t.textLayer, m, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), p && this._refreshFindRuns(e, m), this._redrawSlotHighlights(e, t), d = !0;
|
|
1445
1762
|
} catch (n) {
|
|
1446
|
-
a === t.renderGeneration && o.isCurrent(s) &&
|
|
1763
|
+
if (a === t.renderGeneration && o.isCurrent(s) && u === t.canvas && l === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e) if (c) this._reportRenderError(n);
|
|
1764
|
+
else throw n;
|
|
1447
1765
|
} finally {
|
|
1448
1766
|
this._slideInFlight.delete(e);
|
|
1449
1767
|
let n = this._slots.get(e);
|
|
1450
|
-
!
|
|
1768
|
+
!d && n && (n !== t || l !== this._renderEpoch || a !== n.renderGeneration || !o.isCurrent(s)) && !this._slideInFlight.has(e) && !this._destroyed && !(this._opts.enableMediaPlayback && n.mediaInteractive) && this._renderSlotBitmap(e, n, this._slideWidthPx(), this._dpr(), this._scale);
|
|
1451
1769
|
}
|
|
1452
1770
|
}
|
|
1453
1771
|
setScale(e) {
|
|
@@ -1461,12 +1779,12 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1461
1779
|
f = Math.min(1, Math.max(0, f));
|
|
1462
1780
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
1463
1781
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
1464
|
-
let h =
|
|
1782
|
+
let h = P(this._heights, this._gap(), 0, this._scrollHost.clientHeight, this._overscan(), this._pad());
|
|
1465
1783
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
1466
1784
|
let g = Math.max(0, h.totalHeight - this._scrollHost.clientHeight), _ = (h.offsets[u] ?? 0) + f * (this._heights[u] || 0), v = l < (s.offsets[0] ?? 0) ? c : _ - o;
|
|
1467
1785
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
1468
1786
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
1469
|
-
this._scrollHost.scrollLeft =
|
|
1787
|
+
this._scrollHost.scrollLeft = ae(m, i.x - p, a, r, { maxScroll: e });
|
|
1470
1788
|
}
|
|
1471
1789
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
1472
1790
|
}
|
|
@@ -1474,10 +1792,10 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1474
1792
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
1475
1793
|
}
|
|
1476
1794
|
zoomIn() {
|
|
1477
|
-
this.setScale(
|
|
1795
|
+
this.setScale(j(this.getScale()));
|
|
1478
1796
|
}
|
|
1479
1797
|
zoomOut() {
|
|
1480
|
-
this.setScale(
|
|
1798
|
+
this.setScale(M(this.getScale()));
|
|
1481
1799
|
}
|
|
1482
1800
|
fitWidth() {
|
|
1483
1801
|
this._fit("width");
|
|
@@ -1487,7 +1805,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1487
1805
|
}
|
|
1488
1806
|
_fit(e) {
|
|
1489
1807
|
if (!this._pres || this._pres.slideCount === 0) return;
|
|
1490
|
-
let t =
|
|
1808
|
+
let t = E({
|
|
1491
1809
|
contentWidth: this._pres.slideWidth / x,
|
|
1492
1810
|
contentHeight: this._pres.slideHeight / x,
|
|
1493
1811
|
containerWidth: this._fitWidthPx(),
|
|
@@ -1519,7 +1837,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1519
1837
|
_scheduleSettle() {
|
|
1520
1838
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
1521
1839
|
this._settleTimer = null, this._settleRender();
|
|
1522
|
-
},
|
|
1840
|
+
}, gt);
|
|
1523
1841
|
}
|
|
1524
1842
|
_settleRender() {
|
|
1525
1843
|
if (this._destroyed || !this._pres || this._pres.slideCount === 0) return;
|
|
@@ -1540,7 +1858,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1540
1858
|
}
|
|
1541
1859
|
let o = document.createElement("canvas"), s = ++t.renderGeneration;
|
|
1542
1860
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
1543
|
-
let c = new
|
|
1861
|
+
let c = new k(o, !1), l = c.begin(), u = [], d = !!this._opts.enableTextSelection && !!t.textLayer, f = d || this._findActive, p = f ? (e) => u.push(e) : void 0;
|
|
1544
1862
|
this._pres.renderSlide(o, e, {
|
|
1545
1863
|
width: r,
|
|
1546
1864
|
dpr: n,
|
|
@@ -1551,7 +1869,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1551
1869
|
return;
|
|
1552
1870
|
}
|
|
1553
1871
|
let n = t.canvas;
|
|
1554
|
-
t.dispatcher.destroy(), t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.dispatcher = c, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", d &&
|
|
1872
|
+
t.dispatcher.destroy(), t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.dispatcher = c, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", d && L(t.textLayer, u, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), f && this._refreshFindRuns(e, u), this._redrawSlotHighlights(e, t);
|
|
1555
1873
|
}).catch((n) => {
|
|
1556
1874
|
s === t.renderGeneration && c.isCurrent(l) && a === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e && this._reportRenderError(n), c.destroy();
|
|
1557
1875
|
});
|
|
@@ -1574,14 +1892,14 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1574
1892
|
return;
|
|
1575
1893
|
}
|
|
1576
1894
|
let d = t.canvas, f = t.presentationHandle;
|
|
1577
|
-
t.dispatcher.destroy(), t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.dispatcher = new
|
|
1895
|
+
t.dispatcher.destroy(), t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.dispatcher = new k(s, !1), t.presentationHandle = r, t.renderedScale = i, f?.destroy(), t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", l && L(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), u && this._refreshFindRuns(e, c), this._redrawSlotHighlights(e, t);
|
|
1578
1896
|
}).catch((e) => {
|
|
1579
1897
|
o === t.presentationGeneration && this._reportRenderError(e);
|
|
1580
1898
|
});
|
|
1581
1899
|
}
|
|
1582
1900
|
scrollToSlide(e, t) {
|
|
1583
1901
|
if (!this._pres || this._pres.slideCount === 0 || !this._scaleEstablished) return;
|
|
1584
|
-
let n = Math.max(0, Math.min(e, this._pres.slideCount - 1)), r =
|
|
1902
|
+
let n = Math.max(0, Math.min(e, this._pres.slideCount - 1)), r = P(this._heights, this._gap(), 0, this._scrollHost.clientHeight, this._overscan(), this._pad()), i = r.offsets[n] ?? 0, a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
|
|
1585
1903
|
typeof s.scrollTo == "function" ? s.scrollTo({
|
|
1586
1904
|
top: o,
|
|
1587
1905
|
behavior: t?.behavior ?? "auto"
|
|
@@ -1624,7 +1942,7 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1624
1942
|
t.highlightLayer.innerHTML = "";
|
|
1625
1943
|
return;
|
|
1626
1944
|
}
|
|
1627
|
-
|
|
1945
|
+
R(t.highlightLayer, n, this._find.slideHighlights(e), this._slideWidthPx(), this._slideHeightPx(), (e) => this._measureForFind(e), this._opts.findHighlightColors);
|
|
1628
1946
|
}
|
|
1629
1947
|
_measureForFind(e) {
|
|
1630
1948
|
this._findMeasureCtx === void 0 && (this._findMeasureCtx = document.createElement("canvas").getContext("2d"));
|
|
@@ -1710,26 +2028,96 @@ var Ke = new URL("pptx_parser_bg.wasm", import.meta.url).href, Q = class e {
|
|
|
1710
2028
|
if (!this._pres) throw Error("Presentation not loaded");
|
|
1711
2029
|
return await this._pres.getResourceMetrics();
|
|
1712
2030
|
}
|
|
2031
|
+
getSelectionContext(e = {}) {
|
|
2032
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2033
|
+
return (this._opts.enableTextSelection ? Z(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? ut(this._elementContext, e.maxTextCharacters) : null);
|
|
2034
|
+
}
|
|
2035
|
+
_emitSelectionContextChange() {
|
|
2036
|
+
let e = this.getSelectionContext();
|
|
2037
|
+
e?.kind === "text" && (this._elementHitGeneration++, this._elementContext = null, this._redrawElementOutlines());
|
|
2038
|
+
let t = JSON.stringify(e);
|
|
2039
|
+
t !== this._selectionContextKey && (this._selectionContextKey = t, this._opts.onSelectionContextChange?.(e ? structuredClone(e) : null));
|
|
2040
|
+
}
|
|
2041
|
+
_setElementContext(e) {
|
|
2042
|
+
this._elementContext = e ? structuredClone(e) : null, this._redrawElementOutlines(), this._emitSelectionContextChange();
|
|
2043
|
+
}
|
|
2044
|
+
_invalidateElementSelection(e = !0) {
|
|
2045
|
+
this._elementHitGeneration++, this._elementContext = null, this._redrawElementOutlines(), e && this._emitSelectionContextChange();
|
|
2046
|
+
}
|
|
2047
|
+
_redrawElementOutlines() {
|
|
2048
|
+
for (let [e, t] of this._slots) this._redrawElementOutlineForSlot(e, t);
|
|
2049
|
+
}
|
|
2050
|
+
_redrawElementOutlineForSlot(e, t) {
|
|
2051
|
+
let n = this._elementContext, r = this._pres;
|
|
2052
|
+
if (!n || !r || n.slideIndex !== e) {
|
|
2053
|
+
O(t.elementLayer, null);
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
O(t.elementLayer, {
|
|
2057
|
+
x: n.bounds.x / r.slideWidth,
|
|
2058
|
+
y: n.bounds.y / r.slideHeight,
|
|
2059
|
+
width: n.bounds.width / r.slideWidth,
|
|
2060
|
+
height: n.bounds.height / r.slideHeight,
|
|
2061
|
+
rotation: n.bounds.rotation
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
async _onElementClick(e) {
|
|
2065
|
+
this._destroyed || e.defaultPrevented || e.button !== 0 || await this._resolveContextAt(e);
|
|
2066
|
+
}
|
|
2067
|
+
_onContextMenu(e) {
|
|
2068
|
+
let t;
|
|
2069
|
+
this._opts.onContextMenu?.({
|
|
2070
|
+
originalEvent: e,
|
|
2071
|
+
getContext: () => t ??= this._resolveContextAt(e)
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
async _resolveContextAt(e) {
|
|
2075
|
+
let t = this._pres;
|
|
2076
|
+
if (this._destroyed || !t) return null;
|
|
2077
|
+
if (this._opts.enableTextSelection && Z(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null)) return this._emitSelectionContextChange(), this._destroyed ? null : this.getSelectionContext();
|
|
2078
|
+
if (!this._opts.enableElementSelection) return this.getSelectionContext();
|
|
2079
|
+
let n = e.target, r = [...this._slots].find(([, e]) => n !== null && e.wrapper.contains(n));
|
|
2080
|
+
if (!r) return this._invalidateElementSelection(), null;
|
|
2081
|
+
let [i, a] = r, o = a.canvas.getBoundingClientRect();
|
|
2082
|
+
if (o.width <= 0 || o.height <= 0) return this._invalidateElementSelection(), null;
|
|
2083
|
+
let s = e.clientX - o.left, c = e.clientY - o.top;
|
|
2084
|
+
if (s < 0 || c < 0 || s > o.width || c > o.height) return this._invalidateElementSelection(), null;
|
|
2085
|
+
let l = ++this._elementHitGeneration, u = {
|
|
2086
|
+
x: s / o.width * t.slideWidth,
|
|
2087
|
+
y: c / o.height * t.slideHeight
|
|
2088
|
+
}, d;
|
|
2089
|
+
try {
|
|
2090
|
+
d = await t.getElementContextAt(i, u, {
|
|
2091
|
+
tolerance: this._elementHitTolerance / o.width * t.slideWidth,
|
|
2092
|
+
maxTextCharacters: J
|
|
2093
|
+
});
|
|
2094
|
+
} catch (e) {
|
|
2095
|
+
if (this._destroyed || l !== this._elementHitGeneration || t !== this._pres) return null;
|
|
2096
|
+
throw e;
|
|
2097
|
+
}
|
|
2098
|
+
return this._destroyed || l !== this._elementHitGeneration || t !== this._pres ? null : (this._setElementContext(d), this._destroyed ? null : this.getSelectionContext());
|
|
2099
|
+
}
|
|
1713
2100
|
destroy() {
|
|
1714
2101
|
if (!this._destroyed) {
|
|
1715
|
-
this._destroyed = !0, this._find.invalidate(), this._findActive = !1, this._scrollListener &&= (this._scrollHost.removeEventListener("scroll", this._scrollListener), null), this._wheelListener &&= (this._scrollHost.removeEventListener("wheel", this._wheelListener), null), this._resizeObserver?.disconnect(), this._resizeObserver = null, this._settleTimer !== null && (clearTimeout(this._settleTimer), this._settleTimer = null);
|
|
2102
|
+
this._destroyed = !0, this._find.invalidate(), this._findActive = !1, this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._scrollHost.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._scrollHost.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._scrollListener &&= (this._scrollHost.removeEventListener("scroll", this._scrollListener), null), this._wheelListener &&= (this._scrollHost.removeEventListener("wheel", this._wheelListener), null), this._resizeObserver?.disconnect(), this._resizeObserver = null, this._settleTimer !== null && (clearTimeout(this._settleTimer), this._settleTimer = null);
|
|
1716
2103
|
for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
|
|
1717
2104
|
this._free.length = 0, this._presentationOwner.close(), this._wrapper.remove();
|
|
1718
2105
|
}
|
|
1719
2106
|
}
|
|
1720
|
-
},
|
|
2107
|
+
}, yt = /* @__PURE__ */ e({
|
|
1721
2108
|
OoxmlDecodedImageLimitError: () => p,
|
|
1722
2109
|
OoxmlError: () => w,
|
|
1723
2110
|
OoxmlResourceLimitError: () => y,
|
|
1724
|
-
PptxPresentation: () =>
|
|
1725
|
-
PptxScrollViewer: () =>
|
|
1726
|
-
PptxViewer: () =>
|
|
1727
|
-
autoResize: () =>
|
|
1728
|
-
buildPptxHighlightLayer: () =>
|
|
1729
|
-
buildPptxTextLayer: () =>
|
|
2111
|
+
PptxPresentation: () => Y,
|
|
2112
|
+
PptxScrollViewer: () => $,
|
|
2113
|
+
PptxViewer: () => ht,
|
|
2114
|
+
autoResize: () => _e,
|
|
2115
|
+
buildPptxHighlightLayer: () => R,
|
|
2116
|
+
buildPptxTextLayer: () => L,
|
|
1730
2117
|
isOoxmlDecodedImageLimitError: () => m,
|
|
1731
2118
|
openExternalHyperlink: () => g,
|
|
2119
|
+
readPptxTextSelectionContext: () => Z,
|
|
1732
2120
|
renderSlide: () => n
|
|
1733
2121
|
});
|
|
1734
2122
|
//#endregion
|
|
1735
|
-
export {
|
|
2123
|
+
export { Y as a, Z as i, $ as n, R as o, ht as r, L as s, yt as t };
|