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