@algorisys/yappydraw 0.8.294 → 0.8.296
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-DqccAnxC.js → canva-ai-CkUlVY-Y.js} +1 -1
- package/chunks/{choice-dialog-state-10-yA9qy.js → choice-dialog-state-BUFvjtpq.js} +1 -1
- package/chunks/{custgeom-gp_HWEYw.js → custgeom-DThQ1Qnp.js} +1 -1
- package/chunks/{design-generator-DIyJ4Dr0.js → design-generator-BlrBbMDM.js} +1 -1
- package/chunks/{drawing-engine-nqE0zI8L.js → drawing-engine-KJLwmUE-.js} +1 -1
- package/chunks/{drawings-store-BFtMld-q.js → drawings-store-CiDEeh5h.js} +1 -1
- package/chunks/{ds-operations-40JYI4lM.js → ds-operations-C27tW9qb.js} +1 -1
- package/chunks/{export-game-5Kek7Bol.js → export-game-Bcz0A67O.js} +1 -1
- package/chunks/{from-yappy-ChRzxzZ9.js → from-yappy-lL1q0m9y.js} +31 -20
- package/chunks/{game-runtime--zmzKmmo.js → game-runtime-RZ6Ygr7N.js} +5 -5
- package/chunks/import-DFZ1uZOp.js +1736 -0
- package/chunks/{index-v2rH-W8-.js → index-NbpsufU1.js} +24121 -23837
- 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-BHWkJbay.js → lucide-solid-DL_MnmQm.js} +1 -1
- package/chunks/{markdown-to-slides-siI6fZd3.js → markdown-to-slides-D9CoIzTi.js} +1 -1
- package/chunks/{morph-animator-klLNQx0a.js → morph-animator-C_rDbafN.js} +1 -1
- package/chunks/{onboarding-tour-CV0e3oyB.js → onboarding-tour-B1fDeTqe.js} +1 -1
- package/chunks/{pdf-vector-DLxGyE10.js → pdf-vector-ByOSpRwK.js} +2 -2
- package/chunks/purify.es-B0KlbA1O.js +1520 -0
- package/chunks/{search-53sGgwDp.js → search-MWY5OrgG.js} +2 -2
- package/chunks/{slide-generator-BttJgv2N.js → slide-generator-8-amet_R.js} +1 -1
- package/chunks/{svg2pdf.es.min-B6z21zR3.js → svg2pdf.es.min-4O9RYeoT.js} +1 -1
- package/chunks/{turntable-ai-7udakZBz.js → turntable-ai-DgSAtAc8.js} +1 -1
- package/chunks/{write-CIGfHqn4.js → write-B1-j7TNq.js} +130 -119
- package/package.json +1 -1
- package/yappy.js +1 -1
- package/chunks/import-DGbhv-Je.js +0 -1699
- package/chunks/purify.es-C2Qa7b4C.js +0 -906
|
@@ -1,1699 +0,0 @@
|
|
|
1
|
-
import { u as ae, a as ie } from "./browser-DbZP-BrN.js";
|
|
2
|
-
import { E as H, i as vt, g as le } from "./custgeom-gp_HWEYw.js";
|
|
3
|
-
import { aq as ce, ar as Nt, as as fe, at as ue, M as de, q as he, K as pe } from "./index-v2rH-W8-.js";
|
|
4
|
-
const me = 1e4, ge = 1e5, Wt = 6e4, Q = (t) => t / Wt * (Math.PI / 180);
|
|
5
|
-
function _t(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), c = 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: c,
|
|
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 u = /^(wd|hd|ssd)(\d+)$/.exec(m);
|
|
32
|
-
if (u) {
|
|
33
|
-
const y = u[1] === "wd" ? r : u[1] === "hd" ? a : i, d = Number(u[2]);
|
|
34
|
-
return d ? y / d : 0;
|
|
35
|
-
}
|
|
36
|
-
const h = Number(m);
|
|
37
|
-
return Number.isFinite(h) ? h : 0;
|
|
38
|
-
}, f = (m, g) => {
|
|
39
|
-
s.size > me || s.set(m, xe(g, b));
|
|
40
|
-
};
|
|
41
|
-
for (const [m, g] of t.av ?? []) f(m, o[m] ?? g);
|
|
42
|
-
for (const [m, g] of Object.entries(o)) s.has(m) || f(m, g);
|
|
43
|
-
for (const [m, g] of t.gd ?? []) f(m, g);
|
|
44
|
-
return s;
|
|
45
|
-
}
|
|
46
|
-
function xe(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 * Wt;
|
|
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(Q(r));
|
|
79
|
-
break;
|
|
80
|
-
case "sin":
|
|
81
|
-
i = s * Math.sin(Q(r));
|
|
82
|
-
break;
|
|
83
|
-
case "tan":
|
|
84
|
-
i = s * Math.tan(Q(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 Ot = (t, n, e) => Math.atan2(n * Math.sin(t), e * Math.cos(t));
|
|
107
|
-
function lt(t, n, e, o = {}) {
|
|
108
|
-
const s = Math.max(Math.abs(n), 0) * H, r = Math.max(Math.abs(e), 0) * H, a = _t(t, s, r, o), i = (b) => typeof b == "number" ? b : a.get(b) ?? (Number.isFinite(Number(b)) ? Number(b) : 0), c = [];
|
|
109
|
-
let x = ge;
|
|
110
|
-
for (const b of t.paths) {
|
|
111
|
-
const f = b.w ? s / b.w : 1, m = b.h ? r / b.h : 1, g = (p) => i(p) * f / H, u = (p) => i(p) * m / H, h = [];
|
|
112
|
-
let y = { x: 0, y: 0 }, d = { 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: u(p[2]) }, d = y, h.push({ op: "M", ...y });
|
|
118
|
-
break;
|
|
119
|
-
case "L":
|
|
120
|
-
y = { x: g(p[1]), y: u(p[2]) }, h.push({ op: "L", ...y });
|
|
121
|
-
break;
|
|
122
|
-
case "C": {
|
|
123
|
-
const k = g(p[1]), M = u(p[2]), S = g(p[3]), v = u(p[4]);
|
|
124
|
-
y = { x: g(p[5]), y: u(p[6]) }, h.push({ op: "C", x1: k, y1: M, x2: S, y2: v, ...y });
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case "Q": {
|
|
128
|
-
const k = g(p[1]), M = u(p[2]), S = g(p[3]), v = u(p[4]);
|
|
129
|
-
h.push({ op: "C", x1: y.x + 2 / 3 * (k - y.x), y1: y.y + 2 / 3 * (M - y.y), x2: S + 2 / 3 * (k - S), y2: v + 2 / 3 * (M - v), x: S, y: v }), y = { x: S, y: v };
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case "A": {
|
|
133
|
-
const k = i(p[1]) * f / H, M = i(p[2]) * m / H;
|
|
134
|
-
y = be(h, y, k, M, i(p[3]), i(p[4]));
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
case "Z":
|
|
138
|
-
h.push({ op: "Z" }), y = d;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
h.length && c.push({ cmds: h, fill: b.fill === "none" ? !1 : void 0, stroke: b.stroke === !1 ? !1 : void 0 });
|
|
143
|
-
}
|
|
144
|
-
return c;
|
|
145
|
-
}
|
|
146
|
-
function be(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 = Q(s), i = Math.max(-4 * Math.PI, Math.min(4 * Math.PI, Q(r))), c = Ot(a, e, o);
|
|
149
|
-
let x = Ot(a + i, e, o);
|
|
150
|
-
if (Math.abs(i) >= 2 * Math.PI - 1e-9) x = c + Math.sign(i) * 2 * Math.PI;
|
|
151
|
-
else {
|
|
152
|
-
for (; i > 0 && x < c; ) x += 2 * Math.PI;
|
|
153
|
-
for (; i < 0 && x > c; ) x -= 2 * Math.PI;
|
|
154
|
-
}
|
|
155
|
-
const b = n.x - e * Math.cos(c), f = n.y - o * Math.sin(c), m = x - c, g = Math.max(1, Math.min(16, Math.ceil(Math.abs(m) / (Math.PI / 2)))), u = m / g, h = 4 / 3 * Math.tan(u / 4);
|
|
156
|
-
let y = c, d = n;
|
|
157
|
-
for (let p = 0; p < g; p++) {
|
|
158
|
-
const k = y + u, M = Math.cos(y), S = Math.sin(y), v = Math.cos(k), N = Math.sin(k);
|
|
159
|
-
d = { x: b + e * v, y: f + o * N }, t.push({ op: "C", x1: b + e * (M - h * S), y1: f + o * (S + h * M), x2: b + e * (v + h * N), y2: f + o * (N - h * v), ...d }), y = k;
|
|
160
|
-
}
|
|
161
|
-
return d;
|
|
162
|
-
}
|
|
163
|
-
function Ut(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 = _t(t, s * H, r * H, o), i = (m) => (a.get(m) ?? (Number.isFinite(Number(m)) ? Number(m) : 0)) / H, [c, x, b, f] = t.rect.map(i);
|
|
167
|
-
return { l: c, t: x, r: b, b: f };
|
|
168
|
-
}
|
|
169
|
-
let Rt = null;
|
|
170
|
-
async function ye() {
|
|
171
|
-
return Rt ??= (await import("./presets-DP49P8i2.js")).default, Rt;
|
|
172
|
-
}
|
|
173
|
-
const At = 5e4, ke = 256 * 1024 * 1024, Et = 1024 * 1024 * 1024, we = 1e4, Me = 32, ve = 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
|
-
}, l = (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 = l(e, o);
|
|
186
|
-
return e ?? null;
|
|
187
|
-
}, w = (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 = w(t, n), s = o === null ? NaN : Number(o);
|
|
199
|
-
return Number.isFinite(s) ? s : e;
|
|
200
|
-
}, B = (t, n) => {
|
|
201
|
-
const e = w(t, n);
|
|
202
|
-
return e === null ? void 0 : e === "1" || e === "true" || e === "on";
|
|
203
|
-
}, L = (t) => t / H, Se = /* @__PURE__ */ new Set(["p14", "a14", "a16"]);
|
|
204
|
-
function Ce(t) {
|
|
205
|
-
if (t.localName !== "AlternateContent") return [t];
|
|
206
|
-
const n = l(t, "Fallback");
|
|
207
|
-
for (const e of I(t, "Choice"))
|
|
208
|
-
if ((w(e, "Requires") || "").split(/\s+/).filter(Boolean).every((s) => Se.has(s))) return I(e);
|
|
209
|
-
return I(n);
|
|
210
|
-
}
|
|
211
|
-
const st = (t) => I(t).flatMap(Ce);
|
|
212
|
-
class Pe {
|
|
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[K(s)] = r;
|
|
221
|
-
}
|
|
222
|
-
bytes(n) {
|
|
223
|
-
return this.files[K(n)];
|
|
224
|
-
}
|
|
225
|
-
xml(n) {
|
|
226
|
-
const e = K(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 = ie(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 = K(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 c = w(i, "Id"), x = w(i, "Type") || "", b = w(i, "Target") || "";
|
|
251
|
-
if (!c) continue;
|
|
252
|
-
const f = w(i, "TargetMode") === "External";
|
|
253
|
-
o.set(c, { type: x.slice(x.lastIndexOf("/") + 1), target: f ? b : Te(s, b), external: f });
|
|
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 K = (t) => t.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
263
|
-
function Te(t, n) {
|
|
264
|
-
let e = n.split("#")[0];
|
|
265
|
-
try {
|
|
266
|
-
e = decodeURIComponent(e);
|
|
267
|
-
} catch {
|
|
268
|
-
}
|
|
269
|
-
if (e.startsWith("/")) return K(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 St = { bg1: "lt1", tx1: "dk1", bg2: "lt2", tx2: "dk2" };
|
|
276
|
-
function pt(t) {
|
|
277
|
-
const n = { colors: {}, major: "Calibri Light", minor: "Calibri", fills: [], lines: [], bgFills: [] }, e = l(t, "themeElements");
|
|
278
|
-
for (const r of I(l(e, "clrScheme"))) {
|
|
279
|
-
const a = I(r)[0];
|
|
280
|
-
if (!a) continue;
|
|
281
|
-
const i = a.localName === "sysClr" ? w(a, "lastClr") : w(a, "val");
|
|
282
|
-
i && /^[0-9a-f]{6}$/i.test(i) && (n.colors[r.localName] = "#" + i.toLowerCase());
|
|
283
|
-
}
|
|
284
|
-
const o = l(e, "fontScheme");
|
|
285
|
-
n.major = w(R(o, "majorFont", "latin"), "typeface") || n.major, n.minor = w(R(o, "minorFont", "latin"), "typeface") || n.minor;
|
|
286
|
-
const s = l(e, "fmtScheme");
|
|
287
|
-
return n.fills = I(l(s, "fillStyleLst")), n.lines = I(l(s, "lnStyleLst")), n.bgFills = I(l(s, "bgFillStyleLst")), n;
|
|
288
|
-
}
|
|
289
|
-
const Ie = {
|
|
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
|
-
}, Gt = (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
|
-
}, it = (t, n, e) => "#" + [t, n, e].map((o) => Math.max(0, Math.min(255, Math.round(o))).toString(16).padStart(2, "0")).join(""), J = (t) => (t /= 255, t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4)), _ = (t) => 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * Math.pow(t, 1 / 2.4) - 0.055);
|
|
318
|
-
function Lt(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 mt(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 $(t, n) {
|
|
331
|
-
const e = I(t).find((o) => /Clr$/.test(o.localName));
|
|
332
|
-
return e ? Ne(e, n) : null;
|
|
333
|
-
}
|
|
334
|
-
function Ne(t, n) {
|
|
335
|
-
let e = null, o = 1;
|
|
336
|
-
switch (t.localName) {
|
|
337
|
-
case "srgbClr": {
|
|
338
|
-
const c = w(t, "val");
|
|
339
|
-
e = c && /^[0-9a-f]{6}$/i.test(c) ? "#" + c.toLowerCase() : null;
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
case "sysClr": {
|
|
343
|
-
const c = w(t, "lastClr");
|
|
344
|
-
e = c ? "#" + c.toLowerCase() : w(t, "val") === "window" ? "#ffffff" : "#000000";
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
case "prstClr":
|
|
348
|
-
e = Ie[w(t, "val") || ""] ?? "#000000";
|
|
349
|
-
break;
|
|
350
|
-
case "scrgbClr":
|
|
351
|
-
e = it(_(C(t, "r") / 1e5), _(C(t, "g") / 1e5), _(C(t, "b") / 1e5));
|
|
352
|
-
break;
|
|
353
|
-
case "hslClr": {
|
|
354
|
-
const [c, x, b] = mt(C(t, "hue") / 6e4, C(t, "sat") / 1e5, C(t, "lum") / 1e5);
|
|
355
|
-
e = it(c, x, b);
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
case "schemeClr": {
|
|
359
|
-
const c = w(t, "val") || "";
|
|
360
|
-
if (c === "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[c] ?? St[c] ?? c;
|
|
365
|
-
e = n.theme.colors[x] ?? null;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (!e) return null;
|
|
370
|
-
let [s, r, a] = Gt(e);
|
|
371
|
-
for (const c of I(t)) {
|
|
372
|
-
const x = C(c, "val") / 1e5;
|
|
373
|
-
switch (c.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, f, m] = Lt(s, r, a);
|
|
390
|
-
c.localName === "lumMod" ? m *= x : c.localName === "lumOff" ? m += x : c.localName === "satMod" ? f *= x : c.localName === "satOff" ? f += x : c.localName === "hueMod" ? b *= x : b += C(c, "val") / 6e4, [s, r, a] = mt(b, Math.max(0, Math.min(1, f)), Math.max(0, Math.min(1, m)));
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
case "tint":
|
|
394
|
-
[s, r, a] = [s, r, a].map((b) => _(J(b) * x + (1 - x)));
|
|
395
|
-
break;
|
|
396
|
-
case "shade":
|
|
397
|
-
[s, r, a] = [s, r, a].map((b) => _(J(b) * x));
|
|
398
|
-
break;
|
|
399
|
-
case "comp": {
|
|
400
|
-
const [b, f, m] = Lt(s, r, a);
|
|
401
|
-
[s, r, a] = mt(b + 180, f, 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: it(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 = Ct(e, n);
|
|
420
|
-
if (o) return o;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function Ct(t, n) {
|
|
424
|
-
switch (t.localName) {
|
|
425
|
-
case "noFill":
|
|
426
|
-
return { kind: "none" };
|
|
427
|
-
case "solidFill": {
|
|
428
|
-
const e = $(t, n.ctx);
|
|
429
|
-
return e ? { kind: "solid", color: e } : { kind: "none" };
|
|
430
|
-
}
|
|
431
|
-
case "gradFill": {
|
|
432
|
-
const e = I(l(t, "gsLst"), "gs").slice(0, 256).map((s) => ({ pos: C(s, "pos") / 1e5, color: $(s, n.ctx) ?? { hex: "#000000" } }));
|
|
433
|
-
if (!e.length) return { kind: "none" };
|
|
434
|
-
const o = l(t, "lin");
|
|
435
|
-
return l(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 = Vt(t, n);
|
|
439
|
-
if (!e) return;
|
|
440
|
-
const o = { kind: "image", media: e }, s = l(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 = l(l(t, "blip"), "alphaModFix");
|
|
443
|
-
return r && (o.alpha = Math.max(0, Math.min(1, C(r, "amt", 1e5) / 1e5))), l(l(t, "blip"), "grayscl") && (o.grayscale = !0), o;
|
|
444
|
-
}
|
|
445
|
-
case "pattFill": {
|
|
446
|
-
const e = $(l(t, "fgClr"), n.ctx), o = $(l(t, "bgClr"), n.ctx);
|
|
447
|
-
return e ? { kind: "pattern", preset: w(t, "prst") || "pct50", color: e, ...o ? { bg: o } : {} } : void 0;
|
|
448
|
-
}
|
|
449
|
-
case "grpFill":
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
const Oe = {
|
|
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 Vt(t, n) {
|
|
468
|
-
const e = l(t, "blip"), o = w(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 = Oe[(s.target.split(".").pop() || "").toLowerCase()];
|
|
473
|
-
return r && a ? { bytes: r, ext: a } : null;
|
|
474
|
-
}
|
|
475
|
-
const Re = { solid: "", dot: "sysDot", sysDot: "sysDot", sysDash: "dash", dash: "dash", lgDash: "dash", dashDot: "dash", lgDashDot: "dash", lgDashDotDot: "dash", sysDashDot: "dash", sysDashDotDot: "dash" };
|
|
476
|
-
function U(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 = $(i, n.ctx)), i.localName === "gradFill" && (e = $(l(l(i, "gsLst"), "gs"), n.ctx));
|
|
482
|
-
}
|
|
483
|
-
const o = w(t, "w");
|
|
484
|
-
if (e === void 0 && o === null && !l(t, "prstDash") && !l(t, "headEnd") && !l(t, "tailEnd")) return;
|
|
485
|
-
const s = (i) => {
|
|
486
|
-
const c = w(i, "type");
|
|
487
|
-
if (!c || c === "none") return;
|
|
488
|
-
const x = c === "triangle" || c === "stealth" || c === "arrow" || c === "oval" || c === "diamond" ? c : "triangle", b = w(i, "len") || w(i, "w");
|
|
489
|
-
return { type: x, size: b === "sm" || b === "lg" ? b : "med" };
|
|
490
|
-
}, r = Re[w(l(t, "prstDash"), "val") || "solid"], a = w(t, "cap");
|
|
491
|
-
return {
|
|
492
|
-
// ECMA's default is 9525 EMU — 0.75 pt, one px.
|
|
493
|
-
width: o !== null ? Math.max(0, L(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: l(t, "round") ? "round" : l(t, "bevel") ? "bevel" : l(t, "miter") ? "miter" : void 0,
|
|
498
|
-
head: s(l(t, "headEnd")),
|
|
499
|
-
tail: s(l(t, "tailEnd"))
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function ct(t, n) {
|
|
503
|
-
const e = l(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 = $(e, n.ctx) ?? void 0;
|
|
510
|
-
return Ct(r, { ...n, ctx: { ...n.ctx, phClr: a } });
|
|
511
|
-
}
|
|
512
|
-
function Pt(t, n) {
|
|
513
|
-
const e = l(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 = $(e, n.ctx) ?? void 0;
|
|
520
|
-
return U(s, { ...n, ctx: { ...n.ctx, phClr: r } }) ?? void 0;
|
|
521
|
-
}
|
|
522
|
-
function Y(t) {
|
|
523
|
-
if (!t) return null;
|
|
524
|
-
const n = l(t, "off"), e = l(t, "ext");
|
|
525
|
-
return !n || !e ? null : {
|
|
526
|
-
x: L(C(n, "x")),
|
|
527
|
-
y: L(C(n, "y")),
|
|
528
|
-
w: Math.max(0, L(C(e, "cx"))),
|
|
529
|
-
h: Math.max(0, L(C(e, "cy"))),
|
|
530
|
-
rot: C(t, "rot") / 6e4,
|
|
531
|
-
flipH: !!B(t, "flipH"),
|
|
532
|
-
flipV: !!B(t, "flipV")
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
const gt = (t) => t;
|
|
536
|
-
function Ae(t, n) {
|
|
537
|
-
const e = Y(t);
|
|
538
|
-
if (!e) return n;
|
|
539
|
-
const o = l(t, "chOff"), s = l(t, "chExt"), r = o ? L(C(o, "x")) : e.x, a = o ? L(C(o, "y")) : e.y, i = s ? L(C(s, "cx")) : e.w, c = s ? L(C(s, "cy")) : e.h, x = i > 0 ? e.w / i : 1, b = c > 0 ? e.h / c : 1, f = e.x + e.w / 2, m = e.y + e.h / 2, g = e.rot * Math.PI / 180;
|
|
540
|
-
return (u) => {
|
|
541
|
-
let h = e.x + (u.x + u.w / 2 - r) * x, y = e.y + (u.y + u.h / 2 - a) * b, d = u.rot, p = u.flipH, k = u.flipV;
|
|
542
|
-
if (e.flipH && (h = 2 * f - h, p = !p, d = -d), e.flipV && (y = 2 * m - y, k = !k, d = -d), g) {
|
|
543
|
-
const v = h - f, N = y - m;
|
|
544
|
-
h = f + v * Math.cos(g) - N * Math.sin(g), y = m + v * Math.sin(g) + N * Math.cos(g), d += e.rot;
|
|
545
|
-
}
|
|
546
|
-
const M = u.w * x, S = u.h * b;
|
|
547
|
-
return n({ x: h - M / 2, y: y - S / 2, w: M, h: S, rot: (d % 360 + 360) % 360, flipH: p, flipV: k });
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
function Ft(t) {
|
|
551
|
-
const n = l(t, "spcPts"), e = l(t, "spcPct");
|
|
552
|
-
if (n) return { px: Math.max(0, Math.min(1584, C(n, "val") / 100)) * (vt / H) };
|
|
553
|
-
if (e) return { lines: Math.max(0, Math.min(13.2, C(e, "val") / 1e5)) };
|
|
554
|
-
}
|
|
555
|
-
function jt(t, n, e) {
|
|
556
|
-
const o = l(t, `lvl${n + 1}pPr`) ?? (t && t.localName.endsWith("pPr") ? t : null);
|
|
557
|
-
return o ? qt(o, e) : {};
|
|
558
|
-
}
|
|
559
|
-
function qt(t, n) {
|
|
560
|
-
const e = {};
|
|
561
|
-
if (w(t, "algn") && (e.algn = w(t, "algn")), w(t, "marL") !== null && (e.marL = L(C(t, "marL"))), w(t, "indent") !== null && (e.indent = L(C(t, "indent"))), l(t, "buNone")) e.bullet = "none";
|
|
562
|
-
else if (l(t, "buAutoNum")) {
|
|
563
|
-
const a = l(t, "buAutoNum");
|
|
564
|
-
e.bullet = "num", e.numType = w(a, "type") || "arabicPeriod", e.startAt = w(a, "startAt") !== null ? Math.max(1, Math.min(32767, Math.round(C(a, "startAt", 1)))) : void 0;
|
|
565
|
-
} else l(t, "buChar") ? (e.bullet = "char", e.buChar = w(l(t, "buChar"), "char") || void 0) : l(t, "buBlip") && (e.bullet = "char", e.buChar = "•");
|
|
566
|
-
if (l(t, "buFont") ? e.buFont = w(l(t, "buFont"), "typeface") || null : l(t, "buFontTx") && (e.buFont = null), l(t, "buClr") ? e.buClr = $(l(t, "buClr"), n.ctx) : l(t, "buClrTx") && (e.buClr = null), l(t, "buSzPct")) {
|
|
567
|
-
const a = w(l(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 (l(t, "buSzTx") || l(t, "buSzPts")) && (e.buSz = null);
|
|
570
|
-
const o = R(t, "lnSpc", "spcPct");
|
|
571
|
-
o && (e.lnSpcPct = C(o, "val") / 1e5);
|
|
572
|
-
const s = Ft(l(t, "spcBef")), r = Ft(l(t, "spcAft"));
|
|
573
|
-
return s && (e.spcBef = s), r && (e.spcAft = r), Object.assign(e, Zt(l(t, "defRPr"), n)), e;
|
|
574
|
-
}
|
|
575
|
-
function Zt(t, n) {
|
|
576
|
-
if (!t) return {};
|
|
577
|
-
const e = {};
|
|
578
|
-
w(t, "sz") !== null && (e.sz = C(t, "sz") / 100 * (vt / H)), B(t, "b") !== void 0 && (e.b = B(t, "b")), B(t, "i") !== void 0 && (e.i = B(t, "i")), w(t, "u") && (e.u = w(t, "u") !== "none"), w(t, "strike") && (e.strike = w(t, "strike") !== "noStrike");
|
|
579
|
-
const o = l(t, "solidFill");
|
|
580
|
-
o ? e.color = $(o, n.ctx) : l(t, "noFill") && (e.color = null);
|
|
581
|
-
const s = w(l(t, "latin"), "typeface");
|
|
582
|
-
return s && (e.font = s), e;
|
|
583
|
-
}
|
|
584
|
-
const Ee = {
|
|
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
|
-
}, Le = { 183: "•", 168: "♦", 174: "→", 222: "⇒", 45: "−", 42: "∗" };
|
|
599
|
-
function Fe(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" && Ee[e] || "•" : o === "symbol" ? Le[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 Dt = (...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 je(t, n) {
|
|
612
|
-
if (t)
|
|
613
|
-
return t.startsWith("+mj") ? n.major : t.startsWith("+mn") ? n.minor : t;
|
|
614
|
-
}
|
|
615
|
-
function Tt(t, n, e) {
|
|
616
|
-
if (!t) return;
|
|
617
|
-
const o = I(t, "p");
|
|
618
|
-
if (!o.some((g) => I(g).some((u) => (u.localName === "r" || u.localName === "fld") && (R(u, "t")?.textContent ?? "") !== ""))) return;
|
|
619
|
-
const r = {};
|
|
620
|
-
let a = 1, i = 1;
|
|
621
|
-
for (const g of [...n.bodyPr, l(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 u = l(g, "normAutofit");
|
|
625
|
-
u && (a = w(u, "fontScale") !== null ? C(u, "fontScale") / 1e5 : 1), u && (i = 1 - Math.max(0, Math.min(0.9, C(u, "lnSpcReduction") / 1e5))), (l(g, "noAutofit") || l(g, "spAutoFit")) && (a = 1, i = 1);
|
|
626
|
-
}
|
|
627
|
-
const c = (g, u) => r[g] !== void 0 ? L(Number(r[g]) || 0) : L(u), x = r.anchor === "ctr" ? "ctr" : r.anchor === "b" ? "b" : "t", b = l(t, "lstStyle"), f = [];
|
|
628
|
-
let m;
|
|
629
|
-
for (const g of o) {
|
|
630
|
-
const u = l(g, "pPr"), h = Math.max(0, Math.min(8, C(u, "lvl"))), y = n.fontRef ? { color: n.fontRef.color ?? void 0, font: n.fontRef.font } : {}, d = Dt(...n.levels.map((P) => jt(P, h, e)), y, jt(b, h, e), u ? qt(u, e) : {});
|
|
631
|
-
d.lnSpcPct !== void 0 && m === void 0 && (m = d.lnSpcPct);
|
|
632
|
-
const p = { runs: [], align: d.algn === "ctr" ? "ctr" : d.algn === "r" ? "r" : (d.algn === "just", "l"), level: h };
|
|
633
|
-
if (d.bullet === "char" || d.bullet === "num") {
|
|
634
|
-
if (p.bullet = d.bullet, p.marL = d.marL ?? 0, p.indent = d.indent ?? 0, d.bullet === "char") {
|
|
635
|
-
const P = Fe(d.buChar, d.buFont ?? void 0);
|
|
636
|
-
P !== "•" && (p.bulletChar = P);
|
|
637
|
-
} else
|
|
638
|
-
d.numType && d.numType !== "arabicPeriod" && (p.numType = d.numType), d.startAt && d.startAt !== 1 && (p.startAt = d.startAt);
|
|
639
|
-
d.buClr && (p.bulletColor = d.buClr), d.buSz && Math.abs(d.buSz - 1) > 1e-3 && (p.bulletScale = d.buSz);
|
|
640
|
-
}
|
|
641
|
-
const k = (P) => {
|
|
642
|
-
const T = Dt(d, Zt(P, e)), A = (T.sz ?? 18 * vt / H) * a, E = T.color === null ? void 0 : T.color ?? Kt("tx1", e);
|
|
643
|
-
return {
|
|
644
|
-
text: "",
|
|
645
|
-
size: A,
|
|
646
|
-
bold: T.b || void 0,
|
|
647
|
-
italic: T.i || void 0,
|
|
648
|
-
underline: T.u || void 0,
|
|
649
|
-
strike: T.strike || void 0,
|
|
650
|
-
color: E ?? void 0,
|
|
651
|
-
font: je(T.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 T = R(P, "t")?.textContent ?? "";
|
|
657
|
-
if (!T) continue;
|
|
658
|
-
T.split(/[\v\n]/).forEach((A, E) => {
|
|
659
|
-
E > 0 && p.runs.push({ ...k(l(P, "rPr")), br: !0 }), A && p.runs.push({ ...k(l(P, "rPr")), text: A });
|
|
660
|
-
});
|
|
661
|
-
} else P.localName === "br" && p.runs.push({ ...k(l(P, "rPr")), br: !0 });
|
|
662
|
-
p.endSize = k(l(g, "endParaRPr")).size;
|
|
663
|
-
const M = (p.runs.length ? Math.max(...p.runs.map((P) => P.size ?? 0)) : p.endSize ?? 0) * 1.2 * (d.lnSpcPct ?? 1), S = (P) => P ? ("px" in P ? P.px : P.lines * M) * i : 0, v = S(d.spcBef), N = S(d.spcAft);
|
|
664
|
-
v > 0.05 && (p.spaceBefore = Math.round(v * 100) / 100), N > 0.05 && (p.spaceAfter = Math.round(N * 100) / 100), f.push(p);
|
|
665
|
-
}
|
|
666
|
-
return {
|
|
667
|
-
paragraphs: f,
|
|
668
|
-
anchor: x,
|
|
669
|
-
insets: { l: c("lIns", 91440), t: c("tIns", 45720), r: c("rIns", 91440), b: c("bIns", 45720) },
|
|
670
|
-
wrap: r.wrap !== "none",
|
|
671
|
-
lineSpacing: m
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
const Kt = (t, n) => {
|
|
675
|
-
const e = n.ctx.clrMap[t] ?? St[t] ?? t, o = n.ctx.theme.colors[e];
|
|
676
|
-
return o ? { hex: o } : null;
|
|
677
|
-
}, q = (t) => {
|
|
678
|
-
const n = l(t, "ph");
|
|
679
|
-
return n ? { type: w(n, "type") || "obj", idx: C(n, "idx") } : null;
|
|
680
|
-
}, tt = (t) => l(I(t).find((n) => n.localName.startsWith("nv")) ?? null, "nvPr"), ot = /* @__PURE__ */ new Set(["title", "ctrTitle"]), $t = /* @__PURE__ */ new Set(["title", "ctrTitle", "dt", "ftr", "sldNum", "hdr"]), Bt = (t, n) => t === n || ot.has(t) && ot.has(n) || !$t.has(t) && !$t.has(n);
|
|
681
|
-
function ft(t, n) {
|
|
682
|
-
const e = De(t);
|
|
683
|
-
if (n.idx) {
|
|
684
|
-
const o = e.find((s) => s.ph.idx === n.idx && Bt(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 || ot.has(n.type))) ?? e.find((o) => o.ph.type === n.type) ?? e.find((o) => Bt(o.ph.type, n.type)))?.el ?? null;
|
|
688
|
-
}
|
|
689
|
-
function De(t) {
|
|
690
|
-
const n = [];
|
|
691
|
-
for (const e of st(t)) {
|
|
692
|
-
const o = q(tt(e));
|
|
693
|
-
o && n.push({ el: e, ph: o });
|
|
694
|
-
}
|
|
695
|
-
return n;
|
|
696
|
-
}
|
|
697
|
-
const Qt = (t) => ot.has(t) ? "title" : ["dt", "ftr", "sldNum", "hdr"].includes(t) ? t : "body", $e = (t) => {
|
|
698
|
-
const n = {};
|
|
699
|
-
for (const e of I(l(t, "avLst"), "gd")) {
|
|
700
|
-
const o = w(e, "name"), s = w(e, "fmla");
|
|
701
|
-
o && s && (n[o] = s);
|
|
702
|
-
}
|
|
703
|
-
return n;
|
|
704
|
-
};
|
|
705
|
-
function Be(t) {
|
|
706
|
-
const n = (r) => I(r, "gd").slice(0, 1e4).map((a) => [w(a, "name") || "", w(a, "fmla") || "val 0"]), e = I(l(t, "cxnLst"), "cxn").map((r) => [w(r, "ang") || "0", w(l(r, "pos"), "x") || "0", w(l(r, "pos"), "y") || "0"]), o = l(t, "rect"), s = I(l(t, "pathLst"), "path").slice(0, 1e3).map((r) => {
|
|
707
|
-
const a = [];
|
|
708
|
-
for (const c of I(r)) {
|
|
709
|
-
const x = I(c, "pt").map((b) => [w(b, "x") || "0", w(b, "y") || "0"]).flat();
|
|
710
|
-
switch (c.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", w(c, "wR") || "0", w(c, "hR") || "0", w(c, "stAng") || "0", w(c, "swAng") || "0"]);
|
|
725
|
-
break;
|
|
726
|
-
case "close":
|
|
727
|
-
a.push(["Z"]);
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
const i = w(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(l(t, "avLst"), "gd").map((r) => [w(r, "name") || "", w(r, "fmla") || "val 0"]),
|
|
736
|
-
gd: n(l(t, "gdLst")),
|
|
737
|
-
cxn: e,
|
|
738
|
-
rect: o ? [w(o, "l") || "l", w(o, "t") || "t", w(o, "r") || "r", w(o, "b") || "b"] : null,
|
|
739
|
-
paths: s
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
function et(t, n) {
|
|
743
|
-
const e = l(t, "prstGeom");
|
|
744
|
-
if (e) {
|
|
745
|
-
const s = {};
|
|
746
|
-
for (const [r, a] of Object.entries($e(e))) {
|
|
747
|
-
const i = /^val\s+(-?\d+(\.\d+)?)/.exec(a);
|
|
748
|
-
i && (s[r] = Number(i[1]));
|
|
749
|
-
}
|
|
750
|
-
return { geom: { kind: "preset", prst: w(e, "prst") || "rect", adj: Object.keys(s).length ? s : void 0 } };
|
|
751
|
-
}
|
|
752
|
-
const o = l(t, "custGeom");
|
|
753
|
-
if (o) {
|
|
754
|
-
const s = Be(o);
|
|
755
|
-
return { geom: { kind: "custom", paths: lt(s, n.w, n.h) }, textRect: s.rect ? Ut(s, n.w, n.h) : void 0 };
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
function nt(t, n, e, o, s, r) {
|
|
759
|
-
const a = [];
|
|
760
|
-
if (s > Me)
|
|
761
|
-
return e.warnings.push("Groups nested too deeply; the innermost were skipped."), a;
|
|
762
|
-
for (const i of st(t)) {
|
|
763
|
-
if (++e.count > ve) {
|
|
764
|
-
e.warnings.push("Too many shapes on one slide; the rest were skipped.");
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
try {
|
|
768
|
-
const c = He(i, n, e, o, s, r);
|
|
769
|
-
c && a.push(...Array.isArray(c) ? c : [c]);
|
|
770
|
-
} catch {
|
|
771
|
-
e.warnings.push(`A ${i.localName} couldn't be read and was skipped.`);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
return a;
|
|
775
|
-
}
|
|
776
|
-
const ze = {
|
|
777
|
-
nextslide: "next",
|
|
778
|
-
previousslide: "previous",
|
|
779
|
-
firstslide: "first",
|
|
780
|
-
lastslide: "last",
|
|
781
|
-
endshow: "end"
|
|
782
|
-
};
|
|
783
|
-
function Xe(t, n, e) {
|
|
784
|
-
const o = l(t, "hlinkClick");
|
|
785
|
-
if (!o) return;
|
|
786
|
-
const s = w(o, "action") || "", r = e.rels(n).get(w(o, "r:id") || "");
|
|
787
|
-
if (s.startsWith("ppaction://hlinkshowjump")) {
|
|
788
|
-
const a = ze[(/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 He(t, n, e, o, s, r) {
|
|
796
|
-
const a = I(t).find((x) => x.localName.startsWith("nv")), i = Ye(t, n, e, o, s, r), c = i ? Xe(l(a ?? null, "cNvPr"), n.part, e.pkg) : void 0;
|
|
797
|
-
if (c) for (const x of Array.isArray(i) ? i : [i]) x.link = c;
|
|
798
|
-
return i;
|
|
799
|
-
}
|
|
800
|
-
function Ye(t, n, e, o, s, r) {
|
|
801
|
-
const a = { pkg: e.pkg, part: n.part, ctx: e.ctx }, i = I(t).find((f) => f.localName.startsWith("nv")), c = l(i ?? null, "cNvPr"), x = C(c, "id"), b = w(c, "name") || t.localName;
|
|
802
|
-
if (w(c, "hidden") === "1") return null;
|
|
803
|
-
switch (t.localName) {
|
|
804
|
-
case "sp":
|
|
805
|
-
return Ue(t, n, e, o, x, b, r);
|
|
806
|
-
case "cxnSp": {
|
|
807
|
-
const f = l(t, "spPr"), m = Y(l(f, "xfrm"));
|
|
808
|
-
if (!m) return null;
|
|
809
|
-
const g = o(m), u = l(t, "style"), h = U(l(f, "ln"), a) ?? Pt(u, a) ?? { width: 1, color: { hex: "#000000" } };
|
|
810
|
-
if (!h) return null;
|
|
811
|
-
const y = et(f, g) ?? { geom: { kind: "preset", prst: "line" } }, d = (k) => k ? { id: C(k, "id"), idx: C(k, "idx") } : void 0, p = l(i ?? null, "cNvCxnSpPr");
|
|
812
|
-
return { kind: "connector", id: x, name: b, ...g, geom: y.geom, line: h, start: d(l(p, "stCxn")), end: d(l(p, "endCxn")) };
|
|
813
|
-
}
|
|
814
|
-
case "pic": {
|
|
815
|
-
const f = l(t, "spPr");
|
|
816
|
-
let m = Y(l(f, "xfrm"));
|
|
817
|
-
const g = q(l(i ?? null, "nvPr"));
|
|
818
|
-
if (!m && g && (m = We(g, e)), !m) return null;
|
|
819
|
-
const u = l(t, "blipFill"), h = u ? Vt(u, a) : null;
|
|
820
|
-
if (!h)
|
|
821
|
-
return e.warnings.push(`Picture "${b}" has no image the importer can read.`), null;
|
|
822
|
-
const y = l(u, "srcRect"), d = y ? { l: C(y, "l") / 1e5, t: C(y, "t") / 1e5, r: C(y, "r") / 1e5, b: C(y, "b") / 1e5 } : void 0, p = w(R(u, "blip", "alphaModFix"), "amt"), k = o(m), M = et(f, k)?.geom, S = M && !(M.kind === "preset" && M.prst === "rect") ? M : void 0;
|
|
823
|
-
return { kind: "picture", id: x, name: b, ...k, media: h, crop: d, alpha: p !== null ? Number(p) / 1e5 : void 0, descr: w(c, "descr") || void 0, geom: S, ...R(u, "blip", "grayscl") ? { grayscale: !0 } : {} };
|
|
824
|
-
}
|
|
825
|
-
case "grpSp": {
|
|
826
|
-
const f = l(t, "grpSpPr"), m = l(f, "xfrm"), g = Ae(m, o), u = nt(t, n, e, g, s + 1, r);
|
|
827
|
-
if (!u.length) return null;
|
|
828
|
-
const h = ut(u);
|
|
829
|
-
return { kind: "group", id: x, name: b, ...h, children: u };
|
|
830
|
-
}
|
|
831
|
-
case "graphicFrame":
|
|
832
|
-
return qe(t, n, e, o, x, b, s);
|
|
833
|
-
default:
|
|
834
|
-
return null;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
function ut(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 We(t, n) {
|
|
844
|
-
const e = ft(n.layout?.tree ?? null, t), o = Y(R(e, "spPr", "xfrm"));
|
|
845
|
-
if (o) return o;
|
|
846
|
-
const s = ft(n.master?.tree ?? null, { type: Qt(t.type), idx: 0 });
|
|
847
|
-
return Y(R(s, "spPr", "xfrm"));
|
|
848
|
-
}
|
|
849
|
-
function _e(...t) {
|
|
850
|
-
for (const n of t) {
|
|
851
|
-
const e = n();
|
|
852
|
-
if (e !== void 0) return e;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
function Ue(t, n, e, o, s, r, a) {
|
|
856
|
-
const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, c = tt(t), x = q(c);
|
|
857
|
-
if (x && !a) return null;
|
|
858
|
-
const b = l(t, "spPr"), f = l(t, "style"), m = w(R(t, "nvSpPr", "cNvSpPr"), "txBox") === "1", g = x && e.layout ? ft(e.layout.tree, x) : null, u = x && e.master ? ft(e.master.tree, { type: Qt(g ? q(tt(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 = u && e.master ? { pkg: e.pkg, part: e.master.part, ctx: e.ctx } : null;
|
|
859
|
-
let d = Y(l(b, "xfrm")) ?? Y(R(g, "spPr", "xfrm")) ?? Y(R(u, "spPr", "xfrm"));
|
|
860
|
-
if (!d) return null;
|
|
861
|
-
d = o(d);
|
|
862
|
-
const p = et(b, d) ?? (g ? et(l(g, "spPr"), d) : void 0) ?? (u ? et(l(u, "spPr"), d) : void 0) ?? { geom: { kind: "preset", prst: "rect" } }, M = (B(t, "useBgFill") ? e.background?.kind === "image" ? { kind: "none" } : e.background ?? { kind: "solid", color: { hex: "#ffffff" } } : void 0) ?? V(b, i) ?? ct(f, i) ?? (h ? V(l(g, "spPr"), h) : void 0) ?? (y ? V(l(u, "spPr"), y) : void 0) ?? (h ? ct(l(g, "style"), h) : void 0) ?? { kind: "none" }, S = _e(
|
|
863
|
-
() => U(l(b, "ln"), i),
|
|
864
|
-
() => Pt(f, i),
|
|
865
|
-
() => h ? U(R(g, "spPr", "ln"), h) : void 0,
|
|
866
|
-
() => y ? U(R(u, "spPr", "ln"), y) : void 0
|
|
867
|
-
) ?? null, v = [];
|
|
868
|
-
if (x) {
|
|
869
|
-
const j = g ? q(tt(g))?.type ?? x.type : x.type;
|
|
870
|
-
v.push(ot.has(j) ? e.masterTx.title : ["body", "obj", "subTitle", "tbl", "chart", "dgm", "media", "pic", "clipArt"].includes(j) ? e.masterTx.body : e.masterTx.other), v.push(R(u, "txBody", "lstStyle"), R(g, "txBody", "lstStyle"));
|
|
871
|
-
} else
|
|
872
|
-
v.push(e.defaultText);
|
|
873
|
-
const N = l(f, "fontRef"), P = {
|
|
874
|
-
levels: v,
|
|
875
|
-
bodyPr: [R(u, "txBody", "bodyPr"), R(g, "txBody", "bodyPr")],
|
|
876
|
-
fontRef: N ? { font: w(N, "idx") === "major" ? "+mj-lt" : "+mn-lt", color: $(N, i.ctx) } : void 0
|
|
877
|
-
}, T = Tt(l(t, "txBody"), P, i);
|
|
878
|
-
if (!(M.kind !== "none" || !!S || !!T)) return null;
|
|
879
|
-
let E = p.textRect;
|
|
880
|
-
const O = Y(l(b, "xfrm")), z = T ? Y(l(t, "txXfrm")) : null;
|
|
881
|
-
if (z && O && O.w > 0 && O.h > 0) {
|
|
882
|
-
const j = d.w / O.w, W = d.h / O.h, X = { l: (z.x - O.x) * j, t: (z.y - O.y) * W, r: (z.x + z.w - O.x) * j, b: (z.y + z.h - O.y) * W };
|
|
883
|
-
(Math.abs(X.l) > 0.5 || Math.abs(X.t) > 0.5 || Math.abs(X.r - d.w) > 0.5 || Math.abs(X.b - d.h) > 0.5) && (E = X);
|
|
884
|
-
}
|
|
885
|
-
return { kind: "shape", id: s, name: r, ...d, geom: p.geom, fill: M, line: S, text: T, textBox: m || void 0, textRect: E };
|
|
886
|
-
}
|
|
887
|
-
const zt = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
|
|
888
|
-
function Ge(t, n) {
|
|
889
|
-
const e = {};
|
|
890
|
-
if (!t) return e;
|
|
891
|
-
const o = l(t, "tcStyle"), s = l(t, "tcTxStyle"), r = l(o, "fill"), a = r ? V(r, n) : ct(o, n);
|
|
892
|
-
a && (e.fill = a);
|
|
893
|
-
const i = $(s, n.ctx) ?? $(l(s, "fontRef"), n.ctx);
|
|
894
|
-
i && (e.text = i), w(s, "b") === "on" && (e.bold = !0);
|
|
895
|
-
const c = l(o, "tcBdr");
|
|
896
|
-
for (const x of ["insideH", "bottom", "top", "left"]) {
|
|
897
|
-
const b = l(c, x);
|
|
898
|
-
if (!b) continue;
|
|
899
|
-
const f = U(l(b, "ln"), n) ?? Pt(b, n);
|
|
900
|
-
if (f !== void 0) {
|
|
901
|
-
e.border = f;
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return e;
|
|
906
|
-
}
|
|
907
|
-
function Ve(t, n, e) {
|
|
908
|
-
const o = ((l(t, "tableStyleId")?.textContent || "").trim() || w(e, "def") || zt).toUpperCase(), s = (f) => B(t, f) ?? !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((f) => (w(f, "styleId") || "").toUpperCase() === o);
|
|
909
|
-
if (a) {
|
|
910
|
-
const f = (y) => Ge(l(a, y), n), m = l(a, "tblBg"), g = m ? l(m, "fill") ? V(l(m, "fill"), n) : ct(m, n) : void 0, u = {
|
|
911
|
-
whole: f("wholeTbl"),
|
|
912
|
-
b1H: f("band1H"),
|
|
913
|
-
b2H: f("band2H"),
|
|
914
|
-
b1V: f("band1V"),
|
|
915
|
-
b2V: f("band2V"),
|
|
916
|
-
firstRow: f("firstRow"),
|
|
917
|
-
lastRow: f("lastRow"),
|
|
918
|
-
firstCol: f("firstCol"),
|
|
919
|
-
lastCol: f("lastCol")
|
|
920
|
-
}, h = (y, d, p, k) => {
|
|
921
|
-
const M = [u.whole], S = y - (r.firstRow ? 1 : 0), v = d - (r.firstCol ? 1 : 0);
|
|
922
|
-
r.bandCol && v >= 0 && M.push(v % 2 === 0 ? u.b1V : u.b2V), r.bandRow && S >= 0 && M.push(S % 2 === 0 ? u.b1H : u.b2H), r.firstCol && d === 0 && M.push(u.firstCol), r.lastCol && d === k - 1 && M.push(u.lastCol), r.firstRow && y === 0 && M.push(u.firstRow), r.lastRow && y === p - 1 && M.push(u.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 !== zt) return null;
|
|
931
|
-
const i = n.ctx.theme.colors.accent1 ?? "#4472c4", c = (f) => {
|
|
932
|
-
const [m, g, u] = Gt(i);
|
|
933
|
-
return { hex: it(_(J(m) * f + (1 - f)), _(J(g) * f + (1 - f)), _(J(u) * f + (1 - f))) };
|
|
934
|
-
}, x = { hex: n.ctx.theme.colors.lt1 ?? "#ffffff" }, b = Kt("tx1", n) ?? void 0;
|
|
935
|
-
return (f) => {
|
|
936
|
-
const m = r.firstRow && f === 0, g = r.bandRow && !m && (f - (r.firstRow ? 1 : 0)) % 2 === 0;
|
|
937
|
-
return {
|
|
938
|
-
fill: { kind: "solid", color: m ? { hex: i } : c(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 qe(t, n, e, o, s, r, a = 0) {
|
|
946
|
-
const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, c = Y(l(t, "xfrm"));
|
|
947
|
-
if (!c) return null;
|
|
948
|
-
const x = R(t, "graphic", "graphicData"), b = l(x, "tbl");
|
|
949
|
-
if (b) {
|
|
950
|
-
const g = I(l(b, "tblGrid"), "gridCol").map((k) => L(C(k, "w"))), u = Ve(l(b, "tblPr"), i, e.tableStyles), h = [];
|
|
951
|
-
let y = c.y, d = 1e6 + s * 1e3;
|
|
952
|
-
const p = I(b, "tr");
|
|
953
|
-
if (p.forEach((k, M) => {
|
|
954
|
-
const S = L(C(k, "h"));
|
|
955
|
-
let v = c.x, N = 0;
|
|
956
|
-
for (const P of I(k, "tc")) {
|
|
957
|
-
const T = Math.max(1, C(P, "gridSpan", 1)), A = g.slice(N, N + T).reduce((G, F) => G + F, 0);
|
|
958
|
-
if (N += T, B(P, "hMerge") || B(P, "vMerge")) {
|
|
959
|
-
v += A;
|
|
960
|
-
continue;
|
|
961
|
-
}
|
|
962
|
-
const E = Math.max(1, C(P, "rowSpan", 1)), O = l(P, "tcPr"), z = E > 1 ? S * E : S, j = u ? u(M, N - T, p.length, g.length) : null, W = j?.text ? { color: j.text } : void 0, X = Tt(l(P, "txBody"), { levels: [e.defaultText], bodyPr: [], fontRef: W }, i);
|
|
963
|
-
X && j?.bold && X.paragraphs.forEach((G) => G.runs.forEach((F) => {
|
|
964
|
-
F.bold === void 0 && (F.bold = !0);
|
|
965
|
-
})), X && (X.insets = { l: L(C(O, "marL", 91440)), r: L(C(O, "marR", 91440)), t: L(C(O, "marT", 45720)), b: L(C(O, "marB", 45720)) }, X.anchor = w(O, "anchor") === "ctr" ? "ctr" : w(O, "anchor") === "b" ? "b" : "t");
|
|
966
|
-
const dt = U(l(O, "lnB"), i) ?? U(l(O, "lnT"), i) ?? (j ? j.border ?? null : { width: 1, color: { hex: "#bfbfbf" } }), rt = j?.fill;
|
|
967
|
-
h.push({
|
|
968
|
-
kind: "shape",
|
|
969
|
-
id: d++,
|
|
970
|
-
name: `${r} cell`,
|
|
971
|
-
...o({ x: v, y, w: A, h: z, rot: 0, flipH: !1, flipV: !1 }),
|
|
972
|
-
geom: { kind: "preset", prst: "rect" },
|
|
973
|
-
fill: V(O, i) ?? rt ?? { kind: "none" },
|
|
974
|
-
line: dt,
|
|
975
|
-
text: X
|
|
976
|
-
}), v += A;
|
|
977
|
-
}
|
|
978
|
-
y += S;
|
|
979
|
-
}), !h.length) return null;
|
|
980
|
-
if (u?.background) {
|
|
981
|
-
const k = ut(h);
|
|
982
|
-
h.unshift({
|
|
983
|
-
kind: "shape",
|
|
984
|
-
id: d++,
|
|
985
|
-
name: `${r} background`,
|
|
986
|
-
x: k.x,
|
|
987
|
-
y: k.y,
|
|
988
|
-
w: k.w,
|
|
989
|
-
h: k.h,
|
|
990
|
-
rot: 0,
|
|
991
|
-
flipH: !1,
|
|
992
|
-
flipV: !1,
|
|
993
|
-
geom: { kind: "preset", prst: "rect" },
|
|
994
|
-
fill: u.background,
|
|
995
|
-
line: null
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
return { kind: "group", id: s, name: r, ...ut(h), children: h };
|
|
999
|
-
}
|
|
1000
|
-
const f = w(x, "uri") || "";
|
|
1001
|
-
if (/diagram/.test(f)) {
|
|
1002
|
-
const g = Ze(x, n, e, o, c, s, r, a);
|
|
1003
|
-
if (g) return g;
|
|
1004
|
-
const u = Ke(x, n, e, o, c, s, r, i);
|
|
1005
|
-
if (u) return u;
|
|
1006
|
-
}
|
|
1007
|
-
const m = /chart/.test(f) ? "Chart" : /diagram/.test(f) ? "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(c),
|
|
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 Ze(t, n, e, o, s, r, a, i) {
|
|
1020
|
-
const c = e.pkg.rels(n.part), x = w(l(t, "relIds"), "r:dm"), b = x ? c.get(x) : void 0;
|
|
1021
|
-
let f;
|
|
1022
|
-
if (b && !b.external) {
|
|
1023
|
-
const d = Jt(e.pkg.xml(b.target), "dataModelExt", 6), p = d ? c.get(w(d, "relId") || "") : void 0;
|
|
1024
|
-
p && !p.external && (f = p.target);
|
|
1025
|
-
}
|
|
1026
|
-
if (!f) {
|
|
1027
|
-
const d = [...c.values()].filter((p) => p.type === "diagramDrawing" && !p.external);
|
|
1028
|
-
d.length === 1 && (f = d[0].target);
|
|
1029
|
-
}
|
|
1030
|
-
if (!f) return null;
|
|
1031
|
-
const m = l(e.pkg.xml(f), "spTree");
|
|
1032
|
-
if (!m) return null;
|
|
1033
|
-
const u = nt(m, { part: f, tree: m }, e, (d) => o({ ...d, x: d.x + s.x, y: d.y + s.y }), i + 1, !0);
|
|
1034
|
-
if (!u.length) return null;
|
|
1035
|
-
let h = 2e6 + r * 1e3;
|
|
1036
|
-
const y = (d) => d.forEach((p) => {
|
|
1037
|
-
p.id = h++, p.kind === "group" && y(p.children);
|
|
1038
|
-
});
|
|
1039
|
-
return y(u), { kind: "group", id: r, name: a, ...ut(u), children: u };
|
|
1040
|
-
}
|
|
1041
|
-
function Ke(t, n, e, o, s, r, a, i) {
|
|
1042
|
-
const c = w(l(t, "relIds"), "r:dm"), x = c ? e.pkg.rels(n.part).get(c) : void 0;
|
|
1043
|
-
if (!x || x.external) return null;
|
|
1044
|
-
const b = e.pkg.xml(x.target), f = /* @__PURE__ */ new Map();
|
|
1045
|
-
for (const d of I(l(b, "ptLst"), "pt")) f.set(w(d, "modelId") || "", d);
|
|
1046
|
-
const m = /* @__PURE__ */ new Map();
|
|
1047
|
-
for (const d of I(l(b, "cxnLst"), "cxn")) {
|
|
1048
|
-
if ((w(d, "type") || "parOf") !== "parOf") continue;
|
|
1049
|
-
const p = w(d, "srcId") || "", k = w(d, "destId") || "";
|
|
1050
|
-
m.has(p) || m.set(p, []), m.get(p).push({ id: k, ord: C(d, "srcOrd") });
|
|
1051
|
-
}
|
|
1052
|
-
const g = [...f.values()].find((d) => w(d, "type") === "doc");
|
|
1053
|
-
if (!g) return null;
|
|
1054
|
-
const u = [], h = /* @__PURE__ */ new Set(), y = (d, p) => {
|
|
1055
|
-
if (!(h.has(d) || p > 16 || u.length > 500)) {
|
|
1056
|
-
h.add(d);
|
|
1057
|
-
for (const k of (m.get(d) ?? []).sort((M, S) => M.ord - S.ord)) {
|
|
1058
|
-
const M = f.get(k.id), S = w(M, "type") || "node";
|
|
1059
|
-
if (!M || S !== "node" && S !== "asst") continue;
|
|
1060
|
-
const v = Tt(l(M, "t"), { levels: [e.defaultText], bodyPr: [] }, i);
|
|
1061
|
-
for (const N of v?.paragraphs ?? [])
|
|
1062
|
-
N.runs.some((P) => !P.br && P.text.trim()) && u.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(k.id, p + 1);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
return y(w(g, "modelId") || "", 0), u.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: u, anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
|
|
1083
|
-
}) : null;
|
|
1084
|
-
}
|
|
1085
|
-
function Jt(t, n, e) {
|
|
1086
|
-
if (!t || e < 0) return null;
|
|
1087
|
-
for (const o of st(t)) {
|
|
1088
|
-
if (o.localName === n) return o;
|
|
1089
|
-
const s = Jt(o, n, e - 1);
|
|
1090
|
-
if (s) return s;
|
|
1091
|
-
}
|
|
1092
|
-
return null;
|
|
1093
|
-
}
|
|
1094
|
-
function xt(t, n) {
|
|
1095
|
-
const e = l(t, "bg");
|
|
1096
|
-
if (!e) return;
|
|
1097
|
-
const o = l(e, "bgPr");
|
|
1098
|
-
if (o)
|
|
1099
|
-
return V(o, n);
|
|
1100
|
-
const s = l(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 ? Ct(i, { ...n, ctx: { ...n.ctx, phClr: $(s, n.ctx) ?? void 0 } }) : void 0) ?? ($(s, n.ctx) ? { kind: "solid", color: $(s, n.ctx) } : void 0);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
function Qe(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 c of st(i)) {
|
|
1111
|
-
if (c.localName === "grpSp") {
|
|
1112
|
-
r(c);
|
|
1113
|
-
continue;
|
|
1114
|
-
}
|
|
1115
|
-
if (c.localName !== "sp") continue;
|
|
1116
|
-
const x = q(tt(c));
|
|
1117
|
-
if (!(!x || x.type !== "body" && x.type !== "obj"))
|
|
1118
|
-
for (const b of I(l(c, "txBody"), "p")) {
|
|
1119
|
-
let f = "";
|
|
1120
|
-
for (const m of I(b))
|
|
1121
|
-
m.localName === "r" || m.localName === "fld" ? f += l(m, "t")?.textContent ?? "" : m.localName === "br" && (f += `
|
|
1122
|
-
`);
|
|
1123
|
-
s.push(f);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
r(o);
|
|
1128
|
-
const a = s.join(`
|
|
1129
|
-
`).replace(/\s+$/, "");
|
|
1130
|
-
return a.trim() ? a : void 0;
|
|
1131
|
-
}
|
|
1132
|
-
function Je(t) {
|
|
1133
|
-
const n = st(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 = w(n, "spd"), s = w(n, "p14:dur") !== null ? C(n, "p14:dur") : o === "fast" ? 500 : o === "slow" ? 1e3 : 750, r = w(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 tn(t, n = {}) {
|
|
1153
|
-
const e = [], o = (T) => {
|
|
1154
|
-
e.length < 200 && !e.includes(T) && e.push(T);
|
|
1155
|
-
}, s = n.parseXml ?? ((T) => new DOMParser().parseFromString(T, "application/xml"));
|
|
1156
|
-
let r, a = 0, i = 0;
|
|
1157
|
-
try {
|
|
1158
|
-
r = ae(t, {
|
|
1159
|
-
filter: (T) => (a++, i += T.originalSize, a <= At && T.originalSize <= ke && i <= Et)
|
|
1160
|
-
});
|
|
1161
|
-
} catch {
|
|
1162
|
-
throw new Error("This file is not a PowerPoint presentation (it is not a valid .pptx package).");
|
|
1163
|
-
}
|
|
1164
|
-
(a > At || i > Et) && o("The file is very large; some parts were skipped.");
|
|
1165
|
-
const c = new Pe(r, s, o), x = c.relOfType("", "officeDocument") ?? "ppt/presentation.xml", b = c.xml(x);
|
|
1166
|
-
if (!b || b.localName !== "presentation") throw new Error("This file is not a PowerPoint presentation (no presentation part).");
|
|
1167
|
-
const f = l(b, "sldSz"), m = f ? Math.max(1, L(C(f, "cx", 9144e3))) : 960, g = f ? Math.max(1, L(C(f, "cy", 5143500))) : 540, u = l(b, "defaultTextStyle"), h = c.rels(x), y = c.relOfType(x, "tableStyles"), d = y ? c.xml(y) : null, p = [], k = /* @__PURE__ */ new Set();
|
|
1168
|
-
for (const T of I(l(b, "sldIdLst"), "sldId")) {
|
|
1169
|
-
const A = h.get(w(T, "r:id") || "");
|
|
1170
|
-
A && !k.has(A.target) && p.length < we && (k.add(A.target), p.push(A.target));
|
|
1171
|
-
}
|
|
1172
|
-
const M = /* @__PURE__ */ new Map(), S = (T) => {
|
|
1173
|
-
const A = c.relOfType(T, "theme");
|
|
1174
|
-
return A ? (M.has(A) || M.set(A, pt(c.xml(A))), M.get(A)) : pt(null);
|
|
1175
|
-
}, v = (T) => {
|
|
1176
|
-
if (!T) return null;
|
|
1177
|
-
const A = {};
|
|
1178
|
-
for (let E = 0; E < T.attributes.length; E++) A[T.attributes[E].localName ?? T.attributes[E].name] = T.attributes[E].value;
|
|
1179
|
-
return A;
|
|
1180
|
-
}, N = [];
|
|
1181
|
-
p.forEach((T, A) => {
|
|
1182
|
-
const E = c.xml(T);
|
|
1183
|
-
if (!E) {
|
|
1184
|
-
o(`Slide ${A + 1} couldn't be read and was skipped.`);
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
const O = c.relOfType(T, "slideLayout"), z = O ? c.xml(O) : null, j = O ? c.relOfType(O, "slideMaster") : null, W = j ? c.xml(j) : null, X = j ? S(j) : pt(null), dt = v(R(E, "clrMapOvr", "overrideClrMapping")) ?? v(R(z, "clrMapOvr", "overrideClrMapping")) ?? v(l(W, "clrMap")) ?? St, rt = { theme: X, clrMap: dt }, G = l(W, "txStyles"), F = {
|
|
1188
|
-
pkg: c,
|
|
1189
|
-
ctx: rt,
|
|
1190
|
-
slide: { part: T, tree: R(E, "cSld", "spTree") },
|
|
1191
|
-
layout: O ? { part: O, tree: R(z, "cSld", "spTree") } : null,
|
|
1192
|
-
master: j ? { part: j, tree: R(W, "cSld", "spTree") } : null,
|
|
1193
|
-
masterTx: { title: l(G, "titleStyle"), body: l(G, "bodyStyle"), other: l(G, "otherStyle") },
|
|
1194
|
-
defaultText: u,
|
|
1195
|
-
warnings: e,
|
|
1196
|
-
count: 0,
|
|
1197
|
-
tableStyles: d
|
|
1198
|
-
}, ht = (re) => ({ pkg: c, part: re?.part ?? T, ctx: rt }), It = xt(l(E, "cSld"), ht(F.slide)) ?? xt(l(z, "cSld"), ht(F.layout)) ?? xt(l(W, "cSld"), ht(F.master)) ?? { kind: "solid", color: { hex: "#ffffff" } };
|
|
1199
|
-
F.background = It;
|
|
1200
|
-
const at = [], se = B(E, "showMasterSp") !== !1 && B(z, "showMasterSp") !== !1;
|
|
1201
|
-
F.master && se && at.push(...nt(F.master.tree, F.master, F, gt, 0, !1)), F.layout && B(E, "showMasterSp") !== !1 && at.push(...nt(F.layout.tree, F.layout, F, gt, 0, !1)), at.push(...nt(F.slide.tree, F.slide, F, gt, 0, !0)), N.push({ items: at, background: It, transition: Je(E), name: w(l(E, "cSld"), "name") || void 0, notes: Qe(c, T), key: T });
|
|
1202
|
-
}), N.length || o("The presentation has no slides.");
|
|
1203
|
-
const P = R(c.xml("docProps/core.xml"), "title")?.textContent || void 0;
|
|
1204
|
-
return { deck: { width: m, height: g, slides: N, title: P }, warnings: e };
|
|
1205
|
-
}
|
|
1206
|
-
const en = 80, nn = "default-layer", D = (t) => {
|
|
1207
|
-
if (!t) return "transparent";
|
|
1208
|
-
if (t.alpha === void 0 || t.alpha >= 0.999) return t.hex;
|
|
1209
|
-
const n = t.hex.replace("#", "");
|
|
1210
|
-
return `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${+t.alpha.toFixed(3)})`;
|
|
1211
|
-
}, on = /(times|georgia|garamond|cambria|book|serif|palatino|baskerville|merriweather)/i, sn = /(courier|consolas|mono|menlo|code)/i;
|
|
1212
|
-
function Xt(t) {
|
|
1213
|
-
if (!t) return "sans-serif";
|
|
1214
|
-
const n = de(t);
|
|
1215
|
-
return n || (sn.test(t) ? "monospace" : on.test(t) ? "serif" : "sans-serif");
|
|
1216
|
-
}
|
|
1217
|
-
function rn(t) {
|
|
1218
|
-
const n = [];
|
|
1219
|
-
let e = [], o = !1;
|
|
1220
|
-
const s = () => {
|
|
1221
|
-
if (e.length >= 2) {
|
|
1222
|
-
const r = e[0], a = e[e.length - 1];
|
|
1223
|
-
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 });
|
|
1224
|
-
}
|
|
1225
|
-
e = [], o = !1;
|
|
1226
|
-
};
|
|
1227
|
-
for (const r of t)
|
|
1228
|
-
if (r.op === "M")
|
|
1229
|
-
s(), e.push({ x: r.x, y: r.y, kind: "corner" });
|
|
1230
|
-
else if (r.op === "L")
|
|
1231
|
-
e.length ? e.push({ x: r.x, y: r.y, kind: "corner" }) : e.push({ x: r.x, y: r.y, kind: "corner" });
|
|
1232
|
-
else if (r.op === "C") {
|
|
1233
|
-
const a = e[e.length - 1];
|
|
1234
|
-
if (!a) {
|
|
1235
|
-
e.push({ x: r.x, y: r.y, kind: "corner" });
|
|
1236
|
-
continue;
|
|
1237
|
-
}
|
|
1238
|
-
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" });
|
|
1239
|
-
} else r.op === "Z" && (o = !0, s());
|
|
1240
|
-
return s(), n;
|
|
1241
|
-
}
|
|
1242
|
-
const an = (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 });
|
|
1243
|
-
function ln(t, n) {
|
|
1244
|
-
if (!t) return null;
|
|
1245
|
-
if (t.kind === "url") return t.url;
|
|
1246
|
-
if (t.kind === "action") return fe(t.action);
|
|
1247
|
-
const e = n.slideIds?.get(t.key);
|
|
1248
|
-
return e ? ue(e) : null;
|
|
1249
|
-
}
|
|
1250
|
-
async function cn(t) {
|
|
1251
|
-
if (!(typeof document > "u"))
|
|
1252
|
-
try {
|
|
1253
|
-
const n = new Image();
|
|
1254
|
-
n.src = t, await n.decode();
|
|
1255
|
-
const e = document.createElement("canvas");
|
|
1256
|
-
e.width = Math.max(1, Math.min(8192, n.naturalWidth)), e.height = Math.max(1, Math.min(8192, n.naturalHeight));
|
|
1257
|
-
const o = e.getContext("2d");
|
|
1258
|
-
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;
|
|
1259
|
-
} catch {
|
|
1260
|
-
return;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
async function fn(t, n) {
|
|
1264
|
-
const e = /* @__PURE__ */ new Set(), o = (r) => {
|
|
1265
|
-
for (const a of r)
|
|
1266
|
-
if (a.kind === "group") o(a.children);
|
|
1267
|
-
else if (a.kind === "picture" && a.grayscale) {
|
|
1268
|
-
const i = n.get(a.media)?.url;
|
|
1269
|
-
i && e.add(i);
|
|
1270
|
-
} else if (a.kind === "shape" && a.fill.kind === "image" && a.fill.grayscale) {
|
|
1271
|
-
const i = n.get(a.fill.media)?.url;
|
|
1272
|
-
i && e.add(i);
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
t.slides.forEach((r) => o(r.items));
|
|
1276
|
-
const s = /* @__PURE__ */ new Map();
|
|
1277
|
-
return await Promise.all([...e].map(async (r) => {
|
|
1278
|
-
const a = await cn(r);
|
|
1279
|
-
a && s.set(r, a);
|
|
1280
|
-
})), s;
|
|
1281
|
-
}
|
|
1282
|
-
async function un(t, n, e, o) {
|
|
1283
|
-
if (!(typeof document > "u"))
|
|
1284
|
-
try {
|
|
1285
|
-
const s = new Image();
|
|
1286
|
-
s.src = t, await s.decode();
|
|
1287
|
-
const r = document.createElement("canvas");
|
|
1288
|
-
r.width = Math.max(1, Math.min(4096, Math.round(n))), r.height = Math.max(1, Math.min(4096, Math.round(e)));
|
|
1289
|
-
const a = r.getContext("2d");
|
|
1290
|
-
if (!a) return;
|
|
1291
|
-
if (o) {
|
|
1292
|
-
const i = a.createPattern(s, "repeat");
|
|
1293
|
-
if (!i) return;
|
|
1294
|
-
i.setTransform(new DOMMatrix().scale(o.sx, o.sy)), a.fillStyle = i, a.fillRect(0, 0, r.width, r.height);
|
|
1295
|
-
} else {
|
|
1296
|
-
if (Math.abs(s.naturalWidth / s.naturalHeight - n / e) < 0.01) return;
|
|
1297
|
-
a.drawImage(s, 0, 0, r.width, r.height);
|
|
1298
|
-
}
|
|
1299
|
-
return r.toDataURL(o ? "image/png" : "image/jpeg", 0.92);
|
|
1300
|
-
} catch {
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function Z(t, n, e, o) {
|
|
1305
|
-
return {
|
|
1306
|
-
id: t.nextId(n),
|
|
1307
|
-
type: n,
|
|
1308
|
-
x: e.x + t.ox,
|
|
1309
|
-
y: e.y + t.oy,
|
|
1310
|
-
width: Math.max(e.w, 1),
|
|
1311
|
-
height: Math.max(e.h, 1),
|
|
1312
|
-
angle: e.rot ? e.rot * Math.PI / 180 : 0,
|
|
1313
|
-
flipX: e.flipH || void 0,
|
|
1314
|
-
flipY: e.flipV || void 0,
|
|
1315
|
-
strokeColor: "transparent",
|
|
1316
|
-
backgroundColor: "transparent",
|
|
1317
|
-
fillStyle: "solid",
|
|
1318
|
-
strokeWidth: 0,
|
|
1319
|
-
strokeStyle: "solid",
|
|
1320
|
-
roughness: 0,
|
|
1321
|
-
renderStyle: "architectural",
|
|
1322
|
-
opacity: 100,
|
|
1323
|
-
seed: 1,
|
|
1324
|
-
locked: !1,
|
|
1325
|
-
layerId: nn,
|
|
1326
|
-
groupIds: [...o].reverse(),
|
|
1327
|
-
// innermost first, the store's convention
|
|
1328
|
-
name: e.name
|
|
1329
|
-
};
|
|
1330
|
-
}
|
|
1331
|
-
function Ht(t, n, e) {
|
|
1332
|
-
switch (n.kind) {
|
|
1333
|
-
case "none":
|
|
1334
|
-
t.backgroundColor = "transparent";
|
|
1335
|
-
break;
|
|
1336
|
-
case "solid":
|
|
1337
|
-
t.backgroundColor = D(n.color), t.fillStyle = "solid";
|
|
1338
|
-
break;
|
|
1339
|
-
case "linear":
|
|
1340
|
-
case "radial":
|
|
1341
|
-
t.fillStyle = n.kind, t.backgroundColor = D(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: D(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
|
|
1342
|
-
break;
|
|
1343
|
-
case "pattern": {
|
|
1344
|
-
t.backgroundColor = D(n.color), t.fillStyle = "pattern", t.patternFill = Mn(n.preset, D(n.color), n.bg ? D(n.bg) : "transparent");
|
|
1345
|
-
break;
|
|
1346
|
-
}
|
|
1347
|
-
case "image": {
|
|
1348
|
-
const o = e.images.get(n.media);
|
|
1349
|
-
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);
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
function kt(t, n) {
|
|
1355
|
-
if (!n || !(n.width > 0)) {
|
|
1356
|
-
t.strokeColor = "transparent", t.strokeWidth = 0;
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
t.strokeColor = D(n.color), t.strokeWidth = Math.max(0.5, n.width), t.strokeStyle = n.dash === "sysDot" ? "dotted" : n.dash ? "dashed" : "solid", (n.join === "miter" || n.join === "bevel") && (t.strokeLineJoin = n.join), n.cap === "flat" ? t.strokeLineCap = "butt" : n.cap === "sq" && (t.strokeLineCap = "square");
|
|
1360
|
-
}
|
|
1361
|
-
function dn(t) {
|
|
1362
|
-
const n = /^(alphaLc|alphaUc|arabic|romanLc|romanUc)(ParenBoth|ParenR|Period|Plain)$/.exec(t ?? "");
|
|
1363
|
-
if (!n) return {};
|
|
1364
|
-
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 = {};
|
|
1365
|
-
return e && (s.listNumberStyle = e), o && (s.listNumberSuffix = o), s;
|
|
1366
|
-
}
|
|
1367
|
-
function hn(t, n) {
|
|
1368
|
-
const e = t.bullet === "num" ? dn(t.numType) : t.bulletChar ? { listMarker: t.bulletChar } : {}, o = t.runs.find((s) => !s.br)?.color ?? n.defaults?.color;
|
|
1369
|
-
return t.bulletColor && D(t.bulletColor) !== D(o) && (e.listMarkerColor = D(t.bulletColor)), t.bulletScale && (e.listMarkerScale = Math.round(t.bulletScale * 100) / 100), t.marL !== void 0 && (e.listIndent = Math.max(0, Math.round(t.marL * 10) / 10), e.listMarkerIndent = Math.max(0, Math.round((t.marL + (t.indent ?? 0)) * 10) / 10)), e;
|
|
1370
|
-
}
|
|
1371
|
-
const bt = (t, n) => Math.round(((t.paragraphs[n - 1]?.spaceAfter ?? 0) + (t.paragraphs[n]?.spaceBefore ?? 0)) * 100) / 100;
|
|
1372
|
-
function te(t, n) {
|
|
1373
|
-
const e = t.paragraphs.flatMap((h) => h.runs.filter((y) => !y.br)), o = e[0], s = o?.size ?? 24, r = /* @__PURE__ */ new Map(), a = (h) => h.runs.reduce((y, d) => y + (d.br ? 0 : d.text.trim().length), 0);
|
|
1374
|
-
for (const h of t.paragraphs) {
|
|
1375
|
-
const y = a(h);
|
|
1376
|
-
y && r.set(h.align ?? "l", (r.get(h.align ?? "l") ?? 0) + y);
|
|
1377
|
-
}
|
|
1378
|
-
const i = [...r].sort((h, y) => y[1] - h[1])[0]?.[0] ?? t.paragraphs.find((h) => h.runs.length)?.align ?? "l", c = (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 && D(h.color) === D(o?.color)) && !t.paragraphs.some((h) => h.bullet) && !t.paragraphs.some((h, y) => y > 0 && bt(t, y) > 0) && !t.paragraphs.some(c), b = {
|
|
1379
|
-
fontSize: Math.round(s * 10) / 10,
|
|
1380
|
-
fontFamily: Xt(o?.font),
|
|
1381
|
-
textAlign: i === "ctr" ? "center" : i === "r" ? "right" : "left",
|
|
1382
|
-
verticalAlign: t.anchor === "ctr" ? "middle" : t.anchor === "b" ? "bottom" : "top",
|
|
1383
|
-
textColor: D(o?.color ?? { hex: "#000000" })
|
|
1384
|
-
};
|
|
1385
|
-
t.lineSpacing && Math.abs(t.lineSpacing - 1) > 0.01 && (b.lineHeight = Math.max(0.5, Math.min(4, t.lineSpacing * 1.2)));
|
|
1386
|
-
const f = t.paragraphs.map((h) => h.runs.map((y) => y.br ? `
|
|
1387
|
-
` : y.text).join("")).join(`
|
|
1388
|
-
`);
|
|
1389
|
-
if (x)
|
|
1390
|
-
return o?.bold && (b.fontWeight = 700), o?.italic && (b.fontStyle = "italic"), n ? b.containerText = f : b.text = f, { fields: b, rich: !1 };
|
|
1391
|
-
const m = [], g = [], u = [];
|
|
1392
|
-
return t.paragraphs.forEach((h, y) => {
|
|
1393
|
-
const d = h.level ?? 0;
|
|
1394
|
-
if (h.bullet === "num") {
|
|
1395
|
-
const M = h.numType ?? "arabicPeriod";
|
|
1396
|
-
(g[d] === void 0 || u[d] !== M) && (g[d] = (h.startAt ?? 1) - 1), g[d]++, u[d] = M, g.length = d + 1, u.length = d + 1;
|
|
1397
|
-
} else
|
|
1398
|
-
g.length = Math.min(g.length, d), u.length = g.length;
|
|
1399
|
-
const p = h.bullet ? { listType: h.bullet === "num" ? "ordered" : "bullet", listLevel: d, ...hn(h, t) } : {};
|
|
1400
|
-
h.bullet === "num" && (p.listIndex = g[d]), (h.runs.length ? h.runs : [{ text: "" }]).forEach((M, S) => {
|
|
1401
|
-
const v = { text: M.br ? `
|
|
1402
|
-
` : M.text, ...S === 0 ? p : {} };
|
|
1403
|
-
S === 0 && y > 0 && bt(t, y) > 0 && (v.paragraphSpaceBefore = bt(t, y));
|
|
1404
|
-
const N = c(h);
|
|
1405
|
-
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 = D(M.color)), M.size && (v.fontSize = Math.round(M.size * 10) / 10), M.font && (v.fontFamily = Xt(M.font)), m.push(v);
|
|
1406
|
-
}), y < t.paragraphs.length - 1 && m.push({ text: `
|
|
1407
|
-
` });
|
|
1408
|
-
}), n ? (b.richContainerText = m, b.containerText = f) : (b.richText = m, b.text = f), { fields: b, rich: !0 };
|
|
1409
|
-
}
|
|
1410
|
-
function yt(t, n, e, o, s) {
|
|
1411
|
-
const { fields: r, rich: a } = te(n, !1), i = 4, c = Z(t, a ? "richtext" : "text", {
|
|
1412
|
-
...e,
|
|
1413
|
-
x: e.x + n.insets.l - i,
|
|
1414
|
-
y: e.y + n.insets.t - i,
|
|
1415
|
-
w: Math.max(e.w - n.insets.l - n.insets.r + i * 2, 8),
|
|
1416
|
-
h: Math.max(e.h - n.insets.t - n.insets.b + i * 2, 8)
|
|
1417
|
-
}, o);
|
|
1418
|
-
return Object.assign(c, r, { autoResize: !n.wrap, strokeColor: r.textColor }), c;
|
|
1419
|
-
}
|
|
1420
|
-
const ee = /* @__PURE__ */ new Set(["line", "straightConnector1"]);
|
|
1421
|
-
function ne(t, n, e) {
|
|
1422
|
-
const o = t.geom;
|
|
1423
|
-
if (t.text && t.fill.kind === "none" && !t.line && (t.textBox || o.kind === "preset" && o.prst === "rect"))
|
|
1424
|
-
return n.stats.elements++, [yt(n, t.text, t, e)];
|
|
1425
|
-
if (o.kind === "preset" && ee.has(o.prst)) return wt({ ...t, kind: "connector", line: t.line ?? { width: 1, color: { hex: "#000000" } } }, n, e);
|
|
1426
|
-
if (o.kind === "custom" && t.line && (t.line.head || t.line.tail) && !t.text && o.paths.every((f) => !f.cmds.some((m) => m.op === "Z")))
|
|
1427
|
-
return wt({ ...t, kind: "connector", line: t.line }, n, e);
|
|
1428
|
-
const s = mn(t);
|
|
1429
|
-
if (s) {
|
|
1430
|
-
const f = Z(n, s.type, t, e);
|
|
1431
|
-
Object.assign(f, s.extra), Ht(f, t.fill, n), kt(f, t.line), n.byPptId.set(t.id, { el: f, item: t }), n.stats.elements++;
|
|
1432
|
-
const m = t.textRect ?? { l: 0, t: 0, r: t.w, b: t.h }, g = t.text?.insets, u = 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;
|
|
1433
|
-
if (t.text && (u || h)) {
|
|
1434
|
-
const y = n.nextId("group");
|
|
1435
|
-
return f.groupIds = [...e, y].reverse(), n.stats.elements++, [f, yt(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])];
|
|
1436
|
-
}
|
|
1437
|
-
if (t.text) {
|
|
1438
|
-
const { fields: y } = te(t.text, !0);
|
|
1439
|
-
Object.assign(f, y);
|
|
1440
|
-
}
|
|
1441
|
-
return [f];
|
|
1442
|
-
}
|
|
1443
|
-
const r = o.kind === "custom" ? o.paths : (() => {
|
|
1444
|
-
const f = n.presets[o.prst];
|
|
1445
|
-
if (!f)
|
|
1446
|
-
return n.warnings.push(`Unknown shape "${o.prst}" was imported as a rectangle.`), lt(n.presets.rect, t.w, t.h);
|
|
1447
|
-
const m = Object.fromEntries(Object.entries(o.adj ?? {}).map(([g, u]) => [g, `val ${u}`]));
|
|
1448
|
-
return lt(f, t.w, t.h, m);
|
|
1449
|
-
})(), a = [], i = (t.text || r.some((f) => f.fill === !1)) && r.some((f) => f.fill !== !1) ? n.nextId("group") : null, c = i ? [...e, i] : e, x = /* @__PURE__ */ new Map();
|
|
1450
|
-
for (const f of r) {
|
|
1451
|
-
const m = `${f.fill === !1 ? "nofill" : "fill"}|${f.stroke === !1 ? "nostroke" : "stroke"}`;
|
|
1452
|
-
x.has(m) || x.set(m, []), x.get(m).push(f);
|
|
1453
|
-
}
|
|
1454
|
-
let b = null;
|
|
1455
|
-
for (const [f, m] of x) {
|
|
1456
|
-
const g = m.flatMap((p) => p.cmds), u = le(g);
|
|
1457
|
-
if (!u) continue;
|
|
1458
|
-
const h = rn(an(g, -u.minX, -u.minY));
|
|
1459
|
-
if (!h.length) continue;
|
|
1460
|
-
const y = Z(n, "path", { ...t, x: t.x + u.minX, y: t.y + u.minY, w: Math.max(u.maxX - u.minX, 1), h: Math.max(u.maxY - u.minY, 1) }, c);
|
|
1461
|
-
!(Math.abs(u.minX + u.maxX - t.w) < 0.5 && Math.abs(u.minY + u.maxY - t.h) < 0.5) && (t.rot || t.flipH || t.flipV) && pn(y, h, t, u), y.pathSubpaths = h, y.pathAnchors = h[0].anchors, y.pathClosed = h[0].closed, f.startsWith("fill") ? Ht(y, t.fill, n) : y.backgroundColor = "transparent", f.endsWith("|stroke") ? kt(y, t.line) : (y.strokeColor = "transparent", y.strokeWidth = 0), a.push(y), b ??= y, n.stats.paths++;
|
|
1462
|
-
}
|
|
1463
|
-
if (b && n.byPptId.set(t.id, { el: b, item: t }), t.text) {
|
|
1464
|
-
const f = t.textRect ?? (o.kind === "preset" && n.presets[o.prst] ? Ut(n.presets[o.prst], t.w, t.h) : { l: 0, t: 0, r: t.w, b: t.h });
|
|
1465
|
-
a.push(yt(n, t.text, { ...t, x: t.x + f.l, y: t.y + f.t, w: f.r - f.l, h: f.b - f.t }, c));
|
|
1466
|
-
}
|
|
1467
|
-
return n.stats.elements += a.length, a;
|
|
1468
|
-
}
|
|
1469
|
-
function pn(t, n, e, o) {
|
|
1470
|
-
const s = e.w / 2, r = e.h / 2, a = (e.rot || 0) * Math.PI / 180, i = Math.cos(a), c = Math.sin(a), x = e.flipH ? -1 : 1, b = e.flipV ? -1 : 1, f = (d, p) => {
|
|
1471
|
-
const k = (d + o.minX - s) * x, M = (p + o.minY - r) * b;
|
|
1472
|
-
return { x: s + k * i - M * c, y: r + k * c + M * i };
|
|
1473
|
-
}, m = (d, p) => {
|
|
1474
|
-
const k = d * x, M = p * b;
|
|
1475
|
-
return { x: k * i - M * c, y: k * c + M * i };
|
|
1476
|
-
};
|
|
1477
|
-
let g = 1 / 0, u = 1 / 0, h = -1 / 0, y = -1 / 0;
|
|
1478
|
-
for (const d of n) for (const p of d.anchors) {
|
|
1479
|
-
const k = f(p.x, p.y);
|
|
1480
|
-
if (p.x = k.x, p.y = k.y, p.inX !== void 0) {
|
|
1481
|
-
const M = m(p.inX, p.inY ?? 0);
|
|
1482
|
-
p.inX = M.x, p.inY = M.y;
|
|
1483
|
-
}
|
|
1484
|
-
if (p.outX !== void 0) {
|
|
1485
|
-
const M = m(p.outX, p.outY ?? 0);
|
|
1486
|
-
p.outX = M.x, p.outY = M.y;
|
|
1487
|
-
}
|
|
1488
|
-
g = Math.min(g, p.x), u = Math.min(u, p.y), h = Math.max(h, p.x), y = Math.max(y, p.y);
|
|
1489
|
-
}
|
|
1490
|
-
for (const d of n) for (const p of d.anchors)
|
|
1491
|
-
p.x -= g, p.y -= u;
|
|
1492
|
-
t.x = t.x - o.minX + g, t.y = t.y - o.minY + u, t.width = Math.max(h - g, 1), t.height = Math.max(y - u, 1), t.angle = 0, t.flipX = void 0, t.flipY = void 0;
|
|
1493
|
-
}
|
|
1494
|
-
function mn(t) {
|
|
1495
|
-
const n = t.geom;
|
|
1496
|
-
if (n.kind !== "preset") return null;
|
|
1497
|
-
const e = n.adj ?? {};
|
|
1498
|
-
switch (n.prst) {
|
|
1499
|
-
case "rect":
|
|
1500
|
-
return { type: "rectangle", extra: { borderRadius: 0 } };
|
|
1501
|
-
case "roundRect":
|
|
1502
|
-
return { type: "rectangle", extra: { borderRadius: Math.max(0, Math.min(50, (e.adj ?? 16667) / 1e3)) } };
|
|
1503
|
-
case "ellipse":
|
|
1504
|
-
return { type: "circle", extra: {} };
|
|
1505
|
-
case "diamond":
|
|
1506
|
-
return { type: "diamond", extra: { borderRadius: 0 } };
|
|
1507
|
-
case "triangle":
|
|
1508
|
-
return (e.adj ?? 5e4) === 5e4 ? { type: "triangle", extra: {} } : null;
|
|
1509
|
-
default:
|
|
1510
|
-
return null;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
const Yt = { triangle: "triangle", stealth: "arrow", arrow: "arrow", oval: "dot", diamond: "diamondFilled" };
|
|
1514
|
-
function wt(t, n, e) {
|
|
1515
|
-
const o = t.geom;
|
|
1516
|
-
let s;
|
|
1517
|
-
if (o.kind === "preset" && ee.has(o.prst)) s = [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
|
|
1518
|
-
else if (o.kind === "custom") s = o.paths.flatMap((k) => k.cmds);
|
|
1519
|
-
else {
|
|
1520
|
-
const k = n.presets[o.prst], M = Object.fromEntries(Object.entries(o.adj ?? {}).map(([S, v]) => [S, `val ${v}`]));
|
|
1521
|
-
s = k ? lt(k, t.w, t.h, M).flatMap((S) => S.cmds) : [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
|
|
1522
|
-
}
|
|
1523
|
-
const r = t.w / 2, a = t.h / 2, i = (t.rot || 0) * Math.PI / 180, c = (k, M) => {
|
|
1524
|
-
let S = k - r, v = M - a;
|
|
1525
|
-
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) };
|
|
1526
|
-
}, x = [];
|
|
1527
|
-
let b = { x: 0, y: 0 };
|
|
1528
|
-
for (const k of s)
|
|
1529
|
-
if (k.op === "M" || k.op === "L")
|
|
1530
|
-
b = { x: k.x, y: k.y }, x.push(c(b.x, b.y));
|
|
1531
|
-
else if (k.op === "C") {
|
|
1532
|
-
for (let M = 1; M <= 12; M++) {
|
|
1533
|
-
const S = M / 12, v = 1 - S, N = v * v * v * b.x + 3 * v * v * S * k.x1 + 3 * v * S * S * k.x2 + S * S * S * k.x, P = v * v * v * b.y + 3 * v * v * S * k.y1 + 3 * v * S * S * k.y2 + S * S * S * k.y;
|
|
1534
|
-
x.push(c(N, P));
|
|
1535
|
-
}
|
|
1536
|
-
b = { x: k.x, y: k.y };
|
|
1537
|
-
}
|
|
1538
|
-
if (x.length < 2) return [];
|
|
1539
|
-
const f = Math.min(...x.map((k) => k.x)), m = Math.min(...x.map((k) => k.y)), g = Math.max(...x.map((k) => k.x)), u = Math.max(...x.map((k) => k.y)), h = t.line.head && Yt[t.line.head.type], y = t.line.tail && Yt[t.line.tail.type], d = Z(n, h || y ? "arrow" : "line", { ...t, x: f, y: m, w: Math.max(g - f, 1), h: Math.max(u - m, 1), rot: 0, flipH: !1, flipV: !1 }, e);
|
|
1540
|
-
d.points = x.map((k) => ({ x: k.x - f, y: k.y - m })), d.curveType = "straight", d.startArrowhead = h ?? null, d.endArrowhead = y ?? null, kt(d, t.line);
|
|
1541
|
-
const p = (k, M) => {
|
|
1542
|
-
if (!k) return null;
|
|
1543
|
-
const S = n.byPptId.get(k.id);
|
|
1544
|
-
if (!S || !S.el.width || !S.el.height) return null;
|
|
1545
|
-
const v = S.el;
|
|
1546
|
-
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 };
|
|
1547
|
-
};
|
|
1548
|
-
return n.glue.push(() => {
|
|
1549
|
-
d.startBinding = p(t.start, x[0]), d.endBinding = p(t.end, x[x.length - 1]);
|
|
1550
|
-
}), n.stats.elements++, [d];
|
|
1551
|
-
}
|
|
1552
|
-
function gn(t, n, e) {
|
|
1553
|
-
const o = n.images.get(t.media);
|
|
1554
|
-
if (!o) {
|
|
1555
|
-
n.warnings.push(`Picture "${t.name}" is a ${t.media.ext.toUpperCase()} image, which browsers can't show; it was imported as a placeholder.`);
|
|
1556
|
-
const c = Z(n, "rectangle", t, e);
|
|
1557
|
-
return Object.assign(c, { backgroundColor: "#f1f3f5", strokeColor: "#adb5bd", strokeWidth: 1, strokeStyle: "dashed", containerText: `${t.media.ext.toUpperCase()} picture`, fontSize: 14, textColor: "#495057" }), n.stats.elements++, [c];
|
|
1558
|
-
}
|
|
1559
|
-
const s = Z(n, "image", t, e);
|
|
1560
|
-
if (s.dataURL = t.grayscale && n.gray.get(o.url) || o.url, s.status = "loaded", s.mimeType = Mt[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];
|
|
1561
|
-
const r = n.nextId("group"), a = ne({
|
|
1562
|
-
kind: "shape",
|
|
1563
|
-
id: t.id,
|
|
1564
|
-
name: `${t.name} outline`,
|
|
1565
|
-
x: t.x,
|
|
1566
|
-
y: t.y,
|
|
1567
|
-
w: t.w,
|
|
1568
|
-
h: t.h,
|
|
1569
|
-
rot: t.rot,
|
|
1570
|
-
flipH: t.flipH,
|
|
1571
|
-
flipV: t.flipV,
|
|
1572
|
-
geom: t.geom,
|
|
1573
|
-
fill: { kind: "solid", color: { hex: "#000000" } },
|
|
1574
|
-
line: null
|
|
1575
|
-
}, n, [...e, r]);
|
|
1576
|
-
if (a.length !== 1)
|
|
1577
|
-
return n.stats.elements -= a.length, [s];
|
|
1578
|
-
const i = a[0];
|
|
1579
|
-
return i.isClipMask = !0, s.groupIds = [r, ...s.groupIds], s.clipMaskId = i.id, s.maskType = "clip", [s, i];
|
|
1580
|
-
}
|
|
1581
|
-
function oe(t, n, e) {
|
|
1582
|
-
const o = [];
|
|
1583
|
-
for (const s of t)
|
|
1584
|
-
try {
|
|
1585
|
-
const r = [];
|
|
1586
|
-
switch (s.kind) {
|
|
1587
|
-
case "shape":
|
|
1588
|
-
r.push(...ne(s, n, e));
|
|
1589
|
-
break;
|
|
1590
|
-
case "connector":
|
|
1591
|
-
r.push(...wt(s, n, e));
|
|
1592
|
-
break;
|
|
1593
|
-
case "picture":
|
|
1594
|
-
r.push(...gn(s, n, e));
|
|
1595
|
-
break;
|
|
1596
|
-
case "group":
|
|
1597
|
-
r.push(...oe(s.children, n, [...e, n.nextId("group")]));
|
|
1598
|
-
break;
|
|
1599
|
-
}
|
|
1600
|
-
const a = ln(s.link, n);
|
|
1601
|
-
if (a)
|
|
1602
|
-
for (const i of r) i.link || (i.link = a);
|
|
1603
|
-
o.push(...r);
|
|
1604
|
-
} catch {
|
|
1605
|
-
n.warnings.push(`"${s.name}" couldn't be converted and was skipped.`);
|
|
1606
|
-
}
|
|
1607
|
-
return o;
|
|
1608
|
-
}
|
|
1609
|
-
function xn(t) {
|
|
1610
|
-
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;
|
|
1611
|
-
}
|
|
1612
|
-
function bn(t, n, e) {
|
|
1613
|
-
if (n)
|
|
1614
|
-
if (n.kind === "solid")
|
|
1615
|
-
t.fillStyle = "solid", t.backgroundColor = D(n.color);
|
|
1616
|
-
else if (n.kind === "linear" || n.kind === "radial")
|
|
1617
|
-
t.fillStyle = n.kind, t.backgroundColor = D(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: D(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
|
|
1618
|
-
else if (n.kind === "image") {
|
|
1619
|
-
const o = e.images.get(n.media), s = e.slideBg ?? o?.url;
|
|
1620
|
-
s && (t.fillStyle = "image", t.backgroundImage = s, t.backgroundColor = "#ffffff"), s && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
|
|
1621
|
-
} else n.kind === "pattern" && (t.fillStyle = "solid", t.backgroundColor = D(n.color));
|
|
1622
|
-
}
|
|
1623
|
-
const Mt = {
|
|
1624
|
-
png: "image/png",
|
|
1625
|
-
jpeg: "image/jpeg",
|
|
1626
|
-
gif: "image/gif",
|
|
1627
|
-
svg: "image/svg+xml",
|
|
1628
|
-
bmp: "image/bmp",
|
|
1629
|
-
tiff: "image/tiff",
|
|
1630
|
-
webp: "image/webp",
|
|
1631
|
-
emf: "image/x-emf",
|
|
1632
|
-
wmf: "image/x-wmf"
|
|
1633
|
-
}, yn = /* @__PURE__ */ new Set(["png", "jpeg", "gif", "svg", "bmp", "webp"]);
|
|
1634
|
-
function kn(t) {
|
|
1635
|
-
let n = "";
|
|
1636
|
-
for (let o = 0; o < t.length; o += 32768) n += String.fromCharCode(...t.subarray(o, o + 32768));
|
|
1637
|
-
return btoa(n);
|
|
1638
|
-
}
|
|
1639
|
-
async function wn(t) {
|
|
1640
|
-
const n = /* @__PURE__ */ new Set(), e = (s) => {
|
|
1641
|
-
for (const r of s)
|
|
1642
|
-
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);
|
|
1643
|
-
};
|
|
1644
|
-
for (const s of t.slides)
|
|
1645
|
-
e(s.items), s.background?.kind === "image" && n.add(s.background.media);
|
|
1646
|
-
const o = /* @__PURE__ */ new Map();
|
|
1647
|
-
return await Promise.all([...n].map(async (s) => {
|
|
1648
|
-
if (!yn.has(s.ext)) {
|
|
1649
|
-
o.set(s, null);
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
const r = `data:${Mt[s.ext]};base64,${kn(s.bytes)}`;
|
|
1653
|
-
let a = 0, i = 0;
|
|
1654
|
-
try {
|
|
1655
|
-
const c = await createImageBitmap(new Blob([s.bytes], { type: Mt[s.ext] }));
|
|
1656
|
-
a = c.width, i = c.height, c.close();
|
|
1657
|
-
} catch {
|
|
1658
|
-
}
|
|
1659
|
-
o.set(s, { url: r, w: a, h: i });
|
|
1660
|
-
})), o;
|
|
1661
|
-
}
|
|
1662
|
-
function Mn(t, n, e) {
|
|
1663
|
-
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);
|
|
1664
|
-
if (a) {
|
|
1665
|
-
const i = Math.max(1, Math.min(99, Number(a[1]))), c = i > 50, x = (c ? 100 - i : i) / 100;
|
|
1666
|
-
return { type: "dots", color: c ? e : n, background: c ? n : e, spacing: 4, strokeWidth: Math.max(0.5, 4 * Math.sqrt(x / Math.PI)) };
|
|
1667
|
-
}
|
|
1668
|
-
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 };
|
|
1669
|
-
}
|
|
1670
|
-
async function vn(t, n, e) {
|
|
1671
|
-
const o = await ye(), s = await wn(t), r = Math.round(t.width), a = Math.round(t.height), i = ce(e ?? t.title, "slides", { width: r, height: a }), c = [], x = { slides: 0, elements: 0, pictures: 0, paths: 0 };
|
|
1672
|
-
i.slides = [];
|
|
1673
|
-
const b = await fn(t, s), f = await Promise.all(t.slides.map((u) => {
|
|
1674
|
-
const h = u.background, y = h?.kind === "image" ? s.get(h.media) : void 0;
|
|
1675
|
-
return h?.kind === "image" && y ? un(y.url, r, a, h.tile) : void 0;
|
|
1676
|
-
})), m = t.slides.map(() => n("slide")), g = /* @__PURE__ */ new Map();
|
|
1677
|
-
return t.slides.forEach((u, h) => {
|
|
1678
|
-
u.key && g.set(u.key, m[h]);
|
|
1679
|
-
}), t.slides.forEach((u, h) => {
|
|
1680
|
-
const y = h * (r + en), d = Nt(m[h], u.name || `Slide ${h + 1}`, y, 0, { width: r, height: a });
|
|
1681
|
-
d.order = h;
|
|
1682
|
-
const p = { ox: y, oy: 0, presets: o, nextId: n, out: [], byPptId: /* @__PURE__ */ new Map(), glue: [], warnings: c, stats: x, images: s, slideBg: f[h], gray: b, slideIds: g };
|
|
1683
|
-
i.elements.push(...oe(u.items, p, [])), p.glue.forEach((M) => M()), bn(d, u.background, p);
|
|
1684
|
-
const k = xn(u.transition);
|
|
1685
|
-
k && (d.transition = k), u.notes && (d.notes = u.notes), i.slides.push(d), x.slides++;
|
|
1686
|
-
}), i.slides.length || i.slides.push(Nt(void 0, "Slide 1", 0, 0, { width: r, height: a })), { doc: i, warnings: [...new Set(c)], stats: x };
|
|
1687
|
-
}
|
|
1688
|
-
const Sn = 512 * 1024 * 1024;
|
|
1689
|
-
async function In(t, n) {
|
|
1690
|
-
const e = t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(await t.arrayBuffer());
|
|
1691
|
-
if (e.length > Sn) throw new Error("This presentation is too large to open (over 512 MB).");
|
|
1692
|
-
const { deck: o, warnings: s } = tn(e), r = /* @__PURE__ */ new Set(), a = await vn(o, (c) => pe(c, r), n);
|
|
1693
|
-
he(a.doc);
|
|
1694
|
-
const i = [...s, ...a.warnings];
|
|
1695
|
-
return i.length && console.warn("[pptx import]", i), { stats: a.stats, warnings: i };
|
|
1696
|
-
}
|
|
1697
|
-
export {
|
|
1698
|
-
In as importPptx
|
|
1699
|
-
};
|