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