@algorisys/yappydraw 0.8.297 → 0.8.298

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +2 -2
  2. package/chunks/{canva-ai-cwK_LwEk.js → canva-ai-wYv31lWm.js} +1 -1
  3. package/chunks/{choice-dialog-state-CF9ddIAk.js → choice-dialog-state-DqR_5IIZ.js} +1 -1
  4. package/chunks/{custgeom-N1NlyQKZ.js → custgeom-DUHYX5Vs.js} +28 -26
  5. package/chunks/{design-generator-DSEgwQ7i.js → design-generator-DGqLbsqR.js} +1 -1
  6. package/chunks/{drawing-engine-CPFaJPyz.js → drawing-engine-BCPX1hm_.js} +1 -1
  7. package/chunks/{drawings-store-CxGNbTN7.js → drawings-store-BJW1Dmw_.js} +1 -1
  8. package/chunks/{ds-operations-BTcGLr6X.js → ds-operations-Bi7WKGwN.js} +1 -1
  9. package/chunks/{export-game-BVjxTYD1.js → export-game-BkUpm1R8.js} +1 -1
  10. package/chunks/{from-yappy-kTebD-0Y.js → from-yappy-fz7AULvS.js} +175 -173
  11. package/chunks/{game-runtime-Ch0y0mLm.js → game-runtime-Bng0zlkA.js} +24 -24
  12. package/chunks/import-BvGSYTzL.js +1895 -0
  13. package/chunks/{index-zg1eC33A.js → index-Bqlr2FLr.js} +9325 -9170
  14. package/chunks/{lucide-solid-DAmszm-d.js → lucide-solid-Db2bPSrx.js} +1 -1
  15. package/chunks/{markdown-to-slides-CGvmGrK2.js → markdown-to-slides-D1OVYcQV.js} +1 -1
  16. package/chunks/{morph-animator-BQPPQ08b.js → morph-animator-DCs2sEkC.js} +1 -1
  17. package/chunks/{onboarding-tour-CpRCV3Ub.js → onboarding-tour-DoZ9Sivk.js} +1 -1
  18. package/chunks/{pdf-vector-D65OC03c.js → pdf-vector-DTgEkBKW.js} +1 -1
  19. package/chunks/{search-rp-eRNJ6.js → search-4gFkAhbD.js} +9 -9
  20. package/chunks/{slide-generator-Ctxdc9Yn.js → slide-generator-D1fy8u8B.js} +5 -5
  21. package/chunks/{turntable-ai-ZhAGEjzz.js → turntable-ai-C1B4jzNc.js} +1 -1
  22. package/chunks/write-DDXhxpu-.js +408 -0
  23. package/chunks/yappy-Btkc8ueG.css +1 -0
  24. package/package.json +1 -1
  25. package/yappy.js +1 -1
  26. package/chunks/import-eCGTFoVi.js +0 -1814
  27. package/chunks/write-ZW6FSyj1.js +0 -327
  28. package/chunks/yappy-CvwwkLs8.css +0 -1
@@ -1,1814 +0,0 @@
1
- import { u as he, a as pe } from "./browser-DbZP-BrN.js";
2
- import { e as me, s as Ft, f as ge } from "./anim-map-D7T1mIAM.js";
3
- import { E as z, i as Tt, g as xe } from "./custgeom-N1NlyQKZ.js";
4
- import { ar as be, as as Dt, at as ye, au as ke, M as we, q as Me, K as ve } from "./index-zg1eC33A.js";
5
- const Se = 1e4, Ce = 1e5, Qt = 6e4, nt = (t) => t / Qt * (Math.PI / 180);
6
- function Jt(t, n, e, o = {}) {
7
- const s = /* @__PURE__ */ new Map(), r = Math.max(0, n), a = Math.max(0, e), i = Math.min(r, a), l = Math.max(r, a), p = {
8
- w: r,
9
- h: a,
10
- l: 0,
11
- t: 0,
12
- r,
13
- b: a,
14
- hc: r / 2,
15
- vc: a / 2,
16
- ss: i,
17
- ls: l,
18
- cd2: 108e5,
19
- cd4: 54e5,
20
- cd8: 27e5,
21
- "3cd4": 162e5,
22
- "3cd8": 81e5,
23
- "5cd8": 135e5,
24
- "7cd8": 189e5
25
- };
26
- for (const [g, b] of Object.entries(p)) s.set(g, b);
27
- for (const g of [2, 3, 4, 5, 6, 8, 10, 12, 16, 32])
28
- s.set(`wd${g}`, r / g), s.set(`hd${g}`, a / g), s.set(`ssd${g}`, i / g);
29
- const x = (g) => {
30
- const b = s.get(g);
31
- if (b !== void 0) return b;
32
- const f = /^(wd|hd|ssd)(\d+)$/.exec(g);
33
- if (f) {
34
- const y = f[1] === "wd" ? r : f[1] === "hd" ? a : i, d = Number(f[2]);
35
- return d ? y / d : 0;
36
- }
37
- const h = Number(g);
38
- return Number.isFinite(h) ? h : 0;
39
- }, u = (g, b) => {
40
- s.size > Se || s.set(g, Pe(b, x));
41
- };
42
- for (const [g, b] of t.av ?? []) u(g, o[g] ?? b);
43
- for (const [g, b] of Object.entries(o)) s.has(g) || u(g, b);
44
- for (const [g, b] of t.gd ?? []) u(g, b);
45
- return s;
46
- }
47
- function Pe(t, n) {
48
- const e = String(t || "").trim().split(/\s+/), o = e[0], [s, r, a] = e.slice(1).map(n);
49
- let i;
50
- switch (o) {
51
- case "val":
52
- i = s;
53
- break;
54
- case "*/":
55
- i = a ? s * r / a : 0;
56
- break;
57
- case "+-":
58
- i = s + r - a;
59
- break;
60
- case "+/":
61
- i = a ? (s + r) / a : 0;
62
- break;
63
- case "?:":
64
- i = s > 0 ? r : a;
65
- break;
66
- case "abs":
67
- i = Math.abs(s);
68
- break;
69
- case "at2":
70
- i = Math.atan2(r, s) * 180 / Math.PI * Qt;
71
- break;
72
- case "cat2":
73
- i = s * Math.cos(Math.atan2(a, r));
74
- break;
75
- case "sat2":
76
- i = s * Math.sin(Math.atan2(a, r));
77
- break;
78
- case "cos":
79
- i = s * Math.cos(nt(r));
80
- break;
81
- case "sin":
82
- i = s * Math.sin(nt(r));
83
- break;
84
- case "tan":
85
- i = s * Math.tan(nt(r));
86
- break;
87
- case "max":
88
- i = Math.max(s, r);
89
- break;
90
- case "min":
91
- i = Math.min(s, r);
92
- break;
93
- case "mod":
94
- i = Math.sqrt(s * s + r * r + a * a);
95
- break;
96
- case "pin":
97
- i = r < s ? s : r > a ? a : r;
98
- break;
99
- case "sqrt":
100
- i = Math.sqrt(Math.max(0, s));
101
- break;
102
- default:
103
- i = 0;
104
- }
105
- return Number.isFinite(i) ? i : 0;
106
- }
107
- const jt = (t, n, e) => Math.atan2(n * Math.sin(t), e * Math.cos(t));
108
- function ut(t, n, e, o = {}) {
109
- const s = Math.max(Math.abs(n), 0) * z, r = Math.max(Math.abs(e), 0) * z, a = Jt(t, s, r, o), i = (x) => typeof x == "number" ? x : a.get(x) ?? (Number.isFinite(Number(x)) ? Number(x) : 0), l = [];
110
- let p = Ce;
111
- for (const x of t.paths) {
112
- const u = x.w ? s / x.w : 1, g = x.h ? r / x.h : 1, b = (m) => i(m) * u / z, f = (m) => i(m) * g / z, h = [];
113
- let y = { x: 0, y: 0 }, d = { x: 0, y: 0 };
114
- for (const m of x.d) {
115
- if (--p < 0) break;
116
- switch (m[0]) {
117
- case "M":
118
- y = { x: b(m[1]), y: f(m[2]) }, d = y, h.push({ op: "M", ...y });
119
- break;
120
- case "L":
121
- y = { x: b(m[1]), y: f(m[2]) }, h.push({ op: "L", ...y });
122
- break;
123
- case "C": {
124
- const w = b(m[1]), M = f(m[2]), S = b(m[3]), v = f(m[4]);
125
- y = { x: b(m[5]), y: f(m[6]) }, h.push({ op: "C", x1: w, y1: M, x2: S, y2: v, ...y });
126
- break;
127
- }
128
- case "Q": {
129
- const w = b(m[1]), M = f(m[2]), S = b(m[3]), v = f(m[4]);
130
- h.push({ op: "C", x1: y.x + 2 / 3 * (w - y.x), y1: y.y + 2 / 3 * (M - y.y), x2: S + 2 / 3 * (w - S), y2: v + 2 / 3 * (M - v), x: S, y: v }), y = { x: S, y: v };
131
- break;
132
- }
133
- case "A": {
134
- const w = i(m[1]) * u / z, M = i(m[2]) * g / z;
135
- y = Te(h, y, w, M, i(m[3]), i(m[4]));
136
- break;
137
- }
138
- case "Z":
139
- h.push({ op: "Z" }), y = d;
140
- break;
141
- }
142
- }
143
- h.length && l.push({ cmds: h, fill: x.fill === "none" ? !1 : void 0, stroke: x.stroke === !1 ? !1 : void 0 });
144
- }
145
- return l;
146
- }
147
- function Te(t, n, e, o, s, r) {
148
- if (Math.abs(e) < 1e-9 || Math.abs(o) < 1e-9 || r === 0) return n;
149
- const a = nt(s), i = Math.max(-4 * Math.PI, Math.min(4 * Math.PI, nt(r))), l = jt(a, e, o);
150
- let p = jt(a + i, e, o);
151
- if (Math.abs(i) >= 2 * Math.PI - 1e-9) p = l + Math.sign(i) * 2 * Math.PI;
152
- else {
153
- for (; i > 0 && p < l; ) p += 2 * Math.PI;
154
- for (; i < 0 && p > l; ) p -= 2 * Math.PI;
155
- }
156
- const x = n.x - e * Math.cos(l), u = n.y - o * Math.sin(l), g = p - l, b = Math.max(1, Math.min(16, Math.ceil(Math.abs(g) / (Math.PI / 2)))), f = g / b, h = 4 / 3 * Math.tan(f / 4);
157
- let y = l, d = n;
158
- for (let m = 0; m < b; m++) {
159
- const w = y + f, M = Math.cos(y), S = Math.sin(y), v = Math.cos(w), I = Math.sin(w);
160
- d = { x: x + e * v, y: u + o * I }, t.push({ op: "C", x1: x + e * (M - h * S), y1: u + o * (S + h * M), x2: x + e * (v + h * I), y2: u + o * (I - h * v), ...d }), y = w;
161
- }
162
- return d;
163
- }
164
- function te(t, n, e, o = {}) {
165
- const s = Math.abs(n), r = Math.abs(e);
166
- if (!t.rect) return { l: 0, t: 0, r: s, b: r };
167
- const a = Jt(t, s * z, r * z, o), i = (g) => (a.get(g) ?? (Number.isFinite(Number(g)) ? Number(g) : 0)) / z, [l, p, x, u] = t.rect.map(i);
168
- return { l, t: p, r: x, b: u };
169
- }
170
- let $t = null;
171
- async function Ie() {
172
- return $t ??= (await import("./presets-DP49P8i2.js")).default, $t;
173
- }
174
- const Bt = 5e4, Ne = 256 * 1024 * 1024, zt = 1024 * 1024 * 1024, Oe = 1e4, Ae = 32, Le = 2e4, N = (t, n) => {
175
- if (!t) return [];
176
- const e = [];
177
- for (let o = t.firstChild; o; o = o.nextSibling)
178
- o.nodeType === 1 && (!n || o.localName === n) && e.push(o);
179
- return e;
180
- }, c = (t, n) => {
181
- if (!t) return null;
182
- for (let e = t.firstChild; e; e = e.nextSibling) if (e.nodeType === 1 && e.localName === n) return e;
183
- return null;
184
- }, A = (t, ...n) => {
185
- let e = t;
186
- for (const o of n) e = c(e, o);
187
- return e ?? null;
188
- }, k = (t, n) => {
189
- if (!t) return null;
190
- const e = t.getAttribute(n);
191
- if (e !== null && e !== "") return e;
192
- const o = n.includes(":") ? n.split(":")[1] : n;
193
- for (let s = 0; s < (t.attributes?.length ?? 0); s++) {
194
- const r = t.attributes[s];
195
- if (r.localName === o && (n.includes(":") || !r.name.includes(":"))) return r.value;
196
- }
197
- return null;
198
- }, C = (t, n, e = 0) => {
199
- const o = k(t, n), s = o === null ? NaN : Number(o);
200
- return Number.isFinite(s) ? s : e;
201
- }, B = (t, n) => {
202
- const e = k(t, n);
203
- return e === null ? void 0 : e === "1" || e === "true" || e === "on";
204
- }, R = (t) => t / z, Ee = /* @__PURE__ */ new Set(["p14", "a14", "a16"]);
205
- function Re(t) {
206
- if (t.localName !== "AlternateContent") return [t];
207
- const n = c(t, "Fallback");
208
- for (const e of N(t, "Choice"))
209
- if ((k(e, "Requires") || "").split(/\s+/).filter(Boolean).every((s) => Ee.has(s))) return N(e);
210
- return N(n);
211
- }
212
- const V = (t) => N(t).flatMap(Re);
213
- class Fe {
214
- files;
215
- text = /* @__PURE__ */ new Map();
216
- relCache = /* @__PURE__ */ new Map();
217
- parseXml;
218
- warn;
219
- constructor(n, e, o) {
220
- this.parseXml = e, this.warn = o, this.files = {};
221
- for (const [s, r] of Object.entries(n)) this.files[et(s)] = r;
222
- }
223
- bytes(n) {
224
- return this.files[et(n)];
225
- }
226
- xml(n) {
227
- const e = et(n);
228
- if (!this.text.has(e)) {
229
- const o = this.files[e];
230
- let s = null;
231
- if (o) {
232
- try {
233
- const r = pe(o).replace(/^/, "");
234
- s = /<!DOCTYPE/i.test(r.slice(0, 2048)) ? null : this.parseXml(r), s && s.getElementsByTagName("parsererror").length && (s = null);
235
- } catch {
236
- s = null;
237
- }
238
- s || this.warn(`Couldn't read ${e}`);
239
- }
240
- this.text.set(e, s);
241
- }
242
- return this.text.get(e)?.documentElement ?? null;
243
- }
244
- rels(n) {
245
- const e = et(n);
246
- let o = this.relCache.get(e);
247
- if (o) return o;
248
- o = /* @__PURE__ */ new Map();
249
- const s = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = e.slice(e.lastIndexOf("/") + 1), a = this.xml(`${s ? s + "/" : ""}_rels/${r}.rels`);
250
- for (const i of N(a, "Relationship")) {
251
- const l = k(i, "Id"), p = k(i, "Type") || "", x = k(i, "Target") || "";
252
- if (!l) continue;
253
- const u = k(i, "TargetMode") === "External";
254
- o.set(l, { type: p.slice(p.lastIndexOf("/") + 1), target: u ? x : De(s, x), external: u });
255
- }
256
- return this.relCache.set(e, o), o;
257
- }
258
- relOfType(n, e) {
259
- for (const o of this.rels(n).values()) if (o.type === e && !o.external) return o.target;
260
- return null;
261
- }
262
- }
263
- const et = (t) => t.replace(/\\/g, "/").replace(/^\/+/, "");
264
- function De(t, n) {
265
- let e = n.split("#")[0];
266
- try {
267
- e = decodeURIComponent(e);
268
- } catch {
269
- }
270
- if (e.startsWith("/")) return et(e);
271
- const o = (t ? t.split("/") : []).concat(e.split("/")), s = [];
272
- for (const r of o)
273
- r === ".." ? s.pop() : r && r !== "." && s.push(r);
274
- return s.join("/");
275
- }
276
- const It = { bg1: "lt1", tx1: "dk1", bg2: "lt2", tx2: "dk2" };
277
- function xt(t) {
278
- const n = { colors: {}, major: "Calibri Light", minor: "Calibri", fills: [], lines: [], bgFills: [] }, e = c(t, "themeElements");
279
- for (const r of N(c(e, "clrScheme"))) {
280
- const a = N(r)[0];
281
- if (!a) continue;
282
- const i = a.localName === "sysClr" ? k(a, "lastClr") : k(a, "val");
283
- i && /^[0-9a-f]{6}$/i.test(i) && (n.colors[r.localName] = "#" + i.toLowerCase());
284
- }
285
- const o = c(e, "fontScheme");
286
- n.major = k(A(o, "majorFont", "latin"), "typeface") || n.major, n.minor = k(A(o, "minorFont", "latin"), "typeface") || n.minor;
287
- const s = c(e, "fmtScheme");
288
- return n.fills = N(c(s, "fillStyleLst")), n.lines = N(c(s, "lnStyleLst")), n.bgFills = N(c(s, "bgFillStyleLst")), n;
289
- }
290
- const je = {
291
- black: "#000000",
292
- white: "#ffffff",
293
- red: "#ff0000",
294
- green: "#008000",
295
- blue: "#0000ff",
296
- yellow: "#ffff00",
297
- gray: "#808080",
298
- grey: "#808080",
299
- silver: "#c0c0c0",
300
- orange: "#ffa500",
301
- purple: "#800080",
302
- navy: "#000080",
303
- teal: "#008080",
304
- maroon: "#800000",
305
- lime: "#00ff00",
306
- aqua: "#00ffff",
307
- cyan: "#00ffff",
308
- fuchsia: "#ff00ff",
309
- magenta: "#ff00ff",
310
- olive: "#808000",
311
- darkGray: "#a9a9a9",
312
- lightGray: "#d3d3d3",
313
- dkGray: "#a9a9a9",
314
- ltGray: "#d3d3d3"
315
- }, ee = (t) => {
316
- const n = t.replace("#", "");
317
- return [parseInt(n.slice(0, 2), 16) || 0, parseInt(n.slice(2, 4), 16) || 0, parseInt(n.slice(4, 6), 16) || 0];
318
- }, ft = (t, n, e) => "#" + [t, n, e].map((o) => Math.max(0, Math.min(255, Math.round(o))).toString(16).padStart(2, "0")).join(""), ot = (t) => (t /= 255, t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4)), U = (t) => 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * Math.pow(t, 1 / 2.4) - 0.055);
319
- function Xt(t, n, e) {
320
- t /= 255, n /= 255, e /= 255;
321
- const o = Math.max(t, n, e), s = Math.min(t, n, e), r = (o + s) / 2;
322
- if (o === s) return [0, 0, r];
323
- const a = o - s, i = r > 0.5 ? a / (2 - o - s) : a / (o + s);
324
- return [(o === t ? (n - e) / a + (n < e ? 6 : 0) : o === n ? (e - t) / a + 2 : (t - n) / a + 4) * 60, i, r];
325
- }
326
- function bt(t, n, e) {
327
- if (t = (t % 360 + 360) % 360 / 360, n === 0) return [e * 255, e * 255, e * 255];
328
- const o = e < 0.5 ? e * (1 + n) : e + n - e * n, s = 2 * e - o, r = (a) => (a = (a % 1 + 1) % 1, a < 1 / 6 ? s + (o - s) * 6 * a : a < 1 / 2 ? o : a < 2 / 3 ? s + (o - s) * (2 / 3 - a) * 6 : s);
329
- return [r(t + 1 / 3) * 255, r(t) * 255, r(t - 1 / 3) * 255];
330
- }
331
- function j(t, n) {
332
- const e = N(t).find((o) => /Clr$/.test(o.localName));
333
- return e ? $e(e, n) : null;
334
- }
335
- function $e(t, n) {
336
- let e = null, o = 1;
337
- switch (t.localName) {
338
- case "srgbClr": {
339
- const l = k(t, "val");
340
- e = l && /^[0-9a-f]{6}$/i.test(l) ? "#" + l.toLowerCase() : null;
341
- break;
342
- }
343
- case "sysClr": {
344
- const l = k(t, "lastClr");
345
- e = l ? "#" + l.toLowerCase() : k(t, "val") === "window" ? "#ffffff" : "#000000";
346
- break;
347
- }
348
- case "prstClr":
349
- e = je[k(t, "val") || ""] ?? "#000000";
350
- break;
351
- case "scrgbClr":
352
- e = ft(U(C(t, "r") / 1e5), U(C(t, "g") / 1e5), U(C(t, "b") / 1e5));
353
- break;
354
- case "hslClr": {
355
- const [l, p, x] = bt(C(t, "hue") / 6e4, C(t, "sat") / 1e5, C(t, "lum") / 1e5);
356
- e = ft(l, p, x);
357
- break;
358
- }
359
- case "schemeClr": {
360
- const l = k(t, "val") || "";
361
- if (l === "phClr") {
362
- n.phClr ? (e = n.phClr.hex, o = n.phClr.alpha ?? 1) : e = n.theme.colors.accent1 ?? "#4472c4";
363
- break;
364
- }
365
- const p = n.clrMap[l] ?? It[l] ?? l;
366
- e = n.theme.colors[p] ?? null;
367
- break;
368
- }
369
- }
370
- if (!e) return null;
371
- let [s, r, a] = ee(e);
372
- for (const l of N(t)) {
373
- const p = C(l, "val") / 1e5;
374
- switch (l.localName) {
375
- case "alpha":
376
- o = p;
377
- break;
378
- case "alphaMod":
379
- o *= p;
380
- break;
381
- case "alphaOff":
382
- o += p;
383
- break;
384
- case "lumMod":
385
- case "lumOff":
386
- case "satMod":
387
- case "satOff":
388
- case "hueMod":
389
- case "hueOff": {
390
- let [x, u, g] = Xt(s, r, a);
391
- l.localName === "lumMod" ? g *= p : l.localName === "lumOff" ? g += p : l.localName === "satMod" ? u *= p : l.localName === "satOff" ? u += p : l.localName === "hueMod" ? x *= p : x += C(l, "val") / 6e4, [s, r, a] = bt(x, Math.max(0, Math.min(1, u)), Math.max(0, Math.min(1, g)));
392
- break;
393
- }
394
- case "tint":
395
- [s, r, a] = [s, r, a].map((x) => U(ot(x) * p + (1 - p)));
396
- break;
397
- case "shade":
398
- [s, r, a] = [s, r, a].map((x) => U(ot(x) * p));
399
- break;
400
- case "comp": {
401
- const [x, u, g] = Xt(s, r, a);
402
- [s, r, a] = bt(x + 180, u, g);
403
- break;
404
- }
405
- case "inv":
406
- [s, r, a] = [255 - s, 255 - r, 255 - a];
407
- break;
408
- case "gray": {
409
- s = r = a = 0.299 * s + 0.587 * r + 0.114 * a;
410
- break;
411
- }
412
- }
413
- }
414
- o = Math.max(0, Math.min(1, o));
415
- const i = { hex: ft(s, r, a) };
416
- return o < 0.999 && (i.alpha = o), i;
417
- }
418
- function q(t, n) {
419
- for (const e of N(t)) {
420
- const o = Nt(e, n);
421
- if (o) return o;
422
- }
423
- }
424
- function Nt(t, n) {
425
- switch (t.localName) {
426
- case "noFill":
427
- return { kind: "none" };
428
- case "solidFill": {
429
- const e = j(t, n.ctx);
430
- return e ? { kind: "solid", color: e } : { kind: "none" };
431
- }
432
- case "gradFill": {
433
- const e = N(c(t, "gsLst"), "gs").slice(0, 256).map((s) => ({ pos: C(s, "pos") / 1e5, color: j(s, n.ctx) ?? { hex: "#000000" } }));
434
- if (!e.length) return { kind: "none" };
435
- const o = c(t, "lin");
436
- return c(t, "path") ? { kind: "radial", stops: e } : { kind: "linear", stops: e, angle: o ? C(o, "ang") / 6e4 : 90, scaled: B(o, "scaled") ?? !1 };
437
- }
438
- case "blipFill": {
439
- const e = ne(t, n);
440
- if (!e) return;
441
- const o = { kind: "image", media: e }, s = c(t, "tile");
442
- s && (o.tile = { sx: Math.max(0.01, C(s, "sx", 1e5) / 1e5), sy: Math.max(0.01, C(s, "sy", 1e5) / 1e5) });
443
- const r = c(c(t, "blip"), "alphaModFix");
444
- return r && (o.alpha = Math.max(0, Math.min(1, C(r, "amt", 1e5) / 1e5))), c(c(t, "blip"), "grayscl") && (o.grayscale = !0), o;
445
- }
446
- case "pattFill": {
447
- const e = j(c(t, "fgClr"), n.ctx), o = j(c(t, "bgClr"), n.ctx);
448
- return e ? { kind: "pattern", preset: k(t, "prst") || "pct50", color: e, ...o ? { bg: o } : {} } : void 0;
449
- }
450
- case "grpFill":
451
- return;
452
- }
453
- }
454
- const Be = {
455
- png: "png",
456
- jpg: "jpeg",
457
- jpeg: "jpeg",
458
- jpe: "jpeg",
459
- gif: "gif",
460
- svg: "svg",
461
- bmp: "bmp",
462
- tif: "tiff",
463
- tiff: "tiff",
464
- webp: "webp",
465
- emf: "emf",
466
- wmf: "wmf"
467
- };
468
- function ne(t, n) {
469
- const e = c(t, "blip"), o = k(e, "r:embed");
470
- if (!o) return null;
471
- const s = n.pkg.rels(n.part).get(o);
472
- if (!s || s.external) return null;
473
- const r = n.pkg.bytes(s.target), a = Be[(s.target.split(".").pop() || "").toLowerCase()];
474
- return r && a ? { bytes: r, ext: a } : null;
475
- }
476
- const ze = { solid: "", dot: "sysDot", sysDot: "sysDot", sysDash: "dash", dash: "dash", lgDash: "dash", dashDot: "dash", lgDashDot: "dash", lgDashDotDot: "dash", sysDashDot: "dash", sysDashDotDot: "dash" };
477
- function G(t, n) {
478
- if (!t) return;
479
- let e;
480
- for (const i of N(t)) {
481
- if (i.localName === "noFill") return null;
482
- i.localName === "solidFill" && (e = j(i, n.ctx)), i.localName === "gradFill" && (e = j(c(c(i, "gsLst"), "gs"), n.ctx));
483
- }
484
- const o = k(t, "w");
485
- if (e === void 0 && o === null && !c(t, "prstDash") && !c(t, "headEnd") && !c(t, "tailEnd")) return;
486
- const s = (i) => {
487
- const l = k(i, "type");
488
- if (!l || l === "none") return;
489
- const p = l === "triangle" || l === "stealth" || l === "arrow" || l === "oval" || l === "diamond" ? l : "triangle", x = k(i, "len") || k(i, "w");
490
- return { type: p, size: x === "sm" || x === "lg" ? x : "med" };
491
- }, r = ze[k(c(t, "prstDash"), "val") || "solid"], a = k(t, "cap");
492
- return {
493
- // ECMA's default is 9525 EMU — 0.75 pt, one px.
494
- width: o !== null ? Math.max(0, R(Number(o) || 0)) : 1,
495
- color: e ?? { hex: "#000000" },
496
- dash: r || void 0,
497
- cap: a === "rnd" ? "rnd" : a === "sq" ? "sq" : a === "flat" ? "flat" : void 0,
498
- join: c(t, "round") ? "round" : c(t, "bevel") ? "bevel" : c(t, "miter") ? "miter" : void 0,
499
- head: s(c(t, "headEnd")),
500
- tail: s(c(t, "tailEnd"))
501
- };
502
- }
503
- function dt(t, n) {
504
- const e = c(t, "fillRef");
505
- if (!e) return;
506
- const o = C(e, "idx");
507
- if (o === 0) return { kind: "none" };
508
- const r = (o >= 1001 ? n.ctx.theme.bgFills : n.ctx.theme.fills)[o >= 1001 ? o - 1001 : o - 1];
509
- if (!r) return;
510
- const a = j(e, n.ctx) ?? void 0;
511
- return Nt(r, { ...n, ctx: { ...n.ctx, phClr: a } });
512
- }
513
- function Ot(t, n) {
514
- const e = c(t, "lnRef");
515
- if (!e) return;
516
- const o = C(e, "idx");
517
- if (o === 0) return null;
518
- const s = n.ctx.theme.lines[o - 1];
519
- if (!s) return;
520
- const r = j(e, n.ctx) ?? void 0;
521
- return G(s, { ...n, ctx: { ...n.ctx, phClr: r } }) ?? void 0;
522
- }
523
- function W(t) {
524
- if (!t) return null;
525
- const n = c(t, "off"), e = c(t, "ext");
526
- return !n || !e ? null : {
527
- x: R(C(n, "x")),
528
- y: R(C(n, "y")),
529
- w: Math.max(0, R(C(e, "cx"))),
530
- h: Math.max(0, R(C(e, "cy"))),
531
- rot: C(t, "rot") / 6e4,
532
- flipH: !!B(t, "flipH"),
533
- flipV: !!B(t, "flipV")
534
- };
535
- }
536
- const yt = (t) => t;
537
- function Xe(t, n) {
538
- const e = W(t);
539
- if (!e) return n;
540
- const o = c(t, "chOff"), s = c(t, "chExt"), r = o ? R(C(o, "x")) : e.x, a = o ? R(C(o, "y")) : e.y, i = s ? R(C(s, "cx")) : e.w, l = s ? R(C(s, "cy")) : e.h, p = i > 0 ? e.w / i : 1, x = l > 0 ? e.h / l : 1, u = e.x + e.w / 2, g = e.y + e.h / 2, b = e.rot * Math.PI / 180;
541
- return (f) => {
542
- let h = e.x + (f.x + f.w / 2 - r) * p, y = e.y + (f.y + f.h / 2 - a) * x, d = f.rot, m = f.flipH, w = f.flipV;
543
- if (e.flipH && (h = 2 * u - h, m = !m, d = -d), e.flipV && (y = 2 * g - y, w = !w, d = -d), b) {
544
- const v = h - u, I = y - g;
545
- h = u + v * Math.cos(b) - I * Math.sin(b), y = g + v * Math.sin(b) + I * Math.cos(b), d += e.rot;
546
- }
547
- const M = f.w * p, S = f.h * x;
548
- return n({ x: h - M / 2, y: y - S / 2, w: M, h: S, rot: (d % 360 + 360) % 360, flipH: m, flipV: w });
549
- };
550
- }
551
- function Ht(t) {
552
- const n = c(t, "spcPts"), e = c(t, "spcPct");
553
- if (n) return { px: Math.max(0, Math.min(1584, C(n, "val") / 100)) * (Tt / z) };
554
- if (e) return { lines: Math.max(0, Math.min(13.2, C(e, "val") / 1e5)) };
555
- }
556
- function Yt(t, n, e) {
557
- const o = c(t, `lvl${n + 1}pPr`) ?? (t && t.localName.endsWith("pPr") ? t : null);
558
- return o ? oe(o, e) : {};
559
- }
560
- function oe(t, n) {
561
- const e = {};
562
- if (k(t, "algn") && (e.algn = k(t, "algn")), k(t, "marL") !== null && (e.marL = R(C(t, "marL"))), k(t, "indent") !== null && (e.indent = R(C(t, "indent"))), c(t, "buNone")) e.bullet = "none";
563
- else if (c(t, "buAutoNum")) {
564
- const a = c(t, "buAutoNum");
565
- e.bullet = "num", e.numType = k(a, "type") || "arabicPeriod", e.startAt = k(a, "startAt") !== null ? Math.max(1, Math.min(32767, Math.round(C(a, "startAt", 1)))) : void 0;
566
- } else c(t, "buChar") ? (e.bullet = "char", e.buChar = k(c(t, "buChar"), "char") || void 0) : c(t, "buBlip") && (e.bullet = "char", e.buChar = "•");
567
- if (c(t, "buFont") ? e.buFont = k(c(t, "buFont"), "typeface") || null : c(t, "buFontTx") && (e.buFont = null), c(t, "buClr") ? e.buClr = j(c(t, "buClr"), n.ctx) : c(t, "buClrTx") && (e.buClr = null), c(t, "buSzPct")) {
568
- const a = k(c(t, "buSzPct"), "val") || "", i = a.endsWith("%") ? parseFloat(a) / 100 : Number(a) / 1e5;
569
- e.buSz = Number.isFinite(i) && i > 0 ? Math.max(0.25, Math.min(4, i)) : null;
570
- } else (c(t, "buSzTx") || c(t, "buSzPts")) && (e.buSz = null);
571
- const o = A(t, "lnSpc", "spcPct");
572
- o && (e.lnSpcPct = C(o, "val") / 1e5);
573
- const s = Ht(c(t, "spcBef")), r = Ht(c(t, "spcAft"));
574
- return s && (e.spcBef = s), r && (e.spcAft = r), Object.assign(e, se(c(t, "defRPr"), n)), e;
575
- }
576
- function se(t, n) {
577
- if (!t) return {};
578
- const e = {};
579
- k(t, "sz") !== null && (e.sz = C(t, "sz") / 100 * (Tt / z)), B(t, "b") !== void 0 && (e.b = B(t, "b")), B(t, "i") !== void 0 && (e.i = B(t, "i")), k(t, "u") && (e.u = k(t, "u") !== "none"), k(t, "strike") && (e.strike = k(t, "strike") !== "noStrike");
580
- const o = c(t, "solidFill");
581
- o ? e.color = j(o, n.ctx) : c(t, "noFill") && (e.color = null);
582
- const s = k(c(t, "latin"), "typeface");
583
- return s && (e.font = s), e;
584
- }
585
- const He = {
586
- 108: "●",
587
- 110: "■",
588
- 111: "□",
589
- 113: "❑",
590
- 117: "◆",
591
- 118: "❖",
592
- 159: "•",
593
- 167: "▪",
594
- 168: "◻",
595
- 216: "➢",
596
- 252: "✔",
597
- 251: "✗",
598
- 254: "☑"
599
- }, Ye = { 183: "•", 168: "♦", 174: "→", 222: "⇒", 45: "−", 42: "∗" };
600
- function We(t, n) {
601
- if (!t) return "•";
602
- let e = t.codePointAt(0);
603
- e >= 61440 && e <= 61695 && (e -= 61440);
604
- const o = (n || "").toLowerCase();
605
- return o.startsWith("wingdings") ? o === "wingdings" && He[e] || "•" : o === "symbol" ? Ye[e] ?? (e < 128 && e > 32 ? String.fromCharCode(e) : "•") : o.startsWith("webdings") || o.startsWith("marlett") ? "•" : o === "courier new" && t === "o" ? "◦" : /\s/.test(t) || e < 32 ? "•" : [...t][0];
606
- }
607
- const Wt = (...t) => {
608
- const n = {};
609
- for (const e of t) for (const [o, s] of Object.entries(e)) s !== void 0 && (n[o] = s);
610
- return n;
611
- };
612
- function _e(t, n) {
613
- if (t)
614
- return t.startsWith("+mj") ? n.major : t.startsWith("+mn") ? n.minor : t;
615
- }
616
- function At(t, n, e) {
617
- if (!t) return;
618
- const o = N(t, "p");
619
- if (!o.some((b) => N(b).some((f) => (f.localName === "r" || f.localName === "fld") && (A(f, "t")?.textContent ?? "") !== ""))) return;
620
- const r = {};
621
- let a = 1, i = 1;
622
- for (const b of [...n.bodyPr, c(t, "bodyPr")]) {
623
- if (!b) continue;
624
- for (let h = 0; h < b.attributes.length; h++) r[b.attributes[h].localName ?? b.attributes[h].name] = b.attributes[h].value;
625
- const f = c(b, "normAutofit");
626
- f && (a = k(f, "fontScale") !== null ? C(f, "fontScale") / 1e5 : 1), f && (i = 1 - Math.max(0, Math.min(0.9, C(f, "lnSpcReduction") / 1e5))), (c(b, "noAutofit") || c(b, "spAutoFit")) && (a = 1, i = 1);
627
- }
628
- const l = (b, f) => r[b] !== void 0 ? R(Number(r[b]) || 0) : R(f), p = r.anchor === "ctr" ? "ctr" : r.anchor === "b" ? "b" : "t", x = c(t, "lstStyle"), u = [];
629
- let g;
630
- for (const b of o) {
631
- const f = c(b, "pPr"), h = Math.max(0, Math.min(8, C(f, "lvl"))), y = n.fontRef ? { color: n.fontRef.color ?? void 0, font: n.fontRef.font } : {}, d = Wt(...n.levels.map((P) => Yt(P, h, e)), y, Yt(x, h, e), f ? oe(f, e) : {});
632
- d.lnSpcPct !== void 0 && g === void 0 && (g = d.lnSpcPct);
633
- const m = { runs: [], align: d.algn === "ctr" ? "ctr" : d.algn === "r" ? "r" : (d.algn === "just", "l"), level: h };
634
- if (d.bullet === "char" || d.bullet === "num") {
635
- if (m.bullet = d.bullet, m.marL = d.marL ?? 0, m.indent = d.indent ?? 0, d.bullet === "char") {
636
- const P = We(d.buChar, d.buFont ?? void 0);
637
- P !== "•" && (m.bulletChar = P);
638
- } else
639
- d.numType && d.numType !== "arabicPeriod" && (m.numType = d.numType), d.startAt && d.startAt !== 1 && (m.startAt = d.startAt);
640
- d.buClr && (m.bulletColor = d.buClr), d.buSz && Math.abs(d.buSz - 1) > 1e-3 && (m.bulletScale = d.buSz);
641
- }
642
- const w = (P) => {
643
- const E = Wt(d, se(P, e)), X = (E.sz ?? 18 * Tt / z) * a, H = E.color === null ? void 0 : E.color ?? re("tx1", e);
644
- return {
645
- text: "",
646
- size: X,
647
- bold: E.b || void 0,
648
- italic: E.i || void 0,
649
- underline: E.u || void 0,
650
- strike: E.strike || void 0,
651
- color: H ?? void 0,
652
- font: _e(E.font ?? "+mn-lt", e.ctx.theme)
653
- };
654
- };
655
- for (const P of N(b))
656
- if (P.localName === "r" || P.localName === "fld") {
657
- const E = A(P, "t")?.textContent ?? "";
658
- if (!E) continue;
659
- E.split(/[\v\n]/).forEach((X, H) => {
660
- H > 0 && m.runs.push({ ...w(c(P, "rPr")), br: !0 }), X && m.runs.push({ ...w(c(P, "rPr")), text: X });
661
- });
662
- } else P.localName === "br" && m.runs.push({ ...w(c(P, "rPr")), br: !0 });
663
- m.endSize = w(c(b, "endParaRPr")).size;
664
- const M = (m.runs.length ? Math.max(...m.runs.map((P) => P.size ?? 0)) : m.endSize ?? 0) * 1.2 * (d.lnSpcPct ?? 1), S = (P) => P ? ("px" in P ? P.px : P.lines * M) * i : 0, v = S(d.spcBef), I = S(d.spcAft);
665
- v > 0.05 && (m.spaceBefore = Math.round(v * 100) / 100), I > 0.05 && (m.spaceAfter = Math.round(I * 100) / 100), u.push(m);
666
- }
667
- return {
668
- paragraphs: u,
669
- anchor: p,
670
- insets: { l: l("lIns", 91440), t: l("tIns", 45720), r: l("rIns", 91440), b: l("bIns", 45720) },
671
- wrap: r.wrap !== "none",
672
- lineSpacing: g
673
- };
674
- }
675
- const re = (t, n) => {
676
- const e = n.ctx.clrMap[t] ?? It[t] ?? t, o = n.ctx.theme.colors[e];
677
- return o ? { hex: o } : null;
678
- }, Q = (t) => {
679
- const n = c(t, "ph");
680
- return n ? { type: k(n, "type") || "obj", idx: C(n, "idx") } : null;
681
- }, st = (t) => c(N(t).find((n) => n.localName.startsWith("nv")) ?? null, "nvPr"), it = /* @__PURE__ */ new Set(["title", "ctrTitle"]), _t = /* @__PURE__ */ new Set(["title", "ctrTitle", "dt", "ftr", "sldNum", "hdr"]), Ut = (t, n) => t === n || it.has(t) && it.has(n) || !_t.has(t) && !_t.has(n);
682
- function ht(t, n) {
683
- const e = Ue(t);
684
- if (n.idx) {
685
- const o = e.find((s) => s.ph.idx === n.idx && Ut(s.ph.type, n.type));
686
- if (o) return o.el;
687
- }
688
- return (e.find((o) => o.ph.type === n.type && (o.ph.idx === n.idx || !n.idx || it.has(n.type))) ?? e.find((o) => o.ph.type === n.type) ?? e.find((o) => Ut(o.ph.type, n.type)))?.el ?? null;
689
- }
690
- function Ue(t) {
691
- const n = [];
692
- for (const e of V(t)) {
693
- const o = Q(st(e));
694
- o && n.push({ el: e, ph: o });
695
- }
696
- return n;
697
- }
698
- const ae = (t) => it.has(t) ? "title" : ["dt", "ftr", "sldNum", "hdr"].includes(t) ? t : "body", Ge = (t) => {
699
- const n = {};
700
- for (const e of N(c(t, "avLst"), "gd")) {
701
- const o = k(e, "name"), s = k(e, "fmla");
702
- o && s && (n[o] = s);
703
- }
704
- return n;
705
- };
706
- function Ve(t) {
707
- const n = (r) => N(r, "gd").slice(0, 1e4).map((a) => [k(a, "name") || "", k(a, "fmla") || "val 0"]), e = N(c(t, "cxnLst"), "cxn").map((r) => [k(r, "ang") || "0", k(c(r, "pos"), "x") || "0", k(c(r, "pos"), "y") || "0"]), o = c(t, "rect"), s = N(c(t, "pathLst"), "path").slice(0, 1e3).map((r) => {
708
- const a = [];
709
- for (const l of N(r)) {
710
- const p = N(l, "pt").map((x) => [k(x, "x") || "0", k(x, "y") || "0"]).flat();
711
- switch (l.localName) {
712
- case "moveTo":
713
- a.push(["M", ...p]);
714
- break;
715
- case "lnTo":
716
- a.push(["L", ...p]);
717
- break;
718
- case "quadBezTo":
719
- a.push(["Q", ...p]);
720
- break;
721
- case "cubicBezTo":
722
- a.push(["C", ...p]);
723
- break;
724
- case "arcTo":
725
- a.push(["A", k(l, "wR") || "0", k(l, "hR") || "0", k(l, "stAng") || "0", k(l, "swAng") || "0"]);
726
- break;
727
- case "close":
728
- a.push(["Z"]);
729
- break;
730
- }
731
- }
732
- const i = k(r, "fill");
733
- return { w: C(r, "w") || void 0, h: C(r, "h") || void 0, fill: i && i !== "norm" ? i : void 0, stroke: B(r, "stroke") === !1 ? !1 : void 0, d: a };
734
- });
735
- return {
736
- av: N(c(t, "avLst"), "gd").map((r) => [k(r, "name") || "", k(r, "fmla") || "val 0"]),
737
- gd: n(c(t, "gdLst")),
738
- cxn: e,
739
- rect: o ? [k(o, "l") || "l", k(o, "t") || "t", k(o, "r") || "r", k(o, "b") || "b"] : null,
740
- paths: s
741
- };
742
- }
743
- function rt(t, n) {
744
- const e = c(t, "prstGeom");
745
- if (e) {
746
- const s = {};
747
- for (const [r, a] of Object.entries(Ge(e))) {
748
- const i = /^val\s+(-?\d+(\.\d+)?)/.exec(a);
749
- i && (s[r] = Number(i[1]));
750
- }
751
- return { geom: { kind: "preset", prst: k(e, "prst") || "rect", adj: Object.keys(s).length ? s : void 0 } };
752
- }
753
- const o = c(t, "custGeom");
754
- if (o) {
755
- const s = Ve(o);
756
- return { geom: { kind: "custom", paths: ut(s, n.w, n.h) }, textRect: s.rect ? te(s, n.w, n.h) : void 0 };
757
- }
758
- }
759
- function at(t, n, e, o, s, r) {
760
- const a = [];
761
- if (s > Ae)
762
- return e.warnings.push("Groups nested too deeply; the innermost were skipped."), a;
763
- for (const i of V(t)) {
764
- if (++e.count > Le) {
765
- e.warnings.push("Too many shapes on one slide; the rest were skipped.");
766
- break;
767
- }
768
- try {
769
- const l = Ke(i, n, e, o, s, r);
770
- l && a.push(...Array.isArray(l) ? l : [l]);
771
- } catch {
772
- e.warnings.push(`A ${i.localName} couldn't be read and was skipped.`);
773
- }
774
- }
775
- return a;
776
- }
777
- const qe = {
778
- nextslide: "next",
779
- previousslide: "previous",
780
- firstslide: "first",
781
- lastslide: "last",
782
- endshow: "end"
783
- };
784
- function Ze(t, n, e) {
785
- const o = c(t, "hlinkClick");
786
- if (!o) return;
787
- const s = k(o, "action") || "", r = e.rels(n).get(k(o, "r:id") || "");
788
- if (s.startsWith("ppaction://hlinkshowjump")) {
789
- const a = qe[(/jump=([a-z]+)/i.exec(s)?.[1] ?? "").toLowerCase()];
790
- return a ? { kind: "action", action: a } : void 0;
791
- }
792
- if (s.startsWith("ppaction://hlinksldjump")) return r && !r.external ? { kind: "slide", key: r.target } : void 0;
793
- if (!s)
794
- return r?.external && /^(https?:|mailto:|tel:)/i.test(r.target) ? { kind: "url", url: r.target } : void 0;
795
- }
796
- function Ke(t, n, e, o, s, r) {
797
- const a = N(t).find((p) => p.localName.startsWith("nv")), i = Qe(t, n, e, o, s, r), l = i ? Ze(c(a ?? null, "cNvPr"), n.part, e.pkg) : void 0;
798
- if (l) for (const p of Array.isArray(i) ? i : [i]) p.link = l;
799
- return i;
800
- }
801
- function Qe(t, n, e, o, s, r) {
802
- const a = { pkg: e.pkg, part: n.part, ctx: e.ctx }, i = N(t).find((u) => u.localName.startsWith("nv")), l = c(i ?? null, "cNvPr"), p = C(l, "id"), x = k(l, "name") || t.localName;
803
- if (k(l, "hidden") === "1") return null;
804
- switch (t.localName) {
805
- case "sp":
806
- return en(t, n, e, o, p, x, r);
807
- case "cxnSp": {
808
- const u = c(t, "spPr"), g = W(c(u, "xfrm"));
809
- if (!g) return null;
810
- const b = o(g), f = c(t, "style"), h = G(c(u, "ln"), a) ?? Ot(f, a) ?? { width: 1, color: { hex: "#000000" } };
811
- if (!h) return null;
812
- const y = rt(u, b) ?? { geom: { kind: "preset", prst: "line" } }, d = (w) => w ? { id: C(w, "id"), idx: C(w, "idx") } : void 0, m = c(i ?? null, "cNvCxnSpPr");
813
- return { kind: "connector", id: p, name: x, ...b, geom: y.geom, line: h, start: d(c(m, "stCxn")), end: d(c(m, "endCxn")) };
814
- }
815
- case "pic": {
816
- const u = c(t, "spPr");
817
- let g = W(c(u, "xfrm"));
818
- const b = Q(c(i ?? null, "nvPr"));
819
- if (!g && b && (g = Je(b, e)), !g) return null;
820
- const f = c(t, "blipFill"), h = f ? ne(f, a) : null;
821
- if (!h)
822
- return e.warnings.push(`Picture "${x}" has no image the importer can read.`), null;
823
- const y = c(f, "srcRect"), d = y ? { l: C(y, "l") / 1e5, t: C(y, "t") / 1e5, r: C(y, "r") / 1e5, b: C(y, "b") / 1e5 } : void 0, m = k(A(f, "blip", "alphaModFix"), "amt"), w = o(g), M = rt(u, w)?.geom, S = M && !(M.kind === "preset" && M.prst === "rect") ? M : void 0;
824
- return { kind: "picture", id: p, name: x, ...w, media: h, crop: d, alpha: m !== null ? Number(m) / 1e5 : void 0, descr: k(l, "descr") || void 0, geom: S, ...A(f, "blip", "grayscl") ? { grayscale: !0 } : {} };
825
- }
826
- case "grpSp": {
827
- const u = c(t, "grpSpPr"), g = c(u, "xfrm"), b = Xe(g, o), f = at(t, n, e, b, s + 1, r);
828
- if (!f.length) return null;
829
- const h = pt(f);
830
- return { kind: "group", id: p, name: x, ...h, children: f };
831
- }
832
- case "graphicFrame":
833
- return sn(t, n, e, o, p, x, s);
834
- default:
835
- return null;
836
- }
837
- }
838
- function pt(t) {
839
- let n = 1 / 0, e = 1 / 0, o = -1 / 0, s = -1 / 0;
840
- for (const r of t)
841
- n = Math.min(n, r.x), e = Math.min(e, r.y), o = Math.max(o, r.x + r.w), s = Math.max(s, r.y + r.h);
842
- return { x: n, y: e, w: Math.max(0, o - n), h: Math.max(0, s - e) };
843
- }
844
- function Je(t, n) {
845
- const e = ht(n.layout?.tree ?? null, t), o = W(A(e, "spPr", "xfrm"));
846
- if (o) return o;
847
- const s = ht(n.master?.tree ?? null, { type: ae(t.type), idx: 0 });
848
- return W(A(s, "spPr", "xfrm"));
849
- }
850
- function tn(...t) {
851
- for (const n of t) {
852
- const e = n();
853
- if (e !== void 0) return e;
854
- }
855
- }
856
- function en(t, n, e, o, s, r, a) {
857
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, l = st(t), p = Q(l);
858
- if (p && !a) return null;
859
- const x = c(t, "spPr"), u = c(t, "style"), g = k(A(t, "nvSpPr", "cNvSpPr"), "txBox") === "1", b = p && e.layout ? ht(e.layout.tree, p) : null, f = p && e.master ? ht(e.master.tree, { type: ae(b ? Q(st(b))?.type ?? p.type : p.type), idx: 0 }) : null, h = b && e.layout ? { pkg: e.pkg, part: e.layout.part, ctx: e.ctx } : null, y = f && e.master ? { pkg: e.pkg, part: e.master.part, ctx: e.ctx } : null;
860
- let d = W(c(x, "xfrm")) ?? W(A(b, "spPr", "xfrm")) ?? W(A(f, "spPr", "xfrm"));
861
- if (!d) return null;
862
- d = o(d);
863
- const m = rt(x, d) ?? (b ? rt(c(b, "spPr"), d) : void 0) ?? (f ? rt(c(f, "spPr"), d) : void 0) ?? { geom: { kind: "preset", prst: "rect" } }, M = (B(t, "useBgFill") ? e.background?.kind === "image" ? { kind: "none" } : e.background ?? { kind: "solid", color: { hex: "#ffffff" } } : void 0) ?? q(x, i) ?? dt(u, i) ?? (h ? q(c(b, "spPr"), h) : void 0) ?? (y ? q(c(f, "spPr"), y) : void 0) ?? (h ? dt(c(b, "style"), h) : void 0) ?? { kind: "none" }, S = tn(
864
- () => G(c(x, "ln"), i),
865
- () => Ot(u, i),
866
- () => h ? G(A(b, "spPr", "ln"), h) : void 0,
867
- () => y ? G(A(f, "spPr", "ln"), y) : void 0
868
- ) ?? null, v = [];
869
- if (p) {
870
- const O = b ? Q(st(b))?.type ?? p.type : p.type;
871
- v.push(it.has(O) ? e.masterTx.title : ["body", "obj", "subTitle", "tbl", "chart", "dgm", "media", "pic", "clipArt"].includes(O) ? e.masterTx.body : e.masterTx.other), v.push(A(f, "txBody", "lstStyle"), A(b, "txBody", "lstStyle"));
872
- } else
873
- v.push(e.defaultText);
874
- const I = c(u, "fontRef"), P = {
875
- levels: v,
876
- bodyPr: [A(f, "txBody", "bodyPr"), A(b, "txBody", "bodyPr")],
877
- fontRef: I ? { font: k(I, "idx") === "major" ? "+mj-lt" : "+mn-lt", color: j(I, i.ctx) } : void 0
878
- }, E = At(c(t, "txBody"), P, i);
879
- if (!(M.kind !== "none" || !!S || !!E)) return null;
880
- let H = m.textRect;
881
- const T = W(c(x, "xfrm")), L = E ? W(c(t, "txXfrm")) : null;
882
- if (L && T && T.w > 0 && T.h > 0) {
883
- const O = d.w / T.w, Y = d.h / T.h, D = { l: (L.x - T.x) * O, t: (L.y - T.y) * Y, r: (L.x + L.w - T.x) * O, b: (L.y + L.h - T.y) * Y };
884
- (Math.abs(D.l) > 0.5 || Math.abs(D.t) > 0.5 || Math.abs(D.r - d.w) > 0.5 || Math.abs(D.b - d.h) > 0.5) && (H = D);
885
- }
886
- return { kind: "shape", id: s, name: r, ...d, geom: m.geom, fill: M, line: S, text: E, textBox: g || void 0, textRect: H };
887
- }
888
- const Gt = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
889
- function nn(t, n) {
890
- const e = {};
891
- if (!t) return e;
892
- const o = c(t, "tcStyle"), s = c(t, "tcTxStyle"), r = c(o, "fill"), a = r ? q(r, n) : dt(o, n);
893
- a && (e.fill = a);
894
- const i = j(s, n.ctx) ?? j(c(s, "fontRef"), n.ctx);
895
- i && (e.text = i), k(s, "b") === "on" && (e.bold = !0);
896
- const l = c(o, "tcBdr");
897
- for (const p of ["insideH", "bottom", "top", "left"]) {
898
- const x = c(l, p);
899
- if (!x) continue;
900
- const u = G(c(x, "ln"), n) ?? Ot(x, n);
901
- if (u !== void 0) {
902
- e.border = u;
903
- break;
904
- }
905
- }
906
- return e;
907
- }
908
- function on(t, n, e) {
909
- const o = ((c(t, "tableStyleId")?.textContent || "").trim() || k(e, "def") || Gt).toUpperCase(), s = (u) => B(t, u) ?? !1, r = { firstRow: s("firstRow"), lastRow: s("lastRow"), firstCol: s("firstCol"), lastCol: s("lastCol"), bandRow: s("bandRow"), bandCol: s("bandCol") }, a = N(e, "tblStyle").find((u) => (k(u, "styleId") || "").toUpperCase() === o);
910
- if (a) {
911
- const u = (y) => nn(c(a, y), n), g = c(a, "tblBg"), b = g ? c(g, "fill") ? q(c(g, "fill"), n) : dt(g, n) : void 0, f = {
912
- whole: u("wholeTbl"),
913
- b1H: u("band1H"),
914
- b2H: u("band2H"),
915
- b1V: u("band1V"),
916
- b2V: u("band2V"),
917
- firstRow: u("firstRow"),
918
- lastRow: u("lastRow"),
919
- firstCol: u("firstCol"),
920
- lastCol: u("lastCol")
921
- }, h = (y, d, m, w) => {
922
- const M = [f.whole], S = y - (r.firstRow ? 1 : 0), v = d - (r.firstCol ? 1 : 0);
923
- r.bandCol && v >= 0 && M.push(v % 2 === 0 ? f.b1V : f.b2V), r.bandRow && S >= 0 && M.push(S % 2 === 0 ? f.b1H : f.b2H), r.firstCol && d === 0 && M.push(f.firstCol), r.lastCol && d === w - 1 && M.push(f.lastCol), r.firstRow && y === 0 && M.push(f.firstRow), r.lastRow && y === m - 1 && M.push(f.lastRow);
924
- const I = {};
925
- for (const P of M)
926
- P.fill && (I.fill = P.fill), P.text && (I.text = P.text), P.bold && (I.bold = !0), P.border !== void 0 && (I.border = P.border);
927
- return I;
928
- };
929
- return b && b.kind !== "none" && (h.background = b), h;
930
- }
931
- if (o !== Gt) return null;
932
- const i = n.ctx.theme.colors.accent1 ?? "#4472c4", l = (u) => {
933
- const [g, b, f] = ee(i);
934
- return { hex: ft(U(ot(g) * u + (1 - u)), U(ot(b) * u + (1 - u)), U(ot(f) * u + (1 - u))) };
935
- }, p = { hex: n.ctx.theme.colors.lt1 ?? "#ffffff" }, x = re("tx1", n) ?? void 0;
936
- return (u) => {
937
- const g = r.firstRow && u === 0, b = r.bandRow && !g && (u - (r.firstRow ? 1 : 0)) % 2 === 0;
938
- return {
939
- fill: { kind: "solid", color: g ? { hex: i } : l(b ? 0.4 : 0.2) },
940
- text: g ? p : x,
941
- bold: g || void 0,
942
- border: { width: 1.33, color: p }
943
- };
944
- };
945
- }
946
- function sn(t, n, e, o, s, r, a = 0) {
947
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, l = W(c(t, "xfrm"));
948
- if (!l) return null;
949
- const p = A(t, "graphic", "graphicData"), x = c(p, "tbl");
950
- if (x) {
951
- const b = N(c(x, "tblGrid"), "gridCol").map((w) => R(C(w, "w"))), f = on(c(x, "tblPr"), i, e.tableStyles), h = [];
952
- let y = l.y, d = 1e6 + s * 1e3;
953
- const m = N(x, "tr");
954
- if (m.forEach((w, M) => {
955
- const S = R(C(w, "h"));
956
- let v = l.x, I = 0;
957
- for (const P of N(w, "tc")) {
958
- const E = Math.max(1, C(P, "gridSpan", 1)), X = b.slice(I, I + E).reduce((tt, K) => tt + K, 0);
959
- if (I += E, B(P, "hMerge") || B(P, "vMerge")) {
960
- v += X;
961
- continue;
962
- }
963
- const H = Math.max(1, C(P, "rowSpan", 1)), T = c(P, "tcPr"), L = H > 1 ? S * H : S, O = f ? f(M, I - E, m.length, b.length) : null, Y = O?.text ? { color: O.text } : void 0, D = At(c(P, "txBody"), { levels: [e.defaultText], bodyPr: [], fontRef: Y }, i);
964
- D && O?.bold && D.paragraphs.forEach((tt) => tt.runs.forEach((K) => {
965
- K.bold === void 0 && (K.bold = !0);
966
- })), D && (D.insets = { l: R(C(T, "marL", 91440)), r: R(C(T, "marR", 91440)), t: R(C(T, "marT", 45720)), b: R(C(T, "marB", 45720)) }, D.anchor = k(T, "anchor") === "ctr" ? "ctr" : k(T, "anchor") === "b" ? "b" : "t");
967
- const _ = G(c(T, "lnB"), i) ?? G(c(T, "lnT"), i) ?? (O ? O.border ?? null : { width: 1, color: { hex: "#bfbfbf" } }), Z = O?.fill;
968
- h.push({
969
- kind: "shape",
970
- id: d++,
971
- name: `${r} cell`,
972
- ...o({ x: v, y, w: X, h: L, rot: 0, flipH: !1, flipV: !1 }),
973
- geom: { kind: "preset", prst: "rect" },
974
- fill: q(T, i) ?? Z ?? { kind: "none" },
975
- line: _,
976
- text: D
977
- }), v += X;
978
- }
979
- y += S;
980
- }), !h.length) return null;
981
- if (f?.background) {
982
- const w = pt(h);
983
- h.unshift({
984
- kind: "shape",
985
- id: d++,
986
- name: `${r} background`,
987
- x: w.x,
988
- y: w.y,
989
- w: w.w,
990
- h: w.h,
991
- rot: 0,
992
- flipH: !1,
993
- flipV: !1,
994
- geom: { kind: "preset", prst: "rect" },
995
- fill: f.background,
996
- line: null
997
- });
998
- }
999
- return { kind: "group", id: s, name: r, ...pt(h), children: h };
1000
- }
1001
- const u = k(p, "uri") || "";
1002
- if (/diagram/.test(u)) {
1003
- const b = rn(p, n, e, o, l, s, r, a);
1004
- if (b) return b;
1005
- const f = an(p, n, e, o, l, s, r, i);
1006
- if (f) return f;
1007
- }
1008
- const g = /chart/.test(u) ? "Chart" : /diagram/.test(u) ? "SmartArt diagram" : "Embedded object";
1009
- return e.warnings.push(`${g} "${r}" was imported as a placeholder frame.`), {
1010
- kind: "shape",
1011
- id: s,
1012
- name: r,
1013
- ...o(l),
1014
- geom: { kind: "preset", prst: "rect" },
1015
- fill: { kind: "solid", color: { hex: "#f1f3f5" } },
1016
- line: { width: 1, color: { hex: "#adb5bd" }, dash: "dash" },
1017
- text: { paragraphs: [{ runs: [{ text: `${g}: ${r}`, size: 16, color: { hex: "#495057" } }], align: "ctr" }], anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
1018
- };
1019
- }
1020
- function rn(t, n, e, o, s, r, a, i) {
1021
- const l = e.pkg.rels(n.part), p = k(c(t, "relIds"), "r:dm"), x = p ? l.get(p) : void 0;
1022
- let u;
1023
- if (x && !x.external) {
1024
- const d = lt(e.pkg.xml(x.target), "dataModelExt", 6), m = d ? l.get(k(d, "relId") || "") : void 0;
1025
- m && !m.external && (u = m.target);
1026
- }
1027
- if (!u) {
1028
- const d = [...l.values()].filter((m) => m.type === "diagramDrawing" && !m.external);
1029
- d.length === 1 && (u = d[0].target);
1030
- }
1031
- if (!u) return null;
1032
- const g = c(e.pkg.xml(u), "spTree");
1033
- if (!g) return null;
1034
- const f = at(g, { part: u, tree: g }, e, (d) => o({ ...d, x: d.x + s.x, y: d.y + s.y }), i + 1, !0);
1035
- if (!f.length) return null;
1036
- let h = 2e6 + r * 1e3;
1037
- const y = (d) => d.forEach((m) => {
1038
- m.id = h++, m.kind === "group" && y(m.children);
1039
- });
1040
- return y(f), { kind: "group", id: r, name: a, ...pt(f), children: f };
1041
- }
1042
- function an(t, n, e, o, s, r, a, i) {
1043
- const l = k(c(t, "relIds"), "r:dm"), p = l ? e.pkg.rels(n.part).get(l) : void 0;
1044
- if (!p || p.external) return null;
1045
- const x = e.pkg.xml(p.target), u = /* @__PURE__ */ new Map();
1046
- for (const d of N(c(x, "ptLst"), "pt")) u.set(k(d, "modelId") || "", d);
1047
- const g = /* @__PURE__ */ new Map();
1048
- for (const d of N(c(x, "cxnLst"), "cxn")) {
1049
- if ((k(d, "type") || "parOf") !== "parOf") continue;
1050
- const m = k(d, "srcId") || "", w = k(d, "destId") || "";
1051
- g.has(m) || g.set(m, []), g.get(m).push({ id: w, ord: C(d, "srcOrd") });
1052
- }
1053
- const b = [...u.values()].find((d) => k(d, "type") === "doc");
1054
- if (!b) return null;
1055
- const f = [], h = /* @__PURE__ */ new Set(), y = (d, m) => {
1056
- if (!(h.has(d) || m > 16 || f.length > 500)) {
1057
- h.add(d);
1058
- for (const w of (g.get(d) ?? []).sort((M, S) => M.ord - S.ord)) {
1059
- const M = u.get(w.id), S = k(M, "type") || "node";
1060
- if (!M || S !== "node" && S !== "asst") continue;
1061
- const v = At(c(M, "t"), { levels: [e.defaultText], bodyPr: [] }, i);
1062
- for (const I of v?.paragraphs ?? [])
1063
- I.runs.some((P) => !P.br && P.text.trim()) && f.push({
1064
- ...I,
1065
- align: "l",
1066
- level: m,
1067
- ...m > 0 ? { bullet: "char" } : {},
1068
- runs: I.runs.map((P) => ({ ...P, size: P.size ?? (m > 0 ? 16 : 18), bold: P.bold ?? (m === 0 ? !0 : void 0) }))
1069
- });
1070
- y(w.id, m + 1);
1071
- }
1072
- }
1073
- };
1074
- return y(k(b, "modelId") || "", 0), f.length ? (e.warnings.push(`SmartArt diagram "${a}" had no saved drawing; its text was imported as a list.`), {
1075
- kind: "shape",
1076
- id: r,
1077
- name: a,
1078
- ...o(s),
1079
- geom: { kind: "preset", prst: "rect" },
1080
- fill: { kind: "none" },
1081
- line: null,
1082
- textBox: !0,
1083
- text: { paragraphs: f, anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
1084
- }) : null;
1085
- }
1086
- function lt(t, n, e) {
1087
- if (!t || e < 0) return null;
1088
- for (const o of V(t)) {
1089
- if (o.localName === n) return o;
1090
- const s = lt(o, n, e - 1);
1091
- if (s) return s;
1092
- }
1093
- return null;
1094
- }
1095
- function kt(t, n) {
1096
- const e = c(t, "bg");
1097
- if (!e) return;
1098
- const o = c(e, "bgPr");
1099
- if (o)
1100
- return q(o, n);
1101
- const s = c(e, "bgRef");
1102
- if (s) {
1103
- const r = C(s, "idx"), i = (r >= 1001 ? n.ctx.theme.bgFills : n.ctx.theme.fills)[r >= 1001 ? r - 1001 : r - 1];
1104
- return (i ? Nt(i, { ...n, ctx: { ...n.ctx, phClr: j(s, n.ctx) ?? void 0 } }) : void 0) ?? (j(s, n.ctx) ? { kind: "solid", color: j(s, n.ctx) } : void 0);
1105
- }
1106
- }
1107
- function ln(t, n) {
1108
- const e = t.relOfType(n, "notesSlide"), o = e ? A(t.xml(e), "cSld", "spTree") : null;
1109
- if (!o) return;
1110
- const s = [], r = (i) => {
1111
- for (const l of V(i)) {
1112
- if (l.localName === "grpSp") {
1113
- r(l);
1114
- continue;
1115
- }
1116
- if (l.localName !== "sp") continue;
1117
- const p = Q(st(l));
1118
- if (!(!p || p.type !== "body" && p.type !== "obj"))
1119
- for (const x of N(c(l, "txBody"), "p")) {
1120
- let u = "";
1121
- for (const g of N(x))
1122
- g.localName === "r" || g.localName === "fld" ? u += c(g, "t")?.textContent ?? "" : g.localName === "br" && (u += `
1123
- `);
1124
- s.push(u);
1125
- }
1126
- }
1127
- };
1128
- r(o);
1129
- const a = s.join(`
1130
- `).replace(/\s+$/, "");
1131
- return a.trim() ? a : void 0;
1132
- }
1133
- function cn(t) {
1134
- for (const a of N(t, "AlternateContent"))
1135
- for (const i of N(a, "Choice")) {
1136
- const l = c(i, "transition");
1137
- if (l && c(l, "morph")) {
1138
- const p = k(l, "spd");
1139
- return { kind: "morph", durationMs: k(l, "p14:dur") !== null ? C(l, "p14:dur") : p === "fast" ? 500 : p === "slow" ? 1e3 : 750 };
1140
- }
1141
- }
1142
- const n = V(t).find((a) => a.localName === "transition");
1143
- if (!n) return;
1144
- const e = N(n).find((a) => a.localName !== "sndAc" && a.localName !== "extLst");
1145
- if (!e) return;
1146
- const o = k(n, "spd"), s = k(n, "p14:dur") !== null ? C(n, "p14:dur") : o === "fast" ? 500 : o === "slow" ? 1e3 : 750, r = k(e, "dir");
1147
- switch (e.localName) {
1148
- case "push":
1149
- case "cover":
1150
- case "pull":
1151
- case "wipe":
1152
- return { kind: "push", dir: r === "r" || r === "u" || r === "d" ? r : "l", durationMs: s };
1153
- case "zoom":
1154
- return { kind: "zoom", zoomIn: r !== "out", durationMs: s };
1155
- case "morph":
1156
- return { kind: "morph", durationMs: s };
1157
- case "cut":
1158
- return;
1159
- default:
1160
- return { kind: "fade", durationMs: s };
1161
- }
1162
- }
1163
- function fn(t, n) {
1164
- const e = A(t, "timing", "tnLst");
1165
- if (!e) return [];
1166
- const o = [];
1167
- let s = 0;
1168
- const r = [], a = (i, l) => {
1169
- if (!(l > 40))
1170
- for (const p of V(i)) {
1171
- if (p.localName === "seq") {
1172
- const x = c(p, "cTn"), u = k(x, "nodeType");
1173
- if (u && u !== "mainSeq") {
1174
- s++;
1175
- continue;
1176
- }
1177
- }
1178
- if (p.localName === "cTn" && k(p, "presetClass")) {
1179
- r.push(p);
1180
- continue;
1181
- }
1182
- a(p, l + 1);
1183
- }
1184
- };
1185
- a(e, 0);
1186
- for (const i of r) {
1187
- const l = k(i, "presetClass");
1188
- if (l !== "entr" && l !== "exit" && l !== "emph") {
1189
- s++;
1190
- continue;
1191
- }
1192
- const p = C(i, "presetID"), x = C(i, "presetSubtype"), u = k(i, "nodeType"), g = u === "clickEffect" ? "click" : u === "afterEffect" ? "after" : "with", b = Number(k(A(i, "stCondLst", "cond"), "delay")), f = vt(c(i, "childTnLst"), "cBhvr", 4), h = f.map((I) => lt(I, "spTgt", 2)).find(Boolean), y = h ? C(h, "spid") : NaN;
1193
- if (!Number.isFinite(y) || lt(h, "txEl", 1)) {
1194
- s++;
1195
- continue;
1196
- }
1197
- const d = f.map((I) => Number(k(c(I, "cTn"), "dur"))).filter((I) => Number.isFinite(I) && I > 1), m = d.length ? Math.max(...d) : 500, { effect: w, known: M } = me(l, p);
1198
- M || n(`An animation PowerPoint calls preset ${p} (${l}) came in as a plain ${w}.`);
1199
- const S = vt(c(i, "childTnLst"), "animRot", 2)[0], v = k(i, "repeatCount");
1200
- o.push({
1201
- target: y,
1202
- cls: l,
1203
- effect: w,
1204
- presetId: p,
1205
- subtype: x,
1206
- start: g,
1207
- durationMs: m,
1208
- delayMs: Number.isFinite(b) ? Math.max(0, b) : 0,
1209
- ...Ft(x) && (w === "fly" || w === "wipe") && { dir: Ft(x) },
1210
- ...w === "spin" && S && { degrees: C(S, "by") / 6e4 },
1211
- ...v === "indefinite" ? { repeat: -1 } : v && Number(v) > 1e3 ? { repeat: Math.round(Number(v) / 1e3) } : {}
1212
- });
1213
- }
1214
- return s && n(`${s} animation(s) couldn't be imported (motion paths, triggered or by-paragraph effects).`), o;
1215
- }
1216
- function vt(t, n, e) {
1217
- if (!t || e < 0) return [];
1218
- const o = [];
1219
- for (const s of V(t))
1220
- s.localName === n ? o.push(s) : o.push(...vt(s, n, e - 1));
1221
- return o;
1222
- }
1223
- function Vt(t) {
1224
- const n = V(t).find((s) => s.localName === "transition"), e = n ? k(n, "advTm") : null, o = e !== null ? Number(e) : NaN;
1225
- return Number.isFinite(o) && o > 0 ? o : void 0;
1226
- }
1227
- function un(t, n) {
1228
- const e = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1229
- for (const r of N(c(t, "sldIdLst"), "sldId")) {
1230
- const a = n.get(k(r, "r:id") || ""), i = k(r, "id");
1231
- a && i && o.set(i, a.target);
1232
- }
1233
- const s = lt(c(t, "extLst"), "sectionLst", 4);
1234
- for (const r of N(s, "section")) {
1235
- const a = (k(r, "name") || "").trim(), i = N(c(r, "sldIdLst"), "sldId")[0], l = i ? o.get(k(i, "id") || "") : void 0;
1236
- a && l && !e.has(l) && e.set(l, a);
1237
- }
1238
- return e;
1239
- }
1240
- function dn(t, n = {}) {
1241
- const e = [], o = (T) => {
1242
- e.length < 200 && !e.includes(T) && e.push(T);
1243
- }, s = n.parseXml ?? ((T) => new DOMParser().parseFromString(T, "application/xml"));
1244
- let r, a = 0, i = 0;
1245
- try {
1246
- r = he(t, {
1247
- filter: (T) => (a++, i += T.originalSize, a <= Bt && T.originalSize <= Ne && i <= zt)
1248
- });
1249
- } catch {
1250
- throw new Error("This file is not a PowerPoint presentation (it is not a valid .pptx package).");
1251
- }
1252
- (a > Bt || i > zt) && o("The file is very large; some parts were skipped.");
1253
- const l = new Fe(r, s, o), p = l.relOfType("", "officeDocument") ?? "ppt/presentation.xml", x = l.xml(p);
1254
- if (!x || x.localName !== "presentation") throw new Error("This file is not a PowerPoint presentation (no presentation part).");
1255
- const u = c(x, "sldSz"), g = u ? Math.max(1, R(C(u, "cx", 9144e3))) : 960, b = u ? Math.max(1, R(C(u, "cy", 5143500))) : 540, f = c(x, "defaultTextStyle"), h = l.rels(p), y = l.relOfType(p, "tableStyles"), d = y ? l.xml(y) : null, m = [], w = /* @__PURE__ */ new Set();
1256
- for (const T of N(c(x, "sldIdLst"), "sldId")) {
1257
- const L = h.get(k(T, "r:id") || "");
1258
- L && !w.has(L.target) && m.length < Oe && (w.add(L.target), m.push(L.target));
1259
- }
1260
- const M = /* @__PURE__ */ new Map(), S = (T) => {
1261
- const L = l.relOfType(T, "theme");
1262
- return L ? (M.has(L) || M.set(L, xt(l.xml(L))), M.get(L)) : xt(null);
1263
- }, v = (T) => {
1264
- if (!T) return null;
1265
- const L = {};
1266
- for (let O = 0; O < T.attributes.length; O++) L[T.attributes[O].localName ?? T.attributes[O].name] = T.attributes[O].value;
1267
- return L;
1268
- }, I = un(x, h), P = [];
1269
- m.forEach((T, L) => {
1270
- const O = l.xml(T);
1271
- if (!O) {
1272
- o(`Slide ${L + 1} couldn't be read and was skipped.`);
1273
- return;
1274
- }
1275
- const Y = l.relOfType(T, "slideLayout"), D = Y ? l.xml(Y) : null, _ = Y ? l.relOfType(Y, "slideMaster") : null, Z = _ ? l.xml(_) : null, tt = _ ? S(_) : xt(null), K = v(A(O, "clrMapOvr", "overrideClrMapping")) ?? v(A(D, "clrMapOvr", "overrideClrMapping")) ?? v(c(Z, "clrMap")) ?? It, Lt = { theme: tt, clrMap: K }, mt = c(Z, "txStyles"), $ = {
1276
- pkg: l,
1277
- ctx: Lt,
1278
- slide: { part: T, tree: A(O, "cSld", "spTree") },
1279
- layout: Y ? { part: Y, tree: A(D, "cSld", "spTree") } : null,
1280
- master: _ ? { part: _, tree: A(Z, "cSld", "spTree") } : null,
1281
- masterTx: { title: c(mt, "titleStyle"), body: c(mt, "bodyStyle"), other: c(mt, "otherStyle") },
1282
- defaultText: f,
1283
- warnings: e,
1284
- count: 0,
1285
- tableStyles: d
1286
- }, gt = (de) => ({ pkg: l, part: de?.part ?? T, ctx: Lt }), Et = kt(c(O, "cSld"), gt($.slide)) ?? kt(c(D, "cSld"), gt($.layout)) ?? kt(c(Z, "cSld"), gt($.master)) ?? { kind: "solid", color: { hex: "#ffffff" } };
1287
- $.background = Et;
1288
- const ct = [], ue = B(O, "showMasterSp") !== !1 && B(D, "showMasterSp") !== !1;
1289
- $.master && ue && ct.push(...at($.master.tree, $.master, $, yt, 0, !1)), $.layout && B(O, "showMasterSp") !== !1 && ct.push(...at($.layout.tree, $.layout, $, yt, 0, !1)), ct.push(...at($.slide.tree, $.slide, $, yt, 0, !0)), P.push({
1290
- items: ct,
1291
- background: Et,
1292
- transition: cn(O),
1293
- name: k(c(O, "cSld"), "name") || void 0,
1294
- notes: ln(l, T),
1295
- key: T,
1296
- ...k(O, "show") === "0" && { hidden: !0 },
1297
- ...Vt(O) && { advanceAfterMs: Vt(O) },
1298
- ...I.has(T) && { section: I.get(T) }
1299
- });
1300
- const Rt = fn(O, o);
1301
- Rt.length && (P[P.length - 1].anims = Rt);
1302
- }), P.length || o("The presentation has no slides.");
1303
- const E = A(l.xml("docProps/core.xml"), "title")?.textContent || void 0, X = l.relOfType(p, "presProps"), H = k(c(X ? l.xml(X) : null, "showPr"), "loop");
1304
- return { deck: { width: g, height: b, slides: P, title: E, ...(H === "1" || H === "true") && { loop: !0 } }, warnings: e };
1305
- }
1306
- const hn = 80, pn = "default-layer", F = (t) => {
1307
- if (!t) return "transparent";
1308
- if (t.alpha === void 0 || t.alpha >= 0.999) return t.hex;
1309
- const n = t.hex.replace("#", "");
1310
- return `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${+t.alpha.toFixed(3)})`;
1311
- }, mn = /(times|georgia|garamond|cambria|book|serif|palatino|baskerville|merriweather)/i, gn = /(courier|consolas|mono|menlo|code)/i;
1312
- function qt(t) {
1313
- if (!t) return "sans-serif";
1314
- const n = we(t);
1315
- return n || (gn.test(t) ? "monospace" : mn.test(t) ? "serif" : "sans-serif");
1316
- }
1317
- function xn(t) {
1318
- const n = [];
1319
- let e = [], o = !1;
1320
- const s = () => {
1321
- if (e.length >= 2) {
1322
- const r = e[0], a = e[e.length - 1];
1323
- o && Math.hypot(r.x - a.x, r.y - a.y) < 1e-6 && (r.inX = a.inX, r.inY = a.inY, e.pop()), n.push({ anchors: e, closed: o });
1324
- }
1325
- e = [], o = !1;
1326
- };
1327
- for (const r of t)
1328
- if (r.op === "M")
1329
- s(), e.push({ x: r.x, y: r.y, kind: "corner" });
1330
- else if (r.op === "L")
1331
- e.length ? e.push({ x: r.x, y: r.y, kind: "corner" }) : e.push({ x: r.x, y: r.y, kind: "corner" });
1332
- else if (r.op === "C") {
1333
- const a = e[e.length - 1];
1334
- if (!a) {
1335
- e.push({ x: r.x, y: r.y, kind: "corner" });
1336
- continue;
1337
- }
1338
- a.outX = r.x1 - a.x, a.outY = r.y1 - a.y, e.push({ x: r.x, y: r.y, inX: r.x2 - r.x, inY: r.y2 - r.y, kind: "smooth" });
1339
- } else r.op === "Z" && (o = !0, s());
1340
- return s(), n;
1341
- }
1342
- const bn = (t, n, e) => t.map((o) => o.op === "Z" ? o : o.op === "C" ? { ...o, x1: o.x1 + n, y1: o.y1 + e, x2: o.x2 + n, y2: o.y2 + e, x: o.x + n, y: o.y + e } : { ...o, x: o.x + n, y: o.y + e });
1343
- function yn(t, n, e) {
1344
- let o = !1;
1345
- t.forEach((s, r) => {
1346
- s.start === "click" && (o = !0);
1347
- const a = n.itemEls?.get(s.target);
1348
- if (!a?.length) {
1349
- n.warnings.push("An animation on a shape that wasn't imported was skipped.");
1350
- return;
1351
- }
1352
- a.forEach((i, l) => {
1353
- const p = ge(l === 0 ? s : { ...s, start: "with", delayMs: s.delayMs }, e("anim"), !o);
1354
- p.order = r + l / (a.length + 1), (i.animations ??= []).push(p);
1355
- });
1356
- });
1357
- }
1358
- function kn(t, n) {
1359
- if (!t) return null;
1360
- if (t.kind === "url") return t.url;
1361
- if (t.kind === "action") return ye(t.action);
1362
- const e = n.slideIds?.get(t.key);
1363
- return e ? ke(e) : null;
1364
- }
1365
- async function wn(t) {
1366
- if (!(typeof document > "u"))
1367
- try {
1368
- const n = new Image();
1369
- n.src = t, await n.decode();
1370
- const e = document.createElement("canvas");
1371
- e.width = Math.max(1, Math.min(8192, n.naturalWidth)), e.height = Math.max(1, Math.min(8192, n.naturalHeight));
1372
- const o = e.getContext("2d");
1373
- return o ? (o.filter = "grayscale(1)", o.drawImage(n, 0, 0, e.width, e.height), e.toDataURL(/^data:image\/jpeg/.test(t) ? "image/jpeg" : "image/png", 0.92)) : void 0;
1374
- } catch {
1375
- return;
1376
- }
1377
- }
1378
- async function Mn(t, n) {
1379
- const e = /* @__PURE__ */ new Set(), o = (r) => {
1380
- for (const a of r)
1381
- if (a.kind === "group") o(a.children);
1382
- else if (a.kind === "picture" && a.grayscale) {
1383
- const i = n.get(a.media)?.url;
1384
- i && e.add(i);
1385
- } else if (a.kind === "shape" && a.fill.kind === "image" && a.fill.grayscale) {
1386
- const i = n.get(a.fill.media)?.url;
1387
- i && e.add(i);
1388
- }
1389
- };
1390
- t.slides.forEach((r) => o(r.items));
1391
- const s = /* @__PURE__ */ new Map();
1392
- return await Promise.all([...e].map(async (r) => {
1393
- const a = await wn(r);
1394
- a && s.set(r, a);
1395
- })), s;
1396
- }
1397
- async function vn(t, n, e, o) {
1398
- if (!(typeof document > "u"))
1399
- try {
1400
- const s = new Image();
1401
- s.src = t, await s.decode();
1402
- const r = document.createElement("canvas");
1403
- r.width = Math.max(1, Math.min(4096, Math.round(n))), r.height = Math.max(1, Math.min(4096, Math.round(e)));
1404
- const a = r.getContext("2d");
1405
- if (!a) return;
1406
- if (o) {
1407
- const i = a.createPattern(s, "repeat");
1408
- if (!i) return;
1409
- i.setTransform(new DOMMatrix().scale(o.sx, o.sy)), a.fillStyle = i, a.fillRect(0, 0, r.width, r.height);
1410
- } else {
1411
- if (Math.abs(s.naturalWidth / s.naturalHeight - n / e) < 0.01) return;
1412
- a.drawImage(s, 0, 0, r.width, r.height);
1413
- }
1414
- return r.toDataURL(o ? "image/png" : "image/jpeg", 0.92);
1415
- } catch {
1416
- return;
1417
- }
1418
- }
1419
- function J(t, n, e, o) {
1420
- return {
1421
- id: t.nextId(n),
1422
- type: n,
1423
- x: e.x + t.ox,
1424
- y: e.y + t.oy,
1425
- width: Math.max(e.w, 1),
1426
- height: Math.max(e.h, 1),
1427
- angle: e.rot ? e.rot * Math.PI / 180 : 0,
1428
- flipX: e.flipH || void 0,
1429
- flipY: e.flipV || void 0,
1430
- strokeColor: "transparent",
1431
- backgroundColor: "transparent",
1432
- fillStyle: "solid",
1433
- strokeWidth: 0,
1434
- strokeStyle: "solid",
1435
- roughness: 0,
1436
- renderStyle: "architectural",
1437
- opacity: 100,
1438
- seed: 1,
1439
- locked: !1,
1440
- layerId: pn,
1441
- groupIds: [...o].reverse(),
1442
- // innermost first, the store's convention
1443
- name: e.name
1444
- };
1445
- }
1446
- function Zt(t, n, e) {
1447
- switch (n.kind) {
1448
- case "none":
1449
- t.backgroundColor = "transparent";
1450
- break;
1451
- case "solid":
1452
- t.backgroundColor = F(n.color), t.fillStyle = "solid";
1453
- break;
1454
- case "linear":
1455
- case "radial":
1456
- t.fillStyle = n.kind, t.backgroundColor = F(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: F(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1457
- break;
1458
- case "pattern": {
1459
- t.backgroundColor = F(n.color), t.fillStyle = "pattern", t.patternFill = Rn(n.preset, F(n.color), n.bg ? F(n.bg) : "transparent");
1460
- break;
1461
- }
1462
- case "image": {
1463
- const o = e.images.get(n.media);
1464
- o && (t.fillStyle = "image", t.backgroundImage = n.grayscale && e.gray.get(o.url) || o.url, t.backgroundColor = "#ffffff"), o && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
1465
- break;
1466
- }
1467
- }
1468
- }
1469
- function St(t, n) {
1470
- if (!n || !(n.width > 0)) {
1471
- t.strokeColor = "transparent", t.strokeWidth = 0;
1472
- return;
1473
- }
1474
- t.strokeColor = F(n.color), t.strokeWidth = Math.max(0.5, n.width), t.strokeStyle = n.dash === "sysDot" ? "dotted" : n.dash ? "dashed" : "solid", (n.join === "miter" || n.join === "bevel") && (t.strokeLineJoin = n.join), n.cap === "flat" ? t.strokeLineCap = "butt" : n.cap === "sq" && (t.strokeLineCap = "square");
1475
- }
1476
- function Sn(t) {
1477
- const n = /^(alphaLc|alphaUc|arabic|romanLc|romanUc)(ParenBoth|ParenR|Period|Plain)$/.exec(t ?? "");
1478
- if (!n) return {};
1479
- const e = { alphaLc: "lower-alpha", alphaUc: "upper-alpha", romanLc: "lower-roman", romanUc: "upper-roman", arabic: void 0 }[n[1]], o = { ParenBoth: "parens", ParenR: "paren", Plain: "none", Period: void 0 }[n[2]], s = {};
1480
- return e && (s.listNumberStyle = e), o && (s.listNumberSuffix = o), s;
1481
- }
1482
- function Cn(t, n) {
1483
- const e = t.bullet === "num" ? Sn(t.numType) : t.bulletChar ? { listMarker: t.bulletChar } : {}, o = t.runs.find((s) => !s.br)?.color ?? n.defaults?.color;
1484
- return t.bulletColor && F(t.bulletColor) !== F(o) && (e.listMarkerColor = F(t.bulletColor)), t.bulletScale && (e.listMarkerScale = Math.round(t.bulletScale * 100) / 100), t.marL !== void 0 && (e.listIndent = Math.max(0, Math.round(t.marL * 10) / 10), e.listMarkerIndent = Math.max(0, Math.round((t.marL + (t.indent ?? 0)) * 10) / 10)), e;
1485
- }
1486
- const wt = (t, n) => Math.round(((t.paragraphs[n - 1]?.spaceAfter ?? 0) + (t.paragraphs[n]?.spaceBefore ?? 0)) * 100) / 100;
1487
- function ie(t, n) {
1488
- const e = t.paragraphs.flatMap((h) => h.runs.filter((y) => !y.br)), o = e[0], s = o?.size ?? 24, r = /* @__PURE__ */ new Map(), a = (h) => h.runs.reduce((y, d) => y + (d.br ? 0 : d.text.trim().length), 0);
1489
- for (const h of t.paragraphs) {
1490
- const y = a(h);
1491
- y && r.set(h.align ?? "l", (r.get(h.align ?? "l") ?? 0) + y);
1492
- }
1493
- const i = [...r].sort((h, y) => y[1] - h[1])[0]?.[0] ?? t.paragraphs.find((h) => h.runs.length)?.align ?? "l", l = (h) => a(h) > 0 && (h.align ?? "l") !== i ? h.align === "ctr" ? "center" : h.align === "r" ? "right" : "left" : void 0, p = e.every((h) => h.size === o?.size && h.bold === o?.bold && h.italic === o?.italic && h.underline === o?.underline && h.strike === o?.strike && h.font === o?.font && F(h.color) === F(o?.color)) && !t.paragraphs.some((h) => h.bullet) && !t.paragraphs.some((h, y) => y > 0 && wt(t, y) > 0) && !t.paragraphs.some(l), x = {
1494
- fontSize: Math.round(s * 10) / 10,
1495
- fontFamily: qt(o?.font),
1496
- textAlign: i === "ctr" ? "center" : i === "r" ? "right" : "left",
1497
- verticalAlign: t.anchor === "ctr" ? "middle" : t.anchor === "b" ? "bottom" : "top",
1498
- textColor: F(o?.color ?? { hex: "#000000" })
1499
- };
1500
- t.lineSpacing && Math.abs(t.lineSpacing - 1) > 0.01 && (x.lineHeight = Math.max(0.5, Math.min(4, t.lineSpacing * 1.2)));
1501
- const u = t.paragraphs.map((h) => h.runs.map((y) => y.br ? `
1502
- ` : y.text).join("")).join(`
1503
- `);
1504
- if (p)
1505
- return o?.bold && (x.fontWeight = 700), o?.italic && (x.fontStyle = "italic"), n ? x.containerText = u : x.text = u, { fields: x, rich: !1 };
1506
- const g = [], b = [], f = [];
1507
- return t.paragraphs.forEach((h, y) => {
1508
- const d = h.level ?? 0;
1509
- if (h.bullet === "num") {
1510
- const M = h.numType ?? "arabicPeriod";
1511
- (b[d] === void 0 || f[d] !== M) && (b[d] = (h.startAt ?? 1) - 1), b[d]++, f[d] = M, b.length = d + 1, f.length = d + 1;
1512
- } else
1513
- b.length = Math.min(b.length, d), f.length = b.length;
1514
- const m = h.bullet ? { listType: h.bullet === "num" ? "ordered" : "bullet", listLevel: d, ...Cn(h, t) } : {};
1515
- h.bullet === "num" && (m.listIndex = b[d]), (h.runs.length ? h.runs : [{ text: "" }]).forEach((M, S) => {
1516
- const v = { text: M.br ? `
1517
- ` : M.text, ...S === 0 ? m : {} };
1518
- S === 0 && y > 0 && wt(t, y) > 0 && (v.paragraphSpaceBefore = wt(t, y));
1519
- const I = l(h);
1520
- I && (v.paragraphAlign = I), M.bold && (v.bold = !0), M.italic && (v.italic = !0), M.underline && (v.underline = !0), M.strike && (v.strikethrough = !0), M.color && (v.color = F(M.color)), M.size && (v.fontSize = Math.round(M.size * 10) / 10), M.font && (v.fontFamily = qt(M.font)), g.push(v);
1521
- }), y < t.paragraphs.length - 1 && g.push({ text: `
1522
- ` });
1523
- }), n ? (x.richContainerText = g, x.containerText = u) : (x.richText = g, x.text = u), { fields: x, rich: !0 };
1524
- }
1525
- function Mt(t, n, e, o, s) {
1526
- const { fields: r, rich: a } = ie(n, !1), i = 4, l = J(t, a ? "richtext" : "text", {
1527
- ...e,
1528
- x: e.x + n.insets.l - i,
1529
- y: e.y + n.insets.t - i,
1530
- w: Math.max(e.w - n.insets.l - n.insets.r + i * 2, 8),
1531
- h: Math.max(e.h - n.insets.t - n.insets.b + i * 2, 8)
1532
- }, o);
1533
- return Object.assign(l, r, { autoResize: !n.wrap, strokeColor: r.textColor }), l;
1534
- }
1535
- const le = /* @__PURE__ */ new Set(["line", "straightConnector1"]);
1536
- function ce(t, n, e) {
1537
- const o = t.geom;
1538
- if (t.text && t.fill.kind === "none" && !t.line && (t.textBox || o.kind === "preset" && o.prst === "rect"))
1539
- return n.stats.elements++, [Mt(n, t.text, t, e)];
1540
- if (o.kind === "preset" && le.has(o.prst)) return Ct({ ...t, kind: "connector", line: t.line ?? { width: 1, color: { hex: "#000000" } } }, n, e);
1541
- if (o.kind === "custom" && t.line && (t.line.head || t.line.tail) && !t.text && o.paths.every((u) => !u.cmds.some((g) => g.op === "Z")))
1542
- return Ct({ ...t, kind: "connector", line: t.line }, n, e);
1543
- const s = Tn(t);
1544
- if (s) {
1545
- const u = J(n, s.type, t, e);
1546
- Object.assign(u, s.extra), Zt(u, t.fill, n), St(u, t.line), n.byPptId.set(t.id, { el: u, item: t }), n.stats.elements++;
1547
- const g = t.textRect ?? { l: 0, t: 0, r: t.w, b: t.h }, b = t.text?.insets, f = Math.abs(g.l) > 0.5 || Math.abs(g.t) > 0.5 || Math.abs(g.r - t.w) > 0.5 || Math.abs(g.b - t.h) > 0.5, h = !!b && Math.max(b.l, b.r, b.t, b.b) > 16;
1548
- if (t.text && (f || h)) {
1549
- const y = n.nextId("group");
1550
- return u.groupIds = [...e, y].reverse(), n.stats.elements++, [u, Mt(n, t.text, { ...t, rot: 0, x: t.x + g.l, y: t.y + g.t, w: g.r - g.l, h: g.b - g.t }, [...e, y])];
1551
- }
1552
- if (t.text) {
1553
- const { fields: y } = ie(t.text, !0);
1554
- Object.assign(u, y);
1555
- }
1556
- return [u];
1557
- }
1558
- const r = o.kind === "custom" ? o.paths : (() => {
1559
- const u = n.presets[o.prst];
1560
- if (!u)
1561
- return n.warnings.push(`Unknown shape "${o.prst}" was imported as a rectangle.`), ut(n.presets.rect, t.w, t.h);
1562
- const g = Object.fromEntries(Object.entries(o.adj ?? {}).map(([b, f]) => [b, `val ${f}`]));
1563
- return ut(u, t.w, t.h, g);
1564
- })(), a = [], i = (t.text || r.some((u) => u.fill === !1)) && r.some((u) => u.fill !== !1) ? n.nextId("group") : null, l = i ? [...e, i] : e, p = /* @__PURE__ */ new Map();
1565
- for (const u of r) {
1566
- const g = `${u.fill === !1 ? "nofill" : "fill"}|${u.stroke === !1 ? "nostroke" : "stroke"}`;
1567
- p.has(g) || p.set(g, []), p.get(g).push(u);
1568
- }
1569
- let x = null;
1570
- for (const [u, g] of p) {
1571
- const b = g.flatMap((m) => m.cmds), f = xe(b);
1572
- if (!f) continue;
1573
- const h = xn(bn(b, -f.minX, -f.minY));
1574
- if (!h.length) continue;
1575
- const y = J(n, "path", { ...t, x: t.x + f.minX, y: t.y + f.minY, w: Math.max(f.maxX - f.minX, 1), h: Math.max(f.maxY - f.minY, 1) }, l);
1576
- !(Math.abs(f.minX + f.maxX - t.w) < 0.5 && Math.abs(f.minY + f.maxY - t.h) < 0.5) && (t.rot || t.flipH || t.flipV) && Pn(y, h, t, f), y.pathSubpaths = h, y.pathAnchors = h[0].anchors, y.pathClosed = h[0].closed, u.startsWith("fill") ? Zt(y, t.fill, n) : y.backgroundColor = "transparent", u.endsWith("|stroke") ? St(y, t.line) : (y.strokeColor = "transparent", y.strokeWidth = 0), a.push(y), x ??= y, n.stats.paths++;
1577
- }
1578
- if (x && n.byPptId.set(t.id, { el: x, item: t }), t.text) {
1579
- const u = t.textRect ?? (o.kind === "preset" && n.presets[o.prst] ? te(n.presets[o.prst], t.w, t.h) : { l: 0, t: 0, r: t.w, b: t.h });
1580
- a.push(Mt(n, t.text, { ...t, x: t.x + u.l, y: t.y + u.t, w: u.r - u.l, h: u.b - u.t }, l));
1581
- }
1582
- return n.stats.elements += a.length, a;
1583
- }
1584
- function Pn(t, n, e, o) {
1585
- const s = e.w / 2, r = e.h / 2, a = (e.rot || 0) * Math.PI / 180, i = Math.cos(a), l = Math.sin(a), p = e.flipH ? -1 : 1, x = e.flipV ? -1 : 1, u = (d, m) => {
1586
- const w = (d + o.minX - s) * p, M = (m + o.minY - r) * x;
1587
- return { x: s + w * i - M * l, y: r + w * l + M * i };
1588
- }, g = (d, m) => {
1589
- const w = d * p, M = m * x;
1590
- return { x: w * i - M * l, y: w * l + M * i };
1591
- };
1592
- let b = 1 / 0, f = 1 / 0, h = -1 / 0, y = -1 / 0;
1593
- for (const d of n) for (const m of d.anchors) {
1594
- const w = u(m.x, m.y);
1595
- if (m.x = w.x, m.y = w.y, m.inX !== void 0) {
1596
- const M = g(m.inX, m.inY ?? 0);
1597
- m.inX = M.x, m.inY = M.y;
1598
- }
1599
- if (m.outX !== void 0) {
1600
- const M = g(m.outX, m.outY ?? 0);
1601
- m.outX = M.x, m.outY = M.y;
1602
- }
1603
- b = Math.min(b, m.x), f = Math.min(f, m.y), h = Math.max(h, m.x), y = Math.max(y, m.y);
1604
- }
1605
- for (const d of n) for (const m of d.anchors)
1606
- m.x -= b, m.y -= f;
1607
- t.x = t.x - o.minX + b, t.y = t.y - o.minY + f, t.width = Math.max(h - b, 1), t.height = Math.max(y - f, 1), t.angle = 0, t.flipX = void 0, t.flipY = void 0;
1608
- }
1609
- function Tn(t) {
1610
- const n = t.geom;
1611
- if (n.kind !== "preset") return null;
1612
- const e = n.adj ?? {};
1613
- switch (n.prst) {
1614
- case "rect":
1615
- return { type: "rectangle", extra: { borderRadius: 0 } };
1616
- case "roundRect":
1617
- return { type: "rectangle", extra: { borderRadius: Math.max(0, Math.min(50, (e.adj ?? 16667) / 1e3)) } };
1618
- case "ellipse":
1619
- return { type: "circle", extra: {} };
1620
- case "diamond":
1621
- return { type: "diamond", extra: { borderRadius: 0 } };
1622
- case "triangle":
1623
- return (e.adj ?? 5e4) === 5e4 ? { type: "triangle", extra: {} } : null;
1624
- default:
1625
- return null;
1626
- }
1627
- }
1628
- const Kt = { triangle: "triangle", stealth: "arrow", arrow: "arrow", oval: "dot", diamond: "diamondFilled" };
1629
- function Ct(t, n, e) {
1630
- const o = t.geom;
1631
- let s;
1632
- if (o.kind === "preset" && le.has(o.prst)) s = [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1633
- else if (o.kind === "custom") s = o.paths.flatMap((w) => w.cmds);
1634
- else {
1635
- const w = n.presets[o.prst], M = Object.fromEntries(Object.entries(o.adj ?? {}).map(([S, v]) => [S, `val ${v}`]));
1636
- s = w ? ut(w, t.w, t.h, M).flatMap((S) => S.cmds) : [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1637
- }
1638
- const r = t.w / 2, a = t.h / 2, i = (t.rot || 0) * Math.PI / 180, l = (w, M) => {
1639
- let S = w - r, v = M - a;
1640
- return t.flipH && (S = -S), t.flipV && (v = -v), { x: t.x + r + S * Math.cos(i) - v * Math.sin(i), y: t.y + a + S * Math.sin(i) + v * Math.cos(i) };
1641
- }, p = [];
1642
- let x = { x: 0, y: 0 };
1643
- for (const w of s)
1644
- if (w.op === "M" || w.op === "L")
1645
- x = { x: w.x, y: w.y }, p.push(l(x.x, x.y));
1646
- else if (w.op === "C") {
1647
- for (let M = 1; M <= 12; M++) {
1648
- const S = M / 12, v = 1 - S, I = v * v * v * x.x + 3 * v * v * S * w.x1 + 3 * v * S * S * w.x2 + S * S * S * w.x, P = v * v * v * x.y + 3 * v * v * S * w.y1 + 3 * v * S * S * w.y2 + S * S * S * w.y;
1649
- p.push(l(I, P));
1650
- }
1651
- x = { x: w.x, y: w.y };
1652
- }
1653
- if (p.length < 2) return [];
1654
- const u = Math.min(...p.map((w) => w.x)), g = Math.min(...p.map((w) => w.y)), b = Math.max(...p.map((w) => w.x)), f = Math.max(...p.map((w) => w.y)), h = t.line.head && Kt[t.line.head.type], y = t.line.tail && Kt[t.line.tail.type], d = J(n, h || y ? "arrow" : "line", { ...t, x: u, y: g, w: Math.max(b - u, 1), h: Math.max(f - g, 1), rot: 0, flipH: !1, flipV: !1 }, e);
1655
- d.points = p.map((w) => ({ x: w.x - u, y: w.y - g })), d.curveType = "straight", d.startArrowhead = h ?? null, d.endArrowhead = y ?? null, St(d, t.line);
1656
- const m = (w, M) => {
1657
- if (!w) return null;
1658
- const S = n.byPptId.get(w.id);
1659
- if (!S || !S.el.width || !S.el.height) return null;
1660
- const v = S.el;
1661
- return { elementId: v.id, focus: 0, gap: 0, anchorFractionX: (M.x + n.ox - v.x) / v.width, anchorFractionY: (M.y + n.oy - v.y) / v.height };
1662
- };
1663
- return n.glue.push(() => {
1664
- d.startBinding = m(t.start, p[0]), d.endBinding = m(t.end, p[p.length - 1]);
1665
- }), n.stats.elements++, [d];
1666
- }
1667
- function In(t, n, e) {
1668
- const o = n.images.get(t.media);
1669
- if (!o) {
1670
- n.warnings.push(`Picture "${t.name}" is a ${t.media.ext.toUpperCase()} image, which browsers can't show; it was imported as a placeholder.`);
1671
- const l = J(n, "rectangle", t, e);
1672
- return Object.assign(l, { backgroundColor: "#f1f3f5", strokeColor: "#adb5bd", strokeWidth: 1, strokeStyle: "dashed", containerText: `${t.media.ext.toUpperCase()} picture`, fontSize: 14, textColor: "#495057" }), n.stats.elements++, [l];
1673
- }
1674
- const s = J(n, "image", t, e);
1675
- if (s.dataURL = t.grayscale && n.gray.get(o.url) || o.url, s.status = "loaded", s.mimeType = Pt[t.media.ext], t.crop && (t.crop.l || t.crop.t || t.crop.r || t.crop.b) && (s.crop = { x: t.crop.l * o.w, y: t.crop.t * o.h, width: Math.max(1, (1 - t.crop.l - t.crop.r) * o.w), height: Math.max(1, (1 - t.crop.t - t.crop.b) * o.h) }), t.alpha !== void 0 && t.alpha < 1 && (s.opacity = Math.round(t.alpha * 100)), t.descr && (s.altText = t.descr), n.stats.elements++, n.stats.pictures++, !t.geom) return [s];
1676
- const r = n.nextId("group"), a = ce({
1677
- kind: "shape",
1678
- id: t.id,
1679
- name: `${t.name} outline`,
1680
- x: t.x,
1681
- y: t.y,
1682
- w: t.w,
1683
- h: t.h,
1684
- rot: t.rot,
1685
- flipH: t.flipH,
1686
- flipV: t.flipV,
1687
- geom: t.geom,
1688
- fill: { kind: "solid", color: { hex: "#000000" } },
1689
- line: null
1690
- }, n, [...e, r]);
1691
- if (a.length !== 1)
1692
- return n.stats.elements -= a.length, [s];
1693
- const i = a[0];
1694
- return i.isClipMask = !0, s.groupIds = [r, ...s.groupIds], s.clipMaskId = i.id, s.maskType = "clip", [s, i];
1695
- }
1696
- function fe(t, n, e) {
1697
- const o = [];
1698
- for (const s of t)
1699
- try {
1700
- const r = [];
1701
- switch (s.kind) {
1702
- case "shape":
1703
- r.push(...ce(s, n, e));
1704
- break;
1705
- case "connector":
1706
- r.push(...Ct(s, n, e));
1707
- break;
1708
- case "picture":
1709
- r.push(...In(s, n, e));
1710
- break;
1711
- case "group":
1712
- r.push(...fe(s.children, n, [...e, n.nextId("group")]));
1713
- break;
1714
- }
1715
- const a = kn(s.link, n);
1716
- if (a)
1717
- for (const i of r) i.link || (i.link = a);
1718
- n.itemEls?.set(s.id, r), o.push(...r);
1719
- } catch {
1720
- n.warnings.push(`"${s.name}" couldn't be converted and was skipped.`);
1721
- }
1722
- return o;
1723
- }
1724
- function Nn(t) {
1725
- return t ? { type: t.kind === "morph" ? "morph" : t.kind === "fade" ? "fade" : t.kind === "zoom" ? t.zoomIn === !1 ? "zoom-out" : "zoom-in" : t.dir === "r" ? "slide-right" : t.dir === "u" ? "slide-up" : t.dir === "d" ? "slide-down" : "slide-left", duration: Math.max(100, Math.min(5e3, t.durationMs)), easing: "easeInOutQuad" } : void 0;
1726
- }
1727
- function On(t, n, e) {
1728
- if (n)
1729
- if (n.kind === "solid")
1730
- t.fillStyle = "solid", t.backgroundColor = F(n.color);
1731
- else if (n.kind === "linear" || n.kind === "radial")
1732
- t.fillStyle = n.kind, t.backgroundColor = F(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: F(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1733
- else if (n.kind === "image") {
1734
- const o = e.images.get(n.media), s = e.slideBg ?? o?.url;
1735
- s && (t.fillStyle = "image", t.backgroundImage = s, t.backgroundColor = "#ffffff"), s && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
1736
- } else n.kind === "pattern" && (t.fillStyle = "solid", t.backgroundColor = F(n.color));
1737
- }
1738
- const Pt = {
1739
- png: "image/png",
1740
- jpeg: "image/jpeg",
1741
- gif: "image/gif",
1742
- svg: "image/svg+xml",
1743
- bmp: "image/bmp",
1744
- tiff: "image/tiff",
1745
- webp: "image/webp",
1746
- emf: "image/x-emf",
1747
- wmf: "image/x-wmf"
1748
- }, An = /* @__PURE__ */ new Set(["png", "jpeg", "gif", "svg", "bmp", "webp"]);
1749
- function Ln(t) {
1750
- let n = "";
1751
- for (let o = 0; o < t.length; o += 32768) n += String.fromCharCode(...t.subarray(o, o + 32768));
1752
- return btoa(n);
1753
- }
1754
- async function En(t) {
1755
- const n = /* @__PURE__ */ new Set(), e = (s) => {
1756
- for (const r of s)
1757
- r.kind === "picture" ? n.add(r.media) : r.kind === "group" ? e(r.children) : r.kind === "shape" && r.fill.kind === "image" && n.add(r.fill.media);
1758
- };
1759
- for (const s of t.slides)
1760
- e(s.items), s.background?.kind === "image" && n.add(s.background.media);
1761
- const o = /* @__PURE__ */ new Map();
1762
- return await Promise.all([...n].map(async (s) => {
1763
- if (!An.has(s.ext)) {
1764
- o.set(s, null);
1765
- return;
1766
- }
1767
- const r = `data:${Pt[s.ext]};base64,${Ln(s.bytes)}`;
1768
- let a = 0, i = 0;
1769
- try {
1770
- const l = await createImageBitmap(new Blob([s.bytes], { type: Pt[s.ext] }));
1771
- a = l.width, i = l.height, l.close();
1772
- } catch {
1773
- }
1774
- o.set(s, { url: r, w: a, h: i });
1775
- })), o;
1776
- }
1777
- function Rn(t, n, e) {
1778
- const o = /^(nar|sm)/.test(t) ? 4 : /^(wd|lg)/.test(t) ? 12 : 8, s = /^dk/.test(t) ? 3 : /^lt/.test(t) ? 1 : /^(wd)/.test(t) ? 3 : 1.5, r = { color: n, background: e, spacing: o, strokeWidth: s }, a = /^pct(\d+)$/.exec(t);
1779
- if (a) {
1780
- const i = Math.max(1, Math.min(99, Number(a[1]))), l = i > 50, p = (l ? 100 - i : i) / 100;
1781
- return { type: "dots", color: l ? e : n, background: l ? n : e, spacing: 4, strokeWidth: Math.max(0.5, 4 * Math.sqrt(p / Math.PI)) };
1782
- }
1783
- return /Horz$|^horz|Brick$|^shingle$|^wave$|^zigZag$/.test(t) ? { type: "stripes", ...r, angle: 0 } : /Vert$|^vert$/.test(t) ? { type: "stripes", ...r, angle: 90 } : /DnDiag$|^dnDiag$/.test(t) ? { type: "stripes", ...r, angle: 45 } : /UpDiag$|^upDiag$/.test(t) ? { type: "stripes", ...r, angle: -45 } : /^(diagCross|trellis|openDmnd|weave)$/.test(t) ? { type: "crosshatch", ...r } : /Check$|^solidDmnd$/.test(t) ? { type: "checker", ...r, angle: t === "solidDmnd" ? 45 : 0 } : /^(cross|smGrid|lgGrid|dotGrid|plaid)$/.test(t) ? { type: "grid", ...r } : { type: "dots", ...r, strokeWidth: 1 };
1784
- }
1785
- async function Fn(t, n, e) {
1786
- const o = await Ie(), s = await En(t), r = Math.round(t.width), a = Math.round(t.height), i = be(e ?? t.title, "slides", { width: r, height: a }), l = [], p = { slides: 0, elements: 0, pictures: 0, paths: 0 };
1787
- i.slides = [];
1788
- const x = await Mn(t, s), u = await Promise.all(t.slides.map((f) => {
1789
- const h = f.background, y = h?.kind === "image" ? s.get(h.media) : void 0;
1790
- return h?.kind === "image" && y ? vn(y.url, r, a, h.tile) : void 0;
1791
- })), g = t.slides.map(() => n("slide")), b = /* @__PURE__ */ new Map();
1792
- return t.slides.forEach((f, h) => {
1793
- f.key && b.set(f.key, g[h]);
1794
- }), t.slides.forEach((f, h) => {
1795
- const y = h * (r + hn), d = Dt(g[h], f.name || `Slide ${h + 1}`, y, 0, { width: r, height: a });
1796
- d.order = h;
1797
- const m = { ox: y, oy: 0, presets: o, nextId: n, out: [], byPptId: /* @__PURE__ */ new Map(), glue: [], warnings: l, stats: p, images: s, slideBg: u[h], gray: x, slideIds: b, itemEls: /* @__PURE__ */ new Map() };
1798
- i.elements.push(...fe(f.items, m, [])), yn(f.anims ?? [], m, n), m.glue.forEach((M) => M()), On(d, f.background, m);
1799
- const w = Nn(f.transition);
1800
- w && (d.transition = w), f.notes && (d.notes = f.notes), f.hidden && (d.hidden = !0), f.advanceAfterMs && (d.advanceAfter = f.advanceAfterMs), f.section && (d.section = f.section), i.slides.push(d), p.slides++;
1801
- }), i.slides.length || i.slides.push(Dt(void 0, "Slide 1", 0, 0, { width: r, height: a })), t.loop && (i.globalSettings = { ...i.globalSettings || {}, slideShowLoop: !0 }), { doc: i, warnings: [...new Set(l)], stats: p };
1802
- }
1803
- const Dn = 512 * 1024 * 1024;
1804
- async function Xn(t, n) {
1805
- const e = t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(await t.arrayBuffer());
1806
- if (e.length > Dn) throw new Error("This presentation is too large to open (over 512 MB).");
1807
- const { deck: o, warnings: s } = dn(e), r = /* @__PURE__ */ new Set(), a = await Fn(o, (l) => ve(l, r), n);
1808
- Me(a.doc);
1809
- const i = [...s, ...a.warnings];
1810
- return i.length && console.warn("[pptx import]", i), { stats: a.stats, warnings: i };
1811
- }
1812
- export {
1813
- Xn as importPptx
1814
- };